From b9889903e89bd4127c7503a512cfe215b9ccc740 Mon Sep 17 00:00:00 2001 From: Susu Date: Thu, 4 Jul 2013 12:20:51 +0200 Subject: - Added interface iStatus (needed to renamed it because A LOT of variables are already called 'status') --- src/map/elemental.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/map/elemental.c') diff --git a/src/map/elemental.c b/src/map/elemental.c index 53c85577b..839fa3640 100644 --- a/src/map/elemental.c +++ b/src/map/elemental.c @@ -244,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)); - status_set_viewdata(&ed->bl, ed->elemental.class_); + iStatus->set_viewdata(&ed->bl, ed->elemental.class_); ed->vd->head_mid = 10; // Why? - status_change_init(&ed->bl); + iStatus->change_init(&ed->bl); unit_dataset(&ed->bl); ed->ud.dir = sd->ud.dir; @@ -283,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 = status_skill2sc(skill_id); + sc_type type = iStatus->skill2sc(skill_id); nullpo_ret(ed); @@ -432,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 = iTimer->add_timer( tick+status_get_speed(&ed->bl)*walk_dist, skill->castend_pos, ed->bl.id, 0 ); + ed->ud.skilltimer = iTimer->add_timer( tick+iStatus->get_speed(&ed->bl)*walk_dist, skill->castend_pos, ed->bl.id, 0 ); else - ed->ud.skilltimer = iTimer->add_timer( tick+status_get_speed(&ed->bl)*walk_dist, skill->castend_id, ed->bl.id, 0 ); + ed->ud.skilltimer = iTimer->add_timer( tick+iStatus->get_speed(&ed->bl)*walk_dist, skill->castend_id, ed->bl.id, 0 ); } return 1; @@ -591,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( !status_check_skilluse(&ed->bl, bl, 0, 0) ) + if( !iStatus->check_skilluse(&ed->bl, bl, 0, 0) ) return 0; if( ed->target_id == 0 ) @@ -611,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 || !status_check_skilluse(&ed->bl, bl, 0, 0) ) + if( (*target) == bl || !iStatus->check_skilluse(&ed->bl, bl, 0, 0) ) return 0; if( battle->check_target(&ed->bl,bl,BCT_ENEMY) <= 0 ) -- cgit v1.2.3-70-g09d2 From 9d5309327da9543f86385549001df7e9a7c98833 Mon Sep 17 00:00:00 2001 From: Susu Date: Mon, 29 Jul 2013 15:28:48 +0200 Subject: Added elemental interface --- src/map/atcommand.c | 4 +- src/map/chrif.c | 4 +- src/map/duel.c | 2 +- src/map/duel.h | 2 +- src/map/elemental.c | 1928 ++++++++++++++++++++++++++------------------------- src/map/elemental.h | 200 +++--- src/map/intif.c | 2 +- src/map/map.c | 14 +- src/map/pc.c | 6 +- src/map/skill.c | 18 +- src/map/status.c | 10 +- src/map/unit.c | 8 +- 12 files changed, 1129 insertions(+), 1069 deletions(-) (limited to 'src/map/elemental.c') diff --git a/src/map/atcommand.c b/src/map/atcommand.c index d11fd9a9b..c14b8a26e 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -3600,7 +3600,7 @@ ACMD(reloadmobdb) { homun->reload(); read_mercenarydb(); read_mercenary_skilldb(); - reload_elementaldb(); + elemental->reload_elementaldb(); clif->message(fd, msg_txt(98)); // Monster database has been reloaded. return true; @@ -3614,7 +3614,7 @@ ACMD(reloadskilldb) nullpo_retr(-1, sd); skill->reload(); homun->reload_skill(); - reload_elemental_skilldb(); + elemental->reload_skilldb(); read_mercenary_skilldb(); clif->message(fd, msg_txt(99)); // Skill database has been reloaded. diff --git a/src/map/chrif.c b/src/map/chrif.c index 0fd14cd28..02e9e977c 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -314,8 +314,8 @@ int chrif_save(struct map_session_data *sd, int flag) { homun->save(sd->hd); if( sd->md && mercenary_get_lifetime(sd->md) > 0 ) mercenary_save(sd->md); - if( sd->ed && elemental_get_lifetime(sd->ed) > 0 ) - elemental_save(sd->ed); + if( sd->ed && elemental->get_lifetime(sd->ed) > 0 ) + elemental->save(sd->ed); if( sd->save_quest ) intif_quest_save(sd); diff --git a/src/map/duel.c b/src/map/duel.c index 80ef1b530..7a4e61fa0 100644 --- a/src/map/duel.c +++ b/src/map/duel.c @@ -185,7 +185,7 @@ void do_init_duel(void) * Generated by HerculesInterfaceMaker * created by Susu *-------------------------------------*/ -void duel_defaults(void) { +void iDuel_defaults(void) { iDuel = &iDuel_s; /* vars */ iDuel->duel_count = 0; diff --git a/src/map/duel.h b/src/map/duel.h index ec9c4bf83..9fa33833a 100644 --- a/src/map/duel.h +++ b/src/map/duel.h @@ -40,6 +40,6 @@ struct duel_interface { struct duel_interface *iDuel; -void duel_defaults(void); +void iDuel_defaults(void); #endif /* _DUEL_H_ */ diff --git a/src/map/elemental.c b/src/map/elemental.c index 839fa3640..3c212ccaa 100644 --- a/src/map/elemental.c +++ b/src/map/elemental.c @@ -1,944 +1,984 @@ -// 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" -#include "../common/socket.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/mmo.h" -#include "../common/showmsg.h" -#include "../common/utils.h" -#include "../common/random.h" -#include "../common/strlib.h" - -#include "log.h" -#include "clif.h" -#include "chrif.h" -#include "intif.h" -#include "itemdb.h" -#include "map.h" -#include "pc.h" -#include "status.h" -#include "skill.h" -#include "mob.h" -#include "pet.h" -#include "battle.h" -#include "party.h" -#include "guild.h" -#include "atcommand.h" -#include "script.h" -#include "npc.h" -#include "trade.h" -#include "unit.h" -#include "elemental.h" - -#include -#include -#include -#include - -struct s_elemental_db elemental_db[MAX_ELEMENTAL_CLASS]; // Elemental Database - -int elemental_search_index(int class_) { - int i; - 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); -} - -struct view_data * elemental_get_viewdata(int class_) { - int i = elemental_search_index(class_); - if( i < 0 ) - return 0; - - return &elemental_db[i].vd; -} - -int elemental_create(struct map_session_data *sd, int class_, unsigned int lifetime) { - struct s_elemental ele; - struct s_elemental_db *db; - int i; - - nullpo_retr(1,sd); - - if( (i = elemental_search_index(class_)) < 0 ) - return 0; - - db = &elemental_db[i]; - memset(&ele,0,sizeof(struct s_elemental)); - - ele.char_id = sd->status.char_id; - ele.class_ = class_; - 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] - 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 - ele.sp = ele.max_sp = sd->battle_status.max_sp/4; - //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) ] - ele.atk2 = sd->battle_status.max_sp / 18; - //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)] - ele.matk = i * (sd->battle_status.int_ / 2 + sd->battle_status.dex / 4); - //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) - ele.def = sd->battle_status.def + sd->status.base_level / (5-i); - //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) - ele.flee = sd->status.base_level / (5-i); - //Caster�s HIT + (Caster�s Base Level ) - ele.hit = sd->battle_status.hit + sd->status.base_level; - - //per individual bonuses - switch(db->class_){ - case 2114: case 2115: - case 2116: //ATK + (Summon Agni Skill Level x 20) / HIT + (Summon Agni Skill Level x 10) - ele.atk += i * 20; - ele.atk2 += i * 20; - ele.hit += i * 10; - break; - case 2117: case 2118: - case 2119: //MDEF + (Summon Aqua Skill Level x 10) / MATK + (Summon Aqua Skill Level x 20) - ele.mdef += i * 10; - ele.matk += i * 20; - break; - case 2120: case 2121: - case 2122: //FLEE + (Summon Ventus Skill Level x 20) / MATK + (Summon Ventus Skill Level x 10) - ele.flee += i * 20; - ele.matk += i * 10; - break; - case 2123: case 2124: - case 2125: //DEF + (Summon Tera Skill Level x 25) / ATK + (Summon Tera Skill Level x 5) - ele.def += i * 25; - ele.atk += i * 5; - ele.atk2 += i * 5; - break; - } - - if( (i=pc->checkskill(sd,SO_EL_SYMPATHY)) > 0 ){ - ele.hp = ele.max_hp = ele.max_hp * 5 * i / 100; - ele.sp = ele.max_sp = ele.max_sp * 5 * i / 100; - ele.atk += 25 * i; - ele.atk2 += 25 * i; - ele.matk += 25 * i; - } - - ele.life_time = lifetime; - - // Request Char Server to create this elemental - intif_elemental_create(&ele); - - return 1; -} - -int elemental_get_lifetime(struct elemental_data *ed) { - const struct TimerData * td; - if( ed == NULL || ed->summon_timer == INVALID_TIMER ) - return 0; - - td = iTimer->get_timer(ed->summon_timer); - return (td != NULL) ? DIFF_TICK(td->tick, iTimer->gettick()) : 0; -} - -int elemental_save(struct elemental_data *ed) { - ed->elemental.mode = ed->battle_status.mode; - ed->elemental.hp = ed->battle_status.hp; - ed->elemental.sp = ed->battle_status.sp; - ed->elemental.max_hp = ed->battle_status.max_hp; - ed->elemental.max_sp = ed->battle_status.max_sp; - ed->elemental.atk = ed->battle_status.rhw.atk; - ed->elemental.atk2 = ed->battle_status.rhw.atk2; - ed->elemental.matk = ed->battle_status.matk_min; - ed->elemental.def = ed->battle_status.def; - ed->elemental.mdef = ed->battle_status.mdef; - ed->elemental.flee = ed->battle_status.flee; - ed->elemental.hit = ed->battle_status.hit; - ed->elemental.life_time = elemental_get_lifetime(ed); - intif_elemental_save(&ed->elemental); - return 1; -} - -static int elemental_summon_end(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 ) - 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); - return 0; - } - - ed->summon_timer = INVALID_TIMER; - elemental_delete(ed, 0); // Elemental's summon time is over. - - return 0; -} - -void elemental_summon_stop(struct elemental_data *ed) { - nullpo_retv(ed); - if( ed->summon_timer != INVALID_TIMER ) - iTimer->delete_timer(ed->summon_timer, elemental_summon_end); - ed->summon_timer = INVALID_TIMER; -} - -int elemental_delete(struct elemental_data *ed, int reply) { - struct map_session_data *sd; - nullpo_ret(ed); - - sd = ed->master; - ed->elemental.life_time = 0; - - elemental_clean_effect(ed); - elemental_summon_stop(ed); - - if( !sd ) - return unit_free(&ed->bl, 0); - - sd->ed = NULL; - sd->status.ele_id = 0; - - return unit_remove_map(&ed->bl, 0); -} - -void elemental_summon_init(struct elemental_data *ed) { - if( ed->summon_timer == INVALID_TIMER ) - ed->summon_timer = iTimer->add_timer(iTimer->gettick() + ed->elemental.life_time, elemental_summon_end, ed->master->bl.id, 0); - - ed->regen.state.block = 0; -} - -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_); - - if( (sd = iMap->charid2sd(ele->char_id)) == NULL ) - return 0; - - if( !flag || i < 0 ) { // Not created - loaded - DB info - sd->status.ele_id = 0; - return 0; - } - - 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; - ed->bl.id = npc_get_new_npc_id(); - ed->master = sd; - ed->db = db; - memcpy(&ed->elemental, ele, sizeof(struct s_elemental)); - iStatus->set_viewdata(&ed->bl, ed->elemental.class_); - ed->vd->head_mid = 10; // Why? - iStatus->change_init(&ed->bl); - unit_dataset(&ed->bl); - ed->ud.dir = sd->ud.dir; - - ed->bl.m = sd->bl.m; - ed->bl.x = sd->bl.x; - ed->bl.y = sd->bl.y; - unit_calc_pos(&ed->bl, sd->bl.x, sd->bl.y, sd->ud.dir); - ed->bl.x = ed->ud.to_x; - ed->bl.y = ed->ud.to_y; - - iMap->addiddb(&ed->bl); - status_calc_elemental(ed,1); - ed->last_spdrain_time = ed->last_thinktime = iTimer->gettick(); - ed->summon_timer = INVALID_TIMER; - elemental_summon_init(ed); - } else { - memcpy(&sd->ed->elemental, ele, sizeof(struct s_elemental)); - ed = sd->ed; - } - - sd->status.ele_id = ele->elemental_id; - - if( ed->bl.prev == NULL && sd->bl.prev != NULL ) { - iMap->addblock(&ed->bl); - clif->spawn(&ed->bl); - clif->elemental_info(sd); - clif->elemental_updatestatus(sd,SP_HP); - clif->hpmeter_single(sd->fd,ed->bl.id,ed->battle_status.hp,ed->battle_status.max_hp); - clif->elemental_updatestatus(sd,SP_SP); - } - - return 1; -} - -int elemental_clean_single_effect(struct elemental_data *ed, uint16 skill_id) { - struct block_list *bl; - sc_type type = iStatus->skill2sc(skill_id); - - nullpo_ret(ed); - - bl = battle->get_master(&ed->bl); - - if( type ) { - switch( type ) { - // Just remove status change. - case SC_PYROTECHNIC_OPTION: - case SC_HEATER_OPTION: - case SC_TROPIC_OPTION: - case SC_FIRE_CLOAK_OPTION: - case SC_AQUAPLAY_OPTION: - case SC_WATER_SCREEN_OPTION: - case SC_COOLER_OPTION: - case SC_CHILLY_AIR_OPTION: - case SC_GUST_OPTION: - case SC_WIND_STEP_OPTION: - case SC_BLAST_OPTION: - case SC_WATER_DROP_OPTION: - case SC_WIND_CURTAIN_OPTION: - case SC_WILD_STORM_OPTION: - case SC_PETROLOGY_OPTION: - case SC_SOLID_SKIN_OPTION: - case SC_CURSED_SOIL_OPTION: - case SC_STONE_SHIELD_OPTION: - case SC_UPHEAVAL_OPTION: - case SC_CIRCLE_OF_FIRE_OPTION: - case SC_TIDAL_WEAPON_OPTION: - if( bl ) status_change_end(bl,type,INVALID_TIMER); // Master - status_change_end(&ed->bl,type-1,INVALID_TIMER); // Elemental Spirit - break; - case SC_ZEPHYR: - if( bl ) status_change_end(bl,type,INVALID_TIMER); - break; - default: - ShowWarning("Invalid SC=%d in elemental_clean_single_effect\n",type); - break; - } - } - - return 1; -} - -int elemental_clean_effect(struct elemental_data *ed) { - struct map_session_data *sd; - - nullpo_ret(ed); - - // Elemental side - status_change_end(&ed->bl, SC_TROPIC, INVALID_TIMER); - status_change_end(&ed->bl, SC_HEATER, INVALID_TIMER); - status_change_end(&ed->bl, SC_AQUAPLAY, INVALID_TIMER); - status_change_end(&ed->bl, SC_COOLER, INVALID_TIMER); - status_change_end(&ed->bl, SC_CHILLY_AIR, INVALID_TIMER); - status_change_end(&ed->bl, SC_PYROTECHNIC, INVALID_TIMER); - status_change_end(&ed->bl, SC_FIRE_CLOAK, INVALID_TIMER); - status_change_end(&ed->bl, SC_WATER_DROP, INVALID_TIMER); - status_change_end(&ed->bl, SC_WATER_SCREEN, INVALID_TIMER); - status_change_end(&ed->bl, SC_GUST, INVALID_TIMER); - status_change_end(&ed->bl, SC_WIND_STEP, INVALID_TIMER); - status_change_end(&ed->bl, SC_BLAST, INVALID_TIMER); - status_change_end(&ed->bl, SC_WIND_CURTAIN, INVALID_TIMER); - status_change_end(&ed->bl, SC_WILD_STORM, INVALID_TIMER); - status_change_end(&ed->bl, SC_PETROLOGY, INVALID_TIMER); - status_change_end(&ed->bl, SC_SOLID_SKIN, INVALID_TIMER); - status_change_end(&ed->bl, SC_CURSED_SOIL, INVALID_TIMER); - status_change_end(&ed->bl, SC_STONE_SHIELD, INVALID_TIMER); - status_change_end(&ed->bl, SC_UPHEAVAL, INVALID_TIMER); - status_change_end(&ed->bl, SC_CIRCLE_OF_FIRE, INVALID_TIMER); - status_change_end(&ed->bl, SC_TIDAL_WEAPON, INVALID_TIMER); - - if( (sd = ed->master) == NULL ) - return 0; - - // Master side - status_change_end(&sd->bl, SC_TROPIC_OPTION, INVALID_TIMER); - status_change_end(&sd->bl, SC_HEATER_OPTION, INVALID_TIMER); - status_change_end(&sd->bl, SC_AQUAPLAY_OPTION, INVALID_TIMER); - status_change_end(&sd->bl, SC_COOLER_OPTION, INVALID_TIMER); - status_change_end(&sd->bl, SC_CHILLY_AIR_OPTION, INVALID_TIMER); - status_change_end(&sd->bl, SC_PYROTECHNIC_OPTION, INVALID_TIMER); - status_change_end(&sd->bl, SC_FIRE_CLOAK_OPTION, INVALID_TIMER); - status_change_end(&sd->bl, SC_WATER_DROP_OPTION, INVALID_TIMER); - status_change_end(&sd->bl, SC_WATER_SCREEN_OPTION, INVALID_TIMER); - status_change_end(&sd->bl, SC_GUST_OPTION, INVALID_TIMER); - status_change_end(&sd->bl, SC_WIND_STEP_OPTION, INVALID_TIMER); - status_change_end(&sd->bl, SC_BLAST_OPTION, INVALID_TIMER); - status_change_end(&sd->bl, SC_WATER_DROP_OPTION, INVALID_TIMER); - status_change_end(&sd->bl, SC_WIND_CURTAIN_OPTION, INVALID_TIMER); - status_change_end(&sd->bl, SC_WILD_STORM_OPTION, INVALID_TIMER); - status_change_end(&sd->bl, SC_ZEPHYR, INVALID_TIMER); - status_change_end(&sd->bl, SC_WIND_STEP_OPTION, INVALID_TIMER); - status_change_end(&sd->bl, SC_PETROLOGY_OPTION, INVALID_TIMER); - status_change_end(&sd->bl, SC_SOLID_SKIN_OPTION, INVALID_TIMER); - status_change_end(&sd->bl, SC_CURSED_SOIL_OPTION, INVALID_TIMER); - status_change_end(&sd->bl, SC_STONE_SHIELD_OPTION, INVALID_TIMER); - status_change_end(&sd->bl, SC_UPHEAVAL_OPTION, INVALID_TIMER); - status_change_end(&sd->bl, SC_CIRCLE_OF_FIRE_OPTION, INVALID_TIMER); - status_change_end(&sd->bl, SC_TIDAL_WEAPON_OPTION, INVALID_TIMER); - - return 1; -} - -int elemental_action(struct elemental_data *ed, struct block_list *bl, unsigned int tick) { - struct skill_condition req; - uint16 skill_id, skill_lv; - int i; - - nullpo_ret(ed); - nullpo_ret(bl); - - if( !ed->master ) - return 0; - - if( ed->target_id ) - elemental_unlocktarget(ed); // Remove previous target. - - ARR_FIND(0, MAX_ELESKILLTREE, i, ed->db->skill[i].id && (ed->db->skill[i].mode&EL_SKILLMODE_AGGRESSIVE)); - if( i == MAX_ELESKILLTREE ) - return 0; - - skill_id = ed->db->skill[i].id; - skill_lv = ed->db->skill[i].lv; - - if( elemental_skillnotok(skill_id, ed) ) - return 0; - - if( ed->ud.skilltimer != INVALID_TIMER ) - return 0; - else if( DIFF_TICK(tick, ed->ud.canact_tick) < 0 ) - return 0; - - ed->target_id = ed->ud.skilltarget = bl->id; // Set new target - ed->last_thinktime = tick; - - // Not in skill range. - if( !battle->check_range(&ed->bl,bl,skill->get_range(skill_id,skill_lv)) ) { - // Try to walk to the target. - if( !unit_walktobl(&ed->bl, bl, skill->get_range(skill_id,skill_lv), 2) ) - elemental_unlocktarget(ed); - else { - // Walking, waiting to be in range. Client don't handle it, then we must handle it here. - int walk_dist = distance_bl(&ed->bl,bl) - skill->get_range(skill_id,skill_lv); - ed->ud.skill_id = skill_id; - ed->ud.skill_lv = skill_lv; - - if( skill->get_inf(skill_id) & INF_GROUND_SKILL ) - ed->ud.skilltimer = iTimer->add_timer( tick+iStatus->get_speed(&ed->bl)*walk_dist, skill->castend_pos, ed->bl.id, 0 ); - else - ed->ud.skilltimer = iTimer->add_timer( tick+iStatus->get_speed(&ed->bl)*walk_dist, skill->castend_id, ed->bl.id, 0 ); - } - return 1; - - } - - req = elemental_skill_get_requirements(skill_id, skill_lv); - - if(req.hp || req.sp){ - struct map_session_data *sd = BL_CAST(BL_PC, battle->get_master(&ed->bl)); - if( sd ){ - if( sd->skill_id_old != SO_EL_ACTION && //regardless of remaining HP/SP it can be cast - (status_get_hp(&ed->bl) < req.hp || status_get_sp(&ed->bl) < req.sp) ) - return 1; - else - status_zap(&ed->bl, req.hp, req.sp); - } - } - - //Otherwise, just cast the skill. - if( skill->get_inf(skill_id) & INF_GROUND_SKILL ) - unit_skilluse_pos(&ed->bl, bl->x, bl->y, skill_id, skill_lv); - else - unit_skilluse_id(&ed->bl, bl->id, skill_id, skill_lv); - - // Reset target. - ed->target_id = 0; - - return 1; -} - -/*=============================================================== - * Action that elemental perform after changing mode. - * Activates one of the skills of the new mode. - *-------------------------------------------------------------*/ -int elemental_change_mode_ack(struct elemental_data *ed, int mode) { - struct block_list *bl = &ed->master->bl; - uint16 skill_id, skill_lv; - int i; - - nullpo_ret(ed); - - if( !bl ) - return 0; - - // Select a skill. - ARR_FIND(0, MAX_ELESKILLTREE, i, ed->db->skill[i].id && (ed->db->skill[i].mode&mode)); - if( i == MAX_ELESKILLTREE ) - return 0; - - skill_id = ed->db->skill[i].id; - skill_lv = ed->db->skill[i].lv; - - if( elemental_skillnotok(skill_id, ed) ) - return 0; - - if( ed->ud.skilltimer != INVALID_TIMER ) - return 0; - else if( DIFF_TICK(iTimer->gettick(), ed->ud.canact_tick) < 0 ) - return 0; - - ed->target_id = bl->id; // Set new target - ed->last_thinktime = iTimer->gettick(); - - if( skill->get_inf(skill_id) & INF_GROUND_SKILL ) - unit_skilluse_pos(&ed->bl, bl->x, bl->y, skill_id, skill_lv); - else - unit_skilluse_id(&ed->bl,bl->id,skill_id,skill_lv); - - ed->target_id = 0; // Reset target after casting the skill to avoid continious attack. - - return 1; -} - -/*=============================================================== - * Change elemental mode. - *-------------------------------------------------------------*/ -int elemental_change_mode(struct elemental_data *ed, int mode) { - nullpo_ret(ed); - - // Remove target - elemental_unlocktarget(ed); - - // Removes the effects of the previous mode. - if(ed->elemental.mode != mode ) elemental_clean_effect(ed); - - ed->battle_status.mode = ed->elemental.mode = mode; - - // Normalize elemental mode to elemental skill mode. - if( mode == EL_MODE_AGGRESSIVE ) mode = EL_SKILLMODE_AGGRESSIVE; // Aggressive spirit mode -> Aggressive spirit skill. - else if( mode == EL_MODE_ASSIST ) mode = EL_SKILLMODE_ASSIST; // Assist spirit mode -> Assist spirit skill. - else mode = EL_SKILLMODE_PASIVE; // Passive spirit mode -> Passive spirit skill. - - // Use a skill inmediately after every change mode. - if( mode != EL_SKILLMODE_AGGRESSIVE ) - elemental_change_mode_ack(ed,mode); - return 1; -} - -void elemental_heal(struct elemental_data *ed, int hp, int sp) { - if( hp ) - clif->elemental_updatestatus(ed->master, SP_HP); - if( sp ) - clif->elemental_updatestatus(ed->master, SP_SP); -} - -int elemental_dead(struct elemental_data *ed) { - elemental_delete(ed, 1); - return 0; -} - -int elemental_unlocktarget(struct elemental_data *ed) { - nullpo_ret(ed); - - ed->target_id = 0; - elemental_stop_attack(ed); - elemental_stop_walking(ed,1); - return 0; -} - -int elemental_skillnotok(uint16 skill_id, struct elemental_data *ed) { - int idx = skill->get_index(skill_id); - nullpo_retr(1,ed); - - if (idx == 0) - return 1; // invalid skill id - - return skill->not_ok(skill_id, ed->master); -} - -struct skill_condition elemental_skill_get_requirements(uint16 skill_id, uint16 skill_lv){ - struct skill_condition req; - int idx = skill->get_index(skill_id); - - memset(&req,0,sizeof(req)); - - if( idx == 0 ) // invalid skill id - return req; - - 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]; - - return req; -} - -int elemental_set_target( struct map_session_data *sd, struct block_list *bl ) { - struct elemental_data *ed = sd->ed; - - nullpo_ret(ed); - nullpo_ret(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) ) - return 0; - - if( ed->target_id == 0 ) - ed->target_id = bl->id; - - return 1; -} - -static int elemental_ai_sub_timer_activesearch(struct block_list *bl, va_list ap) { - struct elemental_data *ed; - struct block_list **target; - int dist; - - nullpo_ret(bl); - - ed = va_arg(ap,struct elemental_data *); - 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) ) - return 0; - - if( battle->check_target(&ed->bl,bl,BCT_ENEMY) <= 0 ) - return 0; - - switch( bl->type ) { - case BL_PC: - if( !map_flag_vs(ed->bl.m) ) - return 0; - default: - dist = distance_bl(&ed->bl, bl); - if( ((*target) == NULL || !check_distance_bl(&ed->bl, *target, dist)) && battle->check_range(&ed->bl,bl,ed->db->range2) ) { //Pick closest target? - (*target) = bl; - ed->target_id = bl->id; - ed->min_chase = dist + ed->db->range3; - if( ed->min_chase > AREA_SIZE ) - ed->min_chase = AREA_SIZE; - return 1; - } - break; - } - return 0; -} - -static 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; - - nullpo_ret(ed); - nullpo_ret(sd); - - if( ed->bl.prev == NULL || sd == NULL || sd->bl.prev == NULL ) - return 0; - - // Check if caster can sustain the summoned elemental - if( DIFF_TICK(tick,ed->last_spdrain_time) >= 10000 ){// Drain SP every 10 seconds - int sp = 5; - - switch(ed->vd->class_){ - case 2115: case 2118: - case 2121: case 2124: - sp = 8; - break; - case 2116: case 2119: - case 2122: case 2125: - sp = 11; - break; - } - - if( status_get_sp(&sd->bl) < sp ){ // Can't sustain delete it. - elemental_delete(sd->ed,0); - return 0; - } - - status_zap(&sd->bl,0,sp); - ed->last_spdrain_time = tick; - } - - if( DIFF_TICK(tick,ed->last_thinktime) < MIN_ELETHINKTIME ) - return 0; - - ed->last_thinktime = tick; - - if( ed->ud.skilltimer != INVALID_TIMER ) - return 0; - - if( ed->ud.walktimer != INVALID_TIMER && ed->ud.walkpath.path_pos <= 2 ) - return 0; //No thinking when you just started to walk. - - if(ed->ud.walkpath.path_pos < ed->ud.walkpath.path_len && ed->ud.target == sd->bl.id) - return 0; //No thinking until be near the master. - - if( ed->sc.count && ed->sc.data[SC_BLIND] ) - view_range = 3; - else - view_range = ed->db->range2; - - mode = status_get_mode(&ed->bl); - - master_dist = distance_bl(&sd->bl, &ed->bl); - if( master_dist > AREA_SIZE ) { // Master out of vision range. - elemental_unlocktarget(ed); - unit_warp(&ed->bl,sd->bl.m,sd->bl.x,sd->bl.y,CLR_TELEPORT); - clif->elemental_updatestatus(sd,SP_HP); - clif->elemental_updatestatus(sd,SP_SP); - return 0; - } else if( master_dist > MAX_ELEDISTANCE ) { // Master too far, chase. - short x = sd->bl.x, y = sd->bl.y; - if( ed->target_id ) - elemental_unlocktarget(ed); - if( ed->ud.walktimer != INVALID_TIMER && ed->ud.target == sd->bl.id ) - 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) ) - return 0; - } - - if( mode == EL_MODE_AGGRESSIVE ) { - target = iMap->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)); - - if( !target ) { //No targets available. - elemental_unlocktarget(ed); - return 1; - } - - if( battle->check_range(&ed->bl,target,view_range) && rnd()%100 < 2 ) { // 2% chance to cast attack skill. - if( elemental_action(ed,target,tick) ) - return 1; - } - - //Attempt to attack. - //At this point we know the target is attackable, we just gotta check if the range matches. - if( ed->ud.target == target->id && ed->ud.attacktimer != INVALID_TIMER ) //Already locked. - return 1; - - if( battle->check_range(&ed->bl, target, ed->base_status.rhw.range) ) {//Target within range, engage - unit_attack(&ed->bl,target->id,1); - return 1; - } - - //Follow up if possible. - if( !unit_walktobl(&ed->bl, target, ed->base_status.rhw.range, 2) ) - elemental_unlocktarget(ed); - } - - return 0; -} - -static 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); - - 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); - return 0; -} - -int read_elementaldb(void) { - FILE *fp; - char line[1024], *p; - char *str[26]; - int i, j = 0, k = 0, ele; - struct s_elemental_db *db; - struct status_data *status; - - sprintf(line, "%s/%s", iMap->db_path, "elemental_db.txt"); - memset(elemental_db,0,sizeof(elemental_db)); - - fp = fopen(line, "r"); - if( !fp ) { - ShowError("read_elementaldb : can't read elemental_db.txt\n"); - return -1; - } - - while( fgets(line, sizeof(line), fp) && j < MAX_ELEMENTAL_CLASS ) { - k++; - if( line[0] == '/' && line[1] == '/' ) - continue; - - if( line[0] == '\0' || line[0] == '\n' || line[0] == '\r') - continue; - - i = 0; - p = strtok(line, ","); - while( p != NULL && i < 26 ) { - str[i++] = p; - p = strtok(NULL, ","); - } - if( i < 26 ) { - ShowError("read_elementaldb : Incorrect number of columns at elemental_db.txt line %d.\n", k); - continue; - } - - db = &elemental_db[j]; - db->class_ = atoi(str[0]); - safestrncpy(db->sprite, str[1], NAME_LENGTH); - safestrncpy(db->name, str[2], NAME_LENGTH); - db->lv = atoi(str[3]); - - status = &db->status; - db->vd.class_ = db->class_; - - status->max_hp = atoi(str[4]); - status->max_sp = atoi(str[5]); - status->rhw.range = atoi(str[6]); - status->rhw.atk = atoi(str[7]); - status->rhw.atk2 = atoi(str[8]); - status->def = atoi(str[9]); - status->mdef = atoi(str[10]); - status->str = atoi(str[11]); - status->agi = atoi(str[12]); - status->vit = atoi(str[13]); - status->int_ = atoi(str[14]); - status->dex = atoi(str[15]); - status->luk = atoi(str[16]); - db->range2 = atoi(str[17]); - db->range3 = atoi(str[18]); - status->size = atoi(str[19]); - status->race = atoi(str[20]); - - ele = atoi(str[21]); - status->def_ele = ele%10; - status->ele_lv = ele/20; - if( status->def_ele >= ELE_MAX ) { - ShowWarning("Elemental %d has invalid element type %d (max element is %d)\n", db->class_, status->def_ele, ELE_MAX - 1); - status->def_ele = ELE_NEUTRAL; - } - if( status->ele_lv < 1 || status->ele_lv > 4 ) { - ShowWarning("Elemental %d has invalid element level %d (max is 4)\n", db->class_, status->ele_lv); - status->ele_lv = 1; - } - - status->aspd_rate = 1000; - status->speed = atoi(str[22]); - status->adelay = atoi(str[23]); - status->amotion = atoi(str[24]); - status->dmotion = atoi(str[25]); - - j++; - } - - fclose(fp); - ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' elementals in '"CL_WHITE"db/elemental_db.txt"CL_RESET"'.\n",j); - - return 0; -} - -int read_elemental_skilldb(void) { - FILE *fp; - char line[1024], *p; - char *str[4]; - struct s_elemental_db *db; - int i, j = 0, k = 0, class_; - uint16 skill_id, skill_lv; - int skillmode; - - sprintf(line, "%s/%s", iMap->db_path, "elemental_skill_db.txt"); - fp = fopen(line, "r"); - if( !fp ) { - ShowError("read_elemental_skilldb : can't read elemental_skill_db.txt\n"); - return -1; - } - - while( fgets(line, sizeof(line), fp) ) { - k++; - if( line[0] == '/' && line[1] == '/' ) - continue; - - if( line[0] == '\0' || line[0] == '\n' || line[0] == '\r') - continue; - - i = 0; - p = strtok(line, ","); - while( p != NULL && i < 4 ) { - str[i++] = p; - p = strtok(NULL, ","); - } - if( i < 4 ) { - ShowError("read_elemental_skilldb : Incorrect number of columns at elemental_skill_db.txt line %d.\n", k); - continue; - } - - class_ = atoi(str[0]); - 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; - } - - skill_id = atoi(str[1]); - if( skill_id < EL_SKILLBASE || skill_id >= EL_SKILLBASE + MAX_ELEMENTALSKILL ) { - ShowError("read_elemental_skilldb : Skill out of range, line %d.\n", k); - continue; - } - - db = &elemental_db[i]; - skill_lv = atoi(str[2]); - - skillmode = atoi(str[3]); - if( skillmode < EL_SKILLMODE_PASIVE || skillmode > EL_SKILLMODE_AGGRESSIVE ) { - ShowError("read_elemental_skilldb : Skillmode out of range, line %d.\n",k); - continue; - } - ARR_FIND( 0, MAX_ELESKILLTREE, i, db->skill[i].id == 0 || db->skill[i].id == skill_id ); - if( i == MAX_ELESKILLTREE ) { - ShowWarning("Unable to load skill %d into Elemental %d's tree. Maximum number of skills per elemental has been reached.\n", skill_id, class_); - continue; - } - db->skill[i].id = skill_id; - db->skill[i].lv = skill_lv; - db->skill[i].mode = skillmode; - j++; - } - - fclose(fp); - ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"db/elemental_skill_db.txt"CL_RESET"'.\n",j); - return 0; -} - -void reload_elementaldb(void) { - read_elementaldb(); - reload_elemental_skilldb(); -} - -void reload_elemental_skilldb(void) { - read_elemental_skilldb(); -} - -int do_init_elemental(void) { - read_elementaldb(); - read_elemental_skilldb(); - - iTimer->add_timer_func_list(elemental_ai_timer,"elemental_ai_timer"); - iTimer->add_timer_interval(iTimer->gettick()+MIN_ELETHINKTIME,elemental_ai_timer,0,0,MIN_ELETHINKTIME); - - return 0; -} - -void do_final_elemental(void) { - return; -} +// 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" +#include "../common/socket.h" +#include "../common/timer.h" +#include "../common/nullpo.h" +#include "../common/mmo.h" +#include "../common/showmsg.h" +#include "../common/utils.h" +#include "../common/random.h" +#include "../common/strlib.h" + +#include "log.h" +#include "clif.h" +#include "chrif.h" +#include "intif.h" +#include "itemdb.h" +#include "map.h" +#include "pc.h" +#include "status.h" +#include "skill.h" +#include "mob.h" +#include "pet.h" +#include "battle.h" +#include "party.h" +#include "guild.h" +#include "atcommand.h" +#include "script.h" +#include "npc.h" +#include "trade.h" +#include "unit.h" +#include "elemental.h" + +#include +#include +#include +#include + +int elemental_search_index(int class_) { + int i; + ARR_FIND(0, MAX_ELEMENTAL_CLASS, i, elemental->elemental_db[i].class_ == class_); + return (i == MAX_ELEMENTAL_CLASS)?-1:i; +} + +bool elemental_class(int class_) { + return (bool)(elemental_search_index(class_) > -1); +} + +struct view_data * elemental_get_viewdata(int class_) { + int i = elemental_search_index(class_); + if( i < 0 ) + return 0; + + return &elemental->elemental_db[i].vd; +} + +int elemental_create(struct map_session_data *sd, int class_, unsigned int lifetime) { + struct s_elemental ele; + struct s_elemental_db *db; + int i; + + nullpo_retr(1,sd); + + if( (i = elemental_search_index(class_)) < 0 ) + return 0; + + db = &elemental->elemental_db[i]; + memset(&ele,0,sizeof(struct s_elemental)); + + ele.char_id = sd->status.char_id; + ele.class_ = class_; + 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] + 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 + ele.sp = ele.max_sp = sd->battle_status.max_sp/4; + //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) ] + ele.atk2 = sd->battle_status.max_sp / 18; + //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)] + ele.matk = i * (sd->battle_status.int_ / 2 + sd->battle_status.dex / 4); + //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) + ele.def = sd->battle_status.def + sd->status.base_level / (5-i); + //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) + ele.flee = sd->status.base_level / (5-i); + //Caster�s HIT + (Caster�s Base Level ) + ele.hit = sd->battle_status.hit + sd->status.base_level; + + //per individual bonuses + switch(db->class_){ + case 2114: case 2115: + case 2116: //ATK + (Summon Agni Skill Level x 20) / HIT + (Summon Agni Skill Level x 10) + ele.atk += i * 20; + ele.atk2 += i * 20; + ele.hit += i * 10; + break; + case 2117: case 2118: + case 2119: //MDEF + (Summon Aqua Skill Level x 10) / MATK + (Summon Aqua Skill Level x 20) + ele.mdef += i * 10; + ele.matk += i * 20; + break; + case 2120: case 2121: + case 2122: //FLEE + (Summon Ventus Skill Level x 20) / MATK + (Summon Ventus Skill Level x 10) + ele.flee += i * 20; + ele.matk += i * 10; + break; + case 2123: case 2124: + case 2125: //DEF + (Summon Tera Skill Level x 25) / ATK + (Summon Tera Skill Level x 5) + ele.def += i * 25; + ele.atk += i * 5; + ele.atk2 += i * 5; + break; + } + + if( (i=pc->checkskill(sd,SO_EL_SYMPATHY)) > 0 ){ + ele.hp = ele.max_hp = ele.max_hp * 5 * i / 100; + ele.sp = ele.max_sp = ele.max_sp * 5 * i / 100; + ele.atk += 25 * i; + ele.atk2 += 25 * i; + ele.matk += 25 * i; + } + + ele.life_time = lifetime; + + // Request Char Server to create this elemental + intif_elemental_create(&ele); + + return 1; +} + +int elemental_get_lifetime(struct elemental_data *ed) { + const struct TimerData * td; + if( ed == NULL || ed->summon_timer == INVALID_TIMER ) + return 0; + + td = iTimer->get_timer(ed->summon_timer); + return (td != NULL) ? DIFF_TICK(td->tick, iTimer->gettick()) : 0; +} + +int elemental_save(struct elemental_data *ed) { + ed->elemental.mode = ed->battle_status.mode; + ed->elemental.hp = ed->battle_status.hp; + ed->elemental.sp = ed->battle_status.sp; + ed->elemental.max_hp = ed->battle_status.max_hp; + ed->elemental.max_sp = ed->battle_status.max_sp; + ed->elemental.atk = ed->battle_status.rhw.atk; + ed->elemental.atk2 = ed->battle_status.rhw.atk2; + ed->elemental.matk = ed->battle_status.matk_min; + ed->elemental.def = ed->battle_status.def; + ed->elemental.mdef = ed->battle_status.mdef; + ed->elemental.flee = ed->battle_status.flee; + ed->elemental.hit = ed->battle_status.hit; + ed->elemental.life_time = elemental->get_lifetime(ed); + intif_elemental_save(&ed->elemental); + return 1; +} + +static int elemental_summon_end(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 ) + 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); + return 0; + } + + ed->summon_timer = INVALID_TIMER; + elemental->delete(ed, 0); // Elemental's summon time is over. + + return 0; +} + +void elemental_summon_stop(struct elemental_data *ed) { + nullpo_retv(ed); + if( ed->summon_timer != INVALID_TIMER ) + iTimer->delete_timer(ed->summon_timer, elemental_summon_end); + ed->summon_timer = INVALID_TIMER; +} + +int elemental_delete(struct elemental_data *ed, int reply) { + struct map_session_data *sd; + nullpo_ret(ed); + + sd = ed->master; + ed->elemental.life_time = 0; + + elemental->clean_effect(ed); + elemental->summon_stop(ed); + + if( !sd ) + return unit_free(&ed->bl, 0); + + sd->ed = NULL; + sd->status.ele_id = 0; + + return unit_remove_map(&ed->bl, 0); +} + +void elemental_summon_init(struct elemental_data *ed) { + if( ed->summon_timer == INVALID_TIMER ) + ed->summon_timer = iTimer->add_timer(iTimer->gettick() + ed->elemental.life_time, elemental_summon_end, ed->master->bl.id, 0); + + ed->regen.state.block = 0; +} + +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_); + + if( (sd = iMap->charid2sd(ele->char_id)) == NULL ) + return 0; + + if( !flag || i < 0 ) { // Not created - loaded - DB info + sd->status.ele_id = 0; + return 0; + } + + db = &elemental->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; + ed->bl.id = npc_get_new_npc_id(); + ed->master = sd; + ed->db = db; + memcpy(&ed->elemental, ele, sizeof(struct s_elemental)); + iStatus->set_viewdata(&ed->bl, ed->elemental.class_); + ed->vd->head_mid = 10; // Why? + iStatus->change_init(&ed->bl); + unit_dataset(&ed->bl); + ed->ud.dir = sd->ud.dir; + + ed->bl.m = sd->bl.m; + ed->bl.x = sd->bl.x; + ed->bl.y = sd->bl.y; + unit_calc_pos(&ed->bl, sd->bl.x, sd->bl.y, sd->ud.dir); + ed->bl.x = ed->ud.to_x; + ed->bl.y = ed->ud.to_y; + + iMap->addiddb(&ed->bl); + status_calc_elemental(ed,1); + ed->last_spdrain_time = ed->last_thinktime = iTimer->gettick(); + ed->summon_timer = INVALID_TIMER; + elemental_summon_init(ed); + } else { + memcpy(&sd->ed->elemental, ele, sizeof(struct s_elemental)); + ed = sd->ed; + } + + sd->status.ele_id = ele->elemental_id; + + if( ed->bl.prev == NULL && sd->bl.prev != NULL ) { + iMap->addblock(&ed->bl); + clif->spawn(&ed->bl); + clif->elemental_info(sd); + clif->elemental_updatestatus(sd,SP_HP); + clif->hpmeter_single(sd->fd,ed->bl.id,ed->battle_status.hp,ed->battle_status.max_hp); + clif->elemental_updatestatus(sd,SP_SP); + } + + return 1; +} + +int elemental_clean_single_effect(struct elemental_data *ed, uint16 skill_id) { + struct block_list *bl; + sc_type type = iStatus->skill2sc(skill_id); + + nullpo_ret(ed); + + bl = battle->get_master(&ed->bl); + + if( type ) { + switch( type ) { + // Just remove status change. + case SC_PYROTECHNIC_OPTION: + case SC_HEATER_OPTION: + case SC_TROPIC_OPTION: + case SC_FIRE_CLOAK_OPTION: + case SC_AQUAPLAY_OPTION: + case SC_WATER_SCREEN_OPTION: + case SC_COOLER_OPTION: + case SC_CHILLY_AIR_OPTION: + case SC_GUST_OPTION: + case SC_WIND_STEP_OPTION: + case SC_BLAST_OPTION: + case SC_WATER_DROP_OPTION: + case SC_WIND_CURTAIN_OPTION: + case SC_WILD_STORM_OPTION: + case SC_PETROLOGY_OPTION: + case SC_SOLID_SKIN_OPTION: + case SC_CURSED_SOIL_OPTION: + case SC_STONE_SHIELD_OPTION: + case SC_UPHEAVAL_OPTION: + case SC_CIRCLE_OF_FIRE_OPTION: + case SC_TIDAL_WEAPON_OPTION: + if( bl ) status_change_end(bl,type,INVALID_TIMER); // Master + status_change_end(&ed->bl,type-1,INVALID_TIMER); // Elemental Spirit + break; + case SC_ZEPHYR: + if( bl ) status_change_end(bl,type,INVALID_TIMER); + break; + default: + ShowWarning("Invalid SC=%d in elemental_clean_single_effect\n",type); + break; + } + } + + return 1; +} + +int elemental_clean_effect(struct elemental_data *ed) { + struct map_session_data *sd; + + nullpo_ret(ed); + + // Elemental side + status_change_end(&ed->bl, SC_TROPIC, INVALID_TIMER); + status_change_end(&ed->bl, SC_HEATER, INVALID_TIMER); + status_change_end(&ed->bl, SC_AQUAPLAY, INVALID_TIMER); + status_change_end(&ed->bl, SC_COOLER, INVALID_TIMER); + status_change_end(&ed->bl, SC_CHILLY_AIR, INVALID_TIMER); + status_change_end(&ed->bl, SC_PYROTECHNIC, INVALID_TIMER); + status_change_end(&ed->bl, SC_FIRE_CLOAK, INVALID_TIMER); + status_change_end(&ed->bl, SC_WATER_DROP, INVALID_TIMER); + status_change_end(&ed->bl, SC_WATER_SCREEN, INVALID_TIMER); + status_change_end(&ed->bl, SC_GUST, INVALID_TIMER); + status_change_end(&ed->bl, SC_WIND_STEP, INVALID_TIMER); + status_change_end(&ed->bl, SC_BLAST, INVALID_TIMER); + status_change_end(&ed->bl, SC_WIND_CURTAIN, INVALID_TIMER); + status_change_end(&ed->bl, SC_WILD_STORM, INVALID_TIMER); + status_change_end(&ed->bl, SC_PETROLOGY, INVALID_TIMER); + status_change_end(&ed->bl, SC_SOLID_SKIN, INVALID_TIMER); + status_change_end(&ed->bl, SC_CURSED_SOIL, INVALID_TIMER); + status_change_end(&ed->bl, SC_STONE_SHIELD, INVALID_TIMER); + status_change_end(&ed->bl, SC_UPHEAVAL, INVALID_TIMER); + status_change_end(&ed->bl, SC_CIRCLE_OF_FIRE, INVALID_TIMER); + status_change_end(&ed->bl, SC_TIDAL_WEAPON, INVALID_TIMER); + + if( (sd = ed->master) == NULL ) + return 0; + + // Master side + status_change_end(&sd->bl, SC_TROPIC_OPTION, INVALID_TIMER); + status_change_end(&sd->bl, SC_HEATER_OPTION, INVALID_TIMER); + status_change_end(&sd->bl, SC_AQUAPLAY_OPTION, INVALID_TIMER); + status_change_end(&sd->bl, SC_COOLER_OPTION, INVALID_TIMER); + status_change_end(&sd->bl, SC_CHILLY_AIR_OPTION, INVALID_TIMER); + status_change_end(&sd->bl, SC_PYROTECHNIC_OPTION, INVALID_TIMER); + status_change_end(&sd->bl, SC_FIRE_CLOAK_OPTION, INVALID_TIMER); + status_change_end(&sd->bl, SC_WATER_DROP_OPTION, INVALID_TIMER); + status_change_end(&sd->bl, SC_WATER_SCREEN_OPTION, INVALID_TIMER); + status_change_end(&sd->bl, SC_GUST_OPTION, INVALID_TIMER); + status_change_end(&sd->bl, SC_WIND_STEP_OPTION, INVALID_TIMER); + status_change_end(&sd->bl, SC_BLAST_OPTION, INVALID_TIMER); + status_change_end(&sd->bl, SC_WATER_DROP_OPTION, INVALID_TIMER); + status_change_end(&sd->bl, SC_WIND_CURTAIN_OPTION, INVALID_TIMER); + status_change_end(&sd->bl, SC_WILD_STORM_OPTION, INVALID_TIMER); + status_change_end(&sd->bl, SC_ZEPHYR, INVALID_TIMER); + status_change_end(&sd->bl, SC_WIND_STEP_OPTION, INVALID_TIMER); + status_change_end(&sd->bl, SC_PETROLOGY_OPTION, INVALID_TIMER); + status_change_end(&sd->bl, SC_SOLID_SKIN_OPTION, INVALID_TIMER); + status_change_end(&sd->bl, SC_CURSED_SOIL_OPTION, INVALID_TIMER); + status_change_end(&sd->bl, SC_STONE_SHIELD_OPTION, INVALID_TIMER); + status_change_end(&sd->bl, SC_UPHEAVAL_OPTION, INVALID_TIMER); + status_change_end(&sd->bl, SC_CIRCLE_OF_FIRE_OPTION, INVALID_TIMER); + status_change_end(&sd->bl, SC_TIDAL_WEAPON_OPTION, INVALID_TIMER); + + return 1; +} + +int elemental_action(struct elemental_data *ed, struct block_list *bl, unsigned int tick) { + struct skill_condition req; + uint16 skill_id, skill_lv; + int i; + + nullpo_ret(ed); + nullpo_ret(bl); + + if( !ed->master ) + return 0; + + if( ed->target_id ) + elemental->unlocktarget(ed); // Remove previous target. + + ARR_FIND(0, MAX_ELESKILLTREE, i, ed->db->skill[i].id && (ed->db->skill[i].mode&EL_SKILLMODE_AGGRESSIVE)); + if( i == MAX_ELESKILLTREE ) + return 0; + + skill_id = ed->db->skill[i].id; + skill_lv = ed->db->skill[i].lv; + + if( elemental->skillnotok(skill_id, ed) ) + return 0; + + if( ed->ud.skilltimer != INVALID_TIMER ) + return 0; + else if( DIFF_TICK(tick, ed->ud.canact_tick) < 0 ) + return 0; + + ed->target_id = ed->ud.skilltarget = bl->id; // Set new target + ed->last_thinktime = tick; + + // Not in skill range. + if( !battle->check_range(&ed->bl,bl,skill->get_range(skill_id,skill_lv)) ) { + // Try to walk to the target. + if( !unit_walktobl(&ed->bl, bl, skill->get_range(skill_id,skill_lv), 2) ) + elemental->unlocktarget(ed); + else { + // Walking, waiting to be in range. Client don't handle it, then we must handle it here. + int walk_dist = distance_bl(&ed->bl,bl) - skill->get_range(skill_id,skill_lv); + ed->ud.skill_id = skill_id; + ed->ud.skill_lv = skill_lv; + + if( skill->get_inf(skill_id) & INF_GROUND_SKILL ) + ed->ud.skilltimer = iTimer->add_timer( tick+iStatus->get_speed(&ed->bl)*walk_dist, skill->castend_pos, ed->bl.id, 0 ); + else + ed->ud.skilltimer = iTimer->add_timer( tick+iStatus->get_speed(&ed->bl)*walk_dist, skill->castend_id, ed->bl.id, 0 ); + } + return 1; + + } + + req = elemental->skill_get_requirements(skill_id, skill_lv); + + if(req.hp || req.sp){ + struct map_session_data *sd = BL_CAST(BL_PC, battle->get_master(&ed->bl)); + if( sd ){ + if( sd->skill_id_old != SO_EL_ACTION && //regardless of remaining HP/SP it can be cast + (status_get_hp(&ed->bl) < req.hp || status_get_sp(&ed->bl) < req.sp) ) + return 1; + else + status_zap(&ed->bl, req.hp, req.sp); + } + } + + //Otherwise, just cast the skill. + if( skill->get_inf(skill_id) & INF_GROUND_SKILL ) + unit_skilluse_pos(&ed->bl, bl->x, bl->y, skill_id, skill_lv); + else + unit_skilluse_id(&ed->bl, bl->id, skill_id, skill_lv); + + // Reset target. + ed->target_id = 0; + + return 1; +} + +/*=============================================================== + * Action that elemental perform after changing mode. + * Activates one of the skills of the new mode. + *-------------------------------------------------------------*/ +int elemental_change_mode_ack(struct elemental_data *ed, int mode) { + struct block_list *bl = &ed->master->bl; + uint16 skill_id, skill_lv; + int i; + + nullpo_ret(ed); + + if( !bl ) + return 0; + + // Select a skill. + ARR_FIND(0, MAX_ELESKILLTREE, i, ed->db->skill[i].id && (ed->db->skill[i].mode&mode)); + if( i == MAX_ELESKILLTREE ) + return 0; + + skill_id = ed->db->skill[i].id; + skill_lv = ed->db->skill[i].lv; + + if( elemental->skillnotok(skill_id, ed) ) + return 0; + + if( ed->ud.skilltimer != INVALID_TIMER ) + return 0; + else if( DIFF_TICK(iTimer->gettick(), ed->ud.canact_tick) < 0 ) + return 0; + + ed->target_id = bl->id; // Set new target + ed->last_thinktime = iTimer->gettick(); + + if( skill->get_inf(skill_id) & INF_GROUND_SKILL ) + unit_skilluse_pos(&ed->bl, bl->x, bl->y, skill_id, skill_lv); + else + unit_skilluse_id(&ed->bl,bl->id,skill_id,skill_lv); + + ed->target_id = 0; // Reset target after casting the skill to avoid continious attack. + + return 1; +} + +/*=============================================================== + * Change elemental mode. + *-------------------------------------------------------------*/ +int elemental_change_mode(struct elemental_data *ed, int mode) { + nullpo_ret(ed); + + // Remove target + elemental->unlocktarget(ed); + + // Removes the effects of the previous mode. + if(ed->elemental.mode != mode ) elemental->clean_effect(ed); + + ed->battle_status.mode = ed->elemental.mode = mode; + + // Normalize elemental mode to elemental skill mode. + if( mode == EL_MODE_AGGRESSIVE ) mode = EL_SKILLMODE_AGGRESSIVE; // Aggressive spirit mode -> Aggressive spirit skill. + else if( mode == EL_MODE_ASSIST ) mode = EL_SKILLMODE_ASSIST; // Assist spirit mode -> Assist spirit skill. + else mode = EL_SKILLMODE_PASIVE; // Passive spirit mode -> Passive spirit skill. + + // Use a skill inmediately after every change mode. + if( mode != EL_SKILLMODE_AGGRESSIVE ) + elemental->change_mode_ack(ed,mode); + return 1; +} + +void elemental_heal(struct elemental_data *ed, int hp, int sp) { + if( hp ) + clif->elemental_updatestatus(ed->master, SP_HP); + if( sp ) + clif->elemental_updatestatus(ed->master, SP_SP); +} + +int elemental_dead(struct elemental_data *ed) { + elemental->delete(ed, 1); + return 0; +} + +int elemental_unlocktarget(struct elemental_data *ed) { + nullpo_ret(ed); + + ed->target_id = 0; + elemental_stop_attack(ed); + elemental_stop_walking(ed,1); + return 0; +} + +int elemental_skillnotok(uint16 skill_id, struct elemental_data *ed) { + int idx = skill->get_index(skill_id); + nullpo_retr(1,ed); + + if (idx == 0) + return 1; // invalid skill id + + return skill->not_ok(skill_id, ed->master); +} + +struct skill_condition elemental_skill_get_requirements(uint16 skill_id, uint16 skill_lv){ + struct skill_condition req; + int idx = skill->get_index(skill_id); + + memset(&req,0,sizeof(req)); + + if( idx == 0 ) // invalid skill id + return req; + + 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]; + + return req; +} + +int elemental_set_target( struct map_session_data *sd, struct block_list *bl ) { + struct elemental_data *ed = sd->ed; + + nullpo_ret(ed); + nullpo_ret(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) ) + return 0; + + if( ed->target_id == 0 ) + ed->target_id = bl->id; + + return 1; +} + +static int elemental_ai_sub_timer_activesearch(struct block_list *bl, va_list ap) { + struct elemental_data *ed; + struct block_list **target; + int dist; + + nullpo_ret(bl); + + ed = va_arg(ap,struct elemental_data *); + 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) ) + return 0; + + if( battle->check_target(&ed->bl,bl,BCT_ENEMY) <= 0 ) + return 0; + + switch( bl->type ) { + case BL_PC: + if( !map_flag_vs(ed->bl.m) ) + return 0; + default: + dist = distance_bl(&ed->bl, bl); + if( ((*target) == NULL || !check_distance_bl(&ed->bl, *target, dist)) && battle->check_range(&ed->bl,bl,ed->db->range2) ) { //Pick closest target? + (*target) = bl; + ed->target_id = bl->id; + ed->min_chase = dist + ed->db->range3; + if( ed->min_chase > AREA_SIZE ) + ed->min_chase = AREA_SIZE; + return 1; + } + break; + } + return 0; +} + +static 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; + + nullpo_ret(ed); + nullpo_ret(sd); + + if( ed->bl.prev == NULL || sd == NULL || sd->bl.prev == NULL ) + return 0; + + // Check if caster can sustain the summoned elemental + if( DIFF_TICK(tick,ed->last_spdrain_time) >= 10000 ){// Drain SP every 10 seconds + int sp = 5; + + switch(ed->vd->class_){ + case 2115: case 2118: + case 2121: case 2124: + sp = 8; + break; + case 2116: case 2119: + case 2122: case 2125: + sp = 11; + break; + } + + if( status_get_sp(&sd->bl) < sp ){ // Can't sustain delete it. + elemental->delete(sd->ed,0); + return 0; + } + + status_zap(&sd->bl,0,sp); + ed->last_spdrain_time = tick; + } + + if( DIFF_TICK(tick,ed->last_thinktime) < MIN_ELETHINKTIME ) + return 0; + + ed->last_thinktime = tick; + + if( ed->ud.skilltimer != INVALID_TIMER ) + return 0; + + if( ed->ud.walktimer != INVALID_TIMER && ed->ud.walkpath.path_pos <= 2 ) + return 0; //No thinking when you just started to walk. + + if(ed->ud.walkpath.path_pos < ed->ud.walkpath.path_len && ed->ud.target == sd->bl.id) + return 0; //No thinking until be near the master. + + if( ed->sc.count && ed->sc.data[SC_BLIND] ) + view_range = 3; + else + view_range = ed->db->range2; + + mode = status_get_mode(&ed->bl); + + master_dist = distance_bl(&sd->bl, &ed->bl); + if( master_dist > AREA_SIZE ) { // Master out of vision range. + elemental->unlocktarget(ed); + unit_warp(&ed->bl,sd->bl.m,sd->bl.x,sd->bl.y,CLR_TELEPORT); + clif->elemental_updatestatus(sd,SP_HP); + clif->elemental_updatestatus(sd,SP_SP); + return 0; + } else if( master_dist > MAX_ELEDISTANCE ) { // Master too far, chase. + short x = sd->bl.x, y = sd->bl.y; + if( ed->target_id ) + elemental->unlocktarget(ed); + if( ed->ud.walktimer != INVALID_TIMER && ed->ud.target == sd->bl.id ) + 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) ) + return 0; + } + + if( mode == EL_MODE_AGGRESSIVE ) { + target = iMap->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)); + + if( !target ) { //No targets available. + elemental->unlocktarget(ed); + return 1; + } + + if( battle->check_range(&ed->bl,target,view_range) && rnd()%100 < 2 ) { // 2% chance to cast attack skill. + if( elemental->action(ed,target,tick) ) + return 1; + } + + //Attempt to attack. + //At this point we know the target is attackable, we just gotta check if the range matches. + if( ed->ud.target == target->id && ed->ud.attacktimer != INVALID_TIMER ) //Already locked. + return 1; + + if( battle->check_range(&ed->bl, target, ed->base_status.rhw.range) ) {//Target within range, engage + unit_attack(&ed->bl,target->id,1); + return 1; + } + + //Follow up if possible. + if( !unit_walktobl(&ed->bl, target, ed->base_status.rhw.range, 2) ) + elemental->unlocktarget(ed); + } + + return 0; +} + +static 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); + + 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); + return 0; +} + +int read_elementaldb(void) { + FILE *fp; + char line[1024], *p; + char *str[26]; + int i, j = 0, k = 0, ele; + struct s_elemental_db *db; + struct status_data *status; + + sprintf(line, "%s/%s", iMap->db_path, "elemental_db.txt"); + memset(elemental->elemental_db,0,sizeof(elemental->elemental_db)); + + fp = fopen(line, "r"); + if( !fp ) { + ShowError("read_elementaldb : can't read elemental_db.txt\n"); + return -1; + } + + while( fgets(line, sizeof(line), fp) && j < MAX_ELEMENTAL_CLASS ) { + k++; + if( line[0] == '/' && line[1] == '/' ) + continue; + + if( line[0] == '\0' || line[0] == '\n' || line[0] == '\r') + continue; + + i = 0; + p = strtok(line, ","); + while( p != NULL && i < 26 ) { + str[i++] = p; + p = strtok(NULL, ","); + } + if( i < 26 ) { + ShowError("read_elementaldb : Incorrect number of columns at elemental_db.txt line %d.\n", k); + continue; + } + + db = &elemental->elemental_db[j]; + db->class_ = atoi(str[0]); + safestrncpy(db->sprite, str[1], NAME_LENGTH); + safestrncpy(db->name, str[2], NAME_LENGTH); + db->lv = atoi(str[3]); + + status = &db->status; + db->vd.class_ = db->class_; + + status->max_hp = atoi(str[4]); + status->max_sp = atoi(str[5]); + status->rhw.range = atoi(str[6]); + status->rhw.atk = atoi(str[7]); + status->rhw.atk2 = atoi(str[8]); + status->def = atoi(str[9]); + status->mdef = atoi(str[10]); + status->str = atoi(str[11]); + status->agi = atoi(str[12]); + status->vit = atoi(str[13]); + status->int_ = atoi(str[14]); + status->dex = atoi(str[15]); + status->luk = atoi(str[16]); + db->range2 = atoi(str[17]); + db->range3 = atoi(str[18]); + status->size = atoi(str[19]); + status->race = atoi(str[20]); + + ele = atoi(str[21]); + status->def_ele = ele%10; + status->ele_lv = ele/20; + if( status->def_ele >= ELE_MAX ) { + ShowWarning("Elemental %d has invalid element type %d (max element is %d)\n", db->class_, status->def_ele, ELE_MAX - 1); + status->def_ele = ELE_NEUTRAL; + } + if( status->ele_lv < 1 || status->ele_lv > 4 ) { + ShowWarning("Elemental %d has invalid element level %d (max is 4)\n", db->class_, status->ele_lv); + status->ele_lv = 1; + } + + status->aspd_rate = 1000; + status->speed = atoi(str[22]); + status->adelay = atoi(str[23]); + status->amotion = atoi(str[24]); + status->dmotion = atoi(str[25]); + + j++; + } + + fclose(fp); + ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' elementals in '"CL_WHITE"db/elemental_db.txt"CL_RESET"'.\n",j); + + return 0; +} + +int read_elemental_skilldb(void) { + FILE *fp; + char line[1024], *p; + char *str[4]; + struct s_elemental_db *db; + int i, j = 0, k = 0, class_; + uint16 skill_id, skill_lv; + int skillmode; + + sprintf(line, "%s/%s", iMap->db_path, "elemental_skill_db.txt"); + fp = fopen(line, "r"); + if( !fp ) { + ShowError("read_elemental_skilldb : can't read elemental_skill_db.txt\n"); + return -1; + } + + while( fgets(line, sizeof(line), fp) ) { + k++; + if( line[0] == '/' && line[1] == '/' ) + continue; + + if( line[0] == '\0' || line[0] == '\n' || line[0] == '\r') + continue; + + i = 0; + p = strtok(line, ","); + while( p != NULL && i < 4 ) { + str[i++] = p; + p = strtok(NULL, ","); + } + if( i < 4 ) { + ShowError("read_elemental_skilldb : Incorrect number of columns at elemental_skill_db.txt line %d.\n", k); + continue; + } + + class_ = atoi(str[0]); + ARR_FIND(0, MAX_ELEMENTAL_CLASS, i, class_ == elemental->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; + } + + skill_id = atoi(str[1]); + if( skill_id < EL_SKILLBASE || skill_id >= EL_SKILLBASE + MAX_ELEMENTALSKILL ) { + ShowError("read_elemental_skilldb : Skill out of range, line %d.\n", k); + continue; + } + + db = &elemental->elemental_db[i]; + skill_lv = atoi(str[2]); + + skillmode = atoi(str[3]); + if( skillmode < EL_SKILLMODE_PASIVE || skillmode > EL_SKILLMODE_AGGRESSIVE ) { + ShowError("read_elemental_skilldb : Skillmode out of range, line %d.\n",k); + continue; + } + ARR_FIND( 0, MAX_ELESKILLTREE, i, db->skill[i].id == 0 || db->skill[i].id == skill_id ); + if( i == MAX_ELESKILLTREE ) { + ShowWarning("Unable to load skill %d into Elemental %d's tree. Maximum number of skills per elemental has been reached.\n", skill_id, class_); + continue; + } + db->skill[i].id = skill_id; + db->skill[i].lv = skill_lv; + db->skill[i].mode = skillmode; + j++; + } + + fclose(fp); + ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"db/elemental_skill_db.txt"CL_RESET"'.\n",j); + return 0; +} + +void reload_elementaldb(void) { + read_elementaldb(); + elemental->reload_skilldb(); +} + +void reload_elemental_skilldb(void) { + elemental->read_skilldb(); +} + +int do_init_elemental(void) { + read_elementaldb(); + elemental->read_skilldb(); + + iTimer->add_timer_func_list(elemental_ai_timer,"elemental_ai_timer"); + iTimer->add_timer_interval(iTimer->gettick()+MIN_ELETHINKTIME,elemental_ai_timer,0,0,MIN_ELETHINKTIME); + + return 0; +} + +void do_final_elemental(void) { + return; +} + +/*===================================== +* Default Functions : elemental.h +* Generated by HerculesInterfaceMaker +* created by Susu +*-------------------------------------*/ +void elemental_defaults(void) { + elemental = &elemental_s; + /* funcs */ + + elemental->class = elemental_class; + elemental->get_viewdata = elemental_get_viewdata; + + elemental->create = elemental_create; + elemental->data_received = elemental_data_received; + elemental->save = elemental_save; + + elemental->change_mode_ack = elemental_change_mode_ack; + elemental->change_mode = elemental_change_mode; + + elemental->heal = elemental_heal; + elemental->dead = elemental_dead; + + elemental->delete = elemental_delete; + elemental->summon_stop = elemental_summon_stop; + + elemental->get_lifetime = elemental_get_lifetime; + + elemental->unlocktarget = elemental_unlocktarget; + elemental->skillnotok = elemental_skillnotok; + elemental->set_target = elemental_set_target; + elemental->clean_single_effect = elemental_clean_single_effect; + elemental->clean_effect = elemental_clean_effect; + elemental->action = elemental_action; + elemental->skill_get_requirements = elemental_skill_get_requirements; + + elemental->read_skilldb = read_elemental_skilldb; + elemental->reload_elementaldb = reload_elementaldb; + elemental->reload_skilldb = reload_elemental_skilldb; + elemental->do_init_elemental = do_init_elemental; + elemental->do_final_elemental = do_final_elemental; +} diff --git a/src/map/elemental.h b/src/map/elemental.h index f941f3dfd..96d2ed89f 100644 --- a/src/map/elemental.h +++ b/src/map/elemental.h @@ -1,94 +1,106 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder - -#ifndef _ELEMENTAL_H_ -#define _ELEMENTAL_H_ - -#include "status.h" // struct status_data, struct status_change -#include "unit.h" // struct unit_data - -#define MIN_ELETHINKTIME 100 -#define MIN_ELEDISTANCE 2 -#define MAX_ELEDISTANCE 5 - -#define EL_MODE_AGGRESSIVE (MD_CANMOVE|MD_AGGRESSIVE|MD_CANATTACK) -#define EL_MODE_ASSIST (MD_CANMOVE|MD_ASSIST) -#define EL_MODE_PASSIVE MD_CANMOVE - -#define EL_SKILLMODE_PASIVE 0x1 -#define EL_SKILLMODE_ASSIST 0x2 -#define EL_SKILLMODE_AGGRESSIVE 0x4 - -struct elemental_skill { - unsigned short id, lv; - short mode; -}; - -struct s_elemental_db { - int class_; - char sprite[NAME_LENGTH], name[NAME_LENGTH]; - unsigned short lv; - short range2, range3; - struct status_data status; - struct view_data vd; - struct elemental_skill skill[MAX_ELESKILLTREE]; -}; - -extern struct s_elemental_db elemental_db[MAX_ELEMENTAL_CLASS]; - -struct elemental_data { - struct block_list bl; - struct unit_data ud; - struct view_data *vd; - struct status_data base_status, battle_status; - struct status_change sc; - struct regen_data regen; - - struct s_elemental_db *db; - struct s_elemental elemental; - - struct map_session_data *master; - int summon_timer; - int skill_timer; - - unsigned last_thinktime, last_linktime, last_spdrain_time; - short min_chase; - int target_id, attacked_id; -}; - -bool elemental_class(int class_); -struct view_data * elemental_get_viewdata(int class_); - -int elemental_create(struct map_session_data *sd, int class_, unsigned int lifetime); -int elemental_data_received(struct s_elemental *ele, bool flag); -int elemental_save(struct elemental_data *ed); - -int elemental_change_mode_ack(struct elemental_data *ed, int mode); -int elemental_change_mode(struct elemental_data *ed, int mode); - -void elemental_heal(struct elemental_data *ed, int hp, int sp); -int elemental_dead(struct elemental_data *ed); - -int elemental_delete(struct elemental_data *ed, int reply); -void elemental_summon_stop(struct elemental_data *ed); - -int elemental_get_lifetime(struct elemental_data *ed); - -int elemental_unlocktarget(struct elemental_data *ed); -int elemental_skillnotok(uint16 skill_id, struct elemental_data *ed); -int elemental_set_target( struct map_session_data *sd, struct block_list *bl ); -int elemental_clean_single_effect(struct elemental_data *ed, uint16 skill_id); -int elemental_clean_effect(struct elemental_data *ed); -int elemental_action(struct elemental_data *ed, struct block_list *bl, unsigned int tick); -struct skill_condition elemental_skill_get_requirements(uint16 skill_id, uint16 skill_lv); - -#define elemental_stop_walking(ed, type) unit_stop_walking(&(ed)->bl, type) -#define elemental_stop_attack(ed) unit_stop_attack(&(ed)->bl) - -int read_elemental_skilldb(void); -void reload_elementaldb(void); -void reload_elemental_skilldb(void); -int do_init_elemental(void); -void do_final_elemental(void); - -#endif /* _ELEMENTAL_H_ */ +// Copyright (c) Athena Dev Teams - Licensed under GNU GPL +// For more information, see LICENCE in the main folder +#ifndef _ELEMENTAL_H_ +#define _ELEMENTAL_H_ +#include "status.h" // struct status_data, struct status_change +#include "unit.h" // struct unit_data +#define MIN_ELETHINKTIME 100 +#define MIN_ELEDISTANCE 2 +#define MAX_ELEDISTANCE 5 +#define EL_MODE_AGGRESSIVE (MD_CANMOVE|MD_AGGRESSIVE|MD_CANATTACK) +#define EL_MODE_ASSIST (MD_CANMOVE|MD_ASSIST) +#define EL_MODE_PASSIVE MD_CANMOVE +#define EL_SKILLMODE_PASIVE 0x1 +#define EL_SKILLMODE_ASSIST 0x2 +#define EL_SKILLMODE_AGGRESSIVE 0x4 +struct elemental_skill { + unsigned short id, lv; + short mode; +}; +struct s_elemental_db { + int class_; + char sprite[NAME_LENGTH], name[NAME_LENGTH]; + unsigned short lv; + short range2, range3; + struct status_data status; + struct view_data vd; + struct elemental_skill skill[MAX_ELESKILLTREE]; +}; +struct elemental_data { + struct block_list bl; + struct unit_data ud; + struct view_data *vd; + struct status_data base_status, battle_status; + struct status_change sc; + struct regen_data regen; + + struct s_elemental_db *db; + struct s_elemental elemental; + + struct map_session_data *master; + int summon_timer; + int skill_timer; + + unsigned last_thinktime, last_linktime, last_spdrain_time; + short min_chase; + 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 +* created by Susu +*-------------------------------------*/ +struct elemental_interface { + /* vars */ + struct s_elemental_db elemental_db[MAX_ELEMENTAL_CLASS]; // Elemental Database + /* funcs */ + bool (*class) (int class_); + struct view_data * (*get_viewdata) (int class_); + + int (*create) (struct map_session_data *sd, int class_, unsigned int lifetime); + int (*data_received) (struct s_elemental *ele, bool flag); + int (*save) (struct elemental_data *ed); + + int (*change_mode_ack) (struct elemental_data *ed, int mode); + int (*change_mode) (struct elemental_data *ed, int mode); + + void (*heal) (struct elemental_data *ed, int hp, int sp); + int (*dead) (struct elemental_data *ed); + + int (*delete) (struct elemental_data *ed, int reply); + void (*summon_stop) (struct elemental_data *ed); + + int (*get_lifetime) (struct elemental_data *ed); + + int (*unlocktarget) (struct elemental_data *ed); + int (*skillnotok) (uint16 skill_id, struct elemental_data *ed); + int (*set_target) (struct map_session_data *sd, struct block_list *bl); + int (*clean_single_effect) (struct elemental_data *ed, uint16 skill_id); + int (*clean_effect) (struct elemental_data *ed); + int (*action) (struct elemental_data *ed, struct block_list *bl, unsigned int tick); + struct skill_condition (*skill_get_requirements) (uint16 skill_id, uint16 skill_lv); + + int (*read_skilldb) (void); + void (*reload_elementaldb) (void); + void (*reload_skilldb) (void); + int (*do_init_elemental) (void); + void (*do_final_elemental) (void); +} elemental_s; + +struct elemental_interface *elemental; + +void elemental_defaults(void); + +#endif /* _ELEMENTAL_H_ */ diff --git a/src/map/intif.c b/src/map/intif.c index 294d79656..f2c5e7e78 100644 --- a/src/map/intif.c +++ b/src/map/intif.c @@ -2055,7 +2055,7 @@ int intif_parse_elemental_received(int fd) return 0; } - elemental_data_received((struct s_elemental*)RFIFOP(fd,5), RFIFOB(fd,4)); + elemental->data_received((struct s_elemental*)RFIFOP(fd,5), RFIFOB(fd,4)); return 0; } diff --git a/src/map/map.c b/src/map/map.c index 0fb988351..5e8102ea0 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -1591,7 +1591,7 @@ int map_quit(struct map_session_data *sd) { if (sd->state.permanent_speed == 1) sd->state.permanent_speed = 0; // Remove lock so speed is set back to normal at login. if( sd->ed ) { - elemental_clean_effect(sd->ed); + elemental->clean_effect(sd->ed); unit_remove_map(&sd->ed->bl,CLR_TELEPORT); } @@ -4945,7 +4945,7 @@ void do_final(void) do_final_unit(); do_final_battleground(); iDuel->do_final_duel(); - do_final_elemental(); + elemental->do_final_elemental(); do_final_maps(); vending->final(); @@ -5155,6 +5155,11 @@ void map_hp_symbols(void) { HPM->share(storage,"storage"); HPM->share(trade,"trade"); HPM->share(iStatus,"iStatus"); + HPM->share(chat, "chat"); + HPM->share(iDuel,"iDuel"); + HPM->share(elemental,"elemental"); + + /* partial */ HPM->share(mapit,"mapit"); /* sql link */ @@ -5191,6 +5196,9 @@ void map_load_defaults(void) { storage_defaults(); trade_defaults(); status_defaults(); + chat_defaults(); + iDuel_defaults(); + elemental_defaults(); } int do_init(int argc, char *argv[]) { @@ -5387,7 +5395,7 @@ int do_init(int argc, char *argv[]) do_init_pet(); homun->init(); do_init_mercenary(); - do_init_elemental(); + elemental->do_init_elemental(); do_init_quest(); do_init_npc(); do_init_unit(); diff --git a/src/map/pc.c b/src/map/pc.c index ee2e62e92..30ef9848c 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -6687,7 +6687,7 @@ void pc_damage(struct map_session_data *sd,struct block_list *src,unsigned int h pet_target_check(sd,src,1); if( sd->status.ele_id > 0 ) - elemental_set_target(sd,src); + elemental->set_target(sd,src); sd->canlog_tick = iTimer->gettick(); } @@ -6728,7 +6728,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) { merc_delete(sd->md, 3); // Your mercenary soldier has ran away. if( sd->ed ) - elemental_delete(sd->ed, 0); + elemental->delete(sd->ed, 0); // Leave duel if you die [LuzZza] if(battle_config.duel_autoleave_when_die) { @@ -7621,7 +7621,7 @@ int pc_jobchange(struct map_session_data *sd,int job, int upper) clif->skillinfoblock(sd); if (sd->ed) - elemental_delete(sd->ed, 0); + elemental->delete(sd->ed, 0); if (sd->state.vending) vending->close(sd); diff --git a/src/map/skill.c b/src/map/skill.c index d2a9b7fbe..0fbd340fa 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -4481,7 +4481,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( (sc && sc->data[type2]) || (tsc && tsc->data[type]) ) { - elemental_clean_single_effect(ele, skill_id); + elemental->clean_single_effect(ele, skill_id); } if( rnd()%100 < 50 ) skill->attack(skill->get_type(skill_id),src,src,bl,skill_id,skill_lv,tick,flag); @@ -8885,10 +8885,10 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui // Remove previous elemental fisrt. if( sd->ed ) - elemental_delete(sd->ed,0); + elemental->delete(sd->ed,0); // Summoning the new one. - if( !elemental_create(sd,elemental_class,skill->get_time(skill_id,skill_lv)) ) { + if( !elemental->create(sd,elemental_class,skill->get_time(skill_id,skill_lv)) ) { clif->skill_fail(sd,skill_id,0,0); break; } @@ -8903,14 +8903,14 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui if( !sd->ed ) break; if( skill_lv == 4 ) {// At level 4 delete elementals. - elemental_delete(sd->ed, 0); + elemental->delete(sd->ed, 0); break; } switch( skill_lv ) {// Select mode bassed on skill level used. case 2: mode = EL_MODE_ASSIST; break; case 3: mode = EL_MODE_AGGRESSIVE; break; } - if( !elemental_change_mode(sd->ed,mode) ) { + if( !elemental->change_mode(sd->ed,mode) ) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); break; } @@ -8923,7 +8923,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui int duration = 3000; if( !sd->ed ) break; sd->skill_id_old = skill_id; - elemental_action(sd->ed, bl, tick); + elemental->action(sd->ed, bl, tick); clif->skill_nodamage(src,bl,skill_id,skill_lv,1); switch(sd->ed->db->class_){ case 2115:case 2124: @@ -8959,7 +8959,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case SO_ELEMENTAL_SHIELD: if( !sd->ed ) break; - elemental_delete(sd->ed, 0); + elemental->delete(sd->ed, 0); if( sd == NULL || sd->status.party_id == 0 || flag&1 ) skill->unitsetting(src,MG_SAFETYWALL,skill_lv,bl->x,bl->y,0); else if( sd ) @@ -9073,7 +9073,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui 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); + 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); @@ -9103,7 +9103,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui 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); + 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); diff --git a/src/map/status.c b/src/map/status.c index a8b61f2d6..48a61cfcb 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -1243,7 +1243,7 @@ int status_damage(struct block_list *src,struct block_list *target,int hp, int s case BL_MOB: mob_damage((TBL_MOB*)target, src, hp); break; case BL_HOM: homun->damaged((TBL_HOM*)target); break; case BL_MER: mercenary_heal((TBL_MER*)target,hp,sp); break; - case BL_ELEM: elemental_heal((TBL_ELEM*)target,hp,sp); break; + case BL_ELEM: elemental->heal((TBL_ELEM*)target,hp,sp); break; } if( src && target->type == BL_PC && (((TBL_PC*)target)->disguise) > 0 ) {// stop walking when attacked in disguise to prevent walk-delay bug @@ -1268,7 +1268,7 @@ int status_damage(struct block_list *src,struct block_list *target,int hp, int s case BL_MOB: flag = mob_dead((TBL_MOB*)target, src, flag&4?3:0); break; case BL_HOM: flag = homun->dead((TBL_HOM*)target); break; case BL_MER: flag = mercenary_dead((TBL_MER*)target); break; - case BL_ELEM: flag = elemental_dead((TBL_ELEM*)target); break; + case BL_ELEM: flag = elemental->dead((TBL_ELEM*)target); break; default: //Unhandled case, do nothing to object. flag = 0; break; @@ -1414,7 +1414,7 @@ int status_heal(struct block_list *bl,int hp,int sp, int flag) case BL_MOB: mob_heal((TBL_MOB*)bl,hp); break; case BL_HOM: homun->healed((TBL_HOM*)bl); break; case BL_MER: mercenary_heal((TBL_MER*)bl,hp,sp); break; - case BL_ELEM: elemental_heal((TBL_ELEM*)bl,hp,sp); break; + case BL_ELEM: elemental->heal((TBL_ELEM*)bl,hp,sp); break; } return hp+sp; @@ -6057,8 +6057,8 @@ void status_set_viewdata(struct block_list *bl, int class_) vd = homun->get_viewdata(class_); else if (merc_class(class_)) vd = merc_get_viewdata(class_); - else if (elemental_class(class_)) - vd = elemental_get_viewdata(class_); + else if (elemental->class(class_)) + vd = elemental->get_viewdata(class_); else vd = NULL; diff --git a/src/map/unit.c b/src/map/unit.c index 7a1c15838..8a11363cb 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -2265,7 +2265,7 @@ int unit_remove_map_(struct block_list *bl, clr_type clrtype, const char* file, 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); @@ -2548,8 +2548,8 @@ int unit_free(struct block_list *bl, clr_type clrtype) case BL_ELEM: { struct elemental_data *ed = (TBL_ELEM*)bl; struct map_session_data *sd = ed->master; - if( elemental_get_lifetime(ed) > 0 ) - elemental_save(ed); + if( elemental->get_lifetime(ed) > 0 ) + elemental->save(ed); else { intif_elemental_delete(ed->elemental.elemental_id); if( sd ) @@ -2558,7 +2558,7 @@ int unit_free(struct block_list *bl, clr_type clrtype) if( sd ) sd->ed = NULL; - elemental_summon_stop(ed); + elemental->summon_stop(ed); break; } } -- cgit v1.2.3-70-g09d2 From 853489bcb5f2acfce14731b117ddc2b246042883 Mon Sep 17 00:00:00 2001 From: Susu Date: Mon, 29 Jul 2013 15:49:14 +0200 Subject: Added intif interface --- src/map/atcommand.c | 20 +- src/map/chrif.c | 14 +- src/map/clif.c | 30 +- src/map/elemental.c | 4 +- src/map/guild.c | 56 +- src/map/homunculus.c | 10 +- src/map/intif.c | 4610 +++++++++++++++++++++++++------------------------- src/map/intif.h | 240 +-- src/map/map.c | 4 +- src/map/mercenary.c | 4 +- src/map/mob.c | 6 +- src/map/npc.c | 4 +- src/map/party.c | 30 +- src/map/pc.c | 34 +- src/map/pet.c | 12 +- src/map/quest.c | 1 - src/map/script.c | 16 +- src/map/storage.c | 4 +- src/map/trade.c | 6 +- src/map/unit.c | 10 +- 20 files changed, 2612 insertions(+), 2503 deletions(-) (limited to 'src/map/elemental.c') diff --git a/src/map/atcommand.c b/src/map/atcommand.c index c14b8a26e..018098928 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -745,7 +745,7 @@ ACMD(save) pc->setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y); if (sd->status.pet_id > 0 && sd->pd) - intif_save_petdata(sd->status.account_id, &sd->pd->pet); + intif->save_petdata(sd->status.account_id, &sd->pd->pet); chrif->save(sd,0); @@ -1048,7 +1048,7 @@ ACMD(kami) if (strstr(command, "l") != NULL) clif->broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, 0, ALL_SAMEMAP); else - intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b' || *(command + 5) == 'B') ? 0x10 : 0); + intif->broadcast(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b' || *(command + 5) == 'B') ? 0x10 : 0); } else { if(!message || !*message || (sscanf(message, "%lx %199[^\n]", &color, atcmd_output) < 2)) { clif->message(fd, msg_txt(981)); // Please enter color and message (usage: @kamic ). @@ -1059,7 +1059,7 @@ ACMD(kami) clif->message(fd, msg_txt(982)); // Invalid color. return false; } - intif_broadcast2(atcmd_output, strlen(atcmd_output) + 1, color, 0x190, 12, 0, 0); + intif->broadcast2(atcmd_output, strlen(atcmd_output) + 1, color, 0x190, 12, 0, 0); } return true; } @@ -2526,7 +2526,7 @@ ACMD(guildlevelup) added_level = 1 - guild_info->guild_lv; if (added_level != 0) { - intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, sizeof(added_level)); + intif->guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, sizeof(added_level)); clif->message(fd, msg_txt(179)); // Guild level changed. } else { clif->message(fd, msg_txt(45)); // Guild level change failed. @@ -2563,7 +2563,7 @@ ACMD(makeegg) pet_id = search_petDB_index(id, PET_EGG); if (pet_id >= 0) { sd->catch_target_class = pet_db[pet_id].class_; - intif_create_pet( + intif->create_pet( sd->status.account_id, sd->status.char_id, (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv, (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate, @@ -2682,7 +2682,7 @@ ACMD(petrename) } pd->pet.rename_flag = 0; - intif_save_petdata(sd->status.account_id, &pd->pet); + intif->save_petdata(sd->status.account_id, &pd->pet); clif->send_petstatus(sd); clif->message(fd, msg_txt(187)); // You can now rename your pet. @@ -4960,7 +4960,7 @@ ACMD(broadcast) } sprintf(atcmd_output, "%s: %s", sd->status.name, message); - intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, 0); + intif->broadcast(atcmd_output, strlen(atcmd_output) + 1, 0); return true; } @@ -7974,7 +7974,7 @@ ACMD(request) } sprintf(atcmd_output, msg_txt(278), message); // (@request): %s - intif_wis_message_to_gm(sd->status.name, PC_PERM_RECEIVE_REQUESTS, atcmd_output); + intif->wis_message_to_gm(sd->status.name, PC_PERM_RECEIVE_REQUESTS, atcmd_output); clif->disp_onlyself(sd, atcmd_output, strlen(atcmd_output)); clif->message(sd->fd,msg_txt(279)); // @request sent. return true; @@ -8335,7 +8335,7 @@ ACMD(delitem) if( sd->inventory_data[idx]->type == IT_PETEGG && sd->status.inventory[idx].card[0] == CARD0_PET ) {// delete pet - intif_delete_petdata(MakeDWord(sd->status.inventory[idx].card[1], sd->status.inventory[idx].card[2])); + intif->delete_petdata(MakeDWord(sd->status.inventory[idx].card[1], sd->status.inventory[idx].card[2])); } pc->delitem(sd, idx, delamount, 0, 0, LOG_TYPE_COMMAND); @@ -8508,7 +8508,7 @@ ACMD(accinfo) { //remove const type safestrncpy(query, message, NAME_LENGTH); - intif_request_accinfo( sd->fd, sd->bl.id, pc->get_group_level(sd), query ); + intif->request_accinfo( sd->fd, sd->bl.id, pc->get_group_level(sd), query ); return true; } diff --git a/src/map/chrif.c b/src/map/chrif.c index 02e9e977c..d1ee8b5b1 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -293,11 +293,11 @@ int chrif_save(struct map_session_data *sd, int flag) { //Saving of registry values. if (sd->state.reg_dirty&4) - intif_saveregistry(sd, 3); //Save char regs + intif->saveregistry(sd, 3); //Save char regs if (sd->state.reg_dirty&2) - intif_saveregistry(sd, 2); //Save account regs + intif->saveregistry(sd, 2); //Save account regs if (sd->state.reg_dirty&1) - intif_saveregistry(sd, 1); //Save account2 regs + intif->saveregistry(sd, 1); //Save account2 regs WFIFOHEAD(char_fd, sizeof(sd->status) + 13); WFIFOW(char_fd,0) = 0x2b01; @@ -309,7 +309,7 @@ int chrif_save(struct map_session_data *sd, int flag) { WFIFOSET(char_fd, WFIFOW(char_fd,2)); if( sd->status.pet_id > 0 && sd->pd ) - intif_save_petdata(sd->status.account_id,&sd->pd->pet); + intif->save_petdata(sd->status.account_id,&sd->pd->pet); if( sd->hd && homun_alive(sd->hd) ) homun->save(sd->hd); if( sd->md && mercenary_get_lifetime(sd->md) > 0 ) @@ -317,7 +317,7 @@ int chrif_save(struct map_session_data *sd, int flag) { if( sd->ed && elemental->get_lifetime(sd->ed) > 0 ) elemental->save(sd->ed); if( sd->save_quest ) - intif_quest_save(sd); + intif->quest_save(sd); return 0; } @@ -1423,12 +1423,12 @@ int chrif_parse(int fd) { while ( RFIFOREST(fd) >= 2 ) { cmd = RFIFOW(fd,0); if (cmd < 0x2af8 || cmd >= 0x2af8 + ARRAYLENGTH(packet_len_table) || packet_len_table[cmd-0x2af8] == 0) { - int r = intif_parse(fd); // Passed on to the intif + int r = intif->parse(fd); // Passed on to the intif if (r == 1) continue; // Treated in intif if (r == 2) return 0; // Didn't have enough data (len==-1) - ShowWarning("chrif_parse: session #%d, intif_parse failed (unrecognized command 0x%.4x).\n", fd, cmd); + ShowWarning("chrif_parse: session #%d, intif->parse failed (unrecognized command 0x%.4x).\n", fd, cmd); set_eof(fd); return 0; } diff --git a/src/map/clif.c b/src/map/clif.c index 8377eed5c..f5ce8ede3 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -9889,7 +9889,7 @@ 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(iMap->wisp_server_name, battle_config.hack_info_GM_level, gm_msg); return; } */ @@ -10489,7 +10489,7 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd) // if there are 'Test' player on an other map-server and 'test' player on this map-server, // and if we ask for 'Test', we must not contact 'test' player // so, we send information to inter-server, which is the only one which decide (and copy correct name). - intif_wis_message(sd, target, message, messagelen); + intif->wis_message(sd, target, message, messagelen); return; } @@ -14556,7 +14556,7 @@ void clif_parse_Mail_refreshinbox(int fd, struct map_session_data *sd) struct mail_data* md = &sd->mail.inbox; if( md->amount < MAIL_MAX_INBOX && (md->full || sd->mail.changed) ) - intif_Mail_requestinbox(sd->status.char_id, 1); + intif->Mail_requestinbox(sd->status.char_id, 1); else clif->mail_refreshinbox(sd); @@ -14620,7 +14620,7 @@ void clif_Mail_read(struct map_session_data *sd, int mail_id) if (msg->status == MAIL_UNREAD) { msg->status = MAIL_READ; - intif_Mail_read(mail_id); + intif->Mail_read(mail_id); clif->pMail_refreshinbox(fd, sd); } } @@ -14700,7 +14700,7 @@ void clif_parse_Mail_getattach(int fd, struct map_session_data *sd) memset(&sd->mail.inbox.msg[i].item, 0, sizeof(struct item)); clif->mail_read(sd, mail_id); - intif_Mail_getattach(sd->status.char_id, mail_id); + intif->Mail_getattach(sd->status.char_id, mail_id); } @@ -14727,7 +14727,7 @@ void clif_parse_Mail_delete(int fd, struct map_session_data *sd) return; } - intif_Mail_delete(sd->status.char_id, mail_id); + intif->Mail_delete(sd->status.char_id, mail_id); } } @@ -14746,7 +14746,7 @@ void clif_parse_Mail_return(int fd, struct map_session_data *sd) ARR_FIND(0, MAIL_MAX_INBOX, i, sd->mail.inbox.msg[i].id == mail_id); if( i < MAIL_MAX_INBOX && sd->mail.inbox.msg[i].send_id != 0 ) - intif_Mail_return(sd->status.char_id, mail_id); + intif->Mail_return(sd->status.char_id, mail_id); else clif->mail_return(sd->fd, mail_id, 1); } @@ -14839,7 +14839,7 @@ void clif_parse_Mail_send(int fd, struct map_session_data *sd) memset(msg.body, 0x00, MAIL_BODY_LENGTH); msg.timestamp = time(NULL); - if( !intif_Mail_send(sd->status.account_id, &msg) ) + if( !intif->Mail_send(sd->status.account_id, &msg) ) mail->deliveryfail(sd, &msg); sd->cansendmail_tick = iTimer->gettick() + 1000; // 1 Second flood Protection @@ -15083,7 +15083,7 @@ void clif_parse_Auction_register(int fd, struct map_session_data *sd) auction.item.amount = 1; auction.timestamp = 0; - if( !intif_Auction_register(&auction) ) + if( !intif->Auction_register(&auction) ) clif->auction_message(fd, 4); // No Char Server? lets say something to the client else { @@ -15103,7 +15103,7 @@ void clif_parse_Auction_cancel(int fd, struct map_session_data *sd) { unsigned int auction_id = RFIFOL(fd,2); - intif_Auction_cancel(sd->status.char_id, auction_id); + intif->Auction_cancel(sd->status.char_id, auction_id); } @@ -15113,7 +15113,7 @@ void clif_parse_Auction_close(int fd, struct map_session_data *sd) { unsigned int auction_id = RFIFOL(fd,2); - intif_Auction_close(sd->status.char_id, auction_id); + intif->Auction_close(sd->status.char_id, auction_id); } @@ -15133,11 +15133,11 @@ void clif_parse_Auction_bid(int fd, struct map_session_data *sd) clif->auction_message(fd, 0); // You have failed to bid into the auction else if( bid > sd->status.zeny ) clif->auction_message(fd, 8); // You do not have enough zeny - else if ( CheckForCharServer() ) // char server is down (bugreport:1138) + else if ( intif->CheckForCharServer() ) // char server is down (bugreport:1138) clif->auction_message(fd, 0); // You have failed to bid into the auction else { pc->payzeny(sd, bid, LOG_TYPE_AUCTION, NULL); - intif_Auction_bid(sd->status.char_id, sd->status.name, auction_id, bid); + intif->Auction_bid(sd->status.char_id, sd->status.name, auction_id, bid); } } @@ -15160,7 +15160,7 @@ void clif_parse_Auction_search(int fd, struct map_session_data* sd) clif->pAuction_cancelreg(fd, sd); safestrncpy(search_text, (char*)RFIFOP(fd,8), sizeof(search_text)); - intif_Auction_requestlist(sd->status.char_id, type, price, search_text, page); + intif->Auction_requestlist(sd->status.char_id, type, price, search_text, page); } @@ -15174,7 +15174,7 @@ void clif_parse_Auction_buysell(int fd, struct map_session_data* sd) short type = RFIFOW(fd,2) + 6; clif->pAuction_cancelreg(fd, sd); - intif_Auction_requestlist(sd->status.char_id, type, 0, "", 1); + intif->Auction_requestlist(sd->status.char_id, type, 0, "", 1); } diff --git a/src/map/elemental.c b/src/map/elemental.c index 3c212ccaa..03aa93e49 100644 --- a/src/map/elemental.c +++ b/src/map/elemental.c @@ -135,7 +135,7 @@ int elemental_create(struct map_session_data *sd, int class_, unsigned int lifet ele.life_time = lifetime; // Request Char Server to create this elemental - intif_elemental_create(&ele); + intif->elemental_create(&ele); return 1; } @@ -163,7 +163,7 @@ int elemental_save(struct elemental_data *ed) { ed->elemental.flee = ed->battle_status.flee; ed->elemental.hit = ed->battle_status.hit; ed->elemental.life_time = elemental->get_lifetime(ed); - intif_elemental_save(&ed->elemental); + intif->elemental_save(&ed->elemental); return 1; } diff --git a/src/map/guild.c b/src/map/guild.c index e5ea6809d..601d88387 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -84,7 +84,7 @@ static TBL_PC* guild_sd_check(int guild_id, int account_id, int char_id) 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 **"); + intif->guild_leave(guild_id,account_id,char_id,0,"** Guild Mismatch **"); return NULL; } @@ -179,7 +179,7 @@ static bool guild_read_castledb(char* str[], int columns, int current) idb_put(castle_db,gc->castle_id,gc); - //intif_guild_castle_info(gc->castle_id); + //intif->guild_castle_info(gc->castle_id); return true; } @@ -313,7 +313,7 @@ int guild_payexp_timer_sub(DBKey key, DBData *data, va_list ap) { else g->member[i].exp+= c->exp; - intif_guild_change_memberinfo(g->guild_id,c->account_id,c->char_id, + intif->guild_change_memberinfo(g->guild_id,c->account_id,c->char_id, GMI_EXP,&g->member[i].exp,sizeof(g->member[i].exp)); c->exp=0; @@ -395,7 +395,7 @@ int guild_create(struct map_session_data *sd, const char *name) guild_makemember(&m,sd); m.position=0; - intif_guild_create(name,&m); + intif->guild_create(name,&m); return 1; } @@ -420,7 +420,7 @@ int guild_created(int account_id,int guild_id) { //Information request int guild_request_info(int guild_id) { - return intif_guild_request_info(guild_id); + return intif->guild_request_info(guild_id); } //Information request with event @@ -733,7 +733,7 @@ int guild_reply_invite(struct map_session_data* sd, int guild_id, int flag) } guild_makemember(&m,sd); - intif_guild_addmember(guild_id, &m); + intif->guild_addmember(guild_id, &m); //TODO: send a minimap update to this player } @@ -799,7 +799,7 @@ int guild_member_added(int guild_id,int account_id,int char_id,int flag) // 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; } @@ -851,7 +851,7 @@ int guild_leave(struct map_session_data* sd, int guild_id, int account_id, int c ((iMap->agit_flag || iMap->agit2_flag) && map[sd->bl.m].flag.gvg_castle)) return 0; - intif_guild_leave(sd->status.guild_id, sd->status.account_id, sd->status.char_id,0,mes); + intif->guild_leave(sd->status.guild_id, sd->status.account_id, sd->status.char_id,0,mes); return 0; } @@ -886,7 +886,7 @@ int guild_expulsion(struct map_session_data* sd, int guild_id, int account_id, i // find the member and perform expulsion i = guild->getindex(g, account_id, char_id); if( i != -1 && strcmp(g->member[i].name,g->master) != 0 ) //Can't expel the GL! - intif_guild_leave(g->guild_id,account_id,char_id,1,mes); + intif->guild_leave(g->guild_id,account_id,char_id,1,mes); return 0; } @@ -954,7 +954,7 @@ int guild_send_memberinfoshort(struct map_session_data *sd,int online) if(!(g = sd->guild)) return 0; - intif_guild_memberinfoshort(g->guild_id, + intif->guild_memberinfoshort(g->guild_id, sd->status.account_id,sd->status.char_id,online,sd->status.base_level,sd->status.class_); if(!online){ @@ -1047,7 +1047,7 @@ int guild_send_message(struct map_session_data *sd,const char *mes,int len) if(sd->status.guild_id==0) return 0; - intif_guild_message(sd->status.guild_id,sd->status.account_id,mes,len); + intif->guild_message(sd->status.guild_id,sd->status.account_id,mes,len); guild->recv_message(sd->status.guild_id,sd->status.account_id,mes,len); // Chat logging type 'G' / Guild Chat @@ -1073,7 +1073,7 @@ int guild_recv_message(int guild_id,int account_id,const char *mes,int len) *---------------------------------------------------*/ int guild_change_memberposition(int guild_id,int account_id,int char_id,short idx) { - return intif_guild_change_memberinfo(guild_id,account_id,char_id,GMI_POSITION,&idx,sizeof(idx)); + return intif->guild_change_memberinfo(guild_id,account_id,char_id,GMI_POSITION,&idx,sizeof(idx)); } /*==================================================== @@ -1106,7 +1106,7 @@ int guild_change_position(int guild_id,int idx, p.mode=mode&0x11; p.exp_mode=exp_mode; safestrncpy(p.name,name,NAME_LENGTH); - return intif_guild_position(guild_id,idx,&p); + return intif->guild_position(guild_id,idx,&p); } /*==================================================== @@ -1137,7 +1137,7 @@ int guild_change_notice(struct map_session_data *sd,int guild_id,const char *mes if(guild_id!=sd->status.guild_id) return 0; - return intif_guild_notice(guild_id,mes1,mes2); + return intif->guild_notice(guild_id,mes1,mes2); } /*==================================================== @@ -1175,7 +1175,7 @@ int guild_change_emblem(struct map_session_data *sd,int len,const char *data) return 0; } - return intif_guild_emblem(sd->status.guild_id,len,data); + return intif->guild_emblem(sd->status.guild_id,len,data); } /*==================================================== @@ -1328,7 +1328,7 @@ int guild_skillup(TBL_PC* sd, uint16 skill_id) if( g->skill_point > 0 && g->skill[idx].id != 0 && g->skill[idx].lv < max ) - intif_guild_skillup(g->guild_id, skill_id, sd->status.account_id, max); + intif->guild_skillup(g->guild_id, skill_id, sd->status.account_id, max); return 0; } @@ -1529,18 +1529,18 @@ int guild_reply_reqalliance(struct map_session_data *sd,int account_id,int flag) for(i=0;ialliance[i].guild_id==tsd->status.guild_id && g->alliance[i].opposition==1) - intif_guild_alliance( sd->status.guild_id,tsd->status.guild_id, + intif->guild_alliance( sd->status.guild_id,tsd->status.guild_id, sd->status.account_id,tsd->status.account_id,9 ); } for(i=0;ialliance[i].guild_id==sd->status.guild_id && tg->alliance[i].opposition==1) - intif_guild_alliance( tsd->status.guild_id,sd->status.guild_id, + intif->guild_alliance( tsd->status.guild_id,sd->status.guild_id, tsd->status.account_id,sd->status.account_id,9 ); } // inform other servers - intif_guild_alliance( sd->status.guild_id,tsd->status.guild_id, + intif->guild_alliance( sd->status.guild_id,tsd->status.guild_id, sd->status.account_id,tsd->status.account_id,0 ); return 0; } else { // deny @@ -1564,7 +1564,7 @@ int guild_delalliance(struct map_session_data *sd,int guild_id,int flag) return 0; } // end addition [Valaris] - intif_guild_alliance( sd->status.guild_id,guild_id,sd->status.account_id,0,flag|8 ); + intif->guild_alliance( sd->status.guild_id,guild_id,sd->status.account_id,0,flag|8 ); return 0; } @@ -1600,13 +1600,13 @@ int guild_opposition(struct map_session_data *sd,struct map_session_data *tsd) if(iMap->agit_flag || iMap->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, + 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, + intif->guild_alliance( sd->status.guild_id,tsd->status.guild_id, sd->status.account_id,tsd->status.account_id,1 ); return 0; } @@ -1713,7 +1713,7 @@ int guild_broken_sub(DBKey key, DBData *data, va_list ap) for(j=0;jmax_member;j++) if( (sd=g->member[j].sd)!=NULL ) clif->guild_delalliance(sd,guild_id,g->alliance[i].opposition); - intif_guild_alliance(g->guild_id, guild_id,0,0,g->alliance[i].opposition|8); + intif->guild_alliance(g->guild_id, guild_id,0,0,g->alliance[i].opposition|8); g->alliance[i].guild_id=0; } } @@ -1799,7 +1799,7 @@ int guild_gm_change(int guild_id, struct map_session_data *sd) return 0; //Notify servers that master has changed. - intif_guild_change_gm(guild_id, sd->status.name, strlen(sd->status.name)+1); + intif->guild_change_gm(guild_id, sd->status.name, strlen(sd->status.name)+1); return 1; } @@ -1905,7 +1905,7 @@ int guild_break(struct map_session_data *sd,char *name) { } } - intif_guild_break(g->guild_id); + intif->guild_break(g->guild_id); return 1; } @@ -1929,7 +1929,7 @@ void guild_castle_map_init(void) *(cursor++) = gc->castle_id; } dbi_destroy(iter); - if (intif_guild_castle_dataload(num, castle_ids)) + if (intif->guild_castle_dataload(num, castle_ids)) ShowStatus("Requested '"CL_WHITE"%d"CL_RESET"' guild castles from char-server...\n", num); aFree(castle_ids); } @@ -1996,7 +1996,7 @@ int guild_castledatasave(int castle_id, int index, int value) return 0; } - if (!intif_guild_castle_datasave(castle_id, index, value)) { + if (!intif->guild_castle_datasave(castle_id, index, value)) { guild->castle_reconnect(castle_id, index, value); } return 0; @@ -2006,7 +2006,7 @@ void guild_castle_reconnect_sub(void *key, void *data, va_list ap) { int castle_id = GetWord((int)__64BPTRSIZE(key), 0); int index = GetWord((int)__64BPTRSIZE(key), 1); - intif_guild_castle_datasave(castle_id, index, *(int *)data); + intif->guild_castle_datasave(castle_id, index, *(int *)data); aFree(data); } diff --git a/src/map/homunculus.c b/src/map/homunculus.c index a1dd38b68..3a6ed074c 100644 --- a/src/map/homunculus.c +++ b/src/map/homunculus.c @@ -544,7 +544,7 @@ void homunculus_save(struct homun_data *hd) { //calculation on login) hd->homunculus.hp = hd->battle_status.hp; hd->homunculus.sp = hd->battle_status.sp; - intif_homunculus_requestsave(sd->status.account_id, &hd->homunculus); + intif->homunculus_requestsave(sd->status.account_id, &hd->homunculus); } unsigned char homunculus_menu(struct map_session_data *sd,unsigned char menu_num) { @@ -731,7 +731,7 @@ bool homunculus_create(struct map_session_data *sd, struct s_homunculus *hom) { if(i < 0) { ShowError("homunculus_create: unknown class [%d] for homunculus '%s', requesting deletion.\n", hom->class_, hom->name); sd->status.hom_id = 0; - intif_homunculus_requestdelete(hom->hom_id); + intif->homunculus_requestdelete(hom->hom_id); return false; } sd->hd = hd = (struct homun_data*)aCalloc(1,sizeof(struct homun_data)); @@ -777,7 +777,7 @@ bool homunculus_call(struct map_session_data *sd) { // If homunc not yet loaded, load it if (!sd->hd) - return intif_homunculus_requestload(sd->status.account_id, sd->status.hom_id); + return intif->homunculus_requestload(sd->status.account_id, sd->status.hom_id); hd = sd->hd; @@ -892,7 +892,7 @@ bool homunculus_creation_request(struct map_session_data *sd, int class_) { hom.luk = base->luk *10; // Request homunculus creation - intif_homunculus_create(sd->status.account_id, &hom); + intif->homunculus_create(sd->status.account_id, &hom); return true; } @@ -904,7 +904,7 @@ bool homunculus_ressurect(struct map_session_data* sd, unsigned char per, short return false; // no homunculus if (!sd->hd) //Load homun data; - return intif_homunculus_requestload(sd->status.account_id, sd->status.hom_id); + return intif->homunculus_requestload(sd->status.account_id, sd->status.hom_id); hd = sd->hd; diff --git a/src/map/intif.c b/src/map/intif.c index f2c5e7e78..813c1cf7c 100644 --- a/src/map/intif.c +++ b/src/map/intif.c @@ -1,2259 +1,2351 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder - -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/malloc.h" -#include "../common/strlib.h" -#include "map.h" -#include "battle.h" -#include "chrif.h" -#include "clif.h" -#include "pc.h" -#include "intif.h" -#include "log.h" -#include "storage.h" -#include "party.h" -#include "guild.h" -#include "pet.h" -#include "atcommand.h" -#include "mercenary.h" -#include "homunculus.h" -#include "elemental.h" -#include "mail.h" -#include "quest.h" - -#include -#include -#include -#include -#include -#include - - -static const int packet_len_table[]={ - -1,-1,27,-1, -1, 0,37,-1, 0, 0, 0, 0, 0, 0, 0, 0, //0x3800-0x380f - 0, 0, 0, 0, 0, 0, 0, 0, -1,11, 0, 0, 0, 0, 0, 0, //0x3810 - 39,-1,15,15, 14,19, 7,-1, 0, 0, 0, 0, 0, 0, 0, 0, //0x3820 - 10,-1,15, 0, 79,19, 7,-1, 0,-1,-1,-1, 14,67,186,-1, //0x3830 - -1, 0, 0,14, 0, 0, 0, 0, -1,74,-1,11, 11,-1, 0, 0, //0x3840 - -1,-1, 7, 7, 7,11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3850 Auctions [Zephyrus] - -1, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3860 Quests [Kevin] [Inkfish] - -1, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 3, 3, 0, //0x3870 Mercenaries [Zephyrus] / Elemental [pakpil] - 11,-1, 7, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3880 - -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 - -//----------------------------------------------------------------- -// Send to inter server - -int CheckForCharServer(void) -{ - return ((char_fd <= 0) || session[char_fd] == NULL || session[char_fd]->wdata == NULL); -} - -// pet -int intif_create_pet(int account_id,int char_id,short pet_class,short pet_lv,short pet_egg_id, - short pet_equip,short intimate,short hungry,char rename_flag,char incuvate,char *pet_name) -{ - if (CheckForCharServer()) - return 0; - WFIFOHEAD(inter_fd, 24 + NAME_LENGTH); - WFIFOW(inter_fd,0) = 0x3080; - WFIFOL(inter_fd,2) = account_id; - WFIFOL(inter_fd,6) = char_id; - WFIFOW(inter_fd,10) = pet_class; - WFIFOW(inter_fd,12) = pet_lv; - WFIFOW(inter_fd,14) = pet_egg_id; - WFIFOW(inter_fd,16) = pet_equip; - WFIFOW(inter_fd,18) = intimate; - WFIFOW(inter_fd,20) = hungry; - WFIFOB(inter_fd,22) = rename_flag; - WFIFOB(inter_fd,23) = incuvate; - memcpy(WFIFOP(inter_fd,24),pet_name,NAME_LENGTH); - WFIFOSET(inter_fd,24+NAME_LENGTH); - - return 0; -} - -int intif_request_petdata(int account_id,int char_id,int pet_id) -{ - if (CheckForCharServer()) - return 0; - WFIFOHEAD(inter_fd, 14); - WFIFOW(inter_fd,0) = 0x3081; - WFIFOL(inter_fd,2) = account_id; - WFIFOL(inter_fd,6) = char_id; - WFIFOL(inter_fd,10) = pet_id; - WFIFOSET(inter_fd,14); - - return 0; -} - -int intif_save_petdata(int account_id,struct s_pet *p) -{ - if (CheckForCharServer()) - return 0; - WFIFOHEAD(inter_fd, sizeof(struct s_pet) + 8); - WFIFOW(inter_fd,0) = 0x3082; - WFIFOW(inter_fd,2) = sizeof(struct s_pet) + 8; - WFIFOL(inter_fd,4) = account_id; - memcpy(WFIFOP(inter_fd,8),p,sizeof(struct s_pet)); - WFIFOSET(inter_fd,WFIFOW(inter_fd,2)); - - return 0; -} - -int intif_delete_petdata(int pet_id) -{ - if (CheckForCharServer()) - return 0; - WFIFOHEAD(inter_fd,6); - WFIFOW(inter_fd,0) = 0x3083; - WFIFOL(inter_fd,2) = pet_id; - WFIFOSET(inter_fd,6); - - return 1; -} - -int intif_rename(struct map_session_data *sd, int type, char *name) -{ - if (CheckForCharServer()) - return 1; - - WFIFOHEAD(inter_fd,NAME_LENGTH+12); - WFIFOW(inter_fd,0) = 0x3006; - WFIFOL(inter_fd,2) = sd->status.account_id; - WFIFOL(inter_fd,6) = sd->status.char_id; - WFIFOB(inter_fd,10) = type; //Type: 0 - PC, 1 - PET, 2 - HOM - memcpy(WFIFOP(inter_fd,11),name, NAME_LENGTH); - WFIFOSET(inter_fd,NAME_LENGTH+12); - return 0; -} - -// GM Send a message -int intif_broadcast(const char* mes, int len, int type) -{ - int lp = type ? 4 : 0; - - // Send to the local players - clif->broadcast(NULL, mes, len, type, ALL_CLIENT); - - if (CheckForCharServer()) - return 0; - - if (chrif->other_mapserver_count < 1) - return 0; //No need to send. - - WFIFOHEAD(inter_fd, 16 + lp + len); - WFIFOW(inter_fd,0) = 0x3000; - WFIFOW(inter_fd,2) = 16 + lp + len; - WFIFOL(inter_fd,4) = 0xFF000000; // 0xFF000000 color signals standard broadcast - WFIFOW(inter_fd,8) = 0; // fontType not used with standard broadcast - WFIFOW(inter_fd,10) = 0; // fontSize not used with standard broadcast - WFIFOW(inter_fd,12) = 0; // fontAlign not used with standard broadcast - WFIFOW(inter_fd,14) = 0; // fontY not used with standard broadcast - if (type == 0x10) // bc_blue - WFIFOL(inter_fd,16) = 0x65756c62; //If there's "blue" at the beginning of the message, game client will display it in blue instead of yellow. - else if (type == 0x20) // bc_woe - WFIFOL(inter_fd,16) = 0x73737373; //If there's "ssss", game client will recognize message as 'WoE broadcast'. - memcpy(WFIFOP(inter_fd,16 + lp), mes, len); - WFIFOSET(inter_fd, WFIFOW(inter_fd,2)); - return 0; -} - -int intif_broadcast2(const char* mes, int len, unsigned long fontColor, short fontType, short fontSize, short fontAlign, short fontY) -{ - // Send to the local players - clif->broadcast2(NULL, mes, len, fontColor, fontType, fontSize, fontAlign, fontY, ALL_CLIENT); - - if (CheckForCharServer()) - return 0; - - if (chrif->other_mapserver_count < 1) - return 0; //No need to send. - - WFIFOHEAD(inter_fd, 16 + len); - WFIFOW(inter_fd,0) = 0x3000; - WFIFOW(inter_fd,2) = 16 + len; - WFIFOL(inter_fd,4) = fontColor; - WFIFOW(inter_fd,8) = fontType; - WFIFOW(inter_fd,10) = fontSize; - WFIFOW(inter_fd,12) = fontAlign; - WFIFOW(inter_fd,14) = fontY; - memcpy(WFIFOP(inter_fd,16), mes, len); - WFIFOSET(inter_fd, WFIFOW(inter_fd,2)); - return 0; -} - -/// send a message using the main chat system -/// the source of message -/// the message that was sent -int intif_main_message(struct map_session_data* sd, const char* message) -{ - char output[256]; - - nullpo_ret(sd); - - // format the message for main broadcasting - snprintf( output, sizeof(output), msg_txt(386), sd->status.name, message ); - - // send the message using the inter-server broadcast service - intif_broadcast2( output, strlen(output) + 1, 0xFE000000, 0, 0, 0, 0 ); - - // log the chat message - logs->chat( LOG_CHAT_MAINCHAT, 0, sd->status.char_id, sd->status.account_id, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, NULL, message ); - - return 0; -} - -// The transmission of Wisp/Page to inter-server (player not found on this server) -int intif_wis_message(struct map_session_data *sd, char *nick, char *mes, int mes_len) -{ - nullpo_ret(sd); - if (CheckForCharServer()) - return 0; - - if (chrif->other_mapserver_count < 1) - { //Character not found. - clif->wis_end(sd->fd, 1); - return 0; - } - - WFIFOHEAD(inter_fd,mes_len + 52); - WFIFOW(inter_fd,0) = 0x3001; - WFIFOW(inter_fd,2) = mes_len + 52; - memcpy(WFIFOP(inter_fd,4), sd->status.name, NAME_LENGTH); - memcpy(WFIFOP(inter_fd,4+NAME_LENGTH), nick, NAME_LENGTH); - memcpy(WFIFOP(inter_fd,4+2*NAME_LENGTH), mes, mes_len); - WFIFOSET(inter_fd, WFIFOW(inter_fd,2)); - - if (battle_config.etc_log) - ShowInfo("intif_wis_message from %s to %s (message: '%s')\n", sd->status.name, nick, mes); - - return 0; -} - -// The reply of Wisp/page -int intif_wis_replay(int id, int flag) -{ - if (CheckForCharServer()) - return 0; - WFIFOHEAD(inter_fd,7); - WFIFOW(inter_fd,0) = 0x3002; - WFIFOL(inter_fd,2) = id; - WFIFOB(inter_fd,6) = flag; // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target - WFIFOSET(inter_fd,7); - - if (battle_config.etc_log) - ShowInfo("intif_wis_replay: id: %d, flag:%d\n", id, flag); - - return 0; -} - -// The transmission of GM only Wisp/Page from server to inter-server -int intif_wis_message_to_gm(char *wisp_name, int permission, char *mes) -{ - int mes_len; - if (CheckForCharServer()) - return 0; - mes_len = strlen(mes) + 1; // + null - WFIFOHEAD(inter_fd, mes_len + 32); - WFIFOW(inter_fd,0) = 0x3003; - WFIFOW(inter_fd,2) = mes_len + 32; - memcpy(WFIFOP(inter_fd,4), wisp_name, NAME_LENGTH); - WFIFOL(inter_fd,4+NAME_LENGTH) = permission; - memcpy(WFIFOP(inter_fd,8+NAME_LENGTH), mes, mes_len); - WFIFOSET(inter_fd, WFIFOW(inter_fd,2)); - - if (battle_config.etc_log) - ShowNotice("intif_wis_message_to_gm: from: '%s', required permission: %d, message: '%s'.\n", wisp_name, permission, mes); - - return 0; -} - -int intif_regtostr(char* str, struct global_reg *reg, int qty) -{ - int len =0, i; - - for (i = 0; i < qty; i++) { - len+= sprintf(str+len, "%s", reg[i].str)+1; //We add 1 to consider the '\0' in place. - len+= sprintf(str+len, "%s", reg[i].value)+1; - } - return len; -} - -//Request for saving registry values. -int intif_saveregistry(struct map_session_data *sd, int type) -{ - struct global_reg *reg; - int count; - int i, p; - - if (CheckForCharServer()) - return -1; - - switch (type) { - case 3: //Character reg - reg = sd->save_reg.global; - count = sd->save_reg.global_num; - sd->state.reg_dirty &= ~0x4; - break; - case 2: //Account reg - reg = sd->save_reg.account; - count = sd->save_reg.account_num; - sd->state.reg_dirty &= ~0x2; - break; - case 1: //Account2 reg - reg = sd->save_reg.account2; - count = sd->save_reg.account2_num; - sd->state.reg_dirty &= ~0x1; - break; - default: //Broken code? - ShowError("intif_saveregistry: Invalid type %d\n", type); - return -1; - } - WFIFOHEAD(inter_fd, 288 * MAX_REG_NUM+13); - WFIFOW(inter_fd,0)=0x3004; - WFIFOL(inter_fd,4)=sd->status.account_id; - WFIFOL(inter_fd,8)=sd->status.char_id; - WFIFOB(inter_fd,12)=type; - for( p = 13, i = 0; i < count; i++ ) { - if (reg[i].str[0] != '\0' && reg[i].value[0] != '\0') { - p+= sprintf((char*)WFIFOP(inter_fd,p), "%s", reg[i].str)+1; //We add 1 to consider the '\0' in place. - p+= sprintf((char*)WFIFOP(inter_fd,p), "%s", reg[i].value)+1; - } - } - WFIFOW(inter_fd,2)=p; - WFIFOSET(inter_fd,WFIFOW(inter_fd,2)); - return 0; -} - -//Request the registries for this player. -int intif_request_registry(struct map_session_data *sd, int flag) -{ - nullpo_ret(sd); - - sd->save_reg.account2_num = -1; - sd->save_reg.account_num = -1; - sd->save_reg.global_num = -1; - - if (CheckForCharServer()) - return 0; - - WFIFOHEAD(inter_fd,6); - WFIFOW(inter_fd,0) = 0x3005; - WFIFOL(inter_fd,2) = sd->status.account_id; - WFIFOL(inter_fd,6) = sd->status.char_id; - WFIFOB(inter_fd,10) = (flag&1?1:0); //Request Acc Reg 2 - WFIFOB(inter_fd,11) = (flag&2?1:0); //Request Acc Reg - WFIFOB(inter_fd,12) = (flag&4?1:0); //Request Char Reg - WFIFOSET(inter_fd,13); - - return 0; -} - -int intif_request_guild_storage(int account_id,int guild_id) -{ - if (CheckForCharServer()) - return 0; - WFIFOHEAD(inter_fd,10); - WFIFOW(inter_fd,0) = 0x3018; - WFIFOL(inter_fd,2) = account_id; - WFIFOL(inter_fd,6) = guild_id; - WFIFOSET(inter_fd,10); - return 0; -} -int intif_send_guild_storage(int account_id,struct guild_storage *gstor) -{ - if (CheckForCharServer()) - return 0; - WFIFOHEAD(inter_fd,sizeof(struct guild_storage)+12); - WFIFOW(inter_fd,0) = 0x3019; - WFIFOW(inter_fd,2) = (unsigned short)sizeof(struct guild_storage)+12; - WFIFOL(inter_fd,4) = account_id; - WFIFOL(inter_fd,8) = gstor->guild_id; - memcpy( WFIFOP(inter_fd,12),gstor, sizeof(struct guild_storage) ); - WFIFOSET(inter_fd,WFIFOW(inter_fd,2)); - return 0; -} - -// Party creation request -int intif_create_party(struct party_member *member,char *name,int item,int item2) -{ - if (CheckForCharServer()) - return 0; - nullpo_ret(member); - - WFIFOHEAD(inter_fd,64); - WFIFOW(inter_fd,0) = 0x3020; - WFIFOW(inter_fd,2) = 30+sizeof(struct party_member); - memcpy(WFIFOP(inter_fd,4),name, NAME_LENGTH); - WFIFOB(inter_fd,28)= item; - WFIFOB(inter_fd,29)= item2; - memcpy(WFIFOP(inter_fd,30), member, sizeof(struct party_member)); - WFIFOSET(inter_fd,WFIFOW(inter_fd, 2)); - return 0; -} - -// Party information request -int intif_request_partyinfo(int party_id, int char_id) -{ - if (CheckForCharServer()) - return 0; - WFIFOHEAD(inter_fd,10); - WFIFOW(inter_fd,0) = 0x3021; - WFIFOL(inter_fd,2) = party_id; - WFIFOL(inter_fd,6) = char_id; - WFIFOSET(inter_fd,10); - return 0; -} - -// Request to add a member to party -int intif_party_addmember(int party_id,struct party_member *member) -{ - if (CheckForCharServer()) - return 0; - WFIFOHEAD(inter_fd,42); - WFIFOW(inter_fd,0)=0x3022; - WFIFOW(inter_fd,2)=8+sizeof(struct party_member); - WFIFOL(inter_fd,4)=party_id; - memcpy(WFIFOP(inter_fd,8),member,sizeof(struct party_member)); - WFIFOSET(inter_fd,WFIFOW(inter_fd, 2)); - return 1; -} - -// Request to change party configuration (exp,item share) -int intif_party_changeoption(int party_id,int account_id,int exp,int item) -{ - if (CheckForCharServer()) - return 0; - WFIFOHEAD(inter_fd,14); - WFIFOW(inter_fd,0)=0x3023; - WFIFOL(inter_fd,2)=party_id; - WFIFOL(inter_fd,6)=account_id; - WFIFOW(inter_fd,10)=exp; - WFIFOW(inter_fd,12)=item; - WFIFOSET(inter_fd,14); - return 0; -} - -// Request to leave party -int intif_party_leave(int party_id,int account_id, int char_id) -{ - if (CheckForCharServer()) - return 0; - WFIFOHEAD(inter_fd,14); - WFIFOW(inter_fd,0)=0x3024; - WFIFOL(inter_fd,2)=party_id; - WFIFOL(inter_fd,6)=account_id; - WFIFOL(inter_fd,10)=char_id; - WFIFOSET(inter_fd,14); - return 0; -} - -// Request keeping party for new map ?? -int intif_party_changemap(struct map_session_data *sd,int online) -{ - int16 m, mapindex; - - if (CheckForCharServer()) - return 0; - if(!sd) - return 0; - - if( (m=iMap->mapindex2mapid(sd->mapindex)) >= 0 && map[m].instance_id >= 0 ) - mapindex = map[map[m].instance_src_map].index; - else - mapindex = sd->mapindex; - - WFIFOHEAD(inter_fd,19); - WFIFOW(inter_fd,0)=0x3025; - WFIFOL(inter_fd,2)=sd->status.party_id; - WFIFOL(inter_fd,6)=sd->status.account_id; - WFIFOL(inter_fd,10)=sd->status.char_id; - WFIFOW(inter_fd,14)=mapindex; - WFIFOB(inter_fd,16)=online; - WFIFOW(inter_fd,17)=sd->status.base_level; - WFIFOSET(inter_fd,19); - return 1; -} - -// Request breaking party -int intif_break_party(int party_id) -{ - if (CheckForCharServer()) - return 0; - WFIFOHEAD(inter_fd,6); - WFIFOW(inter_fd,0)=0x3026; - WFIFOL(inter_fd,2)=party_id; - WFIFOSET(inter_fd,6); - return 0; -} - -// Sending party chat -int intif_party_message(int party_id,int account_id,const char *mes,int len) -{ - if (CheckForCharServer()) - return 0; - - if (chrif->other_mapserver_count < 1) - return 0; //No need to send. - - WFIFOHEAD(inter_fd,len + 12); - WFIFOW(inter_fd,0)=0x3027; - WFIFOW(inter_fd,2)=len+12; - WFIFOL(inter_fd,4)=party_id; - WFIFOL(inter_fd,8)=account_id; - memcpy(WFIFOP(inter_fd,12),mes,len); - WFIFOSET(inter_fd,len+12); - return 0; -} - -// Request a new leader for party -int intif_party_leaderchange(int party_id,int account_id,int char_id) -{ - if (CheckForCharServer()) - return 0; - WFIFOHEAD(inter_fd,14); - WFIFOW(inter_fd,0)=0x3029; - WFIFOL(inter_fd,2)=party_id; - WFIFOL(inter_fd,6)=account_id; - WFIFOL(inter_fd,10)=char_id; - WFIFOSET(inter_fd,14); - return 0; -} - -// Request a Guild creation -int intif_guild_create(const char *name,const struct guild_member *master) -{ - if (CheckForCharServer()) - return 0; - nullpo_ret(master); - - WFIFOHEAD(inter_fd,sizeof(struct guild_member)+(8+NAME_LENGTH)); - WFIFOW(inter_fd,0)=0x3030; - WFIFOW(inter_fd,2)=sizeof(struct guild_member)+(8+NAME_LENGTH); - WFIFOL(inter_fd,4)=master->account_id; - memcpy(WFIFOP(inter_fd,8),name,NAME_LENGTH); - memcpy(WFIFOP(inter_fd,8+NAME_LENGTH),master,sizeof(struct guild_member)); - WFIFOSET(inter_fd,WFIFOW(inter_fd,2)); - return 0; -} - -// Request Guild information -int intif_guild_request_info(int guild_id) -{ - if (CheckForCharServer()) - return 0; - WFIFOHEAD(inter_fd,6); - WFIFOW(inter_fd,0) = 0x3031; - WFIFOL(inter_fd,2) = guild_id; - WFIFOSET(inter_fd,6); - return 0; -} - -// Request to add member to the guild -int intif_guild_addmember(int guild_id,struct guild_member *m) -{ - if (CheckForCharServer()) - return 0; - WFIFOHEAD(inter_fd,sizeof(struct guild_member)+8); - WFIFOW(inter_fd,0) = 0x3032; - WFIFOW(inter_fd,2) = sizeof(struct guild_member)+8; - WFIFOL(inter_fd,4) = guild_id; - memcpy(WFIFOP(inter_fd,8),m,sizeof(struct guild_member)); - WFIFOSET(inter_fd,WFIFOW(inter_fd,2)); - return 0; -} - -// Request a new leader for guild -int intif_guild_change_gm(int guild_id, const char* name, int len) -{ - if (CheckForCharServer()) - return 0; - WFIFOHEAD(inter_fd, len + 8); - WFIFOW(inter_fd, 0)=0x3033; - WFIFOW(inter_fd, 2)=len+8; - WFIFOL(inter_fd, 4)=guild_id; - memcpy(WFIFOP(inter_fd,8),name,len); - WFIFOSET(inter_fd,len+8); - return 0; -} - -// Request to leave guild -int intif_guild_leave(int guild_id,int account_id,int char_id,int flag,const char *mes) -{ - if (CheckForCharServer()) - return 0; - WFIFOHEAD(inter_fd, 55); - WFIFOW(inter_fd, 0) = 0x3034; - WFIFOL(inter_fd, 2) = guild_id; - WFIFOL(inter_fd, 6) = account_id; - WFIFOL(inter_fd,10) = char_id; - WFIFOB(inter_fd,14) = flag; - safestrncpy((char*)WFIFOP(inter_fd,15),mes,40); - WFIFOSET(inter_fd,55); - return 0; -} - -//Update request / Lv online status of the guild members -int intif_guild_memberinfoshort(int guild_id,int account_id,int char_id,int online,int lv,int class_) -{ - if (CheckForCharServer()) - return 0; - WFIFOHEAD(inter_fd, 19); - WFIFOW(inter_fd, 0) = 0x3035; - WFIFOL(inter_fd, 2) = guild_id; - WFIFOL(inter_fd, 6) = account_id; - WFIFOL(inter_fd,10) = char_id; - WFIFOB(inter_fd,14) = online; - WFIFOW(inter_fd,15) = lv; - WFIFOW(inter_fd,17) = class_; - WFIFOSET(inter_fd,19); - return 0; -} - -//Guild disbanded notification -int intif_guild_break(int guild_id) -{ - if (CheckForCharServer()) - return 0; - WFIFOHEAD(inter_fd, 6); - WFIFOW(inter_fd, 0) = 0x3036; - WFIFOL(inter_fd, 2) = guild_id; - WFIFOSET(inter_fd,6); - return 0; -} - -// Send a guild message -int intif_guild_message(int guild_id,int account_id,const char *mes,int len) -{ - if (CheckForCharServer()) - return 0; - - if (chrif->other_mapserver_count < 1) - return 0; //No need to send. - - WFIFOHEAD(inter_fd, len + 12); - WFIFOW(inter_fd,0)=0x3037; - WFIFOW(inter_fd,2)=len+12; - WFIFOL(inter_fd,4)=guild_id; - WFIFOL(inter_fd,8)=account_id; - memcpy(WFIFOP(inter_fd,12),mes,len); - WFIFOSET(inter_fd,len+12); - - return 0; -} - -// Request a change of Guild basic information -int intif_guild_change_basicinfo(int guild_id,int type,const void *data,int len) -{ - if (CheckForCharServer()) - return 0; - WFIFOHEAD(inter_fd, len + 10); - WFIFOW(inter_fd,0)=0x3039; - WFIFOW(inter_fd,2)=len+10; - WFIFOL(inter_fd,4)=guild_id; - WFIFOW(inter_fd,8)=type; - memcpy(WFIFOP(inter_fd,10),data,len); - WFIFOSET(inter_fd,len+10); - return 0; -} - -// Request a change of Guild member information -int intif_guild_change_memberinfo(int guild_id,int account_id,int char_id, - int type,const void *data,int len) -{ - if (CheckForCharServer()) - return 0; - WFIFOHEAD(inter_fd, len + 18); - WFIFOW(inter_fd, 0)=0x303a; - WFIFOW(inter_fd, 2)=len+18; - WFIFOL(inter_fd, 4)=guild_id; - WFIFOL(inter_fd, 8)=account_id; - WFIFOL(inter_fd,12)=char_id; - WFIFOW(inter_fd,16)=type; - memcpy(WFIFOP(inter_fd,18),data,len); - WFIFOSET(inter_fd,len+18); - return 0; -} - -// Request a change of Guild title -int intif_guild_position(int guild_id,int idx,struct guild_position *p) -{ - if (CheckForCharServer()) - return 0; - WFIFOHEAD(inter_fd, sizeof(struct guild_position)+12); - WFIFOW(inter_fd,0)=0x303b; - WFIFOW(inter_fd,2)=sizeof(struct guild_position)+12; - WFIFOL(inter_fd,4)=guild_id; - WFIFOL(inter_fd,8)=idx; - memcpy(WFIFOP(inter_fd,12),p,sizeof(struct guild_position)); - WFIFOSET(inter_fd,WFIFOW(inter_fd,2)); - return 0; -} - -// Request an update of Guildskill skill_id -int intif_guild_skillup(int guild_id, uint16 skill_id, int account_id, int max) -{ - if( CheckForCharServer() ) - return 0; - WFIFOHEAD(inter_fd, 18); - WFIFOW(inter_fd, 0) = 0x303c; - WFIFOL(inter_fd, 2) = guild_id; - WFIFOL(inter_fd, 6) = skill_id; - WFIFOL(inter_fd, 10) = account_id; - WFIFOL(inter_fd, 14) = max; - WFIFOSET(inter_fd, 18); - return 0; -} - -// Request a new guild relationship -int intif_guild_alliance(int guild_id1,int guild_id2,int account_id1,int account_id2,int flag) -{ - if (CheckForCharServer()) - return 0; - WFIFOHEAD(inter_fd,19); - WFIFOW(inter_fd, 0)=0x303d; - WFIFOL(inter_fd, 2)=guild_id1; - WFIFOL(inter_fd, 6)=guild_id2; - WFIFOL(inter_fd,10)=account_id1; - WFIFOL(inter_fd,14)=account_id2; - WFIFOB(inter_fd,18)=flag; - WFIFOSET(inter_fd,19); - return 0; -} - -// Request to change guild notice -int intif_guild_notice(int guild_id,const char *mes1,const char *mes2) -{ - if (CheckForCharServer()) - return 0; - WFIFOHEAD(inter_fd,186); - WFIFOW(inter_fd,0)=0x303e; - WFIFOL(inter_fd,2)=guild_id; - memcpy(WFIFOP(inter_fd,6),mes1,MAX_GUILDMES1); - memcpy(WFIFOP(inter_fd,66),mes2,MAX_GUILDMES2); - WFIFOSET(inter_fd,186); - return 0; -} - -// Request to change guild emblem -int intif_guild_emblem(int guild_id,int len,const char *data) -{ - if (CheckForCharServer()) - return 0; - if(guild_id<=0 || len<0 || len>2000) - return 0; - WFIFOHEAD(inter_fd,len + 12); - WFIFOW(inter_fd,0)=0x303f; - WFIFOW(inter_fd,2)=len+12; - WFIFOL(inter_fd,4)=guild_id; - WFIFOL(inter_fd,8)=0; - memcpy(WFIFOP(inter_fd,12),data,len); - WFIFOSET(inter_fd,len+12); - return 0; -} - -/** - * Requests guild castles data from char-server. - * @param num Number of castles, size of castle_ids array. - * @param castle_ids Pointer to array of castle IDs. - */ -int intif_guild_castle_dataload(int num, int *castle_ids) -{ - if (CheckForCharServer()) - return 0; - WFIFOHEAD(inter_fd, 4 + num * sizeof(int)); - WFIFOW(inter_fd, 0) = 0x3040; - WFIFOW(inter_fd, 2) = 4 + num * sizeof(int); - memcpy(WFIFOP(inter_fd, 4), castle_ids, num * sizeof(int)); - WFIFOSET(inter_fd, WFIFOW(inter_fd, 2)); - return 1; -} - - -// Request change castle guild owner and save data -int intif_guild_castle_datasave(int castle_id,int index, int value) -{ - if (CheckForCharServer()) - return 0; - WFIFOHEAD(inter_fd,9); - WFIFOW(inter_fd,0)=0x3041; - WFIFOW(inter_fd,2)=castle_id; - WFIFOB(inter_fd,4)=index; - WFIFOL(inter_fd,5)=value; - WFIFOSET(inter_fd,9); - return 1; -} - -//----------------------------------------------------------------- -// Homunculus Packets send to Inter server [albator] -//----------------------------------------------------------------- - -int intif_homunculus_create(int account_id, struct s_homunculus *sh) -{ - if (CheckForCharServer()) - return 0; - WFIFOHEAD(inter_fd, sizeof(struct s_homunculus)+8); - WFIFOW(inter_fd,0) = 0x3090; - WFIFOW(inter_fd,2) = sizeof(struct s_homunculus)+8; - WFIFOL(inter_fd,4) = account_id; - memcpy(WFIFOP(inter_fd,8),sh,sizeof(struct s_homunculus)); - WFIFOSET(inter_fd, WFIFOW(inter_fd,2)); - return 0; -} - -bool intif_homunculus_requestload(int account_id, int homun_id) { - if (CheckForCharServer()) - return false; - WFIFOHEAD(inter_fd, 10); - WFIFOW(inter_fd,0) = 0x3091; - WFIFOL(inter_fd,2) = account_id; - WFIFOL(inter_fd,6) = homun_id; - WFIFOSET(inter_fd, 10); - return true; -} - -int intif_homunculus_requestsave(int account_id, struct s_homunculus* sh) -{ - if (CheckForCharServer()) - return 0; - WFIFOHEAD(inter_fd, sizeof(struct s_homunculus)+8); - WFIFOW(inter_fd,0) = 0x3092; - WFIFOW(inter_fd,2) = sizeof(struct s_homunculus)+8; - WFIFOL(inter_fd,4) = account_id; - memcpy(WFIFOP(inter_fd,8),sh,sizeof(struct s_homunculus)); - WFIFOSET(inter_fd, WFIFOW(inter_fd,2)); - return 0; - -} - -int intif_homunculus_requestdelete(int homun_id) -{ - if (CheckForCharServer()) - return 0; - WFIFOHEAD(inter_fd, 6); - WFIFOW(inter_fd, 0) = 0x3093; - WFIFOL(inter_fd,2) = homun_id; - WFIFOSET(inter_fd,6); - return 0; - -} - - -//----------------------------------------------------------------- -// Packets receive from inter server - -// Wisp/Page reception // rewritten by [Yor] -int intif_parse_WisMessage(int fd) -{ - struct map_session_data* sd; - char *wisp_source; - char name[NAME_LENGTH]; - int id, i; - - 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 - intif_wis_replay(id,1); - return 0; - } - if(sd->state.ignoreAll) { - intif_wis_replay(id, 2); - return 0; - } - wisp_source = (char *) RFIFOP(fd,8); // speed up [Yor] - for(i=0; i < MAX_IGNORE_LIST && - sd->ignore[i].name[0] != '\0' && - strcmp(sd->ignore[i].name, wisp_source) != 0 - ; i++); - - if (i < MAX_IGNORE_LIST && sd->ignore[i].name[0] != '\0') - { //Ignored - intif_wis_replay(id, 2); - return 0; - } - //Success to send whisper. - clif->wis_message(sd->fd, wisp_source, (char*)RFIFOP(fd,56),RFIFOW(fd,2)-56); - intif_wis_replay(id,0); // succes - return 0; -} - -// Wisp/page transmission result reception -int intif_parse_WisEnd(int fd) -{ - struct map_session_data* sd; - - 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)); - if (sd != NULL) - clif->wis_end(sd->fd, RFIFOB(fd,26)); - - return 0; -} - -static int mapif_parse_WisToGM_sub(struct map_session_data* sd,va_list va) -{ - int permission = va_arg(va, int); - char *wisp_name; - char *message; - int len; - - if (!pc_has_permission(sd, permission)) - return 0; - wisp_name = va_arg(va, char*); - message = va_arg(va, char*); - len = va_arg(va, int); - clif->wis_message(sd->fd, wisp_name, message, len); - return 1; -} - -// Received wisp message from map-server via char-server for ALL gm -// 0x3003/0x3803 .w .24B .l .?B -int mapif_parse_WisToGM(int fd) -{ - int permission, mes_len; - char Wisp_name[NAME_LENGTH]; - char mbuf[255]; - char *message; - - mes_len = RFIFOW(fd,2) - 32; - message = (char *) (mes_len >= 255 ? (char *) aMalloc(mes_len) : mbuf); - - permission = RFIFOL(fd,28); - 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); - - if (message != mbuf) - aFree(message); - return 0; -} - -// Request player registre -int intif_parse_Registers(int fd) -{ - int j,p,len,max, flag; - struct map_session_data *sd; - struct global_reg *reg; - int *qty; - int account_id = RFIFOL(fd,4), char_id = RFIFOL(fd,8); - struct auth_node *node = chrif->auth_check(account_id, char_id, ST_LOGIN); - if (node) - sd = node->sd; - else { //Normally registries should arrive for in log-in chars. - sd = iMap->id2sd(account_id); - if (sd && RFIFOB(fd,12) == 3 && sd->status.char_id != char_id) - sd = NULL; //Character registry from another character. - } - if (!sd) return 1; - - flag = (sd->save_reg.global_num == -1 || sd->save_reg.account_num == -1 || sd->save_reg.account2_num == -1); - - switch (RFIFOB(fd,12)) { - case 3: //Character Registry - reg = sd->save_reg.global; - qty = &sd->save_reg.global_num; - max = GLOBAL_REG_NUM; - break; - case 2: //Account Registry - reg = sd->save_reg.account; - qty = &sd->save_reg.account_num; - max = ACCOUNT_REG_NUM; - break; - case 1: //Account2 Registry - reg = sd->save_reg.account2; - qty = &sd->save_reg.account2_num; - max = ACCOUNT_REG2_NUM; - break; - default: - ShowError("intif_parse_Registers: Unrecognized type %d\n",RFIFOB(fd,12)); - return 0; - } - for(j=0,p=13;jsave_reg.global_num > -1 && sd->save_reg.account_num > -1 && sd->save_reg.account2_num > -1) - pc->reg_received(sd); //Received all registry values, execute init scripts and what-not. [Skotlex] - return 1; -} - -int intif_parse_LoadGuildStorage(int fd) -{ - struct guild_storage *gstor; - struct map_session_data *sd; - int guild_id; - - guild_id = RFIFOL(fd,8); - if(guild_id <= 0) - return 1; - sd=iMap->id2sd( RFIFOL(fd,4) ); - if(sd==NULL){ - ShowError("intif_parse_LoadGuildStorage: user not found %d\n",RFIFOL(fd,4)); - return 1; - } - gstor=gstorage->id2storage(guild_id); - if(!gstor) { - ShowWarning("intif_parse_LoadGuildStorage: error guild_id %d not exist\n",guild_id); - return 1; - } - if (gstor->storage_status == 1) { // Already open.. lets ignore this update - ShowWarning("intif_parse_LoadGuildStorage: storage received for a client already open (User %d:%d)\n", sd->status.account_id, sd->status.char_id); - return 1; - } - if (gstor->dirty) { // Already have storage, and it has been modified and not saved yet! Exploit! [Skotlex] - ShowWarning("intif_parse_LoadGuildStorage: received storage for an already modified non-saved storage! (User %d:%d)\n", sd->status.account_id, sd->status.char_id); - return 1; - } - if( RFIFOW(fd,2)-12 != sizeof(struct guild_storage) ){ - ShowError("intif_parse_LoadGuildStorage: data size error %d %d\n",RFIFOW(fd,2)-12 , sizeof(struct guild_storage)); - gstor->storage_status = 0; - return 1; - } - - memcpy(gstor,RFIFOP(fd,12),sizeof(struct guild_storage)); - gstorage->open(sd); - return 0; -} - -// ACK guild_storage saved -int intif_parse_SaveGuildStorage(int fd) -{ - gstorage->saved(/*RFIFOL(fd,2), */RFIFOL(fd,6)); - return 0; -} - -// ACK party creation -int intif_parse_PartyCreated(int fd) -{ - if(battle_config.etc_log) - ShowInfo("intif: party created by account %d\n\n", RFIFOL(fd,2)); - party->created(RFIFOL(fd,2), RFIFOL(fd,6),RFIFOB(fd,10),RFIFOL(fd,11), (char *)RFIFOP(fd,15)); - return 0; -} - -// Receive party info -int intif_parse_PartyInfo(int fd) -{ - if( RFIFOW(fd,2) == 12 ){ - ShowWarning("intif: party noinfo (char_id=%d party_id=%d)\n", RFIFOL(fd,4), RFIFOL(fd,8)); - party->recv_noinfo(RFIFOL(fd,8), RFIFOL(fd,4)); - return 0; - } - - if( RFIFOW(fd,2) != 8+sizeof(struct party) ) - ShowError("intif: party info : data size error (char_id=%d party_id=%d packet_len=%d expected_len=%d)\n", RFIFOL(fd,4), RFIFOL(fd,8), RFIFOW(fd,2), 8+sizeof(struct party)); - party->recv_info((struct party *)RFIFOP(fd,8), RFIFOL(fd,4)); - return 0; -} - -// ACK adding party member -int intif_parse_PartyMemberAdded(int fd) -{ - if(battle_config.etc_log) - ShowInfo("intif: party member added Party (%d), Account(%d), Char(%d)\n",RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10)); - party->member_added(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10), RFIFOB(fd, 14)); - return 0; -} - -// ACK changing party option -int intif_parse_PartyOptionChanged(int fd) -{ - party->optionchanged(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOW(fd,10),RFIFOW(fd,12),RFIFOB(fd,14)); - return 0; -} - -// ACK member leaving party -int intif_parse_PartyMemberWithdraw(int fd) -{ - if(battle_config.etc_log) - ShowInfo("intif: party member withdraw: Party(%d), Account(%d), Char(%d)\n",RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10)); - party->member_withdraw(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10)); - return 0; -} - -// ACK party break -int intif_parse_PartyBroken(int fd) -{ - party->broken(RFIFOL(fd,2)); - return 0; -} - -// ACK party on new map -int intif_parse_PartyMove(int fd) -{ - party->recv_movemap(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOW(fd,14),RFIFOB(fd,16),RFIFOW(fd,17)); - return 0; -} - -// ACK party messages -int intif_parse_PartyMessage(int fd) -{ - party->recv_message(RFIFOL(fd,4),RFIFOL(fd,8),(char *) RFIFOP(fd,12),RFIFOW(fd,2)-12); - return 0; -} - -// ACK guild creation -int intif_parse_GuildCreated(int fd) -{ - guild->created(RFIFOL(fd,2),RFIFOL(fd,6)); - return 0; -} - -// ACK guild infos -int intif_parse_GuildInfo(int fd) -{ - if(RFIFOW(fd,2) == 8) { - ShowWarning("intif: guild noinfo %d\n",RFIFOL(fd,4)); - guild->recv_noinfo(RFIFOL(fd,4)); - return 0; - } - if( RFIFOW(fd,2)!=sizeof(struct guild)+4 ) - ShowError("intif: guild info : data size error Gid: %d recv size: %d Expected size: %d\n",RFIFOL(fd,4),RFIFOW(fd,2),sizeof(struct guild)+4); - guild->recv_info((struct guild *)RFIFOP(fd,4)); - return 0; -} - -// ACK adding guild member -int intif_parse_GuildMemberAdded(int fd) -{ - if(battle_config.etc_log) - ShowInfo("intif: guild member added %d %d %d %d\n",RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOB(fd,14)); - guild->member_added(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOB(fd,14)); - return 0; -} - -// ACK member leaving guild -int intif_parse_GuildMemberWithdraw(int fd) -{ - guild->member_withdraw(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOB(fd,14),(char *)RFIFOP(fd,55),(char *)RFIFOP(fd,15)); - return 0; -} - -// ACK guild member basic info -int intif_parse_GuildMemberInfoShort(int fd) -{ - guild->recv_memberinfoshort(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOB(fd,14),RFIFOW(fd,15),RFIFOW(fd,17)); - return 0; -} - -// ACK guild break -int intif_parse_GuildBroken(int fd) -{ - guild->broken(RFIFOL(fd,2),RFIFOB(fd,6)); - return 0; -} - -// basic guild info change notice -// 0x3839 .w .l .w .?b -int intif_parse_GuildBasicInfoChanged(int fd) -{ - //int len = RFIFOW(fd,2) - 10; - int guild_id = RFIFOL(fd,4); - int type = RFIFOW(fd,8); - //void* data = RFIFOP(fd,10); - - struct guild* g = guild->search(guild_id); - if( g == NULL ) - return 0; - - switch(type) { - case GBI_EXP: g->exp = RFIFOQ(fd,10); break; - case GBI_GUILDLV: g->guild_lv = RFIFOW(fd,10); break; - case GBI_SKILLPOINT: g->skill_point = RFIFOL(fd,10); break; - } - - return 0; -} - -// guild member info change notice -// 0x383a .w .l .l .l .w .?b -int intif_parse_GuildMemberInfoChanged(int fd) -{ - //int len = RFIFOW(fd,2) - 18; - int guild_id = RFIFOL(fd,4); - int account_id = RFIFOL(fd,8); - int char_id = RFIFOL(fd,12); - int type = RFIFOW(fd,16); - //void* data = RFIFOP(fd,18); - - struct guild* g; - int idx; - - g = guild->search(guild_id); - if( g == NULL ) - return 0; - - idx = guild->getindex(g,account_id,char_id); - if( idx == -1 ) - return 0; - - switch( type ) { - case GMI_POSITION: g->member[idx].position = RFIFOW(fd,18); guild->memberposition_changed(g,idx,RFIFOW(fd,18)); break; - case GMI_EXP: g->member[idx].exp = RFIFOQ(fd,18); break; - case GMI_HAIR: g->member[idx].hair = RFIFOW(fd,18); break; - case GMI_HAIR_COLOR: g->member[idx].hair_color = RFIFOW(fd,18); break; - case GMI_GENDER: g->member[idx].gender = RFIFOW(fd,18); break; - case GMI_CLASS: g->member[idx].class_ = RFIFOW(fd,18); break; - case GMI_LEVEL: g->member[idx].lv = RFIFOW(fd,18); break; - } - return 0; -} - -// ACK change of guild title -int intif_parse_GuildPosition(int fd) -{ - if( RFIFOW(fd,2)!=sizeof(struct guild_position)+12 ) - ShowError("intif: guild info : data size error\n %d %d %d",RFIFOL(fd,4),RFIFOW(fd,2),sizeof(struct guild_position)+12); - guild->position_changed(RFIFOL(fd,4),RFIFOL(fd,8),(struct guild_position *)RFIFOP(fd,12)); - return 0; -} - -// ACK change of guild skill update -int intif_parse_GuildSkillUp(int fd) -{ - guild->skillupack(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10)); - return 0; -} - -// ACK change of guild relationship -int intif_parse_GuildAlliance(int fd) -{ - guild->allianceack(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOL(fd,14),RFIFOB(fd,18),(char *) RFIFOP(fd,19),(char *) RFIFOP(fd,43)); - return 0; -} - -// ACK change of guild notice -int intif_parse_GuildNotice(int fd) -{ - guild->notice_changed(RFIFOL(fd,2),(char *) RFIFOP(fd,6),(char *) RFIFOP(fd,66)); - return 0; -} - -// ACK change of guild emblem -int intif_parse_GuildEmblem(int fd) -{ - guild->emblem_changed(RFIFOW(fd,2)-12,RFIFOL(fd,4),RFIFOL(fd,8), (char *)RFIFOP(fd,12)); - return 0; -} - -// ACK guild message -int intif_parse_GuildMessage(int fd) -{ - guild->recv_message(RFIFOL(fd,4),RFIFOL(fd,8),(char *) RFIFOP(fd,12),RFIFOW(fd,2)-12); - return 0; -} - -// Reply guild castle data request -int intif_parse_GuildCastleDataLoad(int fd) -{ - return guild->castledataloadack(RFIFOW(fd,2), (struct guild_castle *)RFIFOP(fd,4)); -} - -// ACK change of guildmaster -int intif_parse_GuildMasterChanged(int fd) -{ - return guild->gm_changed(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10)); -} - -// Request pet creation -int intif_parse_CreatePet(int fd) -{ - pet_get_egg(RFIFOL(fd,2),RFIFOL(fd,7),RFIFOB(fd,6)); - return 0; -} - -// ACK pet data -int intif_parse_RecvPetData(int fd) -{ - struct s_pet p; - int len; - len=RFIFOW(fd,2); - if(sizeof(struct s_pet)!=len-9) { - if(battle_config.etc_log) - ShowError("intif: pet data: data size error %d %d\n",sizeof(struct s_pet),len-9); - } - else{ - memcpy(&p,RFIFOP(fd,9),sizeof(struct s_pet)); - pet_recv_petdata(RFIFOL(fd,4),&p,RFIFOB(fd,8)); - } - - return 0; -} - -// ACK pet save data -int intif_parse_SavePetOk(int fd) -{ - if(RFIFOB(fd,6) == 1) - ShowError("pet data save failure\n"); - - return 0; -} - -// ACK deleting pet -int intif_parse_DeletePetOk(int fd) -{ - if(RFIFOB(fd,2) == 1) - ShowError("pet data delete failure\n"); - - return 0; -} - -// ACK changing name resquest, players,pets,hommon -int intif_parse_ChangeNameOk(int fd) -{ - struct map_session_data *sd = NULL; - if((sd=iMap->id2sd(RFIFOL(fd,2)))==NULL || - sd->status.char_id != RFIFOL(fd,6)) - return 0; - - switch (RFIFOB(fd,10)) { - case 0: //Players [NOT SUPPORTED YET] - break; - case 1: //Pets - pet_change_name_ack(sd, (char*)RFIFOP(fd,12), RFIFOB(fd,11)); - break; - case 2: //Hom - homun->change_name_ack(sd, (char*)RFIFOP(fd,12), RFIFOB(fd,11)); - break; - } - return 0; -} - -//---------------------------------------------------------------- -// Homunculus recv packets [albator] - -int intif_parse_CreateHomunculus(int fd) -{ - int len; - len=RFIFOW(fd,2)-9; - if(sizeof(struct s_homunculus)!=len) { - if(battle_config.etc_log) - ShowError("intif: create homun data: data size error %d != %d\n",sizeof(struct s_homunculus),len); - return 0; - } - homun->recv_data(RFIFOL(fd,4), (struct s_homunculus*)RFIFOP(fd,9), RFIFOB(fd,8)) ; - return 0; -} - -int intif_parse_RecvHomunculusData(int fd) -{ - int len; - - len=RFIFOW(fd,2)-9; - - if(sizeof(struct s_homunculus)!=len) { - if(battle_config.etc_log) - ShowError("intif: homun data: data size error %d %d\n",sizeof(struct s_homunculus),len); - return 0; - } - homun->recv_data(RFIFOL(fd,4), (struct s_homunculus*)RFIFOP(fd,9), RFIFOB(fd,8)); - return 0; -} - -int intif_parse_SaveHomunculusOk(int fd) -{ - if(RFIFOB(fd,6) != 1) - ShowError("homunculus data save failure for account %d\n", RFIFOL(fd,2)); - - return 0; -} - -int intif_parse_DeleteHomunculusOk(int fd) -{ - if(RFIFOB(fd,2) != 1) - ShowError("Homunculus data delete failure\n"); - - return 0; -} - -/************************************** - -QUESTLOG SYSTEM FUNCTIONS - -***************************************/ - -int intif_request_questlog(TBL_PC *sd) -{ - WFIFOHEAD(inter_fd,6); - WFIFOW(inter_fd,0) = 0x3060; - WFIFOL(inter_fd,2) = sd->status.char_id; - WFIFOSET(inter_fd,6); - return 0; -} - -int intif_parse_questlog(int fd) -{ - int char_id = RFIFOL(fd, 4); - int i; - TBL_PC * sd = iMap->charid2sd(char_id); - - //User not online anymore - if(!sd) - return -1; - - sd->avail_quests = sd->num_quests = (RFIFOW(fd, 2)-8)/sizeof(struct quest); - - memset(&sd->quest_log, 0, sizeof(sd->quest_log)); - - for( i = 0; i < sd->num_quests; i++ ) - { - memcpy(&sd->quest_log[i], RFIFOP(fd, i*sizeof(struct quest)+8), sizeof(struct quest)); - - sd->quest_index[i] = quest_search_db(sd->quest_log[i].quest_id); - - if( sd->quest_index[i] < 0 ) - { - ShowError("intif_parse_questlog: quest %d not found in DB.\n",sd->quest_log[i].quest_id); - sd->avail_quests--; - sd->num_quests--; - i--; - continue; - } - - if( sd->quest_log[i].state == Q_COMPLETE ) - sd->avail_quests--; - } - - quest_pc_login(sd); - - return 0; -} - -int intif_parse_questsave(int fd) -{ - int cid = RFIFOL(fd, 2); - TBL_PC *sd = iMap->id2sd(cid); - - if( !RFIFOB(fd, 6) ) - ShowError("intif_parse_questsave: Failed to save quest(s) for character %d!\n", cid); - else if( sd ) - sd->save_quest = false; - - return 0; -} - -int intif_quest_save(TBL_PC *sd) -{ - int len; - - if(CheckForCharServer()) - return 0; - - len = sizeof(struct quest)*sd->num_quests + 8; - - WFIFOHEAD(inter_fd, len); - WFIFOW(inter_fd,0) = 0x3061; - WFIFOW(inter_fd,2) = len; - WFIFOL(inter_fd,4) = sd->status.char_id; - if( sd->num_quests ) - memcpy(WFIFOP(inter_fd,8), &sd->quest_log, sizeof(struct quest)*sd->num_quests); - WFIFOSET(inter_fd, len); - - return 0; -} - -/*========================================== - * MAIL SYSTEM - * By Zephyrus - *==========================================*/ - -/*------------------------------------------ - * Inbox Request - * flag: 0 Update Inbox | 1 OpenMail - *------------------------------------------*/ -int intif_Mail_requestinbox(int char_id, unsigned char flag) -{ - if (CheckForCharServer()) - return 0; - - WFIFOHEAD(inter_fd,7); - WFIFOW(inter_fd,0) = 0x3048; - WFIFOL(inter_fd,2) = char_id; - WFIFOB(inter_fd,6) = flag; - WFIFOSET(inter_fd,7); - - return 0; -} - -int intif_parse_Mail_inboxreceived(int fd) -{ - struct map_session_data *sd; - unsigned char flag = RFIFOB(fd,8); - - sd = iMap->charid2sd(RFIFOL(fd,4)); - - if (sd == NULL) - { - ShowError("intif_parse_Mail_inboxreceived: char not found %d\n",RFIFOL(fd,4)); - return 1; - } - - if (RFIFOW(fd,2) - 9 != sizeof(struct mail_data)) - { - ShowError("intif_parse_Mail_inboxreceived: data size error %d %d\n", RFIFOW(fd,2) - 9, sizeof(struct mail_data)); - return 1; - } - - //FIXME: this operation is not safe [ultramage] - memcpy(&sd->mail.inbox, RFIFOP(fd,9), sizeof(struct mail_data)); - sd->mail.changed = false; // cache is now in sync - - if (flag) - clif->mail_refreshinbox(sd); - else if( battle_config.mail_show_status && ( battle_config.mail_show_status == 1 || sd->mail.inbox.unread ) ) - { - char output[128]; - sprintf(output, msg_txt(510), sd->mail.inbox.unchecked, sd->mail.inbox.unread + sd->mail.inbox.unchecked); - clif->disp_onlyself(sd, output, strlen(output)); - } - return 0; -} -/*------------------------------------------ - * Mail Read - *------------------------------------------*/ -int intif_Mail_read(int mail_id) -{ - if (CheckForCharServer()) - return 0; - - WFIFOHEAD(inter_fd,6); - WFIFOW(inter_fd,0) = 0x3049; - WFIFOL(inter_fd,2) = mail_id; - WFIFOSET(inter_fd,6); - - return 0; -} -/*------------------------------------------ - * Get Attachment - *------------------------------------------*/ -int intif_Mail_getattach(int char_id, int mail_id) -{ - if (CheckForCharServer()) - return 0; - - WFIFOHEAD(inter_fd,10); - WFIFOW(inter_fd,0) = 0x304a; - WFIFOL(inter_fd,2) = char_id; - WFIFOL(inter_fd,6) = mail_id; - WFIFOSET(inter_fd, 10); - - return 0; -} - -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) ); - - if (sd == NULL) - { - ShowError("intif_parse_Mail_getattach: char not found %d\n",RFIFOL(fd,4)); - return 1; - } - - if (RFIFOW(fd,2) - 12 != sizeof(struct item)) - { - ShowError("intif_parse_Mail_getattach: data size error %d %d\n", RFIFOW(fd,2) - 16, sizeof(struct item)); - return 1; - } - - memcpy(&item, RFIFOP(fd,12), sizeof(struct item)); - - mail->getattachment(sd, zeny, &item); - return 0; -} -/*------------------------------------------ - * Delete Message - *------------------------------------------*/ -int intif_Mail_delete(int char_id, int mail_id) -{ - if (CheckForCharServer()) - return 0; - - WFIFOHEAD(inter_fd,10); - WFIFOW(inter_fd,0) = 0x304b; - WFIFOL(inter_fd,2) = char_id; - WFIFOL(inter_fd,6) = mail_id; - WFIFOSET(inter_fd,10); - - return 0; -} - -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); - if (sd == NULL) - { - ShowError("intif_parse_Mail_delete: char not found %d\n", char_id); - return 1; - } - - if (!failed) - { - int i; - ARR_FIND(0, MAIL_MAX_INBOX, i, sd->mail.inbox.msg[i].id == mail_id); - if( i < MAIL_MAX_INBOX ) - { - memset(&sd->mail.inbox.msg[i], 0, sizeof(struct mail_message)); - sd->mail.inbox.amount--; - } - - if( sd->mail.inbox.full ) - intif_Mail_requestinbox(sd->status.char_id, 1); // Free space is available for new mails - } - - clif->mail_delete(sd->fd, mail_id, failed); - return 0; -} -/*------------------------------------------ - * Return Message - *------------------------------------------*/ -int intif_Mail_return(int char_id, int mail_id) -{ - if (CheckForCharServer()) - return 0; - - WFIFOHEAD(inter_fd,10); - WFIFOW(inter_fd,0) = 0x304c; - WFIFOL(inter_fd,2) = char_id; - WFIFOL(inter_fd,6) = mail_id; - WFIFOSET(inter_fd,10); - - return 0; -} - -int intif_parse_Mail_return(int fd) -{ - struct map_session_data *sd = iMap->charid2sd(RFIFOL(fd,2)); - int mail_id = RFIFOL(fd,6); - short fail = RFIFOB(fd,10); - - if( sd == NULL ) - { - ShowError("intif_parse_Mail_return: char not found %d\n",RFIFOL(fd,2)); - return 1; - } - - if( !fail ) - { - int i; - ARR_FIND(0, MAIL_MAX_INBOX, i, sd->mail.inbox.msg[i].id == mail_id); - if( i < MAIL_MAX_INBOX ) - { - memset(&sd->mail.inbox.msg[i], 0, sizeof(struct mail_message)); - sd->mail.inbox.amount--; - } - - if( sd->mail.inbox.full ) - intif_Mail_requestinbox(sd->status.char_id, 1); // Free space is available for new mails - } - - clif->mail_return(sd->fd, mail_id, fail); - return 0; -} -/*------------------------------------------ - * Send Mail - *------------------------------------------*/ -int intif_Mail_send(int account_id, struct mail_message *msg) -{ - int len = sizeof(struct mail_message) + 8; - - if (CheckForCharServer()) - return 0; - - WFIFOHEAD(inter_fd,len); - WFIFOW(inter_fd,0) = 0x304d; - WFIFOW(inter_fd,2) = len; - WFIFOL(inter_fd,4) = account_id; - memcpy(WFIFOP(inter_fd,8), msg, sizeof(struct mail_message)); - WFIFOSET(inter_fd,len); - - return 1; -} - -static void intif_parse_Mail_send(int fd) -{ - struct mail_message msg; - struct map_session_data *sd; - bool fail; - - if( RFIFOW(fd,2) - 4 != sizeof(struct mail_message) ) - { - ShowError("intif_parse_Mail_send: data size error %d %d\n", RFIFOW(fd,2) - 4, sizeof(struct mail_message)); - return; - } - - memcpy(&msg, RFIFOP(fd,4), sizeof(struct mail_message)); - fail = (msg.id == 0); - - // notify sender - sd = iMap->charid2sd(msg.send_id); - if( sd != NULL ) - { - if( fail ) - mail->deliveryfail(sd, &msg); - else - { - clif->mail_send(sd->fd, false); - if( iMap->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)); - int mail_id = RFIFOL(fd,6); - const char* sender_name = (char*)RFIFOP(fd,10); - const char* title = (char*)RFIFOP(fd,34); - - if( sd == NULL ) - return; - - sd->mail.changed = true; - clif->mail_new(sd->fd, mail_id, sender_name, title); -} - -/*========================================== - * AUCTION SYSTEM - * By Zephyrus - *==========================================*/ -int intif_Auction_requestlist(int char_id, short type, int price, const char* searchtext, short page) -{ - int len = NAME_LENGTH + 16; - - if( CheckForCharServer() ) - return 0; - - WFIFOHEAD(inter_fd,len); - WFIFOW(inter_fd,0) = 0x3050; - WFIFOW(inter_fd,2) = len; - WFIFOL(inter_fd,4) = char_id; - WFIFOW(inter_fd,8) = type; - WFIFOL(inter_fd,10) = price; - WFIFOW(inter_fd,14) = page; - memcpy(WFIFOP(inter_fd,16), searchtext, NAME_LENGTH); - WFIFOSET(inter_fd,len); - - return 0; -} - -static void intif_parse_Auction_results(int fd) -{ - struct map_session_data *sd = iMap->charid2sd(RFIFOL(fd,4)); - short count = RFIFOW(fd,8); - short pages = RFIFOW(fd,10); - uint8* data = RFIFOP(fd,12); - - if( sd == NULL ) - return; - - clif->auction_results(sd, count, pages, data); -} - -int intif_Auction_register(struct auction_data *auction) -{ - int len = sizeof(struct auction_data) + 4; - - if( CheckForCharServer() ) - return 0; - - WFIFOHEAD(inter_fd,len); - WFIFOW(inter_fd,0) = 0x3051; - WFIFOW(inter_fd,2) = len; - memcpy(WFIFOP(inter_fd,4), auction, sizeof(struct auction_data)); - WFIFOSET(inter_fd,len); - - return 1; -} - -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) ) - { - 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 ) - return; - - if( auction.auction_id > 0 ) - { - clif->auction_message(sd->fd, 1); // Confirmation Packet ?? - if( iMap->save_settings&32 ) - chrif->save(sd,0); - } - else - { - int zeny = auction.hours*battle_config.auction_feeperhour; - - clif->auction_message(sd->fd, 4); - pc->additem(sd, &auction.item, auction.item.amount, LOG_TYPE_AUCTION); - - pc->getzeny(sd, zeny, LOG_TYPE_AUCTION, NULL); - } -} - -int intif_Auction_cancel(int char_id, unsigned int auction_id) -{ - if( CheckForCharServer() ) - return 0; - - WFIFOHEAD(inter_fd,10); - WFIFOW(inter_fd,0) = 0x3052; - WFIFOL(inter_fd,2) = char_id; - WFIFOL(inter_fd,6) = auction_id; - WFIFOSET(inter_fd,10); - - return 0; -} - -static void intif_parse_Auction_cancel(int fd) -{ - struct map_session_data *sd = iMap->charid2sd(RFIFOL(fd,2)); - int result = RFIFOB(fd,6); - - if( sd == NULL ) - return; - - 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; - case 3: clif->auction_message(sd->fd, 3); break; - } -} - -int intif_Auction_close(int char_id, unsigned int auction_id) -{ - if( CheckForCharServer() ) - return 0; - - WFIFOHEAD(inter_fd,10); - WFIFOW(inter_fd,0) = 0x3053; - WFIFOL(inter_fd,2) = char_id; - WFIFOL(inter_fd,6) = auction_id; - WFIFOSET(inter_fd,10); - - return 0; -} - -static void intif_parse_Auction_close(int fd) -{ - struct map_session_data *sd = iMap->charid2sd(RFIFOL(fd,2)); - unsigned char result = RFIFOB(fd,6); - - if( sd == NULL ) - return; - - clif->auction_close(sd->fd, result); - if( result == 0 ) - { - // FIXME: Leeching off a parse function - clif->pAuction_cancelreg(fd, sd); - intif_Auction_requestlist(sd->status.char_id, 6, 0, "", 1); - } -} - -int intif_Auction_bid(int char_id, const char* name, unsigned int auction_id, int bid) -{ - int len = 16 + NAME_LENGTH; - - if( CheckForCharServer() ) - return 0; - - WFIFOHEAD(inter_fd,len); - WFIFOW(inter_fd,0) = 0x3055; - WFIFOW(inter_fd,2) = len; - WFIFOL(inter_fd,4) = char_id; - WFIFOL(inter_fd,8) = auction_id; - WFIFOL(inter_fd,12) = bid; - memcpy(WFIFOP(inter_fd,16), name, NAME_LENGTH); - WFIFOSET(inter_fd,len); - - return 0; -} - -static void intif_parse_Auction_bid(int fd) -{ - struct map_session_data *sd = iMap->charid2sd(RFIFOL(fd,2)); - int bid = RFIFOL(fd,6); - unsigned char result = RFIFOB(fd,10); - - if( sd == NULL ) - return; - - clif->auction_message(sd->fd, result); - if( bid > 0 ) { - pc->getzeny(sd, bid, LOG_TYPE_AUCTION,NULL); - } - if( result == 1 ) { // To update the list, display your buy list - clif->pAuction_cancelreg(fd, sd); - intif_Auction_requestlist(sd->status.char_id, 7, 0, "", 1); - } -} - -// 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)); - unsigned char result = RFIFOB(fd,6); - - if( sd == NULL ) - return; - - clif->auction_message(sd->fd, result); -} - -/*========================================== - * Mercenary's System - *------------------------------------------*/ -int intif_mercenary_create(struct s_mercenary *merc) -{ - int size = sizeof(struct s_mercenary) + 4; - - if( CheckForCharServer() ) - return 0; - - WFIFOHEAD(inter_fd,size); - WFIFOW(inter_fd,0) = 0x3070; - WFIFOW(inter_fd,2) = size; - memcpy(WFIFOP(inter_fd,4), merc, sizeof(struct s_mercenary)); - WFIFOSET(inter_fd,size); - return 0; -} - -int intif_parse_mercenary_received(int fd) -{ - int len = RFIFOW(fd,2) - 5; - if( sizeof(struct s_mercenary) != len ) - { - if( battle_config.etc_log ) - ShowError("intif: create mercenary data size error %d != %d\n", sizeof(struct s_mercenary), len); - return 0; - } - - merc_data_received((struct s_mercenary*)RFIFOP(fd,5), RFIFOB(fd,4)); - return 0; -} - -int intif_mercenary_request(int merc_id, int char_id) -{ - if (CheckForCharServer()) - return 0; - - WFIFOHEAD(inter_fd,10); - WFIFOW(inter_fd,0) = 0x3071; - WFIFOL(inter_fd,2) = merc_id; - WFIFOL(inter_fd,6) = char_id; - WFIFOSET(inter_fd,10); - return 0; -} - -int intif_mercenary_delete(int merc_id) -{ - if (CheckForCharServer()) - return 0; - - WFIFOHEAD(inter_fd,6); - WFIFOW(inter_fd,0) = 0x3072; - WFIFOL(inter_fd,2) = merc_id; - WFIFOSET(inter_fd,6); - return 0; -} - -int intif_parse_mercenary_deleted(int fd) -{ - if( RFIFOB(fd,2) != 1 ) - ShowError("Mercenary data delete failure\n"); - - return 0; -} - -int intif_mercenary_save(struct s_mercenary *merc) -{ - int size = sizeof(struct s_mercenary) + 4; - - if( CheckForCharServer() ) - return 0; - - WFIFOHEAD(inter_fd,size); - WFIFOW(inter_fd,0) = 0x3073; - WFIFOW(inter_fd,2) = size; - memcpy(WFIFOP(inter_fd,4), merc, sizeof(struct s_mercenary)); - WFIFOSET(inter_fd,size); - return 0; -} - -int intif_parse_mercenary_saved(int fd) -{ - if( RFIFOB(fd,2) != 1 ) - ShowError("Mercenary data save failure\n"); - - return 0; -} - -/*========================================== - * Elemental's System - *------------------------------------------*/ -int intif_elemental_create(struct s_elemental *ele) -{ - int size = sizeof(struct s_elemental) + 4; - - if( CheckForCharServer() ) - return 0; - - WFIFOHEAD(inter_fd,size); - WFIFOW(inter_fd,0) = 0x307c; - WFIFOW(inter_fd,2) = size; - memcpy(WFIFOP(inter_fd,4), ele, sizeof(struct s_elemental)); - WFIFOSET(inter_fd,size); - return 0; -} - -int intif_parse_elemental_received(int fd) -{ - int len = RFIFOW(fd,2) - 5; - if( sizeof(struct s_elemental) != len ) - { - if( battle_config.etc_log ) - ShowError("intif: create elemental data size error %d != %d\n", sizeof(struct s_elemental), len); - return 0; - } - - elemental->data_received((struct s_elemental*)RFIFOP(fd,5), RFIFOB(fd,4)); - return 0; -} - -int intif_elemental_request(int ele_id, int char_id) -{ - if (CheckForCharServer()) - return 0; - - WFIFOHEAD(inter_fd,10); - WFIFOW(inter_fd,0) = 0x307d; - WFIFOL(inter_fd,2) = ele_id; - WFIFOL(inter_fd,6) = char_id; - WFIFOSET(inter_fd,10); - return 0; -} - -int intif_elemental_delete(int ele_id) -{ - if (CheckForCharServer()) - return 0; - - WFIFOHEAD(inter_fd,6); - WFIFOW(inter_fd,0) = 0x307e; - WFIFOL(inter_fd,2) = ele_id; - WFIFOSET(inter_fd,6); - return 0; -} - -int intif_parse_elemental_deleted(int fd) -{ - if( RFIFOB(fd,2) != 1 ) - ShowError("Elemental data delete failure\n"); - - return 0; -} - -int intif_elemental_save(struct s_elemental *ele) -{ - int size = sizeof(struct s_elemental) + 4; - - if( CheckForCharServer() ) - return 0; - - WFIFOHEAD(inter_fd,size); - WFIFOW(inter_fd,0) = 0x307f; - WFIFOW(inter_fd,2) = size; - memcpy(WFIFOP(inter_fd,4), ele, sizeof(struct s_elemental)); - WFIFOSET(inter_fd,size); - return 0; -} - -int intif_parse_elemental_saved(int fd) -{ - if( RFIFOB(fd,2) != 1 ) - ShowError("Elemental data save failure\n"); - - return 0; -} - -void intif_request_accinfo( int u_fd, int aid, int group_lv, char* query ) { - - - WFIFOHEAD(inter_fd,2 + 4 + 4 + 4 + NAME_LENGTH); - - WFIFOW(inter_fd,0) = 0x3007; - WFIFOL(inter_fd,2) = u_fd; - WFIFOL(inter_fd,6) = aid; - WFIFOL(inter_fd,10) = group_lv; - safestrncpy((char *)WFIFOP(inter_fd,14), query, NAME_LENGTH); - - WFIFOSET(inter_fd,2 + 4 + 4 + 4 + NAME_LENGTH); - - return; -} - -void intif_parse_MessageToFD(int fd) { - int u_fd = RFIFOL(fd,4); - - if( session[u_fd] && session[u_fd]->session_data ) { - int aid = RFIFOL(fd,8); - struct map_session_data * sd = session[u_fd]->session_data; - /* matching e.g. previous fd owner didn't dc during request or is still the same */ - if( sd->bl.id == aid ) { - char msg[512]; - safestrncpy(msg, (char*)RFIFOP(fd,12), RFIFOW(fd,2) - 12); - clif->message(u_fd,msg); - } - - } - - return; -} - -//----------------------------------------------------------------- -// Communication from the inter server -// Return a 0 (false) if there were any errors. -// 1, 2 if there are not enough to return the length of the packet if the packet processing -int intif_parse(int fd) -{ - int packet_len, cmd; - cmd = RFIFOW(fd,0); - // Verify ID of the packet - if(cmd<0x3800 || cmd>=0x3800+(sizeof(packet_len_table)/sizeof(packet_len_table[0])) || - packet_len_table[cmd-0x3800]==0){ - return 0; - } - // Check the length of the packet - packet_len = packet_len_table[cmd-0x3800]; - if(packet_len==-1){ - if(RFIFOREST(fd)<4) - return 2; - packet_len = RFIFOW(fd,2); - } - if((int)RFIFOREST(fd)broadcast(NULL, (char *) RFIFOP(fd,16), packet_len-16, 0, ALL_CLIENT); - else //Color announce. - clif->broadcast2(NULL, (char *) RFIFOP(fd,16), packet_len-16, RFIFOL(fd,4), RFIFOW(fd,8), RFIFOW(fd,10), RFIFOW(fd,12), RFIFOW(fd,14), ALL_CLIENT); - break; - case 0x3801: intif_parse_WisMessage(fd); break; - case 0x3802: intif_parse_WisEnd(fd); break; - case 0x3803: mapif_parse_WisToGM(fd); break; - case 0x3804: intif_parse_Registers(fd); break; - case 0x3806: intif_parse_ChangeNameOk(fd); break; - case 0x3807: intif_parse_MessageToFD(fd); break; - case 0x3818: intif_parse_LoadGuildStorage(fd); break; - case 0x3819: intif_parse_SaveGuildStorage(fd); break; - case 0x3820: intif_parse_PartyCreated(fd); break; - case 0x3821: intif_parse_PartyInfo(fd); break; - case 0x3822: intif_parse_PartyMemberAdded(fd); break; - case 0x3823: intif_parse_PartyOptionChanged(fd); break; - case 0x3824: intif_parse_PartyMemberWithdraw(fd); break; - case 0x3825: intif_parse_PartyMove(fd); break; - case 0x3826: intif_parse_PartyBroken(fd); break; - case 0x3827: intif_parse_PartyMessage(fd); break; - case 0x3830: intif_parse_GuildCreated(fd); break; - case 0x3831: intif_parse_GuildInfo(fd); break; - case 0x3832: intif_parse_GuildMemberAdded(fd); break; - case 0x3834: intif_parse_GuildMemberWithdraw(fd); break; - case 0x3835: intif_parse_GuildMemberInfoShort(fd); break; - case 0x3836: intif_parse_GuildBroken(fd); break; - case 0x3837: intif_parse_GuildMessage(fd); break; - case 0x3839: intif_parse_GuildBasicInfoChanged(fd); break; - case 0x383a: intif_parse_GuildMemberInfoChanged(fd); break; - case 0x383b: intif_parse_GuildPosition(fd); break; - case 0x383c: intif_parse_GuildSkillUp(fd); break; - case 0x383d: intif_parse_GuildAlliance(fd); break; - case 0x383e: intif_parse_GuildNotice(fd); break; - case 0x383f: intif_parse_GuildEmblem(fd); break; - case 0x3840: intif_parse_GuildCastleDataLoad(fd); break; - case 0x3843: intif_parse_GuildMasterChanged(fd); break; - - //Quest system - case 0x3860: intif_parse_questlog(fd); break; - case 0x3861: intif_parse_questsave(fd); break; - -// Mail System - case 0x3848: intif_parse_Mail_inboxreceived(fd); break; - case 0x3849: intif_parse_Mail_new(fd); break; - case 0x384a: intif_parse_Mail_getattach(fd); break; - case 0x384b: intif_parse_Mail_delete(fd); break; - case 0x384c: intif_parse_Mail_return(fd); break; - case 0x384d: intif_parse_Mail_send(fd); break; -// Auction System - case 0x3850: intif_parse_Auction_results(fd); break; - case 0x3851: intif_parse_Auction_register(fd); break; - case 0x3852: intif_parse_Auction_cancel(fd); break; - case 0x3853: intif_parse_Auction_close(fd); break; - case 0x3854: intif_parse_Auction_message(fd); break; - case 0x3855: intif_parse_Auction_bid(fd); break; - -// Mercenary System - case 0x3870: intif_parse_mercenary_received(fd); break; - case 0x3871: intif_parse_mercenary_deleted(fd); break; - case 0x3872: intif_parse_mercenary_saved(fd); break; -// Elemental System - case 0x387c: intif_parse_elemental_received(fd); break; - case 0x387d: intif_parse_elemental_deleted(fd); break; - case 0x387e: intif_parse_elemental_saved(fd); break; - - case 0x3880: intif_parse_CreatePet(fd); break; - case 0x3881: intif_parse_RecvPetData(fd); break; - case 0x3882: intif_parse_SavePetOk(fd); break; - case 0x3883: intif_parse_DeletePetOk(fd); break; - case 0x3890: intif_parse_CreateHomunculus(fd); break; - case 0x3891: intif_parse_RecvHomunculusData(fd); break; - case 0x3892: intif_parse_SaveHomunculusOk(fd); break; - case 0x3893: intif_parse_DeleteHomunculusOk(fd); break; - default: - ShowError("intif_parse : unknown packet %d %x\n",fd,RFIFOW(fd,0)); - return 0; - } - // Skip packet - RFIFOSKIP(fd,packet_len); - return 1; -} +// Copyright (c) Athena Dev Teams - Licensed under GNU GPL +// For more information, see LICENCE in the main folder + +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/timer.h" +#include "../common/nullpo.h" +#include "../common/malloc.h" +#include "../common/strlib.h" +#include "map.h" +#include "battle.h" +#include "chrif.h" +#include "clif.h" +#include "pc.h" +#include "intif.h" +#include "log.h" +#include "storage.h" +#include "party.h" +#include "guild.h" +#include "pet.h" +#include "atcommand.h" +#include "mercenary.h" +#include "homunculus.h" +#include "elemental.h" +#include "mail.h" +#include "quest.h" + +#include +#include +#include +#include +#include +#include + + +static const int packet_len_table[]={ + -1,-1,27,-1, -1, 0,37,-1, 0, 0, 0, 0, 0, 0, 0, 0, //0x3800-0x380f + 0, 0, 0, 0, 0, 0, 0, 0, -1,11, 0, 0, 0, 0, 0, 0, //0x3810 + 39,-1,15,15, 14,19, 7,-1, 0, 0, 0, 0, 0, 0, 0, 0, //0x3820 + 10,-1,15, 0, 79,19, 7,-1, 0,-1,-1,-1, 14,67,186,-1, //0x3830 + -1, 0, 0,14, 0, 0, 0, 0, -1,74,-1,11, 11,-1, 0, 0, //0x3840 + -1,-1, 7, 7, 7,11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3850 Auctions [Zephyrus] + -1, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3860 Quests [Kevin] [Inkfish] + -1, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 3, 3, 0, //0x3870 Mercenaries [Zephyrus] / Elemental [pakpil] + 11,-1, 7, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3880 + -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 + +//----------------------------------------------------------------- +// Send to inter server + +int CheckForCharServer(void) +{ + return ((char_fd <= 0) || session[char_fd] == NULL || session[char_fd]->wdata == NULL); +} + +// pet +int intif_create_pet(int account_id,int char_id,short pet_class,short pet_lv,short pet_egg_id, + short pet_equip,short intimate,short hungry,char rename_flag,char incuvate,char *pet_name) +{ + if (intif->CheckForCharServer()) + return 0; + WFIFOHEAD(inter_fd, 24 + NAME_LENGTH); + WFIFOW(inter_fd,0) = 0x3080; + WFIFOL(inter_fd,2) = account_id; + WFIFOL(inter_fd,6) = char_id; + WFIFOW(inter_fd,10) = pet_class; + WFIFOW(inter_fd,12) = pet_lv; + WFIFOW(inter_fd,14) = pet_egg_id; + WFIFOW(inter_fd,16) = pet_equip; + WFIFOW(inter_fd,18) = intimate; + WFIFOW(inter_fd,20) = hungry; + WFIFOB(inter_fd,22) = rename_flag; + WFIFOB(inter_fd,23) = incuvate; + memcpy(WFIFOP(inter_fd,24),pet_name,NAME_LENGTH); + WFIFOSET(inter_fd,24+NAME_LENGTH); + + return 0; +} + +int intif_request_petdata(int account_id,int char_id,int pet_id) +{ + if (intif->CheckForCharServer()) + return 0; + WFIFOHEAD(inter_fd, 14); + WFIFOW(inter_fd,0) = 0x3081; + WFIFOL(inter_fd,2) = account_id; + WFIFOL(inter_fd,6) = char_id; + WFIFOL(inter_fd,10) = pet_id; + WFIFOSET(inter_fd,14); + + return 0; +} + +int intif_save_petdata(int account_id,struct s_pet *p) +{ + if (intif->CheckForCharServer()) + return 0; + WFIFOHEAD(inter_fd, sizeof(struct s_pet) + 8); + WFIFOW(inter_fd,0) = 0x3082; + WFIFOW(inter_fd,2) = sizeof(struct s_pet) + 8; + WFIFOL(inter_fd,4) = account_id; + memcpy(WFIFOP(inter_fd,8),p,sizeof(struct s_pet)); + WFIFOSET(inter_fd,WFIFOW(inter_fd,2)); + + return 0; +} + +int intif_delete_petdata(int pet_id) +{ + if (intif->CheckForCharServer()) + return 0; + WFIFOHEAD(inter_fd,6); + WFIFOW(inter_fd,0) = 0x3083; + WFIFOL(inter_fd,2) = pet_id; + WFIFOSET(inter_fd,6); + + return 1; +} + +int intif_rename(struct map_session_data *sd, int type, char *name) +{ + if (intif->CheckForCharServer()) + return 1; + + WFIFOHEAD(inter_fd,NAME_LENGTH+12); + WFIFOW(inter_fd,0) = 0x3006; + WFIFOL(inter_fd,2) = sd->status.account_id; + WFIFOL(inter_fd,6) = sd->status.char_id; + WFIFOB(inter_fd,10) = type; //Type: 0 - PC, 1 - PET, 2 - HOM + memcpy(WFIFOP(inter_fd,11),name, NAME_LENGTH); + WFIFOSET(inter_fd,NAME_LENGTH+12); + return 0; +} + +// GM Send a message +int intif_broadcast(const char* mes, int len, int type) +{ + int lp = type ? 4 : 0; + + // Send to the local players + clif->broadcast(NULL, mes, len, type, ALL_CLIENT); + + if (intif->CheckForCharServer()) + return 0; + + if (chrif->other_mapserver_count < 1) + return 0; //No need to send. + + WFIFOHEAD(inter_fd, 16 + lp + len); + WFIFOW(inter_fd,0) = 0x3000; + WFIFOW(inter_fd,2) = 16 + lp + len; + WFIFOL(inter_fd,4) = 0xFF000000; // 0xFF000000 color signals standard broadcast + WFIFOW(inter_fd,8) = 0; // fontType not used with standard broadcast + WFIFOW(inter_fd,10) = 0; // fontSize not used with standard broadcast + WFIFOW(inter_fd,12) = 0; // fontAlign not used with standard broadcast + WFIFOW(inter_fd,14) = 0; // fontY not used with standard broadcast + if (type == 0x10) // bc_blue + WFIFOL(inter_fd,16) = 0x65756c62; //If there's "blue" at the beginning of the message, game client will display it in blue instead of yellow. + else if (type == 0x20) // bc_woe + WFIFOL(inter_fd,16) = 0x73737373; //If there's "ssss", game client will recognize message as 'WoE broadcast'. + memcpy(WFIFOP(inter_fd,16 + lp), mes, len); + WFIFOSET(inter_fd, WFIFOW(inter_fd,2)); + return 0; +} + +int intif_broadcast2(const char* mes, int len, unsigned long fontColor, short fontType, short fontSize, short fontAlign, short fontY) +{ + // Send to the local players + clif->broadcast2(NULL, mes, len, fontColor, fontType, fontSize, fontAlign, fontY, ALL_CLIENT); + + if (intif->CheckForCharServer()) + return 0; + + if (chrif->other_mapserver_count < 1) + return 0; //No need to send. + + WFIFOHEAD(inter_fd, 16 + len); + WFIFOW(inter_fd,0) = 0x3000; + WFIFOW(inter_fd,2) = 16 + len; + WFIFOL(inter_fd,4) = fontColor; + WFIFOW(inter_fd,8) = fontType; + WFIFOW(inter_fd,10) = fontSize; + WFIFOW(inter_fd,12) = fontAlign; + WFIFOW(inter_fd,14) = fontY; + memcpy(WFIFOP(inter_fd,16), mes, len); + WFIFOSET(inter_fd, WFIFOW(inter_fd,2)); + return 0; +} + +/// send a message using the main chat system +/// the source of message +/// the message that was sent +int intif_main_message(struct map_session_data* sd, const char* message) +{ + char output[256]; + + nullpo_ret(sd); + + // format the message for main broadcasting + snprintf( output, sizeof(output), msg_txt(386), sd->status.name, message ); + + // send the message using the inter-server broadcast service + intif_broadcast2( output, strlen(output) + 1, 0xFE000000, 0, 0, 0, 0 ); + + // log the chat message + logs->chat( LOG_CHAT_MAINCHAT, 0, sd->status.char_id, sd->status.account_id, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, NULL, message ); + + return 0; +} + +// The transmission of Wisp/Page to inter-server (player not found on this server) +int intif_wis_message(struct map_session_data *sd, char *nick, char *mes, int mes_len) +{ + nullpo_ret(sd); + if (intif->CheckForCharServer()) + return 0; + + if (chrif->other_mapserver_count < 1) + { //Character not found. + clif->wis_end(sd->fd, 1); + return 0; + } + + WFIFOHEAD(inter_fd,mes_len + 52); + WFIFOW(inter_fd,0) = 0x3001; + WFIFOW(inter_fd,2) = mes_len + 52; + memcpy(WFIFOP(inter_fd,4), sd->status.name, NAME_LENGTH); + memcpy(WFIFOP(inter_fd,4+NAME_LENGTH), nick, NAME_LENGTH); + memcpy(WFIFOP(inter_fd,4+2*NAME_LENGTH), mes, mes_len); + WFIFOSET(inter_fd, WFIFOW(inter_fd,2)); + + if (battle_config.etc_log) + ShowInfo("intif_wis_message from %s to %s (message: '%s')\n", sd->status.name, nick, mes); + + return 0; +} + +// The reply of Wisp/page +int intif_wis_replay(int id, int flag) +{ + if (intif->CheckForCharServer()) + return 0; + WFIFOHEAD(inter_fd,7); + WFIFOW(inter_fd,0) = 0x3002; + WFIFOL(inter_fd,2) = id; + WFIFOB(inter_fd,6) = flag; // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target + WFIFOSET(inter_fd,7); + + if (battle_config.etc_log) + ShowInfo("intif_wis_replay: id: %d, flag:%d\n", id, flag); + + return 0; +} + +// The transmission of GM only Wisp/Page from server to inter-server +int intif_wis_message_to_gm(char *wisp_name, int permission, char *mes) +{ + int mes_len; + if (intif->CheckForCharServer()) + return 0; + mes_len = strlen(mes) + 1; // + null + WFIFOHEAD(inter_fd, mes_len + 32); + WFIFOW(inter_fd,0) = 0x3003; + WFIFOW(inter_fd,2) = mes_len + 32; + memcpy(WFIFOP(inter_fd,4), wisp_name, NAME_LENGTH); + WFIFOL(inter_fd,4+NAME_LENGTH) = permission; + memcpy(WFIFOP(inter_fd,8+NAME_LENGTH), mes, mes_len); + WFIFOSET(inter_fd, WFIFOW(inter_fd,2)); + + if (battle_config.etc_log) + ShowNotice("intif_wis_message_to_gm: from: '%s', required permission: %d, message: '%s'.\n", wisp_name, permission, mes); + + return 0; +} + +int intif_regtostr(char* str, struct global_reg *reg, int qty) +{ + int len =0, i; + + for (i = 0; i < qty; i++) { + len+= sprintf(str+len, "%s", reg[i].str)+1; //We add 1 to consider the '\0' in place. + len+= sprintf(str+len, "%s", reg[i].value)+1; + } + return len; +} + +//Request for saving registry values. +int intif_saveregistry(struct map_session_data *sd, int type) +{ + struct global_reg *reg; + int count; + int i, p; + + if (intif->CheckForCharServer()) + return -1; + + switch (type) { + case 3: //Character reg + reg = sd->save_reg.global; + count = sd->save_reg.global_num; + sd->state.reg_dirty &= ~0x4; + break; + case 2: //Account reg + reg = sd->save_reg.account; + count = sd->save_reg.account_num; + sd->state.reg_dirty &= ~0x2; + break; + case 1: //Account2 reg + reg = sd->save_reg.account2; + count = sd->save_reg.account2_num; + sd->state.reg_dirty &= ~0x1; + break; + default: //Broken code? + ShowError("intif_saveregistry: Invalid type %d\n", type); + return -1; + } + WFIFOHEAD(inter_fd, 288 * MAX_REG_NUM+13); + WFIFOW(inter_fd,0)=0x3004; + WFIFOL(inter_fd,4)=sd->status.account_id; + WFIFOL(inter_fd,8)=sd->status.char_id; + WFIFOB(inter_fd,12)=type; + for( p = 13, i = 0; i < count; i++ ) { + if (reg[i].str[0] != '\0' && reg[i].value[0] != '\0') { + p+= sprintf((char*)WFIFOP(inter_fd,p), "%s", reg[i].str)+1; //We add 1 to consider the '\0' in place. + p+= sprintf((char*)WFIFOP(inter_fd,p), "%s", reg[i].value)+1; + } + } + WFIFOW(inter_fd,2)=p; + WFIFOSET(inter_fd,WFIFOW(inter_fd,2)); + return 0; +} + +//Request the registries for this player. +int intif_request_registry(struct map_session_data *sd, int flag) +{ + nullpo_ret(sd); + + sd->save_reg.account2_num = -1; + sd->save_reg.account_num = -1; + sd->save_reg.global_num = -1; + + if (intif->CheckForCharServer()) + return 0; + + WFIFOHEAD(inter_fd,6); + WFIFOW(inter_fd,0) = 0x3005; + WFIFOL(inter_fd,2) = sd->status.account_id; + WFIFOL(inter_fd,6) = sd->status.char_id; + WFIFOB(inter_fd,10) = (flag&1?1:0); //Request Acc Reg 2 + WFIFOB(inter_fd,11) = (flag&2?1:0); //Request Acc Reg + WFIFOB(inter_fd,12) = (flag&4?1:0); //Request Char Reg + WFIFOSET(inter_fd,13); + + return 0; +} + +int intif_request_guild_storage(int account_id,int guild_id) +{ + if (intif->CheckForCharServer()) + return 0; + WFIFOHEAD(inter_fd,10); + WFIFOW(inter_fd,0) = 0x3018; + WFIFOL(inter_fd,2) = account_id; + WFIFOL(inter_fd,6) = guild_id; + WFIFOSET(inter_fd,10); + return 0; +} +int intif_send_guild_storage(int account_id,struct guild_storage *gstor) +{ + if (intif->CheckForCharServer()) + return 0; + WFIFOHEAD(inter_fd,sizeof(struct guild_storage)+12); + WFIFOW(inter_fd,0) = 0x3019; + WFIFOW(inter_fd,2) = (unsigned short)sizeof(struct guild_storage)+12; + WFIFOL(inter_fd,4) = account_id; + WFIFOL(inter_fd,8) = gstor->guild_id; + memcpy( WFIFOP(inter_fd,12),gstor, sizeof(struct guild_storage) ); + WFIFOSET(inter_fd,WFIFOW(inter_fd,2)); + return 0; +} + +// Party creation request +int intif_create_party(struct party_member *member,char *name,int item,int item2) +{ + if (intif->CheckForCharServer()) + return 0; + nullpo_ret(member); + + WFIFOHEAD(inter_fd,64); + WFIFOW(inter_fd,0) = 0x3020; + WFIFOW(inter_fd,2) = 30+sizeof(struct party_member); + memcpy(WFIFOP(inter_fd,4),name, NAME_LENGTH); + WFIFOB(inter_fd,28)= item; + WFIFOB(inter_fd,29)= item2; + memcpy(WFIFOP(inter_fd,30), member, sizeof(struct party_member)); + WFIFOSET(inter_fd,WFIFOW(inter_fd, 2)); + return 0; +} + +// Party information request +int intif_request_partyinfo(int party_id, int char_id) +{ + if (intif->CheckForCharServer()) + return 0; + WFIFOHEAD(inter_fd,10); + WFIFOW(inter_fd,0) = 0x3021; + WFIFOL(inter_fd,2) = party_id; + WFIFOL(inter_fd,6) = char_id; + WFIFOSET(inter_fd,10); + return 0; +} + +// Request to add a member to party +int intif_party_addmember(int party_id,struct party_member *member) +{ + if (intif->CheckForCharServer()) + return 0; + WFIFOHEAD(inter_fd,42); + WFIFOW(inter_fd,0)=0x3022; + WFIFOW(inter_fd,2)=8+sizeof(struct party_member); + WFIFOL(inter_fd,4)=party_id; + memcpy(WFIFOP(inter_fd,8),member,sizeof(struct party_member)); + WFIFOSET(inter_fd,WFIFOW(inter_fd, 2)); + return 1; +} + +// Request to change party configuration (exp,item share) +int intif_party_changeoption(int party_id,int account_id,int exp,int item) +{ + if (intif->CheckForCharServer()) + return 0; + WFIFOHEAD(inter_fd,14); + WFIFOW(inter_fd,0)=0x3023; + WFIFOL(inter_fd,2)=party_id; + WFIFOL(inter_fd,6)=account_id; + WFIFOW(inter_fd,10)=exp; + WFIFOW(inter_fd,12)=item; + WFIFOSET(inter_fd,14); + return 0; +} + +// Request to leave party +int intif_party_leave(int party_id,int account_id, int char_id) +{ + if (intif->CheckForCharServer()) + return 0; + WFIFOHEAD(inter_fd,14); + WFIFOW(inter_fd,0)=0x3024; + WFIFOL(inter_fd,2)=party_id; + WFIFOL(inter_fd,6)=account_id; + WFIFOL(inter_fd,10)=char_id; + WFIFOSET(inter_fd,14); + return 0; +} + +// Request keeping party for new map ?? +int intif_party_changemap(struct map_session_data *sd,int online) +{ + int16 m, mapindex; + + if (intif->CheckForCharServer()) + return 0; + if(!sd) + return 0; + + if( (m=iMap->mapindex2mapid(sd->mapindex)) >= 0 && map[m].instance_id >= 0 ) + mapindex = map[map[m].instance_src_map].index; + else + mapindex = sd->mapindex; + + WFIFOHEAD(inter_fd,19); + WFIFOW(inter_fd,0)=0x3025; + WFIFOL(inter_fd,2)=sd->status.party_id; + WFIFOL(inter_fd,6)=sd->status.account_id; + WFIFOL(inter_fd,10)=sd->status.char_id; + WFIFOW(inter_fd,14)=mapindex; + WFIFOB(inter_fd,16)=online; + WFIFOW(inter_fd,17)=sd->status.base_level; + WFIFOSET(inter_fd,19); + return 1; +} + +// Request breaking party +int intif_break_party(int party_id) +{ + if (intif->CheckForCharServer()) + return 0; + WFIFOHEAD(inter_fd,6); + WFIFOW(inter_fd,0)=0x3026; + WFIFOL(inter_fd,2)=party_id; + WFIFOSET(inter_fd,6); + return 0; +} + +// Sending party chat +int intif_party_message(int party_id,int account_id,const char *mes,int len) +{ + if (intif->CheckForCharServer()) + return 0; + + if (chrif->other_mapserver_count < 1) + return 0; //No need to send. + + WFIFOHEAD(inter_fd,len + 12); + WFIFOW(inter_fd,0)=0x3027; + WFIFOW(inter_fd,2)=len+12; + WFIFOL(inter_fd,4)=party_id; + WFIFOL(inter_fd,8)=account_id; + memcpy(WFIFOP(inter_fd,12),mes,len); + WFIFOSET(inter_fd,len+12); + return 0; +} + +// Request a new leader for party +int intif_party_leaderchange(int party_id,int account_id,int char_id) +{ + if (intif->CheckForCharServer()) + return 0; + WFIFOHEAD(inter_fd,14); + WFIFOW(inter_fd,0)=0x3029; + WFIFOL(inter_fd,2)=party_id; + WFIFOL(inter_fd,6)=account_id; + WFIFOL(inter_fd,10)=char_id; + WFIFOSET(inter_fd,14); + return 0; +} + +// Request a Guild creation +int intif_guild_create(const char *name,const struct guild_member *master) +{ + if (intif->CheckForCharServer()) + return 0; + nullpo_ret(master); + + WFIFOHEAD(inter_fd,sizeof(struct guild_member)+(8+NAME_LENGTH)); + WFIFOW(inter_fd,0)=0x3030; + WFIFOW(inter_fd,2)=sizeof(struct guild_member)+(8+NAME_LENGTH); + WFIFOL(inter_fd,4)=master->account_id; + memcpy(WFIFOP(inter_fd,8),name,NAME_LENGTH); + memcpy(WFIFOP(inter_fd,8+NAME_LENGTH),master,sizeof(struct guild_member)); + WFIFOSET(inter_fd,WFIFOW(inter_fd,2)); + return 0; +} + +// Request Guild information +int intif_guild_request_info(int guild_id) +{ + if (intif->CheckForCharServer()) + return 0; + WFIFOHEAD(inter_fd,6); + WFIFOW(inter_fd,0) = 0x3031; + WFIFOL(inter_fd,2) = guild_id; + WFIFOSET(inter_fd,6); + return 0; +} + +// Request to add member to the guild +int intif_guild_addmember(int guild_id,struct guild_member *m) +{ + if (intif->CheckForCharServer()) + return 0; + WFIFOHEAD(inter_fd,sizeof(struct guild_member)+8); + WFIFOW(inter_fd,0) = 0x3032; + WFIFOW(inter_fd,2) = sizeof(struct guild_member)+8; + WFIFOL(inter_fd,4) = guild_id; + memcpy(WFIFOP(inter_fd,8),m,sizeof(struct guild_member)); + WFIFOSET(inter_fd,WFIFOW(inter_fd,2)); + return 0; +} + +// Request a new leader for guild +int intif_guild_change_gm(int guild_id, const char* name, int len) +{ + if (intif->CheckForCharServer()) + return 0; + WFIFOHEAD(inter_fd, len + 8); + WFIFOW(inter_fd, 0)=0x3033; + WFIFOW(inter_fd, 2)=len+8; + WFIFOL(inter_fd, 4)=guild_id; + memcpy(WFIFOP(inter_fd,8),name,len); + WFIFOSET(inter_fd,len+8); + return 0; +} + +// Request to leave guild +int intif_guild_leave(int guild_id,int account_id,int char_id,int flag,const char *mes) +{ + if (intif->CheckForCharServer()) + return 0; + WFIFOHEAD(inter_fd, 55); + WFIFOW(inter_fd, 0) = 0x3034; + WFIFOL(inter_fd, 2) = guild_id; + WFIFOL(inter_fd, 6) = account_id; + WFIFOL(inter_fd,10) = char_id; + WFIFOB(inter_fd,14) = flag; + safestrncpy((char*)WFIFOP(inter_fd,15),mes,40); + WFIFOSET(inter_fd,55); + return 0; +} + +//Update request / Lv online status of the guild members +int intif_guild_memberinfoshort(int guild_id,int account_id,int char_id,int online,int lv,int class_) +{ + if (intif->CheckForCharServer()) + return 0; + WFIFOHEAD(inter_fd, 19); + WFIFOW(inter_fd, 0) = 0x3035; + WFIFOL(inter_fd, 2) = guild_id; + WFIFOL(inter_fd, 6) = account_id; + WFIFOL(inter_fd,10) = char_id; + WFIFOB(inter_fd,14) = online; + WFIFOW(inter_fd,15) = lv; + WFIFOW(inter_fd,17) = class_; + WFIFOSET(inter_fd,19); + return 0; +} + +//Guild disbanded notification +int intif_guild_break(int guild_id) +{ + if (intif->CheckForCharServer()) + return 0; + WFIFOHEAD(inter_fd, 6); + WFIFOW(inter_fd, 0) = 0x3036; + WFIFOL(inter_fd, 2) = guild_id; + WFIFOSET(inter_fd,6); + return 0; +} + +// Send a guild message +int intif_guild_message(int guild_id,int account_id,const char *mes,int len) +{ + if (intif->CheckForCharServer()) + return 0; + + if (chrif->other_mapserver_count < 1) + return 0; //No need to send. + + WFIFOHEAD(inter_fd, len + 12); + WFIFOW(inter_fd,0)=0x3037; + WFIFOW(inter_fd,2)=len+12; + WFIFOL(inter_fd,4)=guild_id; + WFIFOL(inter_fd,8)=account_id; + memcpy(WFIFOP(inter_fd,12),mes,len); + WFIFOSET(inter_fd,len+12); + + return 0; +} + +// Request a change of Guild basic information +int intif_guild_change_basicinfo(int guild_id,int type,const void *data,int len) +{ + if (intif->CheckForCharServer()) + return 0; + WFIFOHEAD(inter_fd, len + 10); + WFIFOW(inter_fd,0)=0x3039; + WFIFOW(inter_fd,2)=len+10; + WFIFOL(inter_fd,4)=guild_id; + WFIFOW(inter_fd,8)=type; + memcpy(WFIFOP(inter_fd,10),data,len); + WFIFOSET(inter_fd,len+10); + return 0; +} + +// Request a change of Guild member information +int intif_guild_change_memberinfo(int guild_id,int account_id,int char_id, + int type,const void *data,int len) +{ + if (intif->CheckForCharServer()) + return 0; + WFIFOHEAD(inter_fd, len + 18); + WFIFOW(inter_fd, 0)=0x303a; + WFIFOW(inter_fd, 2)=len+18; + WFIFOL(inter_fd, 4)=guild_id; + WFIFOL(inter_fd, 8)=account_id; + WFIFOL(inter_fd,12)=char_id; + WFIFOW(inter_fd,16)=type; + memcpy(WFIFOP(inter_fd,18),data,len); + WFIFOSET(inter_fd,len+18); + return 0; +} + +// Request a change of Guild title +int intif_guild_position(int guild_id,int idx,struct guild_position *p) +{ + if (intif->CheckForCharServer()) + return 0; + WFIFOHEAD(inter_fd, sizeof(struct guild_position)+12); + WFIFOW(inter_fd,0)=0x303b; + WFIFOW(inter_fd,2)=sizeof(struct guild_position)+12; + WFIFOL(inter_fd,4)=guild_id; + WFIFOL(inter_fd,8)=idx; + memcpy(WFIFOP(inter_fd,12),p,sizeof(struct guild_position)); + WFIFOSET(inter_fd,WFIFOW(inter_fd,2)); + return 0; +} + +// Request an update of Guildskill skill_id +int intif_guild_skillup(int guild_id, uint16 skill_id, int account_id, int max) +{ + if( intif->CheckForCharServer() ) + return 0; + WFIFOHEAD(inter_fd, 18); + WFIFOW(inter_fd, 0) = 0x303c; + WFIFOL(inter_fd, 2) = guild_id; + WFIFOL(inter_fd, 6) = skill_id; + WFIFOL(inter_fd, 10) = account_id; + WFIFOL(inter_fd, 14) = max; + WFIFOSET(inter_fd, 18); + return 0; +} + +// Request a new guild relationship +int intif_guild_alliance(int guild_id1,int guild_id2,int account_id1,int account_id2,int flag) +{ + if (intif->CheckForCharServer()) + return 0; + WFIFOHEAD(inter_fd,19); + WFIFOW(inter_fd, 0)=0x303d; + WFIFOL(inter_fd, 2)=guild_id1; + WFIFOL(inter_fd, 6)=guild_id2; + WFIFOL(inter_fd,10)=account_id1; + WFIFOL(inter_fd,14)=account_id2; + WFIFOB(inter_fd,18)=flag; + WFIFOSET(inter_fd,19); + return 0; +} + +// Request to change guild notice +int intif_guild_notice(int guild_id,const char *mes1,const char *mes2) +{ + if (intif->CheckForCharServer()) + return 0; + WFIFOHEAD(inter_fd,186); + WFIFOW(inter_fd,0)=0x303e; + WFIFOL(inter_fd,2)=guild_id; + memcpy(WFIFOP(inter_fd,6),mes1,MAX_GUILDMES1); + memcpy(WFIFOP(inter_fd,66),mes2,MAX_GUILDMES2); + WFIFOSET(inter_fd,186); + return 0; +} + +// Request to change guild emblem +int intif_guild_emblem(int guild_id,int len,const char *data) +{ + if (intif->CheckForCharServer()) + return 0; + if(guild_id<=0 || len<0 || len>2000) + return 0; + WFIFOHEAD(inter_fd,len + 12); + WFIFOW(inter_fd,0)=0x303f; + WFIFOW(inter_fd,2)=len+12; + WFIFOL(inter_fd,4)=guild_id; + WFIFOL(inter_fd,8)=0; + memcpy(WFIFOP(inter_fd,12),data,len); + WFIFOSET(inter_fd,len+12); + return 0; +} + +/** + * Requests guild castles data from char-server. + * @param num Number of castles, size of castle_ids array. + * @param castle_ids Pointer to array of castle IDs. + */ +int intif_guild_castle_dataload(int num, int *castle_ids) +{ + if (intif->CheckForCharServer()) + return 0; + WFIFOHEAD(inter_fd, 4 + num * sizeof(int)); + WFIFOW(inter_fd, 0) = 0x3040; + WFIFOW(inter_fd, 2) = 4 + num * sizeof(int); + memcpy(WFIFOP(inter_fd, 4), castle_ids, num * sizeof(int)); + WFIFOSET(inter_fd, WFIFOW(inter_fd, 2)); + return 1; +} + + +// Request change castle guild owner and save data +int intif_guild_castle_datasave(int castle_id,int index, int value) +{ + if (intif->CheckForCharServer()) + return 0; + WFIFOHEAD(inter_fd,9); + WFIFOW(inter_fd,0)=0x3041; + WFIFOW(inter_fd,2)=castle_id; + WFIFOB(inter_fd,4)=index; + WFIFOL(inter_fd,5)=value; + WFIFOSET(inter_fd,9); + return 1; +} + +//----------------------------------------------------------------- +// Homunculus Packets send to Inter server [albator] +//----------------------------------------------------------------- + +int intif_homunculus_create(int account_id, struct s_homunculus *sh) +{ + if (intif->CheckForCharServer()) + return 0; + WFIFOHEAD(inter_fd, sizeof(struct s_homunculus)+8); + WFIFOW(inter_fd,0) = 0x3090; + WFIFOW(inter_fd,2) = sizeof(struct s_homunculus)+8; + WFIFOL(inter_fd,4) = account_id; + memcpy(WFIFOP(inter_fd,8),sh,sizeof(struct s_homunculus)); + WFIFOSET(inter_fd, WFIFOW(inter_fd,2)); + return 0; +} + +bool intif_homunculus_requestload(int account_id, int homun_id) { + if (intif->CheckForCharServer()) + return false; + WFIFOHEAD(inter_fd, 10); + WFIFOW(inter_fd,0) = 0x3091; + WFIFOL(inter_fd,2) = account_id; + WFIFOL(inter_fd,6) = homun_id; + WFIFOSET(inter_fd, 10); + return true; +} + +int intif_homunculus_requestsave(int account_id, struct s_homunculus* sh) +{ + if (intif->CheckForCharServer()) + return 0; + WFIFOHEAD(inter_fd, sizeof(struct s_homunculus)+8); + WFIFOW(inter_fd,0) = 0x3092; + WFIFOW(inter_fd,2) = sizeof(struct s_homunculus)+8; + WFIFOL(inter_fd,4) = account_id; + memcpy(WFIFOP(inter_fd,8),sh,sizeof(struct s_homunculus)); + WFIFOSET(inter_fd, WFIFOW(inter_fd,2)); + return 0; + +} + +int intif_homunculus_requestdelete(int homun_id) +{ + if (intif->CheckForCharServer()) + return 0; + WFIFOHEAD(inter_fd, 6); + WFIFOW(inter_fd, 0) = 0x3093; + WFIFOL(inter_fd,2) = homun_id; + WFIFOSET(inter_fd,6); + return 0; + +} + + +//----------------------------------------------------------------- +// Packets receive from inter server + +// Wisp/Page reception // rewritten by [Yor] +int intif_parse_WisMessage(int fd) +{ + struct map_session_data* sd; + char *wisp_source; + char name[NAME_LENGTH]; + int id, i; + + 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 + intif_wis_replay(id,1); + return 0; + } + if(sd->state.ignoreAll) { + intif_wis_replay(id, 2); + return 0; + } + wisp_source = (char *) RFIFOP(fd,8); // speed up [Yor] + for(i=0; i < MAX_IGNORE_LIST && + sd->ignore[i].name[0] != '\0' && + strcmp(sd->ignore[i].name, wisp_source) != 0 + ; i++); + + if (i < MAX_IGNORE_LIST && sd->ignore[i].name[0] != '\0') + { //Ignored + intif_wis_replay(id, 2); + return 0; + } + //Success to send whisper. + clif->wis_message(sd->fd, wisp_source, (char*)RFIFOP(fd,56),RFIFOW(fd,2)-56); + intif_wis_replay(id,0); // succes + return 0; +} + +// Wisp/page transmission result reception +int intif_parse_WisEnd(int fd) +{ + struct map_session_data* sd; + + 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)); + if (sd != NULL) + clif->wis_end(sd->fd, RFIFOB(fd,26)); + + return 0; +} + +static int mapif_parse_WisToGM_sub(struct map_session_data* sd,va_list va) +{ + int permission = va_arg(va, int); + char *wisp_name; + char *message; + int len; + + if (!pc_has_permission(sd, permission)) + return 0; + wisp_name = va_arg(va, char*); + message = va_arg(va, char*); + len = va_arg(va, int); + clif->wis_message(sd->fd, wisp_name, message, len); + return 1; +} + +// Received wisp message from map-server via char-server for ALL gm +// 0x3003/0x3803 .w .24B .l .?B +int mapif_parse_WisToGM(int fd) +{ + int permission, mes_len; + char Wisp_name[NAME_LENGTH]; + char mbuf[255]; + char *message; + + mes_len = RFIFOW(fd,2) - 32; + message = (char *) (mes_len >= 255 ? (char *) aMalloc(mes_len) : mbuf); + + permission = RFIFOL(fd,28); + 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); + + if (message != mbuf) + aFree(message); + return 0; +} + +// Request player registre +int intif_parse_Registers(int fd) +{ + int j,p,len,max, flag; + struct map_session_data *sd; + struct global_reg *reg; + int *qty; + int account_id = RFIFOL(fd,4), char_id = RFIFOL(fd,8); + struct auth_node *node = chrif->auth_check(account_id, char_id, ST_LOGIN); + if (node) + sd = node->sd; + else { //Normally registries should arrive for in log-in chars. + sd = iMap->id2sd(account_id); + if (sd && RFIFOB(fd,12) == 3 && sd->status.char_id != char_id) + sd = NULL; //Character registry from another character. + } + if (!sd) return 1; + + flag = (sd->save_reg.global_num == -1 || sd->save_reg.account_num == -1 || sd->save_reg.account2_num == -1); + + switch (RFIFOB(fd,12)) { + case 3: //Character Registry + reg = sd->save_reg.global; + qty = &sd->save_reg.global_num; + max = GLOBAL_REG_NUM; + break; + case 2: //Account Registry + reg = sd->save_reg.account; + qty = &sd->save_reg.account_num; + max = ACCOUNT_REG_NUM; + break; + case 1: //Account2 Registry + reg = sd->save_reg.account2; + qty = &sd->save_reg.account2_num; + max = ACCOUNT_REG2_NUM; + break; + default: + ShowError("intif_parse_Registers: Unrecognized type %d\n",RFIFOB(fd,12)); + return 0; + } + for(j=0,p=13;jsave_reg.global_num > -1 && sd->save_reg.account_num > -1 && sd->save_reg.account2_num > -1) + pc->reg_received(sd); //Received all registry values, execute init scripts and what-not. [Skotlex] + return 1; +} + +int intif_parse_LoadGuildStorage(int fd) +{ + struct guild_storage *gstor; + struct map_session_data *sd; + int guild_id; + + guild_id = RFIFOL(fd,8); + if(guild_id <= 0) + return 1; + sd=iMap->id2sd( RFIFOL(fd,4) ); + if(sd==NULL){ + ShowError("intif_parse_LoadGuildStorage: user not found %d\n",RFIFOL(fd,4)); + return 1; + } + gstor=gstorage->id2storage(guild_id); + if(!gstor) { + ShowWarning("intif_parse_LoadGuildStorage: error guild_id %d not exist\n",guild_id); + return 1; + } + if (gstor->storage_status == 1) { // Already open.. lets ignore this update + ShowWarning("intif_parse_LoadGuildStorage: storage received for a client already open (User %d:%d)\n", sd->status.account_id, sd->status.char_id); + return 1; + } + if (gstor->dirty) { // Already have storage, and it has been modified and not saved yet! Exploit! [Skotlex] + ShowWarning("intif_parse_LoadGuildStorage: received storage for an already modified non-saved storage! (User %d:%d)\n", sd->status.account_id, sd->status.char_id); + return 1; + } + if( RFIFOW(fd,2)-12 != sizeof(struct guild_storage) ){ + ShowError("intif_parse_LoadGuildStorage: data size error %d %d\n",RFIFOW(fd,2)-12 , sizeof(struct guild_storage)); + gstor->storage_status = 0; + return 1; + } + + memcpy(gstor,RFIFOP(fd,12),sizeof(struct guild_storage)); + gstorage->open(sd); + return 0; +} + +// ACK guild_storage saved +int intif_parse_SaveGuildStorage(int fd) +{ + gstorage->saved(/*RFIFOL(fd,2), */RFIFOL(fd,6)); + return 0; +} + +// ACK party creation +int intif_parse_PartyCreated(int fd) +{ + if(battle_config.etc_log) + ShowInfo("intif: party created by account %d\n\n", RFIFOL(fd,2)); + party->created(RFIFOL(fd,2), RFIFOL(fd,6),RFIFOB(fd,10),RFIFOL(fd,11), (char *)RFIFOP(fd,15)); + return 0; +} + +// Receive party info +int intif_parse_PartyInfo(int fd) +{ + if( RFIFOW(fd,2) == 12 ){ + ShowWarning("intif: party noinfo (char_id=%d party_id=%d)\n", RFIFOL(fd,4), RFIFOL(fd,8)); + party->recv_noinfo(RFIFOL(fd,8), RFIFOL(fd,4)); + return 0; + } + + if( RFIFOW(fd,2) != 8+sizeof(struct party) ) + ShowError("intif: party info : data size error (char_id=%d party_id=%d packet_len=%d expected_len=%d)\n", RFIFOL(fd,4), RFIFOL(fd,8), RFIFOW(fd,2), 8+sizeof(struct party)); + party->recv_info((struct party *)RFIFOP(fd,8), RFIFOL(fd,4)); + return 0; +} + +// ACK adding party member +int intif_parse_PartyMemberAdded(int fd) +{ + if(battle_config.etc_log) + ShowInfo("intif: party member added Party (%d), Account(%d), Char(%d)\n",RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10)); + party->member_added(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10), RFIFOB(fd, 14)); + return 0; +} + +// ACK changing party option +int intif_parse_PartyOptionChanged(int fd) +{ + party->optionchanged(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOW(fd,10),RFIFOW(fd,12),RFIFOB(fd,14)); + return 0; +} + +// ACK member leaving party +int intif_parse_PartyMemberWithdraw(int fd) +{ + if(battle_config.etc_log) + ShowInfo("intif: party member withdraw: Party(%d), Account(%d), Char(%d)\n",RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10)); + party->member_withdraw(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10)); + return 0; +} + +// ACK party break +int intif_parse_PartyBroken(int fd) +{ + party->broken(RFIFOL(fd,2)); + return 0; +} + +// ACK party on new map +int intif_parse_PartyMove(int fd) +{ + party->recv_movemap(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOW(fd,14),RFIFOB(fd,16),RFIFOW(fd,17)); + return 0; +} + +// ACK party messages +int intif_parse_PartyMessage(int fd) +{ + party->recv_message(RFIFOL(fd,4),RFIFOL(fd,8),(char *) RFIFOP(fd,12),RFIFOW(fd,2)-12); + return 0; +} + +// ACK guild creation +int intif_parse_GuildCreated(int fd) +{ + guild->created(RFIFOL(fd,2),RFIFOL(fd,6)); + return 0; +} + +// ACK guild infos +int intif_parse_GuildInfo(int fd) +{ + if(RFIFOW(fd,2) == 8) { + ShowWarning("intif: guild noinfo %d\n",RFIFOL(fd,4)); + guild->recv_noinfo(RFIFOL(fd,4)); + return 0; + } + if( RFIFOW(fd,2)!=sizeof(struct guild)+4 ) + ShowError("intif: guild info : data size error Gid: %d recv size: %d Expected size: %d\n",RFIFOL(fd,4),RFIFOW(fd,2),sizeof(struct guild)+4); + guild->recv_info((struct guild *)RFIFOP(fd,4)); + return 0; +} + +// ACK adding guild member +int intif_parse_GuildMemberAdded(int fd) +{ + if(battle_config.etc_log) + ShowInfo("intif: guild member added %d %d %d %d\n",RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOB(fd,14)); + guild->member_added(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOB(fd,14)); + return 0; +} + +// ACK member leaving guild +int intif_parse_GuildMemberWithdraw(int fd) +{ + guild->member_withdraw(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOB(fd,14),(char *)RFIFOP(fd,55),(char *)RFIFOP(fd,15)); + return 0; +} + +// ACK guild member basic info +int intif_parse_GuildMemberInfoShort(int fd) +{ + guild->recv_memberinfoshort(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOB(fd,14),RFIFOW(fd,15),RFIFOW(fd,17)); + return 0; +} + +// ACK guild break +int intif_parse_GuildBroken(int fd) +{ + guild->broken(RFIFOL(fd,2),RFIFOB(fd,6)); + return 0; +} + +// basic guild info change notice +// 0x3839 .w .l .w .?b +int intif_parse_GuildBasicInfoChanged(int fd) +{ + //int len = RFIFOW(fd,2) - 10; + int guild_id = RFIFOL(fd,4); + int type = RFIFOW(fd,8); + //void* data = RFIFOP(fd,10); + + struct guild* g = guild->search(guild_id); + if( g == NULL ) + return 0; + + switch(type) { + case GBI_EXP: g->exp = RFIFOQ(fd,10); break; + case GBI_GUILDLV: g->guild_lv = RFIFOW(fd,10); break; + case GBI_SKILLPOINT: g->skill_point = RFIFOL(fd,10); break; + } + + return 0; +} + +// guild member info change notice +// 0x383a .w .l .l .l .w .?b +int intif_parse_GuildMemberInfoChanged(int fd) +{ + //int len = RFIFOW(fd,2) - 18; + int guild_id = RFIFOL(fd,4); + int account_id = RFIFOL(fd,8); + int char_id = RFIFOL(fd,12); + int type = RFIFOW(fd,16); + //void* data = RFIFOP(fd,18); + + struct guild* g; + int idx; + + g = guild->search(guild_id); + if( g == NULL ) + return 0; + + idx = guild->getindex(g,account_id,char_id); + if( idx == -1 ) + return 0; + + switch( type ) { + case GMI_POSITION: g->member[idx].position = RFIFOW(fd,18); guild->memberposition_changed(g,idx,RFIFOW(fd,18)); break; + case GMI_EXP: g->member[idx].exp = RFIFOQ(fd,18); break; + case GMI_HAIR: g->member[idx].hair = RFIFOW(fd,18); break; + case GMI_HAIR_COLOR: g->member[idx].hair_color = RFIFOW(fd,18); break; + case GMI_GENDER: g->member[idx].gender = RFIFOW(fd,18); break; + case GMI_CLASS: g->member[idx].class_ = RFIFOW(fd,18); break; + case GMI_LEVEL: g->member[idx].lv = RFIFOW(fd,18); break; + } + return 0; +} + +// ACK change of guild title +int intif_parse_GuildPosition(int fd) +{ + if( RFIFOW(fd,2)!=sizeof(struct guild_position)+12 ) + ShowError("intif: guild info : data size error\n %d %d %d",RFIFOL(fd,4),RFIFOW(fd,2),sizeof(struct guild_position)+12); + guild->position_changed(RFIFOL(fd,4),RFIFOL(fd,8),(struct guild_position *)RFIFOP(fd,12)); + return 0; +} + +// ACK change of guild skill update +int intif_parse_GuildSkillUp(int fd) +{ + guild->skillupack(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10)); + return 0; +} + +// ACK change of guild relationship +int intif_parse_GuildAlliance(int fd) +{ + guild->allianceack(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOL(fd,14),RFIFOB(fd,18),(char *) RFIFOP(fd,19),(char *) RFIFOP(fd,43)); + return 0; +} + +// ACK change of guild notice +int intif_parse_GuildNotice(int fd) +{ + guild->notice_changed(RFIFOL(fd,2),(char *) RFIFOP(fd,6),(char *) RFIFOP(fd,66)); + return 0; +} + +// ACK change of guild emblem +int intif_parse_GuildEmblem(int fd) +{ + guild->emblem_changed(RFIFOW(fd,2)-12,RFIFOL(fd,4),RFIFOL(fd,8), (char *)RFIFOP(fd,12)); + return 0; +} + +// ACK guild message +int intif_parse_GuildMessage(int fd) +{ + guild->recv_message(RFIFOL(fd,4),RFIFOL(fd,8),(char *) RFIFOP(fd,12),RFIFOW(fd,2)-12); + return 0; +} + +// Reply guild castle data request +int intif_parse_GuildCastleDataLoad(int fd) +{ + return guild->castledataloadack(RFIFOW(fd,2), (struct guild_castle *)RFIFOP(fd,4)); +} + +// ACK change of guildmaster +int intif_parse_GuildMasterChanged(int fd) +{ + return guild->gm_changed(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10)); +} + +// Request pet creation +int intif_parse_CreatePet(int fd) +{ + pet_get_egg(RFIFOL(fd,2),RFIFOL(fd,7),RFIFOB(fd,6)); + return 0; +} + +// ACK pet data +int intif_parse_RecvPetData(int fd) +{ + struct s_pet p; + int len; + len=RFIFOW(fd,2); + if(sizeof(struct s_pet)!=len-9) { + if(battle_config.etc_log) + ShowError("intif: pet data: data size error %d %d\n",sizeof(struct s_pet),len-9); + } + else{ + memcpy(&p,RFIFOP(fd,9),sizeof(struct s_pet)); + pet_recv_petdata(RFIFOL(fd,4),&p,RFIFOB(fd,8)); + } + + return 0; +} + +// ACK pet save data +int intif_parse_SavePetOk(int fd) +{ + if(RFIFOB(fd,6) == 1) + ShowError("pet data save failure\n"); + + return 0; +} + +// ACK deleting pet +int intif_parse_DeletePetOk(int fd) +{ + if(RFIFOB(fd,2) == 1) + ShowError("pet data delete failure\n"); + + return 0; +} + +// ACK changing name resquest, players,pets,hommon +int intif_parse_ChangeNameOk(int fd) +{ + struct map_session_data *sd = NULL; + if((sd=iMap->id2sd(RFIFOL(fd,2)))==NULL || + sd->status.char_id != RFIFOL(fd,6)) + return 0; + + switch (RFIFOB(fd,10)) { + case 0: //Players [NOT SUPPORTED YET] + break; + case 1: //Pets + pet_change_name_ack(sd, (char*)RFIFOP(fd,12), RFIFOB(fd,11)); + break; + case 2: //Hom + homun->change_name_ack(sd, (char*)RFIFOP(fd,12), RFIFOB(fd,11)); + break; + } + return 0; +} + +//---------------------------------------------------------------- +// Homunculus recv packets [albator] + +int intif_parse_CreateHomunculus(int fd) +{ + int len; + len=RFIFOW(fd,2)-9; + if(sizeof(struct s_homunculus)!=len) { + if(battle_config.etc_log) + ShowError("intif: create homun data: data size error %d != %d\n",sizeof(struct s_homunculus),len); + return 0; + } + homun->recv_data(RFIFOL(fd,4), (struct s_homunculus*)RFIFOP(fd,9), RFIFOB(fd,8)) ; + return 0; +} + +int intif_parse_RecvHomunculusData(int fd) +{ + int len; + + len=RFIFOW(fd,2)-9; + + if(sizeof(struct s_homunculus)!=len) { + if(battle_config.etc_log) + ShowError("intif: homun data: data size error %d %d\n",sizeof(struct s_homunculus),len); + return 0; + } + homun->recv_data(RFIFOL(fd,4), (struct s_homunculus*)RFIFOP(fd,9), RFIFOB(fd,8)); + return 0; +} + +int intif_parse_SaveHomunculusOk(int fd) +{ + if(RFIFOB(fd,6) != 1) + ShowError("homunculus data save failure for account %d\n", RFIFOL(fd,2)); + + return 0; +} + +int intif_parse_DeleteHomunculusOk(int fd) +{ + if(RFIFOB(fd,2) != 1) + ShowError("Homunculus data delete failure\n"); + + return 0; +} + +/************************************** + +QUESTLOG SYSTEM FUNCTIONS + +***************************************/ + +int intif_request_questlog(TBL_PC *sd) +{ + WFIFOHEAD(inter_fd,6); + WFIFOW(inter_fd,0) = 0x3060; + WFIFOL(inter_fd,2) = sd->status.char_id; + WFIFOSET(inter_fd,6); + return 0; +} + +int intif_parse_questlog(int fd) +{ + int char_id = RFIFOL(fd, 4); + int i; + TBL_PC * sd = iMap->charid2sd(char_id); + + //User not online anymore + if(!sd) + return -1; + + sd->avail_quests = sd->num_quests = (RFIFOW(fd, 2)-8)/sizeof(struct quest); + + memset(&sd->quest_log, 0, sizeof(sd->quest_log)); + + for( i = 0; i < sd->num_quests; i++ ) + { + memcpy(&sd->quest_log[i], RFIFOP(fd, i*sizeof(struct quest)+8), sizeof(struct quest)); + + sd->quest_index[i] = quest_search_db(sd->quest_log[i].quest_id); + + if( sd->quest_index[i] < 0 ) + { + ShowError("intif_parse_questlog: quest %d not found in DB.\n",sd->quest_log[i].quest_id); + sd->avail_quests--; + sd->num_quests--; + i--; + continue; + } + + if( sd->quest_log[i].state == Q_COMPLETE ) + sd->avail_quests--; + } + + quest_pc_login(sd); + + return 0; +} + +int intif_parse_questsave(int fd) +{ + int cid = RFIFOL(fd, 2); + TBL_PC *sd = iMap->id2sd(cid); + + if( !RFIFOB(fd, 6) ) + ShowError("intif_parse_questsave: Failed to save quest(s) for character %d!\n", cid); + else if( sd ) + sd->save_quest = false; + + return 0; +} + +int intif_quest_save(TBL_PC *sd) +{ + int len; + + if(intif->CheckForCharServer()) + return 0; + + len = sizeof(struct quest)*sd->num_quests + 8; + + WFIFOHEAD(inter_fd, len); + WFIFOW(inter_fd,0) = 0x3061; + WFIFOW(inter_fd,2) = len; + WFIFOL(inter_fd,4) = sd->status.char_id; + if( sd->num_quests ) + memcpy(WFIFOP(inter_fd,8), &sd->quest_log, sizeof(struct quest)*sd->num_quests); + WFIFOSET(inter_fd, len); + + return 0; +} + +/*========================================== + * MAIL SYSTEM + * By Zephyrus + *==========================================*/ + +/*------------------------------------------ + * Inbox Request + * flag: 0 Update Inbox | 1 OpenMail + *------------------------------------------*/ +int intif_Mail_requestinbox(int char_id, unsigned char flag) +{ + if (intif->CheckForCharServer()) + return 0; + + WFIFOHEAD(inter_fd,7); + WFIFOW(inter_fd,0) = 0x3048; + WFIFOL(inter_fd,2) = char_id; + WFIFOB(inter_fd,6) = flag; + WFIFOSET(inter_fd,7); + + return 0; +} + +int intif_parse_Mail_inboxreceived(int fd) +{ + struct map_session_data *sd; + unsigned char flag = RFIFOB(fd,8); + + sd = iMap->charid2sd(RFIFOL(fd,4)); + + if (sd == NULL) + { + ShowError("intif_parse_Mail_inboxreceived: char not found %d\n",RFIFOL(fd,4)); + return 1; + } + + if (RFIFOW(fd,2) - 9 != sizeof(struct mail_data)) + { + ShowError("intif_parse_Mail_inboxreceived: data size error %d %d\n", RFIFOW(fd,2) - 9, sizeof(struct mail_data)); + return 1; + } + + //FIXME: this operation is not safe [ultramage] + memcpy(&sd->mail.inbox, RFIFOP(fd,9), sizeof(struct mail_data)); + sd->mail.changed = false; // cache is now in sync + + if (flag) + clif->mail_refreshinbox(sd); + else if( battle_config.mail_show_status && ( battle_config.mail_show_status == 1 || sd->mail.inbox.unread ) ) + { + char output[128]; + sprintf(output, msg_txt(510), sd->mail.inbox.unchecked, sd->mail.inbox.unread + sd->mail.inbox.unchecked); + clif->disp_onlyself(sd, output, strlen(output)); + } + return 0; +} +/*------------------------------------------ + * Mail Read + *------------------------------------------*/ +int intif_Mail_read(int mail_id) +{ + if (intif->CheckForCharServer()) + return 0; + + WFIFOHEAD(inter_fd,6); + WFIFOW(inter_fd,0) = 0x3049; + WFIFOL(inter_fd,2) = mail_id; + WFIFOSET(inter_fd,6); + + return 0; +} +/*------------------------------------------ + * Get Attachment + *------------------------------------------*/ +int intif_Mail_getattach(int char_id, int mail_id) +{ + if (intif->CheckForCharServer()) + return 0; + + WFIFOHEAD(inter_fd,10); + WFIFOW(inter_fd,0) = 0x304a; + WFIFOL(inter_fd,2) = char_id; + WFIFOL(inter_fd,6) = mail_id; + WFIFOSET(inter_fd, 10); + + return 0; +} + +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) ); + + if (sd == NULL) + { + ShowError("intif_parse_Mail_getattach: char not found %d\n",RFIFOL(fd,4)); + return 1; + } + + if (RFIFOW(fd,2) - 12 != sizeof(struct item)) + { + ShowError("intif_parse_Mail_getattach: data size error %d %d\n", RFIFOW(fd,2) - 16, sizeof(struct item)); + return 1; + } + + memcpy(&item, RFIFOP(fd,12), sizeof(struct item)); + + mail->getattachment(sd, zeny, &item); + return 0; +} +/*------------------------------------------ + * Delete Message + *------------------------------------------*/ +int intif_Mail_delete(int char_id, int mail_id) +{ + if (intif->CheckForCharServer()) + return 0; + + WFIFOHEAD(inter_fd,10); + WFIFOW(inter_fd,0) = 0x304b; + WFIFOL(inter_fd,2) = char_id; + WFIFOL(inter_fd,6) = mail_id; + WFIFOSET(inter_fd,10); + + return 0; +} + +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); + if (sd == NULL) + { + ShowError("intif_parse_Mail_delete: char not found %d\n", char_id); + return 1; + } + + if (!failed) + { + int i; + ARR_FIND(0, MAIL_MAX_INBOX, i, sd->mail.inbox.msg[i].id == mail_id); + if( i < MAIL_MAX_INBOX ) + { + memset(&sd->mail.inbox.msg[i], 0, sizeof(struct mail_message)); + sd->mail.inbox.amount--; + } + + if( sd->mail.inbox.full ) + intif_Mail_requestinbox(sd->status.char_id, 1); // Free space is available for new mails + } + + clif->mail_delete(sd->fd, mail_id, failed); + return 0; +} +/*------------------------------------------ + * Return Message + *------------------------------------------*/ +int intif_Mail_return(int char_id, int mail_id) +{ + if (intif->CheckForCharServer()) + return 0; + + WFIFOHEAD(inter_fd,10); + WFIFOW(inter_fd,0) = 0x304c; + WFIFOL(inter_fd,2) = char_id; + WFIFOL(inter_fd,6) = mail_id; + WFIFOSET(inter_fd,10); + + return 0; +} + +int intif_parse_Mail_return(int fd) +{ + struct map_session_data *sd = iMap->charid2sd(RFIFOL(fd,2)); + int mail_id = RFIFOL(fd,6); + short fail = RFIFOB(fd,10); + + if( sd == NULL ) + { + ShowError("intif_parse_Mail_return: char not found %d\n",RFIFOL(fd,2)); + return 1; + } + + if( !fail ) + { + int i; + ARR_FIND(0, MAIL_MAX_INBOX, i, sd->mail.inbox.msg[i].id == mail_id); + if( i < MAIL_MAX_INBOX ) + { + memset(&sd->mail.inbox.msg[i], 0, sizeof(struct mail_message)); + sd->mail.inbox.amount--; + } + + if( sd->mail.inbox.full ) + intif_Mail_requestinbox(sd->status.char_id, 1); // Free space is available for new mails + } + + clif->mail_return(sd->fd, mail_id, fail); + return 0; +} +/*------------------------------------------ + * Send Mail + *------------------------------------------*/ +int intif_Mail_send(int account_id, struct mail_message *msg) +{ + int len = sizeof(struct mail_message) + 8; + + if (intif->CheckForCharServer()) + return 0; + + WFIFOHEAD(inter_fd,len); + WFIFOW(inter_fd,0) = 0x304d; + WFIFOW(inter_fd,2) = len; + WFIFOL(inter_fd,4) = account_id; + memcpy(WFIFOP(inter_fd,8), msg, sizeof(struct mail_message)); + WFIFOSET(inter_fd,len); + + return 1; +} + +static void intif_parse_Mail_send(int fd) +{ + struct mail_message msg; + struct map_session_data *sd; + bool fail; + + if( RFIFOW(fd,2) - 4 != sizeof(struct mail_message) ) + { + ShowError("intif_parse_Mail_send: data size error %d %d\n", RFIFOW(fd,2) - 4, sizeof(struct mail_message)); + return; + } + + memcpy(&msg, RFIFOP(fd,4), sizeof(struct mail_message)); + fail = (msg.id == 0); + + // notify sender + sd = iMap->charid2sd(msg.send_id); + if( sd != NULL ) + { + if( fail ) + mail->deliveryfail(sd, &msg); + else + { + clif->mail_send(sd->fd, false); + if( iMap->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)); + int mail_id = RFIFOL(fd,6); + const char* sender_name = (char*)RFIFOP(fd,10); + const char* title = (char*)RFIFOP(fd,34); + + if( sd == NULL ) + return; + + sd->mail.changed = true; + clif->mail_new(sd->fd, mail_id, sender_name, title); +} + +/*========================================== + * AUCTION SYSTEM + * By Zephyrus + *==========================================*/ +int intif_Auction_requestlist(int char_id, short type, int price, const char* searchtext, short page) +{ + int len = NAME_LENGTH + 16; + + if( intif->CheckForCharServer() ) + return 0; + + WFIFOHEAD(inter_fd,len); + WFIFOW(inter_fd,0) = 0x3050; + WFIFOW(inter_fd,2) = len; + WFIFOL(inter_fd,4) = char_id; + WFIFOW(inter_fd,8) = type; + WFIFOL(inter_fd,10) = price; + WFIFOW(inter_fd,14) = page; + memcpy(WFIFOP(inter_fd,16), searchtext, NAME_LENGTH); + WFIFOSET(inter_fd,len); + + return 0; +} + +static void intif_parse_Auction_results(int fd) +{ + struct map_session_data *sd = iMap->charid2sd(RFIFOL(fd,4)); + short count = RFIFOW(fd,8); + short pages = RFIFOW(fd,10); + uint8* data = RFIFOP(fd,12); + + if( sd == NULL ) + return; + + clif->auction_results(sd, count, pages, data); +} + +int intif_Auction_register(struct auction_data *auction) +{ + int len = sizeof(struct auction_data) + 4; + + if( intif->CheckForCharServer() ) + return 0; + + WFIFOHEAD(inter_fd,len); + WFIFOW(inter_fd,0) = 0x3051; + WFIFOW(inter_fd,2) = len; + memcpy(WFIFOP(inter_fd,4), auction, sizeof(struct auction_data)); + WFIFOSET(inter_fd,len); + + return 1; +} + +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) ) + { + 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 ) + return; + + if( auction.auction_id > 0 ) + { + clif->auction_message(sd->fd, 1); // Confirmation Packet ?? + if( iMap->save_settings&32 ) + chrif->save(sd,0); + } + else + { + int zeny = auction.hours*battle_config.auction_feeperhour; + + clif->auction_message(sd->fd, 4); + pc->additem(sd, &auction.item, auction.item.amount, LOG_TYPE_AUCTION); + + pc->getzeny(sd, zeny, LOG_TYPE_AUCTION, NULL); + } +} + +int intif_Auction_cancel(int char_id, unsigned int auction_id) +{ + if( intif->CheckForCharServer() ) + return 0; + + WFIFOHEAD(inter_fd,10); + WFIFOW(inter_fd,0) = 0x3052; + WFIFOL(inter_fd,2) = char_id; + WFIFOL(inter_fd,6) = auction_id; + WFIFOSET(inter_fd,10); + + return 0; +} + +static void intif_parse_Auction_cancel(int fd) +{ + struct map_session_data *sd = iMap->charid2sd(RFIFOL(fd,2)); + int result = RFIFOB(fd,6); + + if( sd == NULL ) + return; + + 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; + case 3: clif->auction_message(sd->fd, 3); break; + } +} + +int intif_Auction_close(int char_id, unsigned int auction_id) +{ + if( intif->CheckForCharServer() ) + return 0; + + WFIFOHEAD(inter_fd,10); + WFIFOW(inter_fd,0) = 0x3053; + WFIFOL(inter_fd,2) = char_id; + WFIFOL(inter_fd,6) = auction_id; + WFIFOSET(inter_fd,10); + + return 0; +} + +static void intif_parse_Auction_close(int fd) +{ + struct map_session_data *sd = iMap->charid2sd(RFIFOL(fd,2)); + unsigned char result = RFIFOB(fd,6); + + if( sd == NULL ) + return; + + clif->auction_close(sd->fd, result); + if( result == 0 ) + { + // FIXME: Leeching off a parse function + clif->pAuction_cancelreg(fd, sd); + intif_Auction_requestlist(sd->status.char_id, 6, 0, "", 1); + } +} + +int intif_Auction_bid(int char_id, const char* name, unsigned int auction_id, int bid) +{ + int len = 16 + NAME_LENGTH; + + if( intif->CheckForCharServer() ) + return 0; + + WFIFOHEAD(inter_fd,len); + WFIFOW(inter_fd,0) = 0x3055; + WFIFOW(inter_fd,2) = len; + WFIFOL(inter_fd,4) = char_id; + WFIFOL(inter_fd,8) = auction_id; + WFIFOL(inter_fd,12) = bid; + memcpy(WFIFOP(inter_fd,16), name, NAME_LENGTH); + WFIFOSET(inter_fd,len); + + return 0; +} + +static void intif_parse_Auction_bid(int fd) +{ + struct map_session_data *sd = iMap->charid2sd(RFIFOL(fd,2)); + int bid = RFIFOL(fd,6); + unsigned char result = RFIFOB(fd,10); + + if( sd == NULL ) + return; + + clif->auction_message(sd->fd, result); + if( bid > 0 ) { + pc->getzeny(sd, bid, LOG_TYPE_AUCTION,NULL); + } + if( result == 1 ) { // To update the list, display your buy list + clif->pAuction_cancelreg(fd, sd); + intif_Auction_requestlist(sd->status.char_id, 7, 0, "", 1); + } +} + +// 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)); + unsigned char result = RFIFOB(fd,6); + + if( sd == NULL ) + return; + + clif->auction_message(sd->fd, result); +} + +/*========================================== + * Mercenary's System + *------------------------------------------*/ +int intif_mercenary_create(struct s_mercenary *merc) +{ + int size = sizeof(struct s_mercenary) + 4; + + if( intif->CheckForCharServer() ) + return 0; + + WFIFOHEAD(inter_fd,size); + WFIFOW(inter_fd,0) = 0x3070; + WFIFOW(inter_fd,2) = size; + memcpy(WFIFOP(inter_fd,4), merc, sizeof(struct s_mercenary)); + WFIFOSET(inter_fd,size); + return 0; +} + +int intif_parse_mercenary_received(int fd) +{ + int len = RFIFOW(fd,2) - 5; + if( sizeof(struct s_mercenary) != len ) + { + if( battle_config.etc_log ) + ShowError("intif: create mercenary data size error %d != %d\n", sizeof(struct s_mercenary), len); + return 0; + } + + merc_data_received((struct s_mercenary*)RFIFOP(fd,5), RFIFOB(fd,4)); + return 0; +} + +int intif_mercenary_request(int merc_id, int char_id) +{ + if (intif->CheckForCharServer()) + return 0; + + WFIFOHEAD(inter_fd,10); + WFIFOW(inter_fd,0) = 0x3071; + WFIFOL(inter_fd,2) = merc_id; + WFIFOL(inter_fd,6) = char_id; + WFIFOSET(inter_fd,10); + return 0; +} + +int intif_mercenary_delete(int merc_id) +{ + if (intif->CheckForCharServer()) + return 0; + + WFIFOHEAD(inter_fd,6); + WFIFOW(inter_fd,0) = 0x3072; + WFIFOL(inter_fd,2) = merc_id; + WFIFOSET(inter_fd,6); + return 0; +} + +int intif_parse_mercenary_deleted(int fd) +{ + if( RFIFOB(fd,2) != 1 ) + ShowError("Mercenary data delete failure\n"); + + return 0; +} + +int intif_mercenary_save(struct s_mercenary *merc) +{ + int size = sizeof(struct s_mercenary) + 4; + + if( intif->CheckForCharServer() ) + return 0; + + WFIFOHEAD(inter_fd,size); + WFIFOW(inter_fd,0) = 0x3073; + WFIFOW(inter_fd,2) = size; + memcpy(WFIFOP(inter_fd,4), merc, sizeof(struct s_mercenary)); + WFIFOSET(inter_fd,size); + return 0; +} + +int intif_parse_mercenary_saved(int fd) +{ + if( RFIFOB(fd,2) != 1 ) + ShowError("Mercenary data save failure\n"); + + return 0; +} + +/*========================================== + * Elemental's System + *------------------------------------------*/ +int intif_elemental_create(struct s_elemental *ele) +{ + int size = sizeof(struct s_elemental) + 4; + + if( intif->CheckForCharServer() ) + return 0; + + WFIFOHEAD(inter_fd,size); + WFIFOW(inter_fd,0) = 0x307c; + WFIFOW(inter_fd,2) = size; + memcpy(WFIFOP(inter_fd,4), ele, sizeof(struct s_elemental)); + WFIFOSET(inter_fd,size); + return 0; +} + +int intif_parse_elemental_received(int fd) +{ + int len = RFIFOW(fd,2) - 5; + if( sizeof(struct s_elemental) != len ) + { + if( battle_config.etc_log ) + ShowError("intif: create elemental data size error %d != %d\n", sizeof(struct s_elemental), len); + return 0; + } + + elemental->data_received((struct s_elemental*)RFIFOP(fd,5), RFIFOB(fd,4)); + return 0; +} + +int intif_elemental_request(int ele_id, int char_id) +{ + if (intif->CheckForCharServer()) + return 0; + + WFIFOHEAD(inter_fd,10); + WFIFOW(inter_fd,0) = 0x307d; + WFIFOL(inter_fd,2) = ele_id; + WFIFOL(inter_fd,6) = char_id; + WFIFOSET(inter_fd,10); + return 0; +} + +int intif_elemental_delete(int ele_id) +{ + if (intif->CheckForCharServer()) + return 0; + + WFIFOHEAD(inter_fd,6); + WFIFOW(inter_fd,0) = 0x307e; + WFIFOL(inter_fd,2) = ele_id; + WFIFOSET(inter_fd,6); + return 0; +} + +int intif_parse_elemental_deleted(int fd) +{ + if( RFIFOB(fd,2) != 1 ) + ShowError("Elemental data delete failure\n"); + + return 0; +} + +int intif_elemental_save(struct s_elemental *ele) +{ + int size = sizeof(struct s_elemental) + 4; + + if( intif->CheckForCharServer() ) + return 0; + + WFIFOHEAD(inter_fd,size); + WFIFOW(inter_fd,0) = 0x307f; + WFIFOW(inter_fd,2) = size; + memcpy(WFIFOP(inter_fd,4), ele, sizeof(struct s_elemental)); + WFIFOSET(inter_fd,size); + return 0; +} + +int intif_parse_elemental_saved(int fd) +{ + if( RFIFOB(fd,2) != 1 ) + ShowError("Elemental data save failure\n"); + + return 0; +} + +void intif_request_accinfo( int u_fd, int aid, int group_lv, char* query ) { + + + WFIFOHEAD(inter_fd,2 + 4 + 4 + 4 + NAME_LENGTH); + + WFIFOW(inter_fd,0) = 0x3007; + WFIFOL(inter_fd,2) = u_fd; + WFIFOL(inter_fd,6) = aid; + WFIFOL(inter_fd,10) = group_lv; + safestrncpy((char *)WFIFOP(inter_fd,14), query, NAME_LENGTH); + + WFIFOSET(inter_fd,2 + 4 + 4 + 4 + NAME_LENGTH); + + return; +} + +void intif_parse_MessageToFD(int fd) { + int u_fd = RFIFOL(fd,4); + + if( session[u_fd] && session[u_fd]->session_data ) { + int aid = RFIFOL(fd,8); + struct map_session_data * sd = session[u_fd]->session_data; + /* matching e.g. previous fd owner didn't dc during request or is still the same */ + if( sd->bl.id == aid ) { + char msg[512]; + safestrncpy(msg, (char*)RFIFOP(fd,12), RFIFOW(fd,2) - 12); + clif->message(u_fd,msg); + } + + } + + return; +} + +//----------------------------------------------------------------- +// Communication from the inter server +// Return a 0 (false) if there were any errors. +// 1, 2 if there are not enough to return the length of the packet if the packet processing +int intif_parse(int fd) +{ + int packet_len, cmd; + cmd = RFIFOW(fd,0); + // Verify ID of the packet + if(cmd<0x3800 || cmd>=0x3800+(sizeof(packet_len_table)/sizeof(packet_len_table[0])) || + packet_len_table[cmd-0x3800]==0){ + return 0; + } + // Check the length of the packet + packet_len = packet_len_table[cmd-0x3800]; + if(packet_len==-1){ + if(RFIFOREST(fd)<4) + return 2; + packet_len = RFIFOW(fd,2); + } + if((int)RFIFOREST(fd)broadcast(NULL, (char *) RFIFOP(fd,16), packet_len-16, 0, ALL_CLIENT); + else //Color announce. + clif->broadcast2(NULL, (char *) RFIFOP(fd,16), packet_len-16, RFIFOL(fd,4), RFIFOW(fd,8), RFIFOW(fd,10), RFIFOW(fd,12), RFIFOW(fd,14), ALL_CLIENT); + break; + case 0x3801: intif_parse_WisMessage(fd); break; + case 0x3802: intif_parse_WisEnd(fd); break; + case 0x3803: mapif_parse_WisToGM(fd); break; + case 0x3804: intif_parse_Registers(fd); break; + case 0x3806: intif_parse_ChangeNameOk(fd); break; + case 0x3807: intif_parse_MessageToFD(fd); break; + case 0x3818: intif_parse_LoadGuildStorage(fd); break; + case 0x3819: intif_parse_SaveGuildStorage(fd); break; + case 0x3820: intif_parse_PartyCreated(fd); break; + case 0x3821: intif_parse_PartyInfo(fd); break; + case 0x3822: intif_parse_PartyMemberAdded(fd); break; + case 0x3823: intif_parse_PartyOptionChanged(fd); break; + case 0x3824: intif_parse_PartyMemberWithdraw(fd); break; + case 0x3825: intif_parse_PartyMove(fd); break; + case 0x3826: intif_parse_PartyBroken(fd); break; + case 0x3827: intif_parse_PartyMessage(fd); break; + case 0x3830: intif_parse_GuildCreated(fd); break; + case 0x3831: intif_parse_GuildInfo(fd); break; + case 0x3832: intif_parse_GuildMemberAdded(fd); break; + case 0x3834: intif_parse_GuildMemberWithdraw(fd); break; + case 0x3835: intif_parse_GuildMemberInfoShort(fd); break; + case 0x3836: intif_parse_GuildBroken(fd); break; + case 0x3837: intif_parse_GuildMessage(fd); break; + case 0x3839: intif_parse_GuildBasicInfoChanged(fd); break; + case 0x383a: intif_parse_GuildMemberInfoChanged(fd); break; + case 0x383b: intif_parse_GuildPosition(fd); break; + case 0x383c: intif_parse_GuildSkillUp(fd); break; + case 0x383d: intif_parse_GuildAlliance(fd); break; + case 0x383e: intif_parse_GuildNotice(fd); break; + case 0x383f: intif_parse_GuildEmblem(fd); break; + case 0x3840: intif_parse_GuildCastleDataLoad(fd); break; + case 0x3843: intif_parse_GuildMasterChanged(fd); break; + + //Quest system + case 0x3860: intif_parse_questlog(fd); break; + case 0x3861: intif_parse_questsave(fd); break; + +// Mail System + case 0x3848: intif_parse_Mail_inboxreceived(fd); break; + case 0x3849: intif_parse_Mail_new(fd); break; + case 0x384a: intif_parse_Mail_getattach(fd); break; + case 0x384b: intif_parse_Mail_delete(fd); break; + case 0x384c: intif_parse_Mail_return(fd); break; + case 0x384d: intif_parse_Mail_send(fd); break; +// Auction System + case 0x3850: intif_parse_Auction_results(fd); break; + case 0x3851: intif_parse_Auction_register(fd); break; + case 0x3852: intif_parse_Auction_cancel(fd); break; + case 0x3853: intif_parse_Auction_close(fd); break; + case 0x3854: intif_parse_Auction_message(fd); break; + case 0x3855: intif_parse_Auction_bid(fd); break; + +// Mercenary System + case 0x3870: intif_parse_mercenary_received(fd); break; + case 0x3871: intif_parse_mercenary_deleted(fd); break; + case 0x3872: intif_parse_mercenary_saved(fd); break; +// Elemental System + case 0x387c: intif_parse_elemental_received(fd); break; + case 0x387d: intif_parse_elemental_deleted(fd); break; + case 0x387e: intif_parse_elemental_saved(fd); break; + + case 0x3880: intif_parse_CreatePet(fd); break; + case 0x3881: intif_parse_RecvPetData(fd); break; + case 0x3882: intif_parse_SavePetOk(fd); break; + case 0x3883: intif_parse_DeletePetOk(fd); break; + case 0x3890: intif_parse_CreateHomunculus(fd); break; + case 0x3891: intif_parse_RecvHomunculusData(fd); break; + case 0x3892: intif_parse_SaveHomunculusOk(fd); break; + case 0x3893: intif_parse_DeleteHomunculusOk(fd); break; + default: + ShowError("intif_parse : unknown packet %d %x\n",fd,RFIFOW(fd,0)); + return 0; + } + // Skip packet + RFIFOSKIP(fd,packet_len); + return 1; +} + +/*===================================== +* Default Functions : intif.h +* Generated by HerculesInterfaceMaker +* created by Susu +*-------------------------------------*/ +void intif_defaults(void) { + intif = &intif_s; + /* funcs */ + + intif->parse = intif_parse; + + intif->broadcast = intif_broadcast; + intif->broadcast2 = intif_broadcast2; + intif->main_message = intif_main_message; + + intif->wis_message = intif_wis_message; + intif->wis_message_to_gm = intif_wis_message_to_gm; + + intif->saveregistry = intif_saveregistry; + intif->request_registry = intif_request_registry; + + intif->request_guild_storage = intif_request_guild_storage; + intif->send_guild_storage = intif_send_guild_storage; + + intif->create_party = intif_create_party; + intif->request_partyinfo = intif_request_partyinfo; + + intif->party_addmember = intif_party_addmember; + intif->party_changeoption = intif_party_changeoption; + intif->party_leave = intif_party_leave; + intif->party_changemap = intif_party_changemap; + intif->break_party = intif_break_party; + intif->party_message = intif_party_message; + intif->party_leaderchange = intif_party_leaderchange; + + intif->guild_create = intif_guild_create; + intif->guild_request_info = intif_guild_request_info; + intif->guild_addmember = intif_guild_addmember; + intif->guild_leave = intif_guild_leave; + intif->guild_memberinfoshort = intif_guild_memberinfoshort; + intif->guild_break = intif_guild_break; + intif->guild_message = intif_guild_message; + intif->guild_change_gm = intif_guild_change_gm; + intif->guild_change_basicinfo = intif_guild_change_basicinfo; + intif->guild_change_memberinfo = intif_guild_change_memberinfo; + intif->guild_position = intif_guild_position; + intif->guild_skillup = intif_guild_skillup; + intif->guild_alliance = intif_guild_alliance; + intif->guild_notice = intif_guild_notice; + intif->guild_emblem = intif_guild_emblem; + intif->guild_castle_dataload = intif_guild_castle_dataload; + intif->guild_castle_datasave = intif_guild_castle_datasave; + intif->request_petdata = intif_request_petdata; + intif->save_petdata = intif_save_petdata; + intif->delete_petdata = intif_delete_petdata; + intif->rename = intif_rename; + intif->homunculus_create = intif_homunculus_create; + intif->homunculus_requestload = intif_homunculus_requestload; + intif->homunculus_requestsave = intif_homunculus_requestsave; + intif->homunculus_requestdelete = intif_homunculus_requestdelete; + /******QUEST SYTEM*******/ + intif->request_questlog = intif_request_questlog; + intif->quest_save = intif_quest_save; + // MERCENARY SYSTEM + intif->mercenary_create = intif_mercenary_create; + intif->mercenary_request = intif_mercenary_request; + intif->mercenary_delete = intif_mercenary_delete; + intif->mercenary_save = intif_mercenary_save; + // MAIL SYSTEM + intif->Mail_requestinbox = intif_Mail_requestinbox; + intif->Mail_read = intif_Mail_read; + intif->Mail_getattach = intif_Mail_getattach; + intif->Mail_delete = intif_Mail_delete; + intif->Mail_return = intif_Mail_return; + intif->Mail_send = intif_Mail_send; + // AUCTION SYSTEM + intif->Auction_requestlist = intif_Auction_requestlist; + intif->Auction_register = intif_Auction_register; + intif->Auction_cancel = intif_Auction_cancel; + intif->Auction_close = intif_Auction_close; + intif->Auction_bid = intif_Auction_bid; + // ELEMENTAL SYSTEM + intif->elemental_create = intif_elemental_create; + intif->elemental_request = intif_elemental_request; + intif->elemental_delete = intif_elemental_delete; + intif->elemental_save = intif_elemental_save; + /* @accinfo */ + intif->request_accinfo = intif_request_accinfo; + + intif->CheckForCharServer = CheckForCharServer; +} diff --git a/src/map/intif.h b/src/map/intif.h index 43bbc0859..f0c1067fb 100644 --- a/src/map/intif.h +++ b/src/map/intif.h @@ -1,112 +1,128 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder - -#ifndef _INTIF_H_ -#define _INFIF_H_ - -//#include "../common/mmo.h" -struct party_member; -struct guild_member; -struct guild_position; -struct s_pet; -struct s_homunculus; -struct s_mercenary; -struct s_elemental; -struct mail_message; -struct auction_data; - -int intif_parse(int fd); - -int intif_broadcast(const char* mes, int len, int type); -int intif_broadcast2(const char* mes, int len, unsigned long fontColor, short fontType, short fontSize, short fontAlign, short fontY); -int intif_main_message(struct map_session_data* sd, const char* message); - -int intif_wis_message(struct map_session_data *sd,char *nick,char *mes,int mes_len); -int intif_wis_message_to_gm(char *Wisp_name, int permission, char *mes); - -int intif_saveregistry(struct map_session_data *sd, int type); -int intif_request_registry(struct map_session_data *sd, int flag); - -int intif_request_guild_storage(int account_id, int guild_id); -int intif_send_guild_storage(int account_id, struct guild_storage *gstor); - - -int intif_create_party(struct party_member *member,char *name,int item,int item2); -int intif_request_partyinfo(int party_id, int char_id); - -int intif_party_addmember(int party_id,struct party_member *member); -int intif_party_changeoption(int party_id, int account_id, int exp, int item); -int intif_party_leave(int party_id,int account_id, int char_id); -int intif_party_changemap(struct map_session_data *sd, int online); -int intif_break_party(int party_id); -int intif_party_message(int party_id, int account_id, const char *mes,int len); -int intif_party_leaderchange(int party_id,int account_id,int char_id); - - -int intif_guild_create(const char *name, const struct guild_member *master); -int intif_guild_request_info(int guild_id); -int intif_guild_addmember(int guild_id, struct guild_member *m); -int intif_guild_leave(int guild_id, int account_id, int char_id, int flag, const char *mes); -int intif_guild_memberinfoshort(int guild_id, int account_id, int char_id, int online, int lv, int class_); -int intif_guild_break(int guild_id); -int intif_guild_message(int guild_id, int account_id, const char *mes, int len); -int intif_guild_change_gm(int guild_id, const char* name, int len); -int intif_guild_change_basicinfo(int guild_id, int type, const void *data, int len); -int intif_guild_change_memberinfo(int guild_id, int account_id, int char_id, int type, const void *data, int len); -int intif_guild_position(int guild_id, int idx, struct guild_position *p); -int intif_guild_skillup(int guild_id, uint16 skill_id, int account_id, int max); -int intif_guild_alliance(int guild_id1, int guild_id2, int account_id1, int account_id2, int flag); -int intif_guild_notice(int guild_id, const char *mes1, const char *mes2); -int intif_guild_emblem(int guild_id, int len, const char *data); -int intif_guild_castle_dataload(int num, int *castle_ids); -int intif_guild_castle_datasave(int castle_id, int index, int value); - -int intif_create_pet(int account_id, int char_id, short pet_type, short pet_lv, short pet_egg_id, - short pet_equip, short intimate, short hungry, char rename_flag, char incuvate, char *pet_name); -int intif_request_petdata(int account_id, int char_id, int pet_id); -int intif_save_petdata(int account_id, struct s_pet *p); -int intif_delete_petdata(int pet_id); -int intif_rename(struct map_session_data *sd, int type, char *name); -#define intif_rename_pc(sd, name) intif_rename(sd, 0, name) -#define intif_rename_pet(sd, name) intif_rename(sd, 1, name) -#define intif_rename_hom(sd, name) intif_rename(sd, 2, name) -int intif_homunculus_create(int account_id, struct s_homunculus *sh); -bool intif_homunculus_requestload(int account_id, int homun_id); -int intif_homunculus_requestsave(int account_id, struct s_homunculus* sh); -int intif_homunculus_requestdelete(int homun_id); - -/******QUEST SYTEM*******/ -int intif_request_questlog(struct map_session_data * sd); -int intif_quest_save(struct map_session_data * sd); - -// MERCENARY SYSTEM -int intif_mercenary_create(struct s_mercenary *merc); -int intif_mercenary_request(int merc_id, int char_id); -int intif_mercenary_delete(int merc_id); -int intif_mercenary_save(struct s_mercenary *merc); - -// MAIL SYSTEM -int intif_Mail_requestinbox(int char_id, unsigned char flag); -int intif_Mail_read(int mail_id); -int intif_Mail_getattach(int char_id, int mail_id); -int intif_Mail_delete(int char_id, int mail_id); -int intif_Mail_return(int char_id, int mail_id); -int intif_Mail_send(int account_id, struct mail_message *msg); -// AUCTION SYSTEM -int intif_Auction_requestlist(int char_id, short type, int price, const char* searchtext, short page); -int intif_Auction_register(struct auction_data *auction); -int intif_Auction_cancel(int char_id, unsigned int auction_id); -int intif_Auction_close(int char_id, unsigned int auction_id); -int intif_Auction_bid(int char_id, const char* name, unsigned int auction_id, int bid); -// ELEMENTAL SYSTEM -int intif_elemental_create(struct s_elemental *ele); -int intif_elemental_request(int ele_id, int char_id); -int intif_elemental_delete(int ele_id); -int intif_elemental_save(struct s_elemental *ele); - -/* @accinfo */ -void intif_request_accinfo( int u_fd, int aid, int group_lv, char* query ); - -int CheckForCharServer(void); - -#endif /* _INTIF_H_ */ +// Copyright (c) Athena Dev Teams - Licensed under GNU GPL +// For more information, see LICENCE in the main folder +#ifndef _INTIF_H_ +#define _INFIF_H_ +//#include "../common/mmo.h" +struct party_member; +struct guild_member; +struct guild_position; +struct s_pet; +struct s_homunculus; +struct s_mercenary; +struct s_elemental; +struct mail_message; +struct auction_data; + + + + + +#define intif_rename_pc(sd, name) intif->rename(sd, 0, name) +#define intif_rename_pet(sd, name) intif->rename(sd, 1, name) +#define intif_rename_hom(sd, name) intif->rename(sd, 2, name) + + + + + + +/*===================================== +* Interface : intif.h +* Generated by HerculesInterfaceMaker +* created by Susu +*-------------------------------------*/ +struct intif_interface { + /* funcs */ + + + int (*parse) (int fd); + + int (*create_pet)(int account_id, int char_id, short pet_type, short pet_lv, short pet_egg_id, + short pet_equip, short intimate, short hungry, char rename_flag, char incuvate, char *pet_name); + + int (*broadcast) (const char* mes, int len, int type); + int (*broadcast2) (const char* mes, int len, unsigned long fontColor, short fontType, short fontSize, short fontAlign, short fontY); + int (*main_message) (struct map_session_data* sd, const char* message); + + int (*wis_message) (struct map_session_data *sd,char *nick,char *mes,int mes_len); + int (*wis_message_to_gm) (char *Wisp_name, int permission, char *mes); + + int (*saveregistry) (struct map_session_data *sd, int type); + int (*request_registry) (struct map_session_data *sd, int flag); + + int (*request_guild_storage) (int account_id, int guild_id); + int (*send_guild_storage) (int account_id, struct guild_storage *gstor); + + int (*create_party) (struct party_member *member,char *name,int item,int item2); + int (*request_partyinfo) (int party_id, int char_id); + + int (*party_addmember) (int party_id,struct party_member *member); + int (*party_changeoption) (int party_id, int account_id, int exp, int item); + int (*party_leave) (int party_id,int account_id, int char_id); + int (*party_changemap) (struct map_session_data *sd, int online); + int (*break_party) (int party_id); + int (*party_message) (int party_id, int account_id, const char *mes,int len); + int (*party_leaderchange) (int party_id,int account_id,int char_id); + + int (*guild_create) (const char *name, const struct guild_member *master); + int (*guild_request_info) (int guild_id); + int (*guild_addmember) (int guild_id, struct guild_member *m); + int (*guild_leave) (int guild_id, int account_id, int char_id, int flag, const char *mes); + int (*guild_memberinfoshort) (int guild_id, int account_id, int char_id, int online, int lv, int class_); + int (*guild_break) (int guild_id); + int (*guild_message) (int guild_id, int account_id, const char *mes, int len); + int (*guild_change_gm) (int guild_id, const char* name, int len); + int (*guild_change_basicinfo) (int guild_id, int type, const void *data, int len); + int (*guild_change_memberinfo) (int guild_id, int account_id, int char_id, int type, const void *data, int len); + int (*guild_position) (int guild_id, int idx, struct guild_position *p); + int (*guild_skillup) (int guild_id, uint16 skill_id, int account_id, int max); + int (*guild_alliance) (int guild_id1, int guild_id2, int account_id1, int account_id2, int flag); + int (*guild_notice) (int guild_id, const char *mes1, const char *mes2); + int (*guild_emblem) (int guild_id, int len, const char *data); + int (*guild_castle_dataload) (int num, int *castle_ids); + int (*guild_castle_datasave) (int castle_id, int index, int value); + int (*request_petdata) (int account_id, int char_id, int pet_id); + int (*save_petdata) (int account_id, struct s_pet *p); + int (*delete_petdata) (int pet_id); + int (*rename) (struct map_session_data *sd, int type, char *name); + int (*homunculus_create) (int account_id, struct s_homunculus *sh); + bool (*homunculus_requestload) (int account_id, int homun_id); + int (*homunculus_requestsave) (int account_id, struct s_homunculus* sh); + int (*homunculus_requestdelete) (int homun_id); + /******QUEST SYTEM*******/ + int (*request_questlog) (struct map_session_data * sd); + int (*quest_save) (struct map_session_data * sd); + // MERCENARY SYSTEM + int (*mercenary_create) (struct s_mercenary *merc); + int (*mercenary_request) (int merc_id, int char_id); + int (*mercenary_delete) (int merc_id); + int (*mercenary_save) (struct s_mercenary *merc); + // MAIL SYSTEM + int (*Mail_requestinbox) (int char_id, unsigned char flag); + int (*Mail_read) (int mail_id); + int (*Mail_getattach) (int char_id, int mail_id); + int (*Mail_delete) (int char_id, int mail_id); + int (*Mail_return) (int char_id, int mail_id); + int (*Mail_send) (int account_id, struct mail_message *msg); + // AUCTION SYSTEM + int (*Auction_requestlist) (int char_id, short type, int price, const char* searchtext, short page); + int (*Auction_register) (struct auction_data *auction); + int (*Auction_cancel) (int char_id, unsigned int auction_id); + int (*Auction_close) (int char_id, unsigned int auction_id); + int (*Auction_bid) (int char_id, const char* name, unsigned int auction_id, int bid); + // ELEMENTAL SYSTEM + int (*elemental_create) (struct s_elemental *ele); + int (*elemental_request) (int ele_id, int char_id); + int (*elemental_delete) (int ele_id); + int (*elemental_save) (struct s_elemental *ele); + /* @accinfo */ + void (*request_accinfo) (int u_fd, int aid, int group_lv, char* query); + + int (*CheckForCharServer) (void); +} intif_s; + +struct intif_interface *intif; + +void intif_defaults(void); + +#endif /* _INTIF_H_ */ diff --git a/src/map/map.c b/src/map/map.c index 5e8102ea0..5db5431a8 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -1185,7 +1185,7 @@ int map_clearflooritem_timer(int tid, unsigned int tick, int id, intptr_t data) if (search_petDB_index(fitem->item_data.nameid, PET_EGG) >= 0) - intif_delete_petdata(MakeDWord(fitem->item_data.card[1], fitem->item_data.card[2])); + intif->delete_petdata(MakeDWord(fitem->item_data.card[1], fitem->item_data.card[2])); clif->clearflooritem(fitem, 0); iMap->deliddb(&fitem->bl); @@ -5158,6 +5158,7 @@ void map_hp_symbols(void) { HPM->share(chat, "chat"); HPM->share(iDuel,"iDuel"); HPM->share(elemental,"elemental"); + HPM->share(intif,"intif"); /* partial */ @@ -5199,6 +5200,7 @@ void map_load_defaults(void) { chat_defaults(); iDuel_defaults(); elemental_defaults(); + intif_defaults(); } int do_init(int argc, char *argv[]) { diff --git a/src/map/mercenary.c b/src/map/mercenary.c index a08b587e7..72ed7628a 100644 --- a/src/map/mercenary.c +++ b/src/map/mercenary.c @@ -82,7 +82,7 @@ int merc_create(struct map_session_data *sd, int class_, unsigned int lifetime) merc.life_time = lifetime; // Request Char Server to create this mercenary - intif_mercenary_create(&merc); + intif->mercenary_create(&merc); return 1; } @@ -213,7 +213,7 @@ int mercenary_save(struct mercenary_data *md) md->mercenary.sp = md->battle_status.sp; md->mercenary.life_time = mercenary_get_lifetime(md); - intif_mercenary_save(&md->mercenary); + intif->mercenary_save(&md->mercenary); return 1; } diff --git a/src/map/mob.c b/src/map/mob.c index 9cd05a8a3..04f3063e5 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -1605,7 +1605,7 @@ static bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick) memcpy (&md->lootitem[md->lootitem_count++], &fitem->item_data, sizeof(md->lootitem[0])); } else { //Destroy first looted item... if (md->lootitem[0].card[0] == CARD0_PET) - intif_delete_petdata( MakeDWord(md->lootitem[0].card[1],md->lootitem[0].card[2]) ); + intif->delete_petdata( MakeDWord(md->lootitem[0].card[1],md->lootitem[0].card[2]) ); memmove(&md->lootitem[0], &md->lootitem[1], (LOOTITEM_SIZE-1)*sizeof(md->lootitem[0])); memcpy (&md->lootitem[LOOTITEM_SIZE-1], &fitem->item_data, sizeof(md->lootitem[0])); } @@ -2386,7 +2386,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) char message[128]; sprintf (message, msg_txt(541), mvp_sd->status.name, md->name, it->jname, (float)drop_rate/100); //MSG: "'%s' won %s's %s (chance: %0.02f%%)" - intif_broadcast(message,strlen(message)+1,0); + intif->broadcast(message,strlen(message)+1,0); } // Announce first, or else ditem will be freed. [Lance] // By popular demand, use base drop rate for autoloot code. [Skotlex] @@ -2527,7 +2527,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) char message[128]; sprintf (message, msg_txt(541), mvp_sd->status.name, md->name, data->jname, temp/100.); //MSG: "'%s' won %s's %s (chance: %0.02f%%)" - intif_broadcast(message,strlen(message)+1,0); + intif->broadcast(message,strlen(message)+1,0); } if((temp = pc->additem(mvp_sd,&item,1,LOG_TYPE_PICKDROP_PLAYER)) != 0) { diff --git a/src/map/npc.c b/src/map/npc.c index 6bb058229..8a2c0f746 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -1710,7 +1710,7 @@ int npc_selllist(struct map_session_data* sd, int n, unsigned short* item_list) if( sd->inventory_data[idx]->type == IT_PETEGG && sd->status.inventory[idx].card[0] == CARD0_PET ) { if( search_petDB_index(sd->status.inventory[idx].nameid, PET_EGG) >= 0 ) { - intif_delete_petdata(MakeDWord(sd->status.inventory[idx].card[1], sd->status.inventory[idx].card[2])); + intif->delete_petdata(MakeDWord(sd->status.inventory[idx].card[1], sd->status.inventory[idx].card[2])); } } @@ -3865,7 +3865,7 @@ int npc_reload(void) { ShowStatus("Event '"CL_WHITE"OnInit"CL_RESET"' executed with '"CL_WHITE"%d"CL_RESET"' NPCs.\n",npc_event_doall("OnInit")); // Execute rest of the startup events if connected to char-server. [Lance] - if(!CheckForCharServer()){ + if(!intif->CheckForCharServer()){ ShowStatus("Event '"CL_WHITE"OnInterIfInit"CL_RESET"' executed with '"CL_WHITE"%d"CL_RESET"' NPCs.\n", npc_event_doall("OnInterIfInit")); ShowStatus("Event '"CL_WHITE"OnInterIfInitOnce"CL_RESET"' executed with '"CL_WHITE"%d"CL_RESET"' NPCs.\n", npc_event_doall("OnInterIfInitOnce")); } diff --git a/src/map/party.c b/src/map/party.c index 30740b058..0d9859345 100644 --- a/src/map/party.c +++ b/src/map/party.c @@ -95,7 +95,7 @@ static TBL_PC* party_sd_check(int party_id, int account_id, int char_id) sd->status.party_id = party_id;// auto-join if not in a party if (sd->status.party_id != party_id) { //If player belongs to a different party, kick him out. - intif_party_leave(party_id,account_id,char_id); + intif->party_leave(party_id,account_id,char_id); return NULL; } @@ -174,7 +174,7 @@ int party_create(struct map_session_data *sd,char *name,int item,int item2) party_fill_member(&leader, sd, 1); - intif_create_party(&leader,name,item,item2); + intif->create_party(&leader,name,item,item2); return 0; } @@ -187,7 +187,7 @@ void party_created(int account_id,int char_id,int fail,int party_id,char *name) 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); + intif->party_leave(party_id,account_id,char_id); return; } @@ -205,7 +205,7 @@ void party_created(int account_id,int char_id,int fail,int party_id,char *name) int party_request_info(int party_id, int char_id) { - return intif_request_partyinfo(party_id, char_id); + return intif->request_partyinfo(party_id, char_id); } /// Invoked (from char-server) when the party info is not found. @@ -417,7 +417,7 @@ void party_reply_invite(struct map_session_data *sd,int party_id,int flag) {// accepted and allowed sd->party_joining = true; party_fill_member(&member, sd, 0); - intif_party_addmember(sd->party_invite, &member); + intif->party_addmember(sd->party_invite, &member); } else {// rejected or failure @@ -466,7 +466,7 @@ int party_member_added(int party_id,int account_id,int char_id, int flag) if(sd == NULL || sd->status.char_id != char_id || !sd->party_joining ) { if (!flag) //Char logged off before being accepted into party. - intif_party_leave(party_id,account_id,char_id); + intif->party_leave(party_id,account_id,char_id); return 0; } @@ -478,7 +478,7 @@ int party_member_added(int party_id,int account_id,int char_id, int flag) if (!p) { ShowError("party_member_added: party %d not found.\n",party_id); - intif_party_leave(party_id,account_id,char_id); + intif->party_leave(party_id,account_id,char_id); return 0; } @@ -540,7 +540,7 @@ int party_removemember(struct map_session_data* sd, int account_id, char* name) if( i == MAX_PARTY ) return 0; // no such char in party - intif_party_leave(p->party.party_id,account_id,p->party.member[i].char_id); + intif->party_leave(p->party.party_id,account_id,p->party.member[i].char_id); return 1; } @@ -558,7 +558,7 @@ int party_leave(struct map_session_data *sd) if( i == MAX_PARTY ) return 0; - intif_party_leave(p->party.party_id,sd->status.account_id,sd->status.char_id); + intif->party_leave(p->party.party_id,sd->status.account_id,sd->status.char_id); return 1; } @@ -630,7 +630,7 @@ int party_changeoption(struct map_session_data *sd,int exp,int item) if( sd->status.party_id==0) return 0; - intif_party_changeoption(sd->status.party_id,sd->status.account_id,exp,item); + intif->party_changeoption(sd->status.party_id,sd->status.account_id,exp,item); return 0; } @@ -698,7 +698,7 @@ bool party_changeleader(struct map_session_data *sd, struct map_session_data *ts clif->message(p->data[tmi].sd->fd, msg_txt(285)); //Update info. - intif_party_leaderchange(p->party.party_id,p->party.member[tmi].account_id,p->party.member[tmi].char_id); + intif->party_leaderchange(p->party.party_id,p->party.member[tmi].account_id,p->party.member[tmi].char_id); clif->party_info(p,NULL); return true; } @@ -742,7 +742,7 @@ void party_send_movemap(struct map_session_data *sd) if( sd->status.party_id==0 ) return; - intif_party_changemap(sd,1); + intif->party_changemap(sd,1); p=party->search(sd->status.party_id); if (!p) return; @@ -770,7 +770,7 @@ void party_send_movemap(struct map_session_data *sd) void party_send_levelup(struct map_session_data *sd) { - intif_party_changemap(sd,1); + intif->party_changemap(sd,1); } int party_send_logout(struct map_session_data *sd) @@ -781,7 +781,7 @@ int party_send_logout(struct map_session_data *sd) if(!sd->status.party_id) return 0; - intif_party_changemap(sd,0); + intif->party_changemap(sd,0); p=party->search(sd->status.party_id); if(!p) return 0; @@ -798,7 +798,7 @@ int party_send_message(struct map_session_data *sd,const char *mes,int len) { if(sd->status.party_id==0) return 0; - intif_party_message(sd->status.party_id,sd->status.account_id,mes,len); + intif->party_message(sd->status.party_id,sd->status.account_id,mes,len); party->recv_message(sd->status.party_id,sd->status.account_id,mes,len); // Chat logging type 'P' / Party Chat diff --git a/src/map/pc.c b/src/map/pc.c index 30ef9848c..e6c3721c3 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -1129,7 +1129,7 @@ bool pc_authok(struct map_session_data *sd, int login_id2, time_t expiration_tim sd->sc_display_count = 0; // Request all registries (auth is considered completed whence they arrive) - intif_request_registry(sd,7); + intif->request_registry(sd,7); return true; } @@ -1236,15 +1236,15 @@ int pc_reg_received(struct map_session_data *sd) // pet if (sd->status.pet_id > 0) - intif_request_petdata(sd->status.account_id, sd->status.char_id, sd->status.pet_id); + intif->request_petdata(sd->status.account_id, sd->status.char_id, sd->status.pet_id); // Homunculus [albator] if( sd->status.hom_id > 0 ) - intif_homunculus_requestload(sd->status.account_id, sd->status.hom_id); + intif->homunculus_requestload(sd->status.account_id, sd->status.hom_id); if( sd->status.mer_id > 0 ) - intif_mercenary_request(sd->status.mer_id, sd->status.char_id); + intif->mercenary_request(sd->status.mer_id, sd->status.char_id); if( sd->status.ele_id > 0 ) - intif_elemental_request(sd->status.ele_id, sd->status.char_id); + intif->elemental_request(sd->status.ele_id, sd->status.char_id); iMap->addiddb(&sd->bl); iMap->delnickdb(sd->status.char_id, sd->status.name); @@ -1256,8 +1256,8 @@ int pc_reg_received(struct map_session_data *sd) status_calc_pc(sd,1); chrif->scdata_request(sd->status.account_id, sd->status.char_id); - intif_Mail_requestinbox(sd->status.char_id, 0); // MAIL SYSTEM - Request Mail Inbox - intif_request_questlog(sd); + intif->Mail_requestinbox(sd->status.char_id, 0); // MAIL SYSTEM - Request Mail Inbox + intif->request_questlog(sd); if (sd->state.connect_new == 0 && sd->fd) { //Character already loaded map! Gotta trigger LoadEndAck manually. sd->state.connect_new = 1; @@ -4681,7 +4681,7 @@ int pc_steal_item(struct map_session_data *sd,struct block_list *bl, uint16 skil char message[128]; sprintf (message, msg_txt(542), (sd->status.name != NULL)?sd->status.name :"GM", md->db->jname, data->jname, (float)md->db->dropitem[i].p/100); //MSG: "'%s' stole %s's %s (chance: %0.02f%%)" - intif_broadcast(message,strlen(message)+1,0); + intif->broadcast(message,strlen(message)+1,0); } return 1; } @@ -7720,7 +7720,7 @@ int pc_changelook(struct map_session_data *sd,int type,int val) if (sd->status.hair != val) { sd->status.hair=val; if (sd->status.guild_id) //Update Guild Window. [Skotlex] - intif_guild_change_memberinfo(sd->status.guild_id,sd->status.account_id,sd->status.char_id, + intif->guild_change_memberinfo(sd->status.guild_id,sd->status.account_id,sd->status.char_id, GMI_HAIR,&sd->status.hair,sizeof(sd->status.hair)); } break; @@ -7742,7 +7742,7 @@ int pc_changelook(struct map_session_data *sd,int type,int val) if (sd->status.hair_color != val) { sd->status.hair_color=val; if (sd->status.guild_id) //Update Guild Window. [Skotlex] - intif_guild_change_memberinfo(sd->status.guild_id,sd->status.account_id,sd->status.char_id, + intif->guild_change_memberinfo(sd->status.guild_id,sd->status.account_id,sd->status.char_id, GMI_HAIR_COLOR,&sd->status.hair_color,sizeof(sd->status.hair_color)); } break; @@ -8094,7 +8094,7 @@ int pc_readregistry(struct map_session_data *sd,const char *reg,int type) if (max == -1) { ShowError("pc_readregistry: Trying to read reg value %s (type %d) before it's been loaded!\n", reg, type); //This really shouldn't happen, so it's possible the data was lost somewhere, we should request it again. - intif_request_registry(sd,type==3?4:type); + intif->request_registry(sd,type==3?4:type); return 0; } @@ -8127,7 +8127,7 @@ char* pc_readregistry_str(struct map_session_data *sd,const char *reg,int type) if (max == -1) { ShowError("pc_readregistry: Trying to read reg value %s (type %d) before it's been loaded!\n", reg, type); //This really shouldn't happen, so it's possible the data was lost somewhere, we should request it again. - intif_request_registry(sd,type==3?4:type); + intif->request_registry(sd,type==3?4:type); return NULL; } @@ -8272,7 +8272,7 @@ int pc_setregistry_str(struct map_session_data *sd,const char *reg,const char *v memset(&sd_reg[*max - 1], 0, sizeof(struct global_reg)); (*max)--; sd->state.reg_dirty |= 1<<(type-1); //Mark this registry as "need to be saved" - if (type!=3) intif_saveregistry(sd,type); + if (type!=3) intif->saveregistry(sd,type); } return 1; } @@ -8283,7 +8283,7 @@ int pc_setregistry_str(struct map_session_data *sd,const char *reg,const char *v { safestrncpy(sd_reg[i].value, val, sizeof(sd_reg[i].value)); sd->state.reg_dirty |= 1<<(type-1); //Mark this registry as "need to be saved" - if (type!=3) intif_saveregistry(sd,type); + if (type!=3) intif->saveregistry(sd,type); return 1; } @@ -8294,7 +8294,7 @@ int pc_setregistry_str(struct map_session_data *sd,const char *reg,const char *v safestrncpy(sd_reg[i].value, val, sizeof(sd_reg[i].value)); (*max)++; sd->state.reg_dirty |= 1<<(type-1); //Mark this registry as "need to be saved" - if (type!=3) intif_saveregistry(sd,type); + if (type!=3) intif->saveregistry(sd,type); return 1; } @@ -9356,7 +9356,7 @@ int map_day_timer(int tid, unsigned int tick, int id, intptr_t data) iMap->night_flag = 0; // 0=day, 1=night [Yor] iMap->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, 0); + intif->broadcast(tmp_soutput, strlen(tmp_soutput) + 1, 0); return 0; } @@ -9377,7 +9377,7 @@ int map_night_timer(int tid, unsigned int tick, int id, intptr_t data) iMap->night_flag = 1; // 0=day, 1=night [Yor] iMap->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, 0); + intif->broadcast(tmp_soutput, strlen(tmp_soutput) + 1, 0); return 0; } diff --git a/src/map/pet.c b/src/map/pet.c index c83027f2a..236ffe98b 100644 --- a/src/map/pet.c +++ b/src/map/pet.c @@ -78,7 +78,7 @@ int pet_create_egg(struct map_session_data *sd, int item_id) if (pet_id < 0) return 0; //No pet egg here. if (!pc->inventoryblank(sd)) return 0; // Inventory full sd->catch_target_class = pet_db[pet_id].class_; - intif_create_pet(sd->status.account_id, sd->status.char_id, + intif->create_pet(sd->status.account_id, sd->status.char_id, (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv, (short)pet_db[pet_id].EggID, 0, @@ -334,7 +334,7 @@ int pet_data_init(struct map_session_data *sd, struct s_pet *pet) if (sd->status.pet_id) { //Wrong pet?? Set incuvate to no and send it back for saving. pet->incuvate = 1; - intif_save_petdata(sd->status.account_id,pet); + intif->save_petdata(sd->status.account_id,pet); sd->status.pet_id = 0; return 1; } @@ -406,7 +406,7 @@ int pet_birth_process(struct map_session_data *sd, struct s_pet *pet) return 1; } - intif_save_petdata(sd->status.account_id,pet); + intif->save_petdata(sd->status.account_id,pet); if (iMap->save_settings&8) chrif->save(sd,0); //is it REALLY Needed to save the char for hatching a pet? [Skotlex] @@ -472,7 +472,7 @@ int pet_select_egg(struct map_session_data *sd,short egg_index) return 0; //Forged packet! if(sd->status.inventory[egg_index].card[0] == CARD0_PET) - intif_request_petdata(sd->status.account_id, sd->status.char_id, MakeDWord(sd->status.inventory[egg_index].card[1], sd->status.inventory[egg_index].card[2]) ); + intif->request_petdata(sd->status.account_id, sd->status.char_id, MakeDWord(sd->status.inventory[egg_index].card[1], sd->status.inventory[egg_index].card[2]) ); else ShowError("wrong egg item inventory %d\n",egg_index); @@ -529,7 +529,7 @@ int pet_catch_process2(struct map_session_data* sd, int target_id) unit_remove_map(&md->bl,CLR_OUTSIGHT); status_kill(&md->bl); clif->pet_roulette(sd,1); - intif_create_pet(sd->status.account_id,sd->status.char_id,pet_db[i].class_,mob_db(pet_db[i].class_)->lv, + intif->create_pet(sd->status.account_id,sd->status.char_id,pet_db[i].class_,mob_db(pet_db[i].class_)->lv, pet_db[i].EggID,0,pet_db[i].intimate,100,0,1,pet_db[i].jname); } else @@ -558,7 +558,7 @@ int pet_get_egg(int account_id,int pet_id,int flag) sd->catch_target_class = -1; if(i < 0) { - intif_delete_petdata(pet_id); + intif->delete_petdata(pet_id); return 0; } diff --git a/src/map/quest.c b/src/map/quest.c index 3776d603f..e1e180786 100644 --- a/src/map/quest.c +++ b/src/map/quest.c @@ -23,7 +23,6 @@ #include "log.h" #include "clif.h" #include "quest.h" -#include "intif.h" #include "chrif.h" #include diff --git a/src/map/script.c b/src/map/script.c index 0827eb497..5e99d2e62 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -3532,9 +3532,9 @@ void run_script_main(struct script_state *st) //Restore previous script if any. script_detach_state(st, true); if (sd->state.reg_dirty&2) - intif_saveregistry(sd,2); + intif->saveregistry(sd,2); if (sd->state.reg_dirty&1) - intif_saveregistry(sd,1); + intif->saveregistry(sd,1); } script->free_state(st); st = NULL; @@ -6252,7 +6252,7 @@ static void buildin_delitem_delete(struct map_session_data* sd, int idx, int* am { if( sd->inventory_data[idx]->type == IT_PETEGG && inv->card[0] == CARD0_PET ) {// delete associated pet - intif_delete_petdata(MakeDWord(inv->card[1], inv->card[2])); + intif->delete_petdata(MakeDWord(inv->card[1], inv->card[2])); } pc->delitem(sd, idx, delamount, 0, 0, LOG_TYPE_SCRIPT); } @@ -6316,7 +6316,7 @@ static bool buildin_delitem_search(struct map_session_data* sd, struct item* it, { if( sd->inventory_data[i]->type == IT_PETEGG ) { - if( inv->card[0] == CARD0_PET && CheckForCharServer() ) + if( inv->card[0] == CARD0_PET && intif->CheckForCharServer() ) {// pet which cannot be deleted continue; } @@ -6346,7 +6346,7 @@ static bool buildin_delitem_search(struct map_session_data* sd, struct item* it, continue; } - if( sd->inventory_data[i]->type == IT_PETEGG && inv->card[0] == CARD0_PET && CheckForCharServer() ) + if( sd->inventory_data[i]->type == IT_PETEGG && inv->card[0] == CARD0_PET && intif->CheckForCharServer() ) {// pet which cannot be deleted continue; } @@ -8311,7 +8311,7 @@ BUILDIN(makepet) pet_id = search_petDB_index(id, PET_EGG); if (pet_id >= 0 && sd) { sd->catch_target_class = pet_db[pet_id].class_; - intif_create_pet( + intif->create_pet( sd->status.account_id, sd->status.char_id, (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv, (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate, @@ -9124,9 +9124,9 @@ BUILDIN(announce) else { if (fontColor) - intif_broadcast2(mes, (int)strlen(mes)+1, strtol(fontColor, (char **)NULL, 0), fontType, fontSize, fontAlign, fontY); + intif->broadcast2(mes, (int)strlen(mes)+1, strtol(fontColor, (char **)NULL, 0), fontType, fontSize, fontAlign, fontY); else - intif_broadcast(mes, (int)strlen(mes)+1, flag&0xf0); + intif->broadcast(mes, (int)strlen(mes)+1, flag&0xf0); } return true; } diff --git a/src/map/storage.c b/src/map/storage.c index 5ebbb0dde..81d746cc8 100644 --- a/src/map/storage.c +++ b/src/map/storage.c @@ -400,7 +400,7 @@ int storage_guild_storageopen(struct map_session_data* sd) } if((gstor = gstorage->id2storage2(sd->status.guild_id)) == NULL) { - intif_request_guild_storage(sd->status.account_id,sd->status.guild_id); + intif->request_guild_storage(sd->status.account_id,sd->status.guild_id); return 0; } if(gstor->storage_status) @@ -657,7 +657,7 @@ int storage_guild_storagesave(int account_id, int guild_id, int flag) if (flag) //Char quitting, close it. stor->storage_status = 0; if (stor->dirty) - intif_send_guild_storage(account_id,stor); + intif->send_guild_storage(account_id,stor); return 1; } return 0; diff --git a/src/map/trade.c b/src/map/trade.c index 13b5f5431..9bf63c428 100644 --- a/src/map/trade.c +++ b/src/map/trade.c @@ -203,9 +203,9 @@ int impossible_trade_check(struct map_session_data *sd) 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(iMap->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(iMap->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 +222,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(iMap->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 diff --git a/src/map/unit.c b/src/map/unit.c index 8a11363cb..b9cdfa278 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -2443,10 +2443,10 @@ int unit_free(struct block_list *bl, clr_type clrtype) pd->loot = NULL; } if( pd->pet.intimate > 0 ) - intif_save_petdata(pd->pet.account_id,&pd->pet); + intif->save_petdata(pd->pet.account_id,&pd->pet); else { //Remove pet. - intif_delete_petdata(pd->pet.pet_id); + intif->delete_petdata(pd->pet.pet_id); if (sd) sd->status.pet_id = 0; } if( sd ) @@ -2519,7 +2519,7 @@ int unit_free(struct block_list *bl, clr_type clrtype) if( hd->homunculus.intimacy > 0 ) homun->save(hd); else { - intif_homunculus_requestdelete(hd->homunculus.hom_id); + intif->homunculus_requestdelete(hd->homunculus.hom_id); if( sd ) sd->status.hom_id = 0; } @@ -2535,7 +2535,7 @@ int unit_free(struct block_list *bl, clr_type clrtype) mercenary_save(md); else { - intif_mercenary_delete(md->mercenary.mercenary_id); + intif->mercenary_delete(md->mercenary.mercenary_id); if( sd ) sd->status.mer_id = 0; } @@ -2551,7 +2551,7 @@ int unit_free(struct block_list *bl, clr_type clrtype) if( elemental->get_lifetime(ed) > 0 ) elemental->save(ed); else { - intif_elemental_delete(ed->elemental.elemental_id); + intif->elemental_delete(ed->elemental.elemental_id); if( sd ) sd->status.ele_id = 0; } -- cgit v1.2.3-70-g09d2 From 4eb223b62e70a293dd2c95f1ce8b29a3f0c83ef7 Mon Sep 17 00:00:00 2001 From: shennetsind Date: Mon, 16 Sep 2013 07:08:32 -0300 Subject: HPM: Unit.c Interface Fully Interfaced Signed-off-by: shennetsind --- src/map/atcommand.c | 8 +- src/map/battle.c | 24 +- src/map/clif.c | 48 +- src/map/elemental.c | 1969 +++++++++++++++++++++++++------------------------- src/map/elemental.h | 206 +++--- src/map/guild.c | 2 +- src/map/homunculus.c | 16 +- src/map/instance.c | 2 +- src/map/map.c | 20 +- src/map/mercenary.c | 8 +- src/map/mob.c | 68 +- src/map/mob.h | 4 +- src/map/npc.c | 6 +- src/map/pc.c | 14 +- src/map/pc.h | 4 +- src/map/pet.c | 34 +- src/map/pet.h | 4 +- src/map/script.c | 44 +- src/map/skill.c | 206 +++--- src/map/status.c | 80 +- src/map/unit.c | 356 +++++---- src/map/unit.h | 124 ++-- 22 files changed, 1638 insertions(+), 1609 deletions(-) (limited to 'src/map/elemental.c') diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 6b62f6325..6c44f8919 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -1453,11 +1453,11 @@ ACMD(help) { // parameter: '0' - everyone, 'id' - only those attacking someone with that id static int atcommand_stopattack(struct block_list *bl,va_list ap) { - struct unit_data *ud = unit_bl2ud(bl); + struct unit_data *ud = unit->bl2ud(bl); int id = va_arg(ap, int); if (ud && ud->attacktimer != INVALID_TIMER && (!id || id == ud->target)) { - unit_stop_attack(bl); + unit->stop_attack(bl); return 1; } return 0; @@ -5429,9 +5429,9 @@ ACMD(useskill) bl = &sd->bl; if (skill->get_inf(skill_id)&INF_GROUND_SKILL) - unit_skilluse_pos(bl, pl_sd->bl.x, pl_sd->bl.y, skill_id, skill_lv); + unit->skilluse_pos(bl, pl_sd->bl.x, pl_sd->bl.y, skill_id, skill_lv); else - unit_skilluse_id(bl, pl_sd->bl.id, skill_id, skill_lv); + unit->skilluse_id(bl, pl_sd->bl.id, skill_id, skill_lv); return true; } diff --git a/src/map/battle.c b/src/map/battle.c index 120b23368..bc963a7f4 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -50,7 +50,7 @@ int battle_getcurrentskill(struct block_list *bl) { //Returns the current/last s return su->group?su->group->skill_id:0; } - ud = unit_bl2ud(bl); + ud = unit->bl2ud(bl); return ud?ud->skill_id:0; } @@ -74,7 +74,7 @@ int battle_gettargeted_sub(struct block_list *bl, va_list ap) { if (*c >= 24) return 0; - if ( !(ud = unit_bl2ud(bl)) ) + if ( !(ud = unit->bl2ud(bl)) ) return 0; if (ud->target == target_id || ud->skilltarget == target_id) { @@ -1250,7 +1250,7 @@ int64 battle_calc_defense(int attack_type, struct block_list *src, struct block_ if( battle_config.vit_penalty_type && battle_config.vit_penalty_target&target->type ) { unsigned char target_count; //256 max targets should be a sane max - target_count = unit_counttargeted(target); + target_count = unit->counttargeted(target); if(target_count >= battle_config.vit_penalty_count) { if(battle_config.vit_penalty_type == 1) { if( !tsc || !tsc->data[SC_STEELBODY] ) @@ -2664,7 +2664,7 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam delay = 200; else delay = 100; - unit_set_walkdelay(bl, iTimer->gettick(), delay, 1); + unit->set_walkdelay(bl, iTimer->gettick(), delay, 1); if(sc->data[SC_CR_SHRINK] && rnd()%100<5*sce->val1) skill->blown(bl,src,skill->get_blewcount(CR_SHRINK,1),-1,0); @@ -2931,9 +2931,9 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam 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); - if( unit_movepos(bl, src->x-dx[dir], src->y-dy[dir], 1, 1) ) { + 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); + unit->setdir(bl, dir); } d->dmg_lv = ATK_DEF; status_change_end(bl, SC_LIGHTNINGWALK, INVALID_TIMER); @@ -3837,7 +3837,7 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list * if(battle_config.agi_penalty_type && battle_config.agi_penalty_target&target->type) { unsigned char attacker_count; //256 max targets should be a sane max - attacker_count = unit_counttargeted(target); + attacker_count = unit->counttargeted(target); if(attacker_count >= battle_config.agi_penalty_count) { if (battle_config.agi_penalty_type == 1) @@ -4303,7 +4303,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list if(battle_config.agi_penalty_type && battle_config.agi_penalty_target&target->type) { unsigned char attacker_count; //256 max targets should be a sane max - attacker_count = unit_counttargeted(target); + attacker_count = unit->counttargeted(target); if(attacker_count >= battle_config.agi_penalty_count) { if (battle_config.agi_penalty_type == 1) flee = (flee * (100 - (attacker_count - (battle_config.agi_penalty_count - 1))*battle_config.agi_penalty_num))/100; @@ -5199,7 +5199,7 @@ int64 battle_calc_return_damage(struct block_list* bl, struct block_list *src, i int ratio = (status_get_hp(src) / 100) * sc->data[SC_CRESCENTELBOW]->val1 * iStatus->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); + skill->blown(bl, src, skill->get_blewcount(SR_CRESCENTELBOW_AUTOSPELL, sc->data[SC_CRESCENTELBOW]->val1), unit->getdir(src), 0); clif->skill_damage(bl, src, iTimer->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, iTimer->gettick(), status_get_amotion(src)+1000, 0, rdamage/10, 1, 0, 0); @@ -5226,13 +5226,13 @@ 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), - t_dir = unit_getdir(bl); + t_dir = unit->getdir(bl); if( !iMap->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, iTimer->gettick(), status_get_amotion(src), 0, -3000, 1, RK_DEATHBOUND, sc->data[SC_DEATHBOUND]->val1, 6); - skill->blown(bl, src, skill->get_blewcount(RK_DEATHBOUND, sc->data[SC_DEATHBOUND]->val1), unit_getdir(src), 0); + skill->blown(bl, src, skill->get_blewcount(RK_DEATHBOUND, sc->data[SC_DEATHBOUND]->val1), unit->getdir(src), 0); if( skill_id ) status_change_end(bl, SC_DEATHBOUND, INVALID_TIMER); *delay = clif->damage(src, src, iTimer->gettick(), status_get_amotion(src), status_get_dmotion(src), rdamage, 1, 4, 0); @@ -5417,7 +5417,7 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t if( tsc && tsc->data[SC_AUTOCOUNTER] && iStatus->check_skilluse(target, src, KN_AUTOCOUNTER, 1) ) { uint8 dir = iMap->calc_dir(target,src->x,src->y); - int t_dir = unit_getdir(target); + 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)) { diff --git a/src/map/clif.c b/src/map/clif.c index 8c7790a8f..f8f88c691 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -902,7 +902,7 @@ void clif_set_unit_idle2(struct block_list* bl, struct map_session_data *tsd, en p.virtue = (sc) ? sc->opt3 : 0; p.isPKModeON = (sd) ? sd->status.karma : 0; p.sex = vd->sex; - WBUFPOS(&p.PosDir[0],0,bl->x,bl->y,unit_getdir(bl)); + WBUFPOS(&p.PosDir[0],0,bl->x,bl->y,unit->getdir(bl)); p.xSize = p.ySize = (sd) ? 5 : 0; p.state = vd->dead_sit; p.clevel = clif_setlevel(bl); @@ -965,7 +965,7 @@ void clif_set_unit_idle(struct block_list* bl, struct map_session_data *tsd, enu p.virtue = (sc) ? sc->opt3 : 0; p.isPKModeON = (sd) ? sd->status.karma : 0; p.sex = vd->sex; - WBUFPOS(&p.PosDir[0],0,bl->x,bl->y,unit_getdir(bl)); + WBUFPOS(&p.PosDir[0],0,bl->x,bl->y,unit->getdir(bl)); p.xSize = p.ySize = (sd) ? 5 : 0; p.state = vd->dead_sit; p.clevel = clif_setlevel(bl); @@ -1034,7 +1034,7 @@ void clif_spawn_unit2(struct block_list* bl, enum send_target target) { p.headDir = (sd)? sd->head_dir : 0; p.isPKModeON = (sd) ? sd->status.karma : 0; p.sex = vd->sex; - WBUFPOS(&p.PosDir[0],0,bl->x,bl->y,unit_getdir(bl)); + WBUFPOS(&p.PosDir[0],0,bl->x,bl->y,unit->getdir(bl)); p.xSize = p.ySize = (sd) ? 5 : 0; clif->send(&p,sizeof(p),bl,target); @@ -1092,7 +1092,7 @@ void clif_spawn_unit(struct block_list* bl, enum send_target target) { p.virtue = (sc) ? sc->opt3 : 0; p.isPKModeON = (sd) ? sd->status.karma : 0; p.sex = vd->sex; - WBUFPOS(&p.PosDir[0],0,bl->x,bl->y,unit_getdir(bl)); + WBUFPOS(&p.PosDir[0],0,bl->x,bl->y,unit->getdir(bl)); p.xSize = p.ySize = (sd) ? 5 : 0; p.clevel = clif_setlevel(bl); #if PACKETVER >= 20080102 @@ -4328,7 +4328,7 @@ void clif_getareachar_unit(struct map_session_data* sd,struct block_list *bl) { if(bl->type == BL_NPC && !((TBL_NPC*)bl)->chat_id && (((TBL_NPC*)bl)->option&OPTION_INVISIBLE)) return; - if ( ( ud = unit_bl2ud(bl) ) && ud->walktimer != INVALID_TIMER ) + if ( ( ud = unit->bl2ud(bl) ) && ud->walktimer != INVALID_TIMER ) clif->set_unit_walking(bl,sd,ud,SELF); else clif->set_unit_idle(bl,sd,SELF); @@ -4512,7 +4512,7 @@ int clif_damage(struct block_list* src, struct block_list* dst, unsigned int tic } if(src == dst) { - unit_setdir(src,unit_getdir(src)); + unit->setdir(src,unit->getdir(src)); } //Return adjusted can't walk delay for further processing. return clif->calc_walkdelay(dst,ddelay,type,damage+damage2,div); @@ -9784,7 +9784,7 @@ void clif_parse_WalkToXY(int fd, struct map_session_data *sd) //Set last idle time... [Skotlex] sd->idletime = last_tick; - unit_walktoxy(&sd->bl, x, y, 4); + unit->walktoxy(&sd->bl, x, y, 4); } @@ -9945,7 +9945,7 @@ void clif_parse_GlobalMessage(int fd, struct map_session_data* sd) pc->disguise(sd,sd->status.class_); if( pc_isdead(sd) ) clif_clearunit_single(-sd->bl.id, CLR_DEAD, sd->fd); - if( unit_is_walking(&sd->bl) ) + if( unit->is_walking(&sd->bl) ) clif->move(&sd->ud); } else if ( sd->disguise == sd->status.class_ && sd->fontcolor_tid != INVALID_TIMER ) { const struct TimerData *timer; @@ -10045,7 +10045,7 @@ void clif_changed_dir(struct block_list *bl, enum send_target target) WBUFW(buf,0) = 0x9c; WBUFL(buf,2) = bl->id; WBUFW(buf,6) = bl->type==BL_PC?((TBL_PC*)bl)->head_dir:0; - WBUFB(buf,8) = unit_getdir(bl); + WBUFB(buf,8) = unit->getdir(bl); clif->send(buf, packet_len(0x9c), bl, target); @@ -10169,7 +10169,7 @@ void clif_parse_ActionRequest_sub(struct map_session_data *sd, int action_type, pc->delinvincibletimer(sd); sd->idletime = last_tick; - unit_attack(&sd->bl, target_id, action_type != 0); + unit->attack(&sd->bl, target_id, action_type != 0); break; case 0x02: // sitdown if (battle_config.basic_skill_check && pc->checkskill(sd, NV_BASIC) < 3) { @@ -11248,7 +11248,7 @@ void clif_parse_UseSkillToId_homun(struct homun_data *hd, struct map_session_dat if( skill_lv > lv ) skill_lv = lv; if( skill_lv ) - unit_skilluse_id(&hd->bl, target_id, skill_id, skill_lv); + unit->skilluse_id(&hd->bl, target_id, skill_id, skill_lv); } void clif_parse_UseSkillToPos_homun(struct homun_data *hd, struct map_session_data *sd, unsigned int tick, uint16 skill_id, uint16 skill_lv, short x, short y, int skillmoreinfo) @@ -11269,7 +11269,7 @@ void clif_parse_UseSkillToPos_homun(struct homun_data *hd, struct map_session_da if( skill_lv > lv ) skill_lv = lv; if( skill_lv ) - unit_skilluse_pos(&hd->bl, x, y, skill_id, skill_lv); + unit->skilluse_pos(&hd->bl, x, y, skill_id, skill_lv); } void clif_parse_UseSkillToId_mercenary(struct mercenary_data *md, struct map_session_data *sd, unsigned int tick, uint16 skill_id, uint16 skill_lv, int target_id) @@ -11291,7 +11291,7 @@ void clif_parse_UseSkillToId_mercenary(struct mercenary_data *md, struct map_ses if( skill_lv > lv ) skill_lv = lv; if( skill_lv ) - unit_skilluse_id(&md->bl, target_id, skill_id, skill_lv); + unit->skilluse_id(&md->bl, target_id, skill_id, skill_lv); } void clif_parse_UseSkillToPos_mercenary(struct mercenary_data *md, struct map_session_data *sd, unsigned int tick, uint16 skill_id, uint16 skill_lv, short x, short y, int skillmoreinfo) @@ -11314,7 +11314,7 @@ void clif_parse_UseSkillToPos_mercenary(struct mercenary_data *md, struct map_se if( skill_lv > lv ) skill_lv = lv; if( skill_lv ) - unit_skilluse_pos(&md->bl, x, y, skill_id, skill_lv); + unit->skilluse_pos(&md->bl, x, y, skill_id, skill_lv); } @@ -11398,7 +11398,7 @@ void clif_parse_UseSkillToId(int fd, struct map_session_data *sd) skill_lv = sd->skillitemlv; if( !(tmp&INF_SELF_SKILL) ) pc->delinvincibletimer(sd); // Target skills thru items cancel invincibility. [Inkfish] - unit_skilluse_id(&sd->bl, target_id, skill_id, skill_lv); + unit->skilluse_id(&sd->bl, target_id, skill_id, skill_lv); return; } @@ -11418,7 +11418,7 @@ void clif_parse_UseSkillToId(int fd, struct map_session_data *sd) pc->delinvincibletimer(sd); if( skill_lv ) - unit_skilluse_id(&sd->bl, target_id, skill_id, skill_lv); + unit->skilluse_id(&sd->bl, target_id, skill_id, skill_lv); } /*========================================== @@ -11490,14 +11490,14 @@ void clif_parse_UseSkillToPosSub(int fd, struct map_session_data *sd, uint16 ski if( sd->skillitem == skill_id ) { if( skill_lv != sd->skillitemlv ) skill_lv = sd->skillitemlv; - unit_skilluse_pos(&sd->bl, x, y, skill_id, skill_lv); + unit->skilluse_pos(&sd->bl, x, y, skill_id, skill_lv); } else { int lv; sd->skillitem = sd->skillitemlv = 0; if( (lv = pc->checkskill(sd, skill_id)) > 0 ) { if( skill_lv > lv ) skill_lv = lv; - unit_skilluse_pos(&sd->bl, x, y, skill_id,skill_lv); + unit->skilluse_pos(&sd->bl, x, y, skill_id,skill_lv); } } } @@ -14282,9 +14282,9 @@ void clif_parse_HomMoveToMaster(int fd, struct map_session_data *sd) else return; - unit_calc_pos(bl, sd->bl.x, sd->bl.y, sd->ud.dir); - ud = unit_bl2ud(bl); - unit_walktoxy(bl, ud->to_x, ud->to_y, 4); + unit->calc_pos(bl, sd->bl.x, sd->bl.y, sd->ud.dir); + ud = unit->bl2ud(bl); + unit->walktoxy(bl, ud->to_x, ud->to_y, 4); } @@ -14305,7 +14305,7 @@ void clif_parse_HomMoveTo(int fd, struct map_session_data *sd) else return; - unit_walktoxy(bl, x, y, 4); + unit->walktoxy(bl, x, y, 4); } @@ -14326,8 +14326,8 @@ void clif_parse_HomAttack(int fd,struct map_session_data *sd) bl = &sd->md->bl; else return; - unit_stop_attack(bl); - unit_attack(bl, target_id, action_type != 0); + unit->stop_attack(bl); + unit->attack(bl, target_id, action_type != 0); } diff --git a/src/map/elemental.c b/src/map/elemental.c index 03aa93e49..1ef85b3e5 100644 --- a/src/map/elemental.c +++ b/src/map/elemental.c @@ -1,984 +1,985 @@ -// 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" -#include "../common/socket.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/mmo.h" -#include "../common/showmsg.h" -#include "../common/utils.h" -#include "../common/random.h" -#include "../common/strlib.h" - -#include "log.h" -#include "clif.h" -#include "chrif.h" -#include "intif.h" -#include "itemdb.h" -#include "map.h" -#include "pc.h" -#include "status.h" -#include "skill.h" -#include "mob.h" -#include "pet.h" -#include "battle.h" -#include "party.h" -#include "guild.h" -#include "atcommand.h" -#include "script.h" -#include "npc.h" -#include "trade.h" -#include "unit.h" -#include "elemental.h" - -#include -#include -#include -#include - -int elemental_search_index(int class_) { - int i; - ARR_FIND(0, MAX_ELEMENTAL_CLASS, i, elemental->elemental_db[i].class_ == class_); - return (i == MAX_ELEMENTAL_CLASS)?-1:i; -} - -bool elemental_class(int class_) { - return (bool)(elemental_search_index(class_) > -1); -} - -struct view_data * elemental_get_viewdata(int class_) { - int i = elemental_search_index(class_); - if( i < 0 ) - return 0; - - return &elemental->elemental_db[i].vd; -} - -int elemental_create(struct map_session_data *sd, int class_, unsigned int lifetime) { - struct s_elemental ele; - struct s_elemental_db *db; - int i; - - nullpo_retr(1,sd); - - if( (i = elemental_search_index(class_)) < 0 ) - return 0; - - db = &elemental->elemental_db[i]; - memset(&ele,0,sizeof(struct s_elemental)); - - ele.char_id = sd->status.char_id; - ele.class_ = class_; - 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] - 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 - ele.sp = ele.max_sp = sd->battle_status.max_sp/4; - //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) ] - ele.atk2 = sd->battle_status.max_sp / 18; - //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)] - ele.matk = i * (sd->battle_status.int_ / 2 + sd->battle_status.dex / 4); - //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) - ele.def = sd->battle_status.def + sd->status.base_level / (5-i); - //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) - ele.flee = sd->status.base_level / (5-i); - //Caster�s HIT + (Caster�s Base Level ) - ele.hit = sd->battle_status.hit + sd->status.base_level; - - //per individual bonuses - switch(db->class_){ - case 2114: case 2115: - case 2116: //ATK + (Summon Agni Skill Level x 20) / HIT + (Summon Agni Skill Level x 10) - ele.atk += i * 20; - ele.atk2 += i * 20; - ele.hit += i * 10; - break; - case 2117: case 2118: - case 2119: //MDEF + (Summon Aqua Skill Level x 10) / MATK + (Summon Aqua Skill Level x 20) - ele.mdef += i * 10; - ele.matk += i * 20; - break; - case 2120: case 2121: - case 2122: //FLEE + (Summon Ventus Skill Level x 20) / MATK + (Summon Ventus Skill Level x 10) - ele.flee += i * 20; - ele.matk += i * 10; - break; - case 2123: case 2124: - case 2125: //DEF + (Summon Tera Skill Level x 25) / ATK + (Summon Tera Skill Level x 5) - ele.def += i * 25; - ele.atk += i * 5; - ele.atk2 += i * 5; - break; - } - - if( (i=pc->checkskill(sd,SO_EL_SYMPATHY)) > 0 ){ - ele.hp = ele.max_hp = ele.max_hp * 5 * i / 100; - ele.sp = ele.max_sp = ele.max_sp * 5 * i / 100; - ele.atk += 25 * i; - ele.atk2 += 25 * i; - ele.matk += 25 * i; - } - - ele.life_time = lifetime; - - // Request Char Server to create this elemental - intif->elemental_create(&ele); - - return 1; -} - -int elemental_get_lifetime(struct elemental_data *ed) { - const struct TimerData * td; - if( ed == NULL || ed->summon_timer == INVALID_TIMER ) - return 0; - - td = iTimer->get_timer(ed->summon_timer); - return (td != NULL) ? DIFF_TICK(td->tick, iTimer->gettick()) : 0; -} - -int elemental_save(struct elemental_data *ed) { - ed->elemental.mode = ed->battle_status.mode; - ed->elemental.hp = ed->battle_status.hp; - ed->elemental.sp = ed->battle_status.sp; - ed->elemental.max_hp = ed->battle_status.max_hp; - ed->elemental.max_sp = ed->battle_status.max_sp; - ed->elemental.atk = ed->battle_status.rhw.atk; - ed->elemental.atk2 = ed->battle_status.rhw.atk2; - ed->elemental.matk = ed->battle_status.matk_min; - ed->elemental.def = ed->battle_status.def; - ed->elemental.mdef = ed->battle_status.mdef; - ed->elemental.flee = ed->battle_status.flee; - ed->elemental.hit = ed->battle_status.hit; - ed->elemental.life_time = elemental->get_lifetime(ed); - intif->elemental_save(&ed->elemental); - return 1; -} - -static int elemental_summon_end(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 ) - 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); - return 0; - } - - ed->summon_timer = INVALID_TIMER; - elemental->delete(ed, 0); // Elemental's summon time is over. - - return 0; -} - -void elemental_summon_stop(struct elemental_data *ed) { - nullpo_retv(ed); - if( ed->summon_timer != INVALID_TIMER ) - iTimer->delete_timer(ed->summon_timer, elemental_summon_end); - ed->summon_timer = INVALID_TIMER; -} - -int elemental_delete(struct elemental_data *ed, int reply) { - struct map_session_data *sd; - nullpo_ret(ed); - - sd = ed->master; - ed->elemental.life_time = 0; - - elemental->clean_effect(ed); - elemental->summon_stop(ed); - - if( !sd ) - return unit_free(&ed->bl, 0); - - sd->ed = NULL; - sd->status.ele_id = 0; - - return unit_remove_map(&ed->bl, 0); -} - -void elemental_summon_init(struct elemental_data *ed) { - if( ed->summon_timer == INVALID_TIMER ) - ed->summon_timer = iTimer->add_timer(iTimer->gettick() + ed->elemental.life_time, elemental_summon_end, ed->master->bl.id, 0); - - ed->regen.state.block = 0; -} - -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_); - - if( (sd = iMap->charid2sd(ele->char_id)) == NULL ) - return 0; - - if( !flag || i < 0 ) { // Not created - loaded - DB info - sd->status.ele_id = 0; - return 0; - } - - db = &elemental->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; - ed->bl.id = npc_get_new_npc_id(); - ed->master = sd; - ed->db = db; - memcpy(&ed->elemental, ele, sizeof(struct s_elemental)); - iStatus->set_viewdata(&ed->bl, ed->elemental.class_); - ed->vd->head_mid = 10; // Why? - iStatus->change_init(&ed->bl); - unit_dataset(&ed->bl); - ed->ud.dir = sd->ud.dir; - - ed->bl.m = sd->bl.m; - ed->bl.x = sd->bl.x; - ed->bl.y = sd->bl.y; - unit_calc_pos(&ed->bl, sd->bl.x, sd->bl.y, sd->ud.dir); - ed->bl.x = ed->ud.to_x; - ed->bl.y = ed->ud.to_y; - - iMap->addiddb(&ed->bl); - status_calc_elemental(ed,1); - ed->last_spdrain_time = ed->last_thinktime = iTimer->gettick(); - ed->summon_timer = INVALID_TIMER; - elemental_summon_init(ed); - } else { - memcpy(&sd->ed->elemental, ele, sizeof(struct s_elemental)); - ed = sd->ed; - } - - sd->status.ele_id = ele->elemental_id; - - if( ed->bl.prev == NULL && sd->bl.prev != NULL ) { - iMap->addblock(&ed->bl); - clif->spawn(&ed->bl); - clif->elemental_info(sd); - clif->elemental_updatestatus(sd,SP_HP); - clif->hpmeter_single(sd->fd,ed->bl.id,ed->battle_status.hp,ed->battle_status.max_hp); - clif->elemental_updatestatus(sd,SP_SP); - } - - return 1; -} - -int elemental_clean_single_effect(struct elemental_data *ed, uint16 skill_id) { - struct block_list *bl; - sc_type type = iStatus->skill2sc(skill_id); - - nullpo_ret(ed); - - bl = battle->get_master(&ed->bl); - - if( type ) { - switch( type ) { - // Just remove status change. - case SC_PYROTECHNIC_OPTION: - case SC_HEATER_OPTION: - case SC_TROPIC_OPTION: - case SC_FIRE_CLOAK_OPTION: - case SC_AQUAPLAY_OPTION: - case SC_WATER_SCREEN_OPTION: - case SC_COOLER_OPTION: - case SC_CHILLY_AIR_OPTION: - case SC_GUST_OPTION: - case SC_WIND_STEP_OPTION: - case SC_BLAST_OPTION: - case SC_WATER_DROP_OPTION: - case SC_WIND_CURTAIN_OPTION: - case SC_WILD_STORM_OPTION: - case SC_PETROLOGY_OPTION: - case SC_SOLID_SKIN_OPTION: - case SC_CURSED_SOIL_OPTION: - case SC_STONE_SHIELD_OPTION: - case SC_UPHEAVAL_OPTION: - case SC_CIRCLE_OF_FIRE_OPTION: - case SC_TIDAL_WEAPON_OPTION: - if( bl ) status_change_end(bl,type,INVALID_TIMER); // Master - status_change_end(&ed->bl,type-1,INVALID_TIMER); // Elemental Spirit - break; - case SC_ZEPHYR: - if( bl ) status_change_end(bl,type,INVALID_TIMER); - break; - default: - ShowWarning("Invalid SC=%d in elemental_clean_single_effect\n",type); - break; - } - } - - return 1; -} - -int elemental_clean_effect(struct elemental_data *ed) { - struct map_session_data *sd; - - nullpo_ret(ed); - - // Elemental side - status_change_end(&ed->bl, SC_TROPIC, INVALID_TIMER); - status_change_end(&ed->bl, SC_HEATER, INVALID_TIMER); - status_change_end(&ed->bl, SC_AQUAPLAY, INVALID_TIMER); - status_change_end(&ed->bl, SC_COOLER, INVALID_TIMER); - status_change_end(&ed->bl, SC_CHILLY_AIR, INVALID_TIMER); - status_change_end(&ed->bl, SC_PYROTECHNIC, INVALID_TIMER); - status_change_end(&ed->bl, SC_FIRE_CLOAK, INVALID_TIMER); - status_change_end(&ed->bl, SC_WATER_DROP, INVALID_TIMER); - status_change_end(&ed->bl, SC_WATER_SCREEN, INVALID_TIMER); - status_change_end(&ed->bl, SC_GUST, INVALID_TIMER); - status_change_end(&ed->bl, SC_WIND_STEP, INVALID_TIMER); - status_change_end(&ed->bl, SC_BLAST, INVALID_TIMER); - status_change_end(&ed->bl, SC_WIND_CURTAIN, INVALID_TIMER); - status_change_end(&ed->bl, SC_WILD_STORM, INVALID_TIMER); - status_change_end(&ed->bl, SC_PETROLOGY, INVALID_TIMER); - status_change_end(&ed->bl, SC_SOLID_SKIN, INVALID_TIMER); - status_change_end(&ed->bl, SC_CURSED_SOIL, INVALID_TIMER); - status_change_end(&ed->bl, SC_STONE_SHIELD, INVALID_TIMER); - status_change_end(&ed->bl, SC_UPHEAVAL, INVALID_TIMER); - status_change_end(&ed->bl, SC_CIRCLE_OF_FIRE, INVALID_TIMER); - status_change_end(&ed->bl, SC_TIDAL_WEAPON, INVALID_TIMER); - - if( (sd = ed->master) == NULL ) - return 0; - - // Master side - status_change_end(&sd->bl, SC_TROPIC_OPTION, INVALID_TIMER); - status_change_end(&sd->bl, SC_HEATER_OPTION, INVALID_TIMER); - status_change_end(&sd->bl, SC_AQUAPLAY_OPTION, INVALID_TIMER); - status_change_end(&sd->bl, SC_COOLER_OPTION, INVALID_TIMER); - status_change_end(&sd->bl, SC_CHILLY_AIR_OPTION, INVALID_TIMER); - status_change_end(&sd->bl, SC_PYROTECHNIC_OPTION, INVALID_TIMER); - status_change_end(&sd->bl, SC_FIRE_CLOAK_OPTION, INVALID_TIMER); - status_change_end(&sd->bl, SC_WATER_DROP_OPTION, INVALID_TIMER); - status_change_end(&sd->bl, SC_WATER_SCREEN_OPTION, INVALID_TIMER); - status_change_end(&sd->bl, SC_GUST_OPTION, INVALID_TIMER); - status_change_end(&sd->bl, SC_WIND_STEP_OPTION, INVALID_TIMER); - status_change_end(&sd->bl, SC_BLAST_OPTION, INVALID_TIMER); - status_change_end(&sd->bl, SC_WATER_DROP_OPTION, INVALID_TIMER); - status_change_end(&sd->bl, SC_WIND_CURTAIN_OPTION, INVALID_TIMER); - status_change_end(&sd->bl, SC_WILD_STORM_OPTION, INVALID_TIMER); - status_change_end(&sd->bl, SC_ZEPHYR, INVALID_TIMER); - status_change_end(&sd->bl, SC_WIND_STEP_OPTION, INVALID_TIMER); - status_change_end(&sd->bl, SC_PETROLOGY_OPTION, INVALID_TIMER); - status_change_end(&sd->bl, SC_SOLID_SKIN_OPTION, INVALID_TIMER); - status_change_end(&sd->bl, SC_CURSED_SOIL_OPTION, INVALID_TIMER); - status_change_end(&sd->bl, SC_STONE_SHIELD_OPTION, INVALID_TIMER); - status_change_end(&sd->bl, SC_UPHEAVAL_OPTION, INVALID_TIMER); - status_change_end(&sd->bl, SC_CIRCLE_OF_FIRE_OPTION, INVALID_TIMER); - status_change_end(&sd->bl, SC_TIDAL_WEAPON_OPTION, INVALID_TIMER); - - return 1; -} - -int elemental_action(struct elemental_data *ed, struct block_list *bl, unsigned int tick) { - struct skill_condition req; - uint16 skill_id, skill_lv; - int i; - - nullpo_ret(ed); - nullpo_ret(bl); - - if( !ed->master ) - return 0; - - if( ed->target_id ) - elemental->unlocktarget(ed); // Remove previous target. - - ARR_FIND(0, MAX_ELESKILLTREE, i, ed->db->skill[i].id && (ed->db->skill[i].mode&EL_SKILLMODE_AGGRESSIVE)); - if( i == MAX_ELESKILLTREE ) - return 0; - - skill_id = ed->db->skill[i].id; - skill_lv = ed->db->skill[i].lv; - - if( elemental->skillnotok(skill_id, ed) ) - return 0; - - if( ed->ud.skilltimer != INVALID_TIMER ) - return 0; - else if( DIFF_TICK(tick, ed->ud.canact_tick) < 0 ) - return 0; - - ed->target_id = ed->ud.skilltarget = bl->id; // Set new target - ed->last_thinktime = tick; - - // Not in skill range. - if( !battle->check_range(&ed->bl,bl,skill->get_range(skill_id,skill_lv)) ) { - // Try to walk to the target. - if( !unit_walktobl(&ed->bl, bl, skill->get_range(skill_id,skill_lv), 2) ) - elemental->unlocktarget(ed); - else { - // Walking, waiting to be in range. Client don't handle it, then we must handle it here. - int walk_dist = distance_bl(&ed->bl,bl) - skill->get_range(skill_id,skill_lv); - ed->ud.skill_id = skill_id; - ed->ud.skill_lv = skill_lv; - - if( skill->get_inf(skill_id) & INF_GROUND_SKILL ) - ed->ud.skilltimer = iTimer->add_timer( tick+iStatus->get_speed(&ed->bl)*walk_dist, skill->castend_pos, ed->bl.id, 0 ); - else - ed->ud.skilltimer = iTimer->add_timer( tick+iStatus->get_speed(&ed->bl)*walk_dist, skill->castend_id, ed->bl.id, 0 ); - } - return 1; - - } - - req = elemental->skill_get_requirements(skill_id, skill_lv); - - if(req.hp || req.sp){ - struct map_session_data *sd = BL_CAST(BL_PC, battle->get_master(&ed->bl)); - if( sd ){ - if( sd->skill_id_old != SO_EL_ACTION && //regardless of remaining HP/SP it can be cast - (status_get_hp(&ed->bl) < req.hp || status_get_sp(&ed->bl) < req.sp) ) - return 1; - else - status_zap(&ed->bl, req.hp, req.sp); - } - } - - //Otherwise, just cast the skill. - if( skill->get_inf(skill_id) & INF_GROUND_SKILL ) - unit_skilluse_pos(&ed->bl, bl->x, bl->y, skill_id, skill_lv); - else - unit_skilluse_id(&ed->bl, bl->id, skill_id, skill_lv); - - // Reset target. - ed->target_id = 0; - - return 1; -} - -/*=============================================================== - * Action that elemental perform after changing mode. - * Activates one of the skills of the new mode. - *-------------------------------------------------------------*/ -int elemental_change_mode_ack(struct elemental_data *ed, int mode) { - struct block_list *bl = &ed->master->bl; - uint16 skill_id, skill_lv; - int i; - - nullpo_ret(ed); - - if( !bl ) - return 0; - - // Select a skill. - ARR_FIND(0, MAX_ELESKILLTREE, i, ed->db->skill[i].id && (ed->db->skill[i].mode&mode)); - if( i == MAX_ELESKILLTREE ) - return 0; - - skill_id = ed->db->skill[i].id; - skill_lv = ed->db->skill[i].lv; - - if( elemental->skillnotok(skill_id, ed) ) - return 0; - - if( ed->ud.skilltimer != INVALID_TIMER ) - return 0; - else if( DIFF_TICK(iTimer->gettick(), ed->ud.canact_tick) < 0 ) - return 0; - - ed->target_id = bl->id; // Set new target - ed->last_thinktime = iTimer->gettick(); - - if( skill->get_inf(skill_id) & INF_GROUND_SKILL ) - unit_skilluse_pos(&ed->bl, bl->x, bl->y, skill_id, skill_lv); - else - unit_skilluse_id(&ed->bl,bl->id,skill_id,skill_lv); - - ed->target_id = 0; // Reset target after casting the skill to avoid continious attack. - - return 1; -} - -/*=============================================================== - * Change elemental mode. - *-------------------------------------------------------------*/ -int elemental_change_mode(struct elemental_data *ed, int mode) { - nullpo_ret(ed); - - // Remove target - elemental->unlocktarget(ed); - - // Removes the effects of the previous mode. - if(ed->elemental.mode != mode ) elemental->clean_effect(ed); - - ed->battle_status.mode = ed->elemental.mode = mode; - - // Normalize elemental mode to elemental skill mode. - if( mode == EL_MODE_AGGRESSIVE ) mode = EL_SKILLMODE_AGGRESSIVE; // Aggressive spirit mode -> Aggressive spirit skill. - else if( mode == EL_MODE_ASSIST ) mode = EL_SKILLMODE_ASSIST; // Assist spirit mode -> Assist spirit skill. - else mode = EL_SKILLMODE_PASIVE; // Passive spirit mode -> Passive spirit skill. - - // Use a skill inmediately after every change mode. - if( mode != EL_SKILLMODE_AGGRESSIVE ) - elemental->change_mode_ack(ed,mode); - return 1; -} - -void elemental_heal(struct elemental_data *ed, int hp, int sp) { - if( hp ) - clif->elemental_updatestatus(ed->master, SP_HP); - if( sp ) - clif->elemental_updatestatus(ed->master, SP_SP); -} - -int elemental_dead(struct elemental_data *ed) { - elemental->delete(ed, 1); - return 0; -} - -int elemental_unlocktarget(struct elemental_data *ed) { - nullpo_ret(ed); - - ed->target_id = 0; - elemental_stop_attack(ed); - elemental_stop_walking(ed,1); - return 0; -} - -int elemental_skillnotok(uint16 skill_id, struct elemental_data *ed) { - int idx = skill->get_index(skill_id); - nullpo_retr(1,ed); - - if (idx == 0) - return 1; // invalid skill id - - return skill->not_ok(skill_id, ed->master); -} - -struct skill_condition elemental_skill_get_requirements(uint16 skill_id, uint16 skill_lv){ - struct skill_condition req; - int idx = skill->get_index(skill_id); - - memset(&req,0,sizeof(req)); - - if( idx == 0 ) // invalid skill id - return req; - - 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]; - - return req; -} - -int elemental_set_target( struct map_session_data *sd, struct block_list *bl ) { - struct elemental_data *ed = sd->ed; - - nullpo_ret(ed); - nullpo_ret(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) ) - return 0; - - if( ed->target_id == 0 ) - ed->target_id = bl->id; - - return 1; -} - -static int elemental_ai_sub_timer_activesearch(struct block_list *bl, va_list ap) { - struct elemental_data *ed; - struct block_list **target; - int dist; - - nullpo_ret(bl); - - ed = va_arg(ap,struct elemental_data *); - 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) ) - return 0; - - if( battle->check_target(&ed->bl,bl,BCT_ENEMY) <= 0 ) - return 0; - - switch( bl->type ) { - case BL_PC: - if( !map_flag_vs(ed->bl.m) ) - return 0; - default: - dist = distance_bl(&ed->bl, bl); - if( ((*target) == NULL || !check_distance_bl(&ed->bl, *target, dist)) && battle->check_range(&ed->bl,bl,ed->db->range2) ) { //Pick closest target? - (*target) = bl; - ed->target_id = bl->id; - ed->min_chase = dist + ed->db->range3; - if( ed->min_chase > AREA_SIZE ) - ed->min_chase = AREA_SIZE; - return 1; - } - break; - } - return 0; -} - -static 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; - - nullpo_ret(ed); - nullpo_ret(sd); - - if( ed->bl.prev == NULL || sd == NULL || sd->bl.prev == NULL ) - return 0; - - // Check if caster can sustain the summoned elemental - if( DIFF_TICK(tick,ed->last_spdrain_time) >= 10000 ){// Drain SP every 10 seconds - int sp = 5; - - switch(ed->vd->class_){ - case 2115: case 2118: - case 2121: case 2124: - sp = 8; - break; - case 2116: case 2119: - case 2122: case 2125: - sp = 11; - break; - } - - if( status_get_sp(&sd->bl) < sp ){ // Can't sustain delete it. - elemental->delete(sd->ed,0); - return 0; - } - - status_zap(&sd->bl,0,sp); - ed->last_spdrain_time = tick; - } - - if( DIFF_TICK(tick,ed->last_thinktime) < MIN_ELETHINKTIME ) - return 0; - - ed->last_thinktime = tick; - - if( ed->ud.skilltimer != INVALID_TIMER ) - return 0; - - if( ed->ud.walktimer != INVALID_TIMER && ed->ud.walkpath.path_pos <= 2 ) - return 0; //No thinking when you just started to walk. - - if(ed->ud.walkpath.path_pos < ed->ud.walkpath.path_len && ed->ud.target == sd->bl.id) - return 0; //No thinking until be near the master. - - if( ed->sc.count && ed->sc.data[SC_BLIND] ) - view_range = 3; - else - view_range = ed->db->range2; - - mode = status_get_mode(&ed->bl); - - master_dist = distance_bl(&sd->bl, &ed->bl); - if( master_dist > AREA_SIZE ) { // Master out of vision range. - elemental->unlocktarget(ed); - unit_warp(&ed->bl,sd->bl.m,sd->bl.x,sd->bl.y,CLR_TELEPORT); - clif->elemental_updatestatus(sd,SP_HP); - clif->elemental_updatestatus(sd,SP_SP); - return 0; - } else if( master_dist > MAX_ELEDISTANCE ) { // Master too far, chase. - short x = sd->bl.x, y = sd->bl.y; - if( ed->target_id ) - elemental->unlocktarget(ed); - if( ed->ud.walktimer != INVALID_TIMER && ed->ud.target == sd->bl.id ) - 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) ) - return 0; - } - - if( mode == EL_MODE_AGGRESSIVE ) { - target = iMap->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)); - - if( !target ) { //No targets available. - elemental->unlocktarget(ed); - return 1; - } - - if( battle->check_range(&ed->bl,target,view_range) && rnd()%100 < 2 ) { // 2% chance to cast attack skill. - if( elemental->action(ed,target,tick) ) - return 1; - } - - //Attempt to attack. - //At this point we know the target is attackable, we just gotta check if the range matches. - if( ed->ud.target == target->id && ed->ud.attacktimer != INVALID_TIMER ) //Already locked. - return 1; - - if( battle->check_range(&ed->bl, target, ed->base_status.rhw.range) ) {//Target within range, engage - unit_attack(&ed->bl,target->id,1); - return 1; - } - - //Follow up if possible. - if( !unit_walktobl(&ed->bl, target, ed->base_status.rhw.range, 2) ) - elemental->unlocktarget(ed); - } - - return 0; -} - -static 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); - - 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); - return 0; -} - -int read_elementaldb(void) { - FILE *fp; - char line[1024], *p; - char *str[26]; - int i, j = 0, k = 0, ele; - struct s_elemental_db *db; - struct status_data *status; - - sprintf(line, "%s/%s", iMap->db_path, "elemental_db.txt"); - memset(elemental->elemental_db,0,sizeof(elemental->elemental_db)); - - fp = fopen(line, "r"); - if( !fp ) { - ShowError("read_elementaldb : can't read elemental_db.txt\n"); - return -1; - } - - while( fgets(line, sizeof(line), fp) && j < MAX_ELEMENTAL_CLASS ) { - k++; - if( line[0] == '/' && line[1] == '/' ) - continue; - - if( line[0] == '\0' || line[0] == '\n' || line[0] == '\r') - continue; - - i = 0; - p = strtok(line, ","); - while( p != NULL && i < 26 ) { - str[i++] = p; - p = strtok(NULL, ","); - } - if( i < 26 ) { - ShowError("read_elementaldb : Incorrect number of columns at elemental_db.txt line %d.\n", k); - continue; - } - - db = &elemental->elemental_db[j]; - db->class_ = atoi(str[0]); - safestrncpy(db->sprite, str[1], NAME_LENGTH); - safestrncpy(db->name, str[2], NAME_LENGTH); - db->lv = atoi(str[3]); - - status = &db->status; - db->vd.class_ = db->class_; - - status->max_hp = atoi(str[4]); - status->max_sp = atoi(str[5]); - status->rhw.range = atoi(str[6]); - status->rhw.atk = atoi(str[7]); - status->rhw.atk2 = atoi(str[8]); - status->def = atoi(str[9]); - status->mdef = atoi(str[10]); - status->str = atoi(str[11]); - status->agi = atoi(str[12]); - status->vit = atoi(str[13]); - status->int_ = atoi(str[14]); - status->dex = atoi(str[15]); - status->luk = atoi(str[16]); - db->range2 = atoi(str[17]); - db->range3 = atoi(str[18]); - status->size = atoi(str[19]); - status->race = atoi(str[20]); - - ele = atoi(str[21]); - status->def_ele = ele%10; - status->ele_lv = ele/20; - if( status->def_ele >= ELE_MAX ) { - ShowWarning("Elemental %d has invalid element type %d (max element is %d)\n", db->class_, status->def_ele, ELE_MAX - 1); - status->def_ele = ELE_NEUTRAL; - } - if( status->ele_lv < 1 || status->ele_lv > 4 ) { - ShowWarning("Elemental %d has invalid element level %d (max is 4)\n", db->class_, status->ele_lv); - status->ele_lv = 1; - } - - status->aspd_rate = 1000; - status->speed = atoi(str[22]); - status->adelay = atoi(str[23]); - status->amotion = atoi(str[24]); - status->dmotion = atoi(str[25]); - - j++; - } - - fclose(fp); - ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' elementals in '"CL_WHITE"db/elemental_db.txt"CL_RESET"'.\n",j); - - return 0; -} - -int read_elemental_skilldb(void) { - FILE *fp; - char line[1024], *p; - char *str[4]; - struct s_elemental_db *db; - int i, j = 0, k = 0, class_; - uint16 skill_id, skill_lv; - int skillmode; - - sprintf(line, "%s/%s", iMap->db_path, "elemental_skill_db.txt"); - fp = fopen(line, "r"); - if( !fp ) { - ShowError("read_elemental_skilldb : can't read elemental_skill_db.txt\n"); - return -1; - } - - while( fgets(line, sizeof(line), fp) ) { - k++; - if( line[0] == '/' && line[1] == '/' ) - continue; - - if( line[0] == '\0' || line[0] == '\n' || line[0] == '\r') - continue; - - i = 0; - p = strtok(line, ","); - while( p != NULL && i < 4 ) { - str[i++] = p; - p = strtok(NULL, ","); - } - if( i < 4 ) { - ShowError("read_elemental_skilldb : Incorrect number of columns at elemental_skill_db.txt line %d.\n", k); - continue; - } - - class_ = atoi(str[0]); - ARR_FIND(0, MAX_ELEMENTAL_CLASS, i, class_ == elemental->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; - } - - skill_id = atoi(str[1]); - if( skill_id < EL_SKILLBASE || skill_id >= EL_SKILLBASE + MAX_ELEMENTALSKILL ) { - ShowError("read_elemental_skilldb : Skill out of range, line %d.\n", k); - continue; - } - - db = &elemental->elemental_db[i]; - skill_lv = atoi(str[2]); - - skillmode = atoi(str[3]); - if( skillmode < EL_SKILLMODE_PASIVE || skillmode > EL_SKILLMODE_AGGRESSIVE ) { - ShowError("read_elemental_skilldb : Skillmode out of range, line %d.\n",k); - continue; - } - ARR_FIND( 0, MAX_ELESKILLTREE, i, db->skill[i].id == 0 || db->skill[i].id == skill_id ); - if( i == MAX_ELESKILLTREE ) { - ShowWarning("Unable to load skill %d into Elemental %d's tree. Maximum number of skills per elemental has been reached.\n", skill_id, class_); - continue; - } - db->skill[i].id = skill_id; - db->skill[i].lv = skill_lv; - db->skill[i].mode = skillmode; - j++; - } - - fclose(fp); - ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"db/elemental_skill_db.txt"CL_RESET"'.\n",j); - return 0; -} - -void reload_elementaldb(void) { - read_elementaldb(); - elemental->reload_skilldb(); -} - -void reload_elemental_skilldb(void) { - elemental->read_skilldb(); -} - -int do_init_elemental(void) { - read_elementaldb(); - elemental->read_skilldb(); - - iTimer->add_timer_func_list(elemental_ai_timer,"elemental_ai_timer"); - iTimer->add_timer_interval(iTimer->gettick()+MIN_ELETHINKTIME,elemental_ai_timer,0,0,MIN_ELETHINKTIME); - - return 0; -} - -void do_final_elemental(void) { - return; -} - -/*===================================== -* Default Functions : elemental.h -* Generated by HerculesInterfaceMaker -* created by Susu -*-------------------------------------*/ -void elemental_defaults(void) { - elemental = &elemental_s; - /* funcs */ - - elemental->class = elemental_class; - elemental->get_viewdata = elemental_get_viewdata; - - elemental->create = elemental_create; - elemental->data_received = elemental_data_received; - elemental->save = elemental_save; - - elemental->change_mode_ack = elemental_change_mode_ack; - elemental->change_mode = elemental_change_mode; - - elemental->heal = elemental_heal; - elemental->dead = elemental_dead; - - elemental->delete = elemental_delete; - elemental->summon_stop = elemental_summon_stop; - - elemental->get_lifetime = elemental_get_lifetime; - - elemental->unlocktarget = elemental_unlocktarget; - elemental->skillnotok = elemental_skillnotok; - elemental->set_target = elemental_set_target; - elemental->clean_single_effect = elemental_clean_single_effect; - elemental->clean_effect = elemental_clean_effect; - elemental->action = elemental_action; - elemental->skill_get_requirements = elemental_skill_get_requirements; - - elemental->read_skilldb = read_elemental_skilldb; - elemental->reload_elementaldb = reload_elementaldb; - elemental->reload_skilldb = reload_elemental_skilldb; - elemental->do_init_elemental = do_init_elemental; - elemental->do_final_elemental = do_final_elemental; -} +// 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" +#include "../common/socket.h" +#include "../common/timer.h" +#include "../common/nullpo.h" +#include "../common/mmo.h" +#include "../common/showmsg.h" +#include "../common/utils.h" +#include "../common/random.h" +#include "../common/strlib.h" + +#include "log.h" +#include "clif.h" +#include "chrif.h" +#include "intif.h" +#include "itemdb.h" +#include "map.h" +#include "pc.h" +#include "status.h" +#include "skill.h" +#include "mob.h" +#include "pet.h" +#include "battle.h" +#include "party.h" +#include "guild.h" +#include "atcommand.h" +#include "script.h" +#include "npc.h" +#include "trade.h" +#include "unit.h" +#include "elemental.h" + +#include +#include +#include +#include + +int elemental_search_index(int class_) { + int i; + ARR_FIND(0, MAX_ELEMENTAL_CLASS, i, elemental->elemental_db[i].class_ == class_); + return (i == MAX_ELEMENTAL_CLASS)?-1:i; +} + +bool elemental_class(int class_) { + return (bool)(elemental_search_index(class_) > -1); +} + +struct view_data * elemental_get_viewdata(int class_) { + int i = elemental_search_index(class_); + if( i < 0 ) + return 0; + + return &elemental->elemental_db[i].vd; +} + +int elemental_create(struct map_session_data *sd, int class_, unsigned int lifetime) { + struct s_elemental ele; + struct s_elemental_db *db; + int i; + + nullpo_retr(1,sd); + + if( (i = elemental_search_index(class_)) < 0 ) + return 0; + + db = &elemental->elemental_db[i]; + memset(&ele,0,sizeof(struct s_elemental)); + + ele.char_id = sd->status.char_id; + ele.class_ = class_; + 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] + 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 + ele.sp = ele.max_sp = sd->battle_status.max_sp/4; + //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) ] + ele.atk2 = sd->battle_status.max_sp / 18; + //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)] + ele.matk = i * (sd->battle_status.int_ / 2 + sd->battle_status.dex / 4); + //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) + ele.def = sd->battle_status.def + sd->status.base_level / (5-i); + //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) + ele.flee = sd->status.base_level / (5-i); + //Caster�s HIT + (Caster�s Base Level ) + ele.hit = sd->battle_status.hit + sd->status.base_level; + + //per individual bonuses + switch(db->class_){ + case 2114: case 2115: + case 2116: //ATK + (Summon Agni Skill Level x 20) / HIT + (Summon Agni Skill Level x 10) + ele.atk += i * 20; + ele.atk2 += i * 20; + ele.hit += i * 10; + break; + case 2117: case 2118: + case 2119: //MDEF + (Summon Aqua Skill Level x 10) / MATK + (Summon Aqua Skill Level x 20) + ele.mdef += i * 10; + ele.matk += i * 20; + break; + case 2120: case 2121: + case 2122: //FLEE + (Summon Ventus Skill Level x 20) / MATK + (Summon Ventus Skill Level x 10) + ele.flee += i * 20; + ele.matk += i * 10; + break; + case 2123: case 2124: + case 2125: //DEF + (Summon Tera Skill Level x 25) / ATK + (Summon Tera Skill Level x 5) + ele.def += i * 25; + ele.atk += i * 5; + ele.atk2 += i * 5; + break; + } + + if( (i=pc->checkskill(sd,SO_EL_SYMPATHY)) > 0 ){ + ele.hp = ele.max_hp = ele.max_hp * 5 * i / 100; + ele.sp = ele.max_sp = ele.max_sp * 5 * i / 100; + ele.atk += 25 * i; + ele.atk2 += 25 * i; + ele.matk += 25 * i; + } + + ele.life_time = lifetime; + + // Request Char Server to create this elemental + intif->elemental_create(&ele); + + return 1; +} + +int elemental_get_lifetime(struct elemental_data *ed) { + const struct TimerData * td; + if( ed == NULL || ed->summon_timer == INVALID_TIMER ) + return 0; + + td = iTimer->get_timer(ed->summon_timer); + return (td != NULL) ? DIFF_TICK(td->tick, iTimer->gettick()) : 0; +} + +int elemental_save(struct elemental_data *ed) { + ed->elemental.mode = ed->battle_status.mode; + ed->elemental.hp = ed->battle_status.hp; + ed->elemental.sp = ed->battle_status.sp; + ed->elemental.max_hp = ed->battle_status.max_hp; + ed->elemental.max_sp = ed->battle_status.max_sp; + ed->elemental.atk = ed->battle_status.rhw.atk; + ed->elemental.atk2 = ed->battle_status.rhw.atk2; + ed->elemental.matk = ed->battle_status.matk_min; + ed->elemental.def = ed->battle_status.def; + ed->elemental.mdef = ed->battle_status.mdef; + ed->elemental.flee = ed->battle_status.flee; + ed->elemental.hit = ed->battle_status.hit; + ed->elemental.life_time = elemental->get_lifetime(ed); + intif->elemental_save(&ed->elemental); + return 1; +} + +static int elemental_summon_end(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 ) + 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); + return 0; + } + + ed->summon_timer = INVALID_TIMER; + elemental->delete(ed, 0); // Elemental's summon time is over. + + return 0; +} + +void elemental_summon_stop(struct elemental_data *ed) { + nullpo_retv(ed); + if( ed->summon_timer != INVALID_TIMER ) + iTimer->delete_timer(ed->summon_timer, elemental_summon_end); + ed->summon_timer = INVALID_TIMER; +} + +int elemental_delete(struct elemental_data *ed, int reply) { + struct map_session_data *sd; + nullpo_ret(ed); + + sd = ed->master; + ed->elemental.life_time = 0; + + elemental->clean_effect(ed); + elemental->summon_stop(ed); + + if( !sd ) + return unit->free(&ed->bl, 0); + + sd->ed = NULL; + sd->status.ele_id = 0; + + return unit->remove_map(&ed->bl, 0, ALC_MARK); +} + +void elemental_summon_init(struct elemental_data *ed) { + if( ed->summon_timer == INVALID_TIMER ) + ed->summon_timer = iTimer->add_timer(iTimer->gettick() + ed->elemental.life_time, elemental_summon_end, ed->master->bl.id, 0); + + ed->regen.state.block = 0; +} + +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_); + + if( (sd = iMap->charid2sd(ele->char_id)) == NULL ) + return 0; + + if( !flag || i < 0 ) { // Not created - loaded - DB info + sd->status.ele_id = 0; + return 0; + } + + db = &elemental->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; + ed->bl.id = npc_get_new_npc_id(); + ed->master = sd; + ed->db = db; + memcpy(&ed->elemental, ele, sizeof(struct s_elemental)); + iStatus->set_viewdata(&ed->bl, ed->elemental.class_); + ed->vd->head_mid = 10; // Why? + iStatus->change_init(&ed->bl); + unit->dataset(&ed->bl); + ed->ud.dir = sd->ud.dir; + + ed->bl.m = sd->bl.m; + ed->bl.x = sd->bl.x; + ed->bl.y = sd->bl.y; + unit->calc_pos(&ed->bl, sd->bl.x, sd->bl.y, sd->ud.dir); + ed->bl.x = ed->ud.to_x; + ed->bl.y = ed->ud.to_y; + + iMap->addiddb(&ed->bl); + status_calc_elemental(ed,1); + ed->last_spdrain_time = ed->last_thinktime = iTimer->gettick(); + ed->summon_timer = INVALID_TIMER; + elemental_summon_init(ed); + } else { + memcpy(&sd->ed->elemental, ele, sizeof(struct s_elemental)); + ed = sd->ed; + } + + sd->status.ele_id = ele->elemental_id; + + if( ed->bl.prev == NULL && sd->bl.prev != NULL ) { + iMap->addblock(&ed->bl); + clif->spawn(&ed->bl); + clif->elemental_info(sd); + clif->elemental_updatestatus(sd,SP_HP); + clif->hpmeter_single(sd->fd,ed->bl.id,ed->battle_status.hp,ed->battle_status.max_hp); + clif->elemental_updatestatus(sd,SP_SP); + } + + return 1; +} + +int elemental_clean_single_effect(struct elemental_data *ed, uint16 skill_id) { + struct block_list *bl; + sc_type type = iStatus->skill2sc(skill_id); + + nullpo_ret(ed); + + bl = battle->get_master(&ed->bl); + + if( type ) { + switch( type ) { + // Just remove status change. + case SC_PYROTECHNIC_OPTION: + case SC_HEATER_OPTION: + case SC_TROPIC_OPTION: + case SC_FIRE_CLOAK_OPTION: + case SC_AQUAPLAY_OPTION: + case SC_WATER_SCREEN_OPTION: + case SC_COOLER_OPTION: + case SC_CHILLY_AIR_OPTION: + case SC_GUST_OPTION: + case SC_WIND_STEP_OPTION: + case SC_BLAST_OPTION: + case SC_WATER_DROP_OPTION: + case SC_WIND_CURTAIN_OPTION: + case SC_WILD_STORM_OPTION: + case SC_PETROLOGY_OPTION: + case SC_SOLID_SKIN_OPTION: + case SC_CURSED_SOIL_OPTION: + case SC_STONE_SHIELD_OPTION: + case SC_UPHEAVAL_OPTION: + case SC_CIRCLE_OF_FIRE_OPTION: + case SC_TIDAL_WEAPON_OPTION: + if( bl ) status_change_end(bl,type,INVALID_TIMER); // Master + status_change_end(&ed->bl,type-1,INVALID_TIMER); // Elemental Spirit + break; + case SC_ZEPHYR: + if( bl ) status_change_end(bl,type,INVALID_TIMER); + break; + default: + ShowWarning("Invalid SC=%d in elemental_clean_single_effect\n",type); + break; + } + } + + return 1; +} + +int elemental_clean_effect(struct elemental_data *ed) { + struct map_session_data *sd; + + nullpo_ret(ed); + + // Elemental side + status_change_end(&ed->bl, SC_TROPIC, INVALID_TIMER); + status_change_end(&ed->bl, SC_HEATER, INVALID_TIMER); + status_change_end(&ed->bl, SC_AQUAPLAY, INVALID_TIMER); + status_change_end(&ed->bl, SC_COOLER, INVALID_TIMER); + status_change_end(&ed->bl, SC_CHILLY_AIR, INVALID_TIMER); + status_change_end(&ed->bl, SC_PYROTECHNIC, INVALID_TIMER); + status_change_end(&ed->bl, SC_FIRE_CLOAK, INVALID_TIMER); + status_change_end(&ed->bl, SC_WATER_DROP, INVALID_TIMER); + status_change_end(&ed->bl, SC_WATER_SCREEN, INVALID_TIMER); + status_change_end(&ed->bl, SC_GUST, INVALID_TIMER); + status_change_end(&ed->bl, SC_WIND_STEP, INVALID_TIMER); + status_change_end(&ed->bl, SC_BLAST, INVALID_TIMER); + status_change_end(&ed->bl, SC_WIND_CURTAIN, INVALID_TIMER); + status_change_end(&ed->bl, SC_WILD_STORM, INVALID_TIMER); + status_change_end(&ed->bl, SC_PETROLOGY, INVALID_TIMER); + status_change_end(&ed->bl, SC_SOLID_SKIN, INVALID_TIMER); + status_change_end(&ed->bl, SC_CURSED_SOIL, INVALID_TIMER); + status_change_end(&ed->bl, SC_STONE_SHIELD, INVALID_TIMER); + status_change_end(&ed->bl, SC_UPHEAVAL, INVALID_TIMER); + status_change_end(&ed->bl, SC_CIRCLE_OF_FIRE, INVALID_TIMER); + status_change_end(&ed->bl, SC_TIDAL_WEAPON, INVALID_TIMER); + + if( (sd = ed->master) == NULL ) + return 0; + + // Master side + status_change_end(&sd->bl, SC_TROPIC_OPTION, INVALID_TIMER); + status_change_end(&sd->bl, SC_HEATER_OPTION, INVALID_TIMER); + status_change_end(&sd->bl, SC_AQUAPLAY_OPTION, INVALID_TIMER); + status_change_end(&sd->bl, SC_COOLER_OPTION, INVALID_TIMER); + status_change_end(&sd->bl, SC_CHILLY_AIR_OPTION, INVALID_TIMER); + status_change_end(&sd->bl, SC_PYROTECHNIC_OPTION, INVALID_TIMER); + status_change_end(&sd->bl, SC_FIRE_CLOAK_OPTION, INVALID_TIMER); + status_change_end(&sd->bl, SC_WATER_DROP_OPTION, INVALID_TIMER); + status_change_end(&sd->bl, SC_WATER_SCREEN_OPTION, INVALID_TIMER); + status_change_end(&sd->bl, SC_GUST_OPTION, INVALID_TIMER); + status_change_end(&sd->bl, SC_WIND_STEP_OPTION, INVALID_TIMER); + status_change_end(&sd->bl, SC_BLAST_OPTION, INVALID_TIMER); + status_change_end(&sd->bl, SC_WATER_DROP_OPTION, INVALID_TIMER); + status_change_end(&sd->bl, SC_WIND_CURTAIN_OPTION, INVALID_TIMER); + status_change_end(&sd->bl, SC_WILD_STORM_OPTION, INVALID_TIMER); + status_change_end(&sd->bl, SC_ZEPHYR, INVALID_TIMER); + status_change_end(&sd->bl, SC_WIND_STEP_OPTION, INVALID_TIMER); + status_change_end(&sd->bl, SC_PETROLOGY_OPTION, INVALID_TIMER); + status_change_end(&sd->bl, SC_SOLID_SKIN_OPTION, INVALID_TIMER); + status_change_end(&sd->bl, SC_CURSED_SOIL_OPTION, INVALID_TIMER); + status_change_end(&sd->bl, SC_STONE_SHIELD_OPTION, INVALID_TIMER); + status_change_end(&sd->bl, SC_UPHEAVAL_OPTION, INVALID_TIMER); + status_change_end(&sd->bl, SC_CIRCLE_OF_FIRE_OPTION, INVALID_TIMER); + status_change_end(&sd->bl, SC_TIDAL_WEAPON_OPTION, INVALID_TIMER); + + return 1; +} + +int elemental_action(struct elemental_data *ed, struct block_list *bl, unsigned int tick) { + struct skill_condition req; + uint16 skill_id, skill_lv; + int i; + + nullpo_ret(ed); + nullpo_ret(bl); + + if( !ed->master ) + return 0; + + if( ed->target_id ) + elemental->unlocktarget(ed); // Remove previous target. + + ARR_FIND(0, MAX_ELESKILLTREE, i, ed->db->skill[i].id && (ed->db->skill[i].mode&EL_SKILLMODE_AGGRESSIVE)); + if( i == MAX_ELESKILLTREE ) + return 0; + + skill_id = ed->db->skill[i].id; + skill_lv = ed->db->skill[i].lv; + + if( elemental->skillnotok(skill_id, ed) ) + return 0; + + if( ed->ud.skilltimer != INVALID_TIMER ) + return 0; + else if( DIFF_TICK(tick, ed->ud.canact_tick) < 0 ) + return 0; + + ed->target_id = ed->ud.skilltarget = bl->id; // Set new target + ed->last_thinktime = tick; + + // Not in skill range. + if( !battle->check_range(&ed->bl,bl,skill->get_range(skill_id,skill_lv)) ) { + // Try to walk to the target. + if( !unit->walktobl(&ed->bl, bl, skill->get_range(skill_id,skill_lv), 2) ) + elemental->unlocktarget(ed); + else { + // Walking, waiting to be in range. Client don't handle it, then we must handle it here. + int walk_dist = distance_bl(&ed->bl,bl) - skill->get_range(skill_id,skill_lv); + ed->ud.skill_id = skill_id; + ed->ud.skill_lv = skill_lv; + + if( skill->get_inf(skill_id) & INF_GROUND_SKILL ) + ed->ud.skilltimer = iTimer->add_timer( tick+iStatus->get_speed(&ed->bl)*walk_dist, skill->castend_pos, ed->bl.id, 0 ); + else + ed->ud.skilltimer = iTimer->add_timer( tick+iStatus->get_speed(&ed->bl)*walk_dist, skill->castend_id, ed->bl.id, 0 ); + } + return 1; + + } + + req = elemental->skill_get_requirements(skill_id, skill_lv); + + if(req.hp || req.sp){ + struct map_session_data *sd = BL_CAST(BL_PC, battle->get_master(&ed->bl)); + if( sd ){ + if( sd->skill_id_old != SO_EL_ACTION && //regardless of remaining HP/SP it can be cast + (status_get_hp(&ed->bl) < req.hp || status_get_sp(&ed->bl) < req.sp) ) + return 1; + else + status_zap(&ed->bl, req.hp, req.sp); + } + } + + //Otherwise, just cast the skill. + if( skill->get_inf(skill_id) & INF_GROUND_SKILL ) + unit->skilluse_pos(&ed->bl, bl->x, bl->y, skill_id, skill_lv); + else + unit->skilluse_id(&ed->bl, bl->id, skill_id, skill_lv); + + // Reset target. + ed->target_id = 0; + + return 1; +} + +/*=============================================================== + * Action that elemental perform after changing mode. + * Activates one of the skills of the new mode. + *-------------------------------------------------------------*/ +int elemental_change_mode_ack(struct elemental_data *ed, int mode) { + struct block_list *bl = &ed->master->bl; + uint16 skill_id, skill_lv; + int i; + + nullpo_ret(ed); + + if( !bl ) + return 0; + + // Select a skill. + ARR_FIND(0, MAX_ELESKILLTREE, i, ed->db->skill[i].id && (ed->db->skill[i].mode&mode)); + if( i == MAX_ELESKILLTREE ) + return 0; + + skill_id = ed->db->skill[i].id; + skill_lv = ed->db->skill[i].lv; + + if( elemental->skillnotok(skill_id, ed) ) + return 0; + + if( ed->ud.skilltimer != INVALID_TIMER ) + return 0; + else if( DIFF_TICK(iTimer->gettick(), ed->ud.canact_tick) < 0 ) + return 0; + + ed->target_id = bl->id; // Set new target + ed->last_thinktime = iTimer->gettick(); + + if( skill->get_inf(skill_id) & INF_GROUND_SKILL ) + unit->skilluse_pos(&ed->bl, bl->x, bl->y, skill_id, skill_lv); + else + unit->skilluse_id(&ed->bl,bl->id,skill_id,skill_lv); + + ed->target_id = 0; // Reset target after casting the skill to avoid continious attack. + + return 1; +} + +/*=============================================================== + * Change elemental mode. + *-------------------------------------------------------------*/ +int elemental_change_mode(struct elemental_data *ed, int mode) { + nullpo_ret(ed); + + // Remove target + elemental->unlocktarget(ed); + + // Removes the effects of the previous mode. + if(ed->elemental.mode != mode ) elemental->clean_effect(ed); + + ed->battle_status.mode = ed->elemental.mode = mode; + + // Normalize elemental mode to elemental skill mode. + if( mode == EL_MODE_AGGRESSIVE ) mode = EL_SKILLMODE_AGGRESSIVE; // Aggressive spirit mode -> Aggressive spirit skill. + else if( mode == EL_MODE_ASSIST ) mode = EL_SKILLMODE_ASSIST; // Assist spirit mode -> Assist spirit skill. + else mode = EL_SKILLMODE_PASIVE; // Passive spirit mode -> Passive spirit skill. + + // Use a skill inmediately after every change mode. + if( mode != EL_SKILLMODE_AGGRESSIVE ) + elemental->change_mode_ack(ed,mode); + return 1; +} + +void elemental_heal(struct elemental_data *ed, int hp, int sp) { + if( hp ) + clif->elemental_updatestatus(ed->master, SP_HP); + if( sp ) + clif->elemental_updatestatus(ed->master, SP_SP); +} + +int elemental_dead(struct elemental_data *ed) { + elemental->delete(ed, 1); + return 0; +} + +int elemental_unlocktarget(struct elemental_data *ed) { + nullpo_ret(ed); + + ed->target_id = 0; + elemental_stop_attack(ed); + elemental_stop_walking(ed,1); + return 0; +} + +int elemental_skillnotok(uint16 skill_id, struct elemental_data *ed) { + int idx = skill->get_index(skill_id); + nullpo_retr(1,ed); + + if (idx == 0) + return 1; // invalid skill id + + return skill->not_ok(skill_id, ed->master); +} + +struct skill_condition elemental_skill_get_requirements(uint16 skill_id, uint16 skill_lv){ + struct skill_condition req; + int idx = skill->get_index(skill_id); + + memset(&req,0,sizeof(req)); + + if( idx == 0 ) // invalid skill id + return req; + + 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]; + + return req; +} + +int elemental_set_target( struct map_session_data *sd, struct block_list *bl ) { + struct elemental_data *ed = sd->ed; + + nullpo_ret(ed); + nullpo_ret(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) ) + return 0; + + if( ed->target_id == 0 ) + ed->target_id = bl->id; + + return 1; +} + +static int elemental_ai_sub_timer_activesearch(struct block_list *bl, va_list ap) { + struct elemental_data *ed; + struct block_list **target; + int dist; + + nullpo_ret(bl); + + ed = va_arg(ap,struct elemental_data *); + 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) ) + return 0; + + if( battle->check_target(&ed->bl,bl,BCT_ENEMY) <= 0 ) + return 0; + + switch( bl->type ) { + case BL_PC: + if( !map_flag_vs(ed->bl.m) ) + return 0; + default: + dist = distance_bl(&ed->bl, bl); + if( ((*target) == NULL || !check_distance_bl(&ed->bl, *target, dist)) && battle->check_range(&ed->bl,bl,ed->db->range2) ) { //Pick closest target? + (*target) = bl; + ed->target_id = bl->id; + ed->min_chase = dist + ed->db->range3; + if( ed->min_chase > AREA_SIZE ) + ed->min_chase = AREA_SIZE; + return 1; + } + break; + } + return 0; +} + +static 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; + + nullpo_ret(ed); + nullpo_ret(sd); + + if( ed->bl.prev == NULL || sd == NULL || sd->bl.prev == NULL ) + return 0; + + // Check if caster can sustain the summoned elemental + if( DIFF_TICK(tick,ed->last_spdrain_time) >= 10000 ){// Drain SP every 10 seconds + int sp = 5; + + switch(ed->vd->class_){ + case 2115: case 2118: + case 2121: case 2124: + sp = 8; + break; + case 2116: case 2119: + case 2122: case 2125: + sp = 11; + break; + } + + if( status_get_sp(&sd->bl) < sp ){ // Can't sustain delete it. + elemental->delete(sd->ed,0); + return 0; + } + + status_zap(&sd->bl,0,sp); + ed->last_spdrain_time = tick; + } + + if( DIFF_TICK(tick,ed->last_thinktime) < MIN_ELETHINKTIME ) + return 0; + + ed->last_thinktime = tick; + + if( ed->ud.skilltimer != INVALID_TIMER ) + return 0; + + if( ed->ud.walktimer != INVALID_TIMER && ed->ud.walkpath.path_pos <= 2 ) + return 0; //No thinking when you just started to walk. + + if(ed->ud.walkpath.path_pos < ed->ud.walkpath.path_len && ed->ud.target == sd->bl.id) + return 0; //No thinking until be near the master. + + if( ed->sc.count && ed->sc.data[SC_BLIND] ) + view_range = 3; + else + view_range = ed->db->range2; + + mode = status_get_mode(&ed->bl); + + master_dist = distance_bl(&sd->bl, &ed->bl); + if( master_dist > AREA_SIZE ) { // Master out of vision range. + elemental->unlocktarget(ed); + unit->warp(&ed->bl,sd->bl.m,sd->bl.x,sd->bl.y,CLR_TELEPORT); + clif->elemental_updatestatus(sd,SP_HP); + clif->elemental_updatestatus(sd,SP_SP); + return 0; + } else if( master_dist > MAX_ELEDISTANCE ) { // Master too far, chase. + short x = sd->bl.x, y = sd->bl.y; + if( ed->target_id ) + elemental->unlocktarget(ed); + if( ed->ud.walktimer != INVALID_TIMER && ed->ud.target == sd->bl.id ) + 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) ) + return 0; + } + + if( mode == EL_MODE_AGGRESSIVE ) { + target = iMap->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)); + + if( !target ) { //No targets available. + elemental->unlocktarget(ed); + return 1; + } + + if( battle->check_range(&ed->bl,target,view_range) && rnd()%100 < 2 ) { // 2% chance to cast attack skill. + if( elemental->action(ed,target,tick) ) + return 1; + } + + //Attempt to attack. + //At this point we know the target is attackable, we just gotta check if the range matches. + if( ed->ud.target == target->id && ed->ud.attacktimer != INVALID_TIMER ) //Already locked. + return 1; + + if( battle->check_range(&ed->bl, target, ed->base_status.rhw.range) ) {//Target within range, engage + unit->attack(&ed->bl,target->id,1); + return 1; + } + + //Follow up if possible. + if( !unit->walktobl(&ed->bl, target, ed->base_status.rhw.range, 2) ) + elemental->unlocktarget(ed); + } + + return 0; +} + +static 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); + + 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); + return 0; +} + +int read_elementaldb(void) { + FILE *fp; + char line[1024], *p; + char *str[26]; + int i, j = 0, k = 0, ele; + struct s_elemental_db *db; + struct status_data *status; + + sprintf(line, "%s/%s", iMap->db_path, "elemental_db.txt"); + memset(elemental->elemental_db,0,sizeof(elemental->elemental_db)); + + fp = fopen(line, "r"); + if( !fp ) { + ShowError("read_elementaldb : can't read elemental_db.txt\n"); + return -1; + } + + while( fgets(line, sizeof(line), fp) && j < MAX_ELEMENTAL_CLASS ) { + k++; + if( line[0] == '/' && line[1] == '/' ) + continue; + + if( line[0] == '\0' || line[0] == '\n' || line[0] == '\r') + continue; + + i = 0; + p = strtok(line, ","); + while( p != NULL && i < 26 ) { + str[i++] = p; + p = strtok(NULL, ","); + } + if( i < 26 ) { + ShowError("read_elementaldb : Incorrect number of columns at elemental_db.txt line %d.\n", k); + continue; + } + + db = &elemental->elemental_db[j]; + db->class_ = atoi(str[0]); + safestrncpy(db->sprite, str[1], NAME_LENGTH); + safestrncpy(db->name, str[2], NAME_LENGTH); + db->lv = atoi(str[3]); + + status = &db->status; + db->vd.class_ = db->class_; + + status->max_hp = atoi(str[4]); + status->max_sp = atoi(str[5]); + status->rhw.range = atoi(str[6]); + status->rhw.atk = atoi(str[7]); + status->rhw.atk2 = atoi(str[8]); + status->def = atoi(str[9]); + status->mdef = atoi(str[10]); + status->str = atoi(str[11]); + status->agi = atoi(str[12]); + status->vit = atoi(str[13]); + status->int_ = atoi(str[14]); + status->dex = atoi(str[15]); + status->luk = atoi(str[16]); + db->range2 = atoi(str[17]); + db->range3 = atoi(str[18]); + status->size = atoi(str[19]); + status->race = atoi(str[20]); + + ele = atoi(str[21]); + status->def_ele = ele%10; + status->ele_lv = ele/20; + if( status->def_ele >= ELE_MAX ) { + ShowWarning("Elemental %d has invalid element type %d (max element is %d)\n", db->class_, status->def_ele, ELE_MAX - 1); + status->def_ele = ELE_NEUTRAL; + } + if( status->ele_lv < 1 || status->ele_lv > 4 ) { + ShowWarning("Elemental %d has invalid element level %d (max is 4)\n", db->class_, status->ele_lv); + status->ele_lv = 1; + } + + status->aspd_rate = 1000; + status->speed = atoi(str[22]); + status->adelay = atoi(str[23]); + status->amotion = atoi(str[24]); + status->dmotion = atoi(str[25]); + + j++; + } + + fclose(fp); + ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' elementals in '"CL_WHITE"db/elemental_db.txt"CL_RESET"'.\n",j); + + return 0; +} + +int read_elemental_skilldb(void) { + FILE *fp; + char line[1024], *p; + char *str[4]; + struct s_elemental_db *db; + int i, j = 0, k = 0, class_; + uint16 skill_id, skill_lv; + int skillmode; + + sprintf(line, "%s/%s", iMap->db_path, "elemental_skill_db.txt"); + fp = fopen(line, "r"); + if( !fp ) { + ShowError("read_elemental_skilldb : can't read elemental_skill_db.txt\n"); + return -1; + } + + while( fgets(line, sizeof(line), fp) ) { + k++; + if( line[0] == '/' && line[1] == '/' ) + continue; + + if( line[0] == '\0' || line[0] == '\n' || line[0] == '\r') + continue; + + i = 0; + p = strtok(line, ","); + while( p != NULL && i < 4 ) { + str[i++] = p; + p = strtok(NULL, ","); + } + if( i < 4 ) { + ShowError("read_elemental_skilldb : Incorrect number of columns at elemental_skill_db.txt line %d.\n", k); + continue; + } + + class_ = atoi(str[0]); + ARR_FIND(0, MAX_ELEMENTAL_CLASS, i, class_ == elemental->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; + } + + skill_id = atoi(str[1]); + if( skill_id < EL_SKILLBASE || skill_id >= EL_SKILLBASE + MAX_ELEMENTALSKILL ) { + ShowError("read_elemental_skilldb : Skill out of range, line %d.\n", k); + continue; + } + + db = &elemental->elemental_db[i]; + skill_lv = atoi(str[2]); + + skillmode = atoi(str[3]); + if( skillmode < EL_SKILLMODE_PASIVE || skillmode > EL_SKILLMODE_AGGRESSIVE ) { + ShowError("read_elemental_skilldb : Skillmode out of range, line %d.\n",k); + continue; + } + ARR_FIND( 0, MAX_ELESKILLTREE, i, db->skill[i].id == 0 || db->skill[i].id == skill_id ); + if( i == MAX_ELESKILLTREE ) { + ShowWarning("Unable to load skill %d into Elemental %d's tree. Maximum number of skills per elemental has been reached.\n", skill_id, class_); + continue; + } + db->skill[i].id = skill_id; + db->skill[i].lv = skill_lv; + db->skill[i].mode = skillmode; + j++; + } + + fclose(fp); + ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"db/elemental_skill_db.txt"CL_RESET"'.\n",j); + return 0; +} + +void reload_elementaldb(void) { + read_elementaldb(); + elemental->reload_skilldb(); +} + +void reload_elemental_skilldb(void) { + elemental->read_skilldb(); +} + +int do_init_elemental(void) { + read_elementaldb(); + elemental->read_skilldb(); + + iTimer->add_timer_func_list(elemental_ai_timer,"elemental_ai_timer"); + iTimer->add_timer_interval(iTimer->gettick()+MIN_ELETHINKTIME,elemental_ai_timer,0,0,MIN_ELETHINKTIME); + + return 0; +} + +void do_final_elemental(void) { + return; +} + +/*===================================== +* Default Functions : elemental.h +* Generated by HerculesInterfaceMaker +* created by Susu +*-------------------------------------*/ +void elemental_defaults(void) { + elemental = &elemental_s; + + /* funcs */ + + elemental->class = elemental_class; + elemental->get_viewdata = elemental_get_viewdata; + + elemental->create = elemental_create; + elemental->data_received = elemental_data_received; + elemental->save = elemental_save; + + elemental->change_mode_ack = elemental_change_mode_ack; + elemental->change_mode = elemental_change_mode; + + elemental->heal = elemental_heal; + elemental->dead = elemental_dead; + + elemental->delete = elemental_delete; + elemental->summon_stop = elemental_summon_stop; + + elemental->get_lifetime = elemental_get_lifetime; + + elemental->unlocktarget = elemental_unlocktarget; + elemental->skillnotok = elemental_skillnotok; + elemental->set_target = elemental_set_target; + elemental->clean_single_effect = elemental_clean_single_effect; + elemental->clean_effect = elemental_clean_effect; + elemental->action = elemental_action; + elemental->skill_get_requirements = elemental_skill_get_requirements; + + elemental->read_skilldb = read_elemental_skilldb; + elemental->reload_elementaldb = reload_elementaldb; + elemental->reload_skilldb = reload_elemental_skilldb; + elemental->do_init_elemental = do_init_elemental; + elemental->do_final_elemental = do_final_elemental; +} diff --git a/src/map/elemental.h b/src/map/elemental.h index 96d2ed89f..ccc3bcb5f 100644 --- a/src/map/elemental.h +++ b/src/map/elemental.h @@ -1,106 +1,100 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder -#ifndef _ELEMENTAL_H_ -#define _ELEMENTAL_H_ -#include "status.h" // struct status_data, struct status_change -#include "unit.h" // struct unit_data -#define MIN_ELETHINKTIME 100 -#define MIN_ELEDISTANCE 2 -#define MAX_ELEDISTANCE 5 -#define EL_MODE_AGGRESSIVE (MD_CANMOVE|MD_AGGRESSIVE|MD_CANATTACK) -#define EL_MODE_ASSIST (MD_CANMOVE|MD_ASSIST) -#define EL_MODE_PASSIVE MD_CANMOVE -#define EL_SKILLMODE_PASIVE 0x1 -#define EL_SKILLMODE_ASSIST 0x2 -#define EL_SKILLMODE_AGGRESSIVE 0x4 -struct elemental_skill { - unsigned short id, lv; - short mode; -}; -struct s_elemental_db { - int class_; - char sprite[NAME_LENGTH], name[NAME_LENGTH]; - unsigned short lv; - short range2, range3; - struct status_data status; - struct view_data vd; - struct elemental_skill skill[MAX_ELESKILLTREE]; -}; -struct elemental_data { - struct block_list bl; - struct unit_data ud; - struct view_data *vd; - struct status_data base_status, battle_status; - struct status_change sc; - struct regen_data regen; - - struct s_elemental_db *db; - struct s_elemental elemental; - - struct map_session_data *master; - int summon_timer; - int skill_timer; - - unsigned last_thinktime, last_linktime, last_spdrain_time; - short min_chase; - 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 -* created by Susu -*-------------------------------------*/ -struct elemental_interface { - /* vars */ - struct s_elemental_db elemental_db[MAX_ELEMENTAL_CLASS]; // Elemental Database - /* funcs */ - bool (*class) (int class_); - struct view_data * (*get_viewdata) (int class_); - - int (*create) (struct map_session_data *sd, int class_, unsigned int lifetime); - int (*data_received) (struct s_elemental *ele, bool flag); - int (*save) (struct elemental_data *ed); - - int (*change_mode_ack) (struct elemental_data *ed, int mode); - int (*change_mode) (struct elemental_data *ed, int mode); - - void (*heal) (struct elemental_data *ed, int hp, int sp); - int (*dead) (struct elemental_data *ed); - - int (*delete) (struct elemental_data *ed, int reply); - void (*summon_stop) (struct elemental_data *ed); - - int (*get_lifetime) (struct elemental_data *ed); - - int (*unlocktarget) (struct elemental_data *ed); - int (*skillnotok) (uint16 skill_id, struct elemental_data *ed); - int (*set_target) (struct map_session_data *sd, struct block_list *bl); - int (*clean_single_effect) (struct elemental_data *ed, uint16 skill_id); - int (*clean_effect) (struct elemental_data *ed); - int (*action) (struct elemental_data *ed, struct block_list *bl, unsigned int tick); - struct skill_condition (*skill_get_requirements) (uint16 skill_id, uint16 skill_lv); - - int (*read_skilldb) (void); - void (*reload_elementaldb) (void); - void (*reload_skilldb) (void); - int (*do_init_elemental) (void); - void (*do_final_elemental) (void); -} elemental_s; - -struct elemental_interface *elemental; - -void elemental_defaults(void); - -#endif /* _ELEMENTAL_H_ */ +// Copyright (c) Athena Dev Teams - Licensed under GNU GPL +// For more information, see LICENCE in the main folder +#ifndef _ELEMENTAL_H_ +#define _ELEMENTAL_H_ +#include "status.h" // struct status_data, struct status_change +#include "unit.h" // struct unit_data +#define MIN_ELETHINKTIME 100 +#define MIN_ELEDISTANCE 2 +#define MAX_ELEDISTANCE 5 +#define EL_MODE_AGGRESSIVE (MD_CANMOVE|MD_AGGRESSIVE|MD_CANATTACK) +#define EL_MODE_ASSIST (MD_CANMOVE|MD_ASSIST) +#define EL_MODE_PASSIVE MD_CANMOVE +#define EL_SKILLMODE_PASIVE 0x1 +#define EL_SKILLMODE_ASSIST 0x2 +#define EL_SKILLMODE_AGGRESSIVE 0x4 +struct elemental_skill { + unsigned short id, lv; + short mode; +}; +struct s_elemental_db { + int class_; + char sprite[NAME_LENGTH], name[NAME_LENGTH]; + unsigned short lv; + short range2, range3; + struct status_data status; + struct view_data vd; + struct elemental_skill skill[MAX_ELESKILLTREE]; +}; +struct elemental_data { + struct block_list bl; + struct unit_data ud; + struct view_data *vd; + struct status_data base_status, battle_status; + struct status_change sc; + struct regen_data regen; + + struct s_elemental_db *db; + struct s_elemental elemental; + + struct map_session_data *master; + int summon_timer; + int skill_timer; + + unsigned last_thinktime, last_linktime, last_spdrain_time; + short min_chase; + 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 +* created by Susu +*-------------------------------------*/ +struct elemental_interface { + + /* vars */ + struct s_elemental_db elemental_db[MAX_ELEMENTAL_CLASS]; // Elemental Database + + /* funcs */ + bool (*class) (int class_); + struct view_data * (*get_viewdata) (int class_); + + int (*create) (struct map_session_data *sd, int class_, unsigned int lifetime); + int (*data_received) (struct s_elemental *ele, bool flag); + int (*save) (struct elemental_data *ed); + + int (*change_mode_ack) (struct elemental_data *ed, int mode); + int (*change_mode) (struct elemental_data *ed, int mode); + + void (*heal) (struct elemental_data *ed, int hp, int sp); + int (*dead) (struct elemental_data *ed); + + int (*delete) (struct elemental_data *ed, int reply); + void (*summon_stop) (struct elemental_data *ed); + + int (*get_lifetime) (struct elemental_data *ed); + + int (*unlocktarget) (struct elemental_data *ed); + int (*skillnotok) (uint16 skill_id, struct elemental_data *ed); + int (*set_target) (struct map_session_data *sd, struct block_list *bl); + int (*clean_single_effect) (struct elemental_data *ed, uint16 skill_id); + int (*clean_effect) (struct elemental_data *ed); + int (*action) (struct elemental_data *ed, struct block_list *bl, unsigned int tick); + struct skill_condition (*skill_get_requirements) (uint16 skill_id, uint16 skill_lv); + + int (*read_skilldb) (void); + void (*reload_elementaldb) (void); + void (*reload_skilldb) (void); + int (*do_init_elemental) (void); + void (*do_final_elemental) (void); +} elemental_s; + +struct elemental_interface *elemental; + +void elemental_defaults(void); + +#endif /* _ELEMENTAL_H_ */ diff --git a/src/map/guild.c b/src/map/guild.c index 995c090ec..37335f9d0 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -1883,7 +1883,7 @@ int guild_break(struct map_session_data *sd,char *name) { } /* regardless of char server allowing it, we clear the guild master's auras */ - if( (ud = unit_bl2ud(&sd->bl)) ) { + if( (ud = unit->bl2ud(&sd->bl)) ) { int count = 0; struct skill_unit_group *groups[4]; for (i=0;iskillunit[i];i++) { diff --git a/src/map/homunculus.c b/src/map/homunculus.c index 3a6ed074c..e0443f1f6 100644 --- a/src/map/homunculus.c +++ b/src/map/homunculus.c @@ -157,7 +157,7 @@ int homunculus_vaporize(struct map_session_data *sd, int flag) { memset(hd->blockskill, 0, sizeof(hd->blockskill)); clif->hominfo(sd, sd->hd, 0); homun->save(hd); - return unit_remove_map(&hd->bl, CLR_OUTSIGHT); + return unit->remove_map(&hd->bl, CLR_OUTSIGHT, ALC_MARK); } //delete a homunculus, completely "killing it". @@ -168,7 +168,7 @@ int homunculus_delete(struct homun_data *hd, int emote) { sd = hd->master; if (!sd) - return unit_free(&hd->bl,CLR_DEAD); + return unit->free(&hd->bl,CLR_DEAD); if (emote >= 0) clif->emotion(&sd->bl, emote); @@ -178,7 +178,7 @@ int homunculus_delete(struct homun_data *hd, int emote) { // Send homunculus_dead to client hd->homunculus.hp = 0; clif->hominfo(sd, hd, 0); - return unit_remove_map(&hd->bl,CLR_OUTSIGHT); + return unit->remove_map(&hd->bl,CLR_OUTSIGHT, ALC_MARK); } int homunculus_calc_skilltree(struct homun_data *hd, int flag_evolve) { @@ -403,7 +403,7 @@ bool homunculus_evolve(struct homun_data *hd) { hom->luk += 10*rnd_value(min->luk, max->luk); hom->intimacy = 500; - unit_remove_map(&hd->bl, CLR_OUTSIGHT); + unit->remove_map(&hd->bl, CLR_OUTSIGHT, ALC_MARK); iMap->addblock(&hd->bl); clif->spawn(&hd->bl); @@ -447,7 +447,7 @@ bool homunculus_mutate(struct homun_data *hd, int homun_id) { return false; } - unit_remove_map(&hd->bl, CLR_OUTSIGHT); + unit->remove_map(&hd->bl, CLR_OUTSIGHT, ALC_MARK); iMap->addblock(&hd->bl); clif->spawn(&hd->bl); @@ -745,14 +745,14 @@ bool homunculus_create(struct map_session_data *sd, struct s_homunculus *hom) { iStatus->set_viewdata(&hd->bl, hd->homunculus.class_); iStatus->change_init(&hd->bl); - unit_dataset(&hd->bl); + unit->dataset(&hd->bl); hd->ud.dir = sd->ud.dir; // Find a random valid pos around the player hd->bl.m = sd->bl.m; hd->bl.x = sd->bl.x; hd->bl.y = sd->bl.y; - unit_calc_pos(&hd->bl, sd->bl.x, sd->bl.y, sd->ud.dir); + unit->calc_pos(&hd->bl, sd->bl.x, sd->bl.y, sd->ud.dir); hd->bl.x = hd->ud.to_x; hd->bl.y = hd->ud.to_y; @@ -801,7 +801,7 @@ bool homunculus_call(struct map_session_data *sd) { homun->save(hd); } else //Warp him to master. - unit_warp(&hd->bl,sd->bl.m, sd->bl.x, sd->bl.y,CLR_OUTSIGHT); + unit->warp(&hd->bl,sd->bl.m, sd->bl.x, sd->bl.y,CLR_OUTSIGHT); return true; } diff --git a/src/map/instance.c b/src/map/instance.c index 4e145fb8f..204b7c137 100644 --- a/src/map/instance.c +++ b/src/map/instance.c @@ -344,7 +344,7 @@ int instance_cleanup_sub(struct block_list *bl, va_list ap) { npc_unload((struct npc_data *)bl,true); break; case BL_MOB: - unit_free(bl,CLR_OUTSIGHT); + unit->free(bl,CLR_OUTSIGHT); break; case BL_PET: //There is no need for this, the pet is removed together with the player. [Skotlex] diff --git a/src/map/map.c b/src/map/map.c index 90ad63adf..64e765b27 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -1307,7 +1307,7 @@ int map_search_freecell(struct block_list *src, int16 m, int16 *x,int16 *y, int1 if (iMap->getcell(m,*x,*y,CELL_CHKREACH)) { - if(flag&2 && !unit_can_reach_pos(src, *x, *y, 1)) + if(flag&2 && !unit->can_reach_pos(src, *x, *y, 1)) continue; if(flag&4) { if (spawn >= 100) return 0; //Limit of retries reached. @@ -1595,7 +1595,7 @@ int map_quit(struct map_session_data *sd) { if( sd->ed ) { elemental->clean_effect(sd->ed); - unit_remove_map(&sd->ed->bl,CLR_TELEPORT); + unit->remove_map(&sd->ed->bl,CLR_TELEPORT,ALC_MARK); } if( hChSys.local && map[sd->bl.m].channel && idb_exists(map[sd->bl.m].channel->users, sd->status.char_id) ) { @@ -1604,7 +1604,7 @@ int map_quit(struct map_session_data *sd) { clif->chsys_quit(sd); - unit_remove_map_pc(sd,CLR_TELEPORT); + unit->remove_map_pc(sd,CLR_TELEPORT); if( map[sd->bl.m].instance_id >= 0 ) { // Avoid map conflicts and warnings on next login int16 m; @@ -1630,7 +1630,7 @@ int map_quit(struct map_session_data *sd) { pc->makesavestatus(sd); pc->clean_skilltree(sd); chrif->save(sd,1); - unit_free_pc(sd); + unit->free_pc(sd); return 0; } @@ -2135,7 +2135,7 @@ int map_removemobs_sub(struct block_list *bl, va_list ap) if( md->db->mexp > 0 ) return 0; - unit_free(&md->bl,CLR_OUTSIGHT); + unit->free(&md->bl,CLR_OUTSIGHT); return 1; } @@ -2244,7 +2244,7 @@ uint8 map_calc_dir(struct block_list* src, int16 x, int16 y) if( dx == 0 && dy == 0 ) { // both are standing on the same spot //dir = 6; // aegis-style, makes knockback default to the left - dir = unit_getdir(src); // athena-style, makes knockback default to behind 'src' + dir = unit->getdir(src); // athena-style, makes knockback default to behind 'src' } else if( dx >= 0 && dy >=0 ) { // upper-right @@ -4872,7 +4872,7 @@ int cleanup_sub(struct block_list *bl, va_list ap) { npc_unload((struct npc_data *)bl,false); break; case BL_MOB: - unit_free(bl,CLR_OUTSIGHT); + unit->free(bl,CLR_OUTSIGHT); break; case BL_PET: //There is no need for this, the pet is removed together with the player. [Skotlex] @@ -4950,7 +4950,7 @@ void do_final(void) atcommand->final_msg(); skill->final(); iStatus->do_final_status(); - do_final_unit(); + unit->final(); do_final_battleground(); iDuel->do_final_duel(); elemental->do_final_elemental(); @@ -5169,6 +5169,7 @@ void map_hp_symbols(void) { HPM->share(intif,"intif"); HPM->share(mercenary,"mercenary"); HPM->share(mob,"mob"); + HPM->share(unit,"unit"); /* partial */ HPM->share(mapit,"mapit"); @@ -5215,6 +5216,7 @@ void map_load_defaults(void) { intif_defaults(); mercenary_defaults(); mob_defaults(); + unit_defaults(); } int do_init(int argc, char *argv[]) { @@ -5415,7 +5417,7 @@ int do_init(int argc, char *argv[]) elemental->do_init_elemental(); do_init_quest(); do_init_npc(); - do_init_unit(); + unit->init(); do_init_battleground(); iDuel->do_init_duel(); vending->init(); diff --git a/src/map/mercenary.c b/src/map/mercenary.c index bb30bb0d1..8bafcde97 100644 --- a/src/map/mercenary.c +++ b/src/map/mercenary.c @@ -247,7 +247,7 @@ int merc_delete(struct mercenary_data *md, int reply) mercenary->contract_stop(md); if( !sd ) - return unit_free(&md->bl, CLR_OUTSIGHT); + return unit->free(&md->bl, CLR_OUTSIGHT); if( md->devotion_flag ) { @@ -262,7 +262,7 @@ int merc_delete(struct mercenary_data *md, int reply) } clif->mercenary_message(sd, reply); - return unit_remove_map(&md->bl, CLR_OUTSIGHT); + return unit->remove_map(&md->bl, CLR_OUTSIGHT, ALC_MARK); } void merc_contract_stop(struct mercenary_data *md) @@ -309,13 +309,13 @@ int merc_data_received(struct s_mercenary *merc, bool flag) memcpy(&md->mercenary, merc, sizeof(struct s_mercenary)); iStatus->set_viewdata(&md->bl, md->mercenary.class_); iStatus->change_init(&md->bl); - unit_dataset(&md->bl); + unit->dataset(&md->bl); md->ud.dir = sd->ud.dir; md->bl.m = sd->bl.m; md->bl.x = sd->bl.x; md->bl.y = sd->bl.y; - unit_calc_pos(&md->bl, sd->bl.x, sd->bl.y, sd->ud.dir); + unit->calc_pos(&md->bl, sd->bl.x, sd->bl.y, sd->ud.dir); md->bl.x = md->ud.to_x; md->bl.y = md->ud.to_y; diff --git a/src/map/mob.c b/src/map/mob.c index 49120fdaf..c566262df 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -283,7 +283,7 @@ struct mob_data* mob_spawn_dataset(struct spawn_data *data) { md->skill_idx = -1; iStatus->set_viewdata(&md->bl, md->class_); iStatus->change_init(&md->bl); - unit_dataset(&md->bl); + unit->dataset(&md->bl); iMap->addiddb(&md->bl); return md; @@ -597,7 +597,7 @@ int mob_spawn_guardian_sub(int tid, unsigned int tick, int id, intptr_t data) } else { if (md->guardian_data->number >= 0 && md->guardian_data->number < MAX_GUARDIANS && md->guardian_data->castle->guardian[md->guardian_data->number].visible) guild->castledatasave(md->guardian_data->castle->castle_id, 10+md->guardian_data->number,0); - unit_free(&md->bl,CLR_OUTSIGHT); //Remove guardian. + unit->free(&md->bl,CLR_OUTSIGHT); //Remove guardian. } return 0; } @@ -783,7 +783,7 @@ int mob_can_reach(struct mob_data *md,struct block_list *bl,int range, int state easy = 1; break; } - return unit_can_reach_bl(&md->bl, bl, range, easy, NULL, NULL); + return unit->can_reach_bl(&md->bl, bl, range, easy, NULL, NULL); } /*========================================== @@ -846,7 +846,7 @@ int mob_setdelayspawn(struct mob_data *md) struct mob_db *db; if (!md->spawn) //Doesn't has respawn data! - return unit_free(&md->bl,CLR_DEAD); + return unit->free(&md->bl,CLR_DEAD); spawntime = md->spawn->delay1; //Base respawn time if (md->spawn->delay2) //random variance @@ -900,10 +900,8 @@ int mob_spawn (struct mob_data *md) md->last_thinktime = tick; if (md->bl.prev != NULL) - unit_remove_map(&md->bl,CLR_RESPAWN); - else - if (md->spawn && md->class_ != md->spawn->class_) - { + 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_); md->db = mob->db(md->class_); @@ -1226,7 +1224,7 @@ int mob_ai_sub_hard_slavemob(struct mob_data *md,unsigned int tick) md->master_dist > MAX_MINCHASE ){ md->master_dist = 0; - unit_warp(&md->bl,bl->m,bl->x,bl->y,CLR_TELEPORT); + unit->warp(&md->bl,bl->m,bl->x,bl->y,CLR_TELEPORT); return 1; } @@ -1235,12 +1233,12 @@ int mob_ai_sub_hard_slavemob(struct mob_data *md,unsigned int tick) // 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)) + 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) - && unit_walktoxy(&md->bl, x, y, 0)) + && unit->walktoxy(&md->bl, x, y, 0)) return 1; } } else if (bl->m != md->bl.m && map_flag_gvg(md->bl.m)) { @@ -1252,7 +1250,7 @@ int mob_ai_sub_hard_slavemob(struct mob_data *md,unsigned int tick) //Avoid attempting to lock the master's target too often to avoid unnecessary overload. [Skotlex] if (DIFF_TICK(md->last_linktime, tick) < MIN_MOBLINKTIME && !md->target_id) { - struct unit_data *ud = unit_bl2ud(bl); + struct unit_data *ud = unit->bl2ud(bl); md->last_linktime = tick; if (ud) { @@ -1316,7 +1314,7 @@ int mob_unlocktarget(struct mob_data *md, unsigned int tick) if (md->target_id) { md->target_id=0; md->ud.target_to = 0; - unit_set_target(&md->ud, 0); + unit->set_target(&md->ud, 0); } return 0; } @@ -1332,7 +1330,7 @@ int mob_randomwalk(struct mob_data *md,unsigned int tick) nullpo_ret(md); if(DIFF_TICK(md->next_walktime,tick)>0 || - !unit_can_move(&md->bl) || + !unit->can_move(&md->bl) || !(status_get_mode(&md->bl)&MD_CANMOVE)) return 0; @@ -1345,7 +1343,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((iMap->getcell(md->bl.m,x,y,CELL_CHKPASS)) && unit->walktoxy(&md->bl,x,y,1)){ break; } } @@ -1389,7 +1387,7 @@ int mob_warpchase(struct mob_data *md, struct block_list *target) iMap->foreachinrange (mob->warpchase_sub, &md->bl, md->db->range2, BL_NPC, target, &warp, &distance); - if (warp && unit_walktobl(&md->bl, &warp->bl, 1, 1)) + if (warp && unit->walktobl(&md->bl, &warp->bl, 1, 1)) return 1; return 0; } @@ -1430,7 +1428,7 @@ bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick) view_range = md->db->range2; mode = status_get_mode(&md->bl); - can_move = (mode&MD_CANMOVE)&&unit_can_move(&md->bl); + can_move = (mode&MD_CANMOVE)&&unit->can_move(&md->bl); if (md->target_id) { //Check validity of current target. [Skotlex] @@ -1464,7 +1462,7 @@ bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick) ) && md->state.attacked_count++ >= RUDE_ATTACKED_COUNT && !mob->skill_use(md, tick, MSC_RUDEATTACKED) // If can't rude Attack - && can_move && unit_escape(&md->bl, tbl, rnd()%10 +1)) // Attempt escape + && can_move && unit->escape(&md->bl, tbl, rnd()%10 +1)) // Attempt escape { //Escaped md->attacked_id = 0; return true; @@ -1489,7 +1487,7 @@ bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick) { // 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)) + && !tbl && unit->escape(&md->bl, abl, rnd()%10 +1)) { //Escaped. //TODO: Maybe it shouldn't attempt to run if it has another, valid target? md->attacked_id = 0; @@ -1555,7 +1553,7 @@ bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick) return true;/* we are already moving */ iMap->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) ) + 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. */ } } @@ -1586,7 +1584,7 @@ bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick) if (!can_move) //Stuck. Wait before walking. return true; md->state.skillstate = MSS_LOOT; - if (!unit_walktobl(&md->bl, tbl, 1, 1)) + if (!unit->walktobl(&md->bl, tbl, 1, 1)) mob->unlocktarget(md, tick); //Can't loot... return true; } @@ -1610,7 +1608,7 @@ bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick) { //Give them walk act/delay to properly mimic players. [Skotlex] clif->takeitem(&md->bl,tbl); md->ud.canact_tick = tick + md->status.amotion; - unit_set_walkdelay(&md->bl, tick, md->status.amotion, 1); + unit->set_walkdelay(&md->bl, tick, md->status.amotion, 1); } //Clear item. iMap->clearflooritem (tbl); @@ -1627,7 +1625,7 @@ bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick) if(tbl->type == BL_PC) mob->log_damage(md, tbl, 0); //Log interaction (counts as 'attacker' for the exp bonus) - unit_attack(&md->bl,tbl->id,1); + unit->attack(&md->bl,tbl->id,1); return true; } @@ -1657,7 +1655,7 @@ bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick) //Follow up if possible. if(!mob->can_reach(md, tbl, md->min_chase, MSS_RUSH) || - !unit_walktobl(&md->bl, tbl, md->status.rhw.range, 2)) + !unit->walktobl(&md->bl, tbl, md->status.rhw.range, 2)) mob->unlocktarget(md,tick); return true; @@ -1738,7 +1736,7 @@ int mob_ai_sub_lazy(struct mob_data *md, va_list args) return 0; } - if( DIFF_TICK(md->next_walktime,tick) < 0 && (status_get_mode(&md->bl)&MD_CANMOVE) && unit_can_move(&md->bl) ) + if( DIFF_TICK(md->next_walktime,tick) < 0 && (status_get_mode(&md->bl)&MD_CANMOVE) && unit->can_move(&md->bl) ) { if( map[md->bl.m].users > 0 ) { @@ -1876,7 +1874,7 @@ int mob_timer_delete(int tid, unsigned int tick, int id, intptr_t data) } //for Alchemist CANNIBALIZE [Lupus] md->deletetimer = INVALID_TIMER; - unit_free(bl, CLR_TELEPORT); + unit->free(bl, CLR_TELEPORT); } return 0; } @@ -2673,7 +2671,7 @@ int mob_guardian_guildchange(struct mob_data *md) } else { if (md->guardian_data->number >= 0 && md->guardian_data->number < MAX_GUARDIANS && md->guardian_data->castle->guardian[md->guardian_data->number].visible) guild->castledatasave(md->guardian_data->castle->castle_id, 10+md->guardian_data->number, 0); - unit_free(&md->bl,CLR_OUTSIGHT); //Remove guardian. + unit->free(&md->bl,CLR_OUTSIGHT); //Remove guardian. } return 0; } @@ -2684,7 +2682,7 @@ int mob_guardian_guildchange(struct mob_data *md) ShowError("mob_guardian_guildchange: New Guild (id %d) does not exists!\n", md->guardian_data->guild_id); if (md->guardian_data->number >= 0 && md->guardian_data->number < MAX_GUARDIANS) guild->castledatasave(md->guardian_data->castle->castle_id, 10+md->guardian_data->number, 0); - unit_free(&md->bl,CLR_OUTSIGHT); + unit->free(&md->bl,CLR_OUTSIGHT); return 0; } @@ -2757,7 +2755,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); + unit->skillcastcancel(&md->bl, 0); iStatus->set_viewdata(&md->bl, class_); clif->class_change(&md->bl, md->vd->class_, 1); status_calc_mob(md, 1); @@ -2810,7 +2808,7 @@ int mob_warpslave_sub(struct block_list *bl,va_list ap) return 0; iMap->search_freecell(master, 0, &x, &y, range, range, 0); - unit_warp(&md->bl, master->m, x, y,CLR_RESPAWN); + unit->warp(&md->bl, master->m, x, y,CLR_RESPAWN); return 1; } @@ -3148,11 +3146,11 @@ int mobskill_use(struct mob_data *md, unsigned int tick, int event) case MSC_SLAVELT: // slave < num flag = (mob->countslave(&md->bl) < c2 ); break; case MSC_ATTACKPCGT: // attack pc > num - flag = (unit_counttargeted(&md->bl) > c2); break; + flag = (unit->counttargeted(&md->bl) > c2); break; case MSC_SLAVELE: // slave <= num flag = (mob->countslave(&md->bl) <= c2 ); break; case MSC_ATTACKPCGE: // attack pc >= num - flag = (unit_counttargeted(&md->bl) >= c2); break; + flag = (unit->counttargeted(&md->bl) >= c2); break; case MSC_AFTERSKILL: flag = (md->ud.skill_id == c2); break; case MSC_RUDEATTACKED: @@ -3162,7 +3160,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=iMap->id2bl(md->master_id)) && unit->counttargeted(fbl) > 0); break; case MSC_ALCHEMIST: flag = (md->state.alchemist); break; @@ -3214,7 +3212,7 @@ int mobskill_use(struct mob_data *md, unsigned int tick, int event) 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) ) + !unit->skilluse_pos2(&md->bl, x, y,ms[i].skill_id, ms[i].skill_lv,ms[i].casttime, ms[i].cancel) ) { iMap->freeblock_unlock(); continue; @@ -3252,7 +3250,7 @@ int mobskill_use(struct mob_data *md, unsigned int tick, int event) 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) ) + !unit->skilluse_id2(&md->bl, bl->id,ms[i].skill_id, ms[i].skill_lv,ms[i].casttime, ms[i].cancel) ) { iMap->freeblock_unlock(); continue; diff --git a/src/map/mob.h b/src/map/mob.h index 7e9ecbd28..4ac8f7bcb 100644 --- a/src/map/mob.h +++ b/src/map/mob.h @@ -243,8 +243,8 @@ struct item_drop_list { }; -#define mob_stop_walking(md, type) unit_stop_walking(&(md)->bl, type) -#define mob_stop_attack(md) unit_stop_attack(&(md)->bl) +#define mob_stop_walking(md, type) unit->stop_walking(&(md)->bl, type) +#define mob_stop_attack(md) unit->stop_attack(&(md)->bl) #define mob_is_battleground(md) ( map[(md)->bl.m].flag.battleground && ((md)->class_ == MOBID_BARRICADE2 || ((md)->class_ >= MOBID_FOOD_STOR && (md)->class_ <= MOBID_PINK_CRYST)) ) #define mob_is_gvg(md) (map[(md)->bl.m].flag.gvg_castle && ( (md)->class_ == MOBID_EMPERIUM || (md)->class_ == MOBID_BARRICADE1 || (md)->class_ == MOBID_GUARIDAN_STONE1 || (md)->class_ == MOBID_GUARIDAN_STONE2) ) #define mob_is_treasure(md) (((md)->class_ >= MOBID_TREAS01 && (md)->class_ <= MOBID_TREAS40) || ((md)->class_ >= MOBID_TREAS41 && (md)->class_ <= MOBID_TREAS49)) diff --git a/src/map/npc.c b/src/map/npc.c index c7c537e1f..c4ef1bcf9 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -971,7 +971,7 @@ int npc_touch_areanpc(struct map_session_data* sd, int16 m, int16 x, int16 y) if( npc_ontouch_event(sd,map[m].npc[i]) > 0 && npc_ontouch2_event(sd,map[m].npc[i]) > 0 ) { // failed to run OnTouch event, so just click the npc - struct unit_data *ud = unit_bl2ud(&sd->bl); + struct unit_data *ud = unit->bl2ud(&sd->bl); if( ud && ud->walkpath.path_pos < ud->walkpath.path_len ) { // Since walktimer always == INVALID_TIMER at this time, we stop walking manually. [Inkfish] clif->fixpos(&sd->bl); @@ -1021,7 +1021,7 @@ int npc_touch_areanpc2(struct mob_data *md) xs = iMap->mapindex2mapid(map[m].npc[i]->u.warp.mapindex); if( m < 0 ) break; // Cannot Warp between map servers - if( unit_warp(&md->bl, xs, map[m].npc[i]->u.warp.x, map[m].npc[i]->u.warp.y, CLR_OUTSIGHT) == 0 ) + if( unit->warp(&md->bl, xs, map[m].npc[i]->u.warp.x, map[m].npc[i]->u.warp.y, CLR_OUTSIGHT) == 0 ) return 1; // Warped break; case SCRIPT: @@ -3796,7 +3796,7 @@ int npc_reload(void) { npc_unload((struct npc_data *)bl, false); break; case BL_MOB: - unit_free(bl,CLR_OUTSIGHT); + unit->free(bl,CLR_OUTSIGHT); break; } } diff --git a/src/map/pc.c b/src/map/pc.c index ce275a21c..d502d9a3a 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -1082,7 +1082,7 @@ bool pc_authok(struct map_session_data *sd, int login_id2, time_t expiration_tim //Set here because we need the inventory data for weapon sprite parsing. iStatus->set_viewdata(&sd->bl, sd->status.class_); - unit_dataset(&sd->bl); + unit->dataset(&sd->bl); sd->guild_x = -1; sd->guild_y = -1; @@ -4933,7 +4933,7 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y npc_event_dequeue(sd); npc_script_event(sd, NPCE_LOGOUT); //remove from map, THEN change x/y coordinates - unit_remove_map_pc(sd,clrtype); + unit->remove_map_pc(sd,clrtype); sd->mapindex = mapindex; sd->bl.x=x; sd->bl.y=y; @@ -4942,7 +4942,7 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y chrif->changemapserver(sd, ip, (short)port); //Free session data from this map server [Kevin] - unit_free_pc(sd); + unit->free_pc(sd); return 0; } @@ -4965,7 +4965,7 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y } if(sd->bl.prev != NULL){ - unit_remove_map_pc(sd,clrtype); + unit->remove_map_pc(sd,clrtype); clif->changemap(sd,m,x,y); // [MouseJstr] } else if(sd->state.active) //Tag player for rewarping after map-loading is done. [Skotlex] @@ -5730,9 +5730,9 @@ int pc_follow_timer(int tid, unsigned int tick, int id, intptr_t data) 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((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); + unit->walktobl(&sd->bl, tbl, 5, 0); } else pc->setpos(sd, map_id2index(tbl->m), tbl->x, tbl->y, CLR_TELEPORT); } @@ -5753,7 +5753,7 @@ int pc_stop_following (struct map_session_data *sd) sd->followtarget = -1; sd->ud.target_to = 0; - unit_stop_walking(&sd->bl, 1); + unit->stop_walking(&sd->bl, 1); return 0; } diff --git a/src/map/pc.h b/src/map/pc.h index 231f369d8..c8e7e17d5 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -645,8 +645,8 @@ enum equip_pos { // Rune Knight Dragon #define pc_isridingdragon(sd) ( (sd)->sc.option&OPTION_DRAGON ) -#define pc_stop_walking(sd, type) unit_stop_walking(&(sd)->bl, type) -#define pc_stop_attack(sd) unit_stop_attack(&(sd)->bl) +#define pc_stop_walking(sd, type) unit->stop_walking(&(sd)->bl, type) +#define pc_stop_attack(sd) unit->stop_attack(&(sd)->bl) //Weapon check considering dual wielding. #define pc_check_weapontype(sd, type) ((type)&((sd)->status.weapon < MAX_WEAPON_TYPE? \ diff --git a/src/map/pet.c b/src/map/pet.c index 796edd0b8..d7f7c29c8 100644 --- a/src/map/pet.c +++ b/src/map/pet.c @@ -121,9 +121,9 @@ int pet_attackskill(struct pet_data *pd, int target_id) 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); + 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. - unit_skilluse_id(&pd->bl,(inf&INF_SELF_SKILL?pd->bl.id:bl->id), pd->a_skill->id, pd->a_skill->lv); + 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; @@ -309,7 +309,7 @@ static int pet_return_egg(struct map_session_data *sd, struct pet_data *pd) iMap->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); + unit->free(&pd->bl,CLR_OUTSIGHT); status_calc_pc(sd,0); sd->status.pet_id = 0; @@ -356,13 +356,13 @@ int pet_data_init(struct map_session_data *sd, struct s_pet *pet) pd->db = mob->db(pet->class_); memcpy(&pd->pet, pet, sizeof(struct s_pet)); iStatus->set_viewdata(&pd->bl, pet->class_); - unit_dataset(&pd->bl); + unit->dataset(&pd->bl); pd->ud.dir = sd->ud.dir; pd->bl.m = sd->bl.m; pd->bl.x = sd->bl.x; pd->bl.y = sd->bl.y; - unit_calc_pos(&pd->bl, sd->bl.x, sd->bl.y, sd->ud.dir); + unit->calc_pos(&pd->bl, sd->bl.x, sd->bl.y, sd->ud.dir); pd->bl.x = pd->ud.to_x; pd->bl.y = pd->ud.to_y; @@ -526,7 +526,7 @@ int pet_catch_process2(struct map_session_data* sd, int target_id) if(rnd()%10000 < pet_catch_rate) { - unit_remove_map(&md->bl,CLR_OUTSIGHT); + unit->remove_map(&md->bl,CLR_OUTSIGHT,ALC_MARK); status_kill(&md->bl); clif->pet_roulette(sd,1); intif->create_pet(sd->status.account_id,sd->status.char_id,pet_db[i].class_,mob->db(pet_db[i].class_)->lv, @@ -793,7 +793,7 @@ static int pet_randomwalk(struct pet_data *pd,unsigned int tick) Assert((pd->msd == 0) || (pd->msd->pd == pd)); - if(DIFF_TICK(pd->next_walktime,tick) < 0 && unit_can_move(&pd->bl)) { + if(DIFF_TICK(pd->next_walktime,tick) < 0 && unit->can_move(&pd->bl)) { const int retrycount=20; int i,x,y,c,d=12-pd->move_fail_count; if(d<5) d=5; @@ -801,7 +801,7 @@ static 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(iMap->getcell(pd->bl.m,x,y,CELL_CHKPASS) && unit->walktoxy(&pd->bl,x,y,0)){ pd->move_fail_count=0; break; } @@ -862,7 +862,7 @@ static int pet_ai_sub_hard(struct pet_data *pd, struct map_session_data *sd, uns pd->status.speed = (sd->battle_status.speed>>1); if(pd->status.speed <= 0) pd->status.speed = 1; - if (!unit_walktobl(&pd->bl, &sd->bl, 3, 0)) + if (!unit->walktobl(&pd->bl, &sd->bl, 3, 0)) pet_randomwalk(pd,tick); return 0; } @@ -899,8 +899,8 @@ static int pet_ai_sub_hard(struct pet_data *pd, struct map_session_data *sd, uns if(pd->ud.walktimer != INVALID_TIMER && check_distance_blxy(&sd->bl, pd->ud.to_x,pd->ud.to_y, 3)) return 0; //Already walking to him - unit_calc_pos(&pd->bl, sd->bl.x, sd->bl.y, sd->ud.dir); - if(!unit_walktoxy(&pd->bl,pd->ud.to_x,pd->ud.to_y,0)) + unit->calc_pos(&pd->bl, sd->bl.x, sd->bl.y, sd->ud.dir); + if(!unit->walktoxy(&pd->bl,pd->ud.to_x,pd->ud.to_y,0)) pet_randomwalk(pd,tick); return 0; @@ -914,16 +914,16 @@ static int pet_ai_sub_hard(struct pet_data *pd, struct map_session_data *sd, uns { //enemy targetted if(!battle->check_range(&pd->bl,target,pd->status.rhw.range)) { //Chase - if(!unit_walktobl(&pd->bl, target, pd->status.rhw.range, 2)) + if(!unit->walktobl(&pd->bl, target, pd->status.rhw.range, 2)) pet_unlocktarget(pd); //Unreachable target. return 0; } //Continuous attack. - unit_attack(&pd->bl, pd->target_id, 1); + unit->attack(&pd->bl, pd->target_id, 1); } else { //Item Targeted, attempt loot if (!check_distance_bl(&pd->bl, target, 1)) { //Out of range - if(!unit_walktobl(&pd->bl, target, 1, 1)) //Unreachable target. + if(!unit->walktobl(&pd->bl, target, 1, 1)) //Unreachable target. pet_unlocktarget(pd); return 0; } else{ @@ -971,7 +971,7 @@ static int pet_ai_sub_hard_lootsearch(struct block_list *bl,va_list ap) if(sd_charid && sd_charid != pd->msd->status.char_id) return 0; - if(unit_can_reach_bl(&pd->bl,bl, pd->db->range2, 1, NULL, NULL) && + if(unit->can_reach_bl(&pd->bl,bl, pd->db->range2, 1, NULL, NULL) && ((*target) == NULL || //New target closer than previous one. !check_distance_bl(&pd->bl, *target, distance_bl(&pd->bl, bl)))) { @@ -1197,9 +1197,9 @@ int pet_skill_support_timer(int tid, unsigned int tick, int id, intptr_t data) pet_stop_walking(pd,1); pd->s_skill->timer=iTimer->add_timer(tick+pd->s_skill->delay*1000,pet_skill_support_timer,sd->bl.id,0); if (skill->get_inf(pd->s_skill->id) & INF_GROUND_SKILL) - unit_skilluse_pos(&pd->bl, sd->bl.x, sd->bl.y, pd->s_skill->id, pd->s_skill->lv); + unit->skilluse_pos(&pd->bl, sd->bl.x, sd->bl.y, pd->s_skill->id, pd->s_skill->lv); else - unit_skilluse_id(&pd->bl, sd->bl.id, pd->s_skill->id, pd->s_skill->lv); + unit->skilluse_id(&pd->bl, sd->bl.id, pd->s_skill->id, pd->s_skill->lv); return 0; } diff --git a/src/map/pet.h b/src/map/pet.h index b46f55229..4060b5382 100644 --- a/src/map/pet.h +++ b/src/map/pet.h @@ -126,8 +126,8 @@ int pet_skill_bonus_timer(int tid, unsigned int tick, int id, intptr_t data); // int pet_recovery_timer(int tid, unsigned int tick, int id, intptr_t data); // [Valaris] int pet_heal_timer(int tid, unsigned int tick, int id, intptr_t data); // [Valaris] -#define pet_stop_walking(pd, type) unit_stop_walking(&(pd)->bl, type) -#define pet_stop_attack(pd) unit_stop_attack(&(pd)->bl) +#define pet_stop_walking(pd, type) unit->stop_walking(&(pd)->bl, type) +#define pet_stop_attack(pd) unit->stop_attack(&(pd)->bl) int read_petdb(void); int do_init_pet(void); diff --git a/src/map/script.c b/src/map/script.c index 337f99cf0..70c9bd9f1 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -12635,7 +12635,7 @@ BUILDIN(npcspeed) { nd = (struct npc_data *)iMap->id2bl(st->oid); if( nd ) { - unit_bl2ud2(&nd->bl); // ensure nd->ud is safe to edit + unit->bl2ud2(&nd->bl); // ensure nd->ud is safe to edit nd->speed = speed; nd->ud->state.speed_changed = 1; } @@ -12651,13 +12651,13 @@ BUILDIN(npcwalkto) { y=script_getnum(st,3); if( nd ) { - unit_bl2ud2(&nd->bl); // ensure nd->ud is safe to edit + unit->bl2ud2(&nd->bl); // ensure nd->ud is safe to edit if (!nd->status.hp) { status_calc_npc(nd, true); } else { status_calc_npc(nd, false); } - unit_walktoxy(&nd->bl,x,y,0); + unit->walktoxy(&nd->bl,x,y,0); } return true; @@ -12667,8 +12667,8 @@ BUILDIN(npcstop) { struct npc_data *nd = (struct npc_data *)iMap->id2bl(st->oid); if( nd ) { - unit_bl2ud2(&nd->bl); // ensure nd->ud is safe to edit - unit_stop_walking(&nd->bl,1|4); + unit->bl2ud2(&nd->bl); // ensure nd->ud is safe to edit + unit->stop_walking(&nd->bl,1|4); } return true; @@ -14918,15 +14918,15 @@ BUILDIN(unitwalk) { } if( bl->type == BL_NPC ) { - unit_bl2ud2(bl); // ensure the ((TBL_NPC*)bl)->ud is safe to edit + unit->bl2ud2(bl); // ensure the ((TBL_NPC*)bl)->ud is safe to edit } if( script_hasdata(st,4) ) { int x = script_getnum(st,3); int y = script_getnum(st,4); - script_pushint(st, unit_walktoxy(bl,x,y,0));// We'll use harder calculations. + 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,iMap->id2bl(map_id),65025,1)); } return true; @@ -14972,8 +14972,8 @@ BUILDIN(unitwarp) { map = iMap->mapname2mapid(mapname); if( map >= 0 && bl != NULL ) { - unit_bl2ud2(bl); // ensure ((TBL_NPC*)bl)->ud is safe to edit - script_pushint(st, unit_warp(bl,map,x,y,CLR_OUTSIGHT)); + unit->bl2ud2(bl); // ensure ((TBL_NPC*)bl)->ud is safe to edit + script_pushint(st, unit->warp(bl,map,x,y,CLR_OUTSIGHT)); } else { script_pushint(st, 0); } @@ -15039,7 +15039,7 @@ BUILDIN(unitattack) script_pushint(st, 0); return false; } - script_pushint(st, unit_walktobl(unit_bl, target_bl, 65025, 2)); + script_pushint(st, unit->walktobl(unit_bl, target_bl, 65025, 2)); return true; } @@ -15055,9 +15055,9 @@ BUILDIN(unitstop) { bl = iMap->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); + unit->bl2ud2(bl); // ensure ((TBL_NPC*)bl)->ud is safe to edit + unit->stop_attack(bl); + unit->stop_walking(bl,4); if( bl->type == BL_MOB ) ((TBL_MOB*)bl)->target_id = 0; } @@ -15139,7 +15139,7 @@ BUILDIN(unitskilluseid) status_calc_npc(((TBL_NPC*)bl), false); } } - unit_skilluse_id(bl, target_id, skill_id, skill_lv); + unit->skilluse_id(bl, target_id, skill_id, skill_lv); } return true; @@ -15174,7 +15174,7 @@ BUILDIN(unitskillusepos) status_calc_npc(((TBL_NPC*)bl), false); } } - unit_skilluse_pos(bl, skill_x, skill_y, skill_id, skill_lv); + unit->skilluse_pos(bl, skill_x, skill_y, skill_id, skill_lv); } return true; @@ -16373,12 +16373,12 @@ static int buildin_mobuseskill_sub(struct block_list *bl,va_list ap) return 0; if( md->ud.skilltimer != INVALID_TIMER ) // Cancel the casting skill. - unit_skillcastcancel(bl,0); + unit->skillcastcancel(bl,0); if( skill->get_casttype(skill_id) == CAST_GROUND ) - unit_skilluse_pos2(&md->bl, tbl->x, tbl->y, skill_id, skill_lv, casttime, cancel); + unit->skilluse_pos2(&md->bl, tbl->x, tbl->y, skill_id, skill_lv, casttime, cancel); else - unit_skilluse_id2(&md->bl, tbl->id, skill_id, skill_lv, casttime, cancel); + unit->skilluse_id2(&md->bl, tbl->id, skill_id, skill_lv, casttime, cancel); clif->emotion(&md->bl, emotion); @@ -16475,7 +16475,7 @@ BUILDIN(pushpc) dx = dirx[dir]; dy = diry[dir]; - unit_blown(&sd->bl, dx, dy, cells, 0); + unit->blown(&sd->bl, dx, dy, cells, 0); return true; } @@ -17140,9 +17140,9 @@ BUILDIN(npcskill) } if (skill->get_inf(skill_id)&INF_GROUND_SKILL) { - unit_skilluse_pos(&nd->bl, sd->bl.x, sd->bl.y, skill_id, skill_level); + unit->skilluse_pos(&nd->bl, sd->bl.x, sd->bl.y, skill_id, skill_level); } else { - unit_skilluse_id(&nd->bl, sd->bl.id, skill_id, skill_level); + unit->skilluse_id(&nd->bl, sd->bl.id, skill_id, skill_level); } return true; diff --git a/src/map/skill.c b/src/map/skill.c index 025ed4486..08da07137 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -863,7 +863,7 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, uint break; case WZ_FIREPILLAR: - unit_set_walkdelay(bl, tick, skill->get_time2(skill_id, skill_lv), 1); + unit->set_walkdelay(bl, tick, skill->get_time2(skill_id, skill_lv), 1); break; case MG_FROSTDIVER: @@ -1447,7 +1447,7 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, uint } if( sd && sd->ed && sc && !iStatus->isdead(bl) && !skill_id ){ - struct unit_data *ud = unit_bl2ud(src); + struct unit_data *ud = unit->bl2ud(src); if( sc->data[SC_WILD_STORM_OPTION] ) temp = sc->data[SC_WILD_STORM_OPTION]->val2; @@ -1559,7 +1559,7 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, uint } sd->state.autocast = 0; //Set canact delay. [Skotlex] - ud = unit_bl2ud(src); + ud = unit->bl2ud(src); if (ud) { rate = skill->delay_fix(src, temp, skill_lv); if (DIFF_TICK(ud->canact_tick, tick + rate) < 0){ @@ -1900,7 +1900,7 @@ int skill_counter_additional_effect (struct block_list* src, struct block_list * } dstsd->state.autocast = 0; //Set canact delay. [Skotlex] - ud = unit_bl2ud(bl); + ud = unit->bl2ud(bl); if (ud) { rate = skill->delay_fix(bl, skill_id, skill_lv); if (DIFF_TICK(ud->canact_tick, tick + rate) < 0){ @@ -2103,7 +2103,7 @@ int skill_blown(struct block_list* src, struct block_list* target, int count, in dy = -diry[dir]; } - return unit_blown(target, dx, dy, count, flag); // send over the proper flag + return unit->blown(target, dx, dy, count, flag); // send over the proper flag } @@ -2338,7 +2338,7 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds sce->timer = iTimer->add_timer(tick+sce->val4, iStatus->change_timer, src->id, SC_COMBOATTACK); break; } - unit_cancel_combo(src); // Cancel combo wait + unit->cancel_combo(src); // Cancel combo wait break; default: if( src == dsrc ) // Ground skills are exceptions. [Inkfish] @@ -2617,7 +2617,7 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds if (dmg.dmg_lv >= ATK_MISS && (type = skill->get_walkdelay(skill_id, skill_lv)) > 0) { //Skills with can't walk delay also stop normal attacking for that //duration when the attack connects. [Skotlex] - struct unit_data *ud = unit_bl2ud(src); + struct unit_data *ud = unit->bl2ud(src); if (ud && DIFF_TICK(ud->attackabletime, tick + type) < 0) ud->attackabletime = tick + type; } @@ -2650,7 +2650,7 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds case SR_KNUCKLEARROW: case GN_WALLOFTHORN: case EL_FIRE_MANTLE: - dir = unit_getdir(bl);// backwards + dir = unit->getdir(bl);// backwards break; // This ensures the storm randomly pushes instead of exactly a cell backwards per official mechanics. case WZ_STORMGUST: @@ -2688,7 +2688,7 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds } break; case GN_WALLOFTHORN: - unit_stop_walking(bl,1); + unit->stop_walking(bl,1); skill->blown(dsrc,bl,dmg.blewcount,dir, 0x2 ); clif->fixpos(bl); break; @@ -3037,7 +3037,7 @@ int skill_check_condition_mercenary(struct block_list *bl, int skill_id, int lv, if( !type ) switch( state ) { case ST_MOVE_ENABLE: - if( !unit_can_move(bl) ) { + if( !unit->can_move(bl) ) { clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0); return 0; } @@ -3086,7 +3086,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 unit_data *ud = unit_bl2ud(src); + struct unit_data *ud = unit->bl2ud(src); struct skill_timerskill *skl; int range; @@ -3116,11 +3116,11 @@ int skill_timerskill(int tid, unsigned int tick, int id, intptr_t data) { switch(skl->skill_id) { case RG_INTIMIDATE: - if (unit_warp(src,-1,-1,-1,CLR_TELEPORT) == 0) { + 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)) - unit_warp(target, -1, x, y, CLR_TELEPORT); + unit->warp(target, -1, x, y, CLR_TELEPORT); } break; case BA_FROSTJOKER: @@ -3193,11 +3193,11 @@ int skill_timerskill(int tid, unsigned int tick, int id, intptr_t data) { break; case SC_FATALMENACE: if( src == target ) // Casters Part - unit_warp(src, -1, skl->x, skl->y, 3); + 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); - unit_warp(target,-1,x,y,3); + unit->warp(target,-1,x,y,3); } break; case LG_MOONSLASHER: @@ -3241,7 +3241,7 @@ int skill_timerskill(int tid, unsigned int tick, int id, intptr_t data) { case SC_ESCAPE: if( skl->type < 4+skl->skill_lv ){ clif->skill_damage(src,src,tick,0,0,-30000,1,skl->skill_id,skl->skill_lv,5); - skill->blown(src,src,1,unit_getdir(src),0); + skill->blown(src,src,1,unit->getdir(src),0); skill->addtimerskill(src,tick+80,src->id,0,0,skl->skill_id,skl->skill_lv,skl->type+1,0); } break; @@ -3300,7 +3300,7 @@ int skill_addtimerskill (struct block_list *src, unsigned int tick, int target, nullpo_retr(1, src); if (src->prev == NULL) return 0; - ud = unit_bl2ud(src); + ud = unit->bl2ud(src); nullpo_retr(1, ud); ARR_FIND( 0, MAX_SKILLTIMERSKILL, i, ud->skilltimerskill[i] == 0 ); @@ -3328,7 +3328,7 @@ int skill_cleartimerskill (struct block_list *src) int i; struct unit_data *ud; nullpo_ret(src); - ud = unit_bl2ud(src); + ud = unit->bl2ud(src); nullpo_ret(ud); for(i=0;icalc_dir(bl, src->x, src->y); // teleport to target (if not on WoE grounds) - if( !map_flag_gvg2(src->m) && !map[src->m].flag.battleground && unit_movepos(src, bl->x, bl->y, 0, 1) ) + if( !map_flag_gvg2(src->m) && !map[src->m].flag.battleground && unit->movepos(src, bl->x, bl->y, 0, 1) ) clif->slide(src, bl->x, bl->y); // cause damage and knockback if the path to target was a straight one @@ -3588,7 +3588,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint skill->blown(src, bl, dist, dir, 0); //HACK: since knockback officially defaults to the left, the client also turns to the left... therefore, // make the caster look in the direction of the target - unit_setdir(src, (dir+4)%8); + unit->setdir(src, (dir+4)%8); } } @@ -3626,12 +3626,12 @@ 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); + 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) { 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] - unit_setdir(bl,dir); + unit->setdir(bl,dir); } else if (sd) clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); @@ -3691,7 +3691,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint else if( dir == 7 || dir < 2 ) y = i; else y = 0; if( (mbl == src || (!map_flag_gvg2(src->m) && !map[src->m].flag.battleground) ) && // only NJ_ISSEN don't have slide effect in GVG - unit_movepos(src, mbl->x+x, mbl->y+y, 1, 1) ) { + unit->movepos(src, mbl->x+x, mbl->y+y, 1, 1) ) { clif->slide(src, src->x, src->y); clif->fixpos(src); clif->spiritball(src); @@ -3830,7 +3830,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint c = skill->get_blewcount(skill_id,skill_lv); // keep moving target in the direction that src is looking, square by square for(i=0;iblown(src,bl,1,(unit_getdir(src)+4)%8,0x1)) + 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 @@ -4073,17 +4073,17 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint { //You don't move on GVG grounds. short x, y; iMap->search_freecell(bl, 0, &x, &y, 1, 1, 0); - if (unit_movepos(src, x, y, 0, 0)) + if (unit->movepos(src, x, y, 0, 0)) clif->slide(src,src->x,src->y); } status_change_end(src, SC_HIDING, INVALID_TIMER); 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,iMap->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); + skill->blown(src,bl,distance_bl(src,bl)-1,unit->getdir(src),0); if( battle->check_target(src,bl,BCT_ENEMY) > 0 ) skill->attack(BF_WEAPON,src,src,bl,skill_id,skill_lv,tick,flag); break; @@ -4100,7 +4100,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint else if( dir == 7 || dir < 2 ) y = -2; else y = 0; - if( unit_movepos(src, bl->x+x, bl->y+y, 1, 1) ) + if( unit->movepos(src, bl->x+x, bl->y+y, 1, 1) ) { clif->slide(src,bl->x+x,bl->y+y); clif->fixpos(src); // the official server send these two packts. @@ -4270,7 +4270,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint short y[8]={1,1,0,-1,-1,-1,0,1}; uint8 dir = iMap->calc_dir(bl, src->x, src->y); - if( unit_movepos(src, bl->x+x[dir], bl->y+y[dir], 1, 1) ) + if( unit->movepos(src, bl->x+x[dir], bl->y+y[dir], 1, 1) ) { clif->slide(src, bl->x+x[dir], bl->y+y[dir]); clif->fixpos(src); @@ -4350,7 +4350,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint } break; case LG_PINPOINTATTACK: - if( !map_flag_gvg2(src->m) && !map[src->m].flag.battleground && unit_movepos(src, bl->x, bl->y, 1, 1) ) + if( !map_flag_gvg2(src->m) && !map[src->m].flag.battleground && unit->movepos(src, bl->x, bl->y, 1, 1) ) clif->slide(src,bl->x,bl->y); skill->attack(BF_WEAPON,src,src,bl,skill_id,skill_lv,tick,flag); break; @@ -4375,7 +4375,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint break; case SR_KNUCKLEARROW: - if( !map_flag_gvg2(src->m) && !map[src->m].flag.battleground && unit_movepos(src, bl->x, bl->y, 1, 1) ) { + if( !map_flag_gvg2(src->m) && !map[src->m].flag.battleground && unit->movepos(src, bl->x, bl->y, 1, 1) ) { clif->slide(src,bl->x,bl->y); clif->fixpos(src); // Aegis send this packet too. } @@ -4523,7 +4523,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 MH_TINDER_BREAKER: - if (unit_movepos(src, bl->x, bl->y, 1, 1)) { + if (unit->movepos(src, bl->x, bl->y, 1, 1)) { #if PACKETVER >= 20111005 clif->snap(src, bl->x, bl->y); #else @@ -4600,7 +4600,7 @@ int skill_castend_id(int tid, unsigned int tick, int id, intptr_t data) return 0;// not found } - ud = unit_bl2ud(src); + ud = unit->bl2ud(src); if( ud == NULL ) { ShowDebug("skill_castend_id: ud == NULL (tid=%d, id=%d)\n", tid, id); @@ -4615,7 +4615,7 @@ int skill_castend_id(int tid, unsigned int tick, int id, intptr_t data) return 0; } - if(ud->skill_id != SA_CASTCANCEL && ud->skill_id != SO_SPELLFIST) {// otherwise handled in unit_skillcastcancel() + if(ud->skill_id != SA_CASTCANCEL && ud->skill_id != SO_SPELLFIST) {// otherwise handled in unit->skillcastcancel() if( ud->skilltimer != tid ) { ShowError("skill_castend_id: Timer mismatch %d!=%d!\n", ud->skilltimer, tid); ud->skilltimer = INVALID_TIMER; @@ -4668,7 +4668,7 @@ 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); + 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)) { break; } @@ -4782,7 +4782,7 @@ int skill_castend_id(int tid, unsigned int tick, int id, intptr_t data) } if (ud->walktimer != INVALID_TIMER && ud->skill_id != TK_RUN && ud->skill_id != RA_WUGDASH) - unit_stop_walking(src,1); + unit->stop_walking(src,1); if( !sd || sd->skillitem != ud->skill_id || skill->get_delay(ud->skill_id,ud->skill_lv) ) ud->canact_tick = tick + skill->delay_fix(src, ud->skill_id, ud->skill_lv); //Tests show wings don't overwrite the delay but skill scrolls do. [Inkfish] @@ -4819,7 +4819,7 @@ int skill_castend_id(int tid, unsigned int tick, int id, intptr_t data) } } if (skill->get_state(ud->skill_id) != ST_MOVE_ENABLE) - unit_set_walkdelay(src, tick, battle_config.default_walk_delay+skill->get_walkdelay(ud->skill_id, ud->skill_lv), 1); + unit->set_walkdelay(src, tick, battle_config.default_walk_delay+skill->get_walkdelay(ud->skill_id, ud->skill_lv), 1); if(battle_config.skill_log && battle_config.skill_log&src->type) ShowInfo("Type %d, ID %d skill castend id [id =%d, lv=%d, target ID %d]\n", @@ -4886,7 +4886,7 @@ int skill_castend_id(int tid, unsigned int tick, int id, intptr_t data) if( dir > 2 && dir < 6 ) y = -2; else if( dir == 7 || dir < 2 ) y = 2; else y = 0; - if (unit_movepos(src, src->x+x, src->y+y, 1, 1)) + if (unit->movepos(src, src->x+x, src->y+y, 1, 1)) { //Display movement + animation. clif->slide(src,src->x,src->y); clif->spiritball(src); @@ -5217,14 +5217,14 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui } else {// mob-casted - struct unit_data *ud = unit_bl2ud(src); + struct unit_data *ud = unit->bl2ud(src); int inf = skill->get_inf(abra_skill_id); if (!ud) break; if (inf&INF_SELF_SKILL || inf&INF_SUPPORT_SKILL) { if (src->type == BL_PET) bl = (struct block_list*)((TBL_PET*)src)->msd; if (!bl) bl = src; - unit_skilluse_id(src, bl->id, abra_skill_id, abra_skill_lv); + unit->skilluse_id(src, bl->id, abra_skill_id, abra_skill_lv); } else { //Assume offensive skills int target_id = 0; if (ud->target) @@ -5238,9 +5238,9 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui if (skill->get_casttype(abra_skill_id) == CAST_GROUND) { bl = iMap->id2bl(target_id); if (!bl) bl = src; - unit_skilluse_pos(src, bl->x, bl->y, abra_skill_id, abra_skill_lv); + unit->skilluse_pos(src, bl->x, bl->y, abra_skill_id, abra_skill_lv); } else - unit_skilluse_id(src, target_id, abra_skill_id, abra_skill_lv); + unit->skilluse_id(src, target_id, abra_skill_id, abra_skill_lv); } } } @@ -5474,10 +5474,10 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui break; case TK_JUMPKICK: - /* Check if the target is an enemy; if not, skill should fail so the character doesn't unit_movepos (exploitable) */ + /* Check if the target is an enemy; if not, skill should fail so the character doesn't unit->movepos (exploitable) */ if( battle->check_target(src, bl, BCT_ENEMY) > 0 ) { - if( unit_movepos(src, bl->x, bl->y, 1, 1) ) + if( unit->movepos(src, bl->x, bl->y, 1, 1) ) { skill->attack(BF_WEAPON,src,src,bl,skill_id,skill_lv,tick,flag); clif->slide(src,bl->x,bl->y); @@ -5726,7 +5726,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui iMap->freeblock_unlock(); return 0; } - unit_skillcastcancel(bl, 2); + unit->skillcastcancel(bl, 2); if( tsc && tsc->count ) { @@ -6069,7 +6069,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui iMap->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)); + clif->skill_nodamage(src,bl,skill_id,skill_lv,sc_start4(bl,type,100,skill_lv,unit->getdir(bl),0,0,0)); if (sd) // If the client receives a skill-use packet inmediately before a walkok packet, it will discard the walk packet! [Skotlex] clif->walkok(sd); // So aegis has to resend the walk ok. break; @@ -6364,12 +6364,12 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui else clif->skill_warppoint(sd,skill_id,skill_lv, (unsigned short)-1,sd->status.save_point.map,0,0); } else - unit_warp(bl,-1,-1,-1,CLR_TELEPORT); + unit->warp(bl,-1,-1,-1,CLR_TELEPORT); break; case NPC_EXPULSION: clif->skill_nodamage(src,bl,skill_id,skill_lv,1); - unit_warp(bl,-1,-1,-1,CLR_TELEPORT); + unit->warp(bl,-1,-1,-1,CLR_TELEPORT); break; case AL_HOLYWATER: @@ -6704,12 +6704,12 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case TF_BACKSLIDING: //This is the correct implementation as per packet logging information. [Skotlex] clif->skill_nodamage(src,bl,skill_id,skill_lv,1); - skill->blown(src,bl,skill->get_blewcount(skill_id,skill_lv),unit_getdir(bl),0); + skill->blown(src,bl,skill->get_blewcount(skill_id,skill_lv),unit->getdir(bl),0); break; case TK_HIGHJUMP: { - int x,y, dir = unit_getdir(src); + int x,y, dir = unit->getdir(src); //Fails on noteleport maps, except for GvG and BG maps [Skotlex] if( map[src->m].flag.noteleport && @@ -6725,7 +6725,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)) { clif->slide(src,x,y); - unit_movepos(src, x, y, 1, 0); + unit->movepos(src, x, y, 1, 0); } } break; @@ -6733,7 +6733,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case SA_CASTCANCEL: case SO_SPELLFIST: clif->skill_nodamage(src,bl,skill_id,skill_lv,1); - unit_skillcastcancel(src,1); + unit->skillcastcancel(src,1); if(sd) { int sp = skill->get_sp(sd->skill_id_old,sd->skill_lv_old); if( skill_id == SO_SPELLFIST ){ @@ -6756,7 +6756,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui iStatus->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); + struct unit_data *ud = unit->bl2ud(bl); int bl_skill_id=0,bl_skill_lv=0,hp = 0; if (!ud || ud->skilltimer == INVALID_TIMER) break; //Nothing to cancel. @@ -6773,7 +6773,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui hp = tstatus->max_hp/50; //Recover 2% HP [Skotlex] clif->skill_nodamage(src,bl,skill_id,skill_lv,1); - unit_skillcastcancel(bl,0); + unit->skillcastcancel(bl,0); sp = skill->get_sp(bl_skill_id,bl_skill_lv); status_zap(bl, hp, sp); @@ -6879,7 +6879,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case NPC_BARRIER: { int skill_time = skill->get_time(skill_id,skill_lv); - struct unit_data *ud = unit_bl2ud(bl); + struct unit_data *ud = unit->bl2ud(bl); if (clif->skill_nodamage(src,bl,skill_id,skill_lv, sc_start(bl,type,100,skill_lv,skill_time)) && ud) { //Disable attacking/acting/moving for skill's duration. @@ -6955,10 +6955,10 @@ 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. - unit_stop_attack(src); + uint8 dir = (bl == src)?unit->getdir(src):iMap->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) + if (unit->walktoxy(src, src->x + skill_lv * mask[dir][0], src->y + skill_lv * mask[dir][1], 2) && md) md->state.skillstate = MSS_WALK; //Otherwise it isn't updated in the ai. } break; @@ -7152,7 +7152,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case BD_ENCORE: clif->skill_nodamage(src,bl,skill_id,skill_lv,1); if(sd) - unit_skilluse_id(src,src->id,sd->skill_id_dance,sd->skill_lv_dance); + unit->skilluse_id(src,src->id,sd->skill_id_dance,sd->skill_lv_dance); break; case AS_SPLASHER: @@ -7198,7 +7198,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui return 0; } - unit_skillcastcancel(bl,0); + unit->skillcastcancel(bl,0); if(tsc && tsc->count){ status_change_end(bl, SC_FREEZE, INVALID_TIMER); @@ -7361,7 +7361,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case 5: // 2000HP heal, random teleported iStatus->heal(src, 2000, 0, 0); if( !map_flag_vs(bl->m) ) - unit_warp(bl, -1,-1,-1, CLR_TELEPORT); + unit->warp(bl, -1,-1,-1, CLR_TELEPORT); break; case 6: // random 2 other effects if (count == -1) @@ -7605,10 +7605,10 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui if (hd) skill->blockhomun_start(hd, skill_id, skill->get_time2(skill_id,skill_lv)); - if (unit_movepos(src,bl->x,bl->y,0,0)) { + if (unit->movepos(src,bl->x,bl->y,0,0)) { clif->skill_nodamage(src,src,skill_id,skill_lv,1); // Homunc clif->slide(src,bl->x,bl->y) ; - if (unit_movepos(bl,x,y,0,0)) + if (unit->movepos(bl,x,y,0,0)) { clif->skill_nodamage(bl,bl,skill_id,skill_lv,1); // Master clif->slide(bl,x,y) ; @@ -8233,7 +8233,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui return 0; } if( sd && pc_isridingwug(sd) ) { - clif->skill_nodamage(src,bl,skill_id,skill_lv,sc_start4(bl,type,100,skill_lv,unit_getdir(bl),0,0,1)); + clif->skill_nodamage(src,bl,skill_id,skill_lv,sc_start4(bl,type,100,skill_lv,unit->getdir(bl),0,0,1)); clif->walkok(sd); } break; @@ -8249,7 +8249,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case NC_F_SIDESLIDE: case NC_B_SIDESLIDE: { - uint8 dir = (skill_id == NC_F_SIDESLIDE) ? (unit_getdir(src)+4)%8 : unit_getdir(src); + uint8 dir = (skill_id == NC_F_SIDESLIDE) ? (unit->getdir(src)+4)%8 : unit->getdir(src); skill->blown(src,bl,skill->get_blewcount(skill_id,skill_lv),dir,0); clif->slide(src,src->x,src->y); clif->skill_nodamage(src,bl,skill_id,skill_lv,1); @@ -8561,7 +8561,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui if( sc_start2(bl, type, 100, skill_lv, src->id, skill->get_time(skill_id, skill_lv))) { if( bl->type == BL_MOB ) mob->unlocktarget((TBL_MOB*)bl,iTimer->gettick()); - unit_stop_attack(bl); + unit->stop_attack(bl); clif->bladestop(src, bl->id, 1); iMap->freeblock_unlock(); return 1; @@ -8796,14 +8796,14 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui sd->skillitemlv = improv_skill_lv; clif->item_skill(sd, improv_skill_id, improv_skill_lv); } else { - struct unit_data *ud = unit_bl2ud(src); + struct unit_data *ud = unit->bl2ud(src); int inf = skill->get_inf(improv_skill_id); if (!ud) break; if (inf&INF_SELF_SKILL || inf&INF_SUPPORT_SKILL) { if (src->type == BL_PET) bl = (struct block_list*)((TBL_PET*)src)->msd; if (!bl) bl = src; - unit_skilluse_id(src, bl->id, improv_skill_id, improv_skill_lv); + unit->skilluse_id(src, bl->id, improv_skill_id, improv_skill_lv); } else { int target_id = 0; if (ud->target) @@ -8817,9 +8817,9 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui if (skill->get_casttype(improv_skill_id) == CAST_GROUND) { bl = iMap->id2bl(target_id); if (!bl) bl = src; - unit_skilluse_pos(src, bl->x, bl->y, improv_skill_id, improv_skill_lv); + unit->skilluse_pos(src, bl->x, bl->y, improv_skill_id, improv_skill_lv); } else - unit_skilluse_id(src, target_id, improv_skill_id, improv_skill_lv); + unit->skilluse_id(src, target_id, improv_skill_id, improv_skill_lv); } } } @@ -9158,7 +9158,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui mob->spawn( md ); pc->setinvincibletimer(sd,500);// unlock target lock clif->skill_nodamage(src,bl,skill_id,skill_lv,1); - skill->blown(src,bl,skill->get_blewcount(skill_id,skill_lv),unit_getdir(bl),0); + skill->blown(src,bl,skill->get_blewcount(skill_id,skill_lv),unit->getdir(bl),0); } } break; @@ -9198,11 +9198,11 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui break; } - if (unit_movepos(src, bl->x, bl->y, 0, 0)) { + if (unit->movepos(src, bl->x, bl->y, 0, 0)) { clif->skill_nodamage(src, src, skill_id, skill_lv, 1); clif->slide(src, bl->x, bl->y) ; sc_start(src, SC_CONFUSION, 25, skill_lv, skill->get_time(skill_id, skill_lv)); - if ( !is_boss(bl) && unit_stop_walking(&sd->bl, 1) && unit_movepos(bl, x, y, 0, 0) ) + if ( !is_boss(bl) && unit->stop_walking(&sd->bl, 1) && unit->movepos(bl, x, y, 0, 0) ) { if( dstsd && pc_issit(dstsd) ) pc->setstand(dstsd); @@ -9389,7 +9389,7 @@ int skill_castend_pos(int tid, unsigned int tick, int id, intptr_t data) struct block_list* src = iMap->id2bl(id); int maxcount; struct map_session_data *sd; - struct unit_data *ud = unit_bl2ud(src); + struct unit_data *ud = unit->bl2ud(src); struct mob_data *md; nullpo_ret(ud); @@ -9485,7 +9485,7 @@ int skill_castend_pos(int tid, unsigned int tick, int id, intptr_t data) src->type, src->id, ud->skill_id, ud->skill_lv, ud->skillx, ud->skilly); if (ud->walktimer != INVALID_TIMER) - unit_stop_walking(src,1); + unit->stop_walking(src,1); if( !sd || sd->skillitem != ud->skill_id || skill->get_delay(ud->skill_id,ud->skill_lv) ) ud->canact_tick = tick + skill->delay_fix(src, ud->skill_id, ud->skill_lv); @@ -9511,7 +9511,7 @@ int skill_castend_pos(int tid, unsigned int tick, int id, intptr_t data) // break; // } // } - unit_set_walkdelay(src, tick, battle_config.default_walk_delay+skill->get_walkdelay(ud->skill_id, ud->skill_lv), 1); + 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(); skill->castend_pos2(src,ud->skillx,ud->skilly,ud->skill_id,ud->skill_lv,tick,0); @@ -9969,7 +9969,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui return 0; // not to consume item. case MO_BODYRELOCATION: - if (unit_movepos(src, x, y, 1, 1)) { + if (unit->movepos(src, x, y, 1, 1)) { #if PACKETVER >= 20111005 clif->snap(src, src->x, src->y); #else @@ -9981,7 +9981,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui break; case NJ_SHADOWJUMP: if( !map_flag_gvg2(src->m) && !map[src->m].flag.battleground ) { //You don't move on GVG grounds. - unit_movepos(src, x, y, 1, 0); + unit->movepos(src, x, y, 1, 0); clif->slide(src,x,y); } status_change_end(src, SC_HIDING, INVALID_TIMER); @@ -10248,7 +10248,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui case SC_FEINTBOMB: skill->unitsetting(src,skill_id,skill_lv,x,y,0); // Set bomb on current Position clif->skill_nodamage(src,src,skill_id,skill_lv,1); - if( skill->blown(src,src,6,unit_getdir(src),0) ) + if( skill->blown(src,src,6,unit->getdir(src),0) ) skill->castend_nodamage_id(src,src,TF_HIDING,1,tick,0x2); break; @@ -10312,7 +10312,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui break; case GN_FIRE_EXPANSION: { int i; - struct unit_data *ud = unit_bl2ud(src); + struct unit_data *ud = unit->bl2ud(src); if( !ud ) break; @@ -11093,7 +11093,7 @@ int skill_unit_onplace (struct skill_unit *src, struct block_list *bl, unsigned } else if(bl->type == BL_MOB && battle_config.mob_warp&2) { int16 m = iMap->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); + unit->warp(bl,m,sg->val2>>16,sg->val2&0xffff,CLR_TELEPORT); } } break; @@ -11182,7 +11182,7 @@ int skill_unit_onplace (struct skill_unit *src, struct block_list *bl, unsigned break; if (ss == bl) //Also needed to prevent infinite loop crash. break; - skill->blown(ss,bl,skill->get_blewcount(sg->skill_id,sg->skill_lv),unit_getdir(bl),0); + skill->blown(ss,bl,skill->get_blewcount(sg->skill_id,sg->skill_lv),unit->getdir(bl),0); break; case UNT_WALLOFTHORN: @@ -11399,7 +11399,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns case UNT_SKIDTRAP: { - skill->blown(&src->bl,bl,skill->get_blewcount(sg->skill_id,sg->skill_lv),unit_getdir(bl),0); + skill->blown(&src->bl,bl,skill->get_blewcount(sg->skill_id,sg->skill_lv),unit->getdir(bl),0); sg->unit_id = UNT_USED_TRAPS; clif->changetraplook(&src->bl, UNT_USED_TRAPS); sg->limit=DIFF_TICK(tick,sg->tick)+1500; @@ -11415,7 +11415,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns if( td ) sec = DIFF_TICK(td->tick, tick); if( sg->unit_id == UNT_MANHOLE || battle_config.skill_trap_type || !map_flag_gvg2(src->bl.m) ) { - unit_movepos(bl, src->bl.x, src->bl.y, 0, 0); + unit->movepos(bl, src->bl.x, src->bl.y, 0, 0); clif->fixpos(bl); } sg->val2 = bl->id; @@ -11644,7 +11644,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns int i = battle->check_target(&src->bl, bl, BCT_ENEMY); if( i > 0 && !(status_get_mode(bl)&MD_BOSS) ) { // knock-back any enemy except Boss - skill->blown(&src->bl, bl, 2, unit_getdir(bl), 0); + skill->blown(&src->bl, bl, 2, unit->getdir(bl), 0); clif->fixpos(bl); } @@ -11720,7 +11720,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns if( tsd && !map[bl->m].flag.noteleport ) pc->randomwarp(tsd,3); else if( bl->type == BL_MOB && battle_config.mob_warp&8 ) - unit_warp(bl,-1,-1,-1,3); + unit->warp(bl,-1,-1,-1,3); break; case UNT_REVERBERATION: @@ -11851,21 +11851,21 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns distance_xy(src->bl.x, src->bl.y, bl->x, bl->y) <= range)// don't consider outer bounderies sc_start(bl, type, 100, sg->skill_lv, sec); - if( unit_is_walking(bl) && // wait until target stop walking + if( unit->is_walking(bl) && // wait until target stop walking ( tsc && tsc->data[type] && tsc->data[type]->val4 >= tsc->data[type]->val3-range )) break; if( tsc && ( !tsc->data[type] || (tsc->data[type] && tsc->data[type]->val4 < 1 ) ) ) break; - if( unit_is_walking(bl) && + if( unit->is_walking(bl) && distance_xy(src->bl.x, src->bl.y, bl->x, bl->y) > range )// going outside of boundaries? then force it to stop - unit_stop_walking(bl,1); + unit->stop_walking(bl,1); - if( !unit_is_walking(bl) && + if( !unit->is_walking(bl) && distance_xy(src->bl.x, src->bl.y, bl->x, bl->y) <= range && // only snap if the target is inside the range or src->bl.x != bl->x && src->bl.y != bl->y){// diagonal position parallel to VE's center - unit_movepos(bl, src->bl.x, src->bl.y, 0, 0); + unit->movepos(bl, src->bl.x, src->bl.y, 0, 0); clif->fixpos(bl); } } @@ -12193,7 +12193,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); - dir = (unit_getdir(&sd->bl) + dir)%8; //This adjusts dir to account for the direction the sd is facing. + 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) p_sd[(*c)++]=tsd->bl.id; @@ -12217,7 +12217,7 @@ int skill_check_condition_char_sub (struct block_list *bl, va_list ap) { default: //Warning: Assuming Ensemble Dance/Songs for code speed. [Skotlex] { uint16 skill_lv; - if(pc_issit(tsd) || !unit_can_move(&tsd->bl)) + if(pc_issit(tsd) || !unit->can_move(&tsd->bl)) return 0; if (sd->status.sex != tsd->status.sex && (tsd->class_&MAPID_UPPERMASK) == MAPID_BARDDANCER && @@ -12546,7 +12546,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id return 0; } } - else if( !unit_can_move(&sd->bl) ) + else if( !unit->can_move(&sd->bl) ) { //Placed here as ST_MOVE_ENABLE should not apply if rooted or on a combo. [Skotlex] clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); return 0; @@ -12590,7 +12590,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id return 0; } if(sc->data[SC_COMBOATTACK]->val1 != skill_id && !( sd && sd->status.base_level >= 90 && pc->famerank(sd->status.char_id, MAPID_TAEKWON) )) { //Cancel combo wait. - unit_cancel_combo(&sd->bl); + unit->cancel_combo(&sd->bl); return 0; } break; //Combo ready. @@ -13093,7 +13093,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id if (sc && sc->data[SC_COMBOATTACK] && sc->data[SC_COMBOATTACK]->val1 == skill_id) sd->ud.canmove_tick = iTimer->gettick(); //When using a combo, cancel the can't move delay to enable the skill. [Skotlex] - if (!unit_can_move(&sd->bl)) { + if (!unit->can_move(&sd->bl)) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); return 0; } @@ -14614,7 +14614,7 @@ int skill_attack_area (struct block_list *bl, va_list ap) *------------------------------------------*/ int skill_clear_group (struct block_list *bl, int flag) { - struct unit_data *ud = unit_bl2ud(bl); + struct unit_data *ud = unit->bl2ud(bl); struct skill_unit_group *group[MAX_SKILLUNITGROUP]; int i, count=0; @@ -14653,7 +14653,7 @@ int skill_clear_group (struct block_list *bl, int flag) * Returns the first element field found [Skotlex] *------------------------------------------*/ struct skill_unit_group *skill_locate_element_field(struct block_list *bl) { - struct unit_data *ud = unit_bl2ud(bl); + struct unit_data *ud = unit->bl2ud(bl); int i; nullpo_ret(bl); if (!ud) return NULL; @@ -14859,7 +14859,7 @@ int skill_cell_overlap(struct block_list *bl, va_list ap) { int skill_chastle_mob_changetarget(struct block_list *bl,va_list ap) { struct mob_data* md; - struct unit_data*ud = unit_bl2ud(bl); + struct unit_data*ud = unit->bl2ud(bl); struct block_list *from_bl; struct block_list *to_bl; md = (struct mob_data*)bl; @@ -15247,7 +15247,7 @@ static int skill_get_new_group_id(void) struct skill_unit_group* skill_initunitgroup (struct block_list* src, int count, uint16 skill_id, uint16 skill_lv, int unit_id, int limit, int interval) { - struct unit_data* ud = unit_bl2ud( src ); + struct unit_data* ud = unit->bl2ud( src ); struct skill_unit_group* group; int i; @@ -15318,7 +15318,7 @@ int skill_delunitgroup(struct skill_unit_group *group, const char* file, int lin } src=iMap->id2bl(group->src_id); - ud = unit_bl2ud(src); + 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; @@ -15442,7 +15442,7 @@ int skill_delunitgroup(struct skill_unit_group *group, const char* file, int lin *------------------------------------------*/ int skill_clear_unitgroup (struct block_list *src) { - struct unit_data *ud = unit_bl2ud(src); + struct unit_data *ud = unit->bl2ud(src); nullpo_ret(ud); @@ -15464,7 +15464,7 @@ struct skill_unit_group_tickset *skill_unitgrouptickset_search (struct block_lis if (group->interval==-1) return NULL; - ud = unit_bl2ud(bl); + ud = unit->bl2ud(bl); if (!ud) return NULL; set = ud->skillunittick; diff --git a/src/map/status.c b/src/map/status.c index 2db38cb15..6efc0b6ca 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -1225,7 +1225,7 @@ int status_damage(struct block_list *src,struct block_list *target,int64 in_hp, if(sc->data[SC_KAGEMUSYA] && --(sc->data[SC_KAGEMUSYA]->val3) <= 0) status_change_end(target, SC_KAGEMUSYA, INVALID_TIMER); } - unit_skillcastcancel(target, 2); + unit->skillcastcancel(target, 2); } status->hp-= hp; @@ -1253,13 +1253,13 @@ int status_damage(struct block_list *src,struct block_list *target,int64 in_hp, } if( src && target->type == BL_PC && (((TBL_PC*)target)->disguise) > 0 ) {// stop walking when attacked in disguise to prevent walk-delay bug - unit_stop_walking( target, 1 ); + unit->stop_walking( target, 1 ); } if( status->hp || (flag&8) ) { //Still lives or has been dead before this damage. if (walkdelay) - unit_set_walkdelay(target, iTimer->gettick(), walkdelay, 0); + unit->set_walkdelay(target, iTimer->gettick(), walkdelay, 0); return (int)(hp+sp); } @@ -1339,13 +1339,13 @@ int status_damage(struct block_list *src,struct block_list *target,int64 in_hp, iStatus->change_clear(target,0); if(flag&4) //Delete from memory. (also invokes map removal code) - unit_free(target,CLR_DEAD); + unit->free(target,CLR_DEAD); else if(flag&2) //remove from map - unit_remove_map(target,CLR_DEAD); + unit->remove_map(target,CLR_DEAD,ALC_MARK); else { //Some death states that would normally be handled by unit_remove_map - unit_stop_attack(target); - unit_stop_walking(target,1); - unit_skillcastcancel(target,0); + unit->stop_attack(target); + unit->stop_walking(target,1); + unit->skillcastcancel(target,0); clif->clearunit_area(target,CLR_DEAD); skill->unit_move(target,iTimer->gettick(),4); skill->cleartimerskill(target); @@ -1628,8 +1628,8 @@ int status_check_skilluse(struct block_list *src, struct block_list *target, uin return 0; 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); + if( unit->bl2ud(src) && (unit->bl2ud(src))->walktimer == INVALID_TIMER ) + unit->walktobl(src, iMap->id2bl(sc->data[SC_DC_WINKCHARM]->val2), 3, 1); clif->emotion(src, E_LV); return 0; } @@ -2088,7 +2088,7 @@ int status_calc_mob_(struct mob_data* md, bool first) if (flag&16 && mbl) { //Max HP setting from Summon Flora/marine Sphere - struct unit_data *ud = unit_bl2ud(mbl); + struct unit_data *ud = unit->bl2ud(mbl); //Remove special AI when this is used by regular mobs. if (mbl->type == BL_MOB && !((TBL_MOB*)mbl)->special_state.ai) md->special_state.ai = 0; @@ -3743,7 +3743,7 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag) } if(flag&SCB_SPEED) { - struct unit_data *ud = unit_bl2ud(bl); + struct unit_data *ud = unit->bl2ud(bl); status->speed = status_calc_speed(bl, sc, b_status->speed); //Re-walk to adjust speed (we do not check if walktimer != INVALID_TIMER @@ -3798,9 +3798,9 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag) status->mode = status_calc_mode(bl, sc, b_status->mode); //Since mode changed, reset their state. if (!(status->mode&MD_CANATTACK)) - unit_stop_attack(bl); + unit->stop_attack(bl); if (!(status->mode&MD_CANMOVE)) - unit_stop_walking(bl,1); + unit->stop_walking(bl,1); } // No status changes alter these yet. @@ -5883,7 +5883,7 @@ defType status_get_def(struct block_list *bl) { struct unit_data *ud; struct status_data *status = iStatus->get_status_data(bl); int def = status?status->def:0; - ud = unit_bl2ud(bl); + ud = unit->bl2ud(bl); if (ud && ud->skilltimer != INVALID_TIMER) def -= def * skill->get_castdef(ud->skill_id)/100; @@ -7554,7 +7554,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val case SC_HANBOK: if (!vd) return 0; //Store previous values as they could be removed. - unit_stop_attack(bl); + unit->stop_attack(bl); break; case SC_NOCHAT: // [GodLesZ] FIXME: is this correct? a hardcoded interval of 60sec? what about configuration ?_? @@ -7914,11 +7914,11 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val //val3: When set, this combo time should NOT delay attack/movement //val3: TK: Last used kick //val4: TK: Combo time - struct unit_data *ud = unit_bl2ud(bl); + struct unit_data *ud = unit->bl2ud(bl); if (ud && !val3) { tick += 300 * battle_config.combo_delay_rate/100; ud->attackabletime = iTimer->gettick()+tick; - unit_set_walkdelay(bl, iTimer->gettick(), tick, 1); + unit->set_walkdelay(bl, iTimer->gettick(), tick, 1); } val3 = 0; val4 = tick; @@ -8498,7 +8498,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val break; case SC_UNLIMITED_HUMMING_VOICE: { - struct unit_data *ud = unit_bl2ud(bl); + struct unit_data *ud = unit->bl2ud(bl); if( ud == NULL ) return 0; ud->state.skillcastcancel = 0; val3 = 15 - (2 * val2); @@ -8861,9 +8861,9 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val status_change_end(bl, SC_DANCING, INVALID_TIMER); // Cancel cast when get status [LuzZza] if (battle_config.sc_castcancel&bl->type) - unit_skillcastcancel(bl, 0); + unit->skillcastcancel(bl, 0); case SC_WHITEIMPRISON: - unit_stop_attack(bl); + unit->stop_attack(bl); case SC_STOP: case SC_CONFUSION: case SC_RG_CCONFINE_M: @@ -8882,11 +8882,11 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val case SC_KYOUGAKU: case SC_NEEDLE_OF_PARALYZE: case SC_DEATHBOUND: - unit_stop_walking(bl,1); + unit->stop_walking(bl,1); break; case SC_ANKLESNARE: if( battle_config.skill_trap_type || !map_flag_gvg(bl->m) ) - unit_stop_walking(bl,1); + unit->stop_walking(bl,1); break; case SC_HIDING: case SC_CLOAKING: @@ -8895,11 +8895,11 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val case SC_WEIGHTOVER90: case SC_CAMOUFLAGE: case SC_SIREN: - unit_stop_attack(bl); + unit->stop_attack(bl); break; case SC_SILENCE: if (battle_config.sc_castcancel&bl->type) - unit_skillcastcancel(bl, 0); + unit->skillcastcancel(bl, 0); break; /* */ case SC_ITEMSCRIPT: @@ -9148,9 +9148,9 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val break; case SC_RUN: { - struct unit_data *ud = unit_bl2ud(bl); + struct unit_data *ud = unit->bl2ud(bl); if( ud ) - ud->state.running = unit_run(bl); + ud->state.running = unit->run(bl); } break; case SC_CASH_BOSS_ALARM: @@ -9167,9 +9167,9 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val **/ case SC_WUGDASH: { - struct unit_data *ud = unit_bl2ud(bl); + struct unit_data *ud = unit->bl2ud(bl); if( ud ) - ud->state.running = unit_wugdash(bl, sd); + ud->state.running = unit->wugdash(bl, sd); } break; case SC_COMBOATTACK: @@ -9365,14 +9365,14 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const break; case SC_RUN: { - struct unit_data *ud = unit_bl2ud(bl); + struct unit_data *ud = unit->bl2ud(bl); bool begin_spurt = true; if (ud) { if(!ud->state.running) begin_spurt = false; ud->state.running = 0; if (ud->walktimer != INVALID_TIMER) - unit_stop_walking(bl,1); + unit->stop_walking(bl,1); } if (begin_spurt && sce->val1 >= 7 && DIFF_TICK(iTimer->gettick(), sce->val4) <= 1000 && @@ -9681,11 +9681,11 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const break; case SC_WUGDASH: { - struct unit_data *ud = unit_bl2ud(bl); + struct unit_data *ud = unit->bl2ud(bl); if (ud) { ud->state.running = 0; if (ud->walktimer != -1) - unit_stop_walking(bl,1); + unit->stop_walking(bl,1); } } break; @@ -10131,8 +10131,8 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) case SC_STONE: if(sc->opt1 == OPT1_STONEWAIT && sce->val3) { sce->val4 = 0; - unit_stop_walking(bl,1); - unit_stop_attack(bl); + unit->stop_walking(bl,1); + unit->stop_attack(bl); sc->opt1 = OPT1_STONE; clif->changeoption(bl); sc_timer_next(1000+tick,iStatus->change_timer, bl->id, data ); @@ -10392,7 +10392,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) if( --(sce->val4) > 0 ) { int damage = status->max_hp/100; // {Target VIT x (New Poison Research Skill Level - 3)} + (Target HP/100) damage += status->vit * (sce->val1 - 3); - unit_skillcastcancel(bl,2); + 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); if( sc->data[type] ) { @@ -10420,8 +10420,8 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) if( !flag ) { // Random Skill Cast if (sd && !pc_issit(sd)) { //can't cast if sit int mushroom_skill_id = 0, i; - unit_stop_attack(bl); - unit_skillcastcancel(bl,1); + unit->stop_attack(bl); + unit->skillcastcancel(bl,1); do { i = rnd() % MAX_SKILL_MAGICMUSHROOM_DB; mushroom_skill_id = skill_magicmushroom_db[i].skill_id; @@ -10618,7 +10618,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) iMap->freeblock_lock(); damage = sce->val3; iStatus->damage(src, bl, damage, 0, clif->damage(bl,bl,tick,status->amotion,status->dmotion+200,damage,1,0,0), 1); - unit_skillcastcancel(bl,1); + unit->skillcastcancel(bl,1); if ( sc->data[type] ) { sc_timer_next(1000 + tick, iStatus->change_timer, bl->id, data); } @@ -11299,7 +11299,7 @@ static int status_natural_heal(struct block_list* bl, va_list args) if (flag && regen->state.overweight) flag=0; - ud = unit_bl2ud(bl); + ud = unit->bl2ud(bl); if (flag&(RGN_HP|RGN_SHP|RGN_SSP) && ud && ud->walktimer != INVALID_TIMER) { diff --git a/src/map/unit.c b/src/map/unit.c index 228cd75dd..65eea39c9 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -45,6 +45,8 @@ const short dirx[8]={0,-1,-1,-1,0,1,1,1}; const short diry[8]={1,1,0,-1,-1,-1,0,1}; +struct unit_interface unit_s; + /** * Returns the unit_data for the given block_list. If the object is using * shared unit_data (i.e. in case of BL_NPC), it returns the shared data. @@ -75,13 +77,13 @@ struct unit_data* unit_bl2ud2(struct block_list *bl) { struct npc_data *nd = (struct npc_data *)bl; nd->ud = NULL; CREATE(nd->ud, struct unit_data, 1); - unit_dataset(&nd->bl); + unit->dataset(&nd->bl); } - return unit_bl2ud(bl); + return unit->bl2ud(bl); } -static int unit_attack_timer(int tid, unsigned int tick, int id, intptr_t data); -static int unit_walktoxy_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); +int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data); int unit_walktoxy_sub(struct block_list *bl) { @@ -90,7 +92,7 @@ int unit_walktoxy_sub(struct block_list *bl) struct unit_data *ud = NULL; nullpo_retr(1, bl); - ud = unit_bl2ud(bl); + ud = unit->bl2ud(bl); if(ud == NULL) return 0; if( !path_search(&wpd,bl->m,bl->x,bl->y,ud->to_x,ud->to_y,ud->state.walk_easy,CELL_CHKNOPASS) ) @@ -131,11 +133,11 @@ int unit_walktoxy_sub(struct block_list *bl) else i = iStatus->get_speed(bl); if( i > 0) - ud->walktimer = iTimer->add_timer(iTimer->gettick()+i,unit_walktoxy_timer,bl->id,i); + ud->walktimer = iTimer->add_timer(iTimer->gettick()+i,unit->walktoxy_timer,bl->id,i); return 1; } -static 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; @@ -152,7 +154,7 @@ static int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data sd = BL_CAST(BL_PC, bl); md = BL_CAST(BL_MOB, bl); mrd = BL_CAST(BL_MER, bl); - ud = unit_bl2ud(bl); + ud = unit->bl2ud(bl); if(ud == NULL) return 0; @@ -178,7 +180,7 @@ static int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data dy = diry[(int)dir]; if(iMap->getcell(bl->m,x+dx,y+dy,CELL_CHKNOPASS)) - return unit_walktoxy_sub(bl); + 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); @@ -216,7 +218,7 @@ static int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data else if (DIFF_TICK(iTimer->gettick(), sd->md->masterteleport_timer) > 3000) { sd->md->masterteleport_timer = 0; - unit_warp( &sd->md->bl, sd->bl.m, sd->bl.x, sd->bl.y, CLR_TELEPORT ); + unit->warp( &sd->md->bl, sd->bl.m, sd->bl.x, sd->bl.y, CLR_TELEPORT ); } } else if( sd->md ) @@ -257,7 +259,7 @@ static int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data else if (DIFF_TICK(iTimer->gettick(), mrd->masterteleport_timer) > 3000) { mrd->masterteleport_timer = 0; - unit_warp( bl, mrd->master->bl.id, mrd->master->bl.x, mrd->master->bl.y, CLR_TELEPORT ); + unit->warp( bl, mrd->master->bl.id, mrd->master->bl.x, mrd->master->bl.y, CLR_TELEPORT ); } } else @@ -270,7 +272,7 @@ static int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data return 0; if(ud->state.change_walk_target) - return unit_walktoxy_sub(bl); + return unit->walktoxy_sub(bl); ud->walkpath.path_pos++; if(ud->walkpath.path_pos>=ud->walkpath.path_len) @@ -281,12 +283,12 @@ static int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data i = iStatus->get_speed(bl); if(i > 0) { - ud->walktimer = iTimer->add_timer(tick+i,unit_walktoxy_timer,id,i); + ud->walktimer = iTimer->add_timer(tick+i,unit->walktoxy_timer,id,i); if( md && DIFF_TICK(tick,md->dmgtick) < 3000 )//not required not damaged recently clif->move(ud); } else if(ud->state.running) { //Keep trying to run. - if ( !(unit_run(bl) || unit_wugdash(bl,sd)) ) + if ( !(unit->run(bl) || unit->wugdash(bl,sd)) ) ud->state.running = 0; } else if (ud->target_to) { @@ -307,10 +309,10 @@ static int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data //only need this one for syncing purposes. [Skotlex] ud->target_to = 0; clif->fixpos(bl); - unit_attack(bl, tbl->id, ud->state.attack_continue); + unit->attack(bl, tbl->id, ud->state.attack_continue); } } else { //Update chase-path - unit_walktobl(bl, tbl, ud->chaserange, ud->state.walk_easy|(ud->state.attack_continue?2:0)); + unit->walktobl(bl, tbl, ud->chaserange, ud->state.walk_easy|(ud->state.attack_continue?2:0)); return 0; } } @@ -321,13 +323,13 @@ static int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data return 0; } -static int unit_delay_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data) +int unit_delay_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data) { struct block_list *bl = iMap->id2bl(id); if (!bl || bl->prev == NULL) return 0; - unit_walktoxy(bl, (short)((data>>16)&0xffff), (short)(data&0xffff), 0); + unit->walktoxy(bl, (short)((data>>16)&0xffff), (short)(data&0xffff), 0); return 1; } @@ -343,7 +345,7 @@ int unit_walktoxy( struct block_list *bl, short x, short y, int flag) nullpo_ret(bl); - ud = unit_bl2ud(bl); + ud = unit->bl2ud(bl); if( ud == NULL) return 0; @@ -362,17 +364,17 @@ int unit_walktoxy( struct block_list *bl, short x, short y, int flag) if (flag&4 && DIFF_TICK(ud->canmove_tick, iTimer->gettick()) > 0 && DIFF_TICK(ud->canmove_tick, iTimer->gettick()) < 2000) { // Delay walking command. [Skotlex] - iTimer->add_timer(ud->canmove_tick+1, unit_delay_walktoxy_timer, bl->id, (x<<16)|(y&0xFFFF)); + iTimer->add_timer(ud->canmove_tick+1, unit->delay_walktoxy_timer, bl->id, (x<<16)|(y&0xFFFF)); return 1; } - if(!(flag&2) && (!(status_get_mode(bl)&MD_CANMOVE) || !unit_can_move(bl))) + if(!(flag&2) && (!(status_get_mode(bl)&MD_CANMOVE) || !unit->can_move(bl))) return 0; ud->state.walk_easy = flag&1; ud->to_x = x; ud->to_y = y; - unit_set_target(ud, 0); + unit->set_target(ud, 0); sc = iStatus->get_sc(bl); if (sc && sc->data[SC_CONFUSION]) //Randomize the target position @@ -380,17 +382,17 @@ int unit_walktoxy( struct block_list *bl, short x, short y, int flag) 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 - // Call a function from a timer unit_walktoxy_sub + // Call a function from a timer unit->walktoxy_sub ud->state.change_walk_target = 1; return 1; } if(ud->attacktimer != INVALID_TIMER) { - iTimer->delete_timer( ud->attacktimer, unit_attack_timer ); + iTimer->delete_timer( ud->attacktimer, unit->attack_timer ); ud->attacktimer = INVALID_TIMER; } - return unit_walktoxy_sub(bl); + return unit->walktoxy_sub(bl); } //To set Mob's CHASE/FOLLOW states (shouldn't be done if there's no path to reach) @@ -402,18 +404,18 @@ static inline void set_mobstate(struct block_list* bl, int flag) md->state.skillstate = md->state.aggressive ? MSS_FOLLOW : MSS_RUSH; } -static int unit_walktobl_sub(int tid, unsigned int tick, int id, intptr_t data) +int unit_walktobl_sub(int tid, unsigned int tick, int id, intptr_t data) { struct block_list *bl = iMap->id2bl(id); - struct unit_data *ud = bl?unit_bl2ud(bl):NULL; + struct unit_data *ud = bl?unit->bl2ud(bl):NULL; if (ud && ud->walktimer == INVALID_TIMER && ud->target == data) { if (DIFF_TICK(ud->canmove_tick, tick) > 0) //Keep waiting? - iTimer->add_timer(ud->canmove_tick+1, unit_walktobl_sub, id, data); - else if (unit_can_move(bl)) + iTimer->add_timer(ud->canmove_tick+1, unit->walktobl_sub, id, data); + else if (unit->can_move(bl)) { - if (unit_walktoxy_sub(bl)) + if (unit->walktoxy_sub(bl)) set_mobstate(bl, ud->state.attack_continue); } } @@ -430,13 +432,13 @@ int unit_walktobl(struct block_list *bl, struct block_list *tbl, int range, int nullpo_ret(bl); nullpo_ret(tbl); - ud = unit_bl2ud(bl); + ud = unit->bl2ud(bl); if( ud == NULL) return 0; if (!(status_get_mode(bl)&MD_CANMOVE)) return 0; - if (!unit_can_reach_bl(bl, tbl, distance_bl(bl, tbl)+1, flag&1, &ud->to_x, &ud->to_y)) { + if (!unit->can_reach_bl(bl, tbl, distance_bl(bl, tbl)+1, flag&1, &ud->to_x, &ud->to_y)) { ud->to_x = bl->x; ud->to_y = bl->y; ud->target_to = 0; @@ -447,7 +449,7 @@ int unit_walktobl(struct block_list *bl, struct block_list *tbl, int range, int ud->target_to = tbl->id; ud->chaserange = range; //Note that if flag&2, this SHOULD be attack-range ud->state.attack_continue = flag&2?1:0; //Chase to attack. - unit_set_target(ud, 0); + unit->set_target(ud, 0); sc = iStatus->get_sc(bl); if (sc && sc->data[SC_CONFUSION]) //Randomize the target position @@ -461,19 +463,19 @@ int unit_walktobl(struct block_list *bl, struct block_list *tbl, int range, int if(DIFF_TICK(ud->canmove_tick, iTimer->gettick()) > 0) { //Can't move, wait a bit before invoking the movement. - iTimer->add_timer(ud->canmove_tick+1, unit_walktobl_sub, bl->id, ud->target); + iTimer->add_timer(ud->canmove_tick+1, unit->walktobl_sub, bl->id, ud->target); return 1; } - if(!unit_can_move(bl)) + if(!unit->can_move(bl)) return 0; if(ud->attacktimer != INVALID_TIMER) { - iTimer->delete_timer( ud->attacktimer, unit_attack_timer ); + iTimer->delete_timer( ud->attacktimer, unit->attack_timer ); ud->attacktimer = INVALID_TIMER; } - if (unit_walktoxy_sub(bl)) { + if (unit->walktoxy_sub(bl)) { set_mobstate(bl, flag&2); return 1; } @@ -490,7 +492,7 @@ int unit_run(struct block_list *bl) if (!(sc && sc->data[SC_RUN])) return 0; - if (!unit_can_move(bl)) { + if (!unit->can_move(bl)) { status_change_end(bl, SC_RUN, INVALID_TIMER); return 0; } @@ -520,30 +522,30 @@ int unit_run(struct block_list *bl) clif->sc_load(bl,bl->id,AREA,SI_TING,0,0,0); //Set running to 0 beforehand so status_change_end knows not to enable spurt [Kevin] - unit_bl2ud(bl)->state.running = 0; + unit->bl2ud(bl)->state.running = 0; status_change_end(bl, SC_RUN, INVALID_TIMER); - skill->blown(bl,bl,skill->get_blewcount(TK_RUN,lv),unit_getdir(bl),0); + skill->blown(bl,bl,skill->get_blewcount(TK_RUN,lv),unit->getdir(bl),0); clif->fixpos(bl); //Why is a clif->slide (skill->blown) AND a fixpos needed? Ask Aegis. clif->sc_end(bl,bl->id,AREA,SI_TING); return 0; } - if (unit_walktoxy(bl, to_x, to_y, 1)) + if (unit->walktoxy(bl, to_x, to_y, 1)) return 1; //There must be an obstacle nearby. Attempt walking one cell at a time. do { to_x -= dir_x; to_y -= dir_y; - } while (--i > 0 && !unit_walktoxy(bl, to_x, to_y, 1)); + } while (--i > 0 && !unit->walktoxy(bl, to_x, to_y, 1)); if ( i == 0 ) { // copy-paste from above clif->sc_load(bl,bl->id,AREA,SI_TING,0,0,0); //Set running to 0 beforehand so status_change_end knows not to enable spurt [Kevin] - unit_bl2ud(bl)->state.running = 0; + unit->bl2ud(bl)->state.running = 0; status_change_end(bl, SC_RUN, INVALID_TIMER); - skill->blown(bl,bl,skill->get_blewcount(TK_RUN,lv),unit_getdir(bl),0); + skill->blown(bl,bl,skill->get_blewcount(TK_RUN,lv),unit->getdir(bl),0); clif->fixpos(bl); clif->sc_end(bl,bl->id,AREA,SI_TING); return 0; @@ -563,7 +565,7 @@ int unit_wugdash(struct block_list *bl, struct map_session_data *sd) { nullpo_ret(sd); nullpo_ret(bl); - if (!unit_can_move(bl)) { + if (!unit->can_move(bl)) { status_change_end(bl,SC_WUGDASH,INVALID_TIMER); return 0; } @@ -588,7 +590,7 @@ int unit_wugdash(struct block_list *bl, struct map_session_data *sd) { if(to_x == bl->x && to_y == bl->y) { - unit_bl2ud(bl)->state.running = 0; + unit->bl2ud(bl)->state.running = 0; status_change_end(bl,SC_WUGDASH,INVALID_TIMER); if( sd ){ @@ -597,15 +599,15 @@ int unit_wugdash(struct block_list *bl, struct map_session_data *sd) { } return 0; } - if (unit_walktoxy(bl, to_x, to_y, 1)) + if (unit->walktoxy(bl, to_x, to_y, 1)) return 1; do { to_x -= dir_x; to_y -= dir_y; - } while (--i > 0 && !unit_walktoxy(bl, to_x, to_y, 1)); + } while (--i > 0 && !unit->walktoxy(bl, to_x, to_y, 1)); if (i==0) { - unit_bl2ud(bl)->state.running = 0; + unit->bl2ud(bl)->state.running = 0; status_change_end(bl,SC_WUGDASH,INVALID_TIMER); if( sd ){ @@ -623,7 +625,7 @@ 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) ) dist--; - return ( dist > 0 && unit_walktoxy(bl, bl->x + dist*dirx[dir], bl->y + dist*diry[dir], 0) ); + return ( dist > 0 && unit->walktoxy(bl, bl->x + dist*dirx[dir], bl->y + dist*diry[dir], 0) ); } //Instant warp function. @@ -636,12 +638,12 @@ int unit_movepos(struct block_list *bl, short dst_x, short dst_y, int easy, bool nullpo_ret(bl); sd = BL_CAST(BL_PC, bl); - ud = unit_bl2ud(bl); + ud = unit->bl2ud(bl); if( ud == NULL) return 0; - unit_stop_walking(bl,1); - unit_stop_attack(bl); + 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)) ) return 0; // unreachable @@ -683,7 +685,7 @@ int unit_movepos(struct block_list *bl, short dst_x, short dst_y, int easy, bool flag = 2; if( flag ) { - unit_movepos(bl,sd->bl.x,sd->bl.y, 0, 0); + unit->movepos(bl,sd->bl.x,sd->bl.y, 0, 0); clif->slide(bl,bl->x,bl->y); } } @@ -695,7 +697,7 @@ int unit_setdir(struct block_list *bl,unsigned char dir) { struct unit_data *ud; nullpo_ret(bl ); - ud = unit_bl2ud(bl); + ud = unit->bl2ud(bl); if (!ud) return 0; ud->dir = dir; if (bl->type == BL_PC) @@ -710,7 +712,7 @@ uint8 unit_getdir(struct block_list *bl) { if( bl->type == BL_NPC ) return ((TBL_NPC*)bl)->dir; - ud = unit_bl2ud(bl); + ud = unit->bl2ud(bl); if (!ud) return 0; return ud->dir; } @@ -735,7 +737,7 @@ int unit_blown(struct block_list* bl, int dx, int dy, int count, int flag) ny = result&0xffff; if(!su) { - unit_stop_walking(bl, 0); + unit->stop_walking(bl, 0); } if( sd ) { @@ -786,7 +788,7 @@ int unit_warp(struct block_list *bl,short m,short x,short y,clr_type type) { struct unit_data *ud; nullpo_ret(bl); - ud = unit_bl2ud(bl); + ud = unit->bl2ud(bl); if(bl->prev==NULL || !ud) return 1; @@ -832,7 +834,7 @@ int unit_warp(struct block_list *bl,short m,short x,short y,clr_type type) if (bl->type == BL_PC) //Use pc_setpos return pc->setpos((TBL_PC*)bl, map_id2index(m), x, y, type); - if (!unit_remove_map(bl, type)) + if (!unit->remove_map(bl, type, ALC_MARK)) return 3; if (bl->m != m && battle_config.clear_unit_onwarp && @@ -865,14 +867,14 @@ int unit_stop_walking(struct block_list *bl,int type) unsigned int tick; nullpo_ret(bl); - ud = unit_bl2ud(bl); + ud = unit->bl2ud(bl); if(!ud || ud->walktimer == INVALID_TIMER) return 0; //NOTE: We are using timer data after deleting it because we know the //iTimer->delete_timer function does not messes with it. If the function's //behaviour changes in the future, this code could break! td = iTimer->get_timer(ud->walktimer); - iTimer->delete_timer(ud->walktimer, unit_walktoxy_timer); + iTimer->delete_timer(ud->walktimer, unit->walktoxy_timer); ud->walktimer = INVALID_TIMER; ud->state.change_walk_target = 0; tick = iTimer->gettick(); @@ -880,7 +882,7 @@ int unit_stop_walking(struct block_list *bl,int type) || (type&0x04 && td && DIFF_TICK(td->tick, tick) <= td->data/2) //Enough time has passed to cover half-cell ) { ud->walkpath.path_len = ud->walkpath.path_pos+1; - unit_walktoxy_timer(INVALID_TIMER, tick, bl->id, ud->walkpath.path_pos); + unit->walktoxy_timer(INVALID_TIMER, tick, bl->id, ud->walkpath.path_pos); } if(type&0x01) @@ -903,7 +905,7 @@ int unit_stop_walking(struct block_list *bl,int type) int unit_skilluse_id(struct block_list *src, int target_id, uint16 skill_id, uint16 skill_lv) { - return unit_skilluse_id2( + return unit->skilluse_id2( src, target_id, skill_id, skill_lv, skill->cast_fix(src, skill_id, skill_lv), skill->get_castcancel(skill_id) @@ -912,7 +914,7 @@ int unit_skilluse_id(struct block_list *src, int target_id, uint16 skill_id, uin int unit_is_walking(struct block_list *bl) { - struct unit_data *ud = unit_bl2ud(bl); + struct unit_data *ud = unit->bl2ud(bl); nullpo_ret(bl); if(!ud) return 0; return (ud->walktimer != INVALID_TIMER); @@ -927,7 +929,7 @@ int unit_can_move(struct block_list *bl) { struct status_change *sc; nullpo_ret(bl); - ud = unit_bl2ud(bl); + ud = unit->bl2ud(bl); sc = iStatus->get_sc(bl); sd = BL_CAST(BL_PC, bl); @@ -1013,10 +1015,10 @@ int unit_resume_running(int tid, unsigned int tick, int id, intptr_t data) 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,iStatus->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,iStatus->skill2sc(TK_RUN),100,ud->skill_lv,unit->getdir(ud->bl),0,0,0)); if (sd) clif->walkok(sd); @@ -1032,7 +1034,7 @@ int unit_resume_running(int tid, unsigned int tick, int id, intptr_t data) *------------------------------------------*/ int unit_set_walkdelay(struct block_list *bl, unsigned int tick, int delay, int type) { - struct unit_data *ud = unit_bl2ud(bl); + struct unit_data *ud = unit->bl2ud(bl); if (delay <= 0 || !ud) return 0; /** @@ -1046,7 +1048,7 @@ int unit_set_walkdelay(struct block_list *bl, unsigned int tick, int delay, int return 0; } else { //Don't set walk delays when already trapped. - if (!unit_can_move(bl)) + if (!unit->can_move(bl)) return 0; } ud->canmove_tick = tick + delay; @@ -1054,18 +1056,18 @@ int unit_set_walkdelay(struct block_list *bl, unsigned int tick, int delay, int { //Stop walking, if chasing, readjust timers. if (delay == 1) { //Minimal delay (walk-delay) disabled. Just stop walking. - unit_stop_walking(bl,4); + unit->stop_walking(bl,4); } else { //Resume running after can move again [Kevin] if(ud->state.running) { - iTimer->add_timer(ud->canmove_tick, unit_resume_running, bl->id, (intptr_t)ud); + iTimer->add_timer(ud->canmove_tick, unit->resume_running, bl->id, (intptr_t)ud); } else { - unit_stop_walking(bl,2|4); + unit->stop_walking(bl,2|4); if(ud->target) - iTimer->add_timer(ud->canmove_tick+1, unit_walktobl_sub, bl->id, ud->target); + iTimer->add_timer(ud->canmove_tick+1, unit->walktobl_sub, bl->id, ud->target); } } } @@ -1087,7 +1089,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui return 0; //Do not continue source is dead sd = BL_CAST(BL_PC, src); - ud = unit_bl2ud(src); + ud = unit->bl2ud(src); if(ud == NULL) return 0; sc = iStatus->get_sc(src); @@ -1234,7 +1236,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui //(these are supposed to always have the same range as your attack) if( src->id != target_id && (!temp || ud->attacktimer == INVALID_TIMER) ) { if( skill->get_state(ud->skill_id) == ST_MOVE_ENABLE ) { - if( !unit_can_reach_bl(src, target, range + 1, 1, NULL, NULL) ) + if( !unit->can_reach_bl(src, target, range + 1, 1, NULL, NULL) ) return 0; // Walk-path check failed. } else if( src->type == BL_MER && skill_id == MA_REMOVETRAP ) { if( !battle->check_range(battle->get_master(src), target, range + 1) ) @@ -1245,7 +1247,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui } if (!temp) //Stop attack on non-combo skills [Skotlex] - unit_stop_attack(src); + unit->stop_attack(src); else if(ud->attacktimer != INVALID_TIMER) //Elsewise, delay current attack sequence ud->attackabletime = tick + status_get_adelay(src); @@ -1349,7 +1351,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui } if(!ud->state.running) //need TK_RUN or WUGDASH handler to be done before that, see bugreport:6026 - unit_stop_walking(src,1);// eventhough this is not how official works but this will do the trick. bugreport:6829 + unit->stop_walking(src,1);// eventhough this is not how official works but this will do the trick. bugreport:6829 // in official this is triggered even if no cast time. clif->skillcasting(src, src->id, target_id, 0,0, skill_id, skill->get_ele(skill_id, skill_lv), casttime); @@ -1430,7 +1432,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui int unit_skilluse_pos(struct block_list *src, short skill_x, short skill_y, uint16 skill_id, uint16 skill_lv) { - return unit_skilluse_pos2( + return unit->skilluse_pos2( src, skill_x, skill_y, skill_id, skill_lv, skill->cast_fix(src, skill_id, skill_lv), skill->get_castcancel(skill_id) @@ -1452,7 +1454,7 @@ int unit_skilluse_pos2( struct block_list *src, short skill_x, short skill_y, ui if(iStatus->isdead(src)) return 0; sd = BL_CAST(BL_PC, src); - ud = unit_bl2ud(src); + ud = unit->bl2ud(src); if(ud == NULL) return 0; if(ud->skilltimer != INVALID_TIMER) //Normally not needed since clif.c checks for it, but at/char/script commands don't! [Skotlex] @@ -1501,12 +1503,12 @@ int unit_skilluse_pos2( struct block_list *src, short skill_x, short skill_y, ui range = skill->get_range2(src, skill_id, skill_lv); // Skill cast distance from database if( skill->get_state(ud->skill_id) == ST_MOVE_ENABLE ) { - if( !unit_can_reach_bl(src, &bl, range + 1, 1, NULL, NULL) ) + if( !unit->can_reach_bl(src, &bl, range + 1, 1, NULL, NULL) ) return 0; //Walk-path check failed. } else if( !battle->check_range(src, &bl, range + 1) ) return 0; //Arrow-path check failed. - unit_stop_attack(src); + unit->stop_attack(src); // moved here to prevent Suffragium from ending if skill fails #ifndef RENEWAL_CAST @@ -1550,7 +1552,7 @@ int unit_skilluse_pos2( struct block_list *src, short skill_x, short skill_y, ui } } - unit_stop_walking(src,1); + unit->stop_walking(src,1); // in official this is triggered even if no cast time. clif->skillcasting(src, src->id, 0, skill_x, skill_y, skill_id, skill->get_ele(skill_id, skill_lv), casttime); if( casttime > 0 ) { @@ -1575,9 +1577,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 = iMap->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 = iMap->id2bl(target_id)) && (ux = unit->bl2ud(target)) ) ux->target_count ++; } @@ -1587,25 +1589,25 @@ int unit_set_target(struct unit_data* ud, int target_id) int unit_stop_attack(struct block_list *bl) { - struct unit_data *ud = unit_bl2ud(bl); + struct unit_data *ud = unit->bl2ud(bl); nullpo_ret(bl); if(!ud || ud->attacktimer == INVALID_TIMER) return 0; - iTimer->delete_timer( ud->attacktimer, unit_attack_timer ); + iTimer->delete_timer( ud->attacktimer, unit->attack_timer ); ud->attacktimer = INVALID_TIMER; - unit_set_target(ud, 0); + unit->set_target(ud, 0); return 0; } //Means current target is unattackable. For now only unlocks mobs. int unit_unattackable(struct block_list *bl) { - struct unit_data *ud = unit_bl2ud(bl); + struct unit_data *ud = unit->bl2ud(bl); if (ud) { ud->state.attack_continue = 0; - unit_set_target(ud, 0); + unit->set_target(ud, 0); } if(bl->type == BL_MOB) @@ -1624,11 +1626,11 @@ 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)); + nullpo_ret(ud = unit->bl2ud(src)); target = iMap->id2bl(target_id); if( target==NULL || iStatus->isdead(target) ) { - unit_unattackable(src); + unit->unattackable(src); return 1; } @@ -1639,16 +1641,16 @@ int unit_attack(struct block_list *src,int target_id,int continuous) return 0; } if( pc_is90overweight(sd) || pc_isridingwug(sd) ) { // overweight or mounted on warg - stop attacking - unit_stop_attack(src); + unit->stop_attack(src); return 0; } } if( battle->check_target(src,target,BCT_ENEMY) <= 0 || !iStatus->check_skilluse(src, target, 0, 0) ) { - unit_unattackable(src); + unit->unattackable(src); return 1; } ud->state.attack_continue = continuous; - unit_set_target(ud, target_id); + unit->set_target(ud, target_id); if (continuous) //If you're to attack continously, set to auto-case character ud->chaserange = status_get_range(src); @@ -1663,9 +1665,9 @@ int unit_attack(struct block_list *src,int target_id,int continuous) if(DIFF_TICK(ud->attackabletime, iTimer->gettick()) > 0) //Do attack next time it is possible. [Skotlex] - ud->attacktimer=iTimer->add_timer(ud->attackabletime,unit_attack_timer,src->id,0); + ud->attacktimer=iTimer->add_timer(ud->attackabletime,unit->attack_timer,src->id,0); else //Attack NOW. - unit_attack_timer(INVALID_TIMER, iTimer->gettick(), src->id, 0); + unit->attack_timer(INVALID_TIMER, iTimer->gettick(), src->id, 0); return 0; } @@ -1679,7 +1681,7 @@ int unit_cancel_combo(struct block_list *bl) if (!status_change_end(bl, SC_COMBOATTACK, INVALID_TIMER)) return 0; //Combo wasn't active. - ud = unit_bl2ud(bl); + ud = unit->bl2ud(bl); nullpo_ret(ud); ud->attackabletime = iTimer->gettick() + status_get_amotion(bl); @@ -1687,8 +1689,8 @@ int unit_cancel_combo(struct block_list *bl) if (ud->attacktimer == INVALID_TIMER) return 1; //Nothing more to do. - iTimer->delete_timer(ud->attacktimer, unit_attack_timer); - ud->attacktimer=iTimer->add_timer(ud->attackabletime,unit_attack_timer,bl->id,0); + iTimer->delete_timer(ud->attacktimer, unit->attack_timer); + ud->attacktimer=iTimer->add_timer(ud->attackabletime,unit->attack_timer,bl->id,0); return 1; } /*========================================== @@ -1747,7 +1749,7 @@ bool unit_can_reach_bl(struct block_list *bl,struct block_list *tbl, int range, int unit_calc_pos(struct block_list *bl, int tx, int ty, uint8 dir) { int dx, dy, x, y, i, k; - struct unit_data *ud = unit_bl2ud(bl); + struct unit_data *ud = unit->bl2ud(bl); nullpo_ret(ud); if(dir > 7) @@ -1762,11 +1764,11 @@ int unit_calc_pos(struct block_list *bl, int tx, int ty, uint8 dir) x = tx + dx; y = ty + dy; - if( !unit_can_reach_pos(bl, x, y, 0) ) + if( !unit->can_reach_pos(bl, x, y, 0) ) { if( dx > 0 ) x--; else if( dx < 0 ) x++; if( dy > 0 ) y--; else if( dy < 0 ) y++; - if( !unit_can_reach_pos(bl, x, y, 0) ) + if( !unit->can_reach_pos(bl, x, y, 0) ) { for( i = 0; i < 12; i++ ) { @@ -1775,20 +1777,20 @@ int unit_calc_pos(struct block_list *bl, int tx, int ty, uint8 dir) dy = -diry[k] * 2; x = tx + dx; y = ty + dy; - if( unit_can_reach_pos(bl, x, y, 0) ) + if( unit->can_reach_pos(bl, x, y, 0) ) break; else { if( dx > 0 ) x--; else if( dx < 0 ) x++; if( dy > 0 ) y--; else if( dy < 0 ) y++; - if( unit_can_reach_pos(bl, x, y, 0) ) + if( unit->can_reach_pos(bl, x, y, 0) ) break; } } if( i == 12 ) { x = tx; y = tx; // Exactly Master Position - if( !unit_can_reach_pos(bl, x, y, 0) ) + if( !unit->can_reach_pos(bl, x, y, 0) ) return 1; } } @@ -1802,7 +1804,7 @@ int unit_calc_pos(struct block_list *bl, int tx, int ty, uint8 dir) /*========================================== * Continuous Attack (function timer) *------------------------------------------*/ -static int unit_attack_timer_sub(struct block_list* src, int tid, unsigned int tick) +int unit_attack_timer_sub(struct block_list* src, int tid, unsigned int tick) { struct block_list *target; struct unit_data *ud; @@ -1811,7 +1813,7 @@ static int unit_attack_timer_sub(struct block_list* src, int tid, unsigned int t struct mob_data *md = NULL; int range; - if( (ud=unit_bl2ud(src))==NULL ) + if( (ud=unit->bl2ud(src))==NULL ) return 0; if( ud->attacktimer != tid ) { @@ -1855,7 +1857,7 @@ static int unit_attack_timer_sub(struct block_list* src, int tid, unsigned int t if( ud->state.attack_continue ) { if( DIFF_TICK(ud->canact_tick, ud->attackabletime) > 0 ) ud->attackabletime = ud->canact_tick; - ud->attacktimer=iTimer->add_timer(ud->attackabletime,unit_attack_timer,src->id,0); + ud->attacktimer=iTimer->add_timer(ud->attackabletime,unit->attack_timer,src->id,0); } return 1; } @@ -1863,20 +1865,20 @@ static int unit_attack_timer_sub(struct block_list* src, int tid, unsigned int t sstatus = iStatus->get_status_data(src); range = sstatus->rhw.range + 1; - if( unit_is_walking(target) ) + if( unit->is_walking(target) ) range++; //Extra range when chasing if( !check_distance_bl(src,target,range) ) { //Chase if required. if(sd) clif->movetoattack(sd,target); else if(ud->state.attack_continue) - unit_walktobl(src,target,ud->chaserange,ud->state.walk_easy|2); + unit->walktobl(src,target,ud->chaserange,ud->state.walk_easy|2); return 1; } if( !battle->check_range(src,target,range) ) { //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); + unit->walktobl(src,target,ud->chaserange,ud->state.walk_easy|2); } return 1; } @@ -1890,7 +1892,7 @@ static int unit_attack_timer_sub(struct block_list* src, int tid, unsigned int t ud->dir = iMap->calc_dir(src, target->x,target->y ); } if(ud->walktimer != INVALID_TIMER) - unit_stop_walking(src,1); + unit->stop_walking(src,1); if(md) { if (mob->skill_use(md,tick,-1)) return 1; @@ -1919,24 +1921,24 @@ static int unit_attack_timer_sub(struct block_list* src, int tid, unsigned int t ud->attackabletime = tick + sstatus->adelay; // You can't move if you can't attack neither. if (src->type&battle_config.attack_walk_delay) - unit_set_walkdelay(src, tick, sstatus->amotion, 1); + unit->set_walkdelay(src, tick, sstatus->amotion, 1); } if(ud->state.attack_continue) { if( src->type == BL_PC ) ((TBL_PC*)src)->idletime = last_tick; - ud->attacktimer = iTimer->add_timer(ud->attackabletime,unit_attack_timer,src->id,0); + ud->attacktimer = iTimer->add_timer(ud->attackabletime,unit->attack_timer,src->id,0); } return 1; } -static 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); - if(bl && unit_attack_timer_sub(bl, tid, tick) == 0) - unit_unattackable(bl); + if(bl && unit->attack_timer_sub(bl, tid, tick) == 0) + unit->unattackable(bl); return 0; } @@ -1948,7 +1950,7 @@ static int unit_attack_timer(int tid, unsigned int tick, int id, intptr_t data) int unit_skillcastcancel(struct block_list *bl,int type) { struct map_session_data *sd = NULL; - struct unit_data *ud = unit_bl2ud( bl); + struct unit_data *ud = unit->bl2ud( bl); unsigned int tick=iTimer->gettick(); int ret=0, skill_id; @@ -2004,7 +2006,7 @@ int unit_skillcastcancel(struct block_list *bl,int type) // unit_data initialization process void unit_dataset(struct block_list *bl) { struct unit_data *ud; - nullpo_retv(ud = unit_bl2ud(bl)); + nullpo_retv(ud = unit->bl2ud(bl)); memset( ud, 0, sizeof( struct unit_data) ); ud->bl = bl; @@ -2022,7 +2024,7 @@ void unit_dataset(struct block_list *bl) { int unit_counttargeted(struct block_list* bl) { struct unit_data* ud; - if( bl && (ud = unit_bl2ud(bl)) ) + if( bl && (ud = unit->bl2ud(bl)) ) return ud->target_count; return 0; } @@ -2067,9 +2069,9 @@ int unit_changeviewsize(struct block_list *bl,short size) * Otherwise it is assumed bl is being warped. * On-Kill specific stuff is not performed here, look at iStatus->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 unit_data *ud = unit->bl2ud(bl); struct status_change *sc = iStatus->get_sc(bl); nullpo_ret(ud); @@ -2078,14 +2080,14 @@ int unit_remove_map_(struct block_list *bl, clr_type clrtype, const char* file, iMap->freeblock_lock(); - unit_set_target(ud, 0); + unit->set_target(ud, 0); if (ud->walktimer != INVALID_TIMER) - unit_stop_walking(bl,0); + unit->stop_walking(bl,0); if (ud->attacktimer != INVALID_TIMER) - unit_stop_attack(bl); + unit->stop_attack(bl); if (ud->skilltimer != INVALID_TIMER) - unit_skillcastcancel(bl,0); + unit->skillcastcancel(bl,0); // Do not reset can-act delay. [Skotlex] ud->attackabletime = ud->canmove_tick /*= ud->canact_tick*/ = iTimer->gettick(); @@ -2233,10 +2235,10 @@ int unit_remove_map_(struct block_list *bl, clr_type clrtype, const char* file, 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 logging out, this is deleted on unit->free clif->clearunit_area(bl,clrtype); iMap->delblock(bl); - unit_free(bl,CLR_OUTSIGHT); + unit->free(bl,CLR_OUTSIGHT); iMap->freeblock_unlock(); return 0; } @@ -2247,11 +2249,11 @@ int unit_remove_map_(struct block_list *bl, clr_type clrtype, const char* file, 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 logging out, this is deleted on unit->free clif->emotion(bl, E_SOB); clif->clearunit_area(bl,clrtype); iMap->delblock(bl); - unit_free(bl,CLR_OUTSIGHT); + unit->free(bl,CLR_OUTSIGHT); iMap->freeblock_unlock(); return 0; } @@ -2264,7 +2266,7 @@ int unit_remove_map_(struct block_list *bl, clr_type clrtype, const char* file, { clif->clearunit_area(bl,clrtype); iMap->delblock(bl); - unit_free(bl,CLR_OUTSIGHT); + unit->free(bl,CLR_OUTSIGHT); iMap->freeblock_unlock(); return 0; } @@ -2277,7 +2279,7 @@ int unit_remove_map_(struct block_list *bl, clr_type clrtype, const char* file, { clif->clearunit_area(bl,clrtype); iMap->delblock(bl); - unit_free(bl,0); + unit->free(bl,0); iMap->freeblock_unlock(); return 0; } @@ -2297,27 +2299,27 @@ int unit_remove_map_(struct block_list *bl, clr_type clrtype, const char* file, void unit_remove_map_pc(struct map_session_data *sd, clr_type clrtype) { - unit_remove_map(&sd->bl,clrtype); + unit->remove_map(&sd->bl,clrtype,ALC_MARK); if (clrtype == CLR_TELEPORT) clrtype = CLR_OUTSIGHT; //CLR_TELEPORT is the warp from logging out, but pets/homunc need to just 'vanish' instead of showing the warping out animation. if(sd->pd) - unit_remove_map(&sd->pd->bl, clrtype); + unit->remove_map(&sd->pd->bl, clrtype, ALC_MARK); if(homun_alive(sd->hd)) - unit_remove_map(&sd->hd->bl, clrtype); + unit->remove_map(&sd->hd->bl, clrtype, ALC_MARK); if(sd->md) - unit_remove_map(&sd->md->bl, clrtype); + unit->remove_map(&sd->md->bl, clrtype, ALC_MARK); if(sd->ed) - unit_remove_map(&sd->ed->bl, clrtype); + unit->remove_map(&sd->ed->bl, clrtype, ALC_MARK); } void unit_free_pc(struct map_session_data *sd) { - if (sd->pd) unit_free(&sd->pd->bl,CLR_OUTSIGHT); - if (sd->hd) unit_free(&sd->hd->bl,CLR_OUTSIGHT); - if (sd->md) unit_free(&sd->md->bl,CLR_OUTSIGHT); - if (sd->ed) unit_free(&sd->ed->bl,CLR_OUTSIGHT); - unit_free(&sd->bl,CLR_TELEPORT); + if (sd->pd) unit->free(&sd->pd->bl,CLR_OUTSIGHT); + if (sd->hd) unit->free(&sd->hd->bl,CLR_OUTSIGHT); + if (sd->md) unit->free(&sd->md->bl,CLR_OUTSIGHT); + if (sd->ed) unit->free(&sd->ed->bl,CLR_OUTSIGHT); + unit->free(&sd->bl,CLR_TELEPORT); } /*========================================== @@ -2326,12 +2328,12 @@ void unit_free_pc(struct map_session_data *sd) *------------------------------------------*/ int unit_free(struct block_list *bl, clr_type clrtype) { - struct unit_data *ud = unit_bl2ud( bl ); + struct unit_data *ud = unit->bl2ud( bl ); nullpo_ret(ud); iMap->freeblock_lock(); if( bl->prev ) //Players are supposed to logout with a "warp" effect. - unit_remove_map(bl, clrtype); + unit->remove_map(bl, clrtype, ALC_MARK); switch( bl->type ) { case BL_PC: @@ -2590,17 +2592,67 @@ int unit_free(struct block_list *bl, clr_type clrtype) return 0; } -int do_init_unit(void) -{ - iTimer->add_timer_func_list(unit_attack_timer, "unit_attack_timer"); - iTimer->add_timer_func_list(unit_walktoxy_timer,"unit_walktoxy_timer"); - iTimer->add_timer_func_list(unit_walktobl_sub, "unit_walktobl_sub"); - iTimer->add_timer_func_list(unit_delay_walktoxy_timer,"unit_delay_walktoxy_timer"); +int do_init_unit(void) { + iTimer->add_timer_func_list(unit->attack_timer, "unit_attack_timer"); + iTimer->add_timer_func_list(unit->walktoxy_timer,"unit_walktoxy_timer"); + iTimer->add_timer_func_list(unit->walktobl_sub, "unit_walktobl_sub"); + iTimer->add_timer_func_list(unit->delay_walktoxy_timer,"unit_delay_walktoxy_timer"); return 0; } -int do_final_unit(void) -{ +int do_final_unit(void) { // nothing to do return 0; } + +void unit_defaults(void) { + unit = &unit_s; + + unit->init = do_init_unit; + unit->final = do_final_unit; + /* */ + unit->bl2ud = unit_bl2ud; + unit->bl2ud2 = unit_bl2ud2; + unit->attack_timer = unit_attack_timer; + unit->walktoxy_timer = unit_walktoxy_timer; + unit->walktoxy_sub = unit_walktoxy_sub; + unit->delay_walktoxy_timer = unit_delay_walktoxy_timer; + unit->walktoxy = unit_walktoxy; + unit->walktobl_sub = unit_walktobl_sub; + unit->walktobl = unit_walktobl; + unit->run = unit_run; + unit->wugdash = unit_wugdash; + unit->escape = unit_escape; + unit->movepos = unit_movepos; + unit->setdir = unit_setdir; + unit->getdir = unit_getdir; + unit->blown = unit_blown; + unit->warp = unit_warp; + unit->stop_walking = unit_stop_walking; + unit->skilluse_id = unit_skilluse_id; + unit->is_walking = unit_is_walking; + unit->can_move = unit_can_move; + unit->resume_running = unit_resume_running; + unit->set_walkdelay = unit_set_walkdelay; + unit->skilluse_id2 = unit_skilluse_id2; + unit->skilluse_pos = unit_skilluse_pos; + unit->skilluse_pos2 = unit_skilluse_pos2; + unit->set_target = unit_set_target; + unit->stop_attack = unit_stop_attack; + unit->unattackable = unit_unattackable; + unit->attack = unit_attack; + unit->cancel_combo = unit_cancel_combo; + unit->can_reach_pos = unit_can_reach_pos; + unit->can_reach_bl = unit_can_reach_bl; + unit->calc_pos = unit_calc_pos; + unit->attack_timer_sub = unit_attack_timer_sub; + unit->skillcastcancel = unit_skillcastcancel; + unit->dataset = unit_dataset; + unit->counttargeted = unit_counttargeted; + unit->fixdamage = unit_fixdamage; + unit->changeviewsize = unit_changeviewsize; + unit->remove_map = unit_remove_map; + unit->remove_map_pc = unit_remove_map_pc; + unit->free_pc = unit_free_pc; + unit->free = unit_free; +} diff --git a/src/map/unit.h b/src/map/unit.h index b743fc8cb..be7b789d9 100644 --- a/src/map/unit.h +++ b/src/map/unit.h @@ -68,79 +68,61 @@ struct view_data { unsigned dead_sit : 2; }; -// PC, MOB, PET ɋʂ鏈P‚ɂ܂Ƃ߂v - -// sJn -// ߂ĺA0 ( ), 1 ( s ) -int unit_walktoxy( struct block_list *bl, short x, short y, int easy); -int unit_walktobl( struct block_list *bl, struct block_list *target, int range, int easy); -int unit_run(struct block_list *bl); -int unit_calc_pos(struct block_list *bl, int tx, int ty, uint8 dir); - -// s~ -// type͈ȉ̑gݍ킹 : -// 1: ʒȗM( ̊֐̌Ɉʒu𑗐Mꍇ͕sv ) -// 2: _[WfBCL -// 4: s(MOB̂݁H) -int unit_stop_walking(struct block_list *bl,int type); -int unit_can_move(struct block_list *bl); -int unit_is_walking(struct block_list *bl); -int unit_set_walkdelay(struct block_list *bl, unsigned int tick, int delay, int type); - -int unit_escape(struct block_list *bl, struct block_list *target, short dist); -// ʒűړ(΂Ȃ) -int unit_movepos(struct block_list *bl, short dst_x, short dst_y, int easy, bool checkpath); -int unit_warp(struct block_list *bl, short map, short x, short y, clr_type type); -int unit_setdir(struct block_list *bl,unsigned char dir); -uint8 unit_getdir(struct block_list *bl); -int unit_blown(struct block_list* bl, int dx, int dy, int count, int flag); - -// ܂ŕsłǂ蒅邩̔ -bool unit_can_reach_pos(struct block_list *bl,int x,int y,int easy); -bool unit_can_reach_bl(struct block_list *bl,struct block_list *tbl, int range, int easy, short *x, short *y); - -// U֘A -int unit_stop_attack(struct block_list *bl); -int unit_attack(struct block_list *src,int target_id,int continuous); -int unit_cancel_combo(struct block_list *bl); - -// XLgp -int unit_skilluse_id(struct block_list *src, int target_id, uint16 skill_id, uint16 skill_lv); -int unit_skilluse_pos(struct block_list *src, short skill_x, short skill_y, uint16 skill_id, uint16 skill_lv); - -// XLgp( ␳ς݃LXgԁALZsݒt ) -int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, uint16 skill_lv, int casttime, int castcancel); -int unit_skilluse_pos2( struct block_list *src, short skill_x, short skill_y, uint16 skill_id, uint16 skill_lv, int casttime, int castcancel); - -// rLZ -int unit_skillcastcancel(struct block_list *bl,int type); - -int unit_counttargeted(struct block_list *bl); -int unit_set_target(struct unit_data* ud, int target_id); - -// unit_data ̏ -void unit_dataset(struct block_list *bl); +extern const short dirx[8]; +extern const short diry[8]; -int unit_fixdamage(struct block_list *src,struct block_list *target,unsigned int tick,int sdelay,int ddelay,int64 damage,int div,int type,int64 damage2); -// ̑ -struct unit_data* unit_bl2ud(struct block_list *bl); -struct unit_data* unit_bl2ud2(struct block_list *bl); -void unit_remove_map_pc(struct map_session_data *sd, clr_type clrtype); -void unit_free_pc(struct map_session_data *sd); -#define unit_remove_map(bl,clrtype) unit_remove_map_(bl,clrtype,__FILE__,__LINE__,__func__) -int unit_remove_map_(struct block_list *bl, clr_type clrtype, const char* file, int line, const char* func); -int unit_free(struct block_list *bl, clr_type clrtype); -int unit_changeviewsize(struct block_list *bl,short size); +struct unit_interface { + int (*init) (void); + int (*final) (void); + /* */ + struct unit_data* (*bl2ud) (struct block_list *bl); + struct unit_data* (*bl2ud2) (struct block_list *bl); + int (*attack_timer) (int tid, unsigned int tick, int id, intptr_t data); + int (*walktoxy_timer) (int tid, unsigned int tick, int id, intptr_t data); + int (*walktoxy_sub) (struct block_list *bl); + int (*delay_walktoxy_timer) (int tid, unsigned int tick, int id, intptr_t data); + int (*walktoxy) (struct block_list *bl, short x, short y, int flag); + int (*walktobl_sub) (int tid, unsigned int tick, int id, intptr_t data); + int (*walktobl) (struct block_list *bl, struct block_list *tbl, int range, int flag); + int (*run) (struct block_list *bl); + int (*wugdash) (struct block_list *bl, struct map_session_data *sd); + int (*escape) (struct block_list *bl, struct block_list *target, short dist); + int (*movepos) (struct block_list *bl, short dst_x, short dst_y, int easy, bool checkpath); + int (*setdir) (struct block_list *bl, unsigned char dir); + uint8 (*getdir) (struct block_list *bl); + int (*blown) (struct block_list *bl, int dx, int dy, int count, int flag); + int (*warp) (struct block_list *bl, short m, short x, short y, clr_type type); + int (*stop_walking) (struct block_list *bl, int type); + int (*skilluse_id) (struct block_list *src, int target_id, uint16 skill_id, uint16 skill_lv); + int (*is_walking) (struct block_list *bl); + int (*can_move) (struct block_list *bl); + int (*resume_running) (int tid, unsigned int tick, int id, intptr_t data); + int (*set_walkdelay) (struct block_list *bl, unsigned int tick, int delay, int type); + int (*skilluse_id2) (struct block_list *src, int target_id, uint16 skill_id, uint16 skill_lv, int casttime, int castcancel); + int (*skilluse_pos) (struct block_list *src, short skill_x, short skill_y, uint16 skill_id, uint16 skill_lv); + int (*skilluse_pos2) (struct block_list *src, short skill_x, short skill_y, uint16 skill_id, uint16 skill_lv, int casttime, int castcancel); + int (*set_target) (struct unit_data *ud, int target_id); + int (*stop_attack) (struct block_list *bl); + int (*unattackable) (struct block_list *bl); + int (*attack) (struct block_list *src, int target_id, int continuous); + int (*cancel_combo) (struct block_list *bl); + bool (*can_reach_pos) (struct block_list *bl, int x, int y, int easy); + bool (*can_reach_bl) (struct block_list *bl, struct block_list *tbl, int range, int easy, short *x, short *y); + int (*calc_pos) (struct block_list *bl, int tx, int ty, uint8 dir); + int (*attack_timer_sub) (struct block_list *src, int tid, unsigned int tick); + int (*skillcastcancel) (struct block_list *bl, int type); + void (*dataset) (struct block_list *bl); + int (*counttargeted) (struct block_list *bl); + int (*fixdamage) (struct block_list *src, struct block_list *target, unsigned int tick, int sdelay, int ddelay, int64 damage, int div, int type, int64 damage2); + int (*changeviewsize) (struct block_list *bl, short size); + int (*remove_map) (struct block_list *bl, clr_type clrtype, const char *file, int line, const char *func); + void (*remove_map_pc) (struct map_session_data *sd, clr_type clrtype); + void (*free_pc) (struct map_session_data *sd); + int (*free) (struct block_list *bl, clr_type clrtype); +}; -// [` -int do_init_unit(void); -int do_final_unit(void); -/** - * Ranger - **/ -int unit_wugdash(struct block_list *bl, struct map_session_data *sd); +struct unit_interface *unit; -extern const short dirx[8]; -extern const short diry[8]; +void unit_defaults(void); #endif /* _UNIT_H_ */ -- cgit v1.2.3-70-g09d2 From 95e13fe4774a7c46c15c6e41ab28338cca827ecc Mon Sep 17 00:00:00 2001 From: shennetsind Date: Mon, 16 Sep 2013 10:20:29 -0300 Subject: HPM: Npc.c Interface Fully Interfaced. Special Thanks to Haruna Signed-off-by: shennetsind --- src/map/atcommand.c | 40 ++-- src/map/battleground.c | 4 +- src/map/chat.c | 2 +- src/map/chrif.c | 4 +- src/map/clif.c | 54 ++--- src/map/elemental.c | 2 +- src/map/guild.c | 18 +- src/map/homunculus.c | 2 +- src/map/instance.c | 4 +- src/map/map.c | 43 ++-- src/map/mercenary.c | 2 +- src/map/mob.c | 12 +- src/map/npc.c | 615 +++++++++++++++++++++++++++---------------------- src/map/npc.h | 198 +++++++++------- src/map/pc.c | 34 +-- src/map/pet.c | 2 +- src/map/script.c | 116 +++++----- src/map/skill.c | 6 +- src/map/status.c | 6 +- src/map/unit.c | 20 +- 20 files changed, 650 insertions(+), 534 deletions(-) (limited to 'src/map/elemental.c') diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 6c44f8919..d9b9543e4 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -3749,7 +3749,7 @@ ACMD(reloadscript) flush_fifos(); iMap->reloadnpc(true); // reload config files seeking for npcs script->reload(); - npc_reload(); + npc->reload(); clif->message(fd, msg_txt(100)); // Scripts have been reloaded. @@ -4237,7 +4237,7 @@ ACMD(tonpc) return false; } - if ((nd = npc_name2id(npcname)) != NULL) { + if ((nd = npc->name2id(npcname)) != NULL) { if (pc->setpos(sd, map_id2index(nd->bl.m), nd->bl.x, nd->bl.y, CLR_TELEPORT) == 0) clif->message(fd, msg_txt(0)); // Warped. else @@ -4265,8 +4265,8 @@ ACMD(shownpc) return false; } - if (npc_name2id(NPCname) != NULL) { - npc_enable(NPCname, 1); + if (npc->name2id(NPCname) != NULL) { + npc->enable(NPCname, 1); clif->message(fd, msg_txt(110)); // Npc Enabled. } else { clif->message(fd, msg_txt(111)); // This NPC doesn't exist. @@ -4291,12 +4291,12 @@ ACMD(hidenpc) return false; } - if (npc_name2id(NPCname) == NULL) { + if (npc->name2id(NPCname) == NULL) { clif->message(fd, msg_txt(111)); // This NPC doesn't exist. return false; } - npc_enable(NPCname, 0); + npc->enable(NPCname, 0); clif->message(fd, msg_txt(112)); // Npc Disabled. return true; } @@ -4318,9 +4318,9 @@ ACMD(loadnpc) fclose(fp); // add to list of script sources and run it - npc_addsrcfile(message); - npc_parsesrcfile(message,true); - npc_read_event_script(); + npc->addsrcfile(message); + npc->parsesrcfile(message,true); + npc->read_event_script(); clif->message(fd, msg_txt(262)); @@ -4340,14 +4340,14 @@ ACMD(unloadnpc) return false; } - if ((nd = npc_name2id(NPCname)) == NULL) { + if ((nd = npc->name2id(NPCname)) == NULL) { clif->message(fd, msg_txt(111)); // This NPC doesn't exist. return false; } - npc_unload_duplicates(nd); - npc_unload(nd,true); - npc_read_event_script(); + npc->unload_duplicates(nd); + npc->unload(nd,true); + npc->read_event_script(); clif->message(fd, msg_txt(112)); // Npc Disabled. return true; } @@ -4749,7 +4749,7 @@ ACMD(disguise) } else { //Acquired a Name if ((id = mob->db_searchname(message)) == 0) { - struct npc_data* nd = npc_name2id(message); + struct npc_data* nd = npc->name2id(message); if (nd != NULL) id = nd->class_; } @@ -4828,7 +4828,7 @@ ACMD(disguiseguild) id = 0; } else { if( (id = mob->db_searchname(monster)) == 0 ) { - struct npc_data* nd = npc_name2id(monster); + struct npc_data* nd = npc->name2id(monster); if( nd != NULL ) id = nd->class_; } @@ -5116,7 +5116,7 @@ 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; @@ -5165,7 +5165,7 @@ ACMD(addwarp) return false; } - nd = npc_add_warp(warpname, sd->bl.m, sd->bl.x, sd->bl.y, 2, 2, m, x, y); + nd = npc->add_warp(warpname, sd->bl.m, sd->bl.x, sd->bl.y, 2, 2, m, x, y); if( nd == NULL ) return false; @@ -6194,7 +6194,7 @@ ACMD(npctalk) } } - if (!(nd = npc_name2id(name))) { + if (!(nd = npc->name2id(name))) { clif->message(fd, msg_txt(111)); // This NPC doesn't exist return false; } @@ -8759,7 +8759,7 @@ ACMD(unloadnpcfile) { return false; } - if( npc_unloadfile(message) ) + if( npc->unloadfile(message) ) clif->message(fd, msg_txt(1386)); // File unloaded. Be aware that mapflags and monsters spawned directly are not removed. else { clif->message(fd, msg_txt(1387)); // File not found. @@ -10018,7 +10018,7 @@ bool is_atcommand(const int fd, struct map_session_data* sd, const char* message if( binding->log ) /* log only if this command should be logged [Ind/Hercules] */ logs->atcommand(sd, atcmd_msg); - npc_do_atcmd_event((invokeFlag ? sd : ssd), command, params, binding->npc_event); + npc->do_atcmd_event((invokeFlag ? sd : ssd), command, params, binding->npc_event); return true; } } diff --git a/src/map/battleground.c b/src/map/battleground.c index 3b2e0b1ce..66586c5fe 100644 --- a/src/map/battleground.c +++ b/src/map/battleground.c @@ -149,7 +149,7 @@ int bg_team_leave(struct map_session_data *sd, int flag) } if( bg_data->logout_event[0] && flag ) - npc_event(sd, bg_data->logout_event, 0); + npc->event(sd, bg_data->logout_event, 0); if( sd->bg_queue.arena ) { bg->queue_pc_cleanup(sd); @@ -534,7 +534,7 @@ void bg_begin(struct bg_arena *arena) { arena->ongoing = true; mapreg_setreg(script->add_str("$@bg_queue_id"),arena->queue_id);/* TODO: make this a arena-independant var? or just .@? */ mapreg_setregstr(script->add_str("$@bg_delay_var$"),bg->gdelay_var); - npc_event_do(arena->npc_event); + npc->event_do(arena->npc_event); /* we split evenly? */ /* but if a party of say 10 joins, it cant be split evenly unless by luck there are 10 soloers in the queue besides them */ /* not sure how to split T_T needs more info */ diff --git a/src/map/chat.c b/src/map/chat.c index 3a76dd157..28de86fe1 100644 --- a/src/map/chat.c +++ b/src/map/chat.c @@ -388,7 +388,7 @@ int chat_triggerevent(struct chat_data *cd) nullpo_ret(cd); if( cd->users >= cd->trigger && cd->npc_event[0] ) - npc_event_do(cd->npc_event); + npc->event_do(cd->npc_event); return 0; } diff --git a/src/map/chrif.c b/src/map/chrif.c index 6b0397b56..524286da1 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -463,10 +463,10 @@ int chrif_connectack(int fd) { chrif_sendmap(fd); - ShowStatus("Event '"CL_WHITE"OnInterIfInit"CL_RESET"' executed with '"CL_WHITE"%d"CL_RESET"' NPCs.\n", npc_event_doall("OnInterIfInit")); + ShowStatus("Event '"CL_WHITE"OnInterIfInit"CL_RESET"' executed with '"CL_WHITE"%d"CL_RESET"' NPCs.\n", npc->event_doall("OnInterIfInit")); if( !char_init_done ) { char_init_done = true; - ShowStatus("Event '"CL_WHITE"OnInterIfInitOnce"CL_RESET"' executed with '"CL_WHITE"%d"CL_RESET"' NPCs.\n", npc_event_doall("OnInterIfInitOnce")); + ShowStatus("Event '"CL_WHITE"OnInterIfInitOnce"CL_RESET"' executed with '"CL_WHITE"%d"CL_RESET"' NPCs.\n", npc->event_doall("OnInterIfInitOnce")); guild->castle_map_init(); } diff --git a/src/map/clif.c b/src/map/clif.c index f8f88c691..391c3c40b 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -1928,7 +1928,7 @@ void clif_scriptmenu(struct map_session_data* sd, int npcid, const char* mes) int slen = strlen(mes) + 9; struct block_list *bl = NULL; - if (!sd->state.using_fake_npc && (npcid == fake_nd->bl.id || ((bl = iMap->id2bl(npcid)) && (bl->m!=sd->bl.m || + if (!sd->state.using_fake_npc && (npcid == npc->fake_nd->bl.id || ((bl = iMap->id2bl(npcid)) && (bl->m!=sd->bl.m || bl->xbl.x-AREA_SIZE-1 || bl->x>sd->bl.x+AREA_SIZE+1 || bl->ybl.y-AREA_SIZE-1 || bl->y>sd->bl.y+AREA_SIZE+1)))) clif->sendfakenpc(sd, npcid); @@ -1960,7 +1960,7 @@ void clif_scriptinput(struct map_session_data *sd, int npcid) nullpo_retv(sd); - if (!sd->state.using_fake_npc && (npcid == fake_nd->bl.id || ((bl = iMap->id2bl(npcid)) && (bl->m!=sd->bl.m || + if (!sd->state.using_fake_npc && (npcid == npc->fake_nd->bl.id || ((bl = iMap->id2bl(npcid)) && (bl->m!=sd->bl.m || bl->xbl.x-AREA_SIZE-1 || bl->x>sd->bl.x+AREA_SIZE+1 || bl->ybl.y-AREA_SIZE-1 || bl->y>sd->bl.y+AREA_SIZE+1)))) clif->sendfakenpc(sd, npcid); @@ -1991,7 +1991,7 @@ void clif_scriptinputstr(struct map_session_data *sd, int npcid) nullpo_retv(sd); - if (!sd->state.using_fake_npc && (npcid == fake_nd->bl.id || ((bl = iMap->id2bl(npcid)) && (bl->m!=sd->bl.m || + if (!sd->state.using_fake_npc && (npcid == npc->fake_nd->bl.id || ((bl = iMap->id2bl(npcid)) && (bl->m!=sd->bl.m || bl->xbl.x-AREA_SIZE-1 || bl->x>sd->bl.x+AREA_SIZE+1 || bl->ybl.y-AREA_SIZE-1 || bl->y>sd->bl.y+AREA_SIZE+1)))) clif->sendfakenpc(sd, npcid); @@ -9531,7 +9531,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { iMap->map_foreachpc(clif->friendslist_toggle_sub, sd->status.account_id, sd->status.char_id, 1); //Login Event - npc_script_event(sd, NPCE_LOGIN); + npc->script_event(sd, NPCE_LOGIN); } else { //For some reason the client "loses" these on warp/map-change. clif->updatestatus(sd,SP_STR); @@ -9547,7 +9547,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { sd->npc_menu = 0; if(sd->npc_id) - npc_event_dequeue(sd); + npc->event_dequeue(sd); if( sd->guild && ( battle_config.guild_notice_changemap == 2 || ( battle_config.guild_notice_changemap == 1 && sd->state.changemap ) ) ) clif->guild_notice(sd,sd->guild); @@ -9611,7 +9611,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { } if(map[sd->bl.m].flag.loadevent) // Lance - npc_script_event(sd, NPCE_LOADMAP); + npc->script_event(sd, NPCE_LOADMAP); if (pc->checkskill(sd, SG_DEVIL) && !pc->nextjobexp(sd)) //blindness [Komurka] clif->sc_end(&sd->bl, sd->bl.id, SELF, SI_DEVIL1); @@ -9623,7 +9623,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *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)) - npc_touch_areanpc(sd,sd->bl.m,sd->bl.x,sd->bl.y); + npc->touch_areanpc(sd,sd->bl.m,sd->bl.x,sd->bl.y); else sd->areanpc_id = 0; @@ -9750,7 +9750,7 @@ void clif_parse_progressbar(int fd, struct map_session_data * sd) sd->st->state = END; sd->state.workinprogress = sd->progressbar.npc_id = sd->progressbar.timeout = 0; - npc_scriptcont(sd, npc_id, false); + npc->scriptcont(sd, npc_id, false); } @@ -10401,8 +10401,8 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd) //-------------------------------------------------------// if (target[0] && (strncasecmp(target,"NPC:",4) == 0) && (strlen(target) > 4)) { char* str = target+4; //Skip the NPC: string part. - struct npc_data* npc; - if ((npc = npc_name2id(str))) { + struct npc_data *nd; + if ((nd = npc->name2id(str))) { char split_data[NUM_WHISPER_VAR][CHAT_SIZE_MAX]; char *split; char output[256]; @@ -10429,8 +10429,8 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd) script->set_var(sd,output,(char *) split_data[i]); } - sprintf(output, "%s::OnWhisperGlobal", npc->exname); - npc_event(sd,output,0); // Calls the NPC label + sprintf(output, "%s::OnWhisperGlobal", nd->exname); + npc->event(sd,output,0); // Calls the NPC label return; } @@ -10837,7 +10837,7 @@ void clif_parse_NpcClicked(int fd,struct map_session_data *sd) break; } if( bl->m != -1 )// the user can't click floating npcs directly (hack attempt) - npc_click(sd,(TBL_NPC*)bl); + npc->click(sd,(TBL_NPC*)bl); break; } } @@ -10852,7 +10852,7 @@ void clif_parse_NpcBuySellSelected(int fd,struct map_session_data *sd) { if (sd->state.trading) return; - npc_buysellsel(sd,RFIFOL(fd,2),RFIFOB(fd,6)); + npc->buysellsel(sd,RFIFOL(fd,2),RFIFOB(fd,6)); } @@ -10884,7 +10884,7 @@ void clif_parse_NpcBuyListSend(int fd, struct map_session_data* sd) if( sd->state.trading || !sd->npc_shopid ) result = 1; else - result = npc_buylist(sd,n,item_list); + result = npc->buylist(sd,n,item_list); sd->npc_shopid = 0; //Clear shop data. @@ -10920,7 +10920,7 @@ void clif_parse_NpcSellListSend(int fd,struct map_session_data *sd) if (sd->state.trading || !sd->npc_shopid) fail = 1; else - fail = npc_selllist(sd,n,item_list); + fail = npc->selllist(sd,n,item_list); sd->npc_shopid = 0; //Clear shop data. @@ -10949,7 +10949,7 @@ void clif_parse_CreateChatRoom(int fd, struct map_session_data* sd) clif->skill_fail(sd,1,USESKILL_FAIL_LEVEL,3); return; } - if( npc_isnear(&sd->bl) ) { + if( npc->isnear(&sd->bl) ) { // uncomment for more verbose message. //char output[150]; //sprintf(output, msg_txt(662), battle_config.min_npc_vendchat_distance); @@ -11695,7 +11695,7 @@ void clif_parse_NpcSelectMenu(int fd,struct map_session_data *sd) } sd->npc_menu = select; - npc_scriptcont(sd,npc_id, false); + npc->scriptcont(sd,npc_id, false); } @@ -11703,7 +11703,7 @@ void clif_parse_NpcSelectMenu(int fd,struct map_session_data *sd) /// 00b9 .L void clif_parse_NpcNextClicked(int fd,struct map_session_data *sd) { - npc_scriptcont(sd,RFIFOL(fd,2), false); + npc->scriptcont(sd,RFIFOL(fd,2), false); } @@ -11715,7 +11715,7 @@ void clif_parse_NpcAmountInput(int fd,struct map_session_data *sd) int amount = (int)RFIFOL(fd,6); sd->npc_amount = amount; - npc_scriptcont(sd, npcid, false); + npc->scriptcont(sd, npcid, false); } @@ -11731,7 +11731,7 @@ void clif_parse_NpcStringInput(int fd, struct map_session_data* sd) return; // invalid input safestrncpy(sd->npc_str, message, min(message_len,CHATBOX_SIZE)); - npc_scriptcont(sd, npcid, false); + npc->scriptcont(sd, npcid, false); } @@ -11741,7 +11741,7 @@ void clif_parse_NpcCloseClicked(int fd,struct map_session_data *sd) { if (!sd->npc_id) //Avoid parsing anything when the script was done with. [Skotlex] return; - npc_scriptcont(sd, RFIFOL(fd,2), true); + npc->scriptcont(sd, RFIFOL(fd,2), true); } @@ -13275,9 +13275,9 @@ void clif_parse_GMKick(int fd, struct map_session_data *sd) clif->GM_kickack(sd, 0); return; } - npc_unload_duplicates(nd); - npc_unload(nd,true); - npc_read_event_script(); + npc->unload_duplicates(nd); + npc->unload(nd,true); + npc->read_event_script(); } break; @@ -15293,7 +15293,7 @@ void clif_parse_cashshop_buy(int fd, struct map_session_data *sd) short amount = RFIFOW(fd,4); int points = RFIFOL(fd,6); - fail = npc_cashshop_buy(sd, nameid, amount, points); + fail = npc->cashshop_buy(sd, nameid, amount, points); #else int len = RFIFOW(fd,2); int points = RFIFOL(fd,4); @@ -15305,7 +15305,7 @@ void clif_parse_cashshop_buy(int fd, struct map_session_data *sd) ShowWarning("Player %u sent incorrect cash shop buy packet (len %u:%u)!\n", sd->status.char_id, len, 10 + count * 4); return; } - fail = npc_cashshop_buylist(sd,points,count,item_list); + fail = npc->cashshop_buylist(sd,points,count,item_list); #endif } diff --git a/src/map/elemental.c b/src/map/elemental.c index 1ef85b3e5..855d9e2c6 100644 --- a/src/map/elemental.c +++ b/src/map/elemental.c @@ -238,7 +238,7 @@ int elemental_data_received(struct s_elemental *ele, bool flag) { 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; - ed->bl.id = npc_get_new_npc_id(); + ed->bl.id = npc->get_new_npc_id(); ed->master = sd; ed->db = db; memcpy(&ed->elemental, ele, sizeof(struct s_elemental)); diff --git a/src/map/guild.c b/src/map/guild.c index 37335f9d0..6219fc770 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -429,7 +429,7 @@ int guild_npc_request_info(int guild_id,const char *event) if( guild->search(guild_id) ) { if( event && *event ) - npc_event_do(event); + npc->event_do(event); return 0; } @@ -622,7 +622,7 @@ int guild_recv_info(struct guild *sg) { 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); + npc->event_do(ev->name); ev2=ev->next; aFree(ev); ev=ev2; @@ -1736,7 +1736,7 @@ int castle_guild_broken_sub(DBKey key, DBData *data, va_list ap) // We call castle_event::OnGuildBreak of all castles of the guild // You can set all castle_events in the 'db/castle_db.txt' safestrncpy(name, gc->castle_event, sizeof(name)); - npc_event_do(strcat(name, "::OnGuildBreak")); + npc->event_do(strcat(name, "::OnGuildBreak")); //Save the new 'owner', this should invoke guardian clean up and other such things. guild->castledatasave(gc->castle_id, 1, 0); @@ -2044,8 +2044,8 @@ int guild_castledataloadack(int len, struct guild_castle *gc) ev = i; // offset of castle or -1 if( ev < 0 ) { //No castles owned, invoke OnAgitInit as it is. - npc_event_doall("OnAgitInit"); - npc_event_doall("OnAgitInit2"); + npc->event_doall("OnAgitInit"); + npc->event_doall("OnAgitInit2"); } else { // load received castles into memory, one by one for( i = 0; i < n; i++, gc++ ) { struct guild_castle *c = guild->castle_search(gc->castle_id); @@ -2076,7 +2076,7 @@ int guild_castledataloadack(int len, struct guild_castle *gc) *---------------------------------------------------*/ void guild_agit_start(void) { // Run All NPC_Event[OnAgitStart] - int c = npc_event_doall("OnAgitStart"); + int c = npc->event_doall("OnAgitStart"); ShowStatus("NPC_Event:[OnAgitStart] Run (%d) Events by @AgitStart.\n",c); } @@ -2085,7 +2085,7 @@ void guild_agit_start(void) *---------------------------------------------------*/ void guild_agit_end(void) { // Run All NPC_Event[OnAgitEnd] - int c = npc_event_doall("OnAgitEnd"); + int c = npc->event_doall("OnAgitEnd"); ShowStatus("NPC_Event:[OnAgitEnd] Run (%d) Events by @AgitEnd.\n",c); } @@ -2094,7 +2094,7 @@ void guild_agit_end(void) *---------------------------------------------------*/ void guild_agit2_start(void) { // Run All NPC_Event[OnAgitStart2] - int c = npc_event_doall("OnAgitStart2"); + int c = npc->event_doall("OnAgitStart2"); ShowStatus("NPC_Event:[OnAgitStart2] Run (%d) Events by @AgitStart2.\n",c); } @@ -2103,7 +2103,7 @@ void guild_agit2_start(void) *---------------------------------------------------*/ void guild_agit2_end(void) { // Run All NPC_Event[OnAgitEnd2] - int c = npc_event_doall("OnAgitEnd2"); + int c = npc->event_doall("OnAgitEnd2"); ShowStatus("NPC_Event:[OnAgitEnd2] Run (%d) Events by @AgitEnd2.\n",c); } diff --git a/src/map/homunculus.c b/src/map/homunculus.c index e0443f1f6..81971ebef 100644 --- a/src/map/homunculus.c +++ b/src/map/homunculus.c @@ -736,7 +736,7 @@ bool homunculus_create(struct map_session_data *sd, struct s_homunculus *hom) { } sd->hd = hd = (struct homun_data*)aCalloc(1,sizeof(struct homun_data)); hd->bl.type = BL_HOM; - hd->bl.id = npc_get_new_npc_id(); + hd->bl.id = npc->get_new_npc_id(); hd->master = sd; hd->homunculusDB = &homun->db[i]; diff --git a/src/map/instance.c b/src/map/instance.c index 204b7c137..98a0dfc8f 100644 --- a/src/map/instance.c +++ b/src/map/instance.c @@ -297,7 +297,7 @@ int instance_map_npcsub(struct block_list* bl, va_list args) { struct npc_data* nd = (struct npc_data*)bl; int16 m = va_arg(args, int); // Destination Map - if ( npc_duplicate4instance(nd, m) ) + if ( npc->duplicate4instance(nd, m) ) ShowDebug("instance_map_npcsub:npc_duplicate4instance failed (%s/%d)\n",nd->name,m); return 1; @@ -341,7 +341,7 @@ int instance_cleanup_sub(struct block_list *bl, va_list ap) { iMap->quit((struct map_session_data *) bl); break; case BL_NPC: - npc_unload((struct npc_data *)bl,true); + npc->unload((struct npc_data *)bl,true); break; case BL_MOB: unit->free(bl,CLR_OUTSIGHT); diff --git a/src/map/map.c b/src/map/map.c index 64e765b27..e55dea152 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -372,7 +372,7 @@ int map_moveblock(struct block_list *bl, int x1, int y1, unsigned int tick) sc->data[SC_PROPERTYWALK]->val3 >= skill->get_maxcount(sc->data[SC_PROPERTYWALK]->val1,sc->data[SC_PROPERTYWALK]->val2) ) status_change_end(bl,SC_PROPERTYWALK,INVALID_TIMER); } else if (bl->type == BL_NPC) - npc_unsetcells((TBL_NPC*)bl); + npc->unsetcells((TBL_NPC*)bl); if (moveblock) iMap->delblock(bl); #ifdef CELL_NOSTACK @@ -443,7 +443,7 @@ int map_moveblock(struct block_list *bl, int x1, int y1, unsigned int tick) } } } else if (bl->type == BL_NPC) - npc_setcells((TBL_NPC*)bl); + npc->setcells((TBL_NPC*)bl); return 0; } @@ -1534,10 +1534,10 @@ int map_quit(struct map_session_data *sd) { } if (sd->npc_timer_id != INVALID_TIMER) //Cancel the event timer. - npc_timerevent_quit(sd); + npc->timerevent_quit(sd); if (sd->npc_id) - npc_event_dequeue(sd); + npc->event_dequeue(sd); if( sd->bg_id && !sd->bg_queue.arena ) /* TODO: dump this chunk after bg_queue is fully enabled */ bg_team_leave(sd,1); @@ -1548,7 +1548,7 @@ int map_quit(struct map_session_data *sd) { for( i = 0; i < sd->queues_count; i++ ) { struct hQueue *queue; if( (queue = script->queue(sd->queues[i])) && queue->onLogOut[0] != '\0' ) { - npc_event(sd, queue->onLogOut, 0); + npc->event(sd, queue->onLogOut, 0); } } /* two times, the npc event above may assign a new one or delete others */ @@ -1557,7 +1557,7 @@ int map_quit(struct map_session_data *sd) { script->queue_remove(sd->queues[i],sd->status.account_id); } - npc_script_event(sd, NPCE_LOGOUT); + 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 @@ -2104,7 +2104,7 @@ void map_spawnmobs(int16 m) if(map[m].moblist[i]!=NULL) { k+=map[m].moblist[i]->num; - npc_parse_mob2(map[m].moblist[i]); + npc->parse_mob2(map[m].moblist[i]); } if (battle_config.etc_log && k > 0) @@ -2361,7 +2361,7 @@ void map_cellfromcache(struct map_data *m) { m->setcell = map_setcell; for(i = 0; i < m->npc_num; i++) { - npc_setcells(m->npc[i]); + npc->setcells(m->npc[i]); } } } @@ -3274,9 +3274,9 @@ int map_config_read(char *cfgName) { else if (strcmpi(w1, "delmap") == 0) iMap->map_num--; else if (strcmpi(w1, "npc") == 0) - npc_addsrcfile(w2); + npc->addsrcfile(w2); else if (strcmpi(w1, "delnpc") == 0) - npc_delsrcfile(w2); + npc->delsrcfile(w2); else if (strcmpi(w1, "autosave_time") == 0) { iMap->autosave_interval = atoi(w2); if (iMap->autosave_interval < 1) //Revert to default saving. @@ -3379,7 +3379,7 @@ void map_reloadnpc_sub(char *cfgName) *ptr = '\0'; if (strcmpi(w1, "npc") == 0) - npc_addsrcfile(w2); + npc->addsrcfile(w2); else if (strcmpi(w1, "import") == 0) map_reloadnpc_sub(w2); else @@ -3392,7 +3392,7 @@ void map_reloadnpc_sub(char *cfgName) void map_reloadnpc(bool clear) { if (clear) - npc_addsrcfile("clear"); // this will clear the current script list + npc->addsrcfile("clear"); // this will clear the current script list #ifdef RENEWAL map_reloadnpc_sub("npc/re/scripts_main.conf"); @@ -3563,7 +3563,7 @@ void map_zone_remove(int m) { } } - npc_parse_mapflag(map[m].name,empty,flag,params,empty,empty,empty); + npc->parse_mapflag(map[m].name,empty,flag,params,empty,empty,empty); aFree(map[m].zone_mf[k]); map[m].zone_mf[k] = NULL; } @@ -4287,7 +4287,7 @@ void map_zone_apply(int m, struct map_zone_data *zone, const char* start, const if( map_zone_mf_cache(m,flag,params) ) continue; - npc_parse_mapflag(map[m].name,empty,flag,params,start,buffer,filepath); + npc->parse_mapflag(map[m].name,empty,flag,params,start,buffer,filepath); } } /* used on npc load and reload to apply all "Normal" and "PK Mode" zones */ @@ -4315,7 +4315,7 @@ void map_zone_init(void) { if( map[j].zone == zone ) { if( map_zone_mf_cache(j,flag,params) ) break; - npc_parse_mapflag(map[j].name,empty,flag,params,empty,empty,empty); + npc->parse_mapflag(map[j].name,empty,flag,params,empty,empty,empty); } } } @@ -4337,7 +4337,7 @@ void map_zone_init(void) { if( map[j].zone == zone ) { if( map_zone_mf_cache(j,flag,params) ) break; - npc_parse_mapflag(map[j].name,empty,flag,params,empty,empty,empty); + npc->parse_mapflag(map[j].name,empty,flag,params,empty,empty,empty); } } } @@ -4869,7 +4869,7 @@ int cleanup_sub(struct block_list *bl, va_list ap) { iMap->quit((struct map_session_data *) bl); break; case BL_NPC: - npc_unload((struct npc_data *)bl,false); + npc->unload((struct npc_data *)bl,false); break; case BL_MOB: unit->free(bl,CLR_OUTSIGHT); @@ -4917,7 +4917,7 @@ void do_final(void) mapit->free(iter); /* prepares npcs for a faster shutdown process */ - do_clear_npc(); + npc->do_clear_npc(); // remove all objects on maps for (i = 0; i < iMap->map_num; i++) { @@ -4936,7 +4936,7 @@ void do_final(void) chrif->do_final_chrif(); ircbot->final();/* before clif. */ clif->final(); - do_final_npc(); + npc->final(); script->final(); itemdb->final(); instance->final(); @@ -5170,6 +5170,7 @@ void map_hp_symbols(void) { HPM->share(mercenary,"mercenary"); HPM->share(mob,"mob"); HPM->share(unit,"unit"); + HPM->share(npc,"npc"); /* partial */ HPM->share(mapit,"mapit"); @@ -5416,13 +5417,13 @@ int do_init(int argc, char *argv[]) mercenary->init(); elemental->do_init_elemental(); do_init_quest(); - do_init_npc(); + npc->init(); unit->init(); do_init_battleground(); iDuel->do_init_duel(); vending->init(); - npc_event_do_oninit(); // Init npcs (OnInit) + npc->event_do_oninit(); // Init npcs (OnInit) if (battle_config.pk_mode) ShowNotice("Server is running on '"CL_WHITE"PK Mode"CL_RESET"'.\n"); diff --git a/src/map/mercenary.c b/src/map/mercenary.c index 8bafcde97..bf802c643 100644 --- a/src/map/mercenary.c +++ b/src/map/mercenary.c @@ -301,7 +301,7 @@ int merc_data_received(struct s_mercenary *merc, bool flag) { 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(); + md->bl.id = npc->get_new_npc_id(); md->devotion_flag = 0; md->master = sd; diff --git a/src/map/mob.c b/src/map/mob.c index c566262df..13fdae1ee 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -132,7 +132,7 @@ void mvptomb_create(struct mob_data *md, char *killer, time_t time) CREATE(nd, struct npc_data, 1); - nd->bl.id = md->tomb_nid = npc_get_new_npc_id(); + nd->bl.id = md->tomb_nid = npc->get_new_npc_id(); nd->dir = md->ud.dir; nd->bl.m = md->bl.m; @@ -259,7 +259,7 @@ int mob_parse_dataset(struct spawn_data *data) *------------------------------------------*/ struct mob_data* mob_spawn_dataset(struct spawn_data *data) { struct mob_data *md = (struct mob_data*)aCalloc(1, sizeof(struct mob_data)); - md->bl.id= npc_get_new_npc_id(); + md->bl.id= npc->get_new_npc_id(); md->bl.type = BL_MOB; md->bl.m = data->m; md->bl.x = data->x; @@ -2579,15 +2579,15 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) if( md->npc_event[0] && !md->state.npc_killmonster ) { if( sd && battle_config.mob_npc_event_type ) { pc->setparam(sd, SP_KILLERRID, sd->bl.id); - npc_event(sd,md->npc_event,0); + npc->event(sd,md->npc_event,0); } else if( mvp_sd ) { pc->setparam(mvp_sd, SP_KILLERRID, sd?sd->bl.id:0); - npc_event(mvp_sd,md->npc_event,0); + npc->event(mvp_sd,md->npc_event,0); } else - npc_event_do(md->npc_event); + npc->event_do(md->npc_event); } else if( mvp_sd && !md->state.npc_killmonster ) { pc->setparam(mvp_sd, SP_KILLEDRID, md->class_); - npc_script_event(mvp_sd, NPCE_KILLNPC); // PCKillNPC [Lance] + npc->script_event(mvp_sd, NPCE_KILLNPC); // PCKillNPC [Lance] } md->status.hp = 1; diff --git a/src/map/npc.c b/src/map/npc.c index c4ef1bcf9..1a813560b 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -36,15 +36,7 @@ #include #include - -struct npc_data* fake_nd; - -// linked list of npc source files -struct npc_src_list { - struct npc_src_list* next; - char name[4]; // dynamic array, the structure is allocated with extra bytes (string length) -}; -static struct npc_src_list* npc_src_files = NULL; +struct npc_interface npc_s; static int npc_id=START_NPC_NUM; static int npc_warp=0; @@ -54,46 +46,9 @@ static int npc_mob=0; static int npc_delay_mob=0; static int npc_cache_mob=0; -/// 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) ) - 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) ) - return npc_id++;// available - } - // full loop, nothing available - ShowFatalError("npc_get_new_npc_id: All ids are taken. Exiting..."); - exit(1); - } -} - -static DBMap* ev_db; // const char* event_name -> struct event_data* -static DBMap* ev_label_db; // const char* label_name (without leading "::") -> struct linkdb_node** (key: struct npc_data*; data: struct event_data*) -static DBMap* npcname_db; // const char* npc_name -> struct npc_data* - -struct event_data { - struct npc_data *nd; - int pos; -}; - -static struct eri *timer_event_ers; //For the npc timer data. [Skotlex] - -/* hello */ static char *npc_last_path; static char *npc_last_ref; - -struct npc_path_data { - char* path; - unsigned short references; -}; struct npc_path_data *npc_last_npd; -static DBMap *npc_path_db; //For holding the view data of npc classes. [Skotlex] static struct view_data npc_viewdb[MAX_NPC_CLASS]; @@ -120,7 +75,26 @@ struct view_data* npc_get_viewdata(int class_) return NULL; } -static int npc_isnear_sub(struct block_list* bl, va_list args) { +/// 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) ) + 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) ) + return npc_id++;// available + } + // full loop, nothing available + ShowFatalError("npc_get_new_npc_id: All ids are taken. Exiting..."); + exit(1); + } +} + +int npc_isnear_sub(struct block_list* bl, va_list args) { struct npc_data *nd = (struct npc_data*)bl; if( nd->option & (OPTION_HIDE|OPTION_INVISIBLE) ) @@ -132,7 +106,7 @@ static 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) ) + iMap->foreachinrange(npc->isnear_sub,bl, battle_config.min_npc_vendchat_distance, BL_NPC) ) return true; return false; @@ -149,7 +123,7 @@ int npc_ontouch_event(struct map_session_data *sd, struct npc_data *nd) return 1; // Can't trigger 'OnTouch_'. try 'OnTouch' later. snprintf(name, ARRAYLENGTH(name), "%s::%s", nd->exname, script->config.ontouch_name); - return npc_event(sd,name,1); + return npc->event(sd,name,1); } int npc_ontouch2_event(struct map_session_data *sd, struct npc_data *nd) @@ -160,7 +134,7 @@ int npc_ontouch2_event(struct map_session_data *sd, struct npc_data *nd) return 0; snprintf(name, ARRAYLENGTH(name), "%s::%s", nd->exname, script->config.ontouch2_name); - return npc_event(sd,name,2); + return npc->event(sd,name,2); } /*========================================== @@ -179,13 +153,13 @@ int npc_enable_sub(struct block_list *bl, va_list ap) if (nd->option&OPTION_INVISIBLE) return 1; - if( npc_ontouch_event(sd,nd) > 0 && npc_ontouch2_event(sd,nd) > 0 ) + if( npc->ontouch_event(sd,nd) > 0 && npc->ontouch2_event(sd,nd) > 0 ) { // failed to run OnTouch event, so just click the npc if (sd->npc_id != 0) return 0; pc_stop_walking(sd,1); - npc_click(sd,nd); + npc->click(sd,nd); } } return 0; @@ -196,7 +170,7 @@ int npc_enable_sub(struct block_list *bl, va_list ap) *------------------------------------------*/ int npc_enable(const char* name, int flag) { - struct npc_data* nd = npc_name2id(name); + struct npc_data* nd = npc->name2id(name); if ( nd == NULL ) { ShowError("npc_enable: Attempted to %s a non-existing NPC '%s' (flag=%d).\n", (flag&3) ? "show" : "hide", name, flag); @@ -224,7 +198,7 @@ int npc_enable(const char* name, int flag) 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 ); + 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 ); return 0; } @@ -234,7 +208,7 @@ int npc_enable(const char* name, int flag) *------------------------------------------*/ struct npc_data* npc_name2id(const char* name) { - return (struct npc_data *) strdb_get(npcname_db, name); + return (struct npc_data *) strdb_get(npc->name_db, name); } /** * For the Secure NPC Timeout option (check config/Secure.h) [RR] @@ -277,7 +251,7 @@ int npc_rr_secure_timeout_timer(int tid, unsigned int tick, int id, intptr_t dat clif->scriptclear(sd,sd->npc_id); sd->npc_idle_timer = INVALID_TIMER; } else //Create a new instance of ourselves to continue - sd->npc_idle_timer = iTimer->add_timer(iTimer->gettick() + (SECURE_NPCTIMEOUT_INTERVAL*1000),npc_rr_secure_timeout_timer,sd->bl.id,0); + sd->npc_idle_timer = iTimer->add_timer(iTimer->gettick() + (SECURE_NPCTIMEOUT_INTERVAL*1000),npc->secure_timeout_timer,sd->bl.id,0); return 0; } #endif @@ -317,7 +291,7 @@ int npc_event_dequeue(struct map_session_data* sd) /** * @see DBCreateData */ -static DBData npc_event_export_create(DBKey key, va_list args) +DBData npc_event_export_create(DBKey key, va_list args) { struct linkdb_node** head_ptr; CREATE(head_ptr, struct linkdb_node*, 1); @@ -329,7 +303,7 @@ static DBData npc_event_export_create(DBKey key, va_list args) * exports a npc event label * called from npc_parse_script *------------------------------------------*/ -static int npc_event_export(struct npc_data *nd, int i) +int npc_event_export(struct npc_data *nd, int i) { char* lname = nd->u.scr.label_list[i].name; int pos = nd->u.scr.label_list[i].pos; @@ -338,14 +312,14 @@ static int npc_event_export(struct npc_data *nd, int i) struct linkdb_node **label_linkdb = NULL; char buf[EVENT_NAME_LENGTH]; snprintf(buf, ARRAYLENGTH(buf), "%s::%s", nd->exname, lname); - if (strdb_exists(ev_db, buf)) // There was already another event of the same name? + if (strdb_exists(npc->ev_db, buf)) // There was already another event of the same name? return 1; // generate the data and insert it CREATE(ev, struct event_data, 1); ev->nd = nd; ev->pos = pos; - strdb_put(ev_db, buf, ev); - label_linkdb = strdb_ensure(ev_label_db, lname, npc_event_export_create); + strdb_put(npc->ev_db, buf, ev); + label_linkdb = strdb_ensure(npc->ev_label_db, lname, npc->event_export_create); linkdb_insert(label_linkdb, nd, ev); } return 0; @@ -373,7 +347,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(iMap->id2sd(rid), ev, buf); } else { script->run(ev->nd->u.scr.script, ev->pos, rid, ev->nd->bl.id); @@ -386,10 +360,10 @@ void npc_event_doall_sub(void *key, void *data, va_list ap) int npc_event_do(const char* name) { if( name[0] == ':' && name[1] == ':' ) { - return npc_event_doall(name+2); // skip leading "::" + return npc->event_doall(name+2); // skip leading "::" } else { - struct event_data *ev = strdb_get(ev_db, name); + struct event_data *ev = strdb_get(npc->ev_db, name); if (ev) { script->run(ev->nd->u.scr.script, ev->pos, 0, ev->nd->bl.id); return 1; @@ -402,19 +376,19 @@ int npc_event_do(const char* name) int npc_event_doall_id(const char* name, int rid) { int c = 0; - struct linkdb_node **label_linkdb = strdb_get(ev_label_db, name); + struct linkdb_node **label_linkdb = strdb_get(npc->ev_label_db, name); if (label_linkdb == NULL) return 0; - linkdb_foreach(label_linkdb, npc_event_doall_sub, &c, name, rid); + linkdb_foreach(label_linkdb, npc->event_doall_sub, &c, name, rid); return c; } // runs the specified event (global only) int npc_event_doall(const char* name) { - return npc_event_doall_id(name, 0); + return npc->event_doall_id(name, 0); } /*========================================== @@ -447,23 +421,23 @@ int npc_event_do_clock(int tid, unsigned int tick, int id, intptr_t data) } sprintf(buf,"OnMinute%02d",t->tm_min); - c += npc_event_doall(buf); + c += npc->event_doall(buf); sprintf(buf,"OnClock%02d%02d",t->tm_hour,t->tm_min); - c += npc_event_doall(buf); + c += npc->event_doall(buf); sprintf(buf,"On%s%02d%02d",day,t->tm_hour,t->tm_min); - c += npc_event_doall(buf); + c += npc->event_doall(buf); } if (t->tm_hour != ev_tm_b.tm_hour) { sprintf(buf,"OnHour%02d",t->tm_hour); - c += npc_event_doall(buf); + c += npc->event_doall(buf); } if (t->tm_mday != ev_tm_b.tm_mday) { sprintf(buf,"OnDay%02d%02d",t->tm_mon+1,t->tm_mday); - c += npc_event_doall(buf); + c += npc->event_doall(buf); } memcpy(&ev_tm_b,t,sizeof(ev_tm_b)); @@ -475,9 +449,9 @@ int npc_event_do_clock(int tid, unsigned int tick, int id, intptr_t data) *------------------------------------------*/ void npc_event_do_oninit(void) { - ShowStatus("Event '"CL_WHITE"OnInit"CL_RESET"' executed with '"CL_WHITE"%d"CL_RESET"' NPCs."CL_CLL"\n", npc_event_doall("OnInit")); + ShowStatus("Event '"CL_WHITE"OnInit"CL_RESET"' executed with '"CL_WHITE"%d"CL_RESET"' NPCs."CL_CLL"\n", npc->event_doall("OnInit")); - iTimer->add_timer_interval(iTimer->gettick()+100,npc_event_do_clock,0,0,1000); + iTimer->add_timer_interval(iTimer->gettick()+100,npc->event_do_clock,0,0,1000); } /*========================================== @@ -538,7 +512,7 @@ int npc_timerevent(int tid, unsigned int tick, int id, intptr_t data) if( ted->rid && !(sd = iMap->id2sd(ted->rid)) ) { ShowError("npc_timerevent: Attached player not found.\n"); - ers_free(timer_event_ers, ted); + ers_free(npc->timer_event_ers, ted); return 0; } @@ -563,9 +537,9 @@ int npc_timerevent(int tid, unsigned int tick, int id, intptr_t data) next = nd->u.scr.timer_event[ ted->next ].timer - nd->u.scr.timer_event[ ted->next - 1 ].timer; ted->time += next; if( sd ) - sd->npc_timer_id = iTimer->add_timer(tick+next,npc_timerevent,id,(intptr_t)ted); + sd->npc_timer_id = iTimer->add_timer(tick+next,npc->timerevent,id,(intptr_t)ted); else - nd->u.scr.timerid = iTimer->add_timer(tick+next,npc_timerevent,id,(intptr_t)ted); + nd->u.scr.timerid = iTimer->add_timer(tick+next,npc->timerevent,id,(intptr_t)ted); } else { @@ -574,7 +548,7 @@ int npc_timerevent(int tid, unsigned int tick, int id, intptr_t data) else nd->u.scr.timerid = INVALID_TIMER; - ers_free(timer_event_ers, ted); + ers_free(npc->timer_event_ers, ted); } // Run the script @@ -619,20 +593,20 @@ int npc_timerevent_start(struct npc_data* nd, int rid) int next; struct timer_event_data *ted; // Arrange for the next event - ted = ers_alloc(timer_event_ers, struct timer_event_data); + ted = ers_alloc(npc->timer_event_ers, struct timer_event_data); ted->next = j; // Set event index ted->time = nd->u.scr.timer_event[j].timer; next = nd->u.scr.timer_event[j].timer - nd->u.scr.timer; if( sd ) { ted->rid = sd->bl.id; // Attach only the player if attachplayerrid was used. - sd->npc_timer_id = iTimer->add_timer(tick+next,npc_timerevent,nd->bl.id,(intptr_t)ted); + sd->npc_timer_id = iTimer->add_timer(tick+next,npc->timerevent,nd->bl.id,(intptr_t)ted); } else { ted->rid = 0; nd->u.scr.timertick = tick; // Set when timer is started - nd->u.scr.timerid = iTimer->add_timer(tick+next,npc_timerevent,nd->bl.id,(intptr_t)ted); + nd->u.scr.timerid = iTimer->add_timer(tick+next,npc->timerevent,nd->bl.id,(intptr_t)ted); } } else if (!sd) { @@ -667,8 +641,8 @@ int npc_timerevent_stop(struct npc_data* nd) { td = iTimer->get_timer(*tid); if( td && td->data ) - ers_free(timer_event_ers, (void*)td->data); - iTimer->delete_timer(*tid,npc_timerevent); + ers_free(npc->timer_event_ers, (void*)td->data); + iTimer->delete_timer(*tid,npc->timerevent); *tid = INVALID_TIMER; } @@ -701,7 +675,7 @@ void npc_timerevent_quit(struct map_session_data* sd) // Delete timer nd = (struct npc_data *)iMap->id2bl(td->id); ted = (struct timer_event_data*)td->data; - iTimer->delete_timer(sd->npc_timer_id, npc_timerevent); + iTimer->delete_timer(sd->npc_timer_id, npc->timerevent); sd->npc_timer_id = INVALID_TIMER; // Execute OnTimerQuit @@ -711,7 +685,7 @@ void npc_timerevent_quit(struct map_session_data* sd) struct event_data *ev; snprintf(buf, ARRAYLENGTH(buf), "%s::OnTimerQuit", nd->exname); - ev = (struct event_data*)strdb_get(ev_db, buf); + ev = (struct event_data*)strdb_get(npc->ev_db, buf); if( ev && ev->nd != nd ) { ShowWarning("npc_timerevent_quit: Unable to execute \"OnTimerQuit\", two NPCs have the same event name [%s]!\n",buf); @@ -740,7 +714,7 @@ void npc_timerevent_quit(struct map_session_data* sd) nd->u.scr.timertick = old_tick; } } - ers_free(timer_event_ers, ted); + ers_free(npc->timer_event_ers, ted); } /*========================================== @@ -780,9 +754,9 @@ int npc_settimerevent_tick(struct npc_data* nd, int newtimer) // Check if timer is started flag = (nd->u.scr.timerid != INVALID_TIMER || nd->u.scr.timertick); - if( flag ) npc_timerevent_stop(nd); + if( flag ) npc->timerevent_stop(nd); nd->u.scr.timer = newtimer; - if( flag ) npc_timerevent_start(nd, -1); + if( flag ) npc->timerevent_start(nd, -1); nd->u.scr.rid = old_rid; return 0; @@ -807,7 +781,7 @@ int npc_event_sub(struct map_session_data* sd, struct event_data* ev, const char if( ev->nd->option&OPTION_INVISIBLE ) { //Disabled npc, shouldn't trigger event. - npc_event_dequeue(sd); + npc->event_dequeue(sd); return 2; } script->run(ev->nd->u.scr.script,ev->pos,sd->bl.id,ev->nd->bl.id); @@ -819,7 +793,7 @@ int npc_event_sub(struct map_session_data* sd, struct event_data* ev, const char *------------------------------------------*/ int npc_event(struct map_session_data* sd, const char* eventname, int ontouch) { - struct event_data* ev = (struct event_data*)strdb_get(ev_db, eventname); + struct event_data* ev = (struct event_data*)strdb_get(npc->ev_db, eventname); struct npc_data *nd; nullpo_ret(sd); @@ -840,7 +814,7 @@ int npc_event(struct map_session_data* sd, const char* eventname, int ontouch) break; } - return npc_event_sub(sd,ev,eventname); + return npc->event_sub(sd,ev,eventname); } /*========================================== @@ -865,7 +839,7 @@ int npc_touch_areanpc_sub(struct block_list *bl, va_list ap) if( pc_id == sd->bl.id ) return 0; - npc_event(sd,name,1); + npc->event(sd,name,1); return 1; } @@ -894,7 +868,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); + 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); } return 0; } @@ -969,7 +943,7 @@ int npc_touch_areanpc(struct map_session_data* sd, int16 m, int16 x, int16 y) break; } - if( npc_ontouch_event(sd,map[m].npc[i]) > 0 && npc_ontouch2_event(sd,map[m].npc[i]) > 0 ) + if( npc->ontouch_event(sd,map[m].npc[i]) > 0 && npc->ontouch2_event(sd,map[m].npc[i]) > 0 ) { // failed to run OnTouch event, so just click the npc struct unit_data *ud = unit->bl2ud(&sd->bl); if( ud && ud->walkpath.path_pos < ud->walkpath.path_len ) @@ -978,7 +952,7 @@ int npc_touch_areanpc(struct map_session_data* sd, int16 m, int16 x, int16 y) ud->walkpath.path_pos = ud->walkpath.path_len; } sd->areanpc_id = map[m].npc[i]->bl.id; - npc_click(sd,map[m].npc[i]); + npc->click(sd,map[m].npc[i]); } break; } @@ -1028,7 +1002,7 @@ int npc_touch_areanpc2(struct mob_data *md) if( map[m].npc[i]->bl.id == md->areanpc_id ) break; // Already touch this NPC snprintf(eventname, ARRAYLENGTH(eventname), "%s::OnTouchNPC", map[m].npc[i]->exname); - if( (ev = (struct event_data*)strdb_get(ev_db, eventname)) == NULL || ev->nd == NULL ) + if( (ev = (struct event_data*)strdb_get(npc->ev_db, eventname)) == NULL || ev->nd == NULL ) break; // No OnTouchNPC Event md->areanpc_id = map[m].npc[i]->bl.id; id = md->bl.id; // Stores Unique ID @@ -1134,7 +1108,7 @@ struct npc_data* npc_checknear(struct map_session_data* sd, struct block_list* b *------------------------------------------*/ int npc_globalmessage(const char* name, const char* mes) { - struct npc_data* nd = npc_name2id(name); + struct npc_data* nd = npc->name2id(name); char temp[100]; if (!nd) @@ -1185,7 +1159,7 @@ int npc_click(struct map_session_data* sd, struct npc_data* nd) } if(!nd) return 1; - if ((nd = npc_checknear(sd,&nd->bl)) == NULL) + if ((nd = npc->checknear(sd,&nd->bl)) == NULL) return 1; //Hidden/Disabled npc. if (nd->class_ < 0 || nd->option&(OPTION_INVISIBLE|OPTION_HIDE)) @@ -1202,7 +1176,7 @@ int npc_click(struct map_session_data* sd, struct npc_data* nd) script->run(nd->u.scr.script,0,sd->bl.id,nd->bl.id); break; case TOMB: - run_tomb(sd,nd); + npc->run_tomb(sd,nd); break; } @@ -1225,9 +1199,9 @@ int npc_scriptcont(struct map_session_data* sd, int id, bool closing) return 1; } - if(id != fake_nd->bl.id) { // Not item script - if ((npc_checknear(sd,iMap->id2bl(id))) == NULL){ - ShowWarning("npc_scriptcont: failed npc_checknear test.\n"); + if(id != npc->fake_nd->bl.id) { // Not item script + if ((npc->checknear(sd,iMap->id2bl(id))) == NULL){ + ShowWarning("npc_scriptcont: failed npc->checknear test.\n"); return 1; } } @@ -1264,7 +1238,7 @@ int npc_buysellsel(struct map_session_data* sd, int id, int type) nullpo_retr(1, sd); - if ((nd = npc_checknear(sd,iMap->id2bl(id))) == NULL) + if ((nd = npc->checknear(sd,iMap->id2bl(id))) == NULL) return 1; if (nd->subtype!=SHOP) { @@ -1374,7 +1348,7 @@ int npc_cashshop_buylist(struct map_session_data *sd, int points, int count, uns } //npc_buylist for script-controlled shops. -static int npc_buylist_sub(struct map_session_data* sd, int n, unsigned short* item_list, struct npc_data* nd) +int npc_buylist_sub(struct map_session_data* sd, int n, unsigned short* item_list, struct npc_data* nd) { char npc_ev[EVENT_NAME_LENGTH]; int i; @@ -1393,7 +1367,7 @@ static int npc_buylist_sub(struct map_session_data* sd, int n, unsigned short* i // invoke event snprintf(npc_ev, ARRAYLENGTH(npc_ev), "%s::OnBuyItem", nd->exname); - npc_event(sd, npc_ev, 0); + npc->event(sd, npc_ev, 0); return 0; } @@ -1492,7 +1466,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,iMap->id2bl(sd->npc_shopid)); if( nd == NULL ) return 3; if( nd->subtype != SHOP ) @@ -1552,7 +1526,7 @@ int npc_buylist(struct map_session_data* sd, int n, unsigned short* item_list) } if( nd->master_nd != NULL ) //Script-based shops. - return npc_buylist_sub(sd,n,item_list,nd->master_nd); + return npc->buylist_sub(sd,n,item_list,nd->master_nd); if( z > (double)sd->status.zeny ) return 1; // Not enough Zeny @@ -1597,7 +1571,7 @@ int npc_buylist(struct map_session_data* sd, int n, unsigned short* item_list) /// npc_selllist for script-controlled shops -static int npc_selllist_sub(struct map_session_data* sd, int n, unsigned short* item_list, struct npc_data* nd) +int npc_selllist_sub(struct map_session_data* sd, int n, unsigned short* item_list, struct npc_data* nd) { char npc_ev[EVENT_NAME_LENGTH]; char card_slot[NAME_LENGTH]; @@ -1647,7 +1621,7 @@ static int npc_selllist_sub(struct map_session_data* sd, int n, unsigned short* // invoke event snprintf(npc_ev, ARRAYLENGTH(npc_ev), "%s::OnSellItem", nd->exname); - npc_event(sd, npc_ev, 0); + npc->event(sd, npc_ev, 0); return 0; } @@ -1665,7 +1639,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, iMap->id2bl(sd->npc_shopid)) ) == NULL || nd->subtype != SHOP ) { return 1; } @@ -1698,7 +1672,7 @@ int npc_selllist(struct map_session_data* sd, int n, unsigned short* item_list) } if( nd->master_nd ) { // Script-controlled shops - return npc_selllist_sub(sd, n, item_list, nd->master_nd); + return npc->selllist_sub(sd, n, item_list, nd->master_nd); } // delete items @@ -1748,7 +1722,7 @@ int npc_remove_map(struct npc_data* nd) { return 1; //Not assigned to a map. m = nd->bl.m; clif->clearunit_area(&nd->bl,CLR_RESPAWN); - npc_unsetcells(nd); + npc->unsetcells(nd); iMap->delblock(&nd->bl); //Remove npc from map[].npc list. [Skotlex] ARR_FIND( 0, map[m].npc_num, i, map[m].npc[i] == nd ); @@ -1763,13 +1737,13 @@ int npc_remove_map(struct npc_data* nd) { /** * @see DBApply */ -static int npc_unload_ev(DBKey key, DBData *data, va_list ap) +int npc_unload_ev(DBKey key, DBData *data, va_list ap) { struct event_data* ev = DB->data2ptr(data); char* npcname = va_arg(ap, char *); if(strcmp(ev->nd->exname,npcname)==0){ - db_remove(ev_db, key); + db_remove(npc->ev_db, key); return 1; } return 0; @@ -1778,7 +1752,7 @@ static int npc_unload_ev(DBKey key, DBData *data, va_list ap) /** * @see DBApply */ -static int npc_unload_ev_label(DBKey key, DBData *data, va_list ap) +int npc_unload_ev_label(DBKey key, DBData *data, va_list ap) { struct linkdb_node **label_linkdb = DB->data2ptr(data); struct npc_data* nd = va_arg(ap, struct npc_data *); @@ -1790,20 +1764,20 @@ static int npc_unload_ev_label(DBKey key, DBData *data, va_list ap) //Chk if npc matches src_id, then unload. //Sub-function used to find duplicates. -static int npc_unload_dup_sub(struct npc_data* nd, va_list args) +int npc_unload_dup_sub(struct npc_data* nd, va_list args) { int src_id; src_id = va_arg(args, int); if (nd->src_id == src_id) - npc_unload(nd, true); + npc->unload(nd, true); return 0; } //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); + iMap->map_foreachnpc(npc->unload_dup_sub,nd->bl.id); } //Removes an npc from map and db. @@ -1811,10 +1785,10 @@ void npc_unload_duplicates(struct npc_data* nd) int npc_unload(struct npc_data* nd, bool single) { nullpo_ret(nd); - npc_remove_map(nd); + npc->remove_map(nd); iMap->deliddb(&nd->bl); if( single ) - strdb_remove(npcname_db, nd->exname); + strdb_remove(npc->name_db, nd->exname); if (nd->chat_id) // remove npc chatroom object and kick users chat->deletenpcchat(nd); @@ -1826,11 +1800,11 @@ int npc_unload(struct npc_data* nd, bool single) { if( single && nd->path ) { struct npc_path_data* npd = NULL; if( nd->path && nd->path != npc_last_ref ) { - npd = strdb_get(npc_path_db, nd->path); + npd = strdb_get(npc->path_db, nd->path); } if( npd && --npd->references == 0 ) { - strdb_remove(npc_path_db, nd->path);/* remove from db */ + strdb_remove(npc->path_db, nd->path);/* remove from db */ aFree(nd->path);/* remove now that no other instances exist */ } } @@ -1842,8 +1816,8 @@ int npc_unload(struct npc_data* nd, bool single) { struct block_list* bl; if( single ) { - ev_db->foreach(ev_db,npc_unload_ev,nd->exname); //Clean up all events related - ev_label_db->foreach(ev_label_db,npc_unload_ev_label,nd); + npc->ev_db->foreach(npc->ev_db,npc->unload_ev,nd->exname); //Clean up all events related + npc->ev_label_db->foreach(npc->ev_label_db,npc->unload_ev_label,nd); } iter = mapit_geteachpc(); @@ -1856,8 +1830,8 @@ int npc_unload(struct npc_data* nd, bool single) { continue; if( td && td->data ) - ers_free(timer_event_ers, (void*)td->data); - iTimer->delete_timer(sd->npc_timer_id, npc_timerevent); + ers_free(npc->timer_event_ers, (void*)td->data); + iTimer->delete_timer(sd->npc_timer_id, npc->timerevent); sd->npc_timer_id = INVALID_TIMER; } } @@ -1867,8 +1841,8 @@ int npc_unload(struct npc_data* nd, bool single) { const struct TimerData *td; td = iTimer->get_timer(nd->u.scr.timerid); if (td && td->data) - ers_free(timer_event_ers, (void*)td->data); - iTimer->delete_timer(nd->u.scr.timerid, npc_timerevent); + ers_free(npc->timer_event_ers, (void*)td->data); + iTimer->delete_timer(nd->u.scr.timerid, npc->timerevent); } if (nd->u.scr.timer_event) aFree(nd->u.scr.timer_event); @@ -1888,7 +1862,7 @@ int npc_unload(struct npc_data* nd, bool single) { guild->flag_remove(nd); } - if( nd->ud != &npc_base_ud ) { + if( nd->ud != &npc->base_ud ) { aFree(nd->ud); nd->ud = NULL; } @@ -1903,9 +1877,9 @@ int npc_unload(struct npc_data* nd, bool single) { // /// Clears the npc source file list -static void npc_clearsrcfile(void) +void npc_clearsrcfile(void) { - struct npc_src_list* file = npc_src_files; + struct npc_src_list* file = npc->src_files; struct npc_src_list* file_tofree; while( file != NULL ) @@ -1914,7 +1888,7 @@ static void npc_clearsrcfile(void) file = file->next; aFree(file_tofree); } - npc_src_files = NULL; + npc->src_files = NULL; } /// Adds a npc source file (or removes all) @@ -1925,12 +1899,12 @@ void npc_addsrcfile(const char* name) if( strcmpi(name, "clear") == 0 ) { - npc_clearsrcfile(); + npc->clearsrcfile(); return; } // prevent multiple insert of source files - file = npc_src_files; + file = npc->src_files; while( file != NULL ) { if( strcmp(name, file->name) == 0 ) @@ -1943,7 +1917,7 @@ void npc_addsrcfile(const char* name) file->next = NULL; safestrncpy(file->name, name, strlen(name) + 1); if( file_prev == NULL ) - npc_src_files = file; + npc->src_files = file; else file_prev->next = file; } @@ -1951,12 +1925,12 @@ void npc_addsrcfile(const char* name) /// Removes a npc source file (or all) void npc_delsrcfile(const char* name) { - struct npc_src_list* file = npc_src_files; + struct npc_src_list* file = npc->src_files; struct npc_src_list* file_prev = NULL; if( strcmpi(name, "all") == 0 ) { - npc_clearsrcfile(); + npc->clearsrcfile(); return; } @@ -1964,8 +1938,8 @@ void npc_delsrcfile(const char* name) { if( strcmp(file->name, name) == 0 ) { - if( npc_src_files == file ) - npc_src_files = file->next; + if( npc->src_files == file ) + npc->src_files = file->next; else file_prev->next = file->next; aFree(file); @@ -1978,7 +1952,7 @@ void npc_delsrcfile(const char* name) /// Parses and sets the name and exname of a npc. /// Assumes that m, x and y are already set in nd. -static void npc_parsename(struct npc_data* nd, const char* name, const char* start, const char* buffer, const char* filepath) +void npc_parsename(struct npc_data* nd, const char* name, const char* start, const char* buffer, const char* filepath) { const char* p; struct npc_data* dnd;// duplicate npc @@ -2013,7 +1987,7 @@ static void npc_parsename(struct npc_data* nd, const char* name, const char* sta safestrncpy(nd->exname, newname, sizeof(nd->exname)); } - if( (dnd=npc_name2id(nd->exname)) != NULL ) {// duplicate unique name, generate new one + if( (dnd=npc->name2id(nd->exname)) != NULL ) {// duplicate unique name, generate new one char this_mapname[32]; char other_mapname[32]; int i = 0; @@ -2021,7 +1995,7 @@ static void npc_parsename(struct npc_data* nd, const char* name, const char* sta do { ++i; snprintf(newname, ARRAYLENGTH(newname), "%d_%d_%d_%d", i, nd->bl.m, nd->bl.x, nd->bl.y); - } while( npc_name2id(newname) != NULL ); + } while( npc->name2id(newname) != NULL ); strcpy(this_mapname, (nd->bl.m==-1?"(not on a map)":mapindex_id2name(map[nd->bl.m].index))); strcpy(other_mapname, (dnd->bl.m==-1?"(not on a map)":mapindex_id2name(map[dnd->bl.m].index))); @@ -2035,9 +2009,9 @@ static void npc_parsename(struct npc_data* nd, const char* name, const char* sta if( npc_last_path != filepath ) { struct npc_path_data * npd = NULL; - if( !(npd = strdb_get(npc_path_db,filepath) ) ) { + if( !(npd = strdb_get(npc->path_db,filepath) ) ) { CREATE(npd, struct npc_path_data, 1); - strdb_put(npc_path_db, filepath, npd); + strdb_put(npc->path_db, filepath, npd); CREATE(npd->path, char, strlen(filepath)+1); safestrncpy(npd->path, filepath, strlen(filepath)+1); @@ -2064,7 +2038,7 @@ struct npc_data* npc_add_warp(char* name, short from_mapid, short from_x, short struct npc_data *nd; CREATE(nd, struct npc_data, 1); - nd->bl.id = npc_get_new_npc_id(); + nd->bl.id = npc->get_new_npc_id(); iMap->addnpc(from_mapid, nd); nd->bl.prev = nd->bl.next = NULL; nd->bl.m = from_mapid; @@ -2072,13 +2046,13 @@ struct npc_data* npc_add_warp(char* name, short from_mapid, short from_x, short nd->bl.y = from_y; safestrncpy(nd->exname, name, ARRAYLENGTH(nd->exname)); - if (npc_name2id(nd->exname) != NULL) + if (npc->name2id(nd->exname) != NULL) flag = 1; if (flag == 1) snprintf(nd->exname, ARRAYLENGTH(nd->exname), "warp_%d_%d_%d", from_mapid, from_x, from_y); - for( i = 0; npc_name2id(nd->exname) != NULL; ++i ) + for( i = 0; npc->name2id(nd->exname) != NULL; ++i ) snprintf(nd->exname, ARRAYLENGTH(nd->exname), "warp%d_%d_%d_%d", i, from_mapid, from_x, from_y); safestrncpy(nd->name, nd->exname, ARRAYLENGTH(nd->name)); @@ -2095,19 +2069,19 @@ struct npc_data* npc_add_warp(char* name, short from_mapid, short from_x, short nd->u.warp.ys = xs; nd->bl.type = BL_NPC; nd->subtype = WARP; - npc_setcells(nd); + npc->setcells(nd); iMap->addblock(&nd->bl); iStatus->set_viewdata(&nd->bl, nd->class_); - nd->ud = &npc_base_ud; + nd->ud = &npc->base_ud; if( map[nd->bl.m].users ) clif->spawn(&nd->bl); - strdb_put(npcname_db, nd->exname, nd); + strdb_put(npc->name_db, nd->exname, nd); return nd; } /// Parses a warp npc. -static const char* npc_parse_warp(char* w1, char* w2, char* w3, char* w4, const char* start, const char* buffer, const char* filepath) +const char* npc_parse_warp(char* w1, char* w2, char* w3, char* w4, const char* start, const char* buffer, const char* filepath) { int x, y, xs, ys, to_x, to_y, m; unsigned short i; @@ -2138,13 +2112,13 @@ static const char* npc_parse_warp(char* w1, char* w2, char* w3, char* w4, const CREATE(nd, struct npc_data, 1); - nd->bl.id = npc_get_new_npc_id(); + nd->bl.id = npc->get_new_npc_id(); iMap->addnpc(m, nd); nd->bl.prev = nd->bl.next = NULL; nd->bl.m = m; nd->bl.x = x; nd->bl.y = y; - npc_parsename(nd, w3, start, buffer, filepath); + npc->parsename(nd, w3, start, buffer, filepath); if (!battle_config.warp_point_debug) nd->class_ = WARP_CLASS; @@ -2160,19 +2134,19 @@ static const char* npc_parse_warp(char* w1, char* w2, char* w3, char* w4, const npc_warp++; nd->bl.type = BL_NPC; nd->subtype = WARP; - npc_setcells(nd); + npc->setcells(nd); iMap->addblock(&nd->bl); iStatus->set_viewdata(&nd->bl, nd->class_); - nd->ud = &npc_base_ud; + nd->ud = &npc->base_ud; if( map[nd->bl.m].users ) clif->spawn(&nd->bl); - strdb_put(npcname_db, nd->exname, nd); + strdb_put(npc->name_db, nd->exname, nd); return strchr(start,'\n');// continue } /// Parses a shop/cashshop npc. -static const char* npc_parse_shop(char* w1, char* w2, char* w3, char* w4, const char* start, const char* buffer, const char* filepath) +const char* npc_parse_shop(char* w1, char* w2, char* w3, char* w4, const char* start, const char* buffer, const char* filepath) { //TODO: could be rewritten to NOT need this temp array [ultramage] #define MAX_SHOPITEM 100 @@ -2263,8 +2237,8 @@ static const char* npc_parse_shop(char* w1, char* w2, char* w3, char* w4, const nd->bl.m = m; nd->bl.x = x; nd->bl.y = y; - nd->bl.id = npc_get_new_npc_id(); - npc_parsename(nd, w3, start, buffer, filepath); + nd->bl.id = npc->get_new_npc_id(); + npc->parsename(nd, w3, start, buffer, filepath); nd->class_ = m==-1?-1:atoi(w4); nd->speed = 200; @@ -2275,14 +2249,14 @@ static const char* npc_parse_shop(char* w1, char* w2, char* w3, char* w4, const iMap->addnpc(m,nd); iMap->addblock(&nd->bl); iStatus->set_viewdata(&nd->bl, nd->class_); - nd->ud = &npc_base_ud; + nd->ud = &npc->base_ud; nd->dir = dir; if( map[nd->bl.m].users ) clif->spawn(&nd->bl); } else {// 'floating' shop? iMap->addiddb(&nd->bl); } - strdb_put(npcname_db, nd->exname, nd); + strdb_put(npc->name_db, nd->exname, nd); return strchr(start,'\n');// continue } @@ -2318,7 +2292,7 @@ void npc_convertlabel_db(struct npc_label_list* label_list, const char *filepath } // Skip the contents of a script. -static const char* npc_skip_script(const char* start, const char* buffer, const char* filepath) +const char* npc_skip_script(const char* start, const char* buffer, const char* filepath) { const char* p; int curly_count; @@ -2379,7 +2353,7 @@ static const char* npc_skip_script(const char* start, const char* buffer, const /// -%TAB%script%TAB%%TAB%-1,{} /// ,,,%TAB%script%TAB%%TAB%,{} /// ,,,%TAB%script%TAB%%TAB%,,,{} -static const char* npc_parse_script(char* w1, char* w2, char* w3, char* w4, const char* start, const char* buffer, const char* filepath, bool runOnInit) { +const char* npc_parse_script(char* w1, char* w2, char* w3, char* w4, const char* start, const char* buffer, const char* filepath, bool runOnInit) { int x, y, dir = 0, m, xs = 0, ys = 0, class_ = 0; // [Valaris] thanks to fov char mapname[32]; struct script_code *scriptroot; @@ -2416,7 +2390,7 @@ static const char* npc_parse_script(char* w1, char* w2, char* w3, char* w4, cons } ++script_start; - end = npc_skip_script(script_start, buffer, filepath); + end = npc->skip_script(script_start, buffer, filepath); if( end == NULL ) return NULL;// (simple) parse error, don't continue @@ -2426,7 +2400,7 @@ static const char* npc_parse_script(char* w1, char* w2, char* w3, char* w4, cons if( script->label_count ) { CREATE(label_list,struct npc_label_list,script->label_count); label_list_num = script->label_count; - npc_convertlabel_db(label_list,filepath); + npc->convertlabel_db(label_list,filepath); } CREATE(nd, struct npc_data, 1); @@ -2447,8 +2421,8 @@ static const char* npc_parse_script(char* w1, char* w2, char* w3, char* w4, cons nd->bl.m = m; nd->bl.x = x; nd->bl.y = y; - npc_parsename(nd, w3, start, buffer, filepath); - nd->bl.id = npc_get_new_npc_id(); + npc->parsename(nd, w3, start, buffer, filepath); + nd->bl.id = npc->get_new_npc_id(); nd->class_ = class_; nd->speed = 200; nd->u.scr.script = scriptroot; @@ -2461,9 +2435,9 @@ static const char* npc_parse_script(char* w1, char* w2, char* w3, char* w4, cons if( m >= 0 ) { iMap->addnpc(m, nd); - nd->ud = &npc_base_ud; + nd->ud = &npc->base_ud; nd->dir = dir; - npc_setcells(nd); + npc->setcells(nd); iMap->addblock(&nd->bl); if( class_ >= 0 ) { iStatus->set_viewdata(&nd->bl, nd->class_); @@ -2474,16 +2448,16 @@ static const char* npc_parse_script(char* w1, char* w2, char* w3, char* w4, cons // we skip iMap->addnpc, but still add it to the list of ID's iMap->addiddb(&nd->bl); } - strdb_put(npcname_db, nd->exname, nd); + strdb_put(npc->name_db, nd->exname, nd); //----------------------------------------- // Loop through labels to export them as necessary for (i = 0; i < nd->u.scr.label_list_num; i++) { - if (npc_event_export(nd, i)) { + if (npc->event_export(nd, i)) { ShowWarning("npc_parse_script : duplicate event %s::%s (%s)\n", nd->exname, nd->u.scr.label_list[i].name, filepath); } - npc_timerevent_export(nd, i); + npc->timerevent_export(nd, i); } nd->u.scr.timerid = INVALID_TIMER; @@ -2494,7 +2468,7 @@ static const char* npc_parse_script(char* w1, char* w2, char* w3, char* w4, cons snprintf(evname, ARRAYLENGTH(evname), "%s::OnInit", nd->exname); - if( ( ev = (struct event_data*)strdb_get(ev_db, evname) ) ) { + if( ( ev = (struct event_data*)strdb_get(npc->ev_db, evname) ) ) { //Execute OnInit script->run(nd->u.scr.script,ev->pos,0,nd->bl.id); @@ -2536,7 +2510,7 @@ const char* npc_parse_duplicate(char* w1, char* w2, char* w3, char* w4, const ch } safestrncpy(srcname, w2+10, length-10); - dnd = npc_name2id(srcname); + dnd = npc->name2id(srcname); if( dnd == NULL) { ShowError("npc_parse_script: original npc not found for duplicate in file '%s', line '%d' : %s\n", filepath, strline(buffer,start-buffer), srcname); return end;// next line, try to continue @@ -2576,8 +2550,8 @@ const char* npc_parse_duplicate(char* w1, char* w2, char* w3, char* w4, const ch nd->bl.m = m; nd->bl.x = x; nd->bl.y = y; - npc_parsename(nd, w3, start, buffer, filepath); - nd->bl.id = npc_get_new_npc_id(); + npc->parsename(nd, w3, start, buffer, filepath); + nd->bl.id = npc->get_new_npc_id(); nd->class_ = class_; nd->speed = 200; nd->src_id = src_id; @@ -2617,9 +2591,9 @@ 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); - nd->ud = &npc_base_ud; + nd->ud = &npc->base_ud; nd->dir = dir; - npc_setcells(nd); + npc->setcells(nd); iMap->addblock(&nd->bl); if( class_ >= 0 ) { iStatus->set_viewdata(&nd->bl, nd->class_); @@ -2630,7 +2604,7 @@ const char* npc_parse_duplicate(char* w1, char* w2, char* w3, char* w4, const ch // we skip iMap->addnpc, but still add it to the list of ID's iMap->addiddb(&nd->bl); } - strdb_put(npcname_db, nd->exname, nd); + strdb_put(npc->name_db, nd->exname, nd); if( type != SCRIPT ) return end; @@ -2638,11 +2612,11 @@ const char* npc_parse_duplicate(char* w1, char* w2, char* w3, char* w4, const ch //----------------------------------------- // Loop through labels to export them as necessary for (i = 0; i < nd->u.scr.label_list_num; i++) { - if (npc_event_export(nd, i)) { + if (npc->event_export(nd, i)) { ShowWarning("npc_parse_duplicate : duplicate event %s::%s (%s)\n", nd->exname, nd->u.scr.label_list[i].name, filepath); } - npc_timerevent_export(nd, i); + npc->timerevent_export(nd, i); } nd->u.scr.timerid = INVALID_TIMER; @@ -2657,7 +2631,7 @@ int npc_duplicate4instance(struct npc_data *snd, int16 m) { return 1; snprintf(newname, ARRAYLENGTH(newname), "dup_%d_%d", map[m].instance_id, snd->bl.id); - if( npc_name2id(newname) != NULL ) { // Name already in use + if( npc->name2id(newname) != NULL ) { // Name already in use ShowError("npc_duplicate4instance: the npcname (%s) is already in use while trying to duplicate npc %s in instance %d.\n", newname, snd->exname, map[m].instance_id); return 1; } @@ -2673,7 +2647,7 @@ int npc_duplicate4instance(struct npc_data *snd, int16 m) { } CREATE(wnd, struct npc_data, 1); - wnd->bl.id = npc_get_new_npc_id(); + wnd->bl.id = npc->get_new_npc_id(); iMap->addnpc(m, wnd); wnd->bl.prev = wnd->bl.next = NULL; wnd->bl.m = m; @@ -2690,13 +2664,13 @@ int npc_duplicate4instance(struct npc_data *snd, int16 m) { wnd->u.warp.ys = snd->u.warp.ys; wnd->bl.type = BL_NPC; wnd->subtype = WARP; - npc_setcells(wnd); + npc->setcells(wnd); iMap->addblock(&wnd->bl); iStatus->set_viewdata(&wnd->bl, wnd->class_); - wnd->ud = &npc_base_ud; + wnd->ud = &npc->base_ud; if( map[wnd->bl.m].users ) clif->spawn(&wnd->bl); - strdb_put(npcname_db, wnd->exname, wnd); + strdb_put(npc->name_db, wnd->exname, wnd); } else { static char w1[50], w2[50], w3[50], w4[50]; const char* stat_buf = "- call from instancing subsystem -\n"; @@ -2710,7 +2684,7 @@ int npc_duplicate4instance(struct npc_data *snd, int16 m) { else snprintf(w4, sizeof(w4), "%d", snd->class_); - npc_parse_duplicate(w1, w2, w3, w4, stat_buf, stat_buf, "INSTANCING"); + npc->parse_duplicate(w1, w2, w3, w4, stat_buf, stat_buf, "INSTANCING"); } return 0; @@ -2750,7 +2724,7 @@ int npc_unsetcells_sub(struct block_list* bl, va_list ap) { struct npc_data *nd = (struct npc_data*)bl; int id = va_arg(ap,int); if (nd->bl.id == id) return 0; - npc_setcells(nd); + npc->setcells(nd); return 1; } @@ -2782,7 +2756,7 @@ void npc_unsetcells(struct npc_data* nd) { map[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 ); + iMap->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) @@ -2833,7 +2807,7 @@ void npc_setclass(struct npc_data* nd, short class_) // @commands (script based) int npc_do_atcmd_event(struct map_session_data* sd, const char* command, const char* message, const char* eventname) { - struct event_data* ev = (struct event_data*)strdb_get(ev_db, eventname); + struct event_data* ev = (struct event_data*)strdb_get(npc->ev_db, eventname); struct npc_data *nd; struct script_state *st; int i = 0, j = 0, k = 0; @@ -2859,7 +2833,7 @@ int npc_do_atcmd_event(struct map_session_data* sd, const char* command, const c } if( ev->nd->option&OPTION_INVISIBLE ) { // Disabled npc, shouldn't trigger event. - npc_event_dequeue(sd); + npc->event_dequeue(sd); return 2; } @@ -2894,7 +2868,7 @@ int npc_do_atcmd_event(struct map_session_data* sd, const char* command, const c /// Parses a function. /// function%TAB%script%TAB%%TAB%{} -static const char* npc_parse_function(char* w1, char* w2, char* w3, char* w4, const char* start, const char* buffer, const char* filepath) +const char* npc_parse_function(char* w1, char* w2, char* w3, char* w4, const char* start, const char* buffer, const char* filepath) { DBMap* func_db; DBData old_data; @@ -2911,7 +2885,7 @@ static const char* npc_parse_function(char* w1, char* w2, char* w3, char* w4, co } ++script_start; - end = npc_skip_script(script_start,buffer,filepath); + end = npc->skip_script(script_start,buffer,filepath); if( end == NULL ) return NULL;// (simple) parse error, don't continue @@ -2950,7 +2924,7 @@ void npc_parse_mob2(struct spawn_data* mobspawn) } } -static const char* npc_parse_mob(char* w1, char* w2, char* w3, char* w4, const char* start, const char* buffer, const char* filepath) +const char* npc_parse_mob(char* w1, char* w2, char* w3, char* w4, const char* start, const char* buffer, const char* filepath) { int num, class_, m,x,y,xs,ys, i,j; int mob_lv = -1, ai = -1, size = -1; @@ -3105,11 +3079,11 @@ static const char* npc_parse_mob(char* w1, char* w2, char* w3, char* w4, const c // (usually shouldn't occur when map server is just starting, // but not the case when we do @reloadscript if( map[data->m].users > 0 ) { - npc_parse_mob2(data); + npc->parse_mob2(data); } } else { data->state.dynamic = false; - npc_parse_mob2(data); + npc->parse_mob2(data); npc_delay_mob += data->num; } @@ -3600,7 +3574,7 @@ void npc_parsesrcfile(const char* filepath, bool runOnInit) ShowError("npc_parsesrcfile: Unknown map '%s' in file '%s', line '%d'. Skipping line...\n", mapname, filepath, strline(buffer,p-buffer)); if( strcasecmp(w2,"script") == 0 && count > 3 ) { - if((p = npc_skip_script(p,buffer,filepath)) == NULL) + if((p = npc->skip_script(p,buffer,filepath)) == NULL) { break; } @@ -3613,7 +3587,7 @@ void npc_parsesrcfile(const char* filepath, bool runOnInit) {// "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) + if((p = npc->skip_script(p,buffer,filepath)) == NULL) { break; } @@ -3625,7 +3599,7 @@ void npc_parsesrcfile(const char* filepath, bool runOnInit) ShowError("npc_parsesrcfile: Unknown coordinates ('%d', '%d') for map '%s' in file '%s', line '%d'. Skipping line...\n", x, y, mapname, filepath, strline(buffer,p-buffer)); if( strcasecmp(w2,"script") == 0 && count > 3 ) { - if((p = npc_skip_script(p,buffer,filepath)) == NULL) + if((p = npc->skip_script(p,buffer,filepath)) == NULL) { break; } @@ -3637,30 +3611,30 @@ void npc_parsesrcfile(const char* filepath, bool runOnInit) if( strcasecmp(w2,"warp") == 0 && count > 3 ) { - p = npc_parse_warp(w1,w2,w3,w4, p, buffer, filepath); + p = npc->parse_warp(w1,w2,w3,w4, p, buffer, filepath); } else if( (!strcasecmp(w2,"shop") || !strcasecmp(w2,"cashshop")) && count > 3 ) { - p = npc_parse_shop(w1,w2,w3,w4, p, buffer, filepath); + p = npc->parse_shop(w1,w2,w3,w4, p, buffer, filepath); } else if( strcasecmp(w2,"script") == 0 && count > 3 ) { if( strcasecmp(w1,"function") == 0 ) - p = npc_parse_function(w1, w2, w3, w4, p, buffer, filepath); + p = npc->parse_function(w1, w2, w3, w4, p, buffer, filepath); else - p = npc_parse_script(w1,w2,w3,w4, p, buffer, filepath,runOnInit); + p = npc->parse_script(w1,w2,w3,w4, p, buffer, filepath,runOnInit); } else if( (i=0, sscanf(w2,"duplicate%n",&i), (i > 0 && w2[i] == '(')) && count > 3 ) { - p = npc_parse_duplicate(w1,w2,w3,w4, p, buffer, filepath); + p = npc->parse_duplicate(w1,w2,w3,w4, p, buffer, filepath); } else if( (strcmpi(w2,"monster") == 0 || strcmpi(w2,"boss_monster") == 0) && count > 3 ) { - p = npc_parse_mob(w1, w2, w3, w4, p, buffer, filepath); + p = npc->parse_mob(w1, w2, w3, w4, p, buffer, filepath); } else if( strcmpi(w2,"mapflag") == 0 && count >= 3 ) { - p = npc_parse_mapflag(w1, w2, trim(w3), trim(w4), p, buffer, filepath); + p = npc->parse_mapflag(w1, w2, trim(w3), trim(w4), p, buffer, filepath); } else { @@ -3683,7 +3657,7 @@ int npc_script_event(struct map_session_data* sd, enum npce_event type) return 0; } for (i = 0; ievent_sub(sd,script_event[type].event[i],script_event[type].event_name[i]); return i; } @@ -3714,7 +3688,7 @@ void npc_read_event_script(void) safestrncpy(name+2,config[i].event_name,62); script_event[i].event_count = 0; - iter = db_iterator(ev_db); + iter = db_iterator(npc->ev_db); for( data = iter->first(iter,&key); iter->exists(iter); data = iter->next(iter,&key) ) { const char* p = key.str; @@ -3747,7 +3721,7 @@ void npc_read_event_script(void) /** * @see DBApply */ -static int npc_path_db_clear_sub(DBKey key, DBData *data, va_list args) +int npc_path_db_clear_sub(DBKey key, DBData *data, va_list args) { struct npc_path_data *npd = DB->data2ptr(data); if (npd->path) @@ -3758,7 +3732,7 @@ static int npc_path_db_clear_sub(DBKey key, DBData *data, va_list args) /** * @see DBApply */ -static int ev_label_db_clear_sub(DBKey key, DBData *data, va_list args) +int npc_ev_label_db_clear_sub(DBKey key, DBData *data, va_list args) { struct linkdb_node **label_linkdb = DB->data2ptr(data); linkdb_final(label_linkdb); // linked data (struct event_data*) is freed when clearing ev_db @@ -3776,11 +3750,11 @@ int npc_reload(void) { /* clear guild flag cache */ guild->flags_clear(); - npc_path_db->clear(npc_path_db, npc_path_db_clear_sub); + npc->path_db->clear(npc->path_db, npc->path_db_clear_sub); - db_clear(npcname_db); - db_clear(ev_db); - ev_label_db->clear(ev_label_db, ev_label_db_clear_sub); + db_clear(npc->name_db); + db_clear(npc->ev_db); + npc->ev_label_db->clear(npc->ev_label_db, npc->ev_label_db_clear_sub); npc_last_npd = NULL; npc_last_path = NULL; @@ -3792,8 +3766,8 @@ int npc_reload(void) { for( bl = (struct block_list*)mapit->first(iter); mapit->exists(iter); bl = (struct block_list*)mapit->next(iter) ) { switch(bl->type) { case BL_NPC: - if( bl->id != fake_nd->bl.id )// don't remove fake_nd - npc_unload((struct npc_data *)bl, false); + if( bl->id != npc->fake_nd->bl.id )// don't remove fake_nd + npc->unload((struct npc_data *)bl, false); break; case BL_MOB: unit->free(bl,CLR_OUTSIGHT); @@ -3831,9 +3805,9 @@ int npc_reload(void) { //TODO: the following code is copy-pasted from do_init_npc(); clean it up // Reloading npcs now - for (nsl = npc_src_files; nsl; nsl = nsl->next) { + for (nsl = npc->src_files; nsl; nsl = nsl->next) { ShowStatus("Loading NPC file: %s"CL_CLL"\r", nsl->name); - npc_parsesrcfile(nsl->name,false); + npc->parsesrcfile(nsl->name,false); } ShowInfo ("Done loading '"CL_WHITE"%d"CL_RESET"' NPCs:"CL_CLL"\n" "\t-'"CL_WHITE"%d"CL_RESET"' Warps\n" @@ -3852,69 +3826,69 @@ int npc_reload(void) { iMap->zone_init(); - npc->motd = npc_name2id("HerculesMOTD"); /* [Ind/Hercules] */ + npc->motd = npc->name2id("HerculesMOTD"); /* [Ind/Hercules] */ //Re-read the NPC Script Events cache. - npc_read_event_script(); + npc->read_event_script(); /* refresh guild castle flags on both woe setups */ - npc_event_doall("OnAgitInit"); - npc_event_doall("OnAgitInit2"); + npc->event_doall("OnAgitInit"); + npc->event_doall("OnAgitInit2"); //Execute the OnInit event for freshly loaded npcs. [Skotlex] - ShowStatus("Event '"CL_WHITE"OnInit"CL_RESET"' executed with '"CL_WHITE"%d"CL_RESET"' NPCs.\n",npc_event_doall("OnInit")); + ShowStatus("Event '"CL_WHITE"OnInit"CL_RESET"' executed with '"CL_WHITE"%d"CL_RESET"' NPCs.\n",npc->event_doall("OnInit")); // Execute rest of the startup events if connected to char-server. [Lance] if(!intif->CheckForCharServer()){ - ShowStatus("Event '"CL_WHITE"OnInterIfInit"CL_RESET"' executed with '"CL_WHITE"%d"CL_RESET"' NPCs.\n", npc_event_doall("OnInterIfInit")); - ShowStatus("Event '"CL_WHITE"OnInterIfInitOnce"CL_RESET"' executed with '"CL_WHITE"%d"CL_RESET"' NPCs.\n", npc_event_doall("OnInterIfInitOnce")); + ShowStatus("Event '"CL_WHITE"OnInterIfInit"CL_RESET"' executed with '"CL_WHITE"%d"CL_RESET"' NPCs.\n", npc->event_doall("OnInterIfInit")); + ShowStatus("Event '"CL_WHITE"OnInterIfInitOnce"CL_RESET"' executed with '"CL_WHITE"%d"CL_RESET"' NPCs.\n", npc->event_doall("OnInterIfInitOnce")); } return 0; } //Unload all npc in the given file bool npc_unloadfile( const char* path ) { - DBIterator * iter = db_iterator(npcname_db); + DBIterator * iter = db_iterator(npc->name_db); struct npc_data* nd = NULL; bool found = false; for( nd = dbi_first(iter); dbi_exists(iter); nd = dbi_next(iter) ) { if( nd->path && strcasecmp(nd->path,path) == 0 ) { found = true; - npc_unload_duplicates(nd);/* unload any npcs which could duplicate this but be in a different file */ - npc_unload(nd, true); + npc->unload_duplicates(nd);/* unload any npcs which could duplicate this but be in a different file */ + npc->unload(nd, true); } } dbi_destroy(iter); if( found ) /* refresh event cache */ - npc_read_event_script(); + npc->read_event_script(); return found; } void do_clear_npc(void) { - db_clear(npcname_db); - db_clear(ev_db); - ev_label_db->clear(ev_label_db, ev_label_db_clear_sub); + db_clear(npc->name_db); + db_clear(npc->ev_db); + npc->ev_label_db->clear(npc->ev_label_db, npc->ev_label_db_clear_sub); } /*========================================== * Destructor *------------------------------------------*/ int do_final_npc(void) { - db_destroy(ev_db); - ev_label_db->destroy(ev_label_db, ev_label_db_clear_sub); - db_destroy(npcname_db); - npc_path_db->destroy(npc_path_db, npc_path_db_clear_sub); - ers_destroy(timer_event_ers); - npc_clearsrcfile(); + db_destroy(npc->ev_db); + npc->ev_label_db->destroy(npc->ev_label_db, npc->ev_label_db_clear_sub); + db_destroy(npc->name_db); + npc->path_db->destroy(npc->path_db, npc->path_db_clear_sub); + ers_destroy(npc->timer_event_ers); + npc->clearsrcfile(); return 0; } -static 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) @@ -3945,7 +3919,7 @@ static void npc_debug_warps(void) int16 m, i; for (m = 0; m < iMap->map_num; m++) for (i = 0; i < map[m].npc_num; i++) - npc_debug_warps_sub(map[m].npc[i]); + npc->debug_warps_sub(map[m].npc[i]); } /*========================================== @@ -3956,14 +3930,14 @@ int do_init_npc(void) struct npc_src_list *file; int i; - memset(&npc_base_ud, 0, sizeof( struct unit_data) ); - npc_base_ud.bl = NULL; - npc_base_ud.walktimer = INVALID_TIMER; - npc_base_ud.skilltimer = INVALID_TIMER; - npc_base_ud.attacktimer = INVALID_TIMER; - npc_base_ud.attackabletime = - npc_base_ud.canact_tick = - npc_base_ud.canmove_tick = iTimer->gettick(); + memset(&npc->base_ud, 0, sizeof( struct unit_data) ); + npc->base_ud.bl = NULL; + npc->base_ud.walktimer = INVALID_TIMER; + npc->base_ud.skilltimer = INVALID_TIMER; + npc->base_ud.attacktimer = INVALID_TIMER; + npc->base_ud.attackabletime = + npc->base_ud.canact_tick = + npc->base_ud.canmove_tick = iTimer->gettick(); //Stock view data for normal npcs. memset(&npc_viewdb, 0, sizeof(npc_viewdb)); @@ -3974,12 +3948,12 @@ int do_init_npc(void) for( i = MAX_NPC_CLASS2_START; i < MAX_NPC_CLASS2_END; i++ ) npc_viewdb2[i - MAX_NPC_CLASS2_START].class_ = i; - ev_db = stridb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, EVENT_NAME_LENGTH); - ev_label_db = stridb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, NAME_LENGTH); - npcname_db = strdb_alloc(DB_OPT_BASE, NAME_LENGTH); - npc_path_db = strdb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, 0); + npc->ev_db = stridb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, EVENT_NAME_LENGTH); + npc->ev_label_db = stridb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, NAME_LENGTH); + npc->name_db = strdb_alloc(DB_OPT_BASE, NAME_LENGTH); + npc->path_db = strdb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, 0); - timer_event_ers = ers_new(sizeof(struct timer_event_data),"clif.c::timer_event_ers",ERS_OPT_NONE); + npc->timer_event_ers = ers_new(sizeof(struct timer_event_data),"clif.c::timer_event_ers",ERS_OPT_NONE); npc_last_npd = NULL; npc_last_path = NULL; @@ -3987,9 +3961,9 @@ int do_init_npc(void) // process all npc files ShowStatus("Loading NPCs...\r"); - for( file = npc_src_files; file != NULL; file = file->next ) { + for( file = npc->src_files; file != NULL; file = file->next ) { ShowStatus("Loading NPC file: %s"CL_CLL"\r", file->name); - npc_parsesrcfile(file->name,false); + npc->parsesrcfile(file->name,false); } ShowInfo ("Done loading '"CL_WHITE"%d"CL_RESET"' NPCs:"CL_CLL"\n" "\t-'"CL_WHITE"%d"CL_RESET"' Warps\n" @@ -4004,35 +3978,35 @@ int do_init_npc(void) iMap->zone_init(); - npc->motd = npc_name2id("HerculesMOTD"); /* [Ind/Hercules] */ + npc->motd = npc->name2id("HerculesMOTD"); /* [Ind/Hercules] */ // set up the events cache memset(script_event, 0, sizeof(script_event)); - npc_read_event_script(); + npc->read_event_script(); //Debug function to locate all endless loop warps. if (battle_config.warp_point_debug) - npc_debug_warps(); + npc->debug_warps(); - iTimer->add_timer_func_list(npc_event_do_clock,"npc_event_do_clock"); - iTimer->add_timer_func_list(npc_timerevent,"npc_timerevent"); + iTimer->add_timer_func_list(npc->event_do_clock,"npc_event_do_clock"); + iTimer->add_timer_func_list(npc->timerevent,"npc_timerevent"); // Init dummy NPC - fake_nd = (struct npc_data *)aCalloc(1,sizeof(struct npc_data)); - fake_nd->bl.m = -1; - fake_nd->bl.id = npc_get_new_npc_id(); - fake_nd->class_ = -1; - fake_nd->speed = 200; - strcpy(fake_nd->name,"FAKE_NPC"); - memcpy(fake_nd->exname, fake_nd->name, 9); + npc->fake_nd = (struct npc_data *)aCalloc(1,sizeof(struct npc_data)); + npc->fake_nd->bl.m = -1; + npc->fake_nd->bl.id = npc->get_new_npc_id(); + npc->fake_nd->class_ = -1; + npc->fake_nd->speed = 200; + strcpy(npc->fake_nd->name,"FAKE_NPC"); + memcpy(npc->fake_nd->exname, npc->fake_nd->name, 9); npc_script++; - fake_nd->bl.type = BL_NPC; - fake_nd->subtype = SCRIPT; + npc->fake_nd->bl.type = BL_NPC; + npc->fake_nd->subtype = SCRIPT; - strdb_put(npcname_db, fake_nd->exname, fake_nd); - fake_nd->u.scr.timerid = INVALID_TIMER; - iMap->addiddb(&fake_nd->bl); + 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); // End of initialization return 0; @@ -4041,4 +4015,101 @@ void npc_defaults(void) { npc = &npc_s; npc->motd = NULL; + npc->ev_db = NULL; + npc->ev_label_db = NULL; + npc->name_db = NULL; + npc->path_db = NULL; + npc->timer_event_ers = NULL; + npc->fake_nd = NULL; + npc->src_files = NULL; + /* */ + npc->init = do_init_npc; + npc->final = do_final_npc; + /* */ + npc->get_new_npc_id = npc_get_new_npc_id; + npc->get_viewdata = npc_get_viewdata; + npc->isnear_sub = npc_isnear_sub; + npc->isnear = npc_isnear; + npc->ontouch_event = npc_ontouch_event; + npc->ontouch2_event = npc_ontouch2_event; + npc->enable_sub = npc_enable_sub; + npc->enable = npc_enable; + npc->name2id = npc_name2id; + npc->event_dequeue = npc_event_dequeue; + npc->event_export_create = npc_event_export_create; + npc->event_export = npc_event_export; + npc->event_sub = npc_event_sub; + npc->event_doall_sub = npc_event_doall_sub; + npc->event_do = npc_event_do; + npc->event_doall_id = npc_event_doall_id; + npc->event_doall = npc_event_doall; + npc->event_do_clock = npc_event_do_clock; + npc->event_do_oninit = npc_event_do_oninit; + npc->timerevent_export = npc_timerevent_export; + npc->timerevent = npc_timerevent; + npc->timerevent_start = npc_timerevent_start; + npc->timerevent_stop = npc_timerevent_stop; + npc->timerevent_quit = npc_timerevent_quit; + npc->gettimerevent_tick = npc_gettimerevent_tick; + npc->settimerevent_tick = npc_settimerevent_tick; + npc->event = npc_event; + npc->touch_areanpc_sub = npc_touch_areanpc_sub; + npc->touchnext_areanpc = npc_touchnext_areanpc; + npc->touch_areanpc = npc_touch_areanpc; + npc->touch_areanpc2 = npc_touch_areanpc2; + npc->check_areanpc = npc_check_areanpc; + npc->checknear = npc_checknear; + npc->globalmessage = npc_globalmessage; + npc->run_tomb = run_tomb; + npc->click = npc_click; + npc->scriptcont = npc_scriptcont; + npc->buysellsel = npc_buysellsel; + npc->cashshop_buylist = npc_cashshop_buylist; + npc->buylist_sub = npc_buylist_sub; + npc->cashshop_buy = npc_cashshop_buy; + npc->buylist = npc_buylist; + npc->selllist_sub = npc_selllist_sub; + npc->selllist = npc_selllist; + npc->remove_map = npc_remove_map; + npc->unload_ev = npc_unload_ev; + npc->unload_ev_label = npc_unload_ev_label; + npc->unload_dup_sub = npc_unload_dup_sub; + npc->unload_duplicates = npc_unload_duplicates; + npc->unload = npc_unload; + npc->clearsrcfile = npc_clearsrcfile; + npc->addsrcfile = npc_addsrcfile; + npc->delsrcfile = npc_delsrcfile; + npc->parsename = npc_parsename; + npc->add_warp = npc_add_warp; + npc->parse_warp = npc_parse_warp; + npc->parse_shop = npc_parse_shop; + npc->convertlabel_db = npc_convertlabel_db; + npc->skip_script = npc_skip_script; + npc->parse_script = npc_parse_script; + npc->parse_duplicate = npc_parse_duplicate; + npc->duplicate4instance = npc_duplicate4instance; + npc->setcells = npc_setcells; + npc->unsetcells_sub = npc_unsetcells_sub; + npc->unsetcells = npc_unsetcells; + npc->movenpc = npc_movenpc; + npc->setdisplayname = npc_setdisplayname; + npc->setclass = npc_setclass; + npc->do_atcmd_event = npc_do_atcmd_event; + npc->parse_function = npc_parse_function; + npc->parse_mob2 = npc_parse_mob2; + npc->parse_mob = npc_parse_mob; + npc->parse_mapflag = npc_parse_mapflag; + npc->parsesrcfile = npc_parsesrcfile; + npc->script_event = npc_script_event; + npc->read_event_script = npc_read_event_script; + npc->path_db_clear_sub = npc_path_db_clear_sub; + npc->ev_label_db_clear_sub = npc_ev_label_db_clear_sub; + npc->reload = npc_reload; + npc->unloadfile = npc_unloadfile; + npc->do_clear_npc = do_clear_npc; + npc->debug_warps_sub = npc_debug_warps_sub; + npc->debug_warps = npc_debug_warps; +#ifdef SECURE_NPCTIMEOUT + npc->secure_timeout_timer = npc_rr_secure_timeout_timer; +#endif } diff --git a/src/map/npc.h b/src/map/npc.h index 48c27b297..0fc773dfc 100644 --- a/src/map/npc.h +++ b/src/map/npc.h @@ -12,8 +12,6 @@ struct block_list; struct npc_data; struct view_data; -struct unit_data npc_base_ud; - struct npc_timerevent_list { int timer,pos; }; @@ -82,8 +80,7 @@ struct npc_data { #define START_NPC_NUM 110000000 -enum actor_classes -{ +enum actor_classes { WARP_CLASS = 45, HIDDEN_WARP_CLASS = 139, WARP_DEBUG_CLASS = 722, @@ -117,86 +114,133 @@ enum npce_event { NPCE_KILLNPC, NPCE_MAX }; -struct view_data* npc_get_viewdata(int class_); -int npc_chat_sub(struct block_list* bl, va_list ap); -int npc_event_dequeue(struct map_session_data* sd); -int npc_event(struct map_session_data* sd, const char* eventname, int ontouch); -int npc_touch_areanpc(struct map_session_data* sd, int16 m, int16 x, int16 y); -int npc_touch_areanpc2(struct mob_data *md); // [Skotlex] -int npc_check_areanpc(int flag, int16 m, int16 x, int16 y, int16 range); -int npc_touchnext_areanpc(struct map_session_data* sd,bool leavemap); -int npc_click(struct map_session_data* sd, struct npc_data* nd); -int npc_scriptcont(struct map_session_data* sd, int id, bool closing); -struct npc_data* npc_checknear(struct map_session_data* sd, struct block_list* bl); -int npc_buysellsel(struct map_session_data* sd, int id, int type); -int npc_buylist(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); -void npc_parse_mob2(struct spawn_data* mob); -const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, const char* start, const char* buffer, const char* filepath); -struct npc_data* npc_add_warp(char* name, short from_mapid, short from_x, short from_y, short xs, short ys, unsigned short to_mapindex, short to_x, short to_y); -int npc_globalmessage(const char* name,const char* mes); - -void npc_setcells(struct npc_data* nd); -void npc_unsetcells(struct npc_data* nd); -void npc_movenpc(struct npc_data* nd, int16 x, int16 y); -int npc_enable(const char* name, int flag); -void npc_setdisplayname(struct npc_data* nd, const char* newname); -void npc_setclass(struct npc_data* nd, short class_); -struct npc_data* npc_name2id(const char* name); -bool npc_isnear(struct block_list * bl); - -int npc_get_new_npc_id(void); - -void npc_addsrcfile(const char* name); -void npc_delsrcfile(const char* name); -void npc_parsesrcfile(const char* filepath, bool runOnInit); -void do_clear_npc(void); -int do_final_npc(void); -int do_init_npc(void); -void npc_event_do_oninit(void); -int npc_do_ontimer(int npc_id, int option); - -int npc_event_do(const char* name); -int npc_event_doall(const char* name); -int npc_event_doall_id(const char* name, int rid); - -int npc_timerevent_start(struct npc_data* nd, int rid); -int npc_timerevent_stop(struct npc_data* nd); -void npc_timerevent_quit(struct map_session_data* sd); -int npc_gettimerevent_tick(struct npc_data* nd); -int npc_settimerevent_tick(struct npc_data* nd, int newtimer); -int npc_remove_map(struct npc_data* nd); -void npc_unload_duplicates (struct npc_data* nd); -int npc_unload(struct npc_data* nd, bool single); -int npc_reload(void); -void npc_read_event_script(void); -int npc_script_event(struct map_session_data* sd, enum npce_event type); - -int npc_duplicate4instance(struct npc_data *snd, int16 m); -int npc_cashshop_buy(struct map_session_data *sd, int nameid, int amount, int points); - -extern struct npc_data* fake_nd; - -int npc_cashshop_buylist(struct map_session_data *sd, int points, int count, unsigned short* item_list); - -/** - * For the Secure NPC Timeout option (check config/Secure.h) [RR] - **/ -#ifdef SECURE_NPCTIMEOUT - int npc_rr_secure_timeout_timer(int tid, unsigned int tick, int id, intptr_t data); -#endif -// @commands (script-based) -int npc_do_atcmd_event(struct map_session_data* sd, const char* command, const char* message, const char* eventname); +// linked list of npc source files +struct npc_src_list { + struct npc_src_list* next; + char name[4]; // dynamic array, the structure is allocated with extra bytes (string length) +}; + +struct event_data { + struct npc_data *nd; + int pos; +}; + +struct npc_path_data { + char* path; + unsigned short references; +}; + +/* comes from npc_chat.c */ +int npc_chat_sub (struct block_list* bl, va_list ap); -bool npc_unloadfile( const char* path ); -/* npc.c interface (barely started/WIP) */ +/* npc.c interface */ struct npc_interface { /* */ struct npc_data *motd; + DBMap *ev_db; // const char* event_name -> struct event_data* + DBMap *ev_label_db; // const char* label_name (without leading "::") -> struct linkdb_node** (key: struct npc_data*; data: struct event_data*) + DBMap *name_db; // const char* npc_name -> struct npc_data* + DBMap *path_db; + struct eri *timer_event_ers; //For the npc timer data. [Skotlex] + struct npc_data *fake_nd; + struct npc_src_list *src_files; + struct unit_data base_ud; + /* */ + int (*init) (void); + int (*final) (void); /* */ -} npc_s; + int (*get_new_npc_id) (void); + struct view_data* (*get_viewdata) (int class_); + int (*isnear_sub) (struct block_list *bl, va_list args); + bool (*isnear) (struct block_list *bl); + int (*ontouch_event) (struct map_session_data *sd, struct npc_data *nd); + int (*ontouch2_event) (struct map_session_data *sd, struct npc_data *nd); + int (*enable_sub) (struct block_list *bl, va_list ap); + int (*enable) (const char *name, int flag); + struct npc_data* (*name2id) (const char *name); + int (*event_dequeue) (struct map_session_data *sd); + DBData (*event_export_create) (DBKey key, va_list args); + int (*event_export) (struct npc_data *nd, int i); + int (*event_sub) (struct map_session_data *sd, struct event_data *ev, const char *eventname); + void (*event_doall_sub) (void *key, void *data, va_list ap); + int (*event_do) (const char *name); + int (*event_doall_id) (const char *name, int rid); + int (*event_doall) (const char *name); + int (*event_do_clock) (int tid, unsigned int tick, int id, intptr_t data); + void (*event_do_oninit) (void); + int (*timerevent_export) (struct npc_data *nd, int i); + int (*timerevent) (int tid, unsigned int tick, int id, intptr_t data); + int (*timerevent_start) (struct npc_data *nd, int rid); + int (*timerevent_stop) (struct npc_data *nd); + void (*timerevent_quit) (struct map_session_data *sd); + int (*gettimerevent_tick) (struct npc_data *nd); + int (*settimerevent_tick) (struct npc_data *nd, int newtimer); + int (*event) (struct map_session_data *sd, const char *eventname, int ontouch); + int (*touch_areanpc_sub) (struct block_list *bl, va_list ap); + int (*touchnext_areanpc) (struct map_session_data *sd, bool leavemap); + int (*touch_areanpc) (struct map_session_data *sd, int16 m, int16 x, int16 y); + int (*touch_areanpc2) (struct mob_data *md); + int (*check_areanpc) (int flag, int16 m, int16 x, int16 y, int16 range); + struct npc_data* (*checknear) (struct map_session_data *sd, struct block_list *bl); + int (*globalmessage) (const char *name, const char *mes); + void (*run_tomb) (struct map_session_data *sd, struct npc_data *nd); + int (*click) (struct map_session_data *sd, struct npc_data *nd); + int (*scriptcont) (struct map_session_data *sd, int id, bool closing); + int (*buysellsel) (struct map_session_data *sd, int id, int type); + int (*cashshop_buylist) (struct map_session_data *sd, int points, int count, unsigned short *item_list); + int (*buylist_sub) (struct map_session_data *sd, int n, unsigned short *item_list, struct npc_data *nd); + int (*cashshop_buy) (struct map_session_data *sd, int nameid, int amount, int points); + int (*buylist) (struct map_session_data *sd, int n, unsigned short *item_list); + int (*selllist_sub) (struct map_session_data *sd, int n, unsigned short *item_list, struct npc_data *nd); + int (*selllist) (struct map_session_data *sd, int n, unsigned short *item_list); + int (*remove_map) (struct npc_data *nd); + int (*unload_ev) (DBKey key, DBData *data, va_list ap); + int (*unload_ev_label) (DBKey key, DBData *data, va_list ap); + int (*unload_dup_sub) (struct npc_data *nd, va_list args); + void (*unload_duplicates) (struct npc_data *nd); + int (*unload) (struct npc_data *nd, bool single); + void (*clearsrcfile) (void); + void (*addsrcfile) (const char *name); + void (*delsrcfile) (const char *name); + void (*parsename) (struct npc_data *nd, const char *name, const char *start, const char *buffer, const char *filepath); + struct npc_data* (*add_warp) (char *name, short from_mapid, short from_x, short from_y, short xs, short ys, unsigned short to_mapindex, short to_x, short to_y); + const char* (*parse_warp) (char *w1, char *w2, char *w3, char *w4, const char *start, const char *buffer, const char *filepath); + const char* (*parse_shop) (char *w1, char *w2, char *w3, char *w4, const char *start, const char *buffer, const char *filepath); + void (*convertlabel_db) (struct npc_label_list *label_list, const char *filepath); + const char* (*skip_script) (const char *start, const char *buffer, const char *filepath); + const char* (*parse_script) (char *w1, char *w2, char *w3, char *w4, const char *start, const char *buffer, const char *filepath, bool runOnInit); + const char* (*parse_duplicate) (char *w1, char *w2, char *w3, char *w4, const char *start, const char *buffer, const char *filepath); + int (*duplicate4instance) (struct npc_data *snd, int16 m); + void (*setcells) (struct npc_data *nd); + int (*unsetcells_sub) (struct block_list *bl, va_list ap); + void (*unsetcells) (struct npc_data *nd); + void (*movenpc) (struct npc_data *nd, int16 x, int16 y); + void (*setdisplayname) (struct npc_data *nd, const char *newname); + void (*setclass) (struct npc_data *nd, short class_); + int (*do_atcmd_event) (struct map_session_data *sd, const char *command, const char *message, const char *eventname); + const char* (*parse_function) (char *w1, char *w2, char *w3, char *w4, const char *start, const char *buffer, const char *filepath); + void (*parse_mob2) (struct spawn_data *mob); + const char* (*parse_mob) (char *w1, char *w2, char *w3, char *w4, const char *start, const char *buffer, const char *filepath); + const char* (*parse_mapflag) (char *w1, char *w2, char *w3, char *w4, const char *start, const char *buffer, const char *filepath); + void (*parsesrcfile) (const char *filepath, bool runOnInit); + int (*script_event) (struct map_session_data *sd, enum npce_event type); + void (*read_event_script) (void); + int (*path_db_clear_sub) (DBKey key, DBData *data, va_list args); + int (*ev_label_db_clear_sub) (DBKey key, DBData *data, va_list args); + int (*reload) (void); + bool (*unloadfile) (const char *path); + void (*do_clear_npc) (void); + void (*debug_warps_sub) (struct npc_data *nd); + void (*debug_warps) (void); + /** + * For the Secure NPC Timeout option (check config/Secure.h) [RR] + **/ +#ifdef SECURE_NPCTIMEOUT + int (*secure_timeout_timer) (int tid, unsigned int tick, int id, intptr_t data); +#endif +}; struct npc_interface *npc; diff --git a/src/map/pc.c b/src/map/pc.c index d502d9a3a..b591cd483 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -1334,7 +1334,7 @@ int pc_reg_received(struct map_session_data *sd) } if( npc->motd ) /* [Ind/Hercules] */ - script->run(npc->motd->u.scr.script, 0, sd->bl.id, fake_nd->bl.id); + script->run(npc->motd->u.scr.script, 0, sd->bl.id, npc->fake_nd->bl.id); return 1; } @@ -4476,7 +4476,7 @@ int pc_useitem(struct map_session_data *sd,int n) { script->current_item_id = nameid; - script->run(item_script,0,sd->bl.id,fake_nd->bl.id); + script->run(item_script,0,sd->bl.id,npc->fake_nd->bl.id); script->current_item_id = 0; script->potion_flag = 0; @@ -4874,7 +4874,7 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y struct hQueue *queue; if( (queue = script->queue(sd->queues[i])) && queue->onMapChange[0] != '\0' ) { pc->setregstr(sd, script->add_str("QMapChangeTo"), map[m].name); - npc_event(sd, queue->onMapChange, 0); + npc->event(sd, queue->onMapChange, 0); } } @@ -4930,8 +4930,8 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y return 2; if (sd->npc_id) - npc_event_dequeue(sd); - npc_script_event(sd, NPCE_LOGOUT); + npc->event_dequeue(sd); + npc->script_event(sd, NPCE_LOGOUT); //remove from map, THEN change x/y coordinates unit->remove_map_pc(sd,clrtype); sd->mapindex = mapindex; @@ -5813,7 +5813,7 @@ int pc_checkbaselevelup(struct map_session_data *sd) { sc_start(&sd->bl,iStatus->skill2sc(AL_BLESSING),100,10,600000); } clif->misceffect(&sd->bl,0); - npc_script_event(sd, NPCE_BASELVUP); //LORDALFA - LVLUPEVENT + npc->script_event(sd, NPCE_BASELVUP); //LORDALFA - LVLUPEVENT if(sd->status.party_id) party->send_levelup(sd); @@ -5862,7 +5862,7 @@ int pc_checkjoblevelup(struct map_session_data *sd) if (pc->checkskill(sd, SG_DEVIL) && !pc->nextjobexp(sd)) clif->status_change(&sd->bl,SI_DEVIL1, 1, 0, 0, 0, 1); //Permanent blind effect from SG_DEVIL. - npc_script_event(sd, NPCE_JOBLVUP); + npc->script_event(sd, NPCE_JOBLVUP); return 1; } @@ -6755,7 +6755,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) { } if (sd->npc_id && sd->st && sd->st->state != RUN) - npc_event_dequeue(sd); + npc->event_dequeue(sd); pc_setglobalreg(sd,"PC_DIE_COUNTER",sd->die_counter+1); pc->setparam(sd, SP_KILLERRID, src?src->id:0); @@ -6763,16 +6763,16 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) { if( sd->bg_id ) {/* TODO: purge when bgqueue is deemed ok */ struct battleground_data *bg; if( (bg = bg_team_search(sd->bg_id)) != NULL && bg->die_event[0] ) - npc_event(sd, bg->die_event, 0); + npc->event(sd, bg->die_event, 0); } for( i = 0; i < sd->queues_count; i++ ) { struct hQueue *queue; if( (queue = script->queue(sd->queues[i])) && queue->onDeath[0] != '\0' ) - npc_event(sd, queue->onDeath, 0); + npc->event(sd, queue->onDeath, 0); } - npc_script_event(sd,NPCE_DIE); + npc->script_event(sd,NPCE_DIE); // Clear anything NPC-related when you die and was interacting with one. if (sd->npc_id || sd->npc_shopid) { @@ -6850,7 +6850,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) { if (src && src->type == BL_PC) { struct map_session_data *ssd = (struct map_session_data *)src; pc->setparam(ssd, SP_KILLEDRID, sd->bl.id); - npc_script_event(ssd, NPCE_KILLPC); + npc->script_event(ssd, NPCE_KILLPC); if (battle_config.pk_mode&2) { ssd->status.manner -= 5; @@ -8331,7 +8331,7 @@ static int pc_eventtimer(int tid, unsigned int tick, int id, intptr_t data) { sd->eventtimer[i] = INVALID_TIMER; sd->eventcount--; - npc_event(sd,p,0); + npc->event(sd,p,0); } else ShowError("pc_eventtimer: no such event timer\n"); @@ -8774,7 +8774,7 @@ int pc_equipitem(struct map_session_data *sd,int n,int req_pos) //OnEquip script [Skotlex] if (id) { if (id->equip_script) - script->run(id->equip_script,0,sd->bl.id,fake_nd->bl.id); + script->run(id->equip_script,0,sd->bl.id,npc->fake_nd->bl.id); if(itemdb_isspecial(sd->status.inventory[n].card[0])) ; //No cards else { @@ -8784,7 +8784,7 @@ int pc_equipitem(struct map_session_data *sd,int n,int req_pos) continue; if ( ( data = itemdb->exists(sd->status.inventory[n].card[i]) ) != NULL ) { if( data->equip_script ) - script->run(data->equip_script,0,sd->bl.id,fake_nd->bl.id); + script->run(data->equip_script,0,sd->bl.id,npc->fake_nd->bl.id); } } } @@ -8941,7 +8941,7 @@ int pc_unequipitem(struct map_session_data *sd,int n,int flag) { //OnUnEquip script [Skotlex] if (sd->inventory_data[n]) { if (sd->inventory_data[n]->unequip_script) - script->run(sd->inventory_data[n]->unequip_script,0,sd->bl.id,fake_nd->bl.id); + script->run(sd->inventory_data[n]->unequip_script,0,sd->bl.id,npc->fake_nd->bl.id); if(itemdb_isspecial(sd->status.inventory[n].card[0])) ; //No cards else { @@ -8952,7 +8952,7 @@ int pc_unequipitem(struct map_session_data *sd,int n,int flag) { if ( ( data = itemdb->exists(sd->status.inventory[n].card[i]) ) != NULL ) { if( data->unequip_script ) - script->run(data->unequip_script,0,sd->bl.id,fake_nd->bl.id); + script->run(data->unequip_script,0,sd->bl.id,npc->fake_nd->bl.id); } } diff --git a/src/map/pet.c b/src/map/pet.c index d7f7c29c8..c1bce0b5b 100644 --- a/src/map/pet.c +++ b/src/map/pet.c @@ -349,7 +349,7 @@ int pet_data_init(struct map_session_data *sd, struct s_pet *pet) } sd->pd = pd = (struct pet_data *)aCalloc(1,sizeof(struct pet_data)); pd->bl.type = BL_PET; - pd->bl.id = npc_get_new_npc_id(); + pd->bl.id = npc->get_new_npc_id(); pd->msd = sd; pd->petDB = &pet_db[i]; diff --git a/src/map/script.c b/src/map/script.c index 70c9bd9f1..391109fa9 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -3381,11 +3381,11 @@ static void script_detach_state(struct script_state* st, bool dequeue_event) * We're done with this NPC session, so we cancel the timer (if existent) and move on **/ if( sd->npc_idle_timer != INVALID_TIMER ) { - iTimer->delete_timer(sd->npc_idle_timer,npc_rr_secure_timeout_timer); + iTimer->delete_timer(sd->npc_idle_timer,npc->secure_timeout_timer); sd->npc_idle_timer = INVALID_TIMER; } #endif - npc_event_dequeue(sd); + npc->event_dequeue(sd); } } else if(st->bk_st) { // rid was set to 0, before detaching the script state ShowError("script_detach_state: Found previous script state without attached player (rid=%d, oid=%d, state=%d, bk_npcid=%d)\n", st->bk_st->rid, st->bk_st->oid, st->bk_st->state, st->bk_npcid); @@ -3421,7 +3421,7 @@ void script_attach_state(struct script_state* st) { **/ #ifdef SECURE_NPCTIMEOUT if( sd->npc_idle_timer == INVALID_TIMER ) - sd->npc_idle_timer = iTimer->add_timer(iTimer->gettick() + (SECURE_NPCTIMEOUT_INTERVAL*1000),npc_rr_secure_timeout_timer,sd->bl.id,0); + sd->npc_idle_timer = iTimer->add_timer(iTimer->gettick() + (SECURE_NPCTIMEOUT_INTERVAL*1000),npc->secure_timeout_timer,sd->bl.id,0); sd->npc_idle_tick = iTimer->gettick(); #endif } @@ -6665,7 +6665,7 @@ BUILDIN(getnpcid) if( script_hasdata(st,3) ) {// unique npc name - if( ( nd = npc_name2id(script_getstr(st,3)) ) == NULL ) + if( ( nd = npc->name2id(script_getstr(st,3)) ) == NULL ) { ShowError("buildin_getnpcid: No such NPC '%s'.\n", script_getstr(st,3)); script_pushint(st,0); @@ -8781,7 +8781,7 @@ BUILDIN(doevent) } check_event(st, event); - npc_event(sd, event, 0); + npc->event(sd, event, 0); return true; } /*========================================== @@ -8790,7 +8790,7 @@ BUILDIN(donpcevent) { const char* event = script_getstr(st,2); check_event(st, event); - if( !npc_event_do(event) ) { + if( !npc->event_do(event) ) { struct npc_data * nd = iMap->id2nd(st->oid); ShowDebug("NPCEvent '%s' not found! (source: %s)\n",event,nd?nd->name:"Unknown"); script_pushint(st, 0); @@ -8803,12 +8803,12 @@ BUILDIN(donpcevent) /// basically a specialized 'donpcevent', with the event specified as two arguments instead of one BUILDIN(cmdothernpc) // Added by RoVeRT { - const char* npc = script_getstr(st,2); + const char* npc_name = script_getstr(st,2); const char* command = script_getstr(st,3); char event[EVENT_NAME_LENGTH]; - snprintf(event, sizeof(event), "%s::OnCommand%s", npc, command); + snprintf(event, sizeof(event), "%s::OnCommand%s", npc_name, command); check_event(st, event); - npc_event_do(event); + npc->event_do(event); return true; } @@ -8872,7 +8872,7 @@ BUILDIN(initnpctimer) if( script_hasdata(st,3) ) { //Two arguments: NPC name and attach flag. - nd = npc_name2id(script_getstr(st, 2)); + nd = npc->name2id(script_getstr(st, 2)); flag = script_getnum(st,3); } else if( script_hasdata(st,2) ) @@ -8881,7 +8881,7 @@ BUILDIN(initnpctimer) data = script_getdata(st,2); script->get_val(st,data); if( data_isstring(data) ) //NPC name - nd = npc_name2id(script->conv_str(st, data)); + nd = npc->name2id(script->conv_str(st, data)); else if( data_isint(data) ) //Flag { nd = (struct npc_data *)iMap->id2bl(st->oid); @@ -8907,8 +8907,8 @@ BUILDIN(initnpctimer) } nd->u.scr.timertick = 0; - npc_settimerevent_tick(nd,0); - npc_timerevent_start(nd, st->rid); + npc->settimerevent_tick(nd,0); + npc->timerevent_start(nd, st->rid); return true; } /*========================================== @@ -8920,7 +8920,7 @@ BUILDIN(startnpctimer) if( script_hasdata(st,3) ) { //Two arguments: NPC name and attach flag. - nd = npc_name2id(script_getstr(st, 2)); + nd = npc->name2id(script_getstr(st, 2)); flag = script_getnum(st,3); } else if( script_hasdata(st,2) ) @@ -8929,7 +8929,7 @@ BUILDIN(startnpctimer) data = script_getdata(st,2); script->get_val(st,data); if( data_isstring(data) ) //NPC name - nd = npc_name2id(script->conv_str(st, data)); + nd = npc->name2id(script->conv_str(st, data)); else if( data_isint(data) ) //Flag { nd = (struct npc_data *)iMap->id2bl(st->oid); @@ -8954,7 +8954,7 @@ BUILDIN(startnpctimer) nd->u.scr.rid = sd->bl.id; } - npc_timerevent_start(nd, st->rid); + npc->timerevent_start(nd, st->rid); return true; } /*========================================== @@ -8966,7 +8966,7 @@ BUILDIN(stopnpctimer) if( script_hasdata(st,3) ) { //Two arguments: NPC name and attach flag. - nd = npc_name2id(script_getstr(st, 2)); + nd = npc->name2id(script_getstr(st, 2)); flag = script_getnum(st,3); } else if( script_hasdata(st,2) ) @@ -8975,7 +8975,7 @@ BUILDIN(stopnpctimer) data = script_getdata(st,2); script->get_val(st,data); if( data_isstring(data) ) //NPC name - nd = npc_name2id(script->conv_str(st, data)); + nd = npc->name2id(script->conv_str(st, data)); else if( data_isint(data) ) //Flag { nd = (struct npc_data *)iMap->id2bl(st->oid); @@ -8995,7 +8995,7 @@ BUILDIN(stopnpctimer) if( flag ) //Detach nd->u.scr.rid = 0; - npc_timerevent_stop(nd); + npc->timerevent_stop(nd); return true; } /*========================================== @@ -9008,7 +9008,7 @@ BUILDIN(getnpctimer) int val = 0; if( script_hasdata(st,3) ) - nd = npc_name2id(script_getstr(st,3)); + nd = npc->name2id(script_getstr(st,3)); else nd = (struct npc_data *)iMap->id2bl(st->oid); @@ -9021,7 +9021,7 @@ BUILDIN(getnpctimer) switch( type ) { - case 0: val = npc_gettimerevent_tick(nd); break; + case 0: val = npc->gettimerevent_tick(nd); break; case 1: if( nd->u.scr.rid ) { @@ -9051,7 +9051,7 @@ BUILDIN(setnpctimer) tick = script_getnum(st,2); if( script_hasdata(st,3) ) - nd = npc_name2id(script_getstr(st,3)); + nd = npc->name2id(script_getstr(st,3)); else nd = (struct npc_data *)iMap->id2bl(st->oid); @@ -9062,7 +9062,7 @@ BUILDIN(setnpctimer) return false; } - npc_settimerevent_tick(nd,tick); + npc->settimerevent_tick(nd,tick); script_pushint(st,0); return true; } @@ -9107,7 +9107,7 @@ BUILDIN(detachnpctimer) struct npc_data *nd; if( script_hasdata(st,2) ) - nd = npc_name2id(script_getstr(st,2)); + nd = npc->name2id(script_getstr(st,2)); else nd = (struct npc_data *)iMap->id2bl(st->oid); @@ -9466,7 +9466,7 @@ BUILDIN(enablenpc) { const char *str; str=script_getstr(st,2); - npc_enable(str,1); + npc->enable(str,1); return true; } /*========================================== @@ -9475,7 +9475,7 @@ BUILDIN(disablenpc) { const char *str; str=script_getstr(st,2); - npc_enable(str,0); + npc->enable(str,0); return true; } @@ -9485,7 +9485,7 @@ BUILDIN(hideoffnpc) { const char *str; str=script_getstr(st,2); - npc_enable(str,2); + npc->enable(str,2); return true; } /*========================================== @@ -9494,7 +9494,7 @@ BUILDIN(hideonnpc) { const char *str; str=script_getstr(st,2); - npc_enable(str,4); + npc->enable(str,4); return true; } @@ -10035,7 +10035,7 @@ BUILDIN(globalmes) name=nd->name; //use current npc name } - npc_globalmessage(name,mes); // broadcast to all players connected + npc->globalmessage(name,mes); // broadcast to all players connected return true; } @@ -10074,7 +10074,7 @@ BUILDIN(delwaitingroom) { struct npc_data* nd; if( script_hasdata(st,2) ) - nd = npc_name2id(script_getstr(st, 2)); + nd = npc->name2id(script_getstr(st, 2)); else nd = (struct npc_data *)iMap->id2bl(st->oid); if( nd != NULL ) @@ -10092,7 +10092,7 @@ BUILDIN(waitingroomkickall) struct chat_data* cd; if( script_hasdata(st,2) ) - nd = npc_name2id(script_getstr(st,2)); + nd = npc->name2id(script_getstr(st,2)); else nd = (struct npc_data *)iMap->id2bl(st->oid); @@ -10111,7 +10111,7 @@ BUILDIN(enablewaitingroomevent) struct chat_data* cd; if( script_hasdata(st,2) ) - nd = npc_name2id(script_getstr(st, 2)); + nd = npc->name2id(script_getstr(st, 2)); else nd = (struct npc_data *)iMap->id2bl(st->oid); @@ -10130,7 +10130,7 @@ BUILDIN(disablewaitingroomevent) struct chat_data *cd; if( script_hasdata(st,2) ) - nd = npc_name2id(script_getstr(st, 2)); + nd = npc->name2id(script_getstr(st, 2)); else nd = (struct npc_data *)iMap->id2bl(st->oid); @@ -10161,7 +10161,7 @@ BUILDIN(getwaitingroomstate) type = script_getnum(st,2); if( script_hasdata(st,3) ) - nd = npc_name2id(script_getstr(st, 3)); + nd = npc->name2id(script_getstr(st, 3)); else nd = (struct npc_data *)iMap->id2bl(st->oid); @@ -10490,7 +10490,7 @@ BUILDIN(setmapflag) char empty[1] = "\0"; char params[MAP_ZONE_MAPFLAG_LENGTH]; memcpy(params, val2, MAP_ZONE_MAPFLAG_LENGTH); - npc_parse_mapflag(map[m].name, empty, zone, params, empty, empty, empty); + npc->parse_mapflag(map[m].name, empty, zone, params, empty, empty, empty); } break; case MF_NOCOMMAND: map[m].nocommand = (val <= 0) ? 100 : val; break; @@ -10746,7 +10746,7 @@ BUILDIN(emotion) } else if( script_hasdata(st,4) ) { - TBL_NPC *nd = npc_name2id(script_getstr(st,4)); + TBL_NPC *nd = npc->name2id(script_getstr(st,4)); if(nd) clif->emotion(&nd->bl,type); } @@ -11879,7 +11879,7 @@ BUILDIN(misceffect) int type; type=script_getnum(st,2); - if(st->oid && st->oid != fake_nd->bl.id) { + if(st->oid && st->oid != npc->fake_nd->bl.id) { struct block_list *bl = iMap->id2bl(st->oid); if (bl) clif->specialeffect(bl,type,AREA); @@ -12261,7 +12261,7 @@ BUILDIN(specialeffect) if( script_hasdata(st,4) ) { - TBL_NPC *nd = npc_name2id(script_getstr(st,4)); + TBL_NPC *nd = npc->name2id(script_getstr(st,4)); if(nd) clif->specialeffect(&nd->bl, type, target); } @@ -12570,19 +12570,19 @@ BUILDIN(jump_zero) *------------------------------------------*/ BUILDIN(movenpc) { TBL_NPC *nd = NULL; - const char *npc; + const char *npc_name; int x,y; - npc = script_getstr(st,2); + npc_name = script_getstr(st,2); x = script_getnum(st,3); y = script_getnum(st,4); - if ((nd = npc_name2id(npc)) == NULL) + if ((nd = npc->name2id(npc_name)) == NULL) return -1; if (script_hasdata(st,5)) nd->dir = script_getnum(st,5) % 8; - npc_movenpc(nd, x, y); + npc->movenpc(nd, x, y); return true; } @@ -12797,7 +12797,7 @@ BUILDIN(getmapxy) if( script_hasdata(st,6) ) { struct npc_data *nd; - nd=npc_name2id(script_getstr(st,6)); + nd=npc->name2id(script_getstr(st,6)); if (nd) bl = &nd->bl; } else //In case the origin is not an npc? @@ -14083,7 +14083,7 @@ BUILDIN(setnpcdisplay) return false; } - nd = npc_name2id(name); + nd = npc->name2id(name); if( nd == NULL ) {// not found script_pushint(st,1); @@ -14092,7 +14092,7 @@ BUILDIN(setnpcdisplay) // update npc if( newname ) - npc_setdisplayname(nd, newname); + npc->setdisplayname(nd, newname); if( size != -1 && size != (int)nd->size ) nd->size = size; @@ -14100,7 +14100,7 @@ BUILDIN(setnpcdisplay) size = -1; if( class_ != -1 && nd->class_ != class_ ) - npc_setclass(nd, class_); + npc->setclass(nd, class_); else if( size != -1 ) { // Required to update the visual size clif->clearunit_area(&nd->bl, CLR_OUTSIGHT); @@ -14384,7 +14384,7 @@ BUILDIN(callshop) shopname = script_getstr(st, 2); if( script_hasdata(st,3) ) flag = script_getnum(st,3); - nd = npc_name2id(shopname); + nd = npc->name2id(shopname); if( !nd || nd->bl.type != BL_NPC || (nd->subtype != SHOP && nd->subtype != CASHSHOP) ) { ShowError("buildin_callshop: Shop [%s] not found (or NPC is not shop type)\n", shopname); @@ -14399,8 +14399,8 @@ BUILDIN(callshop) switch( flag ) { - case 1: npc_buysellsel(sd,nd->bl.id,0); break; //Buy window - case 2: npc_buysellsel(sd,nd->bl.id,1); break; //Sell window + case 1: npc->buysellsel(sd,nd->bl.id,0); break; //Buy window + case 2: npc->buysellsel(sd,nd->bl.id,1); break; //Sell window default: clif->npcbuysell(sd,nd->bl.id); break; //Show menu } } @@ -14415,7 +14415,7 @@ BUILDIN(callshop) BUILDIN(npcshopitem) { const char* npcname = script_getstr(st, 2); - struct npc_data* nd = npc_name2id(npcname); + struct npc_data* nd = npc->name2id(npcname); int n, i; int amount; @@ -14444,7 +14444,7 @@ BUILDIN(npcshopitem) BUILDIN(npcshopadditem) { const char* npcname = script_getstr(st,2); - struct npc_data* nd = npc_name2id(npcname); + struct npc_data* nd = npc->name2id(npcname); int n, i; int amount; @@ -14473,7 +14473,7 @@ BUILDIN(npcshopadditem) BUILDIN(npcshopdelitem) { const char* npcname = script_getstr(st,2); - struct npc_data* nd = npc_name2id(npcname); + struct npc_data* nd = npc->name2id(npcname); unsigned int nameid; int n, i; int amount; @@ -14512,7 +14512,7 @@ BUILDIN(npcshopdelitem) BUILDIN(npcshopattach) { const char* npcname = script_getstr(st,2); - struct npc_data* nd = npc_name2id(npcname); + struct npc_data* nd = npc->name2id(npcname); int flag = 1; if( script_hasdata(st,3) ) @@ -15246,7 +15246,7 @@ BUILDIN(awake) { struct script_state *tst; struct npc_data* nd; - if( ( nd = npc_name2id(script_getstr(st, 2)) ) == NULL ) { + if( ( nd = npc->name2id(script_getstr(st, 2)) ) == NULL ) { ShowError("awake: NPC \"%s\" not found\n", script_getstr(st, 2)); return false; } @@ -15309,7 +15309,7 @@ BUILDIN(getvariableofnpc) return false; } - nd = npc_name2id(script_getstr(st,3)); + nd = npc->name2id(script_getstr(st,3)); if( nd == NULL || nd->subtype != SCRIPT || nd->u.scr.script == NULL ) {// NPC not found or has no script ShowError("script:getvariableofnpc: can't find npc %s\n", script_getstr(st,3)); @@ -15721,7 +15721,7 @@ BUILDIN(waitingroom2bg) struct map_session_data *sd; if( script_hasdata(st,7) ) - nd = npc_name2id(script_getstr(st,7)); + nd = npc->name2id(script_getstr(st,7)); else nd = (struct npc_data *)iMap->id2bl(st->oid); @@ -15782,7 +15782,7 @@ BUILDIN(waitingroom2bg_single) x = script_getnum(st,4); y = script_getnum(st,5); - nd = npc_name2id(script_getstr(st,6)); + nd = npc->name2id(script_getstr(st,6)); if( nd == NULL || (cd = (struct chat_data *)iMap->id2bl(nd->chat_id)) == NULL || cd->users <= 0 ) return true; @@ -16155,7 +16155,7 @@ BUILDIN(instance_npcname) { else if( st->instance_id >= 0 ) instance_id = st->instance_id; - if( instance_id >= 0 && (nd = npc_name2id(str)) != NULL ) { + if( instance_id >= 0 && (nd = npc->name2id(str)) != NULL ) { static char npcname[NAME_LENGTH]; snprintf(npcname, sizeof(npcname), "dup_%d_%d", instance_id, nd->bl.id); script_pushconststr(st,npcname); diff --git a/src/map/skill.c b/src/map/skill.c index 08da07137..0f448d5cb 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -543,7 +543,7 @@ int skillnotok (uint16 skill_id, struct map_session_data *sd) break; case MC_VENDING: case ALL_BUYING_STORE: - if( npc_isnear(&sd->bl) ) { + if( npc->isnear(&sd->bl) ) { // uncomment for more verbose message. //char output[150]; //sprintf(output, msg_txt(662), battle_config.min_npc_vendchat_distance); @@ -9041,7 +9041,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui if( !script ) break; if( dstsd ) - script->run(scriptroot,0,dstsd->bl.id,fake_nd->bl.id); + script->run(scriptroot,0,dstsd->bl.id,npc->fake_nd->bl.id); else script->run(scriptroot,0,src->id,0); } @@ -12633,7 +12633,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id break; case CG_HERMODE: - if(!npc_check_areanpc(1,sd->bl.m,sd->bl.x,sd->bl.y,skill->get_splash(skill_id, skill_lv))) + if(!npc->check_areanpc(1,sd->bl.m,sd->bl.x,sd->bl.y,skill->get_splash(skill_id, skill_lv))) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); return 0; diff --git a/src/map/status.c b/src/map/status.c index 6efc0b6ca..409d4493d 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -6074,7 +6074,7 @@ void status_set_viewdata(struct block_list *bl, int class_) if (mob->db_checkid(class_) || mob->is_clone(class_)) vd = mob->get_viewdata(class_); else if (npcdb_checkid(class_) || (bl->type == BL_NPC && class_ == WARP_CLASS)) - vd = npc_get_viewdata(class_); + vd = npc->get_viewdata(class_); else if (homdb_checkid(class_)) vd = homun->get_viewdata(class_); else if (mercenary->class(class_)) @@ -9214,7 +9214,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val } if( opt_flag&2 && sd && sd->touching_id ) - npc_touchnext_areanpc(sd,false); // run OnTouch_ on next char in range + npc->touchnext_areanpc(sd,false); // run OnTouch_ on next char in range return 1; } @@ -9982,7 +9982,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const skill->unit_move(bl,iTimer->gettick(),1); if(opt_flag&2 && sd && iMap->getcell(bl->m,bl->x,bl->y,CELL_CHKNPC)) - npc_touch_areanpc(sd,bl->m,bl->x,bl->y); //Trigger on-touch event. + npc->touch_areanpc(sd,bl->m,bl->x,bl->y); //Trigger on-touch event. ers_free(sc_data_ers, sce); return 1; diff --git a/src/map/unit.c b/src/map/unit.c index 65eea39c9..da6f26c9d 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -73,7 +73,7 @@ struct unit_data* unit_bl2ud(struct block_list *bl) { * @return a pointer to the given object's unit_data */ struct unit_data* unit_bl2ud2(struct block_list *bl) { - if( bl && bl->type == BL_NPC && ((struct npc_data*)bl)->ud == &npc_base_ud ) { + if( bl && bl->type == BL_NPC && ((struct npc_data*)bl)->ud == &npc->base_ud ) { struct npc_data *nd = (struct npc_data *)bl; nd->ud = NULL; CREATE(nd->ud, struct unit_data, 1); @@ -200,9 +200,9 @@ int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data) if(sd) { if( sd->touching_id ) - npc_touchnext_areanpc(sd,false); + npc->touchnext_areanpc(sd,false); if(iMap->getcell(bl->m,x,y,CELL_CHKNPC)) { - npc_touch_areanpc(sd,bl->m,x,y); + npc->touch_areanpc(sd,bl->m,x,y); if (bl->prev == NULL) //Script could have warped char, abort remaining of the function. return 0; } else @@ -228,7 +228,7 @@ int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data) } } else if (md) { if( iMap->getcell(bl->m,x,y,CELL_CHKNPC) ) { - if( npc_touch_areanpc2(md) ) return 0; // Warped + if( npc->touch_areanpc2(md) ) return 0; // Warped } else md->areanpc_id = 0; if (md->min_chase > md->db->range3) md->min_chase--; @@ -667,9 +667,9 @@ int unit_movepos(struct block_list *bl, short dst_x, short dst_y, int easy, bool if(sd) { if( sd->touching_id ) - npc_touchnext_areanpc(sd,false); + npc->touchnext_areanpc(sd,false); if(iMap->getcell(bl->m,bl->x,bl->y,CELL_CHKNPC)) { - npc_touch_areanpc(sd,bl->m,bl->x,bl->y); + 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; } else @@ -765,10 +765,10 @@ int unit_blown(struct block_list* bl, int dx, int dy, int count, int flag) if(sd) { if(sd->touching_id) { - npc_touchnext_areanpc(sd, false); + npc->touchnext_areanpc(sd, false); } if(iMap->getcell(bl->m, bl->x, bl->y, CELL_CHKNPC)) { - npc_touch_areanpc(sd, bl->m, bl->x, bl->y); + npc->touch_areanpc(sd, bl->m, bl->x, bl->y); } else { sd->areanpc_id = 0; } @@ -1637,7 +1637,7 @@ int unit_attack(struct block_list *src,int target_id,int continuous) if( src->type == BL_PC ) { TBL_PC* sd = (TBL_PC*)src; if( target->type == BL_NPC ) { // monster npcs [Valaris] - npc_click(sd,(TBL_NPC*)target); // submitted by leinsirk10 [Celest] + npc->click(sd,(TBL_NPC*)target); // submitted by leinsirk10 [Celest] return 0; } if( pc_is90overweight(sd) || pc_isridingwug(sd) ) { // overweight or mounted on warg - stop attacking @@ -2160,7 +2160,7 @@ int unit_remove_map(struct block_list *bl, clr_type clrtype, const char* file, i if(sd->menuskill_id) sd->menuskill_id = sd->menuskill_val = 0; if( sd->touching_id ) - npc_touchnext_areanpc(sd,true); + npc->touchnext_areanpc(sd,true); // Check if warping and not changing the map. if ( sd->state.warping && !sd->state.changemap ) { -- cgit v1.2.3-70-g09d2 From 1114eb3da58b078258a824424fef687a1ccee90c Mon Sep 17 00:00:00 2001 From: shennetsind Date: Wed, 25 Sep 2013 08:50:52 -0300 Subject: Renamed iTimer interface to timer. Also removed duplicate mentions of timer within calls to shorten. --- src/char/char.c | 32 ++++++------- src/char/int_auction.c | 8 ++-- src/char/int_guild.c | 6 +-- src/char/inter.c | 4 +- src/common/HPM.c | 2 +- src/common/console.c | 6 +-- src/common/core.c | 6 +-- src/common/mutex.c | 2 +- src/common/random.c | 2 +- src/common/socket.c | 12 ++--- src/common/sql.c | 4 +- src/common/timer.c | 34 ++++++------- src/common/timer.h | 18 +++---- src/login/ipban_sql.c | 6 +-- src/login/login.c | 26 +++++----- src/map/atcommand.c | 52 ++++++++++---------- src/map/battle.c | 58 +++++++++++------------ src/map/battleground.c | 12 ++--- src/map/chrif.c | 28 +++++------ src/map/clif.c | 86 ++++++++++++++++----------------- src/map/elemental.c | 22 ++++----- src/map/guild.c | 8 ++-- src/map/homunculus.c | 12 ++--- src/map/instance.c | 18 +++---- src/map/irc-bot.c | 18 +++---- src/map/map.c | 22 ++++----- src/map/mapreg_sql.c | 4 +- src/map/mercenary.c | 8 ++-- src/map/mob.c | 60 +++++++++++------------ src/map/npc.c | 50 ++++++++++---------- src/map/party.c | 4 +- src/map/pc.c | 126 ++++++++++++++++++++++++------------------------- src/map/pet.c | 64 ++++++++++++------------- src/map/script.c | 62 ++++++++++++------------ src/map/skill.c | 126 ++++++++++++++++++++++++------------------------- src/map/status.c | 66 +++++++++++++------------- src/map/unit.c | 116 ++++++++++++++++++++++----------------------- 37 files changed, 596 insertions(+), 594 deletions(-) (limited to 'src/map/elemental.c') diff --git a/src/char/char.c b/src/char/char.c index 943d1f52e..f618320e1 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -212,7 +212,7 @@ void set_char_charselect(int account_id) character->pincode_enable = *pincode->charselect + *pincode->enabled; if(character->waiting_disconnect != INVALID_TIMER) { - iTimer->delete_timer(character->waiting_disconnect, chardb_waiting_disconnect); + timer->delete(character->waiting_disconnect, chardb_waiting_disconnect); character->waiting_disconnect = INVALID_TIMER; } @@ -253,7 +253,7 @@ void set_char_online(int map_id, int char_id, int account_id) //Get rid of disconnect timer if(character->waiting_disconnect != INVALID_TIMER) { - iTimer->delete_timer(character->waiting_disconnect, chardb_waiting_disconnect); + timer->delete(character->waiting_disconnect, chardb_waiting_disconnect); character->waiting_disconnect = INVALID_TIMER; } @@ -298,7 +298,7 @@ void set_char_offline(int char_id, int account_id) server[character->server].users--; if(character->waiting_disconnect != INVALID_TIMER){ - iTimer->delete_timer(character->waiting_disconnect, chardb_waiting_disconnect); + timer->delete(character->waiting_disconnect, chardb_waiting_disconnect); character->waiting_disconnect = INVALID_TIMER; } @@ -333,7 +333,7 @@ static int char_db_setoffline(DBKey key, DBData *data, va_list ap) character->char_id = -1; character->server = -1; if(character->waiting_disconnect != INVALID_TIMER){ - iTimer->delete_timer(character->waiting_disconnect, chardb_waiting_disconnect); + timer->delete(character->waiting_disconnect, chardb_waiting_disconnect); character->waiting_disconnect = INVALID_TIMER; } } else if (character->server == server) @@ -2036,7 +2036,7 @@ static void char_auth_ok(int fd, struct char_session_data *sd) { //Character already online. KICK KICK KICK mapif_disconnectplayer(server[character->server].fd, character->account_id, character->char_id, 2); if (character->waiting_disconnect == INVALID_TIMER) - character->waiting_disconnect = iTimer->add_timer(iTimer->gettick()+20000, chardb_waiting_disconnect, character->account_id, 0); + character->waiting_disconnect = timer->add(timer->gettick()+20000, chardb_waiting_disconnect, character->account_id, 0); if (character) character->pincode_enable = -1; WFIFOHEAD(fd,3); @@ -2115,7 +2115,7 @@ void loginif_on_ready(void) loginif_check_shutdown(); //Send online accounts to login server. - send_accounts_tologin(INVALID_TIMER, iTimer->gettick(), 0, 0); + send_accounts_tologin(INVALID_TIMER, timer->gettick(), 0, 0); // if no map-server already connected, display a message... ARR_FIND( 0, ARRAYLENGTH(server), i, server[i].fd > 0 && server[i].map[0] ); @@ -2404,7 +2404,7 @@ int parse_fromlogin(int fd) { { //Kick it from the map server it is on. mapif_disconnectplayer(server[character->server].fd, character->account_id, character->char_id, 2); if (character->waiting_disconnect == INVALID_TIMER) - character->waiting_disconnect = iTimer->add_timer(iTimer->gettick()+AUTH_TIMEOUT, chardb_waiting_disconnect, character->account_id, 0); + character->waiting_disconnect = timer->add(timer->gettick()+AUTH_TIMEOUT, chardb_waiting_disconnect, character->account_id, 0); } else {// Manual kick from char server. @@ -2473,12 +2473,12 @@ int send_accounts_tologin(int tid, unsigned int tick, int id, intptr_t data); void do_init_loginif(void) { // establish char-login connection if not present - iTimer->add_timer_func_list(check_connect_login_server, "check_connect_login_server"); - iTimer->add_timer_interval(iTimer->gettick() + 1000, check_connect_login_server, 0, 0, 10 * 1000); + timer->add_func_list(check_connect_login_server, "check_connect_login_server"); + timer->add_interval(timer->gettick() + 1000, check_connect_login_server, 0, 0, 10 * 1000); // send a list of all online account IDs to login server - iTimer->add_timer_func_list(send_accounts_tologin, "send_accounts_tologin"); - iTimer->add_timer_interval(iTimer->gettick() + 1000, send_accounts_tologin, 0, 0, 3600 * 1000); //Sync online accounts every hour + timer->add_func_list(send_accounts_tologin, "send_accounts_tologin"); + timer->add_interval(timer->gettick() + 1000, send_accounts_tologin, 0, 0, 3600 * 1000); //Sync online accounts every hour } void do_final_loginif(void) @@ -5030,15 +5030,15 @@ int do_init(int argc, char **argv) { do_init_mapif(); // periodically update the overall user count on all mapservers + login server - iTimer->add_timer_func_list(broadcast_user_count, "broadcast_user_count"); - iTimer->add_timer_interval(iTimer->gettick() + 1000, broadcast_user_count, 0, 0, 5 * 1000); + timer->add_func_list(broadcast_user_count, "broadcast_user_count"); + timer->add_interval(timer->gettick() + 1000, broadcast_user_count, 0, 0, 5 * 1000); // Timer to clear (online_char_db) - iTimer->add_timer_func_list(chardb_waiting_disconnect, "chardb_waiting_disconnect"); + timer->add_func_list(chardb_waiting_disconnect, "chardb_waiting_disconnect"); // Online Data timers (checking if char still connected) - iTimer->add_timer_func_list(online_data_cleanup, "online_data_cleanup"); - iTimer->add_timer_interval(iTimer->gettick() + 1000, online_data_cleanup, 0, 0, 600 * 1000); + timer->add_func_list(online_data_cleanup, "online_data_cleanup"); + timer->add_interval(timer->gettick() + 1000, online_data_cleanup, 0, 0, 600 * 1000); //Cleaning the tables for NULL entrys @ startup [Sirius] //Chardb clean diff --git a/src/char/int_auction.c b/src/char/int_auction.c index bf5ea1700..0dad9d2de 100644 --- a/src/char/int_auction.c +++ b/src/char/int_auction.c @@ -115,7 +115,7 @@ unsigned int auction_create(struct auction_data *auction) auction->item.expire_time = 0; auction->auction_id = (unsigned int)SQL->StmtLastInsertId(stmt); - auction->auction_end_timer = iTimer->add_timer( iTimer->gettick() + tick , auction_end_timer, auction->auction_id, 0); + auction->auction_end_timer = timer->add( timer->gettick() + tick , auction_end_timer, auction->auction_id, 0); ShowInfo("New Auction %u | time left %u ms | By %s.\n", auction->auction_id, tick, auction->seller_name); CREATE(auction_, struct auction_data, 1); @@ -170,7 +170,7 @@ void auction_delete(struct auction_data *auction) Sql_ShowDebug(sql_handle); if( auction->auction_end_timer != INVALID_TIMER ) - iTimer->delete_timer(auction->auction_end_timer, auction_end_timer); + timer->delete(auction->auction_end_timer, auction_end_timer); idb_remove(auction_db_, auction_id); } @@ -182,7 +182,7 @@ void inter_auctions_fromsql(void) struct item *item; char *data; StringBuf buf; - unsigned int tick = iTimer->gettick(), endtick; + unsigned int tick = timer->gettick(), endtick; time_t now = time(NULL); StrBuf->Init(&buf); @@ -234,7 +234,7 @@ void inter_auctions_fromsql(void) else endtick = tick + 10000; // 10 Second's to process ended auctions - auction->auction_end_timer = iTimer->add_timer(endtick, auction_end_timer, auction->auction_id, 0); + auction->auction_end_timer = timer->add(endtick, auction_end_timer, auction->auction_id, 0); idb_put(auction_db_, auction->auction_id, auction); } diff --git a/src/char/int_guild.c b/src/char/int_guild.c index a9bce9cbe..fab63894e 100644 --- a/src/char/int_guild.c +++ b/src/char/int_guild.c @@ -86,7 +86,7 @@ static int guild_save_timer(int tid, unsigned int tick, int id, intptr_t data) state = guild_db_->size(guild_db_); if( state < 1 ) state = 1; //Calculate the time slot for the next save. - iTimer->add_timer(tick + autosave_interval/state, guild_save_timer, 0, 0); + timer->add(tick + autosave_interval/state, guild_save_timer, 0, 0); return 0; } @@ -729,8 +729,8 @@ int inter_guild_sql_init(void) //Read exp file sv->readdb("db", DBPATH"exp_guild.txt", ',', 1, 1, 100, exp_guild_parse_row); - iTimer->add_timer_func_list(guild_save_timer, "guild_save_timer"); - iTimer->add_timer(iTimer->gettick() + 10000, guild_save_timer, 0, 0); + timer->add_func_list(guild_save_timer, "guild_save_timer"); + timer->add(timer->gettick() + 10000, guild_save_timer, 0, 0); return 0; } diff --git a/src/char/inter.c b/src/char/inter.c index 1ff2bca61..23f400ee9 100644 --- a/src/char/inter.c +++ b/src/char/inter.c @@ -946,7 +946,7 @@ int check_ttl_wisdata_sub(DBKey key, DBData *data, va_list ap) int check_ttl_wisdata(void) { - unsigned long tick = iTimer->gettick(); + unsigned long tick = timer->gettick(); int i; do { @@ -1039,7 +1039,7 @@ int mapif_parse_WisRequest(int fd) memcpy(wd->src, RFIFOP(fd, 4), NAME_LENGTH); memcpy(wd->dst, RFIFOP(fd,28), NAME_LENGTH); memcpy(wd->msg, RFIFOP(fd,52), wd->len); - wd->tick = iTimer->gettick(); + wd->tick = timer->gettick(); idb_put(wis_db, wd->id, wd); mapif_wis_message(wd); } diff --git a/src/common/HPM.c b/src/common/HPM.c index 3b79febd7..9895ae95d 100644 --- a/src/common/HPM.c +++ b/src/common/HPM.c @@ -470,7 +470,7 @@ void hplugins_share_defaults(void) { /* sql */ HPM->share(SQL,"SQL"); /* timer */ - HPM->share(iTimer,"iTimer"); + HPM->share(timer,"timer"); } diff --git a/src/common/console.c b/src/common/console.c index c9772ecfd..75b6eaea4 100644 --- a/src/common/console.c +++ b/src/common/console.c @@ -362,7 +362,7 @@ void console_parse_final(void) { /* wait for thread to close */ rathread_wait(console->pthread, NULL); - + racond_destroy(console->ptcond); ramutex_destroy(console->ptmutex); } @@ -382,8 +382,8 @@ void console_parse_init(void) { exit(EXIT_FAILURE); } - iTimer->add_timer_func_list(console->parse_timer, "console_parse_timer"); - iTimer->add_timer_interval(iTimer->gettick() + 1000, console->parse_timer, 0, 0, 500);/* start listening in 1s; re-try every 0.5s */ + timer->add_func_list(console->parse_timer, "console_parse_timer"); + timer->add_interval(timer->gettick() + 1000, console->parse_timer, 0, 0, 500);/* start listening in 1s; re-try every 0.5s */ } void console_setSQL(Sql *SQL) { diff --git a/src/common/core.c b/src/common/core.c index 1e5179448..6a73d2d39 100644 --- a/src/common/core.c +++ b/src/common/core.c @@ -325,7 +325,7 @@ int main (int argc, char **argv) { cevents_init(); #endif - iTimer->init(); + timer->init(); console->init(); @@ -341,7 +341,7 @@ int main (int argc, char **argv) { {// Main runtime cycle int next; while (runflag != CORE_ST_STOP) { - next = iTimer->do_timer(iTimer->gettick_nocache()); + next = timer->do_timer(timer->gettick_nocache()); do_sockets(next); } } @@ -352,7 +352,7 @@ int main (int argc, char **argv) { #ifndef MINICORE HPM->final(); #endif - iTimer->final(); + timer->final(); socket_final(); DB->final(); mempool_final(); diff --git a/src/common/mutex.c b/src/common/mutex.c index 6bb1efdab..0668dbc41 100644 --- a/src/common/mutex.c +++ b/src/common/mutex.c @@ -201,7 +201,7 @@ void racond_wait( racond c, ramutex m, sysint timeout_ticks){ pthread_cond_wait( &c->hCond, &m->hMutex ); }else{ struct timespec wtime; - int64 exact_timeout = iTimer->gettick() + timeout_ticks; + int64 exact_timeout = timer->gettick() + timeout_ticks; wtime.tv_sec = exact_timeout/1000; wtime.tv_nsec = (exact_timeout%1000)*1000000; diff --git a/src/common/random.c b/src/common/random.c index a7d432e34..2f1b62934 100644 --- a/src/common/random.c +++ b/src/common/random.c @@ -17,7 +17,7 @@ /// Initializes the random number generator with an appropriate seed. void rnd_init(void) { - uint32 seed = iTimer->gettick(); + uint32 seed = timer->gettick(); seed += (uint32)time(NULL); #if defined(WIN32) seed += GetCurrentProcessId(); diff --git a/src/common/socket.c b/src/common/socket.c index 4f2e386ec..7c8b3738b 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -1012,9 +1012,9 @@ static int connect_check_(uint32 ip) if( hist->ddos ) {// flagged as DDoS return (connect_ok == 2 ? 1 : 0); - } else if( DIFF_TICK(iTimer->gettick(),hist->tick) < ddos_interval ) + } else if( DIFF_TICK(timer->gettick(),hist->tick) < ddos_interval ) {// connection within ddos_interval - hist->tick = iTimer->gettick(); + hist->tick = timer->gettick(); if( hist->count++ >= ddos_count ) {// DDoS attack detected hist->ddos = 1; @@ -1024,7 +1024,7 @@ static int connect_check_(uint32 ip) return connect_ok; } else {// not within ddos_interval, clear data - hist->tick = iTimer->gettick(); + hist->tick = timer->gettick(); hist->count = 0; return connect_ok; } @@ -1035,7 +1035,7 @@ static int connect_check_(uint32 ip) CREATE(hist, ConnectHistory, 1); memset(hist, 0, sizeof(ConnectHistory)); hist->ip = ip; - hist->tick = iTimer->gettick(); + hist->tick = timer->gettick(); hist->next = connect_history[ip&0xFFFF]; connect_history[ip&0xFFFF] = hist; return connect_ok; @@ -1400,8 +1400,8 @@ void socket_init(void) #ifndef MINICORE // Delete old connection history every 5 minutes memset(connect_history, 0, sizeof(connect_history)); - iTimer->add_timer_func_list(connect_check_clear, "connect_check_clear"); - iTimer->add_timer_interval(iTimer->gettick()+1000, connect_check_clear, 0, 0, 5*60*1000); + timer->add_func_list(connect_check_clear, "connect_check_clear"); + timer->add_interval(timer->gettick()+1000, connect_check_clear, 0, 0, 5*60*1000); #endif ShowInfo("Server supports up to '"CL_WHITE"%u"CL_RESET"' concurrent connections.\n", rlim_cur); diff --git a/src/common/sql.c b/src/common/sql.c index 579346001..9b7fe4108 100644 --- a/src/common/sql.c +++ b/src/common/sql.c @@ -210,7 +210,7 @@ static int Sql_P_Keepalive(Sql* self) // establish keepalive ping_interval = timeout - 30; // 30-second reserve //add_timer_func_list(Sql_P_KeepaliveTimer, "Sql_P_KeepaliveTimer"); - return iTimer->add_timer_interval(iTimer->gettick() + ping_interval*1000, Sql_P_KeepaliveTimer, 0, (intptr_t)self, ping_interval*1000); + return timer->add_interval(timer->gettick() + ping_interval*1000, Sql_P_KeepaliveTimer, 0, (intptr_t)self, ping_interval*1000); } @@ -404,7 +404,7 @@ void Sql_Free(Sql* self) { SQL->FreeResult(self); StrBuf->Destroy(&self->buf); - if( self->keepalive != INVALID_TIMER ) iTimer->delete_timer(self->keepalive, Sql_P_KeepaliveTimer); + if( self->keepalive != INVALID_TIMER ) timer->delete(self->keepalive, Sql_P_KeepaliveTimer); aFree(self); } } diff --git a/src/common/timer.c b/src/common/timer.c index f019c6927..a2378a5aa 100644 --- a/src/common/timer.c +++ b/src/common/timer.c @@ -21,6 +21,8 @@ #include // struct timeval, gettimeofday() #endif +struct timer_interface timer_s; + // If the server can't handle processing thousands of monsters // or many connected clients, please increase TIMER_MIN_INTERVAL. #define TIMER_MIN_INTERVAL 50 @@ -257,7 +259,7 @@ int timer_add_interval(unsigned int tick, TimerFunc func, int id, intptr_t data, int tid; if( interval < 1 ) { - ShowError("timer_add_interval: invalid interval (tick=%u %p[%s] id=%d data=%d diff_tick=%d)\n", tick, func, search_timer_func_list(func), id, data, DIFF_TICK(tick, iTimer->gettick())); + ShowError("timer_add_interval: invalid interval (tick=%u %p[%s] id=%d data=%d diff_tick=%d)\n", tick, func, search_timer_func_list(func), id, data, DIFF_TICK(tick, timer->gettick())); return INVALID_TIMER; } @@ -300,7 +302,7 @@ int timer_do_delete(int tid, TimerFunc func) { /// Adjusts a timer's expiration time. /// Returns the new tick value, or -1 if it fails. int timer_addtick(int tid, unsigned int tick) { - return iTimer->settick_timer(tid, timer_data[tid].tick+tick); + return timer->settick(tid, timer_data[tid].tick+tick); } /// Modifies a timer's expiration time (an alternative to deleting a timer and starting a new one). @@ -415,20 +417,20 @@ void timer_final(void) { * created by Susu *-------------------------------------*/ void timer_defaults(void) { - iTimer = &iTimer_s; + timer = &timer_s; /* funcs */ - iTimer->gettick = timer_gettick; - iTimer->gettick_nocache = timer_gettick_nocache; - iTimer->add_timer = timer_add; - iTimer->add_timer_interval = timer_add_interval; - iTimer->add_timer_func_list = timer_add_func_list; - iTimer->get_timer = timer_get; - iTimer->delete_timer = timer_do_delete; - iTimer->addtick_timer = timer_addtick; - iTimer->settick_timer = timer_settick; - iTimer->get_uptime = timer_get_uptime; - iTimer->do_timer = do_timer; - iTimer->init = timer_init; - iTimer->final = timer_final; + timer->gettick = timer_gettick; + timer->gettick_nocache = timer_gettick_nocache; + timer->add = timer_add; + timer->add_interval = timer_add_interval; + timer->add_func_list = timer_add_func_list; + timer->get = timer_get; + timer->delete = timer_do_delete; + timer->addtick = timer_addtick; + timer->settick = timer_settick; + timer->get_uptime = timer_get_uptime; + timer->do_timer = do_timer; + timer->init = timer_init; + timer->final = timer_final; } diff --git a/src/common/timer.h b/src/common/timer.h index 50f1c354b..3146a2e66 100644 --- a/src/common/timer.h +++ b/src/common/timer.h @@ -44,24 +44,24 @@ struct timer_interface { unsigned int (*gettick) (void); unsigned int (*gettick_nocache) (void); - int (*add_timer) (unsigned int tick, TimerFunc func, int id, intptr_t data); - int (*add_timer_interval) (unsigned int tick, TimerFunc func, int id, intptr_t data, int interval); - const struct TimerData *(*get_timer) (int tid); - int (*delete_timer) (int tid, TimerFunc func); + int (*add) (unsigned int tick, TimerFunc func, int id, intptr_t data); + int (*add_interval) (unsigned int tick, TimerFunc func, int id, intptr_t data, int interval); + const struct TimerData *(*get) (int tid); + int (*delete) (int tid, TimerFunc func); - int (*addtick_timer) (int tid, unsigned int tick); - int (*settick_timer) (int tid, unsigned int tick); + int (*addtick) (int tid, unsigned int tick); + int (*settick) (int tid, unsigned int tick); - int (*add_timer_func_list) (TimerFunc func, char* name); + int (*add_func_list) (TimerFunc func, char* name); unsigned long (*get_uptime) (void); int (*do_timer) (unsigned int tick); void (*init) (void); void (*final) (void); -} iTimer_s; +}; -struct timer_interface *iTimer; +struct timer_interface *timer; void timer_defaults(void); diff --git a/src/login/ipban_sql.c b/src/login/ipban_sql.c index fd9f1a4a1..df516a3f6 100644 --- a/src/login/ipban_sql.c +++ b/src/login/ipban_sql.c @@ -86,8 +86,8 @@ void ipban_init(void) if( login_config.ipban_cleanup_interval > 0 ) { // set up periodic cleanup of connection history and active bans - iTimer->add_timer_func_list(ipban_cleanup, "ipban_cleanup"); - cleanup_timer_id = iTimer->add_timer_interval(iTimer->gettick()+10, ipban_cleanup, 0, 0, login_config.ipban_cleanup_interval*1000); + timer->add_func_list(ipban_cleanup, "ipban_cleanup"); + cleanup_timer_id = timer->add_interval(timer->gettick()+10, ipban_cleanup, 0, 0, login_config.ipban_cleanup_interval*1000); } else // make sure it gets cleaned up on login-server start regardless of interval-based cleanups ipban_cleanup(0,0,0,0); } @@ -100,7 +100,7 @@ void ipban_final(void) if( login_config.ipban_cleanup_interval > 0 ) // release data - iTimer->delete_timer(cleanup_timer_id, ipban_cleanup); + timer->delete(cleanup_timer_id, ipban_cleanup); ipban_cleanup(0,0,0,0); // always clean up on login-server stop diff --git a/src/login/login.c b/src/login/login.c index f92f0094d..b603117e4 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -103,7 +103,7 @@ struct online_login_data* add_online_user(int char_server, int account_id) p->char_server = char_server; if( p->waiting_disconnect != INVALID_TIMER ) { - iTimer->delete_timer(p->waiting_disconnect, waiting_disconnect_timer); + timer->delete(p->waiting_disconnect, waiting_disconnect_timer); p->waiting_disconnect = INVALID_TIMER; } return p; @@ -116,7 +116,7 @@ void remove_online_user(int account_id) if( p == NULL ) return; if( p->waiting_disconnect != INVALID_TIMER ) - iTimer->delete_timer(p->waiting_disconnect, waiting_disconnect_timer); + timer->delete(p->waiting_disconnect, waiting_disconnect_timer); idb_remove(online_db, account_id); } @@ -145,7 +145,7 @@ static int online_db_setoffline(DBKey key, DBData *data, va_list ap) p->char_server = -1; if( p->waiting_disconnect != INVALID_TIMER ) { - iTimer->delete_timer(p->waiting_disconnect, waiting_disconnect_timer); + timer->delete(p->waiting_disconnect, waiting_disconnect_timer); p->waiting_disconnect = INVALID_TIMER; } } @@ -793,7 +793,7 @@ int parse_fromchar(int fd) p->char_server = id; if (p->waiting_disconnect != INVALID_TIMER) { - iTimer->delete_timer(p->waiting_disconnect, waiting_disconnect_timer); + timer->delete(p->waiting_disconnect, waiting_disconnect_timer); p->waiting_disconnect = INVALID_TIMER; } } @@ -902,12 +902,12 @@ int parse_fromchar(int fd) int mmo_auth_new(const char* userid, const char* pass, const char sex, const char* last_ip) { static int num_regs = 0; // registration counter static unsigned int new_reg_tick = 0; - unsigned int tick = iTimer->gettick(); + unsigned int tick = timer->gettick(); struct mmo_account acc; //Account Registration Flood Protection by [Kevin] if( new_reg_tick == 0 ) - new_reg_tick = iTimer->gettick(); + new_reg_tick = timer->gettick(); if( DIFF_TICK(tick, new_reg_tick) < 0 && num_regs >= allowed_regs ) { ShowNotice("Account registration denied (registration limit exceeded)\n"); return 3; @@ -1151,7 +1151,7 @@ void login_auth_ok(struct login_session_data* sd) WBUFL(buf,2) = sd->account_id; charif_sendallwos(-1, buf, 6); if( data->waiting_disconnect == INVALID_TIMER ) - data->waiting_disconnect = iTimer->add_timer(iTimer->gettick()+AUTH_TIMEOUT, waiting_disconnect_timer, sd->account_id, 0); + data->waiting_disconnect = timer->add(timer->gettick()+AUTH_TIMEOUT, waiting_disconnect_timer, sd->account_id, 0); WFIFOHEAD(fd,3); WFIFOW(fd,0) = 0x81; @@ -1218,7 +1218,7 @@ void login_auth_ok(struct login_session_data* sd) data = add_online_user(-1, sd->account_id); // schedule deletion of this node - data->waiting_disconnect = iTimer->add_timer(iTimer->gettick()+AUTH_TIMEOUT, waiting_disconnect_timer, sd->account_id, 0); + data->waiting_disconnect = timer->add(timer->gettick()+AUTH_TIMEOUT, waiting_disconnect_timer, sd->account_id, 0); } } @@ -1796,7 +1796,7 @@ int do_init(int argc, char** argv) // Online user database init online_db = idb_alloc(DB_OPT_RELEASE_DATA); - iTimer->add_timer_func_list(waiting_disconnect_timer, "waiting_disconnect_timer"); + timer->add_func_list(waiting_disconnect_timer, "waiting_disconnect_timer"); // Interserver auth init auth_db = idb_alloc(DB_OPT_RELEASE_DATA); @@ -1805,13 +1805,13 @@ int do_init(int argc, char** argv) set_defaultparse(parse_login); // every 10 minutes cleanup online account db. - iTimer->add_timer_func_list(online_data_cleanup, "online_data_cleanup"); - iTimer->add_timer_interval(iTimer->gettick() + 600*1000, online_data_cleanup, 0, 0, 600*1000); + timer->add_func_list(online_data_cleanup, "online_data_cleanup"); + timer->add_interval(timer->gettick() + 600*1000, online_data_cleanup, 0, 0, 600*1000); // add timer to detect ip address change and perform update if (login_config.ip_sync_interval) { - iTimer->add_timer_func_list(sync_ip_addresses, "sync_ip_addresses"); - iTimer->add_timer_interval(iTimer->gettick() + login_config.ip_sync_interval, sync_ip_addresses, 0, 0, login_config.ip_sync_interval); + timer->add_func_list(sync_ip_addresses, "sync_ip_addresses"); + timer->add_interval(timer->gettick() + login_config.ip_sync_interval, sync_ip_addresses, 0, 0, login_config.ip_sync_interval); } // Account database init diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 2466c2cca..23653f803 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -912,7 +912,7 @@ ACMD(hide) if( map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.pvp_nocalcrank ) {// register the player for ranking calculations - sd->pvp_timer = iTimer->add_timer( iTimer->gettick() + 200, pc->calc_pvprank_timer, sd->bl.id, 0 ); + 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); @@ -926,7 +926,7 @@ ACMD(hide) if( map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.pvp_nocalcrank && sd->pvp_timer != INVALID_TIMER ) {// unregister the player for ranking - iTimer->delete_timer( sd->pvp_timer, pc->calc_pvprank_timer ); + timer->delete( sd->pvp_timer, pc->calc_pvprank_timer ); sd->pvp_timer = INVALID_TIMER; } } @@ -1096,7 +1096,7 @@ ACMD(heal) if ( hp < 0 && sp <= 0 ) { iStatus->damage(NULL, &sd->bl, -hp, -sp, 0, 0); - clif->damage(&sd->bl,&sd->bl, iTimer->gettick(), 0, 0, -hp, 0, 4, 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; } @@ -1107,7 +1107,7 @@ ACMD(heal) iStatus->heal(&sd->bl, hp, 0, 0); else { iStatus->damage(NULL, &sd->bl, -hp, 0, 0, 0); - clif->damage(&sd->bl,&sd->bl, iTimer->gettick(), 0, 0, -hp, 0, 4, 0); + clif->damage(&sd->bl,&sd->bl, timer->gettick(), 0, 0, -hp, 0, 4, 0); } } @@ -1470,7 +1470,7 @@ static int atcommand_pvpoff_sub(struct block_list *bl,va_list ap) TBL_PC* sd = (TBL_PC*)bl; clif->pvpset(sd, 0, 0, 2); if (sd->pvp_timer != INVALID_TIMER) { - iTimer->delete_timer(sd->pvp_timer, pc->calc_pvprank_timer); + timer->delete(sd->pvp_timer, pc->calc_pvprank_timer); sd->pvp_timer = INVALID_TIMER; } return 0; @@ -1505,7 +1505,7 @@ static int atcommand_pvpon_sub(struct block_list *bl,va_list ap) { TBL_PC* sd = (TBL_PC*)bl; if (sd->pvp_timer == INVALID_TIMER) { - sd->pvp_timer = iTimer->add_timer(iTimer->gettick() + 200, pc->calc_pvprank_timer, sd->bl.id, 0); + sd->pvp_timer = timer->add(timer->gettick() + 200, pc->calc_pvprank_timer, sd->bl.id, 0); sd->pvp_rank = 0; sd->pvp_lastusers = 0; sd->pvp_point = 5; @@ -4206,7 +4206,7 @@ ACMD(nuke) if ((pl_sd = iMap->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, iTimer->gettick(), 0); + 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! } else { clif->message(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player. @@ -4419,25 +4419,25 @@ ACMD(servertime) 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 - timer_data = iTimer->get_timer(pc->day_timer_tid); - sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,iTimer->gettick())/1000)); // Game time: The game is actualy in night for %s. + 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 = iTimer->get_timer(pc->night_timer_tid); - sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,iTimer->gettick())/1000)); // Game time: The game is actualy in daylight for %s. + 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 = iTimer->get_timer(pc->night_timer_tid); - timer_data2 = iTimer->get_timer(pc->day_timer_tid); - sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,iTimer->gettick())/1000)); // Game time: The game is actualy in daylight for %s. + 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. @@ -4447,9 +4447,9 @@ ACMD(servertime) 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 = iTimer->get_timer(pc->day_timer_tid); - timer_data2 = iTimer->get_timer(pc->night_timer_tid); - sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,iTimer->gettick()) / 1000)); // Game time: The game is actualy in night for %s. + 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. @@ -5131,7 +5131,7 @@ ACMD(npcmove) x = cap_value(x, 0, map[m].xs-1); y = cap_value(y, 0, map[m].ys-1); iMap->foreachinrange(clif->outsight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl); - iMap->moveblock(&nd->bl, x, y, iTimer->gettick()); + iMap->moveblock(&nd->bl, x, y, timer->gettick()); iMap->foreachinrange(clif->insight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl); clif->message(fd, msg_txt(1155)); // NPC moved. @@ -5455,7 +5455,7 @@ ACMD(displayskill) return false; } status = iStatus->get_status_data(&sd->bl); - tick = iTimer->gettick(); + tick = timer->gettick(); clif->skill_damage(&sd->bl,&sd->bl, tick, status->amotion, status->dmotion, 1, 1, skill_id, skill_lv, 5); clif->skill_nodamage(&sd->bl, &sd->bl, skill_id, skill_lv, 1); clif->skill_poseffect(&sd->bl, skill_id, skill_lv, sd->bl.x, sd->bl.y, tick); @@ -6216,9 +6216,9 @@ ACMD(pettalk) nullpo_retr(-1, sd); if ( battle_config.min_chat_delay ) { - if( DIFF_TICK(sd->cantalk_tick, iTimer->gettick()) > 0 ) + if( DIFF_TICK(sd->cantalk_tick, timer->gettick()) > 0 ) return true; - sd->cantalk_tick = iTimer->gettick() + battle_config.min_chat_delay; + sd->cantalk_tick = timer->gettick() + battle_config.min_chat_delay; } if(!sd->status.pet_id || !(pd=sd->pd)) @@ -6339,7 +6339,7 @@ ACMD(summon) int mob_id = 0; int duration = 0; struct mob_data *md; - unsigned int tick=iTimer->gettick(); + unsigned int tick=timer->gettick(); nullpo_retr(-1, sd); @@ -6369,7 +6369,7 @@ ACMD(summon) md->master_id=sd->bl.id; md->special_state.ai=1; - md->deletetimer=iTimer->add_timer(tick+(duration*60000),mob->timer_delete,md->bl.id,0); + md->deletetimer=timer->add(tick+(duration*60000),mob->timer_delete,md->bl.id,0); clif->specialeffect(&md->bl,344,AREA); mob->spawn(md); sc_start4(&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000); @@ -6492,7 +6492,7 @@ ACMD(uptime) minute = 60, days = 0, hours = 0, minutes = 0; nullpo_retr(-1, sd); - seconds = iTimer->get_uptime(); + seconds = timer->get_uptime(); days = seconds/day; seconds -= (seconds/day>0)?(seconds/day)*day:0; hours = seconds/hour; @@ -7044,9 +7044,9 @@ ACMD(homtalk) nullpo_retr(-1, sd); if ( battle_config.min_chat_delay ) { - if( DIFF_TICK(sd->cantalk_tick, iTimer->gettick()) > 0 ) + if( DIFF_TICK(sd->cantalk_tick, timer->gettick()) > 0 ) return true; - sd->cantalk_tick = iTimer->gettick() + battle_config.min_chat_delay; + sd->cantalk_tick = timer->gettick() + battle_config.min_chat_delay; } if (sd->sc.count && //no "chatting" while muted. diff --git a/src/map/battle.c b/src/map/battle.c index 85fa2cb98..a8022ea84 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -277,9 +277,9 @@ int battle_delay_damage (unsigned int tick, int amotion, struct block_list *src, iMap->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 ) - skill->additional_effect(src, target, skill_id, skill_lv, attack_type, dmg_lv, iTimer->gettick()); + 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, iTimer->gettick()); + skill->counter_additional_effect(src, target, skill_id, skill_lv, attack_type, timer->gettick()); iMap->freeblock_unlock(); return 0; } @@ -302,7 +302,7 @@ int battle_delay_damage (unsigned int tick, int amotion, struct block_list *src, ((TBL_PC*)src)->delayed_damage++; } - iTimer->add_timer(tick+amotion, battle->delay_damage_sub, 0, (intptr_t)dat); + timer->add(tick+amotion, battle->delay_damage_sub, 0, (intptr_t)dat); return 0; } @@ -365,7 +365,7 @@ int64 battle_attr_fix(struct block_list *src, struct block_list *target, int64 d y = sg->val3 & 0xffff; skill->unitsetting(src,su->group->skill_id,su->group->skill_lv,x,y,1); sg->val3 = -1; - sg->limit = DIFF_TICK(iTimer->gettick(),sg->tick)+300; + sg->limit = DIFF_TICK(timer->gettick(),sg->tick)+300; } } } @@ -2664,7 +2664,7 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam delay = 200; else delay = 100; - unit->set_walkdelay(bl, iTimer->gettick(), delay, 1); + unit->set_walkdelay(bl, timer->gettick(), delay, 1); if(sc->data[SC_CR_SHRINK] && rnd()%100<5*sce->val1) skill->blown(bl,src,skill->get_blewcount(CR_SHRINK,1),-1,0); @@ -2734,9 +2734,9 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam if (((sce=sc->data[SC_NJ_UTSUSEMI]) || sc->data[SC_NJ_BUNSINJYUTSU]) && flag&BF_WEAPON && !(skill->get_nk(skill_id)&NK_NO_CARDFIX_ATK)) { - skill->additional_effect (src, bl, skill_id, skill_lv, flag, ATK_BLOCK, iTimer->gettick() ); + skill->additional_effect (src, bl, skill_id, skill_lv, flag, ATK_BLOCK, timer->gettick() ); if( !iStatus->isdead(src) ) - skill->counter_additional_effect( src, bl, skill_id, skill_lv, flag, iTimer->gettick() ); + skill->counter_additional_effect( src, bl, skill_id, skill_lv, flag, timer->gettick() ); if (sce) { clif->specialeffect(bl, 462, AREA); skill->blown(src,bl,sce->val3,-1,0); @@ -2873,7 +2873,7 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam damage -= damage * sc->data[SC_PAIN_KILLER]->val3 / 100; } if((sce=sc->data[SC_MAGMA_FLOW]) && (rnd()%100 <= sce->val2) ){ - skill->castend_damage_id(bl,src,MH_MAGMA_FLOW,sce->val1,iTimer->gettick(),0); + skill->castend_damage_id(bl,src,MH_MAGMA_FLOW,sce->val1,timer->gettick(),0); } if( (sce = sc->data[SC_STONEHARDSKIN]) && flag&(BF_SHORT|BF_WEAPON) && damage > 0 ) { @@ -2970,7 +2970,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, iTimer->gettick(), 500, 500, damage, -1, 0, 0), 0); + iStatus->damage(bl, s_bl, damage, 0, clif->damage(s_bl, s_bl, timer->gettick(), 500, 500, damage, -1, 0, 0), 0); return ATK_NONE; } } @@ -3052,9 +3052,9 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam if( bl->type == BL_MOB && !iStatus->isdead(bl) && src != bl) { if (damage > 0 ) - mob->skill_event((TBL_MOB*)bl,src,iTimer->gettick(),flag); + mob->skill_event((TBL_MOB*)bl,src,timer->gettick(),flag); if (skill_id) - mob->skill_event((TBL_MOB*)bl,src,iTimer->gettick(),MSC_SKILLUSED|(skill_id<<16)); + mob->skill_event((TBL_MOB*)bl,src,timer->gettick(),MSC_SKILLUSED|(skill_id<<16)); } if( sd ) { if( pc_ismadogear(sd) && rnd()%100 < 50 ) { @@ -5054,7 +5054,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,iTimer->gettick(),target,wd.amotion,sstatus->dmotion,rdamage,tstatus->race); + iMap->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; } @@ -5062,8 +5062,8 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list //Use Reflect Shield to signal this kind of skill trigger. [Skotlex] if( tsd && src != target ) battle->drain(tsd, src, rdamage, rdamage, sstatus->race, is_boss(src)); - battle->delay_damage(iTimer->gettick(), wd.amotion,target,src,0,CR_REFLECTSHIELD,0,rdamage,ATK_DEF,rdelay,true); - skill->additional_effect(target, src, CR_REFLECTSHIELD, 1, BF_WEAPON|BF_SHORT|BF_NORMAL,ATK_DEF,iTimer->gettick()); + battle->delay_damage(timer->gettick(), wd.amotion,target,src,0,CR_REFLECTSHIELD,0,rdamage,ATK_DEF,rdelay,true); + skill->additional_effect(target, src, CR_REFLECTSHIELD, 1, BF_WEAPON|BF_SHORT|BF_NORMAL,ATK_DEF,timer->gettick()); } } } @@ -5113,7 +5113,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list rnd()%100 < tsc->data[SC_SWORDREJECT]->val2 ) { ATK_RATER(50) - status_fix_damage(target,src,wd.damage,clif->damage(target,src,iTimer->gettick(),0,0,wd.damage,0,0,0)); + status_fix_damage(target,src,wd.damage,clif->damage(target,src,timer->gettick(),0,0,wd.damage,0,0,0)); clif->skill_nodamage(target,target,ST_REJECTSWORD,tsc->data[SC_SWORDREJECT]->val1,1); if( --(tsc->data[SC_SWORDREJECT]->val3) <= 0 ) status_change_end(target, SC_SWORDREJECT, INVALID_TIMER); @@ -5200,9 +5200,9 @@ int64 battle_calc_return_damage(struct block_list* bl, struct block_list *src, i 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, iTimer->gettick(), status_get_amotion(src), 0, rdamage, + 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, iTimer->gettick(), status_get_amotion(src)+1000, 0, rdamage/10, 1, 0, 0); + 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_change_end(bl, SC_CRESCENTELBOW, INVALID_TIMER); return 0; // Just put here to minimize redundancy @@ -5210,18 +5210,18 @@ int64 battle_calc_return_damage(struct block_list* bl, struct block_list *src, i if( flag & BF_SHORT) {//Bounces back part of the damage. if ( sd && sd->bonus.short_weapon_damage_return ){ NORMALIZE_RDAMAGE(damage * sd->bonus.short_weapon_damage_return / 100); - *delay = clif->damage(src, src, iTimer->gettick(), status_get_amotion(src), status_get_dmotion(src), rdamage, 1, 4, 0); + *delay = clif->damage(src, src, timer->gettick(), status_get_amotion(src), status_get_dmotion(src), rdamage, 1, 4, 0); } if( sc && sc->count ) { if( sc->data[SC_REFLECTSHIELD] && skill_id != WS_CARTTERMINATION ){ NORMALIZE_RDAMAGE(damage * sc->data[SC_REFLECTSHIELD]->val2 / 100); - *delay = clif->skill_damage(src, src, iTimer->gettick(), status_get_amotion(src), status_get_dmotion(src), rdamage, 1, CR_REFLECTSHIELD, 1, 4); + *delay = clif->skill_damage(src, src, timer->gettick(), status_get_amotion(src), status_get_dmotion(src), rdamage, 1, CR_REFLECTSHIELD, 1, 4); } if( sc->data[SC_LG_REFLECTDAMAGE] && rand()%100 < (30 + 10*sc->data[SC_LG_REFLECTDAMAGE]->val1) ) { if( skill_id != HT_LANDMINE && skill_id != HT_CLAYMORETRAP && skill_id != RA_CLUSTERBOMB && (skill_id <= RA_VERDURETRAP || skill_id > RA_ICEBOUNDTRAP) && skill_id != MA_LANDMINE ){ NORMALIZE_RDAMAGE((*dmg) * sc->data[SC_LG_REFLECTDAMAGE]->val2 / 100); - *delay = clif->damage(src, src, iTimer->gettick(), status_get_amotion(src), status_get_dmotion(src), rdamage, 1, 4, 0); + *delay = clif->damage(src, src, timer->gettick(), status_get_amotion(src), status_get_dmotion(src), rdamage, 1, 4, 0); } } if( sc->data[SC_DEATHBOUND] && skill_id != WS_CARTTERMINATION && !is_boss(src) ) { @@ -5231,22 +5231,22 @@ int64 battle_calc_return_damage(struct block_list* bl, struct block_list *src, i if( !iMap->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, iTimer->gettick(), status_get_amotion(src), 0, -3000, 1, RK_DEATHBOUND, sc->data[SC_DEATHBOUND]->val1, 6); + clif->skill_damage(src, bl, timer->gettick(), status_get_amotion(src), 0, -3000, 1, RK_DEATHBOUND, sc->data[SC_DEATHBOUND]->val1, 6); skill->blown(bl, src, skill->get_blewcount(RK_DEATHBOUND, sc->data[SC_DEATHBOUND]->val1), unit->getdir(src), 0); if( skill_id ) status_change_end(bl, SC_DEATHBOUND, INVALID_TIMER); - *delay = clif->damage(src, src, iTimer->gettick(), status_get_amotion(src), status_get_dmotion(src), rdamage, 1, 4, 0); + *delay = clif->damage(src, src, timer->gettick(), status_get_amotion(src), status_get_dmotion(src), rdamage, 1, 4, 0); } } if( sc->data[SC_SHIELDSPELL_DEF] && sc->data[SC_SHIELDSPELL_DEF]->val1 == 2 && !is_boss(src) ){ NORMALIZE_RDAMAGE(damage * sc->data[SC_SHIELDSPELL_DEF]->val2 / 100); - *delay = clif->damage(src, src, iTimer->gettick(), status_get_amotion(src), status_get_dmotion(src), rdamage, 1, 4, 0); + *delay = clif->damage(src, src, timer->gettick(), status_get_amotion(src), status_get_dmotion(src), rdamage, 1, 4, 0); } } } else { if (sd && sd->bonus.long_weapon_damage_return){ NORMALIZE_RDAMAGE(damage * sd->bonus.long_weapon_damage_return / 100); - *delay = clif->damage(src, src, iTimer->gettick(), status_get_amotion(src), status_get_dmotion(src), rdamage, 1, 4, 0); + *delay = clif->damage(src, src, timer->gettick(), status_get_amotion(src), status_get_dmotion(src), rdamage, 1, 4, 0); } } @@ -5503,7 +5503,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 = iTimer->add_timer(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), iStatus->kaahi_heal_timer, target->id, SC_KAAHI); //Activate heal. wd = battle->calc_attack(BF_WEAPON, src, target, 0, 0, flag); @@ -5563,7 +5563,7 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t (d_bl->type == BL_PC && ((TBL_PC*)d_bl)->devotion[sce->val2] == target->id) ) && check_distance_bl(target, d_bl, sce->val3) ) { - clif->damage(d_bl, d_bl, iTimer->gettick(), 0, 0, damage, 0, 0, 0); + clif->damage(d_bl, d_bl, timer->gettick(), 0, 0, damage, 0, 0, 0); status_fix_damage(NULL, d_bl, damage, 0); } else @@ -6774,11 +6774,11 @@ 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); - iTimer->add_timer_func_list(battle_delay_damage_sub, "battle_delay_damage_sub"); + timer->add_func_list(battle_delay_damage_sub, "battle_delay_damage_sub"); #ifndef STATS_OPT_OUT - iTimer->add_timer_func_list(Hercules_report_timer, "Hercules_report_timer"); - iTimer->add_timer_interval(iTimer->gettick()+30000, Hercules_report_timer, 0, 0, 60000 * 30); + timer->add_func_list(Hercules_report_timer, "Hercules_report_timer"); + timer->add_interval(timer->gettick()+30000, Hercules_report_timer, 0, 0, 60000 * 30); #endif } diff --git a/src/map/battleground.c b/src/map/battleground.c index e72683880..1bc142b7f 100644 --- a/src/map/battleground.c +++ b/src/map/battleground.c @@ -460,7 +460,7 @@ void bg_queue_ready_ack (struct bg_arena *arena, struct map_session_data *sd, bo } /* check if all are ready then cancell timer, and start game */ if( count == queue->items ) { - iTimer->delete_timer(arena->begin_timer,bg->begin_timer); + timer->delete(arena->begin_timer,bg->begin_timer); arena->begin_timer = INVALID_TIMER; bg->begin(arena); } @@ -556,7 +556,7 @@ void bg_queue_pregame(struct bg_arena *arena) { clif->bgqueue_battlebegins(sd,arena->id,SELF); } } - arena->begin_timer = iTimer->add_timer( iTimer->gettick() + (arena->pregame_duration*1000), bg->begin_timer, arena->id, 0 ); + arena->begin_timer = timer->add( timer->gettick() + (arena->pregame_duration*1000), bg->begin_timer, arena->id, 0 ); } int bg_fillup_timer(int tid, unsigned int tick, int id, intptr_t data) { bg->queue_pregame(bg->arena[id]); @@ -568,12 +568,12 @@ void bg_queue_check(struct bg_arena *arena) { int count = script->hq[arena->queue_id].items; if( count == arena->max_players ) { if( arena->fillup_timer != INVALID_TIMER ) { - iTimer->delete_timer(arena->fillup_timer,bg->fillup_timer); + timer->delete(arena->fillup_timer,bg->fillup_timer); arena->fillup_timer = INVALID_TIMER; } bg->queue_pregame(arena); } else if( count >= arena->min_players && arena->fillup_timer == INVALID_TIMER ) { - arena->fillup_timer = iTimer->add_timer( iTimer->gettick() + (arena->fillup_duration*1000), bg->fillup_timer, arena->id, 0 ); + arena->fillup_timer = timer->add( timer->gettick() + (arena->fillup_duration*1000), bg->fillup_timer, arena->id, 0 ); } } void bg_queue_add(struct map_session_data *sd, struct bg_arena *arena, enum bg_queue_types type) { @@ -764,8 +764,8 @@ enum BATTLEGROUNDS_QUEUE_ACK bg_canqueue(struct map_session_data *sd, struct bg_ } void do_init_battleground(void) { bg->team_db = idb_alloc(DB_OPT_RELEASE_DATA); - iTimer->add_timer_func_list(bg->send_xy_timer, "bg_send_xy_timer"); - iTimer->add_timer_interval(iTimer->gettick() + battle_config.bg_update_interval, bg->send_xy_timer, 0, 0, battle_config.bg_update_interval); + timer->add_func_list(bg->send_xy_timer, "bg_send_xy_timer"); + timer->add_interval(timer->gettick() + battle_config.bg_update_interval, bg->send_xy_timer, 0, 0, battle_config.bg_update_interval); bg->config_read(); } diff --git a/src/map/chrif.c b/src/map/chrif.c index 524286da1..dcca72cc8 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -186,7 +186,7 @@ static bool chrif_sd_to_auth(TBL_PC* sd, enum sd_state state) { node->sex = sd->status.sex; node->fd = sd->fd; node->sd = sd; //Data from logged on char. - node->node_created = iTimer->gettick(); //timestamp for node timeouts + node->node_created = timer->gettick(); //timestamp for node timeouts node->state = state; sd->state.active = 0; @@ -691,11 +691,11 @@ int auth_db_cleanup_sub(DBKey key, DBData *data, va_list ap) { struct auth_node *node = DB->data2ptr(data); const char* states[] = { "Login", "Logout", "Map change" }; - if(DIFF_TICK(iTimer->gettick(),node->node_created)>60000) { + if(DIFF_TICK(timer->gettick(),node->node_created)>60000) { switch (node->state) { case ST_LOGOUT: //Re-save attempt (->sd should never be null here). - node->node_created = iTimer->gettick(); //Refresh tick (avoid char-server load if connection is really bad) + node->node_created = timer->gettick(); //Refresh tick (avoid char-server load if connection is really bad) chrif->save(node->sd, 1); break; default: @@ -1170,10 +1170,10 @@ int chrif_save_scdata(struct map_session_data *sd) { //parses the sc_data of the unsigned int tick; struct status_change_data data; struct status_change *sc = &sd->sc; - const struct TimerData *timer; + const struct TimerData *td; chrif_check(-1); - tick = iTimer->gettick(); + tick = timer->gettick(); WFIFOHEAD(char_fd, 14 + SC_MAX*sizeof(struct status_change_data)); WFIFOW(char_fd,0) = 0x2b1c; @@ -1184,10 +1184,10 @@ int chrif_save_scdata(struct map_session_data *sd) { //parses the sc_data of the if (!sc->data[i]) continue; if (sc->data[i]->timer != INVALID_TIMER) { - timer = iTimer->get_timer(sc->data[i]->timer); - if (timer == NULL || timer->func != iStatus->change_timer || DIFF_TICK(timer->tick,tick) < 0) + td = timer->get(sc->data[i]->timer); + if (td == NULL || td->func != iStatus->change_timer || DIFF_TICK(td->tick,tick) < 0) continue; - data.tick = DIFF_TICK(timer->tick,tick); //Duration that is left before ending. + data.tick = DIFF_TICK(td->tick,tick); //Duration that is left before ending. } else data.tick = -1; //Infinite duration data.type = i; @@ -1342,7 +1342,7 @@ void chrif_on_disconnect(void) { iMap->eraseallipport(); //Attempt to reconnect in a second. [Skotlex] - iTimer->add_timer(iTimer->gettick() + 1000, check_connect_char_server, 0, 0); + timer->add(timer->gettick() + 1000, check_connect_char_server, 0, 0); } @@ -1643,17 +1643,17 @@ 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); - iTimer->add_timer_func_list(check_connect_char_server, "check_connect_char_server"); - iTimer->add_timer_func_list(auth_db_cleanup, "auth_db_cleanup"); + timer->add_func_list(check_connect_char_server, "check_connect_char_server"); + timer->add_func_list(auth_db_cleanup, "auth_db_cleanup"); // establish map-char connection if not present - iTimer->add_timer_interval(iTimer->gettick() + 1000, check_connect_char_server, 0, 0, 10 * 1000); + timer->add_interval(timer->gettick() + 1000, check_connect_char_server, 0, 0, 10 * 1000); // wipe stale data for timed-out client connection requests - iTimer->add_timer_interval(iTimer->gettick() + 1000, auth_db_cleanup, 0, 0, 30 * 1000); + timer->add_interval(timer->gettick() + 1000, auth_db_cleanup, 0, 0, 30 * 1000); // send the user count every 10 seconds, to hide the charserver's online counting problem - iTimer->add_timer_interval(iTimer->gettick() + 1000, send_usercount_tochar, 0, 0, UPDATE_INTERVAL); + timer->add_interval(timer->gettick() + 1000, send_usercount_tochar, 0, 0, UPDATE_INTERVAL); return 0; } diff --git a/src/map/clif.c b/src/map/clif.c index c61630bb5..74d827847 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -594,7 +594,7 @@ void clif_authok(struct map_session_data *sd) struct packet_authok p; p.PacketType = authokType; - p.startTime = iTimer->gettick(); + p.startTime = timer->gettick(); WBUFPOS(&p.PosDir[0],0,sd->bl.x,sd->bl.y,sd->ud.dir); /* do the stupid client math */ p.xSize = p.ySize = 5; /* not-used */ @@ -797,7 +797,7 @@ void clif_clearunit_delayed(struct block_list* bl, clr_type type, unsigned int t { struct block_list *tbl = ers_alloc(clif->delay_clearunit_ers, struct block_list); memcpy (tbl, bl, sizeof (struct block_list)); - iTimer->add_timer(tick, clif->clearunit_delayed_sub, (int)type, (intptr_t)tbl); + timer->add(tick, clif->clearunit_delayed_sub, (int)type, (intptr_t)tbl); } void clif_get_weapon_view(struct map_session_data* sd, unsigned short *rhand, unsigned short *lhand) @@ -1152,7 +1152,7 @@ void clif_set_unit_walking(struct block_list* bl, struct map_session_data *tsd, p.head = vd->hair_style; p.weapon = vd->weapon; p.accessory = vd->head_bottom; - p.moveStartTime = iTimer->gettick(); + p.moveStartTime = timer->gettick(); #if PACKETVER < 7 p.shield = vd->shield; #endif @@ -1530,7 +1530,7 @@ void clif_walkok(struct map_session_data *sd) WFIFOHEAD(fd, packet_len(0x87)); WFIFOW(fd,0)=0x87; - WFIFOL(fd,2)=iTimer->gettick(); + WFIFOL(fd,2)=timer->gettick(); WFIFOPOS2(fd,6,sd->bl.x,sd->bl.y,sd->ud.to_x,sd->ud.to_y,8,8); WFIFOSET(fd,packet_len(0x87)); } @@ -1601,7 +1601,7 @@ void clif_move(struct unit_data *ud) WBUFW(buf,0)=0x86; WBUFL(buf,2)=bl->id; WBUFPOS2(buf,6,bl->x,bl->y,ud->to_x,ud->to_y,8,8); - WBUFL(buf,12)=iTimer->gettick(); + WBUFL(buf,12)=timer->gettick(); clif->send(buf, packet_len(0x86), bl, AREA_WOS); if (disguised(bl)) { WBUFL(buf,2)=-bl->id; @@ -1627,14 +1627,14 @@ 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(iTimer->gettick(), sd->canlog_tick) > battle_config.prevent_logout) + DIFF_TICK(timer->gettick(), sd->canlog_tick) > battle_config.prevent_logout) iMap->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. session[sd->fd]->session_data = NULL; sd->fd = 0; - iTimer->add_timer(iTimer->gettick() + 10000, clif->delayquit, sd->bl.id, 0); + timer->add(timer->gettick() + 10000, clif->delayquit, sd->bl.id, 0); } } @@ -3730,7 +3730,7 @@ void clif_useitemack(struct map_session_data *sd,int index,int amount,bool ok) } void clif_hercules_chsys_send(struct hChSysCh *channel, struct map_session_data *sd, const char *msg) { - if( channel->msg_delay != 0 && DIFF_TICK(sd->hchsysch_tick + ( channel->msg_delay * 1000 ), iTimer->gettick()) > 0 && !pc->has_permission(sd, PC_PERM_HCHSYS_ADMIN) ) { + if( channel->msg_delay != 0 && DIFF_TICK(sd->hchsysch_tick + ( channel->msg_delay * 1000 ), timer->gettick()) > 0 && !pc->has_permission(sd, PC_PERM_HCHSYS_ADMIN) ) { clif->colormes(sd->fd,COLOR_RED,msg_txt(1455)); return; } else { @@ -3740,7 +3740,7 @@ void clif_hercules_chsys_send(struct hChSysCh *channel, struct map_session_data if( channel->type == hChSys_IRC ) ircbot->relay(sd->status.name,msg); if( channel->msg_delay != 0 ) - sd->hchsysch_tick = iTimer->gettick(); + sd->hchsysch_tick = timer->gettick(); } } @@ -9417,7 +9417,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { if(map[sd->bl.m].flag.pvp && !(sd->sc.option&OPTION_INVISIBLE)) { if(!battle_config.pk_mode) { // remove pvp stuff for pk_mode [Valaris] if (!map[sd->bl.m].flag.pvp_nocalcrank) - sd->pvp_timer = iTimer->add_timer(iTimer->gettick()+200, pc->calc_pvprank_timer, sd->bl.id, 0); + sd->pvp_timer = timer->add(timer->gettick()+200, pc->calc_pvprank_timer, sd->bl.id, 0); sd->pvp_rank = 0; sd->pvp_lastusers = 0; sd->pvp_point = 5; @@ -9465,7 +9465,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { if( battle_config.hom_setting&0x8 ) status_calc_bl(&sd->hd->bl, SCB_SPEED); //Homunc mimic their master's speed on each map change if( !(battle_config.hom_setting&0x2) ) - skill->unit_move(&sd->hd->bl,iTimer->gettick(),1); // apply land skills immediately + skill->unit_move(&sd->hd->bl,timer->gettick(),1); // apply land skills immediately } if( sd->md ) { @@ -9641,7 +9641,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { // Trigger skill effects if you appear standing on them if(!battle_config.pc_invincible_time) - skill->unit_move(&sd->bl,iTimer->gettick(),1); + skill->unit_move(&sd->bl,timer->gettick(),1); } @@ -9666,7 +9666,7 @@ void clif_parse_TickSend(int fd, struct map_session_data *sd) { sd->client_tick = RFIFOL(fd,packet_db[RFIFOW(fd,0)].pos[0]); - clif->notify_time(sd, iTimer->gettick()); + clif->notify_time(sd, timer->gettick()); } @@ -9746,7 +9746,7 @@ void clif_parse_progressbar(int fd, struct map_session_data * sd) { int npc_id = sd->progressbar.npc_id; - if( iTimer->gettick() < sd->progressbar.timeout && sd->st ) + if( timer->gettick() < sd->progressbar.timeout && sd->st ) sd->st->state = END; sd->state.workinprogress = sd->progressbar.npc_id = sd->progressbar.timeout = 0; @@ -9813,7 +9813,7 @@ void clif_parse_QuitGame(int fd, struct map_session_data *sd) { /* Rovert's prevent logout option fixed [Valaris] */ if( !sd->sc.data[SC_CLOAKING] && !sd->sc.data[SC_HIDING] && !sd->sc.data[SC_CHASEWALK] && !sd->sc.data[SC_CLOAKINGEXCEED] && - (!battle_config.prevent_logout || DIFF_TICK(iTimer->gettick(), sd->canlog_tick) > battle_config.prevent_logout) ) + (!battle_config.prevent_logout || DIFF_TICK(timer->gettick(), sd->canlog_tick) > battle_config.prevent_logout) ) { set_eof(fd); @@ -9896,9 +9896,9 @@ void clif_parse_GlobalMessage(int fd, struct map_session_data* sd) return; if( battle_config.min_chat_delay ) { //[Skotlex] - if (DIFF_TICK(sd->cantalk_tick, iTimer->gettick()) > 0) + if (DIFF_TICK(sd->cantalk_tick, timer->gettick()) > 0) return; - sd->cantalk_tick = iTimer->gettick() + battle_config.min_chat_delay; + sd->cantalk_tick = timer->gettick() + battle_config.min_chat_delay; } if( (sd->class_&MAPID_UPPERMASK) == MAPID_SUPER_NOVICE ) { @@ -9941,16 +9941,16 @@ void clif_parse_GlobalMessage(int fd, struct map_session_data* sd) unsigned char mylen = 1; if( sd->disguise == -1 ) { - sd->fontcolor_tid = iTimer->add_timer(iTimer->gettick()+5000, clif->undisguise_timer, sd->bl.id, 0); + sd->fontcolor_tid = timer->add(timer->gettick()+5000, clif->undisguise_timer, sd->bl.id, 0); pc->disguise(sd,sd->status.class_); if( pc_isdead(sd) ) clif_clearunit_single(-sd->bl.id, CLR_DEAD, sd->fd); if( unit->is_walking(&sd->bl) ) clif->move(&sd->ud); } else if ( sd->disguise == sd->status.class_ && sd->fontcolor_tid != INVALID_TIMER ) { - const struct TimerData *timer; - if( (timer = iTimer->get_timer(sd->fontcolor_tid)) ) { - iTimer->settick_timer(sd->fontcolor_tid, timer->tick+5000); + const struct TimerData *td; + if( (td = timer->get(sd->fontcolor_tid)) ) { + timer->settick(sd->fontcolor_tid, td->tick+5000); } } @@ -10337,7 +10337,7 @@ void clif_parse_ActionRequest(int fd, struct map_session_data *sd) clif->pActionRequest_sub(sd, RFIFOB(fd,packet_db[RFIFOW(fd,0)].pos[1]), RFIFOL(fd,packet_db[RFIFOW(fd,0)].pos[0]), - iTimer->gettick() + timer->gettick() ); } @@ -10355,7 +10355,7 @@ void clif_parse_Restart(int fd, struct map_session_data *sd) { case 0x01: /* Rovert's Prevent logout option - Fixed [Valaris] */ if( !sd->sc.data[SC_CLOAKING] && !sd->sc.data[SC_HIDING] && !sd->sc.data[SC_CHASEWALK] && !sd->sc.data[SC_CLOAKINGEXCEED] && - (!battle_config.prevent_logout || DIFF_TICK(iTimer->gettick(), sd->canlog_tick) > battle_config.prevent_logout) ) + (!battle_config.prevent_logout || DIFF_TICK(timer->gettick(), sd->canlog_tick) > battle_config.prevent_logout) ) { //Send to char-server for character selection. chrif->charselectreq(sd, session[fd]->client_addr); } else { @@ -10387,10 +10387,10 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd) return; if (battle_config.min_chat_delay) { //[Skotlex] - if (DIFF_TICK(sd->cantalk_tick, iTimer->gettick()) > 0) { + if (DIFF_TICK(sd->cantalk_tick, timer->gettick()) > 0) { return; } - sd->cantalk_tick = iTimer->gettick() + battle_config.min_chat_delay; + sd->cantalk_tick = timer->gettick() + battle_config.min_chat_delay; } // Chat logging type 'W' / Whisper @@ -10827,7 +10827,7 @@ void clif_parse_NpcClicked(int fd,struct map_session_data *sd) switch (bl->type) { case BL_MOB: case BL_PC: - clif->pActionRequest_sub(sd, 0x07, bl->id, iTimer->gettick()); + clif->pActionRequest_sub(sd, 0x07, bl->id, timer->gettick()); break; case BL_NPC: if( sd->ud.skill_id < RK_ENCHANTBLADE && sd->ud.skilltimer != INVALID_TIMER ) {// TODO: should only work with none 3rd job skills @@ -11326,7 +11326,7 @@ void clif_parse_UseSkillToId(int fd, struct map_session_data *sd) { uint16 skill_id, skill_lv; int tmp, target_id; - unsigned int tick = iTimer->gettick(); + unsigned int tick = timer->gettick(); skill_lv = RFIFOW(fd,packet_db[RFIFOW(fd,0)].pos[0]); skill_id = RFIFOW(fd,packet_db[RFIFOW(fd,0)].pos[1]); @@ -11426,7 +11426,7 @@ void clif_parse_UseSkillToId(int fd, struct map_session_data *sd) *------------------------------------------*/ void clif_parse_UseSkillToPosSub(int fd, struct map_session_data *sd, uint16 skill_lv, uint16 skill_id, short x, short y, int skillmoreinfo) { - unsigned int tick = iTimer->gettick(); + unsigned int tick = timer->gettick(); if( !(skill->get_inf(skill_id)&INF_GROUND_SKILL) ) return; //Using a target skill on the ground? WRONG. @@ -12200,9 +12200,9 @@ void clif_parse_PartyMessage(int fd, struct map_session_data* sd) if( battle_config.min_chat_delay ) { //[Skotlex] - if (DIFF_TICK(sd->cantalk_tick, iTimer->gettick()) > 0) + if (DIFF_TICK(sd->cantalk_tick, timer->gettick()) > 0) return; - sd->cantalk_tick = iTimer->gettick() + battle_config.min_chat_delay; + sd->cantalk_tick = timer->gettick() + battle_config.min_chat_delay; } party->send_message(sd, text, textlen); @@ -13041,9 +13041,9 @@ void clif_parse_GuildMessage(int fd, struct map_session_data* sd) if( battle_config.min_chat_delay ) { //[Skotlex] - if (DIFF_TICK(sd->cantalk_tick, iTimer->gettick()) > 0) + if (DIFF_TICK(sd->cantalk_tick, timer->gettick()) > 0) return; - sd->cantalk_tick = iTimer->gettick() + battle_config.min_chat_delay; + sd->cantalk_tick = timer->gettick() + battle_config.min_chat_delay; } if( sd->bg_id ) @@ -14834,7 +14834,7 @@ void clif_parse_Mail_send(int fd, struct map_session_data *sd) return; } - if( DIFF_TICK(sd->cansendmail_tick, iTimer->gettick()) > 0 ) { + if( DIFF_TICK(sd->cansendmail_tick, timer->gettick()) > 0 ) { clif->message(sd->fd,msg_txt(675)); //"Cannot send mails too fast!!." clif->mail_send(fd, true); // fail return; @@ -14872,7 +14872,7 @@ void clif_parse_Mail_send(int fd, struct map_session_data *sd) if( !intif->Mail_send(sd->status.account_id, &msg) ) mail->deliveryfail(sd, &msg); - sd->cansendmail_tick = iTimer->gettick() + 1000; // 1 Second flood Protection + sd->cansendmail_tick = timer->gettick() + 1000; // 1 Second flood Protection } @@ -15411,11 +15411,11 @@ void clif_bossmapinfo(int fd, struct mob_data *md, short flag) } else WFIFOB(fd,2) = 2; // First Time } else if (md->spawn_timer != INVALID_TIMER) { // Boss is Dead - const struct TimerData * timer_data = iTimer->get_timer(md->spawn_timer); + const struct TimerData * timer_data = timer->get(md->spawn_timer); unsigned int seconds; int hours, minutes; - seconds = DIFF_TICK(timer_data->tick, iTimer->gettick()) / 1000 + 60; + seconds = DIFF_TICK(timer_data->tick, timer->gettick()) / 1000 + 60; hours = seconds / (60 * 60); seconds = seconds - (60 * 60 * hours); minutes = seconds / 60; @@ -15961,9 +15961,9 @@ void clif_parse_BattleChat(int fd, struct map_session_data* sd) return; if( battle_config.min_chat_delay ) { - if( DIFF_TICK(sd->cantalk_tick, iTimer->gettick()) > 0 ) + if( DIFF_TICK(sd->cantalk_tick, timer->gettick()) > 0 ) return; - sd->cantalk_tick = iTimer->gettick() + battle_config.min_chat_delay; + sd->cantalk_tick = timer->gettick() + battle_config.min_chat_delay; } bg->send_message(sd, text, textlen); @@ -17397,11 +17397,11 @@ void clif_maptypeproperty2(struct block_list *bl,enum send_target t) { p.flag.guild = 1; p.flag.siege = map_flag_gvg2(bl->m) ? 1: 0; p.flag.mineffect = 1; - p.flag.nolockon = 0; + p.flag.nolockon = 1; p.flag.countpk = map[bl->m].flag.pvp ? 1 : 0; p.flag.nopartyformation = 0; - p.flag.noitemconsumption = 0; - p.flag.summonstarmiracle = 0; + p.flag.noitemconsumption = 1; + p.flag.summonstarmiracle = 1; p.flag.bg = map[bl->m].flag.battleground ? 1 : 0; clif->send(&p,sizeof(p),bl,t); @@ -17909,8 +17909,8 @@ int do_init_clif(void) { exit(EXIT_FAILURE); } - iTimer->add_timer_func_list(clif->clearunit_delayed_sub, "clif_clearunit_delayed_sub"); - iTimer->add_timer_func_list(clif->delayquit, "clif_delayquit"); + timer->add_func_list(clif->clearunit_delayed_sub, "clif_clearunit_delayed_sub"); + timer->add_func_list(clif->delayquit, "clif_delayquit"); clif->delay_clearunit_ers = ers_new(sizeof(struct block_list),"clif.c::delay_clearunit_ers",ERS_OPT_CLEAR); diff --git a/src/map/elemental.c b/src/map/elemental.c index 855d9e2c6..3a6ab2105 100644 --- a/src/map/elemental.c +++ b/src/map/elemental.c @@ -145,8 +145,8 @@ int elemental_get_lifetime(struct elemental_data *ed) { if( ed == NULL || ed->summon_timer == INVALID_TIMER ) return 0; - td = iTimer->get_timer(ed->summon_timer); - return (td != NULL) ? DIFF_TICK(td->tick, iTimer->gettick()) : 0; + td = timer->get(ed->summon_timer); + return (td != NULL) ? DIFF_TICK(td->tick, timer->gettick()) : 0; } int elemental_save(struct elemental_data *ed) { @@ -190,7 +190,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 ) - iTimer->delete_timer(ed->summon_timer, elemental_summon_end); + timer->delete(ed->summon_timer, elemental_summon_end); ed->summon_timer = INVALID_TIMER; } @@ -215,7 +215,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 = iTimer->add_timer(iTimer->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, ed->master->bl.id, 0); ed->regen.state.block = 0; } @@ -257,7 +257,7 @@ int elemental_data_received(struct s_elemental *ele, bool flag) { iMap->addiddb(&ed->bl); status_calc_elemental(ed,1); - ed->last_spdrain_time = ed->last_thinktime = iTimer->gettick(); + ed->last_spdrain_time = ed->last_thinktime = timer->gettick(); ed->summon_timer = INVALID_TIMER; elemental_summon_init(ed); } else { @@ -430,9 +430,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 = iTimer->add_timer( tick+iStatus->get_speed(&ed->bl)*walk_dist, skill->castend_pos, ed->bl.id, 0 ); + ed->ud.skilltimer = timer->add( tick+iStatus->get_speed(&ed->bl)*walk_dist, skill->castend_pos, ed->bl.id, 0 ); else - ed->ud.skilltimer = iTimer->add_timer( tick+iStatus->get_speed(&ed->bl)*walk_dist, skill->castend_id, ed->bl.id, 0 ); + ed->ud.skilltimer = timer->add( tick+iStatus->get_speed(&ed->bl)*walk_dist, skill->castend_id, ed->bl.id, 0 ); } return 1; @@ -490,11 +490,11 @@ int elemental_change_mode_ack(struct elemental_data *ed, int mode) { if( ed->ud.skilltimer != INVALID_TIMER ) return 0; - else if( DIFF_TICK(iTimer->gettick(), ed->ud.canact_tick) < 0 ) + else if( DIFF_TICK(timer->gettick(), ed->ud.canact_tick) < 0 ) return 0; ed->target_id = bl->id; // Set new target - ed->last_thinktime = iTimer->gettick(); + ed->last_thinktime = timer->gettick(); if( skill->get_inf(skill_id) & INF_GROUND_SKILL ) unit->skilluse_pos(&ed->bl, bl->x, bl->y, skill_id, skill_lv); @@ -931,8 +931,8 @@ int do_init_elemental(void) { read_elementaldb(); elemental->read_skilldb(); - iTimer->add_timer_func_list(elemental_ai_timer,"elemental_ai_timer"); - iTimer->add_timer_interval(iTimer->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; } diff --git a/src/map/guild.c b/src/map/guild.c index 6219fc770..b6dde5700 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -2235,10 +2235,10 @@ void do_init_guild(void) { 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] - iTimer->add_timer_func_list(guild_payexp_timer,"guild_payexp_timer"); - iTimer->add_timer_func_list(guild_send_xy_timer, "guild_send_xy_timer"); - iTimer->add_timer_interval(iTimer->gettick()+GUILD_PAYEXP_INVERVAL,guild_payexp_timer,0,0,GUILD_PAYEXP_INVERVAL); - iTimer->add_timer_interval(iTimer->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) { diff --git a/src/map/homunculus.c b/src/map/homunculus.c index 81971ebef..92b92106d 100644 --- a/src/map/homunculus.c +++ b/src/map/homunculus.c @@ -416,7 +416,7 @@ bool homunculus_evolve(struct homun_data *hd) { status_calc_homunculus(hd,1); if (!(battle_config.hom_setting&0x2)) - skill->unit_move(&sd->hd->bl,iTimer->gettick(),1); // apply land skills immediately + skill->unit_move(&sd->hd->bl,timer->gettick(),1); // apply land skills immediately return true; } @@ -463,7 +463,7 @@ bool homunculus_mutate(struct homun_data *hd, int homun_id) { status_calc_homunculus(hd,1); if (!(battle_config.hom_setting&0x2)) - skill->unit_move(&sd->hd->bl,iTimer->gettick(),1); // apply land skills immediately + skill->unit_move(&sd->hd->bl,timer->gettick(),1); // apply land skills immediately return true; } @@ -647,14 +647,14 @@ int homunculus_hunger_timer(int tid, unsigned int tick, int id, intptr_t data) { } clif->send_homdata(sd,SP_HUNGRY,hd->homunculus.hunger); - hd->hungry_timer = iTimer->add_timer(tick+hd->homunculusDB->hungryDelay,homun->hunger_timer,sd->bl.id,0); //simple Fix albator + hd->hungry_timer = timer->add(tick+hd->homunculusDB->hungryDelay,homun->hunger_timer,sd->bl.id,0); //simple Fix albator return 0; } void homunculus_hunger_timer_delete(struct homun_data *hd) { nullpo_retv(hd); if(hd->hungry_timer != INVALID_TIMER) { - iTimer->delete_timer(hd->hungry_timer,homun->hunger_timer); + timer->delete(hd->hungry_timer,homun->hunger_timer); hd->hungry_timer = INVALID_TIMER; } } @@ -765,7 +765,7 @@ bool homunculus_create(struct map_session_data *sd, struct s_homunculus *hom) { void homunculus_init_timers(struct homun_data * hd) { if (hd->hungry_timer == INVALID_TIMER) - hd->hungry_timer = iTimer->add_timer(iTimer->gettick()+hd->homunculusDB->hungryDelay,homun->hunger_timer,hd->master->bl.id,0); + hd->hungry_timer = timer->add(timer->gettick()+hd->homunculusDB->hungryDelay,homun->hunger_timer,hd->master->bl.id,0); hd->regen.state.block = 0; //Restore HP/SP block. } @@ -1235,7 +1235,7 @@ void do_init_homunculus(void) { homun->exp_db_read(); homun->skill_db_read(); // Add homunc timer function to timer func list [Toms] - iTimer->add_timer_func_list(homun->hunger_timer, "homunculus_hunger_timer"); + timer->add_func_list(homun->hunger_timer, "homunculus_hunger_timer"); //Stock view data for homuncs memset(&homun->viewdb, 0, sizeof(homun->viewdb)); diff --git a/src/map/instance.c b/src/map/instance.c index 98a0dfc8f..563c4326f 100644 --- a/src/map/instance.c +++ b/src/map/instance.c @@ -375,7 +375,7 @@ void instance_del_map(int16 m) { iMap->foreachinmap(instance_cleanup_sub, m, BL_ALL); if( map[m].mob_delete_timer != INVALID_TIMER ) - iTimer->delete_timer(map[m].mob_delete_timer, iMap->removemobs_timer); + timer->delete(map[m].mob_delete_timer, iMap->removemobs_timer); mapindex_removemap( map[m].index ); @@ -508,9 +508,9 @@ void instance_destroy(int instance_id) { db_destroy(instances[instance_id].vars); if( instances[instance_id].progress_timer != INVALID_TIMER ) - iTimer->delete_timer( instances[instance_id].progress_timer, instance_destroy_timer); + timer->delete( instances[instance_id].progress_timer, instance_destroy_timer); if( instances[instance_id].idle_timer != INVALID_TIMER ) - iTimer->delete_timer( instances[instance_id].idle_timer, instance_destroy_timer); + timer->delete( instances[instance_id].idle_timer, instance_destroy_timer); instances[instance_id].vars = NULL; @@ -536,13 +536,13 @@ void instance_check_idle(int instance_id) { idle = false; if( instances[instance_id].idle_timer != INVALID_TIMER && !idle ) { - iTimer->delete_timer(instances[instance_id].idle_timer, instance_destroy_timer); + timer->delete(instances[instance_id].idle_timer, instance_destroy_timer); instances[instance_id].idle_timer = INVALID_TIMER; instances[instance_id].idle_timeout = 0; clif->instance(instance_id, 3, 0); // Notify instance users normal instance expiration } else if( instances[instance_id].idle_timer == INVALID_TIMER && idle ) { instances[instance_id].idle_timeout = now + instances[instance_id].idle_timeoutval; - instances[instance_id].idle_timer = iTimer->add_timer( iTimer->gettick() + instances[instance_id].idle_timeoutval * 1000, instance_destroy_timer, instance_id, 0); + instances[instance_id].idle_timer = timer->add( timer->gettick() + instances[instance_id].idle_timeoutval * 1000, instance_destroy_timer, instance_id, 0); clif->instance(instance_id, 4, 0); // Notify instance users it will be destroyed of no user join it again in "X" time } } @@ -558,13 +558,13 @@ void instance_set_timeout(int instance_id, unsigned int progress_timeout, unsign return; if( instances[instance_id].progress_timer != INVALID_TIMER ) - iTimer->delete_timer( instances[instance_id].progress_timer, instance_destroy_timer); + timer->delete( instances[instance_id].progress_timer, instance_destroy_timer); if( instances[instance_id].idle_timer != INVALID_TIMER ) - iTimer->delete_timer( instances[instance_id].idle_timer, instance_destroy_timer); + timer->delete( instances[instance_id].idle_timer, instance_destroy_timer); if( progress_timeout ) { instances[instance_id].progress_timeout = now + progress_timeout; - instances[instance_id].progress_timer = iTimer->add_timer( iTimer->gettick() + progress_timeout * 1000, instance_destroy_timer, instance_id, 0); + instances[instance_id].progress_timer = timer->add( timer->gettick() + progress_timeout * 1000, instance_destroy_timer, instance_id, 0); } else { instances[instance_id].progress_timeout = 0; instances[instance_id].progress_timer = INVALID_TIMER; @@ -613,7 +613,7 @@ void do_final_instance(void) { } void do_init_instance(void) { - iTimer->add_timer_func_list(instance_destroy_timer, "instance_destroy_timer"); + timer->add_func_list(instance_destroy_timer, "instance_destroy_timer"); } void instance_defaults(void) { diff --git a/src/map/irc-bot.c b/src/map/irc-bot.c index b17015b66..5225672af 100644 --- a/src/map/irc-bot.c +++ b/src/map/irc-bot.c @@ -27,7 +27,7 @@ char send_string[IRC_MESSAGE_LENGTH]; /** * Timer callback to (re-)connect to an IRC server - * @see iTimer->do_timer + * @see timer->do_timer */ int irc_connect_timer(int tid, unsigned int tick, int id, intptr_t data) { struct hSockOpt opt; @@ -37,12 +37,12 @@ int irc_connect_timer(int tid, unsigned int tick, int id, intptr_t data) { opt.silent = 1; opt.setTimeo = 0; - ircbot->last_try = iTimer->gettick(); + ircbot->last_try = timer->gettick(); if( ( ircbot->fd = make_connection(ircbot->ip,hChSys.irc_server_port,&opt) ) > 0 ){ session[ircbot->fd]->func_parse = ircbot->parse; session[ircbot->fd]->flag.server = 1; - iTimer->add_timer(iTimer->gettick() + 3000, ircbot->identify_timer, 0, 0); + timer->add(timer->gettick() + 3000, ircbot->identify_timer, 0, 0); ircbot->isOn = true; } return 0; @@ -50,7 +50,7 @@ int irc_connect_timer(int tid, unsigned int tick, int id, intptr_t data) { /** * Timer callback to send identification commands to an IRC server - * @see iTimer->do_timer + * @see timer->do_timer */ int irc_identify_timer(int tid, unsigned int tick, int id, intptr_t data) { if( !ircbot->isOn ) @@ -61,14 +61,14 @@ int irc_identify_timer(int tid, unsigned int tick, int id, intptr_t data) { sprintf(send_string, "NICK %s", hChSys.irc_nick); ircbot->send(send_string); - iTimer->add_timer(iTimer->gettick() + 3000, ircbot->join_timer, 0, 0); + timer->add(timer->gettick() + 3000, ircbot->join_timer, 0, 0); return 0; } /** * Timer callback to join channels (and optionally send NickServ commands) - * @see iTimer->do_timer + * @see timer->do_timer */ int irc_join_timer(int tid, unsigned int tick, int id, intptr_t data) { if( !ircbot->isOn ) @@ -119,7 +119,7 @@ int irc_parse(int fd) { ircbot->isIn = false; ircbot->fails = 0; ircbot->ip = host2ip(hChSys.irc_server); - iTimer->add_timer(iTimer->gettick() + 120000, ircbot->connect_timer, 0, 0); + timer->add(timer->gettick() + 120000, ircbot->connect_timer, 0, 0); return 0; } @@ -427,8 +427,8 @@ void irc_bot_init(void) { ircbot->isIn = false; ircbot->isOn = false; - iTimer->add_timer_func_list(ircbot->connect_timer, "irc_connect_timer"); - iTimer->add_timer(iTimer->gettick() + 7000, ircbot->connect_timer, 0, 0); + timer->add_func_list(ircbot->connect_timer, "irc_connect_timer"); + timer->add(timer->gettick() + 7000, ircbot->connect_timer, 0, 0); } /** diff --git a/src/map/map.c b/src/map/map.c index d4568766a..aff696f06 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -1204,7 +1204,7 @@ void map_clearflooritem(struct block_list *bl) { struct flooritem_data* fitem = (struct flooritem_data*)bl; if( fitem->cleartimer ) - iTimer->delete_timer(fitem->cleartimer,iMap->clearflooritem_timer); + timer->delete(fitem->cleartimer,iMap->clearflooritem_timer); clif->clearflooritem(fitem, 0); iMap->deliddb(&fitem->bl); @@ -1359,7 +1359,7 @@ int map_addflooritem(struct item *item_data,int amount,int16 m,int16 x,int16 y,i } fitem->first_get_charid = first_charid; - fitem->first_get_tick = iTimer->gettick() + (flags&1 ? battle_config.mvp_item_first_get_time : battle_config.item_first_get_time); + fitem->first_get_tick = timer->gettick() + (flags&1 ? battle_config.mvp_item_first_get_time : battle_config.item_first_get_time); fitem->second_get_charid = second_charid; fitem->second_get_tick = fitem->first_get_tick + (flags&1 ? battle_config.mvp_item_second_get_time : battle_config.item_second_get_time); fitem->third_get_charid = third_charid; @@ -1369,7 +1369,7 @@ 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=iTimer->add_timer(iTimer->gettick()+battle_config.flooritem_lifetime,iMap->clearflooritem_timer,fitem->bl.id,0); + fitem->cleartimer=timer->add(timer->gettick()+battle_config.flooritem_lifetime,iMap->clearflooritem_timer,fitem->bl.id,0); iMap->addiddb(&fitem->bl); iMap->addblock(&fitem->bl); @@ -2096,7 +2096,7 @@ void map_spawnmobs(int16 m) int i, k=0; if (map[m].mob_delete_timer != INVALID_TIMER) { //Mobs have not been removed yet [Skotlex] - iTimer->delete_timer(map[m].mob_delete_timer, iMap->removemobs_timer); + timer->delete(map[m].mob_delete_timer, iMap->removemobs_timer); map[m].mob_delete_timer = INVALID_TIMER; return; } @@ -2170,7 +2170,7 @@ void map_removemobs(int16 m) if (map[m].mob_delete_timer != INVALID_TIMER) // should never happen return; //Mobs are already scheduled for removal - map[m].mob_delete_timer = iTimer->add_timer(iTimer->gettick()+battle_config.mob_remove_delay, iMap->removemobs_timer, m, 0); + map[m].mob_delete_timer = timer->add(timer->gettick()+battle_config.mob_remove_delay, iMap->removemobs_timer, m, 0); } /*========================================== @@ -2867,7 +2867,7 @@ void map_clean(int i) { if(battle_config.dynamic_mobs) { //Dynamic mobs flag by [random] int j; if(map[i].mob_delete_timer != INVALID_TIMER) - iTimer->delete_timer(map[i].mob_delete_timer, iMap->removemobs_timer); + timer->delete(map[i].mob_delete_timer, iMap->removemobs_timer); for (j=0; jdelete_timer(map[i].mob_delete_timer, iMap->removemobs_timer); + timer->delete(map[i].mob_delete_timer, iMap->removemobs_timer); for (j=0; jadd_timer_func_list(map_freeblock_timer, "map_freeblock_timer"); - iTimer->add_timer_func_list(map_clearflooritem_timer, "map_clearflooritem_timer"); - iTimer->add_timer_func_list(map_removemobs_timer, "map_removemobs_timer"); - iTimer->add_timer_interval(iTimer->gettick()+1000, map_freeblock_timer, 0, 0, 60*1000); + timer->add_func_list(map_freeblock_timer, "map_freeblock_timer"); + timer->add_func_list(map_clearflooritem_timer, "map_clearflooritem_timer"); + timer->add_func_list(map_removemobs_timer, "map_removemobs_timer"); + timer->add_interval(timer->gettick()+1000, map_freeblock_timer, 0, 0, 60*1000); HPM->load_sub = HPM_map_plugin_load_sub; HPM->symbol_defaults_sub = map_hp_symbols; diff --git a/src/map/mapreg_sql.c b/src/map/mapreg_sql.c index c0bfeb987..0a0b8f75f 100644 --- a/src/map/mapreg_sql.c +++ b/src/map/mapreg_sql.c @@ -295,8 +295,8 @@ void mapreg_init(void) { mapreg->load(); - iTimer->add_timer_func_list(mapreg->save_timer, "mapreg_script_autosave_mapreg"); - iTimer->add_timer_interval(iTimer->gettick() + MAPREG_AUTOSAVE_INTERVAL, mapreg->save_timer, 0, 0, MAPREG_AUTOSAVE_INTERVAL); + timer->add_func_list(mapreg->save_timer, "mapreg_script_autosave_mapreg"); + timer->add_interval(timer->gettick() + MAPREG_AUTOSAVE_INTERVAL, mapreg->save_timer, 0, 0, MAPREG_AUTOSAVE_INTERVAL); } bool mapreg_config_read(const char* w1, const char* w2) { diff --git a/src/map/mercenary.c b/src/map/mercenary.c index bf802c643..0e89d62a9 100644 --- a/src/map/mercenary.c +++ b/src/map/mercenary.c @@ -93,8 +93,8 @@ int mercenary_get_lifetime(struct mercenary_data *md) if( md == NULL || md->contract_timer == INVALID_TIMER ) return 0; - td = iTimer->get_timer(md->contract_timer); - return (td != NULL) ? DIFF_TICK(td->tick, iTimer->gettick()) : 0; + td = timer->get(md->contract_timer); + return (td != NULL) ? DIFF_TICK(td->tick, timer->gettick()) : 0; } int mercenary_get_guild(struct mercenary_data *md) @@ -269,14 +269,14 @@ void merc_contract_stop(struct mercenary_data *md) { nullpo_retv(md); if( md->contract_timer != INVALID_TIMER ) - iTimer->delete_timer(md->contract_timer, merc_contract_end); + timer->delete(md->contract_timer, merc_contract_end); md->contract_timer = INVALID_TIMER; } void merc_contract_init(struct mercenary_data *md) { if( md->contract_timer == INVALID_TIMER ) - md->contract_timer = iTimer->add_timer(iTimer->gettick() + md->mercenary.life_time, merc_contract_end, md->master->bl.id, 0); + md->contract_timer = timer->add(timer->gettick() + md->mercenary.life_time, merc_contract_end, md->master->bl.id, 0); md->regen.state.block = 0; } diff --git a/src/map/mob.c b/src/map/mob.c index 146f82239..4506ca242 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -341,7 +341,7 @@ bool mob_ksprotected (struct block_list *src, struct block_list *target) *t_sd; // Mob Target struct status_change_entry *sce; struct mob_data *md; - unsigned int tick = iTimer->gettick(); + unsigned int tick = timer->gettick(); char output[128]; if( !battle_config.ksprotection ) @@ -491,7 +491,7 @@ int mob_once_spawn(struct map_session_data* sd, int16 m, int16 x, int16 y, const memcpy(md->guardian_data->guild_name, g->name, NAME_LENGTH); } else if (gc->guild_id) //Guild not yet available, retry in 5. - iTimer->add_timer(iTimer->gettick()+5000,mob->spawn_guardian_sub,md->bl.id,md->guardian_data->guild_id); + timer->add(timer->gettick()+5000,mob->spawn_guardian_sub,md->bl.id,md->guardian_data->guild_id); } } // end addition [Valaris] @@ -709,7 +709,7 @@ int mob_spawn_guardian(const char* mapname, short x, short y, const char* mobnam memcpy (md->guardian_data->guild_name, g->name, NAME_LENGTH); md->guardian_data->guardup_lv = guild->checkskill(g,GD_GUARDUP); } else if (md->guardian_data->guild_id) - iTimer->add_timer(iTimer->gettick()+5000,mob->spawn_guardian_sub,md->bl.id,md->guardian_data->guild_id); + timer->add(timer->gettick()+5000,mob->spawn_guardian_sub,md->bl.id,md->guardian_data->guild_id); mob->spawn(md); return md->bl.id; @@ -873,8 +873,8 @@ int mob_setdelayspawn(struct mob_data *md) spawntime = 5000; if( md->spawn_timer != INVALID_TIMER ) - iTimer->delete_timer(md->spawn_timer, mob->delayspawn); - md->spawn_timer = iTimer->add_timer(iTimer->gettick()+spawntime, mob->delayspawn, md->bl.id, 0); + timer->delete(md->spawn_timer, mob->delayspawn); + md->spawn_timer = timer->add(timer->gettick()+spawntime, mob->delayspawn, md->bl.id, 0); return 0; } @@ -895,7 +895,7 @@ int mob_count_sub(struct block_list *bl, va_list ap) { int mob_spawn (struct mob_data *md) { int i=0; - unsigned int tick = iTimer->gettick(); + unsigned int tick = timer->gettick(); int c =0; md->last_thinktime = tick; @@ -918,16 +918,16 @@ int mob_spawn (struct mob_data *md) 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->spawn_timer != INVALID_TIMER ) - iTimer->delete_timer(md->spawn_timer, mob->delayspawn); - md->spawn_timer = iTimer->add_timer(tick+5000,mob->delayspawn,md->bl.id,0); + 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) if( md->spawn_timer != INVALID_TIMER ) - iTimer->delete_timer(md->spawn_timer, mob->delayspawn); - md->spawn_timer = iTimer->add_timer(tick+5000,mob->delayspawn,md->bl.id,0); + timer->delete(md->spawn_timer, mob->delayspawn); + md->spawn_timer = timer->add(tick+5000,mob->delayspawn,md->bl.id,0); return 1; } } @@ -941,7 +941,7 @@ int mob_spawn (struct mob_data *md) md->ud.target_to = 0; if( md->spawn_timer != INVALID_TIMER ) { - iTimer->delete_timer(md->spawn_timer, mob->delayspawn); + timer->delete(md->spawn_timer, mob->delayspawn); md->spawn_timer = INVALID_TIMER; } @@ -2049,7 +2049,7 @@ void mob_damage(struct mob_data *md, struct block_list *src, int damage) { //Log damage if (src) mob->log_damage(md, src, damage); - md->dmgtick = iTimer->gettick(); + md->dmgtick = timer->gettick(); } if (battle_config.show_mob_info&3) @@ -2073,7 +2073,7 @@ void mob_damage(struct mob_data *md, struct block_list *src, int damage) { if( md->special_state.ai == 2 ) {//LOne WOlf explained that ANYONE can trigger the marine countdown skill. [Skotlex] md->state.alchemist = 1; - mob->skill_use(md, iTimer->gettick(), MSC_ALCHEMIST); + mob->skill_use(md, timer->gettick(), MSC_ALCHEMIST); } } @@ -2094,7 +2094,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) } pt[DAMAGELOG_SIZE]; int i, temp, count, m = md->bl.m, pnum = 0; int dmgbltypes = 0; // bitfield of all bl types, that caused damage to the mob and are elligible for exp distribution - unsigned int mvp_damage, tick = iTimer->gettick(); + unsigned int mvp_damage, tick = timer->gettick(); bool rebirth, homkillonly; status = &md->status; @@ -2441,7 +2441,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) mob->item_drop(md, dlist, mob->setlootitem(&md->lootitem[i]), 1, 10000, homkillonly); } if (dlist->item) //There are drop items. - iTimer->add_timer(tick + (!battle_config.delay_battle_damage?500:0), mob->delay_item_drop, 0, (intptr_t)dlist); + timer->add(tick + (!battle_config.delay_battle_damage?500:0), mob->delay_item_drop, 0, (intptr_t)dlist); else //No drops ers_free(item_drop_list_ers, dlist); } else if (md->lootitem && md->lootitem_count) { //Loot MUST drop! @@ -2455,7 +2455,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) dlist->item = NULL; for(i = 0; i < md->lootitem_count; i++) mob->item_drop(md, dlist, mob->setlootitem(&md->lootitem[i]), 1, 10000, homkillonly); - iTimer->add_timer(tick + (!battle_config.delay_battle_damage?500:0), mob->delay_item_drop, 0, (intptr_t)dlist); + timer->add(tick + (!battle_config.delay_battle_damage?500:0), mob->delay_item_drop, 0, (intptr_t)dlist); } if(mvp_sd && md->db->mexp > 0 && !md->special_state.ai) { @@ -2594,7 +2594,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) } if(md->deletetimer != INVALID_TIMER) { - iTimer->delete_timer(md->deletetimer,mob->timer_delete); + timer->delete(md->deletetimer,mob->timer_delete); md->deletetimer = INVALID_TIMER; } /** @@ -2636,7 +2636,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) void mob_revive(struct mob_data *md, unsigned int hp) { - unsigned int tick = iTimer->gettick(); + unsigned int tick = timer->gettick(); md->state.skillstate = MSS_IDLE; md->last_thinktime = tick; md->next_walktime = tick+rnd()%50+5000; @@ -2721,7 +2721,7 @@ int mob_random_class (int *value, size_t count) *------------------------------------------*/ int mob_class_change (struct mob_data *md, int class_) { - unsigned int tick = iTimer->gettick(); + unsigned int tick = timer->gettick(); int i, c, hp_rate; nullpo_ret(md); @@ -3520,8 +3520,8 @@ int mob_clone_spawn(struct map_session_data *sd, int16 m, int16 x, int16 y, cons if (duration) //Auto Delete after a while. { if( md->deletetimer != INVALID_TIMER ) - iTimer->delete_timer(md->deletetimer, mob->timer_delete); - md->deletetimer = iTimer->add_timer (iTimer->gettick() + duration, mob->timer_delete, md->bl.id, 0); + timer->delete(md->deletetimer, mob->timer_delete); + md->deletetimer = timer->add (timer->gettick() + duration, mob->timer_delete, md->bl.id, 0); } } @@ -4655,15 +4655,15 @@ int do_init_mob(void) mob->load(); - iTimer->add_timer_func_list(mob->delayspawn,"mob_delayspawn"); - iTimer->add_timer_func_list(mob->delay_item_drop,"mob_delay_item_drop"); - iTimer->add_timer_func_list(mob->ai_hard,"mob_ai_hard"); - iTimer->add_timer_func_list(mob->ai_lazy,"mob_ai_lazy"); - iTimer->add_timer_func_list(mob->timer_delete,"mob_timer_delete"); - iTimer->add_timer_func_list(mob->spawn_guardian_sub,"mob_spawn_guardian_sub"); - iTimer->add_timer_func_list(mob->respawn,"mob_respawn"); - iTimer->add_timer_interval(iTimer->gettick()+MIN_MOBTHINKTIME,mob->ai_hard,0,0,MIN_MOBTHINKTIME); - iTimer->add_timer_interval(iTimer->gettick()+MIN_MOBTHINKTIME*10,mob->ai_lazy,0,0,MIN_MOBTHINKTIME*10); + timer->add_func_list(mob->delayspawn,"mob_delayspawn"); + timer->add_func_list(mob->delay_item_drop,"mob_delay_item_drop"); + timer->add_func_list(mob->ai_hard,"mob_ai_hard"); + timer->add_func_list(mob->ai_lazy,"mob_ai_lazy"); + timer->add_func_list(mob->timer_delete,"mob_timer_delete"); + timer->add_func_list(mob->spawn_guardian_sub,"mob_spawn_guardian_sub"); + timer->add_func_list(mob->respawn,"mob_respawn"); + timer->add_interval(timer->gettick()+MIN_MOBTHINKTIME,mob->ai_hard,0,0,MIN_MOBTHINKTIME); + timer->add_interval(timer->gettick()+MIN_MOBTHINKTIME*10,mob->ai_lazy,0,0,MIN_MOBTHINKTIME*10); return 0; } diff --git a/src/map/npc.c b/src/map/npc.c index 51d01d711..2439969a9 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -251,7 +251,7 @@ int npc_rr_secure_timeout_timer(int tid, unsigned int tick, int id, intptr_t dat clif->scriptclear(sd,sd->npc_id); sd->npc_idle_timer = INVALID_TIMER; } else //Create a new instance of ourselves to continue - sd->npc_idle_timer = iTimer->add_timer(iTimer->gettick() + (SECURE_NPCTIMEOUT_INTERVAL*1000),npc->secure_timeout_timer,sd->bl.id,0); + sd->npc_idle_timer = timer->add(timer->gettick() + (SECURE_NPCTIMEOUT_INTERVAL*1000),npc->secure_timeout_timer,sd->bl.id,0); return 0; } #endif @@ -451,7 +451,7 @@ void npc_event_do_oninit(void) { ShowStatus("Event '"CL_WHITE"OnInit"CL_RESET"' executed with '"CL_WHITE"%d"CL_RESET"' NPCs."CL_CLL"\n", npc->event_doall("OnInit")); - iTimer->add_timer_interval(iTimer->gettick()+100,npc->event_do_clock,0,0,1000); + timer->add_interval(timer->gettick()+100,npc->event_do_clock,0,0,1000); } /*========================================== @@ -537,9 +537,9 @@ int npc_timerevent(int tid, unsigned int tick, int id, intptr_t data) next = nd->u.scr.timer_event[ ted->next ].timer - nd->u.scr.timer_event[ ted->next - 1 ].timer; ted->time += next; if( sd ) - sd->npc_timer_id = iTimer->add_timer(tick+next,npc->timerevent,id,(intptr_t)ted); + sd->npc_timer_id = timer->add(tick+next,npc->timerevent,id,(intptr_t)ted); else - nd->u.scr.timerid = iTimer->add_timer(tick+next,npc->timerevent,id,(intptr_t)ted); + nd->u.scr.timerid = timer->add(tick+next,npc->timerevent,id,(intptr_t)ted); } else { @@ -569,7 +569,7 @@ int npc_timerevent(int tid, unsigned int tick, int id, intptr_t data) int npc_timerevent_start(struct npc_data* nd, int rid) { int j; - unsigned int tick = iTimer->gettick(); + unsigned int tick = timer->gettick(); struct map_session_data *sd = NULL; //Player to whom script is attached. nullpo_ret(nd); @@ -600,13 +600,13 @@ int npc_timerevent_start(struct npc_data* nd, int rid) if( sd ) { ted->rid = sd->bl.id; // Attach only the player if attachplayerrid was used. - sd->npc_timer_id = iTimer->add_timer(tick+next,npc->timerevent,nd->bl.id,(intptr_t)ted); + sd->npc_timer_id = timer->add(tick+next,npc->timerevent,nd->bl.id,(intptr_t)ted); } else { ted->rid = 0; nd->u.scr.timertick = tick; // Set when timer is started - nd->u.scr.timerid = iTimer->add_timer(tick+next,npc->timerevent,nd->bl.id,(intptr_t)ted); + nd->u.scr.timerid = timer->add(tick+next,npc->timerevent,nd->bl.id,(intptr_t)ted); } } else if (!sd) { @@ -639,16 +639,16 @@ int npc_timerevent_stop(struct npc_data* nd) // Delete timer if ( *tid != INVALID_TIMER ) { - td = iTimer->get_timer(*tid); + td = timer->get(*tid); if( td && td->data ) ers_free(npc->timer_event_ers, (void*)td->data); - iTimer->delete_timer(*tid,npc->timerevent); + timer->delete(*tid,npc->timerevent); *tid = INVALID_TIMER; } if( !sd && nd->u.scr.timertick ) { - nd->u.scr.timer += DIFF_TICK(iTimer->gettick(),nd->u.scr.timertick); // Set 'timer' to the time that has passed since the beginning of the timers + nd->u.scr.timer += DIFF_TICK(timer->gettick(),nd->u.scr.timertick); // Set 'timer' to the time that has passed since the beginning of the timers nd->u.scr.timertick = 0; // Set 'tick' to zero so that we know it's off. } @@ -666,7 +666,7 @@ void npc_timerevent_quit(struct map_session_data* sd) // Check timer existance if( sd->npc_timer_id == INVALID_TIMER ) return; - if( !(td = iTimer->get_timer(sd->npc_timer_id)) ) + if( !(td = timer->get(sd->npc_timer_id)) ) { sd->npc_timer_id = INVALID_TIMER; return; @@ -675,7 +675,7 @@ void npc_timerevent_quit(struct map_session_data* sd) // Delete timer nd = (struct npc_data *)iMap->id2bl(td->id); ted = (struct timer_event_data*)td->data; - iTimer->delete_timer(sd->npc_timer_id, npc->timerevent); + timer->delete(sd->npc_timer_id, npc->timerevent); sd->npc_timer_id = INVALID_TIMER; // Execute OnTimerQuit @@ -702,7 +702,7 @@ void npc_timerevent_quit(struct map_session_data* sd) old_timer = nd->u.scr.timer; nd->u.scr.rid = sd->bl.id; - nd->u.scr.timertick = iTimer->gettick(); + nd->u.scr.timertick = timer->gettick(); nd->u.scr.timer = ted->time; //Execute label @@ -730,7 +730,7 @@ int npc_gettimerevent_tick(struct npc_data* nd) tick = nd->u.scr.timer; // The last time it's active(start, stop or event trigger) if( nd->u.scr.timertick ) // It's a running timer - tick += DIFF_TICK(iTimer->gettick(), nd->u.scr.timertick); + tick += DIFF_TICK(timer->gettick(), nd->u.scr.timertick); return tick; } @@ -1212,13 +1212,13 @@ int npc_scriptcont(struct map_session_data* sd, int id, bool closing) /** * Update the last NPC iteration **/ - sd->npc_idle_tick = iTimer->gettick(); + sd->npc_idle_tick = timer->gettick(); #endif /** * WPE can get to this point with a progressbar; we deny it. **/ - if( sd->progressbar.npc_id && DIFF_TICK(sd->progressbar.timeout,iTimer->gettick()) > 0 ) + if( sd->progressbar.npc_id && DIFF_TICK(sd->progressbar.timeout,timer->gettick()) > 0 ) return 1; if( closing && sd->st->state == CLOSE ) @@ -1824,14 +1824,14 @@ int npc_unload(struct npc_data* nd, bool single) { for( bl = (struct block_list*)mapit->first(iter); mapit->exists(iter); bl = (struct block_list*)mapit->next(iter) ) { struct map_session_data *sd = ((TBL_PC*)bl); if( sd && sd->npc_timer_id != INVALID_TIMER ) { - const struct TimerData *td = iTimer->get_timer(sd->npc_timer_id); + const struct TimerData *td = timer->get(sd->npc_timer_id); if( td && td->id != nd->bl.id ) continue; if( td && td->data ) ers_free(npc->timer_event_ers, (void*)td->data); - iTimer->delete_timer(sd->npc_timer_id, npc->timerevent); + timer->delete(sd->npc_timer_id, npc->timerevent); sd->npc_timer_id = INVALID_TIMER; } } @@ -1839,10 +1839,10 @@ int npc_unload(struct npc_data* nd, bool single) { if (nd->u.scr.timerid != INVALID_TIMER) { const struct TimerData *td; - td = iTimer->get_timer(nd->u.scr.timerid); + td = timer->get(nd->u.scr.timerid); if (td && td->data) ers_free(npc->timer_event_ers, (void*)td->data); - iTimer->delete_timer(nd->u.scr.timerid, npc->timerevent); + timer->delete(nd->u.scr.timerid, npc->timerevent); } if (nd->u.scr.timer_event) aFree(nd->u.scr.timer_event); @@ -2768,7 +2768,7 @@ void npc_movenpc(struct npc_data* nd, int16 x, int16 y) y = cap_value(y, 0, map[m].ys-1); iMap->foreachinrange(clif->outsight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl); - iMap->moveblock(&nd->bl, x, y, iTimer->gettick()); + iMap->moveblock(&nd->bl, x, y, timer->gettick()); iMap->foreachinrange(clif->insight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl); } @@ -3785,7 +3785,7 @@ int npc_reload(void) { } if( map[m].mob_delete_timer != INVALID_TIMER ) { // Mobs were removed anyway,so delete the timer [Inkfish] - iTimer->delete_timer(map[m].mob_delete_timer, iMap->removemobs_timer); + timer->delete(map[m].mob_delete_timer, iMap->removemobs_timer); map[m].mob_delete_timer = INVALID_TIMER; } } @@ -3937,7 +3937,7 @@ int do_init_npc(void) npc->base_ud.attacktimer = INVALID_TIMER; npc->base_ud.attackabletime = npc->base_ud.canact_tick = - npc->base_ud.canmove_tick = iTimer->gettick(); + npc->base_ud.canmove_tick = timer->gettick(); //Stock view data for normal npcs. memset(&npc_viewdb, 0, sizeof(npc_viewdb)); @@ -3988,8 +3988,8 @@ int do_init_npc(void) if (battle_config.warp_point_debug) npc->debug_warps(); - iTimer->add_timer_func_list(npc->event_do_clock,"npc_event_do_clock"); - iTimer->add_timer_func_list(npc->timerevent,"npc_timerevent"); + timer->add_func_list(npc->event_do_clock,"npc_event_do_clock"); + timer->add_func_list(npc->timerevent,"npc_timerevent"); // Init dummy NPC npc->fake_nd = (struct npc_data *)aCalloc(1,sizeof(struct npc_data)); diff --git a/src/map/party.c b/src/map/party.c index 629bf9227..88d6cc0bf 100644 --- a/src/map/party.c +++ b/src/map/party.c @@ -123,8 +123,8 @@ void do_init_party(void) { party_db = idb_alloc(DB_OPT_RELEASE_DATA); party_booking_db = idb_alloc(DB_OPT_RELEASE_DATA); // Party Booking [Spiria] - iTimer->add_timer_func_list(party_send_xy_timer, "party_send_xy_timer"); - iTimer->add_timer_interval(iTimer->gettick()+battle_config.party_update_interval, party_send_xy_timer, 0, 0, battle_config.party_update_interval); + timer->add_func_list(party_send_xy_timer, "party_send_xy_timer"); + timer->add_interval(timer->gettick()+battle_config.party_update_interval, party_send_xy_timer, 0, 0, battle_config.party_update_interval); } /// Party data lookup using party id. diff --git a/src/map/pc.c b/src/map/pc.c index b8380a840..949a66d8c 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -179,8 +179,8 @@ void pc_setinvincibletimer(struct map_session_data* sd, int val) { val += map[sd->bl.m].invincible_time_inc; if( sd->invincible_timer != INVALID_TIMER ) - iTimer->delete_timer(sd->invincible_timer,pc_invincible_timer); - sd->invincible_timer = iTimer->add_timer(iTimer->gettick()+val,pc_invincible_timer,sd->bl.id,0); + timer->delete(sd->invincible_timer,pc_invincible_timer); + sd->invincible_timer = timer->add(timer->gettick()+val,pc_invincible_timer,sd->bl.id,0); } void pc_delinvincibletimer(struct map_session_data* sd) @@ -189,9 +189,9 @@ void pc_delinvincibletimer(struct map_session_data* sd) if( sd->invincible_timer != INVALID_TIMER ) { - iTimer->delete_timer(sd->invincible_timer,pc_invincible_timer); + timer->delete(sd->invincible_timer,pc_invincible_timer); sd->invincible_timer = INVALID_TIMER; - skill->unit_move(&sd->bl,iTimer->gettick(),1); + skill->unit_move(&sd->bl,timer->gettick(),1); } } @@ -240,15 +240,15 @@ int pc_addspiritball(struct map_session_data *sd,int interval,int max) if( sd->spiritball && sd->spiritball >= max ) { if(sd->spirit_timer[0] != INVALID_TIMER) - iTimer->delete_timer(sd->spirit_timer[0],pc_spiritball_timer); + timer->delete(sd->spirit_timer[0],pc_spiritball_timer); sd->spiritball--; if( sd->spiritball != 0 ) memmove(sd->spirit_timer+0, sd->spirit_timer+1, (sd->spiritball)*sizeof(int)); sd->spirit_timer[sd->spiritball] = INVALID_TIMER; } - tid = iTimer->add_timer(iTimer->gettick()+interval, pc_spiritball_timer, sd->bl.id, 0); - ARR_FIND(0, sd->spiritball, i, sd->spirit_timer[i] == INVALID_TIMER || DIFF_TICK(iTimer->get_timer(tid)->tick, iTimer->get_timer(sd->spirit_timer[i])->tick) < 0); + tid = timer->add(timer->gettick()+interval, pc_spiritball_timer, sd->bl.id, 0); + ARR_FIND(0, sd->spiritball, i, sd->spirit_timer[i] == INVALID_TIMER || DIFF_TICK(timer->get(tid)->tick, timer->get(sd->spirit_timer[i])->tick) < 0); if( i != sd->spiritball ) memmove(sd->spirit_timer+i+1, sd->spirit_timer+i, (sd->spiritball-i)*sizeof(int)); sd->spirit_timer[i] = tid; @@ -282,7 +282,7 @@ int pc_delspiritball(struct map_session_data *sd,int count,int type) for(i=0;ispirit_timer[i] != INVALID_TIMER) { - iTimer->delete_timer(sd->spirit_timer[i],pc_spiritball_timer); + timer->delete(sd->spirit_timer[i],pc_spiritball_timer); sd->spirit_timer[i] = INVALID_TIMER; } } @@ -488,7 +488,7 @@ int pc_inventory_rental_clear(struct map_session_data *sd) { if( sd->rental_timer != INVALID_TIMER ) { - iTimer->delete_timer(sd->rental_timer, pc_inventory_rental_end); + timer->delete(sd->rental_timer, pc_inventory_rental_end); sd->rental_timer = INVALID_TIMER; } @@ -523,7 +523,7 @@ void pc_inventory_rentals(struct map_session_data *sd) } if( c > 0 ) // min(next_tick,3600000) 1 hour each timer to keep announcing to the owner, and to avoid a but with rental time > 15 days - sd->rental_timer = iTimer->add_timer(iTimer->gettick() + min(next_tick,3600000), pc_inventory_rental_end, sd->bl.id, 0); + sd->rental_timer = timer->add(timer->gettick() + min(next_tick,3600000), pc_inventory_rental_end, sd->bl.id, 0); else sd->rental_timer = INVALID_TIMER; } @@ -538,15 +538,15 @@ void pc_inventory_rental_add(struct map_session_data *sd, int seconds) if( sd->rental_timer != INVALID_TIMER ) { const struct TimerData * td; - td = iTimer->get_timer(sd->rental_timer); - if( DIFF_TICK(td->tick, iTimer->gettick()) > tick ) + td = timer->get(sd->rental_timer); + if( DIFF_TICK(td->tick, timer->gettick()) > tick ) { // Update Timer as this one ends first than the current one pc->inventory_rental_clear(sd); - sd->rental_timer = iTimer->add_timer(iTimer->gettick() + tick, pc_inventory_rental_end, sd->bl.id, 0); + sd->rental_timer = timer->add(timer->gettick() + tick, pc_inventory_rental_end, sd->bl.id, 0); } } else - sd->rental_timer = iTimer->add_timer(iTimer->gettick() + min(tick,3600000), pc_inventory_rental_end, sd->bl.id, 0); + sd->rental_timer = timer->add(timer->gettick() + min(tick,3600000), pc_inventory_rental_end, sd->bl.id, 0); } /** @@ -637,7 +637,7 @@ int pc_setnewpc(struct map_session_data *sd, int account_id, int char_id, int lo sd->client_tick = client_tick; sd->state.active = 0; //to be set to 1 after player is fully authed and loaded. sd->bl.type = BL_PC; - sd->canlog_tick = iTimer->gettick(); + sd->canlog_tick = timer->gettick(); //Required to prevent homunculus copuing a base speed of 0. sd->battle_status.speed = sd->base_status.speed = DEFAULT_WALK_SPEED; return 0; @@ -978,7 +978,7 @@ int pc_isequip(struct map_session_data *sd,int n) *------------------------------------------*/ bool pc_authok(struct map_session_data *sd, int login_id2, time_t expiration_time, int group_id, struct mmo_charstatus *st, bool changing_mapservers) { int i; - unsigned long tick = iTimer->gettick(); + unsigned long tick = timer->gettick(); uint32 ip = session[sd->fd]->client_addr; sd->login_id2 = login_id2; @@ -1327,7 +1327,7 @@ int pc_reg_received(struct map_session_data *sd) map[sd->bl.m].users_pvp--; if( map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.pvp_nocalcrank && sd->pvp_timer != INVALID_TIMER ) {// unregister the player for ranking - iTimer->delete_timer( sd->pvp_timer, pc->calc_pvprank_timer ); + timer->delete( sd->pvp_timer, pc->calc_pvprank_timer ); sd->pvp_timer = INVALID_TIMER; } clif->changeoption(&sd->bl); @@ -1991,7 +1991,7 @@ int pc_delautobonus(struct map_session_data* sd, struct s_autobonus *autobonus,c } else { // Logout / Unequipped an item with an activated bonus - iTimer->delete_timer(autobonus[i].active,pc->endautobonus); + timer->delete(autobonus[i].active,pc->endautobonus); autobonus[i].active = INVALID_TIMER; } } @@ -2019,7 +2019,7 @@ int pc_exeautobonus(struct map_session_data *sd,struct s_autobonus *autobonus) script->run_autobonus(autobonus->other_script,sd->bl.id,sd->equip_index[j]); } - autobonus->active = iTimer->add_timer(iTimer->gettick()+autobonus->duration, pc->endautobonus, sd->bl.id, (intptr_t)autobonus); + autobonus->active = timer->add(timer->gettick()+autobonus->duration, pc->endautobonus, sd->bl.id, (intptr_t)autobonus); sd->state.autobonus |= autobonus->pos; status_calc_pc(sd,0); @@ -4090,7 +4090,7 @@ int pc_dropitem(struct map_session_data *sd,int n,int amount) int pc_takeitem(struct map_session_data *sd,struct flooritem_data *fitem) { int flag=0; - unsigned int tick = iTimer->gettick(); + unsigned int tick = timer->gettick(); struct map_session_data *first_sd = NULL,*second_sd = NULL,*third_sd = NULL; struct party_data *p=NULL; @@ -4344,7 +4344,7 @@ int pc_isUseitem(struct map_session_data *sd,int n) * 1 = success *------------------------------------------*/ int pc_useitem(struct map_session_data *sd,int n) { - unsigned int tick = iTimer->gettick(); + unsigned int tick = timer->gettick(); int amount, nameid, i; struct script_code *item_script; @@ -4892,8 +4892,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) - iTimer->delete_timer(sce->timer, iStatus->change_timer); - sce->timer = iTimer->add_timer(iTimer->gettick() + skill->get_time(SG_KNOWLEDGE, sce->val1), iStatus->change_timer, sd->bl.id, SC_KNOWLEDGE); + 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); } status_change_end(&sd->bl, SC_PROPERTYWALK, INVALID_TIMER); status_change_end(&sd->bl, SC_CLOAKING, INVALID_TIMER); @@ -5736,7 +5736,7 @@ int pc_follow_timer(int tid, unsigned int tick, int id, intptr_t data) } else pc->setpos(sd, map_id2index(tbl->m), tbl->x, tbl->y, CLR_TELEPORT); } - sd->followtimer = iTimer->add_timer( + sd->followtimer = timer->add( tick + 1000, // increase time a bit to loosen up map's load pc_follow_timer, sd->bl.id, 0); return 0; @@ -5747,7 +5747,7 @@ int pc_stop_following (struct map_session_data *sd) nullpo_ret(sd); if (sd->followtimer != INVALID_TIMER) { - iTimer->delete_timer(sd->followtimer,pc_follow_timer); + timer->delete(sd->followtimer,pc_follow_timer); sd->followtimer = INVALID_TIMER; } sd->followtarget = -1; @@ -5767,7 +5767,7 @@ int pc_follow(struct map_session_data *sd,int target_id) pc->stop_following(sd); sd->followtarget = target_id; - pc_follow_timer(INVALID_TIMER, iTimer->gettick(), sd->bl.id, 0); + pc_follow_timer(INVALID_TIMER, timer->gettick(), sd->bl.id, 0); return 0; } @@ -6705,7 +6705,7 @@ void pc_damage(struct map_session_data *sd,struct block_list *src,unsigned int h if( sd->status.ele_id > 0 ) elemental->set_target(sd,src); - sd->canlog_tick = iTimer->gettick(); + sd->canlog_tick = timer->gettick(); } /*========================================== @@ -6713,7 +6713,7 @@ void pc_damage(struct map_session_data *sd,struct block_list *src,unsigned int h *------------------------------------------*/ int pc_dead(struct map_session_data *sd,struct block_list *src) { int i=0,j=0,k=0; - unsigned int tick = iTimer->gettick(); + unsigned int tick = timer->gettick(); for(k = 0; k < 5; k++) if (sd->devotion[k]){ @@ -6910,7 +6910,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) { pc->setinvincibletimer(sd, battle_config.pc_invincible_time); sc_start(&sd->bl,iStatus->skill2sc(MO_STEELBODY),100,1,skill->get_time(MO_STEELBODY,1)); if(map_flag_gvg2(sd->bl.m)) - pc_respawn_timer(INVALID_TIMER, iTimer->gettick(), sd->bl.id, 0); + pc_respawn_timer(INVALID_TIMER, timer->gettick(), sd->bl.id, 0); return 0; } } @@ -7027,18 +7027,18 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) { } if( sd->pvp_point < 0 ) { - iTimer->add_timer(tick+1, pc_respawn_timer,sd->bl.id,0); + timer->add(tick+1, pc_respawn_timer,sd->bl.id,0); return 1|8; } } //GvG if( map_flag_gvg2(sd->bl.m) ) { - iTimer->add_timer(tick+1, pc_respawn_timer, sd->bl.id, 0); + timer->add(tick+1, pc_respawn_timer, sd->bl.id, 0); return 1|8; } else if( sd->bg_id ) { struct battleground_data *bgd = bg->team_search(sd->bg_id); if( bgd && bgd->mapindex > 0 ) { // Respawn by BG - iTimer->add_timer(tick+1000, pc_respawn_timer, sd->bl.id, 0); + timer->add(tick+1000, pc_respawn_timer, sd->bl.id, 0); return 1|8; } } @@ -7046,7 +7046,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) { //Reset "can log out" tick. if( battle_config.prevent_logout ) - sd->canlog_tick = iTimer->gettick() - battle_config.prevent_logout; + sd->canlog_tick = timer->gettick() - battle_config.prevent_logout; return 1; } @@ -8352,7 +8352,7 @@ int pc_addeventtimer(struct map_session_data *sd,int tick,const char *name) if( i == MAX_EVENTTIMER ) return 0; - sd->eventtimer[i] = iTimer->add_timer(iTimer->gettick()+tick, pc_eventtimer, sd->bl.id, (intptr_t)aStrdup(name)); + sd->eventtimer[i] = timer->add(timer->gettick()+tick, pc_eventtimer, sd->bl.id, (intptr_t)aStrdup(name)); sd->eventcount++; return 1; @@ -8374,13 +8374,13 @@ int pc_deleventtimer(struct map_session_data *sd,const char *name) // find the named event timer ARR_FIND( 0, MAX_EVENTTIMER, i, sd->eventtimer[i] != INVALID_TIMER && - (p = (char *)(iTimer->get_timer(sd->eventtimer[i])->data)) != NULL && + (p = (char *)(timer->get(sd->eventtimer[i])->data)) != NULL && strcmp(p, name) == 0 ); if( i == MAX_EVENTTIMER ) return 0; // not found - iTimer->delete_timer(sd->eventtimer[i],pc_eventtimer); + timer->delete(sd->eventtimer[i],pc_eventtimer); sd->eventtimer[i] = INVALID_TIMER; sd->eventcount--; aFree(p); @@ -8399,8 +8399,8 @@ int pc_addeventtimercount(struct map_session_data *sd,const char *name,int tick) for(i=0;ieventtimer[i] != INVALID_TIMER && strcmp( - (char *)(iTimer->get_timer(sd->eventtimer[i])->data), name)==0 ){ - iTimer->addtick_timer(sd->eventtimer[i],tick); + (char *)(timer->get(sd->eventtimer[i])->data), name)==0 ){ + timer->addtick(sd->eventtimer[i],tick); break; } @@ -8421,8 +8421,8 @@ int pc_cleareventtimer(struct map_session_data *sd) for(i=0;ieventtimer[i] != INVALID_TIMER ){ - char *p = (char *)(iTimer->get_timer(sd->eventtimer[i])->data); - iTimer->delete_timer(sd->eventtimer[i],pc_eventtimer); + char *p = (char *)(timer->get(sd->eventtimer[i])->data); + timer->delete(sd->eventtimer[i],pc_eventtimer); sd->eventtimer[i] = INVALID_TIMER; sd->eventcount--; if (p) aFree(p); @@ -8599,7 +8599,7 @@ int pc_equipitem(struct map_session_data *sd,int n,int req_pos) return 0; } - if( DIFF_TICK(sd->canequip_tick,iTimer->gettick()) > 0 ) + if( DIFF_TICK(sd->canequip_tick,timer->gettick()) > 0 ) { clif->equipitemack(sd,n,0,0); return 0; @@ -9096,7 +9096,7 @@ int pc_calc_pvprank_timer(int tid, unsigned int tick, int id, intptr_t data) } if( pc->calc_pvprank(sd) > 0 ) - sd->pvp_timer = iTimer->add_timer(iTimer->gettick()+PVP_CALCRANK_INTERVAL,pc->calc_pvprank_timer,id,data); + sd->pvp_timer = timer->add(timer->gettick()+PVP_CALCRANK_INTERVAL,pc->calc_pvprank_timer,id,data); return 0; } @@ -9337,7 +9337,7 @@ int pc_autosave(int tid, unsigned int tick, int id, intptr_t data) interval = iMap->autosave_interval/(iMap->usercount()+1); if(interval < iMap->minsave_interval) interval = iMap->minsave_interval; - iTimer->add_timer(iTimer->gettick()+interval,pc_autosave,0,0); + timer->add(timer->gettick()+interval,pc_autosave,0,0); return 0; } @@ -9497,15 +9497,15 @@ int pc_add_charm(struct map_session_data *sd,int interval,int max,int type) if( sd->charm[type] && sd->charm[type] >= max ) { if(sd->charm_timer[type][0] != INVALID_TIMER) - iTimer->delete_timer(sd->charm_timer[type][0],pc_charm_timer); + timer->delete(sd->charm_timer[type][0],pc_charm_timer); sd->charm[type]--; if( sd->charm[type] != 0 ) memmove(sd->charm_timer[type]+0, sd->charm_timer[type]+1, (sd->charm[type])*sizeof(int)); sd->charm_timer[type][sd->charm[type]] = INVALID_TIMER; } - tid = iTimer->add_timer(iTimer->gettick()+interval, pc_charm_timer, sd->bl.id, 0); - ARR_FIND(0, sd->charm[type], i, sd->charm_timer[type][i] == INVALID_TIMER || DIFF_TICK(iTimer->get_timer(tid)->tick, iTimer->get_timer(sd->charm_timer[type][i])->tick) < 0); + tid = timer->add(timer->gettick()+interval, pc_charm_timer, sd->bl.id, 0); + ARR_FIND(0, sd->charm[type], i, sd->charm_timer[type][i] == INVALID_TIMER || DIFF_TICK(timer->get(tid)->tick, timer->get(sd->charm_timer[type][i])->tick) < 0); if( i != sd->charm[type] ) memmove(sd->charm_timer[type]+i+1, sd->charm_timer[type]+i, (sd->charm[type]-i)*sizeof(int)); sd->charm_timer[type][i] = tid; @@ -9536,7 +9536,7 @@ int pc_del_charm(struct map_session_data *sd,int count,int type) for(i = 0; i < count; i++) { if(sd->charm_timer[type][i] != INVALID_TIMER) { - iTimer->delete_timer(sd->charm_timer[type][i],pc_charm_timer); + timer->delete(sd->charm_timer[type][i],pc_charm_timer); sd->charm_timer[type][i] = INVALID_TIMER; } } @@ -10143,7 +10143,7 @@ void pc_itemcd_do(struct map_session_data *sd, bool load) { return; } for(i = 0; i < MAX_ITEMDELAYS; i++) { - if( cd->nameid[i] && DIFF_TICK(iTimer->gettick(),cd->tick[i]) < 0 ) { + if( cd->nameid[i] && DIFF_TICK(timer->gettick(),cd->tick[i]) < 0 ) { sd->item_delay[cursor].tick = cd->tick[i]; sd->item_delay[cursor].nameid = cd->nameid[i]; cursor++; @@ -10157,7 +10157,7 @@ void pc_itemcd_do(struct map_session_data *sd, bool load) { idb_put( itemcd_db, sd->status.char_id, cd ); } for(i = 0; i < MAX_ITEMDELAYS; i++) { - if( sd->item_delay[i].nameid && DIFF_TICK(iTimer->gettick(),sd->item_delay[i].tick) < 0 ) { + if( sd->item_delay[i].nameid && DIFF_TICK(timer->gettick(),sd->item_delay[i].tick) < 0 ) { cd->tick[cursor] = sd->item_delay[i].tick; cd->nameid[cursor] = sd->item_delay[i].nameid; cursor++; @@ -10186,17 +10186,17 @@ int do_init_pc(void) { pc->readdb(); - iTimer->add_timer_func_list(pc_invincible_timer, "pc_invincible_timer"); - iTimer->add_timer_func_list(pc_eventtimer, "pc_eventtimer"); - iTimer->add_timer_func_list(pc_inventory_rental_end, "pc_inventory_rental_end"); - iTimer->add_timer_func_list(pc->calc_pvprank_timer, "pc->calc_pvprank_timer"); - iTimer->add_timer_func_list(pc_autosave, "pc_autosave"); - iTimer->add_timer_func_list(pc_spiritball_timer, "pc_spiritball_timer"); - iTimer->add_timer_func_list(pc_follow_timer, "pc_follow_timer"); - iTimer->add_timer_func_list(pc->endautobonus, "pc->endautobonus"); - iTimer->add_timer_func_list(pc_charm_timer, "pc_charm_timer"); + timer->add_func_list(pc_invincible_timer, "pc_invincible_timer"); + timer->add_func_list(pc_eventtimer, "pc_eventtimer"); + timer->add_func_list(pc_inventory_rental_end, "pc_inventory_rental_end"); + timer->add_func_list(pc->calc_pvprank_timer, "pc->calc_pvprank_timer"); + timer->add_func_list(pc_autosave, "pc_autosave"); + timer->add_func_list(pc_spiritball_timer, "pc_spiritball_timer"); + timer->add_func_list(pc_follow_timer, "pc_follow_timer"); + timer->add_func_list(pc->endautobonus, "pc->endautobonus"); + timer->add_func_list(pc_charm_timer, "pc_charm_timer"); - iTimer->add_timer(iTimer->gettick() + iMap->autosave_interval, pc_autosave, 0, 0); + timer->add(timer->gettick() + iMap->autosave_interval, pc_autosave, 0, 0); // 0=day, 1=night [Yor] iMap->night_flag = battle_config.night_at_start ? 1 : 0; @@ -10205,11 +10205,11 @@ int do_init_pc(void) { int day_duration = battle_config.day_duration; int night_duration = battle_config.night_duration; // add night/day timer [Yor] - iTimer->add_timer_func_list(pc->map_day_timer, "pc->map_day_timer"); - iTimer->add_timer_func_list(pc->map_night_timer, "pc->map_night_timer"); + 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 = iTimer->add_timer_interval(iTimer->gettick() + (iMap->night_flag ? 0 : day_duration) + night_duration, pc->map_day_timer, 0, 0, day_duration + night_duration); - pc->night_timer_tid = iTimer->add_timer_interval(iTimer->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() + (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); } do_init_pc_groups(); diff --git a/src/map/pet.c b/src/map/pet.c index 8498517ef..b4714cc06 100644 --- a/src/map/pet.c +++ b/src/map/pet.c @@ -102,7 +102,7 @@ int pet_attackskill(struct pet_data *pd, int target_id) (battle_config.pet_equip_required && !pd->pet.equip)) return 0; - if (DIFF_TICK(pd->ud.canact_tick, iTimer->gettick()) > 0) + 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)) @@ -183,7 +183,7 @@ int pet_sc_check(struct map_session_data *sd, int type) || pd->recovery->type != type ) return 1; - pd->recovery->timer = iTimer->add_timer(iTimer->gettick()+pd->recovery->delay*1000,pet->recovery_timer,sd->bl.id,0); + pd->recovery->timer = timer->add(timer->gettick()+pd->recovery->delay*1000,pet->recovery_timer,sd->bl.id,0); return 0; } @@ -233,7 +233,7 @@ int pet_hungry(int tid, unsigned int tick, int id, intptr_t data) interval = pd->petDB->hungry_delay; if(interval <= 0) interval = 1; - pd->pet_hungry_timer = iTimer->add_timer(tick+interval,pet->hungry,sd->bl.id,0); + pd->pet_hungry_timer = timer->add(tick+interval,pet->hungry,sd->bl.id,0); return 0; } @@ -263,7 +263,7 @@ int pet_hungry_timer_delete(struct pet_data *pd) { nullpo_ret(pd); if(pd->pet_hungry_timer != INVALID_TIMER) { - iTimer->delete_timer(pd->pet_hungry_timer,pet->hungry); + timer->delete(pd->pet_hungry_timer,pet->hungry); pd->pet_hungry_timer = INVALID_TIMER; } @@ -365,7 +365,7 @@ int pet_data_init(struct map_session_data *sd, struct s_pet *petinfo) iMap->addiddb(&pd->bl); status_calc_pet(pd,1); - pd->last_thinktime = iTimer->gettick(); + pd->last_thinktime = timer->gettick(); pd->state.skillbonus = 0; if( battle_config.pet_status_support ) script->run(pet->db[i].pet_script,0,sd->bl.id,0); @@ -378,7 +378,7 @@ int pet_data_init(struct map_session_data *sd, struct s_pet *petinfo) interval = pd->petDB->hungry_delay; if( interval <= 0 ) interval = 1; - pd->pet_hungry_timer = iTimer->add_timer(iTimer->gettick() + interval, pet->hungry, sd->bl.id, 0); + pd->pet_hungry_timer = timer->add(timer->gettick() + interval, pet->hungry, sd->bl.id, 0); return 0; } @@ -672,16 +672,16 @@ int pet_equipitem(struct map_session_data *sd,int index) clif->send_petdata(NULL, sd->pd, 3, sd->pd->vd.head_bottom); if (battle_config.pet_equip_required) { //Skotlex: start support timers if need - unsigned int tick = iTimer->gettick(); + unsigned int tick = timer->gettick(); if (pd->s_skill && pd->s_skill->timer == INVALID_TIMER) { if (pd->s_skill->id) - pd->s_skill->timer=iTimer->add_timer(tick+pd->s_skill->delay*1000, pet->skill_support_timer, sd->bl.id, 0); + pd->s_skill->timer=timer->add(tick+pd->s_skill->delay*1000, pet->skill_support_timer, sd->bl.id, 0); else - pd->s_skill->timer=iTimer->add_timer(tick+pd->s_skill->delay*1000, pet->heal_timer, sd->bl.id, 0); + pd->s_skill->timer=timer->add(tick+pd->s_skill->delay*1000, pet->heal_timer, sd->bl.id, 0); } if (pd->bonus && pd->bonus->timer == INVALID_TIMER) - pd->bonus->timer=iTimer->add_timer(tick+pd->bonus->delay*1000, pet->skill_bonus_timer, sd->bl.id, 0); + pd->bonus->timer=timer->add(tick+pd->bonus->delay*1000, pet->skill_bonus_timer, sd->bl.id, 0); } return 0; @@ -716,14 +716,14 @@ int pet_unequipitem(struct map_session_data *sd, struct pet_data *pd) if( pd->s_skill && pd->s_skill->timer != INVALID_TIMER ) { if( pd->s_skill->id ) - iTimer->delete_timer(pd->s_skill->timer, pet->skill_support_timer); + timer->delete(pd->s_skill->timer, pet->skill_support_timer); else - iTimer->delete_timer(pd->s_skill->timer, pet->heal_timer); + timer->delete(pd->s_skill->timer, pet->heal_timer); pd->s_skill->timer = INVALID_TIMER; } if( pd->bonus && pd->bonus->timer != INVALID_TIMER ) { - iTimer->delete_timer(pd->bonus->timer, pet->skill_bonus_timer); + timer->delete(pd->bonus->timer, pet->skill_bonus_timer); pd->bonus->timer = INVALID_TIMER; } } @@ -1032,10 +1032,10 @@ int pet_lootitem_drop(struct pet_data *pd,struct map_session_data *sd) memset(pd->loot->item,0,pd->loot->max * sizeof(struct item)); pd->loot->count = 0; pd->loot->weight = 0; - pd->ud.canact_tick = iTimer->gettick()+10000; //prevent picked up during 10*1000ms + pd->ud.canact_tick = timer->gettick()+10000; //prevent picked up during 10*1000ms if (dlist->item) - iTimer->add_timer(iTimer->gettick()+540,pet->delay_item_drop,0,(intptr_t)dlist); + timer->add(timer->gettick()+540,pet->delay_item_drop,0,(intptr_t)dlist); else ers_free(pet->item_drop_list_ers, dlist); return 1; @@ -1049,7 +1049,7 @@ int pet_skill_bonus_timer(int tid, unsigned int tick, int id, intptr_t data) struct map_session_data *sd=iMap->id2sd(id); struct pet_data *pd; int bonus; - int timer = 0; + int next = 0; if(sd == NULL || sd->pd==NULL || sd->pd->bonus == NULL) return 1; @@ -1065,10 +1065,10 @@ int pet_skill_bonus_timer(int tid, unsigned int tick, int id, intptr_t data) // determine the time for the next timer if (pd->state.skillbonus && pd->bonus->delay > 0) { bonus = 0; - timer = pd->bonus->delay*1000; // the duration until pet bonuses will be reactivated again + next = pd->bonus->delay*1000; // the duration until pet bonuses will be reactivated again } else if (pd->pet.intimate) { bonus = 1; - timer = pd->bonus->duration*1000; // the duration for pet bonuses to be in effect + next = pd->bonus->duration*1000; // the duration for pet bonuses to be in effect } else { //Lost pet... pd->bonus->timer = INVALID_TIMER; return 0; @@ -1079,7 +1079,7 @@ int pet_skill_bonus_timer(int tid, unsigned int tick, int id, intptr_t data) status_calc_pc(sd, 0); } // wait for the next timer - pd->bonus->timer=iTimer->add_timer(tick+timer,pet->skill_bonus_timer,sd->bl.id,0); + pd->bonus->timer=timer->add(tick+next,pet->skill_bonus_timer,sd->bl.id,0); return 0; } @@ -1138,14 +1138,14 @@ int pet_heal_timer(int tid, unsigned int tick, int id, intptr_t data) (rate = get_percentage(status->hp, status->max_hp)) > pd->s_skill->hp || (rate = (pd->ud.skilltimer != INVALID_TIMER)) //Another skill is in effect ) { //Wait (how long? 1 sec for every 10% of remaining) - pd->s_skill->timer=iTimer->add_timer(iTimer->gettick()+(rate>10?rate:10)*100,pet->heal_timer,sd->bl.id,0); + pd->s_skill->timer=timer->add(timer->gettick()+(rate>10?rate:10)*100,pet->heal_timer,sd->bl.id,0); return 0; } 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); - pd->s_skill->timer=iTimer->add_timer(tick+pd->s_skill->delay*1000,pet->heal_timer,sd->bl.id,0); + pd->s_skill->timer=timer->add(tick+pd->s_skill->delay*1000,pet->heal_timer,sd->bl.id,0); return 0; } @@ -1172,7 +1172,7 @@ int pet_skill_support_timer(int tid, unsigned int tick, int id, intptr_t data) if (DIFF_TICK(pd->ud.canact_tick, tick) > 0) { //Wait until the pet can act again. - pd->s_skill->timer=iTimer->add_timer(pd->ud.canact_tick,pet->skill_support_timer,sd->bl.id,0); + pd->s_skill->timer=timer->add(pd->ud.canact_tick,pet->skill_support_timer,sd->bl.id,0); return 0; } @@ -1181,13 +1181,13 @@ int pet_skill_support_timer(int tid, unsigned int tick, int id, intptr_t data) (rate = get_percentage(status->hp, status->max_hp)) > pd->s_skill->hp || (rate = (pd->ud.skilltimer != INVALID_TIMER)) //Another skill is in effect ) { //Wait (how long? 1 sec for every 10% of remaining) - pd->s_skill->timer=iTimer->add_timer(tick+(rate>10?rate:10)*100,pet->skill_support_timer,sd->bl.id,0); + pd->s_skill->timer=timer->add(tick+(rate>10?rate:10)*100,pet->skill_support_timer,sd->bl.id,0); return 0; } pet_stop_attack(pd); pet_stop_walking(pd,1); - pd->s_skill->timer=iTimer->add_timer(tick+pd->s_skill->delay*1000,pet->skill_support_timer,sd->bl.id,0); + pd->s_skill->timer=timer->add(tick+pd->s_skill->delay*1000,pet->skill_support_timer,sd->bl.id,0); if (skill->get_inf(pd->s_skill->id) & INF_GROUND_SKILL) unit->skilluse_pos(&pd->bl, sd->bl.x, sd->bl.y, pd->s_skill->id, pd->s_skill->lv); else @@ -1355,14 +1355,14 @@ int do_init_pet(void) pet->item_drop_ers = ers_new(sizeof(struct item_drop),"pet.c::item_drop_ers",ERS_OPT_NONE); pet->item_drop_list_ers = ers_new(sizeof(struct item_drop_list),"pet.c::item_drop_list_ers",ERS_OPT_NONE); - iTimer->add_timer_func_list(pet->hungry,"pet_hungry"); - iTimer->add_timer_func_list(pet->ai_hard,"pet_ai_hard"); - iTimer->add_timer_func_list(pet->skill_bonus_timer,"pet_skill_bonus_timer"); // [Valaris] - iTimer->add_timer_func_list(pet->delay_item_drop,"pet_delay_item_drop"); - iTimer->add_timer_func_list(pet->skill_support_timer, "pet_skill_support_timer"); // [Skotlex] - iTimer->add_timer_func_list(pet->recovery_timer,"pet_recovery_timer"); // [Valaris] - iTimer->add_timer_func_list(pet->heal_timer,"pet_heal_timer"); // [Valaris] - iTimer->add_timer_interval(iTimer->gettick()+MIN_PETTHINKTIME,pet->ai_hard,0,0,MIN_PETTHINKTIME); + timer->add_func_list(pet->hungry,"pet_hungry"); + timer->add_func_list(pet->ai_hard,"pet_ai_hard"); + timer->add_func_list(pet->skill_bonus_timer,"pet_skill_bonus_timer"); // [Valaris] + timer->add_func_list(pet->delay_item_drop,"pet_delay_item_drop"); + timer->add_func_list(pet->skill_support_timer, "pet_skill_support_timer"); // [Skotlex] + timer->add_func_list(pet->recovery_timer,"pet_recovery_timer"); // [Valaris] + timer->add_func_list(pet->heal_timer,"pet_heal_timer"); // [Valaris] + timer->add_interval(timer->gettick()+MIN_PETTHINKTIME,pet->ai_hard,0,0,MIN_PETTHINKTIME); return 0; } diff --git a/src/map/script.c b/src/map/script.c index 7ac638848..bba74e669 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -2822,7 +2822,7 @@ void script_free_state(struct script_state* st) { } if( st->sleep.timer != INVALID_TIMER ) - iTimer->delete_timer(st->sleep.timer, script->run_timer); + timer->delete(st->sleep.timer, script->run_timer); if( st->stack ) { script->free_vars(st->stack->var_function); script->pop_stack(st, 0, st->stack->sp); @@ -3381,7 +3381,7 @@ static void script_detach_state(struct script_state* st, bool dequeue_event) * We're done with this NPC session, so we cancel the timer (if existent) and move on **/ if( sd->npc_idle_timer != INVALID_TIMER ) { - iTimer->delete_timer(sd->npc_idle_timer,npc->secure_timeout_timer); + timer->delete(sd->npc_idle_timer,npc->secure_timeout_timer); sd->npc_idle_timer = INVALID_TIMER; } #endif @@ -3421,8 +3421,8 @@ void script_attach_state(struct script_state* st) { **/ #ifdef SECURE_NPCTIMEOUT if( sd->npc_idle_timer == INVALID_TIMER ) - sd->npc_idle_timer = iTimer->add_timer(iTimer->gettick() + (SECURE_NPCTIMEOUT_INTERVAL*1000),npc->secure_timeout_timer,sd->bl.id,0); - sd->npc_idle_tick = iTimer->gettick(); + sd->npc_idle_timer = timer->add(timer->gettick() + (SECURE_NPCTIMEOUT_INTERVAL*1000),npc->secure_timeout_timer,sd->bl.id,0); + sd->npc_idle_tick = timer->gettick(); #endif } } @@ -3546,7 +3546,7 @@ void run_script_main(struct script_state *st) //Delay execution sd = iMap->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 = iTimer->add_timer(iTimer->gettick()+st->sleep.tick, + st->sleep.timer = timer->add(timer->gettick()+st->sleep.tick, script->run_timer, st->sleep.charid, (intptr_t)st->id); } else if(st->state != END && st->rid){ //Resume later (st is already attached to player). @@ -8154,7 +8154,7 @@ BUILDIN(savepoint) BUILDIN(gettimetick) /* Asgard Version */ { int type; - time_t timer; + time_t tt; struct tm *t; type=script_getnum(st,2); @@ -8167,14 +8167,14 @@ BUILDIN(gettimetick) /* Asgard Version */ break; case 1: //type 1:(Second Ticks: 0-86399, 00:00:00-23:59:59) - time(&timer); - t=localtime(&timer); + time(&tt); + t=localtime(&tt); script_pushint(st,((t->tm_hour)*3600+(t->tm_min)*60+t->tm_sec)); break; case 0: default: //type 0:(System Ticks) - script_pushint(st,iTimer->gettick()); + script_pushint(st,timer->gettick()); break; } return true; @@ -9724,11 +9724,11 @@ BUILDIN(getstatus) case 4: script_pushint(st, sd->sc.data[id]->val4); break; case 5: { - struct TimerData* timer = (struct TimerData*)iTimer->get_timer(sd->sc.data[id]->timer); + struct TimerData* td = (struct TimerData*)timer->get(sd->sc.data[id]->timer); - if( timer ) + if( td ) {// return the amount of time remaining - script_pushint(st, timer->tick - iTimer->gettick()); + script_pushint(st, td->tick - timer->gettick()); } } break; @@ -10402,7 +10402,7 @@ BUILDIN(getmapflag) static int script_mapflag_pvp_sub(struct block_list *bl,va_list ap) { TBL_PC* sd = (TBL_PC*)bl; if (sd->pvp_timer == INVALID_TIMER) { - sd->pvp_timer = iTimer->add_timer(iTimer->gettick() + 200, pc->calc_pvprank_timer, sd->bl.id, 0); + sd->pvp_timer = timer->add(timer->gettick() + 200, pc->calc_pvprank_timer, sd->bl.id, 0); sd->pvp_rank = 0; sd->pvp_lastusers = 0; sd->pvp_point = 5; @@ -10632,7 +10632,7 @@ BUILDIN(pvpon) if( sd->bl.m != m || sd->pvp_timer != INVALID_TIMER ) continue; // not applicable - sd->pvp_timer = iTimer->add_timer(iTimer->gettick()+200,pc->calc_pvprank_timer,sd->bl.id,0); + sd->pvp_timer = timer->add(timer->gettick()+200,pc->calc_pvprank_timer,sd->bl.id,0); sd->pvp_rank = 0; sd->pvp_lastusers = 0; sd->pvp_point = 5; @@ -10649,7 +10649,7 @@ static int buildin_pvpoff_sub(struct block_list *bl,va_list ap) TBL_PC* sd = (TBL_PC*)bl; clif->pvpset(sd, 0, 0, 2); if (sd->pvp_timer != INVALID_TIMER) { - iTimer->delete_timer(sd->pvp_timer, pc->calc_pvprank_timer); + timer->delete(sd->pvp_timer, pc->calc_pvprank_timer); sd->pvp_timer = INVALID_TIMER; } return 0; @@ -11695,7 +11695,7 @@ BUILDIN(petskillbonus) if (pd->bonus) { //Clear previous bonus if (pd->bonus->timer != INVALID_TIMER) - iTimer->delete_timer(pd->bonus->timer, pet->skill_bonus_timer); + timer->delete(pd->bonus->timer, pet->skill_bonus_timer); } else //init pd->bonus = (struct pet_bonus *) aMalloc(sizeof(struct pet_bonus)); @@ -11711,7 +11711,7 @@ BUILDIN(petskillbonus) if (battle_config.pet_equip_required && pd->pet.equip == 0) pd->bonus->timer = INVALID_TIMER; else - pd->bonus->timer = iTimer->add_timer(iTimer->gettick()+pd->bonus->delay*1000, pet->skill_bonus_timer, sd->bl.id, 0); + pd->bonus->timer = timer->add(timer->gettick()+pd->bonus->delay*1000, pet->skill_bonus_timer, sd->bl.id, 0); return true; } @@ -12065,7 +12065,7 @@ BUILDIN(petrecovery) if (pd->recovery) { //Halt previous bonus if (pd->recovery->timer != INVALID_TIMER) - iTimer->delete_timer(pd->recovery->timer, pet->recovery_timer); + timer->delete(pd->recovery->timer, pet->recovery_timer); } else //Init pd->recovery = (struct pet_recovery *)aMalloc(sizeof(struct pet_recovery)); @@ -12093,9 +12093,9 @@ BUILDIN(petheal) if (pd->s_skill->timer != INVALID_TIMER) { if (pd->s_skill->id) - iTimer->delete_timer(pd->s_skill->timer, pet->skill_support_timer); + timer->delete(pd->s_skill->timer, pet->skill_support_timer); else - iTimer->delete_timer(pd->s_skill->timer, pet->heal_timer); + timer->delete(pd->s_skill->timer, pet->heal_timer); } } else //init memory pd->s_skill = (struct pet_skill_support *) aMalloc(sizeof(struct pet_skill_support)); @@ -12111,7 +12111,7 @@ BUILDIN(petheal) if (battle_config.pet_equip_required && pd->pet.equip == 0) pd->s_skill->timer = INVALID_TIMER; else - pd->s_skill->timer = iTimer->add_timer(iTimer->gettick()+pd->s_skill->delay*1000,pet->heal_timer,sd->bl.id,0); + pd->s_skill->timer = timer->add(timer->gettick()+pd->s_skill->delay*1000,pet->heal_timer,sd->bl.id,0); return true; } @@ -12187,9 +12187,9 @@ BUILDIN(petskillsupport) if (pd->s_skill->timer != INVALID_TIMER) { if (pd->s_skill->id) - iTimer->delete_timer(pd->s_skill->timer, pet->skill_support_timer); + timer->delete(pd->s_skill->timer, pet->skill_support_timer); else - iTimer->delete_timer(pd->s_skill->timer, pet->heal_timer); + timer->delete(pd->s_skill->timer, pet->heal_timer); } } else //init memory pd->s_skill = (struct pet_skill_support *) aMalloc(sizeof(struct pet_skill_support)); @@ -12204,7 +12204,7 @@ BUILDIN(petskillsupport) if (battle_config.pet_equip_required && pd->pet.equip == 0) pd->s_skill->timer = INVALID_TIMER; else - pd->s_skill->timer = iTimer->add_timer(iTimer->gettick()+pd->s_skill->delay*1000,pet->skill_support_timer,sd->bl.id,0); + pd->s_skill->timer = timer->add(timer->gettick()+pd->s_skill->delay*1000,pet->skill_support_timer,sd->bl.id,0); return true; } @@ -12242,7 +12242,7 @@ BUILDIN(npcskilleffect) int y=script_getnum(st,5); if (bl) - clif->skill_poseffect(bl,skill_id,skill_lv,x,y,iTimer->gettick()); + clif->skill_poseffect(bl,skill_id,skill_lv,x,y,timer->gettick()); return true; } @@ -12916,7 +12916,7 @@ BUILDIN(summon) const char *str,*event=""; TBL_PC *sd; struct mob_data *md; - int tick = iTimer->gettick(); + int tick = timer->gettick(); sd=script_rid2sd(st); if (!sd) return true; @@ -12937,8 +12937,8 @@ BUILDIN(summon) md->master_id=sd->bl.id; md->special_state.ai = AI_ATTACK; if( md->deletetimer != INVALID_TIMER ) - iTimer->delete_timer(md->deletetimer, mob->timer_delete); - md->deletetimer = iTimer->add_timer(tick+(timeout>0?timeout*1000:60000),mob->timer_delete,md->bl.id,0); + timer->delete(md->deletetimer, mob->timer_delete); + md->deletetimer = timer->add(tick+(timeout>0?timeout*1000:60000),mob->timer_delete,md->bl.id,0); mob->spawn (md); //Now it is ready for spawning. clif->specialeffect(&md->bl,344,AREA); sc_start4(&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000); @@ -15025,7 +15025,7 @@ BUILDIN(unitattack) switch( unit_bl->type ) { case BL_PC: - clif->pActionRequest_sub(((TBL_PC *)unit_bl), actiontype > 0 ? 0x07 : 0x00, target_bl->id, iTimer->gettick()); + clif->pActionRequest_sub(((TBL_PC *)unit_bl), actiontype > 0 ? 0x07 : 0x00, target_bl->id, timer->gettick()); script_pushint(st, 1); return true; case BL_MOB: @@ -15266,7 +15266,7 @@ BUILDIN(awake) { tst->rid = 0; } - iTimer->delete_timer(tst->sleep.timer, script->run_timer); + timer->delete(tst->sleep.timer, script->run_timer); tst->sleep.timer = INVALID_TIMER; if(tst->state != RERUNLINE) tst->sleep.tick = 0; @@ -16433,7 +16433,7 @@ BUILDIN(progressbar) second = script_getnum(st,3); sd->progressbar.npc_id = st->oid; - sd->progressbar.timeout = iTimer->gettick() + second*1000; + sd->progressbar.timeout = timer->gettick() + second*1000; sd->state.workinprogress = 3; clif->progressbar(sd, strtol(color, (char **)NULL, 0), second); diff --git a/src/map/skill.c b/src/map/skill.c index 6ec9d2fec..3b7378022 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -496,7 +496,7 @@ int skillnotok (uint16 skill_id, struct map_session_data *sd) // allowing a skill to be cast. This is to prevent no-delay ACT files from spamming skills such as // AC_DOUBLE which do not have a skill delay and are not regarded in terms of attack motion. if( !sd->state.autocast && sd->skillitem != skill_id && sd->canskill_tick && - DIFF_TICK(iTimer->gettick(), sd->canskill_tick) < (sd->battle_status.amotion * (battle_config.skill_amotion_leniency) / 100) ) + DIFF_TICK(timer->gettick(), sd->canskill_tick) < (sd->battle_status.amotion * (battle_config.skill_amotion_leniency) / 100) ) {// attempted to cast a skill before the attack motion has finished return 1; } @@ -2334,8 +2334,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 ) - iTimer->delete_timer(sce->timer, iStatus->change_timer); - sce->timer = iTimer->add_timer(tick+sce->val4, iStatus->change_timer, src->id, SC_COMBOATTACK); + timer->delete(sce->timer, iStatus->change_timer); + sce->timer = timer->add(tick+sce->val4, iStatus->change_timer, src->id, SC_COMBOATTACK); break; } unit->cancel_combo(src); // Cancel combo wait @@ -2717,12 +2717,12 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds ) && check_distance_bl(bl, d_bl, sce->val3) ) { if(!rmdamage){ - clif->damage(d_bl,d_bl, iTimer->gettick(), 0, 0, damage, 0, 0, 0); + clif->damage(d_bl,d_bl, timer->gettick(), 0, 0, damage, 0, 0, 0); status_fix_damage(NULL,d_bl, damage, 0); } else{ //Reflected magics are done directly on the target not on paladin //This check is only for magical skill. //For BF_WEAPON skills types track var rdamage and function battle_calc_return_damage - clif->damage(bl,bl, iTimer->gettick(), 0, 0, damage, 0, 0, 0); + clif->damage(bl,bl, timer->gettick(), 0, 0, damage, 0, 0, 0); status_fix_damage(bl,bl, damage, 0); } } @@ -3307,7 +3307,7 @@ int skill_addtimerskill (struct block_list *src, unsigned int tick, int target, if( i == MAX_SKILLTIMERSKILL ) return 1; ud->skilltimerskill[i] = ers_alloc(skill->timer_ers, struct skill_timerskill); - ud->skilltimerskill[i]->timer = iTimer->add_timer(tick, skill->timerskill, src->id, i); + ud->skilltimerskill[i]->timer = timer->add(tick, skill->timerskill, src->id, i); ud->skilltimerskill[i]->src_id = src->id; ud->skilltimerskill[i]->target_id = target; ud->skilltimerskill[i]->skill_id = skill_id; @@ -3333,7 +3333,7 @@ int skill_cleartimerskill (struct block_list *src) for(i=0;iskilltimerskill[i]) { - iTimer->delete_timer(ud->skilltimerskill[i]->timer, skill->timerskill); + timer->delete(ud->skilltimerskill[i]->timer, skill->timerskill); ers_free(skill->timer_ers, ud->skilltimerskill[i]); ud->skilltimerskill[i]=NULL; } @@ -3346,8 +3346,8 @@ 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, iTimer->gettick()); - su->limit=DIFF_TICK(iTimer->gettick(),sg->tick); + iMap->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; } return 0; @@ -4430,7 +4430,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint skill->attack(skill->get_type(skill_id), src, src, bl, skill_id, skill_lv, tick, flag); else { clif->skill_nodamage(src, bl, skill_id, 0, 1); - skill->addtimerskill(src, iTimer->gettick() + skill->get_time(skill_id, skill_lv) - 1000, bl->id, 0, 0, skill_id, skill_lv, 0, 0); + skill->addtimerskill(src, timer->gettick() + skill->get_time(skill_id, skill_lv) - 1000, bl->id, 0, 0, skill_id, skill_lv, 0, 0); } break; @@ -4567,7 +4567,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint if( sd && !(flag&1) ) {// ensure that the skill last-cast tick is recorded - sd->canskill_tick = iTimer->gettick(); + sd->canskill_tick = timer->gettick(); if( sd->state.arrow_atk ) {// consume arrow on last invocation to this skill. @@ -4810,8 +4810,8 @@ int skill_castend_id(int tid, unsigned int tick, int id, intptr_t data) case NPC_GRANDDARKNESS: if( (sc = iStatus->get_sc(src)) && sc->data[SC_NOEQUIPSHIELD] ) { - const struct TimerData *timer = iTimer->get_timer(sc->data[SC_NOEQUIPSHIELD]->timer); - if( timer && timer->func == iStatus->change_timer && DIFF_TICK(timer->tick,iTimer->gettick()+skill->get_time(ud->skill_id, ud->skill_lv)) > 0 ) + 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 ) break; } sc_start2(src, SC_NOEQUIPSHIELD, 100, 0, 1, skill->get_time(ud->skill_id, ud->skill_lv)); @@ -8560,7 +8560,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui if( is_boss(bl) ) break; if( sc_start2(bl, type, 100, skill_lv, src->id, skill->get_time(skill_id, skill_lv))) { if( bl->type == BL_MOB ) - mob->unlocktarget((TBL_MOB*)bl,iTimer->gettick()); + mob->unlocktarget((TBL_MOB*)bl,timer->gettick()); unit->stop_attack(bl); clif->bladestop(src, bl->id, 1); iMap->freeblock_unlock(); @@ -9153,8 +9153,8 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui md->master_id = src->id; md->special_state.ai = AI_ZANZOU; if( md->deletetimer != INVALID_TIMER ) - iTimer->delete_timer(md->deletetimer, mob->timer_delete); - md->deletetimer = iTimer->add_timer (iTimer->gettick() + skill->get_time(skill_id, skill_lv), mob->timer_delete, md->bl.id, 0); + 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 ); pc->setinvincibletimer(sd,500);// unlock target lock clif->skill_nodamage(src,bl,skill_id,skill_lv,1); @@ -9338,8 +9338,8 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui if (md) { md->master_id = src->id; if (md->deletetimer != INVALID_TIMER) - iTimer->delete_timer(md->deletetimer, mob->timer_delete); - md->deletetimer = iTimer->add_timer(iTimer->gettick() + skill->get_time(skill_id, skill_lv), mob->timer_delete, md->bl.id, 0); + 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); } @@ -9367,7 +9367,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui } if( sd && !(flag&1) ) { // ensure that the skill last-cast tick is recorded - sd->canskill_tick = iTimer->gettick(); + sd->canskill_tick = timer->gettick(); if( sd->state.arrow_atk ) { // consume arrow on last invocation to this skill. battle->consume_ammo(sd, skill_id, skill_lv); @@ -9772,7 +9772,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui struct skill_unit_group *sg; if ((sg= skill->locate_element_field(src)) != NULL && ( sg->skill_id == SA_VOLCANO || sg->skill_id == SA_DELUGE || sg->skill_id == SA_VIOLENTGALE )) { - if (sg->limit - DIFF_TICK(iTimer->gettick(), sg->tick) > 0) { + if (sg->limit - DIFF_TICK(timer->gettick(), sg->tick) > 0) { skill->unitsetting(src,skill_id,skill_lv,x,y,0); return 0; // not to consume items } else @@ -10000,8 +10000,8 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui md->master_id = src->id; md->special_state.ai = (skill_id == AM_SPHEREMINE) ? AI_SPHERE : AI_FLORA; if( md->deletetimer != INVALID_TIMER ) - iTimer->delete_timer(md->deletetimer, mob->timer_delete); - md->deletetimer = iTimer->add_timer (iTimer->gettick() + skill->get_time(skill_id,skill_lv), mob->timer_delete, md->bl.id, 0); + 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. } } @@ -10099,8 +10099,8 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui if ((i = skill->get_time(skill_id, skill_lv)) > 0) { if( md->deletetimer != INVALID_TIMER ) - iTimer->delete_timer(md->deletetimer, mob->timer_delete); - md->deletetimer = iTimer->add_timer (tick + i, mob->timer_delete, md->bl.id, 0); + timer->delete(md->deletetimer, mob->timer_delete); + md->deletetimer = timer->add (tick + i, mob->timer_delete, md->bl.id, 0); } mob->spawn (md); } @@ -10199,7 +10199,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui case 2: sx = x - i; break; case 6: sx = x + i; break; } - skill->addtimerskill(src,iTimer->gettick() + (50 * i),0,sx,sy,skill_id,skill_lv,dir,flag&2); + skill->addtimerskill(src,timer->gettick() + (50 * i),0,sx,sy,skill_id,skill_lv,dir,flag&2); } } break; @@ -10234,8 +10234,8 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui md->master_id = src->id; md->special_state.ai = AI_FLORA; if( md->deletetimer != INVALID_TIMER ) - iTimer->delete_timer(md->deletetimer, mob->timer_delete); - md->deletetimer = iTimer->add_timer (iTimer->gettick() + skill->get_time(skill_id, skill_lv), mob->timer_delete, md->bl.id, 0); + 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 ); } } @@ -10370,7 +10370,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui status_change_end(src,SC_CURSEDCIRCLE_ATKER,INVALID_TIMER); if( sd ) {// ensure that the skill last-cast tick is recorded - sd->canskill_tick = iTimer->gettick(); + sd->canskill_tick = timer->gettick(); if( sd->state.arrow_atk && !(flag&1) ) { // consume arrow if this is a ground skill @@ -10490,7 +10490,7 @@ int skill_icewall_block(struct block_list *bl,va_list ap) { return 0; if( !check_distance_bl(bl, target, status_get_range(bl) ) ) { - mob->unlocktarget(md,iTimer->gettick()); + mob->unlocktarget(md,timer->gettick()); mob_stop_walking(md,1); } @@ -10644,7 +10644,7 @@ struct skill_unit_group* skill_unitsetting (struct block_list *src, uint16 skill old_sg->skill_id == SA_VIOLENTGALE ) && old_sg->limit > 0) { //Use the previous limit (minus the elapsed time) [Skotlex] - limit = old_sg->limit - DIFF_TICK(iTimer->gettick(), old_sg->tick); + limit = old_sg->limit - DIFF_TICK(timer->gettick(), old_sg->tick); if (limit < 0) //This can happen... limit = skill->get_time(skill_id,skill_lv); } @@ -10859,7 +10859,7 @@ struct skill_unit_group* skill_unitsetting (struct block_list *src, uint16 skill group->state.guildaura = ( skill_id >= GD_LEADERSHIP && skill_id <= GD_HAWKEYES )?1:0; group->item_id = req_item; //if tick is greater than current, do not invoke onplace function just yet. [Skotlex] - if (DIFF_TICK(group->tick, iTimer->gettick()) > SKILLUNITTIMER_INTERVAL) + if (DIFF_TICK(group->tick, timer->gettick()) > SKILLUNITTIMER_INTERVAL) active_flag = 0; if(skill_id==HT_TALKIEBOX || skill_id==RG_GRAFFITI){ @@ -10976,7 +10976,7 @@ 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,unit->bl.m,unit->bl.x,unit->bl.y,group->bl_flag,&unit->bl,iTimer->gettick(),1); + iMap->foreachincell(skill->unit_effect,unit->bl.m,unit->bl.x,unit->bl.y,group->bl_flag,&unit->bl,timer->gettick(),1); } if (!group->alive_count) { //No cells? Something that was blocked completely by Land Protector? @@ -11038,7 +11038,7 @@ int skill_unit_onplace (struct skill_unit *src, struct block_list *bl, unsigned } 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) ) { - const struct TimerData* td = sc->data[type]?iTimer->get_timer(sc->data[type]->timer):NULL; + 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); @@ -11150,8 +11150,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; - iTimer->delete_timer(sce->timer, iStatus->change_timer); - sce->timer = iTimer->add_timer(tick+sg->limit, iStatus->change_timer, bl->id, type); + timer->delete(sce->timer, iStatus->change_timer); + sce->timer = timer->add(tick+sg->limit, iStatus->change_timer, bl->id, type); } break; @@ -11411,7 +11411,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns 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) ) { - const struct TimerData* td = tsc->data[type]?iTimer->get_timer(tsc->data[type]->timer):NULL; + const struct TimerData* td = tsc->data[type]?timer->get(tsc->data[type]->timer):NULL; if( td ) sec = DIFF_TICK(td->tick, tick); if( sg->unit_id == UNT_MANHOLE || battle_config.skill_trap_type || !map_flag_gvg2(src->bl.m) ) { @@ -11748,7 +11748,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns if( !sg->val2 ) { int sec = skill->get_time2(sg->skill_id, sg->skill_lv); if( sc_start(bl, type, 100, sg->skill_lv, sec) ) { - const struct TimerData* td = tsc->data[type]?iTimer->get_timer(tsc->data[type]->timer):NULL; + 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] @@ -12046,11 +12046,11 @@ static int skill_unit_onleft (uint16 skill_id, struct block_list *bl, unsigned i case DC_FORTUNEKISS: case DC_SERVICEFORYOU: if (sce) { - iTimer->delete_timer(sce->timer, iStatus->change_timer); + timer->delete(sce->timer, iStatus->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 = iTimer->add_timer(tick+skill->get_time2(skill_id,1), iStatus->change_timer, bl->id, type); + sce->timer = timer->add(tick+skill->get_time2(skill_id,1), iStatus->change_timer, bl->id, type); } break; case PF_FOGWALL: @@ -12060,8 +12060,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 { - iTimer->delete_timer(sce->timer, iStatus->change_timer); - sce->timer = iTimer->add_timer(30000+tick, iStatus->change_timer, bl->id, SC_BLIND); + timer->delete(sce->timer, iStatus->change_timer); + sce->timer = timer->add(30000+tick, iStatus->change_timer, bl->id, SC_BLIND); } } } @@ -13091,7 +13091,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id break; case ST_MOVE_ENABLE: if (sc && sc->data[SC_COMBOATTACK] && sc->data[SC_COMBOATTACK]->val1 == skill_id) - sd->ud.canmove_tick = iTimer->gettick(); //When using a combo, cancel the can't move delay to enable the skill. [Skotlex] + sd->ud.canmove_tick = timer->gettick(); //When using a combo, cancel the can't move delay to enable the skill. [Skotlex] if (!unit->can_move(&sd->bl)) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); @@ -14741,7 +14741,7 @@ int skill_detonator(struct block_list *bl, va_list ap) iMap->foreachinrange(skill->trap_splash,bl,skill->get_splash(unit->group->skill_id,unit->group->skill_lv),unit->group->bl_flag,bl,unit->group->tick); } clif->changetraplook(bl, UNT_USED_TRAPS); - unit->group->limit = DIFF_TICK(iTimer->gettick(),unit->group->tick) + + unit->group->limit = DIFF_TICK(timer->gettick(),unit->group->tick) + (unit_id == UNT_TALKIEBOX ? 5000 : (unit_id == UNT_CLUSTERBOMB || unit_id == UNT_ICEBOUNDTRAP? 2500 : (unit_id == UNT_FIRINGTRAP ? 0 : 1500)) ); unit->group->unit_id = UNT_USED_TRAPS; break; @@ -14963,7 +14963,7 @@ int skill_trap_splash (struct block_list *bl, va_list ap) { case UNT_FIRINGTRAP: case UNT_ICEBOUNDTRAP: clif->changetraplook(bl, UNT_USED_TRAPS); - su->group->limit = DIFF_TICK(iTimer->gettick(),su->group->tick) + 1500; + su->group->limit = DIFF_TICK(timer->gettick(),su->group->tick) + 1500; su->group->unit_id = UNT_USED_TRAPS; } break; @@ -15159,7 +15159,7 @@ int skill_delunit (struct skill_unit* unit) { // invoke onout event if( !unit->range ) - iMap->foreachincell(skill->unit_effect,unit->bl.m,unit->bl.x,unit->bl.y,group->bl_flag,&unit->bl,iTimer->gettick(),4); + iMap->foreachincell(skill->unit_effect,unit->bl.m,unit->bl.x,unit->bl.y,group->bl_flag,&unit->bl,timer->gettick(),4); // perform ondelete actions switch (group->skill_id) { @@ -15261,7 +15261,7 @@ struct skill_unit_group* skill_initunitgroup (struct block_list* src, int count, if(i == MAX_SKILLUNITGROUP) { // array is full, make room by discarding oldest group int j=0; - unsigned maxdiff=0,x,tick=iTimer->gettick(); + unsigned maxdiff=0,x,tick=timer->gettick(); for(i=0;iskillunit[i];i++) if((x=DIFF_TICK(tick,ud->skillunit[i]->tick))>maxdiff){ maxdiff=x; @@ -15290,7 +15290,7 @@ struct skill_unit_group* skill_initunitgroup (struct block_list* src, int count, group->map = src->m; group->limit = limit; group->interval = interval; - group->tick = iTimer->gettick(); + group->tick = timer->gettick(); group->valstr = NULL; ud->skillunit[i] = group; @@ -15598,7 +15598,7 @@ int skill_unit_timer_sub(DBKey key, DBData *data, va_list ap) { group->limit = skill->get_time(group->skill_id,group->skill_lv); unit->limit = skill->get_time(group->skill_id,group->skill_lv); // apply effect to all units standing on it - iMap->foreachincell(skill->unit_effect,unit->bl.m,unit->bl.x,unit->bl.y,group->bl_flag,&unit->bl,iTimer->gettick(),1); + iMap->foreachincell(skill->unit_effect,unit->bl.m,unit->bl.x,unit->bl.y,group->bl_flag,&unit->bl,timer->gettick(),1); break; case UNT_CALLFAMILY: @@ -15875,7 +15875,7 @@ int skill_unit_move (struct block_list *bl, unsigned int tick, int flag) { int skill_unit_move_unit_group (struct skill_unit_group *group, int16 m, int16 dx, int16 dy) { int i,j; - unsigned int tick = iTimer->gettick(); + unsigned int tick = timer->gettick(); int *m_flag; struct skill_unit *unit1; struct skill_unit *unit2; @@ -16731,8 +16731,8 @@ int skill_magicdecoy(struct map_session_data *sd, int nameid) { md->master_id = sd->bl.id; md->special_state.ai = AI_FLORA; if( md->deletetimer != INVALID_TIMER ) - iTimer->delete_timer(md->deletetimer, mob->timer_delete); - md->deletetimer = iTimer->add_timer (iTimer->gettick() + skill->get_time(NC_MAGICDECOY,skill_id), mob->timer_delete, md->bl.id, 0); + timer->delete(md->deletetimer, mob->timer_delete); + md->deletetimer = timer->add (timer->gettick() + skill->get_time(NC_MAGICDECOY,skill_id), mob->timer_delete, md->bl.id, 0); mob->spawn(md); md->status.matk_min = md->status.matk_max = 250 + (50 * skill_id); } @@ -17062,13 +17062,13 @@ int skill_blockpc_start_(struct map_session_data *sd, uint16 skill_id, int tick, #endif cd->entry[cd->cursor]->skidx = idx; cd->entry[cd->cursor]->skill_id = skill_id; - cd->entry[cd->cursor]->started = iTimer->gettick(); + cd->entry[cd->cursor]->started = timer->gettick(); cd->cursor++; } } - sd->blockskill[idx] = 0x1|(0xFE&iTimer->add_timer(iTimer->gettick()+tick,skill->blockpc_end,sd->bl.id,idx)); + sd->blockskill[idx] = 0x1|(0xFE&timer->add(timer->gettick()+tick,skill->blockpc_end,sd->bl.id,idx)); return 0; } @@ -17094,7 +17094,7 @@ int skill_blockhomun_start(struct homun_data *hd, uint16 skill_id, int tick) { / return -1; } hd->blockskill[idx] = 1; - return iTimer->add_timer(iTimer->gettick() + tick, skill->blockhomun_end, hd->bl.id, idx); + return timer->add(timer->gettick() + tick, skill->blockhomun_end, hd->bl.id, idx); } int skill_blockmerc_end(int tid, unsigned int tick, int id, intptr_t data) {//[orn] @@ -17119,7 +17119,7 @@ int skill_blockmerc_start(struct mercenary_data *md, uint16 skill_id, int tick) return -1; } md->blockskill[idx] = 1; - return iTimer->add_timer(iTimer->gettick() + tick, skill->blockmerc_end, md->bl.id, idx); + return timer->add(timer->gettick() + tick, skill->blockmerc_end, md->bl.id, idx); } /** * Adds a new skill unit entry for this player to recast after map load @@ -17572,7 +17572,7 @@ void skill_cooldown_save(struct map_session_data * sd) { return; } - now = iTimer->gettick(); + now = timer->gettick(); // process each individual cooldown associated with the character for( i = 0; i < cd->cursor; i++ ) { @@ -17598,7 +17598,7 @@ void skill_cooldown_load(struct map_session_data * sd) { clif->cooldown_list(sd->fd,cd); - now = iTimer->gettick(); + now = timer->gettick(); // process each individual cooldown associated with the character for( i = 0; i < cd->cursor; i++ ) { @@ -18087,13 +18087,13 @@ int do_init_skill (void) { ers_chunk_size(skill->cd_ers, 25); ers_chunk_size(skill->cd_entry_ers, 100); - iTimer->add_timer_func_list(skill->unit_timer,"skill_unit_timer"); - iTimer->add_timer_func_list(skill->castend_id,"skill_castend_id"); - iTimer->add_timer_func_list(skill->castend_pos,"skill_castend_pos"); - iTimer->add_timer_func_list(skill->timerskill,"skill_timerskill"); - iTimer->add_timer_func_list(skill->blockpc_end, "skill_blockpc_end"); + timer->add_func_list(skill->unit_timer,"skill_unit_timer"); + timer->add_func_list(skill->castend_id,"skill_castend_id"); + timer->add_func_list(skill->castend_pos,"skill_castend_pos"); + timer->add_func_list(skill->timerskill,"skill_timerskill"); + timer->add_func_list(skill->blockpc_end, "skill_blockpc_end"); - iTimer->add_timer_interval(iTimer->gettick()+SKILLUNITTIMER_INTERVAL,skill->unit_timer,0,0,SKILLUNITTIMER_INTERVAL); + timer->add_interval(timer->gettick()+SKILLUNITTIMER_INTERVAL,skill->unit_timer,0,0,SKILLUNITTIMER_INTERVAL); return 0; } diff --git a/src/map/status.c b/src/map/status.c index ee5d4bfd5..4f1ca9094 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -1157,7 +1157,7 @@ int status_damage(struct block_list *src,struct block_list *target,int64 in_hp, } if (target->type == BL_SKILL) - return skill->unit_ondamaged((struct skill_unit *)target, src, hp, iTimer->gettick()); + return skill->unit_ondamaged((struct skill_unit *)target, src, hp, timer->gettick()); status = iStatus->get_status_data(target); if( status == &dummy_status ) @@ -1259,7 +1259,7 @@ int status_damage(struct block_list *src,struct block_list *target,int64 in_hp, if( status->hp || (flag&8) ) { //Still lives or has been dead before this damage. if (walkdelay) - unit->set_walkdelay(target, iTimer->gettick(), walkdelay, 0); + unit->set_walkdelay(target, timer->gettick(), walkdelay, 0); return (int)(hp+sp); } @@ -1347,7 +1347,7 @@ int status_damage(struct block_list *src,struct block_list *target,int64 in_hp, unit->stop_walking(target,1); unit->skillcastcancel(target,0); clif->clearunit_area(target,CLR_DEAD); - skill->unit_move(target,iTimer->gettick(),4); + skill->unit_move(target,timer->gettick(),4); skill->cleartimerskill(target); } @@ -7302,7 +7302,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) { - iTimer->delete_timer(sce->val4,iStatus->kaahi_heal_timer); + timer->delete(sce->val4,iStatus->kaahi_heal_timer); sce->val4 = INVALID_TIMER; } break; @@ -7882,8 +7882,8 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val 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)++; - iTimer->delete_timer(sce2->timer, iStatus->change_timer); - sce2->timer = iTimer->add_timer(iTimer->gettick()+tick+1000, iStatus->change_timer, src->id, SC_RG_CCONFINE_M); + 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; @@ -7917,8 +7917,8 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val struct unit_data *ud = unit->bl2ud(bl); if (ud && !val3) { tick += 300 * battle_config.combo_delay_rate/100; - ud->attackabletime = iTimer->gettick()+tick; - unit->set_walkdelay(bl, iTimer->gettick(), tick, 1); + ud->attackabletime = timer->gettick()+tick; + unit->set_walkdelay(bl, timer->gettick(), tick, 1); } val3 = 0; val4 = tick; @@ -7928,7 +7928,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val val2 = 11-val1; //Chance to consume: 11-skill_lv% break; case SC_RUN: - val4 = iTimer->gettick(); //Store time at which you started running. + val4 = timer->gettick(); //Store time at which you started running. tick = -1; break; case SC_KAAHI: @@ -8325,7 +8325,7 @@ 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_WUGDASH: - val4 = iTimer->gettick(); //Store time at which you started running. + val4 = timer->gettick(); //Store time at which you started running. tick = -1; break; case SC__SHADOWFORM: { @@ -9115,7 +9115,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 ) - iTimer->delete_timer(sce->timer, iStatus->change_timer); + timer->delete(sce->timer, iStatus->change_timer); } else {// new sc ++(sc->count); sce = sc->data[type] = ers_alloc(sc_data_ers, struct status_change_entry); @@ -9125,7 +9125,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 = iTimer->add_timer(iTimer->gettick() + tick, iStatus->change_timer, bl->id, type); + sce->timer = timer->add(timer->gettick() + tick, iStatus->change_timer, bl->id, type); else sce->timer = INVALID_TIMER; //Infinite duration @@ -9270,7 +9270,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) - iTimer->delete_timer(sc->data[i]->timer, iStatus->change_timer); + timer->delete(sc->data[i]->timer, iStatus->change_timer); ers_free(sc_data_ers, sc->data[i]); sc->data[i] = NULL; } @@ -9319,7 +9319,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 - iTimer->delete_timer(sce->timer,iStatus->change_timer); + timer->delete(sce->timer,iStatus->change_timer); if (sc->opt1) switch (type) { //"Ugly workaround" [Skotlex] @@ -9335,7 +9335,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 = iTimer->add_timer(iTimer->gettick()+10, iStatus->change_timer, bl->id, type); + sce->timer = timer->add(timer->gettick()+10, iStatus->change_timer, bl->id, type); return 1; } } @@ -9375,7 +9375,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const unit->stop_walking(bl,1); } if (begin_spurt && sce->val1 >= 7 && - DIFF_TICK(iTimer->gettick(), sce->val4) <= 1000 && + 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)); @@ -9515,7 +9515,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const { struct block_list *src=iMap->id2bl(sce->val3); if(src && tid != INVALID_TIMER) - skill->castend_damage_id(src, bl, sce->val2, sce->val1, iTimer->gettick(), SD_LEVEL ); + skill->castend_damage_id(src, bl, sce->val2, sce->val1, timer->gettick(), SD_LEVEL ); } break; case SC_RG_CCONFINE_S: @@ -9536,7 +9536,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const +skill->get_range2(bl, iStatus->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, - bl->m, bl->x-range, bl->y-range, bl->x+range,bl->y+range,BL_CHAR,bl,sce,type,iTimer->gettick()); + bl->m, bl->x-range, bl->y-range, bl->x+range,bl->y+range,BL_CHAR,bl,sce,type,timer->gettick()); } break; case SC_COMBOATTACK: @@ -9624,7 +9624,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) - iTimer->delete_timer(sce->val4,iStatus->kaahi_heal_timer); + timer->delete(sce->val4,iStatus->kaahi_heal_timer); break; case SC_JAILED: if(tid == INVALID_TIMER) @@ -9676,7 +9676,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const struct block_list* src = iMap->id2bl(sce->val2); if( tid == -1 || !src) break; // Terminated by Damage - status_fix_damage(src,bl,400*sce->val1,clif->damage(bl,bl,iTimer->gettick(),0,0,400*sce->val1,0,0,0)); + status_fix_damage(src,bl,400*sce->val1,clif->damage(bl,bl,timer->gettick(),0,0,400*sce->val1,0,0,0)); } break; case SC_WUGDASH: @@ -9724,7 +9724,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, iTimer->gettick()); + iMap->foreachinrange(iStatus->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) ) { @@ -9979,7 +9979,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const status_calc_bl(bl,calc_flag); if(opt_flag&4) //Out of hiding, invoke on place. - skill->unit_move(bl,iTimer->gettick(),1); + skill->unit_move(bl,timer->gettick(),1); if(opt_flag&2 && sd && iMap->getcell(bl->m,bl->x,bl->y,CELL_CHKNPC)) npc->touch_areanpc(sd,bl->m,bl->x,bl->y); //Trigger on-touch event. @@ -10061,7 +10061,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) // set the next timer of the sce (don't assume the status still exists) #define sc_timer_next(t,f,i,d) \ if( (sce=sc->data[type]) ) \ - sce->timer = iTimer->add_timer(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) @@ -11131,14 +11131,14 @@ 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); - const struct TimerData *timer; + const struct TimerData *td; unsigned int tick; struct status_change_data data; if( !sc || !sc->count ) return 0; - tick = iTimer->gettick(); + tick = timer->gettick(); for( i = SC_COMMON_MIN; i < SC_MAX; i++ ) { if( !sc->data[i] || i == SC_COMMON_MAX ) @@ -11171,10 +11171,10 @@ int status_change_spread( struct block_list *src, struct block_list *bl ) { case SC_DEATHHURT: case SC_PARALYSE: if( sc->data[i]->timer != INVALID_TIMER ) { - timer = iTimer->get_timer(sc->data[i]->timer); - if (timer == NULL || timer->func != iStatus->change_timer || DIFF_TICK(timer->tick,tick) < 0) + td = timer->get(sc->data[i]->timer); + if (td == NULL || td->func != iStatus->change_timer || DIFF_TICK(td->tick,tick) < 0) continue; - data.tick = DIFF_TICK(timer->tick,tick); + data.tick = DIFF_TICK(td->tick,tick); } else data.tick = INVALID_TIMER; break; @@ -11616,16 +11616,16 @@ int status_readdb(void) *------------------------------------------*/ int do_init_status(void) { - iTimer->add_timer_func_list(iStatus->change_timer,"status_change_timer"); - iTimer->add_timer_func_list(kaahi_heal_timer,"kaahi_heal_timer"); - iTimer->add_timer_func_list(status_natural_heal_timer,"status_natural_heal_timer"); + timer->add_func_list(iStatus->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_calc_sigma(); - natural_heal_prev_tick = iTimer->gettick(); + natural_heal_prev_tick = timer->gettick(); sc_data_ers = ers_new(sizeof(struct status_change_entry),"status.c::sc_data_ers",ERS_OPT_NONE); - iTimer->add_timer_interval(natural_heal_prev_tick + NATURAL_HEAL_INTERVAL, status_natural_heal_timer, 0, 0, NATURAL_HEAL_INTERVAL); + 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) diff --git a/src/map/unit.c b/src/map/unit.c index 0551baaea..1bae8885a 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -133,7 +133,7 @@ int unit_walktoxy_sub(struct block_list *bl) else i = iStatus->get_speed(bl); if( i > 0) - ud->walktimer = iTimer->add_timer(iTimer->gettick()+i,unit->walktoxy_timer,bl->id,i); + ud->walktimer = timer->add(timer->gettick()+i,unit->walktoxy_timer,bl->id,i); return 1; } @@ -213,9 +213,9 @@ int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data) // mercenary should be warped after being 3 seconds too far from the master [greenbox] if (sd->md->masterteleport_timer == 0) { - sd->md->masterteleport_timer = iTimer->gettick(); + sd->md->masterteleport_timer = timer->gettick(); } - else if (DIFF_TICK(iTimer->gettick(), sd->md->masterteleport_timer) > 3000) + else if (DIFF_TICK(timer->gettick(), sd->md->masterteleport_timer) > 3000) { sd->md->masterteleport_timer = 0; unit->warp( &sd->md->bl, sd->bl.m, sd->bl.x, sd->bl.y, CLR_TELEPORT ); @@ -254,9 +254,9 @@ int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data) // mercenary should be warped after being 3 seconds too far from the master [greenbox] if (mrd->masterteleport_timer == 0) { - mrd->masterteleport_timer = iTimer->gettick(); + mrd->masterteleport_timer = timer->gettick(); } - else if (DIFF_TICK(iTimer->gettick(), mrd->masterteleport_timer) > 3000) + else if (DIFF_TICK(timer->gettick(), mrd->masterteleport_timer) > 3000) { mrd->masterteleport_timer = 0; unit->warp( bl, mrd->master->bl.id, mrd->master->bl.x, mrd->master->bl.y, CLR_TELEPORT ); @@ -283,7 +283,7 @@ int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data) i = iStatus->get_speed(bl); if(i > 0) { - ud->walktimer = iTimer->add_timer(tick+i,unit->walktoxy_timer,id,i); + ud->walktimer = timer->add(tick+i,unit->walktoxy_timer,id,i); if( md && DIFF_TICK(tick,md->dmgtick) < 3000 )//not required not damaged recently clif->move(ud); } else if(ud->state.running) { @@ -361,10 +361,10 @@ int unit_walktoxy( struct block_list *bl, short x, short y, int flag) if ((wpd.path_len > battle_config.max_walk_path) && (bl->type != BL_NPC)) return 0; - if (flag&4 && DIFF_TICK(ud->canmove_tick, iTimer->gettick()) > 0 && - DIFF_TICK(ud->canmove_tick, iTimer->gettick()) < 2000) + if (flag&4 && DIFF_TICK(ud->canmove_tick, timer->gettick()) > 0 && + DIFF_TICK(ud->canmove_tick, timer->gettick()) < 2000) { // Delay walking command. [Skotlex] - iTimer->add_timer(ud->canmove_tick+1, unit->delay_walktoxy_timer, bl->id, (x<<16)|(y&0xFFFF)); + timer->add(ud->canmove_tick+1, unit->delay_walktoxy_timer, bl->id, (x<<16)|(y&0xFFFF)); return 1; } @@ -388,7 +388,7 @@ int unit_walktoxy( struct block_list *bl, short x, short y, int flag) } if(ud->attacktimer != INVALID_TIMER) { - iTimer->delete_timer( ud->attacktimer, unit->attack_timer ); + timer->delete( ud->attacktimer, unit->attack_timer ); ud->attacktimer = INVALID_TIMER; } @@ -412,7 +412,7 @@ int unit_walktobl_sub(int tid, unsigned int tick, int id, intptr_t data) if (ud && ud->walktimer == INVALID_TIMER && ud->target == data) { if (DIFF_TICK(ud->canmove_tick, tick) > 0) //Keep waiting? - iTimer->add_timer(ud->canmove_tick+1, unit->walktobl_sub, id, data); + timer->add(ud->canmove_tick+1, unit->walktobl_sub, id, data); else if (unit->can_move(bl)) { if (unit->walktoxy_sub(bl)) @@ -461,9 +461,9 @@ int unit_walktobl(struct block_list *bl, struct block_list *tbl, int range, int return 1; } - if(DIFF_TICK(ud->canmove_tick, iTimer->gettick()) > 0) + if(DIFF_TICK(ud->canmove_tick, timer->gettick()) > 0) { //Can't move, wait a bit before invoking the movement. - iTimer->add_timer(ud->canmove_tick+1, unit->walktobl_sub, bl->id, ud->target); + timer->add(ud->canmove_tick+1, unit->walktobl_sub, bl->id, ud->target); return 1; } @@ -471,7 +471,7 @@ int unit_walktobl(struct block_list *bl, struct block_list *tbl, int range, int return 0; if(ud->attacktimer != INVALID_TIMER) { - iTimer->delete_timer( ud->attacktimer, unit->attack_timer ); + timer->delete( ud->attacktimer, unit->attack_timer ); ud->attacktimer = INVALID_TIMER; } @@ -595,7 +595,7 @@ int unit_wugdash(struct block_list *bl, struct map_session_data *sd) { if( sd ){ clif->fixpos(bl); - skill->castend_damage_id(bl, &sd->bl, RA_WUGDASH, lv, iTimer->gettick(), SD_LEVEL); + skill->castend_damage_id(bl, &sd->bl, RA_WUGDASH, lv, timer->gettick(), SD_LEVEL); } return 0; } @@ -612,7 +612,7 @@ int unit_wugdash(struct block_list *bl, struct map_session_data *sd) { if( sd ){ clif->fixpos(bl); - skill->castend_damage_id(bl, &sd->bl, RA_WUGDASH, lv, iTimer->gettick(), SD_LEVEL); + skill->castend_damage_id(bl, &sd->bl, RA_WUGDASH, lv, timer->gettick(), SD_LEVEL); } return 0; } @@ -659,7 +659,7 @@ int unit_movepos(struct block_list *bl, short dst_x, short dst_y, int easy, bool iMap->foreachinmovearea(clif->outsight, bl, AREA_SIZE, dx, dy, sd?BL_ALL:BL_PC, bl); - iMap->moveblock(bl, dst_x, dst_y, iTimer->gettick()); + iMap->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); @@ -754,7 +754,7 @@ int unit_blown(struct block_list* bl, int dx, int dy, int count, int flag) if(su) { skill->unit_move_unit_group(su->group, bl->m, dx, dy); } else { - iMap->moveblock(bl, nx, ny, iTimer->gettick()); + iMap->moveblock(bl, nx, ny, timer->gettick()); } iMap->foreachinmovearea(clif->insight, bl, AREA_SIZE, -dx, -dy, bl->type == BL_PC ? BL_ALL : BL_PC, bl); @@ -847,7 +847,7 @@ int unit_warp(struct block_list *bl,short m,short x,short y,clr_type type) iMap->addblock(bl); clif->spawn(bl); - skill->unit_move(bl,iTimer->gettick(),1); + skill->unit_move(bl,timer->gettick(),1); return 0; } @@ -871,13 +871,13 @@ int unit_stop_walking(struct block_list *bl,int type) if(!ud || ud->walktimer == INVALID_TIMER) return 0; //NOTE: We are using timer data after deleting it because we know the - //iTimer->delete_timer function does not messes with it. If the function's + //timer->delete function does not messes with it. If the function's //behaviour changes in the future, this code could break! - td = iTimer->get_timer(ud->walktimer); - iTimer->delete_timer(ud->walktimer, unit->walktoxy_timer); + td = timer->get(ud->walktimer); + timer->delete(ud->walktimer, unit->walktoxy_timer); ud->walktimer = INVALID_TIMER; ud->state.change_walk_target = 0; - tick = iTimer->gettick(); + tick = timer->gettick(); if( (type&0x02 && !ud->walkpath.path_pos) //Force moving at least one cell. || (type&0x04 && td && DIFF_TICK(td->tick, tick) <= td->data/2) //Enough time has passed to cover half-cell ) { @@ -893,7 +893,7 @@ int unit_stop_walking(struct block_list *bl,int type) ud->to_x = bl->x; ud->to_y = bl->y; if(bl->type == BL_PET && type&~0xff) - ud->canmove_tick = iTimer->gettick() + (type>>8); + ud->canmove_tick = timer->gettick() + (type>>8); //Readded, the check in unit_set_walkdelay means dmg during running won't fall through to this place in code [Kevin] if (ud->state.running) { @@ -939,7 +939,7 @@ int unit_can_move(struct block_list *bl) { if (ud->skilltimer != INVALID_TIMER && ud->skill_id != LG_EXEEDBREAK && (!sd || !pc->checkskill(sd, SA_FREECAST) || skill->get_inf2(ud->skill_id)&INF2_GUILD_SKILL)) return 0; // prevent moving while casting - if (DIFF_TICK(ud->canmove_tick, iTimer->gettick()) > 0) + if (DIFF_TICK(ud->canmove_tick, timer->gettick()) > 0) return 0; if (sd && ( @@ -1061,13 +1061,13 @@ int unit_set_walkdelay(struct block_list *bl, unsigned int tick, int delay, int //Resume running after can move again [Kevin] if(ud->state.running) { - iTimer->add_timer(ud->canmove_tick, unit->resume_running, bl->id, (intptr_t)ud); + timer->add(ud->canmove_tick, unit->resume_running, bl->id, (intptr_t)ud); } else { unit->stop_walking(bl,2|4); if(ud->target) - iTimer->add_timer(ud->canmove_tick+1, unit->walktobl_sub, bl->id, ud->target); + timer->add(ud->canmove_tick+1, unit->walktobl_sub, bl->id, ud->target); } } } @@ -1081,7 +1081,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui struct status_change *sc; struct map_session_data *sd = NULL; struct block_list * target = NULL; - unsigned int tick = iTimer->gettick(); + unsigned int tick = timer->gettick(); int temp = 0, range; nullpo_ret(src); @@ -1421,7 +1421,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui if( casttime > 0 ) { - ud->skilltimer = iTimer->add_timer( tick+casttime, skill->castend_id, src->id, 0 ); + ud->skilltimer = timer->add( tick+casttime, skill->castend_id, src->id, 0 ); if( sd && (pc->checkskill(sd,SA_FREECAST) > 0 || skill_id == LG_EXEEDBREAK) ) status_calc_bl(&sd->bl, SCB_SPEED); } else @@ -1445,7 +1445,7 @@ int unit_skilluse_pos2( struct block_list *src, short skill_x, short skill_y, ui struct unit_data *ud = NULL; struct status_change *sc; struct block_list bl; - unsigned int tick = iTimer->gettick(); + unsigned int tick = timer->gettick(); int range; nullpo_ret(src); @@ -1556,7 +1556,7 @@ int unit_skilluse_pos2( struct block_list *src, short skill_x, short skill_y, ui // in official this is triggered even if no cast time. clif->skillcasting(src, src->id, 0, skill_x, skill_y, skill_id, skill->get_ele(skill_id, skill_lv), casttime); if( casttime > 0 ) { - ud->skilltimer = iTimer->add_timer( tick+casttime, skill->castend_pos, src->id, 0 ); + ud->skilltimer = timer->add( tick+casttime, skill->castend_pos, src->id, 0 ); if( (sd && pc->checkskill(sd,SA_FREECAST) > 0) || skill_id == LG_EXEEDBREAK) status_calc_bl(&sd->bl, SCB_SPEED); } else { @@ -1595,7 +1595,7 @@ int unit_stop_attack(struct block_list *bl) if(!ud || ud->attacktimer == INVALID_TIMER) return 0; - iTimer->delete_timer( ud->attacktimer, unit->attack_timer ); + timer->delete( ud->attacktimer, unit->attack_timer ); ud->attacktimer = INVALID_TIMER; unit->set_target(ud, 0); return 0; @@ -1611,7 +1611,7 @@ int unit_unattackable(struct block_list *bl) } if(bl->type == BL_MOB) - mob->unlocktarget((struct mob_data*)bl, iTimer->gettick()) ; + mob->unlocktarget((struct mob_data*)bl, timer->gettick()) ; else if(bl->type == BL_PET) pet->unlocktarget((struct pet_data*)bl); return 0; @@ -1663,11 +1663,11 @@ int unit_attack(struct block_list *src,int target_id,int continuous) if(src->type == BL_MOB) ((TBL_MOB*)src)->state.skillstate = ((TBL_MOB*)src)->state.aggressive?MSS_ANGRY:MSS_BERSERK; - if(DIFF_TICK(ud->attackabletime, iTimer->gettick()) > 0) + if(DIFF_TICK(ud->attackabletime, timer->gettick()) > 0) //Do attack next time it is possible. [Skotlex] - ud->attacktimer=iTimer->add_timer(ud->attackabletime,unit->attack_timer,src->id,0); + ud->attacktimer=timer->add(ud->attackabletime,unit->attack_timer,src->id,0); else //Attack NOW. - unit->attack_timer(INVALID_TIMER, iTimer->gettick(), src->id, 0); + unit->attack_timer(INVALID_TIMER, timer->gettick(), src->id, 0); return 0; } @@ -1684,13 +1684,13 @@ int unit_cancel_combo(struct block_list *bl) ud = unit->bl2ud(bl); nullpo_ret(ud); - ud->attackabletime = iTimer->gettick() + status_get_amotion(bl); + ud->attackabletime = timer->gettick() + status_get_amotion(bl); if (ud->attacktimer == INVALID_TIMER) return 1; //Nothing more to do. - iTimer->delete_timer(ud->attacktimer, unit->attack_timer); - ud->attacktimer=iTimer->add_timer(ud->attackabletime,unit->attack_timer,bl->id,0); + timer->delete(ud->attacktimer, unit->attack_timer); + ud->attacktimer=timer->add(ud->attackabletime,unit->attack_timer,bl->id,0); return 1; } /*========================================== @@ -1857,7 +1857,7 @@ int unit_attack_timer_sub(struct block_list* src, int tid, unsigned int tick) if( ud->state.attack_continue ) { if( DIFF_TICK(ud->canact_tick, ud->attackabletime) > 0 ) ud->attackabletime = ud->canact_tick; - ud->attacktimer=iTimer->add_timer(ud->attackabletime,unit->attack_timer,src->id,0); + ud->attacktimer=timer->add(ud->attackabletime,unit->attack_timer,src->id,0); } return 1; } @@ -1927,7 +1927,7 @@ int unit_attack_timer_sub(struct block_list* src, int tid, unsigned int tick) if(ud->state.attack_continue) { if( src->type == BL_PC ) ((TBL_PC*)src)->idletime = last_tick; - ud->attacktimer = iTimer->add_timer(ud->attackabletime,unit->attack_timer,src->id,0); + ud->attacktimer = timer->add(ud->attackabletime,unit->attack_timer,src->id,0); } return 1; @@ -1951,7 +1951,7 @@ int unit_skillcastcancel(struct block_list *bl,int type) { struct map_session_data *sd = NULL; struct unit_data *ud = unit->bl2ud( bl); - unsigned int tick=iTimer->gettick(); + unsigned int tick=timer->gettick(); int ret=0, skill_id; nullpo_ret(bl); @@ -1978,9 +1978,9 @@ int unit_skillcastcancel(struct block_list *bl,int type) skill_id = ud->skill_id; if (skill->get_inf(skill_id) & INF_GROUND_SKILL) - ret = iTimer->delete_timer( ud->skilltimer, skill->castend_pos ); + ret = timer->delete( ud->skilltimer, skill->castend_pos ); else - ret = iTimer->delete_timer( ud->skilltimer, skill->castend_id ); + ret = timer->delete( ud->skilltimer, skill->castend_id ); if( ret < 0 ) ShowError("delete timer error : skill_id : %d\n",ret); @@ -2015,7 +2015,7 @@ void unit_dataset(struct block_list *bl) { ud->attacktimer = INVALID_TIMER; ud->attackabletime = ud->canact_tick = - ud->canmove_tick = iTimer->gettick(); + ud->canmove_tick = timer->gettick(); } /*========================================== @@ -2090,7 +2090,7 @@ int unit_remove_map(struct block_list *bl, clr_type clrtype, const char* file, i unit->skillcastcancel(bl,0); // Do not reset can-act delay. [Skotlex] - ud->attackabletime = ud->canmove_tick /*= ud->canact_tick*/ = iTimer->gettick(); + ud->attackabletime = ud->canmove_tick /*= ud->canact_tick*/ = timer->gettick(); if(sc && sc->count ) { //map-change/warp dispells. status_change_end(bl, SC_BLADESTOP, INVALID_TIMER); status_change_end(bl, SC_BASILICA, INVALID_TIMER); @@ -2126,7 +2126,7 @@ int unit_remove_map(struct block_list *bl, clr_type clrtype, const char* file, i } if (bl->type&(BL_CHAR|BL_PET)) { - skill->unit_move(bl,iTimer->gettick(),4); + skill->unit_move(bl,timer->gettick(),4); skill->cleartimerskill(bl); } @@ -2172,7 +2172,7 @@ int unit_remove_map(struct block_list *bl, clr_type clrtype, const char* file, i sd->adopt_invite = 0; if(sd->pvp_timer != INVALID_TIMER) { - iTimer->delete_timer(sd->pvp_timer,pc->calc_pvprank_timer); + timer->delete(sd->pvp_timer,pc->calc_pvprank_timer); sd->pvp_timer = INVALID_TIMER; sd->pvp_rank = 0; } @@ -2433,9 +2433,9 @@ int unit_free(struct block_list *bl, clr_type clrtype) { if (pd->s_skill->timer != INVALID_TIMER) { if (pd->s_skill->id) - iTimer->delete_timer(pd->s_skill->timer, pet->skill_support_timer); + timer->delete(pd->s_skill->timer, pet->skill_support_timer); else - iTimer->delete_timer(pd->s_skill->timer, pet->heal_timer); + timer->delete(pd->s_skill->timer, pet->heal_timer); } aFree(pd->s_skill); pd->s_skill = NULL; @@ -2443,14 +2443,14 @@ int unit_free(struct block_list *bl, clr_type clrtype) if( pd->recovery ) { if(pd->recovery->timer != INVALID_TIMER) - iTimer->delete_timer(pd->recovery->timer, pet->recovery_timer); + timer->delete(pd->recovery->timer, pet->recovery_timer); aFree(pd->recovery); pd->recovery = NULL; } if( pd->bonus ) { if (pd->bonus->timer != INVALID_TIMER) - iTimer->delete_timer(pd->bonus->timer, pet->skill_bonus_timer); + timer->delete(pd->bonus->timer, pet->skill_bonus_timer); aFree(pd->bonus); pd->bonus = NULL; } @@ -2478,12 +2478,12 @@ int unit_free(struct block_list *bl, clr_type clrtype) struct mob_data *md = (struct mob_data*)bl; if( md->spawn_timer != INVALID_TIMER ) { - iTimer->delete_timer(md->spawn_timer,mob->delayspawn); + timer->delete(md->spawn_timer,mob->delayspawn); md->spawn_timer = INVALID_TIMER; } if( md->deletetimer != INVALID_TIMER ) { - iTimer->delete_timer(md->deletetimer,mob->timer_delete); + timer->delete(md->deletetimer,mob->timer_delete); md->deletetimer = INVALID_TIMER; } if( md->lootitem ) @@ -2593,10 +2593,10 @@ int unit_free(struct block_list *bl, clr_type clrtype) } int do_init_unit(void) { - iTimer->add_timer_func_list(unit->attack_timer, "unit_attack_timer"); - iTimer->add_timer_func_list(unit->walktoxy_timer,"unit_walktoxy_timer"); - iTimer->add_timer_func_list(unit->walktobl_sub, "unit_walktobl_sub"); - iTimer->add_timer_func_list(unit->delay_walktoxy_timer,"unit_delay_walktoxy_timer"); + timer->add_func_list(unit->attack_timer, "unit_attack_timer"); + timer->add_func_list(unit->walktoxy_timer,"unit_walktoxy_timer"); + timer->add_func_list(unit->walktobl_sub, "unit_walktobl_sub"); + timer->add_func_list(unit->delay_walktoxy_timer,"unit_delay_walktoxy_timer"); return 0; } -- cgit v1.2.3-70-g09d2 From afcad494411995396b906f214d1c4ffcf485cc0a Mon Sep 17 00:00:00 2001 From: Haru Date: Wed, 25 Sep 2013 21:26:54 +0200 Subject: Renamed local variables that would conflict with a rename of iStatus to status Signed-off-by: Haru --- src/map/atcommand.c | 80 ++- src/map/battle.c | 68 +- src/map/battle.h | 2 +- src/map/chrif.c | 8 +- src/map/clif.c | 157 +++-- src/map/elemental.c | 60 +- src/map/mercenary.c | 65 +- src/map/mob.c | 145 +++-- src/map/pc.c | 123 ++-- src/map/pet.c | 22 +- src/map/quest.c | 8 +- src/map/quest.h | 2 +- src/map/skill.c | 141 ++-- src/map/status.c | 1764 +++++++++++++++++++++++++-------------------------- src/map/status.h | 4 +- 15 files changed, 1284 insertions(+), 1365 deletions(-) (limited to 'src/map/elemental.c') diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 41d93fa4d..0fd54200d 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -2377,11 +2377,10 @@ ACMD(zeny) /*========================================== * *------------------------------------------*/ -ACMD(param) -{ +ACMD(param) { int i, value = 0, new_value, max; const char* param[] = { "str", "agi", "vit", "int", "dex", "luk" }; - short* status[6]; + short* stats[6]; //we don't use direct initialization because it isn't part of the c standard. nullpo_retr(-1, sd); @@ -2399,28 +2398,28 @@ ACMD(param) return false; } - status[0] = &sd->status.str; - status[1] = &sd->status.agi; - status[2] = &sd->status.vit; - status[3] = &sd->status.int_; - status[4] = &sd->status.dex; - status[5] = &sd->status.luk; + stats[0] = &sd->status.str; + stats[1] = &sd->status.agi; + stats[2] = &sd->status.vit; + stats[3] = &sd->status.int_; + stats[4] = &sd->status.dex; + stats[5] = &sd->status.luk; if( battle_config.atcommand_max_stat_bypass ) max = SHRT_MAX; else max = pc_maxparameter(sd); - if(value < 0 && *status[i] <= -value) { + if(value < 0 && *stats[i] <= -value) { new_value = 1; - } else if(max - *status[i] < value) { + } else if(max - *stats[i] < value) { new_value = max; } else { - new_value = *status[i] + value; + new_value = *stats[i] + value; } - if (new_value != *status[i]) { - *status[i] = new_value; + if (new_value != *stats[i]) { + *stats[i] = new_value; clif->updatestatus(sd, SP_STR + i); clif->updatestatus(sd, SP_USTR + i); status_calc_pc(sd, 0); @@ -2439,19 +2438,18 @@ ACMD(param) /*========================================== * Stat all by fritz (rewritten by [Yor]) *------------------------------------------*/ -ACMD(stat_all) -{ +ACMD(stat_all) { int index, count, value, max, new_value; - short* status[6]; + short* stats[6]; //we don't use direct initialization because it isn't part of the c standard. nullpo_retr(-1, sd); - status[0] = &sd->status.str; - status[1] = &sd->status.agi; - status[2] = &sd->status.vit; - status[3] = &sd->status.int_; - status[4] = &sd->status.dex; - status[5] = &sd->status.luk; + stats[0] = &sd->status.str; + stats[1] = &sd->status.agi; + stats[2] = &sd->status.vit; + stats[3] = &sd->status.int_; + stats[4] = &sd->status.dex; + stats[5] = &sd->status.luk; if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) { value = pc_maxparameter(sd); @@ -2464,17 +2462,17 @@ ACMD(stat_all) } count = 0; - for (index = 0; index < ARRAYLENGTH(status); index++) { + for (index = 0; index < ARRAYLENGTH(stats); index++) { - if (value > 0 && *status[index] > max - value) + if (value > 0 && *stats[index] > max - value) new_value = max; - else if (value < 0 && *status[index] <= -value) + else if (value < 0 && *stats[index] <= -value) new_value = 1; else - new_value = *status[index] +value; + new_value = *stats[index] +value; - if (new_value != (int)*status[index]) { - *status[index] = new_value; + if (new_value != (int)*stats[index]) { + *stats[index] = new_value; clif->updatestatus(sd, SP_STR + index); clif->updatestatus(sd, SP_USTR + index); count++; @@ -5440,9 +5438,8 @@ ACMD(useskill) * Debug command to locate new skill IDs. It sends the * three possible skill-effect packets to the area. *------------------------------------------*/ -ACMD(displayskill) -{ - struct status_data * status; +ACMD(displayskill) { + struct status_data *st; unsigned int tick; uint16 skill_id; uint16 skill_lv = 1; @@ -5453,9 +5450,9 @@ ACMD(displayskill) clif->message(fd, msg_txt(1166)); // Usage: @displayskill {} return false; } - status = iStatus->get_status_data(&sd->bl); + st = iStatus->get_status_data(&sd->bl); tick = timer->gettick(); - clif->skill_damage(&sd->bl,&sd->bl, tick, status->amotion, status->dmotion, 1, 1, skill_id, skill_lv, 5); + 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); clif->skill_poseffect(&sd->bl, skill_id, skill_lv, sd->bl.x, sd->bl.y, tick); return true; @@ -7071,10 +7068,9 @@ ACMD(homtalk) /*========================================== * Show homunculus stats *------------------------------------------*/ -ACMD(hominfo) -{ +ACMD(hominfo) { struct homun_data *hd; - struct status_data *status; + struct status_data *st; nullpo_retr(-1, sd); if ( !homun_alive(sd->hd) ) { @@ -7083,15 +7079,15 @@ ACMD(hominfo) } hd = sd->hd; - status = iStatus->get_status_data(&hd->bl); + st = iStatus->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 - status->hp, status->max_hp, status->sp, status->max_sp); + st->hp, st->max_hp, st->sp, st->max_sp); clif->message(fd, atcmd_output); snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1263), // ATK: %d - MATK: %d~%d - status->rhw.atk2 +status->batk, status->matk_min, status->matk_max); + st->rhw.atk2 +st->batk, st->matk_min, st->matk_max); clif->message(fd, atcmd_output); snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1264), // Hungry: %d - Intimacy: %u @@ -7100,8 +7096,8 @@ ACMD(hominfo) snprintf(atcmd_output, sizeof(atcmd_output) , msg_txt(1265), // Stats: Str %d / Agi %d / Vit %d / Int %d / Dex %d / Luk %d - status->str, status->agi, status->vit, - status->int_, status->dex, status->luk); + st->str, st->agi, st->vit, + st->int_, st->dex, st->luk); clif->message(fd, atcmd_output); return true; diff --git a/src/map/battle.c b/src/map/battle.c index 7900581c6..6427fb157 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -501,28 +501,26 @@ int64 battle_calc_weapon_damage(struct block_list *src, struct block_list *bl, u *&16: Arrow attack but BOW, REVOLVER, RIFLE, SHOTGUN, GATLING or GRENADE type weapon not equipped (i.e. shuriken, kunai and venom knives not affected by DEX) */ #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 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 *status = iStatus->get_status_data(src); + struct status_data *st = iStatus->get_status_data(src); - batk = battle->calc_elefix(src, bl, skill_id, skill_lv, iStatus->calc_batk(bl, iStatus->get_sc(src), status->batk, false), nk, n_ele, ELE_NEUTRAL, ELE_NEUTRAL, false, flag); + 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); if( type == EQI_HAND_L ) - damage = batk + 3 * battle->calc_weapon_damage(src, bl, skill_id, skill_lv, &status->lhw, nk, n_ele, s_ele, s_ele_, status_get_size(bl), type, flag, flag2) / 4; + 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; else - damage = (batk << 1) + battle->calc_weapon_damage(src, bl, skill_id, skill_lv, &status->rhw, nk, n_ele, s_ele, s_ele_, status_get_size(bl), type, flag, flag2); + damage = (batk << 1) + battle->calc_weapon_damage(src, bl, skill_id, skill_lv, &st->rhw, nk, n_ele, s_ele, s_ele_, status_get_size(bl), type, flag, flag2); #else -static int64 battle_calc_base_damage(struct status_data *status, struct weapon_atk *wa, struct status_change *sc, unsigned short t_size, struct map_session_data *sd, int flag) -{ +static int64 battle_calc_base_damage(struct status_data *st, struct weapon_atk *wa, struct status_change *sc, unsigned short t_size, struct map_session_data *sd, int flag) { unsigned int atkmin=0, atkmax=0; short type = 0; int64 damage = 0; if (!sd) { //Mobs/Pets if(flag&4) { - atkmin = status->matk_min; - atkmax = status->matk_max; + atkmin = st->matk_min; + atkmax = st->matk_max; } else { atkmin = wa->atk; atkmax = wa->atk2; @@ -531,10 +529,10 @@ static int64 battle_calc_base_damage(struct status_data *status, struct weapon_a atkmin = atkmax; } else { //PCs atkmax = wa->atk; - type = (wa == &status->lhw)?EQI_HAND_L:EQI_HAND_R; + type = (wa == &st->lhw)?EQI_HAND_L:EQI_HAND_R; if (!(flag&1) || (flag&2)) { //Normal attacks - atkmin = status->dex; + atkmin = st->dex; if (sd->equip_index[type] >= 0 && sd->inventory_data[sd->equip_index[type]]) atkmin = atkmin*(80 + sd->inventory_data[sd->equip_index[type]]->wlv*20)/100; @@ -571,9 +569,9 @@ static int64 battle_calc_base_damage(struct status_data *status, struct weapon_a //Finally, add baseatk if(flag&4) - damage += status->matk_min; + damage += st->matk_min; else - damage += status->batk; + damage += st->batk; //rodatazone says that Overrefine bonuses are part of baseatk //Here we also apply the weapon_atk_rate bonus so it is correctly applied on left/right hands. @@ -606,7 +604,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 *status = iStatus->get_status_data(target); + struct status_data *st = iStatus->get_status_data(target); int weapon, skill_lv; damage = dmg; @@ -614,12 +612,12 @@ int64 battle_addmastery(struct map_session_data *sd,struct block_list *target,in if((skill_lv = pc->checkskill(sd,AL_DEMONBANE)) > 0 && target->type == BL_MOB && //This bonus doesnt work against players. - (battle->check_undead(status->race,status->def_ele) || status->race==RC_DEMON) ) + (battle->check_undead(st->race,st->def_ele) || st->race==RC_DEMON) ) damage += (int)(skill_lv*(3+sd->status.base_level/20.0)); //damage += (skill_lv * 3); - if( (skill_lv = pc->checkskill(sd, RA_RANGERMAIN)) > 0 && (status->race == RC_BRUTE || status->race == RC_PLANT || status->race == RC_FISH) ) + if( (skill_lv = pc->checkskill(sd, RA_RANGERMAIN)) > 0 && (st->race == RC_BRUTE || st->race == RC_PLANT || st->race == RC_FISH) ) damage += (skill_lv * 5); - if( (skill_lv = pc->checkskill(sd,NC_RESEARCHFE)) > 0 && (status->def_ele == ELE_FIRE || status->def_ele == ELE_EARTH) ) + if( (skill_lv = pc->checkskill(sd,NC_RESEARCHFE)) > 0 && (st->def_ele == ELE_FIRE || st->def_ele == ELE_EARTH) ) damage += (skill_lv * 10); if( pc_ismadogear(sd) ) damage += 20 + 20 * pc->checkskill(sd, NC_MADOLICENCE); @@ -627,7 +625,7 @@ int64 battle_addmastery(struct map_session_data *sd,struct block_list *target,in if( (skill_lv = pc->checkskill(sd,BS_WEAPONRESEARCH)) > 0 ) damage += (skill_lv * 2); #endif - if((skill_lv = pc->checkskill(sd,HT_BEASTBANE)) > 0 && (status->race==RC_BRUTE || status->race==RC_INSECT) ) { + if((skill_lv = pc->checkskill(sd,HT_BEASTBANE)) > 0 && (st->race==RC_BRUTE || st->race==RC_INSECT) ) { damage += (skill_lv * 4); if (sd->sc.data[SC_SOULLINK] && sd->sc.data[SC_SOULLINK]->val2 == SL_HUNTER) damage += sd->status.str; @@ -1377,7 +1375,7 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block int i; struct status_change *sc, *tsc; struct map_session_data *sd, *tsd; - struct status_data *status, *tstatus; + struct status_data *st, *tst; nullpo_ret(src); nullpo_ret(target); @@ -1386,8 +1384,8 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block tsd = BL_CAST(BL_PC, target); sc = iStatus->get_sc(src); tsc = iStatus->get_sc(target); - status = iStatus->get_status_data(src); - tstatus = iStatus->get_status_data(target); + st = iStatus->get_status_data(src); + tst = iStatus->get_status_data(target); switch(attack_type){ case BF_MAGIC: @@ -1403,7 +1401,7 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block #endif break; case MG_SOULSTRIKE: - if (battle->check_undead(tstatus->race,tstatus->def_ele)) + if (battle->check_undead(tst->race,tst->def_ele)) skillratio += 5*skill_lv; break; case MG_FIREWALL: @@ -1450,10 +1448,10 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block skillratio += 10 * skill_lv - 30; break; case SL_STIN: - skillratio += (tstatus->size!=SZ_SMALL?-99:10*skill_lv); //target size must be small (0) for full damage. + skillratio += (tst->size!=SZ_SMALL?-99:10*skill_lv); //target size must be small (0) for full damage. break; case SL_STUN: - skillratio += (tstatus->size!=SZ_BIG?5*skill_lv:-99); //Full damage is dealt on small/medium targets + 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% @@ -1904,7 +1902,7 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block #ifndef RENEWAL case MO_EXTREMITYFIST: { //Overflow check. [Skotlex] - unsigned int ratio = skillratio + 100*(8 + status->sp/10); + unsigned int ratio = skillratio + 100*(8 + st->sp/10); //You'd need something like 6K SP to reach this max, so should be fine for most purposes. if (ratio > 60000) ratio = 60000; //We leave some room here in case skillratio gets further increased. skillratio = (unsigned short)ratio; @@ -2009,8 +2007,8 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block break; case GS_BULLSEYE: //Only works well against brute/demihumans non bosses. - if((tstatus->race == RC_BRUTE || tstatus->race == RC_DEMIHUMAN) - && !(tstatus->mode&MD_BOSS)) + if((tst->race == RC_BRUTE || tst->race == RC_DEMIHUMAN) + && !(tst->mode&MD_BOSS)) skillratio += 400; break; case GS_TRACKING: @@ -2109,7 +2107,7 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block else skillratio += 200 * skill_lv; skillratio = (skillratio - 100) * (100 + (iStatus->get_lv(src)-100)) / 100; - if( status->rhw.ele == ELE_FIRE ) + if( st->rhw.ele == ELE_FIRE ) skillratio += 100 * skill_lv; break; case RK_CRUSHSTRIKE: @@ -2117,7 +2115,7 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block {//ATK [{Weapon Level * (Weapon Upgrade Level + 6) * 100} + (Weapon ATK) + (Weapon Weight)]% short index = sd->equip_index[EQI_HAND_R]; if( index >= 0 && sd->inventory_data[index] && sd->inventory_data[index]->type == IT_WEAPON ) - skillratio += -100 + sd->inventory_data[index]->weight/10 + status->rhw.atk + + skillratio += -100 + sd->inventory_data[index]->weight/10 + st->rhw.atk + 100 * sd->inventory_data[index]->wlv * (sd->status.inventory[index].refine + 6); } break; @@ -2210,7 +2208,7 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block RE_LVL_DMOD(100); break; case NC_ARMSCANNON: - switch( tstatus->size ) { + switch( tst->size ) { case SZ_SMALL: skillratio += 100 + 500 * skill_lv; break;// Small case SZ_MEDIUM: skillratio += 100 + 400 * skill_lv; break;// Medium case SZ_BIG: skillratio += 100 + 300 * skill_lv; break;// Large @@ -2379,7 +2377,7 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block RE_LVL_DMOD(150); break; case SR_RIDEINLIGHTNING: // ATK [{(Skill Level x 200) + Additional Damage} x Caster Base Level / 100] % - if( (status->rhw.ele) == ELE_WIND || (status->lhw.ele) == ELE_WIND ) + if( (st->rhw.ele) == ELE_WIND || (st->lhw.ele) == ELE_WIND ) skillratio += skill_lv * 50; skillratio += -100 + 200 * skill_lv; RE_LVL_DMOD(100); @@ -2855,11 +2853,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 *status = iStatus->get_status_data(bl); - int per = 100*status->sp / status->max_sp -1; //100% should be counted as the 80~99% interval + struct status_data *sstatus = iStatus->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)*status->max_sp/1000)) + if (!iStatus->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; diff --git a/src/map/battle.h b/src/map/battle.h index f56bff3be..6909160c9 100644 --- a/src/map/battle.h +++ b/src/map/battle.h @@ -546,7 +546,7 @@ struct battle_interface { #ifdef RENEWAL (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); #else - (struct status_data *status, struct weapon_atk *wa, struct status_change *sc, unsigned short t_size, struct map_session_data *sd, int flag); + (struct status_data *st, struct weapon_atk *wa, struct status_change *sc, unsigned short t_size, struct map_session_data *sd, int flag); #endif struct Damage (*calc_misc_attack) (struct block_list *src,struct block_list *target,uint16 skill_id,uint16 skill_lv,int mflag); struct Damage (*calc_magic_attack) (struct block_list *src,struct block_list *target,uint16 skill_id,uint16 skill_lv,int mflag); diff --git a/src/map/chrif.c b/src/map/chrif.c index 87fa0fc0b..15bf80da3 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -598,7 +598,7 @@ void chrif_authok(int fd) { int account_id, group_id, char_id; uint32 login_id1,login_id2; time_t expiration_time; - struct mmo_charstatus* status; + struct mmo_charstatus* charstatus; struct auth_node *node; bool changing_mapservers; TBL_PC* sd; @@ -615,8 +615,8 @@ void chrif_authok(int fd) { expiration_time = (time_t)(int32)RFIFOL(fd,16); group_id = RFIFOL(fd,20); changing_mapservers = (RFIFOB(fd,24)); - status = (struct mmo_charstatus*)RFIFOP(fd,25); - char_id = status->char_id; + charstatus = (struct mmo_charstatus*)RFIFOP(fd,25); + char_id = charstatus->char_id; //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. @@ -646,7 +646,7 @@ void chrif_authok(int fd) { node->char_id == char_id && node->login_id1 == login_id1 ) { //Auth Ok - if (pc->authok(sd, login_id2, expiration_time, group_id, status, changing_mapservers)) + if (pc->authok(sd, login_id2, expiration_time, group_id, charstatus, changing_mapservers)) return; } else { //Auth Failed pc->authfail(sd); diff --git a/src/map/clif.c b/src/map/clif.c index 7bc808eed..488e2cf0f 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -1370,13 +1370,13 @@ int clif_spawn(struct block_list *bl) /// Sends information about owned homunculus to the client (ZC_PROPERTY_HOMUN). [orn] /// 022e .24B .B .W .W .W .W .W .W .W .W .W .W .W .W .W .W .W .W .L .L .W .W void clif_hominfo(struct map_session_data *sd, struct homun_data *hd, int flag) { - struct status_data *status; + struct status_data *hstatus; unsigned char buf[128]; enum homun_type htype; nullpo_retv(hd); - status = &hd->battle_status; + hstatus = &hd->battle_status; htype = homun->class2type(hd->homunculus.class_); memset(buf,0,packet_len(0x22e)); @@ -1388,30 +1388,30 @@ void clif_hominfo(struct map_session_data *sd, struct homun_data *hd, int flag) WBUFW(buf,29)=hd->homunculus.hunger; WBUFW(buf,31)=(unsigned short) (hd->homunculus.intimacy / 100) ; WBUFW(buf,33)=0; // equip id - WBUFW(buf,35)=cap_value(status->rhw.atk2+status->batk, 0, INT16_MAX); - WBUFW(buf,37)=cap_value(status->matk_max, 0, INT16_MAX); - WBUFW(buf,39)=status->hit; + WBUFW(buf,35)=cap_value(hstatus->rhw.atk2+hstatus->batk, 0, INT16_MAX); + WBUFW(buf,37)=cap_value(hstatus->matk_max, 0, INT16_MAX); + WBUFW(buf,39)=hstatus->hit; if (battle_config.hom_setting&0x10) - WBUFW(buf,41)=status->luk/3 + 1; //crit is a +1 decimal value! Just display purpose.[Vicious] + WBUFW(buf,41)=hstatus->luk/3 + 1; //crit is a +1 decimal value! Just display purpose.[Vicious] else - WBUFW(buf,41)=status->cri/10; - WBUFW(buf,43)=status->def + status->vit ; - WBUFW(buf,45)=status->mdef; - WBUFW(buf,47)=status->flee; - WBUFW(buf,49)=(flag)?0:status->amotion; - if (status->max_hp > INT16_MAX) { - WBUFW(buf,51) = status->hp/(status->max_hp/100); + WBUFW(buf,41)=hstatus->cri/10; + WBUFW(buf,43)=hstatus->def + hstatus->vit ; + WBUFW(buf,45)=hstatus->mdef; + WBUFW(buf,47)=hstatus->flee; + WBUFW(buf,49)=(flag)?0:hstatus->amotion; + if (hstatus->max_hp > INT16_MAX) { + WBUFW(buf,51) = hstatus->hp/(hstatus->max_hp/100); WBUFW(buf,53) = 100; } else { - WBUFW(buf,51)=status->hp; - WBUFW(buf,53)=status->max_hp; + WBUFW(buf,51)=hstatus->hp; + WBUFW(buf,53)=hstatus->max_hp; } - if (status->max_sp > INT16_MAX) { - WBUFW(buf,55) = status->sp/(status->max_sp/100); + if (hstatus->max_sp > INT16_MAX) { + WBUFW(buf,55) = hstatus->sp/(hstatus->max_sp/100); WBUFW(buf,57) = 100; } else { - WBUFW(buf,55)=status->sp; - WBUFW(buf,57)=status->max_sp; + WBUFW(buf,55)=hstatus->sp; + WBUFW(buf,57)=hstatus->max_sp; } WBUFL(buf,59)=hd->homunculus.exp; WBUFL(buf,63)=hd->exp_next; @@ -5462,9 +5462,8 @@ void clif_skill_mapinfomessage(struct map_session_data *sd, int type) /// Displays Sense (WZ_ESTIMATION) information window (ZC_MONSTER_INFO). /// 018c .W .W .W .L .W .W .W .W /// .B .B .B .B .B .B .B .B .B -void clif_skill_estimation(struct map_session_data *sd,struct block_list *dst) -{ - struct status_data *status; +void clif_skill_estimation(struct map_session_data *sd,struct block_list *dst) { + struct status_data *dstatus; unsigned char buf[64]; int i;//, fix; @@ -5474,23 +5473,23 @@ void clif_skill_estimation(struct map_session_data *sd,struct block_list *dst) if( dst->type != BL_MOB ) return; - status = iStatus->get_status_data(dst); + dstatus = iStatus->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)=status->size; - WBUFL(buf, 8)=status->hp; - WBUFW(buf,12)= (battle_config.estimation_type&1?status->def:0) - +(battle_config.estimation_type&2?status->def2:0); - WBUFW(buf,14)=status->race; - WBUFW(buf,16)= (battle_config.estimation_type&1?status->mdef:0) - +(battle_config.estimation_type&2?status->mdef2:0); - WBUFW(buf,18)= status->def_ele; + 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,status->def_ele, status->ele_lv); + 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] -// WBUFB(buf,20+i)= (unsigned char)((fix=battle_attr_ratio(i+1,status->def_ele, status->ele_lv))<0?0:fix); +// WBUFB(buf,20+i)= (unsigned char)((fix=battle_attr_ratio(i+1,dstatus->def_ele, dstatus->ele_lv))<0?0:fix); clif->send(buf,packet_len(0x18c),&sd->bl,sd->status.party_id>0?PARTY_SAMEMAP:SELF); } @@ -15668,58 +15667,57 @@ void clif_quest_show_event(struct map_session_data *sd, struct block_list *bl, s /// Notification about a mercenary status parameter change (ZC_MER_PAR_CHANGE). /// 02a2 .W .L -void clif_mercenary_updatestatus(struct map_session_data *sd, int type) -{ +void clif_mercenary_updatestatus(struct map_session_data *sd, int type) { struct mercenary_data *md; - struct status_data *status; + struct status_data *mstatus; int fd; if( sd == NULL || (md = sd->md) == NULL ) return; fd = sd->fd; - status = &md->battle_status; + mstatus = &md->battle_status; WFIFOHEAD(fd,packet_len(0x2a2)); WFIFOW(fd,0) = 0x2a2; WFIFOW(fd,2) = type; switch( type ) { case SP_ATK1: - { - int atk = rnd()%(status->rhw.atk2 - status->rhw.atk + 1) + status->rhw.atk; - WFIFOL(fd,4) = cap_value(atk, 0, INT16_MAX); - } + { + int atk = rnd()%(mstatus->rhw.atk2 - mstatus->rhw.atk + 1) + mstatus->rhw.atk; + WFIFOL(fd,4) = cap_value(atk, 0, INT16_MAX); + } break; case SP_MATK1: - WFIFOL(fd,4) = cap_value(status->matk_max, 0, INT16_MAX); + WFIFOL(fd,4) = cap_value(mstatus->matk_max, 0, INT16_MAX); break; case SP_HIT: - WFIFOL(fd,4) = status->hit; + WFIFOL(fd,4) = mstatus->hit; break; case SP_CRITICAL: - WFIFOL(fd,4) = status->cri/10; + WFIFOL(fd,4) = mstatus->cri/10; break; case SP_DEF1: - WFIFOL(fd,4) = status->def; + WFIFOL(fd,4) = mstatus->def; break; case SP_MDEF1: - WFIFOL(fd,4) = status->mdef; + WFIFOL(fd,4) = mstatus->mdef; break; case SP_MERCFLEE: - WFIFOL(fd,4) = status->flee; + WFIFOL(fd,4) = mstatus->flee; break; case SP_ASPD: - WFIFOL(fd,4) = status->amotion; + WFIFOL(fd,4) = mstatus->amotion; break; case SP_HP: - WFIFOL(fd,4) = status->hp; + WFIFOL(fd,4) = mstatus->hp; break; case SP_MAXHP: - WFIFOL(fd,4) = status->max_hp; + WFIFOL(fd,4) = mstatus->max_hp; break; case SP_SP: - WFIFOL(fd,4) = status->sp; + WFIFOL(fd,4) = mstatus->sp; break; case SP_MAXSP: - WFIFOL(fd,4) = status->max_sp; + WFIFOL(fd,4) = mstatus->max_sp; break; case SP_MERCKILLS: WFIFOL(fd,4) = md->mercenary.kill_count; @@ -15736,39 +15734,38 @@ void clif_mercenary_updatestatus(struct map_session_data *sd, int type) /// 029b .L .W .W .W .W .W .W .W .W /// .24B .W .L .L .L .L .L .W /// .L .L .W -void clif_mercenary_info(struct map_session_data *sd) -{ +void clif_mercenary_info(struct map_session_data *sd) { int fd; struct mercenary_data *md; - struct status_data *status; + struct status_data *mstatus; int atk; if( sd == NULL || (md = sd->md) == NULL ) return; fd = sd->fd; - status = &md->battle_status; + mstatus = &md->battle_status; WFIFOHEAD(fd,packet_len(0x29b)); WFIFOW(fd,0) = 0x29b; WFIFOL(fd,2) = md->bl.id; // Mercenary shows ATK as a random value between ATK ~ ATK2 - atk = rnd()%(status->rhw.atk2 - status->rhw.atk + 1) + status->rhw.atk; + atk = rnd()%(mstatus->rhw.atk2 - mstatus->rhw.atk + 1) + mstatus->rhw.atk; WFIFOW(fd,6) = cap_value(atk, 0, INT16_MAX); - WFIFOW(fd,8) = cap_value(status->matk_max, 0, INT16_MAX); - WFIFOW(fd,10) = status->hit; - WFIFOW(fd,12) = status->cri/10; - WFIFOW(fd,14) = status->def; - WFIFOW(fd,16) = status->mdef; - WFIFOW(fd,18) = status->flee; - WFIFOW(fd,20) = status->amotion; + WFIFOW(fd,8) = cap_value(mstatus->matk_max, 0, INT16_MAX); + WFIFOW(fd,10) = mstatus->hit; + WFIFOW(fd,12) = mstatus->cri/10; + WFIFOW(fd,14) = mstatus->def; + WFIFOW(fd,16) = mstatus->mdef; + WFIFOW(fd,18) = mstatus->flee; + WFIFOW(fd,20) = mstatus->amotion; safestrncpy((char*)WFIFOP(fd,22), md->db->name, NAME_LENGTH); WFIFOW(fd,46) = md->db->lv; - WFIFOL(fd,48) = status->hp; - WFIFOL(fd,52) = status->max_hp; - WFIFOL(fd,56) = status->sp; - WFIFOL(fd,60) = status->max_sp; + WFIFOL(fd,48) = mstatus->hp; + WFIFOL(fd,52) = mstatus->max_hp; + WFIFOL(fd,56) = mstatus->sp; + WFIFOL(fd,60) = mstatus->max_sp; WFIFOL(fd,64) = (int)time(NULL) + (mercenary->get_lifetime(md) / 1000); WFIFOW(fd,68) = mercenary->get_faith(md); WFIFOL(fd,70) = mercenary->get_calls(md); @@ -16291,29 +16288,29 @@ void clif_parse_ItemListWindowSelected(int fd, struct map_session_data* sd) { *==========================================*/ void clif_elemental_updatestatus(struct map_session_data *sd, int type) { struct elemental_data *ed; - struct status_data *status; + struct status_data *estatus; int fd; if( sd == NULL || (ed = sd->ed) == NULL ) return; fd = sd->fd; - status = &ed->battle_status; + estatus = &ed->battle_status; WFIFOHEAD(fd,8); WFIFOW(fd,0) = 0x81e; WFIFOW(fd,2) = type; switch( type ) { case SP_HP: - WFIFOL(fd,4) = status->hp; + WFIFOL(fd,4) = estatus->hp; break; case SP_MAXHP: - WFIFOL(fd,4) = status->max_hp; + WFIFOL(fd,4) = estatus->max_hp; break; case SP_SP: - WFIFOL(fd,4) = status->sp; + WFIFOL(fd,4) = estatus->sp; break; case SP_MAXSP: - WFIFOL(fd,4) = status->max_sp; + WFIFOL(fd,4) = estatus->max_sp; break; } WFIFOSET(fd,8); @@ -16322,21 +16319,21 @@ void clif_elemental_updatestatus(struct map_session_data *sd, int type) { void clif_elemental_info(struct map_session_data *sd) { int fd; struct elemental_data *ed; - struct status_data *status; + struct status_data *estatus; if( sd == NULL || (ed = sd->ed) == NULL ) return; fd = sd->fd; - status = &ed->battle_status; + estatus = &ed->battle_status; WFIFOHEAD(fd,22); WFIFOW(fd, 0) = 0x81d; WFIFOL(fd, 2) = ed->bl.id; - WFIFOL(fd, 6) = status->hp; - WFIFOL(fd,10) = status->max_hp; - WFIFOL(fd,14) = status->sp; - WFIFOL(fd,18) = status->max_sp; + WFIFOL(fd, 6) = estatus->hp; + WFIFOL(fd,10) = estatus->max_hp; + WFIFOL(fd,14) = estatus->sp; + WFIFOL(fd,18) = estatus->max_sp; WFIFOSET(fd,22); } diff --git a/src/map/elemental.c b/src/map/elemental.c index 3a6ab2105..b1ad4073b 100644 --- a/src/map/elemental.c +++ b/src/map/elemental.c @@ -762,7 +762,7 @@ int read_elementaldb(void) { char *str[26]; int i, j = 0, k = 0, ele; struct s_elemental_db *db; - struct status_data *status; + struct status_data *estatus; sprintf(line, "%s/%s", iMap->db_path, "elemental_db.txt"); memset(elemental->elemental_db,0,sizeof(elemental->elemental_db)); @@ -798,44 +798,44 @@ int read_elementaldb(void) { safestrncpy(db->name, str[2], NAME_LENGTH); db->lv = atoi(str[3]); - status = &db->status; + estatus = &db->status; db->vd.class_ = db->class_; - status->max_hp = atoi(str[4]); - status->max_sp = atoi(str[5]); - status->rhw.range = atoi(str[6]); - status->rhw.atk = atoi(str[7]); - status->rhw.atk2 = atoi(str[8]); - status->def = atoi(str[9]); - status->mdef = atoi(str[10]); - status->str = atoi(str[11]); - status->agi = atoi(str[12]); - status->vit = atoi(str[13]); - status->int_ = atoi(str[14]); - status->dex = atoi(str[15]); - status->luk = atoi(str[16]); + estatus->max_hp = atoi(str[4]); + estatus->max_sp = atoi(str[5]); + estatus->rhw.range = atoi(str[6]); + estatus->rhw.atk = atoi(str[7]); + estatus->rhw.atk2 = atoi(str[8]); + estatus->def = atoi(str[9]); + estatus->mdef = atoi(str[10]); + estatus->str = atoi(str[11]); + estatus->agi = atoi(str[12]); + estatus->vit = atoi(str[13]); + estatus->int_ = atoi(str[14]); + estatus->dex = atoi(str[15]); + estatus->luk = atoi(str[16]); db->range2 = atoi(str[17]); db->range3 = atoi(str[18]); - status->size = atoi(str[19]); - status->race = atoi(str[20]); + estatus->size = atoi(str[19]); + estatus->race = atoi(str[20]); ele = atoi(str[21]); - status->def_ele = ele%10; - status->ele_lv = ele/20; - if( status->def_ele >= ELE_MAX ) { - ShowWarning("Elemental %d has invalid element type %d (max element is %d)\n", db->class_, status->def_ele, ELE_MAX - 1); - status->def_ele = ELE_NEUTRAL; + estatus->def_ele = ele%10; + estatus->ele_lv = ele/20; + if( estatus->def_ele >= ELE_MAX ) { + ShowWarning("Elemental %d has invalid element type %d (max element is %d)\n", db->class_, estatus->def_ele, ELE_MAX - 1); + estatus->def_ele = ELE_NEUTRAL; } - if( status->ele_lv < 1 || status->ele_lv > 4 ) { - ShowWarning("Elemental %d has invalid element level %d (max is 4)\n", db->class_, status->ele_lv); - status->ele_lv = 1; + if( estatus->ele_lv < 1 || estatus->ele_lv > 4 ) { + ShowWarning("Elemental %d has invalid element level %d (max is 4)\n", db->class_, estatus->ele_lv); + estatus->ele_lv = 1; } - status->aspd_rate = 1000; - status->speed = atoi(str[22]); - status->adelay = atoi(str[23]); - status->amotion = atoi(str[24]); - status->dmotion = atoi(str[25]); + estatus->aspd_rate = 1000; + estatus->speed = atoi(str[22]); + estatus->adelay = atoi(str[23]); + estatus->amotion = atoi(str[24]); + estatus->dmotion = atoi(str[25]); j++; } diff --git a/src/map/mercenary.c b/src/map/mercenary.c index 0e89d62a9..402c477bf 100644 --- a/src/map/mercenary.c +++ b/src/map/mercenary.c @@ -397,11 +397,10 @@ int mercenary_checkskill(struct mercenary_data *md, uint16 skill_id) return 0; } -static bool read_mercenarydb_sub(char* str[], int columns, int current) -{ +static bool read_mercenarydb_sub(char* str[], int columns, int current) { int ele; struct s_mercenary_db *db; - struct status_data *status; + struct status_data *mstatus; db = &mercenary->db[current]; db->class_ = atoi(str[0]); @@ -409,46 +408,44 @@ static bool read_mercenarydb_sub(char* str[], int columns, int current) safestrncpy(db->name, str[2], NAME_LENGTH); db->lv = atoi(str[3]); - status = &db->status; + mstatus = &db->status; db->vd.class_ = db->class_; - status->max_hp = atoi(str[4]); - status->max_sp = atoi(str[5]); - status->rhw.range = atoi(str[6]); - status->rhw.atk = atoi(str[7]); - status->rhw.atk2 = status->rhw.atk + atoi(str[8]); - status->def = atoi(str[9]); - status->mdef = atoi(str[10]); - status->str = atoi(str[11]); - status->agi = atoi(str[12]); - status->vit = atoi(str[13]); - status->int_ = atoi(str[14]); - status->dex = atoi(str[15]); - status->luk = atoi(str[16]); + mstatus->max_hp = atoi(str[4]); + mstatus->max_sp = atoi(str[5]); + mstatus->rhw.range = atoi(str[6]); + mstatus->rhw.atk = atoi(str[7]); + mstatus->rhw.atk2 = mstatus->rhw.atk + atoi(str[8]); + mstatus->def = atoi(str[9]); + mstatus->mdef = atoi(str[10]); + mstatus->str = atoi(str[11]); + mstatus->agi = atoi(str[12]); + mstatus->vit = atoi(str[13]); + mstatus->int_ = atoi(str[14]); + mstatus->dex = atoi(str[15]); + mstatus->luk = atoi(str[16]); db->range2 = atoi(str[17]); db->range3 = atoi(str[18]); - status->size = atoi(str[19]); - status->race = atoi(str[20]); + mstatus->size = atoi(str[19]); + mstatus->race = atoi(str[20]); ele = atoi(str[21]); - status->def_ele = ele%10; - status->ele_lv = ele/20; - if( status->def_ele >= ELE_MAX ) - { - ShowWarning("Mercenary %d has invalid element type %d (max element is %d)\n", db->class_, status->def_ele, ELE_MAX - 1); - status->def_ele = ELE_NEUTRAL; + mstatus->def_ele = ele%10; + mstatus->ele_lv = ele/20; + if( mstatus->def_ele >= ELE_MAX ) { + ShowWarning("Mercenary %d has invalid element type %d (max element is %d)\n", db->class_, mstatus->def_ele, ELE_MAX - 1); + mstatus->def_ele = ELE_NEUTRAL; } - if( status->ele_lv < 1 || status->ele_lv > 4 ) - { - ShowWarning("Mercenary %d has invalid element level %d (max is 4)\n", db->class_, status->ele_lv); - status->ele_lv = 1; + if( mstatus->ele_lv < 1 || mstatus->ele_lv > 4 ) { + ShowWarning("Mercenary %d has invalid element level %d (max is 4)\n", db->class_, mstatus->ele_lv); + mstatus->ele_lv = 1; } - status->aspd_rate = 1000; - status->speed = atoi(str[22]); - status->adelay = atoi(str[23]); - status->amotion = atoi(str[24]); - status->dmotion = atoi(str[25]); + mstatus->aspd_rate = 1000; + mstatus->speed = atoi(str[22]); + mstatus->adelay = atoi(str[23]); + mstatus->amotion = atoi(str[24]); + mstatus->dmotion = atoi(str[25]); return true; } diff --git a/src/map/mob.c b/src/map/mob.c index d1b6990c4..32bf3d72a 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -2077,9 +2077,8 @@ void mob_damage(struct mob_data *md, struct block_list *src, int damage) { * Signals death of mob. * type&1 -> no drops, type&2 -> no exp *------------------------------------------*/ -int mob_dead(struct mob_data *md, struct block_list *src, int type) -{ - struct status_data *status; +int mob_dead(struct mob_data *md, struct block_list *src, int type) { + struct status_data *mstatus; struct map_session_data *sd = NULL, *tmpsd[DAMAGELOG_SIZE]; struct map_session_data *mvp_sd = NULL, *second_sd = NULL, *third_sd = NULL; @@ -2093,7 +2092,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) unsigned int mvp_damage, tick = timer->gettick(); bool rebirth, homkillonly; - status = &md->status; + mstatus = &md->status; if( src && src->type == BL_PC ) { @@ -2198,7 +2197,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) per = (double)md->dmglog[i].dmg/(double)md->tdmg; else { //eAthena's exp formula based on max hp. - per = (double)md->dmglog[i].dmg/(double)status->max_hp; + per = (double)md->dmglog[i].dmg/(double)mstatus->max_hp; if (per > 2) per = 2; // prevents unlimited exp gain } @@ -2399,8 +2398,8 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) { if ( sd->add_drop[i].race == -md->class_ || ( sd->add_drop[i].race > 0 && ( - sd->add_drop[i].race & (1<race) || - sd->add_drop[i].race & (1<<(status->mode&MD_BOSS?RC_BOSS:RC_NONBOSS)) + sd->add_drop[i].race & (1<race) || + sd->add_drop[i].race & (1<<(mstatus->mode&MD_BOSS?RC_BOSS:RC_NONBOSS)) ))) { //check if the bonus item drop rate should be multiplied with mob level/10 [Lupus] @@ -3323,14 +3322,13 @@ int mob_is_clone(int class_) //If mode is not passed, a default aggressive mode is used. //If master_id is passed, clone is attached to him. //Returns: ID of newly crafted copy. -int mob_clone_spawn(struct map_session_data *sd, int16 m, int16 x, int16 y, const char *event, int master_id, int mode, int flag, unsigned int duration) -{ +int mob_clone_spawn(struct map_session_data *sd, int16 m, int16 x, int16 y, const char *event, int master_id, int mode, int flag, unsigned int duration) { int class_; int i,j,h,inf,skill_id, fd; struct mob_data *md; struct mob_skill *ms; struct mob_db* db; - struct status_data *status; + struct status_data *mstatus; nullpo_ret(sd); @@ -3342,24 +3340,24 @@ int mob_clone_spawn(struct map_session_data *sd, int16 m, int16 x, int16 y, cons return 0; db = mob->db_data[class_]=(struct mob_db*)aCalloc(1, sizeof(struct mob_db)); - status = &db->status; + mstatus = &db->status; 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); - memcpy(status, &sd->base_status, sizeof(struct status_data)); - status->rhw.atk2= status->dex + status->rhw.atk + status->rhw.atk2; //Max ATK - status->rhw.atk = status->dex; //Min ATK - if (status->lhw.atk) { - status->lhw.atk2= status->dex + status->lhw.atk + status->lhw.atk2; //Max ATK - status->lhw.atk = status->dex; //Min ATK + 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 + if (mstatus->lhw.atk) { + mstatus->lhw.atk2= mstatus->dex + mstatus->lhw.atk + mstatus->lhw.atk2; //Max ATK + mstatus->lhw.atk = mstatus->dex; //Min ATK } if (mode) //User provided mode. - status->mode = mode; + mstatus->mode = mode; else if (flag&1) //Friendly Character, remove looting. - status->mode &= ~MD_LOOTER; - status->hp = status->max_hp; - status->sp = status->max_sp; + mstatus->mode &= ~MD_LOOTER; + mstatus->hp = mstatus->max_hp; + mstatus->sp = mstatus->max_sp; memcpy(&db->vd, &sd->vd, sizeof(struct view_data)); db->base_exp=1; db->job_exp=1; @@ -3639,10 +3637,9 @@ static inline int mob_parse_dbrow_cap_value(int class_, int min, int max, int va /*========================================== * processes one mobdb entry *------------------------------------------*/ -bool mob_parse_dbrow(char** str) -{ +bool mob_parse_dbrow(char** str) { struct mob_db *db, entry; - struct status_data *status; + struct status_data *mstatus; int class_, i, k; double exp, maxhp; struct mob_data data; @@ -3666,7 +3663,7 @@ bool mob_parse_dbrow(char** str) memset(&entry, 0, sizeof(entry)); db = &entry; - status = &db->status; + mstatus = &db->status; db->vd.class_ = class_; safestrncpy(db->sprite, str[1], sizeof(db->sprite)); @@ -3674,8 +3671,8 @@ bool mob_parse_dbrow(char** str) safestrncpy(db->name, str[3], sizeof(db->name)); db->lv = atoi(str[4]); db->lv = cap_value(db->lv, 1, USHRT_MAX); - status->max_hp = atoi(str[5]); - status->max_sp = atoi(str[6]); + mstatus->max_hp = atoi(str[5]); + mstatus->max_sp = atoi(str[6]); exp = (double)atoi(str[7]) * (double)battle_config.base_exp_rate / 100.; db->base_exp = (unsigned int)cap_value(exp, 0, UINT_MAX); @@ -3683,28 +3680,28 @@ bool mob_parse_dbrow(char** str) exp = (double)atoi(str[8]) * (double)battle_config.job_exp_rate / 100.; db->job_exp = (unsigned int)cap_value(exp, 0, UINT_MAX); - status->rhw.range = atoi(str[9]); + mstatus->rhw.range = atoi(str[9]); - status->rhw.atk = mob_parse_dbrow_cap_value(class_,UINT16_MIN,UINT16_MAX,atoi(str[10])); - status->rhw.atk2 = mob_parse_dbrow_cap_value(class_,UINT16_MIN,UINT16_MAX,atoi(str[11])); + mstatus->rhw.atk = mob_parse_dbrow_cap_value(class_,UINT16_MIN,UINT16_MAX,atoi(str[10])); + mstatus->rhw.atk2 = mob_parse_dbrow_cap_value(class_,UINT16_MIN,UINT16_MAX,atoi(str[11])); - status->def = mob_parse_dbrow_cap_value(class_,DEFTYPE_MIN,DEFTYPE_MAX,atoi(str[12])); - status->mdef = mob_parse_dbrow_cap_value(class_,DEFTYPE_MIN,DEFTYPE_MAX,atoi(str[13])); + mstatus->def = mob_parse_dbrow_cap_value(class_,DEFTYPE_MIN,DEFTYPE_MAX,atoi(str[12])); + mstatus->mdef = mob_parse_dbrow_cap_value(class_,DEFTYPE_MIN,DEFTYPE_MAX,atoi(str[13])); - status->str = mob_parse_dbrow_cap_value(class_,UINT16_MIN,UINT16_MAX,atoi(str[14])); - status->agi = mob_parse_dbrow_cap_value(class_,UINT16_MIN,UINT16_MAX,atoi(str[15])); - status->vit = mob_parse_dbrow_cap_value(class_,UINT16_MIN,UINT16_MAX,atoi(str[16])); - status->int_ = mob_parse_dbrow_cap_value(class_,UINT16_MIN,UINT16_MAX,atoi(str[17])); - status->dex = mob_parse_dbrow_cap_value(class_,UINT16_MIN,UINT16_MAX,atoi(str[18])); - status->luk = mob_parse_dbrow_cap_value(class_,UINT16_MIN,UINT16_MAX,atoi(str[19])); + mstatus->str = mob_parse_dbrow_cap_value(class_,UINT16_MIN,UINT16_MAX,atoi(str[14])); + mstatus->agi = mob_parse_dbrow_cap_value(class_,UINT16_MIN,UINT16_MAX,atoi(str[15])); + mstatus->vit = mob_parse_dbrow_cap_value(class_,UINT16_MIN,UINT16_MAX,atoi(str[16])); + mstatus->int_ = mob_parse_dbrow_cap_value(class_,UINT16_MIN,UINT16_MAX,atoi(str[17])); + mstatus->dex = mob_parse_dbrow_cap_value(class_,UINT16_MIN,UINT16_MAX,atoi(str[18])); + mstatus->luk = mob_parse_dbrow_cap_value(class_,UINT16_MIN,UINT16_MAX,atoi(str[19])); //All status should be min 1 to prevent divisions by zero from some skills. [Skotlex] - if (status->str < 1) status->str = 1; - if (status->agi < 1) status->agi = 1; - if (status->vit < 1) status->vit = 1; - if (status->int_< 1) status->int_= 1; - if (status->dex < 1) status->dex = 1; - if (status->luk < 1) status->luk = 1; + if (mstatus->str < 1) mstatus->str = 1; + if (mstatus->agi < 1) mstatus->agi = 1; + if (mstatus->vit < 1) mstatus->vit = 1; + if (mstatus->int_< 1) mstatus->int_= 1; + if (mstatus->dex < 1) mstatus->dex = 1; + if (mstatus->luk < 1) mstatus->luk = 1; db->range2 = atoi(str[20]); db->range3 = atoi(str[21]); @@ -3719,44 +3716,44 @@ bool mob_parse_dbrow(char** str) db->range3 = db->range2; } - status->size = atoi(str[22]); - status->race = atoi(str[23]); + mstatus->size = atoi(str[22]); + mstatus->race = atoi(str[23]); i = atoi(str[24]); //Element - status->def_ele = i%10; - status->ele_lv = i/20; - if (status->def_ele >= ELE_MAX) { - ShowError("mob_parse_dbrow: Invalid element type %d for monster ID %d (max=%d).\n", status->def_ele, class_, ELE_MAX-1); + mstatus->def_ele = i%10; + mstatus->ele_lv = i/20; + if (mstatus->def_ele >= ELE_MAX) { + ShowError("mob_parse_dbrow: Invalid element type %d for monster ID %d (max=%d).\n", mstatus->def_ele, class_, ELE_MAX-1); return false; } - if (status->ele_lv < 1 || status->ele_lv > 4) { - ShowError("mob_parse_dbrow: Invalid element level %d for monster ID %d, must be in range 1-4.\n", status->ele_lv, class_); + if (mstatus->ele_lv < 1 || mstatus->ele_lv > 4) { + ShowError("mob_parse_dbrow: Invalid element level %d for monster ID %d, must be in range 1-4.\n", mstatus->ele_lv, class_); return false; } - status->mode = (int)strtol(str[25], NULL, 0); + mstatus->mode = (int)strtol(str[25], NULL, 0); if (!battle_config.monster_active_enable) - status->mode &= ~MD_AGGRESSIVE; + mstatus->mode &= ~MD_AGGRESSIVE; - status->speed = atoi(str[26]); - status->aspd_rate = 1000; + mstatus->speed = atoi(str[26]); + mstatus->aspd_rate = 1000; i = atoi(str[27]); - status->adelay = cap_value(i, battle_config.monster_max_aspd*2, 4000); + mstatus->adelay = cap_value(i, battle_config.monster_max_aspd*2, 4000); i = atoi(str[28]); - status->amotion = cap_value(i, battle_config.monster_max_aspd, 2000); + mstatus->amotion = cap_value(i, battle_config.monster_max_aspd, 2000); //If the attack animation is longer than the delay, the client crops the attack animation! //On aegis there is no real visible effect of having a recharge-time less than amotion anyway. - if (status->adelay < status->amotion) - status->adelay = status->amotion; - status->dmotion = atoi(str[29]); + if (mstatus->adelay < mstatus->amotion) + mstatus->adelay = mstatus->amotion; + mstatus->dmotion = atoi(str[29]); if(battle_config.monster_damage_delay_rate != 100) - status->dmotion = status->dmotion * battle_config.monster_damage_delay_rate / 100; + mstatus->dmotion = mstatus->dmotion * battle_config.monster_damage_delay_rate / 100; // Fill in remaining status data by using a dummy monster. data.bl.type = BL_MOB; data.level = db->lv; - memcpy(&data.status, status, sizeof(struct status_data)); - iStatus->calc_misc(&data.bl, status, db->lv); + memcpy(&data.status, mstatus, sizeof(struct status_data)); + iStatus->calc_misc(&data.bl, mstatus, db->lv); // MVP EXP Bonus: MEXP // Some new MVP's MEXP multipled by high exp-rate cause overflow. [LuzZza] @@ -3764,7 +3761,7 @@ bool mob_parse_dbrow(char** str) db->mexp = (unsigned int)cap_value(exp, 0, UINT_MAX); //Now that we know if it is an mvp or not, apply battle_config modifiers [Skotlex] - maxhp = (double)status->max_hp; + maxhp = (double)mstatus->max_hp; if (db->mexp > 0) { //Mvp if (battle_config.mvp_hp_rate != 100) maxhp = maxhp * (double)battle_config.mvp_hp_rate / 100.; @@ -3772,12 +3769,12 @@ bool mob_parse_dbrow(char** str) if (battle_config.monster_hp_rate != 100) maxhp = maxhp * (double)battle_config.monster_hp_rate / 100.; - status->max_hp = (unsigned int)cap_value(maxhp, 1, UINT_MAX); - if(status->max_sp < 1) status->max_sp = 1; + mstatus->max_hp = (unsigned int)cap_value(maxhp, 1, UINT_MAX); + if(mstatus->max_sp < 1) mstatus->max_sp = 1; //Since mobs always respawn with full life... - status->hp = status->max_hp; - status->sp = status->max_sp; + mstatus->hp = mstatus->max_hp; + mstatus->sp = mstatus->max_sp; // MVP Drops: MVP1id,MVP1per,MVP2id,MVP2per,MVP3id,MVP3per for(i = 0; i < MAX_MVP_DROP; i++) { @@ -3823,30 +3820,30 @@ bool mob_parse_dbrow(char** str) else switch (type) { // Added suport to restrict normal drops of MVP's [Reddozen] case IT_HEALING: - rate_adjust = (status->mode&MD_BOSS) ? battle_config.item_rate_heal_boss : battle_config.item_rate_heal; + rate_adjust = (mstatus->mode&MD_BOSS) ? battle_config.item_rate_heal_boss : battle_config.item_rate_heal; ratemin = battle_config.item_drop_heal_min; ratemax = battle_config.item_drop_heal_max; break; case IT_USABLE: case IT_CASH: - rate_adjust = (status->mode&MD_BOSS) ? battle_config.item_rate_use_boss : battle_config.item_rate_use; + rate_adjust = (mstatus->mode&MD_BOSS) ? battle_config.item_rate_use_boss : battle_config.item_rate_use; ratemin = battle_config.item_drop_use_min; ratemax = battle_config.item_drop_use_max; break; case IT_WEAPON: case IT_ARMOR: case IT_PETARMOR: - rate_adjust = (status->mode&MD_BOSS) ? battle_config.item_rate_equip_boss : battle_config.item_rate_equip; + rate_adjust = (mstatus->mode&MD_BOSS) ? battle_config.item_rate_equip_boss : battle_config.item_rate_equip; ratemin = battle_config.item_drop_equip_min; ratemax = battle_config.item_drop_equip_max; break; case IT_CARD: - rate_adjust = (status->mode&MD_BOSS) ? battle_config.item_rate_card_boss : battle_config.item_rate_card; + rate_adjust = (mstatus->mode&MD_BOSS) ? battle_config.item_rate_card_boss : battle_config.item_rate_card; ratemin = battle_config.item_drop_card_min; ratemax = battle_config.item_drop_card_max; break; default: - rate_adjust = (status->mode&MD_BOSS) ? battle_config.item_rate_common_boss : battle_config.item_rate_common; + rate_adjust = (mstatus->mode&MD_BOSS) ? battle_config.item_rate_common_boss : battle_config.item_rate_common; ratemin = battle_config.item_drop_common_min; ratemax = battle_config.item_drop_common_max; break; diff --git a/src/map/pc.c b/src/map/pc.c index 441230c29..c485baa43 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -444,20 +444,20 @@ unsigned char pc_famerank(int char_id, int job) } int pc_setrestartvalue(struct map_session_data *sd,int type) { - struct status_data *status, *b_status; + struct status_data *st, *bst; nullpo_ret(sd); - b_status = &sd->base_status; - status = &sd->battle_status; + bst = &sd->base_status; + st = &sd->battle_status; if (type&1) { //Normal resurrection - status->hp = 1; //Otherwise iStatus->heal may fail if dead. - iStatus->heal(&sd->bl, b_status->hp, 0, 1); - if( status->sp < b_status->sp ) - iStatus->set_sp(&sd->bl, b_status->sp, 1); + st->hp = 1; //Otherwise iStatus->heal may fail if dead. + iStatus->heal(&sd->bl, bst->hp, 0, 1); + if( st->sp < bst->sp ) + iStatus->set_sp(&sd->bl, bst->sp, 1); } else { //Just for saving on the char-server (with values as if respawned) - sd->status.hp = b_status->hp; - sd->status.sp = (status->sp < b_status->sp)?b_status->sp:status->sp; + sd->status.hp = bst->hp; + sd->status.sp = (st->sp < bst->sp) ? bst->sp : st->sp; } return 0; } @@ -2100,13 +2100,12 @@ int pc_bonus_subele(struct map_session_data* sd, unsigned char ele, short rate, /*========================================== * Add a bonus(type) to player sd *------------------------------------------*/ -int pc_bonus(struct map_session_data *sd,int type,int val) -{ - struct status_data *status; +int pc_bonus(struct map_session_data *sd,int type,int val) { + struct status_data *bst; int bonus; nullpo_ret(sd); - status = &sd->base_status; + bst = &sd->base_status; switch(type){ case SP_STR: @@ -2120,57 +2119,57 @@ int pc_bonus(struct map_session_data *sd,int type,int val) break; case SP_ATK1: if(!sd->state.lr_flag) { - bonus = status->rhw.atk + val; - status->rhw.atk = cap_value(bonus, 0, USHRT_MAX); + bonus = bst->rhw.atk + val; + bst->rhw.atk = cap_value(bonus, 0, USHRT_MAX); } else if(sd->state.lr_flag == 1) { - bonus = status->lhw.atk + val; - status->lhw.atk = cap_value(bonus, 0, USHRT_MAX); + bonus = bst->lhw.atk + val; + bst->lhw.atk = cap_value(bonus, 0, USHRT_MAX); } break; case SP_ATK2: if(!sd->state.lr_flag) { - bonus = status->rhw.atk2 + val; - status->rhw.atk2 = cap_value(bonus, 0, USHRT_MAX); + bonus = bst->rhw.atk2 + val; + bst->rhw.atk2 = cap_value(bonus, 0, USHRT_MAX); } else if(sd->state.lr_flag == 1) { - bonus = status->lhw.atk2 + val; - status->lhw.atk2 = cap_value(bonus, 0, USHRT_MAX); + bonus = bst->lhw.atk2 + val; + bst->lhw.atk2 = cap_value(bonus, 0, USHRT_MAX); } break; case SP_BASE_ATK: if(sd->state.lr_flag != 2) { #ifdef RENEWAL - status->equip_atk += val; + bst->equip_atk += val; #else - bonus = status->batk + val; - status->batk = cap_value(bonus, 0, USHRT_MAX); + bonus = bst->batk + val; + bst->batk = cap_value(bonus, 0, USHRT_MAX); #endif } break; case SP_DEF1: if(sd->state.lr_flag != 2) { - bonus = status->def + val; + bonus = bst->def + val; #ifdef RENEWAL - status->def = cap_value(bonus, SHRT_MIN, SHRT_MAX); + bst->def = cap_value(bonus, SHRT_MIN, SHRT_MAX); #else - status->def = cap_value(bonus, CHAR_MIN, CHAR_MAX); + bst->def = cap_value(bonus, CHAR_MIN, CHAR_MAX); #endif } break; case SP_DEF2: if(sd->state.lr_flag != 2) { - bonus = status->def2 + val; - status->def2 = cap_value(bonus, SHRT_MIN, SHRT_MAX); + bonus = bst->def2 + val; + bst->def2 = cap_value(bonus, SHRT_MIN, SHRT_MAX); } break; case SP_MDEF1: if(sd->state.lr_flag != 2) { - bonus = status->mdef + val; + bonus = bst->mdef + val; #ifdef RENEWAL - status->mdef = cap_value(bonus, SHRT_MIN, SHRT_MAX); + bst->mdef = cap_value(bonus, SHRT_MIN, SHRT_MAX); #else - status->mdef = cap_value(bonus, CHAR_MIN, CHAR_MAX); + bst->mdef = cap_value(bonus, CHAR_MIN, CHAR_MAX); #endif if( sd->state.lr_flag == 3 ) {//Shield, used for royal guard sd->bonus.shieldmdef += bonus; @@ -2179,33 +2178,33 @@ int pc_bonus(struct map_session_data *sd,int type,int val) break; case SP_MDEF2: if(sd->state.lr_flag != 2) { - bonus = status->mdef2 + val; - status->mdef2 = cap_value(bonus, SHRT_MIN, SHRT_MAX); + bonus = bst->mdef2 + val; + bst->mdef2 = cap_value(bonus, SHRT_MIN, SHRT_MAX); } break; case SP_HIT: if(sd->state.lr_flag != 2) { - bonus = status->hit + val; - status->hit = cap_value(bonus, SHRT_MIN, SHRT_MAX); + bonus = bst->hit + val; + bst->hit = cap_value(bonus, SHRT_MIN, SHRT_MAX); } else sd->bonus.arrow_hit+=val; break; case SP_FLEE1: if(sd->state.lr_flag != 2) { - bonus = status->flee + val; - status->flee = cap_value(bonus, SHRT_MIN, SHRT_MAX); + bonus = bst->flee + val; + bst->flee = cap_value(bonus, SHRT_MIN, SHRT_MAX); } break; case SP_FLEE2: if(sd->state.lr_flag != 2) { - bonus = status->flee2 + val*10; - status->flee2 = cap_value(bonus, SHRT_MIN, SHRT_MAX); + bonus = bst->flee2 + val*10; + bst->flee2 = cap_value(bonus, SHRT_MIN, SHRT_MAX); } break; case SP_CRITICAL: if(sd->state.lr_flag != 2) { - bonus = status->cri + val*10; - status->cri = cap_value(bonus, SHRT_MIN, SHRT_MAX); + bonus = bst->cri + val*10; + bst->cri = cap_value(bonus, SHRT_MIN, SHRT_MAX); } else sd->bonus.arrow_cri += val*10; break; @@ -2214,8 +2213,7 @@ int pc_bonus(struct map_session_data *sd,int type,int val) ShowError("pc_bonus: SP_ATKELE: Invalid element %d\n", val); break; } - switch (sd->state.lr_flag) - { + switch (sd->state.lr_flag) { case 2: switch (sd->status.weapon) { case W_BOW: @@ -2225,7 +2223,7 @@ int pc_bonus(struct map_session_data *sd,int type,int val) case W_SHOTGUN: case W_GRENADE: //Become weapon element. - status->rhw.ele=val; + bst->rhw.ele=val; break; default: //Become arrow element. sd->bonus.arrow_ele=val; @@ -2233,10 +2231,10 @@ int pc_bonus(struct map_session_data *sd,int type,int val) } break; case 1: - status->lhw.ele=val; + bst->lhw.ele=val; break; default: - status->rhw.ele=val; + bst->rhw.ele=val; break; } break; @@ -2246,21 +2244,21 @@ int pc_bonus(struct map_session_data *sd,int type,int val) break; } if(sd->state.lr_flag != 2) - status->def_ele=val; + bst->def_ele=val; break; case SP_MAXHP: if(sd->state.lr_flag == 2) break; - val += (int)status->max_hp; + val += (int)bst->max_hp; //Negative bonuses will underflow, this will be handled in status_calc_pc through casting //If this is called outside of status_calc_pc, you'd better pray they do not underflow and end with UINT_MAX max_hp. - status->max_hp = (unsigned int)val; + bst->max_hp = (unsigned int)val; break; case SP_MAXSP: if(sd->state.lr_flag == 2) break; - val += (int)status->max_sp; - status->max_sp = (unsigned int)val; + val += (int)bst->max_sp; + bst->max_sp = (unsigned int)val; break; #ifndef RENEWAL_CAST case SP_VARCASTRATE: @@ -2291,14 +2289,14 @@ int pc_bonus(struct map_session_data *sd,int type,int val) case W_GATLING: case W_SHOTGUN: case W_GRENADE: - status->rhw.range += val; + bst->rhw.range += val; } break; case 1: - status->lhw.range += val; + bst->lhw.range += val; break; default: - status->rhw.range += val; + bst->rhw.range += val; break; } break; @@ -2317,9 +2315,9 @@ int pc_bonus(struct map_session_data *sd,int type,int val) case SP_ASPD_RATE: //Stackable increase - Made it linear as per rodatazone if(sd->state.lr_flag != 2) #ifndef RENEWAL_ASPD - status->aspd_rate -= 10*val; + bst->aspd_rate -= 10*val; #else - status->aspd_rate2 += val; + bst->aspd_rate2 += val; #endif break; case SP_HP_RECOV_RATE: @@ -5855,14 +5853,13 @@ int pc_checkjoblevelup(struct map_session_data *sd) /*========================================== * Alters experienced based on self bonuses that do not get even shared to the party. *------------------------------------------*/ -static void pc_calcexp(struct map_session_data *sd, unsigned int *base_exp, unsigned int *job_exp, struct block_list *src) -{ +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 *status = iStatus->get_status_data(src); + struct status_data *st = iStatus->get_status_data(src); - if (sd->expaddrace[status->race]) - bonus += sd->expaddrace[status->race]; - bonus += sd->expaddrace[status->mode&MD_BOSS?RC_BOSS:RC_NONBOSS]; + 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) diff --git a/src/map/pet.c b/src/map/pet.c index d064ddfe0..bb5982e7a 100644 --- a/src/map/pet.c +++ b/src/map/pet.c @@ -1114,10 +1114,9 @@ int pet_recovery_timer(int tid, unsigned int tick, int id, intptr_t data) return 0; } -int pet_heal_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 status_data *status; + struct status_data *st; struct pet_data *pd; unsigned int rate = 100; @@ -1131,11 +1130,11 @@ int pet_heal_timer(int tid, unsigned int tick, int id, intptr_t data) return 0; } - status = iStatus->get_status_data(&sd->bl); + st = iStatus->get_status_data(&sd->bl); if(pc_isdead(sd) || - (rate = get_percentage(status->sp, status->max_sp)) > pd->s_skill->sp || - (rate = get_percentage(status->hp, status->max_hp)) > pd->s_skill->hp || + (rate = get_percentage(st->sp, st->max_sp)) > pd->s_skill->sp || + (rate = get_percentage(st->hp, st->max_hp)) > pd->s_skill->hp || (rate = (pd->ud.skilltimer != INVALID_TIMER)) //Another skill is in effect ) { //Wait (how long? 1 sec for every 10% of remaining) pd->s_skill->timer=timer->add(timer->gettick()+(rate>10?rate:10)*100,pet->heal_timer,sd->bl.id,0); @@ -1152,11 +1151,10 @@ 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) -{ +int pet_skill_support_timer(int tid, unsigned int tick, int id, intptr_t data) { struct map_session_data *sd=iMap->id2sd(id); struct pet_data *pd; - struct status_data *status; + struct status_data *st; short rate = 100; if(sd==NULL || sd->pd == NULL || sd->pd->s_skill == NULL) return 1; @@ -1168,7 +1166,7 @@ int pet_skill_support_timer(int tid, unsigned int tick, int id, intptr_t data) return 0; } - status = iStatus->get_status_data(&sd->bl); + st = iStatus->get_status_data(&sd->bl); if (DIFF_TICK(pd->ud.canact_tick, tick) > 0) { //Wait until the pet can act again. @@ -1177,8 +1175,8 @@ int pet_skill_support_timer(int tid, unsigned int tick, int id, intptr_t data) } if(pc_isdead(sd) || - (rate = get_percentage(status->sp, status->max_sp)) > pd->s_skill->sp || - (rate = get_percentage(status->hp, status->max_hp)) > pd->s_skill->hp || + (rate = get_percentage(st->sp, st->max_sp)) > pd->s_skill->sp || + (rate = get_percentage(st->hp, st->max_hp)) > pd->s_skill->hp || (rate = (pd->ud.skilltimer != INVALID_TIMER)) //Another skill is in effect ) { //Wait (how long? 1 sec for every 10% of remaining) pd->s_skill->timer=timer->add(tick+(rate>10?rate:10)*100,pet->skill_support_timer,sd->bl.id,0); diff --git a/src/map/quest.c b/src/map/quest.c index 881037081..40030560a 100644 --- a/src/map/quest.c +++ b/src/map/quest.c @@ -226,7 +226,7 @@ void quest_update_objective(TBL_PC * sd, int mob_id) { } } -int quest_update_status(TBL_PC * sd, int quest_id, quest_state status) { +int quest_update_status(TBL_PC * sd, int quest_id, quest_state qs) { int i; //Only status of active and inactive quests can be updated. Completed quests can't (for now). [Inkfish] @@ -236,11 +236,11 @@ int quest_update_status(TBL_PC * sd, int quest_id, quest_state status) { return -1; } - sd->quest_log[i].state = status; + sd->quest_log[i].state = qs; sd->save_quest = true; - if( status < Q_COMPLETE ) { - clif->quest_update_status(sd, quest_id, (bool)status); + if( qs < Q_COMPLETE ) { + clif->quest_update_status(sd, quest_id, (bool)qs); return 0; } diff --git a/src/map/quest.h b/src/map/quest.h index c127dd402..340bc8608 100644 --- a/src/map/quest.h +++ b/src/map/quest.h @@ -29,7 +29,7 @@ struct quest_interface { int (*delete) (TBL_PC *sd, int quest_id); int (*update_objective_sub) (struct block_list *bl, va_list ap); void (*update_objective) (TBL_PC *sd, int mob_id); - int (*update_status) (TBL_PC *sd, int quest_id, quest_state status); + int (*update_status) (TBL_PC *sd, int quest_id, quest_state qs); int (*check) (TBL_PC *sd, int quest_id, quest_check_type type); int (*read_db) (void); }; diff --git a/src/map/skill.c b/src/map/skill.c index 3669431f0..3e9817faf 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -688,7 +688,6 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, uint struct status_data *sstatus, *tstatus; struct status_change *sc, *tsc; - enum sc_type status; int temp; int rate; @@ -1074,9 +1073,9 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, uint break; case LK_JOINTBEAT: - status = iStatus->skill2sc(skill_id); if (tsc->jb_flag) { - sc_start4(bl,status,(5*skill_lv+5),skill_lv,tsc->jb_flag&BREAK_FLAGS,src->id,0,skill->get_time2(skill_id,skill_lv)); + enum sc_type type = iStatus->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; } break; @@ -2155,8 +2154,7 @@ int skill_magic_reflect(struct block_list* src, struct block_list* bl, int type) * flag&0x2000 is used to signal that the skill_lv should be passed as -1 to the * client (causes player characters to not scream skill name) *-------------------------------------------------------------------------*/ -int skill_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 skill_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) { struct Damage dmg; struct status_data *sstatus, *tstatus; struct status_change *sc; @@ -2263,11 +2261,11 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds 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 *status = iStatus->get_status_data(bl); - int per = 100*status->sp / status->max_sp -1; //100% should be counted as the 80~99% interval + struct status_data *st = iStatus->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)*status->max_sp/1000)) + if (!iStatus->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; @@ -2967,7 +2965,7 @@ int skill_check_unit_range2 (struct block_list *bl, int x, int y, uint16 skill_i * &2: picked menu entry (Warp Portal, Teleport and other menu based skills) *------------------------------------------*/ int skill_check_condition_mercenary(struct block_list *bl, int skill_id, int lv, int type) { - struct status_data *status; + struct status_data *st; struct map_session_data *sd = NULL; int i, hp, sp, hp_rate, sp_rate, state, mhp; uint16 idx; @@ -2983,7 +2981,7 @@ int skill_check_condition_mercenary(struct block_list *bl, int skill_id, int lv, case BL_MER: sd = ((TBL_MER*)bl)->master; break; } - status = iStatus->get_status_data(bl); + st = iStatus->get_status_data(bl); if( (idx = skill->get_index(skill_id)) == 0 ) return 0; @@ -2999,15 +2997,15 @@ int skill_check_condition_mercenary(struct block_list *bl, int skill_id, int lv, sp_rate = skill_db[idx].sp_rate[lv-1]; state = skill_db[idx].state; if( (mhp = skill_db[idx].mhp[lv-1]) > 0 ) - hp += (status->max_hp * mhp) / 100; + hp += (st->max_hp * mhp) / 100; if( hp_rate > 0 ) - hp += (status->hp * hp_rate) / 100; + hp += (st->hp * hp_rate) / 100; else - hp += (status->max_hp * (-hp_rate)) / 100; + hp += (st->max_hp * (-hp_rate)) / 100; if( sp_rate > 0 ) - sp += (status->sp * sp_rate) / 100; + sp += (st->sp * sp_rate) / 100; else - sp += (status->max_sp * (-sp_rate)) / 100; + sp += (st->max_sp * (-sp_rate)) / 100; if( bl->type == BL_HOM ) { // Intimacy Requeriments struct homun_data *hd = BL_CAST(BL_HOM, bl); @@ -3024,11 +3022,11 @@ int skill_check_condition_mercenary(struct block_list *bl, int skill_id, int lv, } if( !(type&2) ) { - if( hp > 0 && status->hp <= (unsigned int)hp ) { + if( hp > 0 && st->hp <= (unsigned int)hp ) { clif->skill_fail(sd, skill_id, USESKILL_FAIL_HP_INSUFFICIENT, 0); return 0; } - if( sp > 0 && status->sp <= (unsigned int)sp ) { + if( sp > 0 && st->sp <= (unsigned int)sp ) { clif->skill_fail(sd, skill_id, USESKILL_FAIL_SP_INSUFFICIENT, 0); return 0; } @@ -10497,14 +10495,13 @@ int skill_icewall_block(struct block_list *bl,va_list ap) { * Initializes and sets a ground skill. * flag&1 is used to determine when the skill 'morphs' (Warp portal becomes active, or Fire Pillar becomes active) *------------------------------------------*/ -struct skill_unit_group* skill_unitsetting (struct block_list *src, uint16 skill_id, uint16 skill_lv, int16 x, int16 y, int flag) -{ +struct skill_unit_group* skill_unitsetting(struct block_list *src, uint16 skill_id, uint16 skill_lv, int16 x, int16 y, int flag) { struct skill_unit_group *group; int i,limit,val1=0,val2=0,val3=0; int target,interval,range,unit_flag,req_item=0; struct s_skill_unit_layout *layout; struct map_session_data *sd; - struct status_data *status; + struct status_data *st; struct status_change *sc; int active_flag=1; int subunt=0; @@ -10527,7 +10524,7 @@ struct skill_unit_group* skill_unitsetting (struct block_list *src, uint16 skill } sd = BL_CAST(BL_PC, src); - status = iStatus->get_status_data(src); + st = iStatus->get_status_data(src); sc = iStatus->get_sc(src); // for traps, firewall and fogwall - celest switch( skill_id ) { @@ -10652,18 +10649,18 @@ struct skill_unit_group* skill_unitsetting (struct block_list *src, uint16 skill case BA_DISSONANCE: case DC_UGLYDANCE: - val1 = 10; //FIXME: This value is not used anywhere, what is it for? [Skotlex] + val1 = 10; //FIXME: This value is not used anywhere, what is it for? [Skotlex] break; case BA_WHISTLE: - val1 = skill_lv +status->agi/10; // Flee increase - val2 = ((skill_lv+1)/2)+status->luk/10; // Perfect dodge increase + val1 = skill_lv +st->agi/10; // Flee increase + val2 = ((skill_lv+1)/2)+st->luk/10; // Perfect dodge increase if(sd){ val1 += pc->checkskill(sd,BA_MUSICALLESSON); val2 += pc->checkskill(sd,BA_MUSICALLESSON); } break; case DC_HUMMING: - val1 = 2*skill_lv+status->dex/10; // Hit increase + val1 = 2*skill_lv+st->dex/10; // Hit increase #ifdef RENEWAL val1 *= 2; #endif @@ -10671,9 +10668,9 @@ struct skill_unit_group* skill_unitsetting (struct block_list *src, uint16 skill val1 += pc->checkskill(sd,DC_DANCINGLESSON); break; case BA_POEMBRAGI: - val1 = 3*skill_lv+status->dex/10; // Casting time reduction + val1 = 3*skill_lv+st->dex/10; // Casting time reduction //For some reason at level 10 the base delay reduction is 50%. - val2 = (skill_lv<10?3*skill_lv:50)+status->int_/5; // After-cast delay reduction + val2 = (skill_lv<10?3*skill_lv:50)+st->int_/5; // After-cast delay reduction if(sd){ val1 += 2*pc->checkskill(sd,BA_MUSICALLESSON); val2 += 2*pc->checkskill(sd,BA_MUSICALLESSON); @@ -10681,11 +10678,11 @@ struct skill_unit_group* skill_unitsetting (struct block_list *src, uint16 skill break; case DC_DONTFORGETME: #ifdef RENEWAL - val1 = status->dex/10 + 3*skill_lv; // ASPD decrease - val2 = status->agi/10 + 2*skill_lv; // Movement speed adjustment. + val1 = st->dex/10 + 3*skill_lv; // ASPD decrease + val2 = st->agi/10 + 2*skill_lv; // Movement speed adjustment. #else - val1 = status->dex/10 + 3*skill_lv + 5; // ASPD decrease - val2 = status->agi/10 + 3*skill_lv + 5; // Movement speed adjustment. + val1 = st->dex/10 + 3*skill_lv + 5; // ASPD decrease + val2 = st->agi/10 + 3*skill_lv + 5; // Movement speed adjustment. #endif if(sd){ val1 += pc->checkskill(sd,DC_DANCINGLESSON); @@ -10693,13 +10690,13 @@ struct skill_unit_group* skill_unitsetting (struct block_list *src, uint16 skill } break; case BA_APPLEIDUN: - val1 = 5+2*skill_lv+status->vit/10; // MaxHP percent increase + val1 = 5+2*skill_lv+st->vit/10; // MaxHP percent increase if(sd) val1 += pc->checkskill(sd,BA_MUSICALLESSON); break; case DC_SERVICEFORYOU: - val1 = 15+skill_lv+(status->int_/10); // MaxSP percent increase TO-DO: this INT bonus value is guessed - val2 = 20+3*skill_lv+(status->int_/10); // SP cost reduction + val1 = 15+skill_lv+(st->int_/10); // MaxSP percent increase TO-DO: this INT bonus value is guessed + val2 = 20+3*skill_lv+(st->int_/10); // SP cost reduction if(sd){ val1 += pc->checkskill(sd,DC_DANCINGLESSON); //TO-DO This bonus value is guessed val2 += pc->checkskill(sd,DC_DANCINGLESSON); //TO-DO Should be half this value @@ -10707,17 +10704,17 @@ struct skill_unit_group* skill_unitsetting (struct block_list *src, uint16 skill break; case BA_ASSASSINCROSS: #ifdef RENEWAL - val1 = 10 + skill_lv + (status->agi/10); // ASPD increase + val1 = 10 + skill_lv + (st->agi/10); // ASPD increase if(sd) val1 += 4*pc->checkskill(sd,BA_MUSICALLESSON); #else - val1 = 100+(10*skill_lv)+(status->agi/10); // ASPD increase + val1 = 100+(10*skill_lv)+(st->agi/10); // ASPD increase if(sd) val1 += 5*pc->checkskill(sd,BA_MUSICALLESSON); #endif break; case DC_FORTUNEKISS: - val1 = 10+skill_lv+(status->luk/10); // Critical increase + val1 = 10+skill_lv+(st->luk/10); // Critical increase if(sd) val1 += pc->checkskill(sd,DC_DANCINGLESSON); val1*=10; //Because every 10 crit is an actual cri point. @@ -10765,7 +10762,7 @@ struct skill_unit_group* skill_unitsetting (struct block_list *src, uint16 skill { int element[5]={ELE_WIND,ELE_DARK,ELE_POISON,ELE_WATER,ELE_FIRE}; - val1 = status->rhw.ele; + val1 = st->rhw.ele; if (!val1) val1=element[rnd()%5]; @@ -12334,7 +12331,7 @@ int skill_isammotype (struct map_session_data *sd, int skill_id) } int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id, uint16 skill_lv) { - struct status_data *status; + struct status_data *st; struct status_change *sc; struct skill_condition require; int i; @@ -12370,7 +12367,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id return 0; break; } - status = &sd->battle_status; + st = &sd->battle_status; sc = &sd->sc; if( !sc->count ) sc = NULL; @@ -12695,9 +12692,8 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id break; //Auron insists we should implement SP consumption when you are not Soul Linked. [Skotlex] //Only invoke on skill begin cast (instant cast skill). [Kevin] - if( require.sp > 0 ) - { - if (status->sp < (unsigned int)require.sp) + if( require.sp > 0 ) { + if (st->sp < (unsigned int)require.sp) clif->skill_fail(sd,skill_id,USESKILL_FAIL_SP_INSUFFICIENT,0); else status_zap(&sd->bl, 0, require.sp); @@ -12725,9 +12721,9 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id case NJ_ISSEN: #ifdef RENEWAL - if (status->hp < (status->hp/100)) { + if (st->hp < (st->hp/100)) { #else - if (status->hp < 2) { + if (st->hp < 2) { #endif clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); return 0; @@ -12747,7 +12743,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id } break; case PF_HPCONVERSION: - if (status->sp == status->max_sp) + if (st->sp == st->max_sp) return 0; //Unusable when at full SP. break; case AM_CALLHOMUN: //Can't summon if a hom is already out @@ -13162,7 +13158,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id break; } - if(require.mhp > 0 && get_percentage(status->hp, status->max_hp) > require.mhp) { + if(require.mhp > 0 && get_percentage(st->hp, st->max_hp) > require.mhp) { //mhp is the max-hp-requirement, that is, //you must have this % or less of HP to cast it. clif->skill_fail(sd,skill_id,USESKILL_FAIL_HP_INSUFFICIENT,0); @@ -13174,7 +13170,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id return 0; } - if( require.sp > 0 && status->sp < (unsigned int)require.sp) { + if( require.sp > 0 && st->sp < (unsigned int)require.sp) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_SP_INSUFFICIENT,0); return 0; } @@ -13216,10 +13212,9 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id return 1; } -int skill_check_condition_castend(struct map_session_data* sd, uint16 skill_id, uint16 skill_lv) -{ +int skill_check_condition_castend(struct map_session_data* sd, uint16 skill_id, uint16 skill_lv) { struct skill_condition require; - struct status_data *status; + struct status_data *st; int i; int index[MAX_SKILL_ITEM_REQUIRE]; @@ -13322,11 +13317,11 @@ int skill_check_condition_castend(struct map_session_data* sd, uint16 skill_id, break; } - status = &sd->battle_status; + st = &sd->battle_status; require = skill->get_requirement(sd,skill_id,skill_lv); - if( require.hp > 0 && status->hp <= (unsigned int)require.hp) { + if( require.hp > 0 && st->hp <= (unsigned int)require.hp) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_HP_INSUFFICIENT,0); return 0; } @@ -13489,10 +13484,9 @@ int skill_consume_requirement( struct map_session_data *sd, uint16 skill_id, uin return 1; } -struct skill_condition skill_get_requirement(struct map_session_data* sd, uint16 skill_id, uint16 skill_lv) -{ +struct skill_condition skill_get_requirement(struct map_session_data* sd, uint16 skill_id, uint16 skill_lv) { struct skill_condition req; - struct status_data *status; + struct status_data *st; struct status_change *sc; int i,hp_rate,sp_rate, sp_skill_rate_bonus = 100; uint16 idx; @@ -13528,23 +13522,23 @@ struct skill_condition skill_get_requirement(struct map_session_data* sd, uint16 if( skill_lv < 1 || skill_lv > MAX_SKILL_LEVEL ) return req; - status = &sd->battle_status; + st = &sd->battle_status; 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 += (status->hp * hp_rate)/100; + req.hp += (st->hp * hp_rate)/100; else - req.hp += (status->max_hp * (-hp_rate))/100; + req.hp += (st->max_hp * (-hp_rate))/100; 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]; if(sp_rate > 0) - req.sp += (status->sp * sp_rate)/100; + req.sp += (st->sp * sp_rate)/100; else - req.sp += (status->max_sp * (-sp_rate))/100; + req.sp += (st->max_sp * (-sp_rate))/100; if( sd->dsprate != 100 ) req.sp = req.sp * sd->dsprate / 100; @@ -16018,16 +16012,15 @@ int skill_can_produce_mix (struct map_session_data *sd, int nameid, int trigger, /*========================================== * *------------------------------------------*/ -int skill_produce_mix (struct map_session_data *sd, uint16 skill_id, int nameid, int slot1, int slot2, int slot3, int qty) -{ +int skill_produce_mix(struct map_session_data *sd, uint16 skill_id, int nameid, int slot1, int slot2, int slot3, int qty) { int slot[3]; int i,sc,ele,idx,equip,wlv,make_per = 0,flag = 0,skill_lv = 0; int num = -1; // exclude the recipe - struct status_data *status; + struct status_data *st; struct item_data* data; nullpo_ret(sd); - status = iStatus->get_status_data(&sd->bl); + st = iStatus->get_status_data(&sd->bl); if( sd->skill_id_old == skill_id ) skill_lv = sd->skill_lv_old; @@ -16125,7 +16118,7 @@ int skill_produce_mix (struct map_session_data *sd, uint16 skill_id, int nameid, case BS_ENCHANTEDSTONE: // Ores & Metals Refining - skill bonuses are straight from kRO website [DracoRPG] i = pc->checkskill(sd,skill_id); - make_per = sd->status.job_level*20 + status->dex*10 + status->luk*10; //Base chance + make_per = sd->status.job_level*20 + st->dex*10 + st->luk*10; //Base chance switch(nameid){ case 998: // Iron make_per += 4000+i*500; // Temper Iron bonus: +26/+32/+38/+44/+50 @@ -16142,7 +16135,7 @@ int skill_produce_mix (struct map_session_data *sd, uint16 skill_id, int nameid, } break; case ASC_CDP: - make_per = (2000 + 40*status->dex + 20*status->luk); + make_per = (2000 + 40*st->dex + 20*st->luk); break; case AL_HOLYWATER: /** @@ -16157,7 +16150,7 @@ int skill_produce_mix (struct map_session_data *sd, uint16 skill_id, int nameid, case AM_TWILIGHT3: make_per = pc->checkskill(sd,AM_LEARNINGPOTION)*50 + pc->checkskill(sd,AM_PHARMACY)*300 + sd->status.job_level*20 - + (status->int_/2)*10 + status->dex*10+status->luk*10; + + (st->int_/2)*10 + st->dex*10+st->luk*10; if(homun_alive(sd->hd)) {//Player got a homun int skill2_lv; if((skill2_lv=homun->checkskill(sd->hd,HVAN_INSTRUCT)) > 0) //His homun is a vanil with instruction change @@ -16205,7 +16198,7 @@ int skill_produce_mix (struct map_session_data *sd, uint16 skill_id, int nameid, case RK_RUNEMASTERY: { int A = 5100 + 200 * pc->checkskill(sd, skill_id); - int B = 10 * status->dex / 3 + (status->luk + sd->status.job_level); + int B = 10 * st->dex / 3 + (st->luk + sd->status.job_level); int C = 100 * cap_value(sd->itemid,0,100); //itemid depend on makerune() int D = 2500; switch (nameid) { //rune rank it_diff 9 craftable rune @@ -16252,7 +16245,7 @@ int skill_produce_mix (struct map_session_data *sd, uint16 skill_id, int nameid, difficulty = (620 - 20 * skill_lv);// (620 - 20 * Skill Level) - make_per = status->int_ + status->dex/2 + status->luk + sd->status.job_level + (30+rnd()%120) + // (Caster?s INT) + (Caster?s DEX / 2) + (Caster?s LUK) + (Caster?s Job Level) + Random number between (30 ~ 150) + + make_per = st->int_ + st->dex/2 + st->luk + sd->status.job_level + (30+rnd()%120) + // (Caster?s INT) + (Caster?s DEX / 2) + (Caster?s LUK) + (Caster?s Job Level) + Random number between (30 ~ 150) + (sd->status.base_level-100) + pc->checkskill(sd, AM_LEARNINGPOTION) + pc->checkskill(sd, CR_FULLPROTECTION)*(4+rnd()%6); // (Caster?s Base Level - 100) + (Potion Research x 5) + (Full Chemical Protection Skill Level) x (Random number between 4 ~ 10) switch(nameid){// difficulty factor @@ -16294,7 +16287,7 @@ int skill_produce_mix (struct map_session_data *sd, uint16 skill_id, int nameid, { int difficulty = 30 + rnd()%120; // Random number between (30 ~ 150) - make_per = sd->status.job_level / 4 + status->luk / 2 + status->dex / 3; // (Caster?s Job Level / 4) + (Caster?s LUK / 2) + (Caster?s DEX / 3) + make_per = sd->status.job_level / 4 + st->luk / 2 + st->dex / 3; // (Caster?s Job Level / 4) + (Caster?s LUK / 2) + (Caster?s DEX / 3) qty = ~(5 + rnd()%5) + 1; switch(nameid){// difficulty factor @@ -16342,10 +16335,10 @@ int skill_produce_mix (struct map_session_data *sd, uint16 skill_id, int nameid, else make_per = 1200 * (sd->menuskill_val - 10) + 20 * (sd->status.base_level + 1) - + 20 * (status->dex + 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) - - 10 * (100 - status->luk + 1) + - 10 * (100 - st->luk + 1) - 500 * (num - 1) - 100 * (rnd()%4 + 1); break; @@ -16354,7 +16347,7 @@ int skill_produce_mix (struct map_session_data *sd, uint16 skill_id, int nameid, break; } } else { // Weapon Forging - skill bonuses are straight from kRO website, other things from a jRO calculator [DracoRPG] - make_per = 5000 + sd->status.job_level*20 + status->dex*10 + status->luk*10; // Base + make_per = 5000 + sd->status.job_level*20 + st->dex*10 + st->luk*10; // Base make_per += pc->checkskill(sd,skill_id)*500; // Smithing skills bonus: +5/+10/+15 make_per += pc->checkskill(sd,BS_WEAPONRESEARCH)*100 +((wlv >= 3)? pc->checkskill(sd,BS_ORIDEOCON)*100:0); // Weaponry Research bonus: +1/+2/+3/+4/+5/+6/+7/+8/+9/+10, Oridecon Research bonus (custom): +1/+2/+3/+4/+5 make_per -= (ele?2000:0) + sc*1500 + (wlv>1?wlv*1000:0); // Element Stone: -20%, Star Crumb: -15% each, Weapon level malus: -0/-20/-30 diff --git a/src/map/status.c b/src/map/status.c index 5d856cfb9..eb398806b 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -1089,37 +1089,35 @@ static inline void status_cpy(struct status_data* a, const struct status_data* b //Sets HP to given value. Flag is the flag passed to iStatus->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 *status; +int status_set_hp(struct block_list *bl, unsigned int hp, int flag) { + struct status_data *st; if (hp < 1) return 0; - status = iStatus->get_status_data(bl); - if (status == &dummy_status) + st = iStatus->get_status_data(bl); + if (st == &dummy_status) return 0; - if (hp > status->max_hp) hp = status->max_hp; - if (hp == status->hp) return 0; - if (hp > status->hp) - return iStatus->heal(bl, hp - status->hp, 0, 1|flag); - return status_zap(bl, status->hp - hp, 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_zap(bl, st->hp - hp, 0); } //Sets SP to given value. Flag is the flag passed to iStatus->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 *status; +int status_set_sp(struct block_list *bl, unsigned int sp, int flag) { + struct status_data *st; - status = iStatus->get_status_data(bl); - if (status == &dummy_status) + st = iStatus->get_status_data(bl); + if (st == &dummy_status) return 0; - if (sp > status->max_sp) sp = status->max_sp; - if (sp == status->sp) return 0; - if (sp > status->sp) - return iStatus->heal(bl, 0, sp - status->sp, 1|flag); - return status_zap(bl, 0, status->sp - sp); + 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_zap(bl, 0, st->sp - sp); } int status_charge(struct block_list* bl, int64 hp, int64 sp) @@ -1135,7 +1133,7 @@ int status_charge(struct block_list* bl, int64 hp, int64 sp) //If flag&4, if killed, mob must not give exp/loot. //flag will be set to &8 when damaging sp of a dead character int status_damage(struct block_list *src,struct block_list *target,int64 in_hp, int64 in_sp, int walkdelay, int flag) { - struct status_data *status; + struct status_data *st; struct status_change *sc; int hp,sp; @@ -1159,24 +1157,24 @@ int status_damage(struct block_list *src,struct block_list *target,int64 in_hp, if (target->type == BL_SKILL) return skill->unit_ondamaged((struct skill_unit *)target, src, hp, timer->gettick()); - status = iStatus->get_status_data(target); - if( status == &dummy_status ) + st = iStatus->get_status_data(target); + if( st == &dummy_status ) return 0; - if ((unsigned int)hp >= status->hp) { + if ((unsigned int)hp >= st->hp) { if (flag&2) return 0; - hp = status->hp; + hp = st->hp; } - if ((unsigned int)sp > status->sp) { + if ((unsigned int)sp > st->sp) { if (flag&2) return 0; - sp = status->sp; + sp = st->sp; } if (!hp && !sp) return 0; - if( !status->hp ) + if( !st->hp ) flag |= 8; // Let through. battle.c/skill.c have the whole logic of when it's possible or @@ -1218,7 +1216,7 @@ int status_damage(struct block_list *src,struct block_list *target,int64 in_hp, status_change_end(target, SC_GRAVITATION, INVALID_TIMER); } } - if(sc->data[SC_DANCING] && (unsigned int)hp > status->max_hp>>2) + if(sc->data[SC_DANCING] && (unsigned int)hp > st->max_hp>>2) status_change_end(target, SC_DANCING, INVALID_TIMER); if(sc->data[SC_CLOAKINGEXCEED] && --(sc->data[SC_CLOAKINGEXCEED]->val2) <= 0) status_change_end(target, SC_CLOAKINGEXCEED, INVALID_TIMER); @@ -1228,19 +1226,19 @@ int status_damage(struct block_list *src,struct block_list *target,int64 in_hp, unit->skillcastcancel(target, 2); } - status->hp-= hp; - status->sp-= sp; + st->hp-= hp; + st->sp-= sp; - if (sc && hp && status->hp) { + if (sc && hp && st->hp) { if (sc->data[SC_AUTOBERSERK] && (!sc->data[SC_PROVOKE] || !sc->data[SC_PROVOKE]->val2) && - status->hp < status->max_hp>>2) + st->hp < st->max_hp>>2) sc_start4(target,SC_PROVOKE,100,10,1,0,0,0); - if (sc->data[SC_BERSERK] && status->hp <= 100) + if (sc->data[SC_BERSERK] && st->hp <= 100) status_change_end(target, SC_BERSERK, INVALID_TIMER); - if( sc->data[SC_RAISINGDRAGON] && status->hp <= 1000 ) + if( sc->data[SC_RAISINGDRAGON] && st->hp <= 1000 ) status_change_end(target, SC_RAISINGDRAGON, INVALID_TIMER); - if (sc->data[SC_SATURDAY_NIGHT_FEVER] && status->hp <= 100) + if (sc->data[SC_SATURDAY_NIGHT_FEVER] && st->hp <= 100) status_change_end(target, SC_SATURDAY_NIGHT_FEVER, INVALID_TIMER); } @@ -1256,14 +1254,14 @@ int status_damage(struct block_list *src,struct block_list *target,int64 in_hp, unit->stop_walking( target, 1 ); } - if( status->hp || (flag&8) ) + if( st->hp || (flag&8) ) { //Still lives or has been dead before this damage. if (walkdelay) unit->set_walkdelay(target, timer->gettick(), walkdelay, 0); return (int)(hp+sp); } - status->hp = 1; //To let the dead function cast skills and all that. + st->hp = 1; //To let the dead function cast skills and all that. //NOTE: These dead functions should return: [Skotlex] //0: Death cancelled, auto-revived. //Non-zero: Standard death. Clear status, cancel move/attack, etc @@ -1284,7 +1282,7 @@ int status_damage(struct block_list *src,struct block_list *target,int64 in_hp, return (int)(hp+sp); //Normal death - status->hp = 0; + st->hp = 0; if (battle_config.clear_unit_ondeath && battle_config.clear_unit_ondeath&target->type) skill->clear_unitgroup(target); @@ -1356,15 +1354,14 @@ int status_damage(struct block_list *src,struct block_list *target,int64 in_hp, //Heals a character. If flag&1, this is forced healing (otherwise stuff like Berserk can block it) //If flag&2, when the player is healed, show the HP/SP heal effect. -int status_heal(struct block_list *bl,int64 in_hp,int64 in_sp, int flag) -{ - struct status_data *status; +int status_heal(struct block_list *bl,int64 in_hp,int64 in_sp, int flag) { + struct status_data *st; struct status_change *sc; int hp,sp; - status = iStatus->get_status_data(bl); + st = iStatus->get_status_data(bl); - if (status == &dummy_status || !status->hp) + if (st == &dummy_status || !st->hp) return 0; /* here onwards we consider it a 32-type, the client does not support higher and from here onwards the value doesn't get thru percentage modifiers */ @@ -1389,8 +1386,8 @@ int status_heal(struct block_list *bl,int64 in_hp,int64 in_sp, int flag) hp = 0; } - if((unsigned int)hp > status->max_hp - status->hp) - hp = status->max_hp - status->hp; + if((unsigned int)hp > st->max_hp - st->hp) + hp = st->max_hp - st->hp; } if(sp < 0) { @@ -1400,21 +1397,21 @@ int status_heal(struct block_list *bl,int64 in_hp,int64 in_sp, int flag) } if(sp) { - if((unsigned int)sp > status->max_sp - status->sp) - sp = status->max_sp - status->sp; + if((unsigned int)sp > st->max_sp - st->sp) + sp = st->max_sp - st->sp; } if(!sp && !hp) return 0; - status->hp+= hp; - status->sp+= sp; + st->hp+= hp; + st->sp+= sp; - if(hp && sc && - sc->data[SC_AUTOBERSERK] && - sc->data[SC_PROVOKE] && - sc->data[SC_PROVOKE]->val2==1 && - status->hp>=status->max_hp>>2 - ) //End auto berserk. + if( hp && sc + && sc->data[SC_AUTOBERSERK] + && sc->data[SC_PROVOKE] + && sc->data[SC_PROVOKE]->val2==1 + && st->hp>=st->max_hp>>2 + ) //End auto berserk. status_change_end(bl, SC_PROVOKE, INVALID_TIMER); // send hp update to client @@ -1435,41 +1432,40 @@ int status_heal(struct block_list *bl,int64 in_hp,int64 in_sp, int flag) //If rates are < 0, percent is of max HP/SP //If !flag, this is heal, otherwise it is damage. //Furthermore, if flag==2, then the target must not die from the substraction. -int status_percent_change(struct block_list *src,struct block_list *target,signed char hp_rate, signed char sp_rate, int flag) -{ - struct status_data *status; - unsigned int hp =0, sp = 0; +int status_percent_change(struct block_list *src,struct block_list *target,signed char hp_rate, signed char sp_rate, int flag) { + struct status_data *st; + unsigned int hp = 0, sp = 0; - status = iStatus->get_status_data(target); + st = iStatus->get_status_data(target); //It's safe now [MarkZD] if (hp_rate > 99) - hp = status->hp; + hp = st->hp; else if (hp_rate > 0) - hp = status->hp>10000? - hp_rate*(status->hp/100): - ((int64)hp_rate*status->hp)/100; + hp = st->hp>10000? + hp_rate*(st->hp/100): + ((int64)hp_rate*st->hp)/100; else if (hp_rate < -99) - hp = status->max_hp; + hp = st->max_hp; else if (hp_rate < 0) - hp = status->max_hp>10000? - (-hp_rate)*(status->max_hp/100): - ((int64)-hp_rate*status->max_hp)/100; + hp = st->max_hp>10000? + (-hp_rate)*(st->max_hp/100): + ((int64)-hp_rate*st->max_hp)/100; if (hp_rate && !hp) hp = 1; - if (flag == 2 && hp >= status->hp) - hp = status->hp-1; //Must not kill target. + if (flag == 2 && hp >= st->hp) + hp = st->hp-1; //Must not kill target. if (sp_rate > 99) - sp = status->sp; + sp = st->sp; else if (sp_rate > 0) - sp = ((int64)sp_rate*status->sp)/100; + sp = ((int64)sp_rate*st->sp)/100; else if (sp_rate < -99) - sp = status->max_sp; + sp = st->max_sp; else if (sp_rate < 0) - sp = ((int64)-sp_rate)*status->max_sp/100; + sp = ((int64)-sp_rate)*st->max_sp/100; if (sp_rate && !sp) sp = 1; @@ -1494,31 +1490,30 @@ int status_percent_change(struct block_list *src,struct block_list *target,signe return iStatus->heal(target, hp, sp, 0); } -int status_revive(struct block_list *bl, unsigned char per_hp, unsigned char per_sp) -{ - struct status_data *status; +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; - status = iStatus->get_status_data(bl); - if (status == &dummy_status) + st = iStatus->get_status_data(bl); + if (st == &dummy_status) return 0; //Invalid target. - hp = (int64)status->max_hp * per_hp/100; - sp = (int64)status->max_sp * per_sp/100; + hp = (int64)st->max_hp * per_hp/100; + sp = (int64)st->max_sp * per_sp/100; - if(hp > status->max_hp - status->hp) - hp = status->max_hp - status->hp; + if(hp > st->max_hp - st->hp) + hp = st->max_hp - st->hp; else if (per_hp && !hp) hp = 1; - if(sp > status->max_sp - status->sp) - sp = status->max_sp - status->sp; + if(sp > st->max_sp - st->sp) + sp = st->max_sp - st->sp; else if (per_sp && !sp) sp = 1; - status->hp += hp; - status->sp += sp; + st->hp += hp; + st->sp += sp; if (bl->prev) //Animation only if character is already on a map. clif->resurrection(bl, 1); @@ -1543,19 +1538,18 @@ int status_revive(struct block_list *bl, unsigned char per_hp, unsigned char per * target MAY Be null, in which case the checks are only to see * whether the source can cast or not the skill on the ground. *------------------------------------------*/ -int status_check_skilluse(struct block_list *src, struct block_list *target, uint16 skill_id, int flag) -{ - struct status_data *status; +int status_check_skilluse(struct block_list *src, struct block_list *target, uint16 skill_id, int flag) { + struct status_data *st; struct status_change *sc=NULL, *tsc; int hide_flag; - status = src?iStatus->get_status_data(src):&dummy_status; + st = src ? iStatus->get_status_data(src) : &dummy_status; if (src && src->type != BL_PC && iStatus->isdead(src)) return 0; if (!skill_id) { //Normal attack checks. - if (!(status->mode&MD_CANATTACK)) + if (!(st->mode&MD_CANATTACK)) 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] @@ -1575,7 +1569,7 @@ int status_check_skilluse(struct block_list *src, struct block_list *target, uin if( src->type == BL_PC ) clif->msg((TBL_PC*)src, SKILL_CANT_USE_AREA); // This skill cannot be used within this area else if( src->type == BL_MOB && map[src->m].zone->disabled_skills[i]->subtype != MZS_NONE ) { - if( (status->mode&MD_BOSS) && !(map[src->m].zone->disabled_skills[i]->subtype&MZS_BOSS) ) + if( (st->mode&MD_BOSS) && !(map[src->m].zone->disabled_skills[i]->subtype&MZS_BOSS) ) break; } return 0; @@ -1599,7 +1593,7 @@ int status_check_skilluse(struct block_list *src, struct block_list *target, uin 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) - && !(status->mode&MD_BOSS) + && !(st->mode&MD_BOSS) && (src->type != BL_PC || ((TBL_PC*)src)->skillitem != skill_id)) return 0; break; @@ -1774,8 +1768,8 @@ int status_check_skilluse(struct block_list *src, struct block_list *target, uin switch( target->type ) { case BL_PC: { struct map_session_data *sd = (TBL_PC*) target; - bool is_boss = (status->mode&MD_BOSS); - bool is_detect = ((status->mode&MD_DETECTOR)?true:false);//god-knows-why gcc doesn't shut up until this happens + bool is_boss = (st->mode&MD_BOSS); + bool is_detect = ((st->mode&MD_DETECTOR)?true:false);//god-knows-why gcc doesn't shut up until this happens if (pc_isinvisible(sd)) return 0; if (tsc->option&hide_flag && !is_boss && @@ -1790,7 +1784,7 @@ int status_check_skilluse(struct block_list *src, struct block_list *target, uin break; case BL_ITEM: //Allow targetting of items to pick'em up (or in the case of mobs, to loot them). //TODO: Would be nice if this could be used to judge whether the player can or not pick up the item it targets. [Skotlex] - if (status->mode&MD_LOOTER) + if (st->mode&MD_LOOTER) return 1; return 0; case BL_HOM: @@ -1805,9 +1799,9 @@ int status_check_skilluse(struct block_list *src, struct block_list *target, uin default: //Check for chase-walk/hiding/cloaking opponents. if( tsc ) { - if( tsc->option&hide_flag && !(status->mode&(MD_BOSS|MD_DETECTOR))) + if( tsc->option&hide_flag && !(st->mode&(MD_BOSS|MD_DETECTOR))) return 0; - if( tsc->data[SC_STEALTHFIELD] && !(status->mode&MD_BOSS) ) + if( tsc->data[SC_STEALTHFIELD] && !(st->mode&MD_BOSS) ) return 0; } } @@ -1816,11 +1810,10 @@ 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 status_check_visibility(struct block_list *src, struct block_list *target) { int view_range; - struct status_data* status = iStatus->get_status_data(src); - struct status_change* tsc = iStatus->get_sc(target); + struct status_data *st = iStatus->get_status_data(src); + struct status_change *tsc = iStatus->get_sc(target); switch (src->type) { case BL_MOB: view_range = ((TBL_MOB*)src)->min_chase; @@ -1841,14 +1834,14 @@ int status_check_visibility(struct block_list *src, struct block_list *target) switch (target->type) { //Check for chase-walk/hiding/cloaking opponents. case BL_PC: - if ( tsc->data[SC_CLOAKINGEXCEED] && !(status->mode&MD_BOSS) ) + if ( tsc->data[SC_CLOAKINGEXCEED] && !(st->mode&MD_BOSS) ) return 0; - if( (tsc->option&(OPTION_HIDE|OPTION_CLOAK|OPTION_CHASEWALK) || tsc->data[SC__INVISIBILITY] || tsc->data[SC_CAMOUFLAGE]) && !(status->mode&MD_BOSS) && - ( ((TBL_PC*)target)->special_state.perfect_hiding || !(status->mode&MD_DETECTOR) ) ) + if( (tsc->option&(OPTION_HIDE|OPTION_CLOAK|OPTION_CHASEWALK) || tsc->data[SC__INVISIBILITY] || tsc->data[SC_CAMOUFLAGE]) && !(st->mode&MD_BOSS) && + ( ((TBL_PC*)target)->special_state.perfect_hiding || !(st->mode&MD_DETECTOR) ) ) return 0; break; default: - if( tsc && (tsc->option&(OPTION_HIDE|OPTION_CLOAK|OPTION_CHASEWALK) || tsc->data[SC__INVISIBILITY] || tsc->data[SC_CAMOUFLAGE]) && !(status->mode&(MD_BOSS|MD_DETECTOR)) ) + if( tsc && (tsc->option&(OPTION_HIDE|OPTION_CLOAK|OPTION_CHASEWALK) || tsc->data[SC__INVISIBILITY] || tsc->data[SC_CAMOUFLAGE]) && !(st->mode&(MD_BOSS|MD_DETECTOR)) ) return 0; } @@ -1857,8 +1850,7 @@ int status_check_visibility(struct block_list *src, struct block_list *target) } // Basic ASPD value -int status_base_amotion_pc(struct map_session_data* sd, struct status_data* status) -{ +int status_base_amotion_pc(struct map_session_data *sd, struct status_data *st) { int amotion; #ifdef RENEWAL_ASPD short mod = -1; @@ -1889,7 +1881,7 @@ int status_base_amotion_pc(struct map_session_data* sd, struct status_data* stat : (aspd_base[pc->class2idx(sd->status.class_)][sd->weapontype1] + aspd_base[pc->class2idx(sd->status.class_)][sd->weapontype2])*7/10; // dual-wield // percentual delay reduction from stats - amotion -= amotion * (4*status->agi + status->dex)/1000; + amotion -= amotion * (4*st->agi + st->dex)/1000; #endif // raw delay adjustment from bAspd bonus amotion += sd->bonus.aspd_add; @@ -1897,8 +1889,7 @@ int status_base_amotion_pc(struct map_session_data* sd, struct status_data* stat return amotion; } -static unsigned short status_base_atk(const struct block_list *bl, const struct status_data *status) -{ +static unsigned short status_base_atk(const struct block_list *bl, const struct status_data *st) { int flag = 0, str, dex, #ifdef RENEWAL rstr, @@ -1925,14 +1916,14 @@ static unsigned short status_base_atk(const struct block_list *bl, const struct #ifdef RENEWAL rstr = #endif - str = status->dex; - dex = status->str; + str = st->dex; + dex = st->str; } else { #ifdef RENEWAL rstr = #endif - str = status->str; - dex = status->dex; + str = st->str; + dex = st->dex; } //Normally only players have base-atk, but homunc have a different batk // equation, hinting that perhaps non-players should use this for batk. @@ -1941,94 +1932,92 @@ static unsigned short status_base_atk(const struct block_list *bl, const struct str += dstr*dstr; if (bl->type == BL_PC) #ifdef RENEWAL - str = (int)(rstr + (float)dex/5 + (float)status->luk/3 + (float)((TBL_PC*)bl)->status.base_level/4); + str = (int)(rstr + (float)dex/5 + (float)st->luk/3 + (float)((TBL_PC*)bl)->status.base_level/4); else if(bl->type == BL_MOB) str = rstr + ((TBL_MOB*)bl)->level; #else - str+= dex/5 + status->luk/5; + str+= dex/5 + st->luk/5; #endif return cap_value(str, 0, USHRT_MAX); } -static inline unsigned short status_base_matk_min(const struct status_data* status){ return status->int_+(status->int_/7)*(status->int_/7); } -static inline unsigned short status_base_matk_max(const struct status_data* status){ return status->int_+(status->int_/5)*(status->int_/5); } +static inline unsigned short status_base_matk_min(const struct status_data *st){ return st->int_+(st->int_/7)*(st->int_/7); } +static inline unsigned short status_base_matk_max(const struct status_data *st){ return st->int_+(st->int_/5)*(st->int_/5); } #ifdef RENEWAL -unsigned short status_base_matk(const struct status_data* status, int level){ return status->int_+(status->int_/2)+(status->dex/5)+(status->luk/3)+(level/4); } +unsigned short status_base_matk(const struct status_data *st, int level){ return st->int_+(st->int_/2)+(st->dex/5)+(st->luk/3)+(level/4); } #endif //Fills in the misc data that can be calculated from the other status info (except for level) -void status_calc_misc(struct block_list *bl, struct status_data *status, int level) -{ +void status_calc_misc(struct block_list *bl, struct status_data *st, int level) { //Non players get the value set, players need to stack with previous bonuses. if( bl->type != BL_PC ) - status->batk = - status->hit = status->flee = - status->def2 = status->mdef2 = - status->cri = status->flee2 = 0; + st->batk = + st->hit = st->flee = + st->def2 = st->mdef2 = + st->cri = st->flee2 = 0; #ifdef RENEWAL // renewal formulas - status->matk_min = status->matk_max = bl->type == BL_PC ? iStatus->base_matk(status, level) : level + status->int_; - status->hit += level + status->dex + (bl->type == BL_PC ? status->luk/3 + 175 : 150); //base level + ( every 1 dex = +1 hit ) + (every 3 luk = +1 hit) + 175 - status->flee += level + status->agi + (bl->type == BL_PC ? status->luk/5 : 0) + 100; //base level + ( every 1 agi = +1 flee ) + (every 5 luk = +1 flee) + 100 - status->def2 += (int)(((float)level + status->vit)/2 + ( bl->type == BL_PC ? ((float)status->agi/5) : 0 )); //base level + (every 2 vit = +1 def) + (every 5 agi = +1 def) - status->mdef2 += (int)( bl->type == BL_PC ?(status->int_ + ((float)level/4) + ((float)(status->dex+status->vit)/5)):((float)(status->int_ + level)/4)); //(every 4 base level = +1 mdef) + (every 1 int = +1 mdef) + (every 5 dex = +1 mdef) + (every 5 vit = +1 mdef) + st->matk_min = st->matk_max = bl->type == BL_PC ? iStatus->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 - status->matk_min = status_base_matk_min(status); - status->matk_max = status_base_matk_max(status); - status->hit += level + status->dex; - status->flee += level + status->agi; - status->def2 += status->vit; - status->mdef2 += status->int_ + (status->vit>>1); + 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 if( bl->type&battle_config.enable_critical ) - status->cri += 10 + (status->luk*10/3); //(every 1 luk = +0.3 critical) + st->cri += 10 + (st->luk*10/3); //(every 1 luk = +0.3 critical) else - status->cri = 0; + st->cri = 0; if (bl->type&battle_config.enable_perfect_flee) - status->flee2 += status->luk + 10; //(every 10 luk = +1 perfect flee) + st->flee2 += st->luk + 10; //(every 10 luk = +1 perfect flee) else - status->flee2 = 0; + st->flee2 = 0; - if (status->batk) { - int temp = status->batk + status_base_atk(bl, status); - status->batk = cap_value(temp, 0, USHRT_MAX); + if (st->batk) { + int temp = st->batk + status_base_atk(bl, st); + st->batk = cap_value(temp, 0, USHRT_MAX); } else - status->batk = status_base_atk(bl, status); - if (status->cri) + st->batk = status_base_atk(bl, st); + if (st->cri) switch (bl->type) { case BL_MOB: if(battle_config.mob_critical_rate != 100) - status->cri = status->cri*battle_config.mob_critical_rate/100; - if(!status->cri && battle_config.mob_critical_rate) - status->cri = 10; + st->cri = st->cri*battle_config.mob_critical_rate/100; + if(!st->cri && battle_config.mob_critical_rate) + st->cri = 10; break; case BL_PC: //Players don't have a critical adjustment setting as of yet. break; case BL_MER: #ifdef RENEWAL - status->matk_min = status->matk_max = status_base_matk_max(status); - status->def2 = status->vit + level / 10 + status->vit / 5; - status->mdef2 = level / 10 + status->int_ / 5; + st->matk_min = st->matk_max = status_base_matk_max(st); + st->def2 = st->vit + level / 10 + st->vit / 5; + st->mdef2 = level / 10 + st->int_ / 5; #endif break; default: if(battle_config.critical_rate != 100) - status->cri = status->cri*battle_config.critical_rate/100; - if (!status->cri && battle_config.critical_rate) - status->cri = 10; + st->cri = st->cri*battle_config.critical_rate/100; + if (!st->cri && battle_config.critical_rate) + st->cri = 10; } if(bl->type&BL_REGEN) - iStatus->calc_regen(bl, status, iStatus->get_regen_data(bl)); + iStatus->calc_regen(bl, st, iStatus->get_regen_data(bl)); } //Skotlex: Calculates the initial status for the given mob //first will only be false when the mob leveled up or got a GuardUp level. -int status_calc_mob_(struct mob_data* md, bool first) -{ - struct status_data *status; +int status_calc_mob_(struct mob_data* md, bool first) { + struct status_data *mstatus; struct block_list *mbl = NULL; int flag=0; @@ -2071,8 +2060,8 @@ int status_calc_mob_(struct mob_data* md, bool first) if (!md->base_status) md->base_status = (struct status_data*)aCalloc(1, sizeof(struct status_data)); - status = md->base_status; - memcpy(status, &md->db->status, sizeof(struct status_data)); + mstatus = md->base_status; + memcpy(mstatus, &md->db->status, sizeof(struct status_data)); if (flag&(8|16)) mbl = iMap->id2bl(md->master_id); @@ -2081,84 +2070,84 @@ int status_calc_mob_(struct mob_data* md, bool first) struct status_data *mstatus = iStatus->get_base_status(mbl); if (mstatus && battle_config.slaves_inherit_speed&(mstatus->mode&MD_CANMOVE?1:2)) - status->speed = mstatus->speed; - if( status->speed < 2 ) /* minimum for the unit to function properly */ - status->speed = 2; + mstatus->speed = mstatus->speed; + if( mstatus->speed < 2 ) /* minimum for the unit to function properly */ + mstatus->speed = 2; } - if (flag&16 && mbl) - { //Max HP setting from Summon Flora/marine Sphere + if (flag&16 && mbl) { + //Max HP setting from Summon Flora/marine Sphere struct unit_data *ud = unit->bl2ud(mbl); //Remove special AI when this is used by regular mobs. if (mbl->type == BL_MOB && !((TBL_MOB*)mbl)->special_state.ai) md->special_state.ai = 0; - if (ud) - { // different levels of HP according to skill level + if (ud) { + // different levels of HP according to skill level if (ud->skill_id == AM_SPHEREMINE) { - status->max_hp = 2000 + 400*ud->skill_lv; - } else if(ud->skill_id == KO_ZANZOU){ - status->max_hp = 3000 + 3000 * ud->skill_lv + status_get_max_sp(battle->get_master(mbl)); + mstatus->max_hp = 2000 + 400*ud->skill_lv; + } 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 - status->max_hp = 1500 + 200*ud->skill_lv + 10*iStatus->get_lv(mbl); - status->mode|= MD_CANATTACK|MD_AGGRESSIVE; + mstatus->max_hp = 1500 + 200*ud->skill_lv + 10*iStatus->get_lv(mbl); + mstatus->mode|= MD_CANATTACK|MD_AGGRESSIVE; } - status->hp = status->max_hp; + mstatus->hp = mstatus->max_hp; } } - if (flag&1) - { // increase from mobs leveling up [Valaris] + if (flag&1) { + // increase from mobs leveling up [Valaris] int diff = md->level - md->db->lv; - status->str+= diff; - status->agi+= diff; - status->vit+= diff; - status->int_+= diff; - status->dex+= diff; - status->luk+= diff; - status->max_hp += diff*status->vit; - status->max_sp += diff*status->int_; - status->hp = status->max_hp; - status->sp = status->max_sp; - status->speed -= cap_value(diff, 0, status->speed - 10); - } - - - if (flag&2 && battle_config.mob_size_influence) - { // change for sized monsters [Valaris] + mstatus->str+= diff; + mstatus->agi+= diff; + mstatus->vit+= diff; + mstatus->int_+= diff; + mstatus->dex+= diff; + mstatus->luk+= diff; + mstatus->max_hp += diff*mstatus->vit; + mstatus->max_sp += diff*mstatus->int_; + mstatus->hp = mstatus->max_hp; + mstatus->sp = mstatus->max_sp; + mstatus->speed -= cap_value(diff, 0, mstatus->speed - 10); + } + + + if (flag&2 && battle_config.mob_size_influence) { + // change for sized monsters [Valaris] if (md->special_state.size==SZ_MEDIUM) { - status->max_hp>>=1; - status->max_sp>>=1; - if (!status->max_hp) status->max_hp = 1; - if (!status->max_sp) status->max_sp = 1; - status->hp=status->max_hp; - status->sp=status->max_sp; - status->str>>=1; - status->agi>>=1; - status->vit>>=1; - status->int_>>=1; - status->dex>>=1; - status->luk>>=1; - if (!status->str) status->str = 1; - if (!status->agi) status->agi = 1; - if (!status->vit) status->vit = 1; - if (!status->int_) status->int_ = 1; - if (!status->dex) status->dex = 1; - if (!status->luk) status->luk = 1; + mstatus->max_hp>>=1; + mstatus->max_sp>>=1; + if (!mstatus->max_hp) mstatus->max_hp = 1; + if (!mstatus->max_sp) mstatus->max_sp = 1; + mstatus->hp=mstatus->max_hp; + mstatus->sp=mstatus->max_sp; + mstatus->str>>=1; + mstatus->agi>>=1; + mstatus->vit>>=1; + mstatus->int_>>=1; + mstatus->dex>>=1; + mstatus->luk>>=1; + if (!mstatus->str) mstatus->str = 1; + if (!mstatus->agi) mstatus->agi = 1; + if (!mstatus->vit) mstatus->vit = 1; + if (!mstatus->int_) mstatus->int_ = 1; + if (!mstatus->dex) mstatus->dex = 1; + if (!mstatus->luk) mstatus->luk = 1; } else if (md->special_state.size==SZ_BIG) { - status->max_hp<<=1; - status->max_sp<<=1; - status->hp=status->max_hp; - status->sp=status->max_sp; - status->str<<=1; - status->agi<<=1; - status->vit<<=1; - status->int_<<=1; - status->dex<<=1; - status->luk<<=1; + mstatus->max_hp<<=1; + mstatus->max_sp<<=1; + mstatus->hp=mstatus->max_hp; + mstatus->sp=mstatus->max_sp; + mstatus->str<<=1; + mstatus->agi<<=1; + mstatus->vit<<=1; + mstatus->int_<<=1; + mstatus->dex<<=1; + mstatus->luk<<=1; } } - iStatus->calc_misc(&md->bl, status, md->level); + iStatus->calc_misc(&md->bl, mstatus, md->level); if(flag&4) { // Strengthen Guardians - custom value +10% / lv @@ -2169,27 +2158,27 @@ int status_calc_mob_(struct mob_data* md, bool first) else if(gc->castle_id < 24 || md->class_ == MOBID_EMPERIUM) { #ifdef RENEWAL - status->max_hp += 50 * gc->defense; - status->max_sp += 70 * gc->defense; + mstatus->max_hp += 50 * gc->defense; + mstatus->max_sp += 70 * gc->defense; #else - status->max_hp += 1000 * gc->defense; - status->max_sp += 200 * gc->defense; + mstatus->max_hp += 1000 * gc->defense; + mstatus->max_sp += 200 * gc->defense; #endif - status->hp = status->max_hp; - status->sp = status->max_sp; - status->def += (gc->defense+2)/3; - status->mdef += (gc->defense+2)/3; + mstatus->hp = mstatus->max_hp; + mstatus->sp = mstatus->max_sp; + mstatus->def += (gc->defense+2)/3; + mstatus->mdef += (gc->defense+2)/3; } if(md->class_ != MOBID_EMPERIUM) { - status->batk += status->batk * 10*md->guardian_data->guardup_lv/100; - status->rhw.atk += status->rhw.atk * 10*md->guardian_data->guardup_lv/100; - status->rhw.atk2 += status->rhw.atk2 * 10*md->guardian_data->guardup_lv/100; - status->aspd_rate -= 100*md->guardian_data->guardup_lv; + mstatus->batk += mstatus->batk * 10*md->guardian_data->guardup_lv/100; + mstatus->rhw.atk += mstatus->rhw.atk * 10*md->guardian_data->guardup_lv/100; + mstatus->rhw.atk2 += mstatus->rhw.atk2 * 10*md->guardian_data->guardup_lv/100; + mstatus->aspd_rate -= 100*md->guardian_data->guardup_lv; } } if( first ) //Initial battle status - memcpy(&md->status, status, sizeof(struct status_data)); + memcpy(&md->status, mstatus, sizeof(struct status_data)); return 1; } @@ -2210,37 +2199,35 @@ int status_calc_pet_(struct pet_data *pd, bool first) } } - if (battle_config.pet_lv_rate && pd->msd) - { + if (battle_config.pet_lv_rate && pd->msd) { struct map_session_data *sd = pd->msd; int lv; lv =sd->status.base_level*battle_config.pet_lv_rate/100; if (lv < 0) lv = 1; - if (lv != pd->pet.level || first) - { - struct status_data *bstat = &pd->db->status, *status = &pd->status; + if (lv != pd->pet.level || first) { + struct status_data *bstat = &pd->db->status, *pstatus = &pd->status; pd->pet.level = lv; if (!first) //Lv Up animation clif->misceffect(&pd->bl, 0); - status->rhw.atk = (bstat->rhw.atk*lv)/pd->db->lv; - status->rhw.atk2 = (bstat->rhw.atk2*lv)/pd->db->lv; - status->str = (bstat->str*lv)/pd->db->lv; - status->agi = (bstat->agi*lv)/pd->db->lv; - status->vit = (bstat->vit*lv)/pd->db->lv; - status->int_ = (bstat->int_*lv)/pd->db->lv; - status->dex = (bstat->dex*lv)/pd->db->lv; - status->luk = (bstat->luk*lv)/pd->db->lv; - - status->rhw.atk = cap_value(status->rhw.atk, 1, battle_config.pet_max_atk1); - status->rhw.atk2 = cap_value(status->rhw.atk2, 2, battle_config.pet_max_atk2); - status->str = cap_value(status->str,1,battle_config.pet_max_stats); - status->agi = cap_value(status->agi,1,battle_config.pet_max_stats); - status->vit = cap_value(status->vit,1,battle_config.pet_max_stats); - status->int_= cap_value(status->int_,1,battle_config.pet_max_stats); - status->dex = cap_value(status->dex,1,battle_config.pet_max_stats); - status->luk = cap_value(status->luk,1,battle_config.pet_max_stats); + pstatus->rhw.atk = (bstat->rhw.atk*lv)/pd->db->lv; + pstatus->rhw.atk2 = (bstat->rhw.atk2*lv)/pd->db->lv; + pstatus->str = (bstat->str*lv)/pd->db->lv; + pstatus->agi = (bstat->agi*lv)/pd->db->lv; + pstatus->vit = (bstat->vit*lv)/pd->db->lv; + pstatus->int_ = (bstat->int_*lv)/pd->db->lv; + pstatus->dex = (bstat->dex*lv)/pd->db->lv; + pstatus->luk = (bstat->luk*lv)/pd->db->lv; + + pstatus->rhw.atk = cap_value(pstatus->rhw.atk, 1, battle_config.pet_max_atk1); + pstatus->rhw.atk2 = cap_value(pstatus->rhw.atk2, 2, battle_config.pet_max_atk2); + pstatus->str = cap_value(pstatus->str,1,battle_config.pet_max_stats); + pstatus->agi = cap_value(pstatus->agi,1,battle_config.pet_max_stats); + pstatus->vit = cap_value(pstatus->vit,1,battle_config.pet_max_stats); + pstatus->int_= cap_value(pstatus->int_,1,battle_config.pet_max_stats); + 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); @@ -2287,8 +2274,7 @@ static void status_calc_sigma(void) /// f(0) = 35 | f(x+1) = f(x) + A + (x + B)*C/D /// which reduces to something close to /// f(x) = 35 + x*(A + B*C/D) + sum(i=2..x){ i*C/D } -static unsigned int status_base_pc_maxhp(struct map_session_data* sd, struct status_data* status) -{ +static unsigned int status_base_pc_maxhp(struct map_session_data *sd, struct status_data *st) { uint64 val = pc->class2idx(sd->status.class_); val = 35 + sd->status.base_level*(int64)hp_coefficient2[val]/100 + hp_sigma_val[val][sd->status.base_level]; @@ -2299,7 +2285,7 @@ static unsigned int status_base_pc_maxhp(struct map_session_data* sd, struct sta if((sd->class_&MAPID_UPPERMASK) == MAPID_SUPER_NOVICE && sd->status.base_level >= 99) val += 2000; //Supernovice lvl99 hp bonus. - val += val * status->vit/100; // +1% per each point of VIT + val += val * st->vit/100; // +1% per each point of VIT if (sd->class_&JOBL_UPPER) val += val * 25/100; //Trans classes get a 25% hp bonus @@ -2308,12 +2294,11 @@ static unsigned int status_base_pc_maxhp(struct map_session_data* sd, struct sta return (unsigned int)val; } -static unsigned int status_base_pc_maxsp(struct map_session_data* sd, struct status_data *status) -{ +static unsigned int status_base_pc_maxsp(struct map_session_data* sd, struct status_data *st) { uint64 val; val = 10 + sd->status.base_level*(int64)sp_coefficient[pc->class2idx(sd->status.class_)]/100; - val += val * status->int_/100; + val += val * st->int_/100; if (sd->class_&JOBL_UPPER) val += val * 25/100; @@ -2327,10 +2312,9 @@ static unsigned int status_base_pc_maxsp(struct map_session_data* sd, struct sta //Calculates player data from scratch without counting SC adjustments. //Should be invoked whenever players raise stats, learn passive skills or change equipment. -int status_calc_pc_(struct map_session_data* sd, bool first) -{ +int status_calc_pc_(struct map_session_data* sd, bool first) { static int calculating = 0; //Check for recursive call preemption. [Skotlex] - struct status_data *status; // pointer to the player's base status + struct status_data *bstatus; // pointer to the player's base status const struct status_change *sc = &sd->sc; struct s_skill b_skill[MAX_SKILL]; // previous skill tree int b_weight, b_max_weight, b_cart_weight_max, // previous weight @@ -2372,7 +2356,7 @@ int status_calc_pc_(struct map_session_data* sd, bool first) } } - status = &sd->base_status; + bstatus = &sd->base_status; // these are not zeroed. [zzo] sd->hprate=100; sd->sprate=100; @@ -2422,26 +2406,26 @@ int status_calc_pc_(struct map_session_data* sd, bool first) clif->sc_end(&sd->bl,sd->bl.id,SELF,SI_CLAIRVOYANCE); memset(&sd->special_state,0,sizeof(sd->special_state)); - memset(&status->max_hp, 0, sizeof(struct status_data)-(sizeof(status->hp)+sizeof(status->sp))); + memset(&bstatus->max_hp, 0, sizeof(struct status_data)-(sizeof(bstatus->hp)+sizeof(bstatus->sp))); //FIXME: Most of these stuff should be calculated once, but how do I fix the memset above to do that? [Skotlex] if (!sd->state.permanent_speed) - status->speed = DEFAULT_WALK_SPEED; + bstatus->speed = DEFAULT_WALK_SPEED; //Give them all modes except these (useful for clones) - status->mode = MD_MASK&~(MD_BOSS|MD_PLANT|MD_DETECTOR|MD_ANGRY|MD_TARGETWEAK); + bstatus->mode = MD_MASK&~(MD_BOSS|MD_PLANT|MD_DETECTOR|MD_ANGRY|MD_TARGETWEAK); - status->size = (sd->class_&JOBL_BABY)?SZ_SMALL:SZ_MEDIUM; + bstatus->size = (sd->class_&JOBL_BABY)?SZ_SMALL:SZ_MEDIUM; if (battle_config.character_size && (pc_isriding(sd) || pc_isridingdragon(sd)) ) { //[Lupus] if (sd->class_&JOBL_BABY) { if (battle_config.character_size&SZ_BIG) - status->size++; + bstatus->size++; } else if(battle_config.character_size&SZ_MEDIUM) - status->size++; + bstatus->size++; } - status->aspd_rate = 1000; - status->ele_lv = 1; - status->race = RC_DEMIHUMAN; + bstatus->aspd_rate = 1000; + bstatus->ele_lv = 1; + bstatus->race = RC_DEMIHUMAN; //zero up structures... memset(&sd->autospell,0,sizeof(sd->autospell) @@ -2507,7 +2491,7 @@ int status_calc_pc_(struct map_session_data* sd, bool first) if( k < map[sd->bl.m].zone->disabled_items_count ) continue; - status->def += sd->inventory_data[index]->def; + bstatus->def += sd->inventory_data[index]->def; if(first && sd->inventory_data[index]->equip_script) { //Execute equip-script on login @@ -2528,10 +2512,10 @@ int status_calc_pc_(struct map_session_data* sd, bool first) wlv = REFINE_TYPE_MAX - 1; if(i == EQI_HAND_L && sd->status.inventory[index].equip == EQP_HAND_L) { wd = &sd->left_weapon; // Left-hand weapon - wa = &status->lhw; + wa = &bstatus->lhw; } else { wd = &sd->right_weapon; - wa = &status->rhw; + wa = &bstatus->rhw; } wa->atk += sd->inventory_data[index]->atk; if ( (r = sd->status.inventory[index].refine) ) @@ -2613,7 +2597,7 @@ int status_calc_pc_(struct map_session_data* sd, bool first) memcpy(sd->param_equip,sd->param_bonus,sizeof(sd->param_equip)); memset(sd->param_bonus, 0, sizeof(sd->param_bonus)); - status->def += (refinedef+50)/100; + bstatus->def += (refinedef+50)/100; //Parse Cards for(i=0;irhw.range < 1) status->rhw.range = 1; - if(status->lhw.range < 1) status->lhw.range = 1; - if(status->rhw.range < status->lhw.range) - status->rhw.range = status->lhw.range; + if(bstatus->rhw.range < 1) bstatus->rhw.range = 1; + if(bstatus->lhw.range < 1) bstatus->lhw.range = 1; + if(bstatus->rhw.range < bstatus->lhw.range) + bstatus->rhw.range = bstatus->lhw.range; sd->bonus.double_rate += sd->bonus.double_add_rate; sd->bonus.perfect_hit += sd->bonus.perfect_hit_add; @@ -2720,205 +2704,205 @@ int status_calc_pc_(struct map_session_data* sd, bool first) if(!job_bonus[index][i]) continue; switch(job_bonus[index][i]) { - case 1: status->str++; break; - case 2: status->agi++; break; - case 3: status->vit++; break; - case 4: status->int_++; break; - case 5: status->dex++; break; - case 6: status->luk++; break; + case 1: bstatus->str++; break; + case 2: bstatus->agi++; break; + case 3: bstatus->vit++; break; + case 4: bstatus->int_++; break; + case 5: bstatus->dex++; break; + case 6: bstatus->luk++; break; } } // If a Super Novice has never died and is at least joblv 70, he gets all stats +10 - if((sd->class_&MAPID_UPPERMASK) == MAPID_SUPER_NOVICE && sd->die_counter == 0 && sd->status.job_level >= 70){ - status->str += 10; - status->agi += 10; - status->vit += 10; - status->int_+= 10; - status->dex += 10; - status->luk += 10; + if((sd->class_&MAPID_UPPERMASK) == MAPID_SUPER_NOVICE && sd->die_counter == 0 && sd->status.job_level >= 70) { + bstatus->str += 10; + bstatus->agi += 10; + bstatus->vit += 10; + bstatus->int_+= 10; + bstatus->dex += 10; + bstatus->luk += 10; } // Absolute modifiers from passive skills if(pc->checkskill(sd,BS_HILTBINDING)>0) - status->str++; + bstatus->str++; if((skill_lv=pc->checkskill(sd,SA_DRAGONOLOGY))>0) - status->int_ += (skill_lv+1)/2; // +1 INT / 2 lv + bstatus->int_ += (skill_lv+1)/2; // +1 INT / 2 lv if((skill_lv=pc->checkskill(sd,AC_OWL))>0) - status->dex += skill_lv; + bstatus->dex += skill_lv; if((skill_lv = pc->checkskill(sd,RA_RESEARCHTRAP))>0) - status->int_ += skill_lv; + bstatus->int_ += skill_lv; // Bonuses from cards and equipment as well as base stat, remember to avoid overflows. - i = status->str + sd->status.str + sd->param_bonus[0] + sd->param_equip[0]; - status->str = cap_value(i,0,USHRT_MAX); - i = status->agi + sd->status.agi + sd->param_bonus[1] + sd->param_equip[1]; - status->agi = cap_value(i,0,USHRT_MAX); - i = status->vit + sd->status.vit + sd->param_bonus[2] + sd->param_equip[2]; - status->vit = cap_value(i,0,USHRT_MAX); - i = status->int_+ sd->status.int_+ sd->param_bonus[3] + sd->param_equip[3]; - status->int_ = cap_value(i,0,USHRT_MAX); - i = status->dex + sd->status.dex + sd->param_bonus[4] + sd->param_equip[4]; - status->dex = cap_value(i,0,USHRT_MAX); - i = status->luk + sd->status.luk + sd->param_bonus[5] + sd->param_equip[5]; - status->luk = cap_value(i,0,USHRT_MAX); + i = bstatus->str + sd->status.str + sd->param_bonus[0] + sd->param_equip[0]; + bstatus->str = cap_value(i,0,USHRT_MAX); + i = bstatus->agi + sd->status.agi + sd->param_bonus[1] + sd->param_equip[1]; + bstatus->agi = cap_value(i,0,USHRT_MAX); + i = bstatus->vit + sd->status.vit + sd->param_bonus[2] + sd->param_equip[2]; + bstatus->vit = cap_value(i,0,USHRT_MAX); + i = bstatus->int_+ sd->status.int_+ sd->param_bonus[3] + sd->param_equip[3]; + bstatus->int_ = cap_value(i,0,USHRT_MAX); + i = bstatus->dex + sd->status.dex + sd->param_bonus[4] + sd->param_equip[4]; + bstatus->dex = cap_value(i,0,USHRT_MAX); + i = bstatus->luk + sd->status.luk + sd->param_bonus[5] + sd->param_equip[5]; + bstatus->luk = cap_value(i,0,USHRT_MAX); // ------ BASE ATTACK CALCULATION ------ // Base batk value is set on iStatus->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]) - status->batk += sd->weapon_atk[sd->status.weapon]; + bstatus->batk += sd->weapon_atk[sd->status.weapon]; // Absolute modifiers from passive skills #ifndef RENEWAL if((skill_lv=pc->checkskill(sd,BS_HILTBINDING))>0) // it doesn't work in RE. - status->batk += 4; + bstatus->batk += 4; #endif // ----- HP MAX CALCULATION ----- // Basic MaxHP value //We hold the standard Max HP here to make it faster to recalculate on vit changes. - sd->status.max_hp = status_base_pc_maxhp(sd,status); + sd->status.max_hp = status_base_pc_maxhp(sd,bstatus); //This is done to handle underflows from negative Max HP bonuses - i64 = sd->status.max_hp + (int)status->max_hp; - status->max_hp = (unsigned int)cap_value(i64, 0, INT_MAX); + i64 = sd->status.max_hp + (int)bstatus->max_hp; + bstatus->max_hp = (unsigned int)cap_value(i64, 0, INT_MAX); // Absolute modifiers from passive skills if((skill_lv=pc->checkskill(sd,CR_TRUST))>0) - status->max_hp += skill_lv*200; + bstatus->max_hp += skill_lv*200; // Apply relative modifiers from equipment if(sd->hprate < 0) sd->hprate = 0; if(sd->hprate!=100) - status->max_hp = (int64)status->max_hp * sd->hprate/100; + bstatus->max_hp = (int64)bstatus->max_hp * sd->hprate/100; if(battle_config.hp_rate != 100) - status->max_hp = (int64)status->max_hp * battle_config.hp_rate/100; + bstatus->max_hp = (int64)bstatus->max_hp * battle_config.hp_rate/100; - if(status->max_hp > (unsigned int)battle_config.max_hp) - status->max_hp = battle_config.max_hp; - else if(!status->max_hp) - status->max_hp = 1; + if(bstatus->max_hp > (unsigned int)battle_config.max_hp) + bstatus->max_hp = battle_config.max_hp; + else if(!bstatus->max_hp) + bstatus->max_hp = 1; // ----- SP MAX CALCULATION ----- // Basic MaxSP value - sd->status.max_sp = status_base_pc_maxsp(sd,status); + sd->status.max_sp = status_base_pc_maxsp(sd,bstatus); //This is done to handle underflows from negative Max SP bonuses - i64 = sd->status.max_sp + (int)status->max_sp; - status->max_sp = (unsigned int)cap_value(i64, 0, INT_MAX); + i64 = sd->status.max_sp + (int)bstatus->max_sp; + bstatus->max_sp = (unsigned int)cap_value(i64, 0, INT_MAX); // Absolute modifiers from passive skills if((skill_lv=pc->checkskill(sd,SL_KAINA))>0) - status->max_sp += 30*skill_lv; + bstatus->max_sp += 30*skill_lv; if((skill_lv=pc->checkskill(sd,HP_MEDITATIO))>0) - status->max_sp += (int64)status->max_sp * skill_lv/100; + bstatus->max_sp += (int64)bstatus->max_sp * skill_lv/100; if((skill_lv=pc->checkskill(sd,HW_SOULDRAIN))>0) - status->max_sp += (int64)status->max_sp * 2*skill_lv/100; + bstatus->max_sp += (int64)bstatus->max_sp * 2*skill_lv/100; if( (skill_lv = pc->checkskill(sd,RA_RESEARCHTRAP)) > 0 ) - status->max_sp += 200 + 20 * skill_lv; + bstatus->max_sp += 200 + 20 * skill_lv; if( (skill_lv = pc->checkskill(sd,WM_LESSON)) > 0 ) - status->max_sp += 30 * skill_lv; + bstatus->max_sp += 30 * skill_lv; // Apply relative modifiers from equipment if(sd->sprate < 0) sd->sprate = 0; if(sd->sprate!=100) - status->max_sp = (int64)status->max_sp * sd->sprate/100; + bstatus->max_sp = (int64)bstatus->max_sp * sd->sprate/100; if(battle_config.sp_rate != 100) - status->max_sp = (int64)status->max_sp * battle_config.sp_rate/100; + bstatus->max_sp = (int64)bstatus->max_sp * battle_config.sp_rate/100; - if(status->max_sp > (unsigned int)battle_config.max_sp) - status->max_sp = battle_config.max_sp; - else if(!status->max_sp) - status->max_sp = 1; + if(bstatus->max_sp > (unsigned int)battle_config.max_sp) + bstatus->max_sp = battle_config.max_sp; + else if(!bstatus->max_sp) + bstatus->max_sp = 1; // ----- RESPAWN HP/SP ----- // //Calc respawn hp and store it on base_status if (sd->special_state.restart_full_recover) { - status->hp = status->max_hp; - status->sp = status->max_sp; + bstatus->hp = bstatus->max_hp; + bstatus->sp = bstatus->max_sp; } else { if((sd->class_&MAPID_BASEMASK) == MAPID_NOVICE && !(sd->class_&JOBL_2) && battle_config.restart_hp_rate < 50) - status->hp = status->max_hp>>1; + bstatus->hp = bstatus->max_hp>>1; else - status->hp = (int64)status->max_hp * battle_config.restart_hp_rate/100; - if(!status->hp) - status->hp = 1; + bstatus->hp = (int64)bstatus->max_hp * battle_config.restart_hp_rate/100; + if(!bstatus->hp) + bstatus->hp = 1; - status->sp = (int64)status->max_sp * battle_config.restart_sp_rate /100; + bstatus->sp = (int64)bstatus->max_sp * battle_config.restart_sp_rate /100; - if( !status->sp ) /* the minimum for the respawn setting is SP:1 */ - status->sp = 1; + if( !bstatus->sp ) /* the minimum for the respawn setting is SP:1 */ + bstatus->sp = 1; } // ----- MISC CALCULATION ----- - iStatus->calc_misc(&sd->bl, status, sd->status.base_level); + iStatus->calc_misc(&sd->bl, bstatus, sd->status.base_level); //Equipment modifiers for misc settings if(sd->matk_rate < 0) sd->matk_rate = 0; if(sd->matk_rate != 100){ - status->matk_max = status->matk_max * sd->matk_rate/100; - status->matk_min = status->matk_min * sd->matk_rate/100; + bstatus->matk_max = bstatus->matk_max * sd->matk_rate/100; + bstatus->matk_min = bstatus->matk_min * sd->matk_rate/100; } if(sd->hit_rate < 0) sd->hit_rate = 0; if(sd->hit_rate != 100) - status->hit = status->hit * sd->hit_rate/100; + bstatus->hit = bstatus->hit * sd->hit_rate/100; if(sd->flee_rate < 0) sd->flee_rate = 0; if(sd->flee_rate != 100) - status->flee = status->flee * sd->flee_rate/100; + bstatus->flee = bstatus->flee * sd->flee_rate/100; if(sd->def2_rate < 0) sd->def2_rate = 0; if(sd->def2_rate != 100) - status->def2 = status->def2 * sd->def2_rate/100; + bstatus->def2 = bstatus->def2 * sd->def2_rate/100; if(sd->mdef2_rate < 0) sd->mdef2_rate = 0; if(sd->mdef2_rate != 100) - status->mdef2 = status->mdef2 * sd->mdef2_rate/100; + bstatus->mdef2 = bstatus->mdef2 * sd->mdef2_rate/100; if(sd->critical_rate < 0) sd->critical_rate = 0; if(sd->critical_rate != 100) - status->cri = status->cri * sd->critical_rate/100; + bstatus->cri = bstatus->cri * sd->critical_rate/100; if(sd->flee2_rate < 0) sd->flee2_rate = 0; if(sd->flee2_rate != 100) - status->flee2 = status->flee2 * sd->flee2_rate/100; + bstatus->flee2 = bstatus->flee2 * sd->flee2_rate/100; // ----- HIT CALCULATION ----- // Absolute modifiers from passive skills #ifndef RENEWAL if((skill_lv=pc->checkskill(sd,BS_WEAPONRESEARCH))>0) // is this correct in pre? there is already hitrate bonus in battle.c - status->hit += skill_lv*2; + bstatus->hit += skill_lv*2; #endif if((skill_lv=pc->checkskill(sd,AC_VULTURE))>0) { #ifndef RENEWAL - status->hit += skill_lv; + bstatus->hit += skill_lv; #endif if(sd->status.weapon == W_BOW) - status->rhw.range += skill_lv; + bstatus->rhw.range += skill_lv; } if(sd->status.weapon >= W_REVOLVER && sd->status.weapon <= W_GRENADE) { if((skill_lv=pc->checkskill(sd,GS_SINGLEACTION))>0) - status->hit += 2*skill_lv; + bstatus->hit += 2*skill_lv; if((skill_lv=pc->checkskill(sd,GS_SNAKEEYE))>0) { - status->hit += skill_lv; - status->rhw.range += skill_lv; + bstatus->hit += skill_lv; + bstatus->rhw.range += skill_lv; } } @@ -2926,24 +2910,23 @@ int status_calc_pc_(struct map_session_data* sd, bool first) // Absolute modifiers from passive skills if((skill_lv=pc->checkskill(sd,TF_MISS))>0) - status->flee += skill_lv*(sd->class_&JOBL_2 && (sd->class_&MAPID_BASEMASK) == MAPID_THIEF? 4 : 3); + bstatus->flee += skill_lv*(sd->class_&JOBL_2 && (sd->class_&MAPID_BASEMASK) == MAPID_THIEF? 4 : 3); if((skill_lv=pc->checkskill(sd,MO_DODGE))>0) - status->flee += (skill_lv*3)>>1; + bstatus->flee += (skill_lv*3)>>1; // ----- EQUIPMENT-DEF CALCULATION ----- // Apply relative modifiers from equipment if(sd->def_rate < 0) sd->def_rate = 0; if(sd->def_rate != 100) { - i = status->def * sd->def_rate/100; - status->def = cap_value(i, DEFTYPE_MIN, DEFTYPE_MAX); + i = bstatus->def * sd->def_rate/100; + bstatus->def = cap_value(i, DEFTYPE_MIN, DEFTYPE_MAX); } #ifndef RENEWAL - if (!battle_config.weapon_defense_type && status->def > battle_config.max_def) - { - status->def2 += battle_config.over_def_bonus*(status->def -battle_config.max_def); - status->def = (unsigned char)battle_config.max_def; + if (!battle_config.weapon_defense_type && bstatus->def > battle_config.max_def) { + bstatus->def2 += battle_config.over_def_bonus*(bstatus->def -battle_config.max_def); + bstatus->def = (unsigned char)battle_config.max_def; } #endif @@ -2953,15 +2936,14 @@ int status_calc_pc_(struct map_session_data* sd, bool first) if(sd->mdef_rate < 0) sd->mdef_rate = 0; if(sd->mdef_rate != 100) { - i = status->mdef * sd->mdef_rate/100; - status->mdef = cap_value(i, DEFTYPE_MIN, DEFTYPE_MAX); + i = bstatus->mdef * sd->mdef_rate/100; + bstatus->mdef = cap_value(i, DEFTYPE_MIN, DEFTYPE_MAX); } #ifndef RENEWAL - if (!battle_config.magic_defense_type && status->mdef > battle_config.max_def) - { - status->mdef2 += battle_config.over_def_bonus*(status->mdef -battle_config.max_def); - status->mdef = (signed char)battle_config.max_def; + if (!battle_config.magic_defense_type && bstatus->mdef > battle_config.max_def) { + bstatus->mdef2 += battle_config.over_def_bonus*(bstatus->mdef -battle_config.max_def); + bstatus->mdef = (signed char)battle_config.max_def; } #endif @@ -2969,44 +2951,44 @@ int status_calc_pc_(struct map_session_data* sd, bool first) // Unlike other stats, ASPD rate modifiers from skills/SCs/items/etc are first all added together, then the final modifier is applied // Basic ASPD value - i = status_base_amotion_pc(sd,status); - status->amotion = cap_value(i,((sd->class_&JOBL_THIRD) ? battle_config.max_third_aspd : battle_config.max_aspd),2000); + i = status_base_amotion_pc(sd,bstatus); + bstatus->amotion = cap_value(i,((sd->class_&JOBL_THIRD) ? battle_config.max_third_aspd : battle_config.max_aspd),2000); // Relative modifiers from passive skills #ifndef RENEWAL_ASPD if((skill_lv=pc->checkskill(sd,SA_ADVANCEDBOOK))>0 && sd->status.weapon == W_BOOK) - status->aspd_rate -= 5*skill_lv; + bstatus->aspd_rate -= 5*skill_lv; if((skill_lv = pc->checkskill(sd,SG_DEVIL)) > 0 && !pc->nextjobexp(sd)) - status->aspd_rate -= 30*skill_lv; + bstatus->aspd_rate -= 30*skill_lv; if((skill_lv=pc->checkskill(sd,GS_SINGLEACTION))>0 && (sd->status.weapon >= W_REVOLVER && sd->status.weapon <= W_GRENADE)) - status->aspd_rate -= ((skill_lv+1)/2) * 10; + bstatus->aspd_rate -= ((skill_lv+1)/2) * 10; if(pc_isriding(sd)) - status->aspd_rate += 500-100*pc->checkskill(sd,KN_CAVALIERMASTERY); + bstatus->aspd_rate += 500-100*pc->checkskill(sd,KN_CAVALIERMASTERY); else if(pc_isridingdragon(sd)) - status->aspd_rate += 250-50*pc->checkskill(sd,RK_DRAGONTRAINING); + bstatus->aspd_rate += 250-50*pc->checkskill(sd,RK_DRAGONTRAINING); #else // needs more info if((skill_lv=pc->checkskill(sd,SA_ADVANCEDBOOK))>0 && sd->status.weapon == W_BOOK) - status->aspd_rate += 5*skill_lv; + bstatus->aspd_rate += 5*skill_lv; if((skill_lv = pc->checkskill(sd,SG_DEVIL)) > 0 && !pc->nextjobexp(sd)) - status->aspd_rate += 30*skill_lv; + bstatus->aspd_rate += 30*skill_lv; if((skill_lv=pc->checkskill(sd,GS_SINGLEACTION))>0 && (sd->status.weapon >= W_REVOLVER && sd->status.weapon <= W_GRENADE)) - status->aspd_rate += ((skill_lv+1)/2) * 10; + bstatus->aspd_rate += ((skill_lv+1)/2) * 10; if(pc_isriding(sd)) - status->aspd_rate -= 500-100*pc->checkskill(sd,KN_CAVALIERMASTERY); + bstatus->aspd_rate -= 500-100*pc->checkskill(sd,KN_CAVALIERMASTERY); else if(pc_isridingdragon(sd)) - status->aspd_rate -= 250-50*pc->checkskill(sd,RK_DRAGONTRAINING); + bstatus->aspd_rate -= 250-50*pc->checkskill(sd,RK_DRAGONTRAINING); #endif - status->adelay = 2*status->amotion; + bstatus->adelay = 2*bstatus->amotion; // ----- DMOTION ----- // - i = 800-status->agi*4; - status->dmotion = cap_value(i, 400, 800); + i = 800-bstatus->agi*4; + bstatus->dmotion = cap_value(i, 400, 800); if(battle_config.pc_damage_delay_rate != 100) - status->dmotion = status->dmotion*battle_config.pc_damage_delay_rate/100; + bstatus->dmotion = bstatus->dmotion*battle_config.pc_damage_delay_rate/100; // ----- MISC CALCULATIONS ----- @@ -3136,7 +3118,7 @@ int status_calc_pc_(struct map_session_data* sd, bool first) if( sc->data[SC_EARTH_INSIGNIA] && sc->data[SC_EARTH_INSIGNIA]->val1 == 3 ) sd->magic_addele[ELE_EARTH] += 25; } - status_cpy(&sd->battle_status, status); + status_cpy(&sd->battle_status, bstatus); // ----- CLIENT-SIDE REFRESH ----- if(!sd->bl.prev) { @@ -3161,106 +3143,104 @@ int status_calc_pc_(struct map_session_data* sd, bool first) return 0; } -int status_calc_mercenary_(struct mercenary_data *md, bool first) -{ - struct status_data *status = &md->base_status; +int status_calc_mercenary_(struct mercenary_data *md, bool first) { + struct status_data *mstatus = &md->base_status; struct s_mercenary *merc = &md->mercenary; - if( first ) - { - memcpy(status, &md->db->status, sizeof(struct status_data)); - status->mode = MD_CANMOVE|MD_CANATTACK; - status->hp = status->max_hp; - status->sp = status->max_sp; + if( first ) { + memcpy(mstatus, &md->db->status, sizeof(struct status_data)); + mstatus->mode = MD_CANMOVE|MD_CANATTACK; + mstatus->hp = mstatus->max_hp; + mstatus->sp = mstatus->max_sp; md->battle_status.hp = merc->hp; md->battle_status.sp = merc->sp; } - iStatus->calc_misc(&md->bl, status, md->db->lv); - status_cpy(&md->battle_status, status); + iStatus->calc_misc(&md->bl, mstatus, md->db->lv); + status_cpy(&md->battle_status, mstatus); return 0; } int status_calc_homunculus_(struct homun_data *hd, bool first) { - struct status_data *status = &hd->base_status; + struct status_data *hstatus = &hd->base_status; struct s_homunculus *hom = &hd->homunculus; int skill_lv; int amotion; - status->str = hom->str / 10; - status->agi = hom->agi / 10; - status->vit = hom->vit / 10; - status->dex = hom->dex / 10; - status->int_ = hom->int_ / 10; - status->luk = hom->luk / 10; + hstatus->str = hom->str / 10; + hstatus->agi = hom->agi / 10; + hstatus->vit = hom->vit / 10; + hstatus->dex = hom->dex / 10; + hstatus->int_ = hom->int_ / 10; + hstatus->luk = hom->luk / 10; if (first) { //[orn] const struct s_homunculus_db *db = hd->homunculusDB; - status->def_ele = db->element; - status->ele_lv = 1; - status->race = db->race; - status->size = (hom->class_ == db->evo_class)?db->evo_size:db->base_size; - status->rhw.range = 1 + status->size; - status->mode = MD_CANMOVE|MD_CANATTACK; - status->speed = DEFAULT_WALK_SPEED; + hstatus->def_ele = db->element; + hstatus->ele_lv = 1; + hstatus->race = db->race; + hstatus->size = (hom->class_ == db->evo_class)?db->evo_size:db->base_size; + hstatus->rhw.range = 1 + hstatus->size; + hstatus->mode = MD_CANMOVE|MD_CANATTACK; + hstatus->speed = DEFAULT_WALK_SPEED; if (battle_config.hom_setting&0x8 && hd->master) - status->speed = iStatus->get_speed(&hd->master->bl); + hstatus->speed = iStatus->get_speed(&hd->master->bl); - status->hp = 1; - status->sp = 1; + hstatus->hp = 1; + hstatus->sp = 1; } - skill_lv = hom->level/10 + status->vit/5; - status->def = cap_value(skill_lv, 0, 99); + skill_lv = hom->level/10 + hstatus->vit/5; + hstatus->def = cap_value(skill_lv, 0, 99); - skill_lv = hom->level/10 + status->int_/5; - status->mdef = cap_value(skill_lv, 0, 99); + skill_lv = hom->level/10 + hstatus->int_/5; + hstatus->mdef = cap_value(skill_lv, 0, 99); - status->max_hp = hom->max_hp ; - status->max_sp = hom->max_sp ; + hstatus->max_hp = hom->max_hp; + hstatus->max_sp = hom->max_sp; homun->calc_skilltree(hd, 0); if((skill_lv=homun->checkskill(hd,HAMI_SKIN)) > 0) - status->def += skill_lv * 4; + hstatus->def += skill_lv * 4; if((skill_lv = homun->checkskill(hd,HVAN_INSTRUCT)) > 0) { - status->int_ += 1 +skill_lv/2 +skill_lv/4 +skill_lv/5; - status->str += 1 +skill_lv/3 +skill_lv/3 +skill_lv/4; + hstatus->int_ += 1 +skill_lv/2 +skill_lv/4 +skill_lv/5; + hstatus->str += 1 +skill_lv/3 +skill_lv/3 +skill_lv/4; } if((skill_lv=homun->checkskill(hd,HAMI_SKIN)) > 0) - status->max_hp += skill_lv * 2 * status->max_hp / 100; + hstatus->max_hp += skill_lv * 2 * hstatus->max_hp / 100; if((skill_lv = homun->checkskill(hd,HLIF_BRAIN)) > 0) - status->max_sp += (1 +skill_lv/2 -skill_lv/4 +skill_lv/5) * status->max_sp / 100 ; + hstatus->max_sp += (1 +skill_lv/2 -skill_lv/4 +skill_lv/5) * hstatus->max_sp / 100; if (first) { - hd->battle_status.hp = hom->hp ; - hd->battle_status.sp = hom->sp ; + hd->battle_status.hp = hom->hp; + hd->battle_status.sp = hom->sp; } - status->rhw.atk = status->dex; - status->rhw.atk2 = status->str + hom->level; + hstatus->rhw.atk = hstatus->dex; + hstatus->rhw.atk2 = hstatus->str + hom->level; - status->aspd_rate = 1000; + hstatus->aspd_rate = 1000; - amotion = (1000 -4*status->agi -status->dex) * hd->homunculusDB->baseASPD/1000; - status->amotion = cap_value(amotion,battle_config.max_aspd,2000); - status->adelay = status->amotion; //It seems adelay = amotion for Homunculus. + amotion = (1000 -4*hstatus->agi -hstatus->dex) * hd->homunculusDB->baseASPD/1000; + 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, status, hom->level); + iStatus->calc_misc(&hd->bl, hstatus, hom->level); #ifdef RENEWAL - status->matk_max = status->matk_min; + hstatus->matk_max = hstatus->matk_min; #endif - status_cpy(&hd->battle_status, status); + status_cpy(&hd->battle_status, hstatus); return 1; } int status_calc_elemental_(struct elemental_data *ed, bool first) { - struct status_data *status = &ed->base_status; + struct status_data *estatus = &ed->base_status; struct s_elemental *ele = &ed->elemental; struct map_session_data *sd = ed->master; @@ -3268,66 +3248,66 @@ int status_calc_elemental_(struct elemental_data *ed, bool first) { return 0; if( first ) { - memcpy(status, &ed->db->status, sizeof(struct status_data)); + memcpy(estatus, &ed->db->status, sizeof(struct status_data)); if( !ele->mode ) - status->mode = EL_MODE_PASSIVE; + estatus->mode = EL_MODE_PASSIVE; else - status->mode = ele->mode; + estatus->mode = ele->mode; - iStatus->calc_misc(&ed->bl, status, 0); + iStatus->calc_misc(&ed->bl, estatus, 0); - status->max_hp = ele->max_hp; - status->max_sp = ele->max_sp; - status->hp = ele->hp; - status->sp = ele->sp; - status->rhw.atk = ele->atk; - status->rhw.atk2 = ele->atk2; + estatus->max_hp = ele->max_hp; + estatus->max_sp = ele->max_sp; + estatus->hp = ele->hp; + estatus->sp = ele->sp; + estatus->rhw.atk = ele->atk; + estatus->rhw.atk2 = ele->atk2; - status->matk_min += ele->matk; - status->def += ele->def; - status->mdef += ele->mdef; - status->flee = ele->flee; - status->hit = ele->hit; + estatus->matk_min += ele->matk; + estatus->def += ele->def; + estatus->mdef += ele->mdef; + estatus->flee = ele->flee; + estatus->hit = ele->hit; - memcpy(&ed->battle_status,status,sizeof(struct status_data)); + memcpy(&ed->battle_status,estatus,sizeof(struct status_data)); } else { - iStatus->calc_misc(&ed->bl, status, 0); - status_cpy(&ed->battle_status, status); + iStatus->calc_misc(&ed->bl, estatus, 0); + status_cpy(&ed->battle_status, estatus); } return 0; } int status_calc_npc_(struct npc_data *nd, bool first) { - struct status_data *status = &nd->status; + struct status_data *nstatus = &nd->status; if (!nd) return 0; if (first) { - status->hp = 1; - status->sp = 1; - status->max_hp = 1; - status->max_sp = 1; - - status->def_ele = ELE_NEUTRAL; - status->ele_lv = 1; - status->race = RC_DEMIHUMAN; - status->size = nd->size; - status->rhw.range = 1 + status->size; - status->mode = (MD_CANMOVE|MD_CANATTACK); - status->speed = nd->speed; - } - - status->str = nd->stat_point; - status->agi = nd->stat_point; - status->vit = nd->stat_point; - status->int_= nd->stat_point; - status->dex = nd->stat_point; - status->luk = nd->stat_point; - - iStatus->calc_misc(&nd->bl, status, nd->level); - status_cpy(&nd->status, status); + nstatus->hp = 1; + nstatus->sp = 1; + nstatus->max_hp = 1; + nstatus->max_sp = 1; + + nstatus->def_ele = ELE_NEUTRAL; + nstatus->ele_lv = 1; + nstatus->race = RC_DEMIHUMAN; + nstatus->size = nd->size; + nstatus->rhw.range = 1 + nstatus->size; + nstatus->mode = (MD_CANMOVE|MD_CANATTACK); + nstatus->speed = nd->speed; + } + + nstatus->str = nd->stat_point; + nstatus->agi = nd->stat_point; + nstatus->vit = nd->stat_point; + nstatus->int_= nd->stat_point; + nstatus->dex = nd->stat_point; + nstatus->luk = nd->stat_point; + + iStatus->calc_misc(&nd->bl, nstatus, nd->level); + status_cpy(&nd->status, nstatus); return 0; } @@ -3363,7 +3343,7 @@ static unsigned short status_calc_batk(struct block_list *,struct status_change #endif //Calculates base regen values. -void status_calc_regen(struct block_list *bl, struct status_data *status, struct regen_data *regen) { +void status_calc_regen(struct block_list *bl, struct status_data *st, struct regen_data *regen) { struct map_session_data *sd; int val, skill_lv, reg_flag; @@ -3371,7 +3351,7 @@ void status_calc_regen(struct block_list *bl, struct status_data *status, struct return; sd = BL_CAST(BL_PC,bl); - val = 1 + (status->vit/5) + (status->max_hp/200); + val = 1 + (st->vit/5) + (st->max_hp/200); if( sd && sd->hprecov_rate != 100 ) val = val*sd->hprecov_rate/100; @@ -3380,9 +3360,9 @@ void status_calc_regen(struct block_list *bl, struct status_data *status, struct regen->hp = cap_value(val, reg_flag, SHRT_MAX); - val = 1 + (status->int_/6) + (status->max_sp/100); - if( status->int_ >= 120 ) - val += ((status->int_-120)>>1) + 4; + val = 1 + (st->int_/6) + (st->max_sp/100); + if( st->int_ >= 120 ) + val += ((st->int_-120)>>1) + 4; if( sd && sd->sprecov_rate != 100 ) val = val*sd->sprecov_rate/100; @@ -3400,14 +3380,14 @@ void status_calc_regen(struct block_list *bl, struct status_data *status, struct val = 0; if( (skill_lv=pc->checkskill(sd,SM_RECOVERY)) > 0 ) - val += skill_lv*5 + skill_lv*status->max_hp/500; + val += skill_lv*5 + skill_lv*st->max_hp/500; sregen->hp = cap_value(val, 0, SHRT_MAX); val = 0; if( (skill_lv=pc->checkskill(sd,MG_SRECOVERY)) > 0 ) - val += skill_lv*3 + skill_lv*status->max_sp/500; + val += skill_lv*3 + skill_lv*st->max_sp/500; if( (skill_lv=pc->checkskill(sd,NJ_NINPOU)) > 0 ) - val += skill_lv*3 + skill_lv*status->max_sp/500; + val += skill_lv*3 + skill_lv*st->max_sp/500; if( (skill_lv=pc->checkskill(sd,WM_LESSON)) > 0 ) val += 3 + 3 * skill_lv; @@ -3418,20 +3398,20 @@ void status_calc_regen(struct block_list *bl, struct status_data *status, struct val = 0; if( (skill_lv=pc->checkskill(sd,MO_SPIRITSRECOVERY)) > 0 ) - val += skill_lv*4 + skill_lv*status->max_hp/500; + val += skill_lv*4 + skill_lv*st->max_hp/500; if( (skill_lv=pc->checkskill(sd,TK_HPTIME)) > 0 && sd->state.rest ) - val += skill_lv*30 + skill_lv*status->max_hp/500; + val += skill_lv*30 + skill_lv*st->max_hp/500; sregen->hp = cap_value(val, 0, SHRT_MAX); val = 0; if( (skill_lv=pc->checkskill(sd,TK_SPTIME)) > 0 && sd->state.rest ) { - val += skill_lv*3 + skill_lv*status->max_sp/500; + val += skill_lv*3 + skill_lv*st->max_sp/500; if ((skill_lv=pc->checkskill(sd,SL_KAINA)) > 0) //Power up Enjoyable Rest val += (30+10*skill_lv)*val/100; } if( (skill_lv=pc->checkskill(sd,MO_SPIRITSRECOVERY)) > 0 ) - val += skill_lv*2 + skill_lv*status->max_sp/500; + val += skill_lv*2 + skill_lv*st->max_sp/500; sregen->sp = cap_value(val, 0, SHRT_MAX); } @@ -3446,16 +3426,16 @@ void status_calc_regen(struct block_list *bl, struct status_data *status, struct regen->sp = cap_value(val, 1, SHRT_MAX); } } else if( bl->type == BL_MER ) { - val = (status->max_hp * status->vit / 10000 + 1) * 6; + val = (st->max_hp * st->vit / 10000 + 1) * 6; regen->hp = cap_value(val, 1, SHRT_MAX); - val = (status->max_sp * (status->int_ + 10) / 750) + 1; + val = (st->max_sp * (st->int_ + 10) / 750) + 1; regen->sp = cap_value(val, 1, SHRT_MAX); } else if( bl->type == BL_ELEM ) { - val = (status->max_hp * status->vit / 10000 + 1) * 6; + val = (st->max_hp * st->vit / 10000 + 1) * 6; regen->hp = cap_value(val, 1, SHRT_MAX); - val = (status->max_sp * (status->int_ + 10) / 750) + 1; + val = (st->max_sp * (st->int_ + 10) / 750) + 1; regen->sp = cap_value(val, 1, SHRT_MAX); } } @@ -3546,31 +3526,30 @@ 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 *b_status = iStatus->get_base_status(bl); - struct status_data *status = iStatus->get_status_data(bl); +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); TBL_PC *sd = BL_CAST(BL_PC,bl); int temp; - if (!b_status || !status) + if (!bst || !st) return; if((!(bl->type&BL_REGEN)) && (!sc || !sc->count)) { //No difference. - status_cpy(status, b_status); + status_cpy(st, bst); return; } if(flag&SCB_STR) { - status->str = status_calc_str(bl, sc, b_status->str); + st->str = status_calc_str(bl, sc, bst->str); flag|=SCB_BATK; if( bl->type&BL_HOM ) flag |= SCB_WATK; } if(flag&SCB_AGI) { - status->agi = status_calc_agi(bl, sc, b_status->agi); + st->agi = status_calc_agi(bl, sc, bst->agi); flag|=SCB_FLEE #ifdef RENEWAL |SCB_DEF2 @@ -3581,7 +3560,7 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag) } if(flag&SCB_VIT) { - status->vit = status_calc_vit(bl, sc, b_status->vit); + st->vit = status_calc_vit(bl, sc, bst->vit); flag|=SCB_DEF2|SCB_MDEF2; if( bl->type&(BL_PC|BL_HOM|BL_MER|BL_ELEM) ) flag |= SCB_MAXHP; @@ -3590,7 +3569,7 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag) } if(flag&SCB_INT) { - status->int_ = status_calc_int(bl, sc, b_status->int_); + st->int_ = status_calc_int(bl, sc, bst->int_); flag|=SCB_MATK|SCB_MDEF2; if( bl->type&(BL_PC|BL_HOM|BL_MER|BL_ELEM) ) flag |= SCB_MAXSP; @@ -3599,7 +3578,7 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag) } if(flag&SCB_DEX) { - status->dex = status_calc_dex(bl, sc, b_status->dex); + st->dex = status_calc_dex(bl, sc, bst->dex); flag|=SCB_BATK|SCB_HIT #ifdef RENEWAL |SCB_MATK|SCB_MDEF2 @@ -3612,7 +3591,7 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag) } if(flag&SCB_LUK) { - status->luk = status_calc_luk(bl, sc, b_status->luk); + st->luk = status_calc_luk(bl, sc, bst->luk); flag|=SCB_BATK|SCB_CRI|SCB_FLEE2 #ifdef RENEWAL |SCB_MATK|SCB_HIT|SCB_FLEE @@ -3620,125 +3599,121 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag) ; } - if(flag&SCB_BATK && b_status->batk) { - status->batk = status_base_atk(bl,status); - temp = b_status->batk - status_base_atk(bl,b_status); - if (temp) - { - temp += status->batk; - status->batk = cap_value(temp, 0, USHRT_MAX); + if(flag&SCB_BATK && bst->batk) { + st->batk = status_base_atk(bl,st); + temp = bst->batk - status_base_atk(bl,bst); + if (temp) { + temp += st->batk; + st->batk = cap_value(temp, 0, USHRT_MAX); } - status->batk = iStatus->calc_batk(bl, sc, status->batk, true); + st->batk = iStatus->calc_batk(bl, sc, st->batk, true); } if(flag&SCB_WATK) { - status->rhw.atk = status_calc_watk(bl, sc, b_status->rhw.atk, true); + st->rhw.atk = status_calc_watk(bl, sc, bst->rhw.atk, true); if (!sd) //Should not affect weapon refine bonus - status->rhw.atk2 = status_calc_watk(bl, sc, b_status->rhw.atk2, true); + st->rhw.atk2 = status_calc_watk(bl, sc, bst->rhw.atk2, true); - if(b_status->lhw.atk) { + if(bst->lhw.atk) { if (sd) { sd->state.lr_flag = 1; - status->lhw.atk = status_calc_watk(bl, sc, b_status->lhw.atk, true); + st->lhw.atk = status_calc_watk(bl, sc, bst->lhw.atk, true); sd->state.lr_flag = 0; } else { - status->lhw.atk = status_calc_watk(bl, sc, b_status->lhw.atk, true); - status->lhw.atk2 = status_calc_watk(bl, sc, b_status->lhw.atk2, true); + st->lhw.atk = status_calc_watk(bl, sc, bst->lhw.atk, true); + st->lhw.atk2 = status_calc_watk(bl, sc, bst->lhw.atk2, true); } } - if( bl->type&BL_HOM ) - { - status->rhw.atk += (status->dex - b_status->dex); - status->rhw.atk2 += (status->str - b_status->str); - if( status->rhw.atk2 < status->rhw.atk ) - status->rhw.atk2 = status->rhw.atk; + if( bl->type&BL_HOM ) { + st->rhw.atk += (st->dex - bst->dex); + st->rhw.atk2 += (st->str - bst->str); + if( st->rhw.atk2 < st->rhw.atk ) + st->rhw.atk2 = st->rhw.atk; } } if(flag&SCB_HIT) { - if (status->dex == b_status->dex + if (st->dex == bst->dex #ifdef RENEWAL - && status->luk == b_status->luk + && st->luk == bst->luk #endif ) - status->hit = status_calc_hit(bl, sc, b_status->hit, true); + st->hit = status_calc_hit(bl, sc, bst->hit, true); else - status->hit = status_calc_hit(bl, sc, b_status->hit + (status->dex - b_status->dex) + st->hit = status_calc_hit(bl, sc, bst->hit + (st->dex - bst->dex) #ifdef RENEWAL - + (status->luk/3 - b_status->luk/3) + + (st->luk/3 - bst->luk/3) #endif , true); } if(flag&SCB_FLEE) { - if (status->agi == b_status->agi + if (st->agi == bst->agi #ifdef RENEWAL - && status->luk == b_status->luk + && st->luk == bst->luk #endif ) - status->flee = status_calc_flee(bl, sc, b_status->flee, true); + st->flee = status_calc_flee(bl, sc, bst->flee, true); else - status->flee = status_calc_flee(bl, sc, b_status->flee +(status->agi - b_status->agi) + st->flee = status_calc_flee(bl, sc, bst->flee +(st->agi - bst->agi) #ifdef RENEWAL - + (status->luk/5 - b_status->luk/5) + + (st->luk/5 - bst->luk/5) #endif , true); } - if(flag&SCB_DEF) - { - status->def = iStatus->calc_def(bl, sc, b_status->def, true); + if(flag&SCB_DEF) { + st->def = iStatus->calc_def(bl, sc, bst->def, true); if( bl->type&BL_HOM ) - status->def += (status->vit/5 - b_status->vit/5); + st->def += (st->vit/5 - bst->vit/5); } if(flag&SCB_DEF2) { - if (status->vit == b_status->vit + if (st->vit == bst->vit #ifdef RENEWAL - && status->agi == b_status->agi + && st->agi == bst->agi #endif ) - status->def2 = iStatus->calc_def2(bl, sc, b_status->def2, true); + st->def2 = iStatus->calc_def2(bl, sc, bst->def2, true); else - status->def2 = iStatus->calc_def2(bl, sc, b_status->def2 + st->def2 = iStatus->calc_def2(bl, sc, bst->def2 #ifdef RENEWAL - + (int)( ((float)status->vit/2 - (float)b_status->vit/2) + ((float)status->agi/5 - (float)b_status->agi/5) ) + + (int)( ((float)st->vit/2 - (float)bst->vit/2) + ((float)st->agi/5 - (float)bst->agi/5) ) #else - + (status->vit - b_status->vit) + + (st->vit - bst->vit) #endif , true); } - if(flag&SCB_MDEF) - { - status->mdef = iStatus->calc_mdef(bl, sc, b_status->mdef, true); + if(flag&SCB_MDEF) { + st->mdef = iStatus->calc_mdef(bl, sc, bst->mdef, true); if( bl->type&BL_HOM ) - status->mdef += (status->int_/5 - b_status->int_/5); + st->mdef += (st->int_/5 - bst->int_/5); } if(flag&SCB_MDEF2) { - if (status->int_ == b_status->int_ && status->vit == b_status->vit + if (st->int_ == bst->int_ && st->vit == bst->vit #ifdef RENEWAL - && status->dex == b_status->dex + && st->dex == bst->dex #endif ) - status->mdef2 = iStatus->calc_mdef2(bl, sc, b_status->mdef2, true); + st->mdef2 = iStatus->calc_mdef2(bl, sc, bst->mdef2, true); else - status->mdef2 = iStatus->calc_mdef2(bl, sc, b_status->mdef2 +(status->int_ - b_status->int_) + st->mdef2 = iStatus->calc_mdef2(bl, sc, bst->mdef2 +(st->int_ - bst->int_) #ifdef RENEWAL - + (int)( ((float)status->dex/5 - (float)b_status->dex/5) + ((float)status->vit/5 - (float)b_status->vit/5) ) + + (int)( ((float)st->dex/5 - (float)bst->dex/5) + ((float)st->vit/5 - (float)bst->vit/5) ) #else - + ((status->vit - b_status->vit)>>1) + + ((st->vit - bst->vit)>>1) #endif , true); } if(flag&SCB_SPEED) { struct unit_data *ud = unit->bl2ud(bl); - status->speed = status_calc_speed(bl, sc, b_status->speed); + st->speed = status_calc_speed(bl, sc, bst->speed); //Re-walk to adjust speed (we do not check if walktimer != INVALID_TIMER //because if you step on something while walking, the moment this @@ -3746,54 +3721,53 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag) if (ud) ud->state.change_walk_target = ud->state.speed_changed = 1; - if( bl->type&BL_PC && status->speed < battle_config.max_walk_speed ) - status->speed = battle_config.max_walk_speed; + if( bl->type&BL_PC && st->speed < battle_config.max_walk_speed ) + st->speed = battle_config.max_walk_speed; if( bl->type&BL_HOM && battle_config.hom_setting&0x8 && ((TBL_HOM*)bl)->master) - status->speed = iStatus->get_speed(&((TBL_HOM*)bl)->master->bl); + st->speed = iStatus->get_speed(&((TBL_HOM*)bl)->master->bl); } - if(flag&SCB_CRI && b_status->cri) { - if (status->luk == b_status->luk) - status->cri = status_calc_critical(bl, sc, b_status->cri, true); + if(flag&SCB_CRI && bst->cri) { + if (st->luk == bst->luk) + st->cri = status_calc_critical(bl, sc, bst->cri, true); else - status->cri = status_calc_critical(bl, sc, b_status->cri + 3*(status->luk - b_status->luk), true); + st->cri = status_calc_critical(bl, sc, bst->cri + 3*(st->luk - bst->luk), true); /** * after status_calc_critical so the bonus is applied despite if you have or not a sc bugreport:5240 **/ if( bl->type == BL_PC && ((TBL_PC*)bl)->status.weapon == W_KATAR ) - status->cri <<= 1; + st->cri <<= 1; } - if(flag&SCB_FLEE2 && b_status->flee2) { - if (status->luk == b_status->luk) - status->flee2 = status_calc_flee2(bl, sc, b_status->flee2, true); + if(flag&SCB_FLEE2 && bst->flee2) { + if (st->luk == bst->luk) + st->flee2 = status_calc_flee2(bl, sc, bst->flee2, true); else - status->flee2 = status_calc_flee2(bl, sc, b_status->flee2 +(status->luk - b_status->luk), true); + st->flee2 = status_calc_flee2(bl, sc, bst->flee2 +(st->luk - bst->luk), true); } if(flag&SCB_ATK_ELE) { - status->rhw.ele = iStatus->calc_attack_element(bl, sc, b_status->rhw.ele); + st->rhw.ele = iStatus->calc_attack_element(bl, sc, bst->rhw.ele); if (sd) sd->state.lr_flag = 1; - status->lhw.ele = iStatus->calc_attack_element(bl, sc, b_status->lhw.ele); + st->lhw.ele = iStatus->calc_attack_element(bl, sc, bst->lhw.ele); if (sd) sd->state.lr_flag = 0; } if(flag&SCB_DEF_ELE) { - status->def_ele = status_calc_element(bl, sc, b_status->def_ele); - status->ele_lv = status_calc_element_lv(bl, sc, b_status->ele_lv); + st->def_ele = status_calc_element(bl, sc, bst->def_ele); + st->ele_lv = status_calc_element_lv(bl, sc, bst->ele_lv); } - if(flag&SCB_MODE) - { - status->mode = status_calc_mode(bl, sc, b_status->mode); + if(flag&SCB_MODE) { + st->mode = status_calc_mode(bl, sc, bst->mode); //Since mode changed, reset their state. - if (!(status->mode&MD_CANATTACK)) + if (!(st->mode&MD_CANATTACK)) unit->stop_attack(bl); - if (!(status->mode&MD_CANMOVE)) + if (!(st->mode&MD_CANMOVE)) unit->stop_walking(bl,1); } @@ -3803,47 +3777,40 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag) // if(flag&SCB_RANGE) if(flag&SCB_MAXHP) { - if( bl->type&BL_PC ) - { - status->max_hp = status_base_pc_maxhp(sd,status); - status->max_hp += b_status->max_hp - sd->status.max_hp; + if( bl->type&BL_PC ) { + st->max_hp = status_base_pc_maxhp(sd,st); + st->max_hp += bst->max_hp - sd->status.max_hp; - status->max_hp = status_calc_maxhp(bl, sc, status->max_hp); + st->max_hp = status_calc_maxhp(bl, sc, st->max_hp); - if( status->max_hp > (unsigned int)battle_config.max_hp ) - status->max_hp = (unsigned int)battle_config.max_hp; - } - else - { - status->max_hp = status_calc_maxhp(bl, sc, b_status->max_hp); + if( st->max_hp > (unsigned int)battle_config.max_hp ) + st->max_hp = (unsigned int)battle_config.max_hp; + } else { + st->max_hp = status_calc_maxhp(bl, sc, bst->max_hp); } - if( status->hp > status->max_hp ) //FIXME: Should perhaps a status_zap should be issued? - { - status->hp = status->max_hp; + if( st->hp > st->max_hp ) { + //FIXME: Should perhaps a status_zap should be issued? + st->hp = st->max_hp; if( sd ) clif->updatestatus(sd,SP_HP); } } if(flag&SCB_MAXSP) { - if( bl->type&BL_PC ) - { - status->max_sp = status_base_pc_maxsp(sd,status); - status->max_sp += b_status->max_sp - sd->status.max_sp; + if( bl->type&BL_PC ) { + st->max_sp = status_base_pc_maxsp(sd,st); + st->max_sp += bst->max_sp - sd->status.max_sp; - status->max_sp = status_calc_maxsp(&sd->bl, &sd->sc, status->max_sp); + st->max_sp = status_calc_maxsp(&sd->bl, &sd->sc, st->max_sp); - if( status->max_sp > (unsigned int)battle_config.max_sp ) - status->max_sp = (unsigned int)battle_config.max_sp; - } - else - { - status->max_sp = status_calc_maxsp(bl, sc, b_status->max_sp); + if( st->max_sp > (unsigned int)battle_config.max_sp ) + st->max_sp = (unsigned int)battle_config.max_sp; + } else { + st->max_sp = status_calc_maxsp(bl, sc, bst->max_sp); } - if( status->sp > status->max_sp ) - { - status->sp = status->max_sp; + if( st->sp > st->max_sp ) { + st->sp = st->max_sp; if( sd ) clif->updatestatus(sd,SP_SP); } } @@ -3854,84 +3821,78 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag) if(flag&SCB_ASPD) { int amotion; - if( bl->type&BL_PC ) - { - amotion = status_base_amotion_pc(sd,status); + if( bl->type&BL_PC ) { + amotion = status_base_amotion_pc(sd,st); #ifndef RENEWAL_ASPD - status->aspd_rate = status_calc_aspd_rate(bl, sc, b_status->aspd_rate); + st->aspd_rate = status_calc_aspd_rate(bl, sc, bst->aspd_rate); - if(status->aspd_rate != 1000) - amotion = amotion*status->aspd_rate/1000; + if(st->aspd_rate != 1000) + amotion = amotion*st->aspd_rate/1000; #else // aspd = baseaspd + floor(sqrt((agi^2/2) + (dex^2/5))/4 + (potskillbonus*agi/200)) - amotion -= (int)(sqrt( (pow(status->agi, 2) / 2) + (pow(status->dex, 2) / 5) ) / 4 + ((float)status_calc_aspd(bl, sc, 1) * status->agi / 200)) * 10; + amotion -= (int)(sqrt( (pow(st->agi, 2) / 2) + (pow(st->dex, 2) / 5) ) / 4 + ((float)status_calc_aspd(bl, sc, 1) * st->agi / 200)) * 10; - if( (status_calc_aspd(bl, sc, 2) + status->aspd_rate2) != 0 ) // RE ASPD percertage modifier + if( (status_calc_aspd(bl, sc, 2) + st->aspd_rate2) != 0 ) // RE ASPD percertage modifier amotion -= (( amotion - ((sd->class_&JOBL_THIRD) ? battle_config.max_third_aspd : battle_config.max_aspd) ) - * (status_calc_aspd(bl, sc, 2) + status->aspd_rate2) / 10 + 5) / 10; + * (status_calc_aspd(bl, sc, 2) + st->aspd_rate2) / 10 + 5) / 10; - if(status->aspd_rate != 1000) // absolute percentage modifier - amotion = ( 200 - (200-amotion/10) * status->aspd_rate / 1000 ) * 10; + if(st->aspd_rate != 1000) // absolute percentage modifier + amotion = ( 200 - (200-amotion/10) * st->aspd_rate / 1000 ) * 10; #endif amotion = status_calc_fix_aspd(bl, sc, amotion); - status->amotion = cap_value(amotion,((sd->class_&JOBL_THIRD) ? battle_config.max_third_aspd : battle_config.max_aspd),2000); + st->amotion = cap_value(amotion,((sd->class_&JOBL_THIRD) ? battle_config.max_third_aspd : battle_config.max_aspd),2000); - status->adelay = 2*status->amotion; - } - else - if( bl->type&BL_HOM ) - { - amotion = (1000 -4*status->agi -status->dex) * ((TBL_HOM*)bl)->homunculusDB->baseASPD/1000; - status->aspd_rate = status_calc_aspd_rate(bl, sc, b_status->aspd_rate); + st->adelay = 2*st->amotion; + } else if( bl->type&BL_HOM ) { + amotion = (1000 - 4*st->agi - st->dex) * ((TBL_HOM*)bl)->homunculusDB->baseASPD/1000; + st->aspd_rate = status_calc_aspd_rate(bl, sc, bst->aspd_rate); - if(status->aspd_rate != 1000) - amotion = amotion*status->aspd_rate/1000; + if(st->aspd_rate != 1000) + amotion = amotion*st->aspd_rate/1000; - amotion = status_calc_fix_aspd(bl, sc, amotion); - status->amotion = cap_value(amotion,battle_config.max_aspd,2000); + amotion = status_calc_fix_aspd(bl, sc, amotion); + st->amotion = cap_value(amotion,battle_config.max_aspd,2000); - status->adelay = status->amotion; - } - else // mercenary and mobs - { - amotion = b_status->amotion; - status->aspd_rate = status_calc_aspd_rate(bl, sc, b_status->aspd_rate); + st->adelay = st->amotion; + } else { // mercenary and mobs + amotion = bst->amotion; + st->aspd_rate = status_calc_aspd_rate(bl, sc, bst->aspd_rate); - if(status->aspd_rate != 1000) - amotion = amotion*status->aspd_rate/1000; + if(st->aspd_rate != 1000) + amotion = amotion*st->aspd_rate/1000; - amotion = status_calc_fix_aspd(bl, sc, amotion); - status->amotion = cap_value(amotion, battle_config.monster_max_aspd, 2000); + amotion = status_calc_fix_aspd(bl, sc, amotion); + st->amotion = cap_value(amotion, battle_config.monster_max_aspd, 2000); - temp = b_status->adelay*status->aspd_rate/1000; - status->adelay = cap_value(temp, battle_config.monster_max_aspd*2, 4000); - } + temp = bst->adelay*st->aspd_rate/1000; + st->adelay = cap_value(temp, battle_config.monster_max_aspd*2, 4000); + } } if(flag&SCB_DSPD) { int dmotion; if( bl->type&BL_PC ) { - if (b_status->agi == status->agi) - status->dmotion = status_calc_dmotion(bl, sc, b_status->dmotion); + if (bst->agi == st->agi) + st->dmotion = status_calc_dmotion(bl, sc, bst->dmotion); else { - dmotion = 800-status->agi*4; - status->dmotion = cap_value(dmotion, 400, 800); + dmotion = 800-st->agi*4; + st->dmotion = cap_value(dmotion, 400, 800); if(battle_config.pc_damage_delay_rate != 100) - status->dmotion = status->dmotion*battle_config.pc_damage_delay_rate/100; - //It's safe to ignore b_status->dmotion since no bonus affects it. - status->dmotion = status_calc_dmotion(bl, sc, status->dmotion); + st->dmotion = st->dmotion*battle_config.pc_damage_delay_rate/100; + //It's safe to ignore bst->dmotion since no bonus affects it. + st->dmotion = status_calc_dmotion(bl, sc, st->dmotion); } } else if( bl->type&BL_HOM ) { - dmotion = 800-status->agi*4; - status->dmotion = cap_value(dmotion, 400, 800); - status->dmotion = status_calc_dmotion(bl, sc, b_status->dmotion); + dmotion = 800-st->agi*4; + st->dmotion = cap_value(dmotion, 400, 800); + st->dmotion = status_calc_dmotion(bl, sc, bst->dmotion); } else { // mercenary and mobs - status->dmotion = status_calc_dmotion(bl, sc, b_status->dmotion); + st->dmotion = status_calc_dmotion(bl, sc, bst->dmotion); } } if(flag&(SCB_VIT|SCB_MAXHP|SCB_INT|SCB_MAXSP) && bl->type&BL_REGEN) - iStatus->calc_regen(bl, status, iStatus->get_regen_data(bl)); + iStatus->calc_regen(bl, st, iStatus->get_regen_data(bl)); if(flag&SCB_REGEN && bl->type&BL_REGEN) iStatus->calc_regen_rate(bl, iStatus->get_regen_data(bl), sc); @@ -3940,10 +3901,9 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag) /// Also sends updates to the client wherever applicable. /// @param flag bitfield of values from enum scb_flag /// @param first if true, will cause status_calc_* functions to run their base status initialization code -void status_calc_bl_(struct block_list* bl, enum scb_flag flag, bool first) -{ - struct status_data b_status; // previous battle status - struct status_data* status; // pointer to current battle status +void status_calc_bl_(struct block_list *bl, enum scb_flag flag, bool first) { + struct status_data bst; // previous battle status + struct status_data *st; // pointer to current battle status if( bl->type == BL_PC && ((TBL_PC*)bl)->delayed_damage != 0 ) { ((TBL_PC*)bl)->state.hold_recalc = 1; @@ -3951,8 +3911,8 @@ void status_calc_bl_(struct block_list* bl, enum scb_flag flag, bool first) } // remember previous values - status = iStatus->get_status_data(bl); - memcpy(&b_status, status, sizeof(struct status_data)); + st = iStatus->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 ) { @@ -3978,137 +3938,136 @@ void status_calc_bl_(struct block_list* bl, enum scb_flag flag, bool first) return; // client update handled by caller // compare against new values and send client updates - if( bl->type == BL_PC ) - { + if( bl->type == BL_PC ) { TBL_PC* sd = BL_CAST(BL_PC, bl); - if(b_status.str != status->str) + if(bst.str != st->str) clif->updatestatus(sd,SP_STR); - if(b_status.agi != status->agi) + if(bst.agi != st->agi) clif->updatestatus(sd,SP_AGI); - if(b_status.vit != status->vit) + if(bst.vit != st->vit) clif->updatestatus(sd,SP_VIT); - if(b_status.int_ != status->int_) + if(bst.int_ != st->int_) clif->updatestatus(sd,SP_INT); - if(b_status.dex != status->dex) + if(bst.dex != st->dex) clif->updatestatus(sd,SP_DEX); - if(b_status.luk != status->luk) + if(bst.luk != st->luk) clif->updatestatus(sd,SP_LUK); - if(b_status.hit != status->hit) + if(bst.hit != st->hit) clif->updatestatus(sd,SP_HIT); - if(b_status.flee != status->flee) + if(bst.flee != st->flee) clif->updatestatus(sd,SP_FLEE1); - if(b_status.amotion != status->amotion) + if(bst.amotion != st->amotion) clif->updatestatus(sd,SP_ASPD); - if(b_status.speed != status->speed) + if(bst.speed != st->speed) clif->updatestatus(sd,SP_SPEED); - if(b_status.batk != status->batk + if(bst.batk != st->batk #ifndef RENEWAL - || b_status.rhw.atk != status->rhw.atk || b_status.lhw.atk != status->lhw.atk + || bst.rhw.atk != st->rhw.atk || bst.lhw.atk != st->lhw.atk #endif - ) + ) clif->updatestatus(sd,SP_ATK1); - if(b_status.def != status->def){ + if(bst.def != st->def) { clif->updatestatus(sd,SP_DEF1); #ifdef RENEWAL clif->updatestatus(sd,SP_DEF2); #endif } - if(b_status.rhw.atk2 != status->rhw.atk2 || b_status.lhw.atk2 != status->lhw.atk2 + if(bst.rhw.atk2 != st->rhw.atk2 || bst.lhw.atk2 != st->lhw.atk2 #ifdef RENEWAL - || b_status.rhw.atk != status->rhw.atk || b_status.lhw.atk != status->lhw.atk + || bst.rhw.atk != st->rhw.atk || bst.lhw.atk != st->lhw.atk #endif ) clif->updatestatus(sd,SP_ATK2); - if(b_status.def2 != status->def2){ + if(bst.def2 != st->def2){ clif->updatestatus(sd,SP_DEF2); #ifdef RENEWAL clif->updatestatus(sd,SP_DEF1); #endif } - if(b_status.flee2 != status->flee2) + if(bst.flee2 != st->flee2) clif->updatestatus(sd,SP_FLEE2); - if(b_status.cri != status->cri) + if(bst.cri != st->cri) clif->updatestatus(sd,SP_CRITICAL); #ifndef RENEWAL - if(b_status.matk_max != status->matk_max) + if(bst.matk_max != st->matk_max) clif->updatestatus(sd,SP_MATK1); - if(b_status.matk_min != status->matk_min) + if(bst.matk_min != st->matk_min) clif->updatestatus(sd,SP_MATK2); #else - if(b_status.matk_max != status->matk_max || b_status.matk_min != status->matk_min){ + if(bst.matk_max != st->matk_max || bst.matk_min != st->matk_min){ clif->updatestatus(sd,SP_MATK2); clif->updatestatus(sd,SP_MATK1); } #endif - if(b_status.mdef != status->mdef){ + if(bst.mdef != st->mdef) { clif->updatestatus(sd,SP_MDEF1); #ifdef RENEWAL clif->updatestatus(sd,SP_MDEF2); #endif } - if(b_status.mdef2 != status->mdef2){ + if(bst.mdef2 != st->mdef2) { clif->updatestatus(sd,SP_MDEF2); #ifdef RENEWAL clif->updatestatus(sd,SP_MDEF1); #endif } - if(b_status.rhw.range != status->rhw.range) + if(bst.rhw.range != st->rhw.range) clif->updatestatus(sd,SP_ATTACKRANGE); - if(b_status.max_hp != status->max_hp) + if(bst.max_hp != st->max_hp) clif->updatestatus(sd,SP_MAXHP); - if(b_status.max_sp != status->max_sp) + if(bst.max_sp != st->max_sp) clif->updatestatus(sd,SP_MAXSP); - if(b_status.hp != status->hp) + if(bst.hp != st->hp) clif->updatestatus(sd,SP_HP); - if(b_status.sp != status->sp) + if(bst.sp != st->sp) clif->updatestatus(sd,SP_SP); #ifdef RENEWAL - if(b_status.equip_atk != status->equip_atk) + if(bst.equip_atk != st->equip_atk) clif->updatestatus(sd,SP_ATK2); #endif } else if( bl->type == BL_HOM ) { TBL_HOM* hd = BL_CAST(BL_HOM, bl); - if( hd->master && memcmp(&b_status, status, sizeof(struct status_data)) != 0 ) + if( hd->master && memcmp(&bst, st, sizeof(struct status_data)) != 0 ) clif->hominfo(hd->master,hd,0); } else if( bl->type == BL_MER ) { TBL_MER* md = BL_CAST(BL_MER, bl); - if( b_status.rhw.atk != status->rhw.atk || b_status.rhw.atk2 != status->rhw.atk2 ) + if( bst.rhw.atk != st->rhw.atk || bst.rhw.atk2 != st->rhw.atk2 ) clif->mercenary_updatestatus(md->master, SP_ATK1); - if( b_status.matk_max != status->matk_max ) + if( bst.matk_max != st->matk_max ) clif->mercenary_updatestatus(md->master, SP_MATK1); - if( b_status.hit != status->hit ) + if( bst.hit != st->hit ) clif->mercenary_updatestatus(md->master, SP_HIT); - if( b_status.cri != status->cri ) + if( bst.cri != st->cri ) clif->mercenary_updatestatus(md->master, SP_CRITICAL); - if( b_status.def != status->def ) + if( bst.def != st->def ) clif->mercenary_updatestatus(md->master, SP_DEF1); - if( b_status.mdef != status->mdef ) + if( bst.mdef != st->mdef ) clif->mercenary_updatestatus(md->master, SP_MDEF1); - if( b_status.flee != status->flee ) + if( bst.flee != st->flee ) clif->mercenary_updatestatus(md->master, SP_MERCFLEE); - if( b_status.amotion != status->amotion ) + if( bst.amotion != st->amotion ) clif->mercenary_updatestatus(md->master, SP_ASPD); - if( b_status.max_hp != status->max_hp ) + if( bst.max_hp != st->max_hp ) clif->mercenary_updatestatus(md->master, SP_MAXHP); - if( b_status.max_sp != status->max_sp ) + if( bst.max_sp != st->max_sp ) clif->mercenary_updatestatus(md->master, SP_MAXSP); - if( b_status.hp != status->hp ) + if( bst.hp != st->hp ) clif->mercenary_updatestatus(md->master, SP_HP); - if( b_status.sp != status->sp ) + if( bst.sp != st->sp ) clif->mercenary_updatestatus(md->master, SP_SP); } else if( bl->type == BL_ELEM ) { TBL_ELEM* ed = BL_CAST(BL_ELEM, bl); - if( b_status.max_hp != status->max_hp ) + if( bst.max_hp != st->max_hp ) clif->elemental_updatestatus(ed->master, SP_MAXHP); - if( b_status.max_sp != status->max_sp ) + if( bst.max_sp != st->max_sp ) clif->elemental_updatestatus(ed->master, SP_MAXSP); - if( b_status.hp != status->hp ) + if( bst.hp != st->hp ) clif->elemental_updatestatus(ed->master, SP_HP); - if( b_status.sp != status->sp ) + if( bst.sp != st->sp ) clif->mercenary_updatestatus(ed->master, SP_SP); } } @@ -5875,8 +5834,8 @@ 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 *status = iStatus->get_status_data(bl); - int def = status?status->def:0; + struct status_data *st = iStatus->get_status_data(bl); + int def = st ? st->def : 0; ud = unit->bl2ud(bl); if (ud && ud->skilltimer != INVALID_TIMER) def -= def * skill->get_castdef(ud->skill_id)/100; @@ -6222,16 +6181,15 @@ void status_change_init(struct block_list *bl) //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. -int status_get_sc_def(struct block_list *bl, enum sc_type type, int rate, int tick, int flag) -{ +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 int sc_def = 0, tick_def = -1; //-1 = use sc_def //Linear resistance substracted from rate and tick after percentual resistance was applied //Example: 25% -> sc_def2=2000 -> 5%; 2500ms -> tick_def2=2000 -> 500ms int sc_def2 = 0, tick_def2 = -1; //-1 = use sc_def2 - struct status_data* status; - struct status_change* sc; + struct status_data *st; + struct status_change *sc; struct map_session_data *sd; nullpo_ret(bl); @@ -6269,10 +6227,10 @@ int status_get_sc_def(struct block_list *bl, enum sc_type type, int rate, int ti case SC__UNLUCKY: case SC__WEAKNESS: return 0; - } + } sd = BL_CAST(BL_PC,bl); - status = iStatus->get_status_data(bl); + st = iStatus->get_status_data(bl); sc = iStatus->get_sc(bl); if( sc && !sc->count ) sc = NULL; @@ -6284,16 +6242,16 @@ int status_get_sc_def(struct block_list *bl, enum sc_type type, int rate, int ti case SC_DPOISON: case SC_SILENCE: case SC_BLOODING: - sc_def = status->vit*100; - sc_def2 = status->luk*10; + sc_def = st->vit*100; + sc_def2 = st->luk*10; break; case SC_SLEEP: - sc_def = status->int_*100; - sc_def2 = status->luk*10; + sc_def = st->int_*100; + sc_def2 = st->luk*10; break; case SC_DEEP_SLEEP: - sc_def = status->int_*50; - tick_def = status->int_*10 + iStatus->get_lv(bl) * 65 / 10; //Seems to be -1 sec every 10 int and -5% chance every 10 int. + 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. break; case SC_DEC_AGI: case SC_ADORAMUS: //Arch Bishop @@ -6303,87 +6261,87 @@ int status_get_sc_def(struct block_list *bl, enum sc_type type, int rate, int ti tick_def = 0; tick_def2 = 0; case SC_FREEZE: - sc_def = status->mdef*100; - sc_def2 = status->luk*10; + sc_def = st->mdef*100; + sc_def2 = st->luk*10; break; case SC_CURSE: //Special property: inmunity when luk is greater than level or zero - if (status->luk > iStatus->get_lv(bl) || status->luk == 0) + if (st->luk > iStatus->get_lv(bl) || st->luk == 0) return 0; - sc_def = status->luk*100; - sc_def2 = status->luk*10; - tick_def = status->vit*100; + sc_def = st->luk*100; + sc_def2 = st->luk*10; + tick_def = st->vit*100; break; case SC_BLIND: if( sc && sc->data[SC__UNLUCKY] ) return tick; - sc_def = (status->vit + status->int_)*50; - sc_def2 = status->luk*10; + sc_def = (st->vit + st->int_)*50; + sc_def2 = st->luk*10; break; case SC_CONFUSION: - sc_def = (status->str + status->int_)*50; - sc_def2 = status->luk*10; + sc_def = (st->str + st->int_)*50; + sc_def2 = st->luk*10; break; case SC_ANKLESNARE: - if(status->mode&MD_BOSS) // Lasts 5 times less on bosses + if(st->mode&MD_BOSS) // Lasts 5 times less on bosses tick /= 5; - sc_def = status->agi*50; + sc_def = st->agi*50; break; case SC_MAGICMIRROR: case SC_STONESKIN: if (sd) //Duration greatly reduced for players. tick /= 15; - sc_def2 = iStatus->get_lv(bl)*20 + status->vit*25 + status->agi*10; // Lineal Reduction of Rate + sc_def2 = iStatus->get_lv(bl)*20 + st->vit*25 + st->agi*10; // Lineal Reduction of Rate tick_def2 = 0; //No duration reduction break; case SC_MARSHOFABYSS: //5 second (Fixed) + 25 second - {( INT + LUK ) / 20 second } - tick_def2 = (status->int_ + status->luk)*50; + tick_def2 = (st->int_ + st->luk)*50; break; case SC_STASIS: //5 second (fixed) + { Stasis Skill level * 5 - (Target's VIT + DEX) / 20 } - tick_def2 = (status->vit + status->dex)*50; + tick_def2 = (st->vit + st->dex)*50; break; if( bl->type == BL_PC ) - tick -= (iStatus->get_lv(bl) / 5 + status->vit / 4 + status->agi / 10)*100; + tick -= (iStatus->get_lv(bl) / 5 + st->vit / 4 + st->agi / 10)*100; else - tick -= (status->vit + status->luk) / 20 * 1000; + tick -= (st->vit + st->luk) / 20 * 1000; break; case SC_BURNING: - tick -= 75 * status->luk + 125 * status->agi; + tick -= 75 * st->luk + 125 * st->agi; tick = max(tick,5000); // Minimum Duration 5s. break; case SC_FROSTMISTY: - tick -= 1000 * ((status->vit + status->dex) / 20); + tick -= 1000 * ((st->vit + st->dex) / 20); tick = max(tick,6000); // Minimum Duration 6s. break; case SC_OBLIVIONCURSE: // 100% - (100 - 0.8 x INT) - sc_def = 100 - ( 100 - status->int_* 8 / 10 ); + sc_def = 100 - ( 100 - st->int_* 8 / 10 ); sc_def = max(sc_def, 5); // minimum of 5% break; case SC_WUGBITE: // {(Base Success chance) - (Target's AGI / 4)} - rate -= status->agi*100/4; + rate -= st->agi*100/4; rate = max(rate,5000); // minimum of 50% break; case SC_ELECTRICSHOCKER: if( bl->type == BL_MOB ) - tick -= 1000 * (status->agi/10); + tick -= 1000 * (st->agi/10); break; case SC_COLD: - tick -= (1000*(status->vit/10))+(iStatus->get_lv(bl)/50); + tick -= (1000*(st->vit/10))+(iStatus->get_lv(bl)/50); break; case SC_SIREN: tick -= 1000 * ((iStatus->get_lv(bl) / 10) + ((sd?sd->status.job_level:0) / 5)); tick = max(tick,10000); break; case SC_MANDRAGORA: - sc_def = (status->vit+status->luk)/5; + sc_def = (st->vit+st->luk)/5; break; case SC_KYOUGAKU: tick -= 1000 * status_get_int(bl) / 20; break; case SC_NEEDLE_OF_PARALYZE: - tick -= 50 * (status->vit + status->luk); //(1000/20); + tick -= 50 * (st->vit + st->luk); //(1000/20); break; default: //Effect that cannot be reduced? Likely a buff. @@ -6563,16 +6521,15 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val struct map_session_data *sd = NULL; struct status_change* sc; struct status_change_entry* sce; - struct status_data *status; + struct status_data *st; struct view_data *vd; int opt_flag, calc_flag, undead_flag, val_flag = 0, tick_time = 0; nullpo_ret(bl); sc = iStatus->get_sc(bl); - status = iStatus->get_status_data(bl); + st = iStatus->get_status_data(bl); - if( type <= SC_NONE || type >= SC_MAX ) - { + if( type <= SC_NONE || type >= SC_MAX ) { ShowError("status_change_start: invalid status change (%d)!\n", type); return 0; } @@ -6642,13 +6599,12 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val sd = BL_CAST(BL_PC, bl); //Adjust tick according to status resistances - if( !(flag&(1|4)) ) - { + if( !(flag&(1|4)) ) { tick = iStatus->get_sc_def(bl, type, rate, tick, flag); if( !tick ) return 0; } - undead_flag = battle->check_undead(status->race,status->def_ele); + undead_flag = battle->check_undead(st->race,st->def_ele); //Check for inmunities / sc fails switch (type) { case SC_DRUMBATTLE: @@ -6697,7 +6653,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val case SC_CRUCIS: //Only affects demons and undead element (but not players) - if((!undead_flag && status->race!=RC_DEMON) || bl->type == BL_PC) + if((!undead_flag && st->race!=RC_DEMON) || bl->type == BL_PC) return 0; break; case SC_LEXAETERNA: @@ -6765,18 +6721,18 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val case SC_MODECHANGE: { int mode; - struct status_data *bstatus = iStatus->get_base_status(bl); - if (!bstatus) return 0; - if (sc->data[type]) - { //Pile up with previous values. + 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:bstatus->mode; //Base mode + mode = val2 ? val2 : bst->mode; //Base mode if (val4) mode&=~val4; //Del mode if (val3) mode|= val3; //Add mode - if (mode == bstatus->mode) { //No change. + if (mode == bst->mode) { //No change. if (sc->data[type]) //Abort previous status return status_change_end(bl, type, INVALID_TIMER); return 0; @@ -6940,7 +6896,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val } //Check for BOSS resistances - if(status->mode&MD_BOSS && !(flag&1)) { + if(st->mode&MD_BOSS && !(flag&1)) { if (type>=SC_COMMON_MIN && type <= SC_COMMON_MAX) return 0; switch (type) { @@ -6993,7 +6949,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val case SC_BLESSING: //TO-DO Blessing and Agi up should do 1 damage against players on Undead Status, even on PvM //but cannot be plagiarized (this requires aegis investigation on packets and official behavior) [Brainstorm] - if ((!undead_flag && status->race!=RC_DEMON) || bl->type == BL_PC) { + if ((!undead_flag && st->race!=RC_DEMON) || bl->type == BL_PC) { status_change_end(bl, SC_CURSE, INVALID_TIMER); if (sc->data[SC_STONE] && sc->opt1 == OPT1_STONE) status_change_end(bl, SC_STONE, INVALID_TIMER); @@ -7357,7 +7313,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val tick = -1; break; case SC_AUTOBERSERK: - if (status->hp < status->max_hp>>2 && + if (st->hp < st->max_hp>>2 && (!sc->data[SC_PROVOKE] || sc->data[SC_PROVOKE]->val2==0)) sc_start4(bl,SC_PROVOKE,100,10,1,0,0,60000); tick = -1; @@ -7388,7 +7344,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val val2 = val1*20; //SP gained break; case SC_KYRIE: - val2 = (int64)status->max_hp * (val1 * 2 + 10) / 100; //%Max HP to absorb + val2 = (int64)st->max_hp * (val1 * 2 + 10) / 100; //%Max HP to absorb val3 = (val1 / 2 + 5); //Hits break; case SC_MAGICPOWER: @@ -7470,21 +7426,21 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val case SC_VOLCANO: val2 = val1*10; //Watk increase #ifndef RENEWAL - if (status->def_ele != ELE_FIRE) + if (st->def_ele != ELE_FIRE) val2 = 0; #endif break; case SC_VIOLENTGALE: val2 = val1*3; //Flee increase #ifndef RENEWAL - if (status->def_ele != ELE_WIND) + if (st->def_ele != ELE_WIND) val2 = 0; #endif break; case SC_DELUGE: val2 = deluge_eff[val1-1]; //HP increase #ifndef RENEWAL - if(status->def_ele != ELE_WATER) + if(st->def_ele != ELE_WATER) val2 = 0; #endif break; @@ -7572,10 +7528,10 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val case SC_DPOISON: //Lose 10/15% of your life as long as it doesn't brings life below 25% - if (status->hp > status->max_hp>>2) { - int diff = status->max_hp*(bl->type==BL_PC?10:15)/100; - if (status->hp - diff < status->max_hp>>2) - diff = status->hp - (status->max_hp>>2); + if (st->hp > st->max_hp>>2) { + int diff = st->max_hp*(bl->type==BL_PC?10:15)/100; + 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); if( src ) @@ -7590,9 +7546,9 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val tick_time = 1000; // [GodLesZ] tick time //val4: HP damage if (bl->type == BL_PC) - val4 = (type == SC_DPOISON) ? 3 + status->max_hp/50 : 3 + status->max_hp*3/200; + val4 = (type == SC_DPOISON) ? 3 + st->max_hp/50 : 3 + st->max_hp*3/200; else - val4 = (type == SC_DPOISON) ? 3 + status->max_hp/100 : 3 + status->max_hp/200; + val4 = (type == SC_DPOISON) ? 3 + st->max_hp/100 : 3 + st->max_hp/200; break; case SC_CONFUSION: @@ -7796,7 +7752,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val 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* status = iStatus->get_status_data(bl); // battle status + struct status_data* tst = iStatus->get_status_data(bl); // battle status if (!psce) return 0; @@ -7804,12 +7760,12 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val val3 = 0; val4 = 0; max_stat = battle_config.max_parameter; //Cap to 99 (default) - stat = (psce->val3 >>16)&0xFF; stat = min(stat, max_stat - status->str ); val3 |= cap_value(stat,0,0xFF)<<16; - stat = (psce->val3 >> 8)&0xFF; stat = min(stat, max_stat - status->agi ); val3 |= cap_value(stat,0,0xFF)<<8; - stat = (psce->val3 >> 0)&0xFF; stat = min(stat, max_stat - status->vit ); val3 |= cap_value(stat,0,0xFF); - stat = (psce->val4 >>16)&0xFF; stat = min(stat, max_stat - status->int_); val4 |= cap_value(stat,0,0xFF)<<16; - stat = (psce->val4 >> 8)&0xFF; stat = min(stat, max_stat - status->dex ); val4 |= cap_value(stat,0,0xFF)<<8; - stat = (psce->val4 >> 0)&0xFF; stat = min(stat, max_stat - status->luk ); val4 |= cap_value(stat,0,0xFF); + 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: @@ -7861,9 +7817,9 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val if( val3 && bl->type == BL_MOB ) { struct block_list* src = iMap->id2bl(val3); if( src ) - mob->log_damage((TBL_MOB*)bl,src,status->hp - 1); + mob->log_damage((TBL_MOB*)bl,src,st->hp - 1); } - status_zap(bl, status->hp-1, val2?0:status->sp); + status_zap(bl, st->hp-1, val2 ? 0 : st->sp); return 1; break; case SC_RG_CCONFINE_S: @@ -7931,7 +7887,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val val4 = INVALID_TIMER; //Kaahi Timer. break; case SC_BLESSING: - if ((!undead_flag && status->race!=RC_DEMON) || bl->type == BL_PC) + if ((!undead_flag && st->race!=RC_DEMON) || bl->type == BL_PC) val2 = val1; else val2 = 0; //0 -> Half stat. @@ -7986,13 +7942,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) + status->dex + status->luk)/2; //def increase + val2 = (iStatus->get_lv(bl) + st->dex + st->luk)/2; //def increase break; case SC_MOON_COMFORT: - val2 = (iStatus->get_lv(bl) + status->dex + status->luk)/10; //flee increase + val2 = (iStatus->get_lv(bl) + st->dex + st->luk)/10; //flee increase break; case SC_STAR_COMFORT: - val2 = (iStatus->get_lv(bl) + status->dex + status->luk); //Aspd increase + val2 = (iStatus->get_lv(bl) + st->dex + st->luk); //Aspd increase break; case SC_QUAGMIRE: val2 = (sd?5:10)*val1; //Agi/Dex decrease. @@ -8076,7 +8032,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val val3= 20*val1; //Int increase break; case SC_SWOO: - if(status->mode&MD_BOSS) + if(st->mode&MD_BOSS) tick /= 5; //TODO: Reduce skill's duration. But for how long? break; case SC_SPIDERWEB: @@ -8411,7 +8367,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val } break; case SC_VACUUM_EXTREME: - tick -= (status->str / 20) * 1000; + tick -= (st->str / 20) * 1000; val4 = val3 = tick / 100; tick_time = 100; // [GodLesZ] tick time break; @@ -8520,8 +8476,8 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val 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] break; - case SC_PRESTIGE: // Bassed on suggested formula in iRO Wiki and some test, still need more test. [pakpil] - val2 = ((status->int_ + status->luk) / 6) + 5; // Chance to evade magic damage. + 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. val1 *= 15; // Defence added if( sd ) val1 += 10 * pc->checkskill(sd,CR_DEFENDER); @@ -8569,7 +8525,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val case SC_GENTLETOUCH_CHANGE: {// take note there is no def increase as skill desc says. [malufett] struct block_list * src; - val3 = status->agi * val1 / 60; // ASPD increase: [(Target AGI x Skill Level) / 60] % + 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] @@ -9132,10 +9088,10 @@ 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, status->max_hp, 0, 1); //Do not use percent_heal as this healing must override BERSERK's block. + 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 } - sce->val2 = 5 * status->max_hp / 100; + sce->val2 = 5 * st->max_hp / 100; break; case SC_HLIF_CHANGE: status_percent_heal(bl, 100, 100); @@ -9203,7 +9159,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val } break; case SC_RAISINGDRAGON: - sce->val2 = status->max_hp / 100;// Officially tested its 1%hp drain. [Jobbie] + sce->val2 = st->max_hp / 100;// Officially tested its 1%hp drain. [Jobbie] break; } @@ -9291,14 +9247,14 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const struct map_session_data *sd; struct status_change *sc; struct status_change_entry *sce; - struct status_data *status; + struct status_data *st; struct view_data *vd; int opt_flag=0, calc_flag; nullpo_ret(bl); sc = iStatus->get_sc(bl); - status = iStatus->get_status_data(bl); + st = iStatus->get_status_data(bl); if(type < 0 || type >= SC_MAX || !sc || !(sce = sc->data[type])) return 0; @@ -9346,13 +9302,14 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const vd = iStatus->get_viewdata(bl); calc_flag = StatusChangeFlagTable[type]; switch(type) { - case SC_GRANITIC_ARMOR:{ - int dammage = status->max_hp*sce->val3/100; - if(status->hp < dammage) //to not kill him - dammage = status->hp-1; - iStatus->damage(NULL, bl, dammage,0,0,1); + case SC_GRANITIC_ARMOR: + { + 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); + } break; - } case SC_PYROCLASTIC: if(bl->type == BL_PC) skill->break_equip(bl,EQP_WEAPON,10000,BCT_SELF); @@ -9573,15 +9530,12 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const case SC_BERSERK: case SC_SATURDAY_NIGHT_FEVER: - if(status->hp > 200 && sc && sc->data[SC__BLOODYLUST]){ + if(st->hp > 200 && sc && sc->data[SC__BLOODYLUST]) { status_percent_heal(bl, 100, 0); status_change_end(bl, SC__BLOODYLUST, INVALID_TIMER); - }else - //If val2 is removed, no HP penalty (dispelled?) [Skotlex] - if(status->hp > 100 && sce->val2) + } else if(st->hp > 100 && sce->val2) //If val2 is removed, no HP penalty (dispelled?) [Skotlex] iStatus->set_hp(bl, 100, 0); - if(sc->data[SC_ENDURE] && sc->data[SC_ENDURE]->val4 == 2) - { + 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); } @@ -9982,12 +9936,11 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const return 1; } -int kaahi_heal_timer(int tid, unsigned int tick, int id, intptr_t data) -{ +int kaahi_heal_timer(int tid, unsigned int tick, int id, intptr_t data) { struct block_list *bl; struct status_change *sc; struct status_change_entry *sce; - struct status_data *status; + struct status_data *st; int hp; if(!((bl=iMap->id2bl(id))&& @@ -10001,13 +9954,13 @@ int kaahi_heal_timer(int tid, unsigned int tick, int id, intptr_t data) return 0; } - status=iStatus->get_status_data(bl); + st=iStatus->get_status_data(bl); if(!iStatus->charge(bl, 0, sce->val3)) { sce->val4 = INVALID_TIMER; return 0; } - hp = status->max_hp - status->hp; + hp = st->max_hp - st->hp; if (hp > sce->val2) hp = sce->val2; if (hp) @@ -10020,12 +9973,11 @@ int kaahi_heal_timer(int tid, unsigned int tick, int id, intptr_t data) * For recusive status, like for each 5s we drop sp etc. * Reseting the end timer. *------------------------------------------*/ -int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) -{ +int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) { enum sc_type type = (sc_type)data; struct block_list *bl; struct map_session_data *sd; - struct status_data *status; + struct status_data *st; struct status_change *sc; struct status_change_entry *sce; @@ -10036,7 +9988,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) return 0; } sc = iStatus->get_sc(bl); - status = iStatus->get_status_data(bl); + st = iStatus->get_status_data(bl); if(!(sc && (sce = sc->data[type]))) { @@ -10134,7 +10086,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) return 0; } if(--(sce->val3) > 0) { - if(++(sce->val4)%5 == 0 && status->hp > status->max_hp/4) + 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 ); return 0; @@ -10142,7 +10094,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) break; case SC_POISON: - if(status->hp <= max(status->max_hp>>2, sce->val4)) //Stop damaging after 25% HP left. + if(st->hp <= max(st->max_hp>>2, sce->val4)) //Stop damaging after 25% HP left. break; case SC_DPOISON: if (--(sce->val3) > 0) { @@ -10164,7 +10116,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) break; case SC_TENSIONRELAX: - if(status->max_hp > status->hp && --(sce->val3) > 0){ + if(st->max_hp > st->hp && --(sce->val3) > 0){ sc_timer_next(sce->val4+tick, iStatus->change_timer, bl->id, data); return 0; } @@ -10186,12 +10138,12 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) int hp = rnd()%600 + 200; struct block_list* src = iMap->id2bl(sce->val2); if( src && bl && bl->type == BL_MOB ) { - mob->log_damage((TBL_MOB*)bl,src,sd||hphp?hp:status->hp-1); + mob->log_damage((TBL_MOB*)bl,src,sd||hphp?hp:st->hp-1); } iMap->freeblock_lock(); - status_fix_damage(src, bl, sd||hphp?hp:status->hp-1, 1); + status_fix_damage(src, bl, sd||hphp?hp:st->hp-1, 1); if( sc->data[type] ) { - if( status->hp == 1 ) { + if( st->hp == 1 ) { iMap->freeblock_unlock(); break; } @@ -10208,7 +10160,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) { // val1 < 0 = per max% | val1 > 0 = exact amount int hp = 0; - if( status->hp < status->max_hp ) + 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); @@ -10289,7 +10241,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) break; case SC_BERSERK: // 5% every 10 seconds [DracoRPG] - if( --( sce->val3 ) > 0 && iStatus->charge(bl, sce->val2, 0) && status->hp > 100 ) + 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); return 0; @@ -10384,8 +10336,8 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) case SC_LEECHESEND: if( --(sce->val4) > 0 ) { - int damage = status->max_hp/100; // {Target VIT x (New Poison Research Skill Level - 3)} + (Target HP/100) - damage += status->vit * (sce->val1 - 3); + 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); @@ -10400,9 +10352,9 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) case SC_MAGICMUSHROOM: if( --(sce->val4) > 0 ) { bool flag = 0; - int damage = status->max_hp * 3 / 100; - if( status->hp <= damage ) - damage = status->hp - 1; // Cannot Kill + int damage = st->max_hp * 3 / 100; + if( st->hp <= damage ) + damage = st->hp - 1; // Cannot Kill if( damage > 0 ) { // 3% Damage each 4 seconds iMap->freeblock_lock(); @@ -10447,7 +10399,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) { //Damage is every 10 seconds including 3%sp drain. iMap->freeblock_lock(); clif->damage(bl,bl,tick,status_get_amotion(bl),1,1,0,0,0); - iStatus->damage(NULL, bl, 1, status->max_sp * 3 / 100, 0, 0); //cancel dmg only if cancelable + iStatus->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 ); } @@ -10482,9 +10434,8 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) return 0; case SC_RENOVATIO: - if( --(sce->val4) > 0 ) - { - int heal = status->max_hp * 3 / 100; + if( --(sce->val4) > 0 ) { + int heal = st->max_hp * 3 / 100; if( sc && sc->data[SC_AKAITSUKI] && heal ) heal = ~heal + 1; iStatus->heal(bl, heal, 0, 2); @@ -10546,9 +10497,8 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) return 0; case SC_ELECTRICSHOCKER: - if( --(sce->val4) > 0 ) - { - iStatus->charge(bl, 0, status->max_sp / 100 * sce->val1 ); + 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); return 0; } @@ -10579,9 +10529,8 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) break; case SC__INVISIBILITY: - if( --(sce->val4) > 0 ) - { - if( !iStatus->charge(bl, 0, (status->sp * 6 - sce->val1) / 100) )// 6% - skill_lv. + if( --(sce->val4) > 0 ) { + if( !iStatus->charge(bl, 0, (st->sp * 6 - sce->val1) / 100) )// 6% - skill_lv. break; sc_timer_next(1000 + tick, iStatus->change_timer, bl->id, data); return 0; @@ -10611,7 +10560,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) break; iMap->freeblock_lock(); damage = sce->val3; - iStatus->damage(src, bl, damage, 0, clif->damage(bl,bl,tick,status->amotion,status->dmotion+200,damage,1,0,0), 1); + iStatus->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); @@ -10632,9 +10581,9 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) break; case SC_DEEP_SLEEP: - if( --(sce->val4) > 0 ) - { // Recovers 1% HP/SP every 2 seconds. - iStatus->heal(bl, status->max_hp / 100, status->max_sp / 100, 2); + 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); return 0; } @@ -10663,10 +10612,9 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) case SC_SATURDAY_NIGHT_FEVER: // 1% HP/SP drain every val4 seconds [Jobbie] - if( --(sce->val3) > 0 ) - { - int hp = status->hp / 100; - int sp = status->sp / 100; + if( --(sce->val3) > 0 ) { + int hp = st->hp / 100; + int sp = st->sp / 100; if( !iStatus->charge(bl, hp, sp) ) break; sc_timer_next(sce->val4+tick, iStatus->change_timer, bl->id, data); @@ -10675,10 +10623,10 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) break; case SC_COLD: - if( --(sce->val4) > 0 ) - { // Drains 2% of HP and 1% of SP every seconds. + 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, status->max_hp * 2 / 100, status->max_sp / 100); + iStatus->charge(bl, st->max_hp * 2 / 100, st->max_sp / 100); sc_timer_next(1000 + tick, iStatus->change_timer, bl->id, data); return 0; } @@ -10716,8 +10664,8 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) case SC_OVERHEAT: { - int damage = status->max_hp / 100; // Suggestion 1% each second - if( damage >= status->hp ) damage = status->hp - 1; // Do not kill, just keep you with 1 hp minimum + 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(); status_fix_damage(NULL,bl,damage,clif->damage(bl,bl,tick,0,0,damage,0,0,0)); if( sc->data[type] ) { @@ -10748,10 +10696,9 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) break; case SC_INSPIRATION: - if(--(sce->val4) > 0) - { - int hp = status->max_hp * (7-sce->val1) / 100; - int sp = status->max_sp * (9-sce->val1) / 100; + if(--(sce->val4) > 0) { + 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; @@ -10810,8 +10757,8 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) sc_timer_next(600000 + tick, iStatus->change_timer, bl->id, data); return 0; case SC_MEIKYOUSISUI: - if( --(sce->val4) > 0 ){ - iStatus->heal(bl, status->max_hp * (sce->val1+1) / 100, status->max_sp * sce->val1 / 100, 0); + 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); return 0; } @@ -10974,12 +10921,12 @@ int status_get_weapon_atk(struct block_list *bl, struct weapon_atk *watk, int fl } #endif -#define GETRANDMATK(){\ - if( status->matk_max > status->matk_min )\ - return status->matk_min + rnd()%(status->matk_max - status->matk_min);\ -else\ - return status->matk_min;\ -} +#define GETRANDMATK(st) do {\ + if( (st)->matk_max > (st)->matk_min ) \ + return (st)->matk_min + rnd()%((st)->matk_max - (st)->matk_min); \ + else \ + return (st)->matk_min; \ + } while(0) /*========================================== * flag [malufett] @@ -10988,72 +10935,72 @@ else\ * 2 - get modified matk * 3 - get matk w/o eatk & SC bonuses *------------------------------------------*/ -int status_get_matk(struct block_list *bl, int flag){ - struct status_data *status; +int status_get_matk(struct block_list *bl, int flag) { + struct status_data *st; struct status_change *sc; struct map_session_data *sd; if( bl == NULL ) return 1; - status = iStatus->get_status_data(bl); + st = iStatus->get_status_data(bl); sc = iStatus->get_sc(bl); sd = BL_CAST(BL_PC, bl); if( flag == 2 ) // just get matk - GETRANDMATK(); + GETRANDMATK(st); #ifndef RENEWAL - status->matk_min = status_base_matk_min(status) + (sd?sd->bonus.ematk:0); - status->matk_max = status_base_matk_max(status) + (sd?sd->bonus.ematk:0); + 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 /** * RE MATK Formula (from irowiki:http://irowiki.org/wiki/MATK) * MATK = (sMATK + wMATK + eMATK) * Multiplicative Modifiers **/ - status->matk_min = iStatus->base_matk(status, iStatus->get_lv(bl)); + st->matk_min = iStatus->base_matk(st, iStatus->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 ) - status->matk_min += sd->bonus.ematk; + st->matk_min += sd->bonus.ematk; if( flag != 3 ) - status->matk_min = status_calc_ematk(bl, sc, status->matk_min); + st->matk_min = status_calc_ematk(bl, sc, st->matk_min); - status->matk_max = status->matk_min; + 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 && (status->rhw.matk + status->lhw.matk) > 0 ){ - int wMatk = status->rhw.matk + status->lhw.matk; // Left and right matk stacks - int variance = wMatk * status->rhw.wlv / 10; // Only use right hand weapon level - status->matk_min += wMatk - variance; - status->matk_max += wMatk + variance; + 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 ){ - status->matk_min = status->matk_max = status_get_int(bl) + iStatus->get_lv(bl); - status->matk_min += 70 * ((TBL_MOB*)bl)->status.rhw.atk2 / 100; - status->matk_max += 130 * ((TBL_MOB*)bl)->status.rhw.atk2 / 100; + st->matk_min = st->matk_max = status_get_int(bl) + iStatus->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; } #endif if (bl->type&BL_PC && sd->matk_rate != 100) { - status->matk_max = status->matk_max * sd->matk_rate/100; - status->matk_min = status->matk_min * sd->matk_rate/100; + st->matk_max = st->matk_max * sd->matk_rate/100; + st->matk_min = st->matk_min * sd->matk_rate/100; } if ((bl->type&BL_HOM && battle_config.hom_setting&0x20) //Hom Min Matk is always the same as Max Matk || (sc && sc->data[SC_RECOGNIZEDSPELL])) - status->matk_min = status->matk_max; + st->matk_min = st->matk_max; #ifdef RENEWAL if( sd && sd->right_weapon.overrefine > 0){ - status->matk_min++; - status->matk_max += sd->right_weapon.overrefine - 1; + st->matk_min++; + st->matk_max += sd->right_weapon.overrefine - 1; } #endif if( flag ) // get unmodified from sc matk - GETRANDMATK(); + GETRANDMATK(st); - status->matk_min = status_calc_matk(bl, sc, status->matk_min, true); - status->matk_max = status_calc_matk(bl, sc, status->matk_max, true); + st->matk_min = status_calc_matk(bl, sc, st->matk_min, true); + st->matk_max = status_calc_matk(bl, sc, st->matk_max, true); return 0; } @@ -11213,10 +11160,9 @@ int status_change_spread( struct block_list *src, struct block_list *bl ) { //Natural regen related stuff. static unsigned int natural_heal_prev_tick,natural_heal_diff_tick; -static int status_natural_heal(struct block_list* bl, va_list args) -{ +static int status_natural_heal(struct block_list* bl, va_list args) { struct regen_data *regen; - struct status_data *status; + struct status_data *st; struct status_change *sc; struct unit_data *ud; struct view_data *vd = NULL; @@ -11226,16 +11172,16 @@ static int status_natural_heal(struct block_list* bl, va_list args) regen = iStatus->get_regen_data(bl); if (!regen) return 0; - status = iStatus->get_status_data(bl); + st = iStatus->get_status_data(bl); sc = iStatus->get_sc(bl); if (sc && !sc->count) sc = NULL; sd = BL_CAST(BL_PC,bl); flag = regen->flag; - if (flag&RGN_HP && (status->hp >= status->max_hp || regen->state.block&1)) + if (flag&RGN_HP && (st->hp >= st->max_hp || regen->state.block&1)) flag&=~(RGN_HP|RGN_SHP); - if (flag&RGN_SP && (status->sp >= status->max_sp || regen->state.block&2)) + if (flag&RGN_SP && (st->sp >= st->max_sp || regen->state.block&2)) flag&=~(RGN_SP|RGN_SSP); if (flag && ( diff --git a/src/map/status.h b/src/map/status.h index 9d49ff3af..c6da44d83 100644 --- a/src/map/status.h +++ b/src/map/status.h @@ -1854,7 +1854,7 @@ struct status_interface { int (*calc_elemental_) (struct elemental_data *ed, bool first); void (*calc_misc) (struct block_list *bl, struct status_data *status, int level); - void (*calc_regen) (struct block_list *bl, struct status_data *status, struct regen_data *regen); + void (*calc_regen) (struct block_list *bl, struct status_data *st, struct regen_data *regen); void (*calc_regen_rate) (struct block_list *bl, struct regen_data *regen, struct status_change *sc); int (*check_skilluse) (struct block_list *src, struct block_list *target, uint16 skill_id, int flag); // [Skotlex] @@ -1869,7 +1869,7 @@ struct status_interface { unsigned short (*calc_batk) (struct block_list *, struct status_change *, int, bool); #ifdef RENEWAL - unsigned short (*base_matk) (const struct status_data* status, int level); + unsigned short (*base_matk) (const struct status_data *st, int level); int (*get_weapon_atk) (struct block_list *src, struct weapon_atk *watk, int flag); #endif int (*get_total_mdef) (struct block_list *src); -- cgit v1.2.3-70-g09d2 From 17bc1fab375f8ecc951fbba058a346b1460bf783 Mon Sep 17 00:00:00 2001 From: Haru Date: Fri, 27 Sep 2013 00:55:25 +0200 Subject: Renamed iStatus interface to status Signed-off-by: Haru --- src/config/const.h | 12 +- src/map/atcommand.c | 39 +- src/map/battle.c | 287 +++++---- src/map/battleground.c | 2 +- src/map/chrif.c | 4 +- src/map/clif.c | 157 +++-- src/map/elemental.c | 14 +- src/map/guild.c | 2 +- src/map/homunculus.c | 12 +- src/map/map.c | 10 +- src/map/mercenary.c | 7 +- src/map/mob.c | 112 ++-- src/map/npc.c | 17 +- src/map/pc.c | 139 ++--- src/map/pc.h | 2 +- src/map/pet.c | 61 +- src/map/script.c | 151 ++--- src/map/skill.c | 1530 ++++++++++++++++++++++++------------------------ src/map/status.c | 1359 +++++++++++++++++++++--------------------- src/map/status.h | 114 ++-- src/map/unit.c | 159 ++--- 21 files changed, 2058 insertions(+), 2132 deletions(-) (limited to 'src/map/elemental.c') diff --git a/src/config/const.h b/src/config/const.h index 7badb1071..6f0dc6311 100644 --- a/src/config/const.h +++ b/src/config/const.h @@ -75,17 +75,17 @@ /* Renewal's dmg level modifier, used as a macro for a easy way to turn off. */ #ifdef RENEWAL_LVDMG #define RE_LVL_DMOD(val) do { \ - if( iStatus->get_lv(src) > 100 && (val) > 0 ) \ - skillratio = skillratio * iStatus->get_lv(src) / (val); \ + if( status->get_lv(src) > 100 && (val) > 0 ) \ + skillratio = skillratio * status->get_lv(src) / (val); \ } while(0) #define RE_LVL_MDMOD(val) do { \ - if( iStatus->get_lv(src) > 100 && (val) > 0) \ - md.damage = md.damage * iStatus->get_lv(src) / (val); \ + if( status->get_lv(src) > 100 && (val) > 0) \ + md.damage = md.damage * status->get_lv(src) / (val); \ } while(0) /* ranger traps special */ #define RE_LVL_TMDMOD() do { \ - if( iStatus->get_lv(src) > 100 ) \ - md.damage = md.damage * 150 / 100 + md.damage * iStatus->get_lv(src) / 100; \ + if( status->get_lv(src) > 100 ) \ + md.damage = md.damage * 150 / 100 + md.damage * status->get_lv(src) / 100; \ } while(0) #else #define RE_LVL_DMOD(val) diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 57d2a73ef..9dbe0ab33 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -895,9 +895,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 @@ -1011,8 +1011,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 +1079,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 +1087,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 +1096,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. @@ -2971,7 +2970,7 @@ ACMD(doommap) *------------------------------------------*/ static 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. @@ -3679,9 +3678,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; } @@ -4444,7 +4442,7 @@ ACMD(servertime) } //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) { @@ -4672,7 +4670,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; } @@ -5425,12 +5423,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 {} 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); @@ -5617,7 +5614,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); @@ -7050,7 +7047,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 diff --git a/src/map/battle.c b/src/map/battle.c index 54716bd32..abbef8c77 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -130,7 +130,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) { @@ -172,7 +172,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!... @@ -221,7 +221,7 @@ int battle_delay_damage_sub(int tid, unsigned int tick, int id, intptr_t data) { struct block_list* src = NULL; struct block_list* target = iMap->id2bl(dat->target_id); - if( !target || iStatus->isdead(target) ) {/* nothing we can do */ + if( !target || status->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 ) { ((TBL_PC*)src)->state.hold_recalc = 0; status_calc_pc(((TBL_PC*)src),0); @@ -238,7 +238,7 @@ int battle_delay_damage_sub(int tid, unsigned int tick, int id, intptr_t data) { { iMap->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); @@ -261,14 +261,13 @@ int battle_delay_damage_sub(int tid, unsigned int tick, int id, intptr_t data) { 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; @@ -276,7 +275,7 @@ int battle_delay_damage (unsigned int tick, int amotion, struct block_list *src, if ( !battle_config.delay_battle_damage || amotion <= 1 ) { iMap->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()); @@ -328,8 +327,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; @@ -356,7 +355,7 @@ int64 battle_attr_fix(struct block_list *src, struct block_list *target, int64 d 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) ) + (src = iMap->id2bl(sg->src_id)) == NULL || status->isdead(src) ) return 0; if( sg->unit_id != UNT_FIREWALL ) { @@ -435,10 +434,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 +502,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 +603,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 +720,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 +819,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 +845,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 +867,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 +902,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 +972,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 +1205,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 +1217,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 +1330,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 +1381,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 +1453,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; @@ -1603,7 +1602,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 +1616,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 +1993,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 +2080,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 +2089,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 +2104,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 +2266,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 +2347,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 +2355,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 +2474,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; @@ -2569,7 +2567,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 +2588,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 +2729,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 +2851,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; @@ -2940,7 +2938,7 @@ 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); @@ -2950,13 +2948,13 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam } 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); 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 +2964,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 +2973,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 +3002,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 +3044,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 +3057,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 +3094,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 +3115,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 +3230,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 +3258,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 +3270,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 +3357,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 +3378,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 +3540,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 +3588,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 +3650,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 +3709,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 +3722,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 +3771,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 +3788,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 +3951,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 +4227,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 +4417,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 +4434,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 +4628,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 +4642,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 +4818,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 +4921,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 +5013,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; } @@ -5173,10 +5170,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 +5183,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 } @@ -5294,7 +5291,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); @@ -5350,11 +5347,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; @@ -5404,7 +5401,7 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t 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) ) + if( tsc && tsc->data[SC_AUTOCOUNTER] && status->check_skilluse(target, src, KN_AUTOCOUNTER, 1) ) { uint8 dir = iMap->calc_dir(target,src->x,src->y); int t_dir = unit->getdir(target); @@ -5493,7 +5490,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); @@ -5566,9 +5563,9 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t } } 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) ) { + 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(); @@ -5588,7 +5585,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); @@ -5674,7 +5671,7 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t (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) + 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) { @@ -5792,7 +5789,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 ) { @@ -6018,8 +6015,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 +6025,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,7 +6045,7 @@ 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; @@ -6056,16 +6053,14 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f }//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; } diff --git a/src/map/battleground.c b/src/map/battleground.c index db6d6cd5a..25d942226 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 } diff --git a/src/map/chrif.c b/src/map/chrif.c index 15bf80da3..7277bfe33 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -1185,7 +1185,7 @@ int chrif_save_scdata(struct map_session_data *sd) { //parses the sc_data of the 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 @@ -1238,7 +1238,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 diff --git a/src/map/clif.c b/src/map/clif.c index e85f1131f..59b0723fc 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 @@ -850,7 +850,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 +865,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 +877,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 +889,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 +897,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 +915,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 +935,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 +949,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 +960,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 +988,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 +1001,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 +1013,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 +1025,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 +1042,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 +1062,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 +1076,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 +1087,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 +1113,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 +1129,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 +1144,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 +1165,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 +1192,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 +1293,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 +1572,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. @@ -3193,8 +3193,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) { @@ -3614,7 +3614,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 +3660,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; @@ -4310,7 +4310,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; @@ -4447,7 +4447,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; @@ -4792,13 +4792,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 +5116,7 @@ void clif_skill_cooldown(struct map_session_data *sd, uint16 skill_id, unsigned /// Skill attack effect and damage. /// 0114 .W .L .L .L .L .L .W .W
.W .B (ZC_NOTIFY_SKILL) /// 01de .W .L .L .L .L .L .L .W
.W .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 +5126,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 +5203,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 .W .L .L .L .L .L .W .W .W .W
.W .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 +5213,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 +5256,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 +5463,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] @@ -5597,7 +5595,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 +5626,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 ) @@ -7680,8 +7678,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); } @@ -9617,7 +9615,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { 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] @@ -9834,8 +9832,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 @@ -9847,7 +9845,7 @@ void clif_parse_GetCharNameRequest(int fd, struct map_session_data *sd) intif->wis_message_to_gm(iMap->wisp_server_name, battle_config.hack_info_GM_level, gm_msg); return; } - */ +#endif // 0 clif->charnameack(fd, bl); } @@ -9913,7 +9911,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; @@ -13236,7 +13234,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 +13249,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' } @@ -13709,7 +13707,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 } } @@ -14363,8 +14361,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 +14370,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); diff --git a/src/map/elemental.c b/src/map/elemental.c index b1ad4073b..e28a64874 100644 --- a/src/map/elemental.c +++ b/src/map/elemental.c @@ -242,9 +242,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; @@ -281,7 +281,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 +430,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; @@ -589,7 +589,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 ) @@ -609,7 +609,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 ) diff --git a/src/map/guild.c b/src/map/guild.c index 8319d4524..253dbcf1c 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -1371,7 +1371,7 @@ 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); + int type = status->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)) ) return; diff --git a/src/map/homunculus.c b/src/map/homunculus.c index 79d993ede..fb954cdec 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; } @@ -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; @@ -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); @@ -924,7 +924,7 @@ bool homunculus_ressurect(struct map_session_data* sd, unsigned char per, short iMap->addblock(&hd->bl); clif->spawn(&hd->bl); } - iStatus->revive(&hd->bl, per, 0); + status->revive(&hd->bl, per, 0); return true; } diff --git a/src/map/map.c b/src/map/map.c index d57fc583a..1d679a79e 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -361,7 +361,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); @@ -1562,7 +1562,7 @@ int map_quit(struct map_session_data *sd) { 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 ){ @@ -4927,7 +4927,7 @@ void do_final(void) homun->final(); atcommand->final_msg(); skill->final(); - iStatus->do_final_status(); + status->final(); unit->final(); bg->final(); duel->final(); @@ -5140,7 +5140,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"); @@ -5399,7 +5399,7 @@ 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(); diff --git a/src/map/mercenary.c b/src/map/mercenary.c index 402c477bf..881038eb4 100644 --- a/src/map/mercenary.c +++ b/src/map/mercenary.c @@ -297,8 +297,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 +306,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; diff --git a/src/map/mob.c b/src/map/mob.c index ceb00a6ce..ff949a3ff 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; @@ -156,8 +156,8 @@ void mvptomb_create(struct mob_data *md, char *killer, time_t time) iMap->addnpc(nd->bl.m, nd); iMap->addblock(&nd->bl); - iStatus->set_viewdata(&nd->bl, nd->class_); - clif->spawn(&nd->bl); + status->set_viewdata(&nd->bl, nd->class_); + clif->spawn(&nd->bl); } @@ -281,8 +281,8 @@ 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); @@ -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; } @@ -894,7 +894,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); } @@ -1017,7 +1017,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 +1045,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 +1094,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 +1103,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 +1128,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; @@ -1194,7 +1194,7 @@ int mob_ai_sub_hard_slavemob(struct mob_data *md,unsigned int tick) bl=iMap->id2bl(md->master_id); - if (!bl || iStatus->isdead(bl)) { + if (!bl || status->isdead(bl)) { status_kill(&md->bl); return 1; } @@ -1254,7 +1254,7 @@ int mob_ai_sub_hard_slavemob(struct mob_data *md,unsigned int tick) 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) @@ -1347,8 +1347,9 @@ int mob_randomwalk(struct mob_data *md,unsigned int tick) } return 0; } - speed=iStatus->get_speed(&md->bl); - for(i=c=0;iud.walkpath.path_len;i++){ // The next walk start time is calculated. + speed=status->get_speed(&md->bl); + for(i=c=0;iud.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 @@ -1421,17 +1422,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] + 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 (!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. @@ -1464,18 +1466,19 @@ bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick) { 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 +1489,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 @@ -1897,12 +1898,11 @@ int mob_deleteslave(struct mob_data *md) return 0; } // Mob respawning through KAIZEL or NPC_REBIRTH [Skotlex] -int mob_respawn(int tid, unsigned int tick, int id, intptr_t data) -{ +int mob_respawn(int tid, unsigned int tick, int id, intptr_t data) { struct block_list *bl = iMap->id2bl(id); if(!bl) return 0; - iStatus->revive(bl, (uint8)data, 0); + status->revive(bl, (uint8)data, 0); return 1; } @@ -2168,7 +2168,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] && @@ -2609,7 +2609,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 +2617,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. @@ -2745,7 +2745,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. @@ -3338,7 +3338,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 @@ -3747,7 +3747,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] diff --git a/src/map/npc.c b/src/map/npc.c index fb106d2d6..024f649d0 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -2071,7 +2071,7 @@ struct npc_data* npc_add_warp(char* name, short from_mapid, short from_x, short nd->subtype = WARP; npc->setcells(nd); iMap->addblock(&nd->bl); - iStatus->set_viewdata(&nd->bl, nd->class_); + status->set_viewdata(&nd->bl, nd->class_); nd->ud = &npc->base_ud; if( maplist[nd->bl.m].users ) clif->spawn(&nd->bl); @@ -2136,7 +2136,7 @@ const char* npc_parse_warp(char* w1, char* w2, char* w3, char* w4, const char* s nd->subtype = WARP; npc->setcells(nd); iMap->addblock(&nd->bl); - iStatus->set_viewdata(&nd->bl, nd->class_); + status->set_viewdata(&nd->bl, nd->class_); nd->ud = &npc->base_ud; if( maplist[nd->bl.m].users ) clif->spawn(&nd->bl); @@ -2248,7 +2248,7 @@ const char* npc_parse_shop(char* w1, char* w2, char* w3, char* w4, const char* s if( m >= 0 ) {// normal shop npc iMap->addnpc(m,nd); iMap->addblock(&nd->bl); - iStatus->set_viewdata(&nd->bl, nd->class_); + status->set_viewdata(&nd->bl, nd->class_); nd->ud = &npc->base_ud; nd->dir = dir; if( maplist[nd->bl.m].users ) @@ -2440,7 +2440,7 @@ const char* npc_parse_script(char* w1, char* w2, char* w3, char* w4, const char* npc->setcells(nd); iMap->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); } @@ -2596,7 +2596,7 @@ const char* npc_parse_duplicate(char* w1, char* w2, char* w3, char* w4, const ch npc->setcells(nd); iMap->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); } @@ -2666,7 +2666,7 @@ int npc_duplicate4instance(struct npc_data *snd, int16 m) { wnd->subtype = WARP; npc->setcells(wnd); iMap->addblock(&wnd->bl); - iStatus->set_viewdata(&wnd->bl, wnd->class_); + status->set_viewdata(&wnd->bl, wnd->class_); wnd->ud = &npc->base_ud; if( maplist[wnd->bl.m].users ) clif->spawn(&wnd->bl); @@ -2789,8 +2789,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 +2798,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 } diff --git a/src/map/pc.c b/src/map/pc.c index 86ee7a8db..9dbb5175a 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -314,7 +314,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 +341,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; } @@ -383,13 +383,11 @@ int pc_banding(struct map_session_data *sd, uint16 skill_lv) { 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] ) - { + 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 +449,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; @@ -1072,12 +1070,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; @@ -1204,7 +1202,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)) @@ -1746,7 +1744,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) { @@ -3329,7 +3327,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 +3336,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 +3431,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 +3471,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: @@ -4386,7 +4381,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 +4681,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] @@ -4876,8 +4871,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); @@ -5147,12 +5142,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); } @@ -5684,15 +5679,14 @@ 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); 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; @@ -5701,17 +5695,16 @@ int pc_follow_timer(int tid, unsigned int tick, int id, intptr_t data) sd->followtimer = INVALID_TIMER; tbl = iMap->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); @@ -5783,16 +5776,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 @@ -5853,14 +5846,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]) @@ -6877,8 +6870,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) { } // 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 ) { @@ -6888,7 +6880,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; @@ -7428,7 +7420,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); } /*========================================== @@ -7560,7 +7552,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); } @@ -7602,7 +7594,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); @@ -7697,7 +7689,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) @@ -7812,9 +7804,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: @@ -7835,7 +7827,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_; } @@ -9237,8 +9229,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) { @@ -9258,7 +9249,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; } diff --git a/src/map/pc.h b/src/map/pc.h index 4b90e7fc3..d384e0145 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -672,7 +672,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..dd0ed1bb9 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)) + 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) { @@ -351,7 +349,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; @@ -650,8 +648,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 +665,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 +683,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,7 +692,7 @@ 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; @@ -869,9 +864,9 @@ 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)) - { + if (!target || pd->bl.m != target->m || status->isdead(target) + || !check_distance_bl(&pd->bl, target, pd->db->range3) + ) { target = NULL; pet->unlocktarget(pd); } @@ -1130,7 +1125,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 +1138,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; } @@ -1166,7 +1161,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. diff --git a/src/map/script.c b/src/map/script.c index d9794e3cd..b940d03e4 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -332,9 +332,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; } } @@ -3641,7 +3641,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); } } @@ -4874,8 +4874,7 @@ BUILDIN(warpguild) /*========================================== * Force Heal a player (hp and sp) *------------------------------------------*/ -BUILDIN(heal) -{ +BUILDIN(heal) { TBL_PC *sd; int hp,sp; @@ -4884,7 +4883,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; } /*========================================== @@ -7253,8 +7252,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 +7264,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 +7542,7 @@ BUILDIN(bonus) return true; } -BUILDIN(autobonus) -{ +BUILDIN(autobonus) { unsigned int dur; short rate; short atk_type = 0; @@ -7556,7 +7553,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 +7567,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 +7578,7 @@ BUILDIN(autobonus) return true; } -BUILDIN(autobonus2) -{ +BUILDIN(autobonus2) { unsigned int dur; short rate; short atk_type = 0; @@ -7593,7 +7589,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 +7603,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 +7614,7 @@ BUILDIN(autobonus2) return true; } -BUILDIN(autobonus3) -{ +BUILDIN(autobonus3) { unsigned int dur; short rate,atk_type; TBL_PC* sd; @@ -7629,7 +7624,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 +7637,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); @@ -9488,8 +9483,7 @@ BUILDIN(hideonnpc) /// Starts a status effect on the target unit or on the attached player. /// /// sc_start ,,{,}; -BUILDIN(sc_start) -{ +BUILDIN(sc_start) { struct block_list* bl; enum sc_type type; int tick; @@ -9504,20 +9498,20 @@ BUILDIN(sc_start) else bl = iMap->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. + 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); 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 +9519,7 @@ BUILDIN(sc_start) /// Starts a status effect on the target unit or on the attached player. /// /// sc_start2 ,,,{,}; -BUILDIN(sc_start2) -{ +BUILDIN(sc_start2) { struct block_list* bl; enum sc_type type; int tick; @@ -9543,20 +9536,20 @@ BUILDIN(sc_start2) else bl = iMap->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. + 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); 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 +9557,7 @@ BUILDIN(sc_start2) /// Starts a status effect on the target unit or on the attached player. /// /// sc_start4 ,,,,,{,}; -BUILDIN(sc_start4) -{ +BUILDIN(sc_start4) { struct block_list* bl; enum sc_type type; int tick; @@ -9585,19 +9577,19 @@ BUILDIN(sc_start4) else bl = iMap->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. + 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); 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,8 +9597,7 @@ BUILDIN(sc_start4) /// Ends one or all status effects on the target unit or on the attached player. /// /// sc_end {,}; -BUILDIN(sc_end) -{ +BUILDIN(sc_end) { struct block_list* bl; int type; @@ -9622,23 +9613,19 @@ BUILDIN(sc_end) 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 +9635,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,8 +9643,7 @@ 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; @@ -9669,7 +9655,7 @@ BUILDIN(getscrate) bl = iMap->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,8 +9937,7 @@ BUILDIN(skillpointcount) /*========================================== * *------------------------------------------*/ -BUILDIN(changebase) -{ +BUILDIN(changebase) { TBL_PC *sd=NULL; int vclass; @@ -9974,7 +9959,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); @@ -12357,7 +12342,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)); @@ -13076,8 +13061,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 +13074,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 +13093,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 +13101,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; @@ -15043,8 +15026,7 @@ BUILDIN(unitstop) { /// Makes the unit say the message /// /// unittalk ,""; -BUILDIN(unittalk) -{ +BUILDIN(unittalk) { int unit_id; const char* message; struct block_list* bl; @@ -15053,11 +15035,10 @@ BUILDIN(unittalk) message = script_getstr(st, 3); bl = iMap->id2bl(unit_id); - if( bl != NULL ) - { + 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)); @@ -15440,8 +15421,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 +15430,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 +15446,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; } diff --git a/src/map/skill.c b/src/map/skill.c index 3541f9f45..8a5969345 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -373,11 +373,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 +390,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 +415,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 +430,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; } @@ -680,8 +682,7 @@ struct s_skill_unit_layout* skill_get_unit_layout (uint16 skill_id, uint16 skill /*========================================== * *------------------------------------------*/ -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 +704,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 +740,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 +758,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 +826,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 +838,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 +1007,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 +1018,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 +1075,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 +1128,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 +1182,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 +1242,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 +1284,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 +1367,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)); @@ -1397,15 +1399,14 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, uint 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 +1445,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 +1474,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; @@ -1712,8 +1712,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 +1725,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 +1774,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 ) ; - 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 +1805,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 +1912,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 +1939,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 +1981,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 +2035,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; @@ -2108,7 +2109,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 +2129,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 +2172,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 +2213,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 +2224,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 +2254,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 +2281,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 +2332,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 @@ -2623,7 +2624,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 +2638,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: @@ -2733,7 +2734,7 @@ 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 ) @@ -2761,14 +2762,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,15 +2783,13 @@ 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); } @@ -2916,7 +2916,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 ) @@ -2974,13 +2974,12 @@ 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; @@ -3106,9 +3105,9 @@ 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) { @@ -3116,7 +3115,7 @@ int skill_timerskill(int tid, unsigned int tick, int id, intptr_t data) { 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)) + if (target != src && !status->isdead(target)) unit->warp(target, -1, x, y, CLR_TELEPORT); } break; @@ -3136,12 +3135,12 @@ int skill_timerskill(int tid, unsigned int tick, int id, intptr_t data) { 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 && @@ -3210,7 +3209,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)); @@ -3243,15 +3242,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; @@ -3365,8 +3365,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,23 +3383,23 @@ 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(); @@ -3546,7 +3545,7 @@ 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; @@ -3659,26 +3658,23 @@ 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); if( dir > 0 && dir < 4) x = -i; @@ -3764,7 +3760,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint 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 ) { @@ -3920,7 +3916,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] @@ -3982,7 +3978,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 +4005,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 +4041,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: @@ -4124,9 +4120,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 +4132,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: @@ -4283,7 +4278,7 @@ 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); @@ -4356,10 +4351,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: @@ -4409,15 +4404,15 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint } 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: @@ -4482,9 +4477,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); @@ -4635,7 +4630,7 @@ int skill_castend_id(int tid, unsigned int tick, int id, intptr_t data) 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 @@ -4670,7 +4665,7 @@ int skill_castend_id(int tid, unsigned int tick, int id, intptr_t data) } 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 +4675,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 +4721,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 +4799,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)); @@ -4832,12 +4827,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 ) @@ -4857,11 +4853,11 @@ int skill_castend_id(int tid, unsigned int tick, int id, intptr_t data) } 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 @@ -4937,10 +4933,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 +4951,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,7 +5009,7 @@ 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(); return 0; @@ -5026,8 +5022,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 && @@ -5051,7 +5047,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 +5073,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; @@ -5110,10 +5106,10 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui 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 + } 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. @@ -5125,7 +5121,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 +5139,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,12 +5164,12 @@ 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); @@ -5247,23 +5243,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 +5271,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 +5316,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); @@ -5345,7 +5341,7 @@ 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 @@ -5694,13 +5690,13 @@ 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))); + iMap->foreachinrange( status->change_timer_sub, src, + skill->get_splash(skill_id, skill_lv), BL_CHAR, + src,NULL,type,tick); + } break; case SM_PROVOKE: @@ -5713,7 +5709,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui } //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)))); + (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 ) @@ -5750,7 +5746,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 @@ -5837,7 +5833,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; @@ -5949,7 +5945,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui 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); + status->damage(src, src, sstatus->max_hp,0,0,1); break; case AL_ANGELUS: @@ -6019,13 +6015,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; } @@ -6118,15 +6115,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 +6158,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]) @@ -6192,11 +6187,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 +6208,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 +6221,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 +6261,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; @@ -6576,7 +6569,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: @@ -6644,7 +6637,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 +6647,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) { @@ -6747,7 +6739,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 +6772,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; @@ -7017,49 +7009,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(); 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: @@ -7216,20 +7208,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 +7259,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 @@ -7337,13 +7329,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 +7345,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 +7444,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 +7452,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 +7463,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); + 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); + 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); + 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 +7510,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); @@ -7636,7 +7628,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui //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] @@ -7741,7 +7733,7 @@ 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) @@ -7768,23 +7760,22 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui 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: @@ -7829,9 +7820,9 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui } }else if( skill_area_temp[5]&0x20 ){ i = status_get_max_hp(bl) * 25 / 100; - iStatus->change_clear_buffs(bl,4); + status->change_clear_buffs(bl,4); skill_area_temp[5] &= ~0x20; - iStatus->heal(bl,i,0,1); + status->heal(bl,i,0,1); type = SC_REFRESH; }else if( skill_area_temp[5]&0x40 ){ skill_area_temp[5] &= ~0x40; @@ -7839,7 +7830,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui }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; } @@ -7945,8 +7936,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 +7979,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 ) @@ -8051,23 +8041,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: @@ -8142,12 +8130,12 @@ 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 ){ @@ -8174,7 +8162,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] ) @@ -8256,7 +8244,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; @@ -8284,10 +8272,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); @@ -8354,8 +8342,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,16 +8352,17 @@ 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; @@ -8484,16 +8473,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; @@ -8613,17 +8604,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 +8666,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 ) { @@ -8747,8 +8736,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)); } @@ -8874,13 +8864,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); + src, skill_id, skill_lv, tick, flag|BCT_ALL|1, skill->castend_nodamage_id); } break; @@ -8954,13 +8944,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 +8975,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] ){ @@ -9075,24 +9065,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 +9095,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 +9130,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 +9164,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; @@ -9248,100 +9240,102 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui } 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; ionce_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 = 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; ionce_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); @@ -9349,8 +9343,8 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui 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); } @@ -9411,7 +9405,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 +9439,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)) { @@ -9693,13 +9687,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. @@ -9744,7 +9738,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui case HT_DETECTING: i = skill->get_splash(skill_id, skill_lv); - iMap->foreachinarea( iStatus->change_timer_sub, + iMap->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) @@ -9988,7 +9982,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; @@ -10110,18 +10104,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 } @@ -10221,9 +10212,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 ) @@ -10274,7 +10264,7 @@ 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), src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_damage_id); @@ -10522,8 +10512,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: @@ -11003,7 +10993,7 @@ 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); @@ -11013,12 +11003,12 @@ int skill_unit_onplace (struct skill_unit *src, struct block_list *bl, unsigned return 0; //AoE skills are ineffective. [Skotlex] if( iMap->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,7 +11019,7 @@ 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); @@ -11111,7 +11101,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 +11132,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 +11207,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)); 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) { @@ -11268,8 +11258,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 +11282,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 +11297,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 +11319,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 +11328,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 +11388,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,8 +11418,7 @@ 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) ) { - + 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) ) { iMap->moveblock(bl, src->bl.x, src->bl.y, tick); clif->fixpos(bl); @@ -11446,7 +11431,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns 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; @@ -11521,7 +11506,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 +11523,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 @@ -11686,7 +11670,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. @@ -11775,11 +11759,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 +11775,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 +11803,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 +11888,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 +11909,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){ @@ -11969,17 +11954,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) -{ +static 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 +12022,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 +12036,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); } } } @@ -12250,13 +12234,13 @@ int skill_check_pc_partner (struct map_session_data *sd, uint16 skill_id, uint16 case PR_BENEDICTIO: for (i = 0; i < c; i++) { if ((tsd = iMap->id2sd(p_sd[i])) != NULL) - iStatus->charge(&tsd->bl, 0, 10); + status->charge(&tsd->bl, 0, 10); } return c; case AB_ADORAMUS: if( c > 0 && (tsd = iMap->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: @@ -12404,22 +12388,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 +12441,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; @@ -13493,12 +13511,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 +13523,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; } @@ -13806,9 +13838,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 +13850,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 +13866,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 +13965,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 +13994,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); @@ -14322,7 +14351,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 +14481,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 +14496,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; } @@ -14527,7 +14556,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 +14587,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); @@ -14580,8 +14608,8 @@ int skill_attack_area (struct block_list *bl, va_list ap) 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; @@ -14984,7 +15012,7 @@ int skill_maelstrom_suction(struct block_list *bl, va_list ap) { 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 +15022,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; @@ -15180,7 +15207,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( iMap->id2bl(group->val2)); if( tsc && tsc->data[SC__MANHOLE] ) tsc->data[SC__MANHOLE]->val4 = 0; // Remove the Unit ID } @@ -15260,26 +15287,26 @@ 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; @@ -15312,7 +15339,7 @@ int skill_delunitgroup(struct skill_unit_group *group, const char* file, int lin 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 +15356,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 +15368,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 +15379,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; } @@ -15631,7 +15657,7 @@ int skill_unit_timer_sub(DBKey key, DBData *data, va_list ap) { { struct block_list *src = iMap->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; } @@ -16018,7 +16044,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; @@ -16663,7 +16689,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 +16700,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 +16755,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; @@ -17466,7 +17492,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 diff --git a/src/map/status.c b/src/map/status.c index 46f732e81..501448cc7 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,13 +1581,13 @@ 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: @@ -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 ) { @@ -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 @@ -2067,7 +2067,7 @@ int status_calc_mob_(struct mob_data* md, bool first) { mbl = iMap->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;icurrent_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;icurrent_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;jcurrent_equip_card_id= c= sd->status.inventory[index].card[j]; + for(j=0;jcurrent_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) { @@ -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++ ) - { + 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); + 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++ ) - { + 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); + 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: @@ -7635,47 +7624,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( 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); + 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] + 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); + status->change_start(&tsd->bl,type,10000,val1,5+val1*5,val3,val4,tick,1); } } } @@ -7702,7 +7684,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 +7694,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 = iMap->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,24 +7772,24 @@ 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 = iMap->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 ) { @@ -7818,21 +7801,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 ? iMap->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 +7920,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 +8172,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; @@ -8402,7 +8385,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 +8447,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 +8474,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: @@ -8650,25 +8631,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 +9049,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 +9059,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 +9072,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; @@ -9177,7 +9166,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 +9176,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 +9204,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 +9237,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 +9253,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 +9269,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 +9283,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 +9291,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 +9309,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: @@ -9375,14 +9364,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 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); } @@ -9466,8 +9453,8 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const 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 ? iMap->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 +9466,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, + iMap->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 +9495,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 status_change* sc2 = pbl ? status->get_sc(pbl) : NULL; if (sc2 && sc2->data[type2]) { @@ -9529,7 +9516,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 +9554,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,8 +9567,8 @@ 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) @@ -9594,11 +9581,10 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const return 1; break; case SC_STOP: - if( sce->val2 ) - { + if( sce->val2 ) { struct block_list* tbl = iMap->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; @@ -9667,7 +9653,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()); + iMap->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 +9668,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 = iMap->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); + if(src) { + struct status_change *sc = status->get_sc(src); sc->bs_counter--; } } @@ -9938,9 +9924,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=iMap->id2bl(id)) + && (sc=status->get_sc(bl)) + && (sce=sc->data[SC_KAAHI]) + )) return 0; if(sce->val4 != tid) { @@ -9949,8 +9936,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 +9946,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; } @@ -9977,13 +9964,12 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) { struct status_change_entry *sce; bl = iMap->id2bl(id); - if(!bl) - { + 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 +9986,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 +10036,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); + iMap->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); + iMap->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 +10061,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; @@ -10102,7 +10087,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) { iMap->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(); } @@ -10111,8 +10096,8 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) { 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; @@ -10142,7 +10127,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) { iMap->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(); return 0; @@ -10151,27 +10136,24 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) { 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 ) - { + 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( 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 +10205,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 +10244,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; @@ -10273,46 +10253,43 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) { 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); + 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; @@ -10322,7 +10299,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) { 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(); return 0; @@ -10335,9 +10312,9 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) { 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); + 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(); return 0; @@ -10383,20 +10360,20 @@ 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. + if( --(sce->val4) > 0 ) { + //Damage is every 10 seconds including 3%sp drain. iMap->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(); return 0; @@ -10404,28 +10381,26 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) { 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,24 +10408,23 @@ 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 ) - { + if( --(sce->val4) > 0 ) { struct block_list *src = iMap->id2bl(sce->val3); int damage = 1000 + 3 * status_get_max_hp(bl) / 100; // Deals fixed (1000 + 3%*MaxHP) iMap->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(); return 0; @@ -10458,11 +10432,10 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) { 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,78 +10445,75 @@ 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; @@ -10551,26 +10521,25 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) { if( --(sce->val4) > 0 ) { struct block_list *src = iMap->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(); 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 + 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 +10547,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 +10577,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 +10588,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; @@ -10664,7 +10630,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) { iMap->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(); } @@ -10674,19 +10640,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 - { + } else { struct block_list *src = iMap->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 +10658,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 +10682,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 +10710,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 +10765,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 +10773,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 +10807,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 +10834,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 +10896,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 +10919,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 +10963,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 +10974,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 +11022,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 +11063,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 +11094,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 +11120,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 +11134,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 +11148,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 +11192,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 +11201,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 +11210,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 +11219,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 +11255,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 } } @@ -11548,22 +11497,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 +11520,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/unit.c b/src/map/unit.c index 4a794da09..e4ea365df 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -129,9 +129,9 @@ 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; @@ -278,9 +278,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); @@ -294,7 +294,8 @@ int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data) 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. + 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) ) @@ -376,7 +377,7 @@ 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); @@ -451,7 +452,7 @@ 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); @@ -482,9 +483,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; @@ -555,7 +555,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; @@ -930,7 +930,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 +951,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 +1011,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); 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 +1077,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 +1087,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 @@ -1169,10 +1171,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 +1262,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: @@ -1451,7 +1453,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 +1462,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; @@ -1482,7 +1484,7 @@ int unit_skilluse_pos2( struct block_list *src, short skill_x, short skill_y, ui } } - 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) ) @@ -1629,7 +1631,7 @@ int unit_attack(struct block_list *src,int target_id,int continuous) nullpo_ret(ud = unit->bl2ud(src)); target = iMap->id2bl(target_id); - if( target==NULL || iStatus->isdead(target) ) { + if( target==NULL || status->isdead(target) ) { unit->unattackable(src); return 1; } @@ -1645,7 +1647,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; } @@ -1829,12 +1831,12 @@ int unit_attack_timer_sub(struct block_list* src, int tid, unsigned int tick) 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 +1864,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) ) @@ -2067,12 +2069,11 @@ 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) @@ -2289,7 +2290,7 @@ 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(); @@ -2341,7 +2342,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); @@ -2583,7 +2584,7 @@ int unit_free(struct block_list *bl, clr_type clrtype) } skill->clear_unitgroup(bl); - iStatus->change_clear(bl,1); + status->change_clear(bl,1); iMap->deliddb(bl); if( bl->type != BL_PC ) //Players are handled by map_quit iMap->freeblock(bl); -- cgit v1.2.3-70-g09d2 From b89f58edd8b368e2548ace86f06354bd6ea1c8d2 Mon Sep 17 00:00:00 2001 From: Haru Date: Fri, 27 Sep 2013 05:30:37 +0200 Subject: Renamed iMap interface to map Signed-off-by: Haru --- src/map/atcommand.c | 489 ++++++++++------------ src/map/battle.c | 246 +++++------ src/map/battleground.c | 10 +- src/map/buyingstore.c | 23 +- src/map/chat.c | 74 ++-- src/map/chrif.c | 64 +-- src/map/clif.c | 304 ++++++-------- src/map/duel.c | 4 +- src/map/elemental.c | 22 +- src/map/guild.c | 151 ++++--- src/map/homunculus.c | 24 +- src/map/instance.c | 32 +- src/map/intif.c | 101 ++--- src/map/itemdb.c | 37 +- src/map/log.c | 2 +- src/map/map.c | 581 +++++++++++++------------ src/map/map.h | 12 +- src/map/mercenary.c | 24 +- src/map/mob.c | 282 ++++++------- src/map/npc.c | 372 ++++++++-------- src/map/npc_chat.c | 8 +- src/map/party.c | 55 ++- src/map/pc.c | 199 ++++----- src/map/pet.c | 84 ++-- src/map/quest.c | 13 +- src/map/script.c | 966 ++++++++++++++++++------------------------ src/map/searchstore.c | 2 +- src/map/skill.c | 1093 +++++++++++++++++++++++------------------------- src/map/status.c | 224 +++++----- src/map/storage.c | 29 +- src/map/trade.c | 42 +- src/map/unit.c | 227 +++++----- src/map/vending.c | 8 +- src/plugins/db2sql.c | 34 +- 34 files changed, 2711 insertions(+), 3127 deletions(-) (limited to 'src/map/elemental.c') diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 9dbe0ab33..f61a4bd45 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -384,8 +384,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 +404,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 +437,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 +448,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 +476,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 +527,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 +544,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 +563,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 +754,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; @@ -908,7 +905,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; @@ -1476,15 +1473,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; } @@ -1514,13 +1511,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. @@ -1539,11 +1536,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; @@ -1560,7 +1557,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); @@ -1852,7 +1849,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; @@ -1952,7 +1949,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; } @@ -1993,8 +1990,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); @@ -2004,13 +2000,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(atkillmonster_sub, map_id, BL_MOB, -drop_flag); clif->message(fd, msg_txt(165)); // All monsters killed! @@ -2193,8 +2189,7 @@ ACMD(memo) /*========================================== * *------------------------------------------*/ -ACMD(gat) -{ +ACMD(gat) { int y; nullpo_retr(-1, sd); @@ -2203,11 +2198,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); } @@ -2687,8 +2682,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; } @@ -2880,11 +2874,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. @@ -2897,11 +2890,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. @@ -3033,8 +3025,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; } @@ -3282,15 +3273,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. @@ -3300,15 +3290,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." @@ -3318,15 +3307,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. @@ -3336,15 +3324,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." @@ -3354,11 +3341,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; } @@ -3615,7 +3601,7 @@ 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; } @@ -3635,7 +3621,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 @@ -3696,8 +3682,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; @@ -3726,7 +3711,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(); @@ -3769,9 +3754,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) { @@ -3789,7 +3774,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++; } } @@ -3968,7 +3953,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) { @@ -4058,8 +4043,7 @@ ACMD(mount_peco) /*========================================== *Spy Commands by Syrus22 *------------------------------------------*/ -ACMD(guildspy) -{ +ACMD(guildspy) { char guild_name[NAME_LENGTH]; struct guild *g; nullpo_retr(-1, sd); @@ -4067,7 +4051,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; @@ -4099,8 +4083,7 @@ ACMD(guildspy) /*========================================== * *------------------------------------------*/ -ACMD(partyspy) -{ +ACMD(partyspy) { char party_name[NAME_LENGTH]; struct party_data *p; nullpo_retr(-1, sd); @@ -4108,7 +4091,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; @@ -4170,8 +4153,7 @@ ACMD(repairall) /*========================================== * @nuke [Valaris] *------------------------------------------*/ -ACMD(nuke) -{ +ACMD(nuke) { struct map_session_data *pl_sd; nullpo_retr(-1, sd); @@ -4182,7 +4164,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! @@ -4372,8 +4354,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) @@ -4390,53 +4371,51 @@ 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; } @@ -4473,8 +4452,7 @@ static void get_jail_time(int jailtime, int* year, int* month, int* day, int* ho * @jail 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; @@ -4487,7 +4465,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; } @@ -4528,8 +4506,7 @@ ACMD(jail) * @unjail/@discharge 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)); @@ -4539,7 +4516,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; } @@ -4563,8 +4540,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; @@ -4619,7 +4595,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; } @@ -5039,8 +5015,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; @@ -5048,7 +5023,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; } @@ -5079,8 +5054,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); @@ -5091,23 +5065,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; @@ -5153,8 +5125,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); @@ -5167,7 +5138,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; @@ -5371,8 +5342,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; @@ -5385,8 +5355,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; } @@ -5439,8 +5410,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; @@ -5453,8 +5423,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; } @@ -5492,8 +5461,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; @@ -5507,7 +5475,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); } } @@ -5515,8 +5483,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] = ""; @@ -5527,7 +5494,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; } @@ -5628,8 +5595,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); @@ -5649,7 +5615,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; } @@ -5662,17 +5628,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 return false; } - if (party->changeleader(sd, iMap->nick2sd((char *) message))) + if (party->changeleader(sd, map->nick2sd((char *) message))) return true; return false; } @@ -6096,33 +6060,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) -{ +static 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. @@ -6372,8 +6331,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); @@ -6382,8 +6340,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; } @@ -6419,8 +6376,7 @@ ACMD(setbattleflag) /*========================================== * @unmute [Valaris] *------------------------------------------*/ -ACMD(unmute) -{ +ACMD(unmute) { struct map_session_data *pl_sd = NULL; nullpo_retr(-1, sd); @@ -6429,7 +6385,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; @@ -6489,8 +6445,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); @@ -6500,8 +6455,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; } @@ -7288,7 +7242,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); @@ -7340,8 +7294,7 @@ static int atcommand_mutearea_sub(struct block_list *bl,va_list ap) return 0; } -ACMD(mutearea) -{ +ACMD(mutearea) { int time; nullpo_ret(sd); @@ -7352,9 +7305,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; } @@ -7566,8 +7519,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); \ @@ -7584,19 +7537,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. @@ -7606,34 +7559,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) @@ -7647,8 +7600,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; } @@ -7706,7 +7659,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." @@ -7778,7 +7731,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) { @@ -7907,8 +7860,7 @@ ACMD(cash) } // @clone/@slaveclone/@evilclone [Valaris] -ACMD(clone) -{ +ACMD(clone) { int x=0,y=0,flag=0,master=0,i=0; struct map_session_data *pl_sd=NULL; @@ -7917,7 +7869,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; } @@ -7946,7 +7898,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; @@ -9060,15 +9012,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) ) { @@ -9121,7 +9073,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; @@ -9942,16 +9894,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; @@ -10000,8 +9957,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; @@ -10299,7 +10258,7 @@ void atcommand_doload(void) { 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_config_read(map->ATCOMMAND_CONF_FILENAME); } void do_init_atcommand(void) { diff --git a/src/map/battle.c b/src/map/battle.c index abbef8c77..64ccfd6c6 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -91,7 +91,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 ) @@ -147,7 +147,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; @@ -189,7 +189,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; @@ -219,10 +219,10 @@ int battle_delay_damage_sub(int tid, unsigned int tick, int id, intptr_t 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 || status->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( 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); } @@ -230,26 +230,27 @@ int battle_delay_damage_sub(int tid, unsigned int tick, int id, intptr_t data) { 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 && !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 ) { @@ -273,13 +274,13 @@ int battle_delay_damage (unsigned int tick, int amotion, struct block_list *src, 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 && !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); @@ -354,8 +355,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 || status->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 ) { @@ -370,39 +373,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 ){ @@ -1574,7 +1577,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; @@ -2536,8 +2539,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; @@ -2549,7 +2551,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) { @@ -2909,7 +2911,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); @@ -2924,7 +2926,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); @@ -2943,15 +2945,15 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam 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 ) 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( 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. @@ -5046,7 +5048,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; } @@ -5212,10 +5214,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); @@ -5312,7 +5314,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 ) @@ -5322,7 +5324,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; @@ -5395,19 +5397,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] && status->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. @@ -5422,8 +5422,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); @@ -5537,13 +5537,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) || @@ -5562,13 +5562,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); + 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); 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; } } @@ -5600,28 +5600,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;vud.skillunit[v] && maxcount;v++) { if(sd->ud.skillunit[v]->skill_id == r_skill) @@ -5631,10 +5633,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; } } @@ -5667,12 +5669,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; - status->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; @@ -5685,7 +5689,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; } @@ -5707,8 +5711,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; @@ -5719,7 +5722,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) @@ -5735,7 +5738,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); @@ -5880,8 +5883,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; @@ -5902,12 +5904,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: @@ -5934,7 +5936,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: @@ -5962,7 +5964,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 ) @@ -5987,7 +5989,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 @@ -6050,7 +6052,7 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f ) 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 ) { @@ -6580,7 +6582,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 ) @@ -6615,7 +6617,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; diff --git a/src/map/battleground.c b/src/map/battleground.c index 25d942226..160d2f96e 100644 --- a/src/map/battleground.c +++ b/src/map/battleground.c @@ -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..fb511505b 100644 --- a/src/map/buyingstore.c +++ b/src/map/buyingstore.c @@ -64,8 +64,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 +119,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 +227,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 +266,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; } @@ -383,7 +383,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 +407,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); } } diff --git a/src/map/chat.c b/src/map/chat.c index 21d49cfc8..3886b69da 100644 --- a/src/map/chat.c +++ b/src/map/chat.c @@ -44,20 +44,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,8 +84,7 @@ 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; } @@ -110,12 +108,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 ) { @@ -167,17 +164,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 +196,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 +212,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 +234,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 +262,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 +276,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 +299,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; @@ -359,20 +350,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); 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; diff --git a/src/map/chrif.c b/src/map/chrif.c index 7277bfe33..cc0797596 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -60,7 +60,7 @@ struct chrif_interface chrif_s; //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) +//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) @@ -362,7 +362,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 +380,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--; @@ -499,7 +499,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); @@ -544,7 +544,7 @@ 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(); @@ -620,7 +620,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 ) @@ -820,7 +820,7 @@ int chrif_changesex(struct map_session_data *sd) { if (sd->fd) clif->authfail_fd(sd->fd, 15); else - iMap->quit(sd); + map->quit(sd); return 0; } @@ -840,7 +840,7 @@ static void chrif_char_ask_name_answer(int acc, const char* player_name, uint16 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 +876,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 +916,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; } @@ -946,14 +946,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 +969,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 +977,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 +1000,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 +1009,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(0message(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(0message(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 +1026,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 +1036,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 +1048,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; @@ -1222,7 +1222,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); @@ -1338,8 +1338,8 @@ 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); @@ -1458,11 +1458,11 @@ int chrif_parse(int fd) { 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 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; @@ -1496,7 +1496,7 @@ int send_usercount_tochar(int tid, unsigned int tick, int id, intptr_t data) { WFIFOHEAD(char_fd,4); WFIFOW(char_fd,0) = 0x2afe; - WFIFOW(char_fd,2) = iMap->usercount(); + WFIFOW(char_fd,2) = map->usercount(); WFIFOSET(char_fd,4); return 0; } @@ -1512,7 +1512,7 @@ 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; diff --git a/src/map/clif.c b/src/map/clif.c index 59b0723fc..1d18559df 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -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; @@ -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->xbl.x-AREA_SIZE-1 || bl->x>sd->bl.x+AREA_SIZE+1 || - bl->ybl.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->xbl.x-AREA_SIZE-1 || bl->x>sd->bl.x+AREA_SIZE+1 || + bl->ybl.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 .L .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->xbl.x-AREA_SIZE-1 || bl->x>sd->bl.x+AREA_SIZE+1 || - bl->ybl.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->xbl.x-AREA_SIZE-1 || bl->x>sd->bl.x+AREA_SIZE+1 || + bl->ybl.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 .W .L .?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->xbl.x-AREA_SIZE-1 || bl->x>sd->bl.x+AREA_SIZE+1 || - bl->ybl.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->xbl.x-AREA_SIZE-1 || bl->x>sd->bl.x+AREA_SIZE+1 || + bl->ybl.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; } @@ -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 .24B (ZC_REQ_EXCHANGE_ITEM) /// 01f4 .24B .L .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); } @@ -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 ) @@ -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); } @@ -5928,8 +5924,7 @@ void clif_upgrademessage(int fd, int result, int item_id) /// Whisper is transmitted to the destination player (ZC_WHISPER). /// 0097 .W .24B .?B /// 0097 .W .24B .L .?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; @@ -5938,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; @@ -6373,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; @@ -8077,28 +8072,22 @@ void clif_wedding_effect(struct block_list *bl) /// Notifies the client of the name of the partner character (ZC_COUPLENAME). /// 01e6 .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; } @@ -8204,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); @@ -8516,7 +8504,7 @@ 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); @@ -9253,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)); @@ -9375,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++; } @@ -9388,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 @@ -9424,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 ) { @@ -9432,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); @@ -9442,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); @@ -9455,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); @@ -9463,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); @@ -9508,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); @@ -9549,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); @@ -9571,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; @@ -9609,7 +9598,7 @@ 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; @@ -9815,8 +9804,7 @@ void clif_parse_QuitGame(int fd, struct map_session_data *sd) /// 0094 .L (CZ_REQNAME) /// 0368 .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; @@ -9824,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] @@ -9842,7 +9830,7 @@ 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 @@ -9851,7 +9839,7 @@ void clif_parse_GetCharNameRequest(int fd, struct map_session_data *sd) } 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); @@ -9987,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 @@ -10106,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()); } @@ -10466,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 @@ -10491,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; } @@ -10532,14 +10519,13 @@ void clif_parse_Broadcast(int fd, struct map_session_data* sd) { /// 009f .L (CZ_ITEM_PICKUP) /// 0362 .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)) { @@ -10808,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) { @@ -11035,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 .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. @@ -11672,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 @@ -11828,12 +11813,11 @@ void clif_parse_InsertCard(int fd,struct map_session_data *sd) /// 0193 .L (CZ_REQNAME_BYGID) /// 0369 .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); } @@ -12061,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); @@ -12082,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); @@ -12198,9 +12182,8 @@ void clif_parse_PartyMessage(int fd, struct map_session_data* sd) /// Changes Party Leader (CZ_CHANGE_GROUP_MASTER). /// 07da .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 @@ -12751,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; } @@ -12948,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 .L .L .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; @@ -12958,9 +12940,8 @@ void clif_parse_GuildInvite(int fd,struct map_session_data *sd) /// Guild invite request (/guildinvite) (CZ_REQ_JOIN_GUILD2). /// 0916 .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; @@ -13054,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) { @@ -13109,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) { @@ -13218,13 +13199,12 @@ void clif_parse_ChangePetName(int fd, struct map_session_data *sd) /// Request to disconnect a character. /// 00cc .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; @@ -13307,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 .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); @@ -13344,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 .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); @@ -13436,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]; @@ -13449,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) @@ -13458,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); } @@ -13536,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)) @@ -13547,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. } @@ -13559,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; @@ -13570,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; } @@ -13775,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); } } @@ -13822,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 .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); @@ -13892,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; @@ -13957,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++); @@ -14042,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); @@ -14431,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; } @@ -15356,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 .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; @@ -15372,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; @@ -15440,10 +15405,9 @@ void clif_bossmapinfo(int fd, struct mob_data *md, short flag) /// Requesting equip of a player (CZ_EQUIPWIN_MICROSCOPE). /// 02d6 .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; @@ -16066,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; } @@ -17713,7 +17677,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/elemental.c b/src/map/elemental.c index e28a64874..09fc6c379 100644 --- a/src/map/elemental.c +++ b/src/map/elemental.c @@ -171,7 +171,7 @@ static int elemental_summon_end(int tid, unsigned int tick, int id, intptr_t dat 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; @@ -226,7 +226,7 @@ int elemental_data_received(struct s_elemental *ele, bool flag) { struct s_elemental_db *db; 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 @@ -255,7 +255,7 @@ 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; @@ -268,7 +268,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); @@ -704,16 +704,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); @@ -752,7 +752,7 @@ static int elemental_ai_sub_foreachclient(struct map_session_data *sd, va_list a } static int elemental_ai_timer(int tid, unsigned int tick, int id, intptr_t data) { - iMap->map_foreachpc(elemental_ai_sub_foreachclient,tick); + map->map_foreachpc(elemental_ai_sub_foreachclient,tick); return 0; } @@ -764,7 +764,7 @@ int read_elementaldb(void) { struct s_elemental_db *db; struct status_data *estatus; - sprintf(line, "%s/%s", iMap->db_path, "elemental_db.txt"); + sprintf(line, "%s/%s", map->db_path, "elemental_db.txt"); memset(elemental->elemental_db,0,sizeof(elemental->elemental_db)); fp = fopen(line, "r"); @@ -855,7 +855,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"); diff --git a/src/map/guild.c b/src/map/guild.c index 253dbcf1c..797b3b370 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -75,16 +75,15 @@ 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); +static 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; } @@ -168,7 +167,7 @@ static bool guild_read_castledb(char* str[], int columns, int current) 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); @@ -401,7 +400,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; @@ -554,9 +553,9 @@ int guild_recv_info(struct guild *sg) { } before=*sg; - //Perform the check on the user because the first load + //Perform the check on the user because the first load guild_check_member(sg); - if ((sd = iMap->nick2sd(sg->master)) != NULL) { + 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 ) @@ -663,7 +662,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 +685,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 +696,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; } @@ -788,33 +786,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 +847,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 +858,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 +876,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 +895,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 +1001,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; } @@ -1213,18 +1209,16 @@ int guild_emblem_changed(int len,int guild_id,int emblem_id,const char *data) 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; @@ -1340,9 +1334,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 +1349,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; } } @@ -1372,8 +1365,8 @@ 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 = status->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)) ) + 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 +1433,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); @@ -1498,12 +1491,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; @@ -1559,14 +1551,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; @@ -1595,31 +1587,30 @@ int guild_opposition(struct map_session_data *sd,struct map_session_data *tsd) 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 +1621,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 +1632,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 +1648,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 +1659,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;jmax_member;j++) @@ -1963,7 +1954,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 +1966,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; } @@ -2234,10 +2225,10 @@ void do_init_guild(void) { guild_flags_count = 0; - sv->readdb(iMap->db_path, "castle_db.txt", ',', 4, 5, -1, &guild_read_castledb); + 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"); diff --git a/src/map/homunculus.c b/src/map/homunculus.c index fb954cdec..45e9af2b0 100644 --- a/src/map/homunculus.c +++ b/src/map/homunculus.c @@ -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){ @@ -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); @@ -921,7 +921,7 @@ 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); } status->revive(&hd->bl, per, 0); @@ -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..097c41edb 100644 --- a/src/map/intif.c +++ b/src/map/intif.c @@ -466,7 +466,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 +851,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 +860,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 +894,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 +933,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 +952,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 +1004,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 +1320,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 +1403,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 +1437,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 +1497,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 +1557,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 +1598,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 +1644,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 +1708,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 +1757,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 +1785,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 +1828,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 +1857,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 +1892,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 +1911,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 2398ba04c..ee0eea5ff 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -1382,7 +1382,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); @@ -1626,7 +1626,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; @@ -1656,7 +1656,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; @@ -1714,7 +1714,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); @@ -1821,12 +1821,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 ) { @@ -1889,9 +1889,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) ) { @@ -1914,7 +1913,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(); @@ -1933,12 +1932,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 1d679a79e..935492dbd 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 ) { @@ -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,8 +1553,8 @@ 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++){ @@ -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; jmap_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; jmap_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; @@ -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(); @@ -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"); @@ -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(); @@ -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 963234ff3..4b06a065b 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -214,10 +214,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) @@ -432,7 +432,7 @@ typedef enum { } cell_t; -// used by iMap->getcell() +// used by map->getcell() typedef enum { CELL_GETTYPE, // retrieves a cell's 'gat' type @@ -524,7 +524,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 { @@ -904,7 +904,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 881038eb4..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 @@ -318,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); @@ -333,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); @@ -451,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; } @@ -487,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 ff949a3ff..b41f7488f 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -154,8 +154,8 @@ 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); + map->addnpc(nd->bl.m, nd); + map->addblock(&nd->bl); status->set_viewdata(&nd->bl, nd->class_); clif->spawn(&nd->bl); @@ -164,14 +164,14 @@ void mvptomb_create(struct mob_data *md, char *killer, time_t time) 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); } @@ -285,7 +285,7 @@ struct mob_data* mob_spawn_dataset(struct spawn_data *data) { 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 ) @@ -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 ) @@ -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); @@ -1188,11 +1185,10 @@ 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 || status->isdead(bl)) { status_kill(&md->bl); @@ -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,9 +1243,9 @@ 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; @@ -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; } } @@ -1372,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; @@ -1424,7 +1420,7 @@ bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick) if (md->target_id) { //Check validity of current target. [Skotlex] - tbl = iMap->id2bl(md->target_id); + 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)) @@ -1462,8 +1458,7 @@ 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 @@ -1517,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_rangestatus.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. @@ -1543,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. */ @@ -1603,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; } @@ -1669,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; } @@ -1749,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; } @@ -1803,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); @@ -1827,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)) @@ -1851,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 ) @@ -1890,16 +1878,15 @@ 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); + struct block_list *bl = map->id2bl(id); if(!bl) return 0; status->revive(bl, (uint8)data, 0); @@ -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 @@ -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 ) { @@ -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); @@ -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. @@ -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); @@ -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 024f649d0..eff80efce 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 /// @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 /// @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,7 +1768,7 @@ 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); @@ -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,7 +2051,7 @@ 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); + map->addblock(&nd->bl); status->set_viewdata(&nd->bl, nd->class_); nd->ud = &npc->base_ud; if( maplist[nd->bl.m].users ) @@ -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,7 +2116,7 @@ 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); + map->addblock(&nd->bl); status->set_viewdata(&nd->bl, nd->class_); nd->ud = &npc->base_ud; if( maplist[nd->bl.m].users ) @@ -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); + 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 ) { 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 ) { 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,7 +2643,7 @@ int npc_duplicate4instance(struct npc_data *snd, int16 m) { wnd->bl.type = BL_NPC; wnd->subtype = WARP; npc->setcells(wnd); - iMap->addblock(&wnd->bl); + map->addblock(&wnd->bl); status->set_viewdata(&wnd->bl, wnd->class_); wnd->ud = &npc->base_ud; if( maplist[wnd->bl.m].users ) @@ -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. @@ -2948,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; @@ -3059,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; @@ -3095,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 } @@ -3164,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; } @@ -3214,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")) @@ -3249,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")) @@ -3444,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; @@ -3570,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) @@ -3765,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]); @@ -3773,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; } } @@ -3789,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 @@ -3812,7 +3789,7 @@ int npc_reload(void) { instance->destroy(i); } - iMap->zone_init(); + map->zone_init(); npc->motd = npc->name2id("HerculesMOTD"); /* [Ind/Hercules] */ @@ -3876,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, @@ -3904,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]); } @@ -3963,7 +3939,7 @@ int do_init_npc(void) itemdb->name_constants(); - iMap->zone_init(); + map->zone_init(); npc->motd = npc->name2id("HerculesMOTD"); /* [Ind/Hercules] */ @@ -3993,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/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;ifreeblock_unlock(); + map->freeblock_unlock(); return total; } diff --git a/src/map/pc.c b/src/map/pc.c index 9dbb5175a..e88bdb2f1 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 ) @@ -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,9 +376,8 @@ 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]); + 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] ) { @@ -463,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 ) @@ -1153,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); } /** @@ -1244,7 +1238,7 @@ int pc_reg_received(struct map_session_data *sd) for(i=0;ifeel_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; @@ -1294,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); @@ -1757,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); } @@ -2016,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); @@ -4055,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); @@ -4085,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 @@ -4095,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) || @@ -4106,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) || @@ -4130,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; } @@ -4783,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; } @@ -4858,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! @@ -4905,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) @@ -4935,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); } @@ -5006,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); @@ -5683,7 +5673,7 @@ 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) { @@ -5693,7 +5683,7 @@ int pc_follow_timer(int tid, unsigned int tick, int id, intptr_t data) { } sd->followtimer = INVALID_TIMER; - tbl = iMap->id2bl(sd->followtarget); + tbl = map->id2bl(sd->followtarget); if (tbl == NULL || pc_isdead(sd) || status->isdead(tbl)) { pc->stop_following(sd); @@ -5733,9 +5723,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) @@ -6638,9 +6627,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; @@ -6690,7 +6678,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; @@ -6866,7 +6854,7 @@ 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] @@ -7608,7 +7596,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; @@ -8289,9 +8277,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) @@ -9034,7 +9021,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) { @@ -9043,7 +9030,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; @@ -9051,11 +9038,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; @@ -9119,8 +9105,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 @@ -9147,11 +9133,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; } @@ -9159,11 +9144,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; } @@ -9171,11 +9155,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; } @@ -9183,11 +9166,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; } @@ -9303,18 +9285,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; @@ -9323,18 +9305,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; @@ -9344,18 +9325,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; @@ -9417,12 +9397,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); @@ -9907,11 +9886,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){ @@ -9989,13 +9968,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; @@ -10017,7 +9996,7 @@ int pc_readdb(void) { for(k=0;kdb_path); + sprintf(line, "%s/"DBPATH"attr_fix.txt", map->db_path); fp=fopen(line,"r"); if(fp==NULL){ @@ -10061,13 +10040,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); @@ -10088,7 +10067,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 @@ -10164,10 +10143,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; @@ -10176,8 +10155,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/pet.c b/src/map/pet.c index dd0ed1bb9..811ac9f09 100644 --- a/src/map/pet.c +++ b/src/map/pet.c @@ -109,7 +109,7 @@ int pet_attackskill(struct pet_data *pd, int target_id) { int inf; struct block_list *bl; - bl=iMap->id2bl(target_id); + 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; @@ -186,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; @@ -300,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); @@ -360,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(); @@ -401,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); @@ -417,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) { @@ -446,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); @@ -483,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; @@ -535,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; @@ -544,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; @@ -565,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; @@ -699,7 +696,7 @@ int pet_unequipitem(struct map_session_data *sd, struct pet_data *pd) { 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 @@ -788,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; } @@ -863,7 +860,7 @@ 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); + 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) ) { @@ -874,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); } @@ -918,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); @@ -936,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; } @@ -970,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; @@ -1039,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; @@ -1081,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) @@ -1110,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; @@ -1147,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; @@ -1218,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 b940d03e4..992f9da94 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; @@ -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; @@ -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; @@ -5931,7 +5926,7 @@ BUILDIN(getitem) it.identify=itemdb->isidentified2(item_data); if( script_hasdata(st,4) ) - sd=iMap->id2sd(script_getnum(st,4)); // + sd=map->id2sd(script_getnum(st,4)); // else sd=script_rid2sd(st); // Attached player @@ -5944,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); } } } @@ -5974,7 +5966,7 @@ BUILDIN(getitem2) struct script_data *data; if( script_hasdata(st,11) ) - sd=iMap->id2sd(script_getnum(st,11)); // + sd=map->id2sd(script_getnum(st,11)); // else sd=script_rid2sd(st); // Attached player @@ -6042,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); } } } @@ -6161,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 @@ -6251,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); @@ -6273,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; } @@ -6434,7 +6422,7 @@ BUILDIN(delitem) if( script_hasdata(st,4) ) { int account_id = script_getnum(st,4); - sd = iMap->id2sd(account_id); // + sd = map->id2sd(account_id); // if( sd == NULL ) { ShowError("script:delitem: player not found (AID=%d).\n", account_id); @@ -6494,18 +6482,15 @@ BUILDIN(delitem) /// /// delitem2 ,,,,,,,,{,} /// delitem2 "",,,,,,,,{,} -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); // - if( sd == NULL ) - { + sd = map->id2sd(account_id); // + if( sd == NULL ) { ShowError("script:delitem2: player not found (AID=%d).\n", account_id); st->state = END; return false; @@ -6591,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); @@ -6621,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); @@ -6904,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; @@ -8405,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); @@ -8479,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; } @@ -8579,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; } @@ -8637,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); @@ -8648,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 ) @@ -8656,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; } @@ -8683,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 ) @@ -8697,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; } @@ -8736,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 @@ -8778,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 @@ -8869,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; @@ -8917,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; @@ -8946,8 +8918,7 @@ BUILDIN(startnpctimer) } /*========================================== *------------------------------------------*/ -BUILDIN(stopnpctimer) -{ +BUILDIN(stopnpctimer) { struct npc_data *nd; int flag = 0; @@ -8963,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; @@ -8987,8 +8955,7 @@ BUILDIN(stopnpctimer) } /*========================================== *------------------------------------------*/ -BUILDIN(getnpctimer) -{ +BUILDIN(getnpctimer) { struct npc_data *nd; TBL_PC *sd; int type = script_getnum(st,2); @@ -8997,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 ) { @@ -9006,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; } @@ -9040,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; @@ -9057,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 ) { @@ -9070,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); @@ -9089,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 ) { @@ -9115,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); @@ -9138,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; @@ -9189,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 ); @@ -9218,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); @@ -9230,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); @@ -9255,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; } @@ -9276,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; @@ -9287,7 +9245,7 @@ BUILDIN(getusers) { } break; case 1: - val = iMap->getusers(); + val = map->getusers(); break; default: ShowWarning("buildin_getusers: Unknown type %d.\n", flag); @@ -9339,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; } @@ -9362,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; } @@ -9386,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; } @@ -9433,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; } @@ -9494,9 +9452,9 @@ 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 && status->sc2skill(type) != 0 ) { // When there isn't a duration specified, try to get it from the skill_db @@ -9505,7 +9463,7 @@ BUILDIN(sc_start) { 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); + bl = map->id2bl(script->potion_target); tick /= 2;// Thrown potions only last half. val4 = 1;// Mark that this was a thrown sc_effect } @@ -9532,9 +9490,9 @@ 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 && status->sc2skill(type) != 0 ) { // When there isn't a duration specified, try to get it from the skill_db @@ -9543,7 +9501,7 @@ BUILDIN(sc_start2) { 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); + bl = map->id2bl(script->potion_target); tick /= 2;// Thrown potions only last half. val4 = 1;// Mark that this was a thrown sc_effect } @@ -9573,9 +9531,9 @@ 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 && status->sc2skill(type) != 0 ) { // When there isn't a duration specified, try to get it from the skill_db @@ -9584,7 +9542,7 @@ BUILDIN(sc_start4) { 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); + bl = map->id2bl(script->potion_target); tick /= 2;// Thrown potions only last half. } @@ -9603,12 +9561,12 @@ BUILDIN(sc_end) { 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; @@ -9650,9 +9608,9 @@ BUILDIN(getscrate) { 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 = status->get_sc_def(bl, (sc_type)type, 10000, 10000, 0); @@ -9942,7 +9900,7 @@ BUILDIN(changebase) { 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); @@ -9991,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; @@ -10018,8 +9975,7 @@ BUILDIN(globalmes) /// Creates a waiting room (chat room) for this npc. /// /// waitingroom "",<limit>{,"<event>"{,<trigger>{,<zeny>{,<minlvl>{,<maxlvl>}}}}}; -BUILDIN(waitingroom) -{ +BUILDIN(waitingroom) { struct npc_data* nd; int pub = 1; const char* title = script_getstr(st, 2); @@ -10030,7 +9986,7 @@ 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); @@ -10041,13 +9997,12 @@ 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); return true; @@ -10057,17 +10012,16 @@ 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 ) + if( nd != NULL && (cd=(struct chat_data *)map->id2bl(nd->chat_id)) != NULL ) chat->npckickall(cd); return true; } @@ -10076,17 +10030,16 @@ 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 ) + if( nd != NULL && (cd=(struct chat_data *)map->id2bl(nd->chat_id)) != NULL ) chat->enableevent(cd); return true; } @@ -10095,17 +10048,16 @@ 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 ) + if( nd != NULL && (cd=(struct chat_data *)map->id2bl(nd->chat_id)) != NULL ) chat->disableevent(cd); return true; } @@ -10124,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; @@ -10134,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; @@ -10180,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); @@ -10239,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; @@ -10264,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; @@ -10278,8 +10225,7 @@ BUILDIN(isloggedin) /*========================================== * *------------------------------------------*/ -BUILDIN(setmapflagnosave) -{ +BUILDIN(setmapflagnosave) { int16 m,x,y; unsigned short mapindex; const char *str,*str2; @@ -10288,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) { @@ -10309,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; @@ -10403,7 +10349,7 @@ BUILDIN(setmapflag) { val = script_getnum(st, 4); } - m = iMap->mapname2mapid(str); + m = map->mapname2mapid(str); if(m >= 0) { switch(i) { @@ -10416,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; @@ -10491,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; @@ -10544,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; @@ -10577,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; @@ -10627,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; @@ -10641,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; } @@ -10650,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; @@ -10668,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; @@ -10686,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; @@ -10701,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; } @@ -10745,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; } @@ -10798,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 ) { @@ -10994,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); } } } @@ -11016,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); @@ -11061,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); } } } @@ -11090,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); @@ -11104,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; @@ -11121,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))) @@ -11150,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; } @@ -11166,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); @@ -11186,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; } @@ -11196,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); @@ -11214,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); @@ -11237,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; } @@ -11308,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; } @@ -11418,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; } @@ -11439,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); @@ -11448,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; } @@ -11819,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; @@ -11841,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{ @@ -11903,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; @@ -11960,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); @@ -11982,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); @@ -11996,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"); } @@ -12192,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); @@ -12210,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; @@ -12239,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); @@ -12282,8 +12200,7 @@ BUILDIN(nude) /*========================================== * gmcommand [MouseJstr] *------------------------------------------*/ -BUILDIN(atcommand) -{ +BUILDIN(atcommand) { TBL_PC *sd, *dummy_sd = NULL; int fd; const char* cmd; @@ -12298,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); @@ -12422,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; } @@ -12549,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); @@ -12567,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) @@ -12592,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 @@ -12604,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); @@ -12624,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 @@ -12746,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); @@ -12761,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); @@ -12776,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); @@ -12785,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); @@ -12794,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); @@ -12909,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; } @@ -13113,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; } @@ -14467,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; @@ -14483,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; @@ -14617,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); @@ -14630,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); @@ -14647,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); @@ -14775,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; @@ -14800,8 +14700,7 @@ BUILDIN(rid2name) return true; } -BUILDIN(pcblockmove) -{ +BUILDIN(pcblockmove) { int id, flag; TBL_PC *sd = NULL; @@ -14809,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); @@ -14819,8 +14718,7 @@ BUILDIN(pcblockmove) return true; } -BUILDIN(pcfollow) -{ +BUILDIN(pcfollow) { int id, targetid; TBL_PC *sd = NULL; @@ -14829,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); @@ -14848,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); @@ -14869,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; @@ -14884,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; @@ -14895,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); @@ -14920,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 @@ -14946,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; @@ -14962,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 ) { @@ -15010,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); @@ -15034,7 +14929,7 @@ BUILDIN(unittalk) { unit_id = script_getnum(st,2); message = script_getstr(st, 3); - bl = iMap->id2bl(unit_id); + bl = map->id2bl(unit_id); if( bl != NULL ) { struct StringBuf sbuf; StrBuf->Init(&sbuf); @@ -15053,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); @@ -15072,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; @@ -15085,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 ) { @@ -15105,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; @@ -15120,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 ) { @@ -15170,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; } @@ -15211,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; @@ -15284,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; @@ -15294,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"); @@ -15351,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); @@ -15363,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; } @@ -15373,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); @@ -15637,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 ) @@ -15658,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 = ""; @@ -15669,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; } @@ -15713,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; @@ -15730,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 ) @@ -15793,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; @@ -15830,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; @@ -15842,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; } @@ -15871,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); @@ -15998,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; } @@ -16083,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; } @@ -16121,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; } @@ -16204,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; } @@ -16252,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; @@ -16308,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; } @@ -16332,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; } @@ -16358,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; } @@ -16621,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 @@ -16703,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); @@ -16722,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); @@ -16741,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); @@ -16853,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); @@ -16995,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); } } } @@ -17008,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; @@ -17046,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; @@ -17055,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 ); @@ -17167,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; @@ -17213,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; @@ -17291,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] ) { @@ -17330,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; @@ -17505,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 8a5969345..8e83f8bd2 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -569,7 +569,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) ) { @@ -666,7 +666,7 @@ 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]; - 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]; @@ -1393,9 +1393,9 @@ int skill_additional_effect(struct block_list* src, struct block_list *bl, uint1 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; } @@ -2094,7 +2094,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 @@ -2521,7 +2521,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) @@ -2655,7 +2655,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; } @@ -2671,7 +2671,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 ); @@ -2681,7 +2681,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; @@ -2707,7 +2707,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) || @@ -2793,7 +2793,7 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds 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); } @@ -2905,7 +2905,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) { @@ -2952,9 +2952,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); } /*========================================== @@ -3081,7 +3081,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; @@ -3096,7 +3096,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) @@ -3114,7 +3114,7 @@ int skill_timerskill(int tid, unsigned int tick, int id, intptr_t data) { 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); + map->search_freecell(src, 0, &x, &y, 1, 1, 0); if (target != src && !status->isdead(target)) unit->warp(target, -1, x, y, CLR_TELEPORT); } @@ -3122,16 +3122,16 @@ int skill_timerskill(int tid, unsigned int tick, int id, intptr_t data) { 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[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; - 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); + 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 @@ -3192,7 +3192,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; @@ -3218,8 +3218,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: @@ -3271,14 +3271,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 +3344,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; } @@ -3401,7 +3402,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint tstatus = status->get_status_data(bl); - iMap->freeblock_lock(); + map->freeblock_lock(); switch(skill_id) { case MER_CRASH: @@ -3551,12 +3552,12 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint 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; @@ -3564,15 +3565,15 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint 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); + 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,9 +3600,9 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint //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); + 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,9 +3611,9 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint 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); + 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: @@ -3622,8 +3623,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] @@ -3676,7 +3677,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint 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; @@ -3795,10 +3796,10 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint //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; @@ -3826,13 +3827,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); + 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); + 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); @@ -3848,15 +3849,15 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint 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); + 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); 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]; } @@ -3868,10 +3869,10 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint { 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] @@ -3950,11 +3951,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 } @@ -4063,7 +4064,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); } @@ -4071,7 +4072,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); @@ -4082,7 +4083,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; @@ -4258,7 +4259,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,39 +4284,33 @@ 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); 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); } @@ -4327,14 +4322,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); + 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); } @@ -4399,9 +4393,9 @@ 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: @@ -4436,7 +4430,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); } @@ -4459,7 +4453,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); } @@ -4504,7 +4498,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; @@ -4532,10 +4526,10 @@ 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, 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); + 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] } } @@ -4546,14 +4540,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 @@ -4583,7 +4577,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); @@ -4624,7 +4618,7 @@ 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 { @@ -4644,7 +4638,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; } @@ -4658,8 +4652,8 @@ 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; } } @@ -4815,7 +4809,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); @@ -4848,7 +4842,7 @@ 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); @@ -4867,10 +4861,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; @@ -5011,7 +5005,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui if( sd && !pc->checkskill(sd, RK_RUNEMASTERY) ){ 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; } } @@ -5032,7 +5026,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: @@ -5171,8 +5165,8 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui if (flag&1) 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; @@ -5227,7 +5221,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 @@ -5331,7 +5325,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; } } @@ -5343,34 +5337,27 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui { 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; } } @@ -5453,8 +5440,8 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui 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); + 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)); @@ -5611,20 +5598,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))); @@ -5692,29 +5678,27 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui 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( status->change_timer_sub, src, - skill->get_splash(skill_id, skill_lv), BL_CHAR, - src,NULL,type,tick); + 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 + status->get_lv(src) - status->get_lv(bl)), skill_lv, skill->get_time(skill_id,skill_lv)))); - if( !i ) - { + 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); @@ -5756,7 +5740,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; } @@ -5768,10 +5752,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; } } @@ -5865,10 +5849,10 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case RG_RAID: 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; @@ -5883,8 +5867,8 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case KO_HAPPOKUNAI: 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; @@ -5916,10 +5900,10 @@ 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: @@ -5927,9 +5911,9 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui 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); + 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] @@ -5939,12 +5923,12 @@ 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); + 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; @@ -6004,7 +5988,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))); @@ -6041,24 +6025,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)); @@ -6076,7 +6058,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: @@ -6176,9 +6158,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; } } @@ -6297,7 +6279,7 @@ 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 @@ -6383,7 +6365,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; @@ -6467,11 +6449,12 @@ 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 ) { @@ -6480,18 +6463,18 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui 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]) { 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; } } @@ -6579,9 +6562,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; } @@ -6683,9 +6666,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] @@ -6709,7 +6692,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); } @@ -6821,8 +6804,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; @@ -6930,7 +6913,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; @@ -6941,7 +6924,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) @@ -7031,7 +7014,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui // if neither was found if(!f_sd && !m_sd) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 0; } status->change_start(bl,SC_STUN,10000,skill_lv,0,0,0,skill->get_time2(skill_id,skill_lv),8); @@ -7066,37 +7049,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.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); } } } @@ -7142,16 +7120,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, @@ -7164,23 +7140,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; } @@ -7276,7 +7252,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); @@ -7302,15 +7278,14 @@ 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] @@ -7467,10 +7442,10 @@ 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)); } 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)); } @@ -7481,10 +7456,10 @@ 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)); } 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)); } @@ -7495,10 +7470,10 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui clif->skill_nodamage(src,bl,AL_HEAL,status_percent_heal(bl,90,90),1); } 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)); } @@ -7519,7 +7494,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); } @@ -7601,8 +7576,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 @@ -7621,7 +7596,7 @@ 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); @@ -7685,13 +7660,13 @@ 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 { + } 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: @@ -7700,10 +7675,10 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui 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 ALL_PARTYFLEE: @@ -7738,14 +7713,13 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case RK_DRAGONHOWLING: if( flag&1) sc_start(bl,type,50 + 6 * skill_lv,skill_lv,skill->get_time(skill_id,skill_lv)); - else - { + 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: @@ -7754,10 +7728,10 @@ 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 ) { @@ -7871,7 +7845,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui { 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); + 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; @@ -7925,8 +7899,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: @@ -7995,9 +7969,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); } @@ -8071,12 +8044,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; @@ -8086,9 +8059,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; @@ -8115,12 +8087,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: @@ -8140,7 +8112,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui 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); } @@ -8211,7 +8183,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) ) { @@ -8223,7 +8195,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 @@ -8258,7 +8230,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); } @@ -8286,7 +8258,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); @@ -8330,8 +8302,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; @@ -8369,7 +8341,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui 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: @@ -8390,40 +8362,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 ) @@ -8437,14 +8408,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) ) @@ -8498,7 +8469,7 @@ 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)); 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); + 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; @@ -8526,7 +8497,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui 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; @@ -8548,13 +8519,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, @@ -8584,7 +8555,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; @@ -8690,7 +8661,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; @@ -8720,12 +8691,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 @@ -8760,7 +8731,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui } 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); + 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; @@ -8799,7 +8770,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 @@ -8830,10 +8801,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); @@ -8869,8 +8840,8 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui 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; @@ -8998,8 +8969,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: @@ -9015,7 +8986,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. @@ -9234,9 +9205,9 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui 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{ + } 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); + 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; @@ -9317,7 +9288,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui 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); + 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; @@ -9339,7 +9310,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui 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; } @@ -9365,16 +9336,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); @@ -9501,7 +9471,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] @@ -9513,7 +9483,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); @@ -9718,38 +9688,38 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui case PR_BENEDICTIO: 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( status->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: @@ -9889,7 +9859,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; @@ -9910,7 +9880,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: @@ -10020,10 +9990,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); } } else { int i = skill_lv%11 - 1; @@ -10042,10 +10012,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; @@ -10055,7 +10025,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; @@ -10071,8 +10041,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; } @@ -10138,14 +10107,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 @@ -10166,13 +10135,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++ ) @@ -10192,7 +10161,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; /** @@ -10246,10 +10215,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; @@ -10266,7 +10235,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui case LG_RAYOFGENESIS: 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); @@ -10274,13 +10243,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); @@ -10312,10 +10281,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: @@ -10403,7 +10372,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); } /*========================================== @@ -10466,7 +10435,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) ) @@ -10543,7 +10512,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. @@ -10559,7 +10528,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; @@ -10798,8 +10767,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: @@ -10874,7 +10843,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. @@ -10886,7 +10855,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: @@ -10938,11 +10907,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; @@ -10958,10 +10927,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; } @@ -10969,7 +10939,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; @@ -10997,11 +10967,11 @@ int skill_unit_onplace (struct skill_unit *src, struct block_list *bl, unsigned 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 = status->get_sc(bl); @@ -11023,7 +10993,7 @@ int skill_unit_onplace (struct skill_unit *src, struct block_list *bl, unsigned 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; } @@ -11065,7 +11035,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; @@ -11073,7 +11043,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); } @@ -11211,7 +11181,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns 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 = status->get_sc(bl); @@ -11243,7 +11213,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) { @@ -11419,12 +11389,12 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns if( status_get_mode(bl)&MD_BOSS ) break; 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) ) { - iMap->moveblock(bl, src->bl.x, src->bl.y, tick); + 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; @@ -11455,9 +11425,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 + @@ -11644,9 +11614,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; @@ -11701,7 +11671,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; @@ -11727,7 +11697,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 @@ -11937,16 +11907,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; } @@ -12168,7 +12138,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) @@ -12233,26 +12203,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) + 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); 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); @@ -12269,7 +12239,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. @@ -12656,7 +12626,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; } @@ -12947,13 +12917,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; @@ -13110,7 +13080,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; @@ -13291,10 +13261,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; } @@ -13312,9 +13283,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; @@ -13324,7 +13295,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; @@ -14208,7 +14179,7 @@ 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); @@ -14217,10 +14188,10 @@ void skill_brandishspear(struct block_list* src, struct block_list* bl, uint16 s 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){ @@ -14233,11 +14204,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; } @@ -14245,7 +14216,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); @@ -14263,7 +14234,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) @@ -14531,11 +14502,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; } @@ -14751,11 +14722,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)) ); @@ -14908,7 +14879,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; @@ -15008,7 +14979,7 @@ 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; @@ -15045,10 +15016,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; } @@ -15079,7 +15051,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; } @@ -15108,13 +15080,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; @@ -15125,13 +15097,13 @@ struct skill_unit *skill_initunit (struct skill_unit_group *group, int idx, int su->val2=val2; idb_put(skillunit_db, su->bl.id, su); - iMap->addiddb(&su->bl); - iMap->addblock(&su->bl); + 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++; @@ -15174,18 +15146,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--; @@ -15197,7 +15170,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); } @@ -15207,7 +15180,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 = status->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 } @@ -15217,8 +15190,8 @@ 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); + map->delblock(&su->bl); // don't free yet + map->deliddb(&su->bl); idb_remove(skillunit_db, su->bl.id); if(--group->alive_count==0) skill->del_unitgroup(group,ALC_MARK); @@ -15320,19 +15293,17 @@ struct skill_unit_group* skill_initunitgroup (struct block_list* src, int count, /*========================================== * *------------------------------------------*/ -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); @@ -15433,7 +15404,7 @@ int skill_delunitgroup(struct skill_unit_group *group, const char* file, int lin } idb_remove(group_db, group->group_id); - iMap->freeblock(&group->unit->bl); // schedules deallocation of whole array (HACK) + map->freeblock(&group->unit->bl); // schedules deallocation of whole array (HACK) group->unit=NULL; group->group_id=0; group->unit_count=0; @@ -15519,7 +15490,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 ) @@ -15591,13 +15562,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); } @@ -15611,20 +15582,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); @@ -15639,23 +15610,23 @@ 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 = status->get_sc(src)) == NULL || !sc->data[SC_BANDING] ) { skill->delunit(su); @@ -15701,7 +15672,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; @@ -15724,9 +15695,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; @@ -15748,11 +15719,11 @@ 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); - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 0; } @@ -15868,7 +15839,7 @@ int skill_unit_move (struct block_list *bl, unsigned int tick, int flag) { 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; @@ -15934,13 +15905,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 @@ -15950,7 +15921,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; } @@ -15963,7 +15934,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); @@ -16529,7 +16500,7 @@ int skill_produce_mix(struct map_session_data *sd, uint16 skill_id, int nameid, 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++; } @@ -16543,7 +16514,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); @@ -16595,7 +16566,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); } @@ -16652,7 +16623,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); } } @@ -16880,7 +16851,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); } } @@ -16951,7 +16922,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: @@ -16960,7 +16931,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. @@ -16972,7 +16943,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) @@ -17081,7 +17052,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; @@ -17106,7 +17077,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; @@ -18024,27 +17995,27 @@ void skill_readdb(void) { 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) { diff --git a/src/map/status.c b/src/map/status.c index 501448cc7..9ad1c2205 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -1592,7 +1592,7 @@ int status_check_skilluse(struct block_list *src, struct block_list *target, uin 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; @@ -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; } @@ -2064,7 +2064,7 @@ 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 = status->get_base_status(mbl); @@ -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; @@ -7291,7 +7291,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val if( sd ) { int i; for( i = 0; i < 5; i++ ) { - if( sd->devotion[i] && (tsd = iMap->id2sd(sd->devotion[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) ) @@ -7379,7 +7379,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val if( sd ) { int i; for( i = 0; i < 5; i++ ) { - if( sd->devotion[i] && (tsd = iMap->id2sd(sd->devotion[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) ) @@ -7518,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); } @@ -7556,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,7 +7634,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val 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])) ) + if( sd->devotion[i] && (tsd = map->id2sd(sd->devotion[i])) ) status->change_start(&tsd->bl, type, 10000, val1, val2, 0, 0, tick, 1); } } @@ -7656,7 +7655,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val 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]))) + 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); } } @@ -7727,7 +7726,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val { int stat,max_stat; // fetch caster information - struct block_list *pbl = iMap->id2bl(val1); + 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 @@ -7776,7 +7775,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val struct block_list *d_bl; struct status_change *d_sc; - if( (d_bl = iMap->id2bl(val1)) && (d_sc = status->get_sc(d_bl)) && d_sc->count ) { + 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; @@ -7793,7 +7792,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val 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); } @@ -7802,7 +7801,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val break; case SC_RG_CCONFINE_S: { - struct block_list *src = val2 ? iMap->id2bl(val2) : NULL; + 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) { @@ -8257,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; @@ -8335,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; @@ -8499,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; @@ -9088,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 @@ -9327,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); @@ -9346,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 ) @@ -9366,7 +9362,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const case SC_BLADESTOP: if(sce->val4) { int tid = sce->val4; - struct block_list *tbl = iMap->id2bl(tid); + 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]) { @@ -9399,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) { @@ -9446,14 +9442,14 @@ 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 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. @@ -9468,7 +9464,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const int range = 1 +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(status->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; @@ -9499,7 +9495,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const 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 block_list *pbl = map->id2bl(sce->val1); struct status_change* sc2 = pbl ? status->get_sc(pbl) : NULL; if (sc2 && sc2->data[type2]) @@ -9575,14 +9571,14 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const 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); + struct block_list* tbl = map->id2bl(sce->val2); sce->val2 = 0; 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); @@ -9602,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)); @@ -9621,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); @@ -9653,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(status->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) ) { @@ -9669,7 +9666,7 @@ 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 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); @@ -9679,7 +9676,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const break; case SC_BLOOD_SUCKER: if( sce->val2 ){ - struct block_list *src = iMap->id2bl(sce->val2); + struct block_list *src = map->id2bl(sce->val2); if(src) { struct status_change *sc = status->get_sc(src); sc->bs_counter--; @@ -9910,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); @@ -9924,7 +9921,7 @@ 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)) + if(!( (bl=map->id2bl(id)) && (sc=status->get_sc(bl)) && (sce=sc->data[SC_KAAHI]) )) @@ -9963,7 +9960,7 @@ 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); + bl = map->id2bl(id); if(!bl) { ShowDebug("status_change_timer: Null pointer id: %d data: %d\n", id, data); return 0; @@ -10036,9 +10033,9 @@ 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(status->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(status->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. @@ -10080,16 +10077,16 @@ 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, status->change_timer, bl->id, data ); } - iMap->freeblock_unlock(); + map->freeblock_unlock(); } return 0; } @@ -10116,20 +10113,20 @@ 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, status->change_timer, bl->id, data); } - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 0; } break; @@ -10149,7 +10146,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) { case SC_CASH_BOSS_ALARM: if( sd && --(sce->val4) >= 0 ) { - struct mob_data *boss_md = iMap->id2boss(sce->val1); + 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) { @@ -10252,7 +10249,7 @@ 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); + 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; @@ -10295,13 +10292,13 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) { 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,status->change_timer,bl->id,data); } - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 0; } break; @@ -10311,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(); + 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, status->change_timer, bl->id, data ); } - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 0; } break; @@ -10329,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 @@ -10369,13 +10366,13 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) { case SC_TOXIN: if( --(sce->val4) > 0 ) { //Damage is every 10 seconds including 3%sp drain. - iMap->freeblock_lock(); + map->freeblock_lock(); clif->damage(bl,bl,tick,status_get_amotion(bl),1,1,0,0,0); 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, status->change_timer, bl->id, data ); } - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 0; } break; @@ -10416,17 +10413,17 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) { case SC_BURNING: if( --(sce->val4) > 0 ) { - struct block_list *src = iMap->id2bl(sce->val3); + 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 status->damage(src, bl, damage, 0, 0, 1); if( sc->data[type]){ // Target still lives. [LimitLine] sc_timer_next(3000 + tick, status->change_timer, bl->id, data); } - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 0; } break; @@ -10519,18 +10516,18 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) { 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 && (status->isdead(src) || src->m != bl->m || distance_bl(src, bl) >= 12)) ) break; - iMap->freeblock_lock(); + map->freeblock_lock(); damage = sce->val3; 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, status->change_timer, bl->id, data); } - iMap->freeblock_unlock(); + map->freeblock_unlock(); status->heal(src, damage*(5 + 5 * sce->val1)/100, 0, 0); // 5 + 5% per level return 0; } @@ -10627,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, status->change_timer, bl->id, data); } - iMap->freeblock_unlock(); + map->freeblock_unlock(); } break; @@ -10644,7 +10641,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) { 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); + struct block_list *src = map->id2bl(sce->val2); struct status_change *ssc; if( !src || (ssc = status->get_sc(src)) == NULL || !ssc->data[SC_MAGNETICFIELD] ) break; // Source no more under Magnetic Field @@ -11294,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; } @@ -11482,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; } 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 e4ea365df..44bb1970c 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -137,8 +137,7 @@ int unit_walktoxy_sub(struct block_list *bl) 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; @@ -290,10 +289,9 @@ 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); + struct block_list *tbl = map->id2bl(ud->target_to); if (!tbl || !status->check_visibility(bl, tbl)) { //Cancel chase. ud->to_x = bl->x; @@ -303,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] @@ -316,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; @@ -363,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; } @@ -379,7 +376,7 @@ int unit_walktoxy( struct block_list *bl, short x, short y, int flag) 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 @@ -405,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); } @@ -454,7 +448,7 @@ int unit_walktobl(struct block_list *bl, struct block_list *tbl, int range, int 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; @@ -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; @@ -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); @@ -1014,7 +1004,7 @@ int unit_can_move(struct block_list *bl) { 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, @@ -1124,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; @@ -1133,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; @@ -1156,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; @@ -1334,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; @@ -1474,11 +1464,11 @@ 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; } @@ -1487,8 +1477,8 @@ int unit_skilluse_pos2( struct block_list *src, short skill_x, short skill_y, ui 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; } @@ -1579,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 ++; } @@ -1623,14 +1613,13 @@ 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); + target = map->id2bl(target_id); if( target==NULL || status->isdead(target) ) { unit->unattackable(src); return 1; @@ -1733,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]; @@ -1826,7 +1815,7 @@ 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; @@ -1877,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); @@ -1888,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); @@ -1901,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 @@ -1935,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; @@ -2079,7 +2066,7 @@ int unit_remove_map(struct block_list *bl, clr_type clrtype, const char* file, i if(bl->prev == NULL) return 0; //Already removed? - iMap->freeblock_lock(); + map->freeblock_lock(); unit->set_target(ud, 0); @@ -2108,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); } @@ -2135,10 +2121,10 @@ 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) @@ -2204,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; @@ -2234,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; } @@ -2248,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; @@ -2262,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; @@ -2275,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; @@ -2292,8 +2276,8 @@ int unit_remove_map(struct block_list *bl, clr_type clrtype, const char* file, i **/ 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; } @@ -2326,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); @@ -2357,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); @@ -2585,10 +2568,10 @@ int unit_free(struct block_list *bl, clr_type clrtype) skill->clear_unitgroup(bl); status->change_clear(bl,1); - iMap->deliddb(bl); + 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? } } } diff --git a/src/plugins/db2sql.c b/src/plugins/db2sql.c index ebd2a9ee5..d769a601e 100644 --- a/src/plugins/db2sql.c +++ b/src/plugins/db2sql.c @@ -49,17 +49,17 @@ int db2sql(char** str, const char* source, int line, int scriptopt) { struct item_data *it = NULL; unsigned char offset = 0; #ifdef RENEWAL - if( iMap->db_use_sql_item_db ) offset = 1; -#endif + if( map->db_use_sql_item_db ) offset = 1; +#endif // RENEWAL if( (it = itemdb->exists(parse_dbrow(str,source,line,scriptopt))) ) { /* renewal has the 'matk' and 'equip_level' is now 'equip_level_min', and there is a new 'equip_level_max' field */ #ifdef RENEWAL - if( SQL_SUCCESS != SQL->StmtPrepare(stmt, "REPLACE INTO `%s` (`id`,`name_english`,`name_japanese`,`type`,`price_buy`,`price_sell`,`weight`,`atk`,`matk`,`defence`,`range`,`slots`,`equip_jobs`,`equip_upper`,`equip_genders`,`equip_locations`,`weapon_level`,`equip_level_min`,`equip_level_max`,`refineable`,`view`,`script`,`equip_script`,`unequip_script`) VALUES ('%u',?,?,'%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u',?,?,?)",iMap->item_db_re_db, - it->nameid,it->flag.delay_consume?IT_DELAYCONSUME:it->type,it->value_buy,it->value_sell,it->weight,it->atk,it->matk,it->def,it->range,it->slot,(unsigned int)strtoul(str[11+offset],NULL,0),atoi(str[12+offset]),atoi(str[13+offset]),atoi(str[14+offset]),it->wlv,it->elv,it->elvmax,atoi(str[17+offset]),it->look) ) -#else - if( SQL_SUCCESS != SQL->StmtPrepare(stmt, "REPLACE INTO `%s` (`id`,`name_english`,`name_japanese`,`type`,`price_buy`,`price_sell`,`weight`,`atk`,`defence`,`range`,`slots`,`equip_jobs`,`equip_upper`,`equip_genders`,`equip_locations`,`weapon_level`,`equip_level`,`refineable`,`view`,`script`,`equip_script`,`unequip_script`) VALUES ('%u',?,?,'%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u',?,?,?)",iMap->item_db_db, - it->nameid,it->flag.delay_consume?IT_DELAYCONSUME:it->type,it->value_buy,it->value_sell,it->weight,it->atk,it->def,it->range,it->slot,(unsigned int)strtoul(str[11],NULL,0),atoi(str[12]),atoi(str[13]),atoi(str[14]),it->wlv,it->elv,atoi(str[17]),it->look) ) -#endif + if( SQL_SUCCESS != SQL->StmtPrepare(stmt, "REPLACE INTO `%s` (`id`,`name_english`,`name_japanese`,`type`,`price_buy`,`price_sell`,`weight`,`atk`,`matk`,`defence`,`range`,`slots`,`equip_jobs`,`equip_upper`,`equip_genders`,`equip_locations`,`weapon_level`,`equip_level_min`,`equip_level_max`,`refineable`,`view`,`script`,`equip_script`,`unequip_script`) VALUES ('%u',?,?,'%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u',?,?,?)",map->item_db_re_db, + it->nameid,it->flag.delay_consume?IT_DELAYCONSUME:it->type,it->value_buy,it->value_sell,it->weight,it->atk,it->matk,it->def,it->range,it->slot,(unsigned int)strtoul(str[11+offset],NULL,0),atoi(str[12+offset]),atoi(str[13+offset]),atoi(str[14+offset]),it->wlv,it->elv,it->elvmax,atoi(str[17+offset]),it->look) ) +#else // not RENEWAL + if( SQL_SUCCESS != SQL->StmtPrepare(stmt, "REPLACE INTO `%s` (`id`,`name_english`,`name_japanese`,`type`,`price_buy`,`price_sell`,`weight`,`atk`,`defence`,`range`,`slots`,`equip_jobs`,`equip_upper`,`equip_genders`,`equip_locations`,`weapon_level`,`equip_level`,`refineable`,`view`,`script`,`equip_script`,`unequip_script`) VALUES ('%u',?,?,'%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u',?,?,?)",map->item_db_db, + it->nameid,it->flag.delay_consume?IT_DELAYCONSUME:it->type,it->value_buy,it->value_sell,it->weight,it->atk,it->def,it->range,it->slot,(unsigned int)strtoul(str[11],NULL,0),atoi(str[12]),atoi(str[13]),atoi(str[14]),it->wlv,it->elv,atoi(str[17]),it->look) ) +#endif // RENEWAL SqlStmt_ShowDebug(stmt); else { if ( SQL_SUCCESS != SQL->StmtBindParam(stmt, 0, SQLDT_STRING, it->name, strlen(it->name)) ) @@ -68,9 +68,9 @@ int db2sql(char** str, const char* source, int line, int scriptopt) { if ( SQL_SUCCESS != SQL->StmtBindParam(stmt, 1, SQLDT_STRING, it->jname, strlen(it->jname)) ) SqlStmt_ShowDebug(stmt); else { - #ifdef RENEWAL - if( iMap->db_use_sql_item_db ) offset += 1; - #endif +#ifdef RENEWAL + if( map->db_use_sql_item_db ) offset += 1; +#endif // RENEWAL if( it->script ) trimbraces(str[19+offset]); if ( SQL_SUCCESS != SQL->StmtBindParam(stmt, 2, SQLDT_STRING, it->script?str[19+offset]:"", it->script?strlen(str[19+offset]):0) ) SqlStmt_ShowDebug(stmt); @@ -98,7 +98,7 @@ int db2sql(char** str, const char* source, int line, int scriptopt) { CPCMD(db2sql) { - if( iMap->db_use_sql_item_db ) { + if( map->db_use_sql_item_db ) { ShowInfo("db2sql: this should not be used with 'db_use_sql_item_db' enabled, skipping...\n"); return; } @@ -114,10 +114,10 @@ CPCMD(db2sql) { itemdb->parse_dbrow = db2sql; /* empty table */ #ifdef RENEWAL - if ( SQL_ERROR == SQL->Query(mysql_handle, "DELETE FROM `%s`", iMap->item_db_re_db ) ) -#else - if ( SQL_ERROR == SQL->Query(mysql_handle, "DELETE FROM `%s`", iMap->item_db_db) ) -#endif + if ( SQL_ERROR == SQL->Query(mysql_handle, "DELETE FROM `%s`", map->item_db_re_db ) ) +#else // not RENEWAL + if ( SQL_ERROR == SQL->Query(mysql_handle, "DELETE FROM `%s`", map->item_db_db) ) +#endif // RENEWAL Sql_ShowDebug(mysql_handle); else { itemdb->reload(); @@ -131,7 +131,7 @@ CPCMD(db2sql) { HPExport void plugin_init (void) { SQL = GET_SYMBOL("SQL"); itemdb = GET_SYMBOL("itemdb"); - iMap = GET_SYMBOL("iMap"); + map = GET_SYMBOL("map"); strlib = GET_SYMBOL("strlib"); HPMi->addCPCommand("server:tools:db2sql",CPCMD_A(db2sql)); -- cgit v1.2.3-70-g09d2 From 4a6a25f6675bd11666b235b97d59f5035a249295 Mon Sep 17 00:00:00 2001 From: shennetsind <ind@henn.et> Date: Fri, 27 Sep 2013 12:58:41 -0300 Subject: HPM: Skill.c Completed Moved missing vars and declarations of interest into the interface. Signed-off-by: shennetsind <ind@henn.et> --- src/map/atcommand.c | 12 +- src/map/battle.c | 6 +- src/map/chrif.c | 4 +- src/map/clif.c | 28 +- src/map/elemental.c | 4 +- src/map/map.c | 2 +- src/map/mob.c | 8 +- src/map/pc.c | 52 +-- src/map/skill.c | 1057 +++++++++++++++++++++++++-------------------------- src/map/skill.h | 64 +++- src/map/status.c | 4 +- 11 files changed, 631 insertions(+), 610 deletions(-) (limited to 'src/map/elemental.c') diff --git a/src/map/atcommand.c b/src/map/atcommand.c index f61a4bd45..13fa86591 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -5312,15 +5312,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); } } @@ -5448,7 +5448,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; } diff --git a/src/map/battle.c b/src/map/battle.c index 64ccfd6c6..352ff7bf5 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -343,11 +343,11 @@ int64 battle_attr_fix(struct block_list *src, struct block_list *target, int64 d ratio = 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 ) { diff --git a/src/map/chrif.c b/src/map/chrif.c index cc0797596..be14a08c9 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -1383,8 +1383,8 @@ void chrif_skillid2idx(int 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++; } diff --git a/src/map/clif.c b/src/map/clif.c index 50b3d1339..f248449a5 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -3477,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++; } } @@ -5500,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; @@ -5547,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++; } @@ -16815,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++; } } diff --git a/src/map/elemental.c b/src/map/elemental.c index 09fc6c379..12e8f4c4e 100644 --- a/src/map/elemental.c +++ b/src/map/elemental.c @@ -574,8 +574,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; } diff --git a/src/map/map.c b/src/map/map.c index 935492dbd..346a85c58 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -4336,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; } } diff --git a/src/map/mob.c b/src/map/mob.c index b41f7488f..8e956adc1 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -3351,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++) { @@ -3384,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; @@ -4321,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; } diff --git a/src/map/pc.c b/src/map/pc.c index e88bdb2f1..338459d16 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -1334,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] ) { @@ -1373,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; @@ -1392,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 } @@ -1413,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 @@ -1437,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; } @@ -1476,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) || @@ -1507,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 ) { @@ -1568,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 || @@ -3502,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; } @@ -3525,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. @@ -3559,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? @@ -5083,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; @@ -6191,7 +6191,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. @@ -6238,22 +6238,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)) || @@ -6481,12 +6481,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 ) { diff --git a/src/map/skill.c b/src/map/skill.c index 8e83f8bd2..5c4dddc6f 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; } @@ -470,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; @@ -664,19 +617,19 @@ 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 : 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 } /*========================================== @@ -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 @@ -1784,7 +1735,7 @@ int skill_counter_additional_effect(struct block_list* src, struct block_list *b ) { //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 { clif->skill_nodamage(src,bl,HW_SOULDRAIN,rate,1); @@ -2655,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 = map->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; } @@ -2738,7 +2689,7 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds 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) @@ -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); } @@ -2986,15 +2936,15 @@ int skill_check_condition_mercenary(struct block_list *bl, int skill_id, int lv, // 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; @@ -3128,9 +3078,9 @@ int skill_timerskill(int tid, unsigned int tick, int id, intptr_t data) { 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] = 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; + 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: @@ -3564,7 +3514,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint case TK_STORMKICK: // Taekwon kicks [Dralnu] clif->skill_nodamage(src,bl,skill_id,skill_lv,1); - skill_area_temp[1] = 0; + 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); @@ -3599,7 +3549,7 @@ 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; + 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); @@ -3610,7 +3560,7 @@ 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; + 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); @@ -3749,13 +3699,13 @@ 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); @@ -3783,20 +3733,20 @@ 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] = 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); + 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 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); @@ -3806,7 +3756,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint 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); @@ -3815,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); @@ -3827,12 +3777,12 @@ 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] = 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 + 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; + 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% @@ -3843,18 +3793,18 @@ 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 = 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); + 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++) { 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); @@ -3867,7 +3817,7 @@ 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)) map->foreachinrange(skill->area_sub,bl, skill->get_splash(skill_id, skill_lv),BL_CHAR, @@ -4326,8 +4276,8 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint short x, y; map->search_freecell(src, 0, &x, &y, -1, -1, 0); // Destination area - skill_area_temp[4] = x; - skill_area_temp[5] = y; + 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); @@ -4522,10 +4472,10 @@ 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; + 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, @@ -5084,19 +5034,19 @@ 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); } @@ -5104,7 +5054,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui status->set_sp(src, 0, 0); break; } else if (status->isdead(bl) && flag&1) { //Revive - skill_area_temp[0]++; //Count it in, then fall-through to the Resurrection code. + 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; @@ -5185,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); @@ -5439,7 +5389,7 @@ 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; + 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); @@ -5800,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 } @@ -5847,7 +5797,7 @@ 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); map->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), splash_target(src), @@ -5865,7 +5815,7 @@ 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 = 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); @@ -5910,7 +5860,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case NJ_RAIGEKISAI: case WZ_FROSTNOVA: clif->skill_nodamage(src,bl,skill_id,skill_lv,1); - skill_area_temp[1] = 0; + 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); @@ -6085,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; @@ -6282,7 +6232,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui 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; @@ -6460,13 +6410,13 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui 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); 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); map->freeblock_unlock(); return 1; @@ -6993,14 +6943,14 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case WE_MALE: { - int hp_rate = (!skill_lv)? 0:skill_db[skill_id].hp_rate[skill_lv-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 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); } @@ -7054,15 +7004,15 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui 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( 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); - 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); + 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); } } } @@ -7288,7 +7238,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui 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 ) @@ -7661,7 +7611,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui 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 + skill->area_temp[2] = 0; //For SD_PREAMBLE clif->skill_nodamage(src,bl,skill_id,skill_lv,1); map->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv),BL_CHAR, @@ -7673,7 +7623,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui 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); map->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv),BL_CHAR, @@ -7714,7 +7664,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui 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; + skill->area_temp[2] = 0; clif->skill_nodamage(src,bl,skill_id,skill_lv,1); map->foreachinrange(skill->area_sub, src, skill->get_splash(skill_id,skill_lv),BL_CHAR, @@ -7764,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)); @@ -7782,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; status->change_clear_buffs(bl,4); - skill_area_temp[5] &= ~0x20; + 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( 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 ) @@ -7822,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); @@ -7844,7 +7794,7 @@ 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; + 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. @@ -8468,7 +8418,7 @@ 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; + 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); } @@ -8494,7 +8444,7 @@ 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; 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); @@ -8727,10 +8677,10 @@ 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). + 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); } @@ -8740,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); @@ -9201,12 +9151,12 @@ 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; + 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; @@ -9686,7 +9636,7 @@ 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); map->foreachinarea(skill->area_sub, src->m, x-i, y-i, x+i, y+i, BL_PC, @@ -9968,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; @@ -9998,7 +9948,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui } 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; @@ -11924,7 +11874,7 @@ 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; @@ -13525,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 @@ -13563,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. @@ -13604,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: @@ -13628,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 ) { @@ -13668,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; } @@ -14184,7 +14134,7 @@ void skill_brandishspear(struct block_list* src, struct block_list* bl, uint16 s 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++){ @@ -14576,7 +14526,7 @@ 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 @@ -15096,7 +15046,7 @@ 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); + idb_put(skill->unit_db, su->bl.id, su); map->addiddb(&su->bl); map->addblock(&su->bl); @@ -15192,7 +15142,7 @@ int skill_delunit (struct skill_unit* su) { su->group=NULL; map->delblock(&su->bl); // don't free yet map->deliddb(&su->bl); - idb_remove(skillunit_db, su->bl.id); + 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..."); @@ -15265,7 +15210,7 @@ struct skill_unit_group* skill_initunitgroup (struct block_list* src, int count, 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->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; @@ -15286,7 +15231,7 @@ struct skill_unit_group* skill_initunitgroup (struct block_list* src, int count, 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; } @@ -15403,7 +15348,7 @@ int skill_delunitgroup(struct skill_unit_group *group, const char* file, int lin group->valstr = NULL; } - idb_remove(group_db, group->group_id); + 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; @@ -15721,14 +15666,13 @@ int skill_unit_timer_sub(DBKey key, DBData *data, va_list ap) { int skill_unit_timer(int tid, unsigned int tick, int id, intptr_t data) { 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); 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 /*========================================== * *------------------------------------------*/ @@ -15768,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"); } @@ -15794,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"); } @@ -15836,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)); } 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; @@ -15954,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 @@ -15974,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; } @@ -15997,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; } } @@ -16028,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; @@ -16085,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); @@ -16229,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; @@ -16332,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); @@ -16482,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; } @@ -16494,10 +16438,10 @@ 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); map->addflooritem(&tmp_item,tmp_item.amount,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); @@ -16577,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 )); } } } @@ -16599,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; } @@ -16611,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; @@ -16736,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); @@ -16747,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 ) { @@ -16868,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; @@ -16883,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 } } @@ -16895,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; } } @@ -17104,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; @@ -17119,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; } @@ -17195,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 @@ -17227,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: { @@ -17241,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: @@ -17265,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: { @@ -17275,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: { @@ -17291,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: { @@ -17316,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++; } @@ -17346,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: @@ -17451,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; } @@ -17607,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; } @@ -17650,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; @@ -17677,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; @@ -17732,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; } @@ -17751,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; } @@ -17765,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; } @@ -17808,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; @@ -17829,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; @@ -17852,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; } @@ -17881,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; } @@ -17899,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; } @@ -17910,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; } @@ -17928,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; } @@ -17942,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; } @@ -17956,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; @@ -17981,19 +17927,25 @@ 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(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); @@ -18050,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); @@ -18079,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); @@ -18093,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; @@ -18100,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; @@ -18288,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 eee62dc4a..1609802f9 100644 --- a/src/map/skill.h +++ b/src/map/skill.h @@ -1624,7 +1624,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; @@ -1690,14 +1689,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 { @@ -1705,13 +1702,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 @@ -1735,11 +1730,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 @@ -1751,11 +1766,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 ); @@ -1861,9 +1900,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); @@ -1946,6 +1985,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 9ad1c2205..d8356264c 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -7423,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; @@ -10339,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 ); -- cgit v1.2.3-70-g09d2 From c728c1f7d1ccff7c1a1bcf4b7a4dd4ef15a0b599 Mon Sep 17 00:00:00 2001 From: shennetsind <ind@henn.et> Date: Fri, 27 Sep 2013 18:08:51 -0300 Subject: HPM: Elemental.c Completed Moved missing vars and declarations of interest into the interface, removed duplicate mentions of elemental within calls to shorten wherever it made sense to. And on a minor thing updated the duel.h header given the file had been previously modified (when the duel interface was implemented) Signed-off-by: shennetsind <ind@henn.et> --- src/map/atcommand.c | 2 +- src/map/duel.h | 8 ++--- src/map/elemental.c | 102 ++++++++++++++++++++++++++++++---------------------- src/map/elemental.h | 43 ++++++++++++++++------ src/map/map.c | 4 +-- 5 files changed, 100 insertions(+), 59 deletions(-) (limited to 'src/map/elemental.c') diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 4f784ecc5..cec314134 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -3561,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; 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 12e8f4c4e..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,7 +169,7 @@ 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; @@ -177,7 +179,7 @@ static int elemental_summon_end(int tid, unsigned int tick, int id, intptr_t dat 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,7 +226,7 @@ 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 = map->charid2sd(ele->char_id)) == NULL ) return 0; @@ -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; @@ -259,7 +261,7 @@ int elemental_data_received(struct s_elemental *ele, bool flag) { 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; @@ -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; @@ -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; @@ -713,7 +715,7 @@ static int elemental_ai_sub_timer(struct elemental_data *ed, struct map_session_ target = map->id2bl(ed->ud.target); if( !target ) - map->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) { - map->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; } @@ -765,7 +767,9 @@ int read_elementaldb(void) { struct status_data *estatus; sprintf(line, "%s/%s", map->db_path, "elemental_db.txt"); - memset(elemental->elemental_db,0,sizeof(elemental->elemental_db)); + + 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); @@ -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/map.c b/src/map/map.c index 09defc75a..8641f7011 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -4918,7 +4918,7 @@ void do_final(void) unit->final(); bg->final(); duel->final(); - elemental->do_final_elemental(); + elemental->final(); do_final_maps(); vending->final(); @@ -5393,7 +5393,7 @@ int do_init(int argc, char *argv[]) pet->init(); homun->init(); mercenary->init(); - elemental->do_init_elemental(); + elemental->init(); quest->init(); npc->init(); unit->init(); -- cgit v1.2.3-70-g09d2 From 2f2afbd3b63a75695f8f96e3bcb4db9fff5a7dc6 Mon Sep 17 00:00:00 2001 From: shennetsind <ind@henn.et> Date: Wed, 2 Oct 2013 14:31:46 -0300 Subject: HPM: Map.c Completed Fully Interfaced. Moved missing vars and declarations of interest into the interface, removed duplicate mentions of map within calls to shorten wherever it made sense to. Ladies and Gentleman its my pleasure to announce that with this commit we've revised all of map-server, we've learned a hell lot from this, improved many things on the go and have a number of features to be released thanks to this. *cough* hpm hooking *cough*. Signed-off-by: shennetsind <ind@henn.et> --- src/map/atcommand.c | 302 +++---- src/map/battle.c | 122 +-- src/map/battleground.c | 4 +- src/map/buyingstore.c | 4 +- src/map/chat.c | 2 +- src/map/clif.c | 130 +-- src/map/duel.c | 4 +- src/map/elemental.c | 2 +- src/map/guild.c | 6 +- src/map/instance.c | 184 ++--- src/map/intif.c | 6 +- src/map/itemdb.c | 22 +- src/map/log.c | 53 +- src/map/log.h | 9 + src/map/mail.c | 2 +- src/map/map.c | 2134 ++++++++++++++++++++++++------------------------ src/map/map.h | 194 ++++- src/map/mapreg_sql.c | 36 +- src/map/mob.c | 88 +- src/map/mob.h | 4 +- src/map/npc.c | 518 ++++++------ src/map/party.c | 2 +- src/map/path.c | 12 +- src/map/pc.c | 92 +-- src/map/pet.c | 2 +- src/map/script.c | 425 +++++----- src/map/skill.c | 68 +- src/map/status.c | 38 +- src/map/trade.c | 2 +- src/map/unit.c | 30 +- 30 files changed, 2313 insertions(+), 2184 deletions(-) (limited to 'src/map/elemental.c') diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 5a6068a54..3d04a6bff 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -412,11 +412,11 @@ ACMD(mapmove) { 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)) { + if (map->list[m].flag.nowarpto && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif->message(fd, msg_txt(247)); return false; } - if (sd->bl.m >= 0 && maplist[sd->bl.m].flag.nowarp && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (sd->bl.m >= 0 && map->list[sd->bl.m].flag.nowarp && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif->message(fd, msg_txt(248)); return false; } @@ -476,12 +476,12 @@ ACMD(jumpto) { return false; } - if (pl_sd->bl.m >= 0 && maplist[pl_sd->bl.m].flag.nowarpto && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (pl_sd->bl.m >= 0 && map->list[pl_sd->bl.m].flag.nowarpto && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif->message(fd, msg_txt(247)); // You are not authorized to warp to this map. return false; } - if (sd->bl.m >= 0 && maplist[sd->bl.m].flag.nowarp && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (sd->bl.m >= 0 && map->list[sd->bl.m].flag.nowarp && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif->message(fd, msg_txt(248)); // You are not authorized to warp from your current map. return false; } @@ -511,7 +511,7 @@ ACMD(jump) sscanf(message, "%hd %hd", &x, &y); - if (maplist[sd->bl.m].flag.noteleport && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (map->list[sd->bl.m].flag.noteleport && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif->message(fd, msg_txt(248)); // You are not authorized to warp from your current map. return false; } @@ -626,11 +626,11 @@ ACMD(who) { StrBuf->Printf(&buf, msg_txt(30), count); // %d players found. } else { if (count == 0) - StrBuf->Printf(&buf, msg_txt(54), maplist[map_id].name); // No player found in map '%s'. + StrBuf->Printf(&buf, msg_txt(54), map->list[map_id].name); // No player found in map '%s'. else if (count == 1) - StrBuf->Printf(&buf, msg_txt(55), maplist[map_id].name); // 1 player found in map '%s'. + StrBuf->Printf(&buf, msg_txt(55), map->list[map_id].name); // 1 player found in map '%s'. else - StrBuf->Printf(&buf, msg_txt(56), count, maplist[map_id].name); // %d players found in map '%s'. + StrBuf->Printf(&buf, msg_txt(56), count, map->list[map_id].name); // %d players found in map '%s'. } clif->message(fd, StrBuf->Value(&buf)); StrBuf->Destroy(&buf); @@ -750,11 +750,11 @@ ACMD(load) { nullpo_retr(-1, sd); m = map->mapindex2mapid(sd->status.save_point.map); - if (m >= 0 && maplist[m].flag.nowarpto && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (m >= 0 && map->list[m].flag.nowarpto && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif->message(fd, msg_txt(249)); // You are not authorized to warp to your save map. return false; } - if (sd->bl.m >= 0 && maplist[sd->bl.m].flag.nowarp && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (sd->bl.m >= 0 && map->list[sd->bl.m].flag.nowarp && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif->message(fd, msg_txt(248)); // You are not authorized to warp from your current map. return false; } @@ -893,9 +893,9 @@ ACMD(hide) { clif->message(fd, msg_txt(10)); // Invisible: Off // increment the number of pvp players on the map - maplist[sd->bl.m].users_pvp++; + map->list[sd->bl.m].users_pvp++; - if( maplist[sd->bl.m].flag.pvp && !maplist[sd->bl.m].flag.pvp_nocalcrank ) { + if( map->list[sd->bl.m].flag.pvp && !map->list[sd->bl.m].flag.pvp_nocalcrank ) { // register the player for ranking calculations sd->pvp_timer = timer->add( timer->gettick() + 200, pc->calc_pvprank_timer, sd->bl.id, 0 ); } @@ -907,9 +907,9 @@ ACMD(hide) { clif->message(fd, msg_txt(11)); // Invisible: On // decrement the number of pvp players on the map - maplist[sd->bl.m].users_pvp--; + map->list[sd->bl.m].users_pvp--; - if( maplist[sd->bl.m].flag.pvp && !maplist[sd->bl.m].flag.pvp_nocalcrank && sd->pvp_timer != INVALID_TIMER ) { + if( map->list[sd->bl.m].flag.pvp && !map->list[sd->bl.m].flag.pvp_nocalcrank && sd->pvp_timer != INVALID_TIMER ) { // unregister the player for ranking timer->delete( sd->pvp_timer, pc->calc_pvprank_timer ); sd->pvp_timer = INVALID_TIMER; @@ -1463,13 +1463,13 @@ int atcommand_pvpoff_sub(struct block_list *bl,va_list ap) ACMD(pvpoff) { nullpo_retr(-1, sd); - if (!maplist[sd->bl.m].flag.pvp) { + if (!map->list[sd->bl.m].flag.pvp) { clif->message(fd, msg_txt(160)); // PvP is already Off. return false; } - map->zone_change2(sd->bl.m,maplist[sd->bl.m].prev_zone); - maplist[sd->bl.m].flag.pvp = 0; + map->zone_change2(sd->bl.m,map->list[sd->bl.m].prev_zone); + map->list[sd->bl.m].flag.pvp = 0; if (!battle_config.pk_mode) { clif->map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING); @@ -1501,13 +1501,13 @@ int atcommand_pvpon_sub(struct block_list *bl,va_list ap) ACMD(pvpon) { nullpo_retr(-1, sd); - if (maplist[sd->bl.m].flag.pvp) { + if (map->list[sd->bl.m].flag.pvp) { clif->message(fd, msg_txt(161)); // PvP is already On. return false; } - map->zone_change2(sd->bl.m,strdb_get(zone_db, MAP_ZONE_PVP_NAME)); - maplist[sd->bl.m].flag.pvp = 1; + map->zone_change2(sd->bl.m,strdb_get(map->zone_db, MAP_ZONE_PVP_NAME)); + map->list[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); @@ -1526,13 +1526,13 @@ ACMD(pvpon) { ACMD(gvgoff) { nullpo_retr(-1, sd); - if (!maplist[sd->bl.m].flag.gvg) { + if (!map->list[sd->bl.m].flag.gvg) { clif->message(fd, msg_txt(162)); // GvG is already Off. return false; } - map->zone_change2(sd->bl.m,maplist[sd->bl.m].prev_zone); - maplist[sd->bl.m].flag.gvg = 0; + map->zone_change2(sd->bl.m,map->list[sd->bl.m].prev_zone); + map->list[sd->bl.m].flag.gvg = 0; clif->map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING); clif->maptypeproperty2(&sd->bl,ALL_SAMEMAP); map->foreachinmap(atcommand->stopattack,sd->bl.m, BL_CHAR, 0); @@ -1547,13 +1547,13 @@ ACMD(gvgoff) { ACMD(gvgon) { nullpo_retr(-1, sd); - if (maplist[sd->bl.m].flag.gvg) { + if (map->list[sd->bl.m].flag.gvg) { clif->message(fd, msg_txt(163)); // GvG is already On. return false; } - map->zone_change2(sd->bl.m,strdb_get(zone_db, MAP_ZONE_GVG_NAME)); - maplist[sd->bl.m].flag.gvg = 1; + map->zone_change2(sd->bl.m,strdb_get(map->zone_db, MAP_ZONE_GVG_NAME)); + map->list[sd->bl.m].flag.gvg = 1; clif->map_property_mapall(sd->bl.m, MAPPROPERTY_AGITZONE); clif->maptypeproperty2(&sd->bl,ALL_SAMEMAP); clif->message(fd, msg_txt(34)); // GvG: On. @@ -1845,11 +1845,11 @@ ACMD(go) if (town >= 0 && town < ARRAYLENGTH(data)) { m = map->mapname2mapid(data[town].map); - if (m >= 0 && maplist[m].flag.nowarpto && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (m >= 0 && map->list[m].flag.nowarpto && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif->message(fd, msg_txt(247)); return false; } - if (sd->bl.m >= 0 && maplist[sd->bl.m].flag.nowarp && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (sd->bl.m >= 0 && map->list[sd->bl.m].flag.nowarp && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif->message(fd, msg_txt(248)); return false; } @@ -2192,7 +2192,7 @@ 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, + map->list[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y, 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), @@ -2688,11 +2688,11 @@ ACMD(recall) { return false; } - if (sd->bl.m >= 0 && maplist[sd->bl.m].flag.nowarpto && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (sd->bl.m >= 0 && map->list[sd->bl.m].flag.nowarpto && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif->message(fd, msg_txt(1019)); // You are not authorized to warp someone to this map. return false; } - if (pl_sd->bl.m >= 0 && maplist[pl_sd->bl.m].flag.nowarp && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (pl_sd->bl.m >= 0 && map->list[pl_sd->bl.m].flag.nowarp && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif->message(fd, msg_txt(1020)); // You are not authorized to warp this player from their map. return false; } @@ -3391,7 +3391,7 @@ ACMD(recallall) memset(atcmd_output, '\0', sizeof(atcmd_output)); - if (sd->bl.m >= 0 && maplist[sd->bl.m].flag.nowarpto && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (sd->bl.m >= 0 && map->list[sd->bl.m].flag.nowarpto && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif->message(fd, msg_txt(1032)); // You are not authorized to warp somenone to your current map. return false; } @@ -3402,7 +3402,7 @@ ACMD(recallall) if (sd->status.account_id != pl_sd->status.account_id && pc->get_group_level(sd) >= pc->get_group_level(pl_sd)) { if (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y) continue; // Don't waste time warping the character to the same place. - if (pl_sd->bl.m >= 0 && maplist[pl_sd->bl.m].flag.nowarp && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) + if (pl_sd->bl.m >= 0 && map->list[pl_sd->bl.m].flag.nowarp && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) count++; else { if (pc_isdead(pl_sd)) { //Wake them up @@ -3444,7 +3444,7 @@ ACMD(guildrecall) return false; } - if (sd->bl.m >= 0 && maplist[sd->bl.m].flag.nowarpto && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (sd->bl.m >= 0 && map->list[sd->bl.m].flag.nowarpto && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif->message(fd, msg_txt(1032)); // You are not authorized to warp somenone to your current map. return false; } @@ -3464,7 +3464,7 @@ ACMD(guildrecall) if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.guild_id == g->guild_id) { if (pc->get_group_level(pl_sd) > pc->get_group_level(sd) || (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y)) continue; // Skip GMs greater than you... or chars already on the cell - if (pl_sd->bl.m >= 0 && maplist[pl_sd->bl.m].flag.nowarp && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) + if (pl_sd->bl.m >= 0 && map->list[pl_sd->bl.m].flag.nowarp && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) count++; else pc->setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN); @@ -3502,7 +3502,7 @@ ACMD(partyrecall) return false; } - if (sd->bl.m >= 0 && maplist[sd->bl.m].flag.nowarpto && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (sd->bl.m >= 0 && map->list[sd->bl.m].flag.nowarpto && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif->message(fd, msg_txt(1032)); // You are not authorized to warp somenone to your current map. return false; } @@ -3521,7 +3521,7 @@ ACMD(partyrecall) if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.party_id == p->party.party_id) { if (pc->get_group_level(pl_sd) > pc->get_group_level(sd) || (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y)) continue; // Skip GMs greater than you... or chars already on the cell - if (pl_sd->bl.m >= 0 && maplist[pl_sd->bl.m].flag.nowarp && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) + if (pl_sd->bl.m >= 0 && map->list[pl_sd->bl.m].flag.nowarp && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) count++; else pc->setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN); @@ -3774,129 +3774,129 @@ ACMD(mapinfo) { } mapit->free(iter); - sprintf(atcmd_output, msg_txt(1040), mapname, maplist[m_id].zone->name, maplist[m_id].users, maplist[m_id].npc_num, chat_num, vend_num); // Map: %s (Zone:%s) | Players: %d | NPCs: %d | Chats: %d | Vendings: %d + sprintf(atcmd_output, msg_txt(1040), mapname, map->list[m_id].zone->name, map->list[m_id].users, map->list[m_id].npc_num, chat_num, vend_num); // Map: %s (Zone:%s) | Players: %d | NPCs: %d | Chats: %d | Vendings: %d clif->message(fd, atcmd_output); clif->message(fd, msg_txt(1041)); // ------ Map Flags ------ - if (maplist[m_id].flag.town) + if (map->list[m_id].flag.town) clif->message(fd, msg_txt(1042)); // Town Map - if (battle_config.autotrade_mapflag == maplist[m_id].flag.autotrade) + if (battle_config.autotrade_mapflag == map->list[m_id].flag.autotrade) clif->message(fd, msg_txt(1043)); // Autotrade Enabled else clif->message(fd, msg_txt(1044)); // Autotrade Disabled - if (maplist[m_id].flag.battleground) + if (map->list[m_id].flag.battleground) clif->message(fd, msg_txt(1045)); // Battlegrounds ON strcpy(atcmd_output,msg_txt(1046)); // PvP Flags: - if (maplist[m_id].flag.pvp) + if (map->list[m_id].flag.pvp) strcat(atcmd_output, msg_txt(1047)); // Pvp ON | - if (maplist[m_id].flag.pvp_noguild) + if (map->list[m_id].flag.pvp_noguild) strcat(atcmd_output, msg_txt(1048)); // NoGuild | - if (maplist[m_id].flag.pvp_noparty) + if (map->list[m_id].flag.pvp_noparty) strcat(atcmd_output, msg_txt(1049)); // NoParty | - if (maplist[m_id].flag.pvp_nightmaredrop) + if (map->list[m_id].flag.pvp_nightmaredrop) strcat(atcmd_output, msg_txt(1050)); // NightmareDrop | - if (maplist[m_id].flag.pvp_nocalcrank) + if (map->list[m_id].flag.pvp_nocalcrank) strcat(atcmd_output, msg_txt(1051)); // NoCalcRank | clif->message(fd, atcmd_output); strcpy(atcmd_output,msg_txt(1052)); // GvG Flags: - if (maplist[m_id].flag.gvg) + if (map->list[m_id].flag.gvg) strcat(atcmd_output, msg_txt(1053)); // GvG ON | - if (maplist[m_id].flag.gvg_dungeon) + if (map->list[m_id].flag.gvg_dungeon) strcat(atcmd_output, msg_txt(1054)); // GvG Dungeon | - if (maplist[m_id].flag.gvg_castle) + if (map->list[m_id].flag.gvg_castle) strcat(atcmd_output, msg_txt(1055)); // GvG Castle | - if (maplist[m_id].flag.gvg_noparty) + if (map->list[m_id].flag.gvg_noparty) strcat(atcmd_output, msg_txt(1056)); // NoParty | clif->message(fd, atcmd_output); strcpy(atcmd_output,msg_txt(1057)); // Teleport Flags: - if (maplist[m_id].flag.noteleport) + if (map->list[m_id].flag.noteleport) strcat(atcmd_output, msg_txt(1058)); // NoTeleport | - if (maplist[m_id].flag.monster_noteleport) + if (map->list[m_id].flag.monster_noteleport) strcat(atcmd_output, msg_txt(1059)); // Monster NoTeleport | - if (maplist[m_id].flag.nowarp) + if (map->list[m_id].flag.nowarp) strcat(atcmd_output, msg_txt(1060)); // NoWarp | - if (maplist[m_id].flag.nowarpto) + if (map->list[m_id].flag.nowarpto) strcat(atcmd_output, msg_txt(1061)); // NoWarpTo | - if (maplist[m_id].flag.noreturn) + if (map->list[m_id].flag.noreturn) strcat(atcmd_output, msg_txt(1062)); // NoReturn | - if (maplist[m_id].flag.nomemo) + if (map->list[m_id].flag.nomemo) strcat(atcmd_output, msg_txt(1064)); // NoMemo | clif->message(fd, atcmd_output); sprintf(atcmd_output, msg_txt(1065), // No Exp Penalty: %s | No Zeny Penalty: %s - (maplist[m_id].flag.noexppenalty) ? msg_txt(1066) : msg_txt(1067), - (maplist[m_id].flag.nozenypenalty) ? msg_txt(1066) : msg_txt(1067)); // On / Off + (map->list[m_id].flag.noexppenalty) ? msg_txt(1066) : msg_txt(1067), + (map->list[m_id].flag.nozenypenalty) ? msg_txt(1066) : msg_txt(1067)); // On / Off clif->message(fd, atcmd_output); - if (maplist[m_id].flag.nosave) { - if (!maplist[m_id].save.map) + if (map->list[m_id].flag.nosave) { + if (!map->list[m_id].save.map) clif->message(fd, msg_txt(1068)); // No Save (Return to last Save Point) - else if (maplist[m_id].save.x == -1 || maplist[m_id].save.y == -1 ) { - sprintf(atcmd_output, msg_txt(1069), mapindex_id2name(maplist[m_id].save.map)); // No Save, Save Point: %s,Random + else if (map->list[m_id].save.x == -1 || map->list[m_id].save.y == -1 ) { + sprintf(atcmd_output, msg_txt(1069), mapindex_id2name(map->list[m_id].save.map)); // No Save, Save Point: %s,Random clif->message(fd, atcmd_output); } else { sprintf(atcmd_output, msg_txt(1070), // No Save, Save Point: %s,%d,%d - mapindex_id2name(maplist[m_id].save.map),maplist[m_id].save.x,maplist[m_id].save.y); + mapindex_id2name(map->list[m_id].save.map),map->list[m_id].save.x,map->list[m_id].save.y); clif->message(fd, atcmd_output); } } strcpy(atcmd_output,msg_txt(1071)); // Weather Flags: - if (maplist[m_id].flag.snow) + if (map->list[m_id].flag.snow) strcat(atcmd_output, msg_txt(1072)); // Snow | - if (maplist[m_id].flag.fog) + if (map->list[m_id].flag.fog) strcat(atcmd_output, msg_txt(1073)); // Fog | - if (maplist[m_id].flag.sakura) + if (map->list[m_id].flag.sakura) strcat(atcmd_output, msg_txt(1074)); // Sakura | - if (maplist[m_id].flag.clouds) + if (map->list[m_id].flag.clouds) strcat(atcmd_output, msg_txt(1075)); // Clouds | - if (maplist[m_id].flag.clouds2) + if (map->list[m_id].flag.clouds2) strcat(atcmd_output, msg_txt(1076)); // Clouds2 | - if (maplist[m_id].flag.fireworks) + if (map->list[m_id].flag.fireworks) strcat(atcmd_output, msg_txt(1077)); // Fireworks | - if (maplist[m_id].flag.leaves) + if (map->list[m_id].flag.leaves) strcat(atcmd_output, msg_txt(1078)); // Leaves | - if (maplist[m_id].flag.nightenabled) + if (map->list[m_id].flag.nightenabled) strcat(atcmd_output, msg_txt(1080)); // Displays Night | clif->message(fd, atcmd_output); strcpy(atcmd_output,msg_txt(1081)); // Other Flags: - if (maplist[m_id].flag.nobranch) + if (map->list[m_id].flag.nobranch) strcat(atcmd_output, msg_txt(1082)); // NoBranch | - if (maplist[m_id].flag.notrade) + if (map->list[m_id].flag.notrade) strcat(atcmd_output, msg_txt(1083)); // NoTrade | - if (maplist[m_id].flag.novending) + if (map->list[m_id].flag.novending) strcat(atcmd_output, msg_txt(1084)); // NoVending | - if (maplist[m_id].flag.nodrop) + if (map->list[m_id].flag.nodrop) strcat(atcmd_output, msg_txt(1085)); // NoDrop | - if (maplist[m_id].flag.noskill) + if (map->list[m_id].flag.noskill) strcat(atcmd_output, msg_txt(1086)); // NoSkill | - if (maplist[m_id].flag.noicewall) + if (map->list[m_id].flag.noicewall) strcat(atcmd_output, msg_txt(1087)); // NoIcewall | - if (maplist[m_id].flag.allowks) + if (map->list[m_id].flag.allowks) strcat(atcmd_output, msg_txt(1088)); // AllowKS | - if (maplist[m_id].flag.reset) + if (map->list[m_id].flag.reset) strcat(atcmd_output, msg_txt(1089)); // Reset | clif->message(fd, atcmd_output); strcpy(atcmd_output,msg_txt(1090)); // Other Flags: - if (maplist[m_id].nocommand) + if (map->list[m_id].nocommand) strcat(atcmd_output, msg_txt(1091)); // NoCommand | - if (maplist[m_id].flag.nobaseexp) + if (map->list[m_id].flag.nobaseexp) strcat(atcmd_output, msg_txt(1092)); // NoBaseEXP | - if (maplist[m_id].flag.nojobexp) + if (map->list[m_id].flag.nojobexp) strcat(atcmd_output, msg_txt(1093)); // NoJobEXP | - if (maplist[m_id].flag.nomobloot) + if (map->list[m_id].flag.nomobloot) strcat(atcmd_output, msg_txt(1094)); // NoMobLoot | - if (maplist[m_id].flag.nomvploot) + if (map->list[m_id].flag.nomvploot) strcat(atcmd_output, msg_txt(1095)); // NoMVPLoot | - if (maplist[m_id].flag.partylock) + if (map->list[m_id].flag.partylock) strcat(atcmd_output, msg_txt(1096)); // PartyLock | - if (maplist[m_id].flag.guildlock) + if (map->list[m_id].flag.guildlock) strcat(atcmd_output, msg_txt(1097)); // GuildLock | clif->message(fd, atcmd_output); @@ -3919,8 +3919,8 @@ ACMD(mapinfo) { break; case 2: clif->message(fd, msg_txt(1100)); // ----- NPCs in Map ----- - for (i = 0; i < maplist[m_id].npc_num;) { - nd = maplist[m_id].npc[i]; + for (i = 0; i < map->list[m_id].npc_num;) { + nd = map->list[m_id].npc[i]; switch(nd->dir) { case 0: strcpy(direction, msg_txt(1101)); break; // North case 1: strcpy(direction, msg_txt(1102)); break; // North West @@ -5028,7 +5028,7 @@ ACMD(killable) { *------------------------------------------*/ ACMD(skillon) { nullpo_retr(-1, sd); - maplist[sd->bl.m].flag.noskill = 0; + map->list[sd->bl.m].flag.noskill = 0; clif->message(fd, msg_txt(244)); return true; } @@ -5039,7 +5039,7 @@ ACMD(skillon) { *------------------------------------------*/ ACMD(skilloff) { nullpo_retr(-1, sd); - maplist[sd->bl.m].flag.noskill = 1; + map->list[sd->bl.m].flag.noskill = 1; clif->message(fd, msg_txt(243)); return true; } @@ -5069,8 +5069,8 @@ ACMD(npcmove) { return false; //Not on a map. } - x = cap_value(x, 0, maplist[m].xs-1); - y = cap_value(y, 0, maplist[m].ys-1); + x = cap_value(x, 0, map->list[m].xs-1); + y = cap_value(y, 0, map->list[m].ys-1); 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); @@ -5557,7 +5557,7 @@ ACMD(changelook) ACMD(autotrade) { nullpo_retr(-1, sd); - if( maplist[sd->bl.m].flag.autotrade != battle_config.autotrade_mapflag ) { + if( map->list[sd->bl.m].flag.autotrade != battle_config.autotrade_mapflag ) { clif->message(fd, msg_txt(1179)); // Autotrade is not allowed on this map. return false; } @@ -5599,7 +5599,7 @@ ACMD(changegm) { return false; } - if( maplist[sd->bl.m].flag.guildlock || maplist[sd->bl.m].flag.gvg_castle ) { + if( map->list[sd->bl.m].flag.guildlock || map->list[sd->bl.m].flag.gvg_castle ) { clif->message(fd, msg_txt(1182)); // You cannot change guild leaders on this map. return false; } @@ -5815,12 +5815,12 @@ ACMD(autolootitem) *------------------------------------------*/ //ACMD(rain) { // nullpo_retr(-1, sd); -// if (maplist[sd->bl.m].flag.rain) { -// maplist[sd->bl.m].flag.rain=0; +// if (map->list[sd->bl.m].flag.rain) { +// map->list[sd->bl.m].flag.rain=0; // clif->weather(sd->bl.m); // clif->message(fd, msg_txt(1201)); // The rain has stopped. // } else { -// maplist[sd->bl.m].flag.rain=1; +// map->list[sd->bl.m].flag.rain=1; // clif->weather(sd->bl.m); // clif->message(fd, msg_txt(1202)); // It has started to rain. // } @@ -5832,12 +5832,12 @@ ACMD(autolootitem) *------------------------------------------*/ ACMD(snow) { nullpo_retr(-1, sd); - if (maplist[sd->bl.m].flag.snow) { - maplist[sd->bl.m].flag.snow=0; + if (map->list[sd->bl.m].flag.snow) { + map->list[sd->bl.m].flag.snow=0; clif->weather(sd->bl.m); clif->message(fd, msg_txt(1203)); // Snow has stopped falling. } else { - maplist[sd->bl.m].flag.snow=1; + map->list[sd->bl.m].flag.snow=1; clif->weather(sd->bl.m); clif->message(fd, msg_txt(1204)); // It has started to snow. } @@ -5850,12 +5850,12 @@ ACMD(snow) { *------------------------------------------*/ ACMD(sakura) { nullpo_retr(-1, sd); - if (maplist[sd->bl.m].flag.sakura) { - maplist[sd->bl.m].flag.sakura=0; + if (map->list[sd->bl.m].flag.sakura) { + map->list[sd->bl.m].flag.sakura=0; clif->weather(sd->bl.m); clif->message(fd, msg_txt(1205)); // Cherry tree leaves no longer fall. } else { - maplist[sd->bl.m].flag.sakura=1; + map->list[sd->bl.m].flag.sakura=1; clif->weather(sd->bl.m); clif->message(fd, msg_txt(1206)); // Cherry tree leaves have begun to fall. } @@ -5867,12 +5867,12 @@ ACMD(sakura) { *------------------------------------------*/ ACMD(clouds) { nullpo_retr(-1, sd); - if (maplist[sd->bl.m].flag.clouds) { - maplist[sd->bl.m].flag.clouds=0; + if (map->list[sd->bl.m].flag.clouds) { + map->list[sd->bl.m].flag.clouds=0; clif->weather(sd->bl.m); clif->message(fd, msg_txt(1207)); // The clouds has disappear. } else { - maplist[sd->bl.m].flag.clouds=1; + map->list[sd->bl.m].flag.clouds=1; clif->weather(sd->bl.m); clif->message(fd, msg_txt(1208)); // Clouds appear. } @@ -5885,12 +5885,12 @@ ACMD(clouds) { *------------------------------------------*/ ACMD(clouds2) { nullpo_retr(-1, sd); - if (maplist[sd->bl.m].flag.clouds2) { - maplist[sd->bl.m].flag.clouds2=0; + if (map->list[sd->bl.m].flag.clouds2) { + map->list[sd->bl.m].flag.clouds2=0; clif->weather(sd->bl.m); clif->message(fd, msg_txt(1209)); // The alternative clouds disappear. } else { - maplist[sd->bl.m].flag.clouds2=1; + map->list[sd->bl.m].flag.clouds2=1; clif->weather(sd->bl.m); clif->message(fd, msg_txt(1210)); // Alternative clouds appear. } @@ -5903,12 +5903,12 @@ ACMD(clouds2) { *------------------------------------------*/ ACMD(fog) { nullpo_retr(-1, sd); - if (maplist[sd->bl.m].flag.fog) { - maplist[sd->bl.m].flag.fog=0; + if (map->list[sd->bl.m].flag.fog) { + map->list[sd->bl.m].flag.fog=0; clif->weather(sd->bl.m); clif->message(fd, msg_txt(1211)); // The fog has gone. } else { - maplist[sd->bl.m].flag.fog=1; + map->list[sd->bl.m].flag.fog=1; clif->weather(sd->bl.m); clif->message(fd, msg_txt(1212)); // Fog hangs over. } @@ -5920,12 +5920,12 @@ ACMD(fog) { *------------------------------------------*/ ACMD(leaves) { nullpo_retr(-1, sd); - if (maplist[sd->bl.m].flag.leaves) { - maplist[sd->bl.m].flag.leaves=0; + if (map->list[sd->bl.m].flag.leaves) { + map->list[sd->bl.m].flag.leaves=0; clif->weather(sd->bl.m); clif->message(fd, msg_txt(1213)); // Leaves no longer fall. } else { - maplist[sd->bl.m].flag.leaves=1; + map->list[sd->bl.m].flag.leaves=1; clif->weather(sd->bl.m); clif->message(fd, msg_txt(1214)); // Fallen leaves fall. } @@ -5938,12 +5938,12 @@ ACMD(leaves) { *------------------------------------------*/ ACMD(fireworks) { nullpo_retr(-1, sd); - if (maplist[sd->bl.m].flag.fireworks) { - maplist[sd->bl.m].flag.fireworks=0; + if (map->list[sd->bl.m].flag.fireworks) { + map->list[sd->bl.m].flag.fireworks=0; clif->weather(sd->bl.m); clif->message(fd, msg_txt(1215)); // Fireworks have ended. } else { - maplist[sd->bl.m].flag.fireworks=1; + map->list[sd->bl.m].flag.fireworks=1; clif->weather(sd->bl.m); clif->message(fd, msg_txt(1216)); // Fireworks have launched. } @@ -5959,14 +5959,14 @@ ACMD(clearweather) { /** * No longer available, keeping here just in case it's back someday. [Ind] **/ - //maplist[sd->bl.m].flag.rain=0; - maplist[sd->bl.m].flag.snow=0; - maplist[sd->bl.m].flag.sakura=0; - maplist[sd->bl.m].flag.clouds=0; - maplist[sd->bl.m].flag.clouds2=0; - maplist[sd->bl.m].flag.fog=0; - maplist[sd->bl.m].flag.fireworks=0; - maplist[sd->bl.m].flag.leaves=0; + //map->list[sd->bl.m].flag.rain=0; + map->list[sd->bl.m].flag.snow=0; + map->list[sd->bl.m].flag.sakura=0; + map->list[sd->bl.m].flag.clouds=0; + map->list[sd->bl.m].flag.clouds2=0; + map->list[sd->bl.m].flag.fog=0; + map->list[sd->bl.m].flag.fireworks=0; + map->list[sd->bl.m].flag.leaves=0; clif->weather(sd->bl.m); clif->message(fd, msg_txt(291)); @@ -7238,7 +7238,7 @@ ACMD(whereis) for (i = 0; i < ARRAYLENGTH(monster->spawn) && monster->spawn[i].qty; i++) { 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); + snprintf(atcmd_output, sizeof atcmd_output, "%s (%d)", map->list[j].name, monster->spawn[i].qty); clif->message(fd, atcmd_output); } if (i == 0) @@ -7513,10 +7513,10 @@ ACMD(fakename) * Ragnarok Resources *------------------------------------------*/ ACMD(mapflag) { -#define CHECKFLAG( cmd ) do { if ( maplist[ sd->bl.m ].flag.cmd ) clif->message(sd->fd,#cmd); } while(0) +#define CHECKFLAG( cmd ) do { if ( map->list[ 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; \ + map->list[ sd->bl.m ].flag.cmd = flag; \ sprintf(atcmd_output,"[ @mapflag ] %s flag has been set to %s value = %hd",#cmd,flag?"On":"Off",flag); \ clif->message(sd->fd,atcmd_output); \ return true; \ @@ -7552,20 +7552,20 @@ ACMD(mapflag) { for (i = 0; flag_name[i]; i++) flag_name[i] = TOLOWER(flag_name[i]); //lowercase if ( strcmp( flag_name , "gvg" ) == 0 ) { - if( flag && !maplist[sd->bl.m].flag.gvg ) - map->zone_change2(sd->bl.m,strdb_get(zone_db, MAP_ZONE_GVG_NAME)); - else if ( !flag && maplist[sd->bl.m].flag.gvg ) - map->zone_change2(sd->bl.m,maplist[sd->bl.m].prev_zone); + if( flag && !map->list[sd->bl.m].flag.gvg ) + map->zone_change2(sd->bl.m,strdb_get(map->zone_db, MAP_ZONE_GVG_NAME)); + else if ( !flag && map->list[sd->bl.m].flag.gvg ) + map->zone_change2(sd->bl.m,map->list[sd->bl.m].prev_zone); } else if ( strcmp( flag_name , "pvp" ) == 0 ) { - if( flag && !maplist[sd->bl.m].flag.pvp ) - map->zone_change2(sd->bl.m,strdb_get(zone_db, MAP_ZONE_PVP_NAME)); - else if ( !flag && maplist[sd->bl.m].flag.pvp ) - map->zone_change2(sd->bl.m,maplist[sd->bl.m].prev_zone); + if( flag && !map->list[sd->bl.m].flag.pvp ) + map->zone_change2(sd->bl.m,strdb_get(map->zone_db, MAP_ZONE_PVP_NAME)); + else if ( !flag && map->list[sd->bl.m].flag.pvp ) + map->zone_change2(sd->bl.m,map->list[sd->bl.m].prev_zone); } else if ( strcmp( flag_name , "battleground" ) == 0 ) { - if( flag && !maplist[sd->bl.m].flag.battleground ) - map->zone_change2(sd->bl.m,strdb_get(zone_db, MAP_ZONE_BG_NAME)); - else if ( !flag && maplist[sd->bl.m].flag.battleground ) - map->zone_change2(sd->bl.m,maplist[sd->bl.m].prev_zone); + if( flag && !map->list[sd->bl.m].flag.battleground ) + map->zone_change2(sd->bl.m,strdb_get(map->zone_db, MAP_ZONE_BG_NAME)); + else if ( !flag && map->list[sd->bl.m].flag.battleground ) + map->zone_change2(sd->bl.m,map->list[sd->bl.m].prev_zone); } SETFLAG(autotrade); SETFLAG(allowks); SETFLAG(nomemo); SETFLAG(noteleport); @@ -8004,11 +8004,11 @@ ACMD(ksprotection) ACMD(allowks) { nullpo_retr(-1,sd); - if( maplist[sd->bl.m].flag.allowks ) { - maplist[sd->bl.m].flag.allowks = 0; + if( map->list[sd->bl.m].flag.allowks ) { + map->list[sd->bl.m].flag.allowks = 0; clif->message(fd, msg_txt(1330)); // [ Map K.S Protection Active ] } else { - maplist[sd->bl.m].flag.allowks = 1; + map->list[sd->bl.m].flag.allowks = 1; clif->message(fd, msg_txt(1331)); // [ Map K.S Protection Inactive ] } return true; @@ -8707,11 +8707,11 @@ ACMD(join) { return false; } if( hChSys.local && strcmpi(name + 1, hChSys.local_name) == 0 ) { - if( !maplist[sd->bl.m].channel ) { + if( !map->list[sd->bl.m].channel ) { clif->chsys_mjoin(sd); return true; } else - channel = maplist[sd->bl.m].channel; + channel = map->list[sd->bl.m].channel; } else if( hChSys.ally && sd->status.guild_id && strcmpi(name + 1, hChSys.ally_name) == 0 ) { struct guild *g = sd->guild; if( !g ) return false;/* unlikely, but we wont let it crash anyway. */ @@ -8877,7 +8877,7 @@ ACMD(channel) { bool show_all = pc->has_permission(sd, PC_PERM_HCHSYS_ADMIN) ? true : false; clif->message(fd, msg_txt(1410)); // -- Public Channels if( hChSys.local ) { - sprintf(atcmd_output, msg_txt(1409), hChSys.local_name, maplist[sd->bl.m].channel ? db_size(maplist[sd->bl.m].channel->users) : 0);// - #%s ( %d users ) + sprintf(atcmd_output, msg_txt(1409), hChSys.local_name, map->list[sd->bl.m].channel ? db_size(map->list[sd->bl.m].channel->users) : 0);// - #%s ( %d users ) clif->message(fd, atcmd_output); } if( hChSys.ally && sd->status.guild_id ) { @@ -9815,7 +9815,7 @@ bool is_atcommand(const int fd, struct map_session_data* sd, const char* message // 1 = player invoked if ( type == 1) { //Commands are disabled on maps flagged as 'nocommand' - if ( maplist[sd->bl.m].nocommand && pc->get_group_level(sd) < maplist[sd->bl.m].nocommand ) { + if ( map->list[sd->bl.m].nocommand && pc->get_group_level(sd) < map->list[sd->bl.m].nocommand ) { clif->message(fd, msg_txt(143)); return false; } @@ -9938,9 +9938,9 @@ bool is_atcommand(const int fd, struct map_session_data* sd, const char* message clif->message(fd, msg_txt(1393)); // You can't use commands while dead return true; } - for(i = 0; i < maplist[sd->bl.m].zone->disabled_commands_count; i++) { - if( info->func == maplist[sd->bl.m].zone->disabled_commands[i]->cmd ) { - if( pc->get_group_level(sd) < maplist[sd->bl.m].zone->disabled_commands[i]->group_lv ) { + for(i = 0; i < map->list[sd->bl.m].zone->disabled_commands_count; i++) { + if( info->func == map->list[sd->bl.m].zone->disabled_commands[i]->cmd ) { + if( pc->get_group_level(sd) < map->list[sd->bl.m].zone->disabled_commands[i]->group_lv ) { clif->colormes(sd->fd,COLOR_RED,"This command is disabled in this area"); return true; } else diff --git a/src/map/battle.c b/src/map/battle.c index 237a4091d..6e6e7eab5 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -3003,16 +3003,16 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam default: if (flag & BF_SKILL) { //Skills get a different reduction than non-skills. [Skotlex] if (flag&BF_WEAPON) - damage = damage * maplist[bl->m].weapon_damage_rate / 100; + damage = damage * map->list[bl->m].weapon_damage_rate / 100; if (flag&BF_MAGIC) - damage = damage * maplist[bl->m].magic_damage_rate / 100; + damage = damage * map->list[bl->m].magic_damage_rate / 100; if (flag&BF_MISC) - damage = damage * maplist[bl->m].misc_damage_rate / 100; + damage = damage * map->list[bl->m].misc_damage_rate / 100; } else { //Normal attacks get reductions based on range. if (flag & BF_SHORT) - damage = damage * maplist[bl->m].short_damage_rate / 100; + damage = damage * map->list[bl->m].short_damage_rate / 100; if (flag & BF_LONG) - damage = damage * maplist[bl->m].long_damage_rate / 100; + damage = damage * map->list[bl->m].long_damage_rate / 100; } if(!damage) damage = 1; break; @@ -3178,12 +3178,12 @@ int battle_range_type(struct block_list *src, struct block_list *target, uint16 return BF_LONG; } int battle_adjust_skill_damage(int m, unsigned short skill_id) { - if( maplist[m].skill_count ) { + if( map->list[m].skill_count ) { int i; - ARR_FIND(0, maplist[m].skill_count, i, maplist[m].skills[i]->skill_id == skill_id ); + ARR_FIND(0, map->list[m].skill_count, i, map->list[m].skills[i]->skill_id == skill_id ); - if( i < maplist[m].skill_count ) { - return maplist[m].skills[i]->modifier; + if( i < map->list[m].skill_count ) { + return map->list[m].skills[i]->modifier; } } @@ -3402,18 +3402,18 @@ struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list } #ifndef HMAP_ZONE_DAMAGE_CAP_TYPE if( target && skill_id ) { - for(i = 0; i < maplist[target->m].zone->capped_skills_count; i++) { - if( skill_id == maplist[target->m].zone->capped_skills[i]->nameid && (maplist[target->m].zone->capped_skills[i]->type & target->type) ) { - if( target->type == BL_MOB && maplist[target->m].zone->capped_skills[i]->subtype != MZS_NONE ) { - if( (((TBL_MOB*)target)->status.mode&MD_BOSS) && !(maplist[target->m].zone->disabled_skills[i]->subtype&MZS_BOSS) ) + for(i = 0; i < map->list[target->m].zone->capped_skills_count; i++) { + if( skill_id == map->list[target->m].zone->capped_skills[i]->nameid && (map->list[target->m].zone->capped_skills[i]->type & target->type) ) { + if( target->type == BL_MOB && map->list[target->m].zone->capped_skills[i]->subtype != MZS_NONE ) { + if( (((TBL_MOB*)target)->status.mode&MD_BOSS) && !(map->list[target->m].zone->disabled_skills[i]->subtype&MZS_BOSS) ) continue; - if( ((TBL_MOB*)target)->special_state.clone && !(maplist[target->m].zone->disabled_skills[i]->subtype&MZS_CLONE) ) + if( ((TBL_MOB*)target)->special_state.clone && !(map->list[target->m].zone->disabled_skills[i]->subtype&MZS_CLONE) ) continue; } - if( ad.damage > maplist[target->m].zone->capped_skills[i]->cap ) - ad.damage = maplist[target->m].zone->capped_skills[i]->cap; - if( ad.damage2 > maplist[target->m].zone->capped_skills[i]->cap ) - ad.damage2 = maplist[target->m].zone->capped_skills[i]->cap; + if( ad.damage > map->list[target->m].zone->capped_skills[i]->cap ) + ad.damage = map->list[target->m].zone->capped_skills[i]->cap; + if( ad.damage2 > map->list[target->m].zone->capped_skills[i]->cap ) + ad.damage2 = map->list[target->m].zone->capped_skills[i]->cap; break; } } @@ -3498,7 +3498,7 @@ struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list ad.damage=battle->calc_damage(src,target,&ad,ad.damage,skill_id,skill_lv); if( map_flag_gvg2(target->m) ) ad.damage=battle->calc_gvg_damage(src,target,ad.damage,ad.div_,skill_id,skill_lv,ad.flag); - else if( maplist[target->m].flag.battleground ) + else if( map->list[target->m].flag.battleground ) ad.damage=battle->calc_bg_damage(src,target,ad.damage,ad.div_,skill_id,skill_lv,ad.flag); switch( skill_id ) { /* post-calc modifiers */ @@ -3844,18 +3844,18 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list * } #ifndef HMAP_ZONE_DAMAGE_CAP_TYPE if( target && skill_id ) { - for(i = 0; i < maplist[target->m].zone->capped_skills_count; i++) { - if( skill_id == maplist[target->m].zone->capped_skills[i]->nameid && (maplist[target->m].zone->capped_skills[i]->type & target->type) ) { - if( target->type == BL_MOB && maplist[target->m].zone->capped_skills[i]->subtype != MZS_NONE ) { - if( (((TBL_MOB*)target)->status.mode&MD_BOSS) && !(maplist[target->m].zone->disabled_skills[i]->subtype&MZS_BOSS) ) + for(i = 0; i < map->list[target->m].zone->capped_skills_count; i++) { + if( skill_id == map->list[target->m].zone->capped_skills[i]->nameid && (map->list[target->m].zone->capped_skills[i]->type & target->type) ) { + if( target->type == BL_MOB && map->list[target->m].zone->capped_skills[i]->subtype != MZS_NONE ) { + if( (((TBL_MOB*)target)->status.mode&MD_BOSS) && !(map->list[target->m].zone->disabled_skills[i]->subtype&MZS_BOSS) ) continue; - if( ((TBL_MOB*)target)->special_state.clone && !(maplist[target->m].zone->disabled_skills[i]->subtype&MZS_CLONE) ) + if( ((TBL_MOB*)target)->special_state.clone && !(map->list[target->m].zone->disabled_skills[i]->subtype&MZS_CLONE) ) continue; } - if( md.damage > maplist[target->m].zone->capped_skills[i]->cap ) - md.damage = maplist[target->m].zone->capped_skills[i]->cap; - if( md.damage2 > maplist[target->m].zone->capped_skills[i]->cap ) - md.damage2 = maplist[target->m].zone->capped_skills[i]->cap; + if( md.damage > map->list[target->m].zone->capped_skills[i]->cap ) + md.damage = map->list[target->m].zone->capped_skills[i]->cap; + if( md.damage2 > map->list[target->m].zone->capped_skills[i]->cap ) + md.damage2 = map->list[target->m].zone->capped_skills[i]->cap; break; } } @@ -3896,7 +3896,7 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list * md.damage=battle->calc_damage(src,target,&md,md.damage,skill_id,skill_lv); if( map_flag_gvg2(target->m) ) md.damage=battle->calc_gvg_damage(src,target,md.damage,md.div_,skill_id,skill_lv,md.flag); - else if( maplist[target->m].flag.battleground ) + else if( map->list[target->m].flag.battleground ) md.damage=battle->calc_bg_damage(src,target,md.damage,md.div_,skill_id,skill_lv,md.flag); switch( skill_id ) { @@ -4859,18 +4859,18 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list return wd; //Enough, rest is not needed. #ifndef HMAP_ZONE_DAMAGE_CAP_TYPE if( target && skill_id ) { - for(i = 0; i < maplist[target->m].zone->capped_skills_count; i++) { - if( skill_id == maplist[target->m].zone->capped_skills[i]->nameid && (maplist[target->m].zone->capped_skills[i]->type & target->type) ) { - if( target->type == BL_MOB && maplist[target->m].zone->capped_skills[i]->subtype != MZS_NONE ) { - if( (((TBL_MOB*)target)->status.mode&MD_BOSS) && !(maplist[target->m].zone->disabled_skills[i]->subtype&MZS_BOSS) ) + for(i = 0; i < map->list[target->m].zone->capped_skills_count; i++) { + if( skill_id == map->list[target->m].zone->capped_skills[i]->nameid && (map->list[target->m].zone->capped_skills[i]->type & target->type) ) { + if( target->type == BL_MOB && map->list[target->m].zone->capped_skills[i]->subtype != MZS_NONE ) { + if( (((TBL_MOB*)target)->status.mode&MD_BOSS) && !(map->list[target->m].zone->disabled_skills[i]->subtype&MZS_BOSS) ) continue; - if( ((TBL_MOB*)target)->special_state.clone && !(maplist[target->m].zone->disabled_skills[i]->subtype&MZS_CLONE) ) + if( ((TBL_MOB*)target)->special_state.clone && !(map->list[target->m].zone->disabled_skills[i]->subtype&MZS_CLONE) ) continue; } - if( wd.damage > maplist[target->m].zone->capped_skills[i]->cap ) - wd.damage = maplist[target->m].zone->capped_skills[i]->cap; - if( wd.damage2 > maplist[target->m].zone->capped_skills[i]->cap ) - wd.damage2 = maplist[target->m].zone->capped_skills[i]->cap; + if( wd.damage > map->list[target->m].zone->capped_skills[i]->cap ) + wd.damage = map->list[target->m].zone->capped_skills[i]->cap; + if( wd.damage2 > map->list[target->m].zone->capped_skills[i]->cap ) + wd.damage2 = map->list[target->m].zone->capped_skills[i]->cap; break; } } @@ -5047,13 +5047,13 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list wd.damage = battle->calc_damage(src,target,&wd,wd.damage,skill_id,skill_lv); if( map_flag_gvg2(target->m) ) wd.damage=battle->calc_gvg_damage(src,target,wd.damage,wd.div_,skill_id,skill_lv,wd.flag); - else if( maplist[target->m].flag.battleground ) + else if( map->list[target->m].flag.battleground ) wd.damage=battle->calc_bg_damage(src,target,wd.damage,wd.div_,skill_id,skill_lv,wd.flag); } else if(!wd.damage) { wd.damage2 = battle->calc_damage(src,target,&wd,wd.damage2,skill_id,skill_lv); if( map_flag_gvg2(target->m) ) wd.damage2 = battle->calc_gvg_damage(src,target,wd.damage2,wd.div_,skill_id,skill_lv,wd.flag); - else if( maplist[target->m].flag.battleground ) + else if( map->list[target->m].flag.battleground ) wd.damage = battle->calc_bg_damage(src,target,wd.damage2,wd.div_,skill_id,skill_lv,wd.flag); } else { #ifdef RENEWAL @@ -5065,7 +5065,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list #endif if( map_flag_gvg2(target->m) ) wd.damage = battle->calc_gvg_damage(src,target,wd.damage,wd.div_,skill_id,skill_lv,wd.flag); - else if( maplist[target->m].flag.battleground ) + else if( map->list[target->m].flag.battleground ) wd.damage = battle->calc_bg_damage(src,target,wd.damage,wd.div_,skill_id,skill_lv,wd.flag); #ifndef RENEWAL wd.damage2 = d2*100/d1 * wd.damage/100; @@ -5118,18 +5118,18 @@ struct Damage battle_calc_attack(int attack_type,struct block_list *bl,struct bl #ifdef HMAP_ZONE_DAMAGE_CAP_TYPE if( target && skill_id ) { int i; - for(i = 0; i < maplist[target->m].zone->capped_skills_count; i++) { - if( skill_id == maplist[target->m].zone->capped_skills[i]->nameid && (maplist[target->m].zone->capped_skills[i]->type & target->type) ) { - if( target->type == BL_MOB && maplist[target->m].zone->capped_skills[i]->subtype != MZS_NONE ) { - if( (((TBL_MOB*)target)->status.mode&MD_BOSS) && !(maplist[target->m].zone->disabled_skills[i]->subtype&MZS_BOSS) ) + for(i = 0; i < map->list[target->m].zone->capped_skills_count; i++) { + if( skill_id == map->list[target->m].zone->capped_skills[i]->nameid && (map->list[target->m].zone->capped_skills[i]->type & target->type) ) { + if( target->type == BL_MOB && map->list[target->m].zone->capped_skills[i]->subtype != MZS_NONE ) { + if( (((TBL_MOB*)target)->status.mode&MD_BOSS) && !(map->list[target->m].zone->disabled_skills[i]->subtype&MZS_BOSS) ) continue; - if( ((TBL_MOB*)target)->special_state.clone && !(maplist[target->m].zone->disabled_skills[i]->subtype&MZS_CLONE) ) + if( ((TBL_MOB*)target)->special_state.clone && !(map->list[target->m].zone->disabled_skills[i]->subtype&MZS_CLONE) ) continue; } - if( d.damage > maplist[target->m].zone->capped_skills[i]->cap ) - d.damage = maplist[target->m].zone->capped_skills[i]->cap; - if( d.damage2 > maplist[target->m].zone->capped_skills[i]->cap ) - d.damage2 = maplist[target->m].zone->capped_skills[i]->cap; + if( d.damage > map->list[target->m].zone->capped_skills[i]->cap ) + d.damage = map->list[target->m].zone->capped_skills[i]->cap; + if( d.damage2 > map->list[target->m].zone->capped_skills[i]->cap ) + d.damage2 = map->list[target->m].zone->capped_skills[i]->cap; break; } } @@ -5801,7 +5801,7 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f switch( battle->get_current_skill(src) ) { case RK_DRAGONBREATH:// it can only hit traps in pvp/gvg maps case RK_DRAGONBREATH_WATER: - if( !maplist[m].flag.pvp && !maplist[m].flag.gvg ) + if( !map->list[m].flag.pvp && !map->list[m].flag.gvg ) break; case 0://you can hit them without skills case MA_REMOVETRAP: @@ -5886,7 +5886,7 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f { struct mob_data *md = BL_CAST(BL_MOB, t_bl); - if( !((map->agit_flag || map->agit2_flag) && maplist[m].flag.gvg_castle) && md->guardian_data && md->guardian_data->guild_id ) + if( !((map->agit_flag || map->agit2_flag) && map->list[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; } @@ -5929,7 +5929,7 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f state |= BCT_ENEMY; // Can kill anything strip_enemy = 0; } else if( sd->duel_group - && !((!battle_config.duel_allow_pvp && maplist[m].flag.pvp) || (!battle_config.duel_allow_gvg && map_flag_gvg(m))) + && !((!battle_config.duel_allow_pvp && map->list[m].flag.pvp) || (!battle_config.duel_allow_gvg && map_flag_gvg(m))) ) { if( t_bl->type == BL_PC && (sd->duel_group == ((TBL_PC*)t_bl)->duel_group) ) return (BCT_ENEMY&flag)?1:-1; // Duel targets can ONLY be your enemy, nothing else. @@ -5946,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( !((map->agit_flag || map->agit2_flag) && maplist[m].flag.gvg_castle) && md->guardian_data && md->guardian_data->guild_id ) + if( !((map->agit_flag || map->agit2_flag) && map->list[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 ) @@ -5994,16 +5994,16 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f if( map_flag_vs(m) ) { //Check rivalry settings. int sbg_id = 0, tbg_id = 0; - if( maplist[m].flag.battleground ) { + if( map->list[m].flag.battleground ) { sbg_id = bg->team_get_id(s_bl); tbg_id = bg->team_get_id(t_bl); } if( flag&(BCT_PARTY|BCT_ENEMY) ) { 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) ) + && !(map->list[m].flag.pvp && map->list[m].flag.pvp_noparty) + && !(map_flag_gvg(m) && map->list[m].flag.gvg_noparty) + && (!map->list[m].flag.battleground || sbg_id == tbg_id) ) state |= BCT_PARTY; else state |= BCT_ENEMY; @@ -6011,15 +6011,15 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f if( flag&(BCT_GUILD|BCT_ENEMY) ) { 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) + if( !(map->list[m].flag.pvp && map->list[m].flag.pvp_noguild) && s_guild && t_guild && (s_guild == t_guild || (!(flag&BCT_SAMEGUILD) && guild->isallied(s_guild, t_guild))) - && (!maplist[m].flag.battleground || sbg_id == tbg_id) ) + && (!map->list[m].flag.battleground || sbg_id == tbg_id) ) state |= BCT_GUILD; else state |= BCT_ENEMY; } - if( state&BCT_ENEMY && maplist[m].flag.battleground && sbg_id && sbg_id == tbg_id ) + if( state&BCT_ENEMY && map->list[m].flag.battleground && sbg_id && sbg_id == tbg_id ) state &= ~BCT_ENEMY; if( state&BCT_ENEMY && battle_config.pk_mode && !map_flag_gvg(m) && s_bl->type == BL_PC && t_bl->type == BL_PC ) diff --git a/src/map/battleground.c b/src/map/battleground.c index 160d2f96e..e7fe4085b 100644 --- a/src/map/battleground.c +++ b/src/map/battleground.c @@ -91,8 +91,8 @@ int bg_team_join(int bg_id, struct map_session_data *sd) { bgd->members[i].x = sd->bl.x; bgd->members[i].y = sd->bl.y; /* populate 'where i came from' */ - if(maplist[sd->bl.m].flag.nosave || maplist[sd->bl.m].instance_id >= 0) { - struct map_data *m=&maplist[sd->bl.m]; + if(map->list[sd->bl.m].flag.nosave || map->list[sd->bl.m].instance_id >= 0) { + struct map_data *m=&map->list[sd->bl.m]; if(m->save.map) memcpy(&bgd->members[i].source,&m->save,sizeof(struct point)); else diff --git a/src/map/buyingstore.c b/src/map/buyingstore.c index 92bf9b869..2a9e6a88e 100644 --- a/src/map/buyingstore.c +++ b/src/map/buyingstore.c @@ -34,7 +34,7 @@ bool buyingstore_setup(struct map_session_data* sd, unsigned char slots) return false; } - if( maplist[sd->bl.m].flag.novending ) { + if( map->list[sd->bl.m].flag.novending ) { // custom: no vending maps clif->message(sd->fd, msg_txt(276)); // "You can't open a shop on this map" return false; @@ -89,7 +89,7 @@ void buyingstore_create(struct map_session_data* sd, int zenylimit, unsigned cha return; } - if( maplist[sd->bl.m].flag.novending ) { + if( map->list[sd->bl.m].flag.novending ) { // custom: no vending maps clif->message(sd->fd, msg_txt(276)); // "You can't open a shop on this map" return; diff --git a/src/map/chat.c b/src/map/chat.c index d6fad4d94..187d40337 100644 --- a/src/map/chat.c +++ b/src/map/chat.c @@ -80,7 +80,7 @@ int chat_createpcchat(struct map_session_data* sd, const char* title, const char return 0; } - if( maplist[sd->bl.m].flag.nochat ) { + if( map->list[sd->bl.m].flag.nochat ) { clif->message(sd->fd, msg_txt(281)); return 0; //Can't create chatrooms on this map. } diff --git a/src/map/clif.c b/src/map/clif.c index 11cce1a2d..f6c2ef4d0 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -1251,22 +1251,22 @@ void clif_weather_check(struct map_session_data *sd) { int16 m = sd->bl.m; int fd = sd->fd; - if (maplist[m].flag.snow) + if (map->list[m].flag.snow) clif->specialeffect_single(&sd->bl, 162, fd); - if (maplist[m].flag.clouds) + if (map->list[m].flag.clouds) clif->specialeffect_single(&sd->bl, 233, fd); - if (maplist[m].flag.clouds2) + if (map->list[m].flag.clouds2) clif->specialeffect_single(&sd->bl, 516, fd); - if (maplist[m].flag.fog) + if (map->list[m].flag.fog) clif->specialeffect_single(&sd->bl, 515, fd); - if (maplist[m].flag.fireworks) { + if (map->list[m].flag.fireworks) { clif->specialeffect_single(&sd->bl, 297, fd); clif->specialeffect_single(&sd->bl, 299, fd); clif->specialeffect_single(&sd->bl, 301, fd); } - if (maplist[m].flag.sakura) + if (map->list[m].flag.sakura) clif->specialeffect_single(&sd->bl, 163, fd); - if (maplist[m].flag.leaves) + if (map->list[m].flag.leaves) clif->specialeffect_single(&sd->bl, 333, fd); } /** @@ -1319,7 +1319,7 @@ int clif_spawn(struct block_list *bl) clif->specialeffect(bl,423,AREA); else if(sd->state.size==SZ_MEDIUM) clif->specialeffect(bl,421,AREA); - if( sd->bg_id && maplist[sd->bl.m].flag.battleground ) + if( sd->bg_id && map->list[sd->bl.m].flag.battleground ) clif->sendbgemblem_area(sd); for( i = 0; i < sd->sc_display_count; i++ ) { clif->sc_load(&sd->bl, sd->bl.id,AREA,status->IconChangeTable[sd->sc_display[i]->type],sd->sc_display[i]->val1,sd->sc_display[i]->val2,sd->sc_display[i]->val3); @@ -1638,7 +1638,7 @@ void clif_changemap(struct map_session_data *sd, short m, int x, int y) { WFIFOHEAD(fd,packet_len(0x91)); WFIFOW(fd,0) = 0x91; - mapindex_getmapname_ext(maplist[m].custom_name ? maplist[maplist[m].instance_src_map].name : maplist[m].name, (char*)WFIFOP(fd,2)); + mapindex_getmapname_ext(map->list[m].custom_name ? map->list[map->list[m].instance_src_map].name : map->list[m].name, (char*)WFIFOP(fd,2)); WFIFOW(fd,18) = x; WFIFOW(fd,20) = y; WFIFOSET(fd,packet_len(0x91)); @@ -4332,7 +4332,7 @@ void clif_getareachar_unit(struct map_session_data* sd,struct block_list *bl) { clif->specialeffect_single(bl,423,sd->fd); else if(tsd->state.size==SZ_MEDIUM) clif->specialeffect_single(bl,421,sd->fd); - if( tsd->bg_id && maplist[tsd->bl.m].flag.battleground ) + if( tsd->bg_id && map->list[tsd->bl.m].flag.battleground ) clif->sendbgemblem_single(sd->fd,tsd); if ( tsd->status.robe ) clif->refreshlook(&sd->bl,bl->id,LOOK_ROBE,tsd->status.robe,SELF); @@ -4574,7 +4574,7 @@ void clif_changemapcell(int fd, int16 m, int x, int y, int type, enum send_targe WBUFW(buf,2) = x; WBUFW(buf,4) = y; WBUFW(buf,6) = type; - mapindex_getmapname_ext(maplist[m].custom_name ? maplist[maplist[m].instance_src_map].name : maplist[m].name,(char*)WBUFP(buf,8)); + mapindex_getmapname_ext(map->list[m].custom_name ? map->list[map->list[m].instance_src_map].name : map->list[m].name,(char*)WBUFP(buf,8)); if( fd ) { WFIFOHEAD(fd,packet_len(0x192)); @@ -6525,7 +6525,7 @@ void clif_party_member_info(struct party_data *p, struct map_session_data *sd) WBUFB(buf,14) = (p->party.member[i].online)?0:1; memcpy(WBUFP(buf,15), p->party.name, NAME_LENGTH); memcpy(WBUFP(buf,39), sd->status.name, NAME_LENGTH); - mapindex_getmapname_ext(maplist[sd->bl.m].custom_name ? maplist[maplist[sd->bl.m].instance_src_map].name : maplist[sd->bl.m].name, (char*)WBUFP(buf,63)); + mapindex_getmapname_ext(map->list[sd->bl.m].custom_name ? map->list[map->list[sd->bl.m].instance_src_map].name : map->list[sd->bl.m].name, (char*)WBUFP(buf,63)); WBUFB(buf,79) = (p->party.item&1)?1:0; WBUFB(buf,80) = (p->party.item&2)?1:0; clif->send(buf,packet_len(0x1e9),&sd->bl,PARTY); @@ -9286,24 +9286,24 @@ void clif_parse_WantToConnection(int fd, struct map_session_data* sd) { chrif->authreq(sd); } void clif_hercules_chsys_mjoin(struct map_session_data *sd) { - if( !maplist[sd->bl.m].channel ) { - CREATE(maplist[sd->bl.m].channel, struct hChSysCh , 1); - safestrncpy(maplist[sd->bl.m].channel->name, hChSys.local_name, HCHSYS_NAME_LENGTH); - maplist[sd->bl.m].channel->type = hChSys_MAP; - maplist[sd->bl.m].channel->m = sd->bl.m; + if( !map->list[sd->bl.m].channel ) { + CREATE(map->list[sd->bl.m].channel, struct hChSysCh , 1); + safestrncpy(map->list[sd->bl.m].channel->name, hChSys.local_name, HCHSYS_NAME_LENGTH); + map->list[sd->bl.m].channel->type = hChSys_MAP; + map->list[sd->bl.m].channel->m = sd->bl.m; - clif->chsys_create(maplist[sd->bl.m].channel,NULL,NULL,hChSys.local_color); + clif->chsys_create(map->list[sd->bl.m].channel,NULL,NULL,hChSys.local_color); } - if( maplist[sd->bl.m].channel->banned && idb_exists(maplist[sd->bl.m].channel->banned, sd->status.account_id) ) { + if( map->list[sd->bl.m].channel->banned && idb_exists(map->list[sd->bl.m].channel->banned, sd->status.account_id) ) { return; } - clif->chsys_join(maplist[sd->bl.m].channel,sd); + clif->chsys_join(map->list[sd->bl.m].channel,sd); - if( !( maplist[sd->bl.m].channel->opt & hChSys_OPT_ANNOUNCE_JOIN ) ) { + if( !( map->list[sd->bl.m].channel->opt & hChSys_OPT_ANNOUNCE_JOIN ) ) { char mout[60]; - sprintf(mout, msg_txt(1435),hChSys.local_name,maplist[sd->bl.m].name); // You're now in the '#%s' channel for '%s' + sprintf(mout, msg_txt(1435),hChSys.local_name,map->list[sd->bl.m].name); // You're now in the '#%s' channel for '%s' clif->colormes(sd->fd, COLOR_DEFAULT, mout); } } @@ -9362,14 +9362,14 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { pc->setinvincibletimer(sd,battle_config.pc_invincible_time); } - if( maplist[sd->bl.m].users++ == 0 && battle_config.dynamic_mobs ) + if( map->list[sd->bl.m].users++ == 0 && battle_config.dynamic_mobs ) 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++; + map->list[sd->bl.m].users_pvp++; } - if( maplist[sd->bl.m].instance_id >= 0 ) { - instance->list[maplist[sd->bl.m].instance_id].users++; - instance->check_idle(maplist[sd->bl.m].instance_id); + if( map->list[sd->bl.m].instance_id >= 0 ) { + instance->list[map->list[sd->bl.m].instance_id].users++; + instance->check_idle(map->list[sd->bl.m].instance_id); } sd->state.debug_remove_map = 0; // temporary state to track double remove_map's [FlavioJS] @@ -9388,9 +9388,9 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { if( sd->bg_id ) clif->bg_hp(sd); // BattleGround System - if(maplist[sd->bl.m].flag.pvp && !(sd->sc.option&OPTION_INVISIBLE)) { + if(map->list[sd->bl.m].flag.pvp && !(sd->sc.option&OPTION_INVISIBLE)) { if(!battle_config.pk_mode) { // remove pvp stuff for pk_mode [Valaris] - if (!maplist[sd->bl.m].flag.pvp_nocalcrank) + if (!map->list[sd->bl.m].flag.pvp_nocalcrank) sd->pvp_timer = timer->add(timer->gettick()+200, pc->calc_pvprank_timer, sd->bl.id, 0); sd->pvp_rank = 0; sd->pvp_lastusers = 0; @@ -9404,7 +9404,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { if(sd->duel_group) clif->map_property(sd, MAPPROPERTY_FREEPVPZONE); - if (maplist[sd->bl.m].flag.gvg_dungeon) + if (map->list[sd->bl.m].flag.gvg_dungeon) clif->map_property(sd, MAPPROPERTY_FREEPVPZONE); //TODO: Figure out the real packet to send here. if( map_flag_gvg2(sd->bl.m) ) @@ -9496,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 (map->night_flag && maplist[sd->bl.m].flag.nightenabled) { + if (map->night_flag && map->list[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]. - map->map_foreachpc(clif->friendslist_toggle_sub, sd->status.account_id, sd->status.char_id, 1); + map->foreachpc(clif->friendslist_toggle_sub, sd->status.account_id, sd->status.char_id, 1); //Login Event npc->script_event(sd, NPCE_LOGIN); @@ -9534,10 +9534,10 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { #endif if( (battle_config.bg_flee_penalty != 100 || battle_config.gvg_flee_penalty != 100) && (map_flag_gvg2(sd->state.pmap) || map_flag_gvg2(sd->bl.m) - || maplist[sd->state.pmap].flag.battleground || maplist[sd->bl.m].flag.battleground) ) + || map->list[sd->state.pmap].flag.battleground || map->list[sd->bl.m].flag.battleground) ) status_calc_bl(&sd->bl, SCB_FLEE); //Refresh flee penalty - if( map->night_flag && maplist[sd->bl.m].flag.nightenabled ) { + if( map->night_flag && map->list[sd->bl.m].flag.nightenabled ) { //Display night. if( !sd->state.night ) { sd->state.night = 1; @@ -9548,13 +9548,13 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { clif->sc_end(&sd->bl, sd->bl.id, SELF, SI_SKE); } - if( maplist[sd->bl.m].flag.battleground ) { + if( map->list[sd->bl.m].flag.battleground ) { clif->map_type(sd, MAPTYPE_BATTLEFIELD); // Battleground Mode - if( maplist[sd->bl.m].flag.battleground == 2 ) + if( map->list[sd->bl.m].flag.battleground == 2 ) clif->bg_updatescore_single(sd); } - if( maplist[sd->bl.m].flag.allowks && !map_flag_ks(sd->bl.m) ) { + if( map->list[sd->bl.m].flag.allowks && !map_flag_ks(sd->bl.m) ) { char output[128]; sprintf(output, "[ Kill Steal Protection Disabled. KS is allowed in this map ]"); clif->broadcast(&sd->bl, output, strlen(output) + 1, BC_BLUE, SELF); @@ -9564,7 +9564,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { status_calc_pc(sd, false);/* some conditions are map-dependent so we must recalculate */ sd->state.changemap = false; - if( hChSys.local && hChSys.local_autojoin && !maplist[sd->bl.m].flag.chsysnolocalaj ) { + if( hChSys.local && hChSys.local_autojoin && !map->list[sd->bl.m].flag.chsysnolocalaj ) { clif->chsys_mjoin(sd); } } @@ -9586,7 +9586,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { clif->showvendingboard(&sd->bl,sd->message,0); } - if(maplist[sd->bl.m].flag.loadevent) // Lance + if(map->list[sd->bl.m].flag.loadevent) // Lance npc->script_event(sd, NPCE_LOADMAP); if (pc->checkskill(sd, SG_DEVIL) && !pc->nextjobexp(sd)) //blindness [Komurka] @@ -10415,10 +10415,10 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd) chname++; if( hChSys.local && strcmpi(chname, hChSys.local_name) == 0 ) { - if( !maplist[sd->bl.m].channel ) { + if( !map->list[sd->bl.m].channel ) { clif->chsys_mjoin(sd); } - channel = maplist[sd->bl.m].channel; + channel = map->list[sd->bl.m].channel; } else if( hChSys.ally && sd->status.guild_id && strcmpi(chname, hChSys.ally_name) == 0 ) { struct guild *g = sd->guild; if( !g ) return; @@ -10699,7 +10699,7 @@ void clif_hercules_chsys_delete(struct hChSysCh *channel) { } db_destroy(channel->users); if( channel->m ) { - maplist[channel->m].channel = NULL; + map->list[channel->m].channel = NULL; aFree(channel); } else if ( channel->type == hChSys_ALLY ) aFree(channel); @@ -12000,7 +12000,7 @@ void clif_parse_CreateParty(int fd, struct map_session_data *sd) { char* name = (char*)RFIFOP(fd,2); name[NAME_LENGTH-1] = '\0'; - if( maplist[sd->bl.m].flag.partylock ) { + if( map->list[sd->bl.m].flag.partylock ) { // Party locked. clif->message(fd, msg_txt(227)); return; @@ -12019,7 +12019,7 @@ void clif_parse_CreateParty2(int fd, struct map_session_data *sd) { int item2 = RFIFOB(fd,27); name[NAME_LENGTH-1] = '\0'; - if( maplist[sd->bl.m].flag.partylock ) { + if( map->list[sd->bl.m].flag.partylock ) { // Party locked. clif->message(fd, msg_txt(227)); return; @@ -12039,7 +12039,7 @@ void clif_parse_CreateParty2(int fd, struct map_session_data *sd) { void clif_parse_PartyInvite(int fd, struct map_session_data *sd) { struct map_session_data *t_sd; - if(maplist[sd->bl.m].flag.partylock) { + if(map->list[sd->bl.m].flag.partylock) { // Party locked. clif->message(fd, msg_txt(227)); return; @@ -12060,7 +12060,7 @@ void clif_parse_PartyInvite2(int fd, struct map_session_data *sd) { char *name = (char*)RFIFOP(fd,2); name[NAME_LENGTH-1] = '\0'; - if(maplist[sd->bl.m].flag.partylock) { + if(map->list[sd->bl.m].flag.partylock) { // Party locked. clif->message(fd, msg_txt(227)); return; @@ -12097,7 +12097,7 @@ void clif_parse_ReplyPartyInvite2(int fd,struct map_session_data *sd) /// Request to leave party (CZ_REQ_LEAVE_GROUP). /// 0100 void clif_parse_LeaveParty(int fd, struct map_session_data *sd) { - if(maplist[sd->bl.m].flag.partylock) { + if(map->list[sd->bl.m].flag.partylock) { // Party locked. clif->message(fd, msg_txt(227)); return; @@ -12109,7 +12109,7 @@ void clif_parse_LeaveParty(int fd, struct map_session_data *sd) { /// Request to expel a party member (CZ_REQ_EXPEL_GROUP_MEMBER). /// 0103 <account id>.L <char name>.24B void clif_parse_RemovePartyMember(int fd, struct map_session_data *sd) { - if(maplist[sd->bl.m].flag.partylock) { + if(map->list[sd->bl.m].flag.partylock) { // Party locked. clif->message(fd, msg_txt(227)); return; @@ -12730,7 +12730,7 @@ void clif_parse_OpenVending(int fd, struct map_session_data* sd) { if( sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOROOM ) return; - if( maplist[sd->bl.m].flag.novending ) { + if( map->list[sd->bl.m].flag.novending ) { clif->message (sd->fd, msg_txt(276)); // "You can't open a shop on this map" return; } @@ -12751,7 +12751,7 @@ void clif_parse_CreateGuild(int fd,struct map_session_data *sd) { char* name = (char*)RFIFOP(fd,6); name[NAME_LENGTH-1] = '\0'; - if(maplist[sd->bl.m].flag.guildlock) { + if(map->list[sd->bl.m].flag.guildlock) { //Guild locked. clif->message(fd, msg_txt(228)); return; @@ -12914,7 +12914,7 @@ clif_sub_guild_invite(int fd, struct map_session_data *sd, struct map_session_da return 1; } - if (maplist[sd->bl.m].flag.guildlock) { + if (map->list[sd->bl.m].flag.guildlock) { //Guild locked. clif->message(fd, msg_txt(228)); return 1; @@ -12961,7 +12961,7 @@ void clif_parse_GuildReplyInvite(int fd,struct map_session_data *sd) /// Request to leave guild (CZ_REQ_LEAVE_GUILD). /// 0159 <guild id>.L <account id>.L <char id>.L <reason>.40B void clif_parse_GuildLeave(int fd,struct map_session_data *sd) { - if(maplist[sd->bl.m].flag.guildlock) { + if(map->list[sd->bl.m].flag.guildlock) { //Guild locked. clif->message(fd, msg_txt(228)); return; @@ -12978,7 +12978,7 @@ void clif_parse_GuildLeave(int fd,struct map_session_data *sd) { /// Request to expel a member of a guild (CZ_REQ_BAN_GUILD). /// 015b <guild id>.L <account id>.L <char id>.L <reason>.40B void clif_parse_GuildExpulsion(int fd,struct map_session_data *sd) { - if( maplist[sd->bl.m].flag.guildlock || sd->bg_id ) { + if( map->list[sd->bl.m].flag.guildlock || sd->bg_id ) { // Guild locked. clif->message(fd, msg_txt(228)); return; @@ -13029,7 +13029,7 @@ void clif_parse_GuildRequestAlliance(int fd, struct map_session_data *sd) { if(!sd->state.gmaster_flag) return; - if(maplist[sd->bl.m].flag.guildlock) { + if(map->list[sd->bl.m].flag.guildlock) { //Guild locked. clif->message(fd, msg_txt(228)); return; @@ -13067,7 +13067,7 @@ void clif_parse_GuildDelAlliance(int fd, struct map_session_data *sd) { if(!sd->state.gmaster_flag) return; - if(maplist[sd->bl.m].flag.guildlock) { + if(map->list[sd->bl.m].flag.guildlock) { //Guild locked. clif->message(fd, msg_txt(228)); return; @@ -13084,7 +13084,7 @@ void clif_parse_GuildOpposition(int fd, struct map_session_data *sd) { if(!sd->state.gmaster_flag) return; - if(maplist[sd->bl.m].flag.guildlock) { + if(map->list[sd->bl.m].flag.guildlock) { //Guild locked. clif->message(fd, msg_txt(228)); return; @@ -13108,7 +13108,7 @@ void clif_parse_GuildOpposition(int fd, struct map_session_data *sd) { /// now guild name; might have been (intended) email, since the /// field name and size is same as the one in CH_DELETE_CHAR. void clif_parse_GuildBreak(int fd, struct map_session_data *sd) { - if( maplist[sd->bl.m].flag.guildlock ) { + if( map->list[sd->bl.m].flag.guildlock ) { //Guild locked. clif->message(fd, msg_txt(228)); return; @@ -15950,8 +15950,8 @@ void clif_bg_updatescore(int16 m) { bl.m = m; WBUFW(buf,0) = 0x2de; - WBUFW(buf,2) = maplist[m].bgscore_lion; - WBUFW(buf,4) = maplist[m].bgscore_eagle; + WBUFW(buf,2) = map->list[m].bgscore_lion; + WBUFW(buf,4) = map->list[m].bgscore_eagle; clif->send(buf,packet_len(0x2de),&bl,ALL_SAMEMAP); } @@ -15962,8 +15962,8 @@ void clif_bg_updatescore_single(struct map_session_data *sd) { WFIFOHEAD(fd,packet_len(0x2de)); WFIFOW(fd,0) = 0x2de; - WFIFOW(fd,2) = maplist[sd->bl.m].bgscore_lion; - WFIFOW(fd,4) = maplist[sd->bl.m].bgscore_eagle; + WFIFOW(fd,2) = map->list[sd->bl.m].bgscore_lion; + WFIFOW(fd,4) = map->list[sd->bl.m].bgscore_eagle; WFIFOSET(fd,packet_len(0x2de)); } @@ -17358,14 +17358,14 @@ void clif_maptypeproperty2(struct block_list *bl,enum send_target t) { p.PacketType = maptypeproperty2Type; p.type = 0x28; - p.flag.party = maplist[bl->m].flag.pvp ? 1 : 0; + p.flag.party = map->list[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 = 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 = maplist[bl->m].flag.partylock ? 1 : 0; - p.flag.bg = maplist[bl->m].flag.battleground ? 1 : 0; + p.flag.countpk = map->list[bl->m].flag.pvp ? 1 : 0; + p.flag.nopartyformation = map->list[bl->m].flag.partylock ? 1 : 0; + p.flag.bg = map->list[bl->m].flag.battleground ? 1 : 0; p.flag.noitemconsumption = 0; // TODO p.flag.summonstarmiracle = 0; // TODO p.flag.usecart = 1; // TODO diff --git a/src/map/duel.c b/src/map/duel.c index a993ee667..4e41865d4 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)); - map->map_foreachpc(duel_showinfo_sub, sd, &p); + 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) { - map->map_foreachpc(duel_leave_sub, did); + map->foreachpc(duel_leave_sub, did); duel->count--; } diff --git a/src/map/elemental.c b/src/map/elemental.c index 5a3630c70..3251ca992 100644 --- a/src/map/elemental.c +++ b/src/map/elemental.c @@ -754,7 +754,7 @@ int elemental_ai_sub_foreachclient(struct map_session_data *sd, va_list ap) { } int elemental_ai_timer(int tid, unsigned int tick, int id, intptr_t data) { - map->map_foreachpc(elemental->ai_sub_foreachclient,tick); + map->foreachpc(elemental->ai_sub_foreachclient,tick); return 0; } diff --git a/src/map/guild.c b/src/map/guild.c index b66961262..30f989f58 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -621,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 - || ((map->agit_flag || map->agit2_flag) && maplist[tsd->bl.m].flag.gvg_castle) + || ((map->agit_flag || map->agit2_flag) && map->list[tsd->bl.m].flag.gvg_castle) ) { //Can't invite people inside castles. [Skotlex] clif->guild_inviteack(sd,0); @@ -806,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 - || ((map->agit_flag || map->agit2_flag) && maplist[sd->bl.m].flag.gvg_castle) + || ((map->agit_flag || map->agit2_flag) && map->list[sd->bl.m].flag.gvg_castle) ) return 0; @@ -838,7 +838,7 @@ int guild_expulsion(struct map_session_data* sd, int guild_id, int account_id, i //Can't leave inside guild castles. if ((tsd = map->id2sd(account_id)) && tsd->status.char_id == char_id - && ((map->agit_flag || map->agit2_flag) && maplist[tsd->bl.m].flag.gvg_castle) + && ((map->agit_flag || map->agit2_flag) && map->list[tsd->bl.m].flag.gvg_castle) ) return 0; diff --git a/src/map/instance.c b/src/map/instance.c index 17b66fa75..6ae1d6141 100644 --- a/src/map/instance.c +++ b/src/map/instance.c @@ -159,95 +159,95 @@ int instance_add_map(const char *name, int instance_id, bool usebasename, const return -2; } - if( maplist[m].instance_id >= 0 ) { + if( map->list[m].instance_id >= 0 ) { // Source map already belong to a Instance. ShowError("instance_add_map: trying to instance already instanced map %s.\n", name); return -4; } - ARR_FIND( instance->start_id, map->map_num, i, maplist[i].name[0] == 0 ); // Searching for a Free Map + ARR_FIND( instance->start_id, map->count, i, map->list[i].name[0] == 0 ); // Searching for a Free Map - if( i < map->map_num ) + if( i < map->count ) im = i; // Unused map found (old instance) else { - im = map->map_num; // Using next map index - RECREATE(maplist,struct map_data,++map->map_num); + im = map->count; // Using next map index + RECREATE(map->list,struct map_data,++map->count); } - if( maplist[m].cell == (struct mapcell *)0xdeadbeaf ) - map->cellfromcache(&maplist[m]); + if( map->list[m].cell == (struct mapcell *)0xdeadbeaf ) + map->cellfromcache(&map->list[m]); - memcpy( &maplist[im], &maplist[m], sizeof(struct map_data) ); // Copy source map + memcpy( &map->list[im], &map->list[m], sizeof(struct map_data) ); // Copy source map if( map_name != NULL ) { - snprintf(maplist[im].name, MAP_NAME_LENGTH, "%s", map_name); - maplist[im].custom_name = true; + snprintf(map->list[im].name, MAP_NAME_LENGTH, "%s", map_name); + map->list[im].custom_name = true; } else - snprintf(maplist[im].name, MAP_NAME_LENGTH, (usebasename ? "%.3d#%s" : "%.3d%s"), instance_id, name); // Generate Name for Instance Map - maplist[im].index = mapindex_addmap(-1, maplist[im].name); // Add map index + snprintf(map->list[im].name, MAP_NAME_LENGTH, (usebasename ? "%.3d#%s" : "%.3d%s"), instance_id, name); // Generate Name for Instance Map + map->list[im].index = mapindex_addmap(-1, map->list[im].name); // Add map index - maplist[im].channel = NULL; + map->list[im].channel = NULL; - if( !maplist[im].index ) { - maplist[im].name[0] = '\0'; + if( !map->list[im].index ) { + map->list[im].name[0] = '\0'; ShowError("instance_add_map: no more free map indexes.\n"); return -3; // No free map index } // Reallocate cells - num_cell = maplist[im].xs * maplist[im].ys; - CREATE( maplist[im].cell, struct mapcell, num_cell ); - memcpy( maplist[im].cell, maplist[m].cell, num_cell * sizeof(struct mapcell) ); + num_cell = map->list[im].xs * map->list[im].ys; + CREATE( map->list[im].cell, struct mapcell, num_cell ); + memcpy( map->list[im].cell, map->list[m].cell, num_cell * sizeof(struct mapcell) ); - size = maplist[im].bxs * maplist[im].bys * sizeof(struct block_list*); - maplist[im].block = (struct block_list**)aCalloc(size, 1); - maplist[im].block_mob = (struct block_list**)aCalloc(size, 1); + size = map->list[im].bxs * map->list[im].bys * sizeof(struct block_list*); + map->list[im].block = (struct block_list**)aCalloc(size, 1); + map->list[im].block_mob = (struct block_list**)aCalloc(size, 1); - memset(maplist[im].npc, 0x00, sizeof(maplist[i].npc)); - maplist[im].npc_num = 0; + memset(map->list[im].npc, 0x00, sizeof(map->list[i].npc)); + map->list[im].npc_num = 0; - memset(maplist[im].moblist, 0x00, sizeof(maplist[im].moblist)); - maplist[im].mob_delete_timer = INVALID_TIMER; + memset(map->list[im].moblist, 0x00, sizeof(map->list[im].moblist)); + map->list[im].mob_delete_timer = INVALID_TIMER; //Mimic unit - if( maplist[m].unit_count ) { - maplist[im].unit_count = maplist[m].unit_count; - CREATE( maplist[im].units, struct mapflag_skill_adjust*, maplist[im].unit_count ); + if( map->list[m].unit_count ) { + map->list[im].unit_count = map->list[m].unit_count; + CREATE( map->list[im].units, struct mapflag_skill_adjust*, map->list[im].unit_count ); - for(i = 0; i < maplist[im].unit_count; i++) { - CREATE( maplist[im].units[i], struct mapflag_skill_adjust, 1); - memcpy( maplist[im].units[i],maplist[m].units[i],sizeof(struct mapflag_skill_adjust)); + for(i = 0; i < map->list[im].unit_count; i++) { + CREATE( map->list[im].units[i], struct mapflag_skill_adjust, 1); + memcpy( map->list[im].units[i],map->list[m].units[i],sizeof(struct mapflag_skill_adjust)); } } //Mimic skills - if( maplist[m].skill_count ) { - maplist[im].skill_count = maplist[m].skill_count; - CREATE( maplist[im].skills, struct mapflag_skill_adjust*, maplist[im].skill_count ); + if( map->list[m].skill_count ) { + map->list[im].skill_count = map->list[m].skill_count; + CREATE( map->list[im].skills, struct mapflag_skill_adjust*, map->list[im].skill_count ); - for(i = 0; i < maplist[im].skill_count; i++) { - CREATE( maplist[im].skills[i], struct mapflag_skill_adjust, 1); - memcpy( maplist[im].skills[i],maplist[m].skills[i],sizeof(struct mapflag_skill_adjust)); + for(i = 0; i < map->list[im].skill_count; i++) { + CREATE( map->list[im].skills[i], struct mapflag_skill_adjust, 1); + memcpy( map->list[im].skills[i],map->list[m].skills[i],sizeof(struct mapflag_skill_adjust)); } } //Mimic zone mf - if( maplist[m].zone_mf_count ) { - maplist[im].zone_mf_count = maplist[m].zone_mf_count; - CREATE( maplist[im].zone_mf, char *, maplist[im].zone_mf_count ); + if( map->list[m].zone_mf_count ) { + map->list[im].zone_mf_count = map->list[m].zone_mf_count; + CREATE( map->list[im].zone_mf, char *, map->list[im].zone_mf_count ); - for(i = 0; i < maplist[im].zone_mf_count; i++) { - CREATE(maplist[im].zone_mf[i], char, MAP_ZONE_MAPFLAG_LENGTH); - safestrncpy(maplist[im].zone_mf[i],maplist[m].zone_mf[i],MAP_ZONE_MAPFLAG_LENGTH); + for(i = 0; i < map->list[im].zone_mf_count; i++) { + CREATE(map->list[im].zone_mf[i], char, MAP_ZONE_MAPFLAG_LENGTH); + safestrncpy(map->list[im].zone_mf[i],map->list[m].zone_mf[i],MAP_ZONE_MAPFLAG_LENGTH); } } - maplist[im].m = im; - maplist[im].instance_id = instance_id; - maplist[im].instance_src_map = m; - maplist[m].flag.src4instance = 1; // Flag this map as a src map for instances + map->list[im].m = im; + map->list[im].instance_id = instance_id; + map->list[im].instance_src_map = m; + map->list[m].flag.src4instance = 1; // Flag this map as a src map for instances RECREATE(instance->list[instance_id].map, unsigned short, ++instance->list[instance_id].num_map); instance->list[instance_id].map[instance->list[instance_id].num_map - 1] = im; // Attach to actual instance - map->addmap2db(&maplist[im]); + map->addmap2db(&map->list[im]); return im; } @@ -265,7 +265,7 @@ int instance_map2imap(int16 m, int instance_id) { } for( i = 0; i < instance->list[instance_id].num_map; i++ ) { - if( instance->list[instance_id].map[i] && maplist[instance->list[instance_id].map[i]].instance_src_map == m ) + if( instance->list[instance_id].map[i] && map->list[instance->list[instance_id].map[i]].instance_src_map == m ) return instance->list[instance_id].map[i]; } return -1; @@ -277,9 +277,9 @@ int instance_map2imap(int16 m, int instance_id) { * result : mapid of map "m" in this instance *--------------------------------------*/ int instance_mapid2imapid(int16 m, int instance_id) { - if( maplist[m].flag.src4instance == 0 ) + if( map->list[m].flag.src4instance == 0 ) return m; // not instances found for this map - else if( maplist[m].instance_id >= 0 ) { // This map is a instance, not a src map instance + else if( map->list[m].instance_id >= 0 ) { // This map is a instance, not a src map instance ShowError("map_instance_mapid2imapid: already instanced (%d / %d)\n", m, instance_id); return -1; } @@ -314,7 +314,7 @@ void instance_init(int instance_id) { return; // nothing to do for( i = 0; i < instance->list[instance_id].num_map; i++ ) - map->foreachinmap(instance_map_npcsub, maplist[instance->list[instance_id].map[i]].instance_src_map, BL_NPC, instance->list[instance_id].map[i]); + map->foreachinmap(instance_map_npcsub, map->list[instance->list[instance_id].map[i]].instance_src_map, BL_NPC, instance->list[instance_id].map[i]); instance->list[instance_id].state = INSTANCE_BUSY; } @@ -367,70 +367,70 @@ int instance_cleanup_sub(struct block_list *bl, va_list ap) { void instance_del_map(int16 m) { int i; - if( m <= 0 || maplist[m].instance_id == -1 ) { + if( m <= 0 || map->list[m].instance_id == -1 ) { ShowError("instance_del_map: tried to remove non-existing instance map (%d)\n", m); return; } - map->map_foreachpc(instance_del_load, m); + 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, map->removemobs_timer); + if( map->list[m].mob_delete_timer != INVALID_TIMER ) + timer->delete(map->list[m].mob_delete_timer, map->removemobs_timer); mapindex_removemap(map_id2index(m)); // Free memory - aFree(maplist[m].cell); - aFree(maplist[m].block); - aFree(maplist[m].block_mob); + aFree(map->list[m].cell); + aFree(map->list[m].block); + aFree(map->list[m].block_mob); - if( maplist[m].unit_count ) { - for(i = 0; i < maplist[m].unit_count; i++) { - aFree(maplist[m].units[i]); + if( map->list[m].unit_count ) { + for(i = 0; i < map->list[m].unit_count; i++) { + aFree(map->list[m].units[i]); } - if( maplist[m].units ) - aFree(maplist[m].units); + if( map->list[m].units ) + aFree(map->list[m].units); } - if( maplist[m].skill_count ) { - for(i = 0; i < maplist[m].skill_count; i++) { - aFree(maplist[m].skills[i]); + if( map->list[m].skill_count ) { + for(i = 0; i < map->list[m].skill_count; i++) { + aFree(map->list[m].skills[i]); } - if( maplist[m].skills ) - aFree(maplist[m].skills); + if( map->list[m].skills ) + aFree(map->list[m].skills); } - if( maplist[m].zone_mf_count ) { - for(i = 0; i < maplist[m].zone_mf_count; i++) { - aFree(maplist[m].zone_mf[i]); + if( map->list[m].zone_mf_count ) { + for(i = 0; i < map->list[m].zone_mf_count; i++) { + aFree(map->list[m].zone_mf[i]); } - if( maplist[m].zone_mf ) - aFree(maplist[m].zone_mf); + if( map->list[m].zone_mf ) + aFree(map->list[m].zone_mf); } // Remove from instance - for( i = 0; i < instance->list[maplist[m].instance_id].num_map; i++ ) { - if( instance->list[maplist[m].instance_id].map[i] == m ) { - instance->list[maplist[m].instance_id].num_map--; - for( ; i < instance->list[maplist[m].instance_id].num_map; i++ ) - instance->list[maplist[m].instance_id].map[i] = instance->list[maplist[m].instance_id].map[i+1]; + for( i = 0; i < instance->list[map->list[m].instance_id].num_map; i++ ) { + if( instance->list[map->list[m].instance_id].map[i] == m ) { + instance->list[map->list[m].instance_id].num_map--; + for( ; i < instance->list[map->list[m].instance_id].num_map; i++ ) + instance->list[map->list[m].instance_id].map[i] = instance->list[map->list[m].instance_id].map[i+1]; i = -1; break; } } - if( i == instance->list[maplist[m].instance_id].num_map ) - ShowError("map_instance_del: failed to remove %s from instance list (%s): %d\n", maplist[m].name, instance->list[maplist[m].instance_id].name, m); + if( i == instance->list[map->list[m].instance_id].num_map ) + ShowError("map_instance_del: failed to remove %s from instance list (%s): %d\n", map->list[m].name, instance->list[map->list[m].instance_id].name, m); - if( maplist[m].channel ) - clif->chsys_delete(maplist[m].channel); - - map->removemapdb(&maplist[m]); - memset(&maplist[m], 0x00, sizeof(maplist[0])); - maplist[m].name[0] = 0; - maplist[m].instance_id = -1; - maplist[m].mob_delete_timer = INVALID_TIMER; + if( map->list[m].channel ) + clif->chsys_delete(map->list[m].channel); + + map->removemapdb(&map->list[m]); + memset(&map->list[m], 0x00, sizeof(map->list[0])); + map->list[m].name[0] = 0; + map->list[m].instance_id = -1; + map->list[m].mob_delete_timer = INVALID_TIMER; } /*-------------------------------------- @@ -592,9 +592,9 @@ void instance_check_kick(struct map_session_data *sd) { int16 m = sd->bl.m; clif->instance_leave(sd->fd); - if( maplist[m].instance_id >= 0 ) { // User was on the instance map - if( maplist[m].save.map ) - pc->setpos(sd, maplist[m].save.map, maplist[m].save.x, maplist[m].save.y, CLR_TELEPORT); + if( map->list[m].instance_id >= 0 ) { // User was on the instance map + if( map->list[m].save.map ) + pc->setpos(sd, map->list[m].save.map, map->list[m].save.x, map->list[m].save.y, CLR_TELEPORT); else pc->setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, CLR_TELEPORT); } diff --git a/src/map/intif.c b/src/map/intif.c index e42679ec6..f31ab0f5a 100644 --- a/src/map/intif.c +++ b/src/map/intif.c @@ -454,8 +454,8 @@ int intif_party_changemap(struct map_session_data *sd,int online) { if(!sd) return 0; - if( (m=map->mapindex2mapid(sd->mapindex)) >= 0 && maplist[m].instance_id >= 0 ) - mapindex = map_id2index(maplist[m].instance_src_map); + if( (m=map->mapindex2mapid(sd->mapindex)) >= 0 && map->list[m].instance_id >= 0 ) + mapindex = map_id2index(map->list[m].instance_src_map); else mapindex = sd->mapindex; @@ -918,7 +918,7 @@ void 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 - map->map_foreachpc(mapif_parse_WisToGM_sub, permission, Wisp_name, message, mes_len); + map->foreachpc(mapif_parse_WisToGM_sub, permission, Wisp_name, message, mes_len); if (message != mbuf) aFree(message); diff --git a/src/map/itemdb.c b/src/map/itemdb.c index f7ee8a884..fe2c43fcc 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -1838,18 +1838,18 @@ int itemdb_read_sqldb(void) { uint32 count = 0; // retrieve all rows from the item database - if( SQL_ERROR == SQL->Query(mmysql_handle, "SELECT * FROM `%s`", item_db_name[fi]) ) { - Sql_ShowDebug(mmysql_handle); + if( SQL_ERROR == SQL->Query(map->mysql_handle, "SELECT * FROM `%s`", item_db_name[fi]) ) { + Sql_ShowDebug(map->mysql_handle); continue; } // process rows one by one - while( SQL_SUCCESS == SQL->NextRow(mmysql_handle) ) {// wrap the result into a TXT-compatible format + while( SQL_SUCCESS == SQL->NextRow(map->mysql_handle) ) {// wrap the result into a TXT-compatible format char* str[ITEMDB_SQL_COLUMNS]; char* dummy = ""; int i; for( i = 0; i < ITEMDB_SQL_COLUMNS; ++i ) { - SQL->GetData(mmysql_handle, i, &str[i], NULL); + SQL->GetData(map->mysql_handle, i, &str[i], NULL); if( str[i] == NULL ) str[i] = dummy; // get rid of NULL columns } @@ -1860,7 +1860,7 @@ int itemdb_read_sqldb(void) { } // free the query result - SQL->FreeResult(mmysql_handle); + SQL->FreeResult(map->mysql_handle); ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, item_db_name[fi]); } @@ -1895,18 +1895,18 @@ uint64 itemdb_unique_id(int8 flag, int64 value) { } int itemdb_uid_load() { char * uid; - if (SQL_ERROR == SQL->Query(mmysql_handle, "SELECT `value` FROM `%s` WHERE `varname`='unique_id'",map->interreg_db)) - Sql_ShowDebug(mmysql_handle); + if (SQL_ERROR == SQL->Query(map->mysql_handle, "SELECT `value` FROM `%s` WHERE `varname`='unique_id'",map->interreg_db)) + Sql_ShowDebug(map->mysql_handle); - if( SQL_SUCCESS != SQL->NextRow(mmysql_handle) ) { + if( SQL_SUCCESS != SQL->NextRow(map->mysql_handle) ) { ShowError("itemdb_uid_load: Unable to fetch unique_id data\n"); - SQL->FreeResult(mmysql_handle); + SQL->FreeResult(map->mysql_handle); return -1; } - SQL->GetData(mmysql_handle, 0, &uid, NULL); + SQL->GetData(map->mysql_handle, 0, &uid, NULL); itemdb->unique_id(1, (uint64)strtoull(uid, NULL, 10)); - SQL->FreeResult(mmysql_handle); + SQL->FreeResult(map->mysql_handle); return 0; } diff --git a/src/map/log.c b/src/map/log.c index 5d88e3df4..e33240505 100644 --- a/src/map/log.c +++ b/src/map/log.c @@ -91,7 +91,7 @@ bool should_log_item(int nameid, int amount, int refine, struct item_data *id) { } void log_branch_sub_sql(struct map_session_data* sd) { SqlStmt* stmt; - stmt = SQL->StmtMalloc(logmysql_handle); + stmt = SQL->StmtMalloc(logs->mysql_handle); if( SQL_SUCCESS != SQL->StmtPrepare(stmt, LOG_QUERY " INTO `%s` (`branch_date`, `account_id`, `char_id`, `char_name`, `map`) VALUES (NOW(), '%d', '%d', ?, '%s')", logs->config.log_branch, sd->status.account_id, sd->status.char_id, mapindex_id2name(sd->mapindex) ) || SQL_SUCCESS != SQL->StmtBindParam(stmt, 0, SQLDT_STRING, sd->status.name, strnlen(sd->status.name, NAME_LENGTH)) || SQL_SUCCESS != SQL->StmtExecute(stmt) ) @@ -125,13 +125,13 @@ void log_branch(struct map_session_data* sd) { logs->branch_sub(sd); } void log_pick_sub_sql(int id, int16 m, e_log_pick_type type, int amount, struct item* itm, struct item_data *data) { - if( SQL_ERROR == SQL->Query(logmysql_handle, + if( SQL_ERROR == SQL->Query(logs->mysql_handle, LOG_QUERY " INTO `%s` (`time`, `char_id`, `type`, `nameid`, `amount`, `refine`, `card0`, `card1`, `card2`, `card3`, `map`, `unique_id`) " "VALUES (NOW(), '%d', '%c', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%s', '%"PRIu64"')", logs->config.log_pick, id, logs->picktype2char(type), itm->nameid, amount, itm->refine, itm->card[0], itm->card[1], itm->card[2], itm->card[3], - maplist[m].name?maplist[m].name:"", itm->unique_id) + map->list[m].name?map->list[m].name:"", itm->unique_id) ) { - Sql_ShowDebug(logmysql_handle); + Sql_ShowDebug(logs->mysql_handle); return; } } @@ -146,7 +146,7 @@ void log_pick_sub_txt(int id, int16 m, e_log_pick_type type, int amount, struct strftime(timestring, sizeof(timestring), "%m/%d/%Y %H:%M:%S", localtime(&curtime)); fprintf(logfp,"%s - %d\t%c\t%d,%d,%d,%d,%d,%d,%d,%s,'%"PRIu64"'\n", timestring, id, logs->picktype2char(type), itm->nameid, amount, itm->refine, itm->card[0], itm->card[1], itm->card[2], itm->card[3], - maplist[m].name?maplist[m].name:"", itm->unique_id); + map->list[m].name?map->list[m].name:"", itm->unique_id); fclose(logfp); } /// logs item transactions (generic) @@ -175,10 +175,10 @@ void log_pick_mob(struct mob_data* md, e_log_pick_type type, int amount, struct log_pick(md->class_, md->bl.m, type, amount, itm, data ? data : itemdb->exists(itm->nameid)); } void log_zeny_sub_sql(struct map_session_data* sd, e_log_pick_type type, struct map_session_data* src_sd, int amount) { - if( SQL_ERROR == SQL->Query(logmysql_handle, LOG_QUERY " INTO `%s` (`time`, `char_id`, `src_id`, `type`, `amount`, `map`) VALUES (NOW(), '%d', '%d', '%c', '%d', '%s')", + if( SQL_ERROR == SQL->Query(logs->mysql_handle, LOG_QUERY " INTO `%s` (`time`, `char_id`, `src_id`, `type`, `amount`, `map`) VALUES (NOW(), '%d', '%d', '%c', '%d', '%s')", logs->config.log_zeny, sd->status.char_id, src_sd->status.char_id, logs->picktype2char(type), amount, mapindex_id2name(sd->mapindex)) ) { - Sql_ShowDebug(logmysql_handle); + Sql_ShowDebug(logs->mysql_handle); return; } } @@ -205,10 +205,10 @@ void log_zeny(struct map_session_data* sd, e_log_pick_type type, struct map_sess logs->zeny_sub(sd,type,src_sd,amount); } void log_mvpdrop_sub_sql(struct map_session_data* sd, int monster_id, int* log_mvp) { - if( SQL_ERROR == SQL->Query(logmysql_handle, LOG_QUERY " INTO `%s` (`mvp_date`, `kill_char_id`, `monster_id`, `prize`, `mvpexp`, `map`) VALUES (NOW(), '%d', '%d', '%d', '%d', '%s') ", + if( SQL_ERROR == SQL->Query(logs->mysql_handle, LOG_QUERY " INTO `%s` (`mvp_date`, `kill_char_id`, `monster_id`, `prize`, `mvpexp`, `map`) VALUES (NOW(), '%d', '%d', '%d', '%d', '%s') ", logs->config.log_mvpdrop, sd->status.char_id, monster_id, log_mvp[0], log_mvp[1], mapindex_id2name(sd->mapindex)) ) { - Sql_ShowDebug(logmysql_handle); + Sql_ShowDebug(logs->mysql_handle); return; } } @@ -238,7 +238,7 @@ void log_mvpdrop(struct map_session_data* sd, int monster_id, int* log_mvp) void log_atcommand_sub_sql(struct map_session_data* sd, const char* message) { SqlStmt* stmt; - stmt = SQL->StmtMalloc(logmysql_handle); + stmt = SQL->StmtMalloc(logs->mysql_handle); if( SQL_SUCCESS != SQL->StmtPrepare(stmt, LOG_QUERY " INTO `%s` (`atcommand_date`, `account_id`, `char_id`, `char_name`, `map`, `command`) VALUES (NOW(), '%d', '%d', ?, '%s', ?)", logs->config.log_gm, sd->status.account_id, sd->status.char_id, mapindex_id2name(sd->mapindex) ) || SQL_SUCCESS != SQL->StmtBindParam(stmt, 0, SQLDT_STRING, sd->status.name, strnlen(sd->status.name, NAME_LENGTH)) || SQL_SUCCESS != SQL->StmtBindParam(stmt, 1, SQLDT_STRING, (char*)message, safestrnlen(message, 255)) @@ -276,7 +276,7 @@ void log_atcommand(struct map_session_data* sd, const char* message) void log_npc_sub_sql(struct map_session_data *sd, const char *message) { SqlStmt* stmt; - stmt = SQL->StmtMalloc(logmysql_handle); + stmt = SQL->StmtMalloc(logs->mysql_handle); if( SQL_SUCCESS != SQL->StmtPrepare(stmt, LOG_QUERY " INTO `%s` (`npc_date`, `account_id`, `char_id`, `char_name`, `map`, `mes`) VALUES (NOW(), '%d', '%d', ?, '%s', ?)", logs->config.log_npc, sd->status.account_id, sd->status.char_id, mapindex_id2name(sd->mapindex) ) || SQL_SUCCESS != SQL->StmtBindParam(stmt, 0, SQLDT_STRING, sd->status.name, strnlen(sd->status.name, NAME_LENGTH)) || SQL_SUCCESS != SQL->StmtBindParam(stmt, 1, SQLDT_STRING, (char*)message, safestrnlen(message, 255)) @@ -314,7 +314,7 @@ void log_npc(struct map_session_data* sd, const char* message) void log_chat_sub_sql(e_log_chat_type type, int type_id, int src_charid, int src_accid, const char *mapname, int x, int y, const char* dst_charname, const char* message) { SqlStmt* stmt; - stmt = SQL->StmtMalloc(logmysql_handle); + stmt = SQL->StmtMalloc(logs->mysql_handle); if( SQL_SUCCESS != SQL->StmtPrepare(stmt, LOG_QUERY " INTO `%s` (`time`, `type`, `type_id`, `src_charid`, `src_accountid`, `src_map`, `src_map_x`, `src_map_y`, `dst_charname`, `message`) VALUES (NOW(), '%c', '%d', '%d', '%d', '%s', '%d', '%d', ?, ?)", logs->config.log_chat, logs->chattype2char(type), type_id, src_charid, src_accid, mapname, x, y) || SQL_SUCCESS != SQL->StmtBindParam(stmt, 0, SQLDT_STRING, (char*)dst_charname, safestrnlen(dst_charname, NAME_LENGTH)) || SQL_SUCCESS != SQL->StmtBindParam(stmt, 1, SQLDT_STRING, (char*)message, safestrnlen(message, CHAT_SIZE_MAX)) @@ -354,6 +354,24 @@ void log_chat(e_log_chat_type type, int type_id, int src_charid, int src_accid, logs->chat_sub(type,type_id,src_charid,src_accid,mapname,x,y,dst_charname,message); } +void log_sql_init(void) { + // log db connection + logs->mysql_handle = SQL->Malloc(); + + ShowInfo(""CL_WHITE"[SQL]"CL_RESET": Connecting to the Log Database "CL_WHITE"%s"CL_RESET" At "CL_WHITE"%s"CL_RESET"...\n",logs->db_name,logs->db_ip); + if ( SQL_ERROR == SQL->Connect(logs->mysql_handle, logs->db_id, logs->db_pw, logs->db_ip, logs->db_port, logs->db_name) ) + exit(EXIT_FAILURE); + ShowStatus(""CL_WHITE"[SQL]"CL_RESET": Successfully '"CL_GREEN"connected"CL_RESET"' to Database '"CL_WHITE"%s"CL_RESET"'.\n", logs->db_name); + + if( strlen(map->default_codepage) > 0 ) + if ( SQL_ERROR == SQL->SetEncoding(logs->mysql_handle, map->default_codepage) ) + Sql_ShowDebug(logs->mysql_handle); +} +void log_sql_final(void) { + ShowStatus("Close Log DB Connection....\n"); + SQL->Free(logs->mysql_handle); + logs->mysql_handle = NULL; +} void log_set_defaults(void) { memset(&logs->config, 0, sizeof(logs->config)); @@ -481,6 +499,15 @@ void log_config_complete(void) { void log_defaults(void) { logs = &log_s; + sprintf(logs->db_ip,"127.0.0.1"); + sprintf(logs->db_id,"ragnarok"); + sprintf(logs->db_pw,"ragnarok"); + sprintf(logs->db_name,"log"); + + logs->db_port = 3306; + logs->mysql_handle = NULL; + /* */ + logs->pick_pc = log_pick_pc; logs->pick_mob = log_pick_mob; logs->zeny = log_zeny; @@ -501,6 +528,8 @@ void log_defaults(void) { logs->config_read = log_config_read; logs->config_done = log_config_complete; + logs->sql_init = log_sql_init; + logs->sql_final = log_sql_final; logs->picktype2char = log_picktype2char; logs->chattype2char = log_chattype2char; diff --git a/src/map/log.h b/src/map/log.h index caf9ce0c5..07606c8ef 100644 --- a/src/map/log.h +++ b/src/map/log.h @@ -95,6 +95,13 @@ struct log_interface { char log_branch[64], log_pick[64], log_zeny[64], log_mvpdrop[64], log_gm[64], log_npc[64], log_chat[64]; } config; /* */ + char db_ip[32]; + int db_port; + char db_id[32]; + char db_pw[32]; + char db_name[32]; + Sql* mysql_handle; + /* */ void (*pick_pc) (struct map_session_data* sd, e_log_pick_type type, int amount, struct item* itm, struct item_data *data); void (*pick_mob) (struct mob_data* md, e_log_pick_type type, int amount, struct item* itm, struct item_data *data); void (*zeny) (struct map_session_data* sd, e_log_pick_type type, struct map_session_data* src_sd, int amount); @@ -114,6 +121,8 @@ struct log_interface { int (*config_read) (const char* cfgName); void (*config_done) (void); + void (*sql_init) (void); + void (*sql_final) (void); char (*picktype2char) (e_log_pick_type type); char (*chattype2char) (e_log_chat_type type); diff --git a/src/map/mail.c b/src/map/mail.c index ea8bda003..2378cbe2a 100644 --- a/src/map/mail.c +++ b/src/map/mail.c @@ -177,7 +177,7 @@ void mail_deliveryfail(struct map_session_data *sd, struct mail_message *msg) // This function only check if the mail operations are valid bool mail_invalid_operation(struct map_session_data *sd) { - if( !maplist[sd->bl.m].flag.town && !pc->can_use_command(sd, "@mail") ) { + if( !map->list[sd->bl.m].flag.town && !pc->can_use_command(sd, "@mail") ) { ShowWarning("clif->parse_Mail: char '%s' trying to do invalid mail operations.\n", sd->status.name); return true; } diff --git a/src/map/map.c b/src/map/map.c index ea40d9979..0457de5bb 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -62,197 +62,106 @@ #include <unistd.h> #endif -char default_codepage[32] = ""; - -int map_server_port = 3306; -char map_server_ip[32] = "127.0.0.1"; -char map_server_id[32] = "ragnarok"; -char map_server_pw[32] = "ragnarok"; -char map_server_db[32] = "ragnarok"; -Sql* mmysql_handle; - -int map_port=0; - -// log database -char log_db_ip[32] = "127.0.0.1"; -int log_db_port = 3306; -char log_db_id[32] = "ragnarok"; -char log_db_pw[32] = "ragnarok"; -char log_db_db[32] = "log"; -Sql* logmysql_handle; - -// DBMap declaration -static DBMap* id_db=NULL; // int id -> struct block_list* -static DBMap* pc_db=NULL; // int id -> struct map_session_data* -static DBMap* mobid_db=NULL; // int id -> struct mob_data* -static DBMap* bossid_db=NULL; // int id -> struct mob_data* (MVP db) -static DBMap* map_db=NULL; // unsigned int mapindex -> struct map_data_other_server* -static DBMap* nick_db=NULL; // int char_id -> struct charid2nick* (requested names of offline characters) -static DBMap* charid_db=NULL; // int char_id -> struct map_session_data* -static DBMap* regen_db=NULL; // int id -> struct block_list* (status_natural_heal processing) - -static int map_users=0; - -#define BLOCK_SIZE 8 -#define block_free_max 1048576 -struct block_list *block_free[block_free_max]; -static int block_free_count = 0, block_free_lock = 0; - -#define BL_LIST_MAX 1048576 -static struct block_list *bl_list[BL_LIST_MAX]; -static int bl_list_count = 0; - -struct charid_request { - struct charid_request* next; - int charid;// who want to be notified of the nick -}; -struct charid2nick { - char nick[NAME_LENGTH]; - struct charid_request* requests;// requests of notification on this nick -}; - -// This is the main header found at the very beginning of the map cache -struct map_cache_main_header { - uint32 file_size; - uint16 map_count; -}; - -// This is the header appended before every compressed map cells info in the map cache -struct map_cache_map_info { - char name[MAP_NAME_LENGTH]; - int16 xs; - int16 ys; - int32 len; -}; - -int16 index2mapid[MAX_MAPINDEX]; - -int enable_grf = 0; //To enable/disable reading maps from GRF files, bypassing mapcache [blackhole89] - -/* [Ind/Hercules] */ -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 map_s; - -struct map_session_data *cpsd; +struct mapit_interface mapit_s; /*========================================== -* server player count (of all mapservers) -*------------------------------------------*/ -void map_setusers(int users) -{ - map_users = users; + * server player count (of all mapservers) + *------------------------------------------*/ +void map_setusers(int users) { + map->users = users; } -int map_getusers(void) -{ - return map_users; +int map_getusers(void) { + return map->users; } /*========================================== -* server player count (this mapserver only) -*------------------------------------------*/ -int map_usercount(void) -{ - return pc_db->size(pc_db); + * server player count (this mapserver only) + *------------------------------------------*/ +int map_usercount(void) { + return db_size(map->pc_db); } - /*========================================== -* Attempt to free a map blocklist -*------------------------------------------*/ -int map_freeblock (struct block_list *bl) -{ - nullpo_retr(block_free_lock, bl); - if (block_free_lock == 0 || block_free_count >= block_free_max) - { + * Attempt to free a map blocklist + *------------------------------------------*/ +int map_freeblock (struct block_list *bl) { + nullpo_retr(map->block_free_lock, bl); + if (map->block_free_lock == 0 || map->block_free_count >= block_free_max) { aFree(bl); bl = NULL; - if (block_free_count >= block_free_max) - ShowWarning("map_freeblock: too many free block! %d %d\n", block_free_count, block_free_lock); + if (map->block_free_count >= block_free_max) + ShowWarning("map_freeblock: too many free block! %d %d\n", map->block_free_count, map->block_free_lock); } else - block_free[block_free_count++] = bl; + map->block_free[map->block_free_count++] = bl; - return block_free_lock; + return map->block_free_lock; } /*========================================== -* Lock blocklist, (prevent map->freeblock usage) -*------------------------------------------*/ -int map_freeblock_lock (void) -{ - return ++block_free_lock; + * Lock blocklist, (prevent map->freeblock usage) + *------------------------------------------*/ +int map_freeblock_lock (void) { + return ++map->block_free_lock; } /*========================================== -* Remove the lock on map_bl -*------------------------------------------*/ -int map_freeblock_unlock (void) -{ - if ((--block_free_lock) == 0) { + * Remove the lock on map_bl + *------------------------------------------*/ +int map_freeblock_unlock (void) { + if ((--map->block_free_lock) == 0) { int i; - for (i = 0; i < block_free_count; i++) + for (i = 0; i < map->block_free_count; i++) { - aFree(block_free[i]); - block_free[i] = NULL; + aFree(map->block_free[i]); + map->block_free[i] = NULL; } - block_free_count = 0; - } else if (block_free_lock < 0) { + map->block_free_count = 0; + } else if (map->block_free_lock < 0) { ShowError("map_freeblock_unlock: lock count < 0 !\n"); - block_free_lock = 0; + map->block_free_lock = 0; } - return block_free_lock; + return map->block_free_lock; } // 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) { - if (block_free_lock > 0) { - ShowError("map_freeblock_timer: block_free_lock(%d) is invalid.\n", block_free_lock); - block_free_lock = 1; + if (map->block_free_lock > 0) { + ShowError("map_freeblock_timer: block_free_lock(%d) is invalid.\n", map->block_free_lock); + map->block_free_lock = 1; map->freeblock_unlock(); } return 0; } -// -// blocklist -// -/*========================================== -* Handling of map_bl[] -* The adresse of bl_heal is set in bl->prev -*------------------------------------------*/ -static struct block_list bl_head; - #ifdef CELL_NOSTACK /*========================================== -* These pair of functions update the counter of how many objects -* lie on a tile. -*------------------------------------------*/ -static void map_addblcell(struct block_list *bl) { - if( bl->m < 0 || bl->x < 0 || bl->x >= maplist[bl->m].xs - || bl->y < 0 || bl->y >= maplist[bl->m].ys + * These pair of functions update the counter of how many objects + * lie on a tile. + *------------------------------------------*/ +void map_addblcell(struct block_list *bl) { + if( bl->m < 0 || bl->x < 0 || bl->x >= map->list[bl->m].xs + || bl->y < 0 || bl->y >= map->list[bl->m].ys || !(bl->type&BL_CHAR) ) return; - maplist[bl->m].cell[bl->x+bl->y*maplist[bl->m].xs].cell_bl++; - return; + map->list[bl->m].cell[bl->x+bl->y*map->list[bl->m].xs].cell_bl++; } -static void map_delblcell(struct block_list *bl) { - if( bl->m < 0 || bl->x < 0 || bl->x >= maplist[bl->m].xs - || bl->y < 0 || bl->y >= maplist[bl->m].ys +void map_delblcell(struct block_list *bl) { + if( bl->m < 0 || bl->x < 0 || bl->x >= map->list[bl->m].xs + || bl->y < 0 || bl->y >= map->list[bl->m].ys || !(bl->type&BL_CHAR) ) - return; - maplist[bl->m].cell[bl->x+bl->y*maplist[bl->m].xs].cell_bl--; + map->list[bl->m].cell[bl->x+bl->y*map->list[bl->m].xs].cell_bl--; } #endif /*========================================== -* Adds a block to the map. -* Returns 0 on success, 1 on failure (illegal coordinates). -*------------------------------------------*/ + * Adds a block to the map. + * Returns 0 on success, 1 on failure (illegal coordinates). + *------------------------------------------*/ int map_addblock(struct block_list* bl) { int16 m, x, y; @@ -268,39 +177,39 @@ int map_addblock(struct block_list* bl) m = bl->m; x = bl->x; y = bl->y; - if( m < 0 || m >= map->map_num ) { - ShowError("map_addblock: invalid map id (%d), only %d are loaded.\n", m, map->map_num); + if( m < 0 || m >= map->count ) { + ShowError("map_addblock: invalid map id (%d), only %d are loaded.\n", m, map->count); return 1; } - if( x < 0 || x >= maplist[m].xs || y < 0 || y >= maplist[m].ys ) { - ShowError("map_addblock: out-of-bounds coordinates (\"%s\",%d,%d), map is %dx%d\n", maplist[m].name, x, y, maplist[m].xs, maplist[m].ys); + if( x < 0 || x >= map->list[m].xs || y < 0 || y >= map->list[m].ys ) { + ShowError("map_addblock: out-of-bounds coordinates (\"%s\",%d,%d), map is %dx%d\n", map->list[m].name, x, y, map->list[m].xs, map->list[m].ys); return 1; } - pos = x/BLOCK_SIZE+(y/BLOCK_SIZE)*maplist[m].bxs; + pos = x/BLOCK_SIZE+(y/BLOCK_SIZE)*map->list[m].bxs; if (bl->type == BL_MOB) { - bl->next = maplist[m].block_mob[pos]; - bl->prev = &bl_head; + bl->next = map->list[m].block_mob[pos]; + bl->prev = &map->bl_head; if (bl->next) bl->next->prev = bl; - maplist[m].block_mob[pos] = bl; + map->list[m].block_mob[pos] = bl; } else { - bl->next = maplist[m].block[pos]; - bl->prev = &bl_head; + bl->next = map->list[m].block[pos]; + bl->prev = &map->bl_head; if (bl->next) bl->next->prev = bl; - maplist[m].block[pos] = bl; + map->list[m].block[pos] = bl; } #ifdef CELL_NOSTACK - map_addblcell(bl); + map->addblcell(bl); #endif return 0; } /*========================================== -* Removes a block from the map. -*------------------------------------------*/ + * Removes a block from the map. + *------------------------------------------*/ int map_delblock(struct block_list* bl) { int pos; @@ -316,19 +225,19 @@ int map_delblock(struct block_list* bl) } #ifdef CELL_NOSTACK - map_delblcell(bl); + map->delblcell(bl); #endif - pos = bl->x/BLOCK_SIZE+(bl->y/BLOCK_SIZE)*maplist[bl->m].bxs; + pos = bl->x/BLOCK_SIZE+(bl->y/BLOCK_SIZE)*map->list[bl->m].bxs; if (bl->next) bl->next->prev = bl->prev; - if (bl->prev == &bl_head) { + if (bl->prev == &map->bl_head) { //Since the head of the list, update the block_list map of [] if (bl->type == BL_MOB) { - maplist[bl->m].block_mob[pos] = bl->next; + map->list[bl->m].block_mob[pos] = bl->next; } else { - maplist[bl->m].block[pos] = bl->next; + map->list[bl->m].block[pos] = bl->next; } } else { bl->prev->next = bl->next; @@ -340,10 +249,10 @@ int map_delblock(struct block_list* bl) } /*========================================== -* Moves a block a x/y target position. [Skotlex] -* Pass flag as 1 to prevent doing skill->unit_move checks -* (which are executed by default on BL_CHAR types) -*------------------------------------------*/ + * Moves a block a x/y target position. [Skotlex] + * Pass flag as 1 to prevent doing skill->unit_move checks + * (which are executed by default on BL_CHAR types) + *------------------------------------------*/ int map_moveblock(struct block_list *bl, int x1, int y1, unsigned int tick) { int x0 = bl->x, y0 = bl->y; @@ -375,13 +284,13 @@ int map_moveblock(struct block_list *bl, int x1, int y1, unsigned int tick) if (moveblock) map->delblock(bl); #ifdef CELL_NOSTACK - else map_delblcell(bl); + else map->delblcell(bl); #endif bl->x = x1; bl->y = y1; if (moveblock) map->addblock(bl); #ifdef CELL_NOSTACK - else map_addblcell(bl); + else map->addblcell(bl); #endif if (bl->type&BL_CHAR) { @@ -449,49 +358,49 @@ int map_moveblock(struct block_list *bl, int x1, int y1, unsigned int tick) } /*========================================== -* Counts specified number of objects on given cell. -* TODO: merge with bl_getall_area -*------------------------------------------*/ + * Counts specified number of objects on given cell. + * TODO: merge with bl_getall_area + *------------------------------------------*/ int map_count_oncell(int16 m, int16 x, int16 y, int type) { int bx,by; struct block_list *bl; int count = 0; - if (x < 0 || y < 0 || (x >= maplist[m].xs) || (y >= maplist[m].ys)) + if (x < 0 || y < 0 || (x >= map->list[m].xs) || (y >= map->list[m].ys)) return 0; bx = x/BLOCK_SIZE; by = y/BLOCK_SIZE; if (type&~BL_MOB) - for( bl = maplist[m].block[bx+by*maplist[m].bxs] ; bl != NULL ; bl = bl->next ) + for( bl = map->list[m].block[bx+by*map->list[m].bxs] ; bl != NULL ; bl = bl->next ) if(bl->x == x && bl->y == y && bl->type&type) count++; if (type&BL_MOB) - for( bl = maplist[m].block_mob[bx+by*maplist[m].bxs] ; bl != NULL ; bl = bl->next ) + for( bl = map->list[m].block_mob[bx+by*map->list[m].bxs] ; bl != NULL ; bl = bl->next ) if(bl->x == x && bl->y == y) count++; return count; } /* -* Looks for a skill unit on a given cell -* flag&1: runs battle_check_target check based on unit->group->target_flag -*/ + * Looks for a skill unit on a given cell + * flag&1: runs battle_check_target check based on unit->group->target_flag + */ struct skill_unit* map_find_skill_unit_oncell(struct block_list* target,int16 x,int16 y,uint16 skill_id,struct skill_unit* out_unit, int flag) { int16 m,bx,by; struct block_list *bl; struct skill_unit *su; m = target->m; - if (x < 0 || y < 0 || (x >= maplist[m].xs) || (y >= maplist[m].ys)) + if (x < 0 || y < 0 || (x >= map->list[m].xs) || (y >= map->list[m].ys)) return NULL; bx = x/BLOCK_SIZE; by = y/BLOCK_SIZE; - for( bl = maplist[m].block[bx+by*maplist[m].bxs] ; bl != NULL ; bl = bl->next ) { + for( bl = map->list[m].block[bx+by*map->list[m].bxs] ; bl != NULL ; bl = bl->next ) { if (bl->x != x || bl->y != y || bl->type != BL_SKILL) continue; @@ -523,17 +432,17 @@ static int bl_vforeach(int (*func)(struct block_list*, va_list), int blockcount, int returnCount = 0; 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. + for (i = blockcount; i < map->bl_list_count && returnCount < max; i++) { + if (map->bl_list[i]->prev) { //func() may delete this bl_list[] slot, checking for prev ensures it wasnt queued for deletion. va_list argscopy; va_copy(argscopy, args); - returnCount += func(bl_list[i], argscopy); + returnCount += func(map->bl_list[i], argscopy); va_end(argscopy); } } map->freeblock_unlock(); - bl_list_count = blockcount; + map->bl_list_count = blockcount; return returnCount; } @@ -553,30 +462,30 @@ static int map_vforeachinmap(int (*func)(struct block_list*, va_list), int16 m, int bsize; va_list argscopy; struct block_list *bl; - int blockcount = bl_list_count; + int blockcount = map->bl_list_count; if (m < 0) return 0; - bsize = maplist[m].bxs * maplist[m].bys; + bsize = map->list[m].bxs * map->list[m].bys; for (i = 0; i < bsize; i++) { if (type&~BL_MOB) { - for (bl = maplist[m].block[i]; bl != NULL; bl = bl->next) { - if (bl->type&type && bl_list_count < BL_LIST_MAX) { - bl_list[bl_list_count++] = bl; + for (bl = map->list[m].block[i]; bl != NULL; bl = bl->next) { + if (bl->type&type && map->bl_list_count < BL_LIST_MAX) { + map->bl_list[map->bl_list_count++] = bl; } } } if (type&BL_MOB) { - for (bl = maplist[m].block_mob[i]; bl != NULL; bl = bl->next) { - if (bl_list_count < BL_LIST_MAX) { - bl_list[bl_list_count++] = bl; + for (bl = map->list[m].block_mob[i]; bl != NULL; bl = bl->next) { + if (map->bl_list_count < BL_LIST_MAX) { + map->bl_list[map->bl_list_count++] = bl; } } } } - if (bl_list_count >= BL_LIST_MAX) + if (map->bl_list_count >= BL_LIST_MAX) ShowError("map.c:map_vforeachinmap: bl_list size (%d) exceeded\n", BL_LIST_MAX); va_copy(argscopy, args); @@ -679,48 +588,48 @@ static int bl_getall_area(int type, int m, int x0, int y0, int x1, int y1, int ( // Limit search area to map size x0 = max(x0, 0); y0 = max(y0, 0); - x1 = min(x1, maplist[m].xs - 1); - y1 = min(y1, maplist[m].ys - 1); + x1 = min(x1, map->list[m].xs - 1); + y1 = min(y1, map->list[m].ys - 1); for (by = y0 / BLOCK_SIZE; by <= y1 / BLOCK_SIZE; by++) { for (bx = x0 / BLOCK_SIZE; bx <= x1 / BLOCK_SIZE; bx++) { if (type&~BL_MOB) { - for (bl = maplist[m].block[bx + by * maplist[m].bxs]; bl != NULL; bl = bl->next) { - if (bl_list_count < BL_LIST_MAX + for (bl = map->list[m].block[bx + by * map->list[m].bxs]; bl != NULL; bl = bl->next) { + if (map->bl_list_count < BL_LIST_MAX && bl->type&type && bl->x >= x0 && bl->x <= x1 && bl->y >= y0 && bl->y <= y1) { if (func) { va_start(args, func); if (func(bl, args)) { - bl_list[bl_list_count++] = bl; + map->bl_list[map->bl_list_count++] = bl; found++; } va_end(args); } else { - bl_list[bl_list_count++] = bl; + map->bl_list[map->bl_list_count++] = bl; found++; } } } } if (type&BL_MOB) { // TODO: fix this code duplication - for (bl = maplist[m].block_mob[bx + by * maplist[m].bxs]; bl != NULL; bl = bl->next) { - if (bl_list_count < BL_LIST_MAX + for (bl = map->list[m].block_mob[bx + by * map->list[m].bxs]; bl != NULL; bl = bl->next) { + if (map->bl_list_count < BL_LIST_MAX //&& bl->type&type // block_mob contains BL_MOBs only && bl->x >= x0 && bl->x <= x1 && bl->y >= y0 && bl->y <= y1) { if (func) { va_start(args, func); if (func(bl, args)) { - bl_list[bl_list_count++] = bl; + map->bl_list[map->bl_list_count++] = bl; found++; } va_end(args); } else { - bl_list[bl_list_count++] = bl; + map->bl_list[map->bl_list_count++] = bl; found++; } } @@ -729,7 +638,7 @@ static int bl_getall_area(int type, int m, int x0, int y0, int x1, int y1, int ( } } - if (bl_list_count >= BL_LIST_MAX) + if (map->bl_list_count >= BL_LIST_MAX) ShowError("map.c:bl_getall_area: bl_list size (%d) exceeded\n", BL_LIST_MAX); return found; @@ -765,7 +674,7 @@ static int bl_vgetall_inrange(struct block_list *bl, va_list args) */ int map_vforeachinrange(int (*func)(struct block_list*, va_list), struct block_list* center, int16 range, int type, va_list ap) { int returnCount = 0; - int blockcount = bl_list_count; + int blockcount = map->bl_list_count; va_list apcopy; if (range < 0) range *= -1; @@ -817,7 +726,7 @@ int map_foreachinrange(int (*func)(struct block_list*, va_list), struct block_li */ int map_vforcountinrange(int (*func)(struct block_list*, va_list), struct block_list* center, int16 range, int count, int type, va_list ap) { int returnCount = 0; - int blockcount = bl_list_count; + int blockcount = map->bl_list_count; va_list apcopy; if (range < 0) range *= -1; @@ -890,7 +799,7 @@ static int bl_vgetall_inshootrange(struct block_list *bl, va_list args) */ int map_vforeachinshootrange(int (*func)(struct block_list*, va_list), struct block_list* center, int16 range, int type, va_list ap) { int returnCount = 0; - int blockcount = bl_list_count; + int blockcount = map->bl_list_count; va_list apcopy; if (range < 0) range *= -1; @@ -943,7 +852,7 @@ int map_foreachinshootrange(int (*func)(struct block_list*, va_list), struct blo */ int map_vforeachinarea(int (*func)(struct block_list*, va_list), int16 m, int16 x0, int16 y0, int16 x1, int16 y1, int type, va_list ap) { int returnCount = 0; - int blockcount = bl_list_count; + int blockcount = map->bl_list_count; va_list apcopy; bl_getall_area(type, m, x0, y0, x1, y1, NULL); @@ -999,7 +908,7 @@ int map_foreachinarea(int (*func)(struct block_list*, va_list), int16 m, int16 x */ int map_vforcountinarea(int (*func)(struct block_list*,va_list), int16 m, int16 x0, int16 y0, int16 x1, int16 y1, int count, int type, va_list ap) { int returnCount = 0; - int blockcount = bl_list_count; + int blockcount = map->bl_list_count; va_list apcopy; bl_getall_area(type, m, x0, y0, x1, y1, NULL); @@ -1084,7 +993,7 @@ static int bl_vgetall_inmovearea(struct block_list *bl, va_list args) */ int map_vforeachinmovearea(int (*func)(struct block_list*, va_list), struct block_list* center, int16 range, int16 dx, int16 dy, int type, va_list ap) { int returnCount = 0; - int blockcount = bl_list_count; + int blockcount = map->bl_list_count; int m, x0, x1, y0, y1; va_list apcopy; @@ -1165,7 +1074,7 @@ int map_foreachinmovearea(int (*func)(struct block_list*, va_list), struct block */ int map_vforeachincell(int (*func)(struct block_list*, va_list), int16 m, int16 x, int16 y, int type, va_list ap) { int returnCount = 0; - int blockcount = bl_list_count; + int blockcount = map->bl_list_count; va_list apcopy; bl_getall_area(type, m, x, y, x, y, NULL); @@ -1280,7 +1189,7 @@ int map_vforeachinpath(int (*func)(struct block_list*, va_list), int16 m, int16 // kRO int returnCount = 0; - int blockcount = bl_list_count; + int blockcount = map->bl_list_count; va_list apcopy; //method specific variables @@ -1369,7 +1278,7 @@ int map_get_new_object_id(void) if( i == MAX_FLOORITEM ) i = MIN_FLOORITEM; - if( !idb_exists(id_db, i) ) + if( !idb_exists(map->id_db, i) ) break; ++i; @@ -1387,11 +1296,11 @@ int map_get_new_object_id(void) } /*========================================== -* Timered function to clear the floor (remove remaining item) -* Called each flooritem_lifetime ms -*------------------------------------------*/ + * 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) { - struct flooritem_data* fitem = (struct flooritem_data*)idb_get(id_db, id); + struct flooritem_data* fitem = (struct flooritem_data*)idb_get(map->id_db, id); if (fitem == NULL || fitem->bl.type != BL_ITEM || (fitem->cleartimer != tid)) { ShowError("map_clearflooritem_timer : error\n"); @@ -1410,8 +1319,8 @@ int map_clearflooritem_timer(int tid, unsigned int tick, int id, intptr_t data) } /* -* clears a single bl item out of the bazooonga. -*/ + * clears a single bl item out of the bazooonga. + */ void map_clearflooritem(struct block_list *bl) { struct flooritem_data* fitem = (struct flooritem_data*)bl; @@ -1425,19 +1334,19 @@ void map_clearflooritem(struct block_list *bl) { } /*========================================== -* (m,x,y) locates a random available free cell around the given coordinates -* to place an BL_ITEM object. Scan area is 9x9, returns 1 on success. -* x and y are modified with the target cell when successful. -*------------------------------------------*/ + * (m,x,y) locates a random available free cell around the given coordinates + * to place an BL_ITEM object. Scan area is 9x9, returns 1 on success. + * x and y are modified with the target cell when successful. + *------------------------------------------*/ int map_searchrandfreecell(int16 m,int16 *x,int16 *y,int stack) { int free_cell,i,j; int free_cells[9][2]; for(free_cell=0,i=-1;i<=1;i++){ - if(i+*y<0 || i+*y>=maplist[m].ys) + if(i+*y<0 || i+*y>=map->list[m].ys) continue; for(j=-1;j<=1;j++){ - if(j+*x<0 || j+*x>=maplist[m].xs) + if(j+*x<0 || j+*x>=map->list[m].xs) continue; if(map->getcell(m,j+*x,i+*y,CELL_CHKNOPASS) && !map->getcell(m,j+*x,i+*y,CELL_CHKICEWALL)) continue; @@ -1457,23 +1366,22 @@ int map_searchrandfreecell(int16 m,int16 *x,int16 *y,int stack) { } -static int map_count_sub(struct block_list *bl,va_list ap) -{ +int map_count_sub(struct block_list *bl,va_list ap) { return 1; } /*========================================== -* Locates a random spare cell around the object given, using range as max -* distance from that spot. Used for warping functions. Use range < 0 for -* whole map range. -* Returns 1 on success. when it fails and src is available, x/y are set to src's -* src can be null as long as flag&1 -* when ~flag&1, m is not needed. -* Flag values: -* &1 = random cell must be around given m,x,y, not around src -* &2 = the target should be able to walk to the target tile. -* &4 = there shouldn't be any players around the target tile (use the no_spawn_on_player setting) -*------------------------------------------*/ + * Locates a random spare cell around the object given, using range as max + * distance from that spot. Used for warping functions. Use range < 0 for + * whole map range. + * Returns 1 on success. when it fails and src is available, x/y are set to src's + * src can be null as long as flag&1 + * when ~flag&1, m is not needed. + * Flag values: + * &1 = random cell must be around given m,x,y, not around src + * &2 = the target should be able to walk to the target tile. + * &4 = there shouldn't be any players around the target tile (use the no_spawn_on_player setting) + *------------------------------------------*/ int map_search_freecell(struct block_list *src, int16 m, int16 *x,int16 *y, int16 rx, int16 ry, int flag) { int tries, spawn=0; @@ -1506,13 +1414,13 @@ int map_search_freecell(struct block_list *src, int16 m, int16 *x,int16 *y, int1 tries = rx2*ry2; if (tries > 100) tries = 100; } else { - tries = maplist[m].xs*maplist[m].ys; + tries = map->list[m].xs*map->list[m].ys; if (tries > 500) tries = 500; } while(tries--) { - *x = (rx >= 0)?(rnd()%rx2-rx+bx):(rnd()%(maplist[m].xs-2)+1); - *y = (ry >= 0)?(rnd()%ry2-ry+by):(rnd()%(maplist[m].ys-2)+1); + *x = (rx >= 0)?(rnd()%rx2-rx+bx):(rnd()%(map->list[m].xs-2)+1); + *y = (ry >= 0)?(rnd()%ry2-ry+by):(rnd()%(map->list[m].ys-2)+1); if (*x == bx && *y == by) continue; //Avoid picking the same target tile. @@ -1523,7 +1431,7 @@ int map_search_freecell(struct block_list *src, int16 m, int16 *x,int16 *y, int1 if(flag&4) { if (spawn >= 100) return 0; //Limit of retries reached. if (spawn++ < battle_config.no_spawn_on_player - && map->foreachinarea(map_count_sub, m, *x-AREA_SIZE, *y-AREA_SIZE, + && map->foreachinarea(map->count_sub, m, *x-AREA_SIZE, *y-AREA_SIZE, *x+AREA_SIZE, *y+AREA_SIZE, BL_PC) ) continue; @@ -1537,14 +1445,14 @@ int map_search_freecell(struct block_list *src, int16 m, int16 *x,int16 *y, int1 } /*========================================== -* Add an item to location (m,x,y) -* Parameters -* @item_data item attributes -* @amount quantity -* @m, @x, @y mapid,x,y -* @first_charid, @second_charid, @third_charid, looting priority -* @flag: &1 MVP item. &2 do stacking check. -*------------------------------------------*/ + * Add an item to location (m,x,y) + * Parameters + * @item_data item attributes + * @amount quantity + * @m, @x, @y mapid,x,y + * @first_charid, @second_charid, @third_charid, looting priority + * @flag: &1 MVP item. &2 do stacking check. + *------------------------------------------*/ int map_addflooritem(struct item *item_data,int amount,int16 m,int16 x,int16 y,int first_charid,int second_charid,int third_charid,int flags) { int r; @@ -1552,7 +1460,7 @@ int map_addflooritem(struct item *item_data,int amount,int16 m,int16 x,int16 y,i nullpo_ret(item_data); - if(!map_searchrandfreecell(m,&x,&y,flags&2?1:0)) + if(!map->searchrandfreecell(m,&x,&y,flags&2?1:0)) return 0; r=rnd(); @@ -1589,9 +1497,9 @@ int map_addflooritem(struct item *item_data,int amount,int16 m,int16 x,int16 y,i } /** -* @see DBCreateData -*/ -static DBData create_charid2nick(DBKey key, va_list args) + * @see DBCreateData + */ +DBData create_charid2nick(DBKey key, va_list args) { struct charid2nick *p; CREATE(p, struct charid2nick, 1); @@ -1609,7 +1517,7 @@ void map_addnickdb(int charid, const char* nick) if( map->charid2sd(charid) ) return;// already online - p = idb_ensure(nick_db, charid, create_charid2nick); + p = idb_ensure(map->nick_db, charid, map->create_charid2nick); safestrncpy(p->nick, nick, sizeof(p->nick)); while( p->requests ) { @@ -1631,7 +1539,7 @@ void map_delnickdb(int charid, const char* name) struct map_session_data* sd; DBData data; - if (!nick_db->remove(nick_db, DB->i2key(charid), &data) || (p = DB->data2ptr(&data)) == NULL) + if (!map->nick_db->remove(map->nick_db, DB->i2key(charid), &data) || (p = DB->data2ptr(&data)) == NULL) return; while( p->requests ) { @@ -1662,7 +1570,7 @@ void map_reqnickdb(struct map_session_data * sd, int charid) return; } - p = idb_ensure(nick_db, charid, create_charid2nick); + p = idb_ensure(map->nick_db, charid, map->create_charid2nick); if( *p->nick ) { clif->solved_charname(sd->fd, charid, p->nick); return; @@ -1675,8 +1583,8 @@ void map_reqnickdb(struct map_session_data * sd, int charid) } /*========================================== -* add bl to id_db -*------------------------------------------*/ + * add bl to id_db + *------------------------------------------*/ void map_addiddb(struct block_list *bl) { nullpo_retv(bl); @@ -1684,27 +1592,27 @@ void map_addiddb(struct block_list *bl) if( bl->type == BL_PC ) { TBL_PC* sd = (TBL_PC*)bl; - idb_put(pc_db,sd->bl.id,sd); - idb_put(charid_db,sd->status.char_id,sd); + idb_put(map->pc_db,sd->bl.id,sd); + idb_put(map->charid_db,sd->status.char_id,sd); } else if( bl->type == BL_MOB ) { TBL_MOB* md = (TBL_MOB*)bl; - idb_put(mobid_db,bl->id,bl); + idb_put(map->mobid_db,bl->id,bl); if( md->state.boss ) - idb_put(bossid_db, bl->id, bl); + idb_put(map->bossid_db, bl->id, bl); } if( bl->type & BL_REGEN ) - idb_put(regen_db, bl->id, bl); + idb_put(map->regen_db, bl->id, bl); - idb_put(id_db,bl->id,bl); + idb_put(map->id_db,bl->id,bl); } /*========================================== -* remove bl from id_db -*------------------------------------------*/ + * remove bl from id_db + *------------------------------------------*/ void map_deliddb(struct block_list *bl) { nullpo_retv(bl); @@ -1712,24 +1620,24 @@ void map_deliddb(struct block_list *bl) if( bl->type == BL_PC ) { TBL_PC* sd = (TBL_PC*)bl; - idb_remove(pc_db,sd->bl.id); - idb_remove(charid_db,sd->status.char_id); + idb_remove(map->pc_db,sd->bl.id); + idb_remove(map->charid_db,sd->status.char_id); } else if( bl->type == BL_MOB ) { - idb_remove(mobid_db,bl->id); - idb_remove(bossid_db,bl->id); + idb_remove(map->mobid_db,bl->id); + idb_remove(map->bossid_db,bl->id); } if( bl->type & BL_REGEN ) - idb_remove(regen_db,bl->id); + idb_remove(map->regen_db,bl->id); - idb_remove(id_db,bl->id); + idb_remove(map->id_db,bl->id); } /*========================================== -* Standard call when a player connection is closed. -*------------------------------------------*/ + * Standard call when a player connection is closed. + *------------------------------------------*/ int map_quit(struct map_session_data *sd) { int i; @@ -1808,19 +1716,19 @@ int map_quit(struct map_session_data *sd) { unit->remove_map(&sd->ed->bl,CLR_TELEPORT,ALC_MARK); } - if( hChSys.local && maplist[sd->bl.m].channel && idb_exists(maplist[sd->bl.m].channel->users, sd->status.char_id) ) { - clif->chsys_left(maplist[sd->bl.m].channel,sd); + if( hChSys.local && map->list[sd->bl.m].channel && idb_exists(map->list[sd->bl.m].channel->users, sd->status.char_id) ) { + clif->chsys_left(map->list[sd->bl.m].channel,sd); } clif->chsys_quit(sd); unit->remove_map_pc(sd,CLR_RESPAWN); - if( maplist[sd->bl.m].instance_id >= 0 ) { // Avoid map conflicts and warnings on next login + if( map->list[sd->bl.m].instance_id >= 0 ) { // Avoid map conflicts and warnings on next login int16 m; struct point *pt; - if( maplist[sd->bl.m].save.map ) - pt = &maplist[sd->bl.m].save; + if( map->list[sd->bl.m].save.map ) + pt = &map->list[sd->bl.m].save; else pt = &sd->status.save_point; @@ -1845,16 +1753,16 @@ int map_quit(struct map_session_data *sd) { } /*========================================== -* Lookup, id to session (player,mob,npc,homon,merc..) -*------------------------------------------*/ + * Lookup, id to session (player,mob,npc,homon,merc..) + *------------------------------------------*/ struct map_session_data *map_id2sd(int id) { if (id <= 0) return NULL; - return (struct map_session_data*)idb_get(pc_db,id); + return (struct map_session_data*)idb_get(map->pc_db,id); } struct mob_data *map_id2md(int id) { if (id <= 0) return NULL; - return (struct mob_data*)idb_get(mobid_db,id); + return (struct mob_data*)idb_get(map->mobid_db,id); } struct npc_data *map_id2nd(int id) { @@ -1891,7 +1799,7 @@ const char *map_charid2nick(int charid) { if( sd ) return sd->status.name;// character is online, return it's name - p = idb_ensure(nick_db, charid, create_charid2nick); + p = idb_ensure(map->nick_db, charid, map->create_charid2nick); if( *p->nick ) return p->nick;// name in nick_db @@ -1902,14 +1810,14 @@ const char *map_charid2nick(int charid) { /// Returns the struct map_session_data of the charid or NULL if the char is not online. struct map_session_data* map_charid2sd(int charid) { - return (struct map_session_data*)idb_get(charid_db, charid); + return (struct map_session_data*)idb_get(map->charid_db, charid); } /*========================================== -* Search session data from a nick name -* (without sensitive case if necessary) -* return map_session_data pointer or NULL -*------------------------------------------*/ + * Search session data from a nick name + * (without sensitive case if necessary) + * return map_session_data pointer or NULL + *------------------------------------------*/ struct map_session_data * map_nick2sd(const char *nick) { struct map_session_data* sd; @@ -1957,29 +1865,29 @@ struct map_session_data * map_nick2sd(const char *nick) } /*========================================== -* Looksup id_db DBMap and returns BL pointer of 'id' or NULL if not found -*------------------------------------------*/ + * Looksup id_db DBMap and returns BL pointer of 'id' or NULL if not found + *------------------------------------------*/ struct block_list * map_id2bl(int id) { - return (struct block_list*)idb_get(id_db,id); + return (struct block_list*)idb_get(map->id_db,id); } /** -* Same as map->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)); + return (idb_exists(map->id_db,id)); } /*========================================== -* Convext Mirror -*------------------------------------------*/ + * Convext Mirror + *------------------------------------------*/ struct mob_data * map_getmob_boss(int16 m) { DBIterator* iter; struct mob_data *md = NULL; bool found = false; - iter = db_iterator(bossid_db); + iter = db_iterator(map->bossid_db); for( md = (struct mob_data*)dbi_first(iter); dbi_exists(iter); md = (struct mob_data*)dbi_next(iter) ) { if( md->bl.m == m ) @@ -1996,16 +1904,16 @@ struct mob_data * map_getmob_boss(int16 m) struct mob_data * map_id2boss(int id) { if (id <= 0) return NULL; - return (struct mob_data*)idb_get(bossid_db,id); + return (struct mob_data*)idb_get(map->bossid_db,id); } /// Applies func to all the players in the db. /// Stops iterating if func returns -1. -void map_vmap_foreachpc(int (*func)(struct map_session_data* sd, va_list args), va_list args) { +void map_vforeachpc(int (*func)(struct map_session_data* sd, va_list args), va_list args) { DBIterator* iter; struct map_session_data* sd; - iter = db_iterator(pc_db); + iter = db_iterator(map->pc_db); for( sd = dbi_first(iter); dbi_exists(iter); sd = dbi_next(iter) ) { va_list argscopy; @@ -2022,22 +1930,22 @@ void map_vmap_foreachpc(int (*func)(struct map_session_data* sd, va_list args), /// Applies func to all the players in the db. /// Stops iterating if func returns -1. -/// @see map_vmap_foreachpc -void map_map_foreachpc(int (*func)(struct map_session_data* sd, va_list args), ...) { +/// @see map_vforeachpc +void map_foreachpc(int (*func)(struct map_session_data* sd, va_list args), ...) { va_list args; va_start(args, func); - map->vmap_foreachpc(func, args); + map->vforeachpc(func, args); va_end(args); } /// Applies func to all the mobs in the db. /// Stops iterating if func returns -1. -void map_vmap_foreachmob(int (*func)(struct mob_data* md, va_list args), va_list args) { +void map_vforeachmob(int (*func)(struct mob_data* md, va_list args), va_list args) { DBIterator* iter; struct mob_data* md; - iter = db_iterator(mobid_db); + iter = db_iterator(map->mobid_db); for( md = (struct mob_data*)dbi_first(iter); dbi_exists(iter); md = (struct mob_data*)dbi_next(iter) ) { va_list argscopy; int ret; @@ -2053,22 +1961,22 @@ void map_vmap_foreachmob(int (*func)(struct mob_data* md, va_list args), va_list /// Applies func to all the mobs in the db. /// Stops iterating if func returns -1. -/// @see map_vmap_foreachmob -void map_map_foreachmob(int (*func)(struct mob_data* md, va_list args), ...) { +/// @see map_vforeachmob +void map_foreachmob(int (*func)(struct mob_data* md, va_list args), ...) { va_list args; va_start(args, func); - map->vmap_foreachmob(func, args); + map->vforeachmob(func, args); va_end(args); } /// Applies func to all the npcs in the db. /// Stops iterating if func returns -1. -void map_vmap_foreachnpc(int (*func)(struct npc_data* nd, va_list args), va_list args) { +void map_vforeachnpc(int (*func)(struct npc_data* nd, va_list args), va_list args) { DBIterator* iter; struct block_list* bl; - iter = db_iterator(id_db); + iter = db_iterator(map->id_db); for( bl = (struct block_list*)dbi_first(iter); dbi_exists(iter); bl = (struct block_list*)dbi_next(iter) ) { if( bl->type == BL_NPC ) { struct npc_data* nd = (struct npc_data*)bl; @@ -2087,22 +1995,22 @@ void map_vmap_foreachnpc(int (*func)(struct npc_data* nd, va_list args), va_list /// Applies func to all the npcs in the db. /// Stops iterating if func returns -1. -/// @see map_vmap_foreachnpc -void map_map_foreachnpc(int (*func)(struct npc_data* nd, va_list args), ...) { +/// @see map_vforeachnpc +void map_foreachnpc(int (*func)(struct npc_data* nd, va_list args), ...) { va_list args; va_start(args, func); - map->vmap_foreachnpc(func, args); + map->vforeachnpc(func, args); va_end(args); } /// Applies func to everything in the db. /// Stops iteratin gif func returns -1. -void map_vmap_foreachregen(int (*func)(struct block_list* bl, va_list args), va_list args) { +void map_vforeachregen(int (*func)(struct block_list* bl, va_list args), va_list args) { DBIterator* iter; struct block_list* bl; - iter = db_iterator(regen_db); + iter = db_iterator(map->regen_db); for( bl = (struct block_list*)dbi_first(iter); dbi_exists(iter); bl = (struct block_list*)dbi_next(iter) ) { va_list argscopy; int ret; @@ -2118,22 +2026,22 @@ void map_vmap_foreachregen(int (*func)(struct block_list* bl, va_list args), va_ /// Applies func to everything in the db. /// Stops iteratin gif func returns -1. -/// @see map_vmap_foreachregen -void map_map_foreachregen(int (*func)(struct block_list* bl, va_list args), ...) { +/// @see map_vforeachregen +void map_foreachregen(int (*func)(struct block_list* bl, va_list args), ...) { va_list args; va_start(args, func); - map->vmap_foreachregen(func, args); + map->vforeachregen(func, args); va_end(args); } /// Applies func to everything in the db. /// Stops iterating if func returns -1. -void map_vmap_foreachiddb(int (*func)(struct block_list* bl, va_list args), va_list args) { +void map_vforeachiddb(int (*func)(struct block_list* bl, va_list args), va_list args) { DBIterator* iter; struct block_list* bl; - iter = db_iterator(id_db); + iter = db_iterator(map->id_db); for( bl = (struct block_list*)dbi_first(iter); dbi_exists(iter); bl = (struct block_list*)dbi_next(iter) ) { va_list argscopy; int ret; @@ -2149,12 +2057,12 @@ void map_vmap_foreachiddb(int (*func)(struct block_list* bl, va_list args), va_l /// Applies func to everything in the db. /// Stops iterating if func returns -1. -/// @see map_vmap_foreachiddb -void map_map_foreachiddb(int (*func)(struct block_list* bl, va_list args), ...) { +/// @see map_vforeachiddb +void map_foreachiddb(int (*func)(struct block_list* bl, va_list args), ...) { va_list args; va_start(args, func); - map->vmap_foreachiddb(func, args); + map->vforeachiddb(func, args); va_end(args); } @@ -2188,12 +2096,12 @@ struct s_mapiterator struct s_mapiterator* mapit_alloc(enum e_mapitflags flags, enum bl_type types) { struct s_mapiterator* iter; - iter = ers_alloc(map_iterator_ers, struct s_mapiterator); + iter = ers_alloc(map->iterator_ers, struct s_mapiterator); iter->flags = flags; iter->types = types; - if( types == BL_PC ) iter->dbi = db_iterator(pc_db); - else if( types == BL_MOB ) iter->dbi = db_iterator(mobid_db); - else iter->dbi = db_iterator(id_db); + if( types == BL_PC ) iter->dbi = db_iterator(map->pc_db); + else if( types == BL_MOB ) iter->dbi = db_iterator(map->mobid_db); + else iter->dbi = db_iterator(map->id_db); return iter; } @@ -2204,7 +2112,7 @@ void mapit_free(struct s_mapiterator* iter) { nullpo_retv(iter); dbi_destroy(iter->dbi); - ers_free(map_iterator_ers, iter); + ers_free(map->iterator_ers, iter); } /// Returns the first block_list that matches the description. @@ -2294,35 +2202,35 @@ bool mapit_exists(struct s_mapiterator* iter) { } /*========================================== -* Add npc-bl to id_db, basically register npc to map -*------------------------------------------*/ + * Add npc-bl to id_db, basically register npc to map + *------------------------------------------*/ bool map_addnpc(int16 m,struct npc_data *nd) { nullpo_ret(nd); - if( m < 0 || m >= map->map_num ) + if( m < 0 || m >= map->count ) return false; - if( maplist[m].npc_num == MAX_NPC_PER_MAP ) { - ShowWarning("too many NPCs in one map %s\n",maplist[m].name); + if( map->list[m].npc_num == MAX_NPC_PER_MAP ) { + ShowWarning("too many NPCs in one map %s\n",map->list[m].name); return false; } - maplist[m].npc[maplist[m].npc_num]=nd; - maplist[m].npc_num++; - idb_put(id_db,nd->bl.id,nd); + map->list[m].npc[map->list[m].npc_num]=nd; + map->list[m].npc_num++; + idb_put(map->id_db,nd->bl.id,nd); return true; } /*========================================= -* Dynamic Mobs [Wizputer] -*-----------------------------------------*/ + * Dynamic Mobs [Wizputer] + *-----------------------------------------*/ // Stores the spawn data entry in the mob list. // Returns the index of successful, or -1 if the list was full. int map_addmobtolist(unsigned short m, struct spawn_data *spawn) { size_t i; - ARR_FIND( 0, MAX_MOB_LIST_PER_MAP, i, maplist[m].moblist[i] == NULL ); + ARR_FIND( 0, MAX_MOB_LIST_PER_MAP, i, map->list[m].moblist[i] == NULL ); if( i < MAX_MOB_LIST_PER_MAP ) { - maplist[m].moblist[i] = spawn; + map->list[m].moblist[i] = spawn; return i; } return -1; @@ -2330,20 +2238,20 @@ int map_addmobtolist(unsigned short m, struct spawn_data *spawn) { void map_spawnmobs(int16 m) { int i, k=0; - if (maplist[m].mob_delete_timer != INVALID_TIMER) { + if (map->list[m].mob_delete_timer != INVALID_TIMER) { //Mobs have not been removed yet [Skotlex] - timer->delete(maplist[m].mob_delete_timer, map->removemobs_timer); - maplist[m].mob_delete_timer = INVALID_TIMER; + timer->delete(map->list[m].mob_delete_timer, map->removemobs_timer); + map->list[m].mob_delete_timer = INVALID_TIMER; return; } for(i=0; i<MAX_MOB_LIST_PER_MAP; i++) - if(maplist[m].moblist[i]!=NULL) { - k+=maplist[m].moblist[i]->num; - npc->parse_mob2(maplist[m].moblist[i]); + if(map->list[m].moblist[i]!=NULL) { + k+=map->list[m].moblist[i]->num; + npc->parse_mob2(map->list[m].moblist[i]); } if (battle_config.etc_log && k > 0) { - ShowStatus("Map %s: Spawned '"CL_WHITE"%d"CL_RESET"' mobs.\n",maplist[m].name, k); + ShowStatus("Map %s: Spawned '"CL_WHITE"%d"CL_RESET"' mobs.\n",map->list[m].name, k); } } @@ -2379,36 +2287,36 @@ int map_removemobs_timer(int tid, unsigned int tick, int id, intptr_t data) int count; const int16 m = id; - if (m < 0 || m >= map->map_num) { //Incorrect map id! + if (m < 0 || m >= map->count) { //Incorrect map id! ShowError("map_removemobs_timer error: timer %d points to invalid map %d\n",tid, m); return 0; } - if (maplist[m].mob_delete_timer != tid) { //Incorrect timer call! - ShowError("map_removemobs_timer mismatch: %d != %d (map %s)\n",maplist[m].mob_delete_timer, tid, maplist[m].name); + if (map->list[m].mob_delete_timer != tid) { //Incorrect timer call! + ShowError("map_removemobs_timer mismatch: %d != %d (map %s)\n",map->list[m].mob_delete_timer, tid, map->list[m].name); return 0; } - maplist[m].mob_delete_timer = INVALID_TIMER; - if (maplist[m].users > 0) //Map not empty! + map->list[m].mob_delete_timer = INVALID_TIMER; + if (map->list[m].users > 0) //Map not empty! return 1; - count = map->foreachinmap(map_removemobs_sub, m, BL_MOB); + count = map->foreachinmap(map->removemobs_sub, m, BL_MOB); if (battle_config.etc_log && count > 0) - ShowStatus("Map %s: Removed '"CL_WHITE"%d"CL_RESET"' mobs.\n",maplist[m].name, count); + ShowStatus("Map %s: Removed '"CL_WHITE"%d"CL_RESET"' mobs.\n",map->list[m].name, count); return 1; } void map_removemobs(int16 m) { - if (maplist[m].mob_delete_timer != INVALID_TIMER) // should never happen + if (map->list[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, map->removemobs_timer, m, 0); + map->list[m].mob_delete_timer = timer->add(timer->gettick()+battle_config.mob_remove_delay, map->removemobs_timer, m, 0); } /*========================================== -* Hookup, get map_id from map_name -*------------------------------------------*/ + * Hookup, get map_id from map_name + *------------------------------------------*/ int16 map_mapname2mapid(const char* name) { unsigned short map_index; map_index = mapindex_name2id(name); @@ -2418,23 +2326,23 @@ int16 map_mapname2mapid(const char* name) { } /*========================================== -* Returns the map of the given mapindex. [Skotlex] -*------------------------------------------*/ + * Returns the map of the given mapindex. [Skotlex] + *------------------------------------------*/ int16 map_mapindex2mapid(unsigned short mapindex) { if (!mapindex || mapindex > MAX_MAPINDEX) return -1; - return index2mapid[mapindex]; + return map->index2mapid[mapindex]; } /*========================================== -* Switching Ip, port ? (like changing map_server) get ip/port from map_name -*------------------------------------------*/ + * Switching Ip, port ? (like changing map_server) get ip/port from map_name + *------------------------------------------*/ int map_mapname2ipport(unsigned short name, uint32* ip, uint16* port) { struct map_data_other_server *mdos; - mdos = (struct map_data_other_server*)uidb_get(map_db,(unsigned int)name); + mdos = (struct map_data_other_server*)uidb_get(map->map_db,(unsigned int)name); if(mdos==NULL || mdos->cell) //If gat isn't null, this is a local map. return -1; *ip=mdos->ip; @@ -2450,21 +2358,21 @@ int map_check_dir(int s_dir,int t_dir) if(s_dir == t_dir) return 0; switch(s_dir) { - case 0: if(t_dir == 7 || t_dir == 1 || t_dir == 0) return 0; break; - case 1: if(t_dir == 0 || t_dir == 2 || t_dir == 1) return 0; break; - case 2: if(t_dir == 1 || t_dir == 3 || t_dir == 2) return 0; break; - case 3: if(t_dir == 2 || t_dir == 4 || t_dir == 3) return 0; break; - case 4: if(t_dir == 3 || t_dir == 5 || t_dir == 4) return 0; break; - case 5: if(t_dir == 4 || t_dir == 6 || t_dir == 5) return 0; break; - case 6: if(t_dir == 5 || t_dir == 7 || t_dir == 6) return 0; break; - case 7: if(t_dir == 6 || t_dir == 0 || t_dir == 7) return 0; break; + case 0: if(t_dir == 7 || t_dir == 1 || t_dir == 0) return 0; break; + case 1: if(t_dir == 0 || t_dir == 2 || t_dir == 1) return 0; break; + case 2: if(t_dir == 1 || t_dir == 3 || t_dir == 2) return 0; break; + case 3: if(t_dir == 2 || t_dir == 4 || t_dir == 3) return 0; break; + case 4: if(t_dir == 3 || t_dir == 5 || t_dir == 4) return 0; break; + case 5: if(t_dir == 4 || t_dir == 6 || t_dir == 5) return 0; break; + case 6: if(t_dir == 5 || t_dir == 7 || t_dir == 6) return 0; break; + case 7: if(t_dir == 6 || t_dir == 0 || t_dir == 7) return 0; break; } return 1; } /*========================================== -* Returns the direction of the given cell, relative to 'src' -*------------------------------------------*/ + * Returns the direction of the given cell, relative to 'src' + *------------------------------------------*/ uint8 map_calc_dir(struct block_list* src, int16 x, int16 y) { uint8 dir = 0; @@ -2508,9 +2416,9 @@ uint8 map_calc_dir(struct block_list* src, int16 x, int16 y) } /*========================================== -* Randomizes target cell x,y to a random walkable cell that -* has the same distance from object as given coordinates do. [Skotlex] -*------------------------------------------*/ + * Randomizes target cell x,y to a random walkable cell that + * has the same distance from object as given coordinates do. [Skotlex] + *------------------------------------------*/ int map_random_dir(struct block_list *bl, int16 *x, int16 *y) { short xi = *x-bl->x; @@ -2546,13 +2454,13 @@ inline static struct mapcell map_gat2cell(int gat) { memset(&cell,0,sizeof(struct mapcell)); switch( gat ) { - case 0: cell.walkable = 1; cell.shootable = 1; cell.water = 0; break; // walkable ground - case 1: cell.walkable = 0; cell.shootable = 0; cell.water = 0; break; // non-walkable ground - case 2: cell.walkable = 1; cell.shootable = 1; cell.water = 0; break; // ??? - case 3: cell.walkable = 1; cell.shootable = 1; cell.water = 1; break; // walkable water - case 4: cell.walkable = 1; cell.shootable = 1; cell.water = 0; break; // ??? - case 5: cell.walkable = 0; cell.shootable = 1; cell.water = 0; break; // gap (snipable) - case 6: cell.walkable = 1; cell.shootable = 1; cell.water = 0; break; // ??? + case 0: cell.walkable = 1; cell.shootable = 1; cell.water = 0; break; // walkable ground + case 1: cell.walkable = 0; cell.shootable = 0; cell.water = 0; break; // non-walkable ground + case 2: cell.walkable = 1; cell.shootable = 1; cell.water = 0; break; // ??? + case 3: cell.walkable = 1; cell.shootable = 1; cell.water = 1; break; // walkable water + case 4: cell.walkable = 1; cell.shootable = 1; cell.water = 0; break; // ??? + case 5: cell.walkable = 0; cell.shootable = 1; cell.water = 0; break; // gap (snipable) + case 6: cell.walkable = 1; cell.shootable = 1; cell.water = 0; break; // ??? default: ShowWarning("map_gat2cell: unrecognized gat type '%d'\n", gat); break; @@ -2561,7 +2469,7 @@ inline static struct mapcell map_gat2cell(int gat) { return cell; } -static int map_cell2gat(struct mapcell cell) { +int map_cell2gat(struct mapcell cell) { if( cell.walkable == 1 && cell.shootable == 1 && cell.water == 0 ) return 0; if( cell.walkable == 0 && cell.shootable == 0 && cell.water == 0 ) return 1; if( cell.walkable == 1 && cell.shootable == 1 && cell.water == 1 ) return 3; @@ -2570,8 +2478,6 @@ static int map_cell2gat(struct mapcell cell) { ShowWarning("map_cell2gat: cell has no matching gat type\n"); return 1; // default to 'wall' } -int map_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); void map_cellfromcache(struct map_data *m) { char decode_buffer[MAX_MAP_SIZE]; struct map_cache_map_info *info = NULL; @@ -2587,10 +2493,10 @@ void map_cellfromcache(struct map_data *m) { CREATE(m->cell, struct mapcell, size); for( xy = 0; xy < size; ++xy ) - m->cell[xy] = map_gat2cell(decode_buffer[xy]); + m->cell[xy] = map->gat2cell(decode_buffer[xy]); - m->getcellp = map_getcellp; - m->setcell = map_setcell; + m->getcellp = map->getcellp; + m->setcell = map->setcell; for(i = 0; i < m->npc_num; i++) { npc->setcells(m->npc[i]); @@ -2599,10 +2505,10 @@ void map_cellfromcache(struct map_data *m) { } /*========================================== -* Confirm if celltype in (m,x,y) match the one given in cellchk -*------------------------------------------*/ + * 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 >= map->map_num) ? 0 : maplist[m].getcellp(&maplist[m],x,y,cellchk); + return (m < 0 || m >= map->count) ? 0 : map->list[m].getcellp(&map->list[m],x,y,cellchk); } int map_getcellp(struct map_data* m,int16 x,int16 y,cell_chk cellchk) { @@ -2619,7 +2525,7 @@ int map_getcellp(struct map_data* m,int16 x,int16 y,cell_chk cellchk) { switch(cellchk) { // gat type retrieval case CELL_GETTYPE: - return map_cell2gat(cell); + return map->cell2gat(cell); // base gat type checks case CELL_CHKWALL: @@ -2678,69 +2584,67 @@ 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) { map->cellfromcache(m); - m->getcellp = map_getcellp; - m->setcell = map_setcell; + m->getcellp = map->getcellp; + m->setcell = map->setcell; return m->getcellp(m,x,y,cellchk); } /*========================================== -* Change the type/flags of a map cell -* 'cell' - which flag to modify -* 'flag' - true = on, false = off -*------------------------------------------*/ + * Change the type/flags of a map cell + * 'cell' - which flag to modify + * 'flag' - true = on, false = off + *------------------------------------------*/ void map_setcell(int16 m, int16 x, int16 y, cell_t cell, bool flag) { int j; - if( m < 0 || m >= map->map_num || x < 0 || x >= maplist[m].xs || y < 0 || y >= maplist[m].ys ) + if( m < 0 || m >= map->count || x < 0 || x >= map->list[m].xs || y < 0 || y >= map->list[m].ys ) return; - j = x + y*maplist[m].xs; + j = x + y*map->list[m].xs; switch( cell ) { - case CELL_WALKABLE: maplist[m].cell[j].walkable = flag; break; - case CELL_SHOOTABLE: maplist[m].cell[j].shootable = flag; break; - case CELL_WATER: maplist[m].cell[j].water = flag; break; - - case CELL_NPC: maplist[m].cell[j].npc = flag; break; - case CELL_BASILICA: maplist[m].cell[j].basilica = flag; break; - case CELL_LANDPROTECTOR: maplist[m].cell[j].landprotector = flag; break; - case CELL_NOVENDING: maplist[m].cell[j].novending = flag; break; - case CELL_NOCHAT: maplist[m].cell[j].nochat = flag; break; - case CELL_MAELSTROM: maplist[m].cell[j].maelstrom = flag; break; - case CELL_ICEWALL: maplist[m].cell[j].icewall = flag; break; + case CELL_WALKABLE: map->list[m].cell[j].walkable = flag; break; + case CELL_SHOOTABLE: map->list[m].cell[j].shootable = flag; break; + case CELL_WATER: map->list[m].cell[j].water = flag; break; + + case CELL_NPC: map->list[m].cell[j].npc = flag; break; + case CELL_BASILICA: map->list[m].cell[j].basilica = flag; break; + case CELL_LANDPROTECTOR: map->list[m].cell[j].landprotector = flag; break; + case CELL_NOVENDING: map->list[m].cell[j].novending = flag; break; + case CELL_NOCHAT: map->list[m].cell[j].nochat = flag; break; + case CELL_MAELSTROM: map->list[m].cell[j].maelstrom = flag; break; + case CELL_ICEWALL: map->list[m].cell[j].icewall = flag; break; default: ShowWarning("map_setcell: invalid cell type '%d'\n", (int)cell); break; } } void map_sub_setcell(int16 m, int16 x, int16 y, cell_t cell, bool flag) { - if( m < 0 || m >= map->map_num || x < 0 || x >= maplist[m].xs || y < 0 || y >= maplist[m].ys ) + if( m < 0 || m >= map->count || x < 0 || x >= map->list[m].xs || y < 0 || y >= map->list[m].ys ) return; - map->cellfromcache(&maplist[m]); - maplist[m].setcell = map_setcell; - maplist[m].getcellp = map_getcellp; - maplist[m].setcell(m,x,y,cell,flag); + map->cellfromcache(&map->list[m]); + map->list[m].setcell = map->setcell; + map->list[m].getcellp = map->getcellp; + map->list[m].setcell(m,x,y,cell,flag); } void map_setgatcell(int16 m, int16 x, int16 y, int gat) { int j; struct mapcell cell; - if( m < 0 || m >= map->map_num || x < 0 || x >= maplist[m].xs || y < 0 || y >= maplist[m].ys ) + if( m < 0 || m >= map->count || x < 0 || x >= map->list[m].xs || y < 0 || y >= map->list[m].ys ) return; - j = x + y*maplist[m].xs; + j = x + y*map->list[m].xs; - cell = map_gat2cell(gat); - maplist[m].cell[j].walkable = cell.walkable; - maplist[m].cell[j].shootable = cell.shootable; - maplist[m].cell[j].water = cell.water; + cell = map->gat2cell(gat); + map->list[m].cell[j].walkable = cell.walkable; + map->list[m].cell[j].shootable = cell.shootable; + map->list[m].cell[j].water = cell.water; } /*========================================== * Invisible Walls *------------------------------------------*/ -static DBMap* iwall_db; - void map_iwall_nextxy(int16 x, int16 y, int8 dir, int pos, int16 *x1, int16 *y1) { if( dir == 0 || dir == 4 ) @@ -2767,7 +2671,7 @@ bool map_iwall_set(int16 m, int16 x, int16 y, int size, int8 dir, bool shootable if( size < 1 || !wall_name ) return false; - if( (iwall = (struct iwall_data *)strdb_get(iwall_db, wall_name)) != NULL ) + if( (iwall = (struct iwall_data *)strdb_get(map->iwall_db, wall_name)) != NULL ) return false; // Already Exists if( map->getcell(m, x, y, CELL_CHKNOREACH) ) @@ -2783,21 +2687,21 @@ bool map_iwall_set(int16 m, int16 x, int16 y, int size, int8 dir, bool shootable safestrncpy(iwall->wall_name, wall_name, sizeof(iwall->wall_name)); for( i = 0; i < size; i++ ) { - map_iwall_nextxy(x, y, dir, i, &x1, &y1); + map->iwall_nextxy(x, y, dir, i, &x1, &y1); 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); + map->list[m].setcell(m, x1, y1, CELL_WALKABLE, false); + map->list[m].setcell(m, x1, y1, CELL_SHOOTABLE, shootable); clif->changemapcell(0, m, x1, y1, map->getcell(m, x1, y1, CELL_GETTYPE), ALL_SAMEMAP); } iwall->size = i; - strdb_put(iwall_db, iwall->wall_name, iwall); - maplist[m].iwall_num++; + strdb_put(map->iwall_db, iwall->wall_name, iwall); + map->list[m].iwall_num++; return true; } @@ -2808,16 +2712,16 @@ void map_iwall_get(struct map_session_data *sd) { int16 x1, y1; int i; - if( maplist[sd->bl.m].iwall_num < 1 ) + if( map->list[sd->bl.m].iwall_num < 1 ) return; - iter = db_iterator(iwall_db); + iter = db_iterator(map->iwall_db); for( iwall = dbi_first(iter); dbi_exists(iter); iwall = dbi_next(iter) ) { if( iwall->m != sd->bl.m ) continue; for( i = 0; i < iwall->size; i++ ) { - map_iwall_nextxy(iwall->x, iwall->y, iwall->dir, i, &x1, &y1); + map->iwall_nextxy(iwall->x, iwall->y, iwall->dir, i, &x1, &y1); clif->changemapcell(sd->fd, iwall->m, x1, y1, map->getcell(iwall->m, x1, y1, CELL_GETTYPE), SELF); } } @@ -2829,26 +2733,26 @@ void map_iwall_remove(const char *wall_name) struct iwall_data *iwall; int16 i, x1, y1; - if( (iwall = (struct iwall_data *)strdb_get(iwall_db, wall_name)) == NULL ) + if( (iwall = (struct iwall_data *)strdb_get(map->iwall_db, wall_name)) == NULL ) return; // Nothing to do for( i = 0; i < iwall->size; i++ ) { - map_iwall_nextxy(iwall->x, iwall->y, iwall->dir, i, &x1, &y1); + map->iwall_nextxy(iwall->x, iwall->y, iwall->dir, i, &x1, &y1); - maplist[iwall->m].setcell(iwall->m, x1, y1, CELL_SHOOTABLE, true); - maplist[iwall->m].setcell(iwall->m, x1, y1, CELL_WALKABLE, true); + map->list[iwall->m].setcell(iwall->m, x1, y1, CELL_SHOOTABLE, true); + map->list[iwall->m].setcell(iwall->m, x1, y1, CELL_WALKABLE, true); clif->changemapcell(0, iwall->m, x1, y1, map->getcell(iwall->m, x1, y1, CELL_GETTYPE), ALL_SAMEMAP); } - maplist[iwall->m].iwall_num--; - strdb_remove(iwall_db, iwall->wall_name); + map->list[iwall->m].iwall_num--; + strdb_remove(map->iwall_db, iwall->wall_name); } /** -* @see DBCreateData -*/ -static DBData create_map_data_other_server(DBKey key, va_list args) + * @see DBCreateData + */ +DBData create_map_data_other_server(DBKey key, va_list args) { struct map_data_other_server *mdos; unsigned short mapindex = (unsigned short)key.ui; @@ -2859,13 +2763,13 @@ static DBData create_map_data_other_server(DBKey key, va_list args) } /*========================================== -* Add mapindex to db of another map server -*------------------------------------------*/ + * Add mapindex to db of another map server + *------------------------------------------*/ int map_setipport(unsigned short mapindex, uint32 ip, uint16 port) { struct map_data_other_server *mdos; - mdos= uidb_ensure(map_db,(unsigned int)mapindex, create_map_data_other_server); + mdos= uidb_ensure(map->map_db,(unsigned int)mapindex, map->create_map_data_other_server); if(mdos->cell) //Local map,Do nothing. Give priority to our own local maps over ones from another server. [Skotlex] return 0; @@ -2880,36 +2784,36 @@ int map_setipport(unsigned short mapindex, uint32 ip, uint16 port) } /** -* Delete all the other maps server management -* @see DBApply -*/ + * Delete all the other maps server management + * @see DBApply + */ int map_eraseallipport_sub(DBKey key, DBData *data, va_list va) { struct map_data_other_server *mdos = DB->data2ptr(data); if(mdos->cell == NULL) { - db_remove(map_db,key); + db_remove(map->map_db,key); aFree(mdos); } return 0; } int map_eraseallipport(void) { - map_db->foreach(map_db,map_eraseallipport_sub); + map->map_db->foreach(map->map_db,map->eraseallipport_sub); return 1; } /*========================================== -* Delete mapindex from db of another map server -*------------------------------------------*/ + * Delete mapindex from db of another map server + *------------------------------------------*/ int map_eraseipport(unsigned short mapindex, uint32 ip, uint16 port) { struct map_data_other_server *mdos; - mdos = (struct map_data_other_server*)uidb_get(map_db,(unsigned int)mapindex); + mdos = (struct map_data_other_server*)uidb_get(map->map_db,(unsigned int)mapindex); if(!mdos || mdos->cell) //Map either does not exists or is a local map. return 0; if(mdos->ip==ip && mdos->port == port) { - uidb_remove(map_db,(unsigned int)mapindex); + uidb_remove(map->map_db,(unsigned int)mapindex); aFree(mdos); return 1; } @@ -2917,10 +2821,9 @@ int map_eraseipport(unsigned short mapindex, uint32 ip, uint16 port) { } /*========================================== -* [Shinryo]: Init the mapcache -*------------------------------------------*/ -static char *map_init_mapcache(FILE *fp) -{ + * [Shinryo]: Init the mapcache + *------------------------------------------*/ +char *map_init_mapcache(FILE *fp) { size_t size = 0; char *buffer; @@ -2948,9 +2851,9 @@ static char *map_init_mapcache(FILE *fp) } /*========================================== -* Map cache reading -* [Shinryo]: Optimized some behaviour to speed this up -*==========================================*/ + * Map cache reading + * [Shinryo]: Optimized some behaviour to speed this up + *==========================================*/ int map_readfromcache(struct map_data *m, char *buffer) { int i; struct map_cache_main_header *header = (struct map_cache_main_header *)buffer; @@ -2993,15 +2896,15 @@ int map_readfromcache(struct map_data *m, char *buffer) { int map_addmap(char* mapname) { - maplist[map->map_num].instance_id = -1; - mapindex_getmapname(mapname, maplist[map->map_num++].name); + map->list[map->count].instance_id = -1; + mapindex_getmapname(mapname, map->list[map->count++].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])*(map->map_num-id-1)); - map->map_num--; +void map_delmapid(int id) { + ShowNotice("Removing map [ %s ] from map->list"CL_CLL"\n",map->list[id].name); + memmove(map->list+id, map->list+id+1, sizeof(map->list[0])*(map->count-id-1)); + map->count--; } int map_delmap(char* mapname) { @@ -3009,14 +2912,14 @@ int map_delmap(char* mapname) { char map_name[MAP_NAME_LENGTH]; if (strcmpi(mapname, "all") == 0) { - map->map_num = 0; + map->count = 0; return 0; } mapindex_getmapname(mapname, map_name); - for(i = 0; i < map->map_num; i++) { - if (strcmp(maplist[i].name, map_name) == 0) { - map_delmapid(i); + for(i = 0; i < map->count; i++) { + if (strcmp(map->list[i].name, map_name) == 0) { + map->delmapid(i); return 1; } } @@ -3026,7 +2929,7 @@ void map_zone_db_clear(void) { struct map_zone_data *zone; int i; - DBIterator *iter = db_iterator(zone_db); + DBIterator *iter = db_iterator(map->zone_db); for(zone = dbi_first(iter); dbi_exists(iter); zone = dbi_next(iter)) { for(i = 0; i < zone->disabled_skills_count; i++) { aFree(zone->disabled_skills[i]); @@ -3048,229 +2951,229 @@ void map_zone_db_clear(void) { } dbi_destroy(iter); - db_destroy(zone_db);/* will aFree(zone) */ + db_destroy(map->zone_db);/* will aFree(zone) */ /* clear the pk zone stuff */ - for(i = 0; i < map_zone_pk.disabled_skills_count; i++) { - aFree(map_zone_pk.disabled_skills[i]); + for(i = 0; i < map->zone_pk.disabled_skills_count; i++) { + aFree(map->zone_pk.disabled_skills[i]); } - aFree(map_zone_pk.disabled_skills); - aFree(map_zone_pk.disabled_items); - for(i = 0; i < map_zone_pk.mapflags_count; i++) { - aFree(map_zone_pk.mapflags[i]); + aFree(map->zone_pk.disabled_skills); + aFree(map->zone_pk.disabled_items); + for(i = 0; i < map->zone_pk.mapflags_count; i++) { + aFree(map->zone_pk.mapflags[i]); } - aFree(map_zone_pk.mapflags); - for(i = 0; i < map_zone_pk.disabled_commands_count; i++) { - aFree(map_zone_pk.disabled_commands[i]); + aFree(map->zone_pk.mapflags); + for(i = 0; i < map->zone_pk.disabled_commands_count; i++) { + aFree(map->zone_pk.disabled_commands[i]); } - aFree(map_zone_pk.disabled_commands); - for(i = 0; i < map_zone_pk.capped_skills_count; i++) { - aFree(map_zone_pk.capped_skills[i]); + aFree(map->zone_pk.disabled_commands); + for(i = 0; i < map->zone_pk.capped_skills_count; i++) { + aFree(map->zone_pk.capped_skills[i]); } - aFree(map_zone_pk.capped_skills); + aFree(map->zone_pk.capped_skills); /* clear the main zone stuff */ - for(i = 0; i < map_zone_all.disabled_skills_count; i++) { - aFree(map_zone_all.disabled_skills[i]); + for(i = 0; i < map->zone_all.disabled_skills_count; i++) { + aFree(map->zone_all.disabled_skills[i]); } - aFree(map_zone_all.disabled_skills); - aFree(map_zone_all.disabled_items); - for(i = 0; i < map_zone_all.mapflags_count; i++) { - aFree(map_zone_all.mapflags[i]); + aFree(map->zone_all.disabled_skills); + aFree(map->zone_all.disabled_items); + for(i = 0; i < map->zone_all.mapflags_count; i++) { + aFree(map->zone_all.mapflags[i]); } - aFree(map_zone_all.mapflags); - for(i = 0; i < map_zone_all.disabled_commands_count; i++) { - aFree(map_zone_all.disabled_commands[i]); + aFree(map->zone_all.mapflags); + for(i = 0; i < map->zone_all.disabled_commands_count; i++) { + aFree(map->zone_all.disabled_commands[i]); } - aFree(map_zone_all.disabled_commands); - for(i = 0; i < map_zone_all.capped_skills_count; i++) { - aFree(map_zone_all.capped_skills[i]); + aFree(map->zone_all.disabled_commands); + for(i = 0; i < map->zone_all.capped_skills_count; i++) { + aFree(map->zone_all.capped_skills[i]); } - aFree(map_zone_all.capped_skills); + aFree(map->zone_all.capped_skills); } void map_clean(int i) { int v; - if(maplist[i].cell && maplist[i].cell != (struct mapcell *)0xdeadbeaf) aFree(maplist[i].cell); - if(maplist[i].block) aFree(maplist[i].block); - if(maplist[i].block_mob) aFree(maplist[i].block_mob); + if(map->list[i].cell && map->list[i].cell != (struct mapcell *)0xdeadbeaf) aFree(map->list[i].cell); + if(map->list[i].block) aFree(map->list[i].block); + if(map->list[i].block_mob) aFree(map->list[i].block_mob); 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, map->removemobs_timer); + if(map->list[i].mob_delete_timer != INVALID_TIMER) + timer->delete(map->list[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]); + if (map->list[i].moblist[j]) aFree(map->list[i].moblist[j]); } - if( maplist[i].unit_count ) { - for(v = 0; v < maplist[i].unit_count; v++) { - aFree(maplist[i].units[v]); + if( map->list[i].unit_count ) { + for(v = 0; v < map->list[i].unit_count; v++) { + aFree(map->list[i].units[v]); } - if( maplist[i].units ) { - aFree(maplist[i].units); - maplist[i].units = NULL; + if( map->list[i].units ) { + aFree(map->list[i].units); + map->list[i].units = NULL; } - maplist[i].unit_count = 0; + map->list[i].unit_count = 0; } - if( maplist[i].skill_count ) { - for(v = 0; v < maplist[i].skill_count; v++) { - aFree(maplist[i].skills[v]); + if( map->list[i].skill_count ) { + for(v = 0; v < map->list[i].skill_count; v++) { + aFree(map->list[i].skills[v]); } - if( maplist[i].skills ) { - aFree(maplist[i].skills); - maplist[i].skills = NULL; + if( map->list[i].skills ) { + aFree(map->list[i].skills); + map->list[i].skills = NULL; } - maplist[i].skill_count = 0; + map->list[i].skill_count = 0; } - if( maplist[i].zone_mf_count ) { - for(v = 0; v < maplist[i].zone_mf_count; v++) { - aFree(maplist[i].zone_mf[v]); + if( map->list[i].zone_mf_count ) { + for(v = 0; v < map->list[i].zone_mf_count; v++) { + aFree(map->list[i].zone_mf[v]); } - if( maplist[i].zone_mf ) { - aFree(maplist[i].zone_mf); - maplist[i].zone_mf = NULL; + if( map->list[i].zone_mf ) { + aFree(map->list[i].zone_mf); + map->list[i].zone_mf = NULL; } - maplist[i].zone_mf_count = 0; + map->list[i].zone_mf_count = 0; } - if( maplist[i].channel ) - clif->chsys_delete(maplist[i].channel); + if( map->list[i].channel ) + clif->chsys_delete(map->list[i].channel); } void do_final_maps(void) { int i, v = 0; - for( i = 0; i < map->map_num; i++ ) { + for( i = 0; i < map->count; i++ ) { - if(maplist[i].cell && maplist[i].cell != (struct mapcell *)0xdeadbeaf ) aFree(maplist[i].cell); - if(maplist[i].block) aFree(maplist[i].block); - if(maplist[i].block_mob) aFree(maplist[i].block_mob); + if(map->list[i].cell && map->list[i].cell != (struct mapcell *)0xdeadbeaf ) aFree(map->list[i].cell); + if(map->list[i].block) aFree(map->list[i].block); + if(map->list[i].block_mob) aFree(map->list[i].block_mob); 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, map->removemobs_timer); + if(map->list[i].mob_delete_timer != INVALID_TIMER) + timer->delete(map->list[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]); + if (map->list[i].moblist[j]) aFree(map->list[i].moblist[j]); } - if( maplist[i].unit_count ) { - for(v = 0; v < maplist[i].unit_count; v++) { - aFree(maplist[i].units[v]); + if( map->list[i].unit_count ) { + for(v = 0; v < map->list[i].unit_count; v++) { + aFree(map->list[i].units[v]); } - if( maplist[i].units ) { - aFree(maplist[i].units); - maplist[i].units = NULL; + if( map->list[i].units ) { + aFree(map->list[i].units); + map->list[i].units = NULL; } - maplist[i].unit_count = 0; + map->list[i].unit_count = 0; } - if( maplist[i].skill_count ) { - for(v = 0; v < maplist[i].skill_count; v++) { - aFree(maplist[i].skills[v]); + if( map->list[i].skill_count ) { + for(v = 0; v < map->list[i].skill_count; v++) { + aFree(map->list[i].skills[v]); } - if( maplist[i].skills ) { - aFree(maplist[i].skills); - maplist[i].skills = NULL; + if( map->list[i].skills ) { + aFree(map->list[i].skills); + map->list[i].skills = NULL; } - maplist[i].skill_count = 0; + map->list[i].skill_count = 0; } - if( maplist[i].zone_mf_count ) { - for(v = 0; v < maplist[i].zone_mf_count; v++) { - aFree(maplist[i].zone_mf[v]); + if( map->list[i].zone_mf_count ) { + for(v = 0; v < map->list[i].zone_mf_count; v++) { + aFree(map->list[i].zone_mf[v]); } - if( maplist[i].zone_mf ) { - aFree(maplist[i].zone_mf); - maplist[i].zone_mf = NULL; + if( map->list[i].zone_mf ) { + aFree(map->list[i].zone_mf); + map->list[i].zone_mf = NULL; } - maplist[i].zone_mf_count = 0; + map->list[i].zone_mf_count = 0; } - if( maplist[i].drop_list_count ) { - maplist[i].drop_list_count = 0; + if( map->list[i].drop_list_count ) { + map->list[i].drop_list_count = 0; } - if( maplist[i].drop_list != NULL ) - aFree(maplist[i].drop_list); + if( map->list[i].drop_list != NULL ) + aFree(map->list[i].drop_list); - if( maplist[i].channel ) - clif->chsys_delete(maplist[i].channel); + if( map->list[i].channel ) + clif->chsys_delete(map->list[i].channel); } - map_zone_db_clear(); + map->zone_db_clear(); } /// Initializes map flags and adjusts them depending on configuration. void map_flags_init(void) { int i, v = 0; - for( i = 0; i < map->map_num; i++ ) { + for( i = 0; i < map->count; i++ ) { // mapflags - memset(&maplist[i].flag, 0, sizeof(maplist[i].flag)); + memset(&map->list[i].flag, 0, sizeof(map->list[i].flag)); // additional mapflag data - maplist[i].nocommand = 0; // nocommand mapflag level - maplist[i].bexp = 100; // per map base exp multiplicator - maplist[i].jexp = 100; // per map job exp multiplicator - if( maplist[i].drop_list != NULL ) - aFree(maplist[i].drop_list); - maplist[i].drop_list = NULL; - maplist[i].drop_list_count = 0; - - if( maplist[i].unit_count ) { - for(v = 0; v < maplist[i].unit_count; v++) { - aFree(maplist[i].units[v]); + map->list[i].nocommand = 0; // nocommand mapflag level + map->list[i].bexp = 100; // per map base exp multiplicator + map->list[i].jexp = 100; // per map job exp multiplicator + if( map->list[i].drop_list != NULL ) + aFree(map->list[i].drop_list); + map->list[i].drop_list = NULL; + map->list[i].drop_list_count = 0; + + if( map->list[i].unit_count ) { + for(v = 0; v < map->list[i].unit_count; v++) { + aFree(map->list[i].units[v]); } - aFree(maplist[i].units); + aFree(map->list[i].units); } - maplist[i].units = NULL; - maplist[i].unit_count = 0; + map->list[i].units = NULL; + map->list[i].unit_count = 0; - if( maplist[i].skill_count ) { - for(v = 0; v < maplist[i].skill_count; v++) { - aFree(maplist[i].skills[v]); + if( map->list[i].skill_count ) { + for(v = 0; v < map->list[i].skill_count; v++) { + aFree(map->list[i].skills[v]); } - aFree(maplist[i].skills); + aFree(map->list[i].skills); } - maplist[i].skills = NULL; - maplist[i].skill_count = 0; + map->list[i].skills = NULL; + map->list[i].skill_count = 0; // adjustments if( battle_config.pk_mode ) { - maplist[i].flag.pvp = 1; // make all maps pvp for pk_mode [Valaris] - maplist[i].zone = &map_zone_pk; + map->list[i].flag.pvp = 1; // make all maps pvp for pk_mode [Valaris] + map->list[i].zone = &map->zone_pk; } else /* align with 'All' zone */ - maplist[i].zone = &map_zone_all; + map->list[i].zone = &map->zone_all; - if( maplist[i].zone_mf_count ) { - for(v = 0; v < maplist[i].zone_mf_count; v++) { - aFree(maplist[i].zone_mf[v]); + if( map->list[i].zone_mf_count ) { + for(v = 0; v < map->list[i].zone_mf_count; v++) { + aFree(map->list[i].zone_mf[v]); } - aFree(maplist[i].zone_mf); + aFree(map->list[i].zone_mf); } - maplist[i].zone_mf = NULL; - maplist[i].zone_mf_count = 0; - maplist[i].prev_zone = maplist[i].zone; + map->list[i].zone_mf = NULL; + map->list[i].zone_mf_count = 0; + map->list[i].prev_zone = map->list[i].zone; - maplist[i].invincible_time_inc = 0; + map->list[i].invincible_time_inc = 0; - maplist[i].weapon_damage_rate = 100; - maplist[i].magic_damage_rate = 100; - maplist[i].misc_damage_rate = 100; - maplist[i].short_damage_rate = 100; - maplist[i].long_damage_rate = 100; + map->list[i].weapon_damage_rate = 100; + map->list[i].magic_damage_rate = 100; + map->list[i].misc_damage_rate = 100; + map->list[i].short_damage_rate = 100; + map->list[i].long_damage_rate = 100; } } #define NO_WATER 1000000 /* -* Reads from the .rsw for each map -* Returns water height (or NO_WATER if file doesn't exist) or other error is encountered. -* Assumed path for file is data/mapname.rsw -* Credits to LittleWolf -*/ + * Reads from the .rsw for each map + * Returns water height (or NO_WATER if file doesn't exist) or other error is encountered. + * Assumed path for file is data/mapname.rsw + * Credits to LittleWolf + */ int map_waterheight(char* mapname) { char fn[256]; @@ -3295,8 +3198,8 @@ int map_waterheight(char* mapname) } /*================================== -* .GAT format -*----------------------------------*/ + * .GAT format + *----------------------------------*/ int map_readgat (struct map_data* m) { char filename[256]; @@ -3315,7 +3218,7 @@ int map_readgat (struct map_data* m) num_cells = m->xs * m->ys; CREATE(m->cell, struct mapcell, num_cells); - water_height = map_waterheight(m->name); + water_height = map->waterheight(m->name); // Set cell properties off = 14; @@ -3329,7 +3232,7 @@ int map_readgat (struct map_data* m) if( type == 0 && water_height != NO_WATER && height > water_height ) type = 3; // Cell is 0 (walkable) but under water level, set to 3 (walkable water) - m->cell[xy] = map_gat2cell(type); + m->cell[xy] = map->gat2cell(type); } aFree(gat); @@ -3338,25 +3241,25 @@ int map_readgat (struct map_data* m) } /*====================================== -* Add/Remove map to the map_db -*--------------------------------------*/ + * Add/Remove map to the map_db + *--------------------------------------*/ void map_addmap2db(struct map_data *m) { - index2mapid[m->index] = m->m; + map->index2mapid[m->index] = m->m; } void map_removemapdb(struct map_data *m) { - index2mapid[m->index] = -1; + map->index2mapid[m->index] = -1; } /*====================================== -* Initiate maps loading stage -*--------------------------------------*/ + * Initiate maps loading stage + *--------------------------------------*/ int map_readallmaps (void) { int i; FILE* fp=NULL; int maps_removed = 0; - if( enable_grf ) + if( map->enable_grf ) ShowStatus("Loading maps (using GRF files)...\n"); else { char mapcachefilepath[254]; @@ -3368,73 +3271,73 @@ int map_readallmaps (void) { } // Init mapcache data.. [Shinryo] - map_cache_buffer = map_init_mapcache(fp); - if(!map_cache_buffer) { + map->cache_buffer = map->init_mapcache(fp); + if(!map->cache_buffer) { ShowFatalError("Failed to initialize mapcache data (%s)..\n", mapcachefilepath); exit(EXIT_FAILURE); } } - for(i = 0; i < map->map_num; i++) { + for(i = 0; i < map->count; i++) { size_t size; // show progress - if(enable_grf) - ShowStatus("Loading maps [%i/%i]: %s"CL_CLL"\r", i, map->map_num, maplist[i].name); + if(map->enable_grf) + ShowStatus("Loading maps [%i/%i]: %s"CL_CLL"\r", i, map->count, map->list[i].name); // try to load the map if( ! - (enable_grf? - map_readgat(&maplist[i]) - :map_readfromcache(&maplist[i], map_cache_buffer)) + (map->enable_grf? + map->readgat(&map->list[i]) + :map->readfromcache(&map->list[i], map->cache_buffer)) ) { - map_delmapid(i); + map->delmapid(i); maps_removed++; i--; continue; } - maplist[i].index = mapindex_name2id(maplist[i].name); + map->list[i].index = mapindex_name2id(map->list[i].name); - if ( index2mapid[map_id2index(i)] != -1 ) { - ShowWarning("Map %s already loaded!"CL_CLL"\n", maplist[i].name); - if (maplist[i].cell && maplist[i].cell != (struct mapcell *)0xdeadbeaf) { - aFree(maplist[i].cell); - maplist[i].cell = NULL; + if ( map->index2mapid[map_id2index(i)] != -1 ) { + ShowWarning("Map %s already loaded!"CL_CLL"\n", map->list[i].name); + if (map->list[i].cell && map->list[i].cell != (struct mapcell *)0xdeadbeaf) { + aFree(map->list[i].cell); + map->list[i].cell = NULL; } - map_delmapid(i); + map->delmapid(i); maps_removed++; i--; continue; } - maplist[i].m = i; - map->addmap2db(&maplist[i]); + map->list[i].m = i; + map->addmap2db(&map->list[i]); - memset(maplist[i].moblist, 0, sizeof(maplist[i].moblist)); //Initialize moblist [Skotlex] - maplist[i].mob_delete_timer = INVALID_TIMER; //Initialize timer [Skotlex] + memset(map->list[i].moblist, 0, sizeof(map->list[i].moblist)); //Initialize moblist [Skotlex] + map->list[i].mob_delete_timer = INVALID_TIMER; //Initialize timer [Skotlex] - maplist[i].bxs = (maplist[i].xs + BLOCK_SIZE - 1) / BLOCK_SIZE; - maplist[i].bys = (maplist[i].ys + BLOCK_SIZE - 1) / BLOCK_SIZE; + map->list[i].bxs = (map->list[i].xs + BLOCK_SIZE - 1) / BLOCK_SIZE; + map->list[i].bys = (map->list[i].ys + BLOCK_SIZE - 1) / BLOCK_SIZE; - size = maplist[i].bxs * maplist[i].bys * sizeof(struct block_list*); - maplist[i].block = (struct block_list**)aCalloc(size, 1); - maplist[i].block_mob = (struct block_list**)aCalloc(size, 1); + size = map->list[i].bxs * map->list[i].bys * sizeof(struct block_list*); + map->list[i].block = (struct block_list**)aCalloc(size, 1); + map->list[i].block_mob = (struct block_list**)aCalloc(size, 1); - maplist[i].getcellp = map_sub_getcellp; - maplist[i].setcell = map_sub_setcell; + map->list[i].getcellp = map->sub_getcellp; + map->list[i].setcell = map->sub_setcell; } // intialization and configuration-dependent adjustments of mapflags map->flags_init(); - if( !enable_grf ) { + if( !map->enable_grf ) { fclose(fp); } // finished map loading - 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 + ShowInfo("Successfully loaded '"CL_WHITE"%d"CL_RESET"' maps."CL_CLL"\n",map->count); + instance->start_id = map->count; // Next Map Index will be instances if (maps_removed) ShowNotice("Maps removed: '"CL_WHITE"%d"CL_RESET"'\n",maps_removed); @@ -3442,13 +3345,9 @@ int map_readallmaps (void) { return 0; } -//////////////////////////////////////////////////////////////////////// -static int map_ip_set = 0; -static int char_ip_set = 0; - /*========================================== -* Read map server configuration files (conf/map_server.conf...) -*------------------------------------------*/ + * Read map server configuration files (conf/map_server.conf...) + *------------------------------------------*/ int map_config_read(char *cfgName) { char line[1024], w1[1024], w2[1024]; FILE *fp; @@ -3488,20 +3387,20 @@ int map_config_read(char *cfgName) { else if (strcmpi(w1, "passwd") == 0) chrif->setpasswd(w2); else if (strcmpi(w1, "char_ip") == 0) - char_ip_set = chrif->setip(w2); + map->char_ip_set = chrif->setip(w2); else if (strcmpi(w1, "char_port") == 0) chrif->setport(atoi(w2)); else if (strcmpi(w1, "map_ip") == 0) - map_ip_set = clif->setip(w2); + map->ip_set = clif->setip(w2); else if (strcmpi(w1, "bind_ip") == 0) clif->setbindip(w2); else if (strcmpi(w1, "map_port") == 0) { clif->setport(atoi(w2)); - map_port = (atoi(w2)); + map->port = (atoi(w2)); } else if (strcmpi(w1, "map") == 0) - map->map_num++; + map->count++; else if (strcmpi(w1, "delmap") == 0) - map->map_num--; + map->count--; else if (strcmpi(w1, "npc") == 0) npc->addsrcfile(w2); else if (strcmpi(w1, "delnpc") == 0) @@ -3529,11 +3428,11 @@ int map_config_read(char *cfgName) { else if (strcmpi(w1, "enable_spy") == 0) map->enable_spy = config_switch(w2); else if (strcmpi(w1, "use_grf") == 0) - enable_grf = config_switch(w2); + map->enable_grf = config_switch(w2); else if (strcmpi(w1, "console_msg_log") == 0) console_msg_log = atoi(w2);//[Ind] else if (strcmpi(w1, "import") == 0) - map_config_read(w2); + map->config_read(w2); else ShowWarning("Unknown setting '%s' in file %s\n", w1, cfgName); } @@ -3568,11 +3467,11 @@ int map_config_read_sub(char *cfgName) { *ptr = '\0'; if (strcmpi(w1, "map") == 0) - map_addmap(w2); + map->addmap(w2); else if (strcmpi(w1, "delmap") == 0) map->delmap(w2); else if (strcmpi(w1, "import") == 0) - map_config_read_sub(w2); + map->config_read_sub(w2); } fclose(fp); @@ -3610,7 +3509,7 @@ void map_reloadnpc_sub(char *cfgName) if (strcmpi(w1, "npc") == 0) npc->addsrcfile(w2); else if (strcmpi(w1, "import") == 0) - map_reloadnpc_sub(w2); + map->reloadnpc_sub(w2); else ShowWarning("Unknown setting '%s' in file %s\n", w1, cfgName); } @@ -3624,9 +3523,9 @@ void map_reloadnpc(bool clear) npc->addsrcfile("clear"); // this will clear the current script list #ifdef RENEWAL - map_reloadnpc_sub("npc/re/scripts_main.conf"); + map->reloadnpc_sub("npc/re/scripts_main.conf"); #else - map_reloadnpc_sub("npc/pre-re/scripts_main.conf"); + map->reloadnpc_sub("npc/pre-re/scripts_main.conf"); #endif } @@ -3663,17 +3562,17 @@ int inter_config_read(char *cfgName) { strcpy(map->interreg_db,w2); /* map sql stuff */ else if(strcmpi(w1,"map_server_ip")==0) - strcpy(map_server_ip, w2); + strcpy(map->server_ip, w2); else if(strcmpi(w1,"map_server_port")==0) - map_server_port=atoi(w2); + map->server_port=atoi(w2); else if(strcmpi(w1,"map_server_id")==0) - strcpy(map_server_id, w2); + strcpy(map->server_id, w2); else if(strcmpi(w1,"map_server_pw")==0) - strcpy(map_server_pw, w2); + strcpy(map->server_pw, w2); else if(strcmpi(w1,"map_server_db")==0) - strcpy(map_server_db, w2); + strcpy(map->server_db, w2); else if(strcmpi(w1,"default_codepage")==0) - strcpy(default_codepage, w2); + strcpy(map->default_codepage, w2); else if(strcmpi(w1,"use_sql_item_db")==0) { map->db_use_sql_item_db = config_switch(w2); ShowStatus ("Using item database as SQL: '%s'\n", w2); @@ -3688,21 +3587,21 @@ int inter_config_read(char *cfgName) { } /* sql log db */ else if(strcmpi(w1,"log_db_ip")==0) - strcpy(log_db_ip, w2); + strcpy(logs->db_ip, w2); else if(strcmpi(w1,"log_db_id")==0) - strcpy(log_db_id, w2); + strcpy(logs->db_id, w2); else if(strcmpi(w1,"log_db_pw")==0) - strcpy(log_db_pw, w2); + strcpy(logs->db_pw, w2); else if(strcmpi(w1,"log_db_port")==0) - log_db_port = atoi(w2); + logs->db_port = atoi(w2); else if(strcmpi(w1,"log_db_db")==0) - strcpy(log_db_db, w2); + strcpy(logs->db_name, w2); /* mapreg */ else if( mapreg->config_read(w1,w2) ) continue; /* import */ else if(strcmpi(w1,"import")==0) - inter_config_read(w2); + map->inter_config_read(w2); } fclose(fp); @@ -3710,21 +3609,21 @@ int inter_config_read(char *cfgName) { } /*======================================= -* MySQL Init -*---------------------------------------*/ + * MySQL Init + *---------------------------------------*/ int map_sql_init(void) { // main db connection - mmysql_handle = SQL->Malloc(); + map->mysql_handle = SQL->Malloc(); ShowInfo("Connecting to the Map DB Server....\n"); - if( SQL_ERROR == SQL->Connect(mmysql_handle, map_server_id, map_server_pw, map_server_ip, map_server_port, map_server_db) ) + if( SQL_ERROR == SQL->Connect(map->mysql_handle, map->server_id, map->server_pw, map->server_ip, map->server_port, map->server_db) ) exit(EXIT_FAILURE); ShowStatus("connect success! (Map Server Connection)\n"); - if( strlen(default_codepage) > 0 ) - if ( SQL_ERROR == SQL->SetEncoding(mmysql_handle, default_codepage) ) - Sql_ShowDebug(mmysql_handle); + if( strlen(map->default_codepage) > 0 ) + if ( SQL_ERROR == SQL->SetEncoding(map->mysql_handle, map->default_codepage) ) + Sql_ShowDebug(map->mysql_handle); return 0; } @@ -3732,46 +3631,29 @@ int map_sql_init(void) int map_sql_close(void) { ShowStatus("Close Map DB Connection....\n"); - SQL->Free(mmysql_handle); - mmysql_handle = NULL; + SQL->Free(map->mysql_handle); + map->mysql_handle = NULL; if (logs->config.sql_logs) { - ShowStatus("Close Log DB Connection....\n"); - SQL->Free(logmysql_handle); - logmysql_handle = NULL; + logs->sql_final(); } return 0; } -int log_sql_init(void) -{ - // log db connection - logmysql_handle = SQL->Malloc(); - - ShowInfo(""CL_WHITE"[SQL]"CL_RESET": Connecting to the Log Database "CL_WHITE"%s"CL_RESET" At "CL_WHITE"%s"CL_RESET"...\n",log_db_db,log_db_ip); - if ( SQL_ERROR == SQL->Connect(logmysql_handle, log_db_id, log_db_pw, log_db_ip, log_db_port, log_db_db) ) - exit(EXIT_FAILURE); - ShowStatus(""CL_WHITE"[SQL]"CL_RESET": Successfully '"CL_GREEN"connected"CL_RESET"' to Database '"CL_WHITE"%s"CL_RESET"'.\n", log_db_db); - - if( strlen(default_codepage) > 0 ) - if ( SQL_ERROR == SQL->SetEncoding(logmysql_handle, default_codepage) ) - Sql_ShowDebug(logmysql_handle); - return 0; -} void map_zone_change2(int m, struct map_zone_data *zone) { char empty[1] = "\0"; - maplist[m].prev_zone = maplist[m].zone; + map->list[m].prev_zone = map->list[m].zone; - if( maplist[m].zone_mf_count ) + if( map->list[m].zone_mf_count ) map->zone_remove(m); 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; + map->list[m].prev_zone = map->list[m].zone; - if( maplist[m].zone_mf_count ) + if( map->list[m].zone_mf_count ) map->zone_remove(m); map->zone_apply(m,zone,start,buffer,filepath); } @@ -3780,10 +3662,10 @@ void map_zone_remove(int m) { char flag[MAP_ZONE_MAPFLAG_LENGTH], params[MAP_ZONE_MAPFLAG_LENGTH]; unsigned short k; char empty[1] = "\0"; - for(k = 0; k < maplist[m].zone_mf_count; k++) { - int len = strlen(maplist[m].zone_mf[k]),j; + for(k = 0; k < map->list[m].zone_mf_count; k++) { + int len = strlen(map->list[m].zone_mf[k]),j; params[0] = '\0'; - memcpy(flag, maplist[m].zone_mf[k], MAP_ZONE_MAPFLAG_LENGTH); + memcpy(flag, map->list[m].zone_mf[k], MAP_ZONE_MAPFLAG_LENGTH); for(j = 0; j < len; j++) { if( flag[j] == '\t' ) { memcpy(params, &flag[j+1], len - j); @@ -3792,19 +3674,19 @@ void map_zone_remove(int m) { } } - npc->parse_mapflag(maplist[m].name,empty,flag,params,empty,empty,empty); - aFree(maplist[m].zone_mf[k]); - maplist[m].zone_mf[k] = NULL; + npc->parse_mapflag(map->list[m].name,empty,flag,params,empty,empty,empty); + aFree(map->list[m].zone_mf[k]); + map->list[m].zone_mf[k] = NULL; } - aFree(maplist[m].zone_mf); - maplist[m].zone_mf = NULL; - maplist[m].zone_mf_count = 0; + aFree(map->list[m].zone_mf); + map->list[m].zone_mf = NULL; + map->list[m].zone_mf_count = 0; } static inline void map_zone_mf_cache_add(int m, char *rflag) { - RECREATE(maplist[m].zone_mf, char *, ++maplist[m].zone_mf_count); - CREATE(maplist[m].zone_mf[maplist[m].zone_mf_count - 1], char, MAP_ZONE_MAPFLAG_LENGTH); - safestrncpy(maplist[m].zone_mf[maplist[m].zone_mf_count - 1], rflag, MAP_ZONE_MAPFLAG_LENGTH); + RECREATE(map->list[m].zone_mf, char *, ++map->list[m].zone_mf_count); + CREATE(map->list[m].zone_mf[map->list[m].zone_mf_count - 1], char, MAP_ZONE_MAPFLAG_LENGTH); + safestrncpy(map->list[m].zone_mf[map->list[m].zone_mf_count - 1], rflag, MAP_ZONE_MAPFLAG_LENGTH); } /* TODO: introduce enumerations to each mapflag so instead of reading the string a number of times we read it only once and use its value wherever we need */ /* cache previous values to revert */ @@ -3820,157 +3702,157 @@ bool map_zone_mf_cache(int m, char *flag, char *params) { char savemap[32]; int savex, savey; if (state == 0) { - if( maplist[m].flag.nosave ) { + if( map->list[m].flag.nosave ) { sprintf(rflag, "nosave\tSavePoint"); map_zone_mf_cache_add(m,nosave); } } else if (!strcmpi(params, "SavePoint")) { - if( maplist[m].save.map ) { - sprintf(rflag, "nosave\t%s,%d,%d",mapindex_id2name(maplist[m].save.map),maplist[m].save.x,maplist[m].save.y); + if( map->list[m].save.map ) { + sprintf(rflag, "nosave\t%s,%d,%d",mapindex_id2name(map->list[m].save.map),map->list[m].save.x,map->list[m].save.y); } else - sprintf(rflag, "nosave\t%s,%d,%d",mapindex_id2name(maplist[m].save.map),maplist[m].save.x,maplist[m].save.y); + sprintf(rflag, "nosave\t%s,%d,%d",mapindex_id2name(map->list[m].save.map),map->list[m].save.x,map->list[m].save.y); map_zone_mf_cache_add(m,nosave); } else if (sscanf(params, "%31[^,],%d,%d", savemap, &savex, &savey) == 3) { - if( maplist[m].save.map ) { - sprintf(rflag, "nosave\t%s,%d,%d",mapindex_id2name(maplist[m].save.map),maplist[m].save.x,maplist[m].save.y); + if( map->list[m].save.map ) { + sprintf(rflag, "nosave\t%s,%d,%d",mapindex_id2name(map->list[m].save.map),map->list[m].save.x,map->list[m].save.y); map_zone_mf_cache_add(m,nosave); } } #endif // 0 } else if (!strcmpi(flag,"autotrade")) { - if( state && maplist[m].flag.autotrade ) + if( state && map->list[m].flag.autotrade ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"autotrade\toff"); - else if( !maplist[m].flag.autotrade ) + else if( !map->list[m].flag.autotrade ) map_zone_mf_cache_add(m,"autotrade"); } } else if (!strcmpi(flag,"allowks")) { - if( state && maplist[m].flag.allowks ) + if( state && map->list[m].flag.allowks ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"allowks\toff"); - else if( !maplist[m].flag.allowks ) + else if( !map->list[m].flag.allowks ) map_zone_mf_cache_add(m,"allowks"); } } else if (!strcmpi(flag,"town")) { - if( state && maplist[m].flag.town ) + if( state && map->list[m].flag.town ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"town\toff"); - else if( !maplist[m].flag.town ) + else if( !map->list[m].flag.town ) map_zone_mf_cache_add(m,"town"); } } else if (!strcmpi(flag,"nomemo")) { - if( state && maplist[m].flag.nomemo ) + if( state && map->list[m].flag.nomemo ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"nomemo\toff"); - else if( !maplist[m].flag.nomemo ) + else if( !map->list[m].flag.nomemo ) map_zone_mf_cache_add(m,"nomemo"); } } else if (!strcmpi(flag,"noteleport")) { - if( state && maplist[m].flag.noteleport ) + if( state && map->list[m].flag.noteleport ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"noteleport\toff"); - else if( !maplist[m].flag.noteleport ) + else if( !map->list[m].flag.noteleport ) map_zone_mf_cache_add(m,"noteleport"); } } else if (!strcmpi(flag,"nowarp")) { - if( state && maplist[m].flag.nowarp ) + if( state && map->list[m].flag.nowarp ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"nowarp\toff"); - else if( !maplist[m].flag.nowarp ) + else if( !map->list[m].flag.nowarp ) map_zone_mf_cache_add(m,"nowarp"); } } else if (!strcmpi(flag,"nowarpto")) { - if( state && maplist[m].flag.nowarpto ) + if( state && map->list[m].flag.nowarpto ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"nowarpto\toff"); - else if( !maplist[m].flag.nowarpto ) + else if( !map->list[m].flag.nowarpto ) map_zone_mf_cache_add(m,"nowarpto"); } } else if (!strcmpi(flag,"noreturn")) { - if( state && maplist[m].flag.noreturn ) + if( state && map->list[m].flag.noreturn ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"noreturn\toff"); - else if( maplist[m].flag.noreturn ) + else if( map->list[m].flag.noreturn ) map_zone_mf_cache_add(m,"noreturn"); } } else if (!strcmpi(flag,"monster_noteleport")) { - if( state && maplist[m].flag.monster_noteleport ) + if( state && map->list[m].flag.monster_noteleport ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"monster_noteleport\toff"); - else if( maplist[m].flag.monster_noteleport ) + else if( map->list[m].flag.monster_noteleport ) map_zone_mf_cache_add(m,"monster_noteleport"); } } else if (!strcmpi(flag,"nobranch")) { - if( state && maplist[m].flag.nobranch ) + if( state && map->list[m].flag.nobranch ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"nobranch\toff"); - else if( maplist[m].flag.nobranch ) + else if( map->list[m].flag.nobranch ) map_zone_mf_cache_add(m,"nobranch"); } } else if (!strcmpi(flag,"nopenalty")) { - if( state && maplist[m].flag.noexppenalty ) /* they are applied together, no need to check both */ + if( state && map->list[m].flag.noexppenalty ) /* they are applied together, no need to check both */ ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"nopenalty\toff"); - else if( maplist[m].flag.noexppenalty ) + else if( map->list[m].flag.noexppenalty ) map_zone_mf_cache_add(m,"nopenalty"); } } else if (!strcmpi(flag,"pvp")) { - if( state && maplist[m].flag.pvp ) + if( state && map->list[m].flag.pvp ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"pvp\toff"); - else if( maplist[m].flag.pvp ) + else if( map->list[m].flag.pvp ) map_zone_mf_cache_add(m,"pvp"); } } else if (!strcmpi(flag,"pvp_noparty")) { - if( state && maplist[m].flag.pvp_noparty ) + if( state && map->list[m].flag.pvp_noparty ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"pvp_noparty\toff"); - else if( maplist[m].flag.pvp_noparty ) + else if( map->list[m].flag.pvp_noparty ) map_zone_mf_cache_add(m,"pvp_noparty"); } } else if (!strcmpi(flag,"pvp_noguild")) { - if( state && maplist[m].flag.pvp_noguild ) + if( state && map->list[m].flag.pvp_noguild ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"pvp_noguild\toff"); - else if( maplist[m].flag.pvp_noguild ) + else if( map->list[m].flag.pvp_noguild ) map_zone_mf_cache_add(m,"pvp_noguild"); } } else if (!strcmpi(flag, "pvp_nightmaredrop")) { - if( state && maplist[m].flag.pvp_nightmaredrop ) + if( state && map->list[m].flag.pvp_nightmaredrop ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"pvp_nightmaredrop\toff"); - else if( maplist[m].flag.pvp_nightmaredrop ) + else if( map->list[m].flag.pvp_nightmaredrop ) map_zone_mf_cache_add(m,"pvp_nightmaredrop"); } #if 0 /* not yet fully supported */ @@ -3992,262 +3874,262 @@ bool map_zone_mf_cache(int m, char *flag, char *params) { if (drop_id != 0) { int i; for (i = 0; i < MAX_DROP_PER_MAP; i++) { - if (maplist[m].drop_list[i].drop_id == 0){ - maplist[m].drop_list[i].drop_id = drop_id; - maplist[m].drop_list[i].drop_type = drop_type; - maplist[m].drop_list[i].drop_per = drop_per; + if (map->list[m].drop_list[i].drop_id == 0){ + map->list[m].drop_list[i].drop_id = drop_id; + map->list[m].drop_list[i].drop_type = drop_type; + map->list[m].drop_list[i].drop_per = drop_per; break; } } - maplist[m].flag.pvp_nightmaredrop = 1; + map->list[m].flag.pvp_nightmaredrop = 1; } } else if (!state) //Disable - maplist[m].flag.pvp_nightmaredrop = 0; + map->list[m].flag.pvp_nightmaredrop = 0; #endif // 0 } else if (!strcmpi(flag,"pvp_nocalcrank")) { - if( state && maplist[m].flag.pvp_nocalcrank ) + if( state && map->list[m].flag.pvp_nocalcrank ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"pvp_nocalcrank\toff"); - else if( maplist[m].flag.pvp_nocalcrank ) + else if( map->list[m].flag.pvp_nocalcrank ) map_zone_mf_cache_add(m,"pvp_nocalcrank"); } } else if (!strcmpi(flag,"gvg")) { - if( state && maplist[m].flag.gvg ) + if( state && map->list[m].flag.gvg ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"gvg\toff"); - else if( maplist[m].flag.gvg ) + else if( map->list[m].flag.gvg ) map_zone_mf_cache_add(m,"gvg"); } } else if (!strcmpi(flag,"gvg_noparty")) { - if( state && maplist[m].flag.gvg_noparty ) + if( state && map->list[m].flag.gvg_noparty ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"gvg_noparty\toff"); - else if( maplist[m].flag.gvg_noparty ) + else if( map->list[m].flag.gvg_noparty ) map_zone_mf_cache_add(m,"gvg_noparty"); } } else if (!strcmpi(flag,"gvg_dungeon")) { - if( state && maplist[m].flag.gvg_dungeon ) + if( state && map->list[m].flag.gvg_dungeon ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"gvg_dungeon\toff"); - else if( maplist[m].flag.gvg_dungeon ) + else if( map->list[m].flag.gvg_dungeon ) map_zone_mf_cache_add(m,"gvg_dungeon"); } } else if (!strcmpi(flag,"gvg_castle")) { - if( state && maplist[m].flag.gvg_castle ) + if( state && map->list[m].flag.gvg_castle ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"gvg_castle\toff"); - else if( maplist[m].flag.gvg_castle ) + else if( map->list[m].flag.gvg_castle ) map_zone_mf_cache_add(m,"gvg_castle"); } } else if (!strcmpi(flag,"battleground")) { - if( state && maplist[m].flag.battleground ) + if( state && map->list[m].flag.battleground ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"battleground\toff"); - else if( maplist[m].flag.battleground ) + else if( map->list[m].flag.battleground ) map_zone_mf_cache_add(m,"battleground"); } } else if (!strcmpi(flag,"noexppenalty")) { - if( state && maplist[m].flag.noexppenalty ) + if( state && map->list[m].flag.noexppenalty ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"noexppenalty\toff"); - else if( maplist[m].flag.noexppenalty ) + else if( map->list[m].flag.noexppenalty ) map_zone_mf_cache_add(m,"noexppenalty"); } } else if (!strcmpi(flag,"nozenypenalty")) { - if( state && maplist[m].flag.nozenypenalty ) + if( state && map->list[m].flag.nozenypenalty ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"nozenypenalty\toff"); - else if( maplist[m].flag.nozenypenalty ) + else if( map->list[m].flag.nozenypenalty ) map_zone_mf_cache_add(m,"nozenypenalty"); } } else if (!strcmpi(flag,"notrade")) { - if( state && maplist[m].flag.notrade ) + if( state && map->list[m].flag.notrade ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"notrade\toff"); - else if( maplist[m].flag.notrade ) + else if( map->list[m].flag.notrade ) map_zone_mf_cache_add(m,"notrade"); } } else if (!strcmpi(flag,"novending")) { - if( state && maplist[m].flag.novending ) + if( state && map->list[m].flag.novending ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"novending\toff"); - else if( maplist[m].flag.novending ) + else if( map->list[m].flag.novending ) map_zone_mf_cache_add(m,"novending"); } } else if (!strcmpi(flag,"nodrop")) { - if( state && maplist[m].flag.nodrop ) + if( state && map->list[m].flag.nodrop ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"nodrop\toff"); - else if( maplist[m].flag.nodrop ) + else if( map->list[m].flag.nodrop ) map_zone_mf_cache_add(m,"nodrop"); } } else if (!strcmpi(flag,"noskill")) { - if( state && maplist[m].flag.noskill ) + if( state && map->list[m].flag.noskill ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"noskill\toff"); - else if( maplist[m].flag.noskill ) + else if( map->list[m].flag.noskill ) map_zone_mf_cache_add(m,"noskill"); } } else if (!strcmpi(flag,"noicewall")) { - if( state && maplist[m].flag.noicewall ) + if( state && map->list[m].flag.noicewall ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"noicewall\toff"); - else if( maplist[m].flag.noicewall ) + else if( map->list[m].flag.noicewall ) map_zone_mf_cache_add(m,"noicewall"); } } else if (!strcmpi(flag,"snow")) { - if( state && maplist[m].flag.snow ) + if( state && map->list[m].flag.snow ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"snow\toff"); - else if( maplist[m].flag.snow ) + else if( map->list[m].flag.snow ) map_zone_mf_cache_add(m,"snow"); } } else if (!strcmpi(flag,"clouds")) { - if( state && maplist[m].flag.clouds ) + if( state && map->list[m].flag.clouds ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"clouds\toff"); - else if( maplist[m].flag.clouds ) + else if( map->list[m].flag.clouds ) map_zone_mf_cache_add(m,"clouds"); } } else if (!strcmpi(flag,"clouds2")) { - if( state && maplist[m].flag.clouds2 ) + if( state && map->list[m].flag.clouds2 ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"clouds2\toff"); - else if( maplist[m].flag.clouds2 ) + else if( map->list[m].flag.clouds2 ) map_zone_mf_cache_add(m,"clouds2"); } } else if (!strcmpi(flag,"fog")) { - if( state && maplist[m].flag.fog ) + if( state && map->list[m].flag.fog ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"fog\toff"); - else if( maplist[m].flag.fog ) + else if( map->list[m].flag.fog ) map_zone_mf_cache_add(m,"fog"); } } else if (!strcmpi(flag,"fireworks")) { - if( state && maplist[m].flag.fireworks ) + if( state && map->list[m].flag.fireworks ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"fireworks\toff"); - else if( maplist[m].flag.fireworks ) + else if( map->list[m].flag.fireworks ) map_zone_mf_cache_add(m,"fireworks"); } } else if (!strcmpi(flag,"sakura")) { - if( state && maplist[m].flag.sakura ) + if( state && map->list[m].flag.sakura ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"sakura\toff"); - else if( maplist[m].flag.sakura ) + else if( map->list[m].flag.sakura ) map_zone_mf_cache_add(m,"sakura"); } } else if (!strcmpi(flag,"leaves")) { - if( state && maplist[m].flag.leaves ) + if( state && map->list[m].flag.leaves ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"leaves\toff"); - else if( maplist[m].flag.leaves ) + else if( map->list[m].flag.leaves ) map_zone_mf_cache_add(m,"leaves"); } } else if (!strcmpi(flag,"nightenabled")) { - if( state && maplist[m].flag.nightenabled ) + if( state && map->list[m].flag.nightenabled ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"nightenabled\toff"); - else if( maplist[m].flag.nightenabled ) + else if( map->list[m].flag.nightenabled ) map_zone_mf_cache_add(m,"nightenabled"); } } else if (!strcmpi(flag,"noexp")) { - if( state && maplist[m].flag.nobaseexp ) + if( state && map->list[m].flag.nobaseexp ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"noexp\toff"); - else if( maplist[m].flag.nobaseexp ) + else if( map->list[m].flag.nobaseexp ) map_zone_mf_cache_add(m,"noexp"); } } else if (!strcmpi(flag,"nobaseexp")) { - if( state && maplist[m].flag.nobaseexp ) + if( state && map->list[m].flag.nobaseexp ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"nobaseexp\toff"); - else if( maplist[m].flag.nobaseexp ) + else if( map->list[m].flag.nobaseexp ) map_zone_mf_cache_add(m,"nobaseexp"); } } else if (!strcmpi(flag,"nojobexp")) { - if( state && maplist[m].flag.nojobexp ) + if( state && map->list[m].flag.nojobexp ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"nojobexp\toff"); - else if( maplist[m].flag.nojobexp ) + else if( map->list[m].flag.nojobexp ) map_zone_mf_cache_add(m,"nojobexp"); } } else if (!strcmpi(flag,"noloot")) { - if( state && maplist[m].flag.nomobloot ) + if( state && map->list[m].flag.nomobloot ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"noloot\toff"); - else if( maplist[m].flag.nomobloot ) + else if( map->list[m].flag.nomobloot ) map_zone_mf_cache_add(m,"noloot"); } } else if (!strcmpi(flag,"nomobloot")) { - if( state && maplist[m].flag.nomobloot ) + if( state && map->list[m].flag.nomobloot ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"nomobloot\toff"); - else if( maplist[m].flag.nomobloot ) + else if( map->list[m].flag.nomobloot ) map_zone_mf_cache_add(m,"nomobloot"); } } else if (!strcmpi(flag,"nomvploot")) { - if( state && maplist[m].flag.nomvploot ) + if( state && map->list[m].flag.nomvploot ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"nomvploot\toff"); - else if( maplist[m].flag.nomvploot ) + else if( map->list[m].flag.nomvploot ) map_zone_mf_cache_add(m,"nomvploot"); } } else if (!strcmpi(flag,"nocommand")) { @@ -4255,79 +4137,79 @@ bool map_zone_mf_cache(int m, char *flag, char *params) { if( state && sscanf(params, "%d", &state) == 1 ) { sprintf(rflag, "nocommand\t%s",params); map_zone_mf_cache_add(m,rflag); - } else if( !state && maplist[m].nocommand ) { - sprintf(rflag, "nocommand\t%d",maplist[m].nocommand); + } else if( !state && map->list[m].nocommand ) { + sprintf(rflag, "nocommand\t%d",map->list[m].nocommand); map_zone_mf_cache_add(m,rflag); - } else if( maplist[m].nocommand ) { + } else if( map->list[m].nocommand ) { map_zone_mf_cache_add(m,"nocommand\toff"); } } else if (!strcmpi(flag,"jexp")) { if( !state ) { - if( maplist[m].jexp != 100 ) { - sprintf(rflag,"jexp\t%d",maplist[m].jexp); + if( map->list[m].jexp != 100 ) { + sprintf(rflag,"jexp\t%d",map->list[m].jexp); map_zone_mf_cache_add(m,rflag); } } if( sscanf(params, "%d", &state) == 1 ) { - if( state != maplist[m].jexp ) { + if( state != map->list[m].jexp ) { sprintf(rflag,"jexp\t%s",params); map_zone_mf_cache_add(m,rflag); } } } else if (!strcmpi(flag,"bexp")) { if( !state ) { - if( maplist[m].bexp != 100 ) { - sprintf(rflag,"bexp\t%d",maplist[m].jexp); + if( map->list[m].bexp != 100 ) { + sprintf(rflag,"bexp\t%d",map->list[m].jexp); map_zone_mf_cache_add(m,rflag); } } if( sscanf(params, "%d", &state) == 1 ) { - if( state != maplist[m].bexp ) { + if( state != map->list[m].bexp ) { sprintf(rflag,"bexp\t%s",params); map_zone_mf_cache_add(m,rflag); } } } else if (!strcmpi(flag,"loadevent")) { - if( state && maplist[m].flag.loadevent ) + if( state && map->list[m].flag.loadevent ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"loadevent\toff"); - else if( maplist[m].flag.loadevent ) + else if( map->list[m].flag.loadevent ) map_zone_mf_cache_add(m,"loadevent"); } } else if (!strcmpi(flag,"nochat")) { - if( state && maplist[m].flag.nochat ) + if( state && map->list[m].flag.nochat ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"nochat\toff"); - else if( maplist[m].flag.nochat ) + else if( map->list[m].flag.nochat ) map_zone_mf_cache_add(m,"nochat"); } } else if (!strcmpi(flag,"partylock")) { - if( state && maplist[m].flag.partylock ) + if( state && map->list[m].flag.partylock ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"partylock\toff"); - else if( maplist[m].flag.partylock ) + else if( map->list[m].flag.partylock ) map_zone_mf_cache_add(m,"partylock"); } } else if (!strcmpi(flag,"guildlock")) { - if( state && maplist[m].flag.guildlock ) + if( state && map->list[m].flag.guildlock ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"guildlock\toff"); - else if( maplist[m].flag.guildlock ) + else if( map->list[m].flag.guildlock ) map_zone_mf_cache_add(m,"guildlock"); } } else if (!strcmpi(flag,"reset")) { - if( state && maplist[m].flag.reset ) + if( state && map->list[m].flag.reset ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"reset\toff"); - else if( maplist[m].flag.reset ) + else if( map->list[m].flag.reset ) map_zone_mf_cache_add(m,"reset"); } } else if (!strcmpi(flag,"adjust_unit_duration")) { @@ -4349,14 +4231,14 @@ bool map_zone_mf_cache(int m, char *flag, char *params) { if( modifier[0] == '\0' || !( skill_id = skill->name2id(skill_name) ) || !skill->get_unit_id( skill->name2id(skill_name), 0) || atoi(modifier) < 1 || atoi(modifier) > USHRT_MAX ) { ;/* we dont mind it, the server will take care of it next. */ } else { - int idx = maplist[m].unit_count; + int idx = map->list[m].unit_count; k = 0; - ARR_FIND(0, idx, k, maplist[m].units[k]->skill_id == skill_id); + ARR_FIND(0, idx, k, map->list[m].units[k]->skill_id == skill_id); if( k < idx ) { - if( atoi(modifier) != maplist[m].units[k]->modifier ) { - sprintf(rflag,"adjust_unit_duration\t%s\t%d",skill_name,maplist[m].units[k]->modifier); + if( atoi(modifier) != map->list[m].units[k]->modifier ) { + sprintf(rflag,"adjust_unit_duration\t%s\t%d",skill_name,map->list[m].units[k]->modifier); map_zone_mf_cache_add(m,rflag); } } else { @@ -4383,14 +4265,14 @@ bool map_zone_mf_cache(int m, char *flag, char *params) { if( modifier[0] == '\0' || !( skill_id = skill->name2id(skill_name) ) || atoi(modifier) < 1 || atoi(modifier) > USHRT_MAX ) { ;/* we dont mind it, the server will take care of it next. */ } else { - int idx = maplist[m].skill_count; + int idx = map->list[m].skill_count; k = 0; - ARR_FIND(0, idx, k, maplist[m].skills[k]->skill_id == skill_id); + ARR_FIND(0, idx, k, map->list[m].skills[k]->skill_id == skill_id); if( k < idx ) { - if( atoi(modifier) != maplist[m].skills[k]->modifier ) { - sprintf(rflag,"adjust_skill_damage\t%s\t%d",skill_name,maplist[m].skills[k]->modifier); + if( atoi(modifier) != map->list[m].skills[k]->modifier ) { + sprintf(rflag,"adjust_skill_damage\t%s\t%d",skill_name,map->list[m].skills[k]->modifier); map_zone_mf_cache_add(m,rflag); } } else { @@ -4400,94 +4282,94 @@ bool map_zone_mf_cache(int m, char *flag, char *params) { } } else if (!strcmpi(flag,"zone")) { - ShowWarning("You can't add a zone through a zone! ERROR, skipping for '%s'...\n",maplist[m].name); + ShowWarning("You can't add a zone through a zone! ERROR, skipping for '%s'...\n",map->list[m].name); return true; } else if ( !strcmpi(flag,"nomapchannelautojoin") ) { - if( state && maplist[m].flag.chsysnolocalaj ) + if( state && map->list[m].flag.chsysnolocalaj ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"nomapchannelautojoin\toff"); - else if( maplist[m].flag.chsysnolocalaj ) + else if( map->list[m].flag.chsysnolocalaj ) map_zone_mf_cache_add(m,"nomapchannelautojoin"); } } else if ( !strcmpi(flag,"invincible_time_inc") ) { if( !state ) { - if( maplist[m].invincible_time_inc != 0 ) { - sprintf(rflag,"invincible_time_inc\t%d",maplist[m].invincible_time_inc); + if( map->list[m].invincible_time_inc != 0 ) { + sprintf(rflag,"invincible_time_inc\t%d",map->list[m].invincible_time_inc); map_zone_mf_cache_add(m,rflag); } } if( sscanf(params, "%d", &state) == 1 ) { - if( state != maplist[m].invincible_time_inc ) { + if( state != map->list[m].invincible_time_inc ) { sprintf(rflag,"invincible_time_inc\t%s",params); map_zone_mf_cache_add(m,rflag); } } } else if ( !strcmpi(flag,"noknockback") ) { - if( state && maplist[m].flag.noknockback ) + if( state && map->list[m].flag.noknockback ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"noknockback\toff"); - else if( maplist[m].flag.noknockback ) + else if( map->list[m].flag.noknockback ) map_zone_mf_cache_add(m,"noknockback"); } } else if ( !strcmpi(flag,"weapon_damage_rate") ) { if( !state ) { - if( maplist[m].weapon_damage_rate != 100 ) { - sprintf(rflag,"weapon_damage_rate\t%d",maplist[m].weapon_damage_rate); + if( map->list[m].weapon_damage_rate != 100 ) { + sprintf(rflag,"weapon_damage_rate\t%d",map->list[m].weapon_damage_rate); map_zone_mf_cache_add(m,rflag); } } if( sscanf(params, "%d", &state) == 1 ) { - if( state != maplist[m].weapon_damage_rate ) { + if( state != map->list[m].weapon_damage_rate ) { sprintf(rflag,"weapon_damage_rate\t%s",params); map_zone_mf_cache_add(m,rflag); } } } else if ( !strcmpi(flag,"magic_damage_rate") ) { if( !state ) { - if( maplist[m].magic_damage_rate != 100 ) { - sprintf(rflag,"magic_damage_rate\t%d",maplist[m].magic_damage_rate); + if( map->list[m].magic_damage_rate != 100 ) { + sprintf(rflag,"magic_damage_rate\t%d",map->list[m].magic_damage_rate); map_zone_mf_cache_add(m,rflag); } } if( sscanf(params, "%d", &state) == 1 ) { - if( state != maplist[m].magic_damage_rate ) { + if( state != map->list[m].magic_damage_rate ) { sprintf(rflag,"magic_damage_rate\t%s",params); map_zone_mf_cache_add(m,rflag); } } } else if ( !strcmpi(flag,"misc_damage_rate") ) { if( !state ) { - if( maplist[m].misc_damage_rate != 100 ) { - sprintf(rflag,"misc_damage_rate\t%d",maplist[m].misc_damage_rate); + if( map->list[m].misc_damage_rate != 100 ) { + sprintf(rflag,"misc_damage_rate\t%d",map->list[m].misc_damage_rate); map_zone_mf_cache_add(m,rflag); } } if( sscanf(params, "%d", &state) == 1 ) { - if( state != maplist[m].misc_damage_rate ) { + if( state != map->list[m].misc_damage_rate ) { sprintf(rflag,"misc_damage_rate\t%s",params); map_zone_mf_cache_add(m,rflag); } } } else if ( !strcmpi(flag,"short_damage_rate") ) { if( !state ) { - if( maplist[m].short_damage_rate != 100 ) { - sprintf(rflag,"short_damage_rate\t%d",maplist[m].short_damage_rate); + if( map->list[m].short_damage_rate != 100 ) { + sprintf(rflag,"short_damage_rate\t%d",map->list[m].short_damage_rate); map_zone_mf_cache_add(m,rflag); } } if( sscanf(params, "%d", &state) == 1 ) { - if( state != maplist[m].short_damage_rate ) { + if( state != map->list[m].short_damage_rate ) { sprintf(rflag,"short_damage_rate\t%s",params); map_zone_mf_cache_add(m,rflag); } } } else if ( !strcmpi(flag,"long_damage_rate") ) { if( !state ) { - if( maplist[m].long_damage_rate != 100 ) { - sprintf(rflag,"long_damage_rate\t%d",maplist[m].long_damage_rate); + if( map->list[m].long_damage_rate != 100 ) { + sprintf(rflag,"long_damage_rate\t%d",map->list[m].long_damage_rate); map_zone_mf_cache_add(m,rflag); } } if( sscanf(params, "%d", &state) == 1 ) { - if( state != maplist[m].long_damage_rate ) { + if( state != map->list[m].long_damage_rate ) { sprintf(rflag,"long_damage_rate\t%s",params); map_zone_mf_cache_add(m,rflag); } @@ -4499,7 +4381,7 @@ void map_zone_apply(int m, struct map_zone_data *zone, const char* start, const int i; char empty[1] = "\0"; char flag[MAP_ZONE_MAPFLAG_LENGTH], params[MAP_ZONE_MAPFLAG_LENGTH]; - maplist[m].zone = zone; + map->list[m].zone = zone; for(i = 0; i < zone->mapflags_count; i++) { int len = strlen(zone->mapflags[i]); int k; @@ -4513,10 +4395,10 @@ void map_zone_apply(int m, struct map_zone_data *zone, const char* start, const } } - if( map_zone_mf_cache(m,flag,params) ) + if( map->zone_mf_cache(m,flag,params) ) continue; - npc->parse_mapflag(maplist[m].name,empty,flag,params,start,buffer,filepath); + npc->parse_mapflag(map->list[m].name,empty,flag,params,start,buffer,filepath); } } /* used on npc load and reload to apply all "Normal" and "PK Mode" zones */ @@ -4526,7 +4408,7 @@ void map_zone_init(void) { char empty[1] = "\0"; int i,k,j; - zone = &map_zone_all; + zone = &map->zone_all; for(i = 0; i < zone->mapflags_count; i++) { int len = strlen(zone->mapflags[i]); @@ -4540,17 +4422,17 @@ void map_zone_init(void) { } } - for(j = 0; j < map->map_num; j++) { - if( maplist[j].zone == zone ) { - if( map_zone_mf_cache(j,flag,params) ) + for(j = 0; j < map->count; j++) { + if( map->list[j].zone == zone ) { + if( map->zone_mf_cache(j,flag,params) ) break; - npc->parse_mapflag(maplist[j].name,empty,flag,params,empty,empty,empty); + npc->parse_mapflag(map->list[j].name,empty,flag,params,empty,empty,empty); } } } if( battle_config.pk_mode ) { - zone = &map_zone_pk; + zone = &map->zone_pk; for(i = 0; i < zone->mapflags_count; i++) { int len = strlen(zone->mapflags[i]); params[0] = '\0'; @@ -4562,11 +4444,11 @@ void map_zone_init(void) { break; } } - for(j = 0; j < map->map_num; j++) { - if( maplist[j].zone == zone ) { - if( map_zone_mf_cache(j,flag,params) ) + for(j = 0; j < map->count; j++) { + if( map->list[j].zone == zone ) { + if( map->zone_mf_cache(j,flag,params) ) break; - npc->parse_mapflag(maplist[j].name,empty,flag,params,empty,empty,empty); + npc->parse_mapflag(map->list[j].name,empty,flag,params,empty,empty,empty); } } } @@ -4694,7 +4576,7 @@ void read_map_zone_db(void) { continue; } - if( strdb_exists(zone_db, zonename) ) { + if( strdb_exists(map->zone_db, zonename) ) { ShowError("map_zone_db: duplicate zone name '%s', skipping...\n",zonename); config_setting_remove_elem(zones,i);/* remove from the tree */ --zone_count; @@ -4704,10 +4586,10 @@ void read_map_zone_db(void) { /* is this the global template? */ if( strncmpi(zonename,MAP_ZONE_NORMAL_NAME,MAP_ZONE_NAME_LENGTH) == 0 ) { - zone = &map_zone_all; + zone = &map->zone_all; is_all = true; } else if( strncmpi(zonename,MAP_ZONE_PK_NAME,MAP_ZONE_NAME_LENGTH) == 0 ) { - zone = &map_zone_pk; + zone = &map->zone_pk; is_all = true; } else { CREATE( zone, struct map_zone_data, 1 ); @@ -4722,14 +4604,14 @@ void read_map_zone_db(void) { for(h = 0; h < config_setting_length(skills); h++) { config_setting_t *skillinfo = config_setting_get_elem(skills, h); name = config_setting_name(skillinfo); - if( !map_zone_str2skillid(name) ) { + if( !map->zone_str2skillid(name) ) { ShowError("map_zone_db: unknown skill (%s) in disabled_skills for zone '%s', skipping skill...\n",name,zone->name); config_setting_remove_elem(skills,h); --disabled_skills_count; --h; continue; } - if( !map_zone_bl_type(config_setting_get_string_elem(skills,h),&subtype) )/* we dont remove it from the three due to inheritance */ + if( !map->zone_bl_type(config_setting_get_string_elem(skills,h),&subtype) )/* we dont remove it from the three due to inheritance */ --disabled_skills_count; } /* all ok, process */ @@ -4740,10 +4622,10 @@ void read_map_zone_db(void) { enum bl_type type; name = config_setting_name(skillinfo); - if( (type = map_zone_bl_type(config_setting_get_string_elem(skills,h),&subtype)) ) { /* only add if enabled */ + if( (type = map->zone_bl_type(config_setting_get_string_elem(skills,h),&subtype)) ) { /* only add if enabled */ CREATE( entry, struct map_zone_disabled_skill_entry, 1 ); - entry->nameid = map_zone_str2skillid(name); + entry->nameid = map->zone_str2skillid(name); entry->type = type; entry->subtype = subtype; @@ -4760,7 +4642,7 @@ void read_map_zone_db(void) { for(h = 0; h < config_setting_length(items); h++) { config_setting_t *item = config_setting_get_elem(items, h); name = config_setting_name(item); - if( !map_zone_str2itemid(name) ) { + if( !map->zone_str2itemid(name) ) { ShowError("map_zone_db: unknown item (%s) in disabled_items for zone '%s', skipping item...\n",name,zone->name); config_setting_remove_elem(items,h); --disabled_items_count; @@ -4777,7 +4659,7 @@ void read_map_zone_db(void) { if( config_setting_get_bool(item) ) { /* only add if enabled */ name = config_setting_name(item); - zone->disabled_items[v++] = map_zone_str2itemid(name); + zone->disabled_items[v++] = map->zone_str2itemid(name); } } @@ -4841,14 +4723,14 @@ void read_map_zone_db(void) { for(h = 0; h < config_setting_length(caps); h++) { config_setting_t *cap = config_setting_get_elem(caps, h); name = config_setting_name(cap); - if( !map_zone_str2skillid(name) ) { + if( !map->zone_str2skillid(name) ) { ShowError("map_zone_db: unknown skill (%s) in skill_damage_cap for zone '%s', skipping skill...\n",name,zone->name); config_setting_remove_elem(caps,h); --capped_skills_count; --h; continue; } - if( !map_zone_bl_type(config_setting_get_string_elem(cap,1),&subtype) )/* we dont remove it from the three due to inheritance */ + if( !map->zone_bl_type(config_setting_get_string_elem(cap,1),&subtype) )/* we dont remove it from the three due to inheritance */ --capped_skills_count; } /* all ok, process */ @@ -4859,10 +4741,10 @@ void read_map_zone_db(void) { enum bl_type type; name = config_setting_name(cap); - if( (type = map_zone_bl_type(config_setting_get_string_elem(cap,1),&subtype)) ) { /* only add if enabled */ + if( (type = map->zone_bl_type(config_setting_get_string_elem(cap,1),&subtype)) ) { /* only add if enabled */ CREATE( entry, struct map_zone_skill_damage_cap_entry, 1 ); - entry->nameid = map_zone_str2skillid(name); + entry->nameid = map->zone_str2skillid(name); entry->cap = config_setting_get_int_elem(cap,0); entry->type = type; entry->subtype = subtype; @@ -4873,7 +4755,7 @@ void read_map_zone_db(void) { } if( !is_all ) /* global template doesn't go into db -- since it isn't a alloc'd piece of data */ - strdb_put(zone_db, zonename, zone); + strdb_put(map->zone_db, zonename, zone); } @@ -4913,17 +4795,17 @@ void read_map_zone_db(void) { name = config_setting_get_string_elem(inherit_tree, h); config_setting_lookup_string(zone_e, "name", &zonename);/* will succeed for we validated it earlier */ - if( !(izone = strdb_get(zone_db, name)) ) { + if( !(izone = strdb_get(map->zone_db, name)) ) { ShowError("map_zone_db: Unknown zone '%s' being inherit by zone '%s', skipping...\n",name,zonename); continue; } if( strncmpi(zonename,MAP_ZONE_NORMAL_NAME,MAP_ZONE_NAME_LENGTH) == 0 ) { - zone = &map_zone_all; + zone = &map->zone_all; } else if( strncmpi(zonename,MAP_ZONE_PK_NAME,MAP_ZONE_NAME_LENGTH) == 0 ) { - zone = &map_zone_pk; + zone = &map->zone_pk; } else - zone = strdb_get(zone_db, zonename);/* will succeed for we just put it in here */ + zone = strdb_get(map->zone_db, zonename);/* will succeed for we just put it in here */ disabled_skills_count_i = izone->disabled_skills_count; disabled_items_count_i = izone->disabled_items_count; @@ -4940,7 +4822,7 @@ void read_map_zone_db(void) { int k; for(k = 0; k < disabled_skills_count; k++) { config_setting_t *skillinfo = config_setting_get_elem(skills, k); - if( map_zone_str2skillid(config_setting_name(skillinfo)) == izone->disabled_skills[j]->nameid ) { + if( map->zone_str2skillid(config_setting_name(skillinfo)) == izone->disabled_skills[j]->nameid ) { break; } } @@ -4966,7 +4848,7 @@ void read_map_zone_db(void) { name = config_setting_name(item); - if( map_zone_str2itemid(name) == izone->disabled_items[j] ) { + if( map->zone_str2itemid(name) == izone->disabled_items[j] ) { if( config_setting_get_bool(item) ) continue; break; @@ -5033,7 +4915,7 @@ void read_map_zone_db(void) { int k; for(k = 0; k < capped_skills_count; k++) { config_setting_t *cap = config_setting_get_elem(caps, k); - if( map_zone_str2skillid(config_setting_name(cap)) == izone->capped_skills[j]->nameid ) { + if( map->zone_str2skillid(config_setting_name(cap)) == izone->capped_skills[j]->nameid ) { break; } } @@ -5059,8 +4941,8 @@ void read_map_zone_db(void) { } /** -* @see DBApply -*/ + * @see DBApply + */ int map_db_final(DBKey key, DBData *data, va_list ap) { struct map_data_other_server *mdos = DB->data2ptr(data); @@ -5071,8 +4953,8 @@ int map_db_final(DBKey key, DBData *data, va_list ap) { } /** -* @see DBApply -*/ + * @see DBApply + */ int nick_db_final(DBKey key, DBData *data, va_list args) { struct charid2nick* p = DB->data2ptr(data); @@ -5094,39 +4976,39 @@ int cleanup_sub(struct block_list *bl, va_list ap) { nullpo_ret(bl); switch(bl->type) { - case BL_PC: - map->quit((struct map_session_data *) bl); - break; - case BL_NPC: - npc->unload((struct npc_data *)bl,false); - break; - case BL_MOB: - unit->free(bl,CLR_OUTSIGHT); - break; - case BL_PET: - //There is no need for this, the pet is removed together with the player. [Skotlex] - break; - case BL_ITEM: - map->clearflooritem(bl); - break; - case BL_SKILL: - skill->delunit((struct skill_unit *) bl); - break; + case BL_PC: + map->quit((struct map_session_data *) bl); + break; + case BL_NPC: + npc->unload((struct npc_data *)bl,false); + break; + case BL_MOB: + unit->free(bl,CLR_OUTSIGHT); + break; + case BL_PET: + //There is no need for this, the pet is removed together with the player. [Skotlex] + break; + case BL_ITEM: + map->clearflooritem(bl); + break; + case BL_SKILL: + skill->delunit((struct skill_unit *) bl); + break; } return 1; } /** -* @see DBApply -*/ -static int cleanup_db_sub(DBKey key, DBData *data, va_list va) { + * @see DBApply + */ +int cleanup_db_sub(DBKey key, DBData *data, va_list va) { return map->cleanup_sub(DB->data2ptr(data), va); } /*========================================== -* map destructor -*------------------------------------------*/ + * map destructor + *------------------------------------------*/ void do_final(void) { int i; @@ -5136,7 +5018,7 @@ void do_final(void) ShowStatus("Terminating...\n"); hChSys.closing = true; HPM->event(HPET_FINAL); - if (cpsd) aFree(cpsd); + if (map->cpsd) aFree(map->cpsd); //Ladies and babies first. iter = mapit_getallusers(); @@ -5148,14 +5030,14 @@ void do_final(void) npc->do_clear_npc(); // remove all objects on maps - 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) + for (i = 0; i < map->count; i++) { + ShowStatus("Cleaning up maps [%d/%d]: %s..."CL_CLL"\r", i+1, map->count, map->list[i].name); + if (map->list[i].m >= 0) map->foreachinmap(map->cleanup_sub, i, BL_ALL); } - ShowStatus("Cleaned up %d maps."CL_CLL"\n", map->map_num); + ShowStatus("Cleaned up %d maps."CL_CLL"\n", map->count); - id_db->foreach(id_db,cleanup_db_sub); + map->id_db->foreach(map->id_db,map->cleanup_db_sub); chrif->char_reset_offline(); chrif->flush_fifo(); @@ -5182,37 +5064,36 @@ void do_final(void) bg->final(); duel->final(); elemental->final(); - do_final_maps(); + map->list_final(); vending->final(); - map_db->destroy(map_db, map_db_final); + map->map_db->destroy(map->map_db, map->db_final); mapindex_final(); - if(enable_grf) + if(map->enable_grf) grfio_final(); - id_db->destroy(id_db, NULL); - pc_db->destroy(pc_db, NULL); - mobid_db->destroy(mobid_db, NULL); - bossid_db->destroy(bossid_db, NULL); - nick_db->destroy(nick_db, nick_db_final); - charid_db->destroy(charid_db, NULL); - iwall_db->destroy(iwall_db, NULL); - regen_db->destroy(regen_db, NULL); + db_destroy(map->id_db); + db_destroy(map->pc_db); + db_destroy(map->mobid_db); + db_destroy(map->bossid_db); + map->nick_db->destroy(map->nick_db, map->nick_db_final); + db_destroy(map->charid_db); + db_destroy(map->iwall_db); + db_destroy(map->regen_db); - map_sql_close(); - ers_destroy(map_iterator_ers); + map->sql_close(); + ers_destroy(map->iterator_ers); - aFree(maplist); + aFree(map->list); - if( !enable_grf ) - aFree(map_cache_buffer); + if( !map->enable_grf ) + aFree(map->cache_buffer); ShowStatus("Finished.\n"); } -static int map_abort_sub(struct map_session_data* sd, va_list ap) -{ +int map_abort_sub(struct map_session_data* sd, va_list ap) { chrif->save(sd,1); return 1; } @@ -5233,19 +5114,19 @@ void do_abort(void) run = 1; if (!chrif->isconnected()) { - if (pc_db->size(pc_db)) - ShowFatalError("Server has crashed without a connection to the char-server, %u characters can't be saved!\n", pc_db->size(pc_db)); + if (db_size(map->pc_db)) + ShowFatalError("Server has crashed without a connection to the char-server, %u characters can't be saved!\n", db_size(map->pc_db)); return; } ShowError("Server received crash signal! Attempting to save all online characters!\n"); - map->map_foreachpc(map_abort_sub); + map->foreachpc(map->abort_sub); chrif->flush_fifo(); } /*====================================================== * Map-Server Version Screen [MC Cameri] *------------------------------------------------------*/ -static void map_helpscreen(bool do_exit) +void map_helpscreen(bool do_exit) { ShowInfo("Usage: %s [options]\n", SERVER_NAME); ShowInfo("\n"); @@ -5266,9 +5147,9 @@ static void map_helpscreen(bool do_exit) } /*====================================================== -* Map-Server Version Screen [MC Cameri] -*------------------------------------------------------*/ -static void map_versionscreen(bool do_exit) { + * Map-Server Version Screen [MC Cameri] + *------------------------------------------------------*/ +void map_versionscreen(bool do_exit) { const char *svn = get_svn_revision(); const char *git = get_git_hash(); ShowInfo(CL_WHITE"Hercules version: %s" CL_RESET"\n", git[0] != HERC_UNKNOWN_VER ? git : svn[0] != HERC_UNKNOWN_VER ? svn : "Unknown"); @@ -5303,7 +5184,7 @@ void do_shutdown(void) } } -static bool map_arg_next_value(const char* option, int i, int argc) +bool map_arg_next_value(const char* option, int i, int argc) { if( i >= argc-1 ) { ShowWarning("Missing value for option '%s'.\n", option); @@ -5327,15 +5208,15 @@ CPCMD(gm_position) { return; } - if( x < 0 || x >= maplist[m].xs || y < 0 || y >= maplist[m].ys ) { + if( x < 0 || x >= map->list[m].xs || y < 0 || y >= map->list[m].ys ) { ShowError("gm:info '"CL_WHITE"%d %d"CL_RESET"' is out of '"CL_WHITE"%s"CL_RESET"' map bounds!\n",x,y,map_name); return; } ShowInfo("HCP: updated console's game position to '"CL_WHITE"%d %d %s"CL_RESET"'\n",x,y,map_name); - cpsd->bl.x = x; - cpsd->bl.y = y; - cpsd->bl.m = m; + map->cpsd->bl.x = x; + map->cpsd->bl.y = y; + map->cpsd->bl.m = m; } CPCMD(gm_use) { @@ -5343,23 +5224,23 @@ CPCMD(gm_use) { ShowError("gm:use invalid syntax. use '"CL_WHITE"gm:use @command <optional params>"CL_RESET"'\n"); return; } - cpsd->fd = -2; - if( !atcommand->parse(cpsd->fd, cpsd, line, 0) ) + map->cpsd->fd = -2; + if( !atcommand->parse(map->cpsd->fd, map->cpsd, line, 0) ) ShowInfo("HCP: '"CL_WHITE"%s"CL_RESET"' failed\n",line); else ShowInfo("HCP: '"CL_WHITE"%s"CL_RESET"' was used\n",line); - cpsd->fd = 0; + map->cpsd->fd = 0; } /* Hercules Console Parser */ void map_cp_defaults(void) { #ifdef CONSOLE_INPUT /* default HCP data */ - cpsd = pc->get_dummy_sd(); - strcpy(cpsd->status.name, "Hercules Console"); - cpsd->bl.x = MAP_DEFAULT_X; - cpsd->bl.y = MAP_DEFAULT_Y; - cpsd->bl.m = map->mapname2mapid(MAP_DEFAULT); + map->cpsd = pc->get_dummy_sd(); + strcpy(map->cpsd->status.name, "Hercules Console"); + map->cpsd->bl.x = MAP_DEFAULT_X; + map->cpsd->bl.y = MAP_DEFAULT_Y; + map->cpsd->bl.m = map->mapname2mapid(MAP_DEFAULT); console->addCommand("gm:info",CPCMD_A(gm_position)); console->addCommand("gm:use",CPCMD_A(gm_use)); @@ -5409,7 +5290,7 @@ void map_hp_symbols(void) { /* partial */ HPM->share(mapit,"mapit"); /* sql link */ - HPM->share(mmysql_handle,"sql_handle"); + HPM->share(map->mysql_handle,"sql_handle"); /* specific */ HPM->share(atcommand->create,"addCommand"); HPM->share(script->addScript,"addScript"); @@ -5417,7 +5298,7 @@ void map_hp_symbols(void) { HPM->share(HPM_map_getFromMSD,"getFromMSD"); HPM->share(HPM_map_removeFromMSD,"removeFromMSD"); /* vars */ - HPM->share(maplist,"maplist"); + HPM->share(map->list,"map->list"); } void map_load_defaults(void) { @@ -5470,44 +5351,6 @@ int do_init(int argc, char *argv[]) map_defaults(); - 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++ ) { @@ -5520,32 +5363,32 @@ int do_init(int argc, char *argv[]) arg++; if( strcmp(arg, "help") == 0 ) { - map_helpscreen(true); + map->helpscreen(true); } else if( strcmp(arg, "version") == 0 ) { - map_versionscreen(true); + map->versionscreen(true); } else if( strcmp(arg, "map-config") == 0 ) { - if( map_arg_next_value(arg, i, argc) ) + if( map->arg_next_value(arg, i, argc) ) map->MAP_CONF_NAME = argv[++i]; } else if( strcmp(arg, "battle-config") == 0 ) { - if( map_arg_next_value(arg, i, argc) ) + if( map->arg_next_value(arg, i, argc) ) map->BATTLE_CONF_FILENAME = argv[++i]; } else if( strcmp(arg, "atcommand-config") == 0 ) { - if( map_arg_next_value(arg, i, argc) ) + if( map->arg_next_value(arg, i, argc) ) map->ATCOMMAND_CONF_FILENAME = argv[++i]; } else if( strcmp(arg, "script-config") == 0 ) { - if( map_arg_next_value(arg, i, argc) ) + if( map->arg_next_value(arg, i, argc) ) map->SCRIPT_CONF_NAME = argv[++i]; } else if( strcmp(arg, "msg-config") == 0 ) { - if( map_arg_next_value(arg, i, argc) ) + if( map->arg_next_value(arg, i, argc) ) map->MSG_CONF_NAME = argv[++i]; } else if( strcmp(arg, "grf-path-file") == 0 ) { - if( map_arg_next_value(arg, i, argc) ) + if( map->arg_next_value(arg, i, argc) ) map->GRF_PATH_FILENAME = argv[++i]; } else if( strcmp(arg, "inter-config") == 0 ) { - if( map_arg_next_value(arg, i, argc) ) + if( map->arg_next_value(arg, i, argc) ) map->INTER_CONF_NAME = argv[++i]; } else if( strcmp(arg, "log-config") == 0 ) { - if( map_arg_next_value(arg, i, argc) ) + if( map->arg_next_value(arg, i, argc) ) 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; @@ -5553,32 +5396,33 @@ int do_init(int argc, char *argv[]) ShowError("Unknown option '%s'.\n", argv[i]); exit(EXIT_FAILURE); } - } else switch( arg[0] ) {// short option - case '?': - case 'h': - map_helpscreen(true); - break; - case 'v': - map_versionscreen(true); - break; - default: - ShowError("Unknown option '%s'.\n", argv[i]); - exit(EXIT_FAILURE); + } else { + switch( arg[0] ) {// short option + case '?': + case 'h': + map->helpscreen(true); + break; + case 'v': + map->versionscreen(true); + break; + default: + ShowError("Unknown option '%s'.\n", argv[i]); + exit(EXIT_FAILURE); + } } } - memset(&index2mapid, -1, sizeof(index2mapid)); map_load_defaults(); - 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); + map->config_read(map->MAP_CONF_NAME); + CREATE(map->list,struct map_data,map->count); + map->count = 0; + map->config_read_sub(map->MAP_CONF_NAME); // loads npcs map->reloadnpc(false); chrif->checkdefaultlogin(); - if (!map_ip_set || !char_ip_set) { + if (!map->ip_set || !map->char_ip_set) { char ip_str[16]; ip2str(addr_[0], ip_str); @@ -5591,46 +5435,45 @@ int do_init(int argc, char *argv[]) ShowInfo("Defaulting to %s as our IP address\n", ip_str); - if (!map_ip_set) + if (!map->ip_set) clif->setip(ip_str); - if (!char_ip_set) + if (!map->char_ip_set) chrif->setip(ip_str); } 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); + map->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 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); - nick_db = idb_alloc(DB_OPT_BASE); - charid_db = idb_alloc(DB_OPT_BASE); - regen_db = idb_alloc(DB_OPT_BASE); // efficient status_natural_heal processing + map->id_db = idb_alloc(DB_OPT_BASE); + map->pc_db = idb_alloc(DB_OPT_BASE); //Added for reliable map->id2sd() use. [Skotlex] + map->mobid_db = idb_alloc(DB_OPT_BASE); //Added to lower the load of the lazy mob ai. [Skotlex] + map->bossid_db = idb_alloc(DB_OPT_BASE); // Used for Convex Mirror quick MVP search + map->map_db = uidb_alloc(DB_OPT_BASE); + map->nick_db = idb_alloc(DB_OPT_BASE); + map->charid_db = idb_alloc(DB_OPT_BASE); + map->regen_db = idb_alloc(DB_OPT_BASE); // efficient status_natural_heal processing + map->iwall_db = strdb_alloc(DB_OPT_RELEASE_DATA,2*NAME_LENGTH+2+1); // [Zephyrus] Invisible Walls + map->zone_db = strdb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, MAP_ZONE_NAME_LENGTH); - iwall_db = strdb_alloc(DB_OPT_RELEASE_DATA,2*NAME_LENGTH+2+1); // [Zephyrus] Invisible Walls - zone_db = strdb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, MAP_ZONE_NAME_LENGTH); + map->iterator_ers = ers_new(sizeof(struct s_mapiterator),"map.c::map_iterator_ers",ERS_OPT_NONE); - map_iterator_ers = ers_new(sizeof(struct s_mapiterator),"map.c::map_iterator_ers",ERS_OPT_NONE); - - map_sql_init(); + map->sql_init(); if (logs->config.sql_logs) - log_sql_init(); + logs->sql_init(); mapindex_init(); - if(enable_grf) + if(map->enable_grf) grfio_init(map->GRF_PATH_FILENAME); - map_readallmaps(); + map->readallmaps(); - timer->add_func_list(map_freeblock_timer, "map_freeblock_timer"); - timer->add_func_list(map_clearflooritem_timer, "map_clearflooritem_timer"); - timer->add_func_list(map_removemobs_timer, "map_removemobs_timer"); - timer->add_interval(timer->gettick()+1000, map_freeblock_timer, 0, 0, 60*1000); + timer->add_func_list(map->freeblock_timer, "map_freeblock_timer"); + timer->add_func_list(map->clearflooritem_timer, "map_clearflooritem_timer"); + timer->add_func_list(map->removemobs_timer, "map_removemobs_timer"); + timer->add_interval(timer->gettick()+1000, map->freeblock_timer, 0, 0, 60*1000); HPM->load_sub = HPM_map_plugin_load_sub; HPM->symbol_defaults_sub = map_hp_symbols; @@ -5646,7 +5489,7 @@ int do_init(int argc, char *argv[]) script->init(); itemdb->init(); skill->init(); - read_map_zone_db();/* read after item and skill initalization */ + map->read_zone_db();/* read after item and skill initalization */ mob->init(); pc->init(); status->init(); @@ -5669,13 +5512,13 @@ int do_init(int argc, char *argv[]) if (battle_config.pk_mode) ShowNotice("Server is running on '"CL_WHITE"PK Mode"CL_RESET"'.\n"); - Sql_HerculesUpdateCheck(mmysql_handle); + Sql_HerculesUpdateCheck(map->mysql_handle); #ifdef CONSOLE_INPUT - console->setSQL(mmysql_handle); + console->setSQL(map->mysql_handle); #endif - ShowStatus("Server is '"CL_GREEN"ready"CL_RESET"' and listening on port '"CL_WHITE"%d"CL_RESET"'.\n\n", map_port); + 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 = map->do_shutdown; @@ -5697,6 +5540,89 @@ int do_init(int argc, char *argv[]) void map_defaults(void) { map = &map_s; + /* */ + map->count = 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"; + + map->default_codepage[0] = '\0'; + map->server_port = 3306; + sprintf(map->server_ip,"127.0.0.1"); + sprintf(map->server_id,"ragnarok"); + sprintf(map->server_pw,"ragnarok"); + sprintf(map->server_db,"ragnarok"); + map->mysql_handle = NULL; + + map->port = 0; + map->users = 0; + map->ip_set = 0; + map->char_ip_set = 0; + map->enable_grf = 0; + + memset(&map->index2mapid, -1, sizeof(map->index2mapid)); + + map->id_db = NULL; + map->pc_db = NULL; + map->mobid_db = NULL; + map->bossid_db = NULL; + map->map_db = NULL; + map->nick_db = NULL; + map->charid_db = NULL; + map->regen_db = NULL; + map->zone_db = NULL; + map->iwall_db = NULL; + + //all in a big chunk, respects order + memset(map->block_free,0,sizeof(map->block_free) + + sizeof(map->block_free_count) + + sizeof(map->block_free_lock) + + sizeof(map->bl_list) + + sizeof(map->bl_list_count) + + sizeof(map->bl_head) + + sizeof(map->zone_all) + + sizeof(map->zone_pk) + ); + + map->cpsd = NULL; + map->list = NULL; + + map->iterator_ers = NULL; + map->cache_buffer = NULL; /* funcs */ map->zone_init = map_zone_init; map->zone_remove = map_zone_remove; @@ -5742,16 +5668,16 @@ void map_defaults(void) { map->charid2nick = map_charid2nick; map->charid2sd = map_charid2sd; - map->vmap_foreachpc = map_vmap_foreachpc; - map->map_foreachpc = map_map_foreachpc; - map->vmap_foreachmob = map_vmap_foreachmob; - map->map_foreachmob = map_map_foreachmob; - map->vmap_foreachnpc = map_vmap_foreachnpc; - map->map_foreachnpc = map_map_foreachnpc; - map->vmap_foreachregen = map_vmap_foreachregen; - map->map_foreachregen = map_map_foreachregen; - map->vmap_foreachiddb = map_vmap_foreachiddb; - map->map_foreachiddb = map_map_foreachiddb; + map->vforeachpc = map_vforeachpc; + map->foreachpc = map_foreachpc; + map->vforeachmob = map_vforeachmob; + map->foreachmob = map_foreachmob; + map->vforeachnpc = map_vforeachnpc; + map->foreachnpc = map_foreachnpc; + map->vforeachregen = map_vforeachregen; + map->foreachregen = map_foreachregen; + map->vforeachiddb = map_vforeachiddb; + map->foreachiddb = map_foreachiddb; map->vforeachinrange = map_vforeachinrange; map->foreachinrange = map_foreachinrange; @@ -5819,7 +5745,57 @@ void map_defaults(void) { map->do_shutdown = do_shutdown; - /* FIXME: temporary until the map.c "Hercules Renewal Phase One" design is complete. [Ind] */ + map->freeblock_timer = map_freeblock_timer; + map->searchrandfreecell = map_searchrandfreecell; + map->count_sub = map_count_sub; + map->create_charid2nick = create_charid2nick; + map->removemobs_sub = map_removemobs_sub; + map->gat2cell = map_gat2cell; + map->cell2gat = map_cell2gat; + map->getcellp = map_getcellp; + map->setcell = map_setcell; + map->sub_getcellp = map_sub_getcellp; + map->sub_setcell = map_sub_setcell; + map->iwall_nextxy = map_iwall_nextxy; + map->create_map_data_other_server = create_map_data_other_server; + map->eraseallipport_sub = map_eraseallipport_sub; + map->init_mapcache = map_init_mapcache; + map->readfromcache = map_readfromcache; + map->addmap = map_addmap; + map->delmapid = map_delmapid; + map->zone_db_clear = map_zone_db_clear; + map->list_final = do_final_maps; + map->waterheight = map_waterheight; + map->readgat = map_readgat; + map->readallmaps = map_readallmaps; + map->config_read = map_config_read; + map->config_read_sub = map_config_read_sub; + map->reloadnpc_sub = map_reloadnpc_sub; + map->inter_config_read = inter_config_read; + map->sql_init = map_sql_init; + map->sql_close = map_sql_close; + map->zone_mf_cache = map_zone_mf_cache; + map->zone_str2itemid = map_zone_str2itemid; + map->zone_str2skillid = map_zone_str2skillid; + map->zone_bl_type = map_zone_bl_type; + map->read_zone_db = read_map_zone_db; + map->db_final = map_db_final; + map->nick_db_final = nick_db_final; + map->cleanup_db_sub = cleanup_db_sub; + map->abort_sub = map_abort_sub; + map->helpscreen = map_helpscreen; + map->versionscreen = map_versionscreen; + map->arg_next_value = map_arg_next_value; + +#ifdef CELL_NOSTACK + map->addblcell = map_addblcell; + map->delblcell = map_delblcell; +#endif + + /** + * mapit interface + **/ + mapit = &mapit_s; mapit->alloc = mapit_alloc; diff --git a/src/map/map.h b/src/map/map.h index 69152ec57..67fdfcf96 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -11,6 +11,7 @@ #include "../common/mapindex.h" #include "../common/db.h" #include "../config/core.h" +#include "../common/sql.h" #include "atcommand.h" #include <stdarg.h> @@ -40,6 +41,11 @@ enum E_MAPSERVER_ST { #define MAX_VENDING 12 #define MAX_MAP_SIZE 512*512 // Wasn't there something like this already? Can't find it.. [Shinryo] +#define BLOCK_SIZE 8 +#define block_free_max 1048576 +#define BL_LIST_MAX 1048576 + + // Added definitions for WoESE objects. [L0ne_W0lf] enum MOBID { MOBID_EMPERIUM = 1288, @@ -67,10 +73,12 @@ enum MOBID { #define JOBL_UPPER 0x1000 //4096 #define JOBL_BABY 0x2000 //8192 #define JOBL_THIRD 0x4000 //16384 + // For filtering and quick checking. #define MAPID_BASEMASK 0x00ff #define MAPID_UPPERMASK 0x0fff #define MAPID_THIRDMASK (JOBL_THIRD|MAPID_UPPERMASK) + //First Jobs //Note the oddity of the novice: //Super Novices are considered the 2-1 version of the novice! Novices are considered a first class type. @@ -215,13 +223,13 @@ enum { #define EVENT_NAME_LENGTH ( NAME_LENGTH * 2 + 3 ) #define DEFAULT_AUTOSAVE_INTERVAL 5*60*1000 // Specifies maps where players may hit each other -#define map_flag_vs(m) (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) +#define map_flag_vs(m) (map->list[m].flag.pvp || map->list[m].flag.gvg_dungeon || map->list[m].flag.gvg || ((map->agit_flag || map->agit2_flag) && map->list[m].flag.gvg_castle) || map->list[m].flag.battleground) // Specifies maps that have special GvG/WoE restrictions -#define map_flag_gvg(m) (maplist[m].flag.gvg || ((map->agit_flag || map->agit2_flag) && maplist[m].flag.gvg_castle)) +#define map_flag_gvg(m) (map->list[m].flag.gvg || ((map->agit_flag || map->agit2_flag) && map->list[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) +#define map_flag_gvg2(m) (map->list[m].flag.gvg || map->list[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) +#define map_flag_ks(m) (map->list[m].flag.town || map->list[m].flag.pvp || map->list[m].flag.gvg || map->list[m].flag.battleground) //This stackable implementation does not means a BL can be more than one type at a time, but it's // meant to make it easier to check for multiple types at a time on invocations such as map_foreach* calls [Skotlex] @@ -460,19 +468,19 @@ typedef enum { struct mapcell { // terrain flags unsigned char -walkable : 1, -shootable : 1, -water : 1; + walkable : 1, + shootable : 1, + water : 1; // dynamic flags unsigned char -npc : 1, -basilica : 1, -landprotector : 1, -novending : 1, -nochat : 1, -maelstrom : 1, -icewall : 1; + npc : 1, + basilica : 1, + landprotector : 1, + novending : 1, + nochat : 1, + maelstrom : 1, + icewall : 1; #ifdef CELL_NOSTACK unsigned char cell_bl; //Holds amount of bls in this cell. @@ -525,9 +533,6 @@ struct map_zone_skill_damage_cap_entry { #define MAP_ZONE_PK_NAME "PK Mode" #define MAP_ZONE_MAPFLAG_LENGTH 50 -//TODO place it in the map interface -DBMap *zone_db;/* string => struct map_zone_data */ - struct map_zone_data { char name[MAP_ZONE_NAME_LENGTH];/* 20'd */ struct map_zone_disabled_skill_entry **disabled_skills; @@ -542,9 +547,6 @@ struct map_zone_data { int capped_skills_count; }; -struct map_zone_data map_zone_all;/* used as a base on all maps */ -struct map_zone_data map_zone_pk;/* used for (pk_mode) */ - struct map_drop_list { int drop_id; int drop_type; @@ -696,10 +698,7 @@ struct map_data_other_server { uint16 port; }; - -struct map_data *maplist; - -#define map_id2index(id) maplist[(id)].index +#define map_id2index(id) map->list[(id)].index /// Bitfield of flags for the iterator. enum e_mapitflags { @@ -718,7 +717,7 @@ struct mapit_interface { struct block_list* (*next) (struct s_mapiterator* iter); struct block_list* (*prev) (struct s_mapiterator* iter); bool (*exists) (struct s_mapiterator* iter); -} mapit_s; +}; struct mapit_interface *mapit; @@ -743,11 +742,29 @@ typedef struct elemental_data TBL_ELEM; #define BL_CAST(type_, bl) \ ( ((bl) == (struct block_list*)NULL || (bl)->type != (type_)) ? (T ## type_ *)NULL : (T ## type_ *)(bl) ) -#include "../common/sql.h" +struct charid_request { + struct charid_request* next; + int charid;// who want to be notified of the nick +}; +struct charid2nick { + char nick[NAME_LENGTH]; + struct charid_request* requests;// requests of notification on this nick +}; +// This is the main header found at the very beginning of the map cache +struct map_cache_main_header { + uint32 file_size; + uint16 map_count; +}; + +// This is the header appended before every compressed map cells info in the map cache +struct map_cache_map_info { + char name[MAP_NAME_LENGTH]; + int16 xs; + int16 ys; + int32 len; +}; -extern Sql* mmysql_handle; -extern Sql* logmysql_handle; /*===================================== * Interface : map.h @@ -757,7 +774,7 @@ extern Sql* logmysql_handle; struct map_interface { /* vars */ - int map_num; + int count; int autosave_interval; int minsave_interval; @@ -796,6 +813,47 @@ struct map_interface { char mob_skill_db2_db[32]; char interreg_db[32]; + char default_codepage[32]; + + int server_port; + char server_ip[32]; + char server_id[32]; + char server_pw[32]; + char server_db[32]; + Sql* mysql_handle; + + int port; + int users; + int enable_grf; //To enable/disable reading maps from GRF files, bypassing mapcache [blackhole89] + int ip_set; + int char_ip_set; + + int16 index2mapid[MAX_MAPINDEX]; + /* */ + DBMap* id_db; // int id -> struct block_list* + DBMap* pc_db; // int id -> struct map_session_data* + DBMap* mobid_db; // int id -> struct mob_data* + DBMap* bossid_db; // int id -> struct mob_data* (MVP db) + DBMap* map_db; // unsigned int mapindex -> struct map_data_other_server* + DBMap* nick_db; // int char_id -> struct charid2nick* (requested names of offline characters) + DBMap* charid_db; // int char_id -> struct map_session_data* + DBMap* regen_db; // int id -> struct block_list* (status_natural_heal processing) + DBMap* zone_db; // string => struct map_zone_data + DBMap* iwall_db; + /* order respected by map_defaults() in order to zero */ + /* from block_free until zone_pk */ + struct block_list *block_free[block_free_max]; + int block_free_count, block_free_lock; + struct block_list *bl_list[BL_LIST_MAX]; + int bl_list_count; + struct block_list bl_head; + struct map_zone_data zone_all;/* used as a base on all maps */ + struct map_zone_data zone_pk;/* used for (pk_mode) */ + struct map_session_data *cpsd; + struct map_data *list; + /* [Ind/Hercules] */ + struct eri *iterator_ers; + char *cache_buffer; // Has the uncompressed gat data of all maps, so just one allocation has to be made /* funcs */ void (*zone_init) (void); void (*zone_remove) (int m); @@ -818,17 +876,17 @@ struct map_interface { // blocklist manipulation int (*addblock) (struct block_list* bl); int (*delblock) (struct block_list* bl); - int (*moveblock) (struct block_list *, int, int, unsigned int); + int (*moveblock) (struct block_list *bl, int x1, int y1, unsigned int tick); //blocklist nb in one cell int (*count_oncell) (int16 m,int16 x,int16 y,int type); - struct skill_unit * (*find_skill_unit_oncell) (struct block_list *,int16 x,int16 y,uint16 skill_id,struct skill_unit *, int flag); + struct skill_unit * (*find_skill_unit_oncell) (struct block_list* target,int16 x,int16 y,uint16 skill_id,struct skill_unit* out_unit, int flag); // search and creation int (*get_new_object_id) (void); int (*search_freecell) (struct block_list *src, int16 m, int16 *x, int16 *y, int16 rx, int16 ry, int flag); // - int (*quit) (struct map_session_data *); + int (*quit) (struct map_session_data *sd); // npc - bool (*addnpc) (int16 m,struct npc_data *); + bool (*addnpc) (int16 m,struct npc_data *nd); // map item int (*clearflooritem_timer) (int tid, unsigned int tick, int id, intptr_t data); int (*removemobs_timer) (int tid, unsigned int tick, int id, intptr_t data); @@ -841,16 +899,16 @@ struct map_interface { const char* (*charid2nick) (int charid); struct map_session_data* (*charid2sd) (int charid); - void (*vmap_foreachpc) (int (*func)(struct map_session_data* sd, va_list args), va_list args); - void (*map_foreachpc) (int (*func)(struct map_session_data* sd, va_list args), ...); - void (*vmap_foreachmob) (int (*func)(struct mob_data* md, va_list args), va_list args); - void (*map_foreachmob) (int (*func)(struct mob_data* md, va_list args), ...); - void (*vmap_foreachnpc) (int (*func)(struct npc_data* nd, va_list args), va_list args); - void (*map_foreachnpc) (int (*func)(struct npc_data* nd, va_list args), ...); - void (*vmap_foreachregen) (int (*func)(struct block_list* bl, va_list args), va_list args); - void (*map_foreachregen) (int (*func)(struct block_list* bl, va_list args), ...); - void (*vmap_foreachiddb) (int (*func)(struct block_list* bl, va_list args), va_list args); - void (*map_foreachiddb) (int (*func)(struct block_list* bl, va_list args), ...); + void (*vforeachpc) (int (*func)(struct map_session_data* sd, va_list args), va_list args); + void (*foreachpc) (int (*func)(struct map_session_data* sd, va_list args), ...); + void (*vforeachmob) (int (*func)(struct mob_data* md, va_list args), va_list args); + void (*foreachmob) (int (*func)(struct mob_data* md, va_list args), ...); + void (*vforeachnpc) (int (*func)(struct npc_data* nd, va_list args), va_list args); + void (*foreachnpc) (int (*func)(struct npc_data* nd, va_list args), ...); + void (*vforeachregen) (int (*func)(struct block_list* bl, va_list args), va_list args); + void (*foreachregen) (int (*func)(struct block_list* bl, va_list args), ...); + void (*vforeachiddb) (int (*func)(struct block_list* bl, va_list args), va_list args); + void (*foreachiddb) (int (*func)(struct block_list* bl, va_list args), ...); int (*vforeachinrange) (int (*func)(struct block_list*,va_list), struct block_list* center, int16 range, int type, va_list ap); int (*foreachinrange) (int (*func)(struct block_list*,va_list), struct block_list* center, int16 range, int type, ...); @@ -887,10 +945,10 @@ struct map_interface { int (*setipport) (unsigned short mapindex, uint32 ip, uint16 port); int (*eraseipport) (unsigned short mapindex, uint32 ip, uint16 port); int (*eraseallipport) (void); - void (*addiddb) (struct block_list *); + void (*addiddb) (struct block_list *bl); void (*deliddb) (struct block_list *bl); /* */ - struct map_session_data * (*nick2sd) (const char*); + struct map_session_data * (*nick2sd) (const char *nick); struct mob_data * (*getmob_boss) (int16 m); struct mob_data * (*id2boss) (int id); // reload config file looking only for npcs @@ -918,6 +976,52 @@ struct map_interface { void (*clean) (int i); void (*do_shutdown) (void); + + int (*freeblock_timer) (int tid, unsigned int tick, int id, intptr_t data); + int (*searchrandfreecell) (int16 m, int16 *x, int16 *y, int stack); + int (*count_sub) (struct block_list *bl, va_list ap); + DBData (*create_charid2nick) (DBKey key, va_list args); + int (*removemobs_sub) (struct block_list *bl, va_list ap); + struct mapcell (*gat2cell) (int gat); + int (*cell2gat) (struct mapcell cell); + int (*getcellp) (struct map_data *m, int16 x, int16 y, cell_chk cellchk); + void (*setcell) (int16 m, int16 x, int16 y, cell_t cell, bool flag); + int (*sub_getcellp) (struct map_data *m, int16 x, int16 y, cell_chk cellchk); + void (*sub_setcell) (int16 m, int16 x, int16 y, cell_t cell, bool flag); + void (*iwall_nextxy) (int16 x, int16 y, int8 dir, int pos, int16 *x1, int16 *y1); + DBData (*create_map_data_other_server) (DBKey key, va_list args); + int (*eraseallipport_sub) (DBKey key, DBData *data, va_list va); + char* (*init_mapcache) (FILE *fp); + int (*readfromcache) (struct map_data *m, char *buffer); + int (*addmap) (char *mapname); + void (*delmapid) (int id); + void (*zone_db_clear) (void); + void (*list_final) (void); + int (*waterheight) (char *mapname); + int (*readgat) (struct map_data *m); + int (*readallmaps) (void); + int (*config_read) (char *cfgName); + int (*config_read_sub) (char *cfgName); + void (*reloadnpc_sub) (char *cfgName); + int (*inter_config_read) (char *cfgName); + int (*sql_init) (void); + int (*sql_close) (void); + bool (*zone_mf_cache) (int m, char *flag, char *params); + unsigned short (*zone_str2itemid) (const char *name); + unsigned short (*zone_str2skillid) (const char *name); + enum bl_type (*zone_bl_type) (const char *entry, enum map_zone_skill_subtype *subtype); + void (*read_zone_db) (void); + int (*db_final) (DBKey key, DBData *data, va_list ap); + int (*nick_db_final) (DBKey key, DBData *data, va_list args); + int (*cleanup_db_sub) (DBKey key, DBData *data, va_list va); + int (*abort_sub) (struct map_session_data *sd, va_list ap); + void (*helpscreen) (bool do_exit); + void (*versionscreen) (bool do_exit); + bool (*arg_next_value) (const char *option, int i, int argc); +#ifdef CELL_NOSTACK + void (*addblcell) (struct block_list *bl); + void (*delblcell) (struct block_list *bl); +#endif }; struct map_interface *map; diff --git a/src/map/mapreg_sql.c b/src/map/mapreg_sql.c index 0a0b8f75f..902b7c39b 100644 --- a/src/map/mapreg_sql.c +++ b/src/map/mapreg_sql.c @@ -10,7 +10,7 @@ #include "../common/sql.h" #include "../common/strlib.h" #include "../common/timer.h" -#include "map.h" // mmysql_handle +#include "map.h" // map->mysql_handle #include "script.h" #include "mapreg.h" #include <stdlib.h> @@ -55,9 +55,9 @@ bool mapreg_setreg(int uid, int val) { if(name[1] != '@') {// write new variable to database char tmp_str[32*2+1]; - SQL->EscapeStringLen(mmysql_handle, tmp_str, name, strnlen(name, 32)); - if( SQL_ERROR == SQL->Query(mmysql_handle, "INSERT INTO `%s`(`varname`,`index`,`value`) VALUES ('%s','%d','%d')", mapreg->table, tmp_str, i, val) ) - Sql_ShowDebug(mmysql_handle); + SQL->EscapeStringLen(map->mysql_handle, tmp_str, name, strnlen(name, 32)); + if( SQL_ERROR == SQL->Query(map->mysql_handle, "INSERT INTO `%s`(`varname`,`index`,`value`) VALUES ('%s','%d','%d')", mapreg->table, tmp_str, i, val) ) + Sql_ShowDebug(map->mysql_handle); } idb_put(mapreg->db, uid, m); } @@ -68,8 +68,8 @@ bool mapreg_setreg(int uid, int val) { idb_remove(mapreg->db,uid); if( name[1] != '@' ) {// Remove from database because it is unused. - if( SQL_ERROR == SQL->Query(mmysql_handle, "DELETE FROM `%s` WHERE `varname`='%s' AND `index`='%d'", mapreg->table, name, i) ) - Sql_ShowDebug(mmysql_handle); + if( SQL_ERROR == SQL->Query(map->mysql_handle, "DELETE FROM `%s` WHERE `varname`='%s' AND `index`='%d'", mapreg->table, name, i) ) + Sql_ShowDebug(map->mysql_handle); } } @@ -85,8 +85,8 @@ bool mapreg_setregstr(int uid, const char* str) { if( str == NULL || *str == 0 ) { if(name[1] != '@') { - if( SQL_ERROR == SQL->Query(mmysql_handle, "DELETE FROM `%s` WHERE `varname`='%s' AND `index`='%d'", mapreg->table, name, i) ) - Sql_ShowDebug(mmysql_handle); + if( SQL_ERROR == SQL->Query(map->mysql_handle, "DELETE FROM `%s` WHERE `varname`='%s' AND `index`='%d'", mapreg->table, name, i) ) + Sql_ShowDebug(map->mysql_handle); } if( (m = idb_get(mapreg->str_db,uid)) ) { if( m->u.str != NULL ) @@ -113,10 +113,10 @@ bool mapreg_setregstr(int uid, const char* str) { if(name[1] != '@') { //put returned null, so we must insert. char tmp_str[32*2+1]; char tmp_str2[255*2+1]; - SQL->EscapeStringLen(mmysql_handle, tmp_str, name, strnlen(name, 32)); - SQL->EscapeStringLen(mmysql_handle, tmp_str2, str, strnlen(str, 255)); - if( SQL_ERROR == SQL->Query(mmysql_handle, "INSERT INTO `%s`(`varname`,`index`,`value`) VALUES ('%s','%d','%s')", mapreg->table, tmp_str, i, tmp_str2) ) - Sql_ShowDebug(mmysql_handle); + SQL->EscapeStringLen(map->mysql_handle, tmp_str, name, strnlen(name, 32)); + SQL->EscapeStringLen(map->mysql_handle, tmp_str2, str, strnlen(str, 255)); + if( SQL_ERROR == SQL->Query(map->mysql_handle, "INSERT INTO `%s`(`varname`,`index`,`value`) VALUES ('%s','%d','%s')", mapreg->table, tmp_str, i, tmp_str2) ) + Sql_ShowDebug(map->mysql_handle); } idb_put(mapreg->str_db, uid, m); } @@ -133,7 +133,7 @@ void script_load_mapreg(void) { | varname | index | value | +-------------------------+ */ - SqlStmt* stmt = SQL->StmtMalloc(mmysql_handle); + SqlStmt* stmt = SQL->StmtMalloc(map->mysql_handle); char varname[32+1]; int index; char value[255+1]; @@ -199,8 +199,8 @@ void script_save_mapreg(void) { int i = (m->uid & 0xff000000) >> 24; const char* name = script->get_str(num); - if( SQL_ERROR == SQL->Query(mmysql_handle, "UPDATE `%s` SET `value`='%d' WHERE `varname`='%s' AND `index`='%d' LIMIT 1", mapreg->table, m->u.i, name, i) ) - Sql_ShowDebug(mmysql_handle); + if( SQL_ERROR == SQL->Query(map->mysql_handle, "UPDATE `%s` SET `value`='%d' WHERE `varname`='%s' AND `index`='%d' LIMIT 1", mapreg->table, m->u.i, name, i) ) + Sql_ShowDebug(map->mysql_handle); m->save = false; } } @@ -217,9 +217,9 @@ void script_save_mapreg(void) { const char* name = script->get_str(num); char tmp_str2[2*255+1]; - SQL->EscapeStringLen(mmysql_handle, tmp_str2, m->u.str, safestrnlen(m->u.str, 255)); - if( SQL_ERROR == SQL->Query(mmysql_handle, "UPDATE `%s` SET `value`='%s' WHERE `varname`='%s' AND `index`='%d' LIMIT 1", mapreg->table, tmp_str2, name, i) ) - Sql_ShowDebug(mmysql_handle); + SQL->EscapeStringLen(map->mysql_handle, tmp_str2, m->u.str, safestrnlen(m->u.str, 255)); + if( SQL_ERROR == SQL->Query(map->mysql_handle, "UPDATE `%s` SET `value`='%s' WHERE `varname`='%s' AND `index`='%d' LIMIT 1", mapreg->table, tmp_str2, name, i) ) + Sql_ShowDebug(map->mysql_handle); m->save = false; } } diff --git a/src/map/mob.c b/src/map/mob.c index 7d04937e7..7023bcb9d 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -173,11 +173,11 @@ void mvptomb_destroy(struct mob_data *md) { map->delblock(&nd->bl); - ARR_FIND( 0, maplist[m].npc_num, i, maplist[m].npc[i] == nd ); - if( !(i == maplist[m].npc_num) ) { - maplist[m].npc_num--; - maplist[m].npc[i] = maplist[m].npc[maplist[m].npc_num]; - maplist[m].npc[maplist[m].npc_num] = NULL; + ARR_FIND( 0, map->list[m].npc_num, i, map->list[m].npc[i] == nd ); + if( !(i == map->list[m].npc_num) ) { + map->list[m].npc_num--; + map->list[m].npc[i] = map->list[m].npc[map->list[m].npc_num]; + map->list[m].npc[map->list[m].npc_num] = NULL; } map->deliddb(&nd->bl); @@ -363,7 +363,7 @@ bool mob_ksprotected (struct block_list *src, struct block_list *target) t_sd = BL_CAST(BL_PC,s_bl); do { - if( maplist[md->bl.m].flag.allowks || map_flag_ks(md->bl.m) ) + if( map->list[md->bl.m].flag.allowks || map_flag_ks(md->bl.m) ) return false; // Ignores GVG, PVP and AllowKS map flags if( md->db->mexp || md->master_id ) @@ -638,12 +638,12 @@ int mob_spawn_guardian(const char* mapname, short x, short y, const char* mobnam if( !has_index ) { guardian = -1; } else if( guardian < 0 || guardian >= MAX_GUARDIANS ) { - ShowError("mob_spawn_guardian: Invalid guardian index %d for guardian %d (castle map %s)\n", guardian, class_, maplist[m].name); + ShowError("mob_spawn_guardian: Invalid guardian index %d for guardian %d (castle map %s)\n", guardian, class_, map->list[m].name); return 0; } 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); + ShowWarning("mob_spawn_guardian: Couldn't locate a spawn cell for guardian class %d (index %d) at castle map %s\n",class_, guardian, map->list[m].name); return 0; } data.x = x; @@ -653,13 +653,13 @@ int mob_spawn_guardian(const char* mapname, short x, short y, const char* mobnam if (!mob->parse_dataset(&data)) return 0; - gc=guild->mapname2gc(maplist[m].name); + gc=guild->mapname2gc(map->list[m].name); if (gc == NULL) { - ShowError("mob_spawn_guardian: No castle set at map %s\n", maplist[m].name); + ShowError("mob_spawn_guardian: No castle set at map %s\n", map->list[m].name); return 0; } if (!gc->guild_id) - ShowWarning("mob_spawn_guardian: Spawning guardian %d on a castle with no guild (castle map %s)\n", class_, maplist[m].name); + ShowWarning("mob_spawn_guardian: Spawning guardian %d on a castle with no guild (castle map %s)\n", class_, map->list[m].name); else g = guild->search(gc->guild_id); @@ -670,7 +670,7 @@ int mob_spawn_guardian(const char* mapname, short x, short y, const char* mobnam && md2->guardian_data && md2->guardian_data->number == guardian ) { - ShowError("mob_spawn_guardian: Attempted to spawn guardian in position %d which already has a guardian (castle map %s)\n", guardian, maplist[m].name); + ShowError("mob_spawn_guardian: Attempted to spawn guardian in position %d which already has a guardian (castle map %s)\n", guardian, map->list[m].name); return 0; } } @@ -732,7 +732,7 @@ int mob_spawn_bg(const char* mapname, short x, short y, const char* mobname, int data.class_ = class_; 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); + ShowWarning("mob_spawn_bg: Couldn't locate a spawn cell for guardian class %d (bg_id %d) at map %s\n",class_, bg_id, map->list[m].name); return 0; } @@ -963,7 +963,7 @@ int mob_spawn (struct mob_data *md) mob->mvptomb_destroy(md); map->addblock(&md->bl); - if( maplist[md->bl.m].users ) + if( map->list[md->bl.m].users ) clif->spawn(&md->bl); skill->unit_move(&md->bl,tick,1); mob->skill_use(md, tick, MSC_SPAWN); @@ -1068,7 +1068,7 @@ int mob_ai_sub_hard_activesearch(struct block_list *bl,va_list ap) battle->check_range(&md->bl,bl,md->db->range2) ) { //Pick closest target? - if( maplist[bl->m].icewall_num && + if( map->list[bl->m].icewall_num && !path->search_long(NULL,bl->m,md->bl.x,md->bl.y,bl->x,bl->y,CELL_CHKICEWALL) ) { if( !check_distance_bl(&md->bl, bl, status_get_range(&md->bl) ) ) @@ -1337,7 +1337,7 @@ int mob_randomwalk(struct mob_data *md,unsigned int tick) if(i==retrycount){ md->move_fail_count++; if(md->move_fail_count>1000){ - ShowWarning("MOB can't move. random spawn %d, class = %d, at %s (%d,%d)\n",md->bl.id,md->class_,maplist[md->bl.m].name, md->bl.x, md->bl.y); + ShowWarning("MOB can't move. random spawn %d, class = %d, at %s (%d,%d)\n",md->bl.id,md->class_,map->list[md->bl.m].name, md->bl.x, md->bl.y); md->move_fail_count=0; mob->spawn(md); } @@ -1683,7 +1683,7 @@ int mob_ai_sub_lazy(struct mob_data *md, va_list args) tick = va_arg(args,unsigned int); - if (battle_config.mob_ai&0x20 && maplist[md->bl.m].users>0) + if (battle_config.mob_ai&0x20 && map->list[md->bl.m].users>0) return (int)mob->ai_sub_hard(md, tick); if (md->bl.prev==NULL || md->status.hp == 0) @@ -1720,7 +1720,7 @@ int mob_ai_sub_lazy(struct mob_data *md, va_list args) } if( DIFF_TICK(md->next_walktime,tick) < 0 && (status_get_mode(&md->bl)&MD_CANMOVE) && unit->can_move(&md->bl) ) { - if( maplist[md->bl.m].users > 0 ) + if( map->list[md->bl.m].users > 0 ) { if( rnd()%1000 < MOB_LAZYMOVEPERC(md) ) mob->randomwalk(md, tick); @@ -1741,7 +1741,7 @@ 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) { - map->map_foreachmob(mob->ai_sub_lazy,tick); + map->foreachmob(mob->ai_sub_lazy,tick); return 0; } @@ -1751,9 +1751,9 @@ int mob_ai_lazy(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) - map->map_foreachmob(mob->ai_sub_lazy,tick); + map->foreachmob(mob->ai_sub_lazy,tick); else - map->map_foreachpc(mob->ai_sub_foreachclient,tick); + map->foreachpc(mob->ai_sub_foreachclient,tick); return 0; } @@ -2145,9 +2145,9 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) { } if( !(type&2) //No exp - && (!maplist[m].flag.pvp || battle_config.pvp_exp) //Pvp no exp rule [MouseJstr] + && (!map->list[m].flag.pvp || battle_config.pvp_exp) //Pvp no exp rule [MouseJstr] && (!md->master_id || !md->special_state.ai) //Only player-summoned mobs do not give exp. [Skotlex] - && (!maplist[m].flag.nobaseexp || !maplist[m].flag.nojobexp) //Gives Exp + && (!map->list[m].flag.nobaseexp || !map->list[m].flag.nojobexp) //Gives Exp ) { //Experience calculation. int bonus = 100; //Bonus on top of your share (common to all attackers). if (md->sc.data[SC_RICHMANKIM]) @@ -2209,15 +2209,15 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) { zeny*=rnd()%250; } - if (maplist[m].flag.nobaseexp || !md->db->base_exp) + if (map->list[m].flag.nobaseexp || !md->db->base_exp) base_exp = 0; else - base_exp = (unsigned int)cap_value(md->db->base_exp * per * bonus/100. * maplist[m].bexp/100., 1, UINT_MAX); + base_exp = (unsigned int)cap_value(md->db->base_exp * per * bonus/100. * map->list[m].bexp/100., 1, UINT_MAX); - if (maplist[m].flag.nojobexp || !md->db->job_exp || md->dmglog[i].flag == MDLF_HOMUN) //Homun earned job-exp is always lost. + if (map->list[m].flag.nojobexp || !md->db->job_exp || md->dmglog[i].flag == MDLF_HOMUN) //Homun earned job-exp is always lost. job_exp = 0; else - job_exp = (unsigned int)cap_value(md->db->job_exp * per * bonus/100. * maplist[m].jexp/100., 1, UINT_MAX); + job_exp = (unsigned int)cap_value(md->db->job_exp * per * bonus/100. * map->list[m].jexp/100., 1, UINT_MAX); if ( (temp = tmpsd[i]->status.party_id) > 0 ) { int j; @@ -2271,7 +2271,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) { } //End EXP giving. - if( !(type&1) && !maplist[m].flag.nomobloot && !md->state.rebirth && ( + if( !(type&1) && !map->list[m].flag.nomobloot && !md->state.rebirth && ( !md->special_state.ai || //Non special mob battle_config.alchemist_summon_reward == 2 || //All summoned give drops (md->special_state.ai==2 && battle_config.alchemist_summon_reward == 1) //Marine Sphere Drops items. @@ -2439,7 +2439,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) { double exp; //mapflag: noexp check [Lorky] - if (maplist[m].flag.nobaseexp || type&2) + if (map->list[m].flag.nobaseexp || type&2) exp =1; else { exp = md->db->mexp; @@ -2454,7 +2454,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) { pc->gainexp(mvp_sd, &md->bl, mexp,0, false); log_mvp[1] = mexp; - if( !(maplist[m].flag.nomvploot || type&1) ) { + if( !(map->list[m].flag.nomvploot || type&1) ) { /* pose them randomly in the list -- so on 100% drop servers it wont always drop the same item */ int mdrop_id[MAX_MVP_DROP]; int mdrop_p[MAX_MVP_DROP]; @@ -2598,7 +2598,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) { return 5; // Note: Actually, it's 4. Oh well... // MvP tomb [GreenBox] - if (battle_config.mvp_tomb_enabled && md->spawn->state.boss && maplist[md->bl.m].flag.notomb != 1) + if (battle_config.mvp_tomb_enabled && md->spawn->state.boss && map->list[md->bl.m].flag.notomb != 1) mob->mvptomb_create(md, mvp_sd ? mvp_sd->status.name : NULL, time(NULL)); if( !rebirth ) { @@ -3354,12 +3354,12 @@ int mob_clone_spawn(struct map_session_data *sd, int16 m, int16 x, int16 y, cons (skill->db[idx].inf2&(INF2_WEDDING_SKILL|INF2_GUILD_SKILL)) ) continue; - for(h = 0; h < maplist[sd->bl.m].zone->disabled_skills_count; h++) { - if( skill_id == maplist[sd->bl.m].zone->disabled_skills[h]->nameid && maplist[sd->bl.m].zone->disabled_skills[h]->subtype == MZS_CLONE ) { + for(h = 0; h < map->list[sd->bl.m].zone->disabled_skills_count; h++) { + if( skill_id == map->list[sd->bl.m].zone->disabled_skills[h]->nameid && map->list[sd->bl.m].zone->disabled_skills[h]->subtype == MZS_CLONE ) { break; } } - if( h < maplist[sd->bl.m].zone->disabled_skills_count ) + if( h < map->list[sd->bl.m].zone->disabled_skills_count ) continue; //Normal aggressive mob, disable skills that cannot help them fight //against players (those with flags UF_NOMOB and UF_NOPC are specific @@ -3890,13 +3890,13 @@ int mob_read_sqldb(void) { uint32 lines = 0, count = 0; // retrieve all rows from the mob database - if( SQL_ERROR == SQL->Query(mmysql_handle, "SELECT * FROM `%s`", mob_db_name[fi]) ) { - Sql_ShowDebug(mmysql_handle); + if( SQL_ERROR == SQL->Query(map->mysql_handle, "SELECT * FROM `%s`", mob_db_name[fi]) ) { + Sql_ShowDebug(map->mysql_handle); continue; } // process rows one by one - while( SQL_SUCCESS == SQL->NextRow(mmysql_handle) ) { + while( SQL_SUCCESS == SQL->NextRow(map->mysql_handle) ) { // wrap the result into a TXT-compatible format char line[1024]; char* str[31+2*MAX_MVP_DROP+2*MAX_MOB_DROP]; @@ -3908,7 +3908,7 @@ int mob_read_sqldb(void) { { char* data; size_t len; - SQL->GetData(mmysql_handle, i, &data, &len); + SQL->GetData(map->mysql_handle, i, &data, &len); strcpy(p, data); str[i] = p; @@ -3922,7 +3922,7 @@ int mob_read_sqldb(void) { } // free the query result - SQL->FreeResult(mmysql_handle); + SQL->FreeResult(map->mysql_handle); ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, mob_db_name[fi]); } @@ -4454,13 +4454,13 @@ int mob_read_sqlskilldb(void) { uint32 lines = 0, count = 0; // retrieve all rows from the mob skill database - if( SQL_ERROR == SQL->Query(mmysql_handle, "SELECT * FROM `%s`", mob_skill_db_name[fi]) ) { - Sql_ShowDebug(mmysql_handle); + if( SQL_ERROR == SQL->Query(map->mysql_handle, "SELECT * FROM `%s`", mob_skill_db_name[fi]) ) { + Sql_ShowDebug(map->mysql_handle); continue; } // process rows one by one - while( SQL_SUCCESS == SQL->NextRow(mmysql_handle) ) { + while( SQL_SUCCESS == SQL->NextRow(map->mysql_handle) ) { // wrap the result into a TXT-compatible format char* str[19]; char* dummy = ""; @@ -4468,7 +4468,7 @@ int mob_read_sqlskilldb(void) { ++lines; for( i = 0; i < 19; ++i ) { - SQL->GetData(mmysql_handle, i, &str[i], NULL); + SQL->GetData(map->mysql_handle, i, &str[i], NULL); if( str[i] == NULL ) str[i] = dummy; // get rid of NULL columns } @@ -4479,7 +4479,7 @@ int mob_read_sqlskilldb(void) { } // free the query result - SQL->FreeResult(mmysql_handle); + SQL->FreeResult(map->mysql_handle); ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, mob_skill_db_name[fi]); } diff --git a/src/map/mob.h b/src/map/mob.h index f4cbd77c6..210983675 100644 --- a/src/map/mob.h +++ b/src/map/mob.h @@ -245,8 +245,8 @@ struct item_drop_list { #define mob_stop_walking(md, type) unit->stop_walking(&(md)->bl, type) #define mob_stop_attack(md) unit->stop_attack(&(md)->bl) -#define mob_is_battleground(md) ( maplist[(md)->bl.m].flag.battleground && ((md)->class_ == MOBID_BARRICADE2 || ((md)->class_ >= MOBID_FOOD_STOR && (md)->class_ <= MOBID_PINK_CRYST)) ) -#define mob_is_gvg(md) (maplist[(md)->bl.m].flag.gvg_castle && ( (md)->class_ == MOBID_EMPERIUM || (md)->class_ == MOBID_BARRICADE1 || (md)->class_ == MOBID_GUARIDAN_STONE1 || (md)->class_ == MOBID_GUARIDAN_STONE2) ) +#define mob_is_battleground(md) ( map->list[(md)->bl.m].flag.battleground && ((md)->class_ == MOBID_BARRICADE2 || ((md)->class_ >= MOBID_FOOD_STOR && (md)->class_ <= MOBID_PINK_CRYST)) ) +#define mob_is_gvg(md) (map->list[(md)->bl.m].flag.gvg_castle && ( (md)->class_ == MOBID_EMPERIUM || (md)->class_ == MOBID_BARRICADE1 || (md)->class_ == MOBID_GUARIDAN_STONE1 || (md)->class_ == MOBID_GUARIDAN_STONE2) ) #define mob_is_treasure(md) (((md)->class_ >= MOBID_TREAS01 && (md)->class_ <= MOBID_TREAS40) || ((md)->class_ >= MOBID_TREAS41 && (md)->class_ <= MOBID_TREAS49)) struct mob_interface { diff --git a/src/map/npc.c b/src/map/npc.c index 21e4221da..a28724238 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -881,53 +881,53 @@ int npc_touch_areanpc(struct map_session_data* sd, int16 m, int16 x, int16 y) //if(sd->npc_id) // return 1; - for(i=0;i<maplist[m].npc_num;i++) { - if (maplist[m].npc[i]->option&OPTION_INVISIBLE) { + for(i=0;i<map->list[m].npc_num;i++) { + if (map->list[m].npc[i]->option&OPTION_INVISIBLE) { f=0; // a npc was found, but it is disabled; don't print warning continue; } - switch(maplist[m].npc[i]->subtype) { + switch(map->list[m].npc[i]->subtype) { case WARP: - xs=maplist[m].npc[i]->u.warp.xs; - ys=maplist[m].npc[i]->u.warp.ys; + xs=map->list[m].npc[i]->u.warp.xs; + ys=map->list[m].npc[i]->u.warp.ys; break; case SCRIPT: - xs=maplist[m].npc[i]->u.scr.xs; - ys=maplist[m].npc[i]->u.scr.ys; + xs=map->list[m].npc[i]->u.scr.xs; + ys=map->list[m].npc[i]->u.scr.ys; break; default: continue; } - if( x >= maplist[m].npc[i]->bl.x-xs && x <= maplist[m].npc[i]->bl.x+xs - && y >= maplist[m].npc[i]->bl.y-ys && y <= maplist[m].npc[i]->bl.y+ys ) + if( x >= map->list[m].npc[i]->bl.x-xs && x <= map->list[m].npc[i]->bl.x+xs + && y >= map->list[m].npc[i]->bl.y-ys && y <= map->list[m].npc[i]->bl.y+ys ) break; } - if( i == maplist[m].npc_num ) { + if( i == map->list[m].npc_num ) { if( f == 1 ) // no npc found - ShowError("npc_touch_areanpc : stray NPC cell/NPC not found in the block on coordinates '%s',%d,%d\n", maplist[m].name, x, y); + ShowError("npc_touch_areanpc : stray NPC cell/NPC not found in the block on coordinates '%s',%d,%d\n", map->list[m].name, x, y); return 1; } - switch(maplist[m].npc[i]->subtype) { + switch(map->list[m].npc[i]->subtype) { case WARP: if( pc_ishiding(sd) || (sd->sc.count && sd->sc.data[SC_CAMOUFLAGE]) ) break; // hidden chars cannot use warps - pc->setpos(sd,maplist[m].npc[i]->u.warp.mapindex,maplist[m].npc[i]->u.warp.x,maplist[m].npc[i]->u.warp.y,CLR_OUTSIGHT); + pc->setpos(sd,map->list[m].npc[i]->u.warp.mapindex,map->list[m].npc[i]->u.warp.x,map->list[m].npc[i]->u.warp.y,CLR_OUTSIGHT); break; case SCRIPT: - for (j = i; j < maplist[m].npc_num; j++) { - if (maplist[m].npc[j]->subtype != WARP) { + for (j = i; j < map->list[m].npc_num; j++) { + if (map->list[m].npc[j]->subtype != WARP) { continue; } - if ((sd->bl.x >= (maplist[m].npc[j]->bl.x - maplist[m].npc[j]->u.warp.xs) - && sd->bl.x <= (maplist[m].npc[j]->bl.x + maplist[m].npc[j]->u.warp.xs)) - && (sd->bl.y >= (maplist[m].npc[j]->bl.y - maplist[m].npc[j]->u.warp.ys) - && sd->bl.y <= (maplist[m].npc[j]->bl.y + maplist[m].npc[j]->u.warp.ys)) + if ((sd->bl.x >= (map->list[m].npc[j]->bl.x - map->list[m].npc[j]->u.warp.xs) + && sd->bl.x <= (map->list[m].npc[j]->bl.x + map->list[m].npc[j]->u.warp.xs)) + && (sd->bl.y >= (map->list[m].npc[j]->bl.y - map->list[m].npc[j]->u.warp.ys) + && sd->bl.y <= (map->list[m].npc[j]->bl.y + map->list[m].npc[j]->u.warp.ys)) ) { if( pc_ishiding(sd) || (sd->sc.count && sd->sc.data[SC_CAMOUFLAGE]) ) break; // hidden chars cannot use warps - pc->setpos(sd,maplist[m].npc[j]->u.warp.mapindex,maplist[m].npc[j]->u.warp.x,maplist[m].npc[j]->u.warp.y,CLR_OUTSIGHT); + pc->setpos(sd,map->list[m].npc[j]->u.warp.mapindex,map->list[m].npc[j]->u.warp.x,map->list[m].npc[j]->u.warp.y,CLR_OUTSIGHT); found_warp = 1; break; } @@ -937,7 +937,7 @@ int npc_touch_areanpc(struct map_session_data* sd, int16 m, int16 x, int16 y) break; } - if( npc->ontouch_event(sd,maplist[m].npc[i]) > 0 && npc->ontouch2_event(sd,maplist[m].npc[i]) > 0 ) + if( npc->ontouch_event(sd,map->list[m].npc[i]) > 0 && npc->ontouch2_event(sd,map->list[m].npc[i]) > 0 ) { // failed to run OnTouch event, so just click the npc struct unit_data *ud = unit->bl2ud(&sd->bl); if( ud && ud->walkpath.path_pos < ud->walkpath.path_len ) @@ -945,8 +945,8 @@ int npc_touch_areanpc(struct map_session_data* sd, int16 m, int16 x, int16 y) clif->fixpos(&sd->bl); ud->walkpath.path_pos = ud->walkpath.path_len; } - sd->areanpc_id = maplist[m].npc[i]->bl.id; - npc->click(sd,maplist[m].npc[i]); + sd->areanpc_id = map->list[m].npc[i]->bl.id; + npc->click(sd,map->list[m].npc[i]); } break; } @@ -962,42 +962,42 @@ int npc_touch_areanpc2(struct mob_data *md) struct event_data* ev; int xs, ys; - for( i = 0; i < maplist[m].npc_num; i++ ) { - if( maplist[m].npc[i]->option&OPTION_INVISIBLE ) + for( i = 0; i < map->list[m].npc_num; i++ ) { + if( map->list[m].npc[i]->option&OPTION_INVISIBLE ) continue; - switch( maplist[m].npc[i]->subtype ) { + switch( map->list[m].npc[i]->subtype ) { case WARP: if( !( battle_config.mob_warp&1 ) ) continue; - xs = maplist[m].npc[i]->u.warp.xs; - ys = maplist[m].npc[i]->u.warp.ys; + xs = map->list[m].npc[i]->u.warp.xs; + ys = map->list[m].npc[i]->u.warp.ys; break; case SCRIPT: - xs = maplist[m].npc[i]->u.scr.xs; - ys = maplist[m].npc[i]->u.scr.ys; + xs = map->list[m].npc[i]->u.scr.xs; + ys = map->list[m].npc[i]->u.scr.ys; break; default: continue; // Keep Searching } - if( x >= maplist[m].npc[i]->bl.x-xs && x <= maplist[m].npc[i]->bl.x+xs && y >= maplist[m].npc[i]->bl.y-ys && y <= maplist[m].npc[i]->bl.y+ys ) { + if( x >= map->list[m].npc[i]->bl.x-xs && x <= map->list[m].npc[i]->bl.x+xs && y >= map->list[m].npc[i]->bl.y-ys && y <= map->list[m].npc[i]->bl.y+ys ) { // In the npc touch area - switch( maplist[m].npc[i]->subtype ) { + switch( map->list[m].npc[i]->subtype ) { case WARP: - xs = map->mapindex2mapid(maplist[m].npc[i]->u.warp.mapindex); + xs = map->mapindex2mapid(map->list[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 ) + if( unit->warp(&md->bl, xs, map->list[m].npc[i]->u.warp.x, map->list[m].npc[i]->u.warp.y, CLR_OUTSIGHT) == 0 ) return 1; // Warped break; case SCRIPT: - if( maplist[m].npc[i]->bl.id == md->areanpc_id ) + if( map->list[m].npc[i]->bl.id == md->areanpc_id ) break; // Already touch this NPC - snprintf(eventname, ARRAYLENGTH(eventname), "%s::OnTouchNPC", maplist[m].npc[i]->exname); + snprintf(eventname, ARRAYLENGTH(eventname), "%s::OnTouchNPC", map->list[m].npc[i]->exname); if( (ev = (struct event_data*)strdb_get(npc->ev_db, eventname)) == NULL || ev->nd == NULL ) break; // No OnTouchNPC Event - md->areanpc_id = maplist[m].npc[i]->bl.id; + md->areanpc_id = map->list[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( map->id2md(id) == NULL ) return 1; // Not Warped, but killed @@ -1023,8 +1023,8 @@ int npc_check_areanpc(int flag, int16 m, int16 x, int16 y, int16 range) { if (range < 0) return 0; x0 = max(x-range, 0); y0 = max(y-range, 0); - x1 = min(x+range, maplist[m].xs-1); - y1 = min(y+range, maplist[m].ys-1); + x1 = min(x+range, map->list[m].xs-1); + y1 = min(y+range, map->list[m].ys-1); //First check for npc_cells on the range given i = 0; @@ -1037,35 +1037,35 @@ int npc_check_areanpc(int flag, int16 m, int16 x, int16 y, int16 range) { if (!i) return 0; //No NPC_CELLs. //Now check for the actual NPC on said range. - for(i=0;i<maplist[m].npc_num;i++) { - if (maplist[m].npc[i]->option&OPTION_INVISIBLE) + for(i=0;i<map->list[m].npc_num;i++) { + if (map->list[m].npc[i]->option&OPTION_INVISIBLE) continue; - switch(maplist[m].npc[i]->subtype) { + switch(map->list[m].npc[i]->subtype) { case WARP: if (!(flag&1)) continue; - xs=maplist[m].npc[i]->u.warp.xs; - ys=maplist[m].npc[i]->u.warp.ys; + xs=map->list[m].npc[i]->u.warp.xs; + ys=map->list[m].npc[i]->u.warp.ys; break; case SCRIPT: if (!(flag&2)) continue; - xs=maplist[m].npc[i]->u.scr.xs; - ys=maplist[m].npc[i]->u.scr.ys; + xs=map->list[m].npc[i]->u.scr.xs; + ys=map->list[m].npc[i]->u.scr.ys; break; default: continue; } - if( x1 >= maplist[m].npc[i]->bl.x-xs && x0 <= maplist[m].npc[i]->bl.x+xs - && y1 >= maplist[m].npc[i]->bl.y-ys && y0 <= maplist[m].npc[i]->bl.y+ys ) + if( x1 >= map->list[m].npc[i]->bl.x-xs && x0 <= map->list[m].npc[i]->bl.x+xs + && y1 >= map->list[m].npc[i]->bl.y-ys && y0 <= map->list[m].npc[i]->bl.y+ys ) break; // found a npc } - if (i==maplist[m].npc_num) + if (i==map->list[m].npc_num) return 0; - return (maplist[m].npc[i]->bl.id); + return (map->list[m].npc[i]->bl.id); } /*========================================== @@ -1410,7 +1410,7 @@ int npc_cashshop_buy(struct map_session_data *sd, int nameid, int amount, int po if( (double)nd->u.shop.shop_item[i].value * amount > INT_MAX ) { ShowWarning("npc_cashshop_buy: Item '%s' (%d) price overflow attempt!\n", item->name, nameid); ShowDebug("(NPC:'%s' (%s,%d,%d), player:'%s' (%d/%d), value:%d, amount:%d)\n", - nd->exname, maplist[nd->bl.m].name, nd->bl.x, nd->bl.y, + nd->exname, map->list[nd->bl.m].name, nd->bl.x, nd->bl.y, sd->status.name, sd->status.account_id, sd->status.char_id, nd->u.shop.shop_item[i].value, amount); return 5; @@ -1707,13 +1707,13 @@ int npc_remove_map(struct npc_data* nd) { clif->clearunit_area(&nd->bl,CLR_RESPAWN); npc->unsetcells(nd); 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? + //Remove npc from map->list[].npc list. [Skotlex] + ARR_FIND( 0, map->list[m].npc_num, i, map->list[m].npc[i] == nd ); + if( i == map->list[m].npc_num ) return 2; //failed to find it? - maplist[m].npc_num--; - maplist[m].npc[i] = maplist[m].npc[maplist[m].npc_num]; - maplist[m].npc[maplist[m].npc_num] = NULL; + map->list[m].npc_num--; + map->list[m].npc[i] = map->list[m].npc[map->list[m].npc_num]; + map->list[m].npc[map->list[m].npc_num] = NULL; return 0; } @@ -1759,7 +1759,7 @@ 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) { - map->map_foreachnpc(npc->unload_dup_sub,nd->bl.id); + map->foreachnpc(npc->unload_dup_sub,nd->bl.id); } //Removes an npc from map and db. @@ -2054,7 +2054,7 @@ struct npc_data* npc_add_warp(char* name, short from_mapid, short from_x, short map->addblock(&nd->bl); status->set_viewdata(&nd->bl, nd->class_); nd->ud = &npc->base_ud; - if( maplist[nd->bl.m].users ) + if( map->list[nd->bl.m].users ) clif->spawn(&nd->bl); strdb_put(npc->name_db, nd->exname, nd); @@ -2086,8 +2086,8 @@ const char* npc_parse_warp(char* w1, char* w2, char* w3, char* w4, const char* s return strchr(start,'\n');// skip and continue } - if( m != -1 && ( x < 0 || x >= maplist[m].xs || y < 0 || y >= maplist[m].ys ) ) { - ShowError("npc_parse_warp: out-of-bounds coordinates (\"%s\",%d,%d), map is %dx%d, in file '%s', line '%d'\n", maplist[m].name, x, y, maplist[m].xs, maplist[m].ys,filepath,strline(buffer,start-buffer)); + if( m != -1 && ( x < 0 || x >= map->list[m].xs || y < 0 || y >= map->list[m].ys ) ) { + ShowError("npc_parse_warp: out-of-bounds coordinates (\"%s\",%d,%d), map is %dx%d, in file '%s', line '%d'\n", map->list[m].name, x, y, map->list[m].xs, map->list[m].ys,filepath,strline(buffer,start-buffer)); return strchr(start,'\n');;//try next } @@ -2119,7 +2119,7 @@ const char* npc_parse_warp(char* w1, char* w2, char* w3, char* w4, const char* s map->addblock(&nd->bl); status->set_viewdata(&nd->bl, nd->class_); nd->ud = &npc->base_ud; - if( maplist[nd->bl.m].users ) + if( map->list[nd->bl.m].users ) clif->spawn(&nd->bl); strdb_put(npc->name_db, nd->exname, nd); @@ -2152,8 +2152,8 @@ const char* npc_parse_shop(char* w1, char* w2, char* w3, char* w4, const char* s m = map->mapname2mapid(mapname); } - if( m != -1 && ( x < 0 || x >= maplist[m].xs || y < 0 || y >= maplist[m].ys ) ) { - ShowError("npc_parse_shop: out-of-bounds coordinates (\"%s\",%d,%d), map is %dx%d, in file '%s', line '%d'\n", maplist[m].name, x, y, maplist[m].xs, maplist[m].ys,filepath,strline(buffer,start-buffer)); + if( m != -1 && ( x < 0 || x >= map->list[m].xs || y < 0 || y >= map->list[m].ys ) ) { + ShowError("npc_parse_shop: out-of-bounds coordinates (\"%s\",%d,%d), map is %dx%d, in file '%s', line '%d'\n", map->list[m].name, x, y, map->list[m].xs, map->list[m].ys,filepath,strline(buffer,start-buffer)); return strchr(start,'\n');;//try next } @@ -2232,7 +2232,7 @@ const char* npc_parse_shop(char* w1, char* w2, char* w3, char* w4, const char* s status->set_viewdata(&nd->bl, nd->class_); nd->ud = &npc->base_ud; nd->dir = dir; - if( maplist[nd->bl.m].users ) + if( map->list[nd->bl.m].users ) clif->spawn(&nd->bl); } else {// 'floating' shop? map->addiddb(&nd->bl); @@ -2419,7 +2419,7 @@ const char* npc_parse_script(char* w1, char* w2, char* w3, char* w4, const char* map->addblock(&nd->bl); if( class_ >= 0 ) { status->set_viewdata(&nd->bl, nd->class_); - if( maplist[nd->bl.m].users ) + if( map->list[nd->bl.m].users ) clif->spawn(&nd->bl); } } else { @@ -2509,8 +2509,8 @@ const char* npc_parse_duplicate(char* w1, char* w2, char* w3, char* w4, const ch m = map->mapname2mapid(mapname); } - if( m != -1 && ( x < 0 || x >= maplist[m].xs || y < 0 || y >= maplist[m].ys ) ) { - ShowError("npc_parse_duplicate: out-of-bounds coordinates (\"%s\",%d,%d), map is %dx%d, in file '%s', line '%d'\n", maplist[m].name, x, y, maplist[m].xs, maplist[m].ys,filepath,strline(buffer,start-buffer)); + if( m != -1 && ( x < 0 || x >= map->list[m].xs || y < 0 || y >= map->list[m].ys ) ) { + ShowError("npc_parse_duplicate: out-of-bounds coordinates (\"%s\",%d,%d), map is %dx%d, in file '%s', line '%d'\n", map->list[m].name, x, y, map->list[m].xs, map->list[m].ys,filepath,strline(buffer,start-buffer)); return end;//try next } @@ -2575,7 +2575,7 @@ const char* npc_parse_duplicate(char* w1, char* w2, char* w3, char* w4, const ch map->addblock(&nd->bl); if( class_ >= 0 ) { status->set_viewdata(&nd->bl, nd->class_); - if( maplist[nd->bl.m].users ) + if( map->list[nd->bl.m].users ) clif->spawn(&nd->bl); } } else { @@ -2605,12 +2605,12 @@ const char* npc_parse_duplicate(char* w1, char* w2, char* w3, char* w4, const ch int npc_duplicate4instance(struct npc_data *snd, int16 m) { char newname[NAME_LENGTH]; - if( m == -1 || maplist[m].instance_id == -1 ) + if( m == -1 || map->list[m].instance_id == -1 ) return 1; - snprintf(newname, ARRAYLENGTH(newname), "dup_%d_%d", maplist[m].instance_id, snd->bl.id); + snprintf(newname, ARRAYLENGTH(newname), "dup_%d_%d", map->list[m].instance_id, snd->bl.id); if( npc->name2id(newname) != NULL ) { // Name already in use - ShowError("npc_duplicate4instance: the npcname (%s) is already in use while trying to duplicate npc %s in instance %d.\n", newname, snd->exname, maplist[m].instance_id); + ShowError("npc_duplicate4instance: the npcname (%s) is already in use while trying to duplicate npc %s in instance %d.\n", newname, snd->exname, map->list[m].instance_id); return 1; } @@ -2619,8 +2619,8 @@ int npc_duplicate4instance(struct npc_data *snd, int16 m) { int dm = map->mapindex2mapid(snd->u.warp.mapindex), im; if( dm < 0 ) return 1; - if( ( im = instance->mapid2imapid(dm, maplist[m].instance_id) ) == -1 ) { - ShowError("npc_duplicate4instance: warp (%s) leading to instanced map (%s), but instance map is not attached to current instance.\n", maplist[dm].name, snd->exname); + if( ( im = instance->mapid2imapid(dm, map->list[m].instance_id) ) == -1 ) { + ShowError("npc_duplicate4instance: warp (%s) leading to instanced map (%s), but instance map is not attached to current instance.\n", map->list[dm].name, snd->exname); return 1; } @@ -2646,14 +2646,14 @@ int npc_duplicate4instance(struct npc_data *snd, int16 m) { map->addblock(&wnd->bl); status->set_viewdata(&wnd->bl, wnd->class_); wnd->ud = &npc->base_ud; - if( maplist[wnd->bl.m].users ) + if( map->list[wnd->bl.m].users ) clif->spawn(&wnd->bl); strdb_put(npc->name_db, wnd->exname, wnd); } else { static char w1[50], w2[50], w3[50], w4[50]; const char* stat_buf = "- call from instancing subsystem -\n"; - snprintf(w1, sizeof(w1), "%s,%d,%d,%d", maplist[m].name, snd->bl.x, snd->bl.y, snd->dir); + snprintf(w1, sizeof(w1), "%s,%d,%d,%d", map->list[m].name, snd->bl.x, snd->bl.y, snd->dir); snprintf(w2, sizeof(w2), "duplicate(%s)", snd->exname); snprintf(w3, sizeof(w3), "%s::%s", snd->name, newname); @@ -2686,14 +2686,14 @@ void npc_setcells(struct npc_data* nd) { return; // Other types doesn't have touch area } - if (m < 0 || xs < 0 || ys < 0 || maplist[m].cell == (struct mapcell *)0xdeadbeaf) //invalid range or map + if (m < 0 || xs < 0 || ys < 0 || map->list[m].cell == (struct mapcell *)0xdeadbeaf) //invalid range or map return; for (i = y-ys; i <= y+ys; i++) { for (j = x-xs; j <= x+xs; j++) { if (map->getcell(m, j, i, CELL_CHKNOPASS)) continue; - maplist[m].setcell(m, j, i, CELL_NPC, true); + map->list[m].setcell(m, j, i, CELL_NPC, true); } } } @@ -2718,20 +2718,20 @@ void npc_unsetcells(struct npc_data* nd) { ys = nd->u.scr.ys; } - if (m < 0 || xs < 0 || ys < 0 || maplist[m].cell == (struct mapcell *)0xdeadbeaf) + if (m < 0 || xs < 0 || ys < 0 || map->list[m].cell == (struct mapcell *)0xdeadbeaf) return; //Locate max range on which we can locate npc cells //FIXME: does this really do what it's supposed to do? [ultramage] for(x0 = x-xs; x0 > 0 && 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(x1 = x+xs; x1 < map->list[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++); + for(y1 = y+ys; y1 < map->list[m].ys-1 && map->getcell(m, x, y1, CELL_CHKNPC); y1++); //Erase this npc's cells for (i = y-ys; i <= y+ys; i++) for (j = x-xs; j <= x+xs; j++) - maplist[m].setcell(m, j, i, CELL_NPC, false); + map->list[m].setcell(m, j, i, CELL_NPC, false); //Re-deploy NPC cells for other nearby npcs. map->foreachinarea( npc->unsetcells_sub, m, x0, y0, x1, y1, BL_NPC, nd->bl.id ); @@ -2742,8 +2742,8 @@ void npc_movenpc(struct npc_data* nd, int16 x, int16 y) const int16 m = nd->bl.m; if (m < 0 || nd->bl.prev == NULL) return; //Not on a map. - x = cap_value(x, 0, maplist[m].xs-1); - y = cap_value(y, 0, maplist[m].ys-1); + x = cap_value(x, 0, map->list[m].xs-1); + y = cap_value(y, 0, map->list[m].ys-1); map->foreachinrange(clif->outsight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl); map->moveblock(&nd->bl, x, y, timer->gettick()); @@ -2759,7 +2759,7 @@ void npc_setdisplayname(struct npc_data* nd, const char* newname) nullpo_retv(nd); safestrncpy(nd->name, newname, sizeof(nd->name)); - if( maplist[nd->bl.m].users ) + if( map->list[nd->bl.m].users ) clif->charnameack(0, &nd->bl); } @@ -2773,11 +2773,11 @@ void npc_setclass(struct npc_data* nd, short class_) { if( nd->class_ == class_ ) return; - if( maplist[nd->bl.m].users ) + if( map->list[nd->bl.m].users ) clif->clearunit_area(&nd->bl, CLR_OUTSIGHT);// fade out nd->class_ = class_; status->set_viewdata(&nd->bl, class_); - if( maplist[nd->bl.m].users ) + if( map->list[nd->bl.m].users ) clif->spawn(&nd->bl);// fade in } @@ -2931,8 +2931,8 @@ const char* npc_parse_mob(char* w1, char* w2, char* w3, char* w4, const char* st return strchr(start,'\n');// skip and continue mobspawn.m = (unsigned short)m; - if( x < 0 || x >= maplist[mobspawn.m].xs || y < 0 || y >= maplist[mobspawn.m].ys ) { - ShowError("npc_parse_mob: Spawn coordinates out of range: %s (%d,%d), map size is (%d,%d) - %s %s (file '%s', line '%d').\n", maplist[mobspawn.m].name, x, y, (maplist[mobspawn.m].xs-1), (maplist[mobspawn.m].ys-1), w1, w3, filepath, strline(buffer,start-buffer)); + if( x < 0 || x >= map->list[mobspawn.m].xs || y < 0 || y >= map->list[mobspawn.m].ys ) { + ShowError("npc_parse_mob: Spawn coordinates out of range: %s (%d,%d), map size is (%d,%d) - %s %s (file '%s', line '%d').\n", map->list[mobspawn.m].name, x, y, (map->list[mobspawn.m].xs-1), (map->list[mobspawn.m].ys-1), w1, w3, filepath, strline(buffer,start-buffer)); return strchr(start,'\n');// skip and continue } @@ -3044,7 +3044,7 @@ const char* npc_parse_mob(char* w1, char* w2, char* w3, char* w4, const char* st // check if target map has players // (usually shouldn't occur when map server is just starting, // but not the case when we do @reloadscript - if( maplist[data->m].users > 0 ) { + if( map->list[data->m].users > 0 ) { npc->parse_mob2(data); } } else { @@ -3088,68 +3088,68 @@ const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, const char if (state == 0) ; //Map flag disabled. else if (!strcmpi(w4, "SavePoint")) { - maplist[m].save.map = 0; - maplist[m].save.x = -1; - maplist[m].save.y = -1; + map->list[m].save.map = 0; + map->list[m].save.x = -1; + map->list[m].save.y = -1; } else if (sscanf(w4, "%31[^,],%d,%d", savemap, &savex, &savey) == 3) { - maplist[m].save.map = mapindex_name2id(savemap); - maplist[m].save.x = savex; - maplist[m].save.y = savey; - if (!maplist[m].save.map) { + map->list[m].save.map = mapindex_name2id(savemap); + map->list[m].save.x = savex; + map->list[m].save.y = savey; + if (!map->list[m].save.map) { ShowWarning("npc_parse_mapflag: Specified save point map '%s' for mapflag 'nosave' not found (file '%s', line '%d'), using 'SavePoint'.\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", savemap, filepath, strline(buffer,start-buffer), w1, w2, w3, w4); - maplist[m].save.x = -1; - maplist[m].save.y = -1; + map->list[m].save.x = -1; + map->list[m].save.y = -1; } } - maplist[m].flag.nosave = state; + map->list[m].flag.nosave = state; } else if (!strcmpi(w3,"autotrade")) - maplist[m].flag.autotrade=state; + map->list[m].flag.autotrade=state; else if (!strcmpi(w3,"allowks")) - maplist[m].flag.allowks=state; // [Kill Steal Protection] + map->list[m].flag.allowks=state; // [Kill Steal Protection] else if (!strcmpi(w3,"town")) - maplist[m].flag.town=state; + map->list[m].flag.town=state; else if (!strcmpi(w3,"nomemo")) - maplist[m].flag.nomemo=state; + map->list[m].flag.nomemo=state; else if (!strcmpi(w3,"noteleport")) - maplist[m].flag.noteleport=state; + map->list[m].flag.noteleport=state; else if (!strcmpi(w3,"nowarp")) - maplist[m].flag.nowarp=state; + map->list[m].flag.nowarp=state; else if (!strcmpi(w3,"nowarpto")) - maplist[m].flag.nowarpto=state; + map->list[m].flag.nowarpto=state; else if (!strcmpi(w3,"noreturn")) - maplist[m].flag.noreturn=state; + map->list[m].flag.noreturn=state; else if (!strcmpi(w3,"monster_noteleport")) - maplist[m].flag.monster_noteleport=state; + map->list[m].flag.monster_noteleport=state; else if (!strcmpi(w3,"nobranch")) - maplist[m].flag.nobranch=state; + map->list[m].flag.nobranch=state; else if (!strcmpi(w3,"nopenalty")) { - maplist[m].flag.noexppenalty=state; - maplist[m].flag.nozenypenalty=state; + map->list[m].flag.noexppenalty=state; + map->list[m].flag.nozenypenalty=state; } else if (!strcmpi(w3,"pvp")) { struct map_zone_data *zone; - maplist[m].flag.pvp = state; - if( state && (maplist[m].flag.gvg || maplist[m].flag.gvg_dungeon || maplist[m].flag.gvg_castle) ) { - maplist[m].flag.gvg = 0; - maplist[m].flag.gvg_dungeon = 0; - maplist[m].flag.gvg_castle = 0; - ShowWarning("npc_parse_mapflag: You can't set PvP and GvG flags for the same map! Removing GvG flags from %s (file '%s', line '%d').\n", maplist[m].name, filepath, strline(buffer,start-buffer)); - } - if( state && maplist[m].flag.battleground ) { - maplist[m].flag.battleground = 0; - ShowWarning("npc_parse_mapflag: You can't set PvP and BattleGround flags for the same map! Removing BattleGround flag from %s (file '%s', line '%d').\n", maplist[m].name, filepath, strline(buffer,start-buffer)); - } - if( state && (zone = strdb_get(zone_db, MAP_ZONE_PVP_NAME)) && maplist[m].zone != zone ) { + map->list[m].flag.pvp = state; + if( state && (map->list[m].flag.gvg || map->list[m].flag.gvg_dungeon || map->list[m].flag.gvg_castle) ) { + map->list[m].flag.gvg = 0; + map->list[m].flag.gvg_dungeon = 0; + map->list[m].flag.gvg_castle = 0; + ShowWarning("npc_parse_mapflag: You can't set PvP and GvG flags for the same map! Removing GvG flags from %s (file '%s', line '%d').\n", map->list[m].name, filepath, strline(buffer,start-buffer)); + } + if( state && map->list[m].flag.battleground ) { + map->list[m].flag.battleground = 0; + ShowWarning("npc_parse_mapflag: You can't set PvP and BattleGround flags for the same map! Removing BattleGround flag from %s (file '%s', line '%d').\n", map->list[m].name, filepath, strline(buffer,start-buffer)); + } + if( state && (zone = strdb_get(map->zone_db, MAP_ZONE_PVP_NAME)) && map->list[m].zone != zone ) { map->zone_change(m,zone,start,buffer,filepath); } else if ( !state ) { - maplist[m].zone = &map_zone_pk; + map->list[m].zone = &map->zone_pk; } } else if (!strcmpi(w3,"pvp_noparty")) - maplist[m].flag.pvp_noparty=state; + map->list[m].flag.pvp_noparty=state; else if (!strcmpi(w3,"pvp_noguild")) - maplist[m].flag.pvp_noguild=state; + map->list[m].flag.pvp_noguild=state; else if (!strcmpi(w3, "pvp_nightmaredrop")) { char drop_arg1[16], drop_arg2[16]; int drop_per = 0; @@ -3167,145 +3167,145 @@ const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, const char drop_type = 3; if (drop_id != 0) { - RECREATE(maplist[m].drop_list, struct map_drop_list, ++maplist[m].drop_list_count); - maplist[m].drop_list[maplist[m].drop_list_count-1].drop_id = drop_id; - maplist[m].drop_list[maplist[m].drop_list_count-1].drop_type = drop_type; - maplist[m].drop_list[maplist[m].drop_list_count-1].drop_per = drop_per; - maplist[m].flag.pvp_nightmaredrop = 1; + RECREATE(map->list[m].drop_list, struct map_drop_list, ++map->list[m].drop_list_count); + map->list[m].drop_list[map->list[m].drop_list_count-1].drop_id = drop_id; + map->list[m].drop_list[map->list[m].drop_list_count-1].drop_type = drop_type; + map->list[m].drop_list[map->list[m].drop_list_count-1].drop_per = drop_per; + map->list[m].flag.pvp_nightmaredrop = 1; } } else if (!state) //Disable - maplist[m].flag.pvp_nightmaredrop = 0; + map->list[m].flag.pvp_nightmaredrop = 0; } else if (!strcmpi(w3,"pvp_nocalcrank")) - maplist[m].flag.pvp_nocalcrank=state; + map->list[m].flag.pvp_nocalcrank=state; else if (!strcmpi(w3,"gvg")) { struct map_zone_data *zone; - maplist[m].flag.gvg = state; - if( state && maplist[m].flag.pvp ) { - maplist[m].flag.pvp = 0; - ShowWarning("npc_parse_mapflag: You can't set PvP and GvG flags for the same map! Removing PvP flag from %s (file '%s', line '%d').\n", maplist[m].name, filepath, strline(buffer,start-buffer)); + map->list[m].flag.gvg = state; + if( state && map->list[m].flag.pvp ) { + map->list[m].flag.pvp = 0; + ShowWarning("npc_parse_mapflag: You can't set PvP and GvG flags for the same map! Removing PvP flag from %s (file '%s', line '%d').\n", map->list[m].name, filepath, strline(buffer,start-buffer)); } - if( state && maplist[m].flag.battleground ) { - maplist[m].flag.battleground = 0; - ShowWarning("npc_parse_mapflag: You can't set GvG and BattleGround flags for the same map! Removing BattleGround flag from %s (file '%s', line '%d').\n", maplist[m].name, filepath, strline(buffer,start-buffer)); + if( state && map->list[m].flag.battleground ) { + map->list[m].flag.battleground = 0; + ShowWarning("npc_parse_mapflag: You can't set GvG and BattleGround flags for the same map! Removing BattleGround flag from %s (file '%s', line '%d').\n", map->list[m].name, filepath, strline(buffer,start-buffer)); } - if( state && (zone = strdb_get(zone_db, MAP_ZONE_GVG_NAME)) && maplist[m].zone != zone ) { + if( state && (zone = strdb_get(map->zone_db, MAP_ZONE_GVG_NAME)) && map->list[m].zone != zone ) { map->zone_change(m,zone,start,buffer,filepath); } } else if (!strcmpi(w3,"gvg_noparty")) - maplist[m].flag.gvg_noparty=state; + map->list[m].flag.gvg_noparty=state; else if (!strcmpi(w3,"gvg_dungeon")) { - maplist[m].flag.gvg_dungeon=state; - if (state) maplist[m].flag.pvp=0; + map->list[m].flag.gvg_dungeon=state; + if (state) map->list[m].flag.pvp=0; } else if (!strcmpi(w3,"gvg_castle")) { - maplist[m].flag.gvg_castle=state; - if (state) maplist[m].flag.pvp=0; + map->list[m].flag.gvg_castle=state; + if (state) map->list[m].flag.pvp=0; } else if (!strcmpi(w3,"battleground")) { struct map_zone_data *zone; if( state ) { if( sscanf(w4, "%d", &state) == 1 ) - maplist[m].flag.battleground = state; + map->list[m].flag.battleground = state; else - maplist[m].flag.battleground = 1; // Default value + map->list[m].flag.battleground = 1; // Default value } else - maplist[m].flag.battleground = 0; + map->list[m].flag.battleground = 0; - if( maplist[m].flag.battleground && maplist[m].flag.pvp ) { - maplist[m].flag.pvp = 0; - ShowWarning("npc_parse_mapflag: You can't set PvP and BattleGround flags for the same map! Removing PvP flag from %s (file '%s', line '%d').\n", maplist[m].name, filepath, strline(buffer,start-buffer)); + if( map->list[m].flag.battleground && map->list[m].flag.pvp ) { + map->list[m].flag.pvp = 0; + ShowWarning("npc_parse_mapflag: You can't set PvP and BattleGround flags for the same map! Removing PvP flag from %s (file '%s', line '%d').\n", map->list[m].name, filepath, strline(buffer,start-buffer)); } - if( maplist[m].flag.battleground && (maplist[m].flag.gvg || maplist[m].flag.gvg_dungeon || maplist[m].flag.gvg_castle) ) { - maplist[m].flag.gvg = 0; - maplist[m].flag.gvg_dungeon = 0; - maplist[m].flag.gvg_castle = 0; - ShowWarning("npc_parse_mapflag: You can't set GvG and BattleGround flags for the same map! Removing GvG flag from %s (file '%s', line '%d').\n", maplist[m].name, filepath, strline(buffer,start-buffer)); + if( map->list[m].flag.battleground && (map->list[m].flag.gvg || map->list[m].flag.gvg_dungeon || map->list[m].flag.gvg_castle) ) { + map->list[m].flag.gvg = 0; + map->list[m].flag.gvg_dungeon = 0; + map->list[m].flag.gvg_castle = 0; + ShowWarning("npc_parse_mapflag: You can't set GvG and BattleGround flags for the same map! Removing GvG flag from %s (file '%s', line '%d').\n", map->list[m].name, filepath, strline(buffer,start-buffer)); } - if( state && (zone = strdb_get(zone_db, MAP_ZONE_BG_NAME)) && maplist[m].zone != zone ) { + if( state && (zone = strdb_get(map->zone_db, MAP_ZONE_BG_NAME)) && map->list[m].zone != zone ) { map->zone_change(m,zone,start,buffer,filepath); } } else if (!strcmpi(w3,"noexppenalty")) - maplist[m].flag.noexppenalty=state; + map->list[m].flag.noexppenalty=state; else if (!strcmpi(w3,"nozenypenalty")) - maplist[m].flag.nozenypenalty=state; + map->list[m].flag.nozenypenalty=state; else if (!strcmpi(w3,"notrade")) - maplist[m].flag.notrade=state; + map->list[m].flag.notrade=state; else if (!strcmpi(w3,"novending")) - maplist[m].flag.novending=state; + map->list[m].flag.novending=state; else if (!strcmpi(w3,"nodrop")) - maplist[m].flag.nodrop=state; + map->list[m].flag.nodrop=state; else if (!strcmpi(w3,"noskill")) - maplist[m].flag.noskill=state; + map->list[m].flag.noskill=state; else if (!strcmpi(w3,"noicewall")) - maplist[m].flag.noicewall=state; + map->list[m].flag.noicewall=state; else if (!strcmpi(w3,"snow")) - maplist[m].flag.snow=state; + map->list[m].flag.snow=state; else if (!strcmpi(w3,"clouds")) - maplist[m].flag.clouds=state; + map->list[m].flag.clouds=state; else if (!strcmpi(w3,"clouds2")) - maplist[m].flag.clouds2=state; + map->list[m].flag.clouds2=state; else if (!strcmpi(w3,"fog")) - maplist[m].flag.fog=state; + map->list[m].flag.fog=state; else if (!strcmpi(w3,"fireworks")) - maplist[m].flag.fireworks=state; + map->list[m].flag.fireworks=state; else if (!strcmpi(w3,"sakura")) - maplist[m].flag.sakura=state; + map->list[m].flag.sakura=state; else if (!strcmpi(w3,"leaves")) - maplist[m].flag.leaves=state; + map->list[m].flag.leaves=state; else if (!strcmpi(w3,"nightenabled")) - maplist[m].flag.nightenabled=state; + map->list[m].flag.nightenabled=state; else if (!strcmpi(w3,"noexp")) { - maplist[m].flag.nobaseexp=state; - maplist[m].flag.nojobexp=state; + map->list[m].flag.nobaseexp=state; + map->list[m].flag.nojobexp=state; } else if (!strcmpi(w3,"nobaseexp")) - maplist[m].flag.nobaseexp=state; + map->list[m].flag.nobaseexp=state; else if (!strcmpi(w3,"nojobexp")) - maplist[m].flag.nojobexp=state; + map->list[m].flag.nojobexp=state; else if (!strcmpi(w3,"noloot")) { - maplist[m].flag.nomobloot=state; - maplist[m].flag.nomvploot=state; + map->list[m].flag.nomobloot=state; + map->list[m].flag.nomvploot=state; } else if (!strcmpi(w3,"nomobloot")) - maplist[m].flag.nomobloot=state; + map->list[m].flag.nomobloot=state; else if (!strcmpi(w3,"nomvploot")) - maplist[m].flag.nomvploot=state; + map->list[m].flag.nomvploot=state; else if (!strcmpi(w3,"nocommand")) { if (state) { if (sscanf(w4, "%d", &state) == 1) - maplist[m].nocommand =state; + map->list[m].nocommand =state; else //No level specified, block everyone. - maplist[m].nocommand =100; + map->list[m].nocommand =100; } else - maplist[m].nocommand=0; + map->list[m].nocommand=0; } else if (!strcmpi(w3,"jexp")) { - maplist[m].jexp = (state) ? atoi(w4) : 100; - if( maplist[m].jexp < 0 ) maplist[m].jexp = 100; - maplist[m].flag.nojobexp = (maplist[m].jexp==0)?1:0; + map->list[m].jexp = (state) ? atoi(w4) : 100; + if( map->list[m].jexp < 0 ) map->list[m].jexp = 100; + map->list[m].flag.nojobexp = (map->list[m].jexp==0)?1:0; } else if (!strcmpi(w3,"bexp")) { - maplist[m].bexp = (state) ? atoi(w4) : 100; - if( maplist[m].bexp < 0 ) maplist[m].bexp = 100; - maplist[m].flag.nobaseexp = (maplist[m].bexp==0)?1:0; + map->list[m].bexp = (state) ? atoi(w4) : 100; + if( map->list[m].bexp < 0 ) map->list[m].bexp = 100; + map->list[m].flag.nobaseexp = (map->list[m].bexp==0)?1:0; } else if (!strcmpi(w3,"loadevent")) - maplist[m].flag.loadevent=state; + map->list[m].flag.loadevent=state; else if (!strcmpi(w3,"nochat")) - maplist[m].flag.nochat=state; + map->list[m].flag.nochat=state; else if (!strcmpi(w3,"partylock")) - maplist[m].flag.partylock=state; + map->list[m].flag.partylock=state; else if (!strcmpi(w3,"guildlock")) - maplist[m].flag.guildlock=state; + map->list[m].flag.guildlock=state; else if (!strcmpi(w3,"reset")) - maplist[m].flag.reset=state; + map->list[m].flag.reset=state; else if (!strcmpi(w3,"notomb")) - maplist[m].flag.notomb=state; + map->list[m].flag.notomb=state; else if (!strcmpi(w3,"adjust_unit_duration")) { int skill_id, k; char skill_name[MAP_ZONE_MAPFLAG_LENGTH], modifier[MAP_ZONE_MAPFLAG_LENGTH]; @@ -3323,41 +3323,41 @@ const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, const char } if( modifier[0] == '\0' ) { - ShowWarning("npc_parse_mapflag: Missing 5th param for 'adjust_unit_duration' flag! removing flag from %s (file '%s', line '%d').\n", maplist[m].name, filepath, strline(buffer,start-buffer)); + ShowWarning("npc_parse_mapflag: Missing 5th param for 'adjust_unit_duration' flag! removing flag from %s (file '%s', line '%d').\n", map->list[m].name, filepath, strline(buffer,start-buffer)); } else if( !( skill_id = skill->name2id(skill_name) ) || !skill->get_unit_id( skill->name2id(skill_name), 0) ) { - ShowWarning("npc_parse_mapflag: Unknown skill (%s) for 'adjust_unit_duration' flag! removing flag from %s (file '%s', line '%d').\n",skill_name, maplist[m].name, filepath, strline(buffer,start-buffer)); + ShowWarning("npc_parse_mapflag: Unknown skill (%s) for 'adjust_unit_duration' flag! removing flag from %s (file '%s', line '%d').\n",skill_name, map->list[m].name, filepath, strline(buffer,start-buffer)); } else if ( atoi(modifier) < 1 || atoi(modifier) > USHRT_MAX ) { - ShowWarning("npc_parse_mapflag: Invalid modifier '%d' for skill '%s' for 'adjust_unit_duration' flag! removing flag from %s (file '%s', line '%d').\n", atoi(modifier), skill_name, maplist[m].name, filepath, strline(buffer,start-buffer)); + ShowWarning("npc_parse_mapflag: Invalid modifier '%d' for skill '%s' for 'adjust_unit_duration' flag! removing flag from %s (file '%s', line '%d').\n", atoi(modifier), skill_name, map->list[m].name, filepath, strline(buffer,start-buffer)); } else { - int idx = maplist[m].unit_count; + int idx = map->list[m].unit_count; - ARR_FIND(0, idx, k, maplist[m].units[k]->skill_id == skill_id); + ARR_FIND(0, idx, k, map->list[m].units[k]->skill_id == skill_id); if( k < idx ) { if( atoi(modifier) != 100 ) - maplist[m].units[k]->modifier = (unsigned short)atoi(modifier); + map->list[m].units[k]->modifier = (unsigned short)atoi(modifier); else { /* remove */ int cursor = 0; - aFree(maplist[m].units[k]); - maplist[m].units[k] = NULL; + aFree(map->list[m].units[k]); + map->list[m].units[k] = NULL; for( k = 0; k < idx; k++ ) { - if( maplist[m].units[k] == NULL ) + if( map->list[m].units[k] == NULL ) continue; - maplist[m].units[cursor] = maplist[m].units[k]; + map->list[m].units[cursor] = map->list[m].units[k]; cursor++; } - if( !( maplist[m].unit_count = cursor ) ) { - aFree(maplist[m].units); - maplist[m].units = NULL; + if( !( map->list[m].unit_count = cursor ) ) { + aFree(map->list[m].units); + map->list[m].units = NULL; } } } else if( atoi(modifier) != 100 ) { - RECREATE(maplist[m].units, struct mapflag_skill_adjust*, ++maplist[m].unit_count); - CREATE(maplist[m].units[idx],struct mapflag_skill_adjust,1); - maplist[m].units[idx]->skill_id = (unsigned short)skill_id; - maplist[m].units[idx]->modifier = (unsigned short)atoi(modifier); + RECREATE(map->list[m].units, struct mapflag_skill_adjust*, ++map->list[m].unit_count); + CREATE(map->list[m].units[idx],struct mapflag_skill_adjust,1); + map->list[m].units[idx]->skill_id = (unsigned short)skill_id; + map->list[m].units[idx]->modifier = (unsigned short)atoi(modifier); } } } else if (!strcmpi(w3,"adjust_skill_damage")) { @@ -3377,68 +3377,68 @@ const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, const char } if( modifier[0] == '\0' ) { - ShowWarning("npc_parse_mapflag: Missing 5th param for 'adjust_skill_damage' flag! removing flag from %s (file '%s', line '%d').\n", maplist[m].name, filepath, strline(buffer,start-buffer)); + ShowWarning("npc_parse_mapflag: Missing 5th param for 'adjust_skill_damage' flag! removing flag from %s (file '%s', line '%d').\n", map->list[m].name, filepath, strline(buffer,start-buffer)); } else if( !( skill_id = skill->name2id(skill_name) ) ) { - ShowWarning("npc_parse_mapflag: Unknown skill (%s) for 'adjust_skill_damage' flag! removing flag from %s (file '%s', line '%d').\n", skill_name, maplist[m].name, filepath, strline(buffer,start-buffer)); + ShowWarning("npc_parse_mapflag: Unknown skill (%s) for 'adjust_skill_damage' flag! removing flag from %s (file '%s', line '%d').\n", skill_name, map->list[m].name, filepath, strline(buffer,start-buffer)); } else if ( atoi(modifier) < 1 || atoi(modifier) > USHRT_MAX ) { - ShowWarning("npc_parse_mapflag: Invalid modifier '%d' for skill '%s' for 'adjust_skill_damage' flag! removing flag from %s (file '%s', line '%d').\n", atoi(modifier), skill_name, maplist[m].name, filepath, strline(buffer,start-buffer)); + ShowWarning("npc_parse_mapflag: Invalid modifier '%d' for skill '%s' for 'adjust_skill_damage' flag! removing flag from %s (file '%s', line '%d').\n", atoi(modifier), skill_name, map->list[m].name, filepath, strline(buffer,start-buffer)); } else { - int idx = maplist[m].skill_count; + int idx = map->list[m].skill_count; - ARR_FIND(0, idx, k, maplist[m].skills[k]->skill_id == skill_id); + ARR_FIND(0, idx, k, map->list[m].skills[k]->skill_id == skill_id); if( k < idx ) { if( atoi(modifier) != 100 ) - maplist[m].skills[k]->modifier = (unsigned short)atoi(modifier); + map->list[m].skills[k]->modifier = (unsigned short)atoi(modifier); else { /* remove */ int cursor = 0; - aFree(maplist[m].skills[k]); - maplist[m].skills[k] = NULL; + aFree(map->list[m].skills[k]); + map->list[m].skills[k] = NULL; for( k = 0; k < idx; k++ ) { - if( maplist[m].skills[k] == NULL ) + if( map->list[m].skills[k] == NULL ) continue; - maplist[m].skills[cursor] = maplist[m].skills[k]; + map->list[m].skills[cursor] = map->list[m].skills[k]; cursor++; } - if( !( maplist[m].skill_count = cursor ) ) { - aFree(maplist[m].skills); - maplist[m].skills = NULL; + if( !( map->list[m].skill_count = cursor ) ) { + aFree(map->list[m].skills); + map->list[m].skills = NULL; } } } else if( atoi(modifier) != 100 ) { - RECREATE(maplist[m].skills, struct mapflag_skill_adjust*, ++maplist[m].skill_count); - CREATE(maplist[m].skills[idx],struct mapflag_skill_adjust,1); - maplist[m].skills[idx]->skill_id = (unsigned short)skill_id; - maplist[m].skills[idx]->modifier = (unsigned short)atoi(modifier); + RECREATE(map->list[m].skills, struct mapflag_skill_adjust*, ++map->list[m].skill_count); + CREATE(map->list[m].skills[idx],struct mapflag_skill_adjust,1); + map->list[m].skills[idx]->skill_id = (unsigned short)skill_id; + map->list[m].skills[idx]->modifier = (unsigned short)atoi(modifier); } } } else if (!strcmpi(w3,"zone")) { struct map_zone_data *zone; - if( !(zone = strdb_get(zone_db, w4)) ) { - ShowWarning("npc_parse_mapflag: Invalid zone '%s'! removing flag from %s (file '%s', line '%d').\n", w4, maplist[m].name, filepath, strline(buffer,start-buffer)); - } else if( maplist[m].zone != zone ) { + if( !(zone = strdb_get(map->zone_db, w4)) ) { + ShowWarning("npc_parse_mapflag: Invalid zone '%s'! removing flag from %s (file '%s', line '%d').\n", w4, map->list[m].name, filepath, strline(buffer,start-buffer)); + } else if( map->list[m].zone != zone ) { map->zone_change(m,zone,start,buffer,filepath); } } else if ( !strcmpi(w3,"nomapchannelautojoin") ) { - maplist[m].flag.chsysnolocalaj = state; + map->list[m].flag.chsysnolocalaj = state; } else if ( !strcmpi(w3,"invincible_time_inc") ) { - maplist[m].invincible_time_inc = (state) ? atoi(w4) : 0; + map->list[m].invincible_time_inc = (state) ? atoi(w4) : 0; } else if ( !strcmpi(w3,"noknockback") ) { - maplist[m].flag.noknockback = state; + map->list[m].flag.noknockback = state; } else if ( !strcmpi(w3,"weapon_damage_rate") ) { - maplist[m].weapon_damage_rate = (state) ? atoi(w4) : 100; + map->list[m].weapon_damage_rate = (state) ? atoi(w4) : 100; } else if ( !strcmpi(w3,"magic_damage_rate") ) { - maplist[m].magic_damage_rate = (state) ? atoi(w4) : 100; + map->list[m].magic_damage_rate = (state) ? atoi(w4) : 100; } else if ( !strcmpi(w3,"misc_damage_rate") ) { - maplist[m].misc_damage_rate = (state) ? atoi(w4) : 100; + map->list[m].misc_damage_rate = (state) ? atoi(w4) : 100; } else if ( !strcmpi(w3,"short_damage_rate") ) { - maplist[m].short_damage_rate = (state) ? atoi(w4) : 100; + map->list[m].short_damage_rate = (state) ? atoi(w4) : 100; } else if ( !strcmpi(w3,"long_damage_rate") ) { - maplist[m].long_damage_rate = (state) ? atoi(w4) : 100; + map->list[m].long_damage_rate = (state) ? atoi(w4) : 100; } else ShowError("npc_parse_mapflag: unrecognized mapflag '%s' (file '%s', line '%d').\n", w3, filepath, strline(buffer,start-buffer)); @@ -3560,7 +3560,7 @@ void npc_parsesrcfile(const char* filepath, bool runOnInit) p = strchr(p,'\n');// next line continue; } - if (x < 0 || x >= maplist[m].xs || y < 0 || y >= maplist[m].ys) { + if (x < 0 || x >= map->list[m].xs || y < 0 || y >= map->list[m].ys) { ShowError("npc_parsesrcfile: Unknown coordinates ('%d', '%d') for map '%s' in file '%s', line '%d'. Skipping line...\n", x, y, mapname, filepath, strline(buffer,p-buffer)); if( strcasecmp(w2,"script") == 0 && count > 3 ) { @@ -3742,20 +3742,20 @@ int npc_reload(void) { mapit->free(iter); if(battle_config.dynamic_mobs) {// dynamic check by [random] - for (m = 0; m < map->map_num; m++) { + for (m = 0; m < map->count; m++) { for (i = 0; i < MAX_MOB_LIST_PER_MAP; i++) { - if (maplist[m].moblist[i] != NULL) { - aFree(maplist[m].moblist[i]); - maplist[m].moblist[i] = NULL; + if (map->list[m].moblist[i] != NULL) { + aFree(map->list[m].moblist[i]); + map->list[m].moblist[i] = NULL; } - if( maplist[m].mob_delete_timer != INVALID_TIMER ) + if( map->list[m].mob_delete_timer != INVALID_TIMER ) { // Mobs were removed anyway,so delete the timer [Inkfish] - timer->delete(maplist[m].mob_delete_timer, map->removemobs_timer); - maplist[m].mob_delete_timer = INVALID_TIMER; + timer->delete(map->list[m].mob_delete_timer, map->removemobs_timer); + map->list[m].mob_delete_timer = INVALID_TIMER; } } - if (maplist[m].npc_num > 0) - ShowWarning("npc_reload: %d npcs weren't removed at map %s!\n", maplist[m].npc_num, maplist[m].name); + if (map->list[m].npc_num > 0) + ShowWarning("npc_reload: %d npcs weren't removed at map %s!\n", map->list[m].npc_num, map->list[m].name); } } @@ -3865,24 +3865,24 @@ void npc_debug_warps_sub(struct npc_data* nd) { 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 + map->list[nd->bl.m].name, nd->bl.x, nd->bl.y, + map->list[m].name, nd->u.warp.x, nd->u.warp.y ); } 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, - maplist[m].name, nd->u.warp.x, nd->u.warp.y + map->list[nd->bl.m].name, nd->bl.x, nd->bl.y, + map->list[m].name, nd->u.warp.x, nd->u.warp.y ); } } static void npc_debug_warps(void) { int16 m, i; - 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]); + for (m = 0; m < map->count; m++) + for (i = 0; i < map->list[m].npc_num; i++) + npc->debug_warps_sub(map->list[m].npc[i]); } /*========================================== diff --git a/src/map/party.c b/src/map/party.c index a3fd5019f..1694adf2c 100644 --- a/src/map/party.c +++ b/src/map/party.c @@ -630,7 +630,7 @@ bool party_changeleader(struct map_session_data *sd, struct map_session_data *ts return false; } - if( maplist[sd->bl.m].flag.partylock ) { + if( map->list[sd->bl.m].flag.partylock ) { clif->message(sd->fd, msg_txt(287)); return false; } diff --git a/src/map/path.c b/src/map/path.c index 79e004601..a47677cf5 100644 --- a/src/map/path.c +++ b/src/map/path.c @@ -68,9 +68,9 @@ int path_blownpos(int16 m,int16 x0,int16 y0,int16 dx,int16 dy,int count) { struct map_data *md; - if( !maplist[m].cell ) + if( !map->list[m].cell ) return -1; - md = &maplist[m]; + md = &map->list[m]; if( count>25 ){ //Cap to prevent too much processing...? ShowWarning("path_blownpos: count too many %d !\n",count); @@ -121,9 +121,9 @@ bool path_search_long(struct shootpath_data *spd,int16 m,int16 x0,int16 y0,int16 if( spd == NULL ) spd = &s_spd; // use dummy output variable - if (!maplist[m].cell) + if (!map->list[m].cell) return false; - md = &maplist[m]; + md = &map->list[m]; dx = (x1 - x0); if (dx < 0) { @@ -255,9 +255,9 @@ bool path_search(struct walkpath_data *wpd, int16 m, int16 x0, int16 y0, int16 x if (wpd == NULL) wpd = &s_wpd; // use dummy output variable - if (!maplist[m].cell) + if (!map->list[m].cell) return false; - md = &maplist[m]; + md = &map->list[m]; #ifdef CELL_NOSTACK //Do not check starting cell as that would get you stuck. diff --git a/src/map/pc.c b/src/map/pc.c index 17734dfe8..58972a204 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -136,7 +136,7 @@ int pc_invincible_timer(int tid, unsigned int tick, int id, intptr_t data) { void pc_setinvincibletimer(struct map_session_data* sd, int val) { nullpo_retv(sd); - val += maplist[sd->bl.m].invincible_time_inc; + val += map->list[sd->bl.m].invincible_time_inc; if( sd->invincible_timer != INVALID_TIMER ) timer->delete(sd->invincible_timer,pc->invincible_timer); @@ -547,8 +547,8 @@ int pc_makesavestatus(struct map_session_data *sd) sd->status.last_point.y = sd->bl.y; } - if(maplist[sd->bl.m].flag.nosave || maplist[sd->bl.m].instance_id >= 0) { - struct map_data *m=&maplist[sd->bl.m]; + if(map->list[sd->bl.m].flag.nosave || map->list[sd->bl.m].instance_id >= 0) { + struct map_data *m=&map->list[sd->bl.m]; if(m->save.map) memcpy(&sd->status.last_point,&m->save,sizeof(sd->status.last_point)); else @@ -1273,9 +1273,9 @@ int pc_reg_received(struct map_session_data *sd) sd->vd.class_ = INVISIBLE_CLASS; clif->message(sd->fd, msg_txt(11)); // Invisible: On // decrement the number of pvp players on the map - maplist[sd->bl.m].users_pvp--; + map->list[sd->bl.m].users_pvp--; - if( maplist[sd->bl.m].flag.pvp && !maplist[sd->bl.m].flag.pvp_nocalcrank && sd->pvp_timer != INVALID_TIMER ) {// unregister the player for ranking + if( map->list[sd->bl.m].flag.pvp && !map->list[sd->bl.m].flag.pvp_nocalcrank && sd->pvp_timer != INVALID_TIMER ) {// unregister the player for ranking timer->delete( sd->pvp_timer, pc->calc_pvprank_timer ); sd->pvp_timer = INVALID_TIMER; } @@ -3998,7 +3998,7 @@ int pc_dropitem(struct map_session_data *sd,int n,int amount) ) return 0; - if( maplist[sd->bl.m].flag.nodrop ) { + if( map->list[sd->bl.m].flag.nodrop ) { clif->message (sd->fd, msg_txt(271)); return 0; //Can't drop items in nodrop mapflag maps. } @@ -4126,7 +4126,7 @@ int pc_isUseitem(struct map_session_data *sd,int n) break; case 601: // Fly Wing case 12212: // Giant Fly Wing - if( maplist[sd->bl.m].flag.noteleport || map_flag_gvg2(sd->bl.m) ) { + if( map->list[sd->bl.m].flag.noteleport || map_flag_gvg2(sd->bl.m) ) { clif->skill_mapinfomessage(sd,0); return 0; } @@ -4143,14 +4143,14 @@ int pc_isUseitem(struct map_session_data *sd,int n) clif->message(sd->fd, msg_txt(663)); return 0; } - if( nameid != 601 && nameid != 12212 && maplist[sd->bl.m].flag.noreturn ) + if( nameid != 601 && nameid != 12212 && map->list[sd->bl.m].flag.noreturn ) return 0; break; case 604: // Dead Branch case 12024: // Red Pouch case 12103: // Bloody Branch case 12109: // Poring Box - if( maplist[sd->bl.m].flag.nobranch || map_flag_gvg2(sd->bl.m) ) + if( map->list[sd->bl.m].flag.nobranch || map_flag_gvg2(sd->bl.m) ) return 0; break; case 12210: // Bubble Gum @@ -4191,7 +4191,7 @@ int pc_isUseitem(struct map_session_data *sd,int n) break; case 12213: //Neuralizer - if( !maplist[sd->bl.m].flag.reset ) + if( !map->list[sd->bl.m].flag.reset ) return 0; break; } @@ -4365,8 +4365,8 @@ int pc_useitem(struct map_session_data *sd,int n) { } /* on restricted maps the item is consumed but the effect is not used */ - for(i = 0; i < maplist[sd->bl.m].zone->disabled_items_count; i++) { - if( maplist[sd->bl.m].zone->disabled_items[i] == nameid ) { + for(i = 0; i < map->list[sd->bl.m].zone->disabled_items_count; i++) { + if( map->list[sd->bl.m].zone->disabled_items[i] == nameid ) { clif->msg(sd, ITEM_CANT_USE_AREA); // This item cannot be used within this area if( battle_config.item_restricted_consumption_type ) { clif->useitemack(sd,n,sd->status.inventory[n].amount-1,true); @@ -4636,7 +4636,7 @@ int pc_steal_item(struct map_session_data *sd,struct block_list *bl, uint16 skil 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] + map->list[bl->m].flag.nomobloot || // check noloot map flag [Lorky] (battle_config.skill_steal_max_tries && //Reached limit of steal attempts. [Lupus] md->state.steal_flag++ >= battle_config.skill_steal_max_tries) ) { //Can't steal from @@ -4744,7 +4744,7 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y pc->setrestartvalue(sd,1); } - if( maplist[m].flag.src4instance ) { + if( map->list[m].flag.src4instance ) { struct party_data *p; bool stop = false; int i = 0, j = 0; @@ -4752,7 +4752,7 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y if( sd->instances ) { for( i = 0; i < sd->instances; i++ ) { if( sd->instance[i] >= 0 ) { - ARR_FIND(0, instance->list[sd->instance[i]].num_map, j, maplist[instance->list[sd->instance[i]].map[j]].instance_src_map == m && !maplist[instance->list[sd->instance[i]].map[j]].custom_name); + ARR_FIND(0, instance->list[sd->instance[i]].num_map, j, map->list[instance->list[sd->instance[i]].map[j]].instance_src_map == m && !map->list[instance->list[sd->instance[i]].map[j]].custom_name); if( j != instance->list[sd->instance[i]].num_map ) break; } @@ -4766,7 +4766,7 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y if ( !stop && sd->status.party_id && (p = party->search(sd->status.party_id)) && p->instances ) { for( i = 0; i < p->instances; i++ ) { if( p->instance[i] >= 0 ) { - ARR_FIND(0, instance->list[p->instance[i]].num_map, j, maplist[instance->list[p->instance[i]].map[j]].instance_src_map == m && !maplist[instance->list[p->instance[i]].map[j]].custom_name); + ARR_FIND(0, instance->list[p->instance[i]].num_map, j, map->list[instance->list[p->instance[i]].map[j]].instance_src_map == m && !map->list[instance->list[p->instance[i]].map[j]].custom_name); if( j != instance->list[p->instance[i]].num_map ) break; } @@ -4780,7 +4780,7 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y if ( !stop && sd->status.guild_id && sd->guild && sd->guild->instances ) { for( i = 0; i < sd->guild->instances; i++ ) { if( sd->guild->instance[i] >= 0 ) { - ARR_FIND(0, instance->list[sd->guild->instance[i]].num_map, j, maplist[instance->list[sd->guild->instance[i]].map[j]].instance_src_map == m && !maplist[instance->list[sd->guild->instance[i]].map[j]].custom_name); + ARR_FIND(0, instance->list[sd->guild->instance[i]].num_map, j, map->list[instance->list[sd->guild->instance[i]].map[j]].instance_src_map == m && !map->list[instance->list[sd->guild->instance[i]].map[j]].custom_name); if( j != instance->list[sd->guild->instance[i]].num_map ) break; } @@ -4803,13 +4803,13 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y for( i = 0; i < sd->queues_count; i++ ) { struct hQueue *queue; if( (queue = script->queue(sd->queues[i])) && queue->onMapChange[0] != '\0' ) { - pc->setregstr(sd, script->add_str("QMapChangeTo"), maplist[m].name); + pc->setregstr(sd, script->add_str("QMapChangeTo"), map->list[m].name); npc->event(sd, queue->onMapChange, 0); } } - if( maplist[m].cell == (struct mapcell *)0xdeadbeaf ) - map->cellfromcache(&maplist[m]); + if( map->list[m].cell == (struct mapcell *)0xdeadbeaf ) + map->cellfromcache(&map->list[m]); if (sd->sc.count) { // Cancel some map related stuff. if (sd->sc.data[SC_JAILED]) return 1; //You may not get out! @@ -4842,13 +4842,13 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y if (sd->regen.state.gc) sd->regen.state.gc = 0; // make sure vending is allowed here - if (sd->state.vending && maplist[m].flag.novending) { + if (sd->state.vending && map->list[m].flag.novending) { clif->message (sd->fd, msg_txt(276)); // "You can't open a shop on this map" vending->close(sd); } - if( hChSys.local && maplist[sd->bl.m].channel && idb_exists(maplist[sd->bl.m].channel->users, sd->status.char_id) ) { - clif->chsys_left(maplist[sd->bl.m].channel,sd); + if( hChSys.local && map->list[sd->bl.m].channel && idb_exists(map->list[sd->bl.m].channel->users, sd->status.char_id) ) { + clif->chsys_left(map->list[sd->bl.m].channel,sd); } } @@ -4877,15 +4877,15 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y return 0; } - if( x < 0 || x >= maplist[m].xs || y < 0 || y >= maplist[m].ys ) { + if( x < 0 || x >= map->list[m].xs || y < 0 || y >= map->list[m].ys ) { ShowError("pc_setpos: attempt to place player %s (%d:%d) on invalid coordinates (%s-%d,%d)\n", sd->status.name, sd->status.account_id, sd->status.char_id, mapindex_id2name(mapindex),x,y); x = y = 0; // make it random } if( x == 0 && y == 0 ) {// pick a random walkable cell do { - x=rnd()%(maplist[m].xs-2)+1; - y=rnd()%(maplist[m].ys-2)+1; + x=rnd()%(map->list[m].xs-2)+1; + y=rnd()%(map->list[m].ys-2)+1; } while(map->getcell(m,x,y,CELL_CHKNOPASS)); } @@ -4906,7 +4906,7 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y sd->bl.x = sd->ud.to_x = x; sd->bl.y = sd->ud.to_y = y; - if( sd->status.guild_id > 0 && maplist[m].flag.gvg_castle ) { // Increased guild castle regen [Valaris] + if( sd->status.guild_id > 0 && map->list[m].flag.gvg_castle ) { // Increased guild castle regen [Valaris] struct guild_castle *gc = guild->mapindex2gc(sd->mapindex); if(gc && gc->guild_id == sd->status.guild_id) sd->regen.state.gc = 1; @@ -4951,12 +4951,12 @@ int pc_randomwarp(struct map_session_data *sd, clr_type type) { m=sd->bl.m; - if (maplist[sd->bl.m].flag.noteleport) //Teleport forbidden + if (map->list[sd->bl.m].flag.noteleport) //Teleport forbidden return 0; do { - x=rnd()%(maplist[m].xs-2)+1; - y=rnd()%(maplist[m].ys-2)+1; + x=rnd()%(map->list[m].xs-2)+1; + y=rnd()%(map->list[m].ys-2)+1; } while( map->getcell(m,x,y,CELL_CHKNOPASS) && (i++) < 1000 ); if (i < 1000) @@ -4975,7 +4975,7 @@ int pc_memo(struct map_session_data* sd, int pos) { nullpo_ret(sd); // check mapflags - if( sd->bl.m >= 0 && (maplist[sd->bl.m].flag.nomemo || maplist[sd->bl.m].flag.nowarpto) && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE) ) { + if( sd->bl.m >= 0 && (map->list[sd->bl.m].flag.nomemo || map->list[sd->bl.m].flag.nowarpto) && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE) ) { clif->skill_mapinfomessage(sd, 1); // "Saved point cannot be memorized." return 0; } @@ -5833,7 +5833,7 @@ int pc_gainexp(struct map_session_data *sd, struct block_list *src, unsigned int if(sd->bl.prev == NULL || pc_isdead(sd)) return 0; - if(!battle_config.pvp_exp && maplist[sd->bl.m].flag.pvp) // [MouseJstr] + if(!battle_config.pvp_exp && map->list[sd->bl.m].flag.pvp) // [MouseJstr] return 0; // no exp on pvp maps if(sd->status.guild_id>0) @@ -6651,7 +6651,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) { if(sd->status.pet_id > 0 && sd->pd) { struct pet_data *pd = sd->pd; - if( !maplist[sd->bl.m].flag.noexppenalty ) { + if( !map->list[sd->bl.m].flag.noexppenalty ) { pet->set_intimate(pd, pd->pet.intimate - pd->petDB->die); if( pd->pet.intimate < 0 ) pd->pet.intimate = 0; @@ -6809,7 +6809,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) { } if( battle_config.bone_drop==2 - || (battle_config.bone_drop==1 && maplist[sd->bl.m].flag.pvp) + || (battle_config.bone_drop==1 && map->list[sd->bl.m].flag.pvp) ) { struct item item_tmp; memset(&item_tmp,0,sizeof(item_tmp)); @@ -6843,7 +6843,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) { // changed penalty options, added death by player if pk_mode [Valaris] if( battle_config.death_penalty_type && (sd->class_&MAPID_UPPERMASK) != MAPID_NOVICE // only novices will receive no penalty - && !maplist[sd->bl.m].flag.noexppenalty && !map_flag_gvg2(sd->bl.m) + && !map->list[sd->bl.m].flag.noexppenalty && !map_flag_gvg2(sd->bl.m) && !sd->sc.data[SC_BABY] && !sd->sc.data[SC_CASH_DEATHPENALTY] ) { unsigned int base_penalty =0; @@ -6881,7 +6881,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) { clif->updatestatus(sd,SP_JOBEXP); } } - if(battle_config.zeny_penalty > 0 && !maplist[sd->bl.m].flag.nozenypenalty) + if(battle_config.zeny_penalty > 0 && !map->list[sd->bl.m].flag.nozenypenalty) { base_penalty = (unsigned int)((double)sd->status.zeny * (double)battle_config.zeny_penalty / 10000.); if(base_penalty) @@ -6889,12 +6889,12 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) { } } - if(maplist[sd->bl.m].flag.pvp_nightmaredrop) { + if(map->list[sd->bl.m].flag.pvp_nightmaredrop) { // Moved this outside so it works when PVP isn't enabled and during pk mode [Ancyker] - for(j=0;j<maplist[sd->bl.m].drop_list_count;j++){ - int id = maplist[sd->bl.m].drop_list[j].drop_id; - int type = maplist[sd->bl.m].drop_list[j].drop_type; - int per = maplist[sd->bl.m].drop_list[j].drop_per; + for(j=0;j<map->list[sd->bl.m].drop_list_count;j++){ + int id = map->list[sd->bl.m].drop_list[j].drop_id; + int type = map->list[sd->bl.m].drop_list[j].drop_type; + int per = map->list[sd->bl.m].drop_list[j].drop_per; if(id == 0) continue; if(id == -1){ @@ -6940,7 +6940,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) { } // pvp // disable certain pvp functions on pk_mode [Valaris] - if( maplist[sd->bl.m].flag.pvp && !battle_config.pk_mode && !maplist[sd->bl.m].flag.pvp_nocalcrank ) { + if( map->list[sd->bl.m].flag.pvp && !battle_config.pk_mode && !map->list[sd->bl.m].flag.pvp_nocalcrank ) { sd->pvp_point -= 5; sd->pvp_lost++; if( src && src->type == BL_PC ) @@ -8992,7 +8992,7 @@ int pc_calc_pvprank_sub(struct block_list *bl,va_list ap) int pc_calc_pvprank(struct map_session_data *sd) { int old; struct map_data *m; - m=&maplist[sd->bl.m]; + m=&map->list[sd->bl.m]; old=sd->pvp_rank; sd->pvp_rank=1; map->foreachinmap(pc_calc_pvprank_sub,sd->bl.m,BL_PC,sd); @@ -9259,7 +9259,7 @@ int pc_autosave(int tid, unsigned int tick, int id, intptr_t data) } int pc_daynight_timer_sub(struct map_session_data *sd,va_list ap) { - if (sd->state.night != map->night_flag && maplist[sd->bl.m].flag.nightenabled) { //Night/day state does not match. + if (sd->state.night != map->night_flag && map->list[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; @@ -9280,7 +9280,7 @@ int map_day_timer(int tid, unsigned int tick, int id, intptr_t data) { return 0; //Already day. map->night_flag = 0; // 0=day, 1=night [Yor] - map->map_foreachpc(pc->daynight_timer_sub); + 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; @@ -9300,7 +9300,7 @@ int map_night_timer(int tid, unsigned int tick, int id, intptr_t data) { return 0; //Already nigth. map->night_flag = 1; // 0=day, 1=night [Yor] - map->map_foreachpc(pc->daynight_timer_sub); + 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; diff --git a/src/map/pet.c b/src/map/pet.c index 811ac9f09..023059a6b 100644 --- a/src/map/pet.c +++ b/src/map/pet.c @@ -934,7 +934,7 @@ int pet_ai_sub_foreachclient(struct map_session_data *sd,va_list ap) } int pet_ai_hard(int tid, unsigned int tick, int id, intptr_t data) { - map->map_foreachpc(pet->ai_sub_foreachclient,tick); + map->foreachpc(pet->ai_sub_foreachclient,tick); return 0; } diff --git a/src/map/script.c b/src/map/script.c index 875ecd841..879ca8c84 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -172,13 +172,13 @@ void script_reportsrc(struct script_state *st) { switch( bl->type ) { case BL_NPC: if( bl->m >= 0 ) - ShowDebug("Source (NPC): %s at %s (%d,%d)\n", ((struct npc_data *)bl)->name, maplist[bl->m].name, bl->x, bl->y); + ShowDebug("Source (NPC): %s at %s (%d,%d)\n", ((struct npc_data *)bl)->name, map->list[bl->m].name, bl->x, bl->y); else ShowDebug("Source (NPC): %s (invisible/not on a map)\n", ((struct npc_data *)bl)->name); break; default: if( bl->m >= 0 ) - ShowDebug("Source (Non-NPC type %d): name %s at %s (%d,%d)\n", bl->type, status->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), map->list[bl->m].name, bl->x, bl->y); else ShowDebug("Source (Non-NPC type %d): name %s (invisible/not on a map)\n", bl->type, status->get_name(bl)); break; @@ -3285,7 +3285,7 @@ void run_script_main(struct script_state *st) { nd = map->id2nd(st->oid); if( nd && nd->bl.m >= 0 ) - st->instance_id = maplist[nd->bl.m].instance_id; + st->instance_id = map->list[nd->bl.m].instance_id; else st->instance_id = -1; @@ -4623,7 +4623,7 @@ BUILDIN(warpparty) if( !(pl_sd = p->data[i].sd) || pl_sd->status.party_id != p_id ) continue; - if( str2 && strcmp(str2, maplist[pl_sd->bl.m].name) != 0 ) + if( str2 && strcmp(str2, map->list[pl_sd->bl.m].name) != 0 ) continue; if( pc_isdead(pl_sd) ) @@ -4632,20 +4632,20 @@ BUILDIN(warpparty) switch( type ) { case 0: // Random - if(!maplist[pl_sd->bl.m].flag.nowarp) + if(!map->list[pl_sd->bl.m].flag.nowarp) pc->randomwarp(pl_sd,CLR_TELEPORT); break; case 1: // SavePointAll - if(!maplist[pl_sd->bl.m].flag.noreturn) + if(!map->list[pl_sd->bl.m].flag.noreturn) pc->setpos(pl_sd,pl_sd->status.save_point.map,pl_sd->status.save_point.x,pl_sd->status.save_point.y,CLR_TELEPORT); break; case 2: // SavePoint - if(!maplist[pl_sd->bl.m].flag.noreturn) + if(!map->list[pl_sd->bl.m].flag.noreturn) pc->setpos(pl_sd,sd->status.save_point.map,sd->status.save_point.x,sd->status.save_point.y,CLR_TELEPORT); break; case 3: // Leader case 4: // m,x,y - if(!maplist[pl_sd->bl.m].flag.noreturn && !maplist[pl_sd->bl.m].flag.nowarp) + if(!map->list[pl_sd->bl.m].flag.noreturn && !map->list[pl_sd->bl.m].flag.nowarp) pc->setpos(pl_sd,mapindex,x,y,CLR_TELEPORT); break; } @@ -4693,19 +4693,19 @@ BUILDIN(warpguild) switch( type ) { case 0: // Random - if(!maplist[pl_sd->bl.m].flag.nowarp) + if(!map->list[pl_sd->bl.m].flag.nowarp) pc->randomwarp(pl_sd,CLR_TELEPORT); break; case 1: // SavePointAll - if(!maplist[pl_sd->bl.m].flag.noreturn) + if(!map->list[pl_sd->bl.m].flag.noreturn) pc->setpos(pl_sd,pl_sd->status.save_point.map,pl_sd->status.save_point.x,pl_sd->status.save_point.y,CLR_TELEPORT); break; case 2: // SavePoint - if(!maplist[pl_sd->bl.m].flag.noreturn) + if(!map->list[pl_sd->bl.m].flag.noreturn) pc->setpos(pl_sd,sd->status.save_point.map,sd->status.save_point.x,sd->status.save_point.y,CLR_TELEPORT); break; case 3: // m,x,y - if(!maplist[pl_sd->bl.m].flag.noreturn && !maplist[pl_sd->bl.m].flag.nowarp) + if(!map->list[pl_sd->bl.m].flag.noreturn && !map->list[pl_sd->bl.m].flag.nowarp) pc->setpos(pl_sd,mapindex_name2id(str),x,y,CLR_TELEPORT); break; } @@ -6715,7 +6715,7 @@ BUILDIN(strcharinfo) } break; case 3: - script_pushconststr(st,maplist[sd->bl.m].name); + script_pushconststr(st,map->list[sd->bl.m].name); break; default: ShowWarning("buildin_strcharinfo: unknown parameter.\n"); @@ -6767,7 +6767,7 @@ BUILDIN(strnpcinfo) { name = aStrdup(nd->exname); break; case 4: // map name - name = aStrdup(maplist[nd->bl.m].name); + name = aStrdup(map->list[nd->bl.m].name); break; } @@ -8314,7 +8314,7 @@ BUILDIN(monster) return false; } - if (maplist[m].flag.src4instance && st->instance_id >= 0) { // Try to redirect to the instance map, not the src map + if (map->list[m].flag.src4instance && st->instance_id >= 0) { // Try to redirect to the instance map, not the src map if ((m = instance->mapid2imapid(m, st->instance_id)) < 0) { ShowError("buildin_monster: Trying to spawn monster (%d) on instance map (%s) without instance attached.\n", class_, mapn); return false; @@ -8412,7 +8412,7 @@ BUILDIN(areamonster) ShowWarning("buildin_areamonster: Attempted to spawn monster class %d on non-existing map '%s'\n",class_, mapn); return false; } - if (maplist[m].flag.src4instance && st->instance_id >= 0) { // Try to redirect to the instance map, not the src map + if (map->list[m].flag.src4instance && st->instance_id >= 0) { // Try to redirect to the instance map, not the src map if ((m = instance->mapid2imapid(m, st->instance_id)) < 0) { ShowError("buildin_areamonster: Trying to spawn monster (%d) on instance map (%s) without instance attached.\n", class_, mapn); return false; @@ -8474,7 +8474,7 @@ BUILDIN(killmonster) { 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 ) + if( map->list[m].flag.src4instance && st->instance_id >= 0 && (m = instance->mapid2imapid(m, st->instance_id)) < 0 ) return true; if( script_hasdata(st,4) ) { @@ -8514,7 +8514,7 @@ BUILDIN(killmonsterall) { 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 ) + if( map->list[m].flag.src4instance && st->instance_id >= 0 && (m = instance->mapid2imapid(m, st->instance_id)) < 0 ) return true; if( script_hasdata(st,3) ) { @@ -9085,7 +9085,7 @@ BUILDIN(getusers) { } if(bl) { - val = maplist[bl->m].users; + val = map->list[bl->m].users; } break; case 1: @@ -9168,7 +9168,7 @@ BUILDIN(getmapusers) { script_pushint(st,-1); return true; } - script_pushint(st,maplist[m].users); + script_pushint(st,map->list[m].users); return true; } /*========================================== @@ -9988,7 +9988,7 @@ BUILDIN(warpwaitingpc) { for( i = 0; i < n && cd->users > 0; i++ ) { sd = cd->usersd[0]; - if( strcmp(map_name,"SavePoint") == 0 && maplist[sd->bl.m].flag.noteleport ) { + if( strcmp(map_name,"SavePoint") == 0 && map->list[sd->bl.m].flag.noteleport ) { // can't teleport on this map break; } @@ -10082,10 +10082,10 @@ BUILDIN(setmapflagnosave) { mapindex = mapindex_name2id(str2); if(m >= 0 && mapindex) { - maplist[m].flag.nosave=1; - maplist[m].save.map=mapindex; - maplist[m].save.x=x; - maplist[m].save.y=y; + map->list[m].flag.nosave=1; + map->list[m].save.map=mapindex; + map->list[m].save.x=x; + map->list[m].save.y=y; } return true; @@ -10102,56 +10102,56 @@ BUILDIN(getmapflag) m = map->mapname2mapid(str); if(m >= 0) { switch(i) { - case MF_NOMEMO: script_pushint(st,maplist[m].flag.nomemo); break; - case MF_NOTELEPORT: script_pushint(st,maplist[m].flag.noteleport); break; - case MF_NOSAVE: script_pushint(st,maplist[m].flag.nosave); break; - case MF_NOBRANCH: script_pushint(st,maplist[m].flag.nobranch); break; - case MF_NOPENALTY: script_pushint(st,maplist[m].flag.noexppenalty); break; - case MF_NOZENYPENALTY: script_pushint(st,maplist[m].flag.nozenypenalty); break; - case MF_PVP: script_pushint(st,maplist[m].flag.pvp); break; - case MF_PVP_NOPARTY: script_pushint(st,maplist[m].flag.pvp_noparty); break; - case MF_PVP_NOGUILD: script_pushint(st,maplist[m].flag.pvp_noguild); break; - case MF_GVG: script_pushint(st,maplist[m].flag.gvg); break; - case MF_GVG_NOPARTY: script_pushint(st,maplist[m].flag.gvg_noparty); break; - case MF_NOTRADE: script_pushint(st,maplist[m].flag.notrade); break; - case MF_NOSKILL: script_pushint(st,maplist[m].flag.noskill); break; - case MF_NOWARP: script_pushint(st,maplist[m].flag.nowarp); break; - case MF_PARTYLOCK: script_pushint(st,maplist[m].flag.partylock); break; - case MF_NOICEWALL: script_pushint(st,maplist[m].flag.noicewall); break; - case MF_SNOW: script_pushint(st,maplist[m].flag.snow); break; - case MF_FOG: script_pushint(st,maplist[m].flag.fog); break; - case MF_SAKURA: script_pushint(st,maplist[m].flag.sakura); break; - case MF_LEAVES: script_pushint(st,maplist[m].flag.leaves); break; - case MF_CLOUDS: script_pushint(st,maplist[m].flag.clouds); break; - case MF_CLOUDS2: script_pushint(st,maplist[m].flag.clouds2); break; - case MF_FIREWORKS: script_pushint(st,maplist[m].flag.fireworks); break; - case MF_GVG_CASTLE: script_pushint(st,maplist[m].flag.gvg_castle); break; - case MF_GVG_DUNGEON: script_pushint(st,maplist[m].flag.gvg_dungeon); break; - case MF_NIGHTENABLED: script_pushint(st,maplist[m].flag.nightenabled); break; - case MF_NOBASEEXP: script_pushint(st,maplist[m].flag.nobaseexp); break; - case MF_NOJOBEXP: script_pushint(st,maplist[m].flag.nojobexp); break; - case MF_NOMOBLOOT: script_pushint(st,maplist[m].flag.nomobloot); break; - case MF_NOMVPLOOT: script_pushint(st,maplist[m].flag.nomvploot); break; - case MF_NORETURN: script_pushint(st,maplist[m].flag.noreturn); break; - case MF_NOWARPTO: script_pushint(st,maplist[m].flag.nowarpto); break; - case MF_NIGHTMAREDROP: script_pushint(st,maplist[m].flag.pvp_nightmaredrop); break; - case MF_NOCOMMAND: script_pushint(st,maplist[m].nocommand); break; - case MF_NODROP: script_pushint(st,maplist[m].flag.nodrop); break; - case MF_JEXP: script_pushint(st,maplist[m].jexp); break; - case MF_BEXP: script_pushint(st,maplist[m].bexp); break; - case MF_NOVENDING: script_pushint(st,maplist[m].flag.novending); break; - case MF_LOADEVENT: script_pushint(st,maplist[m].flag.loadevent); break; - case MF_NOCHAT: script_pushint(st,maplist[m].flag.nochat); break; - case MF_NOEXPPENALTY: script_pushint(st,maplist[m].flag.noexppenalty ); break; - case MF_GUILDLOCK: script_pushint(st,maplist[m].flag.guildlock); break; - case MF_TOWN: script_pushint(st,maplist[m].flag.town); break; - case MF_AUTOTRADE: script_pushint(st,maplist[m].flag.autotrade); break; - case MF_ALLOWKS: script_pushint(st,maplist[m].flag.allowks); break; - case MF_MONSTER_NOTELEPORT: script_pushint(st,maplist[m].flag.monster_noteleport); break; - case MF_PVP_NOCALCRANK: script_pushint(st,maplist[m].flag.pvp_nocalcrank); break; - case MF_BATTLEGROUND: script_pushint(st,maplist[m].flag.battleground); break; - case MF_RESET: script_pushint(st,maplist[m].flag.reset); break; - case MF_NOTOMB: script_pushint(st,maplist[m].flag.notomb); break; + case MF_NOMEMO: script_pushint(st,map->list[m].flag.nomemo); break; + case MF_NOTELEPORT: script_pushint(st,map->list[m].flag.noteleport); break; + case MF_NOSAVE: script_pushint(st,map->list[m].flag.nosave); break; + case MF_NOBRANCH: script_pushint(st,map->list[m].flag.nobranch); break; + case MF_NOPENALTY: script_pushint(st,map->list[m].flag.noexppenalty); break; + case MF_NOZENYPENALTY: script_pushint(st,map->list[m].flag.nozenypenalty); break; + case MF_PVP: script_pushint(st,map->list[m].flag.pvp); break; + case MF_PVP_NOPARTY: script_pushint(st,map->list[m].flag.pvp_noparty); break; + case MF_PVP_NOGUILD: script_pushint(st,map->list[m].flag.pvp_noguild); break; + case MF_GVG: script_pushint(st,map->list[m].flag.gvg); break; + case MF_GVG_NOPARTY: script_pushint(st,map->list[m].flag.gvg_noparty); break; + case MF_NOTRADE: script_pushint(st,map->list[m].flag.notrade); break; + case MF_NOSKILL: script_pushint(st,map->list[m].flag.noskill); break; + case MF_NOWARP: script_pushint(st,map->list[m].flag.nowarp); break; + case MF_PARTYLOCK: script_pushint(st,map->list[m].flag.partylock); break; + case MF_NOICEWALL: script_pushint(st,map->list[m].flag.noicewall); break; + case MF_SNOW: script_pushint(st,map->list[m].flag.snow); break; + case MF_FOG: script_pushint(st,map->list[m].flag.fog); break; + case MF_SAKURA: script_pushint(st,map->list[m].flag.sakura); break; + case MF_LEAVES: script_pushint(st,map->list[m].flag.leaves); break; + case MF_CLOUDS: script_pushint(st,map->list[m].flag.clouds); break; + case MF_CLOUDS2: script_pushint(st,map->list[m].flag.clouds2); break; + case MF_FIREWORKS: script_pushint(st,map->list[m].flag.fireworks); break; + case MF_GVG_CASTLE: script_pushint(st,map->list[m].flag.gvg_castle); break; + case MF_GVG_DUNGEON: script_pushint(st,map->list[m].flag.gvg_dungeon); break; + case MF_NIGHTENABLED: script_pushint(st,map->list[m].flag.nightenabled); break; + case MF_NOBASEEXP: script_pushint(st,map->list[m].flag.nobaseexp); break; + case MF_NOJOBEXP: script_pushint(st,map->list[m].flag.nojobexp); break; + case MF_NOMOBLOOT: script_pushint(st,map->list[m].flag.nomobloot); break; + case MF_NOMVPLOOT: script_pushint(st,map->list[m].flag.nomvploot); break; + case MF_NORETURN: script_pushint(st,map->list[m].flag.noreturn); break; + case MF_NOWARPTO: script_pushint(st,map->list[m].flag.nowarpto); break; + case MF_NIGHTMAREDROP: script_pushint(st,map->list[m].flag.pvp_nightmaredrop); break; + case MF_NOCOMMAND: script_pushint(st,map->list[m].nocommand); break; + case MF_NODROP: script_pushint(st,map->list[m].flag.nodrop); break; + case MF_JEXP: script_pushint(st,map->list[m].jexp); break; + case MF_BEXP: script_pushint(st,map->list[m].bexp); break; + case MF_NOVENDING: script_pushint(st,map->list[m].flag.novending); break; + case MF_LOADEVENT: script_pushint(st,map->list[m].flag.loadevent); break; + case MF_NOCHAT: script_pushint(st,map->list[m].flag.nochat); break; + case MF_NOEXPPENALTY: script_pushint(st,map->list[m].flag.noexppenalty ); break; + case MF_GUILDLOCK: script_pushint(st,map->list[m].flag.guildlock); break; + case MF_TOWN: script_pushint(st,map->list[m].flag.town); break; + case MF_AUTOTRADE: script_pushint(st,map->list[m].flag.autotrade); break; + case MF_ALLOWKS: script_pushint(st,map->list[m].flag.allowks); break; + case MF_MONSTER_NOTELEPORT: script_pushint(st,map->list[m].flag.monster_noteleport); break; + case MF_PVP_NOCALCRANK: script_pushint(st,map->list[m].flag.pvp_nocalcrank); break; + case MF_BATTLEGROUND: script_pushint(st,map->list[m].flag.battleground); break; + case MF_RESET: script_pushint(st,map->list[m].flag.reset); break; + case MF_NOTOMB: script_pushint(st,map->list[m].flag.notomb); break; } } @@ -10197,77 +10197,77 @@ BUILDIN(setmapflag) { if(m >= 0) { switch(i) { - case MF_NOMEMO: maplist[m].flag.nomemo = 1; break; - case MF_NOTELEPORT: maplist[m].flag.noteleport = 1; break; - case MF_NOSAVE: maplist[m].flag.nosave = 1; break; - case MF_NOBRANCH: maplist[m].flag.nobranch = 1; break; - case MF_NOPENALTY: maplist[m].flag.noexppenalty = 1; maplist[m].flag.nozenypenalty = 1; break; - case MF_NOZENYPENALTY: maplist[m].flag.nozenypenalty = 1; break; + case MF_NOMEMO: map->list[m].flag.nomemo = 1; break; + case MF_NOTELEPORT: map->list[m].flag.noteleport = 1; break; + case MF_NOSAVE: map->list[m].flag.nosave = 1; break; + case MF_NOBRANCH: map->list[m].flag.nobranch = 1; break; + case MF_NOPENALTY: map->list[m].flag.noexppenalty = 1; map->list[m].flag.nozenypenalty = 1; break; + case MF_NOZENYPENALTY: map->list[m].flag.nozenypenalty = 1; break; case MF_PVP: - maplist[m].flag.pvp = 1; + map->list[m].flag.pvp = 1; if( !battle_config.pk_mode ) { map->foreachinmap(script->mapflag_pvp_sub,m,BL_PC); } break; - case MF_PVP_NOPARTY: maplist[m].flag.pvp_noparty = 1; break; - case MF_PVP_NOGUILD: maplist[m].flag.pvp_noguild = 1; break; + case MF_PVP_NOPARTY: map->list[m].flag.pvp_noparty = 1; break; + case MF_PVP_NOGUILD: map->list[m].flag.pvp_noguild = 1; break; case MF_GVG: { struct block_list bl; - maplist[m].flag.gvg = 1; + map->list[m].flag.gvg = 1; clif->map_property_mapall(m, MAPPROPERTY_AGITZONE); bl.type = BL_NUL; bl.m = m; clif->maptypeproperty2(&bl,ALL_SAMEMAP); } break; - case MF_GVG_NOPARTY: maplist[m].flag.gvg_noparty = 1; break; - case MF_NOTRADE: maplist[m].flag.notrade = 1; break; - case MF_NOSKILL: maplist[m].flag.noskill = 1; break; - case MF_NOWARP: maplist[m].flag.nowarp = 1; break; - case MF_PARTYLOCK: maplist[m].flag.partylock = 1; break; - case MF_NOICEWALL: maplist[m].flag.noicewall = 1; break; - case MF_SNOW: maplist[m].flag.snow = 1; break; - case MF_FOG: maplist[m].flag.fog = 1; break; - case MF_SAKURA: maplist[m].flag.sakura = 1; break; - case MF_LEAVES: maplist[m].flag.leaves = 1; break; - case MF_CLOUDS: maplist[m].flag.clouds = 1; break; - case MF_CLOUDS2: maplist[m].flag.clouds2 = 1; break; - case MF_FIREWORKS: maplist[m].flag.fireworks = 1; break; - case MF_GVG_CASTLE: maplist[m].flag.gvg_castle = 1; break; - case MF_GVG_DUNGEON: maplist[m].flag.gvg_dungeon = 1; break; - case MF_NIGHTENABLED: maplist[m].flag.nightenabled = 1; break; - case MF_NOBASEEXP: maplist[m].flag.nobaseexp = 1; break; - case MF_NOJOBEXP: maplist[m].flag.nojobexp = 1; break; - case MF_NOMOBLOOT: maplist[m].flag.nomobloot = 1; break; - case MF_NOMVPLOOT: maplist[m].flag.nomvploot = 1; break; - case MF_NORETURN: maplist[m].flag.noreturn = 1; break; - case MF_NOWARPTO: maplist[m].flag.nowarpto = 1; break; - case MF_NIGHTMAREDROP: maplist[m].flag.pvp_nightmaredrop = 1; break; + case MF_GVG_NOPARTY: map->list[m].flag.gvg_noparty = 1; break; + case MF_NOTRADE: map->list[m].flag.notrade = 1; break; + case MF_NOSKILL: map->list[m].flag.noskill = 1; break; + case MF_NOWARP: map->list[m].flag.nowarp = 1; break; + case MF_PARTYLOCK: map->list[m].flag.partylock = 1; break; + case MF_NOICEWALL: map->list[m].flag.noicewall = 1; break; + case MF_SNOW: map->list[m].flag.snow = 1; break; + case MF_FOG: map->list[m].flag.fog = 1; break; + case MF_SAKURA: map->list[m].flag.sakura = 1; break; + case MF_LEAVES: map->list[m].flag.leaves = 1; break; + case MF_CLOUDS: map->list[m].flag.clouds = 1; break; + case MF_CLOUDS2: map->list[m].flag.clouds2 = 1; break; + case MF_FIREWORKS: map->list[m].flag.fireworks = 1; break; + case MF_GVG_CASTLE: map->list[m].flag.gvg_castle = 1; break; + case MF_GVG_DUNGEON: map->list[m].flag.gvg_dungeon = 1; break; + case MF_NIGHTENABLED: map->list[m].flag.nightenabled = 1; break; + case MF_NOBASEEXP: map->list[m].flag.nobaseexp = 1; break; + case MF_NOJOBEXP: map->list[m].flag.nojobexp = 1; break; + case MF_NOMOBLOOT: map->list[m].flag.nomobloot = 1; break; + case MF_NOMVPLOOT: map->list[m].flag.nomvploot = 1; break; + case MF_NORETURN: map->list[m].flag.noreturn = 1; break; + case MF_NOWARPTO: map->list[m].flag.nowarpto = 1; break; + case MF_NIGHTMAREDROP: map->list[m].flag.pvp_nightmaredrop = 1; break; case MF_ZONE: { char zone[6] = "zone\0"; char empty[1] = "\0"; char params[MAP_ZONE_MAPFLAG_LENGTH]; memcpy(params, val2, MAP_ZONE_MAPFLAG_LENGTH); - npc->parse_mapflag(maplist[m].name, empty, zone, params, empty, empty, empty); + npc->parse_mapflag(map->list[m].name, empty, zone, params, empty, empty, empty); } break; - case MF_NOCOMMAND: maplist[m].nocommand = (val <= 0) ? 100 : val; break; - case MF_NODROP: maplist[m].flag.nodrop = 1; break; - case MF_JEXP: maplist[m].jexp = (val <= 0) ? 100 : val; break; - case MF_BEXP: maplist[m].bexp = (val <= 0) ? 100 : val; break; - case MF_NOVENDING: maplist[m].flag.novending = 1; break; - case MF_LOADEVENT: maplist[m].flag.loadevent = 1; break; - case MF_NOCHAT: maplist[m].flag.nochat = 1; break; - case MF_NOEXPPENALTY: maplist[m].flag.noexppenalty = 1; break; - case MF_GUILDLOCK: maplist[m].flag.guildlock = 1; break; - case MF_TOWN: maplist[m].flag.town = 1; break; - case MF_AUTOTRADE: maplist[m].flag.autotrade = 1; break; - case MF_ALLOWKS: maplist[m].flag.allowks = 1; break; - case MF_MONSTER_NOTELEPORT: maplist[m].flag.monster_noteleport = 1; break; - case MF_PVP_NOCALCRANK: maplist[m].flag.pvp_nocalcrank = 1; break; - case MF_BATTLEGROUND: maplist[m].flag.battleground = (val <= 0 || val > 2) ? 1 : val; break; - case MF_RESET: maplist[m].flag.reset = 1; break; - case MF_NOTOMB: maplist[m].flag.notomb = 1; break; + case MF_NOCOMMAND: map->list[m].nocommand = (val <= 0) ? 100 : val; break; + case MF_NODROP: map->list[m].flag.nodrop = 1; break; + case MF_JEXP: map->list[m].jexp = (val <= 0) ? 100 : val; break; + case MF_BEXP: map->list[m].bexp = (val <= 0) ? 100 : val; break; + case MF_NOVENDING: map->list[m].flag.novending = 1; break; + case MF_LOADEVENT: map->list[m].flag.loadevent = 1; break; + case MF_NOCHAT: map->list[m].flag.nochat = 1; break; + case MF_NOEXPPENALTY: map->list[m].flag.noexppenalty = 1; break; + case MF_GUILDLOCK: map->list[m].flag.guildlock = 1; break; + case MF_TOWN: map->list[m].flag.town = 1; break; + case MF_AUTOTRADE: map->list[m].flag.autotrade = 1; break; + case MF_ALLOWKS: map->list[m].flag.allowks = 1; break; + case MF_MONSTER_NOTELEPORT: map->list[m].flag.monster_noteleport = 1; break; + case MF_PVP_NOCALCRANK: map->list[m].flag.pvp_nocalcrank = 1; break; + case MF_BATTLEGROUND: map->list[m].flag.battleground = (val <= 0 || val > 2) ? 1 : val; break; + case MF_RESET: map->list[m].flag.reset = 1; break; + case MF_NOTOMB: map->list[m].flag.notomb = 1; break; } } @@ -10284,75 +10284,75 @@ BUILDIN(removemapflag) { m = map->mapname2mapid(str); if(m >= 0) { switch(i) { - case MF_NOMEMO: maplist[m].flag.nomemo = 0; break; - case MF_NOTELEPORT: maplist[m].flag.noteleport = 0; break; - case MF_NOSAVE: maplist[m].flag.nosave = 0; break; - case MF_NOBRANCH: maplist[m].flag.nobranch = 0; break; - case MF_NOPENALTY: maplist[m].flag.noexppenalty = 0; maplist[m].flag.nozenypenalty = 0; break; - case MF_NOZENYPENALTY: maplist[m].flag.nozenypenalty = 0; break; + case MF_NOMEMO: map->list[m].flag.nomemo = 0; break; + case MF_NOTELEPORT: map->list[m].flag.noteleport = 0; break; + case MF_NOSAVE: map->list[m].flag.nosave = 0; break; + case MF_NOBRANCH: map->list[m].flag.nobranch = 0; break; + case MF_NOPENALTY: map->list[m].flag.noexppenalty = 0; map->list[m].flag.nozenypenalty = 0; break; + case MF_NOZENYPENALTY: map->list[m].flag.nozenypenalty = 0; break; case MF_PVP: { struct block_list bl; bl.type = BL_NUL; bl.m = m; - maplist[m].flag.pvp = 0; + map->list[m].flag.pvp = 0; clif->map_property_mapall(m, MAPPROPERTY_NOTHING); clif->maptypeproperty2(&bl,ALL_SAMEMAP); } break; - case MF_PVP_NOPARTY: maplist[m].flag.pvp_noparty = 0; break; - case MF_PVP_NOGUILD: maplist[m].flag.pvp_noguild = 0; break; + case MF_PVP_NOPARTY: map->list[m].flag.pvp_noparty = 0; break; + case MF_PVP_NOGUILD: map->list[m].flag.pvp_noguild = 0; break; case MF_GVG: { struct block_list bl; bl.type = BL_NUL; bl.m = m; - maplist[m].flag.gvg = 0; + map->list[m].flag.gvg = 0; clif->map_property_mapall(m, MAPPROPERTY_NOTHING); clif->maptypeproperty2(&bl,ALL_SAMEMAP); } break; - case MF_GVG_NOPARTY: maplist[m].flag.gvg_noparty = 0; break; - case MF_NOTRADE: maplist[m].flag.notrade = 0; break; - case MF_NOSKILL: maplist[m].flag.noskill = 0; break; - case MF_NOWARP: maplist[m].flag.nowarp = 0; break; - case MF_PARTYLOCK: maplist[m].flag.partylock = 0; break; - case MF_NOICEWALL: maplist[m].flag.noicewall = 0; break; - case MF_SNOW: maplist[m].flag.snow = 0; break; - case MF_FOG: maplist[m].flag.fog = 0; break; - case MF_SAKURA: maplist[m].flag.sakura = 0; break; - case MF_LEAVES: maplist[m].flag.leaves = 0; break; - case MF_CLOUDS: maplist[m].flag.clouds = 0; break; - case MF_CLOUDS2: maplist[m].flag.clouds2 = 0; break; - case MF_FIREWORKS: maplist[m].flag.fireworks = 0; break; - case MF_GVG_CASTLE: maplist[m].flag.gvg_castle = 0; break; - case MF_GVG_DUNGEON: maplist[m].flag.gvg_dungeon = 0; break; - case MF_NIGHTENABLED: maplist[m].flag.nightenabled = 0; break; - case MF_NOBASEEXP: maplist[m].flag.nobaseexp = 0; break; - case MF_NOJOBEXP: maplist[m].flag.nojobexp = 0; break; - case MF_NOMOBLOOT: maplist[m].flag.nomobloot = 0; break; - case MF_NOMVPLOOT: maplist[m].flag.nomvploot = 0; break; - case MF_NORETURN: maplist[m].flag.noreturn = 0; break; - case MF_NOWARPTO: maplist[m].flag.nowarpto = 0; break; - case MF_NIGHTMAREDROP: maplist[m].flag.pvp_nightmaredrop = 0; break; + case MF_GVG_NOPARTY: map->list[m].flag.gvg_noparty = 0; break; + case MF_NOTRADE: map->list[m].flag.notrade = 0; break; + case MF_NOSKILL: map->list[m].flag.noskill = 0; break; + case MF_NOWARP: map->list[m].flag.nowarp = 0; break; + case MF_PARTYLOCK: map->list[m].flag.partylock = 0; break; + case MF_NOICEWALL: map->list[m].flag.noicewall = 0; break; + case MF_SNOW: map->list[m].flag.snow = 0; break; + case MF_FOG: map->list[m].flag.fog = 0; break; + case MF_SAKURA: map->list[m].flag.sakura = 0; break; + case MF_LEAVES: map->list[m].flag.leaves = 0; break; + case MF_CLOUDS: map->list[m].flag.clouds = 0; break; + case MF_CLOUDS2: map->list[m].flag.clouds2 = 0; break; + case MF_FIREWORKS: map->list[m].flag.fireworks = 0; break; + case MF_GVG_CASTLE: map->list[m].flag.gvg_castle = 0; break; + case MF_GVG_DUNGEON: map->list[m].flag.gvg_dungeon = 0; break; + case MF_NIGHTENABLED: map->list[m].flag.nightenabled = 0; break; + case MF_NOBASEEXP: map->list[m].flag.nobaseexp = 0; break; + case MF_NOJOBEXP: map->list[m].flag.nojobexp = 0; break; + case MF_NOMOBLOOT: map->list[m].flag.nomobloot = 0; break; + case MF_NOMVPLOOT: map->list[m].flag.nomvploot = 0; break; + case MF_NORETURN: map->list[m].flag.noreturn = 0; break; + case MF_NOWARPTO: map->list[m].flag.nowarpto = 0; break; + case MF_NIGHTMAREDROP: map->list[m].flag.pvp_nightmaredrop = 0; break; case MF_ZONE: - map->zone_change2(m, maplist[m].prev_zone); + map->zone_change2(m, map->list[m].prev_zone); break; - case MF_NOCOMMAND: maplist[m].nocommand = 0; break; - case MF_NODROP: maplist[m].flag.nodrop = 0; break; - case MF_JEXP: maplist[m].jexp = 0; break; - case MF_BEXP: maplist[m].bexp = 0; break; - case MF_NOVENDING: maplist[m].flag.novending = 0; break; - case MF_LOADEVENT: maplist[m].flag.loadevent = 0; break; - case MF_NOCHAT: maplist[m].flag.nochat = 0; break; - case MF_NOEXPPENALTY: maplist[m].flag.noexppenalty = 0; break; - case MF_GUILDLOCK: maplist[m].flag.guildlock = 0; break; - case MF_TOWN: maplist[m].flag.town = 0; break; - case MF_AUTOTRADE: maplist[m].flag.autotrade = 0; break; - case MF_ALLOWKS: maplist[m].flag.allowks = 0; break; - case MF_MONSTER_NOTELEPORT: maplist[m].flag.monster_noteleport = 0; break; - case MF_PVP_NOCALCRANK: maplist[m].flag.pvp_nocalcrank = 0; break; - case MF_BATTLEGROUND: maplist[m].flag.battleground = 0; break; - case MF_RESET: maplist[m].flag.reset = 0; break; - case MF_NOTOMB: maplist[m].flag.notomb = 0; break; + case MF_NOCOMMAND: map->list[m].nocommand = 0; break; + case MF_NODROP: map->list[m].flag.nodrop = 0; break; + case MF_JEXP: map->list[m].jexp = 0; break; + case MF_BEXP: map->list[m].bexp = 0; break; + case MF_NOVENDING: map->list[m].flag.novending = 0; break; + case MF_LOADEVENT: map->list[m].flag.loadevent = 0; break; + case MF_NOCHAT: map->list[m].flag.nochat = 0; break; + case MF_NOEXPPENALTY: map->list[m].flag.noexppenalty = 0; break; + case MF_GUILDLOCK: map->list[m].flag.guildlock = 0; break; + case MF_TOWN: map->list[m].flag.town = 0; break; + case MF_AUTOTRADE: map->list[m].flag.autotrade = 0; break; + case MF_ALLOWKS: map->list[m].flag.allowks = 0; break; + case MF_MONSTER_NOTELEPORT: map->list[m].flag.monster_noteleport = 0; break; + case MF_PVP_NOCALCRANK: map->list[m].flag.pvp_nocalcrank = 0; break; + case MF_BATTLEGROUND: map->list[m].flag.battleground = 0; break; + case MF_RESET: map->list[m].flag.reset = 0; break; + case MF_NOTOMB: map->list[m].flag.notomb = 0; break; } } @@ -10368,11 +10368,16 @@ BUILDIN(pvpon) { str = script_getstr(st,2); m = map->mapname2mapid(str); - if( m < 0 || maplist[m].flag.pvp ) + if( m < 0 || map->list[m].flag.pvp ) return true; // nothing to do - map->zone_change2(m, strdb_get(zone_db, MAP_ZONE_PVP_NAME)); - maplist[m].flag.pvp = 1; + if( !strdb_exists(map->zone_db,MAP_ZONE_PVP_NAME) ) { + ShowError("buildin_pvpon: zone_db missing '%s'\n",MAP_ZONE_PVP_NAME); + return true; + } + + map->zone_change2(m, strdb_get(map->zone_db, MAP_ZONE_PVP_NAME)); + map->list[m].flag.pvp = 1; clif->map_property_mapall(m, MAPPROPERTY_FREEPVPZONE); bl.type = BL_NUL; bl.m = m; @@ -10418,11 +10423,11 @@ BUILDIN(pvpoff) { str=script_getstr(st,2); m = map->mapname2mapid(str); - if(m < 0 || !maplist[m].flag.pvp) + if(m < 0 || !map->list[m].flag.pvp) return true; //fixed Lupus - map->zone_change2(m, maplist[m].prev_zone); - maplist[m].flag.pvp = 0; + map->zone_change2(m, map->list[m].prev_zone); + map->list[m].flag.pvp = 0; clif->map_property_mapall(m, MAPPROPERTY_NOTHING); bl.type = BL_NUL; bl.m = m; @@ -10441,10 +10446,16 @@ BUILDIN(gvgon) { str=script_getstr(st,2); m = map->mapname2mapid(str); - if(m >= 0 && !maplist[m].flag.gvg) { + if(m >= 0 && !map->list[m].flag.gvg) { struct block_list bl; - map->zone_change2(m, strdb_get(zone_db, MAP_ZONE_GVG_NAME)); - maplist[m].flag.gvg = 1; + + if( !strdb_exists(map->zone_db,MAP_ZONE_GVG_NAME) ) { + ShowError("buildin_gvgon: zone_db missing '%s'\n",MAP_ZONE_GVG_NAME); + return true; + } + + map->zone_change2(m, strdb_get(map->zone_db, MAP_ZONE_GVG_NAME)); + map->list[m].flag.gvg = 1; clif->map_property_mapall(m, MAPPROPERTY_AGITZONE); bl.type = BL_NUL; bl.m = m; @@ -10459,10 +10470,10 @@ BUILDIN(gvgoff) { str=script_getstr(st,2); m = map->mapname2mapid(str); - if(m >= 0 && maplist[m].flag.gvg) { + if(m >= 0 && map->list[m].flag.gvg) { struct block_list bl; - map->zone_change2(m, maplist[m].prev_zone); - maplist[m].flag.gvg = 0; + map->zone_change2(m, map->list[m].prev_zone); + map->list[m].flag.gvg = 0; clif->map_property_mapall(m, MAPPROPERTY_NOTHING); bl.type = BL_NUL; bl.m = m; @@ -10542,7 +10553,7 @@ BUILDIN(maprespawnguildid) { return true; //Catch ALL players (in case some are 'between maps' on execution time) - map->map_foreachpc(script->buildin_maprespawnguildid_sub_pc,m,g_id,flag); + map->foreachpc(script->buildin_maprespawnguildid_sub_pc,m,g_id,flag); if (flag&4) //Remove script mobs. map->foreachinmap(script->buildin_maprespawnguildid_sub_mob,m,BL_MOB); return true; @@ -10969,7 +10980,7 @@ BUILDIN(mobcount) { return true; } - if( maplist[m].flag.src4instance && maplist[m].instance_id == -1 && st->instance_id >= 0 && (m = instance->mapid2imapid(m, st->instance_id)) < 0 ) { + if( map->list[m].flag.src4instance && map->list[m].instance_id == -1 && st->instance_id >= 0 && (m = instance->mapid2imapid(m, st->instance_id)) < 0 ) { script_pushint(st,-1); return true; } @@ -11690,7 +11701,7 @@ BUILDIN(playBGMall) { map->foreachinmap(script->playBGM_sub, m, BL_PC, name); } else { // entire server - map->map_foreachpc(script->playBGM_foreachpc_sub, name); + map->foreachpc(script->playBGM_foreachpc_sub, name); } return true; @@ -12565,7 +12576,7 @@ BUILDIN(getmapxy) x= bl->x; y= bl->y; - safestrncpy(mapname, maplist[bl->m].name, MAP_NAME_LENGTH); + safestrncpy(mapname, map->list[bl->m].name, MAP_NAME_LENGTH); //Set MapName$ num=st->stack->stack_data[st->start+2].u.num; @@ -14003,16 +14014,16 @@ int buildin_query_sql_sub(struct script_state* st, Sql* handle) return true; } BUILDIN(query_sql) { - return script->buildin_query_sql_sub(st, mmysql_handle); + return script->buildin_query_sql_sub(st, map->mysql_handle); } BUILDIN(query_logsql) { - if( !logs->config.sql_logs ) {// logmysql_handle == NULL + if( !logs->config.sql_logs ) {// logs->mysql_handle == NULL ShowWarning("buildin_query_logsql: SQL logs are disabled, query '%s' will not be executed.\n", script_getstr(st,2)); script_pushint(st,-1); return false; } - return script->buildin_query_sql_sub(st, logmysql_handle); + return script->buildin_query_sql_sub(st, logs->mysql_handle); } //Allows escaping of a given string. @@ -14025,7 +14036,7 @@ BUILDIN(escape_sql) str = script_getstr(st,2); len = strlen(str); esc_str = (char*)aMalloc(len*2+1); - SQL->EscapeStringLen(mmysql_handle, esc_str, str, len); + SQL->EscapeStringLen(map->mysql_handle, esc_str, str, len); script_pushstr(st, esc_str); return true; } @@ -15125,7 +15136,7 @@ BUILDIN(setcell) { for( y = y1; y <= y2; ++y ) for( x = x1; x <= x2; ++x ) - maplist[m].setcell(m, x, y, type, flag); + map->list[m].setcell(m, x, y, type, flag); return true; } @@ -15597,8 +15608,8 @@ BUILDIN(bg_updatescore) { if( (m = map->mapname2mapid(str)) < 0 ) return true; - maplist[m].bgscore_lion = script_getnum(st,3); - maplist[m].bgscore_eagle = script_getnum(st,4); + map->list[m].bgscore_lion = script_getnum(st,3); + map->list[m].bgscore_eagle = script_getnum(st,4); clif->bg_updatescore(m); return true; @@ -15704,7 +15715,7 @@ BUILDIN(instance_attachmap) { script_pushconststr(st, ""); return true; } - script_pushconststr(st, maplist[m].name); + script_pushconststr(st, map->list[m].name); return true; } @@ -15859,7 +15870,7 @@ BUILDIN(has_instance) { if( sd->instances ) { for( i = 0; i < sd->instances; i++ ) { if( sd->instance[i] >= 0 ) { - ARR_FIND(0, instance->list[sd->instance[i]].num_map, j, maplist[instance->list[sd->instance[i]].map[j]].instance_src_map == m); + ARR_FIND(0, instance->list[sd->instance[i]].num_map, j, map->list[instance->list[sd->instance[i]].map[j]].instance_src_map == m); if( j != instance->list[sd->instance[i]].num_map ) break; } @@ -15870,7 +15881,7 @@ BUILDIN(has_instance) { if( instance_id == -1 && sd->status.party_id && (p = party->search(sd->status.party_id)) && p->instances ) { for( i = 0; i < p->instances; i++ ) { if( p->instance[i] >= 0 ) { - ARR_FIND(0, instance->list[p->instance[i]].num_map, j, maplist[instance->list[p->instance[i]].map[j]].instance_src_map == m); + ARR_FIND(0, instance->list[p->instance[i]].num_map, j, map->list[instance->list[p->instance[i]].map[j]].instance_src_map == m); if( j != instance->list[p->instance[i]].num_map ) break; } @@ -15881,7 +15892,7 @@ BUILDIN(has_instance) { if( instance_id == -1 && sd->guild && sd->guild->instances ) { for( i = 0; i < sd->guild->instances; i++ ) { if( sd->guild->instance[i] >= 0 ) { - ARR_FIND(0, instance->list[sd->guild->instance[i]].num_map, j, maplist[instance->list[sd->guild->instance[i]].map[j]].instance_src_map == m); + ARR_FIND(0, instance->list[sd->guild->instance[i]].num_map, j, map->list[instance->list[sd->guild->instance[i]].map[j]].instance_src_map == m); if( j != instance->list[sd->guild->instance[i]].num_map ) break; } @@ -15896,7 +15907,7 @@ BUILDIN(has_instance) { return true; } - script_pushconststr(st, maplist[m].name); + script_pushconststr(st, map->list[m].name); return true; } int buildin_instance_warpall_sub(struct block_list *bl,va_list ap) { @@ -15927,7 +15938,7 @@ BUILDIN(instance_warpall) { else return true; - if( (m = map->mapname2mapid(mapn)) < 0 || (maplist[m].flag.src4instance && (m = instance->mapid2imapid(m, instance_id)) < 0) ) + if( (m = map->mapname2mapid(mapn)) < 0 || (map->list[m].flag.src4instance && (m = instance->mapid2imapid(m, instance_id)) < 0) ) return true; mapindex = map_id2index(m); @@ -16065,7 +16076,7 @@ BUILDIN(areamobuseskill) { return true; } - if( maplist[m].flag.src4instance && st->instance_id >= 0 && (m = instance->mapid2imapid(m, st->instance_id)) < 0 ) + if( map->list[m].flag.src4instance && st->instance_id >= 0 && (m = instance->mapid2imapid(m, st->instance_id)) < 0 ) return true; center.m = m; diff --git a/src/map/skill.c b/src/map/skill.c index 127eb1aa2..dd87f27d9 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -475,7 +475,7 @@ int skillnotok (uint16 skill_id, struct map_session_data *sd) case AL_WARP: case RETURN_TO_ELDICASTES: case ALL_GUARDIAN_RECALL: - if(maplist[m].flag.nowarp) { + if(map->list[m].flag.nowarp) { clif->skill_mapinfomessage(sd,0); return 1; } @@ -483,7 +483,7 @@ int skillnotok (uint16 skill_id, struct map_session_data *sd) case AL_TELEPORT: case SC_FATALMENACE: case SC_DIMENSIONDOOR: - if(maplist[m].flag.noteleport) { + if(map->list[m].flag.noteleport) { clif->skill_mapinfomessage(sd,0); return 1; } @@ -491,7 +491,7 @@ int skillnotok (uint16 skill_id, struct map_session_data *sd) case WE_CALLPARTNER: case WE_CALLPARENT: case WE_CALLBABY: - if (maplist[m].flag.nomemo) { + if (map->list[m].flag.nomemo) { clif->skill_mapinfomessage(sd,1); return 1; } @@ -510,7 +510,7 @@ int skillnotok (uint16 skill_id, struct map_session_data *sd) return 0; // always allowed case WZ_ICEWALL: // noicewall flag [Valaris] - if (maplist[m].flag.noicewall) { + if (map->list[m].flag.noicewall) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); return 1; } @@ -523,8 +523,8 @@ int skillnotok (uint16 skill_id, struct map_session_data *sd) break; case GD_EMERGENCYCALL: 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) + || !(battle_config.emergency_call&(map->list[m].flag.gvg || map->list[m].flag.gvg_castle?8:4)) + || (battle_config.emergency_call&16 && map->list[m].flag.nowarpto && !map->list[m].flag.gvg_castle) ) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); return 1; @@ -560,7 +560,7 @@ int skillnotok (uint16 skill_id, struct map_session_data *sd) break; } - return (maplist[m].flag.noskill); + return (map->list[m].flag.noskill); } int skillnotok_hom(uint16 skill_id, struct homun_data *hd) @@ -2015,7 +2015,7 @@ int skill_blown(struct block_list* src, struct block_list* target, int count, in nullpo_ret(src); - if (src != target && maplist[src->m].flag.noknockback) + if (src != target && map->list[src->m].flag.noknockback) return 0; //No knocking if (count == 0) return 0; //Actual knockback distance is 0. @@ -3526,7 +3526,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint 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) ) + if( !map_flag_gvg2(src->m) && !map->list[src->m].flag.battleground && unit->movepos(src, bl->x, bl->y, 0, 1) ) clif->slide(src, bl->x, bl->y); // cause damage and knockback if the path to target was a straight one @@ -3634,7 +3634,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint if( dir > 2 && dir < 6 ) y = -i; else if( dir == 7 || dir < 2 ) y = i; else y = 0; - if( (mbl == src || (!map_flag_gvg2(src->m) && !maplist[src->m].flag.battleground) ) // only NJ_ISSEN don't have slide effect in GVG + if( (mbl == src || (!map_flag_gvg2(src->m) && !map->list[src->m].flag.battleground) ) // only NJ_ISSEN don't have slide effect in GVG && unit->movepos(src, mbl->x+x, mbl->y+y, 1, 1) ) { clif->slide(src, src->x, src->y); @@ -4011,7 +4011,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint sc_start(src,SC_HIDING,100,skill_lv,skill->get_time(skill_id,skill_lv)); break; case NJ_KIRIKAGE: - if( !map_flag_gvg2(src->m) && !maplist[src->m].flag.battleground ) { + if( !map_flag_gvg2(src->m) && !map->list[src->m].flag.battleground ) { //You don't move on GVG grounds. short x, y; map->search_freecell(bl, 0, &x, &y, 1, 1, 0); @@ -4284,7 +4284,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint } break; case LG_PINPOINTATTACK: - if( !map_flag_gvg2(src->m) && !maplist[src->m].flag.battleground && unit->movepos(src, bl->x, bl->y, 1, 1) ) + if( !map_flag_gvg2(src->m) && !map->list[src->m].flag.battleground && unit->movepos(src, bl->x, bl->y, 1, 1) ) clif->slide(src,bl->x,bl->y); skill->attack(BF_WEAPON,src,src,bl,skill_id,skill_lv,tick,flag); break; @@ -4309,7 +4309,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint break; case SR_KNUCKLEARROW: - if( !map_flag_gvg2(src->m) && !maplist[src->m].flag.battleground && unit->movepos(src, bl->x, bl->y, 1, 1) ) { + if( !map_flag_gvg2(src->m) && !map->list[src->m].flag.battleground && unit->movepos(src, bl->x, bl->y, 1, 1) ) { clif->slide(src,bl->x,bl->y); clif->fixpos(src); // Aegis send this packet too. } @@ -5044,7 +5044,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui break; } skill->area_temp[0] = 5 - skill->area_temp[0]; // The actual penalty... - if (skill->area_temp[0] > 0 && !maplist[src->m].flag.noexppenalty) { //Apply penalty + if (skill->area_temp[0] > 0 && !map->list[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); @@ -5060,7 +5060,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui break; case ALL_RESURRECTION: - if(sd && (map_flag_gvg2(bl->m) || maplist[bl->m].flag.battleground)) { + if(sd && (map_flag_gvg2(bl->m) || map->list[bl->m].flag.battleground)) { //No reviving in WoE grounds! clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); break; @@ -5072,7 +5072,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui if (tsc && tsc->data[SC_HELLPOWER]) break; - if (maplist[bl->m].flag.pvp && dstsd && dstsd->pvp_point < 0) + if (map->list[bl->m].flag.pvp && dstsd && dstsd->pvp_point < 0) break; switch(skill_lv){ @@ -6258,7 +6258,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case AL_TELEPORT: if(sd) { - if (maplist[bl->m].flag.noteleport && skill_lv <= 2) { + if (map->list[bl->m].flag.noteleport && skill_lv <= 2) { clif->skill_mapinfomessage(sd,0); break; } @@ -6631,8 +6631,8 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui int x,y, dir = unit->getdir(src); //Fails on noteleport maps, except for GvG and BG maps [Skotlex] - if( maplist[src->m].flag.noteleport - && !(maplist[src->m].flag.battleground || map_flag_gvg2(src->m)) + if( map->list[src->m].flag.noteleport + && !(map->list[src->m].flag.battleground || map_flag_gvg2(src->m)) ) { x = src->x; y = src->y; @@ -7442,7 +7442,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui for(i = 0; i < g->max_member; i++, j++) { if (j>8) j=0; if ((dstsd = g->member[i].sd) != NULL && sd != dstsd && !dstsd->state.autotrade && !pc_isdead(dstsd)) { - if (maplist[dstsd->bl.m].flag.nowarp && !map_flag_gvg2(dstsd->bl.m)) + if (map->list[dstsd->bl.m].flag.nowarp && !map_flag_gvg2(dstsd->bl.m)) continue; if(map->getcell(src->m,src->x+dx[j],src->y+dy[j],CELL_CHKNOREACH)) dx[j] = dy[j] = 0; @@ -8452,7 +8452,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui } break; case LG_INSPIRATION: - if( sd && !maplist[sd->bl.m].flag.noexppenalty && sd->status.base_level != MAX_LEVEL ) { + if( sd && !map->list[sd->bl.m].flag.noexppenalty && sd->status.base_level != MAX_LEVEL ) { sd->status.base_exp -= min(sd->status.base_exp, pc->nextbaseexp(sd) * 1 / 100); // 1% penalty. sd->status.job_exp -= min(sd->status.job_exp, pc->nextjobexp(sd) * 1 / 100); clif->updatestatus(sd,SP_BASEEXP); @@ -9887,7 +9887,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui } break; case NJ_SHADOWJUMP: - if( !map_flag_gvg2(src->m) && !maplist[src->m].flag.battleground ) { //You don't move on GVG grounds. + if( !map_flag_gvg2(src->m) && !map->list[src->m].flag.battleground ) { //You don't move on GVG grounds. unit->movepos(src, x, y, 1, 0); clif->slide(src,x,y); } @@ -10422,11 +10422,11 @@ struct skill_unit_group* skill_unitsetting(struct block_list *src, uint16 skill_ unit_flag = skill->get_unit_flag(skill_id); layout = skill->get_unit_layout(skill_id,skill_lv,src,x,y); - if( maplist[src->m].unit_count ) { - ARR_FIND(0, maplist[src->m].unit_count, i, maplist[src->m].units[i]->skill_id == skill_id ); + if( map->list[src->m].unit_count ) { + ARR_FIND(0, map->list[src->m].unit_count, i, map->list[src->m].units[i]->skill_id == skill_id ); - if( i < maplist[src->m].unit_count ) { - limit = limit * maplist[src->m].units[i]->modifier / 100; + if( i < map->list[src->m].unit_count ) { + limit = limit * map->list[src->m].units[i]->modifier / 100; } } @@ -10523,7 +10523,7 @@ struct skill_unit_group* skill_unitsetting(struct block_list *src, uint16 skill_ ARR_FIND(0, MAX_SKILL_ITEM_REQUIRE, i, req.itemid[i] && (req.itemid[i] == ITEMID_TRAP || req.itemid[i] == ITEMID_TRAP_ALLOY)); if( req.itemid[i] ) req_item = req.itemid[i]; - if( map_flag_gvg2(src->m) || maplist[src->m].flag.battleground ) + if( map_flag_gvg2(src->m) || map->list[src->m].flag.battleground ) limit *= 4; // longer trap times in WOE [celest] if( battle_config.vs_traps_bctall && map_flag_vs(src->m) && (src->type&battle_config.vs_traps_bctall) ) target = BCT_ALL; @@ -11613,7 +11613,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns break; case UNT_DIMENSIONDOOR: - if( tsd && !maplist[bl->m].flag.noteleport ) + if( tsd && !map->list[bl->m].flag.noteleport ) pc->randomwarp(tsd,3); else if( bl->type == BL_MOB && battle_config.mob_warp&8 ) unit->warp(bl,-1,-1,-1,3); @@ -13974,7 +13974,7 @@ int skill_delay_fix (struct block_list *bl, uint16 skill_id, uint16 skill_lv) { time /= 2; break; case AS_SONICBLOW: - if (!map_flag_gvg2(bl->m) && !maplist[bl->m].flag.battleground && sc->data[SC_SOULLINK]->val2 == SL_ASSASIN) + if (!map_flag_gvg2(bl->m) && !map->list[bl->m].flag.battleground && sc->data[SC_SOULLINK]->val2 == SL_ASSASIN) time /= 2; break; } @@ -14502,7 +14502,7 @@ void skill_unitsetmapcell (struct skill_unit *src, uint16 skill_id, uint16 skill for( y = src->bl.y - range; y <= src->bl.y + range; ++y ) for( x = src->bl.x - range; x <= src->bl.x + range; ++x ) - maplist[src->bl.m].setcell(src->bl.m, x, y, cell, flag); + map->list[src->bl.m].setcell(src->bl.m, x, y, cell, flag); } /*========================================== @@ -15056,7 +15056,7 @@ struct skill_unit *skill_initunit (struct skill_unit_group *group, int idx, int 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++; + map->list[su->bl.m].icewall_num++; break; case SA_LANDPROTECTOR: skill->unitsetmapcell(su,SA_LANDPROTECTOR,group->skill_lv,CELL_LANDPROTECTOR,true); @@ -15111,7 +15111,7 @@ int skill_delunit (struct skill_unit* su) { 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--; + map->list[su->bl.m].icewall_num--; break; case SA_LANDPROTECTOR: skill->unitsetmapcell(su,SA_LANDPROTECTOR,group->skill_lv,CELL_LANDPROTECTOR,false); @@ -15536,13 +15536,13 @@ int skill_unit_timer_sub(DBKey key, DBData *data, va_list ap) { if(group->val1) { sd = map->charid2sd(group->val1); group->val1 = 0; - if (sd && !maplist[sd->bl.m].flag.nowarp) + if (sd && !map->list[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 = map->charid2sd(group->val2); group->val2 = 0; - if (sd && !maplist[sd->bl.m].flag.nowarp) + if (sd && !map->list[sd->bl.m].flag.nowarp) pc->setpos(sd,map_id2index(su->bl.m),su->bl.x,su->bl.y,CLR_TELEPORT); } skill->delunit(su); diff --git a/src/map/status.c b/src/map/status.c index 978380a20..6953312f8 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -1172,7 +1172,7 @@ int status_damage(struct block_list *src,struct block_list *target,int64 in_hp, if ((sce=sc->data[SC_ENDURE]) && !sce->val4 && !sc->data[SC_LKCONCENTRATION]) { //Endure count is only reduced by non-players on non-gvg maps. //val4 signals infinite endure. [Skotlex] - if (src && src->type != BL_PC && !map_flag_gvg2(target->m) && !maplist[target->m].flag.battleground && --(sce->val2) < 0) + if (src && src->type != BL_PC && !map_flag_gvg2(target->m) && !map->list[target->m].flag.battleground && --(sce->val2) < 0) status_change_end(target, SC_ENDURE, INVALID_TIMER); } if ((sce=sc->data[SC_GRAVITATION]) && sce->val3 == BCT_SELF) { @@ -1532,12 +1532,12 @@ int status_check_skilluse(struct block_list *src, struct block_list *target, uin if( src && !(src->type == BL_PC && ((TBL_PC*)src)->skillitem)) { // Items that cast skills using 'itemskill' will not be handled by map_zone_db. int i; - for(i = 0; i < maplist[src->m].zone->disabled_skills_count; i++) { - if( skill_id == maplist[src->m].zone->disabled_skills[i]->nameid && (maplist[src->m].zone->disabled_skills[i]->type&src->type) ) { + for(i = 0; i < map->list[src->m].zone->disabled_skills_count; i++) { + if( skill_id == map->list[src->m].zone->disabled_skills[i]->nameid && (map->list[src->m].zone->disabled_skills[i]->type&src->type) ) { if( src->type == BL_PC ) clif->msg((TBL_PC*)src, SKILL_CANT_USE_AREA); // This skill cannot be used within this area - else if( src->type == BL_MOB && maplist[src->m].zone->disabled_skills[i]->subtype != MZS_NONE ) { - if( (st->mode&MD_BOSS) && !(maplist[src->m].zone->disabled_skills[i]->subtype&MZS_BOSS) ) + else if( src->type == BL_MOB && map->list[src->m].zone->disabled_skills[i]->subtype != MZS_NONE ) { + if( (st->mode&MD_BOSS) && !(map->list[src->m].zone->disabled_skills[i]->subtype&MZS_BOSS) ) break; } return 0; @@ -2120,9 +2120,9 @@ int status_calc_mob_(struct mob_data* md, bool first) { if(flag&4) { // Strengthen Guardians - custom value +10% / lv struct guild_castle *gc; - gc=guild->mapname2gc(maplist[md->bl.m].name); + gc=guild->mapname2gc(map->list[md->bl.m].name); if (!gc) - ShowError("status_calc_mob: No castle set at map %s\n", maplist[md->bl.m].name); + ShowError("status_calc_mob: No castle set at map %s\n", map->list[md->bl.m].name); else if(gc->castle_id < 24 || md->class_ == MOBID_EMPERIUM) { #ifdef RENEWAL @@ -2450,13 +2450,13 @@ int status_calc_pc_(struct map_session_data* sd, bool first) { if(!sd->inventory_data[index]) continue; - for(k = 0; k < maplist[sd->bl.m].zone->disabled_items_count; k++) { - if( maplist[sd->bl.m].zone->disabled_items[k] == sd->inventory_data[index]->nameid ) { + for(k = 0; k < map->list[sd->bl.m].zone->disabled_items_count; k++) { + if( map->list[sd->bl.m].zone->disabled_items[k] == sd->inventory_data[index]->nameid ) { break; } } - if( k < maplist[sd->bl.m].zone->disabled_items_count ) + if( k < map->list[sd->bl.m].zone->disabled_items_count ) continue; bstatus->def += sd->inventory_data[index]->def; @@ -2595,13 +2595,13 @@ int status_calc_pc_(struct map_session_data* sd, bool first) { if(!data) continue; - for(k = 0; k < maplist[sd->bl.m].zone->disabled_items_count; k++) { - if( maplist[sd->bl.m].zone->disabled_items[k] == data->nameid ) { + for(k = 0; k < map->list[sd->bl.m].zone->disabled_items_count; k++) { + if( map->list[sd->bl.m].zone->disabled_items[k] == data->nameid ) { break; } } - if( k < maplist[sd->bl.m].zone->disabled_items_count ) + if( k < map->list[sd->bl.m].zone->disabled_items_count ) continue; if(first && data->equip_script) {//Execute equip-script on login @@ -4675,7 +4675,7 @@ signed short status_calc_flee(struct block_list *bl, struct status_change *sc, i if( bl->type == BL_PC ) { if( map_flag_gvg2(bl->m) ) flee -= flee * battle_config.gvg_flee_penalty/100; - else if( maplist[bl->m].flag.battleground ) + else if( map->list[bl->m].flag.battleground ) flee -= flee * battle_config.bg_flee_penalty/100; } @@ -5479,7 +5479,7 @@ short status_calc_aspd_rate(struct block_list *bl, struct status_change *sc, int } unsigned short status_calc_dmotion(struct block_list *bl, struct status_change *sc, int dmotion) { - if( !sc || !sc->count || map_flag_gvg2(bl->m) || maplist[bl->m].flag.battleground ) + if( !sc || !sc->count || map_flag_gvg2(bl->m) || map->list[bl->m].flag.battleground ) return cap_value(dmotion,0,USHRT_MAX); /** * It has been confirmed on official servers that MvP mobs have no dmotion even without endure @@ -7221,7 +7221,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val break; case SC_ENDURE: val2 = 7; // Hit-count [Celest] - if( !(flag&1) && (bl->type&(BL_PC|BL_MER)) && !map_flag_gvg(bl->m) && !maplist[bl->m].flag.battleground && !val4 ) { + if( !(flag&1) && (bl->type&(BL_PC|BL_MER)) && !map_flag_gvg(bl->m) && !map->list[bl->m].flag.battleground && !val4 ) { struct map_session_data *tsd; if( sd ) { int i; @@ -7516,7 +7516,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val if (sc->data[SC_SOULLINK] && sc->data[SC_SOULLINK]->val2 == SL_ROGUE) val3 -= 40; val4 = 10+val1*2; //SP cost. - if (map_flag_gvg(bl->m) || maplist[bl->m].flag.battleground) val4 *= 5; + if (map_flag_gvg(bl->m) || map->list[bl->m].flag.battleground) val4 *= 5; break; case SC_CLOAKING: if (!sd) //Monsters should be able to walk with no penalties. [Skotlex] @@ -7714,7 +7714,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val // 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; + int i = (map_flag_gvg(bl->m) || map->list[bl->m].flag.battleground)?2:3; while( i >= 0 ) { type2 = types[i]; if( d_sc->data[type2] ) @@ -11227,7 +11227,7 @@ int status_natural_heal(struct block_list* bl, va_list args) { //Natural heal main timer. int status_natural_heal_timer(int tid, unsigned int tick, int id, intptr_t data) { status->natural_heal_diff_tick = DIFF_TICK(tick,status->natural_heal_prev_tick); - map->map_foreachregen(status->natural_heal); + map->foreachregen(status->natural_heal); status->natural_heal_prev_tick = tick; return 0; } diff --git a/src/map/trade.c b/src/map/trade.c index b3082515a..8dd30371b 100644 --- a/src/map/trade.c +++ b/src/map/trade.c @@ -31,7 +31,7 @@ void trade_traderequest(struct map_session_data *sd, struct map_session_data *ta { nullpo_retv(sd); - if (maplist[sd->bl.m].flag.notrade) { + if (map->list[sd->bl.m].flag.notrade) { clif->message (sd->fd, msg_txt(272)); return; //Can't trade in notrade mapflag maps. } diff --git a/src/map/unit.c b/src/map/unit.c index 85d00515c..a7aca10b9 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -792,13 +792,13 @@ int unit_warp(struct block_list *bl,short m,short x,short y,clr_type type) switch (bl->type) { case BL_MOB: - if (maplist[bl->m].flag.monster_noteleport && ((TBL_MOB*)bl)->master_id == 0) + if (map->list[bl->m].flag.monster_noteleport && ((TBL_MOB*)bl)->master_id == 0) return 1; - if (m != bl->m && maplist[m].flag.nobranch && battle_config.mob_warp&4 && !(((TBL_MOB *)bl)->master_id)) + if (m != bl->m && map->list[m].flag.nobranch && battle_config.mob_warp&4 && !(((TBL_MOB *)bl)->master_id)) return 1; break; case BL_PC: - if (maplist[bl->m].flag.noteleport) + if (map->list[bl->m].flag.noteleport) return 1; break; } @@ -806,17 +806,17 @@ 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 (!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); + ShowWarning("unit_warp failed. Unit Id:%d/Type:%d, target position map %d (%s) at [%d,%d]\n", bl->id, bl->type, m, map->list[m].name, x, y); return 2; } } 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); + ShowWarning("unit_warp: Specified non-walkable target cell: %d (%s) at [%d,%d]\n", m, map->list[m].name, x,y); 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); + ShowWarning("unit_warp failed. Unit Id:%d/Type:%d, target position map %d (%s) at [%d,%d]\n", bl->id, bl->type, m, map->list[m].name, x, y); return 2; } } @@ -1955,7 +1955,7 @@ int unit_skillcastcancel(struct block_list *bl,int type) return 0; if (sd && (sd->special_state.no_castcancel2 || - ((sd->sc.data[SC_UNLIMITED_HUMMING_VOICE] || sd->special_state.no_castcancel) && !map_flag_gvg(bl->m) && !maplist[bl->m].flag.battleground))) //fixed flags being read the wrong way around [blackhole89] + ((sd->sc.data[SC_UNLIMITED_HUMMING_VOICE] || sd->special_state.no_castcancel) && !map_flag_gvg(bl->m) && !map->list[bl->m].flag.battleground))) //fixed flags being read the wrong way around [blackhole89] return 0; } @@ -2174,7 +2174,7 @@ int unit_remove_map(struct block_list *bl, clr_type clrtype, const char* file, i guild->send_dot_remove(sd); bg->send_dot_remove(sd); - if( maplist[bl->m].users <= 0 || sd->state.debug_remove_map ) { + if( map->list[bl->m].users <= 0 || sd->state.debug_remove_map ) { // this is only place where map users is decreased, if the mobs were removed too soon then this function was executed too many times [FlavioJS] if( sd->debug_file == NULL || !(sd->state.debug_remove_map) ) { sd->debug_file = ""; @@ -2188,17 +2188,17 @@ int unit_remove_map(struct block_list *bl, clr_type clrtype, const char* file, i " Please report this!!!\n", sd->status.account_id, sd->status.char_id, sd->state.active, sd->state.connect_new, sd->state.rewarp, sd->state.changemap, sd->state.debug_remove_map, - maplist[bl->m].name, maplist[bl->m].users, + map->list[bl->m].name, map->list[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] + } else if (--map->list[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; + --map->list[bl->m].users_pvp; } - if( maplist[bl->m].instance_id >= 0 ) { - instance->list[maplist[bl->m].instance_id].users--; - instance->check_idle(maplist[bl->m].instance_id); + if( map->list[bl->m].instance_id >= 0 ) { + instance->list[map->list[bl->m].instance_id].users--; + instance->check_idle(map->list[bl->m].instance_id); } sd->state.debug_remove_map = 1; // temporary state to track double remove_map's [FlavioJS] sd->debug_file = file; @@ -2340,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] - map->map_foreachpc(clif->friendslist_toggle_sub, sd->status.account_id, sd->status.char_id, 0); + 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); -- cgit v1.2.3-70-g09d2 From 44c33fda3614d588e6bf6cee1cf884e98f1531f0 Mon Sep 17 00:00:00 2001 From: Haru <haru@dotalux.com> Date: Fri, 11 Oct 2013 05:07:45 +0200 Subject: Changed 'tick' variables to 64 bit - This fixes an issue with timers that stop working after about 24-49 days when the tick overflows (note that this may happen much earlier than that, and at hard to predict times, on some systems) - Updated the RDTSC help message in the configure script to also warn users about issues with SpeedStep enabled systems. - On Windows, tick() still has a resolution of 10~15ms (or even as low as 100ms on some systems). A TODO comment (thanks, Ai4rei) was added for a follow-up patch, as I want this one to be as small as possible) - Note: on Windows versions earlier than 6.x (Vista, Server 2008), the tick overflow issue is NOT fixed, since they don't support the function used to retrieve a 64 bit tick. This isn't a big issue, since those platforms are already - or going soon to be - out of their extended support period, and it's already advisable to upgrade, for other reasons. If you're the unfortunate user of such a system, it is recommended that you reboot your machine at least once every 49 days for Hercules to work reliably. - Note: To clear some doubts, since I've already been asked, this has absolutely NOTHING to do with 32/64 bit CPUs or OSes. It's all about a variable's size, not the size of registers of your CPU, and your 32bit CPU will be able to handle this just fine. Signed-off-by: Haru <haru@dotalux.com> --- configure | 14 ++- configure.in | 8 +- src/char/char.c | 22 ++--- src/char/int_auction.c | 11 ++- src/char/int_guild.c | 5 +- src/char/inter.c | 8 +- src/common/console.c | 2 +- src/common/console.h | 2 +- src/common/random.c | 12 +-- src/common/socket.c | 5 +- src/common/socket.h | 3 +- src/common/sql.c | 2 +- src/common/timer.c | 86 +++++++++++++----- src/common/timer.h | 21 ++--- src/login/ipban_sql.c | 5 +- src/login/login.c | 15 ++-- src/map/atcommand.c | 30 ++++--- src/map/battle.c | 18 ++-- src/map/battle.h | 8 +- src/map/battleground.c | 6 +- src/map/battleground.h | 6 +- src/map/chrif.c | 10 +-- src/map/chrif.h | 16 ++-- src/map/clif.c | 72 +++++++-------- src/map/clif.h | 28 +++--- src/map/elemental.c | 14 +-- src/map/elemental.h | 10 +-- src/map/guild.c | 6 +- src/map/guild.h | 4 +- src/map/homunculus.c | 2 +- src/map/homunculus.h | 2 +- src/map/instance.c | 2 +- src/map/instance.h | 2 +- src/map/irc-bot.c | 6 +- src/map/irc-bot.h | 8 +- src/map/map.c | 10 +-- src/map/map.h | 10 +-- src/map/mapreg.h | 2 +- src/map/mapreg_sql.c | 2 +- src/map/mercenary.c | 4 +- src/map/mercenary.h | 4 +- src/map/mob.c | 81 ++++++++--------- src/map/mob.h | 30 +++---- src/map/npc.c | 23 +++-- src/map/npc.h | 12 +-- src/map/party.c | 3 +- src/map/party.h | 2 +- src/map/pc.c | 41 +++++---- src/map/pc.h | 54 ++++++------ src/map/pet.c | 27 +++--- src/map/pet.h | 20 ++--- src/map/script.c | 12 +-- src/map/script.h | 2 +- src/map/skill.c | 231 ++++++++++++++++++++++++------------------------- src/map/skill.h | 58 ++++++------- src/map/status.c | 37 +++++--- src/map/status.h | 9 +- src/map/unit.c | 30 +++---- src/map/unit.h | 24 ++--- 59 files changed, 609 insertions(+), 590 deletions(-) (limited to 'src/map/elemental.c') diff --git a/configure b/configure index abba75ea1..919d6f883 100755 --- a/configure +++ b/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in d26927e. +# From configure.in c4af60e. # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.69. # @@ -1333,9 +1333,15 @@ Optional Features: in conjunction with XEN or Other Virtualization mechanisms) Note: Please ensure that you've disabled dynamic CPU-Frequencys, such as power saving - options. (On the most modern Dedicated Servers - cpufreq is preconfigured, see your distribution's - manual how to disable it) + options. (On most modern Dedicated Servers cpufreq + is preconfigured, see your distribution's manual how + to disable it). Furthermore, If your CPU has + built-in CPU-Frequency scaling features (such as + Intel's SpeedStep(R)), do not enable this option. + Recent CPUs (Intel Core or newer) guarantee a fixed + increment rate for their TSC, so it should be safe + to use, but please doublecheck the documentation of + both your CPU and OS before enabling this option. --enable-profiler=ARG Profilers: no, gprof (disabled by default) --disable-64bit Enforce 32bit output on x86_64 systems. --enable-lto Enables or Disables Linktime Code Optimization (LTO diff --git a/configure.in b/configure.in index bd80bd43f..b79e51f6d 100644 --- a/configure.in +++ b/configure.in @@ -112,8 +112,12 @@ AC_ARG_ENABLE( Note: Please ensure that you've disabled dynamic CPU-Frequencys, such as power saving options. - (On the most modern Dedicated Servers cpufreq is preconfigured, see your distribution's manual - how to disable it) + (On most modern Dedicated Servers cpufreq is preconfigured, see your distribution's + manual how to disable it). + Furthermore, If your CPU has built-in CPU-Frequency scaling features (such as Intel's + SpeedStep(R)), do not enable this option. Recent CPUs (Intel Core or newer) guarantee + a fixed increment rate for their TSC, so it should be safe to use, but please doublecheck + the documentation of both your CPU and OS before enabling this option. ] ), [ diff --git a/src/char/char.c b/src/char/char.c index 0b35c0143..2c126836c 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -179,7 +179,7 @@ static DBMap* auth_db; // int account_id -> struct auth_node* // Online User Database //----------------------------------------------------- -static int chardb_waiting_disconnect(int tid, unsigned int tick, int id, intptr_t data); +static int chardb_waiting_disconnect(int tid, int64 tick, int id, intptr_t data); int delete_char_sql(int char_id); /** @@ -2097,7 +2097,7 @@ static void char_auth_ok(int fd, struct char_session_data *sd) // continues when account data is received... } -int send_accounts_tologin(int tid, unsigned int tick, int id, intptr_t data); +int send_accounts_tologin(int tid, int64 tick, int id, intptr_t data); void mapif_server_reset(int id); @@ -2491,8 +2491,7 @@ int parse_fromlogin(int fd) { return 0; } -int check_connect_login_server(int tid, unsigned int tick, int id, intptr_t data); -int send_accounts_tologin(int tid, unsigned int tick, int id, intptr_t data); +int check_connect_login_server(int tid, int64 tick, int id, intptr_t data); void do_init_loginif(void) { @@ -4488,8 +4487,7 @@ int mapif_send(int fd, unsigned char *buf, unsigned int len) return 0; } -int broadcast_user_count(int tid, unsigned int tick, int id, intptr_t data) -{ +int broadcast_user_count(int tid, int64 tick, int id, intptr_t data) { uint8 buf[6]; int users = count_users(); @@ -4534,8 +4532,7 @@ static int send_accounts_tologin_sub(DBKey key, DBData *data, va_list ap) return 0; } -int send_accounts_tologin(int tid, unsigned int tick, int id, intptr_t data) -{ +int send_accounts_tologin(int tid, int64 tick, int id, intptr_t data) { if (login_fd > 0 && session[login_fd]) { // send account list to login server @@ -4552,8 +4549,7 @@ int send_accounts_tologin(int tid, unsigned int tick, int id, intptr_t data) return 0; } -int check_connect_login_server(int tid, unsigned int tick, int id, intptr_t data) -{ +int check_connect_login_server(int tid, int64 tick, int id, intptr_t data) { if (login_fd > 0 && session[login_fd] != NULL) return 0; @@ -4588,8 +4584,7 @@ int check_connect_login_server(int tid, unsigned int tick, int id, intptr_t data //Invoked 15 seconds after mapif_disconnectplayer in case the map server doesn't //replies/disconnect the player we tried to kick. [Skotlex] //------------------------------------------------ -static int chardb_waiting_disconnect(int tid, unsigned int tick, int id, intptr_t data) -{ +static int chardb_waiting_disconnect(int tid, int64 tick, int id, intptr_t data) { struct online_char_data* character; if ((character = (struct online_char_data*)idb_get(online_char_db, id)) != NULL && character->waiting_disconnect == tid) { //Mark it offline due to timeout. @@ -4615,8 +4610,7 @@ static int online_data_cleanup_sub(DBKey key, DBData *data, va_list ap) return 0; } -static int online_data_cleanup(int tid, unsigned int tick, int id, intptr_t data) -{ +static int online_data_cleanup(int tid, int64 tick, int id, intptr_t data) { online_char_db->foreach(online_char_db, online_data_cleanup_sub); return 0; } diff --git a/src/char/int_auction.c b/src/char/int_auction.c index 0dad9d2de..47f3421c3 100644 --- a/src/char/int_auction.c +++ b/src/char/int_auction.c @@ -22,7 +22,7 @@ static DBMap* auction_db_ = NULL; // int auction_id -> struct auction_data* void auction_delete(struct auction_data *auction); -static int auction_end_timer(int tid, unsigned int tick, int id, intptr_t data); +static int auction_end_timer(int tid, int64 tick, int id, intptr_t data); static int auction_count(int char_id, bool buy) { @@ -108,7 +108,7 @@ unsigned int auction_create(struct auction_data *auction) else { struct auction_data *auction_; - unsigned int tick = auction->hours * 3600000; + int64 tick = auction->hours * 3600000; auction->item.amount = 1; auction->item.identify = 1; @@ -139,8 +139,7 @@ static void mapif_Auction_message(int char_id, unsigned char result) mapif_sendall(buf,7); } -static int auction_end_timer(int tid, unsigned int tick, int id, intptr_t data) -{ +static int auction_end_timer(int tid, int64 tick, int id, intptr_t data) { struct auction_data *auction; if( (auction = (struct auction_data *)idb_get(auction_db_, id)) != NULL ) { @@ -182,7 +181,7 @@ void inter_auctions_fromsql(void) struct item *item; char *data; StringBuf buf; - unsigned int tick = timer->gettick(), endtick; + int64 tick = timer->gettick(), endtick; time_t now = time(NULL); StrBuf->Init(&buf); @@ -230,7 +229,7 @@ void inter_auctions_fromsql(void) } if( auction->timestamp > now ) - endtick = ((unsigned int)(auction->timestamp - now) * 1000) + tick; + endtick = ((int64)(auction->timestamp - now) * 1000) + tick; else endtick = tick + 10000; // 10 Second's to process ended auctions diff --git a/src/char/int_guild.c b/src/char/int_guild.c index fab63894e..5f033f4d7 100644 --- a/src/char/int_guild.c +++ b/src/char/int_guild.c @@ -46,8 +46,7 @@ int mapif_guild_info(int fd,struct guild *g); int guild_break_sub(int key,void *data,va_list ap); int inter_guild_tosql(struct guild *g,int flag); -static int guild_save_timer(int tid, unsigned int tick, int id, intptr_t data) -{ +static int guild_save_timer(int tid, int64 tick, int id, intptr_t data) { static int last_id = 0; //To know in which guild we were. int state = 0; //0: Have not reached last guild. 1: Reached last guild, ready for save. 2: Some guild saved, don't do further saving. DBIterator *iter = db_iterator(guild_db_); @@ -86,7 +85,7 @@ static int guild_save_timer(int tid, unsigned int tick, int id, intptr_t data) state = guild_db_->size(guild_db_); if( state < 1 ) state = 1; //Calculate the time slot for the next save. - timer->add(tick + autosave_interval/state, guild_save_timer, 0, 0); + timer->add(tick + autosave_interval/state, guild_save_timer, 0, 0); return 0; } diff --git a/src/char/inter.c b/src/char/inter.c index 2dc15933b..040246c31 100644 --- a/src/char/inter.c +++ b/src/char/inter.c @@ -61,7 +61,7 @@ int inter_recv_packet_length[] = { struct WisData { int id, fd, count, len; - unsigned long tick; + int64 tick; unsigned char src[24], dst[24], msg[512]; }; static DBMap* wis_db = NULL; // int wis_id -> struct WisData* @@ -974,9 +974,9 @@ int mapif_disconnectplayer(int fd, int account_id, int char_id, int reason) */ int check_ttl_wisdata_sub(DBKey key, DBData *data, va_list ap) { - unsigned long tick; + int64 tick; struct WisData *wd = DB->data2ptr(data); - tick = va_arg(ap, unsigned long); + tick = va_arg(ap, int64); if (DIFF_TICK(tick, wd->tick) > WISDATA_TTL && wis_delnum < WISDELLIST_MAX) wis_dellist[wis_delnum++] = wd->id; @@ -986,7 +986,7 @@ int check_ttl_wisdata_sub(DBKey key, DBData *data, va_list ap) int check_ttl_wisdata(void) { - unsigned long tick = timer->gettick(); + int64 tick = timer->gettick(); int i; do { diff --git a/src/common/console.c b/src/common/console.c index b25de84b3..cb8ed5917 100644 --- a/src/common/console.c +++ b/src/common/console.c @@ -344,7 +344,7 @@ void *cThread_main(void *x) { return NULL; } -int console_parse_timer(int tid, unsigned int tick, int id, intptr_t data) { +int console_parse_timer(int tid, int64 tick, int id, intptr_t data) { int i; EnterSpinLock(&console->ptlock); for(i = 0; i < cinput.count; i++) { diff --git a/src/common/console.h b/src/common/console.h index cef898f17..1beed964a 100644 --- a/src/common/console.h +++ b/src/common/console.h @@ -56,7 +56,7 @@ struct console_interface { /* */ void (*parse_init) (void); void (*parse_final) (void); - int (*parse_timer) (int tid, unsigned int tick, int id, intptr_t data); + int (*parse_timer) (int tid, int64 tick, int id, intptr_t data); void *(*pthread_main) (void *x); void (*parse) (char* line); void (*parse_sub) (char* line); diff --git a/src/common/random.c b/src/common/random.c index 2f1b62934..e46c52cad 100644 --- a/src/common/random.c +++ b/src/common/random.c @@ -17,17 +17,17 @@ /// Initializes the random number generator with an appropriate seed. void rnd_init(void) { - uint32 seed = timer->gettick(); - seed += (uint32)time(NULL); + unsigned long seed = (unsigned long)timer->gettick(); + seed += (unsigned long)time(NULL); #if defined(WIN32) - seed += GetCurrentProcessId(); - seed += GetCurrentThreadId(); + seed += (unsigned long)GetCurrentProcessId(); + seed += (unsigned long)GetCurrentThreadId(); #else #if defined(HAVE_GETPID) - seed += (uint32)getpid(); + seed += (unsigned long)getpid(); #endif // HAVE_GETPID #if defined(HAVE_GETTID) - seed += (uint32)gettid(); + seed += (unsigned long)gettid(); #endif // HAVE_GETTID #endif init_genrand(seed); diff --git a/src/common/socket.c b/src/common/socket.c index 7c8b3738b..c66153550 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -896,7 +896,7 @@ int do_sockets(int next) typedef struct _connect_history { struct _connect_history* next; uint32 ip; - uint32 tick; + int64 tick; int count; unsigned ddos : 1; } ConnectHistory; @@ -1043,8 +1043,7 @@ static int connect_check_(uint32 ip) /// Timer function. /// Deletes old connection history records. -static int connect_check_clear(int tid, unsigned int tick, int id, intptr_t data) -{ +static int connect_check_clear(int tid, int64 tick, int id, intptr_t data) { int i; int clear = 0; int list = 0; diff --git a/src/common/socket.h b/src/common/socket.h index 0e34da660..923fa2515 100644 --- a/src/common/socket.h +++ b/src/common/socket.h @@ -77,8 +77,7 @@ typedef int (*RecvFunc)(int fd); typedef int (*SendFunc)(int fd); typedef int (*ParseFunc)(int fd); -struct socket_data -{ +struct socket_data { struct { unsigned char eof : 1; unsigned char server : 1; diff --git a/src/common/sql.c b/src/common/sql.c index 9b7fe4108..dc6c4c569 100644 --- a/src/common/sql.c +++ b/src/common/sql.c @@ -180,7 +180,7 @@ int Sql_Ping(Sql* self) /// Wrapper function for Sql_Ping. /// /// @private -static int Sql_P_KeepaliveTimer(int tid, unsigned int tick, int id, intptr_t data) +static int Sql_P_KeepaliveTimer(int tid, int64 tick, int id, intptr_t data) { Sql* self = (Sql*)data; ShowInfo("Pinging SQL server to keep connection alive...\n"); diff --git a/src/common/timer.c b/src/common/timer.c index a2378a5aa..ccd91f9c7 100644 --- a/src/common/timer.c +++ b/src/common/timer.c @@ -65,8 +65,7 @@ struct timer_func_list { } *tfl_root = NULL; /// Sets the name of a timer function. -int timer_add_func_list(TimerFunc func, char* name) -{ +int timer_add_func_list(TimerFunc func, char* name) { struct timer_func_list* tfl; if (name) { @@ -139,22 +138,62 @@ static void rdtsc_calibrate(){ #endif -/// platform-abstracted tick retrieval -static unsigned int tick(void) { +/** + * platform-abstracted tick retrieval + * @return server's current tick + */ +static int64 tick(void) { #if defined(WIN32) - return GetTickCount(); + // Windows: GetTickCount/GetTickCount64: Return the number of + // milliseconds that have elapsed since the system was started. + + // TODO: GetTickCount/GetTickCount64 has a resolution of only 10~15ms. + // Ai4rei recommends that we replace it with either performance + // counters or multimedia timers if we want it to be more accurate. + // I'm leaving this for a future follow-up patch. + + // GetTickCount64 is only available in Windows Vista / Windows Server + // 2008 or newer. Since we still support older versions, this runtime + // check is required in order not to crash. + // http://msdn.microsoft.com/en-us/library/windows/desktop/ms724411%28v=vs.85%29.aspx + static bool first = true; + static ULONGLONG (WINAPI *pGetTickCount64)(void) = NULL; + + if( first ) { + HMODULE hlib = GetModuleHandle(TEXT("KERNEL32.DLL")); + if( hlib != NULL ) + pGetTickCount64 = (ULONGLONG (WINAPI *)(void))GetProcAddress(hlib, "GetTickCount64"); + first = false; + } + if (pGetTickCount64) + return (int64)pGetTickCount64(); + // 32-bit fallback. Note: This will wrap around every ~49 days since system startup!!! + return (int64)GetTickCount(); #elif defined(ENABLE_RDTSC) - // - return (unsigned int)((_rdtsc() - RDTSC_BEGINTICK) / RDTSC_CLOCK); - // + // RDTSC: Returns the number of CPU cycles since reset. Unreliable if + // the CPU frequency is variable. + return (int64)((_rdtsc() - RDTSC_BEGINTICK) / RDTSC_CLOCK); #elif defined(HAVE_MONOTONIC_CLOCK) + // Monotinic clock: Implementation-defined. + // Clock that cannot be set and represents monotonic time since some + // unspecified starting point. This clock is not affected by + // discontin‐uous jumps in the system time (e.g., if the system + // administrator manually changes the clock), but is affected by + // the incremental adjustments performed by adjtime(3) and NTP. struct timespec tval; clock_gettime(CLOCK_MONOTONIC, &tval); - return tval.tv_sec * 1000 + tval.tv_nsec / 1000000; + // int64 cast to avoid overflows on platforms where time_t is 32 bit + return (int64)tval.tv_sec * 1000 + tval.tv_nsec / 1000000; #else + // Fallback, regular clock: Number of milliseconds since epoch. + // The time returned by gettimeofday() is affected by discontinuous + // jumps in the system time (e.g., if the system administrator + // manually changes the system time). If you need a monotonically + // increasing clock, see clock_gettime(2). struct timeval tval; gettimeofday(&tval, NULL); - return tval.tv_sec * 1000 + tval.tv_usec / 1000; + // int64 cast to avoid overflows on platforms where time_t is 32 bit + return (int64)tval.tv_sec * 1000 + tval.tv_usec / 1000; #endif } @@ -162,28 +201,28 @@ static unsigned int tick(void) { #if defined(TICK_CACHE) && TICK_CACHE > 1 ////////////////////////////////////////////////////////////////////////// // tick is cached for TICK_CACHE calls -static unsigned int gettick_cache; +static int64 gettick_cache; static int gettick_count = 1; -unsigned int timer_gettick_nocache(void) { +int64 timer_gettick_nocache(void) { gettick_count = TICK_CACHE; gettick_cache = tick(); return gettick_cache; } -unsigned int timer_gettick(void) { +int64 timer_gettick(void) { return ( --gettick_count == 0 ) ? gettick_nocache() : gettick_cache; } ////////////////////////////// #else ////////////////////////////// // tick doesn't get cached -unsigned int timer_gettick_nocache(void) +int64 timer_gettick_nocache(void) { return tick(); } -unsigned int timer_gettick(void) { +int64 timer_gettick(void) { return tick(); } ////////////////////////////////////////////////////////////////////////// @@ -237,7 +276,7 @@ static int acquire_timer(void) { /// Starts a new timer that is deleted once it expires (single-use). /// Returns the timer's id. -int timer_add(unsigned int tick, TimerFunc func, int id, intptr_t data) { +int timer_add(int64 tick, TimerFunc func, int id, intptr_t data) { int tid; tid = acquire_timer(); @@ -254,12 +293,11 @@ int timer_add(unsigned int tick, TimerFunc func, int id, intptr_t data) { /// Starts a new timer that automatically restarts itself (infinite loop until manually removed). /// Returns the timer's id, or INVALID_TIMER if it fails. -int timer_add_interval(unsigned int tick, TimerFunc func, int id, intptr_t data, int interval) -{ +int timer_add_interval(int64 tick, TimerFunc func, int id, intptr_t data, int interval) { int tid; if( interval < 1 ) { - ShowError("timer_add_interval: invalid interval (tick=%u %p[%s] id=%d data=%d diff_tick=%d)\n", tick, func, search_timer_func_list(func), id, data, DIFF_TICK(tick, timer->gettick())); + ShowError("timer_add_interval: invalid interval (tick=%"PRId64" %p[%s] id=%d data=%d diff_tick=%"PRId64")\n", tick, func, search_timer_func_list(func), id, data, DIFF_TICK(tick, timer->gettick())); return INVALID_TIMER; } @@ -301,13 +339,13 @@ int timer_do_delete(int tid, TimerFunc func) { /// Adjusts a timer's expiration time. /// Returns the new tick value, or -1 if it fails. -int timer_addtick(int tid, unsigned int tick) { +int64 timer_addtick(int tid, int64 tick) { return timer->settick(tid, timer_data[tid].tick+tick); } /// Modifies a timer's expiration time (an alternative to deleting a timer and starting a new one). /// Returns the new tick value, or -1 if it fails. -int timer_settick(int tid, unsigned int tick) { +int64 timer_settick(int tid, int64 tick) { size_t i; // search timer position @@ -332,8 +370,8 @@ int timer_settick(int tid, unsigned int tick) { /// Executes all expired timers. /// Returns the value of the smallest non-expired timer (or 1 second if there aren't any). -int do_timer(unsigned int tick) { - int diff = TIMER_MAX_INTERVAL; // return value +int do_timer(int64 tick) { + int64 diff = TIMER_MAX_INTERVAL; // return value // process all timers one by one while( BHEAP_LENGTH(timer_heap) ) { @@ -381,7 +419,7 @@ int do_timer(unsigned int tick) { } } - return cap_value(diff, TIMER_MIN_INTERVAL, TIMER_MAX_INTERVAL); + return (int)cap_value(diff, TIMER_MIN_INTERVAL, TIMER_MAX_INTERVAL); } unsigned long timer_get_uptime(void) { diff --git a/src/common/timer.h b/src/common/timer.h index 600f9fd02..4a2bebe7d 100644 --- a/src/common/timer.h +++ b/src/common/timer.h @@ -5,7 +5,8 @@ #define _TIMER_H_ #include "../common/cbasetypes.h" -#define DIFF_TICK(a,b) ((int)((a)-(b))) +#define DIFF_TICK(a,b) ((a)-(b)) +#define DIFF_TICK32(a,b) ((int32)((a)-(b))) #define INVALID_TIMER -1 @@ -18,10 +19,10 @@ enum { // Struct declaration -typedef int (*TimerFunc)(int tid, unsigned int tick, int id, intptr_t data); +typedef int (*TimerFunc)(int tid, int64 tick, int id, intptr_t data); struct TimerData { - unsigned int tick; + int64 tick; TimerFunc func; unsigned char type; int interval; @@ -40,22 +41,22 @@ struct TimerData { struct timer_interface { /* funcs */ - unsigned int (*gettick) (void); - unsigned int (*gettick_nocache) (void); + int64 (*gettick) (void); + int64 (*gettick_nocache) (void); - int (*add) (unsigned int tick, TimerFunc func, int id, intptr_t data); - int (*add_interval) (unsigned int tick, TimerFunc func, int id, intptr_t data, int interval); + int (*add) (int64 tick, TimerFunc func, int id, intptr_t data); + int (*add_interval) (int64 tick, TimerFunc func, int id, intptr_t data, int interval); const struct TimerData *(*get) (int tid); int (*delete) (int tid, TimerFunc func); - int (*addtick) (int tid, unsigned int tick); - int (*settick) (int tid, unsigned int tick); + int64 (*addtick) (int tid, int64 tick); + int64 (*settick) (int tid, int64 tick); int (*add_func_list) (TimerFunc func, char* name); unsigned long (*get_uptime) (void); - int (*do_timer) (unsigned int tick); + int (*do_timer) (int64 tick); void (*init) (void); void (*final) (void); }; diff --git a/src/login/ipban_sql.c b/src/login/ipban_sql.c index 9b074b368..74f45e418 100644 --- a/src/login/ipban_sql.c +++ b/src/login/ipban_sql.c @@ -36,7 +36,7 @@ static Sql* sql_handle = NULL; static int cleanup_timer_id = INVALID_TIMER; static bool ipban_inited = false; -int ipban_cleanup(int tid, unsigned int tick, int id, intptr_t data); +int ipban_cleanup(int tid, int64 tick, int id, intptr_t data); // initialize @@ -247,8 +247,7 @@ void ipban_log(uint32 ip) } // remove expired bans -int ipban_cleanup(int tid, unsigned int tick, int id, intptr_t data) -{ +int ipban_cleanup(int tid, int64 tick, int id, intptr_t data) { if( !login_config.ipban ) return 0;// ipban disabled diff --git a/src/login/login.c b/src/login/login.c index 7de5dbb76..f47f1519c 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -81,7 +81,7 @@ struct online_login_data { }; static DBMap* online_db; // int account_id -> struct online_login_data* -static int waiting_disconnect_timer(int tid, unsigned int tick, int id, intptr_t data); +static int waiting_disconnect_timer(int tid, int64 tick, int id, intptr_t data); /** * @see DBCreateData @@ -121,8 +121,7 @@ void remove_online_user(int account_id) idb_remove(online_db, account_id); } -static int waiting_disconnect_timer(int tid, unsigned int tick, int id, intptr_t data) -{ +static int waiting_disconnect_timer(int tid, int64 tick, int id, intptr_t data) { struct online_login_data* p = (struct online_login_data*)idb_get(online_db, id); if( p != NULL && p->waiting_disconnect == tid && p->account_id == id ) { @@ -165,8 +164,7 @@ static int online_data_cleanup_sub(DBKey key, DBData *data, va_list ap) return 0; } -static int online_data_cleanup(int tid, unsigned int tick, int id, intptr_t data) -{ +static int online_data_cleanup(int tid, int64 tick, int id, intptr_t data) { online_db->foreach(online_db, online_data_cleanup_sub); return 0; } @@ -234,8 +232,7 @@ void chrif_on_disconnect(int id) //----------------------------------------------------- // periodic ip address synchronization //----------------------------------------------------- -static int sync_ip_addresses(int tid, unsigned int tick, int id, intptr_t data) -{ +static int sync_ip_addresses(int tid, int64 tick, int id, intptr_t data) { uint8 buf[2]; ShowInfo("IP Sync in progress...\n"); WBUFW(buf,0) = 0x2735; @@ -901,8 +898,8 @@ int parse_fromchar(int fd) //------------------------------------- int mmo_auth_new(const char* userid, const char* pass, const char sex, const char* last_ip) { static int num_regs = 0; // registration counter - static unsigned int new_reg_tick = 0; - unsigned int tick = timer->gettick(); + static int64 new_reg_tick = 0; + int64 tick = timer->gettick(); struct mmo_account acc; //Account Registration Flood Protection by [Kevin] diff --git a/src/map/atcommand.c b/src/map/atcommand.c index c815967c2..7ec589956 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -4260,7 +4260,8 @@ ACMD(servertime) { } 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. + sprintf(temp, msg_txt(233), // Game time: The game is actually in night for %s. + txt_time((unsigned int)(DIFF_TICK(timer_data->tick,timer->gettick())/1000))); clif->message(fd, temp); clif->message(fd, msg_txt(234)); // Game time: After, the game will be in permanent daylight. } else @@ -4268,7 +4269,8 @@ ACMD(servertime) { } 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. + sprintf(temp, msg_txt(235), // Game time: The game is actualy in daylight for %s. + txt_time((unsigned int)(DIFF_TICK(timer_data->tick,timer->gettick())/1000))); clif->message(fd, temp); clif->message(fd, msg_txt(236)); // Game time: After, the game will be in permanent night. } else @@ -4277,22 +4279,28 @@ ACMD(servertime) { 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. + sprintf(temp, msg_txt(235), // Game time: The game is actualy in daylight for %s. + txt_time((unsigned int)(DIFF_TICK(timer_data->tick,timer->gettick())/1000))); 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. + sprintf(temp, msg_txt(237), // Game time: After, the game will be in night for %s. + txt_time((unsigned int)(DIFF_TICK(timer_data->interval,DIFF_TICK(timer_data->tick,timer_data2->tick)) / 1000))); 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. + sprintf(temp, msg_txt(237), // Game time: After, the game will be in night for %s. + txt_time((unsigned int)(DIFF_TICK(timer_data2->tick,timer_data->tick)/1000))); 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. + sprintf(temp, msg_txt(233), // Game time: The game is actualy in night for %s. + txt_time((unsigned int)(DIFF_TICK(timer_data->tick,timer->gettick()) / 1000))); 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. + sprintf(temp, msg_txt(239), // Game time: After, the game will be in daylight for %s. + txt_time((unsigned int)((timer_data->interval - DIFF_TICK(timer_data->tick, timer_data2->tick)) / 1000))); 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. + sprintf(temp, msg_txt(239), // Game time: After, the game will be in daylight for %s. + txt_time((unsigned int)(DIFF_TICK(timer_data2->tick, timer_data->tick) / 1000))); 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. @@ -5250,7 +5258,7 @@ ACMD(useskill) { *------------------------------------------*/ ACMD(displayskill) { struct status_data *st; - unsigned int tick; + int64 tick; uint16 skill_id; uint16 skill_lv = 1; @@ -6086,8 +6094,8 @@ ACMD(summon) int mob_id = 0; int duration = 0; struct mob_data *md; - unsigned int tick=timer->gettick(); - + int64 tick=timer->gettick(); + if (!message || !*message || sscanf(message, "%23s %d", name, &duration) < 1) { clif->message(fd, msg_txt(1225)); // Please enter a monster name (usage: @summon <monster name> {duration}). diff --git a/src/map/battle.c b/src/map/battle.c index 050f3f26e..94222f663 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -196,7 +196,7 @@ struct block_list* battle_getenemyarea(struct block_list *src, int x, int y, int return bl_list[rnd()%c]; } -int battle_delay_damage_sub(int tid, unsigned int tick, int id, intptr_t data) { +int battle_delay_damage_sub(int tid, int64 tick, int id, intptr_t data) { struct delay_damage *dat = (struct delay_damage *)data; if ( dat ) { @@ -244,7 +244,7 @@ int battle_delay_damage_sub(int tid, unsigned int tick, int id, intptr_t data) { 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(int64 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); @@ -349,7 +349,7 @@ int64 battle_attr_fix(struct block_list *src, struct block_list *target, int64 d y = sg->val3 & 0xffff; skill->unitsetting(src,su->group->skill_id,su->group->skill_lv,x,y,1); sg->val3 = -1; - sg->limit = DIFF_TICK(timer->gettick(),sg->tick)+300; + sg->limit = DIFF_TICK32(timer->gettick(),sg->tick)+300; } } } @@ -5269,14 +5269,14 @@ void battle_drain(TBL_PC *sd, struct block_list *tbl, int64 rdamage, int64 ldama status_zap(tbl, rhp, rsp); } // Deals the same damage to targets in area. [pakpil] -int battle_damage_area( struct block_list *bl, va_list ap) { - unsigned int tick; +int battle_damage_area(struct block_list *bl, va_list ap) { + int64 tick; int amotion, dmotion, damage; struct block_list *src; nullpo_ret(bl); - tick=va_arg(ap, unsigned int); + tick = va_arg(ap, int64); src=va_arg(ap,struct block_list *); amotion=va_arg(ap,int); dmotion=va_arg(ap,int); @@ -5302,7 +5302,7 @@ int battle_damage_area( struct block_list *bl, va_list ap) { /*========================================== * Do a basic physical attack (call trough unit_attack_timer) *------------------------------------------*/ -enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* target, unsigned int tick, int flag) { +enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* target, int64 tick, int flag) { struct map_session_data *sd = NULL, *tsd = NULL; struct status_data *sstatus, *tstatus; struct status_change *sc, *tsc; @@ -6617,7 +6617,7 @@ void Hercules_report(char* date, char *time_c) { #undef BFLAG_LENGTH } -static int Hercules_report_timer(int tid, unsigned int tick, int id, intptr_t data) { +static int Hercules_report_timer(int tid, int64 tick, int id, intptr_t data) { if( chrif->isconnected() ) {/* char server relays it, so it must be online. */ Hercules_report(__DATE__,__TIME__); } @@ -6761,7 +6761,7 @@ int battle_config_read(const char* cfgName) void do_init_battle(void) { 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"); + timer->add_func_list(battle->delay_damage_sub, "battle_delay_damage_sub"); #ifndef STATS_OPT_OUT timer->add_func_list(Hercules_report_timer, "Hercules_report_timer"); diff --git a/src/map/battle.h b/src/map/battle.h index a2212a647..bf08ab8d6 100644 --- a/src/map/battle.h +++ b/src/map/battle.h @@ -518,11 +518,11 @@ struct battle_interface { /* battlegrounds final damage calculation */ int64 (*calc_bg_damage) (struct block_list *src, struct block_list *bl, int64 damage, int div_, uint16 skill_id, uint16 skill_lv, int flag); /* normal weapon attack */ - enum damage_lv (*weapon_attack) (struct block_list *bl, struct block_list *target, unsigned int tick, int flag); + enum damage_lv (*weapon_attack) (struct block_list *bl, struct block_list *target, int64 tick, int flag); /* calculate weapon attack */ struct Damage (*calc_weapon_attack) (struct block_list *src,struct block_list *target,uint16 skill_id,uint16 skill_lv,int wflag); /* delays damage or skills by a timer */ - int (*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 (*delay_damage) (int64 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); /* drain damage */ void (*drain) (struct map_session_data *sd, struct block_list *tbl, int64 rdamage, int64 ldamage, int race, int boss); /* damage return/reflect */ @@ -566,7 +566,7 @@ struct battle_interface { int (*get_targeted_sub) (struct block_list *bl, va_list ap); int (*get_enemy_sub) (struct block_list *bl, va_list ap); int (*get_enemy_area_sub) (struct block_list *bl, va_list ap); - int (*delay_damage_sub) (int tid, unsigned int tick, int id, intptr_t data); + int (*delay_damage_sub) (int tid, int64 tick, int id, intptr_t data); int (*blewcount_bonus) (struct map_session_data *sd, uint16 skill_id); /* skill range criteria */ int (*range_type) (struct block_list *src, struct block_list *target, uint16 skill_id, uint16 skill_lv); @@ -587,7 +587,7 @@ struct battle_interface { /* picks a random enemy within the specified range */ struct block_list* (*get_enemy_area) (struct block_list *src, int x, int y, int range, int type, int ignore_id); /* damages area, originally for royal guard's reflect damage */ - int (*damage_area) ( struct block_list *bl, va_list ap); + int (*damage_area) (struct block_list *bl, va_list ap); }; struct battle_interface *battle; diff --git a/src/map/battleground.c b/src/map/battleground.c index e7fe4085b..62688659e 100644 --- a/src/map/battleground.c +++ b/src/map/battleground.c @@ -249,7 +249,7 @@ int bg_send_xy_timer_sub(DBKey key, DBData *data, va_list ap) { return 0; } -int bg_send_xy_timer(int tid, unsigned int tick, int id, intptr_t data) { +int bg_send_xy_timer(int tid, int64 tick, int id, intptr_t data) { bg->team_db->foreach(bg->team_db, bg->send_xy_timer_sub, tick); return 0; } @@ -534,7 +534,7 @@ void bg_begin(struct bg_arena *arena) { /* currently running only on solo mode so we do it evenly */ } } -int bg_begin_timer(int tid, unsigned int tick, int id, intptr_t data) { +int bg_begin_timer(int tid, int64 tick, int id, intptr_t data) { bg->begin(bg->arena[id]); bg->arena[id]->begin_timer = INVALID_TIMER; return 0; @@ -553,7 +553,7 @@ void bg_queue_pregame(struct bg_arena *arena) { } arena->begin_timer = timer->add( timer->gettick() + (arena->pregame_duration*1000), bg->begin_timer, arena->id, 0 ); } -int bg_fillup_timer(int tid, unsigned int tick, int id, intptr_t data) { +int bg_fillup_timer(int tid, int64 tick, int id, intptr_t data) { bg->queue_pregame(bg->arena[id]); bg->arena[id]->fillup_timer = INVALID_TIMER; return 0; diff --git a/src/map/battleground.h b/src/map/battleground.h index 1c224e1c2..a5e540924 100644 --- a/src/map/battleground.h +++ b/src/map/battleground.h @@ -84,9 +84,9 @@ struct battleground_interface { int (*id2pos) (int queue_id, int account_id); void (*queue_pc_cleanup) (struct map_session_data *sd); void (*begin) (struct bg_arena *arena); - int (*begin_timer) (int tid, unsigned int tick, int id, intptr_t data); + int (*begin_timer) (int tid, int64 tick, int id, intptr_t data); void (*queue_pregame) (struct bg_arena *arena); - int (*fillup_timer) (int tid, unsigned int tick, int id, intptr_t data); + int (*fillup_timer) (int tid, int64 tick, int id, intptr_t data); void (*queue_ready_ack) (struct bg_arena *arena, struct map_session_data *sd, bool response); void (*match_over) (struct bg_arena *arena, bool canceled); void (*queue_check) (struct bg_arena *arena); @@ -102,7 +102,7 @@ struct battleground_interface { int (*team_get_id) (struct block_list *bl); int (*send_message) (struct map_session_data *sd, const char *mes, int len); 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); + int (*send_xy_timer) (int tid, int64 tick, int id, intptr_t data); /* */ void (*config_read) (void); }; diff --git a/src/map/chrif.c b/src/map/chrif.c index 5308eada9..4efc5bce4 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -682,7 +682,7 @@ int auth_db_cleanup_sub(DBKey key, DBData *data, va_list ap) { return 0; } -int auth_db_cleanup(int tid, unsigned int tick, int id, intptr_t data) { +int auth_db_cleanup(int tid, int64 tick, int id, intptr_t data) { chrif_check(0); chrif->auth_db->foreach(chrif->auth_db, chrif->auth_db_cleanup_sub); return 0; @@ -1139,7 +1139,7 @@ int chrif_save_scdata(struct map_session_data *sd) { //parses the sc_data of the #ifdef ENABLE_SC_SAVING int i, count=0; - unsigned int tick; + int64 tick; struct status_change_data data; struct status_change *sc = &sd->sc; const struct TimerData *td; @@ -1159,7 +1159,7 @@ int chrif_save_scdata(struct map_session_data *sd) { //parses the sc_data of the td = timer->get(sc->data[i]->timer); 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. + data.tick = DIFF_TICK32(td->tick,tick); //Duration that is left before ending. } else data.tick = -1; //Infinite duration data.type = i; @@ -1462,7 +1462,7 @@ int chrif_parse(int fd) { return 0; } -int send_usercount_tochar(int tid, unsigned int tick, int id, intptr_t data) { +int send_usercount_tochar(int tid, int64 tick, int id, intptr_t data) { chrif_check(-1); WFIFOHEAD(chrif->fd,4); @@ -1509,7 +1509,7 @@ int send_users_tochar(void) { * timerFunction * Chk the connection to char server, (if it down) *------------------------------------------*/ -int check_connect_char_server(int tid, unsigned int tick, int id, intptr_t data) { +int check_connect_char_server(int tid, int64 tick, int id, intptr_t data) { static int displayed = 0; if ( chrif->fd <= 0 || session[chrif->fd] == NULL ) { if ( !displayed ) { diff --git a/src/map/chrif.h b/src/map/chrif.h index 0617a6702..9df4b9931 100644 --- a/src/map/chrif.h +++ b/src/map/chrif.h @@ -30,11 +30,11 @@ enum sd_state { ST_LOGIN, ST_LOGOUT, ST_MAPCHANGE }; struct auth_node { int account_id, char_id; int login_id1, login_id2, sex, fd; - time_t expiration_time; // # of seconds 1/1/1970 (timestamp): Validity limit of the account (0 = unlimited) - struct map_session_data *sd; //Data from logged on char. - struct mmo_charstatus *char_dat; //Data from char server. - unsigned int node_created; //timestamp for node timeouts - enum sd_state state; //To track whether player was login in/out or changing maps. + time_t expiration_time; // # of seconds 1/1/1970 (timestamp): Validity limit of the account (0 = unlimited) + struct map_session_data *sd; //Data from logged on char. + struct mmo_charstatus *char_dat; //Data from char server. + int64 node_created; //timestamp for node timeouts + enum sd_state state; //To track whether player was login in/out or changing maps. }; /*===================================== @@ -109,15 +109,15 @@ struct chrif_interface { 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); + int (*check_connect_char_server) (int tid, int64 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 (*send_usercount_tochar) (int tid, int64 tick, int id, intptr_t data); + int (*auth_db_cleanup) (int tid, int64 tick, int id, intptr_t data); int (*connect) (int fd); int (*connectack) (int fd); diff --git a/src/map/clif.c b/src/map/clif.c index decdfc2ce..9810e2a17 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -595,7 +595,7 @@ void clif_authok(struct map_session_data *sd) struct packet_authok p; p.PacketType = authokType; - p.startTime = timer->gettick(); + p.startTime = (unsigned int)timer->gettick(); WBUFPOS(&p.PosDir[0],0,sd->bl.x,sd->bl.y,sd->ud.dir); /* do the stupid client math */ p.xSize = p.ySize = 5; /* not-used */ @@ -787,14 +787,13 @@ void clif_clearunit_area(struct block_list* bl, clr_type type) /// Used to make monsters with player-sprites disappear after dying /// like normal monsters, because the client does not remove those /// automatically. -int clif_clearunit_delayed_sub(int tid, unsigned int tick, int id, intptr_t data) { +int clif_clearunit_delayed_sub(int tid, int64 tick, int id, intptr_t data) { struct block_list *bl = (struct block_list *)data; clif->clearunit_area(bl, (clr_type) id); ers_free(clif->delay_clearunit_ers,bl); return 0; } -void clif_clearunit_delayed(struct block_list* bl, clr_type type, unsigned int tick) -{ +void clif_clearunit_delayed(struct block_list* bl, clr_type type, int64 tick) { struct block_list *tbl = ers_alloc(clif->delay_clearunit_ers, struct block_list); memcpy (tbl, bl, sizeof (struct block_list)); timer->add(tick, clif->clearunit_delayed_sub, (int)type, (intptr_t)tbl); @@ -1156,7 +1155,7 @@ void clif_set_unit_walking(struct block_list* bl, struct map_session_data *tsd, p.head = vd->hair_style; p.weapon = vd->weapon; p.accessory = vd->head_bottom; - p.moveStartTime = timer->gettick(); + p.moveStartTime = (unsigned int)timer->gettick(); #if PACKETVER < 7 p.shield = vd->shield; #endif @@ -1526,7 +1525,7 @@ void clif_walkok(struct map_session_data *sd) WFIFOHEAD(fd, packet_len(0x87)); WFIFOW(fd,0)=0x87; - WFIFOL(fd,2)=timer->gettick(); + WFIFOL(fd,2)=(unsigned int)timer->gettick(); WFIFOPOS2(fd,6,sd->bl.x,sd->bl.y,sd->ud.to_x,sd->ud.to_y,8,8); WFIFOSET(fd,packet_len(0x87)); } @@ -1597,7 +1596,7 @@ void clif_move(struct unit_data *ud) WBUFW(buf,0)=0x86; WBUFL(buf,2)=bl->id; WBUFPOS2(buf,6,bl->x,bl->y,ud->to_x,ud->to_y,8,8); - WBUFL(buf,12)=timer->gettick(); + WBUFL(buf,12)=(unsigned int)timer->gettick(); clif->send(buf, packet_len(0x86), bl, AREA_WOS); if (disguised(bl)) { WBUFL(buf,2)=-bl->id; @@ -1609,7 +1608,7 @@ void clif_move(struct unit_data *ud) /*========================================== * 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) { +int clif_delayquit(int tid, int64 tick, int id, intptr_t data) { struct map_session_data *sd = NULL; //Remove player from map server @@ -4430,8 +4429,7 @@ int clif_calc_walkdelay(struct block_list *bl,int delay, int type, int damage, i /// 10 = critical hit /// 11 = lucky dodge /// 12 = (touch skill?) -int clif_damage(struct block_list* src, struct block_list* dst, unsigned int tick, int sdelay, int ddelay, int64 in_damage, int div, int type, int64 in_damage2) -{ +int clif_damage(struct block_list* src, struct block_list* dst, int64 tick, int sdelay, int ddelay, int64 in_damage, int div, int type, int64 in_damage2) { unsigned char buf[33]; struct status_change *sc; int damage,damage2; @@ -4459,7 +4457,7 @@ int clif_damage(struct block_list* src, struct block_list* dst, unsigned int tic WBUFW(buf,0)=cmd; WBUFL(buf,2)=src->id; WBUFL(buf,6)=dst->id; - WBUFL(buf,10)=tick; + WBUFL(buf,10)=(uint32)tick; WBUFL(buf,14)=sdelay; WBUFL(buf,18)=ddelay; #if PACKETVER < 20071113 @@ -4516,7 +4514,7 @@ int clif_damage(struct block_list* src, struct block_list* dst, unsigned int tic *------------------------------------------*/ void clif_takeitem(struct block_list* src, struct block_list* dst) { - //clif_damage(src,dst,0,0,0,0,0,1,0); + //clif->damage(src,dst,0,0,0,0,0,1,0); unsigned char buf[32]; nullpo_retv(src); @@ -5097,7 +5095,7 @@ void clif_skill_fail(struct map_session_data *sd,uint16 skill_id,enum useskill_f /// Skill cooldown display icon (ZC_SKILL_POSTDELAY). /// 043d <skill ID>.W <tick>.L -void clif_skill_cooldown(struct map_session_data *sd, uint16 skill_id, unsigned int tick) +void clif_skill_cooldown(struct map_session_data *sd, uint16 skill_id, unsigned int duration) { #if PACKETVER>=20081112 int fd; @@ -5108,7 +5106,7 @@ void clif_skill_cooldown(struct map_session_data *sd, uint16 skill_id, unsigned WFIFOHEAD(fd,packet_len(0x43d)); WFIFOW(fd,0) = 0x43d; WFIFOW(fd,2) = skill_id; - WFIFOL(fd,4) = tick; + WFIFOL(fd,4) = duration; WFIFOSET(fd,packet_len(0x43d)); #endif } @@ -5117,7 +5115,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, int64 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; @@ -5138,7 +5136,7 @@ int clif_skill_damage(struct block_list *src,struct block_list *dst,unsigned int WBUFW(buf,2)=skill_id; WBUFL(buf,4)=src->id; WBUFL(buf,8)=dst->id; - WBUFL(buf,12)=tick; + WBUFL(buf,12)=(uint32)tick; WBUFL(buf,16)=sdelay; WBUFL(buf,20)=ddelay; if (battle_config.hide_woe_damage && map_flag_gvg2(src->m)) { @@ -5169,7 +5167,7 @@ int clif_skill_damage(struct block_list *src,struct block_list *dst,unsigned int WBUFW(buf,2)=skill_id; WBUFL(buf,4)=src->id; WBUFL(buf,8)=dst->id; - WBUFL(buf,12)=tick; + WBUFL(buf,12)=(uint32)tick; WBUFL(buf,16)=sdelay; WBUFL(buf,20)=ddelay; if (battle_config.hide_woe_damage && map_flag_gvg2(src->m)) { @@ -5205,7 +5203,7 @@ 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 #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) { +int clif_skill_damage2(struct block_list *src, struct block_list *dst, int64 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; @@ -5225,7 +5223,7 @@ int clif_skill_damage2(struct block_list *src,struct block_list *dst,unsigned in WBUFW(buf,2)=skill_id; WBUFL(buf,4)=src->id; WBUFL(buf,8)=dst->id; - WBUFL(buf,12)=tick; + WBUFL(buf,12)=(uint32)tick; WBUFL(buf,16)=sdelay; WBUFL(buf,20)=ddelay; WBUFW(buf,24)=dst->x; @@ -5295,8 +5293,7 @@ int clif_skill_nodamage(struct block_list *src,struct block_list *dst,uint16 ski /// Non-damaging ground skill effect (ZC_NOTIFY_GROUNDSKILL). /// 0117 <skill id>.W <src id>.L <level>.W <x>.W <y>.W <tick>.L -void clif_skill_poseffect(struct block_list *src,uint16 skill_id,int val,int x,int y,int tick) -{ +void clif_skill_poseffect(struct block_list *src, uint16 skill_id, int val, int x, int y, int64 tick) { unsigned char buf[32]; nullpo_retv(src); @@ -5307,7 +5304,7 @@ void clif_skill_poseffect(struct block_list *src,uint16 skill_id,int val,int x,i WBUFW(buf,8)=val; WBUFW(buf,10)=x; WBUFW(buf,12)=y; - WBUFL(buf,14)=tick; + WBUFL(buf,14)=(uint32)tick; if(disguised(src)) { clif->send(buf,packet_len(0x117),src,AREA_WOS); WBUFL(buf,4)=-src->id; @@ -9431,7 +9428,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { clif->spawn(&sd->pd->bl); clif->send_petdata(sd,sd->pd,0,0); clif->send_petstatus(sd); -// skill->unit_move(&sd->pd->bl,gettick(),1); +// skill->unit_move(&sd->pd->bl,timer->gettick(),1); } } @@ -9649,12 +9646,12 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { /// Server's tick (ZC_NOTIFY_TIME). /// 007f <time>.L -void clif_notify_time(struct map_session_data* sd, unsigned long time) { +void clif_notify_time(struct map_session_data* sd, int64 time) { int fd = sd->fd; WFIFOHEAD(fd,packet_len(0x7f)); WFIFOW(fd,0) = 0x7f; - WFIFOL(fd,2) = time; + WFIFOL(fd,2) = (uint32)time; WFIFOSET(fd,packet_len(0x7f)); } @@ -9750,7 +9747,7 @@ void clif_parse_progressbar(int fd, struct map_session_data * sd) if( timer->gettick() < sd->progressbar.timeout && sd->st ) sd->st->state = END; - sd->state.workinprogress = sd->progressbar.npc_id = sd->progressbar.timeout = 0; + sd->progressbar.timeout = sd->state.workinprogress = sd->progressbar.npc_id = 0; npc->scriptcont(sd, npc_id, false); } @@ -9863,7 +9860,7 @@ void clif_parse_GetCharNameRequest(int fd, struct map_session_data *sd) { clif->charnameack(fd, bl); } -int clif_undisguise_timer(int tid, unsigned int tick, int id, intptr_t data) { +int clif_undisguise_timer(int tid, int64 tick, int id, intptr_t data) { struct map_session_data * sd; if( (sd = map->id2sd(id)) ) { sd->fontcolor_tid = INVALID_TIMER; @@ -10131,8 +10128,7 @@ void clif_parse_HowManyConnections(int fd, struct map_session_data *sd) { } -void clif_parse_ActionRequest_sub(struct map_session_data *sd, int action_type, int target_id, unsigned int tick) -{ +void clif_parse_ActionRequest_sub(struct map_session_data *sd, int action_type, int target_id, int64 tick) { if (pc_isdead(sd)) { clif->clearunit_area(&sd->bl, CLR_DEAD); return; @@ -11254,8 +11250,7 @@ void clif_parse_SkillUp(int fd,struct map_session_data *sd) pc->skillup(sd,RFIFOW(fd,2)); } -void clif_parse_UseSkillToId_homun(struct homun_data *hd, struct map_session_data *sd, unsigned int tick, uint16 skill_id, uint16 skill_lv, int target_id) -{ +void clif_parse_UseSkillToId_homun(struct homun_data *hd, struct map_session_data *sd, int64 tick, uint16 skill_id, uint16 skill_lv, int target_id) { int lv; if( !hd ) @@ -11276,8 +11271,7 @@ void clif_parse_UseSkillToId_homun(struct homun_data *hd, struct map_session_dat unit->skilluse_id(&hd->bl, target_id, skill_id, skill_lv); } -void clif_parse_UseSkillToPos_homun(struct homun_data *hd, struct map_session_data *sd, unsigned int tick, uint16 skill_id, uint16 skill_lv, short x, short y, int skillmoreinfo) -{ +void clif_parse_UseSkillToPos_homun(struct homun_data *hd, struct map_session_data *sd, int64 tick, uint16 skill_id, uint16 skill_lv, short x, short y, int skillmoreinfo) { int lv; if( !hd ) return; @@ -11297,8 +11291,7 @@ void clif_parse_UseSkillToPos_homun(struct homun_data *hd, struct map_session_da unit->skilluse_pos(&hd->bl, x, y, skill_id, skill_lv); } -void clif_parse_UseSkillToId_mercenary(struct mercenary_data *md, struct map_session_data *sd, unsigned int tick, uint16 skill_id, uint16 skill_lv, int target_id) -{ +void clif_parse_UseSkillToId_mercenary(struct mercenary_data *md, struct map_session_data *sd, int64 tick, uint16 skill_id, uint16 skill_lv, int target_id) { int lv; if( !md ) @@ -11319,8 +11312,7 @@ void clif_parse_UseSkillToId_mercenary(struct mercenary_data *md, struct map_ses unit->skilluse_id(&md->bl, target_id, skill_id, skill_lv); } -void clif_parse_UseSkillToPos_mercenary(struct mercenary_data *md, struct map_session_data *sd, unsigned int tick, uint16 skill_id, uint16 skill_lv, short x, short y, int skillmoreinfo) -{ +void clif_parse_UseSkillToPos_mercenary(struct mercenary_data *md, struct map_session_data *sd, int64 tick, uint16 skill_id, uint16 skill_lv, short x, short y, int skillmoreinfo) { int lv; if( !md ) return; @@ -11351,7 +11343,7 @@ void clif_parse_UseSkillToId(int fd, struct map_session_data *sd) { uint16 skill_id, skill_lv; int tmp, target_id; - unsigned int tick = timer->gettick(); + int64 tick = timer->gettick(); skill_lv = RFIFOW(fd,packet_db[RFIFOW(fd,0)].pos[0]); skill_id = RFIFOW(fd,packet_db[RFIFOW(fd,0)].pos[1]); @@ -11452,7 +11444,7 @@ void clif_parse_UseSkillToId(int fd, struct map_session_data *sd) *------------------------------------------*/ void clif_parse_UseSkillToPosSub(int fd, struct map_session_data *sd, uint16 skill_lv, uint16 skill_id, short x, short y, int skillmoreinfo) { - unsigned int tick = timer->gettick(); + int64 tick = timer->gettick(); if( !(skill->get_inf(skill_id)&INF_GROUND_SKILL) ) return; //Using a target skill on the ground? WRONG. @@ -15581,7 +15573,7 @@ void clif_bossmapinfo(int fd, struct mob_data *md, short flag) unsigned int seconds; int hours, minutes; - seconds = DIFF_TICK(timer_data->tick, timer->gettick()) / 1000 + 60; + seconds = (unsigned int)(DIFF_TICK(timer_data->tick, timer->gettick()) / 1000 + 60); hours = seconds / (60 * 60); seconds = seconds - (60 * 60 * hours); minutes = seconds / 60; diff --git a/src/map/clif.h b/src/map/clif.h index 6d0fc0fc1..d7e0199bc 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -542,7 +542,7 @@ struct clif_interface { /* unit-related */ void (*clearunit_single) (int id, clr_type type, int fd); void (*clearunit_area) (struct block_list* bl, clr_type type); - void (*clearunit_delayed) (struct block_list* bl, clr_type type, unsigned int tick); + void (*clearunit_delayed) (struct block_list* bl, clr_type type, int64 tick); void (*walkok) (struct map_session_data *sd); void (*move) (struct unit_data *ud); void (*move2) (struct block_list *bl, struct view_data *vd, struct unit_data *ud); @@ -556,7 +556,7 @@ struct clif_interface { void (*skill_setunit) (struct skill_unit *su); void (*skill_delunit) (struct skill_unit *su); void (*skillunit_update) (struct block_list* bl); - int (*clearunit_delayed_sub) (int tid, unsigned int tick, int id, intptr_t data); + int (*clearunit_delayed_sub) (int tid, int64 tick, int id, intptr_t data); void (*set_unit_idle) (struct block_list* bl, struct map_session_data *tsd,enum send_target target); void (*spawn_unit) (struct block_list* bl, enum send_target target); void (*spawn_unit2) (struct block_list* bl, enum send_target target); @@ -600,7 +600,7 @@ struct clif_interface { void (*scriptclear) (struct map_session_data *sd, int npcid); /* client-user-interface-related */ void (*viewpoint) (struct map_session_data *sd, int npc_id, int type, int x, int y, int id, int color); - int (*damage) (struct block_list* src, struct block_list* dst, unsigned int tick, int sdelay, int ddelay, int64 damage, int div, int type, int64 damage2); + int (*damage) (struct block_list* src, struct block_list* dst, int64 tick, int sdelay, int ddelay, int64 damage, int div, int type, int64 damage2); void (*sitting) (struct block_list* bl); void (*standing) (struct block_list* bl); void (*arrow_create_list) (struct map_session_data *sd); @@ -616,7 +616,7 @@ struct clif_interface { int (*outsight) (struct block_list *bl,va_list ap); void (*skillcastcancel) (struct block_list* bl); void (*skill_fail) (struct map_session_data *sd,uint16 skill_id,enum useskill_fail_cause cause,int btype); - void (*skill_cooldown) (struct map_session_data *sd, uint16 skill_id, unsigned int tick); + void (*skill_cooldown) (struct map_session_data *sd, uint16 skill_id, unsigned int duration); void (*skill_memomessage) (struct map_session_data* sd, int type); void (*skill_mapinfomessage) (struct map_session_data *sd, int type); void (*skill_produce_mix_list) (struct map_session_data *sd, int skill_id, int trigger); @@ -682,7 +682,7 @@ struct clif_interface { void (*movetoattack) (struct map_session_data *sd,struct block_list *bl); void (*solved_charname) (int fd, int charid, const char* name); void (*charnameupdate) (struct map_session_data *ssd); - int (*delayquit) (int tid, unsigned int tick, int id, intptr_t data); + int (*delayquit) (int tid, int64 tick, int id, intptr_t data); void (*getareachar_pc) (struct map_session_data* sd,struct map_session_data* dstsd); void (*disconnect_ack) (struct map_session_data* sd, short result); void (*PVPInfo) (struct map_session_data* sd); @@ -700,9 +700,9 @@ struct clif_interface { void (*wedding_effect) (struct block_list *bl); void (*divorced) (struct map_session_data* sd, const char* name); void (*callpartner) (struct map_session_data *sd); - int (*skill_damage) (struct block_list *src,struct block_list *dst,unsigned int tick,int sdelay,int ddelay,int64 damage,int div,uint16 skill_id,uint16 skill_lv,int type); + int (*skill_damage) (struct block_list *src, struct block_list *dst, int64 tick, int sdelay, int ddelay, int64 damage, int div, uint16 skill_id, uint16 skill_lv, int type); int (*skill_nodamage) (struct block_list *src,struct block_list *dst,uint16 skill_id,int heal,int fail); - void (*skill_poseffect) (struct block_list *src,uint16 skill_id,int val,int x,int y,int tick); + void (*skill_poseffect) (struct block_list *src, uint16 skill_id, int val, int x, int y, int64 tick); void (*skill_estimation) (struct map_session_data *sd,struct block_list *dst); void (*skill_warppoint) (struct map_session_data* sd, uint16 skill_id, uint16 skill_lv, unsigned short map1, unsigned short map2, unsigned short map3, unsigned short map4); void (*skillcasting) (struct block_list* bl, int src_id, int dst_id, int dst_x, int dst_y, uint16 skill_id, int property, int casttime); @@ -960,11 +960,11 @@ struct clif_interface { void (*adopt_reply) (struct map_session_data *sd, int type); void (*adopt_request) (struct map_session_data *sd, struct map_session_data *src, int p_id); void (*readbook) (int fd, int book_id, int page); - void (*notify_time) (struct map_session_data* sd, unsigned long time); + void (*notify_time) (struct map_session_data* sd, int64 time); void (*user_count) (struct map_session_data* sd, int count); void (*noask_sub) (struct map_session_data *src, struct map_session_data *target, int type); void (*bc_ready) (void); - int (*undisguise_timer) (int tid, unsigned int tick, int id, intptr_t data); + int (*undisguise_timer) (int tid, int64 tick, int id, intptr_t data); /* Hercules Channel System */ void (*chsys_create) (struct hChSysCh *channel, char *name, char *pass, unsigned char color); void (*chsys_msg) (struct hChSysCh *channel, struct map_session_data *sd, char *msg); @@ -998,7 +998,7 @@ struct clif_interface { void (*pEmotion) (int fd, struct map_session_data *sd); void (*pHowManyConnections) (int fd, struct map_session_data *sd); void (*pActionRequest) (int fd, struct map_session_data *sd); - void (*pActionRequest_sub) (struct map_session_data *sd, int action_type, int target_id, unsigned int tick); + void (*pActionRequest_sub) (struct map_session_data *sd, int action_type, int target_id, int64 tick); void (*pRestart) (int fd, struct map_session_data *sd); void (*pWisMessage) (int fd, struct map_session_data* sd); void (*pBroadcast) (int fd, struct map_session_data* sd); @@ -1032,12 +1032,12 @@ struct clif_interface { void (*pStatusUp) (int fd,struct map_session_data *sd); void (*pSkillUp) (int fd,struct map_session_data *sd); void (*pUseSkillToId) (int fd, struct map_session_data *sd); - void (*pUseSkillToId_homun) (struct homun_data *hd, struct map_session_data *sd, unsigned int tick, uint16 skill_id, uint16 skill_lv, int target_id); - void (*pUseSkillToId_mercenary) (struct mercenary_data *md, struct map_session_data *sd, unsigned int tick, uint16 skill_id, uint16 skill_lv, int target_id); + void (*pUseSkillToId_homun) (struct homun_data *hd, struct map_session_data *sd, int64 tick, uint16 skill_id, uint16 skill_lv, int target_id); + void (*pUseSkillToId_mercenary) (struct mercenary_data *md, struct map_session_data *sd, int64 tick, uint16 skill_id, uint16 skill_lv, int target_id); void (*pUseSkillToPos) (int fd, struct map_session_data *sd); void (*pUseSkillToPosSub) (int fd, struct map_session_data *sd, uint16 skill_lv, uint16 skill_id, short x, short y, int skillmoreinfo); - void (*pUseSkillToPos_homun) (struct homun_data *hd, struct map_session_data *sd, unsigned int tick, uint16 skill_id, uint16 skill_lv, short x, short y, int skillmoreinfo); - void (*pUseSkillToPos_mercenary) (struct mercenary_data *md, struct map_session_data *sd, unsigned int tick, uint16 skill_id, uint16 skill_lv, short x, short y, int skillmoreinfo); + void (*pUseSkillToPos_homun) (struct homun_data *hd, struct map_session_data *sd, int64 tick, uint16 skill_id, uint16 skill_lv, short x, short y, int skillmoreinfo); + void (*pUseSkillToPos_mercenary) (struct mercenary_data *md, struct map_session_data *sd, int64 tick, uint16 skill_id, uint16 skill_lv, short x, short y, int skillmoreinfo); void (*pUseSkillToPosMoreInfo) (int fd, struct map_session_data *sd); void (*pUseSkillMap) (int fd, struct map_session_data* sd); void (*pRequestMemo) (int fd,struct map_session_data *sd); diff --git a/src/map/elemental.c b/src/map/elemental.c index 3251ca992..f15b735b2 100644 --- a/src/map/elemental.c +++ b/src/map/elemental.c @@ -148,7 +148,7 @@ int elemental_get_lifetime(struct elemental_data *ed) { return 0; td = timer->get(ed->summon_timer); - return (td != NULL) ? DIFF_TICK(td->tick, timer->gettick()) : 0; + return (td != NULL) ? DIFF_TICK32(td->tick, timer->gettick()) : 0; } int elemental_save(struct elemental_data *ed) { @@ -169,7 +169,7 @@ int elemental_save(struct elemental_data *ed) { return 1; } -int elemental_summon_end_timer(int tid, unsigned int tick, int id, intptr_t data) { +int elemental_summon_end_timer(int tid, int64 tick, int id, intptr_t data) { struct map_session_data *sd; struct elemental_data *ed; @@ -388,7 +388,7 @@ int elemental_clean_effect(struct elemental_data *ed) { return 1; } -int elemental_action(struct elemental_data *ed, struct block_list *bl, unsigned int tick) { +int elemental_action(struct elemental_data *ed, struct block_list *bl, int64 tick) { struct skill_condition req; uint16 skill_id, skill_lv; int i; @@ -636,7 +636,7 @@ int elemental_ai_sub_timer_activesearch(struct block_list *bl, va_list ap) { return 0; } -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, int64 tick) { struct block_list *target = NULL; int master_dist, view_range, mode; @@ -723,7 +723,7 @@ int elemental_ai_sub_timer(struct elemental_data *ed, struct map_session_data *s } if( battle->check_range(&ed->bl,target,view_range) && rnd()%100 < 2 ) { // 2% chance to cast attack skill. - if( elemental->action(ed,target,tick) ) + if( elemental->action(ed,target,tick) ) return 1; } @@ -746,14 +746,14 @@ int elemental_ai_sub_timer(struct elemental_data *ed, struct map_session_data *s } int elemental_ai_sub_foreachclient(struct map_session_data *sd, va_list ap) { - unsigned int tick = va_arg(ap,unsigned int); + int64 tick = va_arg(ap,int64); if(sd->status.ele_id && sd->ed) elemental->ai_sub_timer(sd->ed,sd,tick); return 0; } -int elemental_ai_timer(int tid, unsigned int tick, int id, intptr_t data) { +int elemental_ai_timer(int tid, int64 tick, int id, intptr_t data) { map->foreachpc(elemental->ai_sub_foreachclient,tick); return 0; } diff --git a/src/map/elemental.h b/src/map/elemental.h index b42d5c0b7..3cd819d53 100644 --- a/src/map/elemental.h +++ b/src/map/elemental.h @@ -57,7 +57,7 @@ struct elemental_data { int summon_timer; int skill_timer; - unsigned last_thinktime, last_linktime, last_spdrain_time; + int64 last_thinktime, last_linktime, last_spdrain_time; short min_chase; int target_id, attacked_id; }; @@ -99,7 +99,7 @@ struct elemental_interface { int (*set_target) (struct map_session_data *sd, struct block_list *bl); int (*clean_single_effect) (struct elemental_data *ed, uint16 skill_id); int (*clean_effect) (struct elemental_data *ed); - int (*action) (struct elemental_data *ed, struct block_list *bl, unsigned int tick); + int (*action) (struct elemental_data *ed, struct block_list *bl, int64 tick); struct skill_condition (*skill_get_requirements) (uint16 skill_id, uint16 skill_lv); int (*read_skilldb) (void); @@ -108,11 +108,11 @@ struct elemental_interface { 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 (*summon_end_timer) (int tid, int64 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_timer) (struct elemental_data *ed, struct map_session_data *sd, int64 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 (*ai_timer) (int tid, int64 tick, int id, intptr_t data); int (*read_db) (void); }; diff --git a/src/map/guild.c b/src/map/guild.c index 9b3eaaff8..0ae45bede 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -279,8 +279,7 @@ int guild_payexp_timer_sub(DBKey key, DBData *data, va_list ap) { return 0; } -int guild_payexp_timer(int tid, unsigned int tick, int id, intptr_t data) -{ +int guild_payexp_timer(int tid, int64 tick, int id, intptr_t data) { guild->expcache_db->clear(guild->expcache_db,guild->payexp_timer_sub); return 0; } @@ -314,8 +313,7 @@ int guild_send_xy_timer_sub(DBKey key, DBData *data, va_list ap) } //Code from party_send_xy_timer [Skotlex] -int guild_send_xy_timer(int tid, unsigned int tick, int id, intptr_t data) -{ +int guild_send_xy_timer(int tid, int64 tick, int id, intptr_t data) { guild->db->foreach(guild->db,guild->send_xy_timer_sub,tick); return 0; } diff --git a/src/map/guild.h b/src/map/guild.h index 566ca7ce4..348a6c7e4 100644 --- a/src/map/guild.h +++ b/src/map/guild.h @@ -148,13 +148,13 @@ struct guild_interface { /* 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); + int (*payexp_timer) (int tid, int64 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); + int (*send_xy_timer) (int tid, int64 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); diff --git a/src/map/homunculus.c b/src/map/homunculus.c index 1e47053fe..52f0572c0 100644 --- a/src/map/homunculus.c +++ b/src/map/homunculus.c @@ -615,7 +615,7 @@ bool homunculus_feed(struct map_session_data *sd, struct homun_data *hd) { return true; } -int homunculus_hunger_timer(int tid, unsigned int tick, int id, intptr_t data) { +int homunculus_hunger_timer(int tid, int64 tick, int id, intptr_t data) { struct map_session_data *sd; struct homun_data *hd; diff --git a/src/map/homunculus.h b/src/map/homunculus.h index 2cb558930..e3ec38f7b 100644 --- a/src/map/homunculus.h +++ b/src/map/homunculus.h @@ -117,7 +117,7 @@ struct homunculus_interface { void (*save) (struct homun_data *hd); unsigned char (*menu) (struct map_session_data *sd,unsigned char menu_num); bool (*feed) (struct map_session_data *sd, struct homun_data *hd); - int (*hunger_timer) (int tid, unsigned int tick, int id, intptr_t data); + int (*hunger_timer) (int tid, int64 tick, int id, intptr_t data); void (*hunger_timer_delete) (struct homun_data *hd); int (*change_name) (struct map_session_data *sd,char *name); bool (*change_name_ack) (struct map_session_data *sd, char* name, int flag); diff --git a/src/map/instance.c b/src/map/instance.c index 83b538ffc..6b96c3112 100644 --- a/src/map/instance.c +++ b/src/map/instance.c @@ -480,7 +480,7 @@ void instance_del_map(int16 m) { /*-------------------------------------- * Timer to destroy instance by process or idle *--------------------------------------*/ -int instance_destroy_timer(int tid, unsigned int tick, int id, intptr_t data) { +int instance_destroy_timer(int tid, int64 tick, int id, intptr_t data) { instance->destroy(id); return 0; } diff --git a/src/map/instance.h b/src/map/instance.h index 449ca42c6..27a9401b4 100644 --- a/src/map/instance.h +++ b/src/map/instance.h @@ -70,7 +70,7 @@ struct instance_interface { void (*check_kick) (struct map_session_data *sd); void (*set_timeout) (int instance_id, unsigned int progress_timeout, unsigned int idle_timeout); bool (*valid) (int instance_id); - int (*destroy_timer) (int tid, unsigned int tick, int id, intptr_t data); + int (*destroy_timer) (int tid, int64 tick, int id, intptr_t data); }; struct instance_interface *instance; diff --git a/src/map/irc-bot.c b/src/map/irc-bot.c index 5225672af..f67446629 100644 --- a/src/map/irc-bot.c +++ b/src/map/irc-bot.c @@ -29,7 +29,7 @@ char send_string[IRC_MESSAGE_LENGTH]; * Timer callback to (re-)connect to an IRC server * @see timer->do_timer */ -int irc_connect_timer(int tid, unsigned int tick, int id, intptr_t data) { +int irc_connect_timer(int tid, int64 tick, int id, intptr_t data) { struct hSockOpt opt; if( ircbot->isOn || ++ircbot->fails >= 3 ) return 0; @@ -52,7 +52,7 @@ int irc_connect_timer(int tid, unsigned int tick, int id, intptr_t data) { * Timer callback to send identification commands to an IRC server * @see timer->do_timer */ -int irc_identify_timer(int tid, unsigned int tick, int id, intptr_t data) { +int irc_identify_timer(int tid, int64 tick, int id, intptr_t data) { if( !ircbot->isOn ) return 0; @@ -70,7 +70,7 @@ int irc_identify_timer(int tid, unsigned int tick, int id, intptr_t data) { * Timer callback to join channels (and optionally send NickServ commands) * @see timer->do_timer */ -int irc_join_timer(int tid, unsigned int tick, int id, intptr_t data) { +int irc_join_timer(int tid, int64 tick, int id, intptr_t data) { if( !ircbot->isOn ) return 0; diff --git a/src/map/irc-bot.h b/src/map/irc-bot.h index aafbfccde..52ff0c9be 100644 --- a/src/map/irc-bot.h +++ b/src/map/irc-bot.h @@ -22,7 +22,7 @@ struct irc_func { struct irc_bot_interface { int fd; bool isIn, isOn; - unsigned int last_try; + int64 last_try; unsigned char fails; unsigned long ip; unsigned short port; @@ -43,9 +43,9 @@ struct irc_bot_interface { /* */ struct irc_func* (*func_search) (char* function_name); /* */ - int (*connect_timer) (int tid, unsigned int tick, int id, intptr_t data); - int (*identify_timer) (int tid, unsigned int tick, int id, intptr_t data); - int (*join_timer) (int tid, unsigned int tick, int id, intptr_t data); + int (*connect_timer) (int tid, int64 tick, int id, intptr_t data); + int (*identify_timer) (int tid, int64 tick, int id, intptr_t data); + int (*join_timer) (int tid, int64 tick, int id, intptr_t data); /* */ void (*send)(char *str); void (*relay) (char *name, const char *msg); diff --git a/src/map/map.c b/src/map/map.c index 81bd732df..b50297ca6 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -134,7 +134,7 @@ 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, int64 tick, int id, intptr_t data) { if (map->block_free_lock > 0) { ShowError("map_freeblock_timer: block_free_lock(%d) is invalid.\n", map->block_free_lock); map->block_free_lock = 1; @@ -266,8 +266,7 @@ int map_delblock(struct block_list* bl) * Pass flag as 1 to prevent doing skill->unit_move checks * (which are executed by default on BL_CHAR types) *------------------------------------------*/ -int map_moveblock(struct block_list *bl, int x1, int y1, unsigned int tick) -{ +int map_moveblock(struct block_list *bl, int x1, int y1, int64 tick) { int x0 = bl->x, y0 = bl->y; struct status_change *sc = NULL; int moveblock = ( x0/BLOCK_SIZE != x1/BLOCK_SIZE || y0/BLOCK_SIZE != y1/BLOCK_SIZE); @@ -1312,7 +1311,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, int64 tick, int id, intptr_t data) { struct flooritem_data* fitem = (struct flooritem_data*)idb_get(map->id_db, id); if (fitem == NULL || fitem->bl.type != BL_ITEM || (fitem->cleartimer != tid)) { @@ -2296,8 +2295,7 @@ int map_removemobs_sub(struct block_list *bl, va_list ap) return 1; } -int map_removemobs_timer(int tid, unsigned int tick, int id, intptr_t data) -{ +int map_removemobs_timer(int tid, int64 tick, int id, intptr_t data) { int count; const int16 m = id; diff --git a/src/map/map.h b/src/map/map.h index 6e4878dfd..c8b043acb 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -339,7 +339,7 @@ struct flooritem_data { unsigned char subx,suby; int cleartimer; int first_get_charid,second_get_charid,third_get_charid; - unsigned int first_get_tick,second_get_tick,third_get_tick; + int64 first_get_tick,second_get_tick,third_get_tick; struct item item_data; }; @@ -900,7 +900,7 @@ struct map_interface { // blocklist manipulation int (*addblock) (struct block_list* bl); int (*delblock) (struct block_list* bl); - int (*moveblock) (struct block_list *bl, int x1, int y1, unsigned int tick); + int (*moveblock) (struct block_list *bl, int x1, int y1, int64 tick); //blocklist nb in one cell int (*count_oncell) (int16 m,int16 x,int16 y,int type); struct skill_unit * (*find_skill_unit_oncell) (struct block_list* target,int16 x,int16 y,uint16 skill_id,struct skill_unit* out_unit, int flag); @@ -912,8 +912,8 @@ struct map_interface { // npc bool (*addnpc) (int16 m,struct npc_data *nd); // map item - int (*clearflooritem_timer) (int tid, unsigned int tick, int id, intptr_t data); - int (*removemobs_timer) (int tid, unsigned int tick, int id, intptr_t data); + int (*clearflooritem_timer) (int tid, int64 tick, int id, intptr_t data); + int (*removemobs_timer) (int tid, int64 tick, int id, intptr_t data); void (*clearflooritem) (struct block_list* bl); int (*addflooritem) (struct item *item_data,int amount,int16 m,int16 x,int16 y,int first_charid,int second_charid,int third_charid,int flags); // player to map session @@ -1001,7 +1001,7 @@ struct map_interface { void (*do_shutdown) (void); - int (*freeblock_timer) (int tid, unsigned int tick, int id, intptr_t data); + int (*freeblock_timer) (int tid, int64 tick, int id, intptr_t data); int (*searchrandfreecell) (int16 m, int16 *x, int16 *y, int stack); int (*count_sub) (struct block_list *bl, va_list ap); DBData (*create_charid2nick) (DBKey key, va_list args); diff --git a/src/map/mapreg.h b/src/map/mapreg.h index 3c1d0ba0e..c8f229cef 100644 --- a/src/map/mapreg.h +++ b/src/map/mapreg.h @@ -34,7 +34,7 @@ struct mapreg_interface { bool (*setregstr) (int uid, const char *str); void (*load) (void); void (*save) (void); - int (*save_timer) (int tid, unsigned int tick, int id, intptr_t data); + int (*save_timer) (int tid, int64 tick, int id, intptr_t data); void (*reload) (void); bool (*config_read) (const char *w1, const char *w2); }; diff --git a/src/map/mapreg_sql.c b/src/map/mapreg_sql.c index 902b7c39b..c94e42d5d 100644 --- a/src/map/mapreg_sql.c +++ b/src/map/mapreg_sql.c @@ -228,7 +228,7 @@ void script_save_mapreg(void) { } } -int script_autosave_mapreg(int tid, unsigned int tick, int id, intptr_t data) { +int script_autosave_mapreg(int tid, int64 tick, int id, intptr_t data) { mapreg->save(); return 0; } diff --git a/src/map/mercenary.c b/src/map/mercenary.c index 8b8353f46..8c74a5e1e 100644 --- a/src/map/mercenary.c +++ b/src/map/mercenary.c @@ -94,7 +94,7 @@ int mercenary_get_lifetime(struct mercenary_data *md) return 0; td = timer->get(md->contract_timer); - return (td != NULL) ? DIFF_TICK(td->tick, timer->gettick()) : 0; + return (td != NULL) ? DIFF_TICK32(td->tick, timer->gettick()) : 0; } int mercenary_get_guild(struct mercenary_data *md) @@ -217,7 +217,7 @@ int mercenary_save(struct mercenary_data *md) return 1; } -int merc_contract_end_timer(int tid, unsigned int tick, int id, intptr_t data) { +int merc_contract_end_timer(int tid, int64 tick, int id, intptr_t data) { struct map_session_data *sd; struct mercenary_data *md; diff --git a/src/map/mercenary.h b/src/map/mercenary.h index 47f37ac66..3245606cf 100644 --- a/src/map/mercenary.h +++ b/src/map/mercenary.h @@ -43,7 +43,7 @@ struct mercenary_data { int contract_timer; unsigned devotion_flag : 1; - unsigned int masterteleport_timer; + int64 masterteleport_timer; }; /*===================================== @@ -89,7 +89,7 @@ struct mercenary_interface { int (*killbonus) (struct mercenary_data *md); int (*search_index) (int class_); - int (*contract_end_timer) (int tid, unsigned int tick, int id, intptr_t data); + int (*contract_end_timer) (int tid, int64 tick, int id, intptr_t data); bool (*read_db_sub) (char* str[], int columns, int current); bool (*read_skill_db_sub) (char* str[], int columns, int current); }; diff --git a/src/map/mob.c b/src/map/mob.c index 7023bcb9d..97f8ea6c1 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -332,8 +332,7 @@ int mob_get_random_id(int type, int flag, int lv) /*========================================== * Kill Steal Protection [Zephyrus] *------------------------------------------*/ -bool mob_ksprotected (struct block_list *src, struct block_list *target) -{ +bool mob_ksprotected(struct block_list *src, struct block_list *target) { struct block_list *s_bl, *t_bl; struct map_session_data *sd, // Source @@ -341,7 +340,7 @@ bool mob_ksprotected (struct block_list *src, struct block_list *target) *t_sd; // Mob Target struct status_change_entry *sce; struct mob_data *md; - unsigned int tick = timer->gettick(); + int64 tick = timer->gettick(); char output[128]; if( !battle_config.ksprotection ) @@ -559,8 +558,8 @@ int mob_once_spawn_area(struct map_session_data* sd, int16 m, int16 x0, int16 y0 /*========================================== * Set a Guardian's guild data [Skotlex] *------------------------------------------*/ -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. +int mob_spawn_guardian_sub(int tid, int64 tick, int id, intptr_t data) { + //Needed because the guild_data may not be available at guardian spawn time. struct block_list* bl = map->id2bl(id); struct mob_data* md; struct guild* g; @@ -779,18 +778,17 @@ int mob_can_reach(struct mob_data *md,struct block_list *bl,int range, int state /*========================================== * Links nearby mobs (supportive mobs) *------------------------------------------*/ -int mob_linksearch(struct block_list *bl,va_list ap) -{ +int mob_linksearch(struct block_list *bl,va_list ap) { struct mob_data *md; int class_; struct block_list *target; - unsigned int tick; + int64 tick; nullpo_ret(bl); md=(struct mob_data *)bl; class_ = va_arg(ap, int); target = va_arg(ap, struct block_list *); - tick=va_arg(ap, unsigned int); + tick = va_arg(ap, int64); if (md->class_ == class_ && DIFF_TICK(md->last_linktime, tick) < MIN_MOBLINKTIME && !md->target_id) @@ -809,7 +807,7 @@ 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) { +int mob_delayspawn(int tid, int64 tick, int id, intptr_t data) { struct block_list* bl = map->id2bl(id); struct mob_data* md = BL_CAST(BL_MOB, bl); @@ -884,8 +882,8 @@ int mob_count_sub(struct block_list *bl, va_list ap) { int mob_spawn (struct mob_data *md) { int i=0; - unsigned int tick = timer->gettick(); - int c =0; + int64 tick = timer->gettick(); + int64 c = 0; md->last_thinktime = tick; if (md->bl.prev != NULL) @@ -1185,7 +1183,7 @@ 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, int64 tick) { struct block_list *bl; bl=map->id2bl(md->master_id); @@ -1268,8 +1266,7 @@ int mob_ai_sub_hard_slavemob(struct mob_data *md,unsigned int tick) { * when trying to pick new targets when the current chosen target is * unreachable. *------------------------------------------*/ -int mob_unlocktarget(struct mob_data *md, unsigned int tick) -{ +int mob_unlocktarget(struct mob_data *md, int64 tick) { nullpo_ret(md); switch (md->state.skillstate) { @@ -1308,8 +1305,7 @@ int mob_unlocktarget(struct mob_data *md, unsigned int tick) /*========================================== * Random walk *------------------------------------------*/ -int mob_randomwalk(struct mob_data *md,unsigned int tick) -{ +int mob_randomwalk(struct mob_data *md, int64 tick) { const int retrycount=20; int i,x,y,c,d; int speed; @@ -1383,8 +1379,7 @@ int mob_warpchase(struct mob_data *md, struct block_list *target) /*========================================== * AI of MOB whose is near a Player *------------------------------------------*/ -bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick) -{ +bool mob_ai_sub_hard(struct mob_data *md, int64 tick) { struct block_list *tbl = NULL, *abl = NULL; int mode; int view_range, can_move; @@ -1645,10 +1640,9 @@ bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick) return true; } -int mob_ai_sub_hard_timer(struct block_list *bl,va_list ap) -{ +int mob_ai_sub_hard_timer(struct block_list *bl, va_list ap) { struct mob_data *md = (struct mob_data*)bl; - unsigned int tick = va_arg(ap, unsigned int); + int64 tick = va_arg(ap, int64); if (mob->ai_sub_hard(md, tick)) { //Hard AI triggered. if(!md->state.spotted) @@ -1661,9 +1655,9 @@ 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) { - unsigned int tick; - tick=va_arg(ap,unsigned int); +int mob_ai_sub_foreachclient(struct map_session_data *sd, va_list ap) { + int64 tick; + tick=va_arg(ap, int64); map->foreachinrange(mob->ai_sub_hard_timer,&sd->bl, AREA_SIZE+ACTIVE_AI_RANGE, BL_MOB,tick); return 0; @@ -1672,16 +1666,15 @@ int mob_ai_sub_foreachclient(struct map_session_data *sd,va_list ap) { /*========================================== * Negligent mode MOB AI (PC is not in near) *------------------------------------------*/ -int mob_ai_sub_lazy(struct mob_data *md, va_list args) -{ - unsigned int tick; +int mob_ai_sub_lazy(struct mob_data *md, va_list args) { + int64 tick; nullpo_ret(md); if(md->bl.prev == NULL) return 0; - tick = va_arg(args,unsigned int); + tick = va_arg(args, int64); if (battle_config.mob_ai&0x20 && map->list[md->bl.m].users>0) return (int)mob->ai_sub_hard(md, tick); @@ -1715,7 +1708,7 @@ int mob_ai_sub_lazy(struct mob_data *md, va_list args) md->last_thinktime=tick; if (md->master_id) { - mob->ai_sub_hard_slavemob (md,tick); + mob->ai_sub_hard_slavemob(md,tick); return 0; } @@ -1740,7 +1733,7 @@ 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) { +int mob_ai_lazy(int tid, int64 tick, int id, intptr_t data) { map->foreachmob(mob->ai_sub_lazy,tick); return 0; } @@ -1748,7 +1741,7 @@ int mob_ai_lazy(int tid, unsigned int tick, int id, intptr_t data) { /*========================================== * 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, int64 tick, int id, intptr_t data) { if (battle_config.mob_ai&0x20) map->foreachmob(mob->ai_sub_lazy,tick); @@ -1785,8 +1778,7 @@ struct item_drop* mob_setlootitem(struct item* item) /*========================================== * item drop with delay (timer function) *------------------------------------------*/ -int mob_delay_item_drop(int tid, unsigned int tick, int id, intptr_t data) -{ +int mob_delay_item_drop(int tid, int64 tick, int id, intptr_t data) { struct item_drop_list *list; struct item_drop *ditem, *ditem_prev; list=(struct item_drop_list *)data; @@ -1840,7 +1832,7 @@ 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) { +int mob_timer_delete(int tid, int64 tick, int id, intptr_t data) { struct block_list* bl = map->id2bl(id); struct mob_data* md = BL_CAST(BL_MOB, bl); @@ -1885,7 +1877,7 @@ int mob_deleteslave(struct mob_data *md) { return 0; } // Mob respawning through KAIZEL or NPC_REBIRTH [Skotlex] -int mob_respawn(int tid, unsigned int tick, int id, intptr_t data) { +int mob_respawn(int tid, int64 tick, int id, intptr_t data) { struct block_list *bl = map->id2bl(id); if(!bl) return 0; @@ -2069,7 +2061,8 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) { } pt[DAMAGELOG_SIZE]; int i, temp, count, m = md->bl.m, pnum = 0; int dmgbltypes = 0; // bitfield of all bl types, that caused damage to the mob and are elligible for exp distribution - unsigned int mvp_damage, tick = timer->gettick(); + unsigned int mvp_damage; + int64 tick = timer->gettick(); bool rebirth, homkillonly; mstatus = &md->status; @@ -2610,7 +2603,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) { void mob_revive(struct mob_data *md, unsigned int hp) { - unsigned int tick = timer->gettick(); + int64 tick = timer->gettick(); md->state.skillstate = MSS_IDLE; md->last_thinktime = tick; md->next_walktime = tick+rnd()%50+5000; @@ -2695,8 +2688,8 @@ int mob_random_class (int *value, size_t count) *------------------------------------------*/ int mob_class_change (struct mob_data *md, int class_) { - unsigned int tick = timer->gettick(); - int i, c, hp_rate; + int64 tick = timer->gettick(), c = 0; + int i, hp_rate; nullpo_ret(md); @@ -3032,8 +3025,7 @@ struct mob_data *mob_getfriendstatus(struct mob_data *md,int cond1,int cond2) { /*========================================== * Skill use judging *------------------------------------------*/ -int mobskill_use(struct mob_data *md, unsigned int tick, int event) -{ +int mobskill_use(struct mob_data *md, int64 tick, int event) { struct mob_skill *ms; struct block_list *fbl = NULL; //Friend bl, which can either be a BL_PC or BL_MOB depending on the situation. [Skotlex] struct block_list *bl; @@ -3249,8 +3241,7 @@ int mobskill_use(struct mob_data *md, unsigned int tick, int event) /*========================================== * Skill use event processing *------------------------------------------*/ -int mobskill_event(struct mob_data *md, struct block_list *src, unsigned int tick, int flag) -{ +int mobskill_event(struct mob_data *md, struct block_list *src, int64 tick, int flag) { int target_id, res = 0; if(md->bl.prev == NULL || md->status.hp <= 0) @@ -3487,7 +3478,7 @@ int mob_clone_spawn(struct map_session_data *sd, int16 m, int16 x, int16 y, cons { if( md->deletetimer != INVALID_TIMER ) timer->delete(md->deletetimer, mob->timer_delete); - md->deletetimer = timer->add (timer->gettick() + duration, mob->timer_delete, md->bl.id, 0); + md->deletetimer = timer->add(timer->gettick() + duration, mob->timer_delete, md->bl.id, 0); } } diff --git a/src/map/mob.h b/src/map/mob.h index 210983675..2f425e285 100644 --- a/src/map/mob.h +++ b/src/map/mob.h @@ -166,7 +166,7 @@ struct mob_data { int areanpc_id; //Required in OnTouchNPC (to avoid multiple area touchs) unsigned int bg_id; // BattleGround System - unsigned int next_walktime,last_thinktime,last_linktime,last_pcneartime,dmgtick; + int64 next_walktime, last_thinktime, last_linktime, last_pcneartime, dmgtick; short move_fail_count; short lootitem_count; short min_chase; @@ -175,7 +175,7 @@ struct mob_data { int master_id,master_dist; int8 skill_idx;// key of array - unsigned int skilldelay[MAX_MOBSKILL]; + int64 skilldelay[MAX_MOBSKILL]; char npc_event[EVENT_NAME_LENGTH]; /** * Did this monster summon something? @@ -266,7 +266,7 @@ struct mob_interface { struct mob_db* (*db) (int index); struct mob_chat* (*chat) (short id); int (*makedummymobdb) (int); - int (*spawn_guardian_sub) (int tid, unsigned int tick, int id, intptr_t data); + int (*spawn_guardian_sub) (int tid, int64 tick, int id, intptr_t data); int (*skill_id2skill_idx) (int class_, uint16 skill_id); int (*db_searchname) (const char *str); int (*db_searchname_array_sub) (struct mob_db *mob, const char *str, int flag); @@ -287,7 +287,7 @@ struct mob_interface { int (*spawn_bg) (const char *mapname, short x, short y, const char *mobname, int class_, const char *event, unsigned int bg_id); int (*can_reach) (struct mob_data *md, struct block_list *bl, int range, int state); int (*linksearch) (struct block_list *bl, va_list ap); - int (*delayspawn) (int tid, unsigned int tick, int id, intptr_t data); + int (*delayspawn) (int tid, int64 tick, int id, intptr_t data); int (*setdelayspawn) (struct mob_data *md); int (*count_sub) (struct block_list *bl, va_list ap); int (*spawn) (struct mob_data *md); @@ -298,24 +298,24 @@ struct mob_interface { int (*ai_sub_hard_bg_ally) (struct block_list *bl, va_list ap); int (*ai_sub_hard_lootsearch) (struct block_list *bl, va_list ap); int (*warpchase_sub) (struct block_list *bl, va_list ap); - int (*ai_sub_hard_slavemob) (struct mob_data *md, unsigned int tick); - int (*unlocktarget) (struct mob_data *md, unsigned int tick); - int (*randomwalk) (struct mob_data *md, unsigned int tick); + int (*ai_sub_hard_slavemob) (struct mob_data *md, int64 tick); + int (*unlocktarget) (struct mob_data *md, int64 tick); + int (*randomwalk) (struct mob_data *md, int64 tick); int (*warpchase) (struct mob_data *md, struct block_list *target); - bool (*ai_sub_hard) (struct mob_data *md, unsigned int tick); + bool (*ai_sub_hard) (struct mob_data *md, int64 tick); int (*ai_sub_hard_timer) (struct block_list *bl, va_list ap); int (*ai_sub_foreachclient) (struct map_session_data *sd, va_list ap); int (*ai_sub_lazy) (struct mob_data *md, va_list args); - int (*ai_lazy) (int tid, unsigned int tick, int id, intptr_t data); - int (*ai_hard) (int tid, unsigned int tick, int id, intptr_t data); + int (*ai_lazy) (int tid, int64 tick, int id, intptr_t data); + int (*ai_hard) (int tid, int64 tick, int id, intptr_t data); struct item_drop* (*setdropitem) (int nameid, int qty, struct item_data *data); struct item_drop* (*setlootitem) (struct item *item); - int (*delay_item_drop) (int tid, unsigned int tick, int id, intptr_t data); + int (*delay_item_drop) (int tid, int64 tick, int id, intptr_t data); void (*item_drop) (struct mob_data *md, struct item_drop_list *dlist, struct item_drop *ditem, int loot, int drop_rate, unsigned short flag); - int (*timer_delete) (int tid, unsigned int tick, int id, intptr_t data); + int (*timer_delete) (int tid, int64 tick, int id, intptr_t data); int (*deleteslave_sub) (struct block_list *bl, va_list ap); int (*deleteslave) (struct mob_data *md); - int (*respawn) (int tid, unsigned int tick, int id, intptr_t data); + int (*respawn) (int tid, int64 tick, int id, intptr_t data); void (*log_damage) (struct mob_data *md, struct block_list *src, int damage); void (*damage) (struct mob_data *md, struct block_list *src, int damage); int (*dead) (struct mob_data *md, struct block_list *src, int type); @@ -334,8 +334,8 @@ struct mob_interface { struct block_list* (*getmasterhpltmaxrate) (struct mob_data *md, int rate); int (*getfriendstatus_sub) (struct block_list *bl, va_list ap); struct mob_data* (*getfriendstatus) (struct mob_data *md, int cond1, int cond2); - int (*skill_use) (struct mob_data *md, unsigned int tick, int event); - int (*skill_event) (struct mob_data *md, struct block_list *src, unsigned int tick, int flag); + int (*skill_use) (struct mob_data *md, int64 tick, int event); + int (*skill_event) (struct mob_data *md, struct block_list *src, int64 tick, int flag); int (*is_clone) (int class_); int (*clone_spawn) (struct map_session_data *sd, int16 m, int16 x, int16 y, const char *event, int master_id, int mode, int flag, unsigned int duration); int (*clone_delete) (struct mob_data *md); diff --git a/src/map/npc.c b/src/map/npc.c index e4416c19f..ff95cf82d 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -215,7 +215,7 @@ struct npc_data* npc_name2id(const char* name) /** * Timer to check for idle time and timeout the dialog if necessary **/ -int npc_rr_secure_timeout_timer(int tid, unsigned int tick, int id, intptr_t data) { +int npc_rr_secure_timeout_timer(int tid, int64 tick, int id, intptr_t data) { #ifdef SECURE_NPCTIMEOUT struct map_session_data* sd = NULL; unsigned int timeout = NPC_SECURE_TIMEOUT_NEXT; @@ -394,8 +394,7 @@ int npc_event_doall(const char* name) * Clock event execution * OnMinute/OnClock/OnHour/OnDay/OnDDHHMM *------------------------------------------*/ -int npc_event_do_clock(int tid, unsigned int tick, int id, intptr_t data) -{ +int npc_event_do_clock(int tid, int64 tick, int id, intptr_t data) { static struct tm ev_tm_b; // tracks previous execution time time_t clock; struct tm* t; @@ -493,9 +492,9 @@ 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, int64 tick, int id, intptr_t data) { int old_rid, old_timer; - unsigned int old_tick; + int64 old_tick; 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; @@ -529,8 +528,7 @@ int npc_timerevent(int tid, unsigned int tick, int id, intptr_t data) { ted->next++; if( nd->u.scr.timeramount > ted->next ) { - int next; - next = nd->u.scr.timer_event[ ted->next ].timer - nd->u.scr.timer_event[ ted->next - 1 ].timer; + int next = nd->u.scr.timer_event[ ted->next ].timer - nd->u.scr.timer_event[ ted->next - 1 ].timer; ted->time += next; if( sd ) sd->npc_timer_id = timer->add(tick+next,npc->timerevent,id,(intptr_t)ted); @@ -564,7 +562,7 @@ int npc_timerevent(int tid, unsigned int tick, int id, intptr_t data) { *------------------------------------------*/ int npc_timerevent_start(struct npc_data* nd, int rid) { int j; - unsigned int tick = timer->gettick(); + int64 tick = timer->gettick(); struct map_session_data *sd = NULL; //Player to whom script is attached. nullpo_ret(nd); @@ -642,7 +640,7 @@ int npc_timerevent_stop(struct npc_data* nd) if( !sd && nd->u.scr.timertick ) { - nd->u.scr.timer += DIFF_TICK(timer->gettick(),nd->u.scr.timertick); // Set 'timer' to the time that has passed since the beginning of the timers + nd->u.scr.timer += DIFF_TICK32(timer->gettick(),nd->u.scr.timertick); // Set 'timer' to the time that has passed since the beginning of the timers nd->u.scr.timertick = 0; // Set 'tick' to zero so that we know it's off. } @@ -688,7 +686,7 @@ void npc_timerevent_quit(struct map_session_data* sd) if( ev ) { int old_rid,old_timer; - unsigned int old_tick; + int64 old_tick; //Set timer related info. old_rid = (nd->u.scr.rid == sd->bl.id ? 0 : nd->u.scr.rid); // Detach rid if the last attached player logged off. @@ -715,9 +713,8 @@ void npc_timerevent_quit(struct map_session_data* sd) * Get the tick value of an NPC timer * If it's stopped, return stopped time *------------------------------------------*/ -int npc_gettimerevent_tick(struct npc_data* nd) -{ - int tick; +int64 npc_gettimerevent_tick(struct npc_data* nd) { + int64 tick; nullpo_ret(nd); // TODO: Get player attached timer's tick. Now we can just get it by using 'getnpctimer' inside OnTimer event. diff --git a/src/map/npc.h b/src/map/npc.h index f809cb19c..e1ec6e5e4 100644 --- a/src/map/npc.h +++ b/src/map/npc.h @@ -35,7 +35,7 @@ struct npc_data { char exname[NAME_LENGTH+1];// unique npc name int chat_id; int touching_id; - unsigned int next_walktime; + int64 next_walktime; uint8 dir; unsigned size : 2; @@ -54,7 +54,7 @@ struct npc_data { short xs,ys; // OnTouch area radius int guild_id; int timer,timerid,timeramount,rid; - unsigned int timertick; + int64 timertick; struct npc_timerevent_list *timer_event; int label_list_num; struct npc_label_list *label_list; @@ -160,14 +160,14 @@ struct npc_interface { int (*event_do) (const char *name); int (*event_doall_id) (const char *name, int rid); int (*event_doall) (const char *name); - int (*event_do_clock) (int tid, unsigned int tick, int id, intptr_t data); + int (*event_do_clock) (int tid, int64 tick, int id, intptr_t data); void (*event_do_oninit) (void); int (*timerevent_export) (struct npc_data *nd, int i); - int (*timerevent) (int tid, unsigned int tick, int id, intptr_t data); + int (*timerevent) (int tid, int64 tick, int id, intptr_t data); int (*timerevent_start) (struct npc_data *nd, int rid); int (*timerevent_stop) (struct npc_data *nd); void (*timerevent_quit) (struct map_session_data *sd); - int (*gettimerevent_tick) (struct npc_data *nd); + int64 (*gettimerevent_tick) (struct npc_data *nd); int (*settimerevent_tick) (struct npc_data *nd, int newtimer); int (*event) (struct map_session_data *sd, const char *eventname, int ontouch); int (*touch_areanpc_sub) (struct block_list *bl, va_list ap); @@ -229,7 +229,7 @@ struct npc_interface { /** * For the Secure NPC Timeout option (check config/Secure.h) [RR] **/ - int (*secure_timeout_timer) (int tid, unsigned int tick, int id, intptr_t data); + int (*secure_timeout_timer) (int tid, int64 tick, int id, intptr_t data); }; struct npc_interface *npc; diff --git a/src/map/party.c b/src/map/party.c index 904110452..ab05c23f7 100644 --- a/src/map/party.c +++ b/src/map/party.c @@ -831,8 +831,7 @@ int party_skill_check(struct map_session_data *sd, int party_id, uint16 skill_id return 0; } -int party_send_xy_timer(int tid, unsigned int tick, int id, intptr_t data) -{ +int party_send_xy_timer(int tid, int64 tick, int id, intptr_t data) { struct party_data* p; DBIterator *iter = db_iterator(party->db); diff --git a/src/map/party.h b/src/map/party.h index 208edb846..ab14d1a31 100644 --- a/src/map/party.h +++ b/src/map/party.h @@ -123,7 +123,7 @@ struct party_interface { /* */ int (*vforeachsamemap) (int (*func)(struct block_list *,va_list),struct map_session_data *sd,int range, va_list ap); int (*foreachsamemap) (int (*func)(struct block_list *,va_list),struct map_session_data *sd,int range,...); - int (*send_xy_timer) (int tid, unsigned int tick, int id, intptr_t data); + int (*send_xy_timer) (int tid, int64 tick, int id, intptr_t data); void (*fill_member) (struct party_member* member, struct map_session_data* sd, unsigned int leader); TBL_PC* (*sd_check) (int party_id, int account_id, int char_id); void (*check_state) (struct party_data *p); diff --git a/src/map/pc.c b/src/map/pc.c index b39ae1c59..22413d567 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -117,7 +117,7 @@ bool pc_should_log_commands(struct map_session_data *sd) return pc_group_should_log_commands(sd->group); } -int pc_invincible_timer(int tid, unsigned int tick, int id, intptr_t data) { +int pc_invincible_timer(int tid, int64 tick, int id, intptr_t data) { struct map_session_data *sd; if( (sd=(struct map_session_data *)map->id2sd(id)) == NULL || sd->bl.type!=BL_PC ) @@ -155,7 +155,7 @@ void pc_delinvincibletimer(struct map_session_data* sd) } } -int pc_spiritball_timer(int tid, unsigned int tick, int id, intptr_t data) { +int pc_spiritball_timer(int tid, int64 tick, int id, intptr_t data) { struct map_session_data *sd; int i; @@ -419,7 +419,7 @@ int pc_setrestartvalue(struct map_session_data *sd,int type) { /*========================================== Rental System *------------------------------------------*/ -int pc_inventory_rental_end(int tid, unsigned int tick, int id, intptr_t data) { +int pc_inventory_rental_end(int tid, int64 tick, int id, intptr_t data) { struct map_session_data *sd = map->id2sd(id); if( sd == NULL ) return 0; @@ -447,7 +447,7 @@ int pc_inventory_rental_clear(struct map_session_data *sd) void pc_inventory_rentals(struct map_session_data *sd) { int i, c = 0; - unsigned int expire_tick, next_tick = UINT_MAX; + int64 expire_tick, next_tick = INT64_MAX; for( i = 0; i < MAX_INVENTORY; i++ ) { // Check for Rentals on Inventory @@ -464,7 +464,7 @@ void pc_inventory_rentals(struct map_session_data *sd) clif->rental_expired(sd->fd, i, sd->status.inventory[i].nameid); pc->delitem(sd, i, sd->status.inventory[i].amount, 0, 0, LOG_TYPE_OTHER); } else { - expire_tick = (unsigned int)(sd->status.inventory[i].expire_time - time(NULL)) * 1000; + expire_tick = (int64)(sd->status.inventory[i].expire_time - time(NULL)) * 1000; clif->rental_time(sd->fd, sd->status.inventory[i].nameid, (int)(expire_tick / 1000)); next_tick = min(expire_tick, next_tick); c++; @@ -927,7 +927,7 @@ int pc_isequip(struct map_session_data *sd,int n) *------------------------------------------*/ bool pc_authok(struct map_session_data *sd, int login_id2, time_t expiration_time, int group_id, struct mmo_charstatus *st, bool changing_mapservers) { int i; - unsigned long tick = timer->gettick(); + int64 tick = timer->gettick(); uint32 ip = session[sd->fd]->client_addr; sd->login_id2 = login_id2; @@ -1971,7 +1971,7 @@ 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) { +int pc_endautobonus(int tid, int64 tick, int id, intptr_t data) { struct map_session_data *sd = map->id2sd(id); struct s_autobonus *autobonus = (struct s_autobonus *)data; @@ -4026,7 +4026,7 @@ int pc_dropitem(struct map_session_data *sd,int n,int amount) int pc_takeitem(struct map_session_data *sd,struct flooritem_data *fitem) { int flag=0; - unsigned int tick = timer->gettick(); + int64 tick = timer->gettick(); struct map_session_data *first_sd = NULL,*second_sd = NULL,*third_sd = NULL; struct party_data *p=NULL; @@ -4276,7 +4276,7 @@ int pc_isUseitem(struct map_session_data *sd,int n) * 1 = success *------------------------------------------*/ int pc_useitem(struct map_session_data *sd,int n) { - unsigned int tick = timer->gettick(); + int64 tick = timer->gettick(); int amount, nameid, i; struct script_code *item_script; @@ -4343,7 +4343,7 @@ int pc_useitem(struct map_session_data *sd,int n) { if( i < MAX_ITEMDELAYS ) { if( sd->item_delay[i].nameid ) {// found if( DIFF_TICK(sd->item_delay[i].tick, tick) > 0 ) { - int e_tick = DIFF_TICK(sd->item_delay[i].tick, tick)/1000; + int e_tick = (int)(DIFF_TICK(sd->item_delay[i].tick, tick)/1000); clif->msgtable_num(sd->fd, 0x746, e_tick + 1); // [%d] seconds left until you can use return 0; // Delay has not expired yet } @@ -5642,7 +5642,7 @@ 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, int64 tick, int id, intptr_t data) { struct map_session_data *sd; struct block_list *tbl; @@ -6600,7 +6600,7 @@ 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. } -int pc_respawn_timer(int tid, unsigned int tick, int id, intptr_t data) { +int pc_respawn_timer(int tid, int64 tick, int id, intptr_t data) { struct map_session_data *sd = map->id2sd(id); if( sd != NULL ) { @@ -6647,7 +6647,7 @@ void pc_damage(struct map_session_data *sd,struct block_list *src,unsigned int h *------------------------------------------*/ int pc_dead(struct map_session_data *sd,struct block_list *src) { int i=0,j=0,k=0; - unsigned int tick = timer->gettick(); + int64 tick = timer->gettick(); for(k = 0; k < 5; k++) if (sd->devotion[k]){ @@ -8250,7 +8250,7 @@ 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)) *------------------------------------------*/ -int pc_eventtimer(int tid, unsigned int tick, int id, intptr_t data) { +int pc_eventtimer(int tid, int64 tick, int id, intptr_t data) { struct map_session_data *sd=map->id2sd(id); char *p = (char *)data; int i; @@ -9011,7 +9011,7 @@ 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, int64 tick, int id, intptr_t data) { struct map_session_data *sd; sd=map->id2sd(id); @@ -9224,10 +9224,9 @@ int pc_setsavepoint(struct map_session_data *sd, short mapindex,int x,int y) } /*========================================== - * Save 1 player data at autosave intervalle + * Save 1 player data at autosave intervall *------------------------------------------*/ -int pc_autosave(int tid, unsigned int tick, int id, intptr_t data) -{ +int pc_autosave(int tid, int64 tick, int id, intptr_t data) { int interval; struct s_mapiterator* iter; struct map_session_data* sd; @@ -9278,7 +9277,7 @@ 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, int64 tick, int id, intptr_t data) { char tmp_soutput[1024]; if (data == 0 && battle_config.day_duration <= 0) // if we want a day @@ -9298,7 +9297,7 @@ 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, int64 tick, int id, intptr_t data) { char tmp_soutput[1024]; if (data == 0 && battle_config.night_duration <= 0) // if we want a night @@ -9370,7 +9369,7 @@ bool pc_can_use_command(struct map_session_data *sd, const char *command) { return atcommand->can_use(sd,command); } -int pc_charm_timer(int tid, unsigned int tick, int id, intptr_t data) { +int pc_charm_timer(int tid, int64 tick, int id, intptr_t data) { struct map_session_data *sd; int i, type; diff --git a/src/map/pc.h b/src/map/pc.h index ff6246b22..cdf4f9dce 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -210,10 +210,10 @@ struct map_session_data { char npc_str[CHATBOX_SIZE]; // for passing npc input box text to script engine int npc_timer_id; //For player attached npc timers. [Skotlex] unsigned int chatID; - time_t idletime; - struct{ + int64 idletime; + struct { int npc_id; - unsigned int timeout; + int64 timeout; } progressbar; //Progress Bar [Inkfish] struct{ char name[NAME_LENGTH]; @@ -229,17 +229,17 @@ struct map_session_data { int cloneskill_id, reproduceskill_id; int menuskill_id, menuskill_val, menuskill_val2; int invincible_timer; - unsigned int canlog_tick; - unsigned int canuseitem_tick; // [Skotlex] - unsigned int canusecashfood_tick; - unsigned int canequip_tick; // [Inkfish] - unsigned int cantalk_tick; - unsigned int canskill_tick; // used to prevent abuse from no-delay ACT files - unsigned int cansendmail_tick; // [Mail System Flood Protection] - unsigned int ks_floodprotect_tick; // [Kill Steal Protection] + int64 canlog_tick; + int64 canuseitem_tick; // [Skotlex] + int64 canusecashfood_tick; + int64 canequip_tick; // [Inkfish] + int64 cantalk_tick; + int64 canskill_tick; /// used to prevent abuse from no-delay ACT files + int64 cansendmail_tick; /// Mail System Flood Protection + int64 ks_floodprotect_tick; /// [Kill Steal Protection] struct { short nameid; - unsigned int tick; + int64 tick; } item_delay[MAX_ITEMDELAYS]; // [Paradox924X] short weapontype1,weapontype2; short disguise; // [Valaris] @@ -460,7 +460,7 @@ struct map_session_data { * @info * - It is updated on every NPC iteration as mentioned above **/ - unsigned int npc_idle_tick; + int64 npc_idle_tick; /* */ enum npc_timeout_type npc_idle_type; #endif @@ -485,7 +485,7 @@ struct map_session_data { bool stealth; unsigned char fontcolor; unsigned int fontcolor_tid; - unsigned int hchsysch_tick; + int64 hchsysch_tick; /* [Ind/Hercules] */ struct sc_display_entry **sc_display; @@ -695,7 +695,7 @@ enum { ADDITEM_EXIST , ADDITEM_NEW , ADDITEM_OVERAMOUNT }; * All cooldowns are reset when server is restarted. **/ struct item_cd { - unsigned int tick[MAX_ITEMDELAYS];//tick + int64 tick[MAX_ITEMDELAYS];//tick short nameid[MAX_ITEMDELAYS];//skill id }; @@ -796,7 +796,7 @@ struct pc_interface { int (*addautobonus) (struct s_autobonus *bonus,char max,const char *bonus_script,short rate,unsigned int dur,short atk_type,const char *o_script,unsigned short pos,bool onskill); int (*exeautobonus) (struct map_session_data* sd,struct s_autobonus *bonus); - int (*endautobonus) (int tid, unsigned int tick, int id, intptr_t data); + int (*endautobonus) (int tid, int64 tick, int id, intptr_t data); int (*delautobonus) (struct map_session_data* sd,struct s_autobonus *bonus,char max,bool restore); int (*bonus) (struct map_session_data *sd,int type,int val); @@ -878,7 +878,7 @@ struct pc_interface { int (*addeventtimercount) (struct map_session_data *sd,const char *name,int tick); int (*calc_pvprank) (struct map_session_data *sd); - int (*calc_pvprank_timer) (int tid, unsigned int tick, int id, intptr_t data); + int (*calc_pvprank_timer) (int tid, int64 tick, int id, intptr_t data); int (*ismarried) (struct map_session_data *sd); int (*marriage) (struct map_session_data *sd,struct map_session_data *dstsd); @@ -909,8 +909,8 @@ struct pc_interface { int (*set_hate_mob) (struct map_session_data *sd, int pos, struct block_list *bl); int (*readdb) (void); - int (*map_day_timer) (int tid, unsigned int tick, int id, intptr_t data); // by [yor] - int (*map_night_timer) (int tid, unsigned int tick, int id, intptr_t data); // by [yor] + int (*map_day_timer) (int tid, int64 tick, int id, intptr_t data); // by [yor] + int (*map_night_timer) (int tid, int64 tick, int id, intptr_t data); // by [yor] // Rental System void (*inventory_rentals) (struct map_session_data *sd); int (*inventory_rental_clear) (struct map_session_data *sd); @@ -934,10 +934,10 @@ struct pc_interface { int (*level_penalty_mod) (int diff, unsigned char race, unsigned short mode, int type); int (*calc_skillpoint) (struct map_session_data* sd); - int (*invincible_timer) (int tid, unsigned int tick, int id, intptr_t data); - int (*spiritball_timer) (int tid, unsigned int tick, int id, intptr_t data); + int (*invincible_timer) (int tid, int64 tick, int id, intptr_t data); + int (*spiritball_timer) (int tid, int64 tick, int id, intptr_t data); int (*check_banding) ( struct block_list *bl, va_list ap ); - int (*inventory_rental_end) (int tid, unsigned int tick, int id, intptr_t data); + int (*inventory_rental_end) (int tid, int64 tick, int id, intptr_t data); void (*check_skilltree) (struct map_session_data *sd, int skill_id); int (*bonus_autospell) (struct s_autospell *spell, int max, short id, short lv, short rate, short flag, short card_id); int (*bonus_autospell_onskill) (struct s_autospell *spell, int max, short src_skill, short id, short lv, short rate, short card_id); @@ -945,16 +945,16 @@ struct pc_interface { int (*bonus_addeff_onskill) (struct s_addeffectonskill* effect, int max, enum sc_type id, short rate, short skill_id, unsigned char target); int (*bonus_item_drop) (struct s_add_drop *drop, const short max, short id, short group, int race, int rate); void (*calcexp) (struct map_session_data *sd, unsigned int *base_exp, unsigned int *job_exp, struct block_list *src); - int (*respawn_timer) (int tid, unsigned int tick, int id, intptr_t data); + int (*respawn_timer) (int tid, int64 tick, int id, intptr_t data); int (*jobchange_killclone) (struct block_list *bl, va_list ap); int (*getstat) (struct map_session_data* sd, int type); int (*setstat) (struct map_session_data* sd, int type, int val); - int (*eventtimer) (int tid, unsigned int tick, int id, intptr_t data); + int (*eventtimer) (int tid, int64 tick, int id, intptr_t data); int (*daynight_timer_sub) (struct map_session_data *sd,va_list ap); - int (*charm_timer) (int tid, unsigned int tick, int id, intptr_t data); + int (*charm_timer) (int tid, int64 tick, int id, intptr_t data); bool (*readdb_levelpenalty) (char* fields[], int columns, int current); - int (*autosave) (int tid, unsigned int tick, int id, intptr_t data); - int (*follow_timer) (int tid, unsigned int tick, int id, intptr_t data); + int (*autosave) (int tid, int64 tick, int id, intptr_t data); + int (*follow_timer) (int tid, int64 tick, int id, intptr_t data); void (*read_skill_tree) (void); int (*isUseitem) (struct map_session_data *sd,int n); int (*show_steal) (struct block_list *bl,va_list ap); diff --git a/src/map/pet.c b/src/map/pet.c index 023059a6b..a20cc0df0 100644 --- a/src/map/pet.c +++ b/src/map/pet.c @@ -186,7 +186,7 @@ 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, int64 tick, int id, intptr_t data) { struct map_session_data *sd; struct pet_data *pd; int interval; @@ -666,7 +666,7 @@ int pet_equipitem(struct map_session_data *sd,int index) { clif->send_petdata(NULL, sd->pd, 3, sd->pd->vd.head_bottom); if (battle_config.pet_equip_required) { //Skotlex: start support timers if need - unsigned int tick = timer->gettick(); + int64 tick = timer->gettick(); 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); @@ -771,8 +771,7 @@ int pet_food(struct map_session_data *sd, struct pet_data *pd) return 0; } -int pet_randomwalk(struct pet_data *pd,unsigned int tick) -{ +int pet_randomwalk(struct pet_data *pd, int64 tick) { nullpo_ret(pd); Assert((pd->msd == 0) || (pd->msd->pd == pd)); @@ -812,8 +811,7 @@ int pet_randomwalk(struct pet_data *pd,unsigned int tick) return 0; } -int pet_ai_sub_hard(struct pet_data *pd, struct map_session_data *sd, unsigned int tick) -{ +int pet_ai_sub_hard(struct pet_data *pd, struct map_session_data *sd, int64 tick) { struct block_list *target = NULL; if(pd->bl.prev == NULL || sd == NULL || sd->bl.prev == NULL) @@ -924,16 +922,15 @@ int pet_ai_sub_hard(struct pet_data *pd, struct map_session_data *sd, unsigned i return 0; } -int pet_ai_sub_foreachclient(struct map_session_data *sd,va_list ap) -{ - unsigned int tick = va_arg(ap,unsigned int); +int pet_ai_sub_foreachclient(struct map_session_data *sd,va_list ap) { + int64 tick = va_arg(ap,int64); if(sd->status.pet_id && sd->pd) pet->ai_sub_hard(sd->pd,sd,tick); return 0; } -int pet_ai_hard(int tid, unsigned int tick, int id, intptr_t data) { +int pet_ai_hard(int tid, int64 tick, int id, intptr_t data) { map->foreachpc(pet->ai_sub_foreachclient,tick); return 0; @@ -966,7 +963,7 @@ 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, int64 tick, int id, intptr_t data) { struct item_drop_list *list; struct item_drop *ditem, *ditem_prev; list=(struct item_drop_list *)data; @@ -1034,7 +1031,7 @@ 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) { +int pet_skill_bonus_timer(int tid, int64 tick, int id, intptr_t data) { struct map_session_data *sd=map->id2sd(id); struct pet_data *pd; int bonus; @@ -1075,7 +1072,7 @@ 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) { +int pet_recovery_timer(int tid, int64 tick, int id, intptr_t data) { struct map_session_data *sd=map->id2sd(id); struct pet_data *pd; @@ -1102,7 +1099,7 @@ int pet_recovery_timer(int tid, unsigned int tick, int id, intptr_t data) { return 0; } -int pet_heal_timer(int tid, unsigned int tick, int id, intptr_t data) { +int pet_heal_timer(int tid, int64 tick, int id, intptr_t data) { struct map_session_data *sd=map->id2sd(id); struct status_data *st; struct pet_data *pd; @@ -1139,7 +1136,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) { +int pet_skill_support_timer(int tid, int64 tick, int id, intptr_t data) { struct map_session_data *sd=map->id2sd(id); struct pet_data *pd; struct status_data *st; diff --git a/src/map/pet.h b/src/map/pet.h index 2f8e0b7c2..f95e860a2 100644 --- a/src/map/pet.h +++ b/src/map/pet.h @@ -86,7 +86,7 @@ struct pet_data { unsigned skillbonus : 1; } state; int move_fail_count; - unsigned int next_walktime,last_thinktime; + int64 next_walktime, last_thinktime; short rate_fix; //Support rate as modified by intimacy (1000 = 100%) [Skotlex] struct pet_recovery* recovery; @@ -116,7 +116,7 @@ struct pet_interface { int (*attackskill) (struct pet_data *pd, int target_id); int (*target_check) (struct map_session_data *sd, struct block_list *bl, int type); int (*sc_check) (struct map_session_data *sd, int type); - int (*hungry) (int tid, unsigned int tick, int id, intptr_t data); + int (*hungry) (int tid, int64 tick, int id, intptr_t data); int (*search_petDB_index) (int key, int type); int (*hungry_timer_delete) (struct pet_data *pd); int (*performance) (struct map_session_data *sd, struct pet_data *pd); @@ -135,16 +135,16 @@ struct pet_interface { int (*change_name) (struct map_session_data *sd, char *name); int (*change_name_ack) (struct map_session_data *sd, char *name, int flag); int (*equipitem) (struct map_session_data *sd, int index); - int (*randomwalk) (struct pet_data *pd, unsigned int tick); - int (*ai_sub_hard) (struct pet_data *pd, struct map_session_data *sd, unsigned int tick); + int (*randomwalk) (struct pet_data *pd, int64 tick); + int (*ai_sub_hard) (struct pet_data *pd, struct map_session_data *sd, int64 tick); int (*ai_sub_foreachclient) (struct map_session_data *sd, va_list ap); - int (*ai_hard) (int tid, unsigned int tick, int id, intptr_t data); - int (*delay_item_drop) (int tid, unsigned int tick, int id, intptr_t data); + int (*ai_hard) (int tid, int64 tick, int id, intptr_t data); + int (*delay_item_drop) (int tid, int64 tick, int id, intptr_t data); int (*lootitem_drop) (struct pet_data *pd, struct map_session_data *sd); - int (*skill_bonus_timer) (int tid, unsigned int tick, int id, intptr_t data); - int (*recovery_timer) (int tid, unsigned int tick, int id, intptr_t data); - int (*heal_timer) (int tid, unsigned int tick, int id, intptr_t data); - int (*skill_support_timer) (int tid, unsigned int tick, int id, intptr_t data); + int (*skill_bonus_timer) (int tid, int64 tick, int id, intptr_t data); + int (*recovery_timer) (int tid, int64 tick, int id, intptr_t data); + int (*heal_timer) (int tid, int64 tick, int id, intptr_t data); + int (*skill_support_timer) (int tid, int64 tick, int id, intptr_t data); int (*read_db) (); }; diff --git a/src/map/script.c b/src/map/script.c index efc3e0264..6198f21da 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -3184,7 +3184,7 @@ void script_stop_instances(struct script_code *code) { /*========================================== * Timer function for sleep *------------------------------------------*/ -int run_script_timer(int tid, unsigned int tick, int id, intptr_t data) { +int run_script_timer(int tid, int64 tick, int id, intptr_t data) { struct script_state *st = idb_get(script->st_db,(int)data); if( st ) { TBL_PC *sd = map->id2sd(st->rid); @@ -7993,7 +7993,7 @@ BUILDIN(gettimetick) { /* Asgard Version */ case 0: default: //type 0:(System Ticks) - script_pushint(st,timer->gettick()); + script_pushint(st,(int)timer->gettick()); // TODO: change this to int64 when we'll support 64 bit script values break; } return true; @@ -8821,7 +8821,7 @@ BUILDIN(getnpctimer) { } switch( type ) { - case 0: val = npc->gettimerevent_tick(nd); break; + case 0: val = (int)npc->gettimerevent_tick(nd); break; // FIXME: change this to int64 when we'll support 64 bit script values case 1: if( nd->u.scr.rid ) { sd = map->id2sd(nd->u.scr.rid); @@ -9505,7 +9505,7 @@ BUILDIN(getstatus) if( td ) { // return the amount of time remaining - script_pushint(st, td->tick - timer->gettick()); + script_pushint(st, (int)(td->tick - timer->gettick())); // TODO: change this to int64 when we'll support 64 bit script values } } break; @@ -12688,7 +12688,7 @@ BUILDIN(summon) const char *str,*event=""; TBL_PC *sd; struct mob_data *md; - int tick = timer->gettick(); + int64 tick = timer->gettick(); sd=script->rid2sd(st); if (!sd) return true; @@ -14543,7 +14543,7 @@ BUILDIN(checkidle) { sd = script->rid2sd(st); if (sd) - script_pushint(st, DIFF_TICK(last_tick, sd->idletime)); + script_pushint(st, DIFF_TICK32(last_tick, sd->idletime)); // TODO: change this to int64 when we'll support 64 bit script values else script_pushint(st, 0); diff --git a/src/map/script.h b/src/map/script.h index 400916af8..c6cb6070b 100644 --- a/src/map/script.h +++ b/src/map/script.h @@ -536,7 +536,7 @@ struct script_interface { void (*label_add)(int key, int pos); void (*run) (struct script_code *rootscript,int pos,int rid,int oid); void (*run_main) (struct script_state *st); - int (*run_timer) (int tid, unsigned int tick, int id, intptr_t data); + int (*run_timer) (int tid, int64 tick, int id, intptr_t data); int (*set_var) (struct map_session_data *sd, char *name, void *val); void (*stop_instances) (struct script_code *code); void (*free_code) (struct script_code* code); diff --git a/src/map/skill.c b/src/map/skill.c index 36a509876..b70e58c46 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -639,7 +639,7 @@ struct s_skill_unit_layout* skill_get_unit_layout (uint16 skill_id, uint16 skill /*========================================== * *------------------------------------------*/ -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, int64 tick) { struct map_session_data *sd, *dstsd; struct mob_data *md, *dstmd; struct status_data *sstatus, *tstatus; @@ -1569,7 +1569,7 @@ int skill_additional_effect(struct block_list* src, struct block_list *bl, uint1 return 0; } -int skill_onskillusage(struct map_session_data *sd, struct block_list *bl, uint16 skill_id, unsigned int tick) { +int skill_onskillusage(struct map_session_data *sd, struct block_list *bl, uint16 skill_id, int64 tick) { int temp, skill_lv, i, type, notok; struct block_list *tbl; @@ -1667,7 +1667,7 @@ int skill_onskillusage(struct map_session_data *sd, struct block_list *bl, uint1 * 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, int64 tick) { int rate; struct map_session_data *sd=NULL; struct map_session_data *dstsd=NULL; @@ -2109,7 +2109,7 @@ int skill_magic_reflect(struct block_list* src, struct block_list* bl, int type) * flag&0x2000 is used to signal that the skill_lv should be passed as -1 to the * client (causes player characters to not scream skill name) *-------------------------------------------------------------------------*/ -int skill_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 skill_attack(int attack_type, struct block_list* src, struct block_list *dsrc, struct block_list *bl, uint16 skill_id, uint16 skill_lv, int64 tick, int flag) { struct Damage dmg; struct status_data *sstatus, *tstatus; struct status_change *sc; @@ -2357,7 +2357,7 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds break; } //Switch End if (flag) { //Possible to chain - if ( (flag = DIFF_TICK(sd->ud.canact_tick, tick)) < 50 ) flag = 50;/* less is a waste. */ + if ( (flag = DIFF_TICK32(sd->ud.canact_tick, tick)) < 50 ) flag = 50;/* less is a waste. */ sc_start2(src,SC_COMBOATTACK,100,skill_id,bl->id,flag); clif->combo_delay(src, flag); } @@ -2767,21 +2767,21 @@ 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 *------------------------------------------*/ -int skill_area_sub (struct block_list *bl, va_list ap) { +int skill_area_sub(struct block_list *bl, va_list ap) { struct block_list *src; uint16 skill_id,skill_lv; int flag; - unsigned int tick; + int64 tick; SkillFunc func; nullpo_ret(bl); - src=va_arg(ap,struct block_list *); - skill_id=va_arg(ap,int); - skill_lv=va_arg(ap,int); - tick=va_arg(ap,unsigned int); - flag=va_arg(ap,int); - func=va_arg(ap,SkillFunc); + src = va_arg(ap,struct block_list *); + skill_id = va_arg(ap,int); + skill_lv = va_arg(ap,int); + tick = va_arg(ap,int64); + flag = va_arg(ap,int); + func = va_arg(ap,SkillFunc); if(battle->check_target(src,bl,flag) > 0) { // several splash skills need this initial dummy packet to display correctly @@ -3036,14 +3036,14 @@ int skill_check_condition_mercenary(struct block_list *bl, int skill_id, int lv, /*========================================== * what the hell it doesn't need to receive this many params, it doesn't do anything ~_~ *------------------------------------------*/ -int skill_area_sub_count (struct block_list *src, struct block_list *target, uint16 skill_id, uint16 skill_lv, unsigned int tick, int flag) { +int skill_area_sub_count(struct block_list *src, struct block_list *target, uint16 skill_id, uint16 skill_lv, int64 tick, int flag) { return 1; } /*========================================== * *------------------------------------------*/ -int skill_timerskill(int tid, unsigned int tick, int id, intptr_t data) { +int skill_timerskill(int tid, int64 tick, int id, intptr_t data) { struct block_list *src = map->id2bl(id),*target; struct unit_data *ud = unit->bl2ud(src); struct skill_timerskill *skl; @@ -3153,7 +3153,7 @@ int skill_timerskill(int tid, unsigned int tick, int id, intptr_t data) { case WL_TETRAVORTEX_WIND: case WL_TETRAVORTEX_GROUND: clif->skill_nodamage(src, target, skl->skill_id, skl->skill_lv, 1); - skill_attack(BF_MAGIC, src, src, target, skl->skill_id, skl->skill_lv, tick, skl->flag); + skill->attack(BF_MAGIC, src, src, target, skl->skill_id, skl->skill_lv, tick, skl->flag); skill->toggle_magicpower(src, skl->skill_id); // only the first hit will be amplify if( skl->type == 4 ){ const enum sc_type scs[] = { SC_BURNING, SC_BLOODING, SC_FROSTMISTY, SC_STUN }; // status inflicts are depend on what summoned element is used. @@ -3269,8 +3269,7 @@ int skill_timerskill(int tid, unsigned int tick, int id, intptr_t data) { /*========================================== * *------------------------------------------*/ -int skill_addtimerskill (struct block_list *src, unsigned int tick, int target, int x,int y, uint16 skill_id, uint16 skill_lv, int type, int flag) -{ +int skill_addtimerskill(struct block_list *src, int64 tick, int target, int x,int y, uint16 skill_id, uint16 skill_lv, int type, int flag) { int i; struct unit_data *ud; nullpo_retr(1, src); @@ -3334,7 +3333,7 @@ int skill_activate_reverbetion( struct block_list *bl, va_list ap) { return 0; if( su->alive && (sg = su->group) && sg->skill_id == WM_REVERBERATION ) { 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); + su->limit=DIFF_TICK32(timer->gettick(),sg->tick); sg->unit_id = UNT_USED_TRAPS; } return 0; @@ -3355,7 +3354,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, int64 tick, int flag) { struct map_session_data *sd = NULL; struct status_data *tstatus; struct status_change *sc; @@ -4557,8 +4556,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint /*========================================== * *------------------------------------------*/ -int skill_castend_id(int tid, unsigned int tick, int id, intptr_t data) -{ +int skill_castend_id(int tid, int64 tick, int id, intptr_t data) { struct block_list *target, *src; struct map_session_data *sd; struct mob_data *md; @@ -4885,8 +4883,7 @@ int skill_castend_id(int tid, unsigned int tick, int id, intptr_t data) /*========================================== * *------------------------------------------*/ -int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, uint16 skill_id, uint16 skill_lv, unsigned int tick, int flag) -{ +int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uint16 skill_id, uint16 skill_lv, int64 tick, int flag) { struct map_session_data *sd, *dstsd; struct mob_data *md, *dstmd; struct homun_data *hd; @@ -4965,11 +4962,11 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); return 0; } - return skill->castend_damage_id (src, bl, skill_id, skill_lv, tick, flag); + return skill->castend_damage_id(src, bl, skill_id, skill_lv, tick, flag); } break; case NPC_SMOKING: //Since it is a self skill, this one ends here rather than in damage_id. [Skotlex] - return skill->castend_damage_id (src, bl, skill_id, skill_lv, tick, flag); + return skill->castend_damage_id(src, bl, skill_id, skill_lv, tick, flag); case MH_STEINWAND: { struct block_list *s_src = battle->get_master(src); short ret = 0; @@ -7107,8 +7104,8 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case UNT_TALKIEBOX: su->group->unit_id = UNT_USED_TRAPS; clif->changetraplook(bl, UNT_USED_TRAPS); - su->group->limit=DIFF_TICK(tick+1500,su->group->tick); - su->limit=DIFF_TICK(tick+1500,su->group->tick); + su->group->limit=DIFF_TICK32(tick+1500,su->group->tick); + su->limit=DIFF_TICK32(tick+1500,su->group->tick); } } } @@ -9119,7 +9116,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui md->special_state.ai = AI_ZANZOU; 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); + md->deletetimer = timer->add(timer->gettick() + skill->get_time(skill_id, skill_lv), mob->timer_delete, md->bl.id, 0); mob->spawn( md ); pc->setinvincibletimer(sd,500);// unlock target lock clif->skill_nodamage(src,bl,skill_id,skill_lv,1); @@ -9352,7 +9349,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui /*========================================== * *------------------------------------------*/ -int skill_castend_pos(int tid, unsigned int tick, int id, intptr_t data) { +int skill_castend_pos(int tid, int64 tick, int id, intptr_t data) { struct block_list* src = map->id2bl(id); int maxcount; struct map_session_data *sd; @@ -9652,8 +9649,7 @@ int skill_castend_map (struct map_session_data *sd, uint16 skill_id, const char /*========================================== * *------------------------------------------*/ -int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, uint16 skill_lv, unsigned int tick, int flag) -{ +int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, uint16 skill_lv, int64 tick, int flag) { struct map_session_data* sd; struct status_change* sc; struct status_change_entry *sce; @@ -9968,7 +9964,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui md->special_state.ai = (skill_id == AM_SPHEREMINE) ? AI_SPHERE : AI_FLORA; 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); + 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. } } @@ -10066,7 +10062,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui { if( md->deletetimer != INVALID_TIMER ) timer->delete(md->deletetimer, mob->timer_delete); - md->deletetimer = timer->add (tick + i, mob->timer_delete, md->bl.id, 0); + md->deletetimer = timer->add(tick + i, mob->timer_delete, md->bl.id, 0); } mob->spawn (md); } @@ -10197,7 +10193,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui md->special_state.ai = AI_FLORA; 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); + md->deletetimer = timer->add(timer->gettick() + skill->get_time(skill_id, skill_lv), mob->timer_delete, md->bl.id, 0); mob->spawn( md ); } } @@ -10605,7 +10601,7 @@ struct skill_unit_group* skill_unitsetting(struct block_list *src, uint16 skill_ old_sg->skill_id == SA_VIOLENTGALE ) && old_sg->limit > 0) { //Use the previous limit (minus the elapsed time) [Skotlex] - limit = old_sg->limit - DIFF_TICK(timer->gettick(), old_sg->tick); + limit = old_sg->limit - DIFF_TICK32(timer->gettick(), old_sg->tick); if (limit < 0) //This can happen... limit = skill->get_time(skill_id,skill_lv); } @@ -10962,7 +10958,7 @@ struct skill_unit_group* skill_unitsetting(struct block_list *src, uint16 skill_ /*========================================== * *------------------------------------------*/ -int skill_unit_onplace (struct skill_unit *src, struct block_list *bl, unsigned int tick) { +int skill_unit_onplace(struct skill_unit *src, struct block_list *bl, int64 tick) { struct skill_unit_group *sg; struct block_list *ss; struct status_change *sc; @@ -11002,14 +10998,14 @@ int skill_unit_onplace (struct skill_unit *src, struct block_list *bl, unsigned 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); + sec = DIFF_TICK32(td->tick, tick); map->moveblock(bl, src->bl.x, src->bl.y, tick); clif->fixpos(bl); sg->val2 = bl->id; } else sec = 3000; //Couldn't trap it? - sg->limit = DIFF_TICK(tick,sg->tick)+sec; + sg->limit = DIFF_TICK32(tick,sg->tick)+sec; } break; case UNT_SAFETYWALL: @@ -11135,7 +11131,7 @@ int skill_unit_onplace (struct skill_unit *src, struct block_list *bl, unsigned // case UNT_ICEWALL: //Destroy the cell. [Skotlex] // src->val1 = 0; // if(src->limit + sg->tick > tick + 700) - // src->limit = DIFF_TICK(tick+700,sg->tick); + // src->limit = DIFF_TICK32(tick+700,sg->tick); // break; case UNT_MOONLIT: @@ -11173,7 +11169,7 @@ int skill_unit_onplace (struct skill_unit *src, struct block_list *bl, unsigned /*========================================== * *------------------------------------------*/ -int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, unsigned int tick) { +int skill_unit_onplace_timer(struct skill_unit *src, struct block_list *bl, int64 tick) { struct skill_unit_group *sg; struct block_list *ss; TBL_PC* tsd; @@ -11217,7 +11213,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns if ((ts = skill->unitgrouptickset_search(bl,sg,tick))) { //Not all have it, eg: Traps don't have it even though they can be hit by Heaven's Drive [Skotlex] - diff = DIFF_TICK(tick,ts->tick); + diff = DIFF_TICK32(tick,ts->tick); if (diff < 0) return 0; ts->tick = tick+sg->interval; @@ -11317,7 +11313,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns 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); + sg->limit = DIFF_TICK32(tick,sg->tick); break; } } while( x == bl->x && y == bl->y @@ -11360,7 +11356,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns skill->blown(&src->bl,bl,skill->get_blewcount(sg->skill_id,sg->skill_lv),unit->getdir(bl),0); sg->unit_id = UNT_USED_TRAPS; clif->changetraplook(&src->bl, UNT_USED_TRAPS); - sg->limit=DIFF_TICK(tick,sg->tick)+1500; + sg->limit=DIFF_TICK32(tick,sg->tick)+1500; } break; @@ -11371,7 +11367,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns 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); + sec = DIFF_TICK32(td->tick, tick); if( sg->unit_id == UNT_MANHOLE || battle_config.skill_trap_type || !map_flag_gvg2(src->bl.m) ) { unit->movepos(bl, src->bl.x, src->bl.y, 0, 0); clif->fixpos(bl); @@ -11388,7 +11384,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns **/ clif->changetraplook(&src->bl, UNT_ANKLESNARE); } - sg->limit = DIFF_TICK(tick,sg->tick)+sec; + sg->limit = DIFF_TICK32(tick,sg->tick)+sec; sg->interval = -1; src->range = 0; } @@ -11440,7 +11436,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns 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 + + sg->limit=DIFF_TICK32(tick,sg->tick)+1500 + (sg->unit_id== UNT_CLUSTERBOMB || sg->unit_id== UNT_ICEBOUNDTRAP?1000:0);// Cluster Bomb/Icebound has 1s to disappear once activated. sg->unit_id = UNT_USED_TRAPS; //Changed ID so it does not invoke a for each in area again. break; @@ -11452,7 +11448,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns clif->talkiebox(&src->bl, sg->valstr); sg->unit_id = UNT_USED_TRAPS; clif->changetraplook(&src->bl, UNT_USED_TRAPS); - sg->limit = DIFF_TICK(tick, sg->tick) + 5000; + sg->limit = DIFF_TICK32(tick, sg->tick) + 5000; sg->val2 = -1; } break; @@ -11629,7 +11625,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns &src->bl,tick); sg->unit_id = UNT_USED_TRAPS; //clif->changetraplook(&src->bl, UNT_FIREPILLAR_ACTIVE); - sg->limit=DIFF_TICK(tick,sg->tick)+1500; + sg->limit=DIFF_TICK32(tick,sg->tick)+1500; break; /** * 3rd stuff @@ -11682,7 +11678,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); 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->limit = DIFF_TICK32(tick,sg->tick)+1000; sg->unit_id = UNT_USED_TRAPS; break; @@ -11694,7 +11690,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns if( !(status_get_mode(bl)&MD_BOSS) && ss != bl && battle->check_target(&src->bl, bl, BCT_PARTY) > 0 ) { if( !(tsc && tsc->data[type]) ){ sc_start(bl, type, 100, sg->skill_lv, skill->get_time2(sg->skill_id,sg->skill_lv)); - sg->limit = DIFF_TICK(tick,sg->tick); + sg->limit = DIFF_TICK32(tick,sg->tick); sg->unit_id = UNT_USED_TRAPS; } } @@ -11706,13 +11702,13 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns if( sc_start(bl, type, 100, sg->skill_lv, sec) ) { const struct TimerData* td = tsc->data[type]?timer->get(tsc->data[type]->timer):NULL; if( td ) - sec = DIFF_TICK(td->tick, tick); + sec = DIFF_TICK32(td->tick, tick); ///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 sec = 3000; // Couldn't trap it? - sg->limit = DIFF_TICK(tick, sg->tick) + sec; + sg->limit = DIFF_TICK32(tick, sg->tick) + sec; } else if( tsc->data[SC_THORNS_TRAP] && bl->id == sg->val2 ) skill->attack(skill->get_type(GN_THORNS_TRAP), ss, ss, bl, sg->skill_id, sg->skill_lv, tick, SD_LEVEL|SD_ANIMATION); } @@ -11750,7 +11746,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns if( battle->check_target(&src->bl,bl,BCT_ENEMY) > 0 ) skill->attack(skill->get_type(GN_HELLS_PLANT_ATK), ss, &src->bl, bl, GN_HELLS_PLANT_ATK, sg->skill_lv, tick, 0); if( ss != bl) //The caster is the only one who can step on the Plants, without destroying them - sg->limit = DIFF_TICK(tick, sg->tick) + 100; + sg->limit = DIFF_TICK32(tick, sg->tick) + 100; break; case UNT_CLOUD_KILL: @@ -11800,7 +11796,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns case UNT_VACUUM_EXTREME: {// TODO: official behavior in gvg area. [malufett] - int sec = sg->limit - DIFF_TICK(tick, sg->tick); + int sec = sg->limit - DIFF_TICK32(tick, sg->tick); int range = skill->get_unit_range(sg->skill_id, sg->skill_lv); if( tsc && !tsc->data[type] && @@ -11863,7 +11859,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns case UNT_LAVA_SLIDE: skill->attack(BF_WEAPON, ss, &src->bl, bl, sg->skill_id, sg->skill_lv, tick, 0); if(++sg->val1 > 4) //after 5 stop hit and destroy me - sg->limit = DIFF_TICK(tick, sg->tick); + sg->limit = DIFF_TICK32(tick, sg->tick); break; case UNT_POISON_MIST: @@ -11880,7 +11876,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns /*========================================== * Triggered when a char steps out of a skill cell *------------------------------------------*/ -int skill_unit_onout (struct skill_unit *src, struct block_list *bl, unsigned int tick) { +int skill_unit_onout(struct skill_unit *src, struct block_list *bl, int64 tick) { struct skill_unit_group *sg; struct status_change *sc; struct status_change_entry *sce; @@ -11923,7 +11919,7 @@ int skill_unit_onout (struct skill_unit *src, struct block_list *bl, unsigned in 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; + sg->limit = DIFF_TICK32(tick,sg->tick)+1000; } } break; @@ -11934,7 +11930,7 @@ 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] *------------------------------------------*/ -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, int64 tick) { struct status_change *sc; struct status_change_entry *sce; enum sc_type type; @@ -12040,10 +12036,10 @@ int skill_unit_onleft (uint16 skill_id, struct block_list *bl, unsigned int tick * flag&1: Invoke onplace function (otherwise invoke onout) * flag&4: Invoke a onleft call (the unit might be scheduled for deletion) *------------------------------------------*/ -int skill_unit_effect (struct block_list* bl, va_list ap) { +int skill_unit_effect(struct block_list* bl, va_list ap) { struct skill_unit* su = va_arg(ap,struct skill_unit*); struct skill_unit_group* group = su->group; - unsigned int tick = va_arg(ap,unsigned int); + int64 tick = va_arg(ap,int64); unsigned int flag = va_arg(ap,unsigned int); uint16 skill_id; bool dissonance; @@ -12079,8 +12075,7 @@ int skill_unit_effect (struct block_list* bl, va_list ap) { /*========================================== * *------------------------------------------*/ -int skill_unit_ondamaged (struct skill_unit *src, struct block_list *bl, int64 damage, unsigned int tick) -{ +int skill_unit_ondamaged(struct skill_unit *src, struct block_list *bl, int64 damage, int64 tick) { struct skill_unit_group *sg; nullpo_ret(src); @@ -14187,8 +14182,7 @@ 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) -{ +void skill_brandishspear(struct block_list* src, struct block_list* bl, uint16 skill_id, uint16 skill_lv, int64 tick, int flag) { int c,n=4; uint8 dir = map->calc_dir(src,bl->x,bl->y); struct square tc; @@ -14525,10 +14519,10 @@ int skill_sit (struct map_session_data *sd, int type) /*========================================== * *------------------------------------------*/ -int skill_frostjoke_scream (struct block_list *bl, va_list ap) { +int skill_frostjoke_scream(struct block_list *bl, va_list ap) { struct block_list *src; uint16 skill_id,skill_lv; - unsigned int tick; + int64 tick; nullpo_ret(bl); nullpo_ret(src=va_arg(ap,struct block_list*)); @@ -14536,7 +14530,7 @@ int skill_frostjoke_scream (struct block_list *bl, va_list ap) { skill_id=va_arg(ap,int); skill_lv=va_arg(ap,int); if(!skill_lv) return 0; - tick=va_arg(ap,unsigned int); + tick=va_arg(ap,int64); if (src == bl || status->isdead(bl)) return 0; @@ -14569,22 +14563,22 @@ 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; + int64 tick; if(status->isdead(bl)) return 0; atk_type = va_arg(ap,int); - src=va_arg(ap,struct block_list*); - dsrc=va_arg(ap,struct block_list*); - skill_id=va_arg(ap,int); - skill_lv=va_arg(ap,int); - tick=va_arg(ap,unsigned int); - flag=va_arg(ap,int); - type=va_arg(ap,int); + src = va_arg(ap,struct block_list*); + dsrc = va_arg(ap,struct block_list*); + skill_id = va_arg(ap,int); + skill_lv = va_arg(ap,int); + tick = va_arg(ap,int64); + flag = va_arg(ap,int); + 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. @@ -14739,7 +14733,7 @@ int skill_detonator(struct block_list *bl, va_list ap) { 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) + + su->group->limit = DIFF_TICK32(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)) ); su->group->unit_id = UNT_USED_TRAPS; break; @@ -14876,15 +14870,15 @@ int skill_chastle_mob_changetarget(struct block_list *bl,va_list ap) /*========================================== * *------------------------------------------*/ -int skill_trap_splash (struct block_list *bl, va_list ap) { +int skill_trap_splash(struct block_list *bl, va_list ap) { struct block_list *src; - int tick; + int64 tick; struct skill_unit *su; struct skill_unit_group *sg; struct block_list *ss; src = va_arg(ap,struct block_list *); su = (struct skill_unit *)src; - tick = va_arg(ap,int); + tick = va_arg(ap,int64); if( !su->alive || bl->prev == NULL ) return 0; @@ -14962,7 +14956,7 @@ int skill_trap_splash (struct block_list *bl, va_list ap) { case UNT_FIRINGTRAP: case UNT_ICEBOUNDTRAP: clif->changetraplook(bl, UNT_USED_TRAPS); - su->group->limit = DIFF_TICK(timer->gettick(),su->group->tick) + 1500; + su->group->limit = DIFF_TICK32(timer->gettick(),su->group->tick) + 1500; su->group->unit_id = UNT_USED_TRAPS; } break; @@ -15288,11 +15282,11 @@ struct skill_unit_group* skill_initunitgroup (struct block_list* src, int count, if(i == MAX_SKILLUNITGROUP) { // array is full, make room by discarding oldest group int j=0; - unsigned maxdiff=0,x,tick=timer->gettick(); + int64 maxdiff = 0, x, tick = timer->gettick(); for(i=0;i<MAX_SKILLUNITGROUP && ud->skillunit[i];i++) - if((x=DIFF_TICK(tick,ud->skillunit[i]->tick))>maxdiff){ - maxdiff=x; - j=i; + if( (x=DIFF_TICK(tick,ud->skillunit[i]->tick)) > maxdiff ) { + maxdiff = x; + j = i; } skill->del_unitgroup(ud->skillunit[j],ALC_MARK); //Since elements must have shifted, we use the last slot. @@ -15479,7 +15473,7 @@ int skill_clear_unitgroup (struct block_list *src) /*========================================== * *------------------------------------------*/ -struct skill_unit_group_tickset *skill_unitgrouptickset_search (struct block_list *bl, struct skill_unit_group *group, int tick) { +struct skill_unit_group_tickset *skill_unitgrouptickset_search(struct block_list *bl, struct skill_unit_group *group, int64 tick) { int i,j=-1,k,s,id; struct unit_data *ud; struct skill_unit_group_tickset *set; @@ -15519,10 +15513,10 @@ struct skill_unit_group_tickset *skill_unitgrouptickset_search (struct block_lis /*========================================== * *------------------------------------------*/ -int skill_unit_timer_sub_onplace (struct block_list* bl, va_list ap) { +int skill_unit_timer_sub_onplace(struct block_list* bl, va_list ap) { struct skill_unit* su = va_arg(ap,struct skill_unit *); struct skill_unit_group* group = su->group; - unsigned int tick = va_arg(ap,unsigned int); + int64 tick = va_arg(ap,int64); if( !su->alive || bl->prev == NULL ) return 0; @@ -15546,7 +15540,7 @@ int skill_unit_timer_sub_onplace (struct block_list* bl, va_list ap) { int skill_unit_timer_sub(DBKey key, DBData *data, va_list ap) { struct skill_unit* su = DB->data2ptr(data); struct skill_unit_group* group = su->group; - unsigned int tick = va_arg(ap,unsigned int); + int64 tick = va_arg(ap,int64); bool dissonance; struct block_list* bl = &su->bl; @@ -15570,8 +15564,8 @@ int skill_unit_timer_sub(DBKey key, DBData *data, va_list ap) { case UNT_GROUNDDRIFT_FIRE: group->unit_id = UNT_USED_TRAPS; //clif->changetraplook(bl, UNT_FIREPILLAR_ACTIVE); - group->limit=DIFF_TICK(tick+1500,group->tick); - su->limit=DIFF_TICK(tick+1500,group->tick); + group->limit=DIFF_TICK32(tick+1500,group->tick); + su->limit=DIFF_TICK32(tick+1500,group->tick); break; case UNT_ANKLESNARE: @@ -15650,8 +15644,8 @@ int skill_unit_timer_sub(DBKey key, DBData *data, va_list ap) { } clif->changetraplook(bl,UNT_USED_TRAPS); 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->limit = DIFF_TICK32(tick,group->tick)+1000; + su->limit = DIFF_TICK32(tick,group->tick)+1000; group->unit_id = UNT_USED_TRAPS; break; @@ -15672,8 +15666,8 @@ int skill_unit_timer_sub(DBKey key, DBData *data, va_list ap) { break; } // This unit isn't removed while SC_BANDING is active. - group->limit = DIFF_TICK(tick+group->interval,group->tick); - su->limit = DIFF_TICK(tick+group->interval,group->tick); + group->limit = DIFF_TICK32(tick+group->interval,group->tick); + su->limit = DIFF_TICK32(tick+group->interval,group->tick); } break; @@ -15686,7 +15680,7 @@ int skill_unit_timer_sub(DBKey key, DBData *data, va_list ap) { // icewall loses 50 hp every second su->val1 -= SKILLUNITTIMER_INTERVAL/20; // trap's hp if( su->val1 <= 0 && su->limit + group->tick > tick + 700 ) - su->limit = DIFF_TICK(tick+700,group->tick); + su->limit = DIFF_TICK32(tick+700,group->tick); break; case UNT_BLASTMINE: case UNT_SKIDTRAP: @@ -15703,7 +15697,7 @@ int skill_unit_timer_sub(DBKey key, DBData *data, va_list ap) { skill->delunit(su); else { clif->changetraplook(bl, group->unit_id==UNT_LANDMINE?UNT_FIREPILLAR_ACTIVE:UNT_USED_TRAPS); - group->limit = DIFF_TICK(tick, group->tick) + 1500; + group->limit = DIFF_TICK32(tick, group->tick) + 1500; group->unit_id = UNT_USED_TRAPS; } } @@ -15712,15 +15706,15 @@ int skill_unit_timer_sub(DBKey key, DBData *data, va_list ap) { if( su->val1 <= 0 ) { clif->changetraplook(bl,UNT_USED_TRAPS); 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->limit = DIFF_TICK32(tick,group->tick)+1000; + su->limit = DIFF_TICK32(tick,group->tick)+1000; group->unit_id = UNT_USED_TRAPS; } break; case UNT_WALLOFTHORN: if( su->val1 <= 0 ) { group->unit_id = UNT_USED_TRAPS; - group->limit = DIFF_TICK(tick, group->tick) + 1500; + group->limit = DIFF_TICK32(tick, group->tick) + 1500; } break; } @@ -15757,7 +15751,7 @@ 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) { +int skill_unit_timer(int tid, int64 tick, int id, intptr_t data) { map->freeblock_lock(); skill->unit_db->foreach(skill->unit_db, skill->unit_timer_sub, tick); @@ -15770,12 +15764,12 @@ int skill_unit_timer(int tid, unsigned int tick, int id, intptr_t data) { /*========================================== * *------------------------------------------*/ -int skill_unit_move_sub (struct block_list* bl, va_list ap) { +int skill_unit_move_sub(struct block_list* bl, va_list ap) { struct skill_unit* su = (struct skill_unit *)bl; struct skill_unit_group* group = su->group; struct block_list* target = va_arg(ap,struct block_list*); - unsigned int tick = va_arg(ap,unsigned int); + int64 tick = va_arg(ap,int64); int flag = va_arg(ap,int); bool dissonance; @@ -15867,7 +15861,7 @@ int skill_unit_move_sub (struct block_list* bl, va_list ap) { * units to figure out when they have left a group. * flag&4: Force a onleft event (triggered when the bl is killed, for example) *------------------------------------------*/ -int skill_unit_move (struct block_list *bl, unsigned int tick, int flag) { +int skill_unit_move(struct block_list *bl, int64 tick, int flag) { nullpo_ret(bl); if( bl->prev == NULL ) @@ -15892,10 +15886,9 @@ int skill_unit_move (struct block_list *bl, unsigned int tick, int flag) { /*========================================== * *------------------------------------------*/ -int skill_unit_move_unit_group (struct skill_unit_group *group, int16 m, int16 dx, int16 dy) -{ +int skill_unit_move_unit_group(struct skill_unit_group *group, int16 m, int16 dx, int16 dy) { int i,j; - unsigned int tick = timer->gettick(); + int64 tick = timer->gettick(); int *m_flag; struct skill_unit *su1; struct skill_unit *su2; @@ -16749,7 +16742,7 @@ int skill_magicdecoy(struct map_session_data *sd, int nameid) { md->special_state.ai = AI_FLORA; if( md->deletetimer != INVALID_TIMER ) timer->delete(md->deletetimer, mob->timer_delete); - md->deletetimer = timer->add (timer->gettick() + skill->get_time(NC_MAGICDECOY,skill_id), mob->timer_delete, md->bl.id, 0); + md->deletetimer = timer->add(timer->gettick() + skill->get_time(NC_MAGICDECOY,skill_id), mob->timer_delete, md->bl.id, 0); mob->spawn(md); md->status.matk_min = md->status.matk_max = 250 + (50 * skill_id); } @@ -16947,13 +16940,13 @@ int skill_changematerial(struct map_session_data *sd, int n, unsigned short *ite /** * for Royal Guard's LG_TRAMPLE **/ -int skill_destroy_trap( struct block_list *bl, va_list ap ) { +int skill_destroy_trap(struct block_list *bl, va_list ap) { struct skill_unit *su = (struct skill_unit *)bl; struct skill_unit_group *sg; - unsigned int tick; + int64 tick; nullpo_ret(su); - tick = va_arg(ap, unsigned int); + tick = va_arg(ap, int64); if (su->alive && (sg = su->group) && skill->get_inf2(sg->skill_id)&INF2_TRAP) { switch( sg->unit_id ) { @@ -16980,7 +16973,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) { +int skill_blockpc_end(int tid, int64 tick, int id, intptr_t data) { struct map_session_data *sd = map->id2sd(id); struct skill_cd * cd = NULL; @@ -17035,7 +17028,7 @@ int skill_blockpc_end(int tid, unsigned int tick, int id, intptr_t data) { int skill_blockpc_start_(struct map_session_data *sd, uint16 skill_id, int tick) { struct skill_cd* cd = NULL; uint16 idx = skill->get_index(skill_id); - unsigned int now = timer->gettick(); + int64 now = timer->gettick(); nullpo_retr (-1, sd); @@ -17099,7 +17092,7 @@ int skill_blockpc_start_(struct map_session_data *sd, uint16 skill_id, int tick) return 0; } -int skill_blockhomun_end(int tid, unsigned int tick, int id, intptr_t data) { //[orn] +int skill_blockhomun_end(int tid, int64 tick, int id, intptr_t data) { //[orn] struct homun_data *hd = (TBL_HOM*)map->id2bl(id); if (data <= 0 || data >= MAX_SKILL) return 0; @@ -17124,7 +17117,7 @@ int skill_blockhomun_start(struct homun_data *hd, uint16 skill_id, int tick) { / return timer->add(timer->gettick() + tick, skill->blockhomun_end, hd->bl.id, idx); } -int skill_blockmerc_end(int tid, unsigned int tick, int id, intptr_t data) {//[orn] +int skill_blockmerc_end(int tid, int64 tick, int id, intptr_t data) {//[orn] struct mercenary_data *md = (TBL_MER*)map->id2bl(id); if( data <= 0 || data >= MAX_SKILL ) return 0; @@ -17592,7 +17585,7 @@ int skill_get_elemental_type( uint16 skill_id , uint16 skill_lv ) { void skill_cooldown_save(struct map_session_data * sd) { int i; struct skill_cd* cd = NULL; - unsigned int now = 0; + int64 now = 0; // always check to make sure the session properly exists nullpo_retv(sd); @@ -17605,7 +17598,7 @@ void skill_cooldown_save(struct map_session_data * sd) { // process each individual cooldown associated with the character for( i = 0; i < cd->cursor; i++ ) { - cd->entry[i]->duration = DIFF_TICK(cd->entry[i]->started+cd->entry[i]->duration,now); + cd->entry[i]->duration = DIFF_TICK32(cd->entry[i]->started+cd->entry[i]->duration,now); if( cd->entry[i]->timer != INVALID_TIMER ) { timer->delete(cd->entry[i]->timer,skill->blockpc_end); cd->entry[i]->timer = INVALID_TIMER; @@ -17620,7 +17613,7 @@ void skill_cooldown_save(struct map_session_data * sd) { void skill_cooldown_load(struct map_session_data * sd) { int i; struct skill_cd* cd = NULL; - unsigned int now = 0; + int64 now = 0; // always check to make sure the session properly exists nullpo_retv(sd); diff --git a/src/map/skill.h b/src/map/skill.h index c968eebde..fca4952ef 100644 --- a/src/map/skill.h +++ b/src/map/skill.h @@ -1686,7 +1686,7 @@ struct skill_unit_group { int map; int target_flag; //Holds BCT_* flag for battle_check_target int bl_flag; //Holds BL_* flag for map_foreachin* functions - unsigned int tick; + int64 tick; int limit,interval; uint16 skill_id,skill_lv; @@ -1715,7 +1715,7 @@ struct skill_unit { }; struct skill_unit_group_tickset { - unsigned int tick; + int64 tick; int id; }; @@ -1750,7 +1750,7 @@ struct skill_cd_entry { int total;/* used for display on newer clients */ #endif short skidx;//the skill index entries belong to - unsigned int started;/* gettick() of when it started, used vs duration to measure how much left upon logout */ + int64 started;/* gettick() of when it started, used vs duration to measure how much left upon logout */ int timer;/* timer id */ uint16 skill_id;//skill id }; @@ -1791,7 +1791,7 @@ struct s_skill_spellbook_db { int point; }; -typedef int (*SkillFunc)(struct block_list *src, struct block_list *target, uint16 skill_id, uint16 skill_lv, unsigned int tick, int flag); +typedef int (*SkillFunc)(struct block_list *src, struct block_list *target, uint16 skill_id, uint16 skill_lv, int64 tick, int flag); /** * Skill.c Interface @@ -1883,13 +1883,13 @@ struct skill_interface { int (*get_casttype2) (uint16 index); int (*name2id) (const char* name); int (*isammotype) (struct map_session_data *sd, int skill); - int (*castend_id) (int tid, unsigned int tick, int id, intptr_t data); - int (*castend_pos) (int tid, unsigned int tick, int id, intptr_t data); + int (*castend_id) (int tid, int64 tick, int id, intptr_t data); + int (*castend_pos) (int tid, int64 tick, int id, intptr_t data); int (*castend_map) ( struct map_session_data *sd,uint16 skill_id, const char *mapname); int (*cleartimerskill) (struct block_list *src); - int (*addtimerskill) (struct block_list *src,unsigned int tick,int target,int x,int y,uint16 skill_id,uint16 skill_lv,int type,int flag); - int (*additional_effect) ( struct block_list* src, struct block_list *bl,uint16 skill_id,uint16 skill_lv,int attack_type,int dmg_lv,unsigned int tick); - int (*counter_additional_effect) ( struct block_list* src, struct block_list *bl,uint16 skill_id,uint16 skill_lv,int attack_type,unsigned int tick); + int (*addtimerskill) (struct block_list *src, int64 tick, int target, int x, int y, uint16 skill_id, uint16 skill_lv, int type, int flag); + int (*additional_effect) (struct block_list* src, struct block_list *bl, uint16 skill_id, uint16 skill_lv, int attack_type, int dmg_lv, int64 tick); + int (*counter_additional_effect) (struct block_list* src, struct block_list *bl, uint16 skill_id, uint16 skill_lv, int attack_type, int64 tick); int (*blown) (struct block_list* src, struct block_list* target, int count, int8 dir, int flag); int (*break_equip) (struct block_list *bl, unsigned short where, int rate, int flag); int (*strip_equip) (struct block_list *bl, unsigned short where, int rate, int lv, int time); @@ -1901,8 +1901,8 @@ struct skill_interface { int (*del_unitgroup) (struct skill_unit_group *group, const char* file, int line, const char* func); int (*clear_unitgroup) (struct block_list *src); int (*clear_group) (struct block_list *bl, int flag); - int (*unit_onplace) (struct skill_unit *src, struct block_list *bl, unsigned int tick); - int (*unit_ondamaged) (struct skill_unit *src,struct block_list *bl,int64 damage,unsigned int tick); + int (*unit_onplace) (struct skill_unit *src, struct block_list *bl, int64 tick); + int (*unit_ondamaged) (struct skill_unit *src, struct block_list *bl, int64 damage, int64 tick); int (*cast_fix) ( struct block_list *bl, uint16 skill_id, uint16 skill_lv); int (*cast_fix_sc) ( struct block_list *bl, int time); int (*vf_cast_fix) ( struct block_list *bl, double time, uint16 skill_id, uint16 skill_lv); @@ -1912,12 +1912,12 @@ struct skill_interface { int (*consume_requirement) (struct map_session_data *sd, uint16 skill_id, uint16 skill_lv, short type); struct skill_condition (*get_requirement) (struct map_session_data *sd, uint16 skill_id, uint16 skill_lv); int (*check_pc_partner) (struct map_session_data *sd, uint16 skill_id, uint16* skill_lv, int range, int cast_flag); - int (*unit_move) (struct block_list *bl,unsigned int tick,int flag); - int (*unit_onleft) (uint16 skill_id, struct block_list *bl,unsigned int tick); - int (*unit_onout) (struct skill_unit *src, struct block_list *bl, unsigned int tick); + int (*unit_move) (struct block_list *bl, int64 tick, int flag); + int (*unit_onleft) (uint16 skill_id, struct block_list *bl, int64 tick); + int (*unit_onout) (struct skill_unit *src, struct block_list *bl, int64 tick); int (*unit_move_unit_group) ( struct skill_unit_group *group, int16 m,int16 dx,int16 dy); int (*sit) (struct map_session_data *sd, int type); - void (*brandishspear) (struct block_list* src, struct block_list* bl, uint16 skill_id, uint16 skill_lv, unsigned int tick, int flag); + void (*brandishspear) (struct block_list* src, struct block_list* bl, uint16 skill_id, uint16 skill_lv, int64 tick, int flag); void (*repairweapon) (struct map_session_data *sd, int idx); void (*identify) (struct map_session_data *sd,int idx); void (*weaponrefine) (struct map_session_data *sd,int idx); @@ -1932,25 +1932,25 @@ struct skill_interface { int (*can_produce_mix) ( struct map_session_data *sd, int nameid, int trigger, int qty); int (*produce_mix) ( struct map_session_data *sd, uint16 skill_id, int nameid, int slot1, int slot2, int slot3, int qty ); int (*arrow_create) ( struct map_session_data *sd,int nameid); - 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 (*castend_nodamage_id) (struct block_list *src, struct block_list *bl, uint16 skill_id, uint16 skill_lv, int64 tick, int flag); + int (*castend_damage_id) (struct block_list* src, struct block_list *bl, uint16 skill_id, uint16 skill_lv, int64 tick,int flag); + int (*castend_pos2) (struct block_list *src, int x, int y, uint16 skill_id, uint16 skill_lv, int64 tick, int flag); int (*blockpc_start) (struct map_session_data *sd, uint16 skill_id, int tick); 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) (int attack_type, struct block_list* src, struct block_list *dsrc, struct block_list *bl, uint16 skill_id, uint16 skill_lv, int64 tick, int flag); int (*attack_area) (struct block_list *bl,va_list ap); int (*area_sub) (struct block_list *bl, va_list ap); - int (*area_sub_count) (struct block_list *src, struct block_list *target, uint16 skill_id, uint16 skill_lv, unsigned int tick, int flag); + int (*area_sub_count) (struct block_list *src, struct block_list *target, uint16 skill_id, uint16 skill_lv, int64 tick, int flag); int (*check_unit_range) (struct block_list *bl, int x, int y, uint16 skill_id, uint16 skill_lv); int (*check_unit_range_sub) (struct block_list *bl, va_list ap); int (*check_unit_range2) (struct block_list *bl, int x, int y, uint16 skill_id, uint16 skill_lv); int (*check_unit_range2_sub) (struct block_list *bl, va_list ap); void (*toggle_magicpower) (struct block_list *bl, uint16 skill_id); int (*magic_reflect) (struct block_list* src, struct block_list* bl, int type); - int (*onskillusage) (struct map_session_data *sd, struct block_list *bl, uint16 skill_id, unsigned int tick); + int (*onskillusage) (struct map_session_data *sd, struct block_list *bl, uint16 skill_id, int64 tick); int (*cell_overlap) (struct block_list *bl, va_list ap); - int (*timerskill) (int tid, unsigned int tick, int id, intptr_t data); + int (*timerskill) (int tid, int64 tick, int id, intptr_t data); int (*trap_splash) (struct block_list *bl, va_list ap); int (*check_condition_mercenary) (struct block_list *bl, int skill_id, int lv, int type); struct skill_unit_group *(*locate_element_field) (struct block_list *bl); @@ -1963,26 +1963,26 @@ struct skill_interface { int (*greed) (struct block_list *bl, va_list ap); int (*destroy_trap) ( struct block_list *bl, va_list ap ); int (*icewall_block) (struct block_list *bl,va_list ap); - struct skill_unit_group_tickset *(*unitgrouptickset_search) (struct block_list *bl, struct skill_unit_group *group, int tick); + struct skill_unit_group_tickset *(*unitgrouptickset_search) (struct block_list *bl, struct skill_unit_group *group, int64 tick); bool (*dance_switch) (struct skill_unit* su, int flag); int (*check_condition_char_sub) (struct block_list *bl, va_list ap); int (*check_condition_mob_master_sub) (struct block_list *bl, va_list ap); void (*brandishspear_first) (struct square *tc, uint8 dir, int16 x, int16 y); void (*brandishspear_dir) (struct square* tc, uint8 dir, int are); - int (*get_fixed_cast) ( uint16 skill_id ,uint16 skill_lv ); + int (*get_fixed_cast) ( uint16 skill_id ,uint16 skill_lv ); int (*sit_count) (struct block_list *bl, va_list ap); int (*sit_in) (struct block_list *bl, va_list ap); int (*sit_out) (struct block_list *bl, va_list ap); void (*unitsetmapcell) (struct skill_unit *src, uint16 skill_id, uint16 skill_lv, cell_t cell, bool flag); - int (*unit_onplace_timer) (struct skill_unit *src, struct block_list *bl, unsigned int tick); + int (*unit_onplace_timer) (struct skill_unit *src, struct block_list *bl, int64 tick); int (*unit_effect) (struct block_list* bl, va_list ap); int (*unit_timer_sub_onplace) (struct block_list* bl, va_list ap); int (*unit_move_sub) (struct block_list* bl, va_list ap); - int (*blockpc_end) (int tid, unsigned int tick, int id, intptr_t data); - int (*blockhomun_end) (int tid, unsigned int tick, int id, intptr_t data); - int (*blockmerc_end) (int tid, unsigned int tick, int id, intptr_t data); + int (*blockpc_end) (int tid, int64 tick, int id, intptr_t data); + int (*blockhomun_end) (int tid, int64 tick, int id, intptr_t data); + int (*blockmerc_end) (int tid, int64 tick, int id, intptr_t data); int (*split_atoi) (char *str, int *val); - int (*unit_timer) (int tid, unsigned int tick, int id, intptr_t data); + int (*unit_timer) (int tid, int64 tick, int id, intptr_t data); int (*unit_timer_sub) (DBKey key, DBData *data, va_list ap); void (*init_unit_layout) (void); bool (*parse_row_skilldb) (char* split[], int columns, int current); diff --git a/src/map/status.c b/src/map/status.c index 5f6444971..fc032686e 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -7806,7 +7806,13 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val val2 = 11-val1; //Chance to consume: 11-skill_lv% break; case SC_RUN: - val4 = timer->gettick(); //Store time at which you started running. + { + //Store time at which you started running. + int64 currenttick = timer->gettick(); + // Note: this int64 value is stored in two separate int32 variables (FIXME) + val3 = (int)(currenttick&0x00000000ffffffff); + val4 = (int)((currenttick&0xffffffff00000000)>>32); + } tick = -1; break; case SC_KAAHI: @@ -8189,7 +8195,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_WUGDASH: - val4 = timer->gettick(); //Store time at which you started running. + { + //Store time at which you started running. + int64 currenttick = timer->gettick(); + // Note: this int64 value is stored in two separate int32 variables (FIXME) + val3 = (int)(currenttick&0x00000000ffffffff); + val4 = (int)((currenttick&0xffffffff00000000)>>32); + } tick = -1; break; case SC__SHADOWFORM: { @@ -9315,6 +9327,10 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const { struct unit_data *ud = unit->bl2ud(bl); bool begin_spurt = true; + // Note: this int64 value is stored in two separate int32 variables (FIXME) + int64 starttick = (int64)sce->val3&0x00000000ffffffff; + starttick |= ((int64)sce->val4<<32)&0xffffffff00000000; + if (ud) { if(!ud->state.running) begin_spurt = false; @@ -9323,7 +9339,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const unit->stop_walking(bl,1); } if (begin_spurt && sce->val1 >= 7 - && DIFF_TICK(timer->gettick(), sce->val4) <= 1000 + && DIFF_TICK(timer->gettick(), starttick) <= 1000 && (!sd || (sd->weapontype1 == 0 && sd->weapontype2 == 0)) ) sc_start(bl,SC_STRUP,100,sce->val1,skill->get_time2(status->sc2skill(type), sce->val1)); @@ -9932,7 +9948,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const return 1; } -int kaahi_heal_timer(int tid, unsigned int tick, int id, intptr_t data) { +int kaahi_heal_timer(int tid, int64 tick, int id, intptr_t data) { struct block_list *bl; struct status_change *sc; struct status_change_entry *sce; @@ -9970,7 +9986,7 @@ int kaahi_heal_timer(int tid, unsigned int tick, int id, intptr_t data) { * For recusive status, like for each 5s we drop sp etc. * Reseting the end timer. *------------------------------------------*/ -int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) { +int status_change_timer(int tid, int64 tick, int id, intptr_t data) { enum sc_type type = (sc_type)data; struct block_list *bl; struct map_session_data *sd; @@ -10786,7 +10802,7 @@ int status_change_timer_sub(struct block_list* bl, va_list ap) { struct block_list* src = va_arg(ap,struct block_list*); struct status_change_entry* sce = va_arg(ap,struct status_change_entry*); 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); + int64 tick = va_arg(ap, int64); if (status->isdead(bl)) return 0; @@ -11040,7 +11056,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 = status->get_sc(src); - unsigned int tick; + int64 tick; struct status_change_data data; if( !sc || !sc->count ) @@ -11082,7 +11098,7 @@ int status_change_spread( struct block_list *src, struct block_list *bl ) { const struct TimerData *td = timer->get(sc->data[i]->timer); if (td == NULL || td->func != status->change_timer || DIFF_TICK(td->tick,tick) < 0) continue; - data.tick = DIFF_TICK(td->tick,tick); + data.tick = DIFF_TICK32(td->tick,tick); } else data.tick = INVALID_TIMER; break; @@ -11310,8 +11326,9 @@ int status_natural_heal(struct block_list* bl, va_list args) { } //Natural heal main timer. -int status_natural_heal_timer(int tid, unsigned int tick, int id, intptr_t data) { - status->natural_heal_diff_tick = DIFF_TICK(tick,status->natural_heal_prev_tick); +int status_natural_heal_timer(int tid, int64 tick, int id, intptr_t data) { + // This difference is always positive and lower than UINT_MAX (~24 days) + status->natural_heal_diff_tick = (unsigned int)cap_value(DIFF_TICK(tick,status->natural_heal_prev_tick), 0, UINT_MAX); map->foreachregen(status->natural_heal); status->natural_heal_prev_tick = tick; return 0; diff --git a/src/map/status.h b/src/map/status.h index 9b1721d1a..9edf29d2c 100644 --- a/src/map/status.h +++ b/src/map/status.h @@ -1858,7 +1858,8 @@ struct status_interface { sc_conf_type sc_conf[SC_MAX]; struct eri *data_ers; //For sc_data entries struct status_data dummy; - unsigned int natural_heal_prev_tick,natural_heal_diff_tick; + int64 natural_heal_prev_tick; + unsigned int natural_heal_diff_tick; /* */ int (*init) (void); void (*final) (void); @@ -1902,8 +1903,8 @@ struct status_interface { int (*get_sc_def) (struct block_list *bl, enum sc_type type, int rate, int tick, int flag); int (*change_start) (struct block_list* bl,enum sc_type type,int rate,int val1,int val2,int val3,int val4,int tick,int flag); int (*change_end_) (struct block_list* bl, enum sc_type type, int tid, const char* file, int line); - int (*kaahi_heal_timer) (int tid, unsigned int tick, int id, intptr_t data); - int (*change_timer) (int tid, unsigned int tick, int id, intptr_t data); + int (*kaahi_heal_timer) (int tid, int64 tick, int id, intptr_t data); + int (*change_timer) (int tid, int64 tick, int id, intptr_t data); int (*change_timer_sub) (struct block_list* bl, va_list ap); int (*change_clear) (struct block_list* bl, int type); int (*change_clear_buffs) (struct block_list* bl, int type); @@ -1967,7 +1968,7 @@ struct status_interface { void (*display_add) (struct map_session_data *sd, enum sc_type type, int dval1, int dval2, int dval3); void (*display_remove) (struct map_session_data *sd, enum sc_type type); int (*natural_heal) (struct block_list *bl, va_list args); - int (*natural_heal_timer) (int tid, unsigned int tick, int id, intptr_t data); + int (*natural_heal_timer) (int tid, int64 tick, int id, intptr_t data); bool (*readdb_job1) (char *fields[], int columns, int current); bool (*readdb_job2) (char *fields[], int columns, int current); bool (*readdb_sizefix) (char *fields[], int columns, int current); diff --git a/src/map/unit.c b/src/map/unit.c index a9cbd605e..7b4ac2c50 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -82,9 +82,6 @@ struct unit_data* unit_bl2ud2(struct block_list *bl) { return unit->bl2ud(bl); } -int unit_attack_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 unit_walktoxy_sub(struct block_list *bl) { int i; @@ -137,7 +134,7 @@ int unit_walktoxy_sub(struct block_list *bl) return 1; } -int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data) { +int unit_walktoxy_timer(int tid, int64 tick, int id, intptr_t data) { int i; int x,y,dx,dy; uint8 dir; @@ -322,7 +319,7 @@ int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data) { return 0; } -int unit_delay_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data) { +int unit_delay_walktoxy_timer(int tid, int64 tick, int id, intptr_t data) { struct block_list *bl = map->id2bl(id); if (!bl || bl->prev == NULL) @@ -402,7 +399,7 @@ 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) { +int unit_walktobl_sub(int tid, int64 tick, int id, intptr_t data) { struct block_list *bl = map->id2bl(id); struct unit_data *ud = bl?unit->bl2ud(bl):NULL; @@ -854,7 +851,7 @@ int unit_stop_walking(struct block_list *bl,int type) { struct unit_data *ud; const struct TimerData* td; - unsigned int tick; + int64 tick; nullpo_ret(bl); ud = unit->bl2ud(bl); @@ -1001,7 +998,7 @@ 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, int64 tick, int id, intptr_t data) { struct unit_data *ud = (struct unit_data *)data; TBL_PC * sd = map->id2sd(id); @@ -1025,8 +1022,7 @@ int unit_resume_running(int tid, unsigned int tick, int id, intptr_t data) { * if type is 0, this is a damage induced delay: if previous delay is active, do not change it. * if type is 1, this is a skill induced delay: walk-delay may only be increased, not decreased. *------------------------------------------*/ -int unit_set_walkdelay(struct block_list *bl, unsigned int tick, int delay, int type) -{ +int unit_set_walkdelay(struct block_list *bl, int64 tick, int delay, int type) { struct unit_data *ud = unit->bl2ud(bl); if (delay <= 0 || !ud) return 0; @@ -1073,7 +1069,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui struct status_change *sc; struct map_session_data *sd = NULL; struct block_list * target = NULL; - unsigned int tick = timer->gettick(); + int64 tick = timer->gettick(); int temp = 0, range; nullpo_ret(src); @@ -1437,7 +1433,7 @@ int unit_skilluse_pos2( struct block_list *src, short skill_x, short skill_y, ui struct unit_data *ud = NULL; struct status_change *sc; struct block_list bl; - unsigned int tick = timer->gettick(); + int64 tick = timer->gettick(); int range; nullpo_ret(src); @@ -1795,8 +1791,7 @@ int unit_calc_pos(struct block_list *bl, int tx, int ty, uint8 dir) /*========================================== * Continuous Attack (function timer) *------------------------------------------*/ -int unit_attack_timer_sub(struct block_list* src, int tid, unsigned int tick) -{ +int unit_attack_timer_sub(struct block_list* src, int tid, int64 tick) { struct block_list *target; struct unit_data *ud; struct status_data *sstatus; @@ -1923,7 +1918,7 @@ 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, int64 tick, int id, intptr_t data) { struct block_list *bl; bl = map->id2bl(id); if(bl && unit->attack_timer_sub(bl, tid, tick) == 0) @@ -1940,7 +1935,7 @@ int unit_skillcastcancel(struct block_list *bl,int type) { struct map_session_data *sd = NULL; struct unit_data *ud = unit->bl2ud( bl); - unsigned int tick=timer->gettick(); + int64 tick = timer->gettick(); int ret=0, skill_id; nullpo_ret(bl); @@ -2021,8 +2016,7 @@ int unit_counttargeted(struct block_list* bl) /*========================================== * *------------------------------------------*/ -int unit_fixdamage(struct block_list *src,struct block_list *target,unsigned int tick,int sdelay,int ddelay,int64 damage,int div,int type,int64 damage2) -{ +int unit_fixdamage(struct block_list *src, struct block_list *target, int64 tick, int sdelay, int ddelay, int64 damage, int div, int type, int64 damage2) { nullpo_ret(target); if(damage+damage2 <= 0) diff --git a/src/map/unit.h b/src/map/unit.h index be7b789d9..0567688a1 100644 --- a/src/map/unit.h +++ b/src/map/unit.h @@ -30,10 +30,10 @@ struct unit_data { int target_to; int attacktimer; int walktimer; - int chaserange; - unsigned int attackabletime; - unsigned int canact_tick; - unsigned int canmove_tick; + int chaserange; + int64 attackabletime; + int64 canact_tick; + int64 canmove_tick; uint8 dir; unsigned char walk_count; unsigned char target_count; @@ -77,12 +77,12 @@ struct unit_interface { /* */ struct unit_data* (*bl2ud) (struct block_list *bl); struct unit_data* (*bl2ud2) (struct block_list *bl); - int (*attack_timer) (int tid, unsigned int tick, int id, intptr_t data); - int (*walktoxy_timer) (int tid, unsigned int tick, int id, intptr_t data); + int (*attack_timer) (int tid, int64 tick, int id, intptr_t data); + int (*walktoxy_timer) (int tid, int64 tick, int id, intptr_t data); int (*walktoxy_sub) (struct block_list *bl); - int (*delay_walktoxy_timer) (int tid, unsigned int tick, int id, intptr_t data); + int (*delay_walktoxy_timer) (int tid, int64 tick, int id, intptr_t data); int (*walktoxy) (struct block_list *bl, short x, short y, int flag); - int (*walktobl_sub) (int tid, unsigned int tick, int id, intptr_t data); + int (*walktobl_sub) (int tid, int64 tick, int id, intptr_t data); int (*walktobl) (struct block_list *bl, struct block_list *tbl, int range, int flag); int (*run) (struct block_list *bl); int (*wugdash) (struct block_list *bl, struct map_session_data *sd); @@ -96,8 +96,8 @@ struct unit_interface { int (*skilluse_id) (struct block_list *src, int target_id, uint16 skill_id, uint16 skill_lv); int (*is_walking) (struct block_list *bl); int (*can_move) (struct block_list *bl); - int (*resume_running) (int tid, unsigned int tick, int id, intptr_t data); - int (*set_walkdelay) (struct block_list *bl, unsigned int tick, int delay, int type); + int (*resume_running) (int tid, int64 tick, int id, intptr_t data); + int (*set_walkdelay) (struct block_list *bl, int64 tick, int delay, int type); int (*skilluse_id2) (struct block_list *src, int target_id, uint16 skill_id, uint16 skill_lv, int casttime, int castcancel); int (*skilluse_pos) (struct block_list *src, short skill_x, short skill_y, uint16 skill_id, uint16 skill_lv); int (*skilluse_pos2) (struct block_list *src, short skill_x, short skill_y, uint16 skill_id, uint16 skill_lv, int casttime, int castcancel); @@ -109,11 +109,11 @@ struct unit_interface { bool (*can_reach_pos) (struct block_list *bl, int x, int y, int easy); bool (*can_reach_bl) (struct block_list *bl, struct block_list *tbl, int range, int easy, short *x, short *y); int (*calc_pos) (struct block_list *bl, int tx, int ty, uint8 dir); - int (*attack_timer_sub) (struct block_list *src, int tid, unsigned int tick); + int (*attack_timer_sub) (struct block_list *src, int tid, int64 tick); int (*skillcastcancel) (struct block_list *bl, int type); void (*dataset) (struct block_list *bl); int (*counttargeted) (struct block_list *bl); - int (*fixdamage) (struct block_list *src, struct block_list *target, unsigned int tick, int sdelay, int ddelay, int64 damage, int div, int type, int64 damage2); + int (*fixdamage) (struct block_list *src, struct block_list *target, int64 tick, int sdelay, int ddelay, int64 damage, int div, int type, int64 damage2); int (*changeviewsize) (struct block_list *bl, short size); int (*remove_map) (struct block_list *bl, clr_type clrtype, const char *file, int line, const char *func); void (*remove_map_pc) (struct map_session_data *sd, clr_type clrtype); -- cgit v1.2.3-70-g09d2 From 97001710c06ed7053d18c8baaac602eb563b64b3 Mon Sep 17 00:00:00 2001 From: Haru <haru@dotalux.com> Date: Tue, 27 Aug 2013 08:08:34 +0200 Subject: Introducing the Hercules Standalone Script Syntax Checker - Added a command line argument '--script-check' to check a script's syntax without running the server (and without requiring a SQL connection). Usage: ./map-server --script-check /path/to/the/script.txt - For convenience, a script-checker bash script is provided, to set the path correctly when called from a different directory. Usage: /path/to/Hercules/script-checker /path/to/the/script/to/check.txt - While the script checker will supposedly work under windows as well, no convenience scripts are currently provided for platforms other than UNIX (feel free to open a pull request with a .bat launcher or whatever you like) - Integration with IDEs or text editors is possible. In fact, I already have a fully functional plugin for vim (through vim-syntastic), and if there's enough interest, I'll publish it. - screenshot: http://d.pr/i/NOBD - If you want an online checker, http://haru.ws/scriptchecker/ is running this code, without modifications and will be kept up to date (without any warranty though.) - Special thanks to Ind, Yommy, Streusel, who helped making this possible, in a way or another. --- script-checker | 18 ++++++ src/common/core.c | 14 ++++- src/common/mapindex.c | 17 +++-- src/common/mapindex.h | 3 +- src/map/atcommand.c | 5 +- src/map/atcommand.h | 2 +- src/map/battle.c | 5 +- src/map/battle.h | 2 +- src/map/battleground.c | 5 +- src/map/battleground.h | 2 +- src/map/chrif.c | 6 +- src/map/chrif.h | 2 +- src/map/clif.c | 5 +- src/map/clif.h | 2 +- src/map/duel.c | 5 +- src/map/duel.h | 2 +- src/map/elemental.c | 5 +- src/map/elemental.h | 2 +- src/map/guild.c | 15 +++-- src/map/guild.h | 2 +- src/map/homunculus.c | 6 +- src/map/homunculus.h | 2 +- src/map/instance.c | 5 +- src/map/instance.h | 2 +- src/map/irc-bot.c | 5 +- src/map/irc-bot.h | 2 +- src/map/itemdb.c | 15 +++-- src/map/itemdb.h | 4 +- src/map/map.c | 168 +++++++++++++++++++++++++++++-------------------- src/map/map.h | 2 +- src/map/mercenary.c | 5 +- src/map/mercenary.h | 2 +- src/map/mob.c | 20 ++++-- src/map/mob.h | 4 +- src/map/npc.c | 69 ++++++++++---------- src/map/npc.h | 4 +- src/map/party.c | 5 +- src/map/party.h | 2 +- src/map/pc.c | 4 +- src/map/pc.h | 2 +- src/map/pet.c | 6 +- src/map/pet.h | 2 +- src/map/quest.c | 5 +- src/map/quest.h | 2 +- src/map/script.c | 72 +++++++++++++++------ src/map/script.h | 2 +- src/map/skill.c | 15 +++-- src/map/skill.h | 4 +- src/map/status.c | 5 +- src/map/status.h | 2 +- src/map/storage.c | 4 +- src/map/storage.h | 2 +- src/map/unit.c | 5 +- src/map/unit.h | 2 +- src/map/vending.c | 2 +- src/map/vending.h | 2 +- 56 files changed, 382 insertions(+), 197 deletions(-) create mode 100755 script-checker (limited to 'src/map/elemental.c') diff --git a/script-checker b/script-checker new file mode 100755 index 000000000..ec79fcc61 --- /dev/null +++ b/script-checker @@ -0,0 +1,18 @@ +#!/bin/bash + +ORIG_CWD="$(pwd)" +BASEDIR="$(dirname "$0")" +EXECUTABLE="./map-server" + +cd "${BASEDIR}" +if [ -z "$1" ]; then + exit -1 +elif [[ "$1" =~ ^\/ ]]; then + FILE="$1" +else + FILE="${ORIG_CWD}/$1" +fi +if [ ! -x "$EXECUTABLE" ]; then + exit -1 +fi +"$EXECUTABLE" --script-check "${FILE}" 2>&1 diff --git a/src/common/core.c b/src/common/core.c index 6a73d2d39..f57cc4c79 100644 --- a/src/common/core.c +++ b/src/common/core.c @@ -302,10 +302,20 @@ int main (int argc, char **argv) { arg_v = argv; } core_defaults(); + + { + int i; + for(i = 0; i < argc; i++) { + if( strcmp(argv[i], "--script-check") == 0 ) { + msg_silent = 0x7; // silence information and status messages + } + } + } iMalloc->init();// needed for Show* in display_title() [FlavioJS] - - console->display_title(); + + if (!(msg_silent&0x1)) + console->display_title(); #ifdef MINICORE // minimalist Core usercheck(); diff --git a/src/common/mapindex.c b/src/common/mapindex.c index 83de21b2b..a95e143c3 100644 --- a/src/common/mapindex.c +++ b/src/common/mapindex.c @@ -21,7 +21,12 @@ int max_index = 0; char mapindex_cfgfile[80] = "db/map_index.txt"; -#define mapindex_exists(id) (indexes[id].name[0] != '\0') +#define mapindex_exists_sub(id) (indexes[id].name[0] != '\0') + +bool mapindex_exists(int id) { + return mapindex_exists_sub(id); +} + /// Retrieves the map name from 'string' (removing .gat extension if present). /// Result gets placed either into 'buf' or in a static local buffer. const char* mapindex_getmapname(const char* string, char* output) { @@ -102,7 +107,7 @@ int mapindex_addmap(int index, const char* name) { return 0; } - if (mapindex_exists(index)) { + if (mapindex_exists_sub(index)) { ShowWarning("(mapindex_add) Overriding index %d: map \"%s\" -> \"%s\"\n", index, indexes[index].name, map_name); strdb_remove(mapindex_db, indexes[index].name); } @@ -129,18 +134,18 @@ unsigned short mapindex_name2id(const char* name) { } const char* mapindex_id2name_sub(unsigned short id,const char *file, int line, const char *func) { - if (id > MAX_MAPINDEX || !mapindex_exists(id)) { + if (id > MAX_MAPINDEX || !mapindex_exists_sub(id)) { ShowDebug("mapindex_id2name: Requested name for non-existant map index [%d] in cache. %s:%s:%d\n", id,file,func,line); return indexes[0].name; // dummy empty string so that the callee doesn't crash } return indexes[id].name; } -void mapindex_init(void) { +int mapindex_init(void) { FILE *fp; char line[1024]; int last_index = -1; - int index; + int index, total = 0; char map_name[12]; if( ( fp = fopen(mapindex_cfgfile,"r") ) == NULL ){ @@ -158,6 +163,7 @@ void mapindex_init(void) { index = last_index+1; case 2: //Map with ID given mapindex_addmap(index,map_name); + total++; break; default: continue; @@ -169,6 +175,7 @@ void mapindex_init(void) { if( !strdb_iget(mapindex_db, MAP_DEFAULT) ) { ShowError("mapindex_init: MAP_DEFAULT '%s' not found in cache! update mapindex.h MAP_DEFAULT var!!!\n",MAP_DEFAULT); } + return total; } int mapindex_removemap(int index){ diff --git a/src/common/mapindex.h b/src/common/mapindex.h index 43953a8e0..646f73f18 100644 --- a/src/common/mapindex.h +++ b/src/common/mapindex.h @@ -56,12 +56,13 @@ extern char mapindex_cfgfile[80]; #define MAP_MALAYA "malaya" #define MAP_ECLAGE "eclage" +bool mapindex_exists(int id); const char* mapindex_getmapname(const char* string, char* output); const char* mapindex_getmapname_ext(const char* string, char* output); unsigned short mapindex_name2id(const char*); #define mapindex_id2name(n) mapindex_id2name_sub(n,__FILE__, __LINE__, __func__) const char* mapindex_id2name_sub(unsigned short,const char *file, int line, const char *func); -void mapindex_init(void); +int mapindex_init(void); void mapindex_final(void); int mapindex_addmap(int index, const char* name); diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 0ba977ff4..b11a4f4c0 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -10149,7 +10149,10 @@ void atcommand_doload(void) { atcommand->config_read(map->ATCOMMAND_CONF_FILENAME); } -void do_init_atcommand(void) { +void do_init_atcommand(bool minimal) { + if (minimal) + return; + atcommand->at_symbol = '@'; atcommand->char_symbol = '#'; atcommand->binding_count = 0; diff --git a/src/map/atcommand.h b/src/map/atcommand.h index 63c38e4d1..74ab30bed 100644 --- a/src/map/atcommand.h +++ b/src/map/atcommand.h @@ -77,7 +77,7 @@ struct atcommand_interface { /* */ char* msg_table[MAX_MSG]; // Server messages (0-499 reserved for GM commands, 500-999 reserved for others) /* */ - void (*init) (void); + void (*init) (bool minimal); void (*final) (void); /* */ bool (*parse) (const int fd, struct map_session_data* sd, const char* message, int type); diff --git a/src/map/battle.c b/src/map/battle.c index 94222f663..c090c5623 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -6759,7 +6759,10 @@ int battle_config_read(const char* cfgName) return 0; } -void do_init_battle(void) { +void do_init_battle(bool minimal) { + if (minimal) + return; + 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"); diff --git a/src/map/battle.h b/src/map/battle.h index bf08ab8d6..0f3a22c4b 100644 --- a/src/map/battle.h +++ b/src/map/battle.h @@ -506,7 +506,7 @@ struct battle_interface { int attr_fix_table[4][ELE_MAX][ELE_MAX]; struct eri *delay_damage_ers; //For battle delay damage structures. /* init */ - void (*init) (void); + void (*init) (bool minimal); /* final */ void (*final) (void); /* damage calculation */ diff --git a/src/map/battleground.c b/src/map/battleground.c index 62688659e..76cf22471 100644 --- a/src/map/battleground.c +++ b/src/map/battleground.c @@ -757,7 +757,10 @@ enum BATTLEGROUNDS_QUEUE_ACK bg_canqueue(struct map_session_data *sd, struct bg_ return BGQA_SUCCESS; } -void do_init_battleground(void) { +void do_init_battleground(bool minimal) { + if (minimal) + return; + bg->team_db = idb_alloc(DB_OPT_RELEASE_DATA); timer->add_func_list(bg->send_xy_timer, "bg_send_xy_timer"); timer->add_interval(timer->gettick() + battle_config.bg_update_interval, bg->send_xy_timer, 0, 0, battle_config.bg_update_interval); diff --git a/src/map/battleground.h b/src/map/battleground.h index a5e540924..fab614d08 100644 --- a/src/map/battleground.h +++ b/src/map/battleground.h @@ -75,7 +75,7 @@ struct battleground_interface { DBMap *team_db; // int bg_id -> struct battleground_data* unsigned int team_counter; // Next bg_id /* */ - void (*init) (void); + void (*init) (bool minimal); void (*final) (void); /* */ struct bg_arena *(*name2arena) (char *name); diff --git a/src/map/chrif.c b/src/map/chrif.c index a13217060..87ec71ec5 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -1611,8 +1611,10 @@ int do_final_chrif(void) { /*========================================== * *------------------------------------------*/ -int do_init_chrif(void) { - +int do_init_chrif(bool minimal) { + if (minimal) + return 0; + 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); diff --git a/src/map/chrif.h b/src/map/chrif.h index 9df4b9931..56aa569a3 100644 --- a/src/map/chrif.h +++ b/src/map/chrif.h @@ -63,7 +63,7 @@ struct chrif_interface { int state; /* */ int (*final) (void); - int (*init) (void); + int (*init) (bool minimal); /* funcs */ void (*setuserid) (char* id); void (*setpasswd) (char* pwd); diff --git a/src/map/clif.c b/src/map/clif.c index c1e7cb1c9..5f88557fd 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -18046,10 +18046,13 @@ void clif_bc_ready(void) { /*========================================== * *------------------------------------------*/ -int do_init_clif(void) { +int do_init_clif(bool minimal) { const char* colors[COLOR_MAX] = { "0xFF0000", "0x00ff00", "0xffffff" }; int i; + if (minimal) + return 0; + /** * Setup Color Table (saves unnecessary load of strtoul on every call) **/ diff --git a/src/map/clif.h b/src/map/clif.h index cbe3fa857..1710cfc88 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -526,7 +526,7 @@ struct clif_interface { /* */ bool ally_only; /* core */ - int (*init) (void); + int (*init) (bool minimal); void (*final) (void); int (*setip) (const char* ip); void (*setbindip) (const char* ip); diff --git a/src/map/duel.c b/src/map/duel.c index 4e41865d4..5e305244a 100644 --- a/src/map/duel.c +++ b/src/map/duel.c @@ -166,7 +166,10 @@ void duel_reject(const unsigned int did, struct map_session_data* sd) { void do_final_duel(void) { } -void do_init_duel(void) { +void do_init_duel(bool minimal) { + if (minimal) + return; + memset(&duel->list[0], 0, sizeof(duel->list)); } diff --git a/src/map/duel.h b/src/map/duel.h index d1ec58415..d60c9531a 100644 --- a/src/map/duel.h +++ b/src/map/duel.h @@ -34,7 +34,7 @@ struct duel_interface { void (*showinfo) (const unsigned int did, struct map_session_data* sd); int (*checktime) (struct map_session_data* sd); - void (*init) (void); + void (*init) (bool minimal); void (*final) (void); } duel_s; diff --git a/src/map/elemental.c b/src/map/elemental.c index f15b735b2..2581d1839 100644 --- a/src/map/elemental.c +++ b/src/map/elemental.c @@ -931,7 +931,10 @@ void reload_elemental_skilldb(void) { elemental->read_skilldb(); } -int do_init_elemental(void) { +int do_init_elemental(bool minimal) { + if (minimal) + return 0; + elemental->read_db(); elemental->read_skilldb(); diff --git a/src/map/elemental.h b/src/map/elemental.h index 3cd819d53..8ffffa5e3 100644 --- a/src/map/elemental.h +++ b/src/map/elemental.h @@ -73,7 +73,7 @@ struct elemental_interface { struct s_elemental_db db[MAX_ELEMENTAL_CLASS]; // Elemental Database /* */ - int (*init) (void); + int (*init) (bool minimal); void (*final) (void); /* funcs */ bool (*class) (int class_); diff --git a/src/map/guild.c b/src/map/guild.c index 0ae45bede..908c38341 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -2172,12 +2172,15 @@ void guild_flags_clear(void) { guild->flags_count = 0; } -void do_init_guild(void) { - 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); +void do_init_guild(bool minimal) { + if (minimal) + return; + + 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); diff --git a/src/map/guild.h b/src/map/guild.h index 348a6c7e4..8da9036e6 100644 --- a/src/map/guild.h +++ b/src/map/guild.h @@ -56,7 +56,7 @@ struct s_guild_skill_tree { struct guild_interface { - void (*init) (void); + void (*init) (bool minimal); void (*final) (void); /* */ DBMap* db; // int guild_id -> struct guild* diff --git a/src/map/homunculus.c b/src/map/homunculus.c index 52f0572c0..cb54d2d8b 100644 --- a/src/map/homunculus.c +++ b/src/map/homunculus.c @@ -1229,8 +1229,12 @@ void homunculus_skill_reload(void) { homun->skill_db_read(); } -void do_init_homunculus(void) { +void do_init_homunculus(bool minimal) { int class_; + + if (minimal) + return; + homun->read_db(); homun->exp_db_read(); homun->skill_db_read(); diff --git a/src/map/homunculus.h b/src/map/homunculus.h index e3ec38f7b..bf1de6171 100644 --- a/src/map/homunculus.h +++ b/src/map/homunculus.h @@ -91,7 +91,7 @@ struct homunculus_interface { struct s_homunculus_db db[MAX_HOMUNCULUS_CLASS]; struct homun_skill_tree_entry skill_tree[MAX_HOMUNCULUS_CLASS][MAX_SKILL_TREE]; /* */ - void (*init) (void); + void (*init) (bool minimal); void (*final) (void); void (*reload) (void); void (*reload_skill) (void); diff --git a/src/map/instance.c b/src/map/instance.c index 6b96c3112..ab68c9e22 100644 --- a/src/map/instance.c +++ b/src/map/instance.c @@ -691,7 +691,10 @@ void do_final_instance(void) { instance->instances = 0; } -void do_init_instance(void) { +void do_init_instance(bool minimal) { + if (minimal) + return; + timer->add_func_list(instance->destroy_timer, "instance_destroy_timer"); } diff --git a/src/map/instance.h b/src/map/instance.h index 27a9401b4..4f65d7db0 100644 --- a/src/map/instance.h +++ b/src/map/instance.h @@ -47,7 +47,7 @@ struct instance_data { }; struct instance_interface { - void (*init) (void); + void (*init) (bool minimal); void (*final) (void); void (*reload) (void); /* start point */ diff --git a/src/map/irc-bot.c b/src/map/irc-bot.c index f67446629..0f487d8f7 100644 --- a/src/map/irc-bot.c +++ b/src/map/irc-bot.c @@ -386,7 +386,7 @@ void irc_relay(char *name, const char *msg) { /** * IRC bot initializer */ -void irc_bot_init(void) { +void irc_bot_init(bool minimal) { /// Command handlers const struct irc_func irc_func_base[] = { { "PING" , ircbot->pong }, @@ -399,6 +399,9 @@ void irc_bot_init(void) { struct irc_func* function; int i; + if (minimal) + return; + if( !hChSys.irc ) return; diff --git a/src/map/irc-bot.h b/src/map/irc-bot.h index 52ff0c9be..305cdfd91 100644 --- a/src/map/irc-bot.h +++ b/src/map/irc-bot.h @@ -34,7 +34,7 @@ struct irc_bot_interface { unsigned int size; } funcs; /* */ - void (*init) (void); + void (*init) (bool minimal); void (*final) (void); /* */ int (*parse) (int fd); diff --git a/src/map/itemdb.c b/src/map/itemdb.c index 3fc8d526b..e29b74cd4 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -1927,7 +1927,7 @@ int itemdb_uid_load() { /*==================================== * read all item-related databases *------------------------------------*/ -void itemdb_read(void) { +void itemdb_read(bool minimal) { int i; DBData prev; @@ -1945,6 +1945,9 @@ void itemdb_read(void) { } } + if (minimal) + return; + itemdb->read_combos(); itemdb->read_groups(); itemdb->read_chains(); @@ -2065,7 +2068,7 @@ void itemdb_reload(void) { db_clear(itemdb->names); // read new data - itemdb->read(); + itemdb->read(false); //Epoque's awesome @reloaditemdb fix - thanks! [Ind] //- Fixes the need of a @reloadmobdb after a @reloaditemdb to re-link monster drop data @@ -2174,12 +2177,16 @@ void do_final_itemdb(void) { db_destroy(itemdb->names); } -void do_init_itemdb(void) { +void do_init_itemdb(bool minimal) { memset(itemdb->array, 0, sizeof(itemdb->array)); itemdb->other = idb_alloc(DB_OPT_BASE); itemdb->names = strdb_alloc(DB_OPT_BASE,ITEM_NAME_LENGTH); itemdb->create_dummy_data(); //Dummy data item. - itemdb->read(); + itemdb->read(minimal); + + if (minimal) + return; + clif->cashshop_load(); } void itemdb_defaults(void) { diff --git a/src/map/itemdb.h b/src/map/itemdb.h index 2579d84ca..80d2fd0ce 100644 --- a/src/map/itemdb.h +++ b/src/map/itemdb.h @@ -266,7 +266,7 @@ struct item_package { #define itemdb_canauction(item, gmlv) itemdb->isrestricted(item , gmlv, 0, itemdb->canauction_sub) struct itemdb_interface { - void (*init) (void); + void (*init) (bool minimal); void (*final) (void); void (*reload) (void); void (*name_constants) (void); @@ -343,7 +343,7 @@ struct itemdb_interface { int (*read_sqldb) (void); uint64 (*unique_id) (int8 flag, int64 value); int (*uid_load) (); - void (*read) (void); + void (*read) (bool minimal); void (*destroy_item_data) (struct item_data *self, int free_self); int (*final_sub) (DBKey key, DBData *data, va_list ap); }; diff --git a/src/map/map.c b/src/map/map.c index 781cc0ff9..cd192b7d4 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -2905,7 +2905,7 @@ int map_readfromcache(struct map_data *m, char *buffer) { } -int map_addmap(char* mapname) { +int map_addmap(const char* mapname) { map->list[map->count].instance_id = -1; mapindex_getmapname(mapname, map->list[map->count++].name); return 0; @@ -5419,6 +5419,8 @@ void map_load_defaults(void) { } int do_init(int argc, char *argv[]) { + bool minimal = false; + char *scriptcheck = NULL; int i; #ifdef GCOLLECT @@ -5468,6 +5470,11 @@ int do_init(int argc, char *argv[]) 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 if( strcmp(arg, "script-check") == 0 ) { + minimal = true; + runflag = CORE_ST_STOP; + if( map->arg_next_value(arg, i, argc) ) + scriptcheck = argv[++i]; } else { ShowError("Unknown option '%s'.\n", argv[i]); exit(EXIT_FAILURE); @@ -5489,39 +5496,42 @@ int do_init(int argc, char *argv[]) } map_load_defaults(); - map->config_read(map->MAP_CONF_NAME); - CREATE(map->list,struct map_data,map->count); - map->count = 0; - map->config_read_sub(map->MAP_CONF_NAME); - // loads npcs - map->reloadnpc(false); + if (!minimal) { + map->config_read(map->MAP_CONF_NAME); + CREATE(map->list,struct map_data,map->count); + map->count = 0; + map->config_read_sub(map->MAP_CONF_NAME); - chrif->checkdefaultlogin(); + // loads npcs + map->reloadnpc(false); - if (!map->ip_set || !map->char_ip_set) { - char ip_str[16]; - ip2str(addr_[0], ip_str); + chrif->checkdefaultlogin(); - ShowWarning("Not all IP addresses in /conf/map-server.conf configured, autodetecting...\n"); + if (!map->ip_set || !map->char_ip_set) { + char ip_str[16]; + ip2str(addr_[0], ip_str); - if (naddr_ == 0) - ShowError("Unable to determine your IP address...\n"); - else if (naddr_ > 1) - ShowNotice("Multiple interfaces detected...\n"); + ShowWarning("Not all IP addresses in /conf/map-server.conf configured, autodetecting...\n"); - ShowInfo("Defaulting to %s as our IP address\n", ip_str); + if (naddr_ == 0) + ShowError("Unable to determine your IP address...\n"); + else if (naddr_ > 1) + ShowNotice("Multiple interfaces detected...\n"); - if (!map->ip_set) - clif->setip(ip_str); - if (!map->char_ip_set) - chrif->setip(ip_str); - } + ShowInfo("Defaulting to %s as our IP address\n", ip_str); - battle->config_read(map->BATTLE_CONF_FILENAME); - atcommand->msg_read(map->MSG_CONF_NAME); + if (!map->ip_set) + clif->setip(ip_str); + if (!map->char_ip_set) + chrif->setip(ip_str); + } + + battle->config_read(map->BATTLE_CONF_FILENAME); + atcommand->msg_read(map->MSG_CONF_NAME); + map->inter_config_read(map->INTER_CONF_NAME); + logs->config_read(map->LOG_CONF_NAME); + } script->config_read(map->SCRIPT_CONF_NAME); - map->inter_config_read(map->INTER_CONF_NAME); - logs->config_read(map->LOG_CONF_NAME); map->id_db = idb_alloc(DB_OPT_BASE); map->pc_db = idb_alloc(DB_OPT_BASE); //Added for reliable map->id2sd() use. [Skotlex] @@ -5538,53 +5548,77 @@ int do_init(int argc, char *argv[]) map->flooritem_ers = ers_new(sizeof(struct flooritem_data),"map.c::map_flooritem_ers",ERS_OPT_NONE); ers_chunk_size(map->flooritem_ers, 100); - - map->sql_init(); - if (logs->config.sql_logs) - logs->sql_init(); - mapindex_init(); + if (!minimal) { + map->sql_init(); + if (logs->config.sql_logs) + logs->sql_init(); + } + + i = mapindex_init(); + + if (minimal) { + // Pretend all maps from the mapindex are on this mapserver + CREATE(map->list,struct map_data,i); + + for( i = 0; i < MAX_MAPINDEX; i++ ) { + if (mapindex_exists(i)) { + map->addmap(mapindex_id2name(i)); + } + } + } + if(map->enable_grf) grfio_init(map->GRF_PATH_FILENAME); map->readallmaps(); - timer->add_func_list(map->freeblock_timer, "map_freeblock_timer"); - timer->add_func_list(map->clearflooritem_timer, "map_clearflooritem_timer"); - timer->add_func_list(map->removemobs_timer, "map_removemobs_timer"); - timer->add_interval(timer->gettick()+1000, map->freeblock_timer, 0, 0, 60*1000); - - HPM->load_sub = HPM_map_plugin_load_sub; - HPM->symbol_defaults_sub = map_hp_symbols; - HPM->config_read(); - HPM->event(HPET_INIT); - - atcommand->init(); - battle->init(); - instance->init(); - chrif->init(); - clif->init(); - ircbot->init(); - script->init(); - itemdb->init(); - skill->init(); - map->read_zone_db();/* read after item and skill initalization */ - mob->init(); - pc->init(); - status->init(); - party->init(); - guild->init(); - gstorage->init(); - pet->init(); - homun->init(); - mercenary->init(); - elemental->init(); - quest->init(); - npc->init(); - unit->init(); - bg->init(); - duel->init(); - vending->init(); + + if (!minimal) { + timer->add_func_list(map->freeblock_timer, "map_freeblock_timer"); + timer->add_func_list(map->clearflooritem_timer, "map_clearflooritem_timer"); + timer->add_func_list(map->removemobs_timer, "map_removemobs_timer"); + timer->add_interval(timer->gettick()+1000, map->freeblock_timer, 0, 0, 60*1000); + + HPM->load_sub = HPM_map_plugin_load_sub; + HPM->symbol_defaults_sub = map_hp_symbols; + HPM->config_read(); + HPM->event(HPET_INIT); + } + + atcommand->init(minimal); + battle->init(minimal); + instance->init(minimal); + chrif->init(minimal); + clif->init(minimal); + ircbot->init(minimal); + script->init(minimal); + itemdb->init(minimal); + skill->init(minimal); + if (!minimal) + map->read_zone_db();/* read after item and skill initalization */ + mob->init(minimal); + pc->init(minimal); + status->init(minimal); + party->init(minimal); + guild->init(minimal); + gstorage->init(minimal); + pet->init(minimal); + homun->init(minimal); + mercenary->init(minimal); + elemental->init(minimal); + quest->init(minimal); + npc->init(minimal); + unit->init(minimal); + bg->init(minimal); + duel->init(minimal); + vending->init(minimal); + + if (minimal) { + if (npc->parsesrcfile(scriptcheck, false) == 0) + exit(EXIT_SUCCESS); + exit(EXIT_FAILURE); + } npc->event_do_oninit(); // Init npcs (OnInit) diff --git a/src/map/map.h b/src/map/map.h index 6b7d2a630..31ee0ef60 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -1020,7 +1020,7 @@ struct map_interface { int (*eraseallipport_sub) (DBKey key, DBData *data, va_list va); char* (*init_mapcache) (FILE *fp); int (*readfromcache) (struct map_data *m, char *buffer); - int (*addmap) (char *mapname); + int (*addmap) (const char *mapname); void (*delmapid) (int id); void (*zone_db_clear) (void); void (*list_final) (void); diff --git a/src/map/mercenary.c b/src/map/mercenary.c index 8c74a5e1e..a38b37b1e 100644 --- a/src/map/mercenary.c +++ b/src/map/mercenary.c @@ -490,7 +490,10 @@ int read_mercenary_skilldb(void) { return 0; } -void do_init_mercenary(void) { +void do_init_mercenary(bool minimal) { + if (minimal) + return; + mercenary->read_db(); mercenary->read_skilldb(); diff --git a/src/map/mercenary.h b/src/map/mercenary.h index 3245606cf..3f2214b65 100644 --- a/src/map/mercenary.h +++ b/src/map/mercenary.h @@ -59,7 +59,7 @@ struct mercenary_interface { /* funcs */ - void (*init) (void); + void (*init) (bool minimal); bool (*class) (int class_); struct view_data * (*get_viewdata) (int class_); diff --git a/src/map/mob.c b/src/map/mob.c index 97f8ea6c1..c5a79dffe 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -4534,7 +4534,12 @@ bool mob_readdb_itemratio(char* str[], int columns, int current) /** * read all mob-related databases */ -void mob_load(void) { +void mob_load(bool minimal) { + if (minimal) { + // Only read the mob db in minimal mode + mob->readdb(); + return; + } 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 (map->db_use_sql_mob_db) { @@ -4569,7 +4574,7 @@ void mob_reload(void) { } } - mob->load(); + mob->load(false); } void mob_clear_spawninfo() @@ -4583,15 +4588,18 @@ void mob_clear_spawninfo() /*========================================== * Circumference initialization of mob *------------------------------------------*/ -int do_init_mob(void) -{ //Initialize the mob database +int do_init_mob(bool minimal) { + // Initialize the mob database memset(mob->db_data,0,sizeof(mob->db_data)); //Clear the array - mob->db_data[0] = (struct mob_db*)aCalloc(1, sizeof (struct mob_db)); //This mob is used for random spawns + mob->db_data[0] = (struct mob_db*)aCalloc(1, sizeof (struct mob_db)); //This mob is used for random spawns mob->makedummymobdb(0); //The first time this is invoked, it creates the dummy mob item_drop_ers = ers_new(sizeof(struct item_drop),"mob.c::item_drop_ers",ERS_OPT_NONE); item_drop_list_ers = ers_new(sizeof(struct item_drop_list),"mob.c::item_drop_list_ers",ERS_OPT_NONE); - mob->load(); + mob->load(minimal); + + if (minimal) + return 0; timer->add_func_list(mob->delayspawn,"mob_delayspawn"); timer->add_func_list(mob->delay_item_drop,"mob_delay_item_drop"); diff --git a/src/map/mob.h b/src/map/mob.h index 2f425e285..31a8666a2 100644 --- a/src/map/mob.h +++ b/src/map/mob.h @@ -259,7 +259,7 @@ struct mob_interface { int manuk[8]; int splendide[5]; /* */ - int (*init) (void); + int (*init) (bool mimimal); int (*final) (void); void (*reload) (void); /* */ @@ -354,7 +354,7 @@ struct mob_interface { int (*read_sqlskilldb) (void); bool (*readdb_race2) (char *fields[], int columns, int current); bool (*readdb_itemratio) (char *str[], int columns, int current); - void (*load) (void); + void (*load) (bool minimal); void (*clear_spawninfo) (); }; diff --git a/src/map/npc.c b/src/map/npc.c index d78b3f8d4..9330d59d3 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -1253,6 +1253,7 @@ int npc_buysellsel(struct map_session_data* sd, int id, int type) { } return 0; } + /*========================================== * Cash Shop Buy List *------------------------------------------*/ @@ -3498,8 +3499,7 @@ const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, const char //Read file and create npc/func/mapflag/monster... accordingly. //@runOnInit should we exec OnInit when it's done ? -void npc_parsesrcfile(const char* filepath, bool runOnInit) -{ +int npc_parsesrcfile(const char* filepath, bool runOnInit) { int16 m, x, y; int lines = 0; FILE* fp; @@ -3512,7 +3512,7 @@ void npc_parsesrcfile(const char* filepath, bool runOnInit) if( fp == NULL ) { ShowError("npc_parsesrcfile: File not found '%s'.\n", filepath); - return; + return -1; } fseek(fp, 0, SEEK_END); len = ftell(fp); @@ -3525,7 +3525,7 @@ void npc_parsesrcfile(const char* filepath, bool runOnInit) ShowError("npc_parsesrcfile: Failed to read file '%s' - %s\n", filepath, strerror(errno)); aFree(buffer); fclose(fp); - return; + return -1; } fclose(fp); @@ -3660,7 +3660,7 @@ void npc_parsesrcfile(const char* filepath, bool runOnInit) } aFree(buffer); - return; + return 0; } int npc_script_event(struct map_session_data* sd, enum npce_event type) @@ -3937,8 +3937,7 @@ static void npc_debug_warps(void) { /*========================================== * npc initialization *------------------------------------------*/ -int do_init_npc(void) -{ +int do_init_npc(bool minimal) { struct npc_src_list *file; int i; @@ -3965,43 +3964,47 @@ int do_init_npc(void) npc->name_db = strdb_alloc(DB_OPT_BASE, NAME_LENGTH); npc->path_db = strdb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, 0); - npc->timer_event_ers = ers_new(sizeof(struct timer_event_data),"clif.c::timer_event_ers",ERS_OPT_NONE); - npc_last_npd = NULL; npc_last_path = NULL; npc_last_ref = NULL; - // process all npc files - ShowStatus("Loading NPCs...\r"); - for( file = npc->src_files; file != NULL; file = file->next ) { - ShowStatus("Loading NPC file: %s"CL_CLL"\r", file->name); - npc->parsesrcfile(file->name,false); + if (!minimal) { + npc->timer_event_ers = ers_new(sizeof(struct timer_event_data),"clif.c::timer_event_ers",ERS_OPT_NONE); + + // process all npc files + ShowStatus("Loading NPCs...\r"); + for( file = npc->src_files; file != NULL; file = file->next ) { + ShowStatus("Loading NPC file: %s"CL_CLL"\r", file->name); + npc->parsesrcfile(file->name,false); + } + ShowInfo ("Done loading '"CL_WHITE"%d"CL_RESET"' NPCs:"CL_CLL"\n" + "\t-'"CL_WHITE"%d"CL_RESET"' Warps\n" + "\t-'"CL_WHITE"%d"CL_RESET"' Shops\n" + "\t-'"CL_WHITE"%d"CL_RESET"' Scripts\n" + "\t-'"CL_WHITE"%d"CL_RESET"' Spawn sets\n" + "\t-'"CL_WHITE"%d"CL_RESET"' Mobs Cached\n" + "\t-'"CL_WHITE"%d"CL_RESET"' Mobs Not Cached\n", + npc_id - START_NPC_NUM, npc_warp, npc_shop, npc_script, npc_mob, npc_cache_mob, npc_delay_mob); } - ShowInfo ("Done loading '"CL_WHITE"%d"CL_RESET"' NPCs:"CL_CLL"\n" - "\t-'"CL_WHITE"%d"CL_RESET"' Warps\n" - "\t-'"CL_WHITE"%d"CL_RESET"' Shops\n" - "\t-'"CL_WHITE"%d"CL_RESET"' Scripts\n" - "\t-'"CL_WHITE"%d"CL_RESET"' Spawn sets\n" - "\t-'"CL_WHITE"%d"CL_RESET"' Mobs Cached\n" - "\t-'"CL_WHITE"%d"CL_RESET"' Mobs Not Cached\n", - npc_id - START_NPC_NUM, npc_warp, npc_shop, npc_script, npc_mob, npc_cache_mob, npc_delay_mob); itemdb->name_constants(); + + if (!minimal) { + map->zone_init(); - map->zone_init(); - - npc->motd = npc->name2id("HerculesMOTD"); /* [Ind/Hercules] */ + npc->motd = npc->name2id("HerculesMOTD"); /* [Ind/Hercules] */ - // set up the events cache - memset(script_event, 0, sizeof(script_event)); - npc->read_event_script(); + // set up the events cache + memset(script_event, 0, sizeof(script_event)); + npc->read_event_script(); - //Debug function to locate all endless loop warps. - if (battle_config.warp_point_debug) - npc->debug_warps(); + //Debug function to locate all endless loop warps. + if (battle_config.warp_point_debug) + npc->debug_warps(); - timer->add_func_list(npc->event_do_clock,"npc_event_do_clock"); - timer->add_func_list(npc->timerevent,"npc_timerevent"); + timer->add_func_list(npc->event_do_clock,"npc_event_do_clock"); + timer->add_func_list(npc->timerevent,"npc_timerevent"); + } // Init dummy NPC npc->fake_nd = (struct npc_data *)aCalloc(1,sizeof(struct npc_data)); diff --git a/src/map/npc.h b/src/map/npc.h index 5ec201e55..10f3406b4 100644 --- a/src/map/npc.h +++ b/src/map/npc.h @@ -140,7 +140,7 @@ struct npc_interface { struct npc_src_list *src_files; struct unit_data base_ud; /* */ - int (*init) (void); + int (*init) (bool minimal); int (*final) (void); /* */ int (*get_new_npc_id) (void); @@ -218,7 +218,7 @@ struct npc_interface { void (*parse_mob2) (struct spawn_data *mobspawn); const char* (*parse_mob) (char *w1, char *w2, char *w3, char *w4, const char *start, const char *buffer, const char *filepath); const char* (*parse_mapflag) (char *w1, char *w2, char *w3, char *w4, const char *start, const char *buffer, const char *filepath); - void (*parsesrcfile) (const char *filepath, bool runOnInit); + int (*parsesrcfile) (const char *filepath, bool runOnInit); int (*script_event) (struct map_session_data *sd, enum npce_event type); void (*read_event_script) (void); int (*path_db_clear_sub) (DBKey key, DBData *data, va_list args); diff --git a/src/map/party.c b/src/map/party.c index ab05c23f7..2801d0466 100644 --- a/src/map/party.c +++ b/src/map/party.c @@ -1306,7 +1306,10 @@ void do_final_party(void) { db_destroy(party->booking_db); // Party Booking [Spiria] } // Constructor, init vars -void do_init_party(void) { +void do_init_party(bool minimal) { + if (minimal) + return; + party->db = idb_alloc(DB_OPT_RELEASE_DATA); party->booking_db = idb_alloc(DB_OPT_RELEASE_DATA); // Party Booking [Spiria] timer->add_func_list(party->send_xy_timer, "party_send_xy_timer"); diff --git a/src/map/party.h b/src/map/party.h index ab14d1a31..91f4c1b7d 100644 --- a/src/map/party.h +++ b/src/map/party.h @@ -73,7 +73,7 @@ struct party_interface { DBMap* booking_db; // int char_id -> struct party_booking_ad_info* (releases data) // Party Booking [Spiria] unsigned long booking_nextid; /* funcs */ - void (*init) (void); + void (*init) (bool minimal); void (*final) (void); /* */ struct party_data* (*search) (int party_id); diff --git a/src/map/pc.c b/src/map/pc.c index d1d76fd4c..89b094043 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -10215,7 +10215,9 @@ void do_final_pc(void) { return; } -void do_init_pc(void) { +void do_init_pc(bool minimal) { + if (minimal) + return; pc->itemcd_db = idb_alloc(DB_OPT_RELEASE_DATA); diff --git a/src/map/pc.h b/src/map/pc.h index 7ae92c9a5..af03aa2f3 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -742,7 +742,7 @@ struct pc_interface { /* */ struct eri *sc_display_ers; /* funcs */ - void (*init) (void); + void (*init) (bool minimal); void (*final) (void); struct map_session_data* (*get_dummy_sd) (void); diff --git a/src/map/pet.c b/src/map/pet.c index 7dcf06c02..612ddfada 100644 --- a/src/map/pet.c +++ b/src/map/pet.c @@ -1328,8 +1328,10 @@ int read_petdb() /*========================================== * Initialization process relationship skills *------------------------------------------*/ -int do_init_pet(void) -{ +int do_init_pet(bool minimal) { + if (minimal) + return 0; + pet->read_db(); pet->item_drop_ers = ers_new(sizeof(struct item_drop),"pet.c::item_drop_ers",ERS_OPT_NONE); diff --git a/src/map/pet.h b/src/map/pet.h index f95e860a2..f9a756de2 100644 --- a/src/map/pet.h +++ b/src/map/pet.h @@ -106,7 +106,7 @@ struct pet_interface { struct eri *item_drop_ers; //For loot drops delay structures. struct eri *item_drop_list_ers; /* */ - int (*init) (void); + int (*init) (bool minimal); int (*final) (void); /* */ int (*hungry_val) (struct pet_data *pd); diff --git a/src/map/quest.c b/src/map/quest.c index f40b60c3d..0719b8dbb 100644 --- a/src/map/quest.c +++ b/src/map/quest.c @@ -351,7 +351,10 @@ int quest_read_db(void) { return 0; } -void do_init_quest(void) { +void do_init_quest(bool minimal) { + if (minimal) + return; + quest->read_db(); } diff --git a/src/map/quest.h b/src/map/quest.h index 340bc8608..0725a8c46 100644 --- a/src/map/quest.h +++ b/src/map/quest.h @@ -19,7 +19,7 @@ typedef enum quest_check_type { HAVEQUEST, PLAYTIME, HUNTING } quest_check_type; struct quest_interface { struct s_quest_db db[MAX_QUEST_DB]; /* */ - void (*init) (void); + void (*init) (bool minimal); void (*reload) (void); /* */ int (*search_db) (int quest_id); diff --git a/src/map/script.c b/src/map/script.c index 3b0557235..ea3867083 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -1863,66 +1863,98 @@ void read_constdb(void) { fclose(fp); } +// Standard UNIX tab size is 8 +#define TAB_SIZE 8 +#define update_tabstop(tabstop,chars) \ + do { \ + (tabstop) -= (chars); \ + while ((tabstop) <= 0) (tabstop) += TAB_SIZE; \ + } while (false) + /*========================================== * Display emplacement line of script *------------------------------------------*/ const char* script_print_line(StringBuf* buf, const char* p, const char* mark, int line) { - int i; + int i, mark_pos = 0, tabstop = TAB_SIZE; if( p == NULL || !p[0] ) return NULL; if( line < 0 ) - StrBuf->Printf(buf, "*% 5d : ", -line); + StrBuf->Printf(buf, "*%5d: ", -line); // len = 8 else - StrBuf->Printf(buf, " % 5d : ", line); - for(i=0;p[i] && p[i] != '\n';i++){ - if(p + i != mark) - StrBuf->Printf(buf, "%c", p[i]); + StrBuf->Printf(buf, " %5d: ", line); // len = 8 + update_tabstop(tabstop,8); // len = 8 + for( i=0; p[i] && p[i] != '\n'; i++ ) { + char c = p[i]; + int w = 1; + // Like Clang does, let's print the code with tabs expanded to spaces to ensure that the marker will be under the right character + if( c == '\t' ) { + c = ' '; + w = tabstop; + } + update_tabstop(tabstop, w); + if( p + i < mark) + mark_pos += w; + if( p + i != mark) + StrBuf->Printf(buf, "%*c", w, c); else - StrBuf->Printf(buf, "\'%c\'", p[i]); + StrBuf->Printf(buf, CL_BT_RED"%*c"CL_RESET, w, c); } StrBuf->AppendStr(buf, "\n"); + if( mark ) { + StrBuf->AppendStr(buf, " "CL_BT_CYAN); // len = 8 + for( ; mark_pos > 0; mark_pos-- ) { + StrBuf->AppendStr(buf, "~"); + } + StrBuf->AppendStr(buf, CL_RESET CL_BT_GREEN"^"CL_RESET"\n"); + } return p+i+(p[i] == '\n' ? 1 : 0); } +#undef TAB_SIZE +#undef update_tabstop +#define CONTEXTLINES 3 void script_errorwarning_sub(StringBuf *buf, const char* src, const char* file, int start_line, const char* error_msg, const char* error_pos) { // Find the line where the error occurred int j; int line = start_line; - const char *p; - const char *linestart[5] = { NULL, NULL, NULL, NULL, NULL }; + const char *p, *error_linepos; + const char *linestart[CONTEXTLINES]; + memset(linestart, '\0', sizeof(linestart)); for(p=src;p && *p;line++){ const char *lineend=strchr(p,'\n'); if(lineend==NULL || error_pos<lineend){ break; } - for( j = 0; j < 4; j++ ) { + for( j = 0; j < CONTEXTLINES-1; j++ ) { linestart[j] = linestart[j+1]; } - linestart[4] = p; - p=lineend+1; + linestart[CONTEXTLINES-1] = p; + p = lineend+1; } + error_linepos = p; if( line >= 0 ) - StrBuf->Printf(buf, "script error in file '%s' line %d\n", file, line); + StrBuf->Printf(buf, "script error in file '%s' line %d column %d\n", file, line, error_pos-error_linepos+1); else StrBuf->Printf(buf, "script error in file '%s' item ID %d\n", file, -line); StrBuf->Printf(buf, " %s\n", error_msg); - for(j = 0; j < 5; j++ ) { - script->print_line(buf, linestart[j], NULL, line + j - 5); + for(j = 0; j < CONTEXTLINES; j++ ) { + script->print_line(buf, linestart[j], NULL, line + j - CONTEXTLINES); } p = script->print_line(buf, p, error_pos, -line); - for(j = 0; j < 5; j++) { + for(j = 0; j < CONTEXTLINES; j++) { p = script->print_line(buf, p, NULL, line + j + 1 ); } } +#undef CONTEXTLINES void script_error(const char* src, const char* file, int start_line, const char* error_msg, const char* error_pos) { StringBuf buf; StrBuf->Init(&buf); - StrBuf->AppendStr(&buf, "\a\n"); + StrBuf->AppendStr(&buf, "\a"); script->errorwarning_sub(&buf, src, file, start_line, error_msg, error_pos); @@ -3694,7 +3726,7 @@ void do_final_script(void) { /*========================================== * Initialization *------------------------------------------*/ -void do_init_script(void) { +void do_init_script(bool minimal) { script->st_db = idb_alloc(DB_OPT_BASE); script->userfunc_db = strdb_alloc(DB_OPT_DUP_KEY,0); script->autobonus_db = strdb_alloc(DB_OPT_DUP_KEY,0); @@ -3707,6 +3739,10 @@ void do_init_script(void) { script->parse_builtin(); script->read_constdb(); + + if (minimal) + return; + mapreg->init(); } diff --git a/src/map/script.h b/src/map/script.h index a4d14c777..6aebc8a30 100644 --- a/src/map/script.h +++ b/src/map/script.h @@ -507,7 +507,7 @@ struct script_interface { int potion_hp, potion_per_hp, potion_sp, potion_per_sp; int potion_target; /* */ - void (*init) (void); + void (*init) (bool minimal); void (*final) (void); int (*reload) (void); /* parse */ diff --git a/src/map/skill.c b/src/map/skill.c index b70e58c46..c16ab832c 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -18027,7 +18027,7 @@ bool skill_parse_row_changematerialdb(char* split[], int columns, int current) { * create_arrow_db.txt * abra_db.txt *------------------------------*/ -void skill_readdb(void) { +void skill_readdb(bool minimal) { // init skill db structures db_clear(skill->name2id_db); @@ -18050,6 +18050,10 @@ void skill_readdb(void) { safestrncpy(skill->db[0].desc, "Unknown Skill", sizeof(skill->db[0].desc)); sv->readdb(map->db_path, DBPATH"skill_db.txt", ',', 17, 17, MAX_SKILL_DB, skill->parse_row_skilldb); + + if (minimal) + return; + sv->readdb(map->db_path, DBPATH"skill_require_db.txt", ',', 32, 32, MAX_SKILL_DB, skill->parse_row_requiredb); #ifdef RENEWAL_CAST sv->readdb(map->db_path, "re/skill_cast_db.txt", ',', 8, 8, MAX_SKILL_DB, skill->parse_row_castdb); @@ -18077,7 +18081,7 @@ void skill_reload (void) { struct map_session_data *sd; int i,c,k; - skill->read_db(); + skill->read_db(false); //[Ind/Hercules] refresh index cache for(c = 0; c < CLASS_COUNT; c++) { @@ -18103,9 +18107,12 @@ void skill_reload (void) { /*========================================== * *------------------------------------------*/ -int do_init_skill (void) { +int do_init_skill(bool minimal) { skill->name2id_db = strdb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, MAX_SKILL_NAME_LENGTH); - skill->read_db(); + skill->read_db(minimal); + + if (minimal) + return 0; skill->group_db = idb_alloc(DB_OPT_BASE); skill->unit_db = idb_alloc(DB_OPT_BASE); diff --git a/src/map/skill.h b/src/map/skill.h index fca4952ef..918216e8a 100644 --- a/src/map/skill.h +++ b/src/map/skill.h @@ -1797,10 +1797,10 @@ typedef int (*SkillFunc)(struct block_list *src, struct block_list *target, uint * Skill.c Interface **/ struct skill_interface { - int (*init) (void); + int (*init) (bool minimal); int (*final) (void); void (*reload) (void); - void (*read_db) (void); + void (*read_db) (bool minimal); /* */ DBMap* cd_db; // char_id -> struct skill_cd DBMap* name2id_db; diff --git a/src/map/status.c b/src/map/status.c index c06de4dfe..17fa4dd38 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -11536,7 +11536,10 @@ int status_readdb(void) /*========================================== * Status db init and destroy. *------------------------------------------*/ -int do_init_status(void) { +int do_init_status(bool minimal) { + if (minimal) + return 0; + timer->add_func_list(status->change_timer,"status_change_timer"); timer->add_func_list(status->kaahi_heal_timer,"status_kaahi_heal_timer"); timer->add_func_list(status->natural_heal_timer,"status_natural_heal_timer"); diff --git a/src/map/status.h b/src/map/status.h index 254f3bfab..7d48e5684 100644 --- a/src/map/status.h +++ b/src/map/status.h @@ -1864,7 +1864,7 @@ struct status_interface { int64 natural_heal_prev_tick; unsigned int natural_heal_diff_tick; /* */ - int (*init) (void); + int (*init) (bool minimal); void (*final) (void); /* funcs */ int (*get_refine_chance) (enum refine_type wlv, int refine); diff --git a/src/map/storage.c b/src/map/storage.c index cc1100d28..45a80867d 100644 --- a/src/map/storage.c +++ b/src/map/storage.c @@ -717,7 +717,9 @@ int storage_guild_storage_quit(struct map_session_data* sd, int flag) { return 0; } -void do_init_gstorage(void) { +void do_init_gstorage(bool minimal) { + if (minimal) + return; gstorage->db = idb_alloc(DB_OPT_RELEASE_DATA); } void do_final_gstorage(void) { diff --git a/src/map/storage.h b/src/map/storage.h index 9258e0265..8a10c9f3b 100644 --- a/src/map/storage.h +++ b/src/map/storage.h @@ -36,7 +36,7 @@ struct guild_storage_interface { struct guild_storage *(*id2storage) (int guild_id); struct guild_storage *(*id2storage2) (int guild_id); /* */ - void (*init) (void); + void (*init) (bool minimal); void (*final) (void); /* */ int (*delete) (int guild_id); diff --git a/src/map/unit.c b/src/map/unit.c index c7ba2f6f9..b1240def2 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -2573,7 +2573,10 @@ int unit_free(struct block_list *bl, clr_type clrtype) { return 0; } -int do_init_unit(void) { +int do_init_unit(bool minimal) { + if (minimal) + return 0; + timer->add_func_list(unit->attack_timer, "unit_attack_timer"); timer->add_func_list(unit->walktoxy_timer,"unit_walktoxy_timer"); timer->add_func_list(unit->walktobl_sub, "unit_walktobl_sub"); diff --git a/src/map/unit.h b/src/map/unit.h index 0567688a1..8220b7e8f 100644 --- a/src/map/unit.h +++ b/src/map/unit.h @@ -72,7 +72,7 @@ extern const short dirx[8]; extern const short diry[8]; struct unit_interface { - int (*init) (void); + int (*init) (bool minimal); int (*final) (void); /* */ struct unit_data* (*bl2ud) (struct block_list *bl); diff --git a/src/map/vending.c b/src/map/vending.c index 7d6d02cfb..c7a2dfa68 100644 --- a/src/map/vending.c +++ b/src/map/vending.c @@ -360,7 +360,7 @@ void final(void) { db_destroy(vending->db); } -void init(void) { +void init(bool minimal) { vending->db = idb_alloc(DB_OPT_BASE); vending->next_id = 0; } diff --git a/src/map/vending.h b/src/map/vending.h index 968811ecd..b760bf064 100644 --- a/src/map/vending.h +++ b/src/map/vending.h @@ -20,7 +20,7 @@ struct vending_interface { unsigned int next_id;/* next vender id */ DBMap *db; /* */ - void (*init) (void); + void (*init) (bool minimal); void (*final) (void); /* */ void (*close) (struct map_session_data* sd); -- cgit v1.2.3-70-g09d2 From 6f77d070b98c73962a4f45f274a0f5c58a2448e3 Mon Sep 17 00:00:00 2001 From: shennetsind <ind@henn.et> Date: Wed, 6 Nov 2013 15:10:35 -0200 Subject: Modified status_calc_ Replaces the previous 'first' flag with a multi-option flag capable of selectively determining calls where the recalculation must not be hold by delayed damage, and therefore must take place immediately. This fixes issues caused by actions that require immediate recalculation e.g. on-level-up max_hp update, also modified @baselevel where status_calc was being called after the heal and not before, causing it not to be fully healed. Special Thanks to Haruna! <3 Signed-off-by: shennetsind <ind@henn.et> --- src/map/atcommand.c | 11 ++++---- src/map/battle.c | 4 +-- src/map/clif.c | 2 +- src/map/elemental.c | 2 +- src/map/guild.c | 2 +- src/map/homunculus.c | 12 ++++----- src/map/itemdb.c | 2 +- src/map/mercenary.c | 2 +- src/map/mob.c | 6 ++--- src/map/pc.c | 64 ++++++++++++++++++++++---------------------- src/map/pet.c | 16 +++++------ src/map/script.c | 18 ++++++------- src/map/status.c | 75 +++++++++++++++++++++++++++------------------------- src/map/status.h | 38 +++++++++++++++----------- 14 files changed, 132 insertions(+), 122 deletions(-) (limited to 'src/map/elemental.c') diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 2abdb5925..7e5d42e69 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -1258,6 +1258,7 @@ ACMD(baselevelup) sd->status.status_point += status_point; sd->status.base_level += (unsigned int)level; + status_calc_pc(sd, SCO_FORCE); status_percent_heal(&sd->bl, 100, 100); clif->misceffect(&sd->bl, 0); clif->message(fd, msg_txt(21)); // Base level raised. @@ -1279,13 +1280,13 @@ ACMD(baselevelup) sd->status.status_point -= status_point; sd->status.base_level -= (unsigned int)level; clif->message(fd, msg_txt(22)); // Base level lowered. + status_calc_pc(sd, SCO_FORCE); } sd->status.base_exp = 0; clif->updatestatus(sd, SP_STATUSPOINT); clif->updatestatus(sd, SP_BASELEVEL); clif->updatestatus(sd, SP_BASEEXP); clif->updatestatus(sd, SP_NEXTBASEEXP); - status_calc_pc(sd, 0); pc->baselevelchanged(sd); if(sd->status.party_id) party->send_levelup(sd); @@ -1338,7 +1339,7 @@ ACMD(joblevelup) clif->updatestatus(sd, SP_JOBEXP); clif->updatestatus(sd, SP_NEXTJOBEXP); clif->updatestatus(sd, SP_SKILLPOINT); - status_calc_pc(sd, 0); + status_calc_pc(sd, SCO_FORCE); return true; } @@ -2352,7 +2353,7 @@ ACMD(param) { *stats[i] = new_value; clif->updatestatus(sd, SP_STR + i); clif->updatestatus(sd, SP_USTR + i); - status_calc_pc(sd, 0); + status_calc_pc(sd, SCO_FORCE); clif->message(fd, msg_txt(42)); // Stat changed. } else { if (value < 0) @@ -2409,7 +2410,7 @@ ACMD(stat_all) { } if (count > 0) { // if at least 1 stat modified - status_calc_pc(sd, 0); + status_calc_pc(sd, SCO_FORCE); clif->message(fd, msg_txt(84)); // All stats changed! } else { if (value < 0) @@ -6725,7 +6726,7 @@ ACMD(homlevel) { hd->homunculus.exp += hd->exp_next; } while( hd->homunculus.level < level && homun->levelup(hd) ); - status_calc_homunculus(hd,0); + status_calc_homunculus(hd,SCO_NONE); status_percent_heal(&hd->bl, 100, 100); clif->specialeffect(&hd->bl,568,AREA); return true; diff --git a/src/map/battle.c b/src/map/battle.c index 94222f663..499b7e3a0 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -206,7 +206,7 @@ int battle_delay_damage_sub(int tid, int64 tick, int id, intptr_t data) { 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); + status_calc_pc(((TBL_PC*)src),SCO_FORCE); } ers_free(battle->delay_damage_ers, dat); return 0; @@ -237,7 +237,7 @@ int battle_delay_damage_sub(int tid, int64 tick, int id, intptr_t data) { if( src && src->type == BL_PC && --((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); + status_calc_pc(((TBL_PC*)src),SCO_FORCE); } } ers_free(battle->delay_damage_ers, dat); diff --git a/src/map/clif.c b/src/map/clif.c index c1e7cb1c9..913a94058 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -9473,7 +9473,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { } 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 */ + status_calc_pc(sd, SCO_NONE);/* some conditions are map-dependent so we must recalculate */ sd->state.changemap = false; if( hChSys.local && hChSys.local_autojoin && !map->list[sd->bl.m].flag.chsysnolocalaj ) { diff --git a/src/map/elemental.c b/src/map/elemental.c index f15b735b2..d280f5b81 100644 --- a/src/map/elemental.c +++ b/src/map/elemental.c @@ -258,7 +258,7 @@ int elemental_data_received(struct s_elemental *ele, bool flag) { ed->bl.y = ed->ud.to_y; map->addiddb(&ed->bl); - status_calc_elemental(ed,1); + status_calc_elemental(ed,SCO_FIRST); ed->last_spdrain_time = ed->last_thinktime = timer->gettick(); ed->summon_timer = INVALID_TIMER; elemental->summon_init(ed); diff --git a/src/map/guild.c b/src/map/guild.c index 0ae45bede..4dcdb6c46 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -1923,7 +1923,7 @@ int guild_castledatasave(int castle_id, int index, int value) gc->defense = value; for (i = 0; i < MAX_GUARDIANS; i++) if (gc->guardian[i].visible && (gd = map->id2md(gc->guardian[i].id)) != NULL) - status_calc_mob(gd, 0); + status_calc_mob(gd, SCO_NONE); break; } case 4: diff --git a/src/map/homunculus.c b/src/map/homunculus.c index 52f0572c0..a7a409011 100644 --- a/src/map/homunculus.c +++ b/src/map/homunculus.c @@ -272,7 +272,7 @@ void homunculus_skillup(struct homun_data *hd,uint16 skill_id) { { hd->homunculus.hskill[i].lv++; hd->homunculus.skillpts-- ; - status_calc_homunculus(hd,0); + status_calc_homunculus(hd,SCO_NONE); if (hd->master) { clif->homskillup(hd->master, skill_id); clif->hominfo(hd->master,hd,0); @@ -413,7 +413,7 @@ bool homunculus_evolve(struct homun_data *hd) { //status_Calc flag&1 will make current HP/SP be reloaded from hom structure hom->hp = hd->battle_status.hp; hom->sp = hd->battle_status.sp; - status_calc_homunculus(hd,1); + status_calc_homunculus(hd,SCO_FIRST); if (!(battle_config.hom_setting&0x2)) skill->unit_move(&sd->hd->bl,timer->gettick(),1); // apply land skills immediately @@ -460,7 +460,7 @@ bool homunculus_mutate(struct homun_data *hd, int homun_id) { hom->hp = hd->battle_status.hp; hom->sp = hd->battle_status.sp; hom->prev_class = prev_class; - status_calc_homunculus(hd,1); + status_calc_homunculus(hd,SCO_FIRST); if (!(battle_config.hom_setting&0x2)) skill->unit_move(&sd->hd->bl,timer->gettick(),1); // apply land skills immediately @@ -505,7 +505,7 @@ int homunculus_gainexp(struct homun_data *hd,unsigned int exp) { hd->homunculus.exp = 0; clif->specialeffect(&hd->bl,568,AREA); - status_calc_homunculus(hd,0); + status_calc_homunculus(hd,SCO_NONE); status_percent_heal(&hd->bl, 100, 100); return 0; } @@ -757,7 +757,7 @@ bool homunculus_create(struct map_session_data *sd, struct s_homunculus *hom) { hd->bl.y = hd->ud.to_y; map->addiddb(&hd->bl); - status_calc_homunculus(hd,1); + status_calc_homunculus(hd,SCO_FIRST); hd->hungry_timer = INVALID_TIMER; return true; @@ -1003,7 +1003,7 @@ bool homunculus_shuffle(struct homun_data *hd) { memcpy(&hd->homunculus.hskill, &b_skill, sizeof(b_skill)); hd->homunculus.skillpts = skillpts; clif->homskillinfoblock(sd); - status_calc_homunculus(hd,0); + status_calc_homunculus(hd,SCO_NONE); status_percent_heal(&hd->bl, 100, 100); clif->specialeffect(&hd->bl,568,AREA); diff --git a/src/map/itemdb.c b/src/map/itemdb.c index 3fc8d526b..8dd6e9d9d 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -2108,7 +2108,7 @@ void itemdb_reload(void) { sd->combos.id = NULL; sd->combos.count = 0; if( pc->load_combo(sd) > 0 ) - status_calc_pc(sd,0); + status_calc_pc(sd,SCO_FORCE); } } diff --git a/src/map/mercenary.c b/src/map/mercenary.c index 8c74a5e1e..5ea10dc66 100644 --- a/src/map/mercenary.c +++ b/src/map/mercenary.c @@ -317,7 +317,7 @@ int merc_data_received(struct s_mercenary *merc, bool flag) { md->bl.y = md->ud.to_y; map->addiddb(&md->bl); - status_calc_mercenary(md,1); + status_calc_mercenary(md,SCO_FIRST); md->contract_timer = INVALID_TIMER; merc_contract_init(md); } diff --git a/src/map/mob.c b/src/map/mob.c index 97f8ea6c1..3f2ae2a55 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -601,7 +601,7 @@ int mob_spawn_guardian_sub(int tid, int64 tick, int id, intptr_t data) { memcpy(md->guardian_data->guild_name, g->name, NAME_LENGTH); md->guardian_data->guardup_lv = guardup_lv; if( guardup_lv ) - status_calc_mob(md, 0); //Give bonuses. + status_calc_mob(md, SCO_NONE); //Give bonuses. return 0; } @@ -919,7 +919,7 @@ int mob_spawn (struct mob_data *md) } memset(&md->state, 0, sizeof(md->state)); - status_calc_mob(md, 1); + status_calc_mob(md, SCO_FIRST); md->attacked_id = 0; md->target_id = 0; md->move_fail_count = 0; @@ -2725,7 +2725,7 @@ int mob_class_change (struct mob_data *md, int class_) unit->skillcastcancel(&md->bl, 0); status->set_viewdata(&md->bl, class_); clif->class_change(&md->bl, md->vd->class_, 1); - status_calc_mob(md, 1); + status_calc_mob(md, SCO_FIRST); md->ud.state.speed_changed = 1; //Speed change update. if (battle_config.monster_class_change_recover) { diff --git a/src/map/pc.c b/src/map/pc.c index d1d76fd4c..f5e20b32b 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -1320,7 +1320,7 @@ int pc_reg_received(struct map_session_data *sd) pc->load_combo(sd); - status_calc_pc(sd,1); + status_calc_pc(sd,SCO_FIRST|SCO_FORCE); chrif->scdata_request(sd->status.account_id, sd->status.char_id); intif->Mail_requestinbox(sd->status.char_id, 0); // MAIL SYSTEM - Request Mail Inbox @@ -2028,7 +2028,7 @@ int pc_exeautobonus(struct map_session_data *sd,struct s_autobonus *autobonus) autobonus->active = timer->add(timer->gettick()+autobonus->duration, pc->endautobonus, sd->bl.id, (intptr_t)autobonus); sd->state.autobonus |= autobonus->pos; - status_calc_pc(sd,0); + status_calc_pc(sd,SCO_NONE); return 0; } @@ -2042,7 +2042,7 @@ int pc_endautobonus(int tid, int64 tick, int id, intptr_t data) { autobonus->active = INVALID_TIMER; sd->state.autobonus &= ~autobonus->pos; - status_calc_pc(sd,0); + status_calc_pc(sd,SCO_NONE); return 0; } @@ -3549,7 +3549,7 @@ int pc_skill(TBL_PC* sd, int id, int level, int flag) { } else clif->addskill(sd,id); if( !skill->db[index].inf ) //Only recalculate for passive skills. - status_calc_pc(sd, 0); + status_calc_pc(sd, SCO_NONE); break; case 1: //Item bonus skill. if( sd->status.skill[index].id == id ) { @@ -3583,7 +3583,7 @@ int pc_skill(TBL_PC* sd, int id, int level, int flag) { } else clif->addskill(sd,id); if( !skill->db[index].inf ) //Only recalculate for passive skills. - status_calc_pc(sd, 0); + status_calc_pc(sd, SCO_NONE); break; default: //Unknown flag? return 0; @@ -5789,13 +5789,13 @@ int pc_checkbaselevelup(struct map_session_data *sd) { } while ((next=pc->nextbaseexp(sd)) > 0 && sd->status.base_exp >= next); if (battle_config.pet_lv_rate && sd->pd) //<Skotlex> update pet's level - status_calc_pet(sd->pd,0); + status_calc_pet(sd->pd,SCO_NONE); clif->updatestatus(sd,SP_STATUSPOINT); clif->updatestatus(sd,SP_BASELEVEL); clif->updatestatus(sd,SP_BASEEXP); clif->updatestatus(sd,SP_NEXTBASEEXP); - status_calc_pc(sd,0); + status_calc_pc(sd,SCO_FORCE); status_percent_heal(&sd->bl,100,100); if((sd->class_&MAPID_UPPERMASK) == MAPID_SUPER_NOVICE) { @@ -5855,7 +5855,7 @@ int pc_checkjoblevelup(struct map_session_data *sd) clif->updatestatus(sd,SP_JOBEXP); clif->updatestatus(sd,SP_NEXTJOBEXP); clif->updatestatus(sd,SP_SKILLPOINT); - status_calc_pc(sd,0); + status_calc_pc(sd,SCO_FORCE); clif->misceffect(&sd->bl,1); if (pc->checkskill(sd, SG_DEVIL) && !pc->nextjobexp(sd)) clif->status_change(&sd->bl,SI_DEVIL1, 1, 0, 0, 0, 1); //Permanent blind effect from SG_DEVIL. @@ -6143,7 +6143,7 @@ int pc_statusup(struct map_session_data* sd, int type) val = pc->setstat(sd, type, pc->getstat(sd,type) + 1); sd->status.status_point -= need; - status_calc_pc(sd,0); + status_calc_pc(sd,SCO_NONE); // update increase cost indicator if( need != pc->need_status_point(sd,type,1) ) @@ -6183,7 +6183,7 @@ int pc_statusup2(struct map_session_data* sd, int type, int val) max = pc_maxparameter(sd); val = pc->setstat(sd, type, cap_value(pc->getstat(sd,type) + val, 1, max)); - status_calc_pc(sd,0); + status_calc_pc(sd,SCO_NONE); // update increase cost indicator if( need != pc->need_status_point(sd,type,1) ) @@ -6226,7 +6226,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 ) - status_calc_pc(sd,0); // Only recalculate for passive skills. + status_calc_pc(sd,SCO_NONE); // 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. else @@ -6299,7 +6299,7 @@ int pc_allskillup(struct map_session_data *sd) sd->status.skill[idx].lv = skill->tree_get_max(id, sd->status.class_); // celest } } - status_calc_pc(sd,0); + status_calc_pc(sd,SCO_NONE); //Required because if you could level up all skills previously, //the update will not be sent as only the lv variable changes. clif->skillinfoblock(sd); @@ -6389,7 +6389,7 @@ int pc_resetlvl(struct map_session_data* sd,int type) if ((type == 1 || type == 2 || type == 3) && sd->status.party_id) party->send_levelup(sd); - status_calc_pc(sd,0); + status_calc_pc(sd,SCO_FORCE); clif->skillinfoblock(sd); return 0; @@ -6454,7 +6454,7 @@ int pc_resetstate(struct map_session_data* sd) pc_setglobalreg(sd,"TK_MISSION_ID", 0); } - status_calc_pc(sd,0); + status_calc_pc(sd,SCO_NONE); return 1; } @@ -6565,7 +6565,7 @@ int pc_resetskill(struct map_session_data* sd, int flag) if( flag&1 ) { clif->updatestatus(sd,SP_SKILLPOINT); clif->skillinfoblock(sd); - status_calc_pc(sd,0); + status_calc_pc(sd,SCO_FORCE); } return skill_point; @@ -6819,7 +6819,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) { ) { // monster level up [Valaris] clif->misceffect(&md->bl,0); md->level++; - status_calc_mob(md, 0); + status_calc_mob(md, SCO_NONE); status_percent_heal(src,10,0); if( battle_config.show_mob_info&4 ) @@ -7235,7 +7235,7 @@ int pc_setparam(struct map_session_data *sd,int type,int val) clif->updatestatus(sd, SP_NEXTBASEEXP); clif->updatestatus(sd, SP_STATUSPOINT); clif->updatestatus(sd, SP_BASEEXP); - status_calc_pc(sd, 0); + status_calc_pc(sd, SCO_FORCE); if(sd->status.party_id) { party->send_levelup(sd); @@ -7252,7 +7252,7 @@ int pc_setparam(struct map_session_data *sd,int type,int val) // clif->updatestatus(sd, SP_JOBLEVEL); // Gets updated at the bottom clif->updatestatus(sd, SP_NEXTJOBEXP); clif->updatestatus(sd, SP_JOBEXP); - status_calc_pc(sd, 0); + status_calc_pc(sd, SCO_FORCE); break; case SP_SKILLPOINT: sd->status.skill_point = val; @@ -7662,7 +7662,7 @@ int pc_jobchange(struct map_session_data *sd,int job, int upper) if(sd->status.manner < 0) clif->changestatus(sd,SP_MANNER,sd->status.manner); - status_calc_pc(sd,0); + status_calc_pc(sd,SCO_FORCE); pc->checkallowskill(sd); pc->equiplookall(sd); @@ -7785,11 +7785,11 @@ int pc_setoption(struct map_session_data *sd,int type) if( (type&OPTION_RIDING && !(p_type&OPTION_RIDING)) || (type&OPTION_DRAGON && !(p_type&OPTION_DRAGON) && pc->checkskill(sd,RK_DRAGONTRAINING) > 0) ) { // Mounting clif->sc_load(&sd->bl,sd->bl.id,AREA,SI_RIDING, 0, 0, 0); - status_calc_pc(sd,0); + status_calc_pc(sd,SCO_NONE); } else if( (!(type&OPTION_RIDING) && p_type&OPTION_RIDING) || (!(type&OPTION_DRAGON) && p_type&OPTION_DRAGON) ) { // Dismount clif->sc_end(&sd->bl,sd->bl.id,AREA,SI_RIDING); - status_calc_pc(sd,0); + status_calc_pc(sd,SCO_NONE); } #ifndef NEW_CARTS @@ -7797,11 +7797,11 @@ int pc_setoption(struct map_session_data *sd,int type) clif->cartlist(sd); clif->updatestatus(sd, SP_CARTINFO); if(pc->checkskill(sd, MC_PUSHCART) < 10) - status_calc_pc(sd,0); //Apply speed penalty. + status_calc_pc(sd,SCO_NONE); //Apply speed penalty. } else if( !( type&OPTION_CART ) && p_type&OPTION_CART ){ //Cart Off clif->clearcart(sd->fd); if(pc->checkskill(sd, MC_PUSHCART) < 10) - status_calc_pc(sd,0); //Remove speed penalty. + status_calc_pc(sd,SCO_NONE); //Remove speed penalty. } #endif @@ -7813,18 +7813,18 @@ int pc_setoption(struct map_session_data *sd,int type) if( (sd->class_&MAPID_THIRDMASK) == MAPID_RANGER ) { if( type&OPTION_WUGRIDER && !(p_type&OPTION_WUGRIDER) ) { // Mounting clif->sc_load(&sd->bl,sd->bl.id,AREA,SI_WUGRIDER, 0, 0, 0); - status_calc_pc(sd,0); + status_calc_pc(sd,SCO_NONE); } else if( !(type&OPTION_WUGRIDER) && p_type&OPTION_WUGRIDER ) { // Dismount clif->sc_end(&sd->bl,sd->bl.id,AREA,SI_WUGRIDER); - status_calc_pc(sd,0); + status_calc_pc(sd,SCO_NONE); } } if( (sd->class_&MAPID_THIRDMASK) == MAPID_MECHANIC ) { int i; if( type&OPTION_MADOGEAR && !(p_type&OPTION_MADOGEAR) ) - status_calc_pc(sd, 0); + status_calc_pc(sd, SCO_NONE); else if( !(type&OPTION_MADOGEAR) && p_type&OPTION_MADOGEAR ) - status_calc_pc(sd, 0); + status_calc_pc(sd, SCO_NONE); for( i = 0; i < SC_MAX; i++ ){ if ( !sd->sc.data[i] || !status->get_sc_type(i) ) continue; @@ -7903,7 +7903,7 @@ int pc_setcart(struct map_session_data *sd,int type) { } if(pc->checkskill(sd, MC_PUSHCART) < 10) - status_calc_pc(sd,0); //Recalc speed penalty. + status_calc_pc(sd,SCO_NONE); //Recalc speed penalty. #else // Update option option = sd->sc.option; @@ -8155,7 +8155,7 @@ int pc_setregistry(struct map_session_data *sd,const char *reg,int val,int type) i = (!sd->die_counter && (sd->class_&MAPID_UPPERMASK) == MAPID_SUPER_NOVICE); sd->die_counter = val; if( i ) - status_calc_pc(sd,0); // Lost the bonus. + status_calc_pc(sd,SCO_NONE); // Lost the bonus. } else if( !strcmp(reg,"COOK_MASTERY") && sd->cook_mastery != val ) { @@ -8759,7 +8759,7 @@ int pc_equipitem(struct map_session_data *sd,int n,int req_pos) } } - status_calc_pc(sd,0); + status_calc_pc(sd,SCO_NONE); if (flag) //Update skill data clif->skillinfoblock(sd); @@ -8924,7 +8924,7 @@ int pc_unequipitem(struct map_session_data *sd,int n,int flag) { if(flag&1 || status_cacl) { pc->checkallowskill(sd); - status_calc_pc(sd,0); + status_calc_pc(sd,SCO_NONE); } if(sd->sc.data[SC_CRUCIS] && !battle->check_undead(sd->battle_status.race,sd->battle_status.def_ele)) @@ -9029,7 +9029,7 @@ int pc_checkitem(struct map_session_data *sd) if( calc_flag && sd->state.active ) { pc->checkallowskill(sd); - status_calc_pc(sd,0); + status_calc_pc(sd,SCO_NONE); } return 0; diff --git a/src/map/pet.c b/src/map/pet.c index 7dcf06c02..b75cc5a44 100644 --- a/src/map/pet.c +++ b/src/map/pet.c @@ -65,7 +65,7 @@ void pet_set_intimate(struct pet_data *pd, int value) pd->pet.intimate = value; if( (intimate >= battle_config.pet_equip_min_friendly && pd->pet.intimate < battle_config.pet_equip_min_friendly) || (intimate < battle_config.pet_equip_min_friendly && pd->pet.intimate >= battle_config.pet_equip_min_friendly) ) - status_calc_pc(sd,0); + status_calc_pc(sd,SCO_NONE); } int pet_create_egg(struct map_session_data *sd, int item_id) @@ -219,7 +219,7 @@ int pet_hungry(int tid, int64 tick, int id, intptr_t data) { pd->pet.intimate = 0; pd->status.speed = pd->db->status.speed; } - status_calc_pet(pd, 0); + status_calc_pet(pd, SCO_NONE); clif->send_petdata(sd,pd,1,pd->pet.intimate); } clif->send_petdata(sd,pd,2,pd->pet.hungry); @@ -304,7 +304,7 @@ int pet_return_egg(struct map_session_data *sd, struct pet_data *pd) pd->pet.incuvate = 1; unit->free(&pd->bl,CLR_OUTSIGHT); - status_calc_pc(sd,0); + status_calc_pc(sd,SCO_NONE); sd->status.pet_id = 0; return 1; @@ -360,14 +360,14 @@ int pet_data_init(struct map_session_data *sd, struct s_pet *petinfo) pd->bl.y = pd->ud.to_y; map->addiddb(&pd->bl); - status_calc_pet(pd,1); + status_calc_pet(pd,SCO_FIRST); pd->last_thinktime = timer->gettick(); pd->state.skillbonus = 0; if( battle_config.pet_status_support ) script->run(pet->db[i].pet_script,0,sd->bl.id,0); if( pd->petDB && pd->petDB->equip_script ) - status_calc_pc(sd,0); + status_calc_pc(sd,SCO_NONE); if( battle_config.pet_hungry_delay_rate != 100 ) interval = (pd->petDB->hungry_delay*battle_config.pet_hungry_delay_rate)/100; @@ -703,7 +703,7 @@ int pet_unequipitem(struct map_session_data *sd, struct pet_data *pd) { if( pd->state.skillbonus ) { pd->state.skillbonus = 0; - status_calc_pc(sd,0); + status_calc_pc(sd,SCO_NONE); } if( pd->s_skill && pd->s_skill->timer != INVALID_TIMER ) { @@ -759,7 +759,7 @@ int pet_food(struct map_session_data *sd, struct pet_data *pd) } else if( pd->pet.intimate > 1000 ) pd->pet.intimate = 1000; - status_calc_pet(pd, 0); + status_calc_pet(pd, SCO_NONE); pd->pet.hungry += pd->petDB->fullness; if( pd->pet.hungry > 100 ) pd->pet.hungry = 100; @@ -1062,7 +1062,7 @@ int pet_skill_bonus_timer(int tid, int64 tick, int id, intptr_t data) { if (pd->state.skillbonus != bonus) { pd->state.skillbonus = bonus; - status_calc_pc(sd, 0); + status_calc_pc(sd, SCO_NONE); } // wait for the next timer pd->bonus->timer=timer->add(tick+duration,pet->skill_bonus_timer,sd->bl.id,0); diff --git a/src/map/script.c b/src/map/script.c index 3b0557235..8fd7f425c 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -12099,7 +12099,7 @@ BUILDIN(nude) } if( calcflag ) - status_calc_pc(sd,0); + status_calc_pc(sd,SCO_NONE); return true; } @@ -12425,9 +12425,9 @@ BUILDIN(npcwalkto) { if( nd ) { unit->bl2ud2(&nd->bl); // ensure nd->ud is safe to edit if (!nd->status.hp) { - status_calc_npc(nd, true); + status_calc_npc(nd, SCO_FIRST); } else { - status_calc_npc(nd, false); + status_calc_npc(nd, SCO_NONE); } unit->walktoxy(&nd->bl,x,y,0); } @@ -14967,9 +14967,9 @@ BUILDIN(unitskilluseid) { if( bl != NULL ) { if( bl->type == BL_NPC ) { if (!((TBL_NPC*)bl)->status.hp) { - status_calc_npc(((TBL_NPC*)bl), true); + status_calc_npc(((TBL_NPC*)bl), SCO_FIRST); } else { - status_calc_npc(((TBL_NPC*)bl), false); + status_calc_npc(((TBL_NPC*)bl), SCO_NONE); } } unit->skilluse_id(bl, target_id, skill_id, skill_lv); @@ -15001,9 +15001,9 @@ BUILDIN(unitskillusepos) { if( bl != NULL ) { if( bl->type == BL_NPC ) { if (!((TBL_NPC*)bl)->status.hp) { - status_calc_npc(((TBL_NPC*)bl), true); + status_calc_npc(((TBL_NPC*)bl), SCO_FIRST); } else { - status_calc_npc(((TBL_NPC*)bl), false); + status_calc_npc(((TBL_NPC*)bl), SCO_NONE); } } unit->skilluse_pos(bl, skill_x, skill_y, skill_id, skill_lv); @@ -17013,9 +17013,9 @@ BUILDIN(npcskill) { nd->stat_point = stat_point; if (!nd->status.hp) { - status_calc_npc(nd, true); + status_calc_npc(nd, SCO_FIRST); } else { - status_calc_npc(nd, false); + status_calc_npc(nd, SCO_NONE); } if (skill->get_inf(skill_id)&INF_GROUND_SKILL) { diff --git a/src/map/status.c b/src/map/status.c index c06de4dfe..1df98a957 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -1999,13 +1999,12 @@ void status_calc_misc(struct block_list *bl, struct status_data *st, int level) //Skotlex: Calculates the initial status for the given mob //first will only be false when the mob leveled up or got a GuardUp level. -int status_calc_mob_(struct mob_data* md, bool first) { +int status_calc_mob_(struct mob_data* md, enum e_status_calc_opt opt) { struct status_data *mstatus; struct block_list *mbl = NULL; int flag=0; - if(first) - { //Set basic level on respawn. + if(opt&SCO_FIRST) { //Set basic level on respawn. if (md->level > 0 && md->level <= MAX_LEVEL && md->level != md->db->lv) ; else @@ -2036,7 +2035,7 @@ int status_calc_mob_(struct mob_data* md, bool first) { aFree(md->base_status); md->base_status = NULL; } - if(first) + if(opt&SCO_FIRST) memcpy(&md->status, &md->db->status, sizeof(struct status_data)); return 0; } @@ -2160,18 +2159,18 @@ int status_calc_mob_(struct mob_data* md, bool first) { } } - if( first ) //Initial battle status + if( opt&SCO_FIRST ) //Initial battle status memcpy(&md->status, mstatus, sizeof(struct status_data)); return 1; } //Skotlex: Calculates the stats of the given pet. -int status_calc_pet_(struct pet_data *pd, bool first) +int status_calc_pet_(struct pet_data *pd, enum e_status_calc_opt opt) { nullpo_ret(pd); - if (first) { + if (opt&SCO_FIRST) { memcpy(&pd->status, &pd->db->status, sizeof(struct status_data)); pd->status.mode = MD_CANMOVE; // pets discard all modes, except walking pd->status.speed = pd->petDB->speed; @@ -2189,10 +2188,10 @@ int status_calc_pet_(struct pet_data *pd, bool first) lv =sd->status.base_level*battle_config.pet_lv_rate/100; if (lv < 0) lv = 1; - if (lv != pd->pet.level || first) { + if (lv != pd->pet.level || opt&SCO_FIRST) { struct status_data *bstat = &pd->db->status, *pstatus = &pd->status; pd->pet.level = lv; - if (!first) //Lv Up animation + if (! (opt&SCO_FIRST) ) //Lv Up animation clif->misceffect(&pd->bl, 0); pstatus->rhw.atk = (bstat->rhw.atk*lv)/pd->db->lv; pstatus->rhw.atk2 = (bstat->rhw.atk2*lv)/pd->db->lv; @@ -2214,10 +2213,10 @@ int status_calc_pet_(struct pet_data *pd, bool first) status->calc_misc(&pd->bl, &pd->status, lv); - if (!first) //Not done the first time because the pet is not visible yet + if (! (opt&SCO_FIRST) ) //Not done the first time because the pet is not visible yet clif->send_petstatus(sd); } - } else if (first) { + } else if ( opt&SCO_FIRST ) { 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; @@ -2295,7 +2294,7 @@ unsigned int status_base_pc_maxsp(struct map_session_data* sd, struct status_dat //Calculates player data from scratch without counting SC adjustments. //Should be invoked whenever players raise stats, learn passive skills or change equipment. -int status_calc_pc_(struct map_session_data* sd, bool first) { +int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) { static int calculating = 0; //Check for recursive call preemption. [Skotlex] struct status_data *bstatus; // pointer to the player's base status const struct status_change *sc = &sd->sc; @@ -2317,7 +2316,7 @@ int status_calc_pc_(struct map_session_data* sd, bool first) { sd->max_weight = status->max_weight_base[pc->class2idx(sd->status.class_)]+sd->status.str*300; - if(first) { + if(opt&SCO_FIRST) { //Load Hp/SP from char-received data. sd->battle_status.hp = sd->status.hp; sd->battle_status.sp = sd->status.sp; @@ -2482,7 +2481,7 @@ int status_calc_pc_(struct map_session_data* sd, bool first) { bstatus->def += sd->inventory_data[index]->def; - if(first && sd->inventory_data[index]->equip_script) + if(opt&SCO_FIRST && sd->inventory_data[index]->equip_script) { //Execute equip-script on login script->run(sd->inventory_data[index]->equip_script,0,sd->bl.id,0); if (!calculating) @@ -2625,7 +2624,7 @@ int status_calc_pc_(struct map_session_data* sd, bool first) { if( k < map->list[sd->bl.m].zone->disabled_items_count ) continue; - if(first && data->equip_script) {//Execute equip-script on login + if(opt&SCO_FIRST && data->equip_script) {//Execute equip-script on login script->run(data->equip_script,0,sd->bl.id,0); if (!calculating) return 1; @@ -3135,11 +3134,11 @@ int status_calc_pc_(struct map_session_data* sd, bool first) { return 0; } -int status_calc_mercenary_(struct mercenary_data *md, bool first) { +int status_calc_mercenary_(struct mercenary_data *md, enum e_status_calc_opt opt) { struct status_data *mstatus = &md->base_status; struct s_mercenary *merc = &md->mercenary; - if( first ) { + if( opt&SCO_FIRST ) { memcpy(mstatus, &md->db->status, sizeof(struct status_data)); mstatus->mode = MD_CANMOVE|MD_CANATTACK; mstatus->hp = mstatus->max_hp; @@ -3154,7 +3153,7 @@ int status_calc_mercenary_(struct mercenary_data *md, bool first) { return 0; } -int status_calc_homunculus_(struct homun_data *hd, bool first) { +int status_calc_homunculus_(struct homun_data *hd, enum e_status_calc_opt opt) { struct status_data *hstatus = &hd->base_status; struct s_homunculus *hom = &hd->homunculus; int skill_lv; @@ -3167,7 +3166,7 @@ int status_calc_homunculus_(struct homun_data *hd, bool first) { hstatus->int_ = hom->int_ / 10; hstatus->luk = hom->luk / 10; - if (first) { //[orn] + if ( opt&SCO_FIRST ) { //[orn] const struct s_homunculus_db *db = hd->homunculusDB; hstatus->def_ele = db->element; hstatus->ele_lv = 1; @@ -3207,7 +3206,7 @@ int status_calc_homunculus_(struct homun_data *hd, bool first) { if((skill_lv = homun->checkskill(hd,HLIF_BRAIN)) > 0) hstatus->max_sp += (1 +skill_lv/2 -skill_lv/4 +skill_lv/5) * hstatus->max_sp / 100; - if (first) { + if ( opt&SCO_FIRST ) { hd->battle_status.hp = hom->hp; hd->battle_status.sp = hom->sp; } @@ -3231,7 +3230,7 @@ int status_calc_homunculus_(struct homun_data *hd, bool first) { return 1; } -int status_calc_elemental_(struct elemental_data *ed, bool first) { +int status_calc_elemental_(struct elemental_data *ed, enum e_status_calc_opt opt) { struct status_data *estatus = &ed->base_status; struct s_elemental *ele = &ed->elemental; struct map_session_data *sd = ed->master; @@ -3239,7 +3238,7 @@ int status_calc_elemental_(struct elemental_data *ed, bool first) { if( !sd ) return 0; - if( first ) { + if( opt&SCO_FIRST ) { memcpy(estatus, &ed->db->status, sizeof(struct status_data)); if( !ele->mode ) estatus->mode = EL_MODE_PASSIVE; @@ -3270,13 +3269,13 @@ int status_calc_elemental_(struct elemental_data *ed, bool first) { return 0; } -int status_calc_npc_(struct npc_data *nd, bool first) { +int status_calc_npc_(struct npc_data *nd, enum e_status_calc_opt opt) { struct status_data *nstatus = &nd->status; if (!nd) return 0; - if (first) { + if ( opt&SCO_FIRST ) { nstatus->hp = 1; nstatus->sp = 1; nstatus->max_hp = 1; @@ -3863,13 +3862,17 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag) { /// Also sends updates to the client wherever applicable. /// @param flag bitfield of values from enum scb_flag /// @param first if true, will cause status_calc_* functions to run their base status initialization code -void status_calc_bl_(struct block_list *bl, enum scb_flag flag, bool first) { +void status_calc_bl_(struct block_list *bl, enum scb_flag flag, enum e_status_calc_opt opt) { struct status_data bst; // previous battle status struct status_data *st; // pointer to current battle status if( bl->type == BL_PC && ((TBL_PC*)bl)->delayed_damage != 0 ) { - ((TBL_PC*)bl)->state.hold_recalc = 1; - return; + if( opt&SCO_FORCE ) + ((TBL_PC*)bl)->state.hold_recalc = 0;/* clear and move on */ + else { + ((TBL_PC*)bl)->state.hold_recalc = 1;/* flag and stop */ + return; + } } // remember previous values @@ -3878,25 +3881,25 @@ void status_calc_bl_(struct block_list *bl, enum scb_flag flag, bool first) { if( flag&SCB_BASE ) {// calculate the object's base status too switch( bl->type ) { - 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; + case BL_PC: status->calc_pc_(BL_CAST(BL_PC,bl), opt); break; + case BL_MOB: status->calc_mob_(BL_CAST(BL_MOB,bl), opt); break; + case BL_PET: status->calc_pet_(BL_CAST(BL_PET,bl), opt); break; + case BL_HOM: status->calc_homunculus_(BL_CAST(BL_HOM,bl), opt); break; + case BL_MER: status->calc_mercenary_(BL_CAST(BL_MER,bl), opt); break; + case BL_ELEM: status->calc_elemental_(BL_CAST(BL_ELEM,bl), opt); break; + case BL_NPC: status->calc_npc_(BL_CAST(BL_NPC,bl), opt); break; } } if( bl->type == BL_PET ) return; // pets are not affected by statuses - if( first && bl->type == BL_MOB ) + if( opt&SCO_FIRST && bl->type == BL_MOB ) return; // assume there will be no statuses active status->calc_bl_main(bl, flag); - if( first && bl->type == BL_HOM ) + if( opt&SCO_FIRST && bl->type == BL_HOM ) return; // client update handled by caller // compare against new values and send client updates diff --git a/src/map/status.h b/src/map/status.h index 254f3bfab..e588fbb3f 100644 --- a/src/map/status.h +++ b/src/map/status.h @@ -1627,6 +1627,12 @@ enum e_regen { RGN_SSP = 0x08, }; +enum e_status_calc_opt { + SCO_NONE = 0x0, + SCO_FIRST = 0x1, /* trigger the calculations that should take place only onspawn/once */ + SCO_FORCE = 0x2, /* only relevant to BL_PC types, ensures call bypasses the queue caused by delayed damage */ +}; + //Define to determine who gets HP/SP consumed on doing skills/etc. [Skotlex] #define BL_CONSUME (BL_PC|BL_HOM|BL_MER|BL_ELEM) //Define to determine who has regen @@ -1810,14 +1816,14 @@ struct status_change { #define status_change_end(bl,type,tid) status->change_end_(bl,type,tid,__FILE__,__LINE__) -#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) +#define status_calc_bl(bl, flag) status->calc_bl_(bl, (enum scb_flag)(flag), SCO_NONE) +#define status_calc_mob(md, opt) status->calc_bl_(&(md)->bl, SCB_ALL, opt) +#define status_calc_pet(pd, opt) status->calc_bl_(&(pd)->bl, SCB_ALL, opt) +#define status_calc_pc(sd, opt) status->calc_bl_(&(sd)->bl, SCB_ALL, opt) +#define status_calc_homunculus(hd, opt) status->calc_bl_(&(hd)->bl, SCB_ALL, opt) +#define status_calc_mercenary(md, opt) status->calc_bl_(&(md)->bl, SCB_ALL, opt) +#define status_calc_elemental(ed, opt) status->calc_bl_(&(ed)->bl, SCB_ALL, opt) +#define status_calc_npc(nd, opt) status->calc_bl_(&(nd)->bl, SCB_ALL, opt) // bonus values and upgrade chances for refining equipment struct s_refine_info { @@ -1911,13 +1917,13 @@ struct status_interface { int (*change_timer_sub) (struct block_list* bl, va_list ap); int (*change_clear) (struct block_list* bl, int type); int (*change_clear_buffs) (struct block_list* bl, int type); - void (*calc_bl_) (struct block_list *bl, enum scb_flag flag, bool first); - int (*calc_mob_) (struct mob_data* md, bool first); - int (*calc_pet_) (struct pet_data* pd, bool first); - int (*calc_pc_) (struct map_session_data* sd, bool first); - int (*calc_homunculus_) (struct homun_data *hd, bool first); - int (*calc_mercenary_) (struct mercenary_data *md, bool first); - int (*calc_elemental_) (struct elemental_data *ed, bool first); + void (*calc_bl_) (struct block_list *bl, enum scb_flag flag, enum e_status_calc_opt opt); + int (*calc_mob_) (struct mob_data* md, enum e_status_calc_opt opt); + int (*calc_pet_) (struct pet_data* pd, enum e_status_calc_opt opt); + int (*calc_pc_) (struct map_session_data* sd, enum e_status_calc_opt opt); + int (*calc_homunculus_) (struct homun_data *hd, enum e_status_calc_opt opt); + int (*calc_mercenary_) (struct mercenary_data *md, enum e_status_calc_opt opt); + int (*calc_elemental_) (struct elemental_data *ed, enum e_status_calc_opt opt); void (*calc_misc) (struct block_list *bl, struct status_data *status, int level); void (*calc_regen) (struct block_list *bl, struct status_data *st, struct regen_data *regen); void (*calc_regen_rate) (struct block_list *bl, struct regen_data *regen, struct status_change *sc); @@ -1943,7 +1949,7 @@ struct status_interface { void (*calc_sigma) (void); unsigned int (*base_pc_maxhp) (struct map_session_data *sd, struct status_data *st); unsigned int (*base_pc_maxsp) (struct map_session_data *sd, struct status_data *st); - int (*calc_npc_) (struct npc_data *nd, bool first); + int (*calc_npc_) (struct npc_data *nd, enum e_status_calc_opt opt); unsigned short (*calc_str) (struct block_list *bl, struct status_change *sc, int str); unsigned short (*calc_agi) (struct block_list *bl, struct status_change *sc, int agi); unsigned short (*calc_vit) (struct block_list *bl, struct status_change *sc, int vit); -- cgit v1.2.3-70-g09d2 From b6b3f58795288701d0e162d43fa6f0a47af913b3 Mon Sep 17 00:00:00 2001 From: Haru <haru@dotalux.com> Date: Sun, 4 May 2014 06:13:56 +0200 Subject: Fixed order of includes in all source files - Changed order according to the (upcoming) code style guidelines. - Fixes several issues caused by missing headers when their include order is changed or in plugins. Signed-off-by: Haru <haru@dotalux.com> --- src/char/char.c | 44 +++++----- src/char/char.h | 1 - src/char/int_auction.c | 25 +++--- src/char/int_elemental.c | 22 +++-- src/char/int_elemental.h | 2 +- src/char/int_guild.c | 24 ++--- src/char/int_guild.h | 3 - src/char/int_homun.c | 21 +++-- src/char/int_homun.h | 2 + src/char/int_mail.c | 20 +++-- src/char/int_mail.h | 3 + src/char/int_mercenary.c | 22 +++-- src/char/int_mercenary.h | 4 +- src/char/int_party.c | 25 +++--- src/char/int_party.h | 2 - src/char/int_pet.c | 22 +++-- src/char/int_quest.c | 22 ++--- src/char/int_storage.c | 22 +++-- src/char/inter.c | 43 ++++----- src/char/inter.h | 5 +- src/char/pincode.c | 11 ++- src/common/HPM.c | 31 ++++--- src/common/HPM.h | 6 +- src/common/HPMi.h | 16 +--- src/common/cbasetypes.h | 6 ++ src/common/conf.c | 3 + src/common/conf.h | 1 + src/common/console.c | 223 ++++++++++++++++++++++++----------------------- src/common/console.h | 21 +++-- src/common/core.c | 38 ++++---- src/common/core.h | 3 +- src/common/db.c | 10 ++- src/common/db.h | 3 +- src/common/des.c | 7 +- src/common/ers.c | 8 +- src/common/grfio.c | 17 ++-- src/common/malloc.c | 11 ++- src/common/mapindex.c | 15 ++-- src/common/md5calc.c | 8 +- src/common/mmo.h | 6 +- src/common/mutex.c | 5 +- src/common/mutex.h | 1 + src/common/nullpo.c | 6 +- src/common/random.c | 18 ++-- src/common/showmsg.c | 17 ++-- src/common/showmsg.h | 23 +++-- src/common/socket.c | 64 +++++++------- src/common/socket.h | 12 +-- src/common/spinlock.h | 9 +- src/common/sql.c | 12 ++- src/common/sql.h | 3 +- src/common/strlib.c | 13 +-- src/common/strlib.h | 15 ++-- src/common/sysinfo.c | 32 +++++-- src/common/sysinfo.h | 16 ---- src/common/thread.c | 31 ++++--- src/common/thread.h | 1 - src/common/timer.c | 19 ++-- src/common/utils.c | 36 ++++---- src/common/utils.h | 3 +- src/config/const.h | 7 -- src/config/renewal.h | 1 + src/login/account.h | 1 + src/login/account_sql.c | 17 ++-- src/login/ipban_sql.c | 14 +-- src/login/login.c | 21 +++-- src/login/login.h | 2 +- src/login/loginlog.h | 2 +- src/login/loginlog_sql.c | 9 +- src/map/HPMmap.c | 42 ++++----- src/map/atcommand.c | 67 +++++++------- src/map/atcommand.h | 2 +- src/map/battle.c | 61 +++++++------ src/map/battle.h | 2 +- src/map/battleground.c | 33 +++---- src/map/battleground.h | 2 +- src/map/buyingstore.c | 17 ++-- src/map/buyingstore.h | 5 ++ src/map/chat.c | 23 ++--- src/map/chat.h | 5 +- src/map/chrif.c | 35 ++++---- src/map/chrif.h | 4 +- src/map/clif.c | 83 +++++++++--------- src/map/clif.h | 9 +- src/map/date.c | 6 +- src/map/date.h | 2 + src/map/duel.c | 10 ++- src/map/duel.h | 4 + src/map/elemental.c | 54 ++++++------ src/map/elemental.h | 1 + src/map/guild.c | 47 +++++----- src/map/guild.h | 16 +--- src/map/homunculus.c | 56 ++++++------ src/map/homunculus.h | 3 +- src/map/instance.c | 34 ++++---- src/map/instance.h | 3 + src/map/intif.c | 51 ++++++----- src/map/intif.h | 13 +-- src/map/irc-bot.c | 22 ++--- src/map/irc-bot.h | 2 + src/map/itemdb.c | 27 +++--- src/map/itemdb.h | 5 +- src/map/log.c | 23 ++--- src/map/log.h | 5 +- src/map/mail.c | 16 ++-- src/map/mail.h | 6 +- src/map/map.c | 96 ++++++++++---------- src/map/map.h | 9 +- src/map/mapreg_sql.c | 14 +-- src/map/mercenary.c | 54 ++++++------ src/map/mercenary.h | 1 + src/map/mob.c | 69 ++++++++------- src/map/mob.h | 9 +- src/map/npc.c | 57 ++++++------ src/map/npc.h | 4 +- src/map/npc_chat.c | 26 +++--- src/map/party.c | 43 ++++----- src/map/party.h | 7 +- src/map/path.c | 17 ++-- src/map/path.h | 1 + src/map/pc.c | 59 +++++++------ src/map/pc.h | 29 +++--- src/map/pc_groups.c | 14 +-- src/map/pc_groups.h | 4 + src/map/pet.c | 48 +++++----- src/map/pet.h | 10 ++- src/map/quest.c | 45 +++++----- src/map/quest.h | 4 + src/map/script.c | 79 +++++++++-------- src/map/script.h | 12 +-- src/map/searchstore.c | 11 ++- src/map/searchstore.h | 6 ++ src/map/skill.c | 64 +++++++------- src/map/skill.h | 14 +-- src/map/status.c | 59 +++++++------ src/map/status.h | 16 ++-- src/map/storage.c | 32 +++---- src/map/storage.h | 5 +- src/map/trade.c | 24 ++--- src/map/unit.c | 63 ++++++------- src/map/unit.h | 12 ++- src/map/vending.c | 27 +++--- src/map/vending.h | 1 + src/tool/mapcache.c | 14 +-- 144 files changed, 1676 insertions(+), 1367 deletions(-) (limited to 'src/map/elemental.c') diff --git a/src/char/char.c b/src/char/char.c index 77e393c0d..6c0902644 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -2,7 +2,30 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams +#define HERCULES_CORE + +#include "../config/core.h" // CONSOLE_INPUT +#include "char.h" + +#include <signal.h> +#include <stdarg.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/types.h> +#include <time.h> + +#include "int_elemental.h" +#include "int_guild.h" +#include "int_homun.h" +#include "int_mercenary.h" +#include "int_party.h" +#include "int_storage.h" +#include "inter.h" +#include "pincode.h" +#include "../common/HPM.h" #include "../common/cbasetypes.h" +#include "../common/console.h" #include "../common/core.h" #include "../common/db.h" #include "../common/malloc.h" @@ -13,25 +36,6 @@ #include "../common/strlib.h" #include "../common/timer.h" #include "../common/utils.h" -#include "../common/console.h" -#include "../common/HPM.h" -#include "int_guild.h" -#include "int_homun.h" -#include "int_mercenary.h" -#include "int_elemental.h" -#include "int_party.h" -#include "int_storage.h" -#include "char.h" -#include "inter.h" -#include "pincode.h" - -#include <sys/types.h> -#include <time.h> -#include <signal.h> -#include <string.h> -#include <stdarg.h> -#include <stdio.h> -#include <stdlib.h> // private declarations #define CHAR_CONF_NAME "conf/char-server.conf" @@ -5497,7 +5501,7 @@ int do_init(int argc, char **argv) { Sql_HerculesUpdateCheck(sql_handle); #ifdef CONSOLE_INPUT - console->setSQL(sql_handle); + console->input->setSQL(sql_handle); #endif ShowStatus("The char-server is "CL_GREEN"ready"CL_RESET" (Server is listening on the port %d).\n\n", char_port); diff --git a/src/char/char.h b/src/char/char.h index 2928929de..09a78f6b9 100644 --- a/src/char/char.h +++ b/src/char/char.h @@ -5,7 +5,6 @@ #ifndef _COMMON_CHAR_H_ #define _COMMON_CHAR_H_ -#include "../config/core.h" #include "../common/core.h" // CORE_ST_LAST #include "../common/db.h" diff --git a/src/char/int_auction.c b/src/char/int_auction.c index 924930867..886b5be26 100644 --- a/src/char/int_auction.c +++ b/src/char/int_auction.c @@ -2,22 +2,25 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/mmo.h" -#include "../common/malloc.h" +#define HERCULES_CORE + +#include "int_auction.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "char.h" +#include "int_mail.h" +#include "inter.h" #include "../common/db.h" +#include "../common/malloc.h" +#include "../common/mmo.h" #include "../common/showmsg.h" #include "../common/socket.h" -#include "../common/strlib.h" #include "../common/sql.h" +#include "../common/strlib.h" #include "../common/timer.h" -#include "char.h" -#include "inter.h" -#include "int_mail.h" -#include "int_auction.h" - -#include <stdio.h> -#include <string.h> -#include <stdlib.h> static DBMap* auction_db_ = NULL; // int auction_id -> struct auction_data* diff --git a/src/char/int_elemental.c b/src/char/int_elemental.c index ed0c2a9ed..3a36e75a2 100644 --- a/src/char/int_elemental.c +++ b/src/char/int_elemental.c @@ -2,20 +2,24 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/mmo.h" -#include "../common/malloc.h" -#include "../common/strlib.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/utils.h" -#include "../common/sql.h" -#include "char.h" -#include "inter.h" +#define HERCULES_CORE + +#include "int_elemental.h" #include <stdio.h> #include <stdlib.h> #include <string.h> +#include "char.h" +#include "inter.h" +#include "../common/malloc.h" +#include "../common/mmo.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/sql.h" +#include "../common/strlib.h" +#include "../common/utils.h" + bool mapif_elemental_save(struct s_elemental* ele) { bool flag = true; diff --git a/src/char/int_elemental.h b/src/char/int_elemental.h index c90891fc4..c869e6fc2 100644 --- a/src/char/int_elemental.h +++ b/src/char/int_elemental.h @@ -4,7 +4,7 @@ #ifndef _CHAR_INT_ELEMENTAL_H_ #define _CHAR_INT_ELEMENTAL_H_ -struct s_elemental; +#include "../common/cbasetypes.h" void inter_elemental_sql_init(void); void inter_elemental_sql_final(void); diff --git a/src/char/int_guild.c b/src/char/int_guild.c index 895cbbb94..ffbe48e10 100644 --- a/src/char/int_guild.c +++ b/src/char/int_guild.c @@ -2,21 +2,25 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams +#define HERCULES_CORE + +#include "../config/core.h" // DBPATH +#include "int_guild.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "char.h" +#include "inter.h" #include "../common/cbasetypes.h" -#include "../common/mmo.h" -#include "../common/malloc.h" -#include "../common/socket.h" #include "../common/db.h" +#include "../common/malloc.h" +#include "../common/mmo.h" #include "../common/showmsg.h" +#include "../common/socket.h" #include "../common/strlib.h" #include "../common/timer.h" -#include "char.h" -#include "inter.h" -#include "int_guild.h" - -#include <string.h> -#include <stdio.h> -#include <stdlib.h> #define GS_MEMBER_UNMODIFIED 0x00 #define GS_MEMBER_MODIFIED 0x01 diff --git a/src/char/int_guild.h b/src/char/int_guild.h index 4eb7d310b..5e657ff06 100644 --- a/src/char/int_guild.h +++ b/src/char/int_guild.h @@ -20,9 +20,6 @@ enum { GS_REMOVE = 0x8000, }; -struct guild; -struct guild_castle; - int inter_guild_parse_frommap(int fd); int inter_guild_sql_init(void); void inter_guild_sql_final(void); diff --git a/src/char/int_homun.c b/src/char/int_homun.c index 143277f05..795a6b927 100644 --- a/src/char/int_homun.c +++ b/src/char/int_homun.c @@ -2,20 +2,23 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/mmo.h" -#include "../common/malloc.h" -#include "../common/strlib.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/utils.h" -#include "../common/sql.h" -#include "char.h" -#include "inter.h" +#define HERCULES_CORE + +#include "int_homun.h" #include <stdio.h> #include <stdlib.h> #include <string.h> +#include "char.h" +#include "inter.h" +#include "../common/malloc.h" +#include "../common/mmo.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/sql.h" +#include "../common/strlib.h" +#include "../common/utils.h" int inter_homunculus_sql_init(void) { diff --git a/src/char/int_homun.h b/src/char/int_homun.h index 561dc848f..9477f4f03 100644 --- a/src/char/int_homun.h +++ b/src/char/int_homun.h @@ -4,6 +4,8 @@ #ifndef _CHAR_INT_HOMUN_H_ #define _CHAR_INT_HOMUN_H_ +#include "../common/cbasetypes.h" + struct s_homunculus; int inter_homunculus_sql_init(void); diff --git a/src/char/int_mail.c b/src/char/int_mail.c index 826771676..86a36d59f 100644 --- a/src/char/int_mail.c +++ b/src/char/int_mail.c @@ -2,19 +2,23 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/mmo.h" +#define HERCULES_CORE + +#include "int_mail.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "char.h" +#include "inter.h" #include "../common/malloc.h" +#include "../common/mmo.h" #include "../common/showmsg.h" #include "../common/socket.h" -#include "../common/strlib.h" #include "../common/sql.h" +#include "../common/strlib.h" #include "../common/timer.h" -#include "char.h" -#include "inter.h" - -#include <stdio.h> -#include <string.h> -#include <stdlib.h> static int mail_fromsql(int char_id, struct mail_data* md) { diff --git a/src/char/int_mail.h b/src/char/int_mail.h index 7c06cdc1f..824ba48a3 100644 --- a/src/char/int_mail.h +++ b/src/char/int_mail.h @@ -4,6 +4,9 @@ #ifndef _CHAR_INT_MAIL_H_ #define _CHAR_INT_MAIL_H_ +struct item; +struct mail_message; + int inter_mail_parse_frommap(int fd); void mail_sendmail(int send_id, const char* send_name, int dest_id, const char* dest_name, const char* title, const char* body, int zeny, struct item *item); diff --git a/src/char/int_mercenary.c b/src/char/int_mercenary.c index aecb3844a..1dffb656c 100644 --- a/src/char/int_mercenary.c +++ b/src/char/int_mercenary.c @@ -2,20 +2,24 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/mmo.h" -#include "../common/malloc.h" -#include "../common/strlib.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/utils.h" -#include "../common/sql.h" -#include "char.h" -#include "inter.h" +#define HERCULES_CORE + +#include "int_mercenary.h" #include <stdio.h> #include <stdlib.h> #include <string.h> +#include "char.h" +#include "inter.h" +#include "../common/malloc.h" +#include "../common/mmo.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/sql.h" +#include "../common/strlib.h" +#include "../common/utils.h" + bool mercenary_owner_fromsql(int char_id, struct mmo_charstatus *status) { char* data; diff --git a/src/char/int_mercenary.h b/src/char/int_mercenary.h index b614b8cf7..195a83b34 100644 --- a/src/char/int_mercenary.h +++ b/src/char/int_mercenary.h @@ -4,7 +4,9 @@ #ifndef _CHAR_INT_MERCENARY_H_ #define _CHAR_INT_MERCENARY_H_ -struct s_mercenary; +#include "../common/cbasetypes.h" + +struct mmo_charstatus; int inter_mercenary_sql_init(void); void inter_mercenary_sql_final(void); diff --git a/src/char/int_party.c b/src/char/int_party.c index 7c328c452..3e4a743d6 100644 --- a/src/char/int_party.c +++ b/src/char/int_party.c @@ -2,23 +2,26 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/mmo.h" -#include "../common/db.h" -#include "../common/malloc.h" -#include "../common/strlib.h" -#include "../common/socket.h" -#include "../common/showmsg.h" -#include "../common/mapindex.h" -#include "../common/sql.h" -#include "char.h" -#include "inter.h" +#define HERCULES_CORE + #include "int_party.h" #include <stdio.h> #include <stdlib.h> #include <string.h> +#include "char.h" +#include "inter.h" +#include "../common/cbasetypes.h" +#include "../common/db.h" +#include "../common/malloc.h" +#include "../common/mapindex.h" +#include "../common/mmo.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/sql.h" +#include "../common/strlib.h" + struct party_data { struct party party; unsigned int min_lv, max_lv; diff --git a/src/char/int_party.h b/src/char/int_party.h index 84f00635a..098c1e9a9 100644 --- a/src/char/int_party.h +++ b/src/char/int_party.h @@ -14,8 +14,6 @@ enum { PS_BREAK = 0x20, //Specify that this party must be deleted. }; -struct party; - int inter_party_parse_frommap(int fd); int inter_party_sql_init(void); void inter_party_sql_final(void); diff --git a/src/char/int_pet.c b/src/char/int_pet.c index 25f00e6f0..29c40eff9 100644 --- a/src/char/int_pet.c +++ b/src/char/int_pet.c @@ -2,20 +2,24 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/mmo.h" -#include "../common/malloc.h" -#include "../common/socket.h" -#include "../common/strlib.h" -#include "../common/showmsg.h" -#include "../common/utils.h" -#include "../common/sql.h" -#include "char.h" -#include "inter.h" +#define HERCULES_CORE + +#include "int_pet.h" #include <stdio.h> #include <stdlib.h> #include <string.h> +#include "char.h" +#include "inter.h" +#include "../common/malloc.h" +#include "../common/mmo.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/sql.h" +#include "../common/strlib.h" +#include "../common/utils.h" + struct s_pet *pet_pt; //--------------------------------------------------------- diff --git a/src/char/int_quest.c b/src/char/int_quest.c index 061dd89d9..61b43c57d 100644 --- a/src/char/int_quest.c +++ b/src/char/int_quest.c @@ -2,23 +2,25 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/mmo.h" +#define HERCULES_CORE + +#include "int_quest.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "char.h" +#include "inter.h" #include "../common/db.h" #include "../common/malloc.h" +#include "../common/mmo.h" #include "../common/showmsg.h" #include "../common/socket.h" -#include "../common/strlib.h" #include "../common/sql.h" +#include "../common/strlib.h" #include "../common/timer.h" -#include "char.h" -#include "inter.h" -#include "int_quest.h" - -#include <stdio.h> -#include <string.h> -#include <stdlib.h> - /** * Loads the entire questlog for a character. * diff --git a/src/char/int_storage.c b/src/char/int_storage.c index 966e61bb3..bf7b76da0 100644 --- a/src/char/int_storage.c +++ b/src/char/int_storage.c @@ -2,19 +2,23 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/mmo.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/strlib.h" // StringBuf -#include "../common/sql.h" -#include "char.h" -#include "inter.h" +#define HERCULES_CORE + +#include "../config/core.h" // GP_BOUND_ITEMS +#include "int_storage.h" #include <stdio.h> -#include <string.h> #include <stdlib.h> +#include <string.h> +#include "char.h" +#include "inter.h" +#include "../common/malloc.h" +#include "../common/mmo.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/sql.h" +#include "../common/strlib.h" // StringBuf #define STORAGE_MEMINC 16 diff --git a/src/char/inter.c b/src/char/inter.c index c48b26fdd..8b6368e9d 100644 --- a/src/char/inter.c +++ b/src/char/inter.c @@ -2,33 +2,34 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/mmo.h" -#include "../common/db.h" -#include "../common/malloc.h" -#include "../common/strlib.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/timer.h" -#include "char.h" +#define HERCULES_CORE + #include "inter.h" -#include "int_party.h" -#include "int_guild.h" -#include "int_storage.h" -#include "int_pet.h" -#include "int_homun.h" -#include "int_mercenary.h" -#include "int_mail.h" -#include "int_auction.h" -#include "int_quest.h" -#include "int_elemental.h" +#include <errno.h> #include <stdio.h> -#include <string.h> #include <stdlib.h> -#include <errno.h> - +#include <string.h> #include <sys/stat.h> // for stat/lstat/fstat - [Dekamaster/Ultimate GM Tool] +#include "char.h" +#include "int_auction.h" +#include "int_elemental.h" +#include "int_guild.h" +#include "int_homun.h" +#include "int_mail.h" +#include "int_mercenary.h" +#include "int_party.h" +#include "int_pet.h" +#include "int_quest.h" +#include "int_storage.h" +#include "../common/db.h" +#include "../common/malloc.h" +#include "../common/mmo.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/timer.h" #define WISDATA_TTL (60*1000) //Wis data Time To Live (60 seconds) #define WISDELLIST_MAX 256 // Number of elements in the list Delete data Wis diff --git a/src/char/inter.h b/src/char/inter.h index 25b0c2a96..5e655237e 100644 --- a/src/char/inter.h +++ b/src/char/inter.h @@ -5,9 +5,10 @@ #ifndef _CHAR_INTER_H_ #define _CHAR_INTER_H_ -struct accreg; -#include "../common/sql.h" #include "char.h" +#include "../common/sql.h" + +struct accreg; int inter_init_sql(const char *file); void inter_final(void); diff --git a/src/char/pincode.c b/src/char/pincode.c index d51953448..59182f12d 100644 --- a/src/char/pincode.c +++ b/src/char/pincode.c @@ -2,16 +2,19 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams +#define HERCULES_CORE + +#include "pincode.h" + +#include <stdlib.h> + +#include "char.h" #include "../common/cbasetypes.h" #include "../common/mmo.h" #include "../common/random.h" #include "../common/showmsg.h" #include "../common/socket.h" #include "../common/strlib.h" -#include "char.h" -#include "pincode.h" - -#include <stdlib.h> int enabled = PINCODE_OK; int changetime = 0; diff --git a/src/common/HPM.c b/src/common/HPM.c index 9ffce87de..00b92dc60 100644 --- a/src/common/HPM.c +++ b/src/common/HPM.c @@ -1,26 +1,31 @@ // Copyright (c) Hercules Dev Team, licensed under GNU GPL. // See the LICENSE file +#define HERCULES_CORE + +#include "../config/core.h" // CONSOLE_INPUT +#include "HPM.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + #include "../common/cbasetypes.h" -#include "../common/mmo.h" +#include "../common/conf.h" +#include "../common/console.h" #include "../common/core.h" #include "../common/malloc.h" +#include "../common/mmo.h" #include "../common/showmsg.h" #include "../common/socket.h" -#include "../common/timer.h" -#include "../common/conf.h" -#include "../common/utils.h" -#include "../common/console.h" -#include "../common/strlib.h" #include "../common/sql.h" +#include "../common/strlib.h" #include "../common/sysinfo.h" -#include "HPM.h" +#include "../common/timer.h" +#include "../common/utils.h" -#include <stdio.h> -#include <stdlib.h> -#include <string.h> #ifndef WIN32 -#include <unistd.h> +# include <unistd.h> #endif struct malloc_interface iMalloc_HPM; @@ -686,7 +691,7 @@ bool hplugins_parse_conf(const char *w1, const char *w2, enum HPluginConfType po void hplugins_share_defaults(void) { /* console */ #ifdef CONSOLE_INPUT - HPM->share(console->addCommand,"addCPCommand"); + HPM->share(console->input->addCommand,"addCPCommand"); #endif /* our own */ HPM->share(hplugins_addpacket,"addPacket"); @@ -755,7 +760,7 @@ void hpm_init(void) { HPM->symbol_defaults(); #ifdef CONSOLE_INPUT - console->addCommand("plugins",CPCMD_A(plugins)); + console->input->addCommand("plugins",CPCMD_A(plugins)); #endif return; } diff --git a/src/common/HPM.h b/src/common/HPM.h index 0f0df4cda..9c176cfd6 100644 --- a/src/common/HPM.h +++ b/src/common/HPM.h @@ -4,8 +4,12 @@ #ifndef _COMMON_HPM_H_ #define _COMMON_HPM_H_ -#include "../common/cbasetypes.h" +#ifndef HERCULES_CORE +#error You should never include HPM.h from a plugin. +#endif + #include "../common/HPMi.h" +#include "../common/cbasetypes.h" #ifdef WIN32 #ifndef WIN32_LEAN_AND_MEAN diff --git a/src/common/HPMi.h b/src/common/HPMi.h index 19206aeca..b98e87d90 100644 --- a/src/common/HPMi.h +++ b/src/common/HPMi.h @@ -5,8 +5,8 @@ #define _COMMON_HPMI_H_ #include "../common/cbasetypes.h" -#include "../common/core.h" #include "../common/console.h" +#include "../common/core.h" #include "../common/sql.h" struct script_state; @@ -20,18 +20,6 @@ struct map_session_data; #define HPExport #endif -#ifndef _COMMON_SHOWMSG_H_ - HPExport void (*ShowMessage) (const char *, ...); - HPExport void (*ShowStatus) (const char *, ...); - HPExport void (*ShowSQL) (const char *, ...); - HPExport void (*ShowInfo) (const char *, ...); - HPExport void (*ShowNotice) (const char *, ...); - HPExport void (*ShowWarning) (const char *, ...); - HPExport void (*ShowDebug) (const char *, ...); - HPExport void (*ShowError) (const char *, ...); - HPExport void (*ShowFatalError) (const char *, ...); -#endif - /* after */ #include "../common/showmsg.h" @@ -192,7 +180,7 @@ HPExport struct HPMi_interface { /* pc group permission */ void (*addPCGPermission) (unsigned int pluginID, char *name, unsigned int *mask); } HPMi_s; -#ifndef _COMMON_HPM_H_ +#ifndef HERCULES_CORE HPExport struct HPMi_interface *HPMi; #endif diff --git a/src/common/cbasetypes.h b/src/common/cbasetypes.h index f44e80413..da0d6b307 100644 --- a/src/common/cbasetypes.h +++ b/src/common/cbasetypes.h @@ -442,5 +442,11 @@ void SET_FUNCPOINTER(T1& var, T2 p) #define SET_FUNCPOINTER(var,p) ((var) = (p)) #endif +/* pointer size fix which fixes several gcc warnings */ +#ifdef __64BIT__ + #define __64BPTRSIZE(y) ((intptr)(y)) +#else + #define __64BPTRSIZE(y) (y) +#endif #endif /* _COMMON_CBASETYPES_H_ */ diff --git a/src/common/conf.c b/src/common/conf.c index b816b2f7f..46a034497 100644 --- a/src/common/conf.c +++ b/src/common/conf.c @@ -2,7 +2,10 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams +#define HERCULES_CORE + #include "conf.h" + #include "../../3rdparty/libconfig/libconfig.h" #include "../common/showmsg.h" // ShowError diff --git a/src/common/conf.h b/src/common/conf.h index 9aff3df47..e5b637e47 100644 --- a/src/common/conf.h +++ b/src/common/conf.h @@ -6,6 +6,7 @@ #define _COMMON_CONF_H_ #include "../common/cbasetypes.h" + #include "../../3rdparty/libconfig/libconfig.h" /** diff --git a/src/common/console.c b/src/common/console.c index d8f352c8a..6a82db555 100644 --- a/src/common/console.c +++ b/src/common/console.c @@ -2,42 +2,46 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams +#define HERCULES_CORE + +#include "../config/core.h" // CONSOLE_INPUT, MAX_CONSOLE_INPUT +#include "console.h" + +#include <stdio.h> +#include <stdlib.h> + #include "../common/cbasetypes.h" -#include "../common/showmsg.h" #include "../common/core.h" +#include "../common/showmsg.h" #include "../common/sysinfo.h" -#include "../config/core.h" -#include "console.h" #ifndef MINICORE - #include "../common/ers.h" - #include "../common/malloc.h" - #include "../common/atomic.h" - #include "../common/spinlock.h" - #include "../common/thread.h" - #include "../common/mutex.h" - #include "../common/timer.h" - #include "../common/strlib.h" - #include "../common/sql.h" +# include "../common/atomic.h" +# include "../common/ers.h" +# include "../common/malloc.h" +# include "../common/mutex.h" +# include "../common/spinlock.h" +# include "../common/sql.h" +# include "../common/strlib.h" +# include "../common/thread.h" +# include "../common/timer.h" #endif -#include <stdio.h> -#include <stdlib.h> #if !defined(WIN32) - #include <unistd.h> - #include <sys/time.h> +# include <sys/time.h> +# include <unistd.h> #else - #include "../common/winapi.h" // Console close event handling +# include "../common/winapi.h" // Console close event handling +# ifdef CONSOLE_INPUT +# include <conio.h> /* _kbhit() */ +# endif #endif +struct console_interface console_s; #ifdef CONSOLE_INPUT - #if defined(WIN32) - #include <conio.h> /* _kbhit() */ - #endif +struct console_input_interface console_input_s; #endif -struct console_interface console_s; - /*====================================== * CORE : Display title *--------------------------------------*/ @@ -116,12 +120,12 @@ CPCMD_C(mem_report,server) { **/ CPCMD(help) { unsigned int i = 0; - for ( i = 0; i < console->cmd_list_count; i++ ) { - if( console->cmd_list[i]->next_count ) { - ShowInfo("- '"CL_WHITE"%s"CL_RESET"' subs\n",console->cmd_list[i]->cmd); - console->parse_list_subs(console->cmd_list[i],2); + for ( i = 0; i < console->input->cmd_list_count; i++ ) { + if( console->input->cmd_list[i]->next_count ) { + ShowInfo("- '"CL_WHITE"%s"CL_RESET"' subs\n",console->input->cmd_list[i]->cmd); + console->input->parse_list_subs(console->input->cmd_list[i],2); } else { - ShowInfo("- '"CL_WHITE"%s"CL_RESET"'\n",console->cmd_list[i]->cmd); + ShowInfo("- '"CL_WHITE"%s"CL_RESET"'\n",console->input->cmd_list[i]->cmd); } } } @@ -144,7 +148,7 @@ CPCMD_C(skip,update) { ShowDebug("usage example: sql update skip 2013-02-14--16-15.sql\n"); return; } - Sql_HerculesUpdateSkip(console->SQL, line); + Sql_HerculesUpdateSkip(console->input->SQL, line); } /** @@ -206,7 +210,7 @@ void console_load_defaults(void) { unsigned int i, len = ARRAYLENGTH(default_list); struct CParseEntry *cmd; - RECREATE(console->cmds,struct CParseEntry *, len); + RECREATE(console->input->cmds,struct CParseEntry *, len); for(i = 0; i < len; i++) { CREATE(cmd, struct CParseEntry, 1); @@ -220,12 +224,12 @@ void console_load_defaults(void) { cmd->next_count = 0; - console->cmd_count++; - console->cmds[i] = cmd; + console->input->cmd_count++; + console->input->cmds[i] = cmd; default_list[i].self = cmd; if( !default_list[i].connect ) { - RECREATE(console->cmd_list,struct CParseEntry *, ++console->cmd_list_count); - console->cmd_list[console->cmd_list_count - 1] = cmd; + RECREATE(console->input->cmd_list,struct CParseEntry *, ++console->input->cmd_list_count); + console->input->cmd_list[console->input->cmd_list_count - 1] = cmd; } } @@ -233,11 +237,11 @@ void console_load_defaults(void) { unsigned int k; if( !default_list[i].connect ) continue; - for(k = 0; k < console->cmd_count; k++) { - if( strcmpi(default_list[i].connect,console->cmds[k]->cmd) == 0 ) { + for(k = 0; k < console->input->cmd_count; k++) { + if( strcmpi(default_list[i].connect,console->input->cmds[k]->cmd) == 0 ) { cmd = default_list[i].self; - RECREATE(console->cmds[k]->u.next, struct CParseEntry *, ++console->cmds[k]->next_count); - console->cmds[k]->u.next[console->cmds[k]->next_count - 1] = cmd; + RECREATE(console->input->cmds[k]->u.next, struct CParseEntry *, ++console->input->cmds[k]->next_count); + console->input->cmds[k]->u.next[console->input->cmds[k]->next_count - 1] = cmd; break; } } @@ -256,23 +260,23 @@ void console_parse_create(char *name, CParseFunc func) { safestrncpy(sublist, name, CP_CMD_LENGTH * 5); tok = strtok(sublist,":"); - for ( i = 0; i < console->cmd_list_count; i++ ) { - if( strcmpi(tok,console->cmd_list[i]->cmd) == 0 ) + for ( i = 0; i < console->input->cmd_list_count; i++ ) { + if( strcmpi(tok,console->input->cmd_list[i]->cmd) == 0 ) break; } - if( i == console->cmd_list_count ) { - RECREATE(console->cmds,struct CParseEntry *, ++console->cmd_count); + if( i == console->input->cmd_list_count ) { + RECREATE(console->input->cmds,struct CParseEntry *, ++console->input->cmd_count); CREATE(cmd, struct CParseEntry, 1); safestrncpy(cmd->cmd, tok, CP_CMD_LENGTH); cmd->next_count = 0; - console->cmds[console->cmd_count - 1] = cmd; - RECREATE(console->cmd_list,struct CParseEntry *, ++console->cmd_list_count); - console->cmd_list[console->cmd_list_count - 1] = cmd; - i = console->cmd_list_count - 1; + console->input->cmds[console->input->cmd_count - 1] = cmd; + RECREATE(console->input->cmd_list,struct CParseEntry *, ++console->input->cmd_list_count); + console->input->cmd_list[console->input->cmd_list_count - 1] = cmd; + i = console->input->cmd_list_count - 1; } - cmd = console->cmd_list[i]; + cmd = console->input->cmd_list[i]; while( ( tok = strtok(NULL, ":") ) != NULL ) { for(i = 0; i < cmd->next_count; i++) { @@ -281,13 +285,13 @@ void console_parse_create(char *name, CParseFunc func) { } if ( i == cmd->next_count ) { - RECREATE(console->cmds,struct CParseEntry *, ++console->cmd_count); - CREATE(console->cmds[console->cmd_count-1], struct CParseEntry, 1); - safestrncpy(console->cmds[console->cmd_count-1]->cmd, tok, CP_CMD_LENGTH); - console->cmds[console->cmd_count-1]->next_count = 0; + RECREATE(console->input->cmds,struct CParseEntry *, ++console->input->cmd_count); + CREATE(console->input->cmds[console->input->cmd_count-1], struct CParseEntry, 1); + safestrncpy(console->input->cmds[console->input->cmd_count-1]->cmd, tok, CP_CMD_LENGTH); + console->input->cmds[console->input->cmd_count-1]->next_count = 0; RECREATE(cmd->u.next, struct CParseEntry *, ++cmd->next_count); - cmd->u.next[cmd->next_count - 1] = console->cmds[console->cmd_count-1]; - cmd = console->cmds[console->cmd_count-1]; + cmd->u.next[cmd->next_count - 1] = console->input->cmds[console->input->cmd_count-1]; + cmd = console->input->cmds[console->input->cmd_count-1]; continue; } @@ -302,7 +306,7 @@ void console_parse_list_subs(struct CParseEntry *cmd, unsigned char depth) { memset(msg, '-', depth); snprintf(msg + depth,CP_CMD_LENGTH * 2, " '"CL_WHITE"%s"CL_RESET"'",cmd->u.next[i]->cmd); ShowInfo("%s subs\n",msg); - console->parse_list_subs(cmd->u.next[i],depth + 1); + console->input->parse_list_subs(cmd->u.next[i],depth + 1); } else { memset(msg, '-', depth); snprintf(msg + depth,CP_CMD_LENGTH * 2, " %s",cmd->u.next[i]->cmd); @@ -320,21 +324,21 @@ void console_parse_sub(char *line) { memcpy(bline, line, 200); tok = strtok(line, " "); - for ( i = 0; i < console->cmd_list_count; i++ ) { - if( strcmpi(tok,console->cmd_list[i]->cmd) == 0 ) + for ( i = 0; i < console->input->cmd_list_count; i++ ) { + if( strcmpi(tok,console->input->cmd_list[i]->cmd) == 0 ) break; } - if( i == console->cmd_list_count ) { + if( i == console->input->cmd_list_count ) { ShowError("'"CL_WHITE"%s"CL_RESET"' is not a known command, type '"CL_WHITE"help"CL_RESET"' to list all commands\n",line); return; } - cmd = console->cmd_list[i]; + cmd = console->input->cmd_list[i]; len += snprintf(sublist,CP_CMD_LENGTH * 5,"%s", cmd->cmd) + 1; - if( cmd->next_count == 0 && console->cmd_list[i]->u.func ) { + if( cmd->next_count == 0 && console->input->cmd_list[i]->u.func ) { char *r = NULL; if( (tok = strtok(NULL, " ")) ) { r = bline; @@ -351,7 +355,7 @@ void console_parse_sub(char *line) { if( strcmpi("help",tok) == 0 ) { if( cmd->next_count ) { ShowInfo("- '"CL_WHITE"%s"CL_RESET"' subs\n",sublist); - console->parse_list_subs(cmd,2); + console->input->parse_list_subs(cmd,2); } else { ShowError("'"CL_WHITE"%s"CL_RESET"' doesn't possess any subcommands\n",sublist); } @@ -392,95 +396,95 @@ void console_parse(char* line) { } void *cThread_main(void *x) { - while( console->ptstate ) {/* loopx */ - if( console->key_pressed() ) { + while( console->input->ptstate ) {/* loopx */ + if( console->input->key_pressed() ) { char input[MAX_CONSOLE_INPUT]; - console->parse(input); + console->input->parse(input); if( input[0] != '\0' ) {/* did we get something? */ - EnterSpinLock(&console->ptlock); + EnterSpinLock(&console->input->ptlock); if( cinput.count == CONSOLE_PARSE_SIZE ) { - LeaveSpinLock(&console->ptlock); + LeaveSpinLock(&console->input->ptlock); continue;/* drop */ } safestrncpy(cinput.queue[cinput.count++],input,MAX_CONSOLE_INPUT); - LeaveSpinLock(&console->ptlock); + LeaveSpinLock(&console->input->ptlock); } } - ramutex_lock( console->ptmutex ); - racond_wait( console->ptcond, console->ptmutex, -1 ); - ramutex_unlock( console->ptmutex ); + ramutex_lock( console->input->ptmutex ); + racond_wait( console->input->ptcond, console->input->ptmutex, -1 ); + ramutex_unlock( console->input->ptmutex ); } return NULL; } int console_parse_timer(int tid, int64 tick, int id, intptr_t data) { int i; - EnterSpinLock(&console->ptlock); + EnterSpinLock(&console->input->ptlock); for(i = 0; i < cinput.count; i++) { - console->parse_sub(cinput.queue[i]); + console->input->parse_sub(cinput.queue[i]); } cinput.count = 0; - LeaveSpinLock(&console->ptlock); - racond_signal(console->ptcond); + LeaveSpinLock(&console->input->ptlock); + racond_signal(console->input->ptcond); return 0; } void console_parse_final(void) { - if( console->ptstate ) { - InterlockedDecrement(&console->ptstate); - racond_signal(console->ptcond); + if( console->input->ptstate ) { + InterlockedDecrement(&console->input->ptstate); + racond_signal(console->input->ptcond); /* wait for thread to close */ - rathread_wait(console->pthread, NULL); + rathread_wait(console->input->pthread, NULL); - racond_destroy(console->ptcond); - ramutex_destroy(console->ptmutex); + racond_destroy(console->input->ptcond); + ramutex_destroy(console->input->ptmutex); } } void console_parse_init(void) { cinput.count = 0; - console->ptstate = 1; + console->input->ptstate = 1; - InitializeSpinLock(&console->ptlock); + InitializeSpinLock(&console->input->ptlock); - console->ptmutex = ramutex_create(); - console->ptcond = racond_create(); + console->input->ptmutex = ramutex_create(); + console->input->ptcond = racond_create(); - if( (console->pthread = rathread_create(console->pthread_main, NULL)) == NULL ){ + if( (console->input->pthread = rathread_create(console->input->pthread_main, NULL)) == NULL ){ ShowFatalError("console_parse_init: failed to spawn console_parse thread.\n"); exit(EXIT_FAILURE); } - timer->add_func_list(console->parse_timer, "console_parse_timer"); - timer->add_interval(timer->gettick() + 1000, console->parse_timer, 0, 0, 500);/* start listening in 1s; re-try every 0.5s */ + timer->add_func_list(console->input->parse_timer, "console_parse_timer"); + timer->add_interval(timer->gettick() + 1000, console->input->parse_timer, 0, 0, 500);/* start listening in 1s; re-try every 0.5s */ } void console_setSQL(Sql *SQL_handle) { - console->SQL = SQL_handle; + console->input->SQL = SQL_handle; } #endif /* CONSOLE_INPUT */ void console_init (void) { #ifdef CONSOLE_INPUT - console->cmd_count = console->cmd_list_count = 0; - console->load_defaults(); - console->parse_init(); + console->input->cmd_count = console->input->cmd_list_count = 0; + console->input->load_defaults(); + console->input->parse_init(); #endif } void console_final(void) { #ifdef CONSOLE_INPUT unsigned int i; - console->parse_final(); - for( i = 0; i < console->cmd_count; i++ ) { - if( console->cmds[i]->next_count ) - aFree(console->cmds[i]->u.next); - aFree(console->cmds[i]); + console->input->parse_final(); + for( i = 0; i < console->input->cmd_count; i++ ) { + if( console->input->cmds[i]->next_count ) + aFree(console->input->cmds[i]->u.next); + aFree(console->input->cmds[i]); } - aFree(console->cmds); - aFree(console->cmd_list); + aFree(console->input->cmds); + aFree(console->input->cmd_list); #endif } void console_defaults(void) { @@ -489,17 +493,20 @@ void console_defaults(void) { console->final = console_final; console->display_title = display_title; #ifdef CONSOLE_INPUT - console->parse_init = console_parse_init; - console->parse_final = console_parse_final; - console->parse_timer = console_parse_timer; - console->pthread_main = cThread_main; - console->parse = console_parse; - console->parse_sub = console_parse_sub; - console->key_pressed = console_parse_key_pressed; - console->load_defaults = console_load_defaults; - console->parse_list_subs = console_parse_list_subs; - console->addCommand = console_parse_create; - console->setSQL = console_setSQL; - console->SQL = NULL; + console->input = &console_input_s; + console->input->parse_init = console_parse_init; + console->input->parse_final = console_parse_final; + console->input->parse_timer = console_parse_timer; + console->input->pthread_main = cThread_main; + console->input->parse = console_parse; + console->input->parse_sub = console_parse_sub; + console->input->key_pressed = console_parse_key_pressed; + console->input->load_defaults = console_load_defaults; + console->input->parse_list_subs = console_parse_list_subs; + console->input->addCommand = console_parse_create; + console->input->setSQL = console_setSQL; + console->input->SQL = NULL; +#else + console->input = NULL; #endif } diff --git a/src/common/console.h b/src/common/console.h index 3d19ddc9d..d2c58f978 100644 --- a/src/common/console.h +++ b/src/common/console.h @@ -4,11 +4,13 @@ #ifndef _COMMON_CONSOLE_H_ #define _COMMON_CONSOLE_H_ -#include "../common/thread.h" +#include "../config/core.h" // MAX_CONSOLE_INPUT + +#include "../common/cbasetypes.h" #include "../common/mutex.h" #include "../common/spinlock.h" #include "../common/sql.h" -#include "../config/core.h" +#include "../common/thread.h" /** * Queue Max @@ -47,11 +49,8 @@ struct { unsigned short count; } cinput; -struct console_interface { - void (*init) (void); - void (*final) (void); - void (*display_title) (void); #ifdef CONSOLE_INPUT +struct console_input_interface { /* vars */ SPIN_LOCK ptlock;/* parse thread lock */ rAthread pthread;/* parse thread */ @@ -77,7 +76,17 @@ struct console_interface { void (*parse_list_subs) (struct CParseEntry *cmd, unsigned char depth); void (*addCommand) (char *name, CParseFunc func); void (*setSQL) (Sql *SQL_handle); +}; +#else +struct console_input_interface; #endif + +struct console_interface { + void (*init) (void); + void (*final) (void); + void (*display_title) (void); + + struct console_input_interface *input; }; struct console_interface *console; diff --git a/src/common/core.c b/src/common/core.c index 49b272488..85f824866 100644 --- a/src/common/core.c +++ b/src/common/core.c @@ -2,36 +2,40 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/mmo.h" -#include "../common/showmsg.h" -#include "../common/malloc.h" -#include "../common/strlib.h" +#define HERCULES_CORE + +#include "../config/core.h" #include "core.h" + +#include "../common/cbasetypes.h" #include "../common/console.h" +#include "../common/malloc.h" +#include "../common/mmo.h" #include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" #include "../common/sysinfo.h" #ifndef MINICORE - #include "../common/db.h" - #include "../common/socket.h" - #include "../common/timer.h" - #include "../common/thread.h" - #include "../common/sql.h" - #include "../config/core.h" - #include "../common/HPM.h" - #include "../common/utils.h" - #include "../common/conf.h" - #include "../common/ers.h" +# include "../common/HPM.h" +# include "../common/conf.h" +# include "../common/db.h" +# include "../common/ers.h" +# include "../common/socket.h" +# include "../common/sql.h" +# include "../common/thread.h" +# include "../common/timer.h" +# include "../common/utils.h" #endif +#include <signal.h> #include <stdio.h> #include <stdlib.h> -#include <signal.h> #include <string.h> #ifndef _WIN32 -#include <unistd.h> +# include <unistd.h> #else -#include "../common/winapi.h" // Console close event handling +# include "../common/winapi.h" // Console close event handling #endif /// Called when a terminate signal is received. diff --git a/src/common/core.h b/src/common/core.h index e9f7c5961..ba75e6b01 100644 --- a/src/common/core.h +++ b/src/common/core.h @@ -7,11 +7,10 @@ #include "../common/db.h" #include "../common/mmo.h" -#include "../config/core.h" /* so that developers with --enable-debug can raise signals from any section of the code they'd like */ #ifdef DEBUG - #include <signal.h> +# include <signal.h> #endif extern int arg_c; diff --git a/src/common/db.c b/src/common/db.c index 8d6b08815..1781aa96f 100644 --- a/src/common/db.c +++ b/src/common/db.c @@ -67,14 +67,18 @@ * @encoding US-ASCII * @see #db.h \*****************************************************************************/ + +#define HERCULES_CORE + +#include "db.h" + #include <stdio.h> #include <stdlib.h> -#include "db.h" -#include "../common/mmo.h" +#include "../common/ers.h" #include "../common/malloc.h" +#include "../common/mmo.h" #include "../common/showmsg.h" -#include "../common/ers.h" #include "../common/strlib.h" /*****************************************************************************\ diff --git a/src/common/db.h b/src/common/db.h index 67abe6f19..0d2548806 100644 --- a/src/common/db.h +++ b/src/common/db.h @@ -42,9 +42,10 @@ #ifndef _COMMON_DB_H_ #define _COMMON_DB_H_ -#include "../common/cbasetypes.h" #include <stdarg.h> +#include "../common/cbasetypes.h" + /*****************************************************************************\ * (1) Section with public typedefs, enums, unions, structures and defines. * * DBRelease - Enumeration of release options. * diff --git a/src/common/des.c b/src/common/des.c index ed6d098dc..7f952be76 100644 --- a/src/common/des.c +++ b/src/common/des.c @@ -1,8 +1,11 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#include "../common/cbasetypes.h" -#include "../common/des.h" +#define HERCULES_CORE + +#include "des.h" + +#include "../common/cbasetypes.h" /// DES (Data Encryption Standard) algorithm, modified version. /// @see http://www.eathena.ws/board/index.php?autocom=bugtracker&showbug=5099. diff --git a/src/common/ers.c b/src/common/ers.c index 5a3d7314a..d9895e4f2 100644 --- a/src/common/ers.c +++ b/src/common/ers.c @@ -39,14 +39,18 @@ * @encoding US-ASCII * * @see common#ers.h * \*****************************************************************************/ + +#define HERCULES_CORE + +#include "ers.h" + #include <stdlib.h> #include <string.h> #include "../common/cbasetypes.h" #include "../common/malloc.h" // CREATE, RECREATE, aMalloc, aFree -#include "../common/showmsg.h" // ShowMessage, ShowError, ShowFatalError, CL_BOLD, CL_NORMAL #include "../common/nullpo.h" -#include "ers.h" +#include "../common/showmsg.h" // ShowMessage, ShowError, ShowFatalError, CL_BOLD, CL_NORMAL #ifndef DISABLE_ERS diff --git a/src/common/grfio.c b/src/common/grfio.c index bde0ed720..1111fb3f3 100644 --- a/src/common/grfio.c +++ b/src/common/grfio.c @@ -2,13 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/des.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/utils.h" -#include "../common/nullpo.h" +#define HERCULES_CORE + #include "grfio.h" #include <stdio.h> @@ -17,6 +12,14 @@ #include <sys/stat.h> #include <zlib.h> +#include "../common/cbasetypes.h" +#include "../common/des.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" +#include "../common/utils.h" + //---------------------------- // file entry table struct //---------------------------- diff --git a/src/common/malloc.c b/src/common/malloc.c index 5b39cbab6..13cf0b5ce 100644 --- a/src/common/malloc.c +++ b/src/common/malloc.c @@ -2,16 +2,19 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/malloc.h" -#include "../common/core.h" -#include "../common/showmsg.h" -#include "../common/sysinfo.h" +#define HERCULES_CORE + +#include "malloc.h" #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> +#include "../common/core.h" +#include "../common/showmsg.h" +#include "../common/sysinfo.h" + struct malloc_interface iMalloc_s; ////////////// Memory Libraries ////////////////// diff --git a/src/common/mapindex.c b/src/common/mapindex.c index 3128a3cb0..5c69c7063 100644 --- a/src/common/mapindex.c +++ b/src/common/mapindex.c @@ -2,16 +2,19 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/mmo.h" -#include "../common/showmsg.h" -#include "../common/malloc.h" -#include "../common/strlib.h" -#include "../common/db.h" +#define HERCULES_CORE + #include "mapindex.h" -#include <string.h> #include <stdio.h> #include <stdlib.h> +#include <string.h> + +#include "../common/db.h" +#include "../common/malloc.h" +#include "../common/mmo.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" /* mapindex.c interface source */ struct mapindex_interface mapindex_s; diff --git a/src/common/md5calc.c b/src/common/md5calc.c index 05fde42cc..e7b506e27 100644 --- a/src/common/md5calc.c +++ b/src/common/md5calc.c @@ -6,11 +6,15 @@ * ***********************************************************/ -#include "../common/random.h" +#define HERCULES_CORE + #include "md5calc.h" -#include <string.h> + #include <stdio.h> #include <stdlib.h> +#include <string.h> + +#include "../common/random.h" #ifndef UINT_MAX #define UINT_MAX 4294967295U diff --git a/src/common/mmo.h b/src/common/mmo.h index d535d2874..1d826463e 100644 --- a/src/common/mmo.h +++ b/src/common/mmo.h @@ -5,10 +5,11 @@ #ifndef _COMMON_MMO_H_ #define _COMMON_MMO_H_ -#include "cbasetypes.h" -#include "../common/db.h" #include <time.h> +#include "../common/cbasetypes.h" +#include "../common/db.h" + // server->client protocol version // 0 - pre-? // 1 - ? - 0x196 @@ -96,6 +97,7 @@ //Official Limit: 2.1b ( the var that stores the money doesn't go much higher than this by default ) #define MAX_BANK_ZENY 2100000000 +#define MAX_LEVEL 175 #define MAX_FAME 1000000000 #define MAX_CART 100 #define MAX_SKILL 1478 diff --git a/src/common/mutex.c b/src/common/mutex.c index 0668dbc41..12524c3b7 100644 --- a/src/common/mutex.c +++ b/src/common/mutex.c @@ -1,6 +1,10 @@ // Copyright (c) rAthena Project (www.rathena.org) - Licensed under GNU GPL // For more information, see LICENCE in the main folder +#define HERCULES_CORE + +#include "mutex.h" + #ifdef WIN32 #include "../common/winapi.h" #else @@ -13,7 +17,6 @@ #include "../common/malloc.h" #include "../common/showmsg.h" #include "../common/timer.h" -#include "../common/mutex.h" struct ramutex{ #ifdef WIN32 diff --git a/src/common/mutex.h b/src/common/mutex.h index eeb24e6ff..3b83b66d6 100644 --- a/src/common/mutex.h +++ b/src/common/mutex.h @@ -4,6 +4,7 @@ #ifndef _COMMON_MUTEX_H_ #define _COMMON_MUTEX_H_ +#include "../common/cbasetypes.h" typedef struct ramutex *ramutex; // Mutex typedef struct racond *racond; // Condition Var diff --git a/src/common/nullpo.c b/src/common/nullpo.c index 1cb471aff..1891835f1 100644 --- a/src/common/nullpo.c +++ b/src/common/nullpo.c @@ -2,10 +2,14 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams +#define HERCULES_CORE + +#include "nullpo.h" + #include <stdio.h> #include <stdarg.h> #include <string.h> -#include "../common/nullpo.h" + #include "../common/showmsg.h" /** diff --git a/src/common/random.c b/src/common/random.c index e46c52cad..7019a31f3 100644 --- a/src/common/random.c +++ b/src/common/random.c @@ -1,17 +1,23 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder +#define HERCULES_CORE + +#include "random.h" + +#include <time.h> // time + +#include <mt19937ar.h> // init_genrand, genrand_int32, genrand_res53 + #include "../common/showmsg.h" #include "../common/timer.h" // gettick -#include "random.h" + #if defined(WIN32) - #include "../common/winapi.h" +# include "../common/winapi.h" #elif defined(HAVE_GETPID) || defined(HAVE_GETTID) - #include <sys/types.h> - #include <unistd.h> +# include <sys/types.h> +# include <unistd.h> #endif -#include <time.h> // time -#include <mt19937ar.h> // init_genrand, genrand_int32, genrand_res53 /// Initializes the random number generator with an appropriate seed. diff --git a/src/common/showmsg.c b/src/common/showmsg.c index 14342fe5e..1dbcba282 100644 --- a/src/common/showmsg.c +++ b/src/common/showmsg.c @@ -2,23 +2,26 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/strlib.h" // StringBuf +#define HERCULES_CORE + #include "showmsg.h" -#include "core.h" //[Ind] - For SERVER_TYPE +#include <stdarg.h> #include <stdio.h> +#include <stdlib.h> // atexit #include <string.h> -#include <stdarg.h> #include <time.h> -#include <stdlib.h> // atexit #include "../../3rdparty/libconfig/libconfig.h" +#include "../common/cbasetypes.h" +#include "../common/core.h" //[Ind] - For SERVER_TYPE +#include "../common/strlib.h" // StringBuf + #ifdef WIN32 -#include "../common/winapi.h" +# include "../common/winapi.h" #else // not WIN32 -#include <unistd.h> +# include <unistd.h> #endif // WIN32 #if defined(DEBUGLOGMAP) diff --git a/src/common/showmsg.h b/src/common/showmsg.h index 49fbc34fb..5b32f39ae 100644 --- a/src/common/showmsg.h +++ b/src/common/showmsg.h @@ -5,12 +5,14 @@ #ifndef _COMMON_SHOWMSG_H_ #define _COMMON_SHOWMSG_H_ -#ifndef _COMMON_HPMI_H_ - #include "../../3rdparty/libconfig/libconfig.h" -#endif - #include <stdarg.h> +#ifdef HERCULES_CORE +# include "../../3rdparty/libconfig/libconfig.h" +#else +# include "../common/HPMi.h" +#endif + // for help with the console colors look here: // http://www.edoceo.com/liberum/?doc=printf-with-color // some code explanation (used here): @@ -90,7 +92,7 @@ enum msg_type { }; extern void ClearScreen(void); -#ifndef _COMMON_HPMI_H_ +#ifdef HERCULES_CORE extern void ShowMessage(const char *, ...); extern void ShowStatus(const char *, ...); extern void ShowSQL(const char *, ...); @@ -101,7 +103,18 @@ extern void ClearScreen(void); extern void ShowError(const char *, ...); extern void ShowFatalError(const char *, ...); extern void ShowConfigWarning(config_setting_t *config, const char *string, ...); +#else + HPExport void (*ShowMessage) (const char *, ...); + HPExport void (*ShowStatus) (const char *, ...); + HPExport void (*ShowSQL) (const char *, ...); + HPExport void (*ShowInfo) (const char *, ...); + HPExport void (*ShowNotice) (const char *, ...); + HPExport void (*ShowWarning) (const char *, ...); + HPExport void (*ShowDebug) (const char *, ...); + HPExport void (*ShowError) (const char *, ...); + HPExport void (*ShowFatalError) (const char *, ...); #endif + extern int _vShowMessage(enum msg_type flag, const char *string, va_list ap); #endif /* _COMMON_SHOWMSG_H_ */ diff --git a/src/common/socket.c b/src/common/socket.c index 35d350e95..3738f2c2a 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -2,48 +2,50 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/mmo.h" -#include "../common/timer.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../config/core.h" -#include "../common/HPM.h" +#define HERCULES_CORE +#include "../config/core.h" // SHOW_SERVER_STATS #define _H_SOCKET_C_ - #include "socket.h" +#undef _H_SOCKET_C_ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/types.h> +#include "../common/HPM.h" +#include "../common/cbasetypes.h" +#include "../common/malloc.h" +#include "../common/mmo.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" +#include "../common/timer.h" + #ifdef WIN32 - #include "../common/winapi.h" +# include "../common/winapi.h" #else - #include <errno.h> - #include <sys/socket.h> - #include <netinet/in.h> - #include <netinet/tcp.h> - #include <net/if.h> - #include <unistd.h> - #include <sys/time.h> - #include <sys/ioctl.h> - #include <netdb.h> - #include <arpa/inet.h> - - #ifndef SIOCGIFCONF - #include <sys/sockio.h> // SIOCGIFCONF on Solaris, maybe others? [Shinomori] - #endif - #ifndef FIONBIO - #include <sys/filio.h> // FIONBIO on Solaris [FlavioJS] - #endif - - #ifdef HAVE_SETRLIMIT - #include <sys/resource.h> - #endif +# include <arpa/inet.h> +# include <errno.h> +# include <net/if.h> +# include <netdb.h> +# include <netinet/in.h> +# include <netinet/tcp.h> +# include <sys/ioctl.h> +# include <sys/socket.h> +# include <sys/time.h> +# include <unistd.h> + +# ifndef SIOCGIFCONF +# include <sys/sockio.h> // SIOCGIFCONF on Solaris, maybe others? [Shinomori] +# endif +# ifndef FIONBIO +# include <sys/filio.h> // FIONBIO on Solaris [FlavioJS] +# endif + +# ifdef HAVE_SETRLIMIT +# include <sys/resource.h> +# endif #endif /** diff --git a/src/common/socket.h b/src/common/socket.h index 75adde4cf..804b9284f 100644 --- a/src/common/socket.h +++ b/src/common/socket.h @@ -5,19 +5,19 @@ #ifndef _COMMON_SOCKET_H_ #define _COMMON_SOCKET_H_ +#include <time.h> + #include "../common/cbasetypes.h" #ifdef WIN32 - #include "../common/winapi.h" +# include "../common/winapi.h" typedef long in_addr_t; #else - #include <sys/types.h> - #include <sys/socket.h> - #include <netinet/in.h> +# include <netinet/in.h> +# include <sys/socket.h> +# include <sys/types.h> #endif -#include <time.h> - struct HPluginData; #define FIFOSIZE_SERVERLINK 256*1024 diff --git a/src/common/spinlock.h b/src/common/spinlock.h index 29fbb355b..0058e1d83 100644 --- a/src/common/spinlock.h +++ b/src/common/spinlock.h @@ -1,4 +1,3 @@ -#pragma once #ifndef _COMMON_SPINLOCK_H_ #define _COMMON_SPINLOCK_H_ @@ -15,14 +14,14 @@ // // +#include "../common/atomic.h" +#include "../common/cbasetypes.h" +#include "../common/thread.h" + #ifdef WIN32 #include "../common/winapi.h" #endif -#include "../common/cbasetypes.h" -#include "../common/atomic.h" -#include "../common/thread.h" - #ifdef WIN32 typedef struct __declspec( align(64) ) SPIN_LOCK{ diff --git a/src/common/sql.c b/src/common/sql.c index 79ccc8e92..aeb56bff0 100644 --- a/src/common/sql.c +++ b/src/common/sql.c @@ -2,19 +2,23 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams +#define HERCULES_CORE + +#include "sql.h" + +#include <stdlib.h> // strtoul +#include <string.h> // strlen/strnlen/memcpy/memset + #include "../common/cbasetypes.h" #include "../common/malloc.h" #include "../common/showmsg.h" #include "../common/strlib.h" #include "../common/timer.h" -#include "sql.h" #ifdef WIN32 -#include "../common/winapi.h" +# include "../common/winapi.h" // Needed before mysql.h #endif #include <mysql.h> -#include <string.h>// strlen/strnlen/memcpy/memset -#include <stdlib.h>// strtoul void hercules_mysql_error_handler(unsigned int ecode); diff --git a/src/common/sql.h b/src/common/sql.h index 1fb436853..807e0843c 100644 --- a/src/common/sql.h +++ b/src/common/sql.h @@ -5,10 +5,9 @@ #ifndef _COMMON_SQL_H_ #define _COMMON_SQL_H_ -#include "../common/cbasetypes.h" #include <stdarg.h>// va_list - +#include "../common/cbasetypes.h" // Return codes #define SQL_ERROR (-1) diff --git a/src/common/strlib.c b/src/common/strlib.c index 361595b07..e2e802915 100644 --- a/src/common/strlib.c +++ b/src/common/strlib.c @@ -2,16 +2,19 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" -#define STRLIB_C +#define HERCULES_CORE + +#define _H_STRLIB_C_ #include "strlib.h" +#undef _H_STRLIB_C_ +#include <errno.h> #include <stdio.h> #include <stdlib.h> -#include <errno.h> +#include "../common/cbasetypes.h" +#include "../common/malloc.h" +#include "../common/showmsg.h" #define J_MAX_MALLOC_SIZE 65535 diff --git a/src/common/strlib.h b/src/common/strlib.h index 10844d257..decf661a6 100644 --- a/src/common/strlib.h +++ b/src/common/strlib.h @@ -5,15 +5,16 @@ #ifndef _COMMON_STRLIB_H_ #define _COMMON_STRLIB_H_ -#include "../common/cbasetypes.h" #include <stdarg.h> +#include "../common/cbasetypes.h" + #ifndef __USE_GNU - #define __USE_GNU // required to enable strnlen on some platforms - #include <string.h> - #undef __USE_GNU +# define __USE_GNU // required to enable strnlen on some platforms +# include <string.h> +# undef __USE_GNU #else - #include <string.h> +# include <string.h> #endif #ifdef WIN32 @@ -165,7 +166,7 @@ struct sv_interface *sv; void strlib_defaults(void); /* the purpose of these macros is simply to not make calling them be an annoyance */ -#ifndef STRLIB_C +#ifndef _H_STRLIB_C_ #define jstrescape(pt) (strlib->jstrescape(pt)) #define jstrescapecpy(pt,spt) (strlib->jstrescapecpy((pt),(spt))) #define jmemescapecpy(pt,spt,size) (strlib->jmemescapecpy((pt),(spt),(size))) @@ -189,6 +190,6 @@ void strlib_defaults(void); #define safesnprintf(buf,sz,fmt,...) (strlib->safesnprintf((buf),(sz),(fmt),##__VA_ARGS__)) #define strline(str,pos) (strlib->strline((str),(pos))) #define bin2hex(output,input,count) (strlib->bin2hex((output),(input),(count))) -#endif /* STRLIB_C */ +#endif /* _H_STRLIB_C_ */ #endif /* _COMMON_STRLIB_H_ */ diff --git a/src/common/sysinfo.c b/src/common/sysinfo.c index a56896458..3fdfadb41 100644 --- a/src/common/sysinfo.c +++ b/src/common/sysinfo.c @@ -4,23 +4,39 @@ /// See sysinfo.h for a description of this file -#define _COMMON_SYSINFO_P_ +#define HERCULES_CORE + #include "sysinfo.h" -#undef _COMMON_SYSINFO_P_ + +#include <stdio.h> // fopen +#include <stdlib.h> // atoi #include "../common/cbasetypes.h" #include "../common/core.h" -#include "../common/strlib.h" #include "../common/malloc.h" +#include "../common/strlib.h" #ifdef WIN32 -#include <windows.h> -#include <string.h> // strlen +# include <string.h> // strlen +# include <windows.h> #else -#include <unistd.h> +# include <unistd.h> #endif -#include <stdio.h> // fopen -#include <stdlib.h> // atoi + +/// Private interface fields +struct sysinfo_private { + char *platform; + char *osversion; + char *cpu; + int cpucores; + char *arch; + char *compiler; + char *cflags; + char *vcstype_name; + int vcstype; + char *vcsrevision_src; + char *vcsrevision_scripts; +}; /// sysinfo.c interface source struct sysinfo_interface sysinfo_s; diff --git a/src/common/sysinfo.h b/src/common/sysinfo.h index 17faac26b..c0c4d276a 100644 --- a/src/common/sysinfo.h +++ b/src/common/sysinfo.h @@ -13,23 +13,7 @@ #include "../common/cbasetypes.h" -#ifdef _COMMON_SYSINFO_P_ -struct sysinfo_private { - char *platform; - char *osversion; - char *cpu; - int cpucores; - char *arch; - char *compiler; - char *cflags; - char *vcstype_name; - int vcstype; - char *vcsrevision_src; - char *vcsrevision_scripts; -}; -#else struct sysinfo_private; -#endif /** * sysinfo.c interface diff --git a/src/common/thread.c b/src/common/thread.c index 4d110f2dd..4f73aa9b3 100644 --- a/src/common/thread.c +++ b/src/common/thread.c @@ -6,24 +6,27 @@ // Copyright (c) rAthena Project (www.rathena.org) - Licensed under GNU GPL // For more information, see LICENCE in the main folder +#define HERCULES_CORE + +#include "thread.h" + +#include "../common/cbasetypes.h" +#include "../common/malloc.h" +#include "../common/showmsg.h" + #ifdef WIN32 -#include "../common/winapi.h" -#define getpagesize() 4096 // @TODO: implement this properly (GetSystemInfo .. dwPageSize..). (Atm as on all supported win platforms its 4k its static.) -#define __thread __declspec( thread ) +# include "../common/winapi.h" +# define getpagesize() 4096 // @TODO: implement this properly (GetSystemInfo .. dwPageSize..). (Atm as on all supported win platforms its 4k its static.) +# define __thread __declspec( thread ) #else -#include <stdlib.h> -#include <unistd.h> -#include <string.h> -#include <signal.h> -#include <pthread.h> -#include <sched.h> +# include <stdlib.h> +# include <unistd.h> +# include <string.h> +# include <signal.h> +# include <pthread.h> +# include <sched.h> #endif -#include "cbasetypes.h" -#include "malloc.h" -#include "showmsg.h" -#include "thread.h" - // When Compiling using MSC (on win32..) we know we have support in any case! #ifdef _MSC_VER #define HAS_TLS diff --git a/src/common/thread.h b/src/common/thread.h index d6b2bbc6e..887c03179 100644 --- a/src/common/thread.h +++ b/src/common/thread.h @@ -1,7 +1,6 @@ // Copyright (c) rAthena Project (www.rathena.org) - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#pragma once #ifndef _COMMON_THREAD_H_ #define _COMMON_THREAD_H_ diff --git a/src/common/timer.c b/src/common/timer.c index 526854582..10f14b0f2 100644 --- a/src/common/timer.c +++ b/src/common/timer.c @@ -2,11 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/db.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" -#include "../common/utils.h" +#define HERCULES_CORE + #include "timer.h" #include <stdio.h> @@ -14,11 +11,17 @@ #include <string.h> #include <time.h> +#include "../common/cbasetypes.h" +#include "../common/db.h" +#include "../common/malloc.h" +#include "../common/showmsg.h" +#include "../common/utils.h" + #ifdef WIN32 -#include "../common/winapi.h" // GetTickCount() +# include "../common/winapi.h" // GetTickCount() #else -#include <unistd.h> -#include <sys/time.h> // struct timeval, gettimeofday() +# include <sys/time.h> // struct timeval, gettimeofday() +# include <unistd.h> #endif struct timer_interface timer_s; diff --git a/src/common/utils.c b/src/common/utils.c index 47747dd32..84925f707 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -2,33 +2,35 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/mmo.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" -#include "../common/core.h" -#include "socket.h" +#define HERCULES_CORE + #include "utils.h" -#include <stdio.h> +#include <math.h> // floor() #include <stdarg.h> +#include <stdio.h> #include <stdlib.h> #include <string.h> -#include <math.h> // floor() +#include <sys/stat.h> // cache purposes [Ind/Hercules] + +#include "../common/cbasetypes.h" +#include "../common/core.h" +#include "../common/malloc.h" +#include "../common/mmo.h" +#include "../common/showmsg.h" +#include "../common/socket.h" #ifdef WIN32 - #include "../common/winapi.h" - #ifndef F_OK - #define F_OK 0x0 - #endif /* F_OK */ +# include "../common/winapi.h" +# ifndef F_OK +# define F_OK 0x0 +# endif /* F_OK */ #else - #include <unistd.h> - #include <dirent.h> - #include <sys/stat.h> +# include <dirent.h> +# include <sys/stat.h> +# include <unistd.h> #endif -#include <sys/stat.h> // cache purposes [Ind/Hercules] - struct HCache_interface HCache_s; /// Dumps given buffer into file pointed to by a handle. diff --git a/src/common/utils.h b/src/common/utils.h index f89546b8a..823651163 100644 --- a/src/common/utils.h +++ b/src/common/utils.h @@ -5,10 +5,11 @@ #ifndef _COMMON_UTILS_H_ #define _COMMON_UTILS_H_ -#include "../common/cbasetypes.h" #include <stdio.h> // FILE* #include <time.h> +#include "../common/cbasetypes.h" + /* [HCache] 1-byte key to ensure our method is the latest, we can modify to ensure the method matches */ #define HCACHE_KEY 'k' diff --git a/src/config/const.h b/src/config/const.h index 6557cb987..f9baa4d7d 100644 --- a/src/config/const.h +++ b/src/config/const.h @@ -52,13 +52,6 @@ #define DEFTYPE_MAX CHAR_MAX #endif -/* pointer size fix which fixes several gcc warnings */ -#ifdef __64BIT__ - #define __64BPTRSIZE(y) ((intptr)(y)) -#else - #define __64BPTRSIZE(y) (y) -#endif - /* ATCMD_FUNC(mobinfo) HIT and FLEE calculations */ #ifdef RENEWAL #define MOB_FLEE(mobdata) ( (mobdata)->lv + (mobdata)->status.agi + 100 ) diff --git a/src/config/renewal.h b/src/config/renewal.h index 36615d63b..36bdd3958 100644 --- a/src/config/renewal.h +++ b/src/config/renewal.h @@ -74,5 +74,6 @@ #define RENEWAL_ASPD #endif // DISABLE_RENEWAL +#undef DISABLE_RENEWAL #endif // _CONFIG_RENEWAL_H_ diff --git a/src/login/account.h b/src/login/account.h index 234e7c0c1..329ae31c8 100644 --- a/src/login/account.h +++ b/src/login/account.h @@ -7,6 +7,7 @@ #include "../common/cbasetypes.h" #include "../common/mmo.h" // ACCOUNT_REG2_NUM +#include "../common/sql.h" // Sql typedef struct AccountDB AccountDB; typedef struct AccountDBIterator AccountDBIterator; diff --git a/src/login/account_sql.c b/src/login/account_sql.c index 1483196ab..2e4ed7ab9 100644 --- a/src/login/account_sql.c +++ b/src/login/account_sql.c @@ -2,17 +2,22 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams +#define HERCULES_CORE + +#include "../config/core.h" // CONSOLE_INPUT +#include "account.h" + +#include <stdlib.h> +#include <string.h> + +#include "../common/console.h" #include "../common/malloc.h" #include "../common/mmo.h" #include "../common/showmsg.h" +#include "../common/socket.h" #include "../common/sql.h" #include "../common/strlib.h" #include "../common/timer.h" -#include "../common/console.h" -#include "../common/socket.h" -#include "account.h" -#include <stdlib.h> -#include <string.h> /// global defines #define ACCOUNT_SQL_DB_VERSION 20110114 @@ -652,7 +657,7 @@ Sql* account_db_sql_up(AccountDB* self) { AccountDB_SQL* db = (AccountDB_SQL*)self; Sql_HerculesUpdateCheck(db->accounts); #ifdef CONSOLE_INPUT - console->setSQL(db->accounts); + console->input->setSQL(db->accounts); #endif return db->accounts; } diff --git a/src/login/ipban_sql.c b/src/login/ipban_sql.c index 74f45e418..081f28d84 100644 --- a/src/login/ipban_sql.c +++ b/src/login/ipban_sql.c @@ -2,6 +2,15 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams +#define HERCULES_CORE + +#include "ipban.h" + +#include <stdlib.h> +#include <string.h> + +#include "login.h" +#include "loginlog.h" #include "../common/cbasetypes.h" #include "../common/db.h" #include "../common/malloc.h" @@ -9,11 +18,6 @@ #include "../common/socket.h" #include "../common/strlib.h" #include "../common/timer.h" -#include "login.h" -#include "ipban.h" -#include "loginlog.h" -#include <stdlib.h> -#include <string.h> // global sql settings static char global_db_hostname[32] = "127.0.0.1"; diff --git a/src/login/login.c b/src/login/login.c index af59fcf38..cb46e0226 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -2,6 +2,18 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams +#define HERCULES_CORE + +#include "login.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "account.h" +#include "ipban.h" +#include "loginlog.h" +#include "../common/HPM.h" #include "../common/core.h" #include "../common/db.h" #include "../common/malloc.h" @@ -12,15 +24,6 @@ #include "../common/strlib.h" #include "../common/timer.h" #include "../common/utils.h" -#include "../common/HPM.h" -#include "account.h" -#include "ipban.h" -#include "login.h" -#include "loginlog.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> struct Login_Config login_config; diff --git a/src/login/login.h b/src/login/login.h index 14c361a15..e77b96a0e 100644 --- a/src/login/login.h +++ b/src/login/login.h @@ -5,8 +5,8 @@ #ifndef _LOGIN_LOGIN_H_ #define _LOGIN_LOGIN_H_ -#include "../common/mmo.h" // NAME_LENGTH,SEX_* #include "../common/core.h" // CORE_ST_LAST +#include "../common/mmo.h" // NAME_LENGTH,SEX_* enum E_LOGINSERVER_ST { diff --git a/src/login/loginlog.h b/src/login/loginlog.h index 730fb6e62..a86ad431c 100644 --- a/src/login/loginlog.h +++ b/src/login/loginlog.h @@ -4,6 +4,7 @@ #ifndef _LOGIN_LOGINLOG_H_ #define _LOGIN_LOGINLOG_H_ +#include "../common/cbasetypes.h" unsigned long loginlog_failedattempts(uint32 ip, unsigned int minutes); void login_log(uint32 ip, const char* username, int rcode, const char* message); @@ -11,5 +12,4 @@ bool loginlog_init(void); bool loginlog_final(void); bool loginlog_config_read(const char* w1, const char* w2); - #endif /* _LOGIN_LOGINLOG_H_ */ diff --git a/src/login/loginlog_sql.c b/src/login/loginlog_sql.c index 231ac783b..2cbc02c93 100644 --- a/src/login/loginlog_sql.c +++ b/src/login/loginlog_sql.c @@ -2,13 +2,18 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams +#define HERCULES_CORE + +#include "loginlog.h" + +#include <string.h> +#include <stdlib.h> // exit + #include "../common/cbasetypes.h" #include "../common/mmo.h" #include "../common/socket.h" #include "../common/sql.h" #include "../common/strlib.h" -#include <string.h> -#include <stdlib.h> // exit // global sql settings (in ipban_sql.c) static char global_db_hostname[32] = "127.0.0.1"; diff --git a/src/map/HPMmap.c b/src/map/HPMmap.c index 061479d87..cb8c979c6 100644 --- a/src/map/HPMmap.c +++ b/src/map/HPMmap.c @@ -1,25 +1,15 @@ // Copyright (c) Hercules Dev Team, licensed under GNU GPL. // See the LICENSE file -#include "../common/cbasetypes.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" -#include "../common/HPM.h" -#include "../common/conf.h" -#include "../common/db.h" -#include "../common/des.h" -#include "../common/ers.h" -#include "../common/mapindex.h" -#include "../common/mmo.h" -#include "../common/socket.h" -#include "../common/strlib.h" - +#define HERCULES_CORE #include "HPMmap.h" -#include "pc.h" -#include "map.h" -// +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <time.h> + #include "atcommand.h" #include "battle.h" #include "battleground.h" @@ -37,12 +27,14 @@ #include "itemdb.h" #include "log.h" #include "mail.h" +#include "map.h" #include "mapreg.h" #include "mercenary.h" #include "mob.h" #include "npc.h" #include "party.h" #include "path.h" +#include "pc.h" #include "pc_groups.h" #include "pet.h" #include "quest.h" @@ -54,11 +46,19 @@ #include "trade.h" #include "unit.h" #include "vending.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <time.h> +#include "../common/HPM.h" +#include "../common/cbasetypes.h" +#include "../common/conf.h" +#include "../common/db.h" +#include "../common/des.h" +#include "../common/ers.h" +#include "../common/malloc.h" +#include "../common/mapindex.h" +#include "../common/mmo.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/sysinfo.h" #include "../common/HPMDataCheck.h" diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 5fd0faf86..df3be40a5 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -2,57 +2,60 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/mmo.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/core.h" -#include "../common/showmsg.h" -#include "../common/malloc.h" -#include "../common/random.h" -#include "../common/socket.h" -#include "../common/strlib.h" -#include "../common/utils.h" -#include "../common/conf.h" -#include "../common/sysinfo.h" +#define HERCULES_CORE +#include "../config/core.h" // AUTOLOOTITEM_SIZE, AUTOTRADE_PERSISTENCY, MAX_CARTS, MAX_SUGGESTIONS, MOB_FLEE(), MOB_HIT(), RENEWAL, RENEWAL_DROP, RENEWAL_EXP #include "atcommand.h" + +#include <math.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + #include "battle.h" #include "chat.h" -#include "clif.h" #include "chrif.h" +#include "clif.h" #include "duel.h" +#include "elemental.h" +#include "guild.h" +#include "homunculus.h" #include "intif.h" #include "itemdb.h" #include "log.h" +#include "mail.h" #include "map.h" -#include "pc.h" -#include "pc_groups.h" // groupid2name -#include "status.h" -#include "skill.h" +#include "mapreg.h" +#include "mercenary.h" #include "mob.h" #include "npc.h" -#include "pet.h" -#include "homunculus.h" -#include "mail.h" -#include "mercenary.h" -#include "elemental.h" #include "party.h" -#include "guild.h" +#include "pc.h" +#include "pc_groups.h" // groupid2name +#include "pet.h" +#include "quest.h" #include "script.h" +#include "searchstore.h" +#include "skill.h" +#include "status.h" #include "storage.h" #include "trade.h" #include "unit.h" -#include "mapreg.h" -#include "quest.h" -#include "searchstore.h" +#include "../common/cbasetypes.h" +#include "../common/conf.h" +#include "../common/core.h" +#include "../common/malloc.h" +#include "../common/mmo.h" +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/sysinfo.h" +#include "../common/timer.h" +#include "../common/utils.h" #include "HPMmap.h" -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <math.h> - struct atcommand_interface atcommand_s; static char atcmd_output[CHAT_SIZE_MAX]; diff --git a/src/map/atcommand.h b/src/map/atcommand.h index bc4ab30a3..c8a1863af 100644 --- a/src/map/atcommand.h +++ b/src/map/atcommand.h @@ -5,9 +5,9 @@ #ifndef _MAP_ATCOMMAND_H_ #define _MAP_ATCOMMAND_H_ +#include "pc_groups.h" #include "../common/conf.h" #include "../common/db.h" -#include "pc_groups.h" /** * Declarations diff --git a/src/map/battle.c b/src/map/battle.c index 9089b7102..0865ee4ba 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -2,41 +2,44 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" -#include "../common/ers.h" -#include "../common/random.h" -#include "../common/socket.h" -#include "../common/strlib.h" -#include "../common/utils.h" -#include "../common/sysinfo.h" -#include "../common/HPM.h" +#define HERCULES_CORE -#include "map.h" -#include "path.h" -#include "pc.h" -#include "status.h" -#include "skill.h" -#include "homunculus.h" -#include "mercenary.h" -#include "elemental.h" -#include "mob.h" -#include "itemdb.h" -#include "clif.h" -#include "pet.h" -#include "guild.h" -#include "party.h" +#include "../config/core.h" // CELL_NOSTACK, CIRCULAR_AREA, CONSOLE_INPUT, HMAP_ZONE_DAMAGE_CAP_TYPE, OFFICIAL_WALKPATH, RENEWAL, RENEWAL_ASPD, RENEWAL_CAST, RENEWAL_DROP, RENEWAL_EDP, RENEWAL_EXP, RENEWAL_LVDMG, RE_LVL_DMOD(), RE_LVL_MDMOD(), RE_LVL_TMDMOD(), RE_SKILL_REDUCTION(), SCRIPT_CALLFUNC_CHECK, SECURE_NPCTIMEOUT, STATS_OPT_OUT #include "battle.h" -#include "battleground.h" -#include "chrif.h" +#include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <math.h> + +#include "battleground.h" +#include "chrif.h" +#include "clif.h" +#include "elemental.h" +#include "guild.h" +#include "homunculus.h" +#include "itemdb.h" +#include "map.h" +#include "mercenary.h" +#include "mob.h" +#include "party.h" +#include "path.h" +#include "pc.h" +#include "pet.h" +#include "skill.h" +#include "status.h" +#include "../common/HPM.h" +#include "../common/cbasetypes.h" +#include "../common/ers.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/sysinfo.h" +#include "../common/timer.h" +#include "../common/utils.h" struct Battle_Config battle_config; struct battle_interface battle_s; diff --git a/src/map/battle.h b/src/map/battle.h index 88038ddb4..fbe097c78 100644 --- a/src/map/battle.h +++ b/src/map/battle.h @@ -5,8 +5,8 @@ #ifndef _MAP_BATTLE_H_ #define _MAP_BATTLE_H_ -#include "../common/cbasetypes.h" #include "map.h" //ELE_MAX +#include "../common/cbasetypes.h" /** * Declarations diff --git a/src/map/battleground.c b/src/map/battleground.c index 68539e25d..a7169de0e 100644 --- a/src/map/battleground.c +++ b/src/map/battleground.c @@ -2,29 +2,32 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/timer.h" -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/strlib.h" -#include "../common/conf.h" +#define HERCULES_CORE #include "battleground.h" + +#include <string.h> +#include <stdio.h> + #include "battle.h" #include "clif.h" +#include "homunculus.h" #include "map.h" +#include "mapreg.h" +#include "mercenary.h" +#include "mob.h" // struct mob_data #include "npc.h" -#include "pc.h" #include "party.h" +#include "pc.h" #include "pet.h" -#include "homunculus.h" -#include "mercenary.h" -#include "mapreg.h" - -#include <string.h> -#include <stdio.h> +#include "../common/cbasetypes.h" +#include "../common/conf.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/timer.h" struct battleground_interface bg_s; diff --git a/src/map/battleground.h b/src/map/battleground.h index 05c4eb060..ec0a86f14 100644 --- a/src/map/battleground.h +++ b/src/map/battleground.h @@ -5,9 +5,9 @@ #ifndef _MAP_BATTLEGROUND_H_ #define _MAP_BATTLEGROUND_H_ -#include "../common/mmo.h" // struct party #include "clif.h" #include "guild.h" +#include "../common/mmo.h" // struct party /** * Defines diff --git a/src/map/buyingstore.c b/src/map/buyingstore.c index 2a15e66fc..80264b30d 100644 --- a/src/map/buyingstore.c +++ b/src/map/buyingstore.c @@ -2,18 +2,21 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/db.h" // ARR_FIND -#include "../common/showmsg.h" // ShowWarning -#include "../common/socket.h" // RBUF* -#include "../common/strlib.h" // safestrncpy +#define HERCULES_CORE + +#include "buyingstore.h" // struct s_buyingstore + #include "atcommand.h" // msg_txt #include "battle.h" // battle_config.* -#include "buyingstore.h" // struct s_buyingstore +#include "chrif.h" #include "clif.h" // clif->buyingstore_* #include "log.h" // log_pick_pc, log_zeny #include "pc.h" // struct map_session_data -#include "chrif.h" +#include "../common/cbasetypes.h" +#include "../common/db.h" // ARR_FIND +#include "../common/showmsg.h" // ShowWarning +#include "../common/socket.h" // RBUF* +#include "../common/strlib.h" // safestrncpy struct buyingstore_interface buyingstore_s; diff --git a/src/map/buyingstore.h b/src/map/buyingstore.h index 5141a1013..914631872 100644 --- a/src/map/buyingstore.h +++ b/src/map/buyingstore.h @@ -5,6 +5,11 @@ #ifndef _MAP_BUYINGSTORE_H_ #define _MAP_BUYINGSTORE_H_ +#include "../common/cbasetypes.h" +#include "../common/mmo.h" // MAX_SLOTS + +struct map_session_data; + /** * Declarations **/ diff --git a/src/map/chat.c b/src/map/chat.c index 08fc4a575..c9d3e6d46 100644 --- a/src/map/chat.c +++ b/src/map/chat.c @@ -2,12 +2,13 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/mmo.h" +#define HERCULES_CORE + +#include "chat.h" + +#include <stdio.h> +#include <string.h> + #include "atcommand.h" // msg_txt() #include "battle.h" // struct battle_config #include "clif.h" @@ -15,10 +16,12 @@ #include "npc.h" // npc_event_do() #include "pc.h" #include "skill.h" // ext_skill_unit_onplace() -#include "chat.h" - -#include <stdio.h> -#include <string.h> +#include "../common/cbasetypes.h" +#include "../common/malloc.h" +#include "../common/mmo.h" +#include "../common/nullpo.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" struct chat_interface chat_s; diff --git a/src/map/chat.h b/src/map/chat.h index b0c6cd905..cbc2a391e 100644 --- a/src/map/chat.h +++ b/src/map/chat.h @@ -6,9 +6,12 @@ #define _MAP_CHAT_H_ #include "map.h" // struct block_list, CHATROOM_TITLE_SIZE +#include "../common/cbasetypes.h" +#include "../common/db.h" -struct map_session_data; struct chat_data; +struct map_session_data; +struct npc_data; #define MAX_CHAT_USERS 20 diff --git a/src/map/chrif.c b/src/map/chrif.c index 99a1935fd..81e2d387c 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -2,15 +2,16 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/malloc.h" -#include "../common/socket.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/ers.h" -#include "../common/HPM.h" +#define HERCULES_CORE + +#include "../config/core.h" // AUTOTRADE_PERSISTENCY, STATS_OPT_OUT +#include "chrif.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/types.h> +#include <time.h> #include "map.h" #include "battle.h" @@ -25,15 +26,17 @@ #include "instance.h" #include "mercenary.h" #include "elemental.h" -#include "chrif.h" #include "quest.h" #include "storage.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <sys/types.h> -#include <time.h> +#include "../common/HPM.h" +#include "../common/cbasetypes.h" +#include "../common/ers.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/timer.h" struct chrif_interface chrif_s; diff --git a/src/map/chrif.h b/src/map/chrif.h index 25e955604..84efc66d3 100644 --- a/src/map/chrif.h +++ b/src/map/chrif.h @@ -5,9 +5,11 @@ #ifndef _MAP_CHRIF_H_ #define _MAP_CHRIF_H_ -#include "../common/cbasetypes.h" #include <time.h> + #include "map.h" //TBL_stuff +#include "../common/cbasetypes.h" +#include "../common/db.h" struct status_change_entry; diff --git a/src/map/clif.c b/src/map/clif.c index 062a437a2..1da6070e8 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -2,56 +2,59 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/socket.h" -#include "../common/timer.h" -#include "../common/grfio.h" -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/utils.h" -#include "../common/ers.h" -#include "../common/conf.h" -#include "../common/HPM.h" +#define HERCULES_CORE + +#include "../config/core.h" // ANTI_MAYAP_CHEAT, NEW_CARTS, RENEWAL, SECURE_NPCTIMEOUT +#include "clif.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <stdarg.h> +#include <time.h> -#include "map.h" -#include "chrif.h" -#include "pc.h" -#include "status.h" -#include "npc.h" -#include "itemdb.h" -#include "chat.h" -#include "trade.h" -#include "storage.h" -#include "script.h" -#include "skill.h" #include "atcommand.h" -#include "intif.h" #include "battle.h" #include "battleground.h" -#include "mob.h" -#include "party.h" -#include "unit.h" +#include "chat.h" +#include "chrif.h" +#include "elemental.h" #include "guild.h" -#include "vending.h" -#include "pet.h" #include "homunculus.h" #include "instance.h" -#include "mercenary.h" -#include "elemental.h" +#include "intif.h" +#include "irc-bot.h" +#include "itemdb.h" #include "log.h" -#include "clif.h" #include "mail.h" +#include "map.h" +#include "mercenary.h" +#include "mob.h" +#include "npc.h" +#include "party.h" +#include "pc.h" +#include "pet.h" #include "quest.h" -#include "irc-bot.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <stdarg.h> -#include <time.h> +#include "script.h" +#include "skill.h" +#include "status.h" +#include "storage.h" +#include "trade.h" +#include "unit.h" +#include "vending.h" +#include "../common/HPM.h" +#include "../common/cbasetypes.h" +#include "../common/conf.h" +#include "../common/ers.h" +#include "../common/grfio.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/timer.h" +#include "../common/utils.h" struct clif_interface clif_s; diff --git a/src/map/clif.h b/src/map/clif.h index bbe07b718..f54c4afce 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -5,13 +5,13 @@ #ifndef _MAP_CLIF_H_ #define _MAP_CLIF_H_ +#include <stdarg.h> + +#include "map.h" +#include "packets_struct.h" #include "../common/cbasetypes.h" #include "../common/db.h" #include "../common/mmo.h" -#include "../common/socket.h" -#include "../map/map.h" -#include "../map/packets_struct.h" -#include <stdarg.h> /** * Declarations @@ -20,7 +20,6 @@ struct item; struct item_data; struct storage_data; struct guild_storage; -struct block_list; struct unit_data; struct map_session_data; struct homun_data; diff --git a/src/map/date.c b/src/map/date.c index f38ead858..975a00c50 100644 --- a/src/map/date.c +++ b/src/map/date.c @@ -1,10 +1,14 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#include "../common/cbasetypes.h" +#define HERCULES_CORE + #include "date.h" + #include <time.h> +#include "../common/cbasetypes.h" + int date_get_year(void) { time_t t; diff --git a/src/map/date.h b/src/map/date.h index 46f0d86c3..b3ed59b2f 100644 --- a/src/map/date.h +++ b/src/map/date.h @@ -4,6 +4,8 @@ #ifndef _MAP_DATE_H_ #define _MAP_DATE_H_ +#include "../common/cbasetypes.h" + int date_get_year(void); int date_get_month(void); int date_get_day(void); diff --git a/src/map/duel.c b/src/map/duel.c index af2741f77..a423ef240 100644 --- a/src/map/duel.c +++ b/src/map/duel.c @@ -2,18 +2,20 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" +#define HERCULES_CORE -#include "atcommand.h" // msg_txt -#include "clif.h" #include "duel.h" -#include "pc.h" #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> +#include "atcommand.h" // msg_txt +#include "clif.h" +#include "pc.h" +#include "../common/cbasetypes.h" + /*========================================== * Duel organizing functions [LuzZza] *------------------------------------------*/ diff --git a/src/map/duel.h b/src/map/duel.h index 5405d2eee..956aed36d 100644 --- a/src/map/duel.h +++ b/src/map/duel.h @@ -5,6 +5,10 @@ #ifndef _MAP_DUEL_H_ #define _MAP_DUEL_H_ +#include "../common/cbasetypes.h" + +struct map_session_data; + struct duel { int members_count; int invites_count; diff --git a/src/map/elemental.c b/src/map/elemental.c index f335600d6..323df41e1 100644 --- a/src/map/elemental.c +++ b/src/map/elemental.c @@ -2,42 +2,44 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/malloc.h" -#include "../common/socket.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/mmo.h" -#include "../common/showmsg.h" -#include "../common/utils.h" -#include "../common/random.h" -#include "../common/strlib.h" +#define HERCULES_CORE -#include "log.h" -#include "clif.h" +#include "elemental.h" + +#include <math.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "atcommand.h" +#include "battle.h" #include "chrif.h" +#include "clif.h" +#include "guild.h" #include "intif.h" #include "itemdb.h" +#include "log.h" #include "map.h" -#include "pc.h" -#include "status.h" -#include "skill.h" #include "mob.h" -#include "pet.h" -#include "battle.h" +#include "npc.h" #include "party.h" -#include "guild.h" -#include "atcommand.h" +#include "pc.h" +#include "pet.h" #include "script.h" -#include "npc.h" +#include "skill.h" +#include "status.h" #include "trade.h" #include "unit.h" -#include "elemental.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <math.h> +#include "../common/cbasetypes.h" +#include "../common/malloc.h" +#include "../common/mmo.h" +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/timer.h" +#include "../common/utils.h" struct elemental_interface elemental_s; diff --git a/src/map/elemental.h b/src/map/elemental.h index 6d04a41a5..aa27aadc9 100644 --- a/src/map/elemental.h +++ b/src/map/elemental.h @@ -7,6 +7,7 @@ #include "status.h" // struct status_data, struct status_change #include "unit.h" // struct unit_data +#include "../common/mmo.h" // NAME_LENGTH /** * Defines diff --git a/src/map/guild.c b/src/map/guild.c index fa5805c8b..69f67238d 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -2,35 +2,38 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/malloc.h" -#include "../common/mapindex.h" -#include "../common/showmsg.h" -#include "../common/ers.h" -#include "../common/strlib.h" -#include "../common/utils.h" -#include "../common/HPM.h" +#define HERCULES_CORE -#include "map.h" +#include "../config/core.h" // GP_BOUND_ITEMS #include "guild.h" -#include "storage.h" -#include "battle.h" -#include "npc.h" -#include "pc.h" -#include "status.h" -#include "mob.h" -#include "intif.h" -#include "clif.h" -#include "skill.h" -#include "log.h" -#include "instance.h" #include <stdio.h> #include <stdlib.h> #include <string.h> +#include "battle.h" +#include "clif.h" +#include "instance.h" +#include "intif.h" +#include "log.h" +#include "map.h" +#include "mob.h" +#include "npc.h" +#include "pc.h" +#include "skill.h" +#include "status.h" +#include "storage.h" +#include "../common/HPM.h" +#include "../common/cbasetypes.h" +#include "../common/ers.h" +#include "../common/malloc.h" +#include "../common/mapindex.h" +#include "../common/nullpo.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" +#include "../common/timer.h" +#include "../common/utils.h" + struct guild_interface guild_s; /*========================================== diff --git a/src/map/guild.h b/src/map/guild.h index b03bd664d..34e27a56c 100644 --- a/src/map/guild.h +++ b/src/map/guild.h @@ -5,18 +5,10 @@ #ifndef _MAP_GUILD_H_ #define _MAP_GUILD_H_ -//#include "../common/mmo.h" -#include "map.h" // NAME_LENGTH - -/** - * Declarations - **/ -struct guild; -struct guild_member; -struct guild_position; -struct guild_castle; -struct map_session_data; -struct mob_data; +#include "map.h" // EVENT_NAME_LENGTH, TBL_PC +#include "../common/cbasetypes.h" +#include "../common/db.h" +#include "../common/mmo.h" /** * Defines diff --git a/src/map/homunculus.c b/src/map/homunculus.c index ff9f7a5b1..b6a83d1cb 100644 --- a/src/map/homunculus.c +++ b/src/map/homunculus.c @@ -2,43 +2,45 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/malloc.h" -#include "../common/socket.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/mmo.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/utils.h" +#define HERCULES_CORE -#include "log.h" -#include "clif.h" +#include "../config/core.h" // DBPATH +#include "homunculus.h" + +#include <math.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "atcommand.h" +#include "battle.h" #include "chrif.h" +#include "clif.h" +#include "guild.h" #include "intif.h" #include "itemdb.h" +#include "log.h" #include "map.h" -#include "pc.h" -#include "status.h" -#include "skill.h" #include "mob.h" -#include "pet.h" -#include "battle.h" +#include "npc.h" #include "party.h" -#include "guild.h" -#include "atcommand.h" +#include "pc.h" +#include "pet.h" #include "script.h" -#include "npc.h" +#include "skill.h" +#include "status.h" #include "trade.h" #include "unit.h" - -#include "homunculus.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <math.h> +#include "../common/cbasetypes.h" +#include "../common/malloc.h" +#include "../common/mmo.h" +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/timer.h" +#include "../common/utils.h" struct homunculus_interface homunculus_s; diff --git a/src/map/homunculus.h b/src/map/homunculus.h index e6d59e30e..9eef6af5b 100644 --- a/src/map/homunculus.h +++ b/src/map/homunculus.h @@ -5,9 +5,10 @@ #ifndef _MAP_HOMUNCULUS_H_ #define _MAP_HOMUNCULUS_H_ +#include "pc.h" #include "status.h" // struct status_data, struct status_change #include "unit.h" // struct unit_data -#include "pc.h" +#include "../common/mmo.h" #define MAX_HOM_SKILL_REQUIRE 5 #define homdb_checkid(id) ((id) >= HM_CLASS_BASE && (id) <= HM_CLASS_MAX) diff --git a/src/map/instance.c b/src/map/instance.c index caf622b3d..5789d7dd6 100644 --- a/src/map/instance.c +++ b/src/map/instance.c @@ -2,30 +2,32 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/socket.h" -#include "../common/timer.h" -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/utils.h" -#include "../common/db.h" -#include "../common/HPM.h" +#define HERCULES_CORE -#include "clif.h" #include "instance.h" -#include "map.h" -#include "npc.h" -#include "party.h" -#include "pc.h" +#include <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <stdarg.h> #include <time.h> +#include "clif.h" +#include "map.h" +#include "npc.h" +#include "party.h" +#include "pc.h" +#include "../common/HPM.h" +#include "../common/cbasetypes.h" +#include "../common/db.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/timer.h" +#include "../common/utils.h" + struct instance_interface instance_s; /// Checks whether given instance id is valid or not. diff --git a/src/map/instance.h b/src/map/instance.h index 712a0f141..ae649eda7 100644 --- a/src/map/instance.h +++ b/src/map/instance.h @@ -6,8 +6,11 @@ #define _MAP_INSTANCE_H_ #include "script.h" // struct reg_db +#include "../common/cbasetypes.h" #include "../common/mmo.h" // struct point + struct block_list; +struct map_session_data; #define INSTANCE_NAME_LENGTH (60+1) diff --git a/src/map/intif.c b/src/map/intif.c index 6bd24368a..383150fbc 100644 --- a/src/map/intif.c +++ b/src/map/intif.c @@ -1,37 +1,40 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/malloc.h" -#include "../common/strlib.h" -#include "map.h" +#define HERCULES_CORE + +#include "../config/core.h" // GP_BOUND_ITEMS +#include "intif.h" + +#include <fcntl.h> +#include <signal.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/types.h> + +#include "atcommand.h" #include "battle.h" #include "chrif.h" #include "clif.h" -#include "pc.h" -#include "intif.h" -#include "log.h" -#include "storage.h" -#include "party.h" +#include "elemental.h" #include "guild.h" -#include "pet.h" -#include "atcommand.h" -#include "mercenary.h" #include "homunculus.h" -#include "elemental.h" +#include "log.h" #include "mail.h" +#include "map.h" +#include "mercenary.h" +#include "party.h" +#include "pc.h" +#include "pet.h" #include "quest.h" - -#include <sys/types.h> -#include <stdio.h> -#include <stdlib.h> -#include <signal.h> -#include <fcntl.h> -#include <string.h> - +#include "storage.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/timer.h" struct intif_interface intif_s; diff --git a/src/map/intif.h b/src/map/intif.h index 290dcfcdc..b6ee727f3 100644 --- a/src/map/intif.h +++ b/src/map/intif.h @@ -5,19 +5,22 @@ #ifndef _MAP_INTIF_H_ #define _MAP_INTIF_H_ +#include "../common/cbasetypes.h" /** * Declarations **/ -struct party_member; +struct auction_data; struct guild_member; struct guild_position; -struct s_pet; +struct guild_storage; +struct mail_message; +struct map_session_data; +struct party_member; +struct s_elemental; struct s_homunculus; struct s_mercenary; -struct s_elemental; -struct mail_message; -struct auction_data; +struct s_pet; /** * Defines diff --git a/src/map/irc-bot.c b/src/map/irc-bot.c index ff28082e7..6f016697f 100644 --- a/src/map/irc-bot.c +++ b/src/map/irc-bot.c @@ -2,23 +2,25 @@ // See the LICENSE file // Base Author: shennetsind @ http://hercules.ws -#include "../common/cbasetypes.h" -#include "../common/malloc.h" -#include "../common/strlib.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/timer.h" -#include "../common/random.h" +#define HERCULES_CORE -#include "map.h" -#include "pc.h" -#include "clif.h" #include "irc-bot.h" #include <stdio.h> #include <stdlib.h> #include <string.h> +#include "clif.h" +#include "map.h" +#include "pc.h" +#include "../common/cbasetypes.h" +#include "../common/malloc.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/timer.h" + //#define IRCBOT_DEBUG struct irc_bot_interface irc_bot_s; diff --git a/src/map/irc-bot.h b/src/map/irc-bot.h index c15a5d46a..60f03fca5 100644 --- a/src/map/irc-bot.h +++ b/src/map/irc-bot.h @@ -6,6 +6,8 @@ #ifndef _MAP_IRC_BOT_H_ #define _MAP_IRC_BOT_H_ +#include "../common/cbasetypes.h" + #define IRC_NICK_LENGTH 40 #define IRC_IDENT_LENGTH 40 #define IRC_HOST_LENGTH 63 diff --git a/src/map/itemdb.c b/src/map/itemdb.c index 5eeb90be5..1981f435c 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -2,23 +2,28 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/nullpo.h" -#include "../common/malloc.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/utils.h" -#include "../common/conf.h" +#define HERCULES_CORE + +#include "../config/core.h" // DBPATH, RENEWAL #include "itemdb.h" -#include "map.h" -#include "battle.h" // struct battle_config -#include "script.h" // item script processing -#include "pc.h" // W_MUSICAL, W_WHIP #include <stdio.h> #include <stdlib.h> #include <string.h> +#include "battle.h" // struct battle_config +#include "map.h" +#include "mob.h" // MAX_MOB_DB +#include "pc.h" // W_MUSICAL, W_WHIP +#include "script.h" // item script processing +#include "../common/conf.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" +#include "../common/utils.h" + struct itemdb_interface itemdb_s; /** diff --git a/src/map/itemdb.h b/src/map/itemdb.h index 77fb2e2ec..12766b288 100644 --- a/src/map/itemdb.h +++ b/src/map/itemdb.h @@ -5,9 +5,12 @@ #ifndef _MAP_ITEMDB_H_ #define _MAP_ITEMDB_H_ +#include "map.h" +#include "../common/cbasetypes.h" +#include "../common/conf.h" #include "../common/db.h" #include "../common/mmo.h" // ITEM_NAME_LENGTH -#include "map.h" +#include "../common/sql.h" /** * Declarations diff --git a/src/map/log.c b/src/map/log.c index 19a98f34b..523ef1d65 100644 --- a/src/map/log.c +++ b/src/map/log.c @@ -2,22 +2,25 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/sql.h" // SQL_INNODB -#include "../common/strlib.h" -#include "../common/nullpo.h" -#include "../common/showmsg.h" -#include "battle.h" -#include "itemdb.h" +#define HERCULES_CORE + #include "log.h" -#include "map.h" -#include "mob.h" -#include "pc.h" #include <stdio.h> #include <stdlib.h> #include <string.h> +#include "battle.h" +#include "itemdb.h" +#include "map.h" +#include "mob.h" +#include "pc.h" +#include "../common/cbasetypes.h" +#include "../common/nullpo.h" +#include "../common/showmsg.h" +#include "../common/sql.h" // SQL_INNODB +#include "../common/strlib.h" + struct log_interface log_s; /// obtain log type character for item/zeny logs diff --git a/src/map/log.h b/src/map/log.h index b2cb92c20..ecfedeac2 100644 --- a/src/map/log.h +++ b/src/map/log.h @@ -11,11 +11,10 @@ /** * Declarations **/ -struct block_list; -struct map_session_data; -struct mob_data; struct item; struct item_data; +struct map_session_data; +struct mob_data; /** * Defines diff --git a/src/map/mail.c b/src/map/mail.c index 371aa892f..7ba7d7470 100644 --- a/src/map/mail.c +++ b/src/map/mail.c @@ -2,19 +2,21 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/nullpo.h" -#include "../common/showmsg.h" +#define HERCULES_CORE #include "mail.h" -#include "atcommand.h" -#include "itemdb.h" -#include "clif.h" -#include "pc.h" -#include "log.h" #include <time.h> #include <string.h> +#include "atcommand.h" +#include "clif.h" +#include "itemdb.h" +#include "log.h" +#include "pc.h" +#include "../common/nullpo.h" +#include "../common/showmsg.h" + struct mail_interface mail_s; void mail_clear(struct map_session_data *sd) diff --git a/src/map/mail.h b/src/map/mail.h index 8df537ff3..30b032ef4 100644 --- a/src/map/mail.h +++ b/src/map/mail.h @@ -5,7 +5,11 @@ #ifndef _MAP_MAIL_H_ #define _MAP_MAIL_H_ -#include "../common/mmo.h" +#include "../common/cbasetypes.h" + +struct item; +struct mail_message; +struct map_session_data; struct mail_interface { void (*clear) (struct map_session_data *sd); diff --git a/src/map/map.c b/src/map/map.c index 24a07699f..bccb51d7e 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -2,62 +2,66 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/core.h" -#include "../common/timer.h" -#include "../common/ers.h" -#include "../common/grfio.h" -#include "../common/malloc.h" -#include "../common/socket.h" // WFIFO*() -#include "../common/showmsg.h" -#include "../common/nullpo.h" -#include "../common/random.h" -#include "../common/strlib.h" -#include "../common/utils.h" -#include "../common/conf.h" -#include "../common/console.h" -#include "../common/HPM.h" +#define HERCULES_CORE +#include "../config/core.h" // CELL_NOSTACK, CIRCULAR_AREA, CONSOLE_INPUT, DBPATH, RENEWAL #include "map.h" -#include "path.h" + +#include <math.h> +#include <stdarg.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "HPMmap.h" +#include "atcommand.h" +#include "battle.h" +#include "battleground.h" +#include "chat.h" #include "chrif.h" #include "clif.h" #include "duel.h" +#include "elemental.h" +#include "guild.h" +#include "homunculus.h" +#include "instance.h" #include "intif.h" +#include "irc-bot.h" +#include "itemdb.h" +#include "log.h" +#include "mail.h" +#include "mapreg.h" +#include "mercenary.h" +#include "mob.h" #include "npc.h" +#include "npc.h" // npc_setcells(), npc_unsetcells() +#include "party.h" +#include "path.h" #include "pc.h" +#include "pet.h" +#include "quest.h" +#include "script.h" +#include "skill.h" #include "status.h" -#include "mob.h" -#include "npc.h" // npc_setcells(), npc_unsetcells() -#include "chat.h" -#include "itemdb.h" #include "storage.h" -#include "skill.h" #include "trade.h" -#include "party.h" #include "unit.h" -#include "battle.h" -#include "battleground.h" -#include "quest.h" -#include "script.h" -#include "mapreg.h" -#include "guild.h" -#include "pet.h" -#include "homunculus.h" -#include "instance.h" -#include "mercenary.h" -#include "elemental.h" -#include "atcommand.h" -#include "log.h" -#include "mail.h" -#include "irc-bot.h" -#include "HPMmap.h" +#include "../common/HPM.h" +#include "../common/cbasetypes.h" +#include "../common/conf.h" +#include "../common/console.h" +#include "../common/core.h" +#include "../common/ers.h" +#include "../common/grfio.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/socket.h" // WFIFO*() +#include "../common/strlib.h" +#include "../common/timer.h" +#include "../common/utils.h" -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <stdarg.h> -#include <math.h> #ifndef _WIN32 #include <unistd.h> #endif @@ -5480,8 +5484,8 @@ void map_cp_defaults(void) { map->cpsd->bl.y = MAP_DEFAULT_Y; map->cpsd->bl.m = map->mapname2mapid(MAP_DEFAULT); - console->addCommand("gm:info",CPCMD_A(gm_position)); - console->addCommand("gm:use",CPCMD_A(gm_use)); + console->input->addCommand("gm:info",CPCMD_A(gm_position)); + console->input->addCommand("gm:use",CPCMD_A(gm_use)); #endif } /* Hercules Plugin Mananger */ @@ -5837,7 +5841,7 @@ int do_init(int argc, char *argv[]) Sql_HerculesUpdateCheck(map->mysql_handle); #ifdef CONSOLE_INPUT - console->setSQL(map->mysql_handle); + console->input->setSQL(map->mysql_handle); #endif ShowStatus("Server is '"CL_GREEN"ready"CL_RESET"' and listening on port '"CL_WHITE"%d"CL_RESET"'.\n\n", map->port); diff --git a/src/map/map.h b/src/map/map.h index 6b2e9d909..8277c7a62 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -5,18 +5,18 @@ #ifndef _MAP_MAP_H_ #define _MAP_MAP_H_ +#include <stdarg.h> + +#include "atcommand.h" #include "../common/cbasetypes.h" #include "../common/core.h" // CORE_ST_LAST #include "../common/mmo.h" #include "../common/mapindex.h" #include "../common/db.h" -#include "../config/core.h" #include "../common/sql.h" -#include "atcommand.h" -#include <stdarg.h> +struct mob_data; struct npc_data; -struct item_data; struct hChSysCh; enum E_MAPSERVER_ST { @@ -36,7 +36,6 @@ enum E_MAPSERVER_ST { #define NATURAL_HEAL_INTERVAL 500 #define MIN_FLOORITEM 2 #define MAX_FLOORITEM START_ACCOUNT_NUM -#define MAX_LEVEL 175 #define MAX_IGNORE_LIST 20 // official is 14 #define MAX_VENDING 12 #define MAX_MAP_SIZE (512*512) // Wasn't there something like this already? Can't find it.. [Shinryo] diff --git a/src/map/mapreg_sql.c b/src/map/mapreg_sql.c index 61c25f24e..f026fde00 100644 --- a/src/map/mapreg_sql.c +++ b/src/map/mapreg_sql.c @@ -2,6 +2,15 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams +#define HERCULES_CORE + +#include "mapreg.h" + +#include <stdlib.h> +#include <string.h> + +#include "map.h" // map->mysql_handle +#include "script.h" #include "../common/cbasetypes.h" #include "../common/db.h" #include "../common/ers.h" @@ -10,11 +19,6 @@ #include "../common/sql.h" #include "../common/strlib.h" #include "../common/timer.h" -#include "map.h" // map->mysql_handle -#include "script.h" -#include "mapreg.h" -#include <stdlib.h> -#include <string.h> struct mapreg_interface mapreg_s; diff --git a/src/map/mercenary.c b/src/map/mercenary.c index 495621014..26bc8c188 100644 --- a/src/map/mercenary.c +++ b/src/map/mercenary.c @@ -2,42 +2,44 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/malloc.h" -#include "../common/socket.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/mmo.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/utils.h" +#define HERCULES_CORE -#include "log.h" -#include "clif.h" +#include "mercenary.h" + +#include <math.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "atcommand.h" +#include "battle.h" #include "chrif.h" +#include "clif.h" +#include "guild.h" #include "intif.h" #include "itemdb.h" +#include "log.h" #include "map.h" -#include "pc.h" -#include "status.h" -#include "skill.h" #include "mob.h" -#include "pet.h" -#include "battle.h" +#include "npc.h" #include "party.h" -#include "guild.h" -#include "atcommand.h" +#include "pc.h" +#include "pet.h" #include "script.h" -#include "npc.h" +#include "skill.h" +#include "status.h" #include "trade.h" #include "unit.h" -#include "mercenary.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <math.h> +#include "../common/cbasetypes.h" +#include "../common/malloc.h" +#include "../common/mmo.h" +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/timer.h" +#include "../common/utils.h" struct mercenary_interface mercenary_s; diff --git a/src/map/mercenary.h b/src/map/mercenary.h index dd9266b2e..b998ac006 100644 --- a/src/map/mercenary.h +++ b/src/map/mercenary.h @@ -6,6 +6,7 @@ #include "status.h" // struct status_data, struct status_change #include "unit.h" // struct unit_data +#include "../common/cbasetypes.h" // number of cells that a mercenary can walk to from it's master before being warped #define MAX_MER_DISTANCE 15 diff --git a/src/map/mob.c b/src/map/mob.c index 8f12d4b1b..11ac74621 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -2,46 +2,49 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/timer.h" -#include "../common/db.h" -#include "../common/nullpo.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" -#include "../common/ers.h" -#include "../common/random.h" -#include "../common/strlib.h" -#include "../common/utils.h" -#include "../common/socket.h" +#define HERCULES_CORE -#include "map.h" -#include "path.h" -#include "clif.h" -#include "intif.h" -#include "pc.h" -#include "pet.h" -#include "status.h" +#include "../config/core.h" // AUTOLOOT_DISTANCE, DBPATH, DEFTYPE_MAX, DEFTYPE_MIN, RENEWAL_DROP, RENEWAL_EXP #include "mob.h" -#include "homunculus.h" -#include "mercenary.h" + +#include <math.h> +#include <stdarg.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "atcommand.h" +#include "battle.h" +#include "clif.h" +#include "date.h" #include "elemental.h" #include "guild.h" +#include "homunculus.h" +#include "intif.h" #include "itemdb.h" -#include "skill.h" -#include "battle.h" -#include "party.h" -#include "npc.h" #include "log.h" -#include "script.h" -#include "atcommand.h" -#include "date.h" +#include "map.h" +#include "mercenary.h" +#include "npc.h" +#include "party.h" +#include "path.h" +#include "pc.h" +#include "pet.h" #include "quest.h" - -#include <stdio.h> -#include <stdlib.h> -#include <stdarg.h> -#include <string.h> -#include <math.h> +#include "script.h" +#include "skill.h" +#include "status.h" +#include "../common/cbasetypes.h" +#include "../common/db.h" +#include "../common/ers.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/timer.h" +#include "../common/utils.h" struct mob_interface mob_s; diff --git a/src/map/mob.h b/src/map/mob.h index 80175b1db..d07f78c77 100644 --- a/src/map/mob.h +++ b/src/map/mob.h @@ -5,12 +5,11 @@ #ifndef _MAP_MOB_H_ #define _MAP_MOB_H_ -#include "../common/mmo.h" // struct item -#include "guild.h" // struct guardian_data #include "map.h" // struct status_data, struct view_data, struct mob_skill -#include "status.h" // struct status data, struct status_change -#include "unit.h" // unit_stop_walking(), unit_stop_attack() -#include "npc.h" +#include "status.h" // struct status_data, struct status_change +#include "unit.h" // struct unit_data +#include "../common/cbasetypes.h" +#include "../common/mmo.h" // struct item #define MAX_RANDOMMONSTER 5 diff --git a/src/map/npc.c b/src/map/npc.c index 27759d185..289c42d44 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -2,41 +2,44 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/utils.h" -#include "../common/ers.h" -#include "../common/db.h" -#include "../common/socket.h" -#include "../common/HPM.h" +#define HERCULES_CORE -#include "map.h" -#include "log.h" +#include "../config/core.h" // NPC_SECURE_TIMEOUT_INPUT, NPC_SECURE_TIMEOUT_MENU, NPC_SECURE_TIMEOUT_NEXT, SECURE_NPCTIMEOUT, SECURE_NPCTIMEOUT_INTERVAL +#include "npc.h" + +#include <errno.h> +#include <math.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <time.h> + +#include "battle.h" +#include "chat.h" #include "clif.h" +#include "instance.h" #include "intif.h" -#include "pc.h" -#include "status.h" #include "itemdb.h" -#include "script.h" +#include "log.h" +#include "map.h" #include "mob.h" +#include "pc.h" #include "pet.h" -#include "instance.h" -#include "battle.h" +#include "script.h" #include "skill.h" +#include "status.h" #include "unit.h" -#include "npc.h" -#include "chat.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <math.h> -#include <time.h> -#include <errno.h> +#include "../common/HPM.h" +#include "../common/cbasetypes.h" +#include "../common/db.h" +#include "../common/ers.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/timer.h" +#include "../common/utils.h" struct npc_interface npc_s; diff --git a/src/map/npc.h b/src/map/npc.h index d11db0164..a277d4968 100644 --- a/src/map/npc.h +++ b/src/map/npc.h @@ -8,10 +8,10 @@ #include "map.h" // struct block_list #include "status.h" // struct status_change #include "unit.h" // struct unit_data +#include "../common/cbasetypes.h" +#include "../common/db.h" struct HPluginData; -struct block_list; -struct npc_data; struct view_data; enum npc_parse_options { diff --git a/src/map/npc_chat.c b/src/map/npc_chat.c index 9d5639efc..f245ffea5 100644 --- a/src/map/npc_chat.c +++ b/src/map/npc_chat.c @@ -2,25 +2,27 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifdef PCRE_SUPPORT +#define HERCULES_CORE -#include "../common/timer.h" -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" +#ifdef PCRE_SUPPORT -#include "mob.h" // struct mob_data #include "npc.h" // struct npc_data -#include "pc.h" // struct map_session_data -#include "script.h" // set_var() - -#include "../../3rdparty/pcre/include/pcre.h" +#include <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <stdarg.h> + +#include "../../3rdparty/pcre/include/pcre.h" + +#include "mob.h" // struct mob_data +#include "pc.h" // struct map_session_data +#include "script.h" // set_var() +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" +#include "../common/timer.h" /** * interface sources diff --git a/src/map/party.c b/src/map/party.c index cf5e7bbe3..7c49e241c 100644 --- a/src/map/party.c +++ b/src/map/party.c @@ -2,34 +2,37 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/timer.h" -#include "../common/socket.h" // last_tick -#include "../common/nullpo.h" -#include "../common/malloc.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/utils.h" -#include "../common/strlib.h" -#include "../common/HPM.h" +#define HERCULES_CORE +#include "../config/core.h" // GP_BOUND_ITEMS, RENEWAL_EXP #include "party.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + #include "atcommand.h" //msg_txt() -#include "pc.h" -#include "map.h" -#include "instance.h" #include "battle.h" -#include "intif.h" #include "clif.h" +#include "instance.h" +#include "intif.h" +#include "itemdb.h" #include "log.h" +#include "map.h" +#include "mob.h" // struct mob_data +#include "pc.h" #include "skill.h" #include "status.h" -#include "itemdb.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - +#include "../common/HPM.h" +#include "../common/cbasetypes.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/socket.h" // last_tick +#include "../common/strlib.h" +#include "../common/timer.h" +#include "../common/utils.h" struct party_interface party_s; diff --git a/src/map/party.h b/src/map/party.h index ed8289af6..3bad22b13 100644 --- a/src/map/party.h +++ b/src/map/party.h @@ -5,11 +5,12 @@ #ifndef _MAP_PARTY_H_ #define _MAP_PARTY_H_ -#include "../common/mmo.h" // struct party -#include "../config/core.h" #include <stdarg.h> -#include "map.h" +#include "map.h" // TBL_PC +#include "../common/cbasetypes.h" +#include "../common/db.h" +#include "../common/mmo.h" // struct party #define PARTY_BOOKING_JOBS 6 #define PARTY_BOOKING_RESULTS 10 diff --git a/src/map/path.c b/src/map/path.c index ae9fc389d..d02e9ee4a 100644 --- a/src/map/path.c +++ b/src/map/path.c @@ -2,20 +2,23 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/db.h" -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/random.h" -#include "../common/showmsg.h" +#define HERCULES_CORE +#include "../config/core.h" // CELL_NOSTACK, CIRCULAR_AREA #include "path.h" -#include "map.h" #include <stdio.h> #include <stdlib.h> #include <string.h> +#include "map.h" +#include "../common/cbasetypes.h" +#include "../common/db.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" + #define SET_OPEN 0 #define SET_CLOSED 1 diff --git a/src/map/path.h b/src/map/path.h index 0b67a0120..b48ff05fb 100644 --- a/src/map/path.h +++ b/src/map/path.h @@ -6,6 +6,7 @@ #define _MAP_PATH_H_ #include "map.h" // enum cell_chk +#include "../common/cbasetypes.h" #define MOVE_COST 10 #define MOVE_DIAGONAL_COST 14 diff --git a/src/map/pc.c b/src/map/pc.c index c8fb14e55..45adfe22a 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -2,21 +2,16 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/core.h" // get_svn_revision() -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/socket.h" // session[] -#include "../common/strlib.h" // safestrncpy() -#include "../common/timer.h" -#include "../common/utils.h" -#include "../common/conf.h" -#include "../common/mmo.h" //NAME_LENGTH -#include "../common/sysinfo.h" +#define HERCULES_CORE +#include "../config/core.h" // DBPATH, GP_BOUND_ITEMS, MAX_CARTS, MAX_SPIRITBALL, NEW_CARTS, RENEWAL, RENEWAL_ASPD, RENEWAL_CAST, RENEWAL_DROP, RENEWAL_EXP, SECURE_NPCTIMEOUT #include "pc.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <time.h> + #include "atcommand.h" // get_atcommand_level() #include "battle.h" // battle_config #include "battleground.h" @@ -25,32 +20,40 @@ #include "clif.h" #include "date.h" // is_day_of_*() #include "duel.h" +#include "elemental.h" +#include "guild.h" // guild->search(), guild_request_info() +#include "homunculus.h" +#include "instance.h" #include "intif.h" #include "itemdb.h" #include "log.h" #include "mail.h" #include "map.h" -#include "path.h" -#include "homunculus.h" -#include "instance.h" #include "mercenary.h" -#include "elemental.h" +#include "mob.h" // struct mob_data #include "npc.h" // fake_nd -#include "pet.h" // pet_unlocktarget() #include "party.h" // party->search() -#include "guild.h" // guild->search(), guild_request_info() +#include "path.h" +#include "pc_groups.h" +#include "pet.h" // pet_unlocktarget() +#include "quest.h" #include "script.h" // script_config #include "skill.h" #include "status.h" // struct status_data #include "storage.h" -#include "pc_groups.h" -#include "quest.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <time.h> - +#include "../common/cbasetypes.h" +#include "../common/conf.h" +#include "../common/core.h" // get_svn_revision() +#include "../common/malloc.h" +#include "../common/mmo.h" //NAME_LENGTH +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/socket.h" // session[] +#include "../common/strlib.h" // safestrncpy() +#include "../common/sysinfo.h" +#include "../common/timer.h" +#include "../common/utils.h" struct pc_interface pc_s; @@ -10651,9 +10654,7 @@ void pc_defaults(void) { memset(pc->exp_table, 0, sizeof(pc->exp_table) + sizeof(pc->max_level) + sizeof(pc->statp) -#if defined(RENEWAL_DROP) || defined(RENEWAL_EXP) + sizeof(pc->level_penalty) -#endif + sizeof(pc->skill_tree) + sizeof(pc->smith_fame_list) + sizeof(pc->chemist_fame_list) diff --git a/src/map/pc.h b/src/map/pc.h index 70df9ca56..c4026a48d 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -5,23 +5,23 @@ #ifndef _MAP_PC_H_ #define _MAP_PC_H_ -#include "../common/mmo.h" // JOB_*, MAX_FAME_LIST, struct fame_list, struct mmo_charstatus -#include "../common/ers.h" -#include "../common/timer.h" // INVALID_TIMER -#include "atcommand.h" // AtCommandType +#include "../config/core.h" // AUTOLOOTITEM_SIZE, RENEWAL, SECURE_NPCTIMEOUT + #include "battle.h" // battle_config -#include "battleground.h" +#include "battleground.h" // enum bg_queue_types #include "buyingstore.h" // struct s_buyingstore -#include "itemdb.h" -#include "log.h" -#include "map.h" // RC_MAX -#include "mob.h" -#include "pc_groups.h" -#include "script.h" // struct script_reg, struct script_regstr +#include "itemdb.h" // MAX_ITEMDELAYS +#include "log.h" // struct e_log_pick_type +#include "map.h" // RC_MAX, ELE_MAX +#include "pc_groups.h" // GroupSettings +#include "script.h" // struct reg_db #include "searchstore.h" // struct s_search_store_info -#include "status.h" // OPTION_*, struct weapon_atk -#include "unit.h" // unit_stop_attack(), unit_stop_walking() +#include "status.h" // enum sc_type, OPTION_* +#include "unit.h" // struct unit_data, struct view_data #include "vending.h" // struct s_vending +#include "../common/cbasetypes.h" +#include "../common/ers.h" // struct eri +#include "../common/mmo.h" // JOB_*, MAX_FAME_LIST, struct fame_list, struct mmo_charstatus /** * Defines @@ -742,9 +742,8 @@ struct pc_interface { unsigned int exp_table[CLASS_COUNT][2][MAX_LEVEL]; unsigned int max_level[CLASS_COUNT][2]; unsigned int statp[MAX_LEVEL+1]; -#if defined(RENEWAL_DROP) || defined(RENEWAL_EXP) unsigned int level_penalty[3][RC_MAX][MAX_LEVEL*2+1]; -#endif + unsigned int equip_pos[EQI_MAX]; /* */ struct skill_tree_entry skill_tree[CLASS_COUNT][MAX_SKILL_TREE]; diff --git a/src/map/pc_groups.c b/src/map/pc_groups.c index 906462c7e..a917ef409 100644 --- a/src/map/pc_groups.c +++ b/src/map/pc_groups.c @@ -2,6 +2,14 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams +#define HERCULES_CORE + +#include "pc_groups.h" + +#include "atcommand.h" // atcommand->exists(), atcommand->load_groups() +#include "clif.h" // clif->GM_kick() +#include "map.h" // mapiterator +#include "pc.h" // pc->set_group() #include "../common/cbasetypes.h" #include "../common/conf.h" #include "../common/db.h" @@ -10,12 +18,6 @@ #include "../common/showmsg.h" #include "../common/strlib.h" // strcmp -#include "pc_groups.h" -#include "atcommand.h" // atcommand->exists(), atcommand->load_groups() -#include "clif.h" // clif->GM_kick() -#include "map.h" // mapiterator -#include "pc.h" // pc->set_group() - static GroupSettings dummy_group; ///< dummy group used in dummy map sessions @see pc_get_dummy_sd() struct pc_groups_interface pcg_s; diff --git a/src/map/pc_groups.h b/src/map/pc_groups.h index 5c03f999f..7c8cdd82a 100644 --- a/src/map/pc_groups.h +++ b/src/map/pc_groups.h @@ -5,6 +5,10 @@ #ifndef _MAP_PC_GROUPS_H_ #define _MAP_PC_GROUPS_H_ +#include "../common/cbasetypes.h" +#include "../common/conf.h" +#include "../common/db.h" + /// PC permissions enum e_pc_permission { PC_PERM_NONE = 0, // #0 diff --git a/src/map/pet.c b/src/map/pet.c index 993497434..aa2be4473 100644 --- a/src/map/pet.c +++ b/src/map/pet.c @@ -2,37 +2,39 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/db.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/malloc.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/utils.h" -#include "../common/ers.h" +#define HERCULES_CORE -#include "pc.h" -#include "status.h" -#include "map.h" -#include "path.h" -#include "intif.h" -#include "clif.h" -#include "chrif.h" #include "pet.h" -#include "itemdb.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "atcommand.h" // msg_txt() #include "battle.h" +#include "chrif.h" +#include "clif.h" +#include "intif.h" +#include "itemdb.h" +#include "log.h" +#include "map.h" #include "mob.h" #include "npc.h" +#include "path.h" +#include "pc.h" #include "script.h" #include "skill.h" +#include "status.h" #include "unit.h" -#include "atcommand.h" // msg_txt() -#include "log.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> +#include "../common/db.h" +#include "../common/ers.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" +#include "../common/timer.h" +#include "../common/utils.h" struct pet_interface pet_s; diff --git a/src/map/pet.h b/src/map/pet.h index 4ec30b3fb..8dde0fac2 100644 --- a/src/map/pet.h +++ b/src/map/pet.h @@ -5,8 +5,14 @@ #ifndef _MAP_PET_H_ #define _MAP_PET_H_ -#define MAX_PET_DB 300 -#define MAX_PETLOOT_SIZE 30 +#include "map.h" // struct block_list +#include "status.h" // enum sc_type +#include "unit.h" // struct unit_data +#include "../common/cbasetypes.h" +#include "../common/mmo.h" // NAME_LENGTH, struct s_pet + +#define MAX_PET_DB 300 +#define MAX_PETLOOT_SIZE 30 struct s_pet_db { short class_; diff --git a/src/map/quest.c b/src/map/quest.c index bde276f9d..b76d6bc82 100644 --- a/src/map/quest.c +++ b/src/map/quest.c @@ -2,36 +2,37 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/socket.h" -#include "../common/timer.h" -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/utils.h" +#define HERCULES_CORE -#include "map.h" -#include "pc.h" -#include "npc.h" -#include "itemdb.h" -#include "script.h" -#include "intif.h" -#include "battle.h" -#include "mob.h" -#include "party.h" -#include "unit.h" -#include "log.h" -#include "clif.h" #include "quest.h" -#include "chrif.h" +#include <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <stdarg.h> #include <time.h> +#include "battle.h" +#include "chrif.h" +#include "clif.h" +#include "intif.h" +#include "itemdb.h" +#include "log.h" +#include "map.h" +#include "mob.h" +#include "npc.h" +#include "party.h" +#include "pc.h" +#include "script.h" +#include "unit.h" +#include "../common/cbasetypes.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/timer.h" +#include "../common/utils.h" struct quest_interface quest_s; diff --git a/src/map/quest.h b/src/map/quest.h index e01e35619..87894d639 100644 --- a/src/map/quest.h +++ b/src/map/quest.h @@ -5,6 +5,10 @@ #ifndef _MAP_QUEST_H_ #define _MAP_QUEST_H_ +#include "map.h" // TBL_PC +#include "../common/cbasetypes.h" +#include "../common/mmo.h" // MAX_QUEST_OBJECTIVES + #define MAX_QUEST_DB (60355+1) // Highest quest ID + 1 struct quest_db { diff --git a/src/map/script.c b/src/map/script.c index aecdf9b28..e4cf7f227 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -2,6 +2,46 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams +#define HERCULES_CORE + +#include "../config/core.h" // NEW_CARTS, RENEWAL, RENEWAL_ASPD, RENEWAL_CAST, RENEWAL_DROP, RENEWAL_EDP, RENEWAL_EXP, RENEWAL_LVDMG, SCRIPT_CALLFUNC_CHECK, SECURE_NPCTIMEOUT, SECURE_NPCTIMEOUT_INTERVAL +#include "script.h" + +#include <math.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "atcommand.h" +#include "battle.h" +#include "battleground.h" +#include "chat.h" +#include "chrif.h" +#include "clif.h" +#include "elemental.h" +#include "guild.h" +#include "homunculus.h" +#include "instance.h" +#include "intif.h" +#include "itemdb.h" +#include "log.h" +#include "mail.h" +#include "map.h" +#include "mapreg.h" +#include "mercenary.h" +#include "mob.h" +#include "npc.h" +#include "party.h" +#include "path.h" +#include "pc.h" +#include "pet.h" +#include "pet.h" +#include "quest.h" +#include "skill.h" +#include "status.h" +#include "status.h" +#include "storage.h" +#include "unit.h" #include "../common/cbasetypes.h" #include "../common/malloc.h" #include "../common/md5calc.h" @@ -10,47 +50,10 @@ #include "../common/showmsg.h" #include "../common/socket.h" // usage: getcharip #include "../common/strlib.h" +#include "../common/sysinfo.h" #include "../common/timer.h" #include "../common/utils.h" -#include "../common/sysinfo.h" - -#include "map.h" -#include "path.h" -#include "clif.h" -#include "chrif.h" -#include "itemdb.h" -#include "pc.h" -#include "status.h" -#include "storage.h" -#include "mob.h" -#include "npc.h" -#include "pet.h" -#include "mapreg.h" -#include "homunculus.h" -#include "instance.h" -#include "mercenary.h" -#include "intif.h" -#include "skill.h" -#include "status.h" -#include "chat.h" -#include "battle.h" -#include "battleground.h" -#include "party.h" -#include "guild.h" -#include "atcommand.h" -#include "log.h" -#include "unit.h" -#include "pet.h" -#include "mail.h" -#include "script.h" -#include "quest.h" -#include "elemental.h" -#include "../config/core.h" -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <math.h> #ifndef WIN32 #include <sys/time.h> #endif diff --git a/src/map/script.h b/src/map/script.h index 90b18d87f..899c745da 100644 --- a/src/map/script.h +++ b/src/map/script.h @@ -5,17 +5,19 @@ #ifndef _MAP_SCRIPT_H_ #define _MAP_SCRIPT_H_ -#include "../common/strlib.h" //StringBuf -#include "../common/cbasetypes.h" -#include "map.h" //EVENT_NAME_LENGTH - #include <setjmp.h> #include <errno.h> +#include "map.h" //EVENT_NAME_LENGTH +#include "../common/cbasetypes.h" +#include "../common/db.h" +#include "../common/mmo.h" // struct item +#include "../common/sql.h" // Sql +#include "../common/strlib.h" //StringBuf + /** * Declarations **/ -struct map_session_data; struct eri; /** diff --git a/src/map/searchstore.c b/src/map/searchstore.c index 0144aea93..72b28aacd 100644 --- a/src/map/searchstore.c +++ b/src/map/searchstore.c @@ -2,14 +2,17 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams +#define HERCULES_CORE + +#include "searchstore.h" // struct s_search_store_info + +#include "battle.h" // battle_config.* +#include "clif.h" // clif->open_search_store_info, clif->search_store_info_* +#include "pc.h" // struct map_session_data #include "../common/cbasetypes.h" #include "../common/malloc.h" // aMalloc, aRealloc, aFree #include "../common/showmsg.h" // ShowError, ShowWarning #include "../common/strlib.h" // safestrncpy -#include "battle.h" // battle_config.* -#include "clif.h" // clif->open_search_store_info, clif->search_store_info_* -#include "pc.h" // struct map_session_data -#include "searchstore.h" // struct s_search_store_info struct searchstore_interface searchstore_s; diff --git a/src/map/searchstore.h b/src/map/searchstore.h index 827e39053..c9b93ba54 100644 --- a/src/map/searchstore.h +++ b/src/map/searchstore.h @@ -5,6 +5,12 @@ #ifndef _MAP_SEARCHSTORE_H_ #define _MAP_SEARCHSTORE_H_ +#include <time.h> + +#include "map.h" // MESSAGE_SIZE +#include "../common/cbasetypes.h" +#include "../common/mmo.h" // MAX_SLOTS + /** * Defines **/ diff --git a/src/map/skill.c b/src/map/skill.c index c8388770a..b2e94ec79 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -2,46 +2,48 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/malloc.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/utils.h" -#include "../common/ers.h" +#define HERCULES_CORE -#include "map.h" -#include "path.h" -#include "clif.h" -#include "pc.h" -#include "status.h" +#include "../config/core.h" // DBPATH, MAGIC_REFLECTION_TYPE, OFFICIAL_WALKPATH, RENEWAL, RENEWAL_CAST, VARCAST_REDUCTION() #include "skill.h" -#include "pet.h" + +#include <math.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <time.h> + +#include "battle.h" +#include "battleground.h" +#include "chrif.h" +#include "clif.h" +#include "date.h" +#include "elemental.h" +#include "guild.h" #include "homunculus.h" +#include "intif.h" +#include "itemdb.h" +#include "log.h" +#include "map.h" #include "mercenary.h" -#include "elemental.h" #include "mob.h" #include "npc.h" -#include "battle.h" -#include "battleground.h" #include "party.h" -#include "itemdb.h" +#include "path.h" +#include "pc.h" +#include "pet.h" #include "script.h" -#include "intif.h" -#include "log.h" -#include "chrif.h" -#include "guild.h" -#include "date.h" +#include "status.h" #include "unit.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <time.h> -#include <math.h> - +#include "../common/cbasetypes.h" +#include "../common/ers.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" +#include "../common/timer.h" +#include "../common/utils.h" #define SKILLUNITTIMER_INTERVAL 100 diff --git a/src/map/skill.h b/src/map/skill.h index dda310bd4..b6dbb1fcb 100644 --- a/src/map/skill.h +++ b/src/map/skill.h @@ -5,19 +5,23 @@ #ifndef _MAP_SKILL_H_ #define _MAP_SKILL_H_ -#include "../common/mmo.h" // MAX_SKILL, struct square -#include "../common/db.h" +#include "../config/core.h" // RENEWAL_CAST + #include "map.h" // struct block_list +#include "status.h" // enum sc_type +#include "../common/cbasetypes.h" +#include "../common/db.h" +#include "../common/mmo.h" // MAX_SKILL, struct square /** * Declarations **/ -struct map_session_data; struct homun_data; +struct map_session_data; +struct mercenary_data; struct skill_unit; -struct skill_unit_group; -struct status_change_entry; struct square; +struct status_change_entry; /** * Defines diff --git a/src/map/status.c b/src/map/status.c index 4c2bc6d22..eb06138da 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -2,43 +2,46 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/malloc.h" -#include "../common/utils.h" -#include "../common/ers.h" -#include "../common/strlib.h" +#define HERCULES_CORE + +#include "../config/core.h" // ANTI_MAYAP_CHEAT, DBPATH, DEFTYPE_MAX, DEFTYPE_MIN, DEVOTION_REFLECT_DAMAGE, RENEWAL, RENEWAL_ASPD, RENEWAL_EDP +#include "status.h" +#include <math.h> +#include <memory.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <time.h> + +#include "battle.h" +#include "chrif.h" +#include "clif.h" +#include "elemental.h" +#include "guild.h" +#include "homunculus.h" +#include "itemdb.h" #include "map.h" +#include "mercenary.h" +#include "mob.h" +#include "npc.h" #include "path.h" #include "pc.h" #include "pet.h" -#include "npc.h" -#include "mob.h" -#include "clif.h" -#include "guild.h" +#include "script.h" #include "skill.h" -#include "itemdb.h" -#include "battle.h" -#include "chrif.h" #include "skill.h" -#include "status.h" -#include "script.h" #include "unit.h" -#include "homunculus.h" -#include "mercenary.h" -#include "elemental.h" #include "vending.h" - -#include <time.h> -#include <stdio.h> -#include <stdlib.h> -#include <memory.h> -#include <string.h> -#include <math.h> +#include "../common/cbasetypes.h" +#include "../common/ers.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" +#include "../common/timer.h" +#include "../common/utils.h" struct status_interface status_s; diff --git a/src/map/status.h b/src/map/status.h index e47c2b365..baa586297 100644 --- a/src/map/status.h +++ b/src/map/status.h @@ -5,14 +5,18 @@ #ifndef _MAP_STATUS_H_ #define _MAP_STATUS_H_ +#include "../config/core.h" // defType, NEW_CARTS, RENEWAL, RENEWAL_ASPD + +#include "../common/cbasetypes.h" #include "../common/mmo.h" struct block_list; -struct mob_data; -struct pet_data; +struct elemental_data; struct homun_data; struct mercenary_data; -struct status_change; +struct mob_data; +struct npc_data; +struct pet_data; //Change the equation when the values are high enough to discard the //imprecision in exchange of overflow protection [Skotlex] @@ -1878,11 +1882,7 @@ struct status_interface { int hp_coefficient2[CLASS_COUNT]; int hp_sigma_val[CLASS_COUNT][MAX_LEVEL+1]; int sp_coefficient[CLASS_COUNT]; -#ifdef RENEWAL_ASPD - int aspd_base[CLASS_COUNT][MAX_WEAPON_TYPE+1]; -#else - int aspd_base[CLASS_COUNT][MAX_WEAPON_TYPE]; //[blackhole89] -#endif + int aspd_base[CLASS_COUNT][MAX_WEAPON_TYPE+1]; // +1 for RENEWAL_ASPD sc_type Skill2SCTable[MAX_SKILL]; // skill -> status int IconChangeTable[SC_MAX]; // status -> "icon" (icon is a bit of a misnomer, since there exist values with no icon associated) unsigned int ChangeFlagTable[SC_MAX]; // status -> flags diff --git a/src/map/storage.c b/src/map/storage.c index e65ed7b80..2db5fff3d 100644 --- a/src/map/storage.c +++ b/src/map/storage.c @@ -2,28 +2,30 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/db.h" -#include "../common/nullpo.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" +#define HERCULES_CORE -#include "map.h" // struct map_session_data #include "storage.h" -#include "chrif.h" -#include "itemdb.h" -#include "clif.h" -#include "intif.h" -#include "pc.h" -#include "guild.h" -#include "battle.h" -#include "atcommand.h" -#include "log.h" #include <stdio.h> #include <stdlib.h> #include <string.h> +#include "atcommand.h" +#include "battle.h" +#include "chrif.h" +#include "clif.h" +#include "guild.h" +#include "intif.h" +#include "itemdb.h" +#include "log.h" +#include "map.h" // struct map_session_data +#include "pc.h" +#include "../common/cbasetypes.h" +#include "../common/db.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/showmsg.h" + struct storage_interface storage_s; struct guild_storage_interface gstorage_s; diff --git a/src/map/storage.h b/src/map/storage.h index 8f9f904f6..5edb68cfc 100644 --- a/src/map/storage.h +++ b/src/map/storage.h @@ -5,11 +5,12 @@ #ifndef _MAP_STORAGE_H_ #define _MAP_STORAGE_H_ -struct storage_data; +#include "../common/cbasetypes.h" +#include "../common/db.h" + struct guild_storage; struct item; struct map_session_data; -struct DBMap; struct storage_interface { /* */ diff --git a/src/map/trade.c b/src/map/trade.c index 44b669ebd..83426c407 100644 --- a/src/map/trade.c +++ b/src/map/trade.c @@ -2,25 +2,27 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/nullpo.h" -#include "../common/socket.h" +#define HERCULES_CORE #include "trade.h" + +#include <stdio.h> +#include <string.h> + +#include "atcommand.h" +#include "battle.h" +#include "chrif.h" #include "clif.h" +#include "intif.h" #include "itemdb.h" +#include "log.h" #include "map.h" +#include "npc.h" #include "path.h" #include "pc.h" -#include "npc.h" -#include "battle.h" -#include "chrif.h" #include "storage.h" -#include "intif.h" -#include "atcommand.h" -#include "log.h" - -#include <stdio.h> -#include <string.h> +#include "../common/nullpo.h" +#include "../common/socket.h" struct trade_interface trade_s; diff --git a/src/map/unit.c b/src/map/unit.c index 151d4bad5..0ad770e80 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -2,45 +2,48 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/showmsg.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/db.h" -#include "../common/malloc.h" -#include "../common/random.h" -#include "../common/HPM.h" +#define HERCULES_CORE +#include "../config/core.h" // RENEWAL_CAST +#include "unit.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "battle.h" +#include "battleground.h" +#include "chat.h" +#include "chrif.h" +#include "clif.h" +#include "duel.h" +#include "elemental.h" +#include "guild.h" +#include "homunculus.h" +#include "instance.h" +#include "intif.h" #include "map.h" +#include "mercenary.h" +#include "mob.h" +#include "npc.h" +#include "party.h" #include "path.h" #include "pc.h" -#include "mob.h" #include "pet.h" -#include "homunculus.h" -#include "instance.h" -#include "mercenary.h" -#include "elemental.h" +#include "script.h" #include "skill.h" -#include "clif.h" -#include "duel.h" -#include "npc.h" -#include "guild.h" #include "status.h" -#include "unit.h" -#include "battle.h" -#include "battleground.h" -#include "chat.h" +#include "storage.h" #include "trade.h" #include "vending.h" -#include "party.h" -#include "intif.h" -#include "chrif.h" -#include "script.h" -#include "storage.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - +#include "../common/HPM.h" +#include "../common/db.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/timer.h" const short dirx[8]={0,-1,-1,-1,0,1,1,1}; const short diry[8]={1,1,0,-1,-1,-1,0,1}; diff --git a/src/map/unit.h b/src/map/unit.h index 33fa4e052..9e05647b1 100644 --- a/src/map/unit.h +++ b/src/map/unit.h @@ -5,15 +5,13 @@ #ifndef _MAP_UNIT_H_ #define _MAP_UNIT_H_ -//#include "map.h" -struct block_list; -struct unit_data; -struct map_session_data; - #include "clif.h" // clr_type -#include "map.h" // struct block_list #include "path.h" // struct walkpath_data -#include "skill.h" // struct skill_timerskill, struct skill_unit_group, struct skill_unit_group_tickset +#include "skill.h" // 'MAX_SKILLTIMERSKILL, struct skill_timerskill, struct skill_unit_group, struct skill_unit_group_tickset +#include "../common/cbasetypes.h" + +struct map_session_data; +struct block_list; struct unit_data { struct block_list *bl; diff --git a/src/map/vending.c b/src/map/vending.c index 9462975b3..c8ac814db 100644 --- a/src/map/vending.c +++ b/src/map/vending.c @@ -2,24 +2,27 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/nullpo.h" -#include "../common/strlib.h" -#include "../common/utils.h" +#define HERCULES_CORE + +#include "vending.h" + +#include <stdio.h> +#include <string.h> + +#include "atcommand.h" +#include "battle.h" +#include "chrif.h" #include "clif.h" #include "itemdb.h" -#include "atcommand.h" +#include "log.h" #include "map.h" +#include "npc.h" #include "path.h" -#include "chrif.h" -#include "vending.h" #include "pc.h" -#include "npc.h" #include "skill.h" -#include "battle.h" -#include "log.h" - -#include <stdio.h> -#include <string.h> +#include "../common/nullpo.h" +#include "../common/strlib.h" +#include "../common/utils.h" struct vending_interface vending_s; diff --git a/src/map/vending.h b/src/map/vending.h index a212f8385..a70726374 100644 --- a/src/map/vending.h +++ b/src/map/vending.h @@ -7,6 +7,7 @@ #include "../common/cbasetypes.h" #include "../common/db.h" + struct map_session_data; struct s_search_store_search; diff --git a/src/tool/mapcache.c b/src/tool/mapcache.c index 85d5fb548..96d51aec6 100644 --- a/src/tool/mapcache.c +++ b/src/tool/mapcache.c @@ -1,6 +1,14 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder +#define HERCULES_CORE + +#include "../config/core.h" // RENEWAL + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + #include "../common/cbasetypes.h" #include "../common/grfio.h" #include "../common/malloc.h" @@ -8,12 +16,6 @@ #include "../common/showmsg.h" #include "../common/utils.h" -#include "../config/renewal.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - #ifndef _WIN32 #include <unistd.h> #endif -- cgit v1.2.3-70-g09d2 From 94657284973f4037596bae468ebfbee5c217e02b Mon Sep 17 00:00:00 2001 From: panikon <panikon@zoho.com> Date: Sat, 10 May 2014 06:08:56 -0300 Subject: Revert "Fixed order of includes in all source files" This reverts commit b6b3f58795288701d0e162d43fa6f0a47af913b3. Fixes issue 8184 http://hercules.ws/board/tracker/issue-8184-cart-related/ --- src/char/char.c | 44 +++++----- src/char/char.h | 1 + src/char/int_auction.c | 25 +++--- src/char/int_elemental.c | 22 ++--- src/char/int_elemental.h | 2 +- src/char/int_guild.c | 24 +++-- src/char/int_guild.h | 3 + src/char/int_homun.c | 21 ++--- src/char/int_homun.h | 2 - src/char/int_mail.c | 20 ++--- src/char/int_mail.h | 3 - src/char/int_mercenary.c | 22 ++--- src/char/int_mercenary.h | 4 +- src/char/int_party.c | 25 +++--- src/char/int_party.h | 2 + src/char/int_pet.c | 22 ++--- src/char/int_quest.c | 22 +++-- src/char/int_storage.c | 22 ++--- src/char/inter.c | 43 +++++---- src/char/inter.h | 5 +- src/char/pincode.c | 11 +-- src/common/HPM.c | 31 +++---- src/common/HPM.h | 6 +- src/common/HPMi.h | 16 +++- src/common/cbasetypes.h | 6 -- src/common/conf.c | 3 - src/common/conf.h | 1 - src/common/console.c | 223 +++++++++++++++++++++++------------------------ src/common/console.h | 21 ++--- src/common/core.c | 38 ++++---- src/common/core.h | 3 +- src/common/db.c | 10 +-- src/common/db.h | 3 +- src/common/des.c | 7 +- src/common/ers.c | 8 +- src/common/grfio.c | 17 ++-- src/common/malloc.c | 11 +-- src/common/mapindex.c | 15 ++-- src/common/md5calc.c | 8 +- src/common/mmo.h | 6 +- src/common/mutex.c | 5 +- src/common/mutex.h | 1 - src/common/nullpo.c | 6 +- src/common/random.c | 18 ++-- src/common/showmsg.c | 17 ++-- src/common/showmsg.h | 23 ++--- src/common/socket.c | 64 +++++++------- src/common/socket.h | 12 +-- src/common/spinlock.h | 9 +- src/common/sql.c | 12 +-- src/common/sql.h | 3 +- src/common/strlib.c | 13 ++- src/common/strlib.h | 15 ++-- src/common/sysinfo.c | 32 ++----- src/common/sysinfo.h | 16 ++++ src/common/thread.c | 31 +++---- src/common/thread.h | 1 + src/common/timer.c | 19 ++-- src/common/utils.c | 36 ++++---- src/common/utils.h | 3 +- src/config/const.h | 7 ++ src/config/renewal.h | 1 - src/login/account.h | 1 - src/login/account_sql.c | 17 ++-- src/login/ipban_sql.c | 14 ++- src/login/login.c | 21 ++--- src/login/login.h | 2 +- src/login/loginlog.h | 2 +- src/login/loginlog_sql.c | 9 +- src/map/HPMmap.c | 42 ++++----- src/map/atcommand.c | 67 +++++++------- src/map/atcommand.h | 2 +- src/map/battle.c | 61 ++++++------- src/map/battle.h | 2 +- src/map/battleground.c | 33 ++++--- src/map/battleground.h | 2 +- src/map/buyingstore.c | 17 ++-- src/map/buyingstore.h | 5 -- src/map/chat.c | 23 +++-- src/map/chat.h | 5 +- src/map/chrif.c | 35 ++++---- src/map/chrif.h | 4 +- src/map/clif.c | 83 +++++++++--------- src/map/clif.h | 9 +- src/map/date.c | 6 +- src/map/date.h | 2 - src/map/duel.c | 10 +-- src/map/duel.h | 4 - src/map/elemental.c | 54 ++++++------ src/map/elemental.h | 1 - src/map/guild.c | 47 +++++----- src/map/guild.h | 16 +++- src/map/homunculus.c | 56 ++++++------ src/map/homunculus.h | 3 +- src/map/instance.c | 34 ++++---- src/map/instance.h | 3 - src/map/intif.c | 51 +++++------ src/map/intif.h | 13 ++- src/map/irc-bot.c | 22 +++-- src/map/irc-bot.h | 2 - src/map/itemdb.c | 27 +++--- src/map/itemdb.h | 5 +- src/map/log.c | 23 +++-- src/map/log.h | 5 +- src/map/mail.c | 16 ++-- src/map/mail.h | 6 +- src/map/map.c | 96 ++++++++++---------- src/map/map.h | 9 +- src/map/mapreg_sql.c | 14 ++- src/map/mercenary.c | 54 ++++++------ src/map/mercenary.h | 1 - src/map/mob.c | 69 +++++++-------- src/map/mob.h | 9 +- src/map/npc.c | 57 ++++++------ src/map/npc.h | 4 +- src/map/npc_chat.c | 26 +++--- src/map/party.c | 43 +++++---- src/map/party.h | 7 +- src/map/path.c | 17 ++-- src/map/path.h | 1 - src/map/pc.c | 59 ++++++------- src/map/pc.h | 29 +++--- src/map/pc_groups.c | 14 ++- src/map/pc_groups.h | 4 - src/map/pet.c | 48 +++++----- src/map/pet.h | 10 +-- src/map/quest.c | 45 +++++----- src/map/quest.h | 4 - src/map/script.c | 79 ++++++++--------- src/map/script.h | 12 ++- src/map/searchstore.c | 11 +-- src/map/searchstore.h | 6 -- src/map/skill.c | 64 +++++++------- src/map/skill.h | 14 ++- src/map/status.c | 59 ++++++------- src/map/status.h | 16 ++-- src/map/storage.c | 32 ++++--- src/map/storage.h | 5 +- src/map/trade.c | 24 +++-- src/map/unit.c | 63 +++++++------ src/map/unit.h | 12 +-- src/map/vending.c | 27 +++--- src/map/vending.h | 1 - src/tool/mapcache.c | 14 ++- 144 files changed, 1367 insertions(+), 1676 deletions(-) (limited to 'src/map/elemental.c') diff --git a/src/char/char.c b/src/char/char.c index 6c0902644..77e393c0d 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -2,30 +2,7 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "../config/core.h" // CONSOLE_INPUT -#include "char.h" - -#include <signal.h> -#include <stdarg.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <sys/types.h> -#include <time.h> - -#include "int_elemental.h" -#include "int_guild.h" -#include "int_homun.h" -#include "int_mercenary.h" -#include "int_party.h" -#include "int_storage.h" -#include "inter.h" -#include "pincode.h" -#include "../common/HPM.h" #include "../common/cbasetypes.h" -#include "../common/console.h" #include "../common/core.h" #include "../common/db.h" #include "../common/malloc.h" @@ -36,6 +13,25 @@ #include "../common/strlib.h" #include "../common/timer.h" #include "../common/utils.h" +#include "../common/console.h" +#include "../common/HPM.h" +#include "int_guild.h" +#include "int_homun.h" +#include "int_mercenary.h" +#include "int_elemental.h" +#include "int_party.h" +#include "int_storage.h" +#include "char.h" +#include "inter.h" +#include "pincode.h" + +#include <sys/types.h> +#include <time.h> +#include <signal.h> +#include <string.h> +#include <stdarg.h> +#include <stdio.h> +#include <stdlib.h> // private declarations #define CHAR_CONF_NAME "conf/char-server.conf" @@ -5501,7 +5497,7 @@ int do_init(int argc, char **argv) { Sql_HerculesUpdateCheck(sql_handle); #ifdef CONSOLE_INPUT - console->input->setSQL(sql_handle); + console->setSQL(sql_handle); #endif ShowStatus("The char-server is "CL_GREEN"ready"CL_RESET" (Server is listening on the port %d).\n\n", char_port); diff --git a/src/char/char.h b/src/char/char.h index 09a78f6b9..2928929de 100644 --- a/src/char/char.h +++ b/src/char/char.h @@ -5,6 +5,7 @@ #ifndef _COMMON_CHAR_H_ #define _COMMON_CHAR_H_ +#include "../config/core.h" #include "../common/core.h" // CORE_ST_LAST #include "../common/db.h" diff --git a/src/char/int_auction.c b/src/char/int_auction.c index 886b5be26..924930867 100644 --- a/src/char/int_auction.c +++ b/src/char/int_auction.c @@ -2,25 +2,22 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "int_auction.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "char.h" -#include "int_mail.h" -#include "inter.h" -#include "../common/db.h" -#include "../common/malloc.h" #include "../common/mmo.h" +#include "../common/malloc.h" +#include "../common/db.h" #include "../common/showmsg.h" #include "../common/socket.h" -#include "../common/sql.h" #include "../common/strlib.h" +#include "../common/sql.h" #include "../common/timer.h" +#include "char.h" +#include "inter.h" +#include "int_mail.h" +#include "int_auction.h" + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> static DBMap* auction_db_ = NULL; // int auction_id -> struct auction_data* diff --git a/src/char/int_elemental.c b/src/char/int_elemental.c index 3a36e75a2..ed0c2a9ed 100644 --- a/src/char/int_elemental.c +++ b/src/char/int_elemental.c @@ -2,23 +2,19 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "int_elemental.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "char.h" -#include "inter.h" -#include "../common/malloc.h" #include "../common/mmo.h" +#include "../common/malloc.h" +#include "../common/strlib.h" #include "../common/showmsg.h" #include "../common/socket.h" -#include "../common/sql.h" -#include "../common/strlib.h" #include "../common/utils.h" +#include "../common/sql.h" +#include "char.h" +#include "inter.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> bool mapif_elemental_save(struct s_elemental* ele) { bool flag = true; diff --git a/src/char/int_elemental.h b/src/char/int_elemental.h index c869e6fc2..c90891fc4 100644 --- a/src/char/int_elemental.h +++ b/src/char/int_elemental.h @@ -4,7 +4,7 @@ #ifndef _CHAR_INT_ELEMENTAL_H_ #define _CHAR_INT_ELEMENTAL_H_ -#include "../common/cbasetypes.h" +struct s_elemental; void inter_elemental_sql_init(void); void inter_elemental_sql_final(void); diff --git a/src/char/int_guild.c b/src/char/int_guild.c index ffbe48e10..895cbbb94 100644 --- a/src/char/int_guild.c +++ b/src/char/int_guild.c @@ -2,25 +2,21 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "../config/core.h" // DBPATH -#include "int_guild.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "char.h" -#include "inter.h" #include "../common/cbasetypes.h" -#include "../common/db.h" -#include "../common/malloc.h" #include "../common/mmo.h" -#include "../common/showmsg.h" +#include "../common/malloc.h" #include "../common/socket.h" +#include "../common/db.h" +#include "../common/showmsg.h" #include "../common/strlib.h" #include "../common/timer.h" +#include "char.h" +#include "inter.h" +#include "int_guild.h" + +#include <string.h> +#include <stdio.h> +#include <stdlib.h> #define GS_MEMBER_UNMODIFIED 0x00 #define GS_MEMBER_MODIFIED 0x01 diff --git a/src/char/int_guild.h b/src/char/int_guild.h index 5e657ff06..4eb7d310b 100644 --- a/src/char/int_guild.h +++ b/src/char/int_guild.h @@ -20,6 +20,9 @@ enum { GS_REMOVE = 0x8000, }; +struct guild; +struct guild_castle; + int inter_guild_parse_frommap(int fd); int inter_guild_sql_init(void); void inter_guild_sql_final(void); diff --git a/src/char/int_homun.c b/src/char/int_homun.c index 795a6b927..143277f05 100644 --- a/src/char/int_homun.c +++ b/src/char/int_homun.c @@ -2,23 +2,20 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "int_homun.h" +#include "../common/mmo.h" +#include "../common/malloc.h" +#include "../common/strlib.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/utils.h" +#include "../common/sql.h" +#include "char.h" +#include "inter.h" #include <stdio.h> #include <stdlib.h> #include <string.h> -#include "char.h" -#include "inter.h" -#include "../common/malloc.h" -#include "../common/mmo.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/sql.h" -#include "../common/strlib.h" -#include "../common/utils.h" int inter_homunculus_sql_init(void) { diff --git a/src/char/int_homun.h b/src/char/int_homun.h index 9477f4f03..561dc848f 100644 --- a/src/char/int_homun.h +++ b/src/char/int_homun.h @@ -4,8 +4,6 @@ #ifndef _CHAR_INT_HOMUN_H_ #define _CHAR_INT_HOMUN_H_ -#include "../common/cbasetypes.h" - struct s_homunculus; int inter_homunculus_sql_init(void); diff --git a/src/char/int_mail.c b/src/char/int_mail.c index 86a36d59f..826771676 100644 --- a/src/char/int_mail.c +++ b/src/char/int_mail.c @@ -2,23 +2,19 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "int_mail.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "char.h" -#include "inter.h" -#include "../common/malloc.h" #include "../common/mmo.h" +#include "../common/malloc.h" #include "../common/showmsg.h" #include "../common/socket.h" -#include "../common/sql.h" #include "../common/strlib.h" +#include "../common/sql.h" #include "../common/timer.h" +#include "char.h" +#include "inter.h" + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> static int mail_fromsql(int char_id, struct mail_data* md) { diff --git a/src/char/int_mail.h b/src/char/int_mail.h index 824ba48a3..7c06cdc1f 100644 --- a/src/char/int_mail.h +++ b/src/char/int_mail.h @@ -4,9 +4,6 @@ #ifndef _CHAR_INT_MAIL_H_ #define _CHAR_INT_MAIL_H_ -struct item; -struct mail_message; - int inter_mail_parse_frommap(int fd); void mail_sendmail(int send_id, const char* send_name, int dest_id, const char* dest_name, const char* title, const char* body, int zeny, struct item *item); diff --git a/src/char/int_mercenary.c b/src/char/int_mercenary.c index 1dffb656c..aecb3844a 100644 --- a/src/char/int_mercenary.c +++ b/src/char/int_mercenary.c @@ -2,23 +2,19 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "int_mercenary.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "char.h" -#include "inter.h" -#include "../common/malloc.h" #include "../common/mmo.h" +#include "../common/malloc.h" +#include "../common/strlib.h" #include "../common/showmsg.h" #include "../common/socket.h" -#include "../common/sql.h" -#include "../common/strlib.h" #include "../common/utils.h" +#include "../common/sql.h" +#include "char.h" +#include "inter.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> bool mercenary_owner_fromsql(int char_id, struct mmo_charstatus *status) { diff --git a/src/char/int_mercenary.h b/src/char/int_mercenary.h index 195a83b34..b614b8cf7 100644 --- a/src/char/int_mercenary.h +++ b/src/char/int_mercenary.h @@ -4,9 +4,7 @@ #ifndef _CHAR_INT_MERCENARY_H_ #define _CHAR_INT_MERCENARY_H_ -#include "../common/cbasetypes.h" - -struct mmo_charstatus; +struct s_mercenary; int inter_mercenary_sql_init(void); void inter_mercenary_sql_final(void); diff --git a/src/char/int_party.c b/src/char/int_party.c index 3e4a743d6..7c328c452 100644 --- a/src/char/int_party.c +++ b/src/char/int_party.c @@ -2,25 +2,22 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "int_party.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "char.h" -#include "inter.h" #include "../common/cbasetypes.h" +#include "../common/mmo.h" #include "../common/db.h" #include "../common/malloc.h" -#include "../common/mapindex.h" -#include "../common/mmo.h" -#include "../common/showmsg.h" +#include "../common/strlib.h" #include "../common/socket.h" +#include "../common/showmsg.h" +#include "../common/mapindex.h" #include "../common/sql.h" -#include "../common/strlib.h" +#include "char.h" +#include "inter.h" +#include "int_party.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> struct party_data { struct party party; diff --git a/src/char/int_party.h b/src/char/int_party.h index 098c1e9a9..84f00635a 100644 --- a/src/char/int_party.h +++ b/src/char/int_party.h @@ -14,6 +14,8 @@ enum { PS_BREAK = 0x20, //Specify that this party must be deleted. }; +struct party; + int inter_party_parse_frommap(int fd); int inter_party_sql_init(void); void inter_party_sql_final(void); diff --git a/src/char/int_pet.c b/src/char/int_pet.c index 29c40eff9..25f00e6f0 100644 --- a/src/char/int_pet.c +++ b/src/char/int_pet.c @@ -2,23 +2,19 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "int_pet.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "char.h" -#include "inter.h" -#include "../common/malloc.h" #include "../common/mmo.h" -#include "../common/showmsg.h" +#include "../common/malloc.h" #include "../common/socket.h" -#include "../common/sql.h" #include "../common/strlib.h" +#include "../common/showmsg.h" #include "../common/utils.h" +#include "../common/sql.h" +#include "char.h" +#include "inter.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> struct s_pet *pet_pt; diff --git a/src/char/int_quest.c b/src/char/int_quest.c index 61b43c57d..061dd89d9 100644 --- a/src/char/int_quest.c +++ b/src/char/int_quest.c @@ -2,25 +2,23 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "int_quest.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "char.h" -#include "inter.h" +#include "../common/mmo.h" #include "../common/db.h" #include "../common/malloc.h" -#include "../common/mmo.h" #include "../common/showmsg.h" #include "../common/socket.h" -#include "../common/sql.h" #include "../common/strlib.h" +#include "../common/sql.h" #include "../common/timer.h" +#include "char.h" +#include "inter.h" +#include "int_quest.h" + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> + /** * Loads the entire questlog for a character. * diff --git a/src/char/int_storage.c b/src/char/int_storage.c index bf7b76da0..966e61bb3 100644 --- a/src/char/int_storage.c +++ b/src/char/int_storage.c @@ -2,23 +2,19 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "../config/core.h" // GP_BOUND_ITEMS -#include "int_storage.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "char.h" -#include "inter.h" -#include "../common/malloc.h" #include "../common/mmo.h" +#include "../common/malloc.h" #include "../common/showmsg.h" #include "../common/socket.h" -#include "../common/sql.h" #include "../common/strlib.h" // StringBuf +#include "../common/sql.h" +#include "char.h" +#include "inter.h" + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> + #define STORAGE_MEMINC 16 diff --git a/src/char/inter.c b/src/char/inter.c index 972407ef3..515ca0ec4 100644 --- a/src/char/inter.c +++ b/src/char/inter.c @@ -2,34 +2,33 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - +#include "../common/mmo.h" +#include "../common/db.h" +#include "../common/malloc.h" +#include "../common/strlib.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/timer.h" +#include "char.h" #include "inter.h" +#include "int_party.h" +#include "int_guild.h" +#include "int_storage.h" +#include "int_pet.h" +#include "int_homun.h" +#include "int_mercenary.h" +#include "int_mail.h" +#include "int_auction.h" +#include "int_quest.h" +#include "int_elemental.h" -#include <errno.h> #include <stdio.h> -#include <stdlib.h> #include <string.h> +#include <stdlib.h> +#include <errno.h> + #include <sys/stat.h> // for stat/lstat/fstat - [Dekamaster/Ultimate GM Tool] -#include "char.h" -#include "int_auction.h" -#include "int_elemental.h" -#include "int_guild.h" -#include "int_homun.h" -#include "int_mail.h" -#include "int_mercenary.h" -#include "int_party.h" -#include "int_pet.h" -#include "int_quest.h" -#include "int_storage.h" -#include "../common/db.h" -#include "../common/malloc.h" -#include "../common/mmo.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/strlib.h" -#include "../common/timer.h" #define WISDATA_TTL (60*1000) //Wis data Time To Live (60 seconds) #define WISDELLIST_MAX 256 // Number of elements in the list Delete data Wis diff --git a/src/char/inter.h b/src/char/inter.h index 5e655237e..25b0c2a96 100644 --- a/src/char/inter.h +++ b/src/char/inter.h @@ -5,10 +5,9 @@ #ifndef _CHAR_INTER_H_ #define _CHAR_INTER_H_ -#include "char.h" -#include "../common/sql.h" - struct accreg; +#include "../common/sql.h" +#include "char.h" int inter_init_sql(const char *file); void inter_final(void); diff --git a/src/char/pincode.c b/src/char/pincode.c index 59182f12d..d51953448 100644 --- a/src/char/pincode.c +++ b/src/char/pincode.c @@ -2,19 +2,16 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "pincode.h" - -#include <stdlib.h> - -#include "char.h" #include "../common/cbasetypes.h" #include "../common/mmo.h" #include "../common/random.h" #include "../common/showmsg.h" #include "../common/socket.h" #include "../common/strlib.h" +#include "char.h" +#include "pincode.h" + +#include <stdlib.h> int enabled = PINCODE_OK; int changetime = 0; diff --git a/src/common/HPM.c b/src/common/HPM.c index 00b92dc60..9ffce87de 100644 --- a/src/common/HPM.c +++ b/src/common/HPM.c @@ -1,31 +1,26 @@ // Copyright (c) Hercules Dev Team, licensed under GNU GPL. // See the LICENSE file -#define HERCULES_CORE - -#include "../config/core.h" // CONSOLE_INPUT -#include "HPM.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - #include "../common/cbasetypes.h" -#include "../common/conf.h" -#include "../common/console.h" +#include "../common/mmo.h" #include "../common/core.h" #include "../common/malloc.h" -#include "../common/mmo.h" #include "../common/showmsg.h" #include "../common/socket.h" -#include "../common/sql.h" -#include "../common/strlib.h" -#include "../common/sysinfo.h" #include "../common/timer.h" +#include "../common/conf.h" #include "../common/utils.h" +#include "../common/console.h" +#include "../common/strlib.h" +#include "../common/sql.h" +#include "../common/sysinfo.h" +#include "HPM.h" +#include <stdio.h> +#include <stdlib.h> +#include <string.h> #ifndef WIN32 -# include <unistd.h> +#include <unistd.h> #endif struct malloc_interface iMalloc_HPM; @@ -691,7 +686,7 @@ bool hplugins_parse_conf(const char *w1, const char *w2, enum HPluginConfType po void hplugins_share_defaults(void) { /* console */ #ifdef CONSOLE_INPUT - HPM->share(console->input->addCommand,"addCPCommand"); + HPM->share(console->addCommand,"addCPCommand"); #endif /* our own */ HPM->share(hplugins_addpacket,"addPacket"); @@ -760,7 +755,7 @@ void hpm_init(void) { HPM->symbol_defaults(); #ifdef CONSOLE_INPUT - console->input->addCommand("plugins",CPCMD_A(plugins)); + console->addCommand("plugins",CPCMD_A(plugins)); #endif return; } diff --git a/src/common/HPM.h b/src/common/HPM.h index 9c176cfd6..0f0df4cda 100644 --- a/src/common/HPM.h +++ b/src/common/HPM.h @@ -4,12 +4,8 @@ #ifndef _COMMON_HPM_H_ #define _COMMON_HPM_H_ -#ifndef HERCULES_CORE -#error You should never include HPM.h from a plugin. -#endif - -#include "../common/HPMi.h" #include "../common/cbasetypes.h" +#include "../common/HPMi.h" #ifdef WIN32 #ifndef WIN32_LEAN_AND_MEAN diff --git a/src/common/HPMi.h b/src/common/HPMi.h index b98e87d90..19206aeca 100644 --- a/src/common/HPMi.h +++ b/src/common/HPMi.h @@ -5,8 +5,8 @@ #define _COMMON_HPMI_H_ #include "../common/cbasetypes.h" -#include "../common/console.h" #include "../common/core.h" +#include "../common/console.h" #include "../common/sql.h" struct script_state; @@ -20,6 +20,18 @@ struct map_session_data; #define HPExport #endif +#ifndef _COMMON_SHOWMSG_H_ + HPExport void (*ShowMessage) (const char *, ...); + HPExport void (*ShowStatus) (const char *, ...); + HPExport void (*ShowSQL) (const char *, ...); + HPExport void (*ShowInfo) (const char *, ...); + HPExport void (*ShowNotice) (const char *, ...); + HPExport void (*ShowWarning) (const char *, ...); + HPExport void (*ShowDebug) (const char *, ...); + HPExport void (*ShowError) (const char *, ...); + HPExport void (*ShowFatalError) (const char *, ...); +#endif + /* after */ #include "../common/showmsg.h" @@ -180,7 +192,7 @@ HPExport struct HPMi_interface { /* pc group permission */ void (*addPCGPermission) (unsigned int pluginID, char *name, unsigned int *mask); } HPMi_s; -#ifndef HERCULES_CORE +#ifndef _COMMON_HPM_H_ HPExport struct HPMi_interface *HPMi; #endif diff --git a/src/common/cbasetypes.h b/src/common/cbasetypes.h index da0d6b307..f44e80413 100644 --- a/src/common/cbasetypes.h +++ b/src/common/cbasetypes.h @@ -442,11 +442,5 @@ void SET_FUNCPOINTER(T1& var, T2 p) #define SET_FUNCPOINTER(var,p) ((var) = (p)) #endif -/* pointer size fix which fixes several gcc warnings */ -#ifdef __64BIT__ - #define __64BPTRSIZE(y) ((intptr)(y)) -#else - #define __64BPTRSIZE(y) (y) -#endif #endif /* _COMMON_CBASETYPES_H_ */ diff --git a/src/common/conf.c b/src/common/conf.c index 46a034497..b816b2f7f 100644 --- a/src/common/conf.c +++ b/src/common/conf.c @@ -2,10 +2,7 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - #include "conf.h" - #include "../../3rdparty/libconfig/libconfig.h" #include "../common/showmsg.h" // ShowError diff --git a/src/common/conf.h b/src/common/conf.h index e5b637e47..9aff3df47 100644 --- a/src/common/conf.h +++ b/src/common/conf.h @@ -6,7 +6,6 @@ #define _COMMON_CONF_H_ #include "../common/cbasetypes.h" - #include "../../3rdparty/libconfig/libconfig.h" /** diff --git a/src/common/console.c b/src/common/console.c index 6a82db555..d8f352c8a 100644 --- a/src/common/console.c +++ b/src/common/console.c @@ -2,46 +2,42 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "../config/core.h" // CONSOLE_INPUT, MAX_CONSOLE_INPUT -#include "console.h" - -#include <stdio.h> -#include <stdlib.h> - #include "../common/cbasetypes.h" -#include "../common/core.h" #include "../common/showmsg.h" +#include "../common/core.h" #include "../common/sysinfo.h" +#include "../config/core.h" +#include "console.h" #ifndef MINICORE -# include "../common/atomic.h" -# include "../common/ers.h" -# include "../common/malloc.h" -# include "../common/mutex.h" -# include "../common/spinlock.h" -# include "../common/sql.h" -# include "../common/strlib.h" -# include "../common/thread.h" -# include "../common/timer.h" + #include "../common/ers.h" + #include "../common/malloc.h" + #include "../common/atomic.h" + #include "../common/spinlock.h" + #include "../common/thread.h" + #include "../common/mutex.h" + #include "../common/timer.h" + #include "../common/strlib.h" + #include "../common/sql.h" #endif +#include <stdio.h> +#include <stdlib.h> #if !defined(WIN32) -# include <sys/time.h> -# include <unistd.h> + #include <unistd.h> + #include <sys/time.h> #else -# include "../common/winapi.h" // Console close event handling -# ifdef CONSOLE_INPUT -# include <conio.h> /* _kbhit() */ -# endif + #include "../common/winapi.h" // Console close event handling #endif -struct console_interface console_s; #ifdef CONSOLE_INPUT -struct console_input_interface console_input_s; + #if defined(WIN32) + #include <conio.h> /* _kbhit() */ + #endif #endif +struct console_interface console_s; + /*====================================== * CORE : Display title *--------------------------------------*/ @@ -120,12 +116,12 @@ CPCMD_C(mem_report,server) { **/ CPCMD(help) { unsigned int i = 0; - for ( i = 0; i < console->input->cmd_list_count; i++ ) { - if( console->input->cmd_list[i]->next_count ) { - ShowInfo("- '"CL_WHITE"%s"CL_RESET"' subs\n",console->input->cmd_list[i]->cmd); - console->input->parse_list_subs(console->input->cmd_list[i],2); + for ( i = 0; i < console->cmd_list_count; i++ ) { + if( console->cmd_list[i]->next_count ) { + ShowInfo("- '"CL_WHITE"%s"CL_RESET"' subs\n",console->cmd_list[i]->cmd); + console->parse_list_subs(console->cmd_list[i],2); } else { - ShowInfo("- '"CL_WHITE"%s"CL_RESET"'\n",console->input->cmd_list[i]->cmd); + ShowInfo("- '"CL_WHITE"%s"CL_RESET"'\n",console->cmd_list[i]->cmd); } } } @@ -148,7 +144,7 @@ CPCMD_C(skip,update) { ShowDebug("usage example: sql update skip 2013-02-14--16-15.sql\n"); return; } - Sql_HerculesUpdateSkip(console->input->SQL, line); + Sql_HerculesUpdateSkip(console->SQL, line); } /** @@ -210,7 +206,7 @@ void console_load_defaults(void) { unsigned int i, len = ARRAYLENGTH(default_list); struct CParseEntry *cmd; - RECREATE(console->input->cmds,struct CParseEntry *, len); + RECREATE(console->cmds,struct CParseEntry *, len); for(i = 0; i < len; i++) { CREATE(cmd, struct CParseEntry, 1); @@ -224,12 +220,12 @@ void console_load_defaults(void) { cmd->next_count = 0; - console->input->cmd_count++; - console->input->cmds[i] = cmd; + console->cmd_count++; + console->cmds[i] = cmd; default_list[i].self = cmd; if( !default_list[i].connect ) { - RECREATE(console->input->cmd_list,struct CParseEntry *, ++console->input->cmd_list_count); - console->input->cmd_list[console->input->cmd_list_count - 1] = cmd; + RECREATE(console->cmd_list,struct CParseEntry *, ++console->cmd_list_count); + console->cmd_list[console->cmd_list_count - 1] = cmd; } } @@ -237,11 +233,11 @@ void console_load_defaults(void) { unsigned int k; if( !default_list[i].connect ) continue; - for(k = 0; k < console->input->cmd_count; k++) { - if( strcmpi(default_list[i].connect,console->input->cmds[k]->cmd) == 0 ) { + for(k = 0; k < console->cmd_count; k++) { + if( strcmpi(default_list[i].connect,console->cmds[k]->cmd) == 0 ) { cmd = default_list[i].self; - RECREATE(console->input->cmds[k]->u.next, struct CParseEntry *, ++console->input->cmds[k]->next_count); - console->input->cmds[k]->u.next[console->input->cmds[k]->next_count - 1] = cmd; + RECREATE(console->cmds[k]->u.next, struct CParseEntry *, ++console->cmds[k]->next_count); + console->cmds[k]->u.next[console->cmds[k]->next_count - 1] = cmd; break; } } @@ -260,23 +256,23 @@ void console_parse_create(char *name, CParseFunc func) { safestrncpy(sublist, name, CP_CMD_LENGTH * 5); tok = strtok(sublist,":"); - for ( i = 0; i < console->input->cmd_list_count; i++ ) { - if( strcmpi(tok,console->input->cmd_list[i]->cmd) == 0 ) + for ( i = 0; i < console->cmd_list_count; i++ ) { + if( strcmpi(tok,console->cmd_list[i]->cmd) == 0 ) break; } - if( i == console->input->cmd_list_count ) { - RECREATE(console->input->cmds,struct CParseEntry *, ++console->input->cmd_count); + if( i == console->cmd_list_count ) { + RECREATE(console->cmds,struct CParseEntry *, ++console->cmd_count); CREATE(cmd, struct CParseEntry, 1); safestrncpy(cmd->cmd, tok, CP_CMD_LENGTH); cmd->next_count = 0; - console->input->cmds[console->input->cmd_count - 1] = cmd; - RECREATE(console->input->cmd_list,struct CParseEntry *, ++console->input->cmd_list_count); - console->input->cmd_list[console->input->cmd_list_count - 1] = cmd; - i = console->input->cmd_list_count - 1; + console->cmds[console->cmd_count - 1] = cmd; + RECREATE(console->cmd_list,struct CParseEntry *, ++console->cmd_list_count); + console->cmd_list[console->cmd_list_count - 1] = cmd; + i = console->cmd_list_count - 1; } - cmd = console->input->cmd_list[i]; + cmd = console->cmd_list[i]; while( ( tok = strtok(NULL, ":") ) != NULL ) { for(i = 0; i < cmd->next_count; i++) { @@ -285,13 +281,13 @@ void console_parse_create(char *name, CParseFunc func) { } if ( i == cmd->next_count ) { - RECREATE(console->input->cmds,struct CParseEntry *, ++console->input->cmd_count); - CREATE(console->input->cmds[console->input->cmd_count-1], struct CParseEntry, 1); - safestrncpy(console->input->cmds[console->input->cmd_count-1]->cmd, tok, CP_CMD_LENGTH); - console->input->cmds[console->input->cmd_count-1]->next_count = 0; + RECREATE(console->cmds,struct CParseEntry *, ++console->cmd_count); + CREATE(console->cmds[console->cmd_count-1], struct CParseEntry, 1); + safestrncpy(console->cmds[console->cmd_count-1]->cmd, tok, CP_CMD_LENGTH); + console->cmds[console->cmd_count-1]->next_count = 0; RECREATE(cmd->u.next, struct CParseEntry *, ++cmd->next_count); - cmd->u.next[cmd->next_count - 1] = console->input->cmds[console->input->cmd_count-1]; - cmd = console->input->cmds[console->input->cmd_count-1]; + cmd->u.next[cmd->next_count - 1] = console->cmds[console->cmd_count-1]; + cmd = console->cmds[console->cmd_count-1]; continue; } @@ -306,7 +302,7 @@ void console_parse_list_subs(struct CParseEntry *cmd, unsigned char depth) { memset(msg, '-', depth); snprintf(msg + depth,CP_CMD_LENGTH * 2, " '"CL_WHITE"%s"CL_RESET"'",cmd->u.next[i]->cmd); ShowInfo("%s subs\n",msg); - console->input->parse_list_subs(cmd->u.next[i],depth + 1); + console->parse_list_subs(cmd->u.next[i],depth + 1); } else { memset(msg, '-', depth); snprintf(msg + depth,CP_CMD_LENGTH * 2, " %s",cmd->u.next[i]->cmd); @@ -324,21 +320,21 @@ void console_parse_sub(char *line) { memcpy(bline, line, 200); tok = strtok(line, " "); - for ( i = 0; i < console->input->cmd_list_count; i++ ) { - if( strcmpi(tok,console->input->cmd_list[i]->cmd) == 0 ) + for ( i = 0; i < console->cmd_list_count; i++ ) { + if( strcmpi(tok,console->cmd_list[i]->cmd) == 0 ) break; } - if( i == console->input->cmd_list_count ) { + if( i == console->cmd_list_count ) { ShowError("'"CL_WHITE"%s"CL_RESET"' is not a known command, type '"CL_WHITE"help"CL_RESET"' to list all commands\n",line); return; } - cmd = console->input->cmd_list[i]; + cmd = console->cmd_list[i]; len += snprintf(sublist,CP_CMD_LENGTH * 5,"%s", cmd->cmd) + 1; - if( cmd->next_count == 0 && console->input->cmd_list[i]->u.func ) { + if( cmd->next_count == 0 && console->cmd_list[i]->u.func ) { char *r = NULL; if( (tok = strtok(NULL, " ")) ) { r = bline; @@ -355,7 +351,7 @@ void console_parse_sub(char *line) { if( strcmpi("help",tok) == 0 ) { if( cmd->next_count ) { ShowInfo("- '"CL_WHITE"%s"CL_RESET"' subs\n",sublist); - console->input->parse_list_subs(cmd,2); + console->parse_list_subs(cmd,2); } else { ShowError("'"CL_WHITE"%s"CL_RESET"' doesn't possess any subcommands\n",sublist); } @@ -396,95 +392,95 @@ void console_parse(char* line) { } void *cThread_main(void *x) { - while( console->input->ptstate ) {/* loopx */ - if( console->input->key_pressed() ) { + while( console->ptstate ) {/* loopx */ + if( console->key_pressed() ) { char input[MAX_CONSOLE_INPUT]; - console->input->parse(input); + console->parse(input); if( input[0] != '\0' ) {/* did we get something? */ - EnterSpinLock(&console->input->ptlock); + EnterSpinLock(&console->ptlock); if( cinput.count == CONSOLE_PARSE_SIZE ) { - LeaveSpinLock(&console->input->ptlock); + LeaveSpinLock(&console->ptlock); continue;/* drop */ } safestrncpy(cinput.queue[cinput.count++],input,MAX_CONSOLE_INPUT); - LeaveSpinLock(&console->input->ptlock); + LeaveSpinLock(&console->ptlock); } } - ramutex_lock( console->input->ptmutex ); - racond_wait( console->input->ptcond, console->input->ptmutex, -1 ); - ramutex_unlock( console->input->ptmutex ); + ramutex_lock( console->ptmutex ); + racond_wait( console->ptcond, console->ptmutex, -1 ); + ramutex_unlock( console->ptmutex ); } return NULL; } int console_parse_timer(int tid, int64 tick, int id, intptr_t data) { int i; - EnterSpinLock(&console->input->ptlock); + EnterSpinLock(&console->ptlock); for(i = 0; i < cinput.count; i++) { - console->input->parse_sub(cinput.queue[i]); + console->parse_sub(cinput.queue[i]); } cinput.count = 0; - LeaveSpinLock(&console->input->ptlock); - racond_signal(console->input->ptcond); + LeaveSpinLock(&console->ptlock); + racond_signal(console->ptcond); return 0; } void console_parse_final(void) { - if( console->input->ptstate ) { - InterlockedDecrement(&console->input->ptstate); - racond_signal(console->input->ptcond); + if( console->ptstate ) { + InterlockedDecrement(&console->ptstate); + racond_signal(console->ptcond); /* wait for thread to close */ - rathread_wait(console->input->pthread, NULL); + rathread_wait(console->pthread, NULL); - racond_destroy(console->input->ptcond); - ramutex_destroy(console->input->ptmutex); + racond_destroy(console->ptcond); + ramutex_destroy(console->ptmutex); } } void console_parse_init(void) { cinput.count = 0; - console->input->ptstate = 1; + console->ptstate = 1; - InitializeSpinLock(&console->input->ptlock); + InitializeSpinLock(&console->ptlock); - console->input->ptmutex = ramutex_create(); - console->input->ptcond = racond_create(); + console->ptmutex = ramutex_create(); + console->ptcond = racond_create(); - if( (console->input->pthread = rathread_create(console->input->pthread_main, NULL)) == NULL ){ + if( (console->pthread = rathread_create(console->pthread_main, NULL)) == NULL ){ ShowFatalError("console_parse_init: failed to spawn console_parse thread.\n"); exit(EXIT_FAILURE); } - timer->add_func_list(console->input->parse_timer, "console_parse_timer"); - timer->add_interval(timer->gettick() + 1000, console->input->parse_timer, 0, 0, 500);/* start listening in 1s; re-try every 0.5s */ + timer->add_func_list(console->parse_timer, "console_parse_timer"); + timer->add_interval(timer->gettick() + 1000, console->parse_timer, 0, 0, 500);/* start listening in 1s; re-try every 0.5s */ } void console_setSQL(Sql *SQL_handle) { - console->input->SQL = SQL_handle; + console->SQL = SQL_handle; } #endif /* CONSOLE_INPUT */ void console_init (void) { #ifdef CONSOLE_INPUT - console->input->cmd_count = console->input->cmd_list_count = 0; - console->input->load_defaults(); - console->input->parse_init(); + console->cmd_count = console->cmd_list_count = 0; + console->load_defaults(); + console->parse_init(); #endif } void console_final(void) { #ifdef CONSOLE_INPUT unsigned int i; - console->input->parse_final(); - for( i = 0; i < console->input->cmd_count; i++ ) { - if( console->input->cmds[i]->next_count ) - aFree(console->input->cmds[i]->u.next); - aFree(console->input->cmds[i]); + console->parse_final(); + for( i = 0; i < console->cmd_count; i++ ) { + if( console->cmds[i]->next_count ) + aFree(console->cmds[i]->u.next); + aFree(console->cmds[i]); } - aFree(console->input->cmds); - aFree(console->input->cmd_list); + aFree(console->cmds); + aFree(console->cmd_list); #endif } void console_defaults(void) { @@ -493,20 +489,17 @@ void console_defaults(void) { console->final = console_final; console->display_title = display_title; #ifdef CONSOLE_INPUT - console->input = &console_input_s; - console->input->parse_init = console_parse_init; - console->input->parse_final = console_parse_final; - console->input->parse_timer = console_parse_timer; - console->input->pthread_main = cThread_main; - console->input->parse = console_parse; - console->input->parse_sub = console_parse_sub; - console->input->key_pressed = console_parse_key_pressed; - console->input->load_defaults = console_load_defaults; - console->input->parse_list_subs = console_parse_list_subs; - console->input->addCommand = console_parse_create; - console->input->setSQL = console_setSQL; - console->input->SQL = NULL; -#else - console->input = NULL; + console->parse_init = console_parse_init; + console->parse_final = console_parse_final; + console->parse_timer = console_parse_timer; + console->pthread_main = cThread_main; + console->parse = console_parse; + console->parse_sub = console_parse_sub; + console->key_pressed = console_parse_key_pressed; + console->load_defaults = console_load_defaults; + console->parse_list_subs = console_parse_list_subs; + console->addCommand = console_parse_create; + console->setSQL = console_setSQL; + console->SQL = NULL; #endif } diff --git a/src/common/console.h b/src/common/console.h index d2c58f978..3d19ddc9d 100644 --- a/src/common/console.h +++ b/src/common/console.h @@ -4,13 +4,11 @@ #ifndef _COMMON_CONSOLE_H_ #define _COMMON_CONSOLE_H_ -#include "../config/core.h" // MAX_CONSOLE_INPUT - -#include "../common/cbasetypes.h" +#include "../common/thread.h" #include "../common/mutex.h" #include "../common/spinlock.h" #include "../common/sql.h" -#include "../common/thread.h" +#include "../config/core.h" /** * Queue Max @@ -49,8 +47,11 @@ struct { unsigned short count; } cinput; +struct console_interface { + void (*init) (void); + void (*final) (void); + void (*display_title) (void); #ifdef CONSOLE_INPUT -struct console_input_interface { /* vars */ SPIN_LOCK ptlock;/* parse thread lock */ rAthread pthread;/* parse thread */ @@ -76,17 +77,7 @@ struct console_input_interface { void (*parse_list_subs) (struct CParseEntry *cmd, unsigned char depth); void (*addCommand) (char *name, CParseFunc func); void (*setSQL) (Sql *SQL_handle); -}; -#else -struct console_input_interface; #endif - -struct console_interface { - void (*init) (void); - void (*final) (void); - void (*display_title) (void); - - struct console_input_interface *input; }; struct console_interface *console; diff --git a/src/common/core.c b/src/common/core.c index 85f824866..49b272488 100644 --- a/src/common/core.c +++ b/src/common/core.c @@ -2,40 +2,36 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "../config/core.h" -#include "core.h" - -#include "../common/cbasetypes.h" -#include "../common/console.h" -#include "../common/malloc.h" #include "../common/mmo.h" -#include "../common/random.h" #include "../common/showmsg.h" +#include "../common/malloc.h" #include "../common/strlib.h" +#include "core.h" +#include "../common/console.h" +#include "../common/random.h" #include "../common/sysinfo.h" #ifndef MINICORE -# include "../common/HPM.h" -# include "../common/conf.h" -# include "../common/db.h" -# include "../common/ers.h" -# include "../common/socket.h" -# include "../common/sql.h" -# include "../common/thread.h" -# include "../common/timer.h" -# include "../common/utils.h" + #include "../common/db.h" + #include "../common/socket.h" + #include "../common/timer.h" + #include "../common/thread.h" + #include "../common/sql.h" + #include "../config/core.h" + #include "../common/HPM.h" + #include "../common/utils.h" + #include "../common/conf.h" + #include "../common/ers.h" #endif -#include <signal.h> #include <stdio.h> #include <stdlib.h> +#include <signal.h> #include <string.h> #ifndef _WIN32 -# include <unistd.h> +#include <unistd.h> #else -# include "../common/winapi.h" // Console close event handling +#include "../common/winapi.h" // Console close event handling #endif /// Called when a terminate signal is received. diff --git a/src/common/core.h b/src/common/core.h index ba75e6b01..e9f7c5961 100644 --- a/src/common/core.h +++ b/src/common/core.h @@ -7,10 +7,11 @@ #include "../common/db.h" #include "../common/mmo.h" +#include "../config/core.h" /* so that developers with --enable-debug can raise signals from any section of the code they'd like */ #ifdef DEBUG -# include <signal.h> + #include <signal.h> #endif extern int arg_c; diff --git a/src/common/db.c b/src/common/db.c index 1781aa96f..8d6b08815 100644 --- a/src/common/db.c +++ b/src/common/db.c @@ -67,18 +67,14 @@ * @encoding US-ASCII * @see #db.h \*****************************************************************************/ - -#define HERCULES_CORE - -#include "db.h" - #include <stdio.h> #include <stdlib.h> -#include "../common/ers.h" -#include "../common/malloc.h" +#include "db.h" #include "../common/mmo.h" +#include "../common/malloc.h" #include "../common/showmsg.h" +#include "../common/ers.h" #include "../common/strlib.h" /*****************************************************************************\ diff --git a/src/common/db.h b/src/common/db.h index 0d2548806..67abe6f19 100644 --- a/src/common/db.h +++ b/src/common/db.h @@ -42,9 +42,8 @@ #ifndef _COMMON_DB_H_ #define _COMMON_DB_H_ -#include <stdarg.h> - #include "../common/cbasetypes.h" +#include <stdarg.h> /*****************************************************************************\ * (1) Section with public typedefs, enums, unions, structures and defines. * diff --git a/src/common/des.c b/src/common/des.c index 7f952be76..ed6d098dc 100644 --- a/src/common/des.c +++ b/src/common/des.c @@ -1,11 +1,8 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder - -#define HERCULES_CORE - -#include "des.h" - #include "../common/cbasetypes.h" +#include "../common/des.h" + /// DES (Data Encryption Standard) algorithm, modified version. /// @see http://www.eathena.ws/board/index.php?autocom=bugtracker&showbug=5099. diff --git a/src/common/ers.c b/src/common/ers.c index d9895e4f2..5a3d7314a 100644 --- a/src/common/ers.c +++ b/src/common/ers.c @@ -39,18 +39,14 @@ * @encoding US-ASCII * * @see common#ers.h * \*****************************************************************************/ - -#define HERCULES_CORE - -#include "ers.h" - #include <stdlib.h> #include <string.h> #include "../common/cbasetypes.h" #include "../common/malloc.h" // CREATE, RECREATE, aMalloc, aFree -#include "../common/nullpo.h" #include "../common/showmsg.h" // ShowMessage, ShowError, ShowFatalError, CL_BOLD, CL_NORMAL +#include "../common/nullpo.h" +#include "ers.h" #ifndef DISABLE_ERS diff --git a/src/common/grfio.c b/src/common/grfio.c index 1111fb3f3..bde0ed720 100644 --- a/src/common/grfio.c +++ b/src/common/grfio.c @@ -2,8 +2,13 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - +#include "../common/cbasetypes.h" +#include "../common/des.h" +#include "../common/malloc.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" +#include "../common/utils.h" +#include "../common/nullpo.h" #include "grfio.h" #include <stdio.h> @@ -12,14 +17,6 @@ #include <sys/stat.h> #include <zlib.h> -#include "../common/cbasetypes.h" -#include "../common/des.h" -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/utils.h" - //---------------------------- // file entry table struct //---------------------------- diff --git a/src/common/malloc.c b/src/common/malloc.c index 13cf0b5ce..5b39cbab6 100644 --- a/src/common/malloc.c +++ b/src/common/malloc.c @@ -2,19 +2,16 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "malloc.h" +#include "../common/malloc.h" +#include "../common/core.h" +#include "../common/showmsg.h" +#include "../common/sysinfo.h" #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> -#include "../common/core.h" -#include "../common/showmsg.h" -#include "../common/sysinfo.h" - struct malloc_interface iMalloc_s; ////////////// Memory Libraries ////////////////// diff --git a/src/common/mapindex.c b/src/common/mapindex.c index 5c69c7063..3128a3cb0 100644 --- a/src/common/mapindex.c +++ b/src/common/mapindex.c @@ -2,19 +2,16 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - +#include "../common/mmo.h" +#include "../common/showmsg.h" +#include "../common/malloc.h" +#include "../common/strlib.h" +#include "../common/db.h" #include "mapindex.h" +#include <string.h> #include <stdio.h> #include <stdlib.h> -#include <string.h> - -#include "../common/db.h" -#include "../common/malloc.h" -#include "../common/mmo.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" /* mapindex.c interface source */ struct mapindex_interface mapindex_s; diff --git a/src/common/md5calc.c b/src/common/md5calc.c index e7b506e27..05fde42cc 100644 --- a/src/common/md5calc.c +++ b/src/common/md5calc.c @@ -6,15 +6,11 @@ * ***********************************************************/ -#define HERCULES_CORE - +#include "../common/random.h" #include "md5calc.h" - +#include <string.h> #include <stdio.h> #include <stdlib.h> -#include <string.h> - -#include "../common/random.h" #ifndef UINT_MAX #define UINT_MAX 4294967295U diff --git a/src/common/mmo.h b/src/common/mmo.h index 1d826463e..d535d2874 100644 --- a/src/common/mmo.h +++ b/src/common/mmo.h @@ -5,10 +5,9 @@ #ifndef _COMMON_MMO_H_ #define _COMMON_MMO_H_ -#include <time.h> - -#include "../common/cbasetypes.h" +#include "cbasetypes.h" #include "../common/db.h" +#include <time.h> // server->client protocol version // 0 - pre-? @@ -97,7 +96,6 @@ //Official Limit: 2.1b ( the var that stores the money doesn't go much higher than this by default ) #define MAX_BANK_ZENY 2100000000 -#define MAX_LEVEL 175 #define MAX_FAME 1000000000 #define MAX_CART 100 #define MAX_SKILL 1478 diff --git a/src/common/mutex.c b/src/common/mutex.c index 12524c3b7..0668dbc41 100644 --- a/src/common/mutex.c +++ b/src/common/mutex.c @@ -1,10 +1,6 @@ // Copyright (c) rAthena Project (www.rathena.org) - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#define HERCULES_CORE - -#include "mutex.h" - #ifdef WIN32 #include "../common/winapi.h" #else @@ -17,6 +13,7 @@ #include "../common/malloc.h" #include "../common/showmsg.h" #include "../common/timer.h" +#include "../common/mutex.h" struct ramutex{ #ifdef WIN32 diff --git a/src/common/mutex.h b/src/common/mutex.h index 3b83b66d6..eeb24e6ff 100644 --- a/src/common/mutex.h +++ b/src/common/mutex.h @@ -4,7 +4,6 @@ #ifndef _COMMON_MUTEX_H_ #define _COMMON_MUTEX_H_ -#include "../common/cbasetypes.h" typedef struct ramutex *ramutex; // Mutex typedef struct racond *racond; // Condition Var diff --git a/src/common/nullpo.c b/src/common/nullpo.c index 1891835f1..1cb471aff 100644 --- a/src/common/nullpo.c +++ b/src/common/nullpo.c @@ -2,14 +2,10 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "nullpo.h" - #include <stdio.h> #include <stdarg.h> #include <string.h> - +#include "../common/nullpo.h" #include "../common/showmsg.h" /** diff --git a/src/common/random.c b/src/common/random.c index 7019a31f3..e46c52cad 100644 --- a/src/common/random.c +++ b/src/common/random.c @@ -1,23 +1,17 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#define HERCULES_CORE - -#include "random.h" - -#include <time.h> // time - -#include <mt19937ar.h> // init_genrand, genrand_int32, genrand_res53 - #include "../common/showmsg.h" #include "../common/timer.h" // gettick - +#include "random.h" #if defined(WIN32) -# include "../common/winapi.h" + #include "../common/winapi.h" #elif defined(HAVE_GETPID) || defined(HAVE_GETTID) -# include <sys/types.h> -# include <unistd.h> + #include <sys/types.h> + #include <unistd.h> #endif +#include <time.h> // time +#include <mt19937ar.h> // init_genrand, genrand_int32, genrand_res53 /// Initializes the random number generator with an appropriate seed. diff --git a/src/common/showmsg.c b/src/common/showmsg.c index 1dbcba282..14342fe5e 100644 --- a/src/common/showmsg.c +++ b/src/common/showmsg.c @@ -2,26 +2,23 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - +#include "../common/cbasetypes.h" +#include "../common/strlib.h" // StringBuf #include "showmsg.h" +#include "core.h" //[Ind] - For SERVER_TYPE -#include <stdarg.h> #include <stdio.h> -#include <stdlib.h> // atexit #include <string.h> +#include <stdarg.h> #include <time.h> +#include <stdlib.h> // atexit #include "../../3rdparty/libconfig/libconfig.h" -#include "../common/cbasetypes.h" -#include "../common/core.h" //[Ind] - For SERVER_TYPE -#include "../common/strlib.h" // StringBuf - #ifdef WIN32 -# include "../common/winapi.h" +#include "../common/winapi.h" #else // not WIN32 -# include <unistd.h> +#include <unistd.h> #endif // WIN32 #if defined(DEBUGLOGMAP) diff --git a/src/common/showmsg.h b/src/common/showmsg.h index 5b32f39ae..49fbc34fb 100644 --- a/src/common/showmsg.h +++ b/src/common/showmsg.h @@ -5,14 +5,12 @@ #ifndef _COMMON_SHOWMSG_H_ #define _COMMON_SHOWMSG_H_ -#include <stdarg.h> - -#ifdef HERCULES_CORE -# include "../../3rdparty/libconfig/libconfig.h" -#else -# include "../common/HPMi.h" +#ifndef _COMMON_HPMI_H_ + #include "../../3rdparty/libconfig/libconfig.h" #endif +#include <stdarg.h> + // for help with the console colors look here: // http://www.edoceo.com/liberum/?doc=printf-with-color // some code explanation (used here): @@ -92,7 +90,7 @@ enum msg_type { }; extern void ClearScreen(void); -#ifdef HERCULES_CORE +#ifndef _COMMON_HPMI_H_ extern void ShowMessage(const char *, ...); extern void ShowStatus(const char *, ...); extern void ShowSQL(const char *, ...); @@ -103,18 +101,7 @@ extern void ClearScreen(void); extern void ShowError(const char *, ...); extern void ShowFatalError(const char *, ...); extern void ShowConfigWarning(config_setting_t *config, const char *string, ...); -#else - HPExport void (*ShowMessage) (const char *, ...); - HPExport void (*ShowStatus) (const char *, ...); - HPExport void (*ShowSQL) (const char *, ...); - HPExport void (*ShowInfo) (const char *, ...); - HPExport void (*ShowNotice) (const char *, ...); - HPExport void (*ShowWarning) (const char *, ...); - HPExport void (*ShowDebug) (const char *, ...); - HPExport void (*ShowError) (const char *, ...); - HPExport void (*ShowFatalError) (const char *, ...); #endif - extern int _vShowMessage(enum msg_type flag, const char *string, va_list ap); #endif /* _COMMON_SHOWMSG_H_ */ diff --git a/src/common/socket.c b/src/common/socket.c index 3738f2c2a..35d350e95 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -2,50 +2,48 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE +#include "../common/cbasetypes.h" +#include "../common/mmo.h" +#include "../common/timer.h" +#include "../common/malloc.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" +#include "../config/core.h" +#include "../common/HPM.h" -#include "../config/core.h" // SHOW_SERVER_STATS #define _H_SOCKET_C_ + #include "socket.h" -#undef _H_SOCKET_C_ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/types.h> -#include "../common/HPM.h" -#include "../common/cbasetypes.h" -#include "../common/malloc.h" -#include "../common/mmo.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/timer.h" - #ifdef WIN32 -# include "../common/winapi.h" + #include "../common/winapi.h" #else -# include <arpa/inet.h> -# include <errno.h> -# include <net/if.h> -# include <netdb.h> -# include <netinet/in.h> -# include <netinet/tcp.h> -# include <sys/ioctl.h> -# include <sys/socket.h> -# include <sys/time.h> -# include <unistd.h> - -# ifndef SIOCGIFCONF -# include <sys/sockio.h> // SIOCGIFCONF on Solaris, maybe others? [Shinomori] -# endif -# ifndef FIONBIO -# include <sys/filio.h> // FIONBIO on Solaris [FlavioJS] -# endif - -# ifdef HAVE_SETRLIMIT -# include <sys/resource.h> -# endif + #include <errno.h> + #include <sys/socket.h> + #include <netinet/in.h> + #include <netinet/tcp.h> + #include <net/if.h> + #include <unistd.h> + #include <sys/time.h> + #include <sys/ioctl.h> + #include <netdb.h> + #include <arpa/inet.h> + + #ifndef SIOCGIFCONF + #include <sys/sockio.h> // SIOCGIFCONF on Solaris, maybe others? [Shinomori] + #endif + #ifndef FIONBIO + #include <sys/filio.h> // FIONBIO on Solaris [FlavioJS] + #endif + + #ifdef HAVE_SETRLIMIT + #include <sys/resource.h> + #endif #endif /** diff --git a/src/common/socket.h b/src/common/socket.h index 804b9284f..75adde4cf 100644 --- a/src/common/socket.h +++ b/src/common/socket.h @@ -5,19 +5,19 @@ #ifndef _COMMON_SOCKET_H_ #define _COMMON_SOCKET_H_ -#include <time.h> - #include "../common/cbasetypes.h" #ifdef WIN32 -# include "../common/winapi.h" + #include "../common/winapi.h" typedef long in_addr_t; #else -# include <netinet/in.h> -# include <sys/socket.h> -# include <sys/types.h> + #include <sys/types.h> + #include <sys/socket.h> + #include <netinet/in.h> #endif +#include <time.h> + struct HPluginData; #define FIFOSIZE_SERVERLINK 256*1024 diff --git a/src/common/spinlock.h b/src/common/spinlock.h index 0058e1d83..29fbb355b 100644 --- a/src/common/spinlock.h +++ b/src/common/spinlock.h @@ -1,3 +1,4 @@ +#pragma once #ifndef _COMMON_SPINLOCK_H_ #define _COMMON_SPINLOCK_H_ @@ -14,14 +15,14 @@ // // -#include "../common/atomic.h" -#include "../common/cbasetypes.h" -#include "../common/thread.h" - #ifdef WIN32 #include "../common/winapi.h" #endif +#include "../common/cbasetypes.h" +#include "../common/atomic.h" +#include "../common/thread.h" + #ifdef WIN32 typedef struct __declspec( align(64) ) SPIN_LOCK{ diff --git a/src/common/sql.c b/src/common/sql.c index aeb56bff0..79ccc8e92 100644 --- a/src/common/sql.c +++ b/src/common/sql.c @@ -2,23 +2,19 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "sql.h" - -#include <stdlib.h> // strtoul -#include <string.h> // strlen/strnlen/memcpy/memset - #include "../common/cbasetypes.h" #include "../common/malloc.h" #include "../common/showmsg.h" #include "../common/strlib.h" #include "../common/timer.h" +#include "sql.h" #ifdef WIN32 -# include "../common/winapi.h" // Needed before mysql.h +#include "../common/winapi.h" #endif #include <mysql.h> +#include <string.h>// strlen/strnlen/memcpy/memset +#include <stdlib.h>// strtoul void hercules_mysql_error_handler(unsigned int ecode); diff --git a/src/common/sql.h b/src/common/sql.h index 807e0843c..1fb436853 100644 --- a/src/common/sql.h +++ b/src/common/sql.h @@ -5,9 +5,10 @@ #ifndef _COMMON_SQL_H_ #define _COMMON_SQL_H_ +#include "../common/cbasetypes.h" #include <stdarg.h>// va_list -#include "../common/cbasetypes.h" + // Return codes #define SQL_ERROR (-1) diff --git a/src/common/strlib.c b/src/common/strlib.c index e2e802915..361595b07 100644 --- a/src/common/strlib.c +++ b/src/common/strlib.c @@ -2,19 +2,16 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#define _H_STRLIB_C_ +#include "../common/cbasetypes.h" +#include "../common/malloc.h" +#include "../common/showmsg.h" +#define STRLIB_C #include "strlib.h" -#undef _H_STRLIB_C_ -#include <errno.h> #include <stdio.h> #include <stdlib.h> +#include <errno.h> -#include "../common/cbasetypes.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" #define J_MAX_MALLOC_SIZE 65535 diff --git a/src/common/strlib.h b/src/common/strlib.h index decf661a6..10844d257 100644 --- a/src/common/strlib.h +++ b/src/common/strlib.h @@ -5,16 +5,15 @@ #ifndef _COMMON_STRLIB_H_ #define _COMMON_STRLIB_H_ -#include <stdarg.h> - #include "../common/cbasetypes.h" +#include <stdarg.h> #ifndef __USE_GNU -# define __USE_GNU // required to enable strnlen on some platforms -# include <string.h> -# undef __USE_GNU + #define __USE_GNU // required to enable strnlen on some platforms + #include <string.h> + #undef __USE_GNU #else -# include <string.h> + #include <string.h> #endif #ifdef WIN32 @@ -166,7 +165,7 @@ struct sv_interface *sv; void strlib_defaults(void); /* the purpose of these macros is simply to not make calling them be an annoyance */ -#ifndef _H_STRLIB_C_ +#ifndef STRLIB_C #define jstrescape(pt) (strlib->jstrescape(pt)) #define jstrescapecpy(pt,spt) (strlib->jstrescapecpy((pt),(spt))) #define jmemescapecpy(pt,spt,size) (strlib->jmemescapecpy((pt),(spt),(size))) @@ -190,6 +189,6 @@ void strlib_defaults(void); #define safesnprintf(buf,sz,fmt,...) (strlib->safesnprintf((buf),(sz),(fmt),##__VA_ARGS__)) #define strline(str,pos) (strlib->strline((str),(pos))) #define bin2hex(output,input,count) (strlib->bin2hex((output),(input),(count))) -#endif /* _H_STRLIB_C_ */ +#endif /* STRLIB_C */ #endif /* _COMMON_STRLIB_H_ */ diff --git a/src/common/sysinfo.c b/src/common/sysinfo.c index 3fdfadb41..a56896458 100644 --- a/src/common/sysinfo.c +++ b/src/common/sysinfo.c @@ -4,39 +4,23 @@ /// See sysinfo.h for a description of this file -#define HERCULES_CORE - +#define _COMMON_SYSINFO_P_ #include "sysinfo.h" - -#include <stdio.h> // fopen -#include <stdlib.h> // atoi +#undef _COMMON_SYSINFO_P_ #include "../common/cbasetypes.h" #include "../common/core.h" -#include "../common/malloc.h" #include "../common/strlib.h" +#include "../common/malloc.h" #ifdef WIN32 -# include <string.h> // strlen -# include <windows.h> +#include <windows.h> +#include <string.h> // strlen #else -# include <unistd.h> +#include <unistd.h> #endif - -/// Private interface fields -struct sysinfo_private { - char *platform; - char *osversion; - char *cpu; - int cpucores; - char *arch; - char *compiler; - char *cflags; - char *vcstype_name; - int vcstype; - char *vcsrevision_src; - char *vcsrevision_scripts; -}; +#include <stdio.h> // fopen +#include <stdlib.h> // atoi /// sysinfo.c interface source struct sysinfo_interface sysinfo_s; diff --git a/src/common/sysinfo.h b/src/common/sysinfo.h index c0c4d276a..17faac26b 100644 --- a/src/common/sysinfo.h +++ b/src/common/sysinfo.h @@ -13,7 +13,23 @@ #include "../common/cbasetypes.h" +#ifdef _COMMON_SYSINFO_P_ +struct sysinfo_private { + char *platform; + char *osversion; + char *cpu; + int cpucores; + char *arch; + char *compiler; + char *cflags; + char *vcstype_name; + int vcstype; + char *vcsrevision_src; + char *vcsrevision_scripts; +}; +#else struct sysinfo_private; +#endif /** * sysinfo.c interface diff --git a/src/common/thread.c b/src/common/thread.c index 4f73aa9b3..4d110f2dd 100644 --- a/src/common/thread.c +++ b/src/common/thread.c @@ -6,27 +6,24 @@ // Copyright (c) rAthena Project (www.rathena.org) - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#define HERCULES_CORE - -#include "thread.h" - -#include "../common/cbasetypes.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" - #ifdef WIN32 -# include "../common/winapi.h" -# define getpagesize() 4096 // @TODO: implement this properly (GetSystemInfo .. dwPageSize..). (Atm as on all supported win platforms its 4k its static.) -# define __thread __declspec( thread ) +#include "../common/winapi.h" +#define getpagesize() 4096 // @TODO: implement this properly (GetSystemInfo .. dwPageSize..). (Atm as on all supported win platforms its 4k its static.) +#define __thread __declspec( thread ) #else -# include <stdlib.h> -# include <unistd.h> -# include <string.h> -# include <signal.h> -# include <pthread.h> -# include <sched.h> +#include <stdlib.h> +#include <unistd.h> +#include <string.h> +#include <signal.h> +#include <pthread.h> +#include <sched.h> #endif +#include "cbasetypes.h" +#include "malloc.h" +#include "showmsg.h" +#include "thread.h" + // When Compiling using MSC (on win32..) we know we have support in any case! #ifdef _MSC_VER #define HAS_TLS diff --git a/src/common/thread.h b/src/common/thread.h index 887c03179..d6b2bbc6e 100644 --- a/src/common/thread.h +++ b/src/common/thread.h @@ -1,6 +1,7 @@ // Copyright (c) rAthena Project (www.rathena.org) - Licensed under GNU GPL // For more information, see LICENCE in the main folder +#pragma once #ifndef _COMMON_THREAD_H_ #define _COMMON_THREAD_H_ diff --git a/src/common/timer.c b/src/common/timer.c index 10f14b0f2..526854582 100644 --- a/src/common/timer.c +++ b/src/common/timer.c @@ -2,8 +2,11 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - +#include "../common/cbasetypes.h" +#include "../common/db.h" +#include "../common/malloc.h" +#include "../common/showmsg.h" +#include "../common/utils.h" #include "timer.h" #include <stdio.h> @@ -11,17 +14,11 @@ #include <string.h> #include <time.h> -#include "../common/cbasetypes.h" -#include "../common/db.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" -#include "../common/utils.h" - #ifdef WIN32 -# include "../common/winapi.h" // GetTickCount() +#include "../common/winapi.h" // GetTickCount() #else -# include <sys/time.h> // struct timeval, gettimeofday() -# include <unistd.h> +#include <unistd.h> +#include <sys/time.h> // struct timeval, gettimeofday() #endif struct timer_interface timer_s; diff --git a/src/common/utils.c b/src/common/utils.c index 84925f707..47747dd32 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -2,35 +2,33 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - +#include "../common/cbasetypes.h" +#include "../common/mmo.h" +#include "../common/malloc.h" +#include "../common/showmsg.h" +#include "../common/core.h" +#include "socket.h" #include "utils.h" -#include <math.h> // floor() -#include <stdarg.h> #include <stdio.h> +#include <stdarg.h> #include <stdlib.h> #include <string.h> -#include <sys/stat.h> // cache purposes [Ind/Hercules] - -#include "../common/cbasetypes.h" -#include "../common/core.h" -#include "../common/malloc.h" -#include "../common/mmo.h" -#include "../common/showmsg.h" -#include "../common/socket.h" +#include <math.h> // floor() #ifdef WIN32 -# include "../common/winapi.h" -# ifndef F_OK -# define F_OK 0x0 -# endif /* F_OK */ + #include "../common/winapi.h" + #ifndef F_OK + #define F_OK 0x0 + #endif /* F_OK */ #else -# include <dirent.h> -# include <sys/stat.h> -# include <unistd.h> + #include <unistd.h> + #include <dirent.h> + #include <sys/stat.h> #endif +#include <sys/stat.h> // cache purposes [Ind/Hercules] + struct HCache_interface HCache_s; /// Dumps given buffer into file pointed to by a handle. diff --git a/src/common/utils.h b/src/common/utils.h index 823651163..f89546b8a 100644 --- a/src/common/utils.h +++ b/src/common/utils.h @@ -5,11 +5,10 @@ #ifndef _COMMON_UTILS_H_ #define _COMMON_UTILS_H_ +#include "../common/cbasetypes.h" #include <stdio.h> // FILE* #include <time.h> -#include "../common/cbasetypes.h" - /* [HCache] 1-byte key to ensure our method is the latest, we can modify to ensure the method matches */ #define HCACHE_KEY 'k' diff --git a/src/config/const.h b/src/config/const.h index f9baa4d7d..6557cb987 100644 --- a/src/config/const.h +++ b/src/config/const.h @@ -52,6 +52,13 @@ #define DEFTYPE_MAX CHAR_MAX #endif +/* pointer size fix which fixes several gcc warnings */ +#ifdef __64BIT__ + #define __64BPTRSIZE(y) ((intptr)(y)) +#else + #define __64BPTRSIZE(y) (y) +#endif + /* ATCMD_FUNC(mobinfo) HIT and FLEE calculations */ #ifdef RENEWAL #define MOB_FLEE(mobdata) ( (mobdata)->lv + (mobdata)->status.agi + 100 ) diff --git a/src/config/renewal.h b/src/config/renewal.h index 36bdd3958..36615d63b 100644 --- a/src/config/renewal.h +++ b/src/config/renewal.h @@ -74,6 +74,5 @@ #define RENEWAL_ASPD #endif // DISABLE_RENEWAL -#undef DISABLE_RENEWAL #endif // _CONFIG_RENEWAL_H_ diff --git a/src/login/account.h b/src/login/account.h index 329ae31c8..234e7c0c1 100644 --- a/src/login/account.h +++ b/src/login/account.h @@ -7,7 +7,6 @@ #include "../common/cbasetypes.h" #include "../common/mmo.h" // ACCOUNT_REG2_NUM -#include "../common/sql.h" // Sql typedef struct AccountDB AccountDB; typedef struct AccountDBIterator AccountDBIterator; diff --git a/src/login/account_sql.c b/src/login/account_sql.c index 2e4ed7ab9..1483196ab 100644 --- a/src/login/account_sql.c +++ b/src/login/account_sql.c @@ -2,22 +2,17 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "../config/core.h" // CONSOLE_INPUT -#include "account.h" - -#include <stdlib.h> -#include <string.h> - -#include "../common/console.h" #include "../common/malloc.h" #include "../common/mmo.h" #include "../common/showmsg.h" -#include "../common/socket.h" #include "../common/sql.h" #include "../common/strlib.h" #include "../common/timer.h" +#include "../common/console.h" +#include "../common/socket.h" +#include "account.h" +#include <stdlib.h> +#include <string.h> /// global defines #define ACCOUNT_SQL_DB_VERSION 20110114 @@ -657,7 +652,7 @@ Sql* account_db_sql_up(AccountDB* self) { AccountDB_SQL* db = (AccountDB_SQL*)self; Sql_HerculesUpdateCheck(db->accounts); #ifdef CONSOLE_INPUT - console->input->setSQL(db->accounts); + console->setSQL(db->accounts); #endif return db->accounts; } diff --git a/src/login/ipban_sql.c b/src/login/ipban_sql.c index 081f28d84..74f45e418 100644 --- a/src/login/ipban_sql.c +++ b/src/login/ipban_sql.c @@ -2,15 +2,6 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "ipban.h" - -#include <stdlib.h> -#include <string.h> - -#include "login.h" -#include "loginlog.h" #include "../common/cbasetypes.h" #include "../common/db.h" #include "../common/malloc.h" @@ -18,6 +9,11 @@ #include "../common/socket.h" #include "../common/strlib.h" #include "../common/timer.h" +#include "login.h" +#include "ipban.h" +#include "loginlog.h" +#include <stdlib.h> +#include <string.h> // global sql settings static char global_db_hostname[32] = "127.0.0.1"; diff --git a/src/login/login.c b/src/login/login.c index cb46e0226..af59fcf38 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -2,18 +2,6 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "login.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "account.h" -#include "ipban.h" -#include "loginlog.h" -#include "../common/HPM.h" #include "../common/core.h" #include "../common/db.h" #include "../common/malloc.h" @@ -24,6 +12,15 @@ #include "../common/strlib.h" #include "../common/timer.h" #include "../common/utils.h" +#include "../common/HPM.h" +#include "account.h" +#include "ipban.h" +#include "login.h" +#include "loginlog.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> struct Login_Config login_config; diff --git a/src/login/login.h b/src/login/login.h index e77b96a0e..14c361a15 100644 --- a/src/login/login.h +++ b/src/login/login.h @@ -5,8 +5,8 @@ #ifndef _LOGIN_LOGIN_H_ #define _LOGIN_LOGIN_H_ -#include "../common/core.h" // CORE_ST_LAST #include "../common/mmo.h" // NAME_LENGTH,SEX_* +#include "../common/core.h" // CORE_ST_LAST enum E_LOGINSERVER_ST { diff --git a/src/login/loginlog.h b/src/login/loginlog.h index a86ad431c..730fb6e62 100644 --- a/src/login/loginlog.h +++ b/src/login/loginlog.h @@ -4,7 +4,6 @@ #ifndef _LOGIN_LOGINLOG_H_ #define _LOGIN_LOGINLOG_H_ -#include "../common/cbasetypes.h" unsigned long loginlog_failedattempts(uint32 ip, unsigned int minutes); void login_log(uint32 ip, const char* username, int rcode, const char* message); @@ -12,4 +11,5 @@ bool loginlog_init(void); bool loginlog_final(void); bool loginlog_config_read(const char* w1, const char* w2); + #endif /* _LOGIN_LOGINLOG_H_ */ diff --git a/src/login/loginlog_sql.c b/src/login/loginlog_sql.c index 2cbc02c93..231ac783b 100644 --- a/src/login/loginlog_sql.c +++ b/src/login/loginlog_sql.c @@ -2,18 +2,13 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "loginlog.h" - -#include <string.h> -#include <stdlib.h> // exit - #include "../common/cbasetypes.h" #include "../common/mmo.h" #include "../common/socket.h" #include "../common/sql.h" #include "../common/strlib.h" +#include <string.h> +#include <stdlib.h> // exit // global sql settings (in ipban_sql.c) static char global_db_hostname[32] = "127.0.0.1"; diff --git a/src/map/HPMmap.c b/src/map/HPMmap.c index cb8c979c6..061479d87 100644 --- a/src/map/HPMmap.c +++ b/src/map/HPMmap.c @@ -1,15 +1,25 @@ // Copyright (c) Hercules Dev Team, licensed under GNU GPL. // See the LICENSE file -#define HERCULES_CORE +#include "../common/cbasetypes.h" +#include "../common/malloc.h" +#include "../common/showmsg.h" +#include "../common/HPM.h" +#include "../common/conf.h" +#include "../common/db.h" +#include "../common/des.h" +#include "../common/ers.h" +#include "../common/mapindex.h" +#include "../common/mmo.h" +#include "../common/socket.h" +#include "../common/strlib.h" -#include "HPMmap.h" -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <time.h> +#include "HPMmap.h" +#include "pc.h" +#include "map.h" +// #include "atcommand.h" #include "battle.h" #include "battleground.h" @@ -27,14 +37,12 @@ #include "itemdb.h" #include "log.h" #include "mail.h" -#include "map.h" #include "mapreg.h" #include "mercenary.h" #include "mob.h" #include "npc.h" #include "party.h" #include "path.h" -#include "pc.h" #include "pc_groups.h" #include "pet.h" #include "quest.h" @@ -46,19 +54,11 @@ #include "trade.h" #include "unit.h" #include "vending.h" -#include "../common/HPM.h" -#include "../common/cbasetypes.h" -#include "../common/conf.h" -#include "../common/db.h" -#include "../common/des.h" -#include "../common/ers.h" -#include "../common/malloc.h" -#include "../common/mapindex.h" -#include "../common/mmo.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/strlib.h" -#include "../common/sysinfo.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <time.h> #include "../common/HPMDataCheck.h" diff --git a/src/map/atcommand.c b/src/map/atcommand.c index df3be40a5..5fd0faf86 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -2,60 +2,57 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE +#include "../common/cbasetypes.h" +#include "../common/mmo.h" +#include "../common/timer.h" +#include "../common/nullpo.h" +#include "../common/core.h" +#include "../common/showmsg.h" +#include "../common/malloc.h" +#include "../common/random.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/utils.h" +#include "../common/conf.h" +#include "../common/sysinfo.h" -#include "../config/core.h" // AUTOLOOTITEM_SIZE, AUTOTRADE_PERSISTENCY, MAX_CARTS, MAX_SUGGESTIONS, MOB_FLEE(), MOB_HIT(), RENEWAL, RENEWAL_DROP, RENEWAL_EXP #include "atcommand.h" - -#include <math.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - #include "battle.h" #include "chat.h" -#include "chrif.h" #include "clif.h" +#include "chrif.h" #include "duel.h" -#include "elemental.h" -#include "guild.h" -#include "homunculus.h" #include "intif.h" #include "itemdb.h" #include "log.h" -#include "mail.h" #include "map.h" -#include "mapreg.h" -#include "mercenary.h" -#include "mob.h" -#include "npc.h" -#include "party.h" #include "pc.h" #include "pc_groups.h" // groupid2name +#include "status.h" +#include "skill.h" +#include "mob.h" +#include "npc.h" #include "pet.h" -#include "quest.h" +#include "homunculus.h" +#include "mail.h" +#include "mercenary.h" +#include "elemental.h" +#include "party.h" +#include "guild.h" #include "script.h" -#include "searchstore.h" -#include "skill.h" -#include "status.h" #include "storage.h" #include "trade.h" #include "unit.h" -#include "../common/cbasetypes.h" -#include "../common/conf.h" -#include "../common/core.h" -#include "../common/malloc.h" -#include "../common/mmo.h" -#include "../common/nullpo.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/strlib.h" -#include "../common/sysinfo.h" -#include "../common/timer.h" -#include "../common/utils.h" +#include "mapreg.h" +#include "quest.h" +#include "searchstore.h" #include "HPMmap.h" +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <math.h> + struct atcommand_interface atcommand_s; static char atcmd_output[CHAT_SIZE_MAX]; diff --git a/src/map/atcommand.h b/src/map/atcommand.h index c8a1863af..bc4ab30a3 100644 --- a/src/map/atcommand.h +++ b/src/map/atcommand.h @@ -5,9 +5,9 @@ #ifndef _MAP_ATCOMMAND_H_ #define _MAP_ATCOMMAND_H_ -#include "pc_groups.h" #include "../common/conf.h" #include "../common/db.h" +#include "pc_groups.h" /** * Declarations diff --git a/src/map/battle.c b/src/map/battle.c index 0865ee4ba..9089b7102 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -2,44 +2,41 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "../config/core.h" // CELL_NOSTACK, CIRCULAR_AREA, CONSOLE_INPUT, HMAP_ZONE_DAMAGE_CAP_TYPE, OFFICIAL_WALKPATH, RENEWAL, RENEWAL_ASPD, RENEWAL_CAST, RENEWAL_DROP, RENEWAL_EDP, RENEWAL_EXP, RENEWAL_LVDMG, RE_LVL_DMOD(), RE_LVL_MDMOD(), RE_LVL_TMDMOD(), RE_SKILL_REDUCTION(), SCRIPT_CALLFUNC_CHECK, SECURE_NPCTIMEOUT, STATS_OPT_OUT -#include "battle.h" - -#include <math.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "battleground.h" -#include "chrif.h" -#include "clif.h" -#include "elemental.h" -#include "guild.h" -#include "homunculus.h" -#include "itemdb.h" -#include "map.h" -#include "mercenary.h" -#include "mob.h" -#include "party.h" -#include "path.h" -#include "pc.h" -#include "pet.h" -#include "skill.h" -#include "status.h" -#include "../common/HPM.h" #include "../common/cbasetypes.h" -#include "../common/ers.h" -#include "../common/malloc.h" +#include "../common/timer.h" #include "../common/nullpo.h" -#include "../common/random.h" +#include "../common/malloc.h" #include "../common/showmsg.h" +#include "../common/ers.h" +#include "../common/random.h" #include "../common/socket.h" #include "../common/strlib.h" -#include "../common/sysinfo.h" -#include "../common/timer.h" #include "../common/utils.h" +#include "../common/sysinfo.h" +#include "../common/HPM.h" + +#include "map.h" +#include "path.h" +#include "pc.h" +#include "status.h" +#include "skill.h" +#include "homunculus.h" +#include "mercenary.h" +#include "elemental.h" +#include "mob.h" +#include "itemdb.h" +#include "clif.h" +#include "pet.h" +#include "guild.h" +#include "party.h" +#include "battle.h" +#include "battleground.h" +#include "chrif.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <math.h> struct Battle_Config battle_config; struct battle_interface battle_s; diff --git a/src/map/battle.h b/src/map/battle.h index fbe097c78..88038ddb4 100644 --- a/src/map/battle.h +++ b/src/map/battle.h @@ -5,8 +5,8 @@ #ifndef _MAP_BATTLE_H_ #define _MAP_BATTLE_H_ -#include "map.h" //ELE_MAX #include "../common/cbasetypes.h" +#include "map.h" //ELE_MAX /** * Declarations diff --git a/src/map/battleground.c b/src/map/battleground.c index a7169de0e..68539e25d 100644 --- a/src/map/battleground.c +++ b/src/map/battleground.c @@ -2,32 +2,29 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE +#include "../common/cbasetypes.h" +#include "../common/timer.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/conf.h" #include "battleground.h" - -#include <string.h> -#include <stdio.h> - #include "battle.h" #include "clif.h" -#include "homunculus.h" #include "map.h" -#include "mapreg.h" -#include "mercenary.h" -#include "mob.h" // struct mob_data #include "npc.h" -#include "party.h" #include "pc.h" +#include "party.h" #include "pet.h" -#include "../common/cbasetypes.h" -#include "../common/conf.h" -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/strlib.h" -#include "../common/timer.h" +#include "homunculus.h" +#include "mercenary.h" +#include "mapreg.h" + +#include <string.h> +#include <stdio.h> struct battleground_interface bg_s; diff --git a/src/map/battleground.h b/src/map/battleground.h index ec0a86f14..05c4eb060 100644 --- a/src/map/battleground.h +++ b/src/map/battleground.h @@ -5,9 +5,9 @@ #ifndef _MAP_BATTLEGROUND_H_ #define _MAP_BATTLEGROUND_H_ +#include "../common/mmo.h" // struct party #include "clif.h" #include "guild.h" -#include "../common/mmo.h" // struct party /** * Defines diff --git a/src/map/buyingstore.c b/src/map/buyingstore.c index 80264b30d..2a15e66fc 100644 --- a/src/map/buyingstore.c +++ b/src/map/buyingstore.c @@ -2,21 +2,18 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "buyingstore.h" // struct s_buyingstore - -#include "atcommand.h" // msg_txt -#include "battle.h" // battle_config.* -#include "chrif.h" -#include "clif.h" // clif->buyingstore_* -#include "log.h" // log_pick_pc, log_zeny -#include "pc.h" // struct map_session_data #include "../common/cbasetypes.h" #include "../common/db.h" // ARR_FIND #include "../common/showmsg.h" // ShowWarning #include "../common/socket.h" // RBUF* #include "../common/strlib.h" // safestrncpy +#include "atcommand.h" // msg_txt +#include "battle.h" // battle_config.* +#include "buyingstore.h" // struct s_buyingstore +#include "clif.h" // clif->buyingstore_* +#include "log.h" // log_pick_pc, log_zeny +#include "pc.h" // struct map_session_data +#include "chrif.h" struct buyingstore_interface buyingstore_s; diff --git a/src/map/buyingstore.h b/src/map/buyingstore.h index 914631872..5141a1013 100644 --- a/src/map/buyingstore.h +++ b/src/map/buyingstore.h @@ -5,11 +5,6 @@ #ifndef _MAP_BUYINGSTORE_H_ #define _MAP_BUYINGSTORE_H_ -#include "../common/cbasetypes.h" -#include "../common/mmo.h" // MAX_SLOTS - -struct map_session_data; - /** * Declarations **/ diff --git a/src/map/chat.c b/src/map/chat.c index c9d3e6d46..08fc4a575 100644 --- a/src/map/chat.c +++ b/src/map/chat.c @@ -2,13 +2,12 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "chat.h" - -#include <stdio.h> -#include <string.h> - +#include "../common/cbasetypes.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" +#include "../common/mmo.h" #include "atcommand.h" // msg_txt() #include "battle.h" // struct battle_config #include "clif.h" @@ -16,12 +15,10 @@ #include "npc.h" // npc_event_do() #include "pc.h" #include "skill.h" // ext_skill_unit_onplace() -#include "../common/cbasetypes.h" -#include "../common/malloc.h" -#include "../common/mmo.h" -#include "../common/nullpo.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" +#include "chat.h" + +#include <stdio.h> +#include <string.h> struct chat_interface chat_s; diff --git a/src/map/chat.h b/src/map/chat.h index cbc2a391e..b0c6cd905 100644 --- a/src/map/chat.h +++ b/src/map/chat.h @@ -6,12 +6,9 @@ #define _MAP_CHAT_H_ #include "map.h" // struct block_list, CHATROOM_TITLE_SIZE -#include "../common/cbasetypes.h" -#include "../common/db.h" -struct chat_data; struct map_session_data; -struct npc_data; +struct chat_data; #define MAX_CHAT_USERS 20 diff --git a/src/map/chrif.c b/src/map/chrif.c index 81e2d387c..99a1935fd 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -2,16 +2,15 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "../config/core.h" // AUTOTRADE_PERSISTENCY, STATS_OPT_OUT -#include "chrif.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <sys/types.h> -#include <time.h> +#include "../common/cbasetypes.h" +#include "../common/malloc.h" +#include "../common/socket.h" +#include "../common/timer.h" +#include "../common/nullpo.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" +#include "../common/ers.h" +#include "../common/HPM.h" #include "map.h" #include "battle.h" @@ -26,17 +25,15 @@ #include "instance.h" #include "mercenary.h" #include "elemental.h" +#include "chrif.h" #include "quest.h" #include "storage.h" -#include "../common/HPM.h" -#include "../common/cbasetypes.h" -#include "../common/ers.h" -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/strlib.h" -#include "../common/timer.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/types.h> +#include <time.h> struct chrif_interface chrif_s; diff --git a/src/map/chrif.h b/src/map/chrif.h index 84efc66d3..25e955604 100644 --- a/src/map/chrif.h +++ b/src/map/chrif.h @@ -5,11 +5,9 @@ #ifndef _MAP_CHRIF_H_ #define _MAP_CHRIF_H_ +#include "../common/cbasetypes.h" #include <time.h> - #include "map.h" //TBL_stuff -#include "../common/cbasetypes.h" -#include "../common/db.h" struct status_change_entry; diff --git a/src/map/clif.c b/src/map/clif.c index cb2474961..1a6665307 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -2,59 +2,56 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "../config/core.h" // ANTI_MAYAP_CHEAT, NEW_CARTS, RENEWAL, SECURE_NPCTIMEOUT -#include "clif.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <stdarg.h> -#include <time.h> +#include "../common/cbasetypes.h" +#include "../common/socket.h" +#include "../common/timer.h" +#include "../common/grfio.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" +#include "../common/utils.h" +#include "../common/ers.h" +#include "../common/conf.h" +#include "../common/HPM.h" +#include "map.h" +#include "chrif.h" +#include "pc.h" +#include "status.h" +#include "npc.h" +#include "itemdb.h" +#include "chat.h" +#include "trade.h" +#include "storage.h" +#include "script.h" +#include "skill.h" #include "atcommand.h" +#include "intif.h" #include "battle.h" #include "battleground.h" -#include "chat.h" -#include "chrif.h" -#include "elemental.h" +#include "mob.h" +#include "party.h" +#include "unit.h" #include "guild.h" +#include "vending.h" +#include "pet.h" #include "homunculus.h" #include "instance.h" -#include "intif.h" -#include "irc-bot.h" -#include "itemdb.h" +#include "mercenary.h" +#include "elemental.h" #include "log.h" +#include "clif.h" #include "mail.h" -#include "map.h" -#include "mercenary.h" -#include "mob.h" -#include "npc.h" -#include "party.h" -#include "pc.h" -#include "pet.h" #include "quest.h" -#include "script.h" -#include "skill.h" -#include "status.h" -#include "storage.h" -#include "trade.h" -#include "unit.h" -#include "vending.h" -#include "../common/HPM.h" -#include "../common/cbasetypes.h" -#include "../common/conf.h" -#include "../common/ers.h" -#include "../common/grfio.h" -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/strlib.h" -#include "../common/timer.h" -#include "../common/utils.h" +#include "irc-bot.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <stdarg.h> +#include <time.h> struct clif_interface clif_s; diff --git a/src/map/clif.h b/src/map/clif.h index 7b27e1fe6..0f4a9e756 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -5,13 +5,13 @@ #ifndef _MAP_CLIF_H_ #define _MAP_CLIF_H_ -#include <stdarg.h> - -#include "map.h" -#include "packets_struct.h" #include "../common/cbasetypes.h" #include "../common/db.h" #include "../common/mmo.h" +#include "../common/socket.h" +#include "../map/map.h" +#include "../map/packets_struct.h" +#include <stdarg.h> /** * Declarations @@ -20,6 +20,7 @@ struct item; struct item_data; struct storage_data; struct guild_storage; +struct block_list; struct unit_data; struct map_session_data; struct homun_data; diff --git a/src/map/date.c b/src/map/date.c index 975a00c50..f38ead858 100644 --- a/src/map/date.c +++ b/src/map/date.c @@ -1,14 +1,10 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#define HERCULES_CORE - +#include "../common/cbasetypes.h" #include "date.h" - #include <time.h> -#include "../common/cbasetypes.h" - int date_get_year(void) { time_t t; diff --git a/src/map/date.h b/src/map/date.h index b3ed59b2f..46f0d86c3 100644 --- a/src/map/date.h +++ b/src/map/date.h @@ -4,8 +4,6 @@ #ifndef _MAP_DATE_H_ #define _MAP_DATE_H_ -#include "../common/cbasetypes.h" - int date_get_year(void); int date_get_month(void); int date_get_day(void); diff --git a/src/map/duel.c b/src/map/duel.c index a423ef240..af2741f77 100644 --- a/src/map/duel.c +++ b/src/map/duel.c @@ -2,20 +2,18 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE +#include "../common/cbasetypes.h" +#include "atcommand.h" // msg_txt +#include "clif.h" #include "duel.h" +#include "pc.h" #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> -#include "atcommand.h" // msg_txt -#include "clif.h" -#include "pc.h" -#include "../common/cbasetypes.h" - /*========================================== * Duel organizing functions [LuzZza] *------------------------------------------*/ diff --git a/src/map/duel.h b/src/map/duel.h index 956aed36d..5405d2eee 100644 --- a/src/map/duel.h +++ b/src/map/duel.h @@ -5,10 +5,6 @@ #ifndef _MAP_DUEL_H_ #define _MAP_DUEL_H_ -#include "../common/cbasetypes.h" - -struct map_session_data; - struct duel { int members_count; int invites_count; diff --git a/src/map/elemental.c b/src/map/elemental.c index 323df41e1..f335600d6 100644 --- a/src/map/elemental.c +++ b/src/map/elemental.c @@ -2,44 +2,42 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "elemental.h" - -#include <math.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> +#include "../common/cbasetypes.h" +#include "../common/malloc.h" +#include "../common/socket.h" +#include "../common/timer.h" +#include "../common/nullpo.h" +#include "../common/mmo.h" +#include "../common/showmsg.h" +#include "../common/utils.h" +#include "../common/random.h" +#include "../common/strlib.h" -#include "atcommand.h" -#include "battle.h" -#include "chrif.h" +#include "log.h" #include "clif.h" -#include "guild.h" +#include "chrif.h" #include "intif.h" #include "itemdb.h" -#include "log.h" #include "map.h" -#include "mob.h" -#include "npc.h" -#include "party.h" #include "pc.h" +#include "status.h" +#include "skill.h" +#include "mob.h" #include "pet.h" +#include "battle.h" +#include "party.h" +#include "guild.h" +#include "atcommand.h" #include "script.h" -#include "skill.h" -#include "status.h" +#include "npc.h" #include "trade.h" #include "unit.h" -#include "../common/cbasetypes.h" -#include "../common/malloc.h" -#include "../common/mmo.h" -#include "../common/nullpo.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/strlib.h" -#include "../common/timer.h" -#include "../common/utils.h" +#include "elemental.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <math.h> struct elemental_interface elemental_s; diff --git a/src/map/elemental.h b/src/map/elemental.h index aa27aadc9..6d04a41a5 100644 --- a/src/map/elemental.h +++ b/src/map/elemental.h @@ -7,7 +7,6 @@ #include "status.h" // struct status_data, struct status_change #include "unit.h" // struct unit_data -#include "../common/mmo.h" // NAME_LENGTH /** * Defines diff --git a/src/map/guild.c b/src/map/guild.c index 69f67238d..fa5805c8b 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -2,37 +2,34 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "../config/core.h" // GP_BOUND_ITEMS -#include "guild.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "battle.h" -#include "clif.h" -#include "instance.h" -#include "intif.h" -#include "log.h" -#include "map.h" -#include "mob.h" -#include "npc.h" -#include "pc.h" -#include "skill.h" -#include "status.h" -#include "storage.h" -#include "../common/HPM.h" #include "../common/cbasetypes.h" -#include "../common/ers.h" +#include "../common/timer.h" +#include "../common/nullpo.h" #include "../common/malloc.h" #include "../common/mapindex.h" -#include "../common/nullpo.h" #include "../common/showmsg.h" +#include "../common/ers.h" #include "../common/strlib.h" -#include "../common/timer.h" #include "../common/utils.h" +#include "../common/HPM.h" + +#include "map.h" +#include "guild.h" +#include "storage.h" +#include "battle.h" +#include "npc.h" +#include "pc.h" +#include "status.h" +#include "mob.h" +#include "intif.h" +#include "clif.h" +#include "skill.h" +#include "log.h" +#include "instance.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> struct guild_interface guild_s; diff --git a/src/map/guild.h b/src/map/guild.h index 34e27a56c..b03bd664d 100644 --- a/src/map/guild.h +++ b/src/map/guild.h @@ -5,10 +5,18 @@ #ifndef _MAP_GUILD_H_ #define _MAP_GUILD_H_ -#include "map.h" // EVENT_NAME_LENGTH, TBL_PC -#include "../common/cbasetypes.h" -#include "../common/db.h" -#include "../common/mmo.h" +//#include "../common/mmo.h" +#include "map.h" // NAME_LENGTH + +/** + * Declarations + **/ +struct guild; +struct guild_member; +struct guild_position; +struct guild_castle; +struct map_session_data; +struct mob_data; /** * Defines diff --git a/src/map/homunculus.c b/src/map/homunculus.c index b6a83d1cb..ff9f7a5b1 100644 --- a/src/map/homunculus.c +++ b/src/map/homunculus.c @@ -2,45 +2,43 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "../config/core.h" // DBPATH -#include "homunculus.h" - -#include <math.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> +#include "../common/cbasetypes.h" +#include "../common/malloc.h" +#include "../common/socket.h" +#include "../common/timer.h" +#include "../common/nullpo.h" +#include "../common/mmo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" +#include "../common/utils.h" -#include "atcommand.h" -#include "battle.h" -#include "chrif.h" +#include "log.h" #include "clif.h" -#include "guild.h" +#include "chrif.h" #include "intif.h" #include "itemdb.h" -#include "log.h" #include "map.h" -#include "mob.h" -#include "npc.h" -#include "party.h" #include "pc.h" +#include "status.h" +#include "skill.h" +#include "mob.h" #include "pet.h" +#include "battle.h" +#include "party.h" +#include "guild.h" +#include "atcommand.h" #include "script.h" -#include "skill.h" -#include "status.h" +#include "npc.h" #include "trade.h" #include "unit.h" -#include "../common/cbasetypes.h" -#include "../common/malloc.h" -#include "../common/mmo.h" -#include "../common/nullpo.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/strlib.h" -#include "../common/timer.h" -#include "../common/utils.h" + +#include "homunculus.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <math.h> struct homunculus_interface homunculus_s; diff --git a/src/map/homunculus.h b/src/map/homunculus.h index 9eef6af5b..e6d59e30e 100644 --- a/src/map/homunculus.h +++ b/src/map/homunculus.h @@ -5,10 +5,9 @@ #ifndef _MAP_HOMUNCULUS_H_ #define _MAP_HOMUNCULUS_H_ -#include "pc.h" #include "status.h" // struct status_data, struct status_change #include "unit.h" // struct unit_data -#include "../common/mmo.h" +#include "pc.h" #define MAX_HOM_SKILL_REQUIRE 5 #define homdb_checkid(id) ((id) >= HM_CLASS_BASE && (id) <= HM_CLASS_MAX) diff --git a/src/map/instance.c b/src/map/instance.c index 5789d7dd6..caf622b3d 100644 --- a/src/map/instance.c +++ b/src/map/instance.c @@ -2,32 +2,30 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE +#include "../common/cbasetypes.h" +#include "../common/socket.h" +#include "../common/timer.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" +#include "../common/utils.h" +#include "../common/db.h" +#include "../common/HPM.h" +#include "clif.h" #include "instance.h" +#include "map.h" +#include "npc.h" +#include "party.h" +#include "pc.h" -#include <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <stdarg.h> #include <time.h> -#include "clif.h" -#include "map.h" -#include "npc.h" -#include "party.h" -#include "pc.h" -#include "../common/HPM.h" -#include "../common/cbasetypes.h" -#include "../common/db.h" -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/strlib.h" -#include "../common/timer.h" -#include "../common/utils.h" - struct instance_interface instance_s; /// Checks whether given instance id is valid or not. diff --git a/src/map/instance.h b/src/map/instance.h index ae649eda7..712a0f141 100644 --- a/src/map/instance.h +++ b/src/map/instance.h @@ -6,11 +6,8 @@ #define _MAP_INSTANCE_H_ #include "script.h" // struct reg_db -#include "../common/cbasetypes.h" #include "../common/mmo.h" // struct point - struct block_list; -struct map_session_data; #define INSTANCE_NAME_LENGTH (60+1) diff --git a/src/map/intif.c b/src/map/intif.c index 383150fbc..6bd24368a 100644 --- a/src/map/intif.c +++ b/src/map/intif.c @@ -1,40 +1,37 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#define HERCULES_CORE - -#include "../config/core.h" // GP_BOUND_ITEMS -#include "intif.h" - -#include <fcntl.h> -#include <signal.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <sys/types.h> - -#include "atcommand.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/timer.h" +#include "../common/nullpo.h" +#include "../common/malloc.h" +#include "../common/strlib.h" +#include "map.h" #include "battle.h" #include "chrif.h" #include "clif.h" -#include "elemental.h" -#include "guild.h" -#include "homunculus.h" +#include "pc.h" +#include "intif.h" #include "log.h" -#include "mail.h" -#include "map.h" -#include "mercenary.h" +#include "storage.h" #include "party.h" -#include "pc.h" +#include "guild.h" #include "pet.h" +#include "atcommand.h" +#include "mercenary.h" +#include "homunculus.h" +#include "elemental.h" +#include "mail.h" #include "quest.h" -#include "storage.h" -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/strlib.h" -#include "../common/timer.h" + +#include <sys/types.h> +#include <stdio.h> +#include <stdlib.h> +#include <signal.h> +#include <fcntl.h> +#include <string.h> + struct intif_interface intif_s; diff --git a/src/map/intif.h b/src/map/intif.h index b6ee727f3..290dcfcdc 100644 --- a/src/map/intif.h +++ b/src/map/intif.h @@ -5,22 +5,19 @@ #ifndef _MAP_INTIF_H_ #define _MAP_INTIF_H_ -#include "../common/cbasetypes.h" /** * Declarations **/ -struct auction_data; +struct party_member; struct guild_member; struct guild_position; -struct guild_storage; -struct mail_message; -struct map_session_data; -struct party_member; -struct s_elemental; +struct s_pet; struct s_homunculus; struct s_mercenary; -struct s_pet; +struct s_elemental; +struct mail_message; +struct auction_data; /** * Defines diff --git a/src/map/irc-bot.c b/src/map/irc-bot.c index 6f016697f..ff28082e7 100644 --- a/src/map/irc-bot.c +++ b/src/map/irc-bot.c @@ -2,25 +2,23 @@ // See the LICENSE file // Base Author: shennetsind @ http://hercules.ws -#define HERCULES_CORE +#include "../common/cbasetypes.h" +#include "../common/malloc.h" +#include "../common/strlib.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/timer.h" +#include "../common/random.h" +#include "map.h" +#include "pc.h" +#include "clif.h" #include "irc-bot.h" #include <stdio.h> #include <stdlib.h> #include <string.h> -#include "clif.h" -#include "map.h" -#include "pc.h" -#include "../common/cbasetypes.h" -#include "../common/malloc.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/strlib.h" -#include "../common/timer.h" - //#define IRCBOT_DEBUG struct irc_bot_interface irc_bot_s; diff --git a/src/map/irc-bot.h b/src/map/irc-bot.h index 60f03fca5..c15a5d46a 100644 --- a/src/map/irc-bot.h +++ b/src/map/irc-bot.h @@ -6,8 +6,6 @@ #ifndef _MAP_IRC_BOT_H_ #define _MAP_IRC_BOT_H_ -#include "../common/cbasetypes.h" - #define IRC_NICK_LENGTH 40 #define IRC_IDENT_LENGTH 40 #define IRC_HOST_LENGTH 63 diff --git a/src/map/itemdb.c b/src/map/itemdb.c index 1981f435c..5eeb90be5 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -2,27 +2,22 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "../config/core.h" // DBPATH, RENEWAL -#include "itemdb.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "battle.h" // struct battle_config -#include "map.h" -#include "mob.h" // MAX_MOB_DB -#include "pc.h" // W_MUSICAL, W_WHIP -#include "script.h" // item script processing -#include "../common/conf.h" -#include "../common/malloc.h" #include "../common/nullpo.h" +#include "../common/malloc.h" #include "../common/random.h" #include "../common/showmsg.h" #include "../common/strlib.h" #include "../common/utils.h" +#include "../common/conf.h" +#include "itemdb.h" +#include "map.h" +#include "battle.h" // struct battle_config +#include "script.h" // item script processing +#include "pc.h" // W_MUSICAL, W_WHIP + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> struct itemdb_interface itemdb_s; diff --git a/src/map/itemdb.h b/src/map/itemdb.h index 12766b288..77fb2e2ec 100644 --- a/src/map/itemdb.h +++ b/src/map/itemdb.h @@ -5,12 +5,9 @@ #ifndef _MAP_ITEMDB_H_ #define _MAP_ITEMDB_H_ -#include "map.h" -#include "../common/cbasetypes.h" -#include "../common/conf.h" #include "../common/db.h" #include "../common/mmo.h" // ITEM_NAME_LENGTH -#include "../common/sql.h" +#include "map.h" /** * Declarations diff --git a/src/map/log.c b/src/map/log.c index 523ef1d65..19a98f34b 100644 --- a/src/map/log.c +++ b/src/map/log.c @@ -2,24 +2,21 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "log.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - +#include "../common/cbasetypes.h" +#include "../common/sql.h" // SQL_INNODB +#include "../common/strlib.h" +#include "../common/nullpo.h" +#include "../common/showmsg.h" #include "battle.h" #include "itemdb.h" +#include "log.h" #include "map.h" #include "mob.h" #include "pc.h" -#include "../common/cbasetypes.h" -#include "../common/nullpo.h" -#include "../common/showmsg.h" -#include "../common/sql.h" // SQL_INNODB -#include "../common/strlib.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> struct log_interface log_s; diff --git a/src/map/log.h b/src/map/log.h index ecfedeac2..b2cb92c20 100644 --- a/src/map/log.h +++ b/src/map/log.h @@ -11,10 +11,11 @@ /** * Declarations **/ -struct item; -struct item_data; +struct block_list; struct map_session_data; struct mob_data; +struct item; +struct item_data; /** * Defines diff --git a/src/map/mail.c b/src/map/mail.c index 7ba7d7470..371aa892f 100644 --- a/src/map/mail.c +++ b/src/map/mail.c @@ -2,20 +2,18 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE +#include "../common/nullpo.h" +#include "../common/showmsg.h" #include "mail.h" - -#include <time.h> -#include <string.h> - #include "atcommand.h" -#include "clif.h" #include "itemdb.h" -#include "log.h" +#include "clif.h" #include "pc.h" -#include "../common/nullpo.h" -#include "../common/showmsg.h" +#include "log.h" + +#include <time.h> +#include <string.h> struct mail_interface mail_s; diff --git a/src/map/mail.h b/src/map/mail.h index 30b032ef4..8df537ff3 100644 --- a/src/map/mail.h +++ b/src/map/mail.h @@ -5,11 +5,7 @@ #ifndef _MAP_MAIL_H_ #define _MAP_MAIL_H_ -#include "../common/cbasetypes.h" - -struct item; -struct mail_message; -struct map_session_data; +#include "../common/mmo.h" struct mail_interface { void (*clear) (struct map_session_data *sd); diff --git a/src/map/map.c b/src/map/map.c index 01d3dbb9f..315924e2e 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -2,66 +2,62 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE +#include "../common/cbasetypes.h" +#include "../common/core.h" +#include "../common/timer.h" +#include "../common/ers.h" +#include "../common/grfio.h" +#include "../common/malloc.h" +#include "../common/socket.h" // WFIFO*() +#include "../common/showmsg.h" +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/strlib.h" +#include "../common/utils.h" +#include "../common/conf.h" +#include "../common/console.h" +#include "../common/HPM.h" -#include "../config/core.h" // CELL_NOSTACK, CIRCULAR_AREA, CONSOLE_INPUT, DBPATH, RENEWAL #include "map.h" - -#include <math.h> -#include <stdarg.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "HPMmap.h" -#include "atcommand.h" -#include "battle.h" -#include "battleground.h" -#include "chat.h" +#include "path.h" #include "chrif.h" #include "clif.h" #include "duel.h" -#include "elemental.h" -#include "guild.h" -#include "homunculus.h" -#include "instance.h" #include "intif.h" -#include "irc-bot.h" -#include "itemdb.h" -#include "log.h" -#include "mail.h" -#include "mapreg.h" -#include "mercenary.h" -#include "mob.h" #include "npc.h" -#include "npc.h" // npc_setcells(), npc_unsetcells() -#include "party.h" -#include "path.h" #include "pc.h" -#include "pet.h" -#include "quest.h" -#include "script.h" -#include "skill.h" #include "status.h" +#include "mob.h" +#include "npc.h" // npc_setcells(), npc_unsetcells() +#include "chat.h" +#include "itemdb.h" #include "storage.h" +#include "skill.h" #include "trade.h" +#include "party.h" #include "unit.h" -#include "../common/HPM.h" -#include "../common/cbasetypes.h" -#include "../common/conf.h" -#include "../common/console.h" -#include "../common/core.h" -#include "../common/ers.h" -#include "../common/grfio.h" -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/socket.h" // WFIFO*() -#include "../common/strlib.h" -#include "../common/timer.h" -#include "../common/utils.h" +#include "battle.h" +#include "battleground.h" +#include "quest.h" +#include "script.h" +#include "mapreg.h" +#include "guild.h" +#include "pet.h" +#include "homunculus.h" +#include "instance.h" +#include "mercenary.h" +#include "elemental.h" +#include "atcommand.h" +#include "log.h" +#include "mail.h" +#include "irc-bot.h" +#include "HPMmap.h" +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <stdarg.h> +#include <math.h> #ifndef _WIN32 #include <unistd.h> #endif @@ -5486,8 +5482,8 @@ void map_cp_defaults(void) { map->cpsd->bl.y = MAP_DEFAULT_Y; map->cpsd->bl.m = map->mapname2mapid(MAP_DEFAULT); - console->input->addCommand("gm:info",CPCMD_A(gm_position)); - console->input->addCommand("gm:use",CPCMD_A(gm_use)); + console->addCommand("gm:info",CPCMD_A(gm_position)); + console->addCommand("gm:use",CPCMD_A(gm_use)); #endif } /* Hercules Plugin Mananger */ @@ -5843,7 +5839,7 @@ int do_init(int argc, char *argv[]) Sql_HerculesUpdateCheck(map->mysql_handle); #ifdef CONSOLE_INPUT - console->input->setSQL(map->mysql_handle); + console->setSQL(map->mysql_handle); #endif ShowStatus("Server is '"CL_GREEN"ready"CL_RESET"' and listening on port '"CL_WHITE"%d"CL_RESET"'.\n\n", map->port); diff --git a/src/map/map.h b/src/map/map.h index 539b02ed8..c61868b13 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -5,18 +5,18 @@ #ifndef _MAP_MAP_H_ #define _MAP_MAP_H_ -#include <stdarg.h> - -#include "atcommand.h" #include "../common/cbasetypes.h" #include "../common/core.h" // CORE_ST_LAST #include "../common/mmo.h" #include "../common/mapindex.h" #include "../common/db.h" +#include "../config/core.h" #include "../common/sql.h" +#include "atcommand.h" +#include <stdarg.h> -struct mob_data; struct npc_data; +struct item_data; struct hChSysCh; enum E_MAPSERVER_ST { @@ -36,6 +36,7 @@ enum E_MAPSERVER_ST { #define NATURAL_HEAL_INTERVAL 500 #define MIN_FLOORITEM 2 #define MAX_FLOORITEM START_ACCOUNT_NUM +#define MAX_LEVEL 175 #define MAX_IGNORE_LIST 20 // official is 14 #define MAX_VENDING 12 #define MAX_MAP_SIZE (512*512) // Wasn't there something like this already? Can't find it.. [Shinryo] diff --git a/src/map/mapreg_sql.c b/src/map/mapreg_sql.c index f026fde00..61c25f24e 100644 --- a/src/map/mapreg_sql.c +++ b/src/map/mapreg_sql.c @@ -2,15 +2,6 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "mapreg.h" - -#include <stdlib.h> -#include <string.h> - -#include "map.h" // map->mysql_handle -#include "script.h" #include "../common/cbasetypes.h" #include "../common/db.h" #include "../common/ers.h" @@ -19,6 +10,11 @@ #include "../common/sql.h" #include "../common/strlib.h" #include "../common/timer.h" +#include "map.h" // map->mysql_handle +#include "script.h" +#include "mapreg.h" +#include <stdlib.h> +#include <string.h> struct mapreg_interface mapreg_s; diff --git a/src/map/mercenary.c b/src/map/mercenary.c index 26bc8c188..495621014 100644 --- a/src/map/mercenary.c +++ b/src/map/mercenary.c @@ -2,44 +2,42 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "mercenary.h" - -#include <math.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> +#include "../common/cbasetypes.h" +#include "../common/malloc.h" +#include "../common/socket.h" +#include "../common/timer.h" +#include "../common/nullpo.h" +#include "../common/mmo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" +#include "../common/utils.h" -#include "atcommand.h" -#include "battle.h" -#include "chrif.h" +#include "log.h" #include "clif.h" -#include "guild.h" +#include "chrif.h" #include "intif.h" #include "itemdb.h" -#include "log.h" #include "map.h" -#include "mob.h" -#include "npc.h" -#include "party.h" #include "pc.h" +#include "status.h" +#include "skill.h" +#include "mob.h" #include "pet.h" +#include "battle.h" +#include "party.h" +#include "guild.h" +#include "atcommand.h" #include "script.h" -#include "skill.h" -#include "status.h" +#include "npc.h" #include "trade.h" #include "unit.h" -#include "../common/cbasetypes.h" -#include "../common/malloc.h" -#include "../common/mmo.h" -#include "../common/nullpo.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/strlib.h" -#include "../common/timer.h" -#include "../common/utils.h" +#include "mercenary.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <math.h> struct mercenary_interface mercenary_s; diff --git a/src/map/mercenary.h b/src/map/mercenary.h index b998ac006..dd9266b2e 100644 --- a/src/map/mercenary.h +++ b/src/map/mercenary.h @@ -6,7 +6,6 @@ #include "status.h" // struct status_data, struct status_change #include "unit.h" // struct unit_data -#include "../common/cbasetypes.h" // number of cells that a mercenary can walk to from it's master before being warped #define MAX_MER_DISTANCE 15 diff --git a/src/map/mob.c b/src/map/mob.c index 11ac74621..8f12d4b1b 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -2,49 +2,46 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "../config/core.h" // AUTOLOOT_DISTANCE, DBPATH, DEFTYPE_MAX, DEFTYPE_MIN, RENEWAL_DROP, RENEWAL_EXP -#include "mob.h" - -#include <math.h> -#include <stdarg.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> +#include "../common/cbasetypes.h" +#include "../common/timer.h" +#include "../common/db.h" +#include "../common/nullpo.h" +#include "../common/malloc.h" +#include "../common/showmsg.h" +#include "../common/ers.h" +#include "../common/random.h" +#include "../common/strlib.h" +#include "../common/utils.h" +#include "../common/socket.h" -#include "atcommand.h" -#include "battle.h" +#include "map.h" +#include "path.h" #include "clif.h" -#include "date.h" +#include "intif.h" +#include "pc.h" +#include "pet.h" +#include "status.h" +#include "mob.h" +#include "homunculus.h" +#include "mercenary.h" #include "elemental.h" #include "guild.h" -#include "homunculus.h" -#include "intif.h" #include "itemdb.h" -#include "log.h" -#include "map.h" -#include "mercenary.h" -#include "npc.h" +#include "skill.h" +#include "battle.h" #include "party.h" -#include "path.h" -#include "pc.h" -#include "pet.h" -#include "quest.h" +#include "npc.h" +#include "log.h" #include "script.h" -#include "skill.h" -#include "status.h" -#include "../common/cbasetypes.h" -#include "../common/db.h" -#include "../common/ers.h" -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/strlib.h" -#include "../common/timer.h" -#include "../common/utils.h" +#include "atcommand.h" +#include "date.h" +#include "quest.h" + +#include <stdio.h> +#include <stdlib.h> +#include <stdarg.h> +#include <string.h> +#include <math.h> struct mob_interface mob_s; diff --git a/src/map/mob.h b/src/map/mob.h index d07f78c77..80175b1db 100644 --- a/src/map/mob.h +++ b/src/map/mob.h @@ -5,11 +5,12 @@ #ifndef _MAP_MOB_H_ #define _MAP_MOB_H_ -#include "map.h" // struct status_data, struct view_data, struct mob_skill -#include "status.h" // struct status_data, struct status_change -#include "unit.h" // struct unit_data -#include "../common/cbasetypes.h" #include "../common/mmo.h" // struct item +#include "guild.h" // struct guardian_data +#include "map.h" // struct status_data, struct view_data, struct mob_skill +#include "status.h" // struct status data, struct status_change +#include "unit.h" // unit_stop_walking(), unit_stop_attack() +#include "npc.h" #define MAX_RANDOMMONSTER 5 diff --git a/src/map/npc.c b/src/map/npc.c index 8e5854dbf..20b500630 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -2,44 +2,41 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "../config/core.h" // NPC_SECURE_TIMEOUT_INPUT, NPC_SECURE_TIMEOUT_MENU, NPC_SECURE_TIMEOUT_NEXT, SECURE_NPCTIMEOUT, SECURE_NPCTIMEOUT_INTERVAL -#include "npc.h" - -#include <errno.h> -#include <math.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <time.h> +#include "../common/cbasetypes.h" +#include "../common/timer.h" +#include "../common/nullpo.h" +#include "../common/malloc.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" +#include "../common/utils.h" +#include "../common/ers.h" +#include "../common/db.h" +#include "../common/socket.h" +#include "../common/HPM.h" -#include "battle.h" -#include "chat.h" +#include "map.h" +#include "log.h" #include "clif.h" -#include "instance.h" #include "intif.h" +#include "pc.h" +#include "status.h" #include "itemdb.h" -#include "log.h" -#include "map.h" +#include "script.h" #include "mob.h" -#include "pc.h" #include "pet.h" -#include "script.h" +#include "instance.h" +#include "battle.h" #include "skill.h" -#include "status.h" #include "unit.h" -#include "../common/HPM.h" -#include "../common/cbasetypes.h" -#include "../common/db.h" -#include "../common/ers.h" -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/strlib.h" -#include "../common/timer.h" -#include "../common/utils.h" +#include "npc.h" +#include "chat.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <math.h> +#include <time.h> +#include <errno.h> struct npc_interface npc_s; diff --git a/src/map/npc.h b/src/map/npc.h index 6e9686d33..c154b14d0 100644 --- a/src/map/npc.h +++ b/src/map/npc.h @@ -8,10 +8,10 @@ #include "map.h" // struct block_list #include "status.h" // struct status_change #include "unit.h" // struct unit_data -#include "../common/cbasetypes.h" -#include "../common/db.h" struct HPluginData; +struct block_list; +struct npc_data; struct view_data; enum npc_parse_options { diff --git a/src/map/npc_chat.c b/src/map/npc_chat.c index f245ffea5..9d5639efc 100644 --- a/src/map/npc_chat.c +++ b/src/map/npc_chat.c @@ -2,27 +2,25 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - #ifdef PCRE_SUPPORT +#include "../common/timer.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" + +#include "mob.h" // struct mob_data #include "npc.h" // struct npc_data +#include "pc.h" // struct map_session_data +#include "script.h" // set_var() + +#include "../../3rdparty/pcre/include/pcre.h" -#include <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <string.h> - -#include "../../3rdparty/pcre/include/pcre.h" - -#include "mob.h" // struct mob_data -#include "pc.h" // struct map_session_data -#include "script.h" // set_var() -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/timer.h" +#include <stdarg.h> /** * interface sources diff --git a/src/map/party.c b/src/map/party.c index 7c49e241c..cf5e7bbe3 100644 --- a/src/map/party.c +++ b/src/map/party.c @@ -2,37 +2,34 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE +#include "../common/cbasetypes.h" +#include "../common/timer.h" +#include "../common/socket.h" // last_tick +#include "../common/nullpo.h" +#include "../common/malloc.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/utils.h" +#include "../common/strlib.h" +#include "../common/HPM.h" -#include "../config/core.h" // GP_BOUND_ITEMS, RENEWAL_EXP #include "party.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - #include "atcommand.h" //msg_txt() -#include "battle.h" -#include "clif.h" +#include "pc.h" +#include "map.h" #include "instance.h" +#include "battle.h" #include "intif.h" -#include "itemdb.h" +#include "clif.h" #include "log.h" -#include "map.h" -#include "mob.h" // struct mob_data -#include "pc.h" #include "skill.h" #include "status.h" -#include "../common/HPM.h" -#include "../common/cbasetypes.h" -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/socket.h" // last_tick -#include "../common/strlib.h" -#include "../common/timer.h" -#include "../common/utils.h" +#include "itemdb.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + struct party_interface party_s; diff --git a/src/map/party.h b/src/map/party.h index 3bad22b13..ed8289af6 100644 --- a/src/map/party.h +++ b/src/map/party.h @@ -5,12 +5,11 @@ #ifndef _MAP_PARTY_H_ #define _MAP_PARTY_H_ +#include "../common/mmo.h" // struct party +#include "../config/core.h" #include <stdarg.h> -#include "map.h" // TBL_PC -#include "../common/cbasetypes.h" -#include "../common/db.h" -#include "../common/mmo.h" // struct party +#include "map.h" #define PARTY_BOOKING_JOBS 6 #define PARTY_BOOKING_RESULTS 10 diff --git a/src/map/path.c b/src/map/path.c index d02e9ee4a..ae9fc389d 100644 --- a/src/map/path.c +++ b/src/map/path.c @@ -2,16 +2,6 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "../config/core.h" // CELL_NOSTACK, CIRCULAR_AREA -#include "path.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "map.h" #include "../common/cbasetypes.h" #include "../common/db.h" #include "../common/malloc.h" @@ -19,6 +9,13 @@ #include "../common/random.h" #include "../common/showmsg.h" +#include "path.h" +#include "map.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + #define SET_OPEN 0 #define SET_CLOSED 1 diff --git a/src/map/path.h b/src/map/path.h index b48ff05fb..0b67a0120 100644 --- a/src/map/path.h +++ b/src/map/path.h @@ -6,7 +6,6 @@ #define _MAP_PATH_H_ #include "map.h" // enum cell_chk -#include "../common/cbasetypes.h" #define MOVE_COST 10 #define MOVE_DIAGONAL_COST 14 diff --git a/src/map/pc.c b/src/map/pc.c index 45adfe22a..c8fb14e55 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -2,16 +2,21 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE +#include "../common/cbasetypes.h" +#include "../common/core.h" // get_svn_revision() +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/socket.h" // session[] +#include "../common/strlib.h" // safestrncpy() +#include "../common/timer.h" +#include "../common/utils.h" +#include "../common/conf.h" +#include "../common/mmo.h" //NAME_LENGTH +#include "../common/sysinfo.h" -#include "../config/core.h" // DBPATH, GP_BOUND_ITEMS, MAX_CARTS, MAX_SPIRITBALL, NEW_CARTS, RENEWAL, RENEWAL_ASPD, RENEWAL_CAST, RENEWAL_DROP, RENEWAL_EXP, SECURE_NPCTIMEOUT #include "pc.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <time.h> - #include "atcommand.h" // get_atcommand_level() #include "battle.h" // battle_config #include "battleground.h" @@ -20,40 +25,32 @@ #include "clif.h" #include "date.h" // is_day_of_*() #include "duel.h" -#include "elemental.h" -#include "guild.h" // guild->search(), guild_request_info() -#include "homunculus.h" -#include "instance.h" #include "intif.h" #include "itemdb.h" #include "log.h" #include "mail.h" #include "map.h" +#include "path.h" +#include "homunculus.h" +#include "instance.h" #include "mercenary.h" -#include "mob.h" // struct mob_data +#include "elemental.h" #include "npc.h" // fake_nd -#include "party.h" // party->search() -#include "path.h" -#include "pc_groups.h" #include "pet.h" // pet_unlocktarget() -#include "quest.h" +#include "party.h" // party->search() +#include "guild.h" // guild->search(), guild_request_info() #include "script.h" // script_config #include "skill.h" #include "status.h" // struct status_data #include "storage.h" -#include "../common/cbasetypes.h" -#include "../common/conf.h" -#include "../common/core.h" // get_svn_revision() -#include "../common/malloc.h" -#include "../common/mmo.h" //NAME_LENGTH -#include "../common/nullpo.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/socket.h" // session[] -#include "../common/strlib.h" // safestrncpy() -#include "../common/sysinfo.h" -#include "../common/timer.h" -#include "../common/utils.h" +#include "pc_groups.h" +#include "quest.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <time.h> + struct pc_interface pc_s; @@ -10654,7 +10651,9 @@ void pc_defaults(void) { memset(pc->exp_table, 0, sizeof(pc->exp_table) + sizeof(pc->max_level) + sizeof(pc->statp) +#if defined(RENEWAL_DROP) || defined(RENEWAL_EXP) + sizeof(pc->level_penalty) +#endif + sizeof(pc->skill_tree) + sizeof(pc->smith_fame_list) + sizeof(pc->chemist_fame_list) diff --git a/src/map/pc.h b/src/map/pc.h index c4026a48d..70df9ca56 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -5,23 +5,23 @@ #ifndef _MAP_PC_H_ #define _MAP_PC_H_ -#include "../config/core.h" // AUTOLOOTITEM_SIZE, RENEWAL, SECURE_NPCTIMEOUT - +#include "../common/mmo.h" // JOB_*, MAX_FAME_LIST, struct fame_list, struct mmo_charstatus +#include "../common/ers.h" +#include "../common/timer.h" // INVALID_TIMER +#include "atcommand.h" // AtCommandType #include "battle.h" // battle_config -#include "battleground.h" // enum bg_queue_types +#include "battleground.h" #include "buyingstore.h" // struct s_buyingstore -#include "itemdb.h" // MAX_ITEMDELAYS -#include "log.h" // struct e_log_pick_type -#include "map.h" // RC_MAX, ELE_MAX -#include "pc_groups.h" // GroupSettings -#include "script.h" // struct reg_db +#include "itemdb.h" +#include "log.h" +#include "map.h" // RC_MAX +#include "mob.h" +#include "pc_groups.h" +#include "script.h" // struct script_reg, struct script_regstr #include "searchstore.h" // struct s_search_store_info -#include "status.h" // enum sc_type, OPTION_* -#include "unit.h" // struct unit_data, struct view_data +#include "status.h" // OPTION_*, struct weapon_atk +#include "unit.h" // unit_stop_attack(), unit_stop_walking() #include "vending.h" // struct s_vending -#include "../common/cbasetypes.h" -#include "../common/ers.h" // struct eri -#include "../common/mmo.h" // JOB_*, MAX_FAME_LIST, struct fame_list, struct mmo_charstatus /** * Defines @@ -742,8 +742,9 @@ struct pc_interface { unsigned int exp_table[CLASS_COUNT][2][MAX_LEVEL]; unsigned int max_level[CLASS_COUNT][2]; unsigned int statp[MAX_LEVEL+1]; +#if defined(RENEWAL_DROP) || defined(RENEWAL_EXP) unsigned int level_penalty[3][RC_MAX][MAX_LEVEL*2+1]; - +#endif unsigned int equip_pos[EQI_MAX]; /* */ struct skill_tree_entry skill_tree[CLASS_COUNT][MAX_SKILL_TREE]; diff --git a/src/map/pc_groups.c b/src/map/pc_groups.c index a917ef409..906462c7e 100644 --- a/src/map/pc_groups.c +++ b/src/map/pc_groups.c @@ -2,14 +2,6 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "pc_groups.h" - -#include "atcommand.h" // atcommand->exists(), atcommand->load_groups() -#include "clif.h" // clif->GM_kick() -#include "map.h" // mapiterator -#include "pc.h" // pc->set_group() #include "../common/cbasetypes.h" #include "../common/conf.h" #include "../common/db.h" @@ -18,6 +10,12 @@ #include "../common/showmsg.h" #include "../common/strlib.h" // strcmp +#include "pc_groups.h" +#include "atcommand.h" // atcommand->exists(), atcommand->load_groups() +#include "clif.h" // clif->GM_kick() +#include "map.h" // mapiterator +#include "pc.h" // pc->set_group() + static GroupSettings dummy_group; ///< dummy group used in dummy map sessions @see pc_get_dummy_sd() struct pc_groups_interface pcg_s; diff --git a/src/map/pc_groups.h b/src/map/pc_groups.h index 7c8cdd82a..5c03f999f 100644 --- a/src/map/pc_groups.h +++ b/src/map/pc_groups.h @@ -5,10 +5,6 @@ #ifndef _MAP_PC_GROUPS_H_ #define _MAP_PC_GROUPS_H_ -#include "../common/cbasetypes.h" -#include "../common/conf.h" -#include "../common/db.h" - /// PC permissions enum e_pc_permission { PC_PERM_NONE = 0, // #0 diff --git a/src/map/pet.c b/src/map/pet.c index aa2be4473..993497434 100644 --- a/src/map/pet.c +++ b/src/map/pet.c @@ -2,39 +2,37 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "pet.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> +#include "../common/db.h" +#include "../common/timer.h" +#include "../common/nullpo.h" +#include "../common/malloc.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" +#include "../common/utils.h" +#include "../common/ers.h" -#include "atcommand.h" // msg_txt() -#include "battle.h" -#include "chrif.h" -#include "clif.h" +#include "pc.h" +#include "status.h" +#include "map.h" +#include "path.h" #include "intif.h" +#include "clif.h" +#include "chrif.h" +#include "pet.h" #include "itemdb.h" -#include "log.h" -#include "map.h" +#include "battle.h" #include "mob.h" #include "npc.h" -#include "path.h" -#include "pc.h" #include "script.h" #include "skill.h" -#include "status.h" #include "unit.h" -#include "../common/db.h" -#include "../common/ers.h" -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/timer.h" -#include "../common/utils.h" +#include "atcommand.h" // msg_txt() +#include "log.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> struct pet_interface pet_s; diff --git a/src/map/pet.h b/src/map/pet.h index 8dde0fac2..4ec30b3fb 100644 --- a/src/map/pet.h +++ b/src/map/pet.h @@ -5,14 +5,8 @@ #ifndef _MAP_PET_H_ #define _MAP_PET_H_ -#include "map.h" // struct block_list -#include "status.h" // enum sc_type -#include "unit.h" // struct unit_data -#include "../common/cbasetypes.h" -#include "../common/mmo.h" // NAME_LENGTH, struct s_pet - -#define MAX_PET_DB 300 -#define MAX_PETLOOT_SIZE 30 +#define MAX_PET_DB 300 +#define MAX_PETLOOT_SIZE 30 struct s_pet_db { short class_; diff --git a/src/map/quest.c b/src/map/quest.c index b76d6bc82..bde276f9d 100644 --- a/src/map/quest.c +++ b/src/map/quest.c @@ -2,37 +2,36 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE +#include "../common/cbasetypes.h" +#include "../common/socket.h" +#include "../common/timer.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" +#include "../common/utils.h" +#include "map.h" +#include "pc.h" +#include "npc.h" +#include "itemdb.h" +#include "script.h" +#include "intif.h" +#include "battle.h" +#include "mob.h" +#include "party.h" +#include "unit.h" +#include "log.h" +#include "clif.h" #include "quest.h" +#include "chrif.h" -#include <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <stdarg.h> #include <time.h> -#include "battle.h" -#include "chrif.h" -#include "clif.h" -#include "intif.h" -#include "itemdb.h" -#include "log.h" -#include "map.h" -#include "mob.h" -#include "npc.h" -#include "party.h" -#include "pc.h" -#include "script.h" -#include "unit.h" -#include "../common/cbasetypes.h" -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/strlib.h" -#include "../common/timer.h" -#include "../common/utils.h" struct quest_interface quest_s; diff --git a/src/map/quest.h b/src/map/quest.h index 87894d639..e01e35619 100644 --- a/src/map/quest.h +++ b/src/map/quest.h @@ -5,10 +5,6 @@ #ifndef _MAP_QUEST_H_ #define _MAP_QUEST_H_ -#include "map.h" // TBL_PC -#include "../common/cbasetypes.h" -#include "../common/mmo.h" // MAX_QUEST_OBJECTIVES - #define MAX_QUEST_DB (60355+1) // Highest quest ID + 1 struct quest_db { diff --git a/src/map/script.c b/src/map/script.c index 068be8524..4d77c506b 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -2,46 +2,6 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "../config/core.h" // NEW_CARTS, RENEWAL, RENEWAL_ASPD, RENEWAL_CAST, RENEWAL_DROP, RENEWAL_EDP, RENEWAL_EXP, RENEWAL_LVDMG, SCRIPT_CALLFUNC_CHECK, SECURE_NPCTIMEOUT, SECURE_NPCTIMEOUT_INTERVAL -#include "script.h" - -#include <math.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "atcommand.h" -#include "battle.h" -#include "battleground.h" -#include "chat.h" -#include "chrif.h" -#include "clif.h" -#include "elemental.h" -#include "guild.h" -#include "homunculus.h" -#include "instance.h" -#include "intif.h" -#include "itemdb.h" -#include "log.h" -#include "mail.h" -#include "map.h" -#include "mapreg.h" -#include "mercenary.h" -#include "mob.h" -#include "npc.h" -#include "party.h" -#include "path.h" -#include "pc.h" -#include "pet.h" -#include "pet.h" -#include "quest.h" -#include "skill.h" -#include "status.h" -#include "status.h" -#include "storage.h" -#include "unit.h" #include "../common/cbasetypes.h" #include "../common/malloc.h" #include "../common/md5calc.h" @@ -50,10 +10,47 @@ #include "../common/showmsg.h" #include "../common/socket.h" // usage: getcharip #include "../common/strlib.h" -#include "../common/sysinfo.h" #include "../common/timer.h" #include "../common/utils.h" +#include "../common/sysinfo.h" + +#include "map.h" +#include "path.h" +#include "clif.h" +#include "chrif.h" +#include "itemdb.h" +#include "pc.h" +#include "status.h" +#include "storage.h" +#include "mob.h" +#include "npc.h" +#include "pet.h" +#include "mapreg.h" +#include "homunculus.h" +#include "instance.h" +#include "mercenary.h" +#include "intif.h" +#include "skill.h" +#include "status.h" +#include "chat.h" +#include "battle.h" +#include "battleground.h" +#include "party.h" +#include "guild.h" +#include "atcommand.h" +#include "log.h" +#include "unit.h" +#include "pet.h" +#include "mail.h" +#include "script.h" +#include "quest.h" +#include "elemental.h" +#include "../config/core.h" +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <math.h> #ifndef WIN32 #include <sys/time.h> #endif diff --git a/src/map/script.h b/src/map/script.h index 899c745da..90b18d87f 100644 --- a/src/map/script.h +++ b/src/map/script.h @@ -5,19 +5,17 @@ #ifndef _MAP_SCRIPT_H_ #define _MAP_SCRIPT_H_ +#include "../common/strlib.h" //StringBuf +#include "../common/cbasetypes.h" +#include "map.h" //EVENT_NAME_LENGTH + #include <setjmp.h> #include <errno.h> -#include "map.h" //EVENT_NAME_LENGTH -#include "../common/cbasetypes.h" -#include "../common/db.h" -#include "../common/mmo.h" // struct item -#include "../common/sql.h" // Sql -#include "../common/strlib.h" //StringBuf - /** * Declarations **/ +struct map_session_data; struct eri; /** diff --git a/src/map/searchstore.c b/src/map/searchstore.c index 72b28aacd..0144aea93 100644 --- a/src/map/searchstore.c +++ b/src/map/searchstore.c @@ -2,17 +2,14 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "searchstore.h" // struct s_search_store_info - -#include "battle.h" // battle_config.* -#include "clif.h" // clif->open_search_store_info, clif->search_store_info_* -#include "pc.h" // struct map_session_data #include "../common/cbasetypes.h" #include "../common/malloc.h" // aMalloc, aRealloc, aFree #include "../common/showmsg.h" // ShowError, ShowWarning #include "../common/strlib.h" // safestrncpy +#include "battle.h" // battle_config.* +#include "clif.h" // clif->open_search_store_info, clif->search_store_info_* +#include "pc.h" // struct map_session_data +#include "searchstore.h" // struct s_search_store_info struct searchstore_interface searchstore_s; diff --git a/src/map/searchstore.h b/src/map/searchstore.h index c9b93ba54..827e39053 100644 --- a/src/map/searchstore.h +++ b/src/map/searchstore.h @@ -5,12 +5,6 @@ #ifndef _MAP_SEARCHSTORE_H_ #define _MAP_SEARCHSTORE_H_ -#include <time.h> - -#include "map.h" // MESSAGE_SIZE -#include "../common/cbasetypes.h" -#include "../common/mmo.h" // MAX_SLOTS - /** * Defines **/ diff --git a/src/map/skill.c b/src/map/skill.c index b2e94ec79..c8388770a 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -2,48 +2,46 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "../config/core.h" // DBPATH, MAGIC_REFLECTION_TYPE, OFFICIAL_WALKPATH, RENEWAL, RENEWAL_CAST, VARCAST_REDUCTION() -#include "skill.h" - -#include <math.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <time.h> +#include "../common/cbasetypes.h" +#include "../common/timer.h" +#include "../common/nullpo.h" +#include "../common/malloc.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" +#include "../common/utils.h" +#include "../common/ers.h" -#include "battle.h" -#include "battleground.h" -#include "chrif.h" +#include "map.h" +#include "path.h" #include "clif.h" -#include "date.h" -#include "elemental.h" -#include "guild.h" +#include "pc.h" +#include "status.h" +#include "skill.h" +#include "pet.h" #include "homunculus.h" -#include "intif.h" -#include "itemdb.h" -#include "log.h" -#include "map.h" #include "mercenary.h" +#include "elemental.h" #include "mob.h" #include "npc.h" +#include "battle.h" +#include "battleground.h" #include "party.h" -#include "path.h" -#include "pc.h" -#include "pet.h" +#include "itemdb.h" #include "script.h" -#include "status.h" +#include "intif.h" +#include "log.h" +#include "chrif.h" +#include "guild.h" +#include "date.h" #include "unit.h" -#include "../common/cbasetypes.h" -#include "../common/ers.h" -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/timer.h" -#include "../common/utils.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <time.h> +#include <math.h> + #define SKILLUNITTIMER_INTERVAL 100 diff --git a/src/map/skill.h b/src/map/skill.h index b6dbb1fcb..dda310bd4 100644 --- a/src/map/skill.h +++ b/src/map/skill.h @@ -5,23 +5,19 @@ #ifndef _MAP_SKILL_H_ #define _MAP_SKILL_H_ -#include "../config/core.h" // RENEWAL_CAST - -#include "map.h" // struct block_list -#include "status.h" // enum sc_type -#include "../common/cbasetypes.h" -#include "../common/db.h" #include "../common/mmo.h" // MAX_SKILL, struct square +#include "../common/db.h" +#include "map.h" // struct block_list /** * Declarations **/ -struct homun_data; struct map_session_data; -struct mercenary_data; +struct homun_data; struct skill_unit; -struct square; +struct skill_unit_group; struct status_change_entry; +struct square; /** * Defines diff --git a/src/map/status.c b/src/map/status.c index eb06138da..4c2bc6d22 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -2,46 +2,43 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "../config/core.h" // ANTI_MAYAP_CHEAT, DBPATH, DEFTYPE_MAX, DEFTYPE_MIN, DEVOTION_REFLECT_DAMAGE, RENEWAL, RENEWAL_ASPD, RENEWAL_EDP -#include "status.h" - -#include <math.h> -#include <memory.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <time.h> +#include "../common/cbasetypes.h" +#include "../common/timer.h" +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/malloc.h" +#include "../common/utils.h" +#include "../common/ers.h" +#include "../common/strlib.h" -#include "battle.h" -#include "chrif.h" -#include "clif.h" -#include "elemental.h" -#include "guild.h" -#include "homunculus.h" -#include "itemdb.h" #include "map.h" -#include "mercenary.h" -#include "mob.h" -#include "npc.h" #include "path.h" #include "pc.h" #include "pet.h" -#include "script.h" +#include "npc.h" +#include "mob.h" +#include "clif.h" +#include "guild.h" #include "skill.h" +#include "itemdb.h" +#include "battle.h" +#include "chrif.h" #include "skill.h" +#include "status.h" +#include "script.h" #include "unit.h" +#include "homunculus.h" +#include "mercenary.h" +#include "elemental.h" #include "vending.h" -#include "../common/cbasetypes.h" -#include "../common/ers.h" -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/timer.h" -#include "../common/utils.h" + +#include <time.h> +#include <stdio.h> +#include <stdlib.h> +#include <memory.h> +#include <string.h> +#include <math.h> struct status_interface status_s; diff --git a/src/map/status.h b/src/map/status.h index baa586297..e47c2b365 100644 --- a/src/map/status.h +++ b/src/map/status.h @@ -5,18 +5,14 @@ #ifndef _MAP_STATUS_H_ #define _MAP_STATUS_H_ -#include "../config/core.h" // defType, NEW_CARTS, RENEWAL, RENEWAL_ASPD - -#include "../common/cbasetypes.h" #include "../common/mmo.h" struct block_list; -struct elemental_data; -struct homun_data; -struct mercenary_data; struct mob_data; -struct npc_data; struct pet_data; +struct homun_data; +struct mercenary_data; +struct status_change; //Change the equation when the values are high enough to discard the //imprecision in exchange of overflow protection [Skotlex] @@ -1882,7 +1878,11 @@ struct status_interface { int hp_coefficient2[CLASS_COUNT]; int hp_sigma_val[CLASS_COUNT][MAX_LEVEL+1]; int sp_coefficient[CLASS_COUNT]; - int aspd_base[CLASS_COUNT][MAX_WEAPON_TYPE+1]; // +1 for RENEWAL_ASPD +#ifdef RENEWAL_ASPD + int aspd_base[CLASS_COUNT][MAX_WEAPON_TYPE+1]; +#else + int aspd_base[CLASS_COUNT][MAX_WEAPON_TYPE]; //[blackhole89] +#endif sc_type Skill2SCTable[MAX_SKILL]; // skill -> status int IconChangeTable[SC_MAX]; // status -> "icon" (icon is a bit of a misnomer, since there exist values with no icon associated) unsigned int ChangeFlagTable[SC_MAX]; // status -> flags diff --git a/src/map/storage.c b/src/map/storage.c index 2db5fff3d..e65ed7b80 100644 --- a/src/map/storage.c +++ b/src/map/storage.c @@ -2,29 +2,27 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE +#include "../common/cbasetypes.h" +#include "../common/db.h" +#include "../common/nullpo.h" +#include "../common/malloc.h" +#include "../common/showmsg.h" +#include "map.h" // struct map_session_data #include "storage.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "atcommand.h" -#include "battle.h" #include "chrif.h" +#include "itemdb.h" #include "clif.h" -#include "guild.h" #include "intif.h" -#include "itemdb.h" -#include "log.h" -#include "map.h" // struct map_session_data #include "pc.h" -#include "../common/cbasetypes.h" -#include "../common/db.h" -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/showmsg.h" +#include "guild.h" +#include "battle.h" +#include "atcommand.h" +#include "log.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> struct storage_interface storage_s; struct guild_storage_interface gstorage_s; diff --git a/src/map/storage.h b/src/map/storage.h index 5edb68cfc..8f9f904f6 100644 --- a/src/map/storage.h +++ b/src/map/storage.h @@ -5,12 +5,11 @@ #ifndef _MAP_STORAGE_H_ #define _MAP_STORAGE_H_ -#include "../common/cbasetypes.h" -#include "../common/db.h" - +struct storage_data; struct guild_storage; struct item; struct map_session_data; +struct DBMap; struct storage_interface { /* */ diff --git a/src/map/trade.c b/src/map/trade.c index 83426c407..44b669ebd 100644 --- a/src/map/trade.c +++ b/src/map/trade.c @@ -2,27 +2,25 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE +#include "../common/nullpo.h" +#include "../common/socket.h" #include "trade.h" - -#include <stdio.h> -#include <string.h> - -#include "atcommand.h" -#include "battle.h" -#include "chrif.h" #include "clif.h" -#include "intif.h" #include "itemdb.h" -#include "log.h" #include "map.h" -#include "npc.h" #include "path.h" #include "pc.h" +#include "npc.h" +#include "battle.h" +#include "chrif.h" #include "storage.h" -#include "../common/nullpo.h" -#include "../common/socket.h" +#include "intif.h" +#include "atcommand.h" +#include "log.h" + +#include <stdio.h> +#include <string.h> struct trade_interface trade_s; diff --git a/src/map/unit.c b/src/map/unit.c index 0ad770e80..151d4bad5 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -2,48 +2,45 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "../config/core.h" // RENEWAL_CAST -#include "unit.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> +#include "../common/showmsg.h" +#include "../common/timer.h" +#include "../common/nullpo.h" +#include "../common/db.h" +#include "../common/malloc.h" +#include "../common/random.h" +#include "../common/HPM.h" -#include "battle.h" -#include "battleground.h" -#include "chat.h" -#include "chrif.h" -#include "clif.h" -#include "duel.h" -#include "elemental.h" -#include "guild.h" -#include "homunculus.h" -#include "instance.h" -#include "intif.h" #include "map.h" -#include "mercenary.h" -#include "mob.h" -#include "npc.h" -#include "party.h" #include "path.h" #include "pc.h" +#include "mob.h" #include "pet.h" -#include "script.h" +#include "homunculus.h" +#include "instance.h" +#include "mercenary.h" +#include "elemental.h" #include "skill.h" +#include "clif.h" +#include "duel.h" +#include "npc.h" +#include "guild.h" #include "status.h" -#include "storage.h" +#include "unit.h" +#include "battle.h" +#include "battleground.h" +#include "chat.h" #include "trade.h" #include "vending.h" -#include "../common/HPM.h" -#include "../common/db.h" -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/timer.h" +#include "party.h" +#include "intif.h" +#include "chrif.h" +#include "script.h" +#include "storage.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + const short dirx[8]={0,-1,-1,-1,0,1,1,1}; const short diry[8]={1,1,0,-1,-1,-1,0,1}; diff --git a/src/map/unit.h b/src/map/unit.h index 9e05647b1..33fa4e052 100644 --- a/src/map/unit.h +++ b/src/map/unit.h @@ -5,13 +5,15 @@ #ifndef _MAP_UNIT_H_ #define _MAP_UNIT_H_ +//#include "map.h" +struct block_list; +struct unit_data; +struct map_session_data; + #include "clif.h" // clr_type +#include "map.h" // struct block_list #include "path.h" // struct walkpath_data -#include "skill.h" // 'MAX_SKILLTIMERSKILL, struct skill_timerskill, struct skill_unit_group, struct skill_unit_group_tickset -#include "../common/cbasetypes.h" - -struct map_session_data; -struct block_list; +#include "skill.h" // struct skill_timerskill, struct skill_unit_group, struct skill_unit_group_tickset struct unit_data { struct block_list *bl; diff --git a/src/map/vending.c b/src/map/vending.c index c8ac814db..9462975b3 100644 --- a/src/map/vending.c +++ b/src/map/vending.c @@ -2,27 +2,24 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "vending.h" - -#include <stdio.h> -#include <string.h> - -#include "atcommand.h" -#include "battle.h" -#include "chrif.h" +#include "../common/nullpo.h" +#include "../common/strlib.h" +#include "../common/utils.h" #include "clif.h" #include "itemdb.h" -#include "log.h" +#include "atcommand.h" #include "map.h" -#include "npc.h" #include "path.h" +#include "chrif.h" +#include "vending.h" #include "pc.h" +#include "npc.h" #include "skill.h" -#include "../common/nullpo.h" -#include "../common/strlib.h" -#include "../common/utils.h" +#include "battle.h" +#include "log.h" + +#include <stdio.h> +#include <string.h> struct vending_interface vending_s; diff --git a/src/map/vending.h b/src/map/vending.h index a70726374..a212f8385 100644 --- a/src/map/vending.h +++ b/src/map/vending.h @@ -7,7 +7,6 @@ #include "../common/cbasetypes.h" #include "../common/db.h" - struct map_session_data; struct s_search_store_search; diff --git a/src/tool/mapcache.c b/src/tool/mapcache.c index 96d51aec6..85d5fb548 100644 --- a/src/tool/mapcache.c +++ b/src/tool/mapcache.c @@ -1,14 +1,6 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#define HERCULES_CORE - -#include "../config/core.h" // RENEWAL - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - #include "../common/cbasetypes.h" #include "../common/grfio.h" #include "../common/malloc.h" @@ -16,6 +8,12 @@ #include "../common/showmsg.h" #include "../common/utils.h" +#include "../config/renewal.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + #ifndef _WIN32 #include <unistd.h> #endif -- cgit v1.2.3-70-g09d2 From 0ab52ac65bdba93be94e4149e267698d31b41d72 Mon Sep 17 00:00:00 2001 From: Haru <haru@dotalux.com> Date: Sat, 10 May 2014 17:17:13 +0200 Subject: Re-commit of "Fixed order of includes in all source files" This reverts commit 94657284973f4037596bae468ebfbee5c217e02b. --- src/char/char.c | 44 +++++----- src/char/char.h | 1 - src/char/int_auction.c | 25 +++--- src/char/int_elemental.c | 22 +++-- src/char/int_elemental.h | 2 +- src/char/int_guild.c | 24 ++--- src/char/int_guild.h | 3 - src/char/int_homun.c | 21 +++-- src/char/int_homun.h | 2 + src/char/int_mail.c | 20 +++-- src/char/int_mail.h | 3 + src/char/int_mercenary.c | 22 +++-- src/char/int_mercenary.h | 4 +- src/char/int_party.c | 25 +++--- src/char/int_party.h | 2 - src/char/int_pet.c | 22 +++-- src/char/int_quest.c | 22 ++--- src/char/int_storage.c | 22 +++-- src/char/inter.c | 43 ++++----- src/char/inter.h | 5 +- src/char/pincode.c | 11 ++- src/common/HPM.c | 31 ++++--- src/common/HPM.h | 6 +- src/common/HPMi.h | 16 +--- src/common/cbasetypes.h | 6 ++ src/common/conf.c | 3 + src/common/conf.h | 1 + src/common/console.c | 223 ++++++++++++++++++++++++----------------------- src/common/console.h | 21 +++-- src/common/core.c | 38 ++++---- src/common/core.h | 3 +- src/common/db.c | 10 ++- src/common/db.h | 3 +- src/common/des.c | 7 +- src/common/ers.c | 8 +- src/common/grfio.c | 17 ++-- src/common/malloc.c | 11 ++- src/common/mapindex.c | 15 ++-- src/common/md5calc.c | 8 +- src/common/mmo.h | 6 +- src/common/mutex.c | 5 +- src/common/mutex.h | 1 + src/common/nullpo.c | 6 +- src/common/random.c | 18 ++-- src/common/showmsg.c | 17 ++-- src/common/showmsg.h | 23 +++-- src/common/socket.c | 64 +++++++------- src/common/socket.h | 12 +-- src/common/spinlock.h | 9 +- src/common/sql.c | 12 ++- src/common/sql.h | 3 +- src/common/strlib.c | 13 +-- src/common/strlib.h | 15 ++-- src/common/sysinfo.c | 32 +++++-- src/common/sysinfo.h | 16 ---- src/common/thread.c | 31 ++++--- src/common/thread.h | 1 - src/common/timer.c | 19 ++-- src/common/utils.c | 36 ++++---- src/common/utils.h | 3 +- src/config/const.h | 7 -- src/config/renewal.h | 1 + src/login/account.h | 1 + src/login/account_sql.c | 17 ++-- src/login/ipban_sql.c | 14 +-- src/login/login.c | 21 +++-- src/login/login.h | 2 +- src/login/loginlog.h | 2 +- src/login/loginlog_sql.c | 9 +- src/map/HPMmap.c | 42 ++++----- src/map/atcommand.c | 67 +++++++------- src/map/atcommand.h | 2 +- src/map/battle.c | 61 +++++++------ src/map/battle.h | 2 +- src/map/battleground.c | 33 +++---- src/map/battleground.h | 2 +- src/map/buyingstore.c | 17 ++-- src/map/buyingstore.h | 5 ++ src/map/chat.c | 23 ++--- src/map/chat.h | 5 +- src/map/chrif.c | 35 ++++---- src/map/chrif.h | 4 +- src/map/clif.c | 83 +++++++++--------- src/map/clif.h | 9 +- src/map/date.c | 6 +- src/map/date.h | 2 + src/map/duel.c | 10 ++- src/map/duel.h | 4 + src/map/elemental.c | 54 ++++++------ src/map/elemental.h | 1 + src/map/guild.c | 47 +++++----- src/map/guild.h | 16 +--- src/map/homunculus.c | 56 ++++++------ src/map/homunculus.h | 3 +- src/map/instance.c | 34 ++++---- src/map/instance.h | 3 + src/map/intif.c | 51 ++++++----- src/map/intif.h | 13 +-- src/map/irc-bot.c | 22 ++--- src/map/irc-bot.h | 2 + src/map/itemdb.c | 27 +++--- src/map/itemdb.h | 5 +- src/map/log.c | 23 ++--- src/map/log.h | 5 +- src/map/mail.c | 16 ++-- src/map/mail.h | 6 +- src/map/map.c | 96 ++++++++++---------- src/map/map.h | 9 +- src/map/mapreg_sql.c | 14 +-- src/map/mercenary.c | 54 ++++++------ src/map/mercenary.h | 1 + src/map/mob.c | 69 ++++++++------- src/map/mob.h | 9 +- src/map/npc.c | 57 ++++++------ src/map/npc.h | 4 +- src/map/npc_chat.c | 26 +++--- src/map/party.c | 43 ++++----- src/map/party.h | 7 +- src/map/path.c | 17 ++-- src/map/path.h | 1 + src/map/pc.c | 59 +++++++------ src/map/pc.h | 29 +++--- src/map/pc_groups.c | 14 +-- src/map/pc_groups.h | 4 + src/map/pet.c | 48 +++++----- src/map/pet.h | 10 ++- src/map/quest.c | 45 +++++----- src/map/quest.h | 4 + src/map/script.c | 79 +++++++++-------- src/map/script.h | 12 +-- src/map/searchstore.c | 11 ++- src/map/searchstore.h | 6 ++ src/map/skill.c | 64 +++++++------- src/map/skill.h | 14 +-- src/map/status.c | 59 +++++++------ src/map/status.h | 16 ++-- src/map/storage.c | 32 +++---- src/map/storage.h | 5 +- src/map/trade.c | 24 ++--- src/map/unit.c | 63 ++++++------- src/map/unit.h | 12 ++- src/map/vending.c | 27 +++--- src/map/vending.h | 1 + src/tool/mapcache.c | 14 +-- 144 files changed, 1676 insertions(+), 1367 deletions(-) (limited to 'src/map/elemental.c') diff --git a/src/char/char.c b/src/char/char.c index 77e393c0d..6c0902644 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -2,7 +2,30 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams +#define HERCULES_CORE + +#include "../config/core.h" // CONSOLE_INPUT +#include "char.h" + +#include <signal.h> +#include <stdarg.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/types.h> +#include <time.h> + +#include "int_elemental.h" +#include "int_guild.h" +#include "int_homun.h" +#include "int_mercenary.h" +#include "int_party.h" +#include "int_storage.h" +#include "inter.h" +#include "pincode.h" +#include "../common/HPM.h" #include "../common/cbasetypes.h" +#include "../common/console.h" #include "../common/core.h" #include "../common/db.h" #include "../common/malloc.h" @@ -13,25 +36,6 @@ #include "../common/strlib.h" #include "../common/timer.h" #include "../common/utils.h" -#include "../common/console.h" -#include "../common/HPM.h" -#include "int_guild.h" -#include "int_homun.h" -#include "int_mercenary.h" -#include "int_elemental.h" -#include "int_party.h" -#include "int_storage.h" -#include "char.h" -#include "inter.h" -#include "pincode.h" - -#include <sys/types.h> -#include <time.h> -#include <signal.h> -#include <string.h> -#include <stdarg.h> -#include <stdio.h> -#include <stdlib.h> // private declarations #define CHAR_CONF_NAME "conf/char-server.conf" @@ -5497,7 +5501,7 @@ int do_init(int argc, char **argv) { Sql_HerculesUpdateCheck(sql_handle); #ifdef CONSOLE_INPUT - console->setSQL(sql_handle); + console->input->setSQL(sql_handle); #endif ShowStatus("The char-server is "CL_GREEN"ready"CL_RESET" (Server is listening on the port %d).\n\n", char_port); diff --git a/src/char/char.h b/src/char/char.h index 2928929de..09a78f6b9 100644 --- a/src/char/char.h +++ b/src/char/char.h @@ -5,7 +5,6 @@ #ifndef _COMMON_CHAR_H_ #define _COMMON_CHAR_H_ -#include "../config/core.h" #include "../common/core.h" // CORE_ST_LAST #include "../common/db.h" diff --git a/src/char/int_auction.c b/src/char/int_auction.c index 924930867..886b5be26 100644 --- a/src/char/int_auction.c +++ b/src/char/int_auction.c @@ -2,22 +2,25 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/mmo.h" -#include "../common/malloc.h" +#define HERCULES_CORE + +#include "int_auction.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "char.h" +#include "int_mail.h" +#include "inter.h" #include "../common/db.h" +#include "../common/malloc.h" +#include "../common/mmo.h" #include "../common/showmsg.h" #include "../common/socket.h" -#include "../common/strlib.h" #include "../common/sql.h" +#include "../common/strlib.h" #include "../common/timer.h" -#include "char.h" -#include "inter.h" -#include "int_mail.h" -#include "int_auction.h" - -#include <stdio.h> -#include <string.h> -#include <stdlib.h> static DBMap* auction_db_ = NULL; // int auction_id -> struct auction_data* diff --git a/src/char/int_elemental.c b/src/char/int_elemental.c index ed0c2a9ed..3a36e75a2 100644 --- a/src/char/int_elemental.c +++ b/src/char/int_elemental.c @@ -2,20 +2,24 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/mmo.h" -#include "../common/malloc.h" -#include "../common/strlib.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/utils.h" -#include "../common/sql.h" -#include "char.h" -#include "inter.h" +#define HERCULES_CORE + +#include "int_elemental.h" #include <stdio.h> #include <stdlib.h> #include <string.h> +#include "char.h" +#include "inter.h" +#include "../common/malloc.h" +#include "../common/mmo.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/sql.h" +#include "../common/strlib.h" +#include "../common/utils.h" + bool mapif_elemental_save(struct s_elemental* ele) { bool flag = true; diff --git a/src/char/int_elemental.h b/src/char/int_elemental.h index c90891fc4..c869e6fc2 100644 --- a/src/char/int_elemental.h +++ b/src/char/int_elemental.h @@ -4,7 +4,7 @@ #ifndef _CHAR_INT_ELEMENTAL_H_ #define _CHAR_INT_ELEMENTAL_H_ -struct s_elemental; +#include "../common/cbasetypes.h" void inter_elemental_sql_init(void); void inter_elemental_sql_final(void); diff --git a/src/char/int_guild.c b/src/char/int_guild.c index 895cbbb94..ffbe48e10 100644 --- a/src/char/int_guild.c +++ b/src/char/int_guild.c @@ -2,21 +2,25 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams +#define HERCULES_CORE + +#include "../config/core.h" // DBPATH +#include "int_guild.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "char.h" +#include "inter.h" #include "../common/cbasetypes.h" -#include "../common/mmo.h" -#include "../common/malloc.h" -#include "../common/socket.h" #include "../common/db.h" +#include "../common/malloc.h" +#include "../common/mmo.h" #include "../common/showmsg.h" +#include "../common/socket.h" #include "../common/strlib.h" #include "../common/timer.h" -#include "char.h" -#include "inter.h" -#include "int_guild.h" - -#include <string.h> -#include <stdio.h> -#include <stdlib.h> #define GS_MEMBER_UNMODIFIED 0x00 #define GS_MEMBER_MODIFIED 0x01 diff --git a/src/char/int_guild.h b/src/char/int_guild.h index 4eb7d310b..5e657ff06 100644 --- a/src/char/int_guild.h +++ b/src/char/int_guild.h @@ -20,9 +20,6 @@ enum { GS_REMOVE = 0x8000, }; -struct guild; -struct guild_castle; - int inter_guild_parse_frommap(int fd); int inter_guild_sql_init(void); void inter_guild_sql_final(void); diff --git a/src/char/int_homun.c b/src/char/int_homun.c index 143277f05..795a6b927 100644 --- a/src/char/int_homun.c +++ b/src/char/int_homun.c @@ -2,20 +2,23 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/mmo.h" -#include "../common/malloc.h" -#include "../common/strlib.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/utils.h" -#include "../common/sql.h" -#include "char.h" -#include "inter.h" +#define HERCULES_CORE + +#include "int_homun.h" #include <stdio.h> #include <stdlib.h> #include <string.h> +#include "char.h" +#include "inter.h" +#include "../common/malloc.h" +#include "../common/mmo.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/sql.h" +#include "../common/strlib.h" +#include "../common/utils.h" int inter_homunculus_sql_init(void) { diff --git a/src/char/int_homun.h b/src/char/int_homun.h index 561dc848f..9477f4f03 100644 --- a/src/char/int_homun.h +++ b/src/char/int_homun.h @@ -4,6 +4,8 @@ #ifndef _CHAR_INT_HOMUN_H_ #define _CHAR_INT_HOMUN_H_ +#include "../common/cbasetypes.h" + struct s_homunculus; int inter_homunculus_sql_init(void); diff --git a/src/char/int_mail.c b/src/char/int_mail.c index 826771676..86a36d59f 100644 --- a/src/char/int_mail.c +++ b/src/char/int_mail.c @@ -2,19 +2,23 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/mmo.h" +#define HERCULES_CORE + +#include "int_mail.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "char.h" +#include "inter.h" #include "../common/malloc.h" +#include "../common/mmo.h" #include "../common/showmsg.h" #include "../common/socket.h" -#include "../common/strlib.h" #include "../common/sql.h" +#include "../common/strlib.h" #include "../common/timer.h" -#include "char.h" -#include "inter.h" - -#include <stdio.h> -#include <string.h> -#include <stdlib.h> static int mail_fromsql(int char_id, struct mail_data* md) { diff --git a/src/char/int_mail.h b/src/char/int_mail.h index 7c06cdc1f..824ba48a3 100644 --- a/src/char/int_mail.h +++ b/src/char/int_mail.h @@ -4,6 +4,9 @@ #ifndef _CHAR_INT_MAIL_H_ #define _CHAR_INT_MAIL_H_ +struct item; +struct mail_message; + int inter_mail_parse_frommap(int fd); void mail_sendmail(int send_id, const char* send_name, int dest_id, const char* dest_name, const char* title, const char* body, int zeny, struct item *item); diff --git a/src/char/int_mercenary.c b/src/char/int_mercenary.c index aecb3844a..1dffb656c 100644 --- a/src/char/int_mercenary.c +++ b/src/char/int_mercenary.c @@ -2,20 +2,24 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/mmo.h" -#include "../common/malloc.h" -#include "../common/strlib.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/utils.h" -#include "../common/sql.h" -#include "char.h" -#include "inter.h" +#define HERCULES_CORE + +#include "int_mercenary.h" #include <stdio.h> #include <stdlib.h> #include <string.h> +#include "char.h" +#include "inter.h" +#include "../common/malloc.h" +#include "../common/mmo.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/sql.h" +#include "../common/strlib.h" +#include "../common/utils.h" + bool mercenary_owner_fromsql(int char_id, struct mmo_charstatus *status) { char* data; diff --git a/src/char/int_mercenary.h b/src/char/int_mercenary.h index b614b8cf7..195a83b34 100644 --- a/src/char/int_mercenary.h +++ b/src/char/int_mercenary.h @@ -4,7 +4,9 @@ #ifndef _CHAR_INT_MERCENARY_H_ #define _CHAR_INT_MERCENARY_H_ -struct s_mercenary; +#include "../common/cbasetypes.h" + +struct mmo_charstatus; int inter_mercenary_sql_init(void); void inter_mercenary_sql_final(void); diff --git a/src/char/int_party.c b/src/char/int_party.c index 7c328c452..3e4a743d6 100644 --- a/src/char/int_party.c +++ b/src/char/int_party.c @@ -2,23 +2,26 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/mmo.h" -#include "../common/db.h" -#include "../common/malloc.h" -#include "../common/strlib.h" -#include "../common/socket.h" -#include "../common/showmsg.h" -#include "../common/mapindex.h" -#include "../common/sql.h" -#include "char.h" -#include "inter.h" +#define HERCULES_CORE + #include "int_party.h" #include <stdio.h> #include <stdlib.h> #include <string.h> +#include "char.h" +#include "inter.h" +#include "../common/cbasetypes.h" +#include "../common/db.h" +#include "../common/malloc.h" +#include "../common/mapindex.h" +#include "../common/mmo.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/sql.h" +#include "../common/strlib.h" + struct party_data { struct party party; unsigned int min_lv, max_lv; diff --git a/src/char/int_party.h b/src/char/int_party.h index 84f00635a..098c1e9a9 100644 --- a/src/char/int_party.h +++ b/src/char/int_party.h @@ -14,8 +14,6 @@ enum { PS_BREAK = 0x20, //Specify that this party must be deleted. }; -struct party; - int inter_party_parse_frommap(int fd); int inter_party_sql_init(void); void inter_party_sql_final(void); diff --git a/src/char/int_pet.c b/src/char/int_pet.c index 25f00e6f0..29c40eff9 100644 --- a/src/char/int_pet.c +++ b/src/char/int_pet.c @@ -2,20 +2,24 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/mmo.h" -#include "../common/malloc.h" -#include "../common/socket.h" -#include "../common/strlib.h" -#include "../common/showmsg.h" -#include "../common/utils.h" -#include "../common/sql.h" -#include "char.h" -#include "inter.h" +#define HERCULES_CORE + +#include "int_pet.h" #include <stdio.h> #include <stdlib.h> #include <string.h> +#include "char.h" +#include "inter.h" +#include "../common/malloc.h" +#include "../common/mmo.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/sql.h" +#include "../common/strlib.h" +#include "../common/utils.h" + struct s_pet *pet_pt; //--------------------------------------------------------- diff --git a/src/char/int_quest.c b/src/char/int_quest.c index 061dd89d9..61b43c57d 100644 --- a/src/char/int_quest.c +++ b/src/char/int_quest.c @@ -2,23 +2,25 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/mmo.h" +#define HERCULES_CORE + +#include "int_quest.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "char.h" +#include "inter.h" #include "../common/db.h" #include "../common/malloc.h" +#include "../common/mmo.h" #include "../common/showmsg.h" #include "../common/socket.h" -#include "../common/strlib.h" #include "../common/sql.h" +#include "../common/strlib.h" #include "../common/timer.h" -#include "char.h" -#include "inter.h" -#include "int_quest.h" - -#include <stdio.h> -#include <string.h> -#include <stdlib.h> - /** * Loads the entire questlog for a character. * diff --git a/src/char/int_storage.c b/src/char/int_storage.c index 966e61bb3..bf7b76da0 100644 --- a/src/char/int_storage.c +++ b/src/char/int_storage.c @@ -2,19 +2,23 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/mmo.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/strlib.h" // StringBuf -#include "../common/sql.h" -#include "char.h" -#include "inter.h" +#define HERCULES_CORE + +#include "../config/core.h" // GP_BOUND_ITEMS +#include "int_storage.h" #include <stdio.h> -#include <string.h> #include <stdlib.h> +#include <string.h> +#include "char.h" +#include "inter.h" +#include "../common/malloc.h" +#include "../common/mmo.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/sql.h" +#include "../common/strlib.h" // StringBuf #define STORAGE_MEMINC 16 diff --git a/src/char/inter.c b/src/char/inter.c index 515ca0ec4..972407ef3 100644 --- a/src/char/inter.c +++ b/src/char/inter.c @@ -2,33 +2,34 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/mmo.h" -#include "../common/db.h" -#include "../common/malloc.h" -#include "../common/strlib.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/timer.h" -#include "char.h" +#define HERCULES_CORE + #include "inter.h" -#include "int_party.h" -#include "int_guild.h" -#include "int_storage.h" -#include "int_pet.h" -#include "int_homun.h" -#include "int_mercenary.h" -#include "int_mail.h" -#include "int_auction.h" -#include "int_quest.h" -#include "int_elemental.h" +#include <errno.h> #include <stdio.h> -#include <string.h> #include <stdlib.h> -#include <errno.h> - +#include <string.h> #include <sys/stat.h> // for stat/lstat/fstat - [Dekamaster/Ultimate GM Tool] +#include "char.h" +#include "int_auction.h" +#include "int_elemental.h" +#include "int_guild.h" +#include "int_homun.h" +#include "int_mail.h" +#include "int_mercenary.h" +#include "int_party.h" +#include "int_pet.h" +#include "int_quest.h" +#include "int_storage.h" +#include "../common/db.h" +#include "../common/malloc.h" +#include "../common/mmo.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/timer.h" #define WISDATA_TTL (60*1000) //Wis data Time To Live (60 seconds) #define WISDELLIST_MAX 256 // Number of elements in the list Delete data Wis diff --git a/src/char/inter.h b/src/char/inter.h index 25b0c2a96..5e655237e 100644 --- a/src/char/inter.h +++ b/src/char/inter.h @@ -5,9 +5,10 @@ #ifndef _CHAR_INTER_H_ #define _CHAR_INTER_H_ -struct accreg; -#include "../common/sql.h" #include "char.h" +#include "../common/sql.h" + +struct accreg; int inter_init_sql(const char *file); void inter_final(void); diff --git a/src/char/pincode.c b/src/char/pincode.c index d51953448..59182f12d 100644 --- a/src/char/pincode.c +++ b/src/char/pincode.c @@ -2,16 +2,19 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams +#define HERCULES_CORE + +#include "pincode.h" + +#include <stdlib.h> + +#include "char.h" #include "../common/cbasetypes.h" #include "../common/mmo.h" #include "../common/random.h" #include "../common/showmsg.h" #include "../common/socket.h" #include "../common/strlib.h" -#include "char.h" -#include "pincode.h" - -#include <stdlib.h> int enabled = PINCODE_OK; int changetime = 0; diff --git a/src/common/HPM.c b/src/common/HPM.c index 9ffce87de..00b92dc60 100644 --- a/src/common/HPM.c +++ b/src/common/HPM.c @@ -1,26 +1,31 @@ // Copyright (c) Hercules Dev Team, licensed under GNU GPL. // See the LICENSE file +#define HERCULES_CORE + +#include "../config/core.h" // CONSOLE_INPUT +#include "HPM.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + #include "../common/cbasetypes.h" -#include "../common/mmo.h" +#include "../common/conf.h" +#include "../common/console.h" #include "../common/core.h" #include "../common/malloc.h" +#include "../common/mmo.h" #include "../common/showmsg.h" #include "../common/socket.h" -#include "../common/timer.h" -#include "../common/conf.h" -#include "../common/utils.h" -#include "../common/console.h" -#include "../common/strlib.h" #include "../common/sql.h" +#include "../common/strlib.h" #include "../common/sysinfo.h" -#include "HPM.h" +#include "../common/timer.h" +#include "../common/utils.h" -#include <stdio.h> -#include <stdlib.h> -#include <string.h> #ifndef WIN32 -#include <unistd.h> +# include <unistd.h> #endif struct malloc_interface iMalloc_HPM; @@ -686,7 +691,7 @@ bool hplugins_parse_conf(const char *w1, const char *w2, enum HPluginConfType po void hplugins_share_defaults(void) { /* console */ #ifdef CONSOLE_INPUT - HPM->share(console->addCommand,"addCPCommand"); + HPM->share(console->input->addCommand,"addCPCommand"); #endif /* our own */ HPM->share(hplugins_addpacket,"addPacket"); @@ -755,7 +760,7 @@ void hpm_init(void) { HPM->symbol_defaults(); #ifdef CONSOLE_INPUT - console->addCommand("plugins",CPCMD_A(plugins)); + console->input->addCommand("plugins",CPCMD_A(plugins)); #endif return; } diff --git a/src/common/HPM.h b/src/common/HPM.h index 0f0df4cda..9c176cfd6 100644 --- a/src/common/HPM.h +++ b/src/common/HPM.h @@ -4,8 +4,12 @@ #ifndef _COMMON_HPM_H_ #define _COMMON_HPM_H_ -#include "../common/cbasetypes.h" +#ifndef HERCULES_CORE +#error You should never include HPM.h from a plugin. +#endif + #include "../common/HPMi.h" +#include "../common/cbasetypes.h" #ifdef WIN32 #ifndef WIN32_LEAN_AND_MEAN diff --git a/src/common/HPMi.h b/src/common/HPMi.h index 19206aeca..b98e87d90 100644 --- a/src/common/HPMi.h +++ b/src/common/HPMi.h @@ -5,8 +5,8 @@ #define _COMMON_HPMI_H_ #include "../common/cbasetypes.h" -#include "../common/core.h" #include "../common/console.h" +#include "../common/core.h" #include "../common/sql.h" struct script_state; @@ -20,18 +20,6 @@ struct map_session_data; #define HPExport #endif -#ifndef _COMMON_SHOWMSG_H_ - HPExport void (*ShowMessage) (const char *, ...); - HPExport void (*ShowStatus) (const char *, ...); - HPExport void (*ShowSQL) (const char *, ...); - HPExport void (*ShowInfo) (const char *, ...); - HPExport void (*ShowNotice) (const char *, ...); - HPExport void (*ShowWarning) (const char *, ...); - HPExport void (*ShowDebug) (const char *, ...); - HPExport void (*ShowError) (const char *, ...); - HPExport void (*ShowFatalError) (const char *, ...); -#endif - /* after */ #include "../common/showmsg.h" @@ -192,7 +180,7 @@ HPExport struct HPMi_interface { /* pc group permission */ void (*addPCGPermission) (unsigned int pluginID, char *name, unsigned int *mask); } HPMi_s; -#ifndef _COMMON_HPM_H_ +#ifndef HERCULES_CORE HPExport struct HPMi_interface *HPMi; #endif diff --git a/src/common/cbasetypes.h b/src/common/cbasetypes.h index f44e80413..da0d6b307 100644 --- a/src/common/cbasetypes.h +++ b/src/common/cbasetypes.h @@ -442,5 +442,11 @@ void SET_FUNCPOINTER(T1& var, T2 p) #define SET_FUNCPOINTER(var,p) ((var) = (p)) #endif +/* pointer size fix which fixes several gcc warnings */ +#ifdef __64BIT__ + #define __64BPTRSIZE(y) ((intptr)(y)) +#else + #define __64BPTRSIZE(y) (y) +#endif #endif /* _COMMON_CBASETYPES_H_ */ diff --git a/src/common/conf.c b/src/common/conf.c index b816b2f7f..46a034497 100644 --- a/src/common/conf.c +++ b/src/common/conf.c @@ -2,7 +2,10 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams +#define HERCULES_CORE + #include "conf.h" + #include "../../3rdparty/libconfig/libconfig.h" #include "../common/showmsg.h" // ShowError diff --git a/src/common/conf.h b/src/common/conf.h index 9aff3df47..e5b637e47 100644 --- a/src/common/conf.h +++ b/src/common/conf.h @@ -6,6 +6,7 @@ #define _COMMON_CONF_H_ #include "../common/cbasetypes.h" + #include "../../3rdparty/libconfig/libconfig.h" /** diff --git a/src/common/console.c b/src/common/console.c index d8f352c8a..6a82db555 100644 --- a/src/common/console.c +++ b/src/common/console.c @@ -2,42 +2,46 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams +#define HERCULES_CORE + +#include "../config/core.h" // CONSOLE_INPUT, MAX_CONSOLE_INPUT +#include "console.h" + +#include <stdio.h> +#include <stdlib.h> + #include "../common/cbasetypes.h" -#include "../common/showmsg.h" #include "../common/core.h" +#include "../common/showmsg.h" #include "../common/sysinfo.h" -#include "../config/core.h" -#include "console.h" #ifndef MINICORE - #include "../common/ers.h" - #include "../common/malloc.h" - #include "../common/atomic.h" - #include "../common/spinlock.h" - #include "../common/thread.h" - #include "../common/mutex.h" - #include "../common/timer.h" - #include "../common/strlib.h" - #include "../common/sql.h" +# include "../common/atomic.h" +# include "../common/ers.h" +# include "../common/malloc.h" +# include "../common/mutex.h" +# include "../common/spinlock.h" +# include "../common/sql.h" +# include "../common/strlib.h" +# include "../common/thread.h" +# include "../common/timer.h" #endif -#include <stdio.h> -#include <stdlib.h> #if !defined(WIN32) - #include <unistd.h> - #include <sys/time.h> +# include <sys/time.h> +# include <unistd.h> #else - #include "../common/winapi.h" // Console close event handling +# include "../common/winapi.h" // Console close event handling +# ifdef CONSOLE_INPUT +# include <conio.h> /* _kbhit() */ +# endif #endif +struct console_interface console_s; #ifdef CONSOLE_INPUT - #if defined(WIN32) - #include <conio.h> /* _kbhit() */ - #endif +struct console_input_interface console_input_s; #endif -struct console_interface console_s; - /*====================================== * CORE : Display title *--------------------------------------*/ @@ -116,12 +120,12 @@ CPCMD_C(mem_report,server) { **/ CPCMD(help) { unsigned int i = 0; - for ( i = 0; i < console->cmd_list_count; i++ ) { - if( console->cmd_list[i]->next_count ) { - ShowInfo("- '"CL_WHITE"%s"CL_RESET"' subs\n",console->cmd_list[i]->cmd); - console->parse_list_subs(console->cmd_list[i],2); + for ( i = 0; i < console->input->cmd_list_count; i++ ) { + if( console->input->cmd_list[i]->next_count ) { + ShowInfo("- '"CL_WHITE"%s"CL_RESET"' subs\n",console->input->cmd_list[i]->cmd); + console->input->parse_list_subs(console->input->cmd_list[i],2); } else { - ShowInfo("- '"CL_WHITE"%s"CL_RESET"'\n",console->cmd_list[i]->cmd); + ShowInfo("- '"CL_WHITE"%s"CL_RESET"'\n",console->input->cmd_list[i]->cmd); } } } @@ -144,7 +148,7 @@ CPCMD_C(skip,update) { ShowDebug("usage example: sql update skip 2013-02-14--16-15.sql\n"); return; } - Sql_HerculesUpdateSkip(console->SQL, line); + Sql_HerculesUpdateSkip(console->input->SQL, line); } /** @@ -206,7 +210,7 @@ void console_load_defaults(void) { unsigned int i, len = ARRAYLENGTH(default_list); struct CParseEntry *cmd; - RECREATE(console->cmds,struct CParseEntry *, len); + RECREATE(console->input->cmds,struct CParseEntry *, len); for(i = 0; i < len; i++) { CREATE(cmd, struct CParseEntry, 1); @@ -220,12 +224,12 @@ void console_load_defaults(void) { cmd->next_count = 0; - console->cmd_count++; - console->cmds[i] = cmd; + console->input->cmd_count++; + console->input->cmds[i] = cmd; default_list[i].self = cmd; if( !default_list[i].connect ) { - RECREATE(console->cmd_list,struct CParseEntry *, ++console->cmd_list_count); - console->cmd_list[console->cmd_list_count - 1] = cmd; + RECREATE(console->input->cmd_list,struct CParseEntry *, ++console->input->cmd_list_count); + console->input->cmd_list[console->input->cmd_list_count - 1] = cmd; } } @@ -233,11 +237,11 @@ void console_load_defaults(void) { unsigned int k; if( !default_list[i].connect ) continue; - for(k = 0; k < console->cmd_count; k++) { - if( strcmpi(default_list[i].connect,console->cmds[k]->cmd) == 0 ) { + for(k = 0; k < console->input->cmd_count; k++) { + if( strcmpi(default_list[i].connect,console->input->cmds[k]->cmd) == 0 ) { cmd = default_list[i].self; - RECREATE(console->cmds[k]->u.next, struct CParseEntry *, ++console->cmds[k]->next_count); - console->cmds[k]->u.next[console->cmds[k]->next_count - 1] = cmd; + RECREATE(console->input->cmds[k]->u.next, struct CParseEntry *, ++console->input->cmds[k]->next_count); + console->input->cmds[k]->u.next[console->input->cmds[k]->next_count - 1] = cmd; break; } } @@ -256,23 +260,23 @@ void console_parse_create(char *name, CParseFunc func) { safestrncpy(sublist, name, CP_CMD_LENGTH * 5); tok = strtok(sublist,":"); - for ( i = 0; i < console->cmd_list_count; i++ ) { - if( strcmpi(tok,console->cmd_list[i]->cmd) == 0 ) + for ( i = 0; i < console->input->cmd_list_count; i++ ) { + if( strcmpi(tok,console->input->cmd_list[i]->cmd) == 0 ) break; } - if( i == console->cmd_list_count ) { - RECREATE(console->cmds,struct CParseEntry *, ++console->cmd_count); + if( i == console->input->cmd_list_count ) { + RECREATE(console->input->cmds,struct CParseEntry *, ++console->input->cmd_count); CREATE(cmd, struct CParseEntry, 1); safestrncpy(cmd->cmd, tok, CP_CMD_LENGTH); cmd->next_count = 0; - console->cmds[console->cmd_count - 1] = cmd; - RECREATE(console->cmd_list,struct CParseEntry *, ++console->cmd_list_count); - console->cmd_list[console->cmd_list_count - 1] = cmd; - i = console->cmd_list_count - 1; + console->input->cmds[console->input->cmd_count - 1] = cmd; + RECREATE(console->input->cmd_list,struct CParseEntry *, ++console->input->cmd_list_count); + console->input->cmd_list[console->input->cmd_list_count - 1] = cmd; + i = console->input->cmd_list_count - 1; } - cmd = console->cmd_list[i]; + cmd = console->input->cmd_list[i]; while( ( tok = strtok(NULL, ":") ) != NULL ) { for(i = 0; i < cmd->next_count; i++) { @@ -281,13 +285,13 @@ void console_parse_create(char *name, CParseFunc func) { } if ( i == cmd->next_count ) { - RECREATE(console->cmds,struct CParseEntry *, ++console->cmd_count); - CREATE(console->cmds[console->cmd_count-1], struct CParseEntry, 1); - safestrncpy(console->cmds[console->cmd_count-1]->cmd, tok, CP_CMD_LENGTH); - console->cmds[console->cmd_count-1]->next_count = 0; + RECREATE(console->input->cmds,struct CParseEntry *, ++console->input->cmd_count); + CREATE(console->input->cmds[console->input->cmd_count-1], struct CParseEntry, 1); + safestrncpy(console->input->cmds[console->input->cmd_count-1]->cmd, tok, CP_CMD_LENGTH); + console->input->cmds[console->input->cmd_count-1]->next_count = 0; RECREATE(cmd->u.next, struct CParseEntry *, ++cmd->next_count); - cmd->u.next[cmd->next_count - 1] = console->cmds[console->cmd_count-1]; - cmd = console->cmds[console->cmd_count-1]; + cmd->u.next[cmd->next_count - 1] = console->input->cmds[console->input->cmd_count-1]; + cmd = console->input->cmds[console->input->cmd_count-1]; continue; } @@ -302,7 +306,7 @@ void console_parse_list_subs(struct CParseEntry *cmd, unsigned char depth) { memset(msg, '-', depth); snprintf(msg + depth,CP_CMD_LENGTH * 2, " '"CL_WHITE"%s"CL_RESET"'",cmd->u.next[i]->cmd); ShowInfo("%s subs\n",msg); - console->parse_list_subs(cmd->u.next[i],depth + 1); + console->input->parse_list_subs(cmd->u.next[i],depth + 1); } else { memset(msg, '-', depth); snprintf(msg + depth,CP_CMD_LENGTH * 2, " %s",cmd->u.next[i]->cmd); @@ -320,21 +324,21 @@ void console_parse_sub(char *line) { memcpy(bline, line, 200); tok = strtok(line, " "); - for ( i = 0; i < console->cmd_list_count; i++ ) { - if( strcmpi(tok,console->cmd_list[i]->cmd) == 0 ) + for ( i = 0; i < console->input->cmd_list_count; i++ ) { + if( strcmpi(tok,console->input->cmd_list[i]->cmd) == 0 ) break; } - if( i == console->cmd_list_count ) { + if( i == console->input->cmd_list_count ) { ShowError("'"CL_WHITE"%s"CL_RESET"' is not a known command, type '"CL_WHITE"help"CL_RESET"' to list all commands\n",line); return; } - cmd = console->cmd_list[i]; + cmd = console->input->cmd_list[i]; len += snprintf(sublist,CP_CMD_LENGTH * 5,"%s", cmd->cmd) + 1; - if( cmd->next_count == 0 && console->cmd_list[i]->u.func ) { + if( cmd->next_count == 0 && console->input->cmd_list[i]->u.func ) { char *r = NULL; if( (tok = strtok(NULL, " ")) ) { r = bline; @@ -351,7 +355,7 @@ void console_parse_sub(char *line) { if( strcmpi("help",tok) == 0 ) { if( cmd->next_count ) { ShowInfo("- '"CL_WHITE"%s"CL_RESET"' subs\n",sublist); - console->parse_list_subs(cmd,2); + console->input->parse_list_subs(cmd,2); } else { ShowError("'"CL_WHITE"%s"CL_RESET"' doesn't possess any subcommands\n",sublist); } @@ -392,95 +396,95 @@ void console_parse(char* line) { } void *cThread_main(void *x) { - while( console->ptstate ) {/* loopx */ - if( console->key_pressed() ) { + while( console->input->ptstate ) {/* loopx */ + if( console->input->key_pressed() ) { char input[MAX_CONSOLE_INPUT]; - console->parse(input); + console->input->parse(input); if( input[0] != '\0' ) {/* did we get something? */ - EnterSpinLock(&console->ptlock); + EnterSpinLock(&console->input->ptlock); if( cinput.count == CONSOLE_PARSE_SIZE ) { - LeaveSpinLock(&console->ptlock); + LeaveSpinLock(&console->input->ptlock); continue;/* drop */ } safestrncpy(cinput.queue[cinput.count++],input,MAX_CONSOLE_INPUT); - LeaveSpinLock(&console->ptlock); + LeaveSpinLock(&console->input->ptlock); } } - ramutex_lock( console->ptmutex ); - racond_wait( console->ptcond, console->ptmutex, -1 ); - ramutex_unlock( console->ptmutex ); + ramutex_lock( console->input->ptmutex ); + racond_wait( console->input->ptcond, console->input->ptmutex, -1 ); + ramutex_unlock( console->input->ptmutex ); } return NULL; } int console_parse_timer(int tid, int64 tick, int id, intptr_t data) { int i; - EnterSpinLock(&console->ptlock); + EnterSpinLock(&console->input->ptlock); for(i = 0; i < cinput.count; i++) { - console->parse_sub(cinput.queue[i]); + console->input->parse_sub(cinput.queue[i]); } cinput.count = 0; - LeaveSpinLock(&console->ptlock); - racond_signal(console->ptcond); + LeaveSpinLock(&console->input->ptlock); + racond_signal(console->input->ptcond); return 0; } void console_parse_final(void) { - if( console->ptstate ) { - InterlockedDecrement(&console->ptstate); - racond_signal(console->ptcond); + if( console->input->ptstate ) { + InterlockedDecrement(&console->input->ptstate); + racond_signal(console->input->ptcond); /* wait for thread to close */ - rathread_wait(console->pthread, NULL); + rathread_wait(console->input->pthread, NULL); - racond_destroy(console->ptcond); - ramutex_destroy(console->ptmutex); + racond_destroy(console->input->ptcond); + ramutex_destroy(console->input->ptmutex); } } void console_parse_init(void) { cinput.count = 0; - console->ptstate = 1; + console->input->ptstate = 1; - InitializeSpinLock(&console->ptlock); + InitializeSpinLock(&console->input->ptlock); - console->ptmutex = ramutex_create(); - console->ptcond = racond_create(); + console->input->ptmutex = ramutex_create(); + console->input->ptcond = racond_create(); - if( (console->pthread = rathread_create(console->pthread_main, NULL)) == NULL ){ + if( (console->input->pthread = rathread_create(console->input->pthread_main, NULL)) == NULL ){ ShowFatalError("console_parse_init: failed to spawn console_parse thread.\n"); exit(EXIT_FAILURE); } - timer->add_func_list(console->parse_timer, "console_parse_timer"); - timer->add_interval(timer->gettick() + 1000, console->parse_timer, 0, 0, 500);/* start listening in 1s; re-try every 0.5s */ + timer->add_func_list(console->input->parse_timer, "console_parse_timer"); + timer->add_interval(timer->gettick() + 1000, console->input->parse_timer, 0, 0, 500);/* start listening in 1s; re-try every 0.5s */ } void console_setSQL(Sql *SQL_handle) { - console->SQL = SQL_handle; + console->input->SQL = SQL_handle; } #endif /* CONSOLE_INPUT */ void console_init (void) { #ifdef CONSOLE_INPUT - console->cmd_count = console->cmd_list_count = 0; - console->load_defaults(); - console->parse_init(); + console->input->cmd_count = console->input->cmd_list_count = 0; + console->input->load_defaults(); + console->input->parse_init(); #endif } void console_final(void) { #ifdef CONSOLE_INPUT unsigned int i; - console->parse_final(); - for( i = 0; i < console->cmd_count; i++ ) { - if( console->cmds[i]->next_count ) - aFree(console->cmds[i]->u.next); - aFree(console->cmds[i]); + console->input->parse_final(); + for( i = 0; i < console->input->cmd_count; i++ ) { + if( console->input->cmds[i]->next_count ) + aFree(console->input->cmds[i]->u.next); + aFree(console->input->cmds[i]); } - aFree(console->cmds); - aFree(console->cmd_list); + aFree(console->input->cmds); + aFree(console->input->cmd_list); #endif } void console_defaults(void) { @@ -489,17 +493,20 @@ void console_defaults(void) { console->final = console_final; console->display_title = display_title; #ifdef CONSOLE_INPUT - console->parse_init = console_parse_init; - console->parse_final = console_parse_final; - console->parse_timer = console_parse_timer; - console->pthread_main = cThread_main; - console->parse = console_parse; - console->parse_sub = console_parse_sub; - console->key_pressed = console_parse_key_pressed; - console->load_defaults = console_load_defaults; - console->parse_list_subs = console_parse_list_subs; - console->addCommand = console_parse_create; - console->setSQL = console_setSQL; - console->SQL = NULL; + console->input = &console_input_s; + console->input->parse_init = console_parse_init; + console->input->parse_final = console_parse_final; + console->input->parse_timer = console_parse_timer; + console->input->pthread_main = cThread_main; + console->input->parse = console_parse; + console->input->parse_sub = console_parse_sub; + console->input->key_pressed = console_parse_key_pressed; + console->input->load_defaults = console_load_defaults; + console->input->parse_list_subs = console_parse_list_subs; + console->input->addCommand = console_parse_create; + console->input->setSQL = console_setSQL; + console->input->SQL = NULL; +#else + console->input = NULL; #endif } diff --git a/src/common/console.h b/src/common/console.h index 3d19ddc9d..d2c58f978 100644 --- a/src/common/console.h +++ b/src/common/console.h @@ -4,11 +4,13 @@ #ifndef _COMMON_CONSOLE_H_ #define _COMMON_CONSOLE_H_ -#include "../common/thread.h" +#include "../config/core.h" // MAX_CONSOLE_INPUT + +#include "../common/cbasetypes.h" #include "../common/mutex.h" #include "../common/spinlock.h" #include "../common/sql.h" -#include "../config/core.h" +#include "../common/thread.h" /** * Queue Max @@ -47,11 +49,8 @@ struct { unsigned short count; } cinput; -struct console_interface { - void (*init) (void); - void (*final) (void); - void (*display_title) (void); #ifdef CONSOLE_INPUT +struct console_input_interface { /* vars */ SPIN_LOCK ptlock;/* parse thread lock */ rAthread pthread;/* parse thread */ @@ -77,7 +76,17 @@ struct console_interface { void (*parse_list_subs) (struct CParseEntry *cmd, unsigned char depth); void (*addCommand) (char *name, CParseFunc func); void (*setSQL) (Sql *SQL_handle); +}; +#else +struct console_input_interface; #endif + +struct console_interface { + void (*init) (void); + void (*final) (void); + void (*display_title) (void); + + struct console_input_interface *input; }; struct console_interface *console; diff --git a/src/common/core.c b/src/common/core.c index 49b272488..85f824866 100644 --- a/src/common/core.c +++ b/src/common/core.c @@ -2,36 +2,40 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/mmo.h" -#include "../common/showmsg.h" -#include "../common/malloc.h" -#include "../common/strlib.h" +#define HERCULES_CORE + +#include "../config/core.h" #include "core.h" + +#include "../common/cbasetypes.h" #include "../common/console.h" +#include "../common/malloc.h" +#include "../common/mmo.h" #include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" #include "../common/sysinfo.h" #ifndef MINICORE - #include "../common/db.h" - #include "../common/socket.h" - #include "../common/timer.h" - #include "../common/thread.h" - #include "../common/sql.h" - #include "../config/core.h" - #include "../common/HPM.h" - #include "../common/utils.h" - #include "../common/conf.h" - #include "../common/ers.h" +# include "../common/HPM.h" +# include "../common/conf.h" +# include "../common/db.h" +# include "../common/ers.h" +# include "../common/socket.h" +# include "../common/sql.h" +# include "../common/thread.h" +# include "../common/timer.h" +# include "../common/utils.h" #endif +#include <signal.h> #include <stdio.h> #include <stdlib.h> -#include <signal.h> #include <string.h> #ifndef _WIN32 -#include <unistd.h> +# include <unistd.h> #else -#include "../common/winapi.h" // Console close event handling +# include "../common/winapi.h" // Console close event handling #endif /// Called when a terminate signal is received. diff --git a/src/common/core.h b/src/common/core.h index e9f7c5961..ba75e6b01 100644 --- a/src/common/core.h +++ b/src/common/core.h @@ -7,11 +7,10 @@ #include "../common/db.h" #include "../common/mmo.h" -#include "../config/core.h" /* so that developers with --enable-debug can raise signals from any section of the code they'd like */ #ifdef DEBUG - #include <signal.h> +# include <signal.h> #endif extern int arg_c; diff --git a/src/common/db.c b/src/common/db.c index 8d6b08815..1781aa96f 100644 --- a/src/common/db.c +++ b/src/common/db.c @@ -67,14 +67,18 @@ * @encoding US-ASCII * @see #db.h \*****************************************************************************/ + +#define HERCULES_CORE + +#include "db.h" + #include <stdio.h> #include <stdlib.h> -#include "db.h" -#include "../common/mmo.h" +#include "../common/ers.h" #include "../common/malloc.h" +#include "../common/mmo.h" #include "../common/showmsg.h" -#include "../common/ers.h" #include "../common/strlib.h" /*****************************************************************************\ diff --git a/src/common/db.h b/src/common/db.h index 67abe6f19..0d2548806 100644 --- a/src/common/db.h +++ b/src/common/db.h @@ -42,9 +42,10 @@ #ifndef _COMMON_DB_H_ #define _COMMON_DB_H_ -#include "../common/cbasetypes.h" #include <stdarg.h> +#include "../common/cbasetypes.h" + /*****************************************************************************\ * (1) Section with public typedefs, enums, unions, structures and defines. * * DBRelease - Enumeration of release options. * diff --git a/src/common/des.c b/src/common/des.c index ed6d098dc..7f952be76 100644 --- a/src/common/des.c +++ b/src/common/des.c @@ -1,8 +1,11 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#include "../common/cbasetypes.h" -#include "../common/des.h" +#define HERCULES_CORE + +#include "des.h" + +#include "../common/cbasetypes.h" /// DES (Data Encryption Standard) algorithm, modified version. /// @see http://www.eathena.ws/board/index.php?autocom=bugtracker&showbug=5099. diff --git a/src/common/ers.c b/src/common/ers.c index 5a3d7314a..d9895e4f2 100644 --- a/src/common/ers.c +++ b/src/common/ers.c @@ -39,14 +39,18 @@ * @encoding US-ASCII * * @see common#ers.h * \*****************************************************************************/ + +#define HERCULES_CORE + +#include "ers.h" + #include <stdlib.h> #include <string.h> #include "../common/cbasetypes.h" #include "../common/malloc.h" // CREATE, RECREATE, aMalloc, aFree -#include "../common/showmsg.h" // ShowMessage, ShowError, ShowFatalError, CL_BOLD, CL_NORMAL #include "../common/nullpo.h" -#include "ers.h" +#include "../common/showmsg.h" // ShowMessage, ShowError, ShowFatalError, CL_BOLD, CL_NORMAL #ifndef DISABLE_ERS diff --git a/src/common/grfio.c b/src/common/grfio.c index bde0ed720..1111fb3f3 100644 --- a/src/common/grfio.c +++ b/src/common/grfio.c @@ -2,13 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/des.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/utils.h" -#include "../common/nullpo.h" +#define HERCULES_CORE + #include "grfio.h" #include <stdio.h> @@ -17,6 +12,14 @@ #include <sys/stat.h> #include <zlib.h> +#include "../common/cbasetypes.h" +#include "../common/des.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" +#include "../common/utils.h" + //---------------------------- // file entry table struct //---------------------------- diff --git a/src/common/malloc.c b/src/common/malloc.c index 5b39cbab6..13cf0b5ce 100644 --- a/src/common/malloc.c +++ b/src/common/malloc.c @@ -2,16 +2,19 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/malloc.h" -#include "../common/core.h" -#include "../common/showmsg.h" -#include "../common/sysinfo.h" +#define HERCULES_CORE + +#include "malloc.h" #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> +#include "../common/core.h" +#include "../common/showmsg.h" +#include "../common/sysinfo.h" + struct malloc_interface iMalloc_s; ////////////// Memory Libraries ////////////////// diff --git a/src/common/mapindex.c b/src/common/mapindex.c index 3128a3cb0..5c69c7063 100644 --- a/src/common/mapindex.c +++ b/src/common/mapindex.c @@ -2,16 +2,19 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/mmo.h" -#include "../common/showmsg.h" -#include "../common/malloc.h" -#include "../common/strlib.h" -#include "../common/db.h" +#define HERCULES_CORE + #include "mapindex.h" -#include <string.h> #include <stdio.h> #include <stdlib.h> +#include <string.h> + +#include "../common/db.h" +#include "../common/malloc.h" +#include "../common/mmo.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" /* mapindex.c interface source */ struct mapindex_interface mapindex_s; diff --git a/src/common/md5calc.c b/src/common/md5calc.c index 05fde42cc..e7b506e27 100644 --- a/src/common/md5calc.c +++ b/src/common/md5calc.c @@ -6,11 +6,15 @@ * ***********************************************************/ -#include "../common/random.h" +#define HERCULES_CORE + #include "md5calc.h" -#include <string.h> + #include <stdio.h> #include <stdlib.h> +#include <string.h> + +#include "../common/random.h" #ifndef UINT_MAX #define UINT_MAX 4294967295U diff --git a/src/common/mmo.h b/src/common/mmo.h index d535d2874..1d826463e 100644 --- a/src/common/mmo.h +++ b/src/common/mmo.h @@ -5,10 +5,11 @@ #ifndef _COMMON_MMO_H_ #define _COMMON_MMO_H_ -#include "cbasetypes.h" -#include "../common/db.h" #include <time.h> +#include "../common/cbasetypes.h" +#include "../common/db.h" + // server->client protocol version // 0 - pre-? // 1 - ? - 0x196 @@ -96,6 +97,7 @@ //Official Limit: 2.1b ( the var that stores the money doesn't go much higher than this by default ) #define MAX_BANK_ZENY 2100000000 +#define MAX_LEVEL 175 #define MAX_FAME 1000000000 #define MAX_CART 100 #define MAX_SKILL 1478 diff --git a/src/common/mutex.c b/src/common/mutex.c index 0668dbc41..12524c3b7 100644 --- a/src/common/mutex.c +++ b/src/common/mutex.c @@ -1,6 +1,10 @@ // Copyright (c) rAthena Project (www.rathena.org) - Licensed under GNU GPL // For more information, see LICENCE in the main folder +#define HERCULES_CORE + +#include "mutex.h" + #ifdef WIN32 #include "../common/winapi.h" #else @@ -13,7 +17,6 @@ #include "../common/malloc.h" #include "../common/showmsg.h" #include "../common/timer.h" -#include "../common/mutex.h" struct ramutex{ #ifdef WIN32 diff --git a/src/common/mutex.h b/src/common/mutex.h index eeb24e6ff..3b83b66d6 100644 --- a/src/common/mutex.h +++ b/src/common/mutex.h @@ -4,6 +4,7 @@ #ifndef _COMMON_MUTEX_H_ #define _COMMON_MUTEX_H_ +#include "../common/cbasetypes.h" typedef struct ramutex *ramutex; // Mutex typedef struct racond *racond; // Condition Var diff --git a/src/common/nullpo.c b/src/common/nullpo.c index 1cb471aff..1891835f1 100644 --- a/src/common/nullpo.c +++ b/src/common/nullpo.c @@ -2,10 +2,14 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams +#define HERCULES_CORE + +#include "nullpo.h" + #include <stdio.h> #include <stdarg.h> #include <string.h> -#include "../common/nullpo.h" + #include "../common/showmsg.h" /** diff --git a/src/common/random.c b/src/common/random.c index e46c52cad..7019a31f3 100644 --- a/src/common/random.c +++ b/src/common/random.c @@ -1,17 +1,23 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder +#define HERCULES_CORE + +#include "random.h" + +#include <time.h> // time + +#include <mt19937ar.h> // init_genrand, genrand_int32, genrand_res53 + #include "../common/showmsg.h" #include "../common/timer.h" // gettick -#include "random.h" + #if defined(WIN32) - #include "../common/winapi.h" +# include "../common/winapi.h" #elif defined(HAVE_GETPID) || defined(HAVE_GETTID) - #include <sys/types.h> - #include <unistd.h> +# include <sys/types.h> +# include <unistd.h> #endif -#include <time.h> // time -#include <mt19937ar.h> // init_genrand, genrand_int32, genrand_res53 /// Initializes the random number generator with an appropriate seed. diff --git a/src/common/showmsg.c b/src/common/showmsg.c index 14342fe5e..1dbcba282 100644 --- a/src/common/showmsg.c +++ b/src/common/showmsg.c @@ -2,23 +2,26 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/strlib.h" // StringBuf +#define HERCULES_CORE + #include "showmsg.h" -#include "core.h" //[Ind] - For SERVER_TYPE +#include <stdarg.h> #include <stdio.h> +#include <stdlib.h> // atexit #include <string.h> -#include <stdarg.h> #include <time.h> -#include <stdlib.h> // atexit #include "../../3rdparty/libconfig/libconfig.h" +#include "../common/cbasetypes.h" +#include "../common/core.h" //[Ind] - For SERVER_TYPE +#include "../common/strlib.h" // StringBuf + #ifdef WIN32 -#include "../common/winapi.h" +# include "../common/winapi.h" #else // not WIN32 -#include <unistd.h> +# include <unistd.h> #endif // WIN32 #if defined(DEBUGLOGMAP) diff --git a/src/common/showmsg.h b/src/common/showmsg.h index 49fbc34fb..5b32f39ae 100644 --- a/src/common/showmsg.h +++ b/src/common/showmsg.h @@ -5,12 +5,14 @@ #ifndef _COMMON_SHOWMSG_H_ #define _COMMON_SHOWMSG_H_ -#ifndef _COMMON_HPMI_H_ - #include "../../3rdparty/libconfig/libconfig.h" -#endif - #include <stdarg.h> +#ifdef HERCULES_CORE +# include "../../3rdparty/libconfig/libconfig.h" +#else +# include "../common/HPMi.h" +#endif + // for help with the console colors look here: // http://www.edoceo.com/liberum/?doc=printf-with-color // some code explanation (used here): @@ -90,7 +92,7 @@ enum msg_type { }; extern void ClearScreen(void); -#ifndef _COMMON_HPMI_H_ +#ifdef HERCULES_CORE extern void ShowMessage(const char *, ...); extern void ShowStatus(const char *, ...); extern void ShowSQL(const char *, ...); @@ -101,7 +103,18 @@ extern void ClearScreen(void); extern void ShowError(const char *, ...); extern void ShowFatalError(const char *, ...); extern void ShowConfigWarning(config_setting_t *config, const char *string, ...); +#else + HPExport void (*ShowMessage) (const char *, ...); + HPExport void (*ShowStatus) (const char *, ...); + HPExport void (*ShowSQL) (const char *, ...); + HPExport void (*ShowInfo) (const char *, ...); + HPExport void (*ShowNotice) (const char *, ...); + HPExport void (*ShowWarning) (const char *, ...); + HPExport void (*ShowDebug) (const char *, ...); + HPExport void (*ShowError) (const char *, ...); + HPExport void (*ShowFatalError) (const char *, ...); #endif + extern int _vShowMessage(enum msg_type flag, const char *string, va_list ap); #endif /* _COMMON_SHOWMSG_H_ */ diff --git a/src/common/socket.c b/src/common/socket.c index 35d350e95..3738f2c2a 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -2,48 +2,50 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/mmo.h" -#include "../common/timer.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../config/core.h" -#include "../common/HPM.h" +#define HERCULES_CORE +#include "../config/core.h" // SHOW_SERVER_STATS #define _H_SOCKET_C_ - #include "socket.h" +#undef _H_SOCKET_C_ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/types.h> +#include "../common/HPM.h" +#include "../common/cbasetypes.h" +#include "../common/malloc.h" +#include "../common/mmo.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" +#include "../common/timer.h" + #ifdef WIN32 - #include "../common/winapi.h" +# include "../common/winapi.h" #else - #include <errno.h> - #include <sys/socket.h> - #include <netinet/in.h> - #include <netinet/tcp.h> - #include <net/if.h> - #include <unistd.h> - #include <sys/time.h> - #include <sys/ioctl.h> - #include <netdb.h> - #include <arpa/inet.h> - - #ifndef SIOCGIFCONF - #include <sys/sockio.h> // SIOCGIFCONF on Solaris, maybe others? [Shinomori] - #endif - #ifndef FIONBIO - #include <sys/filio.h> // FIONBIO on Solaris [FlavioJS] - #endif - - #ifdef HAVE_SETRLIMIT - #include <sys/resource.h> - #endif +# include <arpa/inet.h> +# include <errno.h> +# include <net/if.h> +# include <netdb.h> +# include <netinet/in.h> +# include <netinet/tcp.h> +# include <sys/ioctl.h> +# include <sys/socket.h> +# include <sys/time.h> +# include <unistd.h> + +# ifndef SIOCGIFCONF +# include <sys/sockio.h> // SIOCGIFCONF on Solaris, maybe others? [Shinomori] +# endif +# ifndef FIONBIO +# include <sys/filio.h> // FIONBIO on Solaris [FlavioJS] +# endif + +# ifdef HAVE_SETRLIMIT +# include <sys/resource.h> +# endif #endif /** diff --git a/src/common/socket.h b/src/common/socket.h index 75adde4cf..804b9284f 100644 --- a/src/common/socket.h +++ b/src/common/socket.h @@ -5,19 +5,19 @@ #ifndef _COMMON_SOCKET_H_ #define _COMMON_SOCKET_H_ +#include <time.h> + #include "../common/cbasetypes.h" #ifdef WIN32 - #include "../common/winapi.h" +# include "../common/winapi.h" typedef long in_addr_t; #else - #include <sys/types.h> - #include <sys/socket.h> - #include <netinet/in.h> +# include <netinet/in.h> +# include <sys/socket.h> +# include <sys/types.h> #endif -#include <time.h> - struct HPluginData; #define FIFOSIZE_SERVERLINK 256*1024 diff --git a/src/common/spinlock.h b/src/common/spinlock.h index 29fbb355b..0058e1d83 100644 --- a/src/common/spinlock.h +++ b/src/common/spinlock.h @@ -1,4 +1,3 @@ -#pragma once #ifndef _COMMON_SPINLOCK_H_ #define _COMMON_SPINLOCK_H_ @@ -15,14 +14,14 @@ // // +#include "../common/atomic.h" +#include "../common/cbasetypes.h" +#include "../common/thread.h" + #ifdef WIN32 #include "../common/winapi.h" #endif -#include "../common/cbasetypes.h" -#include "../common/atomic.h" -#include "../common/thread.h" - #ifdef WIN32 typedef struct __declspec( align(64) ) SPIN_LOCK{ diff --git a/src/common/sql.c b/src/common/sql.c index 79ccc8e92..aeb56bff0 100644 --- a/src/common/sql.c +++ b/src/common/sql.c @@ -2,19 +2,23 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams +#define HERCULES_CORE + +#include "sql.h" + +#include <stdlib.h> // strtoul +#include <string.h> // strlen/strnlen/memcpy/memset + #include "../common/cbasetypes.h" #include "../common/malloc.h" #include "../common/showmsg.h" #include "../common/strlib.h" #include "../common/timer.h" -#include "sql.h" #ifdef WIN32 -#include "../common/winapi.h" +# include "../common/winapi.h" // Needed before mysql.h #endif #include <mysql.h> -#include <string.h>// strlen/strnlen/memcpy/memset -#include <stdlib.h>// strtoul void hercules_mysql_error_handler(unsigned int ecode); diff --git a/src/common/sql.h b/src/common/sql.h index 1fb436853..807e0843c 100644 --- a/src/common/sql.h +++ b/src/common/sql.h @@ -5,10 +5,9 @@ #ifndef _COMMON_SQL_H_ #define _COMMON_SQL_H_ -#include "../common/cbasetypes.h" #include <stdarg.h>// va_list - +#include "../common/cbasetypes.h" // Return codes #define SQL_ERROR (-1) diff --git a/src/common/strlib.c b/src/common/strlib.c index 361595b07..e2e802915 100644 --- a/src/common/strlib.c +++ b/src/common/strlib.c @@ -2,16 +2,19 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" -#define STRLIB_C +#define HERCULES_CORE + +#define _H_STRLIB_C_ #include "strlib.h" +#undef _H_STRLIB_C_ +#include <errno.h> #include <stdio.h> #include <stdlib.h> -#include <errno.h> +#include "../common/cbasetypes.h" +#include "../common/malloc.h" +#include "../common/showmsg.h" #define J_MAX_MALLOC_SIZE 65535 diff --git a/src/common/strlib.h b/src/common/strlib.h index 10844d257..decf661a6 100644 --- a/src/common/strlib.h +++ b/src/common/strlib.h @@ -5,15 +5,16 @@ #ifndef _COMMON_STRLIB_H_ #define _COMMON_STRLIB_H_ -#include "../common/cbasetypes.h" #include <stdarg.h> +#include "../common/cbasetypes.h" + #ifndef __USE_GNU - #define __USE_GNU // required to enable strnlen on some platforms - #include <string.h> - #undef __USE_GNU +# define __USE_GNU // required to enable strnlen on some platforms +# include <string.h> +# undef __USE_GNU #else - #include <string.h> +# include <string.h> #endif #ifdef WIN32 @@ -165,7 +166,7 @@ struct sv_interface *sv; void strlib_defaults(void); /* the purpose of these macros is simply to not make calling them be an annoyance */ -#ifndef STRLIB_C +#ifndef _H_STRLIB_C_ #define jstrescape(pt) (strlib->jstrescape(pt)) #define jstrescapecpy(pt,spt) (strlib->jstrescapecpy((pt),(spt))) #define jmemescapecpy(pt,spt,size) (strlib->jmemescapecpy((pt),(spt),(size))) @@ -189,6 +190,6 @@ void strlib_defaults(void); #define safesnprintf(buf,sz,fmt,...) (strlib->safesnprintf((buf),(sz),(fmt),##__VA_ARGS__)) #define strline(str,pos) (strlib->strline((str),(pos))) #define bin2hex(output,input,count) (strlib->bin2hex((output),(input),(count))) -#endif /* STRLIB_C */ +#endif /* _H_STRLIB_C_ */ #endif /* _COMMON_STRLIB_H_ */ diff --git a/src/common/sysinfo.c b/src/common/sysinfo.c index a56896458..3fdfadb41 100644 --- a/src/common/sysinfo.c +++ b/src/common/sysinfo.c @@ -4,23 +4,39 @@ /// See sysinfo.h for a description of this file -#define _COMMON_SYSINFO_P_ +#define HERCULES_CORE + #include "sysinfo.h" -#undef _COMMON_SYSINFO_P_ + +#include <stdio.h> // fopen +#include <stdlib.h> // atoi #include "../common/cbasetypes.h" #include "../common/core.h" -#include "../common/strlib.h" #include "../common/malloc.h" +#include "../common/strlib.h" #ifdef WIN32 -#include <windows.h> -#include <string.h> // strlen +# include <string.h> // strlen +# include <windows.h> #else -#include <unistd.h> +# include <unistd.h> #endif -#include <stdio.h> // fopen -#include <stdlib.h> // atoi + +/// Private interface fields +struct sysinfo_private { + char *platform; + char *osversion; + char *cpu; + int cpucores; + char *arch; + char *compiler; + char *cflags; + char *vcstype_name; + int vcstype; + char *vcsrevision_src; + char *vcsrevision_scripts; +}; /// sysinfo.c interface source struct sysinfo_interface sysinfo_s; diff --git a/src/common/sysinfo.h b/src/common/sysinfo.h index 17faac26b..c0c4d276a 100644 --- a/src/common/sysinfo.h +++ b/src/common/sysinfo.h @@ -13,23 +13,7 @@ #include "../common/cbasetypes.h" -#ifdef _COMMON_SYSINFO_P_ -struct sysinfo_private { - char *platform; - char *osversion; - char *cpu; - int cpucores; - char *arch; - char *compiler; - char *cflags; - char *vcstype_name; - int vcstype; - char *vcsrevision_src; - char *vcsrevision_scripts; -}; -#else struct sysinfo_private; -#endif /** * sysinfo.c interface diff --git a/src/common/thread.c b/src/common/thread.c index 4d110f2dd..4f73aa9b3 100644 --- a/src/common/thread.c +++ b/src/common/thread.c @@ -6,24 +6,27 @@ // Copyright (c) rAthena Project (www.rathena.org) - Licensed under GNU GPL // For more information, see LICENCE in the main folder +#define HERCULES_CORE + +#include "thread.h" + +#include "../common/cbasetypes.h" +#include "../common/malloc.h" +#include "../common/showmsg.h" + #ifdef WIN32 -#include "../common/winapi.h" -#define getpagesize() 4096 // @TODO: implement this properly (GetSystemInfo .. dwPageSize..). (Atm as on all supported win platforms its 4k its static.) -#define __thread __declspec( thread ) +# include "../common/winapi.h" +# define getpagesize() 4096 // @TODO: implement this properly (GetSystemInfo .. dwPageSize..). (Atm as on all supported win platforms its 4k its static.) +# define __thread __declspec( thread ) #else -#include <stdlib.h> -#include <unistd.h> -#include <string.h> -#include <signal.h> -#include <pthread.h> -#include <sched.h> +# include <stdlib.h> +# include <unistd.h> +# include <string.h> +# include <signal.h> +# include <pthread.h> +# include <sched.h> #endif -#include "cbasetypes.h" -#include "malloc.h" -#include "showmsg.h" -#include "thread.h" - // When Compiling using MSC (on win32..) we know we have support in any case! #ifdef _MSC_VER #define HAS_TLS diff --git a/src/common/thread.h b/src/common/thread.h index d6b2bbc6e..887c03179 100644 --- a/src/common/thread.h +++ b/src/common/thread.h @@ -1,7 +1,6 @@ // Copyright (c) rAthena Project (www.rathena.org) - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#pragma once #ifndef _COMMON_THREAD_H_ #define _COMMON_THREAD_H_ diff --git a/src/common/timer.c b/src/common/timer.c index 526854582..10f14b0f2 100644 --- a/src/common/timer.c +++ b/src/common/timer.c @@ -2,11 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/db.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" -#include "../common/utils.h" +#define HERCULES_CORE + #include "timer.h" #include <stdio.h> @@ -14,11 +11,17 @@ #include <string.h> #include <time.h> +#include "../common/cbasetypes.h" +#include "../common/db.h" +#include "../common/malloc.h" +#include "../common/showmsg.h" +#include "../common/utils.h" + #ifdef WIN32 -#include "../common/winapi.h" // GetTickCount() +# include "../common/winapi.h" // GetTickCount() #else -#include <unistd.h> -#include <sys/time.h> // struct timeval, gettimeofday() +# include <sys/time.h> // struct timeval, gettimeofday() +# include <unistd.h> #endif struct timer_interface timer_s; diff --git a/src/common/utils.c b/src/common/utils.c index 47747dd32..84925f707 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -2,33 +2,35 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/mmo.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" -#include "../common/core.h" -#include "socket.h" +#define HERCULES_CORE + #include "utils.h" -#include <stdio.h> +#include <math.h> // floor() #include <stdarg.h> +#include <stdio.h> #include <stdlib.h> #include <string.h> -#include <math.h> // floor() +#include <sys/stat.h> // cache purposes [Ind/Hercules] + +#include "../common/cbasetypes.h" +#include "../common/core.h" +#include "../common/malloc.h" +#include "../common/mmo.h" +#include "../common/showmsg.h" +#include "../common/socket.h" #ifdef WIN32 - #include "../common/winapi.h" - #ifndef F_OK - #define F_OK 0x0 - #endif /* F_OK */ +# include "../common/winapi.h" +# ifndef F_OK +# define F_OK 0x0 +# endif /* F_OK */ #else - #include <unistd.h> - #include <dirent.h> - #include <sys/stat.h> +# include <dirent.h> +# include <sys/stat.h> +# include <unistd.h> #endif -#include <sys/stat.h> // cache purposes [Ind/Hercules] - struct HCache_interface HCache_s; /// Dumps given buffer into file pointed to by a handle. diff --git a/src/common/utils.h b/src/common/utils.h index f89546b8a..823651163 100644 --- a/src/common/utils.h +++ b/src/common/utils.h @@ -5,10 +5,11 @@ #ifndef _COMMON_UTILS_H_ #define _COMMON_UTILS_H_ -#include "../common/cbasetypes.h" #include <stdio.h> // FILE* #include <time.h> +#include "../common/cbasetypes.h" + /* [HCache] 1-byte key to ensure our method is the latest, we can modify to ensure the method matches */ #define HCACHE_KEY 'k' diff --git a/src/config/const.h b/src/config/const.h index 6557cb987..f9baa4d7d 100644 --- a/src/config/const.h +++ b/src/config/const.h @@ -52,13 +52,6 @@ #define DEFTYPE_MAX CHAR_MAX #endif -/* pointer size fix which fixes several gcc warnings */ -#ifdef __64BIT__ - #define __64BPTRSIZE(y) ((intptr)(y)) -#else - #define __64BPTRSIZE(y) (y) -#endif - /* ATCMD_FUNC(mobinfo) HIT and FLEE calculations */ #ifdef RENEWAL #define MOB_FLEE(mobdata) ( (mobdata)->lv + (mobdata)->status.agi + 100 ) diff --git a/src/config/renewal.h b/src/config/renewal.h index 36615d63b..36bdd3958 100644 --- a/src/config/renewal.h +++ b/src/config/renewal.h @@ -74,5 +74,6 @@ #define RENEWAL_ASPD #endif // DISABLE_RENEWAL +#undef DISABLE_RENEWAL #endif // _CONFIG_RENEWAL_H_ diff --git a/src/login/account.h b/src/login/account.h index 234e7c0c1..329ae31c8 100644 --- a/src/login/account.h +++ b/src/login/account.h @@ -7,6 +7,7 @@ #include "../common/cbasetypes.h" #include "../common/mmo.h" // ACCOUNT_REG2_NUM +#include "../common/sql.h" // Sql typedef struct AccountDB AccountDB; typedef struct AccountDBIterator AccountDBIterator; diff --git a/src/login/account_sql.c b/src/login/account_sql.c index 1483196ab..2e4ed7ab9 100644 --- a/src/login/account_sql.c +++ b/src/login/account_sql.c @@ -2,17 +2,22 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams +#define HERCULES_CORE + +#include "../config/core.h" // CONSOLE_INPUT +#include "account.h" + +#include <stdlib.h> +#include <string.h> + +#include "../common/console.h" #include "../common/malloc.h" #include "../common/mmo.h" #include "../common/showmsg.h" +#include "../common/socket.h" #include "../common/sql.h" #include "../common/strlib.h" #include "../common/timer.h" -#include "../common/console.h" -#include "../common/socket.h" -#include "account.h" -#include <stdlib.h> -#include <string.h> /// global defines #define ACCOUNT_SQL_DB_VERSION 20110114 @@ -652,7 +657,7 @@ Sql* account_db_sql_up(AccountDB* self) { AccountDB_SQL* db = (AccountDB_SQL*)self; Sql_HerculesUpdateCheck(db->accounts); #ifdef CONSOLE_INPUT - console->setSQL(db->accounts); + console->input->setSQL(db->accounts); #endif return db->accounts; } diff --git a/src/login/ipban_sql.c b/src/login/ipban_sql.c index 74f45e418..081f28d84 100644 --- a/src/login/ipban_sql.c +++ b/src/login/ipban_sql.c @@ -2,6 +2,15 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams +#define HERCULES_CORE + +#include "ipban.h" + +#include <stdlib.h> +#include <string.h> + +#include "login.h" +#include "loginlog.h" #include "../common/cbasetypes.h" #include "../common/db.h" #include "../common/malloc.h" @@ -9,11 +18,6 @@ #include "../common/socket.h" #include "../common/strlib.h" #include "../common/timer.h" -#include "login.h" -#include "ipban.h" -#include "loginlog.h" -#include <stdlib.h> -#include <string.h> // global sql settings static char global_db_hostname[32] = "127.0.0.1"; diff --git a/src/login/login.c b/src/login/login.c index af59fcf38..cb46e0226 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -2,6 +2,18 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams +#define HERCULES_CORE + +#include "login.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "account.h" +#include "ipban.h" +#include "loginlog.h" +#include "../common/HPM.h" #include "../common/core.h" #include "../common/db.h" #include "../common/malloc.h" @@ -12,15 +24,6 @@ #include "../common/strlib.h" #include "../common/timer.h" #include "../common/utils.h" -#include "../common/HPM.h" -#include "account.h" -#include "ipban.h" -#include "login.h" -#include "loginlog.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> struct Login_Config login_config; diff --git a/src/login/login.h b/src/login/login.h index 14c361a15..e77b96a0e 100644 --- a/src/login/login.h +++ b/src/login/login.h @@ -5,8 +5,8 @@ #ifndef _LOGIN_LOGIN_H_ #define _LOGIN_LOGIN_H_ -#include "../common/mmo.h" // NAME_LENGTH,SEX_* #include "../common/core.h" // CORE_ST_LAST +#include "../common/mmo.h" // NAME_LENGTH,SEX_* enum E_LOGINSERVER_ST { diff --git a/src/login/loginlog.h b/src/login/loginlog.h index 730fb6e62..a86ad431c 100644 --- a/src/login/loginlog.h +++ b/src/login/loginlog.h @@ -4,6 +4,7 @@ #ifndef _LOGIN_LOGINLOG_H_ #define _LOGIN_LOGINLOG_H_ +#include "../common/cbasetypes.h" unsigned long loginlog_failedattempts(uint32 ip, unsigned int minutes); void login_log(uint32 ip, const char* username, int rcode, const char* message); @@ -11,5 +12,4 @@ bool loginlog_init(void); bool loginlog_final(void); bool loginlog_config_read(const char* w1, const char* w2); - #endif /* _LOGIN_LOGINLOG_H_ */ diff --git a/src/login/loginlog_sql.c b/src/login/loginlog_sql.c index 231ac783b..2cbc02c93 100644 --- a/src/login/loginlog_sql.c +++ b/src/login/loginlog_sql.c @@ -2,13 +2,18 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams +#define HERCULES_CORE + +#include "loginlog.h" + +#include <string.h> +#include <stdlib.h> // exit + #include "../common/cbasetypes.h" #include "../common/mmo.h" #include "../common/socket.h" #include "../common/sql.h" #include "../common/strlib.h" -#include <string.h> -#include <stdlib.h> // exit // global sql settings (in ipban_sql.c) static char global_db_hostname[32] = "127.0.0.1"; diff --git a/src/map/HPMmap.c b/src/map/HPMmap.c index 061479d87..cb8c979c6 100644 --- a/src/map/HPMmap.c +++ b/src/map/HPMmap.c @@ -1,25 +1,15 @@ // Copyright (c) Hercules Dev Team, licensed under GNU GPL. // See the LICENSE file -#include "../common/cbasetypes.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" -#include "../common/HPM.h" -#include "../common/conf.h" -#include "../common/db.h" -#include "../common/des.h" -#include "../common/ers.h" -#include "../common/mapindex.h" -#include "../common/mmo.h" -#include "../common/socket.h" -#include "../common/strlib.h" - +#define HERCULES_CORE #include "HPMmap.h" -#include "pc.h" -#include "map.h" -// +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <time.h> + #include "atcommand.h" #include "battle.h" #include "battleground.h" @@ -37,12 +27,14 @@ #include "itemdb.h" #include "log.h" #include "mail.h" +#include "map.h" #include "mapreg.h" #include "mercenary.h" #include "mob.h" #include "npc.h" #include "party.h" #include "path.h" +#include "pc.h" #include "pc_groups.h" #include "pet.h" #include "quest.h" @@ -54,11 +46,19 @@ #include "trade.h" #include "unit.h" #include "vending.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <time.h> +#include "../common/HPM.h" +#include "../common/cbasetypes.h" +#include "../common/conf.h" +#include "../common/db.h" +#include "../common/des.h" +#include "../common/ers.h" +#include "../common/malloc.h" +#include "../common/mapindex.h" +#include "../common/mmo.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/sysinfo.h" #include "../common/HPMDataCheck.h" diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 5fd0faf86..df3be40a5 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -2,57 +2,60 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/mmo.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/core.h" -#include "../common/showmsg.h" -#include "../common/malloc.h" -#include "../common/random.h" -#include "../common/socket.h" -#include "../common/strlib.h" -#include "../common/utils.h" -#include "../common/conf.h" -#include "../common/sysinfo.h" +#define HERCULES_CORE +#include "../config/core.h" // AUTOLOOTITEM_SIZE, AUTOTRADE_PERSISTENCY, MAX_CARTS, MAX_SUGGESTIONS, MOB_FLEE(), MOB_HIT(), RENEWAL, RENEWAL_DROP, RENEWAL_EXP #include "atcommand.h" + +#include <math.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + #include "battle.h" #include "chat.h" -#include "clif.h" #include "chrif.h" +#include "clif.h" #include "duel.h" +#include "elemental.h" +#include "guild.h" +#include "homunculus.h" #include "intif.h" #include "itemdb.h" #include "log.h" +#include "mail.h" #include "map.h" -#include "pc.h" -#include "pc_groups.h" // groupid2name -#include "status.h" -#include "skill.h" +#include "mapreg.h" +#include "mercenary.h" #include "mob.h" #include "npc.h" -#include "pet.h" -#include "homunculus.h" -#include "mail.h" -#include "mercenary.h" -#include "elemental.h" #include "party.h" -#include "guild.h" +#include "pc.h" +#include "pc_groups.h" // groupid2name +#include "pet.h" +#include "quest.h" #include "script.h" +#include "searchstore.h" +#include "skill.h" +#include "status.h" #include "storage.h" #include "trade.h" #include "unit.h" -#include "mapreg.h" -#include "quest.h" -#include "searchstore.h" +#include "../common/cbasetypes.h" +#include "../common/conf.h" +#include "../common/core.h" +#include "../common/malloc.h" +#include "../common/mmo.h" +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/sysinfo.h" +#include "../common/timer.h" +#include "../common/utils.h" #include "HPMmap.h" -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <math.h> - struct atcommand_interface atcommand_s; static char atcmd_output[CHAT_SIZE_MAX]; diff --git a/src/map/atcommand.h b/src/map/atcommand.h index bc4ab30a3..c8a1863af 100644 --- a/src/map/atcommand.h +++ b/src/map/atcommand.h @@ -5,9 +5,9 @@ #ifndef _MAP_ATCOMMAND_H_ #define _MAP_ATCOMMAND_H_ +#include "pc_groups.h" #include "../common/conf.h" #include "../common/db.h" -#include "pc_groups.h" /** * Declarations diff --git a/src/map/battle.c b/src/map/battle.c index 9089b7102..0865ee4ba 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -2,41 +2,44 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" -#include "../common/ers.h" -#include "../common/random.h" -#include "../common/socket.h" -#include "../common/strlib.h" -#include "../common/utils.h" -#include "../common/sysinfo.h" -#include "../common/HPM.h" +#define HERCULES_CORE -#include "map.h" -#include "path.h" -#include "pc.h" -#include "status.h" -#include "skill.h" -#include "homunculus.h" -#include "mercenary.h" -#include "elemental.h" -#include "mob.h" -#include "itemdb.h" -#include "clif.h" -#include "pet.h" -#include "guild.h" -#include "party.h" +#include "../config/core.h" // CELL_NOSTACK, CIRCULAR_AREA, CONSOLE_INPUT, HMAP_ZONE_DAMAGE_CAP_TYPE, OFFICIAL_WALKPATH, RENEWAL, RENEWAL_ASPD, RENEWAL_CAST, RENEWAL_DROP, RENEWAL_EDP, RENEWAL_EXP, RENEWAL_LVDMG, RE_LVL_DMOD(), RE_LVL_MDMOD(), RE_LVL_TMDMOD(), RE_SKILL_REDUCTION(), SCRIPT_CALLFUNC_CHECK, SECURE_NPCTIMEOUT, STATS_OPT_OUT #include "battle.h" -#include "battleground.h" -#include "chrif.h" +#include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <math.h> + +#include "battleground.h" +#include "chrif.h" +#include "clif.h" +#include "elemental.h" +#include "guild.h" +#include "homunculus.h" +#include "itemdb.h" +#include "map.h" +#include "mercenary.h" +#include "mob.h" +#include "party.h" +#include "path.h" +#include "pc.h" +#include "pet.h" +#include "skill.h" +#include "status.h" +#include "../common/HPM.h" +#include "../common/cbasetypes.h" +#include "../common/ers.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/sysinfo.h" +#include "../common/timer.h" +#include "../common/utils.h" struct Battle_Config battle_config; struct battle_interface battle_s; diff --git a/src/map/battle.h b/src/map/battle.h index 88038ddb4..fbe097c78 100644 --- a/src/map/battle.h +++ b/src/map/battle.h @@ -5,8 +5,8 @@ #ifndef _MAP_BATTLE_H_ #define _MAP_BATTLE_H_ -#include "../common/cbasetypes.h" #include "map.h" //ELE_MAX +#include "../common/cbasetypes.h" /** * Declarations diff --git a/src/map/battleground.c b/src/map/battleground.c index 68539e25d..a7169de0e 100644 --- a/src/map/battleground.c +++ b/src/map/battleground.c @@ -2,29 +2,32 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/timer.h" -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/strlib.h" -#include "../common/conf.h" +#define HERCULES_CORE #include "battleground.h" + +#include <string.h> +#include <stdio.h> + #include "battle.h" #include "clif.h" +#include "homunculus.h" #include "map.h" +#include "mapreg.h" +#include "mercenary.h" +#include "mob.h" // struct mob_data #include "npc.h" -#include "pc.h" #include "party.h" +#include "pc.h" #include "pet.h" -#include "homunculus.h" -#include "mercenary.h" -#include "mapreg.h" - -#include <string.h> -#include <stdio.h> +#include "../common/cbasetypes.h" +#include "../common/conf.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/timer.h" struct battleground_interface bg_s; diff --git a/src/map/battleground.h b/src/map/battleground.h index 05c4eb060..ec0a86f14 100644 --- a/src/map/battleground.h +++ b/src/map/battleground.h @@ -5,9 +5,9 @@ #ifndef _MAP_BATTLEGROUND_H_ #define _MAP_BATTLEGROUND_H_ -#include "../common/mmo.h" // struct party #include "clif.h" #include "guild.h" +#include "../common/mmo.h" // struct party /** * Defines diff --git a/src/map/buyingstore.c b/src/map/buyingstore.c index 2a15e66fc..80264b30d 100644 --- a/src/map/buyingstore.c +++ b/src/map/buyingstore.c @@ -2,18 +2,21 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/db.h" // ARR_FIND -#include "../common/showmsg.h" // ShowWarning -#include "../common/socket.h" // RBUF* -#include "../common/strlib.h" // safestrncpy +#define HERCULES_CORE + +#include "buyingstore.h" // struct s_buyingstore + #include "atcommand.h" // msg_txt #include "battle.h" // battle_config.* -#include "buyingstore.h" // struct s_buyingstore +#include "chrif.h" #include "clif.h" // clif->buyingstore_* #include "log.h" // log_pick_pc, log_zeny #include "pc.h" // struct map_session_data -#include "chrif.h" +#include "../common/cbasetypes.h" +#include "../common/db.h" // ARR_FIND +#include "../common/showmsg.h" // ShowWarning +#include "../common/socket.h" // RBUF* +#include "../common/strlib.h" // safestrncpy struct buyingstore_interface buyingstore_s; diff --git a/src/map/buyingstore.h b/src/map/buyingstore.h index 5141a1013..914631872 100644 --- a/src/map/buyingstore.h +++ b/src/map/buyingstore.h @@ -5,6 +5,11 @@ #ifndef _MAP_BUYINGSTORE_H_ #define _MAP_BUYINGSTORE_H_ +#include "../common/cbasetypes.h" +#include "../common/mmo.h" // MAX_SLOTS + +struct map_session_data; + /** * Declarations **/ diff --git a/src/map/chat.c b/src/map/chat.c index 08fc4a575..c9d3e6d46 100644 --- a/src/map/chat.c +++ b/src/map/chat.c @@ -2,12 +2,13 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/mmo.h" +#define HERCULES_CORE + +#include "chat.h" + +#include <stdio.h> +#include <string.h> + #include "atcommand.h" // msg_txt() #include "battle.h" // struct battle_config #include "clif.h" @@ -15,10 +16,12 @@ #include "npc.h" // npc_event_do() #include "pc.h" #include "skill.h" // ext_skill_unit_onplace() -#include "chat.h" - -#include <stdio.h> -#include <string.h> +#include "../common/cbasetypes.h" +#include "../common/malloc.h" +#include "../common/mmo.h" +#include "../common/nullpo.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" struct chat_interface chat_s; diff --git a/src/map/chat.h b/src/map/chat.h index b0c6cd905..cbc2a391e 100644 --- a/src/map/chat.h +++ b/src/map/chat.h @@ -6,9 +6,12 @@ #define _MAP_CHAT_H_ #include "map.h" // struct block_list, CHATROOM_TITLE_SIZE +#include "../common/cbasetypes.h" +#include "../common/db.h" -struct map_session_data; struct chat_data; +struct map_session_data; +struct npc_data; #define MAX_CHAT_USERS 20 diff --git a/src/map/chrif.c b/src/map/chrif.c index 99a1935fd..81e2d387c 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -2,15 +2,16 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/malloc.h" -#include "../common/socket.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/ers.h" -#include "../common/HPM.h" +#define HERCULES_CORE + +#include "../config/core.h" // AUTOTRADE_PERSISTENCY, STATS_OPT_OUT +#include "chrif.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/types.h> +#include <time.h> #include "map.h" #include "battle.h" @@ -25,15 +26,17 @@ #include "instance.h" #include "mercenary.h" #include "elemental.h" -#include "chrif.h" #include "quest.h" #include "storage.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <sys/types.h> -#include <time.h> +#include "../common/HPM.h" +#include "../common/cbasetypes.h" +#include "../common/ers.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/timer.h" struct chrif_interface chrif_s; diff --git a/src/map/chrif.h b/src/map/chrif.h index 25e955604..84efc66d3 100644 --- a/src/map/chrif.h +++ b/src/map/chrif.h @@ -5,9 +5,11 @@ #ifndef _MAP_CHRIF_H_ #define _MAP_CHRIF_H_ -#include "../common/cbasetypes.h" #include <time.h> + #include "map.h" //TBL_stuff +#include "../common/cbasetypes.h" +#include "../common/db.h" struct status_change_entry; diff --git a/src/map/clif.c b/src/map/clif.c index 1a6665307..cb2474961 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -2,56 +2,59 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/socket.h" -#include "../common/timer.h" -#include "../common/grfio.h" -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/utils.h" -#include "../common/ers.h" -#include "../common/conf.h" -#include "../common/HPM.h" +#define HERCULES_CORE + +#include "../config/core.h" // ANTI_MAYAP_CHEAT, NEW_CARTS, RENEWAL, SECURE_NPCTIMEOUT +#include "clif.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <stdarg.h> +#include <time.h> -#include "map.h" -#include "chrif.h" -#include "pc.h" -#include "status.h" -#include "npc.h" -#include "itemdb.h" -#include "chat.h" -#include "trade.h" -#include "storage.h" -#include "script.h" -#include "skill.h" #include "atcommand.h" -#include "intif.h" #include "battle.h" #include "battleground.h" -#include "mob.h" -#include "party.h" -#include "unit.h" +#include "chat.h" +#include "chrif.h" +#include "elemental.h" #include "guild.h" -#include "vending.h" -#include "pet.h" #include "homunculus.h" #include "instance.h" -#include "mercenary.h" -#include "elemental.h" +#include "intif.h" +#include "irc-bot.h" +#include "itemdb.h" #include "log.h" -#include "clif.h" #include "mail.h" +#include "map.h" +#include "mercenary.h" +#include "mob.h" +#include "npc.h" +#include "party.h" +#include "pc.h" +#include "pet.h" #include "quest.h" -#include "irc-bot.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <stdarg.h> -#include <time.h> +#include "script.h" +#include "skill.h" +#include "status.h" +#include "storage.h" +#include "trade.h" +#include "unit.h" +#include "vending.h" +#include "../common/HPM.h" +#include "../common/cbasetypes.h" +#include "../common/conf.h" +#include "../common/ers.h" +#include "../common/grfio.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/timer.h" +#include "../common/utils.h" struct clif_interface clif_s; diff --git a/src/map/clif.h b/src/map/clif.h index 0f4a9e756..7b27e1fe6 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -5,13 +5,13 @@ #ifndef _MAP_CLIF_H_ #define _MAP_CLIF_H_ +#include <stdarg.h> + +#include "map.h" +#include "packets_struct.h" #include "../common/cbasetypes.h" #include "../common/db.h" #include "../common/mmo.h" -#include "../common/socket.h" -#include "../map/map.h" -#include "../map/packets_struct.h" -#include <stdarg.h> /** * Declarations @@ -20,7 +20,6 @@ struct item; struct item_data; struct storage_data; struct guild_storage; -struct block_list; struct unit_data; struct map_session_data; struct homun_data; diff --git a/src/map/date.c b/src/map/date.c index f38ead858..975a00c50 100644 --- a/src/map/date.c +++ b/src/map/date.c @@ -1,10 +1,14 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#include "../common/cbasetypes.h" +#define HERCULES_CORE + #include "date.h" + #include <time.h> +#include "../common/cbasetypes.h" + int date_get_year(void) { time_t t; diff --git a/src/map/date.h b/src/map/date.h index 46f0d86c3..b3ed59b2f 100644 --- a/src/map/date.h +++ b/src/map/date.h @@ -4,6 +4,8 @@ #ifndef _MAP_DATE_H_ #define _MAP_DATE_H_ +#include "../common/cbasetypes.h" + int date_get_year(void); int date_get_month(void); int date_get_day(void); diff --git a/src/map/duel.c b/src/map/duel.c index af2741f77..a423ef240 100644 --- a/src/map/duel.c +++ b/src/map/duel.c @@ -2,18 +2,20 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" +#define HERCULES_CORE -#include "atcommand.h" // msg_txt -#include "clif.h" #include "duel.h" -#include "pc.h" #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> +#include "atcommand.h" // msg_txt +#include "clif.h" +#include "pc.h" +#include "../common/cbasetypes.h" + /*========================================== * Duel organizing functions [LuzZza] *------------------------------------------*/ diff --git a/src/map/duel.h b/src/map/duel.h index 5405d2eee..956aed36d 100644 --- a/src/map/duel.h +++ b/src/map/duel.h @@ -5,6 +5,10 @@ #ifndef _MAP_DUEL_H_ #define _MAP_DUEL_H_ +#include "../common/cbasetypes.h" + +struct map_session_data; + struct duel { int members_count; int invites_count; diff --git a/src/map/elemental.c b/src/map/elemental.c index f335600d6..323df41e1 100644 --- a/src/map/elemental.c +++ b/src/map/elemental.c @@ -2,42 +2,44 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/malloc.h" -#include "../common/socket.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/mmo.h" -#include "../common/showmsg.h" -#include "../common/utils.h" -#include "../common/random.h" -#include "../common/strlib.h" +#define HERCULES_CORE -#include "log.h" -#include "clif.h" +#include "elemental.h" + +#include <math.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "atcommand.h" +#include "battle.h" #include "chrif.h" +#include "clif.h" +#include "guild.h" #include "intif.h" #include "itemdb.h" +#include "log.h" #include "map.h" -#include "pc.h" -#include "status.h" -#include "skill.h" #include "mob.h" -#include "pet.h" -#include "battle.h" +#include "npc.h" #include "party.h" -#include "guild.h" -#include "atcommand.h" +#include "pc.h" +#include "pet.h" #include "script.h" -#include "npc.h" +#include "skill.h" +#include "status.h" #include "trade.h" #include "unit.h" -#include "elemental.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <math.h> +#include "../common/cbasetypes.h" +#include "../common/malloc.h" +#include "../common/mmo.h" +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/timer.h" +#include "../common/utils.h" struct elemental_interface elemental_s; diff --git a/src/map/elemental.h b/src/map/elemental.h index 6d04a41a5..aa27aadc9 100644 --- a/src/map/elemental.h +++ b/src/map/elemental.h @@ -7,6 +7,7 @@ #include "status.h" // struct status_data, struct status_change #include "unit.h" // struct unit_data +#include "../common/mmo.h" // NAME_LENGTH /** * Defines diff --git a/src/map/guild.c b/src/map/guild.c index fa5805c8b..69f67238d 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -2,35 +2,38 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/malloc.h" -#include "../common/mapindex.h" -#include "../common/showmsg.h" -#include "../common/ers.h" -#include "../common/strlib.h" -#include "../common/utils.h" -#include "../common/HPM.h" +#define HERCULES_CORE -#include "map.h" +#include "../config/core.h" // GP_BOUND_ITEMS #include "guild.h" -#include "storage.h" -#include "battle.h" -#include "npc.h" -#include "pc.h" -#include "status.h" -#include "mob.h" -#include "intif.h" -#include "clif.h" -#include "skill.h" -#include "log.h" -#include "instance.h" #include <stdio.h> #include <stdlib.h> #include <string.h> +#include "battle.h" +#include "clif.h" +#include "instance.h" +#include "intif.h" +#include "log.h" +#include "map.h" +#include "mob.h" +#include "npc.h" +#include "pc.h" +#include "skill.h" +#include "status.h" +#include "storage.h" +#include "../common/HPM.h" +#include "../common/cbasetypes.h" +#include "../common/ers.h" +#include "../common/malloc.h" +#include "../common/mapindex.h" +#include "../common/nullpo.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" +#include "../common/timer.h" +#include "../common/utils.h" + struct guild_interface guild_s; /*========================================== diff --git a/src/map/guild.h b/src/map/guild.h index b03bd664d..34e27a56c 100644 --- a/src/map/guild.h +++ b/src/map/guild.h @@ -5,18 +5,10 @@ #ifndef _MAP_GUILD_H_ #define _MAP_GUILD_H_ -//#include "../common/mmo.h" -#include "map.h" // NAME_LENGTH - -/** - * Declarations - **/ -struct guild; -struct guild_member; -struct guild_position; -struct guild_castle; -struct map_session_data; -struct mob_data; +#include "map.h" // EVENT_NAME_LENGTH, TBL_PC +#include "../common/cbasetypes.h" +#include "../common/db.h" +#include "../common/mmo.h" /** * Defines diff --git a/src/map/homunculus.c b/src/map/homunculus.c index ff9f7a5b1..b6a83d1cb 100644 --- a/src/map/homunculus.c +++ b/src/map/homunculus.c @@ -2,43 +2,45 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/malloc.h" -#include "../common/socket.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/mmo.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/utils.h" +#define HERCULES_CORE -#include "log.h" -#include "clif.h" +#include "../config/core.h" // DBPATH +#include "homunculus.h" + +#include <math.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "atcommand.h" +#include "battle.h" #include "chrif.h" +#include "clif.h" +#include "guild.h" #include "intif.h" #include "itemdb.h" +#include "log.h" #include "map.h" -#include "pc.h" -#include "status.h" -#include "skill.h" #include "mob.h" -#include "pet.h" -#include "battle.h" +#include "npc.h" #include "party.h" -#include "guild.h" -#include "atcommand.h" +#include "pc.h" +#include "pet.h" #include "script.h" -#include "npc.h" +#include "skill.h" +#include "status.h" #include "trade.h" #include "unit.h" - -#include "homunculus.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <math.h> +#include "../common/cbasetypes.h" +#include "../common/malloc.h" +#include "../common/mmo.h" +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/timer.h" +#include "../common/utils.h" struct homunculus_interface homunculus_s; diff --git a/src/map/homunculus.h b/src/map/homunculus.h index e6d59e30e..9eef6af5b 100644 --- a/src/map/homunculus.h +++ b/src/map/homunculus.h @@ -5,9 +5,10 @@ #ifndef _MAP_HOMUNCULUS_H_ #define _MAP_HOMUNCULUS_H_ +#include "pc.h" #include "status.h" // struct status_data, struct status_change #include "unit.h" // struct unit_data -#include "pc.h" +#include "../common/mmo.h" #define MAX_HOM_SKILL_REQUIRE 5 #define homdb_checkid(id) ((id) >= HM_CLASS_BASE && (id) <= HM_CLASS_MAX) diff --git a/src/map/instance.c b/src/map/instance.c index caf622b3d..5789d7dd6 100644 --- a/src/map/instance.c +++ b/src/map/instance.c @@ -2,30 +2,32 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/socket.h" -#include "../common/timer.h" -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/utils.h" -#include "../common/db.h" -#include "../common/HPM.h" +#define HERCULES_CORE -#include "clif.h" #include "instance.h" -#include "map.h" -#include "npc.h" -#include "party.h" -#include "pc.h" +#include <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <stdarg.h> #include <time.h> +#include "clif.h" +#include "map.h" +#include "npc.h" +#include "party.h" +#include "pc.h" +#include "../common/HPM.h" +#include "../common/cbasetypes.h" +#include "../common/db.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/timer.h" +#include "../common/utils.h" + struct instance_interface instance_s; /// Checks whether given instance id is valid or not. diff --git a/src/map/instance.h b/src/map/instance.h index 712a0f141..ae649eda7 100644 --- a/src/map/instance.h +++ b/src/map/instance.h @@ -6,8 +6,11 @@ #define _MAP_INSTANCE_H_ #include "script.h" // struct reg_db +#include "../common/cbasetypes.h" #include "../common/mmo.h" // struct point + struct block_list; +struct map_session_data; #define INSTANCE_NAME_LENGTH (60+1) diff --git a/src/map/intif.c b/src/map/intif.c index 6bd24368a..383150fbc 100644 --- a/src/map/intif.c +++ b/src/map/intif.c @@ -1,37 +1,40 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/malloc.h" -#include "../common/strlib.h" -#include "map.h" +#define HERCULES_CORE + +#include "../config/core.h" // GP_BOUND_ITEMS +#include "intif.h" + +#include <fcntl.h> +#include <signal.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/types.h> + +#include "atcommand.h" #include "battle.h" #include "chrif.h" #include "clif.h" -#include "pc.h" -#include "intif.h" -#include "log.h" -#include "storage.h" -#include "party.h" +#include "elemental.h" #include "guild.h" -#include "pet.h" -#include "atcommand.h" -#include "mercenary.h" #include "homunculus.h" -#include "elemental.h" +#include "log.h" #include "mail.h" +#include "map.h" +#include "mercenary.h" +#include "party.h" +#include "pc.h" +#include "pet.h" #include "quest.h" - -#include <sys/types.h> -#include <stdio.h> -#include <stdlib.h> -#include <signal.h> -#include <fcntl.h> -#include <string.h> - +#include "storage.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/timer.h" struct intif_interface intif_s; diff --git a/src/map/intif.h b/src/map/intif.h index 290dcfcdc..b6ee727f3 100644 --- a/src/map/intif.h +++ b/src/map/intif.h @@ -5,19 +5,22 @@ #ifndef _MAP_INTIF_H_ #define _MAP_INTIF_H_ +#include "../common/cbasetypes.h" /** * Declarations **/ -struct party_member; +struct auction_data; struct guild_member; struct guild_position; -struct s_pet; +struct guild_storage; +struct mail_message; +struct map_session_data; +struct party_member; +struct s_elemental; struct s_homunculus; struct s_mercenary; -struct s_elemental; -struct mail_message; -struct auction_data; +struct s_pet; /** * Defines diff --git a/src/map/irc-bot.c b/src/map/irc-bot.c index ff28082e7..6f016697f 100644 --- a/src/map/irc-bot.c +++ b/src/map/irc-bot.c @@ -2,23 +2,25 @@ // See the LICENSE file // Base Author: shennetsind @ http://hercules.ws -#include "../common/cbasetypes.h" -#include "../common/malloc.h" -#include "../common/strlib.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/timer.h" -#include "../common/random.h" +#define HERCULES_CORE -#include "map.h" -#include "pc.h" -#include "clif.h" #include "irc-bot.h" #include <stdio.h> #include <stdlib.h> #include <string.h> +#include "clif.h" +#include "map.h" +#include "pc.h" +#include "../common/cbasetypes.h" +#include "../common/malloc.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/timer.h" + //#define IRCBOT_DEBUG struct irc_bot_interface irc_bot_s; diff --git a/src/map/irc-bot.h b/src/map/irc-bot.h index c15a5d46a..60f03fca5 100644 --- a/src/map/irc-bot.h +++ b/src/map/irc-bot.h @@ -6,6 +6,8 @@ #ifndef _MAP_IRC_BOT_H_ #define _MAP_IRC_BOT_H_ +#include "../common/cbasetypes.h" + #define IRC_NICK_LENGTH 40 #define IRC_IDENT_LENGTH 40 #define IRC_HOST_LENGTH 63 diff --git a/src/map/itemdb.c b/src/map/itemdb.c index 5eeb90be5..1981f435c 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -2,23 +2,28 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/nullpo.h" -#include "../common/malloc.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/utils.h" -#include "../common/conf.h" +#define HERCULES_CORE + +#include "../config/core.h" // DBPATH, RENEWAL #include "itemdb.h" -#include "map.h" -#include "battle.h" // struct battle_config -#include "script.h" // item script processing -#include "pc.h" // W_MUSICAL, W_WHIP #include <stdio.h> #include <stdlib.h> #include <string.h> +#include "battle.h" // struct battle_config +#include "map.h" +#include "mob.h" // MAX_MOB_DB +#include "pc.h" // W_MUSICAL, W_WHIP +#include "script.h" // item script processing +#include "../common/conf.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" +#include "../common/utils.h" + struct itemdb_interface itemdb_s; /** diff --git a/src/map/itemdb.h b/src/map/itemdb.h index 77fb2e2ec..12766b288 100644 --- a/src/map/itemdb.h +++ b/src/map/itemdb.h @@ -5,9 +5,12 @@ #ifndef _MAP_ITEMDB_H_ #define _MAP_ITEMDB_H_ +#include "map.h" +#include "../common/cbasetypes.h" +#include "../common/conf.h" #include "../common/db.h" #include "../common/mmo.h" // ITEM_NAME_LENGTH -#include "map.h" +#include "../common/sql.h" /** * Declarations diff --git a/src/map/log.c b/src/map/log.c index 19a98f34b..523ef1d65 100644 --- a/src/map/log.c +++ b/src/map/log.c @@ -2,22 +2,25 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/sql.h" // SQL_INNODB -#include "../common/strlib.h" -#include "../common/nullpo.h" -#include "../common/showmsg.h" -#include "battle.h" -#include "itemdb.h" +#define HERCULES_CORE + #include "log.h" -#include "map.h" -#include "mob.h" -#include "pc.h" #include <stdio.h> #include <stdlib.h> #include <string.h> +#include "battle.h" +#include "itemdb.h" +#include "map.h" +#include "mob.h" +#include "pc.h" +#include "../common/cbasetypes.h" +#include "../common/nullpo.h" +#include "../common/showmsg.h" +#include "../common/sql.h" // SQL_INNODB +#include "../common/strlib.h" + struct log_interface log_s; /// obtain log type character for item/zeny logs diff --git a/src/map/log.h b/src/map/log.h index b2cb92c20..ecfedeac2 100644 --- a/src/map/log.h +++ b/src/map/log.h @@ -11,11 +11,10 @@ /** * Declarations **/ -struct block_list; -struct map_session_data; -struct mob_data; struct item; struct item_data; +struct map_session_data; +struct mob_data; /** * Defines diff --git a/src/map/mail.c b/src/map/mail.c index 371aa892f..7ba7d7470 100644 --- a/src/map/mail.c +++ b/src/map/mail.c @@ -2,19 +2,21 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/nullpo.h" -#include "../common/showmsg.h" +#define HERCULES_CORE #include "mail.h" -#include "atcommand.h" -#include "itemdb.h" -#include "clif.h" -#include "pc.h" -#include "log.h" #include <time.h> #include <string.h> +#include "atcommand.h" +#include "clif.h" +#include "itemdb.h" +#include "log.h" +#include "pc.h" +#include "../common/nullpo.h" +#include "../common/showmsg.h" + struct mail_interface mail_s; void mail_clear(struct map_session_data *sd) diff --git a/src/map/mail.h b/src/map/mail.h index 8df537ff3..30b032ef4 100644 --- a/src/map/mail.h +++ b/src/map/mail.h @@ -5,7 +5,11 @@ #ifndef _MAP_MAIL_H_ #define _MAP_MAIL_H_ -#include "../common/mmo.h" +#include "../common/cbasetypes.h" + +struct item; +struct mail_message; +struct map_session_data; struct mail_interface { void (*clear) (struct map_session_data *sd); diff --git a/src/map/map.c b/src/map/map.c index 315924e2e..01d3dbb9f 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -2,62 +2,66 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/core.h" -#include "../common/timer.h" -#include "../common/ers.h" -#include "../common/grfio.h" -#include "../common/malloc.h" -#include "../common/socket.h" // WFIFO*() -#include "../common/showmsg.h" -#include "../common/nullpo.h" -#include "../common/random.h" -#include "../common/strlib.h" -#include "../common/utils.h" -#include "../common/conf.h" -#include "../common/console.h" -#include "../common/HPM.h" +#define HERCULES_CORE +#include "../config/core.h" // CELL_NOSTACK, CIRCULAR_AREA, CONSOLE_INPUT, DBPATH, RENEWAL #include "map.h" -#include "path.h" + +#include <math.h> +#include <stdarg.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "HPMmap.h" +#include "atcommand.h" +#include "battle.h" +#include "battleground.h" +#include "chat.h" #include "chrif.h" #include "clif.h" #include "duel.h" +#include "elemental.h" +#include "guild.h" +#include "homunculus.h" +#include "instance.h" #include "intif.h" +#include "irc-bot.h" +#include "itemdb.h" +#include "log.h" +#include "mail.h" +#include "mapreg.h" +#include "mercenary.h" +#include "mob.h" #include "npc.h" +#include "npc.h" // npc_setcells(), npc_unsetcells() +#include "party.h" +#include "path.h" #include "pc.h" +#include "pet.h" +#include "quest.h" +#include "script.h" +#include "skill.h" #include "status.h" -#include "mob.h" -#include "npc.h" // npc_setcells(), npc_unsetcells() -#include "chat.h" -#include "itemdb.h" #include "storage.h" -#include "skill.h" #include "trade.h" -#include "party.h" #include "unit.h" -#include "battle.h" -#include "battleground.h" -#include "quest.h" -#include "script.h" -#include "mapreg.h" -#include "guild.h" -#include "pet.h" -#include "homunculus.h" -#include "instance.h" -#include "mercenary.h" -#include "elemental.h" -#include "atcommand.h" -#include "log.h" -#include "mail.h" -#include "irc-bot.h" -#include "HPMmap.h" +#include "../common/HPM.h" +#include "../common/cbasetypes.h" +#include "../common/conf.h" +#include "../common/console.h" +#include "../common/core.h" +#include "../common/ers.h" +#include "../common/grfio.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/socket.h" // WFIFO*() +#include "../common/strlib.h" +#include "../common/timer.h" +#include "../common/utils.h" -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <stdarg.h> -#include <math.h> #ifndef _WIN32 #include <unistd.h> #endif @@ -5482,8 +5486,8 @@ void map_cp_defaults(void) { map->cpsd->bl.y = MAP_DEFAULT_Y; map->cpsd->bl.m = map->mapname2mapid(MAP_DEFAULT); - console->addCommand("gm:info",CPCMD_A(gm_position)); - console->addCommand("gm:use",CPCMD_A(gm_use)); + console->input->addCommand("gm:info",CPCMD_A(gm_position)); + console->input->addCommand("gm:use",CPCMD_A(gm_use)); #endif } /* Hercules Plugin Mananger */ @@ -5839,7 +5843,7 @@ int do_init(int argc, char *argv[]) Sql_HerculesUpdateCheck(map->mysql_handle); #ifdef CONSOLE_INPUT - console->setSQL(map->mysql_handle); + console->input->setSQL(map->mysql_handle); #endif ShowStatus("Server is '"CL_GREEN"ready"CL_RESET"' and listening on port '"CL_WHITE"%d"CL_RESET"'.\n\n", map->port); diff --git a/src/map/map.h b/src/map/map.h index c61868b13..539b02ed8 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -5,18 +5,18 @@ #ifndef _MAP_MAP_H_ #define _MAP_MAP_H_ +#include <stdarg.h> + +#include "atcommand.h" #include "../common/cbasetypes.h" #include "../common/core.h" // CORE_ST_LAST #include "../common/mmo.h" #include "../common/mapindex.h" #include "../common/db.h" -#include "../config/core.h" #include "../common/sql.h" -#include "atcommand.h" -#include <stdarg.h> +struct mob_data; struct npc_data; -struct item_data; struct hChSysCh; enum E_MAPSERVER_ST { @@ -36,7 +36,6 @@ enum E_MAPSERVER_ST { #define NATURAL_HEAL_INTERVAL 500 #define MIN_FLOORITEM 2 #define MAX_FLOORITEM START_ACCOUNT_NUM -#define MAX_LEVEL 175 #define MAX_IGNORE_LIST 20 // official is 14 #define MAX_VENDING 12 #define MAX_MAP_SIZE (512*512) // Wasn't there something like this already? Can't find it.. [Shinryo] diff --git a/src/map/mapreg_sql.c b/src/map/mapreg_sql.c index 61c25f24e..f026fde00 100644 --- a/src/map/mapreg_sql.c +++ b/src/map/mapreg_sql.c @@ -2,6 +2,15 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams +#define HERCULES_CORE + +#include "mapreg.h" + +#include <stdlib.h> +#include <string.h> + +#include "map.h" // map->mysql_handle +#include "script.h" #include "../common/cbasetypes.h" #include "../common/db.h" #include "../common/ers.h" @@ -10,11 +19,6 @@ #include "../common/sql.h" #include "../common/strlib.h" #include "../common/timer.h" -#include "map.h" // map->mysql_handle -#include "script.h" -#include "mapreg.h" -#include <stdlib.h> -#include <string.h> struct mapreg_interface mapreg_s; diff --git a/src/map/mercenary.c b/src/map/mercenary.c index 495621014..26bc8c188 100644 --- a/src/map/mercenary.c +++ b/src/map/mercenary.c @@ -2,42 +2,44 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/malloc.h" -#include "../common/socket.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/mmo.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/utils.h" +#define HERCULES_CORE -#include "log.h" -#include "clif.h" +#include "mercenary.h" + +#include <math.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "atcommand.h" +#include "battle.h" #include "chrif.h" +#include "clif.h" +#include "guild.h" #include "intif.h" #include "itemdb.h" +#include "log.h" #include "map.h" -#include "pc.h" -#include "status.h" -#include "skill.h" #include "mob.h" -#include "pet.h" -#include "battle.h" +#include "npc.h" #include "party.h" -#include "guild.h" -#include "atcommand.h" +#include "pc.h" +#include "pet.h" #include "script.h" -#include "npc.h" +#include "skill.h" +#include "status.h" #include "trade.h" #include "unit.h" -#include "mercenary.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <math.h> +#include "../common/cbasetypes.h" +#include "../common/malloc.h" +#include "../common/mmo.h" +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/timer.h" +#include "../common/utils.h" struct mercenary_interface mercenary_s; diff --git a/src/map/mercenary.h b/src/map/mercenary.h index dd9266b2e..b998ac006 100644 --- a/src/map/mercenary.h +++ b/src/map/mercenary.h @@ -6,6 +6,7 @@ #include "status.h" // struct status_data, struct status_change #include "unit.h" // struct unit_data +#include "../common/cbasetypes.h" // number of cells that a mercenary can walk to from it's master before being warped #define MAX_MER_DISTANCE 15 diff --git a/src/map/mob.c b/src/map/mob.c index 8f12d4b1b..11ac74621 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -2,46 +2,49 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/timer.h" -#include "../common/db.h" -#include "../common/nullpo.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" -#include "../common/ers.h" -#include "../common/random.h" -#include "../common/strlib.h" -#include "../common/utils.h" -#include "../common/socket.h" +#define HERCULES_CORE -#include "map.h" -#include "path.h" -#include "clif.h" -#include "intif.h" -#include "pc.h" -#include "pet.h" -#include "status.h" +#include "../config/core.h" // AUTOLOOT_DISTANCE, DBPATH, DEFTYPE_MAX, DEFTYPE_MIN, RENEWAL_DROP, RENEWAL_EXP #include "mob.h" -#include "homunculus.h" -#include "mercenary.h" + +#include <math.h> +#include <stdarg.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "atcommand.h" +#include "battle.h" +#include "clif.h" +#include "date.h" #include "elemental.h" #include "guild.h" +#include "homunculus.h" +#include "intif.h" #include "itemdb.h" -#include "skill.h" -#include "battle.h" -#include "party.h" -#include "npc.h" #include "log.h" -#include "script.h" -#include "atcommand.h" -#include "date.h" +#include "map.h" +#include "mercenary.h" +#include "npc.h" +#include "party.h" +#include "path.h" +#include "pc.h" +#include "pet.h" #include "quest.h" - -#include <stdio.h> -#include <stdlib.h> -#include <stdarg.h> -#include <string.h> -#include <math.h> +#include "script.h" +#include "skill.h" +#include "status.h" +#include "../common/cbasetypes.h" +#include "../common/db.h" +#include "../common/ers.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/timer.h" +#include "../common/utils.h" struct mob_interface mob_s; diff --git a/src/map/mob.h b/src/map/mob.h index 80175b1db..d07f78c77 100644 --- a/src/map/mob.h +++ b/src/map/mob.h @@ -5,12 +5,11 @@ #ifndef _MAP_MOB_H_ #define _MAP_MOB_H_ -#include "../common/mmo.h" // struct item -#include "guild.h" // struct guardian_data #include "map.h" // struct status_data, struct view_data, struct mob_skill -#include "status.h" // struct status data, struct status_change -#include "unit.h" // unit_stop_walking(), unit_stop_attack() -#include "npc.h" +#include "status.h" // struct status_data, struct status_change +#include "unit.h" // struct unit_data +#include "../common/cbasetypes.h" +#include "../common/mmo.h" // struct item #define MAX_RANDOMMONSTER 5 diff --git a/src/map/npc.c b/src/map/npc.c index 20b500630..8e5854dbf 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -2,41 +2,44 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/utils.h" -#include "../common/ers.h" -#include "../common/db.h" -#include "../common/socket.h" -#include "../common/HPM.h" +#define HERCULES_CORE -#include "map.h" -#include "log.h" +#include "../config/core.h" // NPC_SECURE_TIMEOUT_INPUT, NPC_SECURE_TIMEOUT_MENU, NPC_SECURE_TIMEOUT_NEXT, SECURE_NPCTIMEOUT, SECURE_NPCTIMEOUT_INTERVAL +#include "npc.h" + +#include <errno.h> +#include <math.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <time.h> + +#include "battle.h" +#include "chat.h" #include "clif.h" +#include "instance.h" #include "intif.h" -#include "pc.h" -#include "status.h" #include "itemdb.h" -#include "script.h" +#include "log.h" +#include "map.h" #include "mob.h" +#include "pc.h" #include "pet.h" -#include "instance.h" -#include "battle.h" +#include "script.h" #include "skill.h" +#include "status.h" #include "unit.h" -#include "npc.h" -#include "chat.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <math.h> -#include <time.h> -#include <errno.h> +#include "../common/HPM.h" +#include "../common/cbasetypes.h" +#include "../common/db.h" +#include "../common/ers.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/timer.h" +#include "../common/utils.h" struct npc_interface npc_s; diff --git a/src/map/npc.h b/src/map/npc.h index c154b14d0..6e9686d33 100644 --- a/src/map/npc.h +++ b/src/map/npc.h @@ -8,10 +8,10 @@ #include "map.h" // struct block_list #include "status.h" // struct status_change #include "unit.h" // struct unit_data +#include "../common/cbasetypes.h" +#include "../common/db.h" struct HPluginData; -struct block_list; -struct npc_data; struct view_data; enum npc_parse_options { diff --git a/src/map/npc_chat.c b/src/map/npc_chat.c index 9d5639efc..f245ffea5 100644 --- a/src/map/npc_chat.c +++ b/src/map/npc_chat.c @@ -2,25 +2,27 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifdef PCRE_SUPPORT +#define HERCULES_CORE -#include "../common/timer.h" -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" +#ifdef PCRE_SUPPORT -#include "mob.h" // struct mob_data #include "npc.h" // struct npc_data -#include "pc.h" // struct map_session_data -#include "script.h" // set_var() - -#include "../../3rdparty/pcre/include/pcre.h" +#include <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <stdarg.h> + +#include "../../3rdparty/pcre/include/pcre.h" + +#include "mob.h" // struct mob_data +#include "pc.h" // struct map_session_data +#include "script.h" // set_var() +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" +#include "../common/timer.h" /** * interface sources diff --git a/src/map/party.c b/src/map/party.c index cf5e7bbe3..7c49e241c 100644 --- a/src/map/party.c +++ b/src/map/party.c @@ -2,34 +2,37 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/timer.h" -#include "../common/socket.h" // last_tick -#include "../common/nullpo.h" -#include "../common/malloc.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/utils.h" -#include "../common/strlib.h" -#include "../common/HPM.h" +#define HERCULES_CORE +#include "../config/core.h" // GP_BOUND_ITEMS, RENEWAL_EXP #include "party.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + #include "atcommand.h" //msg_txt() -#include "pc.h" -#include "map.h" -#include "instance.h" #include "battle.h" -#include "intif.h" #include "clif.h" +#include "instance.h" +#include "intif.h" +#include "itemdb.h" #include "log.h" +#include "map.h" +#include "mob.h" // struct mob_data +#include "pc.h" #include "skill.h" #include "status.h" -#include "itemdb.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - +#include "../common/HPM.h" +#include "../common/cbasetypes.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/socket.h" // last_tick +#include "../common/strlib.h" +#include "../common/timer.h" +#include "../common/utils.h" struct party_interface party_s; diff --git a/src/map/party.h b/src/map/party.h index ed8289af6..3bad22b13 100644 --- a/src/map/party.h +++ b/src/map/party.h @@ -5,11 +5,12 @@ #ifndef _MAP_PARTY_H_ #define _MAP_PARTY_H_ -#include "../common/mmo.h" // struct party -#include "../config/core.h" #include <stdarg.h> -#include "map.h" +#include "map.h" // TBL_PC +#include "../common/cbasetypes.h" +#include "../common/db.h" +#include "../common/mmo.h" // struct party #define PARTY_BOOKING_JOBS 6 #define PARTY_BOOKING_RESULTS 10 diff --git a/src/map/path.c b/src/map/path.c index ae9fc389d..d02e9ee4a 100644 --- a/src/map/path.c +++ b/src/map/path.c @@ -2,20 +2,23 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/db.h" -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/random.h" -#include "../common/showmsg.h" +#define HERCULES_CORE +#include "../config/core.h" // CELL_NOSTACK, CIRCULAR_AREA #include "path.h" -#include "map.h" #include <stdio.h> #include <stdlib.h> #include <string.h> +#include "map.h" +#include "../common/cbasetypes.h" +#include "../common/db.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" + #define SET_OPEN 0 #define SET_CLOSED 1 diff --git a/src/map/path.h b/src/map/path.h index 0b67a0120..b48ff05fb 100644 --- a/src/map/path.h +++ b/src/map/path.h @@ -6,6 +6,7 @@ #define _MAP_PATH_H_ #include "map.h" // enum cell_chk +#include "../common/cbasetypes.h" #define MOVE_COST 10 #define MOVE_DIAGONAL_COST 14 diff --git a/src/map/pc.c b/src/map/pc.c index c8fb14e55..45adfe22a 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -2,21 +2,16 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/core.h" // get_svn_revision() -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/socket.h" // session[] -#include "../common/strlib.h" // safestrncpy() -#include "../common/timer.h" -#include "../common/utils.h" -#include "../common/conf.h" -#include "../common/mmo.h" //NAME_LENGTH -#include "../common/sysinfo.h" +#define HERCULES_CORE +#include "../config/core.h" // DBPATH, GP_BOUND_ITEMS, MAX_CARTS, MAX_SPIRITBALL, NEW_CARTS, RENEWAL, RENEWAL_ASPD, RENEWAL_CAST, RENEWAL_DROP, RENEWAL_EXP, SECURE_NPCTIMEOUT #include "pc.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <time.h> + #include "atcommand.h" // get_atcommand_level() #include "battle.h" // battle_config #include "battleground.h" @@ -25,32 +20,40 @@ #include "clif.h" #include "date.h" // is_day_of_*() #include "duel.h" +#include "elemental.h" +#include "guild.h" // guild->search(), guild_request_info() +#include "homunculus.h" +#include "instance.h" #include "intif.h" #include "itemdb.h" #include "log.h" #include "mail.h" #include "map.h" -#include "path.h" -#include "homunculus.h" -#include "instance.h" #include "mercenary.h" -#include "elemental.h" +#include "mob.h" // struct mob_data #include "npc.h" // fake_nd -#include "pet.h" // pet_unlocktarget() #include "party.h" // party->search() -#include "guild.h" // guild->search(), guild_request_info() +#include "path.h" +#include "pc_groups.h" +#include "pet.h" // pet_unlocktarget() +#include "quest.h" #include "script.h" // script_config #include "skill.h" #include "status.h" // struct status_data #include "storage.h" -#include "pc_groups.h" -#include "quest.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <time.h> - +#include "../common/cbasetypes.h" +#include "../common/conf.h" +#include "../common/core.h" // get_svn_revision() +#include "../common/malloc.h" +#include "../common/mmo.h" //NAME_LENGTH +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/socket.h" // session[] +#include "../common/strlib.h" // safestrncpy() +#include "../common/sysinfo.h" +#include "../common/timer.h" +#include "../common/utils.h" struct pc_interface pc_s; @@ -10651,9 +10654,7 @@ void pc_defaults(void) { memset(pc->exp_table, 0, sizeof(pc->exp_table) + sizeof(pc->max_level) + sizeof(pc->statp) -#if defined(RENEWAL_DROP) || defined(RENEWAL_EXP) + sizeof(pc->level_penalty) -#endif + sizeof(pc->skill_tree) + sizeof(pc->smith_fame_list) + sizeof(pc->chemist_fame_list) diff --git a/src/map/pc.h b/src/map/pc.h index 70df9ca56..c4026a48d 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -5,23 +5,23 @@ #ifndef _MAP_PC_H_ #define _MAP_PC_H_ -#include "../common/mmo.h" // JOB_*, MAX_FAME_LIST, struct fame_list, struct mmo_charstatus -#include "../common/ers.h" -#include "../common/timer.h" // INVALID_TIMER -#include "atcommand.h" // AtCommandType +#include "../config/core.h" // AUTOLOOTITEM_SIZE, RENEWAL, SECURE_NPCTIMEOUT + #include "battle.h" // battle_config -#include "battleground.h" +#include "battleground.h" // enum bg_queue_types #include "buyingstore.h" // struct s_buyingstore -#include "itemdb.h" -#include "log.h" -#include "map.h" // RC_MAX -#include "mob.h" -#include "pc_groups.h" -#include "script.h" // struct script_reg, struct script_regstr +#include "itemdb.h" // MAX_ITEMDELAYS +#include "log.h" // struct e_log_pick_type +#include "map.h" // RC_MAX, ELE_MAX +#include "pc_groups.h" // GroupSettings +#include "script.h" // struct reg_db #include "searchstore.h" // struct s_search_store_info -#include "status.h" // OPTION_*, struct weapon_atk -#include "unit.h" // unit_stop_attack(), unit_stop_walking() +#include "status.h" // enum sc_type, OPTION_* +#include "unit.h" // struct unit_data, struct view_data #include "vending.h" // struct s_vending +#include "../common/cbasetypes.h" +#include "../common/ers.h" // struct eri +#include "../common/mmo.h" // JOB_*, MAX_FAME_LIST, struct fame_list, struct mmo_charstatus /** * Defines @@ -742,9 +742,8 @@ struct pc_interface { unsigned int exp_table[CLASS_COUNT][2][MAX_LEVEL]; unsigned int max_level[CLASS_COUNT][2]; unsigned int statp[MAX_LEVEL+1]; -#if defined(RENEWAL_DROP) || defined(RENEWAL_EXP) unsigned int level_penalty[3][RC_MAX][MAX_LEVEL*2+1]; -#endif + unsigned int equip_pos[EQI_MAX]; /* */ struct skill_tree_entry skill_tree[CLASS_COUNT][MAX_SKILL_TREE]; diff --git a/src/map/pc_groups.c b/src/map/pc_groups.c index 906462c7e..a917ef409 100644 --- a/src/map/pc_groups.c +++ b/src/map/pc_groups.c @@ -2,6 +2,14 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams +#define HERCULES_CORE + +#include "pc_groups.h" + +#include "atcommand.h" // atcommand->exists(), atcommand->load_groups() +#include "clif.h" // clif->GM_kick() +#include "map.h" // mapiterator +#include "pc.h" // pc->set_group() #include "../common/cbasetypes.h" #include "../common/conf.h" #include "../common/db.h" @@ -10,12 +18,6 @@ #include "../common/showmsg.h" #include "../common/strlib.h" // strcmp -#include "pc_groups.h" -#include "atcommand.h" // atcommand->exists(), atcommand->load_groups() -#include "clif.h" // clif->GM_kick() -#include "map.h" // mapiterator -#include "pc.h" // pc->set_group() - static GroupSettings dummy_group; ///< dummy group used in dummy map sessions @see pc_get_dummy_sd() struct pc_groups_interface pcg_s; diff --git a/src/map/pc_groups.h b/src/map/pc_groups.h index 5c03f999f..7c8cdd82a 100644 --- a/src/map/pc_groups.h +++ b/src/map/pc_groups.h @@ -5,6 +5,10 @@ #ifndef _MAP_PC_GROUPS_H_ #define _MAP_PC_GROUPS_H_ +#include "../common/cbasetypes.h" +#include "../common/conf.h" +#include "../common/db.h" + /// PC permissions enum e_pc_permission { PC_PERM_NONE = 0, // #0 diff --git a/src/map/pet.c b/src/map/pet.c index 993497434..aa2be4473 100644 --- a/src/map/pet.c +++ b/src/map/pet.c @@ -2,37 +2,39 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/db.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/malloc.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/utils.h" -#include "../common/ers.h" +#define HERCULES_CORE -#include "pc.h" -#include "status.h" -#include "map.h" -#include "path.h" -#include "intif.h" -#include "clif.h" -#include "chrif.h" #include "pet.h" -#include "itemdb.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "atcommand.h" // msg_txt() #include "battle.h" +#include "chrif.h" +#include "clif.h" +#include "intif.h" +#include "itemdb.h" +#include "log.h" +#include "map.h" #include "mob.h" #include "npc.h" +#include "path.h" +#include "pc.h" #include "script.h" #include "skill.h" +#include "status.h" #include "unit.h" -#include "atcommand.h" // msg_txt() -#include "log.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> +#include "../common/db.h" +#include "../common/ers.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" +#include "../common/timer.h" +#include "../common/utils.h" struct pet_interface pet_s; diff --git a/src/map/pet.h b/src/map/pet.h index 4ec30b3fb..8dde0fac2 100644 --- a/src/map/pet.h +++ b/src/map/pet.h @@ -5,8 +5,14 @@ #ifndef _MAP_PET_H_ #define _MAP_PET_H_ -#define MAX_PET_DB 300 -#define MAX_PETLOOT_SIZE 30 +#include "map.h" // struct block_list +#include "status.h" // enum sc_type +#include "unit.h" // struct unit_data +#include "../common/cbasetypes.h" +#include "../common/mmo.h" // NAME_LENGTH, struct s_pet + +#define MAX_PET_DB 300 +#define MAX_PETLOOT_SIZE 30 struct s_pet_db { short class_; diff --git a/src/map/quest.c b/src/map/quest.c index bde276f9d..b76d6bc82 100644 --- a/src/map/quest.c +++ b/src/map/quest.c @@ -2,36 +2,37 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/socket.h" -#include "../common/timer.h" -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/utils.h" +#define HERCULES_CORE -#include "map.h" -#include "pc.h" -#include "npc.h" -#include "itemdb.h" -#include "script.h" -#include "intif.h" -#include "battle.h" -#include "mob.h" -#include "party.h" -#include "unit.h" -#include "log.h" -#include "clif.h" #include "quest.h" -#include "chrif.h" +#include <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <stdarg.h> #include <time.h> +#include "battle.h" +#include "chrif.h" +#include "clif.h" +#include "intif.h" +#include "itemdb.h" +#include "log.h" +#include "map.h" +#include "mob.h" +#include "npc.h" +#include "party.h" +#include "pc.h" +#include "script.h" +#include "unit.h" +#include "../common/cbasetypes.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/timer.h" +#include "../common/utils.h" struct quest_interface quest_s; diff --git a/src/map/quest.h b/src/map/quest.h index e01e35619..87894d639 100644 --- a/src/map/quest.h +++ b/src/map/quest.h @@ -5,6 +5,10 @@ #ifndef _MAP_QUEST_H_ #define _MAP_QUEST_H_ +#include "map.h" // TBL_PC +#include "../common/cbasetypes.h" +#include "../common/mmo.h" // MAX_QUEST_OBJECTIVES + #define MAX_QUEST_DB (60355+1) // Highest quest ID + 1 struct quest_db { diff --git a/src/map/script.c b/src/map/script.c index 4d77c506b..068be8524 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -2,6 +2,46 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams +#define HERCULES_CORE + +#include "../config/core.h" // NEW_CARTS, RENEWAL, RENEWAL_ASPD, RENEWAL_CAST, RENEWAL_DROP, RENEWAL_EDP, RENEWAL_EXP, RENEWAL_LVDMG, SCRIPT_CALLFUNC_CHECK, SECURE_NPCTIMEOUT, SECURE_NPCTIMEOUT_INTERVAL +#include "script.h" + +#include <math.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "atcommand.h" +#include "battle.h" +#include "battleground.h" +#include "chat.h" +#include "chrif.h" +#include "clif.h" +#include "elemental.h" +#include "guild.h" +#include "homunculus.h" +#include "instance.h" +#include "intif.h" +#include "itemdb.h" +#include "log.h" +#include "mail.h" +#include "map.h" +#include "mapreg.h" +#include "mercenary.h" +#include "mob.h" +#include "npc.h" +#include "party.h" +#include "path.h" +#include "pc.h" +#include "pet.h" +#include "pet.h" +#include "quest.h" +#include "skill.h" +#include "status.h" +#include "status.h" +#include "storage.h" +#include "unit.h" #include "../common/cbasetypes.h" #include "../common/malloc.h" #include "../common/md5calc.h" @@ -10,47 +50,10 @@ #include "../common/showmsg.h" #include "../common/socket.h" // usage: getcharip #include "../common/strlib.h" +#include "../common/sysinfo.h" #include "../common/timer.h" #include "../common/utils.h" -#include "../common/sysinfo.h" - -#include "map.h" -#include "path.h" -#include "clif.h" -#include "chrif.h" -#include "itemdb.h" -#include "pc.h" -#include "status.h" -#include "storage.h" -#include "mob.h" -#include "npc.h" -#include "pet.h" -#include "mapreg.h" -#include "homunculus.h" -#include "instance.h" -#include "mercenary.h" -#include "intif.h" -#include "skill.h" -#include "status.h" -#include "chat.h" -#include "battle.h" -#include "battleground.h" -#include "party.h" -#include "guild.h" -#include "atcommand.h" -#include "log.h" -#include "unit.h" -#include "pet.h" -#include "mail.h" -#include "script.h" -#include "quest.h" -#include "elemental.h" -#include "../config/core.h" -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <math.h> #ifndef WIN32 #include <sys/time.h> #endif diff --git a/src/map/script.h b/src/map/script.h index 90b18d87f..899c745da 100644 --- a/src/map/script.h +++ b/src/map/script.h @@ -5,17 +5,19 @@ #ifndef _MAP_SCRIPT_H_ #define _MAP_SCRIPT_H_ -#include "../common/strlib.h" //StringBuf -#include "../common/cbasetypes.h" -#include "map.h" //EVENT_NAME_LENGTH - #include <setjmp.h> #include <errno.h> +#include "map.h" //EVENT_NAME_LENGTH +#include "../common/cbasetypes.h" +#include "../common/db.h" +#include "../common/mmo.h" // struct item +#include "../common/sql.h" // Sql +#include "../common/strlib.h" //StringBuf + /** * Declarations **/ -struct map_session_data; struct eri; /** diff --git a/src/map/searchstore.c b/src/map/searchstore.c index 0144aea93..72b28aacd 100644 --- a/src/map/searchstore.c +++ b/src/map/searchstore.c @@ -2,14 +2,17 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams +#define HERCULES_CORE + +#include "searchstore.h" // struct s_search_store_info + +#include "battle.h" // battle_config.* +#include "clif.h" // clif->open_search_store_info, clif->search_store_info_* +#include "pc.h" // struct map_session_data #include "../common/cbasetypes.h" #include "../common/malloc.h" // aMalloc, aRealloc, aFree #include "../common/showmsg.h" // ShowError, ShowWarning #include "../common/strlib.h" // safestrncpy -#include "battle.h" // battle_config.* -#include "clif.h" // clif->open_search_store_info, clif->search_store_info_* -#include "pc.h" // struct map_session_data -#include "searchstore.h" // struct s_search_store_info struct searchstore_interface searchstore_s; diff --git a/src/map/searchstore.h b/src/map/searchstore.h index 827e39053..c9b93ba54 100644 --- a/src/map/searchstore.h +++ b/src/map/searchstore.h @@ -5,6 +5,12 @@ #ifndef _MAP_SEARCHSTORE_H_ #define _MAP_SEARCHSTORE_H_ +#include <time.h> + +#include "map.h" // MESSAGE_SIZE +#include "../common/cbasetypes.h" +#include "../common/mmo.h" // MAX_SLOTS + /** * Defines **/ diff --git a/src/map/skill.c b/src/map/skill.c index c8388770a..b2e94ec79 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -2,46 +2,48 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/malloc.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/utils.h" -#include "../common/ers.h" +#define HERCULES_CORE -#include "map.h" -#include "path.h" -#include "clif.h" -#include "pc.h" -#include "status.h" +#include "../config/core.h" // DBPATH, MAGIC_REFLECTION_TYPE, OFFICIAL_WALKPATH, RENEWAL, RENEWAL_CAST, VARCAST_REDUCTION() #include "skill.h" -#include "pet.h" + +#include <math.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <time.h> + +#include "battle.h" +#include "battleground.h" +#include "chrif.h" +#include "clif.h" +#include "date.h" +#include "elemental.h" +#include "guild.h" #include "homunculus.h" +#include "intif.h" +#include "itemdb.h" +#include "log.h" +#include "map.h" #include "mercenary.h" -#include "elemental.h" #include "mob.h" #include "npc.h" -#include "battle.h" -#include "battleground.h" #include "party.h" -#include "itemdb.h" +#include "path.h" +#include "pc.h" +#include "pet.h" #include "script.h" -#include "intif.h" -#include "log.h" -#include "chrif.h" -#include "guild.h" -#include "date.h" +#include "status.h" #include "unit.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <time.h> -#include <math.h> - +#include "../common/cbasetypes.h" +#include "../common/ers.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" +#include "../common/timer.h" +#include "../common/utils.h" #define SKILLUNITTIMER_INTERVAL 100 diff --git a/src/map/skill.h b/src/map/skill.h index dda310bd4..b6dbb1fcb 100644 --- a/src/map/skill.h +++ b/src/map/skill.h @@ -5,19 +5,23 @@ #ifndef _MAP_SKILL_H_ #define _MAP_SKILL_H_ -#include "../common/mmo.h" // MAX_SKILL, struct square -#include "../common/db.h" +#include "../config/core.h" // RENEWAL_CAST + #include "map.h" // struct block_list +#include "status.h" // enum sc_type +#include "../common/cbasetypes.h" +#include "../common/db.h" +#include "../common/mmo.h" // MAX_SKILL, struct square /** * Declarations **/ -struct map_session_data; struct homun_data; +struct map_session_data; +struct mercenary_data; struct skill_unit; -struct skill_unit_group; -struct status_change_entry; struct square; +struct status_change_entry; /** * Defines diff --git a/src/map/status.c b/src/map/status.c index 4c2bc6d22..eb06138da 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -2,43 +2,46 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/malloc.h" -#include "../common/utils.h" -#include "../common/ers.h" -#include "../common/strlib.h" +#define HERCULES_CORE + +#include "../config/core.h" // ANTI_MAYAP_CHEAT, DBPATH, DEFTYPE_MAX, DEFTYPE_MIN, DEVOTION_REFLECT_DAMAGE, RENEWAL, RENEWAL_ASPD, RENEWAL_EDP +#include "status.h" +#include <math.h> +#include <memory.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <time.h> + +#include "battle.h" +#include "chrif.h" +#include "clif.h" +#include "elemental.h" +#include "guild.h" +#include "homunculus.h" +#include "itemdb.h" #include "map.h" +#include "mercenary.h" +#include "mob.h" +#include "npc.h" #include "path.h" #include "pc.h" #include "pet.h" -#include "npc.h" -#include "mob.h" -#include "clif.h" -#include "guild.h" +#include "script.h" #include "skill.h" -#include "itemdb.h" -#include "battle.h" -#include "chrif.h" #include "skill.h" -#include "status.h" -#include "script.h" #include "unit.h" -#include "homunculus.h" -#include "mercenary.h" -#include "elemental.h" #include "vending.h" - -#include <time.h> -#include <stdio.h> -#include <stdlib.h> -#include <memory.h> -#include <string.h> -#include <math.h> +#include "../common/cbasetypes.h" +#include "../common/ers.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" +#include "../common/timer.h" +#include "../common/utils.h" struct status_interface status_s; diff --git a/src/map/status.h b/src/map/status.h index e47c2b365..baa586297 100644 --- a/src/map/status.h +++ b/src/map/status.h @@ -5,14 +5,18 @@ #ifndef _MAP_STATUS_H_ #define _MAP_STATUS_H_ +#include "../config/core.h" // defType, NEW_CARTS, RENEWAL, RENEWAL_ASPD + +#include "../common/cbasetypes.h" #include "../common/mmo.h" struct block_list; -struct mob_data; -struct pet_data; +struct elemental_data; struct homun_data; struct mercenary_data; -struct status_change; +struct mob_data; +struct npc_data; +struct pet_data; //Change the equation when the values are high enough to discard the //imprecision in exchange of overflow protection [Skotlex] @@ -1878,11 +1882,7 @@ struct status_interface { int hp_coefficient2[CLASS_COUNT]; int hp_sigma_val[CLASS_COUNT][MAX_LEVEL+1]; int sp_coefficient[CLASS_COUNT]; -#ifdef RENEWAL_ASPD - int aspd_base[CLASS_COUNT][MAX_WEAPON_TYPE+1]; -#else - int aspd_base[CLASS_COUNT][MAX_WEAPON_TYPE]; //[blackhole89] -#endif + int aspd_base[CLASS_COUNT][MAX_WEAPON_TYPE+1]; // +1 for RENEWAL_ASPD sc_type Skill2SCTable[MAX_SKILL]; // skill -> status int IconChangeTable[SC_MAX]; // status -> "icon" (icon is a bit of a misnomer, since there exist values with no icon associated) unsigned int ChangeFlagTable[SC_MAX]; // status -> flags diff --git a/src/map/storage.c b/src/map/storage.c index e65ed7b80..2db5fff3d 100644 --- a/src/map/storage.c +++ b/src/map/storage.c @@ -2,28 +2,30 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/db.h" -#include "../common/nullpo.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" +#define HERCULES_CORE -#include "map.h" // struct map_session_data #include "storage.h" -#include "chrif.h" -#include "itemdb.h" -#include "clif.h" -#include "intif.h" -#include "pc.h" -#include "guild.h" -#include "battle.h" -#include "atcommand.h" -#include "log.h" #include <stdio.h> #include <stdlib.h> #include <string.h> +#include "atcommand.h" +#include "battle.h" +#include "chrif.h" +#include "clif.h" +#include "guild.h" +#include "intif.h" +#include "itemdb.h" +#include "log.h" +#include "map.h" // struct map_session_data +#include "pc.h" +#include "../common/cbasetypes.h" +#include "../common/db.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/showmsg.h" + struct storage_interface storage_s; struct guild_storage_interface gstorage_s; diff --git a/src/map/storage.h b/src/map/storage.h index 8f9f904f6..5edb68cfc 100644 --- a/src/map/storage.h +++ b/src/map/storage.h @@ -5,11 +5,12 @@ #ifndef _MAP_STORAGE_H_ #define _MAP_STORAGE_H_ -struct storage_data; +#include "../common/cbasetypes.h" +#include "../common/db.h" + struct guild_storage; struct item; struct map_session_data; -struct DBMap; struct storage_interface { /* */ diff --git a/src/map/trade.c b/src/map/trade.c index 44b669ebd..83426c407 100644 --- a/src/map/trade.c +++ b/src/map/trade.c @@ -2,25 +2,27 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/nullpo.h" -#include "../common/socket.h" +#define HERCULES_CORE #include "trade.h" + +#include <stdio.h> +#include <string.h> + +#include "atcommand.h" +#include "battle.h" +#include "chrif.h" #include "clif.h" +#include "intif.h" #include "itemdb.h" +#include "log.h" #include "map.h" +#include "npc.h" #include "path.h" #include "pc.h" -#include "npc.h" -#include "battle.h" -#include "chrif.h" #include "storage.h" -#include "intif.h" -#include "atcommand.h" -#include "log.h" - -#include <stdio.h> -#include <string.h> +#include "../common/nullpo.h" +#include "../common/socket.h" struct trade_interface trade_s; diff --git a/src/map/unit.c b/src/map/unit.c index 151d4bad5..0ad770e80 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -2,45 +2,48 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/showmsg.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/db.h" -#include "../common/malloc.h" -#include "../common/random.h" -#include "../common/HPM.h" +#define HERCULES_CORE +#include "../config/core.h" // RENEWAL_CAST +#include "unit.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "battle.h" +#include "battleground.h" +#include "chat.h" +#include "chrif.h" +#include "clif.h" +#include "duel.h" +#include "elemental.h" +#include "guild.h" +#include "homunculus.h" +#include "instance.h" +#include "intif.h" #include "map.h" +#include "mercenary.h" +#include "mob.h" +#include "npc.h" +#include "party.h" #include "path.h" #include "pc.h" -#include "mob.h" #include "pet.h" -#include "homunculus.h" -#include "instance.h" -#include "mercenary.h" -#include "elemental.h" +#include "script.h" #include "skill.h" -#include "clif.h" -#include "duel.h" -#include "npc.h" -#include "guild.h" #include "status.h" -#include "unit.h" -#include "battle.h" -#include "battleground.h" -#include "chat.h" +#include "storage.h" #include "trade.h" #include "vending.h" -#include "party.h" -#include "intif.h" -#include "chrif.h" -#include "script.h" -#include "storage.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - +#include "../common/HPM.h" +#include "../common/db.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/timer.h" const short dirx[8]={0,-1,-1,-1,0,1,1,1}; const short diry[8]={1,1,0,-1,-1,-1,0,1}; diff --git a/src/map/unit.h b/src/map/unit.h index 33fa4e052..9e05647b1 100644 --- a/src/map/unit.h +++ b/src/map/unit.h @@ -5,15 +5,13 @@ #ifndef _MAP_UNIT_H_ #define _MAP_UNIT_H_ -//#include "map.h" -struct block_list; -struct unit_data; -struct map_session_data; - #include "clif.h" // clr_type -#include "map.h" // struct block_list #include "path.h" // struct walkpath_data -#include "skill.h" // struct skill_timerskill, struct skill_unit_group, struct skill_unit_group_tickset +#include "skill.h" // 'MAX_SKILLTIMERSKILL, struct skill_timerskill, struct skill_unit_group, struct skill_unit_group_tickset +#include "../common/cbasetypes.h" + +struct map_session_data; +struct block_list; struct unit_data { struct block_list *bl; diff --git a/src/map/vending.c b/src/map/vending.c index 9462975b3..c8ac814db 100644 --- a/src/map/vending.c +++ b/src/map/vending.c @@ -2,24 +2,27 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/nullpo.h" -#include "../common/strlib.h" -#include "../common/utils.h" +#define HERCULES_CORE + +#include "vending.h" + +#include <stdio.h> +#include <string.h> + +#include "atcommand.h" +#include "battle.h" +#include "chrif.h" #include "clif.h" #include "itemdb.h" -#include "atcommand.h" +#include "log.h" #include "map.h" +#include "npc.h" #include "path.h" -#include "chrif.h" -#include "vending.h" #include "pc.h" -#include "npc.h" #include "skill.h" -#include "battle.h" -#include "log.h" - -#include <stdio.h> -#include <string.h> +#include "../common/nullpo.h" +#include "../common/strlib.h" +#include "../common/utils.h" struct vending_interface vending_s; diff --git a/src/map/vending.h b/src/map/vending.h index a212f8385..a70726374 100644 --- a/src/map/vending.h +++ b/src/map/vending.h @@ -7,6 +7,7 @@ #include "../common/cbasetypes.h" #include "../common/db.h" + struct map_session_data; struct s_search_store_search; diff --git a/src/tool/mapcache.c b/src/tool/mapcache.c index 85d5fb548..96d51aec6 100644 --- a/src/tool/mapcache.c +++ b/src/tool/mapcache.c @@ -1,6 +1,14 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder +#define HERCULES_CORE + +#include "../config/core.h" // RENEWAL + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + #include "../common/cbasetypes.h" #include "../common/grfio.h" #include "../common/malloc.h" @@ -8,12 +16,6 @@ #include "../common/showmsg.h" #include "../common/utils.h" -#include "../config/renewal.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - #ifndef _WIN32 #include <unistd.h> #endif -- cgit v1.2.3-70-g09d2 From 5d67f33135a5305665f78307e03fa9aee7aa544b Mon Sep 17 00:00:00 2001 From: Haru <haru@dotalux.com> Date: Tue, 13 May 2014 18:17:52 +0200 Subject: Removed trailing whitespace (sources) Signed-off-by: Haru <haru@dotalux.com> --- src/char/char.c | 12 +- src/char/int_auction.c | 2 +- src/char/int_party.c | 6 +- src/char/int_party.h | 2 +- src/common/HPM.c | 4 +- src/common/atomic.h | 8 +- src/common/cbasetypes.h | 2 +- src/common/db.c | 28 +- src/common/db.h | 40 +- src/common/ers.c | 34 +- src/common/ers.h | 12 +- src/common/malloc.c | 4 +- src/common/mutex.c | 2 +- src/common/mutex.h | 34 +- src/common/nullpo.c | 2 +- src/common/showmsg.c | 34 +- src/common/socket.c | 8 +- src/common/spinlock.h | 4 +- src/common/sql.c | 5 +- src/common/sql.h | 6 +- src/common/strlib.c | 12 +- src/common/thread.c | 41 +- src/common/thread.h | 38 +- src/common/timer.c | 4 +- src/common/timer.h | 4 +- src/common/utils.c | 4 +- src/common/winapi.h | 4 +- src/config/const.h | 2 +- src/login/login.c | 6 +- src/map/atcommand.c | 12 +- src/map/battle.c | 35 +- src/map/battle.h | 4 +- src/map/chat.c | 6 +- src/map/chat.h | 4 +- src/map/chrif.c | 8 +- src/map/chrif.h | 2 +- src/map/clif.c | 32 +- src/map/duel.c | 4 +- src/map/duel.h | 2 +- src/map/elemental.c | 2 +- src/map/elemental.h | 2 +- src/map/guild.c | 6 +- src/map/intif.c | 2 +- src/map/intif.h | 4 +- src/map/itemdb.c | 17 +- src/map/map.c | 4 +- src/map/map.h | 6 +- src/map/mercenary.c | 2 +- src/map/mercenary.h | 2 +- src/map/mob.c | 2 +- src/map/npc.c | 4 +- src/map/npc_chat.c | 27 +- src/map/packets.h | 26 +- src/map/packets_struct.h | 2 +- src/map/party.c | 2 +- src/map/party.h | 2 +- src/map/path.c | 4 +- src/map/pc.c | 10 +- src/map/pc.h | 2 +- src/map/pc_groups.c | 2 +- src/map/pet.c | 28 +- src/map/skill.c | 42 +- src/map/skill.h | 2 +- src/map/sql/CMakeLists.txt | 2 +- src/map/status.c | 24 +- src/map/status.h | 1539 ++++++++++++++++++++++---------------------- src/map/unit.c | 8 +- src/map/vending.c | 2 +- src/plugins/db2sql.c | 2 +- src/plugins/dbghelpplug.c | 23 +- src/test/test_spinlock.c | 15 +- 71 files changed, 1147 insertions(+), 1143 deletions(-) (limited to 'src/map/elemental.c') diff --git a/src/char/char.c b/src/char/char.c index 6c0902644..289df62a4 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -797,7 +797,7 @@ int memitemdata_to_sql(const struct item items[], int max, int id, int tableswit StrBuf->Printf(&buf, "UPDATE `%s` SET `amount`='%d', `equip`='%d', `identify`='%d', `refine`='%d',`attribute`='%d', `expire_time`='%u', `bound`='%d'", tablename, items[i].amount, items[i].equip, items[i].identify, items[i].refine, items[i].attribute, items[i].expire_time, items[i].bound); for( j = 0; j < MAX_SLOTS; ++j )for( j = 0; j < MAX_SLOTS; ++j ) - StrBuf->Printf(&buf, ", `card%d`=%d", j, items[i].card[j]); + StrBuf->Printf(&buf, ", `card%d`=%d", j, items[i].card[j]); StrBuf->Printf(&buf, " WHERE `id`='%d' LIMIT 1", item.id); if( SQL_ERROR == SQL->QueryStr(sql_handle, StrBuf->Value(&buf)) ) @@ -1674,7 +1674,7 @@ int make_new_char_sql(struct char_session_data* sd, char* name_, int str, int ag { if( SQL_ERROR == SQL->Query(sql_handle, "INSERT INTO `%s` (`char_id`,`nameid`, `amount`, `identify`) VALUES ('%d', '%d', '%d', '%d')", - inventory_db, char_id, start_items[k], 1, 1) + inventory_db, char_id, start_items[k], 1, 1) ) Sql_ShowDebug(sql_handle); } @@ -2048,7 +2048,7 @@ int mmo_char_send006b(int fd, struct char_session_data* sd) int j, offset = 0; #if PACKETVER >= 20100413 offset += 3; -#endif +#endif if (save_log) ShowInfo("Loading Char Data ("CL_BOLD"%d"CL_RESET")\n",sd->account_id); @@ -3978,7 +3978,7 @@ static void char_delete2_req(int fd, struct char_session_data* sd) // see issue: 7338 if( char_aegis_delete ) { - if( SQL_SUCCESS != SQL->Query(sql_handle, "SELECT `party_id`, `guild_id` FROM `%s` WHERE `char_id`='%d'", char_db, char_id) + if( SQL_SUCCESS != SQL->Query(sql_handle, "SELECT `party_id`, `guild_id` FROM `%s` WHERE `char_id`='%d'", char_db, char_id) || SQL_SUCCESS != SQL->NextRow(sql_handle) ) { @@ -4268,7 +4268,7 @@ int parse_char(int fd) #if PACKETVER >= 20110309 if( *pincode->enabled ){ // hack check - struct online_char_data* character; + struct online_char_data* character; character = (struct online_char_data*)idb_get(online_char_db, sd->account_id); if( character && character->pincode_enable == -1){ WFIFOHEAD(fd,3); @@ -4508,7 +4508,7 @@ int parse_char(int fd) int i; #if PACKETVER >= 20110309 if( *pincode->enabled ){ // hack check - struct online_char_data* character; + struct online_char_data* character; character = (struct online_char_data*)idb_get(online_char_db, sd->account_id); if( character && character->pincode_enable == -1 ){ WFIFOHEAD(fd,3); diff --git a/src/char/int_auction.c b/src/char/int_auction.c index 886b5be26..d246e9851 100644 --- a/src/char/int_auction.c +++ b/src/char/int_auction.c @@ -268,7 +268,7 @@ static void mapif_parse_Auction_requestlist(int fd) for( auction = dbi_first(iter); dbi_exists(iter); auction = dbi_next(iter) ) { - if( (type == 0 && auction->type != IT_ARMOR && auction->type != IT_PETARMOR) || + if( (type == 0 && auction->type != IT_ARMOR && auction->type != IT_PETARMOR) || (type == 1 && auction->type != IT_WEAPON) || (type == 2 && auction->type != IT_CARD) || (type == 3 && auction->type != IT_ETC) || diff --git a/src/char/int_party.c b/src/char/int_party.c index 3e4a743d6..5dd64a32b 100644 --- a/src/char/int_party.c +++ b/src/char/int_party.c @@ -652,7 +652,7 @@ int mapif_parse_PartyChangeMap(int fd, int party_id, int account_id, int char_id if (p == NULL) return 0; - for(i = 0; i < MAX_PARTY && + for(i = 0; i < MAX_PARTY && (p->party.member[i].account_id != account_id || p->party.member[i].char_id != char_id); i++); @@ -666,7 +666,7 @@ int mapif_parse_PartyChangeMap(int fd, int party_id, int account_id, int char_id else p->party.count--; // Even share check situations: Family state (always breaks) - // character logging on/off is max/min level (update level range) + // character logging on/off is max/min level (update level range) // or character logging on/off has a different level (update level range using new level) if (p->family || (p->party.member[i].lv <= p->min_lv || p->party.member[i].lv >= p->max_lv) || @@ -731,7 +731,7 @@ int mapif_parse_PartyLeaderChange(int fd,int party_id,int account_id,int char_id for (i = 0; i < MAX_PARTY; i++) { - if(p->party.member[i].leader) + if(p->party.member[i].leader) p->party.member[i].leader = 0; if(p->party.member[i].account_id == account_id && p->party.member[i].char_id == char_id) diff --git a/src/char/int_party.h b/src/char/int_party.h index 098c1e9a9..33325b46b 100644 --- a/src/char/int_party.h +++ b/src/char/int_party.h @@ -6,7 +6,7 @@ //Party Flags on what to save/delete. enum { - PS_CREATE = 0x01, //Create a new party entry (index holds leader's info) + PS_CREATE = 0x01, //Create a new party entry (index holds leader's info) PS_BASIC = 0x02, //Update basic party info. PS_LEADER = 0x04, //Update party's leader PS_ADDMEMBER = 0x08, //Specify new party member (index specifies which party member) diff --git a/src/common/HPM.c b/src/common/HPM.c index 00b92dc60..d33a4c1aa 100644 --- a/src/common/HPM.c +++ b/src/common/HPM.c @@ -505,7 +505,7 @@ bool hplugins_addpacket(unsigned short cmd, short length,void (*receive) (int fd return true; } -/* +/* 0 = unknown 1 = OK 2 = incomplete @@ -635,7 +635,7 @@ bool hpm_add_arg(unsigned int pluginID, char *name, bool has_param, void (*func) CREATE(data, struct HPMArgData, 1); - data->pluginID = pluginID; + data->pluginID = pluginID; data->name = aStrdup(name); data->func = func; data->help = help; diff --git a/src/common/atomic.h b/src/common/atomic.h index 8c01943e7..1349d0887 100644 --- a/src/common/atomic.h +++ b/src/common/atomic.h @@ -4,16 +4,16 @@ #ifndef _COMMON_ATOMIC_H_ #define _COMMON_ATOMIC_H_ -// Atomic Operations +// Atomic Operations // (Interlocked CompareExchange, Add .. and so on ..) -// +// // Implementation varies / depends on: // - Architecture // - Compiler // - Operating System // // our Abstraction is fully API-Compatible to Microsofts implementation @ NT5.0+ -// +// #include "../common/cbasetypes.h" #if defined(_MSC_VER) @@ -36,7 +36,7 @@ forceinline int64 InterlockedCompareExchange64(volatile int64 *dest, int64 exch, mov ecx,4[edi]; mov esi,dest; - lock CMPXCHG8B [esi]; + lock CMPXCHG8B [esi]; } } diff --git a/src/common/cbasetypes.h b/src/common/cbasetypes.h index da0d6b307..ac65b08a8 100644 --- a/src/common/cbasetypes.h +++ b/src/common/cbasetypes.h @@ -313,7 +313,7 @@ typedef char bool; #undef swap #endif // hmm only ints? -//#define swap(a,b) { int temp=a; a=b; b=temp;} +//#define swap(a,b) { int temp=a; a=b; b=temp;} // if using macros then something that is type independent //#define swap(a,b) ((a == b) || ((a ^= b), (b ^= a), (a ^= b))) // Avoid "value computed is not used" warning and generates the same assembly code diff --git a/src/common/db.c b/src/common/db.c index 1781aa96f..bbeaf0b61 100644 --- a/src/common/db.c +++ b/src/common/db.c @@ -94,7 +94,7 @@ \*****************************************************************************/ /** - * If defined statistics about database nodes, database creating/destruction + * If defined statistics about database nodes, database creating/destruction * and function usage are keept and displayed when finalizing the database * system. * WARNING: This adds overhead to every database operation (not shure how much). @@ -522,7 +522,7 @@ static void db_rebalance_erase(DBNode node, DBNode *root) x_parent = y->parent; if (x) x->parent = y->parent; y->parent->left = x; - // put the right of 'node' in 'y' + // put the right of 'node' in 'y' y->right = node->right; node->right->parent = y; // 'y' is a direct child of 'node' @@ -1409,7 +1409,7 @@ DBData* dbit_obj_prev(DBIterator* self, DBKey* out_key) /** * Returns true if the fetched entry exists. - * The databases entries might have NULL data, so use this to to test if + * The databases entries might have NULL data, so use this to to test if * the iterator is done. * @param self Iterator * @return true if the entry exists @@ -1426,7 +1426,7 @@ bool dbit_obj_exists(DBIterator* self) /** * Removes the current entry from the database. - * NOTE: {@link DBIterator#exists} will return false until another entry + * NOTE: {@link DBIterator#exists} will return false until another entry * is fetched * Puts data of the removed entry in out_data, if out_data is not NULL. * @param self Iterator @@ -1477,7 +1477,7 @@ void dbit_obj_destroy(DBIterator* self) /** * Returns a new iterator for this database. * The iterator keeps the database locked until it is destroyed. - * The database will keep functioning normally but will only free internal + * The database will keep functioning normally but will only free internal * memory when unlocked, so destroy the iterator as soon as possible. * @param self Database * @return New iterator @@ -1615,7 +1615,7 @@ static DBData* db_obj_get(DBMap* self, DBKey key) * It puts a maximum of <code>max</code> entries into <code>buf</code>. * If <code>buf</code> is NULL, it only counts the matches. * Returns the number of entries that matched. - * NOTE: if the value returned is greater than <code>max</code>, only the + * NOTE: if the value returned is greater than <code>max</code>, only the * first <code>max</code> entries found are put into the buffer. * @param self Interface of the database * @param buf Buffer to put the data of the matched entries @@ -1686,7 +1686,7 @@ static unsigned int db_obj_vgetall(DBMap* self, DBData **buf, unsigned int max, * It puts a maximum of <code>max</code> entries into <code>buf</code>. * If <code>buf</code> is NULL, it only counts the matches. * Returns the number of entries that matched. - * NOTE: if the value returned is greater than <code>max</code>, only the + * NOTE: if the value returned is greater than <code>max</code>, only the * first <code>max</code> entries found are put into the buffer. * @param self Interface of the database * @param buf Buffer to put the data of the matched entries @@ -1714,7 +1714,7 @@ static unsigned int db_obj_getall(DBMap* self, DBData **buf, unsigned int max, D /** * Get the data of the entry identified by the key. - * If the entry does not exist, an entry is added with the data returned by + * If the entry does not exist, an entry is added with the data returned by * <code>create</code>. * @param self Interface of the database * @param key Key that identifies the entry @@ -1813,7 +1813,7 @@ static DBData* db_obj_vensure(DBMap* self, DBKey key, DBCreateData create, va_li /** * Just calls {@link DBMap#vensure}. * Get the data of the entry identified by the key. - * If the entry does not exist, an entry is added with the data returned by + * If the entry does not exist, an entry is added with the data returned by * <code>create</code>. * @param self Interface of the database * @param key Key that identifies the entry @@ -2163,7 +2163,7 @@ static int db_obj_vclear(DBMap* self, DBApply func, va_list args) * Before deleting an entry, func is applied to it. * Releases the key and the data. * Returns the sum of values returned by func, if it exists. - * NOTE: This locks the database globally. Any attempt to insert or remove + * NOTE: This locks the database globally. Any attempt to insert or remove * a database entry will give an error and be aborted (except for clearing). * @param self Interface of the database * @param func Function to be applied to every entry before deleting @@ -2191,7 +2191,7 @@ static int db_obj_clear(DBMap* self, DBApply func, ...) * Finalize the database, feeing all the memory it uses. * Before deleting an entry, func is applied to it. * Returns the sum of values returned by func, if it exists. - * NOTE: This locks the database globally. Any attempt to insert or remove + * NOTE: This locks the database globally. Any attempt to insert or remove * a database entry will give an error and be aborted (except for clearing). * @param self Interface of the database * @param func Function to be applied to every entry before deleting @@ -2246,7 +2246,7 @@ static int db_obj_vdestroy(DBMap* self, DBApply func, va_list args) * Before deleting an entry, func is applied to it. * Releases the key and the data. * Returns the sum of values returned by func, if it exists. - * NOTE: This locks the database globally. Any attempt to insert or remove + * NOTE: This locks the database globally. Any attempt to insert or remove * a database entry will give an error and be aborted. * @param self Database * @param func Function to be applied to every entry before deleting @@ -2448,7 +2448,7 @@ DBHasher db_default_hash(DBType type) } /** - * Returns the default releaser for the specified type of database with the + * Returns the default releaser for the specified type of database with the * specified options. * NOTE: the options are fixed with {@link #db_fix_options(DBType,DBOptions)} * before choosing the releaser. @@ -2509,7 +2509,7 @@ DBReleaser db_custom_release(DBRelease which) * @param line Line of the file where the database is being allocated * @param type Type of database * @param options Options of the database - * @param maxlen Maximum length of the string to be used as key in string + * @param maxlen Maximum length of the string to be used as key in string * databases. If 0, the maximum number of maxlen is used (64K). * @return The interface of the database * @public diff --git a/src/common/db.h b/src/common/db.h index 0d2548806..f5714ceaf 100644 --- a/src/common/db.h +++ b/src/common/db.h @@ -79,7 +79,7 @@ typedef enum DBRelease { /** * Supported types of database. - * See {@link #db_fix_options(DBType,DBOptions)} for restrictions of the + * See {@link #db_fix_options(DBType,DBOptions)} for restrictions of the * types of databases. * @param DB_INT Uses int's for keys * @param DB_UINT Uses unsigned int's for keys @@ -107,14 +107,14 @@ typedef enum DBType { /** * Bitfield of options that define the behaviour of the database. - * See {@link #db_fix_options(DBType,DBOptions)} for restrictions of the + * See {@link #db_fix_options(DBType,DBOptions)} for restrictions of the * types of databases. * @param DB_OPT_BASE Base options: does not duplicate keys, releases nothing * and does not allow NULL keys or NULL data. - * @param DB_OPT_DUP_KEY Duplicates the keys internally. If DB_OPT_RELEASE_KEY + * @param DB_OPT_DUP_KEY Duplicates the keys internally. If DB_OPT_RELEASE_KEY * is defined, the real key is freed as soon as the entry is added. * @param DB_OPT_RELEASE_KEY Releases the key. - * @param DB_OPT_RELEASE_DATA Releases the data whenever an entry is removed + * @param DB_OPT_RELEASE_DATA Releases the data whenever an entry is removed * from the database. * WARNING: for funtions that return the data (like DBMap::remove), * a dangling pointer will be returned. @@ -188,7 +188,7 @@ typedef struct DBData { } DBData; /** - * Format of functions that create the data for the key when the entry doesn't + * Format of functions that create the data for the key when the entry doesn't * exist in the database yet. * @param key Key of the database entry * @param args Extra arguments of the function @@ -200,9 +200,9 @@ typedef struct DBData { typedef DBData (*DBCreateData)(DBKey key, va_list args); /** - * Format of functions to be applied to an unspecified quantity of entries of + * Format of functions to be applied to an unspecified quantity of entries of * a database. - * Any function that applies this function to the database will return the sum + * Any function that applies this function to the database will return the sum * of values returned by this function. * @param key Key of the database entry * @param data Data of the database entry @@ -280,7 +280,7 @@ typedef struct DBMap DBMap; * Database iterator. * Supports forward iteration, backward iteration and removing entries from the database. * The iterator is initially positioned before the first entry of the database. - * While the iterator exists the database is locked internally, so invoke + * While the iterator exists the database is locked internally, so invoke * {@link DBIterator#destroy} as soon as possible. * @public * @see #DBMap @@ -334,7 +334,7 @@ struct DBIterator /** * Returns true if the fetched entry exists. - * The databases entries might have NULL data, so use this to to test if + * The databases entries might have NULL data, so use this to to test if * the iterator is done. * @param self Iterator * @return true is the entry exists @@ -344,7 +344,7 @@ struct DBIterator /** * Removes the current entry from the database. - * NOTE: {@link DBIterator#exists} will return false until another entry + * NOTE: {@link DBIterator#exists} will return false until another entry * is fetched * Puts data of the removed entry in out_data, if out_data is not NULL. * @param self Iterator @@ -375,7 +375,7 @@ struct DBMap { /** * Returns a new iterator for this database. * The iterator keeps the database locked until it is destroyed. - * The database will keep functioning normally but will only free internal + * The database will keep functioning normally but will only free internal * memory when unlocked, so destroy the iterator as soon as possible. * @param self Database * @return New iterator @@ -407,7 +407,7 @@ struct DBMap { * It puts a maximum of <code>max</code> entries into <code>buf</code>. * If <code>buf</code> is NULL, it only counts the matches. * Returns the number of entries that matched. - * NOTE: if the value returned is greater than <code>max</code>, only the + * NOTE: if the value returned is greater than <code>max</code>, only the * first <code>max</code> entries found are put into the buffer. * @param self Database * @param buf Buffer to put the data of the matched entries @@ -425,7 +425,7 @@ struct DBMap { * It puts a maximum of <code>max</code> entries into <code>buf</code>. * If <code>buf</code> is NULL, it only counts the matches. * Returns the number of entries that matched. - * NOTE: if the value returned is greater than <code>max</code>, only the + * NOTE: if the value returned is greater than <code>max</code>, only the * first <code>max</code> entries found are put into the buffer. * @param self Database * @param buf Buffer to put the data of the matched entries @@ -441,7 +441,7 @@ struct DBMap { /** * Just calls {@link DBMap#vensure}. * Get the data of the entry identified by the key. - * If the entry does not exist, an entry is added with the data returned by + * If the entry does not exist, an entry is added with the data returned by * <code>create</code>. * @param self Database * @param key Key that identifies the entry @@ -455,7 +455,7 @@ struct DBMap { /** * Get the data of the entry identified by the key. - * If the entry does not exist, an entry is added with the data returned by + * If the entry does not exist, an entry is added with the data returned by * <code>create</code>. * @param self Database * @param key Key that identifies the entry @@ -552,7 +552,7 @@ struct DBMap { * Before deleting an entry, func is applied to it. * Releases the key and the data. * Returns the sum of values returned by func, if it exists. - * NOTE: This locks the database globally. Any attempt to insert or remove + * NOTE: This locks the database globally. Any attempt to insert or remove * a database entry will give an error and be aborted (except for clearing). * @param self Database * @param func Function to be applied to every entry before deleting @@ -567,7 +567,7 @@ struct DBMap { * Finalize the database, feeing all the memory it uses. * Before deleting an entry, func is applied to it. * Returns the sum of values returned by func, if it exists. - * NOTE: This locks the database globally. Any attempt to insert or remove + * NOTE: This locks the database globally. Any attempt to insert or remove * a database entry will give an error and be aborted (except for clearing). * @param self Database * @param func Function to be applied to every entry before deleting @@ -759,7 +759,7 @@ DBComparator (*default_cmp) (DBType type); DBHasher (*default_hash) (DBType type); /** - * Returns the default releaser for the specified type of database with the + * Returns the default releaser for the specified type of database with the * specified options. * NOTE: the options are fixed by {@link #db_fix_options(DBType,DBOptions)} * before choosing the releaser @@ -788,7 +788,7 @@ DBReleaser (*custom_release) (DBRelease which); /** * Allocate a new database of the specified type. - * It uses the default comparator, hasher and releaser of the specified + * It uses the default comparator, hasher and releaser of the specified * database type and fixed options. * NOTE: the options are fixed by {@link #db_fix_options(DBType,DBOptions)} * before creating the database. @@ -796,7 +796,7 @@ DBReleaser (*custom_release) (DBRelease which); * @param line Line of the file where the database is being allocated * @param type Type of database * @param options Options of the database - * @param maxlen Maximum length of the string to be used as key in string + * @param maxlen Maximum length of the string to be used as key in string * databases. If 0, the maximum number of maxlen is used (64K). * @return The interface of the database * @public diff --git a/src/common/ers.c b/src/common/ers.c index d9895e4f2..39e05a14c 100644 --- a/src/common/ers.c +++ b/src/common/ers.c @@ -78,7 +78,7 @@ typedef struct ers_cache // Memory blocks array unsigned char **Blocks; - // Max number of blocks + // Max number of blocks unsigned int Max; // Free objects count @@ -190,26 +190,19 @@ static void *ers_obj_alloc_entry(ERS self) struct ers_instance_t *instance = (struct ers_instance_t *)self; void *ret; - if (instance == NULL) - { + if (instance == NULL) { ShowError("ers_obj_alloc_entry: NULL object, aborting entry freeing.\n"); return NULL; } - if (instance->Cache->ReuseList != NULL) - { + if (instance->Cache->ReuseList != NULL) { ret = (void *)((unsigned char *)instance->Cache->ReuseList + sizeof(struct ers_list)); instance->Cache->ReuseList = instance->Cache->ReuseList->Next; - } - else if (instance->Cache->Free > 0) - { + } else if (instance->Cache->Free > 0) { instance->Cache->Free--; ret = &instance->Cache->Blocks[instance->Cache->Used - 1][instance->Cache->Free * instance->Cache->ObjectSize + sizeof(struct ers_list)]; - } - else - { - if (instance->Cache->Used == instance->Cache->Max) - { + } else { + if (instance->Cache->Used == instance->Cache->Max) { instance->Cache->Max = (instance->Cache->Max * 4) + 3; RECREATE(instance->Cache->Blocks, unsigned char *, instance->Cache->Max); } @@ -237,13 +230,10 @@ static void ers_obj_free_entry(ERS self, void *entry) struct ers_instance_t *instance = (struct ers_instance_t *)self; struct ers_list *reuse = (struct ers_list *)((unsigned char *)entry - sizeof(struct ers_list)); - if (instance == NULL) - { + if (instance == NULL) { ShowError("ers_obj_free_entry: NULL object, aborting entry freeing.\n"); return; - } - else if (entry == NULL) - { + } else if (entry == NULL) { ShowError("ers_obj_free_entry: NULL entry, nothing to free.\n"); return; } @@ -261,11 +251,10 @@ static size_t ers_obj_entry_size(ERS self) { struct ers_instance_t *instance = (struct ers_instance_t *)self; - if (instance == NULL) - { + if (instance == NULL) { ShowError("ers_obj_entry_size: NULL object, aborting entry freeing.\n"); return 0; - } + } return instance->Cache->ObjectSize; } @@ -274,8 +263,7 @@ static void ers_obj_destroy(ERS self) { struct ers_instance_t *instance = (struct ers_instance_t *)self; - if (instance == NULL) - { + if (instance == NULL) { ShowError("ers_obj_destroy: NULL object, aborting entry freeing.\n"); return; } diff --git a/src/common/ers.h b/src/common/ers.h index 23a996923..7eceaf87a 100644 --- a/src/common/ers.h +++ b/src/common/ers.h @@ -55,7 +55,7 @@ /** * Define this to disable the Entry Reusage System. * All code except the typedef of ERInterface will be disabled. - * To allow a smooth transition, + * To allow a smooth transition, */ //#define DISABLE_ERS @@ -63,7 +63,7 @@ * Entries are aligned to ERS_ALIGNED bytes in the blocks of entries. * By default it aligns to one byte, using the "natural order" of the entries. * This should NEVER be set to zero or less. - * If greater than one, some memory can be wasted. This should never be needed + * If greater than one, some memory can be wasted. This should never be needed * but is here just in case some aligment issues arise. */ #ifndef ERS_ALIGNED @@ -118,7 +118,7 @@ typedef struct eri { /** * Destroy this instance of the manager. * The manager is actually only destroyed when all the instances are destroyed. - * When destroying the manager a warning is shown if the manager has + * When destroying the manager a warning is shown if the manager has * missing/extra entries. * @param self Interface of the entry manager */ @@ -140,7 +140,7 @@ typedef struct eri { # define ers_report() # define ers_final() #else /* not DISABLE_ERS */ -// These defines should be used to allow the code to keep working whenever +// These defines should be used to allow the code to keep working whenever // the system is disabled # define ers_alloc(obj,type) ((type *)(obj)->alloc(obj)) # define ers_free(obj,entry) ((obj)->free((obj),(entry))) @@ -151,9 +151,9 @@ typedef struct eri { /** * Get a new instance of the manager that handles the specified entry size. * Size has to greater than 0. - * If the specified size is smaller than a pointer, the size of a pointer is + * If the specified size is smaller than a pointer, the size of a pointer is * used instead. - * It's also aligned to ERS_ALIGNED bytes, so the smallest multiple of + * It's also aligned to ERS_ALIGNED bytes, so the smallest multiple of * ERS_ALIGNED that is greater or equal to size is what's actually used. * @param The requested size of the entry in bytes * @return Interface of the object diff --git a/src/common/malloc.c b/src/common/malloc.c index 13cf0b5ce..74303fa92 100644 --- a/src/common/malloc.c +++ b/src/common/malloc.c @@ -21,7 +21,7 @@ struct malloc_interface iMalloc_s; #if defined(MEMWATCH) -# include <string.h> +# include <string.h> # include "memwatch.h" # define MALLOC(n,file,line,func) mwMalloc((n),(file),(line)) # define CALLOC(m,n,file,line,func) mwCalloc((m),(n),(file),(line)) @@ -421,7 +421,7 @@ void _mfree(void *ptr, const char *file, int line, const char *func ) struct unit_head *head; if (ptr == NULL) - return; + return; head = (struct unit_head *)((char *)ptr - sizeof(struct unit_head) + sizeof(long)); if(head->size == 0) { diff --git a/src/common/mutex.c b/src/common/mutex.c index 12524c3b7..1de707e95 100644 --- a/src/common/mutex.c +++ b/src/common/mutex.c @@ -119,7 +119,7 @@ void ramutex_unlock( ramutex m ){ /////////////// // Condition Variables -// +// // Implementation: // diff --git a/src/common/mutex.h b/src/common/mutex.h index 3b83b66d6..f78e31841 100644 --- a/src/common/mutex.h +++ b/src/common/mutex.h @@ -1,5 +1,5 @@ // Copyright (c) rAthena Project (www.rathena.org) - Licensed under GNU GPL -// For more information, see LICENCE in the main folder +// For more information, see LICENCE in the main folder #ifndef _COMMON_MUTEX_H_ #define _COMMON_MUTEX_H_ @@ -10,36 +10,36 @@ typedef struct ramutex *ramutex; // Mutex typedef struct racond *racond; // Condition Var /** - * Creates a Mutex + * Creates a Mutex * * @return not NULL */ ramutex ramutex_create(); -/** +/** * Destroys a Mutex - * + * * @param m - the mutex to destroy */ void ramutex_destroy( ramutex m ); -/** +/** * Gets a lock * * @param m - the mutex to lock */ void ramutex_lock( ramutex m); -/** +/** * Trys to get the Lock - * + * * @param m - the mutex try to lock - * + * * @return boolean (true = got the lock) */ bool ramutex_trylock( ramutex m ); -/** +/** * Unlocks a mutex * * @param m - the mutex to unlock @@ -47,14 +47,14 @@ bool ramutex_trylock( ramutex m ); void ramutex_unlock( ramutex m); -/** +/** * Creates a Condition variable * * @return not NULL */ racond racond_create(); -/** +/** * Destroy a Condition variable * * @param c - the condition varaible to destroy @@ -63,14 +63,14 @@ void racond_destroy( racond c ); /** * Waits Until state is signalled - * - * @param c - the condition var to wait for signalled state + * + * @param c - the condition var to wait for signalled state * @param m - the mutex used for syncronization * @param timeout_ticks - timeout in ticks ( -1 = INFINITE ) */ void racond_wait( racond c, ramutex m, sysint timeout_ticks); -/** +/** * Sets the given condition var to signalled state * * @param c - condition var to set in signalled state. @@ -80,13 +80,13 @@ void racond_wait( racond c, ramutex m, sysint timeout_ticks); */ void racond_signal( racond c ); -/** +/** * Sets notifys all waiting threads thats signalled. * @param c - condition var to set in signalled state - * + * * @note: * All Waiters getting notified. - */ + */ void racond_broadcast( racond c ); diff --git a/src/common/nullpo.c b/src/common/nullpo.c index 1891835f1..a3471b00d 100644 --- a/src/common/nullpo.c +++ b/src/common/nullpo.c @@ -14,7 +14,7 @@ /** * Reports failed assertions or NULL pointers - * + * * @param file Source file where the error was detected * @param line Line * @param func Function diff --git a/src/common/showmsg.c b/src/common/showmsg.c index 1dbcba282..2a8e2d5f8 100644 --- a/src/common/showmsg.c +++ b/src/common/showmsg.c @@ -91,7 +91,7 @@ int console_msg_log = 0;//[Ind] msg error logging // ansi compatible printf with control sequence parser for windows // fast hack, handle with care, not everything implemented // -// \033[#;...;#m - Set Graphics Rendition (SGR) +// \033[#;...;#m - Set Graphics Rendition (SGR) // // printf("\x1b[1;31;40m"); // Bright red on black // printf("\x1b[3;33;45m"); // Blinking yellow on magenta (blink not implemented) @@ -110,19 +110,19 @@ int console_msg_log = 0;//[Ind] msg error logging // 8 - Concealed (invisible) // // \033[#A - Cursor Up (CUU) -// Moves the cursor up by the specified number of lines without changing columns. +// Moves the cursor up by the specified number of lines without changing columns. // If the cursor is already on the top line, this sequence is ignored. \e[A is equivalent to \e[1A. // // \033[#B - Cursor Down (CUD) -// Moves the cursor down by the specified number of lines without changing columns. +// Moves the cursor down by the specified number of lines without changing columns. // If the cursor is already on the bottom line, this sequence is ignored. \e[B is equivalent to \e[1B. // // \033[#C - Cursor Forward (CUF) -// Moves the cursor forward by the specified number of columns without changing lines. +// Moves the cursor forward by the specified number of columns without changing lines. // If the cursor is already in the rightmost column, this sequence is ignored. \e[C is equivalent to \e[1C. // // \033[#D - Cursor Backward (CUB) -// Moves the cursor back by the specified number of columns without changing lines. +// Moves the cursor back by the specified number of columns without changing lines. // If the cursor is already in the leftmost column, this sequence is ignored. \e[D is equivalent to \e[1D. // // \033[#E - Cursor Next Line (CNL) @@ -135,15 +135,15 @@ int console_msg_log = 0;//[Ind] msg error logging // Moves the cursor to indicated column in current row. \e[G is equivalent to \e[1G. // // \033[#;#H - Cursor Position (CUP) -// Moves the cursor to the specified position. The first # specifies the line number, -// the second # specifies the column. If you do not specify a position, the cursor moves to the home position: +// Moves the cursor to the specified position. The first # specifies the line number, +// the second # specifies the column. If you do not specify a position, the cursor moves to the home position: // the upper-left corner of the screen (line 1, column 1). // // \033[#;#f - Horizontal & Vertical Position // (same as \033[#;#H) // // \033[s - Save Cursor Position (SCP) -// The current cursor position is saved. +// The current cursor position is saved. // // \033[u - Restore cursor position (RCP) // Restores the cursor position saved with the (SCP) sequence \033[s. @@ -213,7 +213,7 @@ int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr) WriteFile(handle, p, (DWORD)(q-p), &written, 0); if( q[1]!='[' ) - { // write the escape char (whatever purpose it has) + { // write the escape char (whatever purpose it has) if(0==WriteConsole(handle, q, 1, &written, 0) ) WriteFile(handle,q, 1, &written, 0); p=q+1; //and start searching again @@ -233,7 +233,7 @@ int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr) q=q+2; for(;;) { - if( ISDIGIT(*q) ) + if( ISDIGIT(*q) ) { // add number to number array, only accept 2digits, shift out the rest // so // \033[123456789m will become \033[89m numbers[numpoint] = (numbers[numpoint]<<4) | (*q-'0'); @@ -350,12 +350,12 @@ int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr) else if(num==2) { // Number of chars on screen. cnt = info.dwSize.X * info.dwSize.Y; - SetConsoleCursorPosition(handle, origin); + SetConsoleCursorPosition(handle, origin); } else// 0 and default { // number of chars from cursor to end origin = info.dwCursorPosition; - cnt = info.dwSize.X * (info.dwSize.Y - info.dwCursorPosition.Y) - info.dwCursorPosition.X; + cnt = info.dwSize.X * (info.dwSize.Y - info.dwCursorPosition.Y) - info.dwCursorPosition.X; } FillConsoleOutputAttribute(handle, info.wAttributes, cnt, origin, &tmp); FillConsoleOutputCharacter(handle, ' ', cnt, origin, &tmp); @@ -389,7 +389,7 @@ int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr) else if( *q == 'H' || *q == 'f' ) { // \033[#;#H - Cursor Position (CUP) // \033[#;#f - Horizontal & Vertical Position - // The first # specifies the line number, the second # specifies the column. + // The first # specifies the line number, the second # specifies the column. // The default for both is 1 info.dwCursorPosition.X = (numbers[numpoint])?(numbers[numpoint]>>4)*10+((numbers[numpoint]&0x0F)-1):0; info.dwCursorPosition.Y = (numpoint && numbers[numpoint-1])?(numbers[numpoint-1]>>4)*10+((numbers[numpoint-1]&0x0F)-1):0; @@ -486,7 +486,7 @@ int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr) --q; } // skip the sequencer and search again - p = q+1; + p = q+1; break; }// end while } @@ -542,7 +542,7 @@ int VFPRINTF(FILE *file, const char *fmt, va_list argptr) { // find the escape character fprintf(file, "%.*s", (int)(q-p), p); // write up to the escape if( q[1]!='[' ) - { // write the escape char (whatever purpose it has) + { // write the escape char (whatever purpose it has) fprintf(file, "%.*s", 1, q); p=q+1; //and start searching again } @@ -555,7 +555,7 @@ int VFPRINTF(FILE *file, const char *fmt, va_list argptr) q=q+2; while(1) { - if( ISDIGIT(*q) ) + if( ISDIGIT(*q) ) { ++q; // and next character @@ -624,7 +624,7 @@ int VFPRINTF(FILE *file, const char *fmt, va_list argptr) --q; } // skip the sequencer and search again - p = q+1; + p = q+1; break; }// end while } diff --git a/src/common/socket.c b/src/common/socket.c index 3738f2c2a..ac6be68fe 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -64,7 +64,7 @@ struct socket_interface sockt_s; ///////////////////////////////////////////////////////////////////// #if defined(WIN32) ///////////////////////////////////////////////////////////////////// -// windows portability layer +// windows portability layer typedef int socklen_t; @@ -110,7 +110,7 @@ int sock2fd(SOCKET s) /// Inserts the socket into the global array of sockets. /// Returns a new fd associated with the socket. -/// If there are too many sockets it closes the socket, sets an error and +/// If there are too many sockets it closes the socket, sets an error and // returns -1 instead. /// Since fd 0 is reserved, it returns values in the range [1,FD_SETSIZE[. /// @@ -293,8 +293,8 @@ void set_defaultparse(ParseFunc defaultparse) *--------------------------------------*/ void set_nonblocking(int fd, unsigned long yes) { - // FIONBIO Use with a nonzero argp parameter to enable the nonblocking mode of socket s. - // The argp parameter is zero if nonblocking is to be disabled. + // FIONBIO Use with a nonzero argp parameter to enable the nonblocking mode of socket s. + // The argp parameter is zero if nonblocking is to be disabled. if( sIoctl(fd, FIONBIO, &yes) != 0 ) ShowError("set_nonblocking: Failed to set socket #%d to non-blocking mode (%s) - Please report this!!!\n", fd, error_msg()); } diff --git a/src/common/spinlock.h b/src/common/spinlock.h index 0058e1d83..1c0825181 100644 --- a/src/common/spinlock.h +++ b/src/common/spinlock.h @@ -57,7 +57,7 @@ static forceinline void FinalizeSpinLock(PSPIN_LOCK lck){ static forceinline void EnterSpinLock(PSPIN_LOCK lck){ int tid = rathread_get_tid(); - // Get Sync Lock && Check if the requester thread already owns the lock. + // Get Sync Lock && Check if the requester thread already owns the lock. // if it owns, increase nesting level getsynclock(&lck->sync_lock); if(InterlockedCompareExchange(&lck->lock, tid, tid) == tid){ @@ -69,7 +69,7 @@ static forceinline void EnterSpinLock(PSPIN_LOCK lck){ dropsynclock(&lck->sync_lock); - // Spin until we've got it ! + // Spin until we've got it ! while(1){ if(InterlockedCompareExchange(&lck->lock, tid, 0) == 0){ diff --git a/src/common/sql.c b/src/common/sql.c index aeb56bff0..ffc4d63ef 100644 --- a/src/common/sql.c +++ b/src/common/sql.c @@ -402,8 +402,7 @@ void Sql_ShowDebug_(Sql* self, const char* debug_file, const unsigned long debug /// Frees a Sql handle returned by Sql_Malloc. -void Sql_Free(Sql* self) -{ +void Sql_Free(Sql* self) { if( self ) { SQL->FreeResult(self); @@ -549,7 +548,7 @@ static void Sql_P_ShowDebugMysqlFieldInfo(const char* prefix, enum enum_field_ty SHOW_DEBUG_OF(MYSQL_TYPE_NULL); #undef SHOW_DEBUG_TYPE_OF } - ShowDebug("%stype=%s%s, length=%d%s\n", prefix, sign, type_string, length, length_postfix); + ShowDebug("%stype=%s%s, length=%d%s\n", prefix, sign, type_string, length, length_postfix); } diff --git a/src/common/sql.h b/src/common/sql.h index 807e0843c..64d8307fc 100644 --- a/src/common/sql.h +++ b/src/common/sql.h @@ -147,10 +147,10 @@ struct sql_interface { /////////////////////////////////////////////////////////////////////////////// // Prepared Statements /////////////////////////////////////////////////////////////////////////////// - // Parameters are placed in the statement by embedding question mark ('?') + // Parameters are placed in the statement by embedding question mark ('?') // characters into the query at the appropriate positions. // The markers are legal only in places where they represent data. - // The markers cannot be inside quotes. Quotes will be added automatically + // The markers cannot be inside quotes. Quotes will be added automatically // when they are required. // // example queries with parameters: @@ -236,7 +236,7 @@ struct sql_interface { /// Binds the result of a column to a buffer. /// The buffer will be filled with data when the next row is fetched. - /// For string/enum buffer types there has to be enough space for the data + /// For string/enum buffer types there has to be enough space for the data /// and the nul-terminator (an extra byte). /// /// @return SQL_SUCCESS or SQL_ERROR diff --git a/src/common/strlib.c b/src/common/strlib.c index e2e802915..10e893c3a 100644 --- a/src/common/strlib.c +++ b/src/common/strlib.c @@ -192,7 +192,7 @@ char* normalize_name(char* str,const char* delims) return str; } -//stristr: Case insensitive version of strstr, code taken from +//stristr: Case insensitive version of strstr, code taken from //http://www.daniweb.com/code/snippet313.html, Dave Sinkula // const char* stristr(const char* haystack, const char* needle) @@ -618,13 +618,13 @@ int sv_parse_next(struct s_svstate* svstate) /// out_pos[0] and out_pos[1] are the start and end of line. /// Other position pairs are the start and end of fields. /// Returns the number of fields found or -1 if an error occurs. -/// +/// /// out_pos can be NULL. /// If a line terminator is found, the end position is placed there. -/// out_pos[2] and out_pos[3] for the first field, out_pos[4] and out_pos[5] +/// out_pos[2] and out_pos[3] for the first field, out_pos[4] and out_pos[5] /// for the seconds field and so on. /// Unfilled positions are set to -1. -/// +/// /// @param str String to parse /// @param len Length of the string /// @param startoff Where to start parsing @@ -668,11 +668,11 @@ int sv_parse(const char* str, int len, int startoff, char delim, int* out_pos, i /// out_fields[0] is the start of the next line. /// Other entries are the start of fields (nul-teminated). /// Returns the number of fields found or -1 if an error occurs. -/// +/// /// out_fields can be NULL. /// Fields that don't fit in out_fields are not nul-terminated. /// Extra entries in out_fields are filled with the end of the last field (empty string). -/// +/// /// @param str String to parse /// @param len Length of the string /// @param startoff Where to start parsing diff --git a/src/common/thread.c b/src/common/thread.c index 4f73aa9b3..bba56e7eb 100644 --- a/src/common/thread.c +++ b/src/common/thread.c @@ -17,7 +17,7 @@ #ifdef WIN32 # include "../common/winapi.h" # define getpagesize() 4096 // @TODO: implement this properly (GetSystemInfo .. dwPageSize..). (Atm as on all supported win platforms its 4k its static.) -# define __thread __declspec( thread ) +# define __thread __declspec( thread ) #else # include <stdlib.h> # include <unistd.h> @@ -28,8 +28,8 @@ #endif // When Compiling using MSC (on win32..) we know we have support in any case! -#ifdef _MSC_VER -#define HAS_TLS +#ifdef _MSC_VER +#define HAS_TLS #endif @@ -40,7 +40,7 @@ struct rAthread { RATHREAD_PRIO prio; rAthreadProc proc; - void *param; + void *param; #ifdef WIN32 HANDLE hThread; @@ -82,9 +82,9 @@ void rathread_init(){ void rathread_final(){ register unsigned int i; - // Unterminated Threads Left? + // Unterminated Threads Left? // Should'nt happen .. - // Kill 'em all! + // Kill 'em all! // for(i = 1; i < RA_THREADS_MAX; i++){ if(l_threads[i].proc != NULL){ @@ -116,12 +116,12 @@ static void *_raThreadMainRedirector( void *p ){ // Update myID @ TLS to right id. #ifdef HAS_TLS - g_rathread_ID = ((rAthread)p)->myID; + g_rathread_ID = ((rAthread)p)->myID; #endif #ifndef WIN32 // When using posix threads - // the threads inherits the Signal mask from the thread which's spawned + // the threads inherits the Signal mask from the thread which's spawned // this thread // so we've to block everything we dont care about. sigemptyset(&set); @@ -136,7 +136,7 @@ static void *_raThreadMainRedirector( void *p ){ ret = ((rAthread)p)->proc( ((rAthread)p)->param ) ; -#ifdef WIN32 +#ifdef WIN32 CloseHandle( ((rAthread)p)->hThread ); #endif @@ -154,7 +154,7 @@ static void *_raThreadMainRedirector( void *p ){ /// /// API Level -/// +/// rAthread rathread_create( rAthreadProc entryPoint, void *param ){ return rathread_createEx( entryPoint, param, (1<<23) /*8MB*/, RAT_PRIO_NORMAL ); }//end: rathread_create() @@ -175,7 +175,7 @@ rAthread rathread_createEx( rAthreadProc entryPoint, void *param, size_t szSta szStack += tmp; - // Get a free Thread Slot. + // Get a free Thread Slot. for(i = 0; i < RA_THREADS_MAX; i++){ if(l_threads[i].proc == NULL){ handle = &l_threads[i]; @@ -223,7 +223,6 @@ void rathread_destroy ( rAthread handle ){ if( pthread_cancel( handle->hThread ) == 0){ // We have to join it, otherwise pthread wont re-cycle its internal ressources assoc. with this thread. - // pthread_join( handle->hThread, NULL ); // Tell our manager to release ressources ;) @@ -236,10 +235,10 @@ rAthread rathread_self( ){ #ifdef HAS_TLS rAthread handle = &l_threads[g_rathread_ID]; - if(handle->proc != NULL) // entry point set, so its used! + if(handle->proc != NULL) // entry point set, so its used! return handle; #else - // .. so no tls means we have to search the thread by its api-handle .. + // .. so no tls means we have to search the thread by its api-handle .. int i; #ifdef WIN32 @@ -257,13 +256,13 @@ rAthread rathread_self( ){ #endif - return NULL; + return NULL; }//end: rathread_self() int rathread_get_tid(){ -#ifdef HAS_TLS +#ifdef HAS_TLS return g_rathread_ID; #else // todo @@ -286,7 +285,7 @@ bool rathread_wait( rAthread handle, void* *out_exitCode ){ // #ifdef WIN32 WaitForSingleObject(handle->hThread, INFINITE); - return true; + return true; #else if(pthread_join(handle->hThread, out_exitCode) == 0) return true; @@ -297,8 +296,8 @@ bool rathread_wait( rAthread handle, void* *out_exitCode ){ void rathread_prio_set( rAthread handle, RATHREAD_PRIO prio ){ - handle->prio = RAT_PRIO_NORMAL; - //@TODO + handle->prio = RAT_PRIO_NORMAL; + //@TODO }//end: rathread_prio_set() @@ -308,9 +307,9 @@ RATHREAD_PRIO rathread_prio_get( rAthread handle){ void rathread_yield(){ -#ifdef WIN32 +#ifdef WIN32 SwitchToThread(); #else sched_yield(); -#endif +#endif }//end: rathread_yield() diff --git a/src/common/thread.h b/src/common/thread.h index 887c03179..7ad326509 100644 --- a/src/common/thread.h +++ b/src/common/thread.h @@ -12,7 +12,7 @@ typedef void* (*rAthreadProc)(void*); typedef enum RATHREAD_PRIO { RAT_PRIO_LOW = 0, RAT_PRIO_NORMAL, - RAT_PRIO_HIGH + RAT_PRIO_HIGH } RATHREAD_PRIO; @@ -21,18 +21,18 @@ typedef enum RATHREAD_PRIO { * * @param entyPoint - entryProc, * @param param - general purpose parameter, would be given as parameter to the thread's entrypoint. - * + * * @return not NULL if success */ rAthread rathread_create( rAthreadProc entryPoint, void *param ); -/** +/** * Creates a new Thread (with more creation options) * * @param entyPoint - entryProc, * @param param - general purpose parameter, would be given as parameter to the thread's entrypoint - * @param szStack - stack Size in bytes + * @param szStack - stack Size in bytes * @param prio - Priority of the Thread @ OS Scheduler.. * * @return not NULL if success @@ -43,29 +43,29 @@ rAthread rathread_createEx( rAthreadProc entryPoint, void *param, size_t szSta /** * Destroys the given Thread immediatly * - * @note The Handle gets invalid after call! dont use it afterwards. + * @note The Handle gets invalid after call! dont use it afterwards. * * @param handle - thread to destroy. */ void rathread_destroy ( rAthread handle ); -/** +/** * Returns the thread handle of the thread calling this function - * + * * @note this wont work @ programms main thread - * @note the underlying implementation might not perform very well, cache the value received! - * + * @note the underlying implementation might not perform very well, cache the value received! + * * @return not NULL if success */ rAthread rathread_self( ); /** - * Returns own thrad id (TID) + * Returns own thrad id (TID) * - * @note this is an unique identifier for the calling thread, and - * depends on platfrom / compiler, and may not be the systems Thread ID! + * @note this is an unique identifier for the calling thread, and + * depends on platfrom / compiler, and may not be the systems Thread ID! * * @return -1 when fails, otherwise >= 0 */ @@ -73,26 +73,26 @@ int rathread_get_tid(); /** - * Waits for the given thread to terminate + * Waits for the given thread to terminate * * @param handle - thread to wait (join) for * @param out_Exitcode - [OPTIONAL] - if given => Exitcode (value) of the given thread - if it's terminated - * + * * @return true - if the given thread has been terminated. */ bool rathread_wait( rAthread handle, void* *out_exitCode ); -/** +/** * Sets the given PRIORITY @ OS Task Scheduler - * + * * @param handle - thread to set prio for * @param rio - the priority (RAT_PRIO_LOW ... ) */ void rathread_prio_set( rAthread handle, RATHREAD_PRIO prio ); -/** +/** * Gets the current Prio of the given trhead * * @param handle - the thread to get the prio for. @@ -102,9 +102,9 @@ RATHREAD_PRIO rathread_prio_get( rAthread handle); /** * Tells the OS scheduler to yield the execution of the calling thread - * + * * @note: this will not "pause" the thread, - * it just allows the OS to spent the remaining time + * it just allows the OS to spent the remaining time * of the slice to another thread. */ void rathread_yield(); diff --git a/src/common/timer.c b/src/common/timer.c index 5d67455dc..5240ec202 100644 --- a/src/common/timer.c +++ b/src/common/timer.c @@ -130,7 +130,7 @@ static void rdtsc_calibrate(){ t1 = _rdtsc(); usleep(1000000); //1000 MS t2 = _rdtsc(); - RDTSC_CLOCK += (t2 - t1) / 1000; + RDTSC_CLOCK += (t2 - t1) / 1000; } RDTSC_CLOCK /= 5; @@ -453,7 +453,7 @@ void timer_final(void) { if (free_timer_list) aFree(free_timer_list); } /*===================================== -* Default Functions : timer.h +* Default Functions : timer.h * Generated by HerculesInterfaceMaker * created by Susu *-------------------------------------*/ diff --git a/src/common/timer.h b/src/common/timer.h index 1ce8cf203..a07f81612 100644 --- a/src/common/timer.h +++ b/src/common/timer.h @@ -30,13 +30,13 @@ struct TimerData { int interval; // general-purpose storage - int id; + int id; intptr_t data; }; /*===================================== -* Interface : timer.h +* Interface : timer.h * Generated by HerculesInterfaceMaker * created by Susu *-------------------------------------*/ diff --git a/src/common/utils.c b/src/common/utils.c index 84925f707..80954f848 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -265,9 +265,9 @@ uint32 MakeDWord(uint16 word0, uint16 word1) ( (uint32)(word0 ) )| ( (uint32)(word1 << 0x10) ); } + /************************************* -* Big-endian compatibility functions * -* From mapcache.c * +* Big-endian compatibility functions * *************************************/ // Converts an int16 from current machine order to little-endian diff --git a/src/common/winapi.h b/src/common/winapi.h index 7ce555049..b7c2bea1e 100644 --- a/src/common/winapi.h +++ b/src/common/winapi.h @@ -7,7 +7,7 @@ #define WINVER 0x0500 #define _WIN32_IE 0x0600 #define WIN32_LEAN_AND_MEAN -#define NOCOMM +#define NOCOMM #define NOKANJI #define NOHELP #define NOMCX @@ -32,5 +32,3 @@ #include <Ws2tcpip.h> #include <Mswsock.h> #include <MMSystem.h> - - diff --git a/src/config/const.h b/src/config/const.h index ba06d70cb..23467bfa6 100644 --- a/src/config/const.h +++ b/src/config/const.h @@ -15,7 +15,7 @@ */ /** - * "Sane Checks" to save you from compiling with cool bugs + * "Sane Checks" to save you from compiling with cool bugs **/ #if SECURE_NPCTIMEOUT_INTERVAL <= 0 #error SECURE_NPCTIMEOUT_INTERVAL should be at least 1 (1s) diff --git a/src/login/login.c b/src/login/login.c index cb46e0226..43883c6ce 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -173,7 +173,7 @@ static int online_data_cleanup_sub(DBKey key, DBData *data, va_list ap) static int online_data_cleanup(int tid, int64 tick, int id, intptr_t data) { online_db->foreach(online_db, online_data_cleanup_sub); return 0; -} +} //-------------------------------------------------------------------- @@ -1109,7 +1109,7 @@ void login_auth_ok(struct login_session_data* sd) WFIFOW(fd,0) = 0x81; WFIFOB(fd,2) = 1; // 01 = Server closed WFIFOSET(fd,3); - return; + return; } server_num = 0; @@ -1827,7 +1827,7 @@ int do_init(int argc, char** argv) HPM->config_read(NULL, 0); HPM->event(HPET_INIT); - // server port open & binding + // server port open & binding if( (login_fd = make_listen_bind(login_config.login_ip,login_config.login_port)) == -1 ) { ShowFatalError("Failed to bind to port '"CL_WHITE"%d"CL_RESET"'\n",login_config.login_port); exit(EXIT_FAILURE); diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 7a6ad84e4..96fa9c350 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -1123,14 +1123,14 @@ ACMD(item) memset(item_name, '\0', sizeof(item_name)); if (!strcmpi(info->command,"itembound") && (!message || !*message || ( - sscanf(message, "\"%99[^\"]\" %d %d", item_name, &number, &bound) < 2 && - sscanf(message, "%99s %d %d", item_name, &number, &bound) < 2 + sscanf(message, "\"%99[^\"]\" %d %d", item_name, &number, &bound) < 2 && + sscanf(message, "%99s %d %d", item_name, &number, &bound) < 2 ))) { clif->message(fd, msg_txt(295)); // Please enter an item name or ID (usage: @itembound <item name/ID> <quantity> <bound_type>). return false; } else if (!message || !*message || ( - sscanf(message, "\"%99[^\"]\" %d", item_name, &number) < 1 && - sscanf(message, "%99s %d", item_name, &number) < 1 )) + sscanf(message, "\"%99[^\"]\" %d", item_name, &number) < 1 && + sscanf(message, "%99s %d", item_name, &number) < 1 )) { clif->message(fd, msg_txt(983)); // Please enter an item name or ID (usage: @item <item name/ID> <quantity>). return false; @@ -10088,7 +10088,7 @@ void atcommand_config_read(const char* config_filename) { } commandinfo->log = false; } - } + } // Commands help // We only check if all commands exist @@ -10135,7 +10135,7 @@ static inline int AtCommandType2idx(AtCommandType type) { return (type-1); } /** * Loads permissions for groups to use commands. - * + * */ void atcommand_db_load_groups(GroupSettings **groups, config_setting_t **commands_, size_t sz) { diff --git a/src/map/battle.c b/src/map/battle.c index 0865ee4ba..fc2f4d3cf 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -446,7 +446,7 @@ int64 battle_calc_weapon_damage(struct block_list *src, struct block_list *bl, u if( sc && sc->count ){ if( sc->data[SC_ZENKAI] && watk->ele == sc->data[SC_ZENKAI]->val2 ) eatk += 200; - #ifdef RENEWAL_EDP + #ifdef RENEWAL_EDP if( sc->data[SC_EDP] && skill_id != AS_GRIMTOOTH && skill_id != AS_VENOMKNIFE && skill_id != ASC_BREAKER ){ eatk = eatk * (sc->data[SC_EDP]->val4 / 100 - 1); damage = damage * (sc->data[SC_EDP]->val4 / 100); @@ -655,7 +655,7 @@ int64 battle_addmastery(struct map_session_data *sd,struct block_list *target,in damage += (skill_lv * 10); else if(pc_isriding(sd)) damage += (skill_lv * 5); - else + else damage += (skill_lv * 4); } break; @@ -737,7 +737,7 @@ int64 battle_calc_masteryfix(struct block_list *src, struct block_list *target, #endif ) damage += 3 * skill2_lv; - break; + break; #ifndef RENEWAL case NJ_KUNAI: if( weapon ) @@ -748,7 +748,7 @@ int64 battle_calc_masteryfix(struct block_list *src, struct block_list *target, if( sd->weight ) damage += sd->weight / 8 ; case RA_WUGSTRIKE: - case RA_WUGBITE: + case RA_WUGBITE: damage += 30*pc->checkskill(sd, RA_TOOTHOFWUG); break; case HT_FREEZINGTRAP: @@ -999,7 +999,7 @@ int64 battle_calc_cardfix(int attack_type, struct block_list *src, struct block_ cardfix = cardfix * (100 + sd->right_weapon.addrace[RC_NONDEMIHUMAN]+sd->arrow_addrace[RC_NONDEMIHUMAN]) / 100; }else{ // Melee attack if( !battle_config.left_cardfix_to_right ){ - cardfix=cardfix*(100+sd->right_weapon.addrace[tstatus->race])/100; + cardfix=cardfix*(100+sd->right_weapon.addrace[tstatus->race])/100; if( !(nk&NK_NO_ELEFIX) ){ int ele_fix = sd->right_weapon.addele[tstatus->def_ele]; for (i = 0; ARRAYLENGTH(sd->right_weapon.addele2) > i && sd->right_weapon.addele2[i].rate != 0; i++) { @@ -1019,9 +1019,9 @@ int64 battle_calc_cardfix(int attack_type, struct block_list *src, struct block_ cardfix = cardfix * (100 + sd->right_weapon.addrace[RC_NONDEMIHUMAN]) / 100; if( cflag&1 ){ - cardfix_ = cardfix_*(100+sd->left_weapon.addrace[tstatus->race])/100; + cardfix_ = cardfix_*(100+sd->left_weapon.addrace[tstatus->race])/100; if (!(nk&NK_NO_ELEFIX)){ - int ele_fix_lh = sd->left_weapon.addele[tstatus->def_ele]; + int ele_fix_lh = sd->left_weapon.addele[tstatus->def_ele]; for (i = 0; ARRAYLENGTH(sd->left_weapon.addele2) > i && sd->left_weapon.addele2[i].rate != 0; i++) { if (sd->left_weapon.addele2[i].ele != tstatus->def_ele) continue; if(!(sd->left_weapon.addele2[i].flag&wflag&BF_WEAPONMASK && @@ -1221,7 +1221,7 @@ int64 battle_calc_defense(int attack_type, struct block_list *src, struct block_ **/ defType def1 = status->get_def(target); //Don't use tstatus->def1 due to skill timer reductions. short def2 = tstatus->def2, vit_def; -#ifdef RENEWAL +#ifdef RENEWAL def1 = status->calc_def2(target, tsc, def1, false); // equip def(RE) def2 = status->calc_def(target, tsc, def2, false); // status def(RE) #else @@ -1301,7 +1301,7 @@ int64 battle_calc_defense(int attack_type, struct block_list *src, struct block_ if( def1 < -399 ) // it stops at -399 def1 = 399; // in aegis it set to 1 but in our case it may lead to exploitation so limit it to 399 - //return 1; + //return 1; if( flag&2 ) damage += def1 >> 1; @@ -1357,7 +1357,7 @@ int64 battle_calc_defense(int attack_type, struct block_list *src, struct block_ **/ if( mdef < -99 ) // it stops at -99 mdef = 99; // in aegis it set to 1 but in our case it may lead to exploitation so limit it to 99 - //return 1; + //return 1; damage = (int)((100.0f - mdef / (mdef + 100.0f) * 90.0f) / 100.0f * damage - mdef2); #else @@ -2538,7 +2538,7 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block skillratio += sc->data[SC_LKCONCENTRATION]->val2; if( sd && sd->status.weapon == W_KATAR && (i=pc->checkskill(sd,ASC_KATAR)) > 0 ) skillratio += skillratio * (10 + 2 * i) / 100; -#endif +#endif if( sc && sc->data[SC_CRUSHSTRIKE] ){ if( sd ) {//ATK [{Weapon Level * (Weapon Upgrade Level + 6) * 100} + (Weapon ATK) + (Weapon Weight)]% @@ -2985,7 +2985,7 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam rnd()%100 < sce->val3) status->heal(src, damage*sce->val4/100, 0, 3); - if( (sce = sc->data[SC_FORCEOFVANGUARD]) && flag&BF_WEAPON + if( (sce = sc->data[SC_FORCEOFVANGUARD]) && flag&BF_WEAPON && rnd()%100 < sce->val2 && sc->fv_counter <= sce->val3 ) clif->millenniumshield(bl, sc->fv_counter++); @@ -4517,7 +4517,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list ATK_RATE(50); RE_SKILL_REDUCTION(); } - break; + 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) - status->get_total_def(target); @@ -4886,7 +4886,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list ATK_ADDRATE(sd->bonus.long_attack_atk_rate); if( sc && sc->data[SC_MTF_RANGEATK] ) ATK_ADDRATE(25);// temporary it should be 'bonus.long_attack_atk_rate' - #endif + #endif if( (i=pc->checkskill(sd,AB_EUCHARISTICA)) > 0 && (tstatus->race == RC_DEMON || tstatus->def_ele == ELE_DARK) ) ATK_ADDRATE(-i); @@ -5124,12 +5124,13 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list temp = pc->checkskill(sd,TF_DOUBLE); wd.damage2 = wd.damage * (1 + (temp * 2))/100; - if(wd.damage && !wd.damage2) wd.damage2 = + if(wd.damage && !wd.damage2) { #ifdef RENEWAL - 0; + wd.damage2 = 0; #else - 1; + wd.damage2 = 1; #endif + } flag.lh = 1; } } diff --git a/src/map/battle.h b/src/map/battle.h index fbe097c78..8d7e4183a 100644 --- a/src/map/battle.h +++ b/src/map/battle.h @@ -537,9 +537,9 @@ struct battle_interface { int64 (*attr_fix) (struct block_list *src, struct block_list *target, int64 damage, int atk_elem, int def_type, int def_lv); /* applies card modifiers */ int64 (*calc_cardfix) (int attack_type, struct block_list *src, struct block_list *target, int nk, int s_ele, int s_ele_, int64 damage, int left, int flag); - /* applies element modifiers */ + /* applies element modifiers */ int64 (*calc_elefix) (struct block_list *src, struct block_list *target, uint16 skill_id, uint16 skill_lv, int64 damage, int nk, int n_ele, int s_ele, int s_ele_, bool left, int flag); - /* applies mastery modifiers */ + /* applies mastery modifiers */ int64 (*calc_masteryfix) (struct block_list *src, struct block_list *target, uint16 skill_id, uint16 skill_lv, int64 damage, int div, bool left, bool weapon); /* calculates chorus bonus */ int (*calc_chorusbonus) (struct map_session_data *sd); diff --git a/src/map/chat.c b/src/map/chat.c index c9d3e6d46..40a9d2348 100644 --- a/src/map/chat.c +++ b/src/map/chat.c @@ -157,8 +157,8 @@ bool chat_joinchat(struct map_session_data* sd, int chatid, const char* pass) { pc_setchatid(sd,cd->bl.id); clif->joinchatok(sd, cd); //To the person who newly joined the list of all - 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 + 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->trigger_event(cd); //Event @@ -446,7 +446,7 @@ bool chat_npckickall(struct chat_data* cd) } /*===================================== -* Default Functions : chat.h +* Default Functions : chat.h * Generated by HerculesInterfaceMaker * created by Susu *-------------------------------------*/ diff --git a/src/map/chat.h b/src/map/chat.h index cbc2a391e..6e4fae1c0 100644 --- a/src/map/chat.h +++ b/src/map/chat.h @@ -17,7 +17,7 @@ struct npc_data; struct chat_data { struct block_list bl; // data for this map object - char title[CHATROOM_TITLE_SIZE]; // room title + char title[CHATROOM_TITLE_SIZE]; // room title char pass[CHATROOM_PASS_SIZE]; // password bool pub; // private/public flag uint8 users; // current user count @@ -34,7 +34,7 @@ struct chat_data { }; /*===================================== -* Interface : chat.h +* Interface : chat.h * Generated by HerculesInterfaceMaker * created by Susu *-------------------------------------*/ diff --git a/src/map/chrif.c b/src/map/chrif.c index 81e2d387c..a69cca573 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -271,7 +271,7 @@ bool chrif_save(struct map_session_data *sd, int flag) { if (flag) sd->state.storage_flag = 0; //Force close it. - //Saving of registry values. + //Saving of registry values. if (sd->vars_dirty) intif->saveregistry(sd); @@ -291,7 +291,7 @@ bool chrif_save(struct map_session_data *sd, int flag) { if( sd->md && mercenary->get_lifetime(sd->md) > 0 ) mercenary->save(sd->md); if( sd->ed && elemental->get_lifetime(sd->ed) > 0 ) - elemental->save(sd->ed); + elemental->save(sd->ed); if( sd->save_quest ) intif->quest_save(sd); @@ -1367,7 +1367,7 @@ int chrif_parse(int fd) { 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 + if (r == 1) continue; // Treated in intif if (r == 2) return 0; // Didn't have enough data (len==-1) ShowWarning("chrif_parse: session #%d, intif->parse failed (unrecognized command 0x%.4x).\n", fd, cmd); @@ -1638,7 +1638,7 @@ void do_init_chrif(bool minimal) { /*===================================== -* Default Functions : chrif.h +* Default Functions : chrif.h * Generated by HerculesInterfaceMaker * created by Susu *-------------------------------------*/ diff --git a/src/map/chrif.h b/src/map/chrif.h index 84efc66d3..661ba8f84 100644 --- a/src/map/chrif.h +++ b/src/map/chrif.h @@ -41,7 +41,7 @@ struct auth_node { }; /*===================================== -* Interface : chrif.h +* Interface : chrif.h * Generated by HerculesInterfaceMaker * created by Susu *-------------------------------------*/ diff --git a/src/map/clif.c b/src/map/clif.c index 068cb1e07..d1ae2eb07 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -1105,7 +1105,7 @@ void clif_spawn_unit(struct block_list* bl, enum send_target target) { p.accessory = status->get_emblem_id(bl); p.accessory2 = GetWord(g_id, 1); p.accessory3 = GetWord(g_id, 0); - } + } p.headpalette = vd->hair_color; p.bodypalette = vd->cloth_color; p.headDir = (sd)? sd->head_dir : 0; @@ -1225,7 +1225,7 @@ void clif_set_unit_walking(struct block_list* bl, struct map_session_data *tsd, p.GID = -bl->id; #else p.GID = -bl->id; -#endif +#endif clif->send(&p,sizeof(p),bl,SELF); } } @@ -5639,7 +5639,7 @@ void clif_displaymessage2(const int fd, const char* mes) { } line = strtok(NULL, "\n"); } - aFree(message); + aFree(message); } } /* oh noo! another version of 0x8e! */ @@ -6170,7 +6170,7 @@ void clif_item_refine_list(struct map_session_data *sd) WFIFOHEAD(fd, MAX_INVENTORY * 13 + 4); WFIFOW(fd,0)=0x221; for(i=c=0;i<MAX_INVENTORY;i++){ - if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify + if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify && (wlv=itemdb_wlv(sd->status.inventory[i].nameid)) >=1 && !sd->inventory_data[i]->flag.no_refine && !(sd->status.inventory[i].equip&EQP_ARMS)){ @@ -8429,7 +8429,7 @@ void clif_message(struct block_list* bl, const char* msg) { /** * Notifies the client that the storage window is still open * - * Should only be used in cases where the client closed the + * Should only be used in cases where the client closed the * storage window without server's consent **/ void clif_refresh_storagewindow( struct map_session_data *sd ) { @@ -10312,7 +10312,7 @@ void clif_hercules_chsys_quit(struct map_session_data *sd) { sd->channel_count = 0; aFree(sd->channels); - sd->channels = NULL; + sd->channels = NULL; } /// Request for an action. @@ -11163,8 +11163,8 @@ void clif_parse_GetItemFromCart(int fd,struct map_session_data *sd) /// 012a void clif_parse_RemoveOption(int fd,struct map_session_data *sd) { - if( !(sd->sc.option&(OPTION_RIDING|OPTION_FALCON|OPTION_DRAGON|OPTION_MADOGEAR)) -#ifdef NEW_CARTS + if( !(sd->sc.option&(OPTION_RIDING|OPTION_FALCON|OPTION_DRAGON|OPTION_MADOGEAR)) +#ifdef NEW_CARTS && sd->sc.data[SC_PUSH_CART] ){ pc->setcart(sd,0); #else @@ -13716,7 +13716,7 @@ void clif_parse_GMReqNoChat(int fd,struct map_session_data *sd) { return; value = battle_config.client_accept_chatdori; - dstsd = sd; + dstsd = sd; } else { dstsd = map->id2sd(id); if( dstsd == NULL ) @@ -17557,7 +17557,7 @@ void clif_parse_CashShopOpen(int fd, struct map_session_data *sd) { WFIFOW(fd, 0) = 0x845; WFIFOL(fd, 2) = sd->cashPoints; //[Ryuuzaki] - switched positions to reflect proper values WFIFOL(fd, 6) = sd->kafraPoints; - WFIFOSET(fd, 10); + WFIFOSET(fd, 10); } void clif_parse_CashShopClose(int fd, struct map_session_data *sd) { @@ -17792,7 +17792,7 @@ void clif_bgqueue_ack(struct map_session_data *sd, enum BATTLEGROUNDS_QUEUE_ACK clif->send(&p,sizeof(p), &sd->bl, SELF); } break; - } + } } @@ -17824,7 +17824,7 @@ void clif_parse_bgqueue_register(int fd, struct map_session_data *sd) { default: clif->bgqueue_ack(sd,BGQA_FAIL_TYPE_INVALID, arena->id); return; - } + } bg->queue_add(sd, arena, (enum bg_queue_types)p->type); } @@ -19024,7 +19024,7 @@ void clif_defaults(void) { clif->search_store_info_failed = clif_search_store_info_failed; clif->open_search_store_info = clif_open_search_store_info; clif->search_store_info_click_ack = clif_search_store_info_click_ack; - /* elemental-related */ + /* elemental-related */ clif->elemental_info = clif_elemental_info; clif->elemental_updatestatus = clif_elemental_updatestatus; /* bgqueue */ @@ -19034,7 +19034,7 @@ void clif_defaults(void) { clif->bgqueue_joined = clif_bgqueue_joined; clif->bgqueue_pcleft = clif_bgqueue_pcleft; clif->bgqueue_battlebegins = clif_bgqueue_battlebegins; - /* misc-handling */ + /* misc-handling */ clif->adopt_reply = clif_Adopt_reply; clif->adopt_request = clif_Adopt_request; clif->readbook = clif_readbook; @@ -19071,7 +19071,7 @@ void clif_defaults(void) { clif->npc_market_purchase_ack = clif_npc_market_purchase_ack; /*------------------------ *- Parse Incoming Packet - *------------------------*/ + *------------------------*/ clif->pWantToConnection = clif_parse_WantToConnection; clif->pLoadEndAck = clif_parse_LoadEndAck; clif->pTickSend = clif_parse_TickSend; @@ -19125,7 +19125,7 @@ void clif_defaults(void) { clif->pUseSkillToPos = clif_parse_UseSkillToPos; clif->pUseSkillToPosSub = clif_parse_UseSkillToPosSub; clif->pUseSkillToPos_homun = clif_parse_UseSkillToPos_homun; - clif->pUseSkillToPos_mercenary = clif_parse_UseSkillToPos_mercenary; + clif->pUseSkillToPos_mercenary = clif_parse_UseSkillToPos_mercenary; clif->pUseSkillToPosMoreInfo = clif_parse_UseSkillToPosMoreInfo; clif->pUseSkillMap = clif_parse_UseSkillMap; clif->pRequestMemo = clif_parse_RequestMemo; diff --git a/src/map/duel.c b/src/map/duel.c index a423ef240..4e4eeef1f 100644 --- a/src/map/duel.c +++ b/src/map/duel.c @@ -128,7 +128,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) { - map->foreachpc(duel_leave_sub, did); + map->foreachpc(duel_leave_sub, did); duel->count--; } @@ -176,7 +176,7 @@ void do_init_duel(bool minimal) { } /*===================================== -* Default Functions : duel.h +* Default Functions : duel.h * Generated by HerculesInterfaceMaker * created by Susu *-------------------------------------*/ diff --git a/src/map/duel.h b/src/map/duel.h index 956aed36d..91dfa8f83 100644 --- a/src/map/duel.h +++ b/src/map/duel.h @@ -18,7 +18,7 @@ struct duel { #define MAX_DUEL 1024 /*===================================== -* Interface : duel.h +* Interface : duel.h * Generated by HerculesInterfaceMaker * created by Susu *-------------------------------------*/ diff --git a/src/map/elemental.c b/src/map/elemental.c index 323df41e1..b414d5b9f 100644 --- a/src/map/elemental.c +++ b/src/map/elemental.c @@ -951,7 +951,7 @@ void do_final_elemental(void) { } /*===================================== -* Default Functions : elemental.h +* Default Functions : elemental.h * Generated by HerculesInterfaceMaker * created by Susu *-------------------------------------*/ diff --git a/src/map/elemental.h b/src/map/elemental.h index aa27aadc9..beddd3ea1 100644 --- a/src/map/elemental.h +++ b/src/map/elemental.h @@ -64,7 +64,7 @@ struct elemental_data { }; /*===================================== -* Interface : elemental.h +* Interface : elemental.h * Generated by HerculesInterfaceMaker * created by Susu *-------------------------------------*/ diff --git a/src/map/guild.c b/src/map/guild.c index 69f67238d..935cac8c0 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -1004,7 +1004,7 @@ int guild_recv_memberinfoshort(int guild_id,int account_id,int char_id,int onlin //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); - if(oldonline!=online) + if(oldonline!=online) clif->guild_memberlogin_notice(g, idx, online); if(!g->member[idx].sd) @@ -2008,7 +2008,7 @@ void guild_castle_reconnect_sub(void *key, void *data, va_list ap) } /** - * Saves pending guild castle data changes when char-server is + * Saves pending guild castle data changes when char-server is * disconnected. * On reconnect pushes all changes to char-server for saving. */ @@ -2363,7 +2363,7 @@ void guild_defaults(void) { guild->flag_add = guild_flag_add; guild->flag_remove = guild_flag_remove; guild->flags_clear = guild_flags_clear; - /* guild aura */ + /* guild aura */ guild->aura_refresh = guild_guildaura_refresh; /* */ guild->payexp_timer = guild_payexp_timer; diff --git a/src/map/intif.c b/src/map/intif.c index 383150fbc..75379f6c0 100644 --- a/src/map/intif.c +++ b/src/map/intif.c @@ -2305,7 +2305,7 @@ int intif_parse(int fd) } /*===================================== -* Default Functions : intif.h +* Default Functions : intif.h * Generated by HerculesInterfaceMaker * created by Susu *-------------------------------------*/ diff --git a/src/map/intif.h b/src/map/intif.h index b6ee727f3..d0eeccc6d 100644 --- a/src/map/intif.h +++ b/src/map/intif.h @@ -32,7 +32,7 @@ struct s_pet; /*===================================== -* Interface : intif.h +* Interface : intif.h * Generated by HerculesInterfaceMaker * created by Susu *-------------------------------------*/ @@ -42,7 +42,7 @@ struct intif_interface { /* funcs */ int (*parse) (int fd); int (*create_pet)(int account_id, int char_id, short pet_type, short pet_lv, short pet_egg_id, - short pet_equip, short intimate, short hungry, char rename_flag, char incuvate, char *pet_name); + short pet_equip, short intimate, short hungry, char rename_flag, char incuvate, char *pet_name); int (*broadcast) (const char* mes, size_t len, int type); int (*broadcast2) (const char* mes, size_t len, unsigned int fontColor, short fontType, short fontSize, short fontAlign, short fontY); int (*main_message) (struct map_session_data* sd, const char* message); diff --git a/src/map/itemdb.c b/src/map/itemdb.c index 1981f435c..9bc352276 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -27,7 +27,7 @@ struct itemdb_interface itemdb_s; /** - * Search for item name + * Search for item name * name = item alias, so we should find items aliases first. if not found then look for "jname" (full name) * @see DBApply */ @@ -55,7 +55,7 @@ int itemdb_searchname_sub(DBKey key, DBData *data, va_list ap) } /*========================================== - * Return item data from item name. (lookup) + * Return item data from item name. (lookup) *------------------------------------------*/ struct item_data* itemdb_searchname(const char *str) { struct item_data* item; @@ -256,7 +256,7 @@ void itemdb_package_item(struct map_session_data *sd, struct item_package *packa return; } /*========================================== - * Return a random item id from group. (takes into account % chance giving/tot group) + * Return a random item id from group. (takes into account % chance giving/tot group) *------------------------------------------*/ int itemdb_searchrandomid(struct item_group *group) { @@ -312,7 +312,7 @@ const char* itemdb_typename(int type) } /*========================================== - * Converts the jobid from the format in itemdb + * Converts the jobid from the format in itemdb * to the format used by the map server. [Skotlex] *------------------------------------------*/ void itemdb_jobid2mapid(unsigned int *bclass, unsigned int jobmask) @@ -470,8 +470,7 @@ int itemdb_isequip(int nameid) /*========================================== * Alternate version of itemdb_isequip *------------------------------------------*/ -int itemdb_isequip2(struct item_data *data) -{ +int itemdb_isequip2(struct item_data *data) { nullpo_ret(data); switch(data->type) { case IT_WEAPON: @@ -937,7 +936,7 @@ void itemdb_read_packages(void) { if( HCache->check(config_filename) ) { if( itemdb->read_cached_packages(config_filename) ) return; - } + } if (libconfig->read_file(&item_packages_conf, config_filename)) { ShowError("can't read %s\n", config_filename); @@ -1445,7 +1444,7 @@ void itemdb_read_combos() { p++; str[1] = p; - p = strchr(p,','); + p = strchr(p,','); p++; if (str[1][0] != '{') { @@ -2217,7 +2216,7 @@ void itemdb_name_constants(void) { script->parser_current_file = NULL; #endif // ENABLE_CASE_CHECK - dbi_destroy(iter); + dbi_destroy(iter); } void do_final_itemdb(void) { itemdb->clear(true); diff --git a/src/map/map.c b/src/map/map.c index 01d3dbb9f..e37e902f6 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -494,7 +494,7 @@ static int bl_vforeach(int (*func)(struct block_list*, va_list), int blockcount, static int map_vforeachinmap(int (*func)(struct block_list*, va_list), int16 m, int type, va_list args) { int i; int returnCount = 0; - int bsize; + int bsize; va_list argscopy; struct block_list *bl; int blockcount = map->bl_list_count; @@ -5861,7 +5861,7 @@ int do_init(int argc, char *argv[]) } /*===================================== -* Default Functions : map.h +* Default Functions : map.h * Generated by HerculesInterfaceMaker * created by Susu *-------------------------------------*/ diff --git a/src/map/map.h b/src/map/map.h index 539b02ed8..73ef4bb41 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -579,9 +579,9 @@ struct map_data { "Algorithms in Java, Parts 1-4" 3.18, Robert Sedgewick Map is divided into squares, called blocks (side length = BLOCK_SIZE). For each block there is a linked list of objects in that block (block_list). - Array provides capability to access immediately the set of objects close + Array provides capability to access immediately the set of objects close to a given object. - The linked lists provide the flexibility to store the objects without + The linked lists provide the flexibility to store the objects without knowing ahead how many objects fall into each block. */ struct block_list **block; // Grid array of block_lists containing only non-BL_MOB objects @@ -796,7 +796,7 @@ struct map_cache_map_info { /*===================================== -* Interface : map.h +* Interface : map.h * Generated by HerculesInterfaceMaker * created by Susu *-------------------------------------*/ diff --git a/src/map/mercenary.c b/src/map/mercenary.c index 26bc8c188..80bcfdf05 100644 --- a/src/map/mercenary.c +++ b/src/map/mercenary.c @@ -503,7 +503,7 @@ void do_init_mercenary(bool minimal) { } /*===================================== -* Default Functions : mercenary.h +* Default Functions : mercenary.h * Generated by HerculesInterfaceMaker * created by Susu *-------------------------------------*/ diff --git a/src/map/mercenary.h b/src/map/mercenary.h index b998ac006..22399e289 100644 --- a/src/map/mercenary.h +++ b/src/map/mercenary.h @@ -48,7 +48,7 @@ struct mercenary_data { }; /*===================================== -* Interface : mercenary.h +* Interface : mercenary.h * Generated by HerculesInterfaceMaker * created by Susu *-------------------------------------*/ diff --git a/src/map/mob.c b/src/map/mob.c index 11ac74621..784bb5a07 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -3880,7 +3880,7 @@ bool mob_parse_dbrow(char** str) { mob->db_data[class_] = (struct mob_db*)aMalloc(sizeof(struct mob_db)); else //Copy over spawn data - memcpy(&db->spawn, mob->db_data[class_]->spawn, sizeof(db->spawn)); + memcpy(&db->spawn, mob->db_data[class_]->spawn, sizeof(db->spawn)); memcpy(mob->db_data[class_], db, sizeof(struct mob_db)); return true; diff --git a/src/map/npc.c b/src/map/npc.c index cf509e11f..0817313e2 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -1154,10 +1154,10 @@ int npc_click(struct map_session_data* sd, struct npc_data* nd) // This usually happens when the player clicked on a NPC that has the view id // of a mob, to activate this kind of npc it's needed to be in a 2,2 range - // from it. If the OnTouch area of a npc, coincides with the 2,2 range of + // from it. If the OnTouch area of a npc, coincides with the 2,2 range of // another it's expected that the OnTouch event be put first in stack, because // unit_walktoxy_timer is executed before any other function in this case. - // So it's best practice to put an 'end;' before OnTouch events in npcs that + // So it's best practice to put an 'end;' before OnTouch events in npcs that // have view ids of mobs to avoid this "issue" [Panikon] if (sd->npc_id != 0) { // The player clicked a npc after entering an OnTouch area diff --git a/src/map/npc_chat.c b/src/map/npc_chat.c index f245ffea5..2182e1da2 100644 --- a/src/map/npc_chat.c +++ b/src/map/npc_chat.c @@ -49,7 +49,7 @@ struct pcre_interface libpcre_s; * * defpattern 1, "[^:]+: (.*) loves (.*)", "label"; * - * this defines a new pattern in set 1 using perl syntax + * this defines a new pattern in set 1 using perl syntax * (http://www.troubleshooters.com/codecorn/littperl/perlreg.htm) * and tells it to jump to the supplied label when the pattern * is matched. @@ -59,7 +59,7 @@ struct pcre_interface libpcre_s; * before the script gets executed. * * activatepset 1; - * + * * This activates a set of patterns.. You can have many pattern * sets defined and many active all at once. This feature allows * you to set up "conversations" and ever changing expectations of @@ -95,11 +95,10 @@ void finalize_pcrematch_entry(struct pcrematch_entry* e) /** * Lookup (and possibly create) a new set of patterns by the set id */ -struct pcrematch_set* lookup_pcreset(struct npc_data* nd, int setid) -{ +struct pcrematch_set* lookup_pcreset(struct npc_data* nd, int setid) { struct pcrematch_set *pcreset; struct npc_parse *npcParse = nd->chatdb; - if (npcParse == NULL) + if (npcParse == NULL) nd->chatdb = npcParse = (struct npc_parse *)aCalloc(sizeof(struct npc_parse), 1); pcreset = npcParse->active; @@ -109,7 +108,7 @@ struct pcrematch_set* lookup_pcreset(struct npc_data* nd, int setid) break; pcreset = pcreset->next; } - if (pcreset == NULL) + if (pcreset == NULL) pcreset = npcParse->inactive; while (pcreset != NULL) { @@ -140,7 +139,7 @@ void activate_pcreset(struct npc_data* nd, int setid) { struct pcrematch_set *pcreset; struct npc_parse *npcParse = nd->chatdb; - if (npcParse == NULL) + if (npcParse == NULL) return; // Nothing to activate... pcreset = npcParse->inactive; while (pcreset != NULL) { @@ -154,7 +153,7 @@ void activate_pcreset(struct npc_data* nd, int setid) pcreset->next->prev = pcreset->prev; if (pcreset->prev != NULL) pcreset->prev->next = pcreset->next; - else + else npcParse->inactive = pcreset->next; pcreset->prev = NULL; @@ -173,7 +172,7 @@ void deactivate_pcreset(struct npc_data* nd, int setid) { struct pcrematch_set *pcreset; struct npc_parse *npcParse = nd->chatdb; - if (npcParse == NULL) + if (npcParse == NULL) return; // Nothing to deactivate... if (setid == -1) { while(npcParse->active != NULL) @@ -192,7 +191,7 @@ void deactivate_pcreset(struct npc_data* nd, int setid) pcreset->next->prev = pcreset->prev; if (pcreset->prev != NULL) pcreset->prev->next = pcreset->next; - else + else npcParse->active = pcreset->next; pcreset->prev = NULL; @@ -210,7 +209,7 @@ void delete_pcreset(struct npc_data* nd, int setid) int active = 1; struct pcrematch_set *pcreset; struct npc_parse *npcParse = nd->chatdb; - if (npcParse == NULL) + if (npcParse == NULL) return; // Nothing to deactivate... pcreset = npcParse->active; while (pcreset != NULL) { @@ -227,7 +226,7 @@ void delete_pcreset(struct npc_data* nd, int setid) pcreset = pcreset->next; } } - if (pcreset == NULL) + if (pcreset == NULL) return; if (pcreset->next != NULL) @@ -254,7 +253,7 @@ void delete_pcreset(struct npc_data* nd, int setid) } /** - * create a new pattern entry + * create a new pattern entry */ struct pcrematch_entry* create_pcrematch_entry(struct pcrematch_set* set) { @@ -300,7 +299,7 @@ void npc_chat_def_pattern(struct npc_data* nd, int setid, const char* pattern, c /** * Delete everything associated with a NPC concerning the pattern - * matching code + * matching code * * this could be more efficent but.. how often do you do this? */ diff --git a/src/map/packets.h b/src/map/packets.h index da1f176ff..fe323965c 100644 --- a/src/map/packets.h +++ b/src/map/packets.h @@ -2600,19 +2600,19 @@ packet(0x020d,-1); // 2014-01-15eRagexe - YomRawr #if PACKETVER >= 20140115 - packet(0x0369,7,clif->pActionRequest,2,6); - packet(0x083C,10,clif->pUseSkillToId,2,4,6); - packet(0x0437,5,clif->pWalkToXY,2); - packet(0x035F,6,clif->pTickSend,2); - packet(0x08A7,5,clif->pChangeDir,2,4); - packet(0x0940,6,clif->pTakeItem,2); - packet(0x0361,6,clif->pDropItem,2,4); - packet(0x088E,8,clif->pMoveToKafra,2,4); - packet(0x0367,8,clif->pMoveFromKafra,2,4); - packet(0x0438,10,clif->pUseSkillToPos,2,4,6,8); - packet(0x0366,90,clif->pUseSkillToPosMoreInfo,2,4,6,8,10); - packet(0x0802,6,clif->pGetCharNameRequest,2); - packet(0x0368,6,clif->pSolveCharName,2); + packet(0x0369,7,clif->pActionRequest,2,6); + packet(0x083C,10,clif->pUseSkillToId,2,4,6); + packet(0x0437,5,clif->pWalkToXY,2); + packet(0x035F,6,clif->pTickSend,2); + packet(0x08A7,5,clif->pChangeDir,2,4); + packet(0x0940,6,clif->pTakeItem,2); + packet(0x0361,6,clif->pDropItem,2,4); + packet(0x088E,8,clif->pMoveToKafra,2,4); + packet(0x0367,8,clif->pMoveFromKafra,2,4); + packet(0x0438,10,clif->pUseSkillToPos,2,4,6,8); + packet(0x0366,90,clif->pUseSkillToPosMoreInfo,2,4,6,8,10); + packet(0x0802,6,clif->pGetCharNameRequest,2); + packet(0x0368,6,clif->pSolveCharName,2); packet(0x0360,12,clif->pSearchStoreInfoListItemClick,2,6,10); packet(0x0817,2,clif->pSearchStoreInfoNextPage,0); packet(0x0815,-1,clif->pSearchStoreInfo,2,4,5,9,13,14,15); diff --git a/src/map/packets_struct.h b/src/map/packets_struct.h index 55006db64..3d49944d1 100644 --- a/src/map/packets_struct.h +++ b/src/map/packets_struct.h @@ -596,7 +596,7 @@ struct packet_status_change { #if PACKETVER >= 20120618 unsigned int Total; #endif -#if PACKETVER >= 20090121 +#if PACKETVER >= 20090121 unsigned int Left; int val1; int val2; diff --git a/src/map/party.c b/src/map/party.c index 7c49e241c..678b2cd54 100644 --- a/src/map/party.c +++ b/src/map/party.c @@ -1364,7 +1364,7 @@ void do_init_party(bool minimal) { timer->add_interval(timer->gettick()+battle_config.party_update_interval, party->send_xy_timer, 0, 0, battle_config.party_update_interval); } /*===================================== -* Default Functions : party.h +* Default Functions : party.h * Generated by HerculesInterfaceMaker * created by Susu *-------------------------------------*/ diff --git a/src/map/party.h b/src/map/party.h index 3bad22b13..1c58301d1 100644 --- a/src/map/party.h +++ b/src/map/party.h @@ -71,7 +71,7 @@ struct party_booking_ad_info { #endif /* PARTY_RECRUIT */ /*===================================== -* Interface : party.h +* Interface : party.h * Generated by HerculesInterfaceMaker * created by Susu *-------------------------------------*/ diff --git a/src/map/path.c b/src/map/path.c index d02e9ee4a..e90b26db5 100644 --- a/src/map/path.c +++ b/src/map/path.c @@ -205,7 +205,7 @@ static int add_path(struct node_heap *heap, struct path_node *tp, int16 x, int16 if (g_cost < tp[i].g_cost) { // New path to this node is better than old one // Update costs and parent tp[i].g_cost = g_cost; - tp[i].parent = parent; + tp[i].parent = parent; tp[i].f_cost = g_cost + h_cost; if (tp[i].flag == SET_CLOSED) { heap_push_node(heap, &tp[i]); // Put it in open set again @@ -299,7 +299,7 @@ bool path_search(struct walkpath_data *wpd, int16 m, int16 x0, int16 y0, int16 x return true; } - return false; // easy path unsuccessful + return false; // easy path unsuccessful } else { // !(flag&1) // A* (A-star) pathfinding diff --git a/src/map/pc.c b/src/map/pc.c index 08ff8baf9..ce2b8040e 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -1156,7 +1156,7 @@ bool pc_authok(struct map_session_data *sd, int login_id2, time_t expiration_tim clif->message(sd->fd, buf); } - if (expiration_time != 0) { + if (expiration_time != 0) { sd->expiration_time = expiration_time; } @@ -4448,7 +4448,7 @@ int pc_useitem(struct map_session_data *sd,int n) { } } - /* on restricted maps the item is consumed but the effect is not used */ + /* on restricted maps the item is consumed but the effect is not used */ for(i = 0; i < map->list[sd->bl.m].zone->disabled_items_count; i++) { if( map->list[sd->bl.m].zone->disabled_items[i] == nameid ) { clif->msg(sd, ITEM_CANT_USE_AREA); // This item cannot be used within this area @@ -7264,7 +7264,7 @@ int pc_readparam(struct map_session_data* sd,int type) case SP_DEFELE: val = sd->battle_status.def_ele; break; #ifndef RENEWAL_CAST case SP_VARCASTRATE: -#endif +#endif case SP_CASTRATE: val = sd->castrate+=val; break; @@ -10329,7 +10329,7 @@ int pc_global_expiration_timer(int tid, int64 tick, int id, intptr_t data) { return 0; } -void pc_expire_check(struct map_session_data *sd) { +void pc_expire_check(struct map_session_data *sd) { /* ongoing timer */ if( sd->expiration_tid != INVALID_TIMER ) return; @@ -10630,7 +10630,7 @@ void do_init_pc(bool minimal) { ers_chunk_size(pc->str_reg_ers, 50); } /*===================================== -* Default Functions : pc.h +* Default Functions : pc.h * Generated by HerculesInterfaceMaker * created by Susu *-------------------------------------*/ diff --git a/src/map/pc.h b/src/map/pc.h index 5d723fcf8..90f227cee 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -725,7 +725,7 @@ struct autotrade_vending { }; /*===================================== -* Interface : pc.h +* Interface : pc.h * Generated by HerculesInterfaceMaker * created by Susu *-------------------------------------*/ diff --git a/src/map/pc_groups.c b/src/map/pc_groups.c index a917ef409..e577c642f 100644 --- a/src/map/pc_groups.c +++ b/src/map/pc_groups.c @@ -183,7 +183,7 @@ static void read_config(void) { int j, inherit_count = 0, done = 0; if (group_settings->inheritance_done) // group already processed - continue; + continue; if ((inherit = group_settings->inherit) == NULL || (inherit_count = libconfig->setting_length(inherit)) <= 0) { // this group does not inherit from others diff --git a/src/map/pet.c b/src/map/pet.c index aa2be4473..6a458eae6 100644 --- a/src/map/pet.c +++ b/src/map/pet.c @@ -99,7 +99,7 @@ int pet_unlocktarget(struct pet_data *pd) * Pet Attack Skill [Skotlex] *------------------------------------------*/ int pet_attackskill(struct pet_data *pd, int target_id) { - if (!battle_config.pet_status_support || !pd->a_skill || + if (!battle_config.pet_status_support || !pd->a_skill || (battle_config.pet_equip_required && !pd->pet.equip)) return 0; @@ -107,7 +107,7 @@ int pet_attackskill(struct pet_data *pd, int target_id) { return 0; if (rnd()%100 < (pd->a_skill->rate +pd->pet.intimate*pd->a_skill->bonusrate/1000)) { - //Skotlex: Use pet's skill + //Skotlex: Use pet's skill int inf; struct block_list *bl; @@ -158,7 +158,7 @@ int pet_target_check(struct map_session_data *sd,struct block_list *bl,int type) if(pd->petDB->defence_attack_rate > 0 && rate <= 0) rate = 1; } - if(rnd()%10000 < rate) + if(rnd()%10000 < rate) { if(pd->target_id == 0 || rnd()%10000 < pd->petDB->change_target_rate) pd->target_id = bl->id; @@ -319,7 +319,7 @@ int pet_data_init(struct map_session_data *sd, struct s_pet *petinfo) nullpo_retr(1, sd); - Assert((sd->status.pet_id == 0 || sd->pd == 0) || sd->pd->msd == sd); + Assert((sd->status.pet_id == 0 || sd->pd == 0) || sd->pd->msd == sd); if(sd->status.account_id != petinfo->account_id || sd->status.char_id != petinfo->char_id) { sd->status.pet_id = 0; @@ -390,7 +390,7 @@ int pet_birth_process(struct map_session_data *sd, struct s_pet *petinfo) { nullpo_retr(1, sd); - Assert((sd->status.pet_id == 0 || sd->pd == 0) || sd->pd->msd == sd); + Assert((sd->status.pet_id == 0 || sd->pd == 0) || sd->pd->msd == sd); if(sd->status.pet_id && petinfo->incuvate == 1) { sd->status.pet_id = 0; @@ -418,7 +418,7 @@ int pet_birth_process(struct map_session_data *sd, struct s_pet *petinfo) clif->send_petdata(NULL, sd->pd, 3, sd->pd->vd.head_bottom); clif->send_petstatus(sd); } - Assert((sd->status.pet_id == 0 || sd->pd == 0) || sd->pd->msd == sd); + Assert((sd->status.pet_id == 0 || sd->pd == 0) || sd->pd->msd == sd); return 0; } @@ -912,7 +912,7 @@ int pet_ai_sub_hard(struct pet_data *pd, struct map_session_data *sd, int64 tick (pd->ud.attacktimer != INVALID_TIMER || pd->ud.walktimer != INVALID_TIMER)) return 0; //Target already locked. - if (target->type != BL_ITEM) + if (target->type != BL_ITEM) { //enemy targetted if(!battle->check_range(&pd->bl,target,pd->status.rhw.range)) { //Chase @@ -934,7 +934,7 @@ int pet_ai_sub_hard(struct pet_data *pd, struct map_session_data *sd, int64 tick 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; map->clearflooritem(target); - } + } //Target is unlocked regardless of whether it was picked or not. pet->unlocktarget(pd); } @@ -1050,7 +1050,7 @@ 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, int64 tick, int id, intptr_t data) { struct map_session_data *sd=map->id2sd(id); struct pet_data *pd; @@ -1091,7 +1091,7 @@ int pet_skill_bonus_timer(int tid, int64 tick, int id, intptr_t data) { /*========================================== * pet recovery skills [Valaris] / Rewritten by [Skotlex] - *------------------------------------------*/ + *------------------------------------------*/ int pet_recovery_timer(int tid, int64 tick, int id, intptr_t data) { struct map_session_data *sd=map->id2sd(id); struct pet_data *pd; @@ -1107,7 +1107,7 @@ int pet_recovery_timer(int tid, int64 tick, int id, intptr_t data) { } if(sd->sc.data[pd->recovery->type]) - { //Display a heal animation? + { //Display a heal animation? //Detoxify is chosen for now. clif->skill_nodamage(&pd->bl,&sd->bl,TF_DETOXIFY,1,1); status_change_end(&sd->bl, pd->recovery->type, INVALID_TIMER); @@ -1155,7 +1155,7 @@ int pet_heal_timer(int tid, int64 tick, int id, intptr_t data) { /*========================================== * pet support skills [Skotlex] - *------------------------------------------*/ + *------------------------------------------*/ int pet_skill_support_timer(int tid, int64 tick, int id, intptr_t data) { struct map_session_data *sd=map->id2sd(id); struct pet_data *pd; @@ -1202,12 +1202,12 @@ int pet_skill_support_timer(int tid, int64 tick, int id, intptr_t data) { * Pet read db data * pet->db.txt * pet->db2.txt - *------------------------------------------*/ + *------------------------------------------*/ int read_petdb() { char* filename[] = {"pet_db.txt","pet_db2.txt"}; FILE *fp; - int nameid,i,j,k; + int nameid,i,j,k; // Remove any previous scripts in case reloaddb was invoked. for( j = 0; j < MAX_PET_DB; j++ ) diff --git a/src/map/skill.c b/src/map/skill.c index b2e94ec79..94bcd1d1b 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -2234,7 +2234,7 @@ int skill_attack(int attack_type, struct block_list* src, struct block_list *dsr status_change_end(bl, SC_ENERGYCOAT, INVALID_TIMER); //Reduction: 6% + 6% every 20% dmg.damage -= dmg.damage * (6 * (1+per)) / 100; - } + } } #endif /* MAGIC_REFLECTION_TYPE */ } @@ -2647,7 +2647,7 @@ int skill_attack(int attack_type, struct block_list* src, struct block_list *dsr //blown-specific handling switch( skill_id ) { case LG_OVERBRAND_BRANDISH: - if( skill->blown(dsrc,bl,dmg.blewcount,dir,0) < dmg.blewcount ) + if( skill->blown(dsrc,bl,dmg.blewcount,dir,0) < dmg.blewcount ) skill->addtimerskill(src, tick + status_get_amotion(src), bl->id, 0, 0, LG_OVERBRAND_PLUSATK, skill_lv, BF_WEAPON, flag|SD_ANIMATION); break; case SR_KNUCKLEARROW: @@ -3165,7 +3165,7 @@ int skill_timerskill(int tid, int64 tick, int id, intptr_t data) { BL_CHAR|BL_SKILL, target->id); // Search for a new Target around current one... if( nbl == NULL) skl->x++; - else + else skl->x = 0; skill->addtimerskill(src, tick + 651, (nbl?nbl:target)->id, skl->x, 0, WL_CHAINLIGHTNING_ATK, skl->skill_lv, skl->type + 1, skl->flag); @@ -3177,9 +3177,9 @@ int skill_timerskill(int tid, int64 tick, int id, intptr_t data) { case WL_TETRAVORTEX_WIND: case WL_TETRAVORTEX_GROUND: clif->skill_nodamage(src, target, skl->skill_id, skl->skill_lv, 1); - skill->attack(BF_MAGIC, src, src, target, skl->skill_id, skl->skill_lv, tick, skl->flag); + skill->attack(BF_MAGIC, src, src, target, skl->skill_id, skl->skill_lv, tick, skl->flag); skill->toggle_magicpower(src, skl->skill_id); // only the first hit will be amplify - if( skl->type == 4 ){ + if( skl->type == 4 ){ const enum sc_type scs[] = { SC_BURNING, SC_BLOODING, SC_FROSTMISTY, SC_STUN }; // status inflicts are depend on what summoned element is used. int rate = skl->y, index = skl->x-1; sc_start2(src,target, scs[index], rate, skl->skill_lv, src->id, skill->get_time(WL_TETRAVORTEX,index+1)); @@ -4196,7 +4196,7 @@ int skill_castend_damage_id(struct block_list* src, struct block_list *bl, uint1 case WL_TETRAVORTEX: if( sc ){ int i = SC_SUMMON5, x = 0; - int types[][2] = {{0, 0}, {0, 0}, {0, 0}, {0, 0}}; + int types[][2] = {{0, 0}, {0, 0}, {0, 0}, {0, 0}}; for(; i >= SC_SUMMON1; i--){ if( sc->data[i] ){ int skillid = WL_TETRAVORTEX_FIRE + (sc->data[i]->val1 - WLS_FIRE) + (sc->data[i]->val1 == WLS_WIND) - (sc->data[i]->val1 == WLS_WATER), sc_index = 0, rate = 0; @@ -4272,7 +4272,7 @@ int skill_castend_damage_id(struct block_list* src, struct block_list *bl, uint1 if (sd->skillcooldown[i].id == spell_skill_id){ cooldown += sd->skillcooldown[i].val; break; - } + } } if(cooldown) skill->blockpc_start(sd, spell_skill_id, cooldown); @@ -4769,10 +4769,10 @@ int skill_castend_id(int tid, int64 tick, int id, intptr_t data) { inf &= ~BCT_NEUTRAL; } - if( sd && (inf2&INF2_CHORUS_SKILL) && skill->check_pc_partner(sd, ud->skill_id, &ud->skill_lv, 1, 0) < 1 ) { - clif->skill_fail(sd, ud->skill_id, USESKILL_FAIL_NEED_HELPER, 0); - break; - } + if( sd && (inf2&INF2_CHORUS_SKILL) && skill->check_pc_partner(sd, ud->skill_id, &ud->skill_lv, 1, 0) < 1 ) { + clif->skill_fail(sd, ud->skill_id, USESKILL_FAIL_NEED_HELPER, 0); + break; + } if( ud->skill_id >= SL_SKE && ud->skill_id <= SL_SKA && target->type == BL_MOB ) { @@ -5036,7 +5036,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin **/ case AB_RENOVATIO: case AB_HIGHNESSHEAL: - case AL_INCAGI: + case AL_INCAGI: if( sd && dstsd && pc_ismadogear(dstsd) ){ clif->skill_fail(sd,skill_id,USESKILL_FAIL_TOTARGET,0); return 0; @@ -5674,7 +5674,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin case KN_AUTOCOUNTER: sc_start(src,bl,type,100,skill_lv,skill->get_time(skill_id,skill_lv)); - skill->addtimerskill(src, tick + 100, bl->id, 0, 0, skill_id, skill_lv, BF_WEAPON, flag); + skill->addtimerskill(src, tick + 100, bl->id, 0, 0, skill_id, skill_lv, BF_WEAPON, flag); break; case SO_STRIKING: @@ -10315,7 +10315,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui case WM_SOUND_OF_DESTRUCTION: r = skill->get_splash(skill_id,skill_lv); map->foreachinarea(skill->area_sub,src->m,x-r,y-r,x+r,y+r,BL_CHAR,src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_damage_id); - break; + break; case WM_LULLABY_DEEPSLEEP: r = skill->get_splash(skill_id,skill_lv); @@ -11669,7 +11669,7 @@ int skill_unit_onplace_timer(struct skill_unit *src, struct block_list *bl, int6 case UNT_FIREPILLAR_ACTIVE: case UNT_CLAYMORETRAP: if( sg->unit_id == UNT_FIRINGTRAP || sg->unit_id == UNT_ICEBOUNDTRAP || sg->unit_id == UNT_CLAYMORETRAP ) - 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); + 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 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) @@ -13054,7 +13054,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id { int j, i = 0; for(j = SC_SUMMON1; j <= SC_SUMMON5; j++) - if( sc && sc->data[j] ) + if( sc && sc->data[j] ) i++; switch(skill_id){ @@ -14124,9 +14124,9 @@ int skill_vfcastfix(struct block_list *bl, double time, uint16 skill_id, uint16 if( sd->bonus.varcastrate < 0 ) VARCAST_REDUCTION(sd->bonus.varcastrate); if( sd->bonus.add_varcast != 0 ) // bonus bVariableCast - time += sd->bonus.add_varcast; + time += sd->bonus.add_varcast; if( sd->bonus.add_fixcast != 0 ) // bonus bFixedCast - fixed += sd->bonus.add_fixcast; + fixed += sd->bonus.add_fixcast; for (i = 0; i < ARRAYLENGTH(sd->skillfixcast) && sd->skillfixcast[i].id; i++) if (sd->skillfixcast[i].id == skill_id){ // bonus2 bSkillFixedCast fixed += sd->skillfixcast[i].val; @@ -14197,7 +14197,7 @@ int skill_vfcastfix(struct block_list *bl, double time, uint16 skill_id, uint16 fixcast_r = max(fixcast_r, sc->data[SC_DANCE_WITH_WUG]->val4); 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) ) + 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) + 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] ) @@ -15323,7 +15323,7 @@ bool skill_check_shadowform(struct block_list *bl, int64 damage, int hit){ if( sc && sc->data[SC__SHADOWFORM] && damage ) { src = map->id2bl(sc->data[SC__SHADOWFORM]->val2); - if( !src || src->m != bl->m ) { + if( !src || src->m != bl->m ) { status_change_end(bl, SC__SHADOWFORM, INVALID_TIMER); return false; } @@ -18515,7 +18515,7 @@ void skill_defaults(void) { skill->unit_onplace = skill_unit_onplace; skill->unit_ondamaged = skill_unit_ondamaged; skill->cast_fix = skill_castfix; - skill->cast_fix_sc = skill_castfix_sc; + skill->cast_fix_sc = skill_castfix_sc; skill->vf_cast_fix = skill_vfcastfix; skill->delay_fix = skill_delay_fix; skill->check_condition_castbegin = skill_check_condition_castbegin; diff --git a/src/map/skill.h b/src/map/skill.h index b6dbb1fcb..66d6dc39e 100644 --- a/src/map/skill.h +++ b/src/map/skill.h @@ -1597,7 +1597,7 @@ enum { UNT_ZENKAI_WIND, UNT_MAKIBISHI, UNT_VENOMFOG, - UNT_ICEMINE, + UNT_ICEMINE, UNT_FLAMECROSS, UNT_HELLBURNING, UNT_MAGMA_ERUPTION, diff --git a/src/map/sql/CMakeLists.txt b/src/map/sql/CMakeLists.txt index 11751a1a5..1629b2a8b 100644 --- a/src/map/sql/CMakeLists.txt +++ b/src/map/sql/CMakeLists.txt @@ -18,7 +18,7 @@ set( SQL_MAP_HEADERS "${SQL_MAP_SOURCE_DIR}/guild.h" "${SQL_MAP_SOURCE_DIR}/homunculus.h" "${SQL_MAP_SOURCE_DIR}/HPMmap.h" - "${SQL_MAP_SOURCE_DIR}/instance.h" + "${SQL_MAP_SOURCE_DIR}/instance.h" "${SQL_MAP_SOURCE_DIR}/intif.h" "${SQL_MAP_SOURCE_DIR}/irc-bot.h" "${SQL_MAP_SOURCE_DIR}/itemdb.h" diff --git a/src/map/status.c b/src/map/status.c index eb06138da..316dce8e6 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -180,7 +180,7 @@ void initChangeTables(void) { add_sc( TF_POISON , SC_POISON ); set_sc( KN_TWOHANDQUICKEN , SC_TWOHANDQUICKEN , SI_TWOHANDQUICKEN , SCB_ASPD ); add_sc( KN_AUTOCOUNTER , SC_AUTOCOUNTER ); - set_sc( PR_IMPOSITIO , SC_IMPOSITIO , SI_IMPOSITIO , + set_sc( PR_IMPOSITIO , SC_IMPOSITIO , SI_IMPOSITIO , #ifdef RENEWAL SCB_NONE ); #else @@ -204,7 +204,7 @@ void initChangeTables(void) { set_sc( BS_WEAPONPERFECT , SC_WEAPONPERFECT , SI_WEAPONPERFECT, SCB_NONE ); set_sc( BS_OVERTHRUST , SC_OVERTHRUST , SI_OVERTHRUST , SCB_NONE ); set_sc( BS_MAXIMIZE , SC_MAXIMIZEPOWER , SI_MAXIMIZE , SCB_REGEN ); - add_sc( HT_LANDMINE , SC_STUN ); + add_sc( HT_LANDMINE , SC_STUN ); set_sc( HT_ANKLESNARE , SC_ANKLESNARE , SI_ANKLESNARE , SCB_NONE ); add_sc( HT_SANDMAN , SC_SLEEP ); add_sc( HT_FLASHER , SC_BLIND ); @@ -3672,7 +3672,7 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag) { st->batk = status->calc_batk(bl, sc, st->batk, true); } - if(flag&SCB_WATK) { + if(flag&SCB_WATK) { st->rhw.atk = status->calc_watk(bl, sc, bst->rhw.atk, true); if (!sd) //Should not affect weapon refine bonus st->rhw.atk2 = status->calc_watk(bl, sc, bst->rhw.atk2, true); @@ -5016,7 +5016,7 @@ signed short status_calc_def2(struct block_list *bl, struct status_change *sc, i #ifdef RENEWAL if( sc && sc->data[SC_ASSUMPTIO] ) def2 <<= 1; -#endif +#endif if( sc && sc->data[SC_CAMOUFLAGE] ) def2 -= def2 * 5 * (10-sc->data[SC_CAMOUFLAGE]->val4) / 100; #ifdef RENEWAL @@ -5912,7 +5912,7 @@ struct status_data *status_get_base_status(struct block_list *bl) case BL_HOM: return &((TBL_HOM*)bl)->base_status; case BL_MER: return &((TBL_MER*)bl)->base_status; case BL_ELEM: return &((TBL_ELEM*)bl)->base_status; - case BL_NPC: return ((mob->db_checkid(((TBL_NPC*)bl)->class_) == 0) ? &((TBL_NPC*)bl)->status : NULL); + case BL_NPC: return ((mob->db_checkid(((TBL_NPC*)bl)->class_) == 0) ? &((TBL_NPC*)bl)->status : NULL); default: return NULL; } @@ -5929,8 +5929,8 @@ defType status_get_def(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; + if(bl->type==BL_NPC)//Only BL with speed data but no status_data [Skotlex] + return ((struct npc_data *)bl)->speed; return status->get_status_data(bl)->speed; } @@ -6939,9 +6939,9 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t case SC_ASSNCROS: if(sc->option&OPTION_MADOGEAR) return 0;//Mado is immune to wind walk, cart boost, etc (others above) [Ind] - case SC_INC_AGI: + case SC_INC_AGI: if (sc->data[SC_QUAGMIRE]) - return 0; + return 0; break; case SC_CLOAKING: //Avoid cloaking with no wall and low skill level. [Skotlex] @@ -7143,7 +7143,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t case SC_ROKISWEIL: case SC_FOGWALL: case SC_FROSTMISTY: - case SC_BURNING: + case SC_BURNING: case SC_MARSHOFABYSS: case SC_ADORAMUS: case SC_NEEDLE_OF_PARALYZE: @@ -9401,7 +9401,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t } //On Aegis, when turning on a status change, first goes the option packet, then the sc packet. - if(opt_flag) { + if(opt_flag) { clif->changeoption(bl); if( sd && opt_flag&0x4 ) { clif->changelook(bl,LOOK_BASE,vd->class_); @@ -11958,7 +11958,7 @@ void do_final_status(void) { } /*===================================== -* Default Functions : status.h +* Default Functions : status.h * Generated by HerculesInterfaceMaker * created by Susu *-------------------------------------*/ diff --git a/src/map/status.h b/src/map/status.h index 6bb563b0b..3bdd59041 100644 --- a/src/map/status.h +++ b/src/map/status.h @@ -711,766 +711,787 @@ typedef enum sc_type { SC_MAX, //Automatically updated max, used in for's to check we are within bounds. } sc_type; -// Official status change ids, used to display status icons on the client. + +/// Official status change ids, used to display status icons in the client. enum si_type { - SI_BLANK = -1, - SI_PROVOKE = 0, - SI_ENDURE = 1, - SI_TWOHANDQUICKEN = 2, - SI_CONCENTRATION = 3, - SI_HIDING = 4, - SI_CLOAKING = 5, - SI_ENCHANTPOISON = 6, - SI_POISONREACT = 7, - SI_QUAGMIRE = 8, - SI_ANGELUS = 9, - SI_BLESSING = 10, - SI_CRUCIS = 11, - SI_INC_AGI = 12, - SI_DEC_AGI = 13, - SI_SLOWPOISON = 14, - SI_IMPOSITIO = 15, - SI_SUFFRAGIUM = 16, - SI_ASPERSIO = 17, - SI_BENEDICTIO = 18, - SI_KYRIE = 19, - SI_MAGNIFICAT = 20, - SI_GLORIA = 21, - SI_LEXAETERNA = 22, - SI_ADRENALINE = 23, - SI_WEAPONPERFECT = 24, - SI_OVERTHRUST = 25, - SI_MAXIMIZE = 26, - SI_RIDING = 27, - SI_FALCON = 28, - SI_TRICKDEAD = 29, - SI_SHOUT = 30, - SI_ENERGYCOAT = 31, - SI_BROKENARMOR = 32, - SI_BROKENWEAPON = 33, - SI_ILLUSION = 34, - SI_WEIGHTOVER50 = 35, - SI_WEIGHTOVER90 = 36, - SI_ATTHASTE_POTION1 = 37, - SI_ATTHASTE_POTION2 = 38, - SI_ATTHASTE_POTION3 = 39, - SI_ATTHASTE_INFINITY = 40, - SI_MOVHASTE_POTION = 41, - SI_MOVHASTE_INFINITY = 42, -// SI_AUTOCOUNTER = 43, -// SI_SPLASHER = 44, - SI_ANKLESNARE = 45, - SI_POSTDELAY = 46, -// SI_NOACTION = 47, -// SI_IMPOSSIBLEPICKUP = 48, -// SI_BARRIER = 49, - SI_NOEQUIPWEAPON = 50, - SI_NOEQUIPSHIELD = 51, - SI_NOEQUIPARMOR = 52, - SI_NOEQUIPHELM = 53, - SI_PROTECTWEAPON = 54, - SI_PROTECTSHIELD = 55, - SI_PROTECTARMOR = 56, - SI_PROTECTHELM = 57, - SI_AUTOGUARD = 58, - SI_REFLECTSHIELD = 59, -// SI_DEVOTION = 60, - SI_PROVIDENCE = 61, - SI_DEFENDER = 62, -// SI_MAGICROD = 63, -// SI_WEAPONPROPERTY = 64, - SI_AUTOSPELL = 65, -// SI_SPECIALZONE = 66, -// SI_MASK = 67, - SI_SPEARQUICKEN = 68, -// SI_BDPLAYING = 69, -// SI_WHISTLE = 70, -// SI_ASSASSINCROSS = 71, -// SI_POEMBRAGI = 72, -// SI_APPLEIDUN = 73, -// SI_HUMMING = 74, -// SI_DONTFORGETME = 75, -// SI_FORTUNEKISS = 76, -// SI_SERVICEFORYOU = 77, -// SI_RICHMANKIM = 78, -// SI_ETERNALCHAOS = 79, -// SI_DRUMBATTLEFIELD = 80, -// SI_RINGNIBELUNGEN = 81, -// SI_ROKISWEIL = 82, -// SI_INTOABYSS = 83, -// SI_SIEGFRIED = 84, -// SI_BLADESTOP = 85, - SI_EXPLOSIONSPIRITS = 86, - SI_STEELBODY = 87, - SI_EXTREMITYFIST = 88, -// SI_COMBOATTACK = 89, - SI_PROPERTYFIRE = 90, - SI_PROPERTYWATER = 91, - SI_PROPERTYWIND = 92, - SI_PROPERTYGROUND = 93, -// SI_MAGICATTACK = 94, - SI_STOP = 95, -// SI_WEAPONBRAKER = 96, - SI_PROPERTYUNDEAD = 97, -// SI_POWERUP = 98, -// SI_AGIUP = 99, -// SI_SIEGEMODE = 100, -// SI_INVISIBLE = 101, -// SI_STATUSONE = 102, - SI_AURABLADE = 103, - SI_PARRYING = 104, - SI_LKCONCENTRATION = 105, - SI_TENSIONRELAX = 106, - SI_BERSERK = 107, -// SI_SACRIFICE = 108, -// SI_GOSPEL = 109, - SI_ASSUMPTIO = 110, -// SI_BASILICA = 111, - SI_GROUNDMAGIC = 112, - SI_MAGICPOWER = 113, - SI_EDP = 114, - SI_TRUESIGHT = 115, - SI_WINDWALK = 116, - SI_MELTDOWN = 117, - SI_CARTBOOST = 118, -// SI_CHASEWALK = 119, - SI_SWORDREJECT = 120, - SI_MARIONETTE_MASTER = 121, - SI_MARIONETTE = 122, - SI_MOON = 123, - SI_BLOODING = 124, - SI_JOINTBEAT = 125, -// SI_MINDBREAKER = 126, -// SI_MEMORIZE = 127, -// SI_FOGWALL = 128, -// SI_SPIDERWEB = 129, - SI_PROTECTEXP = 130, -// SI_SUB_WEAPONPROPERTY = 131, - SI_AUTOBERSERK = 132, - SI_RUN = 133, - SI_TING = 134, - SI_STORMKICK_ON = 135, - SI_STORMKICK_READY = 136, - SI_DOWNKICK_ON = 137, - SI_DOWNKICK_READY = 138, - SI_TURNKICK_ON = 139, - SI_TURNKICK_READY = 140, - SI_COUNTER_ON = 141, - SI_COUNTER_READY = 142, - SI_DODGE_ON = 143, - SI_DODGE_READY = 144, - SI_STRUP = 145, - SI_PROPERTYDARK = 146, - SI_ADRENALINE2 = 147, - SI_PROPERTYTELEKINESIS = 148, - SI_SOULLINK = 149, - SI_PLUSATTACKPOWER = 150, - SI_PLUSMAGICPOWER = 151, - SI_DEVIL1 = 152, - SI_KAITE = 153, -// SI_SWOO = 154, -// SI_STAR2 = 155, - SI_KAIZEL = 156, - SI_KAAHI = 157, - SI_KAUPE = 158, - SI_SMA_READY = 159, - SI_SKE = 160, - SI_ONEHANDQUICKEN = 161, -// SI_FRIEND = 162, -// SI_FRIENDUP = 163, -// SI_SG_WARM = 164, - SI_SG_SUN_WARM = 165, -// 166 | The three show the exact same display: ultra red character (165, 166, 167) -// 167 | Their names would be SI_SG_SUN_WARM, SI_SG_MOON_WARM, SI_SG_STAR_WARM -// SI_EMOTION = 168, - SI_SUN_COMFORT = 169, - SI_MOON_COMFORT = 170, - SI_STAR_COMFORT = 171, -// SI_EXPUP = 172, -// SI_GDSKILL_BATTLEORDER = 173, -// SI_GDSKILL_REGENERATION = 174, -// SI_GDSKILL_POSTDELAY = 175, -// SI_RESISTHANDICAP = 176, -// SI_MAXHPPERCENT = 177, -// SI_MAXSPPERCENT = 178, -// SI_DEFENCE = 179, -// SI_SLOWDOWN = 180, - SI_PRESERVE = 181, - SI_INCSTR = 182, -// SI_NOT_EXTREMITYFIST = 183, - SI_CLAIRVOYANCE = 184, -// SI_MOVESLOW_POTION = 185, - SI_DOUBLECASTING = 186, -// SI_GRAVITATION = 187, - SI_OVERTHRUSTMAX = 188, -// SI_LONGING = 189, -// SI_HERMODE = 190, - SI_TAROTCARD = 191, // the icon allows no doubt... but what is it really used for ?? [DracoRPG] -// SI_HLIF_AVOID = 192, -// SI_HFLI_FLEET = 193, -// SI_HFLI_SPEED = 194, -// SI_HLIF_CHANGE = 195, -// SI_HAMI_BLOODLUST = 196, - SI_CR_SHRINK = 197, - SI_WZ_SIGHTBLASTER = 198, - SI_DC_WINKCHARM = 199, - SI_RG_CCONFINE_M = 200, - SI_RG_CCONFINE_S = 201, -// SI_DISABLEMOVE = 202, - SI_GS_MADNESSCANCEL = 203, //[blackhole89] - SI_GS_GATLINGFEVER = 204, - SI_EARTHSCROLL = 205, - SI_NJ_UTSUSEMI = 206, - SI_NJ_BUNSINJYUTSU = 207, - SI_NJ_NEN = 208, - SI_GS_ADJUSTMENT = 209, - SI_GS_ACCURACY = 210, - SI_NJ_SUITON = 211, -// SI_PET = 212, -// SI_MENTAL = 213, -// SI_EXPMEMORY = 214, -// SI_PERFORMANCE = 215, -// SI_GAIN = 216, -// SI_GRIFFON = 217, -// SI_DRIFT = 218, -// SI_WALLSHIFT = 219, -// SI_REINCARNATION = 220, -// SI_PATTACK = 221, -// SI_PSPEED = 222, -// SI_PDEFENSE = 223, -// SI_PCRITICAL = 224, -// SI_RANKING = 225, -// SI_PTRIPLE = 226, -// SI_DENERGY = 227, -// SI_WAVE1 = 228, -// SI_WAVE2 = 229, -// SI_WAVE3 = 230, -// SI_WAVE4 = 231, -// SI_DAURA = 232, -// SI_DFREEZER = 233, -// SI_DPUNISH = 234, -// SI_DBARRIER = 235, -// SI_DWARNING = 236, -// SI_MOUSEWHEEL = 237, -// SI_DGAUGE = 238, -// SI_DACCEL = 239, -// SI_DBLOCK = 240, - SI_FOOD_STR = 241, - SI_FOOD_AGI = 242, - SI_FOOD_VIT = 243, - SI_FOOD_DEX = 244, - SI_FOOD_INT = 245, - SI_FOOD_LUK = 246, - SI_FOOD_BASICAVOIDANCE = 247, - SI_FOOD_BASICHIT = 248, - SI_FOOD_CRITICALSUCCESSVALUE = 249, - SI_CASH_PLUSEXP = 250, - SI_CASH_DEATHPENALTY = 251, - SI_CASH_RECEIVEITEM = 252, - SI_CASH_BOSS_ALARM = 253, -// SI_DA_ENERGY = 254, -// SI_DA_FIRSTSLOT = 255, -// SI_DA_HEADDEF = 256, -// SI_DA_SPACE = 257, -// SI_DA_TRANSFORM = 258, -// SI_DA_ITEMREBUILD = 259, -// SI_DA_ILLUSION = 260, //All mobs display as Turtle General -// SI_DA_DARKPOWER = 261, -// SI_DA_EARPLUG = 262, -// SI_DA_CONTRACT = 263, //Bio Mob effect on you and SI_TRICKDEAD icon -// SI_DA_BLACK = 264, //For short time blurry screen -// SI_DA_MAGICCART = 265, -// SI_CRYSTAL = 266, -// SI_DA_REBUILD = 267, -// SI_DA_EDARKNESS = 268, -// SI_DA_EGUARDIAN = 269, -// SI_DA_TIMEOUT = 270, - SI_FOOD_STR_CASH = 271, - SI_FOOD_AGI_CASH = 272, - SI_FOOD_VIT_CASH = 273, - SI_FOOD_DEX_CASH = 274, - SI_FOOD_INT_CASH = 275, - SI_FOOD_LUK_CASH = 276, - SI_MER_FLEE = 277, - SI_MER_ATK = 278, - SI_MER_HP = 279, - SI_MER_SP = 280, - SI_MER_HIT = 281, - SI_SLOWCAST = 282, -// SI_MAGICMIRROR = 283, -// SI_STONESKIN = 284, -// SI_ANTIMAGIC = 285, - SI_CRITICALWOUND = 286, -// SI_NPC_DEFENDER = 287, -// SI_NOACTION_WAIT = 288, - SI_MOVHASTE_HORSE = 289, - SI_PROTECT_DEF = 290, - SI_PROTECT_MDEF = 291, - SI_HEALPLUS = 292, - SI_S_LIFEPOTION = 293, - SI_L_LIFEPOTION = 294, - SI_CRITICALPERCENT = 295, - SI_PLUSAVOIDVALUE = 296, -// SI_ATKER_ASPD = 297, -// SI_TARGET_ASPD = 298, -// SI_ATKER_MOVESPEED = 299, - SI_ATKER_BLOOD = 300, - SI_TARGET_BLOOD = 301, - SI_ARMOR_PROPERTY = 302, -// SI_REUSE_LIMIT_A = 303, - SI_HELLPOWER = 304, -// SI_STEAMPACK = 305, -// SI_REUSE_LIMIT_B = 306, -// SI_REUSE_LIMIT_C = 307, -// SI_REUSE_LIMIT_D = 308, -// SI_REUSE_LIMIT_E = 309, -// SI_REUSE_LIMIT_F = 310, - SI_INVINCIBLE = 311, - SI_CASH_PLUSONLYJOBEXP = 312, - SI_PARTYFLEE = 313, - SI_ANGEL_PROTECT = 314, -// SI_ENDURE_MDEF = 315, - SI_ENCHANTBLADE = 316, - SI_DEATHBOUND = 317, - SI_REFRESH = 318, - SI_GIANTGROWTH = 319, - SI_STONEHARDSKIN = 320, - SI_VITALITYACTIVATION = 321, - SI_FIGHTINGSPIRIT = 322, - SI_ABUNDANCE = 323, - SI_REUSE_MILLENNIUMSHIELD = 324, - SI_REUSE_CRUSHSTRIKE = 325, - SI_REUSE_REFRESH = 326, - SI_REUSE_STORMBLAST = 327, - SI_VENOMIMPRESS = 328, - SI_EPICLESIS = 329, - SI_ORATIO = 330, - SI_LAUDAAGNUS = 331, - SI_LAUDARAMUS = 332, - SI_CLOAKINGEXCEED = 333, - SI_HALLUCINATIONWALK = 334, - SI_HALLUCINATIONWALK_POSTDELAY = 335, - SI_RENOVATIO = 336, - SI_WEAPONBLOCKING = 337, - SI_WEAPONBLOCKING_POSTDELAY = 338, - SI_ROLLINGCUTTER = 339, - SI_EXPIATIO = 340, - SI_POISONINGWEAPON = 341, - SI_TOXIN = 342, - SI_PARALYSE = 343, - SI_VENOMBLEED = 344, - SI_MAGICMUSHROOM = 345, - SI_DEATHHURT = 346, - SI_PYREXIA = 347, - SI_OBLIVIONCURSE = 348, - SI_LEECHESEND = 349, - SI_DUPLELIGHT = 350, - SI_FROSTMISTY = 351, - SI_FEARBREEZE = 352, - SI_ELECTRICSHOCKER = 353, - SI_MARSHOFABYSS = 354, - SI_RECOGNIZEDSPELL = 355, - SI_STASIS = 356, - SI_WUGRIDER = 357, - SI_WUGDASH = 358, - SI_WUGBITE = 359, - SI_CAMOUFLAGE = 360, - SI_ACCELERATION = 361, - SI_HOVERING = 362, - SI_SPHERE_1 = 363, - SI_SPHERE_2 = 364, - SI_SPHERE_3 = 365, - SI_SPHERE_4 = 366, - SI_SPHERE_5 = 367, - SI_MVPCARD_TAOGUNKA = 368, - SI_MVPCARD_MISTRESS = 369, - SI_MVPCARD_ORCHERO = 370, - SI_MVPCARD_ORCLORD = 371, - SI_OVERHEAT_LIMITPOINT = 372, - SI_OVERHEAT = 373, - SI_SHAPESHIFT = 374, - SI_INFRAREDSCAN = 375, - SI_MAGNETICFIELD = 376, - SI_NEUTRALBARRIER = 377, - SI_NEUTRALBARRIER_MASTER = 378, - SI_STEALTHFIELD = 379, - SI_STEALTHFIELD_MASTER = 380, - SI_MANU_ATK = 381, - SI_MANU_DEF = 382, - SI_SPL_ATK = 383, - SI_SPL_DEF = 384, - SI_REPRODUCE = 385, - SI_MANU_MATK = 386, - SI_SPL_MATK = 387, - SI_STR_SCROLL = 388, - SI_INT_SCROLL = 389, - SI_LG_REFLECTDAMAGE = 390, - SI_FORCEOFVANGUARD = 391, - SI_BUCHEDENOEL = 392, - SI_AUTOSHADOWSPELL = 393, - SI_SHADOWFORM = 394, - SI_RAID = 395, - SI_SHIELDSPELL_DEF = 396, - SI_SHIELDSPELL_MDEF = 397, - SI_SHIELDSPELL_REF = 398, - SI_BODYPAINT = 399, - SI_EXEEDBREAK = 400, - SI_ADORAMUS = 401, - SI_PRESTIGE = 402, - SI_INVISIBILITY = 403, - SI_DEADLYINFECT = 404, - SI_BANDING = 405, - SI_EARTHDRIVE = 406, - SI_INSPIRATION = 407, - SI_ENERVATION = 408, - SI_GROOMY = 409, - SI_RAISINGDRAGON = 410, - SI_IGNORANCE = 411, - SI_LAZINESS = 412, - SI_LIGHTNINGWALK = 413, - SI_ACARAJE = 414, - SI_UNLUCKY = 415, - SI_CURSEDCIRCLE_ATKER = 416, - SI_CURSEDCIRCLE_TARGET = 417, - SI_WEAKNESS = 418, - SI_CRESCENTELBOW = 419, - SI_NOEQUIPACCESSARY = 420, - SI_STRIPACCESSARY = 421, - SI_MANHOLE = 422, - SI_POPECOOKIE = 423, - SI_FALLENEMPIRE = 424, - SI_GENTLETOUCH_ENERGYGAIN = 425, - SI_GENTLETOUCH_CHANGE = 426, - SI_GENTLETOUCH_REVITALIZE = 427, - SI_BLOODYLUST = 428, - SI_SWINGDANCE = 429, - SI_SYMPHONYOFLOVERS = 430, - SI_PROPERTYWALK = 431, - SI_SPELLFIST = 432, - SI_NETHERWORLD = 433, - SI_SIREN = 434, - SI_DEEPSLEEP = 435, - SI_SIRCLEOFNATURE = 436, - SI_COLD = 437, - SI_GLOOMYDAY = 438, - SI_SONG_OF_MANA = 439, - SI_CLOUDKILL = 440, - SI_DANCEWITHWUG = 441, - SI_RUSHWINDMILL = 442, - SI_ECHOSONG = 443, - SI_HARMONIZE = 444, - SI_STRIKING = 445, - SI_WARMER = 446, - SI_MOONLITSERENADE = 447, - SI_SATURDAYNIGHTFEVER = 448, - SI_SITDOWN_FORCE = 449, - SI_ANALYZE = 450, - SI_LERADSDEW = 451, - SI_MELODYOFSINK = 452, - SI_WARCRYOFBEYOND = 453, - SI_UNLIMITEDHUMMINGVOICE = 454, - SI_SPELLBOOK1 = 455, - SI_SPELLBOOK2 = 456, - SI_SPELLBOOK3 = 457, - SI_FREEZE_SP = 458, - SI_GN_TRAINING_SWORD = 459, - SI_GN_REMODELING_CART = 460, - SI_CARTSBOOST = 461, - SI_FIXEDCASTINGTM_REDUCE = 462, - SI_THORNTRAP = 463, - SI_BLOODSUCKER = 464, - SI_SPORE_EXPLOSION = 465, - SI_DEMONIC_FIRE = 466, - SI_FIRE_EXPANSION_SMOKE_POWDER = 467, - SI_FIRE_EXPANSION_TEAR_GAS = 468, - SI_BLOCKING_PLAY = 469, - SI_MANDRAGORA = 470, - SI_ACTIVATE = 471, - SI_SECRAMENT = 472, - SI_ASSUMPTIO2 = 473, - SI_TK_SEVENWIND = 474, - SI_LIMIT_ODINS_RECALL = 475, - SI_STOMACHACHE = 476, - SI_MYSTERIOUS_POWDER = 477, - SI_MELON_BOMB = 478, - SI_BANANA_BOMB_SITDOWN_POSTDELAY = 479, - SI_PROMOTE_HEALTH_RESERCH = 480, - SI_ENERGY_DRINK_RESERCH = 481, - SI_EXTRACT_WHITE_POTION_Z = 482, - SI_VITATA_500 = 483, - SI_EXTRACT_SALAMINE_JUICE = 484, - SI_BOOST500 = 485, - SI_FULL_SWING_K = 486, - SI_MANA_PLUS = 487, - SI_MUSTLE_M = 488, - SI_LIFE_FORCE_F = 489, - SI_VACUUM_EXTREME = 490, - SI_SAVAGE_STEAK = 491, - SI_COCKTAIL_WARG_BLOOD = 492, - SI_MINOR_BBQ = 493, - SI_SIROMA_ICE_TEA = 494, - SI_DROCERA_HERB_STEAMED = 495, - SI_PUTTI_TAILS_NOODLES = 496, - SI_BANANA_BOMB = 497, - SI_SUMMON_AGNI = 498, - SI_SPELLBOOK4 = 499, - SI_SPELLBOOK5 = 500, - SI_SPELLBOOK6 = 501, - SI_SPELLBOOK7 = 502, - SI_ELEMENTAL_AGGRESSIVE = 503, - SI_RETURN_TO_ELDICASTES = 504, - SI_BANDING_DEFENCE = 505, - SI_SKELSCROLL = 506, - SI_DISTRUCTIONSCROLL = 507, - SI_ROYALSCROLL = 508, - SI_IMMUNITYSCROLL = 509, - SI_MYSTICSCROLL = 510, - SI_BATTLESCROLL = 511, - SI_ARMORSCROLL = 512, - SI_FREYJASCROLL = 513, - SI_SOULSCROLL = 514, - SI_CIRCLE_OF_FIRE = 515, - SI_CIRCLE_OF_FIRE_OPTION = 516, - SI_FIRE_CLOAK = 517, - SI_FIRE_CLOAK_OPTION = 518, - SI_WATER_SCREEN = 519, - SI_WATER_SCREEN_OPTION = 520, - SI_WATER_DROP = 521, - SI_WATER_DROP_OPTION = 522, - SI_WIND_STEP = 523, - SI_WIND_STEP_OPTION = 524, - SI_WIND_CURTAIN = 525, - SI_WIND_CURTAIN_OPTION = 526, - SI_WATER_BARRIER = 527, - SI_ZEPHYR = 528, - SI_SOLID_SKIN = 529, - SI_SOLID_SKIN_OPTION = 530, - SI_STONE_SHIELD = 531, - SI_STONE_SHIELD_OPTION = 532, - SI_POWER_OF_GAIA = 533, - // SI_EL_WAIT = 534, - // SI_EL_PASSIVE = 535, - // SI_EL_DEFENSIVE = 536, - // SI_EL_OFFENSIVE = 537, - // SI_EL_COST = 538, - SI_PYROTECHNIC = 539, - SI_PYROTECHNIC_OPTION = 540, - SI_HEATER = 541, - SI_HEATER_OPTION = 542, - SI_TROPIC = 543, - SI_TROPIC_OPTION = 544, - SI_AQUAPLAY = 545, - SI_AQUAPLAY_OPTION = 546, - SI_COOLER = 547, - SI_COOLER_OPTION = 548, - SI_CHILLY_AIR = 549, - SI_CHILLY_AIR_OPTION = 550, - SI_GUST = 551, - SI_GUST_OPTION = 552, - SI_BLAST = 553, - SI_BLAST_OPTION = 554, - SI_WILD_STORM = 555, - SI_WILD_STORM_OPTION = 556, - SI_PETROLOGY = 557, - SI_PETROLOGY_OPTION = 558, - SI_CURSED_SOIL = 559, - SI_CURSED_SOIL_OPTION = 560, - SI_UPHEAVAL = 561, - SI_UPHEAVAL_OPTION = 562, - SI_TIDAL_WEAPON = 563, - SI_TIDAL_WEAPON_OPTION = 564, - SI_ROCK_CRUSHER = 565, - SI_ROCK_CRUSHER_ATK = 566, - SI_FIRE_INSIGNIA = 567, - SI_WATER_INSIGNIA = 568, - SI_WIND_INSIGNIA = 569, - SI_EARTH_INSIGNIA = 570, - SI_EQUIPED_FLOOR = 571, - SI_GUARDIAN_RECALL = 572, - SI_MORA_BUFF = 573, - SI_REUSE_LIMIT_G = 574, - SI_REUSE_LIMIT_H = 575, - SI_NEEDLE_OF_PARALYZE = 576, - SI_PAIN_KILLER = 577, - SI_G_LIFEPOTION = 578, - SI_VITALIZE_POTION = 579, - SI_LIGHT_OF_REGENE = 580, - SI_OVERED_BOOST = 581, - SI_SILENT_BREEZE = 582, - SI_ODINS_POWER = 583, - SI_STYLE_CHANGE = 584, - SI_SONIC_CLAW_POSTDELAY = 585, + SI_BLANK = -1, + + SI_PROVOKE = 0, + SI_ENDURE = 1, + SI_TWOHANDQUICKEN = 2, + SI_CONCENTRATION = 3, + SI_HIDING = 4, + SI_CLOAKING = 5, + SI_ENCHANTPOISON = 6, + SI_POISONREACT = 7, + SI_QUAGMIRE = 8, + SI_ANGELUS = 9, + SI_BLESSING = 10, + SI_CRUCIS = 11, + SI_INC_AGI = 12, + SI_DEC_AGI = 13, + SI_SLOWPOISON = 14, + SI_IMPOSITIO = 15, + SI_SUFFRAGIUM = 16, + SI_ASPERSIO = 17, + SI_BENEDICTIO = 18, + SI_KYRIE = 19, + SI_MAGNIFICAT = 20, + SI_GLORIA = 21, + SI_LEXAETERNA = 22, + SI_ADRENALINE = 23, + SI_WEAPONPERFECT = 24, + SI_OVERTHRUST = 25, + SI_MAXIMIZE = 26, + SI_RIDING = 27, + SI_FALCON = 28, + SI_TRICKDEAD = 29, + SI_SHOUT = 30, + SI_ENERGYCOAT = 31, + SI_BROKENARMOR = 32, + SI_BROKENWEAPON = 33, + SI_ILLUSION = 34, + SI_WEIGHTOVER50 = 35, + SI_WEIGHTOVER90 = 36, + SI_ATTHASTE_POTION1 = 37, + SI_ATTHASTE_POTION2 = 38, + SI_ATTHASTE_POTION3 = 39, + SI_ATTHASTE_INFINITY = 40, + SI_MOVHASTE_POTION = 41, + SI_MOVHASTE_INFINITY = 42, + //SI_AUTOCOUNTER = 43, + //SI_SPLASHER = 44, + SI_ANKLESNARE = 45, + SI_POSTDELAY = 46, + //SI_NOACTION = 47, + //SI_IMPOSSIBLEPICKUP = 48, + //SI_BARRIER = 49, + + SI_NOEQUIPWEAPON = 50, + SI_NOEQUIPSHIELD = 51, + SI_NOEQUIPARMOR = 52, + SI_NOEQUIPHELM = 53, + SI_PROTECTWEAPON = 54, + SI_PROTECTSHIELD = 55, + SI_PROTECTARMOR = 56, + SI_PROTECTHELM = 57, + SI_AUTOGUARD = 58, + SI_REFLECTSHIELD = 59, + //SI_DEVOTION = 60, + SI_PROVIDENCE = 61, + SI_DEFENDER = 62, + //SI_MAGICROD = 63, + //SI_WEAPONPROPERTY = 64, + SI_AUTOSPELL = 65, + //SI_SPECIALZONE = 66, + //SI_MASK = 67, + SI_SPEARQUICKEN = 68, + //SI_BDPLAYING = 69, + //SI_WHISTLE = 70, + //SI_ASSASSINCROSS = 71, + //SI_POEMBRAGI = 72, + //SI_APPLEIDUN = 73, + //SI_HUMMING = 74, + //SI_DONTFORGETME = 75, + //SI_FORTUNEKISS = 76, + //SI_SERVICEFORYOU = 77, + //SI_RICHMANKIM = 78, + //SI_ETERNALCHAOS = 79, + //SI_DRUMBATTLEFIELD = 80, + //SI_RINGNIBELUNGEN = 81, + //SI_ROKISWEIL = 82, + //SI_INTOABYSS = 83, + //SI_SIEGFRIED = 84, + //SI_BLADESTOP = 85, + SI_EXPLOSIONSPIRITS = 86, + SI_STEELBODY = 87, + SI_EXTREMITYFIST = 88, + //SI_COMBOATTACK = 89, + SI_PROPERTYFIRE = 90, + SI_PROPERTYWATER = 91, + SI_PROPERTYWIND = 92, + SI_PROPERTYGROUND = 93, + //SI_MAGICATTACK = 94, + SI_STOP = 95, + //SI_WEAPONBRAKER = 96, + SI_PROPERTYUNDEAD = 97, + //SI_POWERUP = 98, + //SI_AGIUP = 99, + + //SI_SIEGEMODE = 100, + //SI_INVISIBLE = 101, + //SI_STATUSONE = 102, + SI_AURABLADE = 103, + SI_PARRYING = 104, + SI_LKCONCENTRATION = 105, + SI_TENSIONRELAX = 106, + SI_BERSERK = 107, + //SI_SACRIFICE = 108, + //SI_GOSPEL = 109, + SI_ASSUMPTIO = 110, + //SI_BASILICA = 111, + SI_GROUNDMAGIC = 112, + SI_MAGICPOWER = 113, + SI_EDP = 114, + SI_TRUESIGHT = 115, + SI_WINDWALK = 116, + SI_MELTDOWN = 117, + SI_CARTBOOST = 118, + //SI_CHASEWALK = 119, + SI_SWORDREJECT = 120, + SI_MARIONETTE_MASTER = 121, + SI_MARIONETTE = 122, + SI_MOON = 123, + SI_BLOODING = 124, + SI_JOINTBEAT = 125, + //SI_MINDBREAKER = 126, + //SI_MEMORIZE = 127, + //SI_FOGWALL = 128, + //SI_SPIDERWEB = 129, + SI_PROTECTEXP = 130, + //SI_SUB_WEAPONPROPERTY = 131, + SI_AUTOBERSERK = 132, + SI_RUN = 133, + SI_TING = 134, + SI_STORMKICK_ON = 135, + SI_STORMKICK_READY = 136, + SI_DOWNKICK_ON = 137, + SI_DOWNKICK_READY = 138, + SI_TURNKICK_ON = 139, + SI_TURNKICK_READY = 140, + SI_COUNTER_ON = 141, + SI_COUNTER_READY = 142, + SI_DODGE_ON = 143, + SI_DODGE_READY = 144, + SI_STRUP = 145, + SI_PROPERTYDARK = 146, + SI_ADRENALINE2 = 147, + SI_PROPERTYTELEKINESIS = 148, + SI_SOULLINK = 149, + + SI_PLUSATTACKPOWER = 150, + SI_PLUSMAGICPOWER = 151, + SI_DEVIL1 = 152, + SI_KAITE = 153, + //SI_SWOO = 154, + //SI_STAR2 = 155, + SI_KAIZEL = 156, + SI_KAAHI = 157, + SI_KAUPE = 158, + SI_SMA_READY = 159, + SI_SKE = 160, + SI_ONEHANDQUICKEN = 161, + //SI_FRIEND = 162, + //SI_FRIENDUP = 163, + //SI_SG_WARM = 164, + SI_SG_SUN_WARM = 165, + //SI_SG_MOON_WARM = 166 | The three show the exact same display: ultra red character (165, 166, 167) + //SI_SG_STAR_WARM = 167 | Their names would be SI_SG_SUN_WARM, SI_SG_MOON_WARM, SI_SG_STAR_WARM + //SI_EMOTION = 168, + SI_SUN_COMFORT = 169, + SI_MOON_COMFORT = 170, + SI_STAR_COMFORT = 171, + //SI_EXPUP = 172, + //SI_GDSKILL_BATTLEORDER = 173, + //SI_GDSKILL_REGENERATION = 174, + //SI_GDSKILL_POSTDELAY = 175, + //SI_RESISTHANDICAP = 176, + //SI_MAXHPPERCENT = 177, + //SI_MAXSPPERCENT = 178, + //SI_DEFENCE = 179, + //SI_SLOWDOWN = 180, + SI_PRESERVE = 181, + SI_INCSTR = 182, + //SI_NOT_EXTREMITYFIST = 183, + SI_CLAIRVOYANCE = 184, + //SI_MOVESLOW_POTION = 185, + SI_DOUBLECASTING = 186, + //SI_GRAVITATION = 187, + SI_OVERTHRUSTMAX = 188, + //SI_LONGING = 189, + //SI_HERMODE = 190, + SI_TAROTCARD = 191, // the icon allows no doubt... but what is it really used for ?? [DracoRPG] + //SI_HLIF_AVOID = 192, + //SI_HFLI_FLEET = 193, + //SI_HFLI_SPEED = 194, + //SI_HLIF_CHANGE = 195, + //SI_HAMI_BLOODLUST = 196, + SI_CR_SHRINK = 197, + SI_WZ_SIGHTBLASTER = 198, + SI_DC_WINKCHARM = 199, + + SI_RG_CCONFINE_M = 200, + SI_RG_CCONFINE_S = 201, + //SI_DISABLEMOVE = 202, + SI_GS_MADNESSCANCEL = 203, //[blackhole89] + SI_GS_GATLINGFEVER = 204, + SI_EARTHSCROLL = 205, + SI_NJ_UTSUSEMI = 206, + SI_NJ_BUNSINJYUTSU = 207, + SI_NJ_NEN = 208, + SI_GS_ADJUSTMENT = 209, + SI_GS_ACCURACY = 210, + SI_NJ_SUITON = 211, + //SI_PET = 212, + //SI_MENTAL = 213, + //SI_EXPMEMORY = 214, + //SI_PERFORMANCE = 215, + //SI_GAIN = 216, + //SI_GRIFFON = 217, + //SI_DRIFT = 218, + //SI_WALLSHIFT = 219, + //SI_REINCARNATION = 220, + //SI_PATTACK = 221, + //SI_PSPEED = 222, + //SI_PDEFENSE = 223, + //SI_PCRITICAL = 224, + //SI_RANKING = 225, + //SI_PTRIPLE = 226, + //SI_DENERGY = 227, + //SI_WAVE1 = 228, + //SI_WAVE2 = 229, + //SI_WAVE3 = 230, + //SI_WAVE4 = 231, + //SI_DAURA = 232, + //SI_DFREEZER = 233, + //SI_DPUNISH = 234, + //SI_DBARRIER = 235, + //SI_DWARNING = 236, + //SI_MOUSEWHEEL = 237, + //SI_DGAUGE = 238, + //SI_DACCEL = 239, + //SI_DBLOCK = 240, + SI_FOOD_STR = 241, + SI_FOOD_AGI = 242, + SI_FOOD_VIT = 243, + SI_FOOD_DEX = 244, + SI_FOOD_INT = 245, + SI_FOOD_LUK = 246, + SI_FOOD_BASICAVOIDANCE = 247, + SI_FOOD_BASICHIT = 248, + SI_FOOD_CRITICALSUCCESSVALUE = 249, + + SI_CASH_PLUSEXP = 250, + SI_CASH_DEATHPENALTY = 251, + SI_CASH_RECEIVEITEM = 252, + SI_CASH_BOSS_ALARM = 253, + //SI_DA_ENERGY = 254, + //SI_DA_FIRSTSLOT = 255, + //SI_DA_HEADDEF = 256, + //SI_DA_SPACE = 257, + //SI_DA_TRANSFORM = 258, + //SI_DA_ITEMREBUILD = 259, + //SI_DA_ILLUSION = 260, //All mobs display as Turtle General + //SI_DA_DARKPOWER = 261, + //SI_DA_EARPLUG = 262, + //SI_DA_CONTRACT = 263, //Bio Mob effect on you and SI_TRICKDEAD icon + //SI_DA_BLACK = 264, //For short time blurry screen + //SI_DA_MAGICCART = 265, + //SI_CRYSTAL = 266, + //SI_DA_REBUILD = 267, + //SI_DA_EDARKNESS = 268, + //SI_DA_EGUARDIAN = 269, + //SI_DA_TIMEOUT = 270, + SI_FOOD_STR_CASH = 271, + SI_FOOD_AGI_CASH = 272, + SI_FOOD_VIT_CASH = 273, + SI_FOOD_DEX_CASH = 274, + SI_FOOD_INT_CASH = 275, + SI_FOOD_LUK_CASH = 276, + SI_MER_FLEE = 277, + SI_MER_ATK = 278, + SI_MER_HP = 279, + SI_MER_SP = 280, + SI_MER_HIT = 281, + SI_SLOWCAST = 282, + //SI_MAGICMIRROR = 283, + //SI_STONESKIN = 284, + //SI_ANTIMAGIC = 285, + SI_CRITICALWOUND = 286, + //SI_NPC_DEFENDER = 287, + //SI_NOACTION_WAIT = 288, + SI_MOVHASTE_HORSE = 289, + SI_PROTECT_DEF = 290, + SI_PROTECT_MDEF = 291, + SI_HEALPLUS = 292, + SI_S_LIFEPOTION = 293, + SI_L_LIFEPOTION = 294, + SI_CRITICALPERCENT = 295, + SI_PLUSAVOIDVALUE = 296, + //SI_ATKER_ASPD = 297, + //SI_TARGET_ASPD = 298, + //SI_ATKER_MOVESPEED = 299, + + SI_ATKER_BLOOD = 300, + SI_TARGET_BLOOD = 301, + SI_ARMOR_PROPERTY = 302, + //SI_REUSE_LIMIT_A = 303, + SI_HELLPOWER = 304, + //SI_STEAMPACK = 305, + //SI_REUSE_LIMIT_B = 306, + //SI_REUSE_LIMIT_C = 307, + //SI_REUSE_LIMIT_D = 308, + //SI_REUSE_LIMIT_E = 309, + //SI_REUSE_LIMIT_F = 310, + SI_INVINCIBLE = 311, + SI_CASH_PLUSONLYJOBEXP = 312, + SI_PARTYFLEE = 313, + SI_ANGEL_PROTECT = 314, + //SI_ENDURE_MDEF = 315, + SI_ENCHANTBLADE = 316, + SI_DEATHBOUND = 317, + SI_REFRESH = 318, + SI_GIANTGROWTH = 319, + SI_STONEHARDSKIN = 320, + SI_VITALITYACTIVATION = 321, + SI_FIGHTINGSPIRIT = 322, + SI_ABUNDANCE = 323, + SI_REUSE_MILLENNIUMSHIELD = 324, + SI_REUSE_CRUSHSTRIKE = 325, + SI_REUSE_REFRESH = 326, + SI_REUSE_STORMBLAST = 327, + SI_VENOMIMPRESS = 328, + SI_EPICLESIS = 329, + SI_ORATIO = 330, + SI_LAUDAAGNUS = 331, + SI_LAUDARAMUS = 332, + SI_CLOAKINGEXCEED = 333, + SI_HALLUCINATIONWALK = 334, + SI_HALLUCINATIONWALK_POSTDELAY = 335, + SI_RENOVATIO = 336, + SI_WEAPONBLOCKING = 337, + SI_WEAPONBLOCKING_POSTDELAY = 338, + SI_ROLLINGCUTTER = 339, + SI_EXPIATIO = 340, + SI_POISONINGWEAPON = 341, + SI_TOXIN = 342, + SI_PARALYSE = 343, + SI_VENOMBLEED = 344, + SI_MAGICMUSHROOM = 345, + SI_DEATHHURT = 346, + SI_PYREXIA = 347, + SI_OBLIVIONCURSE = 348, + SI_LEECHESEND = 349, + + SI_DUPLELIGHT = 350, + SI_FROSTMISTY = 351, + SI_FEARBREEZE = 352, + SI_ELECTRICSHOCKER = 353, + SI_MARSHOFABYSS = 354, + SI_RECOGNIZEDSPELL = 355, + SI_STASIS = 356, + SI_WUGRIDER = 357, + SI_WUGDASH = 358, + SI_WUGBITE = 359, + SI_CAMOUFLAGE = 360, + SI_ACCELERATION = 361, + SI_HOVERING = 362, + SI_SPHERE_1 = 363, + SI_SPHERE_2 = 364, + SI_SPHERE_3 = 365, + SI_SPHERE_4 = 366, + SI_SPHERE_5 = 367, + SI_MVPCARD_TAOGUNKA = 368, + SI_MVPCARD_MISTRESS = 369, + SI_MVPCARD_ORCHERO = 370, + SI_MVPCARD_ORCLORD = 371, + SI_OVERHEAT_LIMITPOINT = 372, + SI_OVERHEAT = 373, + SI_SHAPESHIFT = 374, + SI_INFRAREDSCAN = 375, + SI_MAGNETICFIELD = 376, + SI_NEUTRALBARRIER = 377, + SI_NEUTRALBARRIER_MASTER = 378, + SI_STEALTHFIELD = 379, + SI_STEALTHFIELD_MASTER = 380, + SI_MANU_ATK = 381, + SI_MANU_DEF = 382, + SI_SPL_ATK = 383, + SI_SPL_DEF = 384, + SI_REPRODUCE = 385, + SI_MANU_MATK = 386, + SI_SPL_MATK = 387, + SI_STR_SCROLL = 388, + SI_INT_SCROLL = 389, + SI_LG_REFLECTDAMAGE = 390, + SI_FORCEOFVANGUARD = 391, + SI_BUCHEDENOEL = 392, + SI_AUTOSHADOWSPELL = 393, + SI_SHADOWFORM = 394, + SI_RAID = 395, + SI_SHIELDSPELL_DEF = 396, + SI_SHIELDSPELL_MDEF = 397, + SI_SHIELDSPELL_REF = 398, + SI_BODYPAINT = 399, + + SI_EXEEDBREAK = 400, + SI_ADORAMUS = 401, + SI_PRESTIGE = 402, + SI_INVISIBILITY = 403, + SI_DEADLYINFECT = 404, + SI_BANDING = 405, + SI_EARTHDRIVE = 406, + SI_INSPIRATION = 407, + SI_ENERVATION = 408, + SI_GROOMY = 409, + SI_RAISINGDRAGON = 410, + SI_IGNORANCE = 411, + SI_LAZINESS = 412, + SI_LIGHTNINGWALK = 413, + SI_ACARAJE = 414, + SI_UNLUCKY = 415, + SI_CURSEDCIRCLE_ATKER = 416, + SI_CURSEDCIRCLE_TARGET = 417, + SI_WEAKNESS = 418, + SI_CRESCENTELBOW = 419, + SI_NOEQUIPACCESSARY = 420, + SI_STRIPACCESSARY = 421, + SI_MANHOLE = 422, + SI_POPECOOKIE = 423, + SI_FALLENEMPIRE = 424, + SI_GENTLETOUCH_ENERGYGAIN = 425, + SI_GENTLETOUCH_CHANGE = 426, + SI_GENTLETOUCH_REVITALIZE = 427, + SI_BLOODYLUST = 428, + SI_SWINGDANCE = 429, + SI_SYMPHONYOFLOVERS = 430, + SI_PROPERTYWALK = 431, + SI_SPELLFIST = 432, + SI_NETHERWORLD = 433, + SI_SIREN = 434, + SI_DEEPSLEEP = 435, + SI_SIRCLEOFNATURE = 436, + SI_COLD = 437, + SI_GLOOMYDAY = 438, + SI_SONG_OF_MANA = 439, + SI_CLOUDKILL = 440, + SI_DANCEWITHWUG = 441, + SI_RUSHWINDMILL = 442, + SI_ECHOSONG = 443, + SI_HARMONIZE = 444, + SI_STRIKING = 445, + SI_WARMER = 446, + SI_MOONLITSERENADE = 447, + SI_SATURDAYNIGHTFEVER = 448, + SI_SITDOWN_FORCE = 449, + + SI_ANALYZE = 450, + SI_LERADSDEW = 451, + SI_MELODYOFSINK = 452, + SI_WARCRYOFBEYOND = 453, + SI_UNLIMITEDHUMMINGVOICE = 454, + SI_SPELLBOOK1 = 455, + SI_SPELLBOOK2 = 456, + SI_SPELLBOOK3 = 457, + SI_FREEZE_SP = 458, + SI_GN_TRAINING_SWORD = 459, + SI_GN_REMODELING_CART = 460, + SI_CARTSBOOST = 461, + SI_FIXEDCASTINGTM_REDUCE = 462, + SI_THORNTRAP = 463, + SI_BLOODSUCKER = 464, + SI_SPORE_EXPLOSION = 465, + SI_DEMONIC_FIRE = 466, + SI_FIRE_EXPANSION_SMOKE_POWDER = 467, + SI_FIRE_EXPANSION_TEAR_GAS = 468, + SI_BLOCKING_PLAY = 469, + SI_MANDRAGORA = 470, + SI_ACTIVATE = 471, + SI_SECRAMENT = 472, + SI_ASSUMPTIO2 = 473, + SI_TK_SEVENWIND = 474, + SI_LIMIT_ODINS_RECALL = 475, + SI_STOMACHACHE = 476, + SI_MYSTERIOUS_POWDER = 477, + SI_MELON_BOMB = 478, + SI_BANANA_BOMB_SITDOWN_POSTDELAY = 479, + SI_PROMOTE_HEALTH_RESERCH = 480, + SI_ENERGY_DRINK_RESERCH = 481, + SI_EXTRACT_WHITE_POTION_Z = 482, + SI_VITATA_500 = 483, + SI_EXTRACT_SALAMINE_JUICE = 484, + SI_BOOST500 = 485, + SI_FULL_SWING_K = 486, + SI_MANA_PLUS = 487, + SI_MUSTLE_M = 488, + SI_LIFE_FORCE_F = 489, + SI_VACUUM_EXTREME = 490, + SI_SAVAGE_STEAK = 491, + SI_COCKTAIL_WARG_BLOOD = 492, + SI_MINOR_BBQ = 493, + SI_SIROMA_ICE_TEA = 494, + SI_DROCERA_HERB_STEAMED = 495, + SI_PUTTI_TAILS_NOODLES = 496, + SI_BANANA_BOMB = 497, + SI_SUMMON_AGNI = 498, + SI_SPELLBOOK4 = 499, + + SI_SPELLBOOK5 = 500, + SI_SPELLBOOK6 = 501, + SI_SPELLBOOK7 = 502, + SI_ELEMENTAL_AGGRESSIVE = 503, + SI_RETURN_TO_ELDICASTES = 504, + SI_BANDING_DEFENCE = 505, + SI_SKELSCROLL = 506, + SI_DISTRUCTIONSCROLL = 507, + SI_ROYALSCROLL = 508, + SI_IMMUNITYSCROLL = 509, + SI_MYSTICSCROLL = 510, + SI_BATTLESCROLL = 511, + SI_ARMORSCROLL = 512, + SI_FREYJASCROLL = 513, + SI_SOULSCROLL = 514, + SI_CIRCLE_OF_FIRE = 515, + SI_CIRCLE_OF_FIRE_OPTION = 516, + SI_FIRE_CLOAK = 517, + SI_FIRE_CLOAK_OPTION = 518, + SI_WATER_SCREEN = 519, + SI_WATER_SCREEN_OPTION = 520, + SI_WATER_DROP = 521, + SI_WATER_DROP_OPTION = 522, + SI_WIND_STEP = 523, + SI_WIND_STEP_OPTION = 524, + SI_WIND_CURTAIN = 525, + SI_WIND_CURTAIN_OPTION = 526, + SI_WATER_BARRIER = 527, + SI_ZEPHYR = 528, + SI_SOLID_SKIN = 529, + SI_SOLID_SKIN_OPTION = 530, + SI_STONE_SHIELD = 531, + SI_STONE_SHIELD_OPTION = 532, + SI_POWER_OF_GAIA = 533, + //SI_EL_WAIT = 534, + //SI_EL_PASSIVE = 535, + //SI_EL_DEFENSIVE = 536, + //SI_EL_OFFENSIVE = 537, + //SI_EL_COST = 538, + SI_PYROTECHNIC = 539, + SI_PYROTECHNIC_OPTION = 540, + SI_HEATER = 541, + SI_HEATER_OPTION = 542, + SI_TROPIC = 543, + SI_TROPIC_OPTION = 544, + SI_AQUAPLAY = 545, + SI_AQUAPLAY_OPTION = 546, + SI_COOLER = 547, + SI_COOLER_OPTION = 548, + SI_CHILLY_AIR = 549, + + SI_CHILLY_AIR_OPTION = 550, + SI_GUST = 551, + SI_GUST_OPTION = 552, + SI_BLAST = 553, + SI_BLAST_OPTION = 554, + SI_WILD_STORM = 555, + SI_WILD_STORM_OPTION = 556, + SI_PETROLOGY = 557, + SI_PETROLOGY_OPTION = 558, + SI_CURSED_SOIL = 559, + SI_CURSED_SOIL_OPTION = 560, + SI_UPHEAVAL = 561, + SI_UPHEAVAL_OPTION = 562, + SI_TIDAL_WEAPON = 563, + SI_TIDAL_WEAPON_OPTION = 564, + SI_ROCK_CRUSHER = 565, + SI_ROCK_CRUSHER_ATK = 566, + SI_FIRE_INSIGNIA = 567, + SI_WATER_INSIGNIA = 568, + SI_WIND_INSIGNIA = 569, + SI_EARTH_INSIGNIA = 570, + SI_EQUIPED_FLOOR = 571, + SI_GUARDIAN_RECALL = 572, + SI_MORA_BUFF = 573, + SI_REUSE_LIMIT_G = 574, + SI_REUSE_LIMIT_H = 575, + SI_NEEDLE_OF_PARALYZE = 576, + SI_PAIN_KILLER = 577, + SI_G_LIFEPOTION = 578, + SI_VITALIZE_POTION = 579, + SI_LIGHT_OF_REGENE = 580, + SI_OVERED_BOOST = 581, + SI_SILENT_BREEZE = 582, + SI_ODINS_POWER = 583, + SI_STYLE_CHANGE = 584, + SI_SONIC_CLAW_POSTDELAY = 585, // ID's 586 - 595 Currently Unused - SI_SILVERVEIN_RUSH_POSTDELAY = 596, - SI_MIDNIGHT_FRENZY_POSTDELAY = 597, - SI_GOLDENE_FERSE = 598, - SI_ANGRIFFS_MODUS = 599, - SI_TINDER_BREAKER = 600, - SI_TINDER_BREAKER_POSTDELAY = 601, - SI_CBC = 602, - SI_CBC_POSTDELAY = 603, - SI_EQC = 604, - SI_MAGMA_FLOW = 605, - SI_GRANITIC_ARMOR = 606, - SI_PYROCLASTIC = 607, - SI_VOLCANIC_ASH = 608, - SI_SPIRITS_SAVEINFO1 = 609, - SI_SPIRITS_SAVEINFO2 = 610, - SI_MAGIC_CANDY = 611, - SI_SEARCH_STORE_INFO = 612, - SI_ALL_RIDING = 613, - SI_ALL_RIDING_REUSE_LIMIT = 614, - SI_MACRO = 615, - SI_MACRO_POSTDELAY = 616, - SI_BEER_BOTTLE_CAP = 617, - SI_OVERLAPEXPUP = 618, - SI_PC_IZ_DUN05 = 619, - SI_CRUSHSTRIKE = 620, - SI_MONSTER_TRANSFORM = 621, - SI_SIT = 622, - SI_ONAIR = 623, - SI_MTF_ASPD = 624, - SI_MTF_RANGEATK = 625, - SI_MTF_MATK = 626, - SI_MTF_MLEATKED = 627, - SI_MTF_CRIDAMAGE = 628, - SI_REUSE_LIMIT_MTF = 629, - SI_MACRO_PERMIT = 630, - SI_MACRO_PLAY = 631, - SI_SKF_CAST = 632, - SI_SKF_ASPD = 633, - SI_SKF_ATK = 634, - SI_SKF_MATK = 635, - SI_REWARD_PLUSONLYJOBEXP = 636, - SI_HANDICAPSTATE_NORECOVER = 637, - SI_SET_NUM_DEF = 638, - SI_SET_NUM_MDEF = 639, - SI_SET_PER_DEF = 640, - SI_SET_PER_MDEF = 641, - SI_PARTYBOOKING_SEARCH_DEALY = 642, - SI_PARTYBOOKING_REGISTER_DEALY = 643, - SI_PERIOD_TIME_CHECK_DETECT_SKILL = 644, - SI_KO_JYUMONJIKIRI = 645, - SI_MEIKYOUSISUI = 646, - SI_ATTHASTE_CASH = 647, - SI_EQUIPPED_DIVINE_ARMOR = 648, - SI_EQUIPPED_HOLY_ARMOR = 649, - SI_2011RWC = 650, - SI_KYOUGAKU = 651, - SI_IZAYOI = 652, - SI_ZENKAI = 653, - SI_KG_KAGEHUMI = 654, - SI_KYOMU = 655, - SI_KAGEMUSYA = 656, - SI_ZANGETSU = 657, - SI_PHI_DEMON = 658, - SI_GENSOU = 659, - SI_AKAITSUKI = 660, - SI_TETANY = 661, - SI_GM_BATTLE = 662, - SI_GM_BATTLE2 = 663, - SI_2011RWC_SCROLL = 664, - SI_ACTIVE_MONSTER_TRANSFORM = 665, - SI_MYSTICPOWDER = 666, - SI_ECLAGE_RECALL = 667, - SI_ENTRY_QUEUE_APPLY_DELAY = 668, - SI_REUSE_LIMIT_ECL = 669, - SI_M_LIFEPOTION = 670, + SI_SILVERVEIN_RUSH_POSTDELAY = 596, + SI_MIDNIGHT_FRENZY_POSTDELAY = 597, + SI_GOLDENE_FERSE = 598, + SI_ANGRIFFS_MODUS = 599, + + SI_TINDER_BREAKER = 600, + SI_TINDER_BREAKER_POSTDELAY = 601, + SI_CBC = 602, + SI_CBC_POSTDELAY = 603, + SI_EQC = 604, + SI_MAGMA_FLOW = 605, + SI_GRANITIC_ARMOR = 606, + SI_PYROCLASTIC = 607, + SI_VOLCANIC_ASH = 608, + SI_SPIRITS_SAVEINFO1 = 609, + SI_SPIRITS_SAVEINFO2 = 610, + SI_MAGIC_CANDY = 611, + SI_SEARCH_STORE_INFO = 612, + SI_ALL_RIDING = 613, + SI_ALL_RIDING_REUSE_LIMIT = 614, + SI_MACRO = 615, + SI_MACRO_POSTDELAY = 616, + SI_BEER_BOTTLE_CAP = 617, + SI_OVERLAPEXPUP = 618, + SI_PC_IZ_DUN05 = 619, + SI_CRUSHSTRIKE = 620, + SI_MONSTER_TRANSFORM = 621, + SI_SIT = 622, + SI_ONAIR = 623, + SI_MTF_ASPD = 624, + SI_MTF_RANGEATK = 625, + SI_MTF_MATK = 626, + SI_MTF_MLEATKED = 627, + SI_MTF_CRIDAMAGE = 628, + SI_REUSE_LIMIT_MTF = 629, + SI_MACRO_PERMIT = 630, + SI_MACRO_PLAY = 631, + SI_SKF_CAST = 632, + SI_SKF_ASPD = 633, + SI_SKF_ATK = 634, + SI_SKF_MATK = 635, + SI_REWARD_PLUSONLYJOBEXP = 636, + SI_HANDICAPSTATE_NORECOVER = 637, + SI_SET_NUM_DEF = 638, + SI_SET_NUM_MDEF = 639, + SI_SET_PER_DEF = 640, + SI_SET_PER_MDEF = 641, + SI_PARTYBOOKING_SEARCH_DEALY = 642, + SI_PARTYBOOKING_REGISTER_DEALY = 643, + SI_PERIOD_TIME_CHECK_DETECT_SKILL = 644, + SI_KO_JYUMONJIKIRI = 645, + SI_MEIKYOUSISUI = 646, + SI_ATTHASTE_CASH = 647, + SI_EQUIPPED_DIVINE_ARMOR = 648, + SI_EQUIPPED_HOLY_ARMOR = 649, + + SI_2011RWC = 650, + SI_KYOUGAKU = 651, + SI_IZAYOI = 652, + SI_ZENKAI = 653, + SI_KG_KAGEHUMI = 654, + SI_KYOMU = 655, + SI_KAGEMUSYA = 656, + SI_ZANGETSU = 657, + SI_PHI_DEMON = 658, + SI_GENSOU = 659, + SI_AKAITSUKI = 660, + SI_TETANY = 661, + SI_GM_BATTLE = 662, + SI_GM_BATTLE2 = 663, + SI_2011RWC_SCROLL = 664, + SI_ACTIVE_MONSTER_TRANSFORM = 665, + SI_MYSTICPOWDER = 666, + SI_ECLAGE_RECALL = 667, + SI_ENTRY_QUEUE_APPLY_DELAY = 668, + SI_REUSE_LIMIT_ECL = 669, + SI_M_LIFEPOTION = 670, SI_ENTRY_QUEUE_NOTIFY_ADMISSION_TIME_OUT = 671, - SI_UNKNOWN_NAME = 672, - SI_ON_PUSH_CART = 673, - SI_HAT_EFFECT = 674, - SI_FLOWER_LEAF = 675, - SI_RAY_OF_PROTECTION = 676, - SI_GLASTHEIM_ATK = 677, - SI_GLASTHEIM_DEF = 678, - SI_GLASTHEIM_HEAL = 679, - SI_GLASTHEIM_HIDDEN = 680, - SI_GLASTHEIM_STATE = 681, - SI_GLASTHEIM_ITEMDEF = 682, - SI_GLASTHEIM_HPSP = 683, - SI_HOMUN_SKILL_POSTDELAY = 684, - SI_ALMIGHTY = 685, - SI_GVG_GIANT = 686, - SI_GVG_GOLEM = 687, - SI_GVG_STUN = 688, - SI_GVG_STONE = 689, - SI_GVG_FREEZ = 690, - SI_GVG_SLEEP = 691, - SI_GVG_CURSE = 692, - SI_GVG_SILENCE = 693, - SI_GVG_BLIND = 694, - SI_CLIENT_ONLY_EQUIP_ARROW = 695, - SI_CLAN_INFO = 696, - SI_JP_EVENT01 = 697, - SI_JP_EVENT02 = 698, - SI_JP_EVENT03 = 699, - SI_JP_EVENT04 = 700, - SI_TELEPORT_FIXEDCASTINGDELAY = 701, - SI_GEFFEN_MAGIC1 = 702, - SI_GEFFEN_MAGIC2 = 703, - SI_GEFFEN_MAGIC3 = 704, - SI_QUEST_BUFF1 = 705, - SI_QUEST_BUFF2 = 706, - SI_QUEST_BUFF3 = 707, - SI_REUSE_LIMIT_RECALL = 708, - SI_SAVEPOSITION = 709, - SI_HANDICAPSTATE_ICEEXPLO = 710, - SI_FENRIR_CARD = 711, - SI_REUSE_LIMIT_ASPD_POTION = 712, - SI_MAXPAIN = 713, - SI_PC_STOP = 714, - SI_FRIGG_SONG = 715, - SI_OFFERTORIUM = 716, - SI_TELEKINESIS_INTENSE = 717, - SI_MOONSTAR = 718, - SI_STRANGELIGHTS = 719, - SI_FULL_THROTTLE = 720, - SI_REBOUND = 721, - SI_UNLIMIT = 722, - SI_KINGS_GRACE = 723, - SI_ITEM_ATKMAX = 724, - SI_ITEM_ATKMIN = 725, - SI_ITEM_MATKMAX = 726, - SI_ITEM_MATKMIN = 727, - SI_SUPER_STAR = 728, - SI_HIGH_RANKER = 729, - SI_DARKCROW = 730, - SI_2013_VALENTINE1 = 731, - SI_2013_VALENTINE2 = 732, - SI_2013_VALENTINE3 = 733, - SI_ILLUSIONDOPING = 734, - //SI_ = 735, - SI_CHILL = 736, - SI_BURNT = 737, - SI_FLASHCOMBO = 740, - SI_B_TRAP = 752, - SI_E_CHAIN = 753, - SI_E_QD_SHOT_READY = 754, - SI_C_MARKER = 755, - SI_H_MINE = 756, - SI_H_MINE_SPLASH = 757, - SI_P_ALTER = 758, - SI_HEAT_BARREL = 759, - SI_ANTI_M_BLAST = 760, - SI_SLUGSHOT = 761, - SI_SWORDCLAN = 762, - SI_ARCWANDCLAN = 763, - SI_GOLDENMACECLAN = 764, - SI_CROSSBOWCLAN = 765, - SI_PACKING_ENVELOPE1 = 766, - SI_PACKING_ENVELOPE2 = 767, - SI_PACKING_ENVELOPE3 = 768, - SI_PACKING_ENVELOPE4 = 769, - SI_PACKING_ENVELOPE5 = 770, - SI_PACKING_ENVELOPE6 = 771, - SI_PACKING_ENVELOPE7 = 772, - SI_PACKING_ENVELOPE8 = 773, - SI_PACKING_ENVELOPE9 = 774, - SI_PACKING_ENVELOPE10 = 775, - SI_GLASTHEIM_TRANS = 776, - SI_HEAT_BARREL_AFTER = 778, - SI_DECORATION_OF_MUSIC = 779, + SI_UNKNOWN_NAME = 672, + SI_ON_PUSH_CART = 673, + SI_HAT_EFFECT = 674, + SI_FLOWER_LEAF = 675, + SI_RAY_OF_PROTECTION = 676, + SI_GLASTHEIM_ATK = 677, + SI_GLASTHEIM_DEF = 678, + SI_GLASTHEIM_HEAL = 679, + SI_GLASTHEIM_HIDDEN = 680, + SI_GLASTHEIM_STATE = 681, + SI_GLASTHEIM_ITEMDEF = 682, + SI_GLASTHEIM_HPSP = 683, + SI_HOMUN_SKILL_POSTDELAY = 684, + SI_ALMIGHTY = 685, + SI_GVG_GIANT = 686, + SI_GVG_GOLEM = 687, + SI_GVG_STUN = 688, + SI_GVG_STONE = 689, + SI_GVG_FREEZ = 690, + SI_GVG_SLEEP = 691, + SI_GVG_CURSE = 692, + SI_GVG_SILENCE = 693, + SI_GVG_BLIND = 694, + SI_CLIENT_ONLY_EQUIP_ARROW = 695, + SI_CLAN_INFO = 696, + SI_JP_EVENT01 = 697, + SI_JP_EVENT02 = 698, + SI_JP_EVENT03 = 699, + + SI_JP_EVENT04 = 700, + SI_TELEPORT_FIXEDCASTINGDELAY = 701, + SI_GEFFEN_MAGIC1 = 702, + SI_GEFFEN_MAGIC2 = 703, + SI_GEFFEN_MAGIC3 = 704, + SI_QUEST_BUFF1 = 705, + SI_QUEST_BUFF2 = 706, + SI_QUEST_BUFF3 = 707, + SI_REUSE_LIMIT_RECALL = 708, + SI_SAVEPOSITION = 709, + SI_HANDICAPSTATE_ICEEXPLO = 710, + SI_FENRIR_CARD = 711, + SI_REUSE_LIMIT_ASPD_POTION = 712, + SI_MAXPAIN = 713, + SI_PC_STOP = 714, + SI_FRIGG_SONG = 715, + SI_OFFERTORIUM = 716, + SI_TELEKINESIS_INTENSE = 717, + SI_MOONSTAR = 718, + SI_STRANGELIGHTS = 719, + SI_FULL_THROTTLE = 720, + SI_REBOUND = 721, + SI_UNLIMIT = 722, + SI_KINGS_GRACE = 723, + SI_ITEM_ATKMAX = 724, + SI_ITEM_ATKMIN = 725, + SI_ITEM_MATKMAX = 726, + SI_ITEM_MATKMIN = 727, + SI_SUPER_STAR = 728, + SI_HIGH_RANKER = 729, + SI_DARKCROW = 730, + SI_2013_VALENTINE1 = 731, + SI_2013_VALENTINE2 = 732, + SI_2013_VALENTINE3 = 733, + SI_ILLUSIONDOPING = 734, + //SI_ = 735, + SI_CHILL = 736, + SI_BURNT = 737, + //... + SI_FLASHCOMBO = 740, + + //... + SI_B_TRAP = 752, + SI_E_CHAIN = 753, + SI_E_QD_SHOT_READY = 754, + SI_C_MARKER = 755, + SI_H_MINE = 756, + SI_H_MINE_SPLASH = 757, + SI_P_ALTER = 758, + SI_HEAT_BARREL = 759, + SI_ANTI_M_BLAST = 760, + SI_SLUGSHOT = 761, + SI_SWORDCLAN = 762, + SI_ARCWANDCLAN = 763, + SI_GOLDENMACECLAN = 764, + SI_CROSSBOWCLAN = 765, + SI_PACKING_ENVELOPE1 = 766, + SI_PACKING_ENVELOPE2 = 767, + SI_PACKING_ENVELOPE3 = 768, + SI_PACKING_ENVELOPE4 = 769, + SI_PACKING_ENVELOPE5 = 770, + SI_PACKING_ENVELOPE6 = 771, + SI_PACKING_ENVELOPE7 = 772, + SI_PACKING_ENVELOPE8 = 773, + SI_PACKING_ENVELOPE9 = 774, + SI_PACKING_ENVELOPE10 = 775, + SI_GLASTHEIM_TRANS = 776, + //... + SI_HEAT_BARREL_AFTER = 778, + SI_DECORATION_OF_MUSIC = 779, + SI_MAX, }; // JOINTBEAT stackable ailments @@ -1698,7 +1719,7 @@ struct status_data { speed, amotion, adelay, dmotion, mode; - short + short hit, flee, cri, flee2, def2, mdef2, #ifdef RENEWAL_ASPD @@ -1867,7 +1888,7 @@ struct s_refine_info { }; /*===================================== -* Interface : status.h +* Interface : status.h * Generated by HerculesInterfaceMaker * created by Susu *-------------------------------------*/ diff --git a/src/map/unit.c b/src/map/unit.c index 0ad770e80..e22d6f697 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -1180,8 +1180,8 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui if( (skill->get_inf2(skill_id)&INF2_ENSEMBLE_SKILL) && skill->check_pc_partner(sd, skill_id, &skill_lv, 1, 0) < 1 ) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); - return 0; - } + return 0; + } switch(skill_id){ case SA_CASTCANCEL: @@ -1371,7 +1371,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui // in official this is triggered even if no cast time. clif->skillcasting(src, src->id, target_id, 0,0, skill_id, skill->get_ele(skill_id, skill_lv), casttime); if( casttime > 0 || temp ) - { + { if (sd && target->type == BL_MOB) { TBL_MOB *md = (TBL_MOB*)target; @@ -1555,7 +1555,7 @@ int unit_skilluse_pos2( struct block_list *src, short skill_x, short skill_y, ui if( casttime > 0 ) { ud->skilltimer = timer->add( tick+casttime, skill->castend_pos, src->id, 0 ); if( (sd && pc->checkskill(sd,SA_FREECAST) > 0) || skill_id == LG_EXEEDBREAK) - status_calc_bl(&sd->bl, SCB_SPEED); + status_calc_bl(&sd->bl, SCB_SPEED); } else { ud->skilltimer = INVALID_TIMER; skill->castend_pos(ud->skilltimer,tick,src->id,0); diff --git a/src/map/vending.c b/src/map/vending.c index c8ac814db..7e9393bf2 100644 --- a/src/map/vending.c +++ b/src/map/vending.c @@ -60,7 +60,7 @@ void vending_vendinglistreq(struct map_session_data* sd, unsigned int id) { // GM is not allowed to trade clif->message(sd->fd, msg_txt(246)); return; - } + } sd->vended_id = vsd->vender_id; // register vending uid diff --git a/src/plugins/db2sql.c b/src/plugins/db2sql.c index 46d654e0d..b8f21407e 100644 --- a/src/plugins/db2sql.c +++ b/src/plugins/db2sql.c @@ -198,7 +198,7 @@ HPExport void server_preinit (void) { libconfig = GET_SYMBOL("libconfig"); - addArg("--db2sql",false,db2sql_arg,NULL); + addArg("--db2sql",false,db2sql_arg,NULL); } HPExport void plugin_init (void) { addCPCommand("server:tools:db2sql",db2sql); diff --git a/src/plugins/dbghelpplug.c b/src/plugins/dbghelpplug.c index 32b30d69a..0f1690f4b 100644 --- a/src/plugins/dbghelpplug.c +++ b/src/plugins/dbghelpplug.c @@ -17,7 +17,7 @@ HPExport struct hplugin_info pinfo = { #ifdef _WIN32 ///////////////////////////////////////////////////////////////////// -// Include files +// Include files // #include <assert.h> @@ -32,13 +32,12 @@ HPExport struct hplugin_info pinfo = { #include <time.h> ///////////////////////////////////////////////////////////////////// -// Types from Cvconst.h (DIA SDK) +// Types from Cvconst.h (DIA SDK) // #ifdef _NO_CVCONST_H -typedef enum _BasicType -{ +typedef enum _BasicType { btNoType = 0, btVoid = 1, btChar = 2, @@ -66,7 +65,7 @@ typedef enum _UdtKind UdtUnion } UdtKind; /* -typedef enum _SymTag { +typedef enum _SymTag { SymTagNull = 0, SymTagExe = 1, SymTagCompiland = 2, @@ -235,7 +234,7 @@ SYMGETMODULEBASE SymGetModuleBase_ = NULL; ///////////////////////////////////////////////////////////////////// // Code -/// Writes the minidump to file. The callback function will at the +/// Writes the minidump to file. The callback function will at the /// same time write the list of modules to the log file. /// /// @param file Filename of the minidump @@ -324,7 +323,7 @@ Dhp__PrintModuleInfoCallback( return TRUE; } -/// Prints details about the current process, platform and exception +/// Prints details about the current process, platform and exception /// information to the log file. /// /// @param exception Exception info @@ -418,7 +417,7 @@ Dhp__PrintProcessInfo( { fprintf(log_file, "eip=%08x esp=%08x ebp=%08x iopl=%1x %s %s %s %s %s %s %s %s %s %s\n", - context->Eip, context->Esp, context->Ebp, + context->Eip, context->Esp, context->Ebp, (context->EFlags >> 12) & 3, // IOPL level value context->EFlags & 0x00100000 ? "vip" : " ", // VIP (virtual interrupt pending) context->EFlags & 0x00080000 ? "vif" : " ", // VIF (virtual interrupt flag) @@ -487,7 +486,7 @@ Dhp__PrintTypeName( switch( symtag ) { case SymTagEnum: - { + { WCHAR* pwszTypeName; if( SymGetTypeInfo_(hProcess, modBase, typeIndex, TI_GET_SYMNAME, &pwszTypeName) ) @@ -1007,7 +1006,7 @@ Dhp__PrintDataValue( fprintf(log_file, "0x%p", *(void**)pVariable); if( SymGetTypeInfo_(hProcess, modBase, typeIndex, TI_GET_TYPE, &childTypeIndex) && - SymGetTypeInfo_(hProcess, modBase, childTypeIndex, TI_GET_SYMTAG, &childSymtag) && + SymGetTypeInfo_(hProcess, modBase, childTypeIndex, TI_GET_SYMTAG, &childSymtag) && childSymtag != SymTagPointerType ) { DWORD childBasetype; @@ -1277,9 +1276,9 @@ Dhp__PrintSymbolInfo( assert( pSymInfo != NULL ); assert( pInterData != NULL ); - switch( pSymInfo->Tag ) + switch( pSymInfo->Tag ) { - case SymTagData: Dhp__PrintDataInfo( pSymInfo, pInterData ); break; + case SymTagData: Dhp__PrintDataInfo( pSymInfo, pInterData ); break; default: /*fprintf(pInterData->log_file, "<unsupported symtag %d>", pSymInfo->Tag);*/ break; } } diff --git a/src/test/test_spinlock.c b/src/test/test_spinlock.c index 878ee8bab..0c0e3e2ae 100644 --- a/src/test/test_spinlock.c +++ b/src/test/test_spinlock.c @@ -8,13 +8,13 @@ #include <stdio.h> #include <stdlib.h> -// -// Simple test for the spinlock implementation to see if it works properly.. +// +// Simple test for the spinlock implementation to see if it works properly.. // -#define THRC 32 //thread Count +#define THRC 32 //thread Count #define PERINC 100000 #define LOOPS 47 @@ -66,7 +66,7 @@ int do_init(int argc, char **argv){ while(1){ - if(InterlockedCompareExchange(&done_threads, THRC, THRC) == THRC) + if(InterlockedCompareExchange(&done_threads, THRC, THRC) == THRC) break; rathread_yield(); @@ -86,7 +86,7 @@ int do_init(int argc, char **argv){ if(ok != LOOPS){ - ShowFatalError("Test failed.\n"); + ShowFatalError("Test failed.\n"); exit(1); }else{ ShowStatus("Test passed.\n"); @@ -103,11 +103,12 @@ void do_abort(){ void set_server_type(){ - SERVER_TYPE = ATHENA_SERVER_NONE; + SERVER_TYPE = SERVER_TYPE_UNKNOWN; }//end: set_server_type() -void do_final(){ +int do_final(){ + return EXIT_SUCCESS; }//end: do_final() -- cgit v1.2.3-70-g09d2 From 0a4975ed611db7d1bcfe501008085e420e743128 Mon Sep 17 00:00:00 2001 From: Shido <the.keikun@gmail.com> Date: Fri, 30 May 2014 10:37:54 +0800 Subject: Fixed typos inside src/ --- src/char/char.c | 50 ++++++------- src/char/int_auction.c | 2 +- src/char/int_guild.c | 10 +-- src/char/int_homun.c | 4 +- src/char/int_party.c | 4 +- src/char/int_quest.c | 2 +- src/char/inter.c | 18 ++--- src/char/pincode.c | 2 +- src/common/HPM.c | 4 +- src/common/HPM.h | 2 +- src/common/atomic.h | 6 +- src/common/conf.h | 2 +- src/common/db.c | 14 ++-- src/common/db.h | 6 +- src/common/ers.c | 8 +- src/common/ers.h | 14 ++-- src/common/grfio.c | 10 +-- src/common/malloc.c | 4 +- src/common/mapindex.c | 2 +- src/common/mmo.h | 4 +- src/common/mutex.h | 16 ++-- src/common/showmsg.c | 6 +- src/common/showmsg.h | 4 +- src/common/socket.c | 14 ++-- src/common/spinlock.h | 2 +- src/common/sql.c | 10 +-- src/common/sql.h | 6 +- src/common/strlib.c | 32 ++++---- src/common/strlib.h | 10 +-- src/common/sysinfo.c | 4 +- src/common/thread.c | 14 ++-- src/common/thread.h | 16 ++-- src/common/timer.c | 6 +- src/common/utils.c | 6 +- src/config/core.h | 4 +- src/config/secure.h | 2 +- src/login/account.h | 2 +- src/login/account_sql.c | 2 +- src/login/login.c | 16 ++-- src/login/login.h | 2 +- src/login/loginlog_sql.c | 2 +- src/map/atcommand.c | 66 ++++++++--------- src/map/battle.c | 66 ++++++++--------- src/map/battle.h | 6 +- src/map/battleground.c | 4 +- src/map/chat.c | 2 +- src/map/chrif.c | 22 +++--- src/map/chrif.h | 2 +- src/map/clif.c | 96 ++++++++++++------------ src/map/clif.h | 2 +- src/map/elemental.c | 4 +- src/map/guild.c | 8 +- src/map/homunculus.c | 4 +- src/map/intif.c | 10 +-- src/map/itemdb.c | 2 +- src/map/map.c | 26 +++---- src/map/map.h | 8 +- src/map/mob.c | 24 +++--- src/map/mob.h | 6 +- src/map/npc.c | 10 +-- src/map/npc_chat.c | 12 +-- src/map/party.c | 4 +- src/map/script.c | 2 +- src/map/skill.c | 188 ++++++++++++++++++++++++----------------------- src/map/status.c | 24 +++--- src/map/status.h | 2 +- src/map/storage.c | 10 +-- src/map/trade.c | 12 +-- src/map/unit.c | 22 +++--- src/map/vending.h | 4 +- 70 files changed, 497 insertions(+), 495 deletions(-) (limited to 'src/map/elemental.c') diff --git a/src/char/char.c b/src/char/char.c index 57031e3ee..fe17fd14f 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -118,7 +118,7 @@ bool char_new = true; int char_new_display = 0; bool name_ignoring_case = false; // Allow or not identical name for characters but with a different case by [Yor] -int char_name_option = 0; // Option to know which letters/symbols are authorised in the name of a character (0: all, 1: only those in char_name_letters, 2: all EXCEPT those in char_name_letters) by [Yor] +int char_name_option = 0; // Option to know which letters/symbols are authorized in the name of a character (0: all, 1: only those in char_name_letters, 2: all EXCEPT those in char_name_letters) by [Yor] char unknown_char_name[NAME_LENGTH] = "Unknown"; // Name to use when the requested name cannot be determined #define TRIM_CHARS "\255\xA0\032\t\x0A\x0D " //The following characters are trimmed regardless because they cause confusion and problems on the servers. [Skotlex] char char_name_letters[1024] = ""; // list of letters/symbols allowed (or not) in a character name. by [Yor] @@ -126,8 +126,8 @@ char char_name_letters[1024] = ""; // list of letters/symbols allowed (or not) i int char_del_level = 0; //From which level u can delete character [Lupus] int char_del_delay = 86400; -int log_char = 1; // loggin char or not [devil] -int log_inter = 1; // loggin inter or not [devil] +int log_char = 1; // logging char or not [devil] +int log_inter = 1; // logging inter or not [devil] int char_aegis_delete = 0; // Verify if char is in guild/party or char and reacts as Aegis does (doesn't allow deletion), see char_delete2_req for more information @@ -1387,7 +1387,7 @@ int mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_everything if( SQL_SUCCESS == SQL->StmtNextRow(stmt) ) strcat(t_msg, " accdata"); - if (save_log) ShowInfo("Loaded char (%d - %s): %s\n", char_id, p->name, t_msg); //ok. all data load successfuly! + if (save_log) ShowInfo("Loaded char (%d - %s): %s\n", char_id, p->name, t_msg); //ok. all data load successfully! SQL->StmtFree(stmt); StrBuf->Destroy(&buf); @@ -1413,7 +1413,7 @@ int mmo_char_sql_init(void) //and send the loginserver the new state.... // Force all users offline in sql when starting char-server - // (useful when servers crashs and don't clean the database) + // (useful when servers crashes and don't clean the database) set_all_offline_sql(); return 0; @@ -1468,7 +1468,7 @@ bool char_slotchange(struct char_session_data *sd, int fd, unsigned short from, } //----------------------------------- -// Function to change chararcter's names +// Function to change character's names //----------------------------------- int rename_char_sql(struct char_session_data *sd, int char_id) { @@ -1540,9 +1540,9 @@ int check_char_name(char * name, char * esc_name) if( strcmpi(name, wisp_server_name) == 0 ) return -1; // nick reserved for internal server messages - // Check Authorised letters/symbols in the name of the character + // Check Authorized letters/symbols in the name of the character if( char_name_option == 1 ) - { // only letters/symbols in char_name_letters are authorised + { // only letters/symbols in char_name_letters are authorized for( i = 0; i < NAME_LENGTH && name[i]; i++ ) if( strchr(char_name_letters, name[i]) == NULL ) return -2; @@ -1576,7 +1576,7 @@ int check_char_name(char * name, char * esc_name) * -1: 'Charname already exists' * -2: 'Char creation denied'/ Unknown error * -3: 'You are underaged' - * -4: 'You are not elegible to open the Character Slot.' + * -4: 'You are not eligible to open the Character Slot.' * -5: 'Symbols in Character Names are forbidden' * char_id: Success **/ @@ -2202,7 +2202,7 @@ void mapif_server_reset(int id); void loginif_reset(void) { int id; - // TODO kick everyone out and reset everything or wait for connect and try to reaquire locks [FlavioJS] + // TODO kick everyone out and reset everything or wait for connect and try to reacquire locks [FlavioJS] for( id = 0; id < ARRAYLENGTH(server); ++id ) mapif_server_reset(id); flush_fifos(); @@ -2286,7 +2286,7 @@ int parse_fromlogin(int fd) { switch( command ) { - // acknowledgement of connect-to-loginserver request + // acknowledgment of connect-to-loginserver request case 0x2711: if (RFIFOREST(fd) < 3) return 0; @@ -2306,7 +2306,7 @@ int parse_fromlogin(int fd) { RFIFOSKIP(fd,3); break; - // acknowledgement of account authentication request + // acknowledgment of account authentication request case 0x2713: if (RFIFOREST(fd) < 33) return 0; @@ -2526,7 +2526,7 @@ int parse_fromlogin(int fd) { unsigned char buf[11]; WBUFW(buf,0) = 0x2b14; WBUFL(buf,2) = RFIFOL(fd,2); - WBUFB(buf,6) = RFIFOB(fd,6); // 0: change of statut, 1: ban + WBUFB(buf,6) = RFIFOB(fd,6); // 0: change of status, 1: ban WBUFL(buf,7) = RFIFOL(fd,7); // status or final date of a banishment mapif_sendall(buf, 11); } @@ -3161,7 +3161,7 @@ int parse_frommap(int fd) memcpy(&char_dat, RFIFOP(fd,13), sizeof(struct mmo_charstatus)); mmo_char_tosql(cid, &char_dat); } else { //This may be valid on char-server reconnection, when re-sending characters that already logged off. - ShowError("parse_from_map (save-char): Received data for non-existant/offline character (%d:%d).\n", aid, cid); + ShowError("parse_from_map (save-char): Received data for non-existing/offline character (%d:%d).\n", aid, cid); set_char_online(id, cid, aid); } @@ -4174,7 +4174,7 @@ int parse_char(int fd) ShowInfo("request connect - account_id:%d/login_id1:%d/login_id2:%d\n", account_id, login_id1, login_id2); if (sd) { - //Received again auth packet for already authentified account?? Discard it. + //Received again auth packet for already authenticated account?? Discard it. //TODO: Perhaps log this as a hack attempt? //TODO: and perhaps send back a reply? break; @@ -4201,7 +4201,7 @@ int parse_char(int fd) break; } - // search authentification + // search authentication node = (struct auth_node*)idb_get(auth_db, account_id); if( node != NULL && node->account_id == account_id && @@ -4232,7 +4232,7 @@ int parse_char(int fd) {// authentication not found (coming from login server) if (login_fd > 0) { // don't send request if no login-server WFIFOHEAD(login_fd,23); - WFIFOW(login_fd,0) = 0x2712; // ask login-server to authentify an account + WFIFOW(login_fd,0) = 0x2712; // ask login-server to authenticate an account WFIFOL(login_fd,2) = sd->account_id; WFIFOL(login_fd,6) = sd->login_id1; WFIFOL(login_fd,10) = sd->login_id2; @@ -4317,7 +4317,7 @@ int parse_char(int fd) break; } - /* set char as online prior to loading its data so 3rd party applications will realise the sql data is not reliable */ + /* set char as online prior to loading its data so 3rd party applications will realize the sql data is not reliable */ set_char_online(-2,char_id,sd->account_id); if( !mmo_char_fromsql(char_id, &char_dat, true) ) { /* failed? set it back offline */ set_char_offline(char_id, sd->account_id); @@ -4459,13 +4459,13 @@ int parse_char(int fd) WFIFOW(fd,0) = 0x6e; /* Others I found [Ind] */ /* 0x02 = Symbols in Character Names are forbidden */ - /* 0x03 = You are not elegible to open the Character Slot. */ + /* 0x03 = You are not eligible to open the Character Slot. */ /* 0x0B = This service is only available for premium users. */ switch (result) { case -1: WFIFOB(fd,2) = 0x00; break; // 'Charname already exists' case -2: WFIFOB(fd,2) = 0xFF; break; // 'Char creation denied' case -3: WFIFOB(fd,2) = 0x01; break; // 'You are underaged' - case -4: WFIFOB(fd,2) = 0x03; break; // 'You are not elegible to open the Character Slot.' + case -4: WFIFOB(fd,2) = 0x03; break; // 'You are not eligible to open the Character Slot.' case -5: WFIFOB(fd,2) = 0x02; break; // 'Symbols in Character Names are forbidden' default: @@ -4641,7 +4641,7 @@ int parse_char(int fd) //Confirm change name. // 0x28f <char_id>.L case 0x28f: - // 0: Sucessfull + // 0: Successful // 1: This character's name has already been changed. You cannot change a character's name more than once. // 2: User information is not correct. // 3: You have failed to change this character's name. @@ -4746,7 +4746,7 @@ int parse_char(int fd) RFIFOSKIP(fd,60); } - return 0; // avoid processing of followup packets here + return 0; // avoid processing of follow-up packets here // checks the entered pin case 0x8b8: @@ -5006,8 +5006,8 @@ static int online_data_cleanup(int tid, int64 tick, int id, intptr_t data) { } //---------------------------------- -// Reading Lan Support configuration -// Rewrote: Anvanced subnet check [LuzZza] +// Reading LAN Support configuration +// Rewrote: Advanced subnet check [LuzZza] //---------------------------------- int char_lan_config_read(const char *lancfgName) { @@ -5479,7 +5479,7 @@ int do_init(int argc, char **argv) { timer->add_func_list(online_data_cleanup, "online_data_cleanup"); timer->add_interval(timer->gettick() + 1000, online_data_cleanup, 0, 0, 600 * 1000); - //Cleaning the tables for NULL entrys @ startup [Sirius] + //Cleaning the tables for NULL entries @ startup [Sirius] //Chardb clean if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `account_id` = '0'", char_db) ) Sql_ShowDebug(sql_handle); diff --git a/src/char/int_auction.c b/src/char/int_auction.c index d246e9851..8cd870647 100644 --- a/src/char/int_auction.c +++ b/src/char/int_auction.c @@ -230,7 +230,7 @@ void inter_auctions_fromsql(void) if( auction->timestamp > now ) endtick = ((int64)(auction->timestamp - now) * 1000) + tick; else - endtick = tick + 10000; // 10 Second's to process ended auctions + endtick = tick + 10000; // 10 seconds to process ended auctions auction->auction_end_timer = timer->add(endtick, auction_end_timer, auction->auction_id, 0); idb_put(auction_db_, auction->auction_id, auction); diff --git a/src/char/int_guild.c b/src/char/int_guild.c index ffbe48e10..a6fcfe48c 100644 --- a/src/char/int_guild.c +++ b/src/char/int_guild.c @@ -117,7 +117,7 @@ int inter_guild_tosql(struct guild *g,int flag) // GS_EXPULSION `guild_expulsion` (`guild_id`,`account_id`,`name`,`mes`) // GS_SKILL `guild_skill` (`guild_id`,`id`,`lv`) - // temporary storage for str convertion. They must be twice the size of the + // temporary storage for str conversion. They must be twice the size of the // original string to ensure no overflows will occur. [Skotlex] char t_info[256]; char esc_name[NAME_LENGTH*2+1]; @@ -836,7 +836,7 @@ int guild_calcinfo(struct guild *g) // Save next exp step g->next_exp = nextexp; - // Set the max number of members, Guild Extention skill - currently adds 6 to max per skill lv. + // Set the max number of members, Guild Extension skill - currently adds 6 to max per skill lv. g->max_member = 16 + guild_checkskill(g, GD_EXTENSION) * 6; if(g->max_member > MAX_GUILD) { @@ -1142,8 +1142,8 @@ int mapif_parse_CreateGuild(int fd,int account_id,char *name,struct guild_member mapif_guild_created(fd,account_id,NULL); return 0; } - // Check Authorised letters/symbols in the name of the character - if (char_name_option == 1) { // only letters/symbols in char_name_letters are authorised + // Check Authorized letters/symbols in the name of the character + if (char_name_option == 1) { // only letters/symbols in char_name_letters are authorized for (i = 0; i < NAME_LENGTH && name[i]; i++) if (strchr(char_name_letters, name[i]) == NULL) { mapif_guild_created(fd,account_id,NULL); @@ -1212,7 +1212,7 @@ int mapif_parse_CreateGuild(int fd,int account_id,char *name,struct guild_member // Return guild info to client int mapif_parse_GuildInfo(int fd,int guild_id) { - struct guild * g = inter_guild_fromsql(guild_id); //We use this because on start-up the info of castle-owned guilds is requied. [Skotlex] + struct guild * g = inter_guild_fromsql(guild_id); //We use this because on start-up the info of castle-owned guilds is required. [Skotlex] if(g) { if (!guild_calcinfo(g)) diff --git a/src/char/int_homun.c b/src/char/int_homun.c index 795a6b927..acde9eb38 100644 --- a/src/char/int_homun.c +++ b/src/char/int_homun.c @@ -248,9 +248,9 @@ bool mapif_homunculus_rename(char *name) { int i; - // Check Authorised letters/symbols in the name of the homun + // Check Authorized letters/symbols in the name of the homun if( char_name_option == 1 ) - {// only letters/symbols in char_name_letters are authorised + {// only letters/symbols in char_name_letters are authorized for( i = 0; i < NAME_LENGTH && name[i]; i++ ) if( strchr(char_name_letters, name[i]) == NULL ) return false; diff --git a/src/char/int_party.c b/src/char/int_party.c index 5dd64a32b..a8722fbe3 100644 --- a/src/char/int_party.c +++ b/src/char/int_party.c @@ -475,8 +475,8 @@ int mapif_parse_CreateParty(int fd, char *name, int item, int item2, struct part mapif_party_created(fd,leader->account_id,leader->char_id,NULL); return 0; } - // Check Authorised letters/symbols in the name of the character - if (char_name_option == 1) { // only letters/symbols in char_name_letters are authorised + // Check Authorized letters/symbols in the name of the character + if (char_name_option == 1) { // only letters/symbols in char_name_letters are authorized for (i = 0; i < NAME_LENGTH && name[i]; i++) if (strchr(char_name_letters, name[i]) == NULL) { if( name[i] == '"' ) { /* client-special-char */ diff --git a/src/char/int_quest.c b/src/char/int_quest.c index 61b43c57d..d4155b0d6 100644 --- a/src/char/int_quest.c +++ b/src/char/int_quest.c @@ -197,7 +197,7 @@ int mapif_parse_quest_save(int fd) { if (j < old_n) { // Update existing quests - // Only states and counts are changable. + // Only states and counts are changeable. ARR_FIND( 0, MAX_QUEST_OBJECTIVES, k, new_qd[i].count[k] != old_qd[j].count[k] ); if (k != MAX_QUEST_OBJECTIVES || new_qd[i].state != old_qd[j].state) success &= mapif_quest_update(char_id, new_qd[i]); diff --git a/src/char/inter.c b/src/char/inter.c index 972407ef3..c2d8de37a 100644 --- a/src/char/inter.c +++ b/src/char/inter.c @@ -589,7 +589,7 @@ void mapif_parse_accinfo(int fd) { inter_msg_to_fd(fd, u_fd, aid, "No matches were found for your criteria, '%s'",query); } else { Sql_ShowDebug(sql_handle); - inter_msg_to_fd(fd, u_fd, aid, "An error occured, bother your admin about it."); + inter_msg_to_fd(fd, u_fd, aid, "An error occurred, bother your admin about it."); } SQL->FreeResult(sql_handle); return; @@ -658,7 +658,7 @@ void mapif_parse_accinfo2(bool success, int map_fd, int u_fd, int u_aid, int acc if (SQL->NumRows(sql_handle) == 0) { inter_msg_to_fd(map_fd, u_fd, u_aid, "This account doesn't have characters."); } else { - inter_msg_to_fd(map_fd, u_fd, u_aid, "An error occured, bother your admin about it."); + inter_msg_to_fd(map_fd, u_fd, u_aid, "An error occurred, bother your admin about it."); Sql_ShowDebug(sql_handle); } } else { @@ -1165,7 +1165,7 @@ int check_ttl_wisdata(void) struct WisData *wd = (struct WisData*)idb_get(wis_db, wis_dellist[i]); ShowWarning("inter: wis data id=%d time out : from %s to %s\n", wd->id, wd->src, wd->dst); // removed. not send information after a timeout. Just no answer for the player - //mapif_wis_end(wd, 1); // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target + //mapif_wis_end(wd, 1); // flag: 0: success to send whisper, 1: target character is not logged in?, 2: ignored by target idb_remove(wis_db, wd->id); } } while(wis_delnum >= WISDELLIST_MAX); @@ -1199,7 +1199,7 @@ int mapif_parse_WisRequest(int fd) if (RFIFOW(fd,2)-52 >= sizeof(wd->msg)) { ShowWarning("inter: Wis message size too long.\n"); return 0; - } else if (RFIFOW(fd,2)-52 <= 0) { // normaly, impossible, but who knows... + } else if (RFIFOW(fd,2)-52 <= 0) { // normally, impossible, but who knows... ShowError("inter: Wis message doesn't exist.\n"); return 0; } @@ -1216,7 +1216,7 @@ int mapif_parse_WisRequest(int fd) unsigned char buf[27]; WBUFW(buf, 0) = 0x3802; memcpy(WBUFP(buf, 2), RFIFOP(fd, 4), NAME_LENGTH); - WBUFB(buf,26) = 1; // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target + WBUFB(buf,26) = 1; // flag: 0: success to send whisper, 1: target character is not logged in?, 2: ignored by target mapif_send(fd, buf, 27); } else @@ -1231,7 +1231,7 @@ int mapif_parse_WisRequest(int fd) uint8 buf[27]; WBUFW(buf, 0) = 0x3802; memcpy(WBUFP(buf, 2), RFIFOP(fd, 4), NAME_LENGTH); - WBUFB(buf,26) = 1; // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target + WBUFB(buf,26) = 1; // flag: 0: success to send whisper, 1: target character is not logged in?, 2: ignored by target mapif_send(fd, buf, 27); } else @@ -1272,7 +1272,7 @@ int mapif_parse_WisReply(int fd) return 0; // This wisp was probably suppress before, because it was timeout of because of target was found on another map-server if ((--wd->count) <= 0 || flag != 1) { - mapif_wis_end(wd, flag); // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target + mapif_wis_end(wd, flag); // flag: 0: success to send whisper, 1: target character is not logged in?, 2: ignored by target idb_remove(wis_db, id); } @@ -1376,8 +1376,8 @@ int mapif_parse_NameChangeRequest(int fd) type = RFIFOB(fd,10); name = (char*)RFIFOP(fd,11); - // Check Authorised letters/symbols in the name - if (char_name_option == 1) { // only letters/symbols in char_name_letters are authorised + // Check Authorized letters/symbols in the name + if (char_name_option == 1) { // only letters/symbols in char_name_letters are authorized for (i = 0; i < NAME_LENGTH && name[i]; i++) if (strchr(char_name_letters, name[i]) == NULL) { mapif_namechange_ack(fd, account_id, char_id, type, 0, name); diff --git a/src/char/pincode.c b/src/char/pincode.c index 59182f12d..18ad0ffc8 100644 --- a/src/char/pincode.c +++ b/src/char/pincode.c @@ -33,7 +33,7 @@ void pincode_handle ( int fd, struct char_session_data* sd ) { } if( strlen(sd->pincode) == 4 ){ - if( *pincode->changetime && time(NULL) > (sd->pincode_change+*pincode->changetime) ){ // User hasnt changed his PIN code for a long time + if( *pincode->changetime && time(NULL) > (sd->pincode_change+*pincode->changetime) ){ // User hasn't changed his PIN code for a long time pincode->sendstate( fd, sd, PINCODE_EXPIRED ); } else { // Ask user for his PIN code pincode->sendstate( fd, sd, PINCODE_ASK ); diff --git a/src/common/HPM.c b/src/common/HPM.c index d33a4c1aa..f39954175 100644 --- a/src/common/HPM.c +++ b/src/common/HPM.c @@ -410,7 +410,7 @@ void hplugins_addToHPData(enum HPluginDataTypes type, unsigned int pluginID, voi *(action.hdatac) += 1; RECREATE(*(action.HPDataSRCPtr),struct HPluginData *,*(action.hdatac)); - /* RECREATE modified the addresss */ + /* RECREATE modified the address */ HPDataSRC = *(action.HPDataSRCPtr); HPDataSRC[*(action.hdatac) - 1] = HPData; } @@ -578,7 +578,7 @@ void* HPM_reallocz(void *p, size_t size, const char *file, int line, const char char* HPM_astrdup(const char *p, const char *file, int line, const char *func) { return iMalloc->astrdup(p,HPM_file2ptr(file),line,func); } -/* todo: add ability for tracking using pID for the upcoming runtime load/unload support. */ +/* TODO: add ability for tracking using pID for the upcoming runtime load/unload support. */ bool HPM_AddHook(enum HPluginHookType type, const char *target, void *hook, unsigned int pID) { if( !HPM->hooking ) { ShowError("HPM:AddHook Fail! '%s' tried to hook to '%s' but HPMHooking is disabled!\n",HPM->pid2name(pID),target); diff --git a/src/common/HPM.h b/src/common/HPM.h index 9c176cfd6..5667f605a 100644 --- a/src/common/HPM.h +++ b/src/common/HPM.h @@ -24,7 +24,7 @@ #define DLL HINSTANCE #else // ! WIN32 #include <dlfcn.h> - #ifdef RTLD_DEEPBIND // Certain linux ditributions require this, but it's not available everywhere + #ifdef RTLD_DEEPBIND // Certain linux distributions require this, but it's not available everywhere #define plugin_open(x) dlopen((x),RTLD_NOW|RTLD_DEEPBIND) #else // ! RTLD_DEEPBIND #define plugin_open(x) dlopen((x),RTLD_NOW) diff --git a/src/common/atomic.h b/src/common/atomic.h index 1349d0887..526811a09 100644 --- a/src/common/atomic.h +++ b/src/common/atomic.h @@ -12,7 +12,7 @@ // - Compiler // - Operating System // -// our Abstraction is fully API-Compatible to Microsofts implementation @ NT5.0+ +// our Abstraction is fully API-Compatible to Microsoft's implementation @ NT5.0+ // #include "../common/cbasetypes.h" @@ -23,7 +23,7 @@ #if _MSC_VER < 1800 #if !defined(_M_X64) -// When compiling for windows 32bit, the 8byte interlocked operations are not provided by microsoft +// When compiling for windows 32bit, the 8byte interlocked operations are not provided by Microsoft // (because they need at least i586 so its not generic enough.. ... ) forceinline int64 InterlockedCompareExchange64(volatile int64 *dest, int64 exch, int64 _cmp){ _asm{ @@ -143,7 +143,7 @@ static forceinline int32 InterlockedExchange(volatile int32 *target, int32 val){ }//end: InterlockedExchange() -#endif //endif compiler decission +#endif //endif compiler decision #endif /* _COMMON_ATOMIC_H_ */ diff --git a/src/common/conf.h b/src/common/conf.h index e5b637e47..7c275bec2 100644 --- a/src/common/conf.h +++ b/src/common/conf.h @@ -10,7 +10,7 @@ #include "../../3rdparty/libconfig/libconfig.h" /** - * The libconfig interface -- specially for plugins, but we enforce it throughought the core to be consistent + * The libconfig interface -- specially for plugins, but we enforce it throughout the core to be consistent **/ struct libconfig_interface { int (*read) (config_t *config, FILE *stream); diff --git a/src/common/db.c b/src/common/db.c index bbeaf0b61..11ac06c93 100644 --- a/src/common/db.c +++ b/src/common/db.c @@ -3,7 +3,7 @@ * For more information, see LICENCE in the main folder * * This file is separated in five sections: - * (1) Private typedefs, enums, structures, defines and gblobal variables + * (1) Private typedefs, enums, structures, defines and global variables * (2) Private functions * (3) Protected functions used internally * (4) Protected functions used in the interface of the database @@ -89,15 +89,15 @@ * DBNColor - Enumeration of colors of the nodes. * * DBNode - Structure of a node in RED-BLACK trees. * * struct db_free - Structure that holds a deleted node to be freed. * - * DBMap_impl - Struture of the database. * + * DBMap_impl - Structure of the database. * * stats - Statistics about the database system. * \*****************************************************************************/ /** * If defined statistics about database nodes, database creating/destruction - * and function usage are keept and displayed when finalizing the database + * and function usage are kept and displayed when finalizing the database * system. - * WARNING: This adds overhead to every database operation (not shure how much). + * WARNING: This adds overhead to every database operation (not sure how much). * @private * @see #DBStats * @see #stats @@ -511,7 +511,7 @@ static void db_rebalance_erase(DBNode node, DBNode *root) } // Remove the node from the tree - if (y != node) { // both childs existed + if (y != node) { // both child existed // put the left of 'node' in the left of 'y' node->left->parent = y; y->left = node->left; @@ -2066,7 +2066,7 @@ static int db_obj_vforeach(DBMap* self, DBApply func, va_list args) * Apply <code>func</code> to every entry in the database. * Returns the sum of values returned by func. * @param self Interface of the database - * @param func Function to be applyed + * @param func Function to be applied * @param ... Extra arguments for func * @return Sum of the values returned by func * @protected @@ -2345,7 +2345,7 @@ static DBOptions db_obj_options(DBMap* self) * db_default_cmp - Get the default comparator for a type of database. * db_default_hash - Get the default hasher for a type of database. * db_default_release - Get the default releaser for a type of database with the specified options. - * db_custom_release - Get a releaser that behaves a certains way. + * db_custom_release - Get a releaser that behaves a certain way. * db_alloc - Allocate a new database. * db_i2key - Manual cast from 'int' to 'DBKey'. * db_ui2key - Manual cast from 'unsigned int' to 'DBKey'. diff --git a/src/common/db.h b/src/common/db.h index f5714ceaf..4f8d6be79 100644 --- a/src/common/db.h +++ b/src/common/db.h @@ -106,7 +106,7 @@ typedef enum DBType { } DBType; /** - * Bitfield of options that define the behaviour of the database. + * Bitfield of options that define the behavior of the database. * See {@link #db_fix_options(DBType,DBOptions)} for restrictions of the * types of databases. * @param DB_OPT_BASE Base options: does not duplicate keys, releases nothing @@ -116,7 +116,7 @@ typedef enum DBType { * @param DB_OPT_RELEASE_KEY Releases the key. * @param DB_OPT_RELEASE_DATA Releases the data whenever an entry is removed * from the database. - * WARNING: for funtions that return the data (like DBMap::remove), + * WARNING: for functions that return the data (like DBMap::remove), * a dangling pointer will be returned. * @param DB_OPT_RELEASE_BOTH Releases both key and data. * @param DB_OPT_ALLOW_NULL_KEY Allow NULL keys in the database. @@ -365,7 +365,7 @@ struct DBIterator }; /** - * Public interface of a database. Only contains funtions. + * Public interface of a database. Only contains functions. * All the functions take the interface as the first argument. * @public * @see #db_alloc(const char*,int,DBType,DBOptions,unsigned short) diff --git a/src/common/ers.c b/src/common/ers.c index 39e05a14c..0842d9e15 100644 --- a/src/common/ers.c +++ b/src/common/ers.c @@ -13,16 +13,16 @@ * If it has reusable entries (freed entry), it uses one. * * So no assumption should be made about the data of the entry. * * Entries should be freed in the manager they where allocated from. * - * Failure to do so can lead to unexpected behaviours. * + * Failure to do so can lead to unexpected behaviors. * * * * <H2>Advantages:</H2> * * - The same manager is used for entries of the same size. * * So entries freed in one instance of the manager can be used by other * * instances of the manager. * * - Much less memory allocation/deallocation - program will be faster. * - * - Avoids memory fragmentaion - program will run better for longer. * + * - Avoids memory fragmentation - program will run better for longer. * * * - * <H2>Disavantages:</H2> * + * <H2>Disadvantages:</H2> * * - Unused entries are almost inevitable - memory being wasted. * * - A manager will only auto-destroy when all of its instances are * * destroyed so memory will usually only be recovered near the end. * @@ -104,7 +104,7 @@ struct ers_instance_t { // Interface to ERS struct eri VTable; - // Name, used for debbuging purpouses + // Name, used for debugging purposes char *Name; // Misc options diff --git a/src/common/ers.h b/src/common/ers.h index 7eceaf87a..f32680339 100644 --- a/src/common/ers.h +++ b/src/common/ers.h @@ -13,16 +13,16 @@ * If it has reusable entries (freed entry), it uses one. * * So no assumption should be made about the data of the entry. * * Entries should be freed in the manager they where allocated from. * - * Failure to do so can lead to unexpected behaviours. * + * Failure to do so can lead to unexpected behaviors. * * * * <H2>Advantages:</H2> * * - The same manager is used for entries of the same size. * * So entries freed in one instance of the manager can be used by other * * instances of the manager. * * - Much less memory allocation/deallocation - program will be faster. * - * - Avoids memory fragmentaion - program will run better for longer. * + * - Avoids memory fragmentation - program will run better for longer. * * * - * <H2>Disavantages:</H2> * + * <H2>Disadvantages:</H2> * * - Unused entries are almost inevitable - memory being wasted. * * - A manager will only auto-destroy when all of its instances are * * destroyed so memory will usually only be recovered near the end. * @@ -49,7 +49,7 @@ * ERS - Entry manager. * * ers_new - Allocate an instance of an entry manager. * * ers_report - Print a report about the current state. * - * ers_final - Clears the remainder of the manangers. * + * ers_final - Clears the remainder of the managers. * \*****************************************************************************/ /** @@ -64,7 +64,7 @@ * By default it aligns to one byte, using the "natural order" of the entries. * This should NEVER be set to zero or less. * If greater than one, some memory can be wasted. This should never be needed - * but is here just in case some aligment issues arise. + * but is here just in case some alignment issues arise. */ #ifndef ERS_ALIGNED # define ERS_ALIGNED 1 @@ -102,7 +102,7 @@ typedef struct eri { /** * Free an entry allocated from this manager. * WARNING: Does not check if the entry was allocated by this manager. - * Freeing such an entry can lead to unexpected behaviour. + * Freeing such an entry can lead to unexpected behavior. * @param self Interface of the entry manager * @param entry Entry to be freed */ @@ -170,7 +170,7 @@ ERS ers_new(uint32 size, char *name, enum ERSOptions options); void ers_report(void); /** - * Clears the remainder of the manangers + * Clears the remainder of the managers **/ void ers_final(void); #endif /* DISABLE_ERS / not DISABLE_ERS */ diff --git a/src/common/grfio.c b/src/common/grfio.c index 1111fb3f3..f592812f6 100644 --- a/src/common/grfio.c +++ b/src/common/grfio.c @@ -418,7 +418,7 @@ void* grfio_reads(const char* fname, int* size) declen = (int)ftell(in); fseek(in,0,SEEK_SET); buf2 = (unsigned char *)aMalloc(declen+1); // +1 for resnametable zero-termination - if(fread(buf2, 1, declen, in) != (size_t)declen) ShowError("An error occured in fread grfio_reads, fname=%s \n",fname); + if(fread(buf2, 1, declen, in) != (size_t)declen) ShowError("An error occurred in fread grfio_reads, fname=%s \n",fname); fclose(in); if( size ) @@ -440,7 +440,7 @@ void* grfio_reads(const char* fname, int* size) int fsize = entry->srclen_aligned; unsigned char *buf = (unsigned char *)aMalloc(fsize); fseek(in, entry->srcpos, 0); - if(fread(buf, 1, fsize, in) != (size_t)fsize) ShowError("An error occured in fread in grfio_reads, grfname=%s\n",grfname); + if(fread(buf, 1, fsize, in) != (size_t)fsize) ShowError("An error occurred in fread in grfio_reads, grfname=%s\n",grfname); fclose(in); buf2 = (unsigned char *)aMalloc(entry->declen+1); // +1 for resnametable zero-termination @@ -583,7 +583,7 @@ static int grfio_entryread(const char* grfname, int gentry) unsigned char *rBuf; uLongf rSize, eSize; - if(fread(eheader,1,8,fp) != 8) ShowError("An error occured in fread while reading eheader buffer\n"); + if(fread(eheader,1,8,fp) != 8) ShowError("An error occurred in fread while reading header buffer\n"); rSize = getlong(eheader); // Read Size eSize = getlong(eheader+4); // Extend Size @@ -595,7 +595,7 @@ static int grfio_entryread(const char* grfname, int gentry) rBuf = (unsigned char *)aMalloc(rSize); // Get a Read Size grf_filelist = (unsigned char *)aMalloc(eSize); // Get a Extend Size - if(fread(rBuf,1,rSize,fp) != rSize) ShowError("An error occured in fread \n"); + if(fread(rBuf,1,rSize,fp) != rSize) ShowError("An error occurred in fread \n"); fclose(fp); decode_zip(grf_filelist, &eSize, rBuf, rSize); // Decode function aFree(rBuf); @@ -827,7 +827,7 @@ void grfio_init(const char* fname) if( grf_num == 0 ) ShowInfo("No GRF loaded, using default data directory\n"); - // Unneccessary area release of filelist + // Unnecessary area release of filelist filelist_compact(); // Resource check diff --git a/src/common/malloc.c b/src/common/malloc.c index 74303fa92..83d1d6656 100644 --- a/src/common/malloc.c +++ b/src/common/malloc.c @@ -776,7 +776,7 @@ static void memmgr_init (void) { #ifdef LOG_MEMMGR sprintf(memmer_logfile, "log/%s.leaks", SERVER_NAME); - ShowStatus("Memory manager initialised: "CL_WHITE"%s"CL_RESET"\n", memmer_logfile); + ShowStatus("Memory manager initialized: "CL_WHITE"%s"CL_RESET"\n", memmer_logfile); memset(hash_unfill, 0, sizeof(hash_unfill)); #endif /* LOG_MEMMGR */ } @@ -784,7 +784,7 @@ static void memmgr_init (void) /*====================================== -* Initialise +* Initialize *-------------------------------------- */ diff --git a/src/common/mapindex.c b/src/common/mapindex.c index 5c69c7063..644f2f619 100644 --- a/src/common/mapindex.c +++ b/src/common/mapindex.c @@ -70,7 +70,7 @@ const char* mapindex_getmapname_ext(const char* string, char* output) { } /// Adds a map to the specified index -/// Returns 1 if successful, 0 oherwise +/// Returns 1 if successful, 0 otherwise int mapindex_addmap(int index, const char* name) { char map_name[MAP_NAME_LENGTH]; diff --git a/src/common/mmo.h b/src/common/mmo.h index 4ac7ee793..6ef5b50f5 100644 --- a/src/common/mmo.h +++ b/src/common/mmo.h @@ -26,7 +26,7 @@ // 20071106 - 2007-11-06aSakexe+ - 0x78, 0x7c, 0x22c // 20080102 - 2008-01-02aSakexe+ - 0x2ec, 0x2ed , 0x2ee // 20081126 - 2008-11-26aSakexe+ - 0x1a2 -// 20090408 - 2009-04-08aSakexe+ - 0x44a (dont use as it overlaps with RE client packets) +// 20090408 - 2009-04-08aSakexe+ - 0x44a (don't use as it overlaps with RE client packets) // 20080827 - 2008-08-27aRagexeRE+ - First RE Client // 20081217 - 2008-12-17aRagexeRE+ - 0x6d (Note: This one still use old Char Info Packet Structure) // 20081218 - 2008-12-17bRagexeRE+ - 0x6d (Note: From this one client use new Char Info Packet Structure) @@ -120,7 +120,7 @@ #define MAX_GUILD_STORAGE 600 #define MAX_PARTY 12 #define MAX_GUILD (16+10*6) // Increased max guild members +6 per 1 extension levels [Lupus] -#define MAX_GUILDPOSITION 20 // Increased max guild positions to accomodate for all members [Valaris] (removed) [PoW] +#define MAX_GUILDPOSITION 20 // Increased max guild positions to accommodate for all members [Valaris] (removed) [PoW] #define MAX_GUILDEXPULSION 32 #define MAX_GUILDALLIANCE 16 #define MAX_GUILDSKILL 15 // Increased max guild skills because of new skills [Sara-chan] diff --git a/src/common/mutex.h b/src/common/mutex.h index f78e31841..ce13a28b7 100644 --- a/src/common/mutex.h +++ b/src/common/mutex.h @@ -57,23 +57,23 @@ racond racond_create(); /** * Destroy a Condition variable * - * @param c - the condition varaible to destroy + * @param c - the condition variable to destroy */ void racond_destroy( racond c ); /** - * Waits Until state is signalled + * Waits Until state is signaled * - * @param c - the condition var to wait for signalled state - * @param m - the mutex used for syncronization + * @param c - the condition var to wait for signaled state + * @param m - the mutex used for synchronization * @param timeout_ticks - timeout in ticks ( -1 = INFINITE ) */ void racond_wait( racond c, ramutex m, sysint timeout_ticks); /** - * Sets the given condition var to signalled state + * Sets the given condition var to signaled state * - * @param c - condition var to set in signalled state. + * @param c - condition var to set in signaled state. * * @note: * Only one waiter gets notified. @@ -81,8 +81,8 @@ void racond_wait( racond c, ramutex m, sysint timeout_ticks); void racond_signal( racond c ); /** - * Sets notifys all waiting threads thats signalled. - * @param c - condition var to set in signalled state + * Sets notifies all waiting threads thats signaled. + * @param c - condition var to set in signaled state * * @note: * All Waiters getting notified. diff --git a/src/common/showmsg.c b/src/common/showmsg.c index 2a8e2d5f8..ece10c1a8 100644 --- a/src/common/showmsg.c +++ b/src/common/showmsg.c @@ -88,7 +88,7 @@ int console_msg_log = 0;//[Ind] msg error logging // XXX adapted from eApp (comments are left untouched) [flaviojs] /////////////////////////////////////////////////////////////////////////////// -// ansi compatible printf with control sequence parser for windows +// ANSI compatible printf with control sequence parser for windows // fast hack, handle with care, not everything implemented // // \033[#;...;#m - Set Graphics Rendition (SGR) @@ -147,7 +147,7 @@ int console_msg_log = 0;//[Ind] msg error logging // // \033[u - Restore cursor position (RCP) // Restores the cursor position saved with the (SCP) sequence \033[s. -// (addition, restore to 0,0 if nothinh was saved before) +// (addition, restore to 0,0 if nothing was saved before) // // \033[#J - Erase Display (ED) @@ -282,7 +282,7 @@ int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr) } //case '2': // not existing //case '3': // blinking (not implemented) - //case '4': // unterline (not implemented) + //case '4': // underline (not implemented) //case '6': // not existing //case '8': // concealed (not implemented) //case '9': // not existing diff --git a/src/common/showmsg.h b/src/common/showmsg.h index 5b32f39ae..8008acf5a 100644 --- a/src/common/showmsg.h +++ b/src/common/showmsg.h @@ -72,9 +72,9 @@ #define CL_XXBL "\033[0;44m" // default on blue #define CL_PASS "\033[0;32;42m" // green on green -#define CL_SPACE " " // space aquivalent of the print messages +#define CL_SPACE " " // space equivalent of the print messages -extern int stdout_with_ansisequence; //If the color ansi sequences are to be used. [flaviojs] +extern int stdout_with_ansisequence; //If the color ANSI sequences are to be used. [flaviojs] extern int msg_silent; //Specifies how silent the console is. [Skotlex] extern int console_msg_log; //Specifies what error messages to log. [Ind] extern char timestamp_format[20]; //For displaying Timestamps [Skotlex] diff --git a/src/common/socket.c b/src/common/socket.c index ac6be68fe..58c2d5bf9 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -360,7 +360,7 @@ int recv_to_fifo(int fd) len = sRecv(fd, (char *) session[fd]->rdata + session[fd]->rdata_size, (int)RFIFOSPACE(fd), 0); if( len == SOCKET_ERROR ) - {//An exception has occured + {//An exception has occurred if( sErrno != S_EWOULDBLOCK ) { //ShowDebug("recv_to_fifo: %s, closing connection #%d\n", error_msg(), fd); set_eof(fd); @@ -400,7 +400,7 @@ int send_from_fifo(int fd) len = sSend(fd, (const char *) session[fd]->wdata, (int)session[fd]->wdata_size, MSG_NOSIGNAL); if( len == SOCKET_ERROR ) - {//An exception has occured + {//An exception has occurred if( sErrno != S_EWOULDBLOCK ) { //ShowDebug("send_from_fifo: %s, ending connection #%d\n", error_msg(), fd); #ifdef SHOW_SERVER_STATS @@ -845,7 +845,7 @@ int do_sockets(int next) session[i]->func_send(i); if(session[i]->flag.eof) //func_send can't free a session, this is safe. - { //Finally, even if there is no data to parse, connections signalled eof should be closed, so we call parse_func [Skotlex] + { //Finally, even if there is no data to parse, connections signaled eof should be closed, so we call parse_func [Skotlex] session[i]->func_parse(i); //This should close the session immediately. } } @@ -1234,7 +1234,7 @@ void socket_final(void) if(session[i]) sockt->close(i); - // session[0] ̃_~[f[^폜 + // session[0] aFree(session[0]->rdata); aFree(session[0]->wdata); aFree(session[0]); @@ -1364,7 +1364,7 @@ void socket_init(void) } } #elif defined(HAVE_SETRLIMIT) && !defined(CYGWIN) - // NOTE: getrlimit and setrlimit have bogus behaviour in cygwin. + // NOTE: getrlimit and setrlimit have bogus behavior in cygwin. // "Number of fds is virtually unlimited in cygwin" (sys/param.h) {// set socket limit to FD_SETSIZE struct rlimit rlp; @@ -1405,7 +1405,7 @@ void socket_init(void) socket_config_read(SOCKET_CONF_FILENAME); - // initialise last send-receive tick + // initialize last send-receive tick sockt->last_tick = time(NULL); // session[0] is now currently used for disconnected sessions of the map server, and as such, @@ -1458,7 +1458,7 @@ uint32 str2ip(const char* ip_str) } // Reorders bytes from network to little endian (Windows). -// Neccessary for sending port numbers to the RO client until Gravity notices that they forgot ntohs() calls. +// Necessary for sending port numbers to the RO client until Gravity notices that they forgot ntohs() calls. uint16 ntows(uint16 netshort) { return ((netshort & 0xFF) << 8) | ((netshort & 0xFF00) >> 8); diff --git a/src/common/spinlock.h b/src/common/spinlock.h index 1c0825181..fe0da6669 100644 --- a/src/common/spinlock.h +++ b/src/common/spinlock.h @@ -4,7 +4,7 @@ // // CAS based Spinlock Implementation // -// CamelCase names are choosen to be consistent with microsofts winapi +// CamelCase names are chosen to be consistent with Microsoft's WinAPI // which implements CriticalSection by this naming... // // Author: Florian Wilkemeyer <fw@f-ws.de> diff --git a/src/common/sql.c b/src/common/sql.c index ffc4d63ef..a562478ea 100644 --- a/src/common/sql.c +++ b/src/common/sql.c @@ -38,7 +38,7 @@ struct Sql { // Column length receiver. -// Takes care of the possible size missmatch between uint32 and unsigned long. +// Takes care of the possible size mismatch between uint32 and unsigned long. struct s_column_length { uint32* out_length; unsigned long length; @@ -569,7 +569,7 @@ static void SqlStmt_P_ShowDebugTruncatedColumn(SqlStmt* self, size_t i) Sql_P_ShowDebugMysqlFieldInfo("data - ", field->type, field->flags&UNSIGNED_FLAG, self->column_lengths[i].length, ""); column = &self->columns[i]; if( column->buffer_type == MYSQL_TYPE_STRING ) - Sql_P_ShowDebugMysqlFieldInfo("buffer - ", column->buffer_type, column->is_unsigned, column->buffer_length, "+1(nul-terminator)"); + Sql_P_ShowDebugMysqlFieldInfo("buffer - ", column->buffer_type, column->is_unsigned, column->buffer_length, "+1(null-terminator)"); else Sql_P_ShowDebugMysqlFieldInfo("buffer - ", column->buffer_type, column->is_unsigned, column->buffer_length, ""); mysql_free_result(meta); @@ -765,10 +765,10 @@ int SqlStmt_BindColumn(SqlStmt* self, size_t idx, enum SqlDataType buffer_type, { if( buffer_len < 1 ) { - ShowDebug("SqlStmt_BindColumn: buffer_len(%d) is too small, no room for the nul-terminator\n", buffer_len); + ShowDebug("SqlStmt_BindColumn: buffer_len(%d) is too small, no room for the null-terminator\n", buffer_len); return SQL_ERROR; } - --buffer_len;// nul-terminator + --buffer_len;// null-terminator } if( !self->bind_columns ) {// initialize the bindings @@ -891,7 +891,7 @@ int SqlStmt_NextRow(SqlStmt* self) if( self->column_lengths[i].out_length ) *self->column_lengths[i].out_length = (uint32)length; if( column->buffer_type == MYSQL_TYPE_STRING ) - {// clear unused part of the string/enum buffer (and nul-terminate) + {// clear unused part of the string/enum buffer (and null-terminate) memset((char*)column->buffer + length, 0, column->buffer_length - length + 1); } else if( column->buffer_type == MYSQL_TYPE_BLOB && length < column->buffer_length ) diff --git a/src/common/sql.h b/src/common/sql.h index 64d8307fc..3bdb76c74 100644 --- a/src/common/sql.h +++ b/src/common/sql.h @@ -166,7 +166,7 @@ struct sql_interface { /// It uses the connection of the parent Sql handle. /// Queries in Sql and SqlStmt are independent and don't affect each other. /// - /// @return SqlStmt handle or NULL if an error occured + /// @return SqlStmt handle or NULL if an error occurred struct SqlStmt* (*StmtMalloc)(Sql* sql); @@ -198,7 +198,7 @@ struct sql_interface { /// Returns the number of parameters in the prepared statement. /// - /// @return Number or paramenters + /// @return Number or parameters size_t (*StmtNumParams)(SqlStmt* self); @@ -237,7 +237,7 @@ struct sql_interface { /// Binds the result of a column to a buffer. /// The buffer will be filled with data when the next row is fetched. /// For string/enum buffer types there has to be enough space for the data - /// and the nul-terminator (an extra byte). + /// and the null-terminator (an extra byte). /// /// @return SQL_SUCCESS or SQL_ERROR int (*StmtBindColumn)(SqlStmt* self, size_t idx, SqlDataType buffer_type, void* buffer, size_t buffer_len, uint32* out_length, int8* out_is_null); diff --git a/src/common/strlib.c b/src/common/strlib.c index 10e893c3a..2ce8fd347 100644 --- a/src/common/strlib.c +++ b/src/common/strlib.c @@ -147,15 +147,15 @@ char* trim(char* str) if( start == end ) *str = '\0';// empty string else - {// move string with nul terminator + {// move string with null-terminator str[end] = '\0'; memmove(str,str+start,end-start+1); } return str; } -// Converts one or more consecutive occurences of the delimiters into a single space -// and removes such occurences from the beginning and end of string +// Converts one or more consecutive occurrences of the delimiters into a single space +// and removes such occurrences from the beginning and end of string // NOTE: make sure the string is not const!! char* normalize_name(char* str,const char* delims) { @@ -358,18 +358,18 @@ int config_switch(const char* str) { return (int)strtol(str, NULL, 0); } -/// strncpy that always nul-terminates the string +/// strncpy that always null-terminates the string char* safestrncpy(char* dst, const char* src, size_t n) { if( n > 0 ) { char* d = dst; const char* s = src; - d[--n] = '\0';/* nul-terminate string */ + d[--n] = '\0';/* null-terminate string */ for( ; n > 0; --n ) { if( (*d++ = *s++) == '\0' ) - {/* nul-pad remaining bytes */ + {/* null-pad remaining bytes */ while( --n > 0 ) *d++ = '\0'; break; @@ -385,12 +385,12 @@ size_t safestrnlen(const char* string, size_t maxlen) return ( string != NULL ) ? strnlen(string, maxlen) : 0; } -/// Works like snprintf, but always nul-terminates the buffer. -/// Returns the size of the string (without nul-terminator) +/// Works like snprintf, but always null-terminates the buffer. +/// Returns the size of the string (without null-terminator) /// or -1 if the buffer is too small. /// /// @param buf Target buffer -/// @param sz Size of the buffer (including nul-terminator) +/// @param sz Size of the buffer (including null-terminator) /// @param fmt Format string /// @param ... Format arguments /// @return The size of the string or -1 if the buffer is too small @@ -404,7 +404,7 @@ int safesnprintf(char* buf, size_t sz, const char* fmt, ...) va_end(ap); if( ret < 0 || (size_t)ret >= sz ) {// overflow - buf[sz-1] = '\0';// always nul-terminate + buf[sz-1] = '\0';// always null-terminate return -1; } return ret; @@ -631,8 +631,8 @@ int sv_parse_next(struct s_svstate* svstate) /// @param delim Field delimiter /// @param out_pos Array of resulting positions /// @param npos Size of the pos array -/// @param opt Options that determine the parsing behaviour -/// @return Number of fields found in the string or -1 if an error occured +/// @param opt Options that determine the parsing behavior +/// @return Number of fields found in the string or -1 if an error occurred int sv_parse(const char* str, int len, int startoff, char delim, int* out_pos, int npos, enum e_svopt opt) { struct s_svstate svstate; int count; @@ -666,11 +666,11 @@ int sv_parse(const char* str, int len, int startoff, char delim, int* out_pos, i /// WARNING: this function modifies the input string /// Starts splitting at startoff and fills the out_fields array. /// out_fields[0] is the start of the next line. -/// Other entries are the start of fields (nul-teminated). +/// Other entries are the start of fields (null-terminated). /// Returns the number of fields found or -1 if an error occurs. /// /// out_fields can be NULL. -/// Fields that don't fit in out_fields are not nul-terminated. +/// Fields that don't fit in out_fields are not null-terminated. /// Extra entries in out_fields are filled with the end of the last field (empty string). /// /// @param str String to parse @@ -679,8 +679,8 @@ int sv_parse(const char* str, int len, int startoff, char delim, int* out_pos, i /// @param delim Field delimiter /// @param out_fields Array of resulting fields /// @param nfields Size of the field array -/// @param opt Options that determine the parsing behaviour -/// @return Number of fields found in the string or -1 if an error occured +/// @param opt Options that determine the parsing behavior +/// @return Number of fields found in the string or -1 if an error occurred int sv_split(char* str, int len, int startoff, char delim, char** out_fields, int nfields, enum e_svopt opt) { int pos[1024]; int i; diff --git a/src/common/strlib.h b/src/common/strlib.h index f93d8ad67..f39f27789 100644 --- a/src/common/strlib.h +++ b/src/common/strlib.h @@ -16,7 +16,7 @@ char *_strtok_r(char* s1, const char* s2, char** lasts); #endif -/// Bitfield determining the behaviour of sv_parse and sv_split. +/// Bitfield determining the behavior of sv_parse and sv_split. typedef enum e_svopt { // default: no escapes and no line terminator SV_NOESCAPE_NOTERMINATE = 0, @@ -73,14 +73,14 @@ struct strlib_interface { int (*e_mail_check) (char* email); int (*config_switch) (const char* str); - /// strncpy that always nul-terminates the string + /// strncpy that always null-terminates the string char *(*safestrncpy) (char* dst, const char* src, size_t n); /// doesn't crash on null pointer size_t (*safestrnlen) (const char* string, size_t maxlen); - /// Works like snprintf, but always nul-terminates the buffer. - /// Returns the size of the string (without nul-terminator) + /// Works like snprintf, but always null-terminates the buffer. + /// Returns the size of the string (without null-terminator) /// or -1 if the buffer is too small. int (*safesnprintf) (char* buf, size_t sz, const char* fmt, ...); @@ -131,7 +131,7 @@ struct sv_interface { /// WARNING: this function modifies the input string /// Starts splitting at startoff and fills the out_fields array. /// out_fields[0] is the start of the next line. - /// Other entries are the start of fields (nul-teminated). + /// Other entries are the start of fields (null-terminated). /// Returns the number of fields found or -1 if an error occurs. int (*split) (char* str, int len, int startoff, char delim, char** out_fields, int nfields, enum e_svopt opt); diff --git a/src/common/sysinfo.c b/src/common/sysinfo.c index 3fdfadb41..40ef6cfc0 100644 --- a/src/common/sysinfo.c +++ b/src/common/sysinfo.c @@ -226,7 +226,7 @@ bool sysinfo_svn_get_revision(char **out) { // - since it's a cache column, the data might not even exist if ((fp = fopen(".svn"PATHSEP_STR"wc.db", "rb")) != NULL || (fp = fopen(".."PATHSEP_STR".svn"PATHSEP_STR"wc.db", "rb")) != NULL) { -#ifndef SVNNODEPATH //not sure how to handle branches, so i'll leave this overridable define until a better solution comes up +#ifndef SVNNODEPATH //not sure how to handle branches, so I'll leave this overridable define until a better solution comes up #define SVNNODEPATH trunk #endif // SVNNODEPATH @@ -709,7 +709,7 @@ void sysinfo_vcsrevision_src_retrieve(void) { #endif // WIN32 /** - * Retrieevs the VCS type name. + * Retrieves the VCS type name. * * Once retrieved, the value is stored in sysinfo->p->vcstype_name. */ diff --git a/src/common/thread.c b/src/common/thread.c index 91360537f..4be37d576 100644 --- a/src/common/thread.c +++ b/src/common/thread.c @@ -68,7 +68,7 @@ void rathread_init(){ l_threads[i].myID = i; } - // now lets init thread id 0, which represnts the main thread + // now lets init thread id 0, which represents the main thread #ifdef HAS_TLS g_rathread_ID = 0; #endif @@ -83,7 +83,7 @@ void rathread_final(){ register unsigned int i; // Unterminated Threads Left? - // Should'nt happen .. + // Shouldn't happen .. // Kill 'em all! // for(i = 1; i < RA_THREADS_MAX; i++){ @@ -121,9 +121,9 @@ static void *_raThreadMainRedirector( void *p ){ #ifndef WIN32 // When using posix threads - // the threads inherits the Signal mask from the thread which's spawned + // the threads inherits the Signal mask from the thread which spawned // this thread - // so we've to block everything we dont care about. + // so we've to block everything we don't care about. sigemptyset(&set); sigaddset(&set, SIGINT); sigaddset(&set, SIGTERM); @@ -222,10 +222,10 @@ void rathread_destroy ( rAthread handle ){ #else if( pthread_cancel( handle->hThread ) == 0){ - // We have to join it, otherwise pthread wont re-cycle its internal ressources assoc. with this thread. + // We have to join it, otherwise pthread wont re-cycle its internal resources assoc. with this thread. pthread_join( handle->hThread, NULL ); - // Tell our manager to release ressources ;) + // Tell our manager to release resources ;) rat_thread_terminated(handle); } #endif @@ -265,7 +265,7 @@ int rathread_get_tid(){ #ifdef HAS_TLS return g_rathread_ID; #else - // todo + // TODO #ifdef WIN32 return (int)GetCurrentThreadId(); #else diff --git a/src/common/thread.h b/src/common/thread.h index 7ad326509..992e3e6c8 100644 --- a/src/common/thread.h +++ b/src/common/thread.h @@ -20,7 +20,7 @@ typedef enum RATHREAD_PRIO { * Creates a new Thread * * @param entyPoint - entryProc, - * @param param - general purpose parameter, would be given as parameter to the thread's entrypoint. + * @param param - general purpose parameter, would be given as parameter to the thread's entry point. * * @return not NULL if success */ @@ -31,7 +31,7 @@ rAthread rathread_create( rAthreadProc entryPoint, void *param ); * Creates a new Thread (with more creation options) * * @param entyPoint - entryProc, - * @param param - general purpose parameter, would be given as parameter to the thread's entrypoint + * @param param - general purpose parameter, would be given as parameter to the thread's entry point * @param szStack - stack Size in bytes * @param prio - Priority of the Thread @ OS Scheduler.. * @@ -41,9 +41,9 @@ rAthread rathread_createEx( rAthreadProc entryPoint, void *param, size_t szSta /** - * Destroys the given Thread immediatly + * Destroys the given Thread immediately * - * @note The Handle gets invalid after call! dont use it afterwards. + * @note The Handle gets invalid after call! don't use it afterwards. * * @param handle - thread to destroy. */ @@ -53,7 +53,7 @@ void rathread_destroy ( rAthread handle ); /** * Returns the thread handle of the thread calling this function * - * @note this wont work @ programms main thread + * @note this wont work @ programs main thread * @note the underlying implementation might not perform very well, cache the value received! * * @return not NULL if success @@ -62,10 +62,10 @@ rAthread rathread_self( ); /** - * Returns own thrad id (TID) + * Returns own thread id (TID) * * @note this is an unique identifier for the calling thread, and - * depends on platfrom / compiler, and may not be the systems Thread ID! + * depends on platform/ compiler, and may not be the systems Thread ID! * * @return -1 when fails, otherwise >= 0 */ @@ -93,7 +93,7 @@ void rathread_prio_set( rAthread handle, RATHREAD_PRIO prio ); /** - * Gets the current Prio of the given trhead + * Gets the current Prio of the given thread * * @param handle - the thread to get the prio for. */ diff --git a/src/common/timer.c b/src/common/timer.c index 5240ec202..ab0471d51 100644 --- a/src/common/timer.c +++ b/src/common/timer.c @@ -170,14 +170,14 @@ static int64 sys_tick(void) { } if (pGetTickCount64) return (int64)pGetTickCount64(); - // 32-bit fallback. Note: This will wrap around every ~49 days since system startup!!! + // 32-bit fall back. Note: This will wrap around every ~49 days since system startup!!! return (int64)GetTickCount(); #elif defined(ENABLE_RDTSC) // RDTSC: Returns the number of CPU cycles since reset. Unreliable if // the CPU frequency is variable. return (int64)((_rdtsc() - RDTSC_BEGINTICK) / RDTSC_CLOCK); #elif defined(HAVE_MONOTONIC_CLOCK) - // Monotinic clock: Implementation-defined. + // Monotonic clock: Implementation-defined. // Clock that cannot be set and represents monotonic time since some // unspecified starting point. This clock is not affected by // discontinuous jumps in the system time (e.g., if the system @@ -188,7 +188,7 @@ static int64 sys_tick(void) { // int64 cast to avoid overflows on platforms where time_t is 32 bit return (int64)tval.tv_sec * 1000 + tval.tv_nsec / 1000000; #else - // Fallback, regular clock: Number of milliseconds since epoch. + // Fall back, regular clock: Number of milliseconds since epoch. // The time returned by gettimeofday() is affected by discontinuous // jumps in the system time (e.g., if the system administrator // manually changes the system time). If you need a monotonically diff --git a/src/common/utils.c b/src/common/utils.c index 80954f848..4e6cb49c2 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -200,7 +200,7 @@ void findfile(const char *p, const char *pat, void (func)(const char*)) sprintf(tmppath,"%s%c%s",path, PATHSEP, entry->d_name); - // check if the pattern matchs. + // check if the pattern matches. if (entry->d_name && strstr(entry->d_name, pattern)) { func( tmppath ); } @@ -211,7 +211,7 @@ void findfile(const char *p, const char *pat, void (func)(const char*)) } // is this a directory? if (S_ISDIR(dir_stat.st_mode)) { - // decent recursivly + // decent recursively findfile(tmppath, pat, func); } }//end while @@ -326,7 +326,7 @@ unsigned int get_percentage(const unsigned int A, const unsigned int B) if( B == 0 ) { - ShowError("get_percentage(): divison by zero! (A=%u,B=%u)\n", A, B); + ShowError("get_percentage(): division by zero! (A=%u,B=%u)\n", A, B); return ~0U; } diff --git a/src/config/core.h b/src/config/core.h index 157d94b2f..24e9de710 100644 --- a/src/config/core.h +++ b/src/config/core.h @@ -27,7 +27,7 @@ /// CONSOLE_INPUT allows you to type commands into the server's console, /// Disabling it saves one thread. #define CONSOLE_INPUT -/// Maximum number of caracters 'CONSOLE_INPUT' will support per line. +/// Maximum number of characters 'CONSOLE_INPUT' will support per line. #define MAX_CONSOLE_INPUT 150 /// Uncomment to disable Hercules' anonymous stat report @@ -43,7 +43,7 @@ /// By default, all range checks in Aegis are of Square shapes, so a weapon range /// - of 10 allows you to attack from anywhere within a 21x21 area. /// Enabling this changes such checks to circular checks, which is more realistic, -/// - but is not the official behaviour. +/// - but is not the official behavior. //#define CIRCULAR_AREA //This is the distance at which @autoloot works, diff --git a/src/config/secure.h b/src/config/secure.h index e5e3662d1..1a89e36cf 100644 --- a/src/config/secure.h +++ b/src/config/secure.h @@ -49,7 +49,7 @@ /** * Uncomment to disable - * while enabled, movement of invisible (cloaking, hide, etca [not chase walk]) units is not informed to nearby foes, + * while enabled, movement of invisible (cloaking, hide, etc [not chase walk]) units is not informed to nearby foes, * rendering any client-side cheat, that would otherwise make these units visible, to not function. * - "Why is this a setting?" because theres a cost, while enabled if a hidden character uses a skill with cast time, * - for example "cloaking -> walk a bit -> soul break another player" the character display will be momentarily abrupted diff --git a/src/login/account.h b/src/login/account.h index 329ae31c8..a14595519 100644 --- a/src/login/account.h +++ b/src/login/account.h @@ -25,7 +25,7 @@ struct mmo_account char email[40]; // e-mail (by default: a@a.com) int group_id; // player group id uint8 char_slots; // this accounts maximum character slots (maximum is limited to MAX_CHARS define in char server) - unsigned int state; // packet 0x006a value + 1 (0: compte OK) + unsigned int state; // packet 0x006a value + 1 (0: complete OK) time_t unban_time; // (timestamp): ban time limit of the account (0 = no ban) time_t expiration_time; // (timestamp): validity limit of the account (0 = unlimited) unsigned int logincount; // number of successful auth attempts diff --git a/src/login/account_sql.c b/src/login/account_sql.c index 2e4ed7ab9..51e499369 100644 --- a/src/login/account_sql.c +++ b/src/login/account_sql.c @@ -454,7 +454,7 @@ static bool account_db_sql_load_str(AccountDB* self, struct mmo_account* acc, co } if( SQL->NumRows(sql_handle) > 1 ) - {// serious problem - duplicit account + {// serious problem - duplicate account ShowError("account_db_sql_load_str: multiple accounts found when retrieving data for account '%s'!\n", userid); SQL->FreeResult(sql_handle); return false; diff --git a/src/login/login.c b/src/login/login.c index 43883c6ce..c3f2f6000 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -287,7 +287,7 @@ int lan_subnetcheck(uint32 ip) } //---------------------------------- -// Reading Lan Support configuration +// Reading LAN Support configuration //---------------------------------- int login_lan_config_read(const char *lancfgName) { @@ -724,13 +724,13 @@ int parse_fromchar(int fd) RFIFOSKIP(fd,6); if( !accounts->load_num(accounts, &acc, account_id) ) - ShowNotice("Char-server '%s': Error of UnBan request (account: %d not found, ip: %s).\n", server[id].name, account_id, ip); + ShowNotice("Char-server '%s': Error of Unban request (account: %d not found, ip: %s).\n", server[id].name, account_id, ip); else if( acc.unban_time == 0 ) - ShowNotice("Char-server '%s': Error of UnBan request (account: %d, no change for unban date, ip: %s).\n", server[id].name, account_id, ip); + ShowNotice("Char-server '%s': Error of Unban request (account: %d, no change for unban date, ip: %s).\n", server[id].name, account_id, ip); else { - ShowNotice("Char-server '%s': UnBan request (account: %d, ip: %s).\n", server[id].name, account_id, ip); + ShowNotice("Char-server '%s': Unban request (account: %d, ip: %s).\n", server[id].name, account_id, ip); acc.unban_time = 0; accounts->save(accounts, &acc); } @@ -912,7 +912,7 @@ int mmo_auth_new(const char* userid, const char* pass, const char sex, const cha // check if the account doesn't exist already if( accounts->load_str(accounts, &acc, userid) ) { - ShowNotice("Attempt of creation of an already existant account (account: %s_%c, pass: %s, received pass: %s)\n", userid, sex, acc.pass, pass); + ShowNotice("Attempt of creation of an already existing account (account: %s_%c, pass: %s, received pass: %s)\n", userid, sex, acc.pass, pass); return 1; // 1 = Incorrect Password } @@ -1104,7 +1104,7 @@ void login_auth_ok(struct login_session_data* sd) WFIFOSET(fd,3); return; } else if( login_config.min_group_id_to_connect >= 0 && login_config.group_id_to_connect == -1 && sd->group_id < login_config.min_group_id_to_connect ) { - ShowStatus("Connection refused: the minium group id required for connection is %d (account: %s, group: %d).\n", login_config.min_group_id_to_connect, sd->userid, sd->group_id); + ShowStatus("Connection refused: the minimum group id required for connection is %d (account: %s, group: %d).\n", login_config.min_group_id_to_connect, sd->userid, sd->group_id); WFIFOHEAD(fd,3); WFIFOW(fd,0) = 0x81; WFIFOB(fd,2) = 1; // 01 = Server closed @@ -1309,7 +1309,7 @@ int parse_login(int fd) // Perform ip-ban check if( login_config.ipban && ipban_check(ipl) ) { - ShowStatus("Connection refused: IP isn't authorised (deny/allow, ip: %s).\n", ip); + ShowStatus("Connection refused: IP isn't authorized (deny/allow, ip: %s).\n", ip); login_log(ipl, "unknown", -3, "ip banned"); WFIFOHEAD(fd,23); WFIFOW(fd,0) = 0x6a; @@ -1772,7 +1772,7 @@ int do_init(int argc, char** argv) { int i; - // intialize engine (to accept config settings) + // initialize engine (to accept config settings) account_engine[0].db = account_engine[0].constructor(); // read login-server configuration diff --git a/src/login/login.h b/src/login/login.h index e77b96a0e..447301ea4 100644 --- a/src/login/login.h +++ b/src/login/login.h @@ -72,7 +72,7 @@ struct Login_Config { unsigned int ip_sync_interval; // interval (in minutes) to execute a DNS/IP update (for dynamic IPs) bool log_login; // whether to log login server actions or not char date_format[32]; // date format used in messages - bool new_account_flag,new_acc_length_limit; // autoregistration via _M/_F ? / if yes minimum length is 4? + bool new_account_flag,new_acc_length_limit; // auto-registration via _M/_F ? / if yes minimum length is 4? int start_limited_time; // new account expiration time (-1: unlimited) bool use_md5_passwds; // work with password hashes instead of plaintext passwords? int group_id_to_connect; // required group id to connect diff --git a/src/login/loginlog_sql.c b/src/login/loginlog_sql.c index 2cbc02c93..2c0b1cc03 100644 --- a/src/login/loginlog_sql.c +++ b/src/login/loginlog_sql.c @@ -35,7 +35,7 @@ static Sql* sql_handle = NULL; static bool enabled = false; -// Returns the number of failed login attemps by the ip in the last minutes. +// Returns the number of failed login attempts by the ip in the last minutes. unsigned long loginlog_failedattempts(uint32 ip, unsigned int minutes) { unsigned long failures = 0; diff --git a/src/map/atcommand.c b/src/map/atcommand.c index a7e4cef39..2acea5872 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -947,7 +947,7 @@ ACMD(jobchange) { } } - // High Jobs, Babys and Third + // High Jobs, Babies and Third for( i = JOB_NOVICE_HIGH; i < JOB_MAX && !found; i++ ){ if (strncmpi(message, pc->job_name(i), 16) == 0) { job = i; @@ -1329,7 +1329,7 @@ ACMD(baselevelup) clif->message(fd, msg_txt(47)); // Base level can't go any higher. return false; } // End Addition - if ((unsigned int)level > pc->maxbaselv(sd) || (unsigned int)level > pc->maxbaselv(sd) - sd->status.base_level) // fix positiv overflow + if ((unsigned int)level > pc->maxbaselv(sd) || (unsigned int)level > pc->maxbaselv(sd) - sd->status.base_level) // fix positive overflow level = pc->maxbaselv(sd) - sd->status.base_level; for (i = 0; i < level; i++) status_point += pc->gets_status_point(sd->status.base_level + i); @@ -1389,7 +1389,7 @@ ACMD(joblevelup) clif->message(fd, msg_txt(23)); // Job level can't go any higher. return false; } - if ((unsigned int)level > pc->maxjoblv(sd) || (unsigned int)level > pc->maxjoblv(sd) - sd->status.job_level) // fix positiv overflow + if ((unsigned int)level > pc->maxjoblv(sd) || (unsigned int)level > pc->maxjoblv(sd) - sd->status.job_level) // fix positive overflow level = pc->maxjoblv(sd) - sd->status.job_level; sd->status.job_level += (unsigned int)level; sd->status.skill_point += level; @@ -1401,11 +1401,11 @@ ACMD(joblevelup) return false; } level *=-1; - if ((unsigned int)level >= sd->status.job_level) // fix negativ overflow + if ((unsigned int)level >= sd->status.job_level) // fix negative overflow level = sd->status.job_level-1; sd->status.job_level -= (unsigned int)level; if (sd->status.skill_point < level) - pc->resetskill(sd,0); //Reset skills since we need to substract more points. + pc->resetskill(sd,0); //Reset skills since we need to subtract more points. if (sd->status.skill_point < level) sd->status.skill_point = 0; else @@ -1631,7 +1631,7 @@ ACMD(model) pc->changelook(sd, LOOK_HAIR, hair_style); pc->changelook(sd, LOOK_HAIR_COLOR, hair_color); pc->changelook(sd, LOOK_CLOTHES_COLOR, cloth_color); - clif->message(fd, msg_txt(36)); // Appearence changed. + clif->message(fd, msg_txt(36)); // Appearance changed. } else { clif->message(fd, msg_txt(37)); // An invalid number was specified. return false; @@ -1657,7 +1657,7 @@ ACMD(dye) if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) { pc->changelook(sd, LOOK_CLOTHES_COLOR, cloth_color); - clif->message(fd, msg_txt(36)); // Appearence changed. + clif->message(fd, msg_txt(36)); // Appearance changed. } else { clif->message(fd, msg_txt(37)); // An invalid number was specified. return false; @@ -1683,7 +1683,7 @@ ACMD(hair_style) if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) { pc->changelook(sd, LOOK_HAIR, hair_style); - clif->message(fd, msg_txt(36)); // Appearence changed. + clif->message(fd, msg_txt(36)); // Appearance changed. } else { clif->message(fd, msg_txt(37)); // An invalid number was specified. return false; @@ -1709,7 +1709,7 @@ ACMD(hair_color) if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) { pc->changelook(sd, LOOK_HAIR_COLOR, hair_color); - clif->message(fd, msg_txt(36)); // Appearence changed. + clif->message(fd, msg_txt(36)); // Appearance changed. } else { clif->message(fd, msg_txt(37)); // An invalid number was specified. return false; @@ -1896,7 +1896,7 @@ ACMD(monster) return false; } - if ((mob_id = mob->db_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number) + if ((mob_id = mob->db_searchname(monster)) == 0) // check name first (to avoid possible name beginning by a number) mob_id = mob->db_checkid(atoi(monster)); if (mob_id == 0) { @@ -2711,7 +2711,7 @@ ACMD(char_block) * mn: minute * s: second * <example> @ban +1m-2mn1s-6y test_player - * this example adds 1 month and 1 second, and substracts 2 minutes and 6 years at the same time. + * this example adds 1 month and 1 second, and subtracts 2 minutes and 6 years at the same time. *------------------------------------------*/ ACMD(char_ban) { @@ -2879,12 +2879,12 @@ ACMD(doom) { status_kill(&pl_sd->bl); clif->specialeffect(&pl_sd->bl,450,AREA); - clif->message(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgement. + clif->message(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgment. } } mapit->free(iter); - clif->message(fd, msg_txt(62)); // Judgement was made. + clif->message(fd, msg_txt(62)); // Judgment was made. return true; } @@ -2904,12 +2904,12 @@ ACMD(doommap) { status_kill(&pl_sd->bl); clif->specialeffect(&pl_sd->bl,450,AREA); - clif->message(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgement. + clif->message(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgment. } } mapit->free(iter); - clif->message(fd, msg_txt(62)); // Judgement was made. + clif->message(fd, msg_txt(62)); // Judgment was made. return true; } @@ -2984,7 +2984,7 @@ ACMD(kick) if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) ) { - clif->message(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player. + clif->message(fd, msg_txt(81)); // Your GM level don't authorize you to do this action on this player. return false; } @@ -3287,7 +3287,7 @@ ACMD(mapexit) { } /*========================================== - * idsearch <part_of_name>: revrited by [Yor] + * idsearch <part_of_name>: rewrite by [Yor] *------------------------------------------*/ ACMD(idsearch) { @@ -3333,7 +3333,7 @@ ACMD(recallall) memset(atcmd_output, '\0', sizeof(atcmd_output)); if (sd->bl.m >= 0 && map->list[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) { - clif->message(fd, msg_txt(1032)); // You are not authorized to warp somenone to your current map. + clif->message(fd, msg_txt(1032)); // You are not authorized to warp someone to your current map. return false; } @@ -3385,7 +3385,7 @@ ACMD(guildrecall) } if (sd->bl.m >= 0 && map->list[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) { - clif->message(fd, msg_txt(1032)); // You are not authorized to warp somenone to your current map. + clif->message(fd, msg_txt(1032)); // You are not authorized to warp someone to your current map. return false; } @@ -3442,7 +3442,7 @@ ACMD(partyrecall) } if (sd->bl.m >= 0 && map->list[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) { - clif->message(fd, msg_txt(1032)); // You are not authorized to warp somenone to your current map. + clif->message(fd, msg_txt(1032)); // You are not authorized to warp someone to your current map. return false; } @@ -4089,7 +4089,7 @@ ACMD(nuke) { 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! } else { - clif->message(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player. + clif->message(fd, msg_txt(81)); // Your GM level don't authorize you to do this action on this player. return false; } } else { @@ -4286,7 +4286,7 @@ ACMD(servertime) { const struct TimerData * timer_data2 = timer->get(pc->day_timer_tid); if (map->night_flag == 0) { - sprintf(temp, msg_txt(235), // Game time: The game is actualy in daylight for %s. + sprintf(temp, msg_txt(235), // Game time: The game is actually in daylight for %s. txt_time((unsigned int)(DIFF_TICK(timer_data->tick,timer->gettick())/1000))); clif->message(fd, temp); if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0) @@ -4297,7 +4297,7 @@ ACMD(servertime) { txt_time((unsigned int)(DIFF_TICK(timer_data2->tick,timer_data->tick)/1000))); clif->message(fd, temp); } else { - sprintf(temp, msg_txt(233), // Game time: The game is actualy in night for %s. + sprintf(temp, msg_txt(233), // Game time: The game is actually in night for %s. txt_time((unsigned int)(DIFF_TICK(timer_data2->tick,timer->gettick()) / 1000))); clif->message(fd, temp); if (DIFF_TICK(timer_data2->tick,timer_data->tick) > 0) @@ -4371,7 +4371,7 @@ ACMD(jail) { if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) { // you can jail only lower or same GM - clif->message(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player. + clif->message(fd, msg_txt(81)); // Your GM level don't authorize you to do this action on this player. return false; } @@ -4422,7 +4422,7 @@ ACMD(unjail) { if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) { // you can jail only lower or same GM - clif->message(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player. + clif->message(fd, msg_txt(81)); // Your GM level don't authorize you to do this action on this player. return false; } @@ -4499,7 +4499,7 @@ ACMD(jailfor) { } if (pc_get_group_level(pl_sd) > pc_get_group_level(sd)) { - clif->message(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player. + clif->message(fd, msg_txt(81)); // Your GM level don't authorize you to do this action on this player. return false; } @@ -5245,7 +5245,7 @@ ACMD(useskill) { if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) ) { - clif->message(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player. + clif->message(fd, msg_txt(81)); // Your GM level don't authorized you to do this action on this player. return false; } @@ -5460,7 +5460,7 @@ ACMD(autotrade) { status->change_start(NULL,&sd->bl, SC_AUTOTRADE, 10000, 0, 0, 0, 0, ((timeout > 0) ? min(timeout,battle_config.at_timeout) : battle_config.at_timeout) * 60000, 0); } - /* currently standalones are not supporting buyingstores, so we rely on the previous method */ + /* currently standalone is not supporting buyingstores, so we rely on the previous method */ if( sd->state.buyingstore ) { clif->authfail_fd(fd, 15); return true; @@ -6385,7 +6385,7 @@ ACMD(changesex) int i; pc->resetskill(sd,4); - // to avoid any problem with equipment and invalid sex, equipment is unequiped. + // to avoid any problem with equipment and invalid sex, equipment is unequipped. for( i=0; i<EQI_MAX; i++ ) if( sd->equip_index[i] >= 0 ) pc->unequipitem(sd, sd->equip_index[i], 3); chrif->changesex(sd); @@ -6411,7 +6411,7 @@ ACMD(mute) { if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) ) { - clif->message(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player. + clif->message(fd, msg_txt(81)); // Your GM level don't authorize you to do this action on this player. return false; } @@ -7700,7 +7700,7 @@ ACMD(accept) { } if(sd->duel_invite <= 0) { - // "Duel: @accept without invititation." + // "Duel: @accept without invitation." clif->message(fd, msg_txt(360)); return false; } @@ -7720,7 +7720,7 @@ ACMD(accept) { ACMD(reject) { if(sd->duel_invite <= 0) { - // "Duel: @reject without invititation." + // "Duel: @reject without invitation." clif->message(fd, msg_txt(362)); return false; } @@ -8632,7 +8632,7 @@ ACMD(join) { if( hChSys.local && strcmpi(name + 1, hChSys.local_name) == 0 ) { if( !map->list[sd->bl.m].channel ) { clif->chsys_mjoin(sd); - if( map->list[sd->bl.m].channel ) /* mjoin might have refused, map has chatting capabilities disabled */ + if( map->list[sd->bl.m].channel ) /* join might have refused, map has chatting capabilities disabled */ return true; } else channel = map->list[sd->bl.m].channel; diff --git a/src/map/battle.c b/src/map/battle.c index 57302166e..810bebae9 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -58,7 +58,7 @@ int battle_getcurrentskill(struct block_list *bl) { //Returns the current/last s } /*========================================== - * Get random targetting enemy + * Get random targeting enemy *------------------------------------------*/ int battle_gettargeted_sub(struct block_list *bl, va_list ap) { struct block_list **bl_list; @@ -102,7 +102,7 @@ struct block_list* battle_gettargeted(struct block_list *target) { } -//Returns the id of the current targetted character of the passed bl. [Skotlex] +//Returns the id of the current targeted character of the passed bl. [Skotlex] int battle_gettarget(struct block_list* bl) { switch (bl->type) { @@ -262,7 +262,7 @@ int battle_delay_damage(int64 tick, int amotion, struct block_list *src, struct if ( !battle_config.delay_battle_damage || amotion <= 1 ) { map->freeblock_lock(); - status_fix_damage(src, target, damage, ddelay); // We have to seperate here between reflect damage and others [icescope] + status_fix_damage(src, target, damage, ddelay); // We have to separate here between reflect damage and others [icescope] 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 ) @@ -358,7 +358,7 @@ 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 + if( tsc && tsc->count ) { //since an atk can only have one type let's optimize this a bit switch(atk_elem){ case ELE_FIRE: if( tsc->data[SC_SPIDERWEB]) { @@ -463,7 +463,7 @@ int64 battle_calc_weapon_damage(struct block_list *src, struct block_list *bl, u damage = battle->calc_elefix(src, bl, skill_id, skill_lv, damage + eatk, nk, n_ele, s_ele, s_ele_, type == EQI_HAND_L, flag); /** - * In RE Shield Bommerang takes weapon element only for damage calculation, + * In RE Shield Boomerang takes weapon element only for damage calculation, * - resist calculation is always against neutral **/ if ( skill_id == CR_SHIELDBOOMERANG ) @@ -482,7 +482,7 @@ int64 battle_calc_weapon_damage(struct block_list *src, struct block_list *bl, u } /*========================================== * Calculates the standard damage of a normal attack assuming it hits, - * it calculates nothing extra fancy, is needed for magnum break's WATK_ELEMENT bonus. [Skotlex] + * it calculates nothing extra fancy, is needed for magnum breaks WATK_ELEMENT bonus. [Skotlex] *------------------------------------------ * Pass damage2 as NULL to not calc it. * Flag values: @@ -567,7 +567,7 @@ int64 battle_calc_base_damage2(struct status_data *st, struct weapon_atk *wa, st else damage += st->batk; - //rodatazone says that Overrefine bonuses are part of baseatk + //rodatazone says that Overrefined bonuses are part of baseatk //Here we also apply the weapon_atk_rate bonus so it is correctly applied on left/right hands. if(sd) { if (type == EQI_HAND_L) { @@ -604,7 +604,7 @@ int64 battle_addmastery(struct map_session_data *sd,struct block_list *target,in nullpo_ret(sd); if((skill_lv = pc->checkskill(sd,AL_DEMONBANE)) > 0 && - target->type == BL_MOB && //This bonus doesnt work against players. + target->type == BL_MOB && //This bonus doesn't work against players. (battle->check_undead(st->race,st->def_ele) || st->race==RC_DEMON) ) damage += (int)(skill_lv*(3+sd->status.base_level/20.0)); //damage += (skill_lv * 3); @@ -676,7 +676,7 @@ int64 battle_addmastery(struct map_session_data *sd,struct block_list *target,in case W_FIST: if((skill_lv = pc->checkskill(sd,TK_RUN)) > 0) damage += (skill_lv * 10); - // No break, fallthrough to Knuckles + // No break, fall through to Knuckles case W_KNUCKLE: if((skill_lv = pc->checkskill(sd,MO_IRONHAND)) > 0) damage += (skill_lv * 3); @@ -1272,9 +1272,9 @@ int64 battle_calc_defense(int attack_type, struct block_list *src, struct block_ #else vit_def = def2; #endif - if((battle->check_undead(sstatus->race,sstatus->def_ele) || sstatus->race==RC_DEMON) && //This bonus already doesnt work vs players + if((battle->check_undead(sstatus->race,sstatus->def_ele) || sstatus->race==RC_DEMON) && //This bonus already doesn't work vs players src->type == BL_MOB && (i=pc->checkskill(tsd,AL_DP)) > 0) - vit_def += i*(int)(3 +(tsd->status.base_level+1)*0.04); // submitted by orn + vit_def += i*(int)(3 +(tsd->status.base_level+1)*0.04); // [orn] if( src->type == BL_MOB && (i=pc->checkskill(tsd,RA_RANGERMAIN))>0 && (sstatus->race == RC_BRUTE || sstatus->race == RC_FISH || sstatus->race == RC_PLANT) ) vit_def += i*5; @@ -1296,7 +1296,7 @@ int64 battle_calc_defense(int attack_type, struct block_list *src, struct block_ #ifdef RENEWAL /** * RE DEF Reduction - * Pierce defence gains 1 atk per def/2 + * Pierce defense gains 1 atk per def/2 **/ if( def1 < -399 ) // it stops at -399 @@ -1384,7 +1384,7 @@ int battle_calc_chorusbonus(struct map_session_data *sd) { if (members < 3) return 0; // Bonus remains 0 unless 3 or more Minstrel's/Wanderer's are in the party. if (members > 7) - return 5; // Maximum effect possiable from 7 or more Minstrel's/Wanderer's + return 5; // Maximum effect possible from 7 or more Minstrel's/Wanderer's return members - 2; // Effect bonus from additional Minstrel's/Wanderer's if not above the max possible } @@ -2005,7 +2005,7 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block skillratio += 50 * skill_lv; break; case GS_BULLSEYE: - //Only works well against brute/demihumans non bosses. + //Only works well against brute/demi-humans non bosses. if((tst->race == RC_BRUTE || tst->race == RC_DEMIHUMAN) && !(tst->mode&MD_BOSS)) skillratio += 400; @@ -2117,7 +2117,7 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block RE_LVL_DMOD(150); break; /** - * GC Guilotine Cross + * GC Guillotine Cross **/ case GC_CROSSIMPACT: skillratio += 900 + 100 * skill_lv; @@ -2401,7 +2401,7 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block { int chorusbonus = battle->calc_chorusbonus(sd); skillratio += 300 + 200 * skill_lv; - //Chorus bonus dont count the first 2 Minstrel's/Wanderer's and only increases when their's 3 or more. [Rytech] + //Chorus bonus don't count the first 2 Minstrel's/Wanderer's and only increases when their's 3 or more. [Rytech] if (chorusbonus >= 1 && chorusbonus <= 5) skillratio += 100<<(chorusbonus-1); // 1->100; 2->200; 3->400; 4->800; 5->1600 RE_LVL_DMOD(100); @@ -2454,7 +2454,7 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block if( sc && sc->data[SC_BLAST_OPTION] ) skillratio += (sd ? sd->status.job_level * 5 : 0); break; - // Physical Elemantal Spirits Attack Skills + // Physical Elemental Spirits Attack Skills case EL_CIRCLE_OF_FIRE: case EL_FIRE_BOMB_ATK: case EL_STONE_RAIN: @@ -2557,8 +2557,8 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block return skillratio; } /*========================================== - * Check dammage trough status. - * ATK may be MISS, BLOCKED FAIL, reduc, increase, end status... + * Check damage trough status. + * ATK may be MISS, BLOCKED FAIL, reduce, 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) { @@ -2715,7 +2715,7 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam clif->skill_nodamage(bl, bl, RK_MILLENNIUMSHIELD, 1, 1); sce->val3 -= (int)cap_value(damage,INT_MIN,INT_MAX); // absorb damage d->dmg_lv = ATK_BLOCK; - sc_start(src,bl,SC_STUN,15,0,skill->get_time2(RK_MILLENNIUMSHIELD,sce->val1)); // There is a chance to be stuned when one shield is broken. + sc_start(src,bl,SC_STUN,15,0,skill->get_time2(RK_MILLENNIUMSHIELD,sce->val1)); // There is a chance to be stunned when one shield is broken. if( sce->val3 <= 0 ) { // Shield Down sce->val2--; if( sce->val2 > 0 ) { @@ -3029,7 +3029,7 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam short rate = 100; struct status_data *tstatus = status->get_status_data(bl); if ( !(flag&BF_SKILL) && (flag&BF_WEAPON) && damage > 0 && rnd()%100 < tsc->data[SC_POISONINGWEAPON]->val3 ) { - if ( tsc->data[SC_POISONINGWEAPON]->val1 == 9 ) // Oblivion Curse gives a 2nd success chance after the 1st one passes which is reduceable. [Rytech] + if ( tsc->data[SC_POISONINGWEAPON]->val1 == 9 ) // Oblivion Curse gives a 2nd success chance after the 1st one passes which is reducible. [Rytech] rate = 100 - tstatus->int_ * 4 / 5; sc_start(src,bl,tsc->data[SC_POISONINGWEAPON]->val2,rate,tsc->data[SC_POISONINGWEAPON]->val1,skill->get_time2(GC_POISONINGWEAPON,1) - (tstatus->vit + tstatus->luk) / 2 * 1000); } @@ -3046,7 +3046,7 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam /* no data claims these settings affect anything other than players */ if( damage && sd && bl->type == BL_PC ) { switch( skill_id ) { - //case PA_PRESSURE: /* pressure also belongs to this list but it doesn't reach this area -- so dont worry about it */ + //case PA_PRESSURE: /* pressure also belongs to this list but it doesn't reach this area -- so don't worry about it */ case HW_GRAVITATION: case NJ_ZENYNAGE: case KO_MUCHANAGE: @@ -3254,7 +3254,7 @@ int battle_blewcount_bonus(struct map_session_data *sd, uint16 skill_id) { int i; if (!sd->skillblown[0].id) return 0; - //Apply the bonus blewcount. [Skotlex] + //Apply the bonus blow count. [Skotlex] for (i = 0; i < ARRAYLENGTH(sd->skillblown) && sd->skillblown[i].id; i++) { if (sd->skillblown[i].id == skill_id) return sd->skillblown[i].val; @@ -3335,7 +3335,7 @@ struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list ad.flag |= battle->range_type(src, target, skill_id, skill_lv); flag.infdef=(tstatus->mode&MD_PLANT?1:0); if( !flag.infdef && target->type == BL_SKILL && ((TBL_SKILL*)target)->group->unit_id == UNT_REVERBERATION ) - flag.infdef = 1; // Reberberation takes 1 damage + flag.infdef = 1; // Reverberation takes 1 damage switch(skill_id) { case MG_FIREWALL: @@ -3600,7 +3600,7 @@ struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list } /*========================================== - * Calculate Misc dammage for skill_id + * Calculate Misc damage for skill_id *------------------------------------------*/ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list *target,uint16 skill_id,uint16 skill_lv,int mflag) { int temp; @@ -3908,7 +3908,7 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list * { if (battle_config.agi_penalty_type == 1) flee = (flee * (100 - (attacker_count - (battle_config.agi_penalty_count - 1))*battle_config.agi_penalty_num))/100; - else //asume type 2: absolute reduction + else // assume type 2: absolute reduction flee -= (attacker_count - (battle_config.agi_penalty_count - 1))*battle_config.agi_penalty_num; if(flee < 1) flee = 1; } @@ -4046,7 +4046,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list unsigned lh : 1; //Attack considers left hand (wd.damage2) unsigned weapon : 1; //It's a weapon attack (consider VVS, and all that) #ifdef RENEWAL - unsigned tdef : 1; //Total defence reduction + unsigned tdef : 1; //Total defense reduction #endif } flag; @@ -4065,7 +4065,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list #endif ?1:0); if( !flag.infdef && target->type == BL_SKILL && ((TBL_SKILL*)target)->group->unit_id == UNT_REVERBERATION ) - flag.infdef = 1; // Reberberation takes 1 damage + flag.infdef = 1; // Reverberation takes 1 damage //Initial Values wd.type=0; //Normal attack @@ -5694,7 +5694,7 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t /** * We need to calculate the DMG before the hp reduction, because it can kill the source. - * For futher information: bugreport:4950 + * For further information: bugreport:4950 **/ ret_val = (damage_lv)skill->attack(BF_WEAPON,src,src,target,PA_SACRIFICE,skill_lv,tick,0); @@ -6058,7 +6058,7 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f if(((((TBL_MOB*)target)->special_state.ai == 2 || //Marine Spheres (((TBL_MOB*)target)->special_state.ai == 3 && battle_config.summon_flora&1)) && //Floras s_bl->type == BL_PC && src->type != BL_MOB) || (((TBL_MOB*)target)->special_state.ai == 4 && t_bl->id != s_bl->id)) //Zanzoe - { //Targettable by players + { //Targetable by players state |= BCT_ENEMY; strip_enemy = 0; } @@ -6137,7 +6137,7 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f sd = BL_CAST(BL_PC, t_bl); if( sd->state.monster_ignore && flag&BCT_ENEMY ) - return 0; // Global inminuty only to Attacks + return 0; // Global immunity only to Attacks if( sd->status.karma && s_bl->type == BL_PC && ((TBL_PC*)s_bl)->status.karma ) state |= BCT_ENEMY; // Characters with bad karma may fight amongst them if( sd->state.killable ) { @@ -6231,7 +6231,7 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f break; } default: - //Need some sort of default behaviour for unhandled types. + //Need some sort of default behavior for unhandled types. if (t_bl->type != s_bl->type) state |= BCT_ENEMY; break; @@ -6351,7 +6351,7 @@ bool battle_check_range(struct block_list *src, struct block_list *bl, int range return true; // No need for path checking. if( d > AREA_SIZE ) - return false; // Avoid targetting objects beyond your range of sight. + return false; // Avoid targeting objects beyond your range of sight. return path->search_long(NULL,src->m,src->x,src->y,bl->x,bl->y,CELL_CHKWALL); } diff --git a/src/map/battle.h b/src/map/battle.h index 433dca95f..fc916597d 100644 --- a/src/map/battle.h +++ b/src/map/battle.h @@ -79,7 +79,7 @@ enum e_battle_check_target { //New definitions [Skotlex] * Structures **/ -// dammage structure +// damage structure struct Damage { int64 damage,damage2; //right, left dmg int type,div_; //chk clif_damage for type @TODO add an enum ? ; nb of hit @@ -489,7 +489,7 @@ enum e_battle_config_idletime { BCIDLE_ATCOMMAND = 0x200, }; -// Dammage delayed info +// Damage delayed info struct delay_damage { int src_id; int target_id; @@ -571,7 +571,7 @@ struct battle_interface { int (*check_target) (struct block_list *src, struct block_list *target,int flag); /* is src and bl within range? */ bool (*check_range) (struct block_list *src,struct block_list *bl,int range); - /* consume amo for this skill and lv */ + /* consume ammo for this skill and lv */ void (*consume_ammo) (struct map_session_data* sd, int skill_id, int lv); int (*get_targeted_sub) (struct block_list *bl, va_list ap); int (*get_enemy_sub) (struct block_list *bl, va_list ap); diff --git a/src/map/battleground.c b/src/map/battleground.c index 4558f32c3..f7131513d 100644 --- a/src/map/battleground.c +++ b/src/map/battleground.c @@ -541,7 +541,7 @@ void bg_match_over(struct bg_arena *arena, bool canceled) { bg->queue_pc_cleanup(sd); } if( canceled ) - clif->colormes(sd->fd,COLOR_RED,"BG Match Cancelled: not enough players"); + clif->colormes(sd->fd,COLOR_RED,"BG Match Canceled: not enough players"); else { pc_setglobalreg(sd, script->add_str(arena->delay_var), (unsigned int)time(NULL)); } @@ -579,7 +579,7 @@ void bg_begin(struct bg_arena *arena) { if( bg->afk_timer_id == INVALID_TIMER && bg->mafksec > 0 ) bg->afk_timer_id = timer->add(timer->gettick()+10000,bg->afk_timer,0,0); - /* TODO: make this a arena-independant var? or just .@? */ + /* TODO: make this a arena-independent var? or just .@? */ mapreg->setreg(script->add_str("$@bg_queue_id"),arena->queue_id); mapreg->setregstr(script->add_str("$@bg_delay_var$"),bg->gdelay_var); diff --git a/src/map/chat.c b/src/map/chat.c index 40a9d2348..cd7b5f811 100644 --- a/src/map/chat.c +++ b/src/map/chat.c @@ -32,7 +32,7 @@ struct chat_data* chat_createchat(struct block_list* bl, const char* title, cons 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] */ + /* Given the overhead and the numerous instances (npc allocated or otherwise) wouldn't it be beneficial to have it use ERS? [Ind] */ cd = (struct chat_data *) aMalloc(sizeof(struct chat_data)); safestrncpy(cd->title, title, sizeof(cd->title)); diff --git a/src/map/chrif.c b/src/map/chrif.c index a69cca573..54cc139f4 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -55,7 +55,7 @@ struct chrif_interface chrif_s; //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...' -//2b06: Incoming, chrif_changemapserverack -> 'awnser of 2b05, ok/fail, data: dunno^^' +//2b06: Incoming, chrif_changemapserverack -> 'answer 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 -> '...' //2b09: Incoming, map_addchariddb -> 'Adds a name to the nick db' @@ -79,7 +79,7 @@ struct chrif_interface chrif_s; //2b1b: Incoming, chrif_recvfamelist -> 'Receive fame ranking lists' //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] +//2b1e: Incoming, chrif_update_ip -> 'Request forwarded from char-server for interserver IP sync.' [Lance] //2b1f: Incoming, chrif_disconnectplayer -> 'disconnects a player (aid X) with the message XY ... 0x81 ..' [Sirius] //2b20: Incoming, chrif_removemap -> 'remove maps of a server (sample: its going offline)' [Sirius] //2b21: Incoming, chrif_save_ack. Returned after a character has been "final saved" on the char-server. [Skotlex] @@ -393,7 +393,7 @@ bool chrif_changemapserver(struct map_session_data* sd, uint32 ip, uint16 port) return true; } -/// map-server change request acknowledgement (positive or negative) +/// map-server change request acknowledgment (positive or negative) /// R 2b06 <account_id>.L <login_id1>.L <login_id2>.L <char_id>.L <map_index>.W <x>.W <y>.W <ip>.L <port>.W bool chrif_changemapserverack(int account_id, int login_id1, int login_id2, int char_id, short map_index, short x, short y, uint32 ip, uint16 port) { struct auth_node *node; @@ -853,9 +853,9 @@ void chrif_changedsex(int fd) { // Path to activate this response: // Map(start) (0x2b0e) -> Char(0x2727) -> Login // Login(0x2723) [ALL] -> Char (0x2b0d)[ALL] -> Map (HERE) - // Char will usually be "logged in" despite being forced to log-out in the begining + // Char will usually be "logged in" despite being forced to log-out in the beginning // of this process, but there's no need to perform map-server specific response - // as everything should've been changed through char-server [Panikon] + // as everything should been changed through char-server [Panikon] } /*========================================== * Request Char Server to Divorce Players @@ -944,14 +944,14 @@ void chrif_idbanned(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 + if (RFIFOB(fd,6) == 0) { // 0: change of status 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)); // Message IDs (for search convenience): 412, 413, 414, 415, 416, 417, 418, 419, 420 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." + clif->message(sd->fd, msg_txt(420)); //"Your account has not more authorized." } else if (RFIFOB(fd,6) == 1) { // 1: ban time_t timestamp; char tmpstr[2048]; @@ -1206,7 +1206,7 @@ bool chrif_ragsrvinfo(int base_rate, int job_rate, int drop_rate) { /*========================================= - * Tell char-server charcter disconnected [Wizputer] + * Tell char-server character disconnected [Wizputer] *-----------------------------------------*/ bool chrif_char_offline_nsd(int account_id, int char_id) { chrif_check(false); @@ -1247,7 +1247,7 @@ bool chrif_char_reset_offline(void) { } /*========================================= - * Tell char-server charcter is online [Wizputer] + * Tell char-server character is online [Wizputer] *-----------------------------------------*/ bool chrif_char_online(struct map_session_data *sd) { chrif_check(false); @@ -1533,7 +1533,7 @@ void chrif_send_report(char* buf, int len) { } /** - * Sends a single scdata for saving into char server, meant to ensure integrity of durationless conditions + * Sends a single scdata for saving into char server, meant to ensure integrity of duration-less conditions **/ void chrif_save_scdata_single(int account_id, int char_id, short type, struct status_change_entry *sce) { @@ -1555,7 +1555,7 @@ void chrif_save_scdata_single(int account_id, int char_id, short type, struct st } /** - * Sends a single scdata deletion request into char server, meant to ensure integrity of durationless conditions + * Sends a single scdata deletion request into char server, meant to ensure integrity of duration-less conditions **/ void chrif_del_scdata_single(int account_id, int char_id, short type) { diff --git a/src/map/chrif.h b/src/map/chrif.h index 661ba8f84..51ab0e9b9 100644 --- a/src/map/chrif.h +++ b/src/map/chrif.h @@ -53,7 +53,7 @@ struct chrif_interface { 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. + struct eri *auth_db_ers; //For re-utilizing player login structures. DBMap* auth_db; // int id -> struct auth_node* /* */ int packet_len_table[CHRIF_PACKET_LEN_TABLE_SIZE]; diff --git a/src/map/clif.c b/src/map/clif.c index d1ae2eb07..d8714dda0 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -2588,7 +2588,7 @@ void clif_cartlist(struct map_session_data *sd) { /// Removes cart (ZC_CARTOFF). /// 012b -/// Client behaviour: +/// Client behavior: /// Closes the cart storage and removes all it's items from memory. /// The Num & Weight values of the cart are left untouched and the cart is NOT removed. void clif_clearcart(int fd) @@ -5047,7 +5047,7 @@ void clif_skillcastcancel(struct block_list* bl) /// 4 = "no party" MsgStringTable[163] /// 5 = "no shout" MsgStringTable[164] /// 6 = "no PKing" MsgStringTable[165] -/// 7 = "no alligning" MsgStringTable[383] +/// 7 = "no aligning" MsgStringTable[383] /// ? = ignored /// cause: /// 0 = "not enough skill level" MsgStringTable[214] (AL_WARP) @@ -5425,7 +5425,7 @@ void clif_skill_estimation(struct map_session_data *sd,struct block_list *dst) { } -/// Presents a textual list of producable items (ZC_MAKABLEITEMLIST). +/// Presents a textual list of producible items (ZC_MAKABLEITEMLIST). /// 018d <packet len>.W { <name id>.W { <material id>.W }*3 }* /// material id: /// unused by the client @@ -5467,7 +5467,7 @@ void clif_skill_produce_mix_list(struct map_session_data *sd, int skill_id , int } -/// Present a list of producable items (ZC_MAKINGITEM_LIST). +/// Present a list of producible items (ZC_MAKINGITEM_LIST). /// 025a <packet len>.W <mk type>.W { <name id>.W }* /// mk type: /// 1 = cooking @@ -5603,7 +5603,7 @@ void clif_displaymessage(const int fd, const char* mes) { if ( ( len = strnlen(mes, 255) ) > 0 ) { // don't send a void message (it's not displaying on the client chat). @help can send void line. WFIFOHEAD(fd, 5 + len); WFIFOW(fd,0) = 0x8e; - WFIFOW(fd,2) = 5 + len; // 4 + len + NULL teminate + WFIFOW(fd,2) = 5 + len; // 4 + len + NULL terminate safestrncpy((char *)WFIFOP(fd,4), mes, len + 1); WFIFOSET(fd, 5 + len); } @@ -5632,7 +5632,7 @@ void clif_displaymessage2(const int fd, const char* mes) { } else { WFIFOHEAD(fd, 5 + len); WFIFOW(fd,0) = 0x8e; - WFIFOW(fd,2) = 5 + len; // 4 + len + NULL teminate + WFIFOW(fd,2) = 5 + len; // 4 + len + NULL terminate safestrncpy((char *)WFIFOP(fd,4), line, len + 1); WFIFOSET(fd, 5 + len); } @@ -5669,7 +5669,7 @@ void clif_displaymessage_sprintf(const int fd, const char* mes, ...) { /* */ WFIFOW(fd,0) = 0x8e; - WFIFOW(fd,2) = 5 + len; // 4 + len + NULL teminate + WFIFOW(fd,2) = 5 + len; // 4 + len + NULL terminate WFIFOSET(fd, 5 + len); } @@ -5924,8 +5924,8 @@ void clif_wis_message(int fd, const char* nick, const char* mes, size_t mes_len) /// Inform the player about the result of his whisper action (ZC_ACK_WHISPER). /// 0098 <result>.B /// result: -/// 0 = success to send wisper -/// 1 = target character is not loged in +/// 0 = success to send whisper +/// 1 = target character is not logged in /// 2 = ignored by target /// 3 = everyone ignored by target void clif_wis_end(int fd, int flag) { @@ -6191,7 +6191,7 @@ void clif_item_refine_list(struct map_session_data *sd) /// Notification of an auto-casted skill (ZC_AUTORUN_SKILL). -/// 0147 <skill id>.W <type>.L <level>.W <sp cost>.W <atk range>.W <skill name>.24B <upgradable>.B +/// 0147 <skill id>.W <type>.L <level>.W <sp cost>.W <atk range>.W <skill name>.24B <upgradeable>.B void clif_item_skill(struct map_session_data *sd,uint16 skill_id,uint16 skill_lv) { int fd; @@ -7276,7 +7276,7 @@ void clif_mvp_noitem(struct map_session_data* sd) /// 0 = "Guild has been created." /// 1 = "You are already in a Guild." /// 2 = "That Guild Name already exists." -/// 3 = "You need the neccessary item to create a Guild." +/// 3 = "You need the necessary item to create a Guild." void clif_guild_created(struct map_session_data *sd,int flag) { int fd; @@ -7669,7 +7669,7 @@ void clif_guild_emblem_area(struct block_list* bl) /// Sends guild skills (ZC_GUILD_SKILLINFO). -/// 0162 <packet len>.W <skill points>.W { <skill id>.W <type>.L <level>.W <sp cost>.W <atk range>.W <skill name>.24B <upgradable>.B }* +/// 0162 <packet len>.W <skill points>.W { <skill id>.W <type>.L <level>.W <sp cost>.W <atk range>.W <skill name>.24B <upgradeable>.B }* void clif_guild_skillinfo(struct map_session_data* sd) { int fd; @@ -8186,7 +8186,7 @@ void clif_manner_message(struct map_session_data* sd, uint32 type) } -/// Followup to 0x14a type 3/5, informs who did the manner adjustment action (ZC_NOTIFY_MANNER_POINT_GIVEN). +/// Follow-up to 0x14a type 3/5, informs who did the manner adjustment action (ZC_NOTIFY_MANNER_POINT_GIVEN). /// 014b <type>.B <GM name>.24B /// type: /// 0 = positive (unmute) @@ -8277,7 +8277,7 @@ void clif_playBGM(struct map_session_data* sd, const char* name) /// term: /// unknown purpose, only relevant to act = 1 /// npc id: -/// The accustic direction of the sound is determined by the +/// The acoustic direction of the sound is determined by the /// relative position of the NPC to the player (3D sound). void clif_soundeffect(struct map_session_data* sd, struct block_list* bl, const char* name, int type) { @@ -8643,7 +8643,7 @@ void clif_charnameack (int fd, struct block_list *bl) return; } - // if no receipient specified just update nearby clients + // if no recipient specified just update nearby clients if (fd == 0) clif->send(buf, packet_len(cmd), bl, AREA); else { @@ -8738,7 +8738,7 @@ void clif_slide(struct block_list *bl, int x, int y) /// 008d <packet len>.W <id>.L <message>.?B void clif_disp_overhead(struct block_list *bl, const char* mes) { - unsigned char buf[256]; //This should be more than sufficient, the theorical max is CHAT_SIZE + 8 (pads and extra inserted crap) + unsigned char buf[256]; //This should be more than sufficient, the theoretical max is CHAT_SIZE + 8 (pads and extra inserted crap) size_t len_mes = strlen(mes)+1; //Account for \0 if (len_mes > sizeof(buf)-8) { @@ -8846,7 +8846,7 @@ void clif_starskill(struct map_session_data* sd, const char* mapname, int monste } /*========================================== - * Info about Star Glaldiator save map [Komurka] + * Info about Star Gladiator save map [Komurka] * type: 1: Information, 0: Map registered *------------------------------------------*/ void clif_feel_info(struct map_session_data* sd, unsigned char feel_level, unsigned char type) @@ -8858,7 +8858,7 @@ void clif_feel_info(struct map_session_data* sd, unsigned char feel_level, unsig } /*========================================== - * Info about Star Glaldiator hate mob [Komurka] + * Info about Star Gladiator hate mob [Komurka] * type: 1: Register mob, 0: Information. *------------------------------------------*/ void clif_hate_info(struct map_session_data *sd, unsigned char hate_level,int class_, unsigned char type) @@ -9052,7 +9052,7 @@ bool clif_process_message(struct map_session_data *sd, int format, char **name_, if( strncmp(name, sd->status.name, namelen) || // the text must start with the speaker's name name[namelen] != ' ' || name[namelen+1] != ':' || name[namelen+2] != ' ' ) // followed by ' : ' { - //Hacked message, or infamous "client desynch" issue where they pick one char while loading another. + //Hacked message, or infamous "client desynchronize" issue where they pick one char while loading another. ShowWarning("clif_process_message: Player '%s' sent a message using an incorrect name! Forcing a relog...\n", sd->status.name); set_eof(fd); // Just kick them out to correct it. return false; @@ -10323,7 +10323,7 @@ void clif_hercules_chsys_quit(struct map_session_data *sd) { /// 1 = pick up item /// 2 = sit down /// 3 = stand up -/// 7 = continous attack +/// 7 = continuous attack /// 12 = (touch skill?) /// There are various variants of this packet, some of them have padding between fields. void clif_parse_ActionRequest(int fd, struct map_session_data *sd) @@ -11037,7 +11037,7 @@ void clif_parse_ChatLeave(int fd, struct map_session_data* sd) } -//Handles notifying asker and rejecter of what has just ocurred. +//Handles notifying asker and rejecter of what has just occurred. //Type is used to determine the correct msg_txt to use: //0: void clif_noask_sub(struct map_session_data *src, struct map_session_data *target, int type) { @@ -12239,7 +12239,7 @@ void clif_parse_PartyChangeLeader(int fd, struct map_session_data* sd) { /// Party Booking in KRO [Spiria] /// -/// Request to register a party booking advertisment (CZ_PARTY_BOOKING_REQ_REGISTER). +/// Request to register a party booking advertisement (CZ_PARTY_BOOKING_REQ_REGISTER). /// 0802 <level>.W <map id>.W { <job>.W }*6 void clif_parse_PartyBookingRegisterReq(int fd, struct map_session_data* sd) { @@ -12259,7 +12259,7 @@ void clif_parse_PartyBookingRegisterReq(int fd, struct map_session_data* sd) } -/// Result of request to register a party booking advertisment (ZC_PARTY_BOOKING_ACK_REGISTER). +/// Result of request to register a party booking advertisement (ZC_PARTY_BOOKING_ACK_REGISTER). /// 0803 <result>.W /// result: /// 0 = success @@ -12280,7 +12280,7 @@ void clif_PartyBookingRegisterAck(struct map_session_data *sd, int flag) } -/// Request to search for party booking advertisments (CZ_PARTY_BOOKING_REQ_SEARCH). +/// Request to search for party booking advertisement (CZ_PARTY_BOOKING_REQ_SEARCH). /// 0804 <level>.W <map id>.W <job>.W <last index>.L <result count>.W void clif_parse_PartyBookingSearchReq(int fd, struct map_session_data* sd) { @@ -12331,7 +12331,7 @@ void clif_PartyBookingSearchAck(int fd, struct party_booking_ad_info** results, } -/// Request to delete own party booking advertisment (CZ_PARTY_BOOKING_REQ_DELETE). +/// Request to delete own party booking advertisement (CZ_PARTY_BOOKING_REQ_DELETE). /// 0806 void clif_parse_PartyBookingDeleteReq(int fd, struct map_session_data* sd) { @@ -12344,7 +12344,7 @@ void clif_parse_PartyBookingDeleteReq(int fd, struct map_session_data* sd) } -/// Result of request to delete own party booking advertisment (ZC_PARTY_BOOKING_ACK_DELETE). +/// Result of request to delete own party booking advertisement (ZC_PARTY_BOOKING_ACK_DELETE). /// 0807 <result>.W /// result: /// 0 = success @@ -12366,7 +12366,7 @@ void clif_PartyBookingDeleteAck(struct map_session_data* sd, int flag) } -/// Request to update party booking advertisment (CZ_PARTY_BOOKING_REQ_UPDATE). +/// Request to update party booking advertisement (CZ_PARTY_BOOKING_REQ_UPDATE). /// 0808 { <job>.W }*6 void clif_parse_PartyBookingUpdateReq(int fd, struct map_session_data* sd) { @@ -12384,7 +12384,7 @@ void clif_parse_PartyBookingUpdateReq(int fd, struct map_session_data* sd) } -/// Notification about new party booking advertisment (ZC_PARTY_BOOKING_NOTIFY_INSERT). +/// Notification about new party booking advertisement (ZC_PARTY_BOOKING_NOTIFY_INSERT). /// 0809 <index>.L <char name>.24B <expire time>.L <level>.W <map id>.W { <job>.W }*6 void clif_PartyBookingInsertNotify(struct map_session_data* sd, struct party_booking_ad_info* pb_ad) { @@ -12410,7 +12410,7 @@ void clif_PartyBookingInsertNotify(struct map_session_data* sd, struct party_boo } -/// Notification about updated party booking advertisment (ZC_PARTY_BOOKING_NOTIFY_UPDATE). +/// Notification about updated party booking advertisement (ZC_PARTY_BOOKING_NOTIFY_UPDATE). /// 080a <index>.L { <job>.W }*6 void clif_PartyBookingUpdateNotify(struct map_session_data* sd, struct party_booking_ad_info* pb_ad) { @@ -12431,7 +12431,7 @@ void clif_PartyBookingUpdateNotify(struct map_session_data* sd, struct party_boo } -/// Notification about deleted party booking advertisment (ZC_PARTY_BOOKING_NOTIFY_DELETE). +/// Notification about deleted party booking advertisement (ZC_PARTY_BOOKING_NOTIFY_DELETE). /// 080b <index>.L void clif_PartyBookingDeleteNotify(struct map_session_data* sd, int index) { @@ -12450,7 +12450,7 @@ void clif_PartyBookingDeleteNotify(struct map_session_data* sd, int index) /// Modified version of Party Booking System for 2012-04-10 or 2012-04-18 (RagexeRE). /// Code written by mkbu95, Spiria, Yommy and Ind -/// Request to register a party booking advertisment (CZ_PARTY_RECRUIT_REQ_REGISTER). +/// Request to register a party booking advertisement (CZ_PARTY_RECRUIT_REQ_REGISTER). /// 08e5 <level>.W <notice>.37B void clif_parse_PartyRecruitRegisterReq(int fd, struct map_session_data* sd) { @@ -12497,7 +12497,7 @@ void clif_PartyRecruitSearchAck(int fd, struct party_booking_ad_info** results, #endif } -/// Result of request to register a party booking advertisment (ZC_PARTY_RECRUIT_ACK_REGISTER). +/// Result of request to register a party booking advertisement (ZC_PARTY_RECRUIT_ACK_REGISTER). /// 08e6 <result>.W /// result: /// 0 = success @@ -12517,7 +12517,7 @@ void clif_PartyRecruitRegisterAck(struct map_session_data *sd, int flag) #endif } -/// Request to search for party booking advertisments (CZ_PARTY_RECRUIT_REQ_SEARCH). +/// Request to search for party booking advertisement (CZ_PARTY_RECRUIT_REQ_SEARCH). /// 08e7 <level>.W <map id>.W <last index>.L <result count>.W void clif_parse_PartyRecruitSearchReq(int fd, struct map_session_data* sd) { @@ -12533,7 +12533,7 @@ void clif_parse_PartyRecruitSearchReq(int fd, struct map_session_data* sd) #endif } -/// Request to delete own party booking advertisment (CZ_PARTY_RECRUIT_REQ_DELETE). +/// Request to delete own party booking advertisement (CZ_PARTY_RECRUIT_REQ_DELETE). /// 08e9 void clif_parse_PartyRecruitDeleteReq(int fd, struct map_session_data* sd) { @@ -12545,7 +12545,7 @@ void clif_parse_PartyRecruitDeleteReq(int fd, struct map_session_data* sd) #endif } -/// Result of request to delete own party booking advertisment (ZC_PARTY_RECRUIT_ACK_DELETE). +/// Result of request to delete own party booking advertisement (ZC_PARTY_RECRUIT_ACK_DELETE). /// 08ea <result>.W /// result: /// 0 = success @@ -12566,7 +12566,7 @@ void clif_PartyRecruitDeleteAck(struct map_session_data* sd, int flag) #endif } -/// Request to update party booking advertisment (CZ_PARTY_RECRUIT_REQ_UPDATE). +/// Request to update party booking advertisement (CZ_PARTY_RECRUIT_REQ_UPDATE). /// 08eb <notice>.37B void clif_parse_PartyRecruitUpdateReq(int fd, struct map_session_data *sd) { @@ -12581,7 +12581,7 @@ void clif_parse_PartyRecruitUpdateReq(int fd, struct map_session_data *sd) #endif } -/// Notification about new party booking advertisment (ZC_PARTY_RECRUIT_NOTIFY_INSERT). +/// Notification about new party booking advertisement (ZC_PARTY_RECRUIT_NOTIFY_INSERT). /// 08ec <index>.L <expire time>.L <char name>.24B <level>.W <notice>.37B void clif_PartyRecruitInsertNotify(struct map_session_data* sd, struct party_booking_ad_info* pb_ad) { @@ -12603,7 +12603,7 @@ void clif_PartyRecruitInsertNotify(struct map_session_data* sd, struct party_boo #endif } -/// Notification about updated party booking advertisment (ZC_PARTY_RECRUIT_NOTIFY_UPDATE). +/// Notification about updated party booking advertisement (ZC_PARTY_RECRUIT_NOTIFY_UPDATE). /// 08ed <index>.L <notice>.37B void clif_PartyRecruitUpdateNotify(struct map_session_data *sd, struct party_booking_ad_info* pb_ad) { @@ -12620,7 +12620,7 @@ void clif_PartyRecruitUpdateNotify(struct map_session_data *sd, struct party_boo #endif } -/// Notification about deleted party booking advertisment (ZC_PARTY_RECRUIT_NOTIFY_DELETE). +/// Notification about deleted party booking advertisement (ZC_PARTY_RECRUIT_NOTIFY_DELETE). /// 08ee <index>.L void clif_PartyRecruitDeleteNotify(struct map_session_data* sd, int index) { @@ -13172,7 +13172,7 @@ void clif_parse_GuildChangeNotice(int fd, struct map_session_data* sd) if(!sd->state.gmaster_flag) return; - // compensate for some client defects when using multilanguage mode + // compensate for some client defects when using multilingual mode if (msg1[0] == '|' && msg1[3] == '|') msg1+= 3; // skip duplicate marker if (msg2[0] == '|' && msg2[3] == '|') msg2+= 3; // skip duplicate marker if (msg2[0] == '|') msg2[strnlen(msg2, MAX_GUILDMES2)-1] = '\0'; // delete extra space at the end of string @@ -13612,7 +13612,7 @@ void clif_parse_GMRecall2(int fd, struct map_session_data* sd) { /// Request to execute GM commands. /// usage: /// /item n - summon n monster or acquire n item/s -/// /item money - grants 2147483647 zenies +/// /item money - grants 2147483647 Zeny /// /item whereisboss - locate boss mob in current map.(not yet implemented) /// /item regenboss_n t - regenerate n boss monster by t millisecond.(not yet implemented) /// /item onekillmonster - toggle an ability to kill mobs in one hit.(not yet implemented) @@ -13993,7 +13993,7 @@ void clif_friendslist_toggle(struct map_session_data *sd,int account_id, int cha } -//Subfunction called from clif_foreachclient to toggle friends on/off [Skotlex] +//Sub-function called from clif_foreachclient to toggle friends on/off [Skotlex] int clif_friendslist_toggle_sub(struct map_session_data *sd,va_list ap) { int account_id, char_id, online; @@ -14342,7 +14342,7 @@ void clif_parse_ranklist(int fd, struct map_session_data *sd) { case RANKTYPE_BLACKSMITH: case RANKTYPE_ALCHEMIST: case RANKTYPE_TAEKWON: - clif->ranklist(sd, type); // pk_list unsuported atm + clif->ranklist(sd, type); // pk_list unsupported atm break; } } @@ -14672,7 +14672,7 @@ void clif_check(int fd, struct map_session_data* pl_sd) { WFIFOW(fd,34) = pl_sd->battle_status.flee2/10; WFIFOW(fd,36) = pl_sd->battle_status.cri/10; WFIFOW(fd,38) = (2000-pl_sd->battle_status.amotion)/10; // aspd - WFIFOW(fd,40) = 0; // FIXME: What is 'plusASPD' supposed to be? Maybe adelay? + WFIFOW(fd,40) = 0; // FIXME: What is 'plusASPD' supposed to be? Maybe a delay? WFIFOSET(fd,packet_len(0x214)); } @@ -14737,7 +14737,7 @@ void clif_Mail_getattachment(int fd, uint8 flag) /// 0249 <result>.B /// result: /// 0 = success -/// 1 = recipinent does not exist +/// 1 = recipient does not exist void clif_Mail_send(int fd, bool fail) { WFIFOHEAD(fd,packet_len(0x249)); @@ -16068,7 +16068,7 @@ void clif_mercenary_info(struct map_session_data *sd) { /// Mercenary skill tree (ZC_MER_SKILLINFO_LIST). -/// 029d <packet len>.W { <skill id>.W <type>.L <level>.W <sp cost>.W <attack range>.W <skill name>.24B <upgradable>.B }* +/// 029d <packet len>.W { <skill id>.W <type>.L <level>.W <sp cost>.W <attack range>.W <skill name>.24B <upgradeable>.B }* void clif_mercenary_skillblock(struct map_session_data *sd) { struct mercenary_data *md; @@ -17142,7 +17142,7 @@ void clif_parse_debug(int fd,struct map_session_data *sd) { } /*========================================== * Server tells client to display a window similar to Magnifier (item) one - * Server populates the window with avilable elemental converter options according to player's inventory + * Server populates the window with available elemental converter options according to player's inventory *------------------------------------------*/ int clif_elementalconverter_list(struct map_session_data *sd) { int i,c,view,fd; @@ -17587,7 +17587,7 @@ void clif_parse_CashShopSchedule(int fd, struct map_session_data *sd) { } void clif_parse_CashShopBuy(int fd, struct map_session_data *sd) { unsigned short limit = RFIFOW(fd, 4), i, j; - unsigned int kafra_pay = RFIFOL(fd, 6);// [Ryuuzaki] - These are free cash points (strangely #CASH = main cash curreny for us, confusing) + unsigned int kafra_pay = RFIFOL(fd, 6);// [Ryuuzaki] - These are free cash points (strangely #CASH = main cash currently for us, confusing) if( map->list[sd->bl.m].flag.nocashshop ) { clif->colormes(fd,COLOR_RED,msg_txt(1489)); //Cash Shop is disabled in this map diff --git a/src/map/clif.h b/src/map/clif.h index 7b27e1fe6..e1af44881 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -66,7 +66,7 @@ typedef enum send_target { AREA, // area AREA_WOS, // area, without self AREA_WOC, // area, without chatrooms - AREA_WOSC, // area, without own chatroom + AREA_WOSC, // area, without own chatrooms AREA_CHAT_WOC, // hearable area, without chatrooms CHAT, // current chatroom CHAT_WOS, // current chatroom, without self diff --git a/src/map/elemental.c b/src/map/elemental.c index b414d5b9f..7ffeea410 100644 --- a/src/map/elemental.c +++ b/src/map/elemental.c @@ -505,7 +505,7 @@ int elemental_change_mode_ack(struct elemental_data *ed, int mode) { else unit->skilluse_id(&ed->bl,bl->id,skill_id,skill_lv); - ed->target_id = 0; // Reset target after casting the skill to avoid continious attack. + ed->target_id = 0; // Reset target after casting the skill to avoid continuous attack. return 1; } @@ -529,7 +529,7 @@ int elemental_change_mode(struct elemental_data *ed, int mode) { else if( mode == EL_MODE_ASSIST ) mode = EL_SKILLMODE_ASSIST; // Assist spirit mode -> Assist spirit skill. else mode = EL_SKILLMODE_PASIVE; // Passive spirit mode -> Passive spirit skill. - // Use a skill inmediately after every change mode. + // Use a skill immediately after every change mode. if( mode != EL_SKILLMODE_AGGRESSIVE ) elemental->change_mode_ack(ed,mode); return 1; diff --git a/src/map/guild.c b/src/map/guild.c index 4bf9c9da0..209f29103 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -61,7 +61,7 @@ int guild_skill_get_max (int id) { return guild->skill_tree[id-GD_SKILLBASE].max; } -// Retrive skill_lv learned by guild +// Retrieve skill_lv learned by guild int guild_checkskill(struct guild *g, int id) { int idx = id - GD_SKILLBASE; if (idx < 0 || idx >= MAX_GUILDSKILL) @@ -764,7 +764,7 @@ int guild_member_added(int guild_id,int account_id,int char_id,int flag) { 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 invalid 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 **"); @@ -882,7 +882,7 @@ int guild_member_withdraw(int guild_id, int account_id, int char_id, int flag, c online_member_sd = guild->getavailablesd(g); if(online_member_sd == NULL) - return 0; // noone online to inform + return 0; // no one online to inform #ifdef GP_BOUND_ITEMS //Guild bound item check @@ -2373,7 +2373,7 @@ void guild_defaults(void) { guild->agit_end = guild_agit_end; guild->agit2_start = guild_agit2_start; guild->agit2_end = guild_agit2_end; - /* guild flag cachin */ + /* guild flag caching */ guild->flag_add = guild_flag_add; guild->flag_remove = guild_flag_remove; guild->flags_clear = guild_flags_clear; diff --git a/src/map/homunculus.c b/src/map/homunculus.c index b6a83d1cb..8c47226db 100644 --- a/src/map/homunculus.c +++ b/src/map/homunculus.c @@ -809,7 +809,7 @@ bool homunculus_call(struct map_session_data *sd) { return true; } -// Recv homunculus data from char server +// Receive homunculus data from char server bool homunculus_recv_data(int account_id, struct s_homunculus *sh, int flag) { struct map_session_data *sd; struct homun_data *hd; @@ -1157,7 +1157,7 @@ bool homunculus_read_skill_db_sub(char* split[], int columns, int current) { classid = atoi(split[0]) - HM_CLASS_BASE; if ( classid >= MAX_HOMUNCULUS_CLASS ) { - ShowWarning("homunculus_read_skill_db_sub: Invalud homunculus class %d.\n", atoi(split[0])); + ShowWarning("homunculus_read_skill_db_sub: Invalid homunculus class %d.\n", atoi(split[0])); return false; } diff --git a/src/map/intif.c b/src/map/intif.c index 042896f4f..4dd0fa448 100644 --- a/src/map/intif.c +++ b/src/map/intif.c @@ -238,7 +238,7 @@ int intif_wis_replay(int id, int flag) WFIFOHEAD(inter_fd,7); WFIFOW(inter_fd,0) = 0x3002; WFIFOL(inter_fd,2) = id; - WFIFOB(inter_fd,6) = flag; // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target + WFIFOB(inter_fd,6) = flag; // flag: 0: success to send whisper, 1: target character is not logged in?, 2: ignored by target WFIFOSET(inter_fd,7); if (battle_config.etc_log) @@ -387,7 +387,7 @@ int intif_request_registry(struct map_session_data *sd, int flag) { nullpo_ret(sd); - /* if char server aint online it doesn't load, shouldn't we kill the session then? */ + /* if char server ain't online it doesn't load, shouldn't we kill the session then? */ if (intif->CheckForCharServer()) return 0; @@ -931,7 +931,7 @@ void intif_parse_WisMessage(int fd) { } //Success to send whisper. clif->wis_message(sd->fd, wisp_source, (char*)RFIFOP(fd,56),RFIFOW(fd,2)-56); - intif_wis_replay(id,0); // succes + intif_wis_replay(id,0); // success } // Wisp/page transmission result reception @@ -939,7 +939,7 @@ void intif_parse_WisEnd(int fd) { struct map_session_data* sd; 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 + ShowInfo("intif_parse_wisend: player: %s, flag: %d\n", RFIFOP(fd,2), RFIFOB(fd,26)); // flag: 0: success to send whisper, 1: target character is not logged in?, 2: ignored by target sd = (struct map_session_data *)map->nick2sd((char *) RFIFOP(fd,2)); if (sd != NULL) clif->wis_end(sd->fd, RFIFOB(fd,26)); @@ -1366,7 +1366,7 @@ void intif_parse_DeletePetOk(int fd) { ShowError("pet data delete failure\n"); } -// ACK changing name resquest, players,pets,hommon +// ACK changing name request, players,pets,homun void intif_parse_ChangeNameOk(int fd) { struct map_session_data *sd = NULL; diff --git a/src/map/itemdb.c b/src/map/itemdb.c index 9bc352276..320c64402 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -1123,7 +1123,7 @@ void itemdb_read_packages(void) { for( r = 0; r < itemdb->packages[count].random_qty; r++ ) { if( itemdb->packages[count].random_groups[r].random_qty == 1 ) { - //item packages dont stop looping until something comes out of them, so if you have only one item in it the drop is guaranteed. + //item packages don't stop looping until something comes out of them, so if you have only one item in it the drop is guaranteed. ShowWarning("itemdb_read_packages: in '%s' 'Random: %d' group has only 1 random option, drop rate will be 100%!\n",itemdb_name(itemdb->packages[count].id),r+1); itemdb->packages[count].random_groups[r].random_list[0].rate = 10000; } diff --git a/src/map/map.c b/src/map/map.c index e37e902f6..a89478cb1 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -254,7 +254,7 @@ int map_delblock(struct block_list* bl) // blocklist (2ways chainlist) if (bl->prev == NULL) { if (bl->next != NULL) { - // can't delete block (already at the begining of the chain) + // can't delete block (already at the beginning of the chain) ShowError("map_delblock error : bl->next!=NULL\n"); } return 0; @@ -468,7 +468,7 @@ static int bl_vforeach(int (*func)(struct block_list*, va_list), int blockcount, map->freeblock_lock(); for (i = blockcount; i < map->bl_list_count && returnCount < max; i++) { - if (map->bl_list[i]->prev) { //func() may delete this bl_list[] slot, checking for prev ensures it wasnt queued for deletion. + if (map->bl_list[i]->prev) { //func() may delete this bl_list[] slot, checking for prev ensures it wasn't queued for deletion. va_list argscopy; va_copy(argscopy, args); returnCount += func(map->bl_list[i], argscopy); @@ -2037,7 +2037,7 @@ void map_foreachnpc(int (*func)(struct npc_data* nd, va_list args), ...) { } /// Applies func to everything in the db. -/// Stops iteratin gif func returns -1. +/// Stops iterating gif func returns -1. void map_vforeachregen(int (*func)(struct block_list* bl, va_list args), va_list args) { DBIterator* iter; struct block_list* bl; @@ -2057,7 +2057,7 @@ void map_vforeachregen(int (*func)(struct block_list* bl, va_list args), va_list } /// Applies func to everything in the db. -/// Stops iteratin gif func returns -1. +/// Stops iterating gif func returns -1. /// @see map_vforeachregen void map_foreachregen(int (*func)(struct block_list* bl, va_list args), ...) { va_list args; @@ -4402,7 +4402,7 @@ bool map_zone_mf_cache(int m, char *flag, char *params) { } if( modifier[0] == '\0' || !( skill_id = skill->name2id(skill_name) ) || !skill->get_unit_id( skill->name2id(skill_name), 0) || atoi(modifier) < 1 || atoi(modifier) > USHRT_MAX ) { - ;/* we dont mind it, the server will take care of it next. */ + ;/* we don't mind it, the server will take care of it next. */ } else { int idx = map->list[m].unit_count; @@ -4435,7 +4435,7 @@ bool map_zone_mf_cache(int m, char *flag, char *params) { } if( modifier[0] == '\0' || !( skill_id = skill->name2id(skill_name) ) || atoi(modifier) < 1 || atoi(modifier) > USHRT_MAX ) { - ;/* we dont mind it, the server will take care of it next. */ + ;/* we don't mind it, the server will take care of it next. */ } else { int idx = map->list[m].skill_count; @@ -4792,7 +4792,7 @@ void read_map_zone_db(void) { --h; continue; } - if( !map->zone_bl_type(libconfig->setting_get_string_elem(skills,h),&subtype) )/* we dont remove it from the three due to inheritance */ + if( !map->zone_bl_type(libconfig->setting_get_string_elem(skills,h),&subtype) )/* we don't remove it from the three due to inheritance */ --disabled_skills_count; } /* all ok, process */ @@ -4830,7 +4830,7 @@ void read_map_zone_db(void) { --h; continue; } - if( !libconfig->setting_get_bool(item) )/* we dont remove it from the three due to inheritance */ + if( !libconfig->setting_get_bool(item) )/* we don't remove it from the three due to inheritance */ --disabled_items_count; } /* all ok, process */ @@ -4875,7 +4875,7 @@ void read_map_zone_db(void) { --h; continue; } - if( !libconfig->setting_get_int(command) )/* we dont remove it from the three due to inheritance */ + if( !libconfig->setting_get_int(command) )/* we don't remove it from the three due to inheritance */ --disabled_commands_count; } /* all ok, process */ @@ -4911,7 +4911,7 @@ void read_map_zone_db(void) { --h; continue; } - if( !map->zone_bl_type(libconfig->setting_get_string_elem(cap,1),&subtype) )/* we dont remove it from the three due to inheritance */ + if( !map->zone_bl_type(libconfig->setting_get_string_elem(cap,1),&subtype) )/* we don't remove it from the three due to inheritance */ --capped_skills_count; } /* all ok, process */ @@ -5712,7 +5712,7 @@ int do_init(int argc, char *argv[]) char ip_str[16]; ip2str(sockt->addr_[0], ip_str); - ShowWarning("Not all IP addresses in /conf/map-server.conf configured, autodetecting...\n"); + ShowWarning("Not all IP addresses in /conf/map-server.conf configured, auto-detecting...\n"); if (sockt->naddr_ == 0) ShowError("Unable to determine your IP address...\n"); @@ -5736,7 +5736,7 @@ int do_init(int argc, char *argv[]) map->id_db = idb_alloc(DB_OPT_BASE); map->pc_db = idb_alloc(DB_OPT_BASE); //Added for reliable map->id2sd() use. [Skotlex] - map->mobid_db = idb_alloc(DB_OPT_BASE); //Added to lower the load of the lazy mob ai. [Skotlex] + map->mobid_db = idb_alloc(DB_OPT_BASE); //Added to lower the load of the lazy mob AI. [Skotlex] map->bossid_db = idb_alloc(DB_OPT_BASE); // Used for Convex Mirror quick MVP search map->map_db = uidb_alloc(DB_OPT_BASE); map->nick_db = idb_alloc(DB_OPT_BASE); @@ -5795,7 +5795,7 @@ int do_init(int argc, char *argv[]) itemdb->init(minimal); skill->init(minimal); if (!minimal) - map->read_zone_db();/* read after item and skill initalization */ + map->read_zone_db();/* read after item and skill initialization */ mob->init(minimal); pc->init(minimal); status->init(minimal); diff --git a/src/map/map.h b/src/map/map.h index 3ce59a804..38167597a 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -324,7 +324,7 @@ struct spawn_data { unsigned int level; struct { unsigned int size : 2; //Holds if mob has to be tiny/large - unsigned int ai : 4; //Special ai for summoned monsters. + unsigned int ai : 4; //Special AI for summoned monsters. //0: Normal mob | 1: Standard summon, attacks mobs //2: Alchemist Marine Sphere | 3: Alchemist Summon Flora | 4: Summon Zanzou unsigned int dynamic : 1; //Whether this data is indexed by a map's dynamic mob list @@ -659,8 +659,8 @@ struct map_data { int nocommand; //Blocks @/# commands for non-gms. [Skotlex] /** * Ice wall reference counter for bugreport:3574 - * - since there are a thounsand mobs out there in a lot of maps checking on, - * - every targetting for icewall on attack path would just be a waste, so, + * - since there are a thousand mobs out there in a lot of maps checking on, + * - every targeting for icewall on attack path would just be a waste, so, * - this counter allows icewall checking be only run when there is a actual ice wall on the map **/ int icewall_num; @@ -732,7 +732,7 @@ struct map_data_other_server { /// Bitfield of flags for the iterator. enum e_mapitflags { MAPIT_NORMAL = 0, - // MAPIT_PCISPLAYING = 1,// Unneeded as pc_db/id_db will only hold auth'ed, active players. + // MAPIT_PCISPLAYING = 1,// Unneeded as pc_db/id_db will only hold authed, active players. }; struct s_mapiterator; diff --git a/src/map/mob.c b/src/map/mob.c index ef47d6b70..552724de0 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -356,7 +356,7 @@ bool mob_ksprotected(struct block_list *src, struct block_list *target) { return false; // KS Protection Disabled if( !(md = BL_CAST(BL_MOB,target)) ) - return false; // Tarjet is not MOB + return false; // Target is not MOB if( (s_bl = battle->get_master(src)) == NULL ) s_bl = src; @@ -1073,7 +1073,7 @@ int mob_ai_sub_hard_activesearch(struct block_list *bl,va_list ap) default: if (battle_config.hom_setting&0x4 && (*target) && (*target)->type == BL_HOM && bl->type != BL_HOM) - return 0; //For some reason Homun targets are never overriden. + return 0; //For some reason Homun targets are never overridden. dist = distance_bl(&md->bl, bl); if( @@ -1443,7 +1443,7 @@ bool mob_ai_sub_hard(struct mob_data *md, int64 tick) { //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. + mob->unlocktarget(md, tick-(battle_config.mob_ai&0x8?3000:0)); //Immediately do random walk. tbl = NULL; } } @@ -2084,7 +2084,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) { unsigned int base_exp,job_exp; } pt[DAMAGELOG_SIZE]; int i, temp, count, m = md->bl.m, pnum = 0; - int dmgbltypes = 0; // bitfield of all bl types, that caused damage to the mob and are elligible for exp distribution + int dmgbltypes = 0; // bitfield of all bl types, that caused damage to the mob and are eligible for exp distribution unsigned int mvp_damage; int64 tick = timer->gettick(); bool rebirth, homkillonly; @@ -2302,7 +2302,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) { int drop_modifier = mvp_sd ? pc->level_penalty_mod( md->level - mvp_sd->status.base_level, md->status.race, md->status.mode, 2) : second_sd ? pc->level_penalty_mod( md->level - second_sd->status.base_level, md->status.race, md->status.mode, 2): third_sd ? pc->level_penalty_mod( md->level - third_sd->status.base_level, md->status.race, md->status.mode, 2) : - 100;/* no player was attached, we dont use any modifier (100 = rates are not touched) */ + 100;/* no player was attached, we don't use any modifier (100 = rates are not touched) */ #endif dlist->m = md->bl.m; dlist->x = md->bl.x; @@ -2613,7 +2613,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) { if( !rebirth ) { if( pcdb_checkid(md->vd->class_) ) {//Player mobs are not removed automatically by the client. - /* first we set them dead, then we delay the outsight effect */ + /* first we set them dead, then we delay the out sight effect */ clif->clearunit_area(&md->bl,CLR_DEAD); clif->clearunit_delayed(&md->bl, CLR_OUTSIGHT,tick+3000); } else @@ -2842,7 +2842,7 @@ int mob_warpslave(struct block_list *bl, int range) { } /*========================================== - * Counts slave sub, curently checking if mob master is the given ID. + * Counts slave sub, currently checking if mob master is the given ID. *------------------------------------------*/ int mob_countslave_sub(struct block_list *bl,va_list ap) { @@ -3231,7 +3231,7 @@ int mobskill_use(struct mob_data *md, int64 tick, int event) { continue; } } else { - //Targetted skill + //Targeted skill switch (skill_target) { case MST_RANDOM: //Pick a random enemy within skill range. bl = battle->get_enemy(&md->bl, DEFAULT_ENEMY_TYPE(md), @@ -3335,7 +3335,7 @@ int mob_is_clone(int class_) } //Flag values: -//&1: Set special ai (fight mobs, not players) +//&1: Set special AI (fight mobs, not players) //If mode is not passed, a default aggressive mode is used. //If master_id is passed, clone is attached to him. //Returns: ID of newly crafted copy. @@ -3621,7 +3621,7 @@ unsigned int mob_drop_adjust(int baserate, int rate_adjust, unsigned short rate_ } /** - * Check if global item drop rate is overriden for given item + * Check if global item drop rate is overridden for given item * in db/mob_item_ratio.txt * @param nameid ID of the item * @param mob_id ID of the monster @@ -3773,7 +3773,7 @@ bool mob_parse_dbrow(char** str) { 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] + // Some new MVP's MEXP multiple by high exp-rate cause overflow. [LuzZza] exp = (double)atoi(str[30]) * (double)battle_config.mvp_exp_rate / 100.; db->mexp = (unsigned int)cap_value(exp, 0, UINT_MAX); @@ -3835,7 +3835,7 @@ bool mob_parse_dbrow(char** str) { ratemax = battle_config.item_drop_treasure_max; } else switch (type) - { // Added suport to restrict normal drops of MVP's [Reddozen] + { // Added support to restrict normal drops of MVP's [Reddozen] case IT_HEALING: rate_adjust = (mstatus->mode&MD_BOSS) ? battle_config.item_rate_heal_boss : battle_config.item_rate_heal; ratemin = battle_config.item_drop_heal_min; diff --git a/src/map/mob.h b/src/map/mob.h index d07f78c77..7e222fa74 100644 --- a/src/map/mob.h +++ b/src/map/mob.h @@ -13,7 +13,7 @@ #define MAX_RANDOMMONSTER 5 -// Change this to increase the table size in your mob_db to accomodate a larger mob database. +// Change this to increase the table size in your mob_db to accommodate a larger mob database. // Be sure to note that IDs 4001 to 4048 are reserved for advanced/baby/expanded classes. // Notice that the last 1000 entries are used for player clones, so always set this to desired value +1000 #define MAX_MOB_DB 4000 @@ -35,7 +35,7 @@ #define MOB_CLONE_START (MAX_MOB_DB-999) #define MOB_CLONE_END MAX_MOB_DB -//Used to determine default enemy type of mobs (for use in eachinrange calls) +//Used to determine default enemy type of mobs (for use in each in range calls) #define DEFAULT_ENEMY_TYPE(md) ((md)->special_state.ai?BL_CHAR:BL_MOB|BL_PC|BL_HOM|BL_MER) #define MAX_MOB_CHAT 250 //Max Skill's messages @@ -127,7 +127,7 @@ struct mob_data { char name[NAME_LENGTH]; struct { unsigned int size : 2; //Small/Big monsters. - unsigned int ai : 4; //Special ai for summoned monsters. + unsigned int ai : 4; //Special AI for summoned monsters. //0: Normal mob. //1: Standard summon, attacks mobs. //2: Alchemist Marine Sphere diff --git a/src/map/npc.c b/src/map/npc.c index 0817313e2..81615022a 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -666,7 +666,7 @@ void npc_timerevent_quit(struct map_session_data* sd) struct npc_data* nd; struct timer_event_data *ted; - // Check timer existance + // Check timer existence if( sd->npc_timer_id == INVALID_TIMER ) return; if( !(td = timer->get(sd->npc_timer_id)) ) @@ -1340,7 +1340,7 @@ int npc_cashshop_buylist(struct map_session_data *sd, int points, int count, uns return ERROR_TYPE_ITEM_ID; if( !itemdb->isstackable(nameid) && amount > 1 ) { - ShowWarning("Player %s (%d:%d) sent a hexed packet trying to buy %d of nonstackable item %d!\n", + ShowWarning("Player %s (%d:%d) sent a hexed packet trying to buy %d of non-stackable item %d!\n", sd->status.name, sd->status.account_id, sd->status.char_id, amount, nameid); amount = item_list[i*2+0] = 1; } @@ -1667,7 +1667,7 @@ int npc_cashshop_buy(struct map_session_data *sd, int nameid, int amount, int po return ERROR_TYPE_ITEM_ID; if(!itemdb->isstackable(nameid) && amount > 1) { - ShowWarning("Player %s (%d:%d) sent a hexed packet trying to buy %d of nonstackable item %d!\n", + ShowWarning("Player %s (%d:%d) sent a hexed packet trying to buy %d of non-stackable item %d!\n", sd->status.name, sd->status.account_id, sd->status.char_id, amount, nameid); amount = 1; } @@ -1775,7 +1775,7 @@ int npc_buylist(struct map_session_data* sd, int n, unsigned short* item_list) { if( !itemdb->isstackable(nameid) && amount > 1 ) { //Exploit? You can't buy more than 1 of equipment types o.O - ShowWarning("Player %s (%d:%d) sent a hexed packet trying to buy %d of nonstackable item %d!\n", + ShowWarning("Player %s (%d:%d) sent a hexed packet trying to buy %d of non-stackable item %d!\n", sd->status.name, sd->status.account_id, sd->status.char_id, amount, nameid); amount = item_list[i*2+0] = 1; } @@ -1898,7 +1898,7 @@ int npc_market_buylist(struct map_session_data* sd, unsigned short list_size, st if( !itemdb->isstackable(nameid) && amount > 1 ) { //Exploit? You can't buy more than 1 of equipment types o.O - ShowWarning("Player %s (%d:%d) sent a hexed packet trying to buy %d of nonstackable item %d!\n", + ShowWarning("Player %s (%d:%d) sent a hexed packet trying to buy %d of non-stackable item %d!\n", sd->status.name, sd->status.account_id, sd->status.char_id, amount, nameid); amount = p->list[i].qty = 1; } diff --git a/src/map/npc_chat.c b/src/map/npc_chat.c index 2182e1da2..8bc246819 100644 --- a/src/map/npc_chat.c +++ b/src/map/npc_chat.c @@ -80,7 +80,7 @@ struct pcre_interface libpcre_s; /** - * delete everythign associated with a entry + * delete everything associated with a entry * * This does NOT do the list management */ @@ -245,7 +245,7 @@ void delete_pcreset(struct npc_data* nd, int setid) while (pcreset->head) { struct pcrematch_entry* n = pcreset->head->next; npc_chat->finalize_pcrematch_entry(pcreset->head); - aFree(pcreset->head); // Cleanin' the last ones.. [Lance] + aFree(pcreset->head); // Cleaning the last ones.. [Lance] pcreset->head = n; } @@ -301,7 +301,7 @@ void npc_chat_def_pattern(struct npc_data* nd, int setid, const char* pattern, c * Delete everything associated with a NPC concerning the pattern * matching code * - * this could be more efficent but.. how often do you do this? + * this could be more efficient but.. how often do you do this? */ void npc_chat_finalize(struct npc_data* nd) { @@ -344,10 +344,10 @@ int npc_chat_sub(struct block_list* bl, va_list ap) // iterate across all active sets for (pcreset = npcParse->active; pcreset != NULL; pcreset = pcreset->next) { - // interate across all patterns in that set + // n across all patterns in that set for (e = pcreset->head; e != NULL; e = e->next) { - int offsets[2*10 + 10]; // 1/3 reserved for temp space requred by pcre_exec + int offsets[2*10 + 10]; // 1/3 reserved for temp space required by pcre_exec // perform pattern match int r = libpcre->exec(e->pcre_, e->pcre_extra_, msg, len, 0, 0, offsets, ARRAYLENGTH(offsets)); @@ -380,7 +380,7 @@ int npc_chat_sub(struct block_list* bl, va_list ap) return 0; } -// Various script builtins used to support these functions +// Various script built-ins used to support these functions BUILDIN(defpattern) { int setid = script_getnum(st,2); const char* pattern = script_getstr(st,3); diff --git a/src/map/party.c b/src/map/party.c index 678b2cd54..7cf340edb 100644 --- a/src/map/party.c +++ b/src/map/party.c @@ -213,7 +213,7 @@ void party_check_state(struct party_data *p) { int i; memset(&p->state, 0, sizeof(p->state)); for (i = 0; i < MAX_PARTY; i ++) { - if (!p->party.member[i].online) continue; //Those not online shouldn't aport to skill usage and all that. + if (!p->party.member[i].online) continue; //Those not online shouldn't apart to skill usage and all that. switch (p->party.member[i].class_) { case JOB_MONK: case JOB_BABY_MONK: @@ -1132,7 +1132,7 @@ int party_sub_count_chorus(struct block_list *bl, va_list ap) { * @param func Function to execute * @param sd Reference character for party, map, area center * @param range Area size (0 = whole map) - * @param ... Adidtional parameters to pass to func() + * @param ... Additional parameters to pass to func() * @return Sum of the return values from func() */ int party_foreachsamemap(int (*func)(struct block_list*,va_list), struct map_session_data *sd, int range, ...) { diff --git a/src/map/script.c b/src/map/script.c index 95cf48a16..6ccbf8eaa 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -2765,7 +2765,7 @@ void script_array_add_member(struct script_array *sa, unsigned int idx) { } /** * Obtains the source of the array database for this type and scenario - * Initializes such database when not yet initialised. + * Initializes such database when not yet initialized. **/ struct reg_db *script_array_src(struct script_state *st, struct map_session_data *sd, const char *name, struct reg_db *ref) { struct reg_db *src = NULL; diff --git a/src/map/skill.c b/src/map/skill.c index 383720361..cb0f4786f 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -852,7 +852,7 @@ int skill_additional_effect(struct block_list* src, struct block_list *bl, uint1 #ifdef RENEWAL sc_start(src,bl,SC_FREEZE,65-(5*skill_lv),skill_lv,skill->get_time2(skill_id,skill_lv)); #else - //Tharis pointed out that this is normal freeze chance with a base of 300% + // [Tharis] pointed out that this is normal freeze chance with a base of 300% if(tsc->sg_counter >= 3 && sc_start(src,bl,SC_FREEZE,300,skill_lv,skill->get_time2(skill_id,skill_lv))) tsc->sg_counter = 0; @@ -993,7 +993,7 @@ int skill_additional_effect(struct block_list* src, struct block_list *bl, uint1 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 = status->get_matk(src, 2); rate*=skill_lv; @@ -1032,7 +1032,7 @@ int skill_additional_effect(struct block_list* src, struct block_list *bl, uint1 sc_start(src,bl,SC_BLIND,100,skill_lv,skill->get_time2(skill_id,skill_lv)); break; - case LK_HEADCRUSH: //Headcrush has chance of causing Bleeding status, except on demon and undead element + case LK_HEADCRUSH: // Headcrush has chance of causing Bleeding status, except on demon and undead element if (!(battle->check_undead(tstatus->race, tstatus->def_ele) || tstatus->race == RC_DEMON)) sc_start2(src, bl, SC_BLOODING,50, skill_lv, src->id, skill->get_time2(skill_id,skill_lv)); break; @@ -1296,11 +1296,11 @@ int skill_additional_effect(struct block_list* src, struct block_list *bl, uint1 sc_start(src, bl, SC_BLOODING, 100, skill_lv, 10000); break; case ITEMID_MELON_BOMB: - sc_start(src, bl, SC_MELON_BOMB, 100, skill_lv, 60000); // Reduces ASPD and moviment speed + sc_start(src, bl, SC_MELON_BOMB, 100, skill_lv, 60000); // Reduces ASPD and movement speed break; case ITEMID_BANANA_BOMB: sc_start(src, bl, SC_BANANA_BOMB, 100, skill_lv, 60000); // Reduces LUK? Needed confirm it, may be it's bugged in kRORE? - sc_start(src, bl, SC_BANANA_BOMB_SITDOWN_POSTDELAY, (sd? sd->status.job_level:0) + sstatus->dex / 6 + tstatus->agi / 4 - tstatus->luk / 5 - status->get_lv(bl) + status->get_lv(src), skill_lv, 1000); // Sitdown for 3 seconds. + sc_start(src, bl, SC_BANANA_BOMB_SITDOWN_POSTDELAY, (sd? sd->status.job_level:0) + sstatus->dex / 6 + tstatus->agi / 4 - tstatus->luk / 5 - status->get_lv(bl) + status->get_lv(src), skill_lv, 1000); // Sit down for 3 seconds. break; } sd->itemid = -1; @@ -1657,7 +1657,7 @@ int skill_onskillusage(struct map_session_data *sd, struct block_list *bl, uint1 return 1; } -/* Splitted off from skill->additional_effect, which is never called when the +/* Split 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 * from cards) that will take effect on the source, not the target. [Skotlex] @@ -1673,7 +1673,7 @@ int skill_counter_additional_effect(struct block_list* src, struct block_list *b nullpo_ret(src); nullpo_ret(bl); - if(skill_id > 0 && !skill_lv) return 0; // don't forget auto attacks! - celest + if(skill_id > 0 && !skill_lv) return 0; // don't forget auto attacks! [celest] sd = BL_CAST(BL_PC, src); dstsd = BL_CAST(BL_PC, bl); @@ -1712,7 +1712,7 @@ int skill_counter_additional_effect(struct block_list* src, struct block_list *b case GS_FULLBUSTER: sc_start(src,src,SC_BLIND,2*skill_lv,skill_lv,skill->get_time2(skill_id,skill_lv)); break; - case HFLI_SBR44: //[orn] + case HFLI_SBR44: // [orn] case HVAN_EXPLOSION: if(src->type == BL_HOM){ TBL_HOM *hd = (TBL_HOM*)src; @@ -1728,15 +1728,15 @@ int skill_counter_additional_effect(struct block_list* src, struct block_list *b } if( sd && (sd->class_&MAPID_UPPERMASK) == MAPID_STAR_GLADIATOR - && rnd()%10000 < battle_config.sg_miracle_skill_ratio) //SG_MIRACLE [Komurka] + && rnd()%10000 < battle_config.sg_miracle_skill_ratio) // SG_MIRACLE [Komurka] sc_start(src,src,SC_MIRACLE,100,1,battle_config.sg_miracle_skill_duration); 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] + // Soul Drain should only work on targeted 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 ) ; else { @@ -1756,7 +1756,7 @@ int skill_counter_additional_effect(struct block_list* src, struct block_list *b if( attack_type&BF_MAGIC ) { sp += sd->bonus.magic_sp_gain_value; hp += sd->bonus.magic_hp_gain_value; - if( skill_id == WZ_WATERBALL ) {//(bugreport:5303) + if( skill_id == WZ_WATERBALL ) {// (bugreport:5303) struct status_change *sc = NULL; if( ( sc = status->get_sc(src) ) ) { if( sc->data[SC_SOULLINK] @@ -1851,7 +1851,7 @@ int skill_counter_additional_effect(struct block_list* src, struct block_list *b break; } dstsd->state.autocast = 0; - //Set canact delay. [Skotlex] + // Set canact delay. [Skotlex] ud = unit->bl2ud(bl); if (ud) { rate = skill->delay_fix(bl, auto_skill_id, auto_skill_lv); @@ -1989,7 +1989,7 @@ int skill_strip_equip(struct block_list *bl, unsigned short where, int rate, int return 0; sc = status->get_sc(bl); - if (!sc || sc->option&OPTION_MADOGEAR ) //Mado Gear cannot be divested [Ind] + if (!sc || sc->option&OPTION_MADOGEAR ) // Mado Gear cannot be divested [Ind] return 0; for (i = 0; i < ARRAYLENGTH(pos); i++) { @@ -2018,16 +2018,16 @@ int skill_blown(struct block_list* src, struct block_list* target, int count, in nullpo_ret(src); if (src != target && map->list[src->m].flag.noknockback) - return 0; //No knocking + return 0; // No knocking if (count == 0) - return 0; //Actual knockback distance is 0. + return 0; // Actual knockback distance is 0. switch (target->type) { case BL_MOB: { struct mob_data* md = BL_CAST(BL_MOB, target); if( md->class_ == MOBID_EMPERIUM ) return 0; - if(src != target && is_boss(target)) //Bosses can't be knocked-back + if(src != target && is_boss(target)) // Bosses can't be knocked-back return 0; } break; @@ -2059,11 +2059,13 @@ 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) -// In case of success returns type of reflection, otherwise 0 -// 1 - Regular reflection (Maya) -// 2 - SL_KAITE reflection +/* + Checks if 'bl' should reflect back a spell cast by 'src'. + type is the type of magic attack: 0: indirect (aoe), 1: direct (targeted) + In case of success returns type of reflection, otherwise 0 + 1 - Regular reflection (Maya) + 2 - SL_KAITE reflection +*/ int skill_magic_reflect(struct block_list* src, struct block_list* bl, int type) { struct status_change *sc = status->get_sc(bl); struct map_session_data* sd = BL_CAST(BL_PC, bl); @@ -2122,8 +2124,8 @@ int skill_attack(int attack_type, struct block_list* src, struct block_list *dsr if(skill_id > 0 && !skill_lv) return 0; - nullpo_ret(src); //Source is the master behind the attack (player/mob/pet) - nullpo_ret(dsrc); //dsrc is the actual originator of the damage, can be the same as src, or a skill casted by src. + nullpo_ret(src); // Source is the master behind the attack (player/mob/pet) + nullpo_ret(dsrc); // dsrc is the actual originator of the damage, can be the same as src, or a skill casted by src. nullpo_ret(bl); //Target to be attacked. if (src != dsrc) { @@ -2131,7 +2133,7 @@ int skill_attack(int attack_type, struct block_list* src, struct block_list *dsr 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] + //Note that splash attacks often only check versus the targeted mob, those around the splash area normally don't get checked for being hidden/cloaked/etc. [Skotlex] if (!status->check_skilluse(src, bl, skill_id, 2)) return 0; } @@ -2185,7 +2187,7 @@ int skill_attack(int attack_type, struct block_list* src, struct block_list *dsr sc = NULL; //Don't need it. /* bugreport:2564 flag&2 disables double casting trigger */ flag |= 2; - /* bugreport:7859 magical reflect'd zeroes blewcount */ + /* bugreport:7859 magical reflected zeroes blow count */ dmg.blewcount = 0; //Spirit of Wizard blocks Kaite's reflection if( type == 2 && sc && sc->data[SC_SOULLINK] && sc->data[SC_SOULLINK]->val2 == SL_WIZARD ) @@ -2207,11 +2209,11 @@ int skill_attack(int attack_type, struct block_list* src, struct block_list *dsr #if MAGIC_REFLECTION_TYPE #ifdef RENEWAL - if( dmg.dmg_lv != ATK_MISS ) //Wiz SL cancelled and consumed fragment + if( dmg.dmg_lv != ATK_MISS ) // Wiz SL canceled and consumed fragment #else // issue:6415 in pre-renewal Kaite reflected the entire damage received - // regardless of caster's equipament (Aegis 11.1) - if( dmg.dmg_lv != ATK_MISS && type == 1 ) //Wiz SL cancelled and consumed fragment + // regardless of caster's equipment (Aegis 11.1) + if( dmg.dmg_lv != ATK_MISS && type == 1 ) //Wiz SL canceled and consumed fragment #endif { short s_ele = skill->get_ele(skill_id, skill_lv); @@ -2503,7 +2505,7 @@ int skill_attack(int attack_type, struct block_list* src, struct block_list *dsr { //Updated to not be able to copy skills if the blow will kill you. [Skotlex] int copy_skill = skill_id, cidx = 0; /** - * Copy Referal: dummy skills should point to their source upon copying + * Copy Referral: dummy skills should point to their source upon copying **/ switch( skill_id ) { case AB_DUPLELIGHT_MELEE: @@ -2740,7 +2742,7 @@ int skill_attack(int attack_type, struct block_list* src, struct block_list *dsr struct status_change *ssc = status->get_sc(src); if( ssc && ssc->data[SC_POISONINGWEAPON] && rnd()%100 < 70 + 5*skill_lv ) { short rate = 100; - if ( ssc->data[SC_POISONINGWEAPON]->val1 == 9 )//Oblivion Curse gives a 2nd success chance after the 1st one passes which is reduceable. [Rytech] + if ( ssc->data[SC_POISONINGWEAPON]->val1 == 9 )// Oblivion Curse gives a 2nd success chance after the 1st one passes which is reducible. [Rytech] rate = 100 - tstatus->int_ * 4 / 5; sc_start(src, bl,ssc->data[SC_POISONINGWEAPON]->val2,rate,ssc->data[SC_POISONINGWEAPON]->val1,skill->get_time2(GC_POISONINGWEAPON,1) - (tstatus->vit + tstatus->luk) / 2 * 1000); status_change_end(src,SC_POISONINGWEAPON,-1); @@ -2775,8 +2777,8 @@ int skill_attack(int attack_type, struct block_list* src, struct block_list *dsr } /*========================================== - * sub fonction for recursive skill call. - * Checking bl battle flag and display dammage + * sub function for recursive skill call. + * Checking bl battle flag and display damage * then call func with source,target,skill_id,skill_lv,tick,flag *------------------------------------------*/ int skill_area_sub(struct block_list *bl, va_list ap) { @@ -2967,7 +2969,7 @@ int skill_check_condition_mercenary(struct block_list *bl, int skill_id, int lv, if( (idx = skill->get_index(skill_id)) == 0 ) return 0; - // Requeriments + // Requirements for( i = 0; i < ARRAYLENGTH(itemid); i++ ) { itemid[i] = skill->db[idx].itemid[i]; @@ -2989,7 +2991,7 @@ int skill_check_condition_mercenary(struct block_list *bl, int skill_id, int lv, else sp += (st->max_sp * (-sp_rate)) / 100; - if( bl->type == BL_HOM ) { // Intimacy Requeriments + if( bl->type == BL_HOM ) { // Intimacy Requirements struct homun_data *hd = BL_CAST(BL_HOM, bl); switch( skill_id ) { case HFLI_SBR44: @@ -3414,7 +3416,7 @@ int skill_castend_damage_id(struct block_list* src, struct block_list *bl, uint1 return 1; 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. + //GTB makes all targeted magic display miss with a single bolt. sc_type sct = status->skill2sc(skill_id); if(sct != SC_NONE) status_change_end(bl, sct, INVALID_TIMER); @@ -4054,7 +4056,7 @@ int skill_castend_damage_id(struct block_list* src, struct block_list *bl, uint1 skill->attack(BF_MISC,src,src,bl,skill_id,skill_lv,tick,flag); break; - // Celest + // [Celest] case PF_SOULBURN: if (rnd()%100 < (skill_lv < 5 ? 30 + skill_lv * 10 : 70)) { clif->skill_nodamage(src,bl,skill_id,skill_lv,1); @@ -4139,7 +4141,7 @@ int skill_castend_damage_id(struct block_list* src, struct block_list *bl, uint1 if( unit->movepos(src, bl->x+x, bl->y+y, 1, 1) ) { clif->slide(src,bl->x+x,bl->y+y); - clif->fixpos(src); // the official server send these two packts. + clif->fixpos(src); // the official server send these two packets. skill->attack(BF_WEAPON,src,src,bl,skill_id,skill_lv,tick,flag); if( rnd()%100 < 4 * skill_lv ) skill->castend_damage_id(src,bl,GC_CROSSIMPACT,skill_lv,tick,flag); @@ -4562,7 +4564,7 @@ int skill_castend_damage_id(struct block_list* src, struct block_list *bl, uint1 } break; - //recursive homon skill + // Recursive homun skill case MH_MAGMA_FLOW: case MH_HEILIGE_STANGE: if(flag & 1) @@ -4791,7 +4793,7 @@ int skill_castend_id(int tid, int64 tick, int id, intptr_t data) { && (sc = status->get_sc(target)) && sc->data[SC_FOGWALL] && rnd() % 100 < 75 ) { - //Fogwall makes all offensive-type targetted skills fail at 75% + // Fogwall makes all offensive-type targeted skills fail at 75% if (sd) clif->skill_fail(sd, ud->skill_id, USESKILL_FAIL_LEVEL, 0); break; } @@ -4842,8 +4844,8 @@ int skill_castend_id(int tid, int64 tick, int id, intptr_t data) { unit->stop_walking(src,1); if( !sd || sd->skillitem != ud->skill_id || skill->get_delay(ud->skill_id,ud->skill_lv) ) - ud->canact_tick = tick + skill->delay_fix(src, ud->skill_id, ud->skill_lv); //Tests show wings don't overwrite the delay but skill scrolls do. [Inkfish] - if (sd) { //Cooldown application + ud->canact_tick = tick + skill->delay_fix(src, ud->skill_id, ud->skill_lv); // Tests show wings don't overwrite the delay but skill scrolls do. [Inkfish] + if (sd) { // Cooldown application int i, cooldown = skill->get_cooldown(ud->skill_id, ud->skill_lv); for (i = 0; i < ARRAYLENGTH(sd->skillcooldown) && sd->skillcooldown[i].id; i++) { // Increases/Decreases cooldown of a skill by item/card bonuses. if (sd->skillcooldown[i].id == ud->skill_id){ @@ -4886,7 +4888,7 @@ int skill_castend_id(int tid, int64 tick, int id, intptr_t data) { // SC_MAGICPOWER needs to switch states before any damage is actually dealt skill->toggle_magicpower(src, ud->skill_id); - /* On aegis damage skills are also increase by camouflage. Need confirmation on kRo. + /* On aegis damage skills are also increase by camouflage. Need confirmation on kRO. if( ud->skill_id != RA_CAMOUFLAGE ) // only normal attack and auto cast skills benefit from its bonuses status_change_end(src,SC_CAMOUFLAGE, INVALID_TIMER); */ @@ -4983,7 +4985,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin int element = 0; enum sc_type type; - if(skill_id > 0 && !skill_lv) return 0; // celest + if(skill_id > 0 && !skill_lv) return 0; // [Celest] nullpo_retr(1, src); nullpo_retr(1, bl); @@ -5024,7 +5026,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin //Check for undead skills that convert a no-damage skill into a damage one. [Skotlex] switch (skill_id) { - case HLIF_HEAL: //[orn] + case HLIF_HEAL: // [orn] if (bl->type != BL_HOM) { if (sd) clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0) ; break ; @@ -5095,7 +5097,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin struct block_list *s_src = battle->get_master(src); short ret = 0; if(!skill->check_unit_range(src, src->x, src->y, skill_id, skill_lv)) //prevent reiteration - ret = skill->castend_pos2(src,src->x,src->y,skill_id,skill_lv,tick,flag); //cast on homon + ret = skill->castend_pos2(src,src->x,src->y,skill_id,skill_lv,tick,flag); //cast on homun if(s_src && !skill->check_unit_range(s_src, s_src->x, s_src->y, skill_id, skill_lv)) ret |= skill->castend_pos2(s_src,s_src->x,s_src->y,skill_id,skill_lv,tick,flag); //cast on master if (hd) @@ -5138,7 +5140,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin map->freeblock_lock(); switch(skill_id) { - case HLIF_HEAL: //[orn] + case HLIF_HEAL: // [orn] case AL_HEAL: /** * Arch Bishop @@ -5494,7 +5496,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin if (dstsd) { if(dstsd->status.weapon == W_FIST || (dstsd->sc.count && !dstsd->sc.data[type] && - ( //Allow re-enchanting to lenghten time. [Skotlex] + ( //Allow re-enchanting to lengthen time. [Skotlex] dstsd->sc.data[SC_PROPERTYFIRE] || dstsd->sc.data[SC_PROPERTYWATER] || dstsd->sc.data[SC_PROPERTYWIND] || @@ -5716,7 +5718,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin { int duration = skill->get_time(skill_id,skill_lv); clif->skill_nodamage(bl,bl,skill_id,skill_lv,sc_start(src,bl,type,100,skill_lv,duration)); // Master - clif->skill_nodamage(src,src,skill_id,skill_lv,sc_start(src,src,type,100,skill_lv,duration)); // Homunc + clif->skill_nodamage(src,src,skill_id,skill_lv,sc_start(src,src,type,100,skill_lv,duration)); // Homun } break; case NJ_BUNSINJYUTSU: @@ -6050,7 +6052,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin BF_MAGIC, src, src, skill_id, skill_lv, tick, flag, BCT_ENEMY); break; - case HVAN_EXPLOSION: //[orn] + case HVAN_EXPLOSION: // [orn] case NPC_SELFDESTRUCTION: { //Self Destruction hits everyone in range (allies+enemies) @@ -6183,7 +6185,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin return 0; } clif->skill_nodamage(src,bl,skill_id,skill_lv,sc_start4(src,bl,type,100,skill_lv,unit->getdir(bl),0,0,0)); - if (sd) // If the client receives a skill-use packet inmediately before a walkok packet, it will discard the walk packet! [Skotlex] + if (sd) // If the client receives a skill-use packet immediately before a walkok packet, it will discard the walk packet! [Skotlex] clif->walkok(sd); // So aegis has to resend the walk ok. break; case AS_CLOAKING: @@ -6419,7 +6421,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin case MC_IDENTIFY: if(sd) { clif->item_identify_list(sd); - if( sd->menuskill_id != MC_IDENTIFY ) {/* failed, dont consume anything, return */ + if( sd->menuskill_id != MC_IDENTIFY ) {/* failed, don't consume anything, return */ map->freeblock_unlock(); return 1; } @@ -6761,7 +6763,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin } clif->skill_nodamage(src,bl,skill_id,skill_lv,1); if((dstsd && (dstsd->class_&MAPID_UPPERMASK) == MAPID_SOUL_LINKER) - || (tsc && tsc->data[SC_SOULLINK] && tsc->data[SC_SOULLINK]->val2 == SL_ROGUE) //Rogue's spirit defends againt dispel. + || (tsc && tsc->data[SC_SOULLINK] && tsc->data[SC_SOULLINK]->val2 == SL_ROGUE) //Rogue's spirit defends against dispel. || (dstsd && pc_ismadogear(dstsd)) || rnd()%100 >= 50+10*skill_lv ) { @@ -7071,7 +7073,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin 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) - md->state.skillstate = MSS_WALK; //Otherwise it isn't updated in the ai. + md->state.skillstate = MSS_WALK; //Otherwise it isn't updated in the AI. } break; @@ -7137,14 +7139,14 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin 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] + int gain_hp = tstatus->max_hp*abs(hp_rate)/100; // The earned is the same % of the target HP than it cost 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] + int gain_sp = tstatus->max_sp*abs(sp_rate)/100;// The earned is the same % of the target SP than it cost the caster. [Skotlex] clif->skill_nodamage(src,bl,skill_id,status->heal(bl, 0, gain_sp, 0),1); } break; @@ -7248,7 +7250,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin // if it is already trapping something don't spring it, // remove trap should be used instead break; - // otherwise fallthrough to below + // otherwise fall through to below case UNT_BLASTMINE: case UNT_SKIDTRAP: case UNT_LANDMINE: @@ -7481,7 +7483,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin if (count == -1) count = 3; else - count++; //Should not retrigger this one. + count++; //Should not re-trigger this one. break; case 7: // stop freeze or stoned { @@ -7696,7 +7698,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin } break; - case AM_CALLHOMUN: //[orn] + case AM_CALLHOMUN: // [orn] if( sd ) { if (homun->call(sd)) clif->skill_nodamage(src, bl, skill_id, skill_lv, 1); @@ -7714,7 +7716,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin } break; - case HAMI_CASTLE: //[orn] + case HAMI_CASTLE: // [orn] if(rnd()%100 < 20*skill_lv && src != bl) { int x,y; @@ -7724,7 +7726,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin skill->blockhomun_start(hd, skill_id, skill->get_time2(skill_id,skill_lv)); if (unit->movepos(src,bl->x,bl->y,0,0)) { - clif->skill_nodamage(src,src,skill_id,skill_lv,1); // Homunc + clif->skill_nodamage(src,src,skill_id,skill_lv,1); // Homun clif->slide(src,bl->x,bl->y) ; if (unit->movepos(bl,x,y,0,0)) { @@ -7743,7 +7745,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin else if (sd) clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0); break; - case HVAN_CHAOTIC: //[orn] + case HVAN_CHAOTIC: // [orn] { static const int per[5][2]={{20,50},{50,60},{25,75},{60,64},{34,67}}; int r = rnd()%100; @@ -7764,7 +7766,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin status->heal(bl, hp, 0, 0); } break; - //Homun single-target support skills [orn] + // Homun single-target support skills [orn] case HAMI_BLOODLUST: case HFLI_FLEET: case HFLI_SPEED: @@ -8016,7 +8018,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin { // Every time the skill is casted the status change is reseted adding a counter. count += (short)tsc->data[SC_ROLLINGCUTTER]->val1; if( count > 10 ) - count = 10; // Max coounter + count = 10; // Max counter status_change_end(bl, SC_ROLLINGCUTTER, INVALID_TIMER); } sc_start(src,bl,SC_ROLLINGCUTTER,100,count,skill->get_time(skill_id,skill_lv)); @@ -8548,7 +8550,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin } if ( tsc && tsc->data[SC__UNLUCKY] && skill_id == SC_UNLUCKY) { //If the target was successfully inflected with the Unlucky status, give 1 of 3 random status's. - switch(rnd()%3) {//Targets in the Unlucky status will be affected by one of the 3 random status's reguardless of resistance. + switch(rnd()%3) {//Targets in the Unlucky status will be affected by one of the 3 random status's regardless of resistance. case 0: status->change_start(src,bl,SC_POISON,10000,skill_lv,0,0,0,skill->get_time(skill_id,skill_lv),10); break; @@ -8732,7 +8734,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin } else { int count = 0; clif->skill_damage(src, bl, tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6); - 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 + count = map->forcountinrange(skill->area_sub, src, skill->get_splash(skill_id,skill_lv), (sd)?sd->spiritball_old:15, // Assume 15 spiritballs in non-characters 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, @@ -8921,7 +8923,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin sc_start(src, bl, type, 100, skill_lv,skill->get_time(skill_id, skill_lv)); if ( madnesscheck >= 8 )//The god of madness deals 9999 fixed unreduceable damage when 8 or more enemy players are affected. status_fix_damage(src, bl, 9999, clif->damage(src, bl, 0, 0, 9999, 0, 0, 0)); - //skill->attack(BF_MISC,src,src,bl,skillid,skilllv,tick,flag);//To renable when I can confirm it deals damage like this. Data shows its dealed as reflected damage which I dont have it coded like that yet. [Rytech] + //skill->attack(BF_MISC,src,src,bl,skillid,skilllv,tick,flag);//To renable when I can confirm it deals damage like this. Data shows its dealt as reflected damage which I don't have it coded like that yet. [Rytech] } else if( sd ) { int rate = sstatus->int_ / 6 + (sd? sd->status.job_level:0) / 5 + skill_lv * 4; if ( rnd()%100 < rate ) { @@ -9047,7 +9049,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin if( sd ) { int elemental_class = skill->get_elemental_type(skill_id,skill_lv); - // Remove previous elemental fisrt. + // Remove previous elemental first. if( sd->ed ) elemental->delete(sd->ed,0); @@ -9070,7 +9072,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin elemental->delete(sd->ed, 0); break; } - switch( skill_lv ) {// Select mode bassed on skill level used. + switch( skill_lv ) {// Select mode based on skill level used. case 2: mode = EL_MODE_ASSIST; break; case 3: mode = EL_MODE_AGGRESSIVE; break; } @@ -9847,7 +9849,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui int r; //if(skill_lv <= 0) return 0; - if(skill_id > 0 && !skill_lv) return 0; // celest + if(skill_id > 0 && !skill_lv) return 0; // [Celest] nullpo_ret(src); @@ -10153,7 +10155,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui int class_ = skill_id==AM_SPHEREMINE?1142:summons[skill_lv-1]; struct mob_data *md; - // Correct info, don't change any of this! [celest] + // Correct info, don't change any of this! [Celest] md = mob->once_spawn_sub(src, src->m, x, y, status->get_name(src), class_, "", SZ_MEDIUM, AI_NONE); if (md) { md->master_id = src->id; @@ -10293,7 +10295,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui sc_start(src,src,type,100,skill_lv,skill->get_time2(skill_id,skill_lv)); break; - case AM_RESURRECTHOMUN: //[orn] + case AM_RESURRECTHOMUN: // [orn] if (sd) { if (!homun->ressurect(sd, 20*skill_lv, x, y)) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); @@ -11871,7 +11873,7 @@ int skill_unit_onplace_timer(struct skill_unit *src, struct block_list *bl, int6 case UNT_POISONSMOKE: if( battle->check_target(ss,bl,BCT_ENEMY) > 0 && !(tsc && tsc->data[sg->val2]) && rnd()%100 < 50 ) { short rate = 100; - if ( sg->val1 == 9 )//Oblivion Curse gives a 2nd success chance after the 1st one passes which is reduceable. [Rytech] + if ( sg->val1 == 9 )//Oblivion Curse gives a 2nd success chance after the 1st one passes which is reducible. [Rytech] rate = 100 - tstatus->int_ * 4 / 5 ; sc_start(ss,bl,sg->val2,rate,sg->val1,skill->get_time2(GC_POISONINGWEAPON,1) - (tstatus->vit + tstatus->luk) / 2 * 1000); } @@ -11906,7 +11908,7 @@ int skill_unit_onplace_timer(struct skill_unit *src, struct block_list *bl, int6 case UNT_STEALTHFIELD: if( bl->id == sg->src_id ) - break; // Dont work on Self (video shows that) + break; // Don't work on Self (video shows that) case UNT_NEUTRALBARRIER: sc_start(ss,bl,type,100,sg->skill_lv,sg->interval + 100); break; @@ -12188,8 +12190,8 @@ int skill_unit_onleft(uint16 skill_id, struct block_list *bl, int64 tick) { //We don't check for SC_LONGING because someone could always have knocked you back and out of the song/dance. //FIXME: This code is not perfect, it doesn't checks for the real ensemble's owner, //it only checks if you are doing the same ensemble. So if there's two chars doing an ensemble - //which overlaps, by stepping outside of the other parther's ensemble will cause you to cancel - //your own. Let's pray that scenario is pretty unlikely and noone will complain too much about it. + //which overlaps, by stepping outside of the other partner's ensemble will cause you to cancel + //your own. Let's pray that scenario is pretty unlikely and none will complain too much about it. status_change_end(bl, SC_DANCING, INVALID_TIMER); } case MH_STEINWAND: @@ -12235,7 +12237,7 @@ int skill_unit_onleft(uint16 skill_id, struct block_list *bl, int64 tick) { if (sce) { status_change_end(bl, type, INVALID_TIMER); if ((sce=sc->data[SC_BLIND])) { - if (bl->type == BL_PC) //Players get blind ended inmediately, others have it still for 30 secs. [Skotlex] + if (bl->type == BL_PC) //Players get blind ended immediately, others have it still for 30 secs. [Skotlex] status_change_end(bl, SC_BLIND, INVALID_TIMER); else { timer->delete(sce->timer, status->change_timer); @@ -12683,7 +12685,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id case BS_GREED: clif->skill_fail(sd,skill_id,USESKILL_FAIL_MADOGEAR,0); return 0; - default: //Only Mechanic exlcusive skill can be used. + default: //Only Mechanic exclusive skill can be used. break; } } @@ -12996,7 +12998,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id return 0; } break; - case AM_REST: //Can't vapo homun if you don't have an active homunc or it's hp is < 80% + case AM_REST: //Can't vapo homun if you don't have an active homun or it's hp is < 80% if (!homun_alive(sd->hd) || sd->hd->battle_status.hp < (sd->hd->battle_status.max_hp*80/100)) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); @@ -13433,7 +13435,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id // There's no need to check if the skill is part of a combo if it's // already been checked before, see unit_skilluse_id2 [Panikon] - // Note that if this check is readded part of issue:8047 will reapear! + // Note that if this check is read part of issue:8047 will reappear! //if( sd->sc.data[SC_COMBOATTACK] && !skill->is_combo(skill_id ) ) // return 0; @@ -13681,7 +13683,7 @@ int skill_consume_requirement( struct map_session_data *sd, uint16 skill_id, uin continue; if( itemid_isgemstone(req.itemid[i]) && skill_id != HW_GANBANTEIN && sc && sc->data[SC_SOULLINK] && sc->data[SC_SOULLINK]->val2 == SL_WIZARD ) - continue; //Gemstones are checked, but not substracted from inventory. + continue; //Gemstones are checked, but not subtracted from inventory. switch( skill_id ){ case SA_SEISMICWEAPON: @@ -13876,7 +13878,7 @@ struct skill_condition skill_get_requirement(struct map_session_data* sd, uint16 if( itemid_isgemstone(req.itemid[i]) && skill_id != HW_GANBANTEIN ) { if( sd->special_state.no_gemstone ) - { // All gem skills except Hocus Pocus and Ganbantein can cast for free with Mistress card -helvetica + { // All gem skills except Hocus Pocus and Ganbantein can cast for free with Mistress card [helvetica] if( skill_id != SA_ABRACADABRA ) req.itemid[i] = req.amount[i] = 0; else if( --req.amount[i] < 1 ) @@ -15033,7 +15035,7 @@ int skill_cell_overlap(struct block_list *bl, va_list ap) { if( su == NULL || su->group == NULL || (*alive) == 0 ) return 0; - if( su->group->state.guildaura ) /* guild auras are not cancelled! */ + if( su->group->state.guildaura ) /* guild auras are not canceled! */ return 0; switch (skill_id) { @@ -15484,7 +15486,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 + if( group->val2 ) { // Someone Trapped 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 @@ -15631,7 +15633,7 @@ int skill_delunitgroup(struct skill_unit_group *group, const char* file, int lin 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] + sc->data[SC_DANCING]->val2 = 0 ; //This prevents status_change_end attempting to re-delete the group. [Skotlex] status_change_end(src, SC_DANCING, INVALID_TIMER); } } @@ -16013,7 +16015,7 @@ int skill_unit_timer_sub(DBKey key, DBData *data, va_list ap) { return 0; } /*========================================== - * Executes on all skill units every SKILLUNITTIMER_INTERVAL miliseconds. + * Executes on all skill units every SKILLUNITTIMER_INTERVAL milliseconds. *------------------------------------------*/ int skill_unit_timer(int tid, int64 tick, int id, intptr_t data) { map->freeblock_lock(); @@ -16420,7 +16422,7 @@ int skill_produce_mix(struct map_session_data *sd, uint16 skill_id, int nameid, make_per = 100000; // Star Crumbs are 100% success crafting rate? (made 1000% so it succeeds even after penalties) [Skotlex] break; default: // Enchanted Stones - make_per += 1000+i*500; // Enchantedstone Craft bonus: +15/+20/+25/+30/+35 + make_per += 1000+i*500; // Enchanted stone Craft bonus: +15/+20/+25/+30/+35 break; } break; @@ -16468,7 +16470,7 @@ int skill_produce_mix(struct map_session_data *sd, uint16 skill_id, int nameid, case ITEMID_COATING_BOTTLE: make_per -= (1+rnd()%100)*10; break; - //Common items, recieve no bonus or penalty, listed just because they are commonly produced + //Common items, receive no bonus or penalty, listed just because they are commonly produced case ITEMID_BLUE_POTION: case ITEMID_RED_SLIM_POTION: case ITEMID_ANODYNE: @@ -17371,7 +17373,7 @@ int skill_blockpc_start_(struct map_session_data *sd, uint16 skill_id, int tick) return 0; } -int skill_blockhomun_end(int tid, int64 tick, int id, intptr_t data) { //[orn] +int skill_blockhomun_end(int tid, int64 tick, int id, intptr_t data) { // [orn] struct homun_data *hd = (TBL_HOM*)map->id2bl(id); if (data <= 0 || data >= MAX_SKILL) return 0; @@ -17380,7 +17382,7 @@ int skill_blockhomun_end(int tid, int64 tick, int id, intptr_t data) { //[orn] return 1; } -int skill_blockhomun_start(struct homun_data *hd, uint16 skill_id, int tick) { //[orn] +int skill_blockhomun_start(struct homun_data *hd, uint16 skill_id, int tick) { // [orn] uint16 idx = skill->get_index(skill_id); nullpo_retr (-1, hd); @@ -17396,7 +17398,7 @@ int skill_blockhomun_start(struct homun_data *hd, uint16 skill_id, int tick) { / return timer->add(timer->gettick() + tick, skill->blockhomun_end, hd->bl.id, idx); } -int skill_blockmerc_end(int tid, int64 tick, int id, intptr_t data) {//[orn] +int skill_blockmerc_end(int tid, int64 tick, int id, intptr_t data) {// [orn] struct mercenary_data *md = (TBL_MER*)map->id2bl(id); if( data <= 0 || data >= MAX_SKILL ) return 0; @@ -17984,7 +17986,7 @@ bool skill_parse_row_requiredb(char* split[], int columns, int current) { 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 + //Which weapon type are required, see doc/item_db for types p = split[7]; for( j = 0; j < 32; j++ ) { int l = atoi(p); @@ -18481,7 +18483,7 @@ void skill_defaults(void) { memset(&skill->area_temp,0,sizeof(skill->area_temp)); memset(&skill->unit_temp,0,sizeof(skill->unit_temp)); skill->unit_group_newid = 0; - /* accesssors */ + /* accessors */ skill->get_index = skill_get_index; skill->get_type = skill_get_type; skill->get_hit = skill_get_hit; diff --git a/src/map/status.c b/src/map/status.c index a716b8913..d05341683 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -1121,8 +1121,8 @@ int status_charge(struct block_list* bl, int64 hp, int64 sp) { } //Inflicts damage on the target with the according walkdelay. -//If flag&1, damage is passive and does not triggers cancelling status changes. -//If flag&2, fail if target does not has enough to substract. +//If flag&1, damage is passive and does not triggers canceling status changes. +//If flag&2, fail if target does not has enough to subtract. //If flag&4, if killed, mob must not give exp/loot. //flag will be set to &8 when damaging sp of a dead character int status_damage(struct block_list *src,struct block_list *target,int64 in_hp, int64 in_sp, int walkdelay, int flag) { @@ -1269,7 +1269,7 @@ int status_damage(struct block_list *src,struct block_list *target,int64 in_hp, st->hp = 1; //To let the dead function cast skills and all that. //NOTE: These dead functions should return: [Skotlex] - //0: Death cancelled, auto-revived. + //0: Death canceled, auto-revived. //Non-zero: Standard death. Clear status, cancel move/attack, etc //&2: Also remove object from map. //&4: Also delete object from memory. @@ -1284,7 +1284,7 @@ int status_damage(struct block_list *src,struct block_list *target,int64 in_hp, break; } - if(!flag) //Death cancelled. + if(!flag) //Death canceled. return (int)(hp+sp); //Normal death @@ -1429,7 +1429,7 @@ int status_heal(struct block_list *bl,int64 in_hp,int64 in_sp, int flag) { //If rates are > 0, percent is of current HP/SP //If rates are < 0, percent is of max HP/SP //If !flag, this is heal, otherwise it is damage. -//Furthermore, if flag==2, then the target must not die from the substraction. +//Furthermore, if flag==2, then the target must not die from the subtraction. int status_percent_change(struct block_list *src,struct block_list *target,signed char hp_rate, signed char sp_rate, int flag) { struct status_data *st; unsigned int hp = 0, sp = 0; @@ -1633,11 +1633,11 @@ int status_check_skilluse(struct block_list *src, struct block_list *target, uin if( sc && sc->count ) { - if (skill_id != RK_REFRESH && sc->opt1 >0 && !(sc->opt1 == OPT1_CRYSTALIZE && src->type == BL_MOB) && sc->opt1 != OPT1_BURNING && skill_id != SR_GENTLETOUCH_CURE) { //Stuned/Frozen/etc + if (skill_id != RK_REFRESH && sc->opt1 >0 && !(sc->opt1 == OPT1_CRYSTALIZE && src->type == BL_MOB) && sc->opt1 != OPT1_BURNING && skill_id != SR_GENTLETOUCH_CURE) { //Stunned/Frozen/etc if (flag != 1) //Can't cast, casted stuff can't damage. return 0; if (!(skill->get_inf(skill_id)&INF_GROUND_SKILL)) - return 0; //Targetted spells can't come off. + return 0; //Targeted spells can't come off. } if ( @@ -1782,7 +1782,7 @@ int status_check_skilluse(struct block_list *src, struct block_list *target, uin if( ( tsc->data[SC_STEALTHFIELD] || tsc->data[SC_CAMOUFLAGE] ) && !(st->mode&(MD_BOSS|MD_DETECTOR)) && flag == 4 ) return 0; } - //If targetting, cloak+hide protect you, otherwise only hiding does. + //If targeting, cloak+hide protect you, otherwise only hiding does. hide_flag = flag?OPTION_HIDE:(OPTION_HIDE|OPTION_CLOAK|OPTION_CHASEWALK); //You cannot hide from ground skills. @@ -1815,7 +1815,7 @@ int status_check_skilluse(struct block_list *src, struct block_list *target, uin } } break; - case BL_ITEM: //Allow targetting of items to pick'em up (or in the case of mobs, to loot them). + case BL_ITEM: //Allow targeting of items to pick'em up (or in the case of mobs, to loot them). //TODO: Would be nice if this could be used to judge whether the player can or not pick up the item it targets. [Skotlex] if (st->mode&MD_LOOTER) return 1; @@ -1891,7 +1891,7 @@ int status_base_amotion_pc(struct map_session_data *sd, struct status_data *st) #ifdef RENEWAL_ASPD short mod = -1; - switch( sd->weapontype2 ){ // adjustment for dual weilding + switch( sd->weapontype2 ){ // adjustment for dual wielding case W_DAGGER: mod = 0; break; // 0, 1, 1 case W_1HSWORD: case W_1HAXE: mod = 1; @@ -2555,7 +2555,7 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) { return 1; } - // sanitize the refine level in case someone decreased the value inbetween + // sanitize the refine level in case someone decreased the value in between if (sd->status.inventory[index].refine > MAX_REFINE) sd->status.inventory[index].refine = MAX_REFINE; @@ -2583,7 +2583,7 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) { wa->matk += status->refine_info[wlv].bonus[r-1] / 100; #endif - //Overrefine bonus. + //Overrefined bonus. if (r) wd->overrefine = status->refine_info[wlv].randombonus_max[r-1] / 100; diff --git a/src/map/status.h b/src/map/status.h index 32bef4df8..b08aa2a04 100644 --- a/src/map/status.h +++ b/src/map/status.h @@ -21,7 +21,7 @@ struct pet_data; //Change the equation when the values are high enough to discard the //imprecision in exchange of overflow protection [Skotlex] //Also add 100% checks since those are the most used cases where we don't -//want aproximation errors. +//want approximation errors. #define APPLY_RATE(value, rate) ( \ (rate) == 100 ? \ (value) \ diff --git a/src/map/storage.c b/src/map/storage.c index 2db5fff3d..fad23d770 100644 --- a/src/map/storage.c +++ b/src/map/storage.c @@ -544,7 +544,7 @@ int storage_guild_storageadd(struct map_session_data* sd, int index, int amount) * @index : storage idx * return * 0 : fail -* 1 : succes +* 1 : success *------------------------------------------*/ int storage_guild_storageget(struct map_session_data* sd, int index, int amount) { @@ -585,7 +585,7 @@ int storage_guild_storageget(struct map_session_data* sd, int index, int amount) * @index : cart inventory idx * return * 0 : fail -* 1 : succes +* 1 : success *------------------------------------------*/ int storage_guild_storageaddfromcart(struct map_session_data* sd, int index, int amount) { @@ -617,7 +617,7 @@ int storage_guild_storageaddfromcart(struct map_session_data* sd, int index, int * @index : storage idx * return * 0 : fail -* 1 : succes +* 1 : success *------------------------------------------*/ int storage_guild_storagegettocart(struct map_session_data* sd, int index, int amount) { @@ -648,7 +648,7 @@ int storage_guild_storagegettocart(struct map_session_data* sd, int index, int a * Request to save guild storage * return * 0 : fail (no storage) -* 1 : succes +* 1 : success *------------------------------------------*/ int storage_guild_storagesave(int account_id, int guild_id, int flag) { @@ -669,7 +669,7 @@ int storage_guild_storagesave(int account_id, int guild_id, int flag) * ACK save of guild storage * return * 0 : fail (no storage) -* 1 : succes +* 1 : success *------------------------------------------*/ int storage_guild_storagesaved(int guild_id) { diff --git a/src/map/trade.c b/src/map/trade.c index 83426c407..8bb47e0cb 100644 --- a/src/map/trade.c +++ b/src/map/trade.c @@ -61,7 +61,7 @@ void trade_traderequest(struct map_session_data *sd, struct map_session_data *ta if( previous_sd ){ previous_sd->trade_partner = 0; clif->tradecancelled(previous_sd); - } // Once cancelled then continue to the new one. + } // Once canceled then continue to the new one. sd->trade_partner = 0; clif->tradecancelled(sd); } @@ -169,7 +169,7 @@ void trade_tradeack(struct map_session_data *sd, int type) { /*========================================== * Check here hacker for duplicate item in trade * normal client refuse to have 2 same types of item (except equipment) in same trade window - * normal client authorise only no equiped item and only from inventory + * normal client authorize only no equipped item and only from inventory *------------------------------------------*/ int impossible_trade_check(struct map_session_data *sd) { @@ -187,9 +187,9 @@ int impossible_trade_check(struct map_session_data *sd) // get inventory of player memcpy(&inventory, &sd->status.inventory, sizeof(struct item) * MAX_INVENTORY); - // remove this part: arrows can be trade and equiped + // remove this part: arrows can be trade and equipped // re-added! [celest] - // remove equiped items (they can not be trade) + // remove equipped items (they can not be trade) for (i = 0; i < MAX_INVENTORY; i++) if (inventory[i].nameid > 0 && inventory[i].equip && !(inventory[i].equip & EQP_AMMO)) memset(&inventory[i], 0, sizeof(struct item)); @@ -457,7 +457,7 @@ void trade_tradeok(struct map_session_data *sd) { } /*========================================== - * 'Cancel' is pressed. (or trade was force-cancelled by the code) + * 'Cancel' is pressed. (or trade was force-canceled by the code) *------------------------------------------*/ void trade_tradecancel(struct map_session_data *sd) { struct map_session_data *target_sd; @@ -466,7 +466,7 @@ void trade_tradecancel(struct map_session_data *sd) { target_sd = map->id2sd(sd->trade_partner); if(!sd->state.trading) - { // Not trade acepted + { // Not trade accepted if( target_sd ) { target_sd->trade_partner = 0; clif->tradecancelled(target_sd); diff --git a/src/map/unit.c b/src/map/unit.c index e22d6f697..95feb2a1d 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -244,7 +244,7 @@ int unit_walktoxy_timer(int tid, int64 tick, int id, intptr_t data) { { if (!(ud->skill_id == NPC_SELFDESTRUCTION && ud->skilltimer != INVALID_TIMER)) { //Skill used, abort walking - clif->fixpos(bl); //Fix position as walk has been cancelled. + clif->fixpos(bl); //Fix position as walk has been canceled. return 0; } //Resend walk packet for proper Self Destruction display. @@ -869,7 +869,7 @@ int unit_stop_walking(struct block_list *bl,int type) return 0; //NOTE: We are using timer data after deleting it because we know the //timer->delete function does not messes with it. If the function's - //behaviour changes in the future, this code could break! + //behavior changes in the future, this code could break! td = timer->get(ud->walktimer); timer->delete(ud->walktimer, unit->walktoxy_timer); ud->walktimer = INVALID_TIMER; @@ -892,7 +892,7 @@ int unit_stop_walking(struct block_list *bl,int type) if(bl->type == BL_PET && type&~0xff) ud->canmove_tick = timer->gettick() + (type>>8); - //Readded, the check in unit_set_walkdelay means dmg during running won't fall through to this place in code [Kevin] + //Read, the check in unit_set_walkdelay means dmg during running won't fall through to this place in code [Kevin] if (ud->state.running) { status_change_end(bl, SC_RUN, INVALID_TIMER); status_change_end(bl, SC_WUGDASH, INVALID_TIMER); @@ -1250,7 +1250,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui if (!temp) //Stop attack on non-combo skills [Skotlex] unit->stop_attack(src); - else if(ud->attacktimer != INVALID_TIMER) //Elsewise, delay current attack sequence + else if(ud->attacktimer != INVALID_TIMER) //Else-wise, delay current attack sequence ud->attackabletime = tick + status_get_adelay(src); ud->state.skillcastcancel = castcancel; @@ -1366,7 +1366,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui } if(!ud->state.running) //need TK_RUN or WUGDASH handler to be done before that, see bugreport:6026 - unit->stop_walking(src,1);// eventhough this is not how official works but this will do the trick. bugreport:6829 + unit->stop_walking(src,1);// even though this is not how official works but this will do the trick. bugreport:6829 // in official this is triggered even if no cast time. clif->skillcasting(src, src->id, target_id, 0,0, skill_id, skill->get_ele(skill_id, skill_lv), casttime); @@ -1375,7 +1375,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui if (sd && target->type == BL_MOB) { TBL_MOB *md = (TBL_MOB*)target; - mob->skill_event(md, src, tick, -1); //Cast targetted skill event. + mob->skill_event(md, src, tick, -1); //Cast targeted skill event. if (tstatus->mode&(MD_CASTSENSOR_IDLE|MD_CASTSENSOR_CHASE) && battle->check_target(target, src, BCT_ENEMY) > 0) { @@ -1470,7 +1470,7 @@ int unit_skilluse_pos2( struct block_list *src, short skill_x, short skill_y, ui if( skill->not_ok(skill_id, sd) || !skill->check_condition_castbegin(sd, skill_id, skill_lv) ) return 0; /** - * "WHY IS IT HEREE": pneuma cannot be cancelled past this point, the client displays the animation even, + * "WHY IS IT HEREE": pneuma cannot be canceled 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 && map->getcell(src->m, skill_x, skill_y, CELL_CHKLANDPROTECTOR) ) { @@ -1648,7 +1648,7 @@ int unit_attack(struct block_list *src,int target_id,int continuous) { ud->state.attack_continue = continuous; unit->set_target(ud, target_id); - if (continuous) //If you're to attack continously, set to auto-case character + if (continuous) //If you're to attack continuously, set to auto-case character ud->chaserange = status_get_range(src); //Just change target/type. [Skotlex] @@ -1938,7 +1938,7 @@ int unit_attack_timer(int tid, int64 tick, int id, intptr_t data) { /*========================================== * Cancels an ongoing skill cast. * flag&1: Cast-Cancel invoked. - * flag&2: Cancel only if skill is cancellable. + * flag&2: Cancel only if skill is can be cancel. *------------------------------------------*/ int unit_skillcastcancel(struct block_list *bl,int type) { @@ -1954,7 +1954,7 @@ int unit_skillcastcancel(struct block_list *bl,int type) sd = BL_CAST(BL_PC, bl); if (type&2) { - //See if it can be cancelled. + //See if it can be canceled. if (!ud->state.skillcastcancel) return 0; @@ -2057,7 +2057,7 @@ int unit_changeviewsize(struct block_list *bl,short size) /*========================================== * Removes a bl/ud from the map. * 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. + * if clrtype is 1 (death), appropriate cleanup is performed. * Otherwise it is assumed bl is being warped. * On-Kill specific stuff is not performed here, look at status->damage for that. *------------------------------------------*/ diff --git a/src/map/vending.h b/src/map/vending.h index a70726374..b65e888e3 100644 --- a/src/map/vending.h +++ b/src/map/vending.h @@ -13,8 +13,8 @@ struct s_search_store_search; struct s_vending { short index; //cart index (return item data) - short amount; //amout of the item for vending - unsigned int value; //at wich price + short amount; //amount of the item for vending + unsigned int value; //at which price }; struct vending_interface { -- cgit v1.2.3-70-g09d2 From b791b665c87589548c9c57afbe0fe50ec7c32676 Mon Sep 17 00:00:00 2001 From: Haru <haru@dotalux.com> Date: Sat, 2 Aug 2014 20:58:22 +0200 Subject: Fixed several issues with SO_EL_SYMPATHY - Corrected an issue that caused the elemental's HP and SP would _decrease to_ summon_level*5% instead of _increasing by_ said amount. - Corrected an issue that decreased the SP cost of summon elemental skills by 5% even when the Spirit Sympathy skill wasn't present. - Added/renamed some variables to prevent confusion. Please don't reuse 'i' variables for things that aren't array indices. Or don't reuse variables altogether for different purposes than their original one. - Special thanks to Kisuka. Signed-off-by: Haru <haru@dotalux.com> --- src/map/elemental.c | 62 ++++++++++++++++++++++++++++------------------------- src/map/skill.c | 6 +++++- 2 files changed, 38 insertions(+), 30 deletions(-) (limited to 'src/map/elemental.c') diff --git a/src/map/elemental.c b/src/map/elemental.c index 7ffeea410..caba02692 100644 --- a/src/map/elemental.c +++ b/src/map/elemental.c @@ -64,7 +64,7 @@ struct view_data * elemental_get_viewdata(int class_) { int elemental_create(struct map_session_data *sd, int class_, unsigned int lifetime) { struct s_elemental ele; struct s_elemental_db *db; - int i; + int i, summon_level, skill_level; nullpo_retr(1,sd); @@ -77,63 +77,67 @@ int elemental_create(struct map_session_data *sd, int class_, unsigned int lifet ele.char_id = sd->status.char_id; ele.class_ = class_; ele.mode = EL_MODE_PASSIVE; // Initial mode - i = db->status.size+1; // summon level + summon_level = 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] - ele.hp = ele.max_hp = (sd->battle_status.max_hp/3 + sd->battle_status.int_*10 + sd->status.job_level) * ((i + 2) / 3); + ele.hp = ele.max_hp = (sd->battle_status.max_hp/3 + sd->battle_status.int_*10 + sd->status.job_level) * ((summon_level + 2) / 3); //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 ] - ele.atk = (sd->battle_status.max_sp / (18 / i) * 1 - 100); + ele.atk = (sd->battle_status.max_sp / (18 / summon_level) * 1 - 100); //Caster's [ Max SP / (18 / Elemental Summon Skill Level) ] ele.atk2 = sd->battle_status.max_sp / 18; //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)] - ele.matk = i * (sd->battle_status.int_ / 2 + sd->battle_status.dex / 4); + ele.matk = summon_level * (sd->battle_status.int_ / 2 + sd->battle_status.dex / 4); //150 + [Caster's DEX / 10] + [Elemental Summon Skill Level x 3 ] - ele.amotion = 150 + sd->battle_status.dex / 10 + i * 3; + ele.amotion = 150 + sd->battle_status.dex / 10 + summon_level * 3; //Caster's DEF + (Caster's Base Level / (5 - Elemental Summon Skill Level) - ele.def = sd->battle_status.def + sd->status.base_level / (5-i); + ele.def = sd->battle_status.def + sd->status.base_level / (5-summon_level); //Caster's MDEF + (Caster's INT / (5 - Elemental Summon Skill Level) - ele.mdef = sd->battle_status.mdef + sd->battle_status.int_ / (5-i); + ele.mdef = sd->battle_status.mdef + sd->battle_status.int_ / (5-summon_level); //Caster's FLEE + (Caster's Base Level / (5 - Elemental Summon Skill Level) - ele.flee = sd->status.base_level / (5-i); + ele.flee = sd->status.base_level / (5-summon_level); //Caster's HIT + (Caster's Base Level) ele.hit = sd->battle_status.hit + sd->status.base_level; //per individual bonuses switch(db->class_){ - case 2114: case 2115: + case 2114: + case 2115: case 2116: //ATK + (Summon Agni Skill Level x 20) / HIT + (Summon Agni Skill Level x 10) - ele.atk += i * 20; - ele.atk2 += i * 20; - ele.hit += i * 10; + ele.atk += summon_level * 20; + ele.atk2 += summon_level * 20; + ele.hit += summon_level * 10; break; - case 2117: case 2118: + case 2117: + case 2118: case 2119: //MDEF + (Summon Aqua Skill Level x 10) / MATK + (Summon Aqua Skill Level x 20) - ele.mdef += i * 10; - ele.matk += i * 20; + ele.mdef += summon_level * 10; + ele.matk += summon_level * 20; break; - case 2120: case 2121: + case 2120: + case 2121: case 2122: //FLEE + (Summon Ventus Skill Level x 20) / MATK + (Summon Ventus Skill Level x 10) - ele.flee += i * 20; - ele.matk += i * 10; + ele.flee += summon_level * 20; + ele.matk += summon_level * 10; break; - case 2123: case 2124: + case 2123: + case 2124: case 2125: //DEF + (Summon Tera Skill Level x 25) / ATK + (Summon Tera Skill Level x 5) - ele.def += i * 25; - ele.atk += i * 5; - ele.atk2 += i * 5; + ele.def += summon_level * 25; + ele.atk += summon_level * 5; + ele.atk2 += summon_level * 5; break; } - if( (i=pc->checkskill(sd,SO_EL_SYMPATHY)) > 0 ){ - ele.hp = ele.max_hp = ele.max_hp * 5 * i / 100; - ele.sp = ele.max_sp = ele.max_sp * 5 * i / 100; - ele.atk += 25 * i; - ele.atk2 += 25 * i; - ele.matk += 25 * i; + if ((skill_level=pc->checkskill(sd,SO_EL_SYMPATHY)) > 0) { + ele.hp = ele.max_hp += ele.max_hp * 5 * skill_level / 100; + ele.sp = ele.max_sp += ele.max_sp * 5 * skill_level / 100; + ele.atk += 25 * skill_level; + ele.atk2 += 25 * skill_level; + ele.matk += 25 * skill_level; } ele.life_time = lifetime; diff --git a/src/map/skill.c b/src/map/skill.c index c744dbde4..e16cb0cc7 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -14043,7 +14043,11 @@ struct skill_condition skill_get_requirement(struct map_session_data* sd, uint16 case SO_SUMMON_AQUA: case SO_SUMMON_VENTUS: case SO_SUMMON_TERA: - req.sp -= req.sp * (5 + 5 * pc->checkskill(sd,SO_EL_SYMPATHY)) / 100; + { + int spirit_sympathy = pc->checkskill(sd,SO_EL_SYMPATHY); + if (spirit_sympathy) + req.sp -= req.sp * (5 + 5 * spirit_sympathy) / 100; + } break; case SO_PSYCHIC_WAVE: if( sc && (sc->data[SC_HEATER_OPTION] || sc->data[SC_COOLER_OPTION] || sc->data[SC_BLAST_OPTION] || sc->data[SC_CURSED_SOIL_OPTION] )) -- cgit v1.2.3-70-g09d2