fix desyncs if protected commands aren't supported by client

This commit is contained in:
Martin Michelsen
2024-03-28 22:50:57 -07:00
parent dd9bc51457
commit 6d73cae91b
2 changed files with 17 additions and 12 deletions
+14 -11
View File
@@ -1418,17 +1418,20 @@ static void on_player_revivable(shared_ptr<Client> c, uint8_t command, uint8_t f
if (player_cheats_enabled && c->config.check_flag(Client::Flag::INFINITE_HP_ENABLED)) { if (player_cheats_enabled && c->config.check_flag(Client::Flag::INFINITE_HP_ENABLED)) {
G_UseMedicalCenter_6x31 v2_cmd = {0x31, 0x01, c->lobby_client_id}; G_UseMedicalCenter_6x31 v2_cmd = {0x31, 0x01, c->lobby_client_id};
G_RevivePlayer_V3_BB_6xA1 v3_cmd = {0xA1, 0x01, c->lobby_client_id}; G_RevivePlayer_V3_BB_6xA1 v3_cmd = {0xA1, 0x01, c->lobby_client_id};
for (auto lc : l->clients) { static_assert(sizeof(v2_cmd) == sizeof(v3_cmd), "Command sizes do not match");
if (!lc) {
continue; const void* c_data = (!is_v1_or_v2(c->version()) || (c->version() == Version::GC_NTE))
} ? static_cast<const void*>(&v3_cmd)
bool use_v3 = !is_v1_or_v2(lc->version()) || (lc->version() == Version::GC_NTE); : static_cast<const void*>(&v2_cmd);
const void* data = use_v3 ? static_cast<const void*>(&v3_cmd) : static_cast<const void*>(&v2_cmd); if (send_protected_command(c, c_data, sizeof(v3_cmd), false)) {
size_t size = use_v3 ? sizeof(v3_cmd) : sizeof(v2_cmd); for (auto lc : l->clients) {
if (lc == c) { if (!lc || (lc == c)) {
send_protected_command(lc, data, size, false); continue;
} else { }
send_command(lc, 0x60, 0x00, data, size); const void* lc_data = (!is_v1_or_v2(lc->version()) || (lc->version() == Version::GC_NTE))
? static_cast<const void*>(&v3_cmd)
: static_cast<const void*>(&v2_cmd);
send_command(lc, 0x60, 0x00, lc_data, sizeof(v3_cmd));
} }
} }
} }
+3 -1
View File
@@ -2417,7 +2417,9 @@ void send_remove_conditions(shared_ptr<Client> c) {
cmd.unknown_a1 = z; cmd.unknown_a1 = z;
cmd.unknown_a2 = 0; cmd.unknown_a2 = 0;
} }
send_protected_command(c, &cmds, sizeof(cmds), true); if (send_protected_command(c, &cmds, sizeof(cmds), true)) {
send_command_excluding_client(c->require_lobby(), c, 0x60, 0x00, &cmds, sizeof(cmds));
}
} }
void send_remove_conditions(Channel& ch, uint16_t client_id) { void send_remove_conditions(Channel& ch, uint16_t client_id) {