diff --git a/src/Account.cc b/src/Account.cc index 2003dfd0..e62aadac 100644 --- a/src/Account.cc +++ b/src/Account.cc @@ -421,7 +421,7 @@ shared_ptr AccountIndex::from_dc_nte_credentials_locked(const string& ser throw incorrect_access_key(); } if (login->account->ban_end_time && (login->account->ban_end_time >= phosg::now())) { - throw invalid_argument("user is banned"); + throw account_banned(); } return login; } @@ -471,7 +471,7 @@ shared_ptr AccountIndex::from_dc_credentials_locked( throw incorrect_access_key(); } if (login->account->ban_end_time && (login->account->ban_end_time >= phosg::now())) { - throw invalid_argument("user is banned"); + throw account_banned(); } if (is_shared) { login->account = this->create_temporary_account_for_shared_account(login->account, access_key + ":" + character_name); @@ -544,7 +544,7 @@ shared_ptr AccountIndex::from_pc_credentials_locked( throw incorrect_access_key(); } if (login->account->ban_end_time && (login->account->ban_end_time >= phosg::now())) { - throw invalid_argument("user is banned"); + throw account_banned(); } if (is_shared) { login->account = this->create_temporary_account_for_shared_account(login->account, access_key + ":" + character_name); @@ -600,7 +600,7 @@ shared_ptr AccountIndex::from_gc_credentials_locked( throw incorrect_password(); } if (login->account->ban_end_time && (login->account->ban_end_time >= phosg::now())) { - throw invalid_argument("user is banned"); + throw account_banned(); } if (is_shared) { login->account = this->create_temporary_account_for_shared_account(login->account, access_key + ":" + character_name); @@ -653,7 +653,7 @@ shared_ptr AccountIndex::from_xb_credentials_locked(const string& gamerta throw incorrect_access_key(); } if (login->account->ban_end_time && (login->account->ban_end_time >= phosg::now())) { - throw invalid_argument("user is banned"); + throw account_banned(); } return login; } @@ -702,7 +702,7 @@ shared_ptr AccountIndex::from_bb_credentials_locked(const string& usernam throw incorrect_password(); } if (login->account->ban_end_time && (login->account->ban_end_time >= phosg::now())) { - throw invalid_argument("user is banned"); + throw account_banned(); } return login; } diff --git a/src/Account.hh b/src/Account.hh index 3963c941..64465a97 100644 --- a/src/Account.hh +++ b/src/Account.hh @@ -159,6 +159,10 @@ public: public: missing_account() : invalid_argument("missing account") {} }; + class account_banned : public std::invalid_argument { + public: + account_banned() : invalid_argument("account is banned") {} + }; explicit AccountIndex(bool force_all_temporary); virtual ~AccountIndex() = default; diff --git a/src/CommandFormats.hh b/src/CommandFormats.hh index eaa13b5d..cd6d08c2 100644 --- a/src/CommandFormats.hh +++ b/src/CommandFormats.hh @@ -3172,6 +3172,22 @@ struct C_JoinSpectatorTeam_Ep3_E6_Flag01 { // ignored during the game server phase). struct S_ClientInit_BB_00E6 { + // The error codes are (error_code => internal_error_code => string) + // 00 => (no error; client proceeds normally) + // => 01 => "(No901)\nUnable to obtain server address.\nPlease confirm your DNS settings.", + // => 02 => "(No902)\nNetwork initialization failed.\nPlease check your Internet connection settings.", + // 01 => 03 => "(No903)\nServer connection failed.\nThe server may be under maintenance.\nPlease check the current news updates on the Official Site.", + // 02 => 04 => "(No904)\nIncorrect Game ID or Game Password.", + // 03 => 05 => "(No905)\nIncorrect Game ID or Game Password.", + // 04 => 06 => "(No906)\nThis server is under maintenance.\nPlease see the Official Site for details.", + // (any) => 07 => "(No907)\nForced server disconnect.\nPlease check your Game ID and individual settings.", + // 06/07 => 08 => "(No910)\nThis Game ID has been suspended.", + // 05 => 09 => "(No911)\nThis Game ID is in use by another user.", + // 08 => 0A => "(No912)\nNo record for this Game ID.\nPlease register your user information at the Official Site.", + // 09 => 0B => "(No913)\nYour paid time has expired.\nPlease renew your account at the Official Site.", + // 0A => 0C => "(No914)\nDue to the program not being shut down properly, data is locked. Please try connecting again in 10 minutes.", + // 0B => 0D => "(No915)\nThis program has not been updated. The patch may not have run properly. Please try shutting down and restarting the program.\nThe most recent news updates can be found on the Official Site.", + // => 0E => "(No916)\nThis server is full.\nPlease try connecting again later." le_uint32_t error_code = 0; le_uint32_t player_tag = 0x00010000; le_uint32_t guild_card_number = 0; diff --git a/src/PatchServer.cc b/src/PatchServer.cc index ab91ef35..89d24bfb 100644 --- a/src/PatchServer.cc +++ b/src/PatchServer.cc @@ -168,13 +168,13 @@ void PatchServer::on_04(shared_ptr c, string& data) { this->config->account_index->from_bb_credentials(username, &password, false); } catch (const AccountIndex::incorrect_password& e) { - this->send_message_box(c, phosg::string_printf("Login failed: %s", e.what())); + c->channel.send(0x15, 0x03); this->disconnect_client(c); return; } catch (const AccountIndex::missing_account& e) { if (!this->config->allow_unregistered_users) { - this->send_message_box(c, phosg::string_printf("Login failed: %s", e.what())); + c->channel.send(0x15, 0x08); this->disconnect_client(c); return; } @@ -184,7 +184,7 @@ void PatchServer::on_04(shared_ptr c, string& data) { try { this->config->account_index->from_bb_credentials(username, nullptr, false); } catch (const AccountIndex::missing_account& e) { - this->send_message_box(c, phosg::string_printf("Login failed: %s", e.what())); + c->channel.send(0x15, 0x08); this->disconnect_client(c); return; } diff --git a/src/ReceiveCommands.cc b/src/ReceiveCommands.cc index f94e156f..febef5e7 100644 --- a/src/ReceiveCommands.cc +++ b/src/ReceiveCommands.cc @@ -599,6 +599,8 @@ static void on_DB_V3(shared_ptr c, uint16_t, uint32_t, string& data) { send_command(c, 0x9A, 0x01); } catch (const AccountIndex::missing_account& e) { send_command(c, 0x9A, 0x04); + } catch (const AccountIndex::account_banned& e) { + send_command(c, 0x9A, 0x0F); } c->should_disconnect = !c->login; @@ -624,6 +626,8 @@ static void on_88_DCNTE(shared_ptr c, uint16_t, uint32_t, string& data) send_message_box(c, "Incorrect access key"); } catch (const AccountIndex::missing_account& e) { send_message_box(c, "Incorrect serial number"); + } catch (const AccountIndex::account_banned& e) { + send_message_box(c, "Account is banned"); } c->should_disconnect = !c->login; @@ -647,6 +651,8 @@ static void on_8B_DCNTE(shared_ptr c, uint16_t, uint32_t, string& data) send_message_box(c, "Incorrect access key"); } catch (const AccountIndex::missing_account& e) { send_message_box(c, "Incorrect serial number"); + } catch (const AccountIndex::account_banned& e) { + send_message_box(c, "Account is banned"); } if (!c->login) { @@ -692,6 +698,8 @@ static void on_90_DC(shared_ptr c, uint16_t, uint32_t, string& data) { send_command(c, 0x90, 0x03); } catch (const AccountIndex::missing_account& e) { send_command(c, 0x90, 0x03); + } catch (const AccountIndex::account_banned& e) { + send_command(c, 0x90, 0x0F); } c->should_disconnect = !c->login; } @@ -739,6 +747,8 @@ static void on_93_DC(shared_ptr c, uint16_t, uint32_t, string& data) { send_message_box(c, "Incorrect access key"); } catch (const AccountIndex::missing_account& e) { send_message_box(c, "Incorrect serial number"); + } catch (const AccountIndex::account_banned& e) { + send_message_box(c, "Account is banned"); } if (!c->login) { c->should_disconnect = true; @@ -833,6 +843,8 @@ static void on_9A(shared_ptr c, uint16_t, uint32_t, string& data) { send_command(c, 0x9A, 0x01); } catch (const AccountIndex::missing_account& e) { send_command(c, 0x9A, 0x03); + } catch (const AccountIndex::account_banned& e) { + send_command(c, 0x9A, 0x0F); } c->should_disconnect = !c->login; @@ -875,6 +887,8 @@ static void on_9C(shared_ptr c, uint16_t, uint32_t, string& data) { send_command(c, 0x9C, 0x00); } catch (const AccountIndex::missing_account& e) { send_command(c, 0x9C, 0x00); + } catch (const AccountIndex::account_banned& e) { + send_message_box(c, "Account is banned"); } c->should_disconnect = !c->login; } @@ -974,6 +988,8 @@ static void on_9D_9E(shared_ptr c, uint16_t command, uint32_t, string& d send_command(c, 0x04, 0x06); } catch (const AccountIndex::missing_account& e) { send_command(c, 0x04, 0x04); + } catch (const AccountIndex::account_banned& e) { + send_command(c, 0x04, 0x04); } if (!c->login) { @@ -1028,6 +1044,8 @@ static void on_9E_XB(shared_ptr c, uint16_t, uint32_t, string& data) { send_command(c, 0x04, 0x03); } catch (const AccountIndex::missing_account& e) { send_command(c, 0x04, 0x03); + } catch (const AccountIndex::account_banned& e) { + send_command(c, 0x04, 0x04); } if (!c->login) { @@ -1056,13 +1074,14 @@ static void on_93_BB(shared_ptr c, uint16_t, uint32_t, string& data) { try { c->login = s->account_index->from_bb_credentials(username, &password, s->allow_unregistered_users); - } catch (const AccountIndex::no_username& e) { - send_message_box(c, "Username is missing"); + send_client_init_bb(c, 0x08); } catch (const AccountIndex::incorrect_password& e) { - send_message_box(c, "Incorrect login password"); + send_client_init_bb(c, 0x03); } catch (const AccountIndex::missing_account& e) { - send_message_box(c, "You are not registered on this server"); + send_client_init_bb(c, 0x08); + } catch (const AccountIndex::account_banned& e) { + send_client_init_bb(c, 0x06); } if (!c->login) { c->should_disconnect = true;