From 8e801f0ac21e13e652a4479c2fb046715ef56bb2 Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Sat, 8 Feb 2020 06:28:15 +0100 Subject: Change NPC ID validation in npc_scriptcont() npc_scriptcont() will now validate the NPC ID - if SECURE_NPCTIMEOUT is _not_ defined or - if SECURE_NPCTIMEOUT is defined and the charcters idle timer is still running. --- src/map/npc.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/map/npc.c b/src/map/npc.c index cc588e52c..28091d0cc 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -1343,14 +1343,20 @@ static int npc_scriptcont(struct map_session_data *sd, int id, bool closing) struct block_list *target = map->id2bl(id); nullpo_retr(1, sd); - if( id != sd->npc_id ){ - struct npc_data *nd_sd = map->id2nd(sd->npc_id); - struct npc_data *nd = BL_CAST(BL_NPC, target); - ShowDebug("npc_scriptcont: %s (sd->npc_id=%d) is not %s (id=%d).\n", - nd_sd?(char*)nd_sd->name:"'Unknown NPC'", (int)sd->npc_id, - nd?(char*)nd->name:"'Unknown NPC'", (int)id); - return 1; +#ifdef SECURE_NPCTIMEOUT + if (sd->npc_idle_timer != INVALID_TIMER) { +#endif + if( id != sd->npc_id ){ + struct npc_data *nd_sd = map->id2nd(sd->npc_id); + struct npc_data *nd = BL_CAST(BL_NPC, target); + ShowDebug("npc_scriptcont: %s (sd->npc_id=%d) is not %s (id=%d).\n", + nd_sd?(char*)nd_sd->name:"'Unknown NPC'", (int)sd->npc_id, + nd?(char*)nd->name:"'Unknown NPC'", (int)id); + return 1; + } +#ifdef SECURE_NPCTIMEOUT } +#endif if (id != npc->fake_nd->bl.id) { // Not item script if (sd->state.npc_unloaded != 0) { -- cgit v1.2.3-60-g2f50