diff --git a/src/map/atcommand.cpp b/src/map/atcommand.cpp index ef821c6487..5495e120c5 100644 --- a/src/map/atcommand.cpp +++ b/src/map/atcommand.cpp @@ -6249,7 +6249,6 @@ ACMD_FUNC(useskill) *------------------------------------------*/ ACMD_FUNC(displayskill) { - struct status_data * status; t_tick tick; uint16 skill_id; uint16 skill_lv = 1; @@ -6262,7 +6261,8 @@ ACMD_FUNC(displayskill) clif_displaymessage(fd, msg_txt(sd,825));// Effect Types: 0: All, 1: Damage, 2: Splash Dmg, 3: No Damage, 4: Ground return -1; } - status = status_get_status_data(&sd->bl); + + status_data* status = status_get_status_data(sd->bl); tick = gettick(); if (type == 0 || type == 1) clif_skill_damage(&sd->bl, &sd->bl, tick, status->amotion, status->dmotion, 1, 1, skill_id, skill_lv, DMG_SINGLE); @@ -8181,7 +8181,6 @@ ACMD_FUNC(homtalk) ACMD_FUNC(hominfo) { struct homun_data *hd; - struct status_data *status; nullpo_retr(-1, sd); if ( !hom_is_active(sd->hd) ) { @@ -8190,7 +8189,7 @@ ACMD_FUNC(hominfo) } hd = sd->hd; - status = status_get_status_data(&hd->bl); + status_data* status = status_get_status_data(hd->bl); clif_displaymessage(fd, msg_txt(sd,1261)); // Homunculus stats: snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1262), // HP: %d/%d - SP: %d/%d diff --git a/src/map/battle.cpp b/src/map/battle.cpp index 43d5a78d2d..9b5854ee65 100644 --- a/src/map/battle.cpp +++ b/src/map/battle.cpp @@ -161,7 +161,7 @@ static int battle_getenemy_sub(struct block_list *bl, va_list ap) if (*c >= 24) return 0; - if (status_isdead(bl)) + if (status_isdead(*bl)) return 0; if (battle_check_target(target, bl, BCT_ENEMY) > 0) { @@ -219,7 +219,7 @@ static int battle_getenemyarea_sub(struct block_list *bl, va_list ap) if( *c >= 23 ) return 0; - if( status_isdead(bl) ) + if( status_isdead(*bl) ) return 0; if( battle_check_target(src, bl, BCT_ENEMY) > 0 ) {// Is Enemy!... @@ -286,7 +286,7 @@ int battle_damage(struct block_list *src, struct block_list *target, int64 damag dmg_change = status_damage(src, target, damage, 0, delay, 16, skill_id); // Coma attack else dmg_change = status_fix_damage(src, target, damage, delay, skill_id); - if (attack_type && !status_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, tick); if (dmg_lv > ATK_BLOCK && attack_type && additional_effects) skill_counter_additional_effect(src, target, skill_id, skill_lv, attack_type, tick); @@ -296,7 +296,7 @@ int battle_damage(struct block_list *src, struct block_list *target, int64 damag if (md != nullptr) { // Trigger monster skill condition for non-skill attacks. - if (!status_isdead(target) && src != target) { + if (!status_isdead(*target) && src != target) { if (damage > 0) mobskill_event(md, src, tick, attack_type, damage); if (skill_id > 0) @@ -335,7 +335,7 @@ TIMER_FUNC(battle_delay_damage_sub){ struct block_list* src = map_id2bl(dat->src_id); struct block_list* target = map_id2bl(dat->target_id); - if (target && !status_isdead(target)) { + if (target && !status_isdead(*target)) { 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] @@ -507,7 +507,7 @@ int64 battle_attr_fix(struct block_list *src, struct block_list *target, int64 d struct block_list *src2; if( !su || !su->alive || (sg = su->group) == nullptr || !sg || sg->val3 == -1 || - (src2 = map_id2bl(sg->src_id)) == nullptr || status_isdead(src2) ) + (src2 = map_id2bl(sg->src_id)) == nullptr || status_isdead(*src2) ) return 0; if( sg->unit_id != UNT_FIREWALL ) { @@ -696,8 +696,6 @@ int battle_calc_cardfix(int attack_type, struct block_list *src, struct block_li std::vector s_race2, /// Attacker Race2 t_race2; ///< Target Race2 enum e_element s_defele; ///< Attacker Element (not a weapon or skill element!) - struct status_data *sstatus, ///< Attacker status data - *tstatus; ///< Target status data int64 original_damage; if( !damage ) @@ -709,8 +707,10 @@ int battle_calc_cardfix(int attack_type, struct block_list *src, struct block_li tsd = BL_CAST(BL_PC, target); t_class = status_get_class(target); s_class = status_get_class(src); - sstatus = status_get_status_data(src); - tstatus = status_get_status_data(target); + ///< Attacker status data + status_data* sstatus = status_get_status_data(*src); + ///< Target status data + status_data* tstatus = status_get_status_data(*target); s_race2 = status_get_race2(src); t_race2 = status_get_race2(target); s_defele = (tsd) ? (enum e_element)status_get_element(src) : ELE_NONE; @@ -1167,7 +1167,7 @@ bool battle_status_block_damage(struct block_list *src, struct block_list *targe int element; if (flag & BF_WEAPON) { - struct status_data *sstatus = status_get_status_data(src); + status_data* sstatus = status_get_status_data(*src); if(sstatus->rhw.ele == ELE_NEUTRAL && sstatus->lhw.ele > sstatus->rhw.ele) element = battle_get_weapon_element(d, src, target, skill_id, skill_lv, EQI_HAND_L, false); else @@ -1358,7 +1358,7 @@ bool battle_status_block_damage(struct block_list *src, struct block_list *targe skill_id == WL_SOULEXPANSION || skill_id == AG_SOUL_VC_STRIKE || (skill_id && skill_get_ele(skill_id, skill_lv) == ELE_GHOST) || - (skill_id == 0 && (status_get_status_data(src))->rhw.ele == ELE_GHOST)) + (skill_id == 0 && (status_get_status_data(*src))->rhw.ele == ELE_GHOST)) { if (skill_id == WL_SOULEXPANSION) damage *= 2; // If used against a player in White Imprison, the skill deals double damage. @@ -1494,7 +1494,7 @@ bool battle_status_block_damage(struct block_list *src, struct block_list *targe if (((sce = sc->getSCE(SC_UTSUSEMI)) || sc->getSCE(SC_BUNSINJYUTSU)) && flag&BF_WEAPON && !skill_get_inf2(skill_id, INF2_IGNORECICADA)) { skill_additional_effect(src, target, skill_id, skill_lv, flag, ATK_BLOCK, gettick()); - if (!status_isdead(src)) + if (!status_isdead(*src)) skill_counter_additional_effect(src, target, skill_id, skill_lv, flag, gettick()); if (sce) { clif_specialeffect(target, EF_STORMKICK4, AREA); @@ -1792,7 +1792,7 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam #endif ) ) { - struct status_data *status = status_get_status_data(bl); + status_data* status = status_get_status_data(*bl); int per = 100*status->sp / status->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 @@ -2234,7 +2234,7 @@ static int battle_calc_drain(int64 damage, int rate, int per) int64 battle_addmastery(map_session_data *sd,struct block_list *target,int64 dmg,int type) { int64 damage; - struct status_data *status = status_get_status_data(target); + status_data* status = status_get_status_data(*target); int weapon, skill; #ifdef RENEWAL @@ -2399,7 +2399,7 @@ static int battle_calc_sizefix(int64 damage, map_session_data *sd, unsigned char */ static int battle_calc_base_weapon_attack(struct block_list *src, struct status_data *tstatus, struct weapon_atk *wa, map_session_data *sd, bool critical) { - struct status_data *status = status_get_status_data(src); + status_data* status = status_get_status_data(*src); uint8 type = (wa == &status->lhw)?EQI_HAND_L:EQI_HAND_R; uint16 atkmin = (type == EQI_HAND_L)?status->watk2:status->watk; uint16 atkmax = atkmin; @@ -2835,7 +2835,7 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list * */ bool is_infinite_defense(struct block_list *target, int flag) { - struct status_data *tstatus = status_get_status_data(target); + status_data* tstatus = status_get_status_data(*target); if(target->type == BL_SKILL) { TBL_SKILL *su = ((TBL_SKILL*)target); @@ -2871,7 +2871,7 @@ bool is_infinite_defense(struct block_list *target, int flag) static bool is_skill_using_arrow(struct block_list *src, int skill_id) { if(src != nullptr) { - struct status_data *sstatus = status_get_status_data(src); + status_data* sstatus = status_get_status_data(*src); map_session_data *sd = BL_CAST(BL_PC, src); return ((sd && sd->state.arrow_atk) || (!sd && ((skill_id && skill_get_ammotype(skill_id)) || sstatus->rhw.range>3)) @@ -2922,7 +2922,7 @@ static bool is_attack_left_handed(struct block_list *src, int skill_id) return true; } - struct status_data *sstatus = status_get_status_data(src); + struct status_data *sstatus = status_get_status_data(*src); if (sstatus->lhw.atk) return true; @@ -2950,7 +2950,7 @@ static bool is_attack_critical(struct Damage* wd, struct block_list *src, struct if( skill_id && !skill_get_nk(skill_id,NK_CRITICAL) ) return false; - struct status_data *sstatus = status_get_status_data(src); + status_data* sstatus = status_get_status_data(*src); if( sstatus->cri ) { @@ -2964,7 +2964,7 @@ static bool is_attack_critical(struct Damage* wd, struct block_list *src, struct return false; } - struct status_data *tstatus = status_get_status_data(target); + status_data* tstatus = status_get_status_data(*target); status_change *sc = status_get_sc(src); status_change *tsc = status_get_sc(target); map_session_data *tsd = BL_CAST(BL_PC, target); @@ -3060,7 +3060,7 @@ static int is_attack_piercing(struct Damage* wd, struct block_list *src, struct if(src != nullptr) { map_session_data *sd = BL_CAST(BL_PC, src); - struct status_data *tstatus = status_get_status_data(target); + status_data* tstatus = status_get_status_data(*target); if( skill_id != PA_SACRIFICE && skill_id != CR_GRANDCROSS && skill_id != NPC_GRANDDARKNESS && skill_id != PA_SHIELDCHAIN && skill_id != KO_HAPPOKUNAI #ifndef RENEWAL @@ -3118,8 +3118,8 @@ static std::bitset battle_skill_get_damage_properties(uint16 skill_id, i */ static bool is_attack_hitting(struct Damage* wd, struct block_list *src, struct block_list *target, int skill_id, int skill_lv, bool first_call) { - struct status_data *sstatus = status_get_status_data(src); - struct status_data *tstatus = status_get_status_data(target); + status_data* sstatus = status_get_status_data(*src); + status_data* tstatus = status_get_status_data(*target); status_change *sc = status_get_sc(src); status_change *tsc = status_get_sc(target); map_session_data *sd = BL_CAST(BL_PC, src); @@ -3312,7 +3312,7 @@ static bool is_attack_hitting(struct Damage* wd, struct block_list *src, struct */ static bool attack_ignores_def(struct Damage* wd, struct block_list *src, struct block_list *target, uint16 skill_id, uint16 skill_lv, short weapon_position) { - struct status_data *tstatus = status_get_status_data(target); + status_data* tstatus = status_get_status_data(*target); status_change *sc = status_get_sc(src); map_session_data *sd = BL_CAST(BL_PC, src); std::bitset nk = battle_skill_get_damage_properties(skill_id, wd->miscflag); @@ -3417,7 +3417,7 @@ static int battle_calc_equip_attack(struct block_list *src, int skill_id) { if(src != nullptr) { int eatk = 0; - struct status_data *status = status_get_status_data(src); + status_data* status = status_get_status_data(*src); map_session_data *sd = BL_CAST(BL_PC, src); // Add arrow atk if using an applicable skill @@ -3446,7 +3446,7 @@ int battle_get_weapon_element(struct Damage* wd, struct block_list *src, struct { map_session_data *sd = BL_CAST(BL_PC, src); status_change *sc = status_get_sc(src); - struct status_data *sstatus = status_get_status_data(src); + status_data* sstatus = status_get_status_data(*src); int element = skill_get_ele(skill_id, skill_lv); //Take weapon's element @@ -3549,7 +3549,7 @@ int battle_get_magic_element(struct block_list* src, struct block_list* target, int element = skill_get_ele(skill_id, skill_lv); map_session_data *sd = BL_CAST(BL_PC, src); status_change *sc = status_get_sc(src); - struct status_data *sstatus = status_get_status_data(src); + status_data* sstatus = status_get_status_data(*src); if (element == ELE_WEAPON) { // pl=-1 : the skill takes the weapon's element element = sstatus->rhw.ele; @@ -3719,8 +3719,8 @@ static void battle_calc_element_damage(struct Damage* wd, struct block_list *src std::bitset nk = battle_skill_get_damage_properties(skill_id, wd->miscflag); map_session_data* sd = BL_CAST(BL_PC, src); status_change* sc = status_get_sc(src); - struct status_data* sstatus = status_get_status_data(src); - struct status_data* tstatus = status_get_status_data(target); + status_data* sstatus = status_get_status_data(*src); + status_data* tstatus = status_get_status_data(*target); int right_element = battle_get_weapon_element(wd, src, target, skill_id, skill_lv, EQI_HAND_R, true); // Elemental attribute fix @@ -3853,7 +3853,7 @@ static void battle_calc_attack_masteries(struct Damage* wd, struct block_list *s { map_session_data *sd = BL_CAST(BL_PC, src); status_change *sc = status_get_sc(src); - struct status_data *sstatus = status_get_status_data(src); + status_data* sstatus = status_get_status_data(*src); int t_class = status_get_class(target); #ifndef RENEWAL @@ -3913,7 +3913,7 @@ static void battle_calc_attack_masteries(struct Damage* wd, struct block_list *s case NC_ARMSCANNON: // Arrow attack of these skills is not influenced by P.ATK so we add it as mastery attack if (sd != nullptr) { - struct status_data* tstatus = status_get_status_data(target); + status_data* tstatus = status_get_status_data(*target); ATK_ADD(wd->masteryAtk, wd->masteryAtk2, battle_attr_fix(src, target, sd->bonus.arrow_atk, sd->bonus.arrow_ele, tstatus->def_ele, tstatus->ele_lv)); } break; @@ -3959,8 +3959,8 @@ static void battle_calc_attack_masteries(struct Damage* wd, struct block_list *s */ static void battle_calc_damage_parts(struct Damage* wd, struct block_list *src,struct block_list *target,uint16 skill_id,uint16 skill_lv) { - struct status_data *sstatus = status_get_status_data(src); - struct status_data *tstatus = status_get_status_data(target); + status_data* sstatus = status_get_status_data(*src); + status_data* tstatus = status_get_status_data(*target); map_session_data *sd = BL_CAST(BL_PC, src); bool critical = false; @@ -4034,8 +4034,8 @@ static void battle_calc_damage_parts(struct Damage* wd, struct block_list *src,s static void battle_calc_skill_base_damage(struct Damage* wd, struct block_list *src,struct block_list *target,uint16 skill_id,uint16 skill_lv) { status_change *sc = status_get_sc(src); - struct status_data *sstatus = status_get_status_data(src); - struct status_data *tstatus = status_get_status_data(target); + status_data* sstatus = status_get_status_data(*src); + status_data* tstatus = status_get_status_data(*target); map_session_data *sd = BL_CAST(BL_PC, src); map_session_data *tsd = BL_CAST(BL_PC, target); @@ -4329,7 +4329,7 @@ static void battle_calc_multi_attack(struct Damage* wd, struct block_list *src,s map_session_data *sd = BL_CAST(BL_PC, src); status_change *sc = status_get_sc(src); status_change *tsc = status_get_sc(target); - struct status_data *tstatus = status_get_status_data(target); + status_data* tstatus = status_get_status_data(*target); if( sd && !skill_id ) { // if no skill_id passed, check for double attack [helvetica] short i; @@ -4526,8 +4526,8 @@ static int battle_calc_attack_skill_ratio(struct Damage* wd, struct block_list * map_session_data *tsd = BL_CAST(BL_PC, target); status_change *sc = status_get_sc(src); 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); + status_data* sstatus = status_get_status_data(*src); + status_data* tstatus = status_get_status_data(*target); int skillratio = 100; int i; @@ -6289,8 +6289,8 @@ static int64 battle_calc_skill_constant_addition(struct Damage* wd, struct block { map_session_data *sd = BL_CAST(BL_PC, src); map_session_data *tsd = BL_CAST(BL_PC, target); - struct status_data *sstatus = status_get_status_data(src); - struct status_data *tstatus = status_get_status_data(target); + status_data* sstatus = status_get_status_data(*src); + status_data* tstatus = status_get_status_data(*target); int64 atk = 0; //Constant/misc additions from skills @@ -6341,8 +6341,8 @@ static void battle_attack_sc_bonus(struct Damage* wd, struct block_list *src, st { map_session_data *sd = BL_CAST(BL_PC, src); status_change *sc = status_get_sc(src); - struct status_data *sstatus = status_get_status_data(src); - struct status_data *tstatus = status_get_status_data(target); + status_data* sstatus = status_get_status_data(*src); + status_data* tstatus = status_get_status_data(*target); uint8 anger_id = 0; // SLS Anger // Kagerou/Oboro Earth Charm effect +15% wATK @@ -6530,8 +6530,8 @@ static void battle_calc_defense_reduction(struct Damage* wd, struct block_list * map_session_data *tsd = BL_CAST(BL_PC, target); status_change *sc = status_get_sc(src); 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); + status_data* sstatus = status_get_status_data(*src); + status_data* tstatus = status_get_status_data(*target); //Defense reduction short vit_def; @@ -6701,7 +6701,7 @@ static void battle_calc_attack_post_defense(struct Damage* wd, struct block_list { map_session_data *sd = BL_CAST(BL_PC, src); status_change *sc = status_get_sc(src); - struct status_data *sstatus = status_get_status_data(src); + status_data* sstatus = status_get_status_data(*src); // Post skill/vit reduction damage increases #ifndef RENEWAL @@ -6756,7 +6756,7 @@ static void battle_calc_attack_post_defense(struct Damage* wd, struct block_list */ static void battle_calc_attack_plant(struct Damage* wd, struct block_list *src,struct block_list *target, uint16 skill_id, uint16 skill_lv) { - struct status_data *tstatus = status_get_status_data(target); + status_data* tstatus = status_get_status_data(*target); bool attack_hits = is_attack_hitting(wd, src, target, skill_id, skill_lv, false); if (skill_id != SN_SHARPSHOOTING && skill_id != RA_ARROWSTORM) @@ -6913,7 +6913,7 @@ static void battle_calc_attack_gvg_bg(struct Damage* wd, struct block_list *src, (src->type == BL_SKILL && (skill_id == SG_SUN_WARM || skill_id == SG_MOON_WARM || skill_id == SG_STAR_WARM))) ) { int64 damage = wd->damage + wd->damage2, rdamage = 0; map_session_data *tsd = BL_CAST(BL_PC, target); - struct status_data *sstatus = status_get_status_data(src); + status_data* sstatus = status_get_status_data(*src); t_tick tick = gettick(), rdelay = 0; rdamage = battle_calc_return_damage(target, src, &damage, wd->flag, skill_id, false); @@ -6975,8 +6975,8 @@ static void battle_calc_weapon_final_atk_modifiers(struct Damage* wd, struct blo map_session_data *tsd = BL_CAST(BL_PC, target); status_change *sc = status_get_sc(src); 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); + status_data* sstatus = status_get_status_data(*src); + status_data* tstatus = status_get_status_data(*target); int skill_damage = 0; //Reject Sword bugreport:4493 by Daegaladh @@ -6992,7 +6992,7 @@ static void battle_calc_weapon_final_atk_modifiers(struct Damage* wd, struct blo ATK_RATER(wd->damage, 50) clif_skill_nodamage(target,target,ST_REJECTSWORD, tsc->getSCE(SC_REJECTSWORD)->val1,1); battle_fix_damage(target,src,wd->damage,clif_damage(target,src,gettick(),0,0,wd->damage,0,DMG_NORMAL,0,false),ST_REJECTSWORD); - if (status_isdead(target)) + if (status_isdead(*target)) return; if( --(tsc->getSCE(SC_REJECTSWORD)->val3) <= 0 ) status_change_end(target, SC_REJECTSWORD); @@ -7070,8 +7070,8 @@ static void battle_calc_weapon_final_atk_modifiers(struct Damage* wd, struct blo */ static struct Damage initialize_weapon_data(struct block_list *src, struct block_list *target, uint16 skill_id, uint16 skill_lv, int wflag) { - struct status_data *sstatus = status_get_status_data(src); - struct status_data *tstatus = status_get_status_data(target); + status_data* sstatus = status_get_status_data(*src); + status_data* tstatus = status_get_status_data(*target); status_change *sc = status_get_sc(src); map_session_data *sd = BL_CAST(BL_PC, src); struct Damage wd; @@ -7264,7 +7264,7 @@ void battle_do_reflect(int attack_type, struct Damage *wd, struct block_list* sr int64 damage = wd->damage + wd->damage2, rdamage = 0; map_session_data *tsd = BL_CAST(BL_PC, target); status_change *tsc = status_get_sc(target); - struct status_data *sstatus = status_get_status_data(src); + status_data* sstatus = status_get_status_data(*src); struct unit_data *ud = unit_bl2ud(target); t_tick tick = gettick(), rdelay = 0; @@ -7315,8 +7315,8 @@ static struct Damage battle_calc_weapon_attack(struct block_list *src, struct bl struct Damage wd; status_change *sc = status_get_sc(src); 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); + status_data* sstatus = status_get_status_data(*src); + status_data* tstatus = status_get_status_data(*target); int right_element, left_element; bool infdef = false; @@ -7390,7 +7390,7 @@ static struct Damage battle_calc_weapon_attack(struct block_list *src, struct bl #ifdef RENEWAL if(skill_id == HW_MAGICCRASHER) { // Add weapon attack for MATK onto Magic Crasher - struct status_data *sstatus = status_get_status_data(src); + status_data* sstatus = status_get_status_data(*src); if (sstatus->matk_max > sstatus->matk_min) { ATK_ADD(wd.weaponAtk, wd.weaponAtk2, sstatus->matk_min+rnd()%(sstatus->matk_max-sstatus->matk_min)); @@ -7596,7 +7596,7 @@ static struct Damage battle_calc_weapon_attack(struct block_list *src, struct bl ATK_ADD(wd.damage, wd.damage2, skill_lv * 240 + status_get_lv(target) * 40); break; case SR_GATEOFHELL: { - status_data *sstatus = status_get_status_data(src); + status_data* sstatus = status_get_status_data(*src); double bonus = 1 + skill_lv * 2 / 10; ATK_ADD(wd.damage, wd.damage2, sstatus->max_hp - sstatus->hp); @@ -7721,8 +7721,6 @@ struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list TBL_PC *tsd; status_change *sc, *tsc; struct Damage ad; - 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; @@ -7735,6 +7733,10 @@ struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list nullpo_info(NLP_MARK); return ad; } + + status_data* sstatus = status_get_status_data(*src); + status_data* tstatus = status_get_status_data(*target); + // Initial Values // Set to 1 because magic damage on plants is 1 per hit; if target is not a plant this gets reinitialized to 0 later ad.damage = 1; @@ -8956,8 +8958,6 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list * map_session_data *sd, *tsd; struct Damage md; //DO NOT CONFUSE with md of mob_data! - struct status_data *sstatus = status_get_status_data(src); - struct status_data *tstatus = status_get_status_data(target); status_change *ssc = status_get_sc(src); memset(&md,0,sizeof(md)); @@ -8967,6 +8967,9 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list * return md; } + status_data* sstatus = status_get_status_data(*src); + status_data* tstatus = status_get_status_data(*target); + //Some initial values md.amotion = (skill_get_inf(skill_id)&INF_GROUND_SKILL ? 0 : sstatus->amotion); md.dmotion = tstatus->dmotion; @@ -9571,7 +9574,7 @@ int64 battle_calc_return_damage(struct block_list* tbl, struct block_list *src, */ bool battle_check_coma(map_session_data& sd, struct block_list& target, e_battle_flag attack_type) { - struct status_data* tstatus = status_get_status_data(&target); + status_data* tstatus = status_get_status_data(target); mob_data* dstmd = BL_CAST(BL_MOB, &target); // Coma @@ -9606,7 +9609,7 @@ bool battle_vellum_damage(map_session_data *sd, struct block_list *target, struc nullpo_retr(false, target); nullpo_retr(false, wd); - struct status_data *tstatus = status_get_status_data(target); + status_data* tstatus = status_get_status_data(*target); // bHPVanishRaceRate int16 vellum_rate_hp = cap_value(sd->hp_vanish_race[tstatus->race].rate + sd->hp_vanish_race[RC_ALL].rate, 0, INT16_MAX); int8 vellum_hp = cap_value(sd->hp_vanish_race[tstatus->race].per + sd->hp_vanish_race[RC_ALL].per, INT8_MIN, INT8_MAX); @@ -9785,7 +9788,6 @@ void battle_autocast_elembuff_skill(map_session_data* sd, struct block_list* tar *------------------------------------------*/ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* target, t_tick tick, int flag) { map_session_data *sd = nullptr, *tsd = nullptr; - struct status_data *sstatus, *tstatus; status_change *sc, *tsc; int64 damage; int skillv; @@ -9801,8 +9803,8 @@ 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 = status_get_status_data(src); - tstatus = status_get_status_data(target); + status_data* sstatus = status_get_status_data(*src); + status_data* tstatus = status_get_status_data(*target); sc = status_get_sc(src); tsc = status_get_sc(target); @@ -10060,7 +10062,7 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t map_freeblock_lock(); if( !(tsc && tsc->getSCE(SC_DEVOTION)) && !vellum_damage && skill_check_shadowform(target, damage, wd.div_) ) { - if( !status_isdead(target) ) + if( !status_isdead(*target) ) skill_additional_effect(src, target, 0, 0, wd.flag, wd.dmg_lv, tick); if( wd.dmg_lv > ATK_BLOCK ) skill_counter_additional_effect(src, target, 0, 0, wd.flag, tick); @@ -10111,7 +10113,7 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t if (tsc->getSCE(SC_WATER_SCREEN_OPTION)) { struct block_list *e_bl = map_id2bl(tsc->getSCE(SC_WATER_SCREEN_OPTION)->val1); - if (e_bl && !status_isdead(e_bl)) { + if (e_bl && !status_isdead(*e_bl)) { clif_damage(e_bl, e_bl, tick, 0, 0, damage, wd.div_, DMG_NORMAL, 0, false); battle_fix_damage(src, e_bl, damage, 0, EL_WATER_SCREEN); } diff --git a/src/map/chat.cpp b/src/map/chat.cpp index d11f912063..eeb87ef331 100644 --- a/src/map/chat.cpp +++ b/src/map/chat.cpp @@ -108,7 +108,7 @@ int chat_createpcchat(map_session_data* sd, const char* title, const char* pass, clif_createchat( *sd, CREATEROOM_SUCCESS ); clif_dispchat(cd,0); - if (status_isdead(&sd->bl)) + if (status_isdead(sd->bl)) achievement_update_objective(sd, AG_CHATTING_DYING, 1, 1); else achievement_update_objective(sd, AG_CHATTING_CREATE, 1, 1); diff --git a/src/map/clif.cpp b/src/map/clif.cpp index f0c64a3126..7cc3f77bb6 100644 --- a/src/map/clif.cpp +++ b/src/map/clif.cpp @@ -6263,7 +6263,6 @@ void clif_skill_teleportmessage( map_session_data& sd, e_notify_mapinfo_result r /// .B .B .B .B .B .B .B .B .B void clif_skill_estimation(map_session_data *sd,struct block_list *dst) { - struct status_data *status; unsigned char buf[64]; int i, fix; @@ -6273,7 +6272,7 @@ void clif_skill_estimation(map_session_data *sd,struct block_list *dst) if( dst->type != BL_MOB ) return; - status = status_get_status_data(dst); + status_data* status = status_get_status_data(*dst); WBUFW(buf, 0)=0x18c; WBUFW(buf, 2)=status_get_class(dst); @@ -11048,7 +11047,7 @@ void clif_parse_LoadEndAck(int fd,map_session_data *sd) sd->areanpc.clear(); /* it broke at some point (e.g. during a crash), so we make it visibly dead again. */ - if( !sd->status.hp && !pc_isdead(sd) && status_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] diff --git a/src/map/homunculus.cpp b/src/map/homunculus.cpp index c8cdef0079..d42496eaf4 100644 --- a/src/map/homunculus.cpp +++ b/src/map/homunculus.cpp @@ -279,7 +279,7 @@ int hom_vaporize(map_session_data *sd, int flag) if (!hd || hd->homunculus.vaporize) return 0; - if (status_isdead(&hd->bl)) + if (status_isdead(hd->bl)) return 0; //Can't vaporize a dead homun. if (flag == HOM_ST_REST && get_percentage(hd->battle_status.hp, hd->battle_status.max_hp) < 80) @@ -1280,7 +1280,7 @@ int hom_ressurect(map_session_data* sd, unsigned char per, short x, short y) if (hd->homunculus.vaporize == HOM_ST_REST) return 0; // vaporized homunculi need to be 'called' - if (!status_isdead(&hd->bl)) + if (!status_isdead(hd->bl)) return 0; // already alive hom_init_timers(hd); diff --git a/src/map/mob.cpp b/src/map/mob.cpp index 1a34aea3e2..39aac95240 100644 --- a/src/map/mob.cpp +++ b/src/map/mob.cpp @@ -1443,7 +1443,7 @@ static int mob_ai_sub_hard_slavemob(struct mob_data *md,t_tick tick) bl=map_id2bl(md->master_id); - if (!bl || status_isdead(bl)) { + if (!bl || status_isdead(*bl)) { status_kill(&md->bl); return 1; } diff --git a/src/map/pc.cpp b/src/map/pc.cpp index dfbc927b13..ecd8523b05 100755 --- a/src/map/pc.cpp +++ b/src/map/pc.cpp @@ -6675,7 +6675,6 @@ bool pc_steal_item(map_session_data *sd,struct block_list *bl, uint16 skill_lv) t_itemid itemid; double rate; unsigned char flag = 0; - struct status_data *sd_status, *md_status; struct mob_data *md; if(!sd || !bl || bl->type!=BL_MOB) @@ -6686,8 +6685,8 @@ bool pc_steal_item(map_session_data *sd,struct block_list *bl, uint16 skill_lv) if(md->state.steal_flag == UCHAR_MAX || ( md->sc.opt1 && md->sc.opt1 != OPT1_BURNING ) ) //already stolen from / status change check return false; - sd_status= status_get_status_data(&sd->bl); - md_status= status_get_status_data(bl); + status_data* sd_status = status_get_status_data(sd->bl); + status_data* md_status = status_get_status_data(*bl); if (md->master_id || status_has_mode(md_status, MD_STATUSIMMUNE) || util::vector_exists(status_get_race2(&md->bl), RC2_TREASURE) || map_getmapflag(bl->m, MF_NOMOBLOOT) || // check noloot map flag [Lorky] @@ -8235,7 +8234,7 @@ static void pc_calcexp(map_session_data *sd, t_exp *base_exp, t_exp *job_exp, st int bonus = 0, vip_bonus_base = 0, vip_bonus_job = 0; if (src) { - struct status_data *status = status_get_status_data(src); + status_data* status = status_get_status_data(*src); if( sd->indexed_bonus.expaddrace[status->race] ) bonus += sd->indexed_bonus.expaddrace[status->race]; diff --git a/src/map/pc.hpp b/src/map/pc.hpp index 9e75c09cd2..4a8f7955ab 100644 --- a/src/map/pc.hpp +++ b/src/map/pc.hpp @@ -1232,7 +1232,7 @@ enum e_mado_type : uint16 { #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) (status_base_matk_min(&(sd)->bl, status_get_status_data(&(sd)->bl), (sd)->status.base_level)) + #define pc_leftside_matk(sd) (status_base_matk_min(&(sd)->bl, 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.cpp b/src/map/pet.cpp index 2577513a6b..e67a244fec 100644 --- a/src/map/pet.cpp +++ b/src/map/pet.cpp @@ -714,7 +714,7 @@ int pet_attackskill(struct pet_data *pd, int target_id) bl = map_id2bl(target_id); - if(bl == nullptr || pd->bl.m != bl->m || bl->prev == nullptr || status_isdead(bl) || + if(bl == nullptr || pd->bl.m != bl->m || bl->prev == nullptr || status_isdead(*bl) || !check_distance_bl(&pd->bl, bl, pd->db->range3)) return 0; @@ -1791,7 +1791,7 @@ static int pet_ai_sub_hard(struct pet_data *pd, map_session_data *sd, t_tick tic if (pd->target_id) { target = map_id2bl(pd->target_id); - if (!target || pd->bl.m != target->m || status_isdead(target) || + if (!target || pd->bl.m != target->m || status_isdead(*target) || !check_distance_bl(&pd->bl, target, pd->db->range3)) { target = nullptr; pet_unlocktarget(pd); @@ -2090,7 +2090,6 @@ TIMER_FUNC(pet_recovery_timer){ */ TIMER_FUNC(pet_heal_timer){ map_session_data *sd = map_id2sd(id); - struct status_data *status; struct pet_data *pd; unsigned int rate = 100; @@ -2104,7 +2103,7 @@ TIMER_FUNC(pet_heal_timer){ return 0; } - status = status_get_status_data(&sd->bl); + status_data* status = status_get_status_data(sd->bl); if(pc_isdead(sd) || (rate = get_percentage(status->sp, status->max_sp)) > pd->s_skill->sp || @@ -2134,7 +2133,6 @@ TIMER_FUNC(pet_heal_timer){ TIMER_FUNC(pet_skill_support_timer){ map_session_data *sd = map_id2sd(id); struct pet_data *pd; - struct status_data *status; short rate = 100; if(sd == nullptr || sd->pd == nullptr || sd->pd->s_skill == nullptr) @@ -2147,7 +2145,7 @@ TIMER_FUNC(pet_skill_support_timer){ return 0; } - status = status_get_status_data(&sd->bl); + status_data* status = 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/skill.cpp b/src/map/skill.cpp index 43862587ed..15840c2325 100755 --- a/src/map/skill.cpp +++ b/src/map/skill.cpp @@ -716,7 +716,7 @@ int skill_calc_heal(struct block_list *src, struct block_list *target, uint16 sk break; default: { - struct status_data *status = status_get_status_data(src); + status_data* status = status_get_status_data(*src); int min, max; min = status_base_matk_min(src, status, status_get_lv(src)); @@ -1233,8 +1233,8 @@ int skill_additional_effect( struct block_list* src, struct block_list *bl, uint status_change* sc = status_get_sc( src ); status_change* tsc = status_get_sc( bl ); - status_data* sstatus = status_get_status_data( src ); - status_data* tstatus = status_get_status_data( bl ); + status_data* sstatus = status_get_status_data(*src); + status_data* tstatus = status_get_status_data(*bl); // Taekwon combos activate on traps, so we need to check them even for targets that don't have status if (sd && skill_id == 0 && !(attack_type&BF_SKILL) && sc) { @@ -2283,7 +2283,7 @@ int skill_additional_effect( struct block_list* src, struct block_list *bl, uint } } - if( sd && sd->ed && sc && !status_isdead(bl) && !skill_id ) { + if( sd && sd->ed && sc && !status_isdead(*bl) && !skill_id ) { struct unit_data *ud = unit_bl2ud(src); int skill; @@ -2313,7 +2313,7 @@ int skill_additional_effect( struct block_list* src, struct block_list *bl, uint } // Autospell when attacking - if( sd && !status_isdead(bl) && !sd->autospell.empty() ) + if( sd && !status_isdead(*bl) && !sd->autospell.empty() ) { for (const auto &it : sd->autospell) { if (!(((it.battle_flag)&attack_type)&BF_WEAPONMASK && @@ -2587,7 +2587,7 @@ int skill_counter_additional_effect (struct block_list* src, struct block_list * if (it.flag&ATF_TARGET && src != bl) status_change_start(src, src, it.sc, rate, 7, 0, 0, 0, it.duration, SCSTART_NONE, 100); - if (it.flag&ATF_SELF && !status_isdead(bl)) + if (it.flag&ATF_SELF && !status_isdead(*bl)) status_change_start(src, bl, it.sc, rate, 7, 0, 0, 0, it.duration, SCSTART_NONE, 100); } } @@ -2641,7 +2641,7 @@ int skill_counter_additional_effect (struct block_list* src, struct block_list * 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) && + 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] @@ -2650,7 +2650,7 @@ int skill_counter_additional_effect (struct block_list* src, struct block_list * status_heal(src, 0, status_get_lv(bl)*(95+15*rate)/100, 2); } - if( sd && status_isdead(bl) ) { + if( sd && status_isdead(*bl) ) { int sp = 0, hp = 0; if( (attack_type&(BF_WEAPON|BF_SHORT)) == (BF_WEAPON|BF_SHORT) ) { sp += sd->bonus.sp_gain_value; @@ -2679,7 +2679,7 @@ int skill_counter_additional_effect (struct block_list* src, struct block_list * } } - if (dstsd && !status_isdead(bl) && !(skill_id && skill_get_nk(skill_id, NK_NODAMAGE))) { + if (dstsd && !status_isdead(*bl) && !(skill_id && skill_get_nk(skill_id, NK_NODAMAGE))) { status_change *sc = status_get_sc(bl); if (sc && sc->getSCE(SC_DORAM_SVSP) && attack_type&(BF_MAGIC|BF_LONG)) @@ -2687,7 +2687,7 @@ int skill_counter_additional_effect (struct block_list* src, struct block_list * } // Trigger counter-spells to retaliate against damage causing skills. - if(dstsd && !status_isdead(bl) && !dstsd->autospell2.empty() && + if(dstsd && !status_isdead(*bl) && !dstsd->autospell2.empty() && !(skill_id && skill_get_nk(skill_id, NK_NODAMAGE))) { for (const auto &it : dstsd->autospell2) { @@ -2757,7 +2757,7 @@ int skill_counter_additional_effect (struct block_list* src, struct block_list * } // Check for player and pet autobonuses when attacked - if (dstsd != nullptr && !status_isdead(bl) && !(skill_id && skill_get_nk(skill_id, NK_NODAMAGE))) { + if (dstsd != nullptr && !status_isdead(*bl) && !(skill_id && skill_get_nk(skill_id, NK_NODAMAGE))) { // Player if (!dstsd->autobonus2.empty()) { for (auto &it : dstsd->autobonus2) { @@ -2946,7 +2946,8 @@ bool skill_strip_equip(struct block_list *src, struct block_list *target, uint16 const int pos[6] = { EQP_WEAPON, EQP_SHIELD, EQP_ARMOR, EQP_HELM, EQP_ACC, EQP_SHADOW_GEAR }; const enum sc_type sc_atk[6] = { SC_STRIPWEAPON, SC_STRIPSHIELD, SC_STRIPARMOR, SC_STRIPHELM, SC__STRIPACCESSORY, SC_SHADOW_STRIP }; const enum sc_type sc_def[6] = { SC_CP_WEAPON, SC_CP_SHIELD, SC_CP_ARMOR, SC_CP_HELM, SC_NONE, SC_PROTECTSHADOWEQUIP }; - struct status_data *sstatus = status_get_status_data(src), *tstatus = status_get_status_data(target); + status_data* sstatus = status_get_status_data(*src); + status_data* tstatus = status_get_status_data(*target); int rate, time, location, mod = 100; switch (skill_id) { // Rate @@ -3455,7 +3456,7 @@ void skill_attack_blow(struct block_list *src, struct block_list *dsrc, struct b int8 dir = -1; // Default direction //Only knockback if it's still alive, otherwise a "ghost" is left behind. [Skotlex] //Reflected spells do not bounce back (src == dsrc since it only happens for direct skills) - if (!blewcount || target == dsrc || status_isdead(target)) + if (!blewcount || target == dsrc || status_isdead(*target)) return; // Skill specific direction @@ -3536,7 +3537,6 @@ void skill_attack_blow(struct block_list *src, struct block_list *dsrc, struct b int64 skill_attack (int attack_type, struct block_list* src, struct block_list *dsrc, struct block_list *bl, uint16 skill_id, uint16 skill_lv, t_tick tick, int flag) { struct Damage dmg; - struct status_data *sstatus, *tstatus; status_change *sc, *tsc; map_session_data *sd, *tsd; int64 damage; @@ -3569,8 +3569,8 @@ int64 skill_attack (int attack_type, struct block_list* src, struct block_list * sd = BL_CAST(BL_PC, src); tsd = BL_CAST(BL_PC, bl); - sstatus = status_get_status_data(src); - tstatus = status_get_status_data(bl); + status_data* sstatus = status_get_status_data(*src); + status_data* tstatus = status_get_status_data(*bl); sc= status_get_sc(src); tsc= status_get_sc(bl); if (tsc && !tsc->count) @@ -3669,7 +3669,7 @@ int64 skill_attack (int attack_type, struct block_list* src, struct block_list * dmg.damage = battle_attr_fix(bl, bl, dmg.damage, s_ele, status_get_element(bl), status_get_element_level(bl)); if( tsc && tsc->getSCE(SC_ENERGYCOAT) ) { - struct status_data *status = status_get_status_data(bl); + status_data* status = status_get_status_data(*bl); int per = 100*status->sp / status->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 @@ -3990,7 +3990,7 @@ int64 skill_attack (int attack_type, struct block_list* src, struct block_list * #endif || skill_id == NPC_EVILLAND) && !shadow_flag ) battle_damage(src, bl, damage, dmg.dmotion, skill_lv, skill_id, dmg.dmg_lv, dmg.flag, false, tick, false); - if( !status_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); @@ -4003,7 +4003,7 @@ int64 skill_attack (int attack_type, struct block_list* src, struct block_list * // Delayed damage must be dealt after the knockback (it needs to know actual position of target) if( dmg.amotion ) { if( shadow_flag ) { - if( !status_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( dmg.flag > ATK_BLOCK ) skill_counter_additional_effect(src, bl, skill_id, skill_lv, dmg.flag, tick); @@ -4011,7 +4011,7 @@ int64 skill_attack (int attack_type, struct block_list* src, struct block_list * battle_delay_damage(tick, dmg.amotion,src,bl,dmg.flag,skill_id,skill_lv,damage,dmg.dmg_lv,dmg.dmotion, additional_effects, false); } else { // Trigger monster skill condition for damage skills with no amotion. - if (bl->type == BL_MOB && src != bl && !status_isdead(bl)) { + if (bl->type == BL_MOB && src != bl && !status_isdead(*bl)) { if (damage > 0) mobskill_event(BL_CAST(BL_MOB, bl), src, tick, dmg.flag); if (skill_id > 0) @@ -4020,7 +4020,7 @@ int64 skill_attack (int attack_type, struct block_list* src, struct block_list * } // Trigger monster skill condition for damage skills. - if (bl->type == BL_MOB && src != bl && !status_isdead(bl)) { + if (bl->type == BL_MOB && src != bl && !status_isdead(*bl)) { if (damage > 0) mobskill_event(BL_CAST(BL_MOB, bl), src, tick, dmg.flag, damage); if (skill_id > 0) @@ -4289,7 +4289,7 @@ static int skill_check_unit_range2_sub (struct block_list *bl, va_list ap) skill_id = va_arg(ap,int); - if( status_isdead(bl) && skill_id != AL_WARP ) + if( status_isdead(*bl) && skill_id != AL_WARP ) return 0; #ifndef RENEWAL @@ -4396,7 +4396,6 @@ void skill_consume_hpspap(block_list* bl, uint16 skill_id, int hp, int sp, int a *------------------------------------------*/ static int skill_check_condition_mercenary(struct block_list *bl, uint16 skill_id, uint16 skill_lv, int type) { - struct status_data *status; map_session_data *sd = nullptr; int i, hp, sp, hp_rate, sp_rate, state, mhp; t_itemid itemid[MAX_SKILL_ITEM_REQUIRE]; @@ -4414,7 +4413,7 @@ static int skill_check_condition_mercenary(struct block_list *bl, uint16 skill_i return 0; } - status = status_get_status_data(bl); + status_data* status = status_get_status_data(*bl); skill_lv = cap_value(skill_lv, 1, MAX_SKILL_LEVEL); std::shared_ptr skill = skill_db.find(skill_id); @@ -4557,7 +4556,7 @@ static TIMER_FUNC(skill_timerskill){ if(src->m != target->m) break; // Different Maps - if(status_isdead(src)) { + if(status_isdead(*src)) { switch(skl->skill_id) { case WL_CHAINLIGHTNING_ATK: case WL_TETRAVORTEX_FIRE: @@ -4576,7 +4575,7 @@ static TIMER_FUNC(skill_timerskill){ continue; // Caster is Dead } } - if(status_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) { @@ -4587,7 +4586,7 @@ static TIMER_FUNC(skill_timerskill){ if (unit_warp(src,-1,-1,-1,CLR_TELEPORT) == 0) { short x,y; map_search_freecell(src, 0, &x, &y, 1, 1, 0); - if (target != src && !status_isdead(target)) + if (target != src && !status_isdead(*target)) unit_warp(target, -1, x, y, CLR_TELEPORT); } break; @@ -4631,12 +4630,12 @@ static TIMER_FUNC(skill_timerskill){ [[fallthrough]]; case WZ_JUPITEL: // Official behaviour is to hit as long as there is a line of sight, regardless of distance - if (skl->type > 0 && !status_isdead(target) && path_search_long(nullptr,src->m,src->x,src->y,target->x,target->y,CELL_CHKWALL)) { + if (skl->type > 0 && !status_isdead(*target) && path_search_long(nullptr,src->m,src->x,src->y,target->x,target->y,CELL_CHKWALL)) { // Apply canact delay here to prevent hacks (unlimited casting) ud->canact_tick = i64max(tick + status_get_amotion(src), ud->canact_tick); skill_attack(BF_MAGIC, src, src, target, skl->skill_id, skl->skill_lv, tick, skl->flag); } - if (unit && !status_isdead(target) && !status_isdead(src)) { + if (unit && !status_isdead(*target) && !status_isdead(*src)) { skill_delunit(unit); // Consume unit for next waterball //Timer will continue and walkdelay set until target is dead, even if there is currently no line of sight unit_set_walkdelay(src, tick, TIMERSKILL_INTERVAL, 1); @@ -4685,7 +4684,7 @@ static TIMER_FUNC(skill_timerskill){ 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|SD_LEVEL|SD_ANIMATION); if (skl->type >= 3) { // Final Hit - if (!status_isdead(target)) { // Final Status Effect + if (!status_isdead(*target)) { // Final Status Effect int effects[4] = { SC_BURNING, SC_FREEZING, SC_BLEEDING, SC_STUN }, applyeffects[4] = { 0, 0, 0, 0 }, i, j = 0, k = 0; @@ -5010,7 +5009,7 @@ static int skill_tarotcard(struct block_list* src, struct block_list *target, ui { battle_fix_damage(src, target, 1000, 0, skill_id); clif_damage(src, target, tick, 0, 0, 1000, 0, DMG_NORMAL, 0, false); - if (!status_isdead(target)) + if (!status_isdead(*target)) { unsigned short where[] = { EQP_ARMOR, EQP_SHIELD, EQP_HELM }; skill_break_equip(src, target, where[rnd() % 3], 10000, BCT_ENEMY); @@ -5105,7 +5104,6 @@ static int skill_tarotcard(struct block_list* src, struct block_list *target, ui int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint16 skill_id, uint16 skill_lv, t_tick tick, int flag) { map_session_data *sd = nullptr; - struct status_data *tstatus; status_change *sc, *tsc; if (skill_id > 0 && !skill_lv) return 0; @@ -5121,7 +5119,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint sd = BL_CAST(BL_PC, src); - if (status_isdead(bl)) + if (status_isdead(*bl)) return 1; if (skill_id && skill_id != AG_DEADLY_PROJECTION && skill_get_type(skill_id) == BF_MAGIC && status_isimmune(bl) == 100) @@ -5140,7 +5138,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint if (tsc && !tsc->count) tsc = nullptr; - tstatus = status_get_status_data(bl); + status_data* tstatus = status_get_status_data(*bl); map_freeblock_lock(); @@ -7276,7 +7274,6 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui struct mob_data *md, *dstmd; struct homun_data *hd; s_mercenary_data *mer; - struct status_data *sstatus, *tstatus; status_change *tsc; struct status_change_entry *tsce; @@ -7301,10 +7298,10 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui if(bl->prev == nullptr) return 1; - if(status_isdead(src)) + if(status_isdead(*src)) return 1; - if( src != bl && status_isdead(bl) ) { + if( src != bl && status_isdead(*bl) ) { switch( skill_id ) { // Skills that may be cast on dead targets case NPC_WIDESOULDRAIN: case PR_REDEMPTIO: @@ -7317,8 +7314,8 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui } } - tstatus = status_get_status_data(bl); - sstatus = status_get_status_data(src); + status_data* tstatus = status_get_status_data(*bl); + status_data* sstatus = status_get_status_data(*src); //Check for undead skills that convert a no-damage skill into a damage one. [Skotlex] switch (skill_id) { @@ -7450,7 +7447,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui #endif status_set_hp(src, 1, 0); break; - } else if (!(status_isdead(bl) && flag&1)) { + } else if (!(status_isdead(*bl) && flag&1)) { //Invalid target, skip resurrection. break; } @@ -7465,7 +7462,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui clif_skill_fail( *sd, skill_id ); break; } - if (!status_isdead(bl)) + if (!status_isdead(*bl)) break; { int per = 0, sper = 0; @@ -10075,10 +10072,10 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui } // Partner must be on the same map and in same party - if (p_sd && !status_isdead(&p_sd->bl) && p_sd->bl.m == sd->bl.m && p_sd->status.party_id == sd->status.party_id) + if (p_sd && !status_isdead(p_sd->bl) && p_sd->bl.m == sd->bl.m && p_sd->status.party_id == sd->status.party_id) pc_setpos(p_sd, map_id2index(sd->bl.m), sd->bl.x, sd->bl.y, CLR_TELEPORT); // Child must be on the same map and in same party as the parent casting - if (c_sd && !status_isdead(&c_sd->bl) && c_sd->bl.m == sd->bl.m && c_sd->status.party_id == sd->status.party_id) + if (c_sd && !status_isdead(c_sd->bl) && c_sd->bl.m == sd->bl.m && c_sd->status.party_id == sd->status.party_id) pc_setpos(c_sd, map_id2index(sd->bl.m), sd->bl.x, sd->bl.y, CLR_TELEPORT); } break; @@ -10097,7 +10094,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui clif_skill_fail( *sd, skill_id ); break; } - if (status_isdead(bl)) { + if (status_isdead(*bl)) { int per = 30, sper = 0; if (battle_check_undead(tstatus->race, tstatus->def_ele)) @@ -11702,7 +11699,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case WM_DEADHILLHERE: if( bl->type == BL_PC ) { - if( !status_isdead(bl) ) + if( !status_isdead(*bl) ) break; tstatus->hp = max(tstatus->sp, 1); @@ -13043,7 +13040,7 @@ static int8 skill_castend_id_check(struct block_list *src, struct block_list *ta break; case PR_TURNUNDEAD: { - struct status_data *tstatus = status_get_status_data(target); + status_data* tstatus = status_get_status_data(*target); if (!battle_check_undead(tstatus->race, tstatus->def_ele)) return USESKILL_FAIL_MAX; } @@ -13216,7 +13213,7 @@ TIMER_FUNC(skill_castend_id){ if (!target || target->prev == nullptr) break; - if (src->m != target->m || status_isdead(src)) + if (src->m != target->m || status_isdead(*src)) break; //These should become skill_castend_pos @@ -13567,7 +13564,7 @@ TIMER_FUNC(skill_castend_pos){ ud->skilltimer = INVALID_TIMER; do { - if( status_isdead(src) ) + if( status_isdead(*src) ) break; if (!skill_pos_maxcount_check(src, ud->skillx, ud->skilly, ud->skill_id, ud->skill_lv, src->type, true)) @@ -13705,7 +13702,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui nullpo_ret(src); - if(status_isdead(src)) + if(status_isdead(*src)) return 0; sd = BL_CAST(BL_PC, src); @@ -14112,7 +14109,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui // Final heal increased by HPlus. // Is this the right place for this??? [Rytech] // Can HPlus also affect SP recovery??? - status_data *sstatus = status_get_status_data(src); + status_data* sstatus = status_get_status_data(*src); if (sstatus && sstatus->hplus > 0) { potion_hp += potion_hp * sstatus->hplus / 100; @@ -14477,10 +14474,9 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui } break; case KO_MUCHANAGE: { - struct status_data *sstatus; int rate = 0; - sstatus = status_get_status_data(src); + status_data* sstatus = status_get_status_data(*src); i = skill_get_splash(skill_id,skill_lv); rate = (100 - (1000 / (sstatus->dex + sstatus->luk) * 5)) * (skill_lv / 2 + 5) / 10; if( rate < 0 ) @@ -14997,7 +14993,6 @@ std::shared_ptr skill_unitsetting(struct block_list *src, ui t_itemid req_item = 0; struct s_skill_unit_layout *layout; map_session_data *sd; - struct status_data *status; status_change *sc; int active_flag = 1; int subunt = 0; @@ -15016,7 +15011,7 @@ std::shared_ptr skill_unitsetting(struct block_list *src, ui layout = skill_get_unit_layout(skill_id,skill_lv,src,x,y); sd = BL_CAST(BL_PC, src); - status = status_get_status_data(src); + status_data* status = status_get_status_data(*src); sc = status_get_sc(src); // for traps, firewall and fogwall - celest hidden = (skill->unit_flag[UF_HIDDENTRAP] && (battle_config.traps_setting == 2 || (battle_config.traps_setting == 1 && map_flag_vs(src->m)))); @@ -15596,14 +15591,13 @@ static int skill_unit_onplace(struct skill_unit *unit, struct block_list *bl, t_ struct block_list *ss; // Actual source that cast the skill unit status_change *sc; struct status_change_entry *sce; - struct status_data *tstatus; enum sc_type type; uint16 skill_id; nullpo_ret(unit); nullpo_ret(bl); - if(bl->prev == nullptr || !unit->alive || status_isdead(bl)) + if(bl->prev == nullptr || !unit->alive || status_isdead(*bl)) return 0; std::shared_ptr sg = unit->group; @@ -15613,7 +15607,7 @@ static int skill_unit_onplace(struct skill_unit *unit, struct block_list *bl, t_ nullpo_ret(ss = map_id2bl(sg->src_id)); - tstatus = status_get_status_data(bl); + status_data* tstatus = status_get_status_data(*bl); if( (skill_get_type(sg->skill_id) == BF_MAGIC && ((battle_config.land_protector_behavior) ? map_getcell(bl->m, bl->x, bl->y, CELL_CHKLANDPROTECTOR) : map_getcell(unit->bl.m, unit->bl.x, unit->bl.y, CELL_CHKLANDPROTECTOR)) && sg->skill_id != SA_LANDPROTECTOR) || map_getcell(bl->m, bl->x, bl->y, CELL_CHKMAELSTROM) ) @@ -15941,7 +15935,6 @@ int skill_unit_onplace_timer(struct skill_unit *unit, struct block_list *bl, t_t { struct block_list *ss; TBL_PC* tsd; - struct status_data *tstatus; status_change *sc, *tsc; struct skill_unit_group_tickset *ts; enum sc_type type; @@ -15951,7 +15944,7 @@ int skill_unit_onplace_timer(struct skill_unit *unit, struct block_list *bl, t_t nullpo_ret(unit); nullpo_ret(bl); - if (bl->prev == nullptr || !unit->alive || status_isdead(bl)) + if (bl->prev == nullptr || !unit->alive || status_isdead(*bl)) return 0; std::shared_ptr sg = unit->group; @@ -15964,7 +15957,7 @@ int skill_unit_onplace_timer(struct skill_unit *unit, struct block_list *bl, t_t tsd = BL_CAST(BL_PC, bl); tsc = status_get_sc(bl); sc = status_get_sc(ss); - tstatus = status_get_status_data(bl); + status_data* tstatus = status_get_status_data(*bl); type = skill_get_sc(sg->skill_id); skill_id = sg->skill_id; @@ -16061,7 +16054,7 @@ int skill_unit_onplace_timer(struct skill_unit *unit, struct block_list *bl, t_t break; } } while(sg->interval > 0 && x == bl->x && y == bl->y && - ++count < SKILLUNITTIMER_INTERVAL/sg->interval && !status_isdead(bl) ); + ++count < SKILLUNITTIMER_INTERVAL/sg->interval && !status_isdead(*bl) ); } break; #ifndef RENEWAL // The storm gust counter was dropped in renewal @@ -16114,7 +16107,7 @@ int skill_unit_onplace_timer(struct skill_unit *unit, struct block_list *bl, t_t do skill_attack(BF_MAGIC,ss,&unit->bl,bl,sg->skill_id,sg->skill_lv,tick+(t_tick)count*sg->interval,0); while(sg->interval > 0 && --unit->val2 && x == bl->x && y == bl->y && - ++count < SKILLUNITTIMER_INTERVAL/sg->interval && !status_isdead(bl)); + ++count < SKILLUNITTIMER_INTERVAL/sg->interval && !status_isdead(*bl)); if (unit->val2 <= 0) skill_delunit(unit); @@ -16761,7 +16754,7 @@ int skill_unit_onout(struct skill_unit *src, struct block_list *bl, t_tick tick) type = skill_get_sc(sg->skill_id); sce = (sc && type != SC_NONE)?sc->getSCE(type):nullptr; - if (bl->prev == nullptr || (status_isdead(bl) && sg->unit_id != UNT_ANKLESNARE)) //Need to delete the trap if the source died. + if (bl->prev == nullptr || (status_isdead(*bl) && sg->unit_id != UNT_ANKLESNARE)) //Need to delete the trap if the source died. return 0; switch(sg->unit_id){ @@ -19935,7 +19928,7 @@ int skill_frostjoke_scream(struct block_list *bl, va_list ap) return 0; tick = va_arg(ap,t_tick); - if (src == bl || status_isdead(bl)) + if (src == bl || status_isdead(*bl)) return 0; if (bl->type == BL_PC) { map_session_data *sd = (map_session_data *)bl; @@ -19981,7 +19974,7 @@ int skill_attack_area(struct block_list *bl, va_list ap) int atk_type,skill_id,skill_lv,flag,type; t_tick tick; - if(status_isdead(bl)) + if(status_isdead(*bl)) return 0; atk_type = va_arg(ap,int); @@ -20454,7 +20447,7 @@ static int skill_trap_splash(struct block_list *bl, va_list ap) case UNT_MAIZETRAP: case UNT_VERDURETRAP: if( bl->type == BL_MOB && status_get_class_(bl) != CLASS_BOSS ) { - struct status_data *status = status_get_status_data(bl); + status_data* status = status_get_status_data(*bl); status->def_ele = skill_get_ele(sg->skill_id, sg->skill_lv); status->ele_lv = (unsigned char)sg->skill_lv; @@ -20611,7 +20604,7 @@ bool skill_check_shadowform(struct block_list *bl, int64 damage, int hit) return false; } - if( src && (status_isdead(src) || !battle_check_target(bl,src,BCT_ENEMY)) ) { + if( src && (status_isdead(*src) || !battle_check_target(bl,src,BCT_ENEMY)) ) { if( src->type == BL_PC ) ((TBL_PC*)src)->shadowform_id = 0; status_change_end(bl, SC__SHADOWFORM); @@ -20992,7 +20985,7 @@ int skill_delunitgroup_(std::shared_ptr group, const char* f return 0; } - if( !status_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: @@ -21877,11 +21870,10 @@ bool skill_produce_mix(map_session_data *sd, uint16 skill_id, t_itemid nameid, i 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; nullpo_ret(sd); - status = status_get_status_data(&sd->bl); + status_data* status = status_get_status_data(sd->bl); if( sd->skill_id_old == skill_id ) skill_lv = sd->skill_lv_old; diff --git a/src/map/status.cpp b/src/map/status.cpp index a228d25f35..e67dd3660a 100644 --- a/src/map/status.cpp +++ b/src/map/status.cpp @@ -1243,10 +1243,11 @@ static inline void status_cpy(struct status_data* a, const struct status_data* b */ int status_set_hp(struct block_list *bl, unsigned int hp, int flag) { - struct status_data *status; if (hp < 1) return 0; - status = status_get_status_data(bl); + + status_data* status = status_get_status_data(*bl); + if (status == &dummy_status) return 0; @@ -1269,12 +1270,13 @@ int status_set_hp(struct block_list *bl, unsigned int hp, int flag) */ int status_set_maxhp(struct block_list *bl, unsigned int maxhp, int flag) { - struct status_data *status; int64 heal; if (maxhp < 1) return 0; - status = status_get_status_data(bl); + + status_data* status = status_get_status_data(*bl); + if (status == &dummy_status) return 0; @@ -1302,9 +1304,8 @@ int status_set_maxhp(struct block_list *bl, unsigned int maxhp, int flag) */ int status_set_sp(struct block_list *bl, unsigned int sp, int flag) { - struct status_data *status; + status_data* status = status_get_status_data(*bl); - status = status_get_status_data(bl); if (status == &dummy_status) return 0; @@ -1327,10 +1328,11 @@ int status_set_sp(struct block_list *bl, unsigned int sp, int flag) */ int status_set_maxsp(struct block_list *bl, unsigned int maxsp, int flag) { - struct status_data *status; if (maxsp < 1) return 0; - status = status_get_status_data(bl); + + status_data* status = status_get_status_data(*bl); + if (status == &dummy_status) return 0; @@ -1355,7 +1357,7 @@ int status_set_maxsp(struct block_list *bl, unsigned int maxsp, int flag) */ int status_set_ap(struct block_list *bl, unsigned int ap, int flag) { - status_data *status = status_get_status_data(bl); + status_data *status = status_get_status_data(*bl); if (status == &dummy_status) return 0; @@ -1382,7 +1384,7 @@ int status_set_maxap(struct block_list *bl, unsigned int maxap, int flag) if (maxap < 1) return 0; - status_data *status = status_get_status_data(bl); + status_data *status = status_get_status_data(*bl); if (status == &dummy_status) return 0; @@ -1434,7 +1436,6 @@ int64 status_charge(struct block_list* bl, int64 hp, int64 sp) */ int status_damage(struct block_list *src,struct block_list *target,int64 dhp, int64 dsp, int64 dap, t_tick walkdelay, int flag, uint16 skill_id) { - struct status_data *status; status_change *sc; int hp = (int)cap_value(dhp,INT_MIN,INT_MAX); int sp = (int)cap_value(dsp,INT_MIN,INT_MAX); @@ -1469,8 +1470,9 @@ int status_damage(struct block_list *src,struct block_list *target,int64 dhp, in return 0; } - status = status_get_status_data(target); - if(!status || status == &dummy_status ) + status_data* status = status_get_status_data(*target); + + if( status == &dummy_status ) return 0; if ((unsigned int)hp >= status->hp) { @@ -1720,13 +1722,12 @@ int status_damage(struct block_list *src,struct block_list *target,int64 dhp, in */ int status_heal(struct block_list *bl,int64 hhp,int64 hsp, int64 hap, int flag) { - struct status_data *status; status_change *sc; int hp = (int)cap_value(hhp,INT_MIN,INT_MAX); int sp = (int)cap_value(hsp,INT_MIN,INT_MAX); int ap = (int)cap_value(hap,INT_MIN,INT_MAX); - status = status_get_status_data(bl); + status_data* status = status_get_status_data(*bl); if (status == &dummy_status || !status->hp) return 0; @@ -1821,11 +1822,8 @@ int status_heal(struct block_list *bl,int64 hhp,int64 hsp, int64 hap, int flag) */ int status_percent_change(struct block_list *src, struct block_list *target, int8 hp_rate, int8 sp_rate, int8 ap_rate, uint8 flag) { - struct status_data *status; unsigned int hp = 0, sp = 0, ap = 0; - - status = status_get_status_data(target); - + status_data* status = status_get_status_data(*target); // It's safe now [MarkZD] if (hp_rate > 99) @@ -1902,11 +1900,11 @@ int status_percent_change(struct block_list *src, struct block_list *target, int */ int status_revive(struct block_list *bl, unsigned char per_hp, unsigned char per_sp, unsigned char per_ap) { - struct status_data *status; unsigned int hp, sp, ap; - if (!status_isdead(bl)) return 0; + if (!status_isdead(*bl)) return 0; + + status_data* status = status_get_status_data(*bl); - status = status_get_status_data(bl); if (status == &dummy_status) return 0; // Invalid target. @@ -1958,13 +1956,13 @@ int status_revive(struct block_list *bl, unsigned char per_hp, unsigned char per * @author [Skotlex] */ bool status_check_skilluse(struct block_list *src, struct block_list *target, uint16 skill_id, int flag) { - struct status_data *status; + status_data* status; int hide_flag; if (src) { - if (src->type != BL_PC && status_isdead(src)) + if (src->type != BL_PC && status_isdead(*src)) return false; - status = status_get_status_data(src); + status = status_get_status_data(*src); }else{ status = &dummy_status; } @@ -1980,7 +1978,7 @@ bool status_check_skilluse(struct block_list *src, struct block_list *target, ui return false; // Dead state is not checked for skills as some skills can be used // on dead characters, said checks are left to skill.cpp [Skotlex] - if (target && status_isdead(target)) + if (target && status_isdead(*target)) return false; } @@ -1992,7 +1990,7 @@ bool status_check_skilluse(struct block_list *src, struct block_list *target, ui break; #endif case GN_WALLOFTHORN: - if( target && status_isdead(target) ) + if( target && status_isdead(*target) ) return false; break; case AL_TELEPORT: @@ -2222,7 +2220,6 @@ bool status_check_skilluse(struct block_list *src, struct block_list *target, ui int status_check_visibility(struct block_list *src, struct block_list *target) { int view_range; - struct status_data* status = status_get_status_data(src); status_change* tsc = status_get_sc(target); switch (src->type) { case BL_MOB: @@ -2243,7 +2240,7 @@ int status_check_visibility(struct block_list *src, struct block_list *target) if (tsc) { bool is_boss = (status_get_class_(src) == CLASS_BOSS); - bool is_detector = status_has_mode(status,MD_DETECTOR); + bool is_detector = status_bl_has_mode(src,MD_DETECTOR); switch (target->type) { // Check for chase-walk/hiding/cloaking opponents. case BL_PC: { @@ -2877,18 +2874,24 @@ int status_calc_mob_(struct mob_data* md, uint8 opt) } case NC_SILVERSNIPER: { - struct status_data *mstatus = status_get_status_data(mbl); + status_data* mstatus = status_get_status_data(*mbl); + + // TODO: check if dummy_status? Can never be nullptr [Lemongrass] if(!mstatus) break; + status->max_hp = (1000 * ud->skill_lv) + (mstatus->hp / 3) + (status_get_lv(mbl) * 12); status->batk = 200 * ud->skill_lv; break; } case NC_MAGICDECOY: { - struct status_data *mstatus = status_get_status_data(mbl); + status_data* mstatus = status_get_status_data(*mbl); + + // TODO: check if dummy_status? Can never be nullptr [Lemongrass] if(!mstatus) break; + status->max_hp = (1000 * ((TBL_PC*)mbl)->menuskill_val) + (mstatus->sp * 4) + (status_get_lv(mbl) * 12); status->matk_min = status->matk_max = 250 + 50*((TBL_PC*)mbl)->menuskill_val; break; @@ -2898,8 +2901,9 @@ int status_calc_mob_(struct mob_data* md, uint8 opt) case MT_SUMMON_ABR_MOTHER_NET: case MT_SUMMON_ABR_INFINITY: { map_session_data *msd = BL_CAST(BL_PC, mbl); - status_data *mstatus = status_get_status_data(mbl); + status_data* mstatus = status_get_status_data(*mbl); + // TODO: check if mstatus is dummy_status? Can never be nullptr [Lemongrass] if (msd == nullptr || mstatus == nullptr) break; @@ -2933,8 +2937,9 @@ int status_calc_mob_(struct mob_data* md, uint8 opt) case BO_CREEPER: case BO_HELLTREE: { map_session_data *msd = BL_CAST(BL_PC, mbl); - status_data *mstatus = status_get_status_data(mbl); + status_data* mstatus = status_get_status_data(*mbl); + // TODO: check if mstatus is dummy_status? Can never be nullptr [Lemongrass] if (msd == nullptr || mstatus == nullptr) break; @@ -5596,7 +5601,7 @@ void status_calc_state( struct block_list *bl, status_change *sc, std::bitset flag) { const struct status_data *b_status = status_get_base_status(&bl); // Base Status - struct status_data *status = status_get_status_data(&bl); // Battle Status + status_data* status = status_get_status_data(bl); // Battle Status status_change *sc = status_get_sc(&bl); TBL_PC *sd = BL_CAST(BL_PC,&bl); int temp; @@ -6239,9 +6244,6 @@ void status_calc_bl_main(struct block_list& bl, std::bitset flag) */ void status_calc_bl_(struct block_list* bl, std::bitset flag, uint8 opt) { - struct status_data b_status; // Previous battle status - struct status_data* status; // Pointer to current battle status - if (bl->type == BL_PC) { map_session_data *sd = BL_CAST(BL_PC, bl); @@ -6255,9 +6257,14 @@ void status_calc_bl_(struct block_list* bl, std::bitset flag, uint8 opt } } + // Pointer to current battle status + status_data* status = status_get_status_data(*bl); + + // Previous battle status + status_data b_status; + // Remember previous values - status = status_get_status_data(bl); - memcpy(&b_status, status, sizeof(struct status_data)); + memcpy(&b_status, status, sizeof(b_status)); if( flag[SCB_BASE] ) { // Calculate the object's base status too switch( bl->type ) { @@ -8991,18 +8998,29 @@ struct regen_data *status_get_regen_data(struct block_list *bl) * @param bl: Object whose status to get [PC|MOB|PET|HOM|MER|ELEM|NPC] * @return status or "dummy_status" if any other bl->type than noted above */ -struct status_data *status_get_status_data(struct block_list *bl) -{ - nullpo_retr(&dummy_status, bl); +status_data* status_get_status_data(block_list& bl){ + switch (bl.type) { + case BL_PC: + return &reinterpret_cast( &bl )->battle_status; + case BL_MOB: + return &reinterpret_cast( &bl )->status; + case BL_PET: + return &reinterpret_cast( &bl )->status; + case BL_HOM: + return &reinterpret_cast( &bl )->battle_status; + case BL_MER: + return &reinterpret_cast( &bl )->battle_status; + case BL_ELEM: + return &reinterpret_cast( &bl )->battle_status; + case BL_NPC: { + npc_data* nd = reinterpret_cast( &bl ); - switch (bl->type) { - case BL_PC: return &((TBL_PC*)bl)->battle_status; - case BL_MOB: return &((TBL_MOB*)bl)->status; - case BL_PET: return &((TBL_PET*)bl)->status; - case BL_HOM: return &((TBL_HOM*)bl)->battle_status; - case BL_MER: return &((TBL_MER*)bl)->battle_status; - case BL_ELEM: return &((TBL_ELEM*)bl)->battle_status; - case BL_NPC: return ((mobdb_checkid(((TBL_NPC*)bl)->class_) == 0) ? &((TBL_NPC*)bl)->status : &dummy_status); + if( mobdb_checkid( nd->class_ ) == 0 ){ + return &nd->status; + }else{ + return &dummy_status; + } + } default: return &dummy_status; } @@ -9037,7 +9055,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 = status_get_status_data(bl); + status_data* status = status_get_status_data(*bl); + // TODO: check if dummy_status? Can never be nullptr [Lemongrass] int def = status?status->def:0; ud = unit_bl2ud(bl); if (ud && ud->skilltimer != INVALID_TIMER) @@ -9053,9 +9072,10 @@ defType status_get_def(struct block_list *bl) */ unsigned short status_get_speed(struct block_list *bl) { + // TODO: is the statement of Skotlex still true? And would it not be better to check for dummy_status instead? [Lemongrass] 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; + return status_get_status_data(*bl)->speed; } /** @@ -9221,9 +9241,7 @@ std::vector status_get_race2(struct block_list *bl) * @param bl: Object to check [PC|MOB|HOM|MER|ELEM] * @return 1: Is dead or 0: Is alive */ -int status_isdead(struct block_list *bl) -{ - nullpo_ret(bl); +bool status_isdead(block_list &bl){ return status_get_status_data(bl)->hp == 0; } @@ -9525,8 +9543,6 @@ t_tick status_get_sc_def(struct block_list *src, struct block_list *bl, enum sc_ /// Example: 25% (2500) -> sc_def2 = 2000 -> 5%; /// 2500ms -> tick_def2=2000 -> 500ms int sc_def2 = 0, tick_def2 = 0; - - struct status_data *status, *status_src; status_change *sc; map_session_data *sd; @@ -9549,8 +9565,8 @@ t_tick status_get_sc_def(struct block_list *src, struct block_list *bl, enum sc_ } sd = BL_CAST(BL_PC,bl); - status = status_get_status_data(bl); - status_src = status_get_status_data(src); + status_data* status = status_get_status_data(*bl); + status_data* status_src = status_get_status_data(*src); sc = status_get_sc(bl); if( sc && !sc->count ) sc = nullptr; @@ -10026,7 +10042,6 @@ int status_change_start(struct block_list* src, struct block_list* bl,enum sc_ty map_session_data *sd = nullptr; status_change* sc; struct status_change_entry* sce; - struct status_data *status; struct view_data *vd; int undead_flag, tick_time = 0; bool sc_isnew = true; @@ -10034,7 +10049,6 @@ int status_change_start(struct block_list* src, struct block_list* bl,enum sc_ty nullpo_ret(bl); sc = status_get_sc(bl); - status = status_get_status_data(bl); if( !scdb ) { ShowError("status_change_start: Invalid status change (%d)!\n", type); @@ -10044,7 +10058,7 @@ int status_change_start(struct block_list* src, struct block_list* bl,enum sc_ty if( !sc ) return 0; // Unable to receive status changes - if( bl->type != BL_NPC && status_isdead(bl) && ( type != SC_NOCHAT && type != SC_JAILED ) ) // SC_NOCHAT and SC_JAILED should work even on dead characters + if( bl->type != BL_NPC && status_isdead(*bl) && ( type != SC_NOCHAT && type != SC_JAILED ) ) // SC_NOCHAT and SC_JAILED should work even on dead characters return 0; if (status_change_isDisabledOnMap(type, map_getmapdata(bl->m))) @@ -10061,6 +10075,8 @@ int status_change_start(struct block_list* src, struct block_list* bl,enum sc_ty if (sc->option&OPTION_MADOGEAR && flag&SCSTART_NOAVOID && scdb->flag[SCF_FAILEDMADO]) return 0; + status_data* status = status_get_status_data(*bl); + // Check for Boss resistances if(status->mode&MD_STATUSIMMUNE && !(flag&SCSTART_NOAVOID) && scdb->flag[SCF_BOSSRESIST]) return 0; @@ -11219,12 +11235,13 @@ int status_change_start(struct block_list* src, struct block_list* bl,enum sc_ty struct block_list *pbl = map_id2bl(val1); status_change *psc = pbl?status_get_sc(pbl):nullptr; struct status_change_entry *psce = psc?psc->getSCE(SC_MARIONETTE):nullptr; - // Fetch target's stats - struct status_data* status2 = status_get_status_data(bl); // Battle status if (!psce) return 0; + // Fetch target's stats + status_data* status2 = status_get_status_data(*bl); // Battle status + val3 = 0; val4 = 0; max_stat = battle_config.max_parameter; // Cap to 99 (default) @@ -11240,7 +11257,7 @@ int status_change_start(struct block_list* src, struct block_list* bl,enum sc_ty //1st Transcendent Spirit works similar to Marionette Control if(sd && val2 == SL_HIGH) { int stat,max_stat; - struct status_data *status2 = status_get_base_status(bl); + status_data *status2 = status_get_base_status(bl); val3 = 0; val4 = 0; @@ -13246,14 +13263,12 @@ int status_change_end(struct block_list* bl, enum sc_type type, int tid) map_session_data *sd; status_change *sc; struct status_change_entry *sce; - struct status_data *status; struct view_data *vd; std::shared_ptr scdb = status_db.find(type); nullpo_ret(bl); sc = status_get_sc(bl); - status = status_get_status_data(bl); if(!sc || !(sce = sc->getSCE(type)) || !scdb) return 0; @@ -13299,7 +13314,7 @@ int status_change_end(struct block_list* bl, enum sc_type type, int tid) sce->val4 = 0; if (group) skill_delunitgroup(group); - if (!status_isdead(bl) && (sce->val2 || sce->val3 || sce->val4)) + if (!status_isdead(*bl) && (sce->val2 || sce->val3 || sce->val4)) return 0; //Don't end the status change yet as there are still unit groups associated with it } if (sce->timer != INVALID_TIMER) // Could be a SC with infinite duration @@ -13318,6 +13333,7 @@ int status_change_end(struct block_list* bl, enum sc_type type, int tid) vd = status_get_viewdata(bl); std::bitset calc_flag = scdb->calc_flag; + status_data* status = status_get_status_data(*bl); switch(type) { case SC_KEEPING: @@ -13747,7 +13763,7 @@ int status_change_end(struct block_list* bl, enum sc_type type, int tid) if( tid != INVALID_TIMER ){ map_session_data *caster = nullptr; - if (status_isdead(bl) || !(caster = map_id2sd(sce->val2))) + if (status_isdead(*bl) || !(caster = map_id2sd(sce->val2))) break; std::shared_ptr skill = skill_db.find(RL_H_MINE); @@ -13931,7 +13947,7 @@ TIMER_FUNC(status_change_timer){ } status_change * const sc = status_get_sc(bl); - struct status_data * const status = status_get_status_data(bl); + if(!sc) { ShowDebug("status_change_timer: Null pointer id: %d data: %" PRIdPTR " bl-type: %d\n", id, data, bl->type); return 0; @@ -13947,6 +13963,8 @@ TIMER_FUNC(status_change_timer){ return 0; } + const status_data* status = status_get_status_data(*bl); + sd = BL_CAST(BL_PC, bl); std::function sc_timer_next = [&sce, &bl, &data](t_tick t) { @@ -14564,7 +14582,7 @@ TIMER_FUNC(status_change_timer){ if (--(sce->val4) >= 0) { struct block_list *src = map_id2bl(sce->val2); - if (!src || (src && (status_isdead(src) || src->m != bl->m))) + if (!src || (src && (status_isdead(*src) || src->m != bl->m))) break; map_freeblock_lock(); if (!status_charge(bl, 0, 50)) @@ -14864,7 +14882,7 @@ TIMER_FUNC(status_change_timer){ struct block_list *star_caster = map_id2bl(sce->val2); struct skill_unit *star_aoe = (struct skill_unit *)map_id2bl(sce->val3); - if (star_caster == nullptr || status_isdead(star_caster) || star_caster->m != bl->m || star_aoe == nullptr) + if (star_caster == nullptr || status_isdead(*star_caster) || star_caster->m != bl->m || star_aoe == nullptr) break; sc_timer_next(500 + tick); @@ -14878,7 +14896,7 @@ TIMER_FUNC(status_change_timer){ if (--(sce->val4) >= 0) { // Needed to check the caster's location for the range check. struct block_list *unity_src = map_id2bl(sce->val2); - if (!unity_src || status_isdead(unity_src) || unity_src->m != bl->m || !check_distance_bl(bl, unity_src, 11)) + if (!unity_src || status_isdead(*unity_src) || unity_src->m != bl->m || !check_distance_bl(bl, unity_src, 11)) break; status_heal(bl, 150 * sce->val1, 0, 2); @@ -15004,7 +15022,7 @@ 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 t_tick tick = va_arg(ap,t_tick); - if (status_isdead(bl)) + if (status_isdead(*bl)) return 0; tsc = status_get_sc(bl); @@ -15208,7 +15226,6 @@ static t_tick natural_heal_prev_tick,natural_heal_diff_tick; static int status_natural_heal(struct block_list* bl, va_list args) { struct regen_data *regen; - struct status_data *status; status_change *sc; struct unit_data *ud; struct view_data *vd = nullptr; @@ -15219,7 +15236,9 @@ static int status_natural_heal(struct block_list* bl, va_list args) regen = status_get_regen_data(bl); if (!regen) return 0; - status = status_get_status_data(bl); + + status_data* status = status_get_status_data(*bl); + sc = status_get_sc(bl); if (sc && !sc->count) sc = nullptr; @@ -15237,7 +15256,7 @@ static int status_natural_heal(struct block_list* bl, va_list args) flag &= ~RGN_SSP; if (flag && ( - status_isdead(bl) || + status_isdead(*bl) || (sc && (sc->option&(OPTION_HIDE|OPTION_CLOAK|OPTION_CHASEWALK) || sc->getSCE(SC__INVISIBILITY))) )) flag = RGN_NONE; diff --git a/src/map/status.hpp b/src/map/status.hpp index 07005b5f8d..c239ceffa9 100644 --- a/src/map/status.hpp +++ b/src/map/status.hpp @@ -3399,68 +3399,68 @@ static int status_heal( struct block_list *bl,int64 hhp,int64 hsp, int flag ){ int status_revive(struct block_list *bl, unsigned char per_hp, unsigned char per_sp, unsigned char per_ap = 0); struct regen_data *status_get_regen_data(struct block_list *bl); -struct status_data *status_get_status_data(struct block_list *bl); +status_data* status_get_status_data(block_list& bl); struct status_data *status_get_base_status(struct block_list *bl); const char * status_get_name(struct block_list *bl); int status_get_class(struct block_list *bl); int status_get_lv(struct block_list *bl); -#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_ap(bl) status_get_status_data(bl)->ap -#define status_get_max_ap(bl) status_get_status_data(bl)->max_ap -#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_pow(bl) status_get_status_data(bl)->pow -#define status_get_sta(bl) status_get_status_data(bl)->sta -#define status_get_wis(bl) status_get_status_data(bl)->wis -#define status_get_spl(bl) status_get_status_data(bl)->spl -#define status_get_con(bl) status_get_status_data(bl)->con -#define status_get_crt(bl) status_get_status_data(bl)->crt -#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_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_ap(bl) status_get_status_data(*bl)->ap +#define status_get_max_ap(bl) status_get_status_data(*bl)->max_ap +#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_pow(bl) status_get_status_data(*bl)->pow +#define status_get_sta(bl) status_get_status_data(*bl)->sta +#define status_get_wis(bl) status_get_status_data(*bl)->wis +#define status_get_spl(bl) status_get_status_data(*bl)->spl +#define status_get_con(bl) status_get_status_data(*bl)->con +#define status_get_crt(bl) status_get_status_data(*bl)->crt +#define status_get_hit(bl) status_get_status_data(*bl)->hit +#define status_get_flee(bl) status_get_status_data(*bl)->flee defType status_get_def(struct block_list *bl); -#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_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 unsigned short status_get_speed(struct block_list *bl); -#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_clientamotion(bl) status_get_status_data(bl)->clientamotion -#define status_get_dmotion(bl) status_get_status_data(bl)->dmotion -#define status_get_patk(bl) status_get_status_data(bl)->patk -#define status_get_smatk(bl) status_get_status_data(bl)->smatk -#define status_get_res(bl) status_get_status_data(bl)->res -#define status_get_mres(bl) status_get_status_data(bl)->mres -#define status_get_hplus(bl) status_get_status_data(bl)->hplus -#define status_get_crate(bl) status_get_status_data(bl)->crate -#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_adelay(bl) status_get_status_data(*bl)->adelay +#define status_get_amotion(bl) status_get_status_data(*bl)->amotion +#define status_get_clientamotion(bl) status_get_status_data(*bl)->clientamotion +#define status_get_dmotion(bl) status_get_status_data(*bl)->dmotion +#define status_get_patk(bl) status_get_status_data(*bl)->patk +#define status_get_smatk(bl) status_get_status_data(*bl)->smatk +#define status_get_res(bl) status_get_status_data(*bl)->res +#define status_get_mres(bl) status_get_status_data(*bl)->mres +#define status_get_hplus(bl) status_get_status_data(*bl)->hplus +#define status_get_crate(bl) status_get_status_data(*bl)->crate +#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 unsigned char status_calc_attack_element(struct block_list *bl, status_change *sc, int element); #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_class_(bl) status_get_status_data(bl)->class_ -#define status_get_size(bl) status_get_status_data(bl)->size -#define status_get_mode(bl) status_get_status_data(bl)->mode +#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_class_(bl) status_get_status_data(*bl)->class_ +#define status_get_size(bl) status_get_status_data(*bl)->size +#define status_get_mode(bl) status_get_status_data(*bl)->mode #define status_has_mode(status,md) (((status)->mode&(md)) == (md)) -#define status_bl_has_mode(bl,md) status_has_mode(status_get_status_data((bl)),(md)) +#define status_bl_has_mode(bl,md) status_has_mode(status_get_status_data(*(bl)),(md)) #define status_get_homstr(bl) (status->str + ((TBL_HOM*)bl)->homunculus.str_value) #define status_get_homagi(bl) (status->agi + ((TBL_HOM*)bl)->homunculus.agi_value) @@ -3479,7 +3479,7 @@ void status_set_viewdata(struct block_list *bl, int class_); void status_change_init(struct block_list *bl); status_change *status_get_sc(struct block_list *bl); -int status_isdead(struct block_list *bl); +bool status_isdead(block_list &bl); int status_isimmune(struct block_list *bl); t_tick status_get_sc_def(struct block_list *src,struct block_list *bl, enum sc_type type, int rate, t_tick tick, unsigned char flag); diff --git a/src/map/unit.cpp b/src/map/unit.cpp index 8f5d4820d0..763cdd6fcf 100644 --- a/src/map/unit.cpp +++ b/src/map/unit.cpp @@ -507,7 +507,7 @@ static TIMER_FUNC(unit_walktoxy_timer) ud->state.walk_script = false; // Check if the unit was killed - if( status_isdead(bl) ){ + if( status_isdead(*bl) ){ struct mob_data* md = BL_CAST(BL_MOB, bl); if( md && !md->spawn ){ @@ -1668,7 +1668,7 @@ int unit_set_walkdelay(struct block_list *bl, t_tick tick, t_tick delay, int typ if (type) { //Bosses can ignore skill induced walkdelay (but not damage induced) - if(bl->type == BL_MOB && status_has_mode(status_get_status_data(bl),MD_STATUSIMMUNE)) + if(bl->type == BL_MOB && status_has_mode(status_get_status_data(*bl),MD_STATUSIMMUNE)) return 0; //Make sure walk delay is not decreased if (DIFF_TICK(ud->canmove_tick, tick+delay) > 0) @@ -1724,7 +1724,6 @@ int unit_set_walkdelay(struct block_list *bl, t_tick tick, t_tick delay, int typ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, uint16 skill_lv, int casttime, int castcancel, bool ignore_range) { struct unit_data *ud; - struct status_data *tstatus; status_change *sc; map_session_data *sd = nullptr; struct block_list * target = nullptr; @@ -1733,7 +1732,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui nullpo_ret(src); - if(status_isdead(src)) + if(status_isdead(*src)) return 0; // Do not continue source is dead sd = BL_CAST(BL_PC, src); @@ -1873,7 +1872,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui return 0; } - tstatus = status_get_status_data(target); + status_data* tstatus = status_get_status_data(*target); // Record the status of the previous skill) if(sd) { @@ -2018,7 +2017,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)) combo = 1; - else if (!status_isdead(target)) + else if (!status_isdead(*target)) return 0; // Can't cast on non-dead characters. break; case MO_FINGEROFFENSIVE: @@ -2240,9 +2239,9 @@ int unit_skilluse_pos(struct block_list *src, short skill_x, short skill_y, uint int unit_skilluse_pos2( struct block_list *src, short skill_x, short skill_y, uint16 skill_id, uint16 skill_lv, int casttime, int castcancel, bool ignore_range) { map_session_data *sd = nullptr; - struct unit_data *ud = nullptr; + struct unit_data *ud = nullptr; status_change *sc; - struct block_list bl; + struct block_list bl; t_tick tick = gettick(); int range; @@ -2251,7 +2250,7 @@ int unit_skilluse_pos2( struct block_list *src, short skill_x, short skill_y, ui if (!src->prev) return 0; // Not on the map - if(status_isdead(src)) + if(status_isdead(*src)) return 0; sd = BL_CAST(BL_PC, src); @@ -2539,7 +2538,7 @@ int unit_attack(struct block_list *src,int target_id,int continuous) nullpo_ret(ud = unit_bl2ud(src)); target = map_id2bl(target_id); - if( target == nullptr || status_isdead(target) ) { + if( target == nullptr || status_isdead(*target) ) { unit_unattackable(src); return 1; } @@ -2797,7 +2796,6 @@ static int unit_attack_timer_sub(struct block_list* src, int tid, t_tick tick) { struct block_list *target; struct unit_data *ud; - struct status_data *sstatus; map_session_data *sd = nullptr; struct mob_data *md = nullptr; int range; @@ -2818,7 +2816,7 @@ static int unit_attack_timer_sub(struct block_list* src, int tid, t_tick tick) if( src == nullptr || src->prev == nullptr || target==nullptr || target->prev == nullptr ) return 0; - if( status_isdead(src) || status_isdead(target) || + 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(nullptr, src->m, src->x, src->y, target->x, target->y, CELL_CHKWALL) @@ -2856,7 +2854,7 @@ static int unit_attack_timer_sub(struct block_list* src, int tid, t_tick tick) return 1; } - sstatus = status_get_status_data(src); + status_data* sstatus = status_get_status_data(*src); range = sstatus->rhw.range; if( (unit_is_walking(target) || ud->state.step_attack) @@ -3412,7 +3410,7 @@ int unit_remove_map_(struct block_list *bl, clr_type clrtype, const char* file, break; case BL_MOB: // /BL_MOB is handled by mob_dead unless the monster is not dead. - if (status_isdead(bl)) { + if (status_isdead(*bl)) { map_delblock(bl); break; } @@ -3522,7 +3520,7 @@ int unit_free(struct block_list *bl, clr_type clrtype) map_session_data *sd = (map_session_data*)bl; int i; - if( status_isdead(bl) ) + if( status_isdead(*bl) ) pc_setrestartvalue(sd,2); pc_delinvincibletimer(sd);