diff options
-rw-r--r-- | src/char/char.c | 42 | ||||
-rw-r--r-- | src/char/int_party.c | 2 | ||||
-rw-r--r-- | src/common/mapindex.c | 92 | ||||
-rw-r--r-- | src/common/mapindex.h | 54 | ||||
-rw-r--r-- | src/map/atcommand.c | 26 | ||||
-rw-r--r-- | src/map/clif.c | 22 | ||||
-rw-r--r-- | src/map/guild.c | 8 | ||||
-rw-r--r-- | src/map/instance.c | 6 | ||||
-rw-r--r-- | src/map/map.c | 25 | ||||
-rw-r--r-- | src/map/npc.c | 8 | ||||
-rw-r--r-- | src/map/pc.c | 26 | ||||
-rw-r--r-- | src/map/pc.h | 2 | ||||
-rw-r--r-- | src/map/script.c | 82 | ||||
-rw-r--r-- | src/map/skill.c | 25 |
14 files changed, 226 insertions, 194 deletions
diff --git a/src/char/char.c b/src/char/char.c index e58fc9eef..6534f484c 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -1073,7 +1073,7 @@ int mmo_chars_fromsql(struct char_session_data* sd, uint8* buf) } for( i = 0; i < MAX_CHARS && SQL_SUCCESS == SQL->StmtNextRow(stmt); i++ ) { - p.last_point.map = mapindex_name2id(last_map); + p.last_point.map = mapindex->name2id(last_map); sd->found_char[p.slot] = p.char_id; sd->unban_time[p.slot] = unban_time; j += mmo_char_tobuf(WBUFP(buf, j), &p); @@ -1199,17 +1199,17 @@ int mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_everything account_id = p->account_id; - p->last_point.map = mapindex_name2id(last_map); - p->save_point.map = mapindex_name2id(save_map); + p->last_point.map = mapindex->name2id(last_map); + p->save_point.map = mapindex->name2id(save_map); if( p->last_point.map == 0 ) { - p->last_point.map = (unsigned short)strdb_iget(mapindex_db, MAP_DEFAULT); + p->last_point.map = (unsigned short)strdb_iget(mapindex->db, MAP_DEFAULT); p->last_point.x = MAP_DEFAULT_X; p->last_point.y = MAP_DEFAULT_Y; } if( p->save_point.map == 0 ) { - p->save_point.map = (unsigned short)strdb_iget(mapindex_db, MAP_DEFAULT); + p->save_point.map = (unsigned short)strdb_iget(mapindex->db, MAP_DEFAULT); p->save_point.x = MAP_DEFAULT_X; p->save_point.y = MAP_DEFAULT_Y; } @@ -1233,7 +1233,7 @@ int mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_everything SqlStmt_ShowDebug(stmt); for( i = 0; i < MAX_MEMOPOINTS && SQL_SUCCESS == SQL->StmtNextRow(stmt); ++i ) { - tmp_point.map = mapindex_name2id(point_map); + tmp_point.map = mapindex->name2id(point_map); memcpy(&p->memo_point[i], &tmp_point, sizeof(tmp_point)); } strcat(t_msg, " memo"); @@ -1913,7 +1913,7 @@ int mmo_char_tobuf(uint8* buffer, struct mmo_charstatus* p) { offset += 2; #endif #if (PACKETVER >= 20100720 && PACKETVER <= 20100727) || PACKETVER >= 20100803 - mapindex_getmapname_ext(mapindex_id2name(p->last_point.map), (char*)WBUFP(buf,108)); + mapindex->getmapname_ext(mapindex_id2name(p->last_point.map), (char*)WBUFP(buf,108)); offset += MAP_NAME_LENGTH_EXT; #endif #if PACKETVER >= 20100803 @@ -4140,22 +4140,22 @@ int parse_char(int fd) WFIFOSET(fd,3); break; } - if ((i = search_mapserver((j=mapindex_name2id(MAP_PRONTERA)),-1,-1)) >= 0) { + if ((i = search_mapserver((j=mapindex->name2id(MAP_PRONTERA)),-1,-1)) >= 0) { cd->last_point.x = 273; cd->last_point.y = 354; - } else if ((i = search_mapserver((j=mapindex_name2id(MAP_GEFFEN)),-1,-1)) >= 0) { + } else if ((i = search_mapserver((j=mapindex->name2id(MAP_GEFFEN)),-1,-1)) >= 0) { cd->last_point.x = 120; cd->last_point.y = 100; - } else if ((i = search_mapserver((j=mapindex_name2id(MAP_MORROC)),-1,-1)) >= 0) { + } else if ((i = search_mapserver((j=mapindex->name2id(MAP_MORROC)),-1,-1)) >= 0) { cd->last_point.x = 160; cd->last_point.y = 94; - } else if ((i = search_mapserver((j=mapindex_name2id(MAP_ALBERTA)),-1,-1)) >= 0) { + } else if ((i = search_mapserver((j=mapindex->name2id(MAP_ALBERTA)),-1,-1)) >= 0) { cd->last_point.x = 116; cd->last_point.y = 57; - } else if ((i = search_mapserver((j=mapindex_name2id(MAP_PAYON)),-1,-1)) >= 0) { + } else if ((i = search_mapserver((j=mapindex->name2id(MAP_PAYON)),-1,-1)) >= 0) { cd->last_point.x = 87; cd->last_point.y = 117; - } else if ((i = search_mapserver((j=mapindex_name2id(MAP_IZLUDE)),-1,-1)) >= 0) { + } else if ((i = search_mapserver((j=mapindex->name2id(MAP_IZLUDE)),-1,-1)) >= 0) { cd->last_point.x = 94; cd->last_point.y = 103; } else { @@ -4189,7 +4189,7 @@ int parse_char(int fd) WFIFOHEAD(fd,28); WFIFOW(fd,0) = 0x71; WFIFOL(fd,2) = cd->char_id; - mapindex_getmapname_ext(mapindex_id2name(cd->last_point.map), (char*)WFIFOP(fd,6)); + mapindex->getmapname_ext(mapindex_id2name(cd->last_point.map), (char*)WFIFOP(fd,6)); subnet_map_ip = lan_subnetcheck(ipl); // Advanced subnet check [LuzZza] WFIFOL(fd,22) = htonl((subnet_map_ip) ? subnet_map_ip : server[i].ip); WFIFOW(fd,26) = ntows(htons(server[i].port)); // [!] LE byte order here [!] @@ -5014,7 +5014,7 @@ int char_config_read(const char* cfgName) int x, y; if (sscanf(w2, "%15[^,],%d,%d", map, &x, &y) < 3) continue; - start_point.map = mapindex_name2id(map); + start_point.map = mapindex->name2id(map); if (!start_point.map) ShowError("Specified start_point %s not found in map-index cache.\n", map); start_point.x = x; @@ -5122,7 +5122,7 @@ void do_final(void) { } SQL->Free(sql_handle); - mapindex_final(); + mapindex->final(); for(i = 0; i < MAX_MAP_SERVERS; i++ ) if( server[i].map ) @@ -5169,13 +5169,13 @@ int do_init(int argc, char **argv) { for(i = 0; i < MAX_MAP_SERVERS; i++ ) server[i].map = NULL; - //Read map indexes - mapindex_init(); - start_point.map = mapindex_name2id("new_zone01"); - - + mapindex_defaults(); pincode_defaults(); + //Read map indexes + mapindex->init(); + start_point.map = mapindex->name2id("new_zone01"); + char_config_read((argc < 2) ? CHAR_CONF_NAME : argv[1]); char_lan_config_read((argc > 3) ? argv[3] : LAN_CONF_NAME); sql_config_read(SQL_CONF_NAME); diff --git a/src/char/int_party.c b/src/char/int_party.c index 9cb4ccf80..7c328c452 100644 --- a/src/char/int_party.c +++ b/src/char/int_party.c @@ -241,7 +241,7 @@ struct party_data *inter_party_fromsql(int party_id) SQL->GetData(sql_handle, 1, &data, NULL); m->char_id = atoi(data); SQL->GetData(sql_handle, 2, &data, &len); memcpy(m->name, data, min(len, NAME_LENGTH)); SQL->GetData(sql_handle, 3, &data, NULL); m->lv = atoi(data); - SQL->GetData(sql_handle, 4, &data, NULL); m->map = mapindex_name2id(data); + SQL->GetData(sql_handle, 4, &data, NULL); m->map = mapindex->name2id(data); SQL->GetData(sql_handle, 5, &data, NULL); m->online = (atoi(data) ? 1 : 0); SQL->GetData(sql_handle, 6, &data, NULL); m->class_ = atoi(data); m->leader = (m->account_id == leader_id && m->char_id == leader_char ? 1 : 0); diff --git a/src/common/mapindex.c b/src/common/mapindex.c index 1d2569afe..3128a3cb0 100644 --- a/src/common/mapindex.c +++ b/src/common/mapindex.c @@ -13,19 +13,8 @@ #include <stdio.h> #include <stdlib.h> -struct _indexes { - char name[MAP_NAME_LENGTH]; //Stores map name -} indexes[MAX_MAPINDEX]; - -int max_index = 0; - -char mapindex_cfgfile[80] = "db/map_index.txt"; - -#define mapindex_exists_sub(id) (indexes[id].name[0] != '\0') - -bool mapindex_exists(int id) { - return mapindex_exists_sub(id); -} +/* mapindex.c interface source */ +struct mapindex_interface mapindex_s; /// Retrieves the map name from 'string' (removing .gat extension if present). /// Result gets placed either into 'buf' or in a static local buffer. @@ -83,9 +72,8 @@ int mapindex_addmap(int index, const char* name) { char map_name[MAP_NAME_LENGTH]; if (index == -1){ - for (index = 1; index < max_index; index++) { - //if (strcmp(indexes[index].name,"#CLEARED#")==0) - if (indexes[index].name[0] == '\0') + for (index = 1; index < mapindex->num; index++) { + if (mapindex->list[index].name[0] == '\0') break; } } @@ -95,7 +83,7 @@ int mapindex_addmap(int index, const char* name) { return 0; } - mapindex_getmapname(name, map_name); + mapindex->getmapname(name, map_name); if (map_name[0] == '\0') { ShowError("(mapindex_add) Cannot add maps with no name.\n"); @@ -107,15 +95,16 @@ int mapindex_addmap(int index, const char* name) { return 0; } - if (mapindex_exists_sub(index)) { - ShowWarning("(mapindex_add) Overriding index %d: map \"%s\" -> \"%s\"\n", index, indexes[index].name, map_name); - strdb_remove(mapindex_db, indexes[index].name); + if (mapindex_exists(index)) { + ShowWarning("(mapindex_add) Overriding index %d: map \"%s\" -> \"%s\"\n", index, mapindex->list[index].name, map_name); + strdb_remove(mapindex->db, mapindex->list[index].name); } - safestrncpy(indexes[index].name, map_name, MAP_NAME_LENGTH); - strdb_iput(mapindex_db, map_name, index); - if (max_index <= index) - max_index = index+1; + safestrncpy(mapindex->list[index].name, map_name, MAP_NAME_LENGTH); + strdb_iput(mapindex->db, map_name, index); + + if (mapindex->num <= index) + mapindex->num = index+1; return index; } @@ -124,9 +113,9 @@ unsigned short mapindex_name2id(const char* name) { int i; char map_name[MAP_NAME_LENGTH]; - mapindex_getmapname(name, map_name); + mapindex->getmapname(name, map_name); - if( (i = strdb_iget(mapindex_db, map_name)) ) + if( (i = strdb_iget(mapindex->db, map_name)) ) return i; ShowDebug("mapindex_name2id: Map \"%s\" not found in index list!\n", map_name); @@ -134,11 +123,11 @@ unsigned short mapindex_name2id(const char* name) { } const char* mapindex_id2name_sub(unsigned short id,const char *file, int line, const char *func) { - if (id > MAX_MAPINDEX || !mapindex_exists_sub(id)) { + if (id > MAX_MAPINDEX || !mapindex_exists(id)) { ShowDebug("mapindex_id2name: Requested name for non-existant map index [%d] in cache. %s:%s:%d\n", id,file,func,line); - return indexes[0].name; // dummy empty string so that the callee doesn't crash + return mapindex->list[0].name; // dummy empty string so that the callee doesn't crash } - return indexes[id].name; + return mapindex->list[id].name; } int mapindex_init(void) { @@ -148,12 +137,13 @@ int mapindex_init(void) { int index, total = 0; char map_name[12]; - if( ( fp = fopen(mapindex_cfgfile,"r") ) == NULL ){ - ShowFatalError("Unable to read mapindex config file %s!\n", mapindex_cfgfile); + if( ( fp = fopen(mapindex->config_file,"r") ) == NULL ){ + ShowFatalError("Unable to read mapindex config file %s!\n", mapindex->config_file); exit(EXIT_FAILURE); //Server can't really run without this file. } - memset (&indexes, 0, sizeof (indexes)); - mapindex_db = strdb_alloc(DB_OPT_DUP_KEY, MAP_NAME_LENGTH); + + mapindex->db = strdb_alloc(DB_OPT_DUP_KEY, MAP_NAME_LENGTH); + while(fgets(line, sizeof(line), fp)) { if(line[0] == '/' && line[1] == '/') continue; @@ -162,7 +152,7 @@ int mapindex_init(void) { case 1: //Map with no ID given, auto-assign index = last_index+1; case 2: //Map with ID given - mapindex_addmap(index,map_name); + mapindex->addmap(index,map_name); total++; break; default: @@ -172,18 +162,40 @@ int mapindex_init(void) { } fclose(fp); - if( !strdb_iget(mapindex_db, MAP_DEFAULT) ) { + if( !strdb_iget(mapindex->db, MAP_DEFAULT) ) { ShowError("mapindex_init: MAP_DEFAULT '%s' not found in cache! update mapindex.h MAP_DEFAULT var!!!\n",MAP_DEFAULT); } + return total; } -int mapindex_removemap(int index){ - strdb_remove(mapindex_db, indexes[index].name); - indexes[index].name[0] = '\0'; - return 0; +void mapindex_removemap(int index){ + strdb_remove(mapindex->db, mapindex->list[index].name); + mapindex->list[index].name[0] = '\0'; } void mapindex_final(void) { - db_destroy(mapindex_db); + db_destroy(mapindex->db); +} + +void mapindex_defaults(void) { + mapindex = &mapindex_s; + + /* TODO: place it in inter-server.conf? */ + snprintf(mapindex->config_file, 80, "%s","db/map_index.txt"); + /* */ + mapindex->db = NULL; + mapindex->num = 0; + memset (&mapindex->list, 0, sizeof (mapindex->list)); + + /* */ + mapindex->init = mapindex_init; + mapindex->final = mapindex_final; + /* */ + mapindex->addmap = mapindex_addmap; + mapindex->removemap = mapindex_removemap; + mapindex->getmapname = mapindex_getmapname; + mapindex->getmapname_ext = mapindex_getmapname_ext; + mapindex->name2id = mapindex_name2id; + mapindex->id2name = mapindex_id2name_sub; } diff --git a/src/common/mapindex.h b/src/common/mapindex.h index cf5486808..98150f441 100644 --- a/src/common/mapindex.h +++ b/src/common/mapindex.h @@ -6,17 +6,16 @@ #define _MAPINDEX_H_ #include "../common/db.h" +#include "../common/mmo.h" + +#define MAX_MAPINDEX 2000 + +/* wohoo, someone look at all those |: map_default could (or *should*) be a char-server.conf */ // When a map index search fails, return results from what map? default:prontera #define MAP_DEFAULT "prontera" #define MAP_DEFAULT_X 150 #define MAP_DEFAULT_Y 150 -DBMap *mapindex_db; - -//File in charge of assigning a numberic ID to each map in existance for space saving when passing map info between servers. -extern char mapindex_cfgfile[80]; - -#define MAX_MAPINDEX 2000 //Some definitions for the mayor city maps. #define MAP_PRONTERA "prontera" @@ -56,16 +55,39 @@ extern char mapindex_cfgfile[80]; #define MAP_MALAYA "malaya" #define MAP_ECLAGE "eclage" -bool mapindex_exists(int id); -const char* mapindex_getmapname(const char* string, char* output); -const char* mapindex_getmapname_ext(const char* string, char* output); -unsigned short mapindex_name2id(const char*); -#define mapindex_id2name(n) mapindex_id2name_sub((n),__FILE__, __LINE__, __func__) -const char* mapindex_id2name_sub(unsigned short,const char *file, int line, const char *func); -int mapindex_init(void); -void mapindex_final(void); +#define mapindex_id2name(n) mapindex->id2name((n),__FILE__, __LINE__, __func__) +#define mapindex_exists(n) ( mapindex->list[(n)].name[0] != '\0' ) + +/** + * mapindex.c interface + **/ +struct mapindex_interface { + char config_file[80]; + /* mapname (str) -> index (int) */ + DBMap *db; + /* number of entries in the index table */ + int num; + /* index list -- since map server map count is *unlimited* this should be too */ + struct { + char name[MAP_NAME_LENGTH]; + } list[MAX_MAPINDEX]; + /* */ + int (*init) (void); + void (*final) (void); + /* */ + int (*addmap) (int index, const char* name); + void (*removemap) (int index); + const char* (*getmapname) (const char* string, char* output); + /* TODO: server shouldn't be handling the extension, game client automatically adds .gat/.rsw/.whatever + * and there are official map names taking advantage of it that we cant support due to the .gat room being saved */ + const char* (*getmapname_ext) (const char* string, char* output); + /* TODO: Hello World! make up your mind, this thing is int on some places and unsigned short on others */ + unsigned short (*name2id) (const char*); + const char* (*id2name) (unsigned short,const char *file, int line, const char *func); +}; + +struct mapindex_interface *mapindex; -int mapindex_addmap(int index, const char* name); -int mapindex_removemap(int index); +void mapindex_defaults(void); #endif /* _MAPINDEX_H_ */ diff --git a/src/map/atcommand.c b/src/map/atcommand.c index be68a399e..da89f0008 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -375,7 +375,7 @@ ACMD(send) *------------------------------------------*/ ACMD(mapmove) { char map_name[MAP_NAME_LENGTH_EXT]; - unsigned short mapindex; + unsigned short map_index; short x = 0, y = 0; int16 m = -1; @@ -389,11 +389,11 @@ ACMD(mapmove) { return false; } - mapindex = mapindex_name2id(map_name); - if (mapindex) - m = map->mapindex2mapid(mapindex); + map_index = mapindex->name2id(map_name); + if (map_index) + m = map->mapindex2mapid(map_index); - if (!mapindex || m < 0) { // m < 0 means on different server or that map is disabled! [Kevin] + if (!map_index || m < 0) { // m < 0 means on different server or that map is disabled! [Kevin] clif->message(fd, msg_txt(1)); // Map not found. return false; } @@ -412,7 +412,7 @@ ACMD(mapmove) { clif->message(fd, msg_txt(248)); return false; } - if (pc->setpos(sd, mapindex, x, y, CLR_TELEPORT) != 0) { + if (pc->setpos(sd, map_index, x, y, CLR_TELEPORT) != 0) { clif->message(fd, msg_txt(1)); // Map not found. return false; } @@ -1865,7 +1865,7 @@ ACMD(go) clif->message(fd, msg_txt(248)); return false; } - if (pc->setpos(sd, mapindex_name2id(data[town].map), data[town].x, data[town].y, CLR_TELEPORT) == 0) { + if (pc->setpos(sd, mapindex->name2id(data[town].map), data[town].x, data[town].y, CLR_TELEPORT) == 0) { clif->message(fd, msg_txt(0)); // Warped. } else { clif->message(fd, msg_txt(1)); // Map not found. @@ -3708,7 +3708,7 @@ ACMD(mapinfo) { clif->message(fd, msg_txt(1)); // Map not found. return false; } - m_index = mapindex_name2id(mapname); //This one shouldn't fail since the previous seek did not. + m_index = mapindex->name2id(mapname); //This one shouldn't fail since the previous seek did not. clif->message(fd, msg_txt(1039)); // ------ Map Info ------ @@ -4402,12 +4402,12 @@ ACMD(jail) { switch(rnd() % 2) { //Jail Locations case 0: - m_index = mapindex_name2id(MAP_JAIL); + m_index = mapindex->name2id(MAP_JAIL); x = 24; y = 75; break; default: - m_index = mapindex_name2id(MAP_JAIL); + m_index = mapindex->name2id(MAP_JAIL); x = 49; y = 75; break; @@ -4554,11 +4554,11 @@ ACMD(jailfor) { switch(rnd()%2) { case 1: //Jail #1 - m_index = mapindex_name2id(MAP_JAIL); + m_index = mapindex->name2id(MAP_JAIL); x = 49; y = 75; break; default: //Default Jail - m_index = mapindex_name2id(MAP_JAIL); + m_index = mapindex->name2id(MAP_JAIL); x = 24; y = 75; break; } @@ -5010,7 +5010,7 @@ ACMD(addwarp) return false; } - m = mapindex_name2id(mapname); + m = mapindex->name2id(mapname); if( m == 0 ) { sprintf(atcmd_output, msg_txt(1157), mapname); // Unknown map '%s'. diff --git a/src/map/clif.c b/src/map/clif.c index d8a3274a0..4e10e2eea 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -1663,7 +1663,7 @@ void clif_changemap(struct map_session_data *sd, short m, int x, int y) { WFIFOHEAD(fd,packet_len(0x91)); WFIFOW(fd,0) = 0x91; - mapindex_getmapname_ext(map->list[m].custom_name ? map->list[map->list[m].instance_src_map].name : map->list[m].name, (char*)WFIFOP(fd,2)); + mapindex->getmapname_ext(map->list[m].custom_name ? map->list[map->list[m].instance_src_map].name : map->list[m].name, (char*)WFIFOP(fd,2)); WFIFOW(fd,18) = x; WFIFOW(fd,20) = y; WFIFOSET(fd,packet_len(0x91)); @@ -1679,7 +1679,7 @@ void clif_changemapserver(struct map_session_data* sd, unsigned short map_index, WFIFOHEAD(fd,packet_len(0x92)); WFIFOW(fd,0) = 0x92; - mapindex_getmapname_ext(mapindex_id2name(map_index), (char*)WFIFOP(fd,2)); + mapindex->getmapname_ext(mapindex_id2name(map_index), (char*)WFIFOP(fd,2)); WFIFOW(fd,18) = x; WFIFOW(fd,20) = y; WFIFOL(fd,22) = htonl(ip); @@ -4501,7 +4501,7 @@ void clif_changemapcell(int fd, int16 m, int x, int y, int type, enum send_targe WBUFW(buf,2) = x; WBUFW(buf,4) = y; WBUFW(buf,6) = type; - mapindex_getmapname_ext(map->list[m].custom_name ? map->list[map->list[m].instance_src_map].name : map->list[m].name,(char*)WBUFP(buf,8)); + mapindex->getmapname_ext(map->list[m].custom_name ? map->list[map->list[m].instance_src_map].name : map->list[m].name,(char*)WBUFP(buf,8)); if( fd ) { WFIFOHEAD(fd,packet_len(0x192)); @@ -5258,10 +5258,10 @@ void clif_skill_warppoint(struct map_session_data* sd, uint16 skill_id, uint16 s memset(WFIFOP(fd,4), 0x00, 4*MAP_NAME_LENGTH_EXT); if (map1 == (unsigned short)-1) strcpy((char*)WFIFOP(fd,4), "Random"); else // normal map name - if (map1 > 0) mapindex_getmapname_ext(mapindex_id2name(map1), (char*)WFIFOP(fd,4)); - if (map2 > 0) mapindex_getmapname_ext(mapindex_id2name(map2), (char*)WFIFOP(fd,20)); - if (map3 > 0) mapindex_getmapname_ext(mapindex_id2name(map3), (char*)WFIFOP(fd,36)); - if (map4 > 0) mapindex_getmapname_ext(mapindex_id2name(map4), (char*)WFIFOP(fd,52)); + if (map1 > 0) mapindex->getmapname_ext(mapindex_id2name(map1), (char*)WFIFOP(fd,4)); + if (map2 > 0) mapindex->getmapname_ext(mapindex_id2name(map2), (char*)WFIFOP(fd,20)); + if (map3 > 0) mapindex->getmapname_ext(mapindex_id2name(map3), (char*)WFIFOP(fd,36)); + if (map4 > 0) mapindex->getmapname_ext(mapindex_id2name(map4), (char*)WFIFOP(fd,52)); WFIFOSET(fd,packet_len(0x11c)); sd->menuskill_id = skill_id; @@ -6430,7 +6430,7 @@ void clif_party_member_info(struct party_data *p, struct map_session_data *sd) WBUFB(buf,14) = (p->party.member[i].online)?0:1; memcpy(WBUFP(buf,15), p->party.name, NAME_LENGTH); memcpy(WBUFP(buf,39), sd->status.name, NAME_LENGTH); - mapindex_getmapname_ext(map->list[sd->bl.m].custom_name ? map->list[map->list[sd->bl.m].instance_src_map].name : map->list[sd->bl.m].name, (char*)WBUFP(buf,63)); + mapindex->getmapname_ext(map->list[sd->bl.m].custom_name ? map->list[map->list[sd->bl.m].instance_src_map].name : map->list[sd->bl.m].name, (char*)WBUFP(buf,63)); WBUFB(buf,79) = (p->party.item&1)?1:0; WBUFB(buf,80) = (p->party.item&2)?1:0; clif->send(buf,packet_len(0x1e9),&sd->bl,PARTY); @@ -6464,7 +6464,7 @@ void clif_party_info(struct party_data* p, struct map_session_data *sd) WBUFL(buf,28+c*46) = m->account_id; memcpy(WBUFP(buf,28+c*46+4), m->name, NAME_LENGTH); - mapindex_getmapname_ext(mapindex_id2name(m->map), (char*)WBUFP(buf,28+c*46+28)); + mapindex->getmapname_ext(mapindex_id2name(m->map), (char*)WBUFP(buf,28+c*46+28)); WBUFB(buf,28+c*46+44) = (m->leader) ? 0 : 1; WBUFB(buf,28+c*46+45) = (m->online) ? 0 : 1; c++; @@ -8771,7 +8771,7 @@ void clif_feel_info(struct map_session_data* sd, unsigned char feel_level, unsig { char mapname[MAP_NAME_LENGTH_EXT]; - mapindex_getmapname_ext(mapindex_id2name(sd->feel_map[feel_level].index), mapname); + mapindex->getmapname_ext(mapindex_id2name(sd->feel_map[feel_level].index), mapname); clif->starskill(sd, mapname, 0, feel_level, type ? 1 : 0); } @@ -11462,7 +11462,7 @@ void clif_parse_UseSkillMap(int fd, struct map_session_data* sd) uint16 skill_id = RFIFOW(fd,2); char map_name[MAP_NAME_LENGTH]; - mapindex_getmapname((char*)RFIFOP(fd,4), map_name); + mapindex->getmapname((char*)RFIFOP(fd,4), map_name); sd->state.workinprogress = 0; if(skill_id != sd->menuskill_id) diff --git a/src/map/guild.c b/src/map/guild.c index cca4da6cf..e73a9323b 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -124,14 +124,14 @@ int guild_check_skill_require(struct guild *g,int id) bool guild_read_castledb(char* str[], int columns, int current) {// <castle id>,<map name>,<castle name>,<castle event>[,<reserved/unused switch flag>] struct guild_castle *gc; - int mapindex = mapindex_name2id(str[1]); + int index = mapindex->name2id(str[1]); - if (map->mapindex2mapid(mapindex) < 0) // Map not found or on another map-server + if (map->mapindex2mapid(index) < 0) // Map not found or on another map-server return false; CREATE(gc, struct guild_castle, 1); gc->castle_id = atoi(str[0]); - gc->mapindex = mapindex; + gc->mapindex = index; safestrncpy(gc->castle_name, str[2], sizeof(gc->castle_name)); safestrncpy(gc->castle_event, str[3], sizeof(gc->castle_event)); @@ -189,7 +189,7 @@ struct guild_castle* guild_mapindex2gc(short mapindex) /// lookup: map name -> castle* struct guild_castle* guild_mapname2gc(const char* mapname) { - return guild->mapindex2gc(mapindex_name2id(mapname)); + return guild->mapindex2gc(mapindex->name2id(mapname)); } struct map_session_data* guild_getavailablesd(struct guild* g) diff --git a/src/map/instance.c b/src/map/instance.c index ab68c9e22..924bbfd14 100644 --- a/src/map/instance.c +++ b/src/map/instance.c @@ -157,7 +157,7 @@ int instance_add_map(const char *name, int instance_id, bool usebasename, const return -1; } - if( map_name != NULL && strdb_iget(mapindex_db, map_name) ) { + if( map_name != NULL && strdb_iget(mapindex->db, map_name) ) { ShowError("instance_add_map: trying to create instanced map with existent name '%s'\n", map_name); return -2; } @@ -186,7 +186,7 @@ int instance_add_map(const char *name, int instance_id, bool usebasename, const map->list[im].custom_name = true; } else 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 + map->list[im].index = mapindex->addmap(-1, map->list[im].name); // Add map index map->list[im].channel = NULL; @@ -419,7 +419,7 @@ void instance_del_map(int16 m) { 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)); + mapindex->removemap(map_id2index(m)); // Free memory aFree(map->list[m].cell); diff --git a/src/map/map.c b/src/map/map.c index 3153c77fb..874dca08c 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -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); @@ -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; @@ -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); @@ -5141,7 +5141,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(); @@ -5379,6 +5379,7 @@ void map_hp_symbols(void) { } void map_load_defaults(void) { + mapindex_defaults(); map_defaults(); /* */ atcommand_defaults(); @@ -5565,7 +5566,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 diff --git a/src/map/npc.c b/src/map/npc.c index d82bbdfd9..5f890c65b 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -2140,7 +2140,7 @@ const char* npc_parse_warp(char* w1, char* w2, char* w3, char* w4, const char* s } m = map->mapname2mapid(mapname); - i = mapindex_name2id(to_mapname); + i = mapindex->name2id(to_mapname); if( i == 0 ) { ShowError("npc_parse_warp: Unknown destination map in file '%s', line '%d' : %s\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer,start-buffer), to_mapname, w1, w2, w3, w4); @@ -2983,7 +2983,7 @@ const char* npc_parse_mob(char* w1, char* w2, char* w3, char* w4, const char* st ShowError("npc_parse_mob: Invalid mob definition in file '%s', line '%d'.\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer,start-buffer), w1, w2, w3, w4); return strchr(start,'\n');// skip and continue } - if( mapindex_name2id(mapname) == 0 ) { + if( mapindex->name2id(mapname) == 0 ) { ShowError("npc_parse_mob: Unknown map '%s' in file '%s', line '%d'.\n", mapname, filepath, strline(buffer,start-buffer)); return strchr(start,'\n');// skip and continue } @@ -3153,7 +3153,7 @@ const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, const char map->list[m].save.x = -1; map->list[m].save.y = -1; } else if (sscanf(w4, "%31[^,],%d,%d", savemap, &savex, &savey) == 3) { - map->list[m].save.map = mapindex_name2id(savemap); + map->list[m].save.map = mapindex->name2id(savemap); map->list[m].save.x = savex; map->list[m].save.y = savey; if (!map->list[m].save.map) { @@ -3598,7 +3598,7 @@ int npc_parsesrcfile(const char* filepath, bool runOnInit) { char mapname[MAP_NAME_LENGTH*2]; x = y = 0; sscanf(w1,"%23[^,],%hd,%hd[^,]",mapname,&x,&y); - if( !mapindex_name2id(mapname) ) + if( !mapindex->name2id(mapname) ) {// Incorrect map, we must skip the script info... ShowError("npc_parsesrcfile: Unknown map '%s' in file '%s', line '%d'. Skipping line...\n", mapname, filepath, strline(buffer,p-buffer)); if( strcmp(w2,"script") == 0 && count > 3 ) diff --git a/src/map/pc.c b/src/map/pc.c index f29ff7567..aa6073be8 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -1146,7 +1146,7 @@ bool pc_authok(struct map_session_data *sd, int login_id2, time_t expiration_tim ShowError ("Last_point_map %s - id %d not found (error code %d)\n", mapindex_id2name(sd->status.last_point.map), sd->status.last_point.map, i); // try warping to a default map instead (church graveyard) - if (pc->setpos(sd, mapindex_name2id(MAP_PRONTERA), 273, 354, CLR_OUTSIGHT) != 0) { + if (pc->setpos(sd, mapindex->name2id(MAP_PRONTERA), 273, 354, CLR_OUTSIGHT) != 0) { // if we fail again clif->authfail_fd(sd->fd, 0); return false; @@ -4864,13 +4864,13 @@ int pc_steal_coin(struct map_session_data *sd, struct block_list *target) { * 1 - Invalid map index. * 2 - Map not in this map-server, and failed to locate alternate map-server. *------------------------------------------*/ -int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y, clr_type clrtype) { +int pc_setpos(struct map_session_data* sd, unsigned short map_index, int x, int y, clr_type clrtype) { int16 m; nullpo_ret(sd); - if( !mapindex || !mapindex_id2name(mapindex) || ( m = map->mapindex2mapid(mapindex) ) == -1 ) { - ShowDebug("pc_setpos: Passed mapindex(%d) is invalid!\n", mapindex); + if( !map_index || !mapindex_id2name(map_index) || ( m = map->mapindex2mapid(map_index) ) == -1 ) { + ShowDebug("pc_setpos: Passed mapindex(%d) is invalid!\n", map_index); return 1; } @@ -4894,7 +4894,7 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y } if( i != sd->instances ) { m = instance->list[sd->instance[i]].map[j]; - mapindex = map_id2index(m); + map_index = map_id2index(m); stop = true; } } @@ -4908,7 +4908,7 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y } if( i != p->instances ) { m = instance->list[p->instance[i]].map[j]; - mapindex = map_id2index(m); + map_index = map_id2index(m); stop = true; } } @@ -4922,7 +4922,7 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y } if( i != sd->guild->instances ) { m = instance->list[sd->guild->instance[i]].map[j]; - mapindex = map_id2index(m); + map_index = map_id2index(m); stop = true; } } @@ -4930,13 +4930,13 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y if( map->list[m].instance_id >= 0 && instance->list[map->list[m].instance_id].respawn.map == 0 && instance->list[map->list[m].instance_id].respawn.x == 0 && instance->list[map->list[m].instance_id].respawn.y == 0) { - instance->list[map->list[m].instance_id].respawn.map = mapindex; + instance->list[map->list[m].instance_id].respawn.map = map_index; instance->list[map->list[m].instance_id].respawn.x = x; instance->list[map->list[m].instance_id].respawn.y = y; } } - sd->state.changemap = (sd->mapindex != mapindex); + sd->state.changemap = (sd->mapindex != map_index); sd->state.warping = 1; sd->state.workinprogress = 0; if( sd->state.changemap ) { // Misc map-changing settings @@ -4999,7 +4999,7 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y uint32 ip; uint16 port; //if can't find any map-servers, just abort setting position. - if(!sd->mapindex || map->mapname2ipport(mapindex,&ip,&port)) + if(!sd->mapindex || map->mapname2ipport(map_index,&ip,&port)) return 2; if (sd->npc_id) @@ -5007,7 +5007,7 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y npc->script_event(sd, NPCE_LOGOUT); //remove from map, THEN change x/y coordinates unit->remove_map_pc(sd,clrtype); - sd->mapindex = mapindex; + sd->mapindex = map_index; sd->bl.x=x; sd->bl.y=y; pc->clean_skilltree(sd); @@ -5021,7 +5021,7 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y } if( x < 0 || x >= map->list[m].xs || y < 0 || y >= map->list[m].ys ) { - ShowError("pc_setpos: attempt to place player %s (%d:%d) on invalid coordinates (%s-%d,%d)\n", sd->status.name, sd->status.account_id, sd->status.char_id, mapindex_id2name(mapindex),x,y); + ShowError("pc_setpos: attempt to place player %s (%d:%d) on invalid coordinates (%s-%d,%d)\n", sd->status.name, sd->status.account_id, sd->status.char_id, mapindex_id2name(map_index),x,y); x = y = 0; // make it random } @@ -5044,7 +5044,7 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y //Tag player for rewarping after map-loading is done. [Skotlex] sd->state.rewarp = 1; - sd->mapindex = mapindex; + sd->mapindex = map_index; sd->bl.m = m; sd->bl.x = sd->ud.to_x = x; sd->bl.y = sd->ud.to_y = y; diff --git a/src/map/pc.h b/src/map/pc.h index 5f81346d4..90e1357cf 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -785,7 +785,7 @@ struct pc_interface { int (*calc_skilltree_normalize_job) (struct map_session_data *sd); int (*clean_skilltree) (struct map_session_data *sd); - int (*setpos) (struct map_session_data* sd, unsigned short mapindex, int x, int y, clr_type clrtype); + int (*setpos) (struct map_session_data* sd, unsigned short map_index, int x, int y, clr_type clrtype); int (*setsavepoint) (struct map_session_data *sd, short mapindex,int x,int y); int (*randomwarp) (struct map_session_data *sd,clr_type type); int (*memo) (struct map_session_data* sd, int pos); diff --git a/src/map/script.c b/src/map/script.c index 9a49cc988..764ae743a 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -4754,7 +4754,7 @@ BUILDIN(warp) else if(strcmp(str,"SavePoint")==0 || strcmp(str,"Save")==0) ret = pc->setpos(sd,sd->status.save_point.map,sd->status.save_point.x,sd->status.save_point.y,CLR_TELEPORT); else - ret = pc->setpos(sd,mapindex_name2id(str),x,y,CLR_OUTSIGHT); + ret = pc->setpos(sd,mapindex->name2id(str),x,y,CLR_OUTSIGHT); if( ret ) { ShowError("buildin_warp: moving player '%s' to \"%s\",%d,%d failed.\n", sd->status.name, str, x, y); @@ -4831,7 +4831,7 @@ BUILDIN(areawarp) if( strcmp(str,"Random") == 0 ) index = 0; - else if( !(index=mapindex_name2id(str)) ) + else if( !(index=mapindex->name2id(str)) ) return true; map->foreachinarea(script->buildin_areawarp_sub, m,x0,y0,x1,y1, BL_PC, index,x2,y2,x3,y3); @@ -4895,7 +4895,7 @@ BUILDIN(warpchar) { if(strcmp(str, "SavePoint") == 0) pc->setpos(sd, sd->status.save_point.map,sd->status.save_point.x, sd->status.save_point.y, CLR_TELEPORT); else - pc->setpos(sd, mapindex_name2id(str), x, y, CLR_TELEPORT); + pc->setpos(sd, mapindex->name2id(str), x, y, CLR_TELEPORT); return true; } @@ -4910,7 +4910,7 @@ BUILDIN(warpparty) TBL_PC *pl_sd; struct party_data* p; int type; - int mapindex; + int map_index; int i; const char* str = script_getstr(st,2); @@ -4938,19 +4938,19 @@ BUILDIN(warpparty) if (i == MAX_PARTY || !p->data[i].sd) //Leader not found / not online return true; pl_sd = p->data[i].sd; - mapindex = pl_sd->mapindex; + map_index = pl_sd->mapindex; x = pl_sd->bl.x; y = pl_sd->bl.y; break; case 4: - mapindex = mapindex_name2id(str); + map_index = mapindex->name2id(str); break; case 2: //"SavePoint" uses save point of the currently attached player if (( sd = script->rid2sd(st) ) == NULL ) return true; default: - mapindex = 0; + map_index = 0; break; } @@ -4981,7 +4981,7 @@ BUILDIN(warpparty) case 3: // Leader case 4: // m,x,y if(!map->list[pl_sd->bl.m].flag.noreturn && !map->list[pl_sd->bl.m].flag.nowarp) - pc->setpos(pl_sd,mapindex,x,y,CLR_TELEPORT); + pc->setpos(pl_sd,map_index,x,y,CLR_TELEPORT); break; } } @@ -5041,7 +5041,7 @@ BUILDIN(warpguild) break; case 3: // m,x,y if(!map->list[pl_sd->bl.m].flag.noreturn && !map->list[pl_sd->bl.m].flag.nowarp) - pc->setpos(pl_sd,mapindex_name2id(str),x,y,CLR_TELEPORT); + pc->setpos(pl_sd,mapindex->name2id(str),x,y,CLR_TELEPORT); break; } } @@ -8336,7 +8336,7 @@ BUILDIN(savepoint) { str = script_getstr(st,2); x = script_getnum(st,3); y = script_getnum(st,4); - mapid = mapindex_name2id(str); + mapid = mapindex->name2id(str); if( mapid ) pc->setsavepoint(sd, mapid, x, y); @@ -10434,7 +10434,7 @@ BUILDIN(warpwaitingpc) { else if( strcmp(map_name,"SavePoint") == 0 ) pc->setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, CLR_TELEPORT); else - pc->setpos(sd, mapindex_name2id(map_name), x, y, CLR_OUTSIGHT); + pc->setpos(sd, mapindex->name2id(map_name), x, y, CLR_OUTSIGHT); } mapreg->setreg(script->add_str("$@warpwaitingpcnum"), i); return true; @@ -10496,7 +10496,7 @@ BUILDIN(isloggedin) { *------------------------------------------*/ BUILDIN(setmapflagnosave) { int16 m,x,y; - unsigned short mapindex; + unsigned short map_index; const char *str,*str2; str=script_getstr(st,2); @@ -10504,11 +10504,11 @@ BUILDIN(setmapflagnosave) { x=script_getnum(st,4); y=script_getnum(st,5); m = map->mapname2mapid(str); - mapindex = mapindex_name2id(str2); + map_index = mapindex->name2id(str2); if(m >= 0 && mapindex) { map->list[m].flag.nosave=1; - map->list[m].save.map=mapindex; + map->list[m].save.map=map_index; map->list[m].save.x=x; map->list[m].save.y=y; } @@ -11060,7 +11060,7 @@ BUILDIN(flagemblem) { BUILDIN(getcastlename) { - const char* mapname = mapindex_getmapname(script_getstr(st,2),NULL); + const char* mapname = mapindex->getmapname(script_getstr(st,2),NULL); struct guild_castle* gc = guild->mapname2gc(mapname); const char* name = (gc) ? gc->castle_name : ""; script_pushstrcopy(st,name); @@ -11069,7 +11069,7 @@ BUILDIN(getcastlename) BUILDIN(getcastledata) { - const char *mapname = mapindex_getmapname(script_getstr(st,2),NULL); + const char *mapname = mapindex->getmapname(script_getstr(st,2),NULL); int index = script_getnum(st,3); struct guild_castle *gc = guild->mapname2gc(mapname); @@ -11112,7 +11112,7 @@ BUILDIN(getcastledata) BUILDIN(setcastledata) { - const char *mapname = mapindex_getmapname(script_getstr(st,2),NULL); + const char *mapname = mapindex->getmapname(script_getstr(st,2),NULL); int index = script_getnum(st,3); int value = script_getnum(st,4); struct guild_castle *gc = guild->mapname2gc(mapname); @@ -11343,7 +11343,7 @@ BUILDIN(mapwarp) { if((m=map->mapname2mapid(mapname))< 0) return true; - if(!(index=mapindex_name2id(str))) + if(!(index=mapindex->name2id(str))) return true; switch(check_val){ @@ -11518,7 +11518,7 @@ BUILDIN(getfatherid) BUILDIN(warppartner) { int x,y; - unsigned short mapindex; + unsigned short map_index; const char *str; TBL_PC *sd=script->rid2sd(st); TBL_PC *p_sd=NULL; @@ -11533,9 +11533,9 @@ BUILDIN(warppartner) x=script_getnum(st,3); y=script_getnum(st,4); - mapindex = mapindex_name2id(str); - if (mapindex) { - pc->setpos(p_sd,mapindex,x,y,CLR_OUTSIGHT); + map_index = mapindex->name2id(str); + if (map_index) { + pc->setpos(p_sd,map_index,x,y,CLR_OUTSIGHT); script_pushint(st,1); } else script_pushint(st,0); @@ -11655,7 +11655,7 @@ BUILDIN(delwall) { /// 2 - current hp /// BUILDIN(guardianinfo) { - const char* mapname = mapindex_getmapname(script_getstr(st,2),NULL); + const char* mapname = mapindex->getmapname(script_getstr(st,2),NULL); int id = script_getnum(st,3); int type = script_getnum(st,4); @@ -15539,7 +15539,7 @@ BUILDIN(getvariableofnpc) BUILDIN(warpportal) { int spx; int spy; - unsigned short mapindex; + unsigned short map_index; int tpx; int tpy; struct skill_unit_group* group; @@ -15554,11 +15554,11 @@ BUILDIN(warpportal) { spx = script_getnum(st,2); spy = script_getnum(st,3); - mapindex = mapindex_name2id(script_getstr(st, 4)); + map_index = mapindex->name2id(script_getstr(st, 4)); tpx = script_getnum(st,5); tpy = script_getnum(st,6); - if( mapindex == 0 ) + if( map_index == 0 ) return true;// map not found group = skill->unitsetting(bl, AL_WARP, 4, spx, spy, 0); @@ -15566,7 +15566,7 @@ BUILDIN(warpportal) { return true;// failed group->val1 = (group->val1<<16)|(short)0; group->val2 = (tpx<<16) | tpy; - group->val3 = mapindex; + group->val3 = map_index; return true; } @@ -15991,7 +15991,7 @@ BUILDIN(waitingroom2bg) { struct npc_data *nd; struct chat_data *cd; const char *map_name, *ev = "", *dev = ""; - int x, y, i, mapindex = 0, bg_id, n; + int x, y, i, map_index = 0, bg_id, n; struct map_session_data *sd; if( script_hasdata(st,7) ) @@ -16007,8 +16007,8 @@ BUILDIN(waitingroom2bg) { map_name = script_getstr(st,2); if( strcmp(map_name,"-") != 0 ) { - mapindex = mapindex_name2id(map_name); - if( mapindex == 0 ) + map_index = mapindex->name2id(map_name); + if( map_index == 0 ) { // Invalid Map script_pushint(st,0); return true; @@ -16020,7 +16020,7 @@ BUILDIN(waitingroom2bg) { ev = script_getstr(st,5); // Logout Event dev = script_getstr(st,6); // Die Event - if( (bg_id = bg->create(mapindex, x, y, ev, dev)) == 0 ) + if( (bg_id = bg->create(map_index, x, y, ev, dev)) == 0 ) { // Creation failed script_pushint(st,0); return true; @@ -16045,11 +16045,11 @@ BUILDIN(waitingroom2bg_single) { struct npc_data *nd; struct chat_data *cd; struct map_session_data *sd; - int x, y, mapindex, bg_id; + int x, y, map_index, bg_id; bg_id = script_getnum(st,2); map_name = script_getstr(st,3); - if( (mapindex = mapindex_name2id(map_name)) == 0 ) + if( (map_index = mapindex->name2id(map_name)) == 0 ) return true; // Invalid Map x = script_getnum(st,4); @@ -16064,7 +16064,7 @@ BUILDIN(waitingroom2bg_single) { if( bg->team_join(bg_id, sd) ) { - pc->setpos(sd, mapindex, x, y, CLR_TELEPORT); + pc->setpos(sd, map_index, x, y, CLR_TELEPORT); script_pushint(st,1); } else @@ -16089,16 +16089,16 @@ BUILDIN(bg_team_setxy) BUILDIN(bg_warp) { - int x, y, mapindex, bg_id; + int x, y, map_index, bg_id; const char* map_name; bg_id = script_getnum(st,2); map_name = script_getstr(st,3); - if( (mapindex = mapindex_name2id(map_name)) == 0 ) + if( (map_index = mapindex->name2id(map_name)) == 0 ) return true; // Invalid Map x = script_getnum(st,4); y = script_getnum(st,5); - bg->team_warp(bg_id, mapindex, x, y); + bg->team_warp(bg_id, map_index, x, y); return true; } @@ -17858,12 +17858,12 @@ BUILDIN(packageitem) { /* returns created team id or -1 when fails */ BUILDIN(bg_create_team) { const char *map_name, *ev = "", *dev = "";//ev and dev will be dropped. - int x, y, mapindex = 0, bg_id; + int x, y, map_index = 0, bg_id; map_name = script_getstr(st,2); if( strcmp(map_name,"-") != 0 ) { - mapindex = mapindex_name2id(map_name); - if( mapindex == 0 ) { // Invalid Map + map_index = mapindex->name2id(map_name); + if( map_index == 0 ) { // Invalid Map script_pushint(st,0); return true; } @@ -17872,7 +17872,7 @@ BUILDIN(bg_create_team) { x = script_getnum(st,3); y = script_getnum(st,4); - if( (bg_id = bg->create(mapindex, x, y, ev, dev)) == 0 ) { // Creation failed + if( (bg_id = bg->create(map_index, x, y, ev, dev)) == 0 ) { // Creation failed script_pushint(st,-1); } else script_pushint(st,bg_id); diff --git a/src/map/skill.c b/src/map/skill.c index 197d4fe2d..1f9a8c15b 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -8791,28 +8791,25 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin if( sd ) { short x, y; // Destiny position. - unsigned short mapindex; + unsigned short map_index; - if( skill_id == RETURN_TO_ELDICASTES) - { + if( skill_id == RETURN_TO_ELDICASTES) { x = 198; y = 187; - mapindex = mapindex_name2id(MAP_DICASTES); - } - else - { + map_index = mapindex->name2id(MAP_DICASTES); + } else { x = 44; y = 151; - mapindex = mapindex_name2id(MAP_MORA); + map_index = mapindex->name2id(MAP_MORA); } - if(!mapindex) { + if(!map_index) { //Given map not found? clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); map->freeblock_unlock(); return 0; } - pc->setpos(sd, mapindex, x, y, CLR_TELEPORT); + pc->setpos(sd, map_index, x, y, CLR_TELEPORT); } break; @@ -9582,9 +9579,9 @@ int skill_castend_map (struct map_session_data *sd, uint16 skill_id, const char int i, lv, wx, wy; int maxcount=0; int x,y; - unsigned short mapindex; + unsigned short map_index; - mapindex = mapindex_name2id(mapname); + map_index = mapindex->name2id(mapname); if(!mapindex) { //Given map not found? clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); skill_failed(sd); @@ -9615,7 +9612,7 @@ int skill_castend_map (struct map_session_data *sd, uint16 skill_id, const char if( lv > 4 ) lv = 4; // crash prevention // check if the chosen map exists in the memo list - ARR_FIND( 0, lv, i, mapindex == p[i]->map ); + ARR_FIND( 0, lv, i, map_index == p[i]->map ); if( i < lv ) { x=p[i]->x; y=p[i]->y; @@ -9640,7 +9637,7 @@ int skill_castend_map (struct map_session_data *sd, uint16 skill_id, const char group->val1 = (group->val1<<16)|(short)0; // record the destination coordinates group->val2 = (x<<16)|y; - group->val3 = mapindex; + group->val3 = map_index; } break; } |