diff options
author | Kenpachi Developer <Kenpachi.Developer@gmx.de> | 2020-02-08 06:28:15 +0100 |
---|---|---|
committer | Kenpachi Developer <Kenpachi.Developer@gmx.de> | 2020-02-08 06:28:15 +0100 |
commit | 8e801f0ac21e13e652a4479c2fb046715ef56bb2 (patch) | |
tree | 634a01352aa5d572d54ea22cdf71f907933244eb | |
parent | c03722679a01e5f181c2138565e95a6b0981a124 (diff) | |
download | hercules-8e801f0ac21e13e652a4479c2fb046715ef56bb2.tar.gz hercules-8e801f0ac21e13e652a4479c2fb046715ef56bb2.tar.bz2 hercules-8e801f0ac21e13e652a4479c2fb046715ef56bb2.tar.xz hercules-8e801f0ac21e13e652a4479c2fb046715ef56bb2.zip |
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.
-rw-r--r-- | src/map/npc.c | 20 |
1 files changed, 13 insertions, 7 deletions
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) { |