Skip to content

Commit e3ceb73

Browse files
committed
snis_server: if you join the wrong system, redirect to the right one
as if going through a warp gate. Signed-off-by: Stephen M. Cameron <[email protected]>
1 parent 040d828 commit e3ceb73

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

snis_client.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,7 @@ static void format_date(char *buf, int bufsize, double date)
781781
static int switched_server = -1;
782782
static char switch_server_location_string[20] = { 0 };
783783
static int switch_warp_gate_number = -1;
784+
static int switch_with_redirection = 0;
784785
static int switched_server2 = -1;
785786
static int writer_thread_should_die = 0;
786787
static int writer_thread_alive = 0;
@@ -7303,7 +7304,12 @@ static int process_switch_server(void)
73037304
switch_warp_gate_number = packed_buffer_extract_u8(&pb);
73047305
packed_buffer_extract_raw(&pb, switch_server_location_string, 20);
73057306
switch_server_location_string[19] = '\0';
7306-
enforce_solarsystem = 0; /* get past multiverse solarsystem verification for warp gates */
7307+
if (switch_warp_gate_number != 255) {
7308+
enforce_solarsystem = 0; /* get past multiverse solarsystem verification for warp gates */
7309+
switch_with_redirection = 0;
7310+
} else {
7311+
switch_with_redirection = 1;
7312+
}
73077313
return 0;
73087314
}
73097315

@@ -22473,9 +22479,13 @@ static int main_da_expose(SDL_Window *window)
2247322479
if (!(o = find_my_ship())) {
2247422480
char msg[100];
2247522481
if (how_long_to_wait == -1)
22476-
how_long_to_wait = 4 * frame_rate_hz;
22482+
how_long_to_wait = 2 * frame_rate_hz;
2247722483
if (how_long_to_wait > 0) {
22478-
snprintf(msg, sizeof(msg) - 1,
22484+
if (switch_with_redirection)
22485+
snprintf(msg, sizeof(msg) - 1,
22486+
"WRONG STAR SYSTEM BUDDY, REDIRECTING . . .");
22487+
else
22488+
snprintf(msg, sizeof(msg) - 1,
2247922489
"PREPARE FOR THE JUMP TO LIGHTSPEED, SPACE NERD");
2248022490
how_long_to_wait--;
2248122491
}

snis_server.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25116,18 +25116,26 @@ static void *per_client_write_thread(__attribute__((unused)) void /* struct game
2511625116

2511725117
if (player_error) {
2511825118
pb = packed_buffer_allocate(256);
25119-
packed_buffer_append(pb, "bb", OPCODE_ADD_PLAYER_ERROR, player_error);
2512025119
if (player_error == ADD_PLAYER_ERROR_WRONG_SOLARSYSTEM) {
25120+
#if 0
25121+
/* Tell player the right server */
2512125122
packed_buffer_append_u16(pb,
2512225123
(uint16_t) strlen(bridgelist[c->bridge].resident_solarsystem));
2512325124
packed_buffer_append_raw(pb, bridgelist[c->bridge].resident_solarsystem,
2512425125
strlen(bridgelist[c->bridge].resident_solarsystem));
25126+
#else
25127+
/* Automatically switch the player to the correct server */
25128+
packed_buffer_append(pb, "bb", OPCODE_SWITCH_SERVER, (uint8_t) 255);
25129+
uppercase(bridgelist[c->bridge].resident_solarsystem);
25130+
packed_buffer_append_raw(pb, bridgelist[c->bridge].resident_solarsystem, 20);
25131+
#endif
2512525132
} else {
25133+
packed_buffer_append(pb, "bb", OPCODE_ADD_PLAYER_ERROR, player_error);
2512625134
packed_buffer_append_u16(pb, (uint16_t) 1);
2512725135
packed_buffer_append_raw(pb, "x", 1);
25136+
disconnect_timer = 1.0;
2512825137
}
2512925138
pb_queue_to_client(c, pb);
25130-
disconnect_timer = 1.0;
2513125139
}
2513225140

2513325141
currentTime = time_now_double();

0 commit comments

Comments
 (0)