瀏覽代碼

Fixed bug with official npc idle timer thing, bugreport:5343

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@15598 54d463be-8e91-2dee-dedb-b68131a5f0ec
shennetsind 13 年之前
父節點
當前提交
6ea41835de
共有 1 個文件被更改,包括 4 次插入2 次删除
  1. 4 2
      src/map/npc.c

+ 4 - 2
src/map/npc.c

@@ -214,9 +214,10 @@ struct npc_data* npc_name2id(const char* name)
  **/
 int npc_rr_secure_timeout_timer(int tid, unsigned int tick, int id, intptr_t data) {
 	struct map_session_data* sd = NULL;
-	if( (sd = map_id2sd(id)) == NULL || !sd->npc_id )
+	if( (sd = map_id2sd(id)) == NULL || !sd->npc_id ) {
+		if( sd ) sd->npc_idle_timer = INVALID_TIMER;
 		return 0;//Not logged in anymore OR no longer attached to a npc
-
+	}
 	if( DIFF_TICK(tick,sd->npc_idle_tick) > (SECURE_NPCTIMEOUT*1000) ) {
 		/**
 		 * If we still have the NPC script attached, tell it to stop.
@@ -227,6 +228,7 @@ int npc_rr_secure_timeout_timer(int tid, unsigned int tick, int id, intptr_t dat
 		 * This guy's been idle for longer than allowed, close him.
 		 **/
 		clif_scriptclose(sd,sd->npc_id);
+		sd->npc_idle_timer = INVALID_TIMER;
 	} else //Create a new instance of ourselves to continue
 		sd->npc_idle_timer = add_timer(gettick() + (SECURE_NPCTIMEOUT_INTERVAL*1000),npc_rr_secure_timeout_timer,sd->bl.id,0);
 	return 0;