diff --git a/src/Episode3/DeckState.cc b/src/Episode3/DeckState.cc index 35be4e3f..9bc707d6 100644 --- a/src/Episode3/DeckState.cc +++ b/src/Episode3/DeckState.cc @@ -11,7 +11,7 @@ NameEntry::NameEntry() { void NameEntry::clear() { this->client_id = 0xFF; this->present = 0; - this->unused_by_server = 0; + this->is_cpu_player = 0; this->unused = 0; } diff --git a/src/Episode3/DeckState.hh b/src/Episode3/DeckState.hh index fd5dd6ef..ed0172bd 100644 --- a/src/Episode3/DeckState.hh +++ b/src/Episode3/DeckState.hh @@ -14,7 +14,7 @@ struct NameEntry { parray name; uint8_t client_id; uint8_t present; - uint8_t unused_by_server; + uint8_t is_cpu_player; uint8_t unused; NameEntry(); diff --git a/src/Episode3/Server.cc b/src/Episode3/Server.cc index f3a53b7b..70630338 100644 --- a/src/Episode3/Server.cc +++ b/src/Episode3/Server.cc @@ -1928,6 +1928,19 @@ void Server::handle_CAx1B_update_player_name(const string& data) { 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(); + } + } + G_SetPlayerNames_GC_Ep3_6xB4x1C out_cmd; for (size_t z = 0; z < 4; z++) { out_cmd.entries[z] = this->name_entries[z]; diff --git a/tests/GC-Episode3Battle.test.txt b/tests/GC-Episode3Battle.test.txt index f561e8f1..935f4f3b 100644 --- a/tests/GC-Episode3Battle.test.txt +++ b/tests/GC-Episode3Battle.test.txt @@ -6165,7 +6165,7 @@ I 32209 2023-09-08 23:40:11 - [Commands] Sending to C-7 (Tali) (version=GC comma 0000 | C9 00 5C 00 B4 16 00 00 1C 00 00 00 54 61 6C 69 | \ Tali 0010 | 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 | 0020 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | -0030 | 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | +0030 | 01 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 | 0040 | 00 00 00 00 FF 00 00 00 00 00 00 00 00 00 00 00 | 0050 | 00 00 00 00 00 00 00 00 FF 00 00 00 | I 32209 2023-09-08 23:40:11 - [Commands] Received from C-7 (Tali) (version=GC command=CA flag=00) @@ -6257,7 +6257,7 @@ I 32209 2023-09-08 23:40:11 - [Commands] Sending to C-7 (Tali) (version=GC comma 0010 | 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 | 0020 | 43 50 55 00 00 00 00 00 00 00 00 00 00 00 00 00 | CPU 0030 | 01 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 | -0040 | 00 00 00 00 02 01 00 00 00 00 00 00 00 00 00 00 | +0040 | 00 00 00 00 02 01 01 00 00 00 00 00 00 00 00 00 | 0050 | 00 00 00 00 00 00 00 00 FF 00 00 00 | I 32209 2023-09-08 23:40:11 - [Commands] Received from C-7 (Tali) (version=GC command=CA flag=00) 0000 | CA 00 70 00 B3 1B 83 99 14 00 00 00 FF FF FF FF | p @@ -6349,7 +6349,7 @@ I 32209 2023-09-08 23:40:11 - [Commands] Sending to C-7 (Tali) (version=GC comma 0020 | 43 50 55 00 00 00 00 00 00 00 00 00 00 00 00 00 | CPU 0030 | 01 01 01 00 43 50 55 00 00 00 00 00 00 00 00 00 | CPU 0040 | 00 00 00 00 02 01 01 00 00 00 00 00 00 00 00 00 | -0050 | 00 00 00 00 00 00 00 00 03 01 00 00 | +0050 | 00 00 00 00 00 00 00 00 03 01 01 00 | I 32209 2023-09-08 23:40:11 - [Commands] Received from C-7 (Tali) (version=GC command=CA flag=00) 0000 | CA 00 70 00 B3 1B 99 83 14 00 00 00 FF FF FF FF | p 0010 | 00 00 00 00 03 00 01 28 00 00 00 00 00 00 00 00 | (