diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/map/clif.c | 32 | ||||
-rw-r--r-- | src/map/instance.c | 171 | ||||
-rw-r--r-- | src/map/instance.h | 7 | ||||
-rw-r--r-- | src/map/map.c | 4 | ||||
-rw-r--r-- | src/map/party.c | 8 | ||||
-rw-r--r-- | src/map/pc.c | 18 | ||||
-rw-r--r-- | src/map/script.c | 30 | ||||
-rw-r--r-- | src/map/unit.c | 2 |
8 files changed, 138 insertions, 134 deletions
diff --git a/src/map/clif.c b/src/map/clif.c index ed75e9aa0..d69d501ac 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -9368,7 +9368,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { maplist[sd->bl.m].users_pvp++; } if( maplist[sd->bl.m].instance_id >= 0 ) { - instances[maplist[sd->bl.m].instance_id].users++; + instance->list[maplist[sd->bl.m].instance_id].users++; instance->check_idle(maplist[sd->bl.m].instance_id); } sd->state.debug_remove_map = 0; // temporary state to track double remove_map's [FlavioJS] @@ -16017,20 +16017,20 @@ int clif_instance(int instance_id, int type, int flag) { unsigned char buf[255]; enum send_target target = PARTY; - switch( instances[instance_id].owner_type ) { + switch( instance->list[instance_id].owner_type ) { case IOT_NONE: return 0; case IOT_GUILD: target = GUILD; - sd = guild->getavailablesd(guild->search(instances[instance_id].owner_id)); + sd = guild->getavailablesd(guild->search(instance->list[instance_id].owner_id)); break; case IOT_PARTY: /* default is already PARTY */ - sd = party->getavailablesd(party->search(instances[instance_id].owner_id)); + sd = party->getavailablesd(party->search(instance->list[instance_id].owner_id)); break; case IOT_CHAR: target = SELF; - sd = map->id2sd(instances[instance_id].owner_id); + sd = map->id2sd(instance->list[instance_id].owner_id); break; } @@ -16043,7 +16043,7 @@ int clif_instance(int instance_id, int type, int flag) { // Required to start the instancing information window on Client // This window re-appear each "refresh" of client automatically until type 4 is send to client. WBUFW(buf,0) = 0x02CB; - memcpy(WBUFP(buf,2),instances[instance_id].name,INSTANCE_NAME_LENGTH); + memcpy(WBUFP(buf,2),instance->list[instance_id].name,INSTANCE_NAME_LENGTH); WBUFW(buf,63) = flag; clif->send(buf,packet_len(0x02CB),&sd->bl,target); break; @@ -16058,13 +16058,13 @@ int clif_instance(int instance_id, int type, int flag) { case 4: // S 0x2cd <Instance Name>.61B <Instance Remaining Time>.L <Instance Noplayers close time>.L WBUFW(buf,0) = 0x02CD; - memcpy(WBUFP(buf,2),instances[instance_id].name,61); + memcpy(WBUFP(buf,2),instance->list[instance_id].name,61); if( type == 3 ) { - WBUFL(buf,63) = instances[instance_id].progress_timeout; + WBUFL(buf,63) = instance->list[instance_id].progress_timeout; WBUFL(buf,67) = 0; } else { WBUFL(buf,63) = 0; - WBUFL(buf,67) = instances[instance_id].idle_timeout; + WBUFL(buf,67) = instance->list[instance_id].idle_timeout; } clif->send(buf,packet_len(0x02CD),&sd->bl,target); break; @@ -16086,24 +16086,24 @@ int clif_instance(int instance_id, int type, int flag) { void clif_instance_join(int fd, int instance_id) { - if( instances[instance_id].idle_timer != INVALID_TIMER ) { + if( instance->list[instance_id].idle_timer != INVALID_TIMER ) { WFIFOHEAD(fd,packet_len(0x02CD)); WFIFOW(fd,0) = 0x02CD; - memcpy(WFIFOP(fd,2),instances[instance_id].name,61); + memcpy(WFIFOP(fd,2),instance->list[instance_id].name,61); WFIFOL(fd,63) = 0; - WFIFOL(fd,67) = instances[instance_id].idle_timeout; + WFIFOL(fd,67) = instance->list[instance_id].idle_timeout; WFIFOSET(fd,packet_len(0x02CD)); - } else if( instances[instance_id].progress_timer != INVALID_TIMER ) { + } else if( instance->list[instance_id].progress_timer != INVALID_TIMER ) { WFIFOHEAD(fd,packet_len(0x02CD)); WFIFOW(fd,0) = 0x02CD; - memcpy(WFIFOP(fd,2),instances[instance_id].name,61); - WFIFOL(fd,63) = instances[instance_id].progress_timeout; + memcpy(WFIFOP(fd,2),instance->list[instance_id].name,61); + WFIFOL(fd,63) = instance->list[instance_id].progress_timeout; WFIFOL(fd,67) = 0; WFIFOSET(fd,packet_len(0x02CD)); } else { WFIFOHEAD(fd,packet_len(0x02CB)); WFIFOW(fd,0) = 0x02CB; - memcpy(WFIFOP(fd,2),instances[instance_id].name,61); + memcpy(WFIFOP(fd,2),instance->list[instance_id].name,61); WFIFOW(fd,63) = 0; WFIFOSET(fd,packet_len(0x02CB)); } diff --git a/src/map/instance.c b/src/map/instance.c index 5ef089fae..17b66fa75 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); @@ -244,9 +244,9 @@ int instance_add_map(const char *name, int instance_id, bool usebasename, const maplist[im].instance_src_map = m; maplist[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 + instance->list[instance_id].map[instance->list[instance_id].num_map - 1] = im; // Attach to actual instance map->addmap2db(&maplist[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] && maplist[instance->list[instance_id].map[i]].instance_src_map == m ) + return instance->list[instance_id].map[i]; } 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, maplist[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; } /*-------------------------------------- @@ -410,18 +410,18 @@ void instance_del_map(int16 m) { } // 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[maplist[m].instance_id].num_map; i++ ) { + if( instance->list[maplist[m].instance_id].map[i] == m ) { + instance->list[maplist[m].instance_id].num_map--; + for( ; i < instance->list[maplist[m].instance_id].num_map; i++ ) + instance->list[maplist[m].instance_id].map[i] = instance->list[maplist[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[maplist[m].instance_id].num_map ) + ShowError("map_instance_del: failed to remove %s from instance list (%s): %d\n", maplist[m].name, instance->list[maplist[m].instance_id].name, m); if( maplist[m].channel ) clif->chsys_delete(maplist[m].channel); @@ -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); } @@ -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; } diff --git a/src/map/instance.h b/src/map/instance.h index 164aaf662..ba6d26d59 100644 --- a/src/map/instance.h +++ b/src/map/instance.h @@ -42,14 +42,14 @@ struct instance_data { unsigned int idle_timeout, idle_timeoutval; }; -struct instance_data *instances; - struct instance_interface { void (*init) (void); void (*final) (void); /* start point */ unsigned short start_id; - unsigned short instances; + unsigned short instances;/* count */ + /* */ + struct instance_data *list;/* pointer to a chunk of consecutive memory, access via instance->list[0]..etc */ /* */ int (*create) (int party_id, const char *name, enum instance_owner_type type); int (*add_map) (const char *name, int instance_id, bool usebasename, const char *map_name); @@ -62,6 +62,7 @@ struct instance_interface { void (*check_kick) (struct map_session_data *sd); void (*set_timeout) (int instance_id, unsigned int progress_timeout, unsigned int idle_timeout); bool (*valid) (int instance_id); + int (*destroy_timer) (int tid, unsigned int tick, int id, intptr_t data); }; struct instance_interface *instance; diff --git a/src/map/map.c b/src/map/map.c index 5d58fd30e..37f0817c4 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -624,8 +624,8 @@ int map_foreachininstance(int (*func)(struct block_list*, va_list), int16 instan int i; int returnCount = 0; - for (i = 0; i < instances[instance_id].num_map; i++) { - int m = instances[instance_id].map[i]; + for (i = 0; i < instance->list[instance_id].num_map; i++) { + int m = instance->list[instance_id].map[i]; va_list ap; va_start(ap, type); returnCount += map_vforeachinmap(func, m, type, ap); diff --git a/src/map/party.c b/src/map/party.c index a4eb38629..db4b88f7d 100644 --- a/src/map/party.c +++ b/src/map/party.c @@ -319,7 +319,7 @@ int party_recv_info(struct party* sp, int char_id) clif->party_info(p,NULL); for( j = 0; j < p->instances; j++ ) { if( p->instance[j] >= 0 ) { - if( instances[p->instance[j]].idle_timer == INVALID_TIMER && instances[p->instance[j]].progress_timer == INVALID_TIMER ) + if( instance->list[p->instance[j]].idle_timer == INVALID_TIMER && instance->list[p->instance[j]].progress_timer == INVALID_TIMER ) continue; clif->instance_join(sd->fd, p->instance[j]); break; @@ -442,7 +442,7 @@ void party_member_joined(struct map_session_data *sd) p->data[i].sd = sd; for( j = 0; j < p->instances; j++ ) { if( p->instance[j] >= 0 ) { - if( instances[p->instance[j]].idle_timer == INVALID_TIMER && instances[p->instance[j]].progress_timer == INVALID_TIMER ) + if( instance->list[p->instance[j]].idle_timer == INVALID_TIMER && instance->list[p->instance[j]].progress_timer == INVALID_TIMER ) continue; clif->instance_join(sd->fd, p->instance[j]); break; @@ -504,7 +504,7 @@ int party_member_added(int party_id,int account_id,int char_id, int flag) { for( j = 0; j < p->instances; j++ ) { if( p->instance[j] >= 0 ) { - if( instances[p->instance[j]].idle_timer == INVALID_TIMER && instances[p->instance[j]].progress_timer == INVALID_TIMER ) + if( instance->list[p->instance[j]].idle_timer == INVALID_TIMER && instance->list[p->instance[j]].progress_timer == INVALID_TIMER ) continue; clif->instance_join(sd->fd, p->instance[j]); break; @@ -604,7 +604,7 @@ int party_broken(int party_id) for( j = 0; j < p->instances; j++ ) { if( p->instance[j] >= 0 ) { instance->destroy( p->instance[j] ); - instances[p->instance[j]].owner_id = 0; + instance->list[p->instance[j]].owner_id = 0; } } diff --git a/src/map/pc.c b/src/map/pc.c index d11eb7e75..e89ecb80a 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -4791,13 +4791,13 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y if( sd->instances ) { for( i = 0; i < sd->instances; i++ ) { if( sd->instance[i] >= 0 ) { - ARR_FIND(0, instances[sd->instance[i]].num_map, j, maplist[instances[sd->instance[i]].map[j]].instance_src_map == m && !maplist[instances[sd->instance[i]].map[j]].custom_name); - if( j != instances[sd->instance[i]].num_map ) + ARR_FIND(0, instance->list[sd->instance[i]].num_map, j, maplist[instance->list[sd->instance[i]].map[j]].instance_src_map == m && !maplist[instance->list[sd->instance[i]].map[j]].custom_name); + if( j != instance->list[sd->instance[i]].num_map ) break; } } if( i != sd->instances ) { - m = instances[sd->instance[i]].map[j]; + m = instance->list[sd->instance[i]].map[j]; mapindex = map_id2index(m); stop = true; } @@ -4805,13 +4805,13 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y if ( !stop && sd->status.party_id && (p = party->search(sd->status.party_id)) && p->instances ) { for( i = 0; i < p->instances; i++ ) { if( p->instance[i] >= 0 ) { - ARR_FIND(0, instances[p->instance[i]].num_map, j, maplist[instances[p->instance[i]].map[j]].instance_src_map == m && !maplist[instances[p->instance[i]].map[j]].custom_name); - if( j != instances[p->instance[i]].num_map ) + ARR_FIND(0, instance->list[p->instance[i]].num_map, j, maplist[instance->list[p->instance[i]].map[j]].instance_src_map == m && !maplist[instance->list[p->instance[i]].map[j]].custom_name); + if( j != instance->list[p->instance[i]].num_map ) break; } } if( i != p->instances ) { - m = instances[p->instance[i]].map[j]; + m = instance->list[p->instance[i]].map[j]; mapindex = map_id2index(m); stop = true; } @@ -4819,13 +4819,13 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y if ( !stop && sd->status.guild_id && sd->guild && sd->guild->instances ) { for( i = 0; i < sd->guild->instances; i++ ) { if( sd->guild->instance[i] >= 0 ) { - ARR_FIND(0, instances[sd->guild->instance[i]].num_map, j, maplist[instances[sd->guild->instance[i]].map[j]].instance_src_map == m && !maplist[instances[sd->guild->instance[i]].map[j]].custom_name); - if( j != instances[sd->guild->instance[i]].num_map ) + ARR_FIND(0, instance->list[sd->guild->instance[i]].num_map, j, maplist[instance->list[sd->guild->instance[i]].map[j]].instance_src_map == m && !maplist[instance->list[sd->guild->instance[i]].map[j]].custom_name); + if( j != instance->list[sd->guild->instance[i]].num_map ) break; } } if( i != sd->guild->instances ) { - m = instances[sd->guild->instance[i]].map[j]; + m = instance->list[sd->guild->instance[i]].map[j]; mapindex = map_id2index(m); stop = true; } diff --git a/src/map/script.c b/src/map/script.c index 06c97bbe6..59af8d2b7 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -2361,7 +2361,7 @@ void get_val(struct script_state* st, struct script_data* data) break; case '\'': if ( st->instance_id >= 0 ) { - data->u.str = (char*)idb_get(instances[st->instance_id].vars,reference_getuid(data)); + data->u.str = (char*)idb_get(instance->list[st->instance_id].vars,reference_getuid(data)); } else { ShowWarning("script_get_val: cannot access instance variable '%s', defaulting to \"\"\n", name); data->u.str = NULL; @@ -2416,7 +2416,7 @@ void get_val(struct script_state* st, struct script_data* data) break; case '\'': if( st->instance_id >= 0 ) - data->u.num = (int)idb_iget(instances[st->instance_id].vars,reference_getuid(data)); + data->u.num = (int)idb_iget(instance->list[st->instance_id].vars,reference_getuid(data)); else { ShowWarning("script_get_val: cannot access instance variable '%s', defaulting to 0\n", name); data->u.num = 0; @@ -2474,8 +2474,8 @@ static int set_reg(struct script_state* st, TBL_PC* sd, int num, const char* nam return 1; case '\'': if( st->instance_id >= 0 ) { - idb_remove(instances[st->instance_id].vars, num); - if( str[0] ) idb_put(instances[st->instance_id].vars, num, aStrdup(str)); + idb_remove(instance->list[st->instance_id].vars, num); + if( str[0] ) idb_put(instance->list[st->instance_id].vars, num, aStrdup(str)); } return 1; default: @@ -2522,9 +2522,9 @@ static int set_reg(struct script_state* st, TBL_PC* sd, int num, const char* nam return 1; case '\'': if( st->instance_id >= 0 ) { - idb_remove(instances[st->instance_id].vars, num); + idb_remove(instance->list[st->instance_id].vars, num); if( val != 0 ) - idb_iput(instances[st->instance_id].vars, num, val); + idb_iput(instance->list[st->instance_id].vars, num, val); } return 1; default: @@ -15930,7 +15930,7 @@ BUILDIN(instance_init) { return true; } - if( instances[instance_id].state != INSTANCE_IDLE ) { + if( instance->list[instance_id].state != INSTANCE_IDLE ) { ShowError("instance_init: instance already initialized.\n"); return true; } @@ -15961,8 +15961,8 @@ BUILDIN(instance_announce) { if( !instance->valid(instance_id) ) return true; - for( i = 0; i < instances[instance_id].num_map; i++ ) - map->foreachinmap(buildin_announce_sub, instances[instance_id].map[i], BL_PC, + for( i = 0; i < instance->list[instance_id].num_map; i++ ) + map->foreachinmap(buildin_announce_sub, instance->list[instance_id].map[i], BL_PC, mes, strlen(mes)+1, flag&BC_COLOR_MASK, fontColor, fontType, fontSize, fontAlign, fontY); return true; @@ -16015,8 +16015,8 @@ BUILDIN(has_instance) { if( sd->instances ) { for( i = 0; i < sd->instances; i++ ) { if( sd->instance[i] >= 0 ) { - ARR_FIND(0, instances[sd->instance[i]].num_map, j, maplist[instances[sd->instance[i]].map[j]].instance_src_map == m); - if( j != instances[sd->instance[i]].num_map ) + ARR_FIND(0, instance->list[sd->instance[i]].num_map, j, maplist[instance->list[sd->instance[i]].map[j]].instance_src_map == m); + if( j != instance->list[sd->instance[i]].num_map ) break; } } @@ -16026,8 +16026,8 @@ BUILDIN(has_instance) { if( instance_id == -1 && sd->status.party_id && (p = party->search(sd->status.party_id)) && p->instances ) { for( i = 0; i < p->instances; i++ ) { if( p->instance[i] >= 0 ) { - ARR_FIND(0, instances[p->instance[i]].num_map, j, maplist[instances[p->instance[i]].map[j]].instance_src_map == m); - if( j != instances[p->instance[i]].num_map ) + ARR_FIND(0, instance->list[p->instance[i]].num_map, j, maplist[instance->list[p->instance[i]].map[j]].instance_src_map == m); + if( j != instance->list[p->instance[i]].num_map ) break; } } @@ -16037,8 +16037,8 @@ BUILDIN(has_instance) { if( instance_id == -1 && sd->guild && sd->guild->instances ) { for( i = 0; i < sd->guild->instances; i++ ) { if( sd->guild->instance[i] >= 0 ) { - ARR_FIND(0, instances[sd->guild->instance[i]].num_map, j, maplist[instances[sd->guild->instance[i]].map[j]].instance_src_map == m); - if( j != instances[sd->guild->instance[i]].num_map ) + ARR_FIND(0, instance->list[sd->guild->instance[i]].num_map, j, maplist[instance->list[sd->guild->instance[i]].map[j]].instance_src_map == m); + if( j != instance->list[sd->guild->instance[i]].num_map ) break; } } diff --git a/src/map/unit.c b/src/map/unit.c index 9d6f107e3..488a210bf 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -2197,7 +2197,7 @@ int unit_remove_map(struct block_list *bl, clr_type clrtype, const char* file, i --maplist[bl->m].users_pvp; } if( maplist[bl->m].instance_id >= 0 ) { - instances[maplist[bl->m].instance_id].users--; + instance->list[maplist[bl->m].instance_id].users--; instance->check_idle(maplist[bl->m].instance_id); } sd->state.debug_remove_map = 1; // temporary state to track double remove_map's [FlavioJS] |