fix 6x69 client ID check

This commit is contained in:
Martin Michelsen
2023-12-22 15:26:03 -08:00
parent cf0588afc8
commit d7bdbf19d1
2 changed files with 2 additions and 5 deletions
+1 -1
View File
@@ -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__;
+1 -4
View File
@@ -1017,10 +1017,7 @@ static void on_npc_control(shared_ptr<Client> 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);