浏览代码

Corrected Instance timers when entering a map (#3594)

* Fixes #3585.
* Resolves an issue when players change maps to instances (aside from script command instance_enter) and the active/idle timers are not adjusted.
* Cleaned up the entering and leaving checks for instances.
Thanks to @Atemo and @Lemongrass3110!
Aleos 6 年之前
父节点
当前提交
fc07588d60
共有 2 个文件被更改,包括 9 次插入25 次删除
  1. 0 6
      src/map/instance.cpp
  2. 9 19
      src/map/pc.cpp

+ 0 - 6
src/map/instance.cpp

@@ -806,12 +806,6 @@ enum e_instance_enter instance_enter(struct map_session_data *sd, unsigned short
 	if (pc_setpos(sd, map_id2index(m), x, y, CLR_OUTSIGHT))
 		return IE_OTHER;
 
-	// If there was an idle timer, let's stop it
-	instance_stopidletimer(im, instance_id);
-
-	// Now we start the instance timer
-	instance_startkeeptimer(im, instance_id);
-
 	return IE_OK;
 }
 

+ 9 - 19
src/map/pc.cpp

@@ -5502,24 +5502,14 @@ enum e_setpos pc_setpos(struct map_session_data* sd, unsigned short mapindex, in
 	sd->state.workinprogress = WIP_DISABLE_NONE;
 
 	if( sd->state.changemap ) { // Misc map-changing settings
-		int i;
-		unsigned short instance_id = map_getmapdata(sd->bl.m)->instance_id;
-
-		if (instance_id && instance_id != mapdata->instance_id) {
-			struct party_data *p = NULL;
-			struct guild *g = NULL;
-			struct clan *cd = NULL;
-
-			if (sd->instance_id)
-				instance_delusers(sd->instance_id);
-			else if (sd->status.party_id && (p = party_search(sd->status.party_id)) != NULL && p->instance_id)
-				instance_delusers(p->instance_id);
-			else if (sd->status.guild_id && (g = guild_search(sd->status.guild_id)) != NULL && g->instance_id)
-				instance_delusers(g->instance_id);
-			else if (sd->status.clan_id && (cd = clan_search(sd->status.clan_id)) != NULL && cd->instance_id)
-				instance_delusers(cd->instance_id);
-			else
-				instance_delusers(instance_id);
+		unsigned short curr_map_instance_id = map_getmapdata(sd->bl.m)->instance_id, new_map_instance_id = mapdata->instance_id;
+
+		if (curr_map_instance_id != new_map_instance_id) {
+			if (curr_map_instance_id) // Update instance timer for the map on leave
+				instance_delusers(curr_map_instance_id);
+
+			if (new_map_instance_id) // Update instance timer for the map on enter
+				instance_addusers(new_map_instance_id);
 		}
 
 		sd->state.pmap = sd->bl.m;
@@ -5542,7 +5532,7 @@ enum e_setpos pc_setpos(struct map_session_data* sd, unsigned short mapindex, in
 			status_change_end(&sd->bl, SC_CLOAKING, INVALID_TIMER);
 			status_change_end(&sd->bl, SC_CLOAKINGEXCEED, INVALID_TIMER);
 		}
-		for( i = 0; i < EQI_MAX; i++ ) {
+		for(int i = 0; i < EQI_MAX; i++ ) {
 			if( sd->equip_index[i] >= 0 )
 				if( pc_isequip(sd,sd->equip_index[i]) )
 					pc_unequipitem(sd,sd->equip_index[i],2);