diff options
Diffstat (limited to 'src/map/instance.c')
-rw-r--r-- | src/map/instance.c | 337 |
1 files changed, 170 insertions, 167 deletions
diff --git a/src/map/instance.c b/src/map/instance.c index 5ef089fae..6ae1d6141 100644 --- a/src/map/instance.c +++ b/src/map/instance.c @@ -33,7 +33,7 @@ bool instance_is_valid(int instance_id) { return false; } - if( instances[instance_id].state == INSTANCE_FREE ) {// uninitialized/freed instance slot + if( instance->list[instance_id].state == INSTANCE_FREE ) {// uninitialized/freed instance slot return false; } @@ -88,30 +88,30 @@ int instance_create(int owner_id, const char *name, enum instance_owner_type typ } if( type != IOT_NONE && *icptr ) { - ARR_FIND(0, *icptr, i, strcmp(instances[iptr[i]].name,name) == 0 ); + ARR_FIND(0, *icptr, i, strcmp(instance->list[iptr[i]].name,name) == 0 ); if( i != *icptr ) return -4;/* already got this instance */ } - ARR_FIND(0, instance->instances, i, instances[i].state == INSTANCE_FREE); + ARR_FIND(0, instance->instances, i, instance->list[i].state == INSTANCE_FREE); if( i == instance->instances ) - RECREATE(instances, struct instance_data, ++instance->instances); - - instances[i].state = INSTANCE_IDLE; - instances[i].id = i; - instances[i].idle_timer = INVALID_TIMER; - instances[i].idle_timeout = instances[i].idle_timeoutval = 0; - instances[i].progress_timer = INVALID_TIMER; - instances[i].progress_timeout = 0; - instances[i].users = 0; - instances[i].map = NULL; - instances[i].num_map = 0; - instances[i].owner_id = owner_id; - instances[i].owner_type = type; - instances[i].vars = idb_alloc(DB_OPT_RELEASE_DATA); - - safestrncpy( instances[i].name, name, sizeof(instances[i].name) ); + RECREATE(instance->list, struct instance_data, ++instance->instances); + + instance->list[i].state = INSTANCE_IDLE; + instance->list[i].id = i; + instance->list[i].idle_timer = INVALID_TIMER; + instance->list[i].idle_timeout = instance->list[i].idle_timeoutval = 0; + instance->list[i].progress_timer = INVALID_TIMER; + instance->list[i].progress_timeout = 0; + instance->list[i].users = 0; + instance->list[i].map = NULL; + instance->list[i].num_map = 0; + instance->list[i].owner_id = owner_id; + instance->list[i].owner_type = type; + instance->list[i].vars = idb_alloc(DB_OPT_RELEASE_DATA); + + safestrncpy( instance->list[i].name, name, sizeof(instance->list[i].name) ); if( type != IOT_NONE ) { ARR_FIND(0, *icptr, j, iptr[j] == -1); @@ -159,95 +159,95 @@ int instance_add_map(const char *name, int instance_id, bool usebasename, const return -2; } - if( maplist[m].instance_id >= 0 ) { + if( map->list[m].instance_id >= 0 ) { // Source map already belong to a Instance. ShowError("instance_add_map: trying to instance already instanced map %s.\n", name); return -4; } - ARR_FIND( instance->start_id, map->map_num, i, maplist[i].name[0] == 0 ); // Searching for a Free Map + ARR_FIND( instance->start_id, map->count, i, map->list[i].name[0] == 0 ); // Searching for a Free Map - if( i < map->map_num ) + if( i < map->count ) im = i; // Unused map found (old instance) else { - im = map->map_num; // Using next map index - RECREATE(maplist,struct map_data,++map->map_num); + im = map->count; // Using next map index + RECREATE(map->list,struct map_data,++map->count); } - if( maplist[m].cell == (struct mapcell *)0xdeadbeaf ) - map->cellfromcache(&maplist[m]); + if( map->list[m].cell == (struct mapcell *)0xdeadbeaf ) + map->cellfromcache(&map->list[m]); - memcpy( &maplist[im], &maplist[m], sizeof(struct map_data) ); // Copy source map + memcpy( &map->list[im], &map->list[m], sizeof(struct map_data) ); // Copy source map if( map_name != NULL ) { - snprintf(maplist[im].name, MAP_NAME_LENGTH, "%s", map_name); - maplist[im].custom_name = true; + snprintf(map->list[im].name, MAP_NAME_LENGTH, "%s", map_name); + map->list[im].custom_name = true; } else - snprintf(maplist[im].name, MAP_NAME_LENGTH, (usebasename ? "%.3d#%s" : "%.3d%s"), instance_id, name); // Generate Name for Instance Map - maplist[im].index = mapindex_addmap(-1, maplist[im].name); // Add map index + snprintf(map->list[im].name, MAP_NAME_LENGTH, (usebasename ? "%.3d#%s" : "%.3d%s"), instance_id, name); // Generate Name for Instance Map + map->list[im].index = mapindex_addmap(-1, map->list[im].name); // Add map index - maplist[im].channel = NULL; + map->list[im].channel = NULL; - if( !maplist[im].index ) { - maplist[im].name[0] = '\0'; + if( !map->list[im].index ) { + map->list[im].name[0] = '\0'; ShowError("instance_add_map: no more free map indexes.\n"); return -3; // No free map index } // Reallocate cells - num_cell = maplist[im].xs * maplist[im].ys; - CREATE( maplist[im].cell, struct mapcell, num_cell ); - memcpy( maplist[im].cell, maplist[m].cell, num_cell * sizeof(struct mapcell) ); + num_cell = map->list[im].xs * map->list[im].ys; + CREATE( map->list[im].cell, struct mapcell, num_cell ); + memcpy( map->list[im].cell, map->list[m].cell, num_cell * sizeof(struct mapcell) ); - size = maplist[im].bxs * maplist[im].bys * sizeof(struct block_list*); - maplist[im].block = (struct block_list**)aCalloc(size, 1); - maplist[im].block_mob = (struct block_list**)aCalloc(size, 1); + size = map->list[im].bxs * map->list[im].bys * sizeof(struct block_list*); + map->list[im].block = (struct block_list**)aCalloc(size, 1); + map->list[im].block_mob = (struct block_list**)aCalloc(size, 1); - memset(maplist[im].npc, 0x00, sizeof(maplist[i].npc)); - maplist[im].npc_num = 0; + memset(map->list[im].npc, 0x00, sizeof(map->list[i].npc)); + map->list[im].npc_num = 0; - memset(maplist[im].moblist, 0x00, sizeof(maplist[im].moblist)); - maplist[im].mob_delete_timer = INVALID_TIMER; + memset(map->list[im].moblist, 0x00, sizeof(map->list[im].moblist)); + map->list[im].mob_delete_timer = INVALID_TIMER; //Mimic unit - if( maplist[m].unit_count ) { - maplist[im].unit_count = maplist[m].unit_count; - CREATE( maplist[im].units, struct mapflag_skill_adjust*, maplist[im].unit_count ); + if( map->list[m].unit_count ) { + map->list[im].unit_count = map->list[m].unit_count; + CREATE( map->list[im].units, struct mapflag_skill_adjust*, map->list[im].unit_count ); - for(i = 0; i < maplist[im].unit_count; i++) { - CREATE( maplist[im].units[i], struct mapflag_skill_adjust, 1); - memcpy( maplist[im].units[i],maplist[m].units[i],sizeof(struct mapflag_skill_adjust)); + for(i = 0; i < map->list[im].unit_count; i++) { + CREATE( map->list[im].units[i], struct mapflag_skill_adjust, 1); + memcpy( map->list[im].units[i],map->list[m].units[i],sizeof(struct mapflag_skill_adjust)); } } //Mimic skills - if( maplist[m].skill_count ) { - maplist[im].skill_count = maplist[m].skill_count; - CREATE( maplist[im].skills, struct mapflag_skill_adjust*, maplist[im].skill_count ); + if( map->list[m].skill_count ) { + map->list[im].skill_count = map->list[m].skill_count; + CREATE( map->list[im].skills, struct mapflag_skill_adjust*, map->list[im].skill_count ); - for(i = 0; i < maplist[im].skill_count; i++) { - CREATE( maplist[im].skills[i], struct mapflag_skill_adjust, 1); - memcpy( maplist[im].skills[i],maplist[m].skills[i],sizeof(struct mapflag_skill_adjust)); + for(i = 0; i < map->list[im].skill_count; i++) { + CREATE( map->list[im].skills[i], struct mapflag_skill_adjust, 1); + memcpy( map->list[im].skills[i],map->list[m].skills[i],sizeof(struct mapflag_skill_adjust)); } } //Mimic zone mf - if( maplist[m].zone_mf_count ) { - maplist[im].zone_mf_count = maplist[m].zone_mf_count; - CREATE( maplist[im].zone_mf, char *, maplist[im].zone_mf_count ); + if( map->list[m].zone_mf_count ) { + map->list[im].zone_mf_count = map->list[m].zone_mf_count; + CREATE( map->list[im].zone_mf, char *, map->list[im].zone_mf_count ); - for(i = 0; i < maplist[im].zone_mf_count; i++) { - CREATE(maplist[im].zone_mf[i], char, MAP_ZONE_MAPFLAG_LENGTH); - safestrncpy(maplist[im].zone_mf[i],maplist[m].zone_mf[i],MAP_ZONE_MAPFLAG_LENGTH); + for(i = 0; i < map->list[im].zone_mf_count; i++) { + CREATE(map->list[im].zone_mf[i], char, MAP_ZONE_MAPFLAG_LENGTH); + safestrncpy(map->list[im].zone_mf[i],map->list[m].zone_mf[i],MAP_ZONE_MAPFLAG_LENGTH); } } - maplist[im].m = im; - maplist[im].instance_id = instance_id; - maplist[im].instance_src_map = m; - maplist[m].flag.src4instance = 1; // Flag this map as a src map for instances + map->list[im].m = im; + map->list[im].instance_id = instance_id; + map->list[im].instance_src_map = m; + map->list[m].flag.src4instance = 1; // Flag this map as a src map for instances - RECREATE(instances[instance_id].map, unsigned short, ++instances[instance_id].num_map); + RECREATE(instance->list[instance_id].map, unsigned short, ++instance->list[instance_id].num_map); - instances[instance_id].map[instances[instance_id].num_map - 1] = im; // Attach to actual instance - map->addmap2db(&maplist[im]); + instance->list[instance_id].map[instance->list[instance_id].num_map - 1] = im; // Attach to actual instance + map->addmap2db(&map->list[im]); return im; } @@ -264,9 +264,9 @@ int instance_map2imap(int16 m, int instance_id) { return -1; } - for( i = 0; i < instances[instance_id].num_map; i++ ) { - if( instances[instance_id].map[i] && maplist[instances[instance_id].map[i]].instance_src_map == m ) - return instances[instance_id].map[i]; + for( i = 0; i < instance->list[instance_id].num_map; i++ ) { + if( instance->list[instance_id].map[i] && map->list[instance->list[instance_id].map[i]].instance_src_map == m ) + return instance->list[instance_id].map[i]; } return -1; } @@ -277,9 +277,9 @@ int instance_map2imap(int16 m, int instance_id) { * result : mapid of map "m" in this instance *--------------------------------------*/ int instance_mapid2imapid(int16 m, int instance_id) { - if( maplist[m].flag.src4instance == 0 ) + if( map->list[m].flag.src4instance == 0 ) return m; // not instances found for this map - else if( maplist[m].instance_id >= 0 ) { // This map is a instance, not a src map instance + else if( map->list[m].instance_id >= 0 ) { // This map is a instance, not a src map instance ShowError("map_instance_mapid2imapid: already instanced (%d / %d)\n", m, instance_id); return -1; } @@ -313,10 +313,10 @@ void instance_init(int instance_id) { if( !instance->valid(instance_id) ) return; // nothing to do - for( i = 0; i < instances[instance_id].num_map; i++ ) - map->foreachinmap(instance_map_npcsub, maplist[instances[instance_id].map[i]].instance_src_map, BL_NPC, instances[instance_id].map[i]); + for( i = 0; i < instance->list[instance_id].num_map; i++ ) + map->foreachinmap(instance_map_npcsub, map->list[instance->list[instance_id].map[i]].instance_src_map, BL_NPC, instance->list[instance_id].map[i]); - instances[instance_id].state = INSTANCE_BUSY; + instance->list[instance_id].state = INSTANCE_BUSY; } /*-------------------------------------- @@ -367,70 +367,70 @@ int instance_cleanup_sub(struct block_list *bl, va_list ap) { void instance_del_map(int16 m) { int i; - if( m <= 0 || maplist[m].instance_id == -1 ) { + if( m <= 0 || map->list[m].instance_id == -1 ) { ShowError("instance_del_map: tried to remove non-existing instance map (%d)\n", m); return; } - map->map_foreachpc(instance_del_load, m); + map->foreachpc(instance_del_load, m); map->foreachinmap(instance_cleanup_sub, m, BL_ALL); - if( maplist[m].mob_delete_timer != INVALID_TIMER ) - timer->delete(maplist[m].mob_delete_timer, map->removemobs_timer); + if( map->list[m].mob_delete_timer != INVALID_TIMER ) + timer->delete(map->list[m].mob_delete_timer, map->removemobs_timer); mapindex_removemap(map_id2index(m)); // Free memory - aFree(maplist[m].cell); - aFree(maplist[m].block); - aFree(maplist[m].block_mob); + aFree(map->list[m].cell); + aFree(map->list[m].block); + aFree(map->list[m].block_mob); - if( maplist[m].unit_count ) { - for(i = 0; i < maplist[m].unit_count; i++) { - aFree(maplist[m].units[i]); + if( map->list[m].unit_count ) { + for(i = 0; i < map->list[m].unit_count; i++) { + aFree(map->list[m].units[i]); } - if( maplist[m].units ) - aFree(maplist[m].units); + if( map->list[m].units ) + aFree(map->list[m].units); } - if( maplist[m].skill_count ) { - for(i = 0; i < maplist[m].skill_count; i++) { - aFree(maplist[m].skills[i]); + if( map->list[m].skill_count ) { + for(i = 0; i < map->list[m].skill_count; i++) { + aFree(map->list[m].skills[i]); } - if( maplist[m].skills ) - aFree(maplist[m].skills); + if( map->list[m].skills ) + aFree(map->list[m].skills); } - if( maplist[m].zone_mf_count ) { - for(i = 0; i < maplist[m].zone_mf_count; i++) { - aFree(maplist[m].zone_mf[i]); + if( map->list[m].zone_mf_count ) { + for(i = 0; i < map->list[m].zone_mf_count; i++) { + aFree(map->list[m].zone_mf[i]); } - if( maplist[m].zone_mf ) - aFree(maplist[m].zone_mf); + if( map->list[m].zone_mf ) + aFree(map->list[m].zone_mf); } // Remove from instance - for( i = 0; i < instances[maplist[m].instance_id].num_map; i++ ) { - if( instances[maplist[m].instance_id].map[i] == m ) { - instances[maplist[m].instance_id].num_map--; - for( ; i < instances[maplist[m].instance_id].num_map; i++ ) - instances[maplist[m].instance_id].map[i] = instances[maplist[m].instance_id].map[i+1]; + for( i = 0; i < instance->list[map->list[m].instance_id].num_map; i++ ) { + if( instance->list[map->list[m].instance_id].map[i] == m ) { + instance->list[map->list[m].instance_id].num_map--; + for( ; i < instance->list[map->list[m].instance_id].num_map; i++ ) + instance->list[map->list[m].instance_id].map[i] = instance->list[map->list[m].instance_id].map[i+1]; i = -1; break; } } - if( i == instances[maplist[m].instance_id].num_map ) - ShowError("map_instance_del: failed to remove %s from instance list (%s): %d\n", maplist[m].name, instances[maplist[m].instance_id].name, m); + if( i == instance->list[map->list[m].instance_id].num_map ) + ShowError("map_instance_del: failed to remove %s from instance list (%s): %d\n", map->list[m].name, instance->list[map->list[m].instance_id].name, m); - if( maplist[m].channel ) - clif->chsys_delete(maplist[m].channel); - - map->removemapdb(&maplist[m]); - memset(&maplist[m], 0x00, sizeof(maplist[0])); - maplist[m].name[0] = 0; - maplist[m].instance_id = -1; - maplist[m].mob_delete_timer = INVALID_TIMER; + if( map->list[m].channel ) + clif->chsys_delete(map->list[m].channel); + + map->removemapdb(&map->list[m]); + memset(&map->list[m], 0x00, sizeof(map->list[0])); + map->list[m].name[0] = 0; + map->list[m].instance_id = -1; + map->list[m].mob_delete_timer = INVALID_TIMER; } /*-------------------------------------- @@ -456,41 +456,41 @@ void instance_destroy(int instance_id) { if( !instance->valid(instance_id) ) return; // nothing to do - if( instances[instance_id].progress_timeout && instances[instance_id].progress_timeout <= now ) + if( instance->list[instance_id].progress_timeout && instance->list[instance_id].progress_timeout <= now ) type = 1; - else if( instances[instance_id].idle_timeout && instances[instance_id].idle_timeout <= now ) + else if( instance->list[instance_id].idle_timeout && instance->list[instance_id].idle_timeout <= now ) type = 2; else type = 3; clif->instance(instance_id, 5, type); // Report users this instance has been destroyed - switch ( instances[instance_id].owner_type ) { + switch ( instance->list[instance_id].owner_type ) { case IOT_NONE: break; case IOT_CHAR: - if( ( sd = map->id2sd(instances[instance_id].owner_id) ) == NULL ) { + if( ( sd = map->id2sd(instance->list[instance_id].owner_id) ) == NULL ) { break; } iptr = sd->instance; icptr = &sd->instances; break; case IOT_PARTY: - if( ( p = party->search(instances[instance_id].owner_id) ) == NULL ) { + if( ( p = party->search(instance->list[instance_id].owner_id) ) == NULL ) { break; } iptr = p->instance; icptr = &p->instances; break; case IOT_GUILD: - if( ( g = guild->search(instances[instance_id].owner_id) ) == NULL ) { + if( ( g = guild->search(instance->list[instance_id].owner_id) ) == NULL ) { break; } iptr = g->instance; icptr = &g->instances; break; default: - ShowError("instance_destroy: unknown type %d for owner_id %d and name '%s'.\n", instances[instance_id].owner_type,instances[instance_id].owner_id,instances[instance_id].name); + ShowError("instance_destroy: unknown type %d for owner_id %d and name '%s'.\n", instance->list[instance_id].owner_type,instance->list[instance_id].owner_id,instance->list[instance_id].name); break; } @@ -500,27 +500,27 @@ void instance_destroy(int instance_id) { iptr[j] = -1; } - while( instances[instance_id].num_map && last != instances[instance_id].map[0] ) { // Remove all maps from instance - last = instances[instance_id].map[0]; - instance->del_map( instances[instance_id].map[0] ); + while( instance->list[instance_id].num_map && last != instance->list[instance_id].map[0] ) { // Remove all maps from instance + last = instance->list[instance_id].map[0]; + instance->del_map( instance->list[instance_id].map[0] ); } - if( instances[instance_id].vars ) - db_destroy(instances[instance_id].vars); + if( instance->list[instance_id].vars ) + db_destroy(instance->list[instance_id].vars); - if( instances[instance_id].progress_timer != INVALID_TIMER ) - timer->delete( instances[instance_id].progress_timer, instance_destroy_timer); - if( instances[instance_id].idle_timer != INVALID_TIMER ) - timer->delete( instances[instance_id].idle_timer, instance_destroy_timer); + if( instance->list[instance_id].progress_timer != INVALID_TIMER ) + timer->delete( instance->list[instance_id].progress_timer, instance->destroy_timer); + if( instance->list[instance_id].idle_timer != INVALID_TIMER ) + timer->delete( instance->list[instance_id].idle_timer, instance->destroy_timer); - instances[instance_id].vars = NULL; + instance->list[instance_id].vars = NULL; - if( instances[instance_id].map ) - aFree(instances[instance_id].map); + if( instance->list[instance_id].map ) + aFree(instance->list[instance_id].map); - instances[instance_id].map = NULL; - instances[instance_id].state = INSTANCE_FREE; - instances[instance_id].num_map = 0; + instance->list[instance_id].map = NULL; + instance->list[instance_id].state = INSTANCE_FREE; + instance->list[instance_id].num_map = 0; } /*-------------------------------------- @@ -530,20 +530,20 @@ void instance_check_idle(int instance_id) { bool idle = true; unsigned int now = (unsigned int)time(NULL); - if( !instance->valid(instance_id) || instances[instance_id].idle_timeoutval == 0 ) + if( !instance->valid(instance_id) || instance->list[instance_id].idle_timeoutval == 0 ) return; - if( instances[instance_id].users ) + if( instance->list[instance_id].users ) idle = false; - if( instances[instance_id].idle_timer != INVALID_TIMER && !idle ) { - timer->delete(instances[instance_id].idle_timer, instance_destroy_timer); - instances[instance_id].idle_timer = INVALID_TIMER; - instances[instance_id].idle_timeout = 0; + if( instance->list[instance_id].idle_timer != INVALID_TIMER && !idle ) { + timer->delete(instance->list[instance_id].idle_timer, instance->destroy_timer); + instance->list[instance_id].idle_timer = INVALID_TIMER; + instance->list[instance_id].idle_timeout = 0; clif->instance(instance_id, 3, 0); // Notify instance users normal instance expiration - } else if( instances[instance_id].idle_timer == INVALID_TIMER && idle ) { - instances[instance_id].idle_timeout = now + instances[instance_id].idle_timeoutval; - instances[instance_id].idle_timer = timer->add( timer->gettick() + instances[instance_id].idle_timeoutval * 1000, instance_destroy_timer, instance_id, 0); + } else if( instance->list[instance_id].idle_timer == INVALID_TIMER && idle ) { + instance->list[instance_id].idle_timeout = now + instance->list[instance_id].idle_timeoutval; + instance->list[instance_id].idle_timer = timer->add( timer->gettick() + instance->list[instance_id].idle_timeoutval * 1000, instance->destroy_timer, instance_id, 0); clif->instance(instance_id, 4, 0); // Notify instance users it will be destroyed of no user join it again in "X" time } } @@ -558,30 +558,30 @@ void instance_set_timeout(int instance_id, unsigned int progress_timeout, unsign if( !instance->valid(instance_id) ) return; - if( instances[instance_id].progress_timer != INVALID_TIMER ) - timer->delete( instances[instance_id].progress_timer, instance_destroy_timer); - if( instances[instance_id].idle_timer != INVALID_TIMER ) - timer->delete( instances[instance_id].idle_timer, instance_destroy_timer); + if( instance->list[instance_id].progress_timer != INVALID_TIMER ) + timer->delete( instance->list[instance_id].progress_timer, instance->destroy_timer); + if( instance->list[instance_id].idle_timer != INVALID_TIMER ) + timer->delete( instance->list[instance_id].idle_timer, instance->destroy_timer); if( progress_timeout ) { - instances[instance_id].progress_timeout = now + progress_timeout; - instances[instance_id].progress_timer = timer->add( timer->gettick() + progress_timeout * 1000, instance_destroy_timer, instance_id, 0); + instance->list[instance_id].progress_timeout = now + progress_timeout; + instance->list[instance_id].progress_timer = timer->add( timer->gettick() + progress_timeout * 1000, instance->destroy_timer, instance_id, 0); } else { - instances[instance_id].progress_timeout = 0; - instances[instance_id].progress_timer = INVALID_TIMER; + instance->list[instance_id].progress_timeout = 0; + instance->list[instance_id].progress_timer = INVALID_TIMER; } if( idle_timeout ) { - instances[instance_id].idle_timeoutval = idle_timeout; - instances[instance_id].idle_timer = INVALID_TIMER; - instance_check_idle(instance_id); + instance->list[instance_id].idle_timeoutval = idle_timeout; + instance->list[instance_id].idle_timer = INVALID_TIMER; + instance->check_idle(instance_id); } else { - instances[instance_id].idle_timeoutval = 0; - instances[instance_id].idle_timeout = 0; - instances[instance_id].idle_timer = INVALID_TIMER; + instance->list[instance_id].idle_timeoutval = 0; + instance->list[instance_id].idle_timeout = 0; + instance->list[instance_id].idle_timer = INVALID_TIMER; } - if( instances[instance_id].idle_timer == INVALID_TIMER && instances[instance_id].progress_timer != INVALID_TIMER ) + if( instance->list[instance_id].idle_timer == INVALID_TIMER && instance->list[instance_id].progress_timer != INVALID_TIMER ) clif->instance(instance_id, 3, 0); } @@ -592,9 +592,9 @@ void instance_check_kick(struct map_session_data *sd) { int16 m = sd->bl.m; clif->instance_leave(sd->fd); - if( maplist[m].instance_id >= 0 ) { // User was on the instance map - if( maplist[m].save.map ) - pc->setpos(sd, maplist[m].save.map, maplist[m].save.x, maplist[m].save.y, CLR_TELEPORT); + if( map->list[m].instance_id >= 0 ) { // User was on the instance map + if( map->list[m].save.map ) + pc->setpos(sd, map->list[m].save.map, map->list[m].save.x, map->list[m].save.y, CLR_TELEPORT); else pc->setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, CLR_TELEPORT); } @@ -607,14 +607,15 @@ void do_final_instance(void) { instance->destroy(i); } - if( instances ) - aFree(instances); + if( instance->list ) + aFree(instance->list); + instance->list = NULL; instance->instances = 0; } void do_init_instance(void) { - timer->add_func_list(instance_destroy_timer, "instance_destroy_timer"); + timer->add_func_list(instance->destroy_timer, "instance_destroy_timer"); } void instance_defaults(void) { @@ -627,7 +628,8 @@ void instance_defaults(void) { instance->start_id = 0; /* count */ instance->instances = 0; - + /* */ + instance->list = NULL; /* */ instance->create = instance_create; instance->add_map = instance_add_map; @@ -640,4 +642,5 @@ void instance_defaults(void) { instance->check_kick = instance_check_kick; instance->set_timeout = instance_set_timeout; instance->valid = instance_is_valid; + instance->destroy_timer = instance_destroy_timer; } |