From fc07588d60154dd86f39a1874154ea21576331ee Mon Sep 17 00:00:00 2001 From: Aleos Date: Thu, 1 Nov 2018 20:10:29 -0400 Subject: [PATCH] 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! --- src/map/instance.cpp | 6 ------ src/map/pc.cpp | 24 +++++++----------------- 2 files changed, 7 insertions(+), 23 deletions(-) diff --git a/src/map/instance.cpp b/src/map/instance.cpp index 380942f125..a14392eac2 100644 --- a/src/map/instance.cpp +++ b/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; } diff --git a/src/map/pc.cpp b/src/map/pc.cpp index 2126b4310e..37348c1df7 100755 --- a/src/map/pc.cpp +++ b/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; + unsigned short curr_map_instance_id = map_getmapdata(sd->bl.m)->instance_id, new_map_instance_id = mapdata->instance_id; - if (instance_id && instance_id != mapdata->instance_id) { - struct party_data *p = NULL; - struct guild *g = NULL; - struct clan *cd = NULL; + 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 (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); + 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);