summaryrefslogtreecommitdiff
path: root/src/map/map.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/map/map.c')
-rw-r--r--src/map/map.c64
1 files changed, 31 insertions, 33 deletions
diff --git a/src/map/map.c b/src/map/map.c
index 099d2c6ea..7ff4ebcc5 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -695,7 +695,7 @@ int map_vforeachinrange(int (*func)(struct block_list*, va_list), struct block_l
va_copy(apcopy, ap);
returnCount = bl_vforeach(func, blockcount, INT_MAX, apcopy);
- va_end(ap);
+ va_end(apcopy);
return returnCount;
}
@@ -2239,7 +2239,7 @@ bool map_addnpc(int16 m,struct npc_data *nd) {
// Stores the spawn data entry in the mob list.
// Returns the index of successful, or -1 if the list was full.
int map_addmobtolist(unsigned short m, struct spawn_data *spawn) {
- size_t i;
+ int i;
ARR_FIND( 0, MAX_MOB_LIST_PER_MAP, i, map->list[m].moblist[i] == NULL );
if( i < MAX_MOB_LIST_PER_MAP ) {
map->list[m].moblist[i] = spawn;
@@ -2330,7 +2330,7 @@ void map_removemobs(int16 m) {
*------------------------------------------*/
int16 map_mapname2mapid(const char* name) {
unsigned short map_index;
- map_index = mapindex_name2id(name);
+ map_index = mapindex->name2id(name);
if (!map_index)
return -1;
return map->mapindex2mapid(map_index);
@@ -2339,12 +2339,12 @@ int16 map_mapname2mapid(const char* name) {
/*==========================================
* Returns the map of the given mapindex. [Skotlex]
*------------------------------------------*/
-int16 map_mapindex2mapid(unsigned short mapindex) {
+int16 map_mapindex2mapid(unsigned short map_index) {
- if (!mapindex || mapindex > MAX_MAPINDEX)
+ if (!map_index || map_index > MAX_MAPINDEX)
return -1;
- return map->index2mapid[mapindex];
+ return map->index2mapid[map_index];
}
/*==========================================
@@ -2766,27 +2766,27 @@ void map_iwall_remove(const char *wall_name)
DBData create_map_data_other_server(DBKey key, va_list args)
{
struct map_data_other_server *mdos;
- unsigned short mapindex = (unsigned short)key.ui;
+ unsigned short map_index = (unsigned short)key.ui;
mdos=(struct map_data_other_server *)aCalloc(1,sizeof(struct map_data_other_server));
- mdos->index = mapindex;
- memcpy(mdos->name, mapindex_id2name(mapindex), MAP_NAME_LENGTH);
+ mdos->index = map_index;
+ memcpy(mdos->name, mapindex_id2name(map_index), MAP_NAME_LENGTH);
return DB->ptr2data(mdos);
}
/*==========================================
* Add mapindex to db of another map server
*------------------------------------------*/
-int map_setipport(unsigned short mapindex, uint32 ip, uint16 port)
+int map_setipport(unsigned short map_index, uint32 ip, uint16 port)
{
struct map_data_other_server *mdos;
- mdos= uidb_ensure(map->map_db,(unsigned int)mapindex, map->create_map_data_other_server);
+ mdos= uidb_ensure(map->map_db,(unsigned int)map_index, map->create_map_data_other_server);
if(mdos->cell) //Local map,Do nothing. Give priority to our own local maps over ones from another server. [Skotlex]
return 0;
if(ip == clif->map_ip && port == clif->map_port) {
//That's odd, we received info that we are the ones with this map, but... we don't have it.
- ShowFatalError("map_setipport : received info that this map-server SHOULD have map '%s', but it is not loaded.\n",mapindex_id2name(mapindex));
+ ShowFatalError("map_setipport : received info that this map-server SHOULD have map '%s', but it is not loaded.\n",mapindex_id2name(map_index));
exit(EXIT_FAILURE);
}
mdos->ip = ip;
@@ -2816,15 +2816,15 @@ int map_eraseallipport(void) {
/*==========================================
* Delete mapindex from db of another map server
*------------------------------------------*/
-int map_eraseipport(unsigned short mapindex, uint32 ip, uint16 port) {
+int map_eraseipport(unsigned short map_index, uint32 ip, uint16 port) {
struct map_data_other_server *mdos;
- mdos = (struct map_data_other_server*)uidb_get(map->map_db,(unsigned int)mapindex);
+ mdos = (struct map_data_other_server*)uidb_get(map->map_db,(unsigned int)map_index);
if(!mdos || mdos->cell) //Map either does not exists or is a local map.
return 0;
if(mdos->ip==ip && mdos->port == port) {
- uidb_remove(map->map_db,(unsigned int)mapindex);
+ uidb_remove(map->map_db,(unsigned int)map_index);
aFree(mdos);
return 1;
}
@@ -2908,7 +2908,7 @@ int map_readfromcache(struct map_data *m, char *buffer) {
int map_addmap(const char* mapname) {
map->list[map->count].instance_id = -1;
- mapindex_getmapname(mapname, map->list[map->count++].name);
+ mapindex->getmapname(mapname, map->list[map->count++].name);
return 0;
}
@@ -2927,7 +2927,7 @@ int map_delmap(char* mapname) {
return 0;
}
- mapindex_getmapname(mapname, map_name);
+ mapindex->getmapname(mapname, map_name);
for(i = 0; i < map->count; i++) {
if (strcmp(map->list[i].name, map_name) == 0) {
map->delmapid(i);
@@ -3318,7 +3318,7 @@ int map_readallmaps (void) {
continue;
}
- map->list[i].index = mapindex_name2id(map->list[i].name);
+ map->list[i].index = mapindex->name2id(map->list[i].name);
if ( map->index2mapid[map_id2index(i)] != -1 ) {
ShowWarning("Map %s already loaded!"CL_CLL"\n", map->list[i].name);
@@ -3684,7 +3684,7 @@ void map_zone_remove(int m) {
unsigned short k;
char empty[1] = "\0";
for(k = 0; k < map->list[m].zone_mf_count; k++) {
- int len = strlen(map->list[m].zone_mf[k]),j;
+ size_t len = strlen(map->list[m].zone_mf[k]),j;
params[0] = '\0';
memcpy(flag, map->list[m].zone_mf[k], MAP_ZONE_MAPFLAG_LENGTH);
for(j = 0; j < len; j++) {
@@ -4236,7 +4236,7 @@ bool map_zone_mf_cache(int m, char *flag, char *params) {
} else if (!strcmpi(flag,"adjust_unit_duration")) {
int skill_id, k;
char skill_name[MAP_ZONE_MAPFLAG_LENGTH], modifier[MAP_ZONE_MAPFLAG_LENGTH];
- int len = strlen(params);
+ size_t len = strlen(params);
modifier[0] = '\0';
memcpy(skill_name, params, MAP_ZONE_MAPFLAG_LENGTH);
@@ -4254,7 +4254,6 @@ bool map_zone_mf_cache(int m, char *flag, char *params) {
} else {
int idx = map->list[m].unit_count;
- k = 0;
ARR_FIND(0, idx, k, map->list[m].units[k]->skill_id == skill_id);
if( k < idx ) {
@@ -4270,7 +4269,7 @@ bool map_zone_mf_cache(int m, char *flag, char *params) {
} else if (!strcmpi(flag,"adjust_skill_damage")) {
int skill_id, k;
char skill_name[MAP_ZONE_MAPFLAG_LENGTH], modifier[MAP_ZONE_MAPFLAG_LENGTH];
- int len = strlen(params);
+ size_t len = strlen(params);
modifier[0] = '\0';
memcpy(skill_name, params, MAP_ZONE_MAPFLAG_LENGTH);
@@ -4288,7 +4287,6 @@ bool map_zone_mf_cache(int m, char *flag, char *params) {
} else {
int idx = map->list[m].skill_count;
- k = 0;
ARR_FIND(0, idx, k, map->list[m].skills[k]->skill_id == skill_id);
if( k < idx ) {
@@ -4414,7 +4412,7 @@ void map_zone_apply(int m, struct map_zone_data *zone, const char* start, const
char flag[MAP_ZONE_MAPFLAG_LENGTH], params[MAP_ZONE_MAPFLAG_LENGTH];
map->list[m].zone = zone;
for(i = 0; i < zone->mapflags_count; i++) {
- int len = strlen(zone->mapflags[i]);
+ size_t len = strlen(zone->mapflags[i]);
int k;
params[0] = '\0';
memcpy(flag, zone->mapflags[i], MAP_ZONE_MAPFLAG_LENGTH);
@@ -4442,7 +4440,7 @@ void map_zone_init(void) {
zone = &map->zone_all;
for(i = 0; i < zone->mapflags_count; i++) {
- int len = strlen(zone->mapflags[i]);
+ size_t len = strlen(zone->mapflags[i]);
params[0] = '\0';
memcpy(flag, zone->mapflags[i], MAP_ZONE_MAPFLAG_LENGTH);
for(k = 0; k < len; k++) {
@@ -4465,7 +4463,7 @@ void map_zone_init(void) {
if( battle_config.pk_mode ) {
zone = &map->zone_pk;
for(i = 0; i < zone->mapflags_count; i++) {
- int len = strlen(zone->mapflags[i]);
+ size_t len = strlen(zone->mapflags[i]);
params[0] = '\0';
memcpy(flag, zone->mapflags[i], MAP_ZONE_MAPFLAG_LENGTH);
for(k = 0; k < len; k++) {
@@ -5116,6 +5114,7 @@ void do_final(void)
ircbot->final();/* before clif. */
clif->final();
npc->final();
+ quest->final();
script->final();
itemdb->final();
instance->final();
@@ -5140,7 +5139,7 @@ void do_final(void)
map->map_db->destroy(map->map_db, map->db_final);
- mapindex_final();
+ mapindex->final();
if(map->enable_grf)
grfio_final();
@@ -5366,18 +5365,17 @@ void map_hp_symbols(void) {
#ifdef PCRE_SUPPORT
HPM->share(npc_chat,"npc_chat");
#endif
- /* partial */
HPM->share(mapit,"mapit");
+ HPM->share(mapindex,"mapindex");
/* sql link */
HPM->share(map->mysql_handle,"sql_handle");
/* specific */
HPM->share(atcommand->create,"addCommand");
HPM->share(script->addScript,"addScript");
- /* vars */
- HPM->share(map->list,"map->list");
}
void map_load_defaults(void) {
+ mapindex_defaults();
map_defaults();
/* */
atcommand_defaults();
@@ -5553,9 +5551,9 @@ int do_init(int argc, char *argv[])
map->iwall_db = strdb_alloc(DB_OPT_RELEASE_DATA,2*NAME_LENGTH+2+1); // [Zephyrus] Invisible Walls
map->zone_db = strdb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, MAP_ZONE_NAME_LENGTH);
- map->iterator_ers = ers_new(sizeof(struct s_mapiterator),"map.c::map_iterator_ers",ERS_OPT_NONE);
+ map->iterator_ers = ers_new(sizeof(struct s_mapiterator),"map.c::map_iterator_ers",ERS_OPT_CLEAN);
- map->flooritem_ers = ers_new(sizeof(struct flooritem_data),"map.c::map_flooritem_ers",ERS_OPT_NONE);
+ map->flooritem_ers = ers_new(sizeof(struct flooritem_data),"map.c::map_flooritem_ers",ERS_OPT_CLEAN);
ers_chunk_size(map->flooritem_ers, 100);
if (!minimal) {
@@ -5564,7 +5562,7 @@ int do_init(int argc, char *argv[])
logs->sql_init();
}
- i = mapindex_init();
+ i = mapindex->init();
if (minimal) {
// Pretend all maps from the mapindex are on this mapserver