fix 6x69 command 02 checks

This commit is contained in:
Martin Michelsen
2023-12-28 11:07:06 -08:00
parent c1bcd45ea1
commit b6cfb5b2a2
2 changed files with 5 additions and 4 deletions
+4 -3
View File
@@ -1028,20 +1028,21 @@ static void on_npc_control(shared_ptr<Client> c, uint8_t command, uint8_t flag,
throw runtime_error("cannot create or modify NPC in the lobby");
}
uint16_t npc_entity_id = 0xFFFF;
int32_t npc_entity_id = -1;
switch (cmd.command) {
case 0:
case 3:
npc_entity_id = cmd.param2;
break;
case 1:
case 2:
npc_entity_id = cmd.param1;
break;
case 2:
break;
default:
throw runtime_error("invalid 6x69 command");
}
if ((npc_entity_id < 4) && l->clients[npc_entity_id]) {
if ((npc_entity_id >= 0) && (npc_entity_id < 4) && l->clients[npc_entity_id]) {
throw runtime_error("cannot create or modify NPC in existing player slot");
}