diff options
Diffstat (limited to 'src/map')
45 files changed, 6246 insertions, 6484 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 57d2a73ef..cec314134 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -53,15 +53,9 @@ struct atcommand_interface atcommand_s; -static char* msg_table[MAX_MSG]; // Server messages (0-499 reserved for GM commands, 500-999 reserved for others) - static char atcmd_output[CHAT_SIZE_MAX]; static char atcmd_player_name[NAME_LENGTH]; -static AtCommandInfo* get_atcommandinfo_byname(const char *name); // @help -static const char* atcommand_checkalias(const char *aliasname); // @help -static void atcommand_get_suggestions(struct map_session_data* sd, const char *name, bool is_atcmd_cmd); // @help - // @commands (script-based) struct atcmd_binding_data* get_atcommandbind_byname(const char* name) { int i = 0; @@ -80,8 +74,8 @@ struct atcmd_binding_data* get_atcommandbind_byname(const char* name) { const char* msg_txt(int msg_number) { if (msg_number >= 0 && msg_number < MAX_MSG && - msg_table[msg_number] != NULL && msg_table[msg_number][0] != '\0') - return msg_table[msg_number]; + atcommand->msg_table[msg_number] != NULL && atcommand->msg_table[msg_number][0] != '\0') + return atcommand->msg_table[msg_number]; return "??"; } @@ -102,7 +96,7 @@ int msg_config_read(const char* cfgName) } if ((--called) == 0) - memset(msg_table, 0, sizeof(msg_table[0]) * MAX_MSG); + memset(atcommand->msg_table, 0, sizeof(atcommand->msg_table[0]) * MAX_MSG); while(fgets(line, sizeof(line), fp)) { @@ -118,10 +112,11 @@ int msg_config_read(const char* cfgName) msg_number = atoi(w1); if (msg_number >= 0 && msg_number < MAX_MSG) { - if (msg_table[msg_number] != NULL) - aFree(msg_table[msg_number]); - msg_table[msg_number] = (char *)aMalloc((strlen(w2) + 1)*sizeof (char)); - strcpy(msg_table[msg_number],w2); + if (atcommand->msg_table[msg_number] != NULL) + aFree(atcommand->msg_table[msg_number]); + /* this could easily become consecutive memory like get_str() and save the malloc overhead for over 1k calls [Ind] */ + atcommand->msg_table[msg_number] = (char *)aMalloc((strlen(w2) + 1)*sizeof (char)); + strcpy(atcommand->msg_table[msg_number],w2); } } } @@ -138,7 +133,7 @@ void do_final_msg(void) { int i; for (i = 0; i < MAX_MSG; i++) - aFree(msg_table[i]); + aFree(atcommand->msg_table[i]); } /** @@ -384,8 +379,7 @@ return false;\ /*========================================== * @rura, @warp, @mapmove *------------------------------------------*/ -ACMD(mapmove) -{ +ACMD(mapmove) { char map_name[MAP_NAME_LENGTH_EXT]; unsigned short mapindex; short x = 0, y = 0; @@ -405,17 +399,17 @@ ACMD(mapmove) mapindex = mapindex_name2id(map_name); if (mapindex) - m = iMap->mapindex2mapid(mapindex); + m = map->mapindex2mapid(mapindex); if (!mapindex || m < 0) { // m < 0 means on different server or that map is disabled! [Kevin] clif->message(fd, msg_txt(1)); // Map not found. return false; } - if ((x || y) && iMap->getcell(m, x, y, CELL_CHKNOPASS) && pc->get_group_level(sd) < battle_config.gm_ignore_warpable_area) - { //This is to prevent the pc->setpos call from printing an error. + if ((x || y) && map->getcell(m, x, y, CELL_CHKNOPASS) && pc->get_group_level(sd) < battle_config.gm_ignore_warpable_area) { + //This is to prevent the pc->setpos call from printing an error. clif->message(fd, msg_txt(2)); - if (!iMap->search_freecell(NULL, m, &x, &y, 10, 10, 1)) + if (!map->search_freecell(NULL, m, &x, &y, 10, 10, 1)) x = y = 0; //Invalid cell, use random spot. } if (maplist[m].flag.nowarpto && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { @@ -438,8 +432,7 @@ ACMD(mapmove) /*========================================== * Displays where a character is. Corrected version by Silent. [Skotlex] *------------------------------------------*/ -ACMD(where) -{ +ACMD(where) { struct map_session_data* pl_sd; nullpo_retr(-1, sd); @@ -450,7 +443,7 @@ ACMD(where) return false; } - pl_sd = iMap->nick2sd(atcmd_player_name); + pl_sd = map->nick2sd(atcmd_player_name); if (pl_sd == NULL || strncmp(pl_sd->status.name, atcmd_player_name, NAME_LENGTH) != 0 || (pc->has_permission(pl_sd, PC_PERM_HIDE_SESSION) && pc->get_group_level(pl_sd) > pc->get_group_level(sd) && !pc->has_permission(sd, PC_PERM_WHO_DISPLAY_AID)) @@ -478,7 +471,7 @@ ACMD(jumpto) { return false; } - if((pl_sd=iMap->nick2sd((char *)message)) == NULL && (pl_sd=iMap->charid2sd(atoi(message))) == NULL) { + if((pl_sd=map->nick2sd((char *)message)) == NULL && (pl_sd=map->charid2sd(atoi(message))) == NULL) { clif->message(fd, msg_txt(3)); // Character not found. return false; } @@ -529,10 +522,10 @@ ACMD(jump) return false; } - if ((x || y) && iMap->getcell(sd->bl.m, x, y, CELL_CHKNOPASS)) - { //This is to prevent the pc->setpos call from printing an error. + if ((x || y) && map->getcell(sd->bl.m, x, y, CELL_CHKNOPASS)) { + //This is to prevent the pc->setpos call from printing an error. clif->message(fd, msg_txt(2)); - if (!iMap->search_freecell(NULL, sd->bl.m, &x, &y, 10, 10, 1)) + if (!map->search_freecell(NULL, sd->bl.m, &x, &y, 10, 10, 1)) x = y = 0; //Invalid cell, use random spot. } @@ -546,8 +539,7 @@ ACMD(jump) * Display list of online characters with * various info. *------------------------------------------*/ -ACMD(who) -{ +ACMD(who) { struct map_session_data *pl_sd = NULL; struct s_mapiterator *iter = NULL; char map_name[MAP_NAME_LENGTH_EXT] = ""; @@ -566,7 +558,7 @@ ACMD(who) nullpo_retr(-1, sd); if (strstr(command, "map") != NULL) { - if (sscanf(message, "%15s %23s", map_name, player_name) < 1 || (map_id = iMap->mapname2mapid(map_name)) < 0) + if (sscanf(message, "%15s %23s", map_name, player_name) < 1 || (map_id = map->mapname2mapid(map_name)) < 0) map_id = sd->bl.m; } else { sscanf(message, "%23s", player_name); @@ -757,7 +749,7 @@ ACMD(load) { nullpo_retr(-1, sd); - m = iMap->mapindex2mapid(sd->status.save_point.map); + m = map->mapindex2mapid(sd->status.save_point.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; @@ -895,9 +887,9 @@ ACMD(hide) { if (sd->sc.option & OPTION_INVISIBLE) { sd->sc.option &= ~OPTION_INVISIBLE; if (sd->disguise != -1 ) - iStatus->set_viewdata(&sd->bl, sd->disguise); + status->set_viewdata(&sd->bl, sd->disguise); else - iStatus->set_viewdata(&sd->bl, sd->status.class_); + status->set_viewdata(&sd->bl, sd->status.class_); clif->message(fd, msg_txt(10)); // Invisible: Off // increment the number of pvp players on the map @@ -908,7 +900,7 @@ ACMD(hide) { sd->pvp_timer = timer->add( timer->gettick() + 200, pc->calc_pvprank_timer, sd->bl.id, 0 ); } //bugreport:2266 - iMap->foreachinmovearea(clif->insight, &sd->bl, AREA_SIZE, sd->bl.x, sd->bl.y, BL_ALL, &sd->bl); + map->foreachinmovearea(clif->insight, &sd->bl, AREA_SIZE, sd->bl.x, sd->bl.y, BL_ALL, &sd->bl); } else { sd->sc.option |= OPTION_INVISIBLE; sd->vd.class_ = INVISIBLE_CLASS; @@ -1011,8 +1003,7 @@ ACMD(kill) ACMD(alive) { nullpo_retr(-1, sd); - if (!iStatus->revive(&sd->bl, 100, 100)) - { + if (!status->revive(&sd->bl, 100, 100)) { clif->message(fd, msg_txt(667)); return false; } @@ -1080,7 +1071,7 @@ ACMD(heal) } if ( hp > 0 && sp >= 0 ) { - if(!iStatus->heal(&sd->bl, hp, sp, 0)) + if(!status->heal(&sd->bl, hp, sp, 0)) clif->message(fd, msg_txt(157)); // HP and SP are already with the good value. else clif->message(fd, msg_txt(17)); // HP, SP recovered. @@ -1088,7 +1079,7 @@ ACMD(heal) } if ( hp < 0 && sp <= 0 ) { - iStatus->damage(NULL, &sd->bl, -hp, -sp, 0, 0); + status->damage(NULL, &sd->bl, -hp, -sp, 0, 0); clif->damage(&sd->bl,&sd->bl, timer->gettick(), 0, 0, -hp, 0, 4, 0); clif->message(fd, msg_txt(156)); // HP or/and SP modified. return true; @@ -1097,18 +1088,18 @@ ACMD(heal) //Opposing signs. if ( hp ) { if (hp > 0) - iStatus->heal(&sd->bl, hp, 0, 0); + status->heal(&sd->bl, hp, 0, 0); else { - iStatus->damage(NULL, &sd->bl, -hp, 0, 0, 0); + status->damage(NULL, &sd->bl, -hp, 0, 0, 0); clif->damage(&sd->bl,&sd->bl, timer->gettick(), 0, 0, -hp, 0, 4, 0); } } if ( sp ) { if (sp > 0) - iStatus->heal(&sd->bl, 0, sp, 0); + status->heal(&sd->bl, 0, sp, 0); else - iStatus->damage(NULL, &sd->bl, 0, -sp, 0, 0); + status->damage(NULL, &sd->bl, 0, -sp, 0, 0); } clif->message(fd, msg_txt(156)); // HP or/and SP modified. @@ -1392,22 +1383,22 @@ ACMD(help) { } else { if (*message == atcommand->at_symbol || *message == atcommand->char_symbol) ++message; - command_name = atcommand_checkalias(message); + command_name = atcommand->check_alias(message); } if (!atcommand->can_use2(sd, command_name, COMMAND_ATCOMMAND)) { sprintf(atcmd_output, msg_txt(153), message); // "%s is Unknown Command" clif->message(fd, atcmd_output); - atcommand_get_suggestions(sd, command_name, true); + atcommand->get_suggestions(sd, command_name, true); return false; } - tinfo = get_atcommandinfo_byname(atcommand_checkalias(command_name)); + tinfo = atcommand->get_info_byname(atcommand->check_alias(command_name)); if ( !tinfo || tinfo->help == NULL ) { sprintf(atcmd_output, msg_txt(988), atcommand->at_symbol, command_name); // There is no help for %c%s. clif->message(fd, atcmd_output); - atcommand_get_suggestions(sd, command_name, true); + atcommand->get_suggestions(sd, command_name, true); return false; } @@ -1423,7 +1414,7 @@ ACMD(help) { StrBuf->Init(&buf); StrBuf->AppendStr(&buf, msg_txt(990)); // Available aliases: - command_info = get_atcommandinfo_byname(command_name); + command_info = atcommand->get_info_byname(command_name); iter = db_iterator(atcommand->alias_db); for (alias_info = dbi_first(iter); dbi_exists(iter); alias_info = dbi_next(iter)) { if (alias_info->command == command_info) { @@ -1444,7 +1435,7 @@ ACMD(help) { // helper function, used in foreach calls to stop auto-attack timers // parameter: '0' - everyone, 'id' - only those attacking someone with that id -static int atcommand_stopattack(struct block_list *bl,va_list ap) +int atcommand_stopattack(struct block_list *bl,va_list ap) { struct unit_data *ud = unit->bl2ud(bl); int id = va_arg(ap, int); @@ -1458,7 +1449,7 @@ static int atcommand_stopattack(struct block_list *bl,va_list ap) /*========================================== * *------------------------------------------*/ -static int atcommand_pvpoff_sub(struct block_list *bl,va_list ap) +int atcommand_pvpoff_sub(struct block_list *bl,va_list ap) { TBL_PC* sd = (TBL_PC*)bl; clif->pvpset(sd, 0, 0, 2); @@ -1477,15 +1468,15 @@ ACMD(pvpoff) { return false; } - iMap->zone_change2(sd->bl.m,maplist[sd->bl.m].prev_zone); + map->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); clif->maptypeproperty2(&sd->bl,ALL_SAMEMAP); } - iMap->foreachinmap(atcommand_pvpoff_sub,sd->bl.m, BL_PC); - iMap->foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0); + map->foreachinmap(atcommand->pvpoff_sub,sd->bl.m, BL_PC); + map->foreachinmap(atcommand->stopattack,sd->bl.m, BL_CHAR, 0); clif->message(fd, msg_txt(31)); // PvP: Off. return true; } @@ -1493,7 +1484,7 @@ ACMD(pvpoff) { /*========================================== * *------------------------------------------*/ -static int atcommand_pvpon_sub(struct block_list *bl,va_list ap) +int atcommand_pvpon_sub(struct block_list *bl,va_list ap) { TBL_PC* sd = (TBL_PC*)bl; if (sd->pvp_timer == INVALID_TIMER) { @@ -1515,13 +1506,13 @@ ACMD(pvpon) { return false; } - iMap->zone_change2(sd->bl.m,strdb_get(zone_db, MAP_ZONE_PVP_NAME)); + map->zone_change2(sd->bl.m,strdb_get(zone_db, MAP_ZONE_PVP_NAME)); 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); clif->maptypeproperty2(&sd->bl,ALL_SAMEMAP); - iMap->foreachinmap(atcommand_pvpon_sub,sd->bl.m, BL_PC); + map->foreachinmap(atcommand->pvpon_sub,sd->bl.m, BL_PC); } clif->message(fd, msg_txt(32)); // PvP: On. @@ -1540,11 +1531,11 @@ ACMD(gvgoff) { return false; } - iMap->zone_change2(sd->bl.m,maplist[sd->bl.m].prev_zone); + map->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); + map->foreachinmap(atcommand->stopattack,sd->bl.m, BL_CHAR, 0); clif->message(fd, msg_txt(33)); // GvG: Off. return true; @@ -1561,7 +1552,7 @@ ACMD(gvgon) { return false; } - iMap->zone_change2(sd->bl.m,strdb_get(zone_db, MAP_ZONE_GVG_NAME)); + map->zone_change2(sd->bl.m,strdb_get(zone_db, MAP_ZONE_GVG_NAME)); maplist[sd->bl.m].flag.gvg = 1; clif->map_property_mapall(sd->bl.m, MAPPROPERTY_AGITZONE); clif->maptypeproperty2(&sd->bl,ALL_SAMEMAP); @@ -1853,7 +1844,7 @@ ACMD(go) } if (town >= 0 && town < ARRAYLENGTH(data)) { - m = iMap->mapname2mapid(data[town].map); + m = map->mapname2mapid(data[town].map); if (m >= 0 && maplist[m].flag.nowarpto && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif->message(fd, msg_txt(247)); return false; @@ -1953,7 +1944,7 @@ ACMD(monster) count = 0; range = (int)sqrt((float)number) +2; // calculation of an odd number (+ 4 area around) for (i = 0; i < number; i++) { - iMap->search_freecell(&sd->bl, 0, &mx, &my, range, range, 0); + map->search_freecell(&sd->bl, 0, &mx, &my, range, range, 0); k = mob->once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, eventname, size, AI_NONE); count += (k != 0) ? 1 : 0; } @@ -1976,7 +1967,7 @@ ACMD(monster) /*========================================== * *------------------------------------------*/ -static int atkillmonster_sub(struct block_list *bl, va_list ap) +int atkillmonster_sub(struct block_list *bl, va_list ap) { struct mob_data *md; int flag; @@ -1994,8 +1985,7 @@ static int atkillmonster_sub(struct block_list *bl, va_list ap) return 1; } -ACMD(killmonster) -{ +ACMD(killmonster) { int map_id, drop_flag; char map_name[MAP_NAME_LENGTH_EXT]; nullpo_retr(-1, sd); @@ -2005,13 +1995,13 @@ ACMD(killmonster) if (!message || !*message || sscanf(message, "%15s", map_name) < 1) map_id = sd->bl.m; else { - if ((map_id = iMap->mapname2mapid(map_name)) < 0) + if ((map_id = map->mapname2mapid(map_name)) < 0) map_id = sd->bl.m; } drop_flag = strcmp(command+1, "killmonster2"); - iMap->foreachinmap(atkillmonster_sub, map_id, BL_MOB, -drop_flag); + map->foreachinmap(atcommand->atkillmonster_sub, map_id, BL_MOB, -drop_flag); clif->message(fd, msg_txt(165)); // All monsters killed! @@ -2194,8 +2184,7 @@ ACMD(memo) /*========================================== * *------------------------------------------*/ -ACMD(gat) -{ +ACMD(gat) { int y; nullpo_retr(-1, sd); @@ -2204,11 +2193,11 @@ ACMD(gat) for (y = 2; y >= -2; y--) { sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X", 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), - iMap->getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE), - iMap->getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE)); + map->getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE), + map->getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE), + map->getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE), + map->getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE), + map->getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE)); clif->message(fd, atcmd_output); } @@ -2688,8 +2677,7 @@ ACMD(recall) { return false; } - if((pl_sd=iMap->nick2sd((char *)message)) == NULL && (pl_sd=iMap->charid2sd(atoi(message))) == NULL) - { + if((pl_sd=map->nick2sd((char *)message)) == NULL && (pl_sd=map->charid2sd(atoi(message))) == NULL) { clif->message(fd, msg_txt(3)); // Character not found. return false; } @@ -2881,11 +2869,10 @@ ACMD(char_unban) /*========================================== * *------------------------------------------*/ -ACMD(night) -{ +ACMD(night) { nullpo_retr(-1, sd); - if (iMap->night_flag != 1) { + if (map->night_flag != 1) { pc->map_night_timer(pc->night_timer_tid, 0, 0, 1); } else { clif->message(fd, msg_txt(89)); // Night mode is already enabled. @@ -2898,11 +2885,10 @@ ACMD(night) /*========================================== * *------------------------------------------*/ -ACMD(day) -{ +ACMD(day) { nullpo_retr(-1, sd); - if (iMap->night_flag != 0) { + if (map->night_flag != 0) { pc->map_day_timer(pc->day_timer_tid, 0, 0, 1); } else { clif->message(fd, msg_txt(90)); // Day mode is already enabled. @@ -2969,9 +2955,9 @@ ACMD(doommap) /*========================================== * *------------------------------------------*/ -static void atcommand_raise_sub(struct map_session_data* sd) { +void atcommand_raise_sub(struct map_session_data* sd) { - iStatus->revive(&sd->bl, 100, 100); + status->revive(&sd->bl, 100, 100); clif->skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1); clif->message(sd->fd, msg_txt(63)); // Mercy has been shown. @@ -2990,7 +2976,7 @@ ACMD(raise) iter = mapit_getallusers(); for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) if( pc_isdead(pl_sd) ) - atcommand_raise_sub(pl_sd); + atcommand->raise_sub(pl_sd); mapit->free(iter); clif->message(fd, msg_txt(64)); // Mercy has been granted. @@ -3011,7 +2997,7 @@ ACMD(raisemap) iter = mapit_getallusers(); for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) if (sd->bl.m == pl_sd->bl.m && pc_isdead(pl_sd) ) - atcommand_raise_sub(pl_sd); + atcommand->raise_sub(pl_sd); mapit->free(iter); clif->message(fd, msg_txt(64)); // Mercy has been granted. @@ -3034,8 +3020,7 @@ ACMD(kick) return false; } - if((pl_sd=iMap->nick2sd((char *)message)) == NULL && (pl_sd=iMap->charid2sd(atoi(message))) == NULL) - { + if((pl_sd=map->nick2sd((char *)message)) == NULL && (pl_sd=map->charid2sd(atoi(message))) == NULL) { clif->message(fd, msg_txt(3)); // Character not found. return false; } @@ -3283,15 +3268,14 @@ ACMD(breakguild) /*========================================== * *------------------------------------------*/ -ACMD(agitstart) -{ +ACMD(agitstart) { nullpo_retr(-1, sd); - if (iMap->agit_flag == 1) { + if (map->agit_flag == 1) { clif->message(fd, msg_txt(73)); // War of Emperium is currently in progress. return false; } - iMap->agit_flag = 1; + map->agit_flag = 1; guild->agit_start(); clif->message(fd, msg_txt(72)); // War of Emperium has been initiated. @@ -3301,15 +3285,14 @@ ACMD(agitstart) /*========================================== * *------------------------------------------*/ -ACMD(agitstart2) -{ +ACMD(agitstart2) { nullpo_retr(-1, sd); - if (iMap->agit2_flag == 1) { + if (map->agit2_flag == 1) { clif->message(fd, msg_txt(404)); // "War of Emperium SE is currently in progress." return false; } - iMap->agit2_flag = 1; + map->agit2_flag = 1; guild->agit2_start(); clif->message(fd, msg_txt(403)); // "War of Emperium SE has been initiated." @@ -3319,15 +3302,14 @@ ACMD(agitstart2) /*========================================== * *------------------------------------------*/ -ACMD(agitend) -{ +ACMD(agitend) { nullpo_retr(-1, sd); - if (iMap->agit_flag == 0) { + if (map->agit_flag == 0) { clif->message(fd, msg_txt(75)); // War of Emperium is currently not in progress. return false; } - iMap->agit_flag = 0; + map->agit_flag = 0; guild->agit_end(); clif->message(fd, msg_txt(74)); // War of Emperium has been ended. @@ -3337,15 +3319,14 @@ ACMD(agitend) /*========================================== * *------------------------------------------*/ -ACMD(agitend2) -{ +ACMD(agitend2) { nullpo_retr(-1, sd); - if (iMap->agit2_flag == 0) { + if (map->agit2_flag == 0) { clif->message(fd, msg_txt(406)); // "War of Emperium SE is currently not in progress." return false; } - iMap->agit2_flag = 0; + map->agit2_flag = 0; guild->agit2_end(); clif->message(fd, msg_txt(405)); // "War of Emperium SE has been ended." @@ -3355,11 +3336,10 @@ ACMD(agitend2) /*========================================== * @mapexit - shuts down the map server *------------------------------------------*/ -ACMD(mapexit) -{ +ACMD(mapexit) { nullpo_retr(-1, sd); - iMap->do_shutdown(); + map->do_shutdown(); return true; } @@ -3581,7 +3561,7 @@ ACMD(reloadmobdb) { homun->reload(); mercenary->read_db(); mercenary->read_skilldb(); - elemental->reload_elementaldb(); + elemental->reload_db(); clif->message(fd, msg_txt(98)); // Monster database has been reloaded. return true; @@ -3605,7 +3585,6 @@ ACMD(reloadskilldb) /*========================================== * @reloadatcommand - reloads conf/atcommand.conf conf/groups.conf *------------------------------------------*/ -void atcommand_doload(); ACMD(reloadatcommand) { config_t run_test; @@ -3616,14 +3595,14 @@ ACMD(reloadatcommand) { config_destroy(&run_test); - if (conf_read_file(&run_test, iMap->ATCOMMAND_CONF_FILENAME)) { + if (conf_read_file(&run_test, map->ATCOMMAND_CONF_FILENAME)) { clif->message(fd, msg_txt(1037)); // Error reading atcommand.conf, reload failed. return false; } config_destroy(&run_test); - atcommand_doload(); + atcommand->doload(); pc_groups_reload(); clif->message(fd, msg_txt(254)); return true; @@ -3636,7 +3615,7 @@ ACMD(reloadbattleconf) struct Battle_Config prev_config; memcpy(&prev_config, &battle_config, sizeof(prev_config)); - battle->config_read(iMap->BATTLE_CONF_FILENAME); + battle->config_read(map->BATTLE_CONF_FILENAME); if( prev_config.item_rate_mvp != battle_config.item_rate_mvp || prev_config.item_rate_common != battle_config.item_rate_common @@ -3679,9 +3658,8 @@ ACMD(reloadbattleconf) /*========================================== * @reloadstatusdb - reloads job_db1.txt job_db2.txt job_db2-2.txt refine_db.txt size_fix.txt *------------------------------------------*/ -ACMD(reloadstatusdb) -{ - iStatus->readdb(); +ACMD(reloadstatusdb) { + status->readdb(); clif->message(fd, msg_txt(256)); return true; } @@ -3698,8 +3676,7 @@ ACMD(reloadpcdb) /*========================================== * @reloadscript - reloads all scripts (npcs, warps, mob spawns, ...) *------------------------------------------*/ -ACMD(reloadscript) -{ +ACMD(reloadscript) { struct s_mapiterator* iter; struct map_session_data* pl_sd; @@ -3728,7 +3705,7 @@ ACMD(reloadscript) mapit->free(iter); flush_fifos(); - iMap->reloadnpc(true); // reload config files seeking for npcs + map->reloadnpc(true); // reload config files seeking for npcs script->reload(); npc->reload(); @@ -3771,9 +3748,9 @@ ACMD(mapinfo) { if (mapname[0] == '\0') { safestrncpy(mapname, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH); - m_id = iMap->mapindex2mapid(sd->mapindex); + m_id = map->mapindex2mapid(sd->mapindex); } else { - m_id = iMap->mapname2mapid(mapname); + m_id = map->mapname2mapid(mapname); } if (m_id < 0) { @@ -3791,7 +3768,7 @@ ACMD(mapinfo) { if( pl_sd->mapindex == m_index ) { if( pl_sd->state.vending ) vend_num++; - else if( (cd = (struct chat_data*)iMap->id2bl(pl_sd->chatID)) != NULL && cd->usersd[0] == pl_sd ) + else if( (cd = (struct chat_data*)map->id2bl(pl_sd->chatID)) != NULL && cd->usersd[0] == pl_sd ) chat_num++; } } @@ -3970,7 +3947,7 @@ ACMD(mapinfo) { iter = mapit_getallusers(); for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) { - if ((cd = (struct chat_data*)iMap->id2bl(pl_sd->chatID)) != NULL && + if ((cd = (struct chat_data*)map->id2bl(pl_sd->chatID)) != NULL && pl_sd->mapindex == m_index && cd->usersd[0] == pl_sd) { @@ -4060,8 +4037,7 @@ ACMD(mount_peco) /*========================================== *Spy Commands by Syrus22 *------------------------------------------*/ -ACMD(guildspy) -{ +ACMD(guildspy) { char guild_name[NAME_LENGTH]; struct guild *g; nullpo_retr(-1, sd); @@ -4069,7 +4045,7 @@ ACMD(guildspy) memset(guild_name, '\0', sizeof(guild_name)); memset(atcmd_output, '\0', sizeof(atcmd_output)); - if (!iMap->enable_spy) + if (!map->enable_spy) { clif->message(fd, msg_txt(1125)); // The mapserver has spy command support disabled. return false; @@ -4101,8 +4077,7 @@ ACMD(guildspy) /*========================================== * *------------------------------------------*/ -ACMD(partyspy) -{ +ACMD(partyspy) { char party_name[NAME_LENGTH]; struct party_data *p; nullpo_retr(-1, sd); @@ -4110,7 +4085,7 @@ ACMD(partyspy) memset(party_name, '\0', sizeof(party_name)); memset(atcmd_output, '\0', sizeof(atcmd_output)); - if (!iMap->enable_spy) + if (!map->enable_spy) { clif->message(fd, msg_txt(1125)); // The mapserver has spy command support disabled. return false; @@ -4172,8 +4147,7 @@ ACMD(repairall) /*========================================== * @nuke [Valaris] *------------------------------------------*/ -ACMD(nuke) -{ +ACMD(nuke) { struct map_session_data *pl_sd; nullpo_retr(-1, sd); @@ -4184,7 +4158,7 @@ ACMD(nuke) return false; } - if ((pl_sd = iMap->nick2sd(atcmd_player_name)) != NULL) { + if ((pl_sd = map->nick2sd(atcmd_player_name)) != NULL) { if (pc->get_group_level(sd) >= pc->get_group_level(pl_sd)) { // you can kill only lower or same GM level skill->castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, timer->gettick(), 0); clif->message(fd, msg_txt(109)); // Player has been nuked! @@ -4374,8 +4348,7 @@ char* txt_time(unsigned int duration) * @time/@date/@serverdate/@servertime: Display the date/time of the server (by [Yor] * Calculation management of GM modification (@day/@night GM commands) is done *------------------------------------------*/ -ACMD(servertime) -{ +ACMD(servertime) { const struct TimerData * timer_data; const struct TimerData * timer_data2; time_t time_server; // variable for number of seconds (used with time() function) @@ -4392,61 +4365,59 @@ ACMD(servertime) clif->message(fd, temp); if (battle_config.night_duration == 0 && battle_config.day_duration == 0) { - if (iMap->night_flag == 0) + if (map->night_flag == 0) clif->message(fd, msg_txt(231)); // Game time: The game is in permanent daylight. else clif->message(fd, msg_txt(232)); // Game time: The game is in permanent night. - } else if (battle_config.night_duration == 0) - if (iMap->night_flag == 1) { // we start with night + } else if (battle_config.night_duration == 0) { + if (map->night_flag == 1) { // we start with night timer_data = timer->get(pc->day_timer_tid); sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,timer->gettick())/1000)); // Game time: The game is actualy in night for %s. clif->message(fd, temp); clif->message(fd, msg_txt(234)); // Game time: After, the game will be in permanent daylight. } else clif->message(fd, msg_txt(231)); // Game time: The game is in permanent daylight. - else if (battle_config.day_duration == 0) - if (iMap->night_flag == 0) { // we start with day - timer_data = timer->get(pc->night_timer_tid); - sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,timer->gettick())/1000)); // Game time: The game is actualy in daylight for %s. - clif->message(fd, temp); - clif->message(fd, msg_txt(236)); // Game time: After, the game will be in permanent night. - } else - clif->message(fd, msg_txt(232)); // Game time: The game is in permanent night. - else { - if (iMap->night_flag == 0) { - timer_data = timer->get(pc->night_timer_tid); - timer_data2 = timer->get(pc->day_timer_tid); - sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,timer->gettick())/1000)); // Game time: The game is actualy in daylight for %s. - clif->message(fd, temp); - if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0) - sprintf(temp, msg_txt(237), txt_time(DIFF_TICK(timer_data->interval,DIFF_TICK(timer_data->tick,timer_data2->tick)) / 1000)); // Game time: After, the game will be in night for %s. - else - sprintf(temp, msg_txt(237), txt_time(DIFF_TICK(timer_data2->tick,timer_data->tick)/1000)); // Game time: After, the game will be in night for %s. - clif->message(fd, temp); - sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s. - clif->message(fd, temp); - } else { - timer_data = timer->get(pc->day_timer_tid); - timer_data2 = timer->get(pc->night_timer_tid); - sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,timer->gettick()) / 1000)); // Game time: The game is actualy in night for %s. - clif->message(fd, temp); - if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0) - sprintf(temp, msg_txt(239), txt_time((timer_data->interval - DIFF_TICK(timer_data->tick, timer_data2->tick)) / 1000)); // Game time: After, the game will be in daylight for %s. - else - sprintf(temp, msg_txt(239), txt_time(DIFF_TICK(timer_data2->tick, timer_data->tick) / 1000)); // Game time: After, the game will be in daylight for %s. - clif->message(fd, temp); - sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s. - clif->message(fd, temp); - } - } + } else if (battle_config.day_duration == 0) { + if (map->night_flag == 0) { // we start with day + timer_data = timer->get(pc->night_timer_tid); + sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,timer->gettick())/1000)); // Game time: The game is actualy in daylight for %s. + clif->message(fd, temp); + clif->message(fd, msg_txt(236)); // Game time: After, the game will be in permanent night. + } else + clif->message(fd, msg_txt(232)); // Game time: The game is in permanent night. + } else { + if (map->night_flag == 0) { + timer_data = timer->get(pc->night_timer_tid); + timer_data2 = timer->get(pc->day_timer_tid); + sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,timer->gettick())/1000)); // Game time: The game is actualy in daylight for %s. + clif->message(fd, temp); + if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0) + sprintf(temp, msg_txt(237), txt_time(DIFF_TICK(timer_data->interval,DIFF_TICK(timer_data->tick,timer_data2->tick)) / 1000)); // Game time: After, the game will be in night for %s. + else + sprintf(temp, msg_txt(237), txt_time(DIFF_TICK(timer_data2->tick,timer_data->tick)/1000)); // Game time: After, the game will be in night for %s. + clif->message(fd, temp); + } else { + timer_data = timer->get(pc->day_timer_tid); + timer_data2 = timer->get(pc->night_timer_tid); + sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,timer->gettick()) / 1000)); // Game time: The game is actualy in night for %s. + clif->message(fd, temp); + if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0) + sprintf(temp, msg_txt(239), txt_time((timer_data->interval - DIFF_TICK(timer_data->tick, timer_data2->tick)) / 1000)); // Game time: After, the game will be in daylight for %s. + else + sprintf(temp, msg_txt(239), txt_time(DIFF_TICK(timer_data2->tick, timer_data->tick) / 1000)); // Game time: After, the game will be in daylight for %s. + clif->message(fd, temp); + } + sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s. + clif->message(fd, temp); + } return true; } //Added by Coltaro -//We're using this function here instead of using time_t so that it only counts player's jail time when he/she's online (and since the idea is to reduce the amount of minutes one by one in iStatus->change_timer...). +//We're using this function here instead of using time_t so that it only counts player's jail time when he/she's online (and since the idea is to reduce the amount of minutes one by one in status->change_timer...). //Well, using time_t could still work but for some reason that looks like more coding x_x -static void get_jail_time(int jailtime, int* year, int* month, int* day, int* hour, int* minute) +void get_jail_time(int jailtime, int* year, int* month, int* day, int* hour, int* minute) { const int factor_year = 518400; //12*30*24*60 = 518400 const int factor_month = 43200; //30*24*60 = 43200 @@ -4475,8 +4446,7 @@ static void get_jail_time(int jailtime, int* year, int* month, int* day, int* ho * @jail <char_name> by [Yor] * Special warp! No check with nowarp and nowarpto flag *------------------------------------------*/ -ACMD(jail) -{ +ACMD(jail) { struct map_session_data *pl_sd; int x, y; unsigned short m_index; @@ -4489,7 +4459,7 @@ ACMD(jail) return false; } - if ((pl_sd = iMap->nick2sd(atcmd_player_name)) == NULL) { + if ((pl_sd = map->nick2sd(atcmd_player_name)) == NULL) { clif->message(fd, msg_txt(3)); // Character not found. return false; } @@ -4530,8 +4500,7 @@ ACMD(jail) * @unjail/@discharge <char_name> by [Yor] * Special warp! No check with nowarp and nowarpto flag *------------------------------------------*/ -ACMD(unjail) -{ +ACMD(unjail) { struct map_session_data *pl_sd; memset(atcmd_player_name, '\0', sizeof(atcmd_player_name)); @@ -4541,7 +4510,7 @@ ACMD(unjail) return false; } - if ((pl_sd = iMap->nick2sd(atcmd_player_name)) == NULL) { + if ((pl_sd = map->nick2sd(atcmd_player_name)) == NULL) { clif->message(fd, msg_txt(3)); // Character not found. return false; } @@ -4565,8 +4534,7 @@ ACMD(unjail) return true; } -ACMD(jailfor) -{ +ACMD(jailfor) { struct map_session_data *pl_sd = NULL; int year, month, day, hour, minute, value; char * modif_p; @@ -4621,7 +4589,7 @@ ACMD(jailfor) return false; } - if ((pl_sd = iMap->nick2sd(atcmd_player_name)) == NULL) { + if ((pl_sd = map->nick2sd(atcmd_player_name)) == NULL) { clif->message(fd, msg_txt(3)); // Character not found. return false; } @@ -4648,7 +4616,7 @@ ACMD(jailfor) clif->message(pl_sd->fd, msg_txt(120)); // GM has discharge you. clif->message(fd, msg_txt(121)); // Player unjailed } else { - get_jail_time(jailtime,&year,&month,&day,&hour,&minute); + atcommand->get_jail_time(jailtime,&year,&month,&day,&hour,&minute); sprintf(atcmd_output,msg_txt(402),msg_txt(1137),year,month,day,hour,minute); //%s in jail for %d years, %d months, %d days, %d hours and %d minutes clif->message(pl_sd->fd, atcmd_output); sprintf(atcmd_output,msg_txt(402),msg_txt(1138),year,month,day,hour,minute); //This player is now in jail for %d years, %d months, %d days, %d hours and %d minutes @@ -4672,7 +4640,7 @@ ACMD(jailfor) break; } - sc_start4(&pl_sd->bl,SC_JAILED,100,jailtime,m_index,x,y,jailtime?60000:1000); //jailtime = 0: Time was reset to 0. Wait 1 second to warp player out (since it's done in iStatus->change_timer). + sc_start4(&pl_sd->bl,SC_JAILED,100,jailtime,m_index,x,y,jailtime?60000:1000); //jailtime = 0: Time was reset to 0. Wait 1 second to warp player out (since it's done in status->change_timer). return true; } @@ -4700,7 +4668,7 @@ ACMD(jailtime) } //Get remaining jail time - get_jail_time(sd->sc.data[SC_JAILED]->val1,&year,&month,&day,&hour,&minute); + atcommand->get_jail_time(sd->sc.data[SC_JAILED]->val1,&year,&month,&day,&hour,&minute); sprintf(atcmd_output,msg_txt(402),msg_txt(1142),year,month,day,hour,minute); // You will remain in jail for %d years, %d months, %d days, %d hours and %d minutes clif->message(fd, atcmd_output); @@ -5041,8 +5009,7 @@ ACMD(killer) * @killable by MouseJstr * enable other people killing you *------------------------------------------*/ -ACMD(killable) -{ +ACMD(killable) { nullpo_retr(-1, sd); sd->state.killable = !sd->state.killable; @@ -5050,7 +5017,7 @@ ACMD(killable) clif->message(fd, msg_txt(242)); else { clif->message(fd, msg_txt(288)); - iMap->foreachinrange(atcommand_stopattack,&sd->bl, AREA_SIZE, BL_CHAR, sd->bl.id); + map->foreachinrange(atcommand->stopattack,&sd->bl, AREA_SIZE, BL_CHAR, sd->bl.id); } return true; } @@ -5081,8 +5048,7 @@ ACMD(skilloff) { * @npcmove by MouseJstr * move a npc *------------------------------------------*/ -ACMD(npcmove) -{ +ACMD(npcmove) { int x = 0, y = 0, m; struct npc_data *nd = 0; nullpo_retr(-1, sd); @@ -5093,23 +5059,21 @@ ACMD(npcmove) return false; } - if ((nd = npc->name2id(atcmd_player_name)) == NULL) - { + if ((nd = npc->name2id(atcmd_player_name)) == NULL) { clif->message(fd, msg_txt(111)); // This NPC doesn't exist. return false; } - if ((m=nd->bl.m) < 0 || nd->bl.prev == NULL) - { + if ((m=nd->bl.m) < 0 || nd->bl.prev == NULL) { clif->message(fd, msg_txt(1154)); // NPC is not on this map. return false; //Not on a map. } 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); + map->foreachinrange(clif->outsight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl); + map->moveblock(&nd->bl, x, y, timer->gettick()); + map->foreachinrange(clif->insight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl); clif->message(fd, msg_txt(1155)); // NPC moved. return true; @@ -5155,8 +5119,7 @@ ACMD(addwarp) * @follow by [MouseJstr] * Follow a player .. staying no more then 5 spaces away *------------------------------------------*/ -ACMD(follow) -{ +ACMD(follow) { struct map_session_data *pl_sd = NULL; nullpo_retr(-1, sd); @@ -5169,7 +5132,7 @@ ACMD(follow) return true; } - if ( (pl_sd = iMap->nick2sd((char *)message)) == NULL ) + if ( (pl_sd = map->nick2sd((char *)message)) == NULL ) { clif->message(fd, msg_txt(3)); // Character not found. return false; @@ -5343,15 +5306,15 @@ ACMD(skillid) { skillen = strlen(message); - iter = db_iterator(skilldb_name2id); + iter = db_iterator(skill->name2id_db); for( data = iter->first(iter,&key); iter->exists(iter); data = iter->next(iter,&key) ) { idx = skill->get_index(DB->data2i(data)); - if (strnicmp(key.str, message, skillen) == 0 || strnicmp(skill_db[idx].desc, message, skillen) == 0) { - sprintf(atcmd_output, msg_txt(1164), DB->data2i(data), skill_db[idx].desc, key.str); // skill %d: %s (%s) + if (strnicmp(key.str, message, skillen) == 0 || strnicmp(skill->db[idx].desc, message, skillen) == 0) { + sprintf(atcmd_output, msg_txt(1164), DB->data2i(data), skill->db[idx].desc, key.str); // skill %d: %s (%s) clif->message(fd, atcmd_output); - } else if ( found < MAX_SKILLID_PARTIAL_RESULTS && ( stristr(key.str,message) || stristr(skill_db[idx].desc,message) ) ) { - snprintf(partials[found++], MAX_SKILLID_PARTIAL_RESULTS_LEN, msg_txt(1164), DB->data2i(data), skill_db[idx].desc, key.str); + } else if ( found < MAX_SKILLID_PARTIAL_RESULTS && ( stristr(key.str,message) || stristr(skill->db[idx].desc,message) ) ) { + snprintf(partials[found++], MAX_SKILLID_PARTIAL_RESULTS_LEN, msg_txt(1164), DB->data2i(data), skill->db[idx].desc, key.str); } } @@ -5373,8 +5336,7 @@ ACMD(skillid) { * @useskill by [MouseJstr] * A way of using skills without having to find them in the skills menu *------------------------------------------*/ -ACMD(useskill) -{ +ACMD(useskill) { struct map_session_data *pl_sd = NULL; struct block_list *bl; uint16 skill_id; @@ -5387,8 +5349,9 @@ ACMD(useskill) return false; } - if(!strcmp(target,"self")) pl_sd = sd; //quick keyword - else if ( (pl_sd = iMap->nick2sd(target)) == NULL ){ + if(!strcmp(target,"self")) + pl_sd = sd; //quick keyword + else if ( (pl_sd = map->nick2sd(target)) == NULL ) { clif->message(fd, msg_txt(3)); // Character not found. return false; } @@ -5425,12 +5388,11 @@ ACMD(displayskill) { uint16 skill_lv = 1; nullpo_retr(-1, sd); - if (!message || !*message || sscanf(message, "%hu %hu", &skill_id, &skill_lv) < 1) - { + if (!message || !*message || sscanf(message, "%hu %hu", &skill_id, &skill_lv) < 1) { clif->message(fd, msg_txt(1166)); // Usage: @displayskill <skill ID> {<skill level>} return false; } - st = iStatus->get_status_data(&sd->bl); + st = status->get_status_data(&sd->bl); tick = timer->gettick(); clif->skill_damage(&sd->bl,&sd->bl, tick, st->amotion, st->dmotion, 1, 1, skill_id, skill_lv, 5); clif->skill_nodamage(&sd->bl, &sd->bl, skill_id, skill_lv, 1); @@ -5442,8 +5404,7 @@ ACMD(displayskill) { * @skilltree by [MouseJstr] * prints the skill tree for a player required to get to a skill *------------------------------------------*/ -ACMD(skilltree) -{ +ACMD(skilltree) { struct map_session_data *pl_sd = NULL; uint16 skill_id; int meets, j, c=0; @@ -5456,8 +5417,7 @@ ACMD(skilltree) return false; } - if ( (pl_sd = iMap->nick2sd(target)) == NULL ) - { + if ( (pl_sd = map->nick2sd(target)) == NULL ) { clif->message(fd, msg_txt(3)); // Character not found. return false; } @@ -5482,7 +5442,7 @@ ACMD(skilltree) { if( ent->need[j].id && pc->checkskill(sd,ent->need[j].id) < ent->need[j].lv) { - sprintf(atcmd_output, msg_txt(1170), ent->need[j].lv, skill_db[ent->need[j].id].desc); // Player requires level %d of skill %s. + sprintf(atcmd_output, msg_txt(1170), ent->need[j].lv, skill->db[ent->need[j].id].desc); // Player requires level %d of skill %s. clif->message(fd, atcmd_output); meets = 0; } @@ -5495,8 +5455,7 @@ ACMD(skilltree) } // Hand a ring with partners name on it to this char -void getring (struct map_session_data* sd) -{ +void getring(struct map_session_data* sd) { int flag, item_id; struct item item_tmp; item_id = (sd->status.sex) ? WEDDING_RING_M : WEDDING_RING_F; @@ -5510,7 +5469,7 @@ void getring (struct map_session_data* sd) if((flag = pc->additem(sd,&item_tmp,1,LOG_TYPE_COMMAND))) { clif->additem(sd,0,0,flag); - iMap->addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); + map->addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); } } @@ -5518,8 +5477,7 @@ void getring (struct map_session_data* sd) * @marry by [MouseJstr], fixed by Lupus * Marry two players *------------------------------------------*/ -ACMD(marry) -{ +ACMD(marry) { struct map_session_data *pl_sd = NULL; char player_name[NAME_LENGTH] = ""; @@ -5530,7 +5488,7 @@ ACMD(marry) return false; } - if ((pl_sd = iMap->nick2sd(player_name)) == NULL) { + if ((pl_sd = map->nick2sd(player_name)) == NULL) { clif->message(fd, msg_txt(3)); return false; } @@ -5617,7 +5575,7 @@ ACMD(autotrade) { sd->state.autotrade = 1; if( battle_config.at_timeout ) { int timeout = atoi(message); - iStatus->change_start(&sd->bl, SC_AUTOTRADE, 10000, 0, 0, 0, 0, ((timeout > 0) ? min(timeout,battle_config.at_timeout) : battle_config.at_timeout) * 60000, 0); + status->change_start(&sd->bl, SC_AUTOTRADE, 10000, 0, 0, 0, 0, ((timeout > 0) ? min(timeout,battle_config.at_timeout) : battle_config.at_timeout) * 60000, 0); } clif->chsys_quit(sd); @@ -5631,8 +5589,7 @@ ACMD(autotrade) { * @changegm by durf (changed by Lupus) * Changes Master of your Guild to a specified guild member *------------------------------------------*/ -ACMD(changegm) -{ +ACMD(changegm) { struct guild *g; struct map_session_data *pl_sd; nullpo_retr(-1, sd); @@ -5652,7 +5609,7 @@ ACMD(changegm) return false; } - if((pl_sd=iMap->nick2sd((char *) message)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) { + if((pl_sd=map->nick2sd((char *) message)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) { clif->message(fd, msg_txt(1184)); // Target character must be online and be a guild member. return false; } @@ -5665,17 +5622,15 @@ ACMD(changegm) * @changeleader by Skotlex * Changes the leader of a party. *------------------------------------------*/ -ACMD(changeleader) -{ +ACMD(changeleader) { nullpo_retr(-1, sd); - if( !message[0] ) - { + if( !message[0] ) { clif->message(fd, msg_txt(1185)); // Usage: @changeleader <party_member_name> return false; } - if (party->changeleader(sd, iMap->nick2sd((char *) message))) + if (party->changeleader(sd, map->nick2sd((char *) message))) return true; return false; } @@ -6099,33 +6054,28 @@ ACMD(mobsearch) * @cleanmap - cleans items on the ground * @cleanarea - cleans items on the ground within an specified area *------------------------------------------*/ -static int atcommand_cleanfloor_sub(struct block_list *bl, va_list ap) -{ +int atcommand_cleanfloor_sub(struct block_list *bl, va_list ap) { nullpo_ret(bl); - iMap->clearflooritem(bl); + map->clearflooritem(bl); return 0; } -ACMD(cleanmap) -{ - iMap->foreachinmap(atcommand_cleanfloor_sub, sd->bl.m, BL_ITEM); +ACMD(cleanmap) { + map->foreachinmap(atcommand->cleanfloor_sub, sd->bl.m, BL_ITEM); clif->message(fd, msg_txt(1221)); // All dropped items have been cleaned up. return true; } -ACMD(cleanarea) -{ +ACMD(cleanarea) { int x0 = 0, y0 = 0, x1 = 0, y1 = 0; if (!message || !*message || sscanf(message, "%d %d %d %d", &x0, &y0, &x1, &y1) < 1) { - iMap->foreachinrange(atcommand_cleanfloor_sub, &sd->bl, AREA_SIZE * 2, BL_ITEM); - } - else if (sscanf(message, "%d %d %d %d", &x0, &y0, &x1, &y1) == 1) { - iMap->foreachinrange(atcommand_cleanfloor_sub, &sd->bl, x0, BL_ITEM); - } - else if (sscanf(message, "%d %d %d %d", &x0, &y0, &x1, &y1) == 4) { - iMap->foreachinarea(atcommand_cleanfloor_sub, sd->bl.m, x0, y0, x1, y1, BL_ITEM); + map->foreachinrange(atcommand->cleanfloor_sub, &sd->bl, AREA_SIZE * 2, BL_ITEM); + } else if (sscanf(message, "%d %d %d %d", &x0, &y0, &x1, &y1) == 1) { + map->foreachinrange(atcommand->cleanfloor_sub, &sd->bl, x0, BL_ITEM); + } else if (sscanf(message, "%d %d %d %d", &x0, &y0, &x1, &y1) == 4) { + map->foreachinarea(atcommand->cleanfloor_sub, sd->bl.m, x0, y0, x1, y1, BL_ITEM); } clif->message(fd, msg_txt(1221)); // All dropped items have been cleaned up. @@ -6375,8 +6325,7 @@ ACMD(adjgroup) * @trade by [MouseJstr] * Open a trade window with a remote player *------------------------------------------*/ -ACMD(trade) -{ +ACMD(trade) { struct map_session_data *pl_sd = NULL; nullpo_retr(-1, sd); @@ -6385,8 +6334,7 @@ ACMD(trade) return false; } - if ( (pl_sd = iMap->nick2sd((char *)message)) == NULL ) - { + if ( (pl_sd = map->nick2sd((char *)message)) == NULL ) { clif->message(fd, msg_txt(3)); // Character not found. return false; } @@ -6422,8 +6370,7 @@ ACMD(setbattleflag) /*========================================== * @unmute [Valaris] *------------------------------------------*/ -ACMD(unmute) -{ +ACMD(unmute) { struct map_session_data *pl_sd = NULL; nullpo_retr(-1, sd); @@ -6432,7 +6379,7 @@ ACMD(unmute) return false; } - if ( (pl_sd = iMap->nick2sd((char *)message)) == NULL ) + if ( (pl_sd = map->nick2sd((char *)message)) == NULL ) { clif->message(fd, msg_txt(3)); // Character not found. return false; @@ -6492,8 +6439,7 @@ ACMD(changesex) /*================================================ * @mute - Mutes a player for a set amount of time *------------------------------------------------*/ -ACMD(mute) -{ +ACMD(mute) { struct map_session_data *pl_sd = NULL; int manner; nullpo_retr(-1, sd); @@ -6503,8 +6449,7 @@ ACMD(mute) return false; } - if ( (pl_sd = iMap->nick2sd(atcmd_player_name)) == NULL ) - { + if ( (pl_sd = map->nick2sd(atcmd_player_name)) == NULL ) { clif->message(fd, msg_txt(3)); // Character not found. return false; } @@ -7050,7 +6995,7 @@ ACMD(hominfo) { } hd = sd->hd; - st = iStatus->get_status_data(&hd->bl); + st = status->get_status_data(&hd->bl); clif->message(fd, msg_txt(1261)); // Homunculus stats: snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1262), // HP: %d/%d - SP: %d/%d @@ -7291,7 +7236,7 @@ ACMD(whereis) clif->message(fd, atcmd_output); for (i = 0; i < ARRAYLENGTH(monster->spawn) && monster->spawn[i].qty; i++) { - j = iMap->mapindex2mapid(monster->spawn[i].mapindex); + j = map->mapindex2mapid(monster->spawn[i].mapindex); if (j < 0) continue; snprintf(atcmd_output, sizeof atcmd_output, "%s (%d)", maplist[j].name, monster->spawn[i].qty); clif->message(fd, atcmd_output); @@ -7322,7 +7267,7 @@ ACMD(version) { /*========================================== * @mutearea by MouseJstr *------------------------------------------*/ -static int atcommand_mutearea_sub(struct block_list *bl,va_list ap) +int atcommand_mutearea_sub(struct block_list *bl,va_list ap) { int time, id; @@ -7343,8 +7288,7 @@ static int atcommand_mutearea_sub(struct block_list *bl,va_list ap) return 0; } -ACMD(mutearea) -{ +ACMD(mutearea) { int time; nullpo_ret(sd); @@ -7355,9 +7299,9 @@ ACMD(mutearea) time = atoi(message); - iMap->foreachinarea(atcommand_mutearea_sub,sd->bl.m, - sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE, - sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time); + map->foreachinarea(atcommand->mutearea_sub,sd->bl.m, + sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE, + sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time); return true; } @@ -7569,8 +7513,8 @@ ACMD(fakename) * Ragnarok Resources *------------------------------------------*/ ACMD(mapflag) { -#define checkflag( cmd ) if ( maplist[ sd->bl.m ].flag.cmd ) clif->message(sd->fd,#cmd) -#define setflag( cmd ) do {\ +#define CHECKFLAG( cmd ) do { if ( maplist[ sd->bl.m ].flag.cmd ) clif->message(sd->fd,#cmd); } while(0) +#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); \ @@ -7587,19 +7531,19 @@ ACMD(mapflag) { if (!message || !*message || (sscanf(message, "%99s %hd", flag_name, &flag) < 1)) { clif->message(sd->fd,msg_txt(1311)); // Enabled Mapflags in this map: clif->message(sd->fd,"----------------------------------"); - checkflag(autotrade); checkflag(allowks); checkflag(nomemo); checkflag(noteleport); - checkflag(noreturn); checkflag(monster_noteleport); checkflag(nosave); checkflag(nobranch); - checkflag(noexppenalty); checkflag(pvp); checkflag(pvp_noparty); checkflag(pvp_noguild); - checkflag(pvp_nightmaredrop); checkflag(pvp_nocalcrank); checkflag(gvg_castle); checkflag(gvg); - checkflag(gvg_dungeon); checkflag(gvg_noparty); checkflag(battleground);checkflag(nozenypenalty); - checkflag(notrade); checkflag(noskill); checkflag(nowarp); checkflag(nowarpto); - checkflag(noicewall); checkflag(snow); checkflag(clouds); checkflag(clouds2); - checkflag(fog); checkflag(fireworks); checkflag(sakura); checkflag(leaves); - checkflag(nobaseexp); - checkflag(nojobexp); checkflag(nomobloot); checkflag(nomvploot); checkflag(nightenabled); - checkflag(nodrop); checkflag(novending); checkflag(loadevent); - checkflag(nochat); checkflag(partylock); checkflag(guildlock); checkflag(src4instance); - checkflag(notomb); + CHECKFLAG(autotrade); CHECKFLAG(allowks); CHECKFLAG(nomemo); CHECKFLAG(noteleport); + CHECKFLAG(noreturn); CHECKFLAG(monster_noteleport); CHECKFLAG(nosave); CHECKFLAG(nobranch); + CHECKFLAG(noexppenalty); CHECKFLAG(pvp); CHECKFLAG(pvp_noparty); CHECKFLAG(pvp_noguild); + CHECKFLAG(pvp_nightmaredrop); CHECKFLAG(pvp_nocalcrank); CHECKFLAG(gvg_castle); CHECKFLAG(gvg); + CHECKFLAG(gvg_dungeon); CHECKFLAG(gvg_noparty); CHECKFLAG(battleground); CHECKFLAG(nozenypenalty); + CHECKFLAG(notrade); CHECKFLAG(noskill); CHECKFLAG(nowarp); CHECKFLAG(nowarpto); + CHECKFLAG(noicewall); CHECKFLAG(snow); CHECKFLAG(clouds); CHECKFLAG(clouds2); + CHECKFLAG(fog); CHECKFLAG(fireworks); CHECKFLAG(sakura); CHECKFLAG(leaves); + CHECKFLAG(nobaseexp); + CHECKFLAG(nojobexp); CHECKFLAG(nomobloot); CHECKFLAG(nomvploot); CHECKFLAG(nightenabled); + CHECKFLAG(nodrop); CHECKFLAG(novending); CHECKFLAG(loadevent); + CHECKFLAG(nochat); CHECKFLAG(partylock); CHECKFLAG(guildlock); CHECKFLAG(src4instance); + CHECKFLAG(notomb); clif->message(sd->fd," "); clif->message(sd->fd,msg_txt(1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On) clif->message(sd->fd,msg_txt(1313)); // Type "@mapflag available" to list the available mapflags. @@ -7609,34 +7553,34 @@ ACMD(mapflag) { if ( strcmp( flag_name , "gvg" ) == 0 ) { if( flag && !maplist[sd->bl.m].flag.gvg ) - iMap->zone_change2(sd->bl.m,strdb_get(zone_db, MAP_ZONE_GVG_NAME)); + map->zone_change2(sd->bl.m,strdb_get(zone_db, MAP_ZONE_GVG_NAME)); else if ( !flag && maplist[sd->bl.m].flag.gvg ) - iMap->zone_change2(sd->bl.m,maplist[sd->bl.m].prev_zone); + map->zone_change2(sd->bl.m,maplist[sd->bl.m].prev_zone); } else if ( strcmp( flag_name , "pvp" ) == 0 ) { if( flag && !maplist[sd->bl.m].flag.pvp ) - iMap->zone_change2(sd->bl.m,strdb_get(zone_db, MAP_ZONE_PVP_NAME)); + map->zone_change2(sd->bl.m,strdb_get(zone_db, MAP_ZONE_PVP_NAME)); else if ( !flag && maplist[sd->bl.m].flag.pvp ) - iMap->zone_change2(sd->bl.m,maplist[sd->bl.m].prev_zone); + map->zone_change2(sd->bl.m,maplist[sd->bl.m].prev_zone); } else if ( strcmp( flag_name , "battleground" ) == 0 ) { if( flag && !maplist[sd->bl.m].flag.battleground ) - iMap->zone_change2(sd->bl.m,strdb_get(zone_db, MAP_ZONE_BG_NAME)); + map->zone_change2(sd->bl.m,strdb_get(zone_db, MAP_ZONE_BG_NAME)); 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); - setflag(noreturn); setflag(monster_noteleport);setflag(nosave); setflag(nobranch); - setflag(noexppenalty); setflag(pvp); setflag(pvp_noparty); setflag(pvp_noguild); - setflag(pvp_nightmaredrop); setflag(pvp_nocalcrank); setflag(gvg_castle); setflag(gvg); - setflag(gvg_dungeon); setflag(gvg_noparty); setflag(battleground); setflag(nozenypenalty); - setflag(notrade); setflag(noskill); setflag(nowarp); setflag(nowarpto); - setflag(noicewall); setflag(snow); setflag(clouds); setflag(clouds2); - setflag(fog); setflag(fireworks); setflag(sakura); setflag(leaves); - setflag(nobaseexp); - setflag(nojobexp); setflag(nomobloot); setflag(nomvploot); setflag(nightenabled); - setflag(nodrop); setflag(novending); setflag(loadevent); - setflag(nochat); setflag(partylock); setflag(guildlock); setflag(src4instance); - setflag(notomb); + map->zone_change2(sd->bl.m,maplist[sd->bl.m].prev_zone); + } + + SETFLAG(autotrade); SETFLAG(allowks); SETFLAG(nomemo); SETFLAG(noteleport); + SETFLAG(noreturn); SETFLAG(monster_noteleport); SETFLAG(nosave); SETFLAG(nobranch); + SETFLAG(noexppenalty); SETFLAG(pvp); SETFLAG(pvp_noparty); SETFLAG(pvp_noguild); + SETFLAG(pvp_nightmaredrop); SETFLAG(pvp_nocalcrank); SETFLAG(gvg_castle); SETFLAG(gvg); + SETFLAG(gvg_dungeon); SETFLAG(gvg_noparty); SETFLAG(battleground); SETFLAG(nozenypenalty); + SETFLAG(notrade); SETFLAG(noskill); SETFLAG(nowarp); SETFLAG(nowarpto); + SETFLAG(noicewall); SETFLAG(snow); SETFLAG(clouds); SETFLAG(clouds2); + SETFLAG(fog); SETFLAG(fireworks); SETFLAG(sakura); SETFLAG(leaves); + SETFLAG(nobaseexp); + SETFLAG(nojobexp); SETFLAG(nomobloot); SETFLAG(nomvploot); SETFLAG(nightenabled); + SETFLAG(nodrop); SETFLAG(novending); SETFLAG(loadevent); + SETFLAG(nochat); SETFLAG(partylock); SETFLAG(guildlock); SETFLAG(src4instance); + SETFLAG(notomb); clif->message(sd->fd,msg_txt(1314)); // Invalid flag name or flag. clif->message(sd->fd,msg_txt(1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On) @@ -7650,8 +7594,8 @@ ACMD(mapflag) { clif->message(sd->fd,"nomvploot, nightenabled, nodrop, novending, loadevent, nochat, partylock,"); clif->message(sd->fd,"guildlock, src4instance, notomb"); -#undef checkflag -#undef setflag +#undef CHECKFLAG +#undef SETFLAG return true; } @@ -7709,7 +7653,7 @@ ACMD(showdelay) *------------------------------------------*/ ACMD(invite) { unsigned int did = sd->duel_group; - struct map_session_data *target_sd = iMap->nick2sd((char *)message); + struct map_session_data *target_sd = map->nick2sd((char *)message); if(did == 0) { // "Duel: @invite without @duel." @@ -7781,7 +7725,7 @@ ACMD(duel) { duel->create(sd, maxpl); } else { struct map_session_data *target_sd; - target_sd = iMap->nick2sd((char *)message); + target_sd = map->nick2sd((char *)message); if(target_sd != NULL) { unsigned int newduel; if((newduel = duel->create(sd, 2)) != -1) { @@ -7910,8 +7854,7 @@ ACMD(cash) } // @clone/@slaveclone/@evilclone <playername> [Valaris] -ACMD(clone) -{ +ACMD(clone) { int x=0,y=0,flag=0,master=0,i=0; struct map_session_data *pl_sd=NULL; @@ -7920,7 +7863,7 @@ ACMD(clone) return true; } - if((pl_sd=iMap->nick2sd((char *)message)) == NULL && (pl_sd=iMap->charid2sd(atoi(message))) == NULL) { + if((pl_sd=map->nick2sd((char *)message)) == NULL && (pl_sd=map->charid2sd(atoi(message))) == NULL) { clif->message(fd, msg_txt(3)); // Character not found. return true; } @@ -7949,7 +7892,7 @@ ACMD(clone) do { x = sd->bl.x + (rnd() % 10 - 5); y = sd->bl.y + (rnd() % 10 - 5); - } while (iMap->getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10); + } while (map->getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10); if (i >= 10) { x = sd->bl.x; @@ -8408,7 +8351,7 @@ ACMD(font) /*========================================== * type: 1 = commands (@), 2 = charcommands (#) *------------------------------------------*/ -static void atcommand_commands_sub(struct map_session_data* sd, const int fd, AtCommandType type) +void atcommand_commands_sub(struct map_session_data* sd, const int fd, AtCommandType type) { char line_buff[CHATBOX_SIZE]; char* cur = line_buff; @@ -8468,7 +8411,7 @@ static void atcommand_commands_sub(struct map_session_data* sd, const int fd, At *------------------------------------------*/ ACMD(commands) { - atcommand_commands_sub(sd, fd, COMMAND_ATCOMMAND); + atcommand->commands_sub(sd, fd, COMMAND_ATCOMMAND); return true; } @@ -8477,7 +8420,7 @@ ACMD(commands) *------------------------------------------*/ ACMD(charcommands) { - atcommand_commands_sub(sd, fd, COMMAND_CHARCOMMAND); + atcommand->commands_sub(sd, fd, COMMAND_CHARCOMMAND); return true; } /* for new mounts */ @@ -9063,15 +9006,15 @@ ACMD(channel) { } if (!message || !*message || sscanf(message, "%s %s %24[^\n]", key, sub1, sub2) < 1) { - sprintf(atcmd_output, msg_txt(1434), sub2);// Player '%s' was not found - clif->message(fd, atcmd_output); - return false; + sprintf(atcmd_output, msg_txt(1434), sub2);// Player '%s' was not found + clif->message(fd, atcmd_output); + return false; } - if( sub2[0] == '\0' || ( pl_sd = iMap->nick2sd(sub2) ) == NULL ) { - sprintf(atcmd_output, msg_txt(1434), sub2);// Player '%s' was not found - clif->message(fd, atcmd_output); - return false; + if( sub2[0] == '\0' || ( pl_sd = map->nick2sd(sub2) ) == NULL ) { + sprintf(atcmd_output, msg_txt(1434), sub2);// Player '%s' was not found + clif->message(fd, atcmd_output); + return false; } if( pc->has_permission(pl_sd, PC_PERM_HCHSYS_ADMIN) ) { @@ -9124,7 +9067,7 @@ ACMD(channel) { return false; } - if( sub2[0] == '\0' || ( pl_sd = iMap->nick2sd(sub2) ) == NULL ) { + if( sub2[0] == '\0' || ( pl_sd = map->nick2sd(sub2) ) == NULL ) { sprintf(atcmd_output, msg_txt(1434), sub2);// Player '%s' was not found clif->message(fd, atcmd_output); return false; @@ -9750,15 +9693,14 @@ AtCommandInfo* atcommand_exists(const char* name) { return strdb_get(atcommand->db, name); } -static AtCommandInfo* get_atcommandinfo_byname(const char *name) { +AtCommandInfo* get_atcommandinfo_byname(const char *name) { AtCommandInfo *cmd; if ((cmd = strdb_get(atcommand->db, name))) return cmd; return NULL; } -static const char* atcommand_checkalias(const char *aliasname) -{ +const char* atcommand_checkalias(const char *aliasname) { AliasInfo *alias_info = NULL; if ((alias_info = (AliasInfo*)strdb_get(atcommand->alias_db, aliasname)) != NULL) return alias_info->command->command; @@ -9766,7 +9708,7 @@ static const char* atcommand_checkalias(const char *aliasname) } /// AtCommand suggestion -static void atcommand_get_suggestions(struct map_session_data* sd, const char *name, bool is_atcmd_cmd) { +void atcommand_get_suggestions(struct map_session_data* sd, const char *name, bool is_atcmd_cmd) { DBIterator* atcommand_iter; DBIterator* alias_iter; AtCommandInfo* command_info = NULL; @@ -9910,7 +9852,7 @@ bool is_atcommand(const int fd, struct map_session_data* sd, const char* message if( !pc->get_group_level(sd) ) { if( x >= 1 || y >= 1 ) { /* we have command */ - info = get_atcommandinfo_byname(atcommand_checkalias(command + 1)); + info = atcommand->get_info_byname(atcommand->check_alias(command + 1)); if( !info || info->char_groups[pc_group_get_idx(sd->group)] == 0 ) /* if we can't use or doesn't exist: don't even display the command failed message */ return false; } else @@ -9945,16 +9887,21 @@ bool is_atcommand(const int fd, struct map_session_data* sd, const char* message binding = atcommand->get_bind_byname(command); // Check if the binding isn't NULL and there is a NPC event, level of usage met, et cetera - if( binding != NULL && binding->npc_event[0] && - ((*atcmd_msg == atcommand->at_symbol && pc->get_group_level(sd) >= binding->group_lv) || - (*atcmd_msg == atcommand->char_symbol && pc->get_group_level(sd) >= binding->group_lv_char))) - { + if( binding != NULL + && binding->npc_event[0] + && ( + (*atcmd_msg == atcommand->at_symbol && pc->get_group_level(sd) >= binding->group_lv) + || (*atcmd_msg == atcommand->char_symbol && pc->get_group_level(sd) >= binding->group_lv_char) + ) + ) { // Check if self or character invoking; if self == character invoked, then self invoke. bool invokeFlag = ((*atcmd_msg == atcommand->at_symbol) ? 1 : 0); // Check if the command initiated is a character command - if (*message == atcommand->char_symbol && - (ssd = iMap->nick2sd(charname)) == NULL && (ssd = iMap->nick2sd(charname2)) == NULL ) { + if (*message == atcommand->char_symbol + && (ssd = map->nick2sd(charname)) == NULL + && (ssd = map->nick2sd(charname2)) == NULL + ) { sprintf(output, msg_txt(1389), command); // %s failed. Player not found. clif->message(fd, output); return true; @@ -9969,12 +9916,12 @@ bool is_atcommand(const int fd, struct map_session_data* sd, const char* message } //Grab the command information and check for the proper GM level required to use it or if the command exists - info = get_atcommandinfo_byname(atcommand_checkalias(command + 1)); + info = atcommand->get_info_byname(atcommand->check_alias(command + 1)); if (info == NULL) { if( pc->get_group_level(sd) ) { // TODO: remove or replace with proper permission sprintf(output, msg_txt(153), command); // "%s is Unknown Command." clif->message(fd, output); - atcommand_get_suggestions(sd, command + 1, *message == atcommand->at_symbol); + atcommand->get_suggestions(sd, command + 1, *message == atcommand->at_symbol); return true; } else return false; @@ -10003,8 +9950,10 @@ bool is_atcommand(const int fd, struct map_session_data* sd, const char* message } // Check if target is valid only if confirmed that player can use command. - if (*message == atcommand->char_symbol && - (ssd = iMap->nick2sd(charname)) == NULL && (ssd = iMap->nick2sd(charname2)) == NULL ) { + if (*message == atcommand->char_symbol + && (ssd = map->nick2sd(charname)) == NULL + && (ssd = map->nick2sd(charname2)) == NULL + ) { sprintf(output, msg_txt(1389), command); // %s failed. Player not found. clif->message(fd, output); return true; @@ -10026,7 +9975,7 @@ bool is_atcommand(const int fd, struct map_session_data* sd, const char* message /*========================================== * *------------------------------------------*/ -static void atcommand_config_read(const char* config_filename) { +void atcommand_config_read(const char* config_filename) { config_t atcommand_config; config_setting_t *aliases = NULL, *help = NULL, *nolog = NULL; const char *symbol = NULL; @@ -10219,7 +10168,7 @@ void atcommand_db_load_groups(GroupSettings **groups, config_setting_t **command } bool atcommand_can_use(struct map_session_data *sd, const char *command) { - AtCommandInfo *info = get_atcommandinfo_byname(atcommand_checkalias(command + 1)); + AtCommandInfo *info = atcommand->get_info_byname(atcommand->check_alias(command + 1)); if (info == NULL) return false; @@ -10232,7 +10181,7 @@ bool atcommand_can_use(struct map_session_data *sd, const char *command) { return false; } bool atcommand_can_use2(struct map_session_data *sd, const char *command, AtCommandType type) { - AtCommandInfo *info = get_atcommandinfo_byname(atcommand_checkalias(command)); + AtCommandInfo *info = atcommand->get_info_byname(atcommand->check_alias(command)); if (info == NULL) return false; @@ -10274,7 +10223,7 @@ bool atcommand_hp_add(char *name, AtCommandFunc func) { /** * @see DBApply */ -static int atcommand_db_clear_sub(DBKey key, DBData *data, va_list args) { +int atcommand_db_clear_sub(DBKey key, DBData *data, va_list args) { AtCommandInfo *cmd = DB->data2ptr(data); aFree(cmd->at_groups); aFree(cmd->char_groups); @@ -10285,7 +10234,7 @@ static int atcommand_db_clear_sub(DBKey key, DBData *data, va_list args) { void atcommand_db_clear(void) { if( atcommand->db != NULL ) { - atcommand->db->destroy(atcommand->db, atcommand_db_clear_sub); + atcommand->db->destroy(atcommand->db, atcommand->cmd_db_clear_sub); atcommand->db = NULL; } if( atcommand->alias_db != NULL ) { @@ -10296,13 +10245,13 @@ void atcommand_db_clear(void) { void atcommand_doload(void) { if( runflag >= MAPSERVER_ST_RUNNING ) - atcommand_db_clear(); + atcommand->cmd_db_clear(); if( atcommand->db == NULL ) atcommand->db = stridb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, ATCOMMAND_LENGTH); if( atcommand->alias_db == NULL ) atcommand->alias_db = stridb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, ATCOMMAND_LENGTH); - atcommand_basecommands(); //fills initial atcommand_db with known commands - atcommand_config_read(iMap->ATCOMMAND_CONF_FILENAME); + atcommand->base_commands(); //fills initial atcommand_db with known commands + atcommand->config_read(map->ATCOMMAND_CONF_FILENAME); } void do_init_atcommand(void) { @@ -10310,11 +10259,11 @@ void do_init_atcommand(void) { atcommand->char_symbol = '#'; atcommand->binding_count = 0; - atcommand_doload(); + atcommand->doload(); } void do_final_atcommand(void) { - atcommand_db_clear(); + atcommand->cmd_db_clear(); } void atcommand_defaults(void) { @@ -10323,6 +10272,8 @@ void atcommand_defaults(void) { atcommand->db = NULL; atcommand->alias_db = NULL; + memset(atcommand->msg_table, 0, sizeof(atcommand->msg_table)); + atcommand->init = do_init_atcommand; atcommand->final = do_final_atcommand; @@ -10335,4 +10286,21 @@ void atcommand_defaults(void) { atcommand->msg_read = msg_config_read; atcommand->final_msg = do_final_msg; atcommand->get_bind_byname = get_atcommandbind_byname; + atcommand->get_info_byname = get_atcommandinfo_byname; + atcommand->check_alias = atcommand_checkalias; + atcommand->get_suggestions = atcommand_get_suggestions; + atcommand->config_read = atcommand_config_read; + atcommand->stopattack = atcommand_stopattack; + atcommand->pvpoff_sub = atcommand_pvpoff_sub; + atcommand->pvpon_sub = atcommand_pvpon_sub; + atcommand->atkillmonster_sub = atkillmonster_sub; + atcommand->raise_sub = atcommand_raise_sub; + atcommand->get_jail_time = get_jail_time; + atcommand->cleanfloor_sub = atcommand_cleanfloor_sub; + atcommand->mutearea_sub = atcommand_mutearea_sub; + atcommand->commands_sub = atcommand_commands_sub; + atcommand->cmd_db_clear = atcommand_db_clear; + atcommand->cmd_db_clear_sub = atcommand_db_clear_sub; + atcommand->doload = atcommand_doload; + atcommand->base_commands = atcommand_basecommands; } diff --git a/src/map/atcommand.h b/src/map/atcommand.h index ad191a014..603abc0cc 100644 --- a/src/map/atcommand.h +++ b/src/map/atcommand.h @@ -14,6 +14,7 @@ **/ struct map_session_data; struct AtCommandInfo; +struct block_list; /** * Defines @@ -74,6 +75,8 @@ struct atcommand_interface { DBMap* db; //name -> AtCommandInfo DBMap* alias_db; //alias -> AtCommandInfo /* */ + char* msg_table[MAX_MSG]; // Server messages (0-499 reserved for GM commands, 500-999 reserved for others) + /* */ void (*init) (void); void (*final) (void); /* */ @@ -87,12 +90,35 @@ struct atcommand_interface { void (*final_msg) (void); /* atcommand binding */ struct atcmd_binding_data* (*get_bind_byname) (const char* name); + /* */ + AtCommandInfo* (*get_info_byname) (const char *name); // @help + const char* (*check_alias) (const char *aliasname); // @help + void (*get_suggestions) (struct map_session_data* sd, const char *name, bool is_atcmd_cmd); // @help + void (*config_read) (const char* config_filename); + /* command-specific subs */ + int (*stopattack) (struct block_list *bl,va_list ap); + int (*pvpoff_sub) (struct block_list *bl,va_list ap); + int (*pvpon_sub) (struct block_list *bl,va_list ap); + int (*atkillmonster_sub) (struct block_list *bl, va_list ap); + void (*raise_sub) (struct map_session_data* sd); + void (*get_jail_time) (int jailtime, int* year, int* month, int* day, int* hour, int* minute); + int (*cleanfloor_sub) (struct block_list *bl, va_list ap); + int (*mutearea_sub) (struct block_list *bl,va_list ap); + /* */ + void (*commands_sub) (struct map_session_data* sd, const int fd, AtCommandType type); + void (*cmd_db_clear) (void); + int (*cmd_db_clear_sub) (DBKey key, DBData *data, va_list args); + void (*doload) (void); + void (*base_commands) (void); }; struct atcommand_interface *atcommand; +/* will remain outside for a while, we have plans for this little fellow */ const char* msg_txt(int msg_number); + void atcommand_defaults(void); + /* stay here */ #define ACMD(x) static bool atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message, struct AtCommandInfo *info) #define ACMD_A(x) atcommand_ ## x diff --git a/src/map/battle.c b/src/map/battle.c index 54716bd32..98e132077 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -36,11 +36,8 @@ #include <string.h> #include <math.h> -int attr_fix_table[4][ELE_MAX][ELE_MAX]; - struct Battle_Config battle_config; struct battle_interface battle_s; -static struct eri *delay_damage_ers; //For battle delay damage structures. int battle_getcurrentskill(struct block_list *bl) { //Returns the current/last skill in use by this bl. struct unit_data *ud; @@ -91,7 +88,7 @@ struct block_list* battle_gettargeted(struct block_list *target) { nullpo_retr(NULL, target); memset(bl_list, 0, sizeof(bl_list)); - iMap->foreachinrange(battle->get_targeted_sub, target, AREA_SIZE, BL_CHAR, bl_list, &c, target->id); + map->foreachinrange(battle->get_targeted_sub, target, AREA_SIZE, BL_CHAR, bl_list, &c, target->id); if ( c == 0 ) return NULL; if( c > 24 ) @@ -130,7 +127,7 @@ int battle_getenemy_sub(struct block_list *bl, va_list ap) { if (*c >= 24) return 0; - if (iStatus->isdead(bl)) + if (status->isdead(bl)) return 0; if (battle->check_target(target, bl, BCT_ENEMY) > 0) { @@ -147,7 +144,7 @@ struct block_list* battle_getenemy(struct block_list *target, int type, int rang int c = 0; memset(bl_list, 0, sizeof(bl_list)); - iMap->foreachinrange(battle->get_enemy_sub, target, range, type, bl_list, &c, target); + map->foreachinrange(battle->get_enemy_sub, target, range, type, bl_list, &c, target); if ( c == 0 ) return NULL; @@ -172,7 +169,7 @@ int battle_getenemyarea_sub(struct block_list *bl, va_list ap) { if( *c >= 23 ) return 0; - if( iStatus->isdead(bl) ) + if( status->isdead(bl) ) return 0; if( battle->check_target(src, bl, BCT_ENEMY) > 0 ) {// Is Enemy!... @@ -189,7 +186,7 @@ struct block_list* battle_getenemyarea(struct block_list *src, int x, int y, int int c = 0; memset(bl_list, 0, sizeof(bl_list)); - iMap->foreachinarea(battle->get_enemy_area_sub, src->m, x - range, y - range, x + range, y + range, type, bl_list, &c, src, ignore_id); + map->foreachinarea(battle->get_enemy_area_sub, src->m, x - range, y - range, x + range, y + range, type, bl_list, &c, src, ignore_id); if( c == 0 ) return NULL; @@ -199,57 +196,43 @@ struct block_list* battle_getenemyarea(struct block_list *src, int x, int y, int return bl_list[rnd()%c]; } -// Dammage delayed info -struct delay_damage { - int src_id; - int target_id; - int64 damage; - int delay; - unsigned short distance; - uint16 skill_lv; - uint16 skill_id; - enum damage_lv dmg_lv; - unsigned short attack_type; - bool additional_effects; - enum bl_type src_type; -}; - int battle_delay_damage_sub(int tid, unsigned int tick, int id, intptr_t data) { struct delay_damage *dat = (struct delay_damage *)data; if ( dat ) { struct block_list* src = NULL; - struct block_list* target = iMap->id2bl(dat->target_id); + struct block_list* target = map->id2bl(dat->target_id); - if( !target || iStatus->isdead(target) ) {/* nothing we can do */ - if( dat->src_type == BL_PC && ( src = iMap->id2bl(dat->src_id) ) && --((TBL_PC*)src)->delayed_damage == 0 && ((TBL_PC*)src)->state.hold_recalc ) { + if( !target || status->isdead(target) ) {/* nothing we can do */ + if( dat->src_type == BL_PC && ( src = map->id2bl(dat->src_id) ) && --((TBL_PC*)src)->delayed_damage == 0 && ((TBL_PC*)src)->state.hold_recalc ) { ((TBL_PC*)src)->state.hold_recalc = 0; status_calc_pc(((TBL_PC*)src),0); } - ers_free(delay_damage_ers, dat); + ers_free(battle->delay_damage_ers, dat); return 0; } - src = iMap->id2bl(dat->src_id); + src = map->id2bl(dat->src_id); - if( src && target->m == src->m && - (target->type != BL_PC || ((TBL_PC*)target)->invincible_timer == INVALID_TIMER) && - check_distance_bl(src, target, dat->distance) ) //Check to see if you haven't teleported. [Skotlex] - { - iMap->freeblock_lock(); + //Check to see if you haven't teleported. [Skotlex] + if( src && target->m == src->m + && (target->type != BL_PC || ((TBL_PC*)target)->invincible_timer == INVALID_TIMER) + && check_distance_bl(src, target, dat->distance) + ) { + map->freeblock_lock(); status_fix_damage(src, target, dat->damage, dat->delay); - if( dat->attack_type && !iStatus->isdead(target) && dat->additional_effects ) + if( dat->attack_type && !status->isdead(target) && dat->additional_effects ) skill->additional_effect(src,target,dat->skill_id,dat->skill_lv,dat->attack_type,dat->dmg_lv,tick); if( dat->dmg_lv > ATK_BLOCK && dat->attack_type ) skill->counter_additional_effect(src,target,dat->skill_id,dat->skill_lv,dat->attack_type,tick); - iMap->freeblock_unlock(); + map->freeblock_unlock(); } else if( !src && dat->skill_id == CR_REFLECTSHIELD ) { /** * it was monster reflected damage, and the monster died, we pass the damage to the character as expected **/ - iMap->freeblock_lock(); + map->freeblock_lock(); status_fix_damage(target, target, dat->damage, dat->delay); - iMap->freeblock_unlock(); + map->freeblock_unlock(); } if( src && src->type == BL_PC && --((TBL_PC*)src)->delayed_damage == 0 && ((TBL_PC*)src)->state.hold_recalc ) { @@ -257,33 +240,32 @@ int battle_delay_damage_sub(int tid, unsigned int tick, int id, intptr_t data) { status_calc_pc(((TBL_PC*)src),0); } } - ers_free(delay_damage_ers, dat); + ers_free(battle->delay_damage_ers, dat); return 0; } -int battle_delay_damage (unsigned int tick, int amotion, struct block_list *src, struct block_list *target, int attack_type, uint16 skill_id, uint16 skill_lv, int64 damage, enum damage_lv dmg_lv, int ddelay, bool additional_effects) -{ +int battle_delay_damage (unsigned int tick, int amotion, struct block_list *src, struct block_list *target, int attack_type, uint16 skill_id, uint16 skill_lv, int64 damage, enum damage_lv dmg_lv, int ddelay, bool additional_effects) { struct delay_damage *dat; struct status_change *sc; nullpo_ret(src); nullpo_ret(target); - sc = iStatus->get_sc(target); + sc = status->get_sc(target); if( sc && sc->data[SC_DEVOTION] && damage > 0 && skill_id != PA_PRESSURE && skill_id != CR_REFLECTSHIELD ) damage = 0; if ( !battle_config.delay_battle_damage || amotion <= 1 ) { - iMap->freeblock_lock(); + map->freeblock_lock(); status_fix_damage(src, target, damage, ddelay); // We have to seperate here between reflect damage and others [icescope] - if( attack_type && !iStatus->isdead(target) && additional_effects ) + if( attack_type && !status->isdead(target) && additional_effects ) skill->additional_effect(src, target, skill_id, skill_lv, attack_type, dmg_lv, timer->gettick()); if( dmg_lv > ATK_BLOCK && attack_type ) skill->counter_additional_effect(src, target, skill_id, skill_lv, attack_type, timer->gettick()); - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 0; } - dat = ers_alloc(delay_damage_ers, struct delay_damage); + dat = ers_alloc(battle->delay_damage_ers, struct delay_damage); dat->src_id = src->id; dat->target_id = target->id; dat->skill_id = skill_id; @@ -315,7 +297,7 @@ int battle_attr_ratio(int atk_elem,int def_type, int def_lv) if (def_type < 0 || def_type > ELE_MAX || def_lv < 1 || def_lv > 4) return 100; - return attr_fix_table[def_lv-1][atk_elem][def_type]; + return battle->attr_fix_table[def_lv-1][atk_elem][def_type]; } /*========================================== @@ -328,8 +310,8 @@ int64 battle_attr_fix(struct block_list *src, struct block_list *target, int64 d struct status_change *sc=NULL, *tsc=NULL; int ratio; - if (src) sc = iStatus->get_sc(src); - if (target) tsc = iStatus->get_sc(target); + if (src) sc = status->get_sc(src); + if (target) tsc = status->get_sc(target); if (atk_elem < 0 || atk_elem >= ELE_MAX) atk_elem = rnd()%ELE_MAX; @@ -340,14 +322,14 @@ int64 battle_attr_fix(struct block_list *src, struct block_list *target, int64 d return damage; } - ratio = attr_fix_table[def_lv-1][atk_elem][def_type]; + ratio = battle->attr_fix_table[def_lv-1][atk_elem][def_type]; if (sc && sc->count) { if(sc->data[SC_VOLCANO] && atk_elem == ELE_FIRE) - ratio += enchant_eff[sc->data[SC_VOLCANO]->val1-1]; + ratio += skill->enchant_eff[sc->data[SC_VOLCANO]->val1-1]; if(sc->data[SC_VIOLENTGALE] && atk_elem == ELE_WIND) - ratio += enchant_eff[sc->data[SC_VIOLENTGALE]->val1-1]; + ratio += skill->enchant_eff[sc->data[SC_VIOLENTGALE]->val1-1]; if(sc->data[SC_DELUGE] && atk_elem == ELE_WATER) - ratio += enchant_eff[sc->data[SC_DELUGE]->val1-1]; + ratio += skill->enchant_eff[sc->data[SC_DELUGE]->val1-1]; } if( target && target->type == BL_SKILL ) { if( atk_elem == ELE_FIRE && battle->get_current_skill(target) == GN_WALLOFTHORN ) { @@ -355,8 +337,10 @@ int64 battle_attr_fix(struct block_list *src, struct block_list *target, int64 d struct skill_unit_group *sg; struct block_list *src; - if( !su || !su->alive || (sg = su->group) == NULL || !sg || sg->val3 == -1 || - (src = iMap->id2bl(sg->src_id)) == NULL || iStatus->isdead(src) ) + if( !su || !su->alive + || (sg = su->group) == NULL || sg->val3 == -1 + || (src = map->id2bl(sg->src_id)) == NULL || status->isdead(src) + ) return 0; if( sg->unit_id != UNT_FIREWALL ) { @@ -371,39 +355,39 @@ int64 battle_attr_fix(struct block_list *src, struct block_list *target, int64 d } if( tsc && tsc->count ) { //since an atk can only have one type let's optimise this a bit switch(atk_elem){ - case ELE_FIRE: - if( tsc->data[SC_SPIDERWEB]) { - tsc->data[SC_SPIDERWEB]->val1 = 0; // free to move now - if( tsc->data[SC_SPIDERWEB]->val2-- > 0 ) - damage <<= 1; // double damage - if( tsc->data[SC_SPIDERWEB]->val2 == 0 ) - status_change_end(target, SC_SPIDERWEB, INVALID_TIMER); - } - if( tsc->data[SC_THORNS_TRAP]) - status_change_end(target, SC_THORNS_TRAP, INVALID_TIMER); - if( tsc->data[SC_FIRE_CLOAK_OPTION]) - damage -= damage * tsc->data[SC_FIRE_CLOAK_OPTION]->val2 / 100; - if( tsc->data[SC_COLD] && target->type != BL_MOB) - status_change_end(target, SC_COLD, INVALID_TIMER); - if( tsc->data[SC_EARTH_INSIGNIA]) damage += damage/2; - if( tsc->data[SC_VOLCANIC_ASH]) damage += damage/2; //150% - break; - case ELE_HOLY: - if( tsc->data[SC_ORATIO]) ratio += tsc->data[SC_ORATIO]->val1 * 2; - break; - case ELE_POISON: - if( tsc->data[SC_VENOMIMPRESS]) ratio += tsc->data[SC_VENOMIMPRESS]->val2; - break; - case ELE_WIND: - if( tsc->data[SC_COLD] && target->type != BL_MOB) damage += damage/2; - if( tsc->data[SC_WATER_INSIGNIA]) damage += damage/2; - break; - case ELE_WATER: - if( tsc->data[SC_FIRE_INSIGNIA]) damage += damage/2; - break; - case ELE_EARTH: - if( tsc->data[SC_WIND_INSIGNIA]) damage += damage/2; - break; + case ELE_FIRE: + if( tsc->data[SC_SPIDERWEB]) { + tsc->data[SC_SPIDERWEB]->val1 = 0; // free to move now + if( tsc->data[SC_SPIDERWEB]->val2-- > 0 ) + damage <<= 1; // double damage + if( tsc->data[SC_SPIDERWEB]->val2 == 0 ) + status_change_end(target, SC_SPIDERWEB, INVALID_TIMER); + } + if( tsc->data[SC_THORNS_TRAP]) + status_change_end(target, SC_THORNS_TRAP, INVALID_TIMER); + if( tsc->data[SC_FIRE_CLOAK_OPTION]) + damage -= damage * tsc->data[SC_FIRE_CLOAK_OPTION]->val2 / 100; + if( tsc->data[SC_COLD] && target->type != BL_MOB) + status_change_end(target, SC_COLD, INVALID_TIMER); + if( tsc->data[SC_EARTH_INSIGNIA]) damage += damage/2; + if( tsc->data[SC_VOLCANIC_ASH]) damage += damage/2; //150% + break; + case ELE_HOLY: + if( tsc->data[SC_ORATIO]) ratio += tsc->data[SC_ORATIO]->val1 * 2; + break; + case ELE_POISON: + if( tsc->data[SC_VENOMIMPRESS]) ratio += tsc->data[SC_VENOMIMPRESS]->val2; + break; + case ELE_WIND: + if( tsc->data[SC_COLD] && target->type != BL_MOB) damage += damage/2; + if( tsc->data[SC_WATER_INSIGNIA]) damage += damage/2; + break; + case ELE_WATER: + if( tsc->data[SC_FIRE_INSIGNIA]) damage += damage/2; + break; + case ELE_EARTH: + if( tsc->data[SC_WIND_INSIGNIA]) damage += damage/2; + break; } } //end tsc check if( src && src->type == BL_PC ){ @@ -435,10 +419,10 @@ int64 battle_calc_weapon_damage(struct block_list *src, struct block_list *bl, u if( !src || !bl ) return 0; - sc = iStatus->get_sc(src); + sc = status->get_sc(src); sd = BL_CAST(BL_PC, src); - damage = iStatus->get_weapon_atk(src, watk, flag); + damage = status->get_weapon_atk(src, watk, flag); if( sd ){ if( type == EQI_HAND_R ) @@ -503,9 +487,9 @@ int64 battle_calc_weapon_damage(struct block_list *src, struct block_list *bl, u #ifdef RENEWAL int64 battle_calc_base_damage(struct block_list *src, struct block_list *bl, uint16 skill_id, uint16 skill_lv, int nk, bool n_ele, short s_ele, short s_ele_, int type, int flag, int flag2) { int64 damage, batk; - struct status_data *st = iStatus->get_status_data(src); + struct status_data *st = status->get_status_data(src); - batk = battle->calc_elefix(src, bl, skill_id, skill_lv, iStatus->calc_batk(bl, iStatus->get_sc(src), st->batk, false), nk, n_ele, ELE_NEUTRAL, ELE_NEUTRAL, false, flag); + batk = battle->calc_elefix(src, bl, skill_id, skill_lv, status->calc_batk(bl, status->get_sc(src), st->batk, false), nk, n_ele, ELE_NEUTRAL, ELE_NEUTRAL, false, flag); if( type == EQI_HAND_L ) damage = batk + 3 * battle->calc_weapon_damage(src, bl, skill_id, skill_lv, &st->lhw, nk, n_ele, s_ele, s_ele_, status_get_size(bl), type, flag, flag2) / 4; @@ -604,7 +588,7 @@ int64 battle_calc_sizefix(struct map_session_data *sd, int64 damage, int type, i *------------------------------------------*/ int64 battle_addmastery(struct map_session_data *sd,struct block_list *target,int64 dmg,int type) { int64 damage; - struct status_data *st = iStatus->get_status_data(target); + struct status_data *st = status->get_status_data(target); int weapon, skill_lv; damage = dmg; @@ -721,9 +705,9 @@ int64 battle_calc_masteryfix(struct block_list *src, struct block_list *target, nullpo_ret(src); nullpo_ret(target); - sc = iStatus->get_sc(src); + sc = status->get_sc(src); sd = BL_CAST(BL_PC, src); - tstatus = iStatus->get_status_data(target); + tstatus = status->get_status_data(target); if ( !sd ) return damage; @@ -820,7 +804,7 @@ int64 battle_calc_masteryfix(struct block_list *src, struct block_list *target, if ( sc && sc->data[SC_MIRACLE] ) i = 2; //Star anger else - ARR_FIND(0, MAX_PC_FEELHATE, i, iStatus->get_class(target) == sd->hate_mob[i]); + ARR_FIND(0, MAX_PC_FEELHATE, i, status->get_class(target) == sd->hate_mob[i]); if ( i < MAX_PC_FEELHATE && (skill2_lv=pc->checkskill(sd,sg_info[i].anger_id)) && weapon ) { int ratio = sd->status.base_level + status_get_dex(src) + status_get_luk(src); if ( i == 2 ) ratio += status_get_str(src); //Star Anger @@ -846,7 +830,7 @@ int64 battle_calc_elefix(struct block_list *src, struct block_list *target, uint nullpo_ret(src); nullpo_ret(target); - tstatus = iStatus->get_status_data(target); + tstatus = status->get_status_data(target); if( (nk&NK_NO_ELEFIX) || n_ele ) return damage; @@ -868,8 +852,8 @@ int64 battle_calc_elefix(struct block_list *src, struct block_list *target, uint struct status_data *sstatus; struct status_change *sc; - sstatus = iStatus->get_status_data(src); - sc = iStatus->get_sc(src); + sstatus = status->get_status_data(src); + sc = status->get_sc(src); if( sc && sc->data[SC_SUB_WEAPONPROPERTY] ) { // Descriptions indicate this means adding a percent of a normal attack in another element. [Skotlex] int64 temp = battle->calc_base_damage(sstatus, &sstatus->rhw, sc, tstatus->size, BL_CAST(BL_PC, src), (flag?2:0)) * sc->data[SC_SUB_WEAPONPROPERTY]->val2 / 100; @@ -903,11 +887,11 @@ int64 battle_calc_cardfix(int attack_type, struct block_list *src, struct block_ sd = BL_CAST(BL_PC, src); tsd = BL_CAST(BL_PC, target); - t_class = iStatus->get_class(target); - s_class = iStatus->get_class(src); - sstatus = iStatus->get_status_data(src); - tstatus = iStatus->get_status_data(target); - s_race2 = iStatus->get_race2(src); + t_class = status->get_class(target); + s_class = status->get_class(src); + sstatus = status->get_status_data(src); + tstatus = status->get_status_data(target); + s_race2 = status->get_race2(src); switch(attack_type){ case BF_MAGIC: @@ -973,7 +957,7 @@ int64 battle_calc_cardfix(int attack_type, struct block_list *src, struct block_ } break; case BF_WEAPON: - t_race2 = iStatus->get_race2(target); + t_race2 = status->get_race2(target); if( cflag&2 ){ if( sd && !(nk&NK_NO_CARDFIX_ATK) ){ short cardfix_ = 1000; @@ -1206,10 +1190,10 @@ int64 battle_calc_defense(int attack_type, struct block_list *src, struct block_ sd = BL_CAST(BL_PC, src); tsd = BL_CAST(BL_PC, target); - sstatus = iStatus->get_status_data(src); - tstatus = iStatus->get_status_data(target); - sc = iStatus->get_sc(src); - tsc = iStatus->get_sc(target); + sstatus = status->get_status_data(src); + tstatus = status->get_status_data(target); + sc = status->get_sc(src); + tsc = status->get_sc(target); switch(attack_type){ case BF_WEAPON: @@ -1218,14 +1202,14 @@ int64 battle_calc_defense(int attack_type, struct block_list *src, struct block_ * def1 = equip def * def2 = status def **/ - defType def1 = iStatus->get_def(target); //Don't use tstatus->def1 due to skill timer reductions. + defType def1 = status->get_def(target); //Don't use tstatus->def1 due to skill timer reductions. short def2 = tstatus->def2, vit_def; #ifdef RENEWAL - def1 = iStatus->calc_def2(target, tsc, def1, false); // equip def(RE) - def2 = iStatus->calc_def(target, tsc, def2, false); // status def(RE) + def1 = status->calc_def2(target, tsc, def1, false); // equip def(RE) + def2 = status->calc_def(target, tsc, def2, false); // status def(RE) #else - def1 = iStatus->calc_def(target, tsc, def1, false); // equip def(RE) - def2 = iStatus->calc_def2(target, tsc, def2, false); // status def(RE) + def1 = status->calc_def(target, tsc, def1, false); // equip def(RE) + def2 = status->calc_def2(target, tsc, def2, false); // status def(RE) #endif if( sd ){ @@ -1331,11 +1315,11 @@ int64 battle_calc_defense(int attack_type, struct block_list *src, struct block_ defType mdef = tstatus->mdef; short mdef2= tstatus->mdef2; #ifdef RENEWAL - mdef2 = iStatus->calc_mdef(target, tsc, mdef2, false); // status mdef(RE) - mdef = iStatus->calc_mdef2(target, tsc, mdef, false); // equip mde(RE) + mdef2 = status->calc_mdef(target, tsc, mdef2, false); // status mdef(RE) + mdef = status->calc_mdef2(target, tsc, mdef, false); // equip mde(RE) #else - mdef2 = iStatus->calc_mdef2(target, tsc, mdef2, false); // status mdef(RE) - mdef = iStatus->calc_mdef(target, tsc, mdef, false); // equip mde(RE) + mdef2 = status->calc_mdef2(target, tsc, mdef2, false); // status mdef(RE) + mdef = status->calc_mdef(target, tsc, mdef, false); // equip mde(RE) #endif if( flag&1 ) mdef = 0; @@ -1382,10 +1366,10 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block sd = BL_CAST(BL_PC, src); tsd = BL_CAST(BL_PC, target); - sc = iStatus->get_sc(src); - tsc = iStatus->get_sc(target); - st = iStatus->get_status_data(src); - tst = iStatus->get_status_data(target); + sc = status->get_sc(src); + tsc = status->get_sc(target); + st = status->get_status_data(src); + tst = status->get_status_data(target); switch(attack_type){ case BF_MAGIC: @@ -1454,7 +1438,7 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block skillratio += (tst->size!=SZ_BIG?5*skill_lv:-99); //Full damage is dealt on small/medium targets break; case SL_SMA: - skillratio += -60 + iStatus->get_lv(src); //Base damage is 40% + lv% + skillratio += -60 + status->get_lv(src); //Base damage is 40% + lv% break; case NJ_KOUENKA: skillratio -= 10; @@ -1575,7 +1559,7 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block party_foreachsamemap(skill->check_condition_char_sub, sd, 3, &sd->bl, &c, &p_sd, skill_id); c = ( c > 1 ? rand()%c : 0 ); - if( (psd = iMap->id2sd(p_sd[c])) && pc->checkskill(psd,WL_COMET) > 0 ){ + if( (psd = map->id2sd(p_sd[c])) && pc->checkskill(psd,WL_COMET) > 0 ){ skillratio = skill_lv * 400; //MATK [{( Skill Level x 400 ) x ( Caster's Base Level / 120 )} + 2500 ] % RE_LVL_DMOD(120); skillratio += 2500; @@ -1603,7 +1587,7 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block case WL_SUMMON_ATK_WATER: case WL_SUMMON_ATK_WIND: case WL_SUMMON_ATK_GROUND: - skillratio = skill_lv * (iStatus->get_lv(src) + ( sd ? sd->status.job_level : 50 ));// This is close to official, but lacking a little info to finalize. [Rytech] + skillratio = skill_lv * (status->get_lv(src) + ( sd ? sd->status.job_level : 50 ));// This is close to official, but lacking a little info to finalize. [Rytech] RE_LVL_DMOD(100); break; case LG_RAYOFGENESIS: @@ -1617,7 +1601,7 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block break; case LG_SHIELDSPELL:// [(Casters Base Level x 4) + (Shield MDEF x 100) + (Casters INT x 2)] % if( sd ) { - skillratio = iStatus->get_lv(src) * 4 + sd->bonus.shieldmdef * 100 + status_get_int(src) * 2; + skillratio = status->get_lv(src) * 4 + sd->bonus.shieldmdef * 100 + status_get_int(src) * 2; } else skillratio += 1900; //2000% break; @@ -1994,10 +1978,9 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block case TK_JUMPKICK: skillratio += -70 + 10*skill_lv; if (sc && sc->data[SC_COMBOATTACK] && sc->data[SC_COMBOATTACK]->val1 == skill_id) - skillratio += 10 * iStatus->get_lv(src) / 3; //Tumble bonus - if (flag) - { - skillratio += 10 * iStatus->get_lv(src) / 3; //Running bonus (TODO: What is the real bonus?) + skillratio += 10 * status->get_lv(src) / 3; //Tumble bonus + if (flag) { + skillratio += 10 * status->get_lv(src) / 3; //Running bonus (TODO: What is the real bonus?) if( sc && sc->data[SC_STRUP] ) // Spurt bonus skillratio *= 2; } @@ -2082,7 +2065,7 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block break; case RK_SONICWAVE: skillratio += -100 + 100 * (skill_lv + 5); - skillratio = skillratio * (100 + (iStatus->get_lv(src)-100) / 2) / 100; + skillratio = skillratio * (100 + (status->get_lv(src)-100) / 2) / 100; break; case RK_HUNDREDSPEAR: skillratio += 500 + (80 * skill_lv); @@ -2091,7 +2074,7 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block if( index >= 0 && sd->inventory_data[index] && sd->inventory_data[index]->type == IT_WEAPON ) skillratio += (10000 - min(10000, sd->inventory_data[index]->weight)) / 10; - skillratio = skillratio * (100 + (iStatus->get_lv(src)-100) / 2) / 100 + 50 * pc->checkskill(sd,LK_SPIRALPIERCE); + skillratio = skillratio * (100 + (status->get_lv(src)-100) / 2) / 100 + 50 * pc->checkskill(sd,LK_SPIRALPIERCE); } break; case RK_WINDCUTTER: @@ -2106,7 +2089,7 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block skillratio += 250 * skill_lv; else skillratio += 200 * skill_lv; - skillratio = (skillratio - 100) * (100 + (iStatus->get_lv(src)-100)) / 100; + skillratio = (skillratio - 100) * (100 + (status->get_lv(src)-100)) / 100; if( st->rhw.ele == ELE_FIRE ) skillratio += 100 * skill_lv; break; @@ -2268,7 +2251,7 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block case LG_SHIELDSPELL:// [(Casters Base Level x 4) + (Shield DEF x 10) + (Casters VIT x 2)] % if( sd ) { struct item_data *shield_data = sd->inventory_data[sd->equip_index[EQI_HAND_L]]; - skillratio += -100 + iStatus->get_lv(src) * 4 + status_get_vit(src) * 2; + skillratio += -100 + status->get_lv(src) * 4 + status_get_vit(src) * 2; if( shield_data ) skillratio += shield_data->def * 10; } else @@ -2349,7 +2332,7 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block break; case SR_KNUCKLEARROW: if( flag&4 ){ // ATK [(Skill Level x 150) + (1000 x Target current weight / Maximum weight) + (Target Base Level x 5) x (Caster Base Level / 150)] % - skillratio += -100 + 150 * skill_lv + iStatus->get_lv(target) * 5 * (iStatus->get_lv(src) / 100) ; + skillratio += -100 + 150 * skill_lv + status->get_lv(target) * 5 * (status->get_lv(src) / 100) ; if( tsd && tsd->weight ) skillratio += 100 * (tsd->weight / tsd->max_weight); }else // ATK [(Skill Level x 100 + 500) x Caster Base Level / 100] % @@ -2357,7 +2340,7 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block RE_LVL_DMOD(100); break; case SR_WINDMILL: // ATK [(Caster Base Level + Caster DEX) x Caster Base Level / 100] % - skillratio += -100 + iStatus->get_lv(src) + status_get_dex(src); + skillratio += -100 + status->get_lv(src) + status_get_dex(src); RE_LVL_DMOD(100); break; case SR_GATEOFHELL: @@ -2476,7 +2459,7 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block skillratio += -100 + 150 * skill_lv; RE_LVL_DMOD(120); if( tsc && tsc->data[SC_KO_JYUMONJIKIRI] ) - skillratio += iStatus->get_lv(src) * skill_lv; + skillratio += status->get_lv(src) * skill_lv; case KO_HUUMARANKA: skillratio += -100 + 150 * skill_lv + status_get_agi(src) + status_get_dex(src) + 100 * (sd ? pc->checkskill(sd, NJ_HUUMA) : 0); break; @@ -2538,8 +2521,7 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block * ATK may be MISS, BLOCKED FAIL, reduc, increase, end status... * After this we apply bg/gvg reduction *------------------------------------------*/ -int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Damage *d,int64 damage,uint16 skill_id,uint16 skill_lv) -{ +int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Damage *d,int64 damage,uint16 skill_id,uint16 skill_lv) { struct map_session_data *sd = NULL; struct status_change *sc; struct status_change_entry *sce; @@ -2551,7 +2533,7 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam return 0; if( battle_config.ksprotection && mob->ksprotected(src, bl) ) return 0; - if( iMap->getcell(bl->m, bl->x, bl->y, CELL_CHKMAELSTROM) && skill->get_type(skill_id) != BF_MISC + if( map->getcell(bl->m, bl->x, bl->y, CELL_CHKMAELSTROM) && skill->get_type(skill_id) != BF_MISC && skill->get_casttype(skill_id) == CAST_GROUND ) return 0; if (bl->type == BL_PC) { @@ -2569,7 +2551,7 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam if(!damage) return 0; } - sc = iStatus->get_sc(bl); + sc = status->get_sc(bl); if( sc && sc->data[SC_INVINCIBLE] && !sc->data[SC_INVINCIBLEOFF] ) return 1; @@ -2590,7 +2572,7 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam skill_id == MG_SOULSTRIKE || skill_id == WL_SOULEXPANSION || (skill_id && skill->get_ele(skill_id, skill_lv) == ELE_GHOST) || - (!skill_id && (iStatus->get_status_data(src))->rhw.ele == ELE_GHOST) + (!skill_id && (status->get_status_data(src))->rhw.ele == ELE_GHOST) ){ if( skill_id == WL_SOULEXPANSION ) damage <<= 1; // If used against a player in White Imprison, the skill deals double damage. @@ -2731,7 +2713,7 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam && flag&BF_WEAPON && !(skill->get_nk(skill_id)&NK_NO_CARDFIX_ATK)) { skill->additional_effect (src, bl, skill_id, skill_lv, flag, ATK_BLOCK, timer->gettick() ); - if( !iStatus->isdead(src) ) + if( !status->isdead(src) ) skill->counter_additional_effect( src, bl, skill_id, skill_lv, flag, timer->gettick() ); if (sce) { clif->specialeffect(bl, 462, AREA); @@ -2853,11 +2835,11 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam if(sc->data[SC_ENERGYCOAT] && (flag&BF_WEAPON && skill_id != WS_CARTTERMINATION)) #endif { - struct status_data *sstatus = iStatus->get_status_data(bl); + struct status_data *sstatus = status->get_status_data(bl); int per = 100*sstatus->sp / sstatus->max_sp -1; //100% should be counted as the 80~99% interval per /=20; //Uses 20% SP intervals. //SP Cost: 1% + 0.5% per every 20% SP - if (!iStatus->charge(bl, 0, (10+5*per)*sstatus->max_sp/1000)) + if (!status->charge(bl, 0, (10+5*per)*sstatus->max_sp/1000)) status_change_end(bl, SC_ENERGYCOAT, INVALID_TIMER); //Reduction: 6% + 6% every 20% damage -= damage * (6 * (1+per)) / 100; @@ -2911,7 +2893,7 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam if(sce->val2>=0) damage=0; else - damage=-sce->val2; + damage=-sce->val2; } if((--sce->val3)<=0 || (sce->val2<=0) || skill_id == AL_HOLYLIGHT) status_change_end(bl, SC_KYRIE, INVALID_TIMER); @@ -2926,7 +2908,7 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam if( (sce = sc->data[SC_LIGHTNINGWALK]) && flag&BF_LONG && rnd()%100 < sce->val1 ) { int dx[8]={0,-1,-1,-1,0,1,1,1}; int dy[8]={1,1,0,-1,-1,-1,0,1}; - uint8 dir = iMap->calc_dir(bl, src->x, src->y); + uint8 dir = map->calc_dir(bl, src->x, src->y); if( unit->movepos(bl, src->x-dx[dir], src->y-dy[dir], 1, 1) ) { clif->slide(bl,src->x-dx[dir],src->y-dy[dir]); unit->setdir(bl, dir); @@ -2940,23 +2922,23 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam //(since battle_drain is strictly for players currently) if ((sce=sc->data[SC_HAMI_BLOODLUST]) && flag&BF_WEAPON && damage > 0 && rnd()%100 < sce->val3) - iStatus->heal(src, damage*sce->val4/100, 0, 3); + status->heal(src, damage*sce->val4/100, 0, 3); if( sd && (sce = sc->data[SC_FORCEOFVANGUARD]) && flag&BF_WEAPON && rnd()%100 < sce->val2 ) pc->addspiritball(sd,skill->get_time(LG_FORCEOFVANGUARD,sce->val1),sce->val3); if (sc->data[SC_STYLE_CHANGE] && rnd()%2) { - TBL_HOM *hd = BL_CAST(BL_HOM,bl); - if (hd) homun->addspiritball(hd, 10); //add a sphere - } + TBL_HOM *hd = BL_CAST(BL_HOM,bl); + if (hd) homun->addspiritball(hd, 10); //add a sphere + } if( sc->data[SC__DEADLYINFECT] && damage > 0 && rnd()%100 < 65 + 5 * sc->data[SC__DEADLYINFECT]->val1 ) - iStatus->change_spread(bl, src); // Deadly infect attacked side + status->change_spread(bl, src); // Deadly infect attacked side if( sc && sc->data[SC__SHADOWFORM] ) { - struct block_list *s_bl = iMap->id2bl(sc->data[SC__SHADOWFORM]->val2); + struct block_list *s_bl = map->id2bl(sc->data[SC__SHADOWFORM]->val2); if( !s_bl || s_bl->m != bl->m ) { // If the shadow form target is not present remove the sc. status_change_end(bl, SC__SHADOWFORM, INVALID_TIMER); - } else if( iStatus->isdead(s_bl) || !battle->check_target(src,s_bl,BCT_ENEMY)) { // If the shadow form target is dead or not your enemy remove the sc in both. + } else if( status->isdead(s_bl) || !battle->check_target(src,s_bl,BCT_ENEMY)) { // If the shadow form target is dead or not your enemy remove the sc in both. status_change_end(bl, SC__SHADOWFORM, INVALID_TIMER); if( s_bl->type == BL_PC ) ((TBL_PC*)s_bl)->shadowform_id = 0; @@ -2966,7 +2948,7 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam if( s_bl->type == BL_PC ) ((TBL_PC*)s_bl)->shadowform_id = 0; } else { - iStatus->damage(bl, s_bl, damage, 0, clif->damage(s_bl, s_bl, timer->gettick(), 500, 500, damage, -1, 0, 0), 0); + status->damage(bl, s_bl, damage, 0, clif->damage(s_bl, s_bl, timer->gettick(), 500, 500, damage, -1, 0, 0), 0); return ATK_NONE; } } @@ -2975,7 +2957,7 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam } //SC effects from caster side. - sc = iStatus->get_sc(src); + sc = status->get_sc(src); if (sc && sc->count) { if( sc->data[SC_INVINCIBLE] && !sc->data[SC_INVINCIBLEOFF] ) @@ -3004,7 +2986,7 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam if( sc->data[SC_POISONINGWEAPON] && skill_id != GC_VENOMPRESSURE && (flag&BF_WEAPON) && damage > 0 && rnd()%100 < sc->data[SC_POISONINGWEAPON]->val3 ) sc_start(bl,sc->data[SC_POISONINGWEAPON]->val2,100,sc->data[SC_POISONINGWEAPON]->val1,skill->get_time2(GC_POISONINGWEAPON, 1)); if( sc->data[SC__DEADLYINFECT] && damage > 0 && rnd()%100 < 65 + 5 * sc->data[SC__DEADLYINFECT]->val1 ) - iStatus->change_spread(src, bl); + status->change_spread(src, bl); if (sc->data[SC_STYLE_CHANGE] && rnd()%2) { TBL_HOM *hd = BL_CAST(BL_HOM,bl); if (hd) homun->addspiritball(hd, 10); @@ -3046,7 +3028,7 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam damage = div_; } - if( bl->type == BL_MOB && !iStatus->isdead(bl) && src != bl) { + if( bl->type == BL_MOB && !status->isdead(bl) && src != bl) { if (damage > 0 ) mob->skill_event((TBL_MOB*)bl,src,timer->gettick(),flag); if (skill_id) @@ -3059,12 +3041,12 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam struct status_data *sstatus = NULL; if( src->type == BL_PC && ((TBL_PC*)src)->bonus.arrow_ele ) element = ((TBL_PC*)src)->bonus.arrow_ele; - else if( (sstatus = iStatus->get_status_data(src)) ) { + else if( (sstatus = status->get_status_data(src)) ) { element = sstatus->rhw.ele; } } else if( element == -2 ) //Use enchantment's element - element = status_get_attack_sc_element(src,iStatus->get_sc(src)); + element = status_get_attack_sc_element(src,status->get_sc(src)); else if( element == -3 ) //Use random element element = rnd()%ELE_MAX; if( element == ELE_FIRE || element == ELE_WATER ) @@ -3096,10 +3078,9 @@ int64 battle_calc_bg_damage(struct block_list *src, struct block_list *bl, int64 /*========================================== * Calculates GVG related damage adjustments. *------------------------------------------*/ -int64 battle_calc_gvg_damage(struct block_list *src,struct block_list *bl,int64 damage,int div_,uint16 skill_id,uint16 skill_lv,int flag) -{ +int64 battle_calc_gvg_damage(struct block_list *src,struct block_list *bl,int64 damage,int div_,uint16 skill_id,uint16 skill_lv,int flag) { struct mob_data* md = BL_CAST(BL_MOB, bl); - int class_ = iStatus->get_class(bl); + int class_ = status->get_class(bl); if (!damage) //No reductions to make. return 0; @@ -3118,7 +3099,7 @@ int64 battle_calc_gvg_damage(struct block_list *src,struct block_list *bl,int64 } } if(src->type != BL_MOB) { - struct guild *g = src->type == BL_PC ? ((TBL_PC *)src)->guild : guild->search(iStatus->get_guild_id(src)); + struct guild *g = src->type == BL_PC ? ((TBL_PC *)src)->guild : guild->search(status->get_guild_id(src)); if (class_ == MOBID_EMPERIUM && (!g || guild->checkskill(g,GD_APPROVAL) <= 0 )) return 0; @@ -3233,8 +3214,8 @@ struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list TBL_PC *sd; struct status_change *sc; struct Damage ad; - struct status_data *sstatus = iStatus->get_status_data(src); - struct status_data *tstatus = iStatus->get_status_data(target); + struct status_data *sstatus = status->get_status_data(src); + struct status_data *tstatus = status->get_status_data(target); struct { unsigned imdef : 1; unsigned infdef : 1; @@ -3261,7 +3242,7 @@ struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list sd = BL_CAST(BL_PC, src); - sc = iStatus->get_sc(src); + sc = status->get_sc(src); //Initialize variables that will be used afterwards s_ele = skill->get_ele(skill_id, skill_lv); @@ -3273,7 +3254,7 @@ struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list if( i < 5 ) s_ele = i; } }else if (s_ele == -2) //Use status element - s_ele = status_get_attack_sc_element(src,iStatus->get_sc(src)); + s_ele = status_get_attack_sc_element(src,status->get_sc(src)); else if( s_ele == -3 ) //Use random element s_ele = rnd()%ELE_MAX; @@ -3360,16 +3341,16 @@ struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list case ALL_RESURRECTION: case PR_TURNUNDEAD: //Undead check is on skill_castend_damageid code. - i = 20*skill_lv + sstatus->luk + sstatus->int_ + iStatus->get_lv(src) + i = 20*skill_lv + sstatus->luk + sstatus->int_ + status->get_lv(src) + 200 - 200*tstatus->hp/tstatus->max_hp; // there is no changed in success chance in renewal. [malufett] if(i > 700) i = 700; if(rnd()%1000 < i && !(tstatus->mode&MD_BOSS)) ad.damage = tstatus->hp; else { #ifdef RENEWAL - MATK_ADD(iStatus->get_matk(src, 2)); + MATK_ADD(status->get_matk(src, 2)); #else - ad.damage = iStatus->get_lv(src) + sstatus->int_ + skill_lv * 10; + ad.damage = status->get_lv(src) + sstatus->int_ + skill_lv * 10; #endif } break; @@ -3381,10 +3362,10 @@ struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list **/ case AB_RENOVATIO: //Damage calculation from iRO wiki. [Jobbie] - ad.damage = (int)((15 * iStatus->get_lv(src)) + (1.5 * sstatus->int_)); + ad.damage = (int)((15 * status->get_lv(src)) + (1.5 * sstatus->int_)); break; default: { - MATK_ADD( iStatus->get_matk(src, 2) ); + MATK_ADD( status->get_matk(src, 2) ); if (nk&NK_SPLASHSPLIT) { // Divide MATK in case of multiple targets skill if(mflag>0) @@ -3543,11 +3524,11 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list * struct map_session_data *sd, *tsd; struct Damage md; //DO NOT CONFUSE with md of mob_data! - struct status_data *sstatus = iStatus->get_status_data(src); - struct status_data *tstatus = iStatus->get_status_data(target); - struct status_change *tsc = iStatus->get_sc(target); + struct status_data *sstatus = status->get_status_data(src); + struct status_data *tstatus = status->get_status_data(target); + struct status_change *tsc = status->get_sc(target); #ifdef RENEWAL - struct status_change *sc = iStatus->get_sc(src); + struct status_change *sc = status->get_sc(src); #endif memset(&md,0,sizeof(md)); @@ -3591,7 +3572,7 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list * case MA_LANDMINE: case HT_BLASTMINE: case HT_CLAYMORETRAP: - md.damage = skill_lv * sstatus->dex * (3+iStatus->get_lv(src)/100) * (1+sstatus->int_/35); + md.damage = skill_lv * sstatus->dex * (3+status->get_lv(src)/100) * (1+sstatus->int_/35); md.damage += md.damage * (rnd()%20-10) / 100; md.damage += 40 * (sd?pc->checkskill(sd,RA_RESEARCHTRAP):0); break; @@ -3653,8 +3634,8 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list * #ifdef RENEWAL {// [malufett] int64 matk=0, atk; - short tdef = iStatus->get_total_def(target); - short tmdef = iStatus->get_total_mdef(target); + short tdef = status->get_total_def(target); + short tmdef = status->get_total_mdef(target); int targetVit = min(120, status_get_vit(target)); short totaldef = (tmdef + tdef - ((uint64)(tmdef + tdef) >> 32)) >> 1; @@ -3712,7 +3693,7 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list * md.damage=md.damage / 2; break; case GS_FLING: - md.damage = sd?sd->status.job_level:iStatus->get_lv(src); + md.damage = sd?sd->status.job_level:status->get_lv(src); break; case HVAN_EXPLOSION: //[orn] md.damage = sstatus->max_hp * (50 + 50 * skill_lv) / 100; @@ -3725,7 +3706,7 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list * #else int ratio = 300 + 50 * skill_lv; int64 matk = battle->calc_magic_attack(src, target, skill_id, skill_lv, mflag).damage; - short totaldef = iStatus->get_total_def(target) + iStatus->get_total_mdef(target); + short totaldef = status->get_total_def(target) + status->get_total_mdef(target); int64 atk = battle->calc_base_damage(src, target, skill_id, skill_lv, nk, false, s_ele, ELE_NEUTRAL, EQI_HAND_R, (sc && sc->data[SC_MAXIMIZEPOWER]?1:0)|(sc && sc->data[SC_WEAPONPERFECT]?8:0), md.flag); if( sc && sc->data[SC_EDP] ) @@ -3774,9 +3755,9 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list * case NC_SELFDESTRUCTION: { #ifdef RENEWAL - short totaldef = iStatus->get_total_def(target); + short totaldef = status->get_total_def(target); #else - short totaldef = tstatus->def2 + (short)iStatus->get_def(target); + short totaldef = tstatus->def2 + (short)status->get_def(target); #endif md.damage = ( (sd?pc->checkskill(sd,NC_MAINFRAME):10) + 8 ) * ( skill_lv + 1 ) * ( status_get_sp(src) + sstatus->vit ); RE_LVL_MDMOD(100); @@ -3791,15 +3772,15 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list * break; case GN_HELLS_PLANT_ATK: //[{( Hell Plant Skill Level x Casters Base Level ) x 10 } + {( Casters INT x 7 ) / 2 } x { 18 + ( Casters Job Level / 4 )] x ( 5 / ( 10 - Summon Flora Skill Level )) - md.damage = ( skill_lv * iStatus->get_lv(src) * 10 ) + ( sstatus->int_ * 7 / 2 ) * ( 18 + (sd?sd->status.job_level:0) / 4 ) * ( 5 / (10 - (sd?pc->checkskill(sd,AM_CANNIBALIZE):0)) ); + md.damage = ( skill_lv * status->get_lv(src) * 10 ) + ( sstatus->int_ * 7 / 2 ) * ( 18 + (sd?sd->status.job_level:0) / 4 ) * ( 5 / (10 - (sd?pc->checkskill(sd,AM_CANNIBALIZE):0)) ); break; case KO_HAPPOKUNAI: { struct Damage wd = battle->calc_weapon_attack(src,target,skill_id,skill_lv,mflag); #ifdef RENEWAL - short totaldef = iStatus->get_total_def(target); + short totaldef = status->get_total_def(target); #else - short totaldef = tstatus->def2 + (short)iStatus->get_def(target); + short totaldef = tstatus->def2 + (short)status->get_def(target); #endif md.damage = 3 * wd.damage * (5 + skill_lv) / 5; md.damage -= totaldef; @@ -3954,10 +3935,10 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list struct map_session_data *sd, *tsd; struct Damage wd; - struct status_change *sc = iStatus->get_sc(src); - struct status_change *tsc = iStatus->get_sc(target); - struct status_data *sstatus = iStatus->get_status_data(src); - struct status_data *tstatus = iStatus->get_status_data(target); + struct status_change *sc = status->get_sc(src); + struct status_change *tsc = status->get_sc(target); + struct status_data *sstatus = status->get_status_data(src); + struct status_data *tstatus = status->get_status_data(target); struct { unsigned hit : 1; //the attack Hit? (not a miss) unsigned cri : 1; //Critical hit @@ -4230,7 +4211,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list //Therefore, we use the old value 3 on cases when an sd gets attacked by a mob cri -= tstatus->luk*(!sd&&tsd?3:2); #else - cri -= iStatus->get_lv(target) / 15 + 2 * status_get_luk(target); + cri -= status->get_lv(target) / 15 + 2 * status_get_luk(target); #endif if( tsc && tsc->data[SC_SLEEP] ) { @@ -4420,7 +4401,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list wd.damage2 = 0; #else { - short totaldef = iStatus->get_total_def(target); + short totaldef = status->get_total_def(target); i = 0; GET_NORMAL_ATTACK( (sc && sc->data[SC_MAXIMIZEPOWER]?1:0)|(sc && sc->data[SC_WEAPONPERFECT]?8:0) ); if( sc && sc->data[SC_NJ_BUNSINJYUTSU] && (i=sc->data[SC_NJ_BUNSINJYUTSU]->val2) > 0 ) @@ -4437,12 +4418,12 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list break; case NJ_SYURIKEN: // [malufett] GET_NORMAL_ATTACK( (sc && sc->data[SC_MAXIMIZEPOWER]?1:0)|(sc && sc->data[SC_WEAPONPERFECT]?8:0) ); - wd.damage += battle->calc_masteryfix(src, target, skill_id, skill_lv, 4 * skill_lv + (sd ? sd->bonus.arrow_atk : 0), wd.div_, 0, flag.weapon) - iStatus->get_total_def(target); + wd.damage += battle->calc_masteryfix(src, target, skill_id, skill_lv, 4 * skill_lv + (sd ? sd->bonus.arrow_atk : 0), wd.div_, 0, flag.weapon) - status->get_total_def(target); RE_SKILL_REDUCTION(); break; case MO_EXTREMITYFIST: // [malufett] { - short totaldef = iStatus->get_total_def(target); + short totaldef = status->get_total_def(target); GET_NORMAL_ATTACK( (sc && sc->data[SC_MAXIMIZEPOWER]?1:0)|8 ); if( wd.damage ){ wd.damage = (250 + 150 * skill_lv) + (10 * (status_get_sp(src)+1) * wd.damage / 100) + (8 * wd.damage); @@ -4631,7 +4612,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list break; case GS_MAGICALBULLET: #ifndef RENEWAL - ATK_ADD( iStatus->get_matk(src, 2) ); + ATK_ADD( status->get_matk(src, 2) ); #else ATK_ADD( battle->calc_magic_attack(src, target, skill_id, skill_lv, wflag).damage ); flag.tdef = 1; @@ -4645,17 +4626,17 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list ATK_ADD( status_get_agi(src) * 2 + (sd?sd->status.job_level:0) * 4 ); break; case SR_TIGERCANNON: // (Tiger Cannon skill level x 240) + (Target Base Level x 40) - ATK_ADD( skill_lv * 240 + iStatus->get_lv(target) * 40 ); + ATK_ADD( skill_lv * 240 + status->get_lv(target) * 40 ); if( sc && sc->data[SC_COMBOATTACK] && sc->data[SC_COMBOATTACK]->val1 == SR_FALLENEMPIRE ) // (Tiger Cannon skill level x 500) + (Target Base Level x 40) - ATK_ADD( skill_lv * 500 + iStatus->get_lv(target) * 40 ); + ATK_ADD( skill_lv * 500 + status->get_lv(target) * 40 ); break; case SR_FALLENEMPIRE:// [(Target Size value + Skill Level - 1) x Caster STR] + [(Target current weight x Caster DEX / 120)] ATK_ADD( ((tstatus->size+1)*2 + skill_lv - 1) * sstatus->str); if( tsd && tsd->weight ){ ATK_ADD( (tsd->weight/10) * sstatus->dex / 120 ); }else{ - ATK_ADD( iStatus->get_lv(target) * 50 ); //mobs + ATK_ADD( status->get_lv(target) * 50 ); //mobs } break; case KO_SETSUDAN: @@ -4821,8 +4802,8 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list if( !skill_id ) { if( sc->data[SC_ENCHANTBLADE] ) { //[( ( Skill Lv x 20 ) + 100 ) x ( casterBaseLevel / 150 )] + casterInt - i = ( sc->data[SC_ENCHANTBLADE]->val1 * 20 + 100 ) * iStatus->get_lv(src) / 150 + status_get_int(src); - i = i - iStatus->get_total_mdef(target) + iStatus->get_matk(src, 2); + i = ( sc->data[SC_ENCHANTBLADE]->val1 * 20 + 100 ) * status->get_lv(src) / 150 + status_get_int(src); + i = i - status->get_total_mdef(target) + status->get_matk(src, 2); if( i ) ATK_ADD(i); } @@ -4924,7 +4905,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list } #endif if( flag.infdef ) { //Plants receive 1 damage when hit - short class_ = iStatus->get_class(target); + short class_ = status->get_class(target); if( flag.hit || wd.damage > 0 ) wd.damage = wd.div_; // In some cases, right hand no need to have a weapon to increase damage if( flag.lh && (flag.hit || wd.damage2 > 0) ) @@ -5016,9 +4997,9 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list case SR_GATEOFHELL: ATK_ADD (sstatus->max_hp - status_get_hp(src)); if(sc && sc->data[SC_COMBOATTACK] && sc->data[SC_COMBOATTACK]->val1 == SR_FALLENEMPIRE){ - ATK_ADD ( (sstatus->max_sp * (1 + skill_lv * 2 / 10)) + 40 * iStatus->get_lv(src) ); + ATK_ADD ( (sstatus->max_sp * (1 + skill_lv * 2 / 10)) + 40 * status->get_lv(src) ); }else{ - ATK_ADD ( (sstatus->sp * (1 + skill_lv * 2 / 10)) + 10 * iStatus->get_lv(src) ); + ATK_ADD ( (sstatus->sp * (1 + skill_lv * 2 / 10)) + 10 * status->get_lv(src) ); } break; } @@ -5049,7 +5030,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list change = true; if( change ) sd->state.autocast = 1; - iMap->foreachinshootrange(battle->damage_area,target,skill->get_splash(LG_REFLECTDAMAGE,1),BL_CHAR,timer->gettick(),target,wd.amotion,sstatus->dmotion,rdamage,tstatus->race); + map->foreachinshootrange(battle->damage_area,target,skill->get_splash(LG_REFLECTDAMAGE,1),BL_CHAR,timer->gettick(),target,wd.amotion,sstatus->dmotion,rdamage,tstatus->race); if( change ) sd->state.autocast = 0; } @@ -5173,10 +5154,10 @@ int64 battle_calc_return_damage(struct block_list* bl, struct block_list *src, i #ifdef RENEWAL int max_reflect_damage; - max_reflect_damage = max(status_get_max_hp(bl), status_get_max_hp(bl) * iStatus->get_lv(bl) / 100); + max_reflect_damage = max(status_get_max_hp(bl), status_get_max_hp(bl) * status->get_lv(bl) / 100); #endif sd = BL_CAST(BL_PC, bl); - sc = iStatus->get_sc(bl); + sc = status->get_sc(bl); #ifdef RENEWAL #define NORMALIZE_RDAMAGE(d){ trdamage += rdamage = max(1, min(max_reflect_damage, d)); } @@ -5186,14 +5167,14 @@ int64 battle_calc_return_damage(struct block_list* bl, struct block_list *src, i if( sc && sc->data[SC_CRESCENTELBOW] && !is_boss(src) && rnd()%100 < sc->data[SC_CRESCENTELBOW]->val2 ){ //ATK [{(Target HP / 100) x Skill Level} x Caster Base Level / 125] % + [Received damage x {1 + (Skill Level x 0.2)}] - int ratio = (status_get_hp(src) / 100) * sc->data[SC_CRESCENTELBOW]->val1 * iStatus->get_lv(bl) / 125; + int ratio = (status_get_hp(src) / 100) * sc->data[SC_CRESCENTELBOW]->val1 * status->get_lv(bl) / 125; if (ratio > 5000) ratio = 5000; // Maximum of 5000% ATK rdamage = rdamage * ratio / 100 + (*dmg) * (10 + sc->data[SC_CRESCENTELBOW]->val1 * 20 / 10) / 10; skill->blown(bl, src, skill->get_blewcount(SR_CRESCENTELBOW_AUTOSPELL, sc->data[SC_CRESCENTELBOW]->val1), unit->getdir(src), 0); clif->skill_damage(bl, src, timer->gettick(), status_get_amotion(src), 0, rdamage, 1, SR_CRESCENTELBOW_AUTOSPELL, sc->data[SC_CRESCENTELBOW]->val1, 6); // This is how official does clif->damage(src, bl, timer->gettick(), status_get_amotion(src)+1000, 0, rdamage/10, 1, 0, 0); - iStatus->damage(src, bl, iStatus->damage(bl, src, rdamage, 0, 0, 1)/10, 0, 0, 1); + status->damage(src, bl, status->damage(bl, src, rdamage, 0, 0, 1)/10, 0, 0, 1); status_change_end(bl, SC_CRESCENTELBOW, INVALID_TIMER); return 0; // Just put here to minimize redundancy } @@ -5215,10 +5196,10 @@ int64 battle_calc_return_damage(struct block_list* bl, struct block_list *src, i } } if( sc->data[SC_DEATHBOUND] && skill_id != WS_CARTTERMINATION && !is_boss(src) ) { - uint8 dir = iMap->calc_dir(bl,src->x,src->y), + uint8 dir = map->calc_dir(bl,src->x,src->y), t_dir = unit->getdir(bl); - if( !iMap->check_dir(dir,t_dir) ) { + if( !map->check_dir(dir,t_dir) ) { int64 rd1 = damage * sc->data[SC_DEATHBOUND]->val2 / 100; // Amplify damage. trdamage += rdamage = rd1 - (*dmg = rd1 * 30 / 100); // not normalized as intended. clif->skill_damage(src, bl, timer->gettick(), status_get_amotion(src), 0, -3000, 1, RK_DEATHBOUND, sc->data[SC_DEATHBOUND]->val1, 6); @@ -5294,7 +5275,7 @@ void battle_drain(TBL_PC *sd, struct block_list *tbl, int64 rdamage, int64 ldama if (!thp && !tsp) return; - iStatus->heal(&sd->bl, thp, tsp, battle_config.show_hp_sp_drain?3:1); + status->heal(&sd->bl, thp, tsp, battle_config.show_hp_sp_drain?3:1); if (rhp || rsp) status_zap(tbl, rhp, rsp); @@ -5315,7 +5296,7 @@ int battle_damage_area( struct block_list *bl, va_list ap) { if( bl->type == BL_MOB && ((TBL_MOB*)bl)->class_ == MOBID_EMPERIUM ) return 0; if( bl != src && battle->check_target(src,bl,BCT_ENEMY) > 0 ) { - iMap->freeblock_lock(); + map->freeblock_lock(); if( src->type == BL_PC ) battle->drain((TBL_PC*)src, bl, damage, damage, status_get_race(bl), is_boss(bl)); if( amotion ) @@ -5325,7 +5306,7 @@ int battle_damage_area( struct block_list *bl, va_list ap) { clif->damage(bl,bl,tick,amotion,dmotion,damage,1,ATK_BLOCK,0); if( !(src && src->type == BL_PC && ((TBL_PC*)src)->state.autocast) ) skill->additional_effect(src, bl, CR_REFLECTSHIELD, 1, BF_WEAPON|BF_SHORT|BF_NORMAL,ATK_DEF,tick); - iMap->freeblock_unlock(); + map->freeblock_unlock(); } return 0; @@ -5350,11 +5331,11 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t sd = BL_CAST(BL_PC, src); tsd = BL_CAST(BL_PC, target); - sstatus = iStatus->get_status_data(src); - tstatus = iStatus->get_status_data(target); + sstatus = status->get_status_data(src); + tstatus = status->get_status_data(target); - sc = iStatus->get_sc(src); - tsc = iStatus->get_sc(target); + sc = status->get_sc(src); + tsc = status->get_sc(target); if (sc && !sc->count) //Avoid sc checks when there's none to check for. [Skotlex] sc = NULL; @@ -5398,19 +5379,17 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t } } } - if (sc && sc->count) { - if (sc->data[SC_CLOAKING] && !(sc->data[SC_CLOAKING]->val4 & 2)) - status_change_end(src, SC_CLOAKING, INVALID_TIMER); - else if (sc->data[SC_CLOAKINGEXCEED] && !(sc->data[SC_CLOAKINGEXCEED]->val4 & 2)) - status_change_end(src, SC_CLOAKINGEXCEED, INVALID_TIMER); - } - if( tsc && tsc->data[SC_AUTOCOUNTER] && iStatus->check_skilluse(target, src, KN_AUTOCOUNTER, 1) ) - { - uint8 dir = iMap->calc_dir(target,src->x,src->y); + if (sc && sc->count) { + if (sc->data[SC_CLOAKING] && !(sc->data[SC_CLOAKING]->val4 & 2)) + status_change_end(src, SC_CLOAKING, INVALID_TIMER); + else if (sc->data[SC_CLOAKINGEXCEED] && !(sc->data[SC_CLOAKINGEXCEED]->val4 & 2)) + status_change_end(src, SC_CLOAKINGEXCEED, INVALID_TIMER); + } + if( tsc && tsc->data[SC_AUTOCOUNTER] && status->check_skilluse(target, src, KN_AUTOCOUNTER, 1) ) { + uint8 dir = map->calc_dir(target,src->x,src->y); int t_dir = unit->getdir(target); int dist = distance_bl(src, target); - if(dist <= 0 || (!iMap->check_dir(dir,t_dir) && dist <= tstatus->rhw.range+1)) - { + if(dist <= 0 || (!map->check_dir(dir,t_dir) && dist <= tstatus->rhw.range+1)) { uint16 skill_lv = tsc->data[SC_AUTOCOUNTER]->val1; clif->skillcastcancel(target); //Remove the casting bar. [Skotlex] clif->damage(src, target, tick, sstatus->amotion, 1, 0, 1, 0, 0); //Display MISS. @@ -5425,8 +5404,8 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t uint16 skill_lv = tsc->data[SC_BLADESTOP_WAIT]->val1; int duration = skill->get_time2(MO_BLADESTOP,skill_lv); status_change_end(target, SC_BLADESTOP_WAIT, INVALID_TIMER); - if(sc_start4(src, SC_BLADESTOP, 100, sd?pc->checkskill(sd, MO_BLADESTOP):5, 0, 0, target->id, duration)) - { //Target locked. + if(sc_start4(src, SC_BLADESTOP, 100, sd?pc->checkskill(sd, MO_BLADESTOP):5, 0, 0, target->id, duration)) { + //Target locked. clif->damage(src, target, tick, sstatus->amotion, 1, 0, 1, 0, 0); //Display MISS. clif->bladestop(target, src->id, 1); sc_start4(target, SC_BLADESTOP, 100, skill_lv, 0, 0, src->id, duration); @@ -5493,7 +5472,7 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t } if(tsc && tsc->data[SC_KAAHI] && tsc->data[SC_KAAHI]->val4 == INVALID_TIMER && tstatus->hp < tstatus->max_hp) - tsc->data[SC_KAAHI]->val4 = timer->add(tick + skill->get_time2(SL_KAAHI,tsc->data[SC_KAAHI]->val1), iStatus->kaahi_heal_timer, target->id, SC_KAAHI); //Activate heal. + tsc->data[SC_KAAHI]->val4 = timer->add(tick + skill->get_time2(SL_KAAHI,tsc->data[SC_KAAHI]->val1), status->kaahi_heal_timer, target->id, SC_KAAHI); //Activate heal. wd = battle->calc_attack(BF_WEAPON, src, target, 0, 0, flag); @@ -5540,13 +5519,13 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t if( su->group && su->group->skill_id == HT_BLASTMINE) skill->blown(src, target, 3, -1, 0); } - iMap->freeblock_lock(); + map->freeblock_lock(); battle->delay_damage(tick, wd.amotion, src, target, wd.flag, 0, 0, damage, wd.dmg_lv, wd.dmotion, true); if( tsc ) { if( tsc->data[SC_DEVOTION] ) { struct status_change_entry *sce = tsc->data[SC_DEVOTION]; - struct block_list *d_bl = iMap->id2bl(sce->val1); + struct block_list *d_bl = map->id2bl(sce->val1); if( d_bl && ( (d_bl->type == BL_MER && ((TBL_MER*)d_bl)->master && ((TBL_MER*)d_bl)->master->bl.id == target->id) || @@ -5565,13 +5544,13 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t skill->attack(BF_MAGIC,&ed->bl,&ed->bl,src,EL_CIRCLE_OF_FIRE,tsc->data[SC_CIRCLE_OF_FIRE_OPTION]->val1,tick,wd.flag); } } else if( tsc->data[SC_WATER_SCREEN_OPTION] && tsc->data[SC_WATER_SCREEN_OPTION]->val1 ) { - struct block_list *e_bl = iMap->id2bl(tsc->data[SC_WATER_SCREEN_OPTION]->val1); - if( e_bl && !iStatus->isdead(e_bl) ) { + struct block_list *e_bl = map->id2bl(tsc->data[SC_WATER_SCREEN_OPTION]->val1); + if( e_bl && !status->isdead(e_bl) ) { clif->damage(e_bl,e_bl,tick,wd.amotion,wd.dmotion,damage,wd.div_,wd.type,wd.damage2); - iStatus->damage(target,e_bl,damage,0,0,0); + status->damage(target,e_bl,damage,0,0,0); // Just show damage in target. clif->damage(src, target, tick, wd.amotion, wd.dmotion, damage, wd.div_, wd.type, wd.damage2 ); - iMap->freeblock_unlock(); + map->freeblock_unlock(); return ATK_NONE; } } @@ -5588,7 +5567,7 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t if (skill_lv < 1) skill_lv = 1; sp = skill->get_sp(skill_id,skill_lv) * 2 / 3; - if (iStatus->charge(src, 0, sp)) { + if (status->charge(src, 0, sp)) { switch (skill->get_casttype(skill_id)) { case CAST_GROUND: skill->castend_pos2(src, target->x, target->y, skill_id, skill_lv, tick, flag); @@ -5603,28 +5582,30 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t } } if (sd) { - if( wd.flag&BF_SHORT && sc && sc->data[SC__AUTOSHADOWSPELL] && rnd()%100 < sc->data[SC__AUTOSHADOWSPELL]->val3 && - sd->status.skill[skill->get_index(sc->data[SC__AUTOSHADOWSPELL]->val1)].id != 0 && sd->status.skill[skill->get_index(sc->data[SC__AUTOSHADOWSPELL]->val1)].flag == SKILL_FLAG_PLAGIARIZED ) - { - int r_skill = sd->status.skill[skill->get_index(sc->data[SC__AUTOSHADOWSPELL]->val1)].id, - r_lv = sc->data[SC__AUTOSHADOWSPELL]->val2; + if( wd.flag&BF_SHORT && sc + && sc->data[SC__AUTOSHADOWSPELL] && rnd()%100 < sc->data[SC__AUTOSHADOWSPELL]->val3 + && sd->status.skill[skill->get_index(sc->data[SC__AUTOSHADOWSPELL]->val1)].id != 0 + && sd->status.skill[skill->get_index(sc->data[SC__AUTOSHADOWSPELL]->val1)].flag == SKILL_FLAG_PLAGIARIZED + ) { + int r_skill = sd->status.skill[skill->get_index(sc->data[SC__AUTOSHADOWSPELL]->val1)].id; + int r_lv = sc->data[SC__AUTOSHADOWSPELL]->val2; if (r_skill != AL_HOLYLIGHT && r_skill != PR_MAGNUS) { int type; if( (type = skill->get_casttype(r_skill)) == CAST_GROUND ) { int maxcount = 0; - if( !(BL_PC&battle_config.skill_reiteration) && - skill->get_unit_flag(r_skill)&UF_NOREITERATION ) - type = -1; + if( !(BL_PC&battle_config.skill_reiteration) + && skill->get_unit_flag(r_skill)&UF_NOREITERATION ) + type = -1; - if( BL_PC&battle_config.skill_nofootset && - skill->get_unit_flag(r_skill)&UF_NOFOOTSET ) - type = -1; + if( BL_PC&battle_config.skill_nofootset + && skill->get_unit_flag(r_skill)&UF_NOFOOTSET ) + type = -1; - if( BL_PC&battle_config.land_skill_limit && - (maxcount = skill->get_maxcount(r_skill, r_lv)) > 0 - ) { + if( BL_PC&battle_config.land_skill_limit + && (maxcount = skill->get_maxcount(r_skill, r_lv)) > 0 + ) { int v; for(v=0;v<MAX_SKILLUNITGROUP && sd->ud.skillunit[v] && maxcount;v++) { if(sd->ud.skillunit[v]->skill_id == r_skill) @@ -5634,10 +5615,10 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t type = -1; } - if( type != CAST_GROUND ){ - clif->skill_fail(sd,r_skill,USESKILL_FAIL_LEVEL,0); - iMap->freeblock_unlock(); - return wd.dmg_lv; + if( type != CAST_GROUND ) { + clif->skill_fail(sd,r_skill,USESKILL_FAIL_LEVEL,0); + map->freeblock_unlock(); + return wd.dmg_lv; } } @@ -5670,12 +5651,14 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t } if (tsc) { - if (tsc->data[SC_POISONREACT] && - (rnd()%100 < tsc->data[SC_POISONREACT]->val3 - || sstatus->def_ele == ELE_POISON) && -// check_distance_bl(src, target, tstatus->rhw.range+1) && Doesn't checks range! o.O; - iStatus->check_skilluse(target, src, TF_POISON, 0) - ) { //Poison React + if (tsc->data[SC_POISONREACT] + && ( rnd()%100 < tsc->data[SC_POISONREACT]->val3 + || sstatus->def_ele == ELE_POISON + ) + /* && check_distance_bl(src, target, tstatus->rhw.range+1) Doesn't check range! o.O; */ + && status->check_skilluse(target, src, TF_POISON, 0) + ) { + //Poison React struct status_change_entry *sce = tsc->data[SC_POISONREACT]; if (sstatus->def_ele == ELE_POISON) { sce->val2 = 0; @@ -5688,7 +5671,7 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t status_change_end(target, SC_POISONREACT, INVALID_TIMER); } } - iMap->freeblock_unlock(); + map->freeblock_unlock(); return wd.dmg_lv; } @@ -5710,8 +5693,7 @@ int battle_check_undead(int race,int element) } //Returns the upmost level master starting with the given object -struct block_list* battle_get_master(struct block_list *src) -{ +struct block_list* battle_get_master(struct block_list *src) { struct block_list *prev; //Used for infinite loop check (master of yourself?) do { prev = src; @@ -5722,7 +5704,7 @@ struct block_list* battle_get_master(struct block_list *src) break; case BL_MOB: if (((TBL_MOB*)src)->master_id) - src = iMap->id2bl(((TBL_MOB*)src)->master_id); + src = map->id2bl(((TBL_MOB*)src)->master_id); break; case BL_HOM: if (((TBL_HOM*)src)->master) @@ -5738,7 +5720,7 @@ struct block_list* battle_get_master(struct block_list *src) break; case BL_SKILL: if (((TBL_SKILL*)src)->group && ((TBL_SKILL*)src)->group->src_id) - src = iMap->id2bl(((TBL_SKILL*)src)->group->src_id); + src = map->id2bl(((TBL_SKILL*)src)->group->src_id); break; } } while (src && src != prev); @@ -5792,7 +5774,7 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f switch( target->type ) { // Checks on actual target case BL_PC: { - struct status_change* sc = iStatus->get_sc(src); + struct status_change* sc = status->get_sc(src); if (((TBL_PC*)target)->invincible_timer != INVALID_TIMER || pc_isinvisible((TBL_PC*)target)) return -1; //Cannot be targeted yet. if( sc && sc->count ) { @@ -5883,8 +5865,7 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f return 0; } //end switch actual target - switch( t_bl->type ) - { //Checks on target master + switch( t_bl->type ) { //Checks on target master case BL_PC: { struct map_session_data *sd; @@ -5905,12 +5886,12 @@ 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) && maplist[m].flag.gvg_castle) && md->guardian_data && md->guardian_data->guild_id ) + if( !((map->agit_flag || map->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; } default: break; //other type doesn't have slave yet - } //end switch master target + } //end switch master target switch( src->type ) { //Checks on actual src type case BL_PET: @@ -5937,7 +5918,7 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f if (t_bl->type == BL_MOB && ((TBL_MOB*)t_bl)->class_ == MOBID_EMPERIUM && flag&BCT_ENEMY) return 0; //mercenary may not attack Emperium break; - } //end switch actual src + } //end switch actual src switch( s_bl->type ) { //Checks on source master case BL_PC: @@ -5965,7 +5946,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) && maplist[m].flag.gvg_castle) && md->guardian_data && md->guardian_data->guild_id ) + if( !((map->agit_flag || map->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 ) @@ -5990,7 +5971,7 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f if (t_bl->type != s_bl->type) state |= BCT_ENEMY; break; - } //end switch on src master + } //end switch on src master if( (flag&BCT_ALL) == BCT_ALL ) { //All actually stands for all attackable chars @@ -6018,8 +5999,8 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f tbg_id = bg->team_get_id(t_bl); } 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) + int s_party = status->get_party_id(s_bl); + if( s_party && s_party == status->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) ) @@ -6028,8 +6009,8 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f state |= 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); + int s_guild = status->get_guild_id(s_bl); + int t_guild = status->get_guild_id(t_bl); 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))) @@ -6048,24 +6029,22 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f (sd->class_&MAPID_UPPERMASK) == MAPID_NOVICE || (sd2->class_&MAPID_UPPERMASK) == MAPID_NOVICE || (int)sd->status.base_level < battle_config.pk_min_level || - (int)sd2->status.base_level < battle_config.pk_min_level || + (int)sd2->status.base_level < battle_config.pk_min_level || (battle_config.pk_level_range && abs((int)sd->status.base_level - (int)sd2->status.base_level) > battle_config.pk_level_range) ) state &= ~BCT_ENEMY; } - }//end map_flag_vs chk rivality + }//end map_flag_vs chk rivality else { //Non pvp/gvg, check party/guild settings. - if( flag&BCT_PARTY || state&BCT_ENEMY ) - { - int s_party = iStatus->get_party_id(s_bl); - if(s_party && s_party == iStatus->get_party_id(t_bl)) + if( flag&BCT_PARTY || state&BCT_ENEMY ) { + int s_party = status->get_party_id(s_bl); + if(s_party && s_party == status->get_party_id(t_bl)) state |= BCT_PARTY; } - if( flag&BCT_GUILD || state&BCT_ENEMY ) - { - int s_guild = iStatus->get_guild_id(s_bl); - int t_guild = iStatus->get_guild_id(t_bl); + if( flag&BCT_GUILD || state&BCT_ENEMY ) { + int s_guild = status->get_guild_id(s_bl); + int t_guild = status->get_guild_id(t_bl); if(s_guild && t_guild && (s_guild == t_guild || (!(flag&BCT_SAMEGUILD) && guild->isallied(s_guild, t_guild)))) state |= BCT_GUILD; } @@ -6585,7 +6564,7 @@ void Hercules_report(char* date, char *time_c) { #endif /* non-define part */ - if( iMap->db_use_sql_item_db || iMap->db_use_sql_mob_db || iMap->db_use_sql_mob_skill_db ) + if( map->db_use_sql_item_db || map->db_use_sql_mob_db || map->db_use_sql_mob_skill_db ) config |= C_SQL_DBS; //TODO: split this config into three. if( logs->config.sql_logs ) @@ -6620,7 +6599,7 @@ void Hercules_report(char* date, char *time_c) { safestrncpy((char*)WBUFP(buf,6 + 12 + 9), timestring, 24); safestrncpy((char*)WBUFP(buf,6 + 12 + 9 + 24), git[0] != HERC_UNKNOWN_VER ? git : svn[0] != HERC_UNKNOWN_VER ? svn : "Unknown", 41); - WBUFL(buf,6 + 12 + 9 + 24 + 41) = iMap->getusers(); + WBUFL(buf,6 + 12 + 9 + 24 + 41) = map->getusers(); WBUFL(buf,6 + 12 + 9 + 24 + 41 + 4) = config; WBUFL(buf,6 + 12 + 9 + 24 + 41 + 4 + 4) = bd_size; @@ -6763,7 +6742,7 @@ int battle_config_read(const char* cfgName) } void do_init_battle(void) { - delay_damage_ers = ers_new(sizeof(struct delay_damage),"battle.c::delay_damage_ers",ERS_OPT_CLEAR); + battle->delay_damage_ers = ers_new(sizeof(struct delay_damage),"battle.c::delay_damage_ers",ERS_OPT_CLEAR); timer->add_func_list(battle_delay_damage_sub, "battle_delay_damage_sub"); #ifndef STATS_OPT_OUT @@ -6774,7 +6753,7 @@ void do_init_battle(void) { } void do_final_battle(void) { - ers_destroy(delay_damage_ers); + ers_destroy(battle->delay_damage_ers); } /* initialize the interface */ @@ -6783,6 +6762,9 @@ void battle_defaults(void) { battle->bc = &battle_config; + memset(battle->attr_fix_table, 0, sizeof(battle->attr_fix_table)); + battle->delay_damage_ers = NULL; + battle->init = do_init_battle; battle->final = do_final_battle; diff --git a/src/map/battle.h b/src/map/battle.h index 6909160c9..8878962b8 100644 --- a/src/map/battle.h +++ b/src/map/battle.h @@ -6,6 +6,7 @@ #define _BATTLE_H_ #include "../common/cbasetypes.h" +#include "map.h" //ELE_MAX /** * Declarations @@ -462,12 +463,20 @@ struct Battle_Config { } battle_config; - -/** - * Vars - **/ -//attribute table -extern int attr_fix_table[4][10][10]; +// Dammage delayed info +struct delay_damage { + int src_id; + int target_id; + int64 damage; + int delay; + unsigned short distance; + uint16 skill_lv; + uint16 skill_id; + enum damage_lv dmg_lv; + unsigned short attack_type; + bool additional_effects; + enum bl_type src_type; +}; /** * Battle.c Interface @@ -475,6 +484,9 @@ extern int attr_fix_table[4][10][10]; struct battle_interface { /* */ struct Battle_Config *bc; + /* */ + int attr_fix_table[4][ELE_MAX][ELE_MAX]; + struct eri *delay_damage_ers; //For battle delay damage structures. /* init */ void (*init) (void); /* final */ @@ -496,7 +508,7 @@ struct battle_interface { /* drain damage */ void (*drain) (struct map_session_data *sd, struct block_list *tbl, int64 rdamage, int64 ldamage, int race, int boss); /* damage return/reflect */ - int64 (*calc_return_damage) (struct block_list *bl, struct block_list *src, int64 *, int flag, uint16 skill_id, int *); + int64 (*calc_return_damage) (struct block_list *bl, struct block_list *src, int64 *, int flag, uint16 skill_id, int *rdelay); /* attribute rate */ int (*attr_ratio) (int atk_elem, int def_type, int def_lv); /* applies attribute modifiers */ diff --git a/src/map/battleground.c b/src/map/battleground.c index db6d6cd5a..160d2f96e 100644 --- a/src/map/battleground.c +++ b/src/map/battleground.c @@ -163,7 +163,7 @@ int bg_member_respawn(struct map_session_data *sd) { if( bgd->mapindex == 0 ) return 0; // Respawn not handled by Core pc->setpos(sd, bgd->mapindex, bgd->x, bgd->y, CLR_OUTSIGHT); - iStatus->revive(&sd->bl, 1, 100); + status->revive(&sd->bl, 1, 100); return 1; // Warped } @@ -200,7 +200,7 @@ int bg_team_get_id(struct block_list *bl) { { struct map_session_data *msd; struct mob_data *md = (TBL_MOB*)bl; - if( md->special_state.ai && (msd = iMap->id2sd(md->master_id)) != NULL ) + if( md->special_state.ai && (msd = map->id2sd(md->master_id)) != NULL ) return msd->bg_id; return md->bg_id; } @@ -448,7 +448,7 @@ void bg_queue_ready_ack (struct bg_arena *arena, struct map_session_data *sd, bo sd->bg_queue.ready = 1; for( i = 0; i < queue->size; i++ ) { - if( queue->item[i] > 0 && ( sd = iMap->id2sd(queue->item[i]) ) ) { + if( queue->item[i] > 0 && ( sd = map->id2sd(queue->item[i]) ) ) { if( sd->bg_queue.ready == 1 ) count++; } @@ -488,7 +488,7 @@ void bg_match_over(struct bg_arena *arena, bool canceled) { for( i = 0; i < queue->size; i++ ) { struct map_session_data * sd = NULL; - if( queue->item[i] > 0 && ( sd = iMap->id2sd(queue->item[i]) ) ) { + if( queue->item[i] > 0 && ( sd = map->id2sd(queue->item[i]) ) ) { if( sd->bg_queue.arena ) { bg->team_leave(sd, 0); bg->queue_pc_cleanup(sd); @@ -513,7 +513,7 @@ void bg_begin(struct bg_arena *arena) { for( i = 0; i < queue->size; i++ ) { struct map_session_data * sd = NULL; - if( queue->item[i] > 0 && ( sd = iMap->id2sd(queue->item[i]) ) ) { + if( queue->item[i] > 0 && ( sd = map->id2sd(queue->item[i]) ) ) { if( sd->bg_queue.ready == 1 ) count++; else @@ -547,7 +547,7 @@ void bg_queue_pregame(struct bg_arena *arena) { for( i = 0; i < queue->size; i++ ) { struct map_session_data * sd = NULL; - if( queue->item[i] > 0 && ( sd = iMap->id2sd(queue->item[i]) ) ) { + if( queue->item[i] > 0 && ( sd = map->id2sd(queue->item[i]) ) ) { clif->bgqueue_battlebegins(sd,arena->id,SELF); } } diff --git a/src/map/buyingstore.c b/src/map/buyingstore.c index f943b2a20..92bf9b869 100644 --- a/src/map/buyingstore.c +++ b/src/map/buyingstore.c @@ -15,37 +15,13 @@ #include "pc.h" // struct map_session_data #include "chrif.h" - -/// constants (client-side restrictions) -#define BUYINGSTORE_MAX_PRICE 99990000 -#define BUYINGSTORE_MAX_AMOUNT 9999 - - -/// failure constants for clif functions -enum e_buyingstore_failure -{ - BUYINGSTORE_CREATE = 1, // "Failed to open buying store." - BUYINGSTORE_CREATE_OVERWEIGHT = 2, // "Total amount of then possessed items exceeds the weight limit by %d. Please re-enter." - BUYINGSTORE_TRADE_BUYER_ZENY = 3, // "All items within the buy limit were purchased." - BUYINGSTORE_TRADE_BUYER_NO_ITEMS = 4, // "All items were purchased." - BUYINGSTORE_TRADE_SELLER_FAILED = 5, // "The deal has failed." - BUYINGSTORE_TRADE_SELLER_COUNT = 6, // "The trade failed, because the entered amount of item %s is higher, than the buyer is willing to buy." - BUYINGSTORE_TRADE_SELLER_ZENY = 7, // "The trade failed, because the buyer is lacking required balance." - BUYINGSTORE_CREATE_NO_INFO = 8, // "No sale (purchase) information available." -}; - - -static unsigned int buyingstore_nextid = 0; -static const short buyingstore_blankslots[MAX_SLOTS] = { 0 }; // used when checking whether or not an item's card slots are blank struct buyingstore_interface buyingstore_s; /// Returns unique buying store id -static unsigned int buyingstore_getuid(void) -{ - return buyingstore_nextid++; +unsigned int buyingstore_getuid(void) { + return buyingstore->nextid++; } - bool buyingstore_setup(struct map_session_data* sd, unsigned char slots) { if( !battle_config.feature_buying_store || sd->state.vending || sd->state.buyingstore || sd->state.trading || slots == 0 ) @@ -64,8 +40,8 @@ bool buyingstore_setup(struct map_session_data* sd, unsigned char slots) return false; } - if( iMap->getcell(sd->bl.m, sd->bl.x, sd->bl.y, CELL_CHKNOVENDING) ) - {// custom: no vending cells + if( map->getcell(sd->bl.m, sd->bl.x, sd->bl.y, CELL_CHKNOVENDING) ) { + // custom: no vending cells clif->message(sd->fd, msg_txt(204)); // "You can't open a shop on this cell." return false; } @@ -119,8 +95,8 @@ void buyingstore_create(struct map_session_data* sd, int zenylimit, unsigned cha return; } - if( iMap->getcell(sd->bl.m, sd->bl.x, sd->bl.y, CELL_CHKNOVENDING) ) - {// custom: no vending cells + if( map->getcell(sd->bl.m, sd->bl.x, sd->bl.y, CELL_CHKNOVENDING) ) { + // custom: no vending cells clif->message(sd->fd, msg_txt(204)); // "You can't open a shop on this cell." return; } @@ -227,8 +203,8 @@ void buyingstore_open(struct map_session_data* sd, int account_id) return; } - if( ( pl_sd = iMap->id2sd(account_id) ) == NULL || !pl_sd->state.buyingstore ) - {// not online or not buying + if( ( pl_sd = map->id2sd(account_id) ) == NULL || !pl_sd->state.buyingstore ) { + // not online or not buying return; } @@ -266,8 +242,8 @@ void buyingstore_trade(struct map_session_data* sd, int account_id, unsigned int return; } - if( ( pl_sd = iMap->id2sd(account_id) ) == NULL || !pl_sd->state.buyingstore || pl_sd->buyer_id != buyer_id ) - {// not online, not buying or not same store + if( ( pl_sd = map->id2sd(account_id) ) == NULL || !pl_sd->state.buyingstore || pl_sd->buyer_id != buyer_id ) { + // not online, not buying or not same store clif->buyingstore_trade_failed_seller(sd, BUYINGSTORE_TRADE_SELLER_FAILED, 0); return; } @@ -314,7 +290,7 @@ void buyingstore_trade(struct map_session_data* sd, int account_id, unsigned int return; } - if( sd->status.inventory[index].expire_time || !itemdb_cantrade(&sd->status.inventory[index], pc->get_group_level(sd), pc->get_group_level(pl_sd)) || memcmp(sd->status.inventory[index].card, buyingstore_blankslots, sizeof(buyingstore_blankslots)) ) + if( sd->status.inventory[index].expire_time || !itemdb_cantrade(&sd->status.inventory[index], pc->get_group_level(sd), pc->get_group_level(pl_sd)) || memcmp(sd->status.inventory[index].card, buyingstore->blankslots, sizeof(buyingstore->blankslots)) ) {// non-tradable item clif->buyingstore_trade_failed_seller(sd, BUYINGSTORE_TRADE_SELLER_FAILED, nameid); return; @@ -383,7 +359,7 @@ void buyingstore_trade(struct map_session_data* sd, int account_id, unsigned int clif->buyingstore_update_item(pl_sd, nameid, amount); } - if( iMap->save_settings&128 ) { + if( map->save_settings&128 ) { chrif->save(sd, 0); chrif->save(pl_sd, 0); } @@ -407,9 +383,8 @@ void buyingstore_trade(struct map_session_data* sd, int account_id, unsigned int buyingstore_close(pl_sd); // remove auto-trader - if( pl_sd->state.autotrade ) - { - iMap->quit(pl_sd); + if( pl_sd->state.autotrade ) { + map->quit(pl_sd); } } @@ -470,7 +445,7 @@ bool buyingstore_searchall(struct map_session_data* sd, const struct s_search_st ; } - if( !searchstore->result(s->search_sd, sd->buyer_id, sd->status.account_id, sd->message, it->nameid, it->amount, it->price, buyingstore_blankslots, 0) ) + if( !searchstore->result(s->search_sd, sd->buyer_id, sd->status.account_id, sd->message, it->nameid, it->amount, it->price, buyingstore->blankslots, 0) ) {// result set full return false; } @@ -481,6 +456,9 @@ bool buyingstore_searchall(struct map_session_data* sd, const struct s_search_st void buyingstore_defaults(void) { buyingstore = &buyingstore_s; + buyingstore->nextid = 0; + memset(buyingstore->blankslots,0,sizeof(buyingstore->blankslots)); + /* */ buyingstore->setup = buyingstore_setup; buyingstore->create = buyingstore_create; buyingstore->close = buyingstore_close; @@ -488,5 +466,6 @@ void buyingstore_defaults(void) { buyingstore->trade = buyingstore_trade; buyingstore->search = buyingstore_search; buyingstore->searchall = buyingstore_searchall; + buyingstore->getuid = buyingstore_getuid; } diff --git a/src/map/buyingstore.h b/src/map/buyingstore.h index ae5fcb9e5..b0db40661 100644 --- a/src/map/buyingstore.h +++ b/src/map/buyingstore.h @@ -5,10 +5,38 @@ #ifndef _BUYINGSTORE_H_ #define _BUYINGSTORE_H_ +/** + * Declarations + **/ struct s_search_store_search; +/** + * Defines + **/ #define MAX_BUYINGSTORE_SLOTS 5 +/// constants (client-side restrictions) +#define BUYINGSTORE_MAX_PRICE 99990000 +#define BUYINGSTORE_MAX_AMOUNT 9999 + +/** + * Enumerations + **/ +/// failure constants for clif functions +enum e_buyingstore_failure { + BUYINGSTORE_CREATE = 1, // "Failed to open buying store." + BUYINGSTORE_CREATE_OVERWEIGHT = 2, // "Total amount of then possessed items exceeds the weight limit by %d. Please re-enter." + BUYINGSTORE_TRADE_BUYER_ZENY = 3, // "All items within the buy limit were purchased." + BUYINGSTORE_TRADE_BUYER_NO_ITEMS = 4, // "All items were purchased." + BUYINGSTORE_TRADE_SELLER_FAILED = 5, // "The deal has failed." + BUYINGSTORE_TRADE_SELLER_COUNT = 6, // "The trade failed, because the entered amount of item %s is higher, than the buyer is willing to buy." + BUYINGSTORE_TRADE_SELLER_ZENY = 7, // "The trade failed, because the buyer is lacking required balance." + BUYINGSTORE_CREATE_NO_INFO = 8, // "No sale (purchase) information available." +}; + +/** + * Structures + **/ struct s_buyingstore_item { int price; unsigned short amount; @@ -21,7 +49,13 @@ struct s_buyingstore { unsigned char slots; }; +/** + * Interface + **/ struct buyingstore_interface { + unsigned int nextid; + short blankslots[MAX_SLOTS]; // used when checking whether or not an item's card slots are blank + /* */ bool (*setup) (struct map_session_data* sd, unsigned char slots); void (*create) (struct map_session_data* sd, int zenylimit, unsigned char result, const char* storename, const uint8* itemlist, unsigned int count); void (*close) (struct map_session_data* sd); @@ -29,6 +63,7 @@ struct buyingstore_interface { void (*trade) (struct map_session_data* sd, int account_id, unsigned int buyer_id, const uint8* itemlist, unsigned int count); bool (*search) (struct map_session_data* sd, unsigned short nameid); bool (*searchall) (struct map_session_data* sd, const struct s_search_store_search* s); + unsigned int (*getuid) (void); }; struct buyingstore_interface *buyingstore; diff --git a/src/map/chat.c b/src/map/chat.c index 21d49cfc8..d6fad4d94 100644 --- a/src/map/chat.c +++ b/src/map/chat.c @@ -1,5 +1,6 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder +// Copyright (c) Hercules Dev Team, licensed under GNU GPL. +// See the LICENSE file +// Portions Copyright (c) Athena Dev Teams #include "../common/cbasetypes.h" #include "../common/malloc.h" @@ -19,16 +20,16 @@ #include <stdio.h> #include <string.h> - -int chat_triggerevent(struct chat_data *cd); // forward declaration +struct chat_interface chat_s; /// Initializes a chatroom object (common functionality for both pc and npc chatrooms). /// Returns a chatroom object on success, or NULL on failure. -static struct chat_data* chat_createchat(struct block_list* bl, const char* title, const char* pass, int limit, bool pub, int trigger, const char* ev, int zeny, int minLvl, int maxLvl) +struct chat_data* chat_createchat(struct block_list* bl, const char* title, const char* pass, int limit, bool pub, int trigger, const char* ev, int zeny, int minLvl, int maxLvl) { struct chat_data* cd; nullpo_retr(NULL, bl); + /* Given the overhead and the numerous instances (npc allocatted or otherwise) wouldn't it be benefitial to have it use ERS? [Ind] */ cd = (struct chat_data *) aMalloc(sizeof(struct chat_data)); safestrncpy(cd->title, title, sizeof(cd->title)); @@ -44,20 +45,19 @@ static struct chat_data* chat_createchat(struct block_list* bl, const char* titl cd->owner = bl; safestrncpy(cd->npc_event, ev, sizeof(cd->npc_event)); - cd->bl.id = iMap->get_new_object_id(); + cd->bl.id = map->get_new_object_id(); cd->bl.m = bl->m; cd->bl.x = bl->x; cd->bl.y = bl->y; cd->bl.type = BL_CHAT; cd->bl.next = cd->bl.prev = NULL; - if( cd->bl.id == 0 ) - { + if( cd->bl.id == 0 ) { aFree(cd); cd = NULL; } - iMap->addiddb(&cd->bl); + map->addiddb(&cd->bl); if( bl->type != BL_NPC ) cd->kick_list = idb_alloc(DB_OPT_BASE); @@ -85,15 +85,14 @@ int chat_createpcchat(struct map_session_data* sd, const char* title, const char return 0; //Can't create chatrooms on this map. } - if( iMap->getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKNOCHAT) ) - { + if( map->getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKNOCHAT) ) { clif->message (sd->fd, msg_txt(665)); return 0; } pc_stop_walking(sd,1); - cd = chat_createchat(&sd->bl, title, pass, limit, pub, 0, "", 0, 1, MAX_LEVEL); + cd = chat->create(&sd->bl, title, pass, limit, pub, 0, "", 0, 1, MAX_LEVEL); if( cd ) { cd->users = 1; cd->usersd[0] = sd; @@ -110,12 +109,11 @@ int chat_createpcchat(struct map_session_data* sd, const char* title, const char /*========================================== * join an existing chatroom *------------------------------------------*/ -int chat_joinchat(struct map_session_data* sd, int chatid, const char* pass) -{ +int chat_joinchat(struct map_session_data* sd, int chatid, const char* pass) { struct chat_data* cd; nullpo_ret(sd); - cd = (struct chat_data*)iMap->id2bl(chatid); + cd = (struct chat_data*)map->id2bl(chatid); if( cd == NULL || cd->bl.type != BL_CHAT || cd->bl.m != sd->bl.m || sd->state.vending || sd->state.buyingstore || sd->chatID || ((cd->owner->type == BL_NPC) ? cd->users+1 : cd->users) >= cd->limit ) { @@ -158,7 +156,7 @@ int chat_joinchat(struct map_session_data* sd, int chatid, const char* pass) clif->addchat(cd, sd); //Reports To the person who already in the chat clif->dispchat(cd, 0); //Reported number of changes to the people around - chat_triggerevent(cd); //Event + chat->trigger_event(cd); //Event return 0; } @@ -167,17 +165,15 @@ int chat_joinchat(struct map_session_data* sd, int chatid, const char* pass) /*========================================== * leave a chatroom *------------------------------------------*/ -int chat_leavechat(struct map_session_data* sd, bool kicked) -{ +int chat_leavechat(struct map_session_data* sd, bool kicked) { struct chat_data* cd; int i; int leavechar; nullpo_retr(1, sd); - cd = (struct chat_data*)iMap->id2bl(sd->chatID); - if( cd == NULL ) - { + cd = (struct chat_data*)map->id2bl(sd->chatID); + if( cd == NULL ) { pc_setchatid(sd, 0); return 1; } @@ -201,15 +197,15 @@ int chat_leavechat(struct map_session_data* sd, bool kicked) if( cd->users == 0 && cd->owner->type == BL_PC ) { // Delete empty chatroom struct skill_unit* su; - struct skill_unit_group* group; + struct skill_unit_group* group; clif->clearchat(cd, 0); db_destroy(cd->kick_list); - iMap->deliddb(&cd->bl); - iMap->delblock(&cd->bl); - iMap->freeblock(&cd->bl); + map->deliddb(&cd->bl); + map->delblock(&cd->bl); + map->freeblock(&cd->bl); - su = iMap->find_skill_unit_oncell(&sd->bl, sd->bl.x, sd->bl.y, AL_WARP, NULL, 0); + su = map->find_skill_unit_oncell(&sd->bl, sd->bl.x, sd->bl.y, AL_WARP, NULL, 0); group = (su != NULL) ? su->group : NULL; if (group != NULL) skill->unit_onplace(su, &sd->bl, group->tick); @@ -217,21 +213,20 @@ int chat_leavechat(struct map_session_data* sd, bool kicked) return 1; } - if( leavechar == 0 && cd->owner->type == BL_PC ) - { // Set and announce new owner + if( leavechar == 0 && cd->owner->type == BL_PC ) { + // Set and announce new owner cd->owner = (struct block_list*) cd->usersd[0]; clif->changechatowner(cd, cd->usersd[0]); clif->clearchat(cd, 0); //Adjust Chat location after owner has been changed. - iMap->delblock( &cd->bl ); + map->delblock( &cd->bl ); cd->bl.x=cd->usersd[0]->bl.x; cd->bl.y=cd->usersd[0]->bl.y; - iMap->addblock( &cd->bl ); + map->addblock( &cd->bl ); clif->dispchat(cd,0); - } - else + } else clif->dispchat(cd,0); // refresh chatroom return 0; @@ -240,15 +235,14 @@ int chat_leavechat(struct map_session_data* sd, bool kicked) /*========================================== * change a chatroom's owner *------------------------------------------*/ -int chat_changechatowner(struct map_session_data* sd, const char* nextownername) -{ +int chat_changechatowner(struct map_session_data* sd, const char* nextownername) { struct chat_data* cd; struct map_session_data* tmpsd; int i; nullpo_retr(1, sd); - cd = (struct chat_data*)iMap->id2bl(sd->chatID); + cd = (struct chat_data*)map->id2bl(sd->chatID); if( cd == NULL || (struct block_list*) sd != cd->owner ) return 1; @@ -269,10 +263,10 @@ int chat_changechatowner(struct map_session_data* sd, const char* nextownername) cd->usersd[0] = tmpsd; // set the new chatroom position - iMap->delblock( &cd->bl ); + map->delblock( &cd->bl ); cd->bl.x = cd->owner->x; cd->bl.y = cd->owner->y; - iMap->addblock( &cd->bl ); + map->addblock( &cd->bl ); // and display again clif->dispchat(cd,0); @@ -283,13 +277,12 @@ int chat_changechatowner(struct map_session_data* sd, const char* nextownername) /*========================================== * change a chatroom's status (title, etc) *------------------------------------------*/ -int chat_changechatstatus(struct map_session_data* sd, const char* title, const char* pass, int limit, bool pub) -{ +int chat_changechatstatus(struct map_session_data* sd, const char* title, const char* pass, int limit, bool pub) { struct chat_data* cd; nullpo_retr(1, sd); - cd = (struct chat_data*)iMap->id2bl(sd->chatID); + cd = (struct chat_data*)map->id2bl(sd->chatID); if( cd==NULL || (struct block_list *)sd != cd->owner ) return 1; @@ -307,14 +300,13 @@ int chat_changechatstatus(struct map_session_data* sd, const char* title, const /*========================================== * kick an user from a chatroom *------------------------------------------*/ -int chat_kickchat(struct map_session_data* sd, const char* kickusername) -{ +int chat_kickchat(struct map_session_data* sd, const char* kickusername) { struct chat_data* cd; int i; nullpo_retr(1, sd); - cd = (struct chat_data *)iMap->id2bl(sd->chatID); + cd = (struct chat_data *)map->id2bl(sd->chatID); if( cd==NULL || (struct block_list *)sd != cd->owner ) return -1; @@ -328,7 +320,7 @@ int chat_kickchat(struct map_session_data* sd, const char* kickusername) idb_put(cd->kick_list,cd->usersd[i]->status.char_id,(void*)1); - chat->leavechat(cd->usersd[i],1); + chat->leave(cd->usersd[i],1); return 0; } @@ -348,7 +340,7 @@ int chat_createnpcchat(struct npc_data* nd, const char* title, int limit, bool p return 0; } - cd = chat_createchat(&nd->bl, title, "", limit, pub, trigger, ev, zeny, minLvl, maxLvl); + cd = chat->create(&nd->bl, title, "", limit, pub, trigger, ev, zeny, minLvl, maxLvl); if( cd ) { nd->chat_id = cd->bl.id; @@ -359,20 +351,19 @@ int chat_createnpcchat(struct npc_data* nd, const char* title, int limit, bool p } /// Removes the chatroom from the npc. -int chat_deletenpcchat(struct npc_data* nd) -{ +int chat_deletenpcchat(struct npc_data* nd) { struct chat_data *cd; nullpo_ret(nd); - cd = (struct chat_data*)iMap->id2bl(nd->chat_id); + cd = (struct chat_data*)map->id2bl(nd->chat_id); if( cd == NULL ) return 0; - chat->npckickall(cd); + chat->npc_kick_all(cd); clif->clearchat(cd, 0); - iMap->deliddb(&cd->bl); - iMap->delblock(&cd->bl); - iMap->freeblock(&cd->bl); + map->deliddb(&cd->bl); + map->delblock(&cd->bl); + map->freeblock(&cd->bl); nd->chat_id = 0; return 0; @@ -397,7 +388,7 @@ int chat_enableevent(struct chat_data* cd) nullpo_ret(cd); cd->trigger &= 0x7f; - chat_triggerevent(cd); + chat->trigger_event(cd); return 0; } @@ -416,7 +407,7 @@ int chat_npckickall(struct chat_data* cd) nullpo_ret(cd); while( cd->users > 0 ) - chat->leavechat(cd->usersd[cd->users-1],0); + chat->leave(cd->usersd[cd->users-1],0); return 0; } @@ -428,18 +419,19 @@ int chat_npckickall(struct chat_data* cd) *-------------------------------------*/ void chat_defaults(void) { chat = &chat_s; - /* funcs */ - chat->createpcchat = chat_createpcchat; - chat->joinchat = chat_joinchat; - chat->leavechat = chat_leavechat; - chat->changechatowner = chat_changechatowner; - chat->changechatstatus = chat_changechatstatus; - chat->kickchat = chat_kickchat; - - chat->createnpcchat = chat_createnpcchat; - chat->deletenpcchat = chat_deletenpcchat; - chat->enableevent = chat_enableevent; - chat->disableevent = chat_disableevent; - chat->npckickall = chat_npckickall; + /* funcs */ + chat->create_pc_chat = chat_createpcchat; + chat->join = chat_joinchat; + chat->leave = chat_leavechat; + chat->change_owner = chat_changechatowner; + chat->change_status = chat_changechatstatus; + chat->kick = chat_kickchat; + chat->create_npc_chat = chat_createnpcchat; + chat->delete_npc_chat = chat_deletenpcchat; + chat->enable_event = chat_enableevent; + chat->disable_event = chat_disableevent; + chat->npc_kick_all = chat_npckickall; + chat->trigger_event = chat_triggerevent; + chat->create = chat_createchat; } diff --git a/src/map/chat.h b/src/map/chat.h index a7736e9f3..695e59b6e 100644 --- a/src/map/chat.h +++ b/src/map/chat.h @@ -1,12 +1,15 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder +// Copyright (c) Hercules Dev Team, licensed under GNU GPL. +// See the LICENSE file +// Portions Copyright (c) Athena Dev Teams + #ifndef _CHAT_H_ #define _CHAT_H_ + #include "map.h" // struct block_list, CHATROOM_TITLE_SIZE + struct map_session_data; struct chat_data; - struct chat_data { struct block_list bl; // data for this map object char title[CHATROOM_TITLE_SIZE]; // room title @@ -21,33 +24,32 @@ struct chat_data { struct map_session_data* usersd[20]; struct block_list* owner; char npc_event[EVENT_NAME_LENGTH]; + /* isn't this a waste? there is a enormous overhead, wouldn't something like skill_blockpc_start be better here? [Ind] */ DBMap* kick_list; //DBMap of users who were kicked from this chat }; - - - /*===================================== * Interface : chat.h * Generated by HerculesInterfaceMaker * created by Susu *-------------------------------------*/ struct chat_interface { - /* funcs */ - - int (*createpcchat) (struct map_session_data* sd, const char* title, const char* pass, int limit, bool pub); - int (*joinchat) (struct map_session_data* sd, int chatid, const char* pass); - int (*leavechat) (struct map_session_data* sd, bool kicked); - int (*changechatowner) (struct map_session_data* sd, const char* nextownername); - int (*changechatstatus) (struct map_session_data* sd, const char* title, const char* pass, int limit, bool pub); - int (*kickchat) (struct map_session_data* sd, const char* kickusername); - int (*createnpcchat) (struct npc_data* nd, const char* title, int limit, bool pub, int trigger, const char* ev, int zeny, int minLvl, int maxLvl); - int (*deletenpcchat) (struct npc_data* nd); - int (*enableevent) (struct chat_data* cd); - int (*disableevent) (struct chat_data* cd); - int (*npckickall) (struct chat_data* cd); -} chat_s; + /* funcs */ + int (*create_pc_chat) (struct map_session_data* sd, const char* title, const char* pass, int limit, bool pub); + int (*join) (struct map_session_data* sd, int chatid, const char* pass); + int (*leave) (struct map_session_data* sd, bool kicked); + int (*change_owner) (struct map_session_data* sd, const char* nextownername); + int (*change_status) (struct map_session_data* sd, const char* title, const char* pass, int limit, bool pub); + int (*kick) (struct map_session_data* sd, const char* kickusername); + int (*create_npc_chat) (struct npc_data* nd, const char* title, int limit, bool pub, int trigger, const char* ev, int zeny, int minLvl, int maxLvl); + int (*delete_npc_chat) (struct npc_data* nd); + int (*enable_event) (struct chat_data* cd); + int (*disable_event) (struct chat_data* cd); + int (*npc_kick_all) (struct chat_data* cd); + int (*trigger_event) (struct chat_data *cd); + struct chat_data* (*create) (struct block_list* bl, const char* title, const char* pass, int limit, bool pub, int trigger, const char* ev, int zeny, int minLvl, int maxLvl); +}; struct chat_interface *chat; diff --git a/src/map/chrif.c b/src/map/chrif.c index 15bf80da3..829dc22b9 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -35,20 +35,6 @@ #include <sys/types.h> #include <time.h> -static int check_connect_char_server(int tid, unsigned int tick, int id, intptr_t data); - -static struct eri *auth_db_ers; //For reutilizing player login structures. -static DBMap* auth_db; // int id -> struct auth_node* - -static const int packet_len_table[0x3d] = { // U - used, F - free - 60, 3,-1,27,10,-1, 6,-1, // 2af8-2aff: U->2af8, U->2af9, U->2afa, U->2afb, U->2afc, U->2afd, U->2afe, U->2aff - 6,-1,18, 7,-1,39,30, 10, // 2b00-2b07: U->2b00, U->2b01, U->2b02, U->2b03, U->2b04, U->2b05, U->2b06, U->2b07 - 6,30, -1, 0,86, 7,44,34, // 2b08-2b0f: U->2b08, U->2b09, U->2b0a, F->2b0b, U->2b0c, U->2b0d, U->2b0e, U->2b0f - 11,10,10, 0,11, 0,266,10, // 2b10-2b17: U->2b10, U->2b11, U->2b12, F->2b13, U->2b14, F->2b15, U->2b16, U->2b17 - 2,10, 2,-1,-1,-1, 2, 7, // 2b18-2b1f: U->2b18, U->2b19, U->2b1a, U->2b1b, U->2b1c, U->2b1d, U->2b1e, U->2b1f - -1,10, 8, 2, 2,14,19,19, // 2b20-2b27: U->2b20, U->2b21, U->2b22, U->2b23, U->2b24, U->2b25, U->2b26, U->2b27 -}; - struct chrif_interface chrif_s; //Used Packets: @@ -56,39 +42,39 @@ struct chrif_interface chrif_s; //2af9: Incoming, chrif_connectack -> 'answer of the 2af8 login(ok / fail)' //2afa: Outgoing, chrif_sendmap -> 'sending our maps' //2afb: Incoming, chrif_sendmapack -> 'Maps received successfully / or not ..' -//2afc: Outgoing, chrif->scdata_request -> request sc_data for pc->authok'ed char. <- new command reuses previous one. -//2afd: Incoming, chrif->authok -> 'client authentication ok' +//2afc: Outgoing, chrif_scdata_request -> request sc_data for pc->authok'ed char. <- new command reuses previous one. +//2afd: Incoming, chrif_authok -> 'client authentication ok' //2afe: Outgoing, send_usercount_tochar -> 'sends player count of this map server to charserver' -//2aff: Outgoing, chrif->send_users_tochar -> 'sends all actual connected character ids to charserver' -//2b00: Incoming, iMap->setusers -> 'set the actual usercount? PACKET.2B COUNT.L.. ?' (not sure) -//2b01: Outgoing, chrif->save -> 'charsave of char XY account XY (complete struct)' -//2b02: Outgoing, chrif->charselectreq -> 'player returns from ingame to charserver to select another char.., this packets includes sessid etc' ? (not 100% sure) +//2aff: Outgoing, chrif_send_users_tochar -> 'sends all actual connected character ids to charserver' +//2b00: Incoming, map_setusers -> 'set the actual usercount? PACKET.2B COUNT.L.. ?' (not sure) +//2b01: Outgoing, chrif_save -> 'charsave of char XY account XY (complete struct)' +//2b02: Outgoing, chrif_charselectreq -> 'player returns from ingame to charserver to select another char.., this packets includes sessid etc' ? (not 100% sure) //2b03: Incoming, clif_charselectok -> '' (i think its the packet after enterworld?) (not sure) //2b04: Incoming, chrif_recvmap -> 'getting maps from charserver of other mapserver's' -//2b05: Outgoing, chrif->changemapserver -> 'Tell the charserver the mapchange / quest for ok...' +//2b05: Outgoing, chrif_changemapserver -> 'Tell the charserver the mapchange / quest for ok...' //2b06: Incoming, chrif_changemapserverack -> 'awnser of 2b05, ok/fail, data: dunno^^' -//2b07: Outgoing, chrif->removefriend -> 'Tell charserver to remove friend_id from char_id friend list' -//2b08: Outgoing, chrif->searchcharid -> '...' +//2b07: Outgoing, chrif_removefriend -> 'Tell charserver to remove friend_id from char_id friend list' +//2b08: Outgoing, chrif_searchcharid -> '...' //2b09: Incoming, map_addchariddb -> 'Adds a name to the nick db' //2b0a: Incoming/Outgoing, socket_datasync() //2b0b: Outgoing, update charserv skillid2idx -//2b0c: Outgoing, chrif->changeemail -> 'change mail address ...' +//2b0c: Outgoing, chrif_changeemail -> 'change mail address ...' //2b0d: Incoming, chrif_changedsex -> 'Change sex of acc XY' -//2b0e: Outgoing, chrif->char_ask_name -> 'Do some operations (change sex, ban / unban etc)' +//2b0e: Outgoing, chrif_char_ask_name -> 'Do some operations (change sex, ban / unban etc)' //2b0f: Incoming, chrif_char_ask_name_answer -> 'answer of the 2b0e' -//2b10: Outgoing, chrif->updatefamelist -> 'Update the fame ranking lists and send them' -//2b11: Outgoing, chrif->divorce -> 'tell the charserver to do divorce' +//2b10: Outgoing, chrif_updatefamelist -> 'Update the fame ranking lists and send them' +//2b11: Outgoing, chrif_divorce -> 'tell the charserver to do divorce' //2b12: Incoming, chrif_divorceack -> 'divorce chars //2b13: FREE //2b14: Incoming, chrif_accountban -> 'not sure: kick the player with message XY' //2b15: FREE -//2b16: Outgoing, chrif->ragsrvinfo -> 'sends base / job / drop rates ....' -//2b17: Outgoing, chrif->char_offline -> 'tell the charserver that the char is now offline' -//2b18: Outgoing, chrif->char_reset_offline -> 'set all players OFF!' -//2b19: Outgoing, chrif->char_online -> 'tell the charserver that the char .. is online' -//2b1a: Outgoing, chrif->buildfamelist -> 'Build the fame ranking lists and send them' +//2b16: Outgoing, chrif_ragsrvinfo -> 'sends base / job / drop rates ....' +//2b17: Outgoing, chrif_char_offline -> 'tell the charserver that the char is now offline' +//2b18: Outgoing, chrif_char_reset_offline -> 'set all players OFF!' +//2b19: Outgoing, chrif_char_online -> 'tell the charserver that the char .. is online' +//2b1a: Outgoing, chrif_buildfamelist -> 'Build the fame ranking lists and send them' //2b1b: Incoming, chrif_recvfamelist -> 'Receive fame ranking lists' -//2b1c: Outgoing, chrif->save_scdata -> 'Send sc_data of player for saving.' +//2b1c: Outgoing, chrif_save_scdata -> 'Send sc_data of player for saving.' //2b1d: Incoming, chrif_load_scdata -> 'received sc_data of player for loading.' //2b1e: Incoming, chrif_update_ip -> 'Reqest forwarded from char-server for interserver IP sync.' [Lance] //2b1f: Incoming, chrif_disconnectplayer -> 'disconnects a player (aid X) with the message XY ... 0x81 ..' [Sirius] @@ -98,45 +84,31 @@ struct chrif_interface chrif_s; //2b23: Outgoing, chrif_keepalive. charserver ping. //2b24: Incoming, chrif_keepalive_ack. charserver ping reply. //2b25: Incoming, chrif_deadopt -> 'Removes baby from Father ID and Mother ID' -//2b26: Outgoing, chrif->authreq -> 'client authentication request' +//2b26: Outgoing, chrif_authreq -> 'client authentication request' //2b27: Incoming, chrif_authfail -> 'client authentication failed' -int char_fd = -1; -int srvinfo; -static char char_ip_str[128]; -static uint32 char_ip = 0; -static uint16 char_port = 6121; -static char userid[NAME_LENGTH], passwd[NAME_LENGTH]; -static int chrif_state = 0; - -//Interval at which map server updates online listing. [Valaris] -#define CHECK_INTERVAL 3600000 -//Interval at which map server sends number of connected users. [Skotlex] -#define UPDATE_INTERVAL 10000 //This define should spare writing the check in every function. [Skotlex] #define chrif_check(a) { if(!chrif->isconnected()) return a; } - /// Resets all the data. void chrif_reset(void) { // TODO kick everyone out and reset everything [FlavioJS] exit(EXIT_FAILURE); } - /// Checks the conditions for the server to stop. /// Releases the cookie when all characters are saved. /// If all the conditions are met, it stops the core loop. void chrif_check_shutdown(void) { if( runflag != MAPSERVER_ST_SHUTDOWN ) return; - if( auth_db->size(auth_db) > 0 ) + if( db_size(chrif->auth_db) > 0 ) return; runflag = CORE_ST_STOP; } struct auth_node* chrif_search(int account_id) { - return (struct auth_node*)idb_get(auth_db, account_id); + return (struct auth_node*)idb_get(chrif->auth_db, account_id); } struct auth_node* chrif_auth_check(int account_id, int char_id, enum sd_state state) { @@ -160,8 +132,8 @@ bool chrif_auth_delete(int account_id, int char_id, enum sd_state state) { if ( node->sd ) aFree(node->sd); - ers_free(auth_db_ers, node); - idb_remove(auth_db,account_id); + ers_free(chrif->auth_db_ers, node); + idb_remove(chrif->auth_db,account_id); return true; } @@ -169,13 +141,13 @@ bool chrif_auth_delete(int account_id, int char_id, enum sd_state state) { } //Moves the sd character to the auth_db structure. -static bool chrif_sd_to_auth(TBL_PC* sd, enum sd_state state) { +bool chrif_sd_to_auth(TBL_PC* sd, enum sd_state state) { struct auth_node *node; if ( chrif->search(sd->status.account_id) ) return false; //Already exists? - node = ers_alloc(auth_db_ers, struct auth_node); + node = ers_alloc(chrif->auth_db_ers, struct auth_node); memset(node, 0, sizeof(struct auth_node)); @@ -191,12 +163,12 @@ static bool chrif_sd_to_auth(TBL_PC* sd, enum sd_state state) { sd->state.active = 0; - idb_put(auth_db, node->account_id, node); + idb_put(chrif->auth_db, node->account_id, node); return true; } -static bool chrif_auth_logout(TBL_PC* sd, enum sd_state state) { +bool chrif_auth_logout(TBL_PC* sd, enum sd_state state) { if(sd->fd && state == ST_LOGOUT) { //Disassociate player, and free it after saving ack returns. [Skotlex] //fd info must not be lost for ST_MAPCHANGE as a final packet needs to be sent to the player. @@ -205,7 +177,7 @@ static bool chrif_auth_logout(TBL_PC* sd, enum sd_state state) { sd->fd = 0; } - return chrif_sd_to_auth(sd, state); + return chrif->sd_to_auth(sd, state); } bool chrif_auth_finished(TBL_PC* sd) { @@ -221,17 +193,17 @@ bool chrif_auth_finished(TBL_PC* sd) { } // sets char-server's user id void chrif_setuserid(char *id) { - memcpy(userid, id, NAME_LENGTH); + memcpy(chrif->userid, id, NAME_LENGTH); } // sets char-server's password void chrif_setpasswd(char *pwd) { - memcpy(passwd, pwd, NAME_LENGTH); + memcpy(chrif->passwd, pwd, NAME_LENGTH); } // security check, prints warning if using default password void chrif_checkdefaultlogin(void) { - if (strcmp(userid, "s1")==0 && strcmp(passwd, "p1")==0) { + if (strcmp(chrif->userid, "s1")==0 && strcmp(chrif->passwd, "p1")==0) { ShowWarning("Using the default user/password s1/p1 is NOT RECOMMENDED.\n"); ShowNotice("Please edit your 'login' table to create a proper inter-server user/password (gender 'S')\n"); ShowNotice("and then edit your user/password in conf/map-server.conf (or conf/import/map_conf.txt)\n"); @@ -242,27 +214,27 @@ void chrif_checkdefaultlogin(void) { int chrif_setip(const char* ip) { char ip_str[16]; - if ( !( char_ip = host2ip(ip) ) ) { + if ( !( chrif->ip = host2ip(ip) ) ) { ShowWarning("Failed to Resolve Char Server Address! (%s)\n", ip); return 0; } - safestrncpy(char_ip_str, ip, sizeof(char_ip_str)); + safestrncpy(chrif->ip_str, ip, sizeof(chrif->ip_str)); - ShowInfo("Char Server IP Address : '"CL_WHITE"%s"CL_RESET"' -> '"CL_WHITE"%s"CL_RESET"'.\n", ip, ip2str(char_ip, ip_str)); + ShowInfo("Char Server IP Address : '"CL_WHITE"%s"CL_RESET"' -> '"CL_WHITE"%s"CL_RESET"'.\n", ip, ip2str(chrif->ip, ip_str)); return 1; } // sets char-server's port number void chrif_setport(uint16 port) { - char_port = port; + chrif->port = port; } // says whether the char-server is connected or not int chrif_isconnected(void) { - return (char_fd > 0 && session[char_fd] != NULL && chrif_state == 2); + return (chrif->fd > 0 && session[chrif->fd] != NULL && chrif->state == 2); } /*========================================== @@ -279,7 +251,7 @@ int chrif_save(struct map_session_data *sd, int flag) { //FIXME: SC are lost if there's no connection at save-time because of the way its related data is cleared immediately after this function. [Skotlex] if ( chrif->isconnected() ) chrif->save_scdata(sd); - if ( !chrif_auth_logout(sd,flag == 1 ? ST_LOGOUT : ST_MAPCHANGE) ) + if ( !chrif->auth_logout(sd,flag == 1 ? ST_LOGOUT : ST_MAPCHANGE) ) ShowError("chrif_save: Failed to set up player %d:%d for proper quitting!\n", sd->status.account_id, sd->status.char_id); } @@ -300,14 +272,14 @@ int chrif_save(struct map_session_data *sd, int flag) { if (sd->state.reg_dirty&1) intif->saveregistry(sd, 1); //Save account2 regs - WFIFOHEAD(char_fd, sizeof(sd->status) + 13); - WFIFOW(char_fd,0) = 0x2b01; - WFIFOW(char_fd,2) = sizeof(sd->status) + 13; - WFIFOL(char_fd,4) = sd->status.account_id; - WFIFOL(char_fd,8) = sd->status.char_id; - WFIFOB(char_fd,12) = (flag==1)?1:0; //Flag to tell char-server this character is quitting. - memcpy(WFIFOP(char_fd,13), &sd->status, sizeof(sd->status)); - WFIFOSET(char_fd, WFIFOW(char_fd,2)); + WFIFOHEAD(chrif->fd, sizeof(sd->status) + 13); + WFIFOW(chrif->fd,0) = 0x2b01; + WFIFOW(chrif->fd,2) = sizeof(sd->status) + 13; + WFIFOL(chrif->fd,4) = sd->status.account_id; + WFIFOL(chrif->fd,8) = sd->status.char_id; + WFIFOB(chrif->fd,12) = (flag==1)?1:0; //Flag to tell char-server this character is quitting. + memcpy(WFIFOP(chrif->fd,13), &sd->status, sizeof(sd->status)); + WFIFOSET(chrif->fd, WFIFOW(chrif->fd,2)); if( sd->status.pet_id > 0 && sd->pd ) intif->save_petdata(sd->status.account_id,&sd->pd->pet); @@ -325,11 +297,11 @@ int chrif_save(struct map_session_data *sd, int flag) { // connects to char-server (plaintext) int chrif_connect(int fd) { - ShowStatus("Logging in to char server...\n", char_fd); + ShowStatus("Logging in to char server...\n", chrif->fd); WFIFOHEAD(fd,60); WFIFOW(fd,0) = 0x2af8; - memcpy(WFIFOP(fd,2), userid, NAME_LENGTH); - memcpy(WFIFOP(fd,26), passwd, NAME_LENGTH); + memcpy(WFIFOP(fd,2), chrif->userid, NAME_LENGTH); + memcpy(WFIFOP(fd,26), chrif->passwd, NAME_LENGTH); WFIFOL(fd,50) = 0; WFIFOL(fd,54) = htonl(clif->map_ip); WFIFOW(fd,58) = htons(clif->map_port); @@ -362,7 +334,7 @@ int chrif_recvmap(int fd) { uint16 port = ntohs(RFIFOW(fd,8)); for(i = 10, j = 0; i < RFIFOW(fd,2); i += 4, j++) { - iMap->setipport(RFIFOW(fd,i), ip, port); + map->setipport(RFIFOW(fd,i), ip, port); } if (battle_config.etc_log) @@ -380,7 +352,7 @@ int chrif_removemap(int fd) { uint16 port = RFIFOW(fd,8); for(i = 10, j = 0; i < RFIFOW(fd, 2); i += 4, j++) - iMap->eraseipport(RFIFOW(fd, i), ip, port); + map->eraseipport(RFIFOW(fd, i), ip, port); chrif->other_mapserver_count--; @@ -391,7 +363,7 @@ int chrif_removemap(int fd) { } // received after a character has been "final saved" on the char-server -static void chrif_save_ack(int fd) { +void chrif_save_ack(int fd) { chrif->auth_delete(RFIFOL(fd,2), RFIFOL(fd,6), ST_LOGOUT); chrif->check_shutdown(); } @@ -407,21 +379,21 @@ int chrif_changemapserver(struct map_session_data* sd, uint32 ip, uint16 port) { chrif_check(-1); - WFIFOHEAD(char_fd,35); - WFIFOW(char_fd, 0) = 0x2b05; - WFIFOL(char_fd, 2) = sd->bl.id; - WFIFOL(char_fd, 6) = sd->login_id1; - WFIFOL(char_fd,10) = sd->login_id2; - WFIFOL(char_fd,14) = sd->status.char_id; - WFIFOW(char_fd,18) = sd->mapindex; - WFIFOW(char_fd,20) = sd->bl.x; - WFIFOW(char_fd,22) = sd->bl.y; - WFIFOL(char_fd,24) = htonl(ip); - WFIFOW(char_fd,28) = htons(port); - WFIFOB(char_fd,30) = sd->status.sex; - WFIFOL(char_fd,31) = htonl(session[sd->fd]->client_addr); - WFIFOL(char_fd,35) = sd->group_id; - WFIFOSET(char_fd,39); + WFIFOHEAD(chrif->fd,35); + WFIFOW(chrif->fd, 0) = 0x2b05; + WFIFOL(chrif->fd, 2) = sd->bl.id; + WFIFOL(chrif->fd, 6) = sd->login_id1; + WFIFOL(chrif->fd,10) = sd->login_id2; + WFIFOL(chrif->fd,14) = sd->status.char_id; + WFIFOW(chrif->fd,18) = sd->mapindex; + WFIFOW(chrif->fd,20) = sd->bl.x; + WFIFOW(chrif->fd,22) = sd->bl.y; + WFIFOL(chrif->fd,24) = htonl(ip); + WFIFOW(chrif->fd,28) = htons(port); + WFIFOB(chrif->fd,30) = sd->status.sex; + WFIFOL(chrif->fd,31) = htonl(session[sd->fd]->client_addr); + WFIFOL(chrif->fd,35) = sd->group_id; + WFIFOSET(chrif->fd,39); return 0; } @@ -458,10 +430,10 @@ int chrif_connectack(int fd) { } ShowStatus("Successfully logged on to Char Server (Connection: '"CL_WHITE"%d"CL_RESET"').\n",fd); - chrif_state = 1; + chrif->state = 1; chrif->connected = 1; - chrif_sendmap(fd); + chrif->sendmap(fd); ShowStatus("Event '"CL_WHITE"OnInterIfInit"CL_RESET"' executed with '"CL_WHITE"%d"CL_RESET"' NPCs.\n", npc->event_doall("OnInterIfInit")); if( !char_init_done ) { @@ -479,7 +451,7 @@ int chrif_connectack(int fd) { /** * @see DBApply */ -static int chrif_reconnect(DBKey key, DBData *data, va_list ap) { +int chrif_reconnect(DBKey key, DBData *data, va_list ap) { struct auth_node *node = DB->data2ptr(data); switch (node->state) { @@ -499,7 +471,7 @@ static int chrif_reconnect(DBKey key, DBData *data, va_list ap) { uint32 ip; uint16 port; - if( iMap->mapname2ipport(sd->mapindex,&ip,&port) == 0 ) + if( map->mapname2ipport(sd->mapindex,&ip,&port) == 0 ) chrif->changemapserver(sd, ip, port); else //too much lag/timeout is the closest explanation for this error. clif->authfail_fd(sd->fd, 3); @@ -516,7 +488,7 @@ static int chrif_reconnect(DBKey key, DBData *data, va_list ap) { void chrif_on_ready(void) { ShowStatus("Map Server is now online.\n"); - chrif_state = 2; + chrif->state = 2; chrif->check_shutdown(); @@ -524,7 +496,7 @@ void chrif_on_ready(void) { chrif->send_users_tochar(); //Auth db reconnect handling - auth_db->foreach(auth_db,chrif_reconnect); + chrif->auth_db->foreach(chrif->auth_db,chrif->reconnect); //Re-save any storages that were modified in the disconnection time. [Skotlex] storage->reconnect(); @@ -544,9 +516,9 @@ int chrif_sendmapack(int fd) { exit(EXIT_FAILURE); } - memcpy(iMap->wisp_server_name, RFIFOP(fd,3), NAME_LENGTH); + memcpy(map->wisp_server_name, RFIFOP(fd,3), NAME_LENGTH); - chrif_on_ready(); + chrif->on_ready(); return 0; } @@ -559,11 +531,11 @@ int chrif_scdata_request(int account_id, int char_id) { #ifdef ENABLE_SC_SAVING chrif_check(-1); - WFIFOHEAD(char_fd,10); - WFIFOW(char_fd,0) = 0x2afc; - WFIFOL(char_fd,2) = account_id; - WFIFOL(char_fd,6) = char_id; - WFIFOSET(char_fd,10); + WFIFOHEAD(chrif->fd,10); + WFIFOW(chrif->fd,0) = 0x2afc; + WFIFOL(chrif->fd,2) = account_id; + WFIFOL(chrif->fd,6) = char_id; + WFIFOSET(chrif->fd,10); #endif return 0; @@ -580,15 +552,15 @@ void chrif_authreq(struct map_session_data *sd) { return; } - WFIFOHEAD(char_fd,19); - WFIFOW(char_fd,0) = 0x2b26; - WFIFOL(char_fd,2) = sd->status.account_id; - WFIFOL(char_fd,6) = sd->status.char_id; - WFIFOL(char_fd,10) = sd->login_id1; - WFIFOB(char_fd,14) = sd->status.sex; - WFIFOL(char_fd,15) = htonl(session[sd->fd]->client_addr); - WFIFOSET(char_fd,19); - chrif_sd_to_auth(sd, ST_LOGIN); + WFIFOHEAD(chrif->fd,19); + WFIFOW(chrif->fd,0) = 0x2b26; + WFIFOL(chrif->fd,2) = sd->status.account_id; + WFIFOL(chrif->fd,6) = sd->status.char_id; + WFIFOL(chrif->fd,10) = sd->login_id1; + WFIFOB(chrif->fd,14) = sd->status.sex; + WFIFOL(chrif->fd,15) = htonl(session[sd->fd]->client_addr); + WFIFOSET(chrif->fd,19); + chrif->sd_to_auth(sd, ST_LOGIN); } /*========================================== @@ -620,7 +592,7 @@ void chrif_authok(int fd) { //Check if we don't already have player data in our server //Causes problems if the currently connected player tries to quit or this data belongs to an already connected player which is trying to re-auth. - if ( ( sd = iMap->id2sd(account_id) ) != NULL ) + if ( ( sd = map->id2sd(account_id) ) != NULL ) return; if ( ( node = chrif->search(account_id) ) == NULL ) @@ -712,7 +684,7 @@ int auth_db_cleanup_sub(DBKey key, DBData *data, va_list ap) { int auth_db_cleanup(int tid, unsigned int tick, int id, intptr_t data) { chrif_check(0); - auth_db->foreach(auth_db, auth_db_cleanup_sub); + chrif->auth_db->foreach(chrif->auth_db, chrif->auth_db_cleanup_sub); return 0; } @@ -727,13 +699,13 @@ int chrif_charselectreq(struct map_session_data* sd, uint32 s_ip) { chrif_check(-1); - WFIFOHEAD(char_fd,18); - WFIFOW(char_fd, 0) = 0x2b02; - WFIFOL(char_fd, 2) = sd->bl.id; - WFIFOL(char_fd, 6) = sd->login_id1; - WFIFOL(char_fd,10) = sd->login_id2; - WFIFOL(char_fd,14) = htonl(s_ip); - WFIFOSET(char_fd,18); + WFIFOHEAD(chrif->fd,18); + WFIFOW(chrif->fd, 0) = 0x2b02; + WFIFOL(chrif->fd, 2) = sd->bl.id; + WFIFOL(chrif->fd, 6) = sd->login_id1; + WFIFOL(chrif->fd,10) = sd->login_id2; + WFIFOL(chrif->fd,14) = htonl(s_ip); + WFIFOSET(chrif->fd,18); return 0; } @@ -748,10 +720,10 @@ int chrif_searchcharid(int char_id) { chrif_check(-1); - WFIFOHEAD(char_fd,6); - WFIFOW(char_fd,0) = 0x2b08; - WFIFOL(char_fd,2) = char_id; - WFIFOSET(char_fd,6); + WFIFOHEAD(chrif->fd,6); + WFIFOW(chrif->fd,0) = 0x2b08; + WFIFOL(chrif->fd,2) = char_id; + WFIFOSET(chrif->fd,6); return 0; } @@ -766,12 +738,12 @@ int chrif_changeemail(int id, const char *actual_email, const char *new_email) { chrif_check(-1); - WFIFOHEAD(char_fd,86); - WFIFOW(char_fd,0) = 0x2b0c; - WFIFOL(char_fd,2) = id; - memcpy(WFIFOP(char_fd,6), actual_email, 40); - memcpy(WFIFOP(char_fd,46), new_email, 40); - WFIFOSET(char_fd,86); + WFIFOHEAD(chrif->fd,86); + WFIFOW(chrif->fd,0) = 0x2b0c; + WFIFOL(chrif->fd,2) = id; + memcpy(WFIFOP(chrif->fd,6), actual_email, 40); + memcpy(WFIFOP(chrif->fd,46), new_email, 40); + WFIFOSET(chrif->fd,86); return 0; } @@ -786,41 +758,41 @@ int chrif_char_ask_name(int acc, const char* character_name, unsigned short oper chrif_check(-1); - WFIFOHEAD(char_fd,44); - WFIFOW(char_fd,0) = 0x2b0e; - WFIFOL(char_fd,2) = acc; - safestrncpy((char*)WFIFOP(char_fd,6), character_name, NAME_LENGTH); - WFIFOW(char_fd,30) = operation_type; + WFIFOHEAD(chrif->fd,44); + WFIFOW(chrif->fd,0) = 0x2b0e; + WFIFOL(chrif->fd,2) = acc; + safestrncpy((char*)WFIFOP(chrif->fd,6), character_name, NAME_LENGTH); + WFIFOW(chrif->fd,30) = operation_type; if ( operation_type == 2 ) { - WFIFOW(char_fd,32) = year; - WFIFOW(char_fd,34) = month; - WFIFOW(char_fd,36) = day; - WFIFOW(char_fd,38) = hour; - WFIFOW(char_fd,40) = minute; - WFIFOW(char_fd,42) = second; + WFIFOW(chrif->fd,32) = year; + WFIFOW(chrif->fd,34) = month; + WFIFOW(chrif->fd,36) = day; + WFIFOW(chrif->fd,38) = hour; + WFIFOW(chrif->fd,40) = minute; + WFIFOW(chrif->fd,42) = second; } - WFIFOSET(char_fd,44); + WFIFOSET(chrif->fd,44); return 0; } int chrif_changesex(struct map_session_data *sd) { chrif_check(-1); - WFIFOHEAD(char_fd,44); - WFIFOW(char_fd,0) = 0x2b0e; - WFIFOL(char_fd,2) = sd->status.account_id; - safestrncpy((char*)WFIFOP(char_fd,6), sd->status.name, NAME_LENGTH); - WFIFOW(char_fd,30) = 5; - WFIFOSET(char_fd,44); + WFIFOHEAD(chrif->fd,44); + WFIFOW(chrif->fd,0) = 0x2b0e; + WFIFOL(chrif->fd,2) = sd->status.account_id; + safestrncpy((char*)WFIFOP(chrif->fd,6), sd->status.name, NAME_LENGTH); + WFIFOW(chrif->fd,30) = 5; + WFIFOSET(chrif->fd,44); clif->message(sd->fd, msg_txt(408)); //"Need disconnection to perform change-sex request..." if (sd->fd) clif->authfail_fd(sd->fd, 15); else - iMap->quit(sd); + map->quit(sd); return 0; } @@ -835,12 +807,12 @@ int chrif_changesex(struct map_session_data *sd) { * 2: gm level too low * 3: login-server offline *------------------------------------------*/ -static void chrif_char_ask_name_answer(int acc, const char* player_name, uint16 type, uint16 answer) { +void chrif_char_ask_name_answer(int acc, const char* player_name, uint16 type, uint16 answer) { struct map_session_data* sd; char action[25]; char output[256]; - sd = iMap->id2sd(acc); + sd = map->id2sd(acc); if( acc < 0 || sd == NULL ) { ShowError("chrif_char_ask_name_answer failed - player not online.\n"); @@ -876,7 +848,7 @@ int chrif_changedsex(int fd) { if ( battle_config.etc_log ) ShowNotice("chrif_changedsex %d.\n", acc); - sd = iMap->id2sd(acc); + sd = map->id2sd(acc); if ( sd ) { //Normally there should not be a char logged on right now! if ( sd->status.sex == sex ) return 0; //Do nothing? Likely safe. @@ -916,7 +888,7 @@ int chrif_changedsex(int fd) { // do same modify in login-server for the account, but no in char-server (it ask again login_id1 to login, and don't remember it) clif->message(sd->fd, msg_txt(409)); //"Your sex has been changed (need disconnection by the server)..." set_eof(sd->fd); // forced to disconnect for the change - iMap->quit(sd); // Remove leftovers (e.g. autotrading) [Paradox924X] + map->quit(sd); // Remove leftovers (e.g. autotrading) [Paradox924X] } return 0; } @@ -926,11 +898,11 @@ int chrif_changedsex(int fd) { int chrif_divorce(int partner_id1, int partner_id2) { chrif_check(-1); - WFIFOHEAD(char_fd,10); - WFIFOW(char_fd,0) = 0x2b11; - WFIFOL(char_fd,2) = partner_id1; - WFIFOL(char_fd,6) = partner_id2; - WFIFOSET(char_fd,10); + WFIFOHEAD(chrif->fd,10); + WFIFOW(chrif->fd,0) = 0x2b11; + WFIFOL(chrif->fd,2) = partner_id1; + WFIFOL(chrif->fd,6) = partner_id2; + WFIFOSET(chrif->fd,10); return 0; } @@ -946,14 +918,14 @@ int chrif_divorceack(int char_id, int partner_id) { if( !char_id || !partner_id ) return 0; - if( ( sd = iMap->charid2sd(char_id) ) != NULL && sd->status.partner_id == partner_id ) { + if( ( sd = map->charid2sd(char_id) ) != NULL && sd->status.partner_id == partner_id ) { sd->status.partner_id = 0; for(i = 0; i < MAX_INVENTORY; i++) if (sd->status.inventory[i].nameid == WEDDING_RING_M || sd->status.inventory[i].nameid == WEDDING_RING_F) pc->delitem(sd, i, 1, 0, 0, LOG_TYPE_OTHER); } - if( ( sd = iMap->charid2sd(partner_id) ) != NULL && sd->status.partner_id == char_id ) { + if( ( sd = map->charid2sd(partner_id) ) != NULL && sd->status.partner_id == char_id ) { sd->status.partner_id = 0; for(i = 0; i < MAX_INVENTORY; i++) if (sd->status.inventory[i].nameid == WEDDING_RING_M || sd->status.inventory[i].nameid == WEDDING_RING_F) @@ -969,7 +941,7 @@ int chrif_deadopt(int father_id, int mother_id, int child_id) { struct map_session_data* sd; int idx = skill->get_index(WE_CALLBABY); - if( father_id && ( sd = iMap->charid2sd(father_id) ) != NULL && sd->status.child == child_id ) { + if( father_id && ( sd = map->charid2sd(father_id) ) != NULL && sd->status.child == child_id ) { sd->status.child = 0; sd->status.skill[idx].id = 0; sd->status.skill[idx].lv = 0; @@ -977,7 +949,7 @@ int chrif_deadopt(int father_id, int mother_id, int child_id) { clif->deleteskill(sd,WE_CALLBABY); } - if( mother_id && ( sd = iMap->charid2sd(mother_id) ) != NULL && sd->status.child == child_id ) { + if( mother_id && ( sd = map->charid2sd(mother_id) ) != NULL && sd->status.child == child_id ) { sd->status.child = 0; sd->status.skill[idx].id = 0; sd->status.skill[idx].lv = 0; @@ -1000,7 +972,7 @@ int chrif_accountban(int fd) { if ( battle_config.etc_log ) ShowNotice("chrif_accountban %d.\n", acc); - sd = iMap->id2sd(acc); + sd = map->id2sd(acc); if ( acc < 0 || sd == NULL ) { ShowError("chrif_accountban failed - player not online.\n"); @@ -1009,13 +981,13 @@ int chrif_accountban(int fd) { sd->login_id1++; // change identify, because if player come back in char within the 5 seconds, he can change its characters if (RFIFOB(fd,6) == 0) { // 0: change of statut, 1: ban - int ret_status = RFIFOL(fd,7); // status or final date of a banishment - if(0<ret_status && ret_status<=9) - clif->message(sd->fd, msg_txt(411+ret_status)); - else if(ret_status==100) - clif->message(sd->fd, msg_txt(421)); - else - clif->message(sd->fd, msg_txt(420)); //"Your account has not more authorised." + int ret_status = RFIFOL(fd,7); // status or final date of a banishment + if(0<ret_status && ret_status<=9) + clif->message(sd->fd, msg_txt(411+ret_status)); + else if(ret_status==100) + clif->message(sd->fd, msg_txt(421)); + else + clif->message(sd->fd, msg_txt(420)); //"Your account has not more authorised." } else if (RFIFOB(fd,6) == 1) { // 0: change of statut, 1: ban time_t timestamp; char tmpstr[2048]; @@ -1026,7 +998,7 @@ int chrif_accountban(int fd) { } set_eof(sd->fd); // forced to disconnect for the change - iMap->quit(sd); // Remove leftovers (e.g. autotrading) [Paradox924X] + map->quit(sd); // Remove leftovers (e.g. autotrading) [Paradox924X] return 0; } @@ -1036,7 +1008,7 @@ int chrif_disconnectplayer(int fd) { struct map_session_data* sd; int account_id = RFIFOL(fd, 2); - sd = iMap->id2sd(account_id); + sd = map->id2sd(account_id); if( sd == NULL ) { struct auth_node* auth = chrif->search(account_id); @@ -1048,7 +1020,7 @@ int chrif_disconnectplayer(int fd) { if (!sd->fd) { //No connection if (sd->state.autotrade) - iMap->quit(sd); //Remove it. + map->quit(sd); //Remove it. //Else we don't remove it because the char should have a timer to remove the player because it force-quit before, //and we don't want them kicking their previous instance before the 10 secs penalty time passes. [Skotlex] return 0; @@ -1080,12 +1052,12 @@ int chrif_updatefamelist(struct map_session_data* sd) { return 0; } - WFIFOHEAD(char_fd, 11); - WFIFOW(char_fd,0) = 0x2b10; - WFIFOL(char_fd,2) = sd->status.char_id; - WFIFOL(char_fd,6) = sd->status.fame; - WFIFOB(char_fd,10) = type; - WFIFOSET(char_fd,11); + WFIFOHEAD(chrif->fd, 11); + WFIFOW(chrif->fd,0) = 0x2b10; + WFIFOL(chrif->fd,2) = sd->status.char_id; + WFIFOL(chrif->fd,6) = sd->status.fame; + WFIFOB(chrif->fd,10) = type; + WFIFOSET(chrif->fd,11); return 0; } @@ -1093,9 +1065,9 @@ int chrif_updatefamelist(struct map_session_data* sd) { int chrif_buildfamelist(void) { chrif_check(-1); - WFIFOHEAD(char_fd,2); - WFIFOW(char_fd,0) = 0x2b1a; - WFIFOSET(char_fd,2); + WFIFOHEAD(chrif->fd,2); + WFIFOW(chrif->fd,0) = 0x2b1a; + WFIFOSET(chrif->fd,2); return 0; } @@ -1175,17 +1147,17 @@ int chrif_save_scdata(struct map_session_data *sd) { //parses the sc_data of the chrif_check(-1); tick = timer->gettick(); - WFIFOHEAD(char_fd, 14 + SC_MAX*sizeof(struct status_change_data)); - WFIFOW(char_fd,0) = 0x2b1c; - WFIFOL(char_fd,4) = sd->status.account_id; - WFIFOL(char_fd,8) = sd->status.char_id; + WFIFOHEAD(chrif->fd, 14 + SC_MAX*sizeof(struct status_change_data)); + WFIFOW(chrif->fd,0) = 0x2b1c; + WFIFOL(chrif->fd,4) = sd->status.account_id; + WFIFOL(chrif->fd,8) = sd->status.char_id; for (i = 0; i < SC_MAX; i++) { if (!sc->data[i]) continue; if (sc->data[i]->timer != INVALID_TIMER) { td = timer->get(sc->data[i]->timer); - if (td == NULL || td->func != iStatus->change_timer || DIFF_TICK(td->tick,tick) < 0) + if (td == NULL || td->func != status->change_timer || DIFF_TICK(td->tick,tick) < 0) continue; data.tick = DIFF_TICK(td->tick,tick); //Duration that is left before ending. } else @@ -1195,7 +1167,7 @@ int chrif_save_scdata(struct map_session_data *sd) { //parses the sc_data of the data.val2 = sc->data[i]->val2; data.val3 = sc->data[i]->val3; data.val4 = sc->data[i]->val4; - memcpy(WFIFOP(char_fd,14 +count*sizeof(struct status_change_data)), + memcpy(WFIFOP(chrif->fd,14 +count*sizeof(struct status_change_data)), &data, sizeof(struct status_change_data)); count++; } @@ -1203,9 +1175,9 @@ int chrif_save_scdata(struct map_session_data *sd) { //parses the sc_data of the if (count == 0) return 0; //Nothing to save. - WFIFOW(char_fd,12) = count; - WFIFOW(char_fd,2) = 14 +count*sizeof(struct status_change_data); //Total packet size - WFIFOSET(char_fd,WFIFOW(char_fd,2)); + WFIFOW(chrif->fd,12) = count; + WFIFOW(chrif->fd,2) = 14 +count*sizeof(struct status_change_data); //Total packet size + WFIFOSET(chrif->fd,WFIFOW(chrif->fd,2)); #endif return 0; @@ -1222,7 +1194,7 @@ int chrif_load_scdata(int fd) { aid = RFIFOL(fd,4); //Player Account ID cid = RFIFOL(fd,8); //Player Char ID - sd = iMap->id2sd(aid); + sd = map->id2sd(aid); if ( !sd ) { ShowError("chrif_load_scdata: Player of AID %d not found!\n", aid); @@ -1238,7 +1210,7 @@ int chrif_load_scdata(int fd) { for (i = 0; i < count; i++) { data = (struct status_change_data*)RFIFOP(fd,14 + i*sizeof(struct status_change_data)); - iStatus->change_start(&sd->bl, (sc_type)data->type, 10000, data->val1, data->val2, data->val3, data->val4, data->tick, 15); + status->change_start(&sd->bl, (sc_type)data->type, 10000, data->val1, data->val2, data->val3, data->val4, data->tick, 15); } #endif @@ -1252,12 +1224,12 @@ int chrif_load_scdata(int fd) { int chrif_ragsrvinfo(int base_rate, int job_rate, int drop_rate) { chrif_check(-1); - WFIFOHEAD(char_fd,14); - WFIFOW(char_fd,0) = 0x2b16; - WFIFOL(char_fd,2) = base_rate; - WFIFOL(char_fd,6) = job_rate; - WFIFOL(char_fd,10) = drop_rate; - WFIFOSET(char_fd,14); + WFIFOHEAD(chrif->fd,14); + WFIFOW(chrif->fd,0) = 0x2b16; + WFIFOL(chrif->fd,2) = base_rate; + WFIFOL(chrif->fd,6) = job_rate; + WFIFOL(chrif->fd,10) = drop_rate; + WFIFOSET(chrif->fd,14); return 0; } @@ -1269,22 +1241,22 @@ int chrif_ragsrvinfo(int base_rate, int job_rate, int drop_rate) { int chrif_char_offline(struct map_session_data *sd) { chrif_check(-1); - WFIFOHEAD(char_fd,10); - WFIFOW(char_fd,0) = 0x2b17; - WFIFOL(char_fd,2) = sd->status.char_id; - WFIFOL(char_fd,6) = sd->status.account_id; - WFIFOSET(char_fd,10); + WFIFOHEAD(chrif->fd,10); + WFIFOW(chrif->fd,0) = 0x2b17; + WFIFOL(chrif->fd,2) = sd->status.char_id; + WFIFOL(chrif->fd,6) = sd->status.account_id; + WFIFOSET(chrif->fd,10); return 0; } int chrif_char_offline_nsd(int account_id, int char_id) { chrif_check(-1); - WFIFOHEAD(char_fd,10); - WFIFOW(char_fd,0) = 0x2b17; - WFIFOL(char_fd,2) = char_id; - WFIFOL(char_fd,6) = account_id; - WFIFOSET(char_fd,10); + WFIFOHEAD(chrif->fd,10); + WFIFOW(chrif->fd,0) = 0x2b17; + WFIFOL(chrif->fd,2) = char_id; + WFIFOL(chrif->fd,6) = account_id; + WFIFOSET(chrif->fd,10); return 0; } @@ -1295,9 +1267,9 @@ int chrif_char_offline_nsd(int account_id, int char_id) { int chrif_flush_fifo(void) { chrif_check(-1); - set_nonblocking(char_fd, 0); + set_nonblocking(chrif->fd, 0); flush_fifos(); - set_nonblocking(char_fd, 1); + set_nonblocking(chrif->fd, 1); return 0; } @@ -1308,9 +1280,9 @@ int chrif_flush_fifo(void) { int chrif_char_reset_offline(void) { chrif_check(-1); - WFIFOHEAD(char_fd,2); - WFIFOW(char_fd,0) = 0x2b18; - WFIFOSET(char_fd,2); + WFIFOHEAD(chrif->fd,2); + WFIFOW(chrif->fd,0) = 0x2b18; + WFIFOSET(chrif->fd,2); return 0; } @@ -1322,11 +1294,11 @@ int chrif_char_reset_offline(void) { int chrif_char_online(struct map_session_data *sd) { chrif_check(-1); - WFIFOHEAD(char_fd,10); - WFIFOW(char_fd,0) = 0x2b19; - WFIFOL(char_fd,2) = sd->status.char_id; - WFIFOL(char_fd,6) = sd->status.account_id; - WFIFOSET(char_fd,10); + WFIFOHEAD(chrif->fd,10); + WFIFOW(chrif->fd,0) = 0x2b19; + WFIFOL(chrif->fd,2) = sd->status.char_id; + WFIFOL(chrif->fd,6) = sd->status.account_id; + WFIFOSET(chrif->fd,10); return 0; } @@ -1338,11 +1310,11 @@ void chrif_on_disconnect(void) { ShowWarning("Connection to Char Server lost.\n\n"); chrif->connected = 0; - chrif->other_mapserver_count = 0; //Reset counter. We receive ALL maps from all map-servers on reconnect. - iMap->eraseallipport(); + chrif->other_mapserver_count = 0; //Reset counter. We receive ALL maps from all map-servers on reconnect. + map->eraseallipport(); //Attempt to reconnect in a second. [Skotlex] - timer->add(timer->gettick() + 1000, check_connect_char_server, 0, 0); + timer->add(timer->gettick() + 1000, chrif->check_connect_char_server, 0, 0); } @@ -1351,10 +1323,10 @@ void chrif_update_ip(int fd) { WFIFOHEAD(fd,6); - new_ip = host2ip(char_ip_str); + new_ip = host2ip(chrif->ip_str); - if (new_ip && new_ip != char_ip) - char_ip = new_ip; //Update char_ip + if (new_ip && new_ip != chrif->ip) + chrif->ip = new_ip; //Update chrif->ip new_ip = clif->refresh_ip(); @@ -1366,7 +1338,7 @@ void chrif_update_ip(int fd) { WFIFOSET(fd,6); } -// pings the charserver +// pings the charserver ( since on-demand flag.ping was introduced, shouldn't this be dropped? only wasting traffic and processing [Ind]) void chrif_keepalive(int fd) { WFIFOHEAD(fd,2); WFIFOW(fd,0) = 0x2b23; @@ -1378,13 +1350,13 @@ void chrif_keepalive_ack(int fd) { void chrif_skillid2idx(int fd) { int i, count = 0; - if( fd == 0 ) fd = char_fd; + if( fd == 0 ) fd = chrif->fd; WFIFOHEAD(fd,4 + (MAX_SKILL * 4)); WFIFOW(fd,0) = 0x2b0b; for(i = 0; i < MAX_SKILL; i++) { - if( skill_db[i].nameid ) { - WFIFOW(fd, 4 + (count*4)) = skill_db[i].nameid; + if( skill->db[i].nameid ) { + WFIFOW(fd, 4 + (count*4)) = skill->db[i].nameid; WFIFOW(fd, 6 + (count*4)) = i; count++; } @@ -1400,7 +1372,7 @@ int chrif_parse(int fd) { int packet_len, cmd, r; // only process data from the char-server - if ( fd != char_fd ) { + if ( fd != chrif->fd ) { ShowDebug("chrif_parse: Disconnecting invalid session #%d (is not the char-server)\n", fd); do_close(fd); return 0; @@ -1408,15 +1380,15 @@ int chrif_parse(int fd) { if ( session[fd]->flag.eof ) { do_close(fd); - char_fd = -1; - chrif_on_disconnect(); + chrif->fd = -1; + chrif->on_disconnect(); return 0; } else if ( session[fd]->flag.ping ) {/* we've reached stall time */ if( DIFF_TICK(last_tick, session[fd]->rdata_tick) > (stall_time * 2) ) {/* we can't wait any longer */ set_eof(fd); return 0; } else if( session[fd]->flag.ping != 2 ) { /* we haven't sent ping out yet */ - chrif_keepalive(fd); + chrif->keepalive(fd); session[fd]->flag.ping = 2; } } @@ -1432,7 +1404,7 @@ int chrif_parse(int fd) { cmd = RFIFOW(fd,0); - if (cmd < 0x2af8 || cmd >= 0x2af8 + ARRAYLENGTH(packet_len_table) || packet_len_table[cmd-0x2af8] == 0) { + if (cmd < 0x2af8 || cmd >= 0x2af8 + ARRAYLENGTH(chrif->packet_len_table) || chrif->packet_len_table[cmd-0x2af8] == 0) { r = intif->parse(fd); // Passed on to the intif if (r == 1) continue; // Treated in intif @@ -1443,7 +1415,7 @@ int chrif_parse(int fd) { return 0; } - if ( ( packet_len = packet_len_table[cmd-0x2af8] ) == -1) { // dynamic-length packet, second WORD holds the length + if ( ( packet_len = chrif->packet_len_table[cmd-0x2af8] ) == -1) { // dynamic-length packet, second WORD holds the length if (RFIFOREST(fd) < 4) return 0; packet_len = RFIFOW(fd,2); @@ -1455,49 +1427,48 @@ int chrif_parse(int fd) { //ShowDebug("Received packet 0x%4x (%d bytes) from char-server (connection %d)\n", RFIFOW(fd,0), packet_len, fd); switch(cmd) { - case 0x2af9: chrif_connectack(fd); break; - case 0x2afb: chrif_sendmapack(fd); break; + case 0x2af9: chrif->connectack(fd); break; + case 0x2afb: chrif->sendmapack(fd); break; case 0x2afd: chrif->authok(fd); break; - case 0x2b00: iMap->setusers(RFIFOL(fd,2)); chrif_keepalive(fd); break; + case 0x2b00: map->setusers(RFIFOL(fd,2)); chrif->keepalive(fd); break; case 0x2b03: clif->charselectok(RFIFOL(fd,2), RFIFOB(fd,6)); break; - case 0x2b04: chrif_recvmap(fd); break; - case 0x2b06: chrif_changemapserverack(RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10), RFIFOL(fd,14), RFIFOW(fd,18), RFIFOW(fd,20), RFIFOW(fd,22), RFIFOL(fd,24), RFIFOW(fd,28)); break; - case 0x2b09: iMap->addnickdb(RFIFOL(fd,2), (char*)RFIFOP(fd,6)); break; + case 0x2b04: chrif->recvmap(fd); break; + case 0x2b06: chrif->changemapserverack(RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10), RFIFOL(fd,14), RFIFOW(fd,18), RFIFOW(fd,20), RFIFOW(fd,22), RFIFOL(fd,24), RFIFOW(fd,28)); break; + case 0x2b09: map->addnickdb(RFIFOL(fd,2), (char*)RFIFOP(fd,6)); break; case 0x2b0a: socket_datasync(fd, false); break; - case 0x2b0d: chrif_changedsex(fd); break; - case 0x2b0f: chrif_char_ask_name_answer(RFIFOL(fd,2), (char*)RFIFOP(fd,6), RFIFOW(fd,30), RFIFOW(fd,32)); break; - case 0x2b12: chrif_divorceack(RFIFOL(fd,2), RFIFOL(fd,6)); break; - case 0x2b14: chrif_accountban(fd); break; - case 0x2b1b: chrif_recvfamelist(fd); break; - case 0x2b1d: chrif_load_scdata(fd); break; - case 0x2b1e: chrif_update_ip(fd); break; - case 0x2b1f: chrif_disconnectplayer(fd); break; - case 0x2b20: chrif_removemap(fd); break; - case 0x2b21: chrif_save_ack(fd); break; - case 0x2b22: chrif_updatefamelist_ack(fd); break; - case 0x2b24: chrif_keepalive_ack(fd); break; - case 0x2b25: chrif_deadopt(RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10)); break; - case 0x2b27: chrif_authfail(fd); break; + case 0x2b0d: chrif->changedsex(fd); break; + case 0x2b0f: chrif->char_ask_name_answer(RFIFOL(fd,2), (char*)RFIFOP(fd,6), RFIFOW(fd,30), RFIFOW(fd,32)); break; + case 0x2b12: chrif->divorceack(RFIFOL(fd,2), RFIFOL(fd,6)); break; + case 0x2b14: chrif->accountban(fd); break; + case 0x2b1b: chrif->recvfamelist(fd); break; + case 0x2b1d: chrif->load_scdata(fd); break; + case 0x2b1e: chrif->update_ip(fd); break; + case 0x2b1f: chrif->disconnectplayer(fd); break; + case 0x2b20: chrif->removemap(fd); break; + case 0x2b21: chrif->save_ack(fd); break; + case 0x2b22: chrif->updatefamelist_ack(fd); break; + case 0x2b24: chrif->keepalive_ack(fd); break; + case 0x2b25: chrif->deadopt(RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10)); break; + case 0x2b27: chrif->authfail(fd); break; default: ShowError("chrif_parse : unknown packet (session #%d): 0x%x. Disconnecting.\n", fd, cmd); set_eof(fd); return 0; } - if ( fd == char_fd ) //There's the slight chance we lost the connection during parse, in which case this would segfault if not checked [Skotlex] + if ( fd == chrif->fd ) //There's the slight chance we lost the connection during parse, in which case this would segfault if not checked [Skotlex] RFIFOSKIP(fd, packet_len); } return 0; } -// unused int send_usercount_tochar(int tid, unsigned int tick, int id, intptr_t data) { chrif_check(-1); - WFIFOHEAD(char_fd,4); - WFIFOW(char_fd,0) = 0x2afe; - WFIFOW(char_fd,2) = iMap->usercount(); - WFIFOSET(char_fd,4); + WFIFOHEAD(chrif->fd,4); + WFIFOW(chrif->fd,0) = 0x2afe; + WFIFOW(chrif->fd,2) = map->usercount(); + WFIFOSET(chrif->fd,4); return 0; } @@ -1512,24 +1483,24 @@ int send_users_tochar(void) { chrif_check(-1); - users = iMap->usercount(); + users = map->usercount(); - WFIFOHEAD(char_fd, 6+8*users); - WFIFOW(char_fd,0) = 0x2aff; + WFIFOHEAD(chrif->fd, 6+8*users); + WFIFOW(chrif->fd,0) = 0x2aff; iter = mapit_getallusers(); for( sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); sd = (TBL_PC*)mapit->next(iter) ) { - WFIFOL(char_fd,6+8*i) = sd->status.account_id; - WFIFOL(char_fd,6+8*i+4) = sd->status.char_id; + WFIFOL(chrif->fd,6+8*i) = sd->status.account_id; + WFIFOL(chrif->fd,6+8*i+4) = sd->status.char_id; i++; } mapit->free(iter); - WFIFOW(char_fd,2) = 6 + 8*users; - WFIFOW(char_fd,4) = users; - WFIFOSET(char_fd, 6+8*users); + WFIFOW(chrif->fd,2) = 6 + 8*users; + WFIFOW(chrif->fd,4) = users; + WFIFOSET(chrif->fd, 6+8*users); return 0; } @@ -1538,30 +1509,30 @@ int send_users_tochar(void) { * timerFunction * Chk the connection to char server, (if it down) *------------------------------------------*/ -static int check_connect_char_server(int tid, unsigned int tick, int id, intptr_t data) { +int check_connect_char_server(int tid, unsigned int tick, int id, intptr_t data) { static int displayed = 0; - if ( char_fd <= 0 || session[char_fd] == NULL ) { + if ( chrif->fd <= 0 || session[chrif->fd] == NULL ) { if ( !displayed ) { ShowStatus("Attempting to connect to Char Server. Please wait.\n"); displayed = 1; } - chrif_state = 0; + chrif->state = 0; - if ( ( char_fd = make_connection(char_ip, char_port,NULL) ) == -1) //Attempt to connect later. [Skotlex] + if ( ( chrif->fd = make_connection(chrif->ip, chrif->port,NULL) ) == -1) //Attempt to connect later. [Skotlex] return 0; - session[char_fd]->func_parse = chrif_parse; - session[char_fd]->flag.server = 1; - realloc_fifo(char_fd, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK); + session[chrif->fd]->func_parse = chrif->parse; + session[chrif->fd]->flag.server = 1; + realloc_fifo(chrif->fd, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK); - chrif_connect(char_fd); - chrif->connected = (chrif_state == 2); - srvinfo = 0; + chrif->connect(chrif->fd); + chrif->connected = (chrif->state == 2); + chrif->srvinfo = 0; } else { - if (srvinfo == 0) { + if (chrif->srvinfo == 0) { chrif->ragsrvinfo(battle_config.base_exp_rate, battle_config.job_exp_rate, battle_config.item_rate_common); - srvinfo = 1; + chrif->srvinfo = 1; } } if ( chrif->isconnected() ) @@ -1576,27 +1547,27 @@ int chrif_removefriend(int char_id, int friend_id) { chrif_check(-1); - WFIFOHEAD(char_fd,10); - WFIFOW(char_fd,0) = 0x2b07; - WFIFOL(char_fd,2) = char_id; - WFIFOL(char_fd,6) = friend_id; - WFIFOSET(char_fd,10); + WFIFOHEAD(chrif->fd,10); + WFIFOW(chrif->fd,0) = 0x2b07; + WFIFOL(chrif->fd,2) = char_id; + WFIFOL(chrif->fd,6) = friend_id; + WFIFOSET(chrif->fd,10); return 0; } void chrif_send_report(char* buf, int len) { #ifndef STATS_OPT_OUT - if( char_fd ) { - WFIFOHEAD(char_fd,len + 2); + if( chrif->fd > 0 ) { + WFIFOHEAD(chrif->fd,len + 2); - WFIFOW(char_fd,0) = 0x3008; + WFIFOW(chrif->fd,0) = 0x3008; - memcpy(WFIFOP(char_fd,2), buf, len); + memcpy(WFIFOP(chrif->fd,2), buf, len); - WFIFOSET(char_fd,len + 2); + WFIFOSET(chrif->fd,len + 2); - flush_fifo(char_fd); /* ensure it's sent now. */ + flush_fifo(chrif->fd); /* ensure it's sent now. */ } #endif } @@ -1613,7 +1584,7 @@ int auth_db_final(DBKey key, DBData *data, va_list ap) { if (node->sd) aFree(node->sd); - ers_free(auth_db_ers, node); + ers_free(chrif->auth_db_ers, node); return 0; } @@ -1623,14 +1594,14 @@ int auth_db_final(DBKey key, DBData *data, va_list ap) { *------------------------------------------*/ int do_final_chrif(void) { - if( char_fd != -1 ) { - do_close(char_fd); - char_fd = -1; + if( chrif->fd != -1 ) { + do_close(chrif->fd); + chrif->fd = -1; } - auth_db->destroy(auth_db, auth_db_final); + chrif->auth_db->destroy(chrif->auth_db, chrif->auth_db_final); - ers_destroy(auth_db_ers); + ers_destroy(chrif->auth_db_ers); return 0; } @@ -1640,20 +1611,21 @@ int do_final_chrif(void) { *------------------------------------------*/ int do_init_chrif(void) { - auth_db = idb_alloc(DB_OPT_BASE); - auth_db_ers = ers_new(sizeof(struct auth_node),"chrif.c::auth_db_ers",ERS_OPT_NONE); + chrif->auth_db = idb_alloc(DB_OPT_BASE); + chrif->auth_db_ers = ers_new(sizeof(struct auth_node),"chrif.c::auth_db_ers",ERS_OPT_NONE); - timer->add_func_list(check_connect_char_server, "check_connect_char_server"); - timer->add_func_list(auth_db_cleanup, "auth_db_cleanup"); + timer->add_func_list(chrif->check_connect_char_server, "check_connect_char_server"); + timer->add_func_list(chrif->auth_db_cleanup, "auth_db_cleanup"); + timer->add_func_list(chrif->send_usercount_tochar, "send_usercount_tochar"); // establish map-char connection if not present - timer->add_interval(timer->gettick() + 1000, check_connect_char_server, 0, 0, 10 * 1000); + timer->add_interval(timer->gettick() + 1000, chrif->check_connect_char_server, 0, 0, 10 * 1000); // wipe stale data for timed-out client connection requests - timer->add_interval(timer->gettick() + 1000, auth_db_cleanup, 0, 0, 30 * 1000); + timer->add_interval(timer->gettick() + 1000, chrif->auth_db_cleanup, 0, 0, 30 * 1000); // send the user count every 10 seconds, to hide the charserver's online counting problem - timer->add_interval(timer->gettick() + 1000, send_usercount_tochar, 0, 0, UPDATE_INTERVAL); + timer->add_interval(timer->gettick() + 1000, chrif->send_usercount_tochar, 0, 0, UPDATE_INTERVAL); return 0; } @@ -1665,15 +1637,39 @@ int do_init_chrif(void) { * created by Susu *-------------------------------------*/ void chrif_defaults(void) { + const int packet_len_table[CHRIF_PACKET_LEN_TABLE_SIZE] = { // U - used, F - free + 60, 3,-1,27,10,-1, 6,-1, // 2af8-2aff: U->2af8, U->2af9, U->2afa, U->2afb, U->2afc, U->2afd, U->2afe, U->2aff + 6,-1,18, 7,-1,39,30, 10, // 2b00-2b07: U->2b00, U->2b01, U->2b02, U->2b03, U->2b04, U->2b05, U->2b06, U->2b07 + 6,30, -1, 0,86, 7,44,34, // 2b08-2b0f: U->2b08, U->2b09, U->2b0a, F->2b0b, U->2b0c, U->2b0d, U->2b0e, U->2b0f + 11,10,10, 0,11, 0,266,10, // 2b10-2b17: U->2b10, U->2b11, U->2b12, F->2b13, U->2b14, F->2b15, U->2b16, U->2b17 + 2,10, 2,-1,-1,-1, 2, 7, // 2b18-2b1f: U->2b18, U->2b19, U->2b1a, U->2b1b, U->2b1c, U->2b1d, U->2b1e, U->2b1f + -1,10, 8, 2, 2,14,19,19, // 2b20-2b27: U->2b20, U->2b21, U->2b22, U->2b23, U->2b24, U->2b25, U->2b26, U->2b27 + }; + chrif = &chrif_s; /* vars */ - chrif->connected = 0; chrif->other_mapserver_count = 0; - - /* funcs */ + memcpy(chrif->packet_len_table,&packet_len_table,sizeof(chrif->packet_len_table)); + chrif->fd = -1; + chrif->srvinfo = 0; + memset(chrif->ip_str,0,sizeof(chrif->ip_str)); + chrif->ip = 0; + chrif->port = 6121; + memset(chrif->userid,0,sizeof(chrif->userid)); + memset(chrif->passwd,0,sizeof(chrif->passwd)); + chrif->state = 0; + + /* */ + chrif->auth_db = NULL; + chrif->auth_db_ers = NULL; + /* */ + chrif->init = do_init_chrif; + chrif->final = do_final_chrif; + + /* funcs */ chrif->setuserid = chrif_setuserid; chrif->setpasswd = chrif_setpasswd; chrif->checkdefaultlogin = chrif_checkdefaultlogin; @@ -1713,10 +1709,41 @@ void chrif_defaults(void) { chrif->removefriend = chrif_removefriend; chrif->send_report = chrif_send_report; - - chrif->do_final_chrif = do_final_chrif; - chrif->do_init_chrif = do_init_chrif; - + chrif->flush_fifo = chrif_flush_fifo; chrif->skillid2idx = chrif_skillid2idx; + + chrif->sd_to_auth = chrif_sd_to_auth; + chrif->check_connect_char_server = check_connect_char_server; + chrif->auth_logout = chrif_auth_logout; + chrif->save_ack = chrif_save_ack; + chrif->reconnect = chrif_reconnect; + chrif->auth_db_cleanup_sub = auth_db_cleanup_sub; + chrif->char_ask_name_answer = chrif_char_ask_name_answer; + chrif->auth_db_final = auth_db_final; + chrif->send_usercount_tochar = send_usercount_tochar; + chrif->auth_db_cleanup = auth_db_cleanup; + + chrif->connect = chrif_connect; + chrif->connectack = chrif_connectack; + chrif->sendmap = chrif_sendmap; + chrif->sendmapack = chrif_sendmapack; + chrif->recvmap = chrif_recvmap; + chrif->changemapserverack = chrif_changemapserverack; + chrif->changedsex = chrif_changedsex; + chrif->divorceack = chrif_divorceack; + chrif->accountban = chrif_accountban; + chrif->recvfamelist = chrif_recvfamelist; + chrif->load_scdata = chrif_load_scdata; + chrif->update_ip = chrif_update_ip; + chrif->disconnectplayer = chrif_disconnectplayer; + chrif->removemap = chrif_removemap; + chrif->updatefamelist_ack = chrif->updatefamelist_ack; + chrif->keepalive = chrif_keepalive; + chrif->keepalive_ack = chrif_keepalive_ack; + chrif->deadopt = chrif_deadopt; + chrif->authfail = chrif_authfail; + chrif->on_ready = chrif_on_ready; + chrif->on_disconnect = chrif_on_disconnect; + chrif->parse = chrif_parse; } diff --git a/src/map/chrif.h b/src/map/chrif.h index b6883d855..0617a6702 100644 --- a/src/map/chrif.h +++ b/src/map/chrif.h @@ -7,9 +7,26 @@ #include "../common/cbasetypes.h" #include <time.h> +#include "map.h" //TBL_stuff +/** + * Defines + **/ +//Interval at which map server updates online listing. [Valaris] +#define CHECK_INTERVAL 3600000 +//Interval at which map server sends number of connected users. [Skotlex] +#define UPDATE_INTERVAL 10000 + +#define CHRIF_PACKET_LEN_TABLE_SIZE 0x3d + +/** + * Enumerations + **/ enum sd_state { ST_LOGIN, ST_LOGOUT, ST_MAPCHANGE }; +/** + * Structures + **/ struct auth_node { int account_id, char_id; int login_id1, login_id2, sex, fd; @@ -32,8 +49,22 @@ struct chrif_interface { int connected; int other_mapserver_count; //Holds count of how many other map servers are online (apart of this instance) [Skotlex] + /* */ + struct eri *auth_db_ers; //For reutilizing player login structures. + DBMap* auth_db; // int id -> struct auth_node* + /* */ + int packet_len_table[CHRIF_PACKET_LEN_TABLE_SIZE]; + int fd; + int srvinfo; + char ip_str[128]; + uint32 ip; + uint16 port; + char userid[NAME_LENGTH], passwd[NAME_LENGTH]; + int state; + /* */ + int (*final) (void); + int (*init) (void); /* funcs */ - void (*setuserid) (char* id); void (*setpasswd) (char* pwd); void (*checkdefaultlogin) (void); @@ -73,12 +104,43 @@ struct chrif_interface { int (*removefriend) (int char_id, int friend_id); void (*send_report) (char* buf, int len); - - int (*do_final_chrif) (void); - int (*do_init_chrif) (void); - + int (*flush_fifo) (void); void (*skillid2idx) (int fd); + + bool (*sd_to_auth) (TBL_PC* sd, enum sd_state state); + int (*check_connect_char_server) (int tid, unsigned int tick, int id, intptr_t data); + bool (*auth_logout) (TBL_PC* sd, enum sd_state state); + void (*save_ack) (int fd); + int (*reconnect) (DBKey key, DBData *data, va_list ap); + int (*auth_db_cleanup_sub) (DBKey key, DBData *data, va_list ap); + void (*char_ask_name_answer) (int acc, const char* player_name, uint16 type, uint16 answer); + int (*auth_db_final) (DBKey key, DBData *data, va_list ap); + int (*send_usercount_tochar) (int tid, unsigned int tick, int id, intptr_t data); + int (*auth_db_cleanup) (int tid, unsigned int tick, int id, intptr_t data); + + int (*connect) (int fd); + int (*connectack) (int fd); + int (*sendmap) (int fd); + int (*sendmapack) (int fd); + int (*recvmap) (int fd); + int (*changemapserverack) (int account_id, int login_id1, int login_id2, int char_id, short map_index, short x, short y, uint32 ip, uint16 port); + int (*changedsex) (int fd); + int (*divorceack) (int char_id, int partner_id); + int (*accountban) (int fd); + int (*recvfamelist) (int fd); + int (*load_scdata) (int fd); + void (*update_ip) (int fd); + int (*disconnectplayer) (int fd); + int (*removemap) (int fd); + int (*updatefamelist_ack) (int fd); + void (*keepalive)(int fd); + void (*keepalive_ack) (int fd); + int (*deadopt) (int father_id, int mother_id, int child_id); + void (*authfail) (int fd); + void (*on_ready) (void); + void (*on_disconnect) (void); + int (*parse) (int fd); }; struct chrif_interface *chrif; diff --git a/src/map/clif.c b/src/map/clif.c index e85f1131f..ed75e9aa0 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -239,13 +239,13 @@ uint32 clif_refresh_ip(void) { #if PACKETVER >= 20071106 static inline unsigned char clif_bl_type(struct block_list *bl) { switch (bl->type) { - case BL_PC: return (disguised(bl) && !pcdb_checkid(iStatus->get_viewdata(bl)->class_))? 0x1:0x0; //PC_TYPE + case BL_PC: return (disguised(bl) && !pcdb_checkid(status->get_viewdata(bl)->class_))? 0x1:0x0; //PC_TYPE case BL_ITEM: return 0x2; //ITEM_TYPE case BL_SKILL: return 0x3; //SKILL_TYPE case BL_CHAT: return 0x4; //UNKNOWN_TYPE - case BL_MOB: return pcdb_checkid(iStatus->get_viewdata(bl)->class_)?0x0:0x5; //NPC_MOB_TYPE + case BL_MOB: return pcdb_checkid(status->get_viewdata(bl)->class_)?0x0:0x5; //NPC_MOB_TYPE case BL_NPC: return 0x6; //NPC_EVT_TYPE - case BL_PET: return pcdb_checkid(iStatus->get_viewdata(bl)->class_)?0x0:0x7; //NPC_PET_TYPE + case BL_PET: return pcdb_checkid(status->get_viewdata(bl)->class_)?0x0:0x7; //NPC_PET_TYPE case BL_HOM: return 0x8; //NPC_HOM_TYPE case BL_MER: return 0x9; //NPC_MERSOL_TYPE case BL_ELEM: return 0xa; //NPC_ELEMENTAL_TYPE @@ -378,12 +378,12 @@ int clif_send(const void* buf, int len, struct block_list* bl, enum send_target clif->send (buf, len, bl, SELF); case AREA_WOC: case AREA_WOS: - iMap->foreachinarea(clif->send_sub, bl->m, bl->x-AREA_SIZE, bl->y-AREA_SIZE, bl->x+AREA_SIZE, bl->y+AREA_SIZE, + map->foreachinarea(clif->send_sub, bl->m, bl->x-AREA_SIZE, bl->y-AREA_SIZE, bl->x+AREA_SIZE, bl->y+AREA_SIZE, BL_PC, buf, len, bl, type); break; case AREA_CHAT_WOC: - iMap->foreachinarea(clif->send_sub, bl->m, bl->x-(AREA_SIZE-5), bl->y-(AREA_SIZE-5), - bl->x+(AREA_SIZE-5), bl->y+(AREA_SIZE-5), BL_PC, buf, len, bl, AREA_WOC); + map->foreachinarea(clif->send_sub, bl->m, bl->x-(AREA_SIZE-5), bl->y-(AREA_SIZE-5), + bl->x+(AREA_SIZE-5), bl->y+(AREA_SIZE-5), BL_PC, buf, len, bl, AREA_WOC); break; case CHAT: @@ -391,7 +391,7 @@ int clif_send(const void* buf, int len, struct block_list* bl, enum send_target { struct chat_data *cd; if (sd) { - cd = (struct chat_data*)iMap->id2bl(sd->chatID); + cd = (struct chat_data*)map->id2bl(sd->chatID); } else if (bl->type == BL_CHAT) { cd = (struct chat_data*)bl; } else break; @@ -443,7 +443,7 @@ int clif_send(const void* buf, int len, struct block_list* bl, enum send_target memcpy(WFIFOP(fd,0), buf, len); WFIFOSET(fd,len); } - if (!iMap->enable_spy) //Skip unnecessary parsing. [Skotlex] + if (!map->enable_spy) //Skip unnecessary parsing. [Skotlex] break; iter = mapit_getallusers(); @@ -520,7 +520,7 @@ int clif_send(const void* buf, int len, struct block_list* bl, enum send_target WFIFOSET(fd,len); } } - if (!iMap->enable_spy) //Skip unnecessary parsing. [Skotlex] + if (!map->enable_spy) //Skip unnecessary parsing. [Skotlex] break; iter = mapit_getallusers(); @@ -569,7 +569,7 @@ int clif_send(const void* buf, int len, struct block_list* bl, enum send_target for( i = 0; i < queue->size; i++ ) { struct map_session_data * sd = NULL; - if( queue->item[i] > 0 && ( sd = iMap->id2sd(queue->item[i]) ) ) { + if( queue->item[i] > 0 && ( sd = map->id2sd(queue->item[i]) ) ) { WFIFOHEAD(sd->fd,len); memcpy(WFIFOP(sd->fd,0), buf, len); WFIFOSET(sd->fd,len); @@ -674,12 +674,11 @@ void clif_authfail_fd(int fd, int type) /// type: /// 1 = disconnect, char-select /// ? = nothing -void clif_charselectok(int id, uint8 ok) -{ +void clif_charselectok(int id, uint8 ok) { struct map_session_data* sd; int fd; - if ((sd = iMap->id2sd(id)) == NULL || !sd->fd) + if ((sd = map->id2sd(id)) == NULL || !sd->fd) return; fd = sd->fd; @@ -850,7 +849,7 @@ static int clif_setlevel_sub(int lv) { } static int clif_setlevel(struct block_list* bl) { - int lv = iStatus->get_lv(bl); + int lv = status->get_lv(bl); if( battle_config.client_limit_unit_lv&bl->type ) return clif_setlevel_sub(lv); switch( bl->type ) { @@ -865,10 +864,10 @@ static int clif_setlevel(struct block_list* bl) { /* for 'packetver < 20091103' 0x78 non-pc-looking unit handling */ void clif_set_unit_idle2(struct block_list* bl, struct map_session_data *tsd, enum send_target target) { struct map_session_data* sd; - struct status_change* sc = iStatus->get_sc(bl); - struct view_data* vd = iStatus->get_viewdata(bl); + struct status_change* sc = status->get_sc(bl); + struct view_data* vd = status->get_viewdata(bl); struct packet_idle_unit2 p; - int g_id = iStatus->get_guild_id(bl); + int g_id = status->get_guild_id(bl); sd = BL_CAST(BL_PC, bl); @@ -877,7 +876,7 @@ void clif_set_unit_idle2(struct block_list* bl, struct map_session_data *tsd, en p.objecttype = clif_bl_type(bl); #endif p.GID = bl->id; - p.speed = iStatus->get_speed(bl); + p.speed = status->get_speed(bl); p.bodyState = (sc) ? sc->opt1 : 0; p.healthState = (sc) ? sc->opt2 : 0; p.effectState = (sc) ? sc->option : bl->type == BL_NPC ? ((TBL_NPC*)bl)->option : 0; @@ -889,7 +888,7 @@ void clif_set_unit_idle2(struct block_list* bl, struct map_session_data *tsd, en p.accessory2 = vd->head_top; p.accessory3 = vd->head_mid; if( bl->type == BL_NPC && vd->class_ == FLAG_CLASS ) { //The hell, why flags work like this? - p.shield = iStatus->get_emblem_id(bl); + p.shield = status->get_emblem_id(bl); p.accessory2 = GetWord(g_id, 1); p.accessory3 = GetWord(g_id, 0); } @@ -897,7 +896,7 @@ void clif_set_unit_idle2(struct block_list* bl, struct map_session_data *tsd, en p.bodypalette = vd->cloth_color; p.headDir = (sd)? sd->head_dir : 0; p.GUID = g_id; - p.GEmblemVer = iStatus->get_emblem_id(bl); + p.GEmblemVer = status->get_emblem_id(bl); p.honor = (sd) ? sd->status.manner : 0; p.virtue = (sc) ? sc->opt3 : 0; p.isPKModeON = (sd) ? sd->status.karma : 0; @@ -915,10 +914,10 @@ void clif_set_unit_idle2(struct block_list* bl, struct map_session_data *tsd, en *------------------------------------------*/ void clif_set_unit_idle(struct block_list* bl, struct map_session_data *tsd, enum send_target target) { struct map_session_data* sd; - struct status_change* sc = iStatus->get_sc(bl); - struct view_data* vd = iStatus->get_viewdata(bl); + struct status_change* sc = status->get_sc(bl); + struct view_data* vd = status->get_viewdata(bl); struct packet_idle_unit p; - int g_id = iStatus->get_guild_id(bl); + int g_id = status->get_guild_id(bl); #if PACKETVER < 20091103 if( !pcdb_checkid(vd->class_) ) { @@ -935,7 +934,7 @@ void clif_set_unit_idle(struct block_list* bl, struct map_session_data *tsd, enu p.objecttype = clif_bl_type(bl); #endif p.GID = bl->id; - p.speed = iStatus->get_speed(bl); + p.speed = status->get_speed(bl); p.bodyState = (sc) ? sc->opt1 : 0; p.healthState = (sc) ? sc->opt2 : 0; p.effectState = (sc) ? sc->option : bl->type == BL_NPC ? ((TBL_NPC*)bl)->option : 0; @@ -949,7 +948,7 @@ void clif_set_unit_idle(struct block_list* bl, struct map_session_data *tsd, enu p.accessory2 = vd->head_top; p.accessory3 = vd->head_mid; if( bl->type == BL_NPC && vd->class_ == FLAG_CLASS ) { //The hell, why flags work like this? - p.accessory = iStatus->get_emblem_id(bl); + p.accessory = status->get_emblem_id(bl); p.accessory2 = GetWord(g_id, 1); p.accessory3 = GetWord(g_id, 0); } @@ -960,7 +959,7 @@ void clif_set_unit_idle(struct block_list* bl, struct map_session_data *tsd, enu p.robe = vd->robe; #endif p.GUID = g_id; - p.GEmblemVer = iStatus->get_emblem_id(bl); + p.GEmblemVer = status->get_emblem_id(bl); p.honor = (sd) ? sd->status.manner : 0; p.virtue = (sc) ? sc->opt3 : 0; p.isPKModeON = (sd) ? sd->status.karma : 0; @@ -988,7 +987,7 @@ void clif_set_unit_idle(struct block_list* bl, struct map_session_data *tsd, enu if( disguised(bl) ) { #if PACKETVER >= 20091103 - p.objecttype = pcdb_checkid(iStatus->get_viewdata(bl)->class_) ? 0x0 : 0x5; //PC_TYPE : NPC_MOB_TYPE + p.objecttype = pcdb_checkid(status->get_viewdata(bl)->class_) ? 0x0 : 0x5; //PC_TYPE : NPC_MOB_TYPE p.GID = -bl->id; #else p.GID = -bl->id; @@ -1001,10 +1000,10 @@ void clif_set_unit_idle(struct block_list* bl, struct map_session_data *tsd, enu /* for 'packetver < 20091103' 0x7c non-pc-looking unit handling */ void clif_spawn_unit2(struct block_list* bl, enum send_target target) { struct map_session_data* sd; - struct status_change* sc = iStatus->get_sc(bl); - struct view_data* vd = iStatus->get_viewdata(bl); + struct status_change* sc = status->get_sc(bl); + struct view_data* vd = status->get_viewdata(bl); struct packet_spawn_unit2 p; - int g_id = iStatus->get_guild_id(bl); + int g_id = status->get_guild_id(bl); sd = BL_CAST(BL_PC, bl); @@ -1013,7 +1012,7 @@ void clif_spawn_unit2(struct block_list* bl, enum send_target target) { p.objecttype = clif_bl_type(bl); #endif p.GID = bl->id; - p.speed = iStatus->get_speed(bl); + p.speed = status->get_speed(bl); p.bodyState = (sc) ? sc->opt1 : 0; p.healthState = (sc) ? sc->opt2 : 0; p.effectState = (sc) ? sc->option : bl->type == BL_NPC ? ((TBL_NPC*)bl)->option : 0; @@ -1025,7 +1024,7 @@ void clif_spawn_unit2(struct block_list* bl, enum send_target target) { p.accessory2 = vd->head_top; p.accessory3 = vd->head_mid; if( bl->type == BL_NPC && vd->class_ == FLAG_CLASS ) { //The hell, why flags work like this? - p.shield = iStatus->get_emblem_id(bl); + p.shield = status->get_emblem_id(bl); p.accessory2 = GetWord(g_id, 1); p.accessory3 = GetWord(g_id, 0); } @@ -1042,10 +1041,10 @@ void clif_spawn_unit2(struct block_list* bl, enum send_target target) { #endif void clif_spawn_unit(struct block_list* bl, enum send_target target) { struct map_session_data* sd; - struct status_change* sc = iStatus->get_sc(bl); - struct view_data* vd = iStatus->get_viewdata(bl); + struct status_change* sc = status->get_sc(bl); + struct view_data* vd = status->get_viewdata(bl); struct packet_spawn_unit p; - int g_id = iStatus->get_guild_id(bl); + int g_id = status->get_guild_id(bl); #if PACKETVER < 20091103 if( !pcdb_checkid(vd->class_) ) { @@ -1062,7 +1061,7 @@ void clif_spawn_unit(struct block_list* bl, enum send_target target) { p.objecttype = clif_bl_type(bl); #endif p.GID = bl->id; - p.speed = iStatus->get_speed(bl); + p.speed = status->get_speed(bl); p.bodyState = (sc) ? sc->opt1 : 0; p.healthState = (sc) ? sc->opt2 : 0; p.effectState = (sc) ? sc->option : bl->type == BL_NPC ? ((TBL_NPC*)bl)->option : 0; @@ -1076,7 +1075,7 @@ void clif_spawn_unit(struct block_list* bl, enum send_target target) { p.accessory2 = vd->head_top; p.accessory3 = vd->head_mid; if( bl->type == BL_NPC && vd->class_ == FLAG_CLASS ) { //The hell, why flags work like this? - p.accessory = iStatus->get_emblem_id(bl); + p.accessory = status->get_emblem_id(bl); p.accessory2 = GetWord(g_id, 1); p.accessory3 = GetWord(g_id, 0); } @@ -1087,7 +1086,7 @@ void clif_spawn_unit(struct block_list* bl, enum send_target target) { p.robe = vd->robe; #endif p.GUID = g_id; - p.GEmblemVer = iStatus->get_emblem_id(bl); + p.GEmblemVer = status->get_emblem_id(bl); p.honor = (sd) ? sd->status.manner : 0; p.virtue = (sc) ? sc->opt3 : 0; p.isPKModeON = (sd) ? sd->status.karma : 0; @@ -1113,7 +1112,7 @@ void clif_spawn_unit(struct block_list* bl, enum send_target target) { if( sd->status.class_ != sd->disguise ) clif->send(&p,sizeof(p),bl,target); #if PACKETVER >= 20091103 - p.objecttype = pcdb_checkid(iStatus->get_viewdata(bl)->class_) ? 0x0 : 0x5; //PC_TYPE : NPC_MOB_TYPE + p.objecttype = pcdb_checkid(status->get_viewdata(bl)->class_) ? 0x0 : 0x5; //PC_TYPE : NPC_MOB_TYPE p.GID = -bl->id; #else p.GID = -bl->id; @@ -1129,10 +1128,10 @@ void clif_spawn_unit(struct block_list* bl, enum send_target target) { *------------------------------------------*/ void clif_set_unit_walking(struct block_list* bl, struct map_session_data *tsd, struct unit_data* ud, enum send_target target) { struct map_session_data* sd; - struct status_change* sc = iStatus->get_sc(bl); - struct view_data* vd = iStatus->get_viewdata(bl); + struct status_change* sc = status->get_sc(bl); + struct view_data* vd = status->get_viewdata(bl); struct packet_unit_walking p; - int g_id = iStatus->get_guild_id(bl); + int g_id = status->get_guild_id(bl); sd = BL_CAST(BL_PC, bl); @@ -1144,7 +1143,7 @@ void clif_set_unit_walking(struct block_list* bl, struct map_session_data *tsd, p.objecttype = clif_bl_type(bl); #endif p.GID = bl->id; - p.speed = iStatus->get_speed(bl); + p.speed = status->get_speed(bl); p.bodyState = (sc) ? sc->opt1 : 0; p.healthState = (sc) ? sc->opt2 : 0; p.effectState = (sc) ? sc->option : bl->type == BL_NPC ? ((TBL_NPC*)bl)->option : 0; @@ -1165,7 +1164,7 @@ void clif_set_unit_walking(struct block_list* bl, struct map_session_data *tsd, p.robe = vd->robe; #endif p.GUID = g_id; - p.GEmblemVer = iStatus->get_emblem_id(bl); + p.GEmblemVer = status->get_emblem_id(bl); p.honor = (sd) ? sd->status.manner : 0; p.virtue = (sc) ? sc->opt3 : 0; p.isPKModeON = (sd) ? sd->status.karma : 0; @@ -1192,7 +1191,7 @@ void clif_set_unit_walking(struct block_list* bl, struct map_session_data *tsd, if( disguised(bl) ) { #if PACKETVER >= 20091103 - p.objecttype = pcdb_checkid(iStatus->get_viewdata(bl)->class_) ? 0x0 : 0x5; //PC_TYPE : NPC_MOB_TYPE + p.objecttype = pcdb_checkid(status->get_viewdata(bl)->class_) ? 0x0 : 0x5; //PC_TYPE : NPC_MOB_TYPE p.GID = -bl->id; #else p.GID = -bl->id; @@ -1293,7 +1292,7 @@ int clif_spawn(struct block_list *bl) { struct view_data *vd; - vd = iStatus->get_viewdata(bl); + vd = status->get_viewdata(bl); if( !vd || vd->class_ == INVISIBLE_CLASS ) return 0; @@ -1572,7 +1571,7 @@ void clif_move(struct unit_data *ud) struct view_data* vd; struct block_list* bl = ud->bl; - vd = iStatus->get_viewdata(bl); + vd = status->get_viewdata(bl); if (!vd || vd->class_ == INVISIBLE_CLASS) return; //This performance check is needed to keep GM-hidden objects from being notified to bots. @@ -1603,14 +1602,14 @@ void clif_move(struct unit_data *ud) /*========================================== - * Delays the iMap->quit of a player after they are disconnected. [Skotlex] + * Delays the map->quit of a player after they are disconnected. [Skotlex] *------------------------------------------*/ int clif_delayquit(int tid, unsigned int tick, int id, intptr_t data) { struct map_session_data *sd = NULL; //Remove player from map server - if ((sd = iMap->id2sd(id)) != NULL && sd->fd == 0) //Should be a disconnected player. - iMap->quit(sd); + if ((sd = map->id2sd(id)) != NULL && sd->fd == 0) //Should be a disconnected player. + map->quit(sd); return 0; } @@ -1620,7 +1619,7 @@ int clif_delayquit(int tid, unsigned int tick, int id, intptr_t data) { void clif_quitsave(int fd,struct map_session_data *sd) { if (!battle_config.prevent_logout || DIFF_TICK(timer->gettick(), sd->canlog_tick) > battle_config.prevent_logout) - iMap->quit(sd); + map->quit(sd); else if (sd->fd) { //Disassociate session from player (session is deleted after this function was called) //And set a timer to make him quit later. @@ -1914,16 +1913,15 @@ void clif_sendfakenpc(struct map_session_data *sd, int npcid) { /// WARNING: the 'cancel' button closes other windows besides the dialog window and the menu window. /// Which suggests their have intertwined behavior. (probably the mouse targeting) /// TODO investigate behavior of other windows [FlavioJS] -void clif_scriptmenu(struct map_session_data* sd, int npcid, const char* mes) -{ +void clif_scriptmenu(struct map_session_data* sd, int npcid, const char* mes) { int fd = sd->fd; int slen = strlen(mes) + 9; struct block_list *bl = NULL; - if (!sd->state.using_fake_npc && (npcid == npc->fake_nd->bl.id || ((bl = iMap->id2bl(npcid)) && (bl->m!=sd->bl.m || - bl->x<sd->bl.x-AREA_SIZE-1 || bl->x>sd->bl.x+AREA_SIZE+1 || - bl->y<sd->bl.y-AREA_SIZE-1 || bl->y>sd->bl.y+AREA_SIZE+1)))) - clif->sendfakenpc(sd, npcid); + if (!sd->state.using_fake_npc && (npcid == npc->fake_nd->bl.id || ((bl = map->id2bl(npcid)) && (bl->m!=sd->bl.m || + bl->x<sd->bl.x-AREA_SIZE-1 || bl->x>sd->bl.x+AREA_SIZE+1 || + bl->y<sd->bl.y-AREA_SIZE-1 || bl->y>sd->bl.y+AREA_SIZE+1)))) + clif->sendfakenpc(sd, npcid); WFIFOHEAD(fd, slen); WFIFOW(fd,0)=0xb7; @@ -1945,17 +1943,16 @@ void clif_scriptmenu(struct map_session_data* sd, int npcid, const char* mes) /// - if npcid exists in the client: /// - 0143 <npcid of inputnum window>.L <atoi(text)>.L /// - close inputnum window -void clif_scriptinput(struct map_session_data *sd, int npcid) -{ +void clif_scriptinput(struct map_session_data *sd, int npcid) { int fd; struct block_list *bl = NULL; nullpo_retv(sd); - if (!sd->state.using_fake_npc && (npcid == npc->fake_nd->bl.id || ((bl = iMap->id2bl(npcid)) && (bl->m!=sd->bl.m || - bl->x<sd->bl.x-AREA_SIZE-1 || bl->x>sd->bl.x+AREA_SIZE+1 || - bl->y<sd->bl.y-AREA_SIZE-1 || bl->y>sd->bl.y+AREA_SIZE+1)))) - clif->sendfakenpc(sd, npcid); + if (!sd->state.using_fake_npc && (npcid == npc->fake_nd->bl.id || ((bl = map->id2bl(npcid)) && (bl->m!=sd->bl.m || + bl->x<sd->bl.x-AREA_SIZE-1 || bl->x>sd->bl.x+AREA_SIZE+1 || + bl->y<sd->bl.y-AREA_SIZE-1 || bl->y>sd->bl.y+AREA_SIZE+1)))) + clif->sendfakenpc(sd, npcid); fd=sd->fd; WFIFOHEAD(fd, packet_len(0x142)); @@ -1976,17 +1973,16 @@ void clif_scriptinput(struct map_session_data *sd, int npcid) /// - if npcid is 0 or npcid exists in the client: /// - 01d5 <packetlen>.W <npcid of inputstr window>.L <text>.?B /// - close inputstr window -void clif_scriptinputstr(struct map_session_data *sd, int npcid) -{ +void clif_scriptinputstr(struct map_session_data *sd, int npcid) { int fd; struct block_list *bl = NULL; nullpo_retv(sd); - if (!sd->state.using_fake_npc && (npcid == npc->fake_nd->bl.id || ((bl = iMap->id2bl(npcid)) && (bl->m!=sd->bl.m || - bl->x<sd->bl.x-AREA_SIZE-1 || bl->x>sd->bl.x+AREA_SIZE+1 || - bl->y<sd->bl.y-AREA_SIZE-1 || bl->y>sd->bl.y+AREA_SIZE+1)))) - clif->sendfakenpc(sd, npcid); + if (!sd->state.using_fake_npc && (npcid == npc->fake_nd->bl.id || ((bl = map->id2bl(npcid)) && (bl->m!=sd->bl.m || + bl->x<sd->bl.x-AREA_SIZE-1 || bl->x>sd->bl.x+AREA_SIZE+1 || + bl->y<sd->bl.y-AREA_SIZE-1 || bl->y>sd->bl.y+AREA_SIZE+1)))) + clif->sendfakenpc(sd, npcid); fd=sd->fd; WFIFOHEAD(fd, packet_len(0x1d4)); @@ -2922,7 +2918,7 @@ int clif_hpmeter_sub(struct block_list *bl, va_list ap) { *------------------------------------------*/ int clif_hpmeter(struct map_session_data *sd) { nullpo_ret(sd); - iMap->foreachinarea(clif->hpmeter_sub, sd->bl.m, sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE, sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd); + map->foreachinarea(clif->hpmeter_sub, sd->bl.m, sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE, sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd); return 0; } @@ -3193,8 +3189,8 @@ void clif_changelook(struct block_list *bl,int type,int val) nullpo_retv(bl); sd = BL_CAST(BL_PC, bl); - sc = iStatus->get_sc(bl); - vd = iStatus->get_viewdata(bl); + sc = status->get_sc(bl); + vd = status->get_viewdata(bl); //nullpo_ret(vd); if( vd ) //temp hack to let Warp Portal change appearance switch(type) { @@ -3481,14 +3477,14 @@ void clif_arrow_create_list(struct map_session_data *sd) WFIFOW(fd,0) = 0x1ad; for (i = 0, c = 0; i < MAX_SKILL_ARROW_DB; i++) { - if (skill_arrow_db[i].nameid > 0 && - (j = pc->search_inventory(sd, skill_arrow_db[i].nameid)) >= 0 && + if (skill->arrow_db[i].nameid > 0 && + (j = pc->search_inventory(sd, skill->arrow_db[i].nameid)) >= 0 && !sd->status.inventory[j].equip && sd->status.inventory[j].identify) { - if ((j = itemdb_viewid(skill_arrow_db[i].nameid)) > 0) + if ((j = itemdb_viewid(skill->arrow_db[i].nameid)) > 0) WFIFOW(fd,c*2+4) = j; else - WFIFOW(fd,c*2+4) = skill_arrow_db[i].nameid; + WFIFOW(fd,c*2+4) = skill->arrow_db[i].nameid; c++; } } @@ -3614,7 +3610,7 @@ void clif_changeoption(struct block_list* bl) nullpo_retv(bl); - if ( !(sc = iStatus->get_sc(bl)) && bl->type != BL_NPC ) return; //How can an option change if there's no sc? + if ( !(sc = status->get_sc(bl)) && bl->type != BL_NPC ) return; //How can an option change if there's no sc? sd = BL_CAST(BL_PC, bl); @@ -3660,7 +3656,7 @@ void clif_changeoption2(struct block_list* bl) { unsigned char buf[20]; struct status_change *sc; - if ( !(sc = iStatus->get_sc(bl)) && bl->type != BL_NPC ) return; //How can an option change if there's no sc? + if ( !(sc = status->get_sc(bl)) && bl->type != BL_NPC ) return; //How can an option change if there's no sc? WBUFW(buf,0) = 0x28a; WBUFL(buf,2) = bl->id; @@ -3975,8 +3971,7 @@ void clif_leavechat(struct chat_data* cd, struct map_session_data* sd, bool flag /// Opens a trade request window from char 'name'. /// 00e5 <nick>.24B (ZC_REQ_EXCHANGE_ITEM) /// 01f4 <nick>.24B <charid>.L <baselvl>.W (ZC_REQ_EXCHANGE_ITEM2) -void clif_traderequest(struct map_session_data* sd, const char* name) -{ +void clif_traderequest(struct map_session_data* sd, const char* name) { int fd = sd->fd; #if PACKETVER < 6 @@ -3984,8 +3979,8 @@ void clif_traderequest(struct map_session_data* sd, const char* name) WFIFOW(fd,0) = 0xe5; safestrncpy((char*)WFIFOP(fd,2), name, NAME_LENGTH); WFIFOSET(fd,packet_len(0xe5)); -#else - struct map_session_data* tsd = iMap->id2sd(sd->trade_partner); +#else // PACKETVER >= 6 + struct map_session_data* tsd = map->id2sd(sd->trade_partner); if( !tsd ) return; WFIFOHEAD(fd,packet_len(0x1f4)); @@ -3994,7 +3989,7 @@ void clif_traderequest(struct map_session_data* sd, const char* name) WFIFOL(fd,26) = tsd->status.char_id; WFIFOW(fd,30) = tsd->status.base_level; WFIFOSET(fd,packet_len(0x1f4)); -#endif +#endif // PACKETVER < 6 } @@ -4008,23 +4003,24 @@ void clif_traderequest(struct map_session_data* sd, const char* name) /// 3 = Accept /// 4 = Cancel /// 5 = Busy -void clif_tradestart(struct map_session_data* sd, uint8 type) -{ +void clif_tradestart(struct map_session_data* sd, uint8 type) { int fd = sd->fd; - struct map_session_data* tsd = iMap->id2sd(sd->trade_partner); - if( PACKETVER < 6 || !tsd ) { - WFIFOHEAD(fd,packet_len(0xe7)); - WFIFOW(fd,0) = 0xe7; - WFIFOB(fd,2) = type; - WFIFOSET(fd,packet_len(0xe7)); - } else { +#if PACKETVER >= 6 + struct map_session_data* tsd = map->id2sd(sd->trade_partner); + if( tsd ) { WFIFOHEAD(fd,packet_len(0x1f5)); WFIFOW(fd,0) = 0x1f5; WFIFOB(fd,2) = type; WFIFOL(fd,3) = tsd->status.char_id; WFIFOW(fd,7) = tsd->status.base_level; WFIFOSET(fd,packet_len(0x1f5)); + return; } +#endif // PACKETVER >= 6 + WFIFOHEAD(fd,packet_len(0xe7)); + WFIFOW(fd,0) = 0xe7; + WFIFOB(fd,2) = type; + WFIFOSET(fd,packet_len(0xe7)); } @@ -4273,7 +4269,7 @@ void clif_getareachar_pc(struct map_session_data* sd,struct map_session_data* ds if( dstsd->chatID ) { struct chat_data *cd = NULL; - if( (cd = (struct chat_data*)iMap->id2bl(dstsd->chatID)) && cd->usersd[0]==dstsd) + if( (cd = (struct chat_data*)map->id2bl(dstsd->chatID)) && cd->usersd[0]==dstsd) clif->dispchat(cd,sd->fd); } else if( dstsd->state.vending ) clif->showvendingboard(&dstsd->bl,dstsd->message,sd->fd); @@ -4302,7 +4298,7 @@ void clif_getareachar_pc(struct map_session_data* sd,struct map_session_data* ds ARR_FIND( 0, 5, i, dstsd->devotion[i] > 0 ); if( i < 5 ) clif->devotion(&dstsd->bl, sd); // display link (dstsd - crusader) to sd - if( dstsd->sc.data[SC_DEVOTION] && (d_bl = iMap->id2bl(dstsd->sc.data[SC_DEVOTION]->val1)) != NULL ) + if( dstsd->sc.data[SC_DEVOTION] && (d_bl = map->id2bl(dstsd->sc.data[SC_DEVOTION]->val1)) != NULL ) clif->devotion(d_bl, sd); } @@ -4310,7 +4306,7 @@ void clif_getareachar_unit(struct map_session_data* sd,struct block_list *bl) { struct unit_data *ud; struct view_data *vd; - vd = iStatus->get_viewdata(bl); + vd = status->get_viewdata(bl); if (!vd || vd->class_ == INVISIBLE_CLASS) return; @@ -4350,7 +4346,7 @@ void clif_getareachar_unit(struct map_session_data* sd,struct block_list *bl) { { TBL_NPC* nd = (TBL_NPC*)bl; if( nd->chat_id ) - clif->dispchat((struct chat_data*)iMap->id2bl(nd->chat_id),sd->fd); + clif->dispchat((struct chat_data*)map->id2bl(nd->chat_id),sd->fd); if( nd->size == SZ_BIG ) clif->specialeffect_single(bl,423,sd->fd); else if( nd->size == SZ_MEDIUM ) @@ -4447,7 +4443,7 @@ int clif_damage(struct block_list* src, struct block_list* dst, unsigned int tic damage2 = (int)cap_value(in_damage2,INT_MIN,INT_MAX); type = clif_calc_delay(type,div,damage+damage2,ddelay); - sc = iStatus->get_sc(dst); + sc = status->get_sc(dst); if(sc && sc->count) { if(sc->data[SC_ILLUSION]) { if(damage) damage = damage*(sc->data[SC_ILLUSION]->val2) + rnd()%100; @@ -4772,7 +4768,7 @@ int clif_outsight(struct block_list *bl,va_list ap) clif->clearunit_single(bl->id,CLR_OUTSIGHT,tsd->fd); if(sd->chatID){ struct chat_data *cd; - cd=(struct chat_data*)iMap->id2bl(sd->chatID); + cd=(struct chat_data*)map->id2bl(sd->chatID); if(cd->usersd[0]==sd) clif->dispchat(cd,tsd->fd); } @@ -4792,13 +4788,13 @@ int clif_outsight(struct block_list *bl,va_list ap) clif->clearunit_single(bl->id,CLR_OUTSIGHT,tsd->fd); break; default: - if ((vd=iStatus->get_viewdata(bl)) && vd->class_ != INVISIBLE_CLASS) + if ((vd=status->get_viewdata(bl)) && vd->class_ != INVISIBLE_CLASS) clif->clearunit_single(bl->id,CLR_OUTSIGHT,tsd->fd); break; } } if (sd && sd->fd) { //sd is watching tbl go out of view. - if (((vd=iStatus->get_viewdata(tbl)) && vd->class_ != INVISIBLE_CLASS) && + if (((vd=status->get_viewdata(tbl)) && vd->class_ != INVISIBLE_CLASS) && !(tbl->type == BL_NPC && (((TBL_NPC*)tbl)->option&OPTION_INVISIBLE))) clif->clearunit_single(tbl->id,CLR_OUTSIGHT,sd->fd); } @@ -5116,8 +5112,7 @@ void clif_skill_cooldown(struct map_session_data *sd, uint16 skill_id, unsigned /// Skill attack effect and damage. /// 0114 <skill id>.W <src id>.L <dst id>.L <tick>.L <src delay>.L <dst delay>.L <damage>.W <level>.W <div>.W <type>.B (ZC_NOTIFY_SKILL) /// 01de <skill id>.W <src id>.L <dst id>.L <tick>.L <src delay>.L <dst delay>.L <damage>.L <level>.W <div>.W <type>.B (ZC_NOTIFY_SKILL2) -int clif_skill_damage(struct block_list *src,struct block_list *dst,unsigned int tick,int sdelay,int ddelay,int64 in_damage,int div,uint16 skill_id,uint16 skill_lv,int type) -{ +int clif_skill_damage(struct block_list *src,struct block_list *dst,unsigned int tick,int sdelay,int ddelay,int64 in_damage,int div,uint16 skill_id,uint16 skill_lv,int type) { unsigned char buf[64]; struct status_change *sc; int damage; @@ -5127,7 +5122,7 @@ int clif_skill_damage(struct block_list *src,struct block_list *dst,unsigned int damage = (int)cap_value(in_damage,INT_MIN,INT_MAX); type = clif_calc_delay(type,div,damage,ddelay); - sc = iStatus->get_sc(dst); + sc = status->get_sc(dst); if(sc && sc->count) { if(sc->data[SC_ILLUSION] && damage) damage = damage*(sc->data[SC_ILLUSION]->val2) + rnd()%100; @@ -5204,9 +5199,8 @@ int clif_skill_damage(struct block_list *src,struct block_list *dst,unsigned int /// Ground skill attack effect and damage (ZC_NOTIFY_SKILL_POSITION). /// 0115 <skill id>.W <src id>.L <dst id>.L <tick>.L <src delay>.L <dst delay>.L <x>.W <y>.W <damage>.W <level>.W <div>.W <type>.B -/* -int clif_skill_damage2(struct block_list *src,struct block_list *dst,unsigned int tick,int sdelay,int ddelay,int damage,int div,uint16 skill_id,uint16 skill_lv,int type) -{ +#if 0 +int clif_skill_damage2(struct block_list *src,struct block_list *dst,unsigned int tick,int sdelay,int ddelay,int damage,int div,uint16 skill_id,uint16 skill_lv,int type) { unsigned char buf[64]; struct status_change *sc; @@ -5215,7 +5209,7 @@ int clif_skill_damage2(struct block_list *src,struct block_list *dst,unsigned in type = (type>0)?type:skill_get_hit(skill_id); type = clif_calc_delay(type,div,damage,ddelay); - sc = iStatus->get_sc(dst); + sc = status->get_sc(dst); if(sc && sc->count) { if(sc->data[SC_ILLUSION] && damage) @@ -5258,7 +5252,7 @@ int clif_skill_damage2(struct block_list *src,struct block_list *dst,unsigned in //Because the damage delay must be synced with the client, here is where the can-walk tick must be updated. [Skotlex] return clif_calc_walkdelay(dst,ddelay,type,damage,div); } -*/ +#endif // 0 /// Non-damaging skill effect (ZC_USE_SKILL). @@ -5465,19 +5459,19 @@ void clif_skill_estimation(struct map_session_data *sd,struct block_list *dst) { if( dst->type != BL_MOB ) return; - dstatus = iStatus->get_status_data(dst); + dstatus = status->get_status_data(dst); - WBUFW(buf, 0)=0x18c; - WBUFW(buf, 2)=iStatus->get_class(dst); - WBUFW(buf, 4)=iStatus->get_lv(dst); - WBUFW(buf, 6)=dstatus->size; - WBUFL(buf, 8)=dstatus->hp; - WBUFW(buf,12)= (battle_config.estimation_type&1?dstatus->def:0) - +(battle_config.estimation_type&2?dstatus->def2:0); - WBUFW(buf,14)=dstatus->race; - WBUFW(buf,16)= (battle_config.estimation_type&1?dstatus->mdef:0) - +(battle_config.estimation_type&2?dstatus->mdef2:0); - WBUFW(buf,18)= dstatus->def_ele; + WBUFW(buf, 0) = 0x18c; + WBUFW(buf, 2) = status->get_class(dst); + WBUFW(buf, 4) = status->get_lv(dst); + WBUFW(buf, 6) = dstatus->size; + WBUFL(buf, 8) = dstatus->hp; + WBUFW(buf,12) = (battle_config.estimation_type&1?dstatus->def:0) + + (battle_config.estimation_type&2?dstatus->def2:0); + WBUFW(buf,14) = dstatus->race; + WBUFW(buf,16) = (battle_config.estimation_type&1?dstatus->mdef:0) + + (battle_config.estimation_type&2?dstatus->mdef2:0); + WBUFW(buf,18) = dstatus->def_ele; for(i=0;i<9;i++) WBUFB(buf,20+i)= (unsigned char)battle->attr_ratio(i+1,dstatus->def_ele, dstatus->ele_lv); // The following caps negative attributes to 0 since the client displays them as 255-fix. [Skotlex] @@ -5506,13 +5500,13 @@ void clif_skill_produce_mix_list(struct map_session_data *sd, int skill_id , int WFIFOW(fd, 0)=0x18d; for(i=0,c=0;i<MAX_SKILL_PRODUCE_DB;i++){ - if( skill->can_produce_mix(sd,skill_produce_db[i].nameid, trigger, 1) && - ( ( skill_id > 0 && skill_produce_db[i].req_skill == skill_id ) || skill_id < 0 ) + if( skill->can_produce_mix(sd,skill->produce_db[i].nameid, trigger, 1) && + ( ( skill_id > 0 && skill->produce_db[i].req_skill == skill_id ) || skill_id < 0 ) ){ - if((view = itemdb_viewid(skill_produce_db[i].nameid)) > 0) + if((view = itemdb_viewid(skill->produce_db[i].nameid)) > 0) WFIFOW(fd,c*8+ 4)= view; else - WFIFOW(fd,c*8+ 4)= skill_produce_db[i].nameid; + WFIFOW(fd,c*8+ 4)= skill->produce_db[i].nameid; WFIFOW(fd,c*8+ 6)= 0; WFIFOW(fd,c*8+ 8)= 0; WFIFOW(fd,c*8+10)= 0; @@ -5553,13 +5547,13 @@ void clif_cooking_list(struct map_session_data *sd, int trigger, uint16 skill_id c = 0; for( i = 0; i < MAX_SKILL_PRODUCE_DB; i++ ) { - if( !skill->can_produce_mix(sd,skill_produce_db[i].nameid,trigger, qty) ) + if( !skill->can_produce_mix(sd,skill->produce_db[i].nameid,trigger, qty) ) continue; - if( (view = itemdb_viewid(skill_produce_db[i].nameid)) > 0 ) + if( (view = itemdb_viewid(skill->produce_db[i].nameid)) > 0 ) WFIFOW(fd, 6 + 2 * c) = view; else - WFIFOW(fd, 6 + 2 * c) = skill_produce_db[i].nameid; + WFIFOW(fd, 6 + 2 * c) = skill->produce_db[i].nameid; c++; } @@ -5597,7 +5591,7 @@ void clif_status_change_notick(struct block_list *bl,int type,int flag,int tick, nullpo_retv(bl); - if (!(iStatus->type2relevant_bl_types(type)&bl->type)) // only send status changes that actually matter to the client + if (!(status->type2relevant_bl_types(type)&bl->type)) // only send status changes that actually matter to the client return; if (type == SI_BLANK) //It shows nothing on the client... @@ -5628,7 +5622,7 @@ void clif_status_change(struct block_list *bl,int type,int flag,int tick,int val nullpo_retv(bl); - if (!(iStatus->type2relevant_bl_types(type)&bl->type)) // only send status changes that actually matter to the client + if (!(status->type2relevant_bl_types(type)&bl->type)) // only send status changes that actually matter to the client return; if ( tick < 0 ) @@ -5930,8 +5924,7 @@ void clif_upgrademessage(int fd, int result, int item_id) /// Whisper is transmitted to the destination player (ZC_WHISPER). /// 0097 <packet len>.W <nick>.24B <message>.?B /// 0097 <packet len>.W <nick>.24B <isAdmin>.L <message>.?B (PACKETVER >= 20091104) -void clif_wis_message(int fd, const char* nick, const char* mes, int mes_len) -{ +void clif_wis_message(int fd, const char* nick, const char* mes, int mes_len) { #if PACKETVER < 20091104 WFIFOHEAD(fd, mes_len + NAME_LENGTH + 4); WFIFOW(fd,0) = 0x97; @@ -5940,7 +5933,7 @@ void clif_wis_message(int fd, const char* nick, const char* mes, int mes_len) safestrncpy((char*)WFIFOP(fd,28), mes, mes_len); WFIFOSET(fd,WFIFOW(fd,2)); #else - struct map_session_data *ssd = iMap->nick2sd(nick); + struct map_session_data *ssd = map->nick2sd(nick); WFIFOHEAD(fd, mes_len + NAME_LENGTH + 8); WFIFOW(fd,0) = 0x97; @@ -6375,7 +6368,7 @@ void clif_vendinglist(struct map_session_data* sd, unsigned int id, struct s_ven nullpo_retv(sd); nullpo_retv(vending_items); - nullpo_retv(vsd=iMap->id2sd(id)); + nullpo_retv(vsd=map->id2sd(id)); fd = sd->fd; count = vsd->vend_num; @@ -7680,8 +7673,8 @@ void clif_guild_emblem_area(struct block_list* bl) // (emblem in the flag npcs and emblem over the head in agit maps) [FlavioJS] WBUFW(buf,0) = 0x1b4; WBUFL(buf,2) = bl->id; - WBUFL(buf,6) = iStatus->get_guild_id(bl); - WBUFW(buf,10) = iStatus->get_emblem_id(bl); + WBUFL(buf,6) = status->get_guild_id(bl); + WBUFW(buf,10) = status->get_emblem_id(bl); clif->send(buf, 12, bl, AREA_WOS); } @@ -8079,28 +8072,22 @@ void clif_wedding_effect(struct block_list *bl) /// Notifies the client of the name of the partner character (ZC_COUPLENAME). /// 01e6 <partner name>.24B -void clif_callpartner(struct map_session_data *sd) -{ +void clif_callpartner(struct map_session_data *sd) { unsigned char buf[26]; nullpo_retv(sd); WBUFW(buf,0) = 0x1e6; - if( sd->status.partner_id ) - { + if( sd->status.partner_id ) { const char *p; - if( ( p = iMap->charid2nick(sd->status.partner_id) ) != NULL ) - { + if( ( p = map->charid2nick(sd->status.partner_id) ) != NULL ) { memcpy(WBUFP(buf,2), p, NAME_LENGTH); - } - else - { + } else { WBUFB(buf,2) = 0; } - } - else - {// Send zero-length name if no partner, to initialize the client buffer. + } else { + // Send zero-length name if no partner, to initialize the client buffer. WBUFB(buf,2) = 0; } @@ -8206,14 +8193,13 @@ void clif_GM_kickack(struct map_session_data *sd, int id) } -void clif_GM_kick(struct map_session_data *sd,struct map_session_data *tsd) -{ +void clif_GM_kick(struct map_session_data *sd,struct map_session_data *tsd) { int fd = tsd->fd; if( fd > 0 ) clif->authfail_fd(fd, 15); else - iMap->quit(tsd); + map->quit(tsd); if( sd ) clif->GM_kickack(sd,tsd->status.account_id); @@ -8518,10 +8504,10 @@ void clif_refresh(struct map_session_data *sd) } if( sd->ed ) clif->elemental_info(sd); - iMap->foreachinrange(clif->getareachar,&sd->bl,AREA_SIZE,BL_ALL,sd); + map->foreachinrange(clif->getareachar,&sd->bl,AREA_SIZE,BL_ALL,sd); clif->weather_check(sd); if( sd->chatID ) - chat->leavechat(sd,0); + chat->leave(sd,0); if( sd->state.vending ) clif->openvending(sd, sd->bl.id, sd->vending); if( pc_issit(sd) ) @@ -9255,7 +9241,7 @@ void clif_parse_WantToConnection(int fd, struct map_session_data* sd) { } //Check for double login. - bl = iMap->id2bl(account_id); + bl = map->id2bl(account_id); if(bl && bl->type != BL_PC) { ShowError("clif_parse_WantToConnection: a non-player object already has id %d, please increase the starting account number\n", account_id); WFIFOHEAD(fd,packet_len(0x6a)); @@ -9377,7 +9363,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { } if( maplist[sd->bl.m].users++ == 0 && battle_config.dynamic_mobs ) - iMap->spawnmobs(sd->bl.m); + map->spawnmobs(sd->bl.m); if( !(sd->sc.option&OPTION_INVISIBLE) ) { // increment the number of pvp players on the map maplist[sd->bl.m].users_pvp++; } @@ -9390,7 +9376,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { // reset the callshop flag if the player changes map sd->state.callshop = 0; - iMap->addblock(&sd->bl); + map->addblock(&sd->bl); clif->spawn(&sd->bl); // Party @@ -9426,7 +9412,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { // info about nearby objects // must use foreachinarea (CIRCULAR_AREA interferes with foreachinrange) - iMap->foreachinarea(clif->getareachar, sd->bl.m, sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE, sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_ALL, sd); + map->foreachinarea(clif->getareachar, sd->bl.m, sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE, sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_ALL, sd); // pet if( sd->pd ) { @@ -9434,7 +9420,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { clif->message(sd->fd, msg_txt(666)); pet->menu(sd, 3); //Option 3 is return to egg. } else { - iMap->addblock(&sd->pd->bl); + map->addblock(&sd->pd->bl); clif->spawn(&sd->pd->bl); clif->send_petdata(sd,sd->pd,0,0); clif->send_petstatus(sd); @@ -9444,7 +9430,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { //homunculus [blackhole89] if( homun_alive(sd->hd) ) { - iMap->addblock(&sd->hd->bl); + map->addblock(&sd->hd->bl); clif->spawn(&sd->hd->bl); clif->send_homdata(sd,SP_ACK,0); clif->hominfo(sd,sd->hd,1); @@ -9457,7 +9443,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { } if( sd->md ) { - iMap->addblock(&sd->md->bl); + map->addblock(&sd->md->bl); clif->spawn(&sd->md->bl); clif->mercenary_info(sd); clif->mercenary_skillblock(sd); @@ -9465,7 +9451,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { } if( sd->ed ) { - iMap->addblock(&sd->ed->bl); + map->addblock(&sd->ed->bl); clif->spawn(&sd->ed->bl); clif->elemental_info(sd); clif->elemental_updatestatus(sd,SP_HP); @@ -9510,13 +9496,13 @@ 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 && maplist[sd->bl.m].flag.nightenabled) { + if (map->night_flag && maplist[sd->bl.m].flag.nightenabled) { sd->state.night = 1; clif->status_change(&sd->bl, SI_SKE, 1, 0, 0, 0, 0); } // Notify everyone that this char logged in [Skotlex]. - iMap->map_foreachpc(clif->friendslist_toggle_sub, sd->status.account_id, sd->status.char_id, 1); + map->map_foreachpc(clif->friendslist_toggle_sub, sd->status.account_id, sd->status.char_id, 1); //Login Event npc->script_event(sd, NPCE_LOGIN); @@ -9551,7 +9537,8 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { || 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 && maplist[sd->bl.m].flag.nightenabled ) { //Display night. + if( map->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); @@ -9573,7 +9560,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { clif->broadcast(&sd->bl, output, strlen(output) + 1, BC_BLUE, SELF); } - iMap->iwall_get(sd); // Updates Walls Info on this Map to Client + map->iwall_get(sd); // Updates Walls Info on this Map to Client status_calc_pc(sd, false);/* some conditions are map-dependent so we must recalculate */ sd->state.changemap = false; @@ -9611,13 +9598,13 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { clif->weather_check(sd); // For automatic triggering of NPCs after map loading (so you don't need to walk 1 step first) - if (iMap->getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKNPC)) + if (map->getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKNPC)) npc->touch_areanpc(sd,sd->bl.m,sd->bl.x,sd->bl.y); else sd->areanpc_id = 0; /* it broke at some point (e.g. during a crash), so we make it visibly dead again. */ - if( !sd->status.hp && !pc_isdead(sd) && iStatus->isdead(&sd->bl) ) + if( !sd->status.hp && !pc_isdead(sd) && status->isdead(&sd->bl) ) pc_setdead(sd); // If player is dead, and is spawned (such as @refresh) send death packet. [Valaris] @@ -9817,8 +9804,7 @@ void clif_parse_QuitGame(int fd, struct map_session_data *sd) /// 0094 <id>.L (CZ_REQNAME) /// 0368 <id>.L (CZ_REQNAME2) /// There are various variants of this packet, some of them have padding between fields. -void clif_parse_GetCharNameRequest(int fd, struct map_session_data *sd) -{ +void clif_parse_GetCharNameRequest(int fd, struct map_session_data *sd) { int id = RFIFOL(fd,packet_db[RFIFOW(fd,0)].pos[0]); struct block_list* bl; //struct status_change *sc; @@ -9826,7 +9812,7 @@ void clif_parse_GetCharNameRequest(int fd, struct map_session_data *sd) if( id < 0 && -id == sd->bl.id ) // for disguises [Valaris] id = sd->bl.id; - bl = iMap->id2bl(id); + bl = map->id2bl(id); if( bl == NULL ) return; // Lagged clients could request names of already gone mobs/players. [Skotlex] @@ -9834,8 +9820,8 @@ void clif_parse_GetCharNameRequest(int fd, struct map_session_data *sd) return; // Block namerequests past view range // 'see people in GM hide' cheat detection - /* disabled due to false positives (network lag + request name of char that's about to hide = race condition) - sc = iStatus->get_sc(bl); +#if 0 /* disabled due to false positives (network lag + request name of char that's about to hide = race condition) */ + sc = status->get_sc(bl); if (sc && sc->option&OPTION_INVISIBLE && !disguised(bl) && bl->type != BL_NPC && //Skip hidden NPCs which can be seen using Maya Purple pc->get_group_level(sd) < battle_config.hack_info_GM_level @@ -9844,16 +9830,16 @@ void clif_parse_GetCharNameRequest(int fd, struct map_session_data *sd) sprintf(gm_msg, "Hack on NameRequest: character '%s' (account: %d) requested the name of an invisible target (id: %d).\n", sd->status.name, sd->status.account_id, id); ShowWarning(gm_msg); // information is sent to all online GMs - intif->wis_message_to_gm(iMap->wisp_server_name, battle_config.hack_info_GM_level, gm_msg); + intif->wis_message_to_gm(map->wisp_server_name, battle_config.hack_info_GM_level, gm_msg); return; } - */ +#endif // 0 clif->charnameack(fd, bl); } int clif_undisguise_timer(int tid, unsigned int tick, int id, intptr_t data) { struct map_session_data * sd; - if( (sd = iMap->id2sd(id)) ) { + if( (sd = map->id2sd(id)) ) { sd->fontcolor_tid = INVALID_TIMER; if( sd->fontcolor && sd->disguise == sd->status.class_ ) pc->disguise(sd,-1); @@ -9913,7 +9899,7 @@ void clif_parse_GlobalMessage(int fd, struct map_session_data* sd) sd->state.snovice_call_flag = 3; break; case 3: - sc_start(&sd->bl, iStatus->skill2sc(MO_EXPLOSIONSPIRITS), 100, 17, skill->get_time(MO_EXPLOSIONSPIRITS, 5)); //Lv17-> +50 critical (noted by Poki) [Skotlex] + sc_start(&sd->bl, status->skill2sc(MO_EXPLOSIONSPIRITS), 100, 17, skill->get_time(MO_EXPLOSIONSPIRITS, 5)); //Lv17-> +50 critical (noted by Poki) [Skotlex] clif->skill_nodamage(&sd->bl, &sd->bl, MO_EXPLOSIONSPIRITS, 5, 1); // prayer always shows successful Lv5 cast and disregards noskill restrictions sd->state.snovice_call_flag = 0; break; @@ -9989,7 +9975,7 @@ void clif_parse_GlobalMessage(int fd, struct map_session_data* sd) WFIFOSET(fd, WFIFOW(fd,2)); #ifdef PCRE_SUPPORT // trigger listening npcs - iMap->foreachinrange(npc_chat->sub, &sd->bl, AREA_SIZE, BL_NPC, text, textlen, &sd->bl); + map->foreachinrange(npc_chat->sub, &sd->bl, AREA_SIZE, BL_NPC, text, textlen, &sd->bl); #endif // Chat logging type 'O' / Global Chat @@ -10108,9 +10094,8 @@ void clif_user_count(struct map_session_data* sd, int count) { /// /w /who (CZ_REQ_USER_COUNT). /// Request to display amount of currently connected players. /// 00c1 -void clif_parse_HowManyConnections(int fd, struct map_session_data *sd) -{ - clif->user_count(sd, iMap->getusers()); +void clif_parse_HowManyConnections(int fd, struct map_session_data *sd) { + clif->user_count(sd, map->getusers()); } @@ -10468,7 +10453,7 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd) } // searching destination character - dstsd = iMap->nick2sd(target); + dstsd = map->nick2sd(target); if (dstsd == NULL || strcmp(dstsd->status.name, target) != 0) { // player is not on this map-server @@ -10493,7 +10478,7 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd) if( dstsd->state.autotrade == 1 ) { char output[256]; sprintf(output, "%s is in autotrade mode and cannot receive whispered messages.", dstsd->status.name); - clif->wis_message(fd, iMap->wisp_server_name, output, strlen(output) + 1); + clif->wis_message(fd, map->wisp_server_name, output, strlen(output) + 1); return; } @@ -10534,14 +10519,13 @@ void clif_parse_Broadcast(int fd, struct map_session_data* sd) { /// 009f <id>.L (CZ_ITEM_PICKUP) /// 0362 <id>.L (CZ_ITEM_PICKUP2) /// There are various variants of this packet, some of them have padding between fields. -void clif_parse_TakeItem(int fd, struct map_session_data *sd) -{ +void clif_parse_TakeItem(int fd, struct map_session_data *sd) { struct flooritem_data *fitem; int map_object_id; map_object_id = RFIFOL(fd,packet_db[RFIFOW(fd,0)].pos[0]); - fitem = (struct flooritem_data*)iMap->id2bl(map_object_id); + fitem = (struct flooritem_data*)map->id2bl(map_object_id); do { if (pc_isdead(sd)) { @@ -10810,7 +10794,7 @@ void clif_parse_NpcClicked(int fd,struct map_session_data *sd) #endif return; } - if ( pc_cant_act2(sd) || !(bl = iMap->id2bl(RFIFOL(fd,2))) || sd->state.vending ) + if ( pc_cant_act2(sd) || !(bl = map->id2bl(RFIFOL(fd,2))) || sd->state.vending ) return; switch (bl->type) { @@ -10953,7 +10937,7 @@ void clif_parse_CreateChatRoom(int fd, struct map_session_data* sd) safestrncpy(s_password, password, CHATROOM_PASS_SIZE); safestrncpy(s_title, title, min(len+1,CHATROOM_TITLE_SIZE)); //NOTE: assumes that safestrncpy will not access the len+1'th byte - chat->createpcchat(sd, s_title, s_password, limit, pub); + chat->create_pc_chat(sd, s_title, s_password, limit, pub); } @@ -10964,7 +10948,7 @@ void clif_parse_ChatAddMember(int fd, struct map_session_data* sd) int chatid = RFIFOL(fd,2); const char* password = (char*)RFIFOP(fd,6); // not zero-terminated - chat->joinchat(sd,chatid,password); + chat->join(sd,chatid,password); } @@ -10989,7 +10973,7 @@ void clif_parse_ChatRoomStatusChange(int fd, struct map_session_data* sd) safestrncpy(s_password, password, CHATROOM_PASS_SIZE); safestrncpy(s_title, title, min(len+1,CHATROOM_TITLE_SIZE)); //NOTE: assumes that safestrncpy will not access the len+1'th byte - chat->changechatstatus(sd, s_title, s_password, limit, pub); + chat->change_status(sd, s_title, s_password, limit, pub); } @@ -11000,7 +10984,7 @@ void clif_parse_ChatRoomStatusChange(int fd, struct map_session_data* sd) /// 1 = normal void clif_parse_ChangeChatOwner(int fd, struct map_session_data* sd) { - chat->changechatowner(sd,(char*)RFIFOP(fd,6)); + chat->change_owner(sd,(char*)RFIFOP(fd,6)); } @@ -11008,7 +10992,7 @@ void clif_parse_ChangeChatOwner(int fd, struct map_session_data* sd) /// 00e2 <name>.24B void clif_parse_KickFromChat(int fd,struct map_session_data *sd) { - chat->kickchat(sd,(char*)RFIFOP(fd,2)); + chat->kick(sd,(char*)RFIFOP(fd,2)); } @@ -11016,7 +11000,7 @@ void clif_parse_KickFromChat(int fd,struct map_session_data *sd) /// 00e3 void clif_parse_ChatLeave(int fd, struct map_session_data* sd) { - chat->leavechat(sd,0); + chat->leave(sd,0); } @@ -11037,11 +11021,10 @@ void clif_noask_sub(struct map_session_data *src, struct map_session_data *targe /// Request to begin a trade (CZ_REQ_EXCHANGE_ITEM). /// 00e4 <account id>.L -void clif_parse_TradeRequest(int fd,struct map_session_data *sd) -{ +void clif_parse_TradeRequest(int fd,struct map_session_data *sd) { struct map_session_data *t_sd; - t_sd = iMap->id2sd(RFIFOL(fd,2)); + t_sd = map->id2sd(RFIFOL(fd,2)); if(!sd->chatID && pc_cant_act(sd)) return; //You can trade while in a chatroom. @@ -11674,7 +11657,7 @@ void clif_parse_NpcSelectMenu(int fd,struct map_session_data *sd) #ifdef SECURE_NPCTIMEOUT if( sd->npc_idle_timer != INVALID_TIMER ) { #endif - TBL_NPC* nd = iMap->id2nd(npc_id); + TBL_NPC* nd = map->id2nd(npc_id); ShowWarning("Invalid menu selection on npc %d:'%s' - got %d, valid range is [%d..%d] (player AID:%d, CID:%d, name:'%s')!\n", npc_id, (nd)?nd->name:"invalid npc id", select, 1, sd->npc_menu, sd->bl.id, sd->status.char_id, sd->status.name); clif->GM_kick(NULL,sd); #ifdef SECURE_NPCTIMEOUT @@ -11830,12 +11813,11 @@ void clif_parse_InsertCard(int fd,struct map_session_data *sd) /// 0193 <char id>.L (CZ_REQNAME_BYGID) /// 0369 <char id>.L (CZ_REQNAME_BYGID2) /// There are various variants of this packet, some of them have padding between fields. -void clif_parse_SolveCharName(int fd, struct map_session_data *sd) -{ +void clif_parse_SolveCharName(int fd, struct map_session_data *sd) { int charid; charid = RFIFOL(fd,packet_db[RFIFOW(fd,0)].pos[0]); - iMap->reqnickdb(sd, charid); + map->reqnickdb(sd, charid); } @@ -12063,7 +12045,7 @@ void clif_parse_PartyInvite(int fd, struct map_session_data *sd) { return; } - t_sd = iMap->id2sd(RFIFOL(fd,2)); + t_sd = map->id2sd(RFIFOL(fd,2)); if(t_sd && t_sd->state.noask) {// @noask [LuzZza] clif->noask_sub(sd, t_sd, 1); @@ -12084,7 +12066,7 @@ void clif_parse_PartyInvite2(int fd, struct map_session_data *sd) { return; } - t_sd = iMap->nick2sd(name); + t_sd = map->nick2sd(name); if(t_sd && t_sd->state.noask) { // @noask [LuzZza] clif->noask_sub(sd, t_sd, 1); @@ -12200,9 +12182,8 @@ void clif_parse_PartyMessage(int fd, struct map_session_data* sd) /// Changes Party Leader (CZ_CHANGE_GROUP_MASTER). /// 07da <account id>.L -void clif_parse_PartyChangeLeader(int fd, struct map_session_data* sd) -{ - party->changeleader(sd, iMap->id2sd(RFIFOL(fd,2))); +void clif_parse_PartyChangeLeader(int fd, struct map_session_data* sd) { + party->changeleader(sd, map->id2sd(RFIFOL(fd,2))); } #ifndef PARTY_RECRUIT @@ -12753,7 +12734,7 @@ void clif_parse_OpenVending(int fd, struct map_session_data* sd) { clif->message (sd->fd, msg_txt(276)); // "You can't open a shop on this map" return; } - if( iMap->getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKNOVENDING) ) { + if( map->getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKNOVENDING) ) { clif->message (sd->fd, msg_txt(204)); // "You can't open a shop on this cell." return; } @@ -12950,9 +12931,8 @@ clif_sub_guild_invite(int fd, struct map_session_data *sd, struct map_session_da /// Guild invite request (CZ_REQ_JOIN_GUILD). /// 0168 <account id>.L <inviter account id>.L <inviter char id>.L -void clif_parse_GuildInvite(int fd,struct map_session_data *sd) -{ - struct map_session_data *t_sd = iMap->id2sd(RFIFOL(fd,2)); +void clif_parse_GuildInvite(int fd,struct map_session_data *sd) { + struct map_session_data *t_sd = map->id2sd(RFIFOL(fd,2)); if (clif_sub_guild_invite(fd, sd, t_sd)) return; @@ -12960,9 +12940,8 @@ void clif_parse_GuildInvite(int fd,struct map_session_data *sd) /// Guild invite request (/guildinvite) (CZ_REQ_JOIN_GUILD2). /// 0916 <char name>.24B -void clif_parse_GuildInvite2(int fd, struct map_session_data *sd) -{ - struct map_session_data *t_sd = iMap->nick2sd((char *)RFIFOP(fd, 2)); +void clif_parse_GuildInvite2(int fd, struct map_session_data *sd) { + struct map_session_data *t_sd = map->nick2sd((char *)RFIFOP(fd, 2)); if (clif_sub_guild_invite(fd, sd, t_sd)) return; @@ -13056,7 +13035,7 @@ void clif_parse_GuildRequestAlliance(int fd, struct map_session_data *sd) { return; } - t_sd = iMap->id2sd(RFIFOL(fd,2)); + t_sd = map->id2sd(RFIFOL(fd,2)); // @noask [LuzZza] if(t_sd && t_sd->state.noask) { @@ -13111,7 +13090,7 @@ void clif_parse_GuildOpposition(int fd, struct map_session_data *sd) { return; } - t_sd = iMap->id2sd(RFIFOL(fd,2)); + t_sd = map->id2sd(RFIFOL(fd,2)); // @noask [LuzZza] if(t_sd && t_sd->state.noask) { @@ -13220,13 +13199,12 @@ void clif_parse_ChangePetName(int fd, struct map_session_data *sd) /// Request to disconnect a character. /// 00cc <account id>.L /// NOTE: Also sent when using GM right click menu "(name) force to quit" -void clif_parse_GMKick(int fd, struct map_session_data *sd) -{ +void clif_parse_GMKick(int fd, struct map_session_data *sd) { struct block_list *target; int tid; tid = RFIFOL(fd,2); - target = iMap->id2bl(tid); + target = map->id2bl(tid); if (!target) { clif->GM_kickack(sd, 0); return; @@ -13236,7 +13214,7 @@ void clif_parse_GMKick(int fd, struct map_session_data *sd) case BL_PC: { char command[NAME_LENGTH+6]; - sprintf(command, "%ckick %s", atcommand->at_symbol, iStatus->get_name(target)); + sprintf(command, "%ckick %s", atcommand->at_symbol, status->get_name(target)); atcommand->parse(fd, sd, command, 1); } break; @@ -13251,7 +13229,7 @@ void clif_parse_GMKick(int fd, struct map_session_data *sd) clif->GM_kickack(sd, 0); return; } - sprintf(command, "/kick %s (%d)", iStatus->get_name(target), iStatus->get_class(target)); + sprintf(command, "/kick %s (%d)", status->get_name(target), status->get_class(target)); logs->atcommand(sd, command); status_percent_damage(&sd->bl, target, 100, 0, true); // can invalidate 'target' } @@ -13309,13 +13287,12 @@ void clif_parse_GMShift(int fd, struct map_session_data *sd) /// /remove (CZ_REMOVE_AID_SSO). /// Request to warp to a character with given account ID. /// 0843 <account id>.L -void clif_parse_GMRemove2(int fd, struct map_session_data* sd) -{ +void clif_parse_GMRemove2(int fd, struct map_session_data* sd) { int account_id; struct map_session_data* pl_sd; account_id = RFIFOL(fd,packet_db[RFIFOW(fd,0)].pos[0]); - if( (pl_sd = iMap->id2sd(account_id)) != NULL ) { + if( (pl_sd = map->id2sd(account_id)) != NULL ) { char command[NAME_LENGTH+8]; sprintf(command, "%cjumpto %s", atcommand->at_symbol, pl_sd->status.name); atcommand->parse(fd, sd, command, 1); @@ -13346,13 +13323,12 @@ void clif_parse_GMRecall(int fd, struct map_session_data *sd) /// /recall (CZ_RECALL_SSO). /// Request to summon a player with given account ID to own position. /// 0842 <account id>.L -void clif_parse_GMRecall2(int fd, struct map_session_data* sd) -{ +void clif_parse_GMRecall2(int fd, struct map_session_data* sd) { int account_id; struct map_session_data* pl_sd; account_id = RFIFOL(fd,packet_db[RFIFOW(fd,0)].pos[0]); - if( (pl_sd = iMap->id2sd(account_id)) != NULL ) { + if( (pl_sd = map->id2sd(account_id)) != NULL ) { char command[NAME_LENGTH+8]; sprintf(command, "%crecall %s", atcommand->at_symbol, pl_sd->status.name); atcommand->parse(fd, sd, command, 1); @@ -13438,8 +13414,7 @@ void clif_parse_GMHide(int fd, struct map_session_data *sd) { /// 0 = positive points /// 1 = negative points /// 2 = self mute (+10 minutes) -void clif_parse_GMReqNoChat(int fd,struct map_session_data *sd) -{ +void clif_parse_GMReqNoChat(int fd,struct map_session_data *sd) { int id, type, value; struct map_session_data *dstsd; char command[NAME_LENGTH+15]; @@ -13451,8 +13426,7 @@ void clif_parse_GMReqNoChat(int fd,struct map_session_data *sd) if( type == 0 ) value = -value; - if (type == 2) - { + if (type == 2) { if (!battle_config.client_accept_chatdori) return; if (pc->get_group_level(sd) > 0 || sd->bl.id != id) @@ -13460,27 +13434,21 @@ void clif_parse_GMReqNoChat(int fd,struct map_session_data *sd) value = battle_config.client_accept_chatdori; dstsd = sd; - } - else - { - dstsd = iMap->id2sd(id); + } else { + dstsd = map->id2sd(id); if( dstsd == NULL ) return; } - if (type == 2 || ( (pc->get_group_level(sd)) > pc->get_group_level(dstsd) && !pc->can_use_command(sd, "@mute"))) - { + if (type == 2 || ( (pc->get_group_level(sd)) > pc->get_group_level(dstsd) && !pc->can_use_command(sd, "@mute"))) { clif->manner_message(sd, 0); clif->manner_message(dstsd, 5); - if (dstsd->status.manner < value) - { + if (dstsd->status.manner < value) { dstsd->status.manner -= value; sc_start(&dstsd->bl,SC_NOCHAT,100,0,0); - } - else - { + } else { dstsd->status.manner = 0; status_change_end(&dstsd->bl, SC_NOCHAT, INVALID_TIMER); } @@ -13538,8 +13506,7 @@ void clif_parse_GMReqAccountName(int fd, struct map_session_data *sd) /// type: /// 0 = not walkable /// 1 = walkable -void clif_parse_GMChangeMapType(int fd, struct map_session_data *sd) -{ +void clif_parse_GMChangeMapType(int fd, struct map_session_data *sd) { int x,y,type; if (!pc->has_permission(sd, PC_PERM_USE_CHANGEMAPTYPE)) @@ -13549,7 +13516,7 @@ void clif_parse_GMChangeMapType(int fd, struct map_session_data *sd) y = RFIFOW(fd,4); type = RFIFOW(fd,6); - iMap->setgatcell(sd->bl.m,x,y,type); + map->setgatcell(sd->bl.m,x,y,type); clif->changemapcell(0,sd->bl.m,x,y,type,ALL_SAMEMAP); //FIXME: once players leave the map, the client 'forgets' this information. } @@ -13561,8 +13528,7 @@ void clif_parse_GMChangeMapType(int fd, struct map_session_data *sd) /// type: /// 0 = (/ex nick) deny speech from nick /// 1 = (/in nick) allow speech from nick -void clif_parse_PMIgnore(int fd, struct map_session_data* sd) -{ +void clif_parse_PMIgnore(int fd, struct map_session_data* sd) { char* nick; uint8 type; int i; @@ -13572,7 +13538,7 @@ void clif_parse_PMIgnore(int fd, struct map_session_data* sd) type = RFIFOB(fd,26); if( type == 0 ) { // Add name to ignore list (block) - if (strcmp(iMap->wisp_server_name, nick) == 0) { + if (strcmp(map->wisp_server_name, nick) == 0) { clif->wisexin(sd, type, 1); // fail return; } @@ -13709,7 +13675,7 @@ void clif_parse_NoviceExplosionSpirits(int fd, struct map_session_data *sd) int percent = (int)( ( (float)sd->status.base_exp/(float)next )*1000. ); if( percent && ( percent%100 ) == 0 ) {// 10.0%, 20.0%, ..., 90.0% - sc_start(&sd->bl, iStatus->skill2sc(MO_EXPLOSIONSPIRITS), 100, 17, skill->get_time(MO_EXPLOSIONSPIRITS, 5)); //Lv17-> +50 critical (noted by Poki) [Skotlex] + sc_start(&sd->bl, status->skill2sc(MO_EXPLOSIONSPIRITS), 100, 17, skill->get_time(MO_EXPLOSIONSPIRITS, 5)); //Lv17-> +50 critical (noted by Poki) [Skotlex] clif->skill_nodamage(&sd->bl, &sd->bl, MO_EXPLOSIONSPIRITS, 5, 1); // prayer always shows successful Lv5 cast and disregards noskill restrictions } } @@ -13777,7 +13743,7 @@ void clif_friendslist_send(struct map_session_data *sd) } for (n = 0; n < i; n++) { //Sending the online players - if (iMap->charid2sd(sd->status.friends[n].char_id)) + if (map->charid2sd(sd->status.friends[n].char_id)) clif->friendslist_toggle(sd, sd->status.friends[n].account_id, sd->status.friends[n].char_id, 1); } } @@ -13824,12 +13790,11 @@ void clif_friendlist_req(struct map_session_data* sd, int account_id, int char_i /// Request to add a player as friend (CZ_ADD_FRIENDS). /// 0202 <name>.24B -void clif_parse_FriendsListAdd(int fd, struct map_session_data *sd) -{ +void clif_parse_FriendsListAdd(int fd, struct map_session_data *sd) { struct map_session_data *f_sd; int i; - f_sd = iMap->nick2sd((char*)RFIFOP(fd,2)); + f_sd = map->nick2sd((char*)RFIFOP(fd,2)); // ensure that the request player's friend list is not full ARR_FIND(0, MAX_FRIENDS, i, sd->status.friends[i].char_id == 0); @@ -13894,7 +13859,7 @@ void clif_parse_FriendsListReply(int fd, struct map_session_data *sd) return; } - f_sd = iMap->id2sd(account_id); //The account id is the same as the bl.id of players. + f_sd = map->id2sd(account_id); //The account id is the same as the bl.id of players. if (f_sd == NULL) return; @@ -13959,7 +13924,7 @@ void clif_parse_FriendsListRemove(int fd, struct map_session_data *sd) } //remove from friend's list first - if( (f_sd = iMap->id2sd(account_id)) && f_sd->status.char_id == char_id) { + if( (f_sd = map->id2sd(account_id)) && f_sd->status.char_id == char_id) { for (i = 0; i < MAX_FRIENDS && (f_sd->status.friends[i].char_id != sd->status.char_id || f_sd->status.friends[i].account_id != sd->status.account_id); i++); @@ -14044,7 +14009,7 @@ void clif_ranklist_sub(unsigned char *buf, enum fame_list_type type) { // Packet size limits this list to 10 elements. [Skotlex] for( i = 0; i < 10 && i < MAX_FAME_LIST; i++ ) { if( list[i].id > 0 ) { - if( strcmp(list[i].name, "-") == 0 && (name = iMap->charid2nick(list[i].id)) != NULL ) { + if( strcmp(list[i].name, "-") == 0 && (name = map->charid2nick(list[i].id)) != NULL ) { strncpy((char *)(WBUFP(buf, 24 * i)), name, NAME_LENGTH); } else { strncpy((char *)(WBUFP(buf, 24 * i)), list[i].name, NAME_LENGTH); @@ -14363,8 +14328,7 @@ void clif_parse_HomMenu(int fd, struct map_session_data *sd) { //[orn] /// Request to resurrect oneself using Token of Siegfried (CZ_STANDING_RESURRECTION). /// 0292 -void clif_parse_AutoRevive(int fd, struct map_session_data *sd) -{ +void clif_parse_AutoRevive(int fd, struct map_session_data *sd) { int item_position = pc->search_inventory(sd, ITEMID_TOKEN_OF_SIEGFRIED); if (item_position < 0) @@ -14373,7 +14337,7 @@ void clif_parse_AutoRevive(int fd, struct map_session_data *sd) if (sd->sc.data[SC_HELLPOWER]) //Cannot res while under the effect of SC_HELLPOWER. return; - if (!iStatus->revive(&sd->bl, 100, 100)) + if (!status->revive(&sd->bl, 100, 100)) return; clif->skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1); @@ -14434,7 +14398,7 @@ void clif_parse_Check(int fd, struct map_session_data *sd) safestrncpy(charname, (const char*)RFIFOP(fd,packet_db[RFIFOW(fd,0)].pos[0]), sizeof(charname)); - if( ( pl_sd = iMap->nick2sd(charname) ) == NULL || pc->get_group_level(sd) < pc->get_group_level(pl_sd) ) { + if( ( pl_sd = map->nick2sd(charname) ) == NULL || pc->get_group_level(sd) < pc->get_group_level(pl_sd) ) { return; } @@ -15359,9 +15323,8 @@ void clif_Adopt_request(struct map_session_data *sd, struct map_session_data *sr /// Request to adopt a player (CZ_REQ_JOIN_BABY). /// 01f9 <account id>.L -void clif_parse_Adopt_request(int fd, struct map_session_data *sd) -{ - struct map_session_data *tsd = iMap->id2sd(RFIFOL(fd,2)), *p_sd = iMap->charid2sd(sd->status.partner_id); +void clif_parse_Adopt_request(int fd, struct map_session_data *sd) { + struct map_session_data *tsd = map->id2sd(RFIFOL(fd,2)), *p_sd = map->charid2sd(sd->status.partner_id); if( pc->can_Adopt(sd, p_sd, tsd) ) { tsd->adopt_invite = sd->status.account_id; @@ -15375,13 +15338,12 @@ void clif_parse_Adopt_request(int fd, struct map_session_data *sd) /// answer: /// 0 = rejected /// 1 = accepted -void clif_parse_Adopt_reply(int fd, struct map_session_data *sd) -{ +void clif_parse_Adopt_reply(int fd, struct map_session_data *sd) { int p1_id = RFIFOL(fd,2); int p2_id = RFIFOL(fd,6); int result = RFIFOL(fd,10); - struct map_session_data* p1_sd = iMap->id2sd(p1_id); - struct map_session_data* p2_sd = iMap->id2sd(p2_id); + struct map_session_data* p1_sd = map->id2sd(p1_id); + struct map_session_data* p2_sd = map->id2sd(p2_id); int pid = sd->adopt_invite; sd->adopt_invite = 0; @@ -15443,10 +15405,9 @@ void clif_bossmapinfo(int fd, struct mob_data *md, short flag) /// Requesting equip of a player (CZ_EQUIPWIN_MICROSCOPE). /// 02d6 <account id>.L -void clif_parse_ViewPlayerEquip(int fd, struct map_session_data* sd) -{ +void clif_parse_ViewPlayerEquip(int fd, struct map_session_data* sd) { int charid = RFIFOL(fd, 2); - struct map_session_data* tsd = iMap->id2sd(charid); + struct map_session_data* tsd = map->id2sd(charid); if (!tsd) return; @@ -16069,7 +16030,7 @@ int clif_instance(int instance_id, int type, int flag) { break; case IOT_CHAR: target = SELF; - sd = iMap->id2sd(instances[instance_id].owner_id); + sd = map->id2sd(instances[instance_id].owner_id); break; } @@ -16854,11 +16815,11 @@ int clif_elementalconverter_list(struct map_session_data *sd) { WFIFOW(fd, 0)=0x1ad; for(i=0,c=0;i<MAX_SKILL_PRODUCE_DB;i++){ - if( skill->can_produce_mix(sd,skill_produce_db[i].nameid,23, 1) ){ - if((view = itemdb_viewid(skill_produce_db[i].nameid)) > 0) + if( skill->can_produce_mix(sd,skill->produce_db[i].nameid,23, 1) ){ + if((view = itemdb_viewid(skill->produce_db[i].nameid)) > 0) WFIFOW(fd,c*2+ 4)= view; else - WFIFOW(fd,c*2+ 4)= skill_produce_db[i].nameid; + WFIFOW(fd,c*2+ 4)= skill->produce_db[i].nameid; c++; } } @@ -17397,17 +17358,18 @@ void clif_maptypeproperty2(struct block_list *bl,enum send_target t) { p.PacketType = maptypeproperty2Type; p.type = 0x28; - p.flag.usecart = 1; - p.flag.party = 1; - p.flag.guild = 1; + p.flag.party = maplist[bl->m].flag.pvp ? 1 : 0; + p.flag.guild = map_flag_gvg(bl->m) ? 1 : 0; p.flag.siege = map_flag_gvg2(bl->m) ? 1: 0; - p.flag.mineffect = 1; - p.flag.nolockon = 1; + p.flag.mineffect = map_flag_gvg(bl->m); // FIXME/CHECKME Forcing /mineffect in castles during WoE (probably redundant? I'm not sure) + p.flag.nolockon = 0; // TODO p.flag.countpk = maplist[bl->m].flag.pvp ? 1 : 0; - p.flag.nopartyformation = 0; - p.flag.noitemconsumption = 1; - p.flag.summonstarmiracle = 1; + p.flag.nopartyformation = maplist[bl->m].flag.partylock ? 1 : 0; p.flag.bg = maplist[bl->m].flag.battleground ? 1 : 0; + p.flag.noitemconsumption = 0; // TODO + p.flag.summonstarmiracle = 0; // TODO + p.flag.usecart = 1; // TODO + p.flag.SpareBits = 0; clif->send(&p,sizeof(p),bl,t); #endif @@ -17716,7 +17678,7 @@ int clif_parse(int fd) { } else { //Unusual logout (during log on/off/map-changer procedure) ShowInfo("Player AID:%d/CID:%d logged off.\n", sd->status.account_id, sd->status.char_id); - iMap->quit(sd); + map->quit(sd); } } else { ShowInfo("Closed connection from '"CL_WHITE"%s"CL_RESET"'.\n", ip2str(session[fd]->client_addr, NULL)); diff --git a/src/map/duel.c b/src/map/duel.c index 1291dd02b..a993ee667 100644 --- a/src/map/duel.c +++ b/src/map/duel.c @@ -69,7 +69,7 @@ void duel_showinfo(const unsigned int did, struct map_session_data* sd) { duel->list[did].members_count + duel->list[did].invites_count); clif->disp_onlyself(sd, output, strlen(output)); - iMap->map_foreachpc(duel_showinfo_sub, sd, &p); + map->map_foreachpc(duel_showinfo_sub, sd, &p); } int duel_create(struct map_session_data* sd, const unsigned int maxpl) { @@ -126,7 +126,7 @@ void duel_leave(const unsigned int did, struct map_session_data* sd) { duel->list[did].members_count--; if(duel->list[did].members_count == 0) { - iMap->map_foreachpc(duel_leave_sub, did); + map->map_foreachpc(duel_leave_sub, did); duel->count--; } diff --git a/src/map/duel.h b/src/map/duel.h index 7802f6163..d1ec58415 100644 --- a/src/map/duel.h +++ b/src/map/duel.h @@ -1,5 +1,7 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder +// Copyright (c) Hercules Dev Team, licensed under GNU GPL. +// See the LICENSE file +// Portions Copyright (c) Athena Dev Teams + #ifndef _DUEL_H_ #define _DUEL_H_ @@ -11,8 +13,6 @@ struct duel { #define MAX_DUEL 1024 - - /*===================================== * Interface : duel.h * Generated by HerculesInterfaceMaker diff --git a/src/map/elemental.c b/src/map/elemental.c index b1ad4073b..5a3630c70 100644 --- a/src/map/elemental.c +++ b/src/map/elemental.c @@ -39,22 +39,24 @@ #include <string.h> #include <math.h> +struct elemental_interface elemental_s; + int elemental_search_index(int class_) { int i; - ARR_FIND(0, MAX_ELEMENTAL_CLASS, i, elemental->elemental_db[i].class_ == class_); + ARR_FIND(0, MAX_ELEMENTAL_CLASS, i, elemental->db[i].class_ == class_); return (i == MAX_ELEMENTAL_CLASS)?-1:i; } bool elemental_class(int class_) { - return (bool)(elemental_search_index(class_) > -1); + return (bool)(elemental->search_index(class_) > -1); } struct view_data * elemental_get_viewdata(int class_) { - int i = elemental_search_index(class_); + int i = elemental->search_index(class_); if( i < 0 ) return 0; - return &elemental->elemental_db[i].vd; + return &elemental->db[i].vd; } int elemental_create(struct map_session_data *sd, int class_, unsigned int lifetime) { @@ -64,10 +66,10 @@ int elemental_create(struct map_session_data *sd, int class_, unsigned int lifet nullpo_retr(1,sd); - if( (i = elemental_search_index(class_)) < 0 ) + if( (i = elemental->search_index(class_)) < 0 ) return 0; - db = &elemental->elemental_db[i]; + db = &elemental->db[i]; memset(&ele,0,sizeof(struct s_elemental)); ele.char_id = sd->status.char_id; @@ -75,27 +77,27 @@ int elemental_create(struct map_session_data *sd, int class_, unsigned int lifet ele.mode = EL_MODE_PASSIVE; // Initial mode i = db->status.size+1; // summon level - //[(Caster�s Max HP/ 3 ) + (Caster�s INT x 10 )+ (Caster�s Job Level x 20 )] x [(Elemental Summon Level + 2) / 3] + //[(Caster's Max HP/ 3 ) + (Caster's INT x 10 )+ (Caster's Job Level x 20 )] x [(Elemental Summon Level + 2) / 3] ele.hp = ele.max_hp = (sd->battle_status.max_hp/3 + sd->battle_status.int_*10 + sd->status.job_level) * ((i + 2) / 3); - //Caster�s Max SP /4 + //Caster's Max SP /4 ele.sp = ele.max_sp = sd->battle_status.max_sp/4; - //Caster�s [ Max SP / (18 / Elemental Summon Skill Level) 1- 100 ] + //Caster's [ Max SP / (18 / Elemental Summon Skill Level) 1- 100 ] ele.atk = (sd->battle_status.max_sp / (18 / i) * 1 - 100); - //Caster�s [ Max SP / (18 / Elemental Summon Skill Level) ] + //Caster's [ Max SP / (18 / Elemental Summon Skill Level) ] ele.atk2 = sd->battle_status.max_sp / 18; - //Caster�s HIT + (Caster�s Base Level ) + //Caster's HIT + (Caster's Base Level) ele.hit = sd->battle_status.hit + sd->status.base_level; - //[Elemental Summon Skill Level x (Caster�s INT / 2 + Caster�s DEX / 4)] + //[Elemental Summon Skill Level x (Caster's INT / 2 + Caster's DEX / 4)] ele.matk = i * (sd->battle_status.int_ / 2 + sd->battle_status.dex / 4); - //150 + [Caster�s DEX / 10] + [Elemental Summon Skill Level x 3 ] + //150 + [Caster's DEX / 10] + [Elemental Summon Skill Level x 3 ] ele.amotion = 150 + sd->battle_status.dex / 10 + i * 3; - //Caster�s DEF + (Caster�s Base Level / (5 � Elemental Summon Skill Level) + //Caster's DEF + (Caster's Base Level / (5 - Elemental Summon Skill Level) ele.def = sd->battle_status.def + sd->status.base_level / (5-i); - //Caster�s MDEF + (Caster�s INT / (5 - Elemental Summon Skill Level) + //Caster's MDEF + (Caster's INT / (5 - Elemental Summon Skill Level) ele.mdef = sd->battle_status.mdef + sd->battle_status.int_ / (5-i); - //Caster�s FLEE + (Caster�s Base Level / (5 � Elemental Summon Skill Level) + //Caster's FLEE + (Caster's Base Level / (5 - Elemental Summon Skill Level) ele.flee = sd->status.base_level / (5-i); - //Caster�s HIT + (Caster�s Base Level ) + //Caster's HIT + (Caster's Base Level) ele.hit = sd->battle_status.hit + sd->status.base_level; //per individual bonuses @@ -167,17 +169,17 @@ int elemental_save(struct elemental_data *ed) { return 1; } -static int elemental_summon_end(int tid, unsigned int tick, int id, intptr_t data) { +int elemental_summon_end_timer(int tid, unsigned int tick, int id, intptr_t data) { struct map_session_data *sd; struct elemental_data *ed; - if( (sd = iMap->id2sd(id)) == NULL ) + if( (sd = map->id2sd(id)) == NULL ) return 1; if( (ed = sd->ed) == NULL ) return 1; if( ed->summon_timer != tid ) { - ShowError("elemental_summon_end %d != %d.\n", ed->summon_timer, tid); + ShowError("elemental_summon_end_timer %d != %d.\n", ed->summon_timer, tid); return 0; } @@ -190,7 +192,7 @@ static int elemental_summon_end(int tid, unsigned int tick, int id, intptr_t dat void elemental_summon_stop(struct elemental_data *ed) { nullpo_retv(ed); if( ed->summon_timer != INVALID_TIMER ) - timer->delete(ed->summon_timer, elemental_summon_end); + timer->delete(ed->summon_timer, elemental->summon_end_timer); ed->summon_timer = INVALID_TIMER; } @@ -215,7 +217,7 @@ int elemental_delete(struct elemental_data *ed, int reply) { void elemental_summon_init(struct elemental_data *ed) { if( ed->summon_timer == INVALID_TIMER ) - ed->summon_timer = timer->add(timer->gettick() + ed->elemental.life_time, elemental_summon_end, ed->master->bl.id, 0); + ed->summon_timer = timer->add(timer->gettick() + ed->elemental.life_time, elemental->summon_end_timer, ed->master->bl.id, 0); ed->regen.state.block = 0; } @@ -224,9 +226,9 @@ int elemental_data_received(struct s_elemental *ele, bool flag) { struct map_session_data *sd; struct elemental_data *ed; struct s_elemental_db *db; - int i = elemental_search_index(ele->class_); + int i = elemental->search_index(ele->class_); - if( (sd = iMap->charid2sd(ele->char_id)) == NULL ) + if( (sd = map->charid2sd(ele->char_id)) == NULL ) return 0; if( !flag || i < 0 ) { // Not created - loaded - DB info @@ -234,7 +236,7 @@ int elemental_data_received(struct s_elemental *ele, bool flag) { return 0; } - db = &elemental->elemental_db[i]; + db = &elemental->db[i]; if( !sd->ed ) { // Initialize it after first summon. sd->ed = ed = (struct elemental_data*)aCalloc(1,sizeof(struct elemental_data)); ed->bl.type = BL_ELEM; @@ -242,9 +244,9 @@ int elemental_data_received(struct s_elemental *ele, bool flag) { ed->master = sd; ed->db = db; memcpy(&ed->elemental, ele, sizeof(struct s_elemental)); - iStatus->set_viewdata(&ed->bl, ed->elemental.class_); + status->set_viewdata(&ed->bl, ed->elemental.class_); ed->vd->head_mid = 10; // Why? - iStatus->change_init(&ed->bl); + status->change_init(&ed->bl); unit->dataset(&ed->bl); ed->ud.dir = sd->ud.dir; @@ -255,11 +257,11 @@ int elemental_data_received(struct s_elemental *ele, bool flag) { ed->bl.x = ed->ud.to_x; ed->bl.y = ed->ud.to_y; - iMap->addiddb(&ed->bl); + map->addiddb(&ed->bl); status_calc_elemental(ed,1); ed->last_spdrain_time = ed->last_thinktime = timer->gettick(); ed->summon_timer = INVALID_TIMER; - elemental_summon_init(ed); + elemental->summon_init(ed); } else { memcpy(&sd->ed->elemental, ele, sizeof(struct s_elemental)); ed = sd->ed; @@ -268,7 +270,7 @@ int elemental_data_received(struct s_elemental *ele, bool flag) { sd->status.ele_id = ele->elemental_id; if( ed->bl.prev == NULL && sd->bl.prev != NULL ) { - iMap->addblock(&ed->bl); + map->addblock(&ed->bl); clif->spawn(&ed->bl); clif->elemental_info(sd); clif->elemental_updatestatus(sd,SP_HP); @@ -281,7 +283,7 @@ int elemental_data_received(struct s_elemental *ele, bool flag) { int elemental_clean_single_effect(struct elemental_data *ed, uint16 skill_id) { struct block_list *bl; - sc_type type = iStatus->skill2sc(skill_id); + sc_type type = status->skill2sc(skill_id); nullpo_ret(ed); @@ -430,9 +432,9 @@ int elemental_action(struct elemental_data *ed, struct block_list *bl, unsigned ed->ud.skill_lv = skill_lv; if( skill->get_inf(skill_id) & INF_GROUND_SKILL ) - ed->ud.skilltimer = timer->add( tick+iStatus->get_speed(&ed->bl)*walk_dist, skill->castend_pos, ed->bl.id, 0 ); + ed->ud.skilltimer = timer->add( tick+status->get_speed(&ed->bl)*walk_dist, skill->castend_pos, ed->bl.id, 0 ); else - ed->ud.skilltimer = timer->add( tick+iStatus->get_speed(&ed->bl)*walk_dist, skill->castend_id, ed->bl.id, 0 ); + ed->ud.skilltimer = timer->add( tick+status->get_speed(&ed->bl)*walk_dist, skill->castend_id, ed->bl.id, 0 ); } return 1; @@ -574,8 +576,8 @@ struct skill_condition elemental_skill_get_requirements(uint16 skill_id, uint16 if( skill_lv < 1 || skill_lv > MAX_SKILL_LEVEL ) return req; - req.hp = skill_db[idx].hp[skill_lv-1]; - req.sp = skill_db[idx].sp[skill_lv-1]; + req.hp = skill->db[idx].hp[skill_lv-1]; + req.sp = skill->db[idx].sp[skill_lv-1]; return req; } @@ -589,7 +591,7 @@ int elemental_set_target( struct map_session_data *sd, struct block_list *bl ) { if( ed->bl.m != bl->m || !check_distance_bl(&ed->bl, bl, ed->db->range2) ) return 0; - if( !iStatus->check_skilluse(&ed->bl, bl, 0, 0) ) + if( !status->check_skilluse(&ed->bl, bl, 0, 0) ) return 0; if( ed->target_id == 0 ) @@ -598,7 +600,7 @@ int elemental_set_target( struct map_session_data *sd, struct block_list *bl ) { return 1; } -static int elemental_ai_sub_timer_activesearch(struct block_list *bl, va_list ap) { +int elemental_ai_sub_timer_activesearch(struct block_list *bl, va_list ap) { struct elemental_data *ed; struct block_list **target; int dist; @@ -609,7 +611,7 @@ static int elemental_ai_sub_timer_activesearch(struct block_list *bl, va_list ap target = va_arg(ap,struct block_list**); //If can't seek yet, not an enemy, or you can't attack it, skip. - if( (*target) == bl || !iStatus->check_skilluse(&ed->bl, bl, 0, 0) ) + if( (*target) == bl || !status->check_skilluse(&ed->bl, bl, 0, 0) ) return 0; if( battle->check_target(&ed->bl,bl,BCT_ENEMY) <= 0 ) @@ -634,7 +636,7 @@ static int elemental_ai_sub_timer_activesearch(struct block_list *bl, va_list ap return 0; } -static int elemental_ai_sub_timer(struct elemental_data *ed, struct map_session_data *sd, unsigned int tick) { +int elemental_ai_sub_timer(struct elemental_data *ed, struct map_session_data *sd, unsigned int tick) { struct block_list *target = NULL; int master_dist, view_range, mode; @@ -704,16 +706,16 @@ static int elemental_ai_sub_timer(struct elemental_data *ed, struct map_session_ return 0; //Already walking to him if( DIFF_TICK(tick, ed->ud.canmove_tick) < 0 ) return 0; //Can't move yet. - if( iMap->search_freecell(&ed->bl, sd->bl.m, &x, &y, MIN_ELEDISTANCE, MIN_ELEDISTANCE, 1) - && unit->walktoxy(&ed->bl, x, y, 0) ) + if( map->search_freecell(&ed->bl, sd->bl.m, &x, &y, MIN_ELEDISTANCE, MIN_ELEDISTANCE, 1) + && unit->walktoxy(&ed->bl, x, y, 0) ) return 0; } if( mode == EL_MODE_AGGRESSIVE ) { - target = iMap->id2bl(ed->ud.target); + target = map->id2bl(ed->ud.target); if( !target ) - iMap->foreachinrange(elemental_ai_sub_timer_activesearch, &ed->bl, view_range, BL_CHAR, ed, &target, status_get_mode(&ed->bl)); + map->foreachinrange(elemental->ai_sub_timer_activesearch, &ed->bl, view_range, BL_CHAR, ed, &target, status_get_mode(&ed->bl)); if( !target ) { //No targets available. elemental->unlocktarget(ed); @@ -743,16 +745,16 @@ static int elemental_ai_sub_timer(struct elemental_data *ed, struct map_session_ return 0; } -static int elemental_ai_sub_foreachclient(struct map_session_data *sd, va_list ap) { +int elemental_ai_sub_foreachclient(struct map_session_data *sd, va_list ap) { unsigned int tick = va_arg(ap,unsigned int); if(sd->status.ele_id && sd->ed) - elemental_ai_sub_timer(sd->ed,sd,tick); + elemental->ai_sub_timer(sd->ed,sd,tick); return 0; } -static int elemental_ai_timer(int tid, unsigned int tick, int id, intptr_t data) { - iMap->map_foreachpc(elemental_ai_sub_foreachclient,tick); +int elemental_ai_timer(int tid, unsigned int tick, int id, intptr_t data) { + map->map_foreachpc(elemental->ai_sub_foreachclient,tick); return 0; } @@ -764,8 +766,10 @@ int read_elementaldb(void) { struct s_elemental_db *db; struct status_data *estatus; - sprintf(line, "%s/%s", iMap->db_path, "elemental_db.txt"); - memset(elemental->elemental_db,0,sizeof(elemental->elemental_db)); + sprintf(line, "%s/%s", map->db_path, "elemental_db.txt"); + + if( runflag == MAPSERVER_ST_RUNNING ) //only necessary after we're up + memset(elemental->db,0,sizeof(elemental->db)); fp = fopen(line, "r"); if( !fp ) { @@ -792,7 +796,7 @@ int read_elementaldb(void) { continue; } - db = &elemental->elemental_db[j]; + db = &elemental->db[j]; db->class_ = atoi(str[0]); safestrncpy(db->sprite, str[1], NAME_LENGTH); safestrncpy(db->name, str[2], NAME_LENGTH); @@ -855,7 +859,7 @@ int read_elemental_skilldb(void) { uint16 skill_id, skill_lv; int skillmode; - sprintf(line, "%s/%s", iMap->db_path, "elemental_skill_db.txt"); + sprintf(line, "%s/%s", map->db_path, "elemental_skill_db.txt"); fp = fopen(line, "r"); if( !fp ) { ShowError("read_elemental_skilldb : can't read elemental_skill_db.txt\n"); @@ -882,7 +886,7 @@ int read_elemental_skilldb(void) { } class_ = atoi(str[0]); - ARR_FIND(0, MAX_ELEMENTAL_CLASS, i, class_ == elemental->elemental_db[i].class_); + ARR_FIND(0, MAX_ELEMENTAL_CLASS, i, class_ == elemental->db[i].class_); if( i == MAX_ELEMENTAL_CLASS ) { ShowError("read_elemental_skilldb : Class not found in elemental_db for skill entry, line %d.\n", k); continue; @@ -894,7 +898,7 @@ int read_elemental_skilldb(void) { continue; } - db = &elemental->elemental_db[i]; + db = &elemental->db[i]; skill_lv = atoi(str[2]); skillmode = atoi(str[3]); @@ -919,7 +923,7 @@ int read_elemental_skilldb(void) { } void reload_elementaldb(void) { - read_elementaldb(); + elemental->read_db(); elemental->reload_skilldb(); } @@ -928,11 +932,11 @@ void reload_elemental_skilldb(void) { } int do_init_elemental(void) { - read_elementaldb(); + elemental->read_db(); elemental->read_skilldb(); - timer->add_func_list(elemental_ai_timer,"elemental_ai_timer"); - timer->add_interval(timer->gettick()+MIN_ELETHINKTIME,elemental_ai_timer,0,0,MIN_ELETHINKTIME); + timer->add_func_list(elemental->ai_timer,"elemental_ai_timer"); + timer->add_interval(timer->gettick()+MIN_ELETHINKTIME,elemental->ai_timer,0,0,MIN_ELETHINKTIME); return 0; } @@ -949,6 +953,13 @@ void do_final_elemental(void) { void elemental_defaults(void) { elemental = &elemental_s; + /* */ + elemental->init = do_init_elemental; + elemental->final = do_final_elemental; + + /* */ + memset(elemental->db,0,sizeof(elemental->db)); + /* funcs */ elemental->class = elemental_class; @@ -978,8 +989,15 @@ void elemental_defaults(void) { elemental->skill_get_requirements = elemental_skill_get_requirements; elemental->read_skilldb = read_elemental_skilldb; - elemental->reload_elementaldb = reload_elementaldb; + elemental->reload_db = reload_elementaldb; elemental->reload_skilldb = reload_elemental_skilldb; - elemental->do_init_elemental = do_init_elemental; - elemental->do_final_elemental = do_final_elemental; + + elemental->search_index = elemental_search_index; + elemental->summon_init = elemental_summon_init; + elemental->summon_end_timer = elemental_summon_end_timer; + elemental->ai_sub_timer_activesearch = elemental_ai_sub_timer_activesearch; + elemental->ai_sub_timer = elemental_ai_sub_timer; + elemental->ai_sub_foreachclient = elemental_ai_sub_foreachclient; + elemental->ai_timer = elemental_ai_timer; + elemental->read_db = read_elementaldb; } diff --git a/src/map/elemental.h b/src/map/elemental.h index ccc3bcb5f..b42d5c0b7 100644 --- a/src/map/elemental.h +++ b/src/map/elemental.h @@ -1,9 +1,16 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder +// Copyright (c) Hercules Dev Team, licensed under GNU GPL. +// See the LICENSE file +// Portions Copyright (c) Athena Dev Teams + #ifndef _ELEMENTAL_H_ #define _ELEMENTAL_H_ + #include "status.h" // struct status_data, struct status_change #include "unit.h" // struct unit_data + +/** + * Defines + **/ #define MIN_ELETHINKTIME 100 #define MIN_ELEDISTANCE 2 #define MAX_ELEDISTANCE 5 @@ -13,10 +20,18 @@ #define EL_SKILLMODE_PASIVE 0x1 #define EL_SKILLMODE_ASSIST 0x2 #define EL_SKILLMODE_AGGRESSIVE 0x4 + +#define elemental_stop_walking(ed, type) unit->stop_walking(&(ed)->bl, type) +#define elemental_stop_attack(ed) unit->stop_attack(&(ed)->bl) + +/** + * Structures + **/ struct elemental_skill { unsigned short id, lv; short mode; }; + struct s_elemental_db { int class_; char sprite[NAME_LENGTH], name[NAME_LENGTH]; @@ -26,6 +41,7 @@ struct s_elemental_db { struct view_data vd; struct elemental_skill skill[MAX_ELESKILLTREE]; }; + struct elemental_data { struct block_list bl; struct unit_data ud; @@ -46,9 +62,6 @@ struct elemental_data { int target_id, attacked_id; }; -#define elemental_stop_walking(ed, type) unit->stop_walking(&(ed)->bl, type) -#define elemental_stop_attack(ed) unit->stop_attack(&(ed)->bl) - /*===================================== * Interface : elemental.h * Generated by HerculesInterfaceMaker @@ -57,8 +70,11 @@ struct elemental_data { struct elemental_interface { /* vars */ - struct s_elemental_db elemental_db[MAX_ELEMENTAL_CLASS]; // Elemental Database + struct s_elemental_db db[MAX_ELEMENTAL_CLASS]; // Elemental Database + /* */ + int (*init) (void); + void (*final) (void); /* funcs */ bool (*class) (int class_); struct view_data * (*get_viewdata) (int class_); @@ -87,11 +103,18 @@ struct elemental_interface { struct skill_condition (*skill_get_requirements) (uint16 skill_id, uint16 skill_lv); int (*read_skilldb) (void); - void (*reload_elementaldb) (void); + void (*reload_db) (void); void (*reload_skilldb) (void); - int (*do_init_elemental) (void); - void (*do_final_elemental) (void); -} elemental_s; + + int (*search_index) (int class_); + void (*summon_init) (struct elemental_data *ed); + int (*summon_end_timer) (int tid, unsigned int tick, int id, intptr_t data); + int (*ai_sub_timer_activesearch) (struct block_list *bl, va_list ap); + int (*ai_sub_timer) (struct elemental_data *ed, struct map_session_data *sd, unsigned int tick); + int (*ai_sub_foreachclient) (struct map_session_data *sd, va_list ap); + int (*ai_timer) (int tid, unsigned int tick, int id, intptr_t data); + int (*read_db) (void); +}; struct elemental_interface *elemental; diff --git a/src/map/guild.c b/src/map/guild.c index 8319d4524..b66961262 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -32,74 +32,32 @@ struct guild_interface guild_s; -static DBMap* guild_db; // int guild_id -> struct guild* -static DBMap* castle_db; // int castle_id -> struct guild_castle* -static DBMap* guild_expcache_db; // int char_id -> struct guild_expcache* -static DBMap* guild_infoevent_db; // int guild_id -> struct eventlist* - -struct eventlist { - char name[EVENT_NAME_LENGTH]; - struct eventlist *next; -}; - -//Constant related to the flash of the Guild EXP cache -#define GUILD_SEND_XY_INVERVAL 5000 // Interval of sending coordinates and HP -#define GUILD_PAYEXP_INVERVAL 10000 //Interval (maximum survival time of the cache, in milliseconds) -#define GUILD_PAYEXP_LIST 8192 //The maximum number of cache - -//Guild EXP cache - -struct guild_expcache { - int guild_id, account_id, char_id; - uint64 exp; -}; -static struct eri *expcache_ers; //For handling of guild exp payment. - -#define MAX_GUILD_SKILL_REQUIRE 5 -struct{ - int id; - int max; - struct{ - short id; - short lv; - }need[MAX_GUILD_SKILL_REQUIRE]; -} guild_skill_tree[MAX_GUILDSKILL]; - -int guild_payexp_timer(int tid, unsigned int tick, int id, intptr_t data); -static int guild_send_xy_timer(int tid, unsigned int tick, int id, intptr_t data); - -/* guild flags cache */ -struct npc_data **guild_flags; -unsigned short guild_flags_count; - /*========================================== * Retrieves and validates the sd pointer for this guild member [Skotlex] *------------------------------------------*/ -static TBL_PC* guild_sd_check(int guild_id, int account_id, int char_id) -{ - TBL_PC* sd = iMap->id2sd(account_id); +TBL_PC* guild_sd_check(int guild_id, int account_id, int char_id) { + TBL_PC* sd = map->id2sd(account_id); if (!(sd && sd->status.char_id == char_id)) return NULL; - if (sd->status.guild_id != guild_id) - { //If player belongs to a different guild, kick him out. - intif->guild_leave(guild_id,account_id,char_id,0,"** Guild Mismatch **"); + if (sd->status.guild_id != guild_id) { + //If player belongs to a different guild, kick him out. + intif->guild_leave(guild_id,account_id,char_id,0,"** Guild Mismatch **"); return NULL; } return sd; } - // Modified [Komurka] +// Modified [Komurka] int guild_skill_get_max (int id) { if (id < GD_SKILLBASE || id >= GD_SKILLBASE+MAX_GUILDSKILL) return 0; - return guild_skill_tree[id-GD_SKILLBASE].max; + return guild->skill_tree[id-GD_SKILLBASE].max; } // Retrive skill_lv learned by guild - int guild_checkskill(struct guild *g, int id) { int idx = id - GD_SKILLBASE; if (idx < 0 || idx >= MAX_GUILDSKILL) @@ -110,7 +68,7 @@ int guild_checkskill(struct guild *g, int id) { /*========================================== * guild_skill_tree.txt reading - from jA [Komurka] *------------------------------------------*/ -static bool guild_read_guildskill_tree_db(char* split[], int columns, int current) +bool guild_read_guildskill_tree_db(char* split[], int columns, int current) {// <skill id>,<max lv>,<req id1>,<req lv1>,<req id2>,<req lv2>,<req id3>,<req lv3>,<req id4>,<req lv4>,<req id5>,<req lv5> int k, id, skill_id; @@ -123,18 +81,18 @@ static bool guild_read_guildskill_tree_db(char* split[], int columns, int curren return false; } - guild_skill_tree[id].id = skill_id; - guild_skill_tree[id].max = atoi(split[1]); + guild->skill_tree[id].id = skill_id; + guild->skill_tree[id].max = atoi(split[1]); - if( guild_skill_tree[id].id == GD_GLORYGUILD && battle_config.require_glory_guild && guild_skill_tree[id].max == 0 ) + if( guild->skill_tree[id].id == GD_GLORYGUILD && battle_config.require_glory_guild && guild->skill_tree[id].max == 0 ) {// enable guild's glory when required for emblems - guild_skill_tree[id].max = 1; + guild->skill_tree[id].max = 1; } for( k = 0; k < MAX_GUILD_SKILL_REQUIRE; k++ ) { - guild_skill_tree[id].need[k].id = atoi(split[k*2+2]); - guild_skill_tree[id].need[k].lv = atoi(split[k*2+3]); + guild->skill_tree[id].need[k].id = atoi(split[k*2+2]); + guild->skill_tree[id].need[k].lv = atoi(split[k*2+3]); } return true; @@ -156,19 +114,19 @@ int guild_check_skill_require(struct guild *g,int id) for(i=0;i<MAX_GUILD_SKILL_REQUIRE;i++) { - if(guild_skill_tree[idx].need[i].id == 0) break; - if(guild_skill_tree[idx].need[i].lv > guild->checkskill(g,guild_skill_tree[idx].need[i].id)) + if(guild->skill_tree[idx].need[i].id == 0) break; + if(guild->skill_tree[idx].need[i].lv > guild->checkskill(g,guild->skill_tree[idx].need[i].id)) return 0; } return 1; } -static bool guild_read_castledb(char* str[], int columns, int current) +bool guild_read_castledb(char* str[], int columns, int current) {// <castle id>,<map name>,<castle name>,<castle event>[,<reserved/unused switch flag>] struct guild_castle *gc; int mapindex = mapindex_name2id(str[1]); - if (iMap->mapindex2mapid(mapindex) < 0) // Map not found or on another map-server + if (map->mapindex2mapid(mapindex) < 0) // Map not found or on another map-server return false; CREATE(gc, struct guild_castle, 1); @@ -177,7 +135,7 @@ static bool guild_read_castledb(char* str[], int columns, int current) safestrncpy(gc->castle_name, str[2], sizeof(gc->castle_name)); safestrncpy(gc->castle_event, str[3], sizeof(gc->castle_event)); - idb_put(castle_db,gc->castle_id,gc); + idb_put(guild->castle_db,gc->castle_id,gc); //intif->guild_castle_info(gc->castle_id); @@ -187,14 +145,14 @@ static bool guild_read_castledb(char* str[], int columns, int current) /// lookup: guild id -> guild* struct guild* guild_search(int guild_id) { - return (struct guild*)idb_get(guild_db,guild_id); + return (struct guild*)idb_get(guild->db,guild_id); } /// lookup: guild name -> guild* struct guild* guild_searchname(char* str) { struct guild* g; - DBIterator *iter = db_iterator(guild_db); + DBIterator *iter = db_iterator(guild->db); for( g = dbi_first(iter); dbi_exists(iter); g = dbi_next(iter) ) { @@ -209,14 +167,14 @@ struct guild* guild_searchname(char* str) /// lookup: castle id -> castle* struct guild_castle* guild_castle_search(int gcid) { - return (struct guild_castle*)idb_get(castle_db,gcid); + return (struct guild_castle*)idb_get(guild->castle_db,gcid); } /// lookup: map index -> castle* struct guild_castle* guild_mapindex2gc(short mapindex) { struct guild_castle* gc; - DBIterator *iter = db_iterator(castle_db); + DBIterator *iter = db_iterator(guild->castle_db); for( gc = dbi_first(iter); dbi_exists(iter); gc = dbi_next(iter) ) { @@ -304,7 +262,7 @@ int guild_payexp_timer_sub(DBKey key, DBData *data, va_list ap) { (g = guild->search(c->guild_id)) == NULL || (i = guild->getindex(g, c->account_id, c->char_id)) < 0 ) { - ers_free(expcache_ers, c); + ers_free(guild->expcache_ers, c); return 0; } @@ -317,13 +275,13 @@ int guild_payexp_timer_sub(DBKey key, DBData *data, va_list ap) { GMI_EXP,&g->member[i].exp,sizeof(g->member[i].exp)); c->exp=0; - ers_free(expcache_ers, c); + ers_free(guild->expcache_ers, c); return 0; } int guild_payexp_timer(int tid, unsigned int tick, int id, intptr_t data) { - guild_expcache_db->clear(guild_expcache_db,guild_payexp_timer_sub); + guild->expcache_db->clear(guild->expcache_db,guild->payexp_timer_sub); return 0; } @@ -356,9 +314,9 @@ int guild_send_xy_timer_sub(DBKey key, DBData *data, va_list ap) } //Code from party_send_xy_timer [Skotlex] -static int guild_send_xy_timer(int tid, unsigned int tick, int id, intptr_t data) +int guild_send_xy_timer(int tid, unsigned int tick, int id, intptr_t data) { - guild_db->foreach(guild_db,guild_send_xy_timer_sub,tick); + guild->db->foreach(guild->db,guild->send_xy_timer_sub,tick); return 0; } @@ -393,7 +351,7 @@ int guild_create(struct map_session_data *sd, const char *name) return 0; } - guild_makemember(&m,sd); + guild->makemember(&m,sd); m.position=0; intif->guild_create(name,&m); return 1; @@ -401,7 +359,7 @@ int guild_create(struct map_session_data *sd, const char *name) //Whether or not to create guild int guild_created(int account_id,int guild_id) { - struct map_session_data *sd=iMap->id2sd(account_id); + struct map_session_data *sd=map->id2sd(account_id); if(sd==NULL) return 0; @@ -441,7 +399,7 @@ int guild_npc_request_info(int guild_id,const char *event) ev=(struct eventlist *)aCalloc(sizeof(struct eventlist),1); memcpy(ev->name,event,strlen(event)); //The one in the db (if present) becomes the next event from this. - if (guild_infoevent_db->put(guild_infoevent_db, DB->i2key(guild_id), DB->ptr2data(ev), &prev)) + if (guild->infoevent_db->put(guild->infoevent_db, DB->i2key(guild_id), DB->ptr2data(ev), &prev)) ev->next = DB->data2ptr(&prev); } @@ -502,12 +460,12 @@ int guild_recv_info(struct guild *sg) { nullpo_ret(sg); - if((g = (struct guild*)idb_get(guild_db,sg->guild_id))==NULL) { + if((g = (struct guild*)idb_get(guild->db,sg->guild_id))==NULL) { guild_new = true; g=(struct guild *)aCalloc(1,sizeof(struct guild)); g->instance = NULL; g->instances = 0; - idb_put(guild_db,sg->guild_id,g); + idb_put(guild->db,sg->guild_id,g); if( hChSys.ally ) { struct hChSysCh *channel; @@ -554,9 +512,9 @@ int guild_recv_info(struct guild *sg) { } before=*sg; - //Perform the check on the user because the first load - guild_check_member(sg); - if ((sd = iMap->nick2sd(sg->master)) != NULL) { + //Perform the check on the user because the first load + guild->check_member(sg); + if ((sd = map->nick2sd(sg->master)) != NULL) { //If the guild master is online the first time the guild_info is received, //that means he was the first to join, so apply guild skill blocking here. if( battle_config.guild_skill_relog_delay ) @@ -584,7 +542,7 @@ int guild_recv_info(struct guild *sg) { for(i=bm=m=0;i<g->max_member;i++){ if(g->member[i].account_id>0){ - sd = g->member[i].sd = guild_sd_check(g->guild_id, g->member[i].account_id, g->member[i].char_id); + sd = g->member[i].sd = guild->sd_check(g->guild_id, g->member[i].account_id, g->member[i].char_id); if (sd) clif->charnameupdate(sd); // [LuzZza] m++; }else @@ -619,7 +577,7 @@ int guild_recv_info(struct guild *sg) { } //Occurrence of an event - if (guild_infoevent_db->remove(guild_infoevent_db, DB->i2key(sg->guild_id), &data)) { + if (guild->infoevent_db->remove(guild->infoevent_db, DB->i2key(sg->guild_id), &data)) { struct eventlist *ev = DB->data2ptr(&data), *ev2; while(ev) { npc->event_do(ev->name); @@ -663,7 +621,7 @@ int guild_invite(struct map_session_data *sd, struct map_session_data *tsd) { if( tsd->status.guild_id > 0 || tsd->guild_invite > 0 - || ((iMap->agit_flag || iMap->agit2_flag) && maplist[tsd->bl.m].flag.gvg_castle) + || ((map->agit_flag || map->agit2_flag) && maplist[tsd->bl.m].flag.gvg_castle) ) { //Can't invite people inside castles. [Skotlex] clif->guild_inviteack(sd,0); @@ -686,8 +644,7 @@ int guild_invite(struct map_session_data *sd, struct map_session_data *tsd) { /// Guild invitation reply. /// flag: 0:rejected, 1:accepted -int guild_reply_invite(struct map_session_data* sd, int guild_id, int flag) -{ +int guild_reply_invite(struct map_session_data* sd, int guild_id, int flag) { struct map_session_data* tsd; nullpo_ret(sd); @@ -698,10 +655,10 @@ int guild_reply_invite(struct map_session_data* sd, int guild_id, int flag) // look up the person who sent the invite //NOTE: this can be NULL because the person might have logged off in the meantime - tsd = iMap->id2sd(sd->guild_invite_account); + tsd = map->id2sd(sd->guild_invite_account); - if ( sd->status.guild_id > 0 ) // [Paradox924X] - { // Already in another guild. + if ( sd->status.guild_id > 0 ) { + // Already in another guild. [Paradox924X] if ( tsd ) clif->guild_inviteack(tsd,0); return 0; } @@ -733,7 +690,7 @@ int guild_reply_invite(struct map_session_data* sd, int guild_id, int flag) return 0; } - guild_makemember(&m,sd); + guild->makemember(&m,sd); intif->guild_addmember(guild_id, &m); //TODO: send a minimap update to this player } @@ -788,33 +745,32 @@ void guild_member_joined(struct map_session_data *sd) /*========================================== * Add a player to a given guild_id *----------------------------------------*/ -int guild_member_added(int guild_id,int account_id,int char_id,int flag) -{ - struct map_session_data *sd= iMap->id2sd(account_id),*sd2; +int guild_member_added(int guild_id,int account_id,int char_id,int flag) { + struct map_session_data *sd = map->id2sd(account_id),*sd2; struct guild *g; if( (g=guild->search(guild_id))==NULL ) return 0; if(sd==NULL || sd->guild_invite==0){ - // cancel if player not present or invalide guild_id invitation + // cancel if player not present or invalide guild_id invitation if (flag == 0) { ShowError("guild: member added error %d is not online\n",account_id); - intif->guild_leave(guild_id,account_id,char_id,0,"** Data Error **"); + intif->guild_leave(guild_id,account_id,char_id,0,"** Data Error **"); } return 0; } - sd2 = iMap->id2sd(sd->guild_invite_account); + sd2 = map->id2sd(sd->guild_invite_account); sd->guild_invite = 0; sd->guild_invite_account = 0; - if (flag == 1) { //failure + if (flag == 1) { //failure if( sd2!=NULL ) clif->guild_inviteack(sd2,3); return 0; } - //if all ok add player to guild + //if all ok add player to guild sd->status.guild_id = g->guild_id; sd->guild_emblem_id = g->emblem_id; sd->guild = g; @@ -850,7 +806,7 @@ int guild_leave(struct map_session_data* sd, int guild_id, int account_id, int c 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) + || ((map->agit_flag || map->agit2_flag) && maplist[sd->bl.m].flag.gvg_castle) ) return 0; @@ -861,8 +817,7 @@ int guild_leave(struct map_session_data* sd, int guild_id, int account_id, int c /*========================================== * Request remove a player to a given guild_id *----------------------------------------*/ -int guild_expulsion(struct map_session_data* sd, int guild_id, int account_id, int char_id, const char* mes) -{ +int guild_expulsion(struct map_session_data* sd, int guild_id, int account_id, int char_id, const char* mes) { struct map_session_data *tsd; struct guild *g; int i,ps; @@ -880,10 +835,10 @@ int guild_expulsion(struct map_session_data* sd, int guild_id, int account_id, i if( (ps=guild->getposition(g,sd))<0 || !(g->position[ps].mode&0x0010) ) return 0; //Expulsion permission - //Can't leave inside guild castles. - if ((tsd = iMap->id2sd(account_id)) + //Can't leave inside guild castles. + if ((tsd = map->id2sd(account_id)) && tsd->status.char_id == char_id - && ((iMap->agit_flag || iMap->agit2_flag) && maplist[tsd->bl.m].flag.gvg_castle) + && ((map->agit_flag || map->agit2_flag) && maplist[tsd->bl.m].flag.gvg_castle) ) return 0; @@ -899,7 +854,7 @@ int guild_member_withdraw(int guild_id, int account_id, int char_id, int flag, c { int i; struct guild* g = guild->search(guild_id); - struct map_session_data* sd = iMap->charid2sd(char_id); + struct map_session_data* sd = map->charid2sd(char_id); struct map_session_data* online_member_sd; if(g == NULL) @@ -1005,13 +960,13 @@ int guild_recv_memberinfoshort(int guild_id,int account_id,int char_id,int onlin } if(idx == -1 || c == 0) { - //Treat char_id who doesn't match guild_id (not found as member) - struct map_session_data *sd = iMap->id2sd(account_id); + //Treat char_id who doesn't match guild_id (not found as member) + struct map_session_data *sd = map->id2sd(account_id); if(sd && sd->status.char_id == char_id) { sd->status.guild_id=0; sd->guild_emblem_id=0; } - ShowWarning("guild: not found member %d,%d on %d[%s]\n", account_id,char_id,guild_id,g->name); + ShowWarning("guild: not found member %d,%d on %d[%s]\n", account_id,char_id,guild_id,g->name); return 0; } @@ -1019,7 +974,7 @@ int guild_recv_memberinfoshort(int guild_id,int account_id,int char_id,int onlin g->connect_member=om; //Ensure validity of pointer (ie: player logs in/out, changes map-server) - g->member[idx].sd = guild_sd_check(guild_id, account_id, char_id); + g->member[idx].sd = guild->sd_check(guild_id, account_id, char_id); if(oldonline!=online) clif->guild_memberlogin_notice(g, idx, online); @@ -1099,8 +1054,7 @@ int guild_memberposition_changed(struct guild *g,int idx,int pos) /*==================================================== * Change guild title or member *---------------------------------------------------*/ -int guild_change_position(int guild_id,int idx, - int mode,int exp_mode,const char *name) +int guild_change_position(int guild_id,int idx,int mode,int exp_mode,const char *name) { struct guild_position p; @@ -1206,25 +1160,23 @@ int guild_emblem_changed(int len,int guild_id,int emblem_id,const char *data) } } {// update guardians (mobs) - DBIterator* iter = db_iterator(castle_db); + DBIterator* iter = db_iterator(guild->castle_db); struct guild_castle* gc; for( gc = (struct guild_castle*)dbi_first(iter) ; dbi_exists(iter); gc = (struct guild_castle*)dbi_next(iter) ) { if( gc->guild_id != guild_id ) continue; // update permanent guardians - for( i = 0; i < ARRAYLENGTH(gc->guardian); ++i ) - { - TBL_MOB* md = (gc->guardian[i].id ? iMap->id2md(gc->guardian[i].id) : NULL); + for( i = 0; i < ARRAYLENGTH(gc->guardian); ++i ) { + TBL_MOB* md = (gc->guardian[i].id ? map->id2md(gc->guardian[i].id) : NULL); if( md == NULL || md->guardian_data == NULL ) continue; md->guardian_data->emblem_id = emblem_id; clif->guild_emblem_area(&md->bl); } // update temporary guardians - for( i = 0; i < gc->temp_guardians_max; ++i ) - { - TBL_MOB* md = (gc->temp_guardians[i] ? iMap->id2md(gc->temp_guardians[i]) : NULL); + for( i = 0; i < gc->temp_guardians_max; ++i ) { + TBL_MOB* md = (gc->temp_guardians[i] ? map->id2md(gc->temp_guardians[i]) : NULL); if( md == NULL || md->guardian_data == NULL ) continue; md->guardian_data->emblem_id = emblem_id; @@ -1234,9 +1186,9 @@ int guild_emblem_changed(int len,int guild_id,int emblem_id,const char *data) dbi_destroy(iter); } {// update npcs (flags or other npcs that used flagemblem to attach to this guild) - for( i = 0; i < guild_flags_count; i++ ) { - if( guild_flags[i] && guild_flags[i]->u.scr.guild_id == guild_id ) { - clif->guild_emblem_area(&guild_flags[i]->bl); + for( i = 0; i < guild->flags_count; i++ ) { + if( guild->flags[i] && guild->flags[i]->u.scr.guild_id == guild_id ) { + clif->guild_emblem_area(&guild->flags[i]->bl); } } } @@ -1246,12 +1198,12 @@ int guild_emblem_changed(int len,int guild_id,int emblem_id,const char *data) /** * @see DBCreateData */ -static DBData create_expcache(DBKey key, va_list args) +DBData create_expcache(DBKey key, va_list args) { struct guild_expcache *c; struct map_session_data *sd = va_arg(args, struct map_session_data*); - c = ers_alloc(expcache_ers, struct guild_expcache); + c = ers_alloc(guild->expcache_ers, struct guild_expcache); c->guild_id = sd->status.guild_id; c->account_id = sd->status.account_id; c->char_id = sd->status.char_id; @@ -1282,7 +1234,7 @@ unsigned int guild_payexp(struct map_session_data *sd,unsigned int exp) { exp = exp * per / 100; //Otherwise tax everything. - c = DB->data2ptr(guild_expcache_db->ensure(guild_expcache_db, DB->i2key(sd->status.char_id), create_expcache, sd)); + c = DB->data2ptr(guild->expcache_db->ensure(guild->expcache_db, DB->i2key(sd->status.char_id), guild->create_expcache, sd)); if (c->exp > UINT64_MAX - exp) c->exp = UINT64_MAX; @@ -1305,7 +1257,7 @@ int guild_getexp(struct map_session_data *sd,int exp) if (sd->status.guild_id == 0 || sd->guild == NULL) return 0; - c = DB->data2ptr(guild_expcache_db->ensure(guild_expcache_db, DB->i2key(sd->status.char_id), create_expcache, sd)); + c = DB->data2ptr(guild->expcache_db->ensure(guild->expcache_db, DB->i2key(sd->status.char_id), guild->create_expcache, sd)); if (c->exp > UINT64_MAX - exp) c->exp = UINT64_MAX; else @@ -1340,9 +1292,8 @@ int guild_skillup(TBL_PC* sd, uint16 skill_id) /*==================================================== * Notification of guildskill skill_id increase request *---------------------------------------------------*/ -int guild_skillupack(int guild_id,uint16 skill_id,int account_id) -{ - struct map_session_data *sd=iMap->id2sd(account_id); +int guild_skillupack(int guild_id,uint16 skill_id,int account_id) { + struct map_session_data *sd=map->id2sd(account_id); struct guild *g=guild->search(guild_id); int i; if(g==NULL) @@ -1356,7 +1307,7 @@ int guild_skillupack(int guild_id,uint16 skill_id,int account_id) case GD_GLORYWOUNDS: case GD_SOULCOLD: case GD_HAWKEYES: - guild->aura_refresh(sd,skill_id,g->skill[skill_id-GD_SKILLBASE].lv); + guild->aura_refresh(sd,skill_id,g->skill[skill_id-GD_SKILLBASE].lv); break; } } @@ -1371,9 +1322,9 @@ int guild_skillupack(int guild_id,uint16 skill_id,int account_id) void guild_guildaura_refresh(struct map_session_data *sd, uint16 skill_id, uint16 skill_lv) { struct skill_unit_group* group = NULL; - int type = iStatus->skill2sc(skill_id); - if( !(battle_config.guild_aura&((iMap->agit_flag || iMap->agit2_flag)?2:1)) && - !(battle_config.guild_aura&(map_flag_gvg2(sd->bl.m)?8:4)) ) + int type = status->skill2sc(skill_id); + if( !(battle_config.guild_aura&((map->agit_flag || map->agit2_flag)?2:1)) + && !(battle_config.guild_aura&(map_flag_gvg2(sd->bl.m)?8:4)) ) return; if( !skill_lv ) return; @@ -1440,15 +1391,15 @@ int guild_check_alliance(int guild_id1, int guild_id2, int flag) /*==================================================== * Player sd, asking player tsd an alliance between their 2 guilds *---------------------------------------------------*/ -int guild_reqalliance(struct map_session_data *sd,struct map_session_data *tsd) -{ +int guild_reqalliance(struct map_session_data *sd,struct map_session_data *tsd) { struct guild *g[2]; int i; - if(iMap->agit_flag || iMap->agit2_flag) { // Disable alliance creation during woe [Valaris] + if(map->agit_flag || map->agit2_flag) { + // Disable alliance creation during woe [Valaris] clif->message(sd->fd,msg_txt(676)); //"Alliances cannot be made during Guild Wars!" return 0; - } // end addition [Valaris] + } nullpo_ret(sd); @@ -1466,11 +1417,11 @@ int guild_reqalliance(struct map_session_data *sd,struct map_session_data *tsd) if(sd->status.guild_id == tsd->status.guild_id) return 0; - if( guild_get_alliance_count(g[0],0) >= battle_config.max_guild_alliance ) { + if( guild->get_alliance_count(g[0],0) >= battle_config.max_guild_alliance ) { clif->guild_allianceack(sd,4); return 0; } - if( guild_get_alliance_count(g[1],0) >= battle_config.max_guild_alliance ) { + if( guild->get_alliance_count(g[1],0) >= battle_config.max_guild_alliance ) { clif->guild_allianceack(sd,3); return 0; } @@ -1498,12 +1449,11 @@ int guild_reqalliance(struct map_session_data *sd,struct map_session_data *tsd) /*==================================================== * Player sd, answer to player tsd (account_id) for an alliance request *---------------------------------------------------*/ -int guild_reply_reqalliance(struct map_session_data *sd,int account_id,int flag) -{ +int guild_reply_reqalliance(struct map_session_data *sd,int account_id,int flag) { struct map_session_data *tsd; nullpo_ret(sd); - tsd= iMap->id2sd( account_id ); + tsd = map->id2sd( account_id ); if (!tsd) { //Character left? Cancel alliance. clif->guild_allianceack(sd,3); return 0; @@ -1519,12 +1469,12 @@ int guild_reply_reqalliance(struct map_session_data *sd,int account_id,int flag) g=sd->guild; tg=tsd->guild; - if(g==NULL || guild_get_alliance_count(g,0) >= battle_config.max_guild_alliance){ + if(g==NULL || guild->get_alliance_count(g,0) >= battle_config.max_guild_alliance){ clif->guild_allianceack(sd,4); clif->guild_allianceack(tsd,3); return 0; } - if(tg==NULL || guild_get_alliance_count(tg,0) >= battle_config.max_guild_alliance){ + if(tg==NULL || guild->get_alliance_count(tg,0) >= battle_config.max_guild_alliance){ clif->guild_allianceack(sd,3); clif->guild_allianceack(tsd,4); return 0; @@ -1559,14 +1509,14 @@ int guild_reply_reqalliance(struct map_session_data *sd,int account_id,int flag) /*==================================================== * Player sd asking to break alliance with guild guild_id *---------------------------------------------------*/ -int guild_delalliance(struct map_session_data *sd,int guild_id,int flag) -{ +int guild_delalliance(struct map_session_data *sd,int guild_id,int flag) { nullpo_ret(sd); - if(iMap->agit_flag || iMap->agit2_flag) { // Disable alliance breaking during woe [Valaris] + if(map->agit_flag || map->agit2_flag) { + // Disable alliance breaking during woe [Valaris] clif->message(sd->fd,msg_txt(677)); //"Alliances cannot be broken during Guild Wars!" return 0; - } // end addition [Valaris] + } intif->guild_alliance( sd->status.guild_id,guild_id,sd->status.account_id,0,flag|8 ); return 0; @@ -1590,36 +1540,35 @@ int guild_opposition(struct map_session_data *sd,struct map_session_data *tsd) if(sd->status.guild_id == tsd->status.guild_id) return 0; - if( guild_get_alliance_count(g,1) >= battle_config.max_guild_alliance ) { + if( guild->get_alliance_count(g,1) >= battle_config.max_guild_alliance ) { clif->guild_oppositionack(sd,1); return 0; } - for (i = 0; i < MAX_GUILDALLIANCE; i++) { // checking relations + for (i = 0; i < MAX_GUILDALLIANCE; i++) { // checking relations if(g->alliance[i].guild_id==tsd->status.guild_id){ - if (g->alliance[i].opposition == 1) { // check if not already hostile + if (g->alliance[i].opposition == 1) { // check if not already hostile clif->guild_oppositionack(sd,2); return 0; } - if(iMap->agit_flag || iMap->agit2_flag) // Prevent the changing of alliances to oppositions during WoE. + if(map->agit_flag || map->agit2_flag) // Prevent the changing of alliances to oppositions during WoE. return 0; //Change alliance to opposition. - intif->guild_alliance( sd->status.guild_id,tsd->status.guild_id, - sd->status.account_id,tsd->status.account_id,8 ); + intif->guild_alliance(sd->status.guild_id,tsd->status.guild_id, + sd->status.account_id,tsd->status.account_id,8); } } - // inform other serv - intif->guild_alliance( sd->status.guild_id,tsd->status.guild_id, - sd->status.account_id,tsd->status.account_id,1 ); + // inform other serv + intif->guild_alliance(sd->status.guild_id,tsd->status.guild_id, + sd->status.account_id,tsd->status.account_id,1); return 0; } /*==================================================== * Notification of a relationship between 2 guilds *---------------------------------------------------*/ -int guild_allianceack(int guild_id1,int guild_id2,int account_id1,int account_id2,int flag,const char *name1,const char *name2) -{ +int guild_allianceack(int guild_id1,int guild_id2,int account_id1,int account_id2,int flag,const char *name1,const char *name2) { struct guild *g[2]; int guild_id[2]; const char *guild_name[2]; @@ -1630,8 +1579,8 @@ int guild_allianceack(int guild_id1,int guild_id2,int account_id1,int account_id guild_id[1] = guild_id2; guild_name[0] = name1; guild_name[1] = name2; - sd[0] = iMap->id2sd(account_id1); - sd[1] = iMap->id2sd(account_id2); + sd[0] = map->id2sd(account_id1); + sd[1] = map->id2sd(account_id2); g[0]=guild->search(guild_id1); g[1]=guild->search(guild_id2); @@ -1641,7 +1590,7 @@ int guild_allianceack(int guild_id1,int guild_id2,int account_id1,int account_id sd[0]->guild_alliance_account=0; } - if (flag & 0x70) { // failure + if (flag & 0x70) { // failure for(i=0;i<2-(flag&1);i++) if( sd[i]!=NULL ) clif->guild_allianceack(sd[i],((flag>>4)==i+1)?3:4); @@ -1657,7 +1606,7 @@ int guild_allianceack(int guild_id1,int guild_id2,int account_id1,int account_id } } - if (!(flag & 0x08)) { // new relationship + if (!(flag & 0x08)) { // new relationship for(i=0;i<2-(flag&1);i++) { if(g[i]!=NULL) { ARR_FIND( 0, MAX_GUILDALLIANCE, j, g[i]->alliance[j].guild_id == 0 ); @@ -1668,28 +1617,28 @@ int guild_allianceack(int guild_id1,int guild_id2,int account_id1,int account_id } } } - } else { // remove relationship + } else { // remove relationship for(i=0;i<2-(flag&1);i++) { if( g[i] != NULL ) { ARR_FIND( 0, MAX_GUILDALLIANCE, j, g[i]->alliance[j].guild_id == guild_id[1-i] && g[i]->alliance[j].opposition == (flag&1) ); if( j < MAX_GUILDALLIANCE ) g[i]->alliance[j].guild_id = 0; } - if (sd[i] != NULL) // notify players + if (sd[i] != NULL) // notify players clif->guild_delalliance(sd[i],guild_id[1-i],(flag&1)); } } - if ((flag & 0x0f) == 0) { // alliance notification + if ((flag & 0x0f) == 0) { // alliance notification if( sd[1]!=NULL ) clif->guild_allianceack(sd[1],2); - } else if ((flag & 0x0f) == 1) { // enemy notification + } else if ((flag & 0x0f) == 1) { // enemy notification if( sd[0]!=NULL ) clif->guild_oppositionack(sd[0],0); } - for (i = 0; i < 2 - (flag & 1); i++) { // Retransmission of the relationship list to all members + for (i = 0; i < 2 - (flag & 1); i++) { // Retransmission of the relationship list to all members struct map_session_data *sd; if(g[i]!=NULL) for(j=0;j<g[i]->max_member;j++) @@ -1774,15 +1723,15 @@ int guild_broken(int guild_id,int flag) } } - guild_db->foreach(guild_db,guild_broken_sub,guild_id); - castle_db->foreach(castle_db,castle_guild_broken_sub,guild_id); + guild->db->foreach(guild->db,guild->broken_sub,guild_id); + guild->castle_db->foreach(guild->castle_db,guild->castle_broken_sub,guild_id); gstorage->delete(guild_id); if( hChSys.ally ) { if( g->channel != NULL ) { clif->chsys_delete(( struct hChSysCh * )g->channel); } } - idb_remove(guild_db,guild_id); + idb_remove(guild->db,guild_id); return 0; } @@ -1920,7 +1869,7 @@ int guild_break(struct map_session_data *sd,char *name) { void guild_castle_map_init(void) { DBIterator* iter = NULL; - int num = db_size(castle_db); + int num = db_size(guild->castle_db); if (num > 0) { struct guild_castle* gc = NULL; @@ -1928,7 +1877,7 @@ void guild_castle_map_init(void) CREATE(castle_ids, int, num); cursor = castle_ids; - iter = db_iterator(castle_db); + iter = db_iterator(guild->castle_db); for (gc = dbi_first(iter); dbi_exists(iter); gc = dbi_next(iter)) { *(cursor++) = gc->castle_id; } @@ -1963,7 +1912,7 @@ int guild_castledatasave(int castle_id, int index, int value) struct mob_data *gd; gc->guild_id = value; for (i = 0; i < MAX_GUARDIANS; i++) - if (gc->guardian[i].visible && (gd = iMap->id2md(gc->guardian[i].id)) != NULL) + if (gc->guardian[i].visible && (gd = map->id2md(gc->guardian[i].id)) != NULL) mob->guardian_guildchange(gd); break; } @@ -1975,7 +1924,7 @@ int guild_castledatasave(int castle_id, int index, int value) struct mob_data *gd; gc->defense = value; for (i = 0; i < MAX_GUARDIANS; i++) - if (gc->guardian[i].visible && (gd = iMap->id2md(gc->guardian[i].id)) != NULL) + if (gc->guardian[i].visible && (gd = map->id2md(gc->guardian[i].id)) != NULL) status_calc_mob(gd, 0); break; } @@ -2024,7 +1973,7 @@ void guild_castle_reconnect(int castle_id, int index, int value) static struct linkdb_node *gc_save_pending = NULL; if (castle_id < 0) { // char-server reconnected - linkdb_foreach(&gc_save_pending, guild_castle_reconnect_sub); + linkdb_foreach(&gc_save_pending, guild->castle_reconnect_sub); linkdb_final(&gc_save_pending); } else { int *data; @@ -2116,7 +2065,7 @@ int guild_checkcastles(struct guild *g) { int nb_cas = 0; struct guild_castle* gc = NULL; - DBIterator *iter = db_iterator(castle_db); + DBIterator *iter = db_iterator(guild->castle_db); for (gc = dbi_first(iter); dbi_exists(iter); gc = dbi_next(iter)) { if (gc->guild_id == g->guild_id) { @@ -2142,38 +2091,38 @@ void guild_flag_add(struct npc_data *nd) { int i; /* check */ - for( i = 0; i < guild_flags_count; i++ ) { - if( guild_flags[i] && guild_flags[i]->bl.id == nd->bl.id ) { + for( i = 0; i < guild->flags_count; i++ ) { + if( guild->flags[i] && guild->flags[i]->bl.id == nd->bl.id ) { return;/* exists, most likely updated the id. */ } } - i = guild_flags_count;/* save the current slot */ + i = guild->flags_count;/* save the current slot */ /* add */ - RECREATE(guild_flags,struct npc_data*,++guild_flags_count); + RECREATE(guild->flags,struct npc_data*,++guild->flags_count); /* save */ - guild_flags[i] = nd; + guild->flags[i] = nd; } void guild_flag_remove(struct npc_data *nd) { int i, cursor; - if( guild_flags_count == 0 ) + if( guild->flags_count == 0 ) return; /* find it */ - for( i = 0; i < guild_flags_count; i++ ) { - if( guild_flags[i] && guild_flags[i]->bl.id == nd->bl.id ) {/* found */ - guild_flags[i] = NULL; + for( i = 0; i < guild->flags_count; i++ ) { + if( guild->flags[i] && guild->flags[i]->bl.id == nd->bl.id ) {/* found */ + guild->flags[i] = NULL; break; } } /* compact list */ - for( i = 0, cursor = 0; i < guild_flags_count; i++ ) { - if( guild_flags[i] == NULL ) + for( i = 0, cursor = 0; i < guild->flags_count; i++ ) { + if( guild->flags[i] == NULL ) continue; if( cursor != i ) { - memmove(&guild_flags[cursor], &guild_flags[i], sizeof(struct npc_data*)); + memmove(&guild->flags[cursor], &guild->flags[i], sizeof(struct npc_data*)); } cursor++; @@ -2184,7 +2133,7 @@ void guild_flag_remove(struct npc_data *nd) { /** * @see DBApply */ -static int eventlist_db_final(DBKey key, DBData *data, va_list ap) { +int eventlist_db_final(DBKey key, DBData *data, va_list ap) { struct eventlist *next = NULL; struct eventlist *current = DB->data2ptr(data); while (current != NULL) { @@ -2198,15 +2147,15 @@ static int eventlist_db_final(DBKey key, DBData *data, va_list ap) { /** * @see DBApply */ -static int guild_expcache_db_final(DBKey key, DBData *data, va_list ap) { - ers_free(expcache_ers, DB->data2ptr(data)); +int guild_expcache_db_final(DBKey key, DBData *data, va_list ap) { + ers_free(guild->expcache_ers, DB->data2ptr(data)); return 0; } /** * @see DBApply */ -static int guild_castle_db_final(DBKey key, DBData *data, va_list ap) { +int guild_castle_db_final(DBKey key, DBData *data, va_list ap) { struct guild_castle* gc = DB->data2ptr(data); if( gc->temp_guardians ) aFree(gc->temp_guardians); @@ -2217,36 +2166,33 @@ static int guild_castle_db_final(DBKey key, DBData *data, va_list ap) { /* called when scripts are reloaded/unloaded */ void guild_flags_clear(void) { int i; - for( i = 0; i < guild_flags_count; i++ ) { - if( guild_flags[i] ) - guild_flags[i] = NULL; + for( i = 0; i < guild->flags_count; i++ ) { + if( guild->flags[i] ) + guild->flags[i] = NULL; } - guild_flags_count = 0; + guild->flags_count = 0; } void do_init_guild(void) { - guild_db = idb_alloc(DB_OPT_RELEASE_DATA); - castle_db = idb_alloc(DB_OPT_BASE); - guild_expcache_db = idb_alloc(DB_OPT_BASE); - guild_infoevent_db = idb_alloc(DB_OPT_BASE); - expcache_ers = ers_new(sizeof(struct guild_expcache),"guild.c::expcache_ers",ERS_OPT_NONE); - - guild_flags_count = 0; - - sv->readdb(iMap->db_path, "castle_db.txt", ',', 4, 5, -1, &guild_read_castledb); + guild->db = idb_alloc(DB_OPT_RELEASE_DATA); + guild->castle_db = idb_alloc(DB_OPT_BASE); + guild->expcache_db = idb_alloc(DB_OPT_BASE); + guild->infoevent_db = idb_alloc(DB_OPT_BASE); + guild->expcache_ers = ers_new(sizeof(struct guild_expcache),"guild.c::expcache_ers",ERS_OPT_NONE); + + sv->readdb(map->db_path, "castle_db.txt", ',', 4, 5, -1, guild->read_castledb); - memset(guild_skill_tree,0,sizeof(guild_skill_tree)); - sv->readdb(iMap->db_path, "guild_skill_tree.txt", ',', 2+MAX_GUILD_SKILL_REQUIRE*2, 2+MAX_GUILD_SKILL_REQUIRE*2, -1, &guild_read_guildskill_tree_db); //guild skill tree [Komurka] + sv->readdb(map->db_path, "guild_skill_tree.txt", ',', 2+MAX_GUILD_SKILL_REQUIRE*2, 2+MAX_GUILD_SKILL_REQUIRE*2, -1, guild->read_guildskill_tree_db); //guild skill tree [Komurka] - timer->add_func_list(guild_payexp_timer,"guild_payexp_timer"); - timer->add_func_list(guild_send_xy_timer, "guild_send_xy_timer"); - timer->add_interval(timer->gettick()+GUILD_PAYEXP_INVERVAL,guild_payexp_timer,0,0,GUILD_PAYEXP_INVERVAL); - timer->add_interval(timer->gettick()+GUILD_SEND_XY_INVERVAL,guild_send_xy_timer,0,0,GUILD_SEND_XY_INVERVAL); + timer->add_func_list(guild->payexp_timer,"guild_payexp_timer"); + timer->add_func_list(guild->send_xy_timer, "guild_send_xy_timer"); + timer->add_interval(timer->gettick()+GUILD_PAYEXP_INVERVAL,guild->payexp_timer,0,0,GUILD_PAYEXP_INVERVAL); + timer->add_interval(timer->gettick()+GUILD_SEND_XY_INVERVAL,guild->send_xy_timer,0,0,GUILD_SEND_XY_INVERVAL); } void do_final_guild(void) { - DBIterator *iter = db_iterator(guild_db); + DBIterator *iter = db_iterator(guild->db); struct guild *g; for( g = dbi_first(iter); dbi_exists(iter); g = dbi_next(iter) ) { @@ -2260,13 +2206,14 @@ void do_final_guild(void) { dbi_destroy(iter); - db_destroy(guild_db); - castle_db->destroy(castle_db,guild_castle_db_final); - guild_expcache_db->destroy(guild_expcache_db,guild_expcache_db_final); - guild_infoevent_db->destroy(guild_infoevent_db,eventlist_db_final); - ers_destroy(expcache_ers); - - aFree(guild_flags);/* never empty; created on boot */ + db_destroy(guild->db); + guild->castle_db->destroy(guild->castle_db,guild->castle_db_final); + guild->expcache_db->destroy(guild->expcache_db,guild->expcache_db_final); + guild->infoevent_db->destroy(guild->infoevent_db,guild->eventlist_db_final); + ers_destroy(guild->expcache_ers); + + if( guild->flags ) + aFree(guild->flags); } void guild_defaults(void) { guild = &guild_s; @@ -2274,6 +2221,18 @@ void guild_defaults(void) { guild->init = do_init_guild; guild->final = do_final_guild; /* */ + guild->db = NULL; + guild->castle_db = NULL; + guild->expcache_db = NULL; + guild->infoevent_db = NULL; + /* */ + guild->expcache_ers = NULL; + /* */ + memset(guild->skill_tree, 0, sizeof(guild->skill_tree)); + /* guild flags cache */ + guild->flags = NULL; + guild->flags_count = 0; + /* */ guild->skill_get_max = guild_skill_get_max; /* */ guild->checkskill = guild_checkskill; @@ -2350,4 +2309,22 @@ void guild_defaults(void) { guild->flags_clear = guild_flags_clear; /* guild aura */ guild->aura_refresh = guild_guildaura_refresh; + /* */ + guild->payexp_timer = guild_payexp_timer; + guild->sd_check = guild_sd_check; + guild->read_guildskill_tree_db = guild_read_guildskill_tree_db; + guild->read_castledb = guild_read_castledb; + guild->payexp_timer_sub = guild_payexp_timer_sub; + guild->send_xy_timer_sub = guild_send_xy_timer_sub; + guild->send_xy_timer = guild_send_xy_timer; + guild->create_expcache = create_expcache; + guild->eventlist_db_final = eventlist_db_final; + guild->expcache_db_final = guild_expcache_db_final; + guild->castle_db_final = guild_castle_db_final; + guild->broken_sub = guild_broken_sub; + guild->castle_broken_sub = castle_guild_broken_sub; + guild->makemember = guild_makemember; + guild->check_member = guild_check_member; + guild->get_alliance_count = guild_get_alliance_count; + guild->castle_reconnect_sub = guild_castle_reconnect_sub; } diff --git a/src/map/guild.h b/src/map/guild.h index 1f61df09e..566ca7ce4 100644 --- a/src/map/guild.h +++ b/src/map/guild.h @@ -6,14 +6,32 @@ #define _GUILD_H_ //#include "../common/mmo.h" +#include "map.h" // NAME_LENGTH + +/** + * Declarations + **/ struct guild; struct guild_member; struct guild_position; struct guild_castle; -#include "map.h" // NAME_LENGTH struct map_session_data; struct mob_data; +/** + * Defines + **/ +#define GUILD_SEND_XY_INVERVAL 5000 // Interval of sending coordinates and HP +#define GUILD_PAYEXP_INVERVAL 10000 //Interval (maximum survival time of the cache, in milliseconds) +#define MAX_GUILD_SKILL_REQUIRE 5 + +/** + * Structures + **/ +struct eventlist { + char name[EVENT_NAME_LENGTH]; + struct eventlist *next; +}; //For quick linking to a guardian's info. [Skotlex] struct guardian_data { int number; //0-MAX_GUARDIANS-1 = Guardians. MAX_GUARDIANS = Emperium. @@ -23,11 +41,36 @@ struct guardian_data { char guild_name[NAME_LENGTH]; struct guild_castle* castle; }; +struct guild_expcache { + int guild_id, account_id, char_id; + uint64 exp; +}; +struct s_guild_skill_tree { + int id; + int max; + struct { + short id; + short lv; + } need[MAX_GUILD_SKILL_REQUIRE]; +}; + struct guild_interface { void (*init) (void); void (*final) (void); /* */ + DBMap* db; // int guild_id -> struct guild* + DBMap* castle_db; // int castle_id -> struct guild_castle* + DBMap* expcache_db; // int char_id -> struct guild_expcache* + DBMap* infoevent_db; // int guild_id -> struct eventlist* + /* */ + struct eri *expcache_ers; //For handling of guild exp payment. + /* */ + struct s_guild_skill_tree skill_tree[MAX_GUILDSKILL]; + /* guild flags cache */ + struct npc_data **flags; + unsigned short flags_count; + /* */ int (*skill_get_max) (int id); /* */ int (*checkskill) (struct guild *g,int id); @@ -104,6 +147,24 @@ struct guild_interface { void (*flags_clear) (void); /* guild aura */ void (*aura_refresh) (struct map_session_data *sd, uint16 skill_id, uint16 skill_lv); + /* */ + int (*payexp_timer) (int tid, unsigned int tick, int id, intptr_t data); + TBL_PC* (*sd_check) (int guild_id, int account_id, int char_id); + bool (*read_guildskill_tree_db) (char* split[], int columns, int current); + bool (*read_castledb) (char* str[], int columns, int current); + int (*payexp_timer_sub) (DBKey key, DBData *data, va_list ap); + int (*send_xy_timer_sub) (DBKey key, DBData *data, va_list ap); + int (*send_xy_timer) (int tid, unsigned int tick, int id, intptr_t data); + DBData (*create_expcache) (DBKey key, va_list args); + int (*eventlist_db_final) (DBKey key, DBData *data, va_list ap); + int (*expcache_db_final) (DBKey key, DBData *data, va_list ap); + int (*castle_db_final) (DBKey key, DBData *data, va_list ap); + int (*broken_sub) (DBKey key, DBData *data, va_list ap); + int (*castle_broken_sub) (DBKey key, DBData *data, va_list ap); + void (*makemember) (struct guild_member *m,struct map_session_data *sd); + int (*check_member) (struct guild *g); + int (*get_alliance_count) (struct guild *g,int flag); + void (*castle_reconnect_sub) (void *key, void *data, va_list ap); }; struct guild_interface *guild; diff --git a/src/map/homunculus.c b/src/map/homunculus.c index 79d993ede..45e9af2b0 100644 --- a/src/map/homunculus.c +++ b/src/map/homunculus.c @@ -143,7 +143,7 @@ int homunculus_vaporize(struct map_session_data *sd, int flag) { if (!hd || hd->homunculus.vaporize) return 0; - if (iStatus->isdead(&hd->bl)) + if (status->isdead(&hd->bl)) return 0; //Can't vaporize a dead homun. if (flag && get_percentage(hd->battle_status.hp, hd->battle_status.max_hp) < 80) @@ -364,7 +364,7 @@ int homunculus_change_class(struct homun_data *hd, short class_) { return 0; hd->homunculusDB = &homun->db[i]; hd->homunculus.class_ = class_; - iStatus->set_viewdata(&hd->bl, class_); + status->set_viewdata(&hd->bl, class_); homun->calc_skilltree(hd, 1); return 1; } @@ -404,7 +404,7 @@ bool homunculus_evolve(struct homun_data *hd) { hom->intimacy = 500; unit->remove_map(&hd->bl, CLR_OUTSIGHT, ALC_MARK); - iMap->addblock(&hd->bl); + map->addblock(&hd->bl); clif->spawn(&hd->bl); clif->emotion(&sd->bl, E_NO1); @@ -448,7 +448,7 @@ bool homunculus_mutate(struct homun_data *hd, int homun_id) { } unit->remove_map(&hd->bl, CLR_OUTSIGHT, ALC_MARK); - iMap->addblock(&hd->bl); + map->addblock(&hd->bl); clif->spawn(&hd->bl); clif->emotion(&sd->bl, E_NO1); @@ -619,7 +619,7 @@ int homunculus_hunger_timer(int tid, unsigned int tick, int id, intptr_t data) { struct map_session_data *sd; struct homun_data *hd; - if(!(sd=iMap->id2sd(id)) || !sd->status.hom_id || !(hd=sd->hd)) + if(!(sd=map->id2sd(id)) || !sd->status.hom_id || !(hd=sd->hd)) return 1; if(hd->hungry_timer != tid){ @@ -743,8 +743,8 @@ bool homunculus_create(struct map_session_data *sd, struct s_homunculus *hom) { memcpy(&hd->homunculus, hom, sizeof(struct s_homunculus)); hd->exp_next = homun->exptable[hd->homunculus.level - 1]; - iStatus->set_viewdata(&hd->bl, hd->homunculus.class_); - iStatus->change_init(&hd->bl); + status->set_viewdata(&hd->bl, hd->homunculus.class_); + status->change_init(&hd->bl); unit->dataset(&hd->bl); hd->ud.dir = sd->ud.dir; @@ -756,7 +756,7 @@ bool homunculus_create(struct map_session_data *sd, struct s_homunculus *hom) { hd->bl.x = hd->ud.to_x; hd->bl.y = hd->ud.to_y; - iMap->addiddb(&hd->bl); + map->addiddb(&hd->bl); status_calc_homunculus(hd,1); hd->hungry_timer = INVALID_TIMER; @@ -790,7 +790,7 @@ bool homunculus_call(struct map_session_data *sd) { hd->bl.x = sd->bl.x; hd->bl.y = sd->bl.y; hd->bl.m = sd->bl.m; - iMap->addblock(&hd->bl); + map->addblock(&hd->bl); clif->spawn(&hd->bl); clif->send_homdata(sd,SP_ACK,0); clif->hominfo(sd,hd,1); @@ -810,7 +810,7 @@ bool homunculus_recv_data(int account_id, struct s_homunculus *sh, int flag) { struct map_session_data *sd; struct homun_data *hd; - sd = iMap->id2sd(account_id); + sd = map->id2sd(account_id); if(!sd) return false; if (sd->status.char_id != sh->char_id) { @@ -836,7 +836,7 @@ bool homunculus_recv_data(int account_id, struct s_homunculus *sh, int flag) { if(hd && hd->homunculus.hp && !hd->homunculus.vaporize && hd->bl.prev == NULL && sd->bl.prev != NULL) { enum homun_type htype = homun->class2type(hd->homunculus.class_); - iMap->addblock(&hd->bl); + map->addblock(&hd->bl); clif->spawn(&hd->bl); clif->send_homdata(sd,SP_ACK,0); clif->hominfo(sd,hd,1); @@ -911,7 +911,7 @@ bool homunculus_ressurect(struct map_session_data* sd, unsigned char per, short if (hd->homunculus.vaporize) return false; // vaporized homunculi need to be 'called' - if (!iStatus->isdead(&hd->bl)) + if (!status->isdead(&hd->bl)) return false; // already alive homun->init_timers(hd); @@ -921,10 +921,10 @@ bool homunculus_ressurect(struct map_session_data* sd, unsigned char per, short hd->bl.m = sd->bl.m; hd->bl.x = x; hd->bl.y = y; - iMap->addblock(&hd->bl); + map->addblock(&hd->bl); clif->spawn(&hd->bl); } - iStatus->revive(&hd->bl, per, 0); + status->revive(&hd->bl, per, 0); return true; } @@ -1129,14 +1129,14 @@ void homunculus_read_db(void) { if( i > 0 ) { char filepath[256]; - sprintf(filepath, "%s/%s", iMap->db_path, filename[i]); + sprintf(filepath, "%s/%s", map->db_path, filename[i]); if( !exists(filepath) ) { continue; } } - sv->readdb(iMap->db_path, filename[i], ',', 50, 50, MAX_HOMUNCULUS_CLASS, homun->read_db_sub); + sv->readdb(map->db_path, filename[i], ',', 50, 50, MAX_HOMUNCULUS_CLASS, homun->read_db_sub); } } @@ -1182,7 +1182,7 @@ bool homunculus_read_skill_db_sub(char* split[], int columns, int current) { void homunculus_skill_db_read(void) { memset(homun->skill_tree,0,sizeof(homun->skill_tree)); - sv->readdb(iMap->db_path, "homun_skill_tree.txt", ',', 13, 15, -1, homun->read_skill_db_sub); + sv->readdb(map->db_path, "homun_skill_tree.txt", ',', 13, 15, -1, homun->read_skill_db_sub); } @@ -1196,7 +1196,7 @@ void homunculus_exp_db_read(void) { memset(homun->exptable,0,sizeof(homun->exptable)); for(i = 0; i < 2; i++) { - sprintf(line, "%s/%s", iMap->db_path, filename[i]); + sprintf(line, "%s/%s", map->db_path, filename[i]); if( (fp=fopen(line,"r")) == NULL) { if(i != 0) continue; diff --git a/src/map/instance.c b/src/map/instance.c index 548a34b1d..5ef089fae 100644 --- a/src/map/instance.c +++ b/src/map/instance.c @@ -59,7 +59,7 @@ int instance_create(int owner_id, const char *name, enum instance_owner_type typ case IOT_NONE: break; case IOT_CHAR: - if( ( sd = iMap->id2sd(owner_id) ) == NULL ) { + if( ( sd = map->id2sd(owner_id) ) == NULL ) { ShowError("instance_create: character %d not found for instance '%s'.\n", owner_id, name); return -2; } @@ -142,7 +142,7 @@ int instance_create(int owner_id, const char *name, enum instance_owner_type typ * Add a map to the instance using src map "name" *--------------------------------------*/ int instance_add_map(const char *name, int instance_id, bool usebasename, const char *map_name) { - int16 m = iMap->mapname2mapid(name); + int16 m = map->mapname2mapid(name); int i, im = -1; size_t num_cell, size; @@ -165,17 +165,17 @@ int instance_add_map(const char *name, int instance_id, bool usebasename, const return -4; } - ARR_FIND( instance->start_id, iMap->map_num, i, maplist[i].name[0] == 0 ); // Searching for a Free Map + ARR_FIND( instance->start_id, map->map_num, i, maplist[i].name[0] == 0 ); // Searching for a Free Map - if( i < iMap->map_num ) + if( i < map->map_num ) im = i; // Unused map found (old instance) else { - im = iMap->map_num; // Using next map index - RECREATE(maplist,struct map_data,++iMap->map_num); + im = map->map_num; // Using next map index + RECREATE(maplist,struct map_data,++map->map_num); } if( maplist[m].cell == (struct mapcell *)0xdeadbeaf ) - iMap->cellfromcache(&maplist[m]); + map->cellfromcache(&maplist[m]); memcpy( &maplist[im], &maplist[m], sizeof(struct map_data) ); // Copy source map if( map_name != NULL ) { @@ -247,7 +247,7 @@ int instance_add_map(const char *name, int instance_id, bool usebasename, const 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(&maplist[im]); + map->addmap2db(&maplist[im]); return im; } @@ -314,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, maplist[instances[instance_id].map[i]].instance_src_map, BL_NPC, instances[instance_id].map[i]); + map->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; } @@ -339,7 +339,7 @@ int instance_cleanup_sub(struct block_list *bl, va_list ap) { switch(bl->type) { case BL_PC: - iMap->quit((struct map_session_data *) bl); + map->quit((struct map_session_data *) bl); break; case BL_NPC: npc->unload((struct npc_data *)bl,true); @@ -351,7 +351,7 @@ int instance_cleanup_sub(struct block_list *bl, va_list ap) { //There is no need for this, the pet is removed together with the player. [Skotlex] break; case BL_ITEM: - iMap->clearflooritem(bl); + map->clearflooritem(bl); break; case BL_SKILL: skill->delunit((struct skill_unit *) bl); @@ -372,11 +372,11 @@ void instance_del_map(int16 m) { return; } - iMap->map_foreachpc(instance_del_load, m); - iMap->foreachinmap(instance_cleanup_sub, m, BL_ALL); + map->map_foreachpc(instance_del_load, m); + map->foreachinmap(instance_cleanup_sub, m, BL_ALL); if( maplist[m].mob_delete_timer != INVALID_TIMER ) - timer->delete(maplist[m].mob_delete_timer, iMap->removemobs_timer); + timer->delete(maplist[m].mob_delete_timer, map->removemobs_timer); mapindex_removemap(map_id2index(m)); @@ -426,7 +426,7 @@ void instance_del_map(int16 m) { if( maplist[m].channel ) clif->chsys_delete(maplist[m].channel); - iMap->removemapdb(&maplist[m]); + map->removemapdb(&maplist[m]); memset(&maplist[m], 0x00, sizeof(maplist[0])); maplist[m].name[0] = 0; maplist[m].instance_id = -1; @@ -469,7 +469,7 @@ void instance_destroy(int instance_id) { case IOT_NONE: break; case IOT_CHAR: - if( ( sd = iMap->id2sd(instances[instance_id].owner_id) ) == NULL ) { + if( ( sd = map->id2sd(instances[instance_id].owner_id) ) == NULL ) { break; } iptr = sd->instance; diff --git a/src/map/intif.c b/src/map/intif.c index cae2561a0..97ff8a681 100644 --- a/src/map/intif.c +++ b/src/map/intif.c @@ -46,15 +46,14 @@ static const int packet_len_table[]={ -1,-1, 7, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3890 Homunculus [albator] }; -extern int char_fd; // inter server Fd used for char_fd -#define inter_fd char_fd // alias +#define inter_fd chrif->fd // alias //----------------------------------------------------------------- // Send to inter server int CheckForCharServer(void) { - return ((char_fd <= 0) || session[char_fd] == NULL || session[char_fd]->wdata == NULL); + return ((chrif->fd <= 0) || session[chrif->fd] == NULL || session[chrif->fd]->wdata == NULL); } // pet @@ -466,7 +465,7 @@ int intif_party_changemap(struct map_session_data *sd,int online) { if(!sd) return 0; - if( (m=iMap->mapindex2mapid(sd->mapindex)) >= 0 && maplist[m].instance_id >= 0 ) + if( (m=map->mapindex2mapid(sd->mapindex)) >= 0 && maplist[m].instance_id >= 0 ) mapindex = map_id2index(maplist[m].instance_src_map); else mapindex = sd->mapindex; @@ -851,8 +850,7 @@ int intif_homunculus_requestdelete(int homun_id) // Packets receive from inter server // Wisp/Page reception // rewritten by [Yor] -int intif_parse_WisMessage(int fd) -{ +int intif_parse_WisMessage(int fd) { struct map_session_data* sd; char *wisp_source; char name[NAME_LENGTH]; @@ -861,9 +859,9 @@ int intif_parse_WisMessage(int fd) id=RFIFOL(fd,4); safestrncpy(name, (char*)RFIFOP(fd,32), NAME_LENGTH); - sd = iMap->nick2sd(name); - if(sd == NULL || strcmp(sd->status.name, name) != 0) - { //Not found + sd = map->nick2sd(name); + if(sd == NULL || strcmp(sd->status.name, name) != 0) { + //Not found intif_wis_replay(id,1); return 0; } @@ -895,7 +893,7 @@ int intif_parse_WisEnd(int fd) if (battle_config.etc_log) ShowInfo("intif_parse_wisend: player: %s, flag: %d\n", RFIFOP(fd,2), RFIFOB(fd,26)); // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target - sd = (struct map_session_data *)iMap->nick2sd((char *) RFIFOP(fd,2)); + sd = (struct map_session_data *)map->nick2sd((char *) RFIFOP(fd,2)); if (sd != NULL) clif->wis_end(sd->fd, RFIFOB(fd,26)); @@ -934,7 +932,7 @@ int mapif_parse_WisToGM(int fd) safestrncpy(Wisp_name, (char*)RFIFOP(fd,4), NAME_LENGTH); safestrncpy(message, (char*)RFIFOP(fd,32), mes_len); // information is sent to all online GM - iMap->map_foreachpc(mapif_parse_WisToGM_sub, permission, Wisp_name, message, mes_len); + map->map_foreachpc(mapif_parse_WisToGM_sub, permission, Wisp_name, message, mes_len); if (message != mbuf) aFree(message); @@ -953,7 +951,7 @@ int intif_parse_Registers(int fd) if (node) sd = node->sd; else { //Normally registries should arrive for in log-in chars. - sd = iMap->id2sd(account_id); + sd = map->id2sd(account_id); if (sd && RFIFOB(fd,12) == 3 && sd->status.char_id != char_id) sd = NULL; //Character registry from another character. } @@ -1005,7 +1003,7 @@ int intif_parse_LoadGuildStorage(int fd) guild_id = RFIFOL(fd,8); if(guild_id <= 0) return 1; - sd=iMap->id2sd( RFIFOL(fd,4) ); + sd=map->id2sd( RFIFOL(fd,4) ); if(sd==NULL){ ShowError("intif_parse_LoadGuildStorage: user not found %d\n",RFIFOL(fd,4)); return 1; @@ -1321,7 +1319,7 @@ int intif_parse_DeletePetOk(int fd) int intif_parse_ChangeNameOk(int fd) { struct map_session_data *sd = NULL; - if((sd=iMap->id2sd(RFIFOL(fd,2)))==NULL || + if((sd=map->id2sd(RFIFOL(fd,2)))==NULL || sd->status.char_id != RFIFOL(fd,6)) return 0; @@ -1404,7 +1402,7 @@ int intif_parse_questlog(int fd) { int char_id = RFIFOL(fd, 4); int i; - TBL_PC * sd = iMap->charid2sd(char_id); + TBL_PC * sd = map->charid2sd(char_id); //User not online anymore if(!sd) @@ -1438,10 +1436,9 @@ int intif_parse_questlog(int fd) return 0; } -int intif_parse_questsave(int fd) -{ +int intif_parse_questsave(int fd) { int cid = RFIFOL(fd, 2); - TBL_PC *sd = iMap->id2sd(cid); + TBL_PC *sd = map->id2sd(cid); if( !RFIFOB(fd, 6) ) ShowError("intif_parse_questsave: Failed to save quest(s) for character %d!\n", cid); @@ -1499,7 +1496,7 @@ int intif_parse_Mail_inboxreceived(int fd) struct map_session_data *sd; unsigned char flag = RFIFOB(fd,8); - sd = iMap->charid2sd(RFIFOL(fd,4)); + sd = map->charid2sd(RFIFOL(fd,4)); if (sd == NULL) { @@ -1559,13 +1556,12 @@ int intif_Mail_getattach(int char_id, int mail_id) return 0; } -int intif_parse_Mail_getattach(int fd) -{ +int intif_parse_Mail_getattach(int fd) { struct map_session_data *sd; struct item item; int zeny = RFIFOL(fd,8); - sd = iMap->charid2sd( RFIFOL(fd,4) ); + sd = map->charid2sd( RFIFOL(fd,4) ); if (sd == NULL) { @@ -1601,13 +1597,12 @@ int intif_Mail_delete(int char_id, int mail_id) return 0; } -int intif_parse_Mail_delete(int fd) -{ +int intif_parse_Mail_delete(int fd) { int char_id = RFIFOL(fd,2); int mail_id = RFIFOL(fd,6); bool failed = RFIFOB(fd,10); - struct map_session_data *sd = iMap->charid2sd(char_id); + struct map_session_data *sd = map->charid2sd(char_id); if (sd == NULL) { ShowError("intif_parse_Mail_delete: char not found %d\n", char_id); @@ -1648,9 +1643,8 @@ int intif_Mail_return(int char_id, int mail_id) return 0; } -int intif_parse_Mail_return(int fd) -{ - struct map_session_data *sd = iMap->charid2sd(RFIFOL(fd,2)); +int intif_parse_Mail_return(int fd) { + struct map_session_data *sd = map->charid2sd(RFIFOL(fd,2)); int mail_id = RFIFOL(fd,6); short fail = RFIFOB(fd,10); @@ -1713,23 +1707,20 @@ static void intif_parse_Mail_send(int fd) fail = (msg.id == 0); // notify sender - sd = iMap->charid2sd(msg.send_id); - if( sd != NULL ) - { + sd = map->charid2sd(msg.send_id); + if( sd != NULL ) { if( fail ) mail->deliveryfail(sd, &msg); - else - { + else { clif->mail_send(sd->fd, false); - if( iMap->save_settings&16 ) + if( map->save_settings&16 ) chrif->save(sd, 0); } } } -static void intif_parse_Mail_new(int fd) -{ - struct map_session_data *sd = iMap->charid2sd(RFIFOL(fd,2)); +static void intif_parse_Mail_new(int fd) { + struct map_session_data *sd = map->charid2sd(RFIFOL(fd,2)); int mail_id = RFIFOL(fd,6); const char* sender_name = (char*)RFIFOP(fd,10); const char* title = (char*)RFIFOP(fd,34); @@ -1765,9 +1756,8 @@ int intif_Auction_requestlist(int char_id, short type, int price, const char* se return 0; } -static void intif_parse_Auction_results(int fd) -{ - struct map_session_data *sd = iMap->charid2sd(RFIFOL(fd,4)); +static void intif_parse_Auction_results(int fd) { + struct map_session_data *sd = map->charid2sd(RFIFOL(fd,4)); short count = RFIFOW(fd,8); short pages = RFIFOW(fd,10); uint8* data = RFIFOP(fd,12); @@ -1794,25 +1784,22 @@ int intif_Auction_register(struct auction_data *auction) return 1; } -static void intif_parse_Auction_register(int fd) -{ +static void intif_parse_Auction_register(int fd) { struct map_session_data *sd; struct auction_data auction; - if( RFIFOW(fd,2) - 4 != sizeof(struct auction_data) ) - { + if( RFIFOW(fd,2) - 4 != sizeof(struct auction_data) ) { ShowError("intif_parse_Auction_register: data size error %d %d\n", RFIFOW(fd,2) - 4, sizeof(struct auction_data)); return; } memcpy(&auction, RFIFOP(fd,4), sizeof(struct auction_data)); - if( (sd = iMap->charid2sd(auction.seller_id)) == NULL ) + if( (sd = map->charid2sd(auction.seller_id)) == NULL ) return; - if( auction.auction_id > 0 ) - { + if( auction.auction_id > 0 ) { clif->auction_message(sd->fd, 1); // Confirmation Packet ?? - if( iMap->save_settings&32 ) + if( map->save_settings&32 ) chrif->save(sd,0); } else @@ -1840,16 +1827,14 @@ int intif_Auction_cancel(int char_id, unsigned int auction_id) return 0; } -static void intif_parse_Auction_cancel(int fd) -{ - struct map_session_data *sd = iMap->charid2sd(RFIFOL(fd,2)); +static void intif_parse_Auction_cancel(int fd) { + struct map_session_data *sd = map->charid2sd(RFIFOL(fd,2)); int result = RFIFOB(fd,6); if( sd == NULL ) return; - switch( result ) - { + switch( result ) { case 0: clif->auction_message(sd->fd, 2); break; case 1: clif->auction_close(sd->fd, 2); break; case 2: clif->auction_close(sd->fd, 1); break; @@ -1871,9 +1856,8 @@ int intif_Auction_close(int char_id, unsigned int auction_id) return 0; } -static void intif_parse_Auction_close(int fd) -{ - struct map_session_data *sd = iMap->charid2sd(RFIFOL(fd,2)); +static void intif_parse_Auction_close(int fd) { + struct map_session_data *sd = map->charid2sd(RFIFOL(fd,2)); unsigned char result = RFIFOB(fd,6); if( sd == NULL ) @@ -1907,9 +1891,8 @@ int intif_Auction_bid(int char_id, const char* name, unsigned int auction_id, in return 0; } -static void intif_parse_Auction_bid(int fd) -{ - struct map_session_data *sd = iMap->charid2sd(RFIFOL(fd,2)); +static void intif_parse_Auction_bid(int fd) { + struct map_session_data *sd = map->charid2sd(RFIFOL(fd,2)); int bid = RFIFOL(fd,6); unsigned char result = RFIFOB(fd,10); @@ -1927,9 +1910,8 @@ static void intif_parse_Auction_bid(int fd) } // Used to send 'You have won the auction' and 'You failed to won the auction' messages -static void intif_parse_Auction_message(int fd) -{ - struct map_session_data *sd = iMap->charid2sd(RFIFOL(fd,2)); +static void intif_parse_Auction_message(int fd) { + struct map_session_data *sd = map->charid2sd(RFIFOL(fd,2)); unsigned char result = RFIFOB(fd,6); if( sd == NULL ) diff --git a/src/map/itemdb.c b/src/map/itemdb.c index 7af6f3262..f7ee8a884 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -1387,7 +1387,7 @@ void itemdb_read_combos() { char filepath[256]; FILE* fp; - sprintf(filepath, "%s/%s", iMap->db_path, DBPATH"item_combo_db.txt"); + sprintf(filepath, "%s/%s", map->db_path, DBPATH"item_combo_db.txt"); if ((fp = fopen(filepath, "r")) == NULL) { ShowError("itemdb_read_combos: File not found \"%s\".\n", filepath); @@ -1631,7 +1631,7 @@ int itemdb_parse_dbrow(char** str, const char* source, int line, int scriptopt) id->weight = atoi(str[6]); #ifdef RENEWAL - if( iMap->db_use_sql_item_db ) { + if( map->db_use_sql_item_db ) { id->atk = atoi(str[7]); id->matk = atoi(str[8]); offset += 1; @@ -1661,7 +1661,7 @@ int itemdb_parse_dbrow(char** str, const char* source, int line, int scriptopt) id->wlv = cap_value(atoi(str[15+offset]), REFINE_TYPE_ARMOR, REFINE_TYPE_MAX); #ifdef RENEWAL - if( iMap->db_use_sql_item_db ) { + if( map->db_use_sql_item_db ) { id->elv = atoi(str[16+offset]); id->elvmax = atoi(str[17+offset]); offset += 1; @@ -1719,7 +1719,7 @@ int itemdb_readdb(void) char filepath[256]; FILE* fp; - sprintf(filepath, "%s/%s", iMap->db_path, filename[fi]); + sprintf(filepath, "%s/%s", map->db_path, filename[fi]); fp = fopen(filepath, "r"); if( fp == NULL ) { ShowWarning("itemdb_readdb: File not found \"%s\", skipping.\n", filepath); @@ -1826,12 +1826,12 @@ int itemdb_readdb(void) int itemdb_read_sqldb(void) { const char* item_db_name[] = { - #ifdef RENEWAL - iMap->item_db_re_db, - #else - iMap->item_db_db, - #endif - iMap->item_db2_db }; +#ifdef RENEWAL + map->item_db_re_db, +#else // not RENEWAL + map->item_db_db, +#endif // RENEWAL + map->item_db2_db }; int fi; for( fi = 0; fi < ARRAYLENGTH(item_db_name); ++fi ) { @@ -1894,9 +1894,8 @@ uint64 itemdb_unique_id(int8 flag, int64 value) { return ++item_uid; } int itemdb_uid_load() { - char * uid; - if (SQL_ERROR == SQL->Query(mmysql_handle, "SELECT `value` FROM `%s` WHERE `varname`='unique_id'",iMap->interreg_db)) + if (SQL_ERROR == SQL->Query(mmysql_handle, "SELECT `value` FROM `%s` WHERE `varname`='unique_id'",map->interreg_db)) Sql_ShowDebug(mmysql_handle); if( SQL_SUCCESS != SQL->NextRow(mmysql_handle) ) { @@ -1919,7 +1918,7 @@ void itemdb_read(void) { int i; DBData prev; - if (iMap->db_use_sql_item_db) + if (map->db_use_sql_item_db) itemdb->read_sqldb(); else itemdb->readdb(); @@ -1938,12 +1937,12 @@ void itemdb_read(void) { itemdb->read_chains(); itemdb->read_packages(); - sv->readdb(iMap->db_path, "item_avail.txt", ',', 2, 2, -1, itemdb->read_itemavail); - sv->readdb(iMap->db_path, DBPATH"item_trade.txt", ',', 3, 3, -1, itemdb->read_itemtrade); - sv->readdb(iMap->db_path, "item_delay.txt", ',', 2, 2, -1, itemdb->read_itemdelay); - sv->readdb(iMap->db_path, "item_stack.txt", ',', 3, 3, -1, itemdb->read_stack); - sv->readdb(iMap->db_path, DBPATH"item_buyingstore.txt", ',', 1, 1, -1, itemdb->read_buyingstore); - sv->readdb(iMap->db_path, "item_nouse.txt", ',', 3, 3, -1, itemdb->read_nouse); + sv->readdb(map->db_path, "item_avail.txt", ',', 2, 2, -1, itemdb->read_itemavail); + sv->readdb(map->db_path, DBPATH"item_trade.txt", ',', 3, 3, -1, itemdb->read_itemtrade); + sv->readdb(map->db_path, "item_delay.txt", ',', 2, 2, -1, itemdb->read_itemdelay); + sv->readdb(map->db_path, "item_stack.txt", ',', 3, 3, -1, itemdb->read_stack); + sv->readdb(map->db_path, DBPATH"item_buyingstore.txt", ',', 1, 1, -1, itemdb->read_buyingstore); + sv->readdb(map->db_path, "item_nouse.txt", ',', 3, 3, -1, itemdb->read_nouse); itemdb->uid_load(); } diff --git a/src/map/log.c b/src/map/log.c index a10549972..929143ba7 100644 --- a/src/map/log.c +++ b/src/map/log.c @@ -374,7 +374,7 @@ void log_chat(e_log_chat_type type, int type_id, int src_charid, int src_accid, return; } - if( logs->config.log_chat_woe_disable && ( iMap->agit_flag || iMap->agit2_flag ) ) { + if( logs->config.log_chat_woe_disable && ( map->agit_flag || map->agit2_flag ) ) { // no chat logging during woe return; } diff --git a/src/map/map.c b/src/map/map.c index d57fc583a..8641f7011 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -133,7 +133,7 @@ int enable_grf = 0; //To enable/disable reading maps from GRF files, bypassing m struct eri *map_iterator_ers; char *map_cache_buffer = NULL; // Has the uncompressed gat data of all maps, so just one allocation has to be made -struct map_interface iMap_s; +struct map_interface map_s; struct map_session_data *cpsd; @@ -177,7 +177,7 @@ int map_freeblock (struct block_list *bl) return block_free_lock; } /*========================================== -* Lock blocklist, (prevent iMap->freeblock usage) +* Lock blocklist, (prevent map->freeblock usage) *------------------------------------------*/ int map_freeblock_lock (void) { @@ -207,12 +207,11 @@ int map_freeblock_unlock (void) // Timer function to check if there some remaining lock and remove them if so. // Called each 1s -int map_freeblock_timer(int tid, unsigned int tick, int id, intptr_t data) -{ +int map_freeblock_timer(int tid, unsigned int tick, int id, intptr_t data) { if (block_free_lock > 0) { ShowError("map_freeblock_timer: block_free_lock(%d) is invalid.\n", block_free_lock); block_free_lock = 1; - iMap->freeblock_unlock(); + map->freeblock_unlock(); } return 0; @@ -269,9 +268,8 @@ int map_addblock(struct block_list* bl) m = bl->m; x = bl->x; y = bl->y; - if( m < 0 || m >= iMap->map_num ) - { - ShowError("map_addblock: invalid map id (%d), only %d are loaded.\n", m, iMap->map_num); + if( m < 0 || m >= map->map_num ) { + ShowError("map_addblock: invalid map id (%d), only %d are loaded.\n", m, map->map_num); return 1; } if( x < 0 || x >= maplist[m].xs || y < 0 || y >= maplist[m].ys ) { @@ -361,7 +359,7 @@ int map_moveblock(struct block_list *bl, int x1, int y1, unsigned int tick) //TODO: Perhaps some outs of bounds checking should be placed here? if (bl->type&BL_CHAR) { - sc = iStatus->get_sc(bl); + sc = status->get_sc(bl); skill->unit_move(bl,tick,2); status_change_end(bl, SC_RG_CCONFINE_M, INVALID_TIMER); @@ -375,13 +373,13 @@ int map_moveblock(struct block_list *bl, int x1, int y1, unsigned int tick) } else if (bl->type == BL_NPC) npc->unsetcells((TBL_NPC*)bl); - if (moveblock) iMap->delblock(bl); + if (moveblock) map->delblock(bl); #ifdef CELL_NOSTACK else map_delblcell(bl); #endif bl->x = x1; bl->y = y1; - if (moveblock) iMap->addblock(bl); + if (moveblock) map->addblock(bl); #ifdef CELL_NOSTACK else map_addblcell(bl); #endif @@ -392,7 +390,7 @@ int map_moveblock(struct block_list *bl, int x1, int y1, unsigned int tick) if( bl->type == BL_PC && ((TBL_PC*)bl)->shadowform_id ) {//Shadow Form Target Moving struct block_list *d_bl; - if( (d_bl = iMap->id2bl(((TBL_PC*)bl)->shadowform_id)) == NULL || !check_distance_bl(bl,d_bl,10) ) { + if( (d_bl = map->id2bl(((TBL_PC*)bl)->shadowform_id)) == NULL || !check_distance_bl(bl,d_bl,10) ) { if( d_bl ) status_change_end(d_bl,SC__SHADOWFORM,INVALID_TIMER); ((TBL_PC*)bl)->shadowform_id = 0; @@ -417,16 +415,17 @@ int map_moveblock(struct block_list *bl, int x1, int y1, unsigned int tick) if( sc->data[SC__SHADOWFORM] ) {//Shadow Form Caster Moving struct block_list *d_bl; - if( (d_bl = iMap->id2bl(sc->data[SC__SHADOWFORM]->val2)) == NULL || !check_distance_bl(bl,d_bl,10) ) + if( (d_bl = map->id2bl(sc->data[SC__SHADOWFORM]->val2)) == NULL || !check_distance_bl(bl,d_bl,10) ) status_change_end(bl,SC__SHADOWFORM,INVALID_TIMER); } if (sc->data[SC_PROPERTYWALK] - && sc->data[SC_PROPERTYWALK]->val3 < skill->get_maxcount(sc->data[SC_PROPERTYWALK]->val1,sc->data[SC_PROPERTYWALK]->val2) - && iMap->find_skill_unit_oncell(bl,bl->x,bl->y,SO_ELECTRICWALK,NULL,0) == NULL - && iMap->find_skill_unit_oncell(bl,bl->x,bl->y,SO_FIREWALK,NULL,0) == NULL - && skill->unitsetting(bl,sc->data[SC_PROPERTYWALK]->val1,sc->data[SC_PROPERTYWALK]->val2,x0, y0,0)) { - sc->data[SC_PROPERTYWALK]->val3++; + && sc->data[SC_PROPERTYWALK]->val3 < skill->get_maxcount(sc->data[SC_PROPERTYWALK]->val1,sc->data[SC_PROPERTYWALK]->val2) + && map->find_skill_unit_oncell(bl,bl->x,bl->y,SO_ELECTRICWALK,NULL,0) == NULL + && map->find_skill_unit_oncell(bl,bl->x,bl->y,SO_FIREWALK,NULL,0) == NULL + && skill->unitsetting(bl,sc->data[SC_PROPERTYWALK]->val1,sc->data[SC_PROPERTYWALK]->val2,x0, y0,0) + ) { + sc->data[SC_PROPERTYWALK]->val3++; } @@ -519,12 +518,11 @@ struct skill_unit* map_find_skill_unit_oncell(struct block_list* target,int16 x, * @param args Extra arguments for func * @return Sum of the values returned by func */ -static int bl_vforeach(int (*func)(struct block_list*, va_list), int blockcount, int max, va_list args) -{ +static int bl_vforeach(int (*func)(struct block_list*, va_list), int blockcount, int max, va_list args) { int i; int returnCount = 0; - iMap->freeblock_lock(); + map->freeblock_lock(); for (i = blockcount; i < bl_list_count && returnCount < max; i++) { if (bl_list[i]->prev) { //func() may delete this bl_list[] slot, checking for prev ensures it wasnt queued for deletion. va_list argscopy; @@ -533,7 +531,7 @@ static int bl_vforeach(int (*func)(struct block_list*, va_list), int blockcount, va_end(argscopy); } } - iMap->freeblock_unlock(); + map->freeblock_unlock(); bl_list_count = blockcount; @@ -1174,8 +1172,7 @@ int map_get_new_object_id(void) * Timered function to clear the floor (remove remaining item) * Called each flooritem_lifetime ms *------------------------------------------*/ -int map_clearflooritem_timer(int tid, unsigned int tick, int id, intptr_t data) -{ +int map_clearflooritem_timer(int tid, unsigned int tick, int id, intptr_t data) { struct flooritem_data* fitem = (struct flooritem_data*)idb_get(id_db, id); if (fitem == NULL || fitem->bl.type != BL_ITEM || (fitem->cleartimer != tid)) { @@ -1188,9 +1185,9 @@ int map_clearflooritem_timer(int tid, unsigned int tick, int id, intptr_t data) intif->delete_petdata(MakeDWord(fitem->item_data.card[1], fitem->item_data.card[2])); clif->clearflooritem(fitem, 0); - iMap->deliddb(&fitem->bl); - iMap->delblock(&fitem->bl); - iMap->freeblock(&fitem->bl); + map->deliddb(&fitem->bl); + map->delblock(&fitem->bl); + map->freeblock(&fitem->bl); return 0; } @@ -1201,12 +1198,12 @@ void map_clearflooritem(struct block_list *bl) { struct flooritem_data* fitem = (struct flooritem_data*)bl; if( fitem->cleartimer ) - timer->delete(fitem->cleartimer,iMap->clearflooritem_timer); + timer->delete(fitem->cleartimer,map->clearflooritem_timer); clif->clearflooritem(fitem, 0); - iMap->deliddb(&fitem->bl); - iMap->delblock(&fitem->bl); - iMap->freeblock(&fitem->bl); + map->deliddb(&fitem->bl); + map->delblock(&fitem->bl); + map->freeblock(&fitem->bl); } /*========================================== @@ -1224,10 +1221,10 @@ int map_searchrandfreecell(int16 m,int16 *x,int16 *y,int stack) { for(j=-1;j<=1;j++){ 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)) + if(map->getcell(m,j+*x,i+*y,CELL_CHKNOPASS) && !map->getcell(m,j+*x,i+*y,CELL_CHKICEWALL)) continue; //Avoid item stacking to prevent against exploits. [Skotlex] - if(stack && iMap->count_oncell(m,j+*x,i+*y, BL_ITEM) > stack) + if(stack && map->count_oncell(m,j+*x,i+*y, BL_ITEM) > stack) continue; free_cells[free_cell][0] = j+*x; free_cells[free_cell++][1] = i+*y; @@ -1284,7 +1281,7 @@ int map_search_freecell(struct block_list *src, int16 m, int16 *x,int16 *y, int1 //No range? Return the target cell then.... *x = bx; *y = by; - return iMap->getcell(m,*x,*y,CELL_CHKREACH); + return map->getcell(m,*x,*y,CELL_CHKREACH); } if (rx >= 0 && ry >= 0) { @@ -1302,8 +1299,7 @@ int map_search_freecell(struct block_list *src, int16 m, int16 *x,int16 *y, int1 if (*x == bx && *y == by) continue; //Avoid picking the same target tile. - if (iMap->getcell(m,*x,*y,CELL_CHKREACH)) - { + if (map->getcell(m,*x,*y,CELL_CHKREACH)) { if(flag&2 && !unit->can_reach_pos(src, *x, *y, 1)) continue; if(flag&4) { @@ -1349,7 +1345,7 @@ int map_addflooritem(struct item *item_data,int amount,int16 m,int16 x,int16 y,i fitem->bl.m=m; fitem->bl.x=x; fitem->bl.y=y; - fitem->bl.id = iMap->get_new_object_id(); + fitem->bl.id = map->get_new_object_id(); if(fitem->bl.id==0){ aFree(fitem); return 0; @@ -1366,10 +1362,10 @@ int map_addflooritem(struct item *item_data,int amount,int16 m,int16 x,int16 y,i fitem->item_data.amount=amount; fitem->subx=(r&3)*3+3; fitem->suby=((r>>2)&3)*3+3; - fitem->cleartimer=timer->add(timer->gettick()+battle_config.flooritem_lifetime,iMap->clearflooritem_timer,fitem->bl.id,0); + fitem->cleartimer=timer->add(timer->gettick()+battle_config.flooritem_lifetime,map->clearflooritem_timer,fitem->bl.id,0); - iMap->addiddb(&fitem->bl); - iMap->addblock(&fitem->bl); + map->addiddb(&fitem->bl); + map->addblock(&fitem->bl); clif->dropflooritem(fitem); return fitem->bl.id; @@ -1393,7 +1389,7 @@ void map_addnickdb(int charid, const char* nick) struct charid_request* req; struct map_session_data* sd; - if( iMap->charid2sd(charid) ) + if( map->charid2sd(charid) ) return;// already online p = idb_ensure(nick_db, charid, create_charid2nick); @@ -1402,7 +1398,7 @@ void map_addnickdb(int charid, const char* nick) while( p->requests ) { req = p->requests; p->requests = req->next; - sd = iMap->charid2sd(req->charid); + sd = map->charid2sd(req->charid); if( sd ) clif->solved_charname(sd->fd, charid, p->nick); aFree(req); @@ -1424,7 +1420,7 @@ void map_delnickdb(int charid, const char* name) while( p->requests ) { req = p->requests; p->requests = req->next; - sd = iMap->charid2sd(req->charid); + sd = map->charid2sd(req->charid); if( sd ) clif->solved_charname(sd->fd, charid, name); aFree(req); @@ -1443,7 +1439,7 @@ void map_reqnickdb(struct map_session_data * sd, int charid) nullpo_retv(sd); - tsd = iMap->charid2sd(charid); + tsd = map->charid2sd(charid); if( tsd ) { clif->solved_charname(sd->fd, charid, tsd->status.name); return; @@ -1557,12 +1553,12 @@ int map_quit(struct map_session_data *sd) { npc->script_event(sd, NPCE_LOGOUT); //Unit_free handles clearing the player related data, - //iMap->quit handles extra specific data which is related to quitting normally - //(changing map-servers invokes unit_free but bypasses iMap->quit) + //map->quit handles extra specific data which is related to quitting normally + //(changing map-servers invokes unit_free but bypasses map->quit) if( sd->sc.count ) { //Status that are not saved... for(i=0; i < SC_MAX; i++){ - if ( iStatus->get_sc_type(i)&SC_NO_SAVE ){ + if ( status->get_sc_type(i)&SC_NO_SAVE ) { if ( !sd->sc.data[i] ) continue; switch( i ){ @@ -1611,7 +1607,7 @@ int map_quit(struct map_session_data *sd) { else pt = &sd->status.save_point; - if( (m=iMap->mapindex2mapid(pt->map)) >= 0 ) { + if( (m=map->mapindex2mapid(pt->map)) >= 0 ) { sd->bl.m = m; sd->bl.x = pt->x; sd->bl.y = pt->y; @@ -1634,53 +1630,47 @@ int map_quit(struct map_session_data *sd) { /*========================================== * Lookup, id to session (player,mob,npc,homon,merc..) *------------------------------------------*/ -struct map_session_data * map_id2sd(int id) -{ +struct map_session_data *map_id2sd(int id) { if (id <= 0) return NULL; return (struct map_session_data*)idb_get(pc_db,id); } -struct mob_data * map_id2md(int id) -{ +struct mob_data *map_id2md(int id) { if (id <= 0) return NULL; return (struct mob_data*)idb_get(mobid_db,id); } -struct npc_data * map_id2nd(int id) -{// just a id2bl lookup because there's no npc_db - struct block_list* bl = iMap->id2bl(id); +struct npc_data *map_id2nd(int id) { + // just a id2bl lookup because there's no npc_db + struct block_list* bl = map->id2bl(id); return BL_CAST(BL_NPC, bl); } -struct homun_data* map_id2hd(int id) -{ - struct block_list* bl = iMap->id2bl(id); +struct homun_data *map_id2hd(int id) { + struct block_list* bl = map->id2bl(id); return BL_CAST(BL_HOM, bl); } -struct mercenary_data* map_id2mc(int id) -{ - struct block_list* bl = iMap->id2bl(id); +struct mercenary_data *map_id2mc(int id) { + struct block_list* bl = map->id2bl(id); return BL_CAST(BL_MER, bl); } -struct chat_data* map_id2cd(int id) -{ - struct block_list* bl = iMap->id2bl(id); +struct chat_data *map_id2cd(int id) { + struct block_list* bl = map->id2bl(id); return BL_CAST(BL_CHAT, bl); } /// Returns the nick of the target charid or NULL if unknown (requests the nick to the char server). -const char* map_charid2nick(int charid) -{ +const char *map_charid2nick(int charid) { struct charid2nick *p; struct map_session_data* sd; - sd = iMap->charid2sd(charid); + sd = map->charid2sd(charid); if( sd ) return sd->status.name;// character is online, return it's name @@ -1757,7 +1747,7 @@ struct block_list * map_id2bl(int id) { } /** -* Same as iMap->id2bl except it only checks for its existence +* Same as map->id2bl except it only checks for its existence **/ bool map_blid_exists( int id ) { return (idb_exists(id_db,id)); @@ -2046,7 +2036,7 @@ bool mapit_exists(struct s_mapiterator* iter) { bool map_addnpc(int16 m,struct npc_data *nd) { nullpo_ret(nd); - if( m < 0 || m >= iMap->map_num ) + if( m < 0 || m >= map->map_num ) return false; if( maplist[m].npc_num == MAX_NPC_PER_MAP ) { @@ -2079,7 +2069,7 @@ void map_spawnmobs(int16 m) { int i, k=0; 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); + timer->delete(maplist[m].mob_delete_timer, map->removemobs_timer); maplist[m].mob_delete_timer = INVALID_TIMER; return; } @@ -2126,7 +2116,7 @@ int map_removemobs_timer(int tid, unsigned int tick, int id, intptr_t data) int count; const int16 m = id; - if (m < 0 || m >= iMap->map_num) { //Incorrect map id! + if (m < 0 || m >= map->map_num) { //Incorrect map id! ShowError("map_removemobs_timer error: timer %d points to invalid map %d\n",tid, m); return 0; } @@ -2146,12 +2136,11 @@ int map_removemobs_timer(int tid, unsigned int tick, int id, intptr_t data) return 1; } -void map_removemobs(int16 m) -{ +void map_removemobs(int16 m) { if (maplist[m].mob_delete_timer != INVALID_TIMER) // should never happen return; //Mobs are already scheduled for removal - maplist[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, map->removemobs_timer, m, 0); } /*========================================== @@ -2162,7 +2151,7 @@ int16 map_mapname2mapid(const char* name) { map_index = mapindex_name2id(name); if (!map_index) return -1; - return iMap->mapindex2mapid(map_index); + return map->mapindex2mapid(map_index); } /*========================================== @@ -2276,9 +2265,8 @@ int map_random_dir(struct block_list *bl, int16 *x, int16 *y) xi = bl->x + segment*dirx[j]; segment = (short)sqrt((float)(dist2 - segment*segment)); //The complement of the previously picked segment yi = bl->y + segment*diry[j]; - } while ( - (iMap->getcell(bl->m,xi,yi,CELL_CHKNOPASS) || !path->search(NULL,bl->m,bl->x,bl->y,xi,yi,1,CELL_CHKNOREACH)) - && (++i)<100 ); + } while ( (map->getcell(bl->m,xi,yi,CELL_CHKNOPASS) || !path->search(NULL,bl->m,bl->x,bl->y,xi,yi,1,CELL_CHKNOREACH)) + && (++i)<100 ); if (i < 100) { *x = xi; @@ -2351,7 +2339,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 : maplist[m].getcellp(&maplist[m],x,y,cellchk); + return (m < 0 || m >= map->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) { @@ -2426,7 +2414,7 @@ int map_getcellp(struct map_data* m,int16 x,int16 y,cell_chk cellchk) { /* [Ind/Hercules] */ int map_sub_getcellp(struct map_data* m,int16 x,int16 y,cell_chk cellchk) { - iMap->cellfromcache(m); + map->cellfromcache(m); m->getcellp = map_getcellp; m->setcell = map_setcell; return m->getcellp(m,x,y,cellchk); @@ -2439,7 +2427,7 @@ 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 >= maplist[m].xs || y < 0 || y >= maplist[m].ys ) + if( m < 0 || m >= map->map_num || x < 0 || x >= maplist[m].xs || y < 0 || y >= maplist[m].ys ) return; j = x + y*maplist[m].xs; @@ -2462,10 +2450,10 @@ void map_setcell(int16 m, int16 x, int16 y, cell_t cell, bool flag) { } } 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 >= maplist[m].xs || y < 0 || y >= maplist[m].ys ) + if( m < 0 || m >= map->map_num || x < 0 || x >= maplist[m].xs || y < 0 || y >= maplist[m].ys ) return; - iMap->cellfromcache(&maplist[m]); + map->cellfromcache(&maplist[m]); maplist[m].setcell = map_setcell; maplist[m].getcellp = map_getcellp; maplist[m].setcell(m,x,y,cell,flag); @@ -2474,7 +2462,7 @@ 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 >= maplist[m].xs || y < 0 || y >= maplist[m].ys ) + if( m < 0 || m >= map->map_num || x < 0 || x >= maplist[m].xs || y < 0 || y >= maplist[m].ys ) return; j = x + y*maplist[m].xs; @@ -2519,7 +2507,7 @@ bool map_iwall_set(int16 m, int16 x, int16 y, int size, int8 dir, bool shootable if( (iwall = (struct iwall_data *)strdb_get(iwall_db, wall_name)) != NULL ) return false; // Already Exists - if( iMap->getcell(m, x, y, CELL_CHKNOREACH) ) + if( map->getcell(m, x, y, CELL_CHKNOREACH) ) return false; // Starting cell problem CREATE(iwall, struct iwall_data, 1); @@ -2534,13 +2522,13 @@ bool map_iwall_set(int16 m, int16 x, int16 y, int size, int8 dir, bool shootable for( i = 0; i < size; i++ ) { map_iwall_nextxy(x, y, dir, i, &x1, &y1); - if( iMap->getcell(m, x1, y1, CELL_CHKNOREACH) ) + if( map->getcell(m, x1, y1, CELL_CHKNOREACH) ) break; // Collision 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); + clif->changemapcell(0, m, x1, y1, map->getcell(m, x1, y1, CELL_GETTYPE), ALL_SAMEMAP); } iwall->size = i; @@ -2567,7 +2555,7 @@ void map_iwall_get(struct map_session_data *sd) { for( i = 0; i < iwall->size; i++ ) { map_iwall_nextxy(iwall->x, iwall->y, iwall->dir, i, &x1, &y1); - clif->changemapcell(sd->fd, iwall->m, x1, y1, iMap->getcell(iwall->m, x1, y1, CELL_GETTYPE), SELF); + clif->changemapcell(sd->fd, iwall->m, x1, y1, map->getcell(iwall->m, x1, y1, CELL_GETTYPE), SELF); } } dbi_destroy(iter); @@ -2587,7 +2575,7 @@ void map_iwall_remove(const char *wall_name) 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); + clif->changemapcell(0, iwall->m, x1, y1, map->getcell(iwall->m, x1, y1, CELL_GETTYPE), ALL_SAMEMAP); } maplist[iwall->m].iwall_num--; @@ -2742,15 +2730,15 @@ int map_readfromcache(struct map_data *m, char *buffer) { int map_addmap(char* mapname) { - maplist[iMap->map_num].instance_id = -1; - mapindex_getmapname(mapname, maplist[iMap->map_num++].name); + maplist[map->map_num].instance_id = -1; + mapindex_getmapname(mapname, maplist[map->map_num++].name); return 0; } static void map_delmapid(int id) { 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--; + memmove(maplist+id, maplist+id+1, sizeof(maplist[0])*(map->map_num-id-1)); + map->map_num--; } int map_delmap(char* mapname) { @@ -2758,12 +2746,12 @@ int map_delmap(char* mapname) { char map_name[MAP_NAME_LENGTH]; if (strcmpi(mapname, "all") == 0) { - iMap->map_num = 0; + map->map_num = 0; return 0; } mapindex_getmapname(mapname, map_name); - for(i = 0; i < iMap->map_num; i++) { + for(i = 0; i < map->map_num; i++) { if (strcmp(maplist[i].name, map_name) == 0) { map_delmapid(i); return 1; @@ -2845,7 +2833,7 @@ void map_clean(int i) { if(battle_config.dynamic_mobs) { //Dynamic mobs flag by [random] int j; if(maplist[i].mob_delete_timer != INVALID_TIMER) - timer->delete(maplist[i].mob_delete_timer, iMap->removemobs_timer); + timer->delete(maplist[i].mob_delete_timer, map->removemobs_timer); for (j=0; j<MAX_MOB_LIST_PER_MAP; j++) if (maplist[i].moblist[j]) aFree(maplist[i].moblist[j]); } @@ -2889,7 +2877,7 @@ void map_clean(int i) { void do_final_maps(void) { int i, v = 0; - for( i = 0; i < iMap->map_num; i++ ) { + for( i = 0; i < map->map_num; i++ ) { if(maplist[i].cell && maplist[i].cell != (struct mapcell *)0xdeadbeaf ) aFree(maplist[i].cell); if(maplist[i].block) aFree(maplist[i].block); @@ -2898,7 +2886,7 @@ void do_final_maps(void) { if(battle_config.dynamic_mobs) { //Dynamic mobs flag by [random] int j; if(maplist[i].mob_delete_timer != INVALID_TIMER) - timer->delete(maplist[i].mob_delete_timer, iMap->removemobs_timer); + timer->delete(maplist[i].mob_delete_timer, map->removemobs_timer); for (j=0; j<MAX_MOB_LIST_PER_MAP; j++) if (maplist[i].moblist[j]) aFree(maplist[i].moblist[j]); } @@ -2953,7 +2941,7 @@ void do_final_maps(void) { void map_flags_init(void) { int i, v = 0; - for( i = 0; i < iMap->map_num; i++ ) { + for( i = 0; i < map->map_num; i++ ) { // mapflags memset(&maplist[i].flag, 0, sizeof(maplist[i].flag)); @@ -3109,7 +3097,7 @@ int map_readallmaps (void) { ShowStatus("Loading maps (using GRF files)...\n"); else { char mapcachefilepath[254]; - sprintf(mapcachefilepath,"%s/%s%s",iMap->db_path,DBPATH,"map_cache.dat"); + sprintf(mapcachefilepath,"%s/%s%s",map->db_path,DBPATH,"map_cache.dat"); ShowStatus("Loading maps (using %s as map cache)...\n", mapcachefilepath); if( (fp = fopen(mapcachefilepath, "rb")) == NULL ) { ShowFatalError("Unable to open map cache file "CL_WHITE"%s"CL_RESET"\n", mapcachefilepath); @@ -3124,12 +3112,12 @@ int map_readallmaps (void) { } } - for(i = 0; i < iMap->map_num; i++) { + for(i = 0; i < map->map_num; i++) { size_t size; // show progress if(enable_grf) - ShowStatus("Loading maps [%i/%i]: %s"CL_CLL"\r", i, iMap->map_num, maplist[i].name); + ShowStatus("Loading maps [%i/%i]: %s"CL_CLL"\r", i, map->map_num, maplist[i].name); // try to load the map if( ! @@ -3158,7 +3146,7 @@ int map_readallmaps (void) { } maplist[i].m = i; - iMap->addmap2db(&maplist[i]); + map->addmap2db(&maplist[i]); memset(maplist[i].moblist, 0, sizeof(maplist[i].moblist)); //Initialize moblist [Skotlex] maplist[i].mob_delete_timer = INVALID_TIMER; //Initialize timer [Skotlex] @@ -3175,15 +3163,15 @@ int map_readallmaps (void) { } // intialization and configuration-dependent adjustments of mapflags - iMap->flags_init(); + map->flags_init(); if( !enable_grf ) { fclose(fp); } // finished map loading - ShowInfo("Successfully loaded '"CL_WHITE"%d"CL_RESET"' maps."CL_CLL"\n",iMap->map_num); - instance->start_id = iMap->map_num; // Next Map Index will be instances + ShowInfo("Successfully loaded '"CL_WHITE"%d"CL_RESET"' maps."CL_CLL"\n",map->map_num); + instance->start_id = map->map_num; // Next Map Index will be instances if (maps_removed) ShowNotice("Maps removed: '"CL_WHITE"%d"CL_RESET"'\n",maps_removed); @@ -3248,35 +3236,35 @@ int map_config_read(char *cfgName) { clif->setport(atoi(w2)); map_port = (atoi(w2)); } else if (strcmpi(w1, "map") == 0) - iMap->map_num++; + map->map_num++; else if (strcmpi(w1, "delmap") == 0) - iMap->map_num--; + map->map_num--; else if (strcmpi(w1, "npc") == 0) npc->addsrcfile(w2); else if (strcmpi(w1, "delnpc") == 0) npc->delsrcfile(w2); else if (strcmpi(w1, "autosave_time") == 0) { - iMap->autosave_interval = atoi(w2); - if (iMap->autosave_interval < 1) //Revert to default saving. - iMap->autosave_interval = DEFAULT_AUTOSAVE_INTERVAL; + map->autosave_interval = atoi(w2); + if (map->autosave_interval < 1) //Revert to default saving. + map->autosave_interval = DEFAULT_AUTOSAVE_INTERVAL; else - iMap->autosave_interval *= 1000; //Pass from sec to ms + map->autosave_interval *= 1000; //Pass from sec to ms } else if (strcmpi(w1, "minsave_time") == 0) { - iMap->minsave_interval= atoi(w2); - if (iMap->minsave_interval < 1) - iMap->minsave_interval = 1; + map->minsave_interval= atoi(w2); + if (map->minsave_interval < 1) + map->minsave_interval = 1; } else if (strcmpi(w1, "save_settings") == 0) - iMap->save_settings = atoi(w2); + map->save_settings = atoi(w2); else if (strcmpi(w1, "help_txt") == 0) - strcpy(iMap->help_txt, w2); + strcpy(map->help_txt, w2); else if (strcmpi(w1, "help2_txt") == 0) - strcpy(iMap->help2_txt, w2); + strcpy(map->help2_txt, w2); else if (strcmpi(w1, "charhelp_txt") == 0) - strcpy(iMap->charhelp_txt, w2); + strcpy(map->charhelp_txt, w2); else if(strcmpi(w1,"db_path") == 0) - safestrncpy(iMap->db_path,w2,255); + safestrncpy(map->db_path,w2,255); else if (strcmpi(w1, "enable_spy") == 0) - iMap->enable_spy = config_switch(w2); + map->enable_spy = config_switch(w2); else if (strcmpi(w1, "use_grf") == 0) enable_grf = config_switch(w2); else if (strcmpi(w1, "console_msg_log") == 0) @@ -3319,7 +3307,7 @@ int map_config_read_sub(char *cfgName) { if (strcmpi(w1, "map") == 0) map_addmap(w2); else if (strcmpi(w1, "delmap") == 0) - iMap->delmap(w2); + map->delmap(w2); else if (strcmpi(w1, "import") == 0) map_config_read_sub(w2); } @@ -3395,21 +3383,21 @@ int inter_config_read(char *cfgName) { continue; /* table names */ if(strcmpi(w1,"item_db_db")==0) - strcpy(iMap->item_db_db,w2); + strcpy(map->item_db_db,w2); else if(strcmpi(w1,"mob_db_db")==0) - strcpy(iMap->mob_db_db,w2); + strcpy(map->mob_db_db,w2); else if(strcmpi(w1,"item_db2_db")==0) - strcpy(iMap->item_db2_db,w2); + strcpy(map->item_db2_db,w2); else if(strcmpi(w1,"item_db_re_db")==0) - strcpy(iMap->item_db_re_db,w2); + strcpy(map->item_db_re_db,w2); else if(strcmpi(w1,"mob_db2_db")==0) - strcpy(iMap->mob_db2_db,w2); + strcpy(map->mob_db2_db,w2); else if(strcmpi(w1,"mob_skill_db_db")==0) - strcpy(iMap->mob_skill_db_db,w2); + strcpy(map->mob_skill_db_db,w2); else if(strcmpi(w1,"mob_skill_db2_db")==0) - strcpy(iMap->mob_skill_db2_db,w2); + strcpy(map->mob_skill_db2_db,w2); else if(strcmpi(w1,"interreg_db")==0) - strcpy(iMap->interreg_db,w2); + strcpy(map->interreg_db,w2); /* map sql stuff */ else if(strcmpi(w1,"map_server_ip")==0) strcpy(map_server_ip, w2); @@ -3424,15 +3412,15 @@ int inter_config_read(char *cfgName) { else if(strcmpi(w1,"default_codepage")==0) strcpy(default_codepage, w2); else if(strcmpi(w1,"use_sql_item_db")==0) { - iMap->db_use_sql_item_db = config_switch(w2); + map->db_use_sql_item_db = config_switch(w2); ShowStatus ("Using item database as SQL: '%s'\n", w2); } else if(strcmpi(w1,"use_sql_mob_db")==0) { - iMap->db_use_sql_mob_db = config_switch(w2); + map->db_use_sql_mob_db = config_switch(w2); ShowStatus ("Using monster database as SQL: '%s'\n", w2); } else if(strcmpi(w1,"use_sql_mob_skill_db")==0) { - iMap->db_use_sql_mob_skill_db = config_switch(w2); + map->db_use_sql_mob_skill_db = config_switch(w2); ShowStatus ("Using monster skill database as SQL: '%s'\n", w2); } /* sql log db */ @@ -3512,17 +3500,17 @@ void map_zone_change2(int m, struct map_zone_data *zone) { maplist[m].prev_zone = maplist[m].zone; if( maplist[m].zone_mf_count ) - iMap->zone_remove(m); + map->zone_remove(m); - iMap->zone_apply(m,zone,empty,empty,empty); + map->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) { maplist[m].prev_zone = maplist[m].zone; if( maplist[m].zone_mf_count ) - iMap->zone_remove(m); - iMap->zone_apply(m,zone,start,buffer,filepath); + map->zone_remove(m); + map->zone_apply(m,zone,start,buffer,filepath); } /* removes previous mapflags from this map */ void map_zone_remove(int m) { @@ -4289,7 +4277,7 @@ void map_zone_init(void) { } } - for(j = 0; j < iMap->map_num; j++) { + for(j = 0; j < map->map_num; j++) { if( maplist[j].zone == zone ) { if( map_zone_mf_cache(j,flag,params) ) break; @@ -4311,7 +4299,7 @@ void map_zone_init(void) { break; } } - for(j = 0; j < iMap->map_num; j++) { + for(j = 0; j < map->map_num; j++) { if( maplist[j].zone == zone ) { if( map_zone_mf_cache(j,flag,params) ) break; @@ -4348,7 +4336,7 @@ unsigned short map_zone_str2skillid(const char *name) { if( !skill->get_index((nameid = atoi(name+2))) ) return 0; } else { - if( !( nameid = strdb_iget(skilldb_name2id, name) ) ) { + if( !( nameid = strdb_iget(skill->name2id_db, name) ) ) { return 0; } } @@ -4844,7 +4832,7 @@ int cleanup_sub(struct block_list *bl, va_list ap) { switch(bl->type) { case BL_PC: - iMap->quit((struct map_session_data *) bl); + map->quit((struct map_session_data *) bl); break; case BL_NPC: npc->unload((struct npc_data *)bl,false); @@ -4856,7 +4844,7 @@ int cleanup_sub(struct block_list *bl, va_list ap) { //There is no need for this, the pet is removed together with the player. [Skotlex] break; case BL_ITEM: - iMap->clearflooritem(bl); + map->clearflooritem(bl); break; case BL_SKILL: skill->delunit((struct skill_unit *) bl); @@ -4869,9 +4857,8 @@ int cleanup_sub(struct block_list *bl, va_list ap) { /** * @see DBApply */ -static int cleanup_db_sub(DBKey key, DBData *data, va_list va) -{ - return iMap->cleanup_sub(DB->data2ptr(data), va); +static int cleanup_db_sub(DBKey key, DBData *data, va_list va) { + return map->cleanup_sub(DB->data2ptr(data), va); } /*========================================== @@ -4891,19 +4878,19 @@ void do_final(void) //Ladies and babies first. iter = mapit_getallusers(); for( sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); sd = (TBL_PC*)mapit->next(iter) ) - iMap->quit(sd); + map->quit(sd); mapit->free(iter); /* prepares npcs for a faster shutdown process */ npc->do_clear_npc(); // 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, maplist[i].name); + for (i = 0; i < map->map_num; i++) { + ShowStatus("Cleaning up maps [%d/%d]: %s..."CL_CLL"\r", i+1, map->map_num, maplist[i].name); if (maplist[i].m >= 0) - map_foreachinmap(iMap->cleanup_sub, i, BL_ALL); + map_foreachinmap(map->cleanup_sub, i, BL_ALL); } - ShowStatus("Cleaned up %d maps."CL_CLL"\n", iMap->map_num); + ShowStatus("Cleaned up %d maps."CL_CLL"\n", map->map_num); id_db->foreach(id_db,cleanup_db_sub); chrif->char_reset_offline(); @@ -4911,7 +4898,7 @@ void do_final(void) atcommand->final(); battle->final(); - chrif->do_final_chrif(); + chrif->final(); ircbot->final();/* before clif. */ clif->final(); npc->final(); @@ -4927,11 +4914,11 @@ void do_final(void) homun->final(); atcommand->final_msg(); skill->final(); - iStatus->do_final_status(); + status->final(); unit->final(); bg->final(); duel->final(); - elemental->do_final_elemental(); + elemental->final(); do_final_maps(); vending->final(); @@ -4988,7 +4975,7 @@ void do_abort(void) return; } ShowError("Server received crash signal! Attempting to save all online characters!\n"); - iMap->map_foreachpc(map_abort_sub); + map->map_foreachpc(map_abort_sub); chrif->flush_fifo(); } @@ -5072,7 +5059,7 @@ CPCMD(gm_position) { return; } - if ( (m = iMap->mapname2mapid(map_name) <= 0 ) ) { + if ( (m = map->mapname2mapid(map_name) <= 0 ) ) { ShowError("gm:info '"CL_WHITE"%s"CL_RESET"' is not a known map\n",map_name); return; } @@ -5109,7 +5096,7 @@ void map_cp_defaults(void) { strcpy(cpsd->status.name, "Hercules Console"); cpsd->bl.x = MAP_DEFAULT_X; cpsd->bl.y = MAP_DEFAULT_Y; - cpsd->bl.m = iMap->mapname2mapid(MAP_DEFAULT); + cpsd->bl.m = map->mapname2mapid(MAP_DEFAULT); console->addCommand("gm:info",CPCMD_A(gm_position)); console->addCommand("gm:use",CPCMD_A(gm_use)); @@ -5127,7 +5114,7 @@ void map_hp_symbols(void) { HPM->share(guild,"guild"); HPM->share(gstorage,"gstorage"); HPM->share(homun,"homun"); - HPM->share(iMap,"iMap"); + HPM->share(map,"map"); HPM->share(ircbot,"ircbot"); HPM->share(itemdb,"itemdb"); HPM->share(logs,"logs"); @@ -5140,7 +5127,7 @@ void map_hp_symbols(void) { HPM->share(party,"party"); HPM->share(storage,"storage"); HPM->share(trade,"trade"); - HPM->share(iStatus,"iStatus"); + HPM->share(status,"status"); HPM->share(chat, "chat"); HPM->share(duel,"duel"); HPM->share(elemental,"elemental"); @@ -5220,44 +5207,44 @@ int do_init(int argc, char *argv[]) map_defaults(); - iMap->map_num = 0; - - sprintf(iMap->db_path ,"db"); - sprintf(iMap->help_txt ,"conf/help.txt"); - sprintf(iMap->help2_txt ,"conf/help2.txt"); - sprintf(iMap->charhelp_txt ,"conf/charhelp.txt"); - - sprintf(iMap->wisp_server_name ,"Server"); // can be modified in char-server configuration file - - iMap->autosave_interval = DEFAULT_AUTOSAVE_INTERVAL; - iMap->minsave_interval = 100; - iMap->save_settings = 0xFFFF; - iMap->agit_flag = 0; - iMap->agit2_flag = 0; - iMap->night_flag = 0; // 0=day, 1=night [Yor] - iMap->enable_spy = 0; //To enable/disable @spy commands, which consume too much cpu time when sending packets. [Skotlex] - - iMap->db_use_sql_item_db = 0; - iMap->db_use_sql_mob_db = 0; - iMap->db_use_sql_mob_skill_db = 0; - - sprintf(iMap->item_db_db, "item_db"); - sprintf(iMap->item_db2_db, "item_db2"); - sprintf(iMap->item_db_re_db, "item_db_re"); - sprintf(iMap->mob_db_db, "mob_db"); - sprintf(iMap->mob_db2_db, "mob_db2"); - sprintf(iMap->mob_skill_db_db, "mob_skill_db"); - sprintf(iMap->mob_skill_db2_db, "mob_skill_db2"); - sprintf(iMap->interreg_db, "interreg"); - - iMap->INTER_CONF_NAME="conf/inter-server.conf"; - iMap->LOG_CONF_NAME="conf/logs.conf"; - iMap->MAP_CONF_NAME = "conf/map-server.conf"; - iMap->BATTLE_CONF_FILENAME = "conf/battle.conf"; - iMap->ATCOMMAND_CONF_FILENAME = "conf/atcommand.conf"; - iMap->SCRIPT_CONF_NAME = "conf/script.conf"; - iMap->MSG_CONF_NAME = "conf/messages.conf"; - iMap->GRF_PATH_FILENAME = "conf/grf-files.txt"; + map->map_num = 0; + + sprintf(map->db_path ,"db"); + sprintf(map->help_txt ,"conf/help.txt"); + sprintf(map->help2_txt ,"conf/help2.txt"); + sprintf(map->charhelp_txt ,"conf/charhelp.txt"); + + sprintf(map->wisp_server_name ,"Server"); // can be modified in char-server configuration file + + map->autosave_interval = DEFAULT_AUTOSAVE_INTERVAL; + map->minsave_interval = 100; + map->save_settings = 0xFFFF; + map->agit_flag = 0; + map->agit2_flag = 0; + map->night_flag = 0; // 0=day, 1=night [Yor] + map->enable_spy = 0; //To enable/disable @spy commands, which consume too much cpu time when sending packets. [Skotlex] + + map->db_use_sql_item_db = 0; + map->db_use_sql_mob_db = 0; + map->db_use_sql_mob_skill_db = 0; + + sprintf(map->item_db_db, "item_db"); + sprintf(map->item_db2_db, "item_db2"); + sprintf(map->item_db_re_db, "item_db_re"); + sprintf(map->mob_db_db, "mob_db"); + sprintf(map->mob_db2_db, "mob_db2"); + sprintf(map->mob_skill_db_db, "mob_skill_db"); + sprintf(map->mob_skill_db2_db, "mob_skill_db2"); + sprintf(map->interreg_db, "interreg"); + + map->INTER_CONF_NAME="conf/inter-server.conf"; + map->LOG_CONF_NAME="conf/logs.conf"; + map->MAP_CONF_NAME = "conf/map-server.conf"; + map->BATTLE_CONF_FILENAME = "conf/battle.conf"; + map->ATCOMMAND_CONF_FILENAME = "conf/atcommand.conf"; + map->SCRIPT_CONF_NAME = "conf/script.conf"; + map->MSG_CONF_NAME = "conf/messages.conf"; + map->GRF_PATH_FILENAME = "conf/grf-files.txt"; rnd_init(); for( i = 1; i < argc ; i++ ) { @@ -5275,28 +5262,28 @@ int do_init(int argc, char *argv[]) map_versionscreen(true); } else if( strcmp(arg, "map-config") == 0 ) { if( map_arg_next_value(arg, i, argc) ) - iMap->MAP_CONF_NAME = argv[++i]; + map->MAP_CONF_NAME = argv[++i]; } else if( strcmp(arg, "battle-config") == 0 ) { if( map_arg_next_value(arg, i, argc) ) - iMap->BATTLE_CONF_FILENAME = argv[++i]; + map->BATTLE_CONF_FILENAME = argv[++i]; } else if( strcmp(arg, "atcommand-config") == 0 ) { if( map_arg_next_value(arg, i, argc) ) - iMap->ATCOMMAND_CONF_FILENAME = argv[++i]; + map->ATCOMMAND_CONF_FILENAME = argv[++i]; } else if( strcmp(arg, "script-config") == 0 ) { if( map_arg_next_value(arg, i, argc) ) - iMap->SCRIPT_CONF_NAME = argv[++i]; + map->SCRIPT_CONF_NAME = argv[++i]; } else if( strcmp(arg, "msg-config") == 0 ) { if( map_arg_next_value(arg, i, argc) ) - iMap->MSG_CONF_NAME = argv[++i]; + map->MSG_CONF_NAME = argv[++i]; } else if( strcmp(arg, "grf-path-file") == 0 ) { if( map_arg_next_value(arg, i, argc) ) - iMap->GRF_PATH_FILENAME = argv[++i]; + map->GRF_PATH_FILENAME = argv[++i]; } else if( strcmp(arg, "inter-config") == 0 ) { if( map_arg_next_value(arg, i, argc) ) - iMap->INTER_CONF_NAME = argv[++i]; + map->INTER_CONF_NAME = argv[++i]; } else if( strcmp(arg, "log-config") == 0 ) { if( map_arg_next_value(arg, i, argc) ) - iMap->LOG_CONF_NAME = argv[++i]; + map->LOG_CONF_NAME = argv[++i]; } else if( strcmp(arg, "run-once") == 0 ) { // close the map-server as soon as its done.. for testing [Celest] runflag = CORE_ST_STOP; } else { @@ -5319,12 +5306,12 @@ int do_init(int argc, char *argv[]) memset(&index2mapid, -1, sizeof(index2mapid)); map_load_defaults(); - map_config_read(iMap->MAP_CONF_NAME); - CREATE(maplist,struct map_data,iMap->map_num); - iMap->map_num = 0; - map_config_read_sub(iMap->MAP_CONF_NAME); + map_config_read(map->MAP_CONF_NAME); + CREATE(maplist,struct map_data,map->map_num); + map->map_num = 0; + map_config_read_sub(map->MAP_CONF_NAME); // loads npcs - iMap->reloadnpc(false); + map->reloadnpc(false); chrif->checkdefaultlogin(); @@ -5347,14 +5334,14 @@ int do_init(int argc, char *argv[]) chrif->setip(ip_str); } - battle->config_read(iMap->BATTLE_CONF_FILENAME); - atcommand->msg_read(iMap->MSG_CONF_NAME); - script->config_read(iMap->SCRIPT_CONF_NAME); - inter_config_read(iMap->INTER_CONF_NAME); - logs->config_read(iMap->LOG_CONF_NAME); + battle->config_read(map->BATTLE_CONF_FILENAME); + atcommand->msg_read(map->MSG_CONF_NAME); + script->config_read(map->SCRIPT_CONF_NAME); + inter_config_read(map->INTER_CONF_NAME); + logs->config_read(map->LOG_CONF_NAME); id_db = idb_alloc(DB_OPT_BASE); - pc_db = idb_alloc(DB_OPT_BASE); //Added for reliable iMap->id2sd() use. [Skotlex] + pc_db = idb_alloc(DB_OPT_BASE); //Added for reliable map->id2sd() use. [Skotlex] mobid_db = idb_alloc(DB_OPT_BASE); //Added to lower the load of the lazy mob ai. [Skotlex] bossid_db = idb_alloc(DB_OPT_BASE); // Used for Convex Mirror quick MVP search map_db = uidb_alloc(DB_OPT_BASE); @@ -5373,7 +5360,7 @@ int do_init(int argc, char *argv[]) mapindex_init(); if(enable_grf) - grfio_init(iMap->GRF_PATH_FILENAME); + grfio_init(map->GRF_PATH_FILENAME); map_readallmaps(); @@ -5390,7 +5377,7 @@ int do_init(int argc, char *argv[]) atcommand->init(); battle->init(); instance->init(); - chrif->do_init_chrif(); + chrif->init(); clif->init(); ircbot->init(); script->init(); @@ -5399,14 +5386,14 @@ int do_init(int argc, char *argv[]) read_map_zone_db();/* read after item and skill initalization */ mob->init(); pc->do_init_pc(); - iStatus->do_init_status(); + status->init(); party->do_init_party(); guild->init(); storage->init(); pet->init(); homun->init(); mercenary->init(); - elemental->do_init_elemental(); + elemental->init(); quest->init(); npc->init(); unit->init(); @@ -5428,7 +5415,7 @@ int do_init(int argc, char *argv[]) ShowStatus("Server is '"CL_GREEN"ready"CL_RESET"' and listening on port '"CL_WHITE"%d"CL_RESET"'.\n\n", map_port); if( runflag != CORE_ST_STOP ) { - shutdown_callback = iMap->do_shutdown; + shutdown_callback = map->do_shutdown; runflag = MAPSERVER_ST_RUNNING; } @@ -5445,114 +5432,114 @@ int do_init(int argc, char *argv[]) * created by Susu *-------------------------------------*/ void map_defaults(void) { - iMap = &iMap_s; + map = &map_s; /* funcs */ - iMap->zone_init = map_zone_init; - iMap->zone_remove = map_zone_remove; - iMap->zone_apply = map_zone_apply; - iMap->zone_change = map_zone_change; - iMap->zone_change2 = map_zone_change2; + map->zone_init = map_zone_init; + map->zone_remove = map_zone_remove; + map->zone_apply = map_zone_apply; + map->zone_change = map_zone_change; + map->zone_change2 = map_zone_change2; - iMap->getcell = map_getcell; - iMap->setgatcell = map_setgatcell; + map->getcell = map_getcell; + map->setgatcell = map_setgatcell; - iMap->cellfromcache = map_cellfromcache; + map->cellfromcache = map_cellfromcache; // users - iMap->setusers = map_setusers; - iMap->getusers = map_getusers; - iMap->usercount = map_usercount; + map->setusers = map_setusers; + map->getusers = map_getusers; + map->usercount = map_usercount; // blocklist lock - iMap->freeblock = map_freeblock; - iMap->freeblock_lock = map_freeblock_lock; - iMap->freeblock_unlock = map_freeblock_unlock; + map->freeblock = map_freeblock; + map->freeblock_lock = map_freeblock_lock; + map->freeblock_unlock = map_freeblock_unlock; // blocklist manipulation - iMap->addblock = map_addblock; - iMap->delblock = map_delblock; - iMap->moveblock = map_moveblock; + map->addblock = map_addblock; + map->delblock = map_delblock; + map->moveblock = map_moveblock; //blocklist nb in one cell - iMap->count_oncell = map_count_oncell; - iMap->find_skill_unit_oncell = map_find_skill_unit_oncell; + map->count_oncell = map_count_oncell; + map->find_skill_unit_oncell = map_find_skill_unit_oncell; // search and creation - iMap->get_new_object_id = map_get_new_object_id; - iMap->search_freecell = map_search_freecell; + map->get_new_object_id = map_get_new_object_id; + map->search_freecell = map_search_freecell; // - iMap->quit = map_quit; + map->quit = map_quit; // npc - iMap->addnpc = map_addnpc; + map->addnpc = map_addnpc; // map item - iMap->clearflooritem_timer = map_clearflooritem_timer; - iMap->removemobs_timer = map_removemobs_timer; - iMap->clearflooritem = map_clearflooritem; - iMap->addflooritem = map_addflooritem; + map->clearflooritem_timer = map_clearflooritem_timer; + map->removemobs_timer = map_removemobs_timer; + map->clearflooritem = map_clearflooritem; + map->addflooritem = map_addflooritem; // player to map session - iMap->addnickdb = map_addnickdb; - iMap->delnickdb = map_delnickdb; - iMap->reqnickdb = map_reqnickdb; - iMap->charid2nick = map_charid2nick; - iMap->charid2sd = map_charid2sd; - - iMap->map_foreachpc = map_map_foreachpc; - iMap->map_foreachmob = map_map_foreachmob; - iMap->map_foreachnpc = map_map_foreachnpc; - iMap->map_foreachregen = map_map_foreachregen; - iMap->map_foreachiddb = map_map_foreachiddb; - - iMap->foreachinrange = map_foreachinrange; - iMap->foreachinshootrange = map_foreachinshootrange; - iMap->foreachinarea = map_foreachinarea; - iMap->forcountinrange = map_forcountinrange; - iMap->forcountinarea = map_forcountinarea; - iMap->foreachinmovearea = map_foreachinmovearea; - iMap->foreachincell = map_foreachincell; - iMap->foreachinpath = map_foreachinpath; - iMap->foreachinmap = map_foreachinmap; - iMap->foreachininstance = map_foreachininstance; - - iMap->id2sd = map_id2sd; - iMap->id2md = map_id2md; - iMap->id2nd = map_id2nd; - iMap->id2hd = map_id2hd; - iMap->id2mc = map_id2mc; - iMap->id2cd = map_id2cd; - iMap->id2bl = map_id2bl; - iMap->blid_exists = map_blid_exists; - iMap->mapindex2mapid = map_mapindex2mapid; - iMap->mapname2mapid = map_mapname2mapid; - iMap->mapname2ipport = map_mapname2ipport; - iMap->setipport = map_setipport; - iMap->eraseipport = map_eraseipport; - iMap->eraseallipport = map_eraseallipport; - iMap->addiddb = map_addiddb; - iMap->deliddb = map_deliddb; + map->addnickdb = map_addnickdb; + map->delnickdb = map_delnickdb; + map->reqnickdb = map_reqnickdb; + map->charid2nick = map_charid2nick; + map->charid2sd = map_charid2sd; + + map->map_foreachpc = map_map_foreachpc; + map->map_foreachmob = map_map_foreachmob; + map->map_foreachnpc = map_map_foreachnpc; + map->map_foreachregen = map_map_foreachregen; + map->map_foreachiddb = map_map_foreachiddb; + + map->foreachinrange = map_foreachinrange; + map->foreachinshootrange = map_foreachinshootrange; + map->foreachinarea = map_foreachinarea; + map->forcountinrange = map_forcountinrange; + map->forcountinarea = map_forcountinarea; + map->foreachinmovearea = map_foreachinmovearea; + map->foreachincell = map_foreachincell; + map->foreachinpath = map_foreachinpath; + map->foreachinmap = map_foreachinmap; + map->foreachininstance = map_foreachininstance; + + map->id2sd = map_id2sd; + map->id2md = map_id2md; + map->id2nd = map_id2nd; + map->id2hd = map_id2hd; + map->id2mc = map_id2mc; + map->id2cd = map_id2cd; + map->id2bl = map_id2bl; + map->blid_exists = map_blid_exists; + map->mapindex2mapid = map_mapindex2mapid; + map->mapname2mapid = map_mapname2mapid; + map->mapname2ipport = map_mapname2ipport; + map->setipport = map_setipport; + map->eraseipport = map_eraseipport; + map->eraseallipport = map_eraseallipport; + map->addiddb = map_addiddb; + map->deliddb = map_deliddb; /* */ - iMap->nick2sd = map_nick2sd; - iMap->getmob_boss = map_getmob_boss; - iMap->id2boss = map_id2boss; + map->nick2sd = map_nick2sd; + map->getmob_boss = map_getmob_boss; + map->id2boss = map_id2boss; // reload config file looking only for npcs - iMap->reloadnpc = map_reloadnpc; + map->reloadnpc = map_reloadnpc; - iMap->check_dir = map_check_dir; - iMap->calc_dir = map_calc_dir; - iMap->random_dir = map_random_dir; // [Skotlex] + map->check_dir = map_check_dir; + map->calc_dir = map_calc_dir; + map->random_dir = map_random_dir; // [Skotlex] - iMap->cleanup_sub = cleanup_sub; + map->cleanup_sub = cleanup_sub; - iMap->delmap = map_delmap; - iMap->flags_init = map_flags_init; + map->delmap = map_delmap; + map->flags_init = map_flags_init; - iMap->iwall_set = map_iwall_set; - iMap->iwall_get = map_iwall_get; - iMap->iwall_remove = map_iwall_remove; + map->iwall_set = map_iwall_set; + map->iwall_get = map_iwall_get; + map->iwall_remove = map_iwall_remove; - iMap->addmobtolist = map_addmobtolist; // [Wizputer] - iMap->spawnmobs = map_spawnmobs; // [Wizputer] - iMap->removemobs = map_removemobs; // [Wizputer] - iMap->addmap2db = map_addmap2db; - iMap->removemapdb = map_removemapdb; - iMap->clean = map_clean; + map->addmobtolist = map_addmobtolist; // [Wizputer] + map->spawnmobs = map_spawnmobs; // [Wizputer] + map->removemobs = map_removemobs; // [Wizputer] + map->addmap2db = map_addmap2db; + map->removemapdb = map_removemapdb; + map->clean = map_clean; - iMap->do_shutdown = do_shutdown; + map->do_shutdown = do_shutdown; /* FIXME: temporary until the map.c "Hercules Renewal Phase One" design is complete. [Ind] */ mapit = &mapit_s; diff --git a/src/map/map.h b/src/map/map.h index 04c082501..f3a74ed2e 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -215,10 +215,10 @@ 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) (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) +#define map_flag_vs(m) (maplist[m].flag.pvp || maplist[m].flag.gvg_dungeon || maplist[m].flag.gvg || ((map->agit_flag || map->agit2_flag) && maplist[m].flag.gvg_castle) || maplist[m].flag.battleground) // Specifies maps that have special GvG/WoE restrictions -#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_gvg(m) (maplist[m].flag.gvg || ((map->agit_flag || map->agit2_flag) && maplist[m].flag.gvg_castle)) +// Specifies if the map is tagged as GvG/WoE (regardless of map->agit_flag status) #define map_flag_gvg2(m) (maplist[m].flag.gvg || maplist[m].flag.gvg_castle) // No Kill Steal Protection #define map_flag_ks(m) (maplist[m].flag.town || maplist[m].flag.pvp || maplist[m].flag.gvg || maplist[m].flag.battleground) @@ -433,7 +433,7 @@ typedef enum { } cell_t; -// used by iMap->getcell() +// used by map->getcell() typedef enum { CELL_GETTYPE, // retrieves a cell's 'gat' type @@ -525,7 +525,7 @@ struct map_zone_skill_damage_cap_entry { #define MAP_ZONE_PK_NAME "PK Mode" #define MAP_ZONE_MAPFLAG_LENGTH 50 -//TODO place it in iMap +//TODO place it in the map interface DBMap *zone_db;/* string => struct map_zone_data */ struct map_zone_data { @@ -905,7 +905,7 @@ struct map_interface { void (*do_shutdown) (void); }; -struct map_interface *iMap; +struct map_interface *map; void map_defaults(void); diff --git a/src/map/mercenary.c b/src/map/mercenary.c index 402c477bf..a1e2986b2 100644 --- a/src/map/mercenary.c +++ b/src/map/mercenary.c @@ -217,12 +217,11 @@ int mercenary_save(struct mercenary_data *md) return 1; } -static int merc_contract_end(int tid, unsigned int tick, int id, intptr_t data) -{ +static int merc_contract_end(int tid, unsigned int tick, int id, intptr_t data) { struct map_session_data *sd; struct mercenary_data *md; - if( (sd = iMap->id2sd(id)) == NULL ) + if( (sd = map->id2sd(id)) == NULL ) return 1; if( (md = sd->md) == NULL ) return 1; @@ -281,14 +280,13 @@ void merc_contract_init(struct mercenary_data *md) md->regen.state.block = 0; } -int merc_data_received(struct s_mercenary *merc, bool flag) -{ +int merc_data_received(struct s_mercenary *merc, bool flag) { struct map_session_data *sd; struct mercenary_data *md; struct s_mercenary_db *db; int i = merc_search_index(merc->class_); - if( (sd = iMap->charid2sd(merc->char_id)) == NULL ) + if( (sd = map->charid2sd(merc->char_id)) == NULL ) return 0; if( !flag || i < 0 ) { // Not created - loaded - DB info @@ -297,8 +295,7 @@ int merc_data_received(struct s_mercenary *merc, bool flag) } db = &mercenary->db[i]; - if( !sd->md ) - { + if( !sd->md ) { sd->md = md = (struct mercenary_data*)aCalloc(1,sizeof(struct mercenary_data)); md->bl.type = BL_MER; md->bl.id = npc->get_new_npc_id(); @@ -307,8 +304,8 @@ int merc_data_received(struct s_mercenary *merc, bool flag) md->master = sd; md->db = db; memcpy(&md->mercenary, merc, sizeof(struct s_mercenary)); - iStatus->set_viewdata(&md->bl, md->mercenary.class_); - iStatus->change_init(&md->bl); + status->set_viewdata(&md->bl, md->mercenary.class_); + status->change_init(&md->bl); unit->dataset(&md->bl); md->ud.dir = sd->ud.dir; @@ -319,7 +316,7 @@ int merc_data_received(struct s_mercenary *merc, bool flag) md->bl.x = md->ud.to_x; md->bl.y = md->ud.to_y; - iMap->addiddb(&md->bl); + map->addiddb(&md->bl); status_calc_mercenary(md,1); md->contract_timer = INVALID_TIMER; merc_contract_init(md); @@ -334,9 +331,8 @@ int merc_data_received(struct s_mercenary *merc, bool flag) mercenary->set_calls(md, 1); sd->status.mer_id = merc->mercenary_id; - if( md && md->bl.prev == NULL && sd->bl.prev != NULL ) - { - iMap->addblock(&md->bl); + if( md && md->bl.prev == NULL && sd->bl.prev != NULL ) { + map->addblock(&md->bl); clif->spawn(&md->bl); clif->mercenary_info(sd); clif->mercenary_skillblock(sd); @@ -452,7 +448,7 @@ static bool read_mercenarydb_sub(char* str[], int columns, int current) { int read_mercenarydb(void) { memset(mercenary->db,0,sizeof(mercenary->db)); - sv->readdb(iMap->db_path, "mercenary_db.txt", ',', 26, 26, MAX_MERCENARY_CLASS, &read_mercenarydb_sub); + sv->readdb(map->db_path, "mercenary_db.txt", ',', 26, 26, MAX_MERCENARY_CLASS, &read_mercenarydb_sub); return 0; } @@ -488,9 +484,8 @@ static bool read_mercenary_skilldb_sub(char* str[], int columns, int current) return true; } -int read_mercenary_skilldb(void) -{ - sv->readdb(iMap->db_path, "mercenary_skill_db.txt", ',', 3, 3, -1, &read_mercenary_skilldb_sub); +int read_mercenary_skilldb(void) { + sv->readdb(map->db_path, "mercenary_skill_db.txt", ',', 3, 3, -1, &read_mercenary_skilldb_sub); return 0; } diff --git a/src/map/mob.c b/src/map/mob.c index ceb00a6ce..8e956adc1 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -134,7 +134,7 @@ void mvptomb_create(struct mob_data *md, char *killer, time_t time) nd->bl.id = md->tomb_nid = npc->get_new_npc_id(); - nd->dir = md->ud.dir; + nd->dir = md->ud.dir; nd->bl.m = md->bl.m; nd->bl.x = md->bl.x; nd->bl.y = md->bl.y; @@ -154,24 +154,24 @@ void mvptomb_create(struct mob_data *md, char *killer, time_t time) else nd->u.tomb.killer_name[0] = '\0'; - iMap->addnpc(nd->bl.m, nd); - iMap->addblock(&nd->bl); - iStatus->set_viewdata(&nd->bl, nd->class_); - clif->spawn(&nd->bl); + map->addnpc(nd->bl.m, nd); + map->addblock(&nd->bl); + status->set_viewdata(&nd->bl, nd->class_); + clif->spawn(&nd->bl); } void mvptomb_destroy(struct mob_data *md) { struct npc_data *nd; - if ( (nd = iMap->id2nd(md->tomb_nid)) ) { + if ( (nd = map->id2nd(md->tomb_nid)) ) { int16 m, i; m = nd->bl.m; clif->clearunit_area(&nd->bl,CLR_OUTSIGHT); - iMap->delblock(&nd->bl); + map->delblock(&nd->bl); ARR_FIND( 0, maplist[m].npc_num, i, maplist[m].npc[i] == nd ); if( !(i == maplist[m].npc_num) ) { @@ -180,7 +180,7 @@ void mvptomb_destroy(struct mob_data *md) { maplist[m].npc[maplist[m].npc_num] = NULL; } - iMap->deliddb(&nd->bl); + map->deliddb(&nd->bl); aFree(nd); } @@ -281,11 +281,11 @@ struct mob_data* mob_spawn_dataset(struct spawn_data *data) { md->spawn_timer = INVALID_TIMER; md->deletetimer = INVALID_TIMER; md->skill_idx = -1; - iStatus->set_viewdata(&md->bl, md->class_); - iStatus->change_init(&md->bl); + status->set_viewdata(&md->bl, md->class_); + status->change_init(&md->bl); unit->dataset(&md->bl); - iMap->addiddb(&md->bl); + map->addiddb(&md->bl); return md; } @@ -356,7 +356,7 @@ bool mob_ksprotected (struct block_list *src, struct block_list *target) if( !(sd = BL_CAST(BL_PC,s_bl)) ) return false; // Master is not PC - t_bl = iMap->id2bl(md->target_id); + t_bl = map->id2bl(md->target_id); if( !t_bl || (s_bl = battle->get_master(t_bl)) == NULL ) s_bl = t_bl; @@ -383,7 +383,7 @@ bool mob_ksprotected (struct block_list *src, struct block_list *target) (sce->val2 == 3 && sce->val4 && sce->val4 != t_sd->status.guild_id)) ) break; - if( (pl_sd = iMap->id2sd(sce->val1)) == NULL || pl_sd->bl.m != md->bl.m ) + if( (pl_sd = map->id2sd(sce->val1)) == NULL || pl_sd->bl.m != md->bl.m ) break; if( !pl_sd->state.noks ) @@ -410,7 +410,7 @@ bool mob_ksprotected (struct block_list *src, struct block_list *target) return true; } while(0); - iStatus->change_start(target, SC_KSPROTECTED, 10000, sd->bl.id, sd->state.noks, sd->status.party_id, sd->status.guild_id, battle_config.ksprotection, 0); + status->change_start(target, SC_KSPROTECTED, 10000, sd->bl.id, sd->state.noks, sd->status.party_id, sd->status.guild_id, battle_config.ksprotection, 0); return false; } @@ -439,11 +439,11 @@ struct mob_data *mob_once_spawn_sub(struct block_list *bl, int16 m, int16 x, int // Locate spot next to player. if (bl && (x < 0 || y < 0)) - iMap->search_freecell(bl, m, &x, &y, 1, 1, 0); + map->search_freecell(bl, m, &x, &y, 1, 1, 0); // if none found, pick random position on map - if (x <= 0 || y <= 0 || iMap->getcell(m,x,y,CELL_CHKNOREACH)) - iMap->search_freecell(NULL, m, &x, &y, -1, -1, 1); + if (x <= 0 || y <= 0 || map->getcell(m,x,y,CELL_CHKNOREACH)) + map->search_freecell(NULL, m, &x, &y, -1, -1, 1); data.x = x; data.y = y; @@ -535,7 +535,7 @@ int mob_once_spawn_area(struct map_session_data* sd, int16 m, int16 x0, int16 y0 x = rnd()%(x1-x0+1)+x0; y = rnd()%(y1-y0+1)+y0; j++; - } while (iMap->getcell(m,x,y,CELL_CHKNOPASS) && j < max); + } while (map->getcell(m,x,y,CELL_CHKNOPASS) && j < max); if (j == max) {// attempt to find an available cell failed @@ -561,7 +561,7 @@ int mob_once_spawn_area(struct map_session_data* sd, int16 m, int16 x0, int16 y0 *------------------------------------------*/ int mob_spawn_guardian_sub(int tid, unsigned int tick, int id, intptr_t data) { //Needed because the guild_data may not be available at guardian spawn time. - struct block_list* bl = iMap->id2bl(id); + struct block_list* bl = map->id2bl(id); struct mob_data* md; struct guild* g; int guardup_lv; @@ -619,7 +619,7 @@ int mob_spawn_guardian(const char* mapname, short x, short y, const char* mobnam memset(&data, 0, sizeof(struct spawn_data)); data.num = 1; - m=iMap->mapname2mapid(mapname); + m=map->mapname2mapid(mapname); if(m<0) { @@ -642,7 +642,7 @@ int mob_spawn_guardian(const char* mapname, short x, short y, const char* mobnam return 0; } - if((x<=0 || y<=0) && !iMap->search_freecell(NULL, m, &x, &y, -1,-1, 1)) { + if((x<=0 || y<=0) && !map->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; } @@ -665,7 +665,7 @@ int mob_spawn_guardian(const char* mapname, short x, short y, const char* mobnam 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); + struct mob_data *md2 = (TBL_MOB*)map->id2bl(gc->guardian[guardian].id); if (md2 && md2->bl.type == BL_MOB && md2->guardian_data && md2->guardian_data->number == guardian @@ -716,8 +716,7 @@ int mob_spawn_bg(const char* mapname, short x, short y, const char* mobname, int struct spawn_data data; int16 m; - if( (m = iMap->mapname2mapid(mapname)) < 0 ) - { + if( (m = map->mapname2mapid(mapname)) < 0 ) { ShowWarning("mob_spawn_bg: Map [%s] not found.\n", mapname); return 0; } @@ -732,7 +731,7 @@ 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) ) { + if( (x <= 0 || y <= 0) && !map->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; } @@ -810,9 +809,8 @@ int mob_linksearch(struct block_list *bl,va_list ap) /*========================================== * mob spawn with delay (timer function) *------------------------------------------*/ -int mob_delayspawn(int tid, unsigned int tick, int id, intptr_t data) -{ - struct block_list* bl = iMap->id2bl(id); +int mob_delayspawn(int tid, unsigned int tick, int id, intptr_t data) { + struct block_list* bl = map->id2bl(id); struct mob_data* md = BL_CAST(BL_MOB, bl); if( md ) @@ -894,7 +892,7 @@ int mob_spawn (struct mob_data *md) unit->remove_map(&md->bl,CLR_RESPAWN,ALC_MARK); else if (md->spawn && md->class_ != md->spawn->class_) { md->class_ = md->spawn->class_; - iStatus->set_viewdata(&md->bl, md->class_); + status->set_viewdata(&md->bl, md->class_); md->db = mob->db(md->class_); memcpy(md->name,md->spawn->name,NAME_LENGTH); } @@ -904,18 +902,17 @@ int mob_spawn (struct mob_data *md) md->bl.x = md->spawn->x; md->bl.y = md->spawn->y; - if( (md->bl.x == 0 && md->bl.y == 0) || md->spawn->xs || md->spawn->ys ) - { //Monster can be spawned on an area. - if( !iMap->search_freecell(&md->bl, -1, &md->bl.x, &md->bl.y, md->spawn->xs, md->spawn->ys, battle_config.no_spawn_on_player?4:0) ) - { // retry again later + if( (md->bl.x == 0 && md->bl.y == 0) || md->spawn->xs || md->spawn->ys ) { + //Monster can be spawned on an area. + if( !map->search_freecell(&md->bl, -1, &md->bl.x, &md->bl.y, md->spawn->xs, md->spawn->ys, battle_config.no_spawn_on_player?4:0) ) { + // retry again later if( md->spawn_timer != INVALID_TIMER ) timer->delete(md->spawn_timer, mob->delayspawn); md->spawn_timer = timer->add(tick+5000,mob->delayspawn,md->bl.id,0); return 1; } - } - else if( battle_config.no_spawn_on_player > 99 && iMap->foreachinrange(mob->count_sub, &md->bl, AREA_SIZE, BL_PC) ) - { // retry again later (players on sight) + } else if( battle_config.no_spawn_on_player > 99 && map->foreachinrange(mob->count_sub, &md->bl, AREA_SIZE, BL_PC) ) { + // retry again later (players on sight) if( md->spawn_timer != INVALID_TIMER ) timer->delete(md->spawn_timer, mob->delayspawn); md->spawn_timer = timer->add(tick+5000,mob->delayspawn,md->bl.id,0); @@ -965,7 +962,7 @@ int mob_spawn (struct mob_data *md) if ( md->tomb_nid ) mob->mvptomb_destroy(md); - iMap->addblock(&md->bl); + map->addblock(&md->bl); if( maplist[md->bl.m].users ) clif->spawn(&md->bl); skill->unit_move(&md->bl,tick,1); @@ -1017,7 +1014,7 @@ int mob_target(struct mob_data *md,struct block_list *bl,int dist) if(md->target_id && !mob->can_changetarget(md, bl, status_get_mode(&md->bl))) return 0; - if(!iStatus->check_skilluse(&md->bl, bl, 0, 0)) + if(!status->check_skilluse(&md->bl, bl, 0, 0)) return 0; md->target_id = bl->id; // Since there was no disturbance, it locks on to target. @@ -1045,10 +1042,10 @@ int mob_ai_sub_hard_activesearch(struct block_list *bl,va_list ap) mode= va_arg(ap,int); //If can't seek yet, not an enemy, or you can't attack it, skip. - if ((*target) == bl || !iStatus->check_skilluse(&md->bl, bl, 0, 0)) + if ((*target) == bl || !status->check_skilluse(&md->bl, bl, 0, 0)) return 0; - if ((mode&MD_TARGETWEAK) && iStatus->get_lv(bl) >= md->level-5) + if ((mode&MD_TARGETWEAK) && status->get_lv(bl) >= md->level-5) return 0; if(battle->check_target(&md->bl,bl,BCT_ENEMY)<=0) @@ -1094,8 +1091,7 @@ int mob_ai_sub_hard_activesearch(struct block_list *bl,va_list ap) /*========================================== * chase target-change routine. *------------------------------------------*/ -int mob_ai_sub_hard_changechase(struct block_list *bl,va_list ap) -{ +int mob_ai_sub_hard_changechase(struct block_list *bl,va_list ap) { struct mob_data *md; struct block_list **target; @@ -1104,9 +1100,10 @@ int mob_ai_sub_hard_changechase(struct block_list *bl,va_list ap) target= va_arg(ap,struct block_list**); //If can't seek yet, not an enemy, or you can't attack it, skip. - if ((*target) == bl || - battle->check_target(&md->bl,bl,BCT_ENEMY)<=0 || - !iStatus->check_skilluse(&md->bl, bl, 0, 0)) + if( *target == bl + || battle->check_target(&md->bl,bl,BCT_ENEMY) <= 0 + || !status->check_skilluse(&md->bl, bl, 0, 0) + ) return 0; if(battle->check_range (&md->bl, bl, md->status.rhw.range)) { @@ -1128,7 +1125,7 @@ int mob_ai_sub_hard_bg_ally(struct block_list *bl,va_list ap) { md=va_arg(ap,struct mob_data *); target= va_arg(ap,struct block_list**); - if( iStatus->check_skilluse(&md->bl, bl, 0, 0) && battle->check_target(&md->bl,bl,BCT_ENEMY)<=0 ) { + if( status->check_skilluse(&md->bl, bl, 0, 0) && battle->check_target(&md->bl,bl,BCT_ENEMY)<=0 ) { (*target) = bl; } return 1; @@ -1188,13 +1185,12 @@ int mob_warpchase_sub(struct block_list *bl,va_list ap) { /*========================================== * Processing of slave monsters *------------------------------------------*/ -int mob_ai_sub_hard_slavemob(struct mob_data *md,unsigned int tick) -{ +int mob_ai_sub_hard_slavemob(struct mob_data *md,unsigned int tick) { struct block_list *bl; - bl=iMap->id2bl(md->master_id); + bl=map->id2bl(md->master_id); - if (!bl || iStatus->isdead(bl)) { + if (!bl || status->isdead(bl)) { status_kill(&md->bl); return 1; } @@ -1223,12 +1219,12 @@ int mob_ai_sub_hard_slavemob(struct mob_data *md,unsigned int tick) return 0; // Approach master if within view range, chase back to Master's area also if standing on top of the master. - if((md->master_dist>MOB_SLAVEDISTANCE || md->master_dist == 0) && - unit->can_move(&md->bl)) - { + if( (md->master_dist>MOB_SLAVEDISTANCE || md->master_dist == 0) + && unit->can_move(&md->bl) + ) { short x = bl->x, y = bl->y; mob_stop_attack(md); - if(iMap->search_freecell(&md->bl, bl->m, &x, &y, MOB_SLAVEDISTANCE, MOB_SLAVEDISTANCE, 1) + if(map->search_freecell(&md->bl, bl->m, &x, &y, MOB_SLAVEDISTANCE, MOB_SLAVEDISTANCE, 1) && unit->walktoxy(&md->bl, x, y, 0)) return 1; } @@ -1247,14 +1243,14 @@ int mob_ai_sub_hard_slavemob(struct mob_data *md,unsigned int tick) if (ud) { struct block_list *tbl=NULL; if (ud->target && ud->state.attack_continue) - tbl=iMap->id2bl(ud->target); + tbl=map->id2bl(ud->target); else if (ud->skilltarget) { - tbl = iMap->id2bl(ud->skilltarget); + tbl = map->id2bl(ud->skilltarget); //Required check as skilltarget is not always an enemy. [Skotlex] if (tbl && battle->check_target(&md->bl, tbl, BCT_ENEMY) <= 0) tbl = NULL; } - if (tbl && iStatus->check_skilluse(&md->bl, tbl, 0, 0)) { + if (tbl && status->check_skilluse(&md->bl, tbl, 0, 0)) { md->target_id=tbl->id; md->min_chase=md->db->range3+distance_bl(&md->bl, tbl); if(md->min_chase>MAX_MINCHASE) @@ -1334,7 +1330,7 @@ int mob_randomwalk(struct mob_data *md,unsigned int tick) x+=md->bl.x; y+=md->bl.y; - if((iMap->getcell(md->bl.m,x,y,CELL_CHKPASS)) && unit->walktoxy(&md->bl,x,y,1)){ + if((map->getcell(md->bl.m,x,y,CELL_CHKPASS)) && unit->walktoxy(&md->bl,x,y,1)){ break; } } @@ -1347,8 +1343,9 @@ int mob_randomwalk(struct mob_data *md,unsigned int tick) } return 0; } - speed=iStatus->get_speed(&md->bl); - for(i=c=0;i<md->ud.walkpath.path_len;i++){ // The next walk start time is calculated. + speed=status->get_speed(&md->bl); + for(i=c=0;i<md->ud.walkpath.path_len;i++) { + // The next walk start time is calculated. if(md->ud.walkpath.path[i]&1) c+=speed*MOVE_DIAGONAL_COST/MOVE_COST; else @@ -1371,12 +1368,12 @@ int mob_warpchase(struct mob_data *md, struct block_list *target) return 0; //No need to do a warp chase. if (md->ud.walktimer != INVALID_TIMER && - iMap->getcell(md->bl.m,md->ud.to_x,md->ud.to_y,CELL_CHKNPC)) + map->getcell(md->bl.m,md->ud.to_x,md->ud.to_y,CELL_CHKNPC)) return 1; //Already walking to a warp. //Search for warps within mob's viewing range. - iMap->foreachinrange (mob->warpchase_sub, &md->bl, - md->db->range2, BL_NPC, target, &warp, &distance); + map->foreachinrange(mob->warpchase_sub, &md->bl, + md->db->range2, BL_NPC, target, &warp, &distance); if (warp && unit->walktobl(&md->bl, &warp->bl, 1, 1)) return 1; @@ -1421,17 +1418,18 @@ bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick) can_move = (mode&MD_CANMOVE)&&unit->can_move(&md->bl); - if (md->target_id) - { //Check validity of current target. [Skotlex] - tbl = iMap->id2bl(md->target_id); - if (!tbl || tbl->m != md->bl.m || - (md->ud.attacktimer == INVALID_TIMER && !iStatus->check_skilluse(&md->bl, tbl, 0, 0)) || - (md->ud.walktimer != INVALID_TIMER && !(battle_config.mob_ai&0x1) && !check_distance_bl(&md->bl, tbl, md->min_chase)) || - ( - tbl->type == BL_PC && - ((((TBL_PC*)tbl)->state.gangsterparadise && !(mode&MD_BOSS)) || - ((TBL_PC*)tbl)->invincible_timer != INVALID_TIMER) - )) { //Unlock current target. + if (md->target_id) { + //Check validity of current target. [Skotlex] + tbl = map->id2bl(md->target_id); + if (!tbl || tbl->m != md->bl.m + || (md->ud.attacktimer == INVALID_TIMER && !status->check_skilluse(&md->bl, tbl, 0, 0)) + || (md->ud.walktimer != INVALID_TIMER && !(battle_config.mob_ai&0x1) && !check_distance_bl(&md->bl, tbl, md->min_chase)) + || ( tbl->type == BL_PC + && ((((TBL_PC*)tbl)->state.gangsterparadise && !(mode&MD_BOSS)) + || ((TBL_PC*)tbl)->invincible_timer != INVALID_TIMER) + ) + ) { + //Unlock current target. if (mob->warpchase(md, tbl)) return true; //Chasing this target. mob->unlocktarget(md, tick-(battle_config.mob_ai&0x8?3000:0)); //Imediately do random walk. @@ -1460,22 +1458,22 @@ bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick) } } else - if( (abl = iMap->id2bl(md->attacked_id)) && (!tbl || mob->can_changetarget(md, abl, mode)) ) - { + if( (abl = map->id2bl(md->attacked_id)) && (!tbl || mob->can_changetarget(md, abl, mode)) ) { int dist; if( md->bl.m != abl->m || abl->prev == NULL - || (dist = distance_bl(&md->bl, abl)) >= MAX_MINCHASE // Attacker longer than visual area - || battle->check_target(&md->bl, abl, BCT_ENEMY) <= 0 // Attacker is not enemy of mob - || (battle_config.mob_ai&0x2 && !iStatus->check_skilluse(&md->bl, abl, 0, 0)) // Cannot normal attack back to Attacker - || (!battle->check_range(&md->bl, abl, md->status.rhw.range) // Not on Melee Range and ... - && ( // Reach check - (!can_move && DIFF_TICK(tick, md->ud.canmove_tick) > 0 && (battle_config.mob_ai&0x2 || (md->sc.data[SC_SPIDERWEB] && md->sc.data[SC_SPIDERWEB]->val1) - || md->sc.data[SC_WUGBITE] || md->sc.data[SC_VACUUM_EXTREME] || md->sc.data[SC_THORNS_TRAP] - || md->sc.data[SC__MANHOLE])) // Not yet confirmed if boss will teleport once it can't reach target. - || !mob->can_reach(md, abl, dist+md->db->range3, MSS_RUSH) - ) - ) ) - { // Rude attacked + || (dist = distance_bl(&md->bl, abl)) >= MAX_MINCHASE // Attacker longer than visual area + || battle->check_target(&md->bl, abl, BCT_ENEMY) <= 0 // Attacker is not enemy of mob + || (battle_config.mob_ai&0x2 && !status->check_skilluse(&md->bl, abl, 0, 0)) // Cannot normal attack back to Attacker + || (!battle->check_range(&md->bl, abl, md->status.rhw.range) // Not on Melee Range and ... + && ( // Reach check + (!can_move && DIFF_TICK(tick, md->ud.canmove_tick) > 0 && (battle_config.mob_ai&0x2 || (md->sc.data[SC_SPIDERWEB] && md->sc.data[SC_SPIDERWEB]->val1) + || md->sc.data[SC_WUGBITE] || md->sc.data[SC_VACUUM_EXTREME] || md->sc.data[SC_THORNS_TRAP] + || md->sc.data[SC__MANHOLE])) // Not yet confirmed if boss will teleport once it can't reach target. + || !mob->can_reach(md, abl, dist+md->db->range3, MSS_RUSH) + ) + ) + ) { + // Rude attacked if (md->state.attacked_count++ >= RUDE_ATTACKED_COUNT && !mob->skill_use(md, tick, MSC_RUDEATTACKED) && can_move && !tbl && unit->escape(&md->bl, abl, rnd()%10 +1)) @@ -1486,12 +1484,10 @@ bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick) } } else - if (!(battle_config.mob_ai&0x2) && !iStatus->check_skilluse(&md->bl, abl, 0, 0)) - { + if (!(battle_config.mob_ai&0x2) && !status->check_skilluse(&md->bl, abl, 0, 0)) { //Can't attack back, but didn't invoke a rude attacked skill... - } - else - { //Attackable + } else { + //Attackable if (!tbl || dist < md->status.rhw.range || !check_distance_bl(&md->bl, tbl, dist) || battle->get_target(tbl) != md->bl.id) { //Change if the new target is closer than the actual one @@ -1516,22 +1512,19 @@ bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick) return true; // Scan area for targets - if (!tbl && mode&MD_LOOTER && md->lootitem && DIFF_TICK(tick, md->ud.canact_tick) > 0 && - (md->lootitem_count < LOOTITEM_SIZE || battle_config.monster_loot_type != 1)) - { // Scan area for items to loot, avoid trying to loot if the mob is full and can't consume the items. - iMap->foreachinrange (mob->ai_sub_hard_lootsearch, &md->bl, view_range, BL_ITEM, md, &tbl); + if (!tbl && mode&MD_LOOTER && md->lootitem && DIFF_TICK(tick, md->ud.canact_tick) > 0 + && (md->lootitem_count < LOOTITEM_SIZE || battle_config.monster_loot_type != 1) + ) { + // Scan area for items to loot, avoid trying to loot if the mob is full and can't consume the items. + map->foreachinrange (mob->ai_sub_hard_lootsearch, &md->bl, view_range, BL_ITEM, md, &tbl); } - if ((!tbl && mode&MD_AGGRESSIVE) || md->state.skillstate == MSS_FOLLOW) - { - iMap->foreachinrange (mob->ai_sub_hard_activesearch, &md->bl, view_range, DEFAULT_ENEMY_TYPE(md), md, &tbl, mode); - } - else - if (mode&MD_CHANGECHASE && (md->state.skillstate == MSS_RUSH || md->state.skillstate == MSS_FOLLOW)) - { + if ((!tbl && mode&MD_AGGRESSIVE) || md->state.skillstate == MSS_FOLLOW) { + map->foreachinrange (mob->ai_sub_hard_activesearch, &md->bl, view_range, DEFAULT_ENEMY_TYPE(md), md, &tbl, mode); + } else if (mode&MD_CHANGECHASE && (md->state.skillstate == MSS_RUSH || md->state.skillstate == MSS_FOLLOW)) { int search_size; search_size = view_range<md->status.rhw.range ? view_range:md->status.rhw.range; - iMap->foreachinrange (mob->ai_sub_hard_changechase, &md->bl, search_size, DEFAULT_ENEMY_TYPE(md), md, &tbl); + map->foreachinrange (mob->ai_sub_hard_changechase, &md->bl, search_size, DEFAULT_ENEMY_TYPE(md), md, &tbl); } if (!tbl) { //No targets available. @@ -1542,7 +1535,7 @@ bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick) if( md->bg_id && mode&MD_CANATTACK ) { if( md->ud.walktimer != INVALID_TIMER ) return true;/* we are already moving */ - iMap->foreachinrange (mob->ai_sub_hard_bg_ally, &md->bl, view_range, BL_PC, md, &tbl, mode); + map->foreachinrange (mob->ai_sub_hard_bg_ally, &md->bl, view_range, BL_PC, md, &tbl, mode); if( tbl ) { if( distance_blxy(&md->bl, tbl->x, tbl->y) <= 3 || unit->walktobl(&md->bl, tbl, 1, 1) ) return true;/* we're moving or close enough don't unlock the target. */ @@ -1602,7 +1595,7 @@ bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick) unit->set_walkdelay(&md->bl, tick, md->status.amotion, 1); } //Clear item. - iMap->clearflooritem (tbl); + map->clearflooritem (tbl); mob->unlocktarget (md,tick); return true; } @@ -1668,11 +1661,10 @@ int mob_ai_sub_hard_timer(struct block_list *bl,va_list ap) /*========================================== * Serious processing for mob in PC field of view (foreachclient) *------------------------------------------*/ -int mob_ai_sub_foreachclient(struct map_session_data *sd,va_list ap) -{ +int mob_ai_sub_foreachclient(struct map_session_data *sd,va_list ap) { unsigned int tick; tick=va_arg(ap,unsigned int); - iMap->foreachinrange(mob->ai_sub_hard_timer,&sd->bl, AREA_SIZE+ACTIVE_AI_RANGE, BL_MOB,tick); + map->foreachinrange(mob->ai_sub_hard_timer,&sd->bl, AREA_SIZE+ACTIVE_AI_RANGE, BL_MOB,tick); return 0; } @@ -1748,22 +1740,20 @@ int mob_ai_sub_lazy(struct mob_data *md, va_list args) /*========================================== * Negligent processing for mob outside PC field of view (interval timer function) *------------------------------------------*/ -int mob_ai_lazy(int tid, unsigned int tick, int id, intptr_t data) -{ - iMap->map_foreachmob(mob->ai_sub_lazy,tick); +int mob_ai_lazy(int tid, unsigned int tick, int id, intptr_t data) { + map->map_foreachmob(mob->ai_sub_lazy,tick); return 0; } /*========================================== * Serious processing for mob in PC field of view (interval timer function) *------------------------------------------*/ -int mob_ai_hard(int tid, unsigned int tick, int id, intptr_t data) -{ +int mob_ai_hard(int tid, unsigned int tick, int id, intptr_t data) { if (battle_config.mob_ai&0x20) - iMap->map_foreachmob(mob->ai_sub_lazy,tick); + map->map_foreachmob(mob->ai_sub_lazy,tick); else - iMap->map_foreachpc(mob->ai_sub_foreachclient,tick); + map->map_foreachpc(mob->ai_sub_foreachclient,tick); return 0; } @@ -1802,9 +1792,9 @@ int mob_delay_item_drop(int tid, unsigned int tick, int id, intptr_t data) list=(struct item_drop_list *)data; ditem = list->item; while (ditem) { - iMap->addflooritem(&ditem->item_data,ditem->item_data.amount, - list->m,list->x,list->y, - list->first_charid,list->second_charid,list->third_charid,0); + map->addflooritem(&ditem->item_data,ditem->item_data.amount, + list->m,list->x,list->y, + list->first_charid,list->second_charid,list->third_charid,0); ditem_prev = ditem; ditem = ditem->next; ers_free(item_drop_ers, ditem_prev); @@ -1826,9 +1816,9 @@ void mob_item_drop(struct mob_data *md, struct item_drop_list *dlist, struct ite //Logs items, dropped by mobs [Lupus] logs->pick_mob(md, loot?LOG_TYPE_LOOT:LOG_TYPE_PICKDROP_MONSTER, -ditem->item_data.amount, &ditem->item_data, NULL); - sd = iMap->charid2sd(dlist->first_charid); - if( sd == NULL ) sd = iMap->charid2sd(dlist->second_charid); - if( sd == NULL ) sd = iMap->charid2sd(dlist->third_charid); + sd = map->charid2sd(dlist->first_charid); + if( sd == NULL ) sd = map->charid2sd(dlist->second_charid); + if( sd == NULL ) sd = map->charid2sd(dlist->third_charid); if( sd && (drop_rate <= sd->state.autoloot || pc->isautolooting(sd, ditem->item_data.nameid)) @@ -1850,9 +1840,8 @@ void mob_item_drop(struct mob_data *md, struct item_drop_list *dlist, struct ite dlist->item = ditem; } -int mob_timer_delete(int tid, unsigned int tick, int id, intptr_t data) -{ - struct block_list* bl = iMap->id2bl(id); +int mob_timer_delete(int tid, unsigned int tick, int id, intptr_t data) { + struct block_list* bl = map->id2bl(id); struct mob_data* md = BL_CAST(BL_MOB, bl); if( md ) @@ -1889,20 +1878,18 @@ int mob_deleteslave_sub(struct block_list *bl,va_list ap) /*========================================== * *------------------------------------------*/ -int mob_deleteslave(struct mob_data *md) -{ +int mob_deleteslave(struct mob_data *md) { nullpo_ret(md); - iMap->foreachinmap(mob->deleteslave_sub, md->bl.m, BL_MOB,md->bl.id); + map->foreachinmap(mob->deleteslave_sub, md->bl.m, BL_MOB,md->bl.id); return 0; } // Mob respawning through KAIZEL or NPC_REBIRTH [Skotlex] -int mob_respawn(int tid, unsigned int tick, int id, intptr_t data) -{ - struct block_list *bl = iMap->id2bl(id); +int mob_respawn(int tid, unsigned int tick, int id, intptr_t data) { + struct block_list *bl = map->id2bl(id); if(!bl) return 0; - iStatus->revive(bl, (uint8)data, 0); + status->revive(bl, (uint8)data, 0); return 1; } @@ -1961,9 +1948,8 @@ void mob_log_damage(struct mob_data *md, struct block_list *src, int damage) case BL_MOB: { struct mob_data* md2 = (TBL_MOB*)src; - if( md2->special_state.ai && md2->master_id ) - { - struct map_session_data* msd = iMap->id2sd(md2->master_id); + if( md2->special_state.ai && md2->master_id ) { + struct map_session_data* msd = map->id2sd(md2->master_id); if( msd ) char_id = msd->status.char_id; } @@ -2053,7 +2039,7 @@ void mob_damage(struct mob_data *md, struct block_list *src, int damage) { int i; for(i = 0; i < DAMAGELOG_SIZE; i++){ // must show hp bar to all char who already hit the mob. if( md->dmglog[i].id ) { - struct map_session_data *sd = iMap->charid2sd(md->dmglog[i].id); + struct map_session_data *sd = map->charid2sd(md->dmglog[i].id); if( sd && check_distance_bl(&md->bl, &sd->bl, AREA_SIZE) ) // check if in range clif->monster_hp_bar(md,sd); } @@ -2103,7 +2089,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) { mob->skill_use(md,tick,-1); } - iMap->freeblock_lock(); + map->freeblock_lock(); memset(pt,0,sizeof(pt)); @@ -2112,9 +2098,8 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) { // filter out entries not eligible for exp distribution memset(tmpsd,0,sizeof(tmpsd)); - for(i = 0, count = 0, mvp_damage = 0; i < DAMAGELOG_SIZE && md->dmglog[i].id; i++) - { - struct map_session_data* tsd = iMap->charid2sd(md->dmglog[i].id); + for(i = 0, count = 0, mvp_damage = 0; i < DAMAGELOG_SIZE && md->dmglog[i].id; i++) { + struct map_session_data* tsd = map->charid2sd(md->dmglog[i].id); if(tsd == NULL) continue; // skip empty entries @@ -2168,7 +2153,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) { if (md->sc.data[SC_RICHMANKIM]) bonus += md->sc.data[SC_RICHMANKIM]->val2; if(sd) { - temp = iStatus->get_class(&md->bl); + temp = status->get_class(&md->bl); if(sd->sc.data[SC_MIRACLE]) i = 2; //All mobs are Star Targets else ARR_FIND(0, MAX_PC_FEELHATE, i, temp == sd->hate_mob[i] && @@ -2516,7 +2501,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) { if((temp = pc->additem(mvp_sd,&item,1,LOG_TYPE_PICKDROP_PLAYER)) != 0) { clif->additem(mvp_sd,0,0,temp); - iMap->addflooritem(&item,1,mvp_sd->bl.m,mvp_sd->bl.x,mvp_sd->bl.y,mvp_sd->status.char_id,(second_sd?second_sd->status.char_id:0),(third_sd?third_sd->status.char_id:0),1); + map->addflooritem(&item,1,mvp_sd->bl.m,mvp_sd->bl.x,mvp_sd->bl.y,mvp_sd->status.char_id,(second_sd?second_sd->status.char_id:0),(third_sd?third_sd->status.char_id:0),1); } //Logs items, MVP prizes [Lupus] @@ -2557,7 +2542,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) { } if( sd->status.party_id ) - iMap->foreachinrange(quest->update_objective_sub,&md->bl,AREA_SIZE,BL_PC,sd->status.party_id,md->class_); + map->foreachinrange(quest->update_objective_sub,&md->bl,AREA_SIZE,BL_PC,sd->status.party_id,md->class_); else if( sd->avail_quests ) quest->update_objective(sd, md->class_); @@ -2592,7 +2577,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) { if( md->can_summon ) mob->deleteslave(md); - iMap->freeblock_unlock(); + map->freeblock_unlock(); if( !rebirth ) { @@ -2609,7 +2594,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) { } - if(!md->spawn) //Tell iStatus->damage to remove it from memory. + if(!md->spawn) //Tell status->damage to remove it from memory. return 5; // Note: Actually, it's 4. Oh well... // MvP tomb [GreenBox] @@ -2617,7 +2602,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) { mob->mvptomb_create(md, mvp_sd ? mvp_sd->status.name : NULL, time(NULL)); if( !rebirth ) { - iStatus->change_clear(&md->bl,1); + status->change_clear(&md->bl,1); mob->setdelayspawn(md); //Set respawning. } return 3; //Remove from map. @@ -2634,7 +2619,7 @@ void mob_revive(struct mob_data *md, unsigned int hp) memset(md->dmglog, 0, sizeof(md->dmglog)); // Reset the damage done on the rebirthed monster, otherwise will grant full exp + damage done. [Valaris] md->tdmg = 0; if (!md->bl.prev) - iMap->addblock(&md->bl); + map->addblock(&md->bl); clif->spawn(&md->bl); skill->unit_move(&md->bl,tick,1); mob->skill_use(md, tick, MSC_SPAWN); @@ -2745,7 +2730,7 @@ int mob_class_change (struct mob_data *md, int class_) mob_stop_attack(md); mob_stop_walking(md, 0); unit->skillcastcancel(&md->bl, 0); - iStatus->set_viewdata(&md->bl, class_); + status->set_viewdata(&md->bl, class_); clif->class_change(&md->bl, md->vd->class_, 1); status_calc_mob(md, 1); md->ud.state.speed_changed = 1; //Speed change update. @@ -2785,8 +2770,7 @@ void mob_heal(struct mob_data *md,unsigned int heal) /*========================================== * Added by RoVeRT *------------------------------------------*/ -int mob_warpslave_sub(struct block_list *bl,va_list ap) -{ +int mob_warpslave_sub(struct block_list *bl,va_list ap) { struct mob_data *md=(struct mob_data *)bl; struct block_list *master; short x,y,range=0; @@ -2796,7 +2780,7 @@ int mob_warpslave_sub(struct block_list *bl,va_list ap) if(md->master_id!=master->id) return 0; - iMap->search_freecell(master, 0, &x, &y, range, range, 0); + map->search_freecell(master, 0, &x, &y, range, range, 0); unit->warp(&md->bl, master->m, x, y,CLR_RESPAWN); return 1; } @@ -2806,12 +2790,11 @@ int mob_warpslave_sub(struct block_list *bl,va_list ap) * Warps slaves. Range is the area around the master that they can * appear in randomly. *------------------------------------------*/ -int mob_warpslave(struct block_list *bl, int range) -{ +int mob_warpslave(struct block_list *bl, int range) { if (range < 1) range = 1; //Min range needed to avoid crashes and stuff. [Skotlex] - return iMap->foreachinmap(mob->warpslave_sub, bl->m, BL_MOB, bl, range); + return map->foreachinmap(mob->warpslave_sub, bl->m, BL_MOB, bl, range); } /*========================================== @@ -2832,9 +2815,8 @@ int mob_countslave_sub(struct block_list *bl,va_list ap) /*========================================== * Counts the number of slaves a mob has on the map. *------------------------------------------*/ -int mob_countslave(struct block_list *bl) -{ - return iMap->foreachinmap(mob->countslave_sub, bl->m, BL_MOB,bl->id); +int mob_countslave(struct block_list *bl) { + return map->foreachinmap(mob->countslave_sub, bl->m, BL_MOB,bl->id); } /*========================================== @@ -2881,7 +2863,7 @@ int mob_summonslave(struct mob_data *md2,int *value,int amount,uint16 skill_id) if (mob->db_checkid(data.class_) == 0) continue; - if (iMap->search_freecell(&md2->bl, 0, &x, &y, MOB_SLAVEDISTANCE, MOB_SLAVEDISTANCE, 0)) { + if (map->search_freecell(&md2->bl, 0, &x, &y, MOB_SLAVEDISTANCE, MOB_SLAVEDISTANCE, 0)) { data.x = x; data.y = y; } else { @@ -2980,8 +2962,7 @@ int mob_getfriendhprate_sub(struct block_list *bl,va_list ap) (*fr) = bl; return 1; } -struct block_list *mob_getfriendhprate(struct mob_data *md,int min_rate,int max_rate) -{ +struct block_list *mob_getfriendhprate(struct mob_data *md,int min_rate,int max_rate) { struct block_list *fr=NULL; int type = BL_MOB; @@ -2990,17 +2971,15 @@ struct block_list *mob_getfriendhprate(struct mob_data *md,int min_rate,int max_ if (md->special_state.ai) //Summoned creatures. [Skotlex] type = BL_PC; - iMap->foreachinrange(mob->getfriendhprate_sub, &md->bl, 8, type,md,min_rate,max_rate,&fr); + map->foreachinrange(mob->getfriendhprate_sub, &md->bl, 8, type,md,min_rate,max_rate,&fr); return fr; } /*========================================== * Check hp rate of its master *------------------------------------------*/ -struct block_list *mob_getmasterhpltmaxrate(struct mob_data *md,int rate) -{ - if( md && md->master_id > 0 ) - { - struct block_list *bl = iMap->id2bl(md->master_id); +struct block_list *mob_getmasterhpltmaxrate(struct mob_data *md,int rate) { + if( md && md->master_id > 0 ) { + struct block_list *bl = map->id2bl(md->master_id); if( bl && get_percentage(status_get_hp(bl), status_get_max_hp(bl)) < rate ) return bl; } @@ -3042,12 +3021,11 @@ int mob_getfriendstatus_sub(struct block_list *bl,va_list ap) return 0; } -struct mob_data *mob_getfriendstatus(struct mob_data *md,int cond1,int cond2) -{ +struct mob_data *mob_getfriendstatus(struct mob_data *md,int cond1,int cond2) { struct mob_data* fr = NULL; nullpo_ret(md); - iMap->foreachinrange(mob->getfriendstatus_sub, &md->bl, 8,BL_MOB, md,cond1,cond2,&fr); + map->foreachinrange(mob->getfriendstatus_sub, &md->bl, 8,BL_MOB, md,cond1,cond2,&fr); return fr; } @@ -3149,7 +3127,7 @@ int mobskill_use(struct mob_data *md, unsigned int tick, int event) case MSC_MASTERHPLTMAXRATE: flag = ((fbl = mob->getmasterhpltmaxrate(md, ms[i].cond2)) != NULL); break; case MSC_MASTERATTACKED: - flag = (md->master_id > 0 && (fbl=iMap->id2bl(md->master_id)) && unit->counttargeted(fbl) > 0); break; + flag = (md->master_id > 0 && (fbl=map->id2bl(md->master_id)) && unit->counttargeted(fbl) > 0); break; case MSC_ALCHEMIST: flag = (md->state.alchemist); break; @@ -3172,12 +3150,12 @@ int mobskill_use(struct mob_data *md, unsigned int tick, int event) case MST_AROUND6: case MST_AROUND7: case MST_AROUND8: - bl = iMap->id2bl(md->target_id); + bl = map->id2bl(md->target_id); break; case MST_MASTER: bl = &md->bl; if (md->master_id) - bl = iMap->id2bl(md->master_id); + bl = map->id2bl(md->master_id); if (bl) //Otherwise, fall through. break; case MST_FRIEND: @@ -3196,14 +3174,14 @@ int mobskill_use(struct mob_data *md, unsigned int tick, int event) j = ms[i].target >= MST_AROUND1? (ms[i].target-MST_AROUND1) +1: (ms[i].target-MST_AROUND5) +1; - iMap->search_freecell(&md->bl, md->bl.m, &x, &y, j, j, 3); + map->search_freecell(&md->bl, md->bl.m, &x, &y, j, j, 3); } md->skill_idx = i; - iMap->freeblock_lock(); - if( !battle->check_range(&md->bl,bl,skill->get_range2(&md->bl, ms[i].skill_id,ms[i].skill_lv)) || - !unit->skilluse_pos2(&md->bl, x, y,ms[i].skill_id, ms[i].skill_lv,ms[i].casttime, ms[i].cancel) ) - { - iMap->freeblock_unlock(); + map->freeblock_lock(); + if( !battle->check_range(&md->bl,bl,skill->get_range2(&md->bl, ms[i].skill_id,ms[i].skill_lv)) + || !unit->skilluse_pos2(&md->bl, x, y,ms[i].skill_id, ms[i].skill_lv,ms[i].casttime, ms[i].cancel) + ) { + map->freeblock_unlock(); continue; } } else { @@ -3214,12 +3192,12 @@ int mobskill_use(struct mob_data *md, unsigned int tick, int event) skill->get_range2(&md->bl, ms[i].skill_id, ms[i].skill_lv)); break; case MST_TARGET: - bl = iMap->id2bl(md->target_id); + bl = map->id2bl(md->target_id); break; case MST_MASTER: bl = &md->bl; if (md->master_id) - bl = iMap->id2bl(md->master_id); + bl = map->id2bl(md->master_id); if (bl) //Otherwise, fall through. break; case MST_FRIEND: @@ -3237,11 +3215,11 @@ int mobskill_use(struct mob_data *md, unsigned int tick, int event) if (!bl) continue; md->skill_idx = i; - iMap->freeblock_lock(); - if( !battle->check_range(&md->bl,bl,skill->get_range2(&md->bl, ms[i].skill_id,ms[i].skill_lv)) || - !unit->skilluse_id2(&md->bl, bl->id,ms[i].skill_id, ms[i].skill_lv,ms[i].casttime, ms[i].cancel) ) - { - iMap->freeblock_unlock(); + map->freeblock_lock(); + if( !battle->check_range(&md->bl,bl,skill->get_range2(&md->bl, ms[i].skill_id,ms[i].skill_lv)) + || !unit->skilluse_id2(&md->bl, bl->id,ms[i].skill_id, ms[i].skill_lv,ms[i].casttime, ms[i].cancel) + ) { + map->freeblock_unlock(); continue; } } @@ -3261,7 +3239,7 @@ int mobskill_use(struct mob_data *md, unsigned int tick, int event) md->skilldelay[j]=tick; } else md->skilldelay[i]=tick; - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 1; } //No skill was used. @@ -3338,7 +3316,7 @@ int mob_clone_spawn(struct map_session_data *sd, int16 m, int16 x, int16 y, cons strcpy(db->sprite,sd->status.name); strcpy(db->name,sd->status.name); strcpy(db->jname,sd->status.name); - db->lv=iStatus->get_lv(&sd->bl); + db->lv=status->get_lv(&sd->bl); memcpy(mstatus, &sd->base_status, sizeof(struct status_data)); mstatus->rhw.atk2= mstatus->dex + mstatus->rhw.atk + mstatus->rhw.atk2; //Max ATK mstatus->rhw.atk = mstatus->dex; //Min ATK @@ -3373,7 +3351,7 @@ int mob_clone_spawn(struct map_session_data *sd, int16 m, int16 x, int16 y, cons int idx = skill_tree[pc->class2idx(sd->status.class_)][j].idx; skill_id = skill_tree[pc->class2idx(sd->status.class_)][j].id; if (!skill_id || sd->status.skill[idx].lv < 1 || - (skill_db[idx].inf2&(INF2_WEDDING_SKILL|INF2_GUILD_SKILL)) + (skill->db[idx].inf2&(INF2_WEDDING_SKILL|INF2_GUILD_SKILL)) ) continue; for(h = 0; h < maplist[sd->bl.m].zone->disabled_skills_count; h++) { @@ -3406,7 +3384,7 @@ int mob_clone_spawn(struct map_session_data *sd, int16 m, int16 x, int16 y, cons ms[i].casttime = skill->cast_fix(&sd->bl,skill_id, ms[i].skill_lv); ms[i].delay = 5000+skill->delay_fix(&sd->bl,skill_id, ms[i].skill_lv); - inf = skill_db[idx].inf; + inf = skill->db[idx].inf; if (inf&INF_ATTACK_SKILL) { ms[i].target = MST_TARGET; ms[i].cond1 = MSC_ALWAYS; @@ -3747,7 +3725,7 @@ bool mob_parse_dbrow(char** str) { data.bl.type = BL_MOB; data.level = db->lv; memcpy(&data.status, mstatus, sizeof(struct status_data)); - iStatus->calc_misc(&data.bl, mstatus, db->lv); + status->calc_misc(&data.bl, mstatus, db->lv); // MVP EXP Bonus: MEXP // Some new MVP's MEXP multipled by high exp-rate cause overflow. [LuzZza] @@ -3891,22 +3869,21 @@ void mob_readdb(void) { for( fi = 0; fi < ARRAYLENGTH(filename); ++fi ) { if(fi > 0) { char filepath[256]; - sprintf(filepath, "%s/%s", iMap->db_path, filename[fi]); + sprintf(filepath, "%s/%s", map->db_path, filename[fi]); if(!exists(filepath)) { continue; } } - sv->readdb(iMap->db_path, filename[fi], ',', 31+2*MAX_MVP_DROP+2*MAX_MOB_DROP, 31+2*MAX_MVP_DROP+2*MAX_MOB_DROP, -1, mob->readdb_sub); + sv->readdb(map->db_path, filename[fi], ',', 31+2*MAX_MVP_DROP+2*MAX_MOB_DROP, 31+2*MAX_MVP_DROP+2*MAX_MOB_DROP, -1, mob->readdb_sub); } } /*========================================== * mob_db table reading *------------------------------------------*/ -int mob_read_sqldb(void) -{ - const char* mob_db_name[] = { iMap->mob_db_db, iMap->mob_db2_db }; +int mob_read_sqldb(void) { + const char* mob_db_name[] = { map->mob_db_db, map->mob_db2_db }; int fi; for( fi = 0; fi < ARRAYLENGTH(mob_db_name); ++fi ) { @@ -4014,7 +3991,7 @@ int mob_read_randommonster(void) for( i = 0; i < ARRAYLENGTH(mobfile) && i < MAX_RANDOMMONSTER; i++ ) { unsigned int count = 0; mob->db_data[0]->summonper[i] = 1002; // Default fallback value, in case the database does not provide one - sprintf(line, "%s/%s", iMap->db_path, mobfile[i]); + sprintf(line, "%s/%s", map->db_path, mobfile[i]); fp=fopen(line,"r"); if(fp==NULL){ ShowError("can't read %s\n",line); @@ -4127,7 +4104,7 @@ void mob_readchatdb(void) { char line[1024], filepath[256]; int i, tmp=0; FILE *fp; - sprintf(filepath, "%s/%s", iMap->db_path, arc); + sprintf(filepath, "%s/%s", map->db_path, arc); fp=fopen(filepath, "r"); if(fp == NULL) { ShowWarning("mob_readchatdb: File not found \"%s\", skipping.\n", filepath); @@ -4344,13 +4321,13 @@ bool mob_parse_row_mobskilldb(char** str, int columns, int current) if ( skill->get_casttype2(sidx) == CAST_GROUND) {//Ground skill. if (ms->target > MST_AROUND) { ShowWarning("mob_parse_row_mobskilldb: Wrong mob skill target for ground skill %d (%s) for %s.\n", - ms->skill_id, skill_db[sidx].name, + ms->skill_id, skill->db[sidx].name, mob_id < 0?"all mobs":mob->db_data[mob_id]->sprite); ms->target = MST_TARGET; } } else if (ms->target > MST_MASTER) { ShowWarning("mob_parse_row_mobskilldb: Wrong mob skill target 'around' for non-ground skill %d (%s) for %s.\n", - ms->skill_id, skill_db[sidx].name, + ms->skill_id, skill->db[sidx].name, mob_id < 0?"all mobs":mob->db_data[mob_id]->sprite); ms->target = MST_TARGET; } @@ -4448,13 +4425,13 @@ void mob_readskilldb(void) { for( fi = 0; fi < ARRAYLENGTH(filename); ++fi ) { if(fi > 0) { char filepath[256]; - sprintf(filepath, "%s/%s", iMap->db_path, filename[fi]); + sprintf(filepath, "%s/%s", map->db_path, filename[fi]); if(!exists(filepath)) { continue; } } - sv->readdb(iMap->db_path, filename[fi], ',', 19, 19, -1, mob->parse_row_mobskilldb); + sv->readdb(map->db_path, filename[fi], ',', 19, 19, -1, mob->parse_row_mobskilldb); } } @@ -4463,9 +4440,8 @@ void mob_readskilldb(void) { * not overly sure if this is all correct * seems to work though... */ -int mob_read_sqlskilldb(void) -{ - const char* mob_skill_db_name[] = { iMap->mob_skill_db_db, iMap->mob_skill_db2_db }; +int mob_read_sqlskilldb(void) { + const char* mob_skill_db_name[] = { map->mob_skill_db_db, map->mob_skill_db2_db }; int fi; if( battle_config.mob_skill_rate == 0 ) { @@ -4568,24 +4544,20 @@ bool mob_readdb_itemratio(char* str[], int columns, int current) * read all mob-related databases */ void mob_load(void) { - sv->readdb(iMap->db_path, "mob_item_ratio.txt", ',', 2, 2+MAX_ITEMRATIO_MOBS, -1, mob->readdb_itemratio); // must be read before mobdb + sv->readdb(map->db_path, "mob_item_ratio.txt", ',', 2, 2+MAX_ITEMRATIO_MOBS, -1, mob->readdb_itemratio); // must be read before mobdb mob->readchatdb(); - if (iMap->db_use_sql_mob_db) - { + if (map->db_use_sql_mob_db) { mob->read_sqldb(); } - if (iMap->db_use_sql_mob_skill_db) - { + if (map->db_use_sql_mob_skill_db) { mob->read_sqlskilldb(); - } - else - { + } else { mob->readdb(); mob->readskilldb(); } - sv->readdb(iMap->db_path, "mob_avail.txt", ',', 2, 12, -1, mob->readdb_mobavail); + sv->readdb(map->db_path, "mob_avail.txt", ',', 2, 12, -1, mob->readdb_mobavail); mob->read_randommonster(); - sv->readdb(iMap->db_path, DBPATH"mob_race2_db.txt", ',', 2, 20, -1, mob->readdb_race2); + sv->readdb(map->db_path, DBPATH"mob_race2_db.txt", ',', 2, 20, -1, mob->readdb_race2); } void mob_reload(void) { diff --git a/src/map/npc.c b/src/map/npc.c index fb106d2d6..21e4221da 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -78,14 +78,14 @@ struct view_data* npc_get_viewdata(int class_) /// Returns a new npc id that isn't being used in id_db. /// Fatal error if nothing is available. int npc_get_new_npc_id(void) { - if( npc_id >= START_NPC_NUM && !iMap->blid_exists(npc_id) ) + if( npc_id >= START_NPC_NUM && !map->blid_exists(npc_id) ) return npc_id++;// available else {// find next id int base_id = npc_id; while( base_id != ++npc_id ) { if( npc_id < START_NPC_NUM ) npc_id = START_NPC_NUM; - if( !iMap->blid_exists(npc_id) ) + if( !map->blid_exists(npc_id) ) return npc_id++;// available } // full loop, nothing available @@ -104,12 +104,11 @@ int npc_isnear_sub(struct block_list* bl, va_list args) { } bool npc_isnear(struct block_list * bl) { - - if( battle_config.min_npc_vendchat_distance > 0 && - iMap->foreachinrange(npc->isnear_sub,bl, battle_config.min_npc_vendchat_distance, BL_NPC) ) - return true; - - return false; + if( battle_config.min_npc_vendchat_distance > 0 + && map->foreachinrange(npc->isnear_sub,bl, battle_config.min_npc_vendchat_distance, BL_NPC) ) + return true; + + return false; } int npc_ontouch_event(struct map_session_data *sd, struct npc_data *nd) @@ -197,8 +196,8 @@ int npc_enable(const char* name, int flag) } else clif->changeoption(&nd->bl); - if( flag&3 && (nd->u.scr.xs >= 0 || nd->u.scr.ys >= 0) ) //check if player standing on a OnTouchArea - iMap->foreachinarea( npc->enable_sub, nd->bl.m, nd->bl.x-nd->u.scr.xs, nd->bl.y-nd->u.scr.ys, nd->bl.x+nd->u.scr.xs, nd->bl.y+nd->u.scr.ys, BL_PC, nd ); + if( flag&3 && (nd->u.scr.xs >= 0 || nd->u.scr.ys >= 0) ) //check if player standing on a OnTouchArea + map->foreachinarea( npc->enable_sub, nd->bl.m, nd->bl.x-nd->u.scr.xs, nd->bl.y-nd->u.scr.ys, nd->bl.x+nd->u.scr.xs, nd->bl.y+nd->u.scr.ys, BL_PC, nd ); return 0; } @@ -220,7 +219,7 @@ struct npc_data* npc_name2id(const char* name) int npc_rr_secure_timeout_timer(int tid, unsigned int tick, int id, intptr_t data) { struct map_session_data* sd = NULL; unsigned int timeout = NPC_SECURE_TIMEOUT_NEXT; - if( (sd = iMap->id2sd(id)) == NULL || !sd->npc_id ) { + if( (sd = map->id2sd(id)) == NULL || !sd->npc_id ) { if( sd ) sd->npc_idle_timer = INVALID_TIMER; return 0;//Not logged in anymore OR no longer attached to a npc } @@ -347,7 +346,7 @@ void npc_event_doall_sub(void *key, void *data, va_list ap) if(rid) { // a player may only have 1 script running at the same time char buf[EVENT_NAME_LENGTH]; snprintf(buf, ARRAYLENGTH(buf), "%s::%s", ev->nd->exname, name); - npc->event_sub(iMap->id2sd(rid), ev, buf); + npc->event_sub(map->id2sd(rid), ev, buf); } else { script->run(ev->nd->u.scr.script, ev->pos, rid, ev->nd->bl.id); @@ -494,23 +493,20 @@ struct timer_event_data { /*========================================== * triger 'OnTimerXXXX' events *------------------------------------------*/ -int npc_timerevent(int tid, unsigned int tick, int id, intptr_t data) -{ +int npc_timerevent(int tid, unsigned int tick, int id, intptr_t data) { int old_rid, old_timer; unsigned int old_tick; - struct npc_data* nd=(struct npc_data *)iMap->id2bl(id); + struct npc_data* nd=(struct npc_data *)map->id2bl(id); struct npc_timerevent_list *te; struct timer_event_data *ted = (struct timer_event_data*)data; struct map_session_data *sd=NULL; - if( nd == NULL ) - { + if( nd == NULL ) { ShowError("npc_timerevent: NPC not found??\n"); return 0; } - if( ted->rid && !(sd = iMap->id2sd(ted->rid)) ) - { + if( ted->rid && !(sd = map->id2sd(ted->rid)) ) { ShowError("npc_timerevent: Attached player not found.\n"); ers_free(npc->timer_event_ers, ted); return 0; @@ -522,9 +518,9 @@ int npc_timerevent(int tid, unsigned int tick, int id, intptr_t data) old_timer = nd->u.scr.timer; // Set the values of the timer - nd->u.scr.rid = sd?sd->bl.id:0; //attached rid - nd->u.scr.timertick = tick; //current time tick - nd->u.scr.timer = ted->time; //total time from beginning to now + nd->u.scr.rid = sd?sd->bl.id:0; //attached rid + nd->u.scr.timertick = tick; //current time tick + nd->u.scr.timer = ted->time; //total time from beginning to now // Locate the event te = nd->u.scr.timer_event + ted->next; @@ -566,8 +562,7 @@ int npc_timerevent(int tid, unsigned int tick, int id, intptr_t data) /*========================================== * Start/Resume NPC timer *------------------------------------------*/ -int npc_timerevent_start(struct npc_data* nd, int rid) -{ +int npc_timerevent_start(struct npc_data* nd, int rid) { int j; unsigned int tick = timer->gettick(); struct map_session_data *sd = NULL; //Player to whom script is attached. @@ -577,8 +572,8 @@ int npc_timerevent_start(struct npc_data* nd, int rid) // Check if there is an OnTimer Event ARR_FIND( 0, nd->u.scr.timeramount, j, nd->u.scr.timer_event[j].timer > nd->u.scr.timer ); - if( nd->u.scr.rid > 0 && !(sd = iMap->id2sd(nd->u.scr.rid)) ) - { // Failed to attach timer to this player. + if( nd->u.scr.rid > 0 && !(sd = map->id2sd(nd->u.scr.rid)) ) { + // Failed to attach timer to this player. ShowError("npc_timerevent_start: Attached player not found!\n"); return 1; } @@ -627,8 +622,7 @@ int npc_timerevent_stop(struct npc_data* nd) nullpo_ret(nd); - if( nd->u.scr.rid && !(sd = iMap->id2sd(nd->u.scr.rid)) ) - { + if( nd->u.scr.rid && !(sd = map->id2sd(nd->u.scr.rid)) ) { ShowError("npc_timerevent_stop: Attached player not found!\n"); return 1; } @@ -673,7 +667,7 @@ void npc_timerevent_quit(struct map_session_data* sd) } // Delete timer - nd = (struct npc_data *)iMap->id2bl(td->id); + nd = (struct npc_data *)map->id2bl(td->id); ted = (struct timer_event_data*)td->data; timer->delete(sd->npc_timer_id, npc->timerevent); sd->npc_timer_id = INVALID_TIMER; @@ -820,14 +814,13 @@ int npc_event(struct map_session_data* sd, const char* eventname, int ontouch) /*========================================== * Sub chk then execute area event type *------------------------------------------*/ -int npc_touch_areanpc_sub(struct block_list *bl, va_list ap) -{ +int npc_touch_areanpc_sub(struct block_list *bl, va_list ap) { struct map_session_data *sd; int pc_id; char *name; nullpo_ret(bl); - nullpo_ret((sd = iMap->id2sd(bl->id))); + nullpo_ret((sd = map->id2sd(bl->id))); pc_id = va_arg(ap,int); name = va_arg(ap,char*); @@ -848,9 +841,8 @@ int npc_touch_areanpc_sub(struct block_list *bl, va_list ap) * Chk if sd is still touching his assigned npc. * If not, it unsets it and searches for another player in range. *------------------------------------------*/ -int npc_touchnext_areanpc(struct map_session_data* sd, bool leavemap) -{ - struct npc_data *nd = iMap->id2nd(sd->touching_id); +int npc_touchnext_areanpc(struct map_session_data* sd, bool leavemap) { + struct npc_data *nd = map->id2nd(sd->touching_id); short xs, ys; if( !nd || nd->touching_id != sd->bl.id ) @@ -868,7 +860,7 @@ int npc_touchnext_areanpc(struct map_session_data* sd, bool leavemap) nd->touching_id = sd->touching_id = 0; snprintf(name, ARRAYLENGTH(name), "%s::%s", nd->exname, script->config.ontouch_name); - iMap->forcountinarea(npc->touch_areanpc_sub,nd->bl.m,nd->bl.x - xs,nd->bl.y - ys,nd->bl.x + xs,nd->bl.y + ys,1,BL_PC,sd->bl.id,name); + map->forcountinarea(npc->touch_areanpc_sub,nd->bl.m,nd->bl.x - xs,nd->bl.y - ys,nd->bl.x + xs,nd->bl.y + ys,1,BL_PC,sd->bl.id,name); } return 0; } @@ -993,7 +985,7 @@ int npc_touch_areanpc2(struct mob_data *md) // In the npc touch area switch( maplist[m].npc[i]->subtype ) { case WARP: - xs = iMap->mapindex2mapid(maplist[m].npc[i]->u.warp.mapindex); + xs = map->mapindex2mapid(maplist[m].npc[i]->u.warp.mapindex); if( m < 0 ) break; // Cannot Warp between map servers if( unit->warp(&md->bl, xs, maplist[m].npc[i]->u.warp.x, maplist[m].npc[i]->u.warp.y, CLR_OUTSIGHT) == 0 ) @@ -1008,7 +1000,7 @@ int npc_touch_areanpc2(struct mob_data *md) 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 + if( map->id2md(id) == NULL ) return 1; // Not Warped, but killed break; } @@ -1037,8 +1029,8 @@ int npc_check_areanpc(int flag, int16 m, int16 x, int16 y, int16 range) { //First check for npc_cells on the range given i = 0; for (ys = y0; ys <= y1 && !i; ys++) { - for(xs = x0; xs <= x1 && !i; xs++){ - if (iMap->getcell(m,xs,ys,CELL_CHKNPC)) + for(xs = x0; xs <= x1 && !i; xs++) { + if (map->getcell(m,xs,ys,CELL_CHKNPC)) i = 1; } } @@ -1191,8 +1183,8 @@ int npc_scriptcont(struct map_session_data* sd, int id, bool closing) nullpo_retr(1, sd); if( id != sd->npc_id ){ - TBL_NPC* nd_sd=(TBL_NPC*)iMap->id2bl(sd->npc_id); - TBL_NPC* nd=(TBL_NPC*)iMap->id2bl(id); + TBL_NPC* nd_sd=(TBL_NPC*)map->id2bl(sd->npc_id); + TBL_NPC* nd=(TBL_NPC*)map->id2bl(id); ShowDebug("npc_scriptcont: %s (sd->npc_id=%d) is not %s (id=%d).\n", nd_sd?(char*)nd_sd->name:"'Unknown NPC'", (int)sd->npc_id, nd?(char*)nd->name:"'Unknown NPC'", (int)id); @@ -1200,7 +1192,7 @@ int npc_scriptcont(struct map_session_data* sd, int id, bool closing) } if(id != npc->fake_nd->bl.id) { // Not item script - if ((npc->checknear(sd,iMap->id2bl(id))) == NULL){ + if ((npc->checknear(sd,map->id2bl(id))) == NULL){ ShowWarning("npc_scriptcont: failed npc->checknear test.\n"); return 1; } @@ -1232,13 +1224,12 @@ int npc_scriptcont(struct map_session_data* sd, int id, bool closing) /*========================================== * Chk if valid call then open buy or selling list *------------------------------------------*/ -int npc_buysellsel(struct map_session_data* sd, int id, int type) -{ +int npc_buysellsel(struct map_session_data* sd, int id, int type) { struct npc_data *nd; nullpo_retr(1, sd); - if ((nd = npc->checknear(sd,iMap->id2bl(id))) == NULL) + if ((nd = npc->checknear(sd,map->id2bl(id))) == NULL) return 1; if (nd->subtype!=SHOP) { @@ -1268,83 +1259,77 @@ int npc_buysellsel(struct map_session_data* sd, int id, int type) /*========================================== * Cash Shop Buy List *------------------------------------------*/ -int npc_cashshop_buylist(struct map_session_data *sd, int points, int count, unsigned short* item_list) -{ - int i, j, nameid, amount, new_, w, vt; - struct npc_data *nd = (struct npc_data *)iMap->id2bl(sd->npc_shopid); - - if( !nd || nd->subtype != CASHSHOP ) - return 1; - - if( sd->state.trading ) - return 4; - - new_ = 0; - w = 0; - vt = 0; // Global Value - - // Validating Process ---------------------------------------------------- - for( i = 0; i < count; i++ ) - { - nameid = item_list[i*2+1]; - amount = item_list[i*2+0]; - - if( !itemdb->exists(nameid) || amount <= 0 ) - return 5; - - ARR_FIND(0,nd->u.shop.count,j,nd->u.shop.shop_item[j].nameid == nameid); - if( j == nd->u.shop.count || nd->u.shop.shop_item[j].value <= 0 ) - return 5; - - if( !itemdb->isstackable(nameid) && amount > 1 ) - { - ShowWarning("Player %s (%d:%d) sent a hexed packet trying to buy %d of nonstackable item %d!\n", sd->status.name, sd->status.account_id, sd->status.char_id, amount, nameid); - amount = item_list[i*2+0] = 1; - } - - switch( pc->checkadditem(sd,nameid,amount) ) - { - case ADDITEM_NEW: - new_++; - break; - case ADDITEM_OVERAMOUNT: - return 3; - } - - vt += nd->u.shop.shop_item[j].value * amount; - w += itemdb_weight(nameid) * amount; - } - - if( w + sd->weight > sd->max_weight ) - return 3; - if( pc->inventoryblank(sd) < new_ ) - return 3; - if( points > vt ) points = vt; - - // Payment Process ---------------------------------------------------- - if( sd->kafraPoints < points || sd->cashPoints < (vt - points) ) - return 6; - pc->paycash(sd,vt,points); - - // Delivery Process ---------------------------------------------------- - for( i = 0; i < count; i++ ) - { - struct item item_tmp; - - nameid = item_list[i*2+1]; - amount = item_list[i*2+0]; - - memset(&item_tmp,0,sizeof(item_tmp)); - - if( !pet->create_egg(sd,nameid) ) - { - item_tmp.nameid = nameid; - item_tmp.identify = 1; - pc->additem(sd,&item_tmp,amount,LOG_TYPE_NPC); - } - } - - return 0; +int npc_cashshop_buylist(struct map_session_data *sd, int points, int count, unsigned short* item_list) { + int i, j, nameid, amount, new_, w, vt; + struct npc_data *nd = (struct npc_data *)map->id2bl(sd->npc_shopid); + + if( !nd || nd->subtype != CASHSHOP ) + return 1; + + if( sd->state.trading ) + return 4; + + new_ = 0; + w = 0; + vt = 0; // Global Value + + // Validating Process ---------------------------------------------------- + for( i = 0; i < count; i++ ) { + nameid = item_list[i*2+1]; + amount = item_list[i*2+0]; + + if( !itemdb->exists(nameid) || amount <= 0 ) + return 5; + + ARR_FIND(0,nd->u.shop.count,j,nd->u.shop.shop_item[j].nameid == nameid); + if( j == nd->u.shop.count || nd->u.shop.shop_item[j].value <= 0 ) + return 5; + + if( !itemdb->isstackable(nameid) && amount > 1 ) { + ShowWarning("Player %s (%d:%d) sent a hexed packet trying to buy %d of nonstackable item %d!\n", sd->status.name, sd->status.account_id, sd->status.char_id, amount, nameid); + amount = item_list[i*2+0] = 1; + } + + switch( pc->checkadditem(sd,nameid,amount) ) { + case ADDITEM_NEW: + new_++; + break; + case ADDITEM_OVERAMOUNT: + return 3; + } + + vt += nd->u.shop.shop_item[j].value * amount; + w += itemdb_weight(nameid) * amount; + } + + if( w + sd->weight > sd->max_weight ) + return 3; + if( pc->inventoryblank(sd) < new_ ) + return 3; + if( points > vt ) points = vt; + + // Payment Process ---------------------------------------------------- + if( sd->kafraPoints < points || sd->cashPoints < (vt - points) ) + return 6; + pc->paycash(sd,vt,points); + + // Delivery Process ---------------------------------------------------- + for( i = 0; i < count; i++ ) { + struct item item_tmp; + + nameid = item_list[i*2+1]; + amount = item_list[i*2+0]; + + memset(&item_tmp,0,sizeof(item_tmp)); + + if( !pet->create_egg(sd,nameid) ) { + item_tmp.nameid = nameid; + item_tmp.identify = 1; + pc->additem(sd,&item_tmp,amount,LOG_TYPE_NPC); + } + } + + return 0; } //npc_buylist for script-controlled shops. @@ -1375,9 +1360,8 @@ int npc_buylist_sub(struct map_session_data* sd, int n, unsigned short* item_lis /*========================================== * Cash Shop Buy *------------------------------------------*/ -int npc_cashshop_buy(struct map_session_data *sd, int nameid, int amount, int points) -{ - struct npc_data *nd = (struct npc_data *)iMap->id2bl(sd->npc_shopid); +int npc_cashshop_buy(struct map_session_data *sd, int nameid, int amount, int points) { + struct npc_data *nd = (struct npc_data *)map->id2bl(sd->npc_shopid); struct item_data *item; int i, price, w; @@ -1458,8 +1442,7 @@ int npc_cashshop_buy(struct map_session_data *sd, int nameid, int amount, int po /// /// @param item_list 'n' pairs <amount,itemid> /// @return result code for clif->parse_NpcBuyListSend -int npc_buylist(struct map_session_data* sd, int n, unsigned short* item_list) -{ +int npc_buylist(struct map_session_data* sd, int n, unsigned short* item_list) { struct npc_data* nd; double z; int i,j,w,skill_t,new_, idx = skill->get_index(MC_DISCOUNT); @@ -1467,7 +1450,7 @@ int npc_buylist(struct map_session_data* sd, int n, unsigned short* item_list) nullpo_retr(3, sd); nullpo_retr(3, item_list); - nd = npc->checknear(sd,iMap->id2bl(sd->npc_shopid)); + nd = npc->checknear(sd,map->id2bl(sd->npc_shopid)); if( nd == NULL ) return 3; if( nd->subtype != SHOP ) @@ -1631,8 +1614,7 @@ int npc_selllist_sub(struct map_session_data* sd, int n, unsigned short* item_li /// /// @param item_list 'n' pairs <index,amount> /// @return result code for clif->parse_NpcSellListSend -int npc_selllist(struct map_session_data* sd, int n, unsigned short* item_list) -{ +int npc_selllist(struct map_session_data* sd, int n, unsigned short* item_list) { double z; int i,skill_t, idx = skill->get_index(MC_OVERCHARGE); struct npc_data *nd; @@ -1640,7 +1622,7 @@ int npc_selllist(struct map_session_data* sd, int n, unsigned short* item_list) nullpo_retr(1, sd); nullpo_retr(1, item_list); - if( ( nd = npc->checknear(sd, iMap->id2bl(sd->npc_shopid)) ) == NULL || nd->subtype != SHOP ) { + if( ( nd = npc->checknear(sd, map->id2bl(sd->npc_shopid)) ) == NULL || nd->subtype != SHOP ) { return 1; } @@ -1721,10 +1703,10 @@ int npc_remove_map(struct npc_data* nd) { if(nd->bl.prev == NULL || nd->bl.m < 0) return 1; //Not assigned to a map. - m = nd->bl.m; + m = nd->bl.m; clif->clearunit_area(&nd->bl,CLR_RESPAWN); npc->unsetcells(nd); - iMap->delblock(&nd->bl); + map->delblock(&nd->bl); //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? @@ -1776,9 +1758,8 @@ int npc_unload_dup_sub(struct npc_data* nd, va_list args) } //Removes all npcs that are duplicates of the passed one. [Skotlex] -void npc_unload_duplicates(struct npc_data* nd) -{ - iMap->map_foreachnpc(npc->unload_dup_sub,nd->bl.id); +void npc_unload_duplicates(struct npc_data* nd) { + map->map_foreachnpc(npc->unload_dup_sub,nd->bl.id); } //Removes an npc from map and db. @@ -1787,12 +1768,12 @@ int npc_unload(struct npc_data* nd, bool single) { nullpo_ret(nd); npc->remove_map(nd); - iMap->deliddb(&nd->bl); + map->deliddb(&nd->bl); if( single ) strdb_remove(npc->name_db, nd->exname); if (nd->chat_id) // remove npc chatroom object and kick users - chat->deletenpcchat(nd); + chat->delete_npc_chat(nd); #ifdef PCRE_SUPPORT npc_chat->finalize(nd); // deallocate npc PCRE data structures @@ -2039,7 +2020,7 @@ struct npc_data* npc_add_warp(char* name, short from_mapid, short from_x, short CREATE(nd, struct npc_data, 1); nd->bl.id = npc->get_new_npc_id(); - iMap->addnpc(from_mapid, nd); + map->addnpc(from_mapid, nd); nd->bl.prev = nd->bl.next = NULL; nd->bl.m = from_mapid; nd->bl.x = from_x; @@ -2070,8 +2051,8 @@ struct npc_data* npc_add_warp(char* name, short from_mapid, short from_x, short nd->bl.type = BL_NPC; nd->subtype = WARP; npc->setcells(nd); - iMap->addblock(&nd->bl); - iStatus->set_viewdata(&nd->bl, nd->class_); + map->addblock(&nd->bl); + status->set_viewdata(&nd->bl, nd->class_); nd->ud = &npc->base_ud; if( maplist[nd->bl.m].users ) clif->spawn(&nd->bl); @@ -2097,7 +2078,7 @@ const char* npc_parse_warp(char* w1, char* w2, char* w3, char* w4, const char* s return strchr(start,'\n');// skip and continue } - m = iMap->mapname2mapid(mapname); + m = map->mapname2mapid(mapname); i = mapindex_name2id(to_mapname); if( i == 0 ) { @@ -2113,7 +2094,7 @@ const char* npc_parse_warp(char* w1, char* w2, char* w3, char* w4, const char* s CREATE(nd, struct npc_data, 1); nd->bl.id = npc->get_new_npc_id(); - iMap->addnpc(m, nd); + map->addnpc(m, nd); nd->bl.prev = nd->bl.next = NULL; nd->bl.m = m; nd->bl.x = x; @@ -2135,8 +2116,8 @@ const char* npc_parse_warp(char* w1, char* w2, char* w3, char* w4, const char* s nd->bl.type = BL_NPC; nd->subtype = WARP; npc->setcells(nd); - iMap->addblock(&nd->bl); - iStatus->set_viewdata(&nd->bl, nd->class_); + map->addblock(&nd->bl); + status->set_viewdata(&nd->bl, nd->class_); nd->ud = &npc->base_ud; if( maplist[nd->bl.m].users ) clif->spawn(&nd->bl); @@ -2168,7 +2149,7 @@ const char* npc_parse_shop(char* w1, char* w2, char* w3, char* w4, const char* s return strchr(start,'\n');// skip and continue } - m = iMap->mapname2mapid(mapname); + m = map->mapname2mapid(mapname); } if( m != -1 && ( x < 0 || x >= maplist[m].xs || y < 0 || y >= maplist[m].ys ) ) { @@ -2246,15 +2227,15 @@ const char* npc_parse_shop(char* w1, char* w2, char* w3, char* w4, const char* s nd->bl.type = BL_NPC; nd->subtype = type; if( m >= 0 ) {// normal shop npc - iMap->addnpc(m,nd); - iMap->addblock(&nd->bl); - iStatus->set_viewdata(&nd->bl, nd->class_); + map->addnpc(m,nd); + map->addblock(&nd->bl); + status->set_viewdata(&nd->bl, nd->class_); nd->ud = &npc->base_ud; nd->dir = dir; if( maplist[nd->bl.m].users ) clif->spawn(&nd->bl); } else {// 'floating' shop? - iMap->addiddb(&nd->bl); + map->addiddb(&nd->bl); } strdb_put(npc->name_db, nd->exname, nd); @@ -2370,15 +2351,12 @@ const char* npc_parse_script(char* w1, char* w2, char* w3, char* w4, const char* x = 0; y = 0; m = -1; - } - else - {// npc in a map - if( sscanf(w1, "%31[^,],%d,%d,%d", mapname, &x, &y, &dir) != 4 ) - { + } else {// npc in a map + if( sscanf(w1, "%31[^,],%d,%d,%d", mapname, &x, &y, &dir) != 4 ) { ShowError("npc_parse_script: Invalid placement format for a script in file '%s', line '%d'. Skipping the rest of file...\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer,start-buffer), w1, w2, w3, w4); return NULL;// unknown format, don't continue } - m = iMap->mapname2mapid(mapname); + m = map->mapname2mapid(mapname); } script_start = strstr(start,",{"); @@ -2434,19 +2412,19 @@ const char* npc_parse_script(char* w1, char* w2, char* w3, char* w4, const char* nd->subtype = SCRIPT; if( m >= 0 ) { - iMap->addnpc(m, nd); + map->addnpc(m, nd); nd->ud = &npc->base_ud; nd->dir = dir; npc->setcells(nd); - iMap->addblock(&nd->bl); + map->addblock(&nd->bl); if( class_ >= 0 ) { - iStatus->set_viewdata(&nd->bl, nd->class_); + status->set_viewdata(&nd->bl, nd->class_); if( maplist[nd->bl.m].users ) clif->spawn(&nd->bl); } } else { - // we skip iMap->addnpc, but still add it to the list of ID's - iMap->addiddb(&nd->bl); + // we skip map->addnpc, but still add it to the list of ID's + map->addiddb(&nd->bl); } strdb_put(npc->name_db, nd->exname, nd); @@ -2528,7 +2506,7 @@ const char* npc_parse_duplicate(char* w1, char* w2, char* w3, char* w4, const ch ShowError("npc_parse_duplicate: Invalid placement format for duplicate in file '%s', line '%d'. Skipping line...\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer,start-buffer), w1, w2, w3, w4); return end;// next line, try to continue } - m = iMap->mapname2mapid(mapname); + m = map->mapname2mapid(mapname); } if( m != -1 && ( x < 0 || x >= maplist[m].xs || y < 0 || y >= maplist[m].ys ) ) { @@ -2590,19 +2568,19 @@ const char* npc_parse_duplicate(char* w1, char* w2, char* w3, char* w4, const ch //Add the npc to its location if( m >= 0 ) { - iMap->addnpc(m, nd); + map->addnpc(m, nd); nd->ud = &npc->base_ud; nd->dir = dir; npc->setcells(nd); - iMap->addblock(&nd->bl); + map->addblock(&nd->bl); if( class_ >= 0 ) { - iStatus->set_viewdata(&nd->bl, nd->class_); + status->set_viewdata(&nd->bl, nd->class_); if( maplist[nd->bl.m].users ) clif->spawn(&nd->bl); } } else { - // we skip iMap->addnpc, but still add it to the list of ID's - iMap->addiddb(&nd->bl); + // we skip map->addnpc, but still add it to the list of ID's + map->addiddb(&nd->bl); } strdb_put(npc->name_db, nd->exname, nd); @@ -2638,7 +2616,7 @@ int npc_duplicate4instance(struct npc_data *snd, int16 m) { if( snd->subtype == WARP ) { // Adjust destination, if instanced struct npc_data *wnd = NULL; // New NPC - int dm = iMap->mapindex2mapid(snd->u.warp.mapindex), im; + int dm = map->mapindex2mapid(snd->u.warp.mapindex), im; if( dm < 0 ) return 1; if( ( im = instance->mapid2imapid(dm, maplist[m].instance_id) ) == -1 ) { @@ -2648,7 +2626,7 @@ int npc_duplicate4instance(struct npc_data *snd, int16 m) { CREATE(wnd, struct npc_data, 1); wnd->bl.id = npc->get_new_npc_id(); - iMap->addnpc(m, wnd); + map->addnpc(m, wnd); wnd->bl.prev = wnd->bl.next = NULL; wnd->bl.m = m; wnd->bl.x = snd->bl.x; @@ -2665,8 +2643,8 @@ int npc_duplicate4instance(struct npc_data *snd, int16 m) { wnd->bl.type = BL_NPC; wnd->subtype = WARP; npc->setcells(wnd); - iMap->addblock(&wnd->bl); - iStatus->set_viewdata(&wnd->bl, wnd->class_); + map->addblock(&wnd->bl); + status->set_viewdata(&wnd->bl, wnd->class_); wnd->ud = &npc->base_ud; if( maplist[wnd->bl.m].users ) clif->spawn(&wnd->bl); @@ -2713,7 +2691,7 @@ void npc_setcells(struct npc_data* nd) { for (i = y-ys; i <= y+ys; i++) { for (j = x-xs; j <= x+xs; j++) { - if (iMap->getcell(m, j, i, CELL_CHKNOPASS)) + if (map->getcell(m, j, i, CELL_CHKNOPASS)) continue; maplist[m].setcell(m, j, i, CELL_NPC, true); } @@ -2745,10 +2723,10 @@ void npc_unsetcells(struct npc_data* nd) { //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 < 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 < maplist[m].ys-1 && iMap->getcell(m, x, y1, CELL_CHKNPC); y1++); + for(x0 = x-xs; x0 > 0 && map->getcell(m, x0, y, CELL_CHKNPC); x0--); + for(x1 = x+xs; x1 < maplist[m].xs-1 && map->getcell(m, x1, y, CELL_CHKNPC); x1++); + for(y0 = y-ys; y0 > 0 && map->getcell(m, x, y0, CELL_CHKNPC); y0--); + for(y1 = y+ys; y1 < maplist[m].ys-1 && map->getcell(m, x, y1, CELL_CHKNPC); y1++); //Erase this npc's cells for (i = y-ys; i <= y+ys; i++) @@ -2756,7 +2734,7 @@ void npc_unsetcells(struct npc_data* nd) { 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 ); + map->foreachinarea( npc->unsetcells_sub, m, x0, y0, x1, y1, BL_NPC, nd->bl.id ); } void npc_movenpc(struct npc_data* nd, int16 x, int16 y) @@ -2767,9 +2745,9 @@ void npc_movenpc(struct npc_data* nd, int16 x, int16 y) 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); + map->foreachinrange(clif->outsight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl); + map->moveblock(&nd->bl, x, y, timer->gettick()); + map->foreachinrange(clif->insight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl); } /// Changes the display name of the npc. @@ -2789,8 +2767,7 @@ void npc_setdisplayname(struct npc_data* nd, const char* newname) /// /// @param nd Target npc /// @param class_ New display class -void npc_setclass(struct npc_data* nd, short class_) -{ +void npc_setclass(struct npc_data* nd, short class_) { nullpo_retv(nd); if( nd->class_ == class_ ) @@ -2799,7 +2776,7 @@ void npc_setclass(struct npc_data* nd, short class_) if( maplist[nd->bl.m].users ) clif->clearunit_area(&nd->bl, CLR_OUTSIGHT);// fade out nd->class_ = class_; - iStatus->set_viewdata(&nd->bl, class_); + status->set_viewdata(&nd->bl, class_); if( maplist[nd->bl.m].users ) clif->spawn(&nd->bl);// fade in } @@ -2949,7 +2926,7 @@ const char* npc_parse_mob(char* w1, char* w2, char* w3, char* w4, const char* st ShowError("npc_parse_mob: Unknown map '%s' in file '%s', line '%d'.\n", mapname, filepath, strline(buffer,start-buffer)); return strchr(start,'\n');// skip and continue } - m = iMap->mapname2mapid(mapname); + m = map->mapname2mapid(mapname); if( m < 0 )//Not loaded on this map-server instance. return strchr(start,'\n');// skip and continue mobspawn.m = (unsigned short)m; @@ -3060,7 +3037,7 @@ const char* npc_parse_mob(char* w1, char* w2, char* w3, char* w4, const char* st memcpy(data, &mobspawn, sizeof(struct spawn_data)); // spawn / cache the new mobs - if( battle_config.dynamic_mobs && iMap->addmobtolist(data->m, data) >= 0 ) { + if( battle_config.dynamic_mobs && map->addmobtolist(data->m, data) >= 0 ) { data->state.dynamic = true; npc_cache_mob += data->num; @@ -3096,9 +3073,8 @@ const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, const char ShowError("npc_parse_mapflag: Invalid mapflag definition in file '%s', line '%d'.\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer,start-buffer), w1, w2, w3, w4); return strchr(start,'\n');// skip and continue } - m = iMap->mapname2mapid(mapname); - if( m < 0 ) - { + m = map->mapname2mapid(mapname); + if( m < 0 ) { ShowWarning("npc_parse_mapflag: Unknown map in file '%s', line '%d' : %s\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", mapname, filepath, strline(buffer,start-buffer), w1, w2, w3, w4); return strchr(start,'\n');// skip and continue } @@ -3165,7 +3141,7 @@ const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, const char 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)) && maplist[m].zone != zone ) { - iMap->zone_change(m,zone,start,buffer,filepath); + map->zone_change(m,zone,start,buffer,filepath); } else if ( !state ) { maplist[m].zone = &map_zone_pk; } @@ -3215,7 +3191,7 @@ const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, const char 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)) && maplist[m].zone != zone ) { - iMap->zone_change(m,zone,start,buffer,filepath); + map->zone_change(m,zone,start,buffer,filepath); } } else if (!strcmpi(w3,"gvg_noparty")) @@ -3250,7 +3226,7 @@ const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, const char } if( state && (zone = strdb_get(zone_db, MAP_ZONE_BG_NAME)) && maplist[m].zone != zone ) { - iMap->zone_change(m,zone,start,buffer,filepath); + map->zone_change(m,zone,start,buffer,filepath); } } else if (!strcmpi(w3,"noexppenalty")) @@ -3445,7 +3421,7 @@ const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, const char if( !(zone = strdb_get(zone_db, w4)) ) { 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); + map->zone_change(m,zone,start,buffer,filepath); } } else if ( !strcmpi(w3,"nomapchannelautojoin") ) { maplist[m].flag.chsysnolocalaj = state; @@ -3571,9 +3547,9 @@ void npc_parsesrcfile(const char* filepath, bool runOnInit) p = strchr(p,'\n');// next line continue; } - m = iMap->mapname2mapid(mapname); - if( m < 0 ) - {// "mapname" is not assigned to this server, we must skip the script info... + m = map->mapname2mapid(mapname); + if( m < 0 ) { + // "mapname" is not assigned to this server, we must skip the script info... if( strcasecmp(w2,"script") == 0 && count > 3 ) { if((p = npc->skip_script(p,buffer,filepath)) == NULL) @@ -3766,7 +3742,7 @@ int npc_reload(void) { mapit->free(iter); if(battle_config.dynamic_mobs) {// dynamic check by [random] - for (m = 0; m < iMap->map_num; m++) { + for (m = 0; m < map->map_num; m++) { for (i = 0; i < MAX_MOB_LIST_PER_MAP; i++) { if (maplist[m].moblist[i] != NULL) { aFree(maplist[m].moblist[i]); @@ -3774,7 +3750,7 @@ int npc_reload(void) { } if( maplist[m].mob_delete_timer != INVALID_TIMER ) { // Mobs were removed anyway,so delete the timer [Inkfish] - timer->delete(maplist[m].mob_delete_timer, iMap->removemobs_timer); + timer->delete(maplist[m].mob_delete_timer, map->removemobs_timer); maplist[m].mob_delete_timer = INVALID_TIMER; } } @@ -3790,7 +3766,7 @@ int npc_reload(void) { npc_mob = npc_cache_mob = npc_delay_mob = 0; // reset mapflags - iMap->flags_init(); + map->flags_init(); //TODO: the following code is copy-pasted from do_init_npc(); clean it up // Reloading npcs now @@ -3813,7 +3789,7 @@ int npc_reload(void) { instance->destroy(i); } - iMap->zone_init(); + map->zone_init(); npc->motd = npc->name2id("HerculesMOTD"); /* [Ind/Hercules] */ @@ -3877,24 +3853,23 @@ int do_final_npc(void) { return 0; } -void npc_debug_warps_sub(struct npc_data* nd) -{ +void npc_debug_warps_sub(struct npc_data* nd) { int16 m; if (nd->bl.type != BL_NPC || nd->subtype != WARP || nd->bl.m < 0) return; - m = iMap->mapindex2mapid(nd->u.warp.mapindex); + m = map->mapindex2mapid(nd->u.warp.mapindex); if (m < 0) return; //Warps to another map, nothing to do about it. if (nd->u.warp.x == 0 && nd->u.warp.y == 0) return; // random warp - if (iMap->getcell(m, nd->u.warp.x, nd->u.warp.y, CELL_CHKNPC)) { + if (map->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, 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)) { + if (map->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, maplist[nd->bl.m].name, nd->bl.x, nd->bl.y, @@ -3905,7 +3880,7 @@ void npc_debug_warps_sub(struct npc_data* nd) static void npc_debug_warps(void) { int16 m, i; - for (m = 0; m < iMap->map_num; m++) + for (m = 0; m < map->map_num; m++) for (i = 0; i < maplist[m].npc_num; i++) npc->debug_warps_sub(maplist[m].npc[i]); } @@ -3964,7 +3939,7 @@ int do_init_npc(void) itemdb->name_constants(); - iMap->zone_init(); + map->zone_init(); npc->motd = npc->name2id("HerculesMOTD"); /* [Ind/Hercules] */ @@ -3994,7 +3969,7 @@ int do_init_npc(void) strdb_put(npc->name_db, npc->fake_nd->exname, npc->fake_nd); npc->fake_nd->u.scr.timerid = INVALID_TIMER; - iMap->addiddb(&npc->fake_nd->bl); + map->addiddb(&npc->fake_nd->bl); // End of initialization return 0; diff --git a/src/map/npc_chat.c b/src/map/npc_chat.c index 848347888..1372fff21 100644 --- a/src/map/npc_chat.c +++ b/src/map/npc_chat.c @@ -379,7 +379,7 @@ BUILDIN(defpattern) { int setid = script_getnum(st,2); const char* pattern = script_getstr(st,3); const char* label = script_getstr(st,4); - struct npc_data* nd = (struct npc_data *)iMap->id2bl(st->oid); + struct npc_data* nd = (struct npc_data *)map->id2bl(st->oid); npc_chat->def_pattern(nd, setid, pattern, label); @@ -388,7 +388,7 @@ BUILDIN(defpattern) { BUILDIN(activatepset) { int setid = script_getnum(st,2); - struct npc_data* nd = (struct npc_data *)iMap->id2bl(st->oid); + struct npc_data* nd = (struct npc_data *)map->id2bl(st->oid); npc_chat->activate_pcreset(nd, setid); @@ -397,7 +397,7 @@ BUILDIN(activatepset) { BUILDIN(deactivatepset) { int setid = script_getnum(st,2); - struct npc_data* nd = (struct npc_data *)iMap->id2bl(st->oid); + struct npc_data* nd = (struct npc_data *)map->id2bl(st->oid); npc_chat->deactivate_pcreset(nd, setid); @@ -406,7 +406,7 @@ BUILDIN(deactivatepset) { BUILDIN(deletepset) { int setid = script_getnum(st,2); - struct npc_data* nd = (struct npc_data *)iMap->id2bl(st->oid); + struct npc_data* nd = (struct npc_data *)map->id2bl(st->oid); npc_chat->delete_pcreset(nd, setid); diff --git a/src/map/packets_struct.h b/src/map/packets_struct.h index 2bfb10ca3..f39b4a55b 100644 --- a/src/map/packets_struct.h +++ b/src/map/packets_struct.h @@ -453,18 +453,18 @@ struct packet_maptypeproperty2 { short PacketType; short type; struct { - unsigned int party : 1; - unsigned int guild : 1; - unsigned int siege : 1; - unsigned int mineffect : 1; - unsigned int nolockon : 1; - unsigned int countpk : 1; - unsigned int nopartyformation : 1; - unsigned int bg : 1; - unsigned int noitemconsumption : 1; - unsigned int usecart : 1; - unsigned int summonstarmiracle : 1; - unsigned int SpareBits : 15; + unsigned int party : 1; // Show attack cursor on non-party members (PvP) + unsigned int guild : 1; // Show attack cursor on non-guild members (GvG) + unsigned int siege : 1; // Show emblem over characters' heads when in GvG (WoE castle) + unsigned int mineffect : 1; // Automatically enable /mineffect + unsigned int nolockon : 1; // TODO: What does this do? (shows attack cursor on non-party members) + unsigned int countpk : 1; /// Show the PvP counter + unsigned int nopartyformation : 1; /// Prevent party creation/modification + unsigned int bg : 1; // TODO: What does this do? Probably related to Battlegrounds, but I'm not sure on the effect + unsigned int noitemconsumption : 1; // TODO: What does this do? (shows a "Nothing found in the selected map" message when set) + unsigned int usecart : 1; /// Allow opening cart inventory + unsigned int summonstarmiracle : 1; // TODO: What does this do? Related to Taekwon Masters, but I have no idea. + unsigned int SpareBits : 15; /// Currently ignored, reserved for future updates } flag; } __attribute__((packed)); diff --git a/src/map/party.c b/src/map/party.c index 2682cf03b..a4eb38629 100644 --- a/src/map/party.c +++ b/src/map/party.c @@ -84,9 +84,8 @@ struct map_session_data* party_getavailablesd(struct party_data *p) * Retrieves and validates the sd pointer for this party member [Skotlex] *------------------------------------------*/ -static TBL_PC* party_sd_check(int party_id, int account_id, int char_id) -{ - TBL_PC* sd = iMap->id2sd(account_id); +static TBL_PC* party_sd_check(int party_id, int account_id, int char_id) { + TBL_PC* sd = map->id2sd(account_id); if (!(sd && sd->status.char_id == char_id)) return NULL; @@ -179,13 +178,12 @@ int party_create(struct map_session_data *sd,char *name,int item,int item2) } -void party_created(int account_id,int char_id,int fail,int party_id,char *name) -{ +void party_created(int account_id,int char_id,int fail,int party_id,char *name) { struct map_session_data *sd; - sd=iMap->id2sd(account_id); + sd=map->id2sd(account_id); - if (!sd || sd->status.char_id != char_id || !sd->party_creating ) - { //Character logged off before creation ack? + if (!sd || sd->status.char_id != char_id || !sd->party_creating ) { + //Character logged off before creation ack? if (!fail) //break up party since player could not be added to it. intif->party_leave(party_id,account_id,char_id); return; @@ -209,13 +207,12 @@ int party_request_info(int party_id, int char_id) } /// Invoked (from char-server) when the party info is not found. -int party_recv_noinfo(int party_id, int char_id) -{ +int party_recv_noinfo(int party_id, int char_id) { party->broken(party_id); - if( char_id != 0 )// requester - { + if( char_id != 0 ) { + // requester struct map_session_data* sd; - sd = iMap->charid2sd(char_id); + sd = map->charid2sd(char_id); if( sd && sd->status.party_id == party_id ) sd->status.party_id = 0; } @@ -329,9 +326,9 @@ int party_recv_info(struct party* sp, int char_id) } } } - if( char_id != 0 )// requester - { - sd = iMap->charid2sd(char_id); + if( char_id != 0 ) { + // requester + sd = map->charid2sd(char_id); if( sd && sd->status.party_id == sp->party_id && party->getmemberid(p,sd) == -1 ) sd->status.party_id = 0;// was not in the party } @@ -400,8 +397,7 @@ int party_invite(struct map_session_data *sd,struct map_session_data *tsd) return 1; } -void party_reply_invite(struct map_session_data *sd,int party_id,int flag) -{ +void party_reply_invite(struct map_session_data *sd,int party_id,int flag) { struct map_session_data* tsd; struct party_member member; @@ -411,7 +407,7 @@ void party_reply_invite(struct map_session_data *sd,int party_id,int flag) sd->party_invite_account = 0; return; } - tsd = iMap->id2sd(sd->party_invite_account); + tsd = map->id2sd(sd->party_invite_account); if( flag == 1 && !sd->party_creating && !sd->party_joining ) {// accepted and allowed @@ -458,9 +454,8 @@ void party_member_joined(struct map_session_data *sd) /// Invoked (from char-server) when a new member is added to the party. /// flag: 0-success, 1-failure -int party_member_added(int party_id,int account_id,int char_id, int flag) -{ - struct map_session_data *sd = iMap->id2sd(account_id),*sd2; +int party_member_added(int party_id,int account_id,int char_id, int flag) { + struct map_session_data *sd = map->id2sd(account_id),*sd2; struct party_data *p = party->search(party_id); int i, j; @@ -470,7 +465,7 @@ int party_member_added(int party_id,int account_id,int char_id, int flag) return 0; } - sd2 = iMap->id2sd(sd->party_invite_account); + sd2 = map->id2sd(sd->party_invite_account); sd->party_joining = false; sd->party_invite = 0; @@ -565,7 +560,7 @@ int party_leave(struct map_session_data *sd) /// Invoked (from char-server) when a party member leaves the party. int party_member_withdraw(int party_id, int account_id, int char_id) { - struct map_session_data* sd = iMap->id2sd(account_id); + struct map_session_data* sd = map->id2sd(account_id); struct party_data* p = party->search(party_id); if( p ) { @@ -634,10 +629,9 @@ int party_changeoption(struct map_session_data *sd,int exp,int item) return 0; } -int party_optionchanged(int party_id,int account_id,int exp,int item,int flag) -{ +int party_optionchanged(int party_id,int account_id,int exp,int item,int flag) { struct party_data *p; - struct map_session_data *sd=iMap->id2sd(account_id); + struct map_session_data *sd=map->id2sd(account_id); if( (p=party->search(party_id))==NULL) return 0; @@ -1099,17 +1093,16 @@ int party_foreachsamemap(int (*func)(struct block_list*,va_list),struct map_sess list[blockcount++]=&psd->bl; } - iMap->freeblock_lock(); + map->freeblock_lock(); - for(i=0;i<blockcount;i++) - { + for(i=0;i<blockcount;i++) { va_list ap; va_start(ap, range); total += func(list[i], ap); va_end(ap); } - iMap->freeblock_unlock(); + map->freeblock_unlock(); return total; } diff --git a/src/map/pc.c b/src/map/pc.c index 29a59cd69..393caa627 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -156,11 +156,10 @@ bool pc_should_log_commands(struct map_session_data *sd) return pc_group_should_log_commands(sd->group); } -static int pc_invincible_timer(int tid, unsigned int tick, int id, intptr_t data) -{ +static int pc_invincible_timer(int tid, unsigned int tick, int id, intptr_t data) { struct map_session_data *sd; - if( (sd=(struct map_session_data *)iMap->id2sd(id)) == NULL || sd->bl.type!=BL_PC ) + if( (sd=(struct map_session_data *)map->id2sd(id)) == NULL || sd->bl.type!=BL_PC ) return 1; if(sd->invincible_timer != tid){ @@ -195,12 +194,11 @@ void pc_delinvincibletimer(struct map_session_data* sd) } } -static int pc_spiritball_timer(int tid, unsigned int tick, int id, intptr_t data) -{ +static int pc_spiritball_timer(int tid, unsigned int tick, int id, intptr_t data) { struct map_session_data *sd; int i; - if( (sd=(struct map_session_data *)iMap->id2sd(id)) == NULL || sd->bl.type!=BL_PC ) + if( (sd=(struct map_session_data *)map->id2sd(id)) == NULL || sd->bl.type!=BL_PC ) return 1; if( sd->spiritball <= 0 ) @@ -314,7 +312,7 @@ static int pc_check_banding( struct block_list *bl, va_list ap ) { if(pc_isdead(tsd)) return 0; - sc = iStatus->get_sc(bl); + sc = status->get_sc(bl); if( bl == src ) return 0; @@ -341,12 +339,12 @@ int pc_banding(struct map_session_data *sd, uint16 skill_lv) { memset(b_sd, 0, sizeof(b_sd)); i = party_foreachsamemap(pc_check_banding,sd,range,&sd->bl,&c,&b_sd); - if( c < 1 ) //just recalc status no need to recalc hp - { // No more Royal Guards in Banding found. - if( (sc = iStatus->get_sc(&sd->bl)) != NULL && sc->data[SC_BANDING] ) - { + if( c < 1 ) { + //just recalc status no need to recalc hp + if( (sc = status->get_sc(&sd->bl)) != NULL && sc->data[SC_BANDING] ) { + // No more Royal Guards in Banding found. sc->data[SC_BANDING]->val2 = 0; // Reset the counter - status_calc_bl(&sd->bl, iStatus->sc2scb_flag(SC_BANDING)); + status_calc_bl(&sd->bl, status->sc2scb_flag(SC_BANDING)); } return 0; } @@ -356,9 +354,8 @@ int pc_banding(struct map_session_data *sd, uint16 skill_lv) { i++; // Get total HP of all Royal Guards in party. - for( j = 0; j < i; j++ ) - { - bsd = iMap->id2sd(b_sd[j]); + for( j = 0; j < i; j++ ) { + bsd = map->id2sd(b_sd[j]); if( bsd != NULL ) hp += status_get_hp(&bsd->bl); } @@ -367,9 +364,8 @@ int pc_banding(struct map_session_data *sd, uint16 skill_lv) { hp = hp / i; // If a Royal Guard have full HP, give more HP to others that haven't full HP. - for( j = 0; j < i; j++ ) - { - bsd = iMap->id2sd(b_sd[j]); + for( j = 0; j < i; j++ ) { + bsd = map->id2sd(b_sd[j]); if( bsd != NULL && (tmp_hp = hp - status_get_max_hp(&bsd->bl)) > 0 ) { extra_hp += tmp_hp; @@ -380,16 +376,13 @@ int pc_banding(struct map_session_data *sd, uint16 skill_lv) { if( extra_hp > 0 && tmp_qty > 0 ) hp += extra_hp / tmp_qty; - for( j = 0; j < i; j++ ) - { - bsd = iMap->id2sd(b_sd[j]); - if( bsd != NULL ) - { - iStatus->set_hp(&bsd->bl,hp,0); // Set hp - if( (sc = iStatus->get_sc(&bsd->bl)) != NULL && sc->data[SC_BANDING] ) - { + for( j = 0; j < i; j++ ) { + bsd = map->id2sd(b_sd[j]); + if( bsd != NULL ) { + status->set_hp(&bsd->bl,hp,0); // Set hp + if( (sc = status->get_sc(&bsd->bl)) != NULL && sc->data[SC_BANDING] ) { sc->data[SC_BANDING]->val2 = c; // Set the counter. It doesn't count your self. - status_calc_bl(&bsd->bl, iStatus->sc2scb_flag(SC_BANDING)); // Set atk and def. + status_calc_bl(&bsd->bl, status->sc2scb_flag(SC_BANDING)); // Set atk and def. } } } @@ -451,10 +444,10 @@ int pc_setrestartvalue(struct map_session_data *sd,int type) { st = &sd->battle_status; if (type&1) { //Normal resurrection - st->hp = 1; //Otherwise iStatus->heal may fail if dead. - iStatus->heal(&sd->bl, bst->hp, 0, 1); + st->hp = 1; //Otherwise status->heal may fail if dead. + status->heal(&sd->bl, bst->hp, 0, 1); if( st->sp < bst->sp ) - iStatus->set_sp(&sd->bl, bst->sp, 1); + status->set_sp(&sd->bl, bst->sp, 1); } else { //Just for saving on the char-server (with values as if respawned) sd->status.hp = bst->hp; sd->status.sp = (st->sp < bst->sp) ? bst->sp : st->sp; @@ -465,9 +458,8 @@ int pc_setrestartvalue(struct map_session_data *sd,int type) { /*========================================== Rental System *------------------------------------------*/ -static int pc_inventory_rental_end(int tid, unsigned int tick, int id, intptr_t data) -{ - struct map_session_data *sd = iMap->id2sd(id); +static int pc_inventory_rental_end(int tid, unsigned int tick, int id, intptr_t data) { + struct map_session_data *sd = map->id2sd(id); if( sd == NULL ) return 0; if( tid != sd->rental_timer ) @@ -1072,12 +1064,12 @@ bool pc_authok(struct map_session_data *sd, int login_id2, time_t expiration_tim if( sd->status.option & OPTION_INVISIBLE && !pc->can_use_command(sd, "@hide") ) sd->status.option &=~ OPTION_INVISIBLE; - iStatus->change_init(&sd->bl); + status->change_init(&sd->bl); sd->sc.option = sd->status.option; //This is the actual option used in battle. //Set here because we need the inventory data for weapon sprite parsing. - iStatus->set_viewdata(&sd->bl, sd->status.class_); + status->set_viewdata(&sd->bl, sd->status.class_); unit->dataset(&sd->bl); sd->guild_x = -1; @@ -1155,7 +1147,7 @@ bool pc_authok(struct map_session_data *sd, int login_id2, time_t expiration_tim if (expiration_time != 0) { // don't display if it's unlimited or unknow value char tmpstr[1024]; strftime(tmpstr, sizeof(tmpstr) - 1, msg_txt(501), localtime(&expiration_time)); // "Your account time limit is: %d-%m-%Y %H:%M:%S." - clif->wis_message(sd->fd, iMap->wisp_server_name, tmpstr, strlen(tmpstr)+1); + clif->wis_message(sd->fd, map->wisp_server_name, tmpstr, strlen(tmpstr)+1); } /** @@ -1204,7 +1196,7 @@ int pc_set_hate_mob(struct map_session_data *sd, int pos, struct block_list *bl) return 0; } - class_ = iStatus->get_class(bl); + class_ = status->get_class(bl); if (!pcdb_checkid(class_)) { unsigned int max_hp = status_get_max_hp(bl); if ((pos == 1 && max_hp < 6000) || (pos == 2 && max_hp < 20000)) @@ -1246,7 +1238,7 @@ int pc_reg_received(struct map_session_data *sd) for(i=0;i<MAX_PC_FEELHATE;i++) { //for now - someone need to make reading from txt/sql if ((j = pc_readglobalreg(sd,sg_info[i].feel_var))!=0) { sd->feel_map[i].index = j; - sd->feel_map[i].m = iMap->mapindex2mapid(j); + sd->feel_map[i].m = map->mapindex2mapid(j); } else { sd->feel_map[i].index = 0; sd->feel_map[i].m = -1; @@ -1296,8 +1288,8 @@ int pc_reg_received(struct map_session_data *sd) if( sd->status.ele_id > 0 ) intif->elemental_request(sd->status.ele_id, sd->status.char_id); - iMap->addiddb(&sd->bl); - iMap->delnickdb(sd->status.char_id, sd->status.name); + map->addiddb(&sd->bl); + map->delnickdb(sd->status.char_id, sd->status.name); if (!chrif->auth_finished(sd)) ShowError("pc_reg_received: Failed to properly remove player %d:%d from logging db!\n", sd->status.account_id, sd->status.char_id); @@ -1342,7 +1334,7 @@ int pc_calc_skillpoint(struct map_session_data* sd) { for(i=1;i<MAX_SKILL;i++){ if( (skill_lv = pc->checkskill2(sd,i)) > 0) { - inf2 = skill_db[i].inf2; + inf2 = skill->db[i].inf2; if((!(inf2&INF2_QUEST_SKILL) || battle_config.quest_skill_learn) && !(inf2&(INF2_WEDDING_SKILL|INF2_SPIRIT_SKILL|INF2_GUILD_SKILL)) //Do not count wedding/link skills. [Skotlex] ) { @@ -1381,7 +1373,7 @@ int pc_calc_skilltree(struct map_session_data *sd) sd->status.skill[i].id = 0; //First clear skills. /* permanent skills that must be re-checked */ if( sd->status.skill[i].flag == SKILL_FLAG_PERMANENT ) { - switch( skill_db[i].nameid ) { + switch( skill->db[i].nameid ) { case NV_TRICKDEAD: if( (sd->class_&MAPID_BASEMASK) != MAPID_NOVICE ) { sd->status.skill[i].id = 0; @@ -1400,19 +1392,19 @@ int pc_calc_skilltree(struct map_session_data *sd) sd->status.skill[i].flag = SKILL_FLAG_PERMANENT; } - if( sd->sc.count && sd->sc.data[SC_SOULLINK] && sd->sc.data[SC_SOULLINK]->val2 == SL_BARDDANCER && skill_db[i].nameid >= DC_HUMMING && skill_db[i].nameid <= DC_SERVICEFORYOU ) + if( sd->sc.count && sd->sc.data[SC_SOULLINK] && sd->sc.data[SC_SOULLINK]->val2 == SL_BARDDANCER && skill->db[i].nameid >= DC_HUMMING && skill->db[i].nameid <= DC_SERVICEFORYOU ) { //Enable Bard/Dancer spirit linked skills. if( sd->status.sex ) { //Link dancer skills to bard. if( sd->status.skill[i-8].lv < 10 ) continue; - sd->status.skill[i].id = skill_db[i].nameid; + sd->status.skill[i].id = skill->db[i].nameid; sd->status.skill[i].lv = sd->status.skill[i-8].lv; // Set the level to the same as the linking skill sd->status.skill[i].flag = SKILL_FLAG_TEMPORARY; // Tag it as a non-savable, non-uppable, bonus skill } else { //Link bard skills to dancer. if( sd->status.skill[i].lv < 10 ) continue; - sd->status.skill[i-8].id = skill_db[i-8].nameid; + sd->status.skill[i-8].id = skill->db[i-8].nameid; sd->status.skill[i-8].lv = sd->status.skill[i].lv; // Set the level to the same as the linking skill sd->status.skill[i-8].flag = SKILL_FLAG_TEMPORARY; // Tag it as a non-savable, non-uppable, bonus skill } @@ -1421,7 +1413,7 @@ int pc_calc_skilltree(struct map_session_data *sd) if( pc->has_permission(sd, PC_PERM_ALL_SKILL) ) { for( i = 0; i < MAX_SKILL; i++ ) { - switch(skill_db[i].nameid) { + switch(skill->db[i].nameid) { /** * Dummy skills must be added here otherwise they'll be displayed in the, * skill tree and since they have no icons they'll give resource errors @@ -1445,10 +1437,10 @@ int pc_calc_skilltree(struct map_session_data *sd) default: break; } - if( skill_db[i].inf2&(INF2_NPC_SKILL|INF2_GUILD_SKILL) ) + if( skill->db[i].inf2&(INF2_NPC_SKILL|INF2_GUILD_SKILL) ) continue; //Only skills you can't have are npc/guild ones - if( skill_db[i].max > 0 ) - sd->status.skill[i].id = skill_db[i].nameid; + if( skill->db[i].max > 0 ) + sd->status.skill[i].id = skill->db[i].nameid; } return 0; } @@ -1484,7 +1476,7 @@ int pc_calc_skilltree(struct map_session_data *sd) } if( f ) { int inf2; - inf2 = skill_db[idx].inf2; + inf2 = skill->db[idx].inf2; if(!sd->status.skill[idx].lv && ( (inf2&INF2_QUEST_SKILL && !battle_config.quest_skill_learn) || @@ -1515,7 +1507,7 @@ int pc_calc_skilltree(struct map_session_data *sd) for( i = 0; i < MAX_SKILL_TREE && (id = skill_tree[c][i].id) > 0; i++ ) { int idx = skill_tree[c][i].idx; - if( (skill_db[idx].inf2&(INF2_QUEST_SKILL|INF2_WEDDING_SKILL)) ) + if( (skill->db[idx].inf2&(INF2_QUEST_SKILL|INF2_WEDDING_SKILL)) ) continue; //Do not include Quest/Wedding skills. if( sd->status.skill[idx].id == 0 ) { @@ -1576,7 +1568,7 @@ static void pc_check_skilltree(struct map_session_data *sd, int skill_id) if( sd->status.job_level < skill_tree[c][i].joblv ) continue; - j = skill_db[idx].inf2; + j = skill->db[idx].inf2; if( !sd->status.skill[idx].lv && ( (j&INF2_QUEST_SKILL && !battle_config.quest_skill_learn) || j&INF2_WEDDING_SKILL || @@ -1746,7 +1738,7 @@ int pc_disguise(struct map_session_data *sd, int class_) { } else sd->disguise = class_; - iStatus->set_viewdata(&sd->bl, class_); + status->set_viewdata(&sd->bl, class_); clif->changeoption(&sd->bl); if (sd->bl.prev != NULL) { @@ -1759,7 +1751,7 @@ int pc_disguise(struct map_session_data *sd, int class_) { if (sd->chatID) { struct chat_data* cd; nullpo_retr(1, sd); - cd = (struct chat_data*)iMap->id2bl(sd->chatID); + cd = (struct chat_data*)map->id2bl(sd->chatID); if( cd != NULL || (struct block_list*)sd == cd->owner ) clif->dispchat(cd,0); } @@ -2018,9 +2010,8 @@ int pc_exeautobonus(struct map_session_data *sd,struct s_autobonus *autobonus) return 0; } -int pc_endautobonus(int tid, unsigned int tick, int id, intptr_t data) -{ - struct map_session_data *sd = iMap->id2sd(id); +int pc_endautobonus(int tid, unsigned int tick, int id, intptr_t data) { + struct map_session_data *sd = map->id2sd(id); struct s_autobonus *autobonus = (struct s_autobonus *)data; nullpo_ret(sd); @@ -3329,7 +3320,7 @@ int pc_bonus3(struct map_session_data *sd,int type,int type2,int type3,int val) int target = skill->get_inf(type2); //Support or Self (non-auto-target) skills should pick self. target = target&INF_SUPPORT_SKILL || (target&INF_SELF_SKILL && !(skill->get_inf2(type2)&INF2_NO_TARGET_SELF)); pc_bonus_autospell(sd->autospell, ARRAYLENGTH(sd->autospell), - target?-type2:type2, type3, val, 0, iStatus->current_equip_card_id); + target?-type2:type2, type3, val, 0, status->current_equip_card_id); } break; case SP_AUTOSPELL_WHENHIT: @@ -3338,7 +3329,7 @@ int pc_bonus3(struct map_session_data *sd,int type,int type2,int type3,int val) int target = skill->get_inf(type2); //Support or Self (non-auto-target) skills should pick self. target = target&INF_SUPPORT_SKILL || (target&INF_SELF_SKILL && !(skill->get_inf2(type2)&INF2_NO_TARGET_SELF)); pc_bonus_autospell(sd->autospell2, ARRAYLENGTH(sd->autospell2), - target?-type2:type2, type3, val, BF_NORMAL|BF_SKILL, iStatus->current_equip_card_id); + target?-type2:type2, type3, val, BF_NORMAL|BF_SKILL, status->current_equip_card_id); } break; case SP_SP_DRAIN_RATE: @@ -3433,28 +3424,26 @@ int pc_bonus3(struct map_session_data *sd,int type,int type2,int type3,int val) return 0; } -int pc_bonus4(struct map_session_data *sd,int type,int type2,int type3,int type4,int val) -{ +int pc_bonus4(struct map_session_data *sd,int type,int type2,int type3,int type4,int val) { nullpo_ret(sd); - switch(type){ + switch(type) { case SP_AUTOSPELL: if(sd->state.lr_flag != 2) - pc_bonus_autospell(sd->autospell, ARRAYLENGTH(sd->autospell), (val&1?type2:-type2), (val&2?-type3:type3), type4, 0, iStatus->current_equip_card_id); + pc_bonus_autospell(sd->autospell, ARRAYLENGTH(sd->autospell), (val&1?type2:-type2), (val&2?-type3:type3), type4, 0, status->current_equip_card_id); break; case SP_AUTOSPELL_WHENHIT: if(sd->state.lr_flag != 2) - pc_bonus_autospell(sd->autospell2, ARRAYLENGTH(sd->autospell2), (val&1?type2:-type2), (val&2?-type3:type3), type4, BF_NORMAL|BF_SKILL, iStatus->current_equip_card_id); + pc_bonus_autospell(sd->autospell2, ARRAYLENGTH(sd->autospell2), (val&1?type2:-type2), (val&2?-type3:type3), type4, BF_NORMAL|BF_SKILL, status->current_equip_card_id); break; case SP_AUTOSPELL_ONSKILL: - if(sd->state.lr_flag != 2) - { + if(sd->state.lr_flag != 2) { int target = skill->get_inf(type2); //Support or Self (non-auto-target) skills should pick self. target = target&INF_SUPPORT_SKILL || (target&INF_SELF_SKILL && !(skill->get_inf2(type2)&INF2_NO_TARGET_SELF)); - pc_bonus_autospell_onskill(sd->autospell3, ARRAYLENGTH(sd->autospell3), type2, target?-type3:type3, type4, val, iStatus->current_equip_card_id); + pc_bonus_autospell_onskill(sd->autospell3, ARRAYLENGTH(sd->autospell3), type2, target?-type3:type3, type4, val, status->current_equip_card_id); } break; @@ -3475,24 +3464,23 @@ int pc_bonus4(struct map_session_data *sd,int type,int type2,int type3,int type4 return 0; } -int pc_bonus5(struct map_session_data *sd,int type,int type2,int type3,int type4,int type5,int val) -{ +int pc_bonus5(struct map_session_data *sd,int type,int type2,int type3,int type4,int type5,int val) { nullpo_ret(sd); switch(type){ case SP_AUTOSPELL: if(sd->state.lr_flag != 2) - pc_bonus_autospell(sd->autospell, ARRAYLENGTH(sd->autospell), (val&1?type2:-type2), (val&2?-type3:type3), type4, type5, iStatus->current_equip_card_id); + pc_bonus_autospell(sd->autospell, ARRAYLENGTH(sd->autospell), (val&1?type2:-type2), (val&2?-type3:type3), type4, type5, status->current_equip_card_id); break; case SP_AUTOSPELL_WHENHIT: if(sd->state.lr_flag != 2) - pc_bonus_autospell(sd->autospell2, ARRAYLENGTH(sd->autospell2), (val&1?type2:-type2), (val&2?-type3:type3), type4, type5, iStatus->current_equip_card_id); + pc_bonus_autospell(sd->autospell2, ARRAYLENGTH(sd->autospell2), (val&1?type2:-type2), (val&2?-type3:type3), type4, type5, status->current_equip_card_id); break; case SP_AUTOSPELL_ONSKILL: if(sd->state.lr_flag != 2) - pc_bonus_autospell_onskill(sd->autospell3, ARRAYLENGTH(sd->autospell3), type2, (val&1?-type3:type3), (val&2?-type4:type4), type5, iStatus->current_equip_card_id); + pc_bonus_autospell_onskill(sd->autospell3, ARRAYLENGTH(sd->autospell3), type2, (val&1?-type3:type3), (val&2?-type4:type4), type5, status->current_equip_card_id); break; default: @@ -3514,7 +3502,7 @@ int pc_skill(TBL_PC* sd, int id, int level, int flag) { uint16 index = 0; nullpo_ret(sd); - if( !(index = skill->get_index(id)) || skill_db[index].name == NULL) { + if( !(index = skill->get_index(id)) || skill->db[index].name == NULL) { ShowError("pc_skill: Skill with id %d does not exist in the skill database\n", id); return 0; } @@ -3537,7 +3525,7 @@ int pc_skill(TBL_PC* sd, int id, int level, int flag) { clif->deleteskill(sd,id); } else clif->addskill(sd,id); - if( !skill_db[index].inf ) //Only recalculate for passive skills. + if( !skill->db[index].inf ) //Only recalculate for passive skills. status_calc_pc(sd, 0); break; case 1: //Item bonus skill. @@ -3571,7 +3559,7 @@ int pc_skill(TBL_PC* sd, int id, int level, int flag) { clif->deleteskill(sd,id); } else clif->addskill(sd,id); - if( !skill_db[index].inf ) //Only recalculate for passive skills. + if( !skill->db[index].inf ) //Only recalculate for passive skills. status_calc_pc(sd, 0); break; default: //Unknown flag? @@ -4060,7 +4048,7 @@ int pc_dropitem(struct map_session_data *sd,int n,int amount) return 0; } - if (!iMap->addflooritem(&sd->status.inventory[n], amount, sd->bl.m, sd->bl.x, sd->bl.y, 0, 0, 0, 2)) + if (!map->addflooritem(&sd->status.inventory[n], amount, sd->bl.m, sd->bl.x, sd->bl.y, 0, 0, 0, 2)) return 0; pc->delitem(sd, n, amount, 1, 0, LOG_TYPE_PICKDROP_PLAYER); @@ -4090,9 +4078,8 @@ int pc_takeitem(struct map_session_data *sd,struct flooritem_data *fitem) if (sd->status.party_id) p = party->search(sd->status.party_id); - if(fitem->first_get_charid > 0 && fitem->first_get_charid != sd->status.char_id) - { - first_sd = iMap->charid2sd(fitem->first_get_charid); + if(fitem->first_get_charid > 0 && fitem->first_get_charid != sd->status.char_id) { + first_sd = map->charid2sd(fitem->first_get_charid); if(DIFF_TICK(tick,fitem->first_get_tick) < 0) { if (!(p && p->party.item&1 && first_sd && first_sd->status.party_id == sd->status.party_id @@ -4100,9 +4087,8 @@ int pc_takeitem(struct map_session_data *sd,struct flooritem_data *fitem) return 0; } else - if(fitem->second_get_charid > 0 && fitem->second_get_charid != sd->status.char_id) - { - second_sd = iMap->charid2sd(fitem->second_get_charid); + if(fitem->second_get_charid > 0 && fitem->second_get_charid != sd->status.char_id) { + second_sd = map->charid2sd(fitem->second_get_charid); if(DIFF_TICK(tick, fitem->second_get_tick) < 0) { if(!(p && p->party.item&1 && ((first_sd && first_sd->status.party_id == sd->status.party_id) || @@ -4111,9 +4097,8 @@ int pc_takeitem(struct map_session_data *sd,struct flooritem_data *fitem) return 0; } else - if(fitem->third_get_charid > 0 && fitem->third_get_charid != sd->status.char_id) - { - third_sd = iMap->charid2sd(fitem->third_get_charid); + if(fitem->third_get_charid > 0 && fitem->third_get_charid != sd->status.char_id) { + third_sd = map->charid2sd(fitem->third_get_charid); if(DIFF_TICK(tick,fitem->third_get_tick) < 0) { if(!(p && p->party.item&1 && ((first_sd && first_sd->status.party_id == sd->status.party_id) || @@ -4135,7 +4120,7 @@ int pc_takeitem(struct map_session_data *sd,struct flooritem_data *fitem) //Display pickup animation. pc_stop_attack(sd); clif->takeitem(&sd->bl,&fitem->bl); - iMap->clearflooritem(&fitem->bl); + map->clearflooritem(&fitem->bl); return 1; } @@ -4386,7 +4371,7 @@ int pc_useitem(struct map_session_data *sd,int n) { //perform a skill-use check before going through. [Skotlex] //resurrection was picked as testing skill, as a non-offensive, generic skill, it will do. //FIXME: Is this really needed here? It'll be checked in unit.c after all and this prevents skill items using when silenced [Inkfish] - if( sd->inventory_data[n]->flag.delay_consume && ( sd->ud.skilltimer != INVALID_TIMER /*|| !iStatus->check_skilluse(&sd->bl, &sd->bl, ALL_RESURRECTION, 0)*/ ) ) + if( sd->inventory_data[n]->flag.delay_consume && ( sd->ud.skilltimer != INVALID_TIMER /*|| !status->check_skilluse(&sd->bl, &sd->bl, ALL_RESURRECTION, 0)*/ ) ) return 0; if( sd->inventory_data[n]->delay > 0 ) { @@ -4686,8 +4671,8 @@ int pc_steal_item(struct map_session_data *sd,struct block_list *bl, uint16 skil if(md->state.steal_flag == UCHAR_MAX || ( md->sc.opt1 && md->sc.opt1 != OPT1_BURNING && md->sc.opt1 != OPT1_CRYSTALIZE ) ) //already stolen from / status change check return 0; - sd_status= iStatus->get_status_data(&sd->bl); - md_status= iStatus->get_status_data(bl); + sd_status= status->get_status_data(&sd->bl); + md_status= status->get_status_data(bl); if( md->master_id || md_status->mode&MD_BOSS || mob_is_treasure(md) || maplist[bl->m].flag.nomobloot || // check noloot map flag [Lorky] @@ -4788,7 +4773,7 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y nullpo_ret(sd); - if( !mapindex || !mapindex_id2name(mapindex) || ( m = iMap->mapindex2mapid(mapindex) ) == -1 ) { + if( !mapindex || !mapindex_id2name(mapindex) || ( m = map->mapindex2mapid(mapindex) ) == -1 ) { ShowDebug("pc_setpos: Passed mapindex(%d) is invalid!\n", mapindex); return 1; } @@ -4863,7 +4848,7 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y } if( maplist[m].cell == (struct mapcell *)0xdeadbeaf ) - iMap->cellfromcache(&maplist[m]); + map->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! @@ -4876,8 +4861,8 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y if (sd->sc.data[SC_KNOWLEDGE]) { struct status_change_entry *sce = sd->sc.data[SC_KNOWLEDGE]; if (sce->timer != INVALID_TIMER) - timer->delete(sce->timer, iStatus->change_timer); - sce->timer = timer->add(timer->gettick() + skill->get_time(SG_KNOWLEDGE, sce->val1), iStatus->change_timer, sd->bl.id, SC_KNOWLEDGE); + timer->delete(sce->timer, status->change_timer); + sce->timer = timer->add(timer->gettick() + skill->get_time(SG_KNOWLEDGE, sce->val1), status->change_timer, sd->bl.id, SC_KNOWLEDGE); } status_change_end(&sd->bl, SC_PROPERTYWALK, INVALID_TIMER); status_change_end(&sd->bl, SC_CLOAKING, INVALID_TIMER); @@ -4910,7 +4895,7 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y uint32 ip; uint16 port; //if can't find any map-servers, just abort setting position. - if(!sd->mapindex || iMap->mapname2ipport(mapindex,&ip,&port)) + if(!sd->mapindex || map->mapname2ipport(mapindex,&ip,&port)) return 2; if (sd->npc_id) @@ -4940,10 +4925,10 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y do { x=rnd()%(maplist[m].xs-2)+1; y=rnd()%(maplist[m].ys-2)+1; - } while(iMap->getcell(m,x,y,CELL_CHKNOPASS)); + } while(map->getcell(m,x,y,CELL_CHKNOPASS)); } - if (sd->state.vending && iMap->getcell(m,x,y,CELL_CHKNOVENDING)) { + if (sd->state.vending && map->getcell(m,x,y,CELL_CHKNOVENDING)) { clif->message (sd->fd, msg_txt(204)); // "You can't open a shop on this cell." vending->close(sd); } @@ -5011,7 +4996,7 @@ int pc_randomwarp(struct map_session_data *sd, clr_type type) { do { x=rnd()%(maplist[m].xs-2)+1; y=rnd()%(maplist[m].ys-2)+1; - } while( iMap->getcell(m,x,y,CELL_CHKNOPASS) && (i++) < 1000 ); + } while( map->getcell(m,x,y,CELL_CHKNOPASS) && (i++) < 1000 ); if (i < 1000) return pc->setpos(sd,map_id2index(sd->bl.m),x,y,type); @@ -5098,14 +5083,14 @@ int pc_checkskill2(struct map_session_data *sd,uint16 index) { ShowError("pc_checkskill: Invalid skill index %d (char_id=%d).\n", index, sd->status.char_id); return 0; } - if( skill_db[index].nameid >= GD_SKILLBASE && skill_db[index].nameid < GD_MAX ) { + if( skill->db[index].nameid >= GD_SKILLBASE && skill->db[index].nameid < GD_MAX ) { struct guild *g; if( sd->status.guild_id>0 && (g=sd->guild)!=NULL) - return guild->checkskill(g,skill_db[index].nameid); + return guild->checkskill(g,skill->db[index].nameid); return 0; } - if(sd->status.skill[index].id == skill_db[index].nameid) + if(sd->status.skill[index].id == skill->db[index].nameid) return (sd->status.skill[index].lv); return 0; @@ -5147,12 +5132,12 @@ int pc_checkallowskill(struct map_session_data *sd) if(!sd->sc.count) return 0; - for (i = 0; i < ARRAYLENGTH(scw_list); i++) - { // Skills requiring specific weapon types + for (i = 0; i < ARRAYLENGTH(scw_list); i++) { + // Skills requiring specific weapon types if( scw_list[i] == SC_DANCING && !battle_config.dancing_weaponswitch_fix ) continue; - if(sd->sc.data[scw_list[i]] && - !pc_check_weapontype(sd,skill->get_weapontype(iStatus->sc2skill(scw_list[i])))) + if( sd->sc.data[scw_list[i]] + && !pc_check_weapontype(sd,skill->get_weapontype(status->sc2skill(scw_list[i])))) status_change_end(&sd->bl, scw_list[i], INVALID_TIMER); } @@ -5688,34 +5673,32 @@ const char* job_name(int class_) } } -int pc_follow_timer(int tid, unsigned int tick, int id, intptr_t data) -{ +int pc_follow_timer(int tid, unsigned int tick, int id, intptr_t data) { struct map_session_data *sd; struct block_list *tbl; - sd = iMap->id2sd(id); + sd = map->id2sd(id); nullpo_ret(sd); - if (sd->followtimer != tid){ + if (sd->followtimer != tid) { ShowError("pc_follow_timer %d != %d\n",sd->followtimer,tid); sd->followtimer = INVALID_TIMER; return 0; } sd->followtimer = INVALID_TIMER; - tbl = iMap->id2bl(sd->followtarget); + tbl = map->id2bl(sd->followtarget); - if (tbl == NULL || pc_isdead(sd) || iStatus->isdead(tbl)) - { + if (tbl == NULL || pc_isdead(sd) || status->isdead(tbl)) { pc->stop_following(sd); return 0; } // either player or target is currently detached from map blocks (could be teleporting), // but still connected to this map, so we'll just increment the timer and check back later - if (sd->bl.prev != NULL && tbl->prev != NULL && - sd->ud.skilltimer == INVALID_TIMER && sd->ud.attacktimer == INVALID_TIMER && sd->ud.walktimer == INVALID_TIMER) - { + if (sd->bl.prev != NULL && tbl->prev != NULL + && sd->ud.skilltimer == INVALID_TIMER && sd->ud.attacktimer == INVALID_TIMER && sd->ud.walktimer == INVALID_TIMER + ) { if((sd->bl.m == tbl->m) && unit->can_reach_bl(&sd->bl,tbl, AREA_SIZE, 0, NULL, NULL)) { if (!check_distance_bl(&sd->bl, tbl, 5)) unit->walktobl(&sd->bl, tbl, 5, 0); @@ -5744,9 +5727,8 @@ int pc_stop_following (struct map_session_data *sd) return 0; } -int pc_follow(struct map_session_data *sd,int target_id) -{ - struct block_list *bl = iMap->id2bl(target_id); +int pc_follow(struct map_session_data *sd,int target_id) { + struct block_list *bl = map->id2bl(target_id); if (bl == NULL /*|| bl->type != BL_PC*/) return 1; if (sd->followtimer != INVALID_TIMER) @@ -5787,16 +5769,16 @@ int pc_checkbaselevelup(struct map_session_data *sd) { status_percent_heal(&sd->bl,100,100); if((sd->class_&MAPID_UPPERMASK) == MAPID_SUPER_NOVICE) { - sc_start(&sd->bl,iStatus->skill2sc(PR_KYRIE),100,1,skill->get_time(PR_KYRIE,1)); - sc_start(&sd->bl,iStatus->skill2sc(PR_IMPOSITIO),100,1,skill->get_time(PR_IMPOSITIO,1)); - sc_start(&sd->bl,iStatus->skill2sc(PR_MAGNIFICAT),100,1,skill->get_time(PR_MAGNIFICAT,1)); - sc_start(&sd->bl,iStatus->skill2sc(PR_GLORIA),100,1,skill->get_time(PR_GLORIA,1)); - sc_start(&sd->bl,iStatus->skill2sc(PR_SUFFRAGIUM),100,1,skill->get_time(PR_SUFFRAGIUM,1)); + sc_start(&sd->bl,status->skill2sc(PR_KYRIE),100,1,skill->get_time(PR_KYRIE,1)); + sc_start(&sd->bl,status->skill2sc(PR_IMPOSITIO),100,1,skill->get_time(PR_IMPOSITIO,1)); + sc_start(&sd->bl,status->skill2sc(PR_MAGNIFICAT),100,1,skill->get_time(PR_MAGNIFICAT,1)); + sc_start(&sd->bl,status->skill2sc(PR_GLORIA),100,1,skill->get_time(PR_GLORIA,1)); + sc_start(&sd->bl,status->skill2sc(PR_SUFFRAGIUM),100,1,skill->get_time(PR_SUFFRAGIUM,1)); if (sd->state.snovice_dead_flag) sd->state.snovice_dead_flag = 0; //Reenable steelbody resurrection on dead. } else if( (sd->class_&MAPID_BASEMASK) == MAPID_TAEKWON ) { - sc_start(&sd->bl,iStatus->skill2sc(AL_INCAGI),100,10,600000); - sc_start(&sd->bl,iStatus->skill2sc(AL_BLESSING),100,10,600000); + sc_start(&sd->bl,status->skill2sc(AL_INCAGI),100,10,600000); + sc_start(&sd->bl,status->skill2sc(AL_BLESSING),100,10,600000); } clif->misceffect(&sd->bl,0); npc->script_event(sd, NPCE_BASELVUP); //LORDALFA - LVLUPEVENT @@ -5857,14 +5839,14 @@ int pc_checkjoblevelup(struct map_session_data *sd) *------------------------------------------*/ static void pc_calcexp(struct map_session_data *sd, unsigned int *base_exp, unsigned int *job_exp, struct block_list *src) { int bonus = 0; - struct status_data *st = iStatus->get_status_data(src); + struct status_data *st = status->get_status_data(src); if (sd->expaddrace[st->race]) bonus += sd->expaddrace[st->race]; bonus += sd->expaddrace[st->mode&MD_BOSS?RC_BOSS:RC_NONBOSS]; - if (battle_config.pk_mode && - (int)(iStatus->get_lv(src) - sd->status.base_level) >= 20) + if (battle_config.pk_mode + && (int)(status->get_lv(src) - sd->status.base_level) >= 20) bonus += 15; // pk_mode additional exp if monster >20 levels [Valaris] if (sd->sc.data[SC_CASH_PLUSEXP]) @@ -6213,7 +6195,7 @@ int pc_skillup(struct map_session_data *sd,uint16 skill_id) { { sd->status.skill[index].lv++; sd->status.skill_point--; - if( !skill_db[index].inf ) + if( !skill->db[index].inf ) status_calc_pc(sd,0); // Only recalculate for passive skills. else if( sd->status.skill_point == 0 && (sd->class_&MAPID_UPPERMASK) == MAPID_TAEKWON && sd->status.base_level >= 90 && pc->famerank(sd->status.char_id, MAPID_TAEKWON) ) pc->calc_skilltree(sd); // Required to grant all TK Ranger skills. @@ -6260,22 +6242,22 @@ int pc_allskillup(struct map_session_data *sd) if (pc->has_permission(sd, PC_PERM_ALL_SKILL)) { //Get ALL skills except npc/guild ones. [Skotlex] //and except SG_DEVIL [Komurka] and MO_TRIPLEATTACK and RG_SNATCHER [ultramage] for(i=0;i<MAX_SKILL;i++){ - switch( skill_db[i].nameid ) { + switch( skill->db[i].nameid ) { case SG_DEVIL: case MO_TRIPLEATTACK: case RG_SNATCHER: continue; default: - if( !(skill_db[i].inf2&(INF2_NPC_SKILL|INF2_GUILD_SKILL)) ) - if ( ( sd->status.skill[i].lv = skill_db[i].max ) )//Nonexistant skills should return a max of 0 anyway. - sd->status.skill[i].id = skill_db[i].nameid; + if( !(skill->db[i].inf2&(INF2_NPC_SKILL|INF2_GUILD_SKILL)) ) + if ( ( sd->status.skill[i].lv = skill->db[i].max ) )//Nonexistant skills should return a max of 0 anyway. + sd->status.skill[i].id = skill->db[i].nameid; } } } else { int inf2; for(i=0;i < MAX_SKILL_TREE && (id=skill_tree[pc->class2idx(sd->status.class_)][i].id)>0;i++){ int idx = skill_tree[pc->class2idx(sd->status.class_)][i].idx; - inf2 = skill_db[idx].inf2; + inf2 = skill->db[idx].inf2; if ( (inf2&INF2_QUEST_SKILL && !battle_config.quest_skill_learn) || (inf2&(INF2_WEDDING_SKILL|INF2_SPIRIT_SKILL)) || @@ -6503,12 +6485,12 @@ int pc_resetskill(struct map_session_data* sd, int flag) lv = sd->status.skill[i].lv; if (lv < 1) continue; - inf2 = skill_db[i].inf2; + inf2 = skill->db[i].inf2; if( inf2&(INF2_WEDDING_SKILL|INF2_SPIRIT_SKILL) ) //Avoid reseting wedding/linker skills. continue; - skill_id = skill_db[i].nameid; + skill_id = skill->db[i].nameid; // Don't reset trick dead if not a novice/baby if( skill_id == NV_TRICKDEAD && (sd->class_&MAPID_BASEMASK) != MAPID_NOVICE ) { @@ -6649,9 +6631,8 @@ void pc_respawn(struct map_session_data* sd, clr_type clrtype) clif->resurrection(&sd->bl, 1); //If warping fails, send a normal stand up packet. } -static int pc_respawn_timer(int tid, unsigned int tick, int id, intptr_t data) -{ - struct map_session_data *sd = iMap->id2sd(id); +static int pc_respawn_timer(int tid, unsigned int tick, int id, intptr_t data) { + struct map_session_data *sd = map->id2sd(id); if( sd != NULL ) { sd->pvp_point=0; @@ -6701,7 +6682,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) { for(k = 0; k < 5; k++) if (sd->devotion[k]){ - struct map_session_data *devsd = iMap->id2sd(sd->devotion[k]); + struct map_session_data *devsd = map->id2sd(sd->devotion[k]); if (devsd) status_change_end(&devsd->bl, SC_DEVOTION, INVALID_TIMER); sd->devotion[k] = 0; @@ -6877,12 +6858,11 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) { item_tmp.card[1]=0; item_tmp.card[2]=GetWord(sd->status.char_id,0); // CharId item_tmp.card[3]=GetWord(sd->status.char_id,1); - iMap->addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); + map->addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); } // activate Steel body if a super novice dies at 99+% exp [celest] - if ((sd->class_&MAPID_UPPERMASK) == MAPID_SUPER_NOVICE && !sd->state.snovice_dead_flag) - { + if ((sd->class_&MAPID_UPPERMASK) == MAPID_SUPER_NOVICE && !sd->state.snovice_dead_flag) { unsigned int next = pc->nextbaseexp(sd); if( next == 0 ) next = pc->thisbaseexp(sd); if( get_percentage(sd->status.base_exp,next) >= 99 ) { @@ -6892,7 +6872,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) { clif->resurrection(&sd->bl, 1); if(battle_config.pc_invincible_time) pc->setinvincibletimer(sd, battle_config.pc_invincible_time); - sc_start(&sd->bl,iStatus->skill2sc(MO_STEELBODY),100,1,skill->get_time(MO_STEELBODY,1)); + sc_start(&sd->bl,status->skill2sc(MO_STEELBODY),100,1,skill->get_time(MO_STEELBODY,1)); if(map_flag_gvg2(sd->bl.m)) pc_respawn_timer(INVALID_TIMER, timer->gettick(), sd->bl.id, 0); return 0; @@ -7432,7 +7412,7 @@ int pc_itemheal(struct map_session_data *sd,int itemid, int hp,int sp) #endif } - return iStatus->heal(&sd->bl, hp, sp, 1); + return status->heal(&sd->bl, hp, sp, 1); } /*========================================== @@ -7564,7 +7544,7 @@ int pc_jobchange(struct map_session_data *sd,int job, int upper) short id; for(i = 0; i < MAX_SKILL_TREE && (id = skill_tree[class_][i].id) > 0; i++) { //Remove status specific to your current tree skills. - enum sc_type sc = iStatus->skill2sc(id); + enum sc_type sc = status->skill2sc(id); if (sc > SC_COMMON_MAX && sd->sc.data[sc]) status_change_end(&sd->bl, sc, INVALID_TIMER); } @@ -7606,7 +7586,7 @@ int pc_jobchange(struct map_session_data *sd,int job, int upper) if (sd->disguise != -1) pc->disguise(sd, -1); - iStatus->set_viewdata(&sd->bl, job); + status->set_viewdata(&sd->bl, job); clif->changelook(&sd->bl,LOOK_BASE,sd->vd.class_); // move sprite update to prevent client crashes with incompatible equipment [Valaris] if(sd->vd.cloth_color) clif->changelook(&sd->bl,LOOK_CLOTHES_COLOR,sd->vd.cloth_color); @@ -7620,7 +7600,7 @@ int pc_jobchange(struct map_session_data *sd,int job, int upper) if (sd->state.vending) vending->close(sd); - iMap->foreachinmap(jobchange_killclone, sd->bl.m, BL_MOB, sd->bl.id); + map->foreachinmap(jobchange_killclone, sd->bl.m, BL_MOB, sd->bl.id); //Remove peco/cart/falcon i = sd->sc.option; @@ -7701,7 +7681,7 @@ int pc_changelook(struct map_session_data *sd,int type,int val) switch(type){ case LOOK_BASE: - iStatus->set_viewdata(&sd->bl, val); + status->set_viewdata(&sd->bl, val); clif->changelook(&sd->bl,LOOK_BASE,sd->vd.class_); clif->changelook(&sd->bl,LOOK_WEAPON,sd->status.weapon); if (sd->vd.cloth_color) @@ -7816,9 +7796,9 @@ int pc_setoption(struct map_session_data *sd,int type) else if( !(type&OPTION_MADOGEAR) && p_type&OPTION_MADOGEAR ) status_calc_pc(sd, 0); for( i = 0; i < SC_MAX; i++ ){ - if ( !sd->sc.data[i] || !iStatus->get_sc_type(i) ) + if ( !sd->sc.data[i] || !status->get_sc_type(i) ) continue; - if ( iStatus->get_sc_type(i)&SC_MADO_NO_RESET ) + if ( status->get_sc_type(i)&SC_MADO_NO_RESET ) continue; switch (i) { case SC_BERSERK: @@ -7839,7 +7819,7 @@ int pc_setoption(struct map_session_data *sd,int type) return 0; //Disguises break sprite changes if (new_look < 0) { //Restore normal look. - iStatus->set_viewdata(&sd->bl, sd->status.class_); + status->set_viewdata(&sd->bl, sd->status.class_); new_look = sd->vd.class_; } @@ -8301,9 +8281,8 @@ int pc_setregistry_str(struct map_session_data *sd,const char *reg,const char *v /*========================================== * Exec eventtimer for player sd (retrieved from map_session (id)) *------------------------------------------*/ -static int pc_eventtimer(int tid, unsigned int tick, int id, intptr_t data) -{ - struct map_session_data *sd=iMap->id2sd(id); +static int pc_eventtimer(int tid, unsigned int tick, int id, intptr_t data) { + struct map_session_data *sd=map->id2sd(id); char *p = (char *)data; int i; if(sd==NULL) @@ -9046,7 +9025,7 @@ int pc_calc_pvprank_sub(struct block_list *bl,va_list ap) return 0; } /*========================================== - * Calculate new rank beetween all present players (iMap->foreachinarea) + * Calculate new rank beetween all present players (map->foreachinarea) * and display result *------------------------------------------*/ int pc_calc_pvprank(struct map_session_data *sd) { @@ -9055,7 +9034,7 @@ int pc_calc_pvprank(struct map_session_data *sd) { 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); + map->foreachinmap(pc_calc_pvprank_sub,sd->bl.m,BL_PC,sd); if(old!=sd->pvp_rank || sd->pvp_lastusers!=m->users_pvp) clif->pvpset(sd,sd->pvp_rank,sd->pvp_lastusers=m->users_pvp,0); return sd->pvp_rank; @@ -9063,11 +9042,10 @@ int pc_calc_pvprank(struct map_session_data *sd) { /*========================================== * Calculate next sd ranking calculation from config *------------------------------------------*/ -int pc_calc_pvprank_timer(int tid, unsigned int tick, int id, intptr_t data) -{ +int pc_calc_pvprank_timer(int tid, unsigned int tick, int id, intptr_t data) { struct map_session_data *sd; - sd=iMap->id2sd(id); + sd=map->id2sd(id); if(sd==NULL) return 0; sd->pvp_timer = INVALID_TIMER; @@ -9131,8 +9109,8 @@ int pc_divorce(struct map_session_data *sd) if( !sd->status.partner_id ) return -1; // Char is not married - if( (p_sd = iMap->charid2sd(sd->status.partner_id)) == NULL ) - { // Lets char server do the divorce + if( (p_sd = map->charid2sd(sd->status.partner_id)) == NULL ) { + // Lets char server do the divorce if( chrif->divorce(sd->status.char_id, sd->status.partner_id) ) return -1; // No char server connected @@ -9159,11 +9137,10 @@ int pc_divorce(struct map_session_data *sd) /*========================================== * Get sd partner charid. (Married partner) *------------------------------------------*/ -struct map_session_data *pc_get_partner(struct map_session_data *sd) -{ +struct map_session_data *pc_get_partner(struct map_session_data *sd) { if (sd && pc->ismarried(sd)) // charid2sd returns NULL if not found - return iMap->charid2sd(sd->status.partner_id); + return map->charid2sd(sd->status.partner_id); return NULL; } @@ -9171,11 +9148,10 @@ struct map_session_data *pc_get_partner(struct map_session_data *sd) /*========================================== * Get sd father charid. (Need to be baby) *------------------------------------------*/ -struct map_session_data *pc_get_father (struct map_session_data *sd) -{ +struct map_session_data *pc_get_father(struct map_session_data *sd) { if (sd && sd->class_&JOBL_BABY && sd->status.father > 0) // charid2sd returns NULL if not found - return iMap->charid2sd(sd->status.father); + return map->charid2sd(sd->status.father); return NULL; } @@ -9183,11 +9159,10 @@ struct map_session_data *pc_get_father (struct map_session_data *sd) /*========================================== * Get sd mother charid. (Need to be baby) *------------------------------------------*/ -struct map_session_data *pc_get_mother (struct map_session_data *sd) -{ +struct map_session_data *pc_get_mother(struct map_session_data *sd) { if (sd && sd->class_&JOBL_BABY && sd->status.mother > 0) // charid2sd returns NULL if not found - return iMap->charid2sd(sd->status.mother); + return map->charid2sd(sd->status.mother); return NULL; } @@ -9195,11 +9170,10 @@ struct map_session_data *pc_get_mother (struct map_session_data *sd) /*========================================== * Get sd children charid. (Need to be married) *------------------------------------------*/ -struct map_session_data *pc_get_child (struct map_session_data *sd) -{ +struct map_session_data *pc_get_child(struct map_session_data *sd) { if (sd && pc->ismarried(sd) && sd->status.child > 0) // charid2sd returns NULL if not found - return iMap->charid2sd(sd->status.child); + return map->charid2sd(sd->status.child); return NULL; } @@ -9241,8 +9215,7 @@ void pc_bleeding (struct map_session_data *sd, unsigned int diff_tick) //Character regen. Flag is used to know which types of regen can take place. //&1: HP regen //&2: SP regen -void pc_regen (struct map_session_data *sd, unsigned int diff_tick) -{ +void pc_regen (struct map_session_data *sd, unsigned int diff_tick) { int hp = 0, sp = 0; if (sd->hp_regen.value) { @@ -9262,7 +9235,7 @@ void pc_regen (struct map_session_data *sd, unsigned int diff_tick) } if (hp > 0 || sp > 0) - iStatus->heal(&sd->bl, hp, sp, 0); + status->heal(&sd->bl, hp, sp, 0); return; } @@ -9316,18 +9289,18 @@ int pc_autosave(int tid, unsigned int tick, int id, intptr_t data) } mapit->free(iter); - interval = iMap->autosave_interval/(iMap->usercount()+1); - if(interval < iMap->minsave_interval) - interval = iMap->minsave_interval; + interval = map->autosave_interval/(map->usercount()+1); + if(interval < map->minsave_interval) + interval = map->minsave_interval; timer->add(timer->gettick()+interval,pc_autosave,0,0); return 0; } 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; + if (sd->state.night != map->night_flag && maplist[sd->bl.m].flag.nightenabled) { //Night/day state does not match. + clif->status_change(&sd->bl, SI_SKE, map->night_flag, 0, 0, 0, 0); //New night effect by dynamix [Skotlex] + sd->state.night = map->night_flag; return 1; } return 0; @@ -9336,18 +9309,17 @@ static int pc_daynight_timer_sub(struct map_session_data *sd,va_list ap) { * timer to do the day [Yor] * data: 0 = called by timer, 1 = gmcommand/script *------------------------------------------------*/ -int map_day_timer(int tid, unsigned int tick, int id, intptr_t data) -{ +int map_day_timer(int tid, unsigned int tick, int id, intptr_t data) { char tmp_soutput[1024]; - if (data == 0 && battle_config.day_duration <= 0) // if we want a day + if (data == 0 && battle_config.day_duration <= 0) // if we want a day return 0; - if (!iMap->night_flag) + if (!map->night_flag) return 0; //Already day. - iMap->night_flag = 0; // 0=day, 1=night [Yor] - iMap->map_foreachpc(pc_daynight_timer_sub); + map->night_flag = 0; // 0=day, 1=night [Yor] + map->map_foreachpc(pc_daynight_timer_sub); strcpy(tmp_soutput, (data == 0) ? msg_txt(502) : msg_txt(60)); // The day has arrived! intif->broadcast(tmp_soutput, strlen(tmp_soutput) + 1, BC_DEFAULT); return 0; @@ -9357,18 +9329,17 @@ int map_day_timer(int tid, unsigned int tick, int id, intptr_t data) * timer to do the night [Yor] * data: 0 = called by timer, 1 = gmcommand/script *------------------------------------------------*/ -int map_night_timer(int tid, unsigned int tick, int id, intptr_t data) -{ +int map_night_timer(int tid, unsigned int tick, int id, intptr_t data) { char tmp_soutput[1024]; - if (data == 0 && battle_config.night_duration <= 0) // if we want a night + if (data == 0 && battle_config.night_duration <= 0) // if we want a night return 0; - if (iMap->night_flag) + if (map->night_flag) return 0; //Already nigth. - iMap->night_flag = 1; // 0=day, 1=night [Yor] - iMap->map_foreachpc(pc_daynight_timer_sub); + map->night_flag = 1; // 0=day, 1=night [Yor] + map->map_foreachpc(pc_daynight_timer_sub); strcpy(tmp_soutput, (data == 0) ? msg_txt(503) : msg_txt(59)); // The night has fallen... intif->broadcast(tmp_soutput, strlen(tmp_soutput) + 1, BC_DEFAULT); return 0; @@ -9430,12 +9401,11 @@ bool pc_can_use_command(struct map_session_data *sd, const char *command) { return atcommand->can_use(sd,command); } -static int pc_charm_timer(int tid, unsigned int tick, int id, intptr_t data) -{ +static int pc_charm_timer(int tid, unsigned int tick, int id, intptr_t data) { struct map_session_data *sd; int i, type; - if( (sd=(struct map_session_data *)iMap->id2sd(id)) == NULL || sd->bl.type!=BL_PC ) + if( (sd=(struct map_session_data *)map->id2sd(id)) == NULL || sd->bl.type!=BL_PC ) return 1; ARR_FIND(1, 5, type, sd->charm[type] > 0); @@ -9921,11 +9891,11 @@ int pc_readdb(void) { FILE *fp; char line[24000],*p; - //reset + //reset memset(exp_table,0,sizeof(exp_table)); memset(max_level,0,sizeof(max_level)); - sprintf(line, "%s/"DBPATH"exp.txt", iMap->db_path); + sprintf(line, "%s/"DBPATH"exp.txt", map->db_path); fp=fopen(line, "r"); if(fp==NULL){ @@ -10003,13 +9973,13 @@ int pc_readdb(void) { if (!max_level[j][1]) ShowWarning("Class %s (%d) does not has a job exp table.\n", pc->job_name(i), i); } - ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s/"DBPATH"%s"CL_RESET"'.\n",count,iMap->db_path,"exp.txt"); + ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s/"DBPATH"%s"CL_RESET"'.\n",count,map->db_path,"exp.txt"); count = 0; // Reset and read skilltree memset(skill_tree,0,sizeof(skill_tree)); pc_read_skill_tree(); #if defined(RENEWAL_DROP) || defined(RENEWAL_EXP) - sv->readdb(iMap->db_path, "re/level_penalty.txt", ',', 4, 4, -1, &pc_readdb_levelpenalty); + sv->readdb(map->db_path, "re/level_penalty.txt", ',', 4, 4, -1, &pc_readdb_levelpenalty); for( k=1; k < 3; k++ ){ // fill in the blanks for( j = 0; j < RC_MAX; j++ ){ int tmp = 0; @@ -10029,9 +9999,9 @@ int pc_readdb(void) { for(i=0;i<4;i++) for(j=0;j<ELE_MAX;j++) for(k=0;k<ELE_MAX;k++) - attr_fix_table[i][j][k]=100; + battle->attr_fix_table[i][j][k]=100; - sprintf(line, "%s/"DBPATH"attr_fix.txt", iMap->db_path); + sprintf(line, "%s/"DBPATH"attr_fix.txt", map->db_path); fp=fopen(line,"r"); if(fp==NULL){ @@ -10064,9 +10034,9 @@ int pc_readdb(void) { for(j=0,p=line;j<n && j<ELE_MAX && p;j++){ while(*p==32 && *p>0) p++; - attr_fix_table[lv-1][i][j]=atoi(p); - if(battle_config.attr_recover == 0 && attr_fix_table[lv-1][i][j] < 0) - attr_fix_table[lv-1][i][j] = 0; + battle->attr_fix_table[lv-1][i][j]=atoi(p); + if(battle_config.attr_recover == 0 && battle->attr_fix_table[lv-1][i][j] < 0) + battle->attr_fix_table[lv-1][i][j] = 0; p=strchr(p,','); if(p) *p++=0; } @@ -10075,13 +10045,13 @@ int pc_readdb(void) { } } fclose(fp); - ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s/"DBPATH"%s"CL_RESET"'.\n",count,iMap->db_path,"attr_fix.txt"); + ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s/"DBPATH"%s"CL_RESET"'.\n",count,map->db_path,"attr_fix.txt"); count = 0; - // reset then read statspoint + // reset then read statspoint memset(statp,0,sizeof(statp)); i=1; - sprintf(line, "%s/"DBPATH"statpoint.txt", iMap->db_path); + sprintf(line, "%s/"DBPATH"statpoint.txt", map->db_path); fp=fopen(line,"r"); if(fp == NULL){ ShowWarning("Can't read '"CL_WHITE"%s"CL_RESET"'... Generating DB.\n",line); @@ -10102,7 +10072,7 @@ int pc_readdb(void) { } fclose(fp); - ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s/"DBPATH"%s"CL_RESET"'.\n",count,iMap->db_path,"statpoint.txt"); + ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s/"DBPATH"%s"CL_RESET"'.\n",count,map->db_path,"statpoint.txt"); } // generate the remaining parts of the db if necessary k = battle_config.use_statpoint_table; //save setting @@ -10178,10 +10148,10 @@ int do_init_pc(void) { timer->add_func_list(pc->endautobonus, "pc->endautobonus"); timer->add_func_list(pc_charm_timer, "pc_charm_timer"); - timer->add(timer->gettick() + iMap->autosave_interval, pc_autosave, 0, 0); + timer->add(timer->gettick() + map->autosave_interval, pc_autosave, 0, 0); // 0=day, 1=night [Yor] - iMap->night_flag = battle_config.night_at_start ? 1 : 0; + map->night_flag = battle_config.night_at_start ? 1 : 0; if (battle_config.day_duration > 0 && battle_config.night_duration > 0) { int day_duration = battle_config.day_duration; @@ -10190,8 +10160,8 @@ int do_init_pc(void) { timer->add_func_list(pc->map_day_timer, "pc->map_day_timer"); timer->add_func_list(pc->map_night_timer, "pc->map_night_timer"); - pc->day_timer_tid = timer->add_interval(timer->gettick() + (iMap->night_flag ? 0 : day_duration) + night_duration, pc->map_day_timer, 0, 0, day_duration + night_duration); - pc->night_timer_tid = timer->add_interval(timer->gettick() + day_duration + (iMap->night_flag ? night_duration : 0), pc->map_night_timer, 0, 0, day_duration + night_duration); + pc->day_timer_tid = timer->add_interval(timer->gettick() + (map->night_flag ? 0 : day_duration) + night_duration, pc->map_day_timer, 0, 0, day_duration + night_duration); + pc->night_timer_tid = timer->add_interval(timer->gettick() + day_duration + (map->night_flag ? night_duration : 0), pc->map_night_timer, 0, 0, day_duration + night_duration); } do_init_pc_groups(); diff --git a/src/map/pc.h b/src/map/pc.h index 36c866535..69bcdea8d 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -673,7 +673,7 @@ enum equip_pos { #define pc_rightside_def(sd) ((sd)->battle_status.def) #define pc_leftside_mdef(sd) ((sd)->battle_status.mdef2) #define pc_rightside_mdef(sd) ((sd)->battle_status.mdef) -#define pc_leftside_matk(sd) (iStatus->base_matk(iStatus->get_status_data(&(sd)->bl), (sd)->status.base_level)) +#define pc_leftside_matk(sd) (status->base_matk(status->get_status_data(&(sd)->bl), (sd)->status.base_level)) #define pc_rightside_matk(sd) ((sd)->battle_status.rhw.matk+(sd)->battle_status.lhw.matk+(sd)->bonus.ematk) #else #define pc_leftside_atk(sd) ((sd)->battle_status.batk + (sd)->battle_status.rhw.atk + (sd)->battle_status.lhw.atk) diff --git a/src/map/pet.c b/src/map/pet.c index bb5982e7a..811ac9f09 100644 --- a/src/map/pet.c +++ b/src/map/pet.c @@ -96,8 +96,7 @@ int pet_unlocktarget(struct pet_data *pd) /*========================================== * Pet Attack Skill [Skotlex] *------------------------------------------*/ -int pet_attackskill(struct pet_data *pd, int target_id) -{ +int pet_attackskill(struct pet_data *pd, int target_id) { if (!battle_config.pet_status_support || !pd->a_skill || (battle_config.pet_equip_required && !pd->pet.equip)) return 0; @@ -105,28 +104,27 @@ int pet_attackskill(struct pet_data *pd, int target_id) if (DIFF_TICK(pd->ud.canact_tick, timer->gettick()) > 0) return 0; - if (rnd()%100 < (pd->a_skill->rate +pd->pet.intimate*pd->a_skill->bonusrate/1000)) - { //Skotlex: Use pet's skill + if (rnd()%100 < (pd->a_skill->rate +pd->pet.intimate*pd->a_skill->bonusrate/1000)) { + //Skotlex: Use pet's skill int inf; struct block_list *bl; - bl=iMap->id2bl(target_id); - if(bl == NULL || pd->bl.m != bl->m || bl->prev == NULL || iStatus->isdead(bl) || - !check_distance_bl(&pd->bl, bl, pd->db->range3)) + bl=map->id2bl(target_id); + if( bl == NULL || pd->bl.m != bl->m || bl->prev == NULL + || status->isdead(bl) || !check_distance_bl(&pd->bl, bl, pd->db->range3)) return 0; inf = skill->get_inf(pd->a_skill->id); if (inf & INF_GROUND_SKILL) unit->skilluse_pos(&pd->bl, bl->x, bl->y, pd->a_skill->id, pd->a_skill->lv); - else //Offensive self skill? Could be stuff like GX. + else //Offensive self skill? Could be stuff like GX. unit->skilluse_id(&pd->bl,(inf&INF_SELF_SKILL?pd->bl.id:bl->id), pd->a_skill->id, pd->a_skill->lv); return 1; //Skill invoked. } return 0; } -int pet_target_check(struct map_session_data *sd,struct block_list *bl,int type) -{ +int pet_target_check(struct map_session_data *sd,struct block_list *bl,int type) { struct pet_data *pd; int rate; @@ -134,17 +132,17 @@ int pet_target_check(struct map_session_data *sd,struct block_list *bl,int type) Assert((pd->msd == 0) || (pd->msd->pd == pd)); - if(bl == NULL || bl->type != BL_MOB || bl->prev == NULL || - pd->pet.intimate < battle_config.pet_support_min_friendly || - pd->pet.hungry < 1 || - pd->pet.class_ == iStatus->get_class(bl)) + if( bl == NULL || bl->type != BL_MOB || bl->prev == NULL + || pd->pet.intimate < battle_config.pet_support_min_friendly + || pd->pet.hungry < 1 + || pd->pet.class_ == status->get_class(bl)) return 0; - if(pd->bl.m != bl->m || - !check_distance_bl(&pd->bl, bl, pd->db->range2)) + if( pd->bl.m != bl->m + || !check_distance_bl(&pd->bl, bl, pd->db->range2)) return 0; - if (!iStatus->check_skilluse(&pd->bl, bl, 0, 0)) + if (!status->check_skilluse(&pd->bl, bl, 0, 0)) return 0; if(!type) { @@ -188,13 +186,12 @@ int pet_sc_check(struct map_session_data *sd, int type) return 0; } -int pet_hungry(int tid, unsigned int tick, int id, intptr_t data) -{ +int pet_hungry(int tid, unsigned int tick, int id, intptr_t data) { struct map_session_data *sd; struct pet_data *pd; int interval; - sd=iMap->id2sd(id); + sd=map->id2sd(id); if(!sd) return 1; @@ -302,7 +299,7 @@ int pet_return_egg(struct map_session_data *sd, struct pet_data *pd) tmp_item.card[3] = pd->pet.rename_flag; if((flag = pc->additem(sd,&tmp_item,1,LOG_TYPE_OTHER))) { clif->additem(sd,0,0,flag); - iMap->addflooritem(&tmp_item,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); + map->addflooritem(&tmp_item,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); } pd->pet.incuvate = 1; unit->free(&pd->bl,CLR_OUTSIGHT); @@ -351,7 +348,7 @@ int pet_data_init(struct map_session_data *sd, struct s_pet *petinfo) pd->petDB = &pet->db[i]; pd->db = mob->db(petinfo->class_); memcpy(&pd->pet, petinfo, sizeof(struct s_pet)); - iStatus->set_viewdata(&pd->bl, petinfo->class_); + status->set_viewdata(&pd->bl, petinfo->class_); unit->dataset(&pd->bl); pd->ud.dir = sd->ud.dir; @@ -362,7 +359,7 @@ int pet_data_init(struct map_session_data *sd, struct s_pet *petinfo) pd->bl.x = pd->ud.to_x; pd->bl.y = pd->ud.to_y; - iMap->addiddb(&pd->bl); + map->addiddb(&pd->bl); status_calc_pet(pd,1); pd->last_thinktime = timer->gettick(); @@ -403,11 +400,11 @@ int pet_birth_process(struct map_session_data *sd, struct s_pet *petinfo) } intif->save_petdata(sd->status.account_id,petinfo); - if (iMap->save_settings&8) + if (map->save_settings&8) chrif->save(sd,0); //is it REALLY Needed to save the char for hatching a pet? [Skotlex] if(sd->bl.prev != NULL) { - iMap->addblock(&sd->pd->bl); + map->addblock(&sd->pd->bl); clif->spawn(&sd->pd->bl); clif->send_petdata(sd,sd->pd, 0,0); clif->send_petdata(sd,sd->pd, 5,battle_config.pet_hair_style); @@ -419,11 +416,10 @@ int pet_birth_process(struct map_session_data *sd, struct s_pet *petinfo) return 0; } -int pet_recv_petdata(int account_id,struct s_pet *p,int flag) -{ +int pet_recv_petdata(int account_id,struct s_pet *p,int flag) { struct map_session_data *sd; - sd = iMap->id2sd(account_id); + sd = map->id2sd(account_id); if(sd == NULL) return 1; if(flag == 1) { @@ -448,7 +444,7 @@ int pet_recv_petdata(int account_id,struct s_pet *p,int flag) } else { pet->data_init(sd,p); if(sd->pd && sd->bl.prev != NULL) { - iMap->addblock(&sd->pd->bl); + map->addblock(&sd->pd->bl); clif->spawn(&sd->pd->bl); clif->send_petdata(sd,sd->pd,0,0); clif->send_petdata(sd,sd->pd,5,battle_config.pet_hair_style); @@ -485,16 +481,15 @@ int pet_catch_process1(struct map_session_data *sd,int target_class) return 0; } -int pet_catch_process2(struct map_session_data* sd, int target_id) -{ +int pet_catch_process2(struct map_session_data* sd, int target_id) { struct mob_data* md; int i = 0, pet_catch_rate = 0; nullpo_retr(1, sd); - md = (struct mob_data*)iMap->id2bl(target_id); - if(!md || md->bl.type != BL_MOB || md->bl.prev == NULL) - { // Invalid inputs/state, abort capture. + md = (struct mob_data*)map->id2bl(target_id); + if(!md || md->bl.type != BL_MOB || md->bl.prev == NULL) { + // Invalid inputs/state, abort capture. clif->pet_roulette(sd,0); sd->catch_target_class = -1; sd->itemid = sd->itemindex = -1; @@ -537,8 +532,8 @@ int pet_catch_process2(struct map_session_data* sd, int target_id) return 0; } -int pet_get_egg(int account_id,int pet_id,int flag) -{ //This function is invoked when a new pet has been created, and at no other time! +///This function is invoked when a new pet has been created, and at no other time! +int pet_get_egg(int account_id,int pet_id,int flag) { struct map_session_data *sd; struct item tmp_item; int i=0,ret=0; @@ -546,7 +541,7 @@ int pet_get_egg(int account_id,int pet_id,int flag) if(flag) return 0; - sd = iMap->id2sd(account_id); + sd = map->id2sd(account_id); if(sd == NULL) return 0; @@ -567,7 +562,7 @@ int pet_get_egg(int account_id,int pet_id,int flag) tmp_item.card[3] = 0; //New pets are not named. if((ret = pc->additem(sd,&tmp_item,1,LOG_TYPE_PICKDROP_PLAYER))) { clif->additem(sd,0,0,ret); - iMap->addflooritem(&tmp_item,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); + map->addflooritem(&tmp_item,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); } return 1; @@ -650,8 +645,7 @@ int pet_change_name_ack(struct map_session_data *sd, char* name, int flag) return 1; } -int pet_equipitem(struct map_session_data *sd,int index) -{ +int pet_equipitem(struct map_session_data *sd,int index) { struct pet_data *pd; int nameid; @@ -668,13 +662,12 @@ int pet_equipitem(struct map_session_data *sd,int index) pc->delitem(sd,index,1,0,0,LOG_TYPE_OTHER); pd->pet.equip = nameid; - iStatus->set_viewdata(&pd->bl, pd->pet.class_); //Updates view_data. + status->set_viewdata(&pd->bl, pd->pet.class_); //Updates view_data. clif->send_petdata(NULL, sd->pd, 3, sd->pd->vd.head_bottom); - if (battle_config.pet_equip_required) - { //Skotlex: start support timers if need + if (battle_config.pet_equip_required) { + //Skotlex: start support timers if need unsigned int tick = timer->gettick(); - if (pd->s_skill && pd->s_skill->timer == INVALID_TIMER) - { + if (pd->s_skill && pd->s_skill->timer == INVALID_TIMER) { if (pd->s_skill->id) pd->s_skill->timer=timer->add(tick+pd->s_skill->delay*1000, pet->skill_support_timer, sd->bl.id, 0); else @@ -687,8 +680,7 @@ int pet_equipitem(struct map_session_data *sd,int index) return 0; } -int pet_unequipitem(struct map_session_data *sd, struct pet_data *pd) -{ +int pet_unequipitem(struct map_session_data *sd, struct pet_data *pd) { struct item tmp_item; int nameid,flag; @@ -697,14 +689,14 @@ int pet_unequipitem(struct map_session_data *sd, struct pet_data *pd) nameid = pd->pet.equip; pd->pet.equip = 0; - iStatus->set_viewdata(&pd->bl, pd->pet.class_); + status->set_viewdata(&pd->bl, pd->pet.class_); clif->send_petdata(NULL, sd->pd, 3, sd->pd->vd.head_bottom); memset(&tmp_item,0,sizeof(tmp_item)); tmp_item.nameid = nameid; tmp_item.identify = 1; if((flag = pc->additem(sd,&tmp_item,1,LOG_TYPE_OTHER))) { clif->additem(sd,0,0,flag); - iMap->addflooritem(&tmp_item,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); + map->addflooritem(&tmp_item,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); } if( battle_config.pet_equip_required ) { // Skotlex: halt support timers if needed @@ -793,7 +785,7 @@ int pet_randomwalk(struct pet_data *pd,unsigned int tick) int r=rnd(); x=pd->bl.x+r%(d*2+1)-d; y=pd->bl.y+r/(d*2+1)%(d*2+1)-d; - if(iMap->getcell(pd->bl.m,x,y,CELL_CHKPASS) && unit->walktoxy(&pd->bl,x,y,0)){ + if(map->getcell(pd->bl.m,x,y,CELL_CHKPASS) && unit->walktoxy(&pd->bl,x,y,0)) { pd->move_fail_count=0; break; } @@ -868,10 +860,10 @@ int pet_ai_sub_hard(struct pet_data *pd, struct map_session_data *sd, unsigned i } if (pd->target_id) { - target= iMap->id2bl(pd->target_id); - if (!target || pd->bl.m != target->m || iStatus->isdead(target) || - !check_distance_bl(&pd->bl, target, pd->db->range3)) - { + target= map->id2bl(pd->target_id); + if (!target || pd->bl.m != target->m || status->isdead(target) + || !check_distance_bl(&pd->bl, target, pd->db->range3) + ) { target = NULL; pet->unlocktarget(pd); } @@ -879,7 +871,7 @@ int pet_ai_sub_hard(struct pet_data *pd, struct map_session_data *sd, unsigned i if(!target && pd->loot && pd->msd && pc->has_permission(pd->msd, PC_PERM_TRADE) && pd->loot->count < pd->loot->max && DIFF_TICK(tick,pd->ud.canact_tick)>0) { //Use half the pet's range of sight. - iMap->foreachinrange(pet->ai_sub_hard_lootsearch,&pd->bl, + map->foreachinrange(pet->ai_sub_hard_lootsearch,&pd->bl, pd->db->range2/2, BL_ITEM,pd,&target); } @@ -923,7 +915,7 @@ int pet_ai_sub_hard(struct pet_data *pd, struct map_session_data *sd, unsigned i if(pd->loot->count < pd->loot->max){ memcpy(&pd->loot->item[pd->loot->count++],&fitem->item_data,sizeof(pd->loot->item[0])); pd->loot->weight += itemdb_weight(fitem->item_data.nameid)*fitem->item_data.amount; - iMap->clearflooritem(target); + map->clearflooritem(target); } //Target is unlocked regardless of whether it was picked or not. pet->unlocktarget(pd); @@ -941,9 +933,8 @@ int pet_ai_sub_foreachclient(struct map_session_data *sd,va_list ap) return 0; } -int pet_ai_hard(int tid, unsigned int tick, int id, intptr_t data) -{ - iMap->map_foreachpc(pet->ai_sub_foreachclient,tick); +int pet_ai_hard(int tid, unsigned int tick, int id, intptr_t data) { + map->map_foreachpc(pet->ai_sub_foreachclient,tick); return 0; } @@ -975,14 +966,13 @@ int pet_ai_sub_hard_lootsearch(struct block_list *bl,va_list ap) return 0; } -int pet_delay_item_drop(int tid, unsigned int tick, int id, intptr_t data) -{ +int pet_delay_item_drop(int tid, unsigned int tick, int id, intptr_t data) { struct item_drop_list *list; struct item_drop *ditem, *ditem_prev; list=(struct item_drop_list *)data; ditem = list->item; while (ditem) { - iMap->addflooritem(&ditem->item_data,ditem->item_data.amount, + map->addflooritem(&ditem->item_data,ditem->item_data.amount, list->m,list->x,list->y, list->first_charid,list->second_charid,list->third_charid,0); ditem_prev = ditem; @@ -1044,9 +1034,8 @@ int pet_lootitem_drop(struct pet_data *pd,struct map_session_data *sd) /*========================================== * pet bonus giving skills [Valaris] / Rewritten by [Skotlex] *------------------------------------------*/ -int pet_skill_bonus_timer(int tid, unsigned int tick, int id, intptr_t data) -{ - struct map_session_data *sd=iMap->id2sd(id); +int pet_skill_bonus_timer(int tid, unsigned int tick, int id, intptr_t data) { + struct map_session_data *sd=map->id2sd(id); struct pet_data *pd; int bonus; int duration = 0; @@ -1086,9 +1075,8 @@ int pet_skill_bonus_timer(int tid, unsigned int tick, int id, intptr_t data) /*========================================== * pet recovery skills [Valaris] / Rewritten by [Skotlex] *------------------------------------------*/ -int pet_recovery_timer(int tid, unsigned int tick, int id, intptr_t data) -{ - struct map_session_data *sd=iMap->id2sd(id); +int pet_recovery_timer(int tid, unsigned int tick, int id, intptr_t data) { + struct map_session_data *sd=map->id2sd(id); struct pet_data *pd; if(sd==NULL || sd->pd == NULL || sd->pd->recovery == NULL) @@ -1115,7 +1103,7 @@ int pet_recovery_timer(int tid, unsigned int tick, int id, intptr_t data) } int pet_heal_timer(int tid, unsigned int tick, int id, intptr_t data) { - struct map_session_data *sd=iMap->id2sd(id); + struct map_session_data *sd=map->id2sd(id); struct status_data *st; struct pet_data *pd; unsigned int rate = 100; @@ -1130,7 +1118,7 @@ int pet_heal_timer(int tid, unsigned int tick, int id, intptr_t data) { return 0; } - st = iStatus->get_status_data(&sd->bl); + st = status->get_status_data(&sd->bl); if(pc_isdead(sd) || (rate = get_percentage(st->sp, st->max_sp)) > pd->s_skill->sp || @@ -1143,7 +1131,7 @@ int pet_heal_timer(int tid, unsigned int tick, int id, intptr_t data) { pet_stop_attack(pd); pet_stop_walking(pd,1); clif->skill_nodamage(&pd->bl,&sd->bl,AL_HEAL,pd->s_skill->lv,1); - iStatus->heal(&sd->bl, pd->s_skill->lv,0, 0); + status->heal(&sd->bl, pd->s_skill->lv,0, 0); pd->s_skill->timer=timer->add(tick+pd->s_skill->delay*1000,pet->heal_timer,sd->bl.id,0); return 0; } @@ -1152,7 +1140,7 @@ int pet_heal_timer(int tid, unsigned int tick, int id, intptr_t data) { * pet support skills [Skotlex] *------------------------------------------*/ int pet_skill_support_timer(int tid, unsigned int tick, int id, intptr_t data) { - struct map_session_data *sd=iMap->id2sd(id); + struct map_session_data *sd=map->id2sd(id); struct pet_data *pd; struct status_data *st; short rate = 100; @@ -1166,7 +1154,7 @@ int pet_skill_support_timer(int tid, unsigned int tick, int id, intptr_t data) { return 0; } - st = iStatus->get_status_data(&sd->bl); + st = status->get_status_data(&sd->bl); if (DIFF_TICK(pd->ud.canact_tick, tick) > 0) { //Wait until the pet can act again. @@ -1223,23 +1211,20 @@ int read_petdb() memset(pet->db,0,sizeof(pet->db)); j = 0; // entry counter - for( i = 0; i < ARRAYLENGTH(filename); i++ ) - { + for( i = 0; i < ARRAYLENGTH(filename); i++ ) { char line[1024]; int lines, entries; - sprintf(line, "%s/%s", iMap->db_path, filename[i]); + sprintf(line, "%s/%s", map->db_path, filename[i]); fp=fopen(line,"r"); - if( fp == NULL ) - { + if( fp == NULL ) { if( i == 0 ) ShowError("can't read %s\n",line); continue; } lines = entries = 0; - while( fgets(line, sizeof(line), fp) && j < MAX_PET_DB ) - { + while( fgets(line, sizeof(line), fp) && j < MAX_PET_DB ) { char *str[22], *p; lines++; diff --git a/src/map/quest.c b/src/map/quest.c index 40030560a..f40b60c3d 100644 --- a/src/map/quest.c +++ b/src/map/quest.c @@ -103,7 +103,7 @@ int quest_add(TBL_PC * sd, int quest_id) clif->quest_add(sd, &sd->quest_log[i], sd->quest_index[i]); clif->quest_update_objective(sd, &sd->quest_log[i], sd->quest_index[i]); - if( iMap->save_settings&64 ) + if( map->save_settings&64 ) chrif->save(sd,0); return 0; @@ -152,7 +152,7 @@ int quest_change(TBL_PC * sd, int qid1, int qid2) clif->quest_add(sd, &sd->quest_log[i], sd->quest_index[i]); clif->quest_update_objective(sd, &sd->quest_log[i], sd->quest_index[i]); - if( iMap->save_settings&64 ) + if( map->save_settings&64 ) chrif->save(sd,0); return 0; @@ -183,7 +183,7 @@ int quest_delete(TBL_PC * sd, int quest_id) clif->quest_delete(sd, quest_id); - if( iMap->save_settings&64 ) + if( map->save_settings&64 ) chrif->save(sd,0); return 0; @@ -253,7 +253,7 @@ int quest_update_status(TBL_PC * sd, int quest_id, quest_state qs) { clif->quest_delete(sd, quest_id); - if( iMap->save_settings&64 ) + if( map->save_settings&64 ) chrif->save(sd,0); return 0; @@ -297,16 +297,15 @@ int quest_read_db(void) { int i,j,k = 0; char *str[20],*p,*np; - sprintf(line, "%s/quest_db.txt", iMap->db_path); + sprintf(line, "%s/quest_db.txt", map->db_path); if( (fp=fopen(line,"r"))==NULL ){ ShowError("can't read %s\n", line); return -1; } while(fgets(line, sizeof(line), fp)) { - if (k == MAX_QUEST_DB) { - ShowError("quest_read_db: Too many entries specified in %s/quest_db.txt!\n", iMap->db_path); + ShowError("quest_read_db: Too many entries specified in %s/quest_db.txt!\n", map->db_path); break; } diff --git a/src/map/script.c b/src/map/script.c index d9794e3cd..06c97bbe6 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -312,14 +312,13 @@ static void script_dump_stack(struct script_state* st) #endif /// Reports on the console the src of a script error. -static void script_reportsrc(struct script_state *st) -{ +static void script_reportsrc(struct script_state *st) { struct block_list* bl; if( st->oid == 0 ) return; //Can't report source. - bl = iMap->id2bl(st->oid); + bl = map->id2bl(st->oid); if( bl == NULL ) return; @@ -332,9 +331,9 @@ static void script_reportsrc(struct script_state *st) 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), maplist[bl->m].name, bl->x, bl->y); + ShowDebug("Source (Non-NPC type %d): name %s at %s (%d,%d)\n", bl->type, status->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)); + ShowDebug("Source (Non-NPC type %d): name %s (invisible/not on a map)\n", bl->type, status->get_name(bl)); break; } } @@ -1993,13 +1992,12 @@ void script_set_constant_force(const char *name, int value, bool isparameter) { * Reading constant databases * const.txt *------------------------------------------*/ -static void read_constdb(void) -{ +static void read_constdb(void) { FILE *fp; char line[1024],name[1024],val[1024]; int type; - sprintf(line, "%s/const.txt", iMap->db_path); + sprintf(line, "%s/const.txt", map->db_path); fp=fopen(line, "r"); if(fp==NULL){ ShowError("can't read %s\n", line); @@ -2290,7 +2288,7 @@ struct script_code* parse_script(const char *src,const char *file,int line,int o /// If there is no player attached, the script is terminated. TBL_PC *script_rid2sd(struct script_state *st) { TBL_PC *sd; - if( !( sd = iMap->id2sd(st->rid) ) ){ + if( !( sd = map->id2sd(st->rid) ) ){ ShowError("script_rid2sd: fatal error ! player not attached!\n"); script_reportfunc(st); script_reportsrc(st); @@ -3341,7 +3339,7 @@ void script_stop_instances(struct script_code *code) { int run_script_timer(int tid, unsigned int tick, int id, intptr_t data) { struct script_state *st = idb_get(script->st_db,(int)data); if( st ) { - TBL_PC *sd = iMap->id2sd(st->rid); + TBL_PC *sd = map->id2sd(st->rid); if((sd && sd->status.char_id != id) || (st->rid && !sd)) { //Character mismatch. Cancel execution. st->rid = 0; @@ -3359,11 +3357,10 @@ int run_script_timer(int tid, unsigned int tick, int id, intptr_t data) { /// /// @param st Script state to detach. /// @param dequeue_event Whether to schedule any queued events, when there was no previous script. -static void script_detach_state(struct script_state* st, bool dequeue_event) -{ +static void script_detach_state(struct script_state* st, bool dequeue_event) { struct map_session_data* sd; - if(st->rid && (sd = iMap->id2sd(st->rid))!=NULL) { + if(st->rid && (sd = map->id2sd(st->rid))!=NULL) { sd->st = st->bk_st; sd->npc_id = st->bk_npcid; sd->state.dialog = 0; @@ -3401,7 +3398,7 @@ static void script_detach_state(struct script_state* st, bool dequeue_event) void script_attach_state(struct script_state* st) { struct map_session_data* sd; - if(st->rid && (sd = iMap->id2sd(st->rid))!=NULL) + if(st->rid && (sd = map->id2sd(st->rid))!=NULL) { if(st!=sd->st) { @@ -3438,7 +3435,7 @@ void run_script_main(struct script_state *st) { script->attach_state(st); - nd = iMap->id2nd(st->oid); + nd = map->id2nd(st->oid); if( nd && nd->bl.m >= 0 ) st->instance_id = maplist[nd->bl.m].instance_id; else @@ -3542,7 +3539,7 @@ void run_script_main(struct script_state *st) { //Restore previous script script_detach_state(st, false); //Delay execution - sd = iMap->id2sd(st->rid); // Get sd since script might have attached someone while running. [Inkfish] + sd = map->id2sd(st->rid); // Get sd since script might have attached someone while running. [Inkfish] st->sleep.charid = sd?sd->status.char_id:0; st->sleep.timer = timer->add(timer->gettick()+st->sleep.tick, script->run_timer, st->sleep.charid, (intptr_t)st->id); @@ -3561,7 +3558,7 @@ void run_script_main(struct script_state *st) { } } else { //Dispose of script. - if ((sd = iMap->id2sd(st->rid))!=NULL) { //Restore previous stack and save char. + if ((sd = map->id2sd(st->rid))!=NULL) { //Restore previous stack and save char. if(sd->state.using_fake_npc){ clif->clearunit_single(sd->npc_id, CLR_OUTSIGHT, sd->fd); sd->state.using_fake_npc = 0; @@ -3641,7 +3638,7 @@ void script_run_autobonus(const char *autobonus, int id, int pos) struct script_code *scriptroot = (struct script_code *)strdb_get(script->autobonus_db, autobonus); if( scriptroot ) { - iStatus->current_equip_item_index = pos; + status->current_equip_item_index = pos; script->run(scriptroot,0,id,0); } } @@ -4102,7 +4099,7 @@ BUILDIN(menu) * menus beyond this length crash the client (see bugreport:6402) **/ if( StrBuf->Length(&buf) >= 2047 ) { - struct npc_data * nd = iMap->id2nd(st->oid); + struct npc_data * nd = map->id2nd(st->oid); char* menu; CREATE(menu, char, 2048); safestrncpy(menu, StrBuf->Value(&buf), 2047); @@ -4207,7 +4204,7 @@ BUILDIN(select) * menus beyond this length crash the client (see bugreport:6402) **/ if( StrBuf->Length(&buf) >= 2047 ) { - struct npc_data * nd = iMap->id2nd(st->oid); + struct npc_data * nd = map->id2nd(st->oid); char* menu; CREATE(menu, char, 2048); safestrncpy(menu, StrBuf->Value(&buf), 2047); @@ -4286,7 +4283,7 @@ BUILDIN(prompt) * menus beyond this length crash the client (see bugreport:6402) **/ if( StrBuf->Length(&buf) >= 2047 ) { - struct npc_data * nd = iMap->id2nd(st->oid); + struct npc_data * nd = map->id2nd(st->oid); char* menu; CREATE(menu, char, 2048); safestrncpy(menu, StrBuf->Value(&buf), 2047); @@ -4611,7 +4608,7 @@ static int buildin_areawarp_sub(struct block_list *bl,va_list ap) tx = rnd()%(x3-x2+1)+x2; ty = rnd()%(y3-y2+1)+y2; j++; - } while( iMap->getcell(index,tx,ty,CELL_CHKNOPASS) && j < max ); + } while( map->getcell(index,tx,ty,CELL_CHKNOPASS) && j < max ); pc->setpos((TBL_PC *)bl,index,tx,ty,CLR_OUTSIGHT); } @@ -4646,7 +4643,7 @@ BUILDIN(areawarp) } } - if( (m = iMap->mapname2mapid(mapname)) < 0 ) + if( (m = map->mapname2mapid(mapname)) < 0 ) return true; if( strcmp(str,"Random") == 0 ) @@ -4654,7 +4651,7 @@ BUILDIN(areawarp) else if( !(index=mapindex_name2id(str)) ) return true; - iMap->foreachinarea(buildin_areawarp_sub, m,x0,y0,x1,y1, BL_PC, index,x2,y2,x3,y3); + map->foreachinarea(buildin_areawarp_sub, m,x0,y0,x1,y1, BL_PC, index,x2,y2,x3,y3); return true; } @@ -4669,8 +4666,7 @@ static int buildin_areapercentheal_sub(struct block_list *bl,va_list ap) pc->percentheal((TBL_PC *)bl,hp,sp); return 0; } -BUILDIN(areapercentheal) -{ +BUILDIN(areapercentheal) { int hp,sp,m; const char *mapname; int x0,y0,x1,y1; @@ -4683,10 +4679,10 @@ BUILDIN(areapercentheal) hp=script_getnum(st,7); sp=script_getnum(st,8); - if( (m=iMap->mapname2mapid(mapname))< 0) + if( (m=map->mapname2mapid(mapname))< 0) return true; - iMap->foreachinarea(buildin_areapercentheal_sub,m,x0,y0,x1,y1,BL_PC,hp,sp); + map->foreachinarea(buildin_areapercentheal_sub,m,x0,y0,x1,y1,BL_PC,hp,sp); return true; } @@ -4696,8 +4692,7 @@ BUILDIN(areapercentheal) * another player npc-session. * Using: warpchar "mapname",x,y,Char_ID; *------------------------------------------*/ -BUILDIN(warpchar) -{ +BUILDIN(warpchar) { int x,y,a; const char *str; TBL_PC *sd; @@ -4707,7 +4702,7 @@ BUILDIN(warpchar) y=script_getnum(st,4); a=script_getnum(st,5); - sd = iMap->charid2sd(a); + sd = map->charid2sd(a); if( sd == NULL ) return true; @@ -4874,8 +4869,7 @@ BUILDIN(warpguild) /*========================================== * Force Heal a player (hp and sp) *------------------------------------------*/ -BUILDIN(heal) -{ +BUILDIN(heal) { TBL_PC *sd; int hp,sp; @@ -4884,7 +4878,7 @@ BUILDIN(heal) hp=script_getnum(st,2); sp=script_getnum(st,3); - iStatus->heal(&sd->bl, hp, sp, 1); + status->heal(&sd->bl, hp, sp, 1); return true; } /*========================================== @@ -5932,7 +5926,7 @@ BUILDIN(getitem) it.identify=itemdb->isidentified2(item_data); if( script_hasdata(st,4) ) - sd=iMap->id2sd(script_getnum(st,4)); // <Account ID> + sd=map->id2sd(script_getnum(st,4)); // <Account ID> else sd=script_rid2sd(st); // Attached player @@ -5945,16 +5939,13 @@ BUILDIN(getitem) else get_count = amount; - for (i = 0; i < amount; i += get_count) - { + for (i = 0; i < amount; i += get_count) { // if not pet egg - if (!pet->create_egg(sd, nameid)) - { - if ((flag = pc->additem(sd, &it, get_count, LOG_TYPE_SCRIPT))) - { + if (!pet->create_egg(sd, nameid)) { + if ((flag = pc->additem(sd, &it, get_count, LOG_TYPE_SCRIPT))) { clif->additem(sd, 0, 0, flag); if( pc->candrop(sd,&it) ) - iMap->addflooritem(&it,get_count,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); + map->addflooritem(&it,get_count,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); } } } @@ -5975,7 +5966,7 @@ BUILDIN(getitem2) struct script_data *data; if( script_hasdata(st,11) ) - sd=iMap->id2sd(script_getnum(st,11)); // <Account ID> + sd=map->id2sd(script_getnum(st,11)); // <Account ID> else sd=script_rid2sd(st); // Attached player @@ -6043,16 +6034,13 @@ BUILDIN(getitem2) else get_count = amount; - for (i = 0; i < amount; i += get_count) - { + for (i = 0; i < amount; i += get_count) { // if not pet egg - if (!pet->create_egg(sd, nameid)) - { - if ((flag = pc->additem(sd, &item_tmp, get_count, LOG_TYPE_SCRIPT))) - { + if (!pet->create_egg(sd, nameid)) { + if ((flag = pc->additem(sd, &item_tmp, get_count, LOG_TYPE_SCRIPT))) { clif->additem(sd, 0, 0, flag); if( pc->candrop(sd,&item_tmp) ) - iMap->addflooritem(&item_tmp,get_count,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); + map->addflooritem(&item_tmp,get_count,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); } } } @@ -6162,10 +6150,10 @@ BUILDIN(getnameditem) data=script_getdata(st,3); script->get_val(st,data); - if( data_isstring(data) ) //Char Name - tsd=iMap->nick2sd(script->conv_str(st,data)); - else //Char Id was given - tsd=iMap->charid2sd(script->conv_num(st,data)); + if( data_isstring(data) ) //Char Name + tsd=map->nick2sd(script->conv_str(st,data)); + else //Char Id was given + tsd=map->charid2sd(script->conv_num(st,data)); if( tsd == NULL ) { //Failed @@ -6252,14 +6240,13 @@ BUILDIN(makeitem) x =script_getnum(st,5); y =script_getnum(st,6); - if(strcmp(mapname,"this")==0) - { + if(strcmp(mapname,"this")==0) { TBL_PC *sd; sd = script_rid2sd(st); if (!sd) return true; //Failed... m=sd->bl.m; } else - m=iMap->mapname2mapid(mapname); + m=map->mapname2mapid(mapname); if( m == -1 ) { ShowError("makeitem: creating map on unexistent map '%s'!\n", mapname); @@ -6274,7 +6261,7 @@ BUILDIN(makeitem) else item_tmp.identify=itemdb->isidentified2(item_data); - iMap->addflooritem(&item_tmp,amount,m,x,y,0,0,0,0); + map->addflooritem(&item_tmp,amount,m,x,y,0,0,0,0); return true; } @@ -6435,7 +6422,7 @@ BUILDIN(delitem) if( script_hasdata(st,4) ) { int account_id = script_getnum(st,4); - sd = iMap->id2sd(account_id); // <account id> + sd = map->id2sd(account_id); // <account id> if( sd == NULL ) { ShowError("script:delitem: player not found (AID=%d).\n", account_id); @@ -6495,18 +6482,15 @@ BUILDIN(delitem) /// /// delitem2 <item id>,<amount>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>{,<account ID>} /// delitem2 "<Item name>",<amount>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>{,<account ID>} -BUILDIN(delitem2) -{ +BUILDIN(delitem2) { TBL_PC *sd; struct item it; struct script_data *data; - if( script_hasdata(st,11) ) - { + if( script_hasdata(st,11) ) { int account_id = script_getnum(st,11); - sd = iMap->id2sd(account_id); // <account id> - if( sd == NULL ) - { + sd = map->id2sd(account_id); // <account id> + if( sd == NULL ) { ShowError("script:delitem2: player not found (AID=%d).\n", account_id); st->state = END; return false; @@ -6592,14 +6576,13 @@ BUILDIN(disableitemuse) * return the basic stats of sd * chk pc->readparam for available type *------------------------------------------*/ -BUILDIN(readparam) -{ +BUILDIN(readparam) { int type; TBL_PC *sd; type=script_getnum(st,2); if( script_hasdata(st,3) ) - sd=iMap->nick2sd(script_getstr(st,3)); + sd=map->nick2sd(script_getstr(st,3)); else sd=script_rid2sd(st); @@ -6622,14 +6605,13 @@ BUILDIN(readparam) * 3 : account_id * 4 : bg_id *------------------------------------------*/ -BUILDIN(getcharid) -{ +BUILDIN(getcharid) { int num; TBL_PC *sd; num = script_getnum(st,2); if( script_hasdata(st,3) ) - sd=iMap->nick2sd(script_getstr(st,3)); + sd=map->nick2sd(script_getstr(st,3)); else sd=script_rid2sd(st); @@ -6905,13 +6887,12 @@ BUILDIN(strcharinfo) * 3 : ::str * 4 : map name *------------------------------------------*/ -BUILDIN(strnpcinfo) -{ +BUILDIN(strnpcinfo) { TBL_NPC* nd; int num; char *buf,*name=NULL; - nd = iMap->id2nd(st->oid); + nd = map->id2nd(st->oid); if (!nd) { script_pushconststr(st, ""); return true; @@ -7253,8 +7234,7 @@ BUILDIN(getequipweaponlv) * x : refine chance * 0 : false (max refine level or unequip..) *------------------------------------------*/ -BUILDIN(getequippercentrefinery) -{ +BUILDIN(getequippercentrefinery) { int i = -1,num; TBL_PC *sd; @@ -7266,7 +7246,7 @@ BUILDIN(getequippercentrefinery) if (num > 0 && num <= ARRAYLENGTH(equip)) i=pc->checkequip(sd,equip[num-1]); if(i >= 0 && sd->status.inventory[i].nameid && sd->status.inventory[i].refine < MAX_REFINE) - script_pushint(st,iStatus->get_refine_chance(itemdb_wlv(sd->status.inventory[i].nameid), (int)sd->status.inventory[i].refine)); + script_pushint(st,status->get_refine_chance(itemdb_wlv(sd->status.inventory[i].nameid), (int)sd->status.inventory[i].refine)); else script_pushint(st,0); @@ -7544,8 +7524,7 @@ BUILDIN(bonus) return true; } -BUILDIN(autobonus) -{ +BUILDIN(autobonus) { unsigned int dur; short rate; short atk_type = 0; @@ -7556,7 +7535,7 @@ BUILDIN(autobonus) if( sd == NULL ) return true; // no player attached - if( sd->state.autobonus&sd->status.inventory[iStatus->current_equip_item_index].equip ) + if( sd->state.autobonus&sd->status.inventory[status->current_equip_item_index].equip ) return true; rate = script_getnum(st,3); @@ -7570,9 +7549,9 @@ BUILDIN(autobonus) if( script_hasdata(st,6) ) other_script = script_getstr(st,6); - if( pc->addautobonus(sd->autobonus,ARRAYLENGTH(sd->autobonus), - bonus_script,rate,dur,atk_type,other_script,sd->status.inventory[iStatus->current_equip_item_index].equip,false) ) - { + if( pc->addautobonus(sd->autobonus,ARRAYLENGTH(sd->autobonus),bonus_script,rate,dur,atk_type,other_script, + sd->status.inventory[status->current_equip_item_index].equip,false) + ) { script_add_autobonus(bonus_script); if( other_script ) script_add_autobonus(other_script); @@ -7581,8 +7560,7 @@ BUILDIN(autobonus) return true; } -BUILDIN(autobonus2) -{ +BUILDIN(autobonus2) { unsigned int dur; short rate; short atk_type = 0; @@ -7593,7 +7571,7 @@ BUILDIN(autobonus2) if( sd == NULL ) return true; // no player attached - if( sd->state.autobonus&sd->status.inventory[iStatus->current_equip_item_index].equip ) + if( sd->state.autobonus&sd->status.inventory[status->current_equip_item_index].equip ) return true; rate = script_getnum(st,3); @@ -7607,9 +7585,9 @@ BUILDIN(autobonus2) if( script_hasdata(st,6) ) other_script = script_getstr(st,6); - if( pc->addautobonus(sd->autobonus2,ARRAYLENGTH(sd->autobonus2), - bonus_script,rate,dur,atk_type,other_script,sd->status.inventory[iStatus->current_equip_item_index].equip,false) ) - { + if( pc->addautobonus(sd->autobonus2,ARRAYLENGTH(sd->autobonus2),bonus_script,rate,dur,atk_type,other_script, + sd->status.inventory[status->current_equip_item_index].equip,false) + ) { script_add_autobonus(bonus_script); if( other_script ) script_add_autobonus(other_script); @@ -7618,8 +7596,7 @@ BUILDIN(autobonus2) return true; } -BUILDIN(autobonus3) -{ +BUILDIN(autobonus3) { unsigned int dur; short rate,atk_type; TBL_PC* sd; @@ -7629,7 +7606,7 @@ BUILDIN(autobonus3) if( sd == NULL ) return true; // no player attached - if( sd->state.autobonus&sd->status.inventory[iStatus->current_equip_item_index].equip ) + if( sd->state.autobonus&sd->status.inventory[status->current_equip_item_index].equip ) return true; rate = script_getnum(st,3); @@ -7642,9 +7619,9 @@ BUILDIN(autobonus3) if( script_hasdata(st,6) ) other_script = script_getstr(st,6); - if( pc->addautobonus(sd->autobonus3,ARRAYLENGTH(sd->autobonus3), - bonus_script,rate,dur,atk_type,other_script,sd->status.inventory[iStatus->current_equip_item_index].equip,true) ) - { + if( pc->addautobonus(sd->autobonus3,ARRAYLENGTH(sd->autobonus3),bonus_script,rate,dur,atk_type,other_script, + sd->status.inventory[status->current_equip_item_index].equip,true) + ) { script_add_autobonus(bonus_script); if( other_script ) script_add_autobonus(other_script); @@ -8410,15 +8387,14 @@ BUILDIN(guildgetexp) /*========================================== * Changes the guild master of a guild [Skotlex] *------------------------------------------*/ -BUILDIN(guildchangegm) -{ +BUILDIN(guildchangegm) { TBL_PC *sd; int guild_id; const char *name; guild_id = script_getnum(st,2); name = script_getstr(st,3); - sd=iMap->nick2sd(name); + sd=map->nick2sd(name); if (!sd) script_pushint(st,0); @@ -8484,13 +8460,12 @@ BUILDIN(monster) return false; } - sd = iMap->id2sd(st->rid); + sd = map->id2sd(st->rid); if (sd && strcmp(mapn, "this") == 0) m = sd->bl.m; else { - - if ( ( m = iMap->mapname2mapid(mapn) ) == -1 ) { + if ( ( m = map->mapname2mapid(mapn) ) == -1 ) { ShowWarning("buildin_monster: Attempted to spawn monster class %d on non-existing map '%s'\n",class_, mapn); return false; } @@ -8584,12 +8559,12 @@ BUILDIN(areamonster) } } - sd = iMap->id2sd(st->rid); + sd = map->id2sd(st->rid); if (sd && strcmp(mapn, "this") == 0) m = sd->bl.m; else { - if ( ( m = iMap->mapname2mapid(mapn) ) == -1 ) { + if ( ( m = map->mapname2mapid(mapn) ) == -1 ) { ShowWarning("buildin_areamonster: Attempted to spawn monster class %d on non-existing map '%s'\n",class_, mapn); return false; } @@ -8642,8 +8617,7 @@ static int buildin_killmonster_sub(struct block_list *bl,va_list ap) } return 0; } -BUILDIN(killmonster) -{ +BUILDIN(killmonster) { const char *mapname,*event; int16 m,allflag=0; mapname=script_getstr(st,2); @@ -8653,7 +8627,7 @@ BUILDIN(killmonster) else check_event(st, event); - if( (m=iMap->mapname2mapid(mapname))<0 ) + if( (m=map->mapname2mapid(mapname))<0 ) return true; if( maplist[m].flag.src4instance && st->instance_id >= 0 && (m = instance->mapid2imapid(m, st->instance_id)) < 0 ) @@ -8661,14 +8635,14 @@ BUILDIN(killmonster) if( script_hasdata(st,4) ) { if ( script_getnum(st,4) == 1 ) { - iMap->foreachinmap(buildin_killmonster_sub, m, BL_MOB, event ,allflag); + map->foreachinmap(buildin_killmonster_sub, m, BL_MOB, event ,allflag); return true; } } - iMap->freeblock_lock(); - iMap->foreachinmap(buildin_killmonster_sub_strip, m, BL_MOB, event ,allflag); - iMap->freeblock_unlock(); + map->freeblock_lock(); + map->foreachinmap(buildin_killmonster_sub_strip, m, BL_MOB, event ,allflag); + map->freeblock_unlock(); return true; } @@ -8688,13 +8662,12 @@ static int buildin_killmonsterall_sub(struct block_list *bl,va_list ap) status_kill(bl); return 0; } -BUILDIN(killmonsterall) -{ +BUILDIN(killmonsterall) { const char *mapname; int16 m; mapname=script_getstr(st,2); - if( (m = iMap->mapname2mapid(mapname))<0 ) + if( (m = map->mapname2mapid(mapname))<0 ) return true; if( maplist[m].flag.src4instance && st->instance_id >= 0 && (m = instance->mapid2imapid(m, st->instance_id)) < 0 ) @@ -8702,12 +8675,12 @@ BUILDIN(killmonsterall) if( script_hasdata(st,3) ) { if ( script_getnum(st,3) == 1 ) { - iMap->foreachinmap(buildin_killmonsterall_sub,m,BL_MOB); + map->foreachinmap(buildin_killmonsterall_sub,m,BL_MOB); return true; } } - iMap->foreachinmap(buildin_killmonsterall_sub_strip,m,BL_MOB); + map->foreachinmap(buildin_killmonsterall_sub_strip,m,BL_MOB); return true; } @@ -8741,13 +8714,13 @@ BUILDIN(clone) { check_event(st, event); - m = iMap->mapname2mapid(mapname); + m = map->mapname2mapid(mapname); if (m < 0) return true; - sd = iMap->charid2sd(char_id); + sd = map->charid2sd(char_id); if (master_id) { - msd = iMap->charid2sd(master_id); + msd = map->charid2sd(master_id); if (msd) master_id = msd->bl.id; else @@ -8783,7 +8756,7 @@ BUILDIN(donpcevent) const char* event = script_getstr(st,2); check_event(st, event); if( !npc->event_do(event) ) { - struct npc_data * nd = iMap->id2nd(st->oid); + struct npc_data * nd = map->id2nd(st->oid); ShowDebug("NPCEvent '%s' not found! (source: %s)\n",event,nd?nd->name:"Unknown"); script_pushint(st, 0); } else @@ -8874,19 +8847,16 @@ BUILDIN(initnpctimer) script->get_val(st,data); if( data_isstring(data) ) //NPC name nd = npc->name2id(script->conv_str(st, data)); - else if( data_isint(data) ) //Flag - { - nd = (struct npc_data *)iMap->id2bl(st->oid); + else if( data_isint(data) ) { + //Flag + nd = (struct npc_data *)map->id2bl(st->oid); flag = script->conv_num(st,data); - } - else - { + } else { ShowError("initnpctimer: invalid argument type #1 (needs be int or string)).\n"); return false; } - } - else - nd = (struct npc_data *)iMap->id2bl(st->oid); + } else + nd = (struct npc_data *)map->id2bl(st->oid); if( !nd ) return true; @@ -8922,19 +8892,16 @@ BUILDIN(startnpctimer) script->get_val(st,data); if( data_isstring(data) ) //NPC name nd = npc->name2id(script->conv_str(st, data)); - else if( data_isint(data) ) //Flag - { - nd = (struct npc_data *)iMap->id2bl(st->oid); + else if( data_isint(data) ) { + //Flag + nd = (struct npc_data *)map->id2bl(st->oid); flag = script->conv_num(st,data); - } - else - { + } else { ShowError("initnpctimer: invalid argument type #1 (needs be int or string)).\n"); return false; } - } - else - nd=(struct npc_data *)iMap->id2bl(st->oid); + } else + nd=(struct npc_data *)map->id2bl(st->oid); if( !nd ) return true; @@ -8951,8 +8918,7 @@ BUILDIN(startnpctimer) } /*========================================== *------------------------------------------*/ -BUILDIN(stopnpctimer) -{ +BUILDIN(stopnpctimer) { struct npc_data *nd; int flag = 0; @@ -8968,19 +8934,16 @@ BUILDIN(stopnpctimer) script->get_val(st,data); if( data_isstring(data) ) //NPC name nd = npc->name2id(script->conv_str(st, data)); - else if( data_isint(data) ) //Flag - { - nd = (struct npc_data *)iMap->id2bl(st->oid); + else if( data_isint(data) ) { + //Flag + nd = (struct npc_data *)map->id2bl(st->oid); flag = script->conv_num(st,data); - } - else - { + } else { ShowError("initnpctimer: invalid argument type #1 (needs be int or string)).\n"); return false; } - } - else - nd=(struct npc_data *)iMap->id2bl(st->oid); + } else + nd=(struct npc_data *)map->id2bl(st->oid); if( !nd ) return true; @@ -8992,8 +8955,7 @@ BUILDIN(stopnpctimer) } /*========================================== *------------------------------------------*/ -BUILDIN(getnpctimer) -{ +BUILDIN(getnpctimer) { struct npc_data *nd; TBL_PC *sd; int type = script_getnum(st,2); @@ -9002,7 +8964,7 @@ BUILDIN(getnpctimer) if( script_hasdata(st,3) ) nd = npc->name2id(script_getstr(st,3)); else - nd = (struct npc_data *)iMap->id2bl(st->oid); + nd = (struct npc_data *)map->id2bl(st->oid); if( !nd || nd->bl.type != BL_NPC ) { @@ -9011,15 +8973,12 @@ BUILDIN(getnpctimer) return false; } - switch( type ) - { + switch( type ) { case 0: val = npc->gettimerevent_tick(nd); break; case 1: - if( nd->u.scr.rid ) - { - sd = iMap->id2sd(nd->u.scr.rid); - if( !sd ) - { + if( nd->u.scr.rid ) { + sd = map->id2sd(nd->u.scr.rid); + if( !sd ) { ShowError("buildin_getnpctimer: Attached player not found!\n"); break; } @@ -9045,10 +9004,9 @@ BUILDIN(setnpctimer) if( script_hasdata(st,3) ) nd = npc->name2id(script_getstr(st,3)); else - nd = (struct npc_data *)iMap->id2bl(st->oid); + nd = (struct npc_data *)map->id2bl(st->oid); - if( !nd || nd->bl.type != BL_NPC ) - { + if( !nd || nd->bl.type != BL_NPC ) { script_pushint(st,1); ShowError("setnpctimer: Invalid NPC.\n"); return false; @@ -9062,10 +9020,9 @@ BUILDIN(setnpctimer) /*========================================== * attaches the player rid to the timer [Celest] *------------------------------------------*/ -BUILDIN(attachnpctimer) -{ +BUILDIN(attachnpctimer) { TBL_PC *sd; - struct npc_data *nd = (struct npc_data *)iMap->id2bl(st->oid); + struct npc_data *nd = (struct npc_data *)map->id2bl(st->oid); if( !nd || nd->bl.type != BL_NPC ) { @@ -9075,7 +9032,7 @@ BUILDIN(attachnpctimer) } if( script_hasdata(st,2) ) - sd = iMap->nick2sd(script_getstr(st,2)); + sd = map->nick2sd(script_getstr(st,2)); else sd = script_rid2sd(st); @@ -9094,14 +9051,13 @@ BUILDIN(attachnpctimer) /*========================================== * detaches a player rid from the timer [Celest] *------------------------------------------*/ -BUILDIN(detachnpctimer) -{ +BUILDIN(detachnpctimer) { struct npc_data *nd; if( script_hasdata(st,2) ) nd = npc->name2id(script_getstr(st,2)); else - nd = (struct npc_data *)iMap->id2bl(st->oid); + nd = (struct npc_data *)map->id2bl(st->oid); if( !nd || nd->bl.type != BL_NPC ) { @@ -9120,9 +9076,8 @@ BUILDIN(detachnpctimer) * it checks if there is a player attached to the current script. [Skotlex] * If no, returns 0, if yes, returns the account_id of the attached player. *------------------------------------------*/ -BUILDIN(playerattached) -{ - if(st->rid == 0 || iMap->id2sd(st->rid) == NULL) +BUILDIN(playerattached) { + if(st->rid == 0 || map->id2sd(st->rid) == NULL) script_pushint(st,0); else script_pushint(st,st->rid); @@ -9143,7 +9098,7 @@ BUILDIN(announce) { if( flag&(BC_TARGET_MASK|BC_SOURCE_MASK) ) { // Broadcast source or broadcast region defined send_target target; - struct block_list *bl = (flag&BC_NPC) ? iMap->id2bl(st->oid) : (struct block_list *)script_rid2sd(st); // If bc_npc flag is set, use NPC as broadcast source + struct block_list *bl = (flag&BC_NPC) ? map->id2bl(st->oid) : (struct block_list *)script_rid2sd(st); // If bc_npc flag is set, use NPC as broadcast source if (bl == NULL) return true; @@ -9194,7 +9149,7 @@ BUILDIN(itemeffect) { struct item_data *item_data; nullpo_retr( 1, ( sd = script_rid2sd( st ) ) ); - nullpo_retr( 1, ( nd = (TBL_NPC *)iMap->id2bl( sd->npc_id ) ) ); + nullpo_retr( 1, ( nd = (TBL_NPC *)map->id2bl( sd->npc_id ) ) ); data = script_getdata( st, 2 ); script->get_val( st, data ); @@ -9223,8 +9178,7 @@ BUILDIN(itemeffect) { return true; } -BUILDIN(mapannounce) -{ +BUILDIN(mapannounce) { const char *mapname = script_getstr(st,2); const char *mes = script_getstr(st,3); int flag = script_getnum(st,4); @@ -9235,17 +9189,16 @@ BUILDIN(mapannounce) int fontY = script_hasdata(st,9) ? script_getnum(st,9) : 0; // default fontY int16 m; - if ((m = iMap->mapname2mapid(mapname)) < 0) + if ((m = map->mapname2mapid(mapname)) < 0) return true; - iMap->foreachinmap(buildin_announce_sub, m, BL_PC, - mes, strlen(mes)+1, flag&BC_COLOR_MASK, fontColor, fontType, fontSize, fontAlign, fontY); + map->foreachinmap(buildin_announce_sub, m, BL_PC, + mes, strlen(mes)+1, flag&BC_COLOR_MASK, fontColor, fontType, fontSize, fontAlign, fontY); return true; } /*========================================== *------------------------------------------*/ -BUILDIN(areaannounce) -{ +BUILDIN(areaannounce) { const char *mapname = script_getstr(st,2); int x0 = script_getnum(st,3); int y0 = script_getnum(st,4); @@ -9260,11 +9213,11 @@ BUILDIN(areaannounce) int fontY = script_hasdata(st,13) ? script_getnum(st,13) : 0; // default fontY int16 m; - if ((m = iMap->mapname2mapid(mapname)) < 0) + if ((m = map->mapname2mapid(mapname)) < 0) return true; - iMap->foreachinarea(buildin_announce_sub, m, x0, y0, x1, y1, BL_PC, - mes, strlen(mes)+1, flag&BC_COLOR_MASK, fontColor, fontType, fontSize, fontAlign, fontY); + map->foreachinarea(buildin_announce_sub, m, x0, y0, x1, y1, BL_PC, + mes, strlen(mes)+1, flag&BC_COLOR_MASK, fontColor, fontType, fontSize, fontAlign, fontY); return true; } @@ -9281,7 +9234,7 @@ BUILDIN(getusers) { case 0: if(flag&0x8) { // npc - bl = iMap->id2bl(st->oid); + bl = map->id2bl(st->oid); } else if((sd = script_rid2sd(st))!=NULL) { // pc bl = &sd->bl; @@ -9292,7 +9245,7 @@ BUILDIN(getusers) { } break; case 1: - val = iMap->getusers(); + val = map->getusers(); break; default: ShowWarning("buildin_getusers: Unknown type %d.\n", flag); @@ -9344,7 +9297,7 @@ BUILDIN(getmapguildusers) struct guild *g = NULL; str=script_getstr(st,2); gid=script_getnum(st,3); - if ((m = iMap->mapname2mapid(str)) < 0) { // map id on this server (m == -1 if not in actual map-server) + if ((m = map->mapname2mapid(str)) < 0) { // map id on this server (m == -1 if not in actual map-server) script_pushint(st,-1); return true; } @@ -9367,7 +9320,7 @@ BUILDIN(getmapusers) { const char *str; int16 m; str=script_getstr(st,2); - if( (m=iMap->mapname2mapid(str))< 0){ + if( (m=map->mapname2mapid(str))< 0){ script_pushint(st,-1); return true; } @@ -9391,12 +9344,12 @@ BUILDIN(getareausers) y0=script_getnum(st,4); x1=script_getnum(st,5); y1=script_getnum(st,6); - if( (m=iMap->mapname2mapid(str))< 0){ + if( (m=map->mapname2mapid(str))< 0){ script_pushint(st,-1); return true; } - iMap->foreachinarea(buildin_getareausers_sub, - m,x0,y0,x1,y1,BL_PC,&users); + map->foreachinarea(buildin_getareausers_sub, + m,x0,y0,x1,y1,BL_PC,&users); script_pushint(st,users); return true; } @@ -9438,12 +9391,12 @@ BUILDIN(getareadropitem) }else item=script->conv_num(st,data); - if( (m=iMap->mapname2mapid(str))< 0){ + if( (m=map->mapname2mapid(str))< 0){ script_pushint(st,-1); return true; } - iMap->foreachinarea(buildin_getareadropitem_sub, - m,x0,y0,x1,y1,BL_ITEM,item,&amount); + map->foreachinarea(buildin_getareadropitem_sub, + m,x0,y0,x1,y1,BL_ITEM,item,&amount); script_pushint(st,amount); return true; } @@ -9488,8 +9441,7 @@ BUILDIN(hideonnpc) /// Starts a status effect on the target unit or on the attached player. /// /// sc_start <effect_id>,<duration>,<val1>{,<unit_id>}; -BUILDIN(sc_start) -{ +BUILDIN(sc_start) { struct block_list* bl; enum sc_type type; int tick; @@ -9500,24 +9452,24 @@ BUILDIN(sc_start) tick = script_getnum(st,3); val1 = script_getnum(st,4); if( script_hasdata(st,5) ) - bl = iMap->id2bl(script_getnum(st,5)); + bl = map->id2bl(script_getnum(st,5)); else - bl = iMap->id2bl(st->rid); + bl = map->id2bl(st->rid); - if( tick == 0 && val1 > 0 && type > SC_NONE && type < SC_MAX && iStatus->sc2skill(type) != 0 ) - {// When there isn't a duration specified, try to get it from the skill_db - tick = skill->get_time(iStatus->sc2skill(type), val1); + if( tick == 0 && val1 > 0 && type > SC_NONE && type < SC_MAX && status->sc2skill(type) != 0 ) { + // When there isn't a duration specified, try to get it from the skill_db + tick = skill->get_time(status->sc2skill(type), val1); } - if( script->potion_flag == 1 && script->potion_target ) - { //skill.c set the flags before running the script, this must be a potion-pitched effect. - bl = iMap->id2bl(script->potion_target); + if( script->potion_flag == 1 && script->potion_target ) { + //skill.c set the flags before running the script, this must be a potion-pitched effect. + bl = map->id2bl(script->potion_target); tick /= 2;// Thrown potions only last half. val4 = 1;// Mark that this was a thrown sc_effect } if( bl ) - iStatus->change_start(bl, type, 10000, val1, 0, 0, val4, tick, 2); + status->change_start(bl, type, 10000, val1, 0, 0, val4, tick, 2); return true; } @@ -9525,8 +9477,7 @@ BUILDIN(sc_start) /// Starts a status effect on the target unit or on the attached player. /// /// sc_start2 <effect_id>,<duration>,<val1>,<percent chance>{,<unit_id>}; -BUILDIN(sc_start2) -{ +BUILDIN(sc_start2) { struct block_list* bl; enum sc_type type; int tick; @@ -9539,24 +9490,24 @@ BUILDIN(sc_start2) val1 = script_getnum(st,4); rate = script_getnum(st,5); if( script_hasdata(st,6) ) - bl = iMap->id2bl(script_getnum(st,6)); + bl = map->id2bl(script_getnum(st,6)); else - bl = iMap->id2bl(st->rid); + bl = map->id2bl(st->rid); - if( tick == 0 && val1 > 0 && type > SC_NONE && type < SC_MAX && iStatus->sc2skill(type) != 0 ) - {// When there isn't a duration specified, try to get it from the skill_db - tick = skill->get_time(iStatus->sc2skill(type), val1); + if( tick == 0 && val1 > 0 && type > SC_NONE && type < SC_MAX && status->sc2skill(type) != 0 ) { + // When there isn't a duration specified, try to get it from the skill_db + tick = skill->get_time(status->sc2skill(type), val1); } - if( script->potion_flag == 1 && script->potion_target ) - { //skill.c set the flags before running the script, this must be a potion-pitched effect. - bl = iMap->id2bl(script->potion_target); + if( script->potion_flag == 1 && script->potion_target ) { + //skill.c set the flags before running the script, this must be a potion-pitched effect. + bl = map->id2bl(script->potion_target); tick /= 2;// Thrown potions only last half. val4 = 1;// Mark that this was a thrown sc_effect } if( bl ) - iStatus->change_start(bl, type, rate, val1, 0, 0, val4, tick, 2); + status->change_start(bl, type, rate, val1, 0, 0, val4, tick, 2); return true; } @@ -9564,8 +9515,7 @@ BUILDIN(sc_start2) /// Starts a status effect on the target unit or on the attached player. /// /// sc_start4 <effect_id>,<duration>,<val1>,<val2>,<val3>,<val4>{,<unit_id>}; -BUILDIN(sc_start4) -{ +BUILDIN(sc_start4) { struct block_list* bl; enum sc_type type; int tick; @@ -9581,23 +9531,23 @@ BUILDIN(sc_start4) val3 = script_getnum(st,6); val4 = script_getnum(st,7); if( script_hasdata(st,8) ) - bl = iMap->id2bl(script_getnum(st,8)); + bl = map->id2bl(script_getnum(st,8)); else - bl = iMap->id2bl(st->rid); + bl = map->id2bl(st->rid); - if( tick == 0 && val1 > 0 && type > SC_NONE && type < SC_MAX && iStatus->sc2skill(type) != 0 ) - {// When there isn't a duration specified, try to get it from the skill_db - tick = skill->get_time(iStatus->sc2skill(type), val1); + if( tick == 0 && val1 > 0 && type > SC_NONE && type < SC_MAX && status->sc2skill(type) != 0 ) { + // When there isn't a duration specified, try to get it from the skill_db + tick = skill->get_time(status->sc2skill(type), val1); } - if( script->potion_flag == 1 && script->potion_target ) - { //skill.c set the flags before running the script, this must be a potion-pitched effect. - bl = iMap->id2bl(script->potion_target); + if( script->potion_flag == 1 && script->potion_target ) { + //skill.c set the flags before running the script, this must be a potion-pitched effect. + bl = map->id2bl(script->potion_target); tick /= 2;// Thrown potions only last half. } if( bl ) - iStatus->change_start(bl, type, 10000, val1, val2, val3, val4, tick, 2); + status->change_start(bl, type, 10000, val1, val2, val3, val4, tick, 2); return true; } @@ -9605,40 +9555,35 @@ BUILDIN(sc_start4) /// Ends one or all status effects on the target unit or on the attached player. /// /// sc_end <effect_id>{,<unit_id>}; -BUILDIN(sc_end) -{ +BUILDIN(sc_end) { struct block_list* bl; int type; type = script_getnum(st, 2); if (script_hasdata(st, 3)) - bl = iMap->id2bl(script_getnum(st, 3)); + bl = map->id2bl(script_getnum(st, 3)); else - bl = iMap->id2bl(st->rid); + bl = map->id2bl(st->rid); if (script->potion_flag == 1 && script->potion_target) //##TODO how does this work [FlavioJS] - bl = iMap->id2bl(script->potion_target); + bl = map->id2bl(script->potion_target); if (!bl) return true; - if (type >= 0 && type < SC_MAX) - { - struct status_change *sc = iStatus->get_sc(bl); + if (type >= 0 && type < SC_MAX) { + struct status_change *sc = status->get_sc(bl); struct status_change_entry *sce = sc ? sc->data[type] : NULL; if (!sce) return true; - - switch (type) - { + switch (type) { case SC_WEIGHTOVER50: case SC_WEIGHTOVER90: case SC_NOCHAT: case SC_PUSH_CART: return true; - default: break; } @@ -9648,7 +9593,7 @@ BUILDIN(sc_end) status_change_end(bl, (sc_type)type, INVALID_TIMER); } else - iStatus->change_clear(bl, 3); // remove all effects + status->change_clear(bl, 3); // remove all effects return true; } @@ -9656,20 +9601,19 @@ BUILDIN(sc_end) /*========================================== * @FIXME atm will return reduced tick, 0 immune, 1 no tick *------------------------------------------*/ -BUILDIN(getscrate) -{ +BUILDIN(getscrate) { struct block_list *bl; int type,rate; type=script_getnum(st,2); rate=script_getnum(st,3); if( script_hasdata(st,4) ) //get for the bl assigned - bl = iMap->id2bl(script_getnum(st,4)); + bl = map->id2bl(script_getnum(st,4)); else - bl = iMap->id2bl(st->rid); + bl = map->id2bl(st->rid); if (bl) - rate = iStatus->get_sc_def(bl, (sc_type)type, 10000, 10000, 0); + rate = status->get_sc_def(bl, (sc_type)type, 10000, 10000, 0); script_pushint(st,rate); return true; @@ -9951,13 +9895,12 @@ BUILDIN(skillpointcount) /*========================================== * *------------------------------------------*/ -BUILDIN(changebase) -{ +BUILDIN(changebase) { TBL_PC *sd=NULL; int vclass; if( script_hasdata(st,3) ) - sd=iMap->id2sd(script_getnum(st,3)); + sd=map->id2sd(script_getnum(st,3)); else sd=script_rid2sd(st); @@ -9974,7 +9917,7 @@ BUILDIN(changebase) } if(sd->disguise == -1 && vclass != sd->vd.class_) { - iStatus->set_viewdata(&sd->bl, vclass); + status->set_viewdata(&sd->bl, vclass); //Updated client view. Base, Weapon and Cloth Colors. clif->changelook(&sd->bl,LOOK_BASE,sd->vd.class_); clif->changelook(&sd->bl,LOOK_WEAPON,sd->status.weapon); @@ -10006,9 +9949,8 @@ BUILDIN(changesex) /*========================================== * Works like 'announce' but outputs in the common chat window *------------------------------------------*/ -BUILDIN(globalmes) -{ - struct block_list *bl = iMap->id2bl(st->oid); +BUILDIN(globalmes) { + struct block_list *bl = map->id2bl(st->oid); struct npc_data *nd = (struct npc_data *)bl; const char *name=NULL,*mes; @@ -10033,8 +9975,7 @@ BUILDIN(globalmes) /// Creates a waiting room (chat room) for this npc. /// /// waitingroom "<title>",<limit>{,"<event>"{,<trigger>{,<zeny>{,<minlvl>{,<maxlvl>}}}}}; -BUILDIN(waitingroom) -{ +BUILDIN(waitingroom) { struct npc_data* nd; int pub = 1; const char* title = script_getstr(st, 2); @@ -10045,9 +9986,9 @@ BUILDIN(waitingroom) int minLvl = script_hasdata(st,7) ? script_getnum(st,7) : 1; int maxLvl = script_hasdata(st,8) ? script_getnum(st,8) : MAX_LEVEL; - nd = (struct npc_data *)iMap->id2bl(st->oid); + nd = (struct npc_data *)map->id2bl(st->oid); if( nd != NULL ) - chat->createnpcchat(nd, title, limit, pub, trigger, ev, zeny, minLvl, maxLvl); + chat->create_npc_chat(nd, title, limit, pub, trigger, ev, zeny, minLvl, maxLvl); return true; } @@ -10056,15 +9997,14 @@ BUILDIN(waitingroom) /// /// delwaitingroom "<npc_name>"; /// delwaitingroom; -BUILDIN(delwaitingroom) -{ +BUILDIN(delwaitingroom) { struct npc_data* nd; if( script_hasdata(st,2) ) nd = npc->name2id(script_getstr(st, 2)); else - nd = (struct npc_data *)iMap->id2bl(st->oid); + nd = (struct npc_data *)map->id2bl(st->oid); if( nd != NULL ) - chat->deletenpcchat(nd); + chat->delete_npc_chat(nd); return true; } @@ -10072,18 +10012,17 @@ BUILDIN(delwaitingroom) /// /// kickwaitingroomall "<npc_name>"; /// kickwaitingroomall; -BUILDIN(waitingroomkickall) -{ +BUILDIN(waitingroomkickall) { struct npc_data* nd; struct chat_data* cd; if( script_hasdata(st,2) ) nd = npc->name2id(script_getstr(st,2)); else - nd = (struct npc_data *)iMap->id2bl(st->oid); + nd = (struct npc_data *)map->id2bl(st->oid); - if( nd != NULL && (cd=(struct chat_data *)iMap->id2bl(nd->chat_id)) != NULL ) - chat->npckickall(cd); + if( nd != NULL && (cd=(struct chat_data *)map->id2bl(nd->chat_id)) != NULL ) + chat->npc_kick_all(cd); return true; } @@ -10091,18 +10030,17 @@ BUILDIN(waitingroomkickall) /// /// enablewaitingroomevent "<npc_name>"; /// enablewaitingroomevent; -BUILDIN(enablewaitingroomevent) -{ +BUILDIN(enablewaitingroomevent) { struct npc_data* nd; struct chat_data* cd; if( script_hasdata(st,2) ) nd = npc->name2id(script_getstr(st, 2)); else - nd = (struct npc_data *)iMap->id2bl(st->oid); + nd = (struct npc_data *)map->id2bl(st->oid); - if( nd != NULL && (cd=(struct chat_data *)iMap->id2bl(nd->chat_id)) != NULL ) - chat->enableevent(cd); + if( nd != NULL && (cd=(struct chat_data *)map->id2bl(nd->chat_id)) != NULL ) + chat->enable_event(cd); return true; } @@ -10110,18 +10048,17 @@ BUILDIN(enablewaitingroomevent) /// /// disablewaitingroomevent "<npc_name>"; /// disablewaitingroomevent; -BUILDIN(disablewaitingroomevent) -{ +BUILDIN(disablewaitingroomevent) { struct npc_data *nd; struct chat_data *cd; if( script_hasdata(st,2) ) nd = npc->name2id(script_getstr(st, 2)); else - nd = (struct npc_data *)iMap->id2bl(st->oid); + nd = (struct npc_data *)map->id2bl(st->oid); - if( nd != NULL && (cd=(struct chat_data *)iMap->id2bl(nd->chat_id)) != NULL ) - chat->disableevent(cd); + if( nd != NULL && (cd=(struct chat_data *)map->id2bl(nd->chat_id)) != NULL ) + chat->disable_event(cd); return true; } @@ -10139,8 +10076,7 @@ BUILDIN(disablewaitingroomevent) /// /// getwaitingroomstate(<type>,"<npc_name>") -> <info> /// getwaitingroomstate(<type>) -> <info> -BUILDIN(getwaitingroomstate) -{ +BUILDIN(getwaitingroomstate) { struct npc_data *nd; struct chat_data *cd; int type; @@ -10149,16 +10085,14 @@ BUILDIN(getwaitingroomstate) if( script_hasdata(st,3) ) nd = npc->name2id(script_getstr(st, 3)); else - nd = (struct npc_data *)iMap->id2bl(st->oid); + nd = (struct npc_data *)map->id2bl(st->oid); - if( nd == NULL || (cd=(struct chat_data *)iMap->id2bl(nd->chat_id)) == NULL ) - { + if( nd == NULL || (cd=(struct chat_data *)map->id2bl(nd->chat_id)) == NULL ) { script_pushint(st, -1); return true; } - switch(type) - { + switch(type) { case 0: script_pushint(st, cd->users); break; case 1: script_pushint(st, cd->limit); break; case 2: script_pushint(st, cd->trigger&0x7f); break; @@ -10195,8 +10129,8 @@ BUILDIN(warpwaitingpc) { struct chat_data* cd; TBL_PC* sd; - nd = (struct npc_data *)iMap->id2bl(st->oid); - if( nd == NULL || (cd=(struct chat_data *)iMap->id2bl(nd->chat_id)) == NULL ) + nd = (struct npc_data *)map->id2bl(st->oid); + if( nd == NULL || (cd=(struct chat_data *)map->id2bl(nd->chat_id)) == NULL ) return true; map_name = script_getstr(st,2); @@ -10254,11 +10188,10 @@ void script_detach_rid(struct script_state* st) { /*========================================== * Attach sd char id to script and detach current one if any *------------------------------------------*/ -BUILDIN(attachrid) -{ +BUILDIN(attachrid) { int rid = script_getnum(st,2); - if (iMap->id2sd(rid) != NULL) { + if (map->id2sd(rid) != NULL) { script_detach_rid(st); st->rid = rid; @@ -10279,9 +10212,8 @@ BUILDIN(detachrid) /*========================================== * Chk if account connected, (and charid from account if specified) *------------------------------------------*/ -BUILDIN(isloggedin) -{ - TBL_PC* sd = iMap->id2sd(script_getnum(st,2)); +BUILDIN(isloggedin) { + TBL_PC* sd = map->id2sd(script_getnum(st,2)); if (script_hasdata(st,3) && sd && sd->status.char_id != script_getnum(st,3)) sd = NULL; @@ -10293,8 +10225,7 @@ BUILDIN(isloggedin) /*========================================== * *------------------------------------------*/ -BUILDIN(setmapflagnosave) -{ +BUILDIN(setmapflagnosave) { int16 m,x,y; unsigned short mapindex; const char *str,*str2; @@ -10303,7 +10234,7 @@ BUILDIN(setmapflagnosave) str2=script_getstr(st,3); x=script_getnum(st,4); y=script_getnum(st,5); - m = iMap->mapname2mapid(str); + m = map->mapname2mapid(str); mapindex = mapindex_name2id(str2); if(m >= 0 && mapindex) { @@ -10324,7 +10255,7 @@ BUILDIN(getmapflag) str=script_getstr(st,2); i=script_getnum(st,3); - m = iMap->mapname2mapid(str); + m = map->mapname2mapid(str); if(m >= 0) { switch(i) { case MF_NOMEMO: script_pushint(st,maplist[m].flag.nomemo); break; @@ -10418,7 +10349,7 @@ BUILDIN(setmapflag) { val = script_getnum(st, 4); } - m = iMap->mapname2mapid(str); + m = map->mapname2mapid(str); if(m >= 0) { switch(i) { @@ -10431,7 +10362,7 @@ BUILDIN(setmapflag) { case MF_PVP: maplist[m].flag.pvp = 1; if( !battle_config.pk_mode ) { - iMap->foreachinmap(script_mapflag_pvp_sub,m,BL_PC); + map->foreachinmap(script_mapflag_pvp_sub,m,BL_PC); } break; case MF_PVP_NOPARTY: maplist[m].flag.pvp_noparty = 1; break; @@ -10506,7 +10437,7 @@ BUILDIN(removemapflag) { str=script_getstr(st,2); i=script_getnum(st,3); - m = iMap->mapname2mapid(str); + m = map->mapname2mapid(str); if(m >= 0) { switch(i) { case MF_NOMEMO: maplist[m].flag.nomemo = 0; break; @@ -10559,7 +10490,7 @@ BUILDIN(removemapflag) { 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, maplist[m].prev_zone); + map->zone_change2(m, maplist[m].prev_zone); break; case MF_NOCOMMAND: maplist[m].nocommand = 0; break; case MF_NODROP: maplist[m].flag.nodrop = 0; break; @@ -10592,11 +10523,11 @@ BUILDIN(pvpon) { struct block_list bl; str = script_getstr(st,2); - m = iMap->mapname2mapid(str); + m = map->mapname2mapid(str); 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->zone_change2(m, strdb_get(zone_db, MAP_ZONE_PVP_NAME)); maplist[m].flag.pvp = 1; clif->map_property_mapall(m, MAPPROPERTY_FREEPVPZONE); bl.type = BL_NUL; @@ -10642,11 +10573,11 @@ BUILDIN(pvpoff) { struct block_list bl; str=script_getstr(st,2); - m = iMap->mapname2mapid(str); + m = map->mapname2mapid(str); if(m < 0 || !maplist[m].flag.pvp) return true; //fixed Lupus - iMap->zone_change2(m, maplist[m].prev_zone); + map->zone_change2(m, maplist[m].prev_zone); maplist[m].flag.pvp = 0; clif->map_property_mapall(m, MAPPROPERTY_NOTHING); bl.type = BL_NUL; @@ -10656,7 +10587,7 @@ BUILDIN(pvpoff) { if(battle_config.pk_mode) // disable ranking options if pk_mode is on [Valaris] return true; - iMap->foreachinmap(buildin_pvpoff_sub, m, BL_PC); + map->foreachinmap(buildin_pvpoff_sub, m, BL_PC); return true; } @@ -10665,10 +10596,10 @@ BUILDIN(gvgon) { const char *str; str=script_getstr(st,2); - m = iMap->mapname2mapid(str); + m = map->mapname2mapid(str); if(m >= 0 && !maplist[m].flag.gvg) { struct block_list bl; - iMap->zone_change2(m, strdb_get(zone_db, MAP_ZONE_GVG_NAME)); + map->zone_change2(m, strdb_get(zone_db, MAP_ZONE_GVG_NAME)); maplist[m].flag.gvg = 1; clif->map_property_mapall(m, MAPPROPERTY_AGITZONE); bl.type = BL_NUL; @@ -10683,10 +10614,10 @@ BUILDIN(gvgoff) { const char *str; str=script_getstr(st,2); - m = iMap->mapname2mapid(str); + m = map->mapname2mapid(str); if(m >= 0 && maplist[m].flag.gvg) { struct block_list bl; - iMap->zone_change2(m, maplist[m].prev_zone); + map->zone_change2(m, maplist[m].prev_zone); maplist[m].flag.gvg = 0; clif->map_property_mapall(m, MAPPROPERTY_NOTHING); bl.type = BL_NUL; @@ -10701,8 +10632,7 @@ BUILDIN(gvgoff) { * emotion emotion#, <target: 0 - NPC, 1 - PC>, <NPC/PC name> *------------------------------------------*/ //Optional second parameter added by [Skotlex] -BUILDIN(emotion) -{ +BUILDIN(emotion) { int type; int player=0; @@ -10716,20 +10646,17 @@ BUILDIN(emotion) if (player) { TBL_PC *sd = NULL; if( script_hasdata(st,4) ) - sd = iMap->nick2sd(script_getstr(st,4)); + sd = map->nick2sd(script_getstr(st,4)); else sd = script_rid2sd(st); if (sd) clif->emotion(&sd->bl,type); + } else if( script_hasdata(st,4) ) { + TBL_NPC *nd = npc->name2id(script_getstr(st,4)); + if(nd) + clif->emotion(&nd->bl,type); } else - if( script_hasdata(st,4) ) - { - TBL_NPC *nd = npc->name2id(script_getstr(st,4)); - if(nd) - clif->emotion(&nd->bl,type); - } - else - clif->emotion(iMap->id2bl(st->oid),type); + clif->emotion(map->id2bl(st->oid),type); return true; } @@ -10760,52 +10687,47 @@ static int buildin_maprespawnguildid_sub_mob(struct block_list *bl,va_list ap) return 0; } -BUILDIN(maprespawnguildid) -{ +BUILDIN(maprespawnguildid) { const char *mapname=script_getstr(st,2); int g_id=script_getnum(st,3); int flag=script_getnum(st,4); - int16 m=iMap->mapname2mapid(mapname); + int16 m=map->mapname2mapid(mapname); if(m == -1) return true; //Catch ALL players (in case some are 'between maps' on execution time) - iMap->map_foreachpc(buildin_maprespawnguildid_sub_pc,m,g_id,flag); + map->map_foreachpc(buildin_maprespawnguildid_sub_pc,m,g_id,flag); if (flag&4) //Remove script mobs. - iMap->foreachinmap(buildin_maprespawnguildid_sub_mob,m,BL_MOB); + map->foreachinmap(buildin_maprespawnguildid_sub_mob,m,BL_MOB); return true; } -BUILDIN(agitstart) -{ - if(iMap->agit_flag==1) return true; // Agit already Start. - iMap->agit_flag=1; +BUILDIN(agitstart) { + if(map->agit_flag==1) return true; // Agit already Start. + map->agit_flag=1; guild->agit_start(); return true; } -BUILDIN(agitend) -{ - if(iMap->agit_flag==0) return true; // Agit already End. - iMap->agit_flag=0; +BUILDIN(agitend) { + if(map->agit_flag==0) return true; // Agit already End. + map->agit_flag=0; guild->agit_end(); return true; } -BUILDIN(agitstart2) -{ - if(iMap->agit2_flag==1) return true; // Agit2 already Start. - iMap->agit2_flag=1; +BUILDIN(agitstart2) { + if(map->agit2_flag==1) return true; // Agit2 already Start. + map->agit2_flag=1; guild->agit2_start(); return true; } -BUILDIN(agitend2) -{ - if(iMap->agit2_flag==0) return true; // Agit2 already End. - iMap->agit2_flag=0; +BUILDIN(agitend2) { + if(map->agit2_flag==0) return true; // Agit2 already End. + map->agit2_flag=0; guild->agit2_end(); return true; } @@ -10813,32 +10735,29 @@ BUILDIN(agitend2) /*========================================== * Returns whether woe is on or off. // choice script *------------------------------------------*/ -BUILDIN(agitcheck) -{ - script_pushint(st,iMap->agit_flag); +BUILDIN(agitcheck) { + script_pushint(st,map->agit_flag); return true; } /*========================================== * Returns whether woese is on or off. // choice script *------------------------------------------*/ -BUILDIN(agitcheck2) -{ - script_pushint(st,iMap->agit2_flag); +BUILDIN(agitcheck2) { + script_pushint(st,map->agit2_flag); return true; } /// Sets the guild_id of this npc. /// /// flagemblem <guild_id>; -BUILDIN(flagemblem) -{ +BUILDIN(flagemblem) { TBL_NPC* nd; int g_id = script_getnum(st,2); if(g_id < 0) return true; - nd = (TBL_NPC*)iMap->id2nd(st->oid); + nd = (TBL_NPC*)map->id2nd(st->oid); if( nd == NULL ) { ShowError("script:flagemblem: npc %d not found\n", st->oid); } else if( nd->subtype != SCRIPT ) { @@ -11009,7 +10928,7 @@ BUILDIN(successremovecards) { if((flag=pc->additem(sd,&item_tmp,1,LOG_TYPE_SCRIPT))){ // get back the cart in inventory clif->additem(sd,0,0,flag); - iMap->addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); + map->addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); } } } @@ -11031,7 +10950,7 @@ BUILDIN(successremovecards) { pc->delitem(sd,i,1,0,3,LOG_TYPE_SCRIPT); if((flag=pc->additem(sd,&item_tmp,1,LOG_TYPE_SCRIPT))){ //chk if can be spawn in inventory otherwise put on floor clif->additem(sd,0,0,flag); - iMap->addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); + map->addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); } clif->misceffect(&sd->bl,3); @@ -11076,7 +10995,7 @@ BUILDIN(failedremovecards) { if((flag=pc->additem(sd,&item_tmp,1,LOG_TYPE_SCRIPT))){ clif->additem(sd,0,0,flag); - iMap->addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); + map->addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); } } } @@ -11105,7 +11024,7 @@ BUILDIN(failedremovecards) { if((flag=pc->additem(sd,&item_tmp,1,LOG_TYPE_SCRIPT))){ clif->additem(sd,0,0,flag); - iMap->addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); + map->addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); } } clif->misceffect(&sd->bl,2); @@ -11119,8 +11038,8 @@ BUILDIN(failedremovecards) { * type: 0=everyone, 1=guild, 2=party; [Reddozen] * improved by [Lance] * ================================================================*/ -BUILDIN(mapwarp) // Added by RoVeRT -{ +// Added by RoVeRT +BUILDIN(mapwarp) { int x,y,m,check_val=0,check_ID=0,i=0; struct guild *g = NULL; struct party_data *p = NULL; @@ -11136,7 +11055,7 @@ BUILDIN(mapwarp) // Added by RoVeRT check_ID=script_getnum(st,7); } - if((m=iMap->mapname2mapid(mapname))< 0) + if((m=map->mapname2mapid(mapname))< 0) return true; if(!(index=mapindex_name2id(str))) @@ -11165,7 +11084,7 @@ BUILDIN(mapwarp) // Added by RoVeRT } break; default: - iMap->foreachinmap(buildin_areawarp_sub,m,BL_PC,index,x,y,0,0); + map->foreachinmap(buildin_areawarp_sub,m,BL_PC,index,x,y,0,0); break; } @@ -11181,8 +11100,8 @@ static int buildin_mobcount_sub(struct block_list *bl,va_list ap) // Added by Ro return 0; } -BUILDIN(mobcount) // Added by RoVeRT -{ +// Added by RoVeRT +BUILDIN(mobcount) { const char *mapname,*event; int16 m; mapname=script_getstr(st,2); @@ -11201,7 +11120,7 @@ BUILDIN(mobcount) // Added by RoVeRT script_pushint(st,-1); return true; } - } else if( (m = iMap->mapname2mapid(mapname)) < 0 ) { + } else if( (m = map->mapname2mapid(mapname)) < 0 ) { script_pushint(st,-1); return true; } @@ -11211,16 +11130,15 @@ BUILDIN(mobcount) // Added by RoVeRT return true; } - script_pushint(st,iMap->foreachinmap(buildin_mobcount_sub, m, BL_MOB, event)); + script_pushint(st,map->foreachinmap(buildin_mobcount_sub, m, BL_MOB, event)); return true; } -BUILDIN(marriage) -{ +BUILDIN(marriage) { const char *partner=script_getstr(st,2); TBL_PC *sd=script_rid2sd(st); - TBL_PC *p_sd=iMap->nick2sd(partner); + TBL_PC *p_sd=map->nick2sd(partner); if(sd==NULL || p_sd==NULL || pc->marriage(sd,p_sd) < 0){ script_pushint(st,0); @@ -11229,13 +11147,12 @@ BUILDIN(marriage) script_pushint(st,1); return true; } -BUILDIN(wedding_effect) -{ +BUILDIN(wedding_effect) { TBL_PC *sd=script_rid2sd(st); struct block_list *bl; if(sd==NULL) { - bl=iMap->id2bl(st->oid); + bl=map->id2bl(st->oid); } else bl=&sd->bl; clif->wedding_effect(bl); @@ -11252,12 +11169,11 @@ BUILDIN(divorce) return true; } -BUILDIN(ispartneron) -{ +BUILDIN(ispartneron) { TBL_PC *sd=script_rid2sd(st); if(sd==NULL || !pc->ismarried(sd) || - iMap->charid2sd(sd->status.partner_id) == NULL) { + map->charid2sd(sd->status.partner_id) == NULL) { script_pushint(st,0); return true; } @@ -11323,7 +11239,7 @@ BUILDIN(warppartner) TBL_PC *p_sd=NULL; if(sd==NULL || !pc->ismarried(sd) || - (p_sd=iMap->charid2sd(sd->status.partner_id)) == NULL) { + (p_sd=map->charid2sd(sd->status.partner_id)) == NULL) { script_pushint(st,0); return true; } @@ -11433,16 +11349,15 @@ BUILDIN(setwall) { shootable = script_getnum(st,7); name = script_getstr(st,8); - if( (m = iMap->mapname2mapid(mapname)) < 0 ) + if( (m = map->mapname2mapid(mapname)) < 0 ) return true; // Invalid Map - iMap->iwall_set(m, x, y, size, dir, shootable, name); + map->iwall_set(m, x, y, size, dir, shootable, name); return true; } -BUILDIN(delwall) -{ +BUILDIN(delwall) { const char *name = script_getstr(st,2); - iMap->iwall_remove(name); + map->iwall_remove(name); return true; } @@ -11454,8 +11369,7 @@ BUILDIN(delwall) /// 1 - maximum hp /// 2 - current hp /// -BUILDIN(guardianinfo) -{ +BUILDIN(guardianinfo) { const char* mapname = mapindex_getmapname(script_getstr(st,2),NULL); int id = script_getnum(st,3); int type = script_getnum(st,4); @@ -11463,27 +11377,23 @@ BUILDIN(guardianinfo) struct guild_castle* gc = guild->mapname2gc(mapname); struct mob_data* gd; - if( gc == NULL || id < 0 || id >= MAX_GUARDIANS ) - { + if( gc == NULL || id < 0 || id >= MAX_GUARDIANS ) { script_pushint(st,-1); return true; } if( type == 0 ) script_pushint(st, gc->guardian[id].visible); + else if( !gc->guardian[id].visible ) + script_pushint(st,-1); + else if( (gd = map->id2md(gc->guardian[id].id)) == NULL ) + script_pushint(st,-1); + else if( type == 1 ) + script_pushint(st,gd->status.max_hp); + else if( type == 2 ) + script_pushint(st,gd->status.hp); else - if( !gc->guardian[id].visible ) - script_pushint(st,-1); - else - if( (gd = iMap->id2md(gc->guardian[id].id)) == NULL ) - script_pushint(st,-1); - else - { - if ( type == 1 ) script_pushint(st,gd->status.max_hp); - else if( type == 2 ) script_pushint(st,gd->status.hp); - else - script_pushint(st,-1); - } + script_pushint(st,-1); return true; } @@ -11834,10 +11744,9 @@ BUILDIN(undisguise) * Transform a bl to another _class, * @type unused *------------------------------------------*/ -BUILDIN(classchange) -{ +BUILDIN(classchange) { int _class,type; - struct block_list *bl=iMap->id2bl(st->oid); + struct block_list *bl=map->id2bl(st->oid); if(bl==NULL) return true; @@ -11856,7 +11765,7 @@ BUILDIN(misceffect) type=script_getnum(st,2); if(st->oid && st->oid != npc->fake_nd->bl.id) { - struct block_list *bl = iMap->id2bl(st->oid); + struct block_list *bl = map->id2bl(st->oid); if (bl) clif->specialeffect(bl,type,AREA); } else{ @@ -11918,28 +11827,26 @@ BUILDIN(playBGMall) { int y1 = script_getnum(st,7); int m; - if ( ( m = iMap->mapname2mapid(mapname) ) == -1 ) { + if ( ( m = map->mapname2mapid(mapname) ) == -1 ) { ShowWarning("playBGMall: Attempted to play song '%s' on non-existent map '%s'\n",name, mapname); return true; } - iMap->foreachinarea(playBGM_sub, m, x0, y0, x1, y1, BL_PC, name); - } - else if( script_hasdata(st,3) ) - {// entire map + map->foreachinarea(playBGM_sub, m, x0, y0, x1, y1, BL_PC, name); + } else if( script_hasdata(st,3) ) { + // entire map const char* mapname = script_getstr(st,3); int m; - if ( ( m = iMap->mapname2mapid(mapname) ) == -1 ) { + if ( ( m = map->mapname2mapid(mapname) ) == -1 ) { ShowWarning("playBGMall: Attempted to play song '%s' on non-existent map '%s'\n",name, mapname); return true; } - iMap->foreachinmap(playBGM_sub, m, BL_PC, name); - } - else - {// entire server - iMap->map_foreachpc(&playBGM_foreachpc_sub, name); + map->foreachinmap(playBGM_sub, m, BL_PC, name); + } else { + // entire server + map->map_foreachpc(&playBGM_foreachpc_sub, name); } return true; @@ -11975,20 +11882,19 @@ int soundeffect_sub(struct block_list* bl,va_list ap) * Play a sound effect (.wav) on multiple clients * soundeffectall "<filepath>",<type>{,"<map name>"}{,<x0>,<y0>,<x1>,<y1>}; *------------------------------------------*/ -BUILDIN(soundeffectall) -{ +BUILDIN(soundeffectall) { struct block_list* bl; const char* name; int type; - bl = (st->rid) ? &(script_rid2sd(st)->bl) : iMap->id2bl(st->oid); + bl = (st->rid) ? &(script_rid2sd(st)->bl) : map->id2bl(st->oid); if (!bl) return true; name = script_getstr(st,2); type = script_getnum(st,3); - //FIXME: enumerating map squares (iMap->foreach) is slower than enumerating the list of online players (iMap->foreachpc?) [ultramage] + //FIXME: enumerating map squares (map->foreach) is slower than enumerating the list of online players (map->foreachpc?) [ultramage] if(!script_hasdata(st,4)) { // area around clif->soundeffectall(bl, name, type, AREA); @@ -11997,12 +11903,12 @@ BUILDIN(soundeffectall) const char *mapname = script_getstr(st,4); int m; - if ( ( m = iMap->mapname2mapid(mapname) ) == -1 ) { + if ( ( m = map->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); + map->foreachinmap(soundeffect_sub, m, BL_PC, name, type); } else if(script_hasdata(st,8)) { // specified part of map const char *mapname = script_getstr(st,4); int x0 = script_getnum(st,5); @@ -12011,12 +11917,12 @@ BUILDIN(soundeffectall) int y1 = script_getnum(st,8); int m; - if ( ( m = iMap->mapname2mapid(mapname) ) == -1 ) { + if ( ( m = map->mapname2mapid(mapname) ) == -1 ) { ShowWarning("soundeffectall: Attempted to play song '%s' (type %d) on non-existent map '%s'\n",name,type, mapname); return true; } - iMap->foreachinarea(soundeffect_sub, m, x0, y0, x1, y1, BL_PC, name, type); + map->foreachinarea(soundeffect_sub, m, x0, y0, x1, y1, BL_PC, name, type); } else { ShowError("buildin_soundeffectall: insufficient arguments for specific area broadcast.\n"); } @@ -12207,9 +12113,8 @@ BUILDIN(skilleffect) *------------------------------------------*/ /// npcskilleffect <skill id>,<level>,<x>,<y> /// npcskilleffect "<skill name>",<level>,<x>,<y> -BUILDIN(npcskilleffect) -{ - struct block_list *bl= iMap->id2bl(st->oid); +BUILDIN(npcskilleffect) { + struct block_list *bl= map->id2bl(st->oid); uint16 skill_id=( script_isstring(st,2) ? skill->name2id(script_getstr(st,2)) : script_getnum(st,2) ); uint16 skill_lv=script_getnum(st,3); @@ -12225,9 +12130,8 @@ BUILDIN(npcskilleffect) /*========================================== * Special effects [Valaris] *------------------------------------------*/ -BUILDIN(specialeffect) -{ - struct block_list *bl=iMap->id2bl(st->oid); +BUILDIN(specialeffect) { + struct block_list *bl=map->id2bl(st->oid); int type = script_getnum(st,2); enum send_target target = script_hasdata(st,3) ? (send_target)script_getnum(st,3) : AREA; @@ -12254,14 +12158,13 @@ BUILDIN(specialeffect) return true; } -BUILDIN(specialeffect2) -{ +BUILDIN(specialeffect2) { TBL_PC *sd=script_rid2sd(st); int type = script_getnum(st,2); enum send_target target = script_hasdata(st,3) ? (send_target)script_getnum(st,3) : AREA; if( script_hasdata(st,4) ) - sd = iMap->nick2sd(script_getstr(st,4)); + sd = map->nick2sd(script_getstr(st,4)); if (sd) clif->specialeffect(&sd->bl, type, target); @@ -12297,8 +12200,7 @@ BUILDIN(nude) /*========================================== * gmcommand [MouseJstr] *------------------------------------------*/ -BUILDIN(atcommand) -{ +BUILDIN(atcommand) { TBL_PC *sd, *dummy_sd = NULL; int fd; const char* cmd; @@ -12313,9 +12215,8 @@ BUILDIN(atcommand) sd = dummy_sd = pc->get_dummy_sd(); fd = 0; - if (st->oid) - { - struct block_list* bl = iMap->id2bl(st->oid); + if (st->oid) { + struct block_list* bl = map->id2bl(st->oid); memcpy(&sd->bl, bl, sizeof(struct block_list)); if (bl->type == BL_NPC) safestrncpy(sd->status.name, ((TBL_NPC*)bl)->name, NAME_LENGTH); @@ -12357,7 +12258,7 @@ BUILDIN(recovery) for( sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); sd = (TBL_PC*)mapit->next(iter) ) { if(pc_isdead(sd)) - iStatus->revive(&sd->bl, 100, 100); + status->revive(&sd->bl, 100, 100); else status_percent_heal(&sd->bl, 100, 100); clif->message(sd->fd,msg_txt(680)); @@ -12437,29 +12338,23 @@ BUILDIN(gethominfo) /// Retrieves information about character's mercenary /// getmercinfo <type>[,<char id>]; -BUILDIN(getmercinfo) -{ +BUILDIN(getmercinfo) { int type, char_id; struct map_session_data* sd; struct mercenary_data* md; type = script_getnum(st,2); - if( script_hasdata(st,3) ) - { + if( script_hasdata(st,3) ) { char_id = script_getnum(st,3); - if( ( sd = iMap->charid2sd(char_id) ) == NULL ) - { + if( ( sd = map->charid2sd(char_id) ) == NULL ) { ShowError("buildin_getmercinfo: No such character (char_id=%d).\n", char_id); script_pushnil(st); return false; } - } - else - { - if( ( sd = script_rid2sd(st) ) == NULL ) - { + } else { + if( ( sd = script_rid2sd(st) ) == NULL ) { script_pushnil(st); return true; } @@ -12564,15 +12459,14 @@ BUILDIN(movenpc) { /*========================================== * message [MouseJstr] *------------------------------------------*/ -BUILDIN(message) -{ +BUILDIN(message) { const char *msg,*player; TBL_PC *pl_sd = NULL; player = script_getstr(st,2); msg = script_getstr(st,3); - if((pl_sd=iMap->nick2sd((char *) player)) == NULL) + if((pl_sd=map->nick2sd((char *) player)) == NULL) return true; clif->message(pl_sd->fd, msg); @@ -12582,12 +12476,11 @@ BUILDIN(message) /*========================================== * npctalk (sends message to surrounding area) *------------------------------------------*/ -BUILDIN(npctalk) -{ +BUILDIN(npctalk) { const char* str; char name[NAME_LENGTH], message[256]; - struct npc_data* nd = (struct npc_data *)iMap->id2bl(st->oid); + struct npc_data* nd = (struct npc_data *)map->id2bl(st->oid); str = script_getstr(st,2); if(nd) @@ -12607,7 +12500,7 @@ BUILDIN(npcspeed) { int speed; speed = script_getnum(st,2); - nd = (struct npc_data *)iMap->id2bl(st->oid); + nd = (struct npc_data *)map->id2bl(st->oid); if( nd ) { unit->bl2ud2(&nd->bl); // ensure nd->ud is safe to edit @@ -12619,7 +12512,7 @@ BUILDIN(npcspeed) { } // make an npc walk to a position [Valaris] BUILDIN(npcwalkto) { - struct npc_data *nd=(struct npc_data *)iMap->id2bl(st->oid); + struct npc_data *nd=(struct npc_data *)map->id2bl(st->oid); int x=0,y=0; x=script_getnum(st,2); @@ -12639,7 +12532,7 @@ BUILDIN(npcwalkto) { } // stop an npc's movement [Valaris] BUILDIN(npcstop) { - struct npc_data *nd = (struct npc_data *)iMap->id2bl(st->oid); + struct npc_data *nd = (struct npc_data *)map->id2bl(st->oid); if( nd ) { unit->bl2ud2(&nd->bl); // ensure nd->ud is safe to edit @@ -12761,7 +12654,7 @@ BUILDIN(getmapxy) switch (type){ case 0: //Get Character Position if( script_hasdata(st,6) ) - sd=iMap->nick2sd(script_getstr(st,6)); + sd=map->nick2sd(script_getstr(st,6)); else sd=script_rid2sd(st); @@ -12776,11 +12669,11 @@ BUILDIN(getmapxy) if (nd) bl = &nd->bl; } else //In case the origin is not an npc? - bl=iMap->id2bl(st->oid); + bl=map->id2bl(st->oid); break; case 2: //Get Pet Position if(script_hasdata(st,6)) - sd=iMap->nick2sd(script_getstr(st,6)); + sd=map->nick2sd(script_getstr(st,6)); else sd=script_rid2sd(st); @@ -12791,7 +12684,7 @@ BUILDIN(getmapxy) break; //Not supported? case 4: //Get Homun Position if(script_hasdata(st,6)) - sd=iMap->nick2sd(script_getstr(st,6)); + sd=map->nick2sd(script_getstr(st,6)); else sd=script_rid2sd(st); @@ -12800,7 +12693,7 @@ BUILDIN(getmapxy) break; case 5: //Get Mercenary Position if(script_hasdata(st,6)) - sd=iMap->nick2sd(script_getstr(st,6)); + sd=map->nick2sd(script_getstr(st,6)); else sd=script_rid2sd(st); @@ -12809,7 +12702,7 @@ BUILDIN(getmapxy) break; case 6: //Get Elemental Position if(script_hasdata(st,6)) - sd=iMap->nick2sd(script_getstr(st,6)); + sd=map->nick2sd(script_getstr(st,6)); else sd=script_rid2sd(st); @@ -12924,15 +12817,13 @@ BUILDIN(summon) /*========================================== * Checks whether it is daytime/nighttime *------------------------------------------*/ -BUILDIN(isnight) -{ - script_pushint(st,(iMap->night_flag == 1)); +BUILDIN(isnight) { + script_pushint(st,(map->night_flag == 1)); return true; } -BUILDIN(isday) -{ - script_pushint(st,(iMap->night_flag == 0)); +BUILDIN(isday) { + script_pushint(st,(map->night_flag == 0)); return true; } @@ -13076,8 +12967,7 @@ BUILDIN(isequipped) * Check how many given inserted cards in the CURRENT * weapon - used for 2/15's cards patch [Lupus] *------------------------------------------------*/ -BUILDIN(cardscnt) -{ +BUILDIN(cardscnt) { TBL_PC *sd; int i, k, id = 1; int ret = 0; @@ -13090,7 +12980,7 @@ BUILDIN(cardscnt) if (id <= 0) continue; - index = iStatus->current_equip_item_index; //we get CURRENT WEAPON inventory index from status.c [Lupus] + index = status->current_equip_item_index; //we get CURRENT WEAPON inventory index from status.c [Lupus] if(index < 0) continue; if(!sd->inventory_data[index]) @@ -13109,7 +12999,7 @@ BUILDIN(cardscnt) } } script_pushint(st,ret); - // script_pushint(st,iStatus->current_equip_item_index); + // script_pushint(st,status->current_equip_item_index); return true; } @@ -13117,11 +13007,10 @@ BUILDIN(cardscnt) * Returns the refined number of the current item, or an * item with inventory index specified *-------------------------------------------------------*/ -BUILDIN(getrefine) -{ +BUILDIN(getrefine) { TBL_PC *sd; if ((sd = script_rid2sd(st))!= NULL) - script_pushint(st,sd->status.inventory[iStatus->current_equip_item_index].refine); + script_pushint(st,sd->status.inventory[status->current_equip_item_index].refine); else script_pushint(st,0); return true; @@ -13130,14 +13019,12 @@ BUILDIN(getrefine) /*======================================================= * Day/Night controls *-------------------------------------------------------*/ -BUILDIN(night) -{ - if (iMap->night_flag != 1) pc->map_night_timer(pc->night_timer_tid, 0, 0, 1); +BUILDIN(night) { + if (map->night_flag != 1) pc->map_night_timer(pc->night_timer_tid, 0, 0, 1); return true; } -BUILDIN(day) -{ - if (iMap->night_flag != 0) pc->map_day_timer(pc->day_timer_tid, 0, 0, 1); +BUILDIN(day) { + if (map->night_flag != 0) pc->map_day_timer(pc->day_timer_tid, 0, 0, 1); return true; } @@ -14484,8 +14371,7 @@ BUILDIN(npcshopdelitem) } //Sets a script to attach to a shop npc. -BUILDIN(npcshopattach) -{ +BUILDIN(npcshopattach) { const char* npcname = script_getstr(st,2); struct npc_data* nd = npc->name2id(npcname); int flag = 1; @@ -14500,7 +14386,7 @@ BUILDIN(npcshopattach) } if (flag) - nd->master_nd = ((struct npc_data *)iMap->id2bl(st->oid)); + nd->master_nd = ((struct npc_data *)map->id2bl(st->oid)); else nd->master_nd = NULL; @@ -14634,7 +14520,7 @@ BUILDIN(checkvending) // check vending [Nab4] TBL_PC *sd = NULL; if(script_hasdata(st,2)) - sd = iMap->nick2sd(script_getstr(st,2)); + sd = map->nick2sd(script_getstr(st,2)); else sd = script_rid2sd(st); @@ -14647,12 +14533,12 @@ BUILDIN(checkvending) // check vending [Nab4] } -BUILDIN(checkchatting) // check chatting [Marka] -{ +// check chatting [Marka] +BUILDIN(checkchatting) { TBL_PC *sd = NULL; if(script_hasdata(st,2)) - sd = iMap->nick2sd(script_getstr(st,2)); + sd = map->nick2sd(script_getstr(st,2)); else sd = script_rid2sd(st); @@ -14664,12 +14550,11 @@ BUILDIN(checkchatting) // check chatting [Marka] return true; } -BUILDIN(checkidle) -{ +BUILDIN(checkidle) { TBL_PC *sd = NULL; if (script_hasdata(st, 2)) - sd = iMap->nick2sd(script_getstr(st, 2)); + sd = map->nick2sd(script_getstr(st, 2)); else sd = script_rid2sd(st); @@ -14792,12 +14677,10 @@ BUILDIN(axtoi) } // [zBuffer] List of player cont commands ---> -BUILDIN(rid2name) -{ +BUILDIN(rid2name) { struct block_list *bl = NULL; int rid = script_getnum(st,2); - if((bl = iMap->id2bl(rid))) - { + if((bl = map->id2bl(rid))) { switch(bl->type) { case BL_MOB: script_pushstrcopy(st,((TBL_MOB*)bl)->name); break; case BL_PC: script_pushstrcopy(st,((TBL_PC*)bl)->status.name); break; @@ -14817,8 +14700,7 @@ BUILDIN(rid2name) return true; } -BUILDIN(pcblockmove) -{ +BUILDIN(pcblockmove) { int id, flag; TBL_PC *sd = NULL; @@ -14826,7 +14708,7 @@ BUILDIN(pcblockmove) flag = script_getnum(st,3); if(id) - sd = iMap->id2sd(id); + sd = map->id2sd(id); else sd = script_rid2sd(st); @@ -14836,8 +14718,7 @@ BUILDIN(pcblockmove) return true; } -BUILDIN(pcfollow) -{ +BUILDIN(pcfollow) { int id, targetid; TBL_PC *sd = NULL; @@ -14846,7 +14727,7 @@ BUILDIN(pcfollow) targetid = script_getnum(st,3); if(id) - sd = iMap->id2sd(id); + sd = map->id2sd(id); else sd = script_rid2sd(st); @@ -14865,7 +14746,7 @@ BUILDIN(pcstopfollow) id = script_getnum(st,2); if(id) - sd = iMap->id2sd(id); + sd = map->id2sd(id); else sd = script_rid2sd(st); @@ -14886,7 +14767,7 @@ BUILDIN(pcstopfollow) BUILDIN(unitwalk) { struct block_list* bl; - bl = iMap->id2bl(script_getnum(st,2)); + bl = map->id2bl(script_getnum(st,2)); if( bl == NULL ) { script_pushint(st, 0); return true; @@ -14901,7 +14782,7 @@ BUILDIN(unitwalk) { script_pushint(st, unit->walktoxy(bl,x,y,0));// We'll use harder calculations. } else { int map_id = script_getnum(st,3); - script_pushint(st, unit->walktobl(bl,iMap->id2bl(map_id),65025,1)); + script_pushint(st, unit->walktobl(bl,map->id2bl(map_id),65025,1)); } return true; @@ -14912,7 +14793,7 @@ BUILDIN(unitwalk) { /// unitkill <unit_id>; BUILDIN(unitkill) { - struct block_list* bl = iMap->id2bl(script_getnum(st,2)); + struct block_list* bl = map->id2bl(script_getnum(st,2)); if( bl != NULL ) status_kill(bl); @@ -14937,14 +14818,14 @@ BUILDIN(unitwarp) { y = (short)script_getnum(st,5); if (!unit_id) //Warp the script's runner - bl = iMap->id2bl(st->rid); + bl = map->id2bl(st->rid); else - bl = iMap->id2bl(unit_id); + bl = map->id2bl(unit_id); if( strcmp(mapname,"this") == 0 ) mapid = bl?bl->m:-1; else - mapid = iMap->mapname2mapid(mapname); + mapid = map->mapname2mapid(mapname); if( mapid >= 0 && bl != NULL ) { unit->bl2ud2(bl); // ensure ((TBL_NPC*)bl)->ud is safe to edit @@ -14963,15 +14844,14 @@ BUILDIN(unitwarp) { /// /// unitattack(<unit_id>,"<target name>"{,<action type>}) -> <bool> /// unitattack(<unit_id>,<target_id>{,<action type>}) -> <bool> -BUILDIN(unitattack) -{ +BUILDIN(unitattack) { struct block_list* unit_bl; struct block_list* target_bl = NULL; struct script_data* data; int actiontype = 0; // get unit - unit_bl = iMap->id2bl(script_getnum(st,2)); + unit_bl = map->id2bl(script_getnum(st,2)); if( unit_bl == NULL ) { script_pushint(st, 0); return true; @@ -14979,13 +14859,12 @@ BUILDIN(unitattack) data = script_getdata(st, 3); script->get_val(st, data); - if( data_isstring(data) ) - { - TBL_PC* sd = iMap->nick2sd(script->conv_str(st, data)); + if( data_isstring(data) ) { + TBL_PC* sd = map->nick2sd(script->conv_str(st, data)); if( sd != NULL ) target_bl = &sd->bl; } else - target_bl = iMap->id2bl(script->conv_num(st, data)); + target_bl = map->id2bl(script->conv_num(st, data)); // request the attack if( target_bl == NULL ) { @@ -15027,9 +14906,8 @@ BUILDIN(unitstop) { unit_id = script_getnum(st,2); - bl = iMap->id2bl(unit_id); - if( bl != NULL ) - { + bl = map->id2bl(unit_id); + if( bl != NULL ) { unit->bl2ud2(bl); // ensure ((TBL_NPC*)bl)->ud is safe to edit unit->stop_attack(bl); unit->stop_walking(bl,4); @@ -15043,8 +14921,7 @@ BUILDIN(unitstop) { /// Makes the unit say the message /// /// unittalk <unit_id>,"<message>"; -BUILDIN(unittalk) -{ +BUILDIN(unittalk) { int unit_id; const char* message; struct block_list* bl; @@ -15052,12 +14929,11 @@ BUILDIN(unittalk) unit_id = script_getnum(st,2); message = script_getstr(st, 3); - bl = iMap->id2bl(unit_id); - if( bl != NULL ) - { + bl = map->id2bl(unit_id); + if( bl != NULL ) { struct StringBuf sbuf; StrBuf->Init(&sbuf); - StrBuf->Printf(&sbuf, "%s : %s", iStatus->get_name(bl), message); + StrBuf->Printf(&sbuf, "%s : %s", status->get_name(bl), message); clif->disp_overhead(bl, StrBuf->Value(&sbuf)); if( bl->type == BL_PC ) clif->message(((TBL_PC*)bl)->fd, StrBuf->Value(&sbuf)); @@ -15072,15 +14948,14 @@ BUILDIN(unittalk) /// unitemote <unit_id>,<emotion>; /// /// @see e_* in const.txt -BUILDIN(unitemote) -{ +BUILDIN(unitemote) { int unit_id; int emotion; struct block_list* bl; unit_id = script_getnum(st,2); emotion = script_getnum(st,3); - bl = iMap->id2bl(unit_id); + bl = map->id2bl(unit_id); if( bl != NULL ) clif->emotion(bl, emotion); @@ -15091,8 +14966,7 @@ BUILDIN(unitemote) /// /// unitskilluseid <unit_id>,<skill_id>,<skill_lv>{,<target_id>}; /// unitskilluseid <unit_id>,"<skill name>",<skill_lv>{,<target_id>}; -BUILDIN(unitskilluseid) -{ +BUILDIN(unitskilluseid) { int unit_id; uint16 skill_id; uint16 skill_lv; @@ -15104,7 +14978,7 @@ BUILDIN(unitskilluseid) skill_lv = script_getnum(st,4); target_id = ( script_hasdata(st,5) ? script_getnum(st,5) : unit_id ); - bl = iMap->id2bl(unit_id); + bl = map->id2bl(unit_id); if( bl != NULL ) { if( bl->type == BL_NPC ) { @@ -15124,8 +14998,7 @@ BUILDIN(unitskilluseid) /// /// unitskillusepos <unit_id>,<skill_id>,<skill_lv>,<target_x>,<target_y>; /// unitskillusepos <unit_id>,"<skill name>",<skill_lv>,<target_x>,<target_y>; -BUILDIN(unitskillusepos) -{ +BUILDIN(unitskillusepos) { int unit_id; uint16 skill_id; uint16 skill_lv; @@ -15139,7 +15012,7 @@ BUILDIN(unitskillusepos) skill_x = script_getnum(st,5); skill_y = script_getnum(st,6); - bl = iMap->id2bl(unit_id); + bl = map->id2bl(unit_id); if( bl != NULL ) { if( bl->type == BL_NPC ) { @@ -15189,26 +15062,23 @@ BUILDIN(sleep) /// Returns if a player is still attached /// /// sleep2(<mili secconds>) -> <bool> -BUILDIN(sleep2) -{ +BUILDIN(sleep2) { int ticks; ticks = script_getnum(st,2); - if( ticks <= 0 ) - {// do nothing - script_pushint(st, (iMap->id2sd(st->rid)!=NULL)); - } - else if( !st->sleep.tick ) - {// sleep for the target amount of time + if( ticks <= 0 ) { + // do nothing + script_pushint(st, (map->id2sd(st->rid)!=NULL)); + } else if( !st->sleep.tick ) { + // sleep for the target amount of time st->state = RERUNLINE; st->sleep.tick = ticks; - } - else - {// sleep time is over + } else { + // sleep time is over st->state = RUN; st->sleep.tick = 0; - script_pushint(st, (iMap->id2sd(st->rid)!=NULL)); + script_pushint(st, (map->id2sd(st->rid)!=NULL)); } return true; } @@ -15230,7 +15100,7 @@ BUILDIN(awake) { for( tst = dbi_first(iter); dbi_exists(iter); tst = dbi_next(iter) ) { if( tst->oid == nd->bl.id ) { - TBL_PC* sd = iMap->id2sd(tst->rid); + TBL_PC* sd = map->id2sd(tst->rid); if( tst->sleep.timer == INVALID_TIMER ) {// already awake ??? continue; @@ -15303,8 +15173,7 @@ BUILDIN(getvariableofnpc) /// warpportal <source x>,<source y>,"<target map>",<target x>,<target y>; /// /// @author blackhole89 -BUILDIN(warpportal) -{ +BUILDIN(warpportal) { int spx; int spy; unsigned short mapindex; @@ -15313,7 +15182,7 @@ BUILDIN(warpportal) struct skill_unit_group* group; struct block_list* bl; - bl = iMap->id2bl(st->oid); + bl = map->id2bl(st->oid); if( bl == NULL ) { ShowError("script:warpportal: npc is needed\n"); @@ -15370,9 +15239,8 @@ BUILDIN(openauction) /// checkcell("<map name>",<x>,<y>,<type>) -> <bool> /// /// @see cell_chk* constants in const.txt for the types -BUILDIN(checkcell) -{ - int16 m = iMap->mapname2mapid(script_getstr(st,2)); +BUILDIN(checkcell) { + int16 m = map->mapname2mapid(script_getstr(st,2)); int16 x = script_getnum(st,3); int16 y = script_getnum(st,4); cell_chk type = (cell_chk)script_getnum(st,5); @@ -15382,7 +15250,7 @@ BUILDIN(checkcell) return true; } - script_pushint(st, iMap->getcell(m, x, y, type)); + script_pushint(st, map->getcell(m, x, y, type)); return true; } @@ -15392,9 +15260,8 @@ BUILDIN(checkcell) /// setcell "<map name>",<x1>,<y1>,<x2>,<y2>,<type>,<flag>; /// /// @see cell_* constants in const.txt for the types -BUILDIN(setcell) -{ - int16 m = iMap->mapname2mapid(script_getstr(st,2)); +BUILDIN(setcell) { + int16 m = map->mapname2mapid(script_getstr(st,2)); int16 x1 = script_getnum(st,3); int16 y1 = script_getnum(st,4); int16 x2 = script_getnum(st,5); @@ -15440,8 +15307,7 @@ BUILDIN(mercenary_create) return true; } -BUILDIN(mercenary_heal) -{ +BUILDIN(mercenary_heal) { struct map_session_data *sd = script_rid2sd(st); int hp, sp; @@ -15450,12 +15316,11 @@ BUILDIN(mercenary_heal) hp = script_getnum(st,2); sp = script_getnum(st,3); - iStatus->heal(&sd->md->bl, hp, sp, 0); + status->heal(&sd->md->bl, hp, sp, 0); return true; } -BUILDIN(mercenary_sc_start) -{ +BUILDIN(mercenary_sc_start) { struct map_session_data *sd = script_rid2sd(st); enum sc_type type; int tick, val1; @@ -15467,7 +15332,7 @@ BUILDIN(mercenary_sc_start) tick = script_getnum(st,3); val1 = script_getnum(st,4); - iStatus->change_start(&sd->md->bl, type, 10000, val1, 0, 0, 0, tick, 2); + status->change_start(&sd->md->bl, type, 10000, val1, 0, 0, 0, tick, 2); return true; } @@ -15658,10 +15523,9 @@ BUILDIN(checkquest) return true; } -BUILDIN(showevent) -{ +BUILDIN(showevent) { TBL_PC *sd = script_rid2sd(st); - struct npc_data *nd = iMap->id2nd(st->oid); + struct npc_data *nd = map->id2nd(st->oid); int state, color; if( sd == NULL || nd == NULL ) @@ -15679,8 +15543,7 @@ BUILDIN(showevent) /*========================================== * BattleGround System *------------------------------------------*/ -BUILDIN(waitingroom2bg) -{ +BUILDIN(waitingroom2bg) { struct npc_data *nd; struct chat_data *cd; const char *map_name, *ev = "", *dev = ""; @@ -15690,10 +15553,9 @@ BUILDIN(waitingroom2bg) if( script_hasdata(st,7) ) nd = npc->name2id(script_getstr(st,7)); else - nd = (struct npc_data *)iMap->id2bl(st->oid); + nd = (struct npc_data *)map->id2bl(st->oid); - if( nd == NULL || (cd = (struct chat_data *)iMap->id2bl(nd->chat_id)) == NULL ) - { + if( nd == NULL || (cd = (struct chat_data *)map->id2bl(nd->chat_id)) == NULL ) { script_pushint(st,0); return true; } @@ -15734,8 +15596,7 @@ BUILDIN(waitingroom2bg) return true; } -BUILDIN(waitingroom2bg_single) -{ +BUILDIN(waitingroom2bg_single) { const char* map_name; struct npc_data *nd; struct chat_data *cd; @@ -15751,7 +15612,7 @@ BUILDIN(waitingroom2bg_single) y = script_getnum(st,5); nd = npc->name2id(script_getstr(st,6)); - if( nd == NULL || (cd = (struct chat_data *)iMap->id2bl(nd->chat_id)) == NULL || cd->users <= 0 ) + if( nd == NULL || (cd = (struct chat_data *)map->id2bl(nd->chat_id)) == NULL || cd->users <= 0 ) return true; if( (sd = cd->usersd[0]) == NULL ) @@ -15814,14 +15675,13 @@ BUILDIN(bg_monster) return true; } -BUILDIN(bg_monster_set_team) -{ +BUILDIN(bg_monster_set_team) { struct mob_data *md; struct block_list *mbl; int id = script_getnum(st,2), bg_id = script_getnum(st,3); - if( (mbl = iMap->id2bl(id)) == NULL || mbl->type != BL_MOB ) + if( (mbl = map->id2bl(id)) == NULL || mbl->type != BL_MOB ) return true; md = (TBL_MOB *)mbl; md->bg_id = bg_id; @@ -15851,8 +15711,7 @@ BUILDIN(bg_destroy) return true; } -BUILDIN(bg_getareausers) -{ +BUILDIN(bg_getareausers) { const char *str; int16 m, x0, y0, x1, y1; int bg_id; @@ -15863,8 +15722,7 @@ BUILDIN(bg_getareausers) bg_id = script_getnum(st,2); str = script_getstr(st,3); - if( (bgd = bg->team_search(bg_id)) == NULL || (m = iMap->mapname2mapid(str)) < 0 ) - { + if( (bgd = bg->team_search(bg_id)) == NULL || (m = map->mapname2mapid(str)) < 0 ) { script_pushint(st,0); return true; } @@ -15892,7 +15750,7 @@ BUILDIN(bg_updatescore) { int16 m; str = script_getstr(st,2); - if( (m = iMap->mapname2mapid(str)) < 0 ) + if( (m = map->mapname2mapid(str)) < 0 ) return true; maplist[m].bgscore_lion = script_getnum(st,3); @@ -16019,7 +15877,7 @@ BUILDIN(instance_detachmap) { instance_id = st->instance_id; else return true; - if( (m = iMap->mapname2mapid(str)) < 0 || (m = instance->map2imap(m,instance_id)) < 0 ) { + if( (m = map->mapname2mapid(str)) < 0 || (m = instance->map2imap(m,instance_id)) < 0 ) { ShowError("buildin_instance_detachmap: Trying to detach invalid map %s\n", str); return true; } @@ -16104,8 +15962,8 @@ BUILDIN(instance_announce) { return true; for( i = 0; i < instances[instance_id].num_map; i++ ) - iMap->foreachinmap(buildin_announce_sub, instances[instance_id].map[i], BL_PC, - mes, strlen(mes)+1, flag&BC_COLOR_MASK, fontColor, fontType, fontSize, fontAlign, fontY); + map->foreachinmap(buildin_announce_sub, instances[instance_id].map[i], BL_PC, + mes, strlen(mes)+1, flag&BC_COLOR_MASK, fontColor, fontType, fontSize, fontAlign, fontY); return true; } @@ -16142,7 +16000,7 @@ BUILDIN(has_instance) { str = script_getstr(st, 2); - if( (m = iMap->mapname2mapid(str)) < 0 ) { + if( (m = map->mapname2mapid(str)) < 0 ) { script_pushconststr(st, ""); return true; } @@ -16225,12 +16083,12 @@ BUILDIN(instance_warpall) { else return true; - if( (m = iMap->mapname2mapid(mapn)) < 0 || (maplist[m].flag.src4instance && (m = instance->mapid2imapid(m, instance_id)) < 0) ) + if( (m = map->mapname2mapid(mapn)) < 0 || (maplist[m].flag.src4instance && (m = instance->mapid2imapid(m, instance_id)) < 0) ) return true; mapindex = map_id2index(m); - iMap->foreachininstance(buildin_instance_warpall_sub, instance_id, BL_PC,mapindex,x,y); + map->foreachininstance(buildin_instance_warpall_sub, instance_id, BL_PC,mapindex,x,y); return true; } @@ -16273,7 +16131,7 @@ BUILDIN(instance_check_party) { for( i = 0; i < MAX_PARTY; i++ ) if( (pl_sd = p->data[i].sd) ) - if(iMap->id2bl(pl_sd->bl.id)){ + if(map->id2bl(pl_sd->bl.id)){ if(pl_sd->status.base_level < min){ script_pushint(st, 0); return true; @@ -16329,9 +16187,9 @@ static int buildin_mobuseskill_sub(struct block_list *bl,va_list ap) // 0:self, 1:target, 2:master, default:random switch( target ) { - case 0: tbl = iMap->id2bl(md->bl.id); break; - case 1: tbl = iMap->id2bl(md->target_id); break; - case 2: tbl = iMap->id2bl(md->master_id); break; + case 0: tbl = map->id2bl(md->bl.id); break; + case 1: tbl = map->id2bl(md->target_id); break; + case 2: tbl = map->id2bl(md->master_id); break; default:tbl = battle->get_enemy(&md->bl, DEFAULT_ENEMY_TYPE(md),skill->get_range2(&md->bl, skill_id, skill_lv)); break; } @@ -16353,13 +16211,12 @@ static int buildin_mobuseskill_sub(struct block_list *bl,va_list ap) /*========================================== * areamobuseskill "Map Name",<x>,<y>,<range>,<Mob ID>,"Skill Name"/<Skill ID>,<Skill Lv>,<Cast Time>,<Cancelable>,<Emotion>,<Target Type>; *------------------------------------------*/ -BUILDIN(areamobuseskill) -{ +BUILDIN(areamobuseskill) { struct block_list center; int16 m; int range,mobid,skill_id,skill_lv,casttime,emotion,target,cancel; - if( (m = iMap->mapname2mapid(script_getstr(st,2))) < 0 ) { + if( (m = map->mapname2mapid(script_getstr(st,2))) < 0 ) { ShowError("areamobuseskill: invalid map name.\n"); return true; } @@ -16379,7 +16236,7 @@ BUILDIN(areamobuseskill) emotion = script_getnum(st,11); target = script_getnum(st,12); - iMap->foreachinrange(buildin_mobuseskill_sub, ¢er, range, BL_MOB, mobid, skill_id, skill_lv, casttime, cancel, emotion, target); + map->foreachinrange(buildin_mobuseskill_sub, ¢er, range, BL_MOB, mobid, skill_id, skill_lv, casttime, cancel, emotion, target); return true; } @@ -16642,20 +16499,17 @@ BUILDIN(getargcount) { /** * getcharip(<account ID>/<character ID>/<character name>) **/ -BUILDIN(getcharip) -{ +BUILDIN(getcharip) { struct map_session_data* sd = NULL; /* check if a character name is specified */ - if( script_hasdata(st, 2) ) - { + if( script_hasdata(st, 2) ) { if (script_isstring(st, 2)) - sd = iMap->nick2sd(script_getstr(st, 2)); - else if (script_isint(st, 2) || script_getnum(st, 2)) - { + sd = map->nick2sd(script_getstr(st, 2)); + else if (script_isint(st, 2) || script_getnum(st, 2)) { int id; id = script_getnum(st, 2); - sd = (iMap->id2sd(id) ? iMap->id2sd(id) : iMap->charid2sd(id)); + sd = (map->id2sd(id) ? map->id2sd(id) : map->charid2sd(id)); } } else @@ -16724,12 +16578,11 @@ BUILDIN(freeloop) { return true; } -BUILDIN(sit) -{ +BUILDIN(sit) { struct map_session_data *sd = NULL; if (script_hasdata(st, 2)) - sd = iMap->nick2sd(script_getstr(st, 2)); + sd = map->nick2sd(script_getstr(st, 2)); if (sd == NULL) sd = script_rid2sd(st); @@ -16743,12 +16596,11 @@ BUILDIN(sit) return true; } -BUILDIN(stand) -{ +BUILDIN(stand) { struct map_session_data *sd = NULL; if (script_hasdata(st, 2)) - sd = iMap->nick2sd(script_getstr(st, 2)); + sd = map->nick2sd(script_getstr(st, 2)); if (sd == NULL) sd = script_rid2sd(st); @@ -16762,12 +16614,11 @@ BUILDIN(stand) return true; } -BUILDIN(issit) -{ +BUILDIN(issit) { struct map_session_data *sd = NULL; if (script_hasdata(st, 2)) - sd = iMap->nick2sd(script_getstr(st, 2)); + sd = map->nick2sd(script_getstr(st, 2)); if (sd == NULL) sd = script_rid2sd(st); @@ -16874,27 +16725,23 @@ BUILDIN(unbindatcmd) { return true; } -BUILDIN(useatcmd) -{ +BUILDIN(useatcmd) { TBL_PC *sd, *dummy_sd = NULL; int fd; const char* cmd; cmd = script_getstr(st,2); - if( st->rid ) - { + if( st->rid ) { sd = script_rid2sd(st); fd = sd->fd; - } - else - { // Use a dummy character. + } else { + // Use a dummy character. sd = dummy_sd = pc->get_dummy_sd(); fd = 0; - if( st->oid ) - { - struct block_list* bl = iMap->id2bl(st->oid); + if( st->oid ) { + struct block_list* bl = map->id2bl(st->oid); memcpy(&sd->bl, bl, sizeof(struct block_list)); if( bl->type == BL_NPC ) safestrncpy(sd->status.name, ((TBL_NPC*)bl)->name, NAME_LENGTH); @@ -17016,7 +16863,7 @@ BUILDIN(getrandgroupitem) { if ((flag = pc->additem(sd, &it, get_count, LOG_TYPE_SCRIPT))) { clif->additem(sd, 0, 0, flag); if( pc->candrop(sd,&it) ) - iMap->addflooritem(&it,get_count,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); + map->addflooritem(&it,get_count,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); } } } @@ -17029,33 +16876,32 @@ BUILDIN(getrandgroupitem) { /* cleanmap <map_name>; * cleanarea <map_name>, <x0>, <y0>, <x1>, <y1>; */ -static int atcommand_cleanfloor_sub(struct block_list *bl, va_list ap) -{ +static int atcommand_cleanfloor_sub(struct block_list *bl, va_list ap) { nullpo_ret(bl); - iMap->clearflooritem(bl); + map->clearflooritem(bl); return 0; } BUILDIN(cleanmap) { - const char *mapname; - int16 m = -1; - int16 x0 = 0, y0 = 0, x1 = 0, y1 = 0; + const char *mapname; + int16 m = -1; + int16 x0 = 0, y0 = 0, x1 = 0, y1 = 0; - mapname = script_getstr(st, 2); - m = iMap->mapname2mapid(mapname); - if ( m == -1 ) - return false; + mapname = script_getstr(st, 2); + m = map->mapname2mapid(mapname); + if ( m == -1 ) + return false; if ((script_lastdata(st) - 2) < 4) { - iMap->foreachinmap(atcommand_cleanfloor_sub, m, BL_ITEM); + map->foreachinmap(atcommand_cleanfloor_sub, m, BL_ITEM); } else { x0 = script_getnum(st, 3); y0 = script_getnum(st, 4); x1 = script_getnum(st, 5); y1 = script_getnum(st, 6); if (x0 > 0 && y0 > 0 && x1 > 0 && y1 > 0) { - iMap->foreachinarea(atcommand_cleanfloor_sub, m, x0, y0, x1, y1, BL_ITEM); + map->foreachinarea(atcommand_cleanfloor_sub, m, x0, y0, x1, y1, BL_ITEM); } else { ShowError("cleanarea: invalid coordinate defined!\n"); return false; @@ -17067,8 +16913,7 @@ BUILDIN(cleanmap) { /* Cast a skill on the attached player. * npcskill <skill id>, <skill lvl>, <stat point>, <NPC level>; * npcskill "<skill name>", <skill lvl>, <stat point>, <NPC level>; */ -BUILDIN(npcskill) -{ +BUILDIN(npcskill) { uint16 skill_id; unsigned short skill_level; unsigned int stat_point; @@ -17076,12 +16921,12 @@ BUILDIN(npcskill) struct npc_data *nd; struct map_session_data *sd; - skill_id = script_isstring(st, 2) ? skill->name2id(script_getstr(st, 2)) : script_getnum(st, 2); - skill_level = script_getnum(st, 3); - stat_point = script_getnum(st, 4); - npc_level = script_getnum(st, 5); - sd = script_rid2sd(st); - nd = (struct npc_data *)iMap->id2bl(sd->npc_id); + skill_id = script_isstring(st, 2) ? skill->name2id(script_getstr(st, 2)) : script_getnum(st, 2); + skill_level = script_getnum(st, 3); + stat_point = script_getnum(st, 4); + npc_level = script_getnum(st, 5); + sd = script_rid2sd(st); + nd = (struct npc_data *)map->id2bl(sd->npc_id); if (stat_point > battle_config.max_third_parameter) { ShowError("npcskill: stat point exceeded maximum of %d.\n",battle_config.max_third_parameter ); @@ -17188,7 +17033,7 @@ bool script_hqueue_add(int idx, int var) { script->hq[idx].item[i] = var; script->hq[idx].items++; - if( var >= START_ACCOUNT_NUM && (sd = iMap->id2sd(var)) ) { + if( var >= START_ACCOUNT_NUM && (sd = map->id2sd(var)) ) { for(i = 0; i < sd->queues_count; i++) { if( sd->queues[i] == -1 ) { break; @@ -17234,7 +17079,7 @@ bool script_hqueue_remove(int idx, int var) { script->hq[idx].item[i] = -1; script->hq[idx].items--; - if( var >= START_ACCOUNT_NUM && (sd = iMap->id2sd(var)) ) { + if( var >= START_ACCOUNT_NUM && (sd = map->id2sd(var)) ) { for(i = 0; i < sd->queues_count; i++) { if( sd->queues[i] == idx ) { break; @@ -17312,7 +17157,7 @@ bool script_hqueue_del(int idx) { int i; for(i = 0; i < script->hq[idx].size; i++) { - if( script->hq[idx].item[i] >= START_ACCOUNT_NUM && (sd = iMap->id2sd(script->hq[idx].item[i])) ) { + if( script->hq[idx].item[i] >= START_ACCOUNT_NUM && (sd = map->id2sd(script->hq[idx].item[i])) ) { int j; for(j = 0; j < sd->queues_count; j++) { if( sd->queues[j] == script->hq[idx].item[i] ) { @@ -17351,7 +17196,7 @@ void script_hqueue_clear(int idx) { for(i = 0; i < script->hq[idx].size; i++) { if( script->hq[idx].item[i] > 0 ) { - if( script->hq[idx].item[i] >= START_ACCOUNT_NUM && (sd = iMap->id2sd(script->hq[idx].item[i])) ) { + if( script->hq[idx].item[i] >= START_ACCOUNT_NUM && (sd = map->id2sd(script->hq[idx].item[i])) ) { for(j = 0; j < sd->queues_count; j++) { if( sd->queues[j] == idx ) { break; @@ -17526,7 +17371,7 @@ BUILDIN(bg_join_team) { int team_id = script_getnum(st, 2); if( script_hasdata(st, 3) ) - sd = iMap->id2sd(script_getnum(st, 3)); + sd = map->id2sd(script_getnum(st, 3)); else sd = script->rid2sd(st); diff --git a/src/map/searchstore.c b/src/map/searchstore.c index c7f4f9fed..6fd6f6aad 100644 --- a/src/map/searchstore.c +++ b/src/map/searchstore.c @@ -274,7 +274,7 @@ void searchstore_click(struct map_session_data* sd, int account_id, int store_id return; } - if( ( pl_sd = iMap->id2sd(account_id) ) == NULL ) {// no longer online + if( ( pl_sd = map->id2sd(account_id) ) == NULL ) {// no longer online clif->search_store_info_failed(sd, SSI_FAILED_SSILIST_CLICK_TO_OPEN_STORE); return; } diff --git a/src/map/skill.c b/src/map/skill.c index 32880e535..96c439741 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -59,50 +59,6 @@ #error GD_SKILLRANGEMAX is greater than 999 #endif -DBMap* skillunit_db = NULL; // int id -> struct skill_unit* - -/** - * Skill Unit Persistency during endack routes (mostly for songs see bugreport:4574) - **/ -DBMap* skillusave_db = NULL; // char_id -> struct skill_usave -struct skill_usave { - uint16 skill_id, skill_lv; -}; - -struct s_skill_db skill_db[MAX_SKILL_DB]; -struct s_skill_produce_db skill_produce_db[MAX_SKILL_PRODUCE_DB]; -struct s_skill_arrow_db skill_arrow_db[MAX_SKILL_ARROW_DB]; -struct s_skill_abra_db skill_abra_db[MAX_SKILL_ABRA_DB]; -struct s_skill_improvise_db { - uint16 skill_id; - short per;//1-10000 -}; -struct s_skill_improvise_db skill_improvise_db[MAX_SKILL_IMPROVISE_DB]; -bool skill_reproduce_db[MAX_SKILL_DB]; -struct s_skill_changematerial_db { - int itemid; - short rate; - int qty[5]; - short qty_rate[5]; -}; -struct s_skill_changematerial_db skill_changematerial_db[MAX_SKILL_PRODUCE_DB]; - -//Warlock -struct s_skill_spellbook_db { - int nameid; - uint16 skill_id; - int point; -}; - -struct s_skill_spellbook_db skill_spellbook_db[MAX_SKILL_SPELLBOOK_DB]; -//Guillotine Cross -struct s_skill_magicmushroom_db skill_magicmushroom_db[MAX_SKILL_MAGICMUSHROOM_DB]; - -struct s_skill_unit_layout skill_unit_layout[MAX_SKILL_UNIT_LAYOUT]; -int firewall_unit_pos; -int icewall_unit_pos; -int earthstrain_unit_pos; - struct skill_interface skill_s; //Since only mob-casted splash skills can hit ice-walls @@ -119,7 +75,7 @@ int skill_name2id(const char* name) { if( name == NULL ) return 0; - return strdb_iget(skilldb_name2id, name); + return strdb_iget(skill->name2id_db, name); } /// Maps skill ids to skill db offsets. @@ -163,11 +119,11 @@ int skill_get_index( uint16 skill_id ) { } const char* skill_get_name( uint16 skill_id ) { - return skill_db[skill->get_index(skill_id)].name; + return skill->db[skill->get_index(skill_id)].name; } const char* skill_get_desc( uint16 skill_id ) { - return skill_db[skill->get_index(skill_id)].desc; + return skill->db[skill->get_index(skill_id)].desc; } // out of bounds error checking [celest] @@ -180,57 +136,57 @@ void skill_chk(uint16* skill_id) { skill->chk(&id); \ if(!id) return 0; \ if( lv > MAX_SKILL_LEVEL && var > 1 ) { \ - int lv2 = lv; lv = skill_db[id].max; \ + int lv2 = lv; lv = skill->db[id].max; \ return (var) + ((lv2-lv)/2);\ } \ return var;\ } #define skill_glv(lv) min(lv,MAX_SKILL_LEVEL-1) // Skill DB -int skill_get_hit( uint16 skill_id ) { skill_get (skill_db[skill_id].hit, skill_id); } -int skill_get_inf( uint16 skill_id ) { skill_get (skill_db[skill_id].inf, skill_id); } -int skill_get_ele( uint16 skill_id , uint16 skill_lv ) { skill_get (skill_db[skill_id].element[skill_glv(skill_lv-1)], skill_id); } -int skill_get_nk( uint16 skill_id ) { skill_get (skill_db[skill_id].nk, skill_id); } -int skill_get_max( uint16 skill_id ) { skill_get (skill_db[skill_id].max, skill_id); } -int skill_get_range( uint16 skill_id , uint16 skill_lv ) { skill_get2 (skill_db[skill_id].range[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_splash( uint16 skill_id , uint16 skill_lv ) { skill_get2 ( (skill_db[skill_id].splash[skill_glv(skill_lv-1)]>=0?skill_db[skill_id].splash[skill_glv(skill_lv-1)]:AREA_SIZE), skill_id, skill_lv); } -int skill_get_hp( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill_db[skill_id].hp[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_sp( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill_db[skill_id].sp[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_hp_rate(uint16 skill_id, uint16 skill_lv ) { skill_get2 (skill_db[skill_id].hp_rate[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_sp_rate(uint16 skill_id, uint16 skill_lv ) { skill_get2 (skill_db[skill_id].sp_rate[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_state(uint16 skill_id) { skill_get (skill_db[skill_id].state, skill_id); } -int skill_get_spiritball(uint16 skill_id, uint16 skill_lv) { skill_get2 (skill_db[skill_id].spiritball[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_itemid(uint16 skill_id, int idx) { skill_get (skill_db[skill_id].itemid[idx], skill_id); } -int skill_get_itemqty(uint16 skill_id, int idx) { skill_get (skill_db[skill_id].amount[idx], skill_id); } -int skill_get_zeny( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill_db[skill_id].zeny[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_num( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill_db[skill_id].num[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_cast( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill_db[skill_id].cast[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_delay( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill_db[skill_id].delay[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_walkdelay( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill_db[skill_id].walkdelay[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_time( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill_db[skill_id].upkeep_time[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_time2( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill_db[skill_id].upkeep_time2[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_castdef( uint16 skill_id ) { skill_get (skill_db[skill_id].cast_def_rate, skill_id); } -int skill_get_weapontype( uint16 skill_id ) { skill_get (skill_db[skill_id].weapon, skill_id); } -int skill_get_ammotype( uint16 skill_id ) { skill_get (skill_db[skill_id].ammo, skill_id); } -int skill_get_ammo_qty( uint16 skill_id, uint16 skill_lv ) { skill_get2 (skill_db[skill_id].ammo_qty[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_inf2( uint16 skill_id ) { skill_get (skill_db[skill_id].inf2, skill_id); } -int skill_get_castcancel( uint16 skill_id ) { skill_get (skill_db[skill_id].castcancel, skill_id); } -int skill_get_maxcount( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill_db[skill_id].maxcount[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_blewcount( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill_db[skill_id].blewcount[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_mhp( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill_db[skill_id].mhp[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_castnodex( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill_db[skill_id].castnodex[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_delaynodex( uint16 skill_id ,uint16 skill_lv ){ skill_get2 (skill_db[skill_id].delaynodex[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_type( uint16 skill_id ) { skill_get (skill_db[skill_id].skill_type, skill_id); } -int skill_get_unit_id ( uint16 skill_id, int flag ){ skill_get (skill_db[skill_id].unit_id[flag], skill_id); } -int skill_get_unit_interval( uint16 skill_id ) { skill_get (skill_db[skill_id].unit_interval, skill_id); } -int skill_get_unit_range( uint16 skill_id, uint16 skill_lv ) { skill_get2 (skill_db[skill_id].unit_range[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_unit_target( uint16 skill_id ) { skill_get (skill_db[skill_id].unit_target&BCT_ALL, skill_id); } -int skill_get_unit_bl_target( uint16 skill_id ) { skill_get (skill_db[skill_id].unit_target&BL_ALL, skill_id); } -int skill_get_unit_flag( uint16 skill_id ) { skill_get (skill_db[skill_id].unit_flag, skill_id); } -int skill_get_unit_layout_type( uint16 skill_id ,uint16 skill_lv ){ skill_get2 (skill_db[skill_id].unit_layout_type[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_cooldown( uint16 skill_id, uint16 skill_lv ) { skill_get2 (skill_db[skill_id].cooldown[skill_glv(skill_lv-1)], skill_id, skill_lv); } +int skill_get_hit( uint16 skill_id ) { skill_get (skill->db[skill_id].hit, skill_id); } +int skill_get_inf( uint16 skill_id ) { skill_get (skill->db[skill_id].inf, skill_id); } +int skill_get_ele( uint16 skill_id , uint16 skill_lv ) { skill_get (skill->db[skill_id].element[skill_glv(skill_lv-1)], skill_id); } +int skill_get_nk( uint16 skill_id ) { skill_get (skill->db[skill_id].nk, skill_id); } +int skill_get_max( uint16 skill_id ) { skill_get (skill->db[skill_id].max, skill_id); } +int skill_get_range( uint16 skill_id , uint16 skill_lv ) { skill_get2 (skill->db[skill_id].range[skill_glv(skill_lv-1)], skill_id, skill_lv); } +int skill_get_splash( uint16 skill_id , uint16 skill_lv ) { skill_get2 ( (skill->db[skill_id].splash[skill_glv(skill_lv-1)]>=0?skill->db[skill_id].splash[skill_glv(skill_lv-1)]:AREA_SIZE), skill_id, skill_lv); } +int skill_get_hp( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill->db[skill_id].hp[skill_glv(skill_lv-1)], skill_id, skill_lv); } +int skill_get_sp( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill->db[skill_id].sp[skill_glv(skill_lv-1)], skill_id, skill_lv); } +int skill_get_hp_rate(uint16 skill_id, uint16 skill_lv ) { skill_get2 (skill->db[skill_id].hp_rate[skill_glv(skill_lv-1)], skill_id, skill_lv); } +int skill_get_sp_rate(uint16 skill_id, uint16 skill_lv ) { skill_get2 (skill->db[skill_id].sp_rate[skill_glv(skill_lv-1)], skill_id, skill_lv); } +int skill_get_state(uint16 skill_id) { skill_get (skill->db[skill_id].state, skill_id); } +int skill_get_spiritball(uint16 skill_id, uint16 skill_lv) { skill_get2 (skill->db[skill_id].spiritball[skill_glv(skill_lv-1)], skill_id, skill_lv); } +int skill_get_itemid(uint16 skill_id, int idx) { skill_get (skill->db[skill_id].itemid[idx], skill_id); } +int skill_get_itemqty(uint16 skill_id, int idx) { skill_get (skill->db[skill_id].amount[idx], skill_id); } +int skill_get_zeny( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill->db[skill_id].zeny[skill_glv(skill_lv-1)], skill_id, skill_lv); } +int skill_get_num( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill->db[skill_id].num[skill_glv(skill_lv-1)], skill_id, skill_lv); } +int skill_get_cast( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill->db[skill_id].cast[skill_glv(skill_lv-1)], skill_id, skill_lv); } +int skill_get_delay( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill->db[skill_id].delay[skill_glv(skill_lv-1)], skill_id, skill_lv); } +int skill_get_walkdelay( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill->db[skill_id].walkdelay[skill_glv(skill_lv-1)], skill_id, skill_lv); } +int skill_get_time( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill->db[skill_id].upkeep_time[skill_glv(skill_lv-1)], skill_id, skill_lv); } +int skill_get_time2( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill->db[skill_id].upkeep_time2[skill_glv(skill_lv-1)], skill_id, skill_lv); } +int skill_get_castdef( uint16 skill_id ) { skill_get (skill->db[skill_id].cast_def_rate, skill_id); } +int skill_get_weapontype( uint16 skill_id ) { skill_get (skill->db[skill_id].weapon, skill_id); } +int skill_get_ammotype( uint16 skill_id ) { skill_get (skill->db[skill_id].ammo, skill_id); } +int skill_get_ammo_qty( uint16 skill_id, uint16 skill_lv ) { skill_get2 (skill->db[skill_id].ammo_qty[skill_glv(skill_lv-1)], skill_id, skill_lv); } +int skill_get_inf2( uint16 skill_id ) { skill_get (skill->db[skill_id].inf2, skill_id); } +int skill_get_castcancel( uint16 skill_id ) { skill_get (skill->db[skill_id].castcancel, skill_id); } +int skill_get_maxcount( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill->db[skill_id].maxcount[skill_glv(skill_lv-1)], skill_id, skill_lv); } +int skill_get_blewcount( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill->db[skill_id].blewcount[skill_glv(skill_lv-1)], skill_id, skill_lv); } +int skill_get_mhp( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill->db[skill_id].mhp[skill_glv(skill_lv-1)], skill_id, skill_lv); } +int skill_get_castnodex( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill->db[skill_id].castnodex[skill_glv(skill_lv-1)], skill_id, skill_lv); } +int skill_get_delaynodex( uint16 skill_id ,uint16 skill_lv ){ skill_get2 (skill->db[skill_id].delaynodex[skill_glv(skill_lv-1)], skill_id, skill_lv); } +int skill_get_type( uint16 skill_id ) { skill_get (skill->db[skill_id].skill_type, skill_id); } +int skill_get_unit_id ( uint16 skill_id, int flag ){ skill_get (skill->db[skill_id].unit_id[flag], skill_id); } +int skill_get_unit_interval( uint16 skill_id ) { skill_get (skill->db[skill_id].unit_interval, skill_id); } +int skill_get_unit_range( uint16 skill_id, uint16 skill_lv ) { skill_get2 (skill->db[skill_id].unit_range[skill_glv(skill_lv-1)], skill_id, skill_lv); } +int skill_get_unit_target( uint16 skill_id ) { skill_get (skill->db[skill_id].unit_target&BCT_ALL, skill_id); } +int skill_get_unit_bl_target( uint16 skill_id ) { skill_get (skill->db[skill_id].unit_target&BL_ALL, skill_id); } +int skill_get_unit_flag( uint16 skill_id ) { skill_get (skill->db[skill_id].unit_flag, skill_id); } +int skill_get_unit_layout_type( uint16 skill_id ,uint16 skill_lv ){ skill_get2 (skill->db[skill_id].unit_layout_type[skill_glv(skill_lv-1)], skill_id, skill_lv); } +int skill_get_cooldown( uint16 skill_id, uint16 skill_lv ) { skill_get2 (skill->db[skill_id].cooldown[skill_glv(skill_lv-1)], skill_id, skill_lv); } #ifdef RENEWAL_CAST -int skill_get_fixed_cast( uint16 skill_id ,uint16 skill_lv ){ skill_get2 (skill_db[skill_id].fixed_cast[skill_glv(skill_lv-1)], skill_id, skill_lv); } +int skill_get_fixed_cast( uint16 skill_id ,uint16 skill_lv ){ skill_get2 (skill->db[skill_id].fixed_cast[skill_glv(skill_lv-1)], skill_id, skill_lv); } #endif int skill_tree_get_max(uint16 skill_id, int b_class) { @@ -244,9 +200,6 @@ int skill_tree_get_max(uint16 skill_id, int b_class) return skill->get_max(skill_id); } -int enchant_eff[5] = { 10, 14, 17, 19, 20 }; -int deluge_eff[5] = { 5, 9, 12, 14, 15 }; - int skill_get_casttype (uint16 skill_id) { int inf = skill->get_inf(skill_id); if (inf&(INF_GROUND_SKILL)) @@ -264,17 +217,17 @@ int skill_get_casttype (uint16 skill_id) { } int skill_get_casttype2 (uint16 index) { - int inf = skill_db[index].inf; + int inf = skill->db[index].inf; if (inf&(INF_GROUND_SKILL)) return CAST_GROUND; if (inf&INF_SUPPORT_SKILL) return CAST_NODAMAGE; if (inf&INF_SELF_SKILL) { - if(skill_db[index].inf2&INF2_NO_TARGET_SELF) + if(skill->db[index].inf2&INF2_NO_TARGET_SELF) return CAST_DAMAGE; //Combo skill. return CAST_NODAMAGE; } - if (skill_db[index].nk&NK_NO_DAMAGE) + if (skill->db[index].nk&NK_NO_DAMAGE) return CAST_NODAMAGE; return CAST_DAMAGE; } @@ -373,11 +326,11 @@ int skill_calc_heal(struct block_list *src, struct block_list *target, uint16 sk switch( skill_id ) { case BA_APPLEIDUN: - #ifdef RENEWAL +#ifdef RENEWAL hp = 100+5*skill_lv+5*(status_get_vit(src)/10); // HP recovery - #else +#else // not RENEWAL hp = 30+5*skill_lv+5*(status_get_vit(src)/10); // HP recovery - #endif +#endif // RENEWAL if( sd ) hp += 5*pc->checkskill(sd,BA_MUSICALLESSON); break; @@ -390,15 +343,15 @@ int skill_calc_heal(struct block_list *src, struct block_list *target, uint16 sk default: if (skill_lv >= battle_config.max_heal_lv) return battle_config.max_heal; - #ifdef RENEWAL - /** - * Renewal Heal Formula - * Formula: ( [(Base Level + INT) / 5] ? 30 ) ? (Heal Level / 10) ? (Modifiers) + MATK - **/ - hp = (iStatus->get_lv(src) + status_get_int(src)) / 5 * 30 * skill_lv / 10; - #else - hp = ( iStatus->get_lv(src) + status_get_int(src) ) / 8 * (4 + ( skill_id == AB_HIGHNESSHEAL ? ( sd ? pc->checkskill(sd,AL_HEAL) : 10 ) : skill_lv ) * 8); - #endif +#ifdef RENEWAL + /** + * Renewal Heal Formula + * Formula: ( [(Base Level + INT) / 5] ? 30 ) ? (Heal Level / 10) ? (Modifiers) + MATK + **/ + hp = (status->get_lv(src) + status_get_int(src)) / 5 * 30 * skill_lv / 10; +#else // not RENEWAL + hp = ( status->get_lv(src) + status_get_int(src) ) / 8 * (4 + ( skill_id == AB_HIGHNESSHEAL ? ( sd ? pc->checkskill(sd,AL_HEAL) : 10 ) : skill_lv ) * 8); +#endif // RENEWAL if( sd && ((skill2_lv = pc->checkskill(sd, HP_MEDITATIO)) > 0) ) hp += hp * skill2_lv * 2 / 100; else if( src->type == BL_HOM && (skill2_lv = homun->checkskill(((TBL_HOM*)src), HLIF_BRAIN)) > 0 ) @@ -415,7 +368,7 @@ int skill_calc_heal(struct block_list *src, struct block_list *target, uint16 sk if( tsd && (skill2_lv = pc->skillheal2_bonus(tsd, skill_id)) ) hp += hp*skill2_lv/100; - sc = iStatus->get_sc(target); + sc = status->get_sc(target); if( sc && sc->count ) { if( sc->data[SC_CRITICALWOUND] && heal ) // Critical Wound has no effect on offensive heal. [Inkfish] hp -= hp * sc->data[SC_CRITICALWOUND]->val2/100; @@ -430,15 +383,17 @@ int skill_calc_heal(struct block_list *src, struct block_list *target, uint16 sk } #ifdef RENEWAL - // MATK part of the RE heal formula [malufett] - // Note: in this part matk bonuses from items or skills are not applied + // MATK part of the RE heal formula [malufett] + // Note: in this part matk bonuses from items or skills are not applied switch( skill_id ) { - case BA_APPLEIDUN: case PR_SANCTUARY: - case NPC_EVILLAND: break; + case BA_APPLEIDUN: + case PR_SANCTUARY: + case NPC_EVILLAND: + break; default: - hp += iStatus->get_matk(src, 3); + hp += status->get_matk(src, 3); } -#endif +#endif // RENEWAL return hp; } @@ -468,7 +423,7 @@ int can_copy (struct map_session_data *sd, uint16 skill_id, struct block_list* b if( !(sd->sc.data[SC__REPRODUCE]) && (skill_id >= RK_ENCHANTBLADE && skill_id <= SR_RIDEINLIGHTNING) ) return 0; // Reproduce will only copy skills according on the list. [Jobbie] - else if( sd->sc.data[SC__REPRODUCE] && !skill_reproduce_db[skill->get_index(skill_id)] ) + else if( sd->sc.data[SC__REPRODUCE] && !skill->reproduce_db[skill->get_index(skill_id)] ) return 0; return 1; @@ -567,7 +522,7 @@ 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)) + if( !(battle_config.emergency_call&((map->agit_flag || map->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) ) { @@ -662,26 +617,25 @@ struct s_skill_unit_layout* skill_get_unit_layout (uint16 skill_id, uint16 skill } if (pos != -1) // simple single-definition layout - return &skill_unit_layout[pos]; + return &skill->unit_layout[pos]; - dir = (src->x == x && src->y == y) ? 6 : iMap->calc_dir(src,x,y); // 6 - default aegis direction + dir = (src->x == x && src->y == y) ? 6 : map->calc_dir(src,x,y); // 6 - default aegis direction if (skill_id == MG_FIREWALL) - return &skill_unit_layout [firewall_unit_pos + dir]; + return &skill->unit_layout [skill->firewall_unit_pos + dir]; else if (skill_id == WZ_ICEWALL) - return &skill_unit_layout [icewall_unit_pos + dir]; + return &skill->unit_layout [skill->icewall_unit_pos + dir]; else if( skill_id == WL_EARTHSTRAIN ) //Warlock - return &skill_unit_layout [earthstrain_unit_pos + dir]; + return &skill->unit_layout [skill->earthstrain_unit_pos + dir]; ShowError("skill_get_unit_layout: unknown unit layout for skill %d (level %d)\n", skill_id, skill_lv); - return &skill_unit_layout[0]; // default 1x1 layout + return &skill->unit_layout[0]; // default 1x1 layout } /*========================================== * *------------------------------------------*/ -int skill_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) -{ +int skill_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) { struct map_session_data *sd, *dstsd; struct mob_data *md, *dstmd; struct status_data *sstatus, *tstatus; @@ -703,10 +657,10 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, uint dstsd = BL_CAST(BL_PC, bl); dstmd = BL_CAST(BL_MOB, bl); - sc = iStatus->get_sc(src); - tsc = iStatus->get_sc(bl); - sstatus = iStatus->get_status_data(src); - tstatus = iStatus->get_status_data(bl); + sc = status->get_sc(src); + tsc = status->get_sc(bl); + sstatus = status->get_status_data(src); + tstatus = status->get_status_data(bl); if (!tsc) //skill additional effect is about adding effects to the target... //So if the target can't be inflicted with statuses, this is pointless. return 0; @@ -739,13 +693,13 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, uint } type = sd->addeff[i].id; - temp = skill->get_time2(iStatus->sc2skill(type),7); + temp = skill->get_time2(status->sc2skill(type),7); if (sd->addeff[i].flag&ATF_TARGET) - iStatus->change_start(bl,type,rate,7,0,(type == SC_BURNING)?src->id:0,0,temp,0); + status->change_start(bl,type,rate,7,0,(type == SC_BURNING)?src->id:0,0,temp,0); if (sd->addeff[i].flag&ATF_SELF) - iStatus->change_start(src,type,rate,7,0,(type == SC_BURNING)?src->id:0,0,temp,0); + status->change_start(src,type,rate,7,0,(type == SC_BURNING)?src->id:0,0,temp,0); } } @@ -757,12 +711,12 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, uint if( skill_id != sd->addeff3[i].skill || !sd->addeff3[i].rate ) continue; type = sd->addeff3[i].id; - temp = skill->get_time2(iStatus->sc2skill(type),7); + temp = skill->get_time2(status->sc2skill(type),7); if( sd->addeff3[i].target&ATF_TARGET ) - iStatus->change_start(bl,type,sd->addeff3[i].rate,7,0,0,0,temp,0); + status->change_start(bl,type,sd->addeff3[i].rate,7,0,0,0,temp,0); if( sd->addeff3[i].target&ATF_SELF ) - iStatus->change_start(src,type,sd->addeff3[i].rate,7,0,0,0,temp,0); + status->change_start(src,type,sd->addeff3[i].rate,7,0,0,0,temp,0); } } } @@ -825,7 +779,7 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, uint struct status_change_entry *sce; // Enchant Poison gives a chance to poison attacked enemies if((sce=sc->data[SC_ENCHANTPOISON])) //Don't use sc_start since chance comes in 1/10000 rate. - iStatus->change_start(bl,SC_POISON,sce->val2, sce->val1,src->id,0,0, + status->change_start(bl,SC_POISON,sce->val2, sce->val1,src->id,0,0, skill->get_time2(AS_ENCHANTPOISON,sce->val1),0); // Enchant Deadly Poison gives a chance to deadly poison attacked enemies if((sce=sc->data[SC_EDP])) @@ -837,7 +791,7 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, uint case SM_BASH: if( sd && skill_lv > 5 && pc->checkskill(sd,SM_FATALBLOW)>0 ) - iStatus->change_start(bl,SC_STUN,500*(skill_lv-5)*sd->status.base_level/50, + status->change_start(bl,SC_STUN,500*(skill_lv-5)*sd->status.base_level/50, skill_lv,0,0,0,skill->get_time2(SM_FATALBLOW,skill_lv),0); break; @@ -1006,7 +960,7 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, uint break; case NPC_PETRIFYATTACK: - sc_start4(bl,iStatus->skill2sc(skill_id),50+10*skill_lv, + sc_start4(bl,status->skill2sc(skill_id),50+10*skill_lv, skill_lv,0,0,skill->get_time(skill_id,skill_lv), skill->get_time2(skill_id,skill_lv)); break; @@ -1017,19 +971,20 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, uint case NPC_SILENCEATTACK: case NPC_STUNATTACK: case NPC_HELLPOWER: - sc_start(bl,iStatus->skill2sc(skill_id),50+10*skill_lv,skill_lv,skill->get_time2(skill_id,skill_lv)); + sc_start(bl,status->skill2sc(skill_id),50+10*skill_lv,skill_lv,skill->get_time2(skill_id,skill_lv)); break; case NPC_ACIDBREATH: case NPC_ICEBREATH: - sc_start(bl,iStatus->skill2sc(skill_id),70,skill_lv,skill->get_time2(skill_id,skill_lv)); + sc_start(bl,status->skill2sc(skill_id),70,skill_lv,skill->get_time2(skill_id,skill_lv)); break; case NPC_BLEEDING: sc_start2(bl,SC_BLOODING,(20*skill_lv),skill_lv,src->id,skill->get_time2(skill_id,skill_lv)); break; case NPC_MENTALBREAKER: - { //Based on observations by Tharis, Mental Breaker should do SP damage + { + //Based on observations by Tharis, Mental Breaker should do SP damage //equal to Matk*skLevel. - rate = iStatus->get_matk(src, 2); + rate = status->get_matk(src, 2); rate*=skill_lv; status_zap(bl, 0, rate); break; @@ -1073,7 +1028,7 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, uint case LK_JOINTBEAT: if (tsc->jb_flag) { - enum sc_type type = iStatus->skill2sc(skill_id); + enum sc_type type = status->skill2sc(skill_id); sc_start4(bl,type,(5*skill_lv+5),skill_lv,tsc->jb_flag&BREAK_FLAGS,src->id,0,skill->get_time2(skill_id,skill_lv)); tsc->jb_flag = 0; } @@ -1126,7 +1081,7 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, uint break; case GS_BULLSEYE: //0.1% coma rate. if(tstatus->race == RC_BRUTE || tstatus->race == RC_DEMIHUMAN) - iStatus->change_start(bl,SC_COMA,10,skill_lv,0,src->id,0,0,0); + status->change_start(bl,SC_COMA,10,skill_lv,0,src->id,0,0,0); break; case GS_PIERCINGSHOT: sc_start2(bl,SC_BLOODING,(skill_lv*3),skill_lv,src->id,skill->get_time2(skill_id,skill_lv)); @@ -1180,12 +1135,12 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, uint sc_start4(bl,SC_BURNING,100,skill_lv,0,src->id,0,skill->get_time2(skill_id,skill_lv)); break; case WL_EARTHSTRAIN: - { - // lv 1 & 2 = Strip Helm, lv 3 = Strip Armor, lv 4 = Strip Weapon and lv 5 = Strip Accessory. [malufett] - const int pos[5] = { EQP_HELM, EQP_HELM, EQP_ARMOR, EQP_WEAPON, EQP_ACC }; - skill->strip_equip(bl, pos[skill_lv], 6 * skill_lv + iStatus->get_lv(src) / 4 + status_get_dex(src) / 10, - skill_lv, skill->get_time2(skill_id,skill_lv)); - } + { + // lv 1 & 2 = Strip Helm, lv 3 = Strip Armor, lv 4 = Strip Weapon and lv 5 = Strip Accessory. [malufett] + const int pos[5] = { EQP_HELM, EQP_HELM, EQP_ARMOR, EQP_WEAPON, EQP_ACC }; + skill->strip_equip(bl, pos[skill_lv], 6 * skill_lv + status->get_lv(src) / 4 + status_get_dex(src) / 10, + skill_lv, skill->get_time2(skill_id,skill_lv)); + } break; case WL_JACKFROST: sc_start(bl,SC_FREEZE,100,skill_lv,skill->get_time(skill_id,skill_lv)); @@ -1240,7 +1195,7 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, uint sc_start(bl, SC_STUN, 30 + 8 * skill_lv, skill_lv, skill->get_time(skill_id,skill_lv)); break; case LG_PINPOINTATTACK: - rate = 30 + (((5 * (sd?pc->checkskill(sd,LG_PINPOINTATTACK):skill_lv)) + (sstatus->agi + iStatus->get_lv(src))) / 10); + rate = 30 + (((5 * (sd?pc->checkskill(sd,LG_PINPOINTATTACK):skill_lv)) + (sstatus->agi + status->get_lv(src))) / 10); switch( skill_lv ) { case 1: sc_start2(bl,SC_BLOODING,rate,skill_lv,src->id,skill->get_time(skill_id,skill_lv)); @@ -1282,7 +1237,7 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, uint sc_start(bl, SC_STUN, 100, skill_lv, 1000 + 1000 * (rnd() %3)); break; case SR_GENTLETOUCH_QUIET: // [(Skill Level x 5) + (Caster?s DEX + Caster?s Base Level) / 10] - sc_start(bl, SC_SILENCE, 5 * skill_lv + (sstatus->dex + iStatus->get_lv(src)) / 10, skill_lv, skill->get_time(skill_id, skill_lv)); + sc_start(bl, SC_SILENCE, 5 * skill_lv + (sstatus->dex + status->get_lv(src)) / 10, skill_lv, skill->get_time(skill_id, skill_lv)); break; case SR_EARTHSHAKER: sc_start(bl,SC_STUN, 25 + 5 * skill_lv,skill_lv,skill->get_time(skill_id,skill_lv)); @@ -1365,7 +1320,7 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, uint break; case EL_ROCK_CRUSHER: case EL_ROCK_CRUSHER_ATK: - sc_start(bl,iStatus->skill2sc(skill_id),50,skill_lv,skill->get_time(EL_ROCK_CRUSHER,skill_lv)); + sc_start(bl,status->skill2sc(skill_id),50,skill_lv,skill->get_time(EL_ROCK_CRUSHER,skill_lv)); break; case EL_TYPOON_MIS: sc_start(bl,SC_SILENCE,10*skill_lv,skill_lv,skill->get_time(skill_id,skill_lv)); @@ -1391,21 +1346,20 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, uint break; } - if (md && battle_config.summons_trigger_autospells && md->master_id && md->special_state.ai) - { //Pass heritage to Master for status causing effects. [Skotlex] - sd = iMap->id2sd(md->master_id); + if (md && battle_config.summons_trigger_autospells && md->master_id && md->special_state.ai) { + //Pass heritage to Master for status causing effects. [Skotlex] + sd = map->id2sd(md->master_id); src = sd?&sd->bl:src; } - if( attack_type&BF_WEAPON ) - { // Coma, Breaking Equipment - if( sd && sd->special_state.bonus_coma ) - { + if( attack_type&BF_WEAPON ) { + // Coma, Breaking Equipment + if( sd && sd->special_state.bonus_coma ) { rate = sd->weapon_coma_ele[tstatus->def_ele]; rate += sd->weapon_coma_race[tstatus->race]; rate += sd->weapon_coma_race[tstatus->mode&MD_BOSS?RC_BOSS:RC_NONBOSS]; if (rate) - iStatus->change_start(bl, SC_COMA, rate, 0, 0, src->id, 0, 0, 0); + status->change_start(bl, SC_COMA, rate, 0, 0, src->id, 0, 0, 0); } if( sd && battle_config.equip_self_break_rate ) { // Self weapon breaking @@ -1444,7 +1398,7 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, uint } } - if( sd && sd->ed && sc && !iStatus->isdead(bl) && !skill_id ){ + if( sd && sd->ed && sc && !status->isdead(bl) && !skill_id ) { struct unit_data *ud = unit->bl2ud(src); if( sc->data[SC_WILD_STORM_OPTION] ) @@ -1473,8 +1427,7 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, uint } // Autospell when attacking - if( sd && !iStatus->isdead(bl) && sd->autospell[0].id ) - { + if( sd && !status->isdead(bl) && sd->autospell[0].id ) { struct block_list *tbl; struct unit_data *ud; int i, skill_lv, type, notok; @@ -1702,8 +1655,6 @@ int skill_onskillusage(struct map_session_data *sd, struct block_list *bl, uint1 return 1; } -//Early declaration -static int skill_area_temp[8]; /* Splitted off from skill->additional_effect, which is never called when the * attack skill kills the enemy. Place in this function counter status effects * when using skills (eg: Asura's sp regen penalty, or counter-status effects @@ -1712,8 +1663,7 @@ static int skill_area_temp[8]; * type of skills, so not every instance of skill->additional_effect needs a call * to this one. */ -int skill_counter_additional_effect (struct block_list* src, struct block_list *bl, uint16 skill_id, uint16 skill_lv, int attack_type, unsigned int tick) -{ +int skill_counter_additional_effect(struct block_list* src, struct block_list *bl, uint16 skill_id, uint16 skill_lv, int attack_type, unsigned int tick) { int rate; struct map_session_data *sd=NULL; struct map_session_data *dstsd=NULL; @@ -1726,31 +1676,30 @@ int skill_counter_additional_effect (struct block_list* src, struct block_list * sd = BL_CAST(BL_PC, src); dstsd = BL_CAST(BL_PC, bl); - if(dstsd && attack_type&BF_WEAPON) - { //Counter effects. + if(dstsd && attack_type&BF_WEAPON) { + //Counter effects. enum sc_type type; int i, time; - for(i=0; i < ARRAYLENGTH(dstsd->addeff2) && dstsd->addeff2[i].flag; i++) - { + for(i=0; i < ARRAYLENGTH(dstsd->addeff2) && dstsd->addeff2[i].flag; i++) { rate = dstsd->addeff2[i].rate; if (attack_type&BF_LONG) rate+=dstsd->addeff2[i].arrow_rate; if (!rate) continue; - if ((dstsd->addeff2[i].flag&(ATF_LONG|ATF_SHORT)) != (ATF_LONG|ATF_SHORT)) - { //Trigger has range consideration. + if ((dstsd->addeff2[i].flag&(ATF_LONG|ATF_SHORT)) != (ATF_LONG|ATF_SHORT)) { + //Trigger has range consideration. if((dstsd->addeff2[i].flag&ATF_LONG && !(attack_type&BF_LONG)) || (dstsd->addeff2[i].flag&ATF_SHORT && !(attack_type&BF_SHORT))) continue; //Range Failed. } type = dstsd->addeff2[i].id; - time = skill->get_time2(iStatus->sc2skill(type),7); + time = skill->get_time2(status->sc2skill(type),7); if (dstsd->addeff2[i].flag&ATF_TARGET) - iStatus->change_start(src,type,rate,7,0,0,0,time,0); + status->change_start(src,type,rate,7,0,0,0,time,0); - if (dstsd->addeff2[i].flag&ATF_SELF && !iStatus->isdead(bl)) - iStatus->change_start(bl,type,rate,7,0,0,0,time,0); + if (dstsd->addeff2[i].flag&ATF_SELF && !status->isdead(bl)) + status->change_start(bl,type,rate,7,0,0,0,time,0); } } @@ -1776,24 +1725,25 @@ int skill_counter_additional_effect (struct block_list* src, struct block_list * break; } - if(sd && (sd->class_&MAPID_UPPERMASK) == MAPID_STAR_GLADIATOR && - rnd()%10000 < battle_config.sg_miracle_skill_ratio) //SG_MIRACLE [Komurka] + if( sd && (sd->class_&MAPID_UPPERMASK) == MAPID_STAR_GLADIATOR + && rnd()%10000 < battle_config.sg_miracle_skill_ratio) //SG_MIRACLE [Komurka] sc_start(src,SC_MIRACLE,100,1,battle_config.sg_miracle_skill_duration); - if(sd && skill_id && attack_type&BF_MAGIC && iStatus->isdead(bl) && - !(skill->get_inf(skill_id)&(INF_GROUND_SKILL|INF_SELF_SKILL)) && - (rate=pc->checkskill(sd,HW_SOULDRAIN))>0 - ){ //Soul Drain should only work on targetted spells [Skotlex] + if( sd && skill_id && attack_type&BF_MAGIC && status->isdead(bl) + && !(skill->get_inf(skill_id)&(INF_GROUND_SKILL|INF_SELF_SKILL)) + && (rate=pc->checkskill(sd,HW_SOULDRAIN)) > 0 + ) { + //Soul Drain should only work on targetted spells [Skotlex] if( pc_issit(sd) ) pc->setstand(sd); //Character stuck in attacking animation while 'sitting' fix. [Skotlex] - if( skill->get_nk(skill_id)&NK_SPLASH && skill_area_temp[1] != bl->id ) + if( skill->get_nk(skill_id)&NK_SPLASH && skill->area_temp[1] != bl->id ) ; - else{ + else { clif->skill_nodamage(src,bl,HW_SOULDRAIN,rate,1); - iStatus->heal(src, 0, iStatus->get_lv(bl)*(95+15*rate)/100, 2); + status->heal(src, 0, status->get_lv(bl)*(95+15*rate)/100, 2); } } - if( sd && iStatus->isdead(bl) ) { + if( sd && status->isdead(bl) ) { int sp = 0, hp = 0; if( attack_type&BF_WEAPON ) { sp += sd->bonus.sp_gain_value; @@ -1806,21 +1756,23 @@ int skill_counter_additional_effect (struct block_list* src, struct block_list * hp += sd->bonus.magic_hp_gain_value; if( skill_id == WZ_WATERBALL ) {//(bugreport:5303) struct status_change *sc = NULL; - if( ( sc = iStatus->get_sc(src) ) ) { - if(sc->data[SC_SOULLINK] && - sc->data[SC_SOULLINK]->val2 == SL_WIZARD && - sc->data[SC_SOULLINK]->val3 == WZ_WATERBALL) - sc->data[SC_SOULLINK]->val3 = 0; //Clear bounced spell check. + if( ( sc = status->get_sc(src) ) ) { + if( sc->data[SC_SOULLINK] + && sc->data[SC_SOULLINK]->val2 == SL_WIZARD + && sc->data[SC_SOULLINK]->val3 == WZ_WATERBALL + ) + sc->data[SC_SOULLINK]->val3 = 0; //Clear bounced spell check. } } } - if( hp || sp ) { // updated to force healing to allow healing through berserk - iStatus->heal(src, hp, sp, battle_config.show_hp_sp_gain ? 3 : 1); + if( hp || sp ) { + // updated to force healing to allow healing through berserk + status->heal(src, hp, sp, battle_config.show_hp_sp_gain ? 3 : 1); } } // Trigger counter-spells to retaliate against damage causing skills. - if(dstsd && !iStatus->isdead(bl) && dstsd->autospell2[0].id && !(skill_id && skill->get_nk(skill_id)&NK_NO_DAMAGE)) { + if(dstsd && !status->isdead(bl) && dstsd->autospell2[0].id && !(skill_id && skill->get_nk(skill_id)&NK_NO_DAMAGE)) { struct block_list *tbl; struct unit_data *ud; int i, skill_id, skill_lv, rate, type, notok; @@ -1911,7 +1863,7 @@ int skill_counter_additional_effect (struct block_list* src, struct block_list * } //Autobonus when attacked - if( dstsd && !iStatus->isdead(bl) && dstsd->autobonus2[0].rate && !(skill_id && skill->get_nk(skill_id)&NK_NO_DAMAGE) ) { + if( dstsd && !status->isdead(bl) && dstsd->autobonus2[0].rate && !(skill_id && skill->get_nk(skill_id)&NK_NO_DAMAGE) ) { int i; for( i = 0; i < ARRAYLENGTH(dstsd->autobonus2); i++ ) { if( rnd()%1000 >= dstsd->autobonus2[i].rate ) @@ -1938,7 +1890,7 @@ int skill_break_equip (struct block_list *bl, unsigned short where, int rate, in const int where_list[4] = {EQP_WEAPON, EQP_ARMOR, EQP_SHIELD, EQP_HELM}; const enum sc_type scatk[4] = {SC_NOEQUIPWEAPON, SC_NOEQUIPARMOR, SC_NOEQUIPSHIELD, SC_NOEQUIPHELM}; const enum sc_type scdef[4] = {SC_PROTECTWEAPON, SC_PROTECTARMOR, SC_PROTECTSHIELD, SC_PROTECTHELM}; - struct status_change *sc = iStatus->get_sc(bl); + struct status_change *sc = status->get_sc(bl); int i,j; TBL_PC *sd; sd = BL_CAST(BL_PC, bl); @@ -1980,7 +1932,7 @@ int skill_break_equip (struct block_list *bl, unsigned short where, int rate, in else if (rnd()%10000 >= rate) where&=~where_list[i]; else if (!sd && !(status_get_mode(bl)&MD_BOSS)) //Cause Strip effect. - sc_start(bl,scatk[i],100,0,skill->get_time(iStatus->sc2skill(scatk[i]),1)); + sc_start(bl,scatk[i],100,0,skill->get_time(status->sc2skill(scatk[i]),1)); } } if (!where) //Nothing to break. @@ -2034,7 +1986,7 @@ int skill_strip_equip(struct block_list *bl, unsigned short where, int rate, int if (rnd()%100 >= rate) return 0; - sc = iStatus->get_sc(bl); + sc = status->get_sc(bl); if (!sc || sc->option&OPTION_MADOGEAR ) //Mado Gear cannot be divested [Ind] return 0; @@ -2093,7 +2045,7 @@ int skill_blown(struct block_list* src, struct block_list* target, int count, in } if (dir == -1) // <optimized>: do the computation here instead of outside - dir = iMap->calc_dir(target, src->x, src->y); // direction from src to target, reversed + dir = map->calc_dir(target, src->x, src->y); // direction from src to target, reversed if (dir >= 0 && dir < 8) { // take the reversed 'direction' and reverse it @@ -2108,7 +2060,7 @@ int skill_blown(struct block_list* src, struct block_list* target, int count, in //Checks if 'bl' should reflect back a spell cast by 'src'. //type is the type of magic attack: 0: indirect (aoe), 1: direct (targetted) int skill_magic_reflect(struct block_list* src, struct block_list* bl, int type) { - struct status_change *sc = iStatus->get_sc(bl); + struct status_change *sc = status->get_sc(bl); struct map_session_data* sd = BL_CAST(BL_PC, bl); if( sc && sc->data[SC_KYOMU] ) // Nullify reflecting ability @@ -2128,7 +2080,7 @@ int skill_magic_reflect(struct block_list* src, struct block_list* bl, int type) if( sc->data[SC_MAGICMIRROR] && rnd()%100 < sc->data[SC_MAGICMIRROR]->val2 ) return 1; - if( sc->data[SC_KAITE] && (src->type == BL_PC || iStatus->get_lv(src) <= 80) ) + if( sc->data[SC_KAITE] && (src->type == BL_PC || status->get_lv(src) <= 80) ) {// Kaite only works against non-players if they are low-level. clif->specialeffect(bl, 438, AREA); if( --sc->data[SC_KAITE]->val2 <= 0 ) @@ -2171,20 +2123,20 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds if (src != dsrc) { //When caster is not the src of attack, this is a ground skill, and as such, do the relevant target checking. [Skotlex] - if (!iStatus->check_skilluse(battle_config.skill_caster_check?src:NULL, bl, skill_id, 2)) + if (!status->check_skilluse(battle_config.skill_caster_check?src:NULL, bl, skill_id, 2)) return 0; } else if ((flag&SD_ANIMATION) && skill->get_nk(skill_id)&NK_SPLASH) { //Note that splash attacks often only check versus the targetted mob, those around the splash area normally don't get checked for being hidden/cloaked/etc. [Skotlex] - if (!iStatus->check_skilluse(src, bl, skill_id, 2)) + if (!status->check_skilluse(src, bl, skill_id, 2)) return 0; } sd = BL_CAST(BL_PC, src); tsd = BL_CAST(BL_PC, bl); - sstatus = iStatus->get_status_data(src); - tstatus = iStatus->get_status_data(bl); - sc= iStatus->get_sc(bl); + sstatus = status->get_status_data(src); + tstatus = status->get_status_data(bl); + sc = status->get_sc(bl); if (sc && !sc->count) sc = NULL; //Don't need it. // Is this check really needed? FrostNova won't hurt you if you step right where the caster is? @@ -2212,10 +2164,10 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds } } - if( dmg.flag&BF_MAGIC && ( skill_id != NPC_EARTHQUAKE || (battle_config.eq_single_target_reflectable && (flag&0xFFF) == 1) ) ) - { // Earthquake on multiple targets is not counted as a target skill. [Inkfish] - if( (dmg.damage || dmg.damage2) && (type = skill->magic_reflect(src, bl, src==dsrc)) ) - { //Magic reflection, switch caster/target + if( dmg.flag&BF_MAGIC && ( skill_id != NPC_EARTHQUAKE || (battle_config.eq_single_target_reflectable && (flag&0xFFF) == 1) ) ) { + // Earthquake on multiple targets is not counted as a target skill. [Inkfish] + if( (dmg.damage || dmg.damage2) && (type = skill->magic_reflect(src, bl, src==dsrc)) ) { + //Magic reflection, switch caster/target struct block_list *tbl = bl; rmdamage = 1; bl = src; @@ -2223,7 +2175,7 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds dsrc = tbl; sd = BL_CAST(BL_PC, src); tsd = BL_CAST(BL_PC, bl); - sc = iStatus->get_sc(bl); + sc = status->get_sc(bl); if (sc && !sc->count) sc = NULL; //Don't need it. /* bugreport:2564 flag&2 disables double casting trigger */ @@ -2253,18 +2205,18 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds if (s_ele == -1) // the skill takes the weapon's element s_ele = sstatus->rhw.ele; else if (s_ele == -2) //Use status element - s_ele = status_get_attack_sc_element(src,iStatus->get_sc(src)); + s_ele = status_get_attack_sc_element(src,status->get_sc(src)); else if( s_ele == -3 ) //Use random element s_ele = rnd()%ELE_MAX; dmg.damage = battle->attr_fix(bl, bl, dmg.damage, s_ele, status_get_element(bl), status_get_element_level(bl)); if( sc && sc->data[SC_ENERGYCOAT] ) { - struct status_data *st = iStatus->get_status_data(bl); + struct status_data *st = status->get_status_data(bl); int per = 100*st->sp / st->max_sp -1; //100% should be counted as the 80~99% interval per /=20; //Uses 20% SP intervals. //SP Cost: 1% + 0.5% per every 20% SP - if (!iStatus->charge(bl, 0, (10+5*per)*st->max_sp/1000)) + if (!status->charge(bl, 0, (10+5*per)*st->max_sp/1000)) status_change_end(bl, SC_ENERGYCOAT, INVALID_TIMER); //Reduction: 6% + 6% every 20% dmg.damage -= dmg.damage * (6 * (1+per)) / 100; @@ -2280,7 +2232,7 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds sp = sp * sc->data[SC_MAGICROD]->val2 / 100; if(skill_id == WZ_WATERBALL && skill_lv > 1) sp = sp/((skill_lv|1)*(skill_lv|1)); //Estimate SP cost of a single water-ball - iStatus->heal(bl, 0, sp, 2); + status->heal(bl, 0, sp, 2); } } @@ -2331,8 +2283,8 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds sce->val1 = skill_id; //Update combo-skill sce->val3 = skill_id; if( sce->timer != INVALID_TIMER ) - timer->delete(sce->timer, iStatus->change_timer); - sce->timer = timer->add(tick+sce->val4, iStatus->change_timer, src->id, SC_COMBOATTACK); + timer->delete(sce->timer, status->change_timer); + sce->timer = timer->add(tick+sce->val4, status->change_timer, src->id, SC_COMBOATTACK); break; } unit->cancel_combo(src); // Cancel combo wait @@ -2520,7 +2472,7 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds break; } - iMap->freeblock_lock(); + map->freeblock_lock(); if(damage > 0 && dmg.flag&BF_SKILL && tsd && pc->checkskill(tsd,RG_PLAGIARISM) @@ -2623,7 +2575,7 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds //Instant damage if( !sc || (!sc->data[SC_DEVOTION] && skill_id != CR_REFLECTSHIELD) ) status_fix_damage(src,bl,damage,dmg.dmotion); //Deal damage before knockback to allow stuff like firewall+storm gust combo. - if( !iStatus->isdead(bl) && additional_effects ) + if( !status->isdead(bl) && additional_effects ) skill->additional_effect(src,bl,skill_id,skill_lv,dmg.flag,dmg.dmg_lv,tick); if( damage > 0 ) //Counter status effects [Skotlex] skill->counter_additional_effect(src,bl,skill_id,skill_lv,dmg.flag,tick); @@ -2637,7 +2589,7 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds //Only knockback if it's still alive, otherwise a "ghost" is left behind. [Skotlex] //Reflected spells do not bounce back (bl == dsrc since it only happens for direct skills) - if (dmg.blewcount > 0 && bl!=dsrc && !iStatus->isdead(bl)) { + if (dmg.blewcount > 0 && bl!=dsrc && !status->isdead(bl)) { int8 dir = -1; // default switch(skill_id) {//direction case MG_FIREWALL: @@ -2654,7 +2606,7 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds dir = rand()%8; break; case WL_CRIMSONROCK: - dir = iMap->calc_dir(bl,skill_area_temp[4],skill_area_temp[5]); + dir = map->calc_dir(bl,skill->area_temp[4],skill->area_temp[5]); break; } @@ -2670,7 +2622,7 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds short dir_x, dir_y; dir_x = dirx[(dir+4)%8]; dir_y = diry[(dir+4)%8]; - if( iMap->getcell(bl->m, bl->x+dir_x, bl->y+dir_y, CELL_CHKNOPASS) != 0 ) + if( map->getcell(bl->m, bl->x+dir_x, bl->y+dir_y, CELL_CHKNOPASS) != 0 ) skill->addtimerskill(src, tick + status_get_amotion(src), bl->id, 0, 0, LG_OVERBRAND_PLUSATK, skill_lv, BF_WEAPON, flag ); } else skill->addtimerskill(src, tick + status_get_amotion(src), bl->id, 0, 0, LG_OVERBRAND_PLUSATK, skill_lv, BF_WEAPON, flag ); @@ -2680,7 +2632,7 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds short dir_x, dir_y; dir_x = dirx[(dir+4)%8]; dir_y = diry[(dir+4)%8]; - if( iMap->getcell(bl->m, bl->x+dir_x, bl->y+dir_y, CELL_CHKNOPASS) != 0 ) + if( map->getcell(bl->m, bl->x+dir_x, bl->y+dir_y, CELL_CHKNOPASS) != 0 ) skill->addtimerskill(src, tick + 300 * ((flag&2) ? 1 : 2), bl->id, 0, 0, skill_id, skill_lv, BF_WEAPON, flag|4); } break; @@ -2706,7 +2658,7 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds if( sc && sc->data[SC_DEVOTION] && skill_id != PA_PRESSURE ) { struct status_change_entry *sce = sc->data[SC_DEVOTION]; - struct block_list *d_bl = iMap->id2bl(sce->val1); + struct block_list *d_bl = map->id2bl(sce->val1); if( d_bl && ( (d_bl->type == BL_MER && ((TBL_MER*)d_bl)->master && ((TBL_MER*)d_bl)->master->bl.id == bl->id) || @@ -2733,11 +2685,11 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds if(damage > 0 && !(tstatus->mode&MD_BOSS)) { if( skill_id == RG_INTIMIDATE ) { int rate = 50 + skill_lv * 5; - rate = rate + (iStatus->get_lv(src) - iStatus->get_lv(bl)); + rate = rate + (status->get_lv(src) - status->get_lv(bl)); if(rnd()%100 < rate) skill->addtimerskill(src,tick + 800,bl->id,0,0,skill_id,skill_lv,0,flag); } else if( skill_id == SC_FATALMENACE ) - skill->addtimerskill(src,tick + 800,bl->id,skill_area_temp[4],skill_area_temp[5],skill_id,skill_lv,0,flag); + skill->addtimerskill(src,tick + 800,bl->id,skill->area_temp[4],skill->area_temp[5],skill_id,skill_lv,0,flag); } if(skill_id == CR_GRANDCROSS || skill_id == NPC_GRANDDARKNESS) @@ -2761,14 +2713,15 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds case RK_CRUSHSTRIKE: skill->break_equip(src,EQP_WEAPON,2000,BCT_SELF); // 20% chance to destroy the weapon. break; - case GC_VENOMPRESSURE: { - struct status_change *ssc = iStatus->get_sc(src); - if( ssc && ssc->data[SC_POISONINGWEAPON] && rnd()%100 < 70 + 5*skill_lv ) { - sc_start(bl,ssc->data[SC_POISONINGWEAPON]->val2,100,ssc->data[SC_POISONINGWEAPON]->val1,skill->get_time2(GC_POISONINGWEAPON, 1)); - status_change_end(src,SC_POISONINGWEAPON,INVALID_TIMER); - clif->skill_nodamage(src,bl,skill_id,skill_lv,1); - } + case GC_VENOMPRESSURE: + { + struct status_change *ssc = status->get_sc(src); + if( ssc && ssc->data[SC_POISONINGWEAPON] && rnd()%100 < 70 + 5*skill_lv ) { + sc_start(bl,ssc->data[SC_POISONINGWEAPON]->val2,100,ssc->data[SC_POISONINGWEAPON]->val1,skill->get_time2(GC_POISONINGWEAPON, 1)); + status_change_end(src,SC_POISONINGWEAPON,INVALID_TIMER); + clif->skill_nodamage(src,bl,skill_id,skill_lv,1); } + } break; case WM_METALICSOUND: status_zap(bl, 0, damage*100/(100*(110-pc->checkskill(sd,WM_LESSON)*10))); @@ -2781,19 +2734,17 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds skill->onskillusage(sd, bl, skill_id, tick); } - if (!(flag&2) && - ( - skill_id == MG_COLDBOLT || skill_id == MG_FIREBOLT || skill_id == MG_LIGHTNINGBOLT - ) && - (sc = iStatus->get_sc(src)) && - sc->data[SC_DOUBLECASTING] && - rnd() % 100 < sc->data[SC_DOUBLECASTING]->val2) - { -// skill->addtimerskill(src, tick + dmg.div_*dmg.amotion, bl->id, 0, 0, skill_id, skill_lv, BF_MAGIC, flag|2); + if (!(flag&2) + && (skill_id == MG_COLDBOLT || skill_id == MG_FIREBOLT || skill_id == MG_LIGHTNINGBOLT) + && (sc = status->get_sc(src)) + && sc->data[SC_DOUBLECASTING] + && rnd() % 100 < sc->data[SC_DOUBLECASTING]->val2 + ) { + //skill->addtimerskill(src, tick + dmg.div_*dmg.amotion, bl->id, 0, 0, skill_id, skill_lv, BF_MAGIC, flag|2); skill->addtimerskill(src, tick + dmg.amotion, bl->id, 0, 0, skill_id, skill_lv, BF_MAGIC, flag|2); } - iMap->freeblock_unlock(); + map->freeblock_unlock(); return (int)cap_value(damage,INT_MIN,INT_MAX); } @@ -2803,7 +2754,6 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds * Checking bl battle flag and display dammage * then call func with source,target,skill_id,skill_lv,tick,flag *------------------------------------------*/ -typedef int (*SkillFunc)(struct block_list *, struct block_list *, int, int, unsigned int, int); int skill_area_sub (struct block_list *bl, va_list ap) { struct block_list *src; uint16 skill_id,skill_lv; @@ -2822,11 +2772,11 @@ int skill_area_sub (struct block_list *bl, va_list ap) { if(battle->check_target(src,bl,flag) > 0) { // several splash skills need this initial dummy packet to display correctly - if (flag&SD_PREAMBLE && skill_area_temp[2] == 0) + if (flag&SD_PREAMBLE && skill->area_temp[2] == 0) clif->skill_damage(src,bl,tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6); if (flag&(SD_SPLASH|SD_PREAMBLE)) - skill_area_temp[2]++; + skill->area_temp[2]++; return func(src,bl,skill_id,skill_lv,tick,flag); } @@ -2905,7 +2855,7 @@ int skill_check_unit_range (struct block_list *bl, int x, int y, uint16 skill_id } range += layout_type; - return iMap->foreachinarea(skill->check_unit_range_sub,bl->m,x-range,y-range,x+range,y+range,BL_SKILL,skill_id); + return map->foreachinarea(skill->check_unit_range_sub,bl->m,x-range,y-range,x+range,y+range,BL_SKILL,skill_id); } int skill_check_unit_range2_sub (struct block_list *bl, va_list ap) { @@ -2916,7 +2866,7 @@ int skill_check_unit_range2_sub (struct block_list *bl, va_list ap) { skill_id = va_arg(ap,int); - if( iStatus->isdead(bl) && skill_id != AL_WARP ) + if( status->isdead(bl) && skill_id != AL_WARP ) return 0; if( skill_id == HP_BASILICA && bl->type == BL_PC ) @@ -2952,9 +2902,9 @@ int skill_check_unit_range2 (struct block_list *bl, int x, int y, uint16 skill_i else type = BL_PC; - return iMap->foreachinarea(skill->check_unit_range2_sub, bl->m, - x - range, y - range, x + range, y + range, - type, skill_id); + return map->foreachinarea(skill->check_unit_range2_sub, bl->m, + x - range, y - range, x + range, y + range, + type, skill_id); } /*========================================== @@ -2974,28 +2924,27 @@ int skill_check_condition_mercenary(struct block_list *bl, int skill_id, int lv, return 0; nullpo_ret(bl); - switch( bl->type ) - { + switch( bl->type ) { case BL_HOM: sd = ((TBL_HOM*)bl)->master; break; case BL_MER: sd = ((TBL_MER*)bl)->master; break; } - st = iStatus->get_status_data(bl); + st = status->get_status_data(bl); if( (idx = skill->get_index(skill_id)) == 0 ) return 0; // Requeriments for( i = 0; i < ARRAYLENGTH(itemid); i++ ) { - itemid[i] = skill_db[idx].itemid[i]; - amount[i] = skill_db[idx].amount[i]; - } - hp = skill_db[idx].hp[lv-1]; - sp = skill_db[idx].sp[lv-1]; - hp_rate = skill_db[idx].hp_rate[lv-1]; - sp_rate = skill_db[idx].sp_rate[lv-1]; - state = skill_db[idx].state; - if( (mhp = skill_db[idx].mhp[lv-1]) > 0 ) + itemid[i] = skill->db[idx].itemid[i]; + amount[i] = skill->db[idx].amount[i]; + } + hp = skill->db[idx].hp[lv-1]; + sp = skill->db[idx].sp[lv-1]; + hp_rate = skill->db[idx].hp_rate[lv-1]; + sp_rate = skill->db[idx].sp_rate[lv-1]; + state = skill->db[idx].state; + if( (mhp = skill->db[idx].mhp[lv-1]) > 0 ) hp += (st->max_hp * mhp) / 100; if( hp_rate > 0 ) hp += (st->hp * hp_rate) / 100; @@ -3082,7 +3031,7 @@ int skill_area_sub_count (struct block_list *src, struct block_list *target, uin * *------------------------------------------*/ int skill_timerskill(int tid, unsigned int tick, int id, intptr_t data) { - struct block_list *src = iMap->id2bl(id),*target; + struct block_list *src = map->id2bl(id),*target; struct unit_data *ud = unit->bl2ud(src); struct skill_timerskill *skl; int range; @@ -3097,7 +3046,7 @@ int skill_timerskill(int tid, unsigned int tick, int id, intptr_t data) { if(src->prev == NULL) break; // Source not on Map if(skl->target_id) { - target = iMap->id2bl(skl->target_id); + target = map->id2bl(skl->target_id); if( ( skl->skill_id == RG_INTIMIDATE || skl->skill_id == SC_FATALMENACE ) && (!target || target->prev == NULL || !check_distance_bl(src,target,AREA_SIZE)) ) target = src; //Required since it has to warp. if(target == NULL) @@ -3106,42 +3055,42 @@ int skill_timerskill(int tid, unsigned int tick, int id, intptr_t data) { break; // Target not on Map if(src->m != target->m) break; // Different Maps - if(iStatus->isdead(src)) + if(status->isdead(src)) break; // Caster is Dead - if(iStatus->isdead(target) && skl->skill_id != RG_INTIMIDATE && skl->skill_id != WZ_WATERBALL) + if(status->isdead(target) && skl->skill_id != RG_INTIMIDATE && skl->skill_id != WZ_WATERBALL) break; switch(skl->skill_id) { case RG_INTIMIDATE: if (unit->warp(src,-1,-1,-1,CLR_TELEPORT) == 0) { short x,y; - iMap->search_freecell(src, 0, &x, &y, 1, 1, 0); - if (target != src && !iStatus->isdead(target)) + map->search_freecell(src, 0, &x, &y, 1, 1, 0); + if (target != src && !status->isdead(target)) unit->warp(target, -1, x, y, CLR_TELEPORT); } break; case BA_FROSTJOKER: case DC_SCREAM: range= skill->get_splash(skl->skill_id, skl->skill_lv); - iMap->foreachinarea(skill->frostjoke_scream,skl->map,skl->x-range,skl->y-range, - skl->x+range,skl->y+range,BL_CHAR,src,skl->skill_id,skl->skill_lv,tick); + map->foreachinarea(skill->frostjoke_scream,skl->map,skl->x-range,skl->y-range, + skl->x+range,skl->y+range,BL_CHAR,src,skl->skill_id,skl->skill_lv,tick); break; case NPC_EARTHQUAKE: if( skl->type > 1 ) skill->addtimerskill(src,tick+250,src->id,0,0,skl->skill_id,skl->skill_lv,skl->type-1,skl->flag); - skill_area_temp[0] = iMap->foreachinrange(skill->area_sub, src, skill->get_splash(skl->skill_id, skl->skill_lv), BL_CHAR, src, skl->skill_id, skl->skill_lv, tick, BCT_ENEMY, skill->area_sub_count); - skill_area_temp[1] = src->id; - skill_area_temp[2] = 0; - iMap->foreachinrange(skill->area_sub, src, skill->get_splash(skl->skill_id, skl->skill_lv), splash_target(src), src, skl->skill_id, skl->skill_lv, tick, skl->flag, skill->castend_damage_id); + skill->area_temp[0] = map->foreachinrange(skill->area_sub, src, skill->get_splash(skl->skill_id, skl->skill_lv), BL_CHAR, src, skl->skill_id, skl->skill_lv, tick, BCT_ENEMY, skill->area_sub_count); + skill->area_temp[1] = src->id; + skill->area_temp[2] = 0; + map->foreachinrange(skill->area_sub, src, skill->get_splash(skl->skill_id, skl->skill_lv), splash_target(src), src, skl->skill_id, skl->skill_lv, tick, skl->flag, skill->castend_damage_id); break; case WZ_WATERBALL: skill->toggle_magicpower(src, skl->skill_id); // only the first hit will be amplify - if (!iStatus->isdead(target)) + if (!status->isdead(target)) skill->attack(BF_MAGIC,src,src,target,skl->skill_id,skl->skill_lv,tick,skl->flag); - if (skl->type>1 && !iStatus->isdead(target) && !iStatus->isdead(src)) { + if (skl->type>1 && !status->isdead(target) && !status->isdead(src)) { skill->addtimerskill(src,tick+125,target->id,0,0,skl->skill_id,skl->skill_lv,skl->type-1,skl->flag); } else { - struct status_change *sc = iStatus->get_sc(src); + struct status_change *sc = status->get_sc(src); if(sc) { if(sc->data[SC_SOULLINK] && sc->data[SC_SOULLINK]->val2 == SL_WIZARD && @@ -3193,7 +3142,7 @@ int skill_timerskill(int tid, unsigned int tick, int id, intptr_t data) { unit->warp(src, -1, skl->x, skl->y, 3); else { // Target's Part short x = skl->x, y = skl->y; - iMap->search_freecell(NULL, target->m, &x, &y, 2, 2, 1); + map->search_freecell(NULL, target->m, &x, &y, 2, 2, 1); unit->warp(target,-1,x,y,3); } break; @@ -3210,7 +3159,7 @@ int skill_timerskill(int tid, unsigned int tick, int id, intptr_t data) { break; case LG_OVERBRAND_BRANDISH: case LG_OVERBRAND_PLUSATK: - if( iStatus->check_skilluse(src, target, skl->skill_id, 1) ) + if( status->check_skilluse(src, target, skl->skill_id, 1) ) skill->attack(BF_WEAPON, src, src, target, skl->skill_id, skl->skill_lv, tick, skl->flag|SD_LEVEL); else clif->skill_damage(src, target, tick, status_get_amotion(src), status_get_dmotion(target), 0, 1, skl->skill_id, skl->skill_lv, skill->get_hit(skl->skill_id)); @@ -3219,8 +3168,8 @@ int skill_timerskill(int tid, unsigned int tick, int id, intptr_t data) { skill->attack(BF_WEAPON, src, src, target, skl->skill_id, skl->skill_lv, tick, skl->flag|SD_LEVEL); break; case GN_SPORE_EXPLOSION: - iMap->foreachinrange(skill->area_sub, target, skill->get_splash(skl->skill_id, skl->skill_lv), BL_CHAR, - src, skl->skill_id, skl->skill_lv, 0, skl->flag|1|BCT_ENEMY, skill->castend_damage_id); + map->foreachinrange(skill->area_sub, target, skill->get_splash(skl->skill_id, skl->skill_lv), BL_CHAR, + src, skl->skill_id, skl->skill_lv, 0, skl->flag|1|BCT_ENEMY, skill->castend_damage_id); break; case SR_FLASHCOMBO_ATK_STEP1: case SR_FLASHCOMBO_ATK_STEP2: @@ -3243,15 +3192,16 @@ int skill_timerskill(int tid, unsigned int tick, int id, intptr_t data) { } break; case CH_PALMSTRIKE: - { - struct status_change* tsc = iStatus->get_sc(target); - struct status_change* sc = iStatus->get_sc(src); - if( ( tsc && tsc->option&OPTION_HIDE ) || - ( sc && sc->option&OPTION_HIDE ) ){ - skill->blown(src,target,skill->get_blewcount(skl->skill_id, skl->skill_lv), -1, 0x0 ); - break; - } + { + struct status_change* tsc = status->get_sc(target); + struct status_change* sc = status->get_sc(src); + if( (tsc && tsc->option&OPTION_HIDE) + || (sc && sc->option&OPTION_HIDE) + ) { + skill->blown(src,target,skill->get_blewcount(skl->skill_id, skl->skill_lv), -1, 0x0 ); + break; } + } default: skill->attack(skl->type,src,src,target,skl->skill_id,skl->skill_lv,tick,skl->flag); break; @@ -3271,14 +3221,15 @@ int skill_timerskill(int tid, unsigned int tick, int id, intptr_t data) { else if( path->search_long(NULL, src->m, src->x, src->y, skl->x, skl->y, CELL_CHKWALL) ) skill->unitsetting(src,skl->skill_id,skl->skill_lv,skl->x,skl->y,skl->flag); break; - case GN_CRAZYWEED_ATK: { - int dummy = 1, i = skill->get_unit_range(skl->skill_id,skl->skill_lv); - iMap->foreachinarea(skill->cell_overlap, src->m, skl->x-i, skl->y-i, skl->x+i, skl->y+i, BL_SKILL, skl->skill_id, &dummy, src); - } + case GN_CRAZYWEED_ATK: + { + int dummy = 1, i = skill->get_unit_range(skl->skill_id,skl->skill_lv); + map->foreachinarea(skill->cell_overlap, src->m, skl->x-i, skl->y-i, skl->x+i, skl->y+i, BL_SKILL, skl->skill_id, &dummy, src); + } + // FIXME: there's no 'break' here. If it was intended, please consider adding a comment (issue #160) case WL_EARTHSTRAIN: skill->unitsetting(src,skl->skill_id,skl->skill_lv,skl->x,skl->y,(skl->type<<16)|skl->flag); break; - } } } while (0); @@ -3343,7 +3294,7 @@ int skill_activate_reverbetion( struct block_list *bl, va_list ap) { if( bl->type != BL_SKILL ) return 0; if( su->alive && (sg = su->group) && sg->skill_id == WM_REVERBERATION ) { - iMap->foreachinrange(skill->trap_splash, bl, skill->get_splash(sg->skill_id, sg->skill_lv), sg->bl_flag, bl, timer->gettick()); + map->foreachinrange(skill->trap_splash, bl, skill->get_splash(sg->skill_id, sg->skill_lv), sg->bl_flag, bl, timer->gettick()); su->limit=DIFF_TICK(timer->gettick(),sg->tick); sg->unit_id = UNT_USED_TRAPS; } @@ -3365,8 +3316,7 @@ int skill_reveal_trap (struct block_list *bl, va_list ap) { * * *------------------------------------------*/ -int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint16 skill_id, uint16 skill_lv, unsigned int tick, int flag) -{ +int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint16 skill_id, uint16 skill_lv, unsigned int tick, int flag) { struct map_session_data *sd = NULL; struct status_data *tstatus; struct status_change *sc; @@ -3384,25 +3334,25 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint sd = BL_CAST(BL_PC, src); - if (iStatus->isdead(bl)) + if (status->isdead(bl)) return 1; - if (skill_id && skill->get_type(skill_id) == BF_MAGIC && iStatus->isimmune(bl) == 100) { + if (skill_id && skill->get_type(skill_id) == BF_MAGIC && status->isimmune(bl) == 100) { //GTB makes all targetted magic display miss with a single bolt. - sc_type sct = iStatus->skill2sc(skill_id); + sc_type sct = status->skill2sc(skill_id); if(sct != SC_NONE) status_change_end(bl, sct, INVALID_TIMER); clif->skill_damage(src, bl, tick, status_get_amotion(src), status_get_dmotion(bl), 0, 1, skill_id, skill_lv, skill->get_hit(skill_id)); return 1; } - sc = iStatus->get_sc(src); + sc = status->get_sc(src); if (sc && !sc->count) sc = NULL; //Unneeded - tstatus = iStatus->get_status_data(bl); + tstatus = status->get_status_data(bl); - iMap->freeblock_lock(); + map->freeblock_lock(); switch(skill_id) { case MER_CRASH: @@ -3546,34 +3496,34 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint case 5: flag |= BREAK_NECK; break; } //TODO: is there really no cleaner way to do this? - sc = iStatus->get_sc(bl); + sc = status->get_sc(bl); if (sc) sc->jb_flag = flag; skill->attack(BF_WEAPON,src,src,bl,skill_id,skill_lv,tick,flag); break; case MO_COMBOFINISH: - if (!(flag&1) && sc && sc->data[SC_SOULLINK] && sc->data[SC_SOULLINK]->val2 == SL_MONK) - { //Becomes a splash attack when Soul Linked. - iMap->foreachinrange(skill->area_sub, bl, - skill->get_splash(skill_id, skill_lv),splash_target(src), - src,skill_id,skill_lv,tick, flag|BCT_ENEMY|1, - skill->castend_damage_id); + if (!(flag&1) && sc && sc->data[SC_SOULLINK] && sc->data[SC_SOULLINK]->val2 == SL_MONK) { + //Becomes a splash attack when Soul Linked. + map->foreachinrange(skill->area_sub, bl, + skill->get_splash(skill_id, skill_lv),splash_target(src), + src,skill_id,skill_lv,tick, flag|BCT_ENEMY|1, + skill->castend_damage_id); } else skill->attack(BF_WEAPON,src,src,bl,skill_id,skill_lv,tick,flag); break; case TK_STORMKICK: // Taekwon kicks [Dralnu] clif->skill_nodamage(src,bl,skill_id,skill_lv,1); - skill_area_temp[1] = 0; - iMap->foreachinrange(skill->attack_area, src, - skill->get_splash(skill_id, skill_lv), splash_target(src), - BF_WEAPON, src, src, skill_id, skill_lv, tick, flag, BCT_ENEMY); + skill->area_temp[1] = 0; + map->foreachinrange(skill->attack_area, src, + skill->get_splash(skill_id, skill_lv), splash_target(src), + BF_WEAPON, src, src, skill_id, skill_lv, tick, flag, BCT_ENEMY); break; case KN_CHARGEATK: { bool path_exists = path->search_long(NULL, src->m, src->x, src->y, bl->x, bl->y,CELL_CHKWALL); unsigned int dist = distance_bl(src, bl); - uint8 dir = iMap->calc_dir(bl, src->x, src->y); + uint8 dir = map->calc_dir(bl, src->x, src->y); // teleport to target (if not on WoE grounds) if( !map_flag_gvg2(src->m) && !maplist[src->m].flag.battleground && unit->movepos(src, bl->x, bl->y, 0, 1) ) @@ -3599,10 +3549,10 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint case LG_CANNONSPEAR: //It won't shoot through walls since on castend there has to be a direct //line of sight between caster and target. - skill_area_temp[1] = bl->id; - iMap->foreachinpath (skill->attack_area,src->m,src->x,src->y,bl->x,bl->y, - skill->get_splash(skill_id, skill_lv),skill->get_maxcount(skill_id,skill_lv), splash_target(src), - skill->get_type(skill_id),src,src,skill_id,skill_lv,tick,flag,BCT_ENEMY); + skill->area_temp[1] = bl->id; + map->foreachinpath(skill->attack_area,src->m,src->x,src->y,bl->x,bl->y, + skill->get_splash(skill_id, skill_lv),skill->get_maxcount(skill_id,skill_lv), splash_target(src), + skill->get_type(skill_id),src,src,skill_id,skill_lv,tick,flag,BCT_ENEMY); break; case NPC_ACIDBREATH: @@ -3610,10 +3560,10 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint case NPC_FIREBREATH: case NPC_ICEBREATH: case NPC_THUNDERBREATH: - skill_area_temp[1] = bl->id; - iMap->foreachinpath(skill->attack_area,src->m,src->x,src->y,bl->x,bl->y, - skill->get_splash(skill_id, skill_lv),skill->get_maxcount(skill_id,skill_lv), splash_target(src), - skill->get_type(skill_id),src,src,skill_id,skill_lv,tick,flag,BCT_ENEMY); + skill->area_temp[1] = bl->id; + map->foreachinpath(skill->attack_area,src->m,src->x,src->y,bl->x,bl->y, + skill->get_splash(skill_id, skill_lv),skill->get_maxcount(skill_id,skill_lv), splash_target(src), + skill->get_type(skill_id),src,src,skill_id,skill_lv,tick,flag,BCT_ENEMY); break; case MO_INVESTIGATE: @@ -3623,8 +3573,8 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint case RG_BACKSTAP: { - uint8 dir = iMap->calc_dir(src, bl->x, bl->y), t_dir = unit->getdir(bl); - if ((!check_distance_bl(src, bl, 0) && !iMap->check_dir(dir, t_dir)) || bl->type == BL_SKILL) { + uint8 dir = map->calc_dir(src, bl->x, bl->y), t_dir = unit->getdir(bl); + if ((!check_distance_bl(src, bl, 0) && !map->check_dir(dir, t_dir)) || bl->type == BL_SKILL) { status_change_end(src, SC_HIDING, INVALID_TIMER); skill->attack(BF_WEAPON, src, src, bl, skill_id, skill_lv, tick, flag); dir = dir < 4 ? dir+4 : dir-4; // change direction [Celest] @@ -3659,28 +3609,25 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint skill->attack(BF_WEAPON,src,src,bl,skill_id,skill_lv,tick,flag); - if( skill_id == MO_EXTREMITYFIST ) - { + if( skill_id == MO_EXTREMITYFIST ) { mbl = src; i = 3; // for Asura(from caster) - iStatus->set_sp(src, 0, 0); + status->set_sp(src, 0, 0); status_change_end(src, SC_EXPLOSIONSPIRITS, INVALID_TIMER); status_change_end(src, SC_BLADESTOP, INVALID_TIMER); - #ifdef RENEWAL +#ifdef RENEWAL sc_start(src,SC_EXTREMITYFIST2,100,skill_lv,skill->get_time(skill_id,skill_lv)); - #endif - }else{ +#endif // RENEWAL + } else { status_change_end(src, SC_NJ_NEN, INVALID_TIMER); status_change_end(src, SC_HIDING, INVALID_TIMER); - iStatus->set_hp(src, - #ifdef RENEWAL - max(status_get_max_hp(src)/100, 1) - #else - 1 - #endif - , 0); +#ifdef RENEWAL + status->set_hp(src, max(status_get_max_hp(src)/100, 1), 0); +#else // not RENEWAL + status->set_hp(src, 1, 0); +#endif // RENEWAL } - dir = iMap->calc_dir(src,bl->x,bl->y); + dir = map->calc_dir(src,bl->x,bl->y); if( dir > 0 && dir < 4) x = -i; else if( dir > 4 ) x = i; else x = 0; @@ -3752,19 +3699,19 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint case KO_BAKURETSU: case GN_ILLUSIONDOPING: if( flag&1 ) {//Recursive invocation - // skill_area_temp[0] holds number of targets in area - // skill_area_temp[1] holds the id of the original target - // skill_area_temp[2] counts how many targets have already been processed - int sflag = skill_area_temp[0] & 0xFFF, heal; + // skill->area_temp[0] holds number of targets in area + // skill->area_temp[1] holds the id of the original target + // skill->area_temp[2] counts how many targets have already been processed + int sflag = skill->area_temp[0] & 0xFFF, heal; if( flag&SD_LEVEL ) sflag |= SD_LEVEL; // -1 will be used in packets instead of the skill level - if( (skill_area_temp[1] != bl->id && !(skill->get_inf2(skill_id)&INF2_NPC_SKILL)) || flag&SD_ANIMATION ) + if( (skill->area_temp[1] != bl->id && !(skill->get_inf2(skill_id)&INF2_NPC_SKILL)) || flag&SD_ANIMATION ) sflag |= SD_ANIMATION; // original target gets no animation (as well as all NPC skills) heal = skill->attack(skill->get_type(skill_id), src, src, bl, skill_id, skill_lv, tick, sflag); if( skill_id == NPC_VAMPIRE_GIFT && heal > 0 ) { clif->skill_nodamage(NULL, src, AL_HEAL, heal, 1); - iStatus->heal(src,heal,0,0); + status->heal(src,heal,0,0); } } else { switch ( skill_id ) { @@ -3786,30 +3733,30 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint break; } - skill_area_temp[0] = 0; - skill_area_temp[1] = bl->id; - skill_area_temp[2] = 0; + skill->area_temp[0] = 0; + skill->area_temp[1] = bl->id; + skill->area_temp[2] = 0; if( skill_id == WL_CRIMSONROCK ) { - skill_area_temp[4] = bl->x; - skill_area_temp[5] = bl->y; + skill->area_temp[4] = bl->x; + skill->area_temp[5] = bl->y; } if( skill_id == WM_REVERBERATION_MELEE || skill_id == WM_REVERBERATION_MAGIC ) - skill_area_temp[1] = 0; + skill->area_temp[1] = 0; // if skill damage should be split among targets, count them //SD_LEVEL -> Forced splash damage for Auto Blitz-Beat -> count targets //special case: Venom Splasher uses a different range for searching than for splashing if( flag&SD_LEVEL || skill->get_nk(skill_id)&NK_SPLASHSPLIT ) - skill_area_temp[0] = iMap->foreachinrange(skill->area_sub, bl, (skill_id == AS_SPLASHER)?1:skill->get_splash(skill_id, skill_lv), BL_CHAR, src, skill_id, skill_lv, tick, BCT_ENEMY, skill->area_sub_count); + skill->area_temp[0] = map->foreachinrange(skill->area_sub, bl, (skill_id == AS_SPLASHER)?1:skill->get_splash(skill_id, skill_lv), BL_CHAR, src, skill_id, skill_lv, tick, BCT_ENEMY, skill->area_sub_count); // recursive invocation of skill->castend_damage_id() with flag|1 - iMap->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), ( skill_id == WM_REVERBERATION_MELEE || skill_id == WM_REVERBERATION_MAGIC )?BL_CHAR:splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY|SD_SPLASH|1, skill->castend_damage_id); + map->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), ( skill_id == WM_REVERBERATION_MELEE || skill_id == WM_REVERBERATION_MAGIC )?BL_CHAR:splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY|SD_SPLASH|1, skill->castend_damage_id); } break; case KN_BRANDISHSPEAR: case ML_BRANDISH: //Coded apart for it needs the flag passed to the damage calculation. - if (skill_area_temp[1] != bl->id) + if (skill->area_temp[1] != bl->id) skill->attack(skill->get_type(skill_id), src, src, bl, skill_id, skill_lv, tick, flag|SD_ANIMATION); else skill->attack(skill->get_type(skill_id), src, src, bl, skill_id, skill_lv, tick, flag); @@ -3818,7 +3765,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint case KN_BOWLINGBASH: case MS_BOWLINGBASH: if(flag&1){ - if(bl->id==skill_area_temp[1]) + if(bl->id==skill->area_temp[1]) break; //two hits for 500% skill->attack(BF_WEAPON,src,src,bl,skill_id,skill_lv,tick,SD_ANIMATION); @@ -3830,13 +3777,13 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint for(i=0;i<c;i++){ if (!skill->blown(src,bl,1,(unit->getdir(src)+4)%8,0x1)) break; //Can't knockback - skill_area_temp[0] = iMap->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), BL_CHAR, src, skill_id, skill_lv, tick, flag|BCT_ENEMY, skill->area_sub_count); - if( skill_area_temp[0] > 1 ) break; // collision + skill->area_temp[0] = map->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), BL_CHAR, src, skill_id, skill_lv, tick, flag|BCT_ENEMY, skill->area_sub_count); + if( skill->area_temp[0] > 1 ) break; // collision } clif->blown(bl); //Update target pos. if (i!=c) { //Splash - skill_area_temp[1] = bl->id; - iMap->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY|1, skill->castend_damage_id); + skill->area_temp[1] = bl->id; + map->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY|1, skill->castend_damage_id); } //Weirdo dual-hit property, two attacks for 500% skill->attack(BF_WEAPON,src,src,bl,skill_id,skill_lv,tick,0); @@ -3846,21 +3793,21 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint case KN_SPEARSTAB: if(flag&1) { - if (bl->id==skill_area_temp[1]) + if (bl->id==skill->area_temp[1]) break; if (skill->attack(BF_WEAPON,src,src,bl,skill_id,skill_lv,tick,SD_ANIMATION)) - skill->blown(src,bl,skill_area_temp[2],-1,0); + skill->blown(src,bl,skill->area_temp[2],-1,0); } else { int x=bl->x,y=bl->y,i,dir; - dir = iMap->calc_dir(bl,src->x,src->y); - skill_area_temp[1] = bl->id; - skill_area_temp[2] = skill->get_blewcount(skill_id,skill_lv); + dir = map->calc_dir(bl,src->x,src->y); + skill->area_temp[1] = bl->id; + skill->area_temp[2] = skill->get_blewcount(skill_id,skill_lv); // all the enemies between the caster and the target are hit, as well as the target if (skill->attack(BF_WEAPON,src,src,bl,skill_id,skill_lv,tick,0)) - skill->blown(src,bl,skill_area_temp[2],-1,0); + skill->blown(src,bl,skill->area_temp[2],-1,0); for (i=0;i<4;i++) { - iMap->foreachincell(skill->area_sub,bl->m,x,y,BL_CHAR, - src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_damage_id); + map->foreachincell(skill->area_sub,bl->m,x,y,BL_CHAR,src,skill_id,skill_lv, + tick,flag|BCT_ENEMY|1,skill->castend_damage_id); x += dirx[dir]; y += diry[dir]; } @@ -3870,12 +3817,12 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint case TK_TURNKICK: case MO_BALKYOUNG: //Active part of the attack. Skill-attack [Skotlex] { - skill_area_temp[1] = bl->id; //NOTE: This is used in skill->castend_nodamage_id to avoid affecting the target. + skill->area_temp[1] = bl->id; //NOTE: This is used in skill->castend_nodamage_id to avoid affecting the target. if (skill->attack(BF_WEAPON,src,src,bl,skill_id,skill_lv,tick,flag)) - iMap->foreachinrange(skill->area_sub,bl, - skill->get_splash(skill_id, skill_lv),BL_CHAR, - src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1, - skill->castend_nodamage_id); + map->foreachinrange(skill->area_sub,bl, + skill->get_splash(skill_id, skill_lv),BL_CHAR, + src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1, + skill->castend_nodamage_id); } break; case CH_PALMSTRIKE: // Palm Strike takes effect 1sec after casting. [Skotlex] @@ -3920,7 +3867,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint case NPC_MAGICALATTACK: skill->attack(BF_MAGIC,src,src,bl,skill_id,skill_lv,tick,flag); - sc_start(src,iStatus->skill2sc(skill_id),100,skill_lv,skill->get_time(skill_id,skill_lv)); + sc_start(src,status->skill2sc(skill_id),100,skill_lv,skill->get_time(skill_id,skill_lv)); break; case HVAN_CAPRICE: //[blackhole89] @@ -3954,11 +3901,11 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint for( y = src->y - range; y <= src->y + range; ++y ) for( x = src->x - range; x <= src->x + range; ++x ) { - if( !iMap->find_skill_unit_oncell(src,x,y,SA_LANDPROTECTOR,NULL,1) ) { - if( src->type != BL_PC || iMap->getcell(src->m,x,y,CELL_CHKWATER) ) // non-players bypass the water requirement + if( !map->find_skill_unit_oncell(src,x,y,SA_LANDPROTECTOR,NULL,1) ) { + if( src->type != BL_PC || map->getcell(src->m,x,y,CELL_CHKWATER) ) // non-players bypass the water requirement count++; // natural water cell - else if( (su = iMap->find_skill_unit_oncell(src,x,y,SA_DELUGE,NULL,1)) != NULL - || (su = iMap->find_skill_unit_oncell(src,x,y,NJ_SUITON,NULL,1)) != NULL ) { + else if( (su = map->find_skill_unit_oncell(src,x,y,SA_DELUGE,NULL,1)) != NULL + || (su = map->find_skill_unit_oncell(src,x,y,NJ_SUITON,NULL,1)) != NULL ) { count++; // skill-induced water cell skill->delunit(su); // consume cell } @@ -3982,7 +3929,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint case SL_STIN: case SL_STUN: if (sd && !battle_config.allow_es_magic_pc && bl->type != BL_MOB) { - iStatus->change_start(src,SC_STUN,10000,skill_lv,0,0,0,500,10); + status->change_start(src,SC_STUN,10000,skill_lv,0,0,0,500,10); clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); break; } @@ -4009,18 +3956,18 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint * Rune Knight **/ case RK_DRAGONBREATH_WATER: - case RK_DRAGONBREATH: { - struct status_change *tsc = NULL; - if( (tsc = iStatus->get_sc(bl)) && (tsc->data[SC_HIDING] )) { - clif->skill_nodamage(src,src,skill_id,skill_lv,1); - } else - skill->attack(BF_MISC,src,src,bl,skill_id,skill_lv,tick,flag); - } + case RK_DRAGONBREATH: + { + struct status_change *tsc = NULL; + if( (tsc = status->get_sc(bl)) && (tsc->data[SC_HIDING] )) { + clif->skill_nodamage(src,src,skill_id,skill_lv,1); + } else + skill->attack(BF_MISC,src,src,bl,skill_id,skill_lv,tick,flag); + } break; - case NPC_SELFDESTRUCTION: { struct status_change *tsc = NULL; - if( (tsc = iStatus->get_sc(bl)) && tsc->data[SC_HIDING] ) + if( (tsc = status->get_sc(bl)) && tsc->data[SC_HIDING] ) break; } case HVAN_EXPLOSION: @@ -4045,14 +3992,14 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint case NPC_BLOODDRAIN: case NPC_ENERGYDRAIN: - { - int heal = skill->attack( (skill_id == NPC_BLOODDRAIN) ? BF_WEAPON : BF_MAGIC, - src, src, bl, skill_id, skill_lv, tick, flag); - if (heal > 0){ - clif->skill_nodamage(NULL, src, AL_HEAL, heal, 1); - iStatus->heal(src, heal, 0, 0); - } + { + int heal = skill->attack( (skill_id == NPC_BLOODDRAIN) ? BF_WEAPON : BF_MAGIC, + src, src, bl, skill_id, skill_lv, tick, flag); + if (heal > 0){ + clif->skill_nodamage(NULL, src, AL_HEAL, heal, 1); + status->heal(src, heal, 0, 0); } + } break; case GS_BULLSEYE: @@ -4067,7 +4014,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint 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); + map->search_freecell(bl, 0, &x, &y, 1, 1, 0); if (unit->movepos(src, x, y, 0, 0)) clif->slide(src,src->x,src->y); } @@ -4075,7 +4022,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint skill->attack(BF_WEAPON,src,src,bl,skill_id,skill_lv,tick,flag); break; case RK_PHANTOMTHRUST: - unit->setdir(src,iMap->calc_dir(src, bl->x, bl->y)); + unit->setdir(src,map->calc_dir(src, bl->x, bl->y)); clif->skill_nodamage(src,bl,skill_id,skill_lv,1); skill->blown(src,bl,distance_bl(src,bl)-1,unit->getdir(src),0); @@ -4086,7 +4033,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint case GC_DARKILLUSION: { short x, y; - short dir = iMap->calc_dir(src,bl->x,bl->y); + short dir = map->calc_dir(src,bl->x,bl->y); if( dir > 0 && dir < 4) x = 2; else if( dir > 4 ) x = -2; @@ -4124,9 +4071,9 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint break; case GC_PHANTOMMENACE: - if( flag&1 ) - { // Only Hits Invisible Targets - struct status_change *tsc = iStatus->get_sc(bl); + if( flag&1 ) { + // Only Hits Invisible Targets + struct status_change *tsc = status->get_sc(bl); if(tsc && (tsc->option&(OPTION_HIDE|OPTION_CLOAK|OPTION_CHASEWALK) || tsc->data[SC__INVISIBILITY]) ) skill->attack(BF_WEAPON,src,src,bl,skill_id,skill_lv,tick,flag); } @@ -4136,21 +4083,20 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint skill->addtimerskill(src,tick+status_get_amotion(src),bl->id,0,0,WL_CHAINLIGHTNING_ATK,skill_lv,0,flag); break; case WL_DRAINLIFE: - { - int heal = skill->attack(skill->get_type(skill_id), src, src, bl, skill_id, skill_lv, tick, flag); - int rate = 70 + 5 * skill_lv; + { + int heal = skill->attack(skill->get_type(skill_id), src, src, bl, skill_id, skill_lv, tick, flag); + int rate = 70 + 5 * skill_lv; - heal = heal * (5 + 5 * skill_lv) / 100; + heal = heal * (5 + 5 * skill_lv) / 100; - if( bl->type == BL_SKILL || status_get_hp(src) == status_get_max_hp(src)) // Don't absorb when caster was in full HP - heal = 0; // Don't absorb heal from Ice Walls or other skill units. + if( bl->type == BL_SKILL || status_get_hp(src) == status_get_max_hp(src)) // Don't absorb when caster was in full HP + heal = 0; // Don't absorb heal from Ice Walls or other skill units. - if( heal && rnd()%100 < rate ) - { - iStatus->heal(src, heal, 0, 0); - clif->skill_nodamage(NULL, src, AL_HEAL, heal, 1); - } + if( heal && rnd()%100 < rate ) { + status->heal(src, heal, 0, 0); + clif->skill_nodamage(NULL, src, AL_HEAL, heal, 1); } + } break; case WL_TETRAVORTEX: @@ -4263,7 +4209,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint if( sd && pc_isridingwug(sd) ){ short x[8]={0,-1,-1,-1,0,1,1,1}; short y[8]={1,1,0,-1,-1,-1,0,1}; - uint8 dir = iMap->calc_dir(bl, src->x, src->y); + uint8 dir = map->calc_dir(bl, src->x, src->y); if( unit->movepos(src, bl->x+x[dir], bl->y+y[dir], 1, 1) ) { @@ -4283,44 +4229,38 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint case RA_SENSITIVEKEEN: if( bl->type != BL_SKILL ) { // Only Hits Invisible Targets - struct status_change * tsc = iStatus->get_sc(bl); + struct status_change * tsc = status->get_sc(bl); if( tsc && tsc->option&(OPTION_HIDE|OPTION_CLOAK) ){ skill->attack(BF_WEAPON,src,src,bl,skill_id,skill_lv,tick,flag); status_change_end(bl, SC_CLOAKINGEXCEED, INVALID_TIMER); } - } - else - { + } else { struct skill_unit *su = BL_CAST(BL_SKILL,bl); struct skill_unit_group* sg; - if( su && (sg=su->group) && skill->get_inf2(sg->skill_id)&INF2_TRAP ) - { - if( !(sg->unit_id == UNT_USED_TRAPS || (sg->unit_id == UNT_ANKLESNARE && sg->val2 != 0 )) ) - { + if( su && (sg=su->group) && skill->get_inf2(sg->skill_id)&INF2_TRAP ) { + if( !(sg->unit_id == UNT_USED_TRAPS || (sg->unit_id == UNT_ANKLESNARE && sg->val2 != 0 )) ) { struct item item_tmp; memset(&item_tmp,0,sizeof(item_tmp)); item_tmp.nameid = sg->item_id?sg->item_id:ITEMID_TRAP; item_tmp.identify = 1; if( item_tmp.nameid ) - iMap->addflooritem(&item_tmp,1,bl->m,bl->x,bl->y,0,0,0,0); + map->addflooritem(&item_tmp,1,bl->m,bl->x,bl->y,0,0,0,0); } skill->delunit(su); } } break; case NC_INFRAREDSCAN: - if( flag&1 ) - { //TODO: Need a confirmation if the other type of hidden status is included to be scanned. [Jobbie] + if( flag&1 ) { + //TODO: Need a confirmation if the other type of hidden status is included to be scanned. [Jobbie] if( rnd()%100 < 50 ) sc_start(bl, SC_INFRAREDSCAN, 10000, skill_lv, skill->get_time(skill_id, skill_lv)); status_change_end(bl, SC_HIDING, INVALID_TIMER); status_change_end(bl, SC_CLOAKING, INVALID_TIMER); status_change_end(bl, SC_CLOAKINGEXCEED, INVALID_TIMER); // Need confirm it. - } - else - { - iMap->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY|SD_SPLASH|1, skill->castend_damage_id); + } else { + map->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY|SD_SPLASH|1, skill->castend_damage_id); clif->skill_damage(src,src,tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6); if( sd ) pc->overheat(sd,1); } @@ -4332,14 +4272,13 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint case SC_FATALMENACE: if( flag&1 ) skill->attack(BF_WEAPON,src,src,bl,skill_id,skill_lv,tick,flag); - else - { + else { short x, y; - iMap->search_freecell(src, 0, &x, &y, -1, -1, 0); + map->search_freecell(src, 0, &x, &y, -1, -1, 0); // Destination area - skill_area_temp[4] = x; - skill_area_temp[5] = y; - iMap->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY|1, skill->castend_damage_id); + skill->area_temp[4] = x; + skill->area_temp[5] = y; + map->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY|1, skill->castend_damage_id); skill->addtimerskill(src,tick + 800,src->id,x,y,skill_id,skill_lv,0,flag); // To teleport Self clif->skill_damage(src,src,tick,status_get_amotion(src),0,-30000,1,skill_id,skill_lv,6); } @@ -4356,10 +4295,10 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint break; case LG_OVERBRAND: - if( iStatus->check_skilluse(src, bl, skill_id, 1) ) - skill->attack(BF_WEAPON, src, src, bl, skill_id, skill_lv, tick, flag|SD_LEVEL); - else - clif->skill_damage(src, bl, tick, status_get_amotion(src), status_get_dmotion(bl), 0, 1, skill_id, skill_lv, skill->get_hit(skill_id)); + if( status->check_skilluse(src, bl, skill_id, 1) ) + skill->attack(BF_WEAPON, src, src, bl, skill_id, skill_lv, tick, flag|SD_LEVEL); + else + clif->skill_damage(src, bl, tick, status_get_amotion(src), status_get_dmotion(bl), 0, 1, skill_id, skill_lv, skill->get_hit(skill_id)); break; case LG_OVERBRAND_BRANDISH: @@ -4404,20 +4343,20 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint status_change_end(bl, SC_HIDING, INVALID_TIMER); status_change_end(bl, SC_CLOAKINGEXCEED, INVALID_TIMER); } else{ - iMap->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY|SD_SPLASH|1, skill->castend_damage_id); + map->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY|SD_SPLASH|1, skill->castend_damage_id); clif->skill_damage(src, src, tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6); - } + } break; - case SO_POISON_BUSTER: { - struct status_change *tsc = iStatus->get_sc(bl); - if( tsc && tsc->data[SC_POISON] ) { - skill->attack(skill->get_type(skill_id), src, src, bl, skill_id, skill_lv, tick, flag); - status_change_end(bl, SC_POISON, INVALID_TIMER); - } - else if( sd ) - clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0); - } + case SO_POISON_BUSTER: + { + struct status_change *tsc = status->get_sc(bl); + if( tsc && tsc->data[SC_POISON] ) { + skill->attack(skill->get_type(skill_id), src, src, bl, skill_id, skill_lv, tick, flag); + status_change_end(bl, SC_POISON, INVALID_TIMER); + } else if( sd ) + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0); + } break; case GN_SPORE_EXPLOSION: @@ -4441,7 +4380,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint clif->skill_nodamage(src,battle->get_master(src),skill_id,skill_lv,1); clif->skill_damage(src, bl, tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6); if( rnd()%100 < 30 ) - iMap->foreachinrange(skill->area_sub,bl,i,BL_CHAR,src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_damage_id); + map->foreachinrange(skill->area_sub,bl,i,BL_CHAR,src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_damage_id); else skill->attack(skill->get_type(skill_id),src,src,bl,skill_id,skill_lv,tick,flag); } @@ -4464,7 +4403,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint clif->skill_nodamage(src,battle->get_master(src),skill_id,skill_lv,1); clif->skill_damage(src, src, tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6); if( rnd()%100 < 30 ) - iMap->foreachinrange(skill->area_sub,bl,i,BL_CHAR,src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_damage_id); + map->foreachinrange(skill->area_sub,bl,i,BL_CHAR,src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_damage_id); else skill->attack(skill->get_type(skill_id),src,src,bl,skill_id,skill_lv,tick,flag); } @@ -4482,9 +4421,9 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint case EL_TIDAL_WEAPON: if( src->type == BL_ELEM ) { struct elemental_data *ele = BL_CAST(BL_ELEM,src); - struct status_change *sc = iStatus->get_sc(&ele->bl); - struct status_change *tsc = iStatus->get_sc(bl); - sc_type type = iStatus->skill2sc(skill_id), type2; + struct status_change *sc = status->get_sc(&ele->bl); + struct status_change *tsc = status->get_sc(bl); + sc_type type = status->skill2sc(skill_id), type2; type2 = type-1; clif->skill_nodamage(src,battle->get_master(src),skill_id,skill_lv,1); @@ -4509,7 +4448,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint if(flag & 1) skill->attack(skill->get_type(skill_id), src, src, bl, skill_id, skill_lv, tick, flag); else { - iMap->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), splash_target(src), src, skill_id, skill_lv, tick, flag | BCT_ENEMY | SD_SPLASH | 1, skill->castend_damage_id); + map->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), splash_target(src), src, skill_id, skill_lv, tick, flag | BCT_ENEMY | SD_SPLASH | 1, skill->castend_damage_id); } break; @@ -4533,14 +4472,14 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint case 0:/* no skill - basic/normal attack */ if(sd) { if (flag & 3){ - if (bl->id != skill_area_temp[1]) + if (bl->id != skill->area_temp[1]) skill->attack(BF_WEAPON, src, src, bl, skill_id, skill_lv, tick, SD_LEVEL|flag); } else { - skill_area_temp[1] = bl->id; - iMap->foreachinrange(skill->area_sub, bl, - sd->bonus.splash_range, BL_CHAR, - src, skill_id, skill_lv, tick, flag | BCT_ENEMY | 1, - skill->castend_damage_id); + skill->area_temp[1] = bl->id; + map->foreachinrange(skill->area_sub, bl, + sd->bonus.splash_range, BL_CHAR, + src, skill_id, skill_lv, tick, flag | BCT_ENEMY | 1, + skill->castend_damage_id); flag|=1; //Set flag to 1 so ammo is not double-consumed. [Skotlex] } } @@ -4551,14 +4490,14 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint clif->skill_damage(src, bl, tick, status_get_amotion(src), tstatus->dmotion, 0, abs(skill->get_num(skill_id, skill_lv)), skill_id, skill_lv, skill->get_hit(skill_id)); - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 1; } if( sc && sc->data[SC_CURSEDCIRCLE_ATKER] ) //Should only remove after the skill has been casted. status_change_end(src,SC_CURSEDCIRCLE_ATKER,INVALID_TIMER); - iMap->freeblock_unlock(); + map->freeblock_unlock(); if( sd && !(flag&1) ) {// ensure that the skill last-cast tick is recorded @@ -4588,7 +4527,7 @@ int skill_castend_id(int tid, unsigned int tick, int id, intptr_t data) struct status_change *sc = NULL; int inf,inf2,flag = 0; - src = iMap->id2bl(id); + src = map->id2bl(id); if( src == NULL ) { ShowDebug("skill_castend_id: src == NULL (tid=%d, id=%d)\n", tid, id); @@ -4629,13 +4568,13 @@ int skill_castend_id(int tid, unsigned int tick, int id, intptr_t data) if (ud->skilltarget == id) target = src; else - target = iMap->id2bl(ud->skilltarget); + target = map->id2bl(ud->skilltarget); // Use a do so that you can break out of it when the skill fails. do { if(!target || target->prev==NULL) break; - if(src->m != target->m || iStatus->isdead(src)) break; + if(src->m != target->m || status->isdead(src)) break; switch (ud->skill_id) { //These should become skill_castend_pos @@ -4649,7 +4588,7 @@ int skill_castend_id(int tid, unsigned int tick, int id, intptr_t data) inf2 = skill->get_splash(ud->skill_id, ud->skill_lv); ud->skillx = target->x + inf2; ud->skilly = target->y + inf2; - if (inf2 && !iMap->random_dir(target, &ud->skillx, &ud->skilly)) { + if (inf2 && !map->random_dir(target, &ud->skillx, &ud->skilly)) { ud->skillx = target->x; ud->skilly = target->y; } @@ -4663,14 +4602,14 @@ int skill_castend_id(int tid, unsigned int tick, int id, intptr_t data) } if(ud->skill_id == RG_BACKSTAP) { - uint8 dir = iMap->calc_dir(src,target->x,target->y),t_dir = unit->getdir(target); - if(check_distance_bl(src, target, 0) || iMap->check_dir(dir,t_dir)) { + uint8 dir = map->calc_dir(src,target->x,target->y),t_dir = unit->getdir(target); + if(check_distance_bl(src, target, 0) || map->check_dir(dir,t_dir)) { break; } } if( ud->skill_id == PR_TURNUNDEAD ) { - struct status_data *tstatus = iStatus->get_status_data(target); + struct status_data *tstatus = status->get_status_data(target); if( !battle->check_undead(tstatus->race, tstatus->def_ele) ) break; } @@ -4680,9 +4619,8 @@ int skill_castend_id(int tid, unsigned int tick, int id, intptr_t data) break; } - if( ud->skill_id == PR_LEXDIVINA || ud->skill_id == MER_LEXDIVINA ) - { - sc = iStatus->get_sc(target); + if( ud->skill_id == PR_LEXDIVINA || ud->skill_id == MER_LEXDIVINA ) { + sc = status->get_sc(target); if( battle->check_target(src,target, BCT_ENEMY) <= 0 && (!sc || !sc->data[SC_SILENCE]) ) { //If it's not an enemy, and not silenced, you can't use the skill on them. [Skotlex] clif->skill_nodamage (src, target, ud->skill_id, ud->skill_lv, 0); @@ -4727,16 +4665,18 @@ int skill_castend_id(int tid, unsigned int tick, int id, intptr_t data) break; } - if(inf&BCT_ENEMY && (sc = iStatus->get_sc(target)) && - sc->data[SC_FOGWALL] && - rnd() % 100 < 75) { //Fogwall makes all offensive-type targetted skills fail at 75% - if (sd) clif->skill_fail(sd, ud->skill_id, USESKILL_FAIL_LEVEL, 0); - break; + if( inf&BCT_ENEMY + && (sc = status->get_sc(target)) && sc->data[SC_FOGWALL] + && rnd() % 100 < 75 + ) { + //Fogwall makes all offensive-type targetted skills fail at 75% + if (sd) clif->skill_fail(sd, ud->skill_id, USESKILL_FAIL_LEVEL, 0); + break; } } //Avoid doing double checks for instant-cast skills. - if (tid != INVALID_TIMER && !iStatus->check_skilluse(src, target, ud->skill_id, 1)) + if (tid != INVALID_TIMER && !status->check_skilluse(src, target, ud->skill_id, 1)) break; if(md) { @@ -4803,10 +4743,9 @@ int skill_castend_id(int tid, unsigned int tick, int id, intptr_t data) break; case CR_GRANDCROSS: case NPC_GRANDDARKNESS: - if( (sc = iStatus->get_sc(src)) && sc->data[SC_NOEQUIPSHIELD] ) - { + if( (sc = status->get_sc(src)) && sc->data[SC_NOEQUIPSHIELD] ) { const struct TimerData *td = timer->get(sc->data[SC_NOEQUIPSHIELD]->timer); - if( td && td->func == iStatus->change_timer && DIFF_TICK(td->tick,timer->gettick()+skill->get_time(ud->skill_id, ud->skill_lv)) > 0 ) + if( td && td->func == status->change_timer && DIFF_TICK(td->tick,timer->gettick()+skill->get_time(ud->skill_id, ud->skill_lv)) > 0 ) break; } sc_start2(src, SC_NOEQUIPSHIELD, 100, 0, 1, skill->get_time(ud->skill_id, ud->skill_lv)); @@ -4820,7 +4759,7 @@ int skill_castend_id(int tid, unsigned int tick, int id, intptr_t data) ShowInfo("Type %d, ID %d skill castend id [id =%d, lv=%d, target ID %d]\n", src->type, src->id, ud->skill_id, ud->skill_lv, target->id); - iMap->freeblock_lock(); + map->freeblock_lock(); // SC_MAGICPOWER needs to switch states before any damage is actually dealt skill->toggle_magicpower(src, ud->skill_id); @@ -4832,12 +4771,13 @@ int skill_castend_id(int tid, unsigned int tick, int id, intptr_t data) else skill->castend_damage_id(src,target,ud->skill_id,ud->skill_lv,tick,flag); - sc = iStatus->get_sc(src); + sc = status->get_sc(src); if(sc && sc->count) { - if(sc->data[SC_SOULLINK] && - sc->data[SC_SOULLINK]->val2 == SL_WIZARD && - sc->data[SC_SOULLINK]->val3 == ud->skill_id && - ud->skill_id != WZ_WATERBALL) + if( sc->data[SC_SOULLINK] + && sc->data[SC_SOULLINK]->val2 == SL_WIZARD + && sc->data[SC_SOULLINK]->val3 == ud->skill_id + && ud->skill_id != WZ_WATERBALL + ) sc->data[SC_SOULLINK]->val3 = 0; //Clear bounced spell check. if( sc->data[SC_DANCING] && skill->get_inf2(ud->skill_id)&INF2_SONG_DANCE && sd ) @@ -4852,16 +4792,16 @@ int skill_castend_id(int tid, unsigned int tick, int id, intptr_t data) else ud->skill_id = 0; //mobs can't clear this one as it is used for skill condition 'afterskill' ud->skill_lv = ud->skilltarget = 0; } - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 1; } while(0); //Skill failed. - if (ud->skill_id == MO_EXTREMITYFIST && sd && !(sc && sc->data[SC_FOGWALL])) - { //When Asura fails... (except when it fails from Fog of Wall) + if (ud->skill_id == MO_EXTREMITYFIST && sd && !(sc && sc->data[SC_FOGWALL])) { + //When Asura fails... (except when it fails from Fog of Wall) //Consume SP/spheres skill->consume_requirement(sd,ud->skill_id, ud->skill_lv,1); - iStatus->set_sp(src, 0, 0); + status->set_sp(src, 0, 0); sc = &sd->sc; if (sc->count) { //End states @@ -4871,10 +4811,10 @@ int skill_castend_id(int tid, unsigned int tick, int id, intptr_t data) sc_start(src, SC_EXTREMITYFIST2, 100, ud->skill_lv, skill->get_time(ud->skill_id, ud->skill_lv)); #endif } - if (target && target->m == src->m) - { //Move character to target anyway. + if (target && target->m == src->m) { + //Move character to target anyway. int dir, x, y; - dir = iMap->calc_dir(src,target->x,target->y); + dir = map->calc_dir(src,target->x,target->y); if( dir > 0 && dir < 4) x = -2; else if( dir > 4 ) x = 2; else x = 0; @@ -4937,10 +4877,10 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui if(bl->prev == NULL) return 1; - if(iStatus->isdead(src)) + if(status->isdead(src)) return 1; - if( src != bl && iStatus->isdead(bl) ) { + if( src != bl && status->isdead(bl) ) { /** * Skills that may be cast on dead targets **/ @@ -4955,8 +4895,8 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui } } - tstatus = iStatus->get_status_data(bl); - sstatus = iStatus->get_status_data(src); + tstatus = status->get_status_data(bl); + sstatus = status->get_status_data(src); //Check for undead skills that convert a no-damage skill into a damage one. [Skotlex] switch (skill_id) { @@ -5013,9 +4953,9 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case RK_FIGHTINGSPIRIT: case RK_ABUNDANCE: if( sd && !pc->checkskill(sd, RK_RUNEMASTERY) ){ - if( iStatus->change_start(&sd->bl, (sc_type)(rnd()%SC_CONFUSION), 1000, 1, 0, 0, 0, skill->get_time2(skill_id,skill_lv),8) ){ + if( status->change_start(&sd->bl, (sc_type)(rnd()%SC_CONFUSION), 1000, 1, 0, 0, 0, skill->get_time2(skill_id,skill_lv),8) ){ skill->consume_requirement(sd,skill_id,skill_lv,2); - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 0; } } @@ -5026,8 +4966,8 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui return skill->castend_pos2(src,bl->x,bl->y,skill_id,skill_lv,tick,0); } - type = iStatus->skill2sc(skill_id); - tsc = iStatus->get_sc(bl); + type = status->skill2sc(skill_id); + tsc = status->get_sc(bl); tsce = (tsc && type != -1)?tsc->data[type]:NULL; if (src!=bl && type > -1 && @@ -5036,7 +4976,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui battle->attr_fix(NULL, NULL, 100, i, tstatus->def_ele, tstatus->ele_lv) <= 0) return 1; //Skills that cause an status should be blocked if the target element blocks its element. - iMap->freeblock_lock(); + map->freeblock_lock(); switch(skill_id) { case HLIF_HEAL: //[orn] case AL_HEAL: @@ -5051,7 +4991,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui if( skill_id == AB_HIGHNESSHEAL ) { heal = heal * ( 15 + 5 * skill_lv ) / 10; } - if( iStatus->isimmune(bl) || + if( status->isimmune(bl) || (dstmd && (dstmd->class_ == MOBID_EMPERIUM || mob_is_battleground(dstmd))) ) heal=0; @@ -5077,7 +5017,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui clif->skill_nodamage (src, bl, skill_id, heal, 1); if( tsc && tsc->data[SC_AKAITSUKI] && heal && skill_id != HLIF_HEAL ) heal = ~heal + 1; - heal_get_jobexp = iStatus->heal(bl,heal,0,0); + heal_get_jobexp = status->heal(bl,heal,0,0); if(sd && dstsd && heal > 0 && sd != dstsd && battle_config.heal_exp > 0){ heal_get_jobexp = heal_get_jobexp * battle_config.heal_exp / 100; @@ -5094,27 +5034,27 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); break; } - skill_area_temp[0] = 0; + skill->area_temp[0] = 0; party_foreachsamemap(skill->area_sub, sd,skill->get_splash(skill_id, skill_lv), src,skill_id,skill_lv,tick, flag|BCT_PARTY|1, skill->castend_nodamage_id); - if (skill_area_temp[0] == 0) { + if (skill->area_temp[0] == 0) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); break; } - skill_area_temp[0] = 5 - skill_area_temp[0]; // The actual 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); + skill->area_temp[0] = 5 - skill->area_temp[0]; // The actual 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); clif->updatestatus(sd,SP_JOBEXP); } - iStatus->set_hp(src, 1, 0); - iStatus->set_sp(src, 0, 0); + status->set_hp(src, 1, 0); + status->set_sp(src, 0, 0); break; - } else if (iStatus->isdead(bl) && flag&1) { //Revive - skill_area_temp[0]++; //Count it in, then fall-through to the Resurrection code. + } else if (status->isdead(bl) && flag&1) { //Revive + skill->area_temp[0]++; //Count it in, then fall-through to the Resurrection code. skill_lv = 3; //Resurrection level 3 is used } else //Invalid target, skip resurrection. break; @@ -5125,7 +5065,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); break; } - if (!iStatus->isdead(bl)) + if (!status->isdead(bl)) break; { int per = 0, sper = 0; @@ -5143,7 +5083,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui } if(dstsd && dstsd->special_state.restart_full_recover) per = sper = 100; - if (iStatus->revive(bl, per, sper)) + if (status->revive(bl, per, sper)) { clif->skill_nodamage(src,bl,ALL_RESURRECTION,skill_lv,1); //Both Redemptio and Res show this skill-animation. if(sd && dstsd && battle_config.resurrection_exp > 0) @@ -5168,15 +5108,15 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case AL_DECAGI: case MER_DECAGI: clif->skill_nodamage (src, bl, skill_id, skill_lv, - sc_start(bl, type, (40 + skill_lv * 2 + (iStatus->get_lv(src) + sstatus->int_)/5), skill_lv, skill->get_time(skill_id,skill_lv))); + sc_start(bl, type, (40 + skill_lv * 2 + (status->get_lv(src) + sstatus->int_)/5), skill_lv, skill->get_time(skill_id,skill_lv))); break; case AL_CRUCIS: if (flag&1) - sc_start(bl,type, 23+skill_lv*4 +iStatus->get_lv(src) -iStatus->get_lv(bl), skill_lv,skill->get_time(skill_id,skill_lv)); + sc_start(bl,type, 23+skill_lv*4 +status->get_lv(src) -status->get_lv(bl), skill_lv,skill->get_time(skill_id,skill_lv)); else { - iMap->foreachinrange(skill->area_sub, src, skill->get_splash(skill_id, skill_lv), BL_CHAR, - src, skill_id, skill_lv, tick, flag|BCT_ENEMY|1, skill->castend_nodamage_id); + map->foreachinrange(skill->area_sub, src, skill->get_splash(skill_id, skill_lv), BL_CHAR, + src, skill_id, skill_lv, tick, flag|BCT_ENEMY|1, skill->castend_nodamage_id); clif->skill_nodamage(src, bl, skill_id, skill_lv, 1); } break; @@ -5195,10 +5135,10 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui int abra_skill_id = 0, abra_skill_lv; do { i = rnd() % MAX_SKILL_ABRA_DB; - abra_skill_id = skill_abra_db[i].skill_id; + abra_skill_id = skill->abra_db[i].skill_id; } while (abra_skill_id == 0 || - skill_abra_db[i].req_lv > skill_lv || //Required lv for it to appear - rnd()%10000 >= skill_abra_db[i].per + skill->abra_db[i].req_lv > skill_lv || //Required lv for it to appear + rnd()%10000 >= skill->abra_db[i].per ); abra_skill_lv = min(skill_lv, skill->get_max(abra_skill_id)); clif->skill_nodamage (src, bl, skill_id, skill_lv, 1); @@ -5231,7 +5171,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui if (!target_id) break; if (skill->get_casttype(abra_skill_id) == CAST_GROUND) { - bl = iMap->id2bl(target_id); + bl = map->id2bl(target_id); if (!bl) bl = src; unit->skilluse_pos(src, bl->x, bl->y, abra_skill_id, abra_skill_lv); } else @@ -5247,23 +5187,23 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui break; case SA_FULLRECOVERY: clif->skill_nodamage(src,bl,skill_id,skill_lv,1); - if (iStatus->isimmune(bl)) + if (status->isimmune(bl)) break; status_percent_heal(bl, 100, 100); break; case NPC_ALLHEAL: - { - int heal; - if( iStatus->isimmune(bl) ) - break; - heal = status_percent_heal(bl, 100, 0); - clif->skill_nodamage(NULL, bl, AL_HEAL, heal, 1); - if( dstmd ) - { // Reset Damage Logs - memset(dstmd->dmglog, 0, sizeof(dstmd->dmglog)); - dstmd->tdmg = 0; - } + { + int heal; + if( status->isimmune(bl) ) + break; + heal = status_percent_heal(bl, 100, 0); + clif->skill_nodamage(NULL, bl, AL_HEAL, heal, 1); + if( dstmd ) { + // Reset Damage Logs + memset(dstmd->dmglog, 0, sizeof(dstmd->dmglog)); + dstmd->tdmg = 0; } + } break; case SA_SUMMONMONSTER: clif->skill_nodamage(src,bl,skill_id,skill_lv,1); @@ -5275,7 +5215,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui break; case SA_INSTANTDEATH: clif->skill_nodamage(src,bl,skill_id,skill_lv,1); - iStatus->set_hp(bl,1,0); + status->set_hp(bl,1,0); break; case SA_QUESTION: case SA_GRAVITY: @@ -5320,7 +5260,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui break; case SA_FORTUNE: clif->skill_nodamage(src,bl,skill_id,skill_lv,1); - if(sd) pc->getzeny(sd,iStatus->get_lv(bl)*100,LOG_TYPE_STEAL,NULL); + if(sd) pc->getzeny(sd,status->get_lv(bl)*100,LOG_TYPE_STEAL,NULL); break; case SA_TAMINGMONSTER: clif->skill_nodamage(src,bl,skill_id,skill_lv,1); @@ -5335,7 +5275,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui if(sd && dstsd){ //Check they are not another crusader [Skotlex] if ((dstsd->class_&MAPID_UPPERMASK) == MAPID_CRUSADER) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 1; } } @@ -5345,36 +5285,29 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case CG_MARIONETTE: { - struct status_change* sc = iStatus->get_sc(src); + struct status_change* sc = status->get_sc(src); - if( sd && dstsd && (dstsd->class_&MAPID_UPPERMASK) == MAPID_BARDDANCER && dstsd->status.sex == sd->status.sex ) - {// Cannot cast on another bard/dancer-type class of the same gender as caster + if( sd && dstsd && (dstsd->class_&MAPID_UPPERMASK) == MAPID_BARDDANCER && dstsd->status.sex == sd->status.sex ) { + // Cannot cast on another bard/dancer-type class of the same gender as caster clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 1; } - if( sc && tsc ) - { - if( !sc->data[SC_MARIONETTE_MASTER] && !tsc->data[SC_MARIONETTE] ) - { + if( sc && tsc ) { + if( !sc->data[SC_MARIONETTE_MASTER] && !tsc->data[SC_MARIONETTE] ) { sc_start(src,SC_MARIONETTE_MASTER,100,bl->id,skill->get_time(skill_id,skill_lv)); sc_start(bl,SC_MARIONETTE,100,src->id,skill->get_time(skill_id,skill_lv)); clif->skill_nodamage(src,bl,skill_id,skill_lv,1); - } - else - if( sc->data[SC_MARIONETTE_MASTER ] && sc->data[SC_MARIONETTE_MASTER ]->val1 == bl->id && - tsc->data[SC_MARIONETTE] && tsc->data[SC_MARIONETTE]->val1 == src->id ) - { + } else if( sc->data[SC_MARIONETTE_MASTER ] && sc->data[SC_MARIONETTE_MASTER ]->val1 == bl->id + && tsc->data[SC_MARIONETTE] && tsc->data[SC_MARIONETTE]->val1 == src->id + ) { status_change_end(src, SC_MARIONETTE_MASTER, INVALID_TIMER); status_change_end(bl, SC_MARIONETTE, INVALID_TIMER); - } - else - { + } else { if( sd ) clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); - - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 1; } } @@ -5456,9 +5389,9 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui //Passive Magnum, should had been casted on yourself. case SM_MAGNUM: case MS_MAGNUM: - skill_area_temp[1] = 0; - iMap->foreachinrange(skill->area_sub, src, skill->get_splash(skill_id, skill_lv), BL_SKILL|BL_CHAR, - src,skill_id,skill_lv,tick, flag|BCT_ENEMY|1, skill->castend_damage_id); + skill->area_temp[1] = 0; + map->foreachinrange(skill->area_sub, src, skill->get_splash(skill_id, skill_lv), BL_SKILL|BL_CHAR, + src,skill_id,skill_lv,tick, flag|BCT_ENEMY|1, skill->castend_damage_id); clif->skill_nodamage (src,src,skill_id,skill_lv,1); // Initiate 10% of your damage becomes fire element. sc_start4(src,SC_SUB_WEAPONPROPERTY,100,3,20,0,0,skill->get_time2(skill_id, skill_lv)); @@ -5615,20 +5548,19 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui sc_start(bl,type,100,skill_lv,skill->get_time(skill_id,skill_lv))); status_change_end(bl, SC_NJ_NEN, INVALID_TIMER); break; - /* Was modified to only affect targetted char. [Skotlex] +#if 0 /* Was modified to only affect targetted char. [Skotlex] */ case HP_ASSUMPTIO: if (flag&1) sc_start(bl,type,100,skill_lv,skill->get_time(skill_id,skill_lv)); - else - { - iMap->foreachinrange(skill->area_sub, bl, - skill->get_splash(skill_id, skill_lv), BL_PC, - src, skill_id, skill_lv, tick, flag|BCT_ALL|1, - skill->castend_nodamage_id); + else { + map->foreachinrange(skill->area_sub, bl, + skill->get_splash(skill_id, skill_lv), BL_PC, + src, skill_id, skill_lv, tick, flag|BCT_ALL|1, + skill->castend_nodamage_id); clif->skill_nodamage(src,bl,skill_id,skill_lv,1); } break; - */ +#endif // 0 case SM_ENDURE: clif->skill_nodamage(src,bl,skill_id,skill_lv, sc_start(bl,type,100,skill_lv,skill->get_time(skill_id,skill_lv))); @@ -5694,31 +5626,29 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui break; case AC_CONCENTRATION: - { - clif->skill_nodamage(src,bl,skill_id,skill_lv, - sc_start(bl,type,100,skill_lv,skill->get_time(skill_id,skill_lv))); - iMap->foreachinrange( iStatus->change_timer_sub, src, - skill->get_splash(skill_id, skill_lv), BL_CHAR, - src,NULL,type,tick); - } + { + clif->skill_nodamage(src,bl,skill_id,skill_lv, + sc_start(bl,type,100,skill_lv,skill->get_time(skill_id,skill_lv))); + map->foreachinrange(status->change_timer_sub, src, + skill->get_splash(skill_id, skill_lv), BL_CHAR, + src,NULL,type,tick); + } break; case SM_PROVOKE: case SM_SELFPROVOKE: case MER_PROVOKE: - if( (tstatus->mode&MD_BOSS) || battle->check_undead(tstatus->race,tstatus->def_ele) ) - { - iMap->freeblock_unlock(); + if( (tstatus->mode&MD_BOSS) || battle->check_undead(tstatus->race,tstatus->def_ele) ) { + map->freeblock_unlock(); return 1; } //TODO: How much does base level affects? Dummy value of 1% per level difference used. [Skotlex] clif->skill_nodamage(src,bl,skill_id == SM_SELFPROVOKE ? SM_PROVOKE : skill_id,skill_lv, - (i = sc_start(bl,type, skill_id == SM_SELFPROVOKE ? 100:( 50 + 3*skill_lv + iStatus->get_lv(src) - iStatus->get_lv(bl)), skill_lv, skill->get_time(skill_id,skill_lv)))); - if( !i ) - { + (i = sc_start(bl,type, skill_id == SM_SELFPROVOKE ? 100:( 50 + 3*skill_lv + status->get_lv(src) - status->get_lv(bl)), skill_lv, skill->get_time(skill_id,skill_lv)))); + if( !i ) { if( sd ) clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 0; } unit->skillcastcancel(bl, 2); @@ -5750,7 +5680,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui break; } - if( (lv = iStatus->get_lv(src) - dstsd->status.base_level) < 0 ) + if( (lv = status->get_lv(src) - dstsd->status.base_level) < 0 ) lv = -lv; if( lv > battle_config.devotion_level_difference || // Level difference requeriments (dstsd->sc.data[type] && dstsd->sc.data[type]->val1 != src->id) || // Cannot Devote a player devoted from another source @@ -5760,7 +5690,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui { if( sd ) clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 1; } @@ -5772,10 +5702,10 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui if( i == count ) { ARR_FIND(0, count, i, sd->devotion[i] == 0 ); - if( i == count ) - { // No free slots, skill Fail + if( i == count ) { + // No free slots, skill Fail clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0); - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 1; } } @@ -5820,7 +5750,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case TK_TURNKICK: case MO_BALKYOUNG: //Passive part of the attack. Splash knock-back+stun. [Skotlex] - if (skill_area_temp[1] != bl->id) { + if (skill->area_temp[1] != bl->id) { skill->blown(src,bl,skill->get_blewcount(skill_id,skill_lv),-1,0); skill->additional_effect(src,bl,skill_id,skill_lv,BF_MISC,ATK_DEF,tick); //Use Misc rather than weapon to signal passive pushback } @@ -5837,7 +5767,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui i = 2 * dstmd->level; mob->target(dstmd,src,0); } - if (i) iStatus->heal(src, 0, i, 3); + if (i) status->heal(src, 0, i, 3); clif->skill_nodamage(src,bl,skill_id,skill_lv,i?1:0); break; @@ -5867,12 +5797,12 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui sc_start(bl,SC_STUN,(20 + 10 * skill_lv),skill_lv,skill->get_time2(skill_id,skill_lv))); break; case RG_RAID: - skill_area_temp[1] = 0; + skill->area_temp[1] = 0; clif->skill_nodamage(src,bl,skill_id,skill_lv,1); - iMap->foreachinrange(skill->area_sub, bl, - skill->get_splash(skill_id, skill_lv), splash_target(src), - src,skill_id,skill_lv,tick, flag|BCT_ENEMY|1, - skill->castend_damage_id); + map->foreachinrange(skill->area_sub, bl, + skill->get_splash(skill_id, skill_lv), splash_target(src), + src,skill_id,skill_lv,tick, flag|BCT_ENEMY|1, + skill->castend_damage_id); status_change_end(src, SC_HIDING, INVALID_TIMER); break; @@ -5885,10 +5815,10 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case SR_RAMPAGEBLASTER: case SR_HOWLINGOFLION: case KO_HAPPOKUNAI: - skill_area_temp[1] = 0; + skill->area_temp[1] = 0; clif->skill_nodamage(src,bl,skill_id,skill_lv,1); - i = iMap->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), splash_target(src), - src, skill_id, skill_lv, tick, flag|BCT_ENEMY|SD_SPLASH|1, skill->castend_damage_id); + i = map->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), splash_target(src), + src, skill_id, skill_lv, tick, flag|BCT_ENEMY|SD_SPLASH|1, skill->castend_damage_id); if( !i && ( skill_id == NC_AXETORNADO || skill_id == SR_SKYNETBLOW || skill_id == KO_HAPPOKUNAI ) ) clif->skill_damage(src,src,tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6); break; @@ -5920,20 +5850,20 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui //Passive side of the attack. status_change_end(src, SC_SIGHT, INVALID_TIMER); clif->skill_nodamage(src,bl,skill_id,skill_lv,1); - iMap->foreachinrange(skill->area_sub,src, - skill->get_splash(skill_id, skill_lv),BL_CHAR|BL_SKILL, - src,skill_id,skill_lv,tick, flag|BCT_ENEMY|1, - skill->castend_damage_id); + map->foreachinrange(skill->area_sub,src, + skill->get_splash(skill_id, skill_lv),BL_CHAR|BL_SKILL, + src,skill_id,skill_lv,tick, flag|BCT_ENEMY|1, + skill->castend_damage_id); break; case NJ_HYOUSYOURAKU: case NJ_RAIGEKISAI: case WZ_FROSTNOVA: clif->skill_nodamage(src,bl,skill_id,skill_lv,1); - skill_area_temp[1] = 0; - iMap->foreachinrange(skill->attack_area, src, - skill->get_splash(skill_id, skill_lv), splash_target(src), - BF_MAGIC, src, src, skill_id, skill_lv, tick, flag, BCT_ENEMY); + skill->area_temp[1] = 0; + map->foreachinrange(skill->attack_area, src, + skill->get_splash(skill_id, skill_lv), splash_target(src), + BF_MAGIC, src, src, skill_id, skill_lv, tick, flag, BCT_ENEMY); break; case HVAN_EXPLOSION: //[orn] @@ -5943,13 +5873,13 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui i = ((!md || md->special_state.ai == 2) && !map_flag_vs(src->m))? BCT_ENEMY:BCT_ALL; clif->skill_nodamage(src, src, skill_id, -1, 1); - iMap->delblock(src); //Required to prevent chain-self-destructions hitting back. - iMap->foreachinrange(skill->area_sub, bl, - skill->get_splash(skill_id, skill_lv), splash_target(src), - src, skill_id, skill_lv, tick, flag|i, - skill->castend_damage_id); - iMap->addblock(src); - iStatus->damage(src, src, sstatus->max_hp,0,0,1); + map->delblock(src); //Required to prevent chain-self-destructions hitting back. + map->foreachinrange(skill->area_sub, bl, + skill->get_splash(skill_id, skill_lv), splash_target(src), + src, skill_id, skill_lv, tick, flag|i, + skill->castend_damage_id); + map->addblock(src); + status->damage(src, src, sstatus->max_hp,0,0,1); break; case AL_ANGELUS: @@ -6008,7 +5938,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui if( tsce ) { clif->skill_nodamage(src,bl,skill_id,skill_lv,status_change_end(bl, type, INVALID_TIMER)); - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 0; } clif->skill_nodamage(src,bl,skill_id,skill_lv,sc_start(bl,type,100,skill_lv,skill->get_time(skill_id,skill_lv))); @@ -6019,13 +5949,14 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case SL_KAUPE: if (sd) { if (!dstsd || !( - (sd->sc.data[SC_SOULLINK] && sd->sc.data[SC_SOULLINK]->val2 == SL_SOULLINKER) || - (dstsd->class_&MAPID_UPPERMASK) == MAPID_SOUL_LINKER || - dstsd->status.char_id == sd->status.char_id || - dstsd->status.char_id == sd->status.partner_id || - dstsd->status.char_id == sd->status.child - )) { - iStatus->change_start(src,SC_STUN,10000,skill_lv,0,0,0,500,8); + (sd->sc.data[SC_SOULLINK] && sd->sc.data[SC_SOULLINK]->val2 == SL_SOULLINKER) + || (dstsd->class_&MAPID_UPPERMASK) == MAPID_SOUL_LINKER + || dstsd->status.char_id == sd->status.char_id + || dstsd->status.char_id == sd->status.partner_id + || dstsd->status.char_id == sd->status.child + ) + ) { + status->change_start(src,SC_STUN,10000,skill_lv,0,0,0,500,8); clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); break; } @@ -6044,24 +5975,22 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case TF_HIDING: case ST_CHASEWALK: case KO_YAMIKUMO: - if (tsce) - { + if (tsce) { clif->skill_nodamage(src,bl,skill_id,-1,status_change_end(bl, type, INVALID_TIMER)); //Hide skill-scream animation. - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 0; } else if( tsc && tsc->option&OPTION_MADOGEAR ) { //Mado Gear cannot hide if( sd ) clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 0; } clif->skill_nodamage(src,bl,skill_id,-1,sc_start(bl,type,100,skill_lv,skill->get_time(skill_id,skill_lv))); break; case TK_RUN: - if (tsce) - { + if (tsce) { clif->skill_nodamage(src,bl,skill_id,skill_lv,status_change_end(bl, type, INVALID_TIMER)); - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 0; } clif->skill_nodamage(src,bl,skill_id,skill_lv,sc_start4(bl,type,100,skill_lv,unit->getdir(bl),0,0,0)); @@ -6079,7 +6008,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui clif->skill_nodamage(src,bl,skill_id,( skill_id == LG_FORCEOFVANGUARD ) ? skill_lv : -1,i); else if( sd ) clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 0; } case RA_CAMOUFLAGE: @@ -6106,7 +6035,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui // custom hack to make the mob display the skill, because these skills don't show the skill use text themselves //NOTE: mobs don't have the sprite animation that is used when performing this skill (will cause glitches) char temp[70]; - snprintf(temp, sizeof(temp), "%s : %s !!",md->name,skill_db[skill_id].desc); + snprintf(temp, sizeof(temp), "%s : %s !!",md->name,skill->db[skill_id].desc); clif->disp_overhead(&md->bl,temp); } break; @@ -6118,15 +6047,13 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case DC_WINKCHARM: if( dstsd ) clif->skill_nodamage(src,bl,skill_id,skill_lv, sc_start(bl,SC_CONFUSION,30,7,skill->get_time2(skill_id,skill_lv))); - else - if( dstmd ) - { - if( iStatus->get_lv(src) > iStatus->get_lv(bl) - && (tstatus->race == RC_DEMON || tstatus->race == RC_DEMIHUMAN || tstatus->race == RC_ANGEL) - && !(tstatus->mode&MD_BOSS) ) + else if( dstmd ) { + if( status->get_lv(src) > status->get_lv(bl) + && (tstatus->race == RC_DEMON || tstatus->race == RC_DEMIHUMAN || tstatus->race == RC_ANGEL) + && !(tstatus->mode&MD_BOSS) + ) { clif->skill_nodamage(src,bl,skill_id,skill_lv, sc_start2(bl,type,70,skill_lv,src->id,skill->get_time(skill_id,skill_lv))); - else - { + } else { clif->skill_nodamage(src,bl,skill_id,skill_lv,0); if(sd) clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); } @@ -6163,7 +6090,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui if (sd) clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); break; } - if(iStatus->isimmune(bl) || !tsc) + if(status->isimmune(bl) || !tsc) break; if (sd && sd->sc.data[SC_PETROLOGY_OPTION]) @@ -6181,9 +6108,9 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui else if(sd) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); // Level 6-10 doesn't consume a red gem if it fails [celest] - if (skill_lv > 5) - { // not to consume items - iMap->freeblock_unlock(); + if (skill_lv > 5) { + // not to consume items + map->freeblock_unlock(); return 0; } } @@ -6192,11 +6119,11 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case NV_FIRSTAID: clif->skill_nodamage(src,bl,skill_id,5,1); - iStatus->heal(bl,5,0,0); + status->heal(bl,5,0,0); break; case AL_CURE: - if(iStatus->isimmune(bl)) { + if(status->isimmune(bl)) { clif->skill_nodamage(src,bl,skill_id,skill_lv,0); break; } @@ -6213,7 +6140,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui break; case PR_STRECOVERY: - if(iStatus->isimmune(bl)) { + if(status->isimmune(bl)) { clif->skill_nodamage(src,bl,skill_id,skill_lv,0); break; } @@ -6226,10 +6153,9 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui } //Is this equation really right? It looks so... special. if( battle->check_undead(tstatus->race,tstatus->def_ele) ) { - iStatus->change_start(bl, SC_BLIND, - 100*(100-(tstatus->int_/2+tstatus->vit/3+tstatus->luk/10)), - 1,0,0,0, - skill->get_time2(skill_id, skill_lv) * (100-(tstatus->int_+tstatus->vit)/2)/100,0); + status->change_start(bl, SC_BLIND, + 100*(100-(tstatus->int_/2+tstatus->vit/3+tstatus->luk/10)), 1,0,0,0, + skill->get_time2(skill_id, skill_lv) * (100-(tstatus->int_+tstatus->vit)/2)/100,0); } clif->skill_nodamage(src,bl,skill_id,skill_lv,1); if(dstmd) @@ -6267,10 +6193,9 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui break; case MER_SCAPEGOAT: - if( mer && mer->master ) - { - iStatus->heal(&mer->master->bl, mer->battle_status.hp, 0, 2); - iStatus->damage(src, src, mer->battle_status.max_hp, 0, 0, 1); + if( mer && mer->master ) { + status->heal(&mer->master->bl, mer->battle_status.hp, 0, 2); + status->damage(src, src, mer->battle_status.max_hp, 0, 0, 1); } break; @@ -6304,10 +6229,10 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui if(sd) { clif->item_identify_list(sd); if( sd->menuskill_id != MC_IDENTIFY ) {/* failed, dont consume anything, return */ - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 1; } - status_zap(src,0,skill_db[skill->get_index(skill_id)].sp[skill_lv]); // consume sp only if succeeded + status_zap(src,0,skill->db[skill->get_index(skill_id)].sp[skill_lv]); // consume sp only if succeeded } break; @@ -6390,7 +6315,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui eflag = pc->additem(sd,&item_tmp,1,LOG_TYPE_PRODUCE); if(eflag) { clif->additem(sd,0,0,eflag); - iMap->addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); + map->addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); } } break; @@ -6474,31 +6399,32 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui } case AM_BERSERKPITCHER: - case AM_POTIONPITCHER: { + case AM_POTIONPITCHER: + { int i,sp = 0; int64 hp = 0; if( dstmd && dstmd->class_ == MOBID_EMPERIUM ) { - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 1; } if( sd ) { int x,bonus=100, potion = min(500+skill_lv,505); x = skill_lv%11 - 1; - i = pc->search_inventory(sd,skill_db[skill_id].itemid[x]); - if( i < 0 || skill_db[skill_id].itemid[x] <= 0 ) { + i = pc->search_inventory(sd,skill->db[skill_id].itemid[x]); + if( i < 0 || skill->db[skill_id].itemid[x] <= 0 ) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 1; } - if(sd->inventory_data[i] == NULL || sd->status.inventory[i].amount < skill_db[skill_id].amount[x]) { + if(sd->inventory_data[i] == NULL || sd->status.inventory[i].amount < skill->db[skill_id].amount[x]) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 1; } if( skill_id == AM_BERSERKPITCHER ) { if( dstsd && dstsd->status.base_level < (unsigned int)sd->inventory_data[i]->elv ) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 1; } } @@ -6576,7 +6502,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui if( tsc && tsc->data[SC_EXTREMITYFIST2] ) sp = 0; #endif - iStatus->heal(bl,(int)hp,sp,0); + status->heal(bl,(int)hp,sp,0); } break; case AM_CP_WEAPON: @@ -6586,9 +6512,9 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui { unsigned int equip[] = {EQP_WEAPON, EQP_SHIELD, EQP_ARMOR, EQP_HEAD_TOP}; - if( sd && ( bl->type != BL_PC || ( dstsd && pc->checkequip(dstsd,equip[skill_id - AM_CP_WEAPON]) < 0 ) ) ){ + if( sd && ( bl->type != BL_PC || ( dstsd && pc->checkequip(dstsd,equip[skill_id - AM_CP_WEAPON]) < 0 ) ) ) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); - iMap->freeblock_unlock(); // Don't consume item requirements + map->freeblock_unlock(); // Don't consume item requirements return 0; } @@ -6644,7 +6570,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); break; } - if(iStatus->isimmune(bl) || !tsc || !tsc->count) + if(status->isimmune(bl) || !tsc || !tsc->count) break; if( sd && dstsd && !map_flag_vs(sd->bl.m) @@ -6654,12 +6580,11 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui break; } - for(i = 0; i < SC_MAX; i++) - { + for(i = 0; i < SC_MAX; i++) { if ( !tsc->data[i] ) continue; - if( SC_COMMON_MAX < i ){ - if ( iStatus->get_sc_type(i)&SC_NO_DISPELL ) + if( SC_COMMON_MAX < i ) { + if ( status->get_sc_type(i)&SC_NO_DISPELL ) continue; } switch (i) { @@ -6691,9 +6616,9 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui break; } //Affect all targets on splash area. - iMap->foreachinrange(skill->area_sub, bl, i, BL_CHAR, - src, skill_id, skill_lv, tick, flag|1, - skill->castend_damage_id); + map->foreachinrange(skill->area_sub, bl, i, BL_CHAR, + src, skill_id, skill_lv, tick, flag|1, + skill->castend_damage_id); break; case TF_BACKSLIDING: //This is the correct implementation as per packet logging information. [Skotlex] @@ -6717,7 +6642,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui } clif->skill_nodamage(src,bl,TK_HIGHJUMP,skill_lv,1); - if(!iMap->count_oncell(src->m,x,y,BL_PC|BL_NPC|BL_MOB) && iMap->getcell(src->m,x,y,CELL_CHKREACH)) { + if(!map->count_oncell(src->m,x,y,BL_PC|BL_NPC|BL_MOB) && map->getcell(src->m,x,y,CELL_CHKREACH)) { clif->slide(src,x,y); unit->movepos(src, x, y, 1, 0); } @@ -6747,7 +6672,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui sp = skill->get_sp(skill_id,skill_lv); sp = sp * tsc->data[SC_MAGICROD]->val2 / 100; if(sp < 1) sp = 1; - iStatus->heal(bl,0,sp,2); + status->heal(bl,0,sp,2); status_percent_damage(bl, src, 0, -20, false); //20% max SP damage. } else { struct unit_data *ud = unit->bl2ud(bl); @@ -6780,7 +6705,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui sp = sp*(25*(skill_lv-1))/100; if(hp || sp) - iStatus->heal(src, hp, sp, 2); + status->heal(src, hp, sp, 2); } } break; @@ -6829,8 +6754,8 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case BS_GREED: if(sd){ clif->skill_nodamage(src,bl,skill_id,skill_lv,1); - iMap->foreachinrange(skill->greed,bl, - skill->get_splash(skill_id, skill_lv),BL_ITEM,bl); + map->foreachinrange(skill->greed,bl, + skill->get_splash(skill_id, skill_lv),BL_ITEM,bl); } break; @@ -6938,7 +6863,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui // not really needed... but adding here anyway ^^ if (md && md->master_id > 0) { struct block_list *mbl, *tbl; - if ((mbl = iMap->id2bl(md->master_id)) == NULL || + if ((mbl = map->id2bl(md->master_id)) == NULL || (tbl = battle->get_targeted(mbl)) == NULL) break; md->state.provoke_flag = tbl->id; @@ -6949,7 +6874,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case NPC_RUN: { const int mask[8][2] = {{0,-1},{1,-1},{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1}}; - uint8 dir = (bl == src)?unit->getdir(src):iMap->calc_dir(src,bl->x,bl->y); //If cast on self, run forward, else run away. + uint8 dir = (bl == src)?unit->getdir(src):map->calc_dir(src,bl->x,bl->y); //If cast on self, run forward, else run away. unit->stop_attack(src); //Run skillv tiles overriding the can-move check. if (unit->walktoxy(src, src->x + skill_lv * mask[dir][0], src->y + skill_lv * mask[dir][1], 2) && md) @@ -7017,49 +6942,49 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui break; case WE_MALE: - { - int hp_rate=(!skill_lv)? 0:skill_db[skill_id].hp_rate[skill_lv-1]; - int gain_hp= tstatus->max_hp*abs(hp_rate)/100; // The earned is the same % of the target HP than it costed the caster. [Skotlex] - clif->skill_nodamage(src,bl,skill_id,iStatus->heal(bl, gain_hp, 0, 0),1); - } + { + int hp_rate = (!skill_lv)? 0:skill->db[skill_id].hp_rate[skill_lv-1]; + int gain_hp = tstatus->max_hp*abs(hp_rate)/100; // The earned is the same % of the target HP than it costed the caster. [Skotlex] + clif->skill_nodamage(src,bl,skill_id,status->heal(bl, gain_hp, 0, 0),1); + } break; case WE_FEMALE: - { - int sp_rate=(!skill_lv)? 0:skill_db[skill_id].sp_rate[skill_lv-1]; - int gain_sp=tstatus->max_sp*abs(sp_rate)/100;// The earned is the same % of the target SP than it costed the caster. [Skotlex] - clif->skill_nodamage(src,bl,skill_id,iStatus->heal(bl, 0, gain_sp, 0),1); - } + { + int sp_rate = (!skill_lv)? 0:skill->db[skill_id].sp_rate[skill_lv-1]; + int gain_sp = tstatus->max_sp*abs(sp_rate)/100;// The earned is the same % of the target SP than it costed the caster. [Skotlex] + clif->skill_nodamage(src,bl,skill_id,status->heal(bl, 0, gain_sp, 0),1); + } break; // parent-baby skills case WE_BABY: - if(sd){ + if(sd) { struct map_session_data *f_sd = pc->get_father(sd); struct map_session_data *m_sd = pc->get_mother(sd); // if neither was found - if(!f_sd && !m_sd){ + if(!f_sd && !m_sd) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 0; } - iStatus->change_start(bl,SC_STUN,10000,skill_lv,0,0,0,skill->get_time2(skill_id,skill_lv),8); + status->change_start(bl,SC_STUN,10000,skill_lv,0,0,0,skill->get_time2(skill_id,skill_lv),8); if (f_sd) sc_start(&f_sd->bl,type,100,skill_lv,skill->get_time(skill_id,skill_lv)); if (m_sd) sc_start(&m_sd->bl,type,100,skill_lv,skill->get_time(skill_id,skill_lv)); } break; case PF_HPCONVERSION: - { - int hp, sp; - hp = sstatus->max_hp/10; - sp = hp * 10 * skill_lv / 100; - if (!iStatus->charge(src,hp,0)) { - if (sd) clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); - break; - } - clif->skill_nodamage(src, bl, skill_id, skill_lv, 1); - iStatus->heal(bl,0,sp,2); + { + int hp, sp; + hp = sstatus->max_hp/10; + sp = hp * 10 * skill_lv / 100; + if (!status->charge(src,hp,0)) { + if (sd) clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); + break; } + clif->skill_nodamage(src, bl, skill_id, skill_lv, 1); + status->heal(bl,0,sp,2); + } break; case MA_REMOVETRAP: @@ -7074,37 +6999,32 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui if( su && (sg = su->group) && (src->type == BL_MER || sg->src_id == src->id || map_flag_vs(bl->m)) && (skill->get_inf2(sg->skill_id)&INF2_TRAP) ) { clif->skill_nodamage(src, bl, skill_id, skill_lv, 1); - if( sd && !(sg->unit_id == UNT_USED_TRAPS || (sg->unit_id == UNT_ANKLESNARE && sg->val2 != 0 )) ) - { // prevent picking up expired traps - if( battle_config.skill_removetrap_type ) - { // get back all items used to deploy the trap - for( i = 0; i < 10; i++ ) - { - if( skill_db[su->group->skill_id].itemid[i] > 0 ) - { + if( sd && !(sg->unit_id == UNT_USED_TRAPS || (sg->unit_id == UNT_ANKLESNARE && sg->val2 != 0 )) ) { + // prevent picking up expired traps + if( battle_config.skill_removetrap_type ) { + // get back all items used to deploy the trap + for( i = 0; i < 10; i++ ) { + if( skill->db[su->group->skill_id].itemid[i] > 0 ) { int flag; struct item item_tmp; memset(&item_tmp,0,sizeof(item_tmp)); - item_tmp.nameid = skill_db[su->group->skill_id].itemid[i]; + item_tmp.nameid = skill->db[su->group->skill_id].itemid[i]; item_tmp.identify = 1; - if( item_tmp.nameid && (flag=pc->additem(sd,&item_tmp,skill_db[su->group->skill_id].amount[i],LOG_TYPE_OTHER)) ) - { + if( item_tmp.nameid && (flag=pc->additem(sd,&item_tmp,skill->db[su->group->skill_id].amount[i],LOG_TYPE_OTHER)) ) { clif->additem(sd,0,0,flag); - iMap->addflooritem(&item_tmp,skill_db[su->group->skill_id].amount[i],sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); + map->addflooritem(&item_tmp,skill->db[su->group->skill_id].amount[i],sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); } } } - } - else - { // get back 1 trap + } else { + // get back 1 trap struct item item_tmp; memset(&item_tmp,0,sizeof(item_tmp)); item_tmp.nameid = su->group->item_id?su->group->item_id:ITEMID_TRAP; item_tmp.identify = 1; - if( item_tmp.nameid && (flag=pc->additem(sd,&item_tmp,1,LOG_TYPE_OTHER)) ) - { + if( item_tmp.nameid && (flag=pc->additem(sd,&item_tmp,1,LOG_TYPE_OTHER)) ) { clif->additem(sd,0,0,flag); - iMap->addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); + map->addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); } } } @@ -7150,16 +7070,14 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui break; case AS_SPLASHER: - if(tstatus->mode&MD_BOSS - /** - * Renewal dropped the 3/4 hp requirement - **/ - #ifndef RENEWAL - || tstatus-> hp > tstatus->max_hp*3/4 - #endif - ) { + if( tstatus->mode&MD_BOSS +#ifndef RENEWAL + /** Renewal dropped the 3/4 hp requirement **/ + || tstatus-> hp > tstatus->max_hp*3/4 +#endif // RENEWAL + ) { if (sd) clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 1; } clif->skill_nodamage(src,bl,skill_id,skill_lv, @@ -7172,23 +7090,23 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case PF_MINDBREAKER: { if(tstatus->mode&MD_BOSS || battle->check_undead(tstatus->race,tstatus->def_ele) ) { - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 1; } - if (tsce) - { //HelloKitty2 (?) explained that this silently fails when target is + if (tsce) { + //HelloKitty2 (?) explained that this silently fails when target is //already inflicted. [Skotlex] - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 1; } //Has a 55% + skill_lv*5% success chance. if (!clif->skill_nodamage(src,bl,skill_id,skill_lv, - sc_start(bl,type,55+5*skill_lv,skill_lv,skill->get_time(skill_id,skill_lv)))) - { + sc_start(bl,type,55+5*skill_lv,skill_lv,skill->get_time(skill_id,skill_lv))) + ) { if (sd) clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 0; } @@ -7216,20 +7134,20 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui } dstmd->state.soul_change_flag = 1; sp2 = sstatus->max_sp * 3 /100; - iStatus->heal(src, 0, sp2, 2); + status->heal(src, 0, sp2, 2); clif->skill_nodamage(src,bl,skill_id,skill_lv,1); break; } sp1 = sstatus->sp; sp2 = tstatus->sp; - #ifdef RENEWAL - sp1 = sp1 / 2; - sp2 = sp2 / 2; - if( tsc && tsc->data[SC_EXTREMITYFIST2] ) - sp1 = tstatus->sp; - #endif - iStatus->set_sp(src, sp2, 3); - iStatus->set_sp(bl, sp1, 3); +#ifdef RENEWAL + sp1 = sp1 / 2; + sp2 = sp2 / 2; + if( tsc && tsc->data[SC_EXTREMITYFIST2] ) + sp1 = tstatus->sp; +#endif // RENEWAL + status->set_sp(src, sp2, 3); + status->set_sp(bl, sp1, 3); clif->skill_nodamage(src,bl,skill_id,skill_lv,1); } break; @@ -7267,7 +7185,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui clif->skill_nodamage(NULL,bl,AL_HEAL,hp,1); if(sp > 0) clif->skill_nodamage(NULL,bl,MG_SRECOVERY,sp,1); - iStatus->heal(bl,hp,sp,0); + status->heal(bl,hp,sp,0); } break; // Full Chemical Protection @@ -7284,7 +7202,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui } if( sd && !s ){ clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); - iMap->freeblock_unlock(); // Don't consume item requirements + map->freeblock_unlock(); // Don't consume item requirements return 0; } clif->skill_nodamage(src,bl,skill_id,skill_lv,1); @@ -7310,18 +7228,17 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui { int eff, count = -1; if( tsc && tsc->data[type] ){ - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 0; } - if( rnd() % 100 > skill_lv * 8 || (dstmd && ((dstmd->guardian_data && dstmd->class_ == MOBID_EMPERIUM) || mob_is_battleground(dstmd))) ) - { + if( rnd() % 100 > skill_lv * 8 || (dstmd && ((dstmd->guardian_data && dstmd->class_ == MOBID_EMPERIUM) || mob_is_battleground(dstmd))) ) { if( sd ) clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 0; } - status_zap(src,0,skill_db[skill->get_index(skill_id)].sp[skill_lv]); // consume sp only if succeeded [Inkfish] + status_zap(src,0,skill->db[skill->get_index(skill_id)].sp[skill_lv]); // consume sp only if succeeded [Inkfish] do { eff = rnd() % 14; if( eff == 5 ) @@ -7337,13 +7254,13 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui sc_start(bl,SC_INCMATKRATE,100,-50,skill->get_time2(skill_id,skill_lv)); break; case 2: // all buffs removed - iStatus->change_clear_buffs(bl,1); + status->change_clear_buffs(bl,1); break; case 3: // 1000 damage, random armor destroyed { status_fix_damage(src, bl, 1000, 0); clif->damage(src,bl,tick,0,0,1000,0,0,0); - if( !iStatus->isdead(bl) ) { + if( !status->isdead(bl) ) { int where[] = { EQP_ARMOR, EQP_SHIELD, EQP_HELM, EQP_SHOES, EQP_GARMENT }; skill->break_equip(bl, where[rnd()%5], 10000, BCT_ENEMY); } @@ -7353,7 +7270,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui sc_start(bl,SC_INCATKRATE,100,-50,skill->get_time2(skill_id,skill_lv)); break; case 5: // 2000HP heal, random teleported - iStatus->heal(src, 2000, 0, 0); + status->heal(src, 2000, 0, 0); if( !map_flag_vs(bl->m) ) unit->warp(bl, -1,-1,-1, CLR_TELEPORT); break; @@ -7452,7 +7369,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui if (tsce) { if(sd) clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); - iStatus->change_start(src,SC_STUN,10000,skill_lv,0,0,0,10000,8); + status->change_start(src,SC_STUN,10000,skill_lv,0,0,0,10000,8); status_change_end(bl, SC_SWOO, INVALID_TIMER); break; } @@ -7460,7 +7377,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case SL_SKE: if (sd && !battle_config.allow_es_magic_pc && bl->type != BL_MOB) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); - iStatus->change_start(src,SC_STUN,10000,skill_lv,0,0,0,500,10); + status->change_start(src,SC_STUN,10000,skill_lv,0,0,0,500,10); break; } clif->skill_nodamage(src,bl,skill_id,skill_lv,sc_start(bl,type,100,skill_lv,skill->get_time(skill_id,skill_lv))); @@ -7471,42 +7388,42 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui // New guild skills [Celest] case GD_BATTLEORDER: if(flag&1) { - if (iStatus->get_guild_id(src) == iStatus->get_guild_id(bl)) + if (status->get_guild_id(src) == status->get_guild_id(bl)) sc_start(bl,type,100,skill_lv,skill->get_time(skill_id, skill_lv)); - } else if (iStatus->get_guild_id(src)) { + } else if (status->get_guild_id(src)) { clif->skill_nodamage(src,bl,skill_id,skill_lv,1); - iMap->foreachinrange(skill->area_sub, src, - skill->get_splash(skill_id, skill_lv), BL_PC, - src,skill_id,skill_lv,tick, flag|BCT_GUILD|1, - skill->castend_nodamage_id); + map->foreachinrange(skill->area_sub, src, + skill->get_splash(skill_id, skill_lv), BL_PC, + src,skill_id,skill_lv,tick, flag|BCT_GUILD|1, + skill->castend_nodamage_id); if (sd) guild->block_skill(sd,skill->get_time2(skill_id,skill_lv)); } break; case GD_REGENERATION: if(flag&1) { - if (iStatus->get_guild_id(src) == iStatus->get_guild_id(bl)) + if (status->get_guild_id(src) == status->get_guild_id(bl)) sc_start(bl,type,100,skill_lv,skill->get_time(skill_id, skill_lv)); - } else if (iStatus->get_guild_id(src)) { + } else if (status->get_guild_id(src)) { clif->skill_nodamage(src,bl,skill_id,skill_lv,1); - iMap->foreachinrange(skill->area_sub, src, - skill->get_splash(skill_id, skill_lv), BL_PC, - src,skill_id,skill_lv,tick, flag|BCT_GUILD|1, - skill->castend_nodamage_id); + map->foreachinrange(skill->area_sub, src, + skill->get_splash(skill_id, skill_lv), BL_PC, + src,skill_id,skill_lv,tick, flag|BCT_GUILD|1, + skill->castend_nodamage_id); if (sd) guild->block_skill(sd,skill->get_time2(skill_id,skill_lv)); } break; case GD_RESTORE: if(flag&1) { - if (iStatus->get_guild_id(src) == iStatus->get_guild_id(bl)) + if (status->get_guild_id(src) == status->get_guild_id(bl)) clif->skill_nodamage(src,bl,AL_HEAL,status_percent_heal(bl,90,90),1); - } else if (iStatus->get_guild_id(src)) { + } else if (status->get_guild_id(src)) { clif->skill_nodamage(src,bl,skill_id,skill_lv,1); - iMap->foreachinrange(skill->area_sub, src, - skill->get_splash(skill_id, skill_lv), BL_PC, - src,skill_id,skill_lv,tick, flag|BCT_GUILD|1, - skill->castend_nodamage_id); + map->foreachinrange(skill->area_sub, src, + skill->get_splash(skill_id, skill_lv), BL_PC, + src,skill_id,skill_lv,tick, flag|BCT_GUILD|1, + skill->castend_nodamage_id); if (sd) guild->block_skill(sd,skill->get_time2(skill_id,skill_lv)); } @@ -7518,7 +7435,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui int j = 0; struct guild *g; // i don't know if it actually summons in a circle, but oh well. ;P - g = sd ? sd->guild : guild->search(iStatus->get_guild_id(src)); + g = sd ? sd->guild : guild->search(status->get_guild_id(src)); if (!g) break; clif->skill_nodamage(src,bl,skill_id,skill_lv,1); @@ -7527,7 +7444,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui if ((dstsd = g->member[i].sd) != NULL && sd != dstsd && !dstsd->state.autotrade && !pc_isdead(dstsd)) { 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)) + if(map->getcell(src->m,src->x+dx[j],src->y+dy[j],CELL_CHKNOREACH)) dx[j] = dy[j] = 0; pc->setpos(dstsd, map_id2index(src->m), src->x+dx[j], src->y+dy[j], CLR_RESPAWN); } @@ -7609,8 +7526,8 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui } //TODO: Shouldn't also players and the like switch targets? - iMap->foreachinrange(skill->chastle_mob_changetarget,src, - AREA_SIZE, BL_MOB, bl, src); + map->foreachinrange(skill->chastle_mob_changetarget,src, + AREA_SIZE, BL_MOB, bl, src); } } // Failed @@ -7629,14 +7546,14 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui else if(r<per[i][1]) //Master bl = battle->get_master(src); else //Enemy - bl = iMap->id2bl(battle->get_target(src)); + bl = map->id2bl(battle->get_target(src)); if (!bl) bl = src; i = skill->calc_heal(src, bl, skill_id, 1+rnd()%skill_lv, true); //Eh? why double skill packet? clif->skill_nodamage(src,bl,AL_HEAL,i,1); clif->skill_nodamage(src,bl,skill_id,i,1); - iStatus->heal(bl, i, 0, 0); + status->heal(bl, i, 0, 0); } break; //Homun single-target support skills [orn] @@ -7693,25 +7610,25 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui default: sc_start2(bl,type,100,skill_lv,src->id,skill->get_time2(skill_id,skill_lv)); } - }else { - skill_area_temp[2] = 0; //For SD_PREAMBLE + } else { + skill->area_temp[2] = 0; //For SD_PREAMBLE clif->skill_nodamage(src,bl,skill_id,skill_lv,1); - iMap->foreachinrange(skill->area_sub, bl, - skill->get_splash(skill_id, skill_lv),BL_CHAR, - src,skill_id,skill_lv,tick, flag|BCT_ENEMY|SD_PREAMBLE|1, - skill->castend_nodamage_id); + map->foreachinrange(skill->area_sub, bl, + skill->get_splash(skill_id, skill_lv),BL_CHAR, + src,skill_id,skill_lv,tick, flag|BCT_ENEMY|SD_PREAMBLE|1, + skill->castend_nodamage_id); } break; case NPC_WIDESOULDRAIN: if (flag&1) status_percent_damage(src,bl,0,((skill_lv-1)%5+1)*20,false); else { - skill_area_temp[2] = 0; //For SD_PREAMBLE + skill->area_temp[2] = 0; //For SD_PREAMBLE clif->skill_nodamage(src,bl,skill_id,skill_lv,1); - iMap->foreachinrange(skill->area_sub, bl, - skill->get_splash(skill_id, skill_lv),BL_CHAR, - src,skill_id,skill_lv,tick, flag|BCT_ENEMY|SD_PREAMBLE|1, - skill->castend_nodamage_id); + map->foreachinrange(skill->area_sub, bl, + skill->get_splash(skill_id, skill_lv),BL_CHAR, + src,skill_id,skill_lv,tick, flag|BCT_ENEMY|SD_PREAMBLE|1, + skill->castend_nodamage_id); } break; case ALL_PARTYFLEE: @@ -7741,19 +7658,18 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui break; case RK_ENCHANTBLADE: clif->skill_nodamage(src,bl,skill_id,skill_lv,// formula not confirmed - sc_start2(bl,type,100,skill_lv,100+20*skill_lv/*+sstatus->int_/2+iStatus->get_lv(bl)/10*/,skill->get_time(skill_id,skill_lv))); + sc_start2(bl,type,100,skill_lv,100+20*skill_lv/*+sstatus->int_/2+status->get_lv(bl)/10*/,skill->get_time(skill_id,skill_lv))); break; case RK_DRAGONHOWLING: if( flag&1) sc_start(bl,type,50 + 6 * skill_lv,skill_lv,skill->get_time(skill_id,skill_lv)); - else - { - skill_area_temp[2] = 0; + else { + skill->area_temp[2] = 0; clif->skill_nodamage(src,bl,skill_id,skill_lv,1); - iMap->foreachinrange(skill->area_sub, src, - skill->get_splash(skill_id,skill_lv),BL_CHAR, - src,skill_id,skill_lv,tick,flag|BCT_ENEMY|SD_PREAMBLE|1, - skill->castend_nodamage_id); + map->foreachinrange(skill->area_sub, src, + skill->get_splash(skill_id,skill_lv),BL_CHAR, + src,skill_id,skill_lv,tick,flag|BCT_ENEMY|SD_PREAMBLE|1, + skill->castend_nodamage_id); } break; case RK_IGNITIONBREAK: @@ -7762,29 +7678,28 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui i = skill->get_splash(skill_id,skill_lv); if( skill_id == LG_EARTHDRIVE ) { int dummy = 1; - iMap->foreachinarea(skill->cell_overlap, src->m, src->x-i, src->y-i, src->x+i, src->y+i, BL_SKILL, LG_EARTHDRIVE, &dummy, src); + map->foreachinarea(skill->cell_overlap, src->m, src->x-i, src->y-i, src->x+i, src->y+i, BL_SKILL, LG_EARTHDRIVE, &dummy, src); } - iMap->foreachinrange(skill->area_sub, bl,i,BL_CHAR, - src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_damage_id); + map->foreachinrange(skill->area_sub, bl,i,BL_CHAR, + src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_damage_id); break; case RK_STONEHARDSKIN: - if( sd ) - { + if( sd ) { int heal = sstatus->hp / 4; // 25% HP - if( iStatus->charge(bl,heal,0) ) + if( status->charge(bl,heal,0) ) clif->skill_nodamage(src,bl,skill_id,skill_lv,sc_start2(bl,type,100,skill_lv,heal,skill->get_time(skill_id,skill_lv))); else clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); } break; case RK_REFRESH: - { - int heal = status_get_max_hp(bl) * 25 / 100; - clif->skill_nodamage(src,bl,skill_id,skill_lv, - sc_start(bl,type,100,skill_lv,skill->get_time(skill_id,skill_lv))); - iStatus->heal(bl,heal,0,1); - iStatus->change_clear_buffs(bl,4); - } + { + int heal = status_get_max_hp(bl) * 25 / 100; + clif->skill_nodamage(src,bl,skill_id,skill_lv, + sc_start(bl,type,100,skill_lv,skill->get_time(skill_id,skill_lv))); + status->heal(bl,heal,0,1); + status->change_clear_buffs(bl,4); + } break; case RK_MILLENNIUMSHIELD: @@ -7799,13 +7714,13 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case RK_FIGHTINGSPIRIT: if( flag&1 ) { if( src == bl ) - sc_start2(bl,type,100,skill_area_temp[5],10*(sd?pc->checkskill(sd,RK_RUNEMASTERY):10),skill->get_time(skill_id,skill_lv)); + sc_start2(bl,type,100,skill->area_temp[5],10*(sd?pc->checkskill(sd,RK_RUNEMASTERY):10),skill->get_time(skill_id,skill_lv)); else - sc_start(bl,type,100,skill_area_temp[5]/4,skill->get_time(skill_id,skill_lv)); + sc_start(bl,type,100,skill->area_temp[5]/4,skill->get_time(skill_id,skill_lv)); } else if( sd ) { if( sd->status.party_id ) { i = party_foreachsamemap(skill->area_sub,sd,skill->get_splash(skill_id,skill_lv),src,skill_id,skill_lv,tick,BCT_PARTY,skill->area_sub_count); - skill_area_temp[5] = 7 * i; // ATK + skill->area_temp[5] = 7 * i; // ATK party_foreachsamemap(skill->area_sub,sd,skill->get_splash(skill_id,skill_lv),src,skill_id,skill_lv,tick,flag|BCT_PARTY|1,skill->castend_nodamage_id); } else sc_start2(bl,type,100,7,5,skill->get_time(skill_id,skill_lv)); @@ -7817,37 +7732,37 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui if( sd == NULL || sd->status.party_id == 0 || flag&1 ){ if( src == bl ) break; - while( skill_area_temp[5] >= 0x10 ){ + while( skill->area_temp[5] >= 0x10 ){ type = SC_NONE; i = 0; - if( skill_area_temp[5]&0x10 ){ + if( skill->area_temp[5]&0x10 ){ if( dstsd ){ i = (rnd()%100<50) ? 4 : ((rnd()%100<80) ? 3 : 2); clif->millenniumshield(dstsd,i); - skill_area_temp[5] &= ~0x10; + skill->area_temp[5] &= ~0x10; type = SC_MILLENNIUMSHIELD; } - }else if( skill_area_temp[5]&0x20 ){ + }else if( skill->area_temp[5]&0x20 ){ i = status_get_max_hp(bl) * 25 / 100; - iStatus->change_clear_buffs(bl,4); - skill_area_temp[5] &= ~0x20; - iStatus->heal(bl,i,0,1); + status->change_clear_buffs(bl,4); + skill->area_temp[5] &= ~0x20; + status->heal(bl,i,0,1); type = SC_REFRESH; - }else if( skill_area_temp[5]&0x40 ){ - skill_area_temp[5] &= ~0x40; + }else if( skill->area_temp[5]&0x40 ){ + skill->area_temp[5] &= ~0x40; type = SC_GIANTGROWTH; - }else if( skill_area_temp[5]&0x80 ){ + }else if( skill->area_temp[5]&0x80 ){ if( dstsd ){ i = sstatus->hp / 4; - if( iStatus->charge(bl,i,0) ) + if( status->charge(bl,i,0) ) type = SC_STONEHARDSKIN; - skill_area_temp[5] &= ~0x80; + skill->area_temp[5] &= ~0x80; } - }else if( skill_area_temp[5]&0x100 ){ - skill_area_temp[5] &= ~0x100; + }else if( skill->area_temp[5]&0x100 ){ + skill->area_temp[5] &= ~0x100; type = SC_VITALITYACTIVATION; - }else if( skill_area_temp[5]&0x200 ){ - skill_area_temp[5] &= ~0x200; + }else if( skill->area_temp[5]&0x200 ){ + skill->area_temp[5] &= ~0x200; type = SC_ABUNDANCE; } if( type > SC_NONE ) @@ -7857,17 +7772,17 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui }else if( sd ){ if( tsc && tsc->count ){ if(tsc->data[SC_MILLENNIUMSHIELD]) - skill_area_temp[5] |= 0x10; + skill->area_temp[5] |= 0x10; if(tsc->data[SC_REFRESH]) - skill_area_temp[5] |= 0x20; + skill->area_temp[5] |= 0x20; if(tsc->data[SC_GIANTGROWTH]) - skill_area_temp[5] |= 0x40; + skill->area_temp[5] |= 0x40; if(tsc->data[SC_STONEHARDSKIN]) - skill_area_temp[5] |= 0x80; + skill->area_temp[5] |= 0x80; if(tsc->data[SC_VITALITYACTIVATION]) - skill_area_temp[5] |= 0x100; + skill->area_temp[5] |= 0x100; if(tsc->data[SC_ABUNDANCE]) - skill_area_temp[5] |= 0x200; + skill->area_temp[5] |= 0x200; } clif->skill_nodamage(src, bl, skill_id, skill_lv, 1); party_foreachsamemap(skill->area_sub, sd, skill->get_splash(skill_id, skill_lv), src, skill_id, skill_lv, tick, flag|BCT_PARTY|1, skill->castend_nodamage_id); @@ -7879,8 +7794,8 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case GC_ROLLINGCUTTER: { short count = 1; - skill_area_temp[2] = 0; - iMap->foreachinrange(skill->area_sub,src,skill->get_splash(skill_id,skill_lv),BL_CHAR,src,skill_id,skill_lv,tick,flag|BCT_ENEMY|SD_PREAMBLE|SD_SPLASH|1,skill->castend_damage_id); + skill->area_temp[2] = 0; + map->foreachinrange(skill->area_sub,src,skill->get_splash(skill_id,skill_lv),BL_CHAR,src,skill_id,skill_lv,tick,flag|BCT_ENEMY|SD_PREAMBLE|SD_SPLASH|1,skill->castend_damage_id); if( tsc && tsc->data[SC_ROLLINGCUTTER] ) { // Every time the skill is casted the status change is reseted adding a counter. count += (short)tsc->data[SC_ROLLINGCUTTER]->val1; @@ -7934,8 +7849,8 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case GC_PHANTOMMENACE: clif->skill_damage(src,bl,tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6); clif->skill_nodamage(src,bl,skill_id,skill_lv,1); - iMap->foreachinrange(skill->area_sub,src,skill->get_splash(skill_id,skill_lv),BL_CHAR, - src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_damage_id); + map->foreachinrange(skill->area_sub,src,skill->get_splash(skill_id,skill_lv),BL_CHAR, + src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_damage_id); break; case GC_HALLUCINATIONWALK: @@ -7945,8 +7860,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui if( sd ) clif->skill_fail(sd,skill_id,USESKILL_FAIL_HP_INSUFFICIENT,0); break; } - if( !iStatus->charge(bl,heal,0) ) - { + if( !status->charge(bl,heal,0) ) { if( sd ) clif->skill_fail(sd,skill_id,USESKILL_FAIL_HP_INSUFFICIENT,0); break; } @@ -7989,13 +7903,13 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui if( sd && tstatus && !battle->check_undead(tstatus->race, tstatus->def_ele) ) { i = skill->calc_heal(src, bl, AL_HEAL, pc->checkskill(sd, AL_HEAL), true); - if( (dstsd && pc_ismadogear(dstsd)) || iStatus->isimmune(bl)) + if( (dstsd && pc_ismadogear(dstsd)) || status->isimmune(bl)) i = 0; // Should heal by 0 or won't do anything?? in iRO it breaks the healing to members.. [malufett] clif->skill_nodamage(bl, bl, skill_id, i, 1); if( tsc && tsc->data[SC_AKAITSUKI] && i ) i = ~i + 1; - iStatus->heal(bl, i, 0, 0); + status->heal(bl, i, 0, 0); } } else if( sd ) @@ -8005,9 +7919,8 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case AB_ORATIO: if( flag&1 ) sc_start(bl, type, 40 + 5 * skill_lv, skill_lv, skill->get_time(skill_id, skill_lv)); - else - { - iMap->foreachinrange(skill->area_sub, src, skill->get_splash(skill_id, skill_lv), BL_CHAR, + else { + map->foreachinrange(skill->area_sub, src, skill->get_splash(skill_id, skill_lv), BL_CHAR, src, skill_id, skill_lv, tick, flag|BCT_ENEMY|1, skill->castend_nodamage_id); clif->skill_nodamage(src, bl, skill_id, skill_lv, 1); } @@ -8051,23 +7964,21 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui break; case AB_CLEARANCE: - if( flag&1 || (i = skill->get_splash(skill_id, skill_lv)) < 1 ) - { //As of the behavior in official server Clearance is just a super version of Dispell skill. [Jobbie] + if( flag&1 || (i = skill->get_splash(skill_id, skill_lv)) < 1 ) { + //As of the behavior in official server Clearance is just a super version of Dispell skill. [Jobbie] clif->skill_nodamage(src,bl,skill_id,skill_lv,1); - if((dstsd && (dstsd->class_&MAPID_UPPERMASK) == MAPID_SOUL_LINKER) || rnd()%100 >= 30 + 10 * skill_lv) - { + if((dstsd && (dstsd->class_&MAPID_UPPERMASK) == MAPID_SOUL_LINKER) || rnd()%100 >= 30 + 10 * skill_lv) { if (sd) clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); break; } - if(iStatus->isimmune(bl) || !tsc || !tsc->count) + if(status->isimmune(bl) || !tsc || !tsc->count) break; - for(i = 0; i < SC_MAX; i++) - { + for(i = 0; i < SC_MAX; i++) { if ( !tsc->data[i] ) continue; if( SC_COMMON_MAX > i ) - if ( iStatus->get_sc_type(i)&SC_NO_CLEARANCE ) + if ( status->get_sc_type(i)&SC_NO_CLEARANCE ) continue; switch (i) { case SC_ASSUMPTIO: @@ -8083,12 +7994,12 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui } break; } - iMap->foreachinrange(skill->area_sub, bl, i, BL_CHAR, src, skill_id, skill_lv, tick, flag|1, skill->castend_damage_id); + map->foreachinrange(skill->area_sub, bl, i, BL_CHAR, src, skill_id, skill_lv, tick, flag|1, skill->castend_damage_id); break; case AB_SILENTIUM: // Should the level of Lex Divina be equivalent to the level of Silentium or should the highest level learned be used? [LimitLine] - iMap->foreachinrange(skill->area_sub, src, skill->get_splash(skill_id, skill_lv), BL_CHAR, + map->foreachinrange(skill->area_sub, src, skill->get_splash(skill_id, skill_lv), BL_CHAR, src, PR_LEXDIVINA, skill_lv, tick, flag|BCT_ENEMY|1, skill->castend_nodamage_id); clif->skill_nodamage(src, bl, skill_id, skill_lv, 1); break; @@ -8098,9 +8009,8 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case WL_STASIS: if( flag&1 ) sc_start(bl,type,100,skill_lv,skill->get_time(skill_id,skill_lv)); - else - { - iMap->foreachinrange(skill->area_sub,src,skill->get_splash(skill_id, skill_lv),BL_CHAR,src,skill_id,skill_lv,tick,(map_flag_vs(src->m)?BCT_ALL:BCT_ENEMY|BCT_SELF)|flag|1,skill->castend_nodamage_id); + else { + map->foreachinrange(skill->area_sub,src,skill->get_splash(skill_id, skill_lv),BL_CHAR,src,skill_id,skill_lv,tick,(map_flag_vs(src->m)?BCT_ALL:BCT_ENEMY|BCT_SELF)|flag|1,skill->castend_nodamage_id); clif->skill_nodamage(src, bl, skill_id, skill_lv, 1); } break; @@ -8127,12 +8037,12 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case WL_FROSTMISTY: clif->skill_nodamage(src,bl,skill_id,skill_lv,1); - iMap->foreachinrange(skill->area_sub,bl,skill->get_splash(skill_id,skill_lv),BL_CHAR|BL_SKILL,src,skill_id,skill_lv,tick,flag|BCT_ENEMY,skill->castend_damage_id); + map->foreachinrange(skill->area_sub,bl,skill->get_splash(skill_id,skill_lv),BL_CHAR|BL_SKILL,src,skill_id,skill_lv,tick,flag|BCT_ENEMY,skill->castend_damage_id); break; case WL_JACKFROST: clif->skill_nodamage(src,bl,skill_id,skill_lv,1); - iMap->foreachinshootrange(skill->area_sub,bl,skill->get_splash(skill_id,skill_lv),BL_CHAR|BL_SKILL,src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_damage_id); + map->foreachinshootrange(skill->area_sub,bl,skill->get_splash(skill_id,skill_lv),BL_CHAR|BL_SKILL,src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_damage_id); break; case WL_MARSHOFABYSS: @@ -8142,17 +8052,17 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case WL_SIENNAEXECRATE: if( flag&1 ) { - if( iStatus->isimmune(bl) || !tsc ) + if( status->isimmune(bl) || !tsc ) break; if( tsc && tsc->data[SC_STONE] ) status_change_end(bl,SC_STONE,INVALID_TIMER); else - iStatus->change_start(bl,SC_STONE,10000,skill_lv,0,0,500,skill->get_time(skill_id, skill_lv),2); + status->change_start(bl,SC_STONE,10000,skill_lv,0,0,500,skill->get_time(skill_id, skill_lv),2); } else { int rate = 45 + 5 * skill_lv; if( rnd()%100 < rate ){ clif->skill_nodamage(src, bl, skill_id, skill_lv, 1); - iMap->foreachinrange(skill->area_sub,bl,skill->get_splash(skill_id,skill_lv),BL_CHAR,src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill_castend_nodamage_id); + map->foreachinrange(skill->area_sub,bl,skill->get_splash(skill_id,skill_lv),BL_CHAR,src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill_castend_nodamage_id); }else if( sd ) // Failure on Rate clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); } @@ -8174,7 +8084,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case WL_READING_SB: if( sd ) { - struct status_change *sc = iStatus->get_sc(bl); + struct status_change *sc = status->get_sc(bl); for( i = SC_SPELLBOOK1; i <= SC_SPELLBOOK7; i++) if( sc && !sc->data[i] ) @@ -8223,7 +8133,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case RA_WUGDASH: if( tsce ) { clif->skill_nodamage(src,bl,skill_id,skill_lv,status_change_end(bl, type, INVALID_TIMER)); - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 0; } if( sd && pc_isridingwug(sd) ) { @@ -8235,7 +8145,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case RA_SENSITIVEKEEN: clif->skill_nodamage(src,bl,skill_id,skill_lv,1); clif->skill_damage(src,src,tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6); - iMap->foreachinrange(skill->area_sub,src,skill->get_splash(skill_id,skill_lv),BL_CHAR|BL_SKILL,src,skill_id,skill_lv,tick,flag|BCT_ENEMY,skill->castend_damage_id); + map->foreachinrange(skill->area_sub,src,skill->get_splash(skill_id,skill_lv),BL_CHAR|BL_SKILL,src,skill_id,skill_lv,tick,flag|BCT_ENEMY,skill->castend_damage_id); break; /** * Mechanic @@ -8256,7 +8166,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui pc->setmadogear(sd, 0); clif->skill_nodamage(src, bl, skill_id, skill_lv, 1); skill->castend_damage_id(src, src, skill_id, skill_lv, tick, flag); - iStatus->set_sp(src, 0, 0); + status->set_sp(src, 0, 0); } break; @@ -8270,7 +8180,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case NC_MAGNETICFIELD: if( (i = sc_start2(bl,type,100,skill_lv,src->id,skill->get_time(skill_id,skill_lv))) ) { - iMap->foreachinrange(skill->area_sub,src,skill->get_splash(skill_id,skill_lv),splash_target(src),src,skill_id,skill_lv,tick,flag|BCT_ENEMY|SD_SPLASH|1,skill->castend_damage_id);; + map->foreachinrange(skill->area_sub,src,skill->get_splash(skill_id,skill_lv),splash_target(src),src,skill_id,skill_lv,tick,flag|BCT_ENEMY|SD_SPLASH|1,skill->castend_damage_id);; clif->skill_damage(src,src,tick,status_get_amotion(src),0,-30000,1,skill_id,skill_lv,6); if (sd) pc->overheat(sd,1); } @@ -8284,10 +8194,10 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui if( dstsd && pc_ismadogear(dstsd) ) { heal = dstsd->status.max_hp * (3+3*skill_lv) / 100; - iStatus->heal(bl,heal,0,2); + status->heal(bl,heal,0,2); } else { heal = sd->status.max_hp * (3+3*skill_lv) / 100; - iStatus->heal(src,heal,0,2); + status->heal(src,heal,0,2); } clif->skill_damage(src, src, tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6); @@ -8298,7 +8208,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case NC_DISJOINT: { if( bl->type != BL_MOB ) break; - md = iMap->id2md(bl->id); + md = map->id2md(bl->id); if( md && md->class_ >= MOBID_SILVERSNIPER && md->class_ <= MOBID_MAGICDECOY_WIND ) status_kill(bl); clif->skill_nodamage(src, bl, skill_id, skill_lv, 1); @@ -8342,8 +8252,8 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui } } else { clif->skill_nodamage(src, bl, skill_id, 0, 1); - iMap->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), BL_CHAR, - src, skill_id, skill_lv, tick, flag|BCT_ENEMY|1, skill->castend_nodamage_id); + map->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), BL_CHAR, + src, skill_id, skill_lv, tick, flag|BCT_ENEMY|1, skill->castend_nodamage_id); } break; @@ -8354,8 +8264,8 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case SC_WEAKNESS: if( !(tsc && tsc->data[type]) ) { //((rand(myDEX / 12, myDEX / 4) + myJobLevel + 10 * skLevel) + myLevel / 10) - (targetLevel / 10 + targetLUK / 10 + (targetMaxWeight - targetWeight) / 1000 + rand(targetAGI / 6, targetAGI / 3)) - int rate = rnd_value(sstatus->dex/12,sstatus->dex/4) + 10*skill_lv + (sd?sd->status.job_level:0) + iStatus->get_lv(src)/10 - - iStatus->get_lv(bl)/10 - tstatus->luk/10 - (dstsd?(dstsd->max_weight-dstsd->weight)/10000:0) - rnd_value(tstatus->agi/6,tstatus->agi/3); + int rate = rnd_value(sstatus->dex/12,sstatus->dex/4) + 10*skill_lv + (sd?sd->status.job_level:0) + status->get_lv(src)/10 + - status->get_lv(bl)/10 - tstatus->luk/10 - (dstsd?(dstsd->max_weight-dstsd->weight)/10000:0) - rnd_value(tstatus->agi/6,tstatus->agi/3); rate = cap_value(rate, skill_lv+sstatus->dex/20, 100); clif->skill_nodamage(src,bl,skill_id,0,sc_start(bl,type,rate,skill_lv,skill->get_time(skill_id,skill_lv))); } else if( sd ) @@ -8364,23 +8274,24 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case SC_IGNORANCE: if( !(tsc && tsc->data[type]) ) { - int rate = rnd_value(sstatus->dex/12,sstatus->dex/4) + 10*skill_lv + (sd?sd->status.job_level:0) + iStatus->get_lv(src)/10 - - iStatus->get_lv(bl)/10 - tstatus->luk/10 - (dstsd?(dstsd->max_weight-dstsd->weight)/10000:0) - rnd_value(tstatus->agi/6,tstatus->agi/3); + int rate = rnd_value(sstatus->dex/12,sstatus->dex/4) + 10*skill_lv + (sd?sd->status.job_level:0) + + status->get_lv(src)/10 - status->get_lv(bl)/10 - tstatus->luk/10 + - (dstsd?(dstsd->max_weight-dstsd->weight)/10000:0) - rnd_value(tstatus->agi/6,tstatus->agi/3); rate = cap_value(rate, skill_lv+sstatus->dex/20, 100); if (clif->skill_nodamage(src,bl,skill_id,0,sc_start(bl,type,rate,skill_lv,skill->get_time(skill_id,skill_lv)))) { int sp = 200 * skill_lv; if( dstmd ) sp = dstmd->level * 2; if( status_zap(bl,0,sp) ) - iStatus->heal(src,0,sp/2,3); - } - else if( sd ) clif->skill_fail(sd,skill_id,0,0); + status->heal(src,0,sp/2,3); + } else if( sd ) + clif->skill_fail(sd,skill_id,0,0); } else if( sd ) clif->skill_fail(sd,skill_id,0,0); break; case LG_TRAMPLE: clif->skill_damage(src,bl,tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6); - iMap->foreachinrange(skill->destroy_trap,bl,skill->get_splash(skill_id,skill_lv),BL_SKILL,tick); + map->foreachinrange(skill->destroy_trap,bl,skill->get_splash(skill_id,skill_lv),BL_SKILL,tick); break; case LG_REFLECTDAMAGE: @@ -8401,40 +8312,39 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui int val, brate; switch( skill_lv ) { case 1: - { - struct item_data *shield_data = sd->inventory_data[sd->equip_index[EQI_HAND_L]]; - if( !shield_data || shield_data->type != IT_ARMOR ) { // No shield? - clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0); + { + struct item_data *shield_data = sd->inventory_data[sd->equip_index[EQI_HAND_L]]; + if( !shield_data || shield_data->type != IT_ARMOR ) { // No shield? + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0); + break; + } + brate = shield_data->def * 10; + if( rate < 50 ) + opt = 1; + else if( rate < 75 ) + opt = 2; + else + opt = 3; + + switch( opt ) { + case 1: + sc_start(bl,SC_SHIELDSPELL_DEF,100,opt,-1); + clif->skill_damage(src,bl,tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6); + if( rate < brate ) + map->foreachinrange(skill->area_sub,src,skill->get_splash(skill_id,skill_lv),BL_CHAR,src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_damage_id); + status_change_end(bl,SC_SHIELDSPELL_DEF,INVALID_TIMER); + break; + case 2: + val = shield_data->def / 10; // % Reflected damage. + sc_start2(bl,SC_SHIELDSPELL_DEF,brate,opt,val,shield_data->def * 1000); + break; + case 3: + val = shield_data->def; // Attack increase. + sc_start2(bl,SC_SHIELDSPELL_DEF,brate,opt,val,shield_data->def * 3000); break; - } - brate = shield_data->def * 10; - if( rate < 50 ) - opt = 1; - else if( rate < 75 ) - opt = 2; - else - opt = 3; - - switch( opt ) { - case 1: - sc_start(bl,SC_SHIELDSPELL_DEF,100,opt,-1); - clif->skill_damage(src,bl,tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6); - if( rate < brate ) - iMap->foreachinrange(skill->area_sub,src,skill->get_splash(skill_id,skill_lv),BL_CHAR,src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_damage_id); - status_change_end(bl,SC_SHIELDSPELL_DEF,INVALID_TIMER); - break; - case 2: - val = shield_data->def / 10; // % Reflected damage. - sc_start2(bl,SC_SHIELDSPELL_DEF,brate,opt,val,shield_data->def * 1000); - break; - case 3: - val = shield_data->def; // Attack increase. - sc_start2(bl,SC_SHIELDSPELL_DEF,brate,opt,val,shield_data->def * 3000); - break; - } } + } break; - case 2: brate = sd->bonus.shieldmdef * 20; if( rate < 30 ) @@ -8448,14 +8358,14 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui sc_start(bl,SC_SHIELDSPELL_MDEF,100,opt,-1); clif->skill_damage(src,bl,tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6); if( rate < brate ) - iMap->foreachinrange(skill->area_sub,src,skill->get_splash(skill_id,skill_lv),BL_CHAR,src,skill_id,skill_lv,tick,flag|BCT_ENEMY|2,skill->castend_damage_id); + map->foreachinrange(skill->area_sub,src,skill->get_splash(skill_id,skill_lv),BL_CHAR,src,skill_id,skill_lv,tick,flag|BCT_ENEMY|2,skill->castend_damage_id); status_change_end(bl,SC_SHIELDSPELL_MDEF,INVALID_TIMER); break; case 2: sc_start(bl,SC_SHIELDSPELL_MDEF,100,opt,-1); clif->skill_damage(src,bl,tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6); if( rate < brate ) - iMap->foreachinrange(skill->area_sub,src,skill->get_splash(skill_id,skill_lv),BL_CHAR,src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_nodamage_id); + map->foreachinrange(skill->area_sub,src,skill->get_splash(skill_id,skill_lv),BL_CHAR,src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_nodamage_id); break; case 3: if( sc_start(bl,SC_SHIELDSPELL_MDEF,brate,opt,sd->bonus.shieldmdef * 30000) ) @@ -8484,16 +8394,18 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui val = 105 * it->refine / 10; sc_start2(bl,SC_SHIELDSPELL_REF,brate,opt,val,skill->get_time(skill_id,skill_lv)); break; - case 2: case 3: - if( rate < brate ) - { + case 2: + case 3: + if( rate < brate ) { val = sstatus->max_hp * (11 + it->refine) / 100; - iStatus->heal(bl, val, 0, 3); + status->heal(bl, val, 0, 3); } break; - /*case 3: - // Full protection. I need confirm what effect should be here. Moved to case 2 to until we got it. - break;*/ +#if 0 // TODO: I need confirm what effect should be here. Moved to case 2 to until we got it. + case 3: + // Full protection. + break; +#endif // 0 } } break; @@ -8506,8 +8418,8 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui if( flag&1 ) sc_start(bl,type,100,skill_lv,skill->get_time(skill_id,skill_lv)); else { - skill_area_temp[2] = 0; - iMap->foreachinrange(skill->area_sub,bl,skill->get_splash(skill_id,skill_lv),BL_PC,src,skill_id,skill_lv,tick,flag|SD_PREAMBLE|BCT_PARTY|BCT_SELF|1,skill->castend_nodamage_id); + skill->area_temp[2] = 0; + map->foreachinrange(skill->area_sub,bl,skill->get_splash(skill_id,skill_lv),BL_PC,src,skill_id,skill_lv,tick,flag|SD_PREAMBLE|BCT_PARTY|BCT_SELF|1,skill->castend_nodamage_id); clif->skill_nodamage(src,bl,skill_id,skill_lv,1); } break; @@ -8532,10 +8444,10 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui } } }else { - skill_area_temp[2] = 0; + skill->area_temp[2] = 0; if( !map_flag_vs(src->m) && !map_flag_gvg(src->m) ) flag |= BCT_GUILD; - iMap->foreachinrange(skill->area_sub,bl,skill->get_splash(skill_id,skill_lv),BL_PC,src,skill_id,skill_lv,tick,flag|SD_PREAMBLE|BCT_PARTY|BCT_SELF|1,skill->castend_nodamage_id); + map->foreachinrange(skill->area_sub,bl,skill->get_splash(skill_id,skill_lv),BL_PC,src,skill_id,skill_lv,tick,flag|SD_PREAMBLE|BCT_PARTY|BCT_SELF|1,skill->castend_nodamage_id); clif->skill_nodamage(src,bl,skill_id,skill_lv,1); } break; @@ -8557,13 +8469,13 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui mob->unlocktarget((TBL_MOB*)bl,timer->gettick()); unit->stop_attack(bl); clif->bladestop(src, bl->id, 1); - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 1; } } else { int count = 0; clif->skill_damage(src, bl, tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6); - count = iMap->forcountinrange(skill->area_sub, src, skill->get_splash(skill_id,skill_lv), (sd)?sd->spiritball_old:15, // Assume 15 spiritballs in non-charactors + count = map->forcountinrange(skill->area_sub, src, skill->get_splash(skill_id,skill_lv), (sd)?sd->spiritball_old:15, // Assume 15 spiritballs in non-charactors BL_CHAR, src, skill_id, skill_lv, tick, flag|BCT_ENEMY|1, skill->castend_nodamage_id); if( sd ) pc->delspiritball(sd, count, 0); clif->skill_nodamage(src, src, skill_id, skill_lv, @@ -8593,7 +8505,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui clif->skill_nodamage(src, bl, skill_id, skill_lv, i ? 1:0); } else { clif->skill_damage(src,bl,tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6); - iMap->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY|BCT_SELF|SD_SPLASH|1, skill->castend_nodamage_id); + map->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY|BCT_SELF|SD_SPLASH|1, skill->castend_nodamage_id); } break; @@ -8613,17 +8525,15 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui { int heal; - if( iStatus->isimmune(bl) ) - { + if( status->isimmune(bl) ) { clif->skill_nodamage(src,bl,skill_id,skill_lv,0); break; } heal = 120 * skill_lv + status_get_max_hp(bl) * (2 + skill_lv) / 100; - iStatus->heal(bl, heal, 0, 0); + status->heal(bl, heal, 0, 0); - if( (tsc && tsc->opt1) && (rnd()%100 < ((skill_lv * 5) + (status_get_dex(src) + iStatus->get_lv(src)) / 4) - (1 + (rnd() % 10))) ) - { + if( (tsc && tsc->opt1) && (rnd()%100 < ((skill_lv * 5) + (status_get_dex(src) + status->get_lv(src)) / 4) - (1 + (rnd() % 10))) ) { status_change_end(bl, SC_STONE, INVALID_TIMER); status_change_end(bl, SC_FREEZE, INVALID_TIMER); status_change_end(bl, SC_STUN, INVALID_TIMER); @@ -8677,7 +8587,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case WM_DEADHILLHERE: if( bl->type == BL_PC ) { - if( !iStatus->isdead(bl) ) + if( !status->isdead(bl) ) break; if( rnd()%100 < 88 + 2 * skill_lv ) { @@ -8701,7 +8611,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui if( flag&1 ) { sc_start2(bl,type,(skill_id==WM_VOICEOFSIREN)?20+10*skill_lv:100,skill_lv,(skill_id==WM_VOICEOFSIREN)?src->id:0,skill->get_time(skill_id,skill_lv)); } else { - iMap->foreachinrange(skill->area_sub, src, skill->get_splash(skill_id,skill_lv),(skill_id==WM_VOICEOFSIREN)?BL_CHAR|BL_SKILL:BL_PC, src, skill_id, skill_lv, tick, flag|BCT_ENEMY|1, skill->castend_nodamage_id); + map->foreachinrange(skill->area_sub, src, skill->get_splash(skill_id,skill_lv),(skill_id==WM_VOICEOFSIREN)?BL_CHAR|BL_SKILL:BL_PC, src, skill_id, skill_lv, tick, flag|BCT_ENEMY|1, skill->castend_nodamage_id); clif->skill_nodamage(src,bl,skill_id,skill_lv,1); } break; @@ -8731,12 +8641,12 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui clif->skill_fail(sd,skill_id,USESKILL_FAIL_NEED_HELPER,0); break; } - if( iMap->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id,skill_lv), + if( map->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id,skill_lv), BL_PC, src, skill_id, skill_lv, tick, BCT_ENEMY, skill->area_sub_count) > 7 ) flag |= 2; else flag |= 1; - iMap->foreachinrange(skill->area_sub, src, skill->get_splash(skill_id,skill_lv),BL_PC, src, skill_id, skill_lv, tick, flag|BCT_ENEMY|BCT_SELF, skill->castend_nodamage_id); + map->foreachinrange(skill->area_sub, src, skill->get_splash(skill_id,skill_lv),BL_PC, src, skill_id, skill_lv, tick, flag|BCT_ENEMY|BCT_SELF, skill->castend_nodamage_id); clif->skill_nodamage(src, bl, skill_id, skill_lv, sc_start(src,SC_STOP,100,skill_lv,skill->get_time2(skill_id,skill_lv))); if( flag&2 ) // Dealed here to prevent conflicts @@ -8747,8 +8657,9 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case WM_SONG_OF_MANA: case WM_DANCE_WITH_WUG: case WM_LERADS_DEW: - if( flag&1 ) { // These affect to to all party members near the caster. - struct status_change *sc = iStatus->get_sc(src); + if( flag&1 ) { + // These affect to to all party members near the caster. + struct status_change *sc = status->get_sc(src); if( sc && sc->data[type] ) { sc_start2(bl,type,100,skill_lv,sc->data[type]->val2,skill->get_time(skill_id,skill_lv)); } @@ -8766,11 +8677,11 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case WM_BEYOND_OF_WARCRY: case WM_UNLIMITED_HUMMING_VOICE: if( flag&1 ) { - sc_start2(bl,type,100,skill_lv,skill_area_temp[0],skill->get_time(skill_id,skill_lv)); + sc_start2(bl,type,100,skill_lv,skill->area_temp[0],skill->get_time(skill_id,skill_lv)); } else { // These affect to all targets arround the caster. uint16 lv = skill_lv; - skill_area_temp[0] = (sd) ? skill->check_pc_partner(sd,skill_id,&lv,skill->get_splash(skill_id,skill_lv),1) : 50; // 50% chance in non BL_PC (clones). - iMap->foreachinrange(skill->area_sub, src, skill->get_splash(skill_id,skill_lv),BL_PC, src, skill_id, skill_lv, tick, flag|BCT_ENEMY|1, skill->castend_nodamage_id); + skill->area_temp[0] = (sd) ? skill->check_pc_partner(sd,skill_id,&lv,skill->get_splash(skill_id,skill_lv),1) : 50; // 50% chance in non BL_PC (clones). + map->foreachinrange(skill->area_sub, src, skill->get_splash(skill_id,skill_lv),BL_PC, src, skill_id, skill_lv, tick, flag|BCT_ENEMY|1, skill->castend_nodamage_id); clif->skill_nodamage(src,bl,skill_id,skill_lv,1); } break; @@ -8779,8 +8690,8 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui int improv_skill_id = 0, improv_skill_lv; do { i = rnd() % MAX_SKILL_IMPROVISE_DB; - improv_skill_id = skill_improvise_db[i].skill_id; - } while( improv_skill_id == 0 || rnd()%10000 >= skill_improvise_db[i].per ); + improv_skill_id = skill->improvise_db[i].skill_id; + } while( improv_skill_id == 0 || rnd()%10000 >= skill->improvise_db[i].per ); improv_skill_lv = 4 + skill_lv; clif->skill_nodamage (src, bl, skill_id, skill_lv, 1); @@ -8809,7 +8720,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui if (!target_id) break; if (skill->get_casttype(improv_skill_id) == CAST_GROUND) { - bl = iMap->id2bl(target_id); + bl = map->id2bl(target_id); if (!bl) bl = src; unit->skilluse_pos(src, bl->x, bl->y, improv_skill_id, improv_skill_lv); } else @@ -8840,10 +8751,10 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui mapindex = mapindex_name2id(MAP_MORA); } - if(!mapindex) - { //Given map not found? + if(!mapindex) { + //Given map not found? clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 0; } pc->setpos(sd, mapindex, x, y, CLR_TELEPORT); @@ -8874,13 +8785,13 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case WM_LULLABY_DEEPSLEEP: if( flag&1 ){ //[(Skill Level x 4) + (Voice Lessons Skill Level x 2) + (Caster?s Base Level / 15) + (Caster?s Job Level / 5)] % - int rate = (4 * skill_lv) + ( (sd) ? pc->checkskill(sd,WM_LESSON)*2 + sd->status.job_level/5 : 0 ) + iStatus->get_lv(src) / 15; + int rate = (4 * skill_lv) + ( (sd) ? pc->checkskill(sd,WM_LESSON)*2 + sd->status.job_level/5 : 0 ) + status->get_lv(src) / 15; if( bl != src ) sc_start(bl,type,rate,skill_lv,skill->get_time(skill_id,skill_lv)); }else { clif->skill_nodamage(src, bl, skill_id, skill_lv, 1); - iMap->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), BL_CHAR, - src, skill_id, skill_lv, tick, flag|BCT_ALL|1, skill->castend_nodamage_id); + map->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), BL_CHAR, + src, skill_id, skill_lv, tick, flag|BCT_ALL|1, skill->castend_nodamage_id); } break; @@ -8954,13 +8865,13 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui int e_hp, e_sp; if( !ed ) break; - if( !iStatus->charge(&sd->bl,s_hp,s_sp) ) { + if( !status->charge(&sd->bl,s_hp,s_sp) ) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); break; } e_hp = ed->battle_status.max_hp * 10 / 100; e_sp = ed->battle_status.max_sp * 10 / 100; - iStatus->heal(&ed->bl,e_hp,e_sp,3); + status->heal(&ed->bl,e_hp,e_sp,3); clif->skill_nodamage(src,&ed->bl,skill_id,skill_lv,1); } break; @@ -8985,7 +8896,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case GN_BLOOD_SUCKER: { - struct status_change *sc = iStatus->get_sc(src); + struct status_change *sc = status->get_sc(src); if( sc && sc->bs_counter < skill->get_maxcount( skill_id , skill_lv) ) { if( tsc && tsc->data[type] ){ @@ -9008,8 +8919,8 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui sc_start(bl, type, 25 + 10 * skill_lv, skill_lv, skill->get_time(skill_id, skill_lv))) ) status_zap(bl, 0, status_get_max_sp(bl) * (25 + 5 * skill_lv) / 100); } else - iMap->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), BL_CHAR, - src, skill_id, skill_lv, tick, flag|BCT_ENEMY|1, skill->castend_nodamage_id); + map->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), BL_CHAR, + src, skill_id, skill_lv, tick, flag|BCT_ENEMY|1, skill->castend_nodamage_id); break; case GN_SLINGITEM: @@ -9025,7 +8936,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui if( itemdb_is_GNbomb(ammo_id) ) { if(battle->check_target(src,bl,BCT_ENEMY) > 0) {// Only attack if the target is an enemy. if( ammo_id == 13263 ) - iMap->foreachincell(skill->area_sub,bl->m,bl->x,bl->y,BL_CHAR,src,GN_SLINGITEM_RANGEMELEEATK,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_damage_id); + map->foreachincell(skill->area_sub,bl->m,bl->x,bl->y,BL_CHAR,src,GN_SLINGITEM_RANGEMELEEATK,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_damage_id); else skill->attack(BF_WEAPON,src,src,bl,GN_SLINGITEM_RANGEMELEEATK,skill_lv,tick,flag); } else //Otherwise, it fails, shows animation and removes items. @@ -9075,24 +8986,25 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case EL_WIND_CURTAIN: case EL_SOLID_SKIN: case EL_STONE_SHIELD: - case EL_WIND_STEP: { - struct elemental_data *ele = BL_CAST(BL_ELEM, src); - if( ele ) { - sc_type type2 = type-1; - struct status_change *sc = iStatus->get_sc(&ele->bl); - - if( (sc && sc->data[type2]) || (tsc && tsc->data[type]) ) { - elemental->clean_single_effect(ele, skill_id); - } else { - clif->skill_nodamage(src,src,skill_id,skill_lv,1); - clif->skill_damage(src, ( skill_id == EL_GUST || skill_id == EL_BLAST || skill_id == EL_WILD_STORM )?src:bl, tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6); - if( skill_id == EL_WIND_STEP ) // There aren't teleport, just push the master away. - skill->blown(src,bl,(rnd()%skill->get_blewcount(skill_id,skill_lv))+1,rand()%8,0); - sc_start(src,type2,100,skill_lv,skill->get_time(skill_id,skill_lv)); - sc_start(bl,type,100,skill_lv,skill->get_time(skill_id,skill_lv)); - } + case EL_WIND_STEP: + { + struct elemental_data *ele = BL_CAST(BL_ELEM, src); + if( ele ) { + sc_type type2 = type-1; + struct status_change *sc = status->get_sc(&ele->bl); + + if( (sc && sc->data[type2]) || (tsc && tsc->data[type]) ) { + elemental->clean_single_effect(ele, skill_id); + } else { + clif->skill_nodamage(src,src,skill_id,skill_lv,1); + clif->skill_damage(src, ( skill_id == EL_GUST || skill_id == EL_BLAST || skill_id == EL_WILD_STORM )?src:bl, tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6); + if( skill_id == EL_WIND_STEP ) // There aren't teleport, just push the master away. + skill->blown(src,bl,(rnd()%skill->get_blewcount(skill_id,skill_lv))+1,rand()%8,0); + sc_start(src,type2,100,skill_lv,skill->get_time(skill_id,skill_lv)); + sc_start(bl,type,100,skill_lv,skill->get_time(skill_id,skill_lv)); } } + } break; case EL_FIRE_MANTLE: @@ -9104,23 +9016,24 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui skill->unitsetting(src,skill_id,skill_lv,bl->x,bl->y,0); break; - case EL_WATER_SCREEN: { - struct elemental_data *ele = BL_CAST(BL_ELEM, src); - if( ele ) { - struct status_change *sc = iStatus->get_sc(&ele->bl); - sc_type type2 = type-1; + case EL_WATER_SCREEN: + { + struct elemental_data *ele = BL_CAST(BL_ELEM, src); + if( ele ) { + struct status_change *sc = status->get_sc(&ele->bl); + sc_type type2 = type-1; - clif->skill_nodamage(src,src,skill_id,skill_lv,1); - if( (sc && sc->data[type2]) || (tsc && tsc->data[type]) ) { - elemental->clean_single_effect(ele, skill_id); - } else { - // This not heals at the end. - clif->skill_damage(src, src, tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6); - sc_start(src,type2,100,skill_lv,skill->get_time(skill_id,skill_lv)); - sc_start(bl,type,100,src->id,skill->get_time(skill_id,skill_lv)); - } + clif->skill_nodamage(src,src,skill_id,skill_lv,1); + if( (sc && sc->data[type2]) || (tsc && tsc->data[type]) ) { + elemental->clean_single_effect(ele, skill_id); + } else { + // This not heals at the end. + clif->skill_damage(src, src, tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6); + sc_start(src,type2,100,skill_lv,skill->get_time(skill_id,skill_lv)); + sc_start(bl,type,100,src->id,skill->get_time(skill_id,skill_lv)); } } + } break; case KO_KAHU_ENTEN: @@ -9138,12 +9051,11 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui break; case KO_ZANZOU: - if(sd){ + if(sd) { struct mob_data *md; - md = mob->once_spawn_sub(src, src->m, src->x, src->y, iStatus->get_name(src), 2308, "", SZ_SMALL, AI_NONE); - if( md ) - { + md = mob->once_spawn_sub(src, src->m, src->x, src->y, status->get_name(src), 2308, "", SZ_SMALL, AI_NONE); + if( md ) { md->master_id = src->id; md->special_state.ai = AI_ZANZOU; if( md->deletetimer != INVALID_TIMER ) @@ -9173,14 +9085,15 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui break; case KO_JYUSATSU: - if( dstsd && tsc && !tsc->data[type] && - rand()%100 < (10 * (5 * skill_lv - status_get_int(bl) / 2 + 45 + 5 * skill_lv)) ){ + if( dstsd && tsc && !tsc->data[type] + && rand()%100 < (10 * (5 * skill_lv - status_get_int(bl) / 2 + 45 + 5 * skill_lv)) + ) { clif->skill_nodamage(src, bl, skill_id, skill_lv, - iStatus->change_start(bl, type, 10000, skill_lv, 0, 0, 0, skill->get_time(skill_id, skill_lv), 1)); + status->change_start(bl, type, 10000, skill_lv, 0, 0, 0, skill->get_time(skill_id, skill_lv), 1)); status_zap(bl, tstatus->max_hp * skill_lv * 5 / 100 , 0); - if( iStatus->get_lv(bl) <= iStatus->get_lv(src) ) - iStatus->change_start(bl, SC_COMA, skill_lv, skill_lv, 0, src->id, 0, 0, 0); - }else if( sd ) + if( status->get_lv(bl) <= status->get_lv(src) ) + status->change_start(bl, SC_COMA, skill_lv, skill_lv, 0, src->id, 0, 0, 0); + } else if( sd ) clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0); break; @@ -9238,119 +9151,121 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui status_change_end(bl, SC_MARIONETTE_MASTER, INVALID_TIMER); status_change_end(bl, SC_HARMONIZE, INVALID_TIMER); } - if( skill_area_temp[2] == 1 ){ + if( skill->area_temp[2] == 1 ){ clif->skill_damage(src,src,tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6); sc_start(src, SC_STOP, 100, skill_lv, skill->get_time(skill_id, skill_lv)); } - }else{ - skill_area_temp[2] = 0; - iMap->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY|SD_SPLASH|1, skill->castend_nodamage_id); + } else { + skill->area_temp[2] = 0; + map->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY|SD_SPLASH|1, skill->castend_nodamage_id); } break; - case MH_SILENT_BREEZE: { - struct status_change *ssc = iStatus->get_sc(src); + case MH_SILENT_BREEZE: + { + struct status_change *ssc = status->get_sc(src); struct block_list *m_bl = battle->get_master(src); - const enum sc_type scs[] = { - SC_MANDRAGORA, SC_HARMONIZE, SC_DEEP_SLEEP, SC_SIREN, SC_SLEEP, SC_CONFUSION, SC_ILLUSION - }; - int heal; - if(tsc){ - for (i = 0; i < ARRAYLENGTH(scs); i++) { - if (tsc->data[scs[i]]) status_change_end(bl, scs[i], INVALID_TIMER); - } - if (!tsc->data[SC_SILENCE]) //put inavoidable silence on target - iStatus->change_start(bl, SC_SILENCE, 100, skill_lv, 0,0,0, skill->get_time(skill_id, skill_lv),1|2|8); + const enum sc_type scs[] = { + SC_MANDRAGORA, SC_HARMONIZE, SC_DEEP_SLEEP, SC_SIREN, SC_SLEEP, SC_CONFUSION, SC_ILLUSION + }; + int heal; + if(tsc){ + for (i = 0; i < ARRAYLENGTH(scs); i++) { + if (tsc->data[scs[i]]) status_change_end(bl, scs[i], INVALID_TIMER); + } + if (!tsc->data[SC_SILENCE]) //put inavoidable silence on target + status->change_start(bl, SC_SILENCE, 100, skill_lv, 0,0,0, skill->get_time(skill_id, skill_lv),1|2|8); } heal = status_get_matk_min(src)*4; - iStatus->heal(bl, heal, 0, 7); + status->heal(bl, heal, 0, 7); //now inflict silence on everyone if(ssc && !ssc->data[SC_SILENCE]) //put inavoidable silence on homun - iStatus->change_start(src, SC_SILENCE, 100, skill_lv, 0,0,0, skill->get_time(skill_id, skill_lv),1|2|8); + status->change_start(src, SC_SILENCE, 100, skill_lv, 0,0,0, skill->get_time(skill_id, skill_lv),1|2|8); if(m_bl){ - struct status_change *msc = iStatus->get_sc(m_bl); - if(msc && !msc->data[SC_SILENCE]) //put inavoidable silence on master - iStatus->change_start(m_bl, SC_SILENCE, 100, skill_lv, 0,0,0, skill->get_time(skill_id, skill_lv),1|2|8); + struct status_change *msc = status->get_sc(m_bl); + if(msc && !msc->data[SC_SILENCE]) //put inavoidable silence on master + status->change_start(m_bl, SC_SILENCE, 100, skill_lv, 0,0,0, skill->get_time(skill_id, skill_lv),1|2|8); } - if (hd) - skill->blockhomun_start(hd, skill_id, skill->get_cooldown(skill_id, skill_lv)); - } - break; - case MH_OVERED_BOOST: - if (hd){ - struct block_list *s_bl = battle->get_master(src); - if(hd->homunculus.hunger>50) //reduce hunger - hd->homunculus.hunger = hd->homunculus.hunger/2; - else - hd->homunculus.hunger = min(1,hd->homunculus.hunger); - if(s_bl && s_bl->type==BL_PC){ - iStatus->set_sp(s_bl,status_get_max_sp(s_bl)/2,0); //master drain 50% sp - clif->send_homdata(((TBL_PC *)s_bl), SP_HUNGRY, hd->homunculus.hunger); //refresh hunger info - sc_start(s_bl, type, 100, skill_lv, skill->get_time(skill_id, skill_lv)); //gene bonus - } - sc_start(bl, type, 100, skill_lv, skill->get_time(skill_id, skill_lv)); - skill->blockhomun_start(hd, skill_id, skill->get_cooldown(skill_id, skill_lv)); - } - break; - case MH_GRANITIC_ARMOR: - case MH_PYROCLASTIC: { - struct block_list *s_bl = battle->get_master(src); - if(s_bl) - sc_start2(s_bl, type, 100, skill_lv, hd->homunculus.level, skill->get_time(skill_id, skill_lv)); //start on master - sc_start2(bl, type, 100, skill_lv, hd->homunculus.level, skill->get_time(skill_id, skill_lv)); - if (hd) - skill->blockhomun_start(hd, skill_id, skill->get_cooldown(skill_id, skill_lv)); + if (hd) + skill->blockhomun_start(hd, skill_id, skill->get_cooldown(skill_id, skill_lv)); + } + break; + case MH_OVERED_BOOST: + if (hd) { + struct block_list *s_bl = battle->get_master(src); + if(hd->homunculus.hunger>50) //reduce hunger + hd->homunculus.hunger = hd->homunculus.hunger/2; + else + hd->homunculus.hunger = min(1,hd->homunculus.hunger); + if(s_bl && s_bl->type==BL_PC) { + status->set_sp(s_bl,status_get_max_sp(s_bl)/2,0); //master drain 50% sp + clif->send_homdata(((TBL_PC *)s_bl), SP_HUNGRY, hd->homunculus.hunger); //refresh hunger info + sc_start(s_bl, type, 100, skill_lv, skill->get_time(skill_id, skill_lv)); //gene bonus } - break; + sc_start(bl, type, 100, skill_lv, skill->get_time(skill_id, skill_lv)); + skill->blockhomun_start(hd, skill_id, skill->get_cooldown(skill_id, skill_lv)); + } + break; + case MH_GRANITIC_ARMOR: + case MH_PYROCLASTIC: + { + struct block_list *s_bl = battle->get_master(src); + if(s_bl) + sc_start2(s_bl, type, 100, skill_lv, hd->homunculus.level, skill->get_time(skill_id, skill_lv)); //start on master + sc_start2(bl, type, 100, skill_lv, hd->homunculus.level, skill->get_time(skill_id, skill_lv)); + if (hd) + skill->blockhomun_start(hd, skill_id, skill->get_cooldown(skill_id, skill_lv)); + } + break; - case MH_LIGHT_OF_REGENE: - if(hd){ + case MH_LIGHT_OF_REGENE: + if(hd) { hd->homunculus.intimacy = 251; //change to neutral (can't be cast if < 750) if(sd) clif->send_homdata(sd, SP_INTIMATE, hd->homunculus.intimacy); //refresh intimacy info } //don't break need to start status and start block timer - case MH_MAGMA_FLOW: - case MH_PAIN_KILLER: - sc_start(bl, type, 100, skill_lv, skill->get_time(skill_id, skill_lv)); - if (hd) - skill->blockhomun_start(hd, skill_id, skill->get_cooldown(skill_id, skill_lv)); - break; - case MH_SUMMON_LEGION: - { - int summons[5] = {1004, 1303, 1303, 1994, 1994}; - int qty[5] = {3 , 3 , 4 , 4 , 5}; - struct mob_data *md; - int i, dummy = 0; + case MH_MAGMA_FLOW: + case MH_PAIN_KILLER: + sc_start(bl, type, 100, skill_lv, skill->get_time(skill_id, skill_lv)); + if (hd) + skill->blockhomun_start(hd, skill_id, skill->get_cooldown(skill_id, skill_lv)); + break; + case MH_SUMMON_LEGION: + { + int summons[5] = {1004, 1303, 1303, 1994, 1994}; + int qty[5] = {3 , 3 , 4 , 4 , 5}; + struct mob_data *md; + int i, dummy = 0; - i = iMap->foreachinmap(skill->check_condition_mob_master_sub ,hd->bl.m, BL_MOB, hd->bl.id, summons[skill_lv-1], skill_id, &dummy); - if(i >= qty[skill_lv-1]) - break; - - for(i=0; i<qty[skill_lv - 1]; i++){ //easy way - md = mob->once_spawn_sub(src, src->m, src->x, src->y, iStatus->get_name(src), summons[skill_lv - 1], "", SZ_SMALL, AI_ATTACK); - if (md) { - md->master_id = src->id; - if (md->deletetimer != INVALID_TIMER) - timer->delete(md->deletetimer, mob->timer_delete); - md->deletetimer = timer->add(timer->gettick() + skill->get_time(skill_id, skill_lv), mob->timer_delete, md->bl.id, 0); - mob->spawn(md); //Now it is ready for spawning. - sc_start4(&md->bl, SC_MODECHANGE, 100, 1, 0, MD_CANATTACK|MD_AGGRESSIVE, 0, 60000); - } - } - if (hd) - skill->blockhomun_start(hd, skill_id, skill->get_cooldown(skill_id, skill_lv)); - } + i = map->foreachinmap(skill->check_condition_mob_master_sub ,hd->bl.m, BL_MOB, hd->bl.id, summons[skill_lv-1], skill_id, &dummy); + if(i >= qty[skill_lv-1]) break; + + for(i=0; i<qty[skill_lv - 1]; i++){ //easy way + md = mob->once_spawn_sub(src, src->m, src->x, src->y, status->get_name(src), summons[skill_lv - 1], "", SZ_SMALL, AI_ATTACK); + if (md) { + md->master_id = src->id; + if (md->deletetimer != INVALID_TIMER) + timer->delete(md->deletetimer, mob->timer_delete); + md->deletetimer = timer->add(timer->gettick() + skill->get_time(skill_id, skill_lv), mob->timer_delete, md->bl.id, 0); + mob->spawn(md); //Now it is ready for spawning. + sc_start4(&md->bl, SC_MODECHANGE, 100, 1, 0, MD_CANATTACK|MD_AGGRESSIVE, 0, 60000); + } + } + if (hd) + skill->blockhomun_start(hd, skill_id, skill->get_cooldown(skill_id, skill_lv)); + } + break; default: ShowWarning("skill_castend_nodamage_id: Unknown skill used:%d\n",skill_id); clif->skill_nodamage(src,bl,skill_id,skill_lv,1); - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 1; } - if(skill_id != SR_CURSEDCIRCLE){ - struct status_change *sc = iStatus->get_sc(src); + if(skill_id != SR_CURSEDCIRCLE) { + struct status_change *sc = status->get_sc(src); if( sc && sc->data[SC_CURSEDCIRCLE_ATKER] )//Should only remove after the skill had been casted. status_change_end(src,SC_CURSEDCIRCLE_ATKER,INVALID_TIMER); } @@ -9371,16 +9286,15 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui skill->consume_requirement(sd,skill_id,skill_lv,2); } - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 0; } /*========================================== * *------------------------------------------*/ -int skill_castend_pos(int tid, unsigned int tick, int id, intptr_t data) -{ - struct block_list* src = iMap->id2bl(id); +int skill_castend_pos(int tid, unsigned int tick, int id, intptr_t data) { + struct block_list* src = map->id2bl(id); int maxcount; struct map_session_data *sd; struct unit_data *ud = unit->bl2ud(src); @@ -9411,7 +9325,7 @@ int skill_castend_pos(int tid, unsigned int tick, int id, intptr_t data) ud->skilltimer = INVALID_TIMER; do { - if( iStatus->isdead(src) ) + if( status->isdead(src) ) break; if( !(src->type&battle_config.skill_reiteration) && @@ -9445,9 +9359,9 @@ int skill_castend_pos(int tid, unsigned int tick, int id, intptr_t data) } } - if(tid != INVALID_TIMER) - { //Avoid double checks on instant cast skills. [Skotlex] - if (!iStatus->check_skilluse(src, NULL, ud->skill_id, 1)) + if(tid != INVALID_TIMER) { + //Avoid double checks on instant cast skills. [Skotlex] + if (!status->check_skilluse(src, NULL, ud->skill_id, 1)) break; if(battle_config.skill_add_range && !check_distance_blxy(src, ud->skillx, ud->skilly, skill->get_range2(src,ud->skill_id,ud->skill_lv)+battle_config.skill_add_range)) { @@ -9507,7 +9421,7 @@ int skill_castend_pos(int tid, unsigned int tick, int id, intptr_t data) // } unit->set_walkdelay(src, tick, battle_config.default_walk_delay+skill->get_walkdelay(ud->skill_id, ud->skill_lv), 1); status_change_end(src,SC_CAMOUFLAGE, INVALID_TIMER);// only normal attack and auto cast skills benefit from its bonuses - iMap->freeblock_lock(); + map->freeblock_lock(); skill->castend_pos2(src,ud->skillx,ud->skilly,ud->skill_id,ud->skill_lv,tick,0); if( sd && sd->skillitem != AL_WARP ) // Warp-Portal thru items will clear data in skill_castend_map. [Inkfish] @@ -9519,7 +9433,7 @@ int skill_castend_pos(int tid, unsigned int tick, int id, intptr_t data) ud->skill_lv = ud->skillx = ud->skilly = 0; } - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 1; } while(0); @@ -9693,13 +9607,13 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui nullpo_ret(src); - if(iStatus->isdead(src)) + if(status->isdead(src)) return 0; sd = BL_CAST(BL_PC, src); - sc = iStatus->get_sc(src); - type = iStatus->skill2sc(skill_id); + sc = status->get_sc(src); + type = status->skill2sc(skill_id); sce = (sc && type != -1)?sc->data[type]:NULL; switch (skill_id) { //Skill effect. @@ -9722,40 +9636,40 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui switch(skill_id) { case PR_BENEDICTIO: - skill_area_temp[1] = src->id; + skill->area_temp[1] = src->id; i = skill->get_splash(skill_id, skill_lv); - iMap->foreachinarea(skill->area_sub, - src->m, x-i, y-i, x+i, y+i, BL_PC, - src, skill_id, skill_lv, tick, flag|BCT_ALL|1, - skill->castend_nodamage_id); - iMap->foreachinarea(skill->area_sub, - src->m, x-i, y-i, x+i, y+i, BL_CHAR, - src, skill_id, skill_lv, tick, flag|BCT_ENEMY|1, - skill->castend_damage_id); + map->foreachinarea(skill->area_sub, + src->m, x-i, y-i, x+i, y+i, BL_PC, + src, skill_id, skill_lv, tick, flag|BCT_ALL|1, + skill->castend_nodamage_id); + map->foreachinarea(skill->area_sub, + src->m, x-i, y-i, x+i, y+i, BL_CHAR, + src, skill_id, skill_lv, tick, flag|BCT_ENEMY|1, + skill->castend_damage_id); break; case BS_HAMMERFALL: i = skill->get_splash(skill_id, skill_lv); - iMap->foreachinarea (skill->area_sub, - src->m, x-i, y-i, x+i, y+i, BL_CHAR, - src, skill_id, skill_lv, tick, flag|BCT_ENEMY|2, - skill->castend_nodamage_id); + map->foreachinarea(skill->area_sub, + src->m, x-i, y-i, x+i, y+i, BL_CHAR, + src, skill_id, skill_lv, tick, flag|BCT_ENEMY|2, + skill->castend_nodamage_id); break; case HT_DETECTING: i = skill->get_splash(skill_id, skill_lv); - iMap->foreachinarea( iStatus->change_timer_sub, - src->m, x-i, y-i, x+i,y+i,BL_CHAR, - src,NULL,SC_SIGHT,tick); + map->foreachinarea(status->change_timer_sub, + src->m, x-i, y-i, x+i,y+i,BL_CHAR, + src,NULL,SC_SIGHT,tick); if(battle_config.traps_setting&1) - iMap->foreachinarea( skill_reveal_trap, - src->m, x-i, y-i, x+i,y+i,BL_SKILL); + map->foreachinarea(skill_reveal_trap, + src->m, x-i, y-i, x+i,y+i,BL_SKILL); break; case SR_RIDEINLIGHTNING: i = skill->get_splash(skill_id, skill_lv); - iMap->foreachinarea(skill->area_sub, src->m, x-i, y-i, x+i, y+i, BL_CHAR, - src, skill_id, skill_lv, tick, flag|BCT_ENEMY|1, skill->castend_damage_id); + map->foreachinarea(skill->area_sub, src->m, x-i, y-i, x+i, y+i, BL_CHAR, + src, skill_id, skill_lv, tick, flag|BCT_ENEMY|1, skill->castend_damage_id); break; case SA_VOLCANO: @@ -9895,7 +9809,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui if( sc->data[SC_BASILICA] ) status_change_end(src, SC_BASILICA, INVALID_TIMER); // Cancel Basilica else { // Create Basilica. Start SC on caster. Unit timer start SC on others. - if( iMap->foreachinrange(skill_count_wos, src, 2, BL_MOB|BL_PC, src) ) { + if( map->foreachinrange(skill_count_wos, src, 2, BL_MOB|BL_PC, src) ) { if( sd ) clif->skill_fail(sd,skill_id,USESKILL_FAIL,0); return 1; @@ -9916,7 +9830,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui break; case RG_CLEANER: // [Valaris] i = skill->get_splash(skill_id, skill_lv); - iMap->foreachinarea(skill->graffitiremover,src->m,x-i,y-i,x+i,y+i,BL_SKILL); + map->foreachinarea(skill->graffitiremover,src->m,x-i,y-i,x+i,y+i,BL_SKILL); break; case SO_WARMER: @@ -9988,7 +9902,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui struct mob_data *md; // Correct info, don't change any of this! [celest] - md = mob->once_spawn_sub(src, src->m, x, y, iStatus->get_name(src), class_, "", SZ_SMALL, AI_NONE); + md = mob->once_spawn_sub(src, src->m, x, y, status->get_name(src), class_, "", SZ_SMALL, AI_NONE); if (md) { md->master_id = src->id; md->special_state.ai = (skill_id == AM_SPHEREMINE) ? AI_SPHERE : AI_FLORA; @@ -10004,8 +9918,8 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui case CR_SLIMPITCHER: if (sd) { int i = skill_lv%11 - 1; - int j = pc->search_inventory(sd,skill_db[skill_id].itemid[i]); - if( j < 0 || skill_db[skill_id].itemid[i] <= 0 || sd->inventory_data[j] == NULL || sd->status.inventory[j].amount < skill_db[skill_id].amount[i] ) + int j = pc->search_inventory(sd,skill->db[skill_id].itemid[i]); + if( j < 0 || skill->db[skill_id].itemid[i] <= 0 || sd->inventory_data[j] == NULL || sd->status.inventory[j].amount < skill->db[skill_id].amount[i] ) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); return 1; @@ -10026,15 +9940,15 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui if(script->potion_hp > 0 || script->potion_sp > 0) { i = skill->get_splash(skill_id, skill_lv); - iMap->foreachinarea(skill->area_sub, - src->m,x-i,y-i,x+i,y+i,BL_CHAR, - src,skill_id,skill_lv,tick,flag|BCT_PARTY|BCT_GUILD|1, - skill->castend_nodamage_id); + map->foreachinarea(skill->area_sub, + src->m,x-i,y-i,x+i,y+i,BL_CHAR, + src,skill_id,skill_lv,tick,flag|BCT_PARTY|BCT_GUILD|1, + skill->castend_nodamage_id); } } else { int i = skill_lv%11 - 1; struct item_data *item; - i = skill_db[skill_id].itemid[i]; + i = skill->db[skill_id].itemid[i]; item = itemdb->search(i); script->potion_flag = 1; script->potion_hp = 0; @@ -10048,10 +9962,10 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui if(script->potion_hp > 0 || script->potion_sp > 0) { i = skill->get_splash(skill_id, skill_lv); - iMap->foreachinarea(skill->area_sub, - src->m,x-i,y-i,x+i,y+i,BL_CHAR, - src,skill_id,skill_lv,tick,flag|BCT_PARTY|BCT_GUILD|1, - skill->castend_nodamage_id); + map->foreachinarea(skill->area_sub, + src->m,x-i,y-i,x+i,y+i,BL_CHAR, + src,skill_id,skill_lv,tick,flag|BCT_PARTY|BCT_GUILD|1, + skill->castend_nodamage_id); } } break; @@ -10061,7 +9975,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui int dummy = 1; clif->skill_poseffect(src,skill_id,skill_lv,x,y,tick); i = skill->get_splash(skill_id, skill_lv); - iMap->foreachinarea(skill->cell_overlap, src->m, x-i, y-i, x+i, y+i, BL_SKILL, HW_GANBANTEIN, &dummy, src); + map->foreachinarea(skill->cell_overlap, src->m, x-i, y-i, x+i, y+i, BL_SKILL, HW_GANBANTEIN, &dummy, src); } else { if (sd) clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); return 1; @@ -10077,8 +9991,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui // Plant Cultivation [Celest] case CR_CULTIVATION: if (sd) { - if( iMap->count_oncell(src->m,x,y,BL_CHAR) > 0 ) - { + if( map->count_oncell(src->m,x,y,BL_CHAR) > 0 ) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); return 1; } @@ -10110,18 +10023,15 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui break; case PA_GOSPEL: - if (sce && sce->val4 == BCT_SELF) - { + if (sce && sce->val4 == BCT_SELF) { status_change_end(src, SC_GOSPEL, INVALID_TIMER); return 0; - } - else - { + } else { sg = skill->unitsetting(src,skill_id,skill_lv,src->x,src->y,0); if (!sg) break; if (sce) status_change_end(src, type, INVALID_TIMER); //Was under someone else's Gospel. [Skotlex] - iStatus->change_clear_buffs(src,3); + status->change_clear_buffs(src,3); sc_start4(src,type,100,skill_lv,0,sg->group_id,BCT_SELF,skill->get_time(skill_id,skill_lv)); clif->skill_poseffect(src, skill_id, skill_lv, 0, 0, tick); // PA_GOSPEL music packet } @@ -10147,14 +10057,14 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui case RK_DRAGONBREATH: case RK_DRAGONBREATH_WATER: i = skill->get_splash(skill_id,skill_lv); - iMap->foreachinarea(skill->area_sub,src->m,x-i,y-i,x+i,y+i,splash_target(src), - src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_damage_id); + map->foreachinarea(skill->area_sub,src->m,x-i,y-i,x+i,y+i,splash_target(src), + src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_damage_id); break; case SO_ARRULLO: i = skill->get_splash(skill_id,skill_lv); - iMap->foreachinarea(skill->area_sub,src->m,x-i,y-i,x+i,y+i,splash_target(src), - src, skill_id, skill_lv, tick, flag|BCT_ENEMY|1, skill->castend_nodamage_id); + map->foreachinarea(skill->area_sub,src->m,x-i,y-i,x+i,y+i,splash_target(src), + src, skill_id, skill_lv, tick, flag|BCT_ENEMY|1, skill->castend_nodamage_id); break; /** * Guilotine Cross @@ -10175,13 +10085,13 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui case AB_EPICLESIS: if( (sg = skill->unitsetting(src, skill_id, skill_lv, x, y, 0)) ) { i = sg->unit->range; - iMap->foreachinarea(skill->area_sub, src->m, x - i, y - i, x + i, y + i, BL_CHAR, src, ALL_RESURRECTION, 1, tick, flag|BCT_NOENEMY|1,skill->castend_nodamage_id); + map->foreachinarea(skill->area_sub, src->m, x - i, y - i, x + i, y + i, BL_CHAR, src, ALL_RESURRECTION, 1, tick, flag|BCT_NOENEMY|1,skill->castend_nodamage_id); } break; case WL_EARTHSTRAIN: { - int i, wave = skill_lv + 4, dir = iMap->calc_dir(src,x,y); + int i, wave = skill_lv + 4, dir = map->calc_dir(src,x,y); int sx = x = src->x, sy = y = src->y; // Store first caster's location to avoid glitch on unit setting for( i = 1; i <= wave; i++ ) @@ -10201,7 +10111,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui **/ case RA_DETONATOR: i = skill->get_splash(skill_id, skill_lv); - iMap->foreachinarea(skill->detonator, src->m, x-i, y-i, x+i, y+i, BL_SKILL, src); + map->foreachinarea(skill->detonator, src->m, x-i, y-i, x+i, y+i, BL_SKILL, src); clif->skill_damage(src, src, tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6); break; /** @@ -10221,9 +10131,8 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui int class_ = 2042; struct mob_data *md; - md = mob->once_spawn_sub(src, src->m, x, y, iStatus->get_name(src), class_, "", SZ_SMALL, AI_NONE); - if( md ) - { + md = mob->once_spawn_sub(src, src->m, x, y, status->get_name(src), class_, "", SZ_SMALL, AI_NONE); + if( md ) { md->master_id = src->id; md->special_state.ai = AI_FLORA; if( md->deletetimer != INVALID_TIMER ) @@ -10256,10 +10165,10 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui int width;//according to data from irowiki it actually is a square for( width = 0; width < 7; width++ ) for( i = 0; i < 7; i++ ) - iMap->foreachincell(skill->area_sub, src->m, x-2+i, y-2+width, splash_target(src), src, LG_OVERBRAND_BRANDISH, skill_lv, tick, flag|BCT_ENEMY,skill->castend_damage_id); + map->foreachincell(skill->area_sub, src->m, x-2+i, y-2+width, splash_target(src), src, LG_OVERBRAND_BRANDISH, skill_lv, tick, flag|BCT_ENEMY,skill->castend_damage_id); for( width = 0; width < 7; width++ ) for( i = 0; i < 7; i++ ) - iMap->foreachincell(skill->area_sub, src->m, x-2+i, y-2+width, splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY,skill->castend_damage_id); + map->foreachincell(skill->area_sub, src->m, x-2+i, y-2+width, splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY,skill->castend_damage_id); } break; @@ -10274,9 +10183,9 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui break; case LG_RAYOFGENESIS: - if( iStatus->charge(src,status_get_max_hp(src)*3*skill_lv / 100,0) ) { + if( status->charge(src,status_get_max_hp(src)*3*skill_lv / 100,0) ) { i = skill->get_splash(skill_id,skill_lv); - iMap->foreachinarea(skill->area_sub,src->m,x-i,y-i,x+i,y+i,splash_target(src), + map->foreachinarea(skill->area_sub,src->m,x-i,y-i,x+i,y+i,splash_target(src), src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_damage_id); } else if( sd ) clif->skill_fail(sd,skill_id,USESKILL_FAIL,0); @@ -10284,13 +10193,13 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui case WM_DOMINION_IMPULSE: i = skill->get_splash(skill_id, skill_lv); - iMap->foreachinarea( skill->activate_reverberation, + map->foreachinarea( skill->activate_reverberation, src->m, x-i, y-i, x+i,y+i,BL_SKILL); break; case WM_GREAT_ECHO: flag|=1; // Should counsume 1 item per skill usage. - iMap->foreachinrange(skill->area_sub, src, skill->get_splash(skill_id,skill_lv),splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY, skill->castend_damage_id); + map->foreachinrange(skill->area_sub, src, skill->get_splash(skill_id,skill_lv),splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY, skill->castend_damage_id); break; case GN_CRAZYWEED: { int area = skill->get_splash(GN_CRAZYWEED_ATK, skill_lv); @@ -10322,10 +10231,10 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui clif->changetraplook(&ud->skillunit[i]->unit->bl, UNT_FIRE_EXPANSION_TEAR_GAS); break; case 5: - iMap->foreachinarea(skill->area_sub, src->m, - ud->skillunit[i]->unit->bl.x - 3, ud->skillunit[i]->unit->bl.y - 3, - ud->skillunit[i]->unit->bl.x + 3, ud->skillunit[i]->unit->bl.y + 3, BL_CHAR, - src, CR_ACIDDEMONSTRATION, sd ? pc->checkskill(sd, CR_ACIDDEMONSTRATION) : skill_lv, tick, flag|BCT_ENEMY|1|SD_LEVEL, skill->castend_damage_id); + map->foreachinarea(skill->area_sub, src->m, + ud->skillunit[i]->unit->bl.x - 3, ud->skillunit[i]->unit->bl.y - 3, + ud->skillunit[i]->unit->bl.x + 3, ud->skillunit[i]->unit->bl.y + 3, BL_CHAR, + src, CR_ACIDDEMONSTRATION, sd ? pc->checkskill(sd, CR_ACIDDEMONSTRATION) : skill_lv, tick, flag|BCT_ENEMY|1|SD_LEVEL, skill->castend_damage_id); skill->delunit(ud->skillunit[i]->unit); break; default: @@ -10413,7 +10322,7 @@ int skill_dance_overlap(struct skill_unit* su, int flag) { su->val2 &= ~UF_ENSEMBLE; } - return iMap->foreachincell(skill->dance_overlap_sub, su->bl.m,su->bl.x,su->bl.y,BL_SKILL, su,flag); + return map->foreachincell(skill->dance_overlap_sub, su->bl.m,su->bl.x,su->bl.y,BL_SKILL, su,flag); } /*========================================== @@ -10476,7 +10385,7 @@ int skill_icewall_block(struct block_list *bl,va_list ap) { nullpo_ret(bl); nullpo_ret(md); - if( !md->target_id || ( target = iMap->id2bl(md->target_id) ) == NULL ) + if( !md->target_id || ( target = map->id2bl(md->target_id) ) == NULL ) return 0; if( path->search_long(NULL,bl->m,bl->x,bl->y,target->x,target->y,CELL_CHKICEWALL) ) @@ -10522,8 +10431,8 @@ struct skill_unit_group* skill_unitsetting(struct block_list *src, uint16 skill_ } sd = BL_CAST(BL_PC, src); - st = iStatus->get_status_data(src); - sc = iStatus->get_sc(src); // for traps, firewall and fogwall - celest + st = status->get_status_data(src); + sc = status->get_sc(src); // for traps, firewall and fogwall - celest switch( skill_id ) { case MH_STEINWAND: @@ -10553,7 +10462,7 @@ struct skill_unit_group* skill_unitsetting(struct block_list *src, uint16 skill_ { //Warp Portal morphing to active mode, extract relevant data from src. [Skotlex] if( src->type != BL_SKILL ) return NULL; group = ((TBL_SKILL*)src)->group; - src = iMap->id2bl(group->src_id); + src = map->id2bl(group->src_id); if( !src ) return NULL; val2 = group->val2; //Copy the (x,y) position you warp to val3 = group->val3; //as well as the mapindex to warp to. @@ -10569,7 +10478,7 @@ struct skill_unit_group* skill_unitsetting(struct block_list *src, uint16 skill_ break; case WZ_FIREPILLAR: - if( iMap->getcell(src->m, x, y, CELL_CHKLANDPROTECTOR) ) + if( map->getcell(src->m, x, y, CELL_CHKLANDPROTECTOR) ) return NULL; if((flag&1)!=0) limit=1000; @@ -10808,8 +10717,8 @@ struct skill_unit_group* skill_unitsetting(struct block_list *src, uint16 skill_ case WM_REVERBERATION: interval = limit; val2 = 1; - case WM_POEMOFNETHERWORLD: // Can't be placed on top of Land Protector. - if( iMap->getcell(src->m, x, y, CELL_CHKLANDPROTECTOR) ) + case WM_POEMOFNETHERWORLD: // Can't be placed on top of Land Protector. + if( map->getcell(src->m, x, y, CELL_CHKLANDPROTECTOR) ) return NULL; break; case SO_CLOUD_KILL: @@ -10884,7 +10793,7 @@ struct skill_unit_group* skill_unitsetting(struct block_list *src, uint16 skill_ int val2 = 0; int alive = 1; - if( !group->state.song_dance && !iMap->getcell(src->m,ux,uy,CELL_CHKREACH) ) + if( !group->state.song_dance && !map->getcell(src->m,ux,uy,CELL_CHKREACH) ) continue; // don't place skill units on walls (except for songs/dances/encores) if( battle_config.skill_wall_check && skill->get_unit_flag(skill_id)&UF_PATHCHECK && !path->search_long(NULL,src->m,ux,uy,x,y,CELL_CHKWALL) ) continue; // no path between cell and center of casting. @@ -10896,7 +10805,7 @@ struct skill_unit_group* skill_unitsetting(struct block_list *src, uint16 skill_ break; case WZ_ICEWALL: val1 = (skill_lv <= 1) ? 500 : 200 + 200*skill_lv; - val2 = iMap->getcell(src->m, ux, uy, CELL_GETTYPE); + val2 = map->getcell(src->m, ux, uy, CELL_GETTYPE); break; case HT_LANDMINE: case MA_LANDMINE: @@ -10948,11 +10857,11 @@ struct skill_unit_group* skill_unitsetting(struct block_list *src, uint16 skill_ if (skill->get_unit_flag(skill_id) & UF_RANGEDSINGLEUNIT && i == (layout->count / 2)) val2 |= UF_RANGEDSINGLEUNIT; // center. - if( sd && iMap->getcell(src->m, ux, uy, CELL_CHKMAELSTROM) ) //Does not recover SP from monster skills - iMap->foreachincell(skill->maelstrom_suction,src->m,ux,uy,BL_SKILL,skill_id,skill_lv); + if( sd && map->getcell(src->m, ux, uy, CELL_CHKMAELSTROM) ) //Does not recover SP from monster skills + map->foreachincell(skill->maelstrom_suction,src->m,ux,uy,BL_SKILL,skill_id,skill_lv); if( range <= 0 ) - iMap->foreachincell(skill->cell_overlap,src->m,ux,uy,BL_SKILL,skill_id, &alive, src); + map->foreachincell(skill->cell_overlap,src->m,ux,uy,BL_SKILL,skill_id, &alive, src); if( !alive ) continue; @@ -10968,10 +10877,11 @@ struct skill_unit_group* skill_unitsetting(struct block_list *src, uint16 skill_ // execute on all targets standing on this cell if (range==0 && active_flag) - iMap->foreachincell(skill->unit_effect,su->bl.m,su->bl.x,su->bl.y,group->bl_flag,&su->bl,timer->gettick(),1); + map->foreachincell(skill->unit_effect,su->bl.m,su->bl.x,su->bl.y,group->bl_flag,&su->bl,timer->gettick(),1); } - if (!group->alive_count) { //No cells? Something that was blocked completely by Land Protector? + if (!group->alive_count) { + //No cells? Something that was blocked completely by Land Protector? skill->del_unitgroup(group,ALC_MARK); return NULL; } @@ -10979,7 +10889,7 @@ struct skill_unit_group* skill_unitsetting(struct block_list *src, uint16 skill_ //success, unit created. switch( skill_id ) { case WZ_ICEWALL: - iMap->foreachinrange(skill->icewall_block, src, AREA_SIZE, BL_MOB); + map->foreachinrange(skill->icewall_block, src, AREA_SIZE, BL_MOB); break; case NJ_TATAMIGAESHI: //Store number of tiles. group->val1 = group->alive_count; @@ -11003,22 +10913,22 @@ int skill_unit_onplace (struct skill_unit *src, struct block_list *bl, unsigned nullpo_ret(src); nullpo_ret(bl); - if(bl->prev==NULL || !src->alive || iStatus->isdead(bl)) + if(bl->prev==NULL || !src->alive || status->isdead(bl)) return 0; nullpo_ret(sg=src->group); - nullpo_ret(ss=iMap->id2bl(sg->src_id)); + nullpo_ret(ss=map->id2bl(sg->src_id)); - if( skill->get_type(sg->skill_id) == BF_MAGIC && iMap->getcell(bl->m, bl->x, bl->y, CELL_CHKLANDPROTECTOR) && sg->skill_id != SA_LANDPROTECTOR ) + if( skill->get_type(sg->skill_id) == BF_MAGIC && map->getcell(bl->m, bl->x, bl->y, CELL_CHKLANDPROTECTOR) && sg->skill_id != SA_LANDPROTECTOR ) return 0; //AoE skills are ineffective. [Skotlex] - if( iMap->getcell(bl->m, bl->x, bl->y, CELL_CHKMAELSTROM) ) + if( map->getcell(bl->m, bl->x, bl->y, CELL_CHKMAELSTROM) ) return 0; - sc = iStatus->get_sc(bl); + sc = status->get_sc(bl); if (sc && sc->option&OPTION_HIDE && sg->skill_id != WZ_HEAVENDRIVE && sg->skill_id != WL_EARTHSTRAIN ) return 0; //Hidden characters are immune to AoE skills except to these. [Skotlex] - type = iStatus->skill2sc(sg->skill_id); + type = status->skill2sc(sg->skill_id); sce = (sc && type != -1)?sc->data[type]:NULL; skill_id = sg->skill_id; //In case the group is deleted, we need to return the correct skill id, still. switch (sg->unit_id) { @@ -11029,11 +10939,11 @@ int skill_unit_onplace (struct skill_unit *src, struct block_list *bl, unsigned break; } else if( sc && battle->check_target(&sg->unit->bl,bl,sg->target_flag) > 0 ) { int sec = skill->get_time2(sg->skill_id,sg->skill_lv); - if( iStatus->change_start(bl,type,10000,sg->skill_lv,1,sg->group_id,0,sec,8) ) { + if( status->change_start(bl,type,10000,sg->skill_lv,1,sg->group_id,0,sec,8) ) { const struct TimerData* td = sc->data[type]?timer->get(sc->data[type]->timer):NULL; if( td ) sec = DIFF_TICK(td->tick, tick); - iMap->moveblock(bl, src->bl.x, src->bl.y, tick); + map->moveblock(bl, src->bl.x, src->bl.y, tick); clif->fixpos(bl); sg->val2 = bl->id; } @@ -11075,7 +10985,7 @@ int skill_unit_onplace (struct skill_unit *src, struct block_list *bl, unsigned if( --count <= 0 ) skill->del_unitgroup(sg,ALC_MARK); - if ( iMap->mapindex2mapid(sg->val3) == sd->bl.m && x == sd->bl.x && y == sd->bl.y ) + if ( map->mapindex2mapid(sg->val3) == sd->bl.m && x == sd->bl.x && y == sd->bl.y ) working = 1;/* we break it because officials break it, lovely stuff. */ sg->val1 = (count<<16)|working; @@ -11083,7 +10993,7 @@ int skill_unit_onplace (struct skill_unit *src, struct block_list *bl, unsigned pc->setpos(sd,m,x,y,CLR_TELEPORT); } } else if(bl->type == BL_MOB && battle_config.mob_warp&2) { - int16 m = iMap->mapindex2mapid(sg->val3); + int16 m = map->mapindex2mapid(sg->val3); if (m < 0) break; //Map not available on this map-server. unit->warp(bl,m,sg->val2>>16,sg->val2&0xffff,CLR_TELEPORT); } @@ -11111,7 +11021,7 @@ int skill_unit_onplace (struct skill_unit *src, struct block_list *bl, unsigned case UNT_HERMODE: if (sg->src_id!=bl->id && battle->check_target(&src->bl,bl,BCT_PARTY|BCT_GUILD) > 0) - iStatus->change_clear_buffs(bl,1); //Should dispell only allies. + status->change_clear_buffs(bl,1); //Should dispell only allies. case UNT_RICHMANKIM: case UNT_ETERNALCHAOS: case UNT_DRUMBATTLEFIELD: @@ -11142,8 +11052,8 @@ int skill_unit_onplace (struct skill_unit *src, struct block_list *bl, unsigned else if (sce->val4 == 1) { //Readjust timers since the effect will not last long. sce->val4 = 0; - timer->delete(sce->timer, iStatus->change_timer); - sce->timer = timer->add(tick+sg->limit, iStatus->change_timer, bl->id, type); + timer->delete(sce->timer, status->change_timer); + sce->timer = timer->add(tick+sg->limit, status->change_timer, bl->id, type); } break; @@ -11217,19 +11127,19 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns nullpo_ret(src); nullpo_ret(bl); - if (bl->prev==NULL || !src->alive || iStatus->isdead(bl)) + if (bl->prev==NULL || !src->alive || status->isdead(bl)) return 0; nullpo_ret(sg=src->group); - nullpo_ret(ss=iMap->id2bl(sg->src_id)); + nullpo_ret(ss=map->id2bl(sg->src_id)); tsd = BL_CAST(BL_PC, bl); - tsc = iStatus->get_sc(bl); + tsc = status->get_sc(bl); if ( tsc && tsc->data[SC_HOVERING] ) return 0; //Under hovering characters are immune to trap and ground target skills. - tstatus = iStatus->get_status_data(bl); - type = iStatus->skill2sc(sg->skill_id); + tstatus = status->get_status_data(bl); + type = status->skill2sc(sg->skill_id); skill_id = sg->skill_id; if (sg->interval == -1) { @@ -11253,7 +11163,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns ts->tick = tick+sg->interval; if ((skill_id==CR_GRANDCROSS || skill_id==NPC_GRANDDARKNESS) && !battle_config.gx_allhit) - ts->tick += sg->interval*(iMap->count_oncell(bl->m,bl->x,bl->y,BL_CHAR)-1); + ts->tick += sg->interval*(map->count_oncell(bl->m,bl->x,bl->y,BL_CHAR)-1); } switch (sg->unit_id) { @@ -11268,8 +11178,8 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns //Take into account these hit more times than the timer interval can handle. do skill->attack(BF_MAGIC,ss,&src->bl,bl,sg->skill_id,sg->skill_lv,tick+count*sg->interval,0); - while(--src->val2 && x == bl->x && y == bl->y && - ++count < SKILLUNITTIMER_INTERVAL/sg->interval && !iStatus->isdead(bl)); + while(--src->val2 && x == bl->x && y == bl->y + && ++count < SKILLUNITTIMER_INTERVAL/sg->interval && !status->isdead(bl)); if (src->val2<=0) skill->delunit(src); @@ -11292,12 +11202,12 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns break; if( tstatus->hp >= tstatus->max_hp ) break; - if( iStatus->isimmune(bl) ) + if( status->isimmune(bl) ) heal = 0; clif->skill_nodamage(&src->bl, bl, AL_HEAL, heal, 1); if( tsc && tsc->data[SC_AKAITSUKI] && heal ) heal = ~heal + 1; - iStatus->heal(bl, heal, 0, 0); + status->heal(bl, heal, 0, 0); if( diff >= 500 ) sg->val1--; } @@ -11307,18 +11217,18 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns case UNT_EVILLAND: //Will heal demon and undead element monsters, but not players. - if ((bl->type == BL_PC) || (!battle->check_undead(tstatus->race, tstatus->def_ele) && tstatus->race!=RC_DEMON)) - { //Damage enemies + if ((bl->type == BL_PC) || (!battle->check_undead(tstatus->race, tstatus->def_ele) && tstatus->race!=RC_DEMON)) { + //Damage enemies if(battle->check_target(&src->bl,bl,BCT_ENEMY)>0) skill->attack(BF_MISC, ss, &src->bl, bl, sg->skill_id, sg->skill_lv, tick, 0); } else { int heal = skill->calc_heal(ss,bl,sg->skill_id,sg->skill_lv,true); if (tstatus->hp >= tstatus->max_hp) break; - if (iStatus->isimmune(bl)) + if (status->isimmune(bl)) heal = 0; clif->skill_nodamage(&src->bl, bl, AL_HEAL, heal, 1); - iStatus->heal(bl, heal, 0, 0); + status->heal(bl, heal, 0, 0); } break; @@ -11329,8 +11239,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns break; case UNT_DUMMYSKILL: - switch (sg->skill_id) - { + switch (sg->skill_id) { case SG_SUN_WARM: //SG skills [Komurka] case SG_MOON_WARM: case SG_STAR_WARM: @@ -11339,23 +11248,20 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns const int x = bl->x, y = bl->y; //If target isn't knocked back it should hit every "interval" ms [Playtester] - do - { + do { if( bl->type == BL_PC ) status_zap(bl, 0, 15); // sp damage to players - else // mobs - if( iStatus->charge(ss, 0, 2) ) // costs 2 SP per hit - { + else if( status->charge(ss, 0, 2) ) { // mobs + // costs 2 SP per hit if( !skill->attack(BF_WEAPON,ss,&src->bl,bl,sg->skill_id,sg->skill_lv,tick+count*sg->interval,0) ) - iStatus->charge(ss, 0, 8); //costs additional 8 SP if miss - } - else - { //should end when out of sp. + status->charge(ss, 0, 8); //costs additional 8 SP if miss + } else { // mobs + //should end when out of sp. sg->limit = DIFF_TICK(tick,sg->tick); break; } - } while( x == bl->x && y == bl->y && - ++count < SKILLUNITTIMER_INTERVAL/sg->interval && !iStatus->isdead(bl) ); + } while( x == bl->x && y == bl->y + && ++count < SKILLUNITTIMER_INTERVAL/sg->interval && !status->isdead(bl) ); } break; /** @@ -11402,7 +11308,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns case UNT_MANHOLE: if( sg->val2 == 0 && tsc && (sg->unit_id == UNT_ANKLESNARE || bl->id != sg->src_id) ) { int sec = skill->get_time2(sg->skill_id,sg->skill_lv); - if( iStatus->change_start(bl,type,10000,sg->skill_lv,sg->group_id,0,0,sec, 8) ) { + if( status->change_start(bl,type,10000,sg->skill_lv,sg->group_id,0,0,sec, 8) ) { const struct TimerData* td = tsc->data[type]?timer->get(tsc->data[type]->timer):NULL; if( td ) sec = DIFF_TICK(td->tick, tick); @@ -11432,21 +11338,20 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns if( bl->id != ss->id ) { if( status_get_mode(bl)&MD_BOSS ) break; - if( iStatus->change_start(bl,type,10000,sg->skill_lv,sg->group_id,0,0,skill->get_time2(sg->skill_id, sg->skill_lv), 8) ) { - - iMap->moveblock(bl, src->bl.x, src->bl.y, tick); + if( status->change_start(bl,type,10000,sg->skill_lv,sg->group_id,0,0,skill->get_time2(sg->skill_id, sg->skill_lv), 8) ) { + map->moveblock(bl, src->bl.x, src->bl.y, tick); clif->fixpos(bl); } - iMap->foreachinrange(skill->trap_splash, &src->bl, skill->get_splash(sg->skill_id, sg->skill_lv), sg->bl_flag, &src->bl, tick); + map->foreachinrange(skill->trap_splash, &src->bl, skill->get_splash(sg->skill_id, sg->skill_lv), sg->bl_flag, &src->bl, tick); sg->unit_id = UNT_USED_TRAPS; //Changed ID so it does not invoke a for each in area again. } break; case UNT_VENOMDUST: if(tsc && !tsc->data[type]) - iStatus->change_start(bl,type,10000,sg->skill_lv,sg->group_id,0,0,skill->get_time2(sg->skill_id,sg->skill_lv),0); + status->change_start(bl,type,10000,sg->skill_lv,sg->group_id,0,0,skill->get_time2(sg->skill_id,sg->skill_lv),0); break; @@ -11470,9 +11375,9 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns case UNT_FIREPILLAR_ACTIVE: case UNT_CLAYMORETRAP: if( sg->unit_id == UNT_FIRINGTRAP || sg->unit_id == UNT_ICEBOUNDTRAP || sg->unit_id == UNT_CLAYMORETRAP ) - iMap->foreachinrange(skill->trap_splash,&src->bl, skill->get_splash(sg->skill_id, sg->skill_lv), sg->bl_flag|BL_SKILL|~BCT_SELF, &src->bl,tick); + map->foreachinrange(skill->trap_splash,&src->bl, skill->get_splash(sg->skill_id, sg->skill_lv), sg->bl_flag|BL_SKILL|~BCT_SELF, &src->bl,tick); else - iMap->foreachinrange(skill->trap_splash,&src->bl, skill->get_splash(sg->skill_id, sg->skill_lv), sg->bl_flag, &src->bl,tick); + map->foreachinrange(skill->trap_splash,&src->bl, skill->get_splash(sg->skill_id, sg->skill_lv), sg->bl_flag, &src->bl,tick); if (sg->unit_id != UNT_FIREPILLAR_ACTIVE) clif->changetraplook(&src->bl, sg->unit_id==UNT_LANDMINE?UNT_FIREPILLAR_ACTIVE:UNT_USED_TRAPS); sg->limit=DIFF_TICK(tick,sg->tick)+1500 + @@ -11521,7 +11426,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns if( tsc->data[SC_AKAITSUKI] && heal ) heal = ~heal + 1; clif->skill_nodamage(&src->bl, bl, AL_HEAL, heal, 1); - iStatus->heal(bl, heal, 0, 0); + status->heal(bl, heal, 0, 0); break; } @@ -11538,15 +11443,14 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns int heal; int i = rnd()%13; // Positive buff count int time = skill->get_time2(sg->skill_id, sg->skill_lv); //Duration - switch (i) - { + switch (i) { case 0: // Heal 1~9999 HP heal = rnd() %9999+1; clif->skill_nodamage(ss,bl,AL_HEAL,heal,1); - iStatus->heal(bl,heal,0,0); + status->heal(bl,heal,0,0); break; case 1: // End all negative status - iStatus->change_clear_buffs(bl,2); + status->change_clear_buffs(bl,2); if (tsd) clif->gospel_info(tsd, 0x15); break; case 2: // Immunity to all status @@ -11660,9 +11564,9 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns case UNT_GROUNDDRIFT_POISON: case UNT_GROUNDDRIFT_WATER: case UNT_GROUNDDRIFT_FIRE: - iMap->foreachinrange(skill->trap_splash,&src->bl, - skill->get_splash(sg->skill_id, sg->skill_lv), sg->bl_flag, - &src->bl,tick); + map->foreachinrange(skill->trap_splash,&src->bl, + skill->get_splash(sg->skill_id, sg->skill_lv), sg->bl_flag, + &src->bl,tick); sg->unit_id = UNT_USED_TRAPS; //clif->changetraplook(&src->bl, UNT_FIREPILLAR_ACTIVE); sg->limit=DIFF_TICK(tick,sg->tick)+1500; @@ -11686,7 +11590,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns } hp = tstatus->max_hp * hp / 100; sp = tstatus->max_sp * sp / 100; - iStatus->heal(bl, hp, sp, 2); + status->heal(bl, hp, sp, 2); sc_start(bl, type, 100, sg->skill_lv, (sg->interval * 3) + 100); } // Reveal hidden players every 5 seconds. @@ -11717,7 +11621,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns case UNT_REVERBERATION: clif->changetraplook(&src->bl,UNT_USED_TRAPS); - iMap->foreachinrange(skill->trap_splash,&src->bl, skill->get_splash(sg->skill_id, sg->skill_lv), sg->bl_flag, &src->bl,tick); + map->foreachinrange(skill->trap_splash,&src->bl, skill->get_splash(sg->skill_id, sg->skill_lv), sg->bl_flag, &src->bl,tick); sg->limit = DIFF_TICK(tick,sg->tick)+1000; sg->unit_id = UNT_USED_TRAPS; break; @@ -11743,7 +11647,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns const struct TimerData* td = tsc->data[type]?timer->get(tsc->data[type]->timer):NULL; if( td ) sec = DIFF_TICK(td->tick, tick); - ///iMap->moveblock(bl, src->bl.x, src->bl.y, tick); // in official server it doesn't behave like this. [malufett] + ///map->moveblock(bl, src->bl.x, src->bl.y, tick); // in official server it doesn't behave like this. [malufett] clif->fixpos(bl); sg->val2 = bl->id; } else @@ -11775,11 +11679,11 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns break; case UNT_FIRE_EXPANSION_SMOKE_POWDER: - sc_start(bl, iStatus->skill2sc(GN_FIRE_EXPANSION_SMOKE_POWDER), 100, sg->skill_lv, 1000); + sc_start(bl, status->skill2sc(GN_FIRE_EXPANSION_SMOKE_POWDER), 100, sg->skill_lv, 1000); break; case UNT_FIRE_EXPANSION_TEAR_GAS: - sc_start(bl, iStatus->skill2sc(GN_FIRE_EXPANSION_TEAR_GAS), 100, sg->skill_lv, 1000); + sc_start(bl, status->skill2sc(GN_FIRE_EXPANSION_TEAR_GAS), 100, sg->skill_lv, 1000); break; case UNT_HELLS_PLANT: @@ -11791,21 +11695,21 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns case UNT_CLOUD_KILL: if(tsc && !tsc->data[type]) - iStatus->change_start(bl,type,10000,sg->skill_lv,sg->group_id,0,0,skill->get_time2(sg->skill_id,sg->skill_lv),8); + status->change_start(bl,type,10000,sg->skill_lv,sg->group_id,0,0,skill->get_time2(sg->skill_id,sg->skill_lv),8); skill->attack(skill->get_type(sg->skill_id),ss,&src->bl,bl,sg->skill_id,sg->skill_lv,tick,0); break; case UNT_WARMER: if( bl->type == BL_PC && !battle->check_undead(tstatus->race, tstatus->def_ele) && tstatus->race != RC_DEMON ) { int hp = 125 * sg->skill_lv; // Officially is 125 * skill_lv. - struct status_change *ssc = iStatus->get_sc(ss); + struct status_change *ssc = status->get_sc(ss); if( ssc && ssc->data[SC_HEATER_OPTION] ) hp += hp * ssc->data[SC_HEATER_OPTION]->val3 / 100; if( tstatus->hp != tstatus->max_hp ) clif->skill_nodamage(&src->bl, bl, AL_HEAL, hp, 0); if( tsc && tsc->data[SC_AKAITSUKI] && hp ) hp = ~hp + 1; - iStatus->heal(bl, hp, 0, 0); + status->heal(bl, hp, 0, 0); sc_start(bl, SC_WARMER, 100, sg->skill_lv, skill->get_time2(sg->skill_id,sg->skill_lv)); } break; @@ -11819,14 +11723,14 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns if (sg->unit_id != UNT_ZEPHYR && !battle->check_undead(tstatus->race, tstatus->def_ele)) { int hp = tstatus->max_hp / 100; //+1% each 5s if ((sg->val3) % 5) { //each 5s - if (tstatus->def_ele == skill->get_ele(sg->skill_id,sg->skill_lv)){ - iStatus->heal(bl, hp, 0, 2); - } else if((sg->unit_id == UNT_FIRE_INSIGNIA && tstatus->def_ele == ELE_EARTH) - ||(sg->unit_id == UNT_WATER_INSIGNIA && tstatus->def_ele == ELE_FIRE) - ||(sg->unit_id == UNT_WIND_INSIGNIA && tstatus->def_ele == ELE_WATER) - ||(sg->unit_id == UNT_EARTH_INSIGNIA && tstatus->def_ele == ELE_WIND) - ){ - iStatus->heal(bl, -hp, 0, 0); + if (tstatus->def_ele == skill->get_ele(sg->skill_id,sg->skill_lv)) { + status->heal(bl, hp, 0, 2); + } else if( (sg->unit_id == UNT_FIRE_INSIGNIA && tstatus->def_ele == ELE_EARTH) + || (sg->unit_id == UNT_WATER_INSIGNIA && tstatus->def_ele == ELE_FIRE) + || (sg->unit_id == UNT_WIND_INSIGNIA && tstatus->def_ele == ELE_WATER) + || (sg->unit_id == UNT_EARTH_INSIGNIA && tstatus->def_ele == ELE_WIND) + ) { + status->heal(bl, -hp, 0, 0); } } sg->val3++; //timer @@ -11904,7 +11808,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns case UNT_POISON_MIST: skill->attack(BF_MAGIC, ss, &src->bl, bl, sg->skill_id, sg->skill_lv, tick, 0); - iStatus->change_start(bl, SC_BLIND, rnd() % 100 > sg->skill_lv * 10, sg->skill_lv, sg->skill_id, 0, 0, skill->get_time2(sg->skill_id, sg->skill_lv), 2|8); + status->change_start(bl, SC_BLIND, rnd() % 100 > sg->skill_lv * 10, sg->skill_lv, sg->skill_id, 0, 0, skill->get_time2(sg->skill_id, sg->skill_lv), 2|8); break; } @@ -11925,12 +11829,13 @@ int skill_unit_onout (struct skill_unit *src, struct block_list *bl, unsigned in nullpo_ret(src); nullpo_ret(bl); nullpo_ret(sg=src->group); - sc = iStatus->get_sc(bl); - type = iStatus->skill2sc(sg->skill_id); + sc = status->get_sc(bl); + type = status->skill2sc(sg->skill_id); sce = (sc && type != -1)?sc->data[type]:NULL; - if( bl->prev==NULL || - (iStatus->isdead(bl) && sg->unit_id != UNT_ANKLESNARE && sg->unit_id != UNT_SPIDERWEB) ) //Need to delete the trap if the source died. + if( bl->prev == NULL + || (status->isdead(bl) && sg->unit_id != UNT_ANKLESNARE && sg->unit_id != UNT_SPIDERWEB) + ) //Need to delete the trap if the source died. return 0; switch(sg->unit_id){ @@ -11952,16 +11857,16 @@ int skill_unit_onout (struct skill_unit *src, struct block_list *bl, unsigned in status_change_end(bl, type, INVALID_TIMER); break; - case UNT_SPIDERWEB: { - struct block_list *target = iMap->id2bl(sg->val2); - if (target && target==bl) - { - if (sce && sce->val3 == sg->group_id) - status_change_end(bl, type, INVALID_TIMER); - sg->limit = DIFF_TICK(tick,sg->tick)+1000; - } - break; + case UNT_SPIDERWEB: + { + struct block_list *target = map->id2bl(sg->val2); + if (target && target==bl) { + if (sce && sce->val3 == sg->group_id) + status_change_end(bl, type, INVALID_TIMER); + sg->limit = DIFF_TICK(tick,sg->tick)+1000; } + } + break; } return sg->skill_id; } @@ -11969,17 +11874,16 @@ int skill_unit_onout (struct skill_unit *src, struct block_list *bl, unsigned in /*========================================== * Triggered when a char steps out of a skill group (entirely) [Skotlex] *------------------------------------------*/ -static int skill_unit_onleft (uint16 skill_id, struct block_list *bl, unsigned int tick) -{ +int skill_unit_onleft (uint16 skill_id, struct block_list *bl, unsigned int tick) { struct status_change *sc; struct status_change_entry *sce; enum sc_type type; - sc = iStatus->get_sc(bl); + sc = status->get_sc(bl); if (sc && !sc->count) sc = NULL; - type = iStatus->skill2sc(skill_id); + type = status->skill2sc(skill_id); sce = (sc && type != -1)?sc->data[type]:NULL; switch (skill_id) { @@ -12038,11 +11942,11 @@ static int skill_unit_onleft (uint16 skill_id, struct block_list *bl, unsigned i case DC_FORTUNEKISS: case DC_SERVICEFORYOU: if (sce) { - timer->delete(sce->timer, iStatus->change_timer); + timer->delete(sce->timer, status->change_timer); //NOTE: It'd be nice if we could get the skill_lv for a more accurate extra time, but alas... //not possible on our current implementation. sce->val4 = 1; //Store the fact that this is a "reduced" duration effect. - sce->timer = timer->add(tick+skill->get_time2(skill_id,1), iStatus->change_timer, bl->id, type); + sce->timer = timer->add(tick+skill->get_time2(skill_id,1), status->change_timer, bl->id, type); } break; case PF_FOGWALL: @@ -12052,8 +11956,8 @@ static int skill_unit_onleft (uint16 skill_id, struct block_list *bl, unsigned i if (bl->type == BL_PC) //Players get blind ended inmediately, others have it still for 30 secs. [Skotlex] status_change_end(bl, SC_BLIND, INVALID_TIMER); else { - timer->delete(sce->timer, iStatus->change_timer); - sce->timer = timer->add(30000+tick, iStatus->change_timer, bl->id, SC_BLIND); + timer->delete(sce->timer, status->change_timer); + sce->timer = timer->add(30000+tick, status->change_timer, bl->id, SC_BLIND); } } } @@ -12184,7 +12088,7 @@ int skill_check_condition_char_sub (struct block_list *bl, va_list ap) { switch(skill_id) { case PR_BENEDICTIO: { - uint8 dir = iMap->calc_dir(&sd->bl,tsd->bl.x,tsd->bl.y); + uint8 dir = map->calc_dir(&sd->bl,tsd->bl.x,tsd->bl.y); dir = (unit->getdir(&sd->bl) + dir)%8; //This adjusts dir to account for the direction the sd is facing. if ((tsd->class_&MAPID_BASEMASK) == MAPID_ACOLYTE && (dir == 2 || dir == 6) //Must be standing to the left/right of Priest. && sd->status.sp >= 10) @@ -12249,26 +12153,26 @@ int skill_check_pc_partner (struct map_session_data *sd, uint16 skill_id, uint16 switch (skill_id) { case PR_BENEDICTIO: for (i = 0; i < c; i++) { - if ((tsd = iMap->id2sd(p_sd[i])) != NULL) - iStatus->charge(&tsd->bl, 0, 10); + if ((tsd = map->id2sd(p_sd[i])) != NULL) + status->charge(&tsd->bl, 0, 10); } return c; case AB_ADORAMUS: - if( c > 0 && (tsd = iMap->id2sd(p_sd[0])) != NULL ) { + if( c > 0 && (tsd = map->id2sd(p_sd[0])) != NULL ) { i = 2 * (*skill_lv); - iStatus->charge(&tsd->bl, 0, i); + status->charge(&tsd->bl, 0, i); } break; case WM_GREAT_ECHO: for( i = 0; i < c; i++ ) { - if( (tsd = iMap->id2sd(p_sd[i])) != NULL ) + if( (tsd = map->id2sd(p_sd[i])) != NULL ) status_zap(&tsd->bl,0,skill->get_sp(skill_id,*skill_lv)/c); } break; default: //Warning: Assuming Ensemble skills here (for speed) if( is_chorus ) break;//Chorus skills are not to be parsed as ensambles - if (c > 0 && sd->sc.data[SC_DANCING] && (tsd = iMap->id2sd(p_sd[0])) != NULL) { + if (c > 0 && sd->sc.data[SC_DANCING] && (tsd = map->id2sd(p_sd[0])) != NULL) { sd->sc.data[SC_DANCING]->val4 = tsd->bl.id; sc_start4(&tsd->bl,SC_DANCING,100,skill_id,sd->sc.data[SC_DANCING]->val2,*skill_lv,sd->bl.id,skill->get_time(skill_id,*skill_lv)+1000); clif->skill_nodamage(&tsd->bl, &sd->bl, skill_id, *skill_lv, 1); @@ -12285,7 +12189,7 @@ int skill_check_pc_partner (struct map_session_data *sd, uint16 skill_id, uint16 if( is_chorus ) i = party_foreachsamemap(skill->check_condition_char_sub,sd,AREA_SIZE,&sd->bl, &c, &p_sd, skill_id, *skill_lv); else - i = iMap->foreachinrange(skill->check_condition_char_sub, &sd->bl, range, BL_PC, &sd->bl, &c, &p_sd, skill_id); + i = map->foreachinrange(skill->check_condition_char_sub, &sd->bl, range, BL_PC, &sd->bl, &c, &p_sd, skill_id); if ( skill_id != PR_BENEDICTIO && skill_id != AB_ADORAMUS && skill_id != WL_COMET ) //Apply the average lv to encore skills. *skill_lv = (i+(*skill_lv))/(c+1); //I know c should be one, but this shows how it could be used for the average of n partners. @@ -12404,22 +12308,51 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id return 0; switch( skill_id ) { // Turn off check. - case BS_MAXIMIZE: case NV_TRICKDEAD: case TF_HIDING: case AS_CLOAKING: case CR_AUTOGUARD: - case ML_AUTOGUARD: case CR_DEFENDER: case ML_DEFENDER: case ST_CHASEWALK: case PA_GOSPEL: - case CR_SHRINK: case TK_RUN: case GS_GATLINGFEVER: case TK_READYCOUNTER: case TK_READYDOWN: - case TK_READYSTORM: case TK_READYTURN: case SG_FUSION: case RA_WUGDASH: case KO_YAMIKUMO: - if( sc && sc->data[iStatus->skill2sc(skill_id)] ) + case BS_MAXIMIZE: + case NV_TRICKDEAD: + case TF_HIDING: + case AS_CLOAKING: + case CR_AUTOGUARD: + case ML_AUTOGUARD: + case CR_DEFENDER: + case ML_DEFENDER: + case ST_CHASEWALK: + case PA_GOSPEL: + case CR_SHRINK: + case TK_RUN: + case GS_GATLINGFEVER: + case TK_READYCOUNTER: + case TK_READYDOWN: + case TK_READYSTORM: + case TK_READYTURN: + case SG_FUSION: + case RA_WUGDASH: + case KO_YAMIKUMO: + if( sc && sc->data[status->skill2sc(skill_id)] ) return 1; } // Check the skills that can be used while mounted on a warg if( pc_isridingwug(sd) ) { switch( skill_id ) { - case HT_SKIDTRAP: case HT_LANDMINE: case HT_ANKLESNARE: case HT_SHOCKWAVE: - case HT_SANDMAN: case HT_FLASHER: case HT_FREEZINGTRAP: case HT_BLASTMINE: - case HT_CLAYMORETRAP: case HT_SPRINGTRAP: case RA_DETONATOR: case RA_CLUSTERBOMB: - case HT_TALKIEBOX: case RA_FIRINGTRAP: case RA_ICEBOUNDTRAP: - case RA_WUGDASH: case RA_WUGRIDER: case RA_WUGSTRIKE: + case HT_SKIDTRAP: + case HT_LANDMINE: + case HT_ANKLESNARE: + case HT_SHOCKWAVE: + case HT_SANDMAN: + case HT_FLASHER: + case HT_FREEZINGTRAP: + case HT_BLASTMINE: + case HT_CLAYMORETRAP: + case HT_SPRINGTRAP: + case RA_DETONATOR: + case RA_CLUSTERBOMB: + case HT_TALKIEBOX: + case RA_FIRINGTRAP: + case RA_ICEBOUNDTRAP: + case RA_WUGDASH: + case RA_WUGRIDER: + case RA_WUGSTRIKE: break; default: // in official there is no message. return 0; @@ -12428,14 +12361,19 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id } if( pc_ismadogear(sd) ) { switch( skill_id ) { //None Mado skills are unusable when Mado is equipped. [Jobbie] - case BS_REPAIRWEAPON: case WS_MELTDOWN: - case BS_HAMMERFALL: case WS_CARTBOOST: - case BS_ADRENALINE: case WS_WEAPONREFINE: - case BS_WEAPONPERFECT: case WS_CARTTERMINATION: - case BS_OVERTHRUST: case WS_OVERTHRUSTMAX: - case BS_MAXIMIZE: - case BS_ADRENALINE2: - case BS_UNFAIRLYTRICK: + case BS_REPAIRWEAPON: + case WS_MELTDOWN: + case BS_HAMMERFALL: + case WS_CARTBOOST: + case BS_ADRENALINE: + case WS_WEAPONREFINE: + case BS_WEAPONPERFECT: + case WS_CARTTERMINATION: + case BS_OVERTHRUST: + case WS_OVERTHRUSTMAX: + case BS_MAXIMIZE: + case BS_ADRENALINE2: + case BS_UNFAIRLYTRICK: case BS_GREED: clif->skill_fail(sd,skill_id,USESKILL_FAIL_MADOGEAR,0); return 0; @@ -12638,7 +12576,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id for (i=0;i<size*size;i++) { x = sd->bl.x+(i%size-range); y = sd->bl.y+(i/size-range); - if (iMap->getcell(sd->bl.m,x,y,CELL_CHKWALL)) { + if (map->getcell(sd->bl.m,x,y,CELL_CHKWALL)) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); return 0; } @@ -12929,13 +12867,13 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id break; case SR_CURSEDCIRCLE: if (map_flag_gvg2(sd->bl.m)) { - if (iMap->foreachinrange(mob->count_sub, &sd->bl, skill->get_splash(skill_id, skill_lv), BL_MOB, - MOBID_EMPERIUM, MOBID_GUARIDAN_STONE1, MOBID_GUARIDAN_STONE2)) { - char output[128]; - sprintf(output, "You're too close to a stone or emperium to do this skill"); - clif->colormes(sd->fd, COLOR_RED, output); - return 0; - } + if (map->foreachinrange(mob->count_sub, &sd->bl, skill->get_splash(skill_id, skill_lv), BL_MOB, + MOBID_EMPERIUM, MOBID_GUARIDAN_STONE1, MOBID_GUARIDAN_STONE2)) { + char output[128]; + sprintf(output, "You're too close to a stone or emperium to do this skill"); + clif->colormes(sd->fd, COLOR_RED, output); + return 0; + } } if( sd->spiritball > 0 ) sd->spiritball_old = require.spiritball = sd->spiritball; @@ -13092,7 +13030,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id case ST_WATER: if (sc && (sc->data[SC_DELUGE] || sc->data[SC_NJ_SUITON])) break; - if (iMap->getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKWATER)) + if (map->getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKWATER)) break; clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); return 0; @@ -13273,10 +13211,11 @@ int skill_check_condition_castend(struct map_session_data* sd, uint16 skill_id, int maxcount = (skill_id==AM_CANNIBALIZE)? 6-skill_lv : skill->get_maxcount(skill_id,skill_lv); int mob_class = (skill_id==AM_CANNIBALIZE)? summons[skill_lv-1] :1142; if(battle_config.land_skill_limit && maxcount>0 && (battle_config.land_skill_limit&BL_PC)) { - i = iMap->foreachinmap(skill->check_condition_mob_master_sub ,sd->bl.m, BL_MOB, sd->bl.id, mob_class, skill_id, &c); - if(c >= maxcount || - (skill_id==AM_CANNIBALIZE && c != i && battle_config.summon_flora&2)) - { //Fails when: exceed max limit. There are other plant types already out. + i = map->foreachinmap(skill->check_condition_mob_master_sub ,sd->bl.m, BL_MOB, sd->bl.id, mob_class, skill_id, &c); + if( c >= maxcount + || (skill_id==AM_CANNIBALIZE && c != i && battle_config.summon_flora&2) + ) { + //Fails when: exceed max limit. There are other plant types already out. clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); return 0; } @@ -13294,9 +13233,9 @@ int skill_check_condition_castend(struct map_session_data* sd, uint16 skill_id, if( battle_config.land_skill_limit && maxcount > 0 && ( battle_config.land_skill_limit&BL_PC ) ) { if( skill_id == NC_MAGICDECOY ) { for( j = mob_class; j <= 2046; j++ ) - iMap->foreachinmap(skill->check_condition_mob_master_sub, sd->bl.m, BL_MOB, sd->bl.id, j, skill_id, &c); + map->foreachinmap(skill->check_condition_mob_master_sub, sd->bl.m, BL_MOB, sd->bl.id, j, skill_id, &c); } else - iMap->foreachinmap(skill->check_condition_mob_master_sub, sd->bl.m, BL_MOB, sd->bl.id, mob_class, skill_id, &c); + map->foreachinmap(skill->check_condition_mob_master_sub, sd->bl.m, BL_MOB, sd->bl.id, mob_class, skill_id, &c); if( c >= maxcount ) { clif->skill_fail(sd , skill_id, USESKILL_FAIL_LEVEL, 0); return 0; @@ -13306,7 +13245,7 @@ int skill_check_condition_castend(struct map_session_data* sd, uint16 skill_id, break; case KO_ZANZOU: { int c = 0; - i = iMap->foreachinmap(skill->check_condition_mob_master_sub, sd->bl.m, BL_MOB, sd->bl.id, 2308, skill_id, &c); + i = map->foreachinmap(skill->check_condition_mob_master_sub, sd->bl.m, BL_MOB, sd->bl.id, 2308, skill_id, &c); if( c >= skill->get_maxcount(skill_id,skill_lv) || c != i) { clif->skill_fail(sd , skill_id, USESKILL_FAIL_LEVEL, 0); return 0; @@ -13493,12 +13432,11 @@ struct skill_condition skill_get_requirement(struct map_session_data* sd, uint16 if( !sd ) return req; - /* temporarily disabled, awaiting for kenpachi to detail this so we can make it work properly */ -#if 0 +#if 0 /* temporarily disabled, awaiting for kenpachi to detail this so we can make it work properly */ if( sd->state.abra_flag ) -#else +#else // not 0 if( sd->skillitem == skill_id ) -#endif +#endif // 0 return req; // Hocus-Pocus don't have requirements. sc = &sd->sc; @@ -13506,11 +13444,26 @@ struct skill_condition skill_get_requirement(struct map_session_data* sd, uint16 sc = NULL; switch( skill_id ) { // Turn off check. - case BS_MAXIMIZE: case NV_TRICKDEAD: case TF_HIDING: case AS_CLOAKING: case CR_AUTOGUARD: - case ML_AUTOGUARD: case CR_DEFENDER: case ML_DEFENDER: case ST_CHASEWALK: case PA_GOSPEL: - case CR_SHRINK: case TK_RUN: case GS_GATLINGFEVER: case TK_READYCOUNTER: case TK_READYDOWN: - case TK_READYSTORM: case TK_READYTURN: case SG_FUSION: case KO_YAMIKUMO: - if( sc && sc->data[iStatus->skill2sc(skill_id)] ) + case BS_MAXIMIZE: + case NV_TRICKDEAD: + case TF_HIDING: + case AS_CLOAKING: + case CR_AUTOGUARD: + case ML_AUTOGUARD: + case CR_DEFENDER: + case ML_DEFENDER: + case ST_CHASEWALK: + case PA_GOSPEL: + case CR_SHRINK: + case TK_RUN: + case GS_GATLINGFEVER: + case TK_READYCOUNTER: + case TK_READYDOWN: + case TK_READYSTORM: + case TK_READYTURN: + case SG_FUSION: + case KO_YAMIKUMO: + if( sc && sc->data[status->skill2sc(skill_id)] ) return req; } @@ -13522,17 +13475,17 @@ struct skill_condition skill_get_requirement(struct map_session_data* sd, uint16 st = &sd->battle_status; - req.hp = skill_db[idx].hp[skill_lv-1]; - hp_rate = skill_db[idx].hp_rate[skill_lv-1]; + req.hp = skill->db[idx].hp[skill_lv-1]; + hp_rate = skill->db[idx].hp_rate[skill_lv-1]; if(hp_rate > 0) req.hp += (st->hp * hp_rate)/100; else req.hp += (st->max_hp * (-hp_rate))/100; - req.sp = skill_db[idx].sp[skill_lv-1]; + req.sp = skill->db[idx].sp[skill_lv-1]; if((sd->skill_id_old == BD_ENCORE) && skill_id == sd->skill_id_dance) req.sp /= 2; - sp_rate = skill_db[idx].sp_rate[skill_lv-1]; + sp_rate = skill->db[idx].sp_rate[skill_lv-1]; if(sp_rate > 0) req.sp += (st->sp * sp_rate)/100; else @@ -13560,22 +13513,22 @@ struct skill_condition skill_get_requirement(struct map_session_data* sd, uint16 req.sp -= req.sp * sc->data[SC_TELEKINESIS_INTENSE]->val2 / 100; } - req.zeny = skill_db[idx].zeny[skill_lv-1]; + req.zeny = skill->db[idx].zeny[skill_lv-1]; if( sc && sc->data[SC__UNLUCKY] ) req.zeny += sc->data[SC__UNLUCKY]->val1 * 500; - req.spiritball = skill_db[idx].spiritball[skill_lv-1]; + req.spiritball = skill->db[idx].spiritball[skill_lv-1]; - req.state = skill_db[idx].state; + req.state = skill->db[idx].state; - req.mhp = skill_db[idx].mhp[skill_lv-1]; + req.mhp = skill->db[idx].mhp[skill_lv-1]; - req.weapon = skill_db[idx].weapon; + req.weapon = skill->db[idx].weapon; - req.ammo_qty = skill_db[idx].ammo_qty[skill_lv-1]; + req.ammo_qty = skill->db[idx].ammo_qty[skill_lv-1]; if (req.ammo_qty) - req.ammo = skill_db[idx].ammo; + req.ammo = skill->db[idx].ammo; if (!req.ammo && skill_id && skill->isammotype(sd, skill_id)) { //Assume this skill is using the weapon, therefore it requires arrows. @@ -13601,11 +13554,11 @@ struct skill_condition skill_get_requirement(struct map_session_data* sd, uint16 continue; break; case AB_ADORAMUS: - if( itemid_isgemstone(skill_db[idx].itemid[i]) && skill->check_pc_partner(sd,skill_id,&skill_lv, 1, 2) ) + if( itemid_isgemstone(skill->db[idx].itemid[i]) && skill->check_pc_partner(sd,skill_id,&skill_lv, 1, 2) ) continue; break; case WL_COMET: - if( itemid_isgemstone(skill_db[idx].itemid[i]) && skill->check_pc_partner(sd,skill_id,&skill_lv, 1, 0) ) + if( itemid_isgemstone(skill->db[idx].itemid[i]) && skill->check_pc_partner(sd,skill_id,&skill_lv, 1, 0) ) continue; break; case GN_FIRE_EXPANSION: @@ -13625,8 +13578,8 @@ struct skill_condition skill_get_requirement(struct map_session_data* sd, uint16 break; } - req.itemid[i] = skill_db[idx].itemid[i]; - req.amount[i] = skill_db[idx].amount[i]; + req.itemid[i] = skill->db[idx].itemid[i]; + req.amount[i] = skill->db[idx].amount[i]; if( itemid_isgemstone(req.itemid[i]) && skill_id != HW_GANBANTEIN ) { @@ -13665,8 +13618,8 @@ struct skill_condition skill_get_requirement(struct map_session_data* sd, uint16 case SO_FIRE_INSIGNIA: case SO_WIND_INSIGNIA: case SO_EARTH_INSIGNIA: - req.itemid[skill_lv-1] = skill_db[idx].itemid[skill_lv-1]; - req.amount[skill_lv-1] = skill_db[idx].amount[skill_lv-1]; + req.itemid[skill_lv-1] = skill->db[idx].itemid[skill_lv-1]; + req.amount[skill_lv-1] = skill->db[idx].amount[skill_lv-1]; break; } @@ -13806,9 +13759,8 @@ int skill_castfix (struct block_list *bl, uint16 skill_id, uint16 skill_lv) { /*========================================== * Does cast-time reductions based on sc data. *------------------------------------------*/ -int skill_castfix_sc (struct block_list *bl, int time) -{ - struct status_change *sc = iStatus->get_sc(bl); +int skill_castfix_sc (struct block_list *bl, int time) { + struct status_change *sc = status->get_sc(bl); if( time < 0 ) return 0; @@ -13819,8 +13771,8 @@ int skill_castfix_sc (struct block_list *bl, int time) if (sc && sc->count) { if (sc->data[SC_SLOWCAST]) time += time * sc->data[SC_SLOWCAST]->val2 / 100; - if (sc->data[SC_NEEDLE_OF_PARALYZE]) - time += sc->data[SC_NEEDLE_OF_PARALYZE]->val3; + if (sc->data[SC_NEEDLE_OF_PARALYZE]) + time += sc->data[SC_NEEDLE_OF_PARALYZE]->val3; if (sc->data[SC_SUFFRAGIUM]) { time -= time * sc->data[SC_SUFFRAGIUM]->val2 / 100; status_change_end(bl, SC_SUFFRAGIUM, INVALID_TIMER); @@ -13835,15 +13787,14 @@ int skill_castfix_sc (struct block_list *bl, int time) if (sc->data[SC_IZAYOI]) time -= time * 50 / 100; } - time = max(time, 0); + time = max(time, 0); -// ShowInfo("Castime castfix_sc = %d\n",time); + //ShowInfo("Castime castfix_sc = %d\n",time); return time; } #ifdef RENEWAL_CAST -int skill_vfcastfix (struct block_list *bl, double time, uint16 skill_id, uint16 skill_lv) -{ - struct status_change *sc = iStatus->get_sc(bl); +int skill_vfcastfix(struct block_list *bl, double time, uint16 skill_id, uint16 skill_lv) { + struct status_change *sc = status->get_sc(bl); struct map_session_data *sd = BL_CAST(BL_PC,bl); int fixed = skill->get_fixed_cast(skill_id, skill_lv), fixcast_r = 0, varcast_r = 0, i = 0; @@ -13935,7 +13886,7 @@ int skill_vfcastfix (struct block_list *bl, double time, uint16 skill_id, uint16 if( sc->data[SC_SECRAMENT] ) fixcast_r = max(fixcast_r, sc->data[SC_SECRAMENT]->val2); if( sd && ( skill_lv = pc->checkskill(sd, WL_RADIUS) ) && (skill_id >= WL_WHITEIMPRISON && skill_id < WL_FREEZE_SP) ) - fixcast_r = max(fixcast_r, (status_get_int(bl) + iStatus->get_lv(bl)) / 15 + skill_lv * 5); // [{(Caster?s INT / 15) + (Caster?s Base Level / 15) + (Radius Skill Level x 5)}] % + fixcast_r = max(fixcast_r, (status_get_int(bl) + status->get_lv(bl)) / 15 + skill_lv * 5); // [{(Caster?s INT / 15) + (Caster?s Base Level / 15) + (Radius Skill Level x 5)}] % // Fixed cast non percentage bonuses if( sc->data[SC_MANDRAGORA] ) fixed += sc->data[SC_MANDRAGORA]->val1 * 1000 / 2; @@ -13964,12 +13915,11 @@ int skill_vfcastfix (struct block_list *bl, double time, uint16 skill_id, uint16 /*========================================== * Does delay reductions based on dex/agi, sc data, item bonuses, ... *------------------------------------------*/ -int skill_delay_fix (struct block_list *bl, uint16 skill_id, uint16 skill_lv) -{ +int skill_delay_fix (struct block_list *bl, uint16 skill_id, uint16 skill_lv) { int delaynodex = skill->get_delaynodex(skill_id, skill_lv); int time = skill->get_delay(skill_id, skill_lv); struct map_session_data *sd; - struct status_change *sc = iStatus->get_sc(bl); + struct status_change *sc = status->get_sc(bl); nullpo_ret(bl); sd = BL_CAST(BL_PC, bl); @@ -14179,19 +14129,19 @@ void skill_brandishspear_dir (struct square* tc, uint8 dir, int are) { void skill_brandishspear(struct block_list* src, struct block_list* bl, uint16 skill_id, uint16 skill_lv, unsigned int tick, int flag) { int c,n=4; - uint8 dir = iMap->calc_dir(src,bl->x,bl->y); + uint8 dir = map->calc_dir(src,bl->x,bl->y); struct square tc; int x=bl->x,y=bl->y; skill->brandishspear_first(&tc,dir,x,y); skill->brandishspear_dir(&tc,dir,4); - skill_area_temp[1] = bl->id; + skill->area_temp[1] = bl->id; if(skill_lv > 9){ for(c=1;c<4;c++){ - iMap->foreachincell(skill->area_sub, - bl->m,tc.val1[c],tc.val2[c],BL_CHAR, - src,skill_id,skill_lv,tick, flag|BCT_ENEMY|n, - skill->castend_damage_id); + map->foreachincell(skill->area_sub, + bl->m,tc.val1[c],tc.val2[c],BL_CHAR, + src,skill_id,skill_lv,tick, flag|BCT_ENEMY|n, + skill->castend_damage_id); } } if(skill_lv > 6){ @@ -14204,11 +14154,11 @@ void skill_brandishspear(struct block_list* src, struct block_list* bl, uint16 s if(skill_lv > 3){ for(c=0;c<5;c++){ - iMap->foreachincell(skill->area_sub, - bl->m,tc.val1[c],tc.val2[c],BL_CHAR, - src,skill_id,skill_lv,tick, flag|BCT_ENEMY|n, - skill->castend_damage_id); - if(skill_lv > 6 && n==3 && c==4){ + map->foreachincell(skill->area_sub, + bl->m,tc.val1[c],tc.val2[c],BL_CHAR, + src,skill_id,skill_lv,tick, flag|BCT_ENEMY|n, + skill->castend_damage_id); + if(skill_lv > 6 && n==3 && c==4) { skill_brandishspear_dir(&tc,dir,-1); n--;c=-1; } @@ -14216,7 +14166,7 @@ void skill_brandishspear(struct block_list* src, struct block_list* bl, uint16 s } for(c=0;c<10;c++){ if(c==0||c==5) skill->brandishspear_dir(&tc,dir,-1); - iMap->foreachincell(skill->area_sub, + map->foreachincell(skill->area_sub, bl->m,tc.val1[c%5],tc.val2[c%5],BL_CHAR, src,skill_id,skill_lv,tick, flag|BCT_ENEMY|1, skill->castend_damage_id); @@ -14234,7 +14184,7 @@ void skill_repairweapon (struct map_session_data *sd, int idx) { nullpo_retv(sd); - if ( !( target_sd = iMap->id2sd(sd->menuskill_val) ) ) //Failed.... + if ( !( target_sd = map->id2sd(sd->menuskill_val) ) ) //Failed.... return; if( idx == 0xFFFF ) // No item selected ('Cancel' clicked) @@ -14322,7 +14272,7 @@ void skill_weaponrefine (struct map_session_data *sd, int idx) return; } - per = iStatus->get_refine_chance(ditem->wlv, (int)item->refine) * 10; + per = status->get_refine_chance(ditem->wlv, (int)item->refine) * 10; // Aegis leaked formula. [malufett] if( sd->status.class_ == JOB_MECHANIC_T ) @@ -14452,8 +14402,8 @@ int skill_sit_in (struct block_list *bl, va_list ap) { if(type&2 && (pc->checkskill(sd,TK_HPTIME) > 0 || pc->checkskill(sd,TK_SPTIME) > 0 )) { sd->state.rest=1; - iStatus->calc_regen(bl, &sd->battle_status, &sd->regen); - iStatus->calc_regen_rate(bl, &sd->regen, &sd->sc); + status->calc_regen(bl, &sd->battle_status, &sd->regen); + status->calc_regen_rate(bl, &sd->regen, &sd->sc); } return 0; @@ -14467,8 +14417,8 @@ int skill_sit_out (struct block_list *bl, va_list ap) { sd->state.gangsterparadise=0; if(sd->state.rest && type&2) { sd->state.rest=0; - iStatus->calc_regen(bl, &sd->battle_status, &sd->regen); - iStatus->calc_regen_rate(bl, &sd->regen, &sd->sc); + status->calc_regen(bl, &sd->battle_status, &sd->regen); + status->calc_regen_rate(bl, &sd->regen, &sd->sc); } return 0; } @@ -14502,11 +14452,11 @@ int skill_sit (struct map_session_data *sd, int type) if (!flag) return 0; if(type) { - if (iMap->foreachinrange(skill->sit_count,&sd->bl, range, BL_PC, flag) > 1) - iMap->foreachinrange(skill->sit_in,&sd->bl, range, BL_PC, flag); + if (map->foreachinrange(skill->sit_count,&sd->bl, range, BL_PC, flag) > 1) + map->foreachinrange(skill->sit_in,&sd->bl, range, BL_PC, flag); } else { - if (iMap->foreachinrange(skill->sit_count,&sd->bl, range, BL_PC, flag) < 2) - iMap->foreachinrange(skill->sit_out,&sd->bl, range, BL_PC, flag); + if (map->foreachinrange(skill->sit_count,&sd->bl, range, BL_PC, flag) < 2) + map->foreachinrange(skill->sit_out,&sd->bl, range, BL_PC, flag); } return 0; } @@ -14527,7 +14477,7 @@ int skill_frostjoke_scream (struct block_list *bl, va_list ap) { if(!skill_lv) return 0; tick=va_arg(ap,unsigned int); - if (src == bl || iStatus->isdead(bl)) + if (src == bl || status->isdead(bl)) return 0; if (bl->type == BL_PC) { struct map_session_data *sd = (struct map_session_data *)bl; @@ -14558,13 +14508,12 @@ void skill_unitsetmapcell (struct skill_unit *src, uint16 skill_id, uint16 skill /*========================================== * *------------------------------------------*/ -int skill_attack_area (struct block_list *bl, va_list ap) -{ +int skill_attack_area (struct block_list *bl, va_list ap) { struct block_list *src,*dsrc; int atk_type,skill_id,skill_lv,flag,type; unsigned int tick; - if(iStatus->isdead(bl)) + if(status->isdead(bl)) return 0; atk_type = va_arg(ap,int); @@ -14577,11 +14526,11 @@ int skill_attack_area (struct block_list *bl, va_list ap) type=va_arg(ap,int); - if (skill_area_temp[1] == bl->id) //This is the target of the skill, do a full attack and skip target checks. + if (skill->area_temp[1] == bl->id) //This is the target of the skill, do a full attack and skip target checks. return skill->attack(atk_type,src,dsrc,bl,skill_id,skill_lv,tick,flag); - if(battle->check_target(dsrc,bl,type) <= 0 || - !iStatus->check_skilluse(NULL, bl, skill_id, 2)) + if( battle->check_target(dsrc,bl,type) <= 0 + || !status->check_skilluse(NULL, bl, skill_id, 2)) return 0; @@ -14723,11 +14672,11 @@ int skill_detonator(struct block_list *bl, va_list ap) { case UNT_CLAYMORETRAP: case UNT_FIRINGTRAP: case UNT_ICEBOUNDTRAP: - iMap->foreachinrange(skill->trap_splash,bl,skill->get_splash(su->group->skill_id,su->group->skill_lv),su->group->bl_flag|BL_SKILL|~BCT_SELF,bl,su->group->tick); + map->foreachinrange(skill->trap_splash,bl,skill->get_splash(su->group->skill_id,su->group->skill_lv),su->group->bl_flag|BL_SKILL|~BCT_SELF,bl,su->group->tick); break; default: - iMap->foreachinrange(skill->trap_splash,bl,skill->get_splash(su->group->skill_id,su->group->skill_lv),su->group->bl_flag,bl,su->group->tick); - } + map->foreachinrange(skill->trap_splash,bl,skill->get_splash(su->group->skill_id,su->group->skill_lv),su->group->bl_flag,bl,su->group->tick); + } clif->changetraplook(bl, UNT_USED_TRAPS); su->group->limit = DIFF_TICK(timer->gettick(),su->group->tick) + (unit_id == UNT_TALKIEBOX ? 5000 : (unit_id == UNT_CLUSTERBOMB || unit_id == UNT_ICEBOUNDTRAP? 2500 : (unit_id == UNT_FIRINGTRAP ? 0 : 1500)) ); @@ -14880,7 +14829,7 @@ int skill_trap_splash (struct block_list *bl, va_list ap) { return 0; nullpo_ret(sg = su->group); - nullpo_ret(ss = iMap->id2bl(sg->src_id)); + nullpo_ret(ss = map->id2bl(sg->src_id)); if(battle->check_target(src,bl,sg->target_flag) <= 0) return 0; @@ -14980,11 +14929,11 @@ int skill_maelstrom_suction(struct block_list *bl, va_list ap) { if( su->group->skill_id == SC_MAELSTROM ) { struct block_list *src; - if( (src = iMap->id2bl(su->group->src_id)) ) { + if( (src = map->id2bl(su->group->src_id)) ) { int sp = su->group->skill_lv * skill_lv; if( src->type == BL_PC ) sp += ((TBL_PC*)src)->status.job_level / 5; - iStatus->heal(src, 0, sp/2, 1); + status->heal(src, 0, sp/2, 1); } } @@ -14994,13 +14943,12 @@ int skill_maelstrom_suction(struct block_list *bl, va_list ap) { /*========================================== * *------------------------------------------*/ -int skill_enchant_elemental_end (struct block_list *bl, int type) -{ +int skill_enchant_elemental_end (struct block_list *bl, int type) { struct status_change *sc; const enum sc_type scs[] = { SC_ENCHANTPOISON, SC_ASPERSIO, SC_PROPERTYFIRE, SC_PROPERTYWATER, SC_PROPERTYWIND, SC_PROPERTYGROUND, SC_PROPERTYDARK, SC_PROPERTYTELEKINESIS, SC_ENCHANTARMS, SC_EXEEDBREAK }; int i; nullpo_ret(bl); - nullpo_ret(sc= iStatus->get_sc(bl)); + nullpo_ret(sc = status->get_sc(bl)); if (!sc->count) return 0; @@ -15018,10 +14966,11 @@ bool skill_check_cloaking(struct block_list *bl, struct status_change_entry *sce bool wall = true; if( (bl->type == BL_PC && battle_config.pc_cloak_check_type&1) - || (bl->type != BL_PC && battle_config.monster_cloak_check_type&1) ) - { //Check for walls. + || (bl->type != BL_PC && battle_config.monster_cloak_check_type&1) + ) { + //Check for walls. int i; - ARR_FIND( 0, 8, i, iMap->getcell(bl->m, bl->x+dx[i], bl->y+dy[i], CELL_CHKNOPASS) != 0 ); + ARR_FIND( 0, 8, i, map->getcell(bl->m, bl->x+dx[i], bl->y+dy[i], CELL_CHKNOPASS) != 0 ); if( i == 8 ) wall = false; } @@ -15052,7 +15001,7 @@ bool skill_check_camouflage(struct block_list *bl, struct status_change_entry *s if( bl->type == BL_PC ) { //Check for walls. int i; - ARR_FIND( 0, 8, i, iMap->getcell(bl->m, bl->x+dx[i], bl->y+dy[i], CELL_CHKNOPASS) != 0 ); + ARR_FIND( 0, 8, i, map->getcell(bl->m, bl->x+dx[i], bl->y+dy[i], CELL_CHKNOPASS) != 0 ); if( i == 8 ) wall = false; } @@ -15081,13 +15030,13 @@ struct skill_unit *skill_initunit (struct skill_unit_group *group, int idx, int nullpo_retr(NULL, group->unit); // crash-protection against poor coding nullpo_retr(NULL, su=&group->unit[idx]); - if( iMap->getcell(iMap->id2bl(group->src_id)->m, x, y, CELL_CHKMAELSTROM) ) + if( map->getcell(map->id2bl(group->src_id)->m, x, y, CELL_CHKMAELSTROM) ) return su; if(!su->alive) group->alive_count++; - su->bl.id=iMap->get_new_object_id(); + su->bl.id=map->get_new_object_id(); su->bl.type=BL_SKILL; su->bl.m=group->map; su->bl.x=x; @@ -15097,14 +15046,14 @@ struct skill_unit *skill_initunit (struct skill_unit_group *group, int idx, int su->val1=val1; su->val2=val2; - idb_put(skillunit_db, su->bl.id, su); - iMap->addiddb(&su->bl); - iMap->addblock(&su->bl); + idb_put(skill->unit_db, su->bl.id, su); + map->addiddb(&su->bl); + map->addblock(&su->bl); // perform oninit actions switch (group->skill_id) { case WZ_ICEWALL: - iMap->setgatcell(su->bl.m,su->bl.x,su->bl.y,5); + map->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); maplist[su->bl.m].icewall_num++; @@ -15147,18 +15096,19 @@ int skill_delunit (struct skill_unit* su) { // invoke onout event if( !su->range ) - iMap->foreachincell(skill->unit_effect,su->bl.m,su->bl.x,su->bl.y,group->bl_flag,&su->bl,timer->gettick(),4); + map->foreachincell(skill->unit_effect,su->bl.m,su->bl.x,su->bl.y,group->bl_flag,&su->bl,timer->gettick(),4); // perform ondelete actions switch (group->skill_id) { - case HT_ANKLESNARE: { - struct block_list* target = iMap->id2bl(group->val2); - if( target ) - status_change_end(target, SC_ANKLESNARE, INVALID_TIMER); - } + case HT_ANKLESNARE: + { + struct block_list* target = map->id2bl(group->val2); + if( target ) + status_change_end(target, SC_ANKLESNARE, INVALID_TIMER); + } break; case WZ_ICEWALL: - iMap->setgatcell(su->bl.m,su->bl.x,su->bl.y,su->val2); + map->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); maplist[su->bl.m].icewall_num--; @@ -15170,7 +15120,7 @@ int skill_delunit (struct skill_unit* su) { skill->unitsetmapcell(su,HP_BASILICA,group->skill_lv,CELL_BASILICA,false); break; case RA_ELECTRICSHOCKER: { - struct block_list* target = iMap->id2bl(group->val2); + struct block_list* target = map->id2bl(group->val2); if( target ) status_change_end(target, SC_ELECTRICSHOCKER, INVALID_TIMER); } @@ -15180,7 +15130,7 @@ int skill_delunit (struct skill_unit* su) { break; case SC_MANHOLE: // Note : Removing the unit don't remove the status (official info) if( group->val2 ) { // Someone Traped - struct status_change *tsc = iStatus->get_sc( iMap->id2bl(group->val2)); + struct status_change *tsc = status->get_sc(map->id2bl(group->val2)); if( tsc && tsc->data[SC__MANHOLE] ) tsc->data[SC__MANHOLE]->val4 = 0; // Remove the Unit ID } @@ -15190,9 +15140,9 @@ int skill_delunit (struct skill_unit* su) { clif->skill_delunit(su); su->group=NULL; - iMap->delblock(&su->bl); // don't free yet - iMap->deliddb(&su->bl); - idb_remove(skillunit_db, su->bl.id); + map->delblock(&su->bl); // don't free yet + map->deliddb(&su->bl); + idb_remove(skill->unit_db, su->bl.id); if(--group->alive_count==0) skill->del_unitgroup(group,ALC_MARK); @@ -15201,31 +15151,26 @@ int skill_delunit (struct skill_unit* su) { /*========================================== * *------------------------------------------*/ -static DBMap* group_db = NULL;// int group_id -> struct skill_unit_group* - /// Returns the target skill_unit_group or NULL if not found. struct skill_unit_group* skill_id2group(int group_id) { - return (struct skill_unit_group*)idb_get(group_db, group_id); + return (struct skill_unit_group*)idb_get(skill->group_db, group_id); } - -static int skill_unit_group_newid = MAX_SKILL_DB; - -/// Returns a new group_id that isn't being used in group_db. +/// Returns a new group_id that isn't being used in skill->group_db. /// Fatal error if nothing is available. -static int skill_get_new_group_id(void) +int skill_get_new_group_id(void) { - if( skill_unit_group_newid >= MAX_SKILL_DB && skill->id2group(skill_unit_group_newid) == NULL ) - return skill_unit_group_newid++;// available + if( skill->unit_group_newid >= MAX_SKILL_DB && skill->id2group(skill->unit_group_newid) == NULL ) + return skill->unit_group_newid++;// available {// find next id - int base_id = skill_unit_group_newid; - while( base_id != ++skill_unit_group_newid ) + int base_id = skill->unit_group_newid; + while( base_id != ++skill->unit_group_newid ) { - if( skill_unit_group_newid < MAX_SKILL_DB ) - skill_unit_group_newid = MAX_SKILL_DB; - if( skill->id2group(skill_unit_group_newid) == NULL ) - return skill_unit_group_newid++;// available + if( skill->unit_group_newid < MAX_SKILL_DB ) + skill->unit_group_newid = MAX_SKILL_DB; + if( skill->id2group(skill->unit_group_newid) == NULL ) + return skill->unit_group_newid++;// available } // full loop, nothing available ShowFatalError("skill_get_new_group_id: All ids are taken. Exiting..."); @@ -15260,59 +15205,57 @@ struct skill_unit_group* skill_initunitgroup (struct block_list* src, int count, i = MAX_SKILLUNITGROUP-1; } - group = ers_alloc(skill->unit_ers, struct skill_unit_group); - group->src_id = src->id; - group->party_id = iStatus->get_party_id(src); - group->guild_id = iStatus->get_guild_id(src); - group->bg_id = bg->team_get_id(src); - group->group_id = skill_get_new_group_id(); - group->unit = (struct skill_unit *)aCalloc(count,sizeof(struct skill_unit)); - group->unit_count = count; + group = ers_alloc(skill->unit_ers, struct skill_unit_group); + group->src_id = src->id; + group->party_id = status->get_party_id(src); + group->guild_id = status->get_guild_id(src); + group->bg_id = bg->team_get_id(src); + group->group_id = skill->get_new_group_id(); + group->unit = (struct skill_unit *)aCalloc(count,sizeof(struct skill_unit)); + group->unit_count = count; group->alive_count = 0; - group->val1 = 0; - group->val2 = 0; - group->val3 = 0; - group->skill_id = skill_id; - group->skill_lv = skill_lv; - group->unit_id = unit_id; - group->map = src->m; - group->limit = limit; - group->interval = interval; - group->tick = timer->gettick(); - group->valstr = NULL; + group->val1 = 0; + group->val2 = 0; + group->val3 = 0; + group->skill_id = skill_id; + group->skill_lv = skill_lv; + group->unit_id = unit_id; + group->map = src->m; + group->limit = limit; + group->interval = interval; + group->tick = timer->gettick(); + group->valstr = NULL; ud->skillunit[i] = group; if (skill_id == PR_SANCTUARY) //Sanctuary starts healing +1500ms after casted. [Skotlex] group->tick += 1500; - idb_put(group_db, group->group_id, group); + idb_put(skill->group_db, group->group_id, group); return group; } /*========================================== * *------------------------------------------*/ -int skill_delunitgroup(struct skill_unit_group *group, const char* file, int line, const char* func) -{ +int skill_delunitgroup(struct skill_unit_group *group, const char* file, int line, const char* func) { struct block_list* src; struct unit_data *ud; int i,j; - if( group == NULL ) - { + if( group == NULL ) { ShowDebug("skill_delunitgroup: group is NULL (source=%s:%d, %s)! Please report this! (#3504)\n", file, line, func); return 0; } - src=iMap->id2bl(group->src_id); + src=map->id2bl(group->src_id); ud = unit->bl2ud(src); if(!src || !ud) { ShowError("skill_delunitgroup: Group's source not found! (src_id: %d skill_id: %d)\n", group->src_id, group->skill_id); return 0; } - if( !iStatus->isdead(src) && ((TBL_PC*)src)->state.warping && !((TBL_PC*)src)->state.changemap ) { + if( !status->isdead(src) && ((TBL_PC*)src)->state.warping && !((TBL_PC*)src)->state.changemap ) { switch( group->skill_id ) { case BA_DISSONANCE: case BA_POEMBRAGI: @@ -15329,9 +15272,8 @@ int skill_delunitgroup(struct skill_unit_group *group, const char* file, int lin } } - if (skill->get_unit_flag(group->skill_id)&(UF_DANCE|UF_SONG|UF_ENSEMBLE)) - { - struct status_change* sc = iStatus->get_sc(src); + if (skill->get_unit_flag(group->skill_id)&(UF_DANCE|UF_SONG|UF_ENSEMBLE)) { + struct status_change* sc = status->get_sc(src); if (sc && sc->data[SC_DANCING]) { sc->data[SC_DANCING]->val2 = 0 ; //This prevents status_change_end attempting to redelete the group. [Skotlex] @@ -15342,7 +15284,7 @@ int skill_delunitgroup(struct skill_unit_group *group, const char* file, int lin // end Gospel's status change on 'src' // (needs to be done when the group is deleted by other means than skill deactivation) if (group->unit_id == UNT_GOSPEL) { - struct status_change *sc = iStatus->get_sc(src); + struct status_change *sc = status->get_sc(src); if(sc && sc->data[SC_GOSPEL]) { sc->data[SC_GOSPEL]->val3 = 0; //Remove reference to this group. [Skotlex] status_change_end(src, SC_GOSPEL, INVALID_TIMER); @@ -15353,40 +15295,40 @@ int skill_delunitgroup(struct skill_unit_group *group, const char* file, int lin case SG_SUN_WARM: case SG_MOON_WARM: case SG_STAR_WARM: - { - struct status_change *sc = NULL; - if( (sc = iStatus->get_sc(src)) != NULL && sc->data[SC_WARM] ) { - sc->data[SC_WARM]->val4 = 0; - status_change_end(src, SC_WARM, INVALID_TIMER); - } + { + struct status_change *sc = NULL; + if( (sc = status->get_sc(src)) != NULL && sc->data[SC_WARM] ) { + sc->data[SC_WARM]->val4 = 0; + status_change_end(src, SC_WARM, INVALID_TIMER); } + } break; case NC_NEUTRALBARRIER: - { - struct status_change *sc = NULL; - if( (sc = iStatus->get_sc(src)) != NULL && sc->data[SC_NEUTRALBARRIER_MASTER] ) { - sc->data[SC_NEUTRALBARRIER_MASTER]->val2 = 0; - status_change_end(src,SC_NEUTRALBARRIER_MASTER,INVALID_TIMER); - } + { + struct status_change *sc = NULL; + if( (sc = status->get_sc(src)) != NULL && sc->data[SC_NEUTRALBARRIER_MASTER] ) { + sc->data[SC_NEUTRALBARRIER_MASTER]->val2 = 0; + status_change_end(src,SC_NEUTRALBARRIER_MASTER,INVALID_TIMER); } + } break; case NC_STEALTHFIELD: - { - struct status_change *sc = NULL; - if( (sc = iStatus->get_sc(src)) != NULL && sc->data[SC_STEALTHFIELD_MASTER] ) { - sc->data[SC_STEALTHFIELD_MASTER]->val2 = 0; - status_change_end(src,SC_STEALTHFIELD_MASTER,INVALID_TIMER); - } + { + struct status_change *sc = NULL; + if( (sc = status->get_sc(src)) != NULL && sc->data[SC_STEALTHFIELD_MASTER] ) { + sc->data[SC_STEALTHFIELD_MASTER]->val2 = 0; + status_change_end(src,SC_STEALTHFIELD_MASTER,INVALID_TIMER); } + } break; case LG_BANDING: - { - struct status_change *sc = NULL; - if( (sc = iStatus->get_sc(src)) && sc->data[SC_BANDING] ) { - sc->data[SC_BANDING]->val4 = 0; - status_change_end(src,SC_BANDING,INVALID_TIMER); - } + { + struct status_change *sc = NULL; + if( (sc = status->get_sc(src)) && sc->data[SC_BANDING] ) { + sc->data[SC_BANDING]->val4 = 0; + status_change_end(src,SC_BANDING,INVALID_TIMER); } + } break; } @@ -15406,8 +15348,8 @@ int skill_delunitgroup(struct skill_unit_group *group, const char* file, int lin group->valstr = NULL; } - idb_remove(group_db, group->group_id); - iMap->freeblock(&group->unit->bl); // schedules deallocation of whole array (HACK) + idb_remove(skill->group_db, group->group_id); + map->freeblock(&group->unit->bl); // schedules deallocation of whole array (HACK) group->unit=NULL; group->group_id=0; group->unit_count=0; @@ -15493,7 +15435,7 @@ int skill_unit_timer_sub_onplace (struct block_list* bl, va_list ap) { nullpo_ret(group); - if( !(skill->get_inf2(group->skill_id)&(INF2_SONG_DANCE|INF2_TRAP|INF2_NOLP)) && iMap->getcell(bl->m, bl->x, bl->y, CELL_CHKLANDPROTECTOR) ) + if( !(skill->get_inf2(group->skill_id)&(INF2_SONG_DANCE|INF2_TRAP|INF2_NOLP)) && map->getcell(bl->m, bl->x, bl->y, CELL_CHKLANDPROTECTOR) ) return 0; //AoE skills are ineffective. [Skotlex] if( battle->check_target(&su->bl,bl,group->target_flag) <= 0 ) @@ -15565,13 +15507,13 @@ int skill_unit_timer_sub(DBKey key, DBData *data, va_list ap) { { struct block_list* src; - if( su->val1 > 0 && (src = iMap->id2bl(group->src_id)) != NULL && src->type == BL_PC ) { + if( su->val1 > 0 && (src = map->id2bl(group->src_id)) != NULL && src->type == BL_PC ) { // revert unit back into a trap struct item item_tmp; memset(&item_tmp,0,sizeof(item_tmp)); item_tmp.nameid = group->item_id?group->item_id:ITEMID_TRAP; item_tmp.identify = 1; - iMap->addflooritem(&item_tmp,1,bl->m,bl->x,bl->y,0,0,0,0); + map->addflooritem(&item_tmp,1,bl->m,bl->x,bl->y,0,0,0,0); } skill->delunit(su); } @@ -15585,20 +15527,20 @@ int skill_unit_timer_sub(DBKey key, DBData *data, va_list ap) { group->limit = skill->get_time(group->skill_id,group->skill_lv); su->limit = skill->get_time(group->skill_id,group->skill_lv); // apply effect to all units standing on it - iMap->foreachincell(skill->unit_effect,su->bl.m,su->bl.x,su->bl.y,group->bl_flag,&su->bl,timer->gettick(),1); + map->foreachincell(skill->unit_effect,su->bl.m,su->bl.x,su->bl.y,group->bl_flag,&su->bl,timer->gettick(),1); break; case UNT_CALLFAMILY: { struct map_session_data *sd = NULL; if(group->val1) { - sd = iMap->charid2sd(group->val1); + sd = map->charid2sd(group->val1); group->val1 = 0; 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); + sd = map->charid2sd(group->val2); group->val2 = 0; if (sd && !maplist[sd->bl.m].flag.nowarp) pc->setpos(sd,map_id2index(su->bl.m),su->bl.x,su->bl.y,CLR_TELEPORT); @@ -15613,25 +15555,25 @@ int skill_unit_timer_sub(DBKey key, DBData *data, va_list ap) { break; } clif->changetraplook(bl,UNT_USED_TRAPS); - iMap->foreachinrange(skill->trap_splash, bl, skill->get_splash(group->skill_id, group->skill_lv), group->bl_flag, bl, tick); + map->foreachinrange(skill->trap_splash, bl, skill->get_splash(group->skill_id, group->skill_lv), group->bl_flag, bl, tick); group->limit = DIFF_TICK(tick,group->tick)+1000; su->limit = DIFF_TICK(tick,group->tick)+1000; group->unit_id = UNT_USED_TRAPS; break; case UNT_FEINTBOMB: { - struct block_list *src = iMap->id2bl(group->src_id); + struct block_list *src = map->id2bl(group->src_id); if( src ) - iMap->foreachinrange(skill->area_sub, &group->unit->bl, su->range, splash_target(src), src, SC_FEINTBOMB, group->skill_lv, tick, BCT_ENEMY|SD_ANIMATION|1, skill->castend_damage_id); + map->foreachinrange(skill->area_sub, &group->unit->bl, su->range, splash_target(src), src, SC_FEINTBOMB, group->skill_lv, tick, BCT_ENEMY|SD_ANIMATION|1, skill->castend_damage_id); skill->delunit(su); break; } case UNT_BANDING: { - struct block_list *src = iMap->id2bl(group->src_id); + struct block_list *src = map->id2bl(group->src_id); struct status_change *sc; - if( !src || (sc = iStatus->get_sc(src)) == NULL || !sc->data[SC_BANDING] ) { + if( !src || (sc = status->get_sc(src)) == NULL || !sc->data[SC_BANDING] ) { skill->delunit(su); break; } @@ -15675,7 +15617,7 @@ int skill_unit_timer_sub(DBKey key, DBData *data, va_list ap) { case UNT_REVERBERATION: if( su->val1 <= 0 ) { clif->changetraplook(bl,UNT_USED_TRAPS); - iMap->foreachinrange(skill->trap_splash, bl, skill->get_splash(group->skill_id, group->skill_lv), group->bl_flag, bl, tick); + map->foreachinrange(skill->trap_splash, bl, skill->get_splash(group->skill_id, group->skill_lv), group->bl_flag, bl, tick); group->limit = DIFF_TICK(tick,group->tick)+1000; su->limit = DIFF_TICK(tick,group->tick)+1000; group->unit_id = UNT_USED_TRAPS; @@ -15698,9 +15640,9 @@ int skill_unit_timer_sub(DBKey key, DBData *data, va_list ap) { if( su->range >= 0 && group->interval != -1 ) { if( battle_config.skill_wall_check ) - iMap->foreachinshootrange(skill->unit_timer_sub_onplace, bl, su->range, group->bl_flag, bl,tick); + map->foreachinshootrange(skill->unit_timer_sub_onplace, bl, su->range, group->bl_flag, bl,tick); else - iMap->foreachinrange(skill->unit_timer_sub_onplace, bl, su->range, group->bl_flag, bl,tick); + map->foreachinrange(skill->unit_timer_sub_onplace, bl, su->range, group->bl_flag, bl,tick); if(su->range == -1) //Unit disabled, but it should not be deleted yet. group->unit_id = UNT_USED_TRAPS; @@ -15722,16 +15664,15 @@ int skill_unit_timer_sub(DBKey key, DBData *data, va_list ap) { * Executes on all skill units every SKILLUNITTIMER_INTERVAL miliseconds. *------------------------------------------*/ int skill_unit_timer(int tid, unsigned int tick, int id, intptr_t data) { - iMap->freeblock_lock(); + map->freeblock_lock(); - skillunit_db->foreach(skillunit_db, skill->unit_timer_sub, tick); + skill->unit_db->foreach(skill->unit_db, skill->unit_timer_sub, tick); - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 0; } -static int skill_unit_temp[20]; // temporary storage for tracking skill unit skill ids as players move in/out of them /*========================================== * *------------------------------------------*/ @@ -15771,15 +15712,15 @@ int skill_unit_move_sub (struct block_list* bl, va_list ap) { if( group->src_id == target->id && group->state.song_dance&0x2 ) { //Ensemble check to see if they went out/in of the area [Skotlex] if( flag&1 ) { if( flag&2 ) { //Clear this skill id. - ARR_FIND( 0, ARRAYLENGTH(skill_unit_temp), i, skill_unit_temp[i] == skill_id ); - if( i < ARRAYLENGTH(skill_unit_temp) ) - skill_unit_temp[i] = 0; + ARR_FIND( 0, ARRAYLENGTH(skill->unit_temp), i, skill->unit_temp[i] == skill_id ); + if( i < ARRAYLENGTH(skill->unit_temp) ) + skill->unit_temp[i] = 0; } } else { if( flag&2 ) { //Store this skill id. - ARR_FIND( 0, ARRAYLENGTH(skill_unit_temp), i, skill_unit_temp[i] == 0 ); - if( i < ARRAYLENGTH(skill_unit_temp) ) - skill_unit_temp[i] = skill_id; + ARR_FIND( 0, ARRAYLENGTH(skill->unit_temp), i, skill->unit_temp[i] == 0 ); + if( i < ARRAYLENGTH(skill->unit_temp) ) + skill->unit_temp[i] = skill_id; else ShowError("skill_unit_move_sub: Reached limit of unit objects per cell!\n"); } @@ -15797,16 +15738,16 @@ int skill_unit_move_sub (struct block_list* bl, va_list ap) { if( flag&1 ) { int result = skill->unit_onplace(su,target,tick); if( flag&2 && result ) { //Clear skill ids we have stored in onout. - ARR_FIND( 0, ARRAYLENGTH(skill_unit_temp), i, skill_unit_temp[i] == result ); - if( i < ARRAYLENGTH(skill_unit_temp) ) - skill_unit_temp[i] = 0; + ARR_FIND( 0, ARRAYLENGTH(skill->unit_temp), i, skill->unit_temp[i] == result ); + if( i < ARRAYLENGTH(skill->unit_temp) ) + skill->unit_temp[i] = 0; } } else { int result = skill->unit_onout(su,target,tick); if( flag&2 && result ) { //Store this unit id. - ARR_FIND( 0, ARRAYLENGTH(skill_unit_temp), i, skill_unit_temp[i] == 0 ); - if( i < ARRAYLENGTH(skill_unit_temp) ) - skill_unit_temp[i] = skill_id; + ARR_FIND( 0, ARRAYLENGTH(skill->unit_temp), i, skill->unit_temp[i] == 0 ); + if( i < ARRAYLENGTH(skill->unit_temp) ) + skill->unit_temp[i] = skill_id; else ShowError("skill_unit_move_sub: Reached limit of unit objects per cell!\n"); } @@ -15839,16 +15780,16 @@ int skill_unit_move (struct block_list *bl, unsigned int tick, int flag) { return 0; if( flag&2 && !(flag&1) ) { //Onout, clear data - memset(skill_unit_temp, 0, sizeof(skill_unit_temp)); + memset(skill->unit_temp, 0, sizeof(skill->unit_temp)); } - iMap->foreachincell(skill->unit_move_sub,bl->m,bl->x,bl->y,BL_SKILL,bl,tick,flag); + map->foreachincell(skill->unit_move_sub,bl->m,bl->x,bl->y,BL_SKILL,bl,tick,flag); if( flag&2 && flag&1 ) { //Onplace, check any skill units you have left. int i; - for( i = 0; i < ARRAYLENGTH(skill_unit_temp); i++ ) - if( skill_unit_temp[i] ) - skill->unit_onleft(skill_unit_temp[i], bl, tick); + for( i = 0; i < ARRAYLENGTH(skill->unit_temp); i++ ) + if( skill->unit_temp[i] ) + skill->unit_onleft(skill->unit_temp[i], bl, tick); } return 0; @@ -15908,13 +15849,13 @@ int skill_unit_move_unit_group (struct skill_unit_group *group, int16 m, int16 d if (!(m_flag[i]&0x2)) { if (group->state.song_dance&0x1) //Cancel dissonance effect. skill->dance_overlap(su1, 0); - iMap->foreachincell(skill->unit_effect,su1->bl.m,su1->bl.x,su1->bl.y,group->bl_flag,&su1->bl,tick,4); + map->foreachincell(skill->unit_effect,su1->bl.m,su1->bl.x,su1->bl.y,group->bl_flag,&su1->bl,tick,4); } //Move Cell using "smart" criteria (avoid useless moving around) switch(m_flag[i]) { case 0: //Cell moves independently, safely move it. - iMap->moveblock(&su1->bl, su1->bl.x+dx, su1->bl.y+dy, tick); + map->moveblock(&su1->bl, su1->bl.x+dx, su1->bl.y+dy, tick); break; case 1: //Cell moves unto another cell, look for a replacement cell that won't collide @@ -15924,7 +15865,7 @@ int skill_unit_move_unit_group (struct skill_unit_group *group, int16 m, int16 d continue; //Move to where this cell would had moved. su2 = &group->unit[j]; - iMap->moveblock(&su1->bl, su2->bl.x+dx, su2->bl.y+dy, tick); + map->moveblock(&su1->bl, su2->bl.x+dx, su2->bl.y+dy, tick); j++; //Skip this cell as we have used it. break; } @@ -15937,7 +15878,7 @@ int skill_unit_move_unit_group (struct skill_unit_group *group, int16 m, int16 d if (group->state.song_dance&0x1) //Check for dissonance effect. skill->dance_overlap(su1, 1); clif->skill_setunit(su1); - iMap->foreachincell(skill->unit_effect,su1->bl.m,su1->bl.x,su1->bl.y,group->bl_flag,&su1->bl,tick,1); + map->foreachincell(skill->unit_effect,su1->bl.m,su1->bl.x,su1->bl.y,group->bl_flag,&su1->bl,tick,1); } } aFree(m_flag); @@ -15957,9 +15898,9 @@ int skill_can_produce_mix (struct map_session_data *sd, int nameid, int trigger, return 0; for(i=0;i<MAX_SKILL_PRODUCE_DB;i++){ - if(skill_produce_db[i].nameid == nameid ){ - if((j=skill_produce_db[i].req_skill)>0 && - pc->checkskill(sd,j) < skill_produce_db[i].req_skill_lv) + if(skill->produce_db[i].nameid == nameid ){ + if((j=skill->produce_db[i].req_skill)>0 && + pc->checkskill(sd,j) < skill->produce_db[i].req_skill_lv) continue; // must iterate again to check other skills that produce it. [malufett] if( j > 0 && sd->menuskill_id > 0 && sd->menuskill_id != j ) continue; // special case @@ -15977,22 +15918,22 @@ int skill_can_produce_mix (struct map_session_data *sd, int nameid, int trigger, if(trigger>=0){ if(trigger>20) { // Non-weapon, non-food item (itemlv must match) - if(skill_produce_db[i].itemlv!=trigger) + if(skill->produce_db[i].itemlv!=trigger) return 0; } else if(trigger>10) { // Food (any item level between 10 and 20 will do) - if(skill_produce_db[i].itemlv<=10 || skill_produce_db[i].itemlv>20) + if(skill->produce_db[i].itemlv<=10 || skill->produce_db[i].itemlv>20) return 0; } else { // Weapon (itemlv must be higher or equal) - if(skill_produce_db[i].itemlv>trigger) + if(skill->produce_db[i].itemlv>trigger) return 0; } } for(j=0;j<MAX_PRODUCE_RESOURCE;j++){ int id,x,y; - if( (id=skill_produce_db[i].mat_id[j]) <= 0 ) + if( (id=skill->produce_db[i].mat_id[j]) <= 0 ) continue; - if(skill_produce_db[i].mat_amount[j] <= 0) { + if(skill->produce_db[i].mat_amount[j] <= 0) { if(pc->search_inventory(sd,id) < 0) return 0; } @@ -16000,7 +15941,7 @@ int skill_can_produce_mix (struct map_session_data *sd, int nameid, int trigger, for(y=0,x=0;y<MAX_INVENTORY;y++) if( sd->status.inventory[y].nameid == id ) x+=sd->status.inventory[y].amount; - if(x<qty*skill_produce_db[i].mat_amount[j]) + if(x<qty*skill->produce_db[i].mat_amount[j]) return 0; } } @@ -16018,7 +15959,7 @@ int skill_produce_mix(struct map_session_data *sd, uint16 skill_id, int nameid, struct item_data* data; nullpo_ret(sd); - st = iStatus->get_status_data(&sd->bl); + st = status->get_status_data(&sd->bl); if( sd->skill_id_old == skill_id ) skill_lv = sd->skill_lv_old; @@ -16031,7 +15972,7 @@ int skill_produce_mix(struct map_session_data *sd, uint16 skill_id, int nameid, qty = 1; if (!skill_id) //A skill can be specified for some override cases. - skill_id = skill_produce_db[idx].req_skill; + skill_id = skill->produce_db[idx].req_skill; if( skill_id == GC_RESEARCHNEWPOISON ) skill_id = GC_CREATENEWPOISON; @@ -16088,10 +16029,10 @@ int skill_produce_mix(struct map_session_data *sd, uint16 skill_id, int nameid, for(i=0;i<MAX_PRODUCE_RESOURCE;i++){ int j,id,x; - if( (id=skill_produce_db[idx].mat_id[i]) <= 0 ) + if( (id=skill->produce_db[idx].mat_id[i]) <= 0 ) continue; num++; - x=( skill_id == RK_RUNEMASTERY ? 1 : qty)*skill_produce_db[idx].mat_amount[i]; + x=( skill_id == RK_RUNEMASTERY ? 1 : qty)*skill->produce_db[idx].mat_amount[i]; do{ int y=0; j = pc->search_inventory(sd,id); @@ -16232,8 +16173,8 @@ int skill_produce_mix(struct map_session_data *sd, uint16 skill_id, int nameid, break; case GN_CHANGEMATERIAL: for(i=0; i<MAX_SKILL_PRODUCE_DB; i++) - if( skill_changematerial_db[i].itemid == nameid ){ - make_per = skill_changematerial_db[i].rate * 10; + if( skill->changematerial_db[i].itemid == nameid ){ + make_per = skill->changematerial_db[i].rate * 10; break; } break; @@ -16335,7 +16276,7 @@ int skill_produce_mix(struct map_session_data *sd, uint16 skill_id, int nameid, + 20 * (sd->status.base_level + 1) + 20 * (st->dex + 1) + 100 * (rnd()%(30+5*(sd->cook_mastery/400) - (6+sd->cook_mastery/80)) + (6+sd->cook_mastery/80)) - - 400 * (skill_produce_db[idx].itemlv - 11 + 1) + - 400 * (skill->produce_db[idx].itemlv - 11 + 1) - 10 * (100 - st->luk + 1) - 500 * (num - 1) - 100 * (rnd()%4 + 1); @@ -16485,11 +16426,11 @@ int skill_produce_mix(struct map_session_data *sd, uint16 skill_id, int nameid, clif->misceffect(&sd->bl,5); break; default: //Those that don't require a skill? - if( skill_produce_db[idx].itemlv > 10 && skill_produce_db[idx].itemlv <= 20) + if( skill->produce_db[idx].itemlv > 10 && skill->produce_db[idx].itemlv <= 20) { //Cooking items. clif->specialeffect(&sd->bl, 608, AREA); if( sd->cook_mastery < 1999 ) - pc_setglobalreg(sd, "COOK_MASTERY",sd->cook_mastery + ( 1 << ( (skill_produce_db[idx].itemlv - 11) / 2 ) ) * 5); + pc_setglobalreg(sd, "COOK_MASTERY",sd->cook_mastery + ( 1 << ( (skill->produce_db[idx].itemlv - 11) / 2 ) ) * 5); } break; } @@ -16497,13 +16438,13 @@ int skill_produce_mix(struct map_session_data *sd, uint16 skill_id, int nameid, if ( skill_id == GN_CHANGEMATERIAL && tmp_item.amount) { //Success int j, k = 0; for(i=0; i<MAX_SKILL_PRODUCE_DB; i++) - if( skill_changematerial_db[i].itemid == nameid ){ + if( skill->changematerial_db[i].itemid == nameid ){ for(j=0; j<5; j++){ - if( rnd()%1000 < skill_changematerial_db[i].qty_rate[j] ){ - tmp_item.amount = qty * skill_changematerial_db[i].qty[j]; + if( rnd()%1000 < skill->changematerial_db[i].qty_rate[j] ){ + tmp_item.amount = qty * skill->changematerial_db[i].qty[j]; if((flag = pc->additem(sd,&tmp_item,tmp_item.amount,LOG_TYPE_PRODUCE))) { clif->additem(sd,0,0,flag); - iMap->addflooritem(&tmp_item,tmp_item.amount,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); + map->addflooritem(&tmp_item,tmp_item.amount,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); } k++; } @@ -16517,7 +16458,7 @@ int skill_produce_mix(struct map_session_data *sd, uint16 skill_id, int nameid, } else if (tmp_item.amount) { //Success if((flag = pc->additem(sd,&tmp_item,tmp_item.amount,LOG_TYPE_PRODUCE))) { clif->additem(sd,0,0,flag); - iMap->addflooritem(&tmp_item,tmp_item.amount,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); + map->addflooritem(&tmp_item,tmp_item.amount,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); } if( skill_id == GN_MIX_COOKING || skill_id == GN_MAKEBOMB || skill_id == GN_S_PHARMACY ) clif->msg_skill(sd,skill_id,0x627); @@ -16569,7 +16510,7 @@ int skill_produce_mix(struct map_session_data *sd, uint16 skill_id, int nameid, tmp_item.identify = 1; if( pc->additem(sd,&tmp_item,tmp_item.amount,LOG_TYPE_PRODUCE) ) { clif->additem(sd,0,0,flag); - iMap->addflooritem(&tmp_item,tmp_item.amount,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); + map->addflooritem(&tmp_item,tmp_item.amount,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); } clif->msg_skill(sd,skill_id,0x628); } @@ -16580,11 +16521,11 @@ int skill_produce_mix(struct map_session_data *sd, uint16 skill_id, int nameid, clif->msg_skill(sd,skill_id,0x628); break; default: - if( skill_produce_db[idx].itemlv > 10 && skill_produce_db[idx].itemlv <= 20 ) + if( skill->produce_db[idx].itemlv > 10 && skill->produce_db[idx].itemlv <= 20 ) { //Cooking items. clif->specialeffect(&sd->bl, 609, AREA); if( sd->cook_mastery > 0 ) - pc_setglobalreg(sd, "COOK_MASTERY", sd->cook_mastery - ( 1 << ((skill_produce_db[idx].itemlv - 11) / 2) ) - ( ( ( 1 << ((skill_produce_db[idx].itemlv - 11) / 2) ) >> 1 ) * 3 )); + pc_setglobalreg(sd, "COOK_MASTERY", sd->cook_mastery - ( 1 << ((skill->produce_db[idx].itemlv - 11) / 2) ) - ( ( ( 1 << ((skill->produce_db[idx].itemlv - 11) / 2) ) >> 1 ) * 3 )); } } } @@ -16602,7 +16543,7 @@ int skill_arrow_create (struct map_session_data *sd, int nameid) return 1; for(i=0;i<MAX_SKILL_ARROW_DB;i++) - if(nameid == skill_arrow_db[i].nameid) { + if(nameid == skill->arrow_db[i].nameid) { index = i; break; } @@ -16614,8 +16555,8 @@ int skill_arrow_create (struct map_session_data *sd, int nameid) for(i=0;i<MAX_ARROW_RESOURCE;i++) { memset(&tmp_item,0,sizeof(tmp_item)); tmp_item.identify = 1; - tmp_item.nameid = skill_arrow_db[index].cre_id[i]; - tmp_item.amount = skill_arrow_db[index].cre_amount[i]; + tmp_item.nameid = skill->arrow_db[index].cre_id[i]; + tmp_item.amount = skill->arrow_db[index].cre_amount[i]; if(battle_config.produce_item_name_input&0x4) { tmp_item.card[0]=CARD0_CREATE; tmp_item.card[1]=0; @@ -16626,7 +16567,7 @@ int skill_arrow_create (struct map_session_data *sd, int nameid) continue; if((flag = pc->additem(sd,&tmp_item,tmp_item.amount,LOG_TYPE_PRODUCE))) { clif->additem(sd,0,0,flag); - iMap->addflooritem(&tmp_item,tmp_item.amount,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); + map->addflooritem(&tmp_item,tmp_item.amount,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); } } @@ -16663,7 +16604,7 @@ int skill_poisoningweapon( struct map_session_data *sd, int nameid) { } void skill_toggle_magicpower(struct block_list *bl, uint16 skill_id) { - struct status_change *sc = iStatus->get_sc(bl); + struct status_change *sc = status->get_sc(bl); // non-offensive and non-magic skills do not affect the status if (skill->get_nk(skill_id)&NK_NO_DAMAGE || !(skill->get_type(skill_id)&BF_MAGIC)) @@ -16674,7 +16615,7 @@ void skill_toggle_magicpower(struct block_list *bl, uint16 skill_id) { status_change_end(bl, SC_MAGICPOWER, INVALID_TIMER); } else { sc->data[SC_MAGICPOWER]->val4 = 1; - status_calc_bl(bl, iStatus->sc2scb_flag(SC_MAGICPOWER)); + status_calc_bl(bl, status->sc2scb_flag(SC_MAGICPOWER)); #ifndef RENEWAL if(bl->type == BL_PC){// update current display. clif->updatestatus(((TBL_PC *)bl),SP_MATK1); @@ -16729,7 +16670,7 @@ int skill_spellbook (struct map_session_data *sd, int nameid) { nullpo_ret(sd); - sc = iStatus->get_sc(&sd->bl); + sc = status->get_sc(&sd->bl); status_change_end(&sd->bl, SC_STOP, INVALID_TIMER); for(i=SC_SPELLBOOK1; i <= SC_SPELLBOOK7; i++) if( sc && !sc->data[i] ) break; @@ -16739,10 +16680,10 @@ int skill_spellbook (struct map_session_data *sd, int nameid) { return 0; } - ARR_FIND(0,MAX_SKILL_SPELLBOOK_DB,i,skill_spellbook_db[i].nameid == nameid); // Search for information of this item + ARR_FIND(0,MAX_SKILL_SPELLBOOK_DB,i,skill->spellbook_db[i].nameid == nameid); // Search for information of this item if( i == MAX_SKILL_SPELLBOOK_DB ) return 0; - if( !pc->checkskill(sd, (skill_id = skill_spellbook_db[i].skill_id)) ) + if( !pc->checkskill(sd, (skill_id = skill->spellbook_db[i].skill_id)) ) { // User don't know the skill sc_start(&sd->bl, SC_SLEEP, 100, 1, skill->get_time(WL_READING_SB, pc->checkskill(sd,WL_READING_SB))); clif->skill_fail(sd, WL_READING_SB, USESKILL_FAIL_SPELLBOOK_DIFFICULT_SLEEP, 0); @@ -16750,7 +16691,7 @@ int skill_spellbook (struct map_session_data *sd, int nameid) { } max_preserve = 4 * pc->checkskill(sd, WL_FREEZE_SP) + (status_get_int(&sd->bl) + sd->status.base_level) / 10; - point = skill_spellbook_db[i].point; + point = skill->spellbook_db[i].point; if( sc && sc->data[SC_READING_SB] ) { if( (sc->data[SC_READING_SB]->val2 + point) > max_preserve ) { @@ -16854,7 +16795,7 @@ int skill_elementalanalysis(struct map_session_data* sd, int n, uint16 skill_lv, if( tmp_item.amount ) { if( (flag = pc->additem(sd,&tmp_item,tmp_item.amount,LOG_TYPE_CONSUME)) ) { clif->additem(sd,0,0,flag); - iMap->addflooritem(&tmp_item,tmp_item.amount,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); + map->addflooritem(&tmp_item,tmp_item.amount,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); } } @@ -16871,13 +16812,13 @@ int skill_changematerial(struct map_session_data *sd, int n, unsigned short *ite // Search for objects that can be created. for( i = 0; i < MAX_SKILL_PRODUCE_DB; i++ ) { - if( skill_produce_db[i].itemlv == 26 ) { + if( skill->produce_db[i].itemlv == 26 ) { p = 0; do { c = 0; // Verification of overlap between the objects required and the list submitted. for( j = 0; j < MAX_PRODUCE_RESOURCE; j++ ) { - if( skill_produce_db[i].mat_id[j] > 0 ) { + if( skill->produce_db[i].mat_id[j] > 0 ) { for( k = 0; k < n; k++ ) { int idx = item_list[k*2+0]-2; nameid = sd->status.inventory[idx].nameid; @@ -16886,8 +16827,8 @@ int skill_changematerial(struct map_session_data *sd, int n, unsigned short *ite clif->msg_skill(sd,GN_CHANGEMATERIAL,0x62D); return 0; } - if( nameid == skill_produce_db[i].mat_id[j] && (amount-p*skill_produce_db[i].mat_amount[j]) >= skill_produce_db[i].mat_amount[j] - && (amount-p*skill_produce_db[i].mat_amount[j])%skill_produce_db[i].mat_amount[j] == 0 ) // must be in exact amount + if( nameid == skill->produce_db[i].mat_id[j] && (amount-p*skill->produce_db[i].mat_amount[j]) >= skill->produce_db[i].mat_amount[j] + && (amount-p*skill->produce_db[i].mat_amount[j])%skill->produce_db[i].mat_amount[j] == 0 ) // must be in exact amount c++; // match } } @@ -16898,7 +16839,7 @@ int skill_changematerial(struct map_session_data *sd, int n, unsigned short *ite } while(n == j && c == n); p--; if ( p > 0 ) { - skill->produce_mix(sd,GN_CHANGEMATERIAL,skill_produce_db[i].nameid,0,0,0,p); + skill->produce_mix(sd,GN_CHANGEMATERIAL,skill->produce_db[i].nameid,0,0,0,p); return 1; } } @@ -16925,7 +16866,7 @@ int skill_destroy_trap( struct block_list *bl, va_list ap ) { case UNT_CLAYMORETRAP: case UNT_FIRINGTRAP: case UNT_ICEBOUNDTRAP: - iMap->foreachinrange(skill->trap_splash,&su->bl, skill->get_splash(sg->skill_id, sg->skill_lv), sg->bl_flag|BL_SKILL|~BCT_SELF, &su->bl,tick); + map->foreachinrange(skill->trap_splash,&su->bl, skill->get_splash(sg->skill_id, sg->skill_lv), sg->bl_flag|BL_SKILL|~BCT_SELF, &su->bl,tick); break; case UNT_LANDMINE: case UNT_BLASTMINE: @@ -16934,7 +16875,7 @@ int skill_destroy_trap( struct block_list *bl, va_list ap ) { case UNT_FLASHER: case UNT_FREEZINGTRAP: case UNT_CLUSTERBOMB: - iMap->foreachinrange(skill->trap_splash,&su->bl, skill->get_splash(sg->skill_id, sg->skill_lv), sg->bl_flag, &su->bl,tick); + map->foreachinrange(skill->trap_splash,&su->bl, skill->get_splash(sg->skill_id, sg->skill_lv), sg->bl_flag, &su->bl,tick); break; } // Traps aren't recovered. @@ -16946,7 +16887,7 @@ int skill_destroy_trap( struct block_list *bl, va_list ap ) { * *------------------------------------------*/ int skill_blockpc_end(int tid, unsigned int tick, int id, intptr_t data) { - struct map_session_data *sd = iMap->id2sd(id); + struct map_session_data *sd = map->id2sd(id); struct skill_cd * cd = NULL; if (data <= 0 || data >= MAX_SKILL) @@ -17055,7 +16996,7 @@ int skill_blockpc_start_(struct map_session_data *sd, uint16 skill_id, int tick, } int skill_blockhomun_end(int tid, unsigned int tick, int id, intptr_t data) { //[orn] - struct homun_data *hd = (TBL_HOM*) iMap->id2bl(id); + struct homun_data *hd = (TBL_HOM*)map->id2bl(id); if (data <= 0 || data >= MAX_SKILL) return 0; if (hd) hd->blockskill[data] = 0; @@ -17080,7 +17021,7 @@ int skill_blockhomun_start(struct homun_data *hd, uint16 skill_id, int tick) { / } int skill_blockmerc_end(int tid, unsigned int tick, int id, intptr_t data) {//[orn] - struct mercenary_data *md = (TBL_MER*)iMap->id2bl(id); + struct mercenary_data *md = (TBL_MER*)map->id2bl(id); if( data <= 0 || data >= MAX_SKILL ) return 0; if( md ) md->blockskill[data] = 0; @@ -17107,14 +17048,14 @@ int skill_blockmerc_start(struct mercenary_data *md, uint16 skill_id, int tick) * Adds a new skill unit entry for this player to recast after map load **/ void skill_usave_add(struct map_session_data * sd, uint16 skill_id, uint16 skill_lv) { - struct skill_usave * sus = NULL; + struct skill_unit_save * sus = NULL; - if( idb_exists(skillusave_db,sd->status.char_id) ) { - idb_remove(skillusave_db,sd->status.char_id); + if( idb_exists(skill->usave_db,sd->status.char_id) ) { + idb_remove(skill->usave_db,sd->status.char_id); } - CREATE( sus, struct skill_usave, 1 ); - idb_put( skillusave_db, sd->status.char_id, sus ); + CREATE( sus, struct skill_unit_save, 1 ); + idb_put( skill->usave_db, sd->status.char_id, sus ); sus->skill_id = skill_id; sus->skill_lv = skill_lv; @@ -17122,15 +17063,15 @@ void skill_usave_add(struct map_session_data * sd, uint16 skill_id, uint16 skill return; } void skill_usave_trigger(struct map_session_data *sd) { - struct skill_usave * sus = NULL; + struct skill_unit_save * sus = NULL; - if( ! (sus = idb_get(skillusave_db,sd->status.char_id)) ) { + if( ! (sus = idb_get(skill->usave_db,sd->status.char_id)) ) { return; } skill->unitsetting(&sd->bl,sus->skill_id,sus->skill_lv,sd->bl.x,sd->bl.y,0); - idb_remove(skillusave_db,sd->status.char_id); + idb_remove(skill->usave_db,sd->status.char_id); return; } @@ -17198,25 +17139,27 @@ int skill_split_atoi (char *str, int *val) { void skill_init_unit_layout (void) { int i,j,size,pos = 0; - memset(skill_unit_layout,0,sizeof(skill_unit_layout)); + //when != it was already cleared during skill_defaults() no need to repeat + if( runflag == MAPSERVER_ST_RUNNING ) + memset(skill->unit_layout,0,sizeof(skill->unit_layout)); // standard square layouts go first for (i=0; i<=MAX_SQUARE_LAYOUT; i++) { size = i*2+1; - skill_unit_layout[i].count = size*size; + skill->unit_layout[i].count = size*size; for (j=0; j<size*size; j++) { - skill_unit_layout[i].dx[j] = (j%size-i); - skill_unit_layout[i].dy[j] = (j/size-i); + skill->unit_layout[i].dx[j] = (j%size-i); + skill->unit_layout[i].dy[j] = (j/size-i); } } // afterwards add special ones pos = i; for (i=0;i<MAX_SKILL_DB;i++) { - if (!skill_db[i].unit_id[0] || skill_db[i].unit_layout_type[0] != -1) + if (!skill->db[i].unit_id[0] || skill->db[i].unit_layout_type[0] != -1) continue; - switch (skill_db[i].nameid) { + switch (skill->db[i].nameid) { case MG_FIREWALL: case WZ_ICEWALL: case WL_EARTHSTRAIN://Warlock @@ -17230,9 +17173,9 @@ void skill_init_unit_layout (void) { static const int dy[]={ -2,-2,-2,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2}; - skill_unit_layout[pos].count = 21; - memcpy(skill_unit_layout[pos].dx,dx,sizeof(dx)); - memcpy(skill_unit_layout[pos].dy,dy,sizeof(dy)); + skill->unit_layout[pos].count = 21; + memcpy(skill->unit_layout[pos].dx,dx,sizeof(dx)); + memcpy(skill->unit_layout[pos].dy,dy,sizeof(dy)); } break; case PR_MAGNUS: { @@ -17244,18 +17187,18 @@ void skill_init_unit_layout (void) { -3,-3,-3,-2,-2,-2,-1,-1,-1,-1, -1,-1,-1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3}; - skill_unit_layout[pos].count = 33; - memcpy(skill_unit_layout[pos].dx,dx,sizeof(dx)); - memcpy(skill_unit_layout[pos].dy,dy,sizeof(dy)); + skill->unit_layout[pos].count = 33; + memcpy(skill->unit_layout[pos].dx,dx,sizeof(dx)); + memcpy(skill->unit_layout[pos].dy,dy,sizeof(dy)); } break; case MH_POISON_MIST: case AS_VENOMDUST: { static const int dx[] = {-1, 0, 0, 0, 1}; static const int dy[] = { 0,-1, 0, 1, 0}; - skill_unit_layout[pos].count = 5; - memcpy(skill_unit_layout[pos].dx,dx,sizeof(dx)); - memcpy(skill_unit_layout[pos].dy,dy,sizeof(dy)); + skill->unit_layout[pos].count = 5; + memcpy(skill->unit_layout[pos].dx,dx,sizeof(dx)); + memcpy(skill->unit_layout[pos].dy,dy,sizeof(dy)); } break; case CR_GRANDCROSS: @@ -17268,9 +17211,9 @@ void skill_init_unit_layout (void) { -4,-3,-2,-2,-2,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 3, 4}; - skill_unit_layout[pos].count = 29; - memcpy(skill_unit_layout[pos].dx,dx,sizeof(dx)); - memcpy(skill_unit_layout[pos].dy,dy,sizeof(dy)); + skill->unit_layout[pos].count = 29; + memcpy(skill->unit_layout[pos].dx,dx,sizeof(dx)); + memcpy(skill->unit_layout[pos].dy,dy,sizeof(dy)); } break; case PF_FOGWALL: { @@ -17278,9 +17221,9 @@ void skill_init_unit_layout (void) { -2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2}; static const int dy[] = { -1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1}; - skill_unit_layout[pos].count = 15; - memcpy(skill_unit_layout[pos].dx,dx,sizeof(dx)); - memcpy(skill_unit_layout[pos].dy,dy,sizeof(dy)); + skill->unit_layout[pos].count = 15; + memcpy(skill->unit_layout[pos].dx,dx,sizeof(dx)); + memcpy(skill->unit_layout[pos].dy,dy,sizeof(dy)); } break; case PA_GOSPEL: { @@ -17294,17 +17237,17 @@ void skill_init_unit_layout (void) { -1,-1,-1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3}; - skill_unit_layout[pos].count = 33; - memcpy(skill_unit_layout[pos].dx,dx,sizeof(dx)); - memcpy(skill_unit_layout[pos].dy,dy,sizeof(dy)); + skill->unit_layout[pos].count = 33; + memcpy(skill->unit_layout[pos].dx,dx,sizeof(dx)); + memcpy(skill->unit_layout[pos].dy,dy,sizeof(dy)); } break; case NJ_KAENSIN: { static const int dx[] = {-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2}; static const int dy[] = { 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 0, 0, 0, 0,-1,-1,-1,-1,-1,-2,-2,-2,-2,-2}; - skill_unit_layout[pos].count = 24; - memcpy(skill_unit_layout[pos].dx,dx,sizeof(dx)); - memcpy(skill_unit_layout[pos].dy,dy,sizeof(dy)); + skill->unit_layout[pos].count = 24; + memcpy(skill->unit_layout[pos].dx,dx,sizeof(dx)); + memcpy(skill->unit_layout[pos].dy,dy,sizeof(dy)); } break; case NJ_TATAMIGAESHI: { @@ -17319,29 +17262,29 @@ void skill_init_unit_layout (void) { static const int dy3[] = { 0, 0, 0, 0, 0, 0,-3,-2,-1, 1, 2, 3}; //lv1 j = 0; - skill_unit_layout[pos].count = 4; - memcpy(skill_unit_layout[pos].dx,dx1,sizeof(dx1)); - memcpy(skill_unit_layout[pos].dy,dy1,sizeof(dy1)); - skill_db[i].unit_layout_type[j] = pos; + skill->unit_layout[pos].count = 4; + memcpy(skill->unit_layout[pos].dx,dx1,sizeof(dx1)); + memcpy(skill->unit_layout[pos].dy,dy1,sizeof(dy1)); + skill->db[i].unit_layout_type[j] = pos; //lv2/3 j++; pos++; - skill_unit_layout[pos].count = 8; - memcpy(skill_unit_layout[pos].dx,dx2,sizeof(dx2)); - memcpy(skill_unit_layout[pos].dy,dy2,sizeof(dy2)); - skill_db[i].unit_layout_type[j] = pos; - skill_db[i].unit_layout_type[++j] = pos; + skill->unit_layout[pos].count = 8; + memcpy(skill->unit_layout[pos].dx,dx2,sizeof(dx2)); + memcpy(skill->unit_layout[pos].dy,dy2,sizeof(dy2)); + skill->db[i].unit_layout_type[j] = pos; + skill->db[i].unit_layout_type[++j] = pos; //lv4/5 j++; pos++; - skill_unit_layout[pos].count = 12; - memcpy(skill_unit_layout[pos].dx,dx3,sizeof(dx3)); - memcpy(skill_unit_layout[pos].dy,dy3,sizeof(dy3)); - skill_db[i].unit_layout_type[j] = pos; - skill_db[i].unit_layout_type[++j] = pos; + skill->unit_layout[pos].count = 12; + memcpy(skill->unit_layout[pos].dx,dx3,sizeof(dx3)); + memcpy(skill->unit_layout[pos].dy,dy3,sizeof(dy3)); + skill->db[i].unit_layout_type[j] = pos; + skill->db[i].unit_layout_type[++j] = pos; //Fill in the rest using lv 5. for (;j<MAX_SKILL_LEVEL;j++) - skill_db[i].unit_layout_type[j] = pos; + skill->db[i].unit_layout_type[j] = pos; //Skip, this way the check below will fail and continue to the next skill. pos++; } @@ -17349,104 +17292,104 @@ void skill_init_unit_layout (void) { case GN_WALLOFTHORN: { static const int dx[] = {-1,-2,-2,-2,-2,-2,-1, 0, 1, 2, 2, 2, 2, 2, 1, 0}; static const int dy[] = { 2, 2, 1, 0,-1,-2,-2,-2,-2,-2,-1, 0, 1, 2, 2, 2}; - skill_unit_layout[pos].count = 16; - memcpy(skill_unit_layout[pos].dx,dx,sizeof(dx)); - memcpy(skill_unit_layout[pos].dy,dy,sizeof(dy)); + skill->unit_layout[pos].count = 16; + memcpy(skill->unit_layout[pos].dx,dx,sizeof(dx)); + memcpy(skill->unit_layout[pos].dy,dy,sizeof(dy)); } break; case EL_FIRE_MANTLE: { static const int dx[] = {-1, 0, 1, 1, 1, 0,-1,-1}; static const int dy[] = { 1, 1, 1, 0,-1,-1,-1, 0}; - skill_unit_layout[pos].count = 8; - memcpy(skill_unit_layout[pos].dx,dx,sizeof(dx)); - memcpy(skill_unit_layout[pos].dy,dy,sizeof(dy)); + skill->unit_layout[pos].count = 8; + memcpy(skill->unit_layout[pos].dx,dx,sizeof(dx)); + memcpy(skill->unit_layout[pos].dy,dy,sizeof(dy)); } break; default: ShowError("unknown unit layout at skill %d\n",i); break; } - if (!skill_unit_layout[pos].count) + if (!skill->unit_layout[pos].count) continue; for (j=0;j<MAX_SKILL_LEVEL;j++) - skill_db[i].unit_layout_type[j] = pos; + skill->db[i].unit_layout_type[j] = pos; pos++; } // firewall and icewall have 8 layouts (direction-dependent) - firewall_unit_pos = pos; + skill->firewall_unit_pos = pos; for (i=0;i<8;i++) { if (i&1) { - skill_unit_layout[pos].count = 5; + skill->unit_layout[pos].count = 5; if (i&0x2) { int dx[] = {-1,-1, 0, 0, 1}; int dy[] = { 1, 0, 0,-1,-1}; - memcpy(skill_unit_layout[pos].dx,dx,sizeof(dx)); - memcpy(skill_unit_layout[pos].dy,dy,sizeof(dy)); + memcpy(skill->unit_layout[pos].dx,dx,sizeof(dx)); + memcpy(skill->unit_layout[pos].dy,dy,sizeof(dy)); } else { int dx[] = { 1, 1 ,0, 0,-1}; int dy[] = { 1, 0, 0,-1,-1}; - memcpy(skill_unit_layout[pos].dx,dx,sizeof(dx)); - memcpy(skill_unit_layout[pos].dy,dy,sizeof(dy)); + memcpy(skill->unit_layout[pos].dx,dx,sizeof(dx)); + memcpy(skill->unit_layout[pos].dy,dy,sizeof(dy)); } } else { - skill_unit_layout[pos].count = 3; + skill->unit_layout[pos].count = 3; if (i%4==0) { int dx[] = {-1, 0, 1}; int dy[] = { 0, 0, 0}; - memcpy(skill_unit_layout[pos].dx,dx,sizeof(dx)); - memcpy(skill_unit_layout[pos].dy,dy,sizeof(dy)); + memcpy(skill->unit_layout[pos].dx,dx,sizeof(dx)); + memcpy(skill->unit_layout[pos].dy,dy,sizeof(dy)); } else { int dx[] = { 0, 0, 0}; int dy[] = {-1, 0, 1}; - memcpy(skill_unit_layout[pos].dx,dx,sizeof(dx)); - memcpy(skill_unit_layout[pos].dy,dy,sizeof(dy)); + memcpy(skill->unit_layout[pos].dx,dx,sizeof(dx)); + memcpy(skill->unit_layout[pos].dy,dy,sizeof(dy)); } } pos++; } - icewall_unit_pos = pos; + skill->icewall_unit_pos = pos; for (i=0;i<8;i++) { - skill_unit_layout[pos].count = 5; + skill->unit_layout[pos].count = 5; if (i&1) { if (i&0x2) { int dx[] = {-2,-1, 0, 1, 2}; int dy[] = { 2, 1, 0,-1,-2}; - memcpy(skill_unit_layout[pos].dx,dx,sizeof(dx)); - memcpy(skill_unit_layout[pos].dy,dy,sizeof(dy)); + memcpy(skill->unit_layout[pos].dx,dx,sizeof(dx)); + memcpy(skill->unit_layout[pos].dy,dy,sizeof(dy)); } else { int dx[] = { 2, 1 ,0,-1,-2}; int dy[] = { 2, 1, 0,-1,-2}; - memcpy(skill_unit_layout[pos].dx,dx,sizeof(dx)); - memcpy(skill_unit_layout[pos].dy,dy,sizeof(dy)); + memcpy(skill->unit_layout[pos].dx,dx,sizeof(dx)); + memcpy(skill->unit_layout[pos].dy,dy,sizeof(dy)); } } else { if (i%4==0) { int dx[] = {-2,-1, 0, 1, 2}; int dy[] = { 0, 0, 0, 0, 0}; - memcpy(skill_unit_layout[pos].dx,dx,sizeof(dx)); - memcpy(skill_unit_layout[pos].dy,dy,sizeof(dy)); + memcpy(skill->unit_layout[pos].dx,dx,sizeof(dx)); + memcpy(skill->unit_layout[pos].dy,dy,sizeof(dy)); } else { int dx[] = { 0, 0, 0, 0, 0}; int dy[] = {-2,-1, 0, 1, 2}; - memcpy(skill_unit_layout[pos].dx,dx,sizeof(dx)); - memcpy(skill_unit_layout[pos].dy,dy,sizeof(dy)); + memcpy(skill->unit_layout[pos].dx,dx,sizeof(dx)); + memcpy(skill->unit_layout[pos].dy,dy,sizeof(dy)); } } pos++; } - earthstrain_unit_pos = pos; + skill->earthstrain_unit_pos = pos; for( i = 0; i < 8; i++ ) { // For each Direction - skill_unit_layout[pos].count = 15; + skill->unit_layout[pos].count = 15; switch( i ) { case 0: case 1: case 3: case 4: case 5: case 7: { int dx[] = {-7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7}; int dy[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - memcpy(skill_unit_layout[pos].dx,dx,sizeof(dx)); - memcpy(skill_unit_layout[pos].dy,dy,sizeof(dy)); + memcpy(skill->unit_layout[pos].dx,dx,sizeof(dx)); + memcpy(skill->unit_layout[pos].dy,dy,sizeof(dy)); } break; case 2: @@ -17454,8 +17397,8 @@ void skill_init_unit_layout (void) { { int dx[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; int dy[] = {-7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7}; - memcpy(skill_unit_layout[pos].dx,dx,sizeof(dx)); - memcpy(skill_unit_layout[pos].dy,dy,sizeof(dy)); + memcpy(skill->unit_layout[pos].dx,dx,sizeof(dx)); + memcpy(skill->unit_layout[pos].dy,dy,sizeof(dy)); } break; } @@ -17466,7 +17409,7 @@ void skill_init_unit_layout (void) { int skill_block_check(struct block_list *bl, sc_type type , uint16 skill_id) { int inf = 0; - struct status_change *sc = iStatus->get_sc(bl); + struct status_change *sc = status->get_sc(bl); if( !sc || !bl || !skill_id ) return 0; // Can do it @@ -17610,35 +17553,35 @@ bool skill_parse_row_skilldb(char* split[], int columns, int current) { if( !idx ) // invalid skill id return false; - skill_db[idx].nameid = skill_id; - skill->split_atoi(split[1],skill_db[idx].range); - skill_db[idx].hit = atoi(split[2]); - skill_db[idx].inf = atoi(split[3]); - skill->split_atoi(split[4],skill_db[idx].element); - skill_db[idx].nk = (int)strtol(split[5], NULL, 0); - skill->split_atoi(split[6],skill_db[idx].splash); - skill_db[idx].max = atoi(split[7]); - skill->split_atoi(split[8],skill_db[idx].num); + skill->db[idx].nameid = skill_id; + skill->split_atoi(split[1],skill->db[idx].range); + skill->db[idx].hit = atoi(split[2]); + skill->db[idx].inf = atoi(split[3]); + skill->split_atoi(split[4],skill->db[idx].element); + skill->db[idx].nk = (int)strtol(split[5], NULL, 0); + skill->split_atoi(split[6],skill->db[idx].splash); + skill->db[idx].max = atoi(split[7]); + skill->split_atoi(split[8],skill->db[idx].num); if( strcmpi(split[9],"yes") == 0 ) - skill_db[idx].castcancel = 1; + skill->db[idx].castcancel = 1; else - skill_db[idx].castcancel = 0; - skill_db[idx].cast_def_rate = atoi(split[10]); - skill_db[idx].inf2 = (int)strtol(split[11], NULL, 0); - skill->split_atoi(split[12],skill_db[idx].maxcount); + skill->db[idx].castcancel = 0; + skill->db[idx].cast_def_rate = atoi(split[10]); + skill->db[idx].inf2 = (int)strtol(split[11], NULL, 0); + skill->split_atoi(split[12],skill->db[idx].maxcount); if( strcmpi(split[13],"weapon") == 0 ) - skill_db[idx].skill_type = BF_WEAPON; + skill->db[idx].skill_type = BF_WEAPON; else if( strcmpi(split[13],"magic") == 0 ) - skill_db[idx].skill_type = BF_MAGIC; + skill->db[idx].skill_type = BF_MAGIC; else if( strcmpi(split[13],"misc") == 0 ) - skill_db[idx].skill_type = BF_MISC; + skill->db[idx].skill_type = BF_MISC; else - skill_db[idx].skill_type = 0; - skill->split_atoi(split[14],skill_db[idx].blewcount); - safestrncpy(skill_db[idx].name, trim(split[15]), sizeof(skill_db[idx].name)); - safestrncpy(skill_db[idx].desc, trim(split[16]), sizeof(skill_db[idx].desc)); - strdb_iput(skilldb_name2id, skill_db[idx].name, skill_id); + skill->db[idx].skill_type = 0; + skill->split_atoi(split[14],skill->db[idx].blewcount); + safestrncpy(skill->db[idx].name, trim(split[15]), sizeof(skill->db[idx].name)); + safestrncpy(skill->db[idx].desc, trim(split[16]), sizeof(skill->db[idx].desc)); + strdb_iput(skill->name2id_db, skill->db[idx].name, skill_id); return true; } @@ -17653,22 +17596,22 @@ bool skill_parse_row_requiredb(char* split[], int columns, int current) { if( !idx ) // invalid skill id return false; - skill->split_atoi(split[1],skill_db[idx].hp); - skill->split_atoi(split[2],skill_db[idx].mhp); - skill->split_atoi(split[3],skill_db[idx].sp); - skill->split_atoi(split[4],skill_db[idx].hp_rate); - skill->split_atoi(split[5],skill_db[idx].sp_rate); - skill->split_atoi(split[6],skill_db[idx].zeny); + skill->split_atoi(split[1],skill->db[idx].hp); + skill->split_atoi(split[2],skill->db[idx].mhp); + skill->split_atoi(split[3],skill->db[idx].sp); + skill->split_atoi(split[4],skill->db[idx].hp_rate); + skill->split_atoi(split[5],skill->db[idx].sp_rate); + skill->split_atoi(split[6],skill->db[idx].zeny); //Wich weapon type are required, see doc/item_db for types p = split[7]; for( j = 0; j < 32; j++ ) { int l = atoi(p); if( l == 99 ) { // Any weapon - skill_db[idx].weapon = 0; + skill->db[idx].weapon = 0; break; } else - skill_db[idx].weapon |= 1<<l; + skill->db[idx].weapon |= 1<<l; p = strchr(p,':'); if(!p) break; @@ -17680,49 +17623,49 @@ bool skill_parse_row_requiredb(char* split[], int columns, int current) { for( j = 0; j < 32; j++ ) { int l = atoi(p); if( l == 99 ) { // Any ammo type - skill_db[idx].ammo = 0xFFFFFFFF; + skill->db[idx].ammo = 0xFFFFFFFF; break; } else if( l ) // 0 stands for no requirement - skill_db[idx].ammo |= 1<<l; + skill->db[idx].ammo |= 1<<l; p = strchr(p,':'); if( !p ) break; p++; } - skill->split_atoi(split[9],skill_db[idx].ammo_qty); - - if( strcmpi(split[10],"hiding") == 0 ) skill_db[idx].state = ST_HIDING; - else if( strcmpi(split[10],"cloaking") == 0 ) skill_db[idx].state = ST_CLOAKING; - else if( strcmpi(split[10],"hidden") == 0 ) skill_db[idx].state = ST_HIDDEN; - else if( strcmpi(split[10],"riding") == 0 ) skill_db[idx].state = ST_RIDING; - else if( strcmpi(split[10],"falcon") == 0 ) skill_db[idx].state = ST_FALCON; - else if( strcmpi(split[10],"cart") == 0 ) skill_db[idx].state = ST_CART; - else if( strcmpi(split[10],"shield") == 0 ) skill_db[idx].state = ST_SHIELD; - else if( strcmpi(split[10],"sight") == 0 ) skill_db[idx].state = ST_SIGHT; - else if( strcmpi(split[10],"explosionspirits") == 0 ) skill_db[idx].state = ST_EXPLOSIONSPIRITS; - else if( strcmpi(split[10],"cartboost") == 0 ) skill_db[idx].state = ST_CARTBOOST; - else if( strcmpi(split[10],"recover_weight_rate") == 0 ) skill_db[idx].state = ST_RECOV_WEIGHT_RATE; - else if( strcmpi(split[10],"move_enable") == 0 ) skill_db[idx].state = ST_MOVE_ENABLE; - else if( strcmpi(split[10],"water") == 0 ) skill_db[idx].state = ST_WATER; - else if( strcmpi(split[10],"dragon") == 0 ) skill_db[idx].state = ST_RIDINGDRAGON; - else if( strcmpi(split[10],"warg") == 0 ) skill_db[idx].state = ST_WUG; - else if( strcmpi(split[10],"ridingwarg") == 0 ) skill_db[idx].state = ST_RIDINGWUG; - else if( strcmpi(split[10],"mado") == 0 ) skill_db[idx].state = ST_MADO; - else if( strcmpi(split[10],"elementalspirit") == 0 ) skill_db[idx].state = ST_ELEMENTALSPIRIT; - else if( strcmpi(split[10],"poisonweapon") == 0 ) skill_db[idx].state = ST_POISONINGWEAPON; - else if( strcmpi(split[10],"rollingcutter") == 0 ) skill_db[idx].state = ST_ROLLINGCUTTER; - else if( strcmpi(split[10],"mh_fighting") == 0 ) skill_db[idx].state = ST_MH_FIGHTING; - else if( strcmpi(split[10],"mh_grappling") == 0 ) skill_db[idx].state = ST_MH_GRAPPLING; - else if( strcmpi(split[10],"peco") == 0 ) skill_db[idx].state = ST_PECO; + skill->split_atoi(split[9],skill->db[idx].ammo_qty); + + if( strcmpi(split[10],"hiding") == 0 ) skill->db[idx].state = ST_HIDING; + else if( strcmpi(split[10],"cloaking") == 0 ) skill->db[idx].state = ST_CLOAKING; + else if( strcmpi(split[10],"hidden") == 0 ) skill->db[idx].state = ST_HIDDEN; + else if( strcmpi(split[10],"riding") == 0 ) skill->db[idx].state = ST_RIDING; + else if( strcmpi(split[10],"falcon") == 0 ) skill->db[idx].state = ST_FALCON; + else if( strcmpi(split[10],"cart") == 0 ) skill->db[idx].state = ST_CART; + else if( strcmpi(split[10],"shield") == 0 ) skill->db[idx].state = ST_SHIELD; + else if( strcmpi(split[10],"sight") == 0 ) skill->db[idx].state = ST_SIGHT; + else if( strcmpi(split[10],"explosionspirits") == 0 ) skill->db[idx].state = ST_EXPLOSIONSPIRITS; + else if( strcmpi(split[10],"cartboost") == 0 ) skill->db[idx].state = ST_CARTBOOST; + else if( strcmpi(split[10],"recover_weight_rate") == 0 ) skill->db[idx].state = ST_RECOV_WEIGHT_RATE; + else if( strcmpi(split[10],"move_enable") == 0 ) skill->db[idx].state = ST_MOVE_ENABLE; + else if( strcmpi(split[10],"water") == 0 ) skill->db[idx].state = ST_WATER; + else if( strcmpi(split[10],"dragon") == 0 ) skill->db[idx].state = ST_RIDINGDRAGON; + else if( strcmpi(split[10],"warg") == 0 ) skill->db[idx].state = ST_WUG; + else if( strcmpi(split[10],"ridingwarg") == 0 ) skill->db[idx].state = ST_RIDINGWUG; + else if( strcmpi(split[10],"mado") == 0 ) skill->db[idx].state = ST_MADO; + else if( strcmpi(split[10],"elementalspirit") == 0 ) skill->db[idx].state = ST_ELEMENTALSPIRIT; + else if( strcmpi(split[10],"poisonweapon") == 0 ) skill->db[idx].state = ST_POISONINGWEAPON; + else if( strcmpi(split[10],"rollingcutter") == 0 ) skill->db[idx].state = ST_ROLLINGCUTTER; + else if( strcmpi(split[10],"mh_fighting") == 0 ) skill->db[idx].state = ST_MH_FIGHTING; + else if( strcmpi(split[10],"mh_grappling") == 0 ) skill->db[idx].state = ST_MH_GRAPPLING; + else if( strcmpi(split[10],"peco") == 0 ) skill->db[idx].state = ST_PECO; /** * Unknown or no state **/ - else skill_db[idx].state = ST_NONE; + else skill->db[idx].state = ST_NONE; - skill->split_atoi(split[11],skill_db[idx].spiritball); + skill->split_atoi(split[11],skill->db[idx].spiritball); for( j = 0; j < MAX_SKILL_ITEM_REQUIRE; j++ ) { - skill_db[idx].itemid[j] = atoi(split[12+ 2*j]); - skill_db[idx].amount[j] = atoi(split[13+ 2*j]); + skill->db[idx].itemid[j] = atoi(split[12+ 2*j]); + skill->db[idx].amount[j] = atoi(split[13+ 2*j]); } return true; @@ -17735,14 +17678,14 @@ bool skill_parse_row_castdb(char* split[], int columns, int current) { if( !idx ) // invalid skill id return false; - skill->split_atoi(split[1],skill_db[idx].cast); - skill->split_atoi(split[2],skill_db[idx].delay); - skill->split_atoi(split[3],skill_db[idx].walkdelay); - skill->split_atoi(split[4],skill_db[idx].upkeep_time); - skill->split_atoi(split[5],skill_db[idx].upkeep_time2); - skill->split_atoi(split[6],skill_db[idx].cooldown); + skill->split_atoi(split[1],skill->db[idx].cast); + skill->split_atoi(split[2],skill->db[idx].delay); + skill->split_atoi(split[3],skill->db[idx].walkdelay); + skill->split_atoi(split[4],skill->db[idx].upkeep_time); + skill->split_atoi(split[5],skill->db[idx].upkeep_time2); + skill->split_atoi(split[6],skill->db[idx].cooldown); #ifdef RENEWAL_CAST - skill->split_atoi(split[7],skill_db[idx].fixed_cast); + skill->split_atoi(split[7],skill->db[idx].fixed_cast); #endif return true; } @@ -17754,9 +17697,9 @@ bool skill_parse_row_castnodexdb(char* split[], int columns, int current) { if( !idx ) // invalid skill id return false; - skill->split_atoi(split[1],skill_db[idx].castnodex); + skill->split_atoi(split[1],skill->db[idx].castnodex); if( split[2] ) // optional column - skill->split_atoi(split[2],skill_db[idx].delaynodex); + skill->split_atoi(split[2],skill->db[idx].delaynodex); return true; } @@ -17768,37 +17711,37 @@ bool skill_parse_row_unitdb(char* split[], int columns, int current) { if( !idx ) // invalid skill id return false; - skill_db[idx].unit_id[0] = strtol(split[1],NULL,16); - skill_db[idx].unit_id[1] = strtol(split[2],NULL,16); - skill->split_atoi(split[3],skill_db[idx].unit_layout_type); - skill->split_atoi(split[4],skill_db[idx].unit_range); - skill_db[idx].unit_interval = atoi(split[5]); - - if( strcmpi(split[6],"noenemy")==0 ) skill_db[idx].unit_target = BCT_NOENEMY; - else if( strcmpi(split[6],"friend")==0 ) skill_db[idx].unit_target = BCT_NOENEMY; - else if( strcmpi(split[6],"party")==0 ) skill_db[idx].unit_target = BCT_PARTY; - else if( strcmpi(split[6],"ally")==0 ) skill_db[idx].unit_target = BCT_PARTY|BCT_GUILD; - else if( strcmpi(split[6],"guild")==0 ) skill_db[idx].unit_target = BCT_GUILD; - else if( strcmpi(split[6],"all")==0 ) skill_db[idx].unit_target = BCT_ALL; - else if( strcmpi(split[6],"enemy")==0 ) skill_db[idx].unit_target = BCT_ENEMY; - else if( strcmpi(split[6],"self")==0 ) skill_db[idx].unit_target = BCT_SELF; - else if( strcmpi(split[6],"sameguild")==0 ) skill_db[idx].unit_target = BCT_GUILD|BCT_SAMEGUILD; - else if( strcmpi(split[6],"noone")==0 ) skill_db[idx].unit_target = BCT_NOONE; - else skill_db[idx].unit_target = strtol(split[6],NULL,16); - - skill_db[idx].unit_flag = strtol(split[7],NULL,16); - - if (skill_db[idx].unit_flag&UF_DEFNOTENEMY && battle_config.defnotenemy) - skill_db[idx].unit_target = BCT_NOENEMY; + skill->db[idx].unit_id[0] = strtol(split[1],NULL,16); + skill->db[idx].unit_id[1] = strtol(split[2],NULL,16); + skill->split_atoi(split[3],skill->db[idx].unit_layout_type); + skill->split_atoi(split[4],skill->db[idx].unit_range); + skill->db[idx].unit_interval = atoi(split[5]); + + if( strcmpi(split[6],"noenemy")==0 ) skill->db[idx].unit_target = BCT_NOENEMY; + else if( strcmpi(split[6],"friend")==0 ) skill->db[idx].unit_target = BCT_NOENEMY; + else if( strcmpi(split[6],"party")==0 ) skill->db[idx].unit_target = BCT_PARTY; + else if( strcmpi(split[6],"ally")==0 ) skill->db[idx].unit_target = BCT_PARTY|BCT_GUILD; + else if( strcmpi(split[6],"guild")==0 ) skill->db[idx].unit_target = BCT_GUILD; + else if( strcmpi(split[6],"all")==0 ) skill->db[idx].unit_target = BCT_ALL; + else if( strcmpi(split[6],"enemy")==0 ) skill->db[idx].unit_target = BCT_ENEMY; + else if( strcmpi(split[6],"self")==0 ) skill->db[idx].unit_target = BCT_SELF; + else if( strcmpi(split[6],"sameguild")==0 ) skill->db[idx].unit_target = BCT_GUILD|BCT_SAMEGUILD; + else if( strcmpi(split[6],"noone")==0 ) skill->db[idx].unit_target = BCT_NOONE; + else skill->db[idx].unit_target = strtol(split[6],NULL,16); + + skill->db[idx].unit_flag = strtol(split[7],NULL,16); + + if (skill->db[idx].unit_flag&UF_DEFNOTENEMY && battle_config.defnotenemy) + skill->db[idx].unit_target = BCT_NOENEMY; //By default, target just characters. - skill_db[idx].unit_target |= BL_CHAR; - if (skill_db[idx].unit_flag&UF_NOPC) - skill_db[idx].unit_target &= ~BL_PC; - if (skill_db[idx].unit_flag&UF_NOMOB) - skill_db[idx].unit_target &= ~BL_MOB; - if (skill_db[idx].unit_flag&UF_SKILL) - skill_db[idx].unit_target |= BL_SKILL; + skill->db[idx].unit_target |= BL_CHAR; + if (skill->db[idx].unit_flag&UF_NOPC) + skill->db[idx].unit_target &= ~BL_PC; + if (skill->db[idx].unit_flag&UF_NOMOB) + skill->db[idx].unit_target &= ~BL_MOB; + if (skill->db[idx].unit_flag&UF_SKILL) + skill->db[idx].unit_target |= BL_SKILL; return true; } @@ -17811,14 +17754,14 @@ bool skill_parse_row_producedb(char* split[], int columns, int current) { if( !i ) return false; - skill_produce_db[current].nameid = i; - skill_produce_db[current].itemlv = atoi(split[1]); - skill_produce_db[current].req_skill = atoi(split[2]); - skill_produce_db[current].req_skill_lv = atoi(split[3]); + skill->produce_db[current].nameid = i; + skill->produce_db[current].itemlv = atoi(split[1]); + skill->produce_db[current].req_skill = atoi(split[2]); + skill->produce_db[current].req_skill_lv = atoi(split[3]); for( x = 4, y = 0; x+1 < columns && split[x] && split[x+1] && y < MAX_PRODUCE_RESOURCE; x += 2, y++ ) { - skill_produce_db[current].mat_id[y] = atoi(split[x]); - skill_produce_db[current].mat_amount[y] = atoi(split[x+1]); + skill->produce_db[current].mat_id[y] = atoi(split[x]); + skill->produce_db[current].mat_amount[y] = atoi(split[x+1]); } return true; @@ -17832,11 +17775,11 @@ bool skill_parse_row_createarrowdb(char* split[], int columns, int current) { if( !i ) return false; - skill_arrow_db[current].nameid = i; + skill->arrow_db[current].nameid = i; for( x = 1, y = 0; x+1 < columns && split[x] && split[x+1] && y < MAX_ARROW_RESOURCE; x += 2, y++ ) { - skill_arrow_db[current].cre_id[y] = atoi(split[x]); - skill_arrow_db[current].cre_amount[y] = atoi(split[x+1]); + skill->arrow_db[current].cre_id[y] = atoi(split[x]); + skill->arrow_db[current].cre_amount[y] = atoi(split[x+1]); } return true; @@ -17855,9 +17798,9 @@ bool skill_parse_row_spellbookdb(char* split[], int columns, int current) { if( points < 1 ) ShowError("spellbook_db: PreservePoints have to be 1 or above! (%d/%s)\n", skill_id, skill->get_name(skill_id)); else { - skill_spellbook_db[current].skill_id = skill_id; - skill_spellbook_db[current].point = points; - skill_spellbook_db[current].nameid = nameid; + skill->spellbook_db[current].skill_id = skill_id; + skill->spellbook_db[current].point = points; + skill->spellbook_db[current].nameid = nameid; return true; } @@ -17884,8 +17827,8 @@ bool skill_parse_row_improvisedb(char* split[], int columns, int current) { if( current >= MAX_SKILL_IMPROVISE_DB ) { ShowError("skill_improvise_db: Maximum amount of entries reached (%d), increase MAX_SKILL_IMPROVISE_DB\n",MAX_SKILL_IMPROVISE_DB); } - skill_improvise_db[current].skill_id = skill_id; - skill_improvise_db[current].per = j; // Still need confirm it. + skill->improvise_db[current].skill_id = skill_id; + skill->improvise_db[current].per = j; // Still need confirm it. return true; } @@ -17902,7 +17845,7 @@ bool skill_parse_row_magicmushroomdb(char* split[], int column, int current) { return false; } - skill_magicmushroom_db[current].skill_id = skill_id; + skill->magicmushroom_db[current].skill_id = skill_id; return true; } @@ -17913,7 +17856,7 @@ bool skill_parse_row_reproducedb(char* split[], int column, int current) { if( !idx ) return false; - skill_reproduce_db[idx] = true; + skill->reproduce_db[idx] = true; return true; } @@ -17931,9 +17874,9 @@ bool skill_parse_row_abradb(char* split[], int columns, int current) { return false; } - skill_abra_db[current].skill_id = skill_id; - skill_abra_db[current].req_lv = atoi(split[2]); - skill_abra_db[current].per = atoi(split[3]); + skill->abra_db[current].skill_id = skill_id; + skill->abra_db[current].req_lv = atoi(split[2]); + skill->abra_db[current].per = atoi(split[3]); return true; } @@ -17945,8 +17888,8 @@ bool skill_parse_row_changematerialdb(char* split[], int columns, int current) { int x,y; for(x=0; x<MAX_SKILL_PRODUCE_DB; x++){ - if( skill_produce_db[x].nameid == skill_id ) - if( skill_produce_db[x].req_skill == GN_CHANGEMATERIAL ) + if( skill->produce_db[x].nameid == skill_id ) + if( skill->produce_db[x].req_skill == GN_CHANGEMATERIAL ) break; } @@ -17959,12 +17902,12 @@ bool skill_parse_row_changematerialdb(char* split[], int columns, int current) { ShowError("skill_changematerial_db: Maximum amount of entries reached (%d), increase MAX_SKILL_PRODUCE_DB\n",MAX_SKILL_PRODUCE_DB); } - skill_changematerial_db[current].itemid = skill_id; - skill_changematerial_db[current].rate = j; + skill->changematerial_db[current].itemid = skill_id; + skill->changematerial_db[current].rate = j; for( x = 2, y = 0; x+1 < columns && split[x] && split[x+1] && y < 5; x += 2, y++ ) { - skill_changematerial_db[current].qty[y] = atoi(split[x]); - skill_changematerial_db[current].qty_rate[y] = atoi(split[x+1]); + skill->changematerial_db[current].qty[y] = atoi(split[x]); + skill->changematerial_db[current].qty_rate[y] = atoi(split[x+1]); } return true; @@ -17984,41 +17927,47 @@ bool skill_parse_row_changematerialdb(char* split[], int columns, int current) { *------------------------------*/ void skill_readdb(void) { // init skill db structures - db_clear(skilldb_name2id); - memset(skill_db,0,sizeof(skill_db)); - memset(skill_produce_db,0,sizeof(skill_produce_db)); - memset(skill_arrow_db,0,sizeof(skill_arrow_db)); - memset(skill_abra_db,0,sizeof(skill_abra_db)); - memset(skill_spellbook_db,0,sizeof(skill_spellbook_db)); - memset(skill_magicmushroom_db,0,sizeof(skill_magicmushroom_db)); - memset(skill_reproduce_db,0,sizeof(skill_reproduce_db)); - memset(skill_changematerial_db,0,sizeof(skill_changematerial_db)); + db_clear(skill->name2id_db); + + /* when != it was called during init and this procedure was already performed by skill_defaults() */ + if( runflag == MAPSERVER_ST_RUNNING ) { + memset(skill->db,0,sizeof(skill->db) + + sizeof(skill->produce_db) + + sizeof(skill->arrow_db) + + sizeof(skill->abra_db) + + sizeof(skill->magicmushroom_db) + + sizeof(skill->improvise_db) + + sizeof(skill->changematerial_db) + + sizeof(skill->spellbook_db) + + sizeof(skill->reproduce_db) + ); + } // load skill databases - safestrncpy(skill_db[0].name, "UNKNOWN_SKILL", sizeof(skill_db[0].name)); - safestrncpy(skill_db[0].desc, "Unknown Skill", sizeof(skill_db[0].desc)); + safestrncpy(skill->db[0].name, "UNKNOWN_SKILL", sizeof(skill->db[0].name)); + safestrncpy(skill->db[0].desc, "Unknown Skill", sizeof(skill->db[0].desc)); - sv->readdb(iMap->db_path, DBPATH"skill_db.txt" , ',', 17, 17, MAX_SKILL_DB, skill->parse_row_skilldb); - sv->readdb(iMap->db_path, DBPATH"skill_require_db.txt" , ',', 32, 32, MAX_SKILL_DB, skill->parse_row_requiredb); + sv->readdb(map->db_path, DBPATH"skill_db.txt", ',', 17, 17, MAX_SKILL_DB, skill->parse_row_skilldb); + sv->readdb(map->db_path, DBPATH"skill_require_db.txt", ',', 32, 32, MAX_SKILL_DB, skill->parse_row_requiredb); #ifdef RENEWAL_CAST - sv->readdb(iMap->db_path, "re/skill_cast_db.txt" , ',', 8, 8, MAX_SKILL_DB, skill->parse_row_castdb); + sv->readdb(map->db_path, "re/skill_cast_db.txt", ',', 8, 8, MAX_SKILL_DB, skill->parse_row_castdb); #else - sv->readdb(iMap->db_path, "pre-re/skill_cast_db.txt" , ',', 7, 7, MAX_SKILL_DB, skill->parse_row_castdb); + sv->readdb(map->db_path, "pre-re/skill_cast_db.txt", ',', 7, 7, MAX_SKILL_DB, skill->parse_row_castdb); #endif - sv->readdb(iMap->db_path, DBPATH"skill_castnodex_db.txt", ',', 2, 3, MAX_SKILL_DB, skill->parse_row_castnodexdb); - sv->readdb(iMap->db_path, DBPATH"skill_unit_db.txt" , ',', 8, 8, MAX_SKILL_DB, skill->parse_row_unitdb); + sv->readdb(map->db_path, DBPATH"skill_castnodex_db.txt", ',', 2, 3, MAX_SKILL_DB, skill->parse_row_castnodexdb); + sv->readdb(map->db_path, DBPATH"skill_unit_db.txt", ',', 8, 8, MAX_SKILL_DB, skill->parse_row_unitdb); skill->init_unit_layout(); - sv->readdb(iMap->db_path, "produce_db.txt" , ',', 4, 4+2*MAX_PRODUCE_RESOURCE, MAX_SKILL_PRODUCE_DB, skill->parse_row_producedb); - sv->readdb(iMap->db_path, "create_arrow_db.txt" , ',', 1+2, 1+2*MAX_ARROW_RESOURCE, MAX_SKILL_ARROW_DB, skill->parse_row_createarrowdb); - sv->readdb(iMap->db_path, "abra_db.txt" , ',', 4, 4, MAX_SKILL_ABRA_DB, skill->parse_row_abradb); + sv->readdb(map->db_path, "produce_db.txt", ',', 4, 4+2*MAX_PRODUCE_RESOURCE, MAX_SKILL_PRODUCE_DB, skill->parse_row_producedb); + sv->readdb(map->db_path, "create_arrow_db.txt", ',', 1+2, 1+2*MAX_ARROW_RESOURCE, MAX_SKILL_ARROW_DB, skill->parse_row_createarrowdb); + sv->readdb(map->db_path, "abra_db.txt", ',', 4, 4, MAX_SKILL_ABRA_DB, skill->parse_row_abradb); //Warlock - sv->readdb(iMap->db_path, "spellbook_db.txt" , ',', 3, 3, MAX_SKILL_SPELLBOOK_DB, skill->parse_row_spellbookdb); + sv->readdb(map->db_path, "spellbook_db.txt", ',', 3, 3, MAX_SKILL_SPELLBOOK_DB, skill->parse_row_spellbookdb); //Guillotine Cross - sv->readdb(iMap->db_path, "magicmushroom_db.txt" , ',', 1, 1, MAX_SKILL_MAGICMUSHROOM_DB, skill->parse_row_magicmushroomdb); - sv->readdb(iMap->db_path, "skill_reproduce_db.txt", ',', 1, 1, MAX_SKILL_DB, skill->parse_row_reproducedb); - sv->readdb(iMap->db_path, "skill_improvise_db.txt" , ',', 2, 2, MAX_SKILL_IMPROVISE_DB, skill->parse_row_improvisedb); - sv->readdb(iMap->db_path, "skill_changematerial_db.txt" , ',', 4, 4+2*5, MAX_SKILL_PRODUCE_DB, skill->parse_row_changematerialdb); + sv->readdb(map->db_path, "magicmushroom_db.txt", ',', 1, 1, MAX_SKILL_MAGICMUSHROOM_DB, skill->parse_row_magicmushroomdb); + sv->readdb(map->db_path, "skill_reproduce_db.txt", ',', 1, 1, MAX_SKILL_DB, skill->parse_row_reproducedb); + sv->readdb(map->db_path, "skill_improvise_db.txt", ',', 2, 2, MAX_SKILL_IMPROVISE_DB, skill->parse_row_improvisedb); + sv->readdb(map->db_path, "skill_changematerial_db.txt", ',', 4, 4+2*5, MAX_SKILL_PRODUCE_DB, skill->parse_row_changematerialdb); } void skill_reload (void) { @@ -18053,13 +18002,13 @@ void skill_reload (void) { * *------------------------------------------*/ int do_init_skill (void) { - skilldb_name2id = strdb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, MAX_SKILL_NAME_LENGTH); + skill->name2id_db = strdb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, MAX_SKILL_NAME_LENGTH); skill->read_db(); - group_db = idb_alloc(DB_OPT_BASE); - skillunit_db = idb_alloc(DB_OPT_BASE); + skill->group_db = idb_alloc(DB_OPT_BASE); + skill->unit_db = idb_alloc(DB_OPT_BASE); skill->cd_db = idb_alloc(DB_OPT_BASE); - skillusave_db = idb_alloc(DB_OPT_RELEASE_DATA); + skill->usave_db = idb_alloc(DB_OPT_RELEASE_DATA); skill->unit_ers = ers_new(sizeof(struct skill_unit_group),"skill.c::skill_unit_ers",ERS_OPT_NONE); skill->timer_ers = ers_new(sizeof(struct skill_timerskill),"skill.c::skill_timer_ers",ERS_OPT_NONE); @@ -18082,11 +18031,11 @@ int do_init_skill (void) { int do_final_skill(void) { - db_destroy(skilldb_name2id); - db_destroy(group_db); - db_destroy(skillunit_db); + db_destroy(skill->name2id_db); + db_destroy(skill->group_db); + db_destroy(skill->unit_db); db_destroy(skill->cd_db); - db_destroy(skillusave_db); + db_destroy(skill->usave_db); ers_destroy(skill->unit_ers); ers_destroy(skill->timer_ers); @@ -18096,6 +18045,9 @@ int do_final_skill(void) { } /* initialize the interface */ void skill_defaults(void) { + const int skill_enchant_eff[5] = { 10, 14, 17, 19, 20 }; + const int skill_deluge_eff[5] = { 5, 9, 12, 14, 15 }; + skill = &skill_s; skill->init = do_init_skill; skill->final = do_final_skill; @@ -18103,11 +18055,36 @@ void skill_defaults(void) { skill->read_db = skill_readdb; /* */ skill->cd_db = NULL; + skill->name2id_db = NULL; + skill->unit_db = NULL; + skill->usave_db = NULL; + skill->group_db = NULL; /* */ skill->unit_ers = NULL; skill->timer_ers = NULL; skill->cd_ers = NULL; skill->cd_entry_ers = NULL; + /* one huge 0, follows skill.h order */ + memset(skill->db,0,sizeof(skill->db) + + sizeof(skill->produce_db) + + sizeof(skill->arrow_db) + + sizeof(skill->abra_db) + + sizeof(skill->magicmushroom_db) + + sizeof(skill->improvise_db) + + sizeof(skill->changematerial_db) + + sizeof(skill->spellbook_db) + + sizeof(skill->reproduce_db) + + sizeof(skill->unit_layout) + ); + /* */ + memcpy(skill->enchant_eff, skill_enchant_eff, sizeof(skill->enchant_eff)); + memcpy(skill->deluge_eff, skill_deluge_eff, sizeof(skill->deluge_eff)); + skill->firewall_unit_pos = 0; + skill->icewall_unit_pos = 0; + skill->earthstrain_unit_pos = 0; + memset(&skill->area_temp,0,sizeof(skill->area_temp)); + memset(&skill->unit_temp,0,sizeof(skill->unit_temp)); + skill->unit_group_newid = 0; /* accesssors */ skill->get_index = skill_get_index; skill->get_type = skill_get_type; @@ -18291,4 +18268,5 @@ void skill_defaults(void) { skill->get_elemental_type = skill_get_elemental_type; skill->cooldown_save = skill_cooldown_save; skill->maelstrom_suction = skill_maelstrom_suction; + skill->get_new_group_id = skill_get_new_group_id; } diff --git a/src/map/skill.h b/src/map/skill.h index 00242887f..d2546c706 100644 --- a/src/map/skill.h +++ b/src/map/skill.h @@ -1649,7 +1649,6 @@ struct s_skill_db { int unit_target; int unit_flag; }; -extern struct s_skill_db skill_db[MAX_SKILL_DB]; struct s_skill_unit_layout { int count; @@ -1715,14 +1714,12 @@ struct s_skill_produce_db { int req_skill,req_skill_lv,itemlv; int mat_id[MAX_PRODUCE_RESOURCE],mat_amount[MAX_PRODUCE_RESOURCE]; }; -extern struct s_skill_produce_db skill_produce_db[MAX_SKILL_PRODUCE_DB]; // Creating database arrow struct s_skill_arrow_db { int nameid, trigger; int cre_id[MAX_ARROW_RESOURCE],cre_amount[MAX_ARROW_RESOURCE]; }; -extern struct s_skill_arrow_db skill_arrow_db[MAX_SKILL_ARROW_DB]; // Abracadabra database struct s_skill_abra_db { @@ -1730,13 +1727,11 @@ struct s_skill_abra_db { int req_lv; int per; }; -extern struct s_skill_abra_db skill_abra_db[MAX_SKILL_ABRA_DB]; //GCross magic mushroom database struct s_skill_magicmushroom_db { uint16 skill_id; }; -extern struct s_skill_magicmushroom_db skill_magicmushroom_db[MAX_SKILL_MAGICMUSHROOM_DB]; struct skill_cd_entry { int duration;//milliseconds @@ -1760,11 +1755,31 @@ struct skill_cd { }; /** - * Vars + * Skill Unit Persistency during endack routes (mostly for songs see bugreport:4574) **/ -extern int enchant_eff[5]; -extern int deluge_eff[5]; -DBMap* skilldb_name2id; +struct skill_unit_save { + uint16 skill_id, skill_lv; +}; + +struct s_skill_improvise_db { + uint16 skill_id; + short per;//1-10000 +}; + +struct s_skill_changematerial_db { + int itemid; + short rate; + int qty[5]; + short qty_rate[5]; +}; + +struct s_skill_spellbook_db { + int nameid; + uint16 skill_id; + int point; +}; + +typedef int (*SkillFunc)(struct block_list *src, struct block_list *target, uint16 skill_id, uint16 skill_lv, unsigned int tick, int flag); /** * Skill.c Interface @@ -1776,11 +1791,35 @@ struct skill_interface { void (*read_db) (void); /* */ DBMap* cd_db; // char_id -> struct skill_cd + DBMap* name2id_db; + DBMap* unit_db; // int id -> struct skill_unit* + DBMap* usave_db; // char_id -> struct skill_unit_save + DBMap* group_db;// int group_id -> struct skill_unit_group* /* */ struct eri *unit_ers; //For handling skill_unit's [Skotlex] struct eri *timer_ers; //For handling skill_timerskills [Skotlex] struct eri *cd_ers; // ERS Storage for skill cool down managers [Ind/Hercules] struct eri *cd_entry_ers; // ERS Storage for skill cool down entries [Ind/Hercules] + /* */ + struct s_skill_db db[MAX_SKILL_DB]; + struct s_skill_produce_db produce_db[MAX_SKILL_PRODUCE_DB]; + struct s_skill_arrow_db arrow_db[MAX_SKILL_ARROW_DB]; + struct s_skill_abra_db abra_db[MAX_SKILL_ABRA_DB]; + struct s_skill_magicmushroom_db magicmushroom_db[MAX_SKILL_MAGICMUSHROOM_DB]; + struct s_skill_improvise_db improvise_db[MAX_SKILL_IMPROVISE_DB]; + struct s_skill_changematerial_db changematerial_db[MAX_SKILL_PRODUCE_DB]; + struct s_skill_spellbook_db spellbook_db[MAX_SKILL_SPELLBOOK_DB]; + bool reproduce_db[MAX_SKILL_DB]; + struct s_skill_unit_layout unit_layout[MAX_SKILL_UNIT_LAYOUT]; + /* */ + int enchant_eff[5]; + int deluge_eff[5]; + int firewall_unit_pos; + int icewall_unit_pos; + int earthstrain_unit_pos; + int area_temp[8]; + int unit_temp[20]; // temporary storage for tracking skill unit skill ids as players move in/out of them + int unit_group_newid; /* accesssors */ int (*get_index) ( uint16 skill_id ); int (*get_type) ( uint16 skill_id ); @@ -1886,9 +1925,9 @@ struct skill_interface { int (*castend_nodamage_id) ( struct block_list *src, struct block_list *bl,uint16 skill_id,uint16 skill_lv,unsigned int tick,int flag ); int (*castend_damage_id) ( struct block_list* src, struct block_list *bl,uint16 skill_id,uint16 skill_lv,unsigned int tick,int flag ); int (*castend_pos2) ( struct block_list *src, int x,int y,uint16 skill_id,uint16 skill_lv,unsigned int tick,int flag); - int (*blockpc_start) (struct map_session_data*, uint16 skill_id, int, bool); - int (*blockhomun_start) (struct homun_data*,uint16 skill_id,int); - int (*blockmerc_start) (struct mercenary_data*,uint16 skill_id,int); + int (*blockpc_start) (struct map_session_data *sd, uint16 skill_id, int tick, bool load); + int (*blockhomun_start) (struct homun_data *hd, uint16 skill_id, int tick); + int (*blockmerc_start) (struct mercenary_data *md, uint16 skill_id, int tick); int (*attack) ( int attack_type, struct block_list* src, struct block_list *dsrc,struct block_list *bl,uint16 skill_id,uint16 skill_lv,unsigned int tick,int flag ); int (*attack_area) (struct block_list *bl,va_list ap); int (*area_sub) (struct block_list *bl, va_list ap); @@ -1971,6 +2010,7 @@ struct skill_interface { int (*get_elemental_type) (uint16 skill_id, uint16 skill_lv); void (*cooldown_save) (struct map_session_data * sd); int (*maelstrom_suction) (struct block_list *bl, va_list ap); + int (*get_new_group_id) (void); }; struct skill_interface *skill; diff --git a/src/map/status.c b/src/map/status.c index bac302dec..0b69ae2ef 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -1086,45 +1086,44 @@ static inline void status_cpy(struct status_data* a, const struct status_data* b memcpy((void*)&a->max_hp, (const void*)&b->max_hp, sizeof(struct status_data)-(sizeof(a->hp)+sizeof(a->sp))); } -//Sets HP to given value. Flag is the flag passed to iStatus->heal in case +//Sets HP to given value. Flag is the flag passed to status->heal in case //final value is higher than current (use 2 to make a healing effect display //on players) It will always succeed (overrides Berserk block), but it can't kill. int status_set_hp(struct block_list *bl, unsigned int hp, int flag) { struct status_data *st; if (hp < 1) return 0; - st = iStatus->get_status_data(bl); + st = status->get_status_data(bl); if (st == &dummy_status) return 0; if (hp > st->max_hp) hp = st->max_hp; if (hp == st->hp) return 0; if (hp > st->hp) - return iStatus->heal(bl, hp - st->hp, 0, 1|flag); + return status->heal(bl, hp - st->hp, 0, 1|flag); return status_zap(bl, st->hp - hp, 0); } -//Sets SP to given value. Flag is the flag passed to iStatus->heal in case +//Sets SP to given value. Flag is the flag passed to status->heal in case //final value is higher than current (use 2 to make a healing effect display //on players) int status_set_sp(struct block_list *bl, unsigned int sp, int flag) { struct status_data *st; - st = iStatus->get_status_data(bl); + st = status->get_status_data(bl); if (st == &dummy_status) return 0; if (sp > st->max_sp) sp = st->max_sp; if (sp == st->sp) return 0; if (sp > st->sp) - return iStatus->heal(bl, 0, sp - st->sp, 1|flag); + return status->heal(bl, 0, sp - st->sp, 1|flag); return status_zap(bl, 0, st->sp - sp); } -int status_charge(struct block_list* bl, int64 hp, int64 sp) -{ +int status_charge(struct block_list* bl, int64 hp, int64 sp) { if(!(bl->type&BL_CONSUME)) return (int)(hp+sp); //Assume all was charged so there are no 'not enough' fails. - return iStatus->damage(NULL, bl, hp, sp, 0, 3); + return status->damage(NULL, bl, hp, sp, 0, 3); } //Inflicts damage on the target with the according walkdelay. @@ -1145,19 +1144,19 @@ int status_damage(struct block_list *src,struct block_list *target,int64 in_hp, sp = 0; //Not a valid SP target. if (hp < 0) { //Assume absorbed damage. - iStatus->heal(target, -hp, 0, 1); + status->heal(target, -hp, 0, 1); hp = 0; } if (sp < 0) { - iStatus->heal(target, 0, -sp, 1); + status->heal(target, 0, -sp, 1); sp = 0; } if (target->type == BL_SKILL) return skill->unit_ondamaged((struct skill_unit *)target, src, hp, timer->gettick()); - st = iStatus->get_status_data(target); + st = status->get_status_data(target); if( st == &dummy_status ) return 0; @@ -1182,7 +1181,7 @@ int status_damage(struct block_list *src,struct block_list *target,int64 in_hp, // if (!target->prev && !(flag&2)) // return 0; //Cannot damage a bl not on a map, except when "charging" hp/sp - sc = iStatus->get_sc(target); + sc = status->get_sc(target); if( hp && battle_config.invincible_nodamage && src && sc && sc->data[SC_INVINCIBLE] && !sc->data[SC_INVINCIBLEOFF] ) hp = 1; @@ -1287,9 +1286,9 @@ int status_damage(struct block_list *src,struct block_list *target,int64 in_hp, battle_config.clear_unit_ondeath&target->type) skill->clear_unitgroup(target); - if(target->type&BL_REGEN) - { //Reset regen ticks. - struct regen_data *regen = iStatus->get_regen_data(target); + if(target->type&BL_REGEN) { + //Reset regen ticks. + struct regen_data *regen = status->get_regen_data(target); if (regen) { memset(®en->tick, 0, sizeof(regen->tick)); if (regen->sregen) @@ -1299,42 +1298,43 @@ int status_damage(struct block_list *src,struct block_list *target,int64 in_hp, } } - if( sc && sc->data[SC_KAIZEL] && !map_flag_gvg2(target->m) ) - { //flag&8 = disable Kaizel + if( sc && sc->data[SC_KAIZEL] && !map_flag_gvg2(target->m) ) { + //flag&8 = disable Kaizel int time = skill->get_time2(SL_KAIZEL,sc->data[SC_KAIZEL]->val1); //Look for Osiris Card's bonus effect on the character and revive 100% or revive normally if ( target->type == BL_PC && BL_CAST(BL_PC,target)->special_state.restart_full_recover ) - iStatus->revive(target, 100, 100); + status->revive(target, 100, 100); else - iStatus->revive(target, sc->data[SC_KAIZEL]->val2, 0); - iStatus->change_clear(target,0); + status->revive(target, sc->data[SC_KAIZEL]->val2, 0); + status->change_clear(target,0); clif->skill_nodamage(target,target,ALL_RESURRECTION,1,1); - sc_start(target,iStatus->skill2sc(PR_KYRIE),100,10,time); + sc_start(target,status->skill2sc(PR_KYRIE),100,10,time); if( target->type == BL_MOB ) ((TBL_MOB*)target)->state.rebirth = 1; return (int)(hp+sp); } - if(target->type == BL_PC){ + if(target->type == BL_PC) { TBL_PC *sd = BL_CAST(BL_PC,target); TBL_HOM *hd = sd->hd; if(hd && hd->sc.data[SC_LIGHT_OF_REGENE]){ clif->skillcasting(&hd->bl, hd->bl.id, target->id, 0,0, MH_LIGHT_OF_REGENE, skill->get_ele(MH_LIGHT_OF_REGENE, 1), 10); //just to display usage - clif->skill_nodamage(&sd->bl, target, ALL_RESURRECTION, 1, iStatus->revive(&sd->bl,10*hd->sc.data[SC_LIGHT_OF_REGENE]->val1,0)); + clif->skill_nodamage(&sd->bl, target, ALL_RESURRECTION, 1, status->revive(&sd->bl,10*hd->sc.data[SC_LIGHT_OF_REGENE]->val1,0)); status_change_end(&sd->hd->bl,SC_LIGHT_OF_REGENE,INVALID_TIMER); return (int)(hp + sp); } } - if (target->type == BL_MOB && sc && sc->data[SC_REBIRTH] && !((TBL_MOB*) target)->state.rebirth) {// Ensure the monster has not already rebirthed before doing so. - iStatus->revive(target, sc->data[SC_REBIRTH]->val2, 0); - iStatus->change_clear(target,0); + if (target->type == BL_MOB && sc && sc->data[SC_REBIRTH] && !((TBL_MOB*) target)->state.rebirth) { + // Ensure the monster has not already rebirthed before doing so. + status->revive(target, sc->data[SC_REBIRTH]->val2, 0); + status->change_clear(target,0); ((TBL_MOB*)target)->state.rebirth = 1; return (int)(hp+sp); } - iStatus->change_clear(target,0); + status->change_clear(target,0); if(flag&4) //Delete from memory. (also invokes map removal code) unit->free(target,CLR_DEAD); @@ -1359,7 +1359,7 @@ int status_heal(struct block_list *bl,int64 in_hp,int64 in_sp, int flag) { struct status_change *sc; int hp,sp; - st = iStatus->get_status_data(bl); + st = status->get_status_data(bl); if (st == &dummy_status || !st->hp) return 0; @@ -1368,13 +1368,13 @@ int status_heal(struct block_list *bl,int64 in_hp,int64 in_sp, int flag) { hp = (int)cap_value(in_hp,INT_MIN,INT_MAX); sp = (int)cap_value(in_sp,INT_MIN,INT_MAX); - sc = iStatus->get_sc(bl); + sc = status->get_sc(bl); if (sc && !sc->count) sc = NULL; if (hp < 0) { if (hp == INT_MIN) hp++; //-INT_MIN == INT_MIN in some architectures! - iStatus->damage(NULL, bl, -hp, 0, 0, 1); + status->damage(NULL, bl, -hp, 0, 0, 1); hp = 0; } @@ -1392,7 +1392,7 @@ int status_heal(struct block_list *bl,int64 in_hp,int64 in_sp, int flag) { if(sp < 0) { if (sp==INT_MIN) sp++; - iStatus->damage(NULL, bl, 0, -sp, 0, 1); + status->damage(NULL, bl, 0, -sp, 0, 1); sp = 0; } @@ -1436,7 +1436,7 @@ int status_percent_change(struct block_list *src,struct block_list *target,signe struct status_data *st; unsigned int hp = 0, sp = 0; - st = iStatus->get_status_data(target); + st = status->get_status_data(target); //It's safe now [MarkZD] @@ -1470,32 +1470,32 @@ int status_percent_change(struct block_list *src,struct block_list *target,signe sp = 1; //Ugly check in case damage dealt is too much for the received args of - //iStatus->heal / iStatus->damage. [Skotlex] + //status->heal / status->damage. [Skotlex] if (hp > INT_MAX) { hp -= INT_MAX; if (flag) - iStatus->damage(src, target, INT_MAX, 0, 0, (!src||src==target?5:1)); + status->damage(src, target, INT_MAX, 0, 0, (!src||src==target?5:1)); else - iStatus->heal(target, INT_MAX, 0, 0); + status->heal(target, INT_MAX, 0, 0); } if (sp > INT_MAX) { sp -= INT_MAX; if (flag) - iStatus->damage(src, target, 0, INT_MAX, 0, (!src||src==target?5:1)); + status->damage(src, target, 0, INT_MAX, 0, (!src||src==target?5:1)); else - iStatus->heal(target, 0, INT_MAX, 0); + status->heal(target, 0, INT_MAX, 0); } if (flag) - return iStatus->damage(src, target, hp, sp, 0, (!src||src==target?5:1)); - return iStatus->heal(target, hp, sp, 0); + return status->damage(src, target, hp, sp, 0, (!src||src==target?5:1)); + return status->heal(target, hp, sp, 0); } int status_revive(struct block_list *bl, unsigned char per_hp, unsigned char per_sp) { struct status_data *st; unsigned int hp, sp; - if (!iStatus->isdead(bl)) return 0; + if (!status->isdead(bl)) return 0; - st = iStatus->get_status_data(bl); + st = status->get_status_data(bl); if (st == &dummy_status) return 0; //Invalid target. @@ -1543,9 +1543,9 @@ int status_check_skilluse(struct block_list *src, struct block_list *target, uin struct status_change *sc=NULL, *tsc; int hide_flag; - st = src ? iStatus->get_status_data(src) : &dummy_status; + st = src ? status->get_status_data(src) : &dummy_status; - if (src && src->type != BL_PC && iStatus->isdead(src)) + if (src && src->type != BL_PC && status->isdead(src)) return 0; if (!skill_id) { //Normal attack checks. @@ -1553,9 +1553,9 @@ int status_check_skilluse(struct block_list *src, struct block_list *target, uin return 0; //This mode is only needed for melee attacking. //Dead state is not checked for skills as some skills can be used //on dead characters, said checks are left to skill.c [Skotlex] - if (target && iStatus->isdead(target)) + if (target && status->isdead(target)) return 0; - if( src && (sc = iStatus->get_sc(src)) && sc->data[SC_COLD] && src->type != BL_MOB) + if( src && (sc = status->get_sc(src)) && sc->data[SC_COLD] && src->type != BL_MOB) return 0; } @@ -1581,18 +1581,18 @@ int status_check_skilluse(struct block_list *src, struct block_list *target, uin case PA_PRESSURE: if( flag && target ) { //Gloria Avoids pretty much everything.... - tsc = iStatus->get_sc(target); + tsc = status->get_sc(target); if(tsc && tsc->option&OPTION_HIDE) return 0; } break; case GN_WALLOFTHORN: - if( target && iStatus->isdead(target) ) + if( target && status->isdead(target) ) return 0; break; case AL_TELEPORT: //Should fail when used on top of Land Protector [Skotlex] - if (src && iMap->getcell(src->m, src->x, src->y, CELL_CHKLANDPROTECTOR) + if (src && map->getcell(src->m, src->x, src->y, CELL_CHKLANDPROTECTOR) && !(st->mode&MD_BOSS) && (src->type != BL_PC || ((TBL_PC*)src)->skillitem != skill_id)) return 0; @@ -1602,7 +1602,7 @@ int status_check_skilluse(struct block_list *src, struct block_list *target, uin } } - if ( src ) sc = iStatus->get_sc(src); + if ( src ) sc = status->get_sc(src); if( sc && sc->count ) { @@ -1623,7 +1623,7 @@ int status_check_skilluse(struct block_list *src, struct block_list *target, uin if (sc->data[SC_DC_WINKCHARM] && target && !flag) { //Prevents skill usage if( unit->bl2ud(src) && (unit->bl2ud(src))->walktimer == INVALID_TIMER ) - unit->walktobl(src, iMap->id2bl(sc->data[SC_DC_WINKCHARM]->val2), 3, 1); + unit->walktobl(src, map->id2bl(sc->data[SC_DC_WINKCHARM]->val2), 3, 1); clif->emotion(src, E_LV); return 0; } @@ -1695,7 +1695,7 @@ int status_check_skilluse(struct block_list *src, struct block_list *target, uin ) return 0; - if( sc->data[SC__MANHOLE] || ((tsc = iStatus->get_sc(target)) && tsc->data[SC__MANHOLE]) ) { + if( sc->data[SC__MANHOLE] || ((tsc = status->get_sc(target)) && tsc->data[SC__MANHOLE]) ) { switch(skill_id) {//##TODO## make this a flag in skill_db? // Skills that can be used even under Man Hole effects. case SC_SHADOWFORM: @@ -1735,7 +1735,7 @@ int status_check_skilluse(struct block_list *src, struct block_list *target, uin if (target == NULL || target == src) //No further checking needed. return 1; - tsc = iStatus->get_sc(target); + tsc = status->get_sc(target); if(tsc && tsc->count) { /* attacks in invincible are capped to 1 damage and handled in batte.c; allow spell break and eske for sealed shrine GDB when in INVINCIBLE state. */ @@ -1812,8 +1812,8 @@ int status_check_skilluse(struct block_list *src, struct block_list *target, uin //Checks whether the source can see and chase target. int status_check_visibility(struct block_list *src, struct block_list *target) { int view_range; - struct status_data *st = iStatus->get_status_data(src); - struct status_change *tsc = iStatus->get_sc(target); + struct status_data *st = status->get_status_data(src); + struct status_change *tsc = status->get_sc(target); switch (src->type) { case BL_MOB: view_range = ((TBL_MOB*)src)->min_chase; @@ -1957,19 +1957,19 @@ void status_calc_misc(struct block_list *bl, struct status_data *st, int level) st->cri = st->flee2 = 0; #ifdef RENEWAL // renewal formulas - st->matk_min = st->matk_max = bl->type == BL_PC ? iStatus->base_matk(st, level) : level + st->int_; + st->matk_min = st->matk_max = bl->type == BL_PC ? status->base_matk(st, level) : level + st->int_; st->hit += level + st->dex + (bl->type == BL_PC ? st->luk/3 + 175 : 150); //base level + ( every 1 dex = +1 hit ) + (every 3 luk = +1 hit) + 175 st->flee += level + st->agi + (bl->type == BL_PC ? st->luk/5 : 0) + 100; //base level + ( every 1 agi = +1 flee ) + (every 5 luk = +1 flee) + 100 st->def2 += (int)(((float)level + st->vit)/2 + ( bl->type == BL_PC ? ((float)st->agi/5) : 0 )); //base level + (every 2 vit = +1 def) + (every 5 agi = +1 def) st->mdef2 += (int)( bl->type == BL_PC ?(st->int_ + ((float)level/4) + ((float)(st->dex+st->vit)/5)):((float)(st->int_ + level)/4)); //(every 4 base level = +1 mdef) + (every 1 int = +1 mdef) + (every 5 dex = +1 mdef) + (every 5 vit = +1 mdef) -#else +#else // not RENEWAL st->matk_min = status_base_matk_min(st); st->matk_max = status_base_matk_max(st); st->hit += level + st->dex; st->flee += level + st->agi; st->def2 += st->vit; st->mdef2 += st->int_ + (st->vit>>1); -#endif +#endif // RENEWAL if( bl->type&battle_config.enable_critical ) st->cri += 10 + (st->luk*10/3); //(every 1 luk = +0.3 critical) @@ -2011,7 +2011,7 @@ void status_calc_misc(struct block_list *bl, struct status_data *st, int level) st->cri = 10; } if(bl->type&BL_REGEN) - iStatus->calc_regen(bl, st, iStatus->get_regen_data(bl)); + status->calc_regen(bl, st, status->get_regen_data(bl)); } //Skotlex: Calculates the initial status for the given mob @@ -2064,10 +2064,10 @@ int status_calc_mob_(struct mob_data* md, bool first) { memcpy(mstatus, &md->db->status, sizeof(struct status_data)); if (flag&(8|16)) - mbl = iMap->id2bl(md->master_id); + mbl = map->id2bl(md->master_id); if (flag&8 && mbl) { - struct status_data *mstatus = iStatus->get_base_status(mbl); + struct status_data *mstatus = status->get_base_status(mbl); if (mstatus && battle_config.slaves_inherit_speed&(mstatus->mode&MD_CANMOVE?1:2)) mstatus->speed = mstatus->speed; @@ -2088,7 +2088,7 @@ int status_calc_mob_(struct mob_data* md, bool first) { } else if(ud->skill_id == KO_ZANZOU) { mstatus->max_hp = 3000 + 3000 * ud->skill_lv + status_get_max_sp(battle->get_master(mbl)); } else { //AM_CANNIBALIZE - mstatus->max_hp = 1500 + 200*ud->skill_lv + 10*iStatus->get_lv(mbl); + mstatus->max_hp = 1500 + 200*ud->skill_lv + 10*status->get_lv(mbl); mstatus->mode|= MD_CANATTACK|MD_AGGRESSIVE; } mstatus->hp = mstatus->max_hp; @@ -2147,7 +2147,7 @@ int status_calc_mob_(struct mob_data* md, bool first) { } } - iStatus->calc_misc(&md->bl, mstatus, md->level); + status->calc_misc(&md->bl, mstatus, md->level); if(flag&4) { // Strengthen Guardians - custom value +10% / lv @@ -2229,13 +2229,13 @@ int status_calc_pet_(struct pet_data *pd, bool first) pstatus->dex = cap_value(pstatus->dex,1,battle_config.pet_max_stats); pstatus->luk = cap_value(pstatus->luk,1,battle_config.pet_max_stats); - iStatus->calc_misc(&pd->bl, &pd->status, lv); + status->calc_misc(&pd->bl, &pd->status, lv); if (!first) //Not done the first time because the pet is not visible yet clif->send_petstatus(sd); } } else if (first) { - iStatus->calc_misc(&pd->bl, &pd->status, pd->db->lv); + status->calc_misc(&pd->bl, &pd->status, pd->db->lv); if (!battle_config.pet_lv_rate && pd->pet.level != pd->db->lv) pd->pet.level = pd->db->lv; } @@ -2466,7 +2466,7 @@ int status_calc_pc_(struct map_session_data* sd, bool first) { // Parse equipment. for(i=0;i<EQI_MAX-1;i++) { - iStatus->current_equip_item_index = index = sd->equip_index[i]; //We pass INDEX to iStatus->current_equip_item_index - for EQUIP_SCRIPT (new cards solution) [Lupus] + status->current_equip_item_index = index = sd->equip_index[i]; //We pass INDEX to status->current_equip_item_index - for EQUIP_SCRIPT (new cards solution) [Lupus] if(index < 0) continue; if(i == EQI_HAND_R && sd->equip_index[EQI_HAND_L] == index) @@ -2601,7 +2601,7 @@ int status_calc_pc_(struct map_session_data* sd, bool first) { //Parse Cards for(i=0;i<EQI_MAX-1;i++) { - iStatus->current_equip_item_index = index = sd->equip_index[i]; //We pass INDEX to iStatus->current_equip_item_index - for EQUIP_SCRIPT (new cards solution) [Lupus] + status->current_equip_item_index = index = sd->equip_index[i]; //We pass INDEX to status->current_equip_item_index - for EQUIP_SCRIPT (new cards solution) [Lupus] if(index < 0) continue; if(i == EQI_HAND_R && sd->equip_index[EQI_HAND_L] == index) @@ -2618,8 +2618,9 @@ int status_calc_pc_(struct map_session_data* sd, bool first) { //Card script execution. if(itemdb_isspecial(sd->status.inventory[index].card[0])) continue; - for(j=0;j<MAX_SLOTS;j++){ // Uses MAX_SLOTS to support Soul Bound system [Inkfish] - iStatus->current_equip_card_id= c= sd->status.inventory[index].card[j]; + for(j=0;j<MAX_SLOTS;j++) { + // Uses MAX_SLOTS to support Soul Bound system [Inkfish] + status->current_equip_card_id= c= sd->status.inventory[index].card[j]; if(!c) continue; data = itemdb->exists(c); @@ -2749,7 +2750,7 @@ int status_calc_pc_(struct map_session_data* sd, bool first) { // ------ BASE ATTACK CALCULATION ------ - // Base batk value is set on iStatus->calc_misc + // Base batk value is set on status->calc_misc // weapon-type bonus (FIXME: Why is the weapon_atk bonus applied to base attack?) if (sd->status.weapon < MAX_WEAPON_TYPE && sd->weapon_atk[sd->status.weapon]) bstatus->batk += sd->weapon_atk[sd->status.weapon]; @@ -2842,7 +2843,7 @@ int status_calc_pc_(struct map_session_data* sd, bool first) { } // ----- MISC CALCULATION ----- - iStatus->calc_misc(&sd->bl, bstatus, sd->status.base_level); + status->calc_misc(&sd->bl, bstatus, sd->status.base_level); //Equipment modifiers for misc settings if(sd->matk_rate < 0) @@ -3156,7 +3157,7 @@ int status_calc_mercenary_(struct mercenary_data *md, bool first) { md->battle_status.sp = merc->sp; } - iStatus->calc_misc(&md->bl, mstatus, md->db->lv); + status->calc_misc(&md->bl, mstatus, md->db->lv); status_cpy(&md->battle_status, mstatus); return 0; @@ -3185,7 +3186,7 @@ int status_calc_homunculus_(struct homun_data *hd, bool first) { hstatus->mode = MD_CANMOVE|MD_CANATTACK; hstatus->speed = DEFAULT_WALK_SPEED; if (battle_config.hom_setting&0x8 && hd->master) - hstatus->speed = iStatus->get_speed(&hd->master->bl); + hstatus->speed = status->get_speed(&hd->master->bl); hstatus->hp = 1; hstatus->sp = 1; @@ -3229,7 +3230,7 @@ int status_calc_homunculus_(struct homun_data *hd, bool first) { hstatus->amotion = cap_value(amotion,battle_config.max_aspd,2000); hstatus->adelay = hstatus->amotion; //It seems adelay = amotion for Homunculus. - iStatus->calc_misc(&hd->bl, hstatus, hom->level); + status->calc_misc(&hd->bl, hstatus, hom->level); #ifdef RENEWAL hstatus->matk_max = hstatus->matk_min; @@ -3254,7 +3255,7 @@ int status_calc_elemental_(struct elemental_data *ed, bool first) { else estatus->mode = ele->mode; - iStatus->calc_misc(&ed->bl, estatus, 0); + status->calc_misc(&ed->bl, estatus, 0); estatus->max_hp = ele->max_hp; estatus->max_sp = ele->max_sp; @@ -3271,7 +3272,7 @@ int status_calc_elemental_(struct elemental_data *ed, bool first) { memcpy(&ed->battle_status,estatus,sizeof(struct status_data)); } else { - iStatus->calc_misc(&ed->bl, estatus, 0); + status->calc_misc(&ed->bl, estatus, 0); status_cpy(&ed->battle_status, estatus); } @@ -3306,7 +3307,7 @@ int status_calc_npc_(struct npc_data *nd, bool first) { nstatus->dex = nd->stat_point; nstatus->luk = nd->stat_point; - iStatus->calc_misc(&nd->bl, nstatus, nd->level); + status->calc_misc(&nd->bl, nstatus, nd->level); status_cpy(&nd->status, nstatus); return 0; @@ -3527,9 +3528,9 @@ void status_calc_regen_rate(struct block_list *bl, struct regen_data *regen, str /// Recalculates parts of an object's battle status according to the specified flags. /// @param flag bitfield of values from enum scb_flag void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag) { - const struct status_data *bst = iStatus->get_base_status(bl); - struct status_data *st = iStatus->get_status_data(bl); - struct status_change *sc = iStatus->get_sc(bl); + const struct status_data *bst = status->get_base_status(bl); + struct status_data *st = status->get_status_data(bl); + struct status_change *sc = status->get_sc(bl); TBL_PC *sd = BL_CAST(BL_PC,bl); int temp; @@ -3606,7 +3607,7 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag) { temp += st->batk; st->batk = cap_value(temp, 0, USHRT_MAX); } - st->batk = iStatus->calc_batk(bl, sc, st->batk, true); + st->batk = status->calc_batk(bl, sc, st->batk, true); } if(flag&SCB_WATK) { @@ -3664,7 +3665,7 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag) { } if(flag&SCB_DEF) { - st->def = iStatus->calc_def(bl, sc, bst->def, true); + st->def = status->calc_def(bl, sc, bst->def, true); if( bl->type&BL_HOM ) st->def += (st->vit/5 - bst->vit/5); @@ -3676,9 +3677,9 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag) { && st->agi == bst->agi #endif ) - st->def2 = iStatus->calc_def2(bl, sc, bst->def2, true); + st->def2 = status->calc_def2(bl, sc, bst->def2, true); else - st->def2 = iStatus->calc_def2(bl, sc, bst->def2 + st->def2 = status->calc_def2(bl, sc, bst->def2 #ifdef RENEWAL + (int)( ((float)st->vit/2 - (float)bst->vit/2) + ((float)st->agi/5 - (float)bst->agi/5) ) #else @@ -3688,7 +3689,7 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag) { } if(flag&SCB_MDEF) { - st->mdef = iStatus->calc_mdef(bl, sc, bst->mdef, true); + st->mdef = status->calc_mdef(bl, sc, bst->mdef, true); if( bl->type&BL_HOM ) st->mdef += (st->int_/5 - bst->int_/5); @@ -3700,9 +3701,9 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag) { && st->dex == bst->dex #endif ) - st->mdef2 = iStatus->calc_mdef2(bl, sc, bst->mdef2, true); + st->mdef2 = status->calc_mdef2(bl, sc, bst->mdef2, true); else - st->mdef2 = iStatus->calc_mdef2(bl, sc, bst->mdef2 +(st->int_ - bst->int_) + st->mdef2 = status->calc_mdef2(bl, sc, bst->mdef2 +(st->int_ - bst->int_) #ifdef RENEWAL + (int)( ((float)st->dex/5 - (float)bst->dex/5) + ((float)st->vit/5 - (float)bst->vit/5) ) #else @@ -3725,7 +3726,7 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag) { st->speed = battle_config.max_walk_speed; if( bl->type&BL_HOM && battle_config.hom_setting&0x8 && ((TBL_HOM*)bl)->master) - st->speed = iStatus->get_speed(&((TBL_HOM*)bl)->master->bl); + st->speed = status->get_speed(&((TBL_HOM*)bl)->master->bl); } @@ -3751,9 +3752,9 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag) { } if(flag&SCB_ATK_ELE) { - st->rhw.ele = iStatus->calc_attack_element(bl, sc, bst->rhw.ele); + st->rhw.ele = status->calc_attack_element(bl, sc, bst->rhw.ele); if (sd) sd->state.lr_flag = 1; - st->lhw.ele = iStatus->calc_attack_element(bl, sc, bst->lhw.ele); + st->lhw.ele = status->calc_attack_element(bl, sc, bst->lhw.ele); if (sd) sd->state.lr_flag = 0; } @@ -3815,8 +3816,8 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag) { } } - if(flag&SCB_MATK) { - iStatus->get_matk(bl, 0); + if(flag&SCB_MATK) { + status->get_matk(bl, 0); } if(flag&SCB_ASPD) { @@ -3892,10 +3893,10 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag) { } if(flag&(SCB_VIT|SCB_MAXHP|SCB_INT|SCB_MAXSP) && bl->type&BL_REGEN) - iStatus->calc_regen(bl, st, iStatus->get_regen_data(bl)); + status->calc_regen(bl, st, status->get_regen_data(bl)); if(flag&SCB_REGEN && bl->type&BL_REGEN) - iStatus->calc_regen_rate(bl, iStatus->get_regen_data(bl), sc); + status->calc_regen_rate(bl, status->get_regen_data(bl), sc); } /// Recalculates parts of an object's base status and battle status according to the specified flags. /// Also sends updates to the client wherever applicable. @@ -3911,18 +3912,18 @@ void status_calc_bl_(struct block_list *bl, enum scb_flag flag, bool first) { } // remember previous values - st = iStatus->get_status_data(bl); + st = status->get_status_data(bl); memcpy(&bst, st, sizeof(struct status_data)); if( flag&SCB_BASE ) {// calculate the object's base status too switch( bl->type ) { - case BL_PC: iStatus->calc_pc_(BL_CAST(BL_PC,bl), first); break; - case BL_MOB: iStatus->calc_mob_(BL_CAST(BL_MOB,bl), first); break; - case BL_PET: iStatus->calc_pet_(BL_CAST(BL_PET,bl), first); break; - case BL_HOM: iStatus->calc_homunculus_(BL_CAST(BL_HOM,bl), first); break; - case BL_MER: iStatus->calc_mercenary_(BL_CAST(BL_MER,bl), first); break; - case BL_ELEM: iStatus->calc_elemental_(BL_CAST(BL_ELEM,bl), first); break; - case BL_NPC: status_calc_npc_(BL_CAST(BL_NPC,bl), first); break; + case BL_PC: status->calc_pc_(BL_CAST(BL_PC,bl), first); break; + case BL_MOB: status->calc_mob_(BL_CAST(BL_MOB,bl), first); break; + case BL_PET: status->calc_pet_(BL_CAST(BL_PET,bl), first); break; + case BL_HOM: status->calc_homunculus_(BL_CAST(BL_HOM,bl), first); break; + case BL_MER: status->calc_mercenary_(BL_CAST(BL_MER,bl), first); break; + case BL_ELEM: status->calc_elemental_(BL_CAST(BL_ELEM,bl), first); break; + case BL_NPC: status_calc_npc_(BL_CAST(BL_NPC,bl), first); break; } } @@ -5831,7 +5832,7 @@ struct status_data *status_get_base_status(struct block_list *bl) } defType status_get_def(struct block_list *bl) { struct unit_data *ud; - struct status_data *st = iStatus->get_status_data(bl); + struct status_data *st = status->get_status_data(bl); int def = st ? st->def : 0; ud = unit->bl2ud(bl); if (ud && ud->skilltimer != INVALID_TIMER) @@ -5840,11 +5841,10 @@ defType status_get_def(struct block_list *bl) { return cap_value(def, DEFTYPE_MIN, DEFTYPE_MAX); } -unsigned short status_get_speed(struct block_list *bl) -{ +unsigned short status_get_speed(struct block_list *bl) { if(bl->type==BL_NPC)//Only BL with speed data but no status_data [Skotlex] return ((struct npc_data *)bl)->speed; - return iStatus->get_status_data(bl)->speed; + return status->get_status_data(bl)->speed; } int status_get_party_id(struct block_list *bl) { @@ -5860,7 +5860,7 @@ int status_get_party_id(struct block_list *bl) { struct mob_data *md=(TBL_MOB*)bl; if( md->master_id > 0 ) { struct map_session_data *msd; - if (md->special_state.ai && (msd = iMap->id2sd(md->master_id)) != NULL) + if (md->special_state.ai && (msd = map->id2sd(md->master_id)) != NULL) return msd->status.party_id; return -md->master_id; } @@ -5898,7 +5898,7 @@ int status_get_guild_id(struct block_list *bl) { struct mob_data *md = (struct mob_data *)bl; if (md->guardian_data) //Guardian's guild [Skotlex] return md->guardian_data->guild_id; - if (md->special_state.ai && (msd = iMap->id2sd(md->master_id)) != NULL) + if (md->special_state.ai && (msd = map->id2sd(md->master_id)) != NULL) return msd->status.guild_id; //Alchemist's mobs [Skotlex] } break; @@ -5938,7 +5938,7 @@ int status_get_emblem_id(struct block_list *bl) { struct mob_data *md = (struct mob_data *)bl; if (md->guardian_data) //Guardian's guild [Skotlex] return md->guardian_data->emblem_id; - if (md->special_state.ai && (msd = iMap->id2sd(md->master_id)) != NULL) + if (md->special_state.ai && (msd = map->id2sd(md->master_id)) != NULL) return msd->guild_emblem_id; //Alchemist's mobs [Skotlex] } break; @@ -5984,15 +5984,13 @@ int status_get_race2(struct block_list *bl) return 0; } -int status_isdead(struct block_list *bl) -{ +int status_isdead(struct block_list *bl) { nullpo_ret(bl); - return iStatus->get_status_data(bl)->hp == 0; + return status->get_status_data(bl)->hp == 0; } -int status_isimmune(struct block_list *bl) -{ - struct status_change *sc =iStatus->get_sc(bl); +int status_isimmune(struct block_list *bl) { + struct status_change *sc = status->get_sc(bl); if (sc && sc->data[SC_HERMODE]) return 100; @@ -6168,16 +6166,15 @@ struct status_change *status_get_sc(struct block_list *bl) { return NULL; } -void status_change_init(struct block_list *bl) -{ - struct status_change *sc = iStatus->get_sc(bl); +void status_change_init(struct block_list *bl) { + struct status_change *sc = status->get_sc(bl); nullpo_retv(sc); memset(sc, 0, sizeof (struct status_change)); } //Applies SC defense to a given status change. //Returns the adjusted duration based on flag values. -//the flag values are the same as in iStatus->change_start. +//the flag values are the same as in status->change_start. int status_get_sc_def(struct block_list *bl, enum sc_type type, int rate, int tick, int flag) { //Percentual resistance: 10000 = 100% Resist //Example: 50% -> sc_def=5000 -> 25%; 5000ms -> tick_def=5000 -> 2500ms @@ -6192,7 +6189,7 @@ int status_get_sc_def(struct block_list *bl, enum sc_type type, int rate, int ti nullpo_ret(bl); //Status that are blocked by Golden Thief Bug card or Wand of Hermod - if (iStatus->isimmune(bl)) + if (status->isimmune(bl)) switch (type) { case SC_DEC_AGI: case SC_SILENCE: @@ -6227,8 +6224,8 @@ int status_get_sc_def(struct block_list *bl, enum sc_type type, int rate, int ti } sd = BL_CAST(BL_PC,bl); - st = iStatus->get_status_data(bl); - sc = iStatus->get_sc(bl); + st = status->get_status_data(bl); + sc = status->get_sc(bl); if( sc && !sc->count ) sc = NULL; switch (type) { @@ -6248,7 +6245,7 @@ int status_get_sc_def(struct block_list *bl, enum sc_type type, int rate, int ti break; case SC_DEEP_SLEEP: sc_def = st->int_*50; - tick_def = st->int_*10 + iStatus->get_lv(bl) * 65 / 10; //Seems to be -1 sec every 10 int and -5% chance every 10 int. + tick_def = st->int_*10 + status->get_lv(bl) * 65 / 10; //Seems to be -1 sec every 10 int and -5% chance every 10 int. break; case SC_DEC_AGI: case SC_ADORAMUS: //Arch Bishop @@ -6263,7 +6260,7 @@ int status_get_sc_def(struct block_list *bl, enum sc_type type, int rate, int ti break; case SC_CURSE: //Special property: inmunity when luk is greater than level or zero - if (st->luk > iStatus->get_lv(bl) || st->luk == 0) + if (st->luk > status->get_lv(bl) || st->luk == 0) return 0; sc_def = st->luk*100; sc_def2 = st->luk*10; @@ -6288,7 +6285,7 @@ int status_get_sc_def(struct block_list *bl, enum sc_type type, int rate, int ti case SC_STONESKIN: if (sd) //Duration greatly reduced for players. tick /= 15; - sc_def2 = iStatus->get_lv(bl)*20 + st->vit*25 + st->agi*10; // Lineal Reduction of Rate + sc_def2 = status->get_lv(bl)*20 + st->vit*25 + st->agi*10; // Lineal Reduction of Rate tick_def2 = 0; //No duration reduction break; case SC_MARSHOFABYSS: @@ -6300,7 +6297,7 @@ int status_get_sc_def(struct block_list *bl, enum sc_type type, int rate, int ti tick_def2 = (st->vit + st->dex)*50; break; if( bl->type == BL_PC ) - tick -= (iStatus->get_lv(bl) / 5 + st->vit / 4 + st->agi / 10)*100; + tick -= (status->get_lv(bl) / 5 + st->vit / 4 + st->agi / 10)*100; else tick -= (st->vit + st->luk) / 20 * 1000; break; @@ -6325,10 +6322,10 @@ int status_get_sc_def(struct block_list *bl, enum sc_type type, int rate, int ti tick -= 1000 * (st->agi/10); break; case SC_COLD: - tick -= (1000*(st->vit/10))+(iStatus->get_lv(bl)/50); + tick -= (1000*(st->vit/10))+(status->get_lv(bl)/50); break; case SC_SIREN: - tick -= 1000 * ((iStatus->get_lv(bl) / 10) + ((sd?sd->status.job_level:0) / 5)); + tick -= 1000 * ((status->get_lv(bl) / 10) + ((sd?sd->status.job_level:0) / 5)); tick = max(tick,10000); break; case SC_MANDRAGORA: @@ -6523,8 +6520,8 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val int opt_flag, calc_flag, undead_flag, val_flag = 0, tick_time = 0; nullpo_ret(bl); - sc = iStatus->get_sc(bl); - st = iStatus->get_status_data(bl); + sc = status->get_sc(bl); + st = status->get_status_data(bl); if( type <= SC_NONE || type >= SC_MAX ) { ShowError("status_change_start: invalid status change (%d)!\n", type); @@ -6534,16 +6531,15 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val if( !sc ) return 0; //Unable to receive status changes - if( iStatus->isdead(bl) && type != SC_NOCHAT ) // SC_NOCHAT should work even on dead characters + if( status->isdead(bl) && type != SC_NOCHAT ) // SC_NOCHAT should work even on dead characters return 0; - if( bl->type == BL_MOB) - { + if( bl->type == BL_MOB) { struct mob_data *md = BL_CAST(BL_MOB,bl); if(md && (md->class_ == MOBID_EMPERIUM || mob_is_battleground(md)) && type != SC_SAFETYWALL && type != SC_PNEUMA) return 0; //Emperium/BG Monsters can't be afflicted by status changes - // if(md && mob_is_gvg(md) && iStatus->sc2scb_flag(type)&SCB_MAXHP) - // return 0; //prevent status addinh hp to gvg mob (like bloodylust=hp*3 etc... + //if(md && mob_is_gvg(md) && status->sc2scb_flag(type)&SCB_MAXHP) + // return 0; //prevent status addinh hp to gvg mob (like bloodylust=hp*3 etc... } if( sc->data[SC_REFRESH] ) { @@ -6597,7 +6593,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val //Adjust tick according to status resistances if( !(flag&(1|4)) ) { - tick = iStatus->get_sc_def(bl, type, rate, tick, flag); + tick = status->get_sc_def(bl, type, rate, tick, flag); if( !tick ) return 0; } @@ -6716,25 +6712,25 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val return 0; break; case SC_MODECHANGE: - { - int mode; - struct status_data *bst = iStatus->get_base_status(bl); - if (!bst) return 0; - if (sc->data[type]) { - //Pile up with previous values. - if(!val2) val2 = sc->data[type]->val2; - val3 |= sc->data[type]->val3; - val4 |= sc->data[type]->val4; - } - mode = val2 ? val2 : bst->mode; //Base mode - if (val4) mode&=~val4; //Del mode - if (val3) mode|= val3; //Add mode - if (mode == bst->mode) { //No change. - if (sc->data[type]) //Abort previous status - return status_change_end(bl, type, INVALID_TIMER); - return 0; - } + { + int mode; + struct status_data *bst = status->get_base_status(bl); + if (!bst) return 0; + if (sc->data[type]) { + //Pile up with previous values. + if(!val2) val2 = sc->data[type]->val2; + val3 |= sc->data[type]->val3; + val4 |= sc->data[type]->val4; + } + mode = val2 ? val2 : bst->mode; //Base mode + if (val4) mode&=~val4; //Del mode + if (val3) mode|= val3; //Add mode + if (mode == bst->mode) { //No change. + if (sc->data[type]) //Abort previous status + return status_change_end(bl, type, INVALID_TIMER); + return 0; } + } break; //Strip skills, need to divest something or it fails. case SC_NOEQUIPWEAPON: @@ -7249,7 +7245,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val //Kaahi overwrites previous level regardless of existing level. //Delete timer if it exists. if (sce->val4 != INVALID_TIMER) { - timer->delete(sce->val4,iStatus->kaahi_heal_timer); + timer->delete(sce->val4,status->kaahi_heal_timer); sce->val4 = INVALID_TIMER; } break; @@ -7280,7 +7276,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val } } - vd = iStatus->get_viewdata(bl); + vd = status->get_viewdata(bl); calc_flag = StatusChangeFlagTable[type]; if(!(flag&4)) { //&4 - Do not parse val settings when loading SCs switch(type) { @@ -7292,17 +7288,14 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val val2 = 7; // Hit-count [Celest] 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 ) - { + if( sd ) { int i; - for( i = 0; i < 5; i++ ) - { - if( sd->devotion[i] && (tsd = iMap->id2sd(sd->devotion[i])) ) - iStatus->change_start(&tsd->bl, type, 10000, val1, val2, val3, val4, tick, 1); + for( i = 0; i < 5; i++ ) { + if( sd->devotion[i] && (tsd = map->id2sd(sd->devotion[i])) ) + status->change_start(&tsd->bl, type, 10000, val1, val2, val3, val4, tick, 1); } - } - else if( bl->type == BL_MER && ((TBL_MER*)bl)->devotion_flag && (tsd = ((TBL_MER*)bl)->master) ) - iStatus->change_start(&tsd->bl, type, 10000, val1, val2, val3, val4, tick, 1); + } else if( bl->type == BL_MER && ((TBL_MER*)bl)->devotion_flag && (tsd = ((TBL_MER*)bl)->master) ) + status->change_start(&tsd->bl, type, 10000, val1, val2, val3, val4, tick, 1); } //val4 signals infinite endure (if val4 == 2 it is infinite endure from Berserk) if( val4 ) @@ -7381,20 +7374,16 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val break; case SC_REFLECTSHIELD: val2=10+val1*3; // %Dmg reflected - if( !(flag&1) && (bl->type&(BL_PC|BL_MER)) ) - { + if( !(flag&1) && (bl->type&(BL_PC|BL_MER)) ) { struct map_session_data *tsd; - if( sd ) - { + if( sd ) { int i; - for( i = 0; i < 5; i++ ) - { - if( sd->devotion[i] && (tsd = iMap->id2sd(sd->devotion[i])) ) - iStatus->change_start(&tsd->bl, type, 10000, val1, val2, 0, 0, tick, 1); + for( i = 0; i < 5; i++ ) { + if( sd->devotion[i] && (tsd = map->id2sd(sd->devotion[i])) ) + status->change_start(&tsd->bl, type, 10000, val1, val2, 0, 0, tick, 1); } - } - else if( bl->type == BL_MER && ((TBL_MER*)bl)->devotion_flag && (tsd = ((TBL_MER*)bl)->master) ) - iStatus->change_start(&tsd->bl, type, 10000, val1, val2, 0, 0, tick, 1); + } else if( bl->type == BL_MER && ((TBL_MER*)bl)->devotion_flag && (tsd = ((TBL_MER*)bl)->master) ) + status->change_start(&tsd->bl, type, 10000, val1, val2, 0, 0, tick, 1); } break; case SC_NOEQUIPWEAPON: @@ -7434,7 +7423,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val #endif break; case SC_DELUGE: - val2 = deluge_eff[val1-1]; //HP increase + val2 = skill->deluge_eff[val1-1]; //HP increase #ifndef RENEWAL if(st->def_ele != ELE_WATER) val2 = 0; @@ -7529,7 +7518,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val if (st->hp - diff < st->max_hp>>2) diff = st->hp - (st->max_hp>>2); if( val2 && bl->type == BL_MOB ) { - struct block_list* src = iMap->id2bl(val2); + struct block_list* src = map->id2bl(val2); if( src ) mob->log_damage((TBL_MOB*)bl,src,diff); } @@ -7567,11 +7556,10 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val tick_time = val2 * 1000; // [GodLesZ] tick time break; case SC_CASH_BOSS_ALARM: - if( sd != NULL ) - { - struct mob_data *boss_md = iMap->getmob_boss(bl->m); // Search for Boss on this Map - if( boss_md == NULL || boss_md->bl.prev == NULL ) - { // No MVP on this map - MVP is dead + if( sd != NULL ) { + struct mob_data *boss_md = map->getmob_boss(bl->m); // Search for Boss on this Map + if( boss_md == NULL || boss_md->bl.prev == NULL ) { + // No MVP on this map - MVP is dead clif->bossmapinfo(sd->fd, boss_md, 1); return 0; // No need to start SC } @@ -7635,47 +7623,40 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val break; case SC_AUTOGUARD: - if( !(flag&1) ) - { + if( !(flag&1) ) { struct map_session_data *tsd; int i,t; - for( i = val2 = 0; i < val1; i++) - { + for( i = val2 = 0; i < val1; i++) { t = 5-(i>>1); val2 += (t < 0)? 1:t; } - if( bl->type&(BL_PC|BL_MER) ) - { - if( sd ) - { - for( i = 0; i < 5; i++ ) - { - if( sd->devotion[i] && (tsd = iMap->id2sd(sd->devotion[i])) ) - iStatus->change_start(&tsd->bl, type, 10000, val1, val2, 0, 0, tick, 1); + if( bl->type&(BL_PC|BL_MER) ) { + if( sd ) { + for( i = 0; i < 5; i++ ) { + if( sd->devotion[i] && (tsd = map->id2sd(sd->devotion[i])) ) + status->change_start(&tsd->bl, type, 10000, val1, val2, 0, 0, tick, 1); } } else if( bl->type == BL_MER && ((TBL_MER*)bl)->devotion_flag && (tsd = ((TBL_MER*)bl)->master) ) - iStatus->change_start(&tsd->bl, type, 10000, val1, val2, 0, 0, tick, 1); + status->change_start(&tsd->bl, type, 10000, val1, val2, 0, 0, tick, 1); } } break; case SC_DEFENDER: - if (!(flag&1)) - { + if (!(flag&1)) { val2 = 5 + 15*val1; //Damage reduction val3 = 0; // unused, previously speed adjustment val4 = 250 - 50*val1; //Aspd adjustment - if (sd) - { + if (sd) { struct map_session_data *tsd; int i; - for (i = 0; i < 5; i++) - { //See if there are devoted characters, and pass the status to them. [Skotlex] - if (sd->devotion[i] && (tsd = iMap->id2sd(sd->devotion[i]))) - iStatus->change_start(&tsd->bl,type,10000,val1,5+val1*5,val3,val4,tick,1); + for (i = 0; i < 5; i++) { + //See if there are devoted characters, and pass the status to them. [Skotlex] + if (sd->devotion[i] && (tsd = map->id2sd(sd->devotion[i]))) + status->change_start(&tsd->bl,type,10000,val1,5+val1*5,val3,val4,tick,1); } } } @@ -7702,7 +7683,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val case SC_JOINTBEAT: if( val2&BREAK_NECK ) - sc_start2(bl,SC_BLOODING,100,val1,val3,skill->get_time2(iStatus->sc2skill(type),val1)); + sc_start2(bl,SC_BLOODING,100,val1,val3,skill->get_time2(status->sc2skill(type),val1)); break; case SC_BERSERK: @@ -7712,58 +7693,59 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val sc_start4(bl, SC_ENDURE, 100,10,0,0,2, tick); //HP healing is performing after the calc_status call. //Val2 holds HP penalty - if (!val4) val4 = skill->get_time2(iStatus->sc2skill(type),val1); + if (!val4) val4 = skill->get_time2(status->sc2skill(type),val1); if (!val4) val4 = 10000; //Val4 holds damage interval val3 = tick/val4; //val3 holds skill duration tick_time = val4; // [GodLesZ] tick time break; case SC_GOSPEL: - if(val4 == BCT_SELF) { // self effect + if(val4 == BCT_SELF) { + // self effect val2 = tick/10000; tick_time = 10000; // [GodLesZ] tick time - iStatus->change_clear_buffs(bl,3); //Remove buffs/debuffs + status->change_clear_buffs(bl,3); //Remove buffs/debuffs } break; case SC_MARIONETTE_MASTER: - { - int stat; - - val3 = 0; - val4 = 0; - stat = ( sd ? sd->status.str : iStatus->get_base_status(bl)->str ) / 2; val3 |= cap_value(stat,0,0xFF)<<16; - stat = ( sd ? sd->status.agi : iStatus->get_base_status(bl)->agi ) / 2; val3 |= cap_value(stat,0,0xFF)<<8; - stat = ( sd ? sd->status.vit : iStatus->get_base_status(bl)->vit ) / 2; val3 |= cap_value(stat,0,0xFF); - stat = ( sd ? sd->status.int_: iStatus->get_base_status(bl)->int_) / 2; val4 |= cap_value(stat,0,0xFF)<<16; - stat = ( sd ? sd->status.dex : iStatus->get_base_status(bl)->dex ) / 2; val4 |= cap_value(stat,0,0xFF)<<8; - stat = ( sd ? sd->status.luk : iStatus->get_base_status(bl)->luk ) / 2; val4 |= cap_value(stat,0,0xFF); - break; - } + { + int stat; + + val3 = 0; + val4 = 0; + stat = ( sd ? sd->status.str : status->get_base_status(bl)->str ) / 2; val3 |= cap_value(stat,0,0xFF)<<16; + stat = ( sd ? sd->status.agi : status->get_base_status(bl)->agi ) / 2; val3 |= cap_value(stat,0,0xFF)<<8; + stat = ( sd ? sd->status.vit : status->get_base_status(bl)->vit ) / 2; val3 |= cap_value(stat,0,0xFF); + stat = ( sd ? sd->status.int_: status->get_base_status(bl)->int_) / 2; val4 |= cap_value(stat,0,0xFF)<<16; + stat = ( sd ? sd->status.dex : status->get_base_status(bl)->dex ) / 2; val4 |= cap_value(stat,0,0xFF)<<8; + stat = ( sd ? sd->status.luk : status->get_base_status(bl)->luk ) / 2; val4 |= cap_value(stat,0,0xFF); + } + break; case SC_MARIONETTE: - { - int stat,max_stat; - // fetch caster information - struct block_list *pbl = iMap->id2bl(val1); - struct status_change *psc = pbl?iStatus->get_sc(pbl):NULL; - struct status_change_entry *psce = psc?psc->data[SC_MARIONETTE_MASTER]:NULL; - // fetch target's stats - struct status_data* tst = iStatus->get_status_data(bl); // battle status - - if (!psce) - return 0; + { + int stat,max_stat; + // fetch caster information + struct block_list *pbl = map->id2bl(val1); + struct status_change *psc = pbl ? status->get_sc(pbl) : NULL; + struct status_change_entry *psce = psc ? psc->data[SC_MARIONETTE_MASTER] : NULL; + // fetch target's stats + struct status_data* tst = status->get_status_data(bl); // battle status + + if (!psce) + return 0; - val3 = 0; - val4 = 0; - max_stat = battle_config.max_parameter; //Cap to 99 (default) - stat = (psce->val3 >>16)&0xFF; stat = min(stat, max_stat - tst->str ); val3 |= cap_value(stat,0,0xFF)<<16; - stat = (psce->val3 >> 8)&0xFF; stat = min(stat, max_stat - tst->agi ); val3 |= cap_value(stat,0,0xFF)<<8; - stat = (psce->val3 >> 0)&0xFF; stat = min(stat, max_stat - tst->vit ); val3 |= cap_value(stat,0,0xFF); - stat = (psce->val4 >>16)&0xFF; stat = min(stat, max_stat - tst->int_); val4 |= cap_value(stat,0,0xFF)<<16; - stat = (psce->val4 >> 8)&0xFF; stat = min(stat, max_stat - tst->dex ); val4 |= cap_value(stat,0,0xFF)<<8; - stat = (psce->val4 >> 0)&0xFF; stat = min(stat, max_stat - tst->luk ); val4 |= cap_value(stat,0,0xFF); - break; - } + val3 = 0; + val4 = 0; + max_stat = battle_config.max_parameter; //Cap to 99 (default) + stat = (psce->val3 >>16)&0xFF; stat = min(stat, max_stat - tst->str ); val3 |= cap_value(stat,0,0xFF)<<16; + stat = (psce->val3 >> 8)&0xFF; stat = min(stat, max_stat - tst->agi ); val3 |= cap_value(stat,0,0xFF)<<8; + stat = (psce->val3 >> 0)&0xFF; stat = min(stat, max_stat - tst->vit ); val3 |= cap_value(stat,0,0xFF); + stat = (psce->val4 >>16)&0xFF; stat = min(stat, max_stat - tst->int_); val4 |= cap_value(stat,0,0xFF)<<16; + stat = (psce->val4 >> 8)&0xFF; stat = min(stat, max_stat - tst->dex ); val4 |= cap_value(stat,0,0xFF)<<8; + stat = (psce->val4 >> 0)&0xFF; stat = min(stat, max_stat - tst->luk ); val4 |= cap_value(stat,0,0xFF); + } + break; case SC_SWORDREJECT: val2 = 15*val1; //Reflect chance val3 = 3; //Reflections @@ -7789,28 +7771,28 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val break; case SC_DEVOTION: - { - 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 - const enum sc_type types[] = { SC_AUTOGUARD, SC_DEFENDER, SC_REFLECTSHIELD, SC_ENDURE }; - enum sc_type type2; - 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)); - i--; - } + { + struct block_list *d_bl; + struct status_change *d_sc; + + if( (d_bl = map->id2bl(val1)) && (d_sc = status->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) || 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(status->sc2skill(type2),d_sc->data[type2]->val1)); + i--; } - break; } + break; + } case SC_COMA: //Coma. Sends a char to 1HP. If val2, do not zap sp if( val3 && bl->type == BL_MOB ) { - struct block_list* src = iMap->id2bl(val3); + struct block_list* src = map->id2bl(val3); if( src ) mob->log_damage((TBL_MOB*)bl,src,st->hp - 1); } @@ -7818,21 +7800,21 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val return 1; break; case SC_RG_CCONFINE_S: - { - struct block_list *src = val2?iMap->id2bl(val2):NULL; - struct status_change *sc2 = src?iStatus->get_sc(src):NULL; - struct status_change_entry *sce2 = sc2?sc2->data[SC_RG_CCONFINE_M]:NULL; - if (src && sc2) { - if (!sce2) //Start lock on caster. - sc_start4(src,SC_RG_CCONFINE_M,100,val1,1,0,0,tick+1000); - else { //Increase count of locked enemies and refresh time. - (sce2->val2)++; - timer->delete(sce2->timer, iStatus->change_timer); - sce2->timer = timer->add(timer->gettick()+tick+1000, iStatus->change_timer, src->id, SC_RG_CCONFINE_M); - } - } else //Status failed. - return 0; - } + { + struct block_list *src = val2 ? map->id2bl(val2) : NULL; + struct status_change *sc2 = src ? status->get_sc(src) : NULL; + struct status_change_entry *sce2 = sc2 ? sc2->data[SC_RG_CCONFINE_M] : NULL; + if (src && sc2) { + if (!sce2) //Start lock on caster. + sc_start4(src,SC_RG_CCONFINE_M,100,val1,1,0,0,tick+1000); + else { //Increase count of locked enemies and refresh time. + (sce2->val2)++; + timer->delete(sce2->timer, status->change_timer); + sce2->timer = timer->add(timer->gettick()+tick+1000, status->change_timer, src->id, SC_RG_CCONFINE_M); + } + } else //Status failed. + return 0; + } break; case SC_KAITE: val2 = 1+val1/5; //Number of bounces: 1 + skill_lv/5 @@ -7937,13 +7919,13 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val val3 = 3*val1; //Hit increase break; case SC_SUN_COMFORT: - val2 = (iStatus->get_lv(bl) + st->dex + st->luk)/2; //def increase + val2 = (status->get_lv(bl) + st->dex + st->luk)/2; //def increase break; case SC_MOON_COMFORT: - val2 = (iStatus->get_lv(bl) + st->dex + st->luk)/10; //flee increase + val2 = (status->get_lv(bl) + st->dex + st->luk)/10; //flee increase break; case SC_STAR_COMFORT: - val2 = (iStatus->get_lv(bl) + st->dex + st->luk); //Aspd increase + val2 = (status->get_lv(bl) + st->dex + st->luk); //Aspd increase break; case SC_QUAGMIRE: val2 = (sd?5:10)*val1; //Agi/Dex decrease. @@ -8189,7 +8171,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val tick_time = 4000; // [GodLesZ] tick time break; case SC_PYREXIA: - iStatus->change_start(bl,SC_BLIND,10000,val1,0,0,0,30000,11); // Blind status that last for 30 seconds + status->change_start(bl,SC_BLIND,10000,val1,0,0,0,30000,11); // Blind status that last for 30 seconds val4 = tick / 3000; tick_time = 3000; // [GodLesZ] tick time break; @@ -8274,7 +8256,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val tick = -1; break; case SC__SHADOWFORM: { - struct map_session_data * s_sd = iMap->id2sd(val2); + struct map_session_data * s_sd = map->id2sd(val2); if( s_sd ) s_sd->shadowform_id = bl->id; val4 = tick / 1000; @@ -8352,14 +8334,14 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val tick_time = 1000; // [GodLesZ] tick time break; case SC_BLOOD_SUCKER: - { - struct block_list *src = iMap->id2bl(val2); - val3 = 1; - if(src) - val3 = 200 + 100 * val1 + status_get_int(src); - val4 = tick / 1000; - tick_time = 1000; // [GodLesZ] tick time - } + { + struct block_list *src = map->id2bl(val2); + val3 = 1; + if(src) + val3 = 200 + 100 * val1 + status_get_int(src); + val4 = tick / 1000; + tick_time = 1000; // [GodLesZ] tick time + } break; case SC_VACUUM_EXTREME: tick -= (st->str / 20) * 1000; @@ -8402,7 +8384,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val tick_time = 3000; // [GodLesZ] tick time break; case SC_SATURDAY_NIGHT_FEVER: - if (!val4) val4 = skill->get_time2(iStatus->sc2skill(type),val1); + if (!val4) val4 = skill->get_time2(status->sc2skill(type),val1); if (!val4) val4 = 3000; val3 = tick/val4; tick_time = val4; // [GodLesZ] tick time @@ -8464,12 +8446,11 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val break; case SC_EXEEDBREAK: val1 *= 150; // 150 * skill_lv - if( sd && sd->inventory_data[sd->equip_index[EQI_HAND_R]] ) { // Chars. - val1 += (sd->inventory_data[sd->equip_index[EQI_HAND_R]]->weight/10 * sd->inventory_data[sd->equip_index[EQI_HAND_R]]->wlv * iStatus->get_lv(bl) / 100); + if( sd && sd->inventory_data[sd->equip_index[EQI_HAND_R]] ) { // Chars. + val1 += (sd->inventory_data[sd->equip_index[EQI_HAND_R]]->weight/10 * sd->inventory_data[sd->equip_index[EQI_HAND_R]]->wlv * status->get_lv(bl) / 100); val1 += 15 * (sd ? sd->status.job_level:50) + 100; - } - else // Mobs - val1 += (400 * iStatus->get_lv(bl) / 100) + (15 * (iStatus->get_lv(bl) / 2)); // About 1138% at mob_lvl 99. Is an aproximation to a standard weapon. [pakpil] + } else // Mobs + val1 += (400 * status->get_lv(bl) / 100) + (15 * (status->get_lv(bl) / 2)); // About 1138% at mob_lvl 99. Is an aproximation to a standard weapon. [pakpil] break; case SC_PRESTIGE: // Based on suggested formula in iRO Wiki and some test, still need more test. [pakpil] val2 = ((st->int_ + st->luk) / 6) + 5; // Chance to evade magic damage. @@ -8492,14 +8473,13 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val tick_time = 1000; // [GodLesZ] tick time break; case SC_INSPIRATION: - if( sd ) - { + if( sd ) { val2 = (40 * val1) + (3 * sd->status.job_level); // ATK bonus val3 = (sd->status.job_level / 10) * 2 + 12; // All stat bonus } val4 = tick / 1000; tick_time = 1000; // [GodLesZ] tick time - iStatus->change_clear_buffs(bl,3); //Remove buffs/debuffs + status->change_clear_buffs(bl,3); //Remove buffs/debuffs break; case SC_SPELLFIST: case SC_CURSEDCIRCLE_ATKER: @@ -8518,22 +8498,22 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val tick_time = 5000; // [GodLesZ] tick time break; case SC_GENTLETOUCH_CHANGE: - {// take note there is no def increase as skill desc says. [malufett] - struct block_list * src; - val3 = st->agi * val1 / 60; // ASPD increase: [(Target AGI x Skill Level) / 60] % - if( (src = iMap->id2bl(val2)) ){ - val4 = ( 200/status_get_int(src) ) * val1;// MDEF decrease: MDEF [(200 / Caster INT) x Skill Level] - val2 = ( status_get_dex(src)/4 + status_get_str(src)/2 ) * val1 / 5; // ATK increase: ATK [{(Caster DEX / 4) + (Caster STR / 2)} x Skill Level / 5] - } + {// take note there is no def increase as skill desc says. [malufett] + struct block_list * src; + val3 = st->agi * val1 / 60; // ASPD increase: [(Target AGI x Skill Level) / 60] % + if( (src = map->id2bl(val2)) ){ + val4 = ( 200/status_get_int(src) ) * val1;// MDEF decrease: MDEF [(200 / Caster INT) x Skill Level] + val2 = ( status_get_dex(src)/4 + status_get_str(src)/2 ) * val1 / 5; // ATK increase: ATK [{(Caster DEX / 4) + (Caster STR / 2)} x Skill Level / 5] } + } break; case SC_GENTLETOUCH_REVITALIZE: - {// take note there is no vit,aspd,speed increase as skill desc says. [malufett] - struct block_list * src; - val3 = val1 * 30 + 150; // Natural HP recovery increase: [(Skill Level x 30) + 50] % - if( (src = iMap->id2bl(val2)) ) // the stat def is not shown in the status window and it is process differently - val4 = ( status_get_vit(src)/4 ) * val1; // STAT DEF increase: [(Caster VIT / 4) x Skill Level] - } + {// take note there is no vit,aspd,speed increase as skill desc says. [malufett] + struct block_list * src; + val3 = val1 * 30 + 150; // Natural HP recovery increase: [(Skill Level x 30) + 50] % + if( (src = map->id2bl(val2)) ) // the stat def is not shown in the status window and it is process differently + val4 = ( status_get_vit(src)/4 ) * val1; // STAT DEF increase: [(Caster VIT / 4) x Skill Level] + } break; case SC_PYROTECHNIC_OPTION: val_flag |= 1|2|4; @@ -8650,25 +8630,33 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val tick_time = 1000; break; case SC_ZANGETSU: - val2 = val4 = iStatus->get_lv(bl) / 3 + 20 * val1; - val3 = iStatus->get_lv(bl) / 2 + 30 * val1; + val2 = val4 = status->get_lv(bl) / 3 + 20 * val1; + val3 = status->get_lv(bl) / 2 + 30 * val1; val2 = (!(status_get_hp(bl)%2) ? val2 : -val3); val3 = (!(status_get_sp(bl)%2) ? val4 : -val3); break; case SC_GENSOU: - { - int hp = status_get_hp(bl), sp = status_get_sp(bl), lv = 5; -#define PER( a ) { if( a <= 15 )lv = 1;else if( a <= 30 )lv = 2;else if( a <= 50 )lv = 3;else if( a <= 75 )lv = 4;} - if( rand()%100 > (25 + 10 * val1) - status_get_int(bl) / 2) - return 0; +#define PER( a ) do { \ + if( a <= 15 ) lv = 1; \ + else if( a <= 30 ) lv = 2; \ + else if( a <= 50 ) lv = 3; \ + else if( a <= 75 ) lv = 4; \ +} while(0) - PER( 100 / (status_get_max_hp(bl) / hp) ); - iStatus->heal(bl, (!(hp%2) ? (6-lv) *4 / 100 : -(lv*4) / 100), 0, 1); + { + int hp = status_get_hp(bl), sp = status_get_sp(bl), lv = 5; - PER( 100 / (status_get_max_sp(bl) / sp) ); - iStatus->heal(bl, 0,(!(sp%2) ? (6-lv) *3 / 100 : -(lv*3) / 100), 1); - } + if( rand()%100 > (25 + 10 * val1) - status_get_int(bl) / 2) + return 0; + + PER( 100 / (status_get_max_hp(bl) / hp) ); + status->heal(bl, (!(hp%2) ? (6-lv) *4 / 100 : -(lv*4) / 100), 0, 1); + + PER( 100 / (status_get_max_sp(bl) / sp) ); + status->heal(bl, 0,(!(sp%2) ? (6-lv) *3 / 100 : -(lv*3) / 100), 1); + } +#undef PER break; case SC_ANGRIFFS_MODUS: val2 = 50 + 20 * val1; //atk bonus @@ -9060,7 +9048,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val //Don't trust the previous sce assignment, in case the SC ended somewhere between there and here. if((sce=sc->data[type])) {// reuse old sc if( sce->timer != INVALID_TIMER ) - timer->delete(sce->timer, iStatus->change_timer); + timer->delete(sce->timer, status->change_timer); } else {// new sc ++(sc->count); sce = sc->data[type] = ers_alloc(sc_data_ers, struct status_change_entry); @@ -9070,7 +9058,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val sce->val3 = val3; sce->val4 = val4; if (tick >= 0) - sce->timer = timer->add(timer->gettick() + tick, iStatus->change_timer, bl->id, type); + sce->timer = timer->add(timer->gettick() + tick, status->change_timer, bl->id, type); else sce->timer = INVALID_TIMER; //Infinite duration @@ -9083,8 +9071,8 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val switch (type) { case SC_BERSERK: if (!(sce->val2)) { //don't heal if already set - iStatus->heal(bl, st->max_hp, 0, 1); //Do not use percent_heal as this healing must override BERSERK's block. - iStatus->set_sp(bl, 0, 0); //Damage all SP + status->heal(bl, st->max_hp, 0, 1); //Do not use percent_heal as this healing must override BERSERK's block. + status->set_sp(bl, 0, 0); //Damage all SP } sce->val2 = 5 * st->max_hp / 100; break; @@ -9099,7 +9087,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val } break; case SC_CASH_BOSS_ALARM: - clif->bossmapinfo(sd->fd, iMap->id2boss(sce->val1), 0); // First Message + clif->bossmapinfo(sd->fd, map->id2boss(sce->val1), 0); // First Message break; case SC_MER_HP: status_percent_heal(bl, 100, 0); // Recover Full HP @@ -9177,7 +9165,7 @@ int status_change_clear(struct block_list* bl, int type) { struct status_change* sc; int i; - sc = iStatus->get_sc(bl); + sc = status->get_sc(bl); if (!sc || !sc->count) return 0; @@ -9187,7 +9175,7 @@ int status_change_clear(struct block_list* bl, int type) { continue; if(type == 0){ - if( iStatus->get_sc_type(i)&SC_NO_REM_DEATH ){ + if( status->get_sc_type(i)&SC_NO_REM_DEATH ) { switch (i) { case SC_ARMOR_PROPERTY://Only when its Holy or Dark that it doesn't dispell on death if( sc->data[i]->val2 != ELE_HOLY && sc->data[i]->val2 != ELE_DARK ) @@ -9215,7 +9203,7 @@ int status_change_clear(struct block_list* bl, int type) { //If for some reason status_change_end decides to still keep the status when quitting. [Skotlex] (sc->count)--; if (sc->data[i]->timer != INVALID_TIMER) - timer->delete(sc->data[i]->timer, iStatus->change_timer); + timer->delete(sc->data[i]->timer, status->change_timer); ers_free(sc_data_ers, sc->data[i]); sc->data[i] = NULL; } @@ -9248,8 +9236,8 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const nullpo_ret(bl); - sc = iStatus->get_sc(bl); - st = iStatus->get_status_data(bl); + sc = status->get_sc(bl); + st = status->get_status_data(bl); if(type < 0 || type >= SC_MAX || !sc || !(sce = sc->data[type])) return 0; @@ -9264,7 +9252,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const //Do not end infinite endure. return 0; if (sce->timer != INVALID_TIMER) //Could be a SC with infinite duration - timer->delete(sce->timer,iStatus->change_timer); + timer->delete(sce->timer,status->change_timer); if (sc->opt1) switch (type) { //"Ugly workaround" [Skotlex] @@ -9280,7 +9268,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const //since these SC are not affected by it, and it lets us know //if we have already delayed this attack or not. sce->val1 = 0; - sce->timer = timer->add(timer->gettick()+10, iStatus->change_timer, bl->id, type); + sce->timer = timer->add(timer->gettick()+10, status->change_timer, bl->id, type); return 1; } } @@ -9294,7 +9282,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const status_display_remove(sd,type); } - vd = iStatus->get_viewdata(bl); + vd = status->get_viewdata(bl); calc_flag = StatusChangeFlagTable[type]; switch(type) { case SC_GRANITIC_ARMOR: @@ -9302,7 +9290,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const int damage = st->max_hp*sce->val3/100; if(st->hp < damage) //to not kill him damage = st->hp-1; - iStatus->damage(NULL, bl, damage,0,0,1); + status->damage(NULL, bl, damage,0,0,1); } break; case SC_PYROCLASTIC: @@ -9320,11 +9308,11 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const if (ud->walktimer != INVALID_TIMER) unit->stop_walking(bl,1); } - if (begin_spurt && sce->val1 >= 7 && - DIFF_TICK(timer->gettick(), sce->val4) <= 1000 && - (!sd || (sd->weapontype1 == 0 && sd->weapontype2 == 0)) - ) - sc_start(bl,SC_STRUP,100,sce->val1,skill->get_time2(iStatus->sc2skill(type), sce->val1)); + if (begin_spurt && sce->val1 >= 7 + && DIFF_TICK(timer->gettick(), sce->val4) <= 1000 + && (!sd || (sd->weapontype1 == 0 && sd->weapontype2 == 0)) + ) + sc_start(bl,SC_STRUP,100,sce->val1,skill->get_time2(status->sc2skill(type), sce->val1)); } break; case SC_AUTOBERSERK: @@ -9338,17 +9326,15 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const case SC_AUTOGUARD: { struct map_session_data *tsd; - if( bl->type == BL_PC ) - { // Clear Status from others + if( bl->type == BL_PC ) { + // Clear Status from others int i; - for( i = 0; i < 5; i++ ) - { - if( sd->devotion[i] && (tsd = iMap->id2sd(sd->devotion[i])) && tsd->sc.data[type] ) + for( i = 0; i < 5; i++ ) { + if( sd->devotion[i] && (tsd = map->id2sd(sd->devotion[i])) && tsd->sc.data[type] ) status_change_end(&tsd->bl, type, INVALID_TIMER); } - } - else if( bl->type == BL_MER && ((TBL_MER*)bl)->devotion_flag ) - { // Clear Status from Master + } else if( bl->type == BL_MER && ((TBL_MER*)bl)->devotion_flag ) { + // Clear Status from Master tsd = ((TBL_MER*)bl)->master; if( tsd && tsd->sc.data[type] ) status_change_end(&tsd->bl, type, INVALID_TIMER); @@ -9357,9 +9343,8 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const break; case SC_DEVOTION: { - struct block_list *d_bl = iMap->id2bl(sce->val1); - if( d_bl ) - { + struct block_list *d_bl = map->id2bl(sce->val1); + if( d_bl ) { if( d_bl->type == BL_PC ) ((TBL_PC*)d_bl)->devotion[sce->val2] = 0; else if( d_bl->type == BL_MER ) @@ -9375,14 +9360,12 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const break; case SC_BLADESTOP: - if(sce->val4) - { + if(sce->val4) { int tid = sce->val4; - struct block_list *tbl = iMap->id2bl(tid); - struct status_change *tsc = iStatus->get_sc(tbl); + struct block_list *tbl = map->id2bl(tid); + struct status_change *tsc = status->get_sc(tbl); sce->val4 = 0; - if(tbl && tsc && tsc->data[SC_BLADESTOP]) - { + if(tbl && tsc && tsc->data[SC_BLADESTOP]) { tsc->data[SC_BLADESTOP]->val4 = 0; status_change_end(tbl, SC_BLADESTOP, INVALID_TIMER); } @@ -9412,7 +9395,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const sd->delunit_prevline = line; } - if(sce->val4 && sce->val4 != BCT_SELF && (dsd=iMap->id2sd(sce->val4))) + if(sce->val4 && sce->val4 != BCT_SELF && (dsd=map->id2sd(sce->val4))) {// end status on partner as well dsc = dsd->sc.data[SC_DANCING]; if(dsc) { @@ -9459,15 +9442,15 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const break; case SC_SPLASHER: { - struct block_list *src=iMap->id2bl(sce->val3); + struct block_list *src=map->id2bl(sce->val3); if(src && tid != INVALID_TIMER) skill->castend_damage_id(src, bl, sce->val2, sce->val1, timer->gettick(), SD_LEVEL ); } break; case SC_RG_CCONFINE_S: { - struct block_list *src = sce->val2?iMap->id2bl(sce->val2):NULL; - struct status_change *sc2 = src?iStatus->get_sc(src):NULL; + struct block_list *src = sce->val2 ? map->id2bl(sce->val2) : NULL; + struct status_change *sc2 = src ? status->get_sc(src) : NULL; if (src && sc2 && sc2->data[SC_RG_CCONFINE_M]) { //If status was already ended, do nothing. //Decrease count @@ -9479,9 +9462,9 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const if (sce->val2 > 0) { //Caster has been unlocked... nearby chars need to be unlocked. int range = 1 - +skill->get_range2(bl, iStatus->sc2skill(type), sce->val1) + +skill->get_range2(bl, status->sc2skill(type), sce->val1) +skill->get_range2(bl, TF_BACKSLIDING, 1); //Since most people use this to escape the hold.... - iMap->foreachinarea(iStatus->change_timer_sub, + map->foreachinarea(status->change_timer_sub, bl->m, bl->x-range, bl->y-range, bl->x+range,bl->y+range,BL_CHAR,bl,sce,type,timer->gettick()); } break; @@ -9508,12 +9491,12 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const break; case SC_MARIONETTE_MASTER: - case SC_MARIONETTE: /// Marionette target - if (sce->val1) - { // check for partner and end their marionette status as well + case SC_MARIONETTE: /// Marionette target + if (sce->val1) { + // check for partner and end their marionette status as well enum sc_type type2 = (type == SC_MARIONETTE_MASTER) ? SC_MARIONETTE : SC_MARIONETTE_MASTER; - struct block_list *pbl = iMap->id2bl(sce->val1); - struct status_change* sc2 = pbl?iStatus->get_sc(pbl):NULL; + struct block_list *pbl = map->id2bl(sce->val1); + struct status_change* sc2 = pbl ? status->get_sc(pbl) : NULL; if (sc2 && sc2->data[type2]) { @@ -9529,7 +9512,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const status_percent_heal(bl, 100, 0); status_change_end(bl, SC__BLOODYLUST, INVALID_TIMER); } else if(st->hp > 100 && sce->val2) //If val2 is removed, no HP penalty (dispelled?) [Skotlex] - iStatus->set_hp(bl, 100, 0); + status->set_hp(bl, 100, 0); if(sc->data[SC_ENDURE] && sc->data[SC_ENDURE]->val4 == 2) { sc->data[SC_ENDURE]->val4 = 0; status_change_end(bl, SC_ENDURE, INVALID_TIMER); @@ -9567,7 +9550,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const case SC_KAAHI: //Delete timer if it exists. if (sce->val4 != INVALID_TIMER) - timer->delete(sce->val4,iStatus->kaahi_heal_timer); + timer->delete(sce->val4,status->kaahi_heal_timer); break; case SC_JAILED: if(tid == INVALID_TIMER) @@ -9580,25 +9563,24 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const if (tid == INVALID_TIMER) break; // "lose almost all their HP and SP" on natural expiration. - iStatus->set_hp(bl, 10, 0); - iStatus->set_sp(bl, 10, 0); + status->set_hp(bl, 10, 0); + status->set_sp(bl, 10, 0); break; case SC_AUTOTRADE: if (tid == INVALID_TIMER) break; // Note: vending/buying is closed by unit_remove_map, no // need to do it here. - iMap->quit(sd); - // Because iMap->quit calls status_change_end with tid -1 + map->quit(sd); + // Because map->quit calls status_change_end with tid -1 // from here it's not neccesary to continue return 1; break; case SC_STOP: - if( sce->val2 ) - { - struct block_list* tbl = iMap->id2bl(sce->val2); + if( sce->val2 ) { + struct block_list* tbl = map->id2bl(sce->val2); sce->val2 = 0; - if( tbl && (sc = iStatus->get_sc(tbl)) && sc->data[SC_STOP] && sc->data[SC_STOP]->val2 == bl->id ) + if( tbl && (sc = status->get_sc(tbl)) && sc->data[SC_STOP] && sc->data[SC_STOP]->val2 == bl->id ) status_change_end(tbl, SC_STOP, INVALID_TIMER); } break; @@ -9616,7 +9598,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const break; case SC_WHITEIMPRISON: { - struct block_list* src = iMap->id2bl(sce->val2); + struct block_list* src = map->id2bl(sce->val2); if( tid == -1 || !src) break; // Terminated by Damage status_fix_damage(src,bl,400*sce->val1,clif->damage(bl,bl,timer->gettick(),0,0,400*sce->val1,0,0,0)); @@ -9635,13 +9617,14 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const case SC_ADORAMUS: status_change_end(bl, SC_BLIND, INVALID_TIMER); break; - case SC__SHADOWFORM: { - struct map_session_data *s_sd = iMap->id2sd(sce->val2); - if( !s_sd ) - break; - s_sd->shadowform_id = 0; - } - break; + case SC__SHADOWFORM: + { + struct map_session_data *s_sd = map->id2sd(sce->val2); + if( !s_sd ) + break; + s_sd->shadowform_id = 0; + } + break; case SC_SITDOWN_FORCE: if( sd && pc_issit(sd) ) { pc->setstand(sd); @@ -9667,7 +9650,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const break; case SC_CURSEDCIRCLE_ATKER: if( sce->val2 ) // used the default area size cause there is a chance the caster could knock back and can't clear the target. - iMap->foreachinrange(iStatus->change_timer_sub, bl, battle_config.area_size,BL_CHAR, bl, sce, SC_CURSEDCIRCLE_TARGET, timer->gettick()); + map->foreachinrange(status->change_timer_sub, bl, battle_config.area_size,BL_CHAR, bl, sce, SC_CURSEDCIRCLE_TARGET, timer->gettick()); break; case SC_RAISINGDRAGON: if( sd && sce->val2 && !pc_isdead(sd) ) { @@ -9682,20 +9665,20 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const } break; case SC_CURSEDCIRCLE_TARGET: - { - struct block_list *src = iMap->id2bl(sce->val2); - struct status_change *sc = iStatus->get_sc(src); - if( sc && sc->data[SC_CURSEDCIRCLE_ATKER] && --(sc->data[SC_CURSEDCIRCLE_ATKER]->val2) == 0 ){ - status_change_end(src, SC_CURSEDCIRCLE_ATKER, INVALID_TIMER); - clif->bladestop(bl, sce->val2, 0); - } + { + struct block_list *src = map->id2bl(sce->val2); + struct status_change *sc = status->get_sc(src); + if( sc && sc->data[SC_CURSEDCIRCLE_ATKER] && --(sc->data[SC_CURSEDCIRCLE_ATKER]->val2) == 0 ){ + status_change_end(src, SC_CURSEDCIRCLE_ATKER, INVALID_TIMER); + clif->bladestop(bl, sce->val2, 0); } + } break; case SC_BLOOD_SUCKER: if( sce->val2 ){ - struct block_list *src = iMap->id2bl(sce->val2); - if(src){ - struct status_change *sc = iStatus->get_sc(src); + struct block_list *src = map->id2bl(sce->val2); + if(src) { + struct status_change *sc = status->get_sc(src); sc->bs_counter--; } } @@ -9924,7 +9907,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const if(opt_flag&4) //Out of hiding, invoke on place. skill->unit_move(bl,timer->gettick(),1); - if(opt_flag&2 && sd && iMap->getcell(bl->m,bl->x,bl->y,CELL_CHKNPC)) + if(opt_flag&2 && sd && map->getcell(bl->m,bl->x,bl->y,CELL_CHKNPC)) npc->touch_areanpc(sd,bl->m,bl->x,bl->y); //Trigger on-touch event. ers_free(sc_data_ers, sce); @@ -9938,9 +9921,10 @@ int kaahi_heal_timer(int tid, unsigned int tick, int id, intptr_t data) { struct status_data *st; int hp; - if(!((bl=iMap->id2bl(id))&& - (sc=iStatus->get_sc(bl)) && - (sce = sc->data[SC_KAAHI]))) + if(!( (bl=map->id2bl(id)) + && (sc=status->get_sc(bl)) + && (sce=sc->data[SC_KAAHI]) + )) return 0; if(sce->val4 != tid) { @@ -9949,8 +9933,8 @@ int kaahi_heal_timer(int tid, unsigned int tick, int id, intptr_t data) { return 0; } - st=iStatus->get_status_data(bl); - if(!iStatus->charge(bl, 0, sce->val3)) { + st=status->get_status_data(bl); + if(!status->charge(bl, 0, sce->val3)) { sce->val4 = INVALID_TIMER; return 0; } @@ -9959,7 +9943,7 @@ int kaahi_heal_timer(int tid, unsigned int tick, int id, intptr_t data) { if (hp > sce->val2) hp = sce->val2; if (hp) - iStatus->heal(bl, hp, 0, 2); + status->heal(bl, hp, 0, 2); sce->val4 = INVALID_TIMER; return 1; } @@ -9976,14 +9960,13 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) { struct status_change *sc; struct status_change_entry *sce; - bl = iMap->id2bl(id); - if(!bl) - { + bl = map->id2bl(id); + if(!bl) { ShowDebug("status_change_timer: Null pointer id: %d data: %d\n", id, data); return 0; } - sc = iStatus->get_sc(bl); - st = iStatus->get_status_data(bl); + sc = status->get_sc(bl); + st = status->get_status_data(bl); if(!(sc && (sce = sc->data[type]))) { @@ -10000,49 +9983,48 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) { sd = BL_CAST(BL_PC, bl); // set the next timer of the sce (don't assume the status still exists) -#define sc_timer_next(t,f,i,d) \ +#define sc_timer_next(t,f,i,d) do { \ if( (sce=sc->data[type]) ) \ - sce->timer = timer->add(t,f,i,d); \ + sce->timer = timer->add(t,f,i,d); \ else \ - ShowError("status_change_timer: Unexpected NULL status change id: %d data: %d\n", id, data) + ShowError("status_change_timer: Unexpected NULL status change id: %d data: %d\n", id, data); \ +} while(0) - switch(type) - { + switch(type) { case SC_MAXIMIZEPOWER: case SC_CLOAKING: - if(!iStatus->charge(bl, 0, 1)) + if(!status->charge(bl, 0, 1)) break; //Not enough SP to continue. - sc_timer_next(sce->val2+tick, iStatus->change_timer, bl->id, data); + sc_timer_next(sce->val2+tick, status->change_timer, bl->id, data); return 0; case SC_CHASEWALK: - if(!iStatus->charge(bl, 0, sce->val4)) + if(!status->charge(bl, 0, sce->val4)) break; //Not enough SP to continue. if (!sc->data[SC_CHASEWALK2]) { sc_start(bl, SC_CHASEWALK2,100,1<<(sce->val1-1), - (sc->data[SC_SOULLINK] && sc->data[SC_SOULLINK]->val2 == SL_ROGUE?10:1) //SL bonus -> x10 duration - *skill->get_time2(iStatus->sc2skill(type),sce->val1)); + (sc->data[SC_SOULLINK] && sc->data[SC_SOULLINK]->val2 == SL_ROGUE?10:1) //SL bonus -> x10 duration + * skill->get_time2(status->sc2skill(type),sce->val1)); } - sc_timer_next(sce->val2+tick, iStatus->change_timer, bl->id, data); + sc_timer_next(sce->val2+tick, status->change_timer, bl->id, data); return 0; break; case SC_SKA: - if(--(sce->val2)>0){ + if(--(sce->val2)>0) { sce->val3 = rnd()%100; //Random defense. - sc_timer_next(1000+tick, iStatus->change_timer,bl->id, data); + sc_timer_next(1000+tick, status->change_timer,bl->id, data); return 0; } break; case SC_HIDING: - if(--(sce->val2)>0){ - - if(sce->val2 % sce->val4 == 0 && !iStatus->charge(bl, 0, 1)) + if(--(sce->val2)>0) { + if(sce->val2 % sce->val4 == 0 && !status->charge(bl, 0, 1)) break; //Fail if it's time to substract SP and there isn't. - sc_timer_next(1000+tick, iStatus->change_timer,bl->id, data); + sc_timer_next(1000+tick, status->change_timer,bl->id, data); return 0; } break; @@ -10051,20 +10033,20 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) { case SC_RUWACH: case SC_WZ_SIGHTBLASTER: if(type == SC_WZ_SIGHTBLASTER) - iMap->foreachinrange( iStatus->change_timer_sub, bl, sce->val3, BL_CHAR|BL_SKILL, bl, sce, type, tick); + map->foreachinrange(status->change_timer_sub, bl, sce->val3, BL_CHAR|BL_SKILL, bl, sce, type, tick); else - iMap->foreachinrange( iStatus->change_timer_sub, bl, sce->val3, BL_CHAR, bl, sce, type, tick); + map->foreachinrange(status->change_timer_sub, bl, sce->val3, BL_CHAR, bl, sce, type, tick); if( --(sce->val2)>0 ){ sce->val4 += 250; // use for Shadow Form 2 seconds checking. - sc_timer_next(250+tick, iStatus->change_timer, bl->id, data); + sc_timer_next(250+tick, status->change_timer, bl->id, data); return 0; } break; case SC_PROVOKE: - if(sce->val2) { //Auto-provoke (it is ended in iStatus->heal) - sc_timer_next(1000*60+tick,iStatus->change_timer, bl->id, data ); + if(sce->val2) { //Auto-provoke (it is ended in status->heal) + sc_timer_next(1000*60+tick, status->change_timer, bl->id, data ); return 0; } break; @@ -10076,14 +10058,14 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) { unit->stop_attack(bl); sc->opt1 = OPT1_STONE; clif->changeoption(bl); - sc_timer_next(1000+tick,iStatus->change_timer, bl->id, data ); + sc_timer_next(1000+tick, status->change_timer, bl->id, data ); status_calc_bl(bl, StatusChangeFlagTable[type]); return 0; } if(--(sce->val3) > 0) { if(++(sce->val4)%5 == 0 && st->hp > st->max_hp/4) status_percent_damage(NULL, bl, 1, 0, false); - sc_timer_next(1000+tick,iStatus->change_timer, bl->id, data ); + sc_timer_next(1000+tick, status->change_timer, bl->id, data ); return 0; } break; @@ -10095,24 +10077,24 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) { if (--(sce->val3) > 0) { if (!sc->data[SC_SLOWPOISON]) { if( sce->val2 && bl->type == BL_MOB ) { - struct block_list* src = iMap->id2bl(sce->val2); + struct block_list* src = map->id2bl(sce->val2); if( src ) mob->log_damage((TBL_MOB*)bl,src,sce->val4); } - iMap->freeblock_lock(); + map->freeblock_lock(); status_zap(bl, sce->val4, 0); if (sc->data[type]) { // Check if the status still last ( can be dead since then ). - sc_timer_next(1000 + tick, iStatus->change_timer, bl->id, data ); + sc_timer_next(1000 + tick, status->change_timer, bl->id, data ); } - iMap->freeblock_unlock(); + map->freeblock_unlock(); } return 0; } break; case SC_TENSIONRELAX: - if(st->max_hp > st->hp && --(sce->val3) > 0){ - sc_timer_next(sce->val4+tick, iStatus->change_timer, bl->id, data); + if(st->max_hp > st->hp && --(sce->val3) > 0) { + sc_timer_next(sce->val4+tick, status->change_timer, bl->id, data); return 0; } break; @@ -10131,47 +10113,44 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) { case SC_BLOODING: if (--(sce->val4) >= 0) { int hp = rnd()%600 + 200; - struct block_list* src = iMap->id2bl(sce->val2); + struct block_list* src = map->id2bl(sce->val2); if( src && bl && bl->type == BL_MOB ) { mob->log_damage((TBL_MOB*)bl,src,sd||hp<st->hp?hp:st->hp-1); } - iMap->freeblock_lock(); + map->freeblock_lock(); status_fix_damage(src, bl, sd||hp<st->hp?hp:st->hp-1, 1); if( sc->data[type] ) { if( st->hp == 1 ) { - iMap->freeblock_unlock(); + map->freeblock_unlock(); break; } - sc_timer_next(10000 + tick, iStatus->change_timer, bl->id, data); + sc_timer_next(10000 + tick, status->change_timer, bl->id, data); } - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 0; } break; case SC_S_LIFEPOTION: case SC_L_LIFEPOTION: - if( sd && --(sce->val4) >= 0 ) - { + if( sd && --(sce->val4) >= 0 ) { // val1 < 0 = per max% | val1 > 0 = exact amount int hp = 0; if( st->hp < st->max_hp ) hp = (sce->val1 < 0) ? (int)(sd->status.max_hp * -1 * sce->val1 / 100.) : sce->val1 ; - iStatus->heal(bl, hp, 0, 2); - sc_timer_next((sce->val2 * 1000) + tick, iStatus->change_timer, bl->id, data); + status->heal(bl, hp, 0, 2); + sc_timer_next((sce->val2 * 1000) + tick, status->change_timer, bl->id, data); return 0; } break; case SC_CASH_BOSS_ALARM: - if( sd && --(sce->val4) >= 0 ) - { - struct mob_data *boss_md = iMap->id2boss(sce->val1); - if( boss_md && sd->bl.m == boss_md->bl.m ) - { + if( sd && --(sce->val4) >= 0 ) { + struct mob_data *boss_md = map->id2boss(sce->val1); + if( boss_md && sd->bl.m == boss_md->bl.m ) { clif->bossmapinfo(sd->fd, boss_md, 1); // Update X - Y on minimap if (boss_md->bl.prev != NULL) { - sc_timer_next(5000 + tick, iStatus->change_timer, bl->id, data); + sc_timer_next(5000 + tick, status->change_timer, bl->id, data); return 0; } } @@ -10223,34 +10202,32 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) { s=10; break; } - if( s != 0 && sce->val3 % s == 0 ) - { + if( s != 0 && sce->val3 % s == 0 ) { if (sc->data[SC_LONGING]) sp*= 3; - if (!iStatus->charge(bl, 0, sp)) + if (!status->charge(bl, 0, sp)) break; } - sc_timer_next(1000+tick, iStatus->change_timer, bl->id, data); + sc_timer_next(1000+tick, status->change_timer, bl->id, data); return 0; } break; case SC_BERSERK: // 5% every 10 seconds [DracoRPG] - if( --( sce->val3 ) > 0 && iStatus->charge(bl, sce->val2, 0) && st->hp > 100 ) - { - sc_timer_next(sce->val4+tick, iStatus->change_timer, bl->id, data); + if( --( sce->val3 ) > 0 && status->charge(bl, sce->val2, 0) && st->hp > 100 ) { + sc_timer_next(sce->val4+tick, status->change_timer, bl->id, data); return 0; } break; case SC_NOCHAT: - if(sd){ + if(sd) { sd->status.manner++; clif->changestatus(sd,SP_MANNER,sd->status.manner); clif->updatestatus(sd,SP_MANNER); - if (sd->status.manner < 0) - { //Every 60 seconds your manner goes up by 1 until it gets back to 0. - sc_timer_next(60000+tick, iStatus->change_timer, bl->id, data); + if (sd->status.manner < 0) { + //Every 60 seconds your manner goes up by 1 until it gets back to 0. + sc_timer_next(60000+tick, status->change_timer, bl->id, data); return 0; } } @@ -10264,7 +10241,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) { // clif->message(bl, counter); //} if((sce->val4 -= 500) > 0) { - sc_timer_next(500 + tick, iStatus->change_timer, bl->id, data); + sc_timer_next(500 + tick, status->change_timer, bl->id, data); return 0; } break; @@ -10272,59 +10249,56 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) { case SC_MARIONETTE_MASTER: case SC_MARIONETTE: { - struct block_list *pbl = iMap->id2bl(sce->val1); - if( pbl && check_distance_bl(bl, pbl, 7) ) - { - sc_timer_next(1000 + tick, iStatus->change_timer, bl->id, data); + struct block_list *pbl = map->id2bl(sce->val1); + if( pbl && check_distance_bl(bl, pbl, 7) ) { + sc_timer_next(1000 + tick, status->change_timer, bl->id, data); return 0; } } break; case SC_GOSPEL: - if(sce->val4 == BCT_SELF && --(sce->val2) > 0) - { + if(sce->val4 == BCT_SELF && --(sce->val2) > 0) { int hp, sp; hp = (sce->val1 > 5) ? 45 : 30; sp = (sce->val1 > 5) ? 35 : 20; - if(!iStatus->charge(bl, hp, sp)) + if(!status->charge(bl, hp, sp)) break; - sc_timer_next(10000+tick, iStatus->change_timer, bl->id, data); + sc_timer_next(10000+tick, status->change_timer, bl->id, data); return 0; } break; case SC_JAILED: - if(sce->val1 == INT_MAX || --(sce->val1) > 0) - { - sc_timer_next(60000+tick, iStatus->change_timer, bl->id,data); + if(sce->val1 == INT_MAX || --(sce->val1) > 0) { + sc_timer_next(60000+tick, status->change_timer, bl->id,data); return 0; } break; case SC_BLIND: - if(sc->data[SC_FOGWALL]) - { //Blind lasts forever while you are standing on the fog. - sc_timer_next(5000+tick, iStatus->change_timer, bl->id, data); + if(sc->data[SC_FOGWALL]) { + //Blind lasts forever while you are standing on the fog. + sc_timer_next(5000+tick, status->change_timer, bl->id, data); return 0; } break; case SC_ABUNDANCE: if(--(sce->val4) > 0) { - iStatus->heal(bl,0,60,0); - sc_timer_next(10000+tick, iStatus->change_timer, bl->id, data); + status->heal(bl,0,60,0); + sc_timer_next(10000+tick, status->change_timer, bl->id, data); } break; case SC_PYREXIA: if( --(sce->val4) > 0 ) { - iMap->freeblock_lock(); + map->freeblock_lock(); clif->damage(bl,bl,tick,status_get_amotion(bl),status_get_dmotion(bl)+500,100,0,0,0); status_fix_damage(NULL,bl,100,0); if( sc->data[type] ) { - sc_timer_next(3000+tick,iStatus->change_timer,bl->id,data); + sc_timer_next(3000+tick,status->change_timer,bl->id,data); } - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 0; } break; @@ -10334,12 +10308,12 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) { int damage = st->max_hp/100; // {Target VIT x (New Poison Research Skill Level - 3)} + (Target HP/100) damage += st->vit * (sce->val1 - 3); unit->skillcastcancel(bl,2); - iMap->freeblock_lock(); - iStatus->damage(bl, bl, damage, 0, clif->damage(bl,bl,tick,status_get_amotion(bl),status_get_dmotion(bl)+500,damage,1,0,0), 1); + map->freeblock_lock(); + status->damage(bl, bl, damage, 0, clif->damage(bl,bl,tick,status_get_amotion(bl),status_get_dmotion(bl)+500,damage,1,0,0), 1); if( sc->data[type] ) { - sc_timer_next(1000 + tick, iStatus->change_timer, bl->id, data ); + sc_timer_next(1000 + tick, status->change_timer, bl->id, data ); } - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 0; } break; @@ -10352,10 +10326,10 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) { damage = st->hp - 1; // Cannot Kill if( damage > 0 ) { // 3% Damage each 4 seconds - iMap->freeblock_lock(); + map->freeblock_lock(); status_zap(bl,damage,0); flag = !sc->data[type]; // Killed? Should not - iMap->freeblock_unlock(); + map->freeblock_unlock(); } if( !flag ) { // Random Skill Cast @@ -10365,7 +10339,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) { unit->skillcastcancel(bl,1); do { i = rnd() % MAX_SKILL_MAGICMUSHROOM_DB; - mushroom_skill_id = skill_magicmushroom_db[i].skill_id; + mushroom_skill_id = skill->magicmushroom_db[i].skill_id; } while( mushroom_skill_id == 0 ); @@ -10383,49 +10357,47 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) { } clif->emotion(bl,E_HEH); - sc_timer_next(4000+tick,iStatus->change_timer,bl->id,data); + sc_timer_next(4000+tick,status->change_timer,bl->id,data); } return 0; } break; case SC_TOXIN: - if( --(sce->val4) > 0 ) - { //Damage is every 10 seconds including 3%sp drain. - iMap->freeblock_lock(); + if( --(sce->val4) > 0 ) { + //Damage is every 10 seconds including 3%sp drain. + map->freeblock_lock(); clif->damage(bl,bl,tick,status_get_amotion(bl),1,1,0,0,0); - iStatus->damage(NULL, bl, 1, st->max_sp * 3 / 100, 0, 0); //cancel dmg only if cancelable + status->damage(NULL, bl, 1, st->max_sp * 3 / 100, 0, 0); //cancel dmg only if cancelable if( sc->data[type] ) { - sc_timer_next(10000 + tick, iStatus->change_timer, bl->id, data ); + sc_timer_next(10000 + tick, status->change_timer, bl->id, data ); } - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 0; } break; case SC_OBLIVIONCURSE: - if( --(sce->val4) > 0 ) - { + if( --(sce->val4) > 0 ) { clif->emotion(bl,E_WHAT); - sc_timer_next(3000 + tick, iStatus->change_timer, bl->id, data ); + sc_timer_next(3000 + tick, status->change_timer, bl->id, data ); return 0; } break; case SC_WEAPONBLOCKING: - if( --(sce->val4) > 0 ) - { - if( !iStatus->charge(bl,0,3) ) + if( --(sce->val4) > 0 ) { + if( !status->charge(bl,0,3) ) break; - sc_timer_next(3000+tick,iStatus->change_timer,bl->id,data); + sc_timer_next(3000+tick,status->change_timer,bl->id,data); return 0; } break; case SC_CLOAKINGEXCEED: - if(!iStatus->charge(bl,0,10-sce->val1)) + if(!status->charge(bl,0,10-sce->val1)) break; - sc_timer_next(1000 + tick, iStatus->change_timer, bl->id, data); + sc_timer_next(1000 + tick, status->change_timer, bl->id, data); return 0; case SC_RENOVATIO: @@ -10433,36 +10405,34 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) { int heal = st->max_hp * 3 / 100; if( sc && sc->data[SC_AKAITSUKI] && heal ) heal = ~heal + 1; - iStatus->heal(bl, heal, 0, 2); - sc_timer_next(5000 + tick, iStatus->change_timer, bl->id, data); + status->heal(bl, heal, 0, 2); + sc_timer_next(5000 + tick, status->change_timer, bl->id, data); return 0; } break; case SC_BURNING: - if( --(sce->val4) > 0 ) - { - struct block_list *src = iMap->id2bl(sce->val3); + if( --(sce->val4) > 0 ) { + struct block_list *src = map->id2bl(sce->val3); int damage = 1000 + 3 * status_get_max_hp(bl) / 100; // Deals fixed (1000 + 3%*MaxHP) - iMap->freeblock_lock(); + map->freeblock_lock(); clif->damage(bl,bl,tick,0,0,damage,1,9,0); //damage is like endure effect with no walk delay - iStatus->damage(src, bl, damage, 0, 0, 1); + status->damage(src, bl, damage, 0, 0, 1); if( sc->data[type]){ // Target still lives. [LimitLine] - sc_timer_next(3000 + tick, iStatus->change_timer, bl->id, data); + sc_timer_next(3000 + tick, status->change_timer, bl->id, data); } - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 0; } break; case SC_FEAR: - if( --(sce->val4) > 0 ) - { + if( --(sce->val4) > 0 ) { if( sce->val2 > 0 ) sce->val2--; - sc_timer_next(1000 + tick, iStatus->change_timer, bl->id, data); + sc_timer_next(1000 + tick, status->change_timer, bl->id, data); return 0; } break; @@ -10472,105 +10442,101 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) { case SC_SUMMON3: case SC_SUMMON4: case SC_SUMMON5: - if( --(sce->val4) > 0 ) - { - if( !iStatus->charge(bl, 0, 1) ) + if( --(sce->val4) > 0 ) { + if( !status->charge(bl, 0, 1) ) break; - sc_timer_next(1000 + tick, iStatus->change_timer, bl->id, data); + sc_timer_next(1000 + tick, status->change_timer, bl->id, data); return 0; } break; case SC_READING_SB: - if( !iStatus->charge(bl, 0, sce->val2) ){ + if( !status->charge(bl, 0, sce->val2) ) { int i; for(i = SC_SPELLBOOK1; i <= SC_SPELLBOOK7; i++) // Also remove stored spell as well. status_change_end(bl, (sc_type)i, INVALID_TIMER); break; } - sc_timer_next(5000 + tick, iStatus->change_timer, bl->id, data); + sc_timer_next(5000 + tick, status->change_timer, bl->id, data); return 0; case SC_ELECTRICSHOCKER: if( --(sce->val4) > 0 ) { - iStatus->charge(bl, 0, st->max_sp / 100 * sce->val1 ); - sc_timer_next(1000 + tick, iStatus->change_timer, bl->id, data); + status->charge(bl, 0, st->max_sp / 100 * sce->val1 ); + sc_timer_next(1000 + tick, status->change_timer, bl->id, data); return 0; } break; case SC_CAMOUFLAGE: - if(--(sce->val4) > 0){ - iStatus->charge(bl,0,7 - sce->val1); - sc_timer_next(1000 + tick, iStatus->change_timer, bl->id, data); + if(--(sce->val4) > 0) { + status->charge(bl,0,7 - sce->val1); + sc_timer_next(1000 + tick, status->change_timer, bl->id, data); return 0; } break; case SC__REPRODUCE: - if(!iStatus->charge(bl, 0, 1)) + if(!status->charge(bl, 0, 1)) break; - sc_timer_next(1000+tick, iStatus->change_timer, bl->id, data); + sc_timer_next(1000+tick, status->change_timer, bl->id, data); return 0; case SC__SHADOWFORM: - if( --(sce->val4) > 0 ) - { - if( !iStatus->charge(bl, 0, sce->val1 - (sce->val1 - 1)) ) + if( --(sce->val4) > 0 ) { + if( !status->charge(bl, 0, sce->val1 - (sce->val1 - 1)) ) break; - sc_timer_next(1000 + tick, iStatus->change_timer, bl->id, data); + sc_timer_next(1000 + tick, status->change_timer, bl->id, data); return 0; } break; case SC__INVISIBILITY: if( --(sce->val4) > 0 ) { - if( !iStatus->charge(bl, 0, (st->sp * 6 - sce->val1) / 100) )// 6% - skill_lv. + if( !status->charge(bl, 0, (st->sp * 6 - sce->val1) / 100) )// 6% - skill_lv. break; - sc_timer_next(1000 + tick, iStatus->change_timer, bl->id, data); + sc_timer_next(1000 + tick, status->change_timer, bl->id, data); return 0; } break; case SC_STRIKING: - if( --(sce->val4) > 0 ) - { - if( !iStatus->charge(bl,0, sce->val1 ) ) + if( --(sce->val4) > 0 ) { + if( !status->charge(bl,0, sce->val1 ) ) break; - sc_timer_next(1000 + tick, iStatus->change_timer, bl->id, data); + sc_timer_next(1000 + tick, status->change_timer, bl->id, data); return 0; } break; case SC_VACUUM_EXTREME: - if( --(sce->val4) > 0 ){ - sc_timer_next(100 + tick, iStatus->change_timer, bl->id, data); + if( --(sce->val4) > 0 ) { + sc_timer_next(100 + tick, status->change_timer, bl->id, data); return 0; } break; case SC_BLOOD_SUCKER: if( --(sce->val4) > 0 ) { - struct block_list *src = iMap->id2bl(sce->val2); + struct block_list *src = map->id2bl(sce->val2); int damage; - if( !src || (src && (iStatus->isdead(src) || src->m != bl->m || distance_bl(src, bl) >= 12)) ) + if( !src || (src && (status->isdead(src) || src->m != bl->m || distance_bl(src, bl) >= 12)) ) break; - iMap->freeblock_lock(); + map->freeblock_lock(); damage = sce->val3; - iStatus->damage(src, bl, damage, 0, clif->damage(bl,bl,tick,st->amotion,st->dmotion+200,damage,1,0,0), 1); + status->damage(src, bl, damage, 0, clif->damage(bl,bl,tick,st->amotion,st->dmotion+200,damage,1,0,0), 1); unit->skillcastcancel(bl,1); if ( sc->data[type] ) { - sc_timer_next(1000 + tick, iStatus->change_timer, bl->id, data); + sc_timer_next(1000 + tick, status->change_timer, bl->id, data); } - iMap->freeblock_unlock(); - iStatus->heal(src, damage*(5 + 5 * sce->val1)/100, 0, 0); // 5 + 5% per level + map->freeblock_unlock(); + status->heal(src, damage*(5 + 5 * sce->val1)/100, 0, 0); // 5 + 5% per level return 0; } break; case SC_SIREN: - if( --(sce->val4) > 0 ) - { + if( --(sce->val4) > 0 ) { clif->emotion(bl,E_LV); - sc_timer_next(2000 + tick, iStatus->change_timer, bl->id, data); + sc_timer_next(2000 + tick, status->change_timer, bl->id, data); return 0; } break; @@ -10578,28 +10544,26 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) { case SC_DEEP_SLEEP: if( --(sce->val4) > 0 ) { // Recovers 1% HP/SP every 2 seconds. - iStatus->heal(bl, st->max_hp / 100, st->max_sp / 100, 2); - sc_timer_next(2000 + tick, iStatus->change_timer, bl->id, data); + status->heal(bl, st->max_hp / 100, st->max_sp / 100, 2); + sc_timer_next(2000 + tick, status->change_timer, bl->id, data); return 0; } break; case SC_SIRCLEOFNATURE: - if( --(sce->val4) > 0 ) - { - if( !iStatus->charge(bl,0,sce->val2) ) + if( --(sce->val4) > 0 ) { + if( !status->charge(bl,0,sce->val2) ) break; - iStatus->heal(bl, sce->val3, 0, 1); - sc_timer_next(1000 + tick, iStatus->change_timer, bl->id, data); + status->heal(bl, sce->val3, 0, 1); + sc_timer_next(1000 + tick, status->change_timer, bl->id, data); return 0; } break; case SC_SONG_OF_MANA: - if( --(sce->val4) > 0 ) - { - iStatus->heal(bl,0,sce->val3,3); - sc_timer_next(3000 + tick, iStatus->change_timer, bl->id, data); + if( --(sce->val4) > 0 ) { + status->heal(bl,0,sce->val3,3); + sc_timer_next(3000 + tick, status->change_timer, bl->id, data); return 0; } break; @@ -10610,9 +10574,9 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) { if( --(sce->val3) > 0 ) { int hp = st->hp / 100; int sp = st->sp / 100; - if( !iStatus->charge(bl, hp, sp) ) + if( !status->charge(bl, hp, sp) ) break; - sc_timer_next(sce->val4+tick, iStatus->change_timer, bl->id, data); + sc_timer_next(sce->val4+tick, status->change_timer, bl->id, data); return 0; } break; @@ -10621,39 +10585,38 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) { if( --(sce->val4) > 0 ) { // Drains 2% of HP and 1% of SP every seconds. if( bl->type != BL_MOB) // doesn't work on mobs - iStatus->charge(bl, st->max_hp * 2 / 100, st->max_sp / 100); - sc_timer_next(1000 + tick, iStatus->change_timer, bl->id, data); + status->charge(bl, st->max_hp * 2 / 100, st->max_sp / 100); + sc_timer_next(1000 + tick, status->change_timer, bl->id, data); return 0; } break; case SC_FORCEOFVANGUARD: - if( !iStatus->charge(bl,0,20) ) + if( !status->charge(bl,0,20) ) break; - sc_timer_next(6000 + tick, iStatus->change_timer, bl->id, data); + sc_timer_next(6000 + tick, status->change_timer, bl->id, data); return 0; case SC_BANDING: - if( iStatus->charge(bl, 0, 7 - sce->val1) ) - { + if( status->charge(bl, 0, 7 - sce->val1) ) { if( sd ) pc->banding(sd, sce->val1); - sc_timer_next(5000 + tick, iStatus->change_timer, bl->id, data); + sc_timer_next(5000 + tick, status->change_timer, bl->id, data); return 0; } break; case SC_LG_REFLECTDAMAGE: if( --(sce->val4) > 0 ) { - if( !iStatus->charge(bl,0,sce->val3) ) + if( !status->charge(bl,0,sce->val3) ) break; - sc_timer_next(10000 + tick, iStatus->change_timer, bl->id, data); + sc_timer_next(10000 + tick, status->change_timer, bl->id, data); return 0; } break; case SC_OVERHEAT_LIMITPOINT: if( --(sce->val1) > 0 ) { // Cooling - sc_timer_next(30000 + tick, iStatus->change_timer, bl->id, data); + sc_timer_next(30000 + tick, status->change_timer, bl->id, data); } break; @@ -10661,12 +10624,12 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) { { int damage = st->max_hp / 100; // Suggestion 1% each second if( damage >= st->hp ) damage = st->hp - 1; // Do not kill, just keep you with 1 hp minimum - iMap->freeblock_lock(); + map->freeblock_lock(); status_fix_damage(NULL,bl,damage,clif->damage(bl,bl,tick,0,0,damage,0,0,0)); if( sc->data[type] ) { - sc_timer_next(1000 + tick, iStatus->change_timer, bl->id, data); + sc_timer_next(1000 + tick, status->change_timer, bl->id, data); } - iMap->freeblock_unlock(); + map->freeblock_unlock(); } break; @@ -10674,19 +10637,16 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) { { if( --(sce->val3) <= 0 ) break; // Time out - if( sce->val2 == bl->id ) - { - if( !iStatus->charge(bl,0,14 + (3 * sce->val1)) ) + if( sce->val2 == bl->id ) { + if( !status->charge(bl,0,14 + (3 * sce->val1)) ) break; // No more SP status should end, and in the next second will end for the other affected players - } - else - { - struct block_list *src = iMap->id2bl(sce->val2); + } else { + struct block_list *src = map->id2bl(sce->val2); struct status_change *ssc; - if( !src || (ssc = iStatus->get_sc(src)) == NULL || !ssc->data[SC_MAGNETICFIELD] ) + if( !src || (ssc = status->get_sc(src)) == NULL || !ssc->data[SC_MAGNETICFIELD] ) break; // Source no more under Magnetic Field } - sc_timer_next(1000 + tick, iStatus->change_timer, bl->id, data); + sc_timer_next(1000 + tick, status->change_timer, bl->id, data); } break; @@ -10695,19 +10655,18 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) { int hp = st->max_hp * (7-sce->val1) / 100; int sp = st->max_sp * (9-sce->val1) / 100; - if( !iStatus->charge(bl,hp,sp) ) break; + if( !status->charge(bl,hp,sp) ) break; - sc_timer_next(1000+tick,iStatus->change_timer,bl->id, data); + sc_timer_next(1000+tick,status->change_timer,bl->id, data); return 0; } break; case SC_RAISINGDRAGON: // 1% every 5 seconds [Jobbie] - if( --(sce->val3)>0 && iStatus->charge(bl, sce->val2, 0) ) - { + if( --(sce->val3)>0 && status->charge(bl, sce->val2, 0) ) { if( !sc->data[type] ) return 0; - sc_timer_next(5000 + tick, iStatus->change_timer, bl->id, data); + sc_timer_next(5000 + tick, status->change_timer, bl->id, data); return 0; } break; @@ -10720,27 +10679,26 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) { case SC_WIND_STEP: case SC_STONE_SHIELD: case SC_SOLID_SKIN: - if( !iStatus->charge(bl,0,sce->val2) ){ + if( !status->charge(bl,0,sce->val2) ){ struct block_list *s_bl = battle->get_master(bl); if( s_bl ) status_change_end(s_bl,type+1,INVALID_TIMER); status_change_end(bl,type,INVALID_TIMER); break; } - sc_timer_next(2000 + tick, iStatus->change_timer, bl->id, data); + sc_timer_next(2000 + tick, status->change_timer, bl->id, data); return 0; case SC_STOMACHACHE: - if( --(sce->val4) > 0 ){ - iStatus->charge(bl,0,sce->val2); // Reduce 8 every 10 seconds. - if( sd && !pc_issit(sd) ) // Force to sit every 10 seconds. - { + if( --(sce->val4) > 0 ) { + status->charge(bl,0,sce->val2); // Reduce 8 every 10 seconds. + if( sd && !pc_issit(sd) ) { // Force to sit every 10 seconds. pc_stop_walking(sd,1|4); pc_stop_attack(sd); pc_setsit(sd); clif->sitting(bl); } - sc_timer_next(10000 + tick, iStatus->change_timer, bl->id, data); + sc_timer_next(10000 + tick, status->change_timer, bl->id, data); return 0; } break; @@ -10749,51 +10707,48 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) { case SC_SOULCOLD: case SC_HAWKEYES: /* they only end by status_change_end */ - sc_timer_next(600000 + tick, iStatus->change_timer, bl->id, data); + sc_timer_next(600000 + tick, status->change_timer, bl->id, data); return 0; case SC_MEIKYOUSISUI: if( --(sce->val4) > 0 ) { - iStatus->heal(bl, st->max_hp * (sce->val1+1) / 100, st->max_sp * sce->val1 / 100, 0); - sc_timer_next(1000 + tick, iStatus->change_timer, bl->id, data); + status->heal(bl, st->max_hp * (sce->val1+1) / 100, st->max_sp * sce->val1 / 100, 0); + sc_timer_next(1000 + tick, status->change_timer, bl->id, data); return 0; } break; case SC_IZAYOI: case SC_KAGEMUSYA: - if( --(sce->val2) > 0 ){ - if(!iStatus->charge(bl, 0, 1)) break; - sc_timer_next(1000+tick, iStatus->change_timer, bl->id, data); + if( --(sce->val2) > 0 ) { + if(!status->charge(bl, 0, 1)) break; + sc_timer_next(1000+tick, status->change_timer, bl->id, data); return 0; } break; case SC_ANGRIFFS_MODUS: if(--(sce->val4) > 0) { //drain hp/sp - if( !iStatus->charge(bl,100,20) ) break; - sc_timer_next(1000+tick,iStatus->change_timer,bl->id, data); + if( !status->charge(bl,100,20) ) break; + sc_timer_next(1000+tick,status->change_timer,bl->id, data); return 0; } break; case SC_FULL_THROTTLE: - if( --(sce->val4) > 0 ) - { + if( --(sce->val4) > 0 ) { status_percent_damage(bl, bl, sce->val2, 0, false); - sc_timer_next(1000 + tick, iStatus->change_timer, bl->id, data); + sc_timer_next(1000 + tick, status->change_timer, bl->id, data); return 0; } break; case SC_KINGS_GRACE: - if( --(sce->val4) > 0 ) - { + if( --(sce->val4) > 0 ) { status_percent_heal(bl, sce->val2, 0); - sc_timer_next(1000 + tick, iStatus->change_timer, bl->id, data); + sc_timer_next(1000 + tick, status->change_timer, bl->id, data); return 0; } break; case SC_FRIGG_SONG: - if( --(sce->val4) > 0 ) - { - iStatus->heal(bl, sce->val3, 0, 0); - sc_timer_next(10000 + tick, iStatus->change_timer, bl->id, data); + if( --(sce->val4) > 0 ) { + status->heal(bl, sce->val3, 0, 0); + sc_timer_next(10000 + tick, status->change_timer, bl->id, data); return 0; } break; @@ -10807,8 +10762,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) { /*========================================== * Foreach iteration of repetitive status *------------------------------------------*/ -int status_change_timer_sub(struct block_list* bl, va_list ap) -{ +int status_change_timer_sub(struct block_list* bl, va_list ap) { struct status_change* tsc; struct block_list* src = va_arg(ap,struct block_list*); @@ -10816,10 +10770,10 @@ int status_change_timer_sub(struct block_list* bl, va_list ap) enum sc_type type = (sc_type)va_arg(ap,int); //gcc: enum args get promoted to int unsigned int tick = va_arg(ap,unsigned int); - if (iStatus->isdead(bl)) + if (status->isdead(bl)) return 0; - tsc = iStatus->get_sc(bl); + tsc = status->get_sc(bl); switch( type ) { case SC_SIGHT: /* Reveal hidden ennemy on 3*3 range */ @@ -10850,11 +10804,12 @@ int status_change_timer_sub(struct block_list* bl, va_list ap) status_change_end(bl, SC__SHADOWFORM, INVALID_TIMER); break; case SC_WZ_SIGHTBLASTER: - if (battle->check_target( src, bl, BCT_ENEMY ) > 0 && - iStatus->check_skilluse(src, bl, WZ_SIGHTBLASTER, 2)) - { + if (battle->check_target( src, bl, BCT_ENEMY ) > 0 + && status->check_skilluse(src, bl, WZ_SIGHTBLASTER, 2) + ) { if (sce && !(bl->type&BL_SKILL) //The hit is not counted if it's against a trap - && skill->attack(BF_MAGIC,src,src,bl,WZ_SIGHTBLASTER,1,tick,0)){ + && skill->attack(BF_MAGIC,src,src,bl,WZ_SIGHTBLASTER,1,tick,0) + ){ sce->val2 = 0; //This signals it to end. } } @@ -10876,13 +10831,13 @@ int status_change_timer_sub(struct block_list* bl, va_list ap) return 0; } -int status_get_total_def(struct block_list *src){ return iStatus->get_status_data(src)->def2 + (short)iStatus->get_def(src); } -int status_get_total_mdef(struct block_list *src){ return iStatus->get_status_data(src)->mdef2 + (short)status_get_mdef(src); } +int status_get_total_def(struct block_list *src) { return status->get_status_data(src)->def2 + (short)status->get_def(src); } +int status_get_total_mdef(struct block_list *src) { return status->get_status_data(src)->mdef2 + (short)status_get_mdef(src); } #ifdef RENEWAL -int status_get_weapon_atk(struct block_list *bl, struct weapon_atk *watk, int flag){ +int status_get_weapon_atk(struct block_list *bl, struct weapon_atk *watk, int flag) { int min = 0, max = 0, dstr; float strdex_bonus, variance; - struct status_change *sc = iStatus->get_sc(bl); + struct status_change *sc = status->get_sc(bl); if ( bl->type == BL_PC && watk->atk ){ if ( flag&2 ) @@ -10938,22 +10893,19 @@ int status_get_matk(struct block_list *bl, int flag) { if( bl == NULL ) return 1; - st = iStatus->get_status_data(bl); - sc = iStatus->get_sc(bl); + st = status->get_status_data(bl); + sc = status->get_sc(bl); sd = BL_CAST(BL_PC, bl); if( flag == 2 ) // just get matk GETRANDMATK(st); -#ifndef RENEWAL - st->matk_min = status_base_matk_min(st) + (sd?sd->bonus.ematk:0); - st->matk_max = status_base_matk_max(st) + (sd?sd->bonus.ematk:0); -#else +#ifdef RENEWAL /** - * RE MATK Formula (from irowiki:http://irowiki.org/wiki/MATK) - * MATK = (sMATK + wMATK + eMATK) * Multiplicative Modifiers - **/ - st->matk_min = iStatus->base_matk(st, iStatus->get_lv(bl)); + * RE MATK Formula (from irowiki:http://irowiki.org/wiki/MATK) + * MATK = (sMATK + wMATK + eMATK) * Multiplicative Modifiers + **/ + st->matk_min = status->base_matk(st, status->get_lv(bl)); // Any +MATK you get from skills and cards, including cards in weapon, is added here. if( sd && sd->bonus.ematk > 0 && flag != 3 ) @@ -10964,16 +10916,19 @@ int status_get_matk(struct block_list *bl, int flag) { st->matk_max = st->matk_min; //This is the only portion in MATK that varies depending on the weapon level and refinement rate. - if( bl->type&BL_PC && (st->rhw.matk + st->lhw.matk) > 0 ){ + if( bl->type&BL_PC && (st->rhw.matk + st->lhw.matk) > 0 ) { int wMatk = st->rhw.matk + st->lhw.matk; // Left and right matk stacks int variance = wMatk * st->rhw.wlv / 10; // Only use right hand weapon level st->matk_min += wMatk - variance; st->matk_max += wMatk + variance; - }else if( bl->type&BL_MOB ){ - st->matk_min = st->matk_max = status_get_int(bl) + iStatus->get_lv(bl); + } else if( bl->type&BL_MOB ) { + st->matk_min = st->matk_max = status_get_int(bl) + status->get_lv(bl); st->matk_min += 70 * ((TBL_MOB*)bl)->status.rhw.atk2 / 100; st->matk_max += 130 * ((TBL_MOB*)bl)->status.rhw.atk2 / 100; } +#else // not RENEWAL + st->matk_min = status_base_matk_min(st) + (sd?sd->bonus.ematk:0); + st->matk_max = status_base_matk_max(st) + (sd?sd->bonus.ematk:0); #endif if (bl->type&BL_PC && sd->matk_rate != 100) { st->matk_max = st->matk_max * sd->matk_rate/100; @@ -11005,10 +10960,9 @@ int status_get_matk(struct block_list *bl, int flag) { * type&1 -> buffs, type&2 -> debuffs * type&4 -> especific debuffs(implemented with refresh) *------------------------------------------*/ -int status_change_clear_buffs (struct block_list* bl, int type) -{ +int status_change_clear_buffs (struct block_list* bl, int type) { int i; - struct status_change *sc= iStatus->get_sc(bl); + struct status_change *sc= status->get_sc(bl); if (!sc || !sc->count) return 0; @@ -11017,18 +10971,17 @@ int status_change_clear_buffs (struct block_list* bl, int type) for (i = SC_COMMON_MIN; i <= SC_COMMON_MAX; i++) status_change_end(bl, (sc_type)i, INVALID_TIMER); - for( i = SC_COMMON_MAX+1; i < SC_MAX; i++ ) - { - if( !sc->data[i] || !iStatus->get_sc_type(i) ) + for( i = SC_COMMON_MAX+1; i < SC_MAX; i++ ) { + if( !sc->data[i] || !status->get_sc_type(i) ) continue; - if( type&3 && !(iStatus->get_sc_type(i)&SC_BUFF) && !(iStatus->get_sc_type(i)&SC_DEBUFF) ) + if( type&3 && !(status->get_sc_type(i)&SC_BUFF) && !(status->get_sc_type(i)&SC_DEBUFF) ) continue; - if( type < 3 ){ - if( type&1 && !(iStatus->get_sc_type(i)&SC_BUFF) ) + if( type < 3 ) { + if( type&1 && !(status->get_sc_type(i)&SC_BUFF) ) continue; - if( type&2 && !(iStatus->get_sc_type(i)&SC_DEBUFF) ) + if( type&2 && !(status->get_sc_type(i)&SC_DEBUFF) ) continue; } switch (i) { @@ -11066,7 +11019,7 @@ int status_change_clear_buffs (struct block_list* bl, int type) int status_change_spread( struct block_list *src, struct block_list *bl ) { int i, flag = 0; - struct status_change *sc = iStatus->get_sc(src); + struct status_change *sc = status->get_sc(src); unsigned int tick; struct status_change_data data; @@ -11107,7 +11060,7 @@ int status_change_spread( struct block_list *src, struct block_list *bl ) { case SC_PARALYSE: if( sc->data[i]->timer != INVALID_TIMER ) { const struct TimerData *td = timer->get(sc->data[i]->timer); - if (td == NULL || td->func != iStatus->change_timer || DIFF_TICK(td->tick,tick) < 0) + if (td == NULL || td->func != status->change_timer || DIFF_TICK(td->tick,tick) < 0) continue; data.tick = DIFF_TICK(td->tick,tick); } else @@ -11138,14 +11091,13 @@ int status_change_spread( struct block_list *src, struct block_list *bl ) { break; default: continue; - break; } - if( i ){ + if( i ) { data.val1 = sc->data[i]->val1; data.val2 = sc->data[i]->val2; data.val3 = sc->data[i]->val3; data.val4 = sc->data[i]->val4; - iStatus->change_start(bl,(sc_type)i,10000,data.val1,data.val2,data.val3,data.val4,data.tick,1|2|8); + status->change_start(bl,(sc_type)i,10000,data.val1,data.val2,data.val3,data.val4,data.tick,1|2|8); flag = 1; } } @@ -11165,10 +11117,10 @@ static int status_natural_heal(struct block_list* bl, va_list args) { struct map_session_data *sd; int val,rate,bonus = 0,flag; - regen = iStatus->get_regen_data(bl); + regen = status->get_regen_data(bl); if (!regen) return 0; - st = iStatus->get_status_data(bl); - sc = iStatus->get_sc(bl); + st = status->get_status_data(bl); + sc = status->get_sc(bl); if (sc && !sc->count) sc = NULL; sd = BL_CAST(BL_PC,bl); @@ -11179,10 +11131,11 @@ static int status_natural_heal(struct block_list* bl, va_list args) { if (flag&RGN_SP && (st->sp >= st->max_sp || regen->state.block&2)) flag&=~(RGN_SP|RGN_SSP); - if (flag && ( - iStatus->isdead(bl) || - (sc && (sc->option&(OPTION_HIDE|OPTION_CLOAK|OPTION_CHASEWALK) || sc->data[SC__INVISIBILITY])) - )) + if (flag + && (status->isdead(bl) + || (sc && (sc->option&(OPTION_HIDE|OPTION_CLOAK|OPTION_CHASEWALK) || sc->data[SC__INVISIBILITY])) + ) + ) flag=0; if (sd) { @@ -11192,37 +11145,38 @@ static int status_natural_heal(struct block_list* bl, va_list args) { pc->regen(sd, natural_heal_diff_tick); } - if(flag&(RGN_SHP|RGN_SSP) && regen->ssregen && - (vd = iStatus->get_viewdata(bl)) && vd->dead_sit == 2) - { //Apply sitting regen bonus. + if (flag&(RGN_SHP|RGN_SSP) + && regen->ssregen + && (vd = status->get_viewdata(bl)) + && vd->dead_sit == 2 + ) { + //Apply sitting regen bonus. sregen = regen->ssregen; - if(flag&(RGN_SHP)) - { //Sitting HP regen + if(flag&(RGN_SHP)) { + //Sitting HP regen val = natural_heal_diff_tick * sregen->rate.hp; if (regen->state.overweight) val>>=1; //Half as fast when overweight. sregen->tick.hp += val; - while(sregen->tick.hp >= (unsigned int)battle_config.natural_heal_skill_interval) - { + while(sregen->tick.hp >= (unsigned int)battle_config.natural_heal_skill_interval) { sregen->tick.hp -= battle_config.natural_heal_skill_interval; - if(iStatus->heal(bl, sregen->hp, 0, 3) < sregen->hp) - { //Full + if(status->heal(bl, sregen->hp, 0, 3) < sregen->hp) { + //Full flag&=~(RGN_HP|RGN_SHP); break; } } } - if(flag&(RGN_SSP)) - { //Sitting SP regen + if(flag&(RGN_SSP)) { + //Sitting SP regen val = natural_heal_diff_tick * sregen->rate.sp; if (regen->state.overweight) val>>=1; //Half as fast when overweight. sregen->tick.sp += val; - while(sregen->tick.sp >= (unsigned int)battle_config.natural_heal_skill_interval) - { + while(sregen->tick.sp >= (unsigned int)battle_config.natural_heal_skill_interval) { sregen->tick.sp -= battle_config.natural_heal_skill_interval; - if(iStatus->heal(bl, 0, sregen->sp, 3) < sregen->sp) - { //Full + if(status->heal(bl, 0, sregen->sp, 3) < sregen->sp) { + //Full flag&=~(RGN_SP|RGN_SSP); break; } @@ -11235,8 +11189,7 @@ static int status_natural_heal(struct block_list* bl, va_list args) { ud = unit->bl2ud(bl); - if (flag&(RGN_HP|RGN_SHP|RGN_SSP) && ud && ud->walktimer != INVALID_TIMER) - { + if (flag&(RGN_HP|RGN_SHP|RGN_SSP) && ud && ud->walktimer != INVALID_TIMER) { flag&=~(RGN_SHP|RGN_SSP); if(!regen->state.walk) flag&=~RGN_HP; @@ -11245,9 +11198,8 @@ static int status_natural_heal(struct block_list* bl, va_list args) { if (!flag) return 0; - if (flag&(RGN_HP|RGN_SP)) - { - if(!vd) vd = iStatus->get_viewdata(bl); + if (flag&(RGN_HP|RGN_SP)) { + if(!vd) vd = status->get_viewdata(bl); if(vd && vd->dead_sit == 2) bonus++; if(regen->state.gc) @@ -11255,8 +11207,7 @@ static int status_natural_heal(struct block_list* bl, va_list args) { } //Natural Hp regen - if (flag&RGN_HP) - { + if (flag&RGN_HP) { rate = natural_heal_diff_tick*(regen->rate.hp+bonus); if (ud && ud->walktimer != INVALID_TIMER) rate/=2; @@ -11265,35 +11216,32 @@ static int status_natural_heal(struct block_list* bl, va_list args) { regen->tick.hp += rate; - if(regen->tick.hp >= (unsigned int)battle_config.natural_healhp_interval) - { + if(regen->tick.hp >= (unsigned int)battle_config.natural_healhp_interval) { val = 0; do { val += regen->hp; regen->tick.hp -= battle_config.natural_healhp_interval; } while(regen->tick.hp >= (unsigned int)battle_config.natural_healhp_interval); - if (iStatus->heal(bl, val, 0, 1) < val) + if (status->heal(bl, val, 0, 1) < val) flag&=~RGN_SHP; //full. } } //Natural SP regen - if(flag&RGN_SP) - { + if(flag&RGN_SP) { rate = natural_heal_diff_tick*(regen->rate.sp+bonus); // Homun SP regen fix (they should regen as if they were sitting (twice as fast) if(bl->type==BL_HOM) rate *=2; regen->tick.sp += rate; - if(regen->tick.sp >= (unsigned int)battle_config.natural_healsp_interval) - { + if(regen->tick.sp >= (unsigned int)battle_config.natural_healsp_interval) { val = 0; do { val += regen->sp; regen->tick.sp -= battle_config.natural_healsp_interval; } while(regen->tick.sp >= (unsigned int)battle_config.natural_healsp_interval); - if (iStatus->heal(bl, 0, val, 1) < val) + if (status->heal(bl, 0, val, 1) < val) flag&=~RGN_SSP; //full. } } @@ -11304,40 +11252,38 @@ static int status_natural_heal(struct block_list* bl, va_list args) { //Skill regen sregen = regen->sregen; - if(flag&RGN_SHP) - { //Skill HP regen + if(flag&RGN_SHP) { + //Skill HP regen sregen->tick.hp += natural_heal_diff_tick * sregen->rate.hp; - while(sregen->tick.hp >= (unsigned int)battle_config.natural_heal_skill_interval) - { + while(sregen->tick.hp >= (unsigned int)battle_config.natural_heal_skill_interval) { sregen->tick.hp -= battle_config.natural_heal_skill_interval; - if(iStatus->heal(bl, sregen->hp, 0, 3) < sregen->hp) + if(status->heal(bl, sregen->hp, 0, 3) < sregen->hp) break; //Full } } - if(flag&RGN_SSP) - { //Skill SP regen + if(flag&RGN_SSP) { + //Skill SP regen sregen->tick.sp += natural_heal_diff_tick * sregen->rate.sp; - while(sregen->tick.sp >= (unsigned int)battle_config.natural_heal_skill_interval) - { + while(sregen->tick.sp >= (unsigned int)battle_config.natural_heal_skill_interval) { val = sregen->sp; if (sd && sd->state.doridori) { val*=2; sd->state.doridori = 0; if ((rate = pc->checkskill(sd,TK_SPTIME))) - sc_start(bl,iStatus->skill2sc(TK_SPTIME), - 100,rate,skill->get_time(TK_SPTIME, rate)); - if ( - (sd->class_&MAPID_UPPERMASK) == MAPID_STAR_GLADIATOR && - rnd()%10000 < battle_config.sg_angel_skill_ratio - ) { //Angel of the Sun/Moon/Star - clif->feel_hate_reset(sd); - pc->resethate(sd); - pc->resetfeel(sd); + sc_start(bl,status->skill2sc(TK_SPTIME), + 100,rate,skill->get_time(TK_SPTIME, rate)); + if ((sd->class_&MAPID_UPPERMASK) == MAPID_STAR_GLADIATOR + &&rnd()%10000 < battle_config.sg_angel_skill_ratio + ) { + //Angel of the Sun/Moon/Star + clif->feel_hate_reset(sd); + pc->resethate(sd); + pc->resetfeel(sd); } } sregen->tick.sp -= battle_config.natural_heal_skill_interval; - if(iStatus->heal(bl, 0, val, 3) < val) + if(status->heal(bl, 0, val, 3) < val) break; //Full } } @@ -11345,10 +11291,9 @@ static int status_natural_heal(struct block_list* bl, va_list args) { } //Natural heal main timer. -static int status_natural_heal_timer(int tid, unsigned int tick, int id, intptr_t data) -{ +static int status_natural_heal_timer(int tid, unsigned int tick, int id, intptr_t data) { natural_heal_diff_tick = DIFF_TICK(tick,natural_heal_prev_tick); - iMap->map_foreachregen(status_natural_heal); + map->map_foreachregen(status_natural_heal); natural_heal_prev_tick = tick; return 0; } @@ -11533,14 +11478,14 @@ int status_readdb(void) #ifdef RENEWAL_ASPD - sv->readdb(iMap->db_path, "re/job_db1.txt", ',', 6+MAX_WEAPON_TYPE, 6+MAX_WEAPON_TYPE, -1, &status_readdb_job1); + sv->readdb(map->db_path, "re/job_db1.txt", ',', 6+MAX_WEAPON_TYPE, 6+MAX_WEAPON_TYPE, -1, &status_readdb_job1); #else - sv->readdb(iMap->db_path, "pre-re/job_db1.txt", ',', 5+MAX_WEAPON_TYPE, 5+MAX_WEAPON_TYPE, -1, &status_readdb_job1); + sv->readdb(map->db_path, "pre-re/job_db1.txt", ',', 5+MAX_WEAPON_TYPE, 5+MAX_WEAPON_TYPE, -1, &status_readdb_job1); #endif - sv->readdb(iMap->db_path, "job_db2.txt", ',', 1, 1+MAX_LEVEL, -1, &status_readdb_job2); - sv->readdb(iMap->db_path, "size_fix.txt", ',', MAX_WEAPON_TYPE, MAX_WEAPON_TYPE, ARRAYLENGTH(atkmods), &status_readdb_sizefix); - sv->readdb(iMap->db_path, DBPATH"refine_db.txt", ',', 4+MAX_REFINE, 4+MAX_REFINE, ARRAYLENGTH(refine_info), &status_readdb_refine); - sv->readdb(iMap->db_path, "sc_config.txt", ',', 2, 2, SC_MAX, &status_readdb_scconfig); + sv->readdb(map->db_path, "job_db2.txt", ',', 1, 1+MAX_LEVEL, -1, &status_readdb_job2); + sv->readdb(map->db_path, "size_fix.txt", ',', MAX_WEAPON_TYPE, MAX_WEAPON_TYPE, ARRAYLENGTH(atkmods), &status_readdb_sizefix); + sv->readdb(map->db_path, DBPATH"refine_db.txt", ',', 4+MAX_REFINE, 4+MAX_REFINE, ARRAYLENGTH(refine_info), &status_readdb_refine); + sv->readdb(map->db_path, "sc_config.txt", ',', 2, 2, SC_MAX, &status_readdb_scconfig); return 0; } @@ -11548,22 +11493,20 @@ int status_readdb(void) /*========================================== * Status db init and destroy. *------------------------------------------*/ -int do_init_status(void) -{ - timer->add_func_list(iStatus->change_timer,"status_change_timer"); +int do_init_status(void) { + timer->add_func_list(status->change_timer,"status_change_timer"); timer->add_func_list(kaahi_heal_timer,"kaahi_heal_timer"); timer->add_func_list(status_natural_heal_timer,"status_natural_heal_timer"); initChangeTables(); initDummyData(); - iStatus->readdb(); + status->readdb(); status_calc_sigma(); natural_heal_prev_tick = timer->gettick(); sc_data_ers = ers_new(sizeof(struct status_change_entry),"status.c::sc_data_ers",ERS_OPT_NONE); timer->add_interval(natural_heal_prev_tick + NATURAL_HEAL_INTERVAL, status_natural_heal_timer, 0, 0, NATURAL_HEAL_INTERVAL); return 0; } -void do_final_status(void) -{ +void do_final_status(void) { ers_destroy(sc_data_ers); } @@ -11573,100 +11516,100 @@ void do_final_status(void) * created by Susu *-------------------------------------*/ void status_defaults(void) { - iStatus = &iStatus_s; + status = &status_s; /* vars */ - iStatus->current_equip_item_index = 0; //Contains inventory index of an equipped item. To pass it into the EQUP_SCRIPT [Lupus] - iStatus->current_equip_card_id = 0; //To prevent card-stacking (from jA) [Skotlex] + status->current_equip_item_index = 0; //Contains inventory index of an equipped item. To pass it into the EQUP_SCRIPT [Lupus] + status->current_equip_card_id = 0; //To prevent card-stacking (from jA) [Skotlex] //we need it for new cards 15 Feb 2005, to check if the combo cards are insrerted into the CURRENT weapon only //to avoid cards exploits /* funcs */ - iStatus->get_refine_chance = status_get_refine_chance; + status->get_refine_chance = status_get_refine_chance; // for looking up associated data - iStatus->skill2sc = status_skill2sc; - iStatus->sc2skill = status_sc2skill; - iStatus->sc2scb_flag = status_sc2scb_flag; - iStatus->type2relevant_bl_types = status_type2relevant_bl_types; - iStatus->get_sc_type = status_get_sc_type; + status->skill2sc = status_skill2sc; + status->sc2skill = status_sc2skill; + status->sc2scb_flag = status_sc2scb_flag; + status->type2relevant_bl_types = status_type2relevant_bl_types; + status->get_sc_type = status_get_sc_type; - iStatus->damage = status_damage; + status->damage = status_damage; //Define for standard HP/SP skill-related cost triggers (mobs require no HP/SP to use skills) - iStatus->charge = status_charge; - iStatus->percent_change = status_percent_change; + status->charge = status_charge; + status->percent_change = status_percent_change; //Used to set the hp/sp of an object to an absolute value (can't kill) - iStatus->set_hp = status_set_hp; - iStatus->set_sp = status_set_sp; - iStatus->heal = status_heal; - iStatus->revive = status_revive; - - iStatus->get_regen_data = status_get_regen_data; - iStatus->get_status_data = status_get_status_data; - iStatus->get_base_status = status_get_base_status; - iStatus->get_name = status_get_name; - iStatus->get_class = status_get_class; - iStatus->get_lv = status_get_lv; - iStatus->get_def = status_get_def; - iStatus->get_speed = status_get_speed; - iStatus->calc_attack_element = status_calc_attack_element; - iStatus->get_party_id = status_get_party_id; - iStatus->get_guild_id = status_get_guild_id; - iStatus->get_emblem_id = status_get_emblem_id; - iStatus->get_mexp = status_get_mexp; - iStatus->get_race2 = status_get_race2; - - iStatus->get_viewdata = status_get_viewdata; - iStatus->set_viewdata = status_set_viewdata; - iStatus->change_init = status_change_init; - iStatus->get_sc = status_get_sc; - - iStatus->isdead = status_isdead; - iStatus->isimmune = status_isimmune; - - iStatus->get_sc_def = status_get_sc_def; - - iStatus->change_start = status_change_start; - iStatus->change_end_ = status_change_end_; - iStatus->kaahi_heal_timer = kaahi_heal_timer; - iStatus->change_timer = status_change_timer; - iStatus->change_timer_sub = status_change_timer_sub; - iStatus->change_clear = status_change_clear; - iStatus->change_clear_buffs = status_change_clear_buffs; - - iStatus->calc_bl_ = status_calc_bl_; - iStatus->calc_mob_ = status_calc_mob_; - iStatus->calc_pet_ = status_calc_pet_; - iStatus->calc_pc_ = status_calc_pc_; - iStatus->calc_homunculus_ = status_calc_homunculus_; - iStatus->calc_mercenary_ = status_calc_mercenary_; - iStatus->calc_elemental_ = status_calc_elemental_; - - iStatus->calc_misc = status_calc_misc; - iStatus->calc_regen = status_calc_regen; - iStatus->calc_regen_rate = status_calc_regen_rate; - - iStatus->check_skilluse = status_check_skilluse; // [Skotlex] - iStatus->check_visibility = status_check_visibility; //[Skotlex] - - iStatus->change_spread = status_change_spread; - - iStatus->calc_def = status_calc_def; - iStatus->calc_def2 = status_calc_def2; - iStatus->calc_mdef = status_calc_mdef; - iStatus->calc_mdef2 = status_calc_mdef2; - iStatus->calc_batk = status_calc_batk; + status->set_hp = status_set_hp; + status->set_sp = status_set_sp; + status->heal = status_heal; + status->revive = status_revive; + + status->get_regen_data = status_get_regen_data; + status->get_status_data = status_get_status_data; + status->get_base_status = status_get_base_status; + status->get_name = status_get_name; + status->get_class = status_get_class; + status->get_lv = status_get_lv; + status->get_def = status_get_def; + status->get_speed = status_get_speed; + status->calc_attack_element = status_calc_attack_element; + status->get_party_id = status_get_party_id; + status->get_guild_id = status_get_guild_id; + status->get_emblem_id = status_get_emblem_id; + status->get_mexp = status_get_mexp; + status->get_race2 = status_get_race2; + + status->get_viewdata = status_get_viewdata; + status->set_viewdata = status_set_viewdata; + status->change_init = status_change_init; + status->get_sc = status_get_sc; + + status->isdead = status_isdead; + status->isimmune = status_isimmune; + + status->get_sc_def = status_get_sc_def; + + status->change_start = status_change_start; + status->change_end_ = status_change_end_; + status->kaahi_heal_timer = kaahi_heal_timer; + status->change_timer = status_change_timer; + status->change_timer_sub = status_change_timer_sub; + status->change_clear = status_change_clear; + status->change_clear_buffs = status_change_clear_buffs; + + status->calc_bl_ = status_calc_bl_; + status->calc_mob_ = status_calc_mob_; + status->calc_pet_ = status_calc_pet_; + status->calc_pc_ = status_calc_pc_; + status->calc_homunculus_ = status_calc_homunculus_; + status->calc_mercenary_ = status_calc_mercenary_; + status->calc_elemental_ = status_calc_elemental_; + + status->calc_misc = status_calc_misc; + status->calc_regen = status_calc_regen; + status->calc_regen_rate = status_calc_regen_rate; + + status->check_skilluse = status_check_skilluse; // [Skotlex] + status->check_visibility = status_check_visibility; //[Skotlex] + + status->change_spread = status_change_spread; + + status->calc_def = status_calc_def; + status->calc_def2 = status_calc_def2; + status->calc_mdef = status_calc_mdef; + status->calc_mdef2 = status_calc_mdef2; + status->calc_batk = status_calc_batk; #ifdef RENEWAL - iStatus->base_matk = status_base_matk; - iStatus->get_weapon_atk = status_get_weapon_atk; + status->base_matk = status_base_matk; + status->get_weapon_atk = status_get_weapon_atk; #endif - iStatus->get_total_mdef = status_get_total_mdef; - iStatus->get_total_def = status_get_total_def; + status->get_total_mdef = status_get_total_mdef; + status->get_total_def = status_get_total_def; - iStatus->get_matk = status_get_matk; + status->get_matk = status_get_matk; - iStatus->readdb = status_readdb; - iStatus->do_init_status = do_init_status; - iStatus->do_final_status = do_final_status; + status->readdb = status_readdb; + status->init = do_init_status; + status->final = do_final_status; } diff --git a/src/map/status.h b/src/map/status.h index c6da44d83..16a9be081 100644 --- a/src/map/status.h +++ b/src/map/status.h @@ -1718,67 +1718,67 @@ struct status_change { //Define for standard HP damage attacks. -#define status_fix_damage(src, target, hp, walkdelay) iStatus->damage(src, target, hp, 0, walkdelay, 0) +#define status_fix_damage(src, target, hp, walkdelay) status->damage(src, target, hp, 0, walkdelay, 0) //Define for standard HP/SP damage triggers. -#define status_zap(bl, hp, sp) iStatus->damage(NULL, bl, hp, sp, 0, 1) -//Easier handling of iStatus->percent_change -#define status_percent_heal(bl, hp_rate, sp_rate) iStatus->percent_change(NULL, bl, -(hp_rate), -(sp_rate), 0) -#define status_percent_damage(src, target, hp_rate, sp_rate, kill) iStatus->percent_change(src, target, hp_rate, sp_rate, (kill)?1:2) +#define status_zap(bl, hp, sp) status->damage(NULL, bl, hp, sp, 0, 1) +//Easier handling of status->percent_change +#define status_percent_heal(bl, hp_rate, sp_rate) status->percent_change(NULL, bl, -(hp_rate), -(sp_rate), 0) +#define status_percent_damage(src, target, hp_rate, sp_rate, kill) status->percent_change(src, target, hp_rate, sp_rate, (kill)?1:2) //Instant kill with no drops/exp/etc #define status_kill(bl) status_percent_damage(NULL, bl, 100, 0, true) -#define status_get_range(bl) iStatus->get_status_data(bl)->rhw.range -#define status_get_hp(bl) iStatus->get_status_data(bl)->hp -#define status_get_max_hp(bl) iStatus->get_status_data(bl)->max_hp -#define status_get_sp(bl) iStatus->get_status_data(bl)->sp -#define status_get_max_sp(bl) iStatus->get_status_data(bl)->max_sp -#define status_get_str(bl) iStatus->get_status_data(bl)->str -#define status_get_agi(bl) iStatus->get_status_data(bl)->agi -#define status_get_vit(bl) iStatus->get_status_data(bl)->vit -#define status_get_int(bl) iStatus->get_status_data(bl)->int_ -#define status_get_dex(bl) iStatus->get_status_data(bl)->dex -#define status_get_luk(bl) iStatus->get_status_data(bl)->luk -#define status_get_hit(bl) iStatus->get_status_data(bl)->hit -#define status_get_flee(bl) iStatus->get_status_data(bl)->flee -#define status_get_mdef(bl) iStatus->get_status_data(bl)->mdef -#define status_get_flee2(bl) iStatus->get_status_data(bl)->flee2 -#define status_get_def2(bl) iStatus->get_status_data(bl)->def2 -#define status_get_mdef2(bl) iStatus->get_status_data(bl)->mdef2 -#define status_get_critical(bl) iStatus->get_status_data(bl)->cri -#define status_get_batk(bl) iStatus->get_status_data(bl)->batk -#define status_get_watk(bl) iStatus->get_status_data(bl)->rhw.atk -#define status_get_watk2(bl) iStatus->get_status_data(bl)->rhw.atk2 -#define status_get_matk_max(bl) iStatus->get_status_data(bl)->matk_max -#define status_get_matk_min(bl) iStatus->get_status_data(bl)->matk_min -#define status_get_lwatk(bl) iStatus->get_status_data(bl)->lhw.atk -#define status_get_lwatk2(bl) iStatus->get_status_data(bl)->lhw.atk2 -#define status_get_adelay(bl) iStatus->get_status_data(bl)->adelay -#define status_get_amotion(bl) iStatus->get_status_data(bl)->amotion -#define status_get_dmotion(bl) iStatus->get_status_data(bl)->dmotion -#define status_get_element(bl) iStatus->get_status_data(bl)->def_ele -#define status_get_element_level(bl) iStatus->get_status_data(bl)->ele_lv -#define status_get_attack_sc_element(bl, sc) iStatus->calc_attack_element(bl, sc, 0) -#define status_get_attack_element(bl) iStatus->get_status_data(bl)->rhw.ele -#define status_get_attack_lelement(bl) iStatus->get_status_data(bl)->lhw.ele -#define status_get_race(bl) iStatus->get_status_data(bl)->race -#define status_get_size(bl) iStatus->get_status_data(bl)->size -#define status_get_mode(bl) iStatus->get_status_data(bl)->mode +#define status_get_range(bl) status->get_status_data(bl)->rhw.range +#define status_get_hp(bl) status->get_status_data(bl)->hp +#define status_get_max_hp(bl) status->get_status_data(bl)->max_hp +#define status_get_sp(bl) status->get_status_data(bl)->sp +#define status_get_max_sp(bl) status->get_status_data(bl)->max_sp +#define status_get_str(bl) status->get_status_data(bl)->str +#define status_get_agi(bl) status->get_status_data(bl)->agi +#define status_get_vit(bl) status->get_status_data(bl)->vit +#define status_get_int(bl) status->get_status_data(bl)->int_ +#define status_get_dex(bl) status->get_status_data(bl)->dex +#define status_get_luk(bl) status->get_status_data(bl)->luk +#define status_get_hit(bl) status->get_status_data(bl)->hit +#define status_get_flee(bl) status->get_status_data(bl)->flee +#define status_get_mdef(bl) status->get_status_data(bl)->mdef +#define status_get_flee2(bl) status->get_status_data(bl)->flee2 +#define status_get_def2(bl) status->get_status_data(bl)->def2 +#define status_get_mdef2(bl) status->get_status_data(bl)->mdef2 +#define status_get_critical(bl) status->get_status_data(bl)->cri +#define status_get_batk(bl) status->get_status_data(bl)->batk +#define status_get_watk(bl) status->get_status_data(bl)->rhw.atk +#define status_get_watk2(bl) status->get_status_data(bl)->rhw.atk2 +#define status_get_matk_max(bl) status->get_status_data(bl)->matk_max +#define status_get_matk_min(bl) status->get_status_data(bl)->matk_min +#define status_get_lwatk(bl) status->get_status_data(bl)->lhw.atk +#define status_get_lwatk2(bl) status->get_status_data(bl)->lhw.atk2 +#define status_get_adelay(bl) status->get_status_data(bl)->adelay +#define status_get_amotion(bl) status->get_status_data(bl)->amotion +#define status_get_dmotion(bl) status->get_status_data(bl)->dmotion +#define status_get_element(bl) status->get_status_data(bl)->def_ele +#define status_get_element_level(bl) status->get_status_data(bl)->ele_lv +#define status_get_attack_sc_element(bl, sc) status->calc_attack_element(bl, sc, 0) +#define status_get_attack_element(bl) status->get_status_data(bl)->rhw.ele +#define status_get_attack_lelement(bl) status->get_status_data(bl)->lhw.ele +#define status_get_race(bl) status->get_status_data(bl)->race +#define status_get_size(bl) status->get_status_data(bl)->size +#define status_get_mode(bl) status->get_status_data(bl)->mode //Short version, receives rate in 1->100 range, and does not uses a flag setting. -#define sc_start(bl, type, rate, val1, tick) iStatus->change_start(bl,type,100*(rate),val1,0,0,0,tick,0) -#define sc_start2(bl, type, rate, val1, val2, tick) iStatus->change_start(bl,type,100*(rate),val1,val2,0,0,tick,0) -#define sc_start4(bl, type, rate, val1, val2, val3, val4, tick) iStatus->change_start(bl,type,100*(rate),val1,val2,val3,val4,tick,0) +#define sc_start(bl, type, rate, val1, tick) status->change_start(bl,type,100*(rate),val1,0,0,0,tick,0) +#define sc_start2(bl, type, rate, val1, val2, tick) status->change_start(bl,type,100*(rate),val1,val2,0,0,tick,0) +#define sc_start4(bl, type, rate, val1, val2, val3, val4, tick) status->change_start(bl,type,100*(rate),val1,val2,val3,val4,tick,0) -#define status_change_end(bl,type,tid) iStatus->change_end_(bl,type,tid,__FILE__,__LINE__) +#define status_change_end(bl,type,tid) status->change_end_(bl,type,tid,__FILE__,__LINE__) -#define status_calc_bl(bl, flag) iStatus->calc_bl_(bl, (enum scb_flag)(flag), false) -#define status_calc_mob(md, first) iStatus->calc_bl_(&(md)->bl, SCB_ALL, first) -#define status_calc_pet(pd, first) iStatus->calc_bl_(&(pd)->bl, SCB_ALL, first) -#define status_calc_pc(sd, first) iStatus->calc_bl_(&(sd)->bl, SCB_ALL, first) -#define status_calc_homunculus(hd, first) iStatus->calc_bl_(&(hd)->bl, SCB_ALL, first) -#define status_calc_mercenary(md, first) iStatus->calc_bl_(&(md)->bl, SCB_ALL, first) -#define status_calc_elemental(ed, first) iStatus->calc_bl_(&(ed)->bl, SCB_ALL, first) -#define status_calc_npc(nd, first) iStatus->calc_bl_(&(nd)->bl, SCB_ALL, first) +#define status_calc_bl(bl, flag) status->calc_bl_(bl, (enum scb_flag)(flag), false) +#define status_calc_mob(md, first) status->calc_bl_(&(md)->bl, SCB_ALL, first) +#define status_calc_pet(pd, first) status->calc_bl_(&(pd)->bl, SCB_ALL, first) +#define status_calc_pc(sd, first) status->calc_bl_(&(sd)->bl, SCB_ALL, first) +#define status_calc_homunculus(hd, first) status->calc_bl_(&(hd)->bl, SCB_ALL, first) +#define status_calc_mercenary(md, first) status->calc_bl_(&(md)->bl, SCB_ALL, first) +#define status_calc_elemental(ed, first) status->calc_bl_(&(ed)->bl, SCB_ALL, first) +#define status_calc_npc(nd, first) status->calc_bl_(&(nd)->bl, SCB_ALL, first) /*===================================== * Interface : status.h @@ -1878,11 +1878,11 @@ struct status_interface { int (*get_matk) (struct block_list *src, int flag); int (*readdb) (void); - int (*do_init_status) (void); - void (*do_final_status) (void); -} iStatus_s; + int (*init) (void); + void (*final) (void); +} status_s; -struct status_interface *iStatus; +struct status_interface *status; void status_defaults(void); diff --git a/src/map/storage.c b/src/map/storage.c index 2fe7607c3..041c2cd72 100644 --- a/src/map/storage.c +++ b/src/map/storage.c @@ -321,13 +321,12 @@ int storage_storagegettocart(struct map_session_data* sd, int index, int amount) /*========================================== * Modified By Valaris to save upon closing [massdriller] *------------------------------------------*/ -void storage_storageclose(struct map_session_data* sd) -{ +void storage_storageclose(struct map_session_data* sd) { nullpo_retv(sd); clif->storageclose(sd); - if( iMap->save_settings&4 ) + if( map->save_settings&4 ) chrif->save(sd,0); //Invokes the storage saving as well. sd->state.storage_flag = 0; @@ -336,11 +335,10 @@ void storage_storageclose(struct map_session_data* sd) /*========================================== * When quitting the game. *------------------------------------------*/ -void storage_storage_quit(struct map_session_data* sd, int flag) -{ +void storage_storage_quit(struct map_session_data* sd, int flag) { nullpo_retv(sd); - if (iMap->save_settings&4) + if (map->save_settings&4) chrif->save(sd, flag); //Invokes the storage saving as well. sd->state.storage_flag = 0; @@ -684,17 +682,15 @@ int storage_guild_storagesaved(int guild_id) } //Close storage for sd and save it -int storage_guild_storageclose(struct map_session_data* sd) -{ +int storage_guild_storageclose(struct map_session_data* sd) { struct guild_storage *stor; nullpo_ret(sd); nullpo_ret(stor=gstorage->id2storage2(sd->status.guild_id)); clif->storageclose(sd); - if (stor->storage_status) - { - if (iMap->save_settings&4) + if (stor->storage_status) { + if (map->save_settings&4) chrif->save(sd, 0); //This one also saves the storage. [Skotlex] else gstorage->save(sd->status.account_id, sd->status.guild_id,0); @@ -705,25 +701,24 @@ int storage_guild_storageclose(struct map_session_data* sd) return 0; } -int storage_guild_storage_quit(struct map_session_data* sd, int flag) -{ +int storage_guild_storage_quit(struct map_session_data* sd, int flag) { struct guild_storage *stor; nullpo_ret(sd); nullpo_ret(stor=gstorage->id2storage2(sd->status.guild_id)); - if(flag) - { //Only during a guild break flag is 1 (don't save storage) + if(flag) { + //Only during a guild break flag is 1 (don't save storage) sd->state.storage_flag = 0; stor->storage_status = 0; clif->storageclose(sd); - if (iMap->save_settings&4) + if (map->save_settings&4) chrif->save(sd,0); return 0; } if(stor->storage_status) { - if (iMap->save_settings&4) + if (map->save_settings&4) chrif->save(sd,0); else gstorage->save(sd->status.account_id,sd->status.guild_id,1); diff --git a/src/map/trade.c b/src/map/trade.c index f8df2a6c3..e137f7105 100644 --- a/src/map/trade.c +++ b/src/map/trade.c @@ -57,7 +57,7 @@ void trade_traderequest(struct map_session_data *sd, struct map_session_data *ta } if ( sd->trade_partner != 0 ) { // If a character tries to trade to another one then cancel the previous one - struct map_session_data *previous_sd = iMap->id2sd(sd->trade_partner); + struct map_session_data *previous_sd = map->id2sd(sd->trade_partner); if( previous_sd ){ previous_sd->trade_partner = 0; clif->tradecancelled(previous_sd); @@ -101,15 +101,14 @@ void trade_traderequest(struct map_session_data *sd, struct map_session_data *ta * Weird enough, the client should only send 3/4 * and the server is the one that can reply 0~2 *------------------------------------------*/ -void trade_tradeack(struct map_session_data *sd, int type) -{ +void trade_tradeack(struct map_session_data *sd, int type) { struct map_session_data *tsd; nullpo_retv(sd); if (sd->state.trading || !sd->trade_partner) return; //Already trading or no partner set. - if ((tsd = iMap->id2sd(sd->trade_partner)) == NULL) { + if ((tsd = map->id2sd(sd->trade_partner)) == NULL) { clif->tradestart(sd, 1); // character does not exist sd->trade_partner=0; return; @@ -200,12 +199,12 @@ int impossible_trade_check(struct map_session_data *sd) if (!sd->deal.item[i].amount) continue; index = sd->deal.item[i].index; - if (inventory[index].amount < sd->deal.item[i].amount) - { // if more than the player have -> hack + if (inventory[index].amount < sd->deal.item[i].amount) { + // if more than the player have -> hack sprintf(message_to_gm, msg_txt(538), sd->status.name, sd->status.account_id); // Hack on trade: character '%s' (account: %d) try to trade more items that he has. - intif->wis_message_to_gm(iMap->wisp_server_name, PC_PERM_RECEIVE_HACK_INFO, message_to_gm); + intif->wis_message_to_gm(map->wisp_server_name, PC_PERM_RECEIVE_HACK_INFO, message_to_gm); sprintf(message_to_gm, msg_txt(539), inventory[index].amount, inventory[index].nameid, sd->deal.item[i].amount); // This player has %d of a kind of item (id: %d), and try to trade %d of them. - intif->wis_message_to_gm(iMap->wisp_server_name, PC_PERM_RECEIVE_HACK_INFO, message_to_gm); + intif->wis_message_to_gm(map->wisp_server_name, PC_PERM_RECEIVE_HACK_INFO, message_to_gm); // if we block people if (battle_config.ban_hack_trade < 0) { chrif->char_ask_name(-1, sd->status.name, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block @@ -222,7 +221,7 @@ int impossible_trade_check(struct map_session_data *sd) // message about the ban strcpy(message_to_gm, msg_txt(508)); // This player hasn't been banned (Ban option is disabled). - intif->wis_message_to_gm(iMap->wisp_server_name, PC_PERM_RECEIVE_HACK_INFO, message_to_gm); + intif->wis_message_to_gm(map->wisp_server_name, PC_PERM_RECEIVE_HACK_INFO, message_to_gm); return 1; } inventory[index].amount -= sd->deal.item[i].amount; // remove item from inventory @@ -320,8 +319,7 @@ int trade_check(struct map_session_data *sd, struct map_session_data *tsd) /*========================================== * Adds an item/qty to the trade window *------------------------------------------*/ -void trade_tradeadditem(struct map_session_data *sd, short index, short amount) -{ +void trade_tradeadditem(struct map_session_data *sd, short index, short amount) { struct map_session_data *target_sd; struct item *item; int trade_i, trade_weight; @@ -331,7 +329,7 @@ void trade_tradeadditem(struct map_session_data *sd, short index, short amount) if( !sd->state.trading || sd->state.deal_locked > 0 ) return; //Can't add stuff. - if( (target_sd = iMap->id2sd(sd->trade_partner)) == NULL ) + if( (target_sd = map->id2sd(sd->trade_partner)) == NULL ) { trade->cancel(sd); return; @@ -415,8 +413,7 @@ void trade_tradeaddzeny(struct map_session_data* sd, int amount) if( !sd->state.trading || sd->state.deal_locked > 0 ) return; //Can't add stuff. - if( (target_sd = iMap->id2sd(sd->trade_partner)) == NULL ) - { + if( (target_sd = map->id2sd(sd->trade_partner)) == NULL ) { trade->cancel(sd); return; } @@ -434,14 +431,13 @@ void trade_tradeaddzeny(struct map_session_data* sd, int amount) /*========================================== * 'Ok' button on the trade window is pressed. *------------------------------------------*/ -void trade_tradeok(struct map_session_data *sd) -{ +void trade_tradeok(struct map_session_data *sd) { struct map_session_data *target_sd; if(sd->state.deal_locked || !sd->state.trading) return; - if ((target_sd = iMap->id2sd(sd->trade_partner)) == NULL) { + if ((target_sd = map->id2sd(sd->trade_partner)) == NULL) { trade->cancel(sd); return; } @@ -454,12 +450,11 @@ void trade_tradeok(struct map_session_data *sd) /*========================================== * 'Cancel' is pressed. (or trade was force-cancelled by the code) *------------------------------------------*/ -void trade_tradecancel(struct map_session_data *sd) -{ +void trade_tradecancel(struct map_session_data *sd) { struct map_session_data *target_sd; int trade_i; - target_sd = iMap->id2sd(sd->trade_partner); + target_sd = map->id2sd(sd->trade_partner); if(!sd->state.trading) { // Not trade acepted @@ -513,8 +508,7 @@ void trade_tradecancel(struct map_session_data *sd) /*========================================== * lock sd and tsd trade data, execute the trade, clear, then save players *------------------------------------------*/ -void trade_tradecommit(struct map_session_data *sd) -{ +void trade_tradecommit(struct map_session_data *sd) { struct map_session_data *tsd; int trade_i; int flag; @@ -522,7 +516,7 @@ void trade_tradecommit(struct map_session_data *sd) if (!sd->state.trading || !sd->state.deal_locked) //Locked should be 1 (pressed ok) before you can press trade. return; - if ((tsd = iMap->id2sd(sd->trade_partner)) == NULL) { + if ((tsd = map->id2sd(sd->trade_partner)) == NULL) { trade_tradecancel(sd); return; } @@ -603,7 +597,7 @@ void trade_tradecommit(struct map_session_data *sd) clif->tradecompleted(tsd, 0); // save both player to avoid crash: they always have no advantage/disadvantage between the 2 players - if (iMap->save_settings&1) + if (map->save_settings&1) { chrif->save(sd,0); chrif->save(tsd,0); diff --git a/src/map/unit.c b/src/map/unit.c index 4a794da09..9d6f107e3 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -129,16 +129,15 @@ int unit_walktoxy_sub(struct block_list *bl) if(ud->walkpath.path_pos>=ud->walkpath.path_len) i = -1; else if(ud->walkpath.path[ud->walkpath.path_pos]&1) - i = iStatus->get_speed(bl)*MOVE_DIAGONAL_COST/MOVE_COST; + i = status->get_speed(bl)*MOVE_DIAGONAL_COST/MOVE_COST; else - i = iStatus->get_speed(bl); + i = status->get_speed(bl); if( i > 0) ud->walktimer = timer->add(timer->gettick()+i,unit->walktoxy_timer,bl->id,i); return 1; } -int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data) -{ +int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data) { int i; int x,y,dx,dy; uint8 dir; @@ -148,7 +147,7 @@ int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data) struct unit_data *ud; struct mercenary_data *mrd; - bl = iMap->id2bl(id); + bl = map->id2bl(id); if(bl == NULL) return 0; sd = BL_CAST(BL_PC, bl); @@ -179,29 +178,29 @@ int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data) dx = dirx[(int)dir]; dy = diry[(int)dir]; - if(iMap->getcell(bl->m,x+dx,y+dy,CELL_CHKNOPASS)) + if(map->getcell(bl->m,x+dx,y+dy,CELL_CHKNOPASS)) return unit->walktoxy_sub(bl); //Refresh view for all those we lose sight - iMap->foreachinmovearea(clif->outsight, bl, AREA_SIZE, dx, dy, sd?BL_ALL:BL_PC, bl); + map->foreachinmovearea(clif->outsight, bl, AREA_SIZE, dx, dy, sd?BL_ALL:BL_PC, bl); x += dx; y += dy; - iMap->moveblock(bl, x, y, tick); + map->moveblock(bl, x, y, tick); ud->walk_count++; //walked cell counter, to be used for walk-triggered skills. [Skotlex] status_change_end(bl, SC_ROLLINGCUTTER, INVALID_TIMER); //If you move, you lose your counters. [malufett] if (bl->x != x || bl->y != y || ud->walktimer != INVALID_TIMER) - return 0; //iMap->moveblock has altered the object beyond what we expected (moved/warped it) + return 0; //map->moveblock has altered the object beyond what we expected (moved/warped it) ud->walktimer = -2; // arbitrary non-INVALID_TIMER value to make the clif code send walking packets - iMap->foreachinmovearea(clif->insight, bl, AREA_SIZE, -dx, -dy, sd?BL_ALL:BL_PC, bl); + map->foreachinmovearea(clif->insight, bl, AREA_SIZE, -dx, -dy, sd?BL_ALL:BL_PC, bl); ud->walktimer = INVALID_TIMER; if(sd) { if( sd->touching_id ) npc->touchnext_areanpc(sd,false); - if(iMap->getcell(bl->m,x,y,CELL_CHKNPC)) { + if(map->getcell(bl->m,x,y,CELL_CHKNPC)) { npc->touch_areanpc(sd,bl->m,x,y); if (bl->prev == NULL) //Script could have warped char, abort remaining of the function. return 0; @@ -227,7 +226,7 @@ int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data) sd->md->masterteleport_timer = 0; } } else if (md) { - if( iMap->getcell(bl->m,x,y,CELL_CHKNPC) ) { + if( map->getcell(bl->m,x,y,CELL_CHKNPC) ) { if( npc->touch_areanpc2(md) ) return 0; // Warped } else md->areanpc_id = 0; @@ -278,9 +277,9 @@ int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data) if(ud->walkpath.path_pos>=ud->walkpath.path_len) i = -1; else if(ud->walkpath.path[ud->walkpath.path_pos]&1) - i = iStatus->get_speed(bl)*14/10; + i = status->get_speed(bl)*14/10; else - i = iStatus->get_speed(bl); + i = status->get_speed(bl); if(i > 0) { ud->walktimer = timer->add(tick+i,unit->walktoxy_timer,id,i); @@ -290,11 +289,11 @@ int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data) //Keep trying to run. if ( !(unit->run(bl) || unit->wugdash(bl,sd)) ) ud->state.running = 0; - } - else if (ud->target_to) { + } else if (ud->target_to) { //Update target trajectory. - struct block_list *tbl = iMap->id2bl(ud->target_to); - if (!tbl || !iStatus->check_visibility(bl, tbl)) { //Cancel chase. + struct block_list *tbl = map->id2bl(ud->target_to); + if (!tbl || !status->check_visibility(bl, tbl)) { + //Cancel chase. ud->to_x = bl->x; ud->to_y = bl->y; if (tbl && bl->type == BL_MOB && mob->warpchase((TBL_MOB*)bl, tbl) ) @@ -302,8 +301,8 @@ int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data) ud->target_to = 0; return 0; } - if (tbl->m == bl->m && check_distance_bl(bl, tbl, ud->chaserange)) - { //Reached destination. + if (tbl->m == bl->m && check_distance_bl(bl, tbl, ud->chaserange)) { + //Reached destination. if (ud->state.attack_continue) { //Aegis uses one before every attack, we should //only need this one for syncing purposes. [Skotlex] @@ -315,17 +314,16 @@ int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data) unit->walktobl(bl, tbl, ud->chaserange, ud->state.walk_easy|(ud->state.attack_continue?2:0)); return 0; } - } - else { //Stopped walking. Update to_x and to_y to current location [Skotlex] + } else { + //Stopped walking. Update to_x and to_y to current location [Skotlex] ud->to_x = bl->x; ud->to_y = bl->y; } return 0; } -int unit_delay_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data) -{ - struct block_list *bl = iMap->id2bl(id); +int unit_delay_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data) { + struct block_list *bl = map->id2bl(id); if (!bl || bl->prev == NULL) return 0; @@ -362,8 +360,8 @@ int unit_walktoxy( struct block_list *bl, short x, short y, int flag) return 0; if (flag&4 && DIFF_TICK(ud->canmove_tick, timer->gettick()) > 0 && - DIFF_TICK(ud->canmove_tick, timer->gettick()) < 2000) - { // Delay walking command. [Skotlex] + DIFF_TICK(ud->canmove_tick, timer->gettick()) < 2000) { + // Delay walking command. [Skotlex] timer->add(ud->canmove_tick+1, unit->delay_walktoxy_timer, bl->id, (x<<16)|(y&0xFFFF)); return 1; } @@ -376,9 +374,9 @@ int unit_walktoxy( struct block_list *bl, short x, short y, int flag) ud->to_y = y; unit->set_target(ud, 0); - sc = iStatus->get_sc(bl); + sc = status->get_sc(bl); if (sc && sc->data[SC_CONFUSION]) //Randomize the target position - iMap->random_dir(bl, &ud->to_x, &ud->to_y); + map->random_dir(bl, &ud->to_x, &ud->to_y); if(ud->walktimer != INVALID_TIMER) { // When you come to the center of the grid because the change of destination while you're walking right now @@ -404,17 +402,14 @@ static inline void set_mobstate(struct block_list* bl, int flag) md->state.skillstate = md->state.aggressive ? MSS_FOLLOW : MSS_RUSH; } -int unit_walktobl_sub(int tid, unsigned int tick, int id, intptr_t data) -{ - struct block_list *bl = iMap->id2bl(id); +int unit_walktobl_sub(int tid, unsigned int tick, int id, intptr_t data) { + struct block_list *bl = map->id2bl(id); struct unit_data *ud = bl?unit->bl2ud(bl):NULL; - if (ud && ud->walktimer == INVALID_TIMER && ud->target == data) - { + if (ud && ud->walktimer == INVALID_TIMER && ud->target == data) { if (DIFF_TICK(ud->canmove_tick, tick) > 0) //Keep waiting? timer->add(ud->canmove_tick+1, unit->walktobl_sub, id, data); - else if (unit->can_move(bl)) - { + else if (unit->can_move(bl)) { if (unit->walktoxy_sub(bl)) set_mobstate(bl, ud->state.attack_continue); } @@ -451,9 +446,9 @@ int unit_walktobl(struct block_list *bl, struct block_list *tbl, int range, int ud->state.attack_continue = flag&2?1:0; //Chase to attack. unit->set_target(ud, 0); - sc = iStatus->get_sc(bl); + sc = status->get_sc(bl); if (sc && sc->data[SC_CONFUSION]) //Randomize the target position - iMap->random_dir(bl, &ud->to_x, &ud->to_y); + map->random_dir(bl, &ud->to_x, &ud->to_y); if(ud->walktimer != INVALID_TIMER) { ud->state.change_walk_target = 1; @@ -482,9 +477,8 @@ int unit_walktobl(struct block_list *bl, struct block_list *tbl, int range, int return 0; } -int unit_run(struct block_list *bl) -{ - struct status_change *sc = iStatus->get_sc(bl); +int unit_run(struct block_list *bl) { + struct status_change *sc = status->get_sc(bl); short to_x,to_y,dir_x,dir_y; int lv; int i; @@ -504,13 +498,12 @@ int unit_run(struct block_list *bl) // determine destination cell to_x = bl->x; to_y = bl->y; - for(i=0;i<AREA_SIZE;i++) - { - if(!iMap->getcell(bl->m,to_x+dir_x,to_y+dir_y,CELL_CHKPASS)) + for(i=0;i<AREA_SIZE;i++) { + if(!map->getcell(bl->m,to_x+dir_x,to_y+dir_y,CELL_CHKPASS)) break; //if sprinting and there's a PC/Mob/NPC, block the path [Kevin] - if(sc->data[SC_RUN] && iMap->count_oncell(bl->m, to_x+dir_x, to_y+dir_y, BL_PC|BL_MOB|BL_NPC)) + if(sc->data[SC_RUN] && map->count_oncell(bl->m, to_x+dir_x, to_y+dir_y, BL_PC|BL_MOB|BL_NPC)) break; to_x += dir_x; @@ -555,7 +548,7 @@ int unit_run(struct block_list *bl) //Exclusive function to Wug Dash state. [Jobbie/3CeAM] int unit_wugdash(struct block_list *bl, struct map_session_data *sd) { - struct status_change *sc = iStatus->get_sc(bl); + struct status_change *sc = status->get_sc(bl); short to_x,to_y,dir_x,dir_y; int lv; int i; @@ -576,12 +569,11 @@ int unit_wugdash(struct block_list *bl, struct map_session_data *sd) { to_x = bl->x; to_y = bl->y; - for(i=0;i<AREA_SIZE;i++) - { - if(!iMap->getcell(bl->m,to_x+dir_x,to_y+dir_y,CELL_CHKPASS)) + for(i=0;i<AREA_SIZE;i++) { + if(!map->getcell(bl->m,to_x+dir_x,to_y+dir_y,CELL_CHKPASS)) break; - if(sc->data[SC_WUGDASH] && iMap->count_oncell(bl->m, to_x+dir_x, to_y+dir_y, BL_PC|BL_MOB|BL_NPC)) + if(sc->data[SC_WUGDASH] && map->count_oncell(bl->m, to_x+dir_x, to_y+dir_y, BL_PC|BL_MOB|BL_NPC)) break; to_x += dir_x; @@ -620,17 +612,15 @@ int unit_wugdash(struct block_list *bl, struct map_session_data *sd) { } //Makes bl attempt to run dist cells away from target. Uses hard-paths. -int unit_escape(struct block_list *bl, struct block_list *target, short dist) -{ - uint8 dir = iMap->calc_dir(target, bl->x, bl->y); - while( dist > 0 && iMap->getcell(bl->m, bl->x + dist*dirx[dir], bl->y + dist*diry[dir], CELL_CHKNOREACH) ) +int unit_escape(struct block_list *bl, struct block_list *target, short dist) { + uint8 dir = map->calc_dir(target, bl->x, bl->y); + while( dist > 0 && map->getcell(bl->m, bl->x + dist*dirx[dir], bl->y + dist*diry[dir], CELL_CHKNOREACH) ) dist--; return ( dist > 0 && unit->walktoxy(bl, bl->x + dist*dirx[dir], bl->y + dist*diry[dir], 0) ); } //Instant warp function. -int unit_movepos(struct block_list *bl, short dst_x, short dst_y, int easy, bool checkpath) -{ +int unit_movepos(struct block_list *bl, short dst_x, short dst_y, int easy, bool checkpath) { short dx,dy; uint8 dir; struct unit_data *ud = NULL; @@ -645,30 +635,30 @@ int unit_movepos(struct block_list *bl, short dst_x, short dst_y, int easy, bool unit->stop_walking(bl,1); unit->stop_attack(bl); - if( checkpath && (iMap->getcell(bl->m,dst_x,dst_y,CELL_CHKNOPASS) || !path->search(NULL,bl->m,bl->x,bl->y,dst_x,dst_y,easy,CELL_CHKNOREACH)) ) + if( checkpath && (map->getcell(bl->m,dst_x,dst_y,CELL_CHKNOPASS) || !path->search(NULL,bl->m,bl->x,bl->y,dst_x,dst_y,easy,CELL_CHKNOREACH)) ) return 0; // unreachable ud->to_x = dst_x; ud->to_y = dst_y; - dir = iMap->calc_dir(bl, dst_x, dst_y); + dir = map->calc_dir(bl, dst_x, dst_y); ud->dir = dir; dx = dst_x - bl->x; dy = dst_y - bl->y; - iMap->foreachinmovearea(clif->outsight, bl, AREA_SIZE, dx, dy, sd?BL_ALL:BL_PC, bl); + map->foreachinmovearea(clif->outsight, bl, AREA_SIZE, dx, dy, sd?BL_ALL:BL_PC, bl); - iMap->moveblock(bl, dst_x, dst_y, timer->gettick()); + map->moveblock(bl, dst_x, dst_y, timer->gettick()); ud->walktimer = -2; // arbitrary non-INVALID_TIMER value to make the clif code send walking packets - iMap->foreachinmovearea(clif->insight, bl, AREA_SIZE, -dx, -dy, sd?BL_ALL:BL_PC, bl); + map->foreachinmovearea(clif->insight, bl, AREA_SIZE, -dx, -dy, sd?BL_ALL:BL_PC, bl); ud->walktimer = INVALID_TIMER; if(sd) { if( sd->touching_id ) npc->touchnext_areanpc(sd,false); - if(iMap->getcell(bl->m,bl->x,bl->y,CELL_CHKNPC)) { + if(map->getcell(bl->m,bl->x,bl->y,CELL_CHKNPC)) { npc->touch_areanpc(sd,bl->m,bl->x,bl->y); if (bl->prev == NULL) //Script could have warped char, abort remaining of the function. return 0; @@ -749,15 +739,15 @@ int unit_blown(struct block_list* bl, int dx, int dy, int count, int flag) dy = ny-bl->y; if(dx || dy) { - iMap->foreachinmovearea(clif->outsight, bl, AREA_SIZE, dx, dy, bl->type == BL_PC ? BL_ALL : BL_PC, bl); + map->foreachinmovearea(clif->outsight, bl, AREA_SIZE, dx, dy, bl->type == BL_PC ? BL_ALL : BL_PC, bl); if(su) { skill->unit_move_unit_group(su->group, bl->m, dx, dy); } else { - iMap->moveblock(bl, nx, ny, timer->gettick()); + map->moveblock(bl, nx, ny, timer->gettick()); } - iMap->foreachinmovearea(clif->insight, bl, AREA_SIZE, -dx, -dy, bl->type == BL_PC ? BL_ALL : BL_PC, bl); + map->foreachinmovearea(clif->insight, bl, AREA_SIZE, -dx, -dy, bl->type == BL_PC ? BL_ALL : BL_PC, bl); if(!(flag&1)) { clif->blown(bl); @@ -767,7 +757,7 @@ int unit_blown(struct block_list* bl, int dx, int dy, int count, int flag) if(sd->touching_id) { npc->touchnext_areanpc(sd, false); } - if(iMap->getcell(bl->m, bl->x, bl->y, CELL_CHKNPC)) { + if(map->getcell(bl->m, bl->x, bl->y, CELL_CHKNPC)) { npc->touch_areanpc(sd, bl->m, bl->x, bl->y); } else { sd->areanpc_id = 0; @@ -815,16 +805,16 @@ int unit_warp(struct block_list *bl,short m,short x,short y,clr_type type) if (x<0 || y<0) { //Random map position. - if (!iMap->search_freecell(NULL, m, &x, &y, -1, -1, 1)) { + if (!map->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, maplist[m].name, x, y); return 2; } - } else if (iMap->getcell(m,x,y,CELL_CHKNOREACH)) { + } else if (map->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)) { + if (!map->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; @@ -845,7 +835,7 @@ int unit_warp(struct block_list *bl,short m,short x,short y,clr_type type) bl->y=ud->to_y=y; bl->m=m; - iMap->addblock(bl); + map->addblock(bl); clif->spawn(bl); skill->unit_move(bl,timer->gettick(),1); @@ -930,7 +920,7 @@ int unit_can_move(struct block_list *bl) { nullpo_ret(bl); ud = unit->bl2ud(bl); - sc = iStatus->get_sc(bl); + sc = status->get_sc(bl); sd = BL_CAST(BL_PC, bl); if (!ud) @@ -951,45 +941,49 @@ int unit_can_move(struct block_list *bl) { return 0; //Can't move if (sc) { - if( sc->count && ( - sc->data[SC_ANKLESNARE] - || sc->data[SC_AUTOCOUNTER] - || sc->data[SC_TRICKDEAD] - || sc->data[SC_BLADESTOP] - || sc->data[SC_BLADESTOP_WAIT] - || (sc->data[SC_GOSPEL] && sc->data[SC_GOSPEL]->val4 == BCT_SELF) // cannot move while gospel is in effect - || (sc->data[SC_BASILICA] && sc->data[SC_BASILICA]->val4 == bl->id) // Basilica caster cannot move - || sc->data[SC_STOP] - || sc->data[SC_RG_CCONFINE_M] - || sc->data[SC_RG_CCONFINE_S] - || sc->data[SC_GS_MADNESSCANCEL] - || (sc->data[SC_GRAVITATION] && sc->data[SC_GRAVITATION]->val3 == BCT_SELF) - || sc->data[SC_WHITEIMPRISON] - || sc->data[SC_ELECTRICSHOCKER] - || sc->data[SC_WUGBITE] - || sc->data[SC_THORNS_TRAP] - || sc->data[SC_MAGNETICFIELD] - || sc->data[SC__MANHOLE] - || sc->data[SC_CURSEDCIRCLE_ATKER] - || sc->data[SC_CURSEDCIRCLE_TARGET] - || (sc->data[SC_COLD] && bl->type != BL_MOB) - || sc->data[SC_NETHERWORLD] - || (sc->data[SC_CAMOUFLAGE] && sc->data[SC_CAMOUFLAGE]->val1 < 3 && !(sc->data[SC_CAMOUFLAGE]->val3&1)) - || sc->data[SC_MEIKYOUSISUI] - || sc->data[SC_KG_KAGEHUMI] - || sc->data[SC_KYOUGAKU] - || sc->data[SC_NEEDLE_OF_PARALYZE] - || sc->data[SC_VACUUM_EXTREME] - || (sc->data[SC_FEAR] && sc->data[SC_FEAR]->val2 > 0) - || (sc->data[SC_SPIDERWEB] && sc->data[SC_SPIDERWEB]->val1) - || (sc->data[SC_DANCING] && sc->data[SC_DANCING]->val4 && ( - !sc->data[SC_LONGING] || - (sc->data[SC_DANCING]->val1&0xFFFF) == CG_MOONLIT || - (sc->data[SC_DANCING]->val1&0xFFFF) == CG_HERMODE - ) ) - || (sc->data[SC_CLOAKING] && //Need wall at level 1-2 - sc->data[SC_CLOAKING]->val1 < 3 && !(sc->data[SC_CLOAKING]->val4&1)) - ) ) + if( sc->count + && ( + sc->data[SC_ANKLESNARE] + || sc->data[SC_AUTOCOUNTER] + || sc->data[SC_TRICKDEAD] + || sc->data[SC_BLADESTOP] + || sc->data[SC_BLADESTOP_WAIT] + || (sc->data[SC_GOSPEL] && sc->data[SC_GOSPEL]->val4 == BCT_SELF) // cannot move while gospel is in effect + || (sc->data[SC_BASILICA] && sc->data[SC_BASILICA]->val4 == bl->id) // Basilica caster cannot move + || sc->data[SC_STOP] + || sc->data[SC_RG_CCONFINE_M] + || sc->data[SC_RG_CCONFINE_S] + || sc->data[SC_GS_MADNESSCANCEL] + || (sc->data[SC_GRAVITATION] && sc->data[SC_GRAVITATION]->val3 == BCT_SELF) + || sc->data[SC_WHITEIMPRISON] + || sc->data[SC_ELECTRICSHOCKER] + || sc->data[SC_WUGBITE] + || sc->data[SC_THORNS_TRAP] + || sc->data[SC_MAGNETICFIELD] + || sc->data[SC__MANHOLE] + || sc->data[SC_CURSEDCIRCLE_ATKER] + || sc->data[SC_CURSEDCIRCLE_TARGET] + || (sc->data[SC_COLD] && bl->type != BL_MOB) + || sc->data[SC_NETHERWORLD] + || (sc->data[SC_CAMOUFLAGE] && sc->data[SC_CAMOUFLAGE]->val1 < 3 && !(sc->data[SC_CAMOUFLAGE]->val3&1)) + || sc->data[SC_MEIKYOUSISUI] + || sc->data[SC_KG_KAGEHUMI] + || sc->data[SC_KYOUGAKU] + || sc->data[SC_NEEDLE_OF_PARALYZE] + || sc->data[SC_VACUUM_EXTREME] + || (sc->data[SC_FEAR] && sc->data[SC_FEAR]->val2 > 0) + || (sc->data[SC_SPIDERWEB] && sc->data[SC_SPIDERWEB]->val1) + || (sc->data[SC_CLOAKING] && sc->data[SC_CLOAKING]->val1 < 3 && !(sc->data[SC_CLOAKING]->val4&1)) //Need wall at level 1-2 + || ( + sc->data[SC_DANCING] && sc->data[SC_DANCING]->val4 + && ( + !sc->data[SC_LONGING] + || (sc->data[SC_DANCING]->val1&0xFFFF) == CG_MOONLIT + || (sc->data[SC_DANCING]->val1&0xFFFF) == CG_HERMODE + ) + ) + ) + ) return 0; @@ -1007,18 +1001,17 @@ int unit_can_move(struct block_list *bl) { * Resume running after a walk delay *------------------------------------------*/ -int unit_resume_running(int tid, unsigned int tick, int id, intptr_t data) -{ +int unit_resume_running(int tid, unsigned int tick, int id, intptr_t data) { struct unit_data *ud = (struct unit_data *)data; - TBL_PC * sd = iMap->id2sd(id); + TBL_PC * sd = map->id2sd(id); if(sd && pc_isridingwug(sd)) clif->skill_nodamage(ud->bl,ud->bl,RA_WUGDASH,ud->skill_lv, - sc_start4(ud->bl,iStatus->skill2sc(RA_WUGDASH),100,ud->skill_lv,unit->getdir(ud->bl),0,0,1)); + sc_start4(ud->bl,status->skill2sc(RA_WUGDASH),100,ud->skill_lv,unit->getdir(ud->bl),0,0,1)); else clif->skill_nodamage(ud->bl,ud->bl,TK_RUN,ud->skill_lv, - sc_start4(ud->bl,iStatus->skill2sc(TK_RUN),100,ud->skill_lv,unit->getdir(ud->bl),0,0,0)); + sc_start4(ud->bl,status->skill2sc(TK_RUN),100,ud->skill_lv,unit->getdir(ud->bl),0,0,0)); if (sd) clif->walkok(sd); @@ -1074,8 +1067,7 @@ int unit_set_walkdelay(struct block_list *bl, unsigned int tick, int delay, int return 1; } -int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, uint16 skill_lv, int casttime, int castcancel) -{ +int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, uint16 skill_lv, int casttime, int castcancel) { struct unit_data *ud; struct status_data *tstatus; struct status_change *sc; @@ -1085,14 +1077,14 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui int temp = 0, range; nullpo_ret(src); - if(iStatus->isdead(src)) + if(status->isdead(src)) return 0; //Do not continue source is dead sd = BL_CAST(BL_PC, src); ud = unit->bl2ud(src); if(ud == NULL) return 0; - sc = iStatus->get_sc(src); + sc = status->get_sc(src); if (sc && !sc->count) sc = NULL; //Unneeded @@ -1122,8 +1114,8 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui switch(skill_id) { //Check for skills that auto-select target case MO_CHAINCOMBO: - if (sc && sc->data[SC_BLADESTOP]){ - if ((target=iMap->id2bl(sc->data[SC_BLADESTOP]->val4)) == NULL) + if (sc && sc->data[SC_BLADESTOP]) { + if ((target=map->id2bl(sc->data[SC_BLADESTOP]->val4)) == NULL) return 0; } break; @@ -1131,7 +1123,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui case WE_FEMALE: if (!sd->status.partner_id) return 0; - target = (struct block_list*)iMap->charid2sd(sd->status.partner_id); + target = (struct block_list*)map->charid2sd(sd->status.partner_id); if (!target) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); return 0; @@ -1154,7 +1146,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui } if( !target ) // choose default target - target = iMap->id2bl(target_id); + target = map->id2bl(target_id); if( !target || src->m != target->m || !src->prev || !target->prev ) return 0; @@ -1169,10 +1161,10 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui if(skill->get_inf2(skill_id)&INF2_NO_TARGET_SELF && src->id == target_id) return 0; - if(!iStatus->check_skilluse(src, target, skill_id, 0)) + if(!status->check_skilluse(src, target, skill_id, 0)) return 0; - tstatus = iStatus->get_status_data(target); + tstatus = status->get_status_data(target); // Record the status of the previous skill) if(sd) { @@ -1260,7 +1252,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui case ALL_RESURRECTION: if(battle->check_undead(tstatus->race,tstatus->def_ele)) { temp = 1; - } else if (!iStatus->isdead(target)) + } else if (!status->isdead(target)) return 0; //Can't cast on non-dead characters. break; case MO_FINGEROFFENSIVE: @@ -1332,7 +1324,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui case NC_DISJOINT: if( target->type == BL_PC ){ struct mob_data *md; - if( (md = iMap->id2md(target->id)) && md->master_id != src->id ) + if( (md = map->id2md(target->id)) && md->master_id != src->id ) casttime <<= 1; } break; @@ -1451,7 +1443,7 @@ int unit_skilluse_pos2( struct block_list *src, short skill_x, short skill_y, ui nullpo_ret(src); if (!src->prev) return 0; // not on the map - if(iStatus->isdead(src)) return 0; + if(status->isdead(src)) return 0; sd = BL_CAST(BL_PC, src); ud = unit->bl2ud(src); @@ -1460,7 +1452,7 @@ int unit_skilluse_pos2( struct block_list *src, short skill_x, short skill_y, ui if(ud->skilltimer != INVALID_TIMER) //Normally not needed since clif.c checks for it, but at/char/script commands don't! [Skotlex] return 0; - sc = iStatus->get_sc(src); + sc = status->get_sc(src); if (sc && !sc->count) sc = NULL; @@ -1472,21 +1464,21 @@ int unit_skilluse_pos2( struct block_list *src, short skill_x, short skill_y, ui * "WHY IS IT HEREE": pneuma cannot be cancelled past this point, the client displays the animation even, * if we cancel it from nodamage_id, so it has to be here for it to not display the animation. **/ - if( skill_id == AL_PNEUMA && iMap->getcell(src->m, skill_x, skill_y, CELL_CHKLANDPROTECTOR) ) { + if( skill_id == AL_PNEUMA && map->getcell(src->m, skill_x, skill_y, CELL_CHKLANDPROTECTOR) ) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); return 0; } - if( (skill_id >= SC_MANHOLE && skill_id <= SC_FEINTBOMB) && iMap->getcell(src->m, skill_x, skill_y, CELL_CHKMAELSTROM) ) { + if( (skill_id >= SC_MANHOLE && skill_id <= SC_FEINTBOMB) && map->getcell(src->m, skill_x, skill_y, CELL_CHKMAELSTROM) ) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); return 0; } } - if (!iStatus->check_skilluse(src, NULL, skill_id, 0)) + if (!status->check_skilluse(src, NULL, skill_id, 0)) return 0; - if( iMap->getcell(src->m, skill_x, skill_y, CELL_CHKWALL) ) - {// can't cast ground targeted spells on wall cells + if( map->getcell(src->m, skill_x, skill_y, CELL_CHKWALL) ) { + // can't cast ground targeted spells on wall cells if (sd) clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); return 0; } @@ -1577,9 +1569,9 @@ int unit_set_target(struct unit_data* ud, int target_id) nullpo_ret(ud); if( ud->target != target_id ) { - if( ud->target && (target = iMap->id2bl(ud->target)) && (ux = unit->bl2ud(target)) && ux->target_count > 0 ) + if( ud->target && (target = map->id2bl(ud->target)) && (ux = unit->bl2ud(target)) && ux->target_count > 0 ) ux->target_count --; - if( target_id && (target = iMap->id2bl(target_id)) && (ux = unit->bl2ud(target)) ) + if( target_id && (target = map->id2bl(target_id)) && (ux = unit->bl2ud(target)) ) ux->target_count ++; } @@ -1621,15 +1613,14 @@ int unit_unattackable(struct block_list *bl) * Attack request * If type is an ongoing attack *------------------------------------------*/ -int unit_attack(struct block_list *src,int target_id,int continuous) -{ +int unit_attack(struct block_list *src,int target_id,int continuous) { struct block_list *target; struct unit_data *ud; nullpo_ret(ud = unit->bl2ud(src)); - target = iMap->id2bl(target_id); - if( target==NULL || iStatus->isdead(target) ) { + target = map->id2bl(target_id); + if( target==NULL || status->isdead(target) ) { unit->unattackable(src); return 1; } @@ -1645,7 +1636,7 @@ int unit_attack(struct block_list *src,int target_id,int continuous) return 0; } } - if( battle->check_target(src,target,BCT_ENEMY) <= 0 || !iStatus->check_skilluse(src, target, 0, 0) ) { + if( battle->check_target(src,target,BCT_ENEMY) <= 0 || !status->check_skilluse(src, target, 0, 0) ) { unit->unattackable(src); return 1; } @@ -1731,9 +1722,9 @@ bool unit_can_reach_bl(struct block_list *bl,struct block_list *tbl, int range, dx=(dx>0)?1:((dx<0)?-1:0); dy=(dy>0)?1:((dy<0)?-1:0); - if (iMap->getcell(tbl->m,tbl->x-dx,tbl->y-dy,CELL_CHKNOPASS)) - { //Look for a suitable cell to place in. - for(i=0;i<9 && iMap->getcell(tbl->m,tbl->x-dirx[i],tbl->y-diry[i],CELL_CHKNOPASS);i++); + if (map->getcell(tbl->m,tbl->x-dx,tbl->y-dy,CELL_CHKNOPASS)) { + //Look for a suitable cell to place in. + for(i=0;i<9 && map->getcell(tbl->m,tbl->x-dirx[i],tbl->y-diry[i],CELL_CHKNOPASS);i++); if (i==9) return false; //No valid cells. dx = dirx[i]; dy = diry[i]; @@ -1824,17 +1815,17 @@ int unit_attack_timer_sub(struct block_list* src, int tid, unsigned int tick) sd = BL_CAST(BL_PC, src); md = BL_CAST(BL_MOB, src); ud->attacktimer = INVALID_TIMER; - target=iMap->id2bl(ud->target); + target=map->id2bl(ud->target); if( src == NULL || src->prev == NULL || target==NULL || target->prev == NULL ) return 0; - if( iStatus->isdead(src) || iStatus->isdead(target) || - battle->check_target(src,target,BCT_ENEMY) <= 0 || !iStatus->check_skilluse(src, target, 0, 0) + if( status->isdead(src) || status->isdead(target) + || battle->check_target(src,target,BCT_ENEMY) <= 0 || !status->check_skilluse(src, target, 0, 0) #ifdef OFFICIAL_WALKPATH - || !path->search_long(NULL, src->m, src->x, src->y, target->x, target->y, CELL_CHKWALL) + || !path->search_long(NULL, src->m, src->x, src->y, target->x, target->y, CELL_CHKWALL) #endif - ) + ) return 0; // can't attack under these conditions if( src->m != target->m ) @@ -1862,7 +1853,7 @@ int unit_attack_timer_sub(struct block_list* src, int tid, unsigned int tick) return 1; } - sstatus = iStatus->get_status_data(src); + sstatus = status->get_status_data(src); range = sstatus->rhw.range + 1; if( unit->is_walking(target) ) @@ -1875,7 +1866,7 @@ int unit_attack_timer_sub(struct block_list* src, int tid, unsigned int tick) return 1; } if( !battle->check_range(src,target,range) ) { - //Within range, but no direct line of attack + //Within range, but no direct line of attack if( ud->state.attack_continue ) { if(ud->chaserange > 2) ud->chaserange-=2; unit->walktobl(src,target,ud->chaserange,ud->state.walk_easy|2); @@ -1886,10 +1877,9 @@ int unit_attack_timer_sub(struct block_list* src, int tid, unsigned int tick) //Non-players use the sync packet on the walk timer. [Skotlex] if (tid == INVALID_TIMER && sd) clif->fixpos(src); - if( DIFF_TICK(ud->attackabletime,tick) <= 0 ) - { + if( DIFF_TICK(ud->attackabletime,tick) <= 0 ) { if (battle_config.attack_direction_change && (src->type&battle_config.attack_direction_change)) { - ud->dir = iMap->calc_dir(src, target->x,target->y ); + ud->dir = map->calc_dir(src, target->x,target->y ); } if(ud->walktimer != INVALID_TIMER) unit->stop_walking(src,1); @@ -1899,18 +1889,18 @@ int unit_attack_timer_sub(struct block_list* src, int tid, unsigned int tick) if (sstatus->mode&MD_ASSIST && DIFF_TICK(md->last_linktime, tick) < MIN_MOBLINKTIME) { // Link monsters nearby [Skotlex] md->last_linktime = tick; - iMap->foreachinrange(mob->linksearch, src, md->db->range2, BL_MOB, md->class_, target, tick); + map->foreachinrange(mob->linksearch, src, md->db->range2, BL_MOB, md->class_, target, tick); } } if(src->type == BL_PET && pet->attackskill((TBL_PET*)src, target->id)) return 1; - iMap->freeblock_lock(); + map->freeblock_lock(); ud->attacktarget_lv = battle->weapon_attack(src,target,tick,0); if(sd && sd->status.pet_id > 0 && sd->pd && battle_config.pet_attack_support) pet->target_check(sd,target,0); - iMap->freeblock_unlock(); + map->freeblock_unlock(); /** * Applied when you're unable to attack (e.g. out of ammo) * We should stop here otherwise timer keeps on and this happens endlessly @@ -1933,10 +1923,9 @@ int unit_attack_timer_sub(struct block_list* src, int tid, unsigned int tick) return 1; } -int unit_attack_timer(int tid, unsigned int tick, int id, intptr_t data) -{ +int unit_attack_timer(int tid, unsigned int tick, int id, intptr_t data) { struct block_list *bl; - bl = iMap->id2bl(id); + bl = map->id2bl(id); if(bl && unit->attack_timer_sub(bl, tid, tick) == 0) unit->unattackable(bl); return 0; @@ -2067,18 +2056,17 @@ int unit_changeviewsize(struct block_list *bl,short size) * Returns 1 on success. 0 if it couldn't be removed or the bl was free'd * if clrtype is 1 (death), appropiate cleanup is performed. * Otherwise it is assumed bl is being warped. - * On-Kill specific stuff is not performed here, look at iStatus->damage for that. + * On-Kill specific stuff is not performed here, look at status->damage for that. *------------------------------------------*/ -int unit_remove_map(struct block_list *bl, clr_type clrtype, const char* file, int line, const char* func) -{ +int unit_remove_map(struct block_list *bl, clr_type clrtype, const char* file, int line, const char* func) { struct unit_data *ud = unit->bl2ud(bl); - struct status_change *sc = iStatus->get_sc(bl); + struct status_change *sc = status->get_sc(bl); nullpo_ret(ud); if(bl->prev == NULL) return 0; //Already removed? - iMap->freeblock_lock(); + map->freeblock_lock(); unit->set_target(ud, 0); @@ -2107,8 +2095,7 @@ int unit_remove_map(struct block_list *bl, clr_type clrtype, const char* file, i status_change_end(bl, SC_RG_CCONFINE_S, INVALID_TIMER); status_change_end(bl, SC_HIDING, INVALID_TIMER); // Ensure the bl is a PC; if so, we'll handle the removal of cloaking and cloaking exceed later - if ( bl->type != BL_PC ) - { + if ( bl->type != BL_PC ) { status_change_end(bl, SC_CLOAKING, INVALID_TIMER); status_change_end(bl, SC_CLOAKINGEXCEED, INVALID_TIMER); } @@ -2134,14 +2121,14 @@ int unit_remove_map(struct block_list *bl, clr_type clrtype, const char* file, i case BL_PC: { struct map_session_data *sd = (struct map_session_data*)bl; - if(sd->shadowform_id){ - struct block_list *d_bl = iMap->id2bl(sd->shadowform_id); - if( d_bl ) - status_change_end(d_bl,SC__SHADOWFORM,INVALID_TIMER); + if(sd->shadowform_id) { + struct block_list *d_bl = map->id2bl(sd->shadowform_id); + if( d_bl ) + status_change_end(d_bl,SC__SHADOWFORM,INVALID_TIMER); } //Leave/reject all invitations. if(sd->chatID) - chat->leavechat(sd,0); + chat->leave(sd,0); if(sd->trade_partner) trade->cancel(sd); buyingstore->close(sd); @@ -2203,8 +2190,8 @@ int unit_remove_map(struct block_list *bl, clr_type clrtype, const char* file, i sd->state.active, sd->state.connect_new, sd->state.rewarp, sd->state.changemap, sd->state.debug_remove_map, maplist[bl->m].name, maplist[bl->m].users, sd->debug_file, sd->debug_line, sd->debug_func, file, line, func); - } else if (--maplist[bl->m].users == 0 && battle_config.dynamic_mobs) //[Skotlex] - iMap->removemobs(bl->m); + } else if (--maplist[bl->m].users == 0 && battle_config.dynamic_mobs) //[Skotlex] + map->removemobs(bl->m); if( !(sd->sc.option&OPTION_INVISIBLE) ) { // decrement the number of active pvp players on the map --maplist[bl->m].users_pvp; @@ -2233,12 +2220,12 @@ int unit_remove_map(struct block_list *bl, clr_type clrtype, const char* file, i } case BL_PET: { struct pet_data *pd = (struct pet_data*)bl; - if( pd->pet.intimate <= 0 && !(pd->msd && !pd->msd->state.active) ) - { //If logging out, this is deleted on unit->free + if( pd->pet.intimate <= 0 && !(pd->msd && !pd->msd->state.active) ) { + //If logging out, this is deleted on unit->free clif->clearunit_area(bl,clrtype); - iMap->delblock(bl); + map->delblock(bl); unit->free(bl,CLR_OUTSIGHT); - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 0; } @@ -2247,13 +2234,13 @@ int unit_remove_map(struct block_list *bl, clr_type clrtype, const char* file, i case BL_HOM: { struct homun_data *hd = (struct homun_data *)bl; ud->canact_tick = ud->canmove_tick; //It appears HOM do reset the can-act tick. - if( !hd->homunculus.intimacy && !(hd->master && !hd->master->state.active) ) - { //If logging out, this is deleted on unit->free + if( !hd->homunculus.intimacy && !(hd->master && !hd->master->state.active) ) { + //If logging out, this is deleted on unit->free clif->emotion(bl, E_SOB); clif->clearunit_area(bl,clrtype); - iMap->delblock(bl); + map->delblock(bl); unit->free(bl,CLR_OUTSIGHT); - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 0; } break; @@ -2261,12 +2248,11 @@ int unit_remove_map(struct block_list *bl, clr_type clrtype, const char* file, i case BL_MER: { struct mercenary_data *md = (struct mercenary_data *)bl; ud->canact_tick = ud->canmove_tick; - if( mercenary->get_lifetime(md) <= 0 && !(md->master && !md->master->state.active) ) - { + if( mercenary->get_lifetime(md) <= 0 && !(md->master && !md->master->state.active) ) { clif->clearunit_area(bl,clrtype); - iMap->delblock(bl); + map->delblock(bl); unit->free(bl,CLR_OUTSIGHT); - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 0; } break; @@ -2274,12 +2260,11 @@ int unit_remove_map(struct block_list *bl, clr_type clrtype, const char* file, i case BL_ELEM: { struct elemental_data *ed = (struct elemental_data *)bl; ud->canact_tick = ud->canmove_tick; - if( elemental->get_lifetime(ed) <= 0 && !(ed->master && !ed->master->state.active) ) - { + if( elemental->get_lifetime(ed) <= 0 && !(ed->master && !ed->master->state.active) ) { clif->clearunit_area(bl,clrtype); - iMap->delblock(bl); + map->delblock(bl); unit->free(bl,0); - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 0; } break; @@ -2289,10 +2274,10 @@ int unit_remove_map(struct block_list *bl, clr_type clrtype, const char* file, i /** * BL_MOB is handled by mob_dead unless the monster is not dead. **/ - if( bl->type != BL_MOB || !iStatus->isdead(bl) ) + if( bl->type != BL_MOB || !status->isdead(bl) ) clif->clearunit_area(bl,clrtype); - iMap->delblock(bl); - iMap->freeblock_unlock(); + map->delblock(bl); + map->freeblock_unlock(); return 1; } @@ -2325,12 +2310,11 @@ void unit_free_pc(struct map_session_data *sd) * Function to free all related resources to the bl * if unit is on map, it is removed using the clrtype specified *------------------------------------------*/ -int unit_free(struct block_list *bl, clr_type clrtype) -{ +int unit_free(struct block_list *bl, clr_type clrtype) { struct unit_data *ud = unit->bl2ud( bl ); nullpo_ret(ud); - iMap->freeblock_lock(); + map->freeblock_lock(); if( bl->prev ) //Players are supposed to logout with a "warp" effect. unit->remove_map(bl, clrtype, ALC_MARK); @@ -2341,7 +2325,7 @@ int unit_free(struct block_list *bl, clr_type clrtype) int i; unsigned int k; - if( iStatus->isdead(bl) ) + if( status->isdead(bl) ) pc->setrestartvalue(sd,2); pc->delinvincibletimer(sd); @@ -2356,7 +2340,7 @@ int unit_free(struct block_list *bl, clr_type clrtype) duel->reject(sd->duel_invite, sd); // Notify friends that this char logged out. [Skotlex] - iMap->map_foreachpc(clif->friendslist_toggle_sub, sd->status.account_id, sd->status.char_id, 0); + map->map_foreachpc(clif->friendslist_toggle_sub, sd->status.account_id, sd->status.char_id, 0); party->send_logout(sd); guild->send_memberinfoshort(sd,0); pc->cleareventtimer(sd); @@ -2583,11 +2567,11 @@ int unit_free(struct block_list *bl, clr_type clrtype) } skill->clear_unitgroup(bl); - iStatus->change_clear(bl,1); - iMap->deliddb(bl); + status->change_clear(bl,1); + map->deliddb(bl); if( bl->type != BL_PC ) //Players are handled by map_quit - iMap->freeblock(bl); - iMap->freeblock_unlock(); + map->freeblock(bl); + map->freeblock_unlock(); return 0; } diff --git a/src/map/vending.c b/src/map/vending.c index 32e084a87..7d6d02cfb 100644 --- a/src/map/vending.c +++ b/src/map/vending.c @@ -48,7 +48,7 @@ void vending_vendinglistreq(struct map_session_data* sd, unsigned int id) { struct map_session_data* vsd; nullpo_retv(sd); - if( (vsd = iMap->id2sd(id)) == NULL ) + if( (vsd = map->id2sd(id)) == NULL ) return; if( !vsd->state.vending ) return; // not vending @@ -71,7 +71,7 @@ void vending_purchasereq(struct map_session_data* sd, int aid, unsigned int uid, int i, j, cursor, w, new_ = 0, blank, vend_list[MAX_VENDING]; double z; struct s_vending vend[MAX_VENDING]; // against duplicate packets - struct map_session_data* vsd = iMap->id2sd(aid); + struct map_session_data* vsd = map->id2sd(aid); nullpo_retv(sd); if( vsd == NULL || !vsd->state.vending || vsd->bl.id == sd->bl.id ) @@ -199,7 +199,7 @@ void vending_purchasereq(struct map_session_data* sd, int aid, unsigned int uid, vsd->vend_num = cursor; //Always save BOTH: buyer and customer - if( iMap->save_settings&2 ) { + if( map->save_settings&2 ) { chrif->save(sd,0); chrif->save(vsd,0); } @@ -211,7 +211,7 @@ void vending_purchasereq(struct map_session_data* sd, int aid, unsigned int uid, if( i == vsd->vend_num ) { //Close Vending (this was automatically done by the client, we have to do it manually for autovenders) [Skotlex] vending->close(vsd); - iMap->quit(vsd); //They have no reason to stay around anymore, do they? + map->quit(vsd); //They have no reason to stay around anymore, do they? } } } |