fix CAx1B client ID check

This commit is contained in:
Martin Michelsen
2023-09-27 10:51:18 -07:00
parent 02584e4458
commit 103e5325a3
2 changed files with 26 additions and 23 deletions
+10 -9
View File
@@ -5146,15 +5146,16 @@ struct G_CardBattleCommandHeader {
// The 6xB3 subcommand has a longer header than 6xB4 and 6xB5. This header is
// common to all 6xB3x (CAx) subcommands.
struct G_CardServerDataCommandHeader {
uint8_t subcommand = 0xB3;
uint8_t size = 0x00;
le_uint16_t unused1 = 0x0000;
uint8_t subsubcommand = 0x00; // See 6xBx subcommand table (after this table)
uint8_t sender_client_id = 0x00;
uint8_t mask_key = 0x00; // Same meaning as in G_CardBattleCommandHeader
uint8_t unused2 = 0x00;
be_uint32_t sequence_num;
be_uint32_t context_token;
/* 00 */ uint8_t subcommand = 0xB3;
/* 01 */ uint8_t size = 0x00;
/* 02 */ le_uint16_t unused1 = 0x0000;
/* 04 */ uint8_t subsubcommand = 0x00; // See 6xBx subcommand table (after this table)
/* 05 */ uint8_t sender_client_id = 0x00;
/* 06 */ uint8_t mask_key = 0x00; // Same meaning as in G_CardBattleCommandHeader
/* 07 */ uint8_t unused2 = 0x00;
/* 08 */ be_uint32_t sequence_num;
/* 0C */ be_uint32_t context_token;
/* 10 */
} __packed__;
// 6xB4: Unknown (XBOX; voice chat)
+16 -14
View File
@@ -2034,21 +2034,23 @@ void Server::handle_CAx1B_update_player_name(const string& data) {
this->send_debug_command_received_message(
in_cmd.entry.client_id, in_cmd.header.subsubcommand, "UPDATE NAME");
if (!this->is_registration_complete() && (in_cmd.entry.client_id < 4)) {
this->name_entries[in_cmd.entry.client_id] = in_cmd.entry;
this->name_entries_valid[in_cmd.entry.client_id] = false;
}
if (in_cmd.entry.client_id < 4) {
if (!this->is_registration_complete()) {
this->name_entries[in_cmd.entry.client_id] = in_cmd.entry;
this->name_entries_valid[in_cmd.entry.client_id] = false;
}
// Note: This check is not part of the original code. This replaces a
// disconnecting player with a CPU if the battle is in progress.
auto l = this->lobby.lock();
if (l && !l->clients[in_cmd.entry.client_id]) {
this->name_entries[in_cmd.entry.client_id].is_cpu_player = 1;
this->presence_entries[in_cmd.entry.client_id].is_cpu_player = 1;
auto ps = this->player_states[in_cmd.entry.client_id];
if (ps && ps->hand_and_equip && !ps->hand_and_equip->is_cpu_player) {
ps->hand_and_equip->is_cpu_player = 1;
this->send_6xB4x02_for_all_players_if_needed();
// Note: This check is not part of the original code. This replaces a
// disconnecting player with a CPU if the battle is in progress.
auto l = this->lobby.lock();
if (l && !l->clients[in_cmd.entry.client_id]) {
this->name_entries[in_cmd.entry.client_id].is_cpu_player = 1;
this->presence_entries[in_cmd.entry.client_id].is_cpu_player = 1;
auto ps = this->player_states[in_cmd.entry.client_id];
if (ps && ps->hand_and_equip && !ps->hand_and_equip->is_cpu_player) {
ps->hand_and_equip->is_cpu_player = 1;
this->send_6xB4x02_for_all_players_if_needed();
}
}
}