Corrected SECURE_NPCTIMEOUT behavior (#3394)

* Fixes #3381 and fixes #3391.
* Properly end NPC sessions when a player times out.
Thanks to @mazvi, @anacondaqq, and @gustavobrigo!
This commit is contained in:
Aleos
2018-08-11 16:13:24 -04:00
committed by GitHub
parent 9ca000a4a7
commit 4befcf747f
5 changed files with 18 additions and 14 deletions

View File

@@ -4177,7 +4177,7 @@ static void script_detach_state(struct script_state* st, bool dequeue_event)
* We're done with this NPC session, so we cancel the timer (if existent) and move on
**/
if( sd->npc_idle_timer != INVALID_TIMER ) {
delete_timer(sd->npc_idle_timer,npc_rr_secure_timeout_timer);
delete_timer(sd->npc_idle_timer,npc_secure_timeout_timer);
sd->npc_idle_timer = INVALID_TIMER;
}
#endif
@@ -4217,7 +4217,7 @@ void script_attach_state(struct script_state* st){
sd->state.disable_atcommand_on_npc = (!pc_has_permission(sd, PC_PERM_ENABLE_COMMAND));
#ifdef SECURE_NPCTIMEOUT
if( sd->npc_idle_timer == INVALID_TIMER )
sd->npc_idle_timer = add_timer(gettick() + (SECURE_NPCTIMEOUT_INTERVAL*1000),npc_rr_secure_timeout_timer,sd->bl.id,0);
sd->npc_idle_timer = add_timer(gettick() + (SECURE_NPCTIMEOUT_INTERVAL*1000),npc_secure_timeout_timer,sd->bl.id,0);
sd->npc_idle_tick = gettick();
#endif
}