fix 6x2F client ID check

This commit is contained in:
Martin Michelsen
2024-03-03 23:34:24 -08:00
parent 6ae08e9b05
commit 3189b71d46
2 changed files with 11 additions and 10 deletions
+5 -5
View File
@@ -4184,12 +4184,12 @@ struct G_SetOrClearPlayerFlags_6x2E {
le_uint32_t or_mask = 0;
} __packed__;
// 6x2F: Hit by enemy
// 6x2F: Change player HP
struct G_HitByEnemy_6x2F {
G_ClientIDHeader header;
le_uint32_t hit_type = 0; // 0 = set HP, 1 = add/subtract HP, 2 = add/sub fixed HP
le_uint16_t damage = 0;
struct G_ChangePlayerHP_6x2F {
G_UnusedHeader header;
le_uint32_t type = 0; // 0 = set HP, 1 = add/subtract HP, 2 = add/sub fixed HP
le_uint16_t amount = 0;
le_uint16_t client_id = 0;
} __packed__;
+6 -5
View File
@@ -1220,8 +1220,9 @@ static void on_received_condition(shared_ptr<Client> c, uint8_t command, uint8_t
}
}
static void on_hit_by_enemy(shared_ptr<Client> c, uint8_t command, uint8_t flag, void* data, size_t size) {
const auto& cmd = check_size_t<G_ClientIDHeader>(data, size, 0xFFFF);
template <typename CmdT>
static void on_change_hp(shared_ptr<Client> c, uint8_t command, uint8_t flag, void* data, size_t size) {
const auto& cmd = check_size_t<CmdT>(data, size, 0xFFFF);
auto l = c->require_lobby();
if (l->is_game() && (cmd.client_id == c->lobby_client_id)) {
@@ -3871,7 +3872,7 @@ const SubcommandDefinition subcommand_definitions[0x100] = {
/* 6x2C */ {0x28, 0x2A, 0x2C, on_forward_check_client},
/* 6x2D */ {0x29, 0x2B, 0x2D, on_forward_check_client},
/* 6x2E */ {0x2A, 0x2C, 0x2E, on_forward_check_client},
/* 6x2F */ {0x2B, 0x2D, 0x2F, on_hit_by_enemy},
/* 6x2F */ {0x2B, 0x2D, 0x2F, on_change_hp<G_ChangePlayerHP_6x2F>},
/* 6x30 */ {0x2C, 0x2E, 0x30, on_level_up},
/* 6x31 */ {0x2D, 0x2F, 0x31, on_forward_check_game},
/* 6x32 */ {0x00, 0x00, 0x32, on_forward_check_game},
@@ -3899,8 +3900,8 @@ const SubcommandDefinition subcommand_definitions[0x100] = {
/* 6x48 */ {0x00, 0x00, 0x48, on_cast_technique_finished},
/* 6x49 */ {0x3E, 0x44, 0x49, on_subtract_pb_energy},
/* 6x4A */ {0x3F, 0x45, 0x4A, on_forward_check_game_client},
/* 6x4B */ {0x40, 0x46, 0x4B, on_hit_by_enemy},
/* 6x4C */ {0x41, 0x47, 0x4C, on_hit_by_enemy},
/* 6x4B */ {0x40, 0x46, 0x4B, on_change_hp<G_ClientIDHeader>},
/* 6x4C */ {0x41, 0x47, 0x4C, on_change_hp<G_ClientIDHeader>},
/* 6x4D */ {0x42, 0x48, 0x4D, on_player_died},
/* 6x4E */ {0x00, 0x00, 0x4E, on_forward_check_game_client},
/* 6x4F */ {0x43, 0x49, 0x4F, on_forward_check_game_client},