diff --git a/src/ReceiveCommands.cc b/src/ReceiveCommands.cc index c71588ff..71194571 100644 --- a/src/ReceiveCommands.cc +++ b/src/ReceiveCommands.cc @@ -162,7 +162,10 @@ void on_connect(std::shared_ptr c) { break; } - case ServerBehavior::LOGIN_SERVER: + case ServerBehavior::SUBSEQUENT_LOGIN_SERVER: + c->config.set_flag(Client::Flag::SAVE_ENABLED); + [[fallthrough]]; + case ServerBehavior::INITIAL_LOGIN_SERVER: send_server_init(c, SendServerInitFlag::IS_INITIAL_CONNECTION); break; @@ -259,51 +262,58 @@ static void send_main_menu(shared_ptr c) { void on_login_complete(shared_ptr c) { // On BB, this function is called when the data server phase is done (and we // should send the ship select menu), so we don't need to check for it here. - if (c->server_behavior == ServerBehavior::LOGIN_SERVER) { - auto s = c->require_server_state(); + switch (c->server_behavior) { + case ServerBehavior::INITIAL_LOGIN_SERVER: + case ServerBehavior::SUBSEQUENT_LOGIN_SERVER: { + auto s = c->require_server_state(); + + // On the login server, send the events/songs, ep3 updates, and the main + // menu or welcome message + if (is_ep3(c->version())) { + if (s->ep3_menu_song >= 0) { + send_ep3_change_music(c->channel, s->ep3_menu_song); + } else if (s->pre_lobby_event) { + send_change_event(c, s->pre_lobby_event); + } + + send_ep3_rank_update(c); + send_get_player_info(c); - // On the login server, send the events/songs, ep3 updates, and the main - // menu or welcome message - if (is_ep3(c->version())) { - if (s->ep3_menu_song >= 0) { - send_ep3_change_music(c->channel, s->ep3_menu_song); } else if (s->pre_lobby_event) { send_change_event(c, s->pre_lobby_event); } - send_ep3_rank_update(c); - send_get_player_info(c); - - } else if (s->pre_lobby_event) { - send_change_event(c, s->pre_lobby_event); - } - - if (s->welcome_message.empty() || - c->config.check_flag(Client::Flag::NO_D6) || - !c->config.check_flag(Client::Flag::AT_WELCOME_MESSAGE)) { - c->config.clear_flag(Client::Flag::AT_WELCOME_MESSAGE); - if (send_enable_send_function_call_if_applicable(c)) { - send_update_client_config(c); + if (s->welcome_message.empty() || + c->config.check_flag(Client::Flag::NO_D6) || + !c->config.check_flag(Client::Flag::AT_WELCOME_MESSAGE)) { + c->config.clear_flag(Client::Flag::AT_WELCOME_MESSAGE); + if (send_enable_send_function_call_if_applicable(c)) { + send_update_client_config(c); + } + send_main_menu(c); + } else { + send_message_box(c, s->welcome_message.c_str()); } - send_main_menu(c); - } else { - send_message_box(c, s->welcome_message.c_str()); + break; } - } else if (c->server_behavior == ServerBehavior::LOBBY_SERVER) { + case ServerBehavior::LOBBY_SERVER: + if (c->version() == Version::BB_V4) { + // This implicitly loads the client's account and player data + send_complete_player_bb(c); + c->should_update_play_time = true; + } - if (c->version() == Version::BB_V4) { - // This implicitly loads the client's account and player data - send_complete_player_bb(c); - c->should_update_play_time = true; - } + if (is_ep3(c->version())) { + send_ep3_rank_update(c); + } - if (is_ep3(c->version())) { - send_ep3_rank_update(c); - } + send_lobby_list(c); + send_get_player_info(c); + break; - send_lobby_list(c); - send_get_player_info(c); + default: + break; } } diff --git a/src/SaveFileFormats.hh b/src/SaveFileFormats.hh index bb6c0133..c2bbcc55 100644 --- a/src/SaveFileFormats.hh +++ b/src/SaveFileFormats.hh @@ -100,7 +100,7 @@ struct PSOGCSystemFile { // This field stores the effective time zone offset between the server and // client, in frames. The default value is 1728000, which corresponds to 16 // hours. This is recomputed when the client receives a B1 command. - /* 0008 */ be_uint32_t server_time_delta_frames; + /* 0008 */ be_int32_t server_time_delta_frames; /* 000C */ be_uint16_t udp_behavior; // 0 = auto, 1 = on, 2 = off /* 000E */ be_uint16_t surround_sound_enabled; /* 0010 */ parray event_flags; // Can be set by quest opcode D8 or E8 @@ -125,7 +125,7 @@ struct PSOBBMinimalSystemFile { /* 0004 */ be_int16_t music_volume = 0; /* 0006 */ int8_t sound_volume = 0; /* 0007 */ uint8_t language = 0; - /* 0008 */ be_uint32_t server_time_delta_frames = 1728000; + /* 0008 */ be_int32_t server_time_delta_frames = 1728000; /* 000C */ be_uint16_t udp_behavior = 0; // 0 = auto, 1 = on, 2 = off /* 000E */ be_uint16_t surround_sound_enabled = 0; /* 0010 */ parray event_flags; @@ -691,7 +691,7 @@ struct PSOPCSystemFile { // PSO______COM /* 0004 */ le_int16_t music_volume; /* 0006 */ int8_t sound_volume; /* 0007 */ uint8_t language; - /* 0008 */ le_uint32_t server_time_delta_frames; + /* 0008 */ le_int32_t server_time_delta_frames; /* 000C */ parray unknown_a4; // Last one is always 0x1234? /* 002C */ parray event_flags; /* 012C */ le_uint32_t round1_seed; diff --git a/src/Version.cc b/src/Version.cc index d16816e5..19595611 100644 --- a/src/Version.cc +++ b/src/Version.cc @@ -166,8 +166,10 @@ const char* name_for_enum(ServerBehavior behavior) { switch (behavior) { case ServerBehavior::PC_CONSOLE_DETECT: return "pc_console_detect"; - case ServerBehavior::LOGIN_SERVER: - return "login_server"; + case ServerBehavior::INITIAL_LOGIN_SERVER: + return "initial_login_server"; + case ServerBehavior::SUBSEQUENT_LOGIN_SERVER: + return "subsequent_login_server"; case ServerBehavior::LOBBY_SERVER: return "lobby_server"; case ServerBehavior::PATCH_SERVER_PC: @@ -184,8 +186,12 @@ template <> ServerBehavior enum_for_name(const char* name) { if (!strcasecmp(name, "pc_console_detect")) { return ServerBehavior::PC_CONSOLE_DETECT; - } else if (!strcasecmp(name, "login_server") || !strcasecmp(name, "login") || !strcasecmp(name, "data_server_bb")) { - return ServerBehavior::LOGIN_SERVER; + } else if (!strcasecmp(name, "login_server")) { + throw invalid_argument("the login_server behavior name is not supported; replace it with initial_login_server or subsequent_login_server"); + } else if (!strcasecmp(name, "initial_login_server")) { + return ServerBehavior::INITIAL_LOGIN_SERVER; + } else if (!strcasecmp(name, "subsequent_login_server") || !strcasecmp(name, "data_server_bb")) { + return ServerBehavior::SUBSEQUENT_LOGIN_SERVER; } else if (!strcasecmp(name, "lobby_server") || !strcasecmp(name, "lobby")) { return ServerBehavior::LOBBY_SERVER; } else if (!strcasecmp(name, "patch_server_pc") || !strcasecmp(name, "patch_pc")) { diff --git a/src/Version.hh b/src/Version.hh index 64d3a220..bdac4ffe 100644 --- a/src/Version.hh +++ b/src/Version.hh @@ -109,7 +109,8 @@ uint32_t default_specific_version_for_version(Version version, int64_t sub_versi enum class ServerBehavior { PC_CONSOLE_DETECT = 0, - LOGIN_SERVER, + INITIAL_LOGIN_SERVER, + SUBSEQUENT_LOGIN_SERVER, LOBBY_SERVER, PATCH_SERVER_PC, PATCH_SERVER_BB, diff --git a/system/config.example.json b/system/config.example.json index a3b7cea9..861dd1ea 100644 --- a/system/config.example.json +++ b/system/config.example.json @@ -58,32 +58,32 @@ // Note: It is not an error that no ports appear here with "dc" in their // definitions. DC clients use the same ports as GC clients, and newserv can // tell them apart at the time they connect. - "gc-jp10": [9000, "gc", "login_server"], - "gc-jp11": [9001, "gc", "login_server"], - "gc-jp3te": [9002, "gc", "login_server"], - "gc-jp3": [9003, "gc", "login_server"], - "gc-us12t1": [9064, "gc", "login_server"], + "gc-jp10": [9000, "gc", "initial_login_server"], + "gc-jp11": [9001, "gc", "initial_login_server"], + "gc-jp3te": [9002, "gc", "initial_login_server"], + "gc-jp3": [9003, "gc", "initial_login_server"], + "gc-us12t1": [9064, "gc", "initial_login_server"], "gc-us10": [9100, "pc", "pc_console_detect"], - "gc-us3": [9103, "gc", "login_server"], - "gc-eu10": [9200, "gc", "login_server"], - "gc-eu11": [9201, "gc", "login_server"], - "gc-eu3-50": [9202, "gc", "login_server"], - "gc-eu3-60a": [9203, "gc", "login_server"], - "gc-eu3-60b": [9204, "gc", "login_server"], - "pc": [9300, "pc", "login_server"], + "gc-us3": [9103, "gc", "initial_login_server"], + "gc-eu10": [9200, "gc", "initial_login_server"], + "gc-eu11": [9201, "gc", "initial_login_server"], + "gc-eu3-50": [9202, "gc", "initial_login_server"], + "gc-eu3-60a": [9203, "gc", "initial_login_server"], + "gc-eu3-60b": [9204, "gc", "initial_login_server"], + "pc": [9300, "pc", "initial_login_server"], "pc-patch": [10000, "patch", "patch_server_pc"], "bb-patch": [11000, "patch", "patch_server_bb"], - "bb-init": [12000, "bb", "login_server"], + "bb-init": [12000, "bb", "initial_login_server"], // PSO Xbox tunnels its connections through the Xbox Live service (or, in // modern times, Insignia), and that service determines which port the // connection goes to on the server side. By default, newserv uses 9500 for // PSO Xbox connections, but this is not hardcoded in the client. - "xb-login": [9500, "xb", "login_server"], + "xb-login": [9500, "xb", "initial_login_server"], // Schthack PSOBB uses these ports. // "bb-patch2": [10500, "patch", "patch_server_bb"], - // "bb-init2": [13000, "bb", "login_server"], + // "bb-init2": [13000, "bb", "initial_login_server"], // Ephinea PSOBB uses these ports. Note that 13000 is also used by Schthack // PSOBB, but not for the patch server; this means you unfortunately can't @@ -91,7 +91,7 @@ // may be fixed in the future using a similar technique as the // pc_console_detect behavior, but this isn't implemented yet. // "bb-patch3": [13000, "patch", "patch_server_bb"], - // "bb-init3": [14000, "bb", "login_server"], + // "bb-init3": [14000, "bb", "initial_login_server"], // newserv uses these ports, but there is no external reason that these // numbers were chosen. You can change the port numbers here without any @@ -112,10 +112,10 @@ // - The proxy ports do not need to be defined unless the proxy server is // enabled for the respective version via the ProxyDestinations fields // (below). - "console-login": [5100, "gc", "login_server"], - "pc-login": [5101, "pc", "login_server"], - "xb-login": [5102, "xb", "login_server"], - "xb-lobby": [5105, "xb", "login_server"], + "console-login": [5100, "gc", "subsequent_login_server"], + "pc-login": [5101, "pc", "subsequent_login_server"], + "xb-login": [5102, "xb", "subsequent_login_server"], + "xb-lobby": [5105, "xb", "subsequent_login_server"], "console-lobby": [5110, "gc", "lobby_server"], "pc-lobby": [5111, "pc", "lobby_server"], "bb-lobby": [5112, "bb", "lobby_server"], @@ -124,8 +124,8 @@ "gc-proxy": [5122, "gc", "proxy_server"], "xb-proxy": [5123, "xb", "proxy_server"], "bb-proxy": [5124, "bb", "proxy_server"], - "bb-data1": [12004, "bb", "login_server"], - "bb-data2": [12005, "bb", "login_server"], + "bb-data1": [12004, "bb", "subsequent_login_server"], + "bb-data2": [12005, "bb", "subsequent_login_server"], }, // Where to listen for IP and PPP stack clients. This exists to interface with diff --git a/tests/config.json b/tests/config.json index 95024f5f..5022fe21 100644 --- a/tests/config.json +++ b/tests/config.json @@ -45,29 +45,29 @@ "Episode3FinalRoundMesetaBonus": 300, "PortConfiguration": { - "gc-jp10": [9000, "gc", "login_server"], - "gc-jp11": [9001, "gc", "login_server"], - "gc-jp3te": [9002, "gc", "login_server"], - "gc-jp3": [9003, "gc", "login_server"], - "gc-us12t1": [9064, "gc", "login_server"], + "gc-jp10": [9000, "gc", "initial_login_server"], + "gc-jp11": [9001, "gc", "initial_login_server"], + "gc-jp3te": [9002, "gc", "initial_login_server"], + "gc-jp3": [9003, "gc", "initial_login_server"], + "gc-us12t1": [9064, "gc", "initial_login_server"], "gc-us10": [9100, "pc", "pc_console_detect"], - "gc-us3": [9103, "gc", "login_server"], - "gc-eu10": [9200, "gc", "login_server"], - "gc-eu11": [9201, "gc", "login_server"], - "gc-eu3-50": [9202, "gc", "login_server"], - "gc-eu3-60a": [9203, "gc", "login_server"], - "gc-eu3-60b": [9204, "gc", "login_server"], - "pc": [9300, "pc", "login_server"], - "xb": [9500, "xb", "login_server"], + "gc-us3": [9103, "gc", "initial_login_server"], + "gc-eu10": [9200, "gc", "initial_login_server"], + "gc-eu11": [9201, "gc", "initial_login_server"], + "gc-eu3-50": [9202, "gc", "initial_login_server"], + "gc-eu3-60a": [9203, "gc", "initial_login_server"], + "gc-eu3-60b": [9204, "gc", "initial_login_server"], + "pc": [9300, "pc", "initial_login_server"], + "xb": [9500, "xb", "initial_login_server"], "pc-patch": [10000, "patch", "patch_server_pc"], "bb-patch": [11000, "patch", "patch_server_bb"], - "bb-init": [12000, "bb", "login_server"], + "bb-init": [12000, "bb", "initial_login_server"], "bb-patch2": [10500, "patch", "patch_server_bb"], "bb-proxy2": [9932, "bb", "proxy_server"], - "bb-patch3": [13000, "bb", "login_server"], - "console-login": [5100, "gc", "login_server"], - "pc-login": [5101, "pc", "login_server"], - "xb-login": [5102, "xb", "login_server"], + "bb-patch3": [13000, "bb", "initial_login_server"], + "console-login": [5100, "gc", "subsequent_login_server"], + "pc-login": [5101, "pc", "subsequent_login_server"], + "xb-login": [5102, "xb", "subsequent_login_server"], "console-lobby": [5110, "gc", "lobby_server"], "pc-lobby": [5111, "pc", "lobby_server"], "xb-lobby": [5105, "xb", "lobby_server"], @@ -77,8 +77,8 @@ "xb-proxy": [5113, "xb", "proxy_server"], "pc-proxy": [5121, "pc", "proxy_server"], "bb-proxy": [5122, "bb", "proxy_server"], - "bb-data1": [12004, "bb", "login_server"], - "bb-data2": [12005, "bb", "login_server"], + "bb-data1": [12004, "bb", "subsequent_login_server"], + "bb-data2": [12005, "bb", "subsequent_login_server"], }, "ProxyDestinations-GC": {