浏览代码

Follow up r17307
- Fix bugreport:7631 add a timered loop to prevent early forced close npc quitting while still executing, (must be in a stop wait etc state to do so)

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@17310 54d463be-8e91-2dee-dedb-b68131a5f0ec

glighta 12 年之前
父节点
当前提交
87d862c423
共有 1 个文件被更改,包括 8 次插入0 次删除
  1. 8 0
      src/map/pc.c

+ 8 - 0
src/map/pc.c

@@ -6569,6 +6569,10 @@ void pc_damage(struct map_session_data *sd,struct block_list *src,unsigned int h
 	sd->canlog_tick = gettick();
 }
 
+void pc_close_npc_timer(int tid, unsigned int tick, int id, intptr_t data){
+    TBL_PC *sd = map_id2sd(id);
+    if(sd) pc_close_npc(sd,data);
+}
 /*
  *  Method to properly close npc for player and clear anything related
  * @flag == 1 : produce close button
@@ -6583,6 +6587,10 @@ void pc_close_npc(struct map_session_data *sd,int flag) {
 			sd->state.using_fake_npc = 0;
 		}
 		if (sd->st) {
+			if(sd->st->state == RUN){ //wait ending code execution
+			    add_timer(gettick()+500,pc_close_npc_timer,sd->bl.id,flag);
+			    return;
+			}
 			sd->st->state = ((flag==1 && sd->st->mes_active)?CLOSE:END);
 			sd->st->mes_active = 0;
 		}