summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authorshennetsind <ind@henn.et>2013-12-06 22:32:27 -0200
committershennetsind <ind@henn.et>2013-12-06 22:32:27 -0200
commitd4a58d24d6bcb23a995d62a3d9f9e7190c054b49 (patch)
tree6e58a0b50957e222ea45d9bb16d47332e2e0a76e /src/map
parent1f1930c0e3d2bb928d9fc9a39f360815daf77e8f (diff)
downloadhercules-d4a58d24d6bcb23a995d62a3d9f9e7190c054b49.tar.gz
hercules-d4a58d24d6bcb23a995d62a3d9f9e7190c054b49.tar.bz2
hercules-d4a58d24d6bcb23a995d62a3d9f9e7190c054b49.tar.xz
hercules-d4a58d24d6bcb23a995d62a3d9f9e7190c054b49.zip
HPM: mapindex interface
Signed-off-by: shennetsind <ind@henn.et>
Diffstat (limited to 'src/map')
-rw-r--r--src/map/atcommand.c26
-rw-r--r--src/map/clif.c22
-rw-r--r--src/map/guild.c8
-rw-r--r--src/map/instance.c6
-rw-r--r--src/map/map.c25
-rw-r--r--src/map/npc.c8
-rw-r--r--src/map/pc.c26
-rw-r--r--src/map/pc.h2
-rw-r--r--src/map/script.c82
-rw-r--r--src/map/skill.c25
10 files changed, 114 insertions, 116 deletions
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;
}