fix enemy_id usage in 6xC8

This commit is contained in:
Martin Michelsen
2023-03-03 19:34:53 -08:00
parent 5e07075977
commit 707b021c88
3 changed files with 14 additions and 12 deletions
+2 -2
View File
@@ -3291,7 +3291,7 @@ struct G_Unknown_6x09 {
struct G_EnemyHitByPlayer_6x0A { struct G_EnemyHitByPlayer_6x0A {
G_EnemyIDHeader header; G_EnemyIDHeader header;
// Note: enemy_id (in header) is in the range [0x1000, 0x4000) // Note: enemy_id (in header) is in the range [0x1000, 0x4000)
le_uint16_t enemy_id2; le_uint16_t enemy_id;
le_uint16_t damage; le_uint16_t damage;
be_uint32_t flags; be_uint32_t flags;
} __packed__; } __packed__;
@@ -4929,7 +4929,7 @@ struct G_SortInventory_6xC4 {
struct G_EnemyKilled_6xC8 { struct G_EnemyKilled_6xC8 {
G_EnemyIDHeader header; G_EnemyIDHeader header;
le_uint16_t enemy_id2; le_uint16_t enemy_id;
le_uint16_t killer_client_id; le_uint16_t killer_client_id;
le_uint32_t unused; le_uint32_t unused;
} __packed__; } __packed__;
+2
View File
@@ -3207,6 +3207,8 @@ shared_ptr<Lobby> create_game_generic(
game->next_game_item_id = 0x00810000; game->next_game_item_id = 0x00810000;
for (size_t area = 0; area < 0x10; area++) { for (size_t area = 0; area < 0x10; area++) {
c->log.info("[Map/%zu] Using variations %" PRIX32 ", %" PRIX32,
area, game->variations[area * 2].load(), game->variations[area * 2 + 1].load());
auto filenames = map_filenames_for_variation( auto filenames = map_filenames_for_variation(
game->episode, game->episode,
is_solo, is_solo,
+10 -10
View File
@@ -1037,15 +1037,15 @@ static void on_enemy_hit(shared_ptr<ServerState>,
if (!l->is_game()) { if (!l->is_game()) {
return; return;
} }
if (cmd.header.enemy_id >= l->enemies.size()) { if (cmd.enemy_id >= l->enemies.size()) {
return; return;
} }
if (l->enemies[cmd.header.enemy_id].hit_flags & 0x80) { if (l->enemies[cmd.enemy_id].hit_flags & 0x80) {
return; return;
} }
l->enemies[cmd.header.enemy_id].hit_flags |= (1 << c->lobby_client_id); l->enemies[cmd.enemy_id].hit_flags |= (1 << c->lobby_client_id);
l->enemies[cmd.header.enemy_id].last_hit = c->lobby_client_id; l->enemies[cmd.enemy_id].last_hit = c->lobby_client_id;
} }
forward_subcommand(l, c, command, flag, data); forward_subcommand(l, c, command, flag, data);
@@ -1062,21 +1062,21 @@ static void on_enemy_killed(shared_ptr<ServerState> s,
if (!l->is_game()) { if (!l->is_game()) {
throw runtime_error("client should not kill enemies outside of games"); throw runtime_error("client should not kill enemies outside of games");
} }
if (cmd.header.enemy_id >= l->enemies.size()) { if (cmd.enemy_id >= l->enemies.size()) {
send_text_message(c, u"$C6Missing enemy killed"); send_text_message(c, u"$C6Missing enemy killed");
return; return;
} }
string e_str = l->enemies[cmd.header.enemy_id].str(); string e_str = l->enemies[cmd.enemy_id].str();
c->log.info("Enemy killed: entry %hu => %s", cmd.header.enemy_id.load(), e_str.c_str()); c->log.info("Enemy killed: entry %hu => %s", cmd.enemy_id.load(), e_str.c_str());
if (l->enemies[cmd.header.enemy_id].hit_flags & 0x80) { if (l->enemies[cmd.enemy_id].hit_flags & 0x80) {
return; // Enemy is already dead return; // Enemy is already dead
} }
if (l->enemies[cmd.header.enemy_id].experience == 0xFFFFFFFF) { if (l->enemies[cmd.enemy_id].experience == 0xFFFFFFFF) {
send_text_message(c, u"$C6Unknown enemy type killed"); send_text_message(c, u"$C6Unknown enemy type killed");
return; return;
} }
auto& enemy = l->enemies[cmd.header.enemy_id]; auto& enemy = l->enemies[cmd.enemy_id];
enemy.hit_flags |= 0x80; enemy.hit_flags |= 0x80;
for (size_t x = 0; x < l->max_clients; x++) { for (size_t x = 0; x < l->max_clients; x++) {
if (!((enemy.hit_flags >> x) & 1)) { if (!((enemy.hit_flags >> x) & 1)) {