From d7bdbf19d1f4e63fbde63f946efbc5e8751c3392 Mon Sep 17 00:00:00 2001 From: Martin Michelsen Date: Fri, 22 Dec 2023 15:26:03 -0800 Subject: [PATCH] fix 6x69 client ID check --- src/CommandFormats.hh | 2 +- src/ReceiveSubcommands.cc | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/CommandFormats.hh b/src/CommandFormats.hh index 4caed01c..949c88a0 100644 --- a/src/CommandFormats.hh +++ b/src/CommandFormats.hh @@ -4559,7 +4559,7 @@ struct G_CreateTelepipe_6x68 { struct G_NPCControl_6x69 { G_UnusedHeader header; le_uint16_t state = 0; - le_uint16_t npc_client_id = 0; + le_uint16_t npc_entity_id = 0; le_uint16_t command = 0; // 0 = create follower NPC, 1 = stop acting, 2 = start acting, 3 = create attacker NPC le_uint16_t npc_template_index = 0; // Specifies which NPC to create if command == 0 or 3; unused otherwise } __packed__; diff --git a/src/ReceiveSubcommands.cc b/src/ReceiveSubcommands.cc index b8df53d6..40bcece2 100644 --- a/src/ReceiveSubcommands.cc +++ b/src/ReceiveSubcommands.cc @@ -1017,10 +1017,7 @@ static void on_npc_control(shared_ptr c, uint8_t command, uint8_t flag, if (!l->is_game()) { throw runtime_error("cannot create NPCs in the lobby"); } - if (cmd.npc_client_id >= 4) { - throw runtime_error("NPC client ID is not valid"); - } - if (l->clients[cmd.npc_client_id]) { + if ((cmd.npc_entity_id < 4) && l->clients[cmd.npc_entity_id]) { throw runtime_error("cannot overwrite existing player with NPC"); } forward_subcommand(c, command, flag, data, size);