diff options
author | Haru <haru@dotalux.com> | 2013-09-26 02:34:45 +0200 |
---|---|---|
committer | Haru <haru@dotalux.com> | 2013-09-26 02:34:45 +0200 |
commit | 3e5bca5a3df07320ff5c41edbb282df041c36f66 (patch) | |
tree | c593fcf36c9113cd750013fff084052110cf56ce | |
parent | afcad494411995396b906f214d1c4ffcf485cc0a (diff) | |
download | hercules-3e5bca5a3df07320ff5c41edbb282df041c36f66.tar.gz hercules-3e5bca5a3df07320ff5c41edbb282df041c36f66.tar.bz2 hercules-3e5bca5a3df07320ff5c41edbb282df041c36f66.tar.xz hercules-3e5bca5a3df07320ff5c41edbb282df041c36f66.zip |
Renamed variables that would conflict with a rename of iMap to map
Note to plugin developers: if you were importing the "map", you'll need
to change it to "maplist"
Signed-off-by: Haru <haru@dotalux.com>
-rw-r--r-- | src/map/atcommand.c | 409 | ||||
-rw-r--r-- | src/map/battle.c | 158 | ||||
-rw-r--r-- | src/map/battleground.c | 4 | ||||
-rw-r--r-- | src/map/buyingstore.c | 8 | ||||
-rw-r--r-- | src/map/chat.c | 6 | ||||
-rw-r--r-- | src/map/clif.c | 221 | ||||
-rw-r--r-- | src/map/clif.h | 2 | ||||
-rw-r--r-- | src/map/guild.c | 26 | ||||
-rw-r--r-- | src/map/instance.c | 179 | ||||
-rw-r--r-- | src/map/intif.c | 4 | ||||
-rw-r--r-- | src/map/log.c | 42 | ||||
-rw-r--r-- | src/map/log.h | 4 | ||||
-rw-r--r-- | src/map/mail.c | 6 | ||||
-rw-r--r-- | src/map/map.c | 1003 | ||||
-rw-r--r-- | src/map/map.h | 16 | ||||
-rw-r--r-- | src/map/mob.c | 92 | ||||
-rw-r--r-- | src/map/mob.h | 4 | ||||
-rw-r--r-- | src/map/npc.c | 522 | ||||
-rw-r--r-- | src/map/party.c | 7 | ||||
-rw-r--r-- | src/map/party.h | 2 | ||||
-rw-r--r-- | src/map/path.c | 12 | ||||
-rw-r--r-- | src/map/pc.c | 111 | ||||
-rw-r--r-- | src/map/script.c | 596 | ||||
-rw-r--r-- | src/map/skill.c | 96 | ||||
-rw-r--r-- | src/map/skill.h | 2 | ||||
-rw-r--r-- | src/map/status.c | 59 | ||||
-rw-r--r-- | src/map/trade.c | 2 | ||||
-rw-r--r-- | src/map/unit.c | 49 |
28 files changed, 1775 insertions, 1867 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 0fd54200d..57d2a73ef 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -418,11 +418,11 @@ ACMD(mapmove) if (!iMap->search_freecell(NULL, m, &x, &y, 10, 10, 1)) x = y = 0; //Invalid cell, use random spot. } - if (map[m].flag.nowarpto && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (maplist[m].flag.nowarpto && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif->message(fd, msg_txt(247)); return false; } - if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (sd->bl.m >= 0 && maplist[sd->bl.m].flag.nowarp && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif->message(fd, msg_txt(248)); return false; } @@ -468,8 +468,7 @@ ACMD(where) /*========================================== * *------------------------------------------*/ -ACMD(jumpto) -{ +ACMD(jumpto) { struct map_session_data *pl_sd = NULL; nullpo_retr(-1, sd); @@ -479,26 +478,22 @@ ACMD(jumpto) return false; } - if((pl_sd=iMap->nick2sd((char *)message)) == NULL && (pl_sd=iMap->charid2sd(atoi(message))) == NULL) - { + if((pl_sd=iMap->nick2sd((char *)message)) == NULL && (pl_sd=iMap->charid2sd(atoi(message))) == NULL) { clif->message(fd, msg_txt(3)); // Character not found. return false; } - if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) - { - clif->message(fd, msg_txt(247)); // You are not authorized to warp to this map. + if (pl_sd->bl.m >= 0 && maplist[pl_sd->bl.m].flag.nowarpto && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + clif->message(fd, msg_txt(247)); // You are not authorized to warp to this map. return false; } - if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) - { - clif->message(fd, msg_txt(248)); // You are not authorized to warp from your current map. + if (sd->bl.m >= 0 && maplist[sd->bl.m].flag.nowarp && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + clif->message(fd, msg_txt(248)); // You are not authorized to warp from your current map. return false; } - if( pc_isdead(sd) ) - { + if( pc_isdead(sd) ) { clif->message(fd, msg_txt(664)); return false; } @@ -523,8 +518,8 @@ ACMD(jump) sscanf(message, "%hd %hd", &x, &y); - if (map[sd->bl.m].flag.noteleport && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { - clif->message(fd, msg_txt(248)); // You are not authorized to warp from your current map. + if (maplist[sd->bl.m].flag.noteleport && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + clif->message(fd, msg_txt(248)); // You are not authorized to warp from your current map. return false; } @@ -639,11 +634,11 @@ ACMD(who) StrBuf->Printf(&buf, msg_txt(30), count); // %d players found. } else { if (count == 0) - StrBuf->Printf(&buf, msg_txt(54), map[map_id].name); // No player found in map '%s'. + StrBuf->Printf(&buf, msg_txt(54), maplist[map_id].name); // No player found in map '%s'. else if (count == 1) - StrBuf->Printf(&buf, msg_txt(55), map[map_id].name); // 1 player found in map '%s'. + StrBuf->Printf(&buf, msg_txt(55), maplist[map_id].name); // 1 player found in map '%s'. else - StrBuf->Printf(&buf, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'. + StrBuf->Printf(&buf, msg_txt(56), count, maplist[map_id].name); // %d players found in map '%s'. } clif->message(fd, StrBuf->Value(&buf)); StrBuf->Destroy(&buf); @@ -757,19 +752,18 @@ ACMD(save) /*========================================== * *------------------------------------------*/ -ACMD(load) -{ +ACMD(load) { int16 m; nullpo_retr(-1, sd); m = iMap->mapindex2mapid(sd->status.save_point.map); - if (m >= 0 && map[m].flag.nowarpto && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { - clif->message(fd, msg_txt(249)); // You are not authorized to warp to your save map. + if (m >= 0 && maplist[m].flag.nowarpto && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + clif->message(fd, msg_txt(249)); // You are not authorized to warp to your save map. return false; } - if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { - clif->message(fd, msg_txt(248)); // You are not authorized to warp from your current map. + if (sd->bl.m >= 0 && maplist[sd->bl.m].flag.nowarp && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + clif->message(fd, msg_txt(248)); // You are not authorized to warp from your current map. return false; } @@ -896,8 +890,7 @@ ACMD(option) /*========================================== * *------------------------------------------*/ -ACMD(hide) -{ +ACMD(hide) { nullpo_retr(-1, sd); if (sd->sc.option & OPTION_INVISIBLE) { sd->sc.option &= ~OPTION_INVISIBLE; @@ -908,10 +901,10 @@ ACMD(hide) clif->message(fd, msg_txt(10)); // Invisible: Off // increment the number of pvp players on the map - map[sd->bl.m].users_pvp++; + maplist[sd->bl.m].users_pvp++; - if( map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.pvp_nocalcrank ) - {// register the player for ranking calculations + if( maplist[sd->bl.m].flag.pvp && !maplist[sd->bl.m].flag.pvp_nocalcrank ) { + // register the player for ranking calculations sd->pvp_timer = timer->add( timer->gettick() + 200, pc->calc_pvprank_timer, sd->bl.id, 0 ); } //bugreport:2266 @@ -922,10 +915,10 @@ ACMD(hide) clif->message(fd, msg_txt(11)); // Invisible: On // decrement the number of pvp players on the map - map[sd->bl.m].users_pvp--; + maplist[sd->bl.m].users_pvp--; - if( map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.pvp_nocalcrank && sd->pvp_timer != INVALID_TIMER ) - {// unregister the player for ranking + if( maplist[sd->bl.m].flag.pvp && !maplist[sd->bl.m].flag.pvp_nocalcrank && sd->pvp_timer != INVALID_TIMER ) { + // unregister the player for ranking timer->delete( sd->pvp_timer, pc->calc_pvprank_timer ); sd->pvp_timer = INVALID_TIMER; } @@ -1476,17 +1469,16 @@ static int atcommand_pvpoff_sub(struct block_list *bl,va_list ap) return 0; } -ACMD(pvpoff) -{ +ACMD(pvpoff) { nullpo_retr(-1, sd); - if (!map[sd->bl.m].flag.pvp) { + if (!maplist[sd->bl.m].flag.pvp) { clif->message(fd, msg_txt(160)); // PvP is already Off. return false; } - iMap->zone_change2(sd->bl.m,map[sd->bl.m].prev_zone); - map[sd->bl.m].flag.pvp = 0; + iMap->zone_change2(sd->bl.m,maplist[sd->bl.m].prev_zone); + maplist[sd->bl.m].flag.pvp = 0; if (!battle_config.pk_mode) { clif->map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING); @@ -1515,17 +1507,16 @@ static int atcommand_pvpon_sub(struct block_list *bl,va_list ap) return 0; } -ACMD(pvpon) -{ +ACMD(pvpon) { nullpo_retr(-1, sd); - if (map[sd->bl.m].flag.pvp) { + if (maplist[sd->bl.m].flag.pvp) { clif->message(fd, msg_txt(161)); // PvP is already On. return false; } iMap->zone_change2(sd->bl.m,strdb_get(zone_db, MAP_ZONE_PVP_NAME)); - map[sd->bl.m].flag.pvp = 1; + maplist[sd->bl.m].flag.pvp = 1; if (!battle_config.pk_mode) {// display pvp circle and rank clif->map_property_mapall(sd->bl.m, MAPPROPERTY_FREEPVPZONE); @@ -1541,17 +1532,16 @@ ACMD(pvpon) /*========================================== * *------------------------------------------*/ -ACMD(gvgoff) -{ +ACMD(gvgoff) { nullpo_retr(-1, sd); - if (!map[sd->bl.m].flag.gvg) { + if (!maplist[sd->bl.m].flag.gvg) { clif->message(fd, msg_txt(162)); // GvG is already Off. return false; } - iMap->zone_change2(sd->bl.m,map[sd->bl.m].prev_zone); - map[sd->bl.m].flag.gvg = 0; + iMap->zone_change2(sd->bl.m,maplist[sd->bl.m].prev_zone); + maplist[sd->bl.m].flag.gvg = 0; clif->map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING); clif->maptypeproperty2(&sd->bl,ALL_SAMEMAP); iMap->foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0); @@ -1563,17 +1553,16 @@ ACMD(gvgoff) /*========================================== * *------------------------------------------*/ -ACMD(gvgon) -{ +ACMD(gvgon) { nullpo_retr(-1, sd); - if (map[sd->bl.m].flag.gvg) { + if (maplist[sd->bl.m].flag.gvg) { clif->message(fd, msg_txt(163)); // GvG is already On. return false; } iMap->zone_change2(sd->bl.m,strdb_get(zone_db, MAP_ZONE_GVG_NAME)); - map[sd->bl.m].flag.gvg = 1; + maplist[sd->bl.m].flag.gvg = 1; clif->map_property_mapall(sd->bl.m, MAPPROPERTY_AGITZONE); clif->maptypeproperty2(&sd->bl,ALL_SAMEMAP); clif->message(fd, msg_txt(34)); // GvG: On. @@ -1863,14 +1852,13 @@ ACMD(go) town = 35; } - if (town >= 0 && town < ARRAYLENGTH(data)) - { + if (town >= 0 && town < ARRAYLENGTH(data)) { m = iMap->mapname2mapid(data[town].map); - if (m >= 0 && map[m].flag.nowarpto && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (m >= 0 && maplist[m].flag.nowarpto && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif->message(fd, msg_txt(247)); return false; } - if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (sd->bl.m >= 0 && maplist[sd->bl.m].flag.nowarp && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif->message(fd, msg_txt(248)); return false; } @@ -2215,7 +2203,7 @@ ACMD(gat) for (y = 2; y >= -2; y--) { sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X", - map[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y, + maplist[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y, iMap->getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE), iMap->getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE), iMap->getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE), @@ -2712,11 +2700,11 @@ ACMD(recall) { return false; } - if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (sd->bl.m >= 0 && maplist[sd->bl.m].flag.nowarpto && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif->message(fd, msg_txt(1019)); // You are not authorized to warp someone to this map. return false; } - if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (pl_sd->bl.m >= 0 && maplist[pl_sd->bl.m].flag.nowarp && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif->message(fd, msg_txt(1020)); // You are not authorized to warp this player from their map. return false; } @@ -3423,20 +3411,18 @@ ACMD(recallall) memset(atcmd_output, '\0', sizeof(atcmd_output)); - if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (sd->bl.m >= 0 && maplist[sd->bl.m].flag.nowarpto && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif->message(fd, msg_txt(1032)); // You are not authorized to warp somenone to your current map. return false; } count = 0; iter = mapit_getallusers(); - for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) - { - if (sd->status.account_id != pl_sd->status.account_id && pc->get_group_level(sd) >= pc->get_group_level(pl_sd)) - { + for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) { + if (sd->status.account_id != pl_sd->status.account_id && pc->get_group_level(sd) >= pc->get_group_level(pl_sd)) { if (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y) continue; // Don't waste time warping the character to the same place. - if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) + if (pl_sd->bl.m >= 0 && maplist[pl_sd->bl.m].flag.nowarp && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) count++; else { if (pc_isdead(pl_sd)) { //Wake them up @@ -3478,7 +3464,7 @@ ACMD(guildrecall) return false; } - if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (sd->bl.m >= 0 && maplist[sd->bl.m].flag.nowarpto && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif->message(fd, msg_txt(1032)); // You are not authorized to warp somenone to your current map. return false; } @@ -3495,11 +3481,10 @@ ACMD(guildrecall) iter = mapit_getallusers(); for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) { - if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.guild_id == g->guild_id) - { + if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.guild_id == g->guild_id) { if (pc->get_group_level(pl_sd) > pc->get_group_level(sd) || (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y)) continue; // Skip GMs greater than you... or chars already on the cell - if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) + if (pl_sd->bl.m >= 0 && maplist[pl_sd->bl.m].flag.nowarp && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) count++; else pc->setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN); @@ -3537,7 +3522,7 @@ ACMD(partyrecall) return false; } - if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (sd->bl.m >= 0 && maplist[sd->bl.m].flag.nowarpto && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif->message(fd, msg_txt(1032)); // You are not authorized to warp somenone to your current map. return false; } @@ -3552,13 +3537,11 @@ ACMD(partyrecall) count = 0; iter = mapit_getallusers(); - for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) - { - if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.party_id == p->party.party_id) - { + for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) { + if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.party_id == p->party.party_id) { if (pc->get_group_level(pl_sd) > pc->get_group_level(sd) || (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y)) continue; // Skip GMs greater than you... or chars already on the cell - if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) + if (pl_sd->bl.m >= 0 && maplist[pl_sd->bl.m].flag.nowarp && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) count++; else pc->setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN); @@ -3814,129 +3797,129 @@ ACMD(mapinfo) { } mapit->free(iter); - sprintf(atcmd_output, msg_txt(1040), mapname, map[m_id].zone->name, map[m_id].users, map[m_id].npc_num, chat_num, vend_num); // Map: %s (Zone:%s) | Players: %d | NPCs: %d | Chats: %d | Vendings: %d + sprintf(atcmd_output, msg_txt(1040), mapname, maplist[m_id].zone->name, maplist[m_id].users, maplist[m_id].npc_num, chat_num, vend_num); // Map: %s (Zone:%s) | Players: %d | NPCs: %d | Chats: %d | Vendings: %d clif->message(fd, atcmd_output); clif->message(fd, msg_txt(1041)); // ------ Map Flags ------ - if (map[m_id].flag.town) + if (maplist[m_id].flag.town) clif->message(fd, msg_txt(1042)); // Town Map - if (battle_config.autotrade_mapflag == map[m_id].flag.autotrade) + if (battle_config.autotrade_mapflag == maplist[m_id].flag.autotrade) clif->message(fd, msg_txt(1043)); // Autotrade Enabled else clif->message(fd, msg_txt(1044)); // Autotrade Disabled - if (map[m_id].flag.battleground) + if (maplist[m_id].flag.battleground) clif->message(fd, msg_txt(1045)); // Battlegrounds ON strcpy(atcmd_output,msg_txt(1046)); // PvP Flags: - if (map[m_id].flag.pvp) + if (maplist[m_id].flag.pvp) strcat(atcmd_output, msg_txt(1047)); // Pvp ON | - if (map[m_id].flag.pvp_noguild) + if (maplist[m_id].flag.pvp_noguild) strcat(atcmd_output, msg_txt(1048)); // NoGuild | - if (map[m_id].flag.pvp_noparty) + if (maplist[m_id].flag.pvp_noparty) strcat(atcmd_output, msg_txt(1049)); // NoParty | - if (map[m_id].flag.pvp_nightmaredrop) + if (maplist[m_id].flag.pvp_nightmaredrop) strcat(atcmd_output, msg_txt(1050)); // NightmareDrop | - if (map[m_id].flag.pvp_nocalcrank) + if (maplist[m_id].flag.pvp_nocalcrank) strcat(atcmd_output, msg_txt(1051)); // NoCalcRank | clif->message(fd, atcmd_output); strcpy(atcmd_output,msg_txt(1052)); // GvG Flags: - if (map[m_id].flag.gvg) + if (maplist[m_id].flag.gvg) strcat(atcmd_output, msg_txt(1053)); // GvG ON | - if (map[m_id].flag.gvg_dungeon) + if (maplist[m_id].flag.gvg_dungeon) strcat(atcmd_output, msg_txt(1054)); // GvG Dungeon | - if (map[m_id].flag.gvg_castle) + if (maplist[m_id].flag.gvg_castle) strcat(atcmd_output, msg_txt(1055)); // GvG Castle | - if (map[m_id].flag.gvg_noparty) + if (maplist[m_id].flag.gvg_noparty) strcat(atcmd_output, msg_txt(1056)); // NoParty | clif->message(fd, atcmd_output); strcpy(atcmd_output,msg_txt(1057)); // Teleport Flags: - if (map[m_id].flag.noteleport) + if (maplist[m_id].flag.noteleport) strcat(atcmd_output, msg_txt(1058)); // NoTeleport | - if (map[m_id].flag.monster_noteleport) + if (maplist[m_id].flag.monster_noteleport) strcat(atcmd_output, msg_txt(1059)); // Monster NoTeleport | - if (map[m_id].flag.nowarp) + if (maplist[m_id].flag.nowarp) strcat(atcmd_output, msg_txt(1060)); // NoWarp | - if (map[m_id].flag.nowarpto) + if (maplist[m_id].flag.nowarpto) strcat(atcmd_output, msg_txt(1061)); // NoWarpTo | - if (map[m_id].flag.noreturn) + if (maplist[m_id].flag.noreturn) strcat(atcmd_output, msg_txt(1062)); // NoReturn | - if (map[m_id].flag.nomemo) + if (maplist[m_id].flag.nomemo) strcat(atcmd_output, msg_txt(1064)); // NoMemo | clif->message(fd, atcmd_output); sprintf(atcmd_output, msg_txt(1065), // No Exp Penalty: %s | No Zeny Penalty: %s - (map[m_id].flag.noexppenalty) ? msg_txt(1066) : msg_txt(1067), (map[m_id].flag.nozenypenalty) ? msg_txt(1066) : msg_txt(1067)); // On / Off + (maplist[m_id].flag.noexppenalty) ? msg_txt(1066) : msg_txt(1067), + (maplist[m_id].flag.nozenypenalty) ? msg_txt(1066) : msg_txt(1067)); // On / Off clif->message(fd, atcmd_output); - if (map[m_id].flag.nosave) { - if (!map[m_id].save.map) + if (maplist[m_id].flag.nosave) { + if (!maplist[m_id].save.map) clif->message(fd, msg_txt(1068)); // No Save (Return to last Save Point) - else if (map[m_id].save.x == -1 || map[m_id].save.y == -1 ) { - sprintf(atcmd_output, msg_txt(1069), mapindex_id2name(map[m_id].save.map)); // No Save, Save Point: %s,Random + else if (maplist[m_id].save.x == -1 || maplist[m_id].save.y == -1 ) { + sprintf(atcmd_output, msg_txt(1069), mapindex_id2name(maplist[m_id].save.map)); // No Save, Save Point: %s,Random clif->message(fd, atcmd_output); - } - else { + } else { sprintf(atcmd_output, msg_txt(1070), // No Save, Save Point: %s,%d,%d - mapindex_id2name(map[m_id].save.map),map[m_id].save.x,map[m_id].save.y); + mapindex_id2name(maplist[m_id].save.map),maplist[m_id].save.x,maplist[m_id].save.y); clif->message(fd, atcmd_output); } } strcpy(atcmd_output,msg_txt(1071)); // Weather Flags: - if (map[m_id].flag.snow) + if (maplist[m_id].flag.snow) strcat(atcmd_output, msg_txt(1072)); // Snow | - if (map[m_id].flag.fog) + if (maplist[m_id].flag.fog) strcat(atcmd_output, msg_txt(1073)); // Fog | - if (map[m_id].flag.sakura) + if (maplist[m_id].flag.sakura) strcat(atcmd_output, msg_txt(1074)); // Sakura | - if (map[m_id].flag.clouds) + if (maplist[m_id].flag.clouds) strcat(atcmd_output, msg_txt(1075)); // Clouds | - if (map[m_id].flag.clouds2) + if (maplist[m_id].flag.clouds2) strcat(atcmd_output, msg_txt(1076)); // Clouds2 | - if (map[m_id].flag.fireworks) + if (maplist[m_id].flag.fireworks) strcat(atcmd_output, msg_txt(1077)); // Fireworks | - if (map[m_id].flag.leaves) + if (maplist[m_id].flag.leaves) strcat(atcmd_output, msg_txt(1078)); // Leaves | - if (map[m_id].flag.nightenabled) + if (maplist[m_id].flag.nightenabled) strcat(atcmd_output, msg_txt(1080)); // Displays Night | clif->message(fd, atcmd_output); strcpy(atcmd_output,msg_txt(1081)); // Other Flags: - if (map[m_id].flag.nobranch) + if (maplist[m_id].flag.nobranch) strcat(atcmd_output, msg_txt(1082)); // NoBranch | - if (map[m_id].flag.notrade) + if (maplist[m_id].flag.notrade) strcat(atcmd_output, msg_txt(1083)); // NoTrade | - if (map[m_id].flag.novending) + if (maplist[m_id].flag.novending) strcat(atcmd_output, msg_txt(1084)); // NoVending | - if (map[m_id].flag.nodrop) + if (maplist[m_id].flag.nodrop) strcat(atcmd_output, msg_txt(1085)); // NoDrop | - if (map[m_id].flag.noskill) + if (maplist[m_id].flag.noskill) strcat(atcmd_output, msg_txt(1086)); // NoSkill | - if (map[m_id].flag.noicewall) + if (maplist[m_id].flag.noicewall) strcat(atcmd_output, msg_txt(1087)); // NoIcewall | - if (map[m_id].flag.allowks) + if (maplist[m_id].flag.allowks) strcat(atcmd_output, msg_txt(1088)); // AllowKS | - if (map[m_id].flag.reset) + if (maplist[m_id].flag.reset) strcat(atcmd_output, msg_txt(1089)); // Reset | clif->message(fd, atcmd_output); strcpy(atcmd_output,msg_txt(1090)); // Other Flags: - if (map[m_id].nocommand) + if (maplist[m_id].nocommand) strcat(atcmd_output, msg_txt(1091)); // NoCommand | - if (map[m_id].flag.nobaseexp) + if (maplist[m_id].flag.nobaseexp) strcat(atcmd_output, msg_txt(1092)); // NoBaseEXP | - if (map[m_id].flag.nojobexp) + if (maplist[m_id].flag.nojobexp) strcat(atcmd_output, msg_txt(1093)); // NoJobEXP | - if (map[m_id].flag.nomobloot) + if (maplist[m_id].flag.nomobloot) strcat(atcmd_output, msg_txt(1094)); // NoMobLoot | - if (map[m_id].flag.nomvploot) + if (maplist[m_id].flag.nomvploot) strcat(atcmd_output, msg_txt(1095)); // NoMVPLoot | - if (map[m_id].flag.partylock) + if (maplist[m_id].flag.partylock) strcat(atcmd_output, msg_txt(1096)); // PartyLock | - if (map[m_id].flag.guildlock) + if (maplist[m_id].flag.guildlock) strcat(atcmd_output, msg_txt(1097)); // GuildLock | clif->message(fd, atcmd_output); @@ -3959,9 +3942,8 @@ ACMD(mapinfo) { break; case 2: clif->message(fd, msg_txt(1100)); // ----- NPCs in Map ----- - for (i = 0; i < map[m_id].npc_num;) - { - nd = map[m_id].npc[i]; + for (i = 0; i < maplist[m_id].npc_num;) { + nd = maplist[m_id].npc[i]; switch(nd->dir) { case 0: strcpy(direction, msg_txt(1101)); break; // North case 1: strcpy(direction, msg_txt(1102)); break; // North West @@ -5077,10 +5059,9 @@ ACMD(killable) * @skillon by MouseJstr * turn skills on for the map *------------------------------------------*/ -ACMD(skillon) -{ +ACMD(skillon) { nullpo_retr(-1, sd); - map[sd->bl.m].flag.noskill = 0; + maplist[sd->bl.m].flag.noskill = 0; clif->message(fd, msg_txt(244)); return true; } @@ -5089,10 +5070,9 @@ ACMD(skillon) * @skilloff by MouseJstr * Turn skills off on the map *------------------------------------------*/ -ACMD(skilloff) -{ +ACMD(skilloff) { nullpo_retr(-1, sd); - map[sd->bl.m].flag.noskill = 1; + maplist[sd->bl.m].flag.noskill = 1; clif->message(fd, msg_txt(243)); return true; } @@ -5125,8 +5105,8 @@ ACMD(npcmove) return false; //Not on a map. } - x = cap_value(x, 0, map[m].xs-1); - y = cap_value(y, 0, map[m].ys-1); + x = cap_value(x, 0, maplist[m].xs-1); + y = cap_value(y, 0, maplist[m].ys-1); iMap->foreachinrange(clif->outsight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl); iMap->moveblock(&nd->bl, x, y, timer->gettick()); iMap->foreachinrange(clif->insight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl); @@ -5619,7 +5599,7 @@ ACMD(changelook) ACMD(autotrade) { nullpo_retr(-1, sd); - if( map[sd->bl.m].flag.autotrade != battle_config.autotrade_mapflag ) { + if( maplist[sd->bl.m].flag.autotrade != battle_config.autotrade_mapflag ) { clif->message(fd, msg_txt(1179)); // Autotrade is not allowed on this map. return false; } @@ -5662,7 +5642,7 @@ ACMD(changegm) return false; } - if( map[sd->bl.m].flag.guildlock || map[sd->bl.m].flag.gvg_castle ) { + if( maplist[sd->bl.m].flag.guildlock || maplist[sd->bl.m].flag.gvg_castle ) { clif->message(fd, msg_txt(1182)); // You cannot change guild leaders on this map. return false; } @@ -5878,15 +5858,14 @@ ACMD(autolootitem) /*========================================== * It is made to rain. *------------------------------------------*/ -//ACMD(rain) -//{ +//ACMD(rain) { // nullpo_retr(-1, sd); -// if (map[sd->bl.m].flag.rain) { -// map[sd->bl.m].flag.rain=0; +// if (maplist[sd->bl.m].flag.rain) { +// maplist[sd->bl.m].flag.rain=0; // clif->weather(sd->bl.m); // clif->message(fd, msg_txt(1201)); // The rain has stopped. // } else { -// map[sd->bl.m].flag.rain=1; +// maplist[sd->bl.m].flag.rain=1; // clif->weather(sd->bl.m); // clif->message(fd, msg_txt(1202)); // It has started to rain. // } @@ -5896,15 +5875,14 @@ ACMD(autolootitem) /*========================================== * It is made to snow. *------------------------------------------*/ -ACMD(snow) -{ +ACMD(snow) { nullpo_retr(-1, sd); - if (map[sd->bl.m].flag.snow) { - map[sd->bl.m].flag.snow=0; + if (maplist[sd->bl.m].flag.snow) { + maplist[sd->bl.m].flag.snow=0; clif->weather(sd->bl.m); clif->message(fd, msg_txt(1203)); // Snow has stopped falling. } else { - map[sd->bl.m].flag.snow=1; + maplist[sd->bl.m].flag.snow=1; clif->weather(sd->bl.m); clif->message(fd, msg_txt(1204)); // It has started to snow. } @@ -5915,15 +5893,14 @@ ACMD(snow) /*========================================== * Cherry tree snowstorm is made to fall. (Sakura) *------------------------------------------*/ -ACMD(sakura) -{ +ACMD(sakura) { nullpo_retr(-1, sd); - if (map[sd->bl.m].flag.sakura) { - map[sd->bl.m].flag.sakura=0; + if (maplist[sd->bl.m].flag.sakura) { + maplist[sd->bl.m].flag.sakura=0; clif->weather(sd->bl.m); clif->message(fd, msg_txt(1205)); // Cherry tree leaves no longer fall. } else { - map[sd->bl.m].flag.sakura=1; + maplist[sd->bl.m].flag.sakura=1; clif->weather(sd->bl.m); clif->message(fd, msg_txt(1206)); // Cherry tree leaves have begun to fall. } @@ -5933,15 +5910,14 @@ ACMD(sakura) /*========================================== * Clouds appear. *------------------------------------------*/ -ACMD(clouds) -{ +ACMD(clouds) { nullpo_retr(-1, sd); - if (map[sd->bl.m].flag.clouds) { - map[sd->bl.m].flag.clouds=0; + if (maplist[sd->bl.m].flag.clouds) { + maplist[sd->bl.m].flag.clouds=0; clif->weather(sd->bl.m); clif->message(fd, msg_txt(1207)); // The clouds has disappear. } else { - map[sd->bl.m].flag.clouds=1; + maplist[sd->bl.m].flag.clouds=1; clif->weather(sd->bl.m); clif->message(fd, msg_txt(1208)); // Clouds appear. } @@ -5952,15 +5928,14 @@ ACMD(clouds) /*========================================== * Different type of clouds using effect 516 *------------------------------------------*/ -ACMD(clouds2) -{ +ACMD(clouds2) { nullpo_retr(-1, sd); - if (map[sd->bl.m].flag.clouds2) { - map[sd->bl.m].flag.clouds2=0; + if (maplist[sd->bl.m].flag.clouds2) { + maplist[sd->bl.m].flag.clouds2=0; clif->weather(sd->bl.m); clif->message(fd, msg_txt(1209)); // The alternative clouds disappear. } else { - map[sd->bl.m].flag.clouds2=1; + maplist[sd->bl.m].flag.clouds2=1; clif->weather(sd->bl.m); clif->message(fd, msg_txt(1210)); // Alternative clouds appear. } @@ -5971,15 +5946,14 @@ ACMD(clouds2) /*========================================== * Fog hangs over. *------------------------------------------*/ -ACMD(fog) -{ +ACMD(fog) { nullpo_retr(-1, sd); - if (map[sd->bl.m].flag.fog) { - map[sd->bl.m].flag.fog=0; + if (maplist[sd->bl.m].flag.fog) { + maplist[sd->bl.m].flag.fog=0; clif->weather(sd->bl.m); clif->message(fd, msg_txt(1211)); // The fog has gone. } else { - map[sd->bl.m].flag.fog=1; + maplist[sd->bl.m].flag.fog=1; clif->weather(sd->bl.m); clif->message(fd, msg_txt(1212)); // Fog hangs over. } @@ -5989,15 +5963,14 @@ ACMD(fog) /*========================================== * Fallen leaves fall. *------------------------------------------*/ -ACMD(leaves) -{ +ACMD(leaves) { nullpo_retr(-1, sd); - if (map[sd->bl.m].flag.leaves) { - map[sd->bl.m].flag.leaves=0; + if (maplist[sd->bl.m].flag.leaves) { + maplist[sd->bl.m].flag.leaves=0; clif->weather(sd->bl.m); clif->message(fd, msg_txt(1213)); // Leaves no longer fall. } else { - map[sd->bl.m].flag.leaves=1; + maplist[sd->bl.m].flag.leaves=1; clif->weather(sd->bl.m); clif->message(fd, msg_txt(1214)); // Fallen leaves fall. } @@ -6008,15 +5981,14 @@ ACMD(leaves) /*========================================== * Fireworks appear. *------------------------------------------*/ -ACMD(fireworks) -{ +ACMD(fireworks) { nullpo_retr(-1, sd); - if (map[sd->bl.m].flag.fireworks) { - map[sd->bl.m].flag.fireworks=0; + if (maplist[sd->bl.m].flag.fireworks) { + maplist[sd->bl.m].flag.fireworks=0; clif->weather(sd->bl.m); clif->message(fd, msg_txt(1215)); // Fireworks have ended. } else { - map[sd->bl.m].flag.fireworks=1; + maplist[sd->bl.m].flag.fireworks=1; clif->weather(sd->bl.m); clif->message(fd, msg_txt(1216)); // Fireworks have launched. } @@ -6027,20 +5999,19 @@ ACMD(fireworks) /*========================================== * Clearing Weather Effects by Dexity *------------------------------------------*/ -ACMD(clearweather) -{ +ACMD(clearweather) { nullpo_retr(-1, sd); /** * No longer available, keeping here just in case it's back someday. [Ind] **/ - //map[sd->bl.m].flag.rain=0; - map[sd->bl.m].flag.snow=0; - map[sd->bl.m].flag.sakura=0; - map[sd->bl.m].flag.clouds=0; - map[sd->bl.m].flag.clouds2=0; - map[sd->bl.m].flag.fog=0; - map[sd->bl.m].flag.fireworks=0; - map[sd->bl.m].flag.leaves=0; + //maplist[sd->bl.m].flag.rain=0; + maplist[sd->bl.m].flag.snow=0; + maplist[sd->bl.m].flag.sakura=0; + maplist[sd->bl.m].flag.clouds=0; + maplist[sd->bl.m].flag.clouds2=0; + maplist[sd->bl.m].flag.fog=0; + maplist[sd->bl.m].flag.fireworks=0; + maplist[sd->bl.m].flag.leaves=0; clif->weather(sd->bl.m); clif->message(fd, msg_txt(291)); @@ -7319,11 +7290,10 @@ ACMD(whereis) snprintf(atcmd_output, sizeof atcmd_output, msg_txt(1289), monster->jname); // %s spawns in: clif->message(fd, atcmd_output); - for (i = 0; i < ARRAYLENGTH(monster->spawn) && monster->spawn[i].qty; i++) - { + for (i = 0; i < ARRAYLENGTH(monster->spawn) && monster->spawn[i].qty; i++) { j = iMap->mapindex2mapid(monster->spawn[i].mapindex); if (j < 0) continue; - snprintf(atcmd_output, sizeof atcmd_output, "%s (%d)", map[j].name, monster->spawn[i].qty); + snprintf(atcmd_output, sizeof atcmd_output, "%s (%d)", maplist[j].name, monster->spawn[i].qty); clif->message(fd, atcmd_output); } if (i == 0) @@ -7599,14 +7569,16 @@ ACMD(fakename) * Ragnarok Resources *------------------------------------------*/ ACMD(mapflag) { -#define checkflag( cmd ) if ( map[ sd->bl.m ].flag.cmd ) clif->message(sd->fd,#cmd) -#define setflag( cmd ) \ -if ( strcmp( flag_name , #cmd ) == 0 ){\ -map[ sd->bl.m ].flag.cmd = flag;\ -sprintf(atcmd_output,"[ @mapflag ] %s flag has been set to %s value = %hd",#cmd,flag?"On":"Off",flag);\ -clif->message(sd->fd,atcmd_output);\ -return true;\ -} +#define checkflag( cmd ) if ( maplist[ sd->bl.m ].flag.cmd ) clif->message(sd->fd,#cmd) +#define setflag( cmd ) do {\ + if ( strcmp( flag_name , #cmd ) == 0 ) { \ + maplist[ sd->bl.m ].flag.cmd = flag; \ + sprintf(atcmd_output,"[ @mapflag ] %s flag has been set to %s value = %hd",#cmd,flag?"On":"Off",flag); \ + clif->message(sd->fd,atcmd_output); \ + return true; \ + } \ +} while(0) + char flag_name[100]; short flag=0,i; nullpo_retr(-1, sd); @@ -7636,20 +7608,20 @@ return true;\ for (i = 0; flag_name[i]; i++) flag_name[i] = TOLOWER(flag_name[i]); //lowercase if ( strcmp( flag_name , "gvg" ) == 0 ) { - if( flag && !map[sd->bl.m].flag.gvg ) + if( flag && !maplist[sd->bl.m].flag.gvg ) iMap->zone_change2(sd->bl.m,strdb_get(zone_db, MAP_ZONE_GVG_NAME)); - else if ( !flag && map[sd->bl.m].flag.gvg ) - iMap->zone_change2(sd->bl.m,map[sd->bl.m].prev_zone); + else if ( !flag && maplist[sd->bl.m].flag.gvg ) + iMap->zone_change2(sd->bl.m,maplist[sd->bl.m].prev_zone); } else if ( strcmp( flag_name , "pvp" ) == 0 ) { - if( flag && !map[sd->bl.m].flag.pvp ) + if( flag && !maplist[sd->bl.m].flag.pvp ) iMap->zone_change2(sd->bl.m,strdb_get(zone_db, MAP_ZONE_PVP_NAME)); - else if ( !flag && map[sd->bl.m].flag.pvp ) - iMap->zone_change2(sd->bl.m,map[sd->bl.m].prev_zone); + else if ( !flag && maplist[sd->bl.m].flag.pvp ) + iMap->zone_change2(sd->bl.m,maplist[sd->bl.m].prev_zone); } else if ( strcmp( flag_name , "battleground" ) == 0 ) { - if( flag && !map[sd->bl.m].flag.battleground ) + if( flag && !maplist[sd->bl.m].flag.battleground ) iMap->zone_change2(sd->bl.m,strdb_get(zone_db, MAP_ZONE_BG_NAME)); - else if ( !flag && map[sd->bl.m].flag.battleground ) - iMap->zone_change2(sd->bl.m,map[sd->bl.m].prev_zone); + else if ( !flag && maplist[sd->bl.m].flag.battleground ) + iMap->zone_change2(sd->bl.m,maplist[sd->bl.m].prev_zone); } setflag(autotrade); setflag(allowks); setflag(nomemo); setflag(noteleport); @@ -8086,15 +8058,14 @@ ACMD(ksprotection) /*========================================== * Map Kill Steal Protection Setting *------------------------------------------*/ -ACMD(allowks) -{ +ACMD(allowks) { nullpo_retr(-1,sd); - if( map[sd->bl.m].flag.allowks ) { - map[sd->bl.m].flag.allowks = 0; + if( maplist[sd->bl.m].flag.allowks ) { + maplist[sd->bl.m].flag.allowks = 0; clif->message(fd, msg_txt(1330)); // [ Map K.S Protection Active ] } else { - map[sd->bl.m].flag.allowks = 1; + maplist[sd->bl.m].flag.allowks = 1; clif->message(fd, msg_txt(1331)); // [ Map K.S Protection Inactive ] } return true; @@ -8793,11 +8764,11 @@ ACMD(join) { return false; } if( hChSys.local && strcmpi(name + 1, hChSys.local_name) == 0 ) { - if( !map[sd->bl.m].channel ) { + if( !maplist[sd->bl.m].channel ) { clif->chsys_mjoin(sd); return true; } else - channel = map[sd->bl.m].channel; + channel = maplist[sd->bl.m].channel; } else if( hChSys.ally && sd->status.guild_id && strcmpi(name + 1, hChSys.ally_name) == 0 ) { struct guild *g = sd->guild; if( !g ) return false;/* unlikely, but we wont let it crash anyway. */ @@ -8963,7 +8934,7 @@ ACMD(channel) { bool show_all = pc->has_permission(sd, PC_PERM_HCHSYS_ADMIN) ? true : false; clif->message(fd, msg_txt(1410)); // -- Public Channels if( hChSys.local ) { - sprintf(atcmd_output, msg_txt(1409), hChSys.local_name, map[sd->bl.m].channel ? db_size(map[sd->bl.m].channel->users) : 0);// - #%s ( %d users ) + sprintf(atcmd_output, msg_txt(1409), hChSys.local_name, maplist[sd->bl.m].channel ? db_size(maplist[sd->bl.m].channel->users) : 0);// - #%s ( %d users ) clif->message(fd, atcmd_output); } if( hChSys.ally && sd->status.guild_id ) { @@ -9902,7 +9873,7 @@ bool is_atcommand(const int fd, struct map_session_data* sd, const char* message // 1 = player invoked if ( type == 1) { //Commands are disabled on maps flagged as 'nocommand' - if ( map[sd->bl.m].nocommand && pc->get_group_level(sd) < map[sd->bl.m].nocommand ) { + if ( maplist[sd->bl.m].nocommand && pc->get_group_level(sd) < maplist[sd->bl.m].nocommand ) { clif->message(fd, msg_txt(143)); return false; } @@ -10020,9 +9991,9 @@ bool is_atcommand(const int fd, struct map_session_data* sd, const char* message clif->message(fd, msg_txt(1393)); // You can't use commands while dead return true; } - for(i = 0; i < map[sd->bl.m].zone->disabled_commands_count; i++) { - if( info->func == map[sd->bl.m].zone->disabled_commands[i]->cmd ) { - if( pc->get_group_level(sd) < map[sd->bl.m].zone->disabled_commands[i]->group_lv ) { + for(i = 0; i < maplist[sd->bl.m].zone->disabled_commands_count; i++) { + if( info->func == maplist[sd->bl.m].zone->disabled_commands[i]->cmd ) { + if( pc->get_group_level(sd) < maplist[sd->bl.m].zone->disabled_commands[i]->group_lv ) { clif->colormes(sd->fd,COLOR_RED,"This command is disabled in this area"); return true; } else diff --git a/src/map/battle.c b/src/map/battle.c index 6427fb157..54716bd32 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -3021,16 +3021,16 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam default: if (flag & BF_SKILL) { //Skills get a different reduction than non-skills. [Skotlex] if (flag&BF_WEAPON) - damage = damage * map[bl->m].weapon_damage_rate / 100; + damage = damage * maplist[bl->m].weapon_damage_rate / 100; if (flag&BF_MAGIC) - damage = damage * map[bl->m].magic_damage_rate / 100; + damage = damage * maplist[bl->m].magic_damage_rate / 100; if (flag&BF_MISC) - damage = damage * map[bl->m].misc_damage_rate / 100; + damage = damage * maplist[bl->m].misc_damage_rate / 100; } else { //Normal attacks get reductions based on range. if (flag & BF_SHORT) - damage = damage * map[bl->m].short_damage_rate / 100; + damage = damage * maplist[bl->m].short_damage_rate / 100; if (flag & BF_LONG) - damage = damage * map[bl->m].long_damage_rate / 100; + damage = damage * maplist[bl->m].long_damage_rate / 100; } if(!damage) damage = 1; break; @@ -3197,13 +3197,12 @@ int battle_range_type(struct block_list *src, struct block_list *target, uint16 return BF_LONG; } int battle_adjust_skill_damage(int m, unsigned short skill_id) { - - if( map[m].skill_count ) { + if( maplist[m].skill_count ) { int i; - ARR_FIND(0, map[m].skill_count, i, map[m].skills[i]->skill_id == skill_id ); + ARR_FIND(0, maplist[m].skill_count, i, maplist[m].skills[i]->skill_id == skill_id ); - if( i < map[m].skill_count ) { - return map[m].skills[i]->modifier; + if( i < maplist[m].skill_count ) { + return maplist[m].skills[i]->modifier; } } @@ -3422,18 +3421,18 @@ struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list } #ifndef HMAP_ZONE_DAMAGE_CAP_TYPE if( target && skill_id ) { - for(i = 0; i < map[target->m].zone->capped_skills_count; i++) { - if( skill_id == map[target->m].zone->capped_skills[i]->nameid && (map[target->m].zone->capped_skills[i]->type & target->type) ) { - if( target->type == BL_MOB && map[target->m].zone->capped_skills[i]->subtype != MZS_NONE ) { - if( (((TBL_MOB*)target)->status.mode&MD_BOSS) && !(map[target->m].zone->disabled_skills[i]->subtype&MZS_BOSS) ) + for(i = 0; i < maplist[target->m].zone->capped_skills_count; i++) { + if( skill_id == maplist[target->m].zone->capped_skills[i]->nameid && (maplist[target->m].zone->capped_skills[i]->type & target->type) ) { + if( target->type == BL_MOB && maplist[target->m].zone->capped_skills[i]->subtype != MZS_NONE ) { + if( (((TBL_MOB*)target)->status.mode&MD_BOSS) && !(maplist[target->m].zone->disabled_skills[i]->subtype&MZS_BOSS) ) continue; - if( ((TBL_MOB*)target)->special_state.clone && !(map[target->m].zone->disabled_skills[i]->subtype&MZS_CLONE) ) + if( ((TBL_MOB*)target)->special_state.clone && !(maplist[target->m].zone->disabled_skills[i]->subtype&MZS_CLONE) ) continue; } - if( ad.damage > map[target->m].zone->capped_skills[i]->cap ) - ad.damage = map[target->m].zone->capped_skills[i]->cap; - if( ad.damage2 > map[target->m].zone->capped_skills[i]->cap ) - ad.damage2 = map[target->m].zone->capped_skills[i]->cap; + if( ad.damage > maplist[target->m].zone->capped_skills[i]->cap ) + ad.damage = maplist[target->m].zone->capped_skills[i]->cap; + if( ad.damage2 > maplist[target->m].zone->capped_skills[i]->cap ) + ad.damage2 = maplist[target->m].zone->capped_skills[i]->cap; break; } } @@ -3518,7 +3517,7 @@ struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list ad.damage=battle->calc_damage(src,target,&ad,ad.damage,skill_id,skill_lv); if( map_flag_gvg2(target->m) ) ad.damage=battle->calc_gvg_damage(src,target,ad.damage,ad.div_,skill_id,skill_lv,ad.flag); - else if( map[target->m].flag.battleground ) + else if( maplist[target->m].flag.battleground ) ad.damage=battle->calc_bg_damage(src,target,ad.damage,ad.div_,skill_id,skill_lv,ad.flag); switch( skill_id ) { /* post-calc modifiers */ @@ -3864,18 +3863,18 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list * } #ifndef HMAP_ZONE_DAMAGE_CAP_TYPE if( target && skill_id ) { - for(i = 0; i < map[target->m].zone->capped_skills_count; i++) { - if( skill_id == map[target->m].zone->capped_skills[i]->nameid && (map[target->m].zone->capped_skills[i]->type & target->type) ) { - if( target->type == BL_MOB && map[target->m].zone->capped_skills[i]->subtype != MZS_NONE ) { - if( (((TBL_MOB*)target)->status.mode&MD_BOSS) && !(map[target->m].zone->disabled_skills[i]->subtype&MZS_BOSS) ) + for(i = 0; i < maplist[target->m].zone->capped_skills_count; i++) { + if( skill_id == maplist[target->m].zone->capped_skills[i]->nameid && (maplist[target->m].zone->capped_skills[i]->type & target->type) ) { + if( target->type == BL_MOB && maplist[target->m].zone->capped_skills[i]->subtype != MZS_NONE ) { + if( (((TBL_MOB*)target)->status.mode&MD_BOSS) && !(maplist[target->m].zone->disabled_skills[i]->subtype&MZS_BOSS) ) continue; - if( ((TBL_MOB*)target)->special_state.clone && !(map[target->m].zone->disabled_skills[i]->subtype&MZS_CLONE) ) + if( ((TBL_MOB*)target)->special_state.clone && !(maplist[target->m].zone->disabled_skills[i]->subtype&MZS_CLONE) ) continue; } - if( md.damage > map[target->m].zone->capped_skills[i]->cap ) - md.damage = map[target->m].zone->capped_skills[i]->cap; - if( md.damage2 > map[target->m].zone->capped_skills[i]->cap ) - md.damage2 = map[target->m].zone->capped_skills[i]->cap; + if( md.damage > maplist[target->m].zone->capped_skills[i]->cap ) + md.damage = maplist[target->m].zone->capped_skills[i]->cap; + if( md.damage2 > maplist[target->m].zone->capped_skills[i]->cap ) + md.damage2 = maplist[target->m].zone->capped_skills[i]->cap; break; } } @@ -3916,7 +3915,7 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list * md.damage=battle->calc_damage(src,target,&md,md.damage,skill_id,skill_lv); if( map_flag_gvg2(target->m) ) md.damage=battle->calc_gvg_damage(src,target,md.damage,md.div_,skill_id,skill_lv,md.flag); - else if( map[target->m].flag.battleground ) + else if( maplist[target->m].flag.battleground ) md.damage=battle->calc_bg_damage(src,target,md.damage,md.div_,skill_id,skill_lv,md.flag); switch( skill_id ) { @@ -4879,18 +4878,18 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list return wd; //Enough, rest is not needed. #ifndef HMAP_ZONE_DAMAGE_CAP_TYPE if( target && skill_id ) { - for(i = 0; i < map[target->m].zone->capped_skills_count; i++) { - if( skill_id == map[target->m].zone->capped_skills[i]->nameid && (map[target->m].zone->capped_skills[i]->type & target->type) ) { - if( target->type == BL_MOB && map[target->m].zone->capped_skills[i]->subtype != MZS_NONE ) { - if( (((TBL_MOB*)target)->status.mode&MD_BOSS) && !(map[target->m].zone->disabled_skills[i]->subtype&MZS_BOSS) ) + for(i = 0; i < maplist[target->m].zone->capped_skills_count; i++) { + if( skill_id == maplist[target->m].zone->capped_skills[i]->nameid && (maplist[target->m].zone->capped_skills[i]->type & target->type) ) { + if( target->type == BL_MOB && maplist[target->m].zone->capped_skills[i]->subtype != MZS_NONE ) { + if( (((TBL_MOB*)target)->status.mode&MD_BOSS) && !(maplist[target->m].zone->disabled_skills[i]->subtype&MZS_BOSS) ) continue; - if( ((TBL_MOB*)target)->special_state.clone && !(map[target->m].zone->disabled_skills[i]->subtype&MZS_CLONE) ) + if( ((TBL_MOB*)target)->special_state.clone && !(maplist[target->m].zone->disabled_skills[i]->subtype&MZS_CLONE) ) continue; } - if( wd.damage > map[target->m].zone->capped_skills[i]->cap ) - wd.damage = map[target->m].zone->capped_skills[i]->cap; - if( wd.damage2 > map[target->m].zone->capped_skills[i]->cap ) - wd.damage2 = map[target->m].zone->capped_skills[i]->cap; + if( wd.damage > maplist[target->m].zone->capped_skills[i]->cap ) + wd.damage = maplist[target->m].zone->capped_skills[i]->cap; + if( wd.damage2 > maplist[target->m].zone->capped_skills[i]->cap ) + wd.damage2 = maplist[target->m].zone->capped_skills[i]->cap; break; } } @@ -5063,24 +5062,19 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list } } } - if(!wd.damage2) - { + if(!wd.damage2) { wd.damage = battle->calc_damage(src,target,&wd,wd.damage,skill_id,skill_lv); if( map_flag_gvg2(target->m) ) wd.damage=battle->calc_gvg_damage(src,target,wd.damage,wd.div_,skill_id,skill_lv,wd.flag); - else if( map[target->m].flag.battleground ) + else if( maplist[target->m].flag.battleground ) wd.damage=battle->calc_bg_damage(src,target,wd.damage,wd.div_,skill_id,skill_lv,wd.flag); - } - else if(!wd.damage) - { + } else if(!wd.damage) { wd.damage2 = battle->calc_damage(src,target,&wd,wd.damage2,skill_id,skill_lv); if( map_flag_gvg2(target->m) ) wd.damage2 = battle->calc_gvg_damage(src,target,wd.damage2,wd.div_,skill_id,skill_lv,wd.flag); - else if( map[target->m].flag.battleground ) + else if( maplist[target->m].flag.battleground ) wd.damage = battle->calc_bg_damage(src,target,wd.damage2,wd.div_,skill_id,skill_lv,wd.flag); - } - else - { + } else { #ifdef RENEWAL wd.damage = battle->calc_damage(src,target,&wd,wd.damage,skill_id,skill_lv); wd.damage2 = battle->calc_damage(src,target,&wd,wd.damage2,skill_id,skill_lv); @@ -5090,7 +5084,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list #endif if( map_flag_gvg2(target->m) ) wd.damage = battle->calc_gvg_damage(src,target,wd.damage,wd.div_,skill_id,skill_lv,wd.flag); - else if( map[target->m].flag.battleground ) + else if( maplist[target->m].flag.battleground ) wd.damage = battle->calc_bg_damage(src,target,wd.damage,wd.div_,skill_id,skill_lv,wd.flag); #ifndef RENEWAL wd.damage2 = d2*100/d1 * wd.damage/100; @@ -5143,18 +5137,18 @@ struct Damage battle_calc_attack(int attack_type,struct block_list *bl,struct bl #ifdef HMAP_ZONE_DAMAGE_CAP_TYPE if( target && skill_id ) { int i; - for(i = 0; i < map[target->m].zone->capped_skills_count; i++) { - if( skill_id == map[target->m].zone->capped_skills[i]->nameid && (map[target->m].zone->capped_skills[i]->type & target->type) ) { - if( target->type == BL_MOB && map[target->m].zone->capped_skills[i]->subtype != MZS_NONE ) { - if( (((TBL_MOB*)target)->status.mode&MD_BOSS) && !(map[target->m].zone->disabled_skills[i]->subtype&MZS_BOSS) ) + for(i = 0; i < maplist[target->m].zone->capped_skills_count; i++) { + if( skill_id == maplist[target->m].zone->capped_skills[i]->nameid && (maplist[target->m].zone->capped_skills[i]->type & target->type) ) { + if( target->type == BL_MOB && maplist[target->m].zone->capped_skills[i]->subtype != MZS_NONE ) { + if( (((TBL_MOB*)target)->status.mode&MD_BOSS) && !(maplist[target->m].zone->disabled_skills[i]->subtype&MZS_BOSS) ) continue; - if( ((TBL_MOB*)target)->special_state.clone && !(map[target->m].zone->disabled_skills[i]->subtype&MZS_CLONE) ) + if( ((TBL_MOB*)target)->special_state.clone && !(maplist[target->m].zone->disabled_skills[i]->subtype&MZS_CLONE) ) continue; } - if( d.damage > map[target->m].zone->capped_skills[i]->cap ) - d.damage = map[target->m].zone->capped_skills[i]->cap; - if( d.damage2 > map[target->m].zone->capped_skills[i]->cap ) - d.damage2 = map[target->m].zone->capped_skills[i]->cap; + if( d.damage > maplist[target->m].zone->capped_skills[i]->cap ) + d.damage = maplist[target->m].zone->capped_skills[i]->cap; + if( d.damage2 > maplist[target->m].zone->capped_skills[i]->cap ) + d.damage2 = maplist[target->m].zone->capped_skills[i]->cap; break; } } @@ -5825,7 +5819,7 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f switch( battle->get_current_skill(src) ) { case RK_DRAGONBREATH:// it can only hit traps in pvp/gvg maps case RK_DRAGONBREATH_WATER: - if( !map[m].flag.pvp && !map[m].flag.gvg ) + if( !maplist[m].flag.pvp && !maplist[m].flag.gvg ) break; case 0://you can hit them without skills case MA_REMOVETRAP: @@ -5911,7 +5905,7 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f { struct mob_data *md = BL_CAST(BL_MOB, t_bl); - if( !((iMap->agit_flag || iMap->agit2_flag) && map[m].flag.gvg_castle) && md->guardian_data && md->guardian_data->guild_id ) + if( !((iMap->agit_flag || iMap->agit2_flag) && maplist[m].flag.gvg_castle) && md->guardian_data && md->guardian_data->guild_id ) return 0; // Disable guardians/emperiums owned by Guilds on non-woe times. break; } @@ -5945,20 +5939,17 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f break; } //end switch actual src - switch( s_bl->type ) - { //Checks on source master + switch( s_bl->type ) { //Checks on source master case BL_PC: { struct map_session_data *sd = BL_CAST(BL_PC, s_bl); - if( s_bl != t_bl ) - { - if( sd->state.killer ) - { + if( s_bl != t_bl ) { + if( sd->state.killer ) { state |= BCT_ENEMY; // Can kill anything strip_enemy = 0; - } - else if( sd->duel_group && !((!battle_config.duel_allow_pvp && map[m].flag.pvp) || (!battle_config.duel_allow_gvg && map_flag_gvg(m))) ) - { + } else if( sd->duel_group + && !((!battle_config.duel_allow_pvp && maplist[m].flag.pvp) || (!battle_config.duel_allow_gvg && map_flag_gvg(m))) + ) { if( t_bl->type == BL_PC && (sd->duel_group == ((TBL_PC*)t_bl)->duel_group) ) return (BCT_ENEMY&flag)?1:-1; // Duel targets can ONLY be your enemy, nothing else. else @@ -5974,7 +5965,7 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f case BL_MOB: { struct mob_data *md = BL_CAST(BL_MOB, s_bl); - if( !((iMap->agit_flag || iMap->agit2_flag) && map[m].flag.gvg_castle) && md->guardian_data && md->guardian_data->guild_id ) + if( !((iMap->agit_flag || iMap->agit2_flag) && maplist[m].flag.gvg_castle) && md->guardian_data && md->guardian_data->guild_id ) return 0; // Disable guardians/emperium owned by Guilds on non-woe times. if( !md->special_state.ai ) @@ -6019,32 +6010,35 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f return (flag&state)?1:-1; } - if( map_flag_vs(m) ) - { //Check rivalry settings. + if( map_flag_vs(m) ) { + //Check rivalry settings. int sbg_id = 0, tbg_id = 0; - if( map[m].flag.battleground ) - { + if( maplist[m].flag.battleground ) { sbg_id = bg->team_get_id(s_bl); tbg_id = bg->team_get_id(t_bl); } - if( flag&(BCT_PARTY|BCT_ENEMY) ) - { + if( flag&(BCT_PARTY|BCT_ENEMY) ) { int s_party = iStatus->get_party_id(s_bl); - if( s_party && s_party == iStatus->get_party_id(t_bl) && !(map[m].flag.pvp && map[m].flag.pvp_noparty) && !(map_flag_gvg(m) && map[m].flag.gvg_noparty) && (!map[m].flag.battleground || sbg_id == tbg_id) ) + if( s_party && s_party == iStatus->get_party_id(t_bl) + && !(maplist[m].flag.pvp && maplist[m].flag.pvp_noparty) + && !(map_flag_gvg(m) && maplist[m].flag.gvg_noparty) + && (!maplist[m].flag.battleground || sbg_id == tbg_id) ) state |= BCT_PARTY; else state |= BCT_ENEMY; } - if( flag&(BCT_GUILD|BCT_ENEMY) ) - { + if( flag&(BCT_GUILD|BCT_ENEMY) ) { int s_guild = iStatus->get_guild_id(s_bl); int t_guild = iStatus->get_guild_id(t_bl); - if( !(map[m].flag.pvp && map[m].flag.pvp_noguild) && s_guild && t_guild && (s_guild == t_guild || (!(flag&BCT_SAMEGUILD) && guild->isallied(s_guild, t_guild))) && (!map[m].flag.battleground || sbg_id == tbg_id) ) + if( !(maplist[m].flag.pvp && maplist[m].flag.pvp_noguild) + && s_guild && t_guild + && (s_guild == t_guild || (!(flag&BCT_SAMEGUILD) && guild->isallied(s_guild, t_guild))) + && (!maplist[m].flag.battleground || sbg_id == tbg_id) ) state |= BCT_GUILD; else state |= BCT_ENEMY; } - if( state&BCT_ENEMY && map[m].flag.battleground && sbg_id && sbg_id == tbg_id ) + if( state&BCT_ENEMY && maplist[m].flag.battleground && sbg_id && sbg_id == tbg_id ) state &= ~BCT_ENEMY; if( state&BCT_ENEMY && battle_config.pk_mode && !map_flag_gvg(m) && s_bl->type == BL_PC && t_bl->type == BL_PC ) diff --git a/src/map/battleground.c b/src/map/battleground.c index 981264774..db6d6cd5a 100644 --- a/src/map/battleground.c +++ b/src/map/battleground.c @@ -91,8 +91,8 @@ int bg_team_join(int bg_id, struct map_session_data *sd) { bgd->members[i].x = sd->bl.x; bgd->members[i].y = sd->bl.y; /* populate 'where i came from' */ - if(map[sd->bl.m].flag.nosave || map[sd->bl.m].instance_id >= 0) { - struct map_data *m=&map[sd->bl.m]; + if(maplist[sd->bl.m].flag.nosave || maplist[sd->bl.m].instance_id >= 0) { + struct map_data *m=&maplist[sd->bl.m]; if(m->save.map) memcpy(&bgd->members[i].source,&m->save,sizeof(struct point)); else diff --git a/src/map/buyingstore.c b/src/map/buyingstore.c index 5edf9a321..f943b2a20 100644 --- a/src/map/buyingstore.c +++ b/src/map/buyingstore.c @@ -58,8 +58,8 @@ bool buyingstore_setup(struct map_session_data* sd, unsigned char slots) return false; } - if( map[sd->bl.m].flag.novending ) - {// custom: no vending maps + if( maplist[sd->bl.m].flag.novending ) { + // custom: no vending maps clif->message(sd->fd, msg_txt(276)); // "You can't open a shop on this map" return false; } @@ -113,8 +113,8 @@ void buyingstore_create(struct map_session_data* sd, int zenylimit, unsigned cha return; } - if( map[sd->bl.m].flag.novending ) - {// custom: no vending maps + if( maplist[sd->bl.m].flag.novending ) { + // custom: no vending maps clif->message(sd->fd, msg_txt(276)); // "You can't open a shop on this map" return; } diff --git a/src/map/chat.c b/src/map/chat.c index b7e561116..21d49cfc8 100644 --- a/src/map/chat.c +++ b/src/map/chat.c @@ -68,8 +68,7 @@ static struct chat_data* chat_createchat(struct block_list* bl, const char* titl /*========================================== * player chatroom creation *------------------------------------------*/ -int chat_createpcchat(struct map_session_data* sd, const char* title, const char* pass, int limit, bool pub) -{ +int chat_createpcchat(struct map_session_data* sd, const char* title, const char* pass, int limit, bool pub) { struct chat_data* cd; nullpo_ret(sd); @@ -81,8 +80,7 @@ int chat_createpcchat(struct map_session_data* sd, const char* title, const char return 0; } - if( map[sd->bl.m].flag.nochat ) - { + if( maplist[sd->bl.m].flag.nochat ) { clif->message(sd->fd, msg_txt(281)); return 0; //Can't create chatrooms on this map. } diff --git a/src/map/clif.c b/src/map/clif.c index 488e2cf0f..e85f1131f 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -1252,31 +1252,23 @@ void clif_weather_check(struct map_session_data *sd) { int16 m = sd->bl.m; int fd = sd->fd; - if (map[m].flag.snow - || map[m].flag.clouds - || map[m].flag.fog - || map[m].flag.fireworks - || map[m].flag.sakura - || map[m].flag.leaves - || map[m].flag.clouds2) { - if (map[m].flag.snow) - clif->specialeffect_single(&sd->bl, 162, fd); - if (map[m].flag.clouds) - clif->specialeffect_single(&sd->bl, 233, fd); - if (map[m].flag.clouds2) - clif->specialeffect_single(&sd->bl, 516, fd); - if (map[m].flag.fog) - clif->specialeffect_single(&sd->bl, 515, fd); - if (map[m].flag.fireworks) { - clif->specialeffect_single(&sd->bl, 297, fd); - clif->specialeffect_single(&sd->bl, 299, fd); - clif->specialeffect_single(&sd->bl, 301, fd); - } - if (map[m].flag.sakura) - clif->specialeffect_single(&sd->bl, 163, fd); - if (map[m].flag.leaves) - clif->specialeffect_single(&sd->bl, 333, fd); - } + if (maplist[m].flag.snow) + clif->specialeffect_single(&sd->bl, 162, fd); + if (maplist[m].flag.clouds) + clif->specialeffect_single(&sd->bl, 233, fd); + if (maplist[m].flag.clouds2) + clif->specialeffect_single(&sd->bl, 516, fd); + if (maplist[m].flag.fog) + clif->specialeffect_single(&sd->bl, 515, fd); + if (maplist[m].flag.fireworks) { + clif->specialeffect_single(&sd->bl, 297, fd); + clif->specialeffect_single(&sd->bl, 299, fd); + clif->specialeffect_single(&sd->bl, 301, fd); + } + if (maplist[m].flag.sakura) + clif->specialeffect_single(&sd->bl, 163, fd); + if (maplist[m].flag.leaves) + clif->specialeffect_single(&sd->bl, 333, fd); } /** * Run when the weather on a map changes, throws all players in map id 'm' to clif_weather_check function @@ -1328,7 +1320,7 @@ int clif_spawn(struct block_list *bl) clif->specialeffect(bl,423,AREA); else if(sd->state.size==SZ_MEDIUM) clif->specialeffect(bl,421,AREA); - if( sd->bg_id && map[sd->bl.m].flag.battleground ) + if( sd->bg_id && maplist[sd->bl.m].flag.battleground ) clif->sendbgemblem_area(sd); for( i = 0; i < sd->sc_display_count; i++ ) { clif->sc_load(&sd->bl, sd->bl.id,AREA,StatusIconChangeTable[sd->sc_display[i]->type],sd->sc_display[i]->val1,sd->sc_display[i]->val2,sd->sc_display[i]->val3); @@ -1647,7 +1639,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[m].custom_name ? map[map[m].instance_src_map].name : map[m].name, (char*)WFIFOP(fd,2)); + mapindex_getmapname_ext(maplist[m].custom_name ? maplist[maplist[m].instance_src_map].name : maplist[m].name, (char*)WFIFOP(fd,2)); WFIFOW(fd,18) = x; WFIFOW(fd,20) = y; WFIFOSET(fd,packet_len(0x91)); @@ -4344,7 +4336,7 @@ void clif_getareachar_unit(struct map_session_data* sd,struct block_list *bl) { clif->specialeffect_single(bl,423,sd->fd); else if(tsd->state.size==SZ_MEDIUM) clif->specialeffect_single(bl,421,sd->fd); - if( tsd->bg_id && map[tsd->bl.m].flag.battleground ) + if( tsd->bg_id && maplist[tsd->bl.m].flag.battleground ) clif->sendbgemblem_single(sd->fd,tsd); if ( tsd->status.robe ) clif->refreshlook(&sd->bl,bl->id,LOOK_ROBE,tsd->status.robe,SELF); @@ -4586,7 +4578,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[m].custom_name ? map[map[m].instance_src_map].name : map[m].name,(char*)WBUFP(buf,8)); + mapindex_getmapname_ext(maplist[m].custom_name ? maplist[maplist[m].instance_src_map].name : maplist[m].name,(char*)WBUFP(buf,8)); if( fd ) { WFIFOHEAD(fd,packet_len(0x192)); @@ -5887,14 +5879,14 @@ void clif_pvpset(struct map_session_data *sd,int pvprank,int pvpnum,int type) /*========================================== * *------------------------------------------*/ -void clif_map_property_mapall(int map, enum map_property property) +void clif_map_property_mapall(int mapid, enum map_property property) { struct block_list bl; unsigned char buf[16]; bl.id = 0; bl.type = BL_NUL; - bl.m = map; + bl.m = mapid; WBUFW(buf,0)=0x199; WBUFW(buf,2)=property; clif->send(buf,packet_len(0x199),&bl,ALL_SAMEMAP); @@ -6540,7 +6532,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[sd->bl.m].custom_name ? map[map[sd->bl.m].instance_src_map].name : map[sd->bl.m].name, (char*)WBUFP(buf,63)); + mapindex_getmapname_ext(maplist[sd->bl.m].custom_name ? maplist[maplist[sd->bl.m].instance_src_map].name : maplist[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); @@ -9308,24 +9300,24 @@ void clif_parse_WantToConnection(int fd, struct map_session_data* sd) { chrif->authreq(sd); } void clif_hercules_chsys_mjoin(struct map_session_data *sd) { - if( !map[sd->bl.m].channel ) { - CREATE(map[sd->bl.m].channel, struct hChSysCh , 1); - safestrncpy(map[sd->bl.m].channel->name, hChSys.local_name, HCHSYS_NAME_LENGTH); - map[sd->bl.m].channel->type = hChSys_MAP; - map[sd->bl.m].channel->m = sd->bl.m; + if( !maplist[sd->bl.m].channel ) { + CREATE(maplist[sd->bl.m].channel, struct hChSysCh , 1); + safestrncpy(maplist[sd->bl.m].channel->name, hChSys.local_name, HCHSYS_NAME_LENGTH); + maplist[sd->bl.m].channel->type = hChSys_MAP; + maplist[sd->bl.m].channel->m = sd->bl.m; - clif->chsys_create(map[sd->bl.m].channel,NULL,NULL,hChSys.local_color); + clif->chsys_create(maplist[sd->bl.m].channel,NULL,NULL,hChSys.local_color); } - if( map[sd->bl.m].channel->banned && idb_exists(map[sd->bl.m].channel->banned, sd->status.account_id) ) { + if( maplist[sd->bl.m].channel->banned && idb_exists(maplist[sd->bl.m].channel->banned, sd->status.account_id) ) { return; } - clif->chsys_join(map[sd->bl.m].channel,sd); + clif->chsys_join(maplist[sd->bl.m].channel,sd); - if( !( map[sd->bl.m].channel->opt & hChSys_OPT_ANNOUNCE_JOIN ) ) { + if( !( maplist[sd->bl.m].channel->opt & hChSys_OPT_ANNOUNCE_JOIN ) ) { char mout[60]; - sprintf(mout, msg_txt(1435),hChSys.local_name,map[sd->bl.m].name); // You're now in the '#%s' channel for '%s' + sprintf(mout, msg_txt(1435),hChSys.local_name,maplist[sd->bl.m].name); // You're now in the '#%s' channel for '%s' clif->colormes(sd->fd, COLOR_DEFAULT, mout); } } @@ -9384,14 +9376,14 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { pc->setinvincibletimer(sd,battle_config.pc_invincible_time); } - if( map[sd->bl.m].users++ == 0 && battle_config.dynamic_mobs ) + if( maplist[sd->bl.m].users++ == 0 && battle_config.dynamic_mobs ) iMap->spawnmobs(sd->bl.m); if( !(sd->sc.option&OPTION_INVISIBLE) ) { // increment the number of pvp players on the map - map[sd->bl.m].users_pvp++; + maplist[sd->bl.m].users_pvp++; } - if( map[sd->bl.m].instance_id >= 0 ) { - instances[map[sd->bl.m].instance_id].users++; - instance->check_idle(map[sd->bl.m].instance_id); + if( maplist[sd->bl.m].instance_id >= 0 ) { + instances[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] @@ -9410,9 +9402,9 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { if( sd->bg_id ) clif->bg_hp(sd); // BattleGround System - if(map[sd->bl.m].flag.pvp && !(sd->sc.option&OPTION_INVISIBLE)) { + if(maplist[sd->bl.m].flag.pvp && !(sd->sc.option&OPTION_INVISIBLE)) { if(!battle_config.pk_mode) { // remove pvp stuff for pk_mode [Valaris] - if (!map[sd->bl.m].flag.pvp_nocalcrank) + if (!maplist[sd->bl.m].flag.pvp_nocalcrank) sd->pvp_timer = timer->add(timer->gettick()+200, pc->calc_pvprank_timer, sd->bl.id, 0); sd->pvp_rank = 0; sd->pvp_lastusers = 0; @@ -9426,7 +9418,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { if(sd->duel_group) clif->map_property(sd, MAPPROPERTY_FREEPVPZONE); - if (map[sd->bl.m].flag.gvg_dungeon) + if (maplist[sd->bl.m].flag.gvg_dungeon) clif->map_property(sd, MAPPROPERTY_FREEPVPZONE); //TODO: Figure out the real packet to send here. if( map_flag_gvg2(sd->bl.m) ) @@ -9518,7 +9510,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { if(homun_alive(sd->hd)) homun->init_timers(sd->hd); - if (iMap->night_flag && map[sd->bl.m].flag.nightenabled) { + if (iMap->night_flag && maplist[sd->bl.m].flag.nightenabled) { sd->state.night = 1; clif->status_change(&sd->bl, SI_SKE, 1, 0, 0, 0, 0); } @@ -9554,11 +9546,12 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { clif->partyinvitationstate(sd); clif->equpcheckbox(sd); #endif - if( (battle_config.bg_flee_penalty != 100 || battle_config.gvg_flee_penalty != 100) && - (map_flag_gvg2(sd->state.pmap) || map_flag_gvg2(sd->bl.m) || map[sd->state.pmap].flag.battleground || map[sd->bl.m].flag.battleground) ) + if( (battle_config.bg_flee_penalty != 100 || battle_config.gvg_flee_penalty != 100) + && (map_flag_gvg2(sd->state.pmap) || map_flag_gvg2(sd->bl.m) + || maplist[sd->state.pmap].flag.battleground || maplist[sd->bl.m].flag.battleground) ) status_calc_bl(&sd->bl, SCB_FLEE); //Refresh flee penalty - if( iMap->night_flag && map[sd->bl.m].flag.nightenabled ) { //Display night. + if( iMap->night_flag && maplist[sd->bl.m].flag.nightenabled ) { //Display night. if( !sd->state.night ) { sd->state.night = 1; clif->status_change(&sd->bl, SI_SKE, 1, 0, 0, 0, 0); @@ -9568,13 +9561,13 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { clif->sc_end(&sd->bl, sd->bl.id, SELF, SI_SKE); } - if( map[sd->bl.m].flag.battleground ) { + if( maplist[sd->bl.m].flag.battleground ) { clif->map_type(sd, MAPTYPE_BATTLEFIELD); // Battleground Mode - if( map[sd->bl.m].flag.battleground == 2 ) + if( maplist[sd->bl.m].flag.battleground == 2 ) clif->bg_updatescore_single(sd); } - if( map[sd->bl.m].flag.allowks && !map_flag_ks(sd->bl.m) ) { + if( maplist[sd->bl.m].flag.allowks && !map_flag_ks(sd->bl.m) ) { char output[128]; sprintf(output, "[ Kill Steal Protection Disabled. KS is allowed in this map ]"); clif->broadcast(&sd->bl, output, strlen(output) + 1, BC_BLUE, SELF); @@ -9584,7 +9577,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { status_calc_pc(sd, false);/* some conditions are map-dependent so we must recalculate */ sd->state.changemap = false; - if( hChSys.local && hChSys.local_autojoin && !map[sd->bl.m].flag.chsysnolocalaj ) { + if( hChSys.local && hChSys.local_autojoin && !maplist[sd->bl.m].flag.chsysnolocalaj ) { clif->chsys_mjoin(sd); } } @@ -9606,7 +9599,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { clif->showvendingboard(&sd->bl,sd->message,0); } - if(map[sd->bl.m].flag.loadevent) // Lance + if(maplist[sd->bl.m].flag.loadevent) // Lance npc->script_event(sd, NPCE_LOADMAP); if (pc->checkskill(sd, SG_DEVIL) && !pc->nextjobexp(sd)) //blindness [Komurka] @@ -10437,10 +10430,10 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd) chname++; if( hChSys.local && strcmpi(chname, hChSys.local_name) == 0 ) { - if( !map[sd->bl.m].channel ) { + if( !maplist[sd->bl.m].channel ) { clif->chsys_mjoin(sd); } - channel = map[sd->bl.m].channel; + channel = maplist[sd->bl.m].channel; } else if( hChSys.ally && sd->status.guild_id && strcmpi(chname, hChSys.ally_name) == 0 ) { struct guild *g = sd->guild; if( !g ) return; @@ -10722,7 +10715,7 @@ void clif_hercules_chsys_delete(struct hChSysCh *channel) { } db_destroy(channel->users); if( channel->m ) { - map[channel->m].channel = NULL; + maplist[channel->m].channel = NULL; aFree(channel); } else if ( channel->type == hChSys_ALLY ) aFree(channel); @@ -12021,12 +12014,12 @@ void clif_storagepassword_result(struct map_session_data* sd, short result, shor /// Party creation request /// 00f9 <party name>.24B (CZ_MAKE_GROUP) /// 01e8 <party name>.24B <item pickup rule>.B <item share rule>.B (CZ_MAKE_GROUP2) -void clif_parse_CreateParty(int fd, struct map_session_data *sd) -{ +void clif_parse_CreateParty(int fd, struct map_session_data *sd) { char* name = (char*)RFIFOP(fd,2); name[NAME_LENGTH-1] = '\0'; - if( map[sd->bl.m].flag.partylock ) { // Party locked. + if( maplist[sd->bl.m].flag.partylock ) { + // Party locked. clif->message(fd, msg_txt(227)); return; } @@ -12038,14 +12031,14 @@ void clif_parse_CreateParty(int fd, struct map_session_data *sd) party->create(sd,name,0,0); } -void clif_parse_CreateParty2(int fd, struct map_session_data *sd) -{ +void clif_parse_CreateParty2(int fd, struct map_session_data *sd) { char* name = (char*)RFIFOP(fd,2); int item1 = RFIFOB(fd,26); int item2 = RFIFOB(fd,27); name[NAME_LENGTH-1] = '\0'; - if( map[sd->bl.m].flag.partylock ) {// Party locked. + if( maplist[sd->bl.m].flag.partylock ) { + // Party locked. clif->message(fd, msg_txt(227)); return; } @@ -12061,11 +12054,11 @@ void clif_parse_CreateParty2(int fd, struct map_session_data *sd) /// Party invitation request /// 00fc <account id>.L (CZ_REQ_JOIN_GROUP) /// 02c4 <char name>.24B (CZ_PARTY_JOIN_REQ) -void clif_parse_PartyInvite(int fd, struct map_session_data *sd) -{ +void clif_parse_PartyInvite(int fd, struct map_session_data *sd) { struct map_session_data *t_sd; - if(map[sd->bl.m].flag.partylock) {// Party locked. + if(maplist[sd->bl.m].flag.partylock) { + // Party locked. clif->message(fd, msg_txt(227)); return; } @@ -12080,13 +12073,13 @@ void clif_parse_PartyInvite(int fd, struct map_session_data *sd) party->invite(sd, t_sd); } -void clif_parse_PartyInvite2(int fd, struct map_session_data *sd) -{ +void clif_parse_PartyInvite2(int fd, struct map_session_data *sd) { struct map_session_data *t_sd; char *name = (char*)RFIFOP(fd,2); name[NAME_LENGTH-1] = '\0'; - if(map[sd->bl.m].flag.partylock) { // Party locked. + if(maplist[sd->bl.m].flag.partylock) { + // Party locked. clif->message(fd, msg_txt(227)); return; } @@ -12121,9 +12114,9 @@ void clif_parse_ReplyPartyInvite2(int fd,struct map_session_data *sd) /// Request to leave party (CZ_REQ_LEAVE_GROUP). /// 0100 -void clif_parse_LeaveParty(int fd, struct map_session_data *sd) -{ - if(map[sd->bl.m].flag.partylock) { //Guild locked. +void clif_parse_LeaveParty(int fd, struct map_session_data *sd) { + if(maplist[sd->bl.m].flag.partylock) { + // Party locked. clif->message(fd, msg_txt(227)); return; } @@ -12133,9 +12126,9 @@ void clif_parse_LeaveParty(int fd, struct map_session_data *sd) /// Request to expel a party member (CZ_REQ_EXPEL_GROUP_MEMBER). /// 0103 <account id>.L <char name>.24B -void clif_parse_RemovePartyMember(int fd, struct map_session_data *sd) -{ - if(map[sd->bl.m].flag.partylock) { //Guild locked. +void clif_parse_RemovePartyMember(int fd, struct map_session_data *sd) { + if(maplist[sd->bl.m].flag.partylock) { + // Party locked. clif->message(fd, msg_txt(227)); return; } @@ -12745,8 +12738,7 @@ void clif_parse_PurchaseReq2(int fd, struct map_session_data* sd) /// result: /// 0 = canceled /// 1 = open -void clif_parse_OpenVending(int fd, struct map_session_data* sd) -{ +void clif_parse_OpenVending(int fd, struct map_session_data* sd) { short len = (short)RFIFOW(fd,2) - 85; const char* message = (char*)RFIFOP(fd,4); bool flag = (bool)RFIFOB(fd,84); @@ -12757,7 +12749,7 @@ void clif_parse_OpenVending(int fd, struct map_session_data* sd) if( sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOROOM ) return; - if( map[sd->bl.m].flag.novending ) { + if( maplist[sd->bl.m].flag.novending ) { clif->message (sd->fd, msg_txt(276)); // "You can't open a shop on this map" return; } @@ -12774,12 +12766,12 @@ void clif_parse_OpenVending(int fd, struct map_session_data* sd) /// Guild creation request (CZ_REQ_MAKE_GUILD). /// 0165 <char id>.L <guild name>.24B -void clif_parse_CreateGuild(int fd,struct map_session_data *sd) -{ +void clif_parse_CreateGuild(int fd,struct map_session_data *sd) { char* name = (char*)RFIFOP(fd,6); name[NAME_LENGTH-1] = '\0'; - if(map[sd->bl.m].flag.guildlock) { //Guild locked. + if(maplist[sd->bl.m].flag.guildlock) { + //Guild locked. clif->message(fd, msg_txt(228)); return; } @@ -12941,7 +12933,8 @@ clif_sub_guild_invite(int fd, struct map_session_data *sd, struct map_session_da return 1; } - if (map[sd->bl.m].flag.guildlock) { //Guild locked. + if (maplist[sd->bl.m].flag.guildlock) { + //Guild locked. clif->message(fd, msg_txt(228)); return 1; } @@ -12988,9 +12981,9 @@ void clif_parse_GuildReplyInvite(int fd,struct map_session_data *sd) /// Request to leave guild (CZ_REQ_LEAVE_GUILD). /// 0159 <guild id>.L <account id>.L <char id>.L <reason>.40B -void clif_parse_GuildLeave(int fd,struct map_session_data *sd) -{ - if(map[sd->bl.m].flag.guildlock) { //Guild locked. +void clif_parse_GuildLeave(int fd,struct map_session_data *sd) { + if(maplist[sd->bl.m].flag.guildlock) { + //Guild locked. clif->message(fd, msg_txt(228)); return; } @@ -13005,9 +12998,9 @@ void clif_parse_GuildLeave(int fd,struct map_session_data *sd) /// Request to expel a member of a guild (CZ_REQ_BAN_GUILD). /// 015b <guild id>.L <account id>.L <char id>.L <reason>.40B -void clif_parse_GuildExpulsion(int fd,struct map_session_data *sd) -{ - if( map[sd->bl.m].flag.guildlock || sd->bg_id ) { // Guild locked. +void clif_parse_GuildExpulsion(int fd,struct map_session_data *sd) { + if( maplist[sd->bl.m].flag.guildlock || sd->bg_id ) { + // Guild locked. clif->message(fd, msg_txt(228)); return; } @@ -13051,14 +13044,14 @@ void clif_parse_GuildMessage(int fd, struct map_session_data* sd) /// Guild alliance request (CZ_REQ_ALLY_GUILD). /// 0170 <account id>.L <inviter account id>.L <inviter char id>.L -void clif_parse_GuildRequestAlliance(int fd, struct map_session_data *sd) -{ +void clif_parse_GuildRequestAlliance(int fd, struct map_session_data *sd) { struct map_session_data *t_sd; if(!sd->state.gmaster_flag) return; - if(map[sd->bl.m].flag.guildlock) { //Guild locked. + if(maplist[sd->bl.m].flag.guildlock) { + //Guild locked. clif->message(fd, msg_txt(228)); return; } @@ -13091,12 +13084,12 @@ void clif_parse_GuildReplyAlliance(int fd, struct map_session_data *sd) /// relation: /// 0 = Ally /// 1 = Enemy -void clif_parse_GuildDelAlliance(int fd, struct map_session_data *sd) -{ +void clif_parse_GuildDelAlliance(int fd, struct map_session_data *sd) { if(!sd->state.gmaster_flag) return; - if(map[sd->bl.m].flag.guildlock) { //Guild locked. + if(maplist[sd->bl.m].flag.guildlock) { + //Guild locked. clif->message(fd, msg_txt(228)); return; } @@ -13106,14 +13099,14 @@ void clif_parse_GuildDelAlliance(int fd, struct map_session_data *sd) /// Request to set a guild as opposition (CZ_REQ_HOSTILE_GUILD). /// 0180 <account id>.L -void clif_parse_GuildOpposition(int fd, struct map_session_data *sd) -{ +void clif_parse_GuildOpposition(int fd, struct map_session_data *sd) { struct map_session_data *t_sd; if(!sd->state.gmaster_flag) return; - if(map[sd->bl.m].flag.guildlock) { //Guild locked. + if(maplist[sd->bl.m].flag.guildlock) { + //Guild locked. clif->message(fd, msg_txt(228)); return; } @@ -13135,9 +13128,9 @@ void clif_parse_GuildOpposition(int fd, struct map_session_data *sd) /// key: /// now guild name; might have been (intended) email, since the /// field name and size is same as the one in CH_DELETE_CHAR. -void clif_parse_GuildBreak(int fd, struct map_session_data *sd) -{ - if( map[sd->bl.m].flag.guildlock ) { //Guild locked. +void clif_parse_GuildBreak(int fd, struct map_session_data *sd) { + if( maplist[sd->bl.m].flag.guildlock ) { + //Guild locked. clif->message(fd, msg_txt(228)); return; } @@ -15987,8 +15980,7 @@ void clif_parse_BattleChat(int fd, struct map_session_data* sd) /// Notifies client of a battleground score change (ZC_BATTLEFIELD_NOTIFY_POINT). /// 02de <camp A points>.W <camp B points>.W -void clif_bg_updatescore(int16 m) -{ +void clif_bg_updatescore(int16 m) { struct block_list bl; unsigned char buf[6]; @@ -15997,21 +15989,20 @@ void clif_bg_updatescore(int16 m) bl.m = m; WBUFW(buf,0) = 0x2de; - WBUFW(buf,2) = map[m].bgscore_lion; - WBUFW(buf,4) = map[m].bgscore_eagle; + WBUFW(buf,2) = maplist[m].bgscore_lion; + WBUFW(buf,4) = maplist[m].bgscore_eagle; clif->send(buf,packet_len(0x2de),&bl,ALL_SAMEMAP); } -void clif_bg_updatescore_single(struct map_session_data *sd) -{ +void clif_bg_updatescore_single(struct map_session_data *sd) { int fd; nullpo_retv(sd); fd = sd->fd; WFIFOHEAD(fd,packet_len(0x2de)); WFIFOW(fd,0) = 0x2de; - WFIFOW(fd,2) = map[sd->bl.m].bgscore_lion; - WFIFOW(fd,4) = map[sd->bl.m].bgscore_eagle; + WFIFOW(fd,2) = maplist[sd->bl.m].bgscore_lion; + WFIFOW(fd,4) = maplist[sd->bl.m].bgscore_eagle; WFIFOSET(fd,packet_len(0x2de)); } @@ -17412,11 +17403,11 @@ void clif_maptypeproperty2(struct block_list *bl,enum send_target t) { p.flag.siege = map_flag_gvg2(bl->m) ? 1: 0; p.flag.mineffect = 1; p.flag.nolockon = 1; - p.flag.countpk = map[bl->m].flag.pvp ? 1 : 0; + p.flag.countpk = maplist[bl->m].flag.pvp ? 1 : 0; p.flag.nopartyformation = 0; p.flag.noitemconsumption = 1; p.flag.summonstarmiracle = 1; - p.flag.bg = map[bl->m].flag.battleground ? 1 : 0; + p.flag.bg = maplist[bl->m].flag.battleground ? 1 : 0; clif->send(&p,sizeof(p),bl,t); #endif diff --git a/src/map/clif.h b/src/map/clif.h index e9bef2629..1e054db1d 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -563,7 +563,7 @@ struct clif_interface { void (*changemapcell) (int fd, int16 m, int x, int y, int type, enum send_target target); void (*map_property) (struct map_session_data* sd, enum map_property property); void (*pvpset) (struct map_session_data *sd, int pvprank, int pvpnum,int type); - void (*map_property_mapall) (int map, enum map_property property); + void (*map_property_mapall) (int mapid, enum map_property property); void (*bossmapinfo) (int fd, struct mob_data *md, short flag); void (*map_type) (struct map_session_data* sd, enum map_type type); void (*maptypeproperty2) (struct block_list *bl,enum send_target t); diff --git a/src/map/guild.c b/src/map/guild.c index b6dde5700..8319d4524 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -661,15 +661,16 @@ int guild_invite(struct map_session_data *sd, struct map_session_data *tsd) { return 0; } - if(tsd->status.guild_id>0 || - tsd->guild_invite>0 || - ((iMap->agit_flag || iMap->agit2_flag) && map[tsd->bl.m].flag.gvg_castle)) - { //Can't invite people inside castles. [Skotlex] + if( tsd->status.guild_id > 0 + || tsd->guild_invite > 0 + || ((iMap->agit_flag || iMap->agit2_flag) && maplist[tsd->bl.m].flag.gvg_castle) + ) { + //Can't invite people inside castles. [Skotlex] clif->guild_inviteack(sd,0); return 0; } - //search an empty spot in guild + //search an empty spot in guild ARR_FIND( 0, g->max_member, i, g->member[i].account_id == 0 ); if(i==g->max_member){ clif->guild_inviteack(sd,3); @@ -846,9 +847,11 @@ int guild_leave(struct map_session_data* sd, int guild_id, int account_id, int c if(g==NULL) return 0; - if(sd->status.account_id!=account_id || - sd->status.char_id!=char_id || sd->status.guild_id!=guild_id || - ((iMap->agit_flag || iMap->agit2_flag) && map[sd->bl.m].flag.gvg_castle)) + if( sd->status.account_id != account_id + || sd->status.char_id != char_id + || sd->status.guild_id != guild_id + || ((iMap->agit_flag || iMap->agit2_flag) && maplist[sd->bl.m].flag.gvg_castle) + ) return 0; intif->guild_leave(sd->status.guild_id, sd->status.account_id, sd->status.char_id,0,mes); @@ -878,9 +881,10 @@ int guild_expulsion(struct map_session_data* sd, int guild_id, int account_id, i return 0; //Expulsion permission //Can't leave inside guild castles. - if ((tsd = iMap->id2sd(account_id)) && - tsd->status.char_id == char_id && - ((iMap->agit_flag || iMap->agit2_flag) && map[tsd->bl.m].flag.gvg_castle)) + if ((tsd = iMap->id2sd(account_id)) + && tsd->status.char_id == char_id + && ((iMap->agit_flag || iMap->agit2_flag) && maplist[tsd->bl.m].flag.gvg_castle) + ) return 0; // find the member and perform expulsion diff --git a/src/map/instance.c b/src/map/instance.c index 476a4d0e3..548a34b1d 100644 --- a/src/map/instance.c +++ b/src/map/instance.c @@ -159,94 +159,95 @@ int instance_add_map(const char *name, int instance_id, bool usebasename, const return -2; } - if( map[m].instance_id >= 0 ) { // Source map already belong to a Instance. + if( maplist[m].instance_id >= 0 ) { + // Source map already belong to a Instance. ShowError("instance_add_map: trying to instance already instanced map %s.\n", name); return -4; } - ARR_FIND( instance->start_id, iMap->map_num, i, map[i].name[0] == 0 ); // Searching for a Free Map + ARR_FIND( instance->start_id, iMap->map_num, i, maplist[i].name[0] == 0 ); // Searching for a Free Map if( i < iMap->map_num ) im = i; // Unused map found (old instance) else { im = iMap->map_num; // Using next map index - RECREATE(map,struct map_data,++iMap->map_num); + RECREATE(maplist,struct map_data,++iMap->map_num); } - if( map[m].cell == (struct mapcell *)0xdeadbeaf ) - iMap->cellfromcache(&map[m]); + if( maplist[m].cell == (struct mapcell *)0xdeadbeaf ) + iMap->cellfromcache(&maplist[m]); - memcpy( &map[im], &map[m], sizeof(struct map_data) ); // Copy source map + memcpy( &maplist[im], &maplist[m], sizeof(struct map_data) ); // Copy source map if( map_name != NULL ) { - snprintf(map[im].name, MAP_NAME_LENGTH, "%s", map_name); - map[im].custom_name = true; + snprintf(maplist[im].name, MAP_NAME_LENGTH, "%s", map_name); + maplist[im].custom_name = true; } else - snprintf(map[im].name, MAP_NAME_LENGTH, (usebasename ? "%.3d#%s" : "%.3d%s"), instance_id, name); // Generate Name for Instance Map - map[im].index = mapindex_addmap(-1, map[im].name); // Add map index + snprintf(maplist[im].name, MAP_NAME_LENGTH, (usebasename ? "%.3d#%s" : "%.3d%s"), instance_id, name); // Generate Name for Instance Map + maplist[im].index = mapindex_addmap(-1, maplist[im].name); // Add map index - map[im].channel = NULL; + maplist[im].channel = NULL; - if( !map[im].index ) { - map[im].name[0] = '\0'; + if( !maplist[im].index ) { + maplist[im].name[0] = '\0'; ShowError("instance_add_map: no more free map indexes.\n"); return -3; // No free map index } // Reallocate cells - num_cell = map[im].xs * map[im].ys; - CREATE( map[im].cell, struct mapcell, num_cell ); - memcpy( map[im].cell, map[m].cell, num_cell * sizeof(struct mapcell) ); + num_cell = maplist[im].xs * maplist[im].ys; + CREATE( maplist[im].cell, struct mapcell, num_cell ); + memcpy( maplist[im].cell, maplist[m].cell, num_cell * sizeof(struct mapcell) ); - size = map[im].bxs * map[im].bys * sizeof(struct block_list*); - map[im].block = (struct block_list**)aCalloc(size, 1); - map[im].block_mob = (struct block_list**)aCalloc(size, 1); + size = maplist[im].bxs * maplist[im].bys * sizeof(struct block_list*); + maplist[im].block = (struct block_list**)aCalloc(size, 1); + maplist[im].block_mob = (struct block_list**)aCalloc(size, 1); - memset(map[im].npc, 0x00, sizeof(map[i].npc)); - map[im].npc_num = 0; + memset(maplist[im].npc, 0x00, sizeof(maplist[i].npc)); + maplist[im].npc_num = 0; - memset(map[im].moblist, 0x00, sizeof(map[im].moblist)); - map[im].mob_delete_timer = INVALID_TIMER; + memset(maplist[im].moblist, 0x00, sizeof(maplist[im].moblist)); + maplist[im].mob_delete_timer = INVALID_TIMER; //Mimic unit - if( map[m].unit_count ) { - map[im].unit_count = map[m].unit_count; - CREATE( map[im].units, struct mapflag_skill_adjust*, map[im].unit_count ); + if( maplist[m].unit_count ) { + maplist[im].unit_count = maplist[m].unit_count; + CREATE( maplist[im].units, struct mapflag_skill_adjust*, maplist[im].unit_count ); - for(i = 0; i < map[im].unit_count; i++) { - CREATE( map[im].units[i], struct mapflag_skill_adjust, 1); - memcpy( map[im].units[i],map[m].units[i],sizeof(struct mapflag_skill_adjust)); + for(i = 0; i < maplist[im].unit_count; i++) { + CREATE( maplist[im].units[i], struct mapflag_skill_adjust, 1); + memcpy( maplist[im].units[i],maplist[m].units[i],sizeof(struct mapflag_skill_adjust)); } } //Mimic skills - if( map[m].skill_count ) { - map[im].skill_count = map[m].skill_count; - CREATE( map[im].skills, struct mapflag_skill_adjust*, map[im].skill_count ); + if( maplist[m].skill_count ) { + maplist[im].skill_count = maplist[m].skill_count; + CREATE( maplist[im].skills, struct mapflag_skill_adjust*, maplist[im].skill_count ); - for(i = 0; i < map[im].skill_count; i++) { - CREATE( map[im].skills[i], struct mapflag_skill_adjust, 1); - memcpy( map[im].skills[i],map[m].skills[i],sizeof(struct mapflag_skill_adjust)); + for(i = 0; i < maplist[im].skill_count; i++) { + CREATE( maplist[im].skills[i], struct mapflag_skill_adjust, 1); + memcpy( maplist[im].skills[i],maplist[m].skills[i],sizeof(struct mapflag_skill_adjust)); } } //Mimic zone mf - if( map[m].zone_mf_count ) { - map[im].zone_mf_count = map[m].zone_mf_count; - CREATE( map[im].zone_mf, char *, map[im].zone_mf_count ); + if( maplist[m].zone_mf_count ) { + maplist[im].zone_mf_count = maplist[m].zone_mf_count; + CREATE( maplist[im].zone_mf, char *, maplist[im].zone_mf_count ); - for(i = 0; i < map[im].zone_mf_count; i++) { - CREATE(map[im].zone_mf[i], char, MAP_ZONE_MAPFLAG_LENGTH); - safestrncpy(map[im].zone_mf[i],map[m].zone_mf[i],MAP_ZONE_MAPFLAG_LENGTH); + for(i = 0; i < maplist[im].zone_mf_count; i++) { + CREATE(maplist[im].zone_mf[i], char, MAP_ZONE_MAPFLAG_LENGTH); + safestrncpy(maplist[im].zone_mf[i],maplist[m].zone_mf[i],MAP_ZONE_MAPFLAG_LENGTH); } } - map[im].m = im; - map[im].instance_id = instance_id; - map[im].instance_src_map = m; - map[m].flag.src4instance = 1; // Flag this map as a src map for instances + maplist[im].m = im; + maplist[im].instance_id = instance_id; + maplist[im].instance_src_map = m; + maplist[m].flag.src4instance = 1; // Flag this map as a src map for instances RECREATE(instances[instance_id].map, unsigned short, ++instances[instance_id].num_map); instances[instance_id].map[instances[instance_id].num_map - 1] = im; // Attach to actual instance - iMap->addmap2db(&map[im]); + iMap->addmap2db(&maplist[im]); return im; } @@ -264,7 +265,7 @@ int instance_map2imap(int16 m, int instance_id) { } for( i = 0; i < instances[instance_id].num_map; i++ ) { - if( instances[instance_id].map[i] && map[instances[instance_id].map[i]].instance_src_map == m ) + if( instances[instance_id].map[i] && maplist[instances[instance_id].map[i]].instance_src_map == m ) return instances[instance_id].map[i]; } return -1; @@ -276,9 +277,9 @@ int instance_map2imap(int16 m, int instance_id) { * result : mapid of map "m" in this instance *--------------------------------------*/ int instance_mapid2imapid(int16 m, int instance_id) { - if( map[m].flag.src4instance == 0 ) + if( maplist[m].flag.src4instance == 0 ) return m; // not instances found for this map - else if( map[m].instance_id >= 0 ) { // This map is a instance, not a src map instance + else if( maplist[m].instance_id >= 0 ) { // This map is a instance, not a src map instance ShowError("map_instance_mapid2imapid: already instanced (%d / %d)\n", m, instance_id); return -1; } @@ -313,7 +314,7 @@ void instance_init(int instance_id) { return; // nothing to do for( i = 0; i < instances[instance_id].num_map; i++ ) - iMap->foreachinmap(instance_map_npcsub, map[instances[instance_id].map[i]].instance_src_map, BL_NPC, instances[instance_id].map[i]); + iMap->foreachinmap(instance_map_npcsub, maplist[instances[instance_id].map[i]].instance_src_map, BL_NPC, instances[instance_id].map[i]); instances[instance_id].state = INSTANCE_BUSY; } @@ -366,7 +367,7 @@ int instance_cleanup_sub(struct block_list *bl, va_list ap) { void instance_del_map(int16 m) { int i; - if( m <= 0 || map[m].instance_id == -1 ) { + if( m <= 0 || maplist[m].instance_id == -1 ) { ShowError("instance_del_map: tried to remove non-existing instance map (%d)\n", m); return; } @@ -374,62 +375,62 @@ void instance_del_map(int16 m) { iMap->map_foreachpc(instance_del_load, m); iMap->foreachinmap(instance_cleanup_sub, m, BL_ALL); - if( map[m].mob_delete_timer != INVALID_TIMER ) - timer->delete(map[m].mob_delete_timer, iMap->removemobs_timer); + if( maplist[m].mob_delete_timer != INVALID_TIMER ) + timer->delete(maplist[m].mob_delete_timer, iMap->removemobs_timer); mapindex_removemap(map_id2index(m)); // Free memory - aFree(map[m].cell); - aFree(map[m].block); - aFree(map[m].block_mob); + aFree(maplist[m].cell); + aFree(maplist[m].block); + aFree(maplist[m].block_mob); - if( map[m].unit_count ) { - for(i = 0; i < map[m].unit_count; i++) { - aFree(map[m].units[i]); + if( maplist[m].unit_count ) { + for(i = 0; i < maplist[m].unit_count; i++) { + aFree(maplist[m].units[i]); } - if( map[m].units ) - aFree(map[m].units); + if( maplist[m].units ) + aFree(maplist[m].units); } - if( map[m].skill_count ) { - for(i = 0; i < map[m].skill_count; i++) { - aFree(map[m].skills[i]); + if( maplist[m].skill_count ) { + for(i = 0; i < maplist[m].skill_count; i++) { + aFree(maplist[m].skills[i]); } - if( map[m].skills ) - aFree(map[m].skills); + if( maplist[m].skills ) + aFree(maplist[m].skills); } - if( map[m].zone_mf_count ) { - for(i = 0; i < map[m].zone_mf_count; i++) { - aFree(map[m].zone_mf[i]); + if( maplist[m].zone_mf_count ) { + for(i = 0; i < maplist[m].zone_mf_count; i++) { + aFree(maplist[m].zone_mf[i]); } - if( map[m].zone_mf ) - aFree(map[m].zone_mf); + if( maplist[m].zone_mf ) + aFree(maplist[m].zone_mf); } // Remove from instance - for( i = 0; i < instances[map[m].instance_id].num_map; i++ ) { - if( instances[map[m].instance_id].map[i] == m ) { - instances[map[m].instance_id].num_map--; - for( ; i < instances[map[m].instance_id].num_map; i++ ) - instances[map[m].instance_id].map[i] = instances[map[m].instance_id].map[i+1]; + 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]; i = -1; break; } } - if( i == instances[map[m].instance_id].num_map ) - ShowError("map_instance_del: failed to remove %s from instance list (%s): %d\n", map[m].name, instances[map[m].instance_id].name, m); + 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( map[m].channel ) - clif->chsys_delete(map[m].channel); - - iMap->removemapdb(&map[m]); - memset(&map[m], 0x00, sizeof(map[0])); - map[m].name[0] = 0; - map[m].instance_id = -1; - map[m].mob_delete_timer = INVALID_TIMER; + if( maplist[m].channel ) + clif->chsys_delete(maplist[m].channel); + + iMap->removemapdb(&maplist[m]); + memset(&maplist[m], 0x00, sizeof(maplist[0])); + maplist[m].name[0] = 0; + maplist[m].instance_id = -1; + maplist[m].mob_delete_timer = INVALID_TIMER; } /*-------------------------------------- @@ -591,9 +592,9 @@ void instance_check_kick(struct map_session_data *sd) { int16 m = sd->bl.m; clif->instance_leave(sd->fd); - if( map[m].instance_id >= 0 ) { // User was on the instance map - if( map[m].save.map ) - pc->setpos(sd, map[m].save.map, map[m].save.x, map[m].save.y, CLR_TELEPORT); + if( maplist[m].instance_id >= 0 ) { // User was on the instance map + if( maplist[m].save.map ) + pc->setpos(sd, maplist[m].save.map, maplist[m].save.x, maplist[m].save.y, CLR_TELEPORT); else pc->setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, CLR_TELEPORT); } diff --git a/src/map/intif.c b/src/map/intif.c index 634735bd6..cae2561a0 100644 --- a/src/map/intif.c +++ b/src/map/intif.c @@ -466,8 +466,8 @@ int intif_party_changemap(struct map_session_data *sd,int online) { if(!sd) return 0; - if( (m=iMap->mapindex2mapid(sd->mapindex)) >= 0 && map[m].instance_id >= 0 ) - mapindex = map_id2index(map[m].instance_src_map); + if( (m=iMap->mapindex2mapid(sd->mapindex)) >= 0 && maplist[m].instance_id >= 0 ) + mapindex = map_id2index(maplist[m].instance_src_map); else mapindex = sd->mapindex; diff --git a/src/map/log.c b/src/map/log.c index 8ed621df5..a10549972 100644 --- a/src/map/log.c +++ b/src/map/log.c @@ -153,9 +153,12 @@ void log_branch(struct map_session_data* sd) { logs->branch_sub(sd); } void log_pick_sub_sql(int id, int16 m, e_log_pick_type type, int amount, struct item* itm, struct item_data *data) { - if( SQL_ERROR == SQL->Query(logmysql_handle, LOG_QUERY " INTO `%s` (`time`, `char_id`, `type`, `nameid`, `amount`, `refine`, `card0`, `card1`, `card2`, `card3`, `map`, `unique_id`) VALUES (NOW(), '%d', '%c', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%s', '%"PRIu64"')", - logs->config.log_pick, id, log_picktype2char(type), itm->nameid, amount, itm->refine, itm->card[0], itm->card[1], itm->card[2], itm->card[3], map[m].name?map[m].name:"", itm->unique_id) ) - { + if( SQL_ERROR == SQL->Query(logmysql_handle, + LOG_QUERY " INTO `%s` (`time`, `char_id`, `type`, `nameid`, `amount`, `refine`, `card0`, `card1`, `card2`, `card3`, `map`, `unique_id`) " + "VALUES (NOW(), '%d', '%c', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%s', '%"PRIu64"')", + logs->config.log_pick, id, log_picktype2char(type), itm->nameid, amount, itm->refine, itm->card[0], itm->card[1], itm->card[2], itm->card[3], + maplist[m].name?maplist[m].name:"", itm->unique_id) + ) { Sql_ShowDebug(logmysql_handle); return; } @@ -169,7 +172,9 @@ void log_pick_sub_txt(int id, int16 m, e_log_pick_type type, int amount, struct return; time(&curtime); strftime(timestring, sizeof(timestring), "%m/%d/%Y %H:%M:%S", localtime(&curtime)); - fprintf(logfp,"%s - %d\t%c\t%d,%d,%d,%d,%d,%d,%d,%s,'%"PRIu64"'\n", timestring, id, log_picktype2char(type), itm->nameid, amount, itm->refine, itm->card[0], itm->card[1], itm->card[2], itm->card[3], map[m].name?map[m].name:"", itm->unique_id); + fprintf(logfp,"%s - %d\t%c\t%d,%d,%d,%d,%d,%d,%d,%s,'%"PRIu64"'\n", + timestring, id, log_picktype2char(type), itm->nameid, amount, itm->refine, itm->card[0], itm->card[1], itm->card[2], itm->card[3], + maplist[m].name?maplist[m].name:"", itm->unique_id); fclose(logfp); } /// logs item transactions (generic) @@ -334,22 +339,22 @@ void log_npc(struct map_session_data* sd, const char* message) logs->npc_sub(sd,message); } -void log_chat_sub_sql(e_log_chat_type type, int type_id, int src_charid, int src_accid, const char* map, int x, int y, const char* dst_charname, const char* message) { +void log_chat_sub_sql(e_log_chat_type type, int type_id, int src_charid, int src_accid, const char *mapname, int x, int y, const char* dst_charname, const char* message) { SqlStmt* stmt; stmt = SQL->StmtMalloc(logmysql_handle); - if( SQL_SUCCESS != SQL->StmtPrepare(stmt, LOG_QUERY " INTO `%s` (`time`, `type`, `type_id`, `src_charid`, `src_accountid`, `src_map`, `src_map_x`, `src_map_y`, `dst_charname`, `message`) VALUES (NOW(), '%c', '%d', '%d', '%d', '%s', '%d', '%d', ?, ?)", logs->config.log_chat, log_chattype2char(type), type_id, src_charid, src_accid, map, x, y) - || SQL_SUCCESS != SQL->StmtBindParam(stmt, 0, SQLDT_STRING, (char*)dst_charname, safestrnlen(dst_charname, NAME_LENGTH)) - || SQL_SUCCESS != SQL->StmtBindParam(stmt, 1, SQLDT_STRING, (char*)message, safestrnlen(message, CHAT_SIZE_MAX)) - || SQL_SUCCESS != SQL->StmtExecute(stmt) ) - { + if( SQL_SUCCESS != SQL->StmtPrepare(stmt, LOG_QUERY " INTO `%s` (`time`, `type`, `type_id`, `src_charid`, `src_accountid`, `src_map`, `src_map_x`, `src_map_y`, `dst_charname`, `message`) VALUES (NOW(), '%c', '%d', '%d', '%d', '%s', '%d', '%d', ?, ?)", logs->config.log_chat, log_chattype2char(type), type_id, src_charid, src_accid, mapname, x, y) + || SQL_SUCCESS != SQL->StmtBindParam(stmt, 0, SQLDT_STRING, (char*)dst_charname, safestrnlen(dst_charname, NAME_LENGTH)) + || SQL_SUCCESS != SQL->StmtBindParam(stmt, 1, SQLDT_STRING, (char*)message, safestrnlen(message, CHAT_SIZE_MAX)) + || SQL_SUCCESS != SQL->StmtExecute(stmt) + ) { SqlStmt_ShowDebug(stmt); SQL->StmtFree(stmt); return; } SQL->StmtFree(stmt); } -void log_chat_sub_txt(e_log_chat_type type, int type_id, int src_charid, int src_accid, const char* map, int x, int y, const char* dst_charname, const char* message) { +void log_chat_sub_txt(e_log_chat_type type, int type_id, int src_charid, int src_accid, const char *mapname, int x, int y, const char* dst_charname, const char* message) { char timestring[255]; time_t curtime; FILE* logfp; @@ -358,24 +363,23 @@ void log_chat_sub_txt(e_log_chat_type type, int type_id, int src_charid, int src return; time(&curtime); strftime(timestring, sizeof(timestring), "%m/%d/%Y %H:%M:%S", localtime(&curtime)); - fprintf(logfp, "%s - %c,%d,%d,%d,%s,%d,%d,%s,%s\n", timestring, log_chattype2char(type), type_id, src_charid, src_accid, map, x, y, dst_charname, message); + fprintf(logfp, "%s - %c,%d,%d,%d,%s,%d,%d,%s,%s\n", timestring, log_chattype2char(type), type_id, src_charid, src_accid, mapname, x, y, dst_charname, message); fclose(logfp); } /// logs chat -void log_chat(e_log_chat_type type, int type_id, int src_charid, int src_accid, const char* map, int x, int y, const char* dst_charname, const char* message) -{ - if( ( logs->config.chat&type ) == 0 ) - {// disabled +void log_chat(e_log_chat_type type, int type_id, int src_charid, int src_accid, const char *mapname, int x, int y, const char* dst_charname, const char* message) { + if( ( logs->config.chat&type ) == 0 ) { + // disabled return; } - if( logs->config.log_chat_woe_disable && ( iMap->agit_flag || iMap->agit2_flag ) ) - {// no chat logging during woe + if( logs->config.log_chat_woe_disable && ( iMap->agit_flag || iMap->agit2_flag ) ) { + // no chat logging during woe return; } - logs->chat_sub(type,type_id,src_charid,src_accid,map,x,y,dst_charname,message); + logs->chat_sub(type,type_id,src_charid,src_accid,mapname,x,y,dst_charname,message); } diff --git a/src/map/log.h b/src/map/log.h index 376483fe7..1da1696ab 100644 --- a/src/map/log.h +++ b/src/map/log.h @@ -63,7 +63,7 @@ struct log_interface { void (*pick_mob) (struct mob_data* md, e_log_pick_type type, int amount, struct item* itm, struct item_data *data); void (*zeny) (struct map_session_data* sd, e_log_pick_type type, struct map_session_data* src_sd, int amount); void (*npc) (struct map_session_data* sd, const char *message); - void (*chat) (e_log_chat_type type, int type_id, int src_charid, int src_accid, const char* map, int x, int y, const char* dst_charname, const char* message); + void (*chat) (e_log_chat_type type, int type_id, int src_charid, int src_accid, const char *mapname, int x, int y, const char* dst_charname, const char* message); void (*atcommand) (struct map_session_data* sd, const char* message); void (*branch) (struct map_session_data* sd); void (*mvpdrop) (struct map_session_data* sd, int monster_id, int* log_mvp); @@ -71,7 +71,7 @@ struct log_interface { void (*pick_sub) (int id, int16 m, e_log_pick_type type, int amount, struct item* itm, struct item_data *data); void (*zeny_sub) (struct map_session_data* sd, e_log_pick_type type, struct map_session_data* src_sd, int amount); void (*npc_sub) (struct map_session_data* sd, const char *message); - void (*chat_sub) (e_log_chat_type type, int type_id, int src_charid, int src_accid, const char* map, int x, int y, const char* dst_charname, const char* message); + void (*chat_sub) (e_log_chat_type type, int type_id, int src_charid, int src_accid, const char *mapname, int x, int y, const char* dst_charname, const char* message); void (*atcommand_sub) (struct map_session_data* sd, const char* message); void (*branch_sub) (struct map_session_data* sd); void (*mvpdrop_sub) (struct map_session_data* sd, int monster_id, int* log_mvp); diff --git a/src/map/mail.c b/src/map/mail.c index 93304bac0..ea8bda003 100644 --- a/src/map/mail.c +++ b/src/map/mail.c @@ -176,10 +176,8 @@ void mail_deliveryfail(struct map_session_data *sd, struct mail_message *msg) } // This function only check if the mail operations are valid -bool mail_invalid_operation(struct map_session_data *sd) -{ - if( !map[sd->bl.m].flag.town && !pc->can_use_command(sd, "@mail") ) - { +bool mail_invalid_operation(struct map_session_data *sd) { + if( !maplist[sd->bl.m].flag.town && !pc->can_use_command(sd, "@mail") ) { ShowWarning("clif->parse_Mail: char '%s' trying to do invalid mail operations.\n", sd->status.name); return true; } diff --git a/src/map/map.c b/src/map/map.c index aeeff5178..d57fc583a 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -232,19 +232,21 @@ static struct block_list bl_head; * These pair of functions update the counter of how many objects * lie on a tile. *------------------------------------------*/ -static void map_addblcell(struct block_list *bl) -{ - if( bl->m<0 || bl->x<0 || bl->x>=map[bl->m].xs || bl->y<0 || bl->y>=map[bl->m].ys || !(bl->type&BL_CHAR) ) +static void map_addblcell(struct block_list *bl) { + if( bl->m < 0 || bl->x < 0 || bl->x >= maplist[bl->m].xs + || bl->y < 0 || bl->y >= maplist[bl->m].ys + || !(bl->type&BL_CHAR) ) return; - map[bl->m].cell[bl->x+bl->y*map[bl->m].xs].cell_bl++; + maplist[bl->m].cell[bl->x+bl->y*maplist[bl->m].xs].cell_bl++; return; } -static void map_delblcell(struct block_list *bl) -{ - if( bl->m <0 || bl->x<0 || bl->x>=map[bl->m].xs || bl->y<0 || bl->y>=map[bl->m].ys || !(bl->type&BL_CHAR) ) +static void map_delblcell(struct block_list *bl) { + if( bl->m < 0 || bl->x < 0 || bl->x >= maplist[bl->m].xs + || bl->y < 0 || bl->y >= maplist[bl->m].ys + || !(bl->type&BL_CHAR) ) return; - map[bl->m].cell[bl->x+bl->y*map[bl->m].xs].cell_bl--; + maplist[bl->m].cell[bl->x+bl->y*maplist[bl->m].xs].cell_bl--; } #endif @@ -272,24 +274,23 @@ int map_addblock(struct block_list* bl) ShowError("map_addblock: invalid map id (%d), only %d are loaded.\n", m, iMap->map_num); return 1; } - if( x < 0 || x >= map[m].xs || y < 0 || y >= map[m].ys ) - { - ShowError("map_addblock: out-of-bounds coordinates (\"%s\",%d,%d), map is %dx%d\n", map[m].name, x, y, map[m].xs, map[m].ys); + if( x < 0 || x >= maplist[m].xs || y < 0 || y >= maplist[m].ys ) { + ShowError("map_addblock: out-of-bounds coordinates (\"%s\",%d,%d), map is %dx%d\n", maplist[m].name, x, y, maplist[m].xs, maplist[m].ys); return 1; } - pos = x/BLOCK_SIZE+(y/BLOCK_SIZE)*map[m].bxs; + pos = x/BLOCK_SIZE+(y/BLOCK_SIZE)*maplist[m].bxs; if (bl->type == BL_MOB) { - bl->next = map[m].block_mob[pos]; + bl->next = maplist[m].block_mob[pos]; bl->prev = &bl_head; if (bl->next) bl->next->prev = bl; - map[m].block_mob[pos] = bl; + maplist[m].block_mob[pos] = bl; } else { - bl->next = map[m].block[pos]; + bl->next = maplist[m].block[pos]; bl->prev = &bl_head; if (bl->next) bl->next->prev = bl; - map[m].block[pos] = bl; + maplist[m].block[pos] = bl; } #ifdef CELL_NOSTACK @@ -320,16 +321,16 @@ int map_delblock(struct block_list* bl) map_delblcell(bl); #endif - pos = bl->x/BLOCK_SIZE+(bl->y/BLOCK_SIZE)*map[bl->m].bxs; + pos = bl->x/BLOCK_SIZE+(bl->y/BLOCK_SIZE)*maplist[bl->m].bxs; if (bl->next) bl->next->prev = bl->prev; if (bl->prev == &bl_head) { //Since the head of the list, update the block_list map of [] if (bl->type == BL_MOB) { - map[bl->m].block_mob[pos] = bl->next; + maplist[bl->m].block_mob[pos] = bl->next; } else { - map[bl->m].block[pos] = bl->next; + maplist[bl->m].block[pos] = bl->next; } } else { bl->prev->next = bl->next; @@ -452,25 +453,24 @@ int map_moveblock(struct block_list *bl, int x1, int y1, unsigned int tick) * Counts specified number of objects on given cell. * TODO: merge with bl_getall_area *------------------------------------------*/ -int map_count_oncell(int16 m, int16 x, int16 y, int type) -{ +int map_count_oncell(int16 m, int16 x, int16 y, int type) { int bx,by; struct block_list *bl; int count = 0; - if (x < 0 || y < 0 || (x >= map[m].xs) || (y >= map[m].ys)) + if (x < 0 || y < 0 || (x >= maplist[m].xs) || (y >= maplist[m].ys)) return 0; bx = x/BLOCK_SIZE; by = y/BLOCK_SIZE; if (type&~BL_MOB) - for( bl = map[m].block[bx+by*map[m].bxs] ; bl != NULL ; bl = bl->next ) + for( bl = maplist[m].block[bx+by*maplist[m].bxs] ; bl != NULL ; bl = bl->next ) if(bl->x == x && bl->y == y && bl->type&type) count++; if (type&BL_MOB) - for( bl = map[m].block_mob[bx+by*map[m].bxs] ; bl != NULL ; bl = bl->next ) + for( bl = maplist[m].block_mob[bx+by*maplist[m].bxs] ; bl != NULL ; bl = bl->next ) if(bl->x == x && bl->y == y) count++; @@ -486,14 +486,13 @@ struct skill_unit* map_find_skill_unit_oncell(struct block_list* target,int16 x, struct skill_unit *su; m = target->m; - if (x < 0 || y < 0 || (x >= map[m].xs) || (y >= map[m].ys)) + if (x < 0 || y < 0 || (x >= maplist[m].xs) || (y >= maplist[m].ys)) return NULL; bx = x/BLOCK_SIZE; by = y/BLOCK_SIZE; - for( bl = map[m].block[bx+by*map[m].bxs] ; bl != NULL ; bl = bl->next ) - { + for( bl = maplist[m].block[bx+by*maplist[m].bxs] ; bl != NULL ; bl = bl->next ) { if (bl->x != x || bl->y != y || bl->type != BL_SKILL) continue; @@ -550,8 +549,7 @@ static int bl_vforeach(int (*func)(struct block_list*, va_list), int blockcount, * @param args Extra arguments for func * @return Sum of the values returned by func */ -static int map_vforeachinmap(int (*func)(struct block_list*, va_list), int16 m, int type, va_list args) -{ +static int map_vforeachinmap(int (*func)(struct block_list*, va_list), int16 m, int type, va_list args) { int i; int returnCount = 0; int bsize; @@ -562,17 +560,17 @@ static int map_vforeachinmap(int (*func)(struct block_list*, va_list), int16 m, if (m < 0) return 0; - bsize = map[m].bxs * map[m].bys; + bsize = maplist[m].bxs * maplist[m].bys; for (i = 0; i < bsize; i++) { if (type&~BL_MOB) { - for (bl = map[m].block[i]; bl != NULL; bl = bl->next) { + for (bl = maplist[m].block[i]; bl != NULL; bl = bl->next) { if (bl->type&type && bl_list_count < BL_LIST_MAX) { bl_list[bl_list_count++] = bl; } } } if (type&BL_MOB) { - for (bl = map[m].block_mob[i]; bl != NULL; bl = bl->next) { + for (bl = maplist[m].block_mob[i]; bl != NULL; bl = bl->next) { if (bl_list_count < BL_LIST_MAX) { bl_list[bl_list_count++] = bl; } @@ -648,8 +646,7 @@ int map_foreachininstance(int (*func)(struct block_list*, va_list), int16 instan * @param ... Extra arguments for func * @return Number of found objects */ -static int bl_getall_area(int type, int m, int x0, int y0, int x1, int y1, int (*func)(struct block_list*, va_list), ...) -{ +static int bl_getall_area(int type, int m, int x0, int y0, int x1, int y1, int (*func)(struct block_list*, va_list), ...) { va_list args; int bx, by; struct block_list *bl; @@ -664,13 +661,13 @@ static int bl_getall_area(int type, int m, int x0, int y0, int x1, int y1, int ( // Limit search area to map size x0 = max(x0, 0); y0 = max(y0, 0); - x1 = min(x1, map[m].xs - 1); - y1 = min(y1, map[m].ys - 1); + x1 = min(x1, maplist[m].xs - 1); + y1 = min(y1, maplist[m].ys - 1); for (by = y0 / BLOCK_SIZE; by <= y1 / BLOCK_SIZE; by++) { for (bx = x0 / BLOCK_SIZE; bx <= x1 / BLOCK_SIZE; bx++) { if (type&~BL_MOB) { - for (bl = map[m].block[bx + by * map[m].bxs]; bl != NULL; bl = bl->next) { + for (bl = maplist[m].block[bx + by * maplist[m].bxs]; bl != NULL; bl = bl->next) { if (bl_list_count < BL_LIST_MAX && bl->type&type && bl->x >= x0 && bl->x <= x1 @@ -691,7 +688,7 @@ static int bl_getall_area(int type, int m, int x0, int y0, int x1, int y1, int ( } } if (type&BL_MOB) { // TODO: fix this code duplication - for (bl = map[m].block_mob[bx + by * map[m].bxs]; bl != NULL; bl = bl->next) { + for (bl = maplist[m].block_mob[bx + by * maplist[m].bxs]; bl != NULL; bl = bl->next) { if (bl_list_count < BL_LIST_MAX //&& bl->type&type // block_mob contains BL_MOBs only && bl->x >= x0 && bl->x <= x1 @@ -1222,10 +1219,10 @@ int map_searchrandfreecell(int16 m,int16 *x,int16 *y,int stack) { int free_cells[9][2]; for(free_cell=0,i=-1;i<=1;i++){ - if(i+*y<0 || i+*y>=map[m].ys) + if(i+*y<0 || i+*y>=maplist[m].ys) continue; for(j=-1;j<=1;j++){ - if(j+*x<0 || j+*x>=map[m].xs) + if(j+*x<0 || j+*x>=maplist[m].xs) continue; if(iMap->getcell(m,j+*x,i+*y,CELL_CHKNOPASS) && !iMap->getcell(m,j+*x,i+*y,CELL_CHKICEWALL)) continue; @@ -1294,13 +1291,13 @@ int map_search_freecell(struct block_list *src, int16 m, int16 *x,int16 *y, int1 tries = rx2*ry2; if (tries > 100) tries = 100; } else { - tries = map[m].xs*map[m].ys; + tries = maplist[m].xs*maplist[m].ys; if (tries > 500) tries = 500; } while(tries--) { - *x = (rx >= 0)?(rnd()%rx2-rx+bx):(rnd()%(map[m].xs-2)+1); - *y = (ry >= 0)?(rnd()%ry2-ry+by):(rnd()%(map[m].ys-2)+1); + *x = (rx >= 0)?(rnd()%rx2-rx+bx):(rnd()%(maplist[m].xs-2)+1); + *y = (ry >= 0)?(rnd()%ry2-ry+by):(rnd()%(maplist[m].ys-2)+1); if (*x == bx && *y == by) continue; //Avoid picking the same target tile. @@ -1598,19 +1595,19 @@ int map_quit(struct map_session_data *sd) { unit->remove_map(&sd->ed->bl,CLR_TELEPORT,ALC_MARK); } - if( hChSys.local && map[sd->bl.m].channel && idb_exists(map[sd->bl.m].channel->users, sd->status.char_id) ) { - clif->chsys_left(map[sd->bl.m].channel,sd); + if( hChSys.local && maplist[sd->bl.m].channel && idb_exists(maplist[sd->bl.m].channel->users, sd->status.char_id) ) { + clif->chsys_left(maplist[sd->bl.m].channel,sd); } clif->chsys_quit(sd); unit->remove_map_pc(sd,CLR_TELEPORT); - if( map[sd->bl.m].instance_id >= 0 ) { // Avoid map conflicts and warnings on next login + if( maplist[sd->bl.m].instance_id >= 0 ) { // Avoid map conflicts and warnings on next login int16 m; struct point *pt; - if( map[sd->bl.m].save.map ) - pt = &map[sd->bl.m].save; + if( maplist[sd->bl.m].save.map ) + pt = &maplist[sd->bl.m].save; else pt = &sd->status.save_point; @@ -2052,14 +2049,13 @@ bool map_addnpc(int16 m,struct npc_data *nd) { if( m < 0 || m >= iMap->map_num ) return false; - if( map[m].npc_num == MAX_NPC_PER_MAP ) - { - ShowWarning("too many NPCs in one map %s\n",map[m].name); + if( maplist[m].npc_num == MAX_NPC_PER_MAP ) { + ShowWarning("too many NPCs in one map %s\n",maplist[m].name); return false; } - map[m].npc[map[m].npc_num]=nd; - map[m].npc_num++; + maplist[m].npc[maplist[m].npc_num]=nd; + maplist[m].npc_num++; idb_put(id_db,nd->bl.id,nd); return true; } @@ -2069,37 +2065,33 @@ 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) -{ +int map_addmobtolist(unsigned short m, struct spawn_data *spawn) { size_t i; - ARR_FIND( 0, MAX_MOB_LIST_PER_MAP, i, map[m].moblist[i] == NULL ); + ARR_FIND( 0, MAX_MOB_LIST_PER_MAP, i, maplist[m].moblist[i] == NULL ); if( i < MAX_MOB_LIST_PER_MAP ) { - map[m].moblist[i] = spawn; + maplist[m].moblist[i] = spawn; return i; } return -1; } -void map_spawnmobs(int16 m) -{ +void map_spawnmobs(int16 m) { int i, k=0; - if (map[m].mob_delete_timer != INVALID_TIMER) - { //Mobs have not been removed yet [Skotlex] - timer->delete(map[m].mob_delete_timer, iMap->removemobs_timer); - map[m].mob_delete_timer = INVALID_TIMER; + if (maplist[m].mob_delete_timer != INVALID_TIMER) { + //Mobs have not been removed yet [Skotlex] + timer->delete(maplist[m].mob_delete_timer, iMap->removemobs_timer); + maplist[m].mob_delete_timer = INVALID_TIMER; return; } for(i=0; i<MAX_MOB_LIST_PER_MAP; i++) - if(map[m].moblist[i]!=NULL) - { - k+=map[m].moblist[i]->num; - npc->parse_mob2(map[m].moblist[i]); + if(maplist[m].moblist[i]!=NULL) { + k+=maplist[m].moblist[i]->num; + npc->parse_mob2(maplist[m].moblist[i]); } - if (battle_config.etc_log && k > 0) - { - ShowStatus("Map %s: Spawned '"CL_WHITE"%d"CL_RESET"' mobs.\n",map[m].name, k); - } + if (battle_config.etc_log && k > 0) { + ShowStatus("Map %s: Spawned '"CL_WHITE"%d"CL_RESET"' mobs.\n",maplist[m].name, k); + } } int map_removemobs_sub(struct block_list *bl, va_list ap) @@ -2138,28 +2130,28 @@ int map_removemobs_timer(int tid, unsigned int tick, int id, intptr_t data) ShowError("map_removemobs_timer error: timer %d points to invalid map %d\n",tid, m); return 0; } - if (map[m].mob_delete_timer != tid) { //Incorrect timer call! - ShowError("map_removemobs_timer mismatch: %d != %d (map %s)\n",map[m].mob_delete_timer, tid, map[m].name); + if (maplist[m].mob_delete_timer != tid) { //Incorrect timer call! + ShowError("map_removemobs_timer mismatch: %d != %d (map %s)\n",maplist[m].mob_delete_timer, tid, maplist[m].name); return 0; } - map[m].mob_delete_timer = INVALID_TIMER; - if (map[m].users > 0) //Map not empty! + maplist[m].mob_delete_timer = INVALID_TIMER; + if (maplist[m].users > 0) //Map not empty! return 1; count = map_foreachinmap(map_removemobs_sub, m, BL_MOB); if (battle_config.etc_log && count > 0) - ShowStatus("Map %s: Removed '"CL_WHITE"%d"CL_RESET"' mobs.\n",map[m].name, count); + ShowStatus("Map %s: Removed '"CL_WHITE"%d"CL_RESET"' mobs.\n",maplist[m].name, count); return 1; } void map_removemobs(int16 m) { - if (map[m].mob_delete_timer != INVALID_TIMER) // should never happen + if (maplist[m].mob_delete_timer != INVALID_TIMER) // should never happen return; //Mobs are already scheduled for removal - map[m].mob_delete_timer = timer->add(timer->gettick()+battle_config.mob_remove_delay, iMap->removemobs_timer, m, 0); + maplist[m].mob_delete_timer = timer->add(timer->gettick()+battle_config.mob_remove_delay, iMap->removemobs_timer, m, 0); } /*========================================== @@ -2359,7 +2351,7 @@ void map_cellfromcache(struct map_data *m) { * Confirm if celltype in (m,x,y) match the one given in cellchk *------------------------------------------*/ int map_getcell(int16 m,int16 x,int16 y,cell_chk cellchk) { - return (m < 0 || m >= iMap->map_num) ? 0 : map[m].getcellp(&map[m],x,y,cellchk); + return (m < 0 || m >= iMap->map_num) ? 0 : maplist[m].getcellp(&maplist[m],x,y,cellchk); } int map_getcellp(struct map_data* m,int16 x,int16 y,cell_chk cellchk) { @@ -2447,52 +2439,50 @@ int map_sub_getcellp(struct map_data* m,int16 x,int16 y,cell_chk cellchk) { void map_setcell(int16 m, int16 x, int16 y, cell_t cell, bool flag) { int j; - if( m < 0 || m >= iMap->map_num || x < 0 || x >= map[m].xs || y < 0 || y >= map[m].ys ) + if( m < 0 || m >= iMap->map_num || x < 0 || x >= maplist[m].xs || y < 0 || y >= maplist[m].ys ) return; - j = x + y*map[m].xs; + j = x + y*maplist[m].xs; switch( cell ) { - case CELL_WALKABLE: map[m].cell[j].walkable = flag; break; - case CELL_SHOOTABLE: map[m].cell[j].shootable = flag; break; - case CELL_WATER: map[m].cell[j].water = flag; break; - - case CELL_NPC: map[m].cell[j].npc = flag; break; - case CELL_BASILICA: map[m].cell[j].basilica = flag; break; - case CELL_LANDPROTECTOR: map[m].cell[j].landprotector = flag; break; - case CELL_NOVENDING: map[m].cell[j].novending = flag; break; - case CELL_NOCHAT: map[m].cell[j].nochat = flag; break; - case CELL_MAELSTROM: map[m].cell[j].maelstrom = flag; break; - case CELL_ICEWALL: map[m].cell[j].icewall = flag; break; + case CELL_WALKABLE: maplist[m].cell[j].walkable = flag; break; + case CELL_SHOOTABLE: maplist[m].cell[j].shootable = flag; break; + case CELL_WATER: maplist[m].cell[j].water = flag; break; + + case CELL_NPC: maplist[m].cell[j].npc = flag; break; + case CELL_BASILICA: maplist[m].cell[j].basilica = flag; break; + case CELL_LANDPROTECTOR: maplist[m].cell[j].landprotector = flag; break; + case CELL_NOVENDING: maplist[m].cell[j].novending = flag; break; + case CELL_NOCHAT: maplist[m].cell[j].nochat = flag; break; + case CELL_MAELSTROM: maplist[m].cell[j].maelstrom = flag; break; + case CELL_ICEWALL: maplist[m].cell[j].icewall = flag; break; default: ShowWarning("map_setcell: invalid cell type '%d'\n", (int)cell); break; } } void map_sub_setcell(int16 m, int16 x, int16 y, cell_t cell, bool flag) { - - if( m < 0 || m >= iMap->map_num || x < 0 || x >= map[m].xs || y < 0 || y >= map[m].ys ) + if( m < 0 || m >= iMap->map_num || x < 0 || x >= maplist[m].xs || y < 0 || y >= maplist[m].ys ) return; - iMap->cellfromcache(&map[m]); - map[m].setcell = map_setcell; - map[m].getcellp = map_getcellp; - map[m].setcell(m,x,y,cell,flag); + iMap->cellfromcache(&maplist[m]); + maplist[m].setcell = map_setcell; + maplist[m].getcellp = map_getcellp; + maplist[m].setcell(m,x,y,cell,flag); } -void map_setgatcell(int16 m, int16 x, int16 y, int gat) -{ +void map_setgatcell(int16 m, int16 x, int16 y, int gat) { int j; struct mapcell cell; - if( m < 0 || m >= iMap->map_num || x < 0 || x >= map[m].xs || y < 0 || y >= map[m].ys ) + if( m < 0 || m >= iMap->map_num || x < 0 || x >= maplist[m].xs || y < 0 || y >= maplist[m].ys ) return; - j = x + y*map[m].xs; + j = x + y*maplist[m].xs; cell = map_gat2cell(gat); - map[m].cell[j].walkable = cell.walkable; - map[m].cell[j].shootable = cell.shootable; - map[m].cell[j].water = cell.water; + maplist[m].cell[j].walkable = cell.walkable; + maplist[m].cell[j].shootable = cell.shootable; + maplist[m].cell[j].water = cell.water; } /*========================================== @@ -2541,15 +2531,14 @@ bool map_iwall_set(int16 m, int16 x, int16 y, int size, int8 dir, bool shootable iwall->shootable = shootable; safestrncpy(iwall->wall_name, wall_name, sizeof(iwall->wall_name)); - for( i = 0; i < size; i++ ) - { + for( i = 0; i < size; i++ ) { map_iwall_nextxy(x, y, dir, i, &x1, &y1); if( iMap->getcell(m, x1, y1, CELL_CHKNOREACH) ) break; // Collision - map[m].setcell(m, x1, y1, CELL_WALKABLE, false); - map[m].setcell(m, x1, y1, CELL_SHOOTABLE, shootable); + maplist[m].setcell(m, x1, y1, CELL_WALKABLE, false); + maplist[m].setcell(m, x1, y1, CELL_SHOOTABLE, shootable); clif->changemapcell(0, m, x1, y1, iMap->getcell(m, x1, y1, CELL_GETTYPE), ALL_SAMEMAP); } @@ -2557,7 +2546,7 @@ bool map_iwall_set(int16 m, int16 x, int16 y, int size, int8 dir, bool shootable iwall->size = i; strdb_put(iwall_db, iwall->wall_name, iwall); - map[m].iwall_num++; + maplist[m].iwall_num++; return true; } @@ -2568,7 +2557,7 @@ void map_iwall_get(struct map_session_data *sd) { int16 x1, y1; int i; - if( map[sd->bl.m].iwall_num < 1 ) + if( maplist[sd->bl.m].iwall_num < 1 ) return; iter = db_iterator(iwall_db); @@ -2595,13 +2584,13 @@ void map_iwall_remove(const char *wall_name) for( i = 0; i < iwall->size; i++ ) { map_iwall_nextxy(iwall->x, iwall->y, iwall->dir, i, &x1, &y1); - map[iwall->m].setcell(iwall->m, x1, y1, CELL_SHOOTABLE, true); - map[iwall->m].setcell(iwall->m, x1, y1, CELL_WALKABLE, true); + maplist[iwall->m].setcell(iwall->m, x1, y1, CELL_SHOOTABLE, true); + maplist[iwall->m].setcell(iwall->m, x1, y1, CELL_WALKABLE, true); clif->changemapcell(0, iwall->m, x1, y1, iMap->getcell(iwall->m, x1, y1, CELL_GETTYPE), ALL_SAMEMAP); } - map[iwall->m].iwall_num--; + maplist[iwall->m].iwall_num--; strdb_remove(iwall_db, iwall->wall_name); } @@ -2753,14 +2742,14 @@ int map_readfromcache(struct map_data *m, char *buffer) { int map_addmap(char* mapname) { - map[iMap->map_num].instance_id = -1; - mapindex_getmapname(mapname, map[iMap->map_num++].name); + maplist[iMap->map_num].instance_id = -1; + mapindex_getmapname(mapname, maplist[iMap->map_num++].name); return 0; } static void map_delmapid(int id) { - ShowNotice("Removing map [ %s ] from maplist"CL_CLL"\n",map[id].name); - memmove(map+id, map+id+1, sizeof(map[0])*(iMap->map_num-id-1)); + ShowNotice("Removing map [ %s ] from maplist"CL_CLL"\n",maplist[id].name); + memmove(maplist+id, maplist+id+1, sizeof(maplist[0])*(iMap->map_num-id-1)); iMap->map_num--; } @@ -2775,7 +2764,7 @@ int map_delmap(char* mapname) { mapindex_getmapname(mapname, map_name); for(i = 0; i < iMap->map_num; i++) { - if (strcmp(map[i].name, map_name) == 0) { + if (strcmp(maplist[i].name, map_name) == 0) { map_delmapid(i); return 1; } @@ -2849,112 +2838,112 @@ void map_zone_db_clear(void) { } void map_clean(int i) { int v; - if(map[i].cell && map[i].cell != (struct mapcell *)0xdeadbeaf) aFree(map[i].cell); - if(map[i].block) aFree(map[i].block); - if(map[i].block_mob) aFree(map[i].block_mob); + if(maplist[i].cell && maplist[i].cell != (struct mapcell *)0xdeadbeaf) aFree(maplist[i].cell); + if(maplist[i].block) aFree(maplist[i].block); + if(maplist[i].block_mob) aFree(maplist[i].block_mob); if(battle_config.dynamic_mobs) { //Dynamic mobs flag by [random] int j; - if(map[i].mob_delete_timer != INVALID_TIMER) - timer->delete(map[i].mob_delete_timer, iMap->removemobs_timer); + if(maplist[i].mob_delete_timer != INVALID_TIMER) + timer->delete(maplist[i].mob_delete_timer, iMap->removemobs_timer); for (j=0; j<MAX_MOB_LIST_PER_MAP; j++) - if (map[i].moblist[j]) aFree(map[i].moblist[j]); + if (maplist[i].moblist[j]) aFree(maplist[i].moblist[j]); } - if( map[i].unit_count ) { - for(v = 0; v < map[i].unit_count; v++) { - aFree(map[i].units[v]); + if( maplist[i].unit_count ) { + for(v = 0; v < maplist[i].unit_count; v++) { + aFree(maplist[i].units[v]); } - if( map[i].units ) { - aFree(map[i].units); - map[i].units = NULL; + if( maplist[i].units ) { + aFree(maplist[i].units); + maplist[i].units = NULL; } - map[i].unit_count = 0; + maplist[i].unit_count = 0; } - if( map[i].skill_count ) { - for(v = 0; v < map[i].skill_count; v++) { - aFree(map[i].skills[v]); + if( maplist[i].skill_count ) { + for(v = 0; v < maplist[i].skill_count; v++) { + aFree(maplist[i].skills[v]); } - if( map[i].skills ) { - aFree(map[i].skills); - map[i].skills = NULL; + if( maplist[i].skills ) { + aFree(maplist[i].skills); + maplist[i].skills = NULL; } - map[i].skill_count = 0; + maplist[i].skill_count = 0; } - if( map[i].zone_mf_count ) { - for(v = 0; v < map[i].zone_mf_count; v++) { - aFree(map[i].zone_mf[v]); + if( maplist[i].zone_mf_count ) { + for(v = 0; v < maplist[i].zone_mf_count; v++) { + aFree(maplist[i].zone_mf[v]); } - if( map[i].zone_mf ) { - aFree(map[i].zone_mf); - map[i].zone_mf = NULL; + if( maplist[i].zone_mf ) { + aFree(maplist[i].zone_mf); + maplist[i].zone_mf = NULL; } - map[i].zone_mf_count = 0; + maplist[i].zone_mf_count = 0; } - if( map[i].channel ) - clif->chsys_delete(map[i].channel); + if( maplist[i].channel ) + clif->chsys_delete(maplist[i].channel); } void do_final_maps(void) { int i, v = 0; for( i = 0; i < iMap->map_num; i++ ) { - if(map[i].cell && map[i].cell != (struct mapcell *)0xdeadbeaf ) aFree(map[i].cell); - if(map[i].block) aFree(map[i].block); - if(map[i].block_mob) aFree(map[i].block_mob); + if(maplist[i].cell && maplist[i].cell != (struct mapcell *)0xdeadbeaf ) aFree(maplist[i].cell); + if(maplist[i].block) aFree(maplist[i].block); + if(maplist[i].block_mob) aFree(maplist[i].block_mob); if(battle_config.dynamic_mobs) { //Dynamic mobs flag by [random] int j; - if(map[i].mob_delete_timer != INVALID_TIMER) - timer->delete(map[i].mob_delete_timer, iMap->removemobs_timer); + if(maplist[i].mob_delete_timer != INVALID_TIMER) + timer->delete(maplist[i].mob_delete_timer, iMap->removemobs_timer); for (j=0; j<MAX_MOB_LIST_PER_MAP; j++) - if (map[i].moblist[j]) aFree(map[i].moblist[j]); + if (maplist[i].moblist[j]) aFree(maplist[i].moblist[j]); } - if( map[i].unit_count ) { - for(v = 0; v < map[i].unit_count; v++) { - aFree(map[i].units[v]); + if( maplist[i].unit_count ) { + for(v = 0; v < maplist[i].unit_count; v++) { + aFree(maplist[i].units[v]); } - if( map[i].units ) { - aFree(map[i].units); - map[i].units = NULL; + if( maplist[i].units ) { + aFree(maplist[i].units); + maplist[i].units = NULL; } - map[i].unit_count = 0; + maplist[i].unit_count = 0; } - if( map[i].skill_count ) { - for(v = 0; v < map[i].skill_count; v++) { - aFree(map[i].skills[v]); + if( maplist[i].skill_count ) { + for(v = 0; v < maplist[i].skill_count; v++) { + aFree(maplist[i].skills[v]); } - if( map[i].skills ) { - aFree(map[i].skills); - map[i].skills = NULL; + if( maplist[i].skills ) { + aFree(maplist[i].skills); + maplist[i].skills = NULL; } - map[i].skill_count = 0; + maplist[i].skill_count = 0; } - if( map[i].zone_mf_count ) { - for(v = 0; v < map[i].zone_mf_count; v++) { - aFree(map[i].zone_mf[v]); + if( maplist[i].zone_mf_count ) { + for(v = 0; v < maplist[i].zone_mf_count; v++) { + aFree(maplist[i].zone_mf[v]); } - if( map[i].zone_mf ) { - aFree(map[i].zone_mf); - map[i].zone_mf = NULL; + if( maplist[i].zone_mf ) { + aFree(maplist[i].zone_mf); + maplist[i].zone_mf = NULL; } - map[i].zone_mf_count = 0; + maplist[i].zone_mf_count = 0; } - if( map[i].drop_list_count ) { - map[i].drop_list_count = 0; + if( maplist[i].drop_list_count ) { + maplist[i].drop_list_count = 0; } - if( map[i].drop_list != NULL ) - aFree(map[i].drop_list); + if( maplist[i].drop_list != NULL ) + aFree(maplist[i].drop_list); - if( map[i].channel ) - clif->chsys_delete(map[i].channel); + if( maplist[i].channel ) + clif->chsys_delete(maplist[i].channel); } map_zone_db_clear(); @@ -2966,60 +2955,60 @@ void map_flags_init(void) { for( i = 0; i < iMap->map_num; i++ ) { // mapflags - memset(&map[i].flag, 0, sizeof(map[i].flag)); + memset(&maplist[i].flag, 0, sizeof(maplist[i].flag)); // additional mapflag data - map[i].nocommand = 0; // nocommand mapflag level - map[i].bexp = 100; // per map base exp multiplicator - map[i].jexp = 100; // per map job exp multiplicator - if( map[i].drop_list != NULL ) - aFree(map[i].drop_list); - map[i].drop_list = NULL; - map[i].drop_list_count = 0; - - if( map[i].unit_count ) { - for(v = 0; v < map[i].unit_count; v++) { - aFree(map[i].units[v]); + maplist[i].nocommand = 0; // nocommand mapflag level + maplist[i].bexp = 100; // per map base exp multiplicator + maplist[i].jexp = 100; // per map job exp multiplicator + if( maplist[i].drop_list != NULL ) + aFree(maplist[i].drop_list); + maplist[i].drop_list = NULL; + maplist[i].drop_list_count = 0; + + if( maplist[i].unit_count ) { + for(v = 0; v < maplist[i].unit_count; v++) { + aFree(maplist[i].units[v]); } - aFree(map[i].units); + aFree(maplist[i].units); } - map[i].units = NULL; - map[i].unit_count = 0; + maplist[i].units = NULL; + maplist[i].unit_count = 0; - if( map[i].skill_count ) { - for(v = 0; v < map[i].skill_count; v++) { - aFree(map[i].skills[v]); + if( maplist[i].skill_count ) { + for(v = 0; v < maplist[i].skill_count; v++) { + aFree(maplist[i].skills[v]); } - aFree(map[i].skills); + aFree(maplist[i].skills); } - map[i].skills = NULL; - map[i].skill_count = 0; + maplist[i].skills = NULL; + maplist[i].skill_count = 0; // adjustments if( battle_config.pk_mode ) { - map[i].flag.pvp = 1; // make all maps pvp for pk_mode [Valaris] - map[i].zone = &map_zone_pk; + maplist[i].flag.pvp = 1; // make all maps pvp for pk_mode [Valaris] + maplist[i].zone = &map_zone_pk; } else /* align with 'All' zone */ - map[i].zone = &map_zone_all; + maplist[i].zone = &map_zone_all; - if( map[i].zone_mf_count ) { - for(v = 0; v < map[i].zone_mf_count; v++) { - aFree(map[i].zone_mf[v]); + if( maplist[i].zone_mf_count ) { + for(v = 0; v < maplist[i].zone_mf_count; v++) { + aFree(maplist[i].zone_mf[v]); } - aFree(map[i].zone_mf); + aFree(maplist[i].zone_mf); } - map[i].zone_mf = NULL; - map[i].zone_mf_count = 0; - map[i].prev_zone = map[i].zone; + maplist[i].zone_mf = NULL; + maplist[i].zone_mf_count = 0; + maplist[i].prev_zone = maplist[i].zone; - map[i].invincible_time_inc = 0; + maplist[i].invincible_time_inc = 0; - map[i].weapon_damage_rate = 100; - map[i].magic_damage_rate = 100; - map[i].misc_damage_rate = 100; - map[i].short_damage_rate = 100; - map[i].long_damage_rate = 100; + maplist[i].weapon_damage_rate = 100; + maplist[i].magic_damage_rate = 100; + maplist[i].misc_damage_rate = 100; + maplist[i].short_damage_rate = 100; + maplist[i].long_damage_rate = 100; } } @@ -3140,13 +3129,13 @@ int map_readallmaps (void) { // show progress if(enable_grf) - ShowStatus("Loading maps [%i/%i]: %s"CL_CLL"\r", i, iMap->map_num, map[i].name); + ShowStatus("Loading maps [%i/%i]: %s"CL_CLL"\r", i, iMap->map_num, maplist[i].name); // try to load the map if( ! (enable_grf? - map_readgat(&map[i]) - :map_readfromcache(&map[i], map_cache_buffer)) + map_readgat(&maplist[i]) + :map_readfromcache(&maplist[i], map_cache_buffer)) ) { map_delmapid(i); maps_removed++; @@ -3154,13 +3143,13 @@ int map_readallmaps (void) { continue; } - map[i].index = mapindex_name2id(map[i].name); + maplist[i].index = mapindex_name2id(maplist[i].name); if ( index2mapid[map_id2index(i)] != -1 ) { - ShowWarning("Map %s already loaded!"CL_CLL"\n", map[i].name); - if (map[i].cell && map[i].cell != (struct mapcell *)0xdeadbeaf) { - aFree(map[i].cell); - map[i].cell = NULL; + ShowWarning("Map %s already loaded!"CL_CLL"\n", maplist[i].name); + if (maplist[i].cell && maplist[i].cell != (struct mapcell *)0xdeadbeaf) { + aFree(maplist[i].cell); + maplist[i].cell = NULL; } map_delmapid(i); maps_removed++; @@ -3168,21 +3157,21 @@ int map_readallmaps (void) { continue; } - map[i].m = i; - iMap->addmap2db(&map[i]); + maplist[i].m = i; + iMap->addmap2db(&maplist[i]); - memset(map[i].moblist, 0, sizeof(map[i].moblist)); //Initialize moblist [Skotlex] - map[i].mob_delete_timer = INVALID_TIMER; //Initialize timer [Skotlex] + memset(maplist[i].moblist, 0, sizeof(maplist[i].moblist)); //Initialize moblist [Skotlex] + maplist[i].mob_delete_timer = INVALID_TIMER; //Initialize timer [Skotlex] - map[i].bxs = (map[i].xs + BLOCK_SIZE - 1) / BLOCK_SIZE; - map[i].bys = (map[i].ys + BLOCK_SIZE - 1) / BLOCK_SIZE; + maplist[i].bxs = (maplist[i].xs + BLOCK_SIZE - 1) / BLOCK_SIZE; + maplist[i].bys = (maplist[i].ys + BLOCK_SIZE - 1) / BLOCK_SIZE; - size = map[i].bxs * map[i].bys * sizeof(struct block_list*); - map[i].block = (struct block_list**)aCalloc(size, 1); - map[i].block_mob = (struct block_list**)aCalloc(size, 1); + size = maplist[i].bxs * maplist[i].bys * sizeof(struct block_list*); + maplist[i].block = (struct block_list**)aCalloc(size, 1); + maplist[i].block_mob = (struct block_list**)aCalloc(size, 1); - map[i].getcellp = map_sub_getcellp; - map[i].setcell = map_sub_setcell; + maplist[i].getcellp = map_sub_getcellp; + maplist[i].setcell = map_sub_setcell; } // intialization and configuration-dependent adjustments of mapflags @@ -3520,18 +3509,18 @@ int log_sql_init(void) void map_zone_change2(int m, struct map_zone_data *zone) { char empty[1] = "\0"; - map[m].prev_zone = map[m].zone; + maplist[m].prev_zone = maplist[m].zone; - if( map[m].zone_mf_count ) + if( maplist[m].zone_mf_count ) iMap->zone_remove(m); iMap->zone_apply(m,zone,empty,empty,empty); } /* when changing from a mapflag to another during runtime */ void map_zone_change(int m, struct map_zone_data *zone, const char* start, const char* buffer, const char* filepath) { - map[m].prev_zone = map[m].zone; + maplist[m].prev_zone = maplist[m].zone; - if( map[m].zone_mf_count ) + if( maplist[m].zone_mf_count ) iMap->zone_remove(m); iMap->zone_apply(m,zone,start,buffer,filepath); } @@ -3540,10 +3529,10 @@ void map_zone_remove(int m) { char flag[MAP_ZONE_MAPFLAG_LENGTH], params[MAP_ZONE_MAPFLAG_LENGTH]; unsigned short k; char empty[1] = "\0"; - for(k = 0; k < map[m].zone_mf_count; k++) { - int len = strlen(map[m].zone_mf[k]),j; + for(k = 0; k < maplist[m].zone_mf_count; k++) { + int len = strlen(maplist[m].zone_mf[k]),j; params[0] = '\0'; - memcpy(flag, map[m].zone_mf[k], MAP_ZONE_MAPFLAG_LENGTH); + memcpy(flag, maplist[m].zone_mf[k], MAP_ZONE_MAPFLAG_LENGTH); for(j = 0; j < len; j++) { if( flag[j] == '\t' ) { memcpy(params, &flag[j+1], len - j); @@ -3552,19 +3541,19 @@ void map_zone_remove(int m) { } } - npc->parse_mapflag(map[m].name,empty,flag,params,empty,empty,empty); - aFree(map[m].zone_mf[k]); - map[m].zone_mf[k] = NULL; + npc->parse_mapflag(maplist[m].name,empty,flag,params,empty,empty,empty); + aFree(maplist[m].zone_mf[k]); + maplist[m].zone_mf[k] = NULL; } - aFree(map[m].zone_mf); - map[m].zone_mf = NULL; - map[m].zone_mf_count = 0; + aFree(maplist[m].zone_mf); + maplist[m].zone_mf = NULL; + maplist[m].zone_mf_count = 0; } static inline void map_zone_mf_cache_add(int m, char *rflag) { - RECREATE(map[m].zone_mf, char *, ++map[m].zone_mf_count); - CREATE(map[m].zone_mf[map[m].zone_mf_count - 1], char, MAP_ZONE_MAPFLAG_LENGTH); - safestrncpy(map[m].zone_mf[map[m].zone_mf_count - 1], rflag, MAP_ZONE_MAPFLAG_LENGTH); + RECREATE(maplist[m].zone_mf, char *, ++maplist[m].zone_mf_count); + CREATE(maplist[m].zone_mf[maplist[m].zone_mf_count - 1], char, MAP_ZONE_MAPFLAG_LENGTH); + safestrncpy(maplist[m].zone_mf[maplist[m].zone_mf_count - 1], rflag, MAP_ZONE_MAPFLAG_LENGTH); } /* TODO: introduce enumerations to each mapflag so instead of reading the string a number of times we read it only once and use its value wherever we need */ /* cache previous values to revert */ @@ -3576,518 +3565,518 @@ bool map_zone_mf_cache(int m, char *flag, char *params) { state = 0; if (!strcmpi(flag, "nosave")) { - ;/* not yet supported to be reversed */ - /* +#if 0 /* not yet supported to be reversed */ char savemap[32]; int savex, savey; if (state == 0) { - if( map[m].flag.nosave ) { - sprintf(rflag, "nosave SavePoint"); - map_zone_mf_cache_add(m,nosave); - } + if( maplist[m].flag.nosave ) { + sprintf(rflag, "nosave\tSavePoint"); + map_zone_mf_cache_add(m,nosave); + } } else if (!strcmpi(params, "SavePoint")) { - if( map[m].save.map ) { - sprintf(rflag, "nosave %s,%d,%d",mapindex_id2name(map[m].save.map),map[m].save.x,map[m].save.y); - } else - sprintf(rflag, "nosave %s,%d,%d",mapindex_id2name(map[m].save.map),map[m].save.x,map[m].save.y); - map_zone_mf_cache_add(m,nosave); + if( maplist[m].save.map ) { + sprintf(rflag, "nosave\t%s,%d,%d",mapindex_id2name(maplist[m].save.map),maplist[m].save.x,maplist[m].save.y); + } else + sprintf(rflag, "nosave\t%s,%d,%d",mapindex_id2name(maplist[m].save.map),maplist[m].save.x,maplist[m].save.y); + map_zone_mf_cache_add(m,nosave); } else if (sscanf(params, "%31[^,],%d,%d", savemap, &savex, &savey) == 3) { - if( map[m].save.map ) { - sprintf(rflag, "nosave %s,%d,%d",mapindex_id2name(map[m].save.map),map[m].save.x,map[m].save.y); - map_zone_mf_cache_add(m,nosave); + if( maplist[m].save.map ) { + sprintf(rflag, "nosave\t%s,%d,%d",mapindex_id2name(maplist[m].save.map),maplist[m].save.x,maplist[m].save.y); + map_zone_mf_cache_add(m,nosave); + } } - }*/ +#endif // 0 } else if (!strcmpi(flag,"autotrade")) { - if( state && map[m].flag.autotrade ) + if( state && maplist[m].flag.autotrade ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"autotrade off"); - else if( !map[m].flag.autotrade ) + map_zone_mf_cache_add(m,"autotrade\toff"); + else if( !maplist[m].flag.autotrade ) map_zone_mf_cache_add(m,"autotrade"); } } else if (!strcmpi(flag,"allowks")) { - if( state && map[m].flag.allowks ) + if( state && maplist[m].flag.allowks ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"allowks off"); - else if( !map[m].flag.allowks ) + map_zone_mf_cache_add(m,"allowks\toff"); + else if( !maplist[m].flag.allowks ) map_zone_mf_cache_add(m,"allowks"); } } else if (!strcmpi(flag,"town")) { - if( state && map[m].flag.town ) + if( state && maplist[m].flag.town ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"town off"); - else if( !map[m].flag.town ) + map_zone_mf_cache_add(m,"town\toff"); + else if( !maplist[m].flag.town ) map_zone_mf_cache_add(m,"town"); } } else if (!strcmpi(flag,"nomemo")) { - if( state && map[m].flag.nomemo ) + if( state && maplist[m].flag.nomemo ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"nomemo off"); - else if( !map[m].flag.nomemo ) + map_zone_mf_cache_add(m,"nomemo\toff"); + else if( !maplist[m].flag.nomemo ) map_zone_mf_cache_add(m,"nomemo"); } } else if (!strcmpi(flag,"noteleport")) { - if( state && map[m].flag.noteleport ) + if( state && maplist[m].flag.noteleport ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"noteleport off"); - else if( !map[m].flag.noteleport ) + map_zone_mf_cache_add(m,"noteleport\toff"); + else if( !maplist[m].flag.noteleport ) map_zone_mf_cache_add(m,"noteleport"); } } else if (!strcmpi(flag,"nowarp")) { - if( state && map[m].flag.nowarp ) + if( state && maplist[m].flag.nowarp ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"nowarp off"); - else if( !map[m].flag.nowarp ) + map_zone_mf_cache_add(m,"nowarp\toff"); + else if( !maplist[m].flag.nowarp ) map_zone_mf_cache_add(m,"nowarp"); } } else if (!strcmpi(flag,"nowarpto")) { - if( state && map[m].flag.nowarpto ) + if( state && maplist[m].flag.nowarpto ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"nowarpto off"); - else if( !map[m].flag.nowarpto ) + map_zone_mf_cache_add(m,"nowarpto\toff"); + else if( !maplist[m].flag.nowarpto ) map_zone_mf_cache_add(m,"nowarpto"); } } else if (!strcmpi(flag,"noreturn")) { - if( state && map[m].flag.noreturn ) + if( state && maplist[m].flag.noreturn ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"noreturn off"); - else if( map[m].flag.noreturn ) + map_zone_mf_cache_add(m,"noreturn\toff"); + else if( maplist[m].flag.noreturn ) map_zone_mf_cache_add(m,"noreturn"); } } else if (!strcmpi(flag,"monster_noteleport")) { - if( state && map[m].flag.monster_noteleport ) + if( state && maplist[m].flag.monster_noteleport ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"monster_noteleport off"); - else if( map[m].flag.monster_noteleport ) + map_zone_mf_cache_add(m,"monster_noteleport\toff"); + else if( maplist[m].flag.monster_noteleport ) map_zone_mf_cache_add(m,"monster_noteleport"); } } else if (!strcmpi(flag,"nobranch")) { - if( state && map[m].flag.nobranch ) + if( state && maplist[m].flag.nobranch ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"nobranch off"); - else if( map[m].flag.nobranch ) + map_zone_mf_cache_add(m,"nobranch\toff"); + else if( maplist[m].flag.nobranch ) map_zone_mf_cache_add(m,"nobranch"); } } else if (!strcmpi(flag,"nopenalty")) { - if( state && map[m].flag.noexppenalty ) /* they are applied together, no need to check both */ + if( state && maplist[m].flag.noexppenalty ) /* they are applied together, no need to check both */ ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"nopenalty off"); - else if( map[m].flag.noexppenalty ) + map_zone_mf_cache_add(m,"nopenalty\toff"); + else if( maplist[m].flag.noexppenalty ) map_zone_mf_cache_add(m,"nopenalty"); } } else if (!strcmpi(flag,"pvp")) { - if( state && map[m].flag.pvp ) + if( state && maplist[m].flag.pvp ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"pvp off"); - else if( map[m].flag.pvp ) + map_zone_mf_cache_add(m,"pvp\toff"); + else if( maplist[m].flag.pvp ) map_zone_mf_cache_add(m,"pvp"); } } else if (!strcmpi(flag,"pvp_noparty")) { - if( state && map[m].flag.pvp_noparty ) + if( state && maplist[m].flag.pvp_noparty ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"pvp_noparty off"); - else if( map[m].flag.pvp_noparty ) + map_zone_mf_cache_add(m,"pvp_noparty\toff"); + else if( maplist[m].flag.pvp_noparty ) map_zone_mf_cache_add(m,"pvp_noparty"); } } else if (!strcmpi(flag,"pvp_noguild")) { - if( state && map[m].flag.pvp_noguild ) + if( state && maplist[m].flag.pvp_noguild ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"pvp_noguild off"); - else if( map[m].flag.pvp_noguild ) + map_zone_mf_cache_add(m,"pvp_noguild\toff"); + else if( maplist[m].flag.pvp_noguild ) map_zone_mf_cache_add(m,"pvp_noguild"); } } else if (!strcmpi(flag, "pvp_nightmaredrop")) { - if( state && map[m].flag.pvp_nightmaredrop ) + if( state && maplist[m].flag.pvp_nightmaredrop ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"pvp_nightmaredrop off"); - else if( map[m].flag.pvp_nightmaredrop ) + map_zone_mf_cache_add(m,"pvp_nightmaredrop\toff"); + else if( maplist[m].flag.pvp_nightmaredrop ) map_zone_mf_cache_add(m,"pvp_nightmaredrop"); } - /* not yet fully supported */ - /*char drop_arg1[16], drop_arg2[16]; +#if 0 /* not yet fully supported */ + char drop_arg1[16], drop_arg2[16]; int drop_per = 0; if (sscanf(w4, "%[^,],%[^,],%d", drop_arg1, drop_arg2, &drop_per) == 3) { - int drop_id = 0, drop_type = 0; - if (!strcmpi(drop_arg1, "random")) - drop_id = -1; - else if (itemdb->exists((drop_id = atoi(drop_arg1))) == NULL) - drop_id = 0; - if (!strcmpi(drop_arg2, "inventory")) - drop_type = 1; - else if (!strcmpi(drop_arg2,"equip")) - drop_type = 2; - else if (!strcmpi(drop_arg2,"all")) - drop_type = 3; - - if (drop_id != 0){ - int i; - for (i = 0; i < MAX_DROP_PER_MAP; i++) { - if (map[m].drop_list[i].drop_id == 0){ - map[m].drop_list[i].drop_id = drop_id; - map[m].drop_list[i].drop_type = drop_type; - map[m].drop_list[i].drop_per = drop_per; - break; - } - } - map[m].flag.pvp_nightmaredrop = 1; - } + int drop_id = 0, drop_type = 0; + if (!strcmpi(drop_arg1, "random")) + drop_id = -1; + else if (itemdb->exists((drop_id = atoi(drop_arg1))) == NULL) + drop_id = 0; + if (!strcmpi(drop_arg2, "inventory")) + drop_type = 1; + else if (!strcmpi(drop_arg2,"equip")) + drop_type = 2; + else if (!strcmpi(drop_arg2,"all")) + drop_type = 3; + + if (drop_id != 0) { + int i; + for (i = 0; i < MAX_DROP_PER_MAP; i++) { + if (maplist[m].drop_list[i].drop_id == 0){ + maplist[m].drop_list[i].drop_id = drop_id; + maplist[m].drop_list[i].drop_type = drop_type; + maplist[m].drop_list[i].drop_per = drop_per; + break; + } + } + maplist[m].flag.pvp_nightmaredrop = 1; + } } else if (!state) //Disable - map[m].flag.pvp_nightmaredrop = 0; - */ + maplist[m].flag.pvp_nightmaredrop = 0; +#endif // 0 } else if (!strcmpi(flag,"pvp_nocalcrank")) { - if( state && map[m].flag.pvp_nocalcrank ) + if( state && maplist[m].flag.pvp_nocalcrank ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"pvp_nocalcrank off"); - else if( map[m].flag.pvp_nocalcrank ) + map_zone_mf_cache_add(m,"pvp_nocalcrank\toff"); + else if( maplist[m].flag.pvp_nocalcrank ) map_zone_mf_cache_add(m,"pvp_nocalcrank"); } } else if (!strcmpi(flag,"gvg")) { - if( state && map[m].flag.gvg ) + if( state && maplist[m].flag.gvg ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"gvg off"); - else if( map[m].flag.gvg ) + map_zone_mf_cache_add(m,"gvg\toff"); + else if( maplist[m].flag.gvg ) map_zone_mf_cache_add(m,"gvg"); } } else if (!strcmpi(flag,"gvg_noparty")) { - if( state && map[m].flag.gvg_noparty ) + if( state && maplist[m].flag.gvg_noparty ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"gvg_noparty off"); - else if( map[m].flag.gvg_noparty ) + map_zone_mf_cache_add(m,"gvg_noparty\toff"); + else if( maplist[m].flag.gvg_noparty ) map_zone_mf_cache_add(m,"gvg_noparty"); } } else if (!strcmpi(flag,"gvg_dungeon")) { - if( state && map[m].flag.gvg_dungeon ) + if( state && maplist[m].flag.gvg_dungeon ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"gvg_dungeon off"); - else if( map[m].flag.gvg_dungeon ) + map_zone_mf_cache_add(m,"gvg_dungeon\toff"); + else if( maplist[m].flag.gvg_dungeon ) map_zone_mf_cache_add(m,"gvg_dungeon"); } } else if (!strcmpi(flag,"gvg_castle")) { - if( state && map[m].flag.gvg_castle ) + if( state && maplist[m].flag.gvg_castle ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"gvg_castle off"); - else if( map[m].flag.gvg_castle ) + map_zone_mf_cache_add(m,"gvg_castle\toff"); + else if( maplist[m].flag.gvg_castle ) map_zone_mf_cache_add(m,"gvg_castle"); } } else if (!strcmpi(flag,"battleground")) { - if( state && map[m].flag.battleground ) + if( state && maplist[m].flag.battleground ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"battleground off"); - else if( map[m].flag.battleground ) + map_zone_mf_cache_add(m,"battleground\toff"); + else if( maplist[m].flag.battleground ) map_zone_mf_cache_add(m,"battleground"); } } else if (!strcmpi(flag,"noexppenalty")) { - if( state && map[m].flag.noexppenalty ) + if( state && maplist[m].flag.noexppenalty ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"noexppenalty off"); - else if( map[m].flag.noexppenalty ) + map_zone_mf_cache_add(m,"noexppenalty\toff"); + else if( maplist[m].flag.noexppenalty ) map_zone_mf_cache_add(m,"noexppenalty"); } } else if (!strcmpi(flag,"nozenypenalty")) { - if( state && map[m].flag.nozenypenalty ) + if( state && maplist[m].flag.nozenypenalty ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"nozenypenalty off"); - else if( map[m].flag.nozenypenalty ) + map_zone_mf_cache_add(m,"nozenypenalty\toff"); + else if( maplist[m].flag.nozenypenalty ) map_zone_mf_cache_add(m,"nozenypenalty"); } } else if (!strcmpi(flag,"notrade")) { - if( state && map[m].flag.notrade ) + if( state && maplist[m].flag.notrade ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"notrade off"); - else if( map[m].flag.notrade ) + map_zone_mf_cache_add(m,"notrade\toff"); + else if( maplist[m].flag.notrade ) map_zone_mf_cache_add(m,"notrade"); } } else if (!strcmpi(flag,"novending")) { - if( state && map[m].flag.novending ) + if( state && maplist[m].flag.novending ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"novending off"); - else if( map[m].flag.novending ) + map_zone_mf_cache_add(m,"novending\toff"); + else if( maplist[m].flag.novending ) map_zone_mf_cache_add(m,"novending"); } } else if (!strcmpi(flag,"nodrop")) { - if( state && map[m].flag.nodrop ) + if( state && maplist[m].flag.nodrop ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"nodrop off"); - else if( map[m].flag.nodrop ) + map_zone_mf_cache_add(m,"nodrop\toff"); + else if( maplist[m].flag.nodrop ) map_zone_mf_cache_add(m,"nodrop"); } } else if (!strcmpi(flag,"noskill")) { - if( state && map[m].flag.noskill ) + if( state && maplist[m].flag.noskill ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"noskill off"); - else if( map[m].flag.noskill ) + map_zone_mf_cache_add(m,"noskill\toff"); + else if( maplist[m].flag.noskill ) map_zone_mf_cache_add(m,"noskill"); } } else if (!strcmpi(flag,"noicewall")) { - if( state && map[m].flag.noicewall ) + if( state && maplist[m].flag.noicewall ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"noicewall off"); - else if( map[m].flag.noicewall ) + map_zone_mf_cache_add(m,"noicewall\toff"); + else if( maplist[m].flag.noicewall ) map_zone_mf_cache_add(m,"noicewall"); } } else if (!strcmpi(flag,"snow")) { - if( state && map[m].flag.snow ) + if( state && maplist[m].flag.snow ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"snow off"); - else if( map[m].flag.snow ) + map_zone_mf_cache_add(m,"snow\toff"); + else if( maplist[m].flag.snow ) map_zone_mf_cache_add(m,"snow"); } } else if (!strcmpi(flag,"clouds")) { - if( state && map[m].flag.clouds ) + if( state && maplist[m].flag.clouds ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"clouds off"); - else if( map[m].flag.clouds ) + map_zone_mf_cache_add(m,"clouds\toff"); + else if( maplist[m].flag.clouds ) map_zone_mf_cache_add(m,"clouds"); } } else if (!strcmpi(flag,"clouds2")) { - if( state && map[m].flag.clouds2 ) + if( state && maplist[m].flag.clouds2 ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"clouds2 off"); - else if( map[m].flag.clouds2 ) + map_zone_mf_cache_add(m,"clouds2\toff"); + else if( maplist[m].flag.clouds2 ) map_zone_mf_cache_add(m,"clouds2"); } } else if (!strcmpi(flag,"fog")) { - if( state && map[m].flag.fog ) + if( state && maplist[m].flag.fog ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"fog off"); - else if( map[m].flag.fog ) + map_zone_mf_cache_add(m,"fog\toff"); + else if( maplist[m].flag.fog ) map_zone_mf_cache_add(m,"fog"); } } else if (!strcmpi(flag,"fireworks")) { - if( state && map[m].flag.fireworks ) + if( state && maplist[m].flag.fireworks ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"fireworks off"); - else if( map[m].flag.fireworks ) + map_zone_mf_cache_add(m,"fireworks\toff"); + else if( maplist[m].flag.fireworks ) map_zone_mf_cache_add(m,"fireworks"); } } else if (!strcmpi(flag,"sakura")) { - if( state && map[m].flag.sakura ) + if( state && maplist[m].flag.sakura ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"sakura off"); - else if( map[m].flag.sakura ) + map_zone_mf_cache_add(m,"sakura\toff"); + else if( maplist[m].flag.sakura ) map_zone_mf_cache_add(m,"sakura"); } } else if (!strcmpi(flag,"leaves")) { - if( state && map[m].flag.leaves ) + if( state && maplist[m].flag.leaves ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"leaves off"); - else if( map[m].flag.leaves ) + map_zone_mf_cache_add(m,"leaves\toff"); + else if( maplist[m].flag.leaves ) map_zone_mf_cache_add(m,"leaves"); } } else if (!strcmpi(flag,"nightenabled")) { - if( state && map[m].flag.nightenabled ) + if( state && maplist[m].flag.nightenabled ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"nightenabled off"); - else if( map[m].flag.nightenabled ) + map_zone_mf_cache_add(m,"nightenabled\toff"); + else if( maplist[m].flag.nightenabled ) map_zone_mf_cache_add(m,"nightenabled"); } } else if (!strcmpi(flag,"noexp")) { - if( state && map[m].flag.nobaseexp ) + if( state && maplist[m].flag.nobaseexp ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"noexp off"); - else if( map[m].flag.nobaseexp ) + map_zone_mf_cache_add(m,"noexp\toff"); + else if( maplist[m].flag.nobaseexp ) map_zone_mf_cache_add(m,"noexp"); } } else if (!strcmpi(flag,"nobaseexp")) { - if( state && map[m].flag.nobaseexp ) + if( state && maplist[m].flag.nobaseexp ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"nobaseexp off"); - else if( map[m].flag.nobaseexp ) + map_zone_mf_cache_add(m,"nobaseexp\toff"); + else if( maplist[m].flag.nobaseexp ) map_zone_mf_cache_add(m,"nobaseexp"); } } else if (!strcmpi(flag,"nojobexp")) { - if( state && map[m].flag.nojobexp ) + if( state && maplist[m].flag.nojobexp ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"nojobexp off"); - else if( map[m].flag.nojobexp ) + map_zone_mf_cache_add(m,"nojobexp\toff"); + else if( maplist[m].flag.nojobexp ) map_zone_mf_cache_add(m,"nojobexp"); } } else if (!strcmpi(flag,"noloot")) { - if( state && map[m].flag.nomobloot ) + if( state && maplist[m].flag.nomobloot ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"noloot off"); - else if( map[m].flag.nomobloot ) + map_zone_mf_cache_add(m,"noloot\toff"); + else if( maplist[m].flag.nomobloot ) map_zone_mf_cache_add(m,"noloot"); } } else if (!strcmpi(flag,"nomobloot")) { - if( state && map[m].flag.nomobloot ) + if( state && maplist[m].flag.nomobloot ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"nomobloot off"); - else if( map[m].flag.nomobloot ) + map_zone_mf_cache_add(m,"nomobloot\toff"); + else if( maplist[m].flag.nomobloot ) map_zone_mf_cache_add(m,"nomobloot"); } } else if (!strcmpi(flag,"nomvploot")) { - if( state && map[m].flag.nomvploot ) + if( state && maplist[m].flag.nomvploot ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"nomvploot off"); - else if( map[m].flag.nomvploot ) + map_zone_mf_cache_add(m,"nomvploot\toff"); + else if( maplist[m].flag.nomvploot ) map_zone_mf_cache_add(m,"nomvploot"); } } else if (!strcmpi(flag,"nocommand")) { /* implementation may be incomplete */ if( state && sscanf(params, "%d", &state) == 1 ) { - sprintf(rflag, "nocommand %s",params); + sprintf(rflag, "nocommand\t%s",params); map_zone_mf_cache_add(m,rflag); - } else if( !state && map[m].nocommand ) { - sprintf(rflag, "nocommand %d",map[m].nocommand); + } else if( !state && maplist[m].nocommand ) { + sprintf(rflag, "nocommand\t%d",maplist[m].nocommand); map_zone_mf_cache_add(m,rflag); - } else if( map[m].nocommand ) { - map_zone_mf_cache_add(m,"nocommand off"); + } else if( maplist[m].nocommand ) { + map_zone_mf_cache_add(m,"nocommand\toff"); } } else if (!strcmpi(flag,"jexp")) { if( !state ) { - if( map[m].jexp != 100 ) { - sprintf(rflag,"jexp %d",map[m].jexp); + if( maplist[m].jexp != 100 ) { + sprintf(rflag,"jexp\t%d",maplist[m].jexp); map_zone_mf_cache_add(m,rflag); } } if( sscanf(params, "%d", &state) == 1 ) { - if( state != map[m].jexp ) { - sprintf(rflag,"jexp %s",params); + if( state != maplist[m].jexp ) { + sprintf(rflag,"jexp\t%s",params); map_zone_mf_cache_add(m,rflag); } } } else if (!strcmpi(flag,"bexp")) { if( !state ) { - if( map[m].bexp != 100 ) { - sprintf(rflag,"bexp %d",map[m].jexp); + if( maplist[m].bexp != 100 ) { + sprintf(rflag,"bexp\t%d",maplist[m].jexp); map_zone_mf_cache_add(m,rflag); } } if( sscanf(params, "%d", &state) == 1 ) { - if( state != map[m].bexp ) { - sprintf(rflag,"bexp %s",params); + if( state != maplist[m].bexp ) { + sprintf(rflag,"bexp\t%s",params); map_zone_mf_cache_add(m,rflag); } } } else if (!strcmpi(flag,"loadevent")) { - if( state && map[m].flag.loadevent ) + if( state && maplist[m].flag.loadevent ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"loadevent off"); - else if( map[m].flag.loadevent ) + map_zone_mf_cache_add(m,"loadevent\toff"); + else if( maplist[m].flag.loadevent ) map_zone_mf_cache_add(m,"loadevent"); } } else if (!strcmpi(flag,"nochat")) { - if( state && map[m].flag.nochat ) + if( state && maplist[m].flag.nochat ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"nochat off"); - else if( map[m].flag.nochat ) + map_zone_mf_cache_add(m,"nochat\toff"); + else if( maplist[m].flag.nochat ) map_zone_mf_cache_add(m,"nochat"); } } else if (!strcmpi(flag,"partylock")) { - if( state && map[m].flag.partylock ) + if( state && maplist[m].flag.partylock ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"partylock off"); - else if( map[m].flag.partylock ) + map_zone_mf_cache_add(m,"partylock\toff"); + else if( maplist[m].flag.partylock ) map_zone_mf_cache_add(m,"partylock"); } } else if (!strcmpi(flag,"guildlock")) { - if( state && map[m].flag.guildlock ) + if( state && maplist[m].flag.guildlock ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"guildlock off"); - else if( map[m].flag.guildlock ) + map_zone_mf_cache_add(m,"guildlock\toff"); + else if( maplist[m].flag.guildlock ) map_zone_mf_cache_add(m,"guildlock"); } } else if (!strcmpi(flag,"reset")) { - if( state && map[m].flag.reset ) + if( state && maplist[m].flag.reset ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"reset off"); - else if( map[m].flag.reset ) + map_zone_mf_cache_add(m,"reset\toff"); + else if( maplist[m].flag.reset ) map_zone_mf_cache_add(m,"reset"); } } else if (!strcmpi(flag,"adjust_unit_duration")) { @@ -4109,20 +4098,20 @@ bool map_zone_mf_cache(int m, char *flag, char *params) { if( modifier[0] == '\0' || !( skill_id = skill->name2id(skill_name) ) || !skill->get_unit_id( skill->name2id(skill_name), 0) || atoi(modifier) < 1 || atoi(modifier) > USHRT_MAX ) { ;/* we dont mind it, the server will take care of it next. */ } else { - int idx = map[m].unit_count; + int idx = maplist[m].unit_count; k = 0; - ARR_FIND(0, idx, k, map[m].units[k]->skill_id == skill_id); + ARR_FIND(0, idx, k, maplist[m].units[k]->skill_id == skill_id); if( k < idx ) { - if( atoi(modifier) != map[m].units[k]->modifier ) { - sprintf(rflag,"adjust_unit_duration %s %d",skill_name,map[m].units[k]->modifier); + if( atoi(modifier) != maplist[m].units[k]->modifier ) { + sprintf(rflag,"adjust_unit_duration\t%s\t%d",skill_name,maplist[m].units[k]->modifier); map_zone_mf_cache_add(m,rflag); } } else { - sprintf(rflag,"adjust_unit_duration %s 100",skill_name); + sprintf(rflag,"adjust_unit_duration\t%s\t100",skill_name); map_zone_mf_cache_add(m,rflag); - } + } } } else if (!strcmpi(flag,"adjust_skill_damage")) { int skill_id, k; @@ -4143,112 +4132,112 @@ bool map_zone_mf_cache(int m, char *flag, char *params) { if( modifier[0] == '\0' || !( skill_id = skill->name2id(skill_name) ) || atoi(modifier) < 1 || atoi(modifier) > USHRT_MAX ) { ;/* we dont mind it, the server will take care of it next. */ } else { - int idx = map[m].skill_count; + int idx = maplist[m].skill_count; k = 0; - ARR_FIND(0, idx, k, map[m].skills[k]->skill_id == skill_id); + ARR_FIND(0, idx, k, maplist[m].skills[k]->skill_id == skill_id); if( k < idx ) { - if( atoi(modifier) != map[m].skills[k]->modifier ) { - sprintf(rflag,"adjust_skill_damage %s %d",skill_name,map[m].skills[k]->modifier); + if( atoi(modifier) != maplist[m].skills[k]->modifier ) { + sprintf(rflag,"adjust_skill_damage\t%s\t%d",skill_name,maplist[m].skills[k]->modifier); map_zone_mf_cache_add(m,rflag); } } else { - sprintf(rflag,"adjust_skill_damage %s 100",skill_name); + sprintf(rflag,"adjust_skill_damage\t%s\t100",skill_name); map_zone_mf_cache_add(m,rflag); } } } else if (!strcmpi(flag,"zone")) { - ShowWarning("You can't add a zone through a zone! ERROR, skipping for '%s'...\n",map[m].name); + ShowWarning("You can't add a zone through a zone! ERROR, skipping for '%s'...\n",maplist[m].name); return true; } else if ( !strcmpi(flag,"nomapchannelautojoin") ) { - if( state && map[m].flag.chsysnolocalaj ) + if( state && maplist[m].flag.chsysnolocalaj ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"nomapchannelautojoin off"); - else if( map[m].flag.chsysnolocalaj ) + map_zone_mf_cache_add(m,"nomapchannelautojoin\toff"); + else if( maplist[m].flag.chsysnolocalaj ) map_zone_mf_cache_add(m,"nomapchannelautojoin"); } } else if ( !strcmpi(flag,"invincible_time_inc") ) { if( !state ) { - if( map[m].invincible_time_inc != 0 ) { - sprintf(rflag,"invincible_time_inc %d",map[m].invincible_time_inc); + if( maplist[m].invincible_time_inc != 0 ) { + sprintf(rflag,"invincible_time_inc\t%d",maplist[m].invincible_time_inc); map_zone_mf_cache_add(m,rflag); } } if( sscanf(params, "%d", &state) == 1 ) { - if( state != map[m].invincible_time_inc ) { - sprintf(rflag,"invincible_time_inc %s",params); + if( state != maplist[m].invincible_time_inc ) { + sprintf(rflag,"invincible_time_inc\t%s",params); map_zone_mf_cache_add(m,rflag); } } } else if ( !strcmpi(flag,"noknockback") ) { - if( state && map[m].flag.noknockback ) + if( state && maplist[m].flag.noknockback ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"noknockback off"); - else if( map[m].flag.noknockback ) + map_zone_mf_cache_add(m,"noknockback\toff"); + else if( maplist[m].flag.noknockback ) map_zone_mf_cache_add(m,"noknockback"); } } else if ( !strcmpi(flag,"weapon_damage_rate") ) { if( !state ) { - if( map[m].weapon_damage_rate != 100 ) { - sprintf(rflag,"weapon_damage_rate %d",map[m].weapon_damage_rate); + if( maplist[m].weapon_damage_rate != 100 ) { + sprintf(rflag,"weapon_damage_rate\t%d",maplist[m].weapon_damage_rate); map_zone_mf_cache_add(m,rflag); } } if( sscanf(params, "%d", &state) == 1 ) { - if( state != map[m].weapon_damage_rate ) { - sprintf(rflag,"weapon_damage_rate %s",params); + if( state != maplist[m].weapon_damage_rate ) { + sprintf(rflag,"weapon_damage_rate\t%s",params); map_zone_mf_cache_add(m,rflag); } } } else if ( !strcmpi(flag,"magic_damage_rate") ) { if( !state ) { - if( map[m].magic_damage_rate != 100 ) { - sprintf(rflag,"magic_damage_rate %d",map[m].magic_damage_rate); + if( maplist[m].magic_damage_rate != 100 ) { + sprintf(rflag,"magic_damage_rate\t%d",maplist[m].magic_damage_rate); map_zone_mf_cache_add(m,rflag); } } if( sscanf(params, "%d", &state) == 1 ) { - if( state != map[m].magic_damage_rate ) { - sprintf(rflag,"magic_damage_rate %s",params); + if( state != maplist[m].magic_damage_rate ) { + sprintf(rflag,"magic_damage_rate\t%s",params); map_zone_mf_cache_add(m,rflag); } } } else if ( !strcmpi(flag,"misc_damage_rate") ) { if( !state ) { - if( map[m].misc_damage_rate != 100 ) { - sprintf(rflag,"misc_damage_rate %d",map[m].misc_damage_rate); + if( maplist[m].misc_damage_rate != 100 ) { + sprintf(rflag,"misc_damage_rate\t%d",maplist[m].misc_damage_rate); map_zone_mf_cache_add(m,rflag); } } if( sscanf(params, "%d", &state) == 1 ) { - if( state != map[m].misc_damage_rate ) { - sprintf(rflag,"misc_damage_rate %s",params); + if( state != maplist[m].misc_damage_rate ) { + sprintf(rflag,"misc_damage_rate\t%s",params); map_zone_mf_cache_add(m,rflag); } } } else if ( !strcmpi(flag,"short_damage_rate") ) { if( !state ) { - if( map[m].short_damage_rate != 100 ) { - sprintf(rflag,"short_damage_rate %d",map[m].short_damage_rate); + if( maplist[m].short_damage_rate != 100 ) { + sprintf(rflag,"short_damage_rate\t%d",maplist[m].short_damage_rate); map_zone_mf_cache_add(m,rflag); } } if( sscanf(params, "%d", &state) == 1 ) { - if( state != map[m].short_damage_rate ) { - sprintf(rflag,"short_damage_rate %s",params); + if( state != maplist[m].short_damage_rate ) { + sprintf(rflag,"short_damage_rate\t%s",params); map_zone_mf_cache_add(m,rflag); } } } else if ( !strcmpi(flag,"long_damage_rate") ) { if( !state ) { - if( map[m].long_damage_rate != 100 ) { - sprintf(rflag,"long_damage_rate %d",map[m].long_damage_rate); + if( maplist[m].long_damage_rate != 100 ) { + sprintf(rflag,"long_damage_rate\t%d",maplist[m].long_damage_rate); map_zone_mf_cache_add(m,rflag); } } if( sscanf(params, "%d", &state) == 1 ) { - if( state != map[m].long_damage_rate ) { - sprintf(rflag,"long_damage_rate %s",params); + if( state != maplist[m].long_damage_rate ) { + sprintf(rflag,"long_damage_rate\t%s",params); map_zone_mf_cache_add(m,rflag); } } @@ -4259,7 +4248,7 @@ void map_zone_apply(int m, struct map_zone_data *zone, const char* start, const int i; char empty[1] = "\0"; char flag[MAP_ZONE_MAPFLAG_LENGTH], params[MAP_ZONE_MAPFLAG_LENGTH]; - map[m].zone = zone; + maplist[m].zone = zone; for(i = 0; i < zone->mapflags_count; i++) { int len = strlen(zone->mapflags[i]); int k; @@ -4276,7 +4265,7 @@ void map_zone_apply(int m, struct map_zone_data *zone, const char* start, const if( map_zone_mf_cache(m,flag,params) ) continue; - npc->parse_mapflag(map[m].name,empty,flag,params,start,buffer,filepath); + npc->parse_mapflag(maplist[m].name,empty,flag,params,start,buffer,filepath); } } /* used on npc load and reload to apply all "Normal" and "PK Mode" zones */ @@ -4301,10 +4290,10 @@ void map_zone_init(void) { } for(j = 0; j < iMap->map_num; j++) { - if( map[j].zone == zone ) { + if( maplist[j].zone == zone ) { if( map_zone_mf_cache(j,flag,params) ) break; - npc->parse_mapflag(map[j].name,empty,flag,params,empty,empty,empty); + npc->parse_mapflag(maplist[j].name,empty,flag,params,empty,empty,empty); } } } @@ -4323,10 +4312,10 @@ void map_zone_init(void) { } } for(j = 0; j < iMap->map_num; j++) { - if( map[j].zone == zone ) { + if( maplist[j].zone == zone ) { if( map_zone_mf_cache(j,flag,params) ) break; - npc->parse_mapflag(map[j].name,empty,flag,params,empty,empty,empty); + npc->parse_mapflag(maplist[j].name,empty,flag,params,empty,empty,empty); } } } @@ -4590,7 +4579,7 @@ void read_map_zone_db(void) { entry->group_lv = group_lv; zone->disabled_commands[v++] = entry; - } + } } zone->disabled_commands_count = disabled_commands_count; } @@ -4630,7 +4619,7 @@ void read_map_zone_db(void) { } } zone->capped_skills_count = capped_skills_count; - } + } if( !is_all ) /* global template doesn't go into db -- since it isn't a alloc'd piece of data */ strdb_put(zone_db, zonename, zone); @@ -4910,8 +4899,8 @@ void do_final(void) // remove all objects on maps for (i = 0; i < iMap->map_num; i++) { - ShowStatus("Cleaning up maps [%d/%d]: %s..."CL_CLL"\r", i+1, iMap->map_num, map[i].name); - if (map[i].m >= 0) + ShowStatus("Cleaning up maps [%d/%d]: %s..."CL_CLL"\r", i+1, iMap->map_num, maplist[i].name); + if (maplist[i].m >= 0) map_foreachinmap(iMap->cleanup_sub, i, BL_ALL); } ShowStatus("Cleaned up %d maps."CL_CLL"\n", iMap->map_num); @@ -4964,7 +4953,7 @@ void do_final(void) map_sql_close(); ers_destroy(map_iterator_ers); - aFree(map); + aFree(maplist); if( !enable_grf ) aFree(map_cache_buffer); @@ -5088,7 +5077,7 @@ CPCMD(gm_position) { return; } - if( x < 0 || x >= map[m].xs || y < 0 || y >= map[m].ys ) { + if( x < 0 || x >= maplist[m].xs || y < 0 || y >= maplist[m].ys ) { ShowError("gm:info '"CL_WHITE"%d %d"CL_RESET"' is out of '"CL_WHITE"%s"CL_RESET"' map bounds!\n",x,y,map_name); return; } @@ -5178,7 +5167,7 @@ void map_hp_symbols(void) { HPM->share(HPM_map_getFromMSD,"getFromMSD"); HPM->share(HPM_map_removeFromMSD,"removeFromMSD"); /* vars */ - HPM->share(map,"map"); + HPM->share(maplist,"maplist"); } void map_load_defaults(void) { @@ -5331,7 +5320,7 @@ int do_init(int argc, char *argv[]) map_load_defaults(); map_config_read(iMap->MAP_CONF_NAME); - CREATE(map,struct map_data,iMap->map_num); + CREATE(maplist,struct map_data,iMap->map_num); iMap->map_num = 0; map_config_read_sub(iMap->MAP_CONF_NAME); // loads npcs @@ -5565,7 +5554,7 @@ void map_defaults(void) { iMap->do_shutdown = do_shutdown; - /* temporary until the map.c "Hercules Renewal Phase One" design is complete. [Ind] */ + /* FIXME: temporary until the map.c "Hercules Renewal Phase One" design is complete. [Ind] */ mapit = &mapit_s; mapit->alloc = mapit_alloc; diff --git a/src/map/map.h b/src/map/map.h index e2d5261b0..963234ff3 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -214,13 +214,13 @@ enum { #define EVENT_NAME_LENGTH ( NAME_LENGTH * 2 + 3 ) #define DEFAULT_AUTOSAVE_INTERVAL 5*60*1000 // Specifies maps where players may hit each other -#define map_flag_vs(m) (map[m].flag.pvp || map[m].flag.gvg_dungeon || map[m].flag.gvg || ((iMap->agit_flag || iMap->agit2_flag) && map[m].flag.gvg_castle) || map[m].flag.battleground) +#define map_flag_vs(m) (maplist[m].flag.pvp || maplist[m].flag.gvg_dungeon || maplist[m].flag.gvg || ((iMap->agit_flag || iMap->agit2_flag) && maplist[m].flag.gvg_castle) || maplist[m].flag.battleground) // Specifies maps that have special GvG/WoE restrictions -#define map_flag_gvg(m) (map[m].flag.gvg || ((iMap->agit_flag || iMap->agit2_flag) && map[m].flag.gvg_castle)) +#define map_flag_gvg(m) (maplist[m].flag.gvg || ((iMap->agit_flag || iMap->agit2_flag) && maplist[m].flag.gvg_castle)) // Specifies if the map is tagged as GvG/WoE (regardless of iMap->agit_flag status) -#define map_flag_gvg2(m) (map[m].flag.gvg || map[m].flag.gvg_castle) +#define map_flag_gvg2(m) (maplist[m].flag.gvg || maplist[m].flag.gvg_castle) // No Kill Steal Protection -#define map_flag_ks(m) (map[m].flag.town || map[m].flag.pvp || map[m].flag.gvg || map[m].flag.battleground) +#define map_flag_ks(m) (maplist[m].flag.town || maplist[m].flag.pvp || maplist[m].flag.gvg || maplist[m].flag.battleground) //This stackable implementation does not means a BL can be more than one type at a time, but it's // meant to make it easier to check for multiple types at a time on invocations such as map_foreach* calls [Skotlex] @@ -696,9 +696,9 @@ struct map_data_other_server { }; -struct map_data *map; +struct map_data *maplist; -#define map_id2index(id) map[(id)].index +#define map_id2index(id) maplist[(id)].index /// Bitfield of flags for the iterator. enum e_mapitflags { @@ -868,8 +868,8 @@ struct map_interface { int16 (*mapindex2mapid) (unsigned short mapindex); int16 (*mapname2mapid) (const char* name); int (*mapname2ipport) (unsigned short name, uint32* ip, uint16* port); - int (*setipport) (unsigned short map, uint32 ip, uint16 port); - int (*eraseipport) (unsigned short map, uint32 ip, uint16 port); + int (*setipport) (unsigned short mapindex, uint32 ip, uint16 port); + int (*eraseipport) (unsigned short mapindex, uint32 ip, uint16 port); int (*eraseallipport) (void); void (*addiddb) (struct block_list *); void (*deliddb) (struct block_list *bl); diff --git a/src/map/mob.c b/src/map/mob.c index 32bf3d72a..ceb00a6ce 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -173,11 +173,11 @@ void mvptomb_destroy(struct mob_data *md) { iMap->delblock(&nd->bl); - ARR_FIND( 0, map[m].npc_num, i, map[m].npc[i] == nd ); - if( !(i == map[m].npc_num) ) { - map[m].npc_num--; - map[m].npc[i] = map[m].npc[map[m].npc_num]; - map[m].npc[map[m].npc_num] = NULL; + ARR_FIND( 0, maplist[m].npc_num, i, maplist[m].npc[i] == nd ); + if( !(i == maplist[m].npc_num) ) { + maplist[m].npc_num--; + maplist[m].npc[i] = maplist[m].npc[maplist[m].npc_num]; + maplist[m].npc[maplist[m].npc_num] = NULL; } iMap->deliddb(&nd->bl); @@ -363,7 +363,7 @@ bool mob_ksprotected (struct block_list *src, struct block_list *target) t_sd = BL_CAST(BL_PC,s_bl); do { - if( map[md->bl.m].flag.allowks || map_flag_ks(md->bl.m) ) + if( maplist[md->bl.m].flag.allowks || map_flag_ks(md->bl.m) ) return false; // Ignores GVG, PVP and AllowKS map flags if( md->db->mexp || md->master_id ) @@ -635,19 +635,15 @@ int mob_spawn_guardian(const char* mapname, short x, short y, const char* mobnam data.class_ = class_; - if( !has_index ) - { + if( !has_index ) { guardian = -1; - } - else if( guardian < 0 || guardian >= MAX_GUARDIANS ) - { - ShowError("mob_spawn_guardian: Invalid guardian index %d for guardian %d (castle map %s)\n", guardian, class_, map[m].name); + } else if( guardian < 0 || guardian >= MAX_GUARDIANS ) { + ShowError("mob_spawn_guardian: Invalid guardian index %d for guardian %d (castle map %s)\n", guardian, class_, maplist[m].name); return 0; } - if((x<=0 || y<=0) && !iMap->search_freecell(NULL, m, &x, &y, -1,-1, 1)) - { - ShowWarning("mob_spawn_guardian: Couldn't locate a spawn cell for guardian class %d (index %d) at castle map %s\n",class_, guardian, map[m].name); + if((x<=0 || y<=0) && !iMap->search_freecell(NULL, m, &x, &y, -1,-1, 1)) { + ShowWarning("mob_spawn_guardian: Couldn't locate a spawn cell for guardian class %d (index %d) at castle map %s\n",class_, guardian, maplist[m].name); return 0; } data.x = x; @@ -657,24 +653,24 @@ int mob_spawn_guardian(const char* mapname, short x, short y, const char* mobnam if (!mob->parse_dataset(&data)) return 0; - gc=guild->mapname2gc(map[m].name); - if (gc == NULL) - { - ShowError("mob_spawn_guardian: No castle set at map %s\n", map[m].name); + gc=guild->mapname2gc(maplist[m].name); + if (gc == NULL) { + ShowError("mob_spawn_guardian: No castle set at map %s\n", maplist[m].name); return 0; } if (!gc->guild_id) - ShowWarning("mob_spawn_guardian: Spawning guardian %d on a castle with no guild (castle map %s)\n", class_, map[m].name); + ShowWarning("mob_spawn_guardian: Spawning guardian %d on a castle with no guild (castle map %s)\n", class_, maplist[m].name); else g = guild->search(gc->guild_id); if( has_index && gc->guardian[guardian].id ) { //Check if guardian already exists, refuse to spawn if so. struct mob_data *md2 = (TBL_MOB*)iMap->id2bl(gc->guardian[guardian].id); - if (md2 && md2->bl.type == BL_MOB && - md2->guardian_data && md2->guardian_data->number == guardian) - { - ShowError("mob_spawn_guardian: Attempted to spawn guardian in position %d which already has a guardian (castle map %s)\n", guardian, map[m].name); + if (md2 && md2->bl.type == BL_MOB + && md2->guardian_data + && md2->guardian_data->number == guardian + ) { + ShowError("mob_spawn_guardian: Attempted to spawn guardian in position %d which already has a guardian (castle map %s)\n", guardian, maplist[m].name); return 0; } } @@ -736,9 +732,8 @@ int mob_spawn_bg(const char* mapname, short x, short y, const char* mobname, int } data.class_ = class_; - if( (x <= 0 || y <= 0) && !iMap->search_freecell(NULL, m, &x, &y, -1,-1, 1) ) - { - ShowWarning("mob_spawn_bg: Couldn't locate a spawn cell for guardian class %d (bg_id %d) at map %s\n",class_, bg_id, map[m].name); + if( (x <= 0 || y <= 0) && !iMap->search_freecell(NULL, m, &x, &y, -1,-1, 1) ) { + ShowWarning("mob_spawn_bg: Couldn't locate a spawn cell for guardian class %d (bg_id %d) at map %s\n",class_, bg_id, maplist[m].name); return 0; } @@ -971,7 +966,7 @@ int mob_spawn (struct mob_data *md) mob->mvptomb_destroy(md); iMap->addblock(&md->bl); - if( map[md->bl.m].users ) + if( maplist[md->bl.m].users ) clif->spawn(&md->bl); skill->unit_move(&md->bl,tick,1); mob->skill_use(md, tick, MSC_SPAWN); @@ -1076,7 +1071,7 @@ int mob_ai_sub_hard_activesearch(struct block_list *bl,va_list ap) battle->check_range(&md->bl,bl,md->db->range2) ) { //Pick closest target? - if( map[bl->m].icewall_num && + if( maplist[bl->m].icewall_num && !path->search_long(NULL,bl->m,md->bl.x,md->bl.y,bl->x,bl->y,CELL_CHKICEWALL) ) { if( !check_distance_bl(&md->bl, bl, status_get_range(&md->bl) ) ) @@ -1346,7 +1341,7 @@ int mob_randomwalk(struct mob_data *md,unsigned int tick) if(i==retrycount){ md->move_fail_count++; if(md->move_fail_count>1000){ - ShowWarning("MOB can't move. random spawn %d, class = %d, at %s (%d,%d)\n",md->bl.id,md->class_,map[md->bl.m].name, md->bl.x, md->bl.y); + ShowWarning("MOB can't move. random spawn %d, class = %d, at %s (%d,%d)\n",md->bl.id,md->class_,maplist[md->bl.m].name, md->bl.x, md->bl.y); md->move_fail_count=0; mob->spawn(md); } @@ -1696,7 +1691,7 @@ int mob_ai_sub_lazy(struct mob_data *md, va_list args) tick = va_arg(args,unsigned int); - if (battle_config.mob_ai&0x20 && map[md->bl.m].users>0) + if (battle_config.mob_ai&0x20 && maplist[md->bl.m].users>0) return (int)mob->ai_sub_hard(md, tick); if (md->bl.prev==NULL || md->status.hp == 0) @@ -1732,9 +1727,8 @@ int mob_ai_sub_lazy(struct mob_data *md, va_list args) return 0; } - if( DIFF_TICK(md->next_walktime,tick) < 0 && (status_get_mode(&md->bl)&MD_CANMOVE) && unit->can_move(&md->bl) ) - { - if( map[md->bl.m].users > 0 ) + if( DIFF_TICK(md->next_walktime,tick) < 0 && (status_get_mode(&md->bl)&MD_CANMOVE) && unit->can_move(&md->bl) ) { + if( maplist[md->bl.m].users > 0 ) { if( rnd()%1000 < MOB_LAZYMOVEPERC(md) ) mob->randomwalk(md, tick); @@ -2165,10 +2159,10 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) { } } - if(!(type&2) && //No exp - (!map[m].flag.pvp || battle_config.pvp_exp) && //Pvp no exp rule [MouseJstr] - (!md->master_id || !md->special_state.ai) && //Only player-summoned mobs do not give exp. [Skotlex] - (!map[m].flag.nobaseexp || !map[m].flag.nojobexp) //Gives Exp + if( !(type&2) //No exp + && (!maplist[m].flag.pvp || battle_config.pvp_exp) //Pvp no exp rule [MouseJstr] + && (!md->master_id || !md->special_state.ai) //Only player-summoned mobs do not give exp. [Skotlex] + && (!maplist[m].flag.nobaseexp || !maplist[m].flag.nojobexp) //Gives Exp ) { //Experience calculation. int bonus = 100; //Bonus on top of your share (common to all attackers). if (md->sc.data[SC_RICHMANKIM]) @@ -2230,15 +2224,15 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) { zeny*=rnd()%250; } - if (map[m].flag.nobaseexp || !md->db->base_exp) + if (maplist[m].flag.nobaseexp || !md->db->base_exp) base_exp = 0; else - base_exp = (unsigned int)cap_value(md->db->base_exp * per * bonus/100. * map[m].bexp/100., 1, UINT_MAX); + base_exp = (unsigned int)cap_value(md->db->base_exp * per * bonus/100. * maplist[m].bexp/100., 1, UINT_MAX); - if (map[m].flag.nojobexp || !md->db->job_exp || md->dmglog[i].flag == MDLF_HOMUN) //Homun earned job-exp is always lost. + if (maplist[m].flag.nojobexp || !md->db->job_exp || md->dmglog[i].flag == MDLF_HOMUN) //Homun earned job-exp is always lost. job_exp = 0; else - job_exp = (unsigned int)cap_value(md->db->job_exp * per * bonus/100. * map[m].jexp/100., 1, UINT_MAX); + job_exp = (unsigned int)cap_value(md->db->job_exp * per * bonus/100. * maplist[m].jexp/100., 1, UINT_MAX); if ( (temp = tmpsd[i]->status.party_id) > 0 ) { int j; @@ -2292,7 +2286,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) { } //End EXP giving. - if( !(type&1) && !map[m].flag.nomobloot && !md->state.rebirth && ( + if( !(type&1) && !maplist[m].flag.nomobloot && !md->state.rebirth && ( !md->special_state.ai || //Non special mob battle_config.alchemist_summon_reward == 2 || //All summoned give drops (md->special_state.ai==2 && battle_config.alchemist_summon_reward == 1) //Marine Sphere Drops items. @@ -2460,7 +2454,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) { double exp; //mapflag: noexp check [Lorky] - if (map[m].flag.nobaseexp || type&2) + if (maplist[m].flag.nobaseexp || type&2) exp =1; else { exp = md->db->mexp; @@ -2475,7 +2469,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) { pc->gainexp(mvp_sd, &md->bl, mexp,0, false); log_mvp[1] = mexp; - if( !(map[m].flag.nomvploot || type&1) ) { + if( !(maplist[m].flag.nomvploot || type&1) ) { /* pose them randomly in the list -- so on 100% drop servers it wont always drop the same item */ int mdrop_id[MAX_MVP_DROP]; int mdrop_p[MAX_MVP_DROP]; @@ -2619,7 +2613,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) { return 5; // Note: Actually, it's 4. Oh well... // MvP tomb [GreenBox] - if (battle_config.mvp_tomb_enabled && md->spawn->state.boss && map[md->bl.m].flag.notomb != 1) + if (battle_config.mvp_tomb_enabled && md->spawn->state.boss && maplist[md->bl.m].flag.notomb != 1) mob->mvptomb_create(md, mvp_sd ? mvp_sd->status.name : NULL, time(NULL)); if( !rebirth ) { @@ -3382,12 +3376,12 @@ int mob_clone_spawn(struct map_session_data *sd, int16 m, int16 x, int16 y, cons (skill_db[idx].inf2&(INF2_WEDDING_SKILL|INF2_GUILD_SKILL)) ) continue; - for(h = 0; h < map[sd->bl.m].zone->disabled_skills_count; h++) { - if( skill_id == map[sd->bl.m].zone->disabled_skills[h]->nameid && map[sd->bl.m].zone->disabled_skills[h]->subtype == MZS_CLONE ) { + for(h = 0; h < maplist[sd->bl.m].zone->disabled_skills_count; h++) { + if( skill_id == maplist[sd->bl.m].zone->disabled_skills[h]->nameid && maplist[sd->bl.m].zone->disabled_skills[h]->subtype == MZS_CLONE ) { break; } } - if( h < map[sd->bl.m].zone->disabled_skills_count ) + if( h < maplist[sd->bl.m].zone->disabled_skills_count ) continue; //Normal aggressive mob, disable skills that cannot help them fight //against players (those with flags UF_NOMOB and UF_NOPC are specific diff --git a/src/map/mob.h b/src/map/mob.h index 4ac8f7bcb..f4cbd77c6 100644 --- a/src/map/mob.h +++ b/src/map/mob.h @@ -245,8 +245,8 @@ struct item_drop_list { #define mob_stop_walking(md, type) unit->stop_walking(&(md)->bl, type) #define mob_stop_attack(md) unit->stop_attack(&(md)->bl) -#define mob_is_battleground(md) ( map[(md)->bl.m].flag.battleground && ((md)->class_ == MOBID_BARRICADE2 || ((md)->class_ >= MOBID_FOOD_STOR && (md)->class_ <= MOBID_PINK_CRYST)) ) -#define mob_is_gvg(md) (map[(md)->bl.m].flag.gvg_castle && ( (md)->class_ == MOBID_EMPERIUM || (md)->class_ == MOBID_BARRICADE1 || (md)->class_ == MOBID_GUARIDAN_STONE1 || (md)->class_ == MOBID_GUARIDAN_STONE2) ) +#define mob_is_battleground(md) ( maplist[(md)->bl.m].flag.battleground && ((md)->class_ == MOBID_BARRICADE2 || ((md)->class_ >= MOBID_FOOD_STOR && (md)->class_ <= MOBID_PINK_CRYST)) ) +#define mob_is_gvg(md) (maplist[(md)->bl.m].flag.gvg_castle && ( (md)->class_ == MOBID_EMPERIUM || (md)->class_ == MOBID_BARRICADE1 || (md)->class_ == MOBID_GUARIDAN_STONE1 || (md)->class_ == MOBID_GUARIDAN_STONE2) ) #define mob_is_treasure(md) (((md)->class_ >= MOBID_TREAS01 && (md)->class_ <= MOBID_TREAS40) || ((md)->class_ >= MOBID_TREAS41 && (md)->class_ <= MOBID_TREAS49)) struct mob_interface { diff --git a/src/map/npc.c b/src/map/npc.c index 1769b660e..fb106d2d6 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -889,51 +889,53 @@ int npc_touch_areanpc(struct map_session_data* sd, int16 m, int16 x, int16 y) //if(sd->npc_id) // return 1; - for(i=0;i<map[m].npc_num;i++) { - if (map[m].npc[i]->option&OPTION_INVISIBLE) { + for(i=0;i<maplist[m].npc_num;i++) { + if (maplist[m].npc[i]->option&OPTION_INVISIBLE) { f=0; // a npc was found, but it is disabled; don't print warning continue; } - switch(map[m].npc[i]->subtype) { + switch(maplist[m].npc[i]->subtype) { case WARP: - xs=map[m].npc[i]->u.warp.xs; - ys=map[m].npc[i]->u.warp.ys; + xs=maplist[m].npc[i]->u.warp.xs; + ys=maplist[m].npc[i]->u.warp.ys; break; case SCRIPT: - xs=map[m].npc[i]->u.scr.xs; - ys=map[m].npc[i]->u.scr.ys; + xs=maplist[m].npc[i]->u.scr.xs; + ys=maplist[m].npc[i]->u.scr.ys; break; default: continue; } - if( x >= map[m].npc[i]->bl.x-xs && x <= map[m].npc[i]->bl.x+xs - && y >= map[m].npc[i]->bl.y-ys && y <= map[m].npc[i]->bl.y+ys ) + if( x >= maplist[m].npc[i]->bl.x-xs && x <= maplist[m].npc[i]->bl.x+xs + && y >= maplist[m].npc[i]->bl.y-ys && y <= maplist[m].npc[i]->bl.y+ys ) break; } - if( i == map[m].npc_num ) - { + if( i == maplist[m].npc_num ) { if( f == 1 ) // no npc found - ShowError("npc_touch_areanpc : stray NPC cell/NPC not found in the block on coordinates '%s',%d,%d\n", map[m].name, x, y); + ShowError("npc_touch_areanpc : stray NPC cell/NPC not found in the block on coordinates '%s',%d,%d\n", maplist[m].name, x, y); return 1; } - switch(map[m].npc[i]->subtype) { + switch(maplist[m].npc[i]->subtype) { case WARP: if( pc_ishiding(sd) || (sd->sc.count && sd->sc.data[SC_CAMOUFLAGE]) ) break; // hidden chars cannot use warps - pc->setpos(sd,map[m].npc[i]->u.warp.mapindex,map[m].npc[i]->u.warp.x,map[m].npc[i]->u.warp.y,CLR_OUTSIGHT); + pc->setpos(sd,maplist[m].npc[i]->u.warp.mapindex,maplist[m].npc[i]->u.warp.x,maplist[m].npc[i]->u.warp.y,CLR_OUTSIGHT); break; case SCRIPT: - for (j = i; j < map[m].npc_num; j++) { - if (map[m].npc[j]->subtype != WARP) { + for (j = i; j < maplist[m].npc_num; j++) { + if (maplist[m].npc[j]->subtype != WARP) { continue; } - if ((sd->bl.x >= (map[m].npc[j]->bl.x - map[m].npc[j]->u.warp.xs) && sd->bl.x <= (map[m].npc[j]->bl.x + map[m].npc[j]->u.warp.xs)) && - (sd->bl.y >= (map[m].npc[j]->bl.y - map[m].npc[j]->u.warp.ys) && sd->bl.y <= (map[m].npc[j]->bl.y + map[m].npc[j]->u.warp.ys))) { + if ((sd->bl.x >= (maplist[m].npc[j]->bl.x - maplist[m].npc[j]->u.warp.xs) + && sd->bl.x <= (maplist[m].npc[j]->bl.x + maplist[m].npc[j]->u.warp.xs)) + && (sd->bl.y >= (maplist[m].npc[j]->bl.y - maplist[m].npc[j]->u.warp.ys) + && sd->bl.y <= (maplist[m].npc[j]->bl.y + maplist[m].npc[j]->u.warp.ys)) + ) { if( pc_ishiding(sd) || (sd->sc.count && sd->sc.data[SC_CAMOUFLAGE]) ) break; // hidden chars cannot use warps - pc->setpos(sd,map[m].npc[j]->u.warp.mapindex,map[m].npc[j]->u.warp.x,map[m].npc[j]->u.warp.y,CLR_OUTSIGHT); + pc->setpos(sd,maplist[m].npc[j]->u.warp.mapindex,maplist[m].npc[j]->u.warp.x,maplist[m].npc[j]->u.warp.y,CLR_OUTSIGHT); found_warp = 1; break; } @@ -943,7 +945,7 @@ int npc_touch_areanpc(struct map_session_data* sd, int16 m, int16 x, int16 y) break; } - if( npc->ontouch_event(sd,map[m].npc[i]) > 0 && npc->ontouch2_event(sd,map[m].npc[i]) > 0 ) + if( npc->ontouch_event(sd,maplist[m].npc[i]) > 0 && npc->ontouch2_event(sd,maplist[m].npc[i]) > 0 ) { // failed to run OnTouch event, so just click the npc struct unit_data *ud = unit->bl2ud(&sd->bl); if( ud && ud->walkpath.path_pos < ud->walkpath.path_len ) @@ -951,8 +953,8 @@ int npc_touch_areanpc(struct map_session_data* sd, int16 m, int16 x, int16 y) clif->fixpos(&sd->bl); ud->walkpath.path_pos = ud->walkpath.path_len; } - sd->areanpc_id = map[m].npc[i]->bl.id; - npc->click(sd,map[m].npc[i]); + sd->areanpc_id = maplist[m].npc[i]->bl.id; + npc->click(sd,maplist[m].npc[i]); } break; } @@ -968,43 +970,42 @@ int npc_touch_areanpc2(struct mob_data *md) struct event_data* ev; int xs, ys; - for( i = 0; i < map[m].npc_num; i++ ) { - if( map[m].npc[i]->option&OPTION_INVISIBLE ) + for( i = 0; i < maplist[m].npc_num; i++ ) { + if( maplist[m].npc[i]->option&OPTION_INVISIBLE ) continue; - switch( map[m].npc[i]->subtype ) { + switch( maplist[m].npc[i]->subtype ) { case WARP: if( !( battle_config.mob_warp&1 ) ) continue; - xs = map[m].npc[i]->u.warp.xs; - ys = map[m].npc[i]->u.warp.ys; + xs = maplist[m].npc[i]->u.warp.xs; + ys = maplist[m].npc[i]->u.warp.ys; break; case SCRIPT: - xs = map[m].npc[i]->u.scr.xs; - ys = map[m].npc[i]->u.scr.ys; + xs = maplist[m].npc[i]->u.scr.xs; + ys = maplist[m].npc[i]->u.scr.ys; break; default: continue; // Keep Searching } - if( x >= map[m].npc[i]->bl.x-xs && x <= map[m].npc[i]->bl.x+xs && y >= map[m].npc[i]->bl.y-ys && y <= map[m].npc[i]->bl.y+ys ) - { // In the npc touch area - switch( map[m].npc[i]->subtype ) - { + if( x >= maplist[m].npc[i]->bl.x-xs && x <= maplist[m].npc[i]->bl.x+xs && y >= maplist[m].npc[i]->bl.y-ys && y <= maplist[m].npc[i]->bl.y+ys ) { + // In the npc touch area + switch( maplist[m].npc[i]->subtype ) { case WARP: - xs = iMap->mapindex2mapid(map[m].npc[i]->u.warp.mapindex); + xs = iMap->mapindex2mapid(maplist[m].npc[i]->u.warp.mapindex); if( m < 0 ) break; // Cannot Warp between map servers - if( unit->warp(&md->bl, xs, map[m].npc[i]->u.warp.x, map[m].npc[i]->u.warp.y, CLR_OUTSIGHT) == 0 ) + if( unit->warp(&md->bl, xs, maplist[m].npc[i]->u.warp.x, maplist[m].npc[i]->u.warp.y, CLR_OUTSIGHT) == 0 ) return 1; // Warped break; case SCRIPT: - if( map[m].npc[i]->bl.id == md->areanpc_id ) + if( maplist[m].npc[i]->bl.id == md->areanpc_id ) break; // Already touch this NPC - snprintf(eventname, ARRAYLENGTH(eventname), "%s::OnTouchNPC", map[m].npc[i]->exname); + snprintf(eventname, ARRAYLENGTH(eventname), "%s::OnTouchNPC", maplist[m].npc[i]->exname); if( (ev = (struct event_data*)strdb_get(npc->ev_db, eventname)) == NULL || ev->nd == NULL ) break; // No OnTouchNPC Event - md->areanpc_id = map[m].npc[i]->bl.id; + md->areanpc_id = maplist[m].npc[i]->bl.id; id = md->bl.id; // Stores Unique ID script->run(ev->nd->u.scr.script, ev->pos, md->bl.id, ev->nd->bl.id); if( iMap->id2md(id) == NULL ) return 1; // Not Warped, but killed @@ -1022,8 +1023,7 @@ int npc_touch_areanpc2(struct mob_data *md) //Flag determines the type of object to check for: //&1: NPC Warps //&2: NPCs with on-touch events. -int npc_check_areanpc(int flag, int16 m, int16 x, int16 y, int16 range) -{ +int npc_check_areanpc(int flag, int16 m, int16 x, int16 y, int16 range) { int i; int x0,y0,x1,y1; int xs,ys; @@ -1031,8 +1031,8 @@ int npc_check_areanpc(int flag, int16 m, int16 x, int16 y, int16 range) if (range < 0) return 0; x0 = max(x-range, 0); y0 = max(y-range, 0); - x1 = min(x+range, map[m].xs-1); - y1 = min(y+range, map[m].ys-1); + x1 = min(x+range, maplist[m].xs-1); + y1 = min(y+range, maplist[m].ys-1); //First check for npc_cells on the range given i = 0; @@ -1045,35 +1045,35 @@ int npc_check_areanpc(int flag, int16 m, int16 x, int16 y, int16 range) if (!i) return 0; //No NPC_CELLs. //Now check for the actual NPC on said range. - for(i=0;i<map[m].npc_num;i++) { - if (map[m].npc[i]->option&OPTION_INVISIBLE) + for(i=0;i<maplist[m].npc_num;i++) { + if (maplist[m].npc[i]->option&OPTION_INVISIBLE) continue; - switch(map[m].npc[i]->subtype) { + switch(maplist[m].npc[i]->subtype) { case WARP: if (!(flag&1)) continue; - xs=map[m].npc[i]->u.warp.xs; - ys=map[m].npc[i]->u.warp.ys; + xs=maplist[m].npc[i]->u.warp.xs; + ys=maplist[m].npc[i]->u.warp.ys; break; case SCRIPT: if (!(flag&2)) continue; - xs=map[m].npc[i]->u.scr.xs; - ys=map[m].npc[i]->u.scr.ys; + xs=maplist[m].npc[i]->u.scr.xs; + ys=maplist[m].npc[i]->u.scr.ys; break; default: continue; } - if( x1 >= map[m].npc[i]->bl.x-xs && x0 <= map[m].npc[i]->bl.x+xs - && y1 >= map[m].npc[i]->bl.y-ys && y0 <= map[m].npc[i]->bl.y+ys ) + if( x1 >= maplist[m].npc[i]->bl.x-xs && x0 <= maplist[m].npc[i]->bl.x+xs + && y1 >= maplist[m].npc[i]->bl.y-ys && y0 <= maplist[m].npc[i]->bl.y+ys ) break; // found a npc } - if (i==map[m].npc_num) + if (i==maplist[m].npc_num) return 0; - return (map[m].npc[i]->bl.id); + return (maplist[m].npc[i]->bl.id); } /*========================================== @@ -1423,11 +1423,12 @@ int npc_cashshop_buy(struct map_session_data *sd, int nameid, int amount, int po if( w + sd->weight > sd->max_weight ) return 3; - if( (double)nd->u.shop.shop_item[i].value * amount > INT_MAX ) - { + if( (double)nd->u.shop.shop_item[i].value * amount > INT_MAX ) { ShowWarning("npc_cashshop_buy: Item '%s' (%d) price overflow attempt!\n", item->name, nameid); ShowDebug("(NPC:'%s' (%s,%d,%d), player:'%s' (%d/%d), value:%d, amount:%d)\n", - nd->exname, map[nd->bl.m].name, nd->bl.x, nd->bl.y, sd->status.name, sd->status.account_id, sd->status.char_id, nd->u.shop.shop_item[i].value, amount); + nd->exname, maplist[nd->bl.m].name, nd->bl.x, nd->bl.y, + sd->status.name, sd->status.account_id, sd->status.char_id, + nd->u.shop.shop_item[i].value, amount); return 5; } @@ -1724,13 +1725,13 @@ int npc_remove_map(struct npc_data* nd) { clif->clearunit_area(&nd->bl,CLR_RESPAWN); npc->unsetcells(nd); iMap->delblock(&nd->bl); - //Remove npc from map[].npc list. [Skotlex] - ARR_FIND( 0, map[m].npc_num, i, map[m].npc[i] == nd ); - if( i == map[m].npc_num ) return 2; //failed to find it? + //Remove npc from maplist[].npc list. [Skotlex] + ARR_FIND( 0, maplist[m].npc_num, i, maplist[m].npc[i] == nd ); + if( i == maplist[m].npc_num ) return 2; //failed to find it? - map[m].npc_num--; - map[m].npc[i] = map[m].npc[map[m].npc_num]; - map[m].npc[map[m].npc_num] = NULL; + maplist[m].npc_num--; + maplist[m].npc[i] = maplist[m].npc[maplist[m].npc_num]; + maplist[m].npc[maplist[m].npc_num] = NULL; return 0; } @@ -2072,7 +2073,7 @@ struct npc_data* npc_add_warp(char* name, short from_mapid, short from_x, short iMap->addblock(&nd->bl); iStatus->set_viewdata(&nd->bl, nd->class_); nd->ud = &npc->base_ud; - if( map[nd->bl.m].users ) + if( maplist[nd->bl.m].users ) clif->spawn(&nd->bl); strdb_put(npc->name_db, nd->exname, nd); @@ -2104,8 +2105,8 @@ const char* npc_parse_warp(char* w1, char* w2, char* w3, char* w4, const char* s return strchr(start,'\n');// skip and continue } - if( m != -1 && ( x < 0 || x >= map[m].xs || y < 0 || y >= map[m].ys ) ) { - ShowError("npc_parse_warp: out-of-bounds coordinates (\"%s\",%d,%d), map is %dx%d, in file '%s', line '%d'\n", map[m].name, x, y, map[m].xs, map[m].ys,filepath,strline(buffer,start-buffer)); + if( m != -1 && ( x < 0 || x >= maplist[m].xs || y < 0 || y >= maplist[m].ys ) ) { + ShowError("npc_parse_warp: out-of-bounds coordinates (\"%s\",%d,%d), map is %dx%d, in file '%s', line '%d'\n", maplist[m].name, x, y, maplist[m].xs, maplist[m].ys,filepath,strline(buffer,start-buffer)); return strchr(start,'\n');;//try next } @@ -2137,7 +2138,7 @@ const char* npc_parse_warp(char* w1, char* w2, char* w3, char* w4, const char* s iMap->addblock(&nd->bl); iStatus->set_viewdata(&nd->bl, nd->class_); nd->ud = &npc->base_ud; - if( map[nd->bl.m].users ) + if( maplist[nd->bl.m].users ) clif->spawn(&nd->bl); strdb_put(npc->name_db, nd->exname, nd); @@ -2170,8 +2171,8 @@ const char* npc_parse_shop(char* w1, char* w2, char* w3, char* w4, const char* s m = iMap->mapname2mapid(mapname); } - if( m != -1 && ( x < 0 || x >= map[m].xs || y < 0 || y >= map[m].ys ) ) { - ShowError("npc_parse_shop: out-of-bounds coordinates (\"%s\",%d,%d), map is %dx%d, in file '%s', line '%d'\n", map[m].name, x, y, map[m].xs, map[m].ys,filepath,strline(buffer,start-buffer)); + if( m != -1 && ( x < 0 || x >= maplist[m].xs || y < 0 || y >= maplist[m].ys ) ) { + ShowError("npc_parse_shop: out-of-bounds coordinates (\"%s\",%d,%d), map is %dx%d, in file '%s', line '%d'\n", maplist[m].name, x, y, maplist[m].xs, maplist[m].ys,filepath,strline(buffer,start-buffer)); return strchr(start,'\n');;//try next } @@ -2250,7 +2251,7 @@ const char* npc_parse_shop(char* w1, char* w2, char* w3, char* w4, const char* s iStatus->set_viewdata(&nd->bl, nd->class_); nd->ud = &npc->base_ud; nd->dir = dir; - if( map[nd->bl.m].users ) + if( maplist[nd->bl.m].users ) clif->spawn(&nd->bl); } else {// 'floating' shop? iMap->addiddb(&nd->bl); @@ -2440,7 +2441,7 @@ const char* npc_parse_script(char* w1, char* w2, char* w3, char* w4, const char* iMap->addblock(&nd->bl); if( class_ >= 0 ) { iStatus->set_viewdata(&nd->bl, nd->class_); - if( map[nd->bl.m].users ) + if( maplist[nd->bl.m].users ) clif->spawn(&nd->bl); } } else { @@ -2530,8 +2531,8 @@ const char* npc_parse_duplicate(char* w1, char* w2, char* w3, char* w4, const ch m = iMap->mapname2mapid(mapname); } - if( m != -1 && ( x < 0 || x >= map[m].xs || y < 0 || y >= map[m].ys ) ) { - ShowError("npc_parse_duplicate: out-of-bounds coordinates (\"%s\",%d,%d), map is %dx%d, in file '%s', line '%d'\n", map[m].name, x, y, map[m].xs, map[m].ys,filepath,strline(buffer,start-buffer)); + if( m != -1 && ( x < 0 || x >= maplist[m].xs || y < 0 || y >= maplist[m].ys ) ) { + ShowError("npc_parse_duplicate: out-of-bounds coordinates (\"%s\",%d,%d), map is %dx%d, in file '%s', line '%d'\n", maplist[m].name, x, y, maplist[m].xs, maplist[m].ys,filepath,strline(buffer,start-buffer)); return end;//try next } @@ -2596,7 +2597,7 @@ const char* npc_parse_duplicate(char* w1, char* w2, char* w3, char* w4, const ch iMap->addblock(&nd->bl); if( class_ >= 0 ) { iStatus->set_viewdata(&nd->bl, nd->class_); - if( map[nd->bl.m].users ) + if( maplist[nd->bl.m].users ) clif->spawn(&nd->bl); } } else { @@ -2626,12 +2627,12 @@ const char* npc_parse_duplicate(char* w1, char* w2, char* w3, char* w4, const ch int npc_duplicate4instance(struct npc_data *snd, int16 m) { char newname[NAME_LENGTH]; - if( m == -1 || map[m].instance_id == -1 ) + if( m == -1 || maplist[m].instance_id == -1 ) return 1; - snprintf(newname, ARRAYLENGTH(newname), "dup_%d_%d", map[m].instance_id, snd->bl.id); + snprintf(newname, ARRAYLENGTH(newname), "dup_%d_%d", maplist[m].instance_id, snd->bl.id); if( npc->name2id(newname) != NULL ) { // Name already in use - ShowError("npc_duplicate4instance: the npcname (%s) is already in use while trying to duplicate npc %s in instance %d.\n", newname, snd->exname, map[m].instance_id); + ShowError("npc_duplicate4instance: the npcname (%s) is already in use while trying to duplicate npc %s in instance %d.\n", newname, snd->exname, maplist[m].instance_id); return 1; } @@ -2640,8 +2641,8 @@ int npc_duplicate4instance(struct npc_data *snd, int16 m) { int dm = iMap->mapindex2mapid(snd->u.warp.mapindex), im; if( dm < 0 ) return 1; - if( ( im = instance->mapid2imapid(dm, map[m].instance_id) ) == -1 ) { - ShowError("npc_duplicate4instance: warp (%s) leading to instanced map (%s), but instance map is not attached to current instance.\n", map[dm].name, snd->exname); + if( ( im = instance->mapid2imapid(dm, maplist[m].instance_id) ) == -1 ) { + ShowError("npc_duplicate4instance: warp (%s) leading to instanced map (%s), but instance map is not attached to current instance.\n", maplist[dm].name, snd->exname); return 1; } @@ -2667,14 +2668,14 @@ int npc_duplicate4instance(struct npc_data *snd, int16 m) { iMap->addblock(&wnd->bl); iStatus->set_viewdata(&wnd->bl, wnd->class_); wnd->ud = &npc->base_ud; - if( map[wnd->bl.m].users ) + if( maplist[wnd->bl.m].users ) clif->spawn(&wnd->bl); strdb_put(npc->name_db, wnd->exname, wnd); } else { static char w1[50], w2[50], w3[50], w4[50]; const char* stat_buf = "- call from instancing subsystem -\n"; - snprintf(w1, sizeof(w1), "%s,%d,%d,%d", map[m].name, snd->bl.x, snd->bl.y, snd->dir); + snprintf(w1, sizeof(w1), "%s,%d,%d,%d", maplist[m].name, snd->bl.x, snd->bl.y, snd->dir); snprintf(w2, sizeof(w2), "duplicate(%s)", snd->exname); snprintf(w3, sizeof(w3), "%s::%s", snd->name, newname); @@ -2707,14 +2708,14 @@ void npc_setcells(struct npc_data* nd) { return; // Other types doesn't have touch area } - if (m < 0 || xs < 0 || ys < 0 || map[m].cell == (struct mapcell *)0xdeadbeaf) //invalid range or map + if (m < 0 || xs < 0 || ys < 0 || maplist[m].cell == (struct mapcell *)0xdeadbeaf) //invalid range or map return; for (i = y-ys; i <= y+ys; i++) { for (j = x-xs; j <= x+xs; j++) { if (iMap->getcell(m, j, i, CELL_CHKNOPASS)) continue; - map[m].setcell(m, j, i, CELL_NPC, true); + maplist[m].setcell(m, j, i, CELL_NPC, true); } } } @@ -2739,20 +2740,20 @@ void npc_unsetcells(struct npc_data* nd) { ys = nd->u.scr.ys; } - if (m < 0 || xs < 0 || ys < 0 || map[m].cell == (struct mapcell *)0xdeadbeaf) + if (m < 0 || xs < 0 || ys < 0 || maplist[m].cell == (struct mapcell *)0xdeadbeaf) return; //Locate max range on which we can locate npc cells //FIXME: does this really do what it's supposed to do? [ultramage] for(x0 = x-xs; x0 > 0 && iMap->getcell(m, x0, y, CELL_CHKNPC); x0--); - for(x1 = x+xs; x1 < map[m].xs-1 && iMap->getcell(m, x1, y, CELL_CHKNPC); x1++); + for(x1 = x+xs; x1 < maplist[m].xs-1 && iMap->getcell(m, x1, y, CELL_CHKNPC); x1++); for(y0 = y-ys; y0 > 0 && iMap->getcell(m, x, y0, CELL_CHKNPC); y0--); - for(y1 = y+ys; y1 < map[m].ys-1 && iMap->getcell(m, x, y1, CELL_CHKNPC); y1++); + for(y1 = y+ys; y1 < maplist[m].ys-1 && iMap->getcell(m, x, y1, CELL_CHKNPC); y1++); //Erase this npc's cells for (i = y-ys; i <= y+ys; i++) for (j = x-xs; j <= x+xs; j++) - map[m].setcell(m, j, i, CELL_NPC, false); + maplist[m].setcell(m, j, i, CELL_NPC, false); //Re-deploy NPC cells for other nearby npcs. iMap->foreachinarea( npc->unsetcells_sub, m, x0, y0, x1, y1, BL_NPC, nd->bl.id ); @@ -2761,10 +2762,10 @@ void npc_unsetcells(struct npc_data* nd) { void npc_movenpc(struct npc_data* nd, int16 x, int16 y) { const int16 m = nd->bl.m; - if (m < 0 || nd->bl.prev == NULL) return; //Not on a map. + if (m < 0 || nd->bl.prev == NULL) return; //Not on a map. - x = cap_value(x, 0, map[m].xs-1); - y = cap_value(y, 0, map[m].ys-1); + x = cap_value(x, 0, maplist[m].xs-1); + y = cap_value(y, 0, maplist[m].ys-1); iMap->foreachinrange(clif->outsight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl); iMap->moveblock(&nd->bl, x, y, timer->gettick()); @@ -2780,7 +2781,7 @@ void npc_setdisplayname(struct npc_data* nd, const char* newname) nullpo_retv(nd); safestrncpy(nd->name, newname, sizeof(nd->name)); - if( map[nd->bl.m].users ) + if( maplist[nd->bl.m].users ) clif->charnameack(0, &nd->bl); } @@ -2795,11 +2796,11 @@ void npc_setclass(struct npc_data* nd, short class_) if( nd->class_ == class_ ) return; - if( map[nd->bl.m].users ) + if( maplist[nd->bl.m].users ) clif->clearunit_area(&nd->bl, CLR_OUTSIGHT);// fade out nd->class_ = class_; iStatus->set_viewdata(&nd->bl, class_); - if( map[nd->bl.m].users ) + if( maplist[nd->bl.m].users ) clif->spawn(&nd->bl);// fade in } @@ -2953,8 +2954,8 @@ const char* npc_parse_mob(char* w1, char* w2, char* w3, char* w4, const char* st return strchr(start,'\n');// skip and continue mobspawn.m = (unsigned short)m; - if( x < 0 || x >= map[mobspawn.m].xs || y < 0 || y >= map[mobspawn.m].ys ) { - ShowError("npc_parse_mob: Spawn coordinates out of range: %s (%d,%d), map size is (%d,%d) - %s %s (file '%s', line '%d').\n", map[mobspawn.m].name, x, y, (map[mobspawn.m].xs-1), (map[mobspawn.m].ys-1), w1, w3, filepath, strline(buffer,start-buffer)); + if( x < 0 || x >= maplist[mobspawn.m].xs || y < 0 || y >= maplist[mobspawn.m].ys ) { + ShowError("npc_parse_mob: Spawn coordinates out of range: %s (%d,%d), map size is (%d,%d) - %s %s (file '%s', line '%d').\n", maplist[mobspawn.m].name, x, y, (maplist[mobspawn.m].xs-1), (maplist[mobspawn.m].ys-1), w1, w3, filepath, strline(buffer,start-buffer)); return strchr(start,'\n');// skip and continue } @@ -3066,7 +3067,7 @@ const char* npc_parse_mob(char* w1, char* w2, char* w3, char* w4, const char* st // check if target map has players // (usually shouldn't occur when map server is just starting, // but not the case when we do @reloadscript - if( map[data->m].users > 0 ) { + if( maplist[data->m].users > 0 ) { npc->parse_mob2(data); } } else { @@ -3111,68 +3112,68 @@ const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, const char if (state == 0) ; //Map flag disabled. else if (!strcmpi(w4, "SavePoint")) { - map[m].save.map = 0; - map[m].save.x = -1; - map[m].save.y = -1; + maplist[m].save.map = 0; + maplist[m].save.x = -1; + maplist[m].save.y = -1; } else if (sscanf(w4, "%31[^,],%d,%d", savemap, &savex, &savey) == 3) { - map[m].save.map = mapindex_name2id(savemap); - map[m].save.x = savex; - map[m].save.y = savey; - if (!map[m].save.map) { + maplist[m].save.map = mapindex_name2id(savemap); + maplist[m].save.x = savex; + maplist[m].save.y = savey; + if (!maplist[m].save.map) { ShowWarning("npc_parse_mapflag: Specified save point map '%s' for mapflag 'nosave' not found (file '%s', line '%d'), using 'SavePoint'.\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", savemap, filepath, strline(buffer,start-buffer), w1, w2, w3, w4); - map[m].save.x = -1; - map[m].save.y = -1; + maplist[m].save.x = -1; + maplist[m].save.y = -1; } } - map[m].flag.nosave = state; + maplist[m].flag.nosave = state; } else if (!strcmpi(w3,"autotrade")) - map[m].flag.autotrade=state; + maplist[m].flag.autotrade=state; else if (!strcmpi(w3,"allowks")) - map[m].flag.allowks=state; // [Kill Steal Protection] + maplist[m].flag.allowks=state; // [Kill Steal Protection] else if (!strcmpi(w3,"town")) - map[m].flag.town=state; + maplist[m].flag.town=state; else if (!strcmpi(w3,"nomemo")) - map[m].flag.nomemo=state; + maplist[m].flag.nomemo=state; else if (!strcmpi(w3,"noteleport")) - map[m].flag.noteleport=state; + maplist[m].flag.noteleport=state; else if (!strcmpi(w3,"nowarp")) - map[m].flag.nowarp=state; + maplist[m].flag.nowarp=state; else if (!strcmpi(w3,"nowarpto")) - map[m].flag.nowarpto=state; + maplist[m].flag.nowarpto=state; else if (!strcmpi(w3,"noreturn")) - map[m].flag.noreturn=state; + maplist[m].flag.noreturn=state; else if (!strcmpi(w3,"monster_noteleport")) - map[m].flag.monster_noteleport=state; + maplist[m].flag.monster_noteleport=state; else if (!strcmpi(w3,"nobranch")) - map[m].flag.nobranch=state; + maplist[m].flag.nobranch=state; else if (!strcmpi(w3,"nopenalty")) { - map[m].flag.noexppenalty=state; - map[m].flag.nozenypenalty=state; + maplist[m].flag.noexppenalty=state; + maplist[m].flag.nozenypenalty=state; } else if (!strcmpi(w3,"pvp")) { struct map_zone_data *zone; - map[m].flag.pvp = state; - if( state && (map[m].flag.gvg || map[m].flag.gvg_dungeon || map[m].flag.gvg_castle) ) { - map[m].flag.gvg = 0; - map[m].flag.gvg_dungeon = 0; - map[m].flag.gvg_castle = 0; - ShowWarning("npc_parse_mapflag: You can't set PvP and GvG flags for the same map! Removing GvG flags from %s (file '%s', line '%d').\n", map[m].name, filepath, strline(buffer,start-buffer)); + maplist[m].flag.pvp = state; + if( state && (maplist[m].flag.gvg || maplist[m].flag.gvg_dungeon || maplist[m].flag.gvg_castle) ) { + maplist[m].flag.gvg = 0; + maplist[m].flag.gvg_dungeon = 0; + maplist[m].flag.gvg_castle = 0; + ShowWarning("npc_parse_mapflag: You can't set PvP and GvG flags for the same map! Removing GvG flags from %s (file '%s', line '%d').\n", maplist[m].name, filepath, strline(buffer,start-buffer)); } - if( state && map[m].flag.battleground ) { - map[m].flag.battleground = 0; - ShowWarning("npc_parse_mapflag: You can't set PvP and BattleGround flags for the same map! Removing BattleGround flag from %s (file '%s', line '%d').\n", map[m].name, filepath, strline(buffer,start-buffer)); + if( state && maplist[m].flag.battleground ) { + maplist[m].flag.battleground = 0; + ShowWarning("npc_parse_mapflag: You can't set PvP and BattleGround flags for the same map! Removing BattleGround flag from %s (file '%s', line '%d').\n", maplist[m].name, filepath, strline(buffer,start-buffer)); } - if( state && (zone = strdb_get(zone_db, MAP_ZONE_PVP_NAME)) && map[m].zone != zone ) { + if( state && (zone = strdb_get(zone_db, MAP_ZONE_PVP_NAME)) && maplist[m].zone != zone ) { iMap->zone_change(m,zone,start,buffer,filepath); } else if ( !state ) { - map[m].zone = &map_zone_pk; + maplist[m].zone = &map_zone_pk; } } else if (!strcmpi(w3,"pvp_noparty")) - map[m].flag.pvp_noparty=state; + maplist[m].flag.pvp_noparty=state; else if (!strcmpi(w3,"pvp_noguild")) - map[m].flag.pvp_noguild=state; + maplist[m].flag.pvp_noguild=state; else if (!strcmpi(w3, "pvp_nightmaredrop")) { char drop_arg1[16], drop_arg2[16]; int drop_per = 0; @@ -3190,145 +3191,145 @@ const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, const char drop_type = 3; if (drop_id != 0) { - RECREATE(map[m].drop_list, struct map_drop_list, ++map[m].drop_list_count); - map[m].drop_list[map[m].drop_list_count-1].drop_id = drop_id; - map[m].drop_list[map[m].drop_list_count-1].drop_type = drop_type; - map[m].drop_list[map[m].drop_list_count-1].drop_per = drop_per; - map[m].flag.pvp_nightmaredrop = 1; + RECREATE(maplist[m].drop_list, struct map_drop_list, ++maplist[m].drop_list_count); + maplist[m].drop_list[maplist[m].drop_list_count-1].drop_id = drop_id; + maplist[m].drop_list[maplist[m].drop_list_count-1].drop_type = drop_type; + maplist[m].drop_list[maplist[m].drop_list_count-1].drop_per = drop_per; + maplist[m].flag.pvp_nightmaredrop = 1; } } else if (!state) //Disable - map[m].flag.pvp_nightmaredrop = 0; + maplist[m].flag.pvp_nightmaredrop = 0; } else if (!strcmpi(w3,"pvp_nocalcrank")) - map[m].flag.pvp_nocalcrank=state; + maplist[m].flag.pvp_nocalcrank=state; else if (!strcmpi(w3,"gvg")) { struct map_zone_data *zone; - map[m].flag.gvg = state; - if( state && map[m].flag.pvp ) { - map[m].flag.pvp = 0; - ShowWarning("npc_parse_mapflag: You can't set PvP and GvG flags for the same map! Removing PvP flag from %s (file '%s', line '%d').\n", map[m].name, filepath, strline(buffer,start-buffer)); + maplist[m].flag.gvg = state; + if( state && maplist[m].flag.pvp ) { + maplist[m].flag.pvp = 0; + ShowWarning("npc_parse_mapflag: You can't set PvP and GvG flags for the same map! Removing PvP flag from %s (file '%s', line '%d').\n", maplist[m].name, filepath, strline(buffer,start-buffer)); } - if( state && map[m].flag.battleground ) { - map[m].flag.battleground = 0; - ShowWarning("npc_parse_mapflag: You can't set GvG and BattleGround flags for the same map! Removing BattleGround flag from %s (file '%s', line '%d').\n", map[m].name, filepath, strline(buffer,start-buffer)); + if( state && maplist[m].flag.battleground ) { + maplist[m].flag.battleground = 0; + ShowWarning("npc_parse_mapflag: You can't set GvG and BattleGround flags for the same map! Removing BattleGround flag from %s (file '%s', line '%d').\n", maplist[m].name, filepath, strline(buffer,start-buffer)); } - if( state && (zone = strdb_get(zone_db, MAP_ZONE_GVG_NAME)) && map[m].zone != zone ) { + if( state && (zone = strdb_get(zone_db, MAP_ZONE_GVG_NAME)) && maplist[m].zone != zone ) { iMap->zone_change(m,zone,start,buffer,filepath); } } else if (!strcmpi(w3,"gvg_noparty")) - map[m].flag.gvg_noparty=state; + maplist[m].flag.gvg_noparty=state; else if (!strcmpi(w3,"gvg_dungeon")) { - map[m].flag.gvg_dungeon=state; - if (state) map[m].flag.pvp=0; + maplist[m].flag.gvg_dungeon=state; + if (state) maplist[m].flag.pvp=0; } else if (!strcmpi(w3,"gvg_castle")) { - map[m].flag.gvg_castle=state; - if (state) map[m].flag.pvp=0; + maplist[m].flag.gvg_castle=state; + if (state) maplist[m].flag.pvp=0; } else if (!strcmpi(w3,"battleground")) { struct map_zone_data *zone; if( state ) { if( sscanf(w4, "%d", &state) == 1 ) - map[m].flag.battleground = state; + maplist[m].flag.battleground = state; else - map[m].flag.battleground = 1; // Default value + maplist[m].flag.battleground = 1; // Default value } else - map[m].flag.battleground = 0; + maplist[m].flag.battleground = 0; - if( map[m].flag.battleground && map[m].flag.pvp ) { - map[m].flag.pvp = 0; - ShowWarning("npc_parse_mapflag: You can't set PvP and BattleGround flags for the same map! Removing PvP flag from %s (file '%s', line '%d').\n", map[m].name, filepath, strline(buffer,start-buffer)); + if( maplist[m].flag.battleground && maplist[m].flag.pvp ) { + maplist[m].flag.pvp = 0; + ShowWarning("npc_parse_mapflag: You can't set PvP and BattleGround flags for the same map! Removing PvP flag from %s (file '%s', line '%d').\n", maplist[m].name, filepath, strline(buffer,start-buffer)); } - if( map[m].flag.battleground && (map[m].flag.gvg || map[m].flag.gvg_dungeon || map[m].flag.gvg_castle) ) { - map[m].flag.gvg = 0; - map[m].flag.gvg_dungeon = 0; - map[m].flag.gvg_castle = 0; - ShowWarning("npc_parse_mapflag: You can't set GvG and BattleGround flags for the same map! Removing GvG flag from %s (file '%s', line '%d').\n", map[m].name, filepath, strline(buffer,start-buffer)); + if( maplist[m].flag.battleground && (maplist[m].flag.gvg || maplist[m].flag.gvg_dungeon || maplist[m].flag.gvg_castle) ) { + maplist[m].flag.gvg = 0; + maplist[m].flag.gvg_dungeon = 0; + maplist[m].flag.gvg_castle = 0; + ShowWarning("npc_parse_mapflag: You can't set GvG and BattleGround flags for the same map! Removing GvG flag from %s (file '%s', line '%d').\n", maplist[m].name, filepath, strline(buffer,start-buffer)); } - if( state && (zone = strdb_get(zone_db, MAP_ZONE_BG_NAME)) && map[m].zone != zone ) { + if( state && (zone = strdb_get(zone_db, MAP_ZONE_BG_NAME)) && maplist[m].zone != zone ) { iMap->zone_change(m,zone,start,buffer,filepath); } } else if (!strcmpi(w3,"noexppenalty")) - map[m].flag.noexppenalty=state; + maplist[m].flag.noexppenalty=state; else if (!strcmpi(w3,"nozenypenalty")) - map[m].flag.nozenypenalty=state; + maplist[m].flag.nozenypenalty=state; else if (!strcmpi(w3,"notrade")) - map[m].flag.notrade=state; + maplist[m].flag.notrade=state; else if (!strcmpi(w3,"novending")) - map[m].flag.novending=state; + maplist[m].flag.novending=state; else if (!strcmpi(w3,"nodrop")) - map[m].flag.nodrop=state; + maplist[m].flag.nodrop=state; else if (!strcmpi(w3,"noskill")) - map[m].flag.noskill=state; + maplist[m].flag.noskill=state; else if (!strcmpi(w3,"noicewall")) - map[m].flag.noicewall=state; + maplist[m].flag.noicewall=state; else if (!strcmpi(w3,"snow")) - map[m].flag.snow=state; + maplist[m].flag.snow=state; else if (!strcmpi(w3,"clouds")) - map[m].flag.clouds=state; + maplist[m].flag.clouds=state; else if (!strcmpi(w3,"clouds2")) - map[m].flag.clouds2=state; + maplist[m].flag.clouds2=state; else if (!strcmpi(w3,"fog")) - map[m].flag.fog=state; + maplist[m].flag.fog=state; else if (!strcmpi(w3,"fireworks")) - map[m].flag.fireworks=state; + maplist[m].flag.fireworks=state; else if (!strcmpi(w3,"sakura")) - map[m].flag.sakura=state; + maplist[m].flag.sakura=state; else if (!strcmpi(w3,"leaves")) - map[m].flag.leaves=state; + maplist[m].flag.leaves=state; else if (!strcmpi(w3,"nightenabled")) - map[m].flag.nightenabled=state; + maplist[m].flag.nightenabled=state; else if (!strcmpi(w3,"noexp")) { - map[m].flag.nobaseexp=state; - map[m].flag.nojobexp=state; + maplist[m].flag.nobaseexp=state; + maplist[m].flag.nojobexp=state; } else if (!strcmpi(w3,"nobaseexp")) - map[m].flag.nobaseexp=state; + maplist[m].flag.nobaseexp=state; else if (!strcmpi(w3,"nojobexp")) - map[m].flag.nojobexp=state; + maplist[m].flag.nojobexp=state; else if (!strcmpi(w3,"noloot")) { - map[m].flag.nomobloot=state; - map[m].flag.nomvploot=state; + maplist[m].flag.nomobloot=state; + maplist[m].flag.nomvploot=state; } else if (!strcmpi(w3,"nomobloot")) - map[m].flag.nomobloot=state; + maplist[m].flag.nomobloot=state; else if (!strcmpi(w3,"nomvploot")) - map[m].flag.nomvploot=state; + maplist[m].flag.nomvploot=state; else if (!strcmpi(w3,"nocommand")) { if (state) { if (sscanf(w4, "%d", &state) == 1) - map[m].nocommand =state; + maplist[m].nocommand =state; else //No level specified, block everyone. - map[m].nocommand =100; + maplist[m].nocommand =100; } else - map[m].nocommand=0; + maplist[m].nocommand=0; } else if (!strcmpi(w3,"jexp")) { - map[m].jexp = (state) ? atoi(w4) : 100; - if( map[m].jexp < 0 ) map[m].jexp = 100; - map[m].flag.nojobexp = (map[m].jexp==0)?1:0; + maplist[m].jexp = (state) ? atoi(w4) : 100; + if( maplist[m].jexp < 0 ) maplist[m].jexp = 100; + maplist[m].flag.nojobexp = (maplist[m].jexp==0)?1:0; } else if (!strcmpi(w3,"bexp")) { - map[m].bexp = (state) ? atoi(w4) : 100; - if( map[m].bexp < 0 ) map[m].bexp = 100; - map[m].flag.nobaseexp = (map[m].bexp==0)?1:0; + maplist[m].bexp = (state) ? atoi(w4) : 100; + if( maplist[m].bexp < 0 ) maplist[m].bexp = 100; + maplist[m].flag.nobaseexp = (maplist[m].bexp==0)?1:0; } else if (!strcmpi(w3,"loadevent")) - map[m].flag.loadevent=state; + maplist[m].flag.loadevent=state; else if (!strcmpi(w3,"nochat")) - map[m].flag.nochat=state; + maplist[m].flag.nochat=state; else if (!strcmpi(w3,"partylock")) - map[m].flag.partylock=state; + maplist[m].flag.partylock=state; else if (!strcmpi(w3,"guildlock")) - map[m].flag.guildlock=state; + maplist[m].flag.guildlock=state; else if (!strcmpi(w3,"reset")) - map[m].flag.reset=state; + maplist[m].flag.reset=state; else if (!strcmpi(w3,"notomb")) - map[m].flag.notomb=state; + maplist[m].flag.notomb=state; else if (!strcmpi(w3,"adjust_unit_duration")) { int skill_id, k; char skill_name[MAP_ZONE_MAPFLAG_LENGTH], modifier[MAP_ZONE_MAPFLAG_LENGTH]; @@ -3346,41 +3347,41 @@ const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, const char } if( modifier[0] == '\0' ) { - ShowWarning("npc_parse_mapflag: Missing 5th param for 'adjust_unit_duration' flag! removing flag from %s (file '%s', line '%d').\n", map[m].name, filepath, strline(buffer,start-buffer)); + ShowWarning("npc_parse_mapflag: Missing 5th param for 'adjust_unit_duration' flag! removing flag from %s (file '%s', line '%d').\n", maplist[m].name, filepath, strline(buffer,start-buffer)); } else if( !( skill_id = skill->name2id(skill_name) ) || !skill->get_unit_id( skill->name2id(skill_name), 0) ) { - ShowWarning("npc_parse_mapflag: Unknown skill (%s) for 'adjust_unit_duration' flag! removing flag from %s (file '%s', line '%d').\n",skill_name, map[m].name, filepath, strline(buffer,start-buffer)); + ShowWarning("npc_parse_mapflag: Unknown skill (%s) for 'adjust_unit_duration' flag! removing flag from %s (file '%s', line '%d').\n",skill_name, maplist[m].name, filepath, strline(buffer,start-buffer)); } else if ( atoi(modifier) < 1 || atoi(modifier) > USHRT_MAX ) { - ShowWarning("npc_parse_mapflag: Invalid modifier '%d' for skill '%s' for 'adjust_unit_duration' flag! removing flag from %s (file '%s', line '%d').\n", atoi(modifier), skill_name, map[m].name, filepath, strline(buffer,start-buffer)); + ShowWarning("npc_parse_mapflag: Invalid modifier '%d' for skill '%s' for 'adjust_unit_duration' flag! removing flag from %s (file '%s', line '%d').\n", atoi(modifier), skill_name, maplist[m].name, filepath, strline(buffer,start-buffer)); } else { - int idx = map[m].unit_count; + int idx = maplist[m].unit_count; - ARR_FIND(0, idx, k, map[m].units[k]->skill_id == skill_id); + ARR_FIND(0, idx, k, maplist[m].units[k]->skill_id == skill_id); if( k < idx ) { if( atoi(modifier) != 100 ) - map[m].units[k]->modifier = (unsigned short)atoi(modifier); + maplist[m].units[k]->modifier = (unsigned short)atoi(modifier); else { /* remove */ int cursor = 0; - aFree(map[m].units[k]); - map[m].units[k] = NULL; + aFree(maplist[m].units[k]); + maplist[m].units[k] = NULL; for( k = 0; k < idx; k++ ) { - if( map[m].units[k] == NULL ) + if( maplist[m].units[k] == NULL ) continue; - map[m].units[cursor] = map[m].units[k]; + maplist[m].units[cursor] = maplist[m].units[k]; cursor++; } - if( !( map[m].unit_count = cursor ) ) { - aFree(map[m].units); - map[m].units = NULL; + if( !( maplist[m].unit_count = cursor ) ) { + aFree(maplist[m].units); + maplist[m].units = NULL; } } } else if( atoi(modifier) != 100 ) { - RECREATE(map[m].units, struct mapflag_skill_adjust*, ++map[m].unit_count); - CREATE(map[m].units[idx],struct mapflag_skill_adjust,1); - map[m].units[idx]->skill_id = (unsigned short)skill_id; - map[m].units[idx]->modifier = (unsigned short)atoi(modifier); + RECREATE(maplist[m].units, struct mapflag_skill_adjust*, ++maplist[m].unit_count); + CREATE(maplist[m].units[idx],struct mapflag_skill_adjust,1); + maplist[m].units[idx]->skill_id = (unsigned short)skill_id; + maplist[m].units[idx]->modifier = (unsigned short)atoi(modifier); } } } else if (!strcmpi(w3,"adjust_skill_damage")) { @@ -3400,41 +3401,41 @@ const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, const char } if( modifier[0] == '\0' ) { - ShowWarning("npc_parse_mapflag: Missing 5th param for 'adjust_skill_damage' flag! removing flag from %s (file '%s', line '%d').\n", map[m].name, filepath, strline(buffer,start-buffer)); + ShowWarning("npc_parse_mapflag: Missing 5th param for 'adjust_skill_damage' flag! removing flag from %s (file '%s', line '%d').\n", maplist[m].name, filepath, strline(buffer,start-buffer)); } else if( !( skill_id = skill->name2id(skill_name) ) ) { - ShowWarning("npc_parse_mapflag: Unknown skill (%s) for 'adjust_skill_damage' flag! removing flag from %s (file '%s', line '%d').\n", skill_name, map[m].name, filepath, strline(buffer,start-buffer)); + ShowWarning("npc_parse_mapflag: Unknown skill (%s) for 'adjust_skill_damage' flag! removing flag from %s (file '%s', line '%d').\n", skill_name, maplist[m].name, filepath, strline(buffer,start-buffer)); } else if ( atoi(modifier) < 1 || atoi(modifier) > USHRT_MAX ) { - ShowWarning("npc_parse_mapflag: Invalid modifier '%d' for skill '%s' for 'adjust_skill_damage' flag! removing flag from %s (file '%s', line '%d').\n", atoi(modifier), skill_name, map[m].name, filepath, strline(buffer,start-buffer)); + ShowWarning("npc_parse_mapflag: Invalid modifier '%d' for skill '%s' for 'adjust_skill_damage' flag! removing flag from %s (file '%s', line '%d').\n", atoi(modifier), skill_name, maplist[m].name, filepath, strline(buffer,start-buffer)); } else { - int idx = map[m].skill_count; + int idx = maplist[m].skill_count; - ARR_FIND(0, idx, k, map[m].skills[k]->skill_id == skill_id); + ARR_FIND(0, idx, k, maplist[m].skills[k]->skill_id == skill_id); if( k < idx ) { if( atoi(modifier) != 100 ) - map[m].skills[k]->modifier = (unsigned short)atoi(modifier); + maplist[m].skills[k]->modifier = (unsigned short)atoi(modifier); else { /* remove */ int cursor = 0; - aFree(map[m].skills[k]); - map[m].skills[k] = NULL; + aFree(maplist[m].skills[k]); + maplist[m].skills[k] = NULL; for( k = 0; k < idx; k++ ) { - if( map[m].skills[k] == NULL ) + if( maplist[m].skills[k] == NULL ) continue; - map[m].skills[cursor] = map[m].skills[k]; + maplist[m].skills[cursor] = maplist[m].skills[k]; cursor++; } - if( !( map[m].skill_count = cursor ) ) { - aFree(map[m].skills); - map[m].skills = NULL; + if( !( maplist[m].skill_count = cursor ) ) { + aFree(maplist[m].skills); + maplist[m].skills = NULL; } } } else if( atoi(modifier) != 100 ) { - RECREATE(map[m].skills, struct mapflag_skill_adjust*, ++map[m].skill_count); - CREATE(map[m].skills[idx],struct mapflag_skill_adjust,1); - map[m].skills[idx]->skill_id = (unsigned short)skill_id; - map[m].skills[idx]->modifier = (unsigned short)atoi(modifier); + RECREATE(maplist[m].skills, struct mapflag_skill_adjust*, ++maplist[m].skill_count); + CREATE(maplist[m].skills[idx],struct mapflag_skill_adjust,1); + maplist[m].skills[idx]->skill_id = (unsigned short)skill_id; + maplist[m].skills[idx]->modifier = (unsigned short)atoi(modifier); } } @@ -3442,26 +3443,26 @@ const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, const char struct map_zone_data *zone; if( !(zone = strdb_get(zone_db, w4)) ) { - ShowWarning("npc_parse_mapflag: Invalid zone '%s'! removing flag from %s (file '%s', line '%d').\n", w4, map[m].name, filepath, strline(buffer,start-buffer)); - } else if( map[m].zone != zone ) { + ShowWarning("npc_parse_mapflag: Invalid zone '%s'! removing flag from %s (file '%s', line '%d').\n", w4, maplist[m].name, filepath, strline(buffer,start-buffer)); + } else if( maplist[m].zone != zone ) { iMap->zone_change(m,zone,start,buffer,filepath); } } else if ( !strcmpi(w3,"nomapchannelautojoin") ) { - map[m].flag.chsysnolocalaj = state; + maplist[m].flag.chsysnolocalaj = state; } else if ( !strcmpi(w3,"invincible_time_inc") ) { - map[m].invincible_time_inc = (state) ? atoi(w4) : 0; + maplist[m].invincible_time_inc = (state) ? atoi(w4) : 0; } else if ( !strcmpi(w3,"noknockback") ) { - map[m].flag.noknockback = state; + maplist[m].flag.noknockback = state; } else if ( !strcmpi(w3,"weapon_damage_rate") ) { - map[m].weapon_damage_rate = (state) ? atoi(w4) : 100; + maplist[m].weapon_damage_rate = (state) ? atoi(w4) : 100; } else if ( !strcmpi(w3,"magic_damage_rate") ) { - map[m].magic_damage_rate = (state) ? atoi(w4) : 100; + maplist[m].magic_damage_rate = (state) ? atoi(w4) : 100; } else if ( !strcmpi(w3,"misc_damage_rate") ) { - map[m].misc_damage_rate = (state) ? atoi(w4) : 100; + maplist[m].misc_damage_rate = (state) ? atoi(w4) : 100; } else if ( !strcmpi(w3,"short_damage_rate") ) { - map[m].short_damage_rate = (state) ? atoi(w4) : 100; + maplist[m].short_damage_rate = (state) ? atoi(w4) : 100; } else if ( !strcmpi(w3,"long_damage_rate") ) { - map[m].long_damage_rate = (state) ? atoi(w4) : 100; + maplist[m].long_damage_rate = (state) ? atoi(w4) : 100; } else ShowError("npc_parse_mapflag: unrecognized mapflag '%s' (file '%s', line '%d').\n", w3, filepath, strline(buffer,start-buffer)); @@ -3583,7 +3584,7 @@ void npc_parsesrcfile(const char* filepath, bool runOnInit) p = strchr(p,'\n');// next line continue; } - if (x < 0 || x >= map[m].xs || y < 0 || y >= map[m].ys) { + if (x < 0 || x >= maplist[m].xs || y < 0 || y >= maplist[m].ys) { ShowError("npc_parsesrcfile: Unknown coordinates ('%d', '%d') for map '%s' in file '%s', line '%d'. Skipping line...\n", x, y, mapname, filepath, strline(buffer,p-buffer)); if( strcasecmp(w2,"script") == 0 && count > 3 ) { @@ -3767,18 +3768,18 @@ int npc_reload(void) { if(battle_config.dynamic_mobs) {// dynamic check by [random] for (m = 0; m < iMap->map_num; m++) { for (i = 0; i < MAX_MOB_LIST_PER_MAP; i++) { - if (map[m].moblist[i] != NULL) { - aFree(map[m].moblist[i]); - map[m].moblist[i] = NULL; + if (maplist[m].moblist[i] != NULL) { + aFree(maplist[m].moblist[i]); + maplist[m].moblist[i] = NULL; } - if( map[m].mob_delete_timer != INVALID_TIMER ) + if( maplist[m].mob_delete_timer != INVALID_TIMER ) { // Mobs were removed anyway,so delete the timer [Inkfish] - timer->delete(map[m].mob_delete_timer, iMap->removemobs_timer); - map[m].mob_delete_timer = INVALID_TIMER; + timer->delete(maplist[m].mob_delete_timer, iMap->removemobs_timer); + maplist[m].mob_delete_timer = INVALID_TIMER; } } - if (map[m].npc_num > 0) - ShowWarning("npc_reload: %d npcs weren't removed at map %s!\n", map[m].npc_num, map[m].name); + if (maplist[m].npc_num > 0) + ShowWarning("npc_reload: %d npcs weren't removed at map %s!\n", maplist[m].npc_num, maplist[m].name); } } @@ -3889,25 +3890,24 @@ void npc_debug_warps_sub(struct npc_data* nd) if (iMap->getcell(m, nd->u.warp.x, nd->u.warp.y, CELL_CHKNPC)) { ShowWarning("Warp %s at %s(%d,%d) warps directly on top of an area npc at %s(%d,%d)\n", nd->name, - map[nd->bl.m].name, nd->bl.x, nd->bl.y, - map[m].name, nd->u.warp.x, nd->u.warp.y + maplist[nd->bl.m].name, nd->bl.x, nd->bl.y, + maplist[m].name, nd->u.warp.x, nd->u.warp.y ); } if (iMap->getcell(m, nd->u.warp.x, nd->u.warp.y, CELL_CHKNOPASS)) { ShowWarning("Warp %s at %s(%d,%d) warps to a non-walkable tile at %s(%d,%d)\n", nd->name, - map[nd->bl.m].name, nd->bl.x, nd->bl.y, - map[m].name, nd->u.warp.x, nd->u.warp.y + maplist[nd->bl.m].name, nd->bl.x, nd->bl.y, + maplist[m].name, nd->u.warp.x, nd->u.warp.y ); } } -static void npc_debug_warps(void) -{ +static void npc_debug_warps(void) { int16 m, i; for (m = 0; m < iMap->map_num; m++) - for (i = 0; i < map[m].npc_num; i++) - npc->debug_warps_sub(map[m].npc[i]); + for (i = 0; i < maplist[m].npc_num; i++) + npc->debug_warps_sub(maplist[m].npc[i]); } /*========================================== diff --git a/src/map/party.c b/src/map/party.c index 88d6cc0bf..2682cf03b 100644 --- a/src/map/party.c +++ b/src/map/party.c @@ -665,8 +665,7 @@ bool party_changeleader(struct map_session_data *sd, struct map_session_data *ts return false; } - if( map[sd->bl.m].flag.partylock ) - { + if( maplist[sd->bl.m].flag.partylock ) { clif->message(sd->fd, msg_txt(287)); return false; } @@ -707,7 +706,7 @@ bool party_changeleader(struct map_session_data *sd, struct map_session_data *ts /// - changes maps /// - logs in or out /// - gains a level (disabled) -int party_recv_movemap(int party_id,int account_id,int char_id, unsigned short map,int online,int lv) +int party_recv_movemap(int party_id,int account_id,int char_id, unsigned short mapid,int online,int lv) { struct party_member* m; struct party_data* p; @@ -725,7 +724,7 @@ int party_recv_movemap(int party_id,int account_id,int char_id, unsigned short m } m = &p->party.member[i]; - m->map = map; + m->map = mapid; m->online = online; m->lv = lv; //Check if they still exist on this map server diff --git a/src/map/party.h b/src/map/party.h index 3ce47141c..7ade6b841 100644 --- a/src/map/party.h +++ b/src/map/party.h @@ -97,7 +97,7 @@ struct party_interface { void (*reply_invite) (struct map_session_data *sd,int party_id,int flag); int (*recv_noinfo) (int party_id, int char_id); int (*recv_info) (struct party* sp, int char_id); - int (*recv_movemap) (int party_id,int account_id,int char_id, unsigned short map,int online,int lv); + int (*recv_movemap) (int party_id,int account_id,int char_id, unsigned short mapid,int online,int lv); int (*broken) (int party_id); int (*optionchanged) (int party_id,int account_id,int exp,int item,int flag); int (*changeoption) (struct map_session_data *sd,int exp,int item); diff --git a/src/map/path.c b/src/map/path.c index 2de3eab00..79e004601 100644 --- a/src/map/path.c +++ b/src/map/path.c @@ -68,9 +68,9 @@ int path_blownpos(int16 m,int16 x0,int16 y0,int16 dx,int16 dy,int count) { struct map_data *md; - if( !map[m].cell ) + if( !maplist[m].cell ) return -1; - md = &map[m]; + md = &maplist[m]; if( count>25 ){ //Cap to prevent too much processing...? ShowWarning("path_blownpos: count too many %d !\n",count); @@ -121,9 +121,9 @@ bool path_search_long(struct shootpath_data *spd,int16 m,int16 x0,int16 y0,int16 if( spd == NULL ) spd = &s_spd; // use dummy output variable - if (!map[m].cell) + if (!maplist[m].cell) return false; - md = &map[m]; + md = &maplist[m]; dx = (x1 - x0); if (dx < 0) { @@ -255,9 +255,9 @@ bool path_search(struct walkpath_data *wpd, int16 m, int16 x0, int16 y0, int16 x if (wpd == NULL) wpd = &s_wpd; // use dummy output variable - if (!map[m].cell) + if (!maplist[m].cell) return false; - md = &map[m]; + md = &maplist[m]; #ifdef CELL_NOSTACK //Do not check starting cell as that would get you stuck. diff --git a/src/map/pc.c b/src/map/pc.c index c485baa43..86ee7a8db 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -176,7 +176,7 @@ static int pc_invincible_timer(int tid, unsigned int tick, int id, intptr_t data void pc_setinvincibletimer(struct map_session_data* sd, int val) { nullpo_retv(sd); - val += map[sd->bl.m].invincible_time_inc; + val += maplist[sd->bl.m].invincible_time_inc; if( sd->invincible_timer != INVALID_TIMER ) timer->delete(sd->invincible_timer,pc_invincible_timer); @@ -594,8 +594,8 @@ int pc_makesavestatus(struct map_session_data *sd) sd->status.last_point.y = sd->bl.y; } - if(map[sd->bl.m].flag.nosave || map[sd->bl.m].instance_id >= 0){ - struct map_data *m=&map[sd->bl.m]; + if(maplist[sd->bl.m].flag.nosave || maplist[sd->bl.m].instance_id >= 0) { + struct map_data *m=&maplist[sd->bl.m]; if(m->save.map) memcpy(&sd->status.last_point,&m->save,sizeof(sd->status.last_point)); else @@ -1320,9 +1320,9 @@ int pc_reg_received(struct map_session_data *sd) sd->vd.class_ = INVISIBLE_CLASS; clif->message(sd->fd, msg_txt(11)); // Invisible: On // decrement the number of pvp players on the map - map[sd->bl.m].users_pvp--; + maplist[sd->bl.m].users_pvp--; - if( map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.pvp_nocalcrank && sd->pvp_timer != INVALID_TIMER ) {// unregister the player for ranking + if( maplist[sd->bl.m].flag.pvp && !maplist[sd->bl.m].flag.pvp_nocalcrank && sd->pvp_timer != INVALID_TIMER ) {// unregister the player for ranking timer->delete( sd->pvp_timer, pc->calc_pvprank_timer ); sd->pvp_timer = INVALID_TIMER; } @@ -4049,8 +4049,7 @@ int pc_dropitem(struct map_session_data *sd,int n,int amount) ) return 0; - if( map[sd->bl.m].flag.nodrop ) - { + if( maplist[sd->bl.m].flag.nodrop ) { clif->message (sd->fd, msg_txt(271)); return 0; //Can't drop items in nodrop mapflag maps. } @@ -4181,8 +4180,7 @@ int pc_isUseitem(struct map_session_data *sd,int n) break; case 601: // Fly Wing case 12212: // Giant Fly Wing - if( map[sd->bl.m].flag.noteleport || map_flag_gvg2(sd->bl.m) ) - { + if( maplist[sd->bl.m].flag.noteleport || map_flag_gvg2(sd->bl.m) ) { clif->skill_mapinfomessage(sd,0); return 0; } @@ -4199,14 +4197,14 @@ int pc_isUseitem(struct map_session_data *sd,int n) clif->message(sd->fd, msg_txt(663)); return 0; } - if( nameid != 601 && nameid != 12212 && map[sd->bl.m].flag.noreturn ) + if( nameid != 601 && nameid != 12212 && maplist[sd->bl.m].flag.noreturn ) return 0; break; case 604: // Dead Branch case 12024: // Red Pouch case 12103: // Bloody Branch case 12109: // Poring Box - if( map[sd->bl.m].flag.nobranch || map_flag_gvg2(sd->bl.m) ) + if( maplist[sd->bl.m].flag.nobranch || map_flag_gvg2(sd->bl.m) ) return 0; break; case 12210: // Bubble Gum @@ -4247,7 +4245,7 @@ int pc_isUseitem(struct map_session_data *sd,int n) break; case 12213: //Neuralizer - if( !map[sd->bl.m].flag.reset ) + if( !maplist[sd->bl.m].flag.reset ) return 0; break; } @@ -4421,8 +4419,8 @@ int pc_useitem(struct map_session_data *sd,int n) { } /* on restricted maps the item is consumed but the effect is not used */ - for(i = 0; i < map[sd->bl.m].zone->disabled_items_count; i++) { - if( map[sd->bl.m].zone->disabled_items[i] == nameid ) { + for(i = 0; i < maplist[sd->bl.m].zone->disabled_items_count; i++) { + if( maplist[sd->bl.m].zone->disabled_items[i] == nameid ) { clif->msg(sd, ITEM_CANT_USE_AREA); // This item cannot be used within this area if( battle_config.item_restricted_consumption_type ) { clif->useitemack(sd,n,sd->status.inventory[n].amount-1,true); @@ -4692,7 +4690,7 @@ int pc_steal_item(struct map_session_data *sd,struct block_list *bl, uint16 skil md_status= iStatus->get_status_data(bl); if( md->master_id || md_status->mode&MD_BOSS || mob_is_treasure(md) || - map[bl->m].flag.nomobloot || // check noloot map flag [Lorky] + maplist[bl->m].flag.nomobloot || // check noloot map flag [Lorky] (battle_config.skill_steal_max_tries && //Reached limit of steal attempts. [Lupus] md->state.steal_flag++ >= battle_config.skill_steal_max_tries) ) { //Can't steal from @@ -4800,7 +4798,7 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y pc->setrestartvalue(sd,1); } - if( map[m].flag.src4instance ) { + if( maplist[m].flag.src4instance ) { struct party_data *p; bool stop = false; int i = 0, j = 0; @@ -4808,7 +4806,7 @@ 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, map[instances[sd->instance[i]].map[j]].instance_src_map == m && !map[instances[sd->instance[i]].map[j]].custom_name); + 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 ) break; } @@ -4822,7 +4820,7 @@ 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, map[instances[p->instance[i]].map[j]].instance_src_map == m && !map[instances[p->instance[i]].map[j]].custom_name); + 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 ) break; } @@ -4836,7 +4834,7 @@ 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, map[instances[sd->guild->instance[i]].map[j]].instance_src_map == m && !map[instances[sd->guild->instance[i]].map[j]].custom_name); + 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 ) break; } @@ -4859,13 +4857,13 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y for( i = 0; i < sd->queues_count; i++ ) { struct hQueue *queue; if( (queue = script->queue(sd->queues[i])) && queue->onMapChange[0] != '\0' ) { - pc->setregstr(sd, script->add_str("QMapChangeTo"), map[m].name); + pc->setregstr(sd, script->add_str("QMapChangeTo"), maplist[m].name); npc->event(sd, queue->onMapChange, 0); } } - if( map[m].cell == (struct mapcell *)0xdeadbeaf ) - iMap->cellfromcache(&map[m]); + if( maplist[m].cell == (struct mapcell *)0xdeadbeaf ) + iMap->cellfromcache(&maplist[m]); if (sd->sc.count) { // Cancel some map related stuff. if (sd->sc.data[SC_JAILED]) return 1; //You may not get out! @@ -4898,13 +4896,13 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y if (sd->regen.state.gc) sd->regen.state.gc = 0; // make sure vending is allowed here - if (sd->state.vending && map[m].flag.novending) { + if (sd->state.vending && maplist[m].flag.novending) { clif->message (sd->fd, msg_txt(276)); // "You can't open a shop on this map" vending->close(sd); } - if( hChSys.local && map[sd->bl.m].channel && idb_exists(map[sd->bl.m].channel->users, sd->status.char_id) ) { - clif->chsys_left(map[sd->bl.m].channel,sd); + if( hChSys.local && maplist[sd->bl.m].channel && idb_exists(maplist[sd->bl.m].channel->users, sd->status.char_id) ) { + clif->chsys_left(maplist[sd->bl.m].channel,sd); } } @@ -4933,15 +4931,15 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y return 0; } - if( x < 0 || x >= map[m].xs || y < 0 || y >= map[m].ys ) { + if( x < 0 || x >= maplist[m].xs || y < 0 || y >= maplist[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); x = y = 0; // make it random } if( x == 0 && y == 0 ) {// pick a random walkable cell do { - x=rnd()%(map[m].xs-2)+1; - y=rnd()%(map[m].ys-2)+1; + x=rnd()%(maplist[m].xs-2)+1; + y=rnd()%(maplist[m].ys-2)+1; } while(iMap->getcell(m,x,y,CELL_CHKNOPASS)); } @@ -4962,7 +4960,7 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y sd->bl.x = sd->ud.to_x = x; sd->bl.y = sd->ud.to_y = y; - if( sd->status.guild_id > 0 && map[m].flag.gvg_castle ) { // Increased guild castle regen [Valaris] + if( sd->status.guild_id > 0 && maplist[m].flag.gvg_castle ) { // Increased guild castle regen [Valaris] struct guild_castle *gc = guild->mapindex2gc(sd->mapindex); if(gc && gc->guild_id == sd->status.guild_id) sd->regen.state.gc = 1; @@ -5007,12 +5005,12 @@ int pc_randomwarp(struct map_session_data *sd, clr_type type) { m=sd->bl.m; - if (map[sd->bl.m].flag.noteleport) //Teleport forbidden + if (maplist[sd->bl.m].flag.noteleport) //Teleport forbidden return 0; do { - x=rnd()%(map[m].xs-2)+1; - y=rnd()%(map[m].ys-2)+1; + x=rnd()%(maplist[m].xs-2)+1; + y=rnd()%(maplist[m].ys-2)+1; } while( iMap->getcell(m,x,y,CELL_CHKNOPASS) && (i++) < 1000 ); if (i < 1000) @@ -5031,7 +5029,7 @@ int pc_memo(struct map_session_data* sd, int pos) { nullpo_ret(sd); // check mapflags - if( sd->bl.m >= 0 && (map[sd->bl.m].flag.nomemo || map[sd->bl.m].flag.nowarpto) && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE) ) { + if( sd->bl.m >= 0 && (maplist[sd->bl.m].flag.nomemo || maplist[sd->bl.m].flag.nowarpto) && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE) ) { clif->skill_mapinfomessage(sd, 1); // "Saved point cannot be memorized." return 0; } @@ -5888,7 +5886,7 @@ int pc_gainexp(struct map_session_data *sd, struct block_list *src, unsigned int if(sd->bl.prev == NULL || pc_isdead(sd)) return 0; - if(!battle_config.pvp_exp && map[sd->bl.m].flag.pvp) // [MouseJstr] + if(!battle_config.pvp_exp && maplist[sd->bl.m].flag.pvp) // [MouseJstr] return 0; // no exp on pvp maps if(sd->status.guild_id>0) @@ -6707,7 +6705,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) { if(sd->status.pet_id > 0 && sd->pd) { struct pet_data *pd = sd->pd; - if( !map[sd->bl.m].flag.noexppenalty ) { + if( !maplist[sd->bl.m].flag.noexppenalty ) { pet->set_intimate(pd, pd->pet.intimate - pd->petDB->die); if( pd->pet.intimate < 0 ) pd->pet.intimate = 0; @@ -6864,9 +6862,9 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) { } } - if(battle_config.bone_drop==2 - || (battle_config.bone_drop==1 && map[sd->bl.m].flag.pvp)) - { + if( battle_config.bone_drop==2 + || (battle_config.bone_drop==1 && maplist[sd->bl.m].flag.pvp) + ) { struct item item_tmp; memset(&item_tmp,0,sizeof(item_tmp)); item_tmp.nameid=ITEMID_SKULL_; @@ -6898,11 +6896,11 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) { } // changed penalty options, added death by player if pk_mode [Valaris] - if(battle_config.death_penalty_type - && (sd->class_&MAPID_UPPERMASK) != MAPID_NOVICE // only novices will receive no penalty - && !map[sd->bl.m].flag.noexppenalty && !map_flag_gvg2(sd->bl.m) - && !sd->sc.data[SC_BABY] && !sd->sc.data[SC_CASH_DEATHPENALTY]) - { + if( battle_config.death_penalty_type + && (sd->class_&MAPID_UPPERMASK) != MAPID_NOVICE // only novices will receive no penalty + && !maplist[sd->bl.m].flag.noexppenalty && !map_flag_gvg2(sd->bl.m) + && !sd->sc.data[SC_BABY] && !sd->sc.data[SC_CASH_DEATHPENALTY] + ) { unsigned int base_penalty =0; if (battle_config.death_penalty_base > 0) { switch (battle_config.death_penalty_type) { @@ -6938,7 +6936,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) { clif->updatestatus(sd,SP_JOBEXP); } } - if(battle_config.zeny_penalty > 0 && !map[sd->bl.m].flag.nozenypenalty) + if(battle_config.zeny_penalty > 0 && !maplist[sd->bl.m].flag.nozenypenalty) { base_penalty = (unsigned int)((double)sd->status.zeny * (double)battle_config.zeny_penalty / 10000.); if(base_penalty) @@ -6946,12 +6944,12 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) { } } - if(map[sd->bl.m].flag.pvp_nightmaredrop) - { // Moved this outside so it works when PVP isn't enabled and during pk mode [Ancyker] - for(j=0;j<map[sd->bl.m].drop_list_count;j++){ - int id = map[sd->bl.m].drop_list[j].drop_id; - int type = map[sd->bl.m].drop_list[j].drop_type; - int per = map[sd->bl.m].drop_list[j].drop_per; + if(maplist[sd->bl.m].flag.pvp_nightmaredrop) { + // Moved this outside so it works when PVP isn't enabled and during pk mode [Ancyker] + for(j=0;j<maplist[sd->bl.m].drop_list_count;j++){ + int id = maplist[sd->bl.m].drop_list[j].drop_id; + int type = maplist[sd->bl.m].drop_list[j].drop_type; + int per = maplist[sd->bl.m].drop_list[j].drop_per; if(id == 0) continue; if(id == -1){ @@ -6997,8 +6995,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) { } // pvp // disable certain pvp functions on pk_mode [Valaris] - if( map[sd->bl.m].flag.pvp && !battle_config.pk_mode && !map[sd->bl.m].flag.pvp_nocalcrank ) - { + if( maplist[sd->bl.m].flag.pvp && !battle_config.pk_mode && !maplist[sd->bl.m].flag.pvp_nocalcrank ) { sd->pvp_point -= 5; sd->pvp_lost++; if( src && src->type == BL_PC ) @@ -9048,11 +9045,10 @@ int pc_calc_pvprank_sub(struct block_list *bl,va_list ap) * Calculate new rank beetween all present players (iMap->foreachinarea) * and display result *------------------------------------------*/ -int pc_calc_pvprank(struct map_session_data *sd) -{ +int pc_calc_pvprank(struct map_session_data *sd) { int old; struct map_data *m; - m=&map[sd->bl.m]; + m=&maplist[sd->bl.m]; old=sd->pvp_rank; sd->pvp_rank=1; iMap->foreachinmap(pc_calc_pvprank_sub,sd->bl.m,BL_PC,sd); @@ -9324,9 +9320,8 @@ int pc_autosave(int tid, unsigned int tick, int id, intptr_t data) return 0; } -static int pc_daynight_timer_sub(struct map_session_data *sd,va_list ap) -{ - if (sd->state.night != iMap->night_flag && map[sd->bl.m].flag.nightenabled) { //Night/day state does not match. +static int pc_daynight_timer_sub(struct map_session_data *sd,va_list ap) { + if (sd->state.night != iMap->night_flag && maplist[sd->bl.m].flag.nightenabled) { //Night/day state does not match. clif->status_change(&sd->bl, SI_SKE, iMap->night_flag, 0, 0, 0, 0); //New night effect by dynamix [Skotlex] sd->state.night = iMap->night_flag; return 1; diff --git a/src/map/script.c b/src/map/script.c index 6ef015009..d9794e3cd 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -326,13 +326,13 @@ static void script_reportsrc(struct script_state *st) switch( bl->type ) { case BL_NPC: if( bl->m >= 0 ) - ShowDebug("Source (NPC): %s at %s (%d,%d)\n", ((struct npc_data *)bl)->name, map[bl->m].name, bl->x, bl->y); + ShowDebug("Source (NPC): %s at %s (%d,%d)\n", ((struct npc_data *)bl)->name, maplist[bl->m].name, bl->x, bl->y); else ShowDebug("Source (NPC): %s (invisible/not on a map)\n", ((struct npc_data *)bl)->name); break; default: if( bl->m >= 0 ) - ShowDebug("Source (Non-NPC type %d): name %s at %s (%d,%d)\n", bl->type, iStatus->get_name(bl), map[bl->m].name, bl->x, bl->y); + ShowDebug("Source (Non-NPC type %d): name %s at %s (%d,%d)\n", bl->type, iStatus->get_name(bl), maplist[bl->m].name, bl->x, bl->y); else ShowDebug("Source (Non-NPC type %d): name %s (invisible/not on a map)\n", bl->type, iStatus->get_name(bl)); break; @@ -3429,8 +3429,7 @@ void script_attach_state(struct script_state* st) { /*========================================== * The main part of the script execution *------------------------------------------*/ -void run_script_main(struct script_state *st) -{ +void run_script_main(struct script_state *st) { int cmdcount = script->config.check_cmdcount; int gotocount = script->config.check_gotocount; TBL_PC *sd; @@ -3441,7 +3440,7 @@ void run_script_main(struct script_state *st) nd = iMap->id2nd(st->oid); if( nd && nd->bl.m >= 0 ) - st->instance_id = map[nd->bl.m].instance_id; + st->instance_id = maplist[nd->bl.m].instance_id; else st->instance_id = -1; @@ -4777,12 +4776,11 @@ BUILDIN(warpparty) break; } - for (i = 0; i < MAX_PARTY; i++) - { + for (i = 0; i < MAX_PARTY; i++) { if( !(pl_sd = p->data[i].sd) || pl_sd->status.party_id != p_id ) continue; - if( str2 && strcmp(str2, map[pl_sd->bl.m].name) != 0 ) + if( str2 && strcmp(str2, maplist[pl_sd->bl.m].name) != 0 ) continue; if( pc_isdead(pl_sd) ) @@ -4791,20 +4789,20 @@ BUILDIN(warpparty) switch( type ) { case 0: // Random - if(!map[pl_sd->bl.m].flag.nowarp) + if(!maplist[pl_sd->bl.m].flag.nowarp) pc->randomwarp(pl_sd,CLR_TELEPORT); break; case 1: // SavePointAll - if(!map[pl_sd->bl.m].flag.noreturn) + if(!maplist[pl_sd->bl.m].flag.noreturn) pc->setpos(pl_sd,pl_sd->status.save_point.map,pl_sd->status.save_point.x,pl_sd->status.save_point.y,CLR_TELEPORT); break; case 2: // SavePoint - if(!map[pl_sd->bl.m].flag.noreturn) + if(!maplist[pl_sd->bl.m].flag.noreturn) pc->setpos(pl_sd,sd->status.save_point.map,sd->status.save_point.x,sd->status.save_point.y,CLR_TELEPORT); break; case 3: // Leader case 4: // m,x,y - if(!map[pl_sd->bl.m].flag.noreturn && !map[pl_sd->bl.m].flag.nowarp) + if(!maplist[pl_sd->bl.m].flag.noreturn && !maplist[pl_sd->bl.m].flag.nowarp) pc->setpos(pl_sd,mapindex,x,y,CLR_TELEPORT); break; } @@ -4852,19 +4850,19 @@ BUILDIN(warpguild) switch( type ) { case 0: // Random - if(!map[pl_sd->bl.m].flag.nowarp) + if(!maplist[pl_sd->bl.m].flag.nowarp) pc->randomwarp(pl_sd,CLR_TELEPORT); break; case 1: // SavePointAll - if(!map[pl_sd->bl.m].flag.noreturn) + if(!maplist[pl_sd->bl.m].flag.noreturn) pc->setpos(pl_sd,pl_sd->status.save_point.map,pl_sd->status.save_point.x,pl_sd->status.save_point.y,CLR_TELEPORT); break; case 2: // SavePoint - if(!map[pl_sd->bl.m].flag.noreturn) + if(!maplist[pl_sd->bl.m].flag.noreturn) pc->setpos(pl_sd,sd->status.save_point.map,sd->status.save_point.x,sd->status.save_point.y,CLR_TELEPORT); break; case 3: // m,x,y - if(!map[pl_sd->bl.m].flag.noreturn && !map[pl_sd->bl.m].flag.nowarp) + if(!maplist[pl_sd->bl.m].flag.noreturn && !maplist[pl_sd->bl.m].flag.nowarp) pc->setpos(pl_sd,mapindex_name2id(str),x,y,CLR_TELEPORT); break; } @@ -6887,7 +6885,7 @@ BUILDIN(strcharinfo) } break; case 3: - script_pushconststr(st,map[sd->bl.m].name); + script_pushconststr(st,maplist[sd->bl.m].name); break; default: ShowWarning("buildin_strcharinfo: unknown parameter.\n"); @@ -6940,7 +6938,7 @@ BUILDIN(strnpcinfo) name = aStrdup(nd->exname); break; case 4: // map name - name = aStrdup(map[nd->bl.m].name); + name = aStrdup(maplist[nd->bl.m].name); break; } @@ -8125,11 +8123,10 @@ BUILDIN(setmadogear) /// /// save "<map name>",<x>,<y> /// savepoint "<map name>",<x>,<y> -BUILDIN(savepoint) -{ +BUILDIN(savepoint) { int x; int y; - short map; + short mapid; const char* str; TBL_PC* sd; @@ -8137,12 +8134,12 @@ BUILDIN(savepoint) if( sd == NULL ) return true;// no player attached, report source - str = script_getstr(st, 2); - x = script_getnum(st,3); - y = script_getnum(st,4); - map = mapindex_name2id(str); - if( map ) - pc->setsavepoint(sd, map, x, y); + str = script_getstr(st,2); + x = script_getnum(st,3); + y = script_getnum(st,4); + mapid = mapindex_name2id(str); + if( mapid ) + pc->setsavepoint(sd, mapid, x, y); return true; } @@ -8498,7 +8495,7 @@ BUILDIN(monster) return false; } - if (map[m].flag.src4instance && st->instance_id >= 0) { // Try to redirect to the instance map, not the src map + if (maplist[m].flag.src4instance && st->instance_id >= 0) { // Try to redirect to the instance map, not the src map if ((m = instance->mapid2imapid(m, st->instance_id)) < 0) { ShowError("buildin_monster: Trying to spawn monster (%d) on instance map (%s) without instance attached.\n", class_, mapn); return false; @@ -8596,7 +8593,7 @@ BUILDIN(areamonster) ShowWarning("buildin_areamonster: Attempted to spawn monster class %d on non-existing map '%s'\n",class_, mapn); return false; } - if (map[m].flag.src4instance && st->instance_id >= 0) { // Try to redirect to the instance map, not the src map + if (maplist[m].flag.src4instance && st->instance_id >= 0) { // Try to redirect to the instance map, not the src map if ((m = instance->mapid2imapid(m, st->instance_id)) < 0) { ShowError("buildin_areamonster: Trying to spawn monster (%d) on instance map (%s) without instance attached.\n", class_, mapn); return false; @@ -8659,7 +8656,7 @@ BUILDIN(killmonster) if( (m=iMap->mapname2mapid(mapname))<0 ) return true; - if( map[m].flag.src4instance && st->instance_id >= 0 && (m = instance->mapid2imapid(m, st->instance_id)) < 0 ) + if( maplist[m].flag.src4instance && st->instance_id >= 0 && (m = instance->mapid2imapid(m, st->instance_id)) < 0 ) return true; if( script_hasdata(st,4) ) { @@ -8700,7 +8697,7 @@ BUILDIN(killmonsterall) if( (m = iMap->mapname2mapid(mapname))<0 ) return true; - if( map[m].flag.src4instance && st->instance_id >= 0 && (m = instance->mapid2imapid(m, st->instance_id)) < 0 ) + if( maplist[m].flag.src4instance && st->instance_id >= 0 && (m = instance->mapid2imapid(m, st->instance_id)) < 0 ) return true; if( script_hasdata(st,3) ) { @@ -8718,14 +8715,13 @@ BUILDIN(killmonsterall) * Creates a clone of a player. * clone map, x, y, event, char_id, master_id, mode, flag, duration *------------------------------------------*/ -BUILDIN(clone) -{ +BUILDIN(clone) { TBL_PC *sd, *msd=NULL; int char_id,master_id=0,x,y, mode = 0, flag = 0, m; unsigned int duration = 0; - const char *map,*event=""; + const char *mapname, *event=""; - map=script_getstr(st,2); + mapname=script_getstr(st,2); x=script_getnum(st,3); y=script_getnum(st,4); event=script_getstr(st,5); @@ -8745,7 +8741,7 @@ BUILDIN(clone) check_event(st, event); - m = iMap->mapname2mapid(map); + m = iMap->mapname2mapid(mapname); if (m < 0) return true; sd = iMap->charid2sd(char_id); @@ -9274,29 +9270,25 @@ BUILDIN(areaannounce) /*========================================== *------------------------------------------*/ -BUILDIN(getusers) -{ +BUILDIN(getusers) { int flag, val = 0; struct map_session_data* sd; struct block_list* bl = NULL; flag = script_getnum(st,2); - switch(flag&0x07) - { + switch(flag&0x07) { case 0: - if(flag&0x8) - {// npc + if(flag&0x8) { + // npc bl = iMap->id2bl(st->oid); - } - else if((sd = script_rid2sd(st))!=NULL) - {// pc + } else if((sd = script_rid2sd(st))!=NULL) { + // pc bl = &sd->bl; } - if(bl) - { - val = map[bl->m].users; + if(bl) { + val = maplist[bl->m].users; } break; case 1: @@ -9371,8 +9363,7 @@ BUILDIN(getmapguildusers) } /*========================================== *------------------------------------------*/ -BUILDIN(getmapusers) -{ +BUILDIN(getmapusers) { const char *str; int16 m; str=script_getstr(st,2); @@ -9380,7 +9371,7 @@ BUILDIN(getmapusers) script_pushint(st,-1); return true; } - script_pushint(st,map[m].users); + script_pushint(st,maplist[m].users); return true; } /*========================================== @@ -10194,8 +10185,7 @@ BUILDIN(getwaitingroomstate) /// /// warpwaitingpc "<map name>",<x>,<y>,<number of players>; /// warpwaitingpc "<map name>",<x>,<y>; -BUILDIN(warpwaitingpc) -{ +BUILDIN(warpwaitingpc) { int x; int y; int i; @@ -10217,19 +10207,18 @@ BUILDIN(warpwaitingpc) if( script_hasdata(st,5) ) n = script_getnum(st,5); - for( i = 0; i < n && cd->users > 0; i++ ) - { + for( i = 0; i < n && cd->users > 0; i++ ) { sd = cd->usersd[0]; - if( strcmp(map_name,"SavePoint") == 0 && map[sd->bl.m].flag.noteleport ) - {// can't teleport on this map + if( strcmp(map_name,"SavePoint") == 0 && maplist[sd->bl.m].flag.noteleport ) { + // can't teleport on this map break; } - if( cd->zeny ) - {// fee set - if( (uint32)sd->status.zeny < cd->zeny ) - {// no zeny to cover set fee + if( cd->zeny ) { + // fee set + if( (uint32)sd->status.zeny < cd->zeny ) { + // no zeny to cover set fee break; } pc->payzeny(sd, cd->zeny, LOG_TYPE_NPC, NULL); @@ -10318,10 +10307,10 @@ BUILDIN(setmapflagnosave) mapindex = mapindex_name2id(str2); if(m >= 0 && mapindex) { - map[m].flag.nosave=1; - map[m].save.map=mapindex; - map[m].save.x=x; - map[m].save.y=y; + maplist[m].flag.nosave=1; + maplist[m].save.map=mapindex; + maplist[m].save.x=x; + maplist[m].save.y=y; } return true; @@ -10338,56 +10327,56 @@ BUILDIN(getmapflag) m = iMap->mapname2mapid(str); if(m >= 0) { switch(i) { - case MF_NOMEMO: script_pushint(st,map[m].flag.nomemo); break; - case MF_NOTELEPORT: script_pushint(st,map[m].flag.noteleport); break; - case MF_NOSAVE: script_pushint(st,map[m].flag.nosave); break; - case MF_NOBRANCH: script_pushint(st,map[m].flag.nobranch); break; - case MF_NOPENALTY: script_pushint(st,map[m].flag.noexppenalty); break; - case MF_NOZENYPENALTY: script_pushint(st,map[m].flag.nozenypenalty); break; - case MF_PVP: script_pushint(st,map[m].flag.pvp); break; - case MF_PVP_NOPARTY: script_pushint(st,map[m].flag.pvp_noparty); break; - case MF_PVP_NOGUILD: script_pushint(st,map[m].flag.pvp_noguild); break; - case MF_GVG: script_pushint(st,map[m].flag.gvg); break; - case MF_GVG_NOPARTY: script_pushint(st,map[m].flag.gvg_noparty); break; - case MF_NOTRADE: script_pushint(st,map[m].flag.notrade); break; - case MF_NOSKILL: script_pushint(st,map[m].flag.noskill); break; - case MF_NOWARP: script_pushint(st,map[m].flag.nowarp); break; - case MF_PARTYLOCK: script_pushint(st,map[m].flag.partylock); break; - case MF_NOICEWALL: script_pushint(st,map[m].flag.noicewall); break; - case MF_SNOW: script_pushint(st,map[m].flag.snow); break; - case MF_FOG: script_pushint(st,map[m].flag.fog); break; - case MF_SAKURA: script_pushint(st,map[m].flag.sakura); break; - case MF_LEAVES: script_pushint(st,map[m].flag.leaves); break; - case MF_CLOUDS: script_pushint(st,map[m].flag.clouds); break; - case MF_CLOUDS2: script_pushint(st,map[m].flag.clouds2); break; - case MF_FIREWORKS: script_pushint(st,map[m].flag.fireworks); break; - case MF_GVG_CASTLE: script_pushint(st,map[m].flag.gvg_castle); break; - case MF_GVG_DUNGEON: script_pushint(st,map[m].flag.gvg_dungeon); break; - case MF_NIGHTENABLED: script_pushint(st,map[m].flag.nightenabled); break; - case MF_NOBASEEXP: script_pushint(st,map[m].flag.nobaseexp); break; - case MF_NOJOBEXP: script_pushint(st,map[m].flag.nojobexp); break; - case MF_NOMOBLOOT: script_pushint(st,map[m].flag.nomobloot); break; - case MF_NOMVPLOOT: script_pushint(st,map[m].flag.nomvploot); break; - case MF_NORETURN: script_pushint(st,map[m].flag.noreturn); break; - case MF_NOWARPTO: script_pushint(st,map[m].flag.nowarpto); break; - case MF_NIGHTMAREDROP: script_pushint(st,map[m].flag.pvp_nightmaredrop); break; - case MF_NOCOMMAND: script_pushint(st,map[m].nocommand); break; - case MF_NODROP: script_pushint(st,map[m].flag.nodrop); break; - case MF_JEXP: script_pushint(st,map[m].jexp); break; - case MF_BEXP: script_pushint(st,map[m].bexp); break; - case MF_NOVENDING: script_pushint(st,map[m].flag.novending); break; - case MF_LOADEVENT: script_pushint(st,map[m].flag.loadevent); break; - case MF_NOCHAT: script_pushint(st,map[m].flag.nochat); break; - case MF_NOEXPPENALTY: script_pushint(st,map[m].flag.noexppenalty ); break; - case MF_GUILDLOCK: script_pushint(st,map[m].flag.guildlock); break; - case MF_TOWN: script_pushint(st,map[m].flag.town); break; - case MF_AUTOTRADE: script_pushint(st,map[m].flag.autotrade); break; - case MF_ALLOWKS: script_pushint(st,map[m].flag.allowks); break; - case MF_MONSTER_NOTELEPORT: script_pushint(st,map[m].flag.monster_noteleport); break; - case MF_PVP_NOCALCRANK: script_pushint(st,map[m].flag.pvp_nocalcrank); break; - case MF_BATTLEGROUND: script_pushint(st,map[m].flag.battleground); break; - case MF_RESET: script_pushint(st,map[m].flag.reset); break; - case MF_NOTOMB: script_pushint(st,map[m].flag.notomb); break; + case MF_NOMEMO: script_pushint(st,maplist[m].flag.nomemo); break; + case MF_NOTELEPORT: script_pushint(st,maplist[m].flag.noteleport); break; + case MF_NOSAVE: script_pushint(st,maplist[m].flag.nosave); break; + case MF_NOBRANCH: script_pushint(st,maplist[m].flag.nobranch); break; + case MF_NOPENALTY: script_pushint(st,maplist[m].flag.noexppenalty); break; + case MF_NOZENYPENALTY: script_pushint(st,maplist[m].flag.nozenypenalty); break; + case MF_PVP: script_pushint(st,maplist[m].flag.pvp); break; + case MF_PVP_NOPARTY: script_pushint(st,maplist[m].flag.pvp_noparty); break; + case MF_PVP_NOGUILD: script_pushint(st,maplist[m].flag.pvp_noguild); break; + case MF_GVG: script_pushint(st,maplist[m].flag.gvg); break; + case MF_GVG_NOPARTY: script_pushint(st,maplist[m].flag.gvg_noparty); break; + case MF_NOTRADE: script_pushint(st,maplist[m].flag.notrade); break; + case MF_NOSKILL: script_pushint(st,maplist[m].flag.noskill); break; + case MF_NOWARP: script_pushint(st,maplist[m].flag.nowarp); break; + case MF_PARTYLOCK: script_pushint(st,maplist[m].flag.partylock); break; + case MF_NOICEWALL: script_pushint(st,maplist[m].flag.noicewall); break; + case MF_SNOW: script_pushint(st,maplist[m].flag.snow); break; + case MF_FOG: script_pushint(st,maplist[m].flag.fog); break; + case MF_SAKURA: script_pushint(st,maplist[m].flag.sakura); break; + case MF_LEAVES: script_pushint(st,maplist[m].flag.leaves); break; + case MF_CLOUDS: script_pushint(st,maplist[m].flag.clouds); break; + case MF_CLOUDS2: script_pushint(st,maplist[m].flag.clouds2); break; + case MF_FIREWORKS: script_pushint(st,maplist[m].flag.fireworks); break; + case MF_GVG_CASTLE: script_pushint(st,maplist[m].flag.gvg_castle); break; + case MF_GVG_DUNGEON: script_pushint(st,maplist[m].flag.gvg_dungeon); break; + case MF_NIGHTENABLED: script_pushint(st,maplist[m].flag.nightenabled); break; + case MF_NOBASEEXP: script_pushint(st,maplist[m].flag.nobaseexp); break; + case MF_NOJOBEXP: script_pushint(st,maplist[m].flag.nojobexp); break; + case MF_NOMOBLOOT: script_pushint(st,maplist[m].flag.nomobloot); break; + case MF_NOMVPLOOT: script_pushint(st,maplist[m].flag.nomvploot); break; + case MF_NORETURN: script_pushint(st,maplist[m].flag.noreturn); break; + case MF_NOWARPTO: script_pushint(st,maplist[m].flag.nowarpto); break; + case MF_NIGHTMAREDROP: script_pushint(st,maplist[m].flag.pvp_nightmaredrop); break; + case MF_NOCOMMAND: script_pushint(st,maplist[m].nocommand); break; + case MF_NODROP: script_pushint(st,maplist[m].flag.nodrop); break; + case MF_JEXP: script_pushint(st,maplist[m].jexp); break; + case MF_BEXP: script_pushint(st,maplist[m].bexp); break; + case MF_NOVENDING: script_pushint(st,maplist[m].flag.novending); break; + case MF_LOADEVENT: script_pushint(st,maplist[m].flag.loadevent); break; + case MF_NOCHAT: script_pushint(st,maplist[m].flag.nochat); break; + case MF_NOEXPPENALTY: script_pushint(st,maplist[m].flag.noexppenalty ); break; + case MF_GUILDLOCK: script_pushint(st,maplist[m].flag.guildlock); break; + case MF_TOWN: script_pushint(st,maplist[m].flag.town); break; + case MF_AUTOTRADE: script_pushint(st,maplist[m].flag.autotrade); break; + case MF_ALLOWKS: script_pushint(st,maplist[m].flag.allowks); break; + case MF_MONSTER_NOTELEPORT: script_pushint(st,maplist[m].flag.monster_noteleport); break; + case MF_PVP_NOCALCRANK: script_pushint(st,maplist[m].flag.pvp_nocalcrank); break; + case MF_BATTLEGROUND: script_pushint(st,maplist[m].flag.battleground); break; + case MF_RESET: script_pushint(st,maplist[m].flag.reset); break; + case MF_NOTOMB: script_pushint(st,maplist[m].flag.notomb); break; } } @@ -10408,8 +10397,7 @@ static int script_mapflag_pvp_sub(struct block_list *bl,va_list ap) { clif->maptypeproperty2(&sd->bl,SELF); return 0; } -BUILDIN(setmapflag) -{ +BUILDIN(setmapflag) { int16 m,i; const char *str, *val2 = NULL; struct script_data* data; @@ -10419,7 +10407,7 @@ BUILDIN(setmapflag) i = script_getnum(st, 3); - if(script_hasdata(st,4)){ + if(script_hasdata(st,4)) { data = script_getdata(st,4); script->get_val(st, data); @@ -10434,85 +10422,84 @@ BUILDIN(setmapflag) if(m >= 0) { switch(i) { - case MF_NOMEMO: map[m].flag.nomemo = 1; break; - case MF_NOTELEPORT: map[m].flag.noteleport = 1; break; - case MF_NOSAVE: map[m].flag.nosave = 1; break; - case MF_NOBRANCH: map[m].flag.nobranch = 1; break; - case MF_NOPENALTY: map[m].flag.noexppenalty = 1; map[m].flag.nozenypenalty = 1; break; - case MF_NOZENYPENALTY: map[m].flag.nozenypenalty = 1; break; + case MF_NOMEMO: maplist[m].flag.nomemo = 1; break; + case MF_NOTELEPORT: maplist[m].flag.noteleport = 1; break; + case MF_NOSAVE: maplist[m].flag.nosave = 1; break; + case MF_NOBRANCH: maplist[m].flag.nobranch = 1; break; + case MF_NOPENALTY: maplist[m].flag.noexppenalty = 1; maplist[m].flag.nozenypenalty = 1; break; + case MF_NOZENYPENALTY: maplist[m].flag.nozenypenalty = 1; break; case MF_PVP: - map[m].flag.pvp = 1; + maplist[m].flag.pvp = 1; if( !battle_config.pk_mode ) { iMap->foreachinmap(script_mapflag_pvp_sub,m,BL_PC); } break; - case MF_PVP_NOPARTY: map[m].flag.pvp_noparty = 1; break; - case MF_PVP_NOGUILD: map[m].flag.pvp_noguild = 1; break; + case MF_PVP_NOPARTY: maplist[m].flag.pvp_noparty = 1; break; + case MF_PVP_NOGUILD: maplist[m].flag.pvp_noguild = 1; break; case MF_GVG: { struct block_list bl; - map[m].flag.gvg = 1; + maplist[m].flag.gvg = 1; clif->map_property_mapall(m, MAPPROPERTY_AGITZONE); bl.type = BL_NUL; bl.m = m; clif->maptypeproperty2(&bl,ALL_SAMEMAP); } break; - case MF_GVG_NOPARTY: map[m].flag.gvg_noparty = 1; break; - case MF_NOTRADE: map[m].flag.notrade = 1; break; - case MF_NOSKILL: map[m].flag.noskill = 1; break; - case MF_NOWARP: map[m].flag.nowarp = 1; break; - case MF_PARTYLOCK: map[m].flag.partylock = 1; break; - case MF_NOICEWALL: map[m].flag.noicewall = 1; break; - case MF_SNOW: map[m].flag.snow = 1; break; - case MF_FOG: map[m].flag.fog = 1; break; - case MF_SAKURA: map[m].flag.sakura = 1; break; - case MF_LEAVES: map[m].flag.leaves = 1; break; - case MF_CLOUDS: map[m].flag.clouds = 1; break; - case MF_CLOUDS2: map[m].flag.clouds2 = 1; break; - case MF_FIREWORKS: map[m].flag.fireworks = 1; break; - case MF_GVG_CASTLE: map[m].flag.gvg_castle = 1; break; - case MF_GVG_DUNGEON: map[m].flag.gvg_dungeon = 1; break; - case MF_NIGHTENABLED: map[m].flag.nightenabled = 1; break; - case MF_NOBASEEXP: map[m].flag.nobaseexp = 1; break; - case MF_NOJOBEXP: map[m].flag.nojobexp = 1; break; - case MF_NOMOBLOOT: map[m].flag.nomobloot = 1; break; - case MF_NOMVPLOOT: map[m].flag.nomvploot = 1; break; - case MF_NORETURN: map[m].flag.noreturn = 1; break; - case MF_NOWARPTO: map[m].flag.nowarpto = 1; break; - case MF_NIGHTMAREDROP: map[m].flag.pvp_nightmaredrop = 1; break; + case MF_GVG_NOPARTY: maplist[m].flag.gvg_noparty = 1; break; + case MF_NOTRADE: maplist[m].flag.notrade = 1; break; + case MF_NOSKILL: maplist[m].flag.noskill = 1; break; + case MF_NOWARP: maplist[m].flag.nowarp = 1; break; + case MF_PARTYLOCK: maplist[m].flag.partylock = 1; break; + case MF_NOICEWALL: maplist[m].flag.noicewall = 1; break; + case MF_SNOW: maplist[m].flag.snow = 1; break; + case MF_FOG: maplist[m].flag.fog = 1; break; + case MF_SAKURA: maplist[m].flag.sakura = 1; break; + case MF_LEAVES: maplist[m].flag.leaves = 1; break; + case MF_CLOUDS: maplist[m].flag.clouds = 1; break; + case MF_CLOUDS2: maplist[m].flag.clouds2 = 1; break; + case MF_FIREWORKS: maplist[m].flag.fireworks = 1; break; + case MF_GVG_CASTLE: maplist[m].flag.gvg_castle = 1; break; + case MF_GVG_DUNGEON: maplist[m].flag.gvg_dungeon = 1; break; + case MF_NIGHTENABLED: maplist[m].flag.nightenabled = 1; break; + case MF_NOBASEEXP: maplist[m].flag.nobaseexp = 1; break; + case MF_NOJOBEXP: maplist[m].flag.nojobexp = 1; break; + case MF_NOMOBLOOT: maplist[m].flag.nomobloot = 1; break; + case MF_NOMVPLOOT: maplist[m].flag.nomvploot = 1; break; + case MF_NORETURN: maplist[m].flag.noreturn = 1; break; + case MF_NOWARPTO: maplist[m].flag.nowarpto = 1; break; + case MF_NIGHTMAREDROP: maplist[m].flag.pvp_nightmaredrop = 1; break; case MF_ZONE: { char zone[6] = "zone\0"; char empty[1] = "\0"; char params[MAP_ZONE_MAPFLAG_LENGTH]; memcpy(params, val2, MAP_ZONE_MAPFLAG_LENGTH); - npc->parse_mapflag(map[m].name, empty, zone, params, empty, empty, empty); + npc->parse_mapflag(maplist[m].name, empty, zone, params, empty, empty, empty); } break; - case MF_NOCOMMAND: map[m].nocommand = (val <= 0) ? 100 : val; break; - case MF_NODROP: map[m].flag.nodrop = 1; break; - case MF_JEXP: map[m].jexp = (val <= 0) ? 100 : val; break; - case MF_BEXP: map[m].bexp = (val <= 0) ? 100 : val; break; - case MF_NOVENDING: map[m].flag.novending = 1; break; - case MF_LOADEVENT: map[m].flag.loadevent = 1; break; - case MF_NOCHAT: map[m].flag.nochat = 1; break; - case MF_NOEXPPENALTY: map[m].flag.noexppenalty = 1; break; - case MF_GUILDLOCK: map[m].flag.guildlock = 1; break; - case MF_TOWN: map[m].flag.town = 1; break; - case MF_AUTOTRADE: map[m].flag.autotrade = 1; break; - case MF_ALLOWKS: map[m].flag.allowks = 1; break; - case MF_MONSTER_NOTELEPORT: map[m].flag.monster_noteleport = 1; break; - case MF_PVP_NOCALCRANK: map[m].flag.pvp_nocalcrank = 1; break; - case MF_BATTLEGROUND: map[m].flag.battleground = (val <= 0 || val > 2) ? 1 : val; break; - case MF_RESET: map[m].flag.reset = 1; break; - case MF_NOTOMB: map[m].flag.notomb = 1; break; + case MF_NOCOMMAND: maplist[m].nocommand = (val <= 0) ? 100 : val; break; + case MF_NODROP: maplist[m].flag.nodrop = 1; break; + case MF_JEXP: maplist[m].jexp = (val <= 0) ? 100 : val; break; + case MF_BEXP: maplist[m].bexp = (val <= 0) ? 100 : val; break; + case MF_NOVENDING: maplist[m].flag.novending = 1; break; + case MF_LOADEVENT: maplist[m].flag.loadevent = 1; break; + case MF_NOCHAT: maplist[m].flag.nochat = 1; break; + case MF_NOEXPPENALTY: maplist[m].flag.noexppenalty = 1; break; + case MF_GUILDLOCK: maplist[m].flag.guildlock = 1; break; + case MF_TOWN: maplist[m].flag.town = 1; break; + case MF_AUTOTRADE: maplist[m].flag.autotrade = 1; break; + case MF_ALLOWKS: maplist[m].flag.allowks = 1; break; + case MF_MONSTER_NOTELEPORT: maplist[m].flag.monster_noteleport = 1; break; + case MF_PVP_NOCALCRANK: maplist[m].flag.pvp_nocalcrank = 1; break; + case MF_BATTLEGROUND: maplist[m].flag.battleground = (val <= 0 || val > 2) ? 1 : val; break; + case MF_RESET: maplist[m].flag.reset = 1; break; + case MF_NOTOMB: maplist[m].flag.notomb = 1; break; } } return true; } -BUILDIN(removemapflag) -{ +BUILDIN(removemapflag) { int16 m,i; const char *str; @@ -10522,83 +10509,82 @@ BUILDIN(removemapflag) m = iMap->mapname2mapid(str); if(m >= 0) { switch(i) { - case MF_NOMEMO: map[m].flag.nomemo = 0; break; - case MF_NOTELEPORT: map[m].flag.noteleport = 0; break; - case MF_NOSAVE: map[m].flag.nosave = 0; break; - case MF_NOBRANCH: map[m].flag.nobranch = 0; break; - case MF_NOPENALTY: map[m].flag.noexppenalty = 0; map[m].flag.nozenypenalty = 0; break; - case MF_NOZENYPENALTY: map[m].flag.nozenypenalty = 0; break; + case MF_NOMEMO: maplist[m].flag.nomemo = 0; break; + case MF_NOTELEPORT: maplist[m].flag.noteleport = 0; break; + case MF_NOSAVE: maplist[m].flag.nosave = 0; break; + case MF_NOBRANCH: maplist[m].flag.nobranch = 0; break; + case MF_NOPENALTY: maplist[m].flag.noexppenalty = 0; maplist[m].flag.nozenypenalty = 0; break; + case MF_NOZENYPENALTY: maplist[m].flag.nozenypenalty = 0; break; case MF_PVP: { struct block_list bl; bl.type = BL_NUL; bl.m = m; - map[m].flag.pvp = 0; + maplist[m].flag.pvp = 0; clif->map_property_mapall(m, MAPPROPERTY_NOTHING); clif->maptypeproperty2(&bl,ALL_SAMEMAP); } break; - case MF_PVP_NOPARTY: map[m].flag.pvp_noparty = 0; break; - case MF_PVP_NOGUILD: map[m].flag.pvp_noguild = 0; break; + case MF_PVP_NOPARTY: maplist[m].flag.pvp_noparty = 0; break; + case MF_PVP_NOGUILD: maplist[m].flag.pvp_noguild = 0; break; case MF_GVG: { struct block_list bl; bl.type = BL_NUL; bl.m = m; - map[m].flag.gvg = 0; + maplist[m].flag.gvg = 0; clif->map_property_mapall(m, MAPPROPERTY_NOTHING); clif->maptypeproperty2(&bl,ALL_SAMEMAP); } break; - case MF_GVG_NOPARTY: map[m].flag.gvg_noparty = 0; break; - case MF_NOTRADE: map[m].flag.notrade = 0; break; - case MF_NOSKILL: map[m].flag.noskill = 0; break; - case MF_NOWARP: map[m].flag.nowarp = 0; break; - case MF_PARTYLOCK: map[m].flag.partylock = 0; break; - case MF_NOICEWALL: map[m].flag.noicewall = 0; break; - case MF_SNOW: map[m].flag.snow = 0; break; - case MF_FOG: map[m].flag.fog = 0; break; - case MF_SAKURA: map[m].flag.sakura = 0; break; - case MF_LEAVES: map[m].flag.leaves = 0; break; - case MF_CLOUDS: map[m].flag.clouds = 0; break; - case MF_CLOUDS2: map[m].flag.clouds2 = 0; break; - case MF_FIREWORKS: map[m].flag.fireworks = 0; break; - case MF_GVG_CASTLE: map[m].flag.gvg_castle = 0; break; - case MF_GVG_DUNGEON: map[m].flag.gvg_dungeon = 0; break; - case MF_NIGHTENABLED: map[m].flag.nightenabled = 0; break; - case MF_NOBASEEXP: map[m].flag.nobaseexp = 0; break; - case MF_NOJOBEXP: map[m].flag.nojobexp = 0; break; - case MF_NOMOBLOOT: map[m].flag.nomobloot = 0; break; - case MF_NOMVPLOOT: map[m].flag.nomvploot = 0; break; - case MF_NORETURN: map[m].flag.noreturn = 0; break; - case MF_NOWARPTO: map[m].flag.nowarpto = 0; break; - case MF_NIGHTMAREDROP: map[m].flag.pvp_nightmaredrop = 0; break; + case MF_GVG_NOPARTY: maplist[m].flag.gvg_noparty = 0; break; + case MF_NOTRADE: maplist[m].flag.notrade = 0; break; + case MF_NOSKILL: maplist[m].flag.noskill = 0; break; + case MF_NOWARP: maplist[m].flag.nowarp = 0; break; + case MF_PARTYLOCK: maplist[m].flag.partylock = 0; break; + case MF_NOICEWALL: maplist[m].flag.noicewall = 0; break; + case MF_SNOW: maplist[m].flag.snow = 0; break; + case MF_FOG: maplist[m].flag.fog = 0; break; + case MF_SAKURA: maplist[m].flag.sakura = 0; break; + case MF_LEAVES: maplist[m].flag.leaves = 0; break; + case MF_CLOUDS: maplist[m].flag.clouds = 0; break; + case MF_CLOUDS2: maplist[m].flag.clouds2 = 0; break; + case MF_FIREWORKS: maplist[m].flag.fireworks = 0; break; + case MF_GVG_CASTLE: maplist[m].flag.gvg_castle = 0; break; + case MF_GVG_DUNGEON: maplist[m].flag.gvg_dungeon = 0; break; + case MF_NIGHTENABLED: maplist[m].flag.nightenabled = 0; break; + case MF_NOBASEEXP: maplist[m].flag.nobaseexp = 0; break; + case MF_NOJOBEXP: maplist[m].flag.nojobexp = 0; break; + case MF_NOMOBLOOT: maplist[m].flag.nomobloot = 0; break; + case MF_NOMVPLOOT: maplist[m].flag.nomvploot = 0; break; + case MF_NORETURN: maplist[m].flag.noreturn = 0; break; + case MF_NOWARPTO: maplist[m].flag.nowarpto = 0; break; + case MF_NIGHTMAREDROP: maplist[m].flag.pvp_nightmaredrop = 0; break; case MF_ZONE: - iMap->zone_change2(m, map[m].prev_zone); + iMap->zone_change2(m, maplist[m].prev_zone); break; - case MF_NOCOMMAND: map[m].nocommand = 0; break; - case MF_NODROP: map[m].flag.nodrop = 0; break; - case MF_JEXP: map[m].jexp = 0; break; - case MF_BEXP: map[m].bexp = 0; break; - case MF_NOVENDING: map[m].flag.novending = 0; break; - case MF_LOADEVENT: map[m].flag.loadevent = 0; break; - case MF_NOCHAT: map[m].flag.nochat = 0; break; - case MF_NOEXPPENALTY: map[m].flag.noexppenalty = 0; break; - case MF_GUILDLOCK: map[m].flag.guildlock = 0; break; - case MF_TOWN: map[m].flag.town = 0; break; - case MF_AUTOTRADE: map[m].flag.autotrade = 0; break; - case MF_ALLOWKS: map[m].flag.allowks = 0; break; - case MF_MONSTER_NOTELEPORT: map[m].flag.monster_noteleport = 0; break; - case MF_PVP_NOCALCRANK: map[m].flag.pvp_nocalcrank = 0; break; - case MF_BATTLEGROUND: map[m].flag.battleground = 0; break; - case MF_RESET: map[m].flag.reset = 0; break; - case MF_NOTOMB: map[m].flag.notomb = 0; break; + case MF_NOCOMMAND: maplist[m].nocommand = 0; break; + case MF_NODROP: maplist[m].flag.nodrop = 0; break; + case MF_JEXP: maplist[m].jexp = 0; break; + case MF_BEXP: maplist[m].bexp = 0; break; + case MF_NOVENDING: maplist[m].flag.novending = 0; break; + case MF_LOADEVENT: maplist[m].flag.loadevent = 0; break; + case MF_NOCHAT: maplist[m].flag.nochat = 0; break; + case MF_NOEXPPENALTY: maplist[m].flag.noexppenalty = 0; break; + case MF_GUILDLOCK: maplist[m].flag.guildlock = 0; break; + case MF_TOWN: maplist[m].flag.town = 0; break; + case MF_AUTOTRADE: maplist[m].flag.autotrade = 0; break; + case MF_ALLOWKS: maplist[m].flag.allowks = 0; break; + case MF_MONSTER_NOTELEPORT: maplist[m].flag.monster_noteleport = 0; break; + case MF_PVP_NOCALCRANK: maplist[m].flag.pvp_nocalcrank = 0; break; + case MF_BATTLEGROUND: maplist[m].flag.battleground = 0; break; + case MF_RESET: maplist[m].flag.reset = 0; break; + case MF_NOTOMB: maplist[m].flag.notomb = 0; break; } } return true; } -BUILDIN(pvpon) -{ +BUILDIN(pvpon) { int16 m; const char *str; TBL_PC* sd = NULL; @@ -10607,11 +10593,11 @@ BUILDIN(pvpon) str = script_getstr(st,2); m = iMap->mapname2mapid(str); - if( m < 0 || map[m].flag.pvp ) + if( m < 0 || maplist[m].flag.pvp ) return true; // nothing to do iMap->zone_change2(m, strdb_get(zone_db, MAP_ZONE_PVP_NAME)); - map[m].flag.pvp = 1; + maplist[m].flag.pvp = 1; clif->map_property_mapall(m, MAPPROPERTY_FREEPVPZONE); bl.type = BL_NUL; bl.m = m; @@ -10650,19 +10636,18 @@ static int buildin_pvpoff_sub(struct block_list *bl,va_list ap) return 0; } -BUILDIN(pvpoff) -{ +BUILDIN(pvpoff) { int16 m; const char *str; struct block_list bl; str=script_getstr(st,2); m = iMap->mapname2mapid(str); - if(m < 0 || !map[m].flag.pvp) + if(m < 0 || !maplist[m].flag.pvp) return true; //fixed Lupus - iMap->zone_change2(m, map[m].prev_zone); - map[m].flag.pvp = 0; + iMap->zone_change2(m, maplist[m].prev_zone); + maplist[m].flag.pvp = 0; clif->map_property_mapall(m, MAPPROPERTY_NOTHING); bl.type = BL_NUL; bl.m = m; @@ -10675,17 +10660,16 @@ BUILDIN(pvpoff) return true; } -BUILDIN(gvgon) -{ +BUILDIN(gvgon) { int16 m; const char *str; str=script_getstr(st,2); m = iMap->mapname2mapid(str); - if(m >= 0 && !map[m].flag.gvg) { + if(m >= 0 && !maplist[m].flag.gvg) { struct block_list bl; iMap->zone_change2(m, strdb_get(zone_db, MAP_ZONE_GVG_NAME)); - map[m].flag.gvg = 1; + maplist[m].flag.gvg = 1; clif->map_property_mapall(m, MAPPROPERTY_AGITZONE); bl.type = BL_NUL; bl.m = m; @@ -10694,17 +10678,16 @@ BUILDIN(gvgon) return true; } -BUILDIN(gvgoff) -{ +BUILDIN(gvgoff) { int16 m; const char *str; str=script_getstr(st,2); m = iMap->mapname2mapid(str); - if(m >= 0 && map[m].flag.gvg) { + if(m >= 0 && maplist[m].flag.gvg) { struct block_list bl; - iMap->zone_change2(m, map[m].prev_zone); - map[m].flag.gvg = 0; + iMap->zone_change2(m, maplist[m].prev_zone); + maplist[m].flag.gvg = 0; clif->map_property_mapall(m, MAPPROPERTY_NOTHING); bl.type = BL_NUL; bl.m = m; @@ -11223,7 +11206,7 @@ BUILDIN(mobcount) // Added by RoVeRT return true; } - if( map[m].flag.src4instance && map[m].instance_id == -1 && st->instance_id >= 0 && (m = instance->mapid2imapid(m, st->instance_id)) < 0 ) { + if( maplist[m].flag.src4instance && maplist[m].instance_id == -1 && st->instance_id >= 0 && (m = instance->mapid2imapid(m, st->instance_id)) < 0 ) { script_pushint(st,-1); return true; } @@ -11395,18 +11378,17 @@ BUILDIN(strmobinfo) * Summon guardians [Valaris] * guardian("<map name>",<x>,<y>,"<name to show>",<mob id>{,"<event label>"}{,<guardian index>}) -> <id> *------------------------------------------*/ -BUILDIN(guardian) -{ - int class_=0,x=0,y=0,guardian=0; - const char *str,*map,*evt=""; +BUILDIN(guardian) { + int class_ = 0, x = 0, y = 0, guardian = 0; + const char *str, *mapname, *evt=""; struct script_data *data; bool has_index = false; - map =script_getstr(st,2); - x =script_getnum(st,3); - y =script_getnum(st,4); - str =script_getstr(st,5); - class_=script_getnum(st,6); + mapname = script_getstr(st,2); + x = script_getnum(st,3); + y = script_getnum(st,4); + str = script_getstr(st,5); + class_ = script_getnum(st,6); if( script_hasdata(st,8) ) {// "<event label>",<guardian index> @@ -11431,28 +11413,27 @@ BUILDIN(guardian) } check_event(st, evt); - script_pushint(st, mob->spawn_guardian(map,x,y,str,class_,evt,guardian,has_index)); + script_pushint(st, mob->spawn_guardian(mapname,x,y,str,class_,evt,guardian,has_index)); return true; } /*========================================== * Invisible Walls [Zephyrus] *------------------------------------------*/ -BUILDIN(setwall) -{ - const char *map, *name; +BUILDIN(setwall) { + const char *mapname, *name; int x, y, m, size, dir; bool shootable; - map = script_getstr(st,2); - x = script_getnum(st,3); - y = script_getnum(st,4); - size = script_getnum(st,5); - dir = script_getnum(st,6); + mapname = script_getstr(st,2); + x = script_getnum(st,3); + y = script_getnum(st,4); + size = script_getnum(st,5); + dir = script_getnum(st,6); shootable = script_getnum(st,7); - name = script_getstr(st,8); + name = script_getstr(st,8); - if( (m = iMap->mapname2mapid(map)) < 0 ) + if( (m = iMap->mapname2mapid(mapname)) < 0 ) return true; // Invalid Map iMap->iwall_set(m, x, y, size, dir, shootable, name); @@ -11923,23 +11904,22 @@ static int playBGM_foreachpc_sub(struct map_session_data* sd, va_list args) /*========================================== * Play a BGM on multiple client [Rikter/Yommy] *------------------------------------------*/ -BUILDIN(playBGMall) -{ +BUILDIN(playBGMall) { const char* name; name = script_getstr(st,2); - if( script_hasdata(st,7) ) - {// specified part of map - const char* map = script_getstr(st,3); + if( script_hasdata(st,7) ) { + // specified part of map + const char *mapname = script_getstr(st,3); int x0 = script_getnum(st,4); int y0 = script_getnum(st,5); int x1 = script_getnum(st,6); int y1 = script_getnum(st,7); int m; - if ( ( m = iMap->mapname2mapid(map) ) == -1 ) { - ShowWarning("playBGMall: Attempted to play song '%s' on non-existent map '%s'\n",name, map); + if ( ( m = iMap->mapname2mapid(mapname) ) == -1 ) { + ShowWarning("playBGMall: Attempted to play song '%s' on non-existent map '%s'\n",name, mapname); return true; } @@ -11947,11 +11927,11 @@ BUILDIN(playBGMall) } else if( script_hasdata(st,3) ) {// entire map - const char* map = script_getstr(st,3); + const char* mapname = script_getstr(st,3); int m; - if ( ( m = iMap->mapname2mapid(map) ) == -1 ) { - ShowWarning("playBGMall: Attempted to play song '%s' on non-existent map '%s'\n",name, map); + if ( ( m = iMap->mapname2mapid(mapname) ) == -1 ) { + ShowWarning("playBGMall: Attempted to play song '%s' on non-existent map '%s'\n",name, mapname); return true; } @@ -12014,25 +11994,25 @@ BUILDIN(soundeffectall) clif->soundeffectall(bl, name, type, AREA); } else { if(!script_hasdata(st,5)) { // entire map - const char* map = script_getstr(st,4); + const char *mapname = script_getstr(st,4); int m; - if ( ( m = iMap->mapname2mapid(map) ) == -1 ) { - ShowWarning("soundeffectall: Attempted to play song '%s' (type %d) on non-existent map '%s'\n",name,type, map); + if ( ( m = iMap->mapname2mapid(mapname) ) == -1 ) { + ShowWarning("soundeffectall: Attempted to play song '%s' (type %d) on non-existent map '%s'\n",name,type, mapname); return true; } iMap->foreachinmap(soundeffect_sub, m, BL_PC, name, type); } else if(script_hasdata(st,8)) { // specified part of map - const char* map = script_getstr(st,4); + const char *mapname = script_getstr(st,4); int x0 = script_getnum(st,5); int y0 = script_getnum(st,6); int x1 = script_getnum(st,7); int y1 = script_getnum(st,8); int m; - if ( ( m = iMap->mapname2mapid(map) ) == -1 ) { - ShowWarning("soundeffectall: Attempted to play song '%s' (type %d) on non-existent map '%s'\n",name,type, map); + if ( ( m = iMap->mapname2mapid(mapname) ) == -1 ) { + ShowWarning("soundeffectall: Attempted to play song '%s' (type %d) on non-existent map '%s'\n",name,type, mapname); return true; } @@ -12848,7 +12828,7 @@ BUILDIN(getmapxy) x= bl->x; y= bl->y; - safestrncpy(mapname, map[bl->m].name, MAP_NAME_LENGTH); + safestrncpy(mapname, maplist[bl->m].name, MAP_NAME_LENGTH); //Set MapName$ num=st->stack->stack_data[st->start+2].u.num; @@ -14945,7 +14925,7 @@ BUILDIN(unitkill) /// unitwarp(<unit_id>,"<map name>",<x>,<y>) -> <bool> BUILDIN(unitwarp) { int unit_id; - int map; + int mapid; short x; short y; struct block_list* bl; @@ -14962,13 +14942,13 @@ BUILDIN(unitwarp) { bl = iMap->id2bl(unit_id); if( strcmp(mapname,"this") == 0 ) - map = bl?bl->m:-1; + mapid = bl?bl->m:-1; else - map = iMap->mapname2mapid(mapname); + mapid = iMap->mapname2mapid(mapname); - if( map >= 0 && bl != NULL ) { + if( mapid >= 0 && bl != NULL ) { unit->bl2ud2(bl); // ensure ((TBL_NPC*)bl)->ud is safe to edit - script_pushint(st, unit->warp(bl,map,x,y,CLR_OUTSIGHT)); + script_pushint(st, unit->warp(bl,mapid,x,y,CLR_OUTSIGHT)); } else { script_pushint(st, 0); } @@ -15434,7 +15414,7 @@ BUILDIN(setcell) for( y = y1; y <= y2; ++y ) for( x = x1; x <= x2; ++x ) - map[m].setcell(m, x, y, type, flag); + maplist[m].setcell(m, x, y, type, flag); return true; } @@ -15820,17 +15800,17 @@ BUILDIN(bg_warp) BUILDIN(bg_monster) { int class_ = 0, x = 0, y = 0, bg_id = 0; - const char *str,*map, *evt=""; - - bg_id = script_getnum(st,2); - map = script_getstr(st,3); - x = script_getnum(st,4); - y = script_getnum(st,5); - str = script_getstr(st,6); - class_ = script_getnum(st,7); + const char *str, *mapname, *evt=""; + + bg_id = script_getnum(st,2); + mapname = script_getstr(st,3); + x = script_getnum(st,4); + y = script_getnum(st,5); + str = script_getstr(st,6); + class_ = script_getnum(st,7); if( script_hasdata(st,8) ) evt = script_getstr(st,8); check_event(st, evt); - script_pushint(st, mob->spawn_bg(map,x,y,str,class_,evt,bg_id)); + script_pushint(st, mob->spawn_bg(mapname,x,y,str,class_,evt,bg_id)); return true; } @@ -15907,8 +15887,7 @@ BUILDIN(bg_getareausers) return true; } -BUILDIN(bg_updatescore) -{ +BUILDIN(bg_updatescore) { const char *str; int16 m; @@ -15916,8 +15895,8 @@ BUILDIN(bg_updatescore) if( (m = iMap->mapname2mapid(str)) < 0 ) return true; - map[m].bgscore_lion = script_getnum(st,3); - map[m].bgscore_eagle = script_getnum(st,4); + maplist[m].bgscore_lion = script_getnum(st,3); + maplist[m].bgscore_eagle = script_getnum(st,4); clif->bg_updatescore(m); return true; @@ -16023,7 +16002,7 @@ BUILDIN(instance_attachmap) { script_pushconststr(st, ""); return true; } - script_pushconststr(st, map[m].name); + script_pushconststr(st, maplist[m].name); return true; } @@ -16178,7 +16157,7 @@ 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, map[instances[sd->instance[i]].map[j]].instance_src_map == m); + 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 ) break; } @@ -16189,7 +16168,7 @@ 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, map[instances[p->instance[i]].map[j]].instance_src_map == m); + 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 ) break; } @@ -16200,7 +16179,7 @@ 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, map[instances[sd->guild->instance[i]].map[j]].instance_src_map == m); + 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 ) break; } @@ -16215,7 +16194,7 @@ BUILDIN(has_instance) { return true; } - script_pushconststr(st, map[m].name); + script_pushconststr(st, maplist[m].name); return true; } static int buildin_instance_warpall_sub(struct block_list *bl,va_list ap) { @@ -16246,7 +16225,7 @@ BUILDIN(instance_warpall) { else return true; - if( (m = iMap->mapname2mapid(mapn)) < 0 || (map[m].flag.src4instance && (m = instance->mapid2imapid(m, instance_id)) < 0) ) + if( (m = iMap->mapname2mapid(mapn)) < 0 || (maplist[m].flag.src4instance && (m = instance->mapid2imapid(m, instance_id)) < 0) ) return true; mapindex = map_id2index(m); @@ -16385,7 +16364,7 @@ BUILDIN(areamobuseskill) return true; } - if( map[m].flag.src4instance && st->instance_id >= 0 && (m = instance->mapid2imapid(m, st->instance_id)) < 0 ) + if( maplist[m].flag.src4instance && st->instance_id >= 0 && (m = instance->mapid2imapid(m, st->instance_id)) < 0 ) return true; center.m = m; @@ -17058,14 +17037,13 @@ static int atcommand_cleanfloor_sub(struct block_list *bl, va_list ap) return 0; } -BUILDIN(cleanmap) -{ - const char *map; +BUILDIN(cleanmap) { + const char *mapname; int16 m = -1; int16 x0 = 0, y0 = 0, x1 = 0, y1 = 0; - map = script_getstr(st, 2); - m = iMap->mapname2mapid(map); + mapname = script_getstr(st, 2); + m = iMap->mapname2mapid(mapname); if ( m == -1 ) return false; diff --git a/src/map/skill.c b/src/map/skill.c index 3e9817faf..3541f9f45 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -520,7 +520,7 @@ int skillnotok (uint16 skill_id, struct map_session_data *sd) case AL_WARP: case RETURN_TO_ELDICASTES: case ALL_GUARDIAN_RECALL: - if(map[m].flag.nowarp) { + if(maplist[m].flag.nowarp) { clif->skill_mapinfomessage(sd,0); return 1; } @@ -528,7 +528,7 @@ int skillnotok (uint16 skill_id, struct map_session_data *sd) case AL_TELEPORT: case SC_FATALMENACE: case SC_DIMENSIONDOOR: - if(map[m].flag.noteleport) { + if(maplist[m].flag.noteleport) { clif->skill_mapinfomessage(sd,0); return 1; } @@ -536,7 +536,7 @@ int skillnotok (uint16 skill_id, struct map_session_data *sd) case WE_CALLPARTNER: case WE_CALLPARENT: case WE_CALLBABY: - if (map[m].flag.nomemo) { + if (maplist[m].flag.nomemo) { clif->skill_mapinfomessage(sd,1); return 1; } @@ -555,7 +555,7 @@ int skillnotok (uint16 skill_id, struct map_session_data *sd) return 0; // always allowed case WZ_ICEWALL: // noicewall flag [Valaris] - if (map[m].flag.noicewall) { + if (maplist[m].flag.noicewall) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); return 1; } @@ -567,11 +567,10 @@ int skillnotok (uint16 skill_id, struct map_session_data *sd) } break; case GD_EMERGENCYCALL: - if ( - !(battle_config.emergency_call&((iMap->agit_flag || iMap->agit2_flag)?2:1)) || - !(battle_config.emergency_call&(map[m].flag.gvg || map[m].flag.gvg_castle?8:4)) || - (battle_config.emergency_call&16 && map[m].flag.nowarpto && !map[m].flag.gvg_castle) - ) { + if( !(battle_config.emergency_call&((iMap->agit_flag || iMap->agit2_flag)?2:1)) + || !(battle_config.emergency_call&(maplist[m].flag.gvg || maplist[m].flag.gvg_castle?8:4)) + || (battle_config.emergency_call&16 && maplist[m].flag.nowarpto && !maplist[m].flag.gvg_castle) + ) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); return 1; } @@ -606,7 +605,7 @@ int skillnotok (uint16 skill_id, struct map_session_data *sd) break; } - return (map[m].flag.noskill); + return (maplist[m].flag.noskill); } int skillnotok_hom(uint16 skill_id, struct homun_data *hd) @@ -2064,7 +2063,7 @@ int skill_blown(struct block_list* src, struct block_list* target, int count, in nullpo_ret(src); - if (src != target && map[src->m].flag.noknockback) + if (src != target && maplist[src->m].flag.noknockback) return 0; //No knocking if (count == 0) return 0; //Actual knockback distance is 0. @@ -3577,7 +3576,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint uint8 dir = iMap->calc_dir(bl, src->x, src->y); // teleport to target (if not on WoE grounds) - if( !map_flag_gvg2(src->m) && !map[src->m].flag.battleground && unit->movepos(src, bl->x, bl->y, 0, 1) ) + if( !map_flag_gvg2(src->m) && !maplist[src->m].flag.battleground && unit->movepos(src, bl->x, bl->y, 0, 1) ) clif->slide(src, bl->x, bl->y); // cause damage and knockback if the path to target was a straight one @@ -3688,8 +3687,9 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint if( dir > 2 && dir < 6 ) y = -i; else if( dir == 7 || dir < 2 ) y = i; else y = 0; - if( (mbl == src || (!map_flag_gvg2(src->m) && !map[src->m].flag.battleground) ) && // only NJ_ISSEN don't have slide effect in GVG - unit->movepos(src, mbl->x+x, mbl->y+y, 1, 1) ) { + if( (mbl == src || (!map_flag_gvg2(src->m) && !maplist[src->m].flag.battleground) ) // only NJ_ISSEN don't have slide effect in GVG + && unit->movepos(src, mbl->x+x, mbl->y+y, 1, 1) + ) { clif->slide(src, src->x, src->y); clif->fixpos(src); clif->spiritball(src); @@ -4064,8 +4064,8 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint sc_start(src,SC_HIDING,100,skill_lv,skill->get_time(skill_id,skill_lv)); break; case NJ_KIRIKAGE: - if( !map_flag_gvg2(src->m) && !map[src->m].flag.battleground ) - { //You don't move on GVG grounds. + if( !map_flag_gvg2(src->m) && !maplist[src->m].flag.battleground ) { + //You don't move on GVG grounds. short x, y; iMap->search_freecell(bl, 0, &x, &y, 1, 1, 0); if (unit->movepos(src, x, y, 0, 0)) @@ -4345,7 +4345,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint } break; case LG_PINPOINTATTACK: - if( !map_flag_gvg2(src->m) && !map[src->m].flag.battleground && unit->movepos(src, bl->x, bl->y, 1, 1) ) + if( !map_flag_gvg2(src->m) && !maplist[src->m].flag.battleground && unit->movepos(src, bl->x, bl->y, 1, 1) ) clif->slide(src,bl->x,bl->y); skill->attack(BF_WEAPON,src,src,bl,skill_id,skill_lv,tick,flag); break; @@ -4370,7 +4370,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint break; case SR_KNUCKLEARROW: - if( !map_flag_gvg2(src->m) && !map[src->m].flag.battleground && unit->movepos(src, bl->x, bl->y, 1, 1) ) { + if( !map_flag_gvg2(src->m) && !maplist[src->m].flag.battleground && unit->movepos(src, bl->x, bl->y, 1, 1) ) { clif->slide(src,bl->x,bl->y); clif->fixpos(src); // Aegis send this packet too. } @@ -5104,7 +5104,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui break; } skill_area_temp[0] = 5 - skill_area_temp[0]; // The actual penalty... - if (skill_area_temp[0] > 0 && !map[src->m].flag.noexppenalty) { //Apply penalty + if (skill_area_temp[0] > 0 && !maplist[src->m].flag.noexppenalty) { //Apply penalty sd->status.base_exp -= min(sd->status.base_exp, pc->nextbaseexp(sd) * skill_area_temp[0] * 2/1000); //0.2% penalty per each. sd->status.job_exp -= min(sd->status.job_exp, pc->nextjobexp(sd) * skill_area_temp[0] * 2/1000); clif->updatestatus(sd,SP_BASEEXP); @@ -5120,8 +5120,8 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui break; case ALL_RESURRECTION: - if(sd && (map_flag_gvg2(bl->m) || map[bl->m].flag.battleground)) - { //No reviving in WoE grounds! + if(sd && (map_flag_gvg2(bl->m) || maplist[bl->m].flag.battleground)) { + //No reviving in WoE grounds! clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); break; } @@ -5132,7 +5132,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui if (tsc && tsc->data[SC_HELLPOWER]) break; - if (map[bl->m].flag.pvp && dstsd && dstsd->pvp_point < 0) + if (maplist[bl->m].flag.pvp && dstsd && dstsd->pvp_point < 0) break; switch(skill_lv){ @@ -6332,9 +6332,8 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui break; case AL_TELEPORT: - if(sd) - { - if (map[bl->m].flag.noteleport && skill_lv <= 2) { + if(sd) { + if (maplist[bl->m].flag.noteleport && skill_lv <= 2) { clif->skill_mapinfomessage(sd,0); break; } @@ -6707,8 +6706,8 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui int x,y, dir = unit->getdir(src); //Fails on noteleport maps, except for GvG and BG maps [Skotlex] - if( map[src->m].flag.noteleport && - !(map[src->m].flag.battleground || map_flag_gvg2(src->m) ) + if( maplist[src->m].flag.noteleport + && !(maplist[src->m].flag.battleground || map_flag_gvg2(src->m)) ) { x = src->x; y = src->y; @@ -7526,7 +7525,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui for(i = 0; i < g->max_member; i++, j++) { if (j>8) j=0; if ((dstsd = g->member[i].sd) != NULL && sd != dstsd && !dstsd->state.autotrade && !pc_isdead(dstsd)) { - if (map[dstsd->bl.m].flag.nowarp && !map_flag_gvg2(dstsd->bl.m)) + if (maplist[dstsd->bl.m].flag.nowarp && !map_flag_gvg2(dstsd->bl.m)) continue; if(iMap->getcell(src->m,src->x+dx[j],src->y+dy[j],CELL_CHKNOREACH)) dx[j] = dy[j] = 0; @@ -8541,7 +8540,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui } break; case LG_INSPIRATION: - if( sd && !map[sd->bl.m].flag.noexppenalty && sd->status.base_level != MAX_LEVEL ) { + if( sd && !maplist[sd->bl.m].flag.noexppenalty && sd->status.base_level != MAX_LEVEL ) { sd->status.base_exp -= min(sd->status.base_exp, pc->nextbaseexp(sd) * 1 / 100); // 1% penalty. sd->status.job_exp -= min(sd->status.job_exp, pc->nextjobexp(sd) * 1 / 100); clif->updatestatus(sd,SP_BASEEXP); @@ -9546,8 +9545,7 @@ static int skill_count_wos(struct block_list *bl,va_list ap) { /*========================================== * *------------------------------------------*/ -int skill_castend_map (struct map_session_data *sd, uint16 skill_id, const char *map) -{ +int skill_castend_map (struct map_session_data *sd, uint16 skill_id, const char *mapname) { nullpo_ret(sd); //Simplify skill_failed code. @@ -9588,16 +9586,16 @@ int skill_castend_map (struct map_session_data *sd, uint16 skill_id, const char pc_stop_walking(sd,0); if(battle_config.skill_log && battle_config.skill_log&BL_PC) - ShowInfo("PC %d skill castend skill =%d map=%s\n",sd->bl.id,skill_id,map); + ShowInfo("PC %d skill castend skill =%d map=%s\n",sd->bl.id,skill_id,mapname); - if(strcmp(map,"cancel")==0) { + if(strcmp(mapname,"cancel")==0) { skill_failed(sd); return 0; } switch(skill_id) { case AL_TELEPORT: - if(strcmp(map,"Random")==0) + if(strcmp(mapname,"Random")==0) pc->randomwarp(sd,CLR_TELEPORT); else if (sd->menuskill_val > 1) //Need lv2 to be able to warp here. pc->setpos(sd,sd->status.save_point.map,sd->status.save_point.x,sd->status.save_point.y,CLR_TELEPORT); @@ -9612,7 +9610,7 @@ int skill_castend_map (struct map_session_data *sd, uint16 skill_id, const char int x,y; unsigned short mapindex; - mapindex = mapindex_name2id((char*)map); + mapindex = mapindex_name2id(mapname); if(!mapindex) { //Given map not found? clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); skill_failed(sd); @@ -9975,7 +9973,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui } break; case NJ_SHADOWJUMP: - if( !map_flag_gvg2(src->m) && !map[src->m].flag.battleground ) { //You don't move on GVG grounds. + if( !map_flag_gvg2(src->m) && !maplist[src->m].flag.battleground ) { //You don't move on GVG grounds. unit->movepos(src, x, y, 1, 0); clif->slide(src,x,y); } @@ -10515,11 +10513,11 @@ struct skill_unit_group* skill_unitsetting(struct block_list *src, uint16 skill_ unit_flag = skill->get_unit_flag(skill_id); layout = skill->get_unit_layout(skill_id,skill_lv,src,x,y); - if( map[src->m].unit_count ) { - ARR_FIND(0, map[src->m].unit_count, i, map[src->m].units[i]->skill_id == skill_id ); + if( maplist[src->m].unit_count ) { + ARR_FIND(0, maplist[src->m].unit_count, i, maplist[src->m].units[i]->skill_id == skill_id ); - if( i < map[src->m].unit_count ) { - limit = limit * map[src->m].units[i]->modifier / 100; + if( i < maplist[src->m].unit_count ) { + limit = limit * maplist[src->m].units[i]->modifier / 100; } } @@ -10616,7 +10614,7 @@ struct skill_unit_group* skill_unitsetting(struct block_list *src, uint16 skill_ ARR_FIND(0, MAX_SKILL_ITEM_REQUIRE, i, req.itemid[i] && (req.itemid[i] == ITEMID_TRAP || req.itemid[i] == ITEMID_TRAP_ALLOY)); if( req.itemid[i] ) req_item = req.itemid[i]; - if( map_flag_gvg2(src->m) || map[src->m].flag.battleground ) + if( map_flag_gvg2(src->m) || maplist[src->m].flag.battleground ) limit *= 4; // longer trap times in WOE [celest] if( battle_config.vs_traps_bctall && map_flag_vs(src->m) && (src->type&battle_config.vs_traps_bctall) ) target = BCT_ALL; @@ -11711,7 +11709,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns break; case UNT_DIMENSIONDOOR: - if( tsd && !map[bl->m].flag.noteleport ) + if( tsd && !maplist[bl->m].flag.noteleport ) pc->randomwarp(tsd,3); else if( bl->type == BL_MOB && battle_config.mob_warp&8 ) unit->warp(bl,-1,-1,-1,3); @@ -14026,7 +14024,7 @@ int skill_delay_fix (struct block_list *bl, uint16 skill_id, uint16 skill_lv) time /= 2; break; case AS_SONICBLOW: - if (!map_flag_gvg2(bl->m) && !map[bl->m].flag.battleground && sc->data[SC_SOULLINK]->val2 == SL_ASSASIN) + if (!map_flag_gvg2(bl->m) && !maplist[bl->m].flag.battleground && sc->data[SC_SOULLINK]->val2 == SL_ASSASIN) time /= 2; break; } @@ -14554,7 +14552,7 @@ void skill_unitsetmapcell (struct skill_unit *src, uint16 skill_id, uint16 skill for( y = src->bl.y - range; y <= src->bl.y + range; ++y ) for( x = src->bl.x - range; x <= src->bl.x + range; ++x ) - map[src->bl.m].setcell(src->bl.m, x, y, cell, flag); + maplist[src->bl.m].setcell(src->bl.m, x, y, cell, flag); } /*========================================== @@ -15109,7 +15107,7 @@ struct skill_unit *skill_initunit (struct skill_unit_group *group, int idx, int iMap->setgatcell(su->bl.m,su->bl.x,su->bl.y,5); clif->changemapcell(0,su->bl.m,su->bl.x,su->bl.y,5,AREA); skill->unitsetmapcell(su,WZ_ICEWALL,group->skill_lv,CELL_ICEWALL,true); - map[su->bl.m].icewall_num++; + maplist[su->bl.m].icewall_num++; break; case SA_LANDPROTECTOR: skill->unitsetmapcell(su,SA_LANDPROTECTOR,group->skill_lv,CELL_LANDPROTECTOR,true); @@ -15163,7 +15161,7 @@ int skill_delunit (struct skill_unit* su) { iMap->setgatcell(su->bl.m,su->bl.x,su->bl.y,su->val2); clif->changemapcell(0,su->bl.m,su->bl.x,su->bl.y,su->val2,ALL_SAMEMAP); // hack to avoid clientside cell bug skill->unitsetmapcell(su,WZ_ICEWALL,group->skill_lv,CELL_ICEWALL,false); - map[su->bl.m].icewall_num--; + maplist[su->bl.m].icewall_num--; break; case SA_LANDPROTECTOR: skill->unitsetmapcell(su,SA_LANDPROTECTOR,group->skill_lv,CELL_LANDPROTECTOR,false); @@ -15596,13 +15594,13 @@ int skill_unit_timer_sub(DBKey key, DBData *data, va_list ap) { if(group->val1) { sd = iMap->charid2sd(group->val1); group->val1 = 0; - if (sd && !map[sd->bl.m].flag.nowarp) + if (sd && !maplist[sd->bl.m].flag.nowarp) pc->setpos(sd,map_id2index(su->bl.m),su->bl.x,su->bl.y,CLR_TELEPORT); } if(group->val2) { sd = iMap->charid2sd(group->val2); group->val2 = 0; - if (sd && !map[sd->bl.m].flag.nowarp) + if (sd && !maplist[sd->bl.m].flag.nowarp) pc->setpos(sd,map_id2index(su->bl.m),su->bl.x,su->bl.y,CLR_TELEPORT); } skill->delunit(su); @@ -17021,7 +17019,7 @@ int skill_blockpc_start_(struct map_session_data *sd, uint16 skill_id, int tick, struct skill_cd* cd = NULL; int i; - if( !(cd = idb_get(skill->cd_db,sd->status.char_id)) ) {// create a new skill cooldown object for map storage + if( !(cd = idb_get(skill->cd_db,sd->status.char_id)) ) {// create a new skill cooldown object for map storage cd = ers_alloc(skill->cd_ers, struct skill_cd); cd->cursor = 0; diff --git a/src/map/skill.h b/src/map/skill.h index 21544b730..eee62dc4a 100644 --- a/src/map/skill.h +++ b/src/map/skill.h @@ -1809,7 +1809,7 @@ struct skill_interface { int (*isammotype) (struct map_session_data *sd, int skill); int (*castend_id) (int tid, unsigned int tick, int id, intptr_t data); int (*castend_pos) (int tid, unsigned int tick, int id, intptr_t data); - int (*castend_map) ( struct map_session_data *sd,uint16 skill_id, const char *map); + int (*castend_map) ( struct map_session_data *sd,uint16 skill_id, const char *mapname); int (*cleartimerskill) (struct block_list *src); int (*addtimerskill) (struct block_list *src,unsigned int tick,int target,int x,int y,uint16 skill_id,uint16 skill_lv,int type,int flag); int (*additional_effect) ( struct block_list* src, struct block_list *bl,uint16 skill_id,uint16 skill_lv,int attack_type,int dmg_lv,unsigned int tick); diff --git a/src/map/status.c b/src/map/status.c index eb398806b..46f732e81 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -1205,7 +1205,7 @@ int status_damage(struct block_list *src,struct block_list *target,int64 in_hp, if ((sce=sc->data[SC_ENDURE]) && !sce->val4 && !sc->data[SC_LKCONCENTRATION]) { //Endure count is only reduced by non-players on non-gvg maps. //val4 signals infinite endure. [Skotlex] - if (src && src->type != BL_PC && !map_flag_gvg2(target->m) && !map[target->m].flag.battleground && --(sce->val2) < 0) + if (src && src->type != BL_PC && !map_flag_gvg2(target->m) && !maplist[target->m].flag.battleground && --(sce->val2) < 0) status_change_end(target, SC_ENDURE, INVALID_TIMER); } if ((sce=sc->data[SC_GRAVITATION]) && sce->val3 == BCT_SELF) { @@ -1564,12 +1564,12 @@ int status_check_skilluse(struct block_list *src, struct block_list *target, uin if( src && !(src->type == BL_PC && ((TBL_PC*)src)->skillitem)) { // Items that cast skills using 'itemskill' will not be handled by map_zone_db. int i; - for(i = 0; i < map[src->m].zone->disabled_skills_count; i++) { - if( skill_id == map[src->m].zone->disabled_skills[i]->nameid && (map[src->m].zone->disabled_skills[i]->type&src->type) ) { + for(i = 0; i < maplist[src->m].zone->disabled_skills_count; i++) { + if( skill_id == maplist[src->m].zone->disabled_skills[i]->nameid && (maplist[src->m].zone->disabled_skills[i]->type&src->type) ) { if( src->type == BL_PC ) clif->msg((TBL_PC*)src, SKILL_CANT_USE_AREA); // This skill cannot be used within this area - else if( src->type == BL_MOB && map[src->m].zone->disabled_skills[i]->subtype != MZS_NONE ) { - if( (st->mode&MD_BOSS) && !(map[src->m].zone->disabled_skills[i]->subtype&MZS_BOSS) ) + else if( src->type == BL_MOB && maplist[src->m].zone->disabled_skills[i]->subtype != MZS_NONE ) { + if( (st->mode&MD_BOSS) && !(maplist[src->m].zone->disabled_skills[i]->subtype&MZS_BOSS) ) break; } return 0; @@ -2152,9 +2152,9 @@ int status_calc_mob_(struct mob_data* md, bool first) { if(flag&4) { // Strengthen Guardians - custom value +10% / lv struct guild_castle *gc; - gc=guild->mapname2gc(map[md->bl.m].name); + gc=guild->mapname2gc(maplist[md->bl.m].name); if (!gc) - ShowError("status_calc_mob: No castle set at map %s\n", map[md->bl.m].name); + ShowError("status_calc_mob: No castle set at map %s\n", maplist[md->bl.m].name); else if(gc->castle_id < 24 || md->class_ == MOBID_EMPERIUM) { #ifdef RENEWAL @@ -2482,13 +2482,13 @@ int status_calc_pc_(struct map_session_data* sd, bool first) { if(!sd->inventory_data[index]) continue; - for(k = 0; k < map[sd->bl.m].zone->disabled_items_count; k++) { - if( map[sd->bl.m].zone->disabled_items[k] == sd->inventory_data[index]->nameid ) { + for(k = 0; k < maplist[sd->bl.m].zone->disabled_items_count; k++) { + if( maplist[sd->bl.m].zone->disabled_items[k] == sd->inventory_data[index]->nameid ) { break; } } - if( k < map[sd->bl.m].zone->disabled_items_count ) + if( k < maplist[sd->bl.m].zone->disabled_items_count ) continue; bstatus->def += sd->inventory_data[index]->def; @@ -2626,13 +2626,13 @@ int status_calc_pc_(struct map_session_data* sd, bool first) { if(!data) continue; - for(k = 0; k < map[sd->bl.m].zone->disabled_items_count; k++) { - if( map[sd->bl.m].zone->disabled_items[k] == data->nameid ) { + for(k = 0; k < maplist[sd->bl.m].zone->disabled_items_count; k++) { + if( maplist[sd->bl.m].zone->disabled_items[k] == data->nameid ) { break; } } - if( k < map[sd->bl.m].zone->disabled_items_count ) + if( k < maplist[sd->bl.m].zone->disabled_items_count ) continue; if(first && data->equip_script) {//Execute equip-script on login @@ -4735,13 +4735,11 @@ static signed short status_calc_hit(struct block_list *bl, struct status_change return (short)cap_value(hit,1,SHRT_MAX); } -static signed short status_calc_flee(struct block_list *bl, struct status_change *sc, int flee, bool viewable) -{ - if( bl->type == BL_PC ) - { +static signed short status_calc_flee(struct block_list *bl, struct status_change *sc, int flee, bool viewable) { + if( bl->type == BL_PC ) { if( map_flag_gvg2(bl->m) ) flee -= flee * battle_config.gvg_flee_penalty/100; - else if( map[bl->m].flag.battleground ) + else if( maplist[bl->m].flag.battleground ) flee -= flee * battle_config.bg_flee_penalty/100; } @@ -5544,9 +5542,8 @@ static short status_calc_aspd_rate(struct block_list *bl, struct status_change * return (short)cap_value(aspd_rate,0,SHRT_MAX); } -static unsigned short status_calc_dmotion(struct block_list *bl, struct status_change *sc, int dmotion) -{ - if( !sc || !sc->count || map_flag_gvg2(bl->m) || map[bl->m].flag.battleground ) +static unsigned short status_calc_dmotion(struct block_list *bl, struct status_change *sc, int dmotion) { + if( !sc || !sc->count || map_flag_gvg2(bl->m) || maplist[bl->m].flag.battleground ) return cap_value(dmotion,0,USHRT_MAX); /** * It has been confirmed on official servers that MvP mobs have no dmotion even without endure @@ -7293,8 +7290,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val break; case SC_ENDURE: val2 = 7; // Hit-count [Celest] - if( !(flag&1) && (bl->type&(BL_PC|BL_MER)) && !map_flag_gvg(bl->m) && !map[bl->m].flag.battleground && !val4 ) - { + if( !(flag&1) && (bl->type&(BL_PC|BL_MER)) && !map_flag_gvg(bl->m) && !maplist[bl->m].flag.battleground && !val4 ) { struct map_session_data *tsd; if( sd ) { @@ -7597,7 +7593,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val if (sc->data[SC_SOULLINK] && sc->data[SC_SOULLINK]->val2 == SL_ROGUE) val3 -= 40; val4 = 10+val1*2; //SP cost. - if (map_flag_gvg(bl->m) || map[bl->m].flag.battleground) val4 *= 5; + if (map_flag_gvg(bl->m) || maplist[bl->m].flag.battleground) val4 *= 5; break; case SC_CLOAKING: if (!sd) //Monsters should be able to walk with no penalties. [Skotlex] @@ -7797,13 +7793,12 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val struct block_list *d_bl; struct status_change *d_sc; - if( (d_bl = iMap->id2bl(val1)) && (d_sc = iStatus->get_sc(d_bl)) && d_sc->count ) - { // Inherits Status From Source + if( (d_bl = iMap->id2bl(val1)) && (d_sc = iStatus->get_sc(d_bl)) && d_sc->count ) { + // Inherits Status From Source const enum sc_type types[] = { SC_AUTOGUARD, SC_DEFENDER, SC_REFLECTSHIELD, SC_ENDURE }; enum sc_type type2; - int i = (map_flag_gvg(bl->m) || map[bl->m].flag.battleground)?2:3; - while( i >= 0 ) - { + int i = (map_flag_gvg(bl->m) || maplist[bl->m].flag.battleground)?2:3; + while( i >= 0 ) { type2 = types[i]; if( d_sc->data[type2] ) sc_start(bl, type2, 100, d_sc->data[type2]->val1, skill->get_time(iStatus->sc2skill(type2),d_sc->data[type2]->val1)); @@ -8006,12 +8001,12 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val { if (sd->mapindex != val2) { - int pos = (bl->x&0xFFFF)|(bl->y<<16), //Current Coordinates - map = sd->mapindex; //Current Map + int pos = (bl->x&0xFFFF)|(bl->y<<16); /// Current Coordinates + int mapindex = sd->mapindex; /// Current Map //1. Place in Jail (val2 -> Jail Map, val3 -> x, val4 -> y pc->setpos(sd,(unsigned short)val2,val3,val4, CLR_TELEPORT); //2. Set restore point (val3 -> return map, val4 return coords - val3 = map; + val3 = mapindex; val4 = pos; } else if (!val3 || val3 == sd->mapindex) { //Use save point. val3 = sd->status.save_point.map; diff --git a/src/map/trade.c b/src/map/trade.c index 3134fa3e4..f8df2a6c3 100644 --- a/src/map/trade.c +++ b/src/map/trade.c @@ -33,7 +33,7 @@ void trade_traderequest(struct map_session_data *sd, struct map_session_data *ta { nullpo_retv(sd); - if (map[sd->bl.m].flag.notrade) { + if (maplist[sd->bl.m].flag.notrade) { clif->message (sd->fd, msg_txt(272)); return; //Can't trade in notrade mapflag maps. } diff --git a/src/map/unit.c b/src/map/unit.c index d95b411da..4a794da09 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -802,31 +802,31 @@ int unit_warp(struct block_list *bl,short m,short x,short y,clr_type type) switch (bl->type) { case BL_MOB: - if (map[bl->m].flag.monster_noteleport && ((TBL_MOB*)bl)->master_id == 0) + if (maplist[bl->m].flag.monster_noteleport && ((TBL_MOB*)bl)->master_id == 0) return 1; - if (m != bl->m && map[m].flag.nobranch && battle_config.mob_warp&4 && !(((TBL_MOB *)bl)->master_id)) + if (m != bl->m && maplist[m].flag.nobranch && battle_config.mob_warp&4 && !(((TBL_MOB *)bl)->master_id)) return 1; break; case BL_PC: - if (map[bl->m].flag.noteleport) + if (maplist[bl->m].flag.noteleport) return 1; break; } - if (x<0 || y<0) - { //Random map position. + if (x<0 || y<0) { + //Random map position. if (!iMap->search_freecell(NULL, m, &x, &y, -1, -1, 1)) { - ShowWarning("unit_warp failed. Unit Id:%d/Type:%d, target position map %d (%s) at [%d,%d]\n", bl->id, bl->type, m, map[m].name, x, y); + ShowWarning("unit_warp failed. Unit Id:%d/Type:%d, target position map %d (%s) at [%d,%d]\n", bl->id, bl->type, m, maplist[m].name, x, y); return 2; } - } else if (iMap->getcell(m,x,y,CELL_CHKNOREACH)) - { //Invalid target cell - ShowWarning("unit_warp: Specified non-walkable target cell: %d (%s) at [%d,%d]\n", m, map[m].name, x,y); + } else if (iMap->getcell(m,x,y,CELL_CHKNOREACH)) { + //Invalid target cell + ShowWarning("unit_warp: Specified non-walkable target cell: %d (%s) at [%d,%d]\n", m, maplist[m].name, x,y); - if (!iMap->search_freecell(NULL, m, &x, &y, 4, 4, 1)) - { //Can't find a nearby cell - ShowWarning("unit_warp failed. Unit Id:%d/Type:%d, target position map %d (%s) at [%d,%d]\n", bl->id, bl->type, m, map[m].name, x, y); + if (!iMap->search_freecell(NULL, m, &x, &y, 4, 4, 1)) { + //Can't find a nearby cell + ShowWarning("unit_warp failed. Unit Id:%d/Type:%d, target position map %d (%s) at [%d,%d]\n", bl->id, bl->type, m, maplist[m].name, x, y); return 2; } } @@ -1966,7 +1966,7 @@ int unit_skillcastcancel(struct block_list *bl,int type) return 0; if (sd && (sd->special_state.no_castcancel2 || - ((sd->sc.data[SC_UNLIMITED_HUMMING_VOICE] || sd->special_state.no_castcancel) && !map_flag_gvg(bl->m) && !map[bl->m].flag.battleground))) //fixed flags being read the wrong way around [blackhole89] + ((sd->sc.data[SC_UNLIMITED_HUMMING_VOICE] || sd->special_state.no_castcancel) && !map_flag_gvg(bl->m) && !maplist[bl->m].flag.battleground))) //fixed flags being read the wrong way around [blackhole89] return 0; } @@ -2187,10 +2187,9 @@ int unit_remove_map(struct block_list *bl, clr_type clrtype, const char* file, i guild->send_dot_remove(sd); bg->send_dot_remove(sd); - if( map[bl->m].users <= 0 || sd->state.debug_remove_map ) - {// this is only place where map users is decreased, if the mobs were removed too soon then this function was executed too many times [FlavioJS] - if( sd->debug_file == NULL || !(sd->state.debug_remove_map) ) - { + if( maplist[bl->m].users <= 0 || sd->state.debug_remove_map ) { + // this is only place where map users is decreased, if the mobs were removed too soon then this function was executed too many times [FlavioJS] + if( sd->debug_file == NULL || !(sd->state.debug_remove_map) ) { sd->debug_file = ""; sd->debug_line = 0; sd->debug_func = ""; @@ -2202,17 +2201,17 @@ int unit_remove_map(struct block_list *bl, clr_type clrtype, const char* file, i " Please report this!!!\n", sd->status.account_id, sd->status.char_id, sd->state.active, sd->state.connect_new, sd->state.rewarp, sd->state.changemap, sd->state.debug_remove_map, - map[bl->m].name, map[bl->m].users, + maplist[bl->m].name, maplist[bl->m].users, sd->debug_file, sd->debug_line, sd->debug_func, file, line, func); - } else if (--map[bl->m].users == 0 && battle_config.dynamic_mobs) //[Skotlex] + } else if (--maplist[bl->m].users == 0 && battle_config.dynamic_mobs) //[Skotlex] iMap->removemobs(bl->m); - if( !(sd->sc.option&OPTION_INVISIBLE) ) - {// decrement the number of active pvp players on the map - --map[bl->m].users_pvp; + if( !(sd->sc.option&OPTION_INVISIBLE) ) { + // decrement the number of active pvp players on the map + --maplist[bl->m].users_pvp; } - if( map[bl->m].instance_id >= 0 ) { - instances[map[bl->m].instance_id].users--; - instance->check_idle(map[bl->m].instance_id); + if( maplist[bl->m].instance_id >= 0 ) { + instances[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] sd->debug_file = file; |