use native error codes for login errors
This commit is contained in:
+6
-6
@@ -421,7 +421,7 @@ shared_ptr<Login> 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<Login> 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<Login> 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<Login> 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<Login> 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<Login> 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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
+3
-3
@@ -168,13 +168,13 @@ void PatchServer::on_04(shared_ptr<Client> 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<Client> 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;
|
||||
}
|
||||
|
||||
+23
-4
@@ -599,6 +599,8 @@ static void on_DB_V3(shared_ptr<Client> 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<Client> 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<Client> 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<Client> 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<Client> 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<Client> 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<Client> 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<Client> 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<Client> 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<Client> 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;
|
||||
|
||||
Reference in New Issue
Block a user