Resolved a potential map crash on instance destruction (fixes #1333)

* Adjusted the instance destruction checks on party and guild breaks.
This commit is contained in:
aleos89
2016-06-02 09:02:14 -04:00
parent 63e8fa0721
commit 5ef2000bd9
3 changed files with 6 additions and 10 deletions

View File

@@ -1852,10 +1852,8 @@ int guild_break(struct map_session_data *sd,char *name) {
return 0;
}
if (g->instance_id) {
instance_data[g->instance_id].owner_id = 0;
if (g->instance_id)
instance_destroy(g->instance_id);
}
/* Regardless of char server allowing it, we clear the guild master's auras */
if ((ud = unit_bl2ud(&sd->bl))) {

View File

@@ -579,7 +579,7 @@ int instance_destroy(unsigned short instance_id)
for(i = 0; i < instance_wait.count; i++)
if(instance_data[instance_wait.id[i]].state == INSTANCE_IDLE)
if ((mode == IM_CHAR && sd != NULL) || (mode == IM_PARTY && p != NULL) || (mode == IM_GUILD && g != NULL))
if ((mode == IM_CHAR && sd) || (mode == IM_PARTY && p) || (mode == IM_GUILD && g))
clif_instance_changewait(instance_id, i + 1);
if(instance_wait.count)
@@ -613,11 +613,11 @@ int instance_destroy(unsigned short instance_id)
im->idle_timer = INVALID_TIMER;
}
if (mode == IM_CHAR)
if (mode == IM_CHAR && sd)
sd->instance_id = 0;
else if (mode == IM_PARTY)
else if (mode == IM_PARTY && p)
p->instance_id = 0;
else if (mode == IM_GUILD)
else if (mode == IM_GUILD && g)
g->instance_id = 0;
if (mode != IM_NONE) {

View File

@@ -659,10 +659,8 @@ int party_broken(int party_id)
if( p == NULL )
return 0;
if( p->instance_id ) {
instance_data[p->instance_id].owner_id = 0;
if( p->instance_id )
instance_destroy( p->instance_id );
}
for( i = 0; i < MAX_PARTY; i++ ) {
if( p->data[i].sd != NULL ) {