Bladeren bron

Added status_change::empty (#8830)

Co-authored-by: Atemo <Atemo@users.noreply.github.com>
Lemongrass3110 6 maanden geleden
bovenliggende
commit
d4a3704203
13 gewijzigde bestanden met toevoegingen van 158 en 137 verwijderingen
  1. 17 17
      src/map/battle.cpp
  2. 1 1
      src/map/battleground.cpp
  3. 5 4
      src/map/clif.cpp
  4. 1 1
      src/map/elemental.cpp
  5. 3 3
      src/map/map.cpp
  6. 2 2
      src/map/mob.cpp
  7. 1 1
      src/map/npc.cpp
  8. 8 8
      src/map/pc.cpp
  9. 17 7
      src/map/script.cpp
  10. 32 32
      src/map/skill.cpp
  11. 67 58
      src/map/status.cpp
  12. 1 0
      src/map/status.hpp
  13. 3 3
      src/map/unit.cpp

+ 17 - 17
src/map/battle.cpp

@@ -467,7 +467,7 @@ int64 battle_attr_fix(struct block_list *src, struct block_list *target, int64 d
 	}
 
 	ratio = elemental_attribute_db.getAttribute(def_lv, atk_elem, def_type);
-	if (sc && sc->count) { //increase dmg by src status
+	if (sc != nullptr && !sc->empty()) { //increase dmg by src status
 		switch(atk_elem){
 			case ELE_FIRE:
 				if (sc->getSCE(SC_VOLCANO))
@@ -528,7 +528,7 @@ int64 battle_attr_fix(struct block_list *src, struct block_list *target, int64 d
 		}
 	}
 
-	if (tsc && tsc->count) { //increase dmg by target status
+	if (tsc != nullptr && !tsc->empty()) { //increase dmg by target status
 		switch(atk_elem) {
 			case ELE_FIRE:
 				if (tsc->getSCE(SC_SPIDERWEB)) { //Double damage
@@ -1676,7 +1676,7 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam
 		return damage;
 	}
 
-	if( tsc && tsc->count ) {
+	if( tsc != nullptr && !tsc->empty() ) {
 		// Damage increasing effects
 #ifdef RENEWAL // Flat +400% damage from melee
 		if (tsc->getSCE(SC_KAITE) && (flag&(BF_SHORT|BF_MAGIC)) == BF_SHORT)
@@ -1941,7 +1941,7 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam
 	//SC effects from caster side.
 	status_change* sc = status_get_sc(src);
 
-	if (sc && sc->count) {
+	if (sc != nullptr && !sc->empty()) {
 		if (sc->getSCE(SC_BREAKINGLIMIT)) {
 			switch (skill_id) {
 				case HN_SHIELD_CHAIN_RUSH:
@@ -2052,7 +2052,7 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam
 	sc = status_get_sc(bl);
 
 	// !TODO: Should RELIEVE needed to be down here or after some other check? Should the skill be independent of damagetaken from mob_db.yml?
-	if (sc && sc->count) {
+	if (sc != nullptr && !sc->empty()) {
 		if ((sce = sc->getSCE(SC_RELIEVE_ON)) && !sc->getSCE(SC_RELIEVE_OFF))
 			damage = i64max((damage - damage * sce->val2 / 100), 1);
 	}
@@ -2064,7 +2064,7 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam
 			damage = i64max(damage * md->damagetaken / 100, 1);
 	}
 	
-	if (tsc && tsc->count) {
+	if (tsc != nullptr && !tsc->empty()) {
 		if (!battle_status_block_damage(src, bl, tsc, d, damage, skill_id, skill_lv)) // Statuses that reduce damage to 0.
 			return 0;
 	}
@@ -3624,7 +3624,7 @@ int32 battle_get_magic_element(struct block_list* src, struct block_list* target
 			break;
 		case NPC_PSYCHIC_WAVE:
 		case SO_PSYCHIC_WAVE:
-			if( sc && sc->count ) {
+			if( sc != nullptr && !sc->empty() ) {
 				static const std::vector<sc_type> types = {
 					SC_HEATER_OPTION,
 					SC_COOLER_OPTION,
@@ -4450,7 +4450,7 @@ static void battle_calc_multi_attack(struct Damage* wd, struct block_list *src,s
 			}
 		}
 		if( wd->div_ == 1 && ((sd->weapontype1 == W_REVOLVER && (skill_lv = pc_checkskill(sd,GS_CHAINACTION)) > 0) //Normal Chain Action effect
-			|| (sc && sc->count && sc->getSCE(SC_E_CHAIN) && (skill_lv = sc->getSCE(SC_E_CHAIN)->val1) > 0)) //Chain Action of ETERNAL_CHAIN
+			|| (sc != nullptr && !sc->empty() && sc->getSCE(SC_E_CHAIN) && (skill_lv = sc->getSCE(SC_E_CHAIN)->val1) > 0)) //Chain Action of ETERNAL_CHAIN
 			&& rnd()%100 < 5*skill_lv ) //Success rate
 		{
 			wd->div_ = skill_get_num(GS_CHAINACTION,skill_lv);
@@ -7457,9 +7457,9 @@ static struct Damage battle_calc_weapon_attack(struct block_list *src, struct bl
 	right_element = battle_get_weapon_element(&wd, src, target, skill_id, skill_lv, EQI_HAND_R, false);
 	left_element = battle_get_weapon_element(&wd, src, target, skill_id, skill_lv, EQI_HAND_L, false);
 
-	if (sc && !sc->count)
+	if (sc != nullptr && sc->empty())
 		sc = nullptr; //Skip checking as there are no status changes active.
-	if (tsc && !tsc->count)
+	if (tsc != nullptr && tsc->empty())
 		tsc = nullptr; //Skip checking as there are no status changes active.
 
 	sd = BL_CAST(BL_PC, src);
@@ -9684,7 +9684,7 @@ int64 battle_calc_return_damage(struct block_list* tbl, struct block_list *src,
 	if (flag & BF_SHORT) {//Bounces back part of the damage.
 		if ( (skill_get_inf2(skill_id, INF2_ISTRAP) || !status_reflect) && tsd && tsd->bonus.short_weapon_damage_return ) {
 			rdamage += damage * tsd->bonus.short_weapon_damage_return / 100;
-		} else if( status_reflect && tsc && tsc->count ) {
+		} else if( status_reflect && tsc != nullptr && !tsc->empty() ) {
 			if( tsc->getSCE(SC_REFLECTSHIELD) ) {
 				status_change_entry *sce_d;
 				block_list *d_bl;
@@ -10014,9 +10014,9 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t
 	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]
+	if (sc != nullptr && sc->empty()) //Avoid sc checks when there's none to check for. [Skotlex]
 		sc = nullptr;
-	if (tsc && !tsc->count)
+	if (tsc != nullptr && tsc->empty())
 		tsc = nullptr;
 
 	if (sd)
@@ -10065,7 +10065,7 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t
 			}
 		}
 	}
-	if (sc && sc->count) {
+	if (sc != nullptr && !sc->empty()) {
 		if (sc->getSCE(SC_CLOAKING) && !(sc->getSCE(SC_CLOAKING)->val4 & 2))
 			status_change_end(src, SC_CLOAKING);
 		else if (sc->getSCE(SC_CLOAKINGEXCEED) && !(sc->getSCE(SC_CLOAKINGEXCEED)->val4 & 2))
@@ -10193,7 +10193,7 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t
 	if (sd && wd.damage + wd.damage2 > 0 && battle_vellum_damage(sd, target, &wd))
 		vellum_damage = true;
 
-	if( sc && sc->count ) {
+	if( sc != nullptr && !sc->empty() ) {
 		if (sc->getSCE(SC_EXEEDBREAK))
 			status_change_end(src, SC_EXEEDBREAK);
 		if( sc->getSCE(SC_SPELLFIST) && !vellum_damage ){
@@ -10767,7 +10767,7 @@ int32 battle_check_target( struct block_list *src, struct block_list *target,int
 
 				if (((TBL_PC*)target)->invincible_timer != INVALID_TIMER || pc_isinvisible((TBL_PC*)target))
 					return -1; //Cannot be targeted yet.
-				if( sc && sc->count ) {
+				if( sc != nullptr && !sc->empty() ) {
 					if( sc->getSCE(SC_VOICEOFSIREN) && sc->getSCE(SC_VOICEOFSIREN)->val2 == target->id )
 						return -1;
 				}
@@ -10910,7 +10910,7 @@ int32 battle_check_target( struct block_list *src, struct block_list *target,int
 						return 1;
 				}
 				//Status changes that prevent traps from triggering
-				if (sc && sc->count && inf2[INF2_ISTRAP]) {
+				if (sc != nullptr && !sc->empty() && inf2[INF2_ISTRAP]) {
 					if( sc->getSCE(SC_SIGHTBLASTER) && sc->getSCE(SC_SIGHTBLASTER)->val2 > 0 && sc->getSCE(SC_SIGHTBLASTER)->val4%2 == 0)
 						return -1;
 				}

+ 1 - 1
src/map/battleground.cpp

@@ -884,7 +884,7 @@ static bool bg_queue_check_status(map_session_data* sd, const char *name)
 {
 	nullpo_retr(false, sd);
 
-	if (sd->sc.count) {
+	if (!sd->sc.empty()) {
 		if (sd->sc.getSCE(SC_ENTRY_QUEUE_APPLY_DELAY)) { // Exclude any player who's recently left a battleground queue
 			char buf[CHAT_SIZE_MAX];
 

+ 5 - 4
src/map/clif.cpp

@@ -5183,7 +5183,7 @@ int32 clif_damage(block_list& src, block_list& dst, t_tick tick, int32 sdelay, i
 
 	status_change *sc = status_get_sc(&dst);
 
-	if(sc && sc->count) {
+	if(sc != nullptr && !sc->empty()) {
 		if(sc->getSCE(SC_HALLUCINATION)) {
 			damage = clif_hallucination_damage();
 			if(damage2)
@@ -5976,7 +5976,6 @@ void clif_skill_cooldown( map_session_data &sd, uint16 skill_id, t_tick tick ){
 int32 clif_skill_damage(struct block_list *src,struct block_list *dst,t_tick tick,int32 sdelay,int32 ddelay,int64 sdamage,int32 div,uint16 skill_id,uint16 skill_lv,enum e_damage_type type)
 {
 	unsigned char buf[64];
-	status_change *sc;
 	int32 damage = (int)cap_value(sdamage,INT_MIN,INT_MAX);
 
 	nullpo_ret(src);
@@ -5984,7 +5983,9 @@ int32 clif_skill_damage(struct block_list *src,struct block_list *dst,t_tick tic
 
 	type = clif_calc_delay(type,div,damage,ddelay);
 
-	if( ( sc = status_get_sc(dst) ) && sc->count ) {
+	status_change* sc = status_get_sc( dst );
+
+	if( sc != nullptr && !sc->empty() ) {
 		if(sc->getSCE(SC_HALLUCINATION) && damage)
 			damage = clif_hallucination_damage();
 	}
@@ -11697,7 +11698,7 @@ void clif_parse_ActionRequest_sub( map_session_data& sd, uint8 action_type, int3
 		if (sd.ud.skilltimer != INVALID_TIMER || (sd.sc.opt1 && sd.sc.opt1 != OPT1_STONEWAIT && sd.sc.opt1 != OPT1_BURNING))
 			break;
 
-		if (sd.sc.count && (
+		if (!sd.sc.empty() && (
 			sd.sc.getSCE(SC_DANCING) ||
 			(sd.sc.getSCE(SC_GRAVITATION) && sd.sc.getSCE(SC_GRAVITATION)->val3 == BCT_SELF)
 		)) //No sitting during these states either.

+ 1 - 1
src/map/elemental.cpp

@@ -584,7 +584,7 @@ static int32 elemental_ai_sub_timer(s_elemental_data *ed, map_session_data *sd,
 
 	int32 master_dist, view_range;
 
-	if( ed->sc.count && ed->sc.getSCE(SC_BLIND) )
+	if( ed->sc.getSCE(SC_BLIND) )
 		view_range = 3;
 	else
 		view_range = ed->db->range2;

+ 3 - 3
src/map/map.cpp

@@ -456,7 +456,7 @@ int32 map_moveblock(struct block_list *bl, int32 x1, int32 y1, t_tick tick)
 		sc = status_get_sc(bl);
 
 		skill_unit_move(bl,tick,2);
-		if ( sc && sc->count ) //at least one to cancel
+		if ( sc != nullptr && !sc->empty() ) //at least one to cancel
 		{
 			status_change_end(bl, SC_CLOSECONFINE);
 			status_change_end(bl, SC_CLOSECONFINE2);
@@ -501,7 +501,7 @@ int32 map_moveblock(struct block_list *bl, int32 x1, int32 y1, t_tick tick)
 			}
 		}
 
-		if (sc && sc->count) {
+		if (sc != nullptr && !sc->empty()) {
 			if (sc->getSCE(SC_DANCING))
 				skill_unit_move_unit_group(skill_id2group(sc->getSCE(SC_DANCING)->val2), bl->m, x1-x0, y1-y0);
 			else {
@@ -2143,7 +2143,7 @@ int32 map_quit(map_session_data *sd) {
 	//Unit_free handles clearing the player related data,
 	//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 ) {
+	if( !sd->sc.empty() ) {
 		for (const auto &it : status_db) {
 			std::bitset<SCF_MAX> &flag = it.second->flag;
 

+ 2 - 2
src/map/mob.cpp

@@ -1739,7 +1739,7 @@ static bool mob_ai_sub_hard(struct mob_data *md, t_tick tick)
 		return false;
 	}
 
-	if (md->sc.count && md->sc.getSCE(SC_BLIND))
+	if (md->sc.getSCE(SC_BLIND))
 		view_range = 3;
 	else
 		view_range = md->db->range2;
@@ -3943,7 +3943,7 @@ int32 mobskill_use(struct mob_data *md, t_tick tick, int32 event, int64 damage)
 					break;
 				case MSC_MYSTATUSON:		// status[num] on
 				case MSC_MYSTATUSOFF:		// status[num] off
-					if( !md->sc.count ){
+					if( md->sc.empty() ){
 						flag = 0;
 					}else if( mob_getstatus_sub( *md, static_cast<e_mob_skill_condition>( ms[i]->cond1 ), static_cast<sc_type>( ms[i]->cond2 ) ) ){
 						flag = 1;

+ 1 - 1
src/map/npc.cpp

@@ -1893,7 +1893,7 @@ int32 npc_touch_areanpc(map_session_data* sd, int16 m, int16 x, int16 y, struct
 
 	switch (nd->subtype) {
 	case NPCTYPE_WARP:
-		if ((!nd->trigger_on_hidden && (pc_ishiding(sd) || (sd->sc.count && sd->sc.getSCE(SC_CAMOUFLAGE)))) || pc_isdead(sd))
+		if ((!nd->trigger_on_hidden && (pc_ishiding(sd) || sd->sc.getSCE(SC_CAMOUFLAGE))) || pc_isdead(sd))
 			break; // hidden or dead chars cannot use warps
 		if (!pc_job_can_entermap((enum e_job)sd->status.class_, map_mapindex2mapid(nd->u.warp.mapindex), pc_get_group_level(sd)))
 			break;

+ 8 - 8
src/map/pc.cpp

@@ -1794,7 +1794,7 @@ uint8 pc_isequip(map_session_data *sd,int32 n)
 	if(item == nullptr)
 		return ITEM_EQUIP_ACK_FAIL;
 
-	if (sd->sc.count && sd->sc.getSCE(SC_SPIRIT) && sd->sc.getSCE(SC_SPIRIT)->val2 == SL_SUPERNOVICE) {
+	if (sd->sc.getSCE(SC_SPIRIT) && sd->sc.getSCE(SC_SPIRIT)->val2 == SL_SUPERNOVICE) {
 		//Spirit of Super Novice equip bonuses. [Skotlex]
 		if (sd->status.base_level >= 90 && item->equip & EQP_HELM)
 			return ITEM_EQUIP_ACK_OK; //Can equip all helms
@@ -1871,7 +1871,7 @@ uint8 pc_isequip(map_session_data *sd,int32 n)
 		}
 	}
 
-	if (sd->sc.count) {
+	if (!sd->sc.empty()) {
 		if(item->equip & EQP_ARMS && item->type == IT_WEAPON && sd->sc.getSCE(SC_STRIPWEAPON)) // Also works with left-hand weapons [DracoRPG]
 			return ITEM_EQUIP_ACK_FAIL;
 		if(item->equip & EQP_SHIELD && item->type == IT_ARMOR && sd->sc.getSCE(SC_STRIPSHIELD))
@@ -2718,7 +2718,7 @@ void pc_calc_skilltree(map_session_data *sd)
 	}
 
 	// Enable Bard/Dancer spirit linked skills.
-	if (sd->sc.count && sd->sc.getSCE(SC_SPIRIT) && sd->sc.getSCE(SC_SPIRIT)->val2 == SL_BARDDANCER) {
+	if (sd->sc.getSCE(SC_SPIRIT) && sd->sc.getSCE(SC_SPIRIT)->val2 == SL_BARDDANCER) {
 		std::vector<std::vector<uint16>> linked_skills = { { BA_WHISTLE, DC_HUMMING },
 														   { BA_ASSASSINCROSS, DC_DONTFORGETME },
 														   { BA_POEMBRAGI, DC_FORTUNEKISS },
@@ -6844,7 +6844,7 @@ enum e_setpos pc_setpos(map_session_data* sd, unsigned short mapindex, int32 x,
 			bg_team_leave(sd, false, true);
 
 		sd->state.pmap = sd->bl.m;
-		if (sc && sc->count) { // Cancel some map related stuff.
+		if (sc != nullptr && !sc->empty()) { // Cancel some map related stuff.
 			if (sc->cant.warp)
 				return SETPOS_MAPINDEX; // You may not get out!
 
@@ -7299,7 +7299,7 @@ static void pc_checkallowskill(map_session_data *sd)
 {
 	nullpo_retv(sd);
 
-	if(!sd->sc.count)
+	if(sd->sc.empty())
 		return;
 
 	for (const auto &it : status_db) {
@@ -10604,7 +10604,7 @@ int32 pc_itemheal(map_session_data *sd, t_itemid itemid, int32 hp, int32 sp)
 		if (bonus != 100 && tmp > sp)
 			sp = tmp;
 	}
-	if (sd->sc.count) {
+	if (!sd->sc.empty()) {
 		// Critical Wound and Death Hurt stack
 		if (sd->sc.getSCE(SC_CRITICALWOUND))
 			penalty += sd->sc.getSCE(SC_CRITICALWOUND)->val2;
@@ -11926,7 +11926,7 @@ bool pc_equipitem(map_session_data *sd,short n,int32 req_pos,bool equipswitch)
 		}
 		return false;
 	}
-	if( sd->sc.count && (sd->sc.cant.equip || (sd->sc.getSCE(SC_PYROCLASTIC) && sd->inventory_data[n]->type == IT_WEAPON)) ) {
+	if( !sd->sc.empty() && (sd->sc.cant.equip || (sd->sc.getSCE(SC_PYROCLASTIC) && sd->inventory_data[n]->type == IT_WEAPON))) {
 		if( equipswitch ){
 			clif_equipswitch_add( sd, n, req_pos, ITEM_EQUIP_ACK_FAIL );
 		}else{
@@ -12267,7 +12267,7 @@ bool pc_unequipitem(map_session_data *sd, int32 n, int32 flag) {
 		return false; //Nothing to unequip
 	}
 	// status change that makes player cannot unequip equipment
-	if (!(flag&2) && sd->sc.count &&( sd->sc.cant.unequip ||
+	if (!(flag&2) && !sd->sc.empty() &&( sd->sc.cant.unequip ||
 		(sd->sc.getSCE(SC_PYROCLASTIC) &&	sd->inventory_data[n]->type == IT_WEAPON)))	// can't switch weapon
 	{
 		clif_unequipitemack(*sd,n,0,false);

+ 17 - 7
src/map/script.cpp

@@ -12469,21 +12469,31 @@ BUILDIN_FUNC(getstatus)
 		return SCRIPT_CMD_SUCCESS;
 	}
 
-	if( sd->sc.count == 0 || !sd->sc.getSCE(id) )
-	{// no status is active
+	status_change_entry* sce = sd->sc.getSCE( id );
+
+	// Check if the status is active
+	if( sce == nullptr ){
 		script_pushint(st, 0);
 		return SCRIPT_CMD_SUCCESS;
 	}
 
 	switch( type )
 	{
-		case 1:	 script_pushint(st, sd->sc.getSCE(id)->val1);	break;
-		case 2:  script_pushint(st, sd->sc.getSCE(id)->val2);	break;
-		case 3:  script_pushint(st, sd->sc.getSCE(id)->val3);	break;
-		case 4:  script_pushint(st, sd->sc.getSCE(id)->val4);	break;
+		case 1:
+			script_pushint( st, sce->val1 );
+			break;
+		case 2:
+			script_pushint( st, sce->val2 );
+			break;
+		case 3:
+			script_pushint( st, sce->val3 );
+			break;
+		case 4:
+			script_pushint( st, sce->val4 );
+			break;
 		case 5:
 			{
-				struct TimerData* timer = (struct TimerData*)get_timer(sd->sc.getSCE(id)->timer);
+				const struct TimerData* timer = get_timer( sce->timer );
 
 				if( timer )
 				{// return the amount of time remaining

+ 32 - 32
src/map/skill.cpp

@@ -648,7 +648,7 @@ int32 skill_calc_heal(struct block_list *src, struct block_list *target, uint16
 		hp += hp * skill / 100;
 #endif
 
-	if (sc && sc->count) {
+	if (sc != nullptr && !sc->empty()) {
 		if (sc->getSCE(SC_OFFERTORIUM) && (skill_id == AB_HIGHNESSHEAL || skill_id == AB_CHEAL || skill_id == NPC_CHEAL || skill_id == PR_SANCTUARY || skill_id == AL_HEAL ||
 			skill_id == CD_DILECTIO_HEAL || skill_id == CD_MEDIALE_VOTUM ))
 #ifdef RENEWAL
@@ -662,7 +662,7 @@ int32 skill_calc_heal(struct block_list *src, struct block_list *target, uint16
 #endif
 	}
 
-	if (tsc && tsc->count) {
+	if (tsc != nullptr && !tsc->empty()) {
 		if (skill_id != NPC_EVILLAND && skill_id != BA_APPLEIDUN) {
 			if (tsc->getSCE(SC_INCHEALRATE))
 #ifdef RENEWAL
@@ -733,7 +733,7 @@ int32 skill_calc_heal(struct block_list *src, struct block_list *target, uint16
 	}
 
 	// Global multipliers are applied after the MATK is applied
-	if (tsc && tsc->count) {
+	if (tsc != nullptr && !tsc->empty()) {
 		if (skill_id != NPC_EVILLAND && skill_id != BA_APPLEIDUN) {
 			if (tsc->getSCE(SC_WATER_INSIGNIA) && tsc->getSCE(SC_WATER_INSIGNIA)->val1 == 2)
 				global_bonus *= 1.1f;
@@ -746,7 +746,7 @@ int32 skill_calc_heal(struct block_list *src, struct block_list *target, uint16
 		global_bonus *= 1 + 0.15f + 0.05f * skill_lv;
 #endif
 
-	if (heal && tsc && tsc->count) {
+	if (heal && tsc != nullptr && !tsc->empty()) {
 		uint8 penalty = 0;
 
 		if (tsc->getSCE(SC_CRITICALWOUND))
@@ -999,7 +999,7 @@ bool skill_isNotOk_hom(struct homun_data *hd, uint16 skill_id, uint16 skill_lv)
 	if (!sd)
 		return true;
 
-	if (sc && !sc->count)
+	if (sc != nullptr && sc->empty())
 		sc = nullptr;
 
 	if (util::vector_exists(hd->blockskill, skill_id)) {
@@ -2063,7 +2063,7 @@ int32 skill_additional_effect( struct block_list* src, struct block_list *bl, ui
 		sc_start(src,bl,SC_STUN,100,skill_lv,skill_get_time2(skill_id,skill_lv));
 		break;
 	case RL_BANISHING_BUSTER: {
-			if (!tsc || !tsc->count)
+			if (tsc == nullptr || tsc->empty())
 				break;
 
 			if (status_isimmune(bl))
@@ -2802,7 +2802,7 @@ int32 skill_break_equip(struct block_list *src, struct block_list *bl, unsigned
 	int32 i;
 	TBL_PC *sd;
 	sd = BL_CAST(BL_PC, bl);
-	if (sc && !sc->count)
+	if (sc != nullptr && sc->empty())
 		sc = nullptr;
 
 	if (sd) {
@@ -2838,7 +2838,7 @@ int32 skill_break_equip(struct block_list *src, struct block_list *bl, unsigned
 
 	for (i = 0; i < 6; i++) {
 		if (where&where_list[i]) {
-			if (sc && sc->count && sc->getSCE(scdef[i]))
+			if (sc != nullptr && sc->getSCE(scdef[i]))
 				where&=~where_list[i];
 			else if (rnd()%10000 >= rate)
 				where&=~where_list[i];
@@ -3144,7 +3144,7 @@ static int32 skill_magic_reflect(struct block_list* src, struct block_list* bl,
 		return 0;
 
 	// status-based reflection
-	if( !sc || sc->count == 0 )
+	if( sc == nullptr || sc->empty() )
 		return 0;
 
 	// Kaite reflection - Does not bypass Boss check
@@ -3559,7 +3559,7 @@ int64 skill_attack (int32 attack_type, struct block_list* src, struct block_list
 	status_data* tstatus = status_get_status_data(*bl);
 	sc= status_get_sc(src);
 	tsc= status_get_sc(bl);
-	if (tsc && !tsc->count)
+	if (tsc != nullptr && tsc->empty())
 		tsc = nullptr; //Don't need it.
 
 	 //Trick Dead protects you from damage, but not from buffs and the like, hence it's placed here.
@@ -3612,7 +3612,7 @@ int64 skill_attack (int32 attack_type, struct block_list* src, struct block_list
 			sd = BL_CAST(BL_PC, src);
 			tsd = BL_CAST(BL_PC, bl);
 			tsc = status_get_sc(bl);
-			if (tsc && !tsc->count)
+			if (tsc != nullptr && tsc->empty())
 				tsc = nullptr; //Don't need it.
 			/* bugreport:2564 flag&2 disables double casting trigger */
 			flag |= 2;
@@ -5122,9 +5122,9 @@ int32 skill_castend_damage_id (struct block_list* src, struct block_list *bl, ui
 
 	sc = status_get_sc(src);
 	tsc = status_get_sc(bl);
-	if (sc && !sc->count)
+	if (sc != nullptr && sc->empty())
 		sc = nullptr; //Unneeded
-	if (tsc && !tsc->count)
+	if (tsc != nullptr && tsc->empty())
 		tsc = nullptr;
 
 	status_data* tstatus = status_get_status_data(*bl);
@@ -7373,7 +7373,7 @@ int32 skill_castend_nodamage_id (struct block_list *src, struct block_list *bl,
 			if (status_isimmune(bl) || (dstmd && (status_get_class(bl) == MOBID_EMPERIUM || status_get_class_(bl) == CLASS_BATTLEFIELD)))
 				heal = 0;
 
-			if( tsc && tsc->count ) {
+			if( tsc != nullptr && !tsc->empty() ) {
 				if( tsc->getSCE(SC_KAITE) && !status_has_mode(sstatus,MD_STATUSIMMUNE) ) { //Bounce back heal
 					if (--tsc->getSCE(SC_KAITE)->val2 <= 0)
 						status_change_end(bl, SC_KAITE);
@@ -9518,7 +9518,7 @@ int32 skill_castend_nodamage_id (struct block_list *src, struct block_list *bl,
 				hp += hp * sstatus->hplus / 100;
 				sp += sp * sstatus->hplus / 100;
 			}
-			if (tsc && tsc->count) {
+			if (tsc != nullptr && !tsc->empty()) {
 				uint8 penalty = 0;
 
 				if (tsc->getSCE(SC_WATER_INSIGNIA) && tsc->getSCE(SC_WATER_INSIGNIA)->val1 == 2) {
@@ -9636,7 +9636,7 @@ int32 skill_castend_nodamage_id (struct block_list *src, struct block_list *bl,
 			else if (dstmd)
 				mob_unlocktarget(dstmd, tick);
 
-			if(!tsc || !tsc->count)
+			if(tsc == nullptr || tsc->empty())
 				break;
 
 			//Statuses that can't be Dispelled
@@ -10328,7 +10328,7 @@ int32 skill_castend_nodamage_id (struct block_list *src, struct block_list *bl,
 				if (sp)
 					sp = sp * (100 + pc_checkskill(dstsd,MG_SRECOVERY)*10 + pc_skillheal2_bonus(dstsd, skill_id))/100;
 			}
-			if (tsc && tsc->count) {
+			if (tsc != nullptr && !tsc->empty()) {
 				uint8 penalty = 0;
 
 				if (tsc->getSCE(SC_WATER_INSIGNIA) && tsc->getSCE(SC_WATER_INSIGNIA)->val1 == 2) {
@@ -11164,7 +11164,7 @@ int32 skill_castend_nodamage_id (struct block_list *src, struct block_list *bl,
 			if (dstsd)
 				pc_bonus_script_clear(dstsd,BSF_REM_ON_CLEARANCE);
 
-			if(!tsc || !tsc->count)
+			if(tsc == nullptr || tsc->empty())
 				break;
 
 			//Statuses change that can't be removed by Cleareance
@@ -11681,7 +11681,7 @@ int32 skill_castend_nodamage_id (struct block_list *src, struct block_list *bl,
 				status_heal(bl, heal, 0, 0);
 			}
 
-			if( tsc && tsc->count && rnd_chance( ( skill_lv * 5 + ( status_get_dex( src ) + status_get_lv( src ) ) / 4 ) - rnd_value( 1, 10 ), 100 ) ){
+			if( tsc != nullptr && !tsc->empty() && rnd_chance( ( skill_lv * 5 + ( status_get_dex( src ) + status_get_lv( src ) ) / 4 ) - rnd_value( 1, 10 ), 100 ) ){
 				status_change_end(bl, SC_STONE);
 				status_change_end(bl, SC_FREEZE);
 				status_change_end(bl, SC_STUN);
@@ -12573,7 +12573,7 @@ int32 skill_castend_nodamage_id (struct block_list *src, struct block_list *bl,
 			clif_skill_fail( *sd, skill_id, USESKILL_FAIL_TOTARGET );
 			break;
 		}
-		if (tsc && tsc->count && tsc->getSCE(type)) // Refresh the status only if it's already active.
+		if (tsc != nullptr && tsc->getSCE(type)) // Refresh the status only if it's already active.
 			sc_start(src, bl, type, 100, skill_lv, skill_get_time(skill_id, skill_lv));
 		else {
 			sc_start(src, bl, type, 100, skill_lv, skill_get_time(skill_id, skill_lv));
@@ -13489,7 +13489,7 @@ TIMER_FUNC(skill_castend_id){
 			sd->skill_keep_using.tid = add_timer( sd->ud.canact_tick + 100, skill_keep_using, sd->bl.id, 0 );
 		}
 
-		if(sc && sc->count) {
+		if(sc != nullptr && !sc->empty()) {
 			if (ud->skill_id != RA_CAMOUFLAGE)
 				status_change_end(src, SC_CAMOUFLAGE); // Applies to the first skill if active
 
@@ -16884,7 +16884,7 @@ int32 skill_unit_onleft(uint16 skill_id, struct block_list *bl, t_tick tick)
 	enum sc_type type;
 
 	sc = status_get_sc(bl);
-	if (sc && !sc->count)
+	if (sc != nullptr && sc->empty())
 		sc = nullptr;
 
 	type = skill_get_sc(skill_id);
@@ -17482,7 +17482,7 @@ bool skill_check_condition_castbegin( map_session_data& sd, uint16 skill_id, uin
 	struct status_data* status = &sd.battle_status;
 	status_change* sc = &sd.sc;
 
-	if( !sc->count )
+	if( sc->empty() )
 		sc = nullptr;
 
 	if( sd.skillitem == skill_id )
@@ -18515,7 +18515,7 @@ bool skill_check_condition_castend( map_session_data& sd, uint16 skill_id, uint1
 	}
 
 	status_change* sc = &sd.sc;
-	if (!sc->count)
+	if (sc->empty())
 		sc = nullptr;
 
 	// perform skill-specific checks (and actions)
@@ -18810,7 +18810,7 @@ void skill_consume_requirement(map_session_data *sd, uint16 skill_id, uint16 ski
 		status_change *sc = &sd->sc;
 		int32 n,i;
 
-		if( !sc->count )
+		if( sc->empty() )
 			sc = nullptr;
 
 		for( i = 0; i < MAX_SKILL_ITEM_REQUIRE; ++i )
@@ -18872,7 +18872,7 @@ struct s_skill_condition skill_get_requirement(map_session_data* sd, uint16 skil
 		return req; // Item skills and Hocus-Pocus don't have requirements.[Inkfish]
 
 	sc = &sd->sc;
-	if( !sc->count )
+	if( sc->empty() )
 		sc = nullptr;
 
 	//Checks if disabling skill - in which case no SP requirements are necessary
@@ -19286,7 +19286,7 @@ int32 skill_castfix(struct block_list *bl, uint16 skill_id, uint16 skill_lv) {
 		}
 
 		// These cast time reductions are processed even if the skill fails
-		if (sc && sc->count) {
+		if (sc != nullptr && !sc->empty()) {
 			// Magic Strings stacks additively with item bonuses
 			if (!(flag&2) && sc->getSCE(SC_POEMBRAGI))
 				reduce_cast_rate += sc->getSCE(SC_POEMBRAGI)->val2;
@@ -19333,7 +19333,7 @@ int32 skill_castfix_sc(struct block_list *bl, double time, uint8 flag)
 
 	status_change *sc = status_get_sc(bl);
 
-	if (sc && sc->count) {
+	if (sc != nullptr && !sc->empty()) {
 		if (!(flag&2)) {
 			if (sc->getSCE(SC_SLOWCAST))
 				time += time * sc->getSCE(SC_SLOWCAST)->val2 / 100;
@@ -19433,7 +19433,7 @@ int32 skill_vfcastfix(struct block_list *bl, double time, uint16 skill_id, uint1
 	}
 
 	// Adjusted by active statuses
-	if (sc && sc->count && !(flag&2)) {
+	if (sc != nullptr && !sc->empty() && !(flag&2)) {
 		// Multiplicative Variable CastTime values
 		if (sc->getSCE(SC_SLOWCAST))
 			VARCAST_REDUCTION(-sc->getSCE(SC_SLOWCAST)->val2);
@@ -19567,7 +19567,7 @@ int32 skill_delayfix(struct block_list *bl, uint16 skill_id, uint16 skill_lv)
 			}
 	}
 
-	if (sc && sc->count) {
+	if (sc != nullptr && !sc->empty()) {
 		if (sc->getSCE(SC_SPIRIT)) {
 			switch (skill_id) {
 				case CR_SHIELDBOOMERANG:
@@ -19585,7 +19585,7 @@ int32 skill_delayfix(struct block_list *bl, uint16 skill_id, uint16 skill_lv)
 	int32 delay = 0;
 
 	if (!(delaynodex&2)) {
-		if (sc && sc->count) {
+		if (sc != nullptr && !sc->empty()) {
 			if (sc->getSCE(SC_POEMBRAGI))
 				delay += sc->getSCE(SC_POEMBRAGI)->val3;
 			if (sc->getSCE(SC_WIND_INSIGNIA) && sc->getSCE(SC_WIND_INSIGNIA)->val1 == 3 && skill_get_type(skill_id) == BF_MAGIC && skill_get_ele(skill_id, skill_lv) == ELE_WIND)
@@ -22713,7 +22713,7 @@ void skill_toggle_magicpower(struct block_list *bl, uint16 skill_id)
 	if (skill_get_nk(skill_id, NK_NODAMAGE) || !(skill_get_type(skill_id)&BF_MAGIC))
 		return;
 
-	if (sc && sc->count && sc->getSCE(SC_MAGICPOWER)) {
+	if (sc != nullptr && !sc->empty() && sc->getSCE(SC_MAGICPOWER)) {
 		if (sc->getSCE(SC_MAGICPOWER)->val4) {
 			status_change_end(bl, SC_MAGICPOWER);
 		} else {

+ 67 - 58
src/map/status.cpp

@@ -1050,7 +1050,7 @@ uint16 StatusDatabase::getSkill(sc_type type) {
  * @return True if flag is set or false otherwise
  */
 bool StatusDatabase::hasSCF(status_change *sc, e_status_change_flag flag) {
-	if (sc == nullptr || sc->count == 0 || flag == SCF_NONE)
+	if (sc == nullptr || sc->empty() || flag == SCF_NONE)
 		return false;
 
 	for (const auto &status_it : *this) {
@@ -1124,7 +1124,7 @@ void StatusDatabase::removeByStatusFlag(block_list *bl, std::vector<e_status_cha
 
 	status_change *sc = status_get_sc(bl);
 
-	if (sc == nullptr || sc->count == 0)
+	if (sc == nullptr || sc->empty())
 		return;
 
 	for (const auto &status_it : *this) {
@@ -1197,6 +1197,10 @@ void status_change::clearSCE(enum sc_type type) {
 	lastStatus = {type, data[type]};
 }
 
+bool status_change::empty(){
+	return this->count == 0;
+}
+
 /** Creates dummy status */
 static void initDummyData(void) {
 	memset(&dummy_status, 0, sizeof(dummy_status));
@@ -1738,7 +1742,7 @@ int32 status_heal(struct block_list *bl,int64 hhp,int64 hsp, int64 hap, int32 fl
 		return 0;
 
 	sc = status_get_sc(bl);
-	if (sc && !sc->count)
+	if (sc != nullptr && sc->empty())
 		sc = nullptr;
 
 	if (hp < 0) {
@@ -2024,7 +2028,7 @@ bool status_check_skilluse(struct block_list *src, struct block_list *target, ui
 			break;
 	}
 
-	if( sc && sc->count ) {
+	if( sc != nullptr && !sc->empty() ) {
 		if (sc->getSCE(SC_ALL_RIDING))
 			return false; //You can't use skills while in the new mounts (The client doesn't let you, this is to make cheat-safe)
 
@@ -2159,7 +2163,7 @@ bool status_check_skilluse(struct block_list *src, struct block_list *target, ui
 	if (target == nullptr || target == src) // No further checking needed.
 		return true;
 
-	if (tsc && tsc->count) {
+	if (tsc != nullptr && !tsc->empty()) {
 		if(!skill_id && tsc->getSCE(SC_TRICKDEAD))
 			return false;
 		if((skill_id == WZ_STORMGUST || skill_id == WZ_FROSTNOVA || skill_id == NJ_HYOUSYOURAKU || skill_id == NPC_STORMGUST2)
@@ -4088,7 +4092,7 @@ int32 status_calc_pc_sub(map_session_data* sd, uint8 opt)
 		current_equip_opt_index = -1;
 	}
 
-	if (sc->count){
+	if (!sc->empty()){
 		if( status_change_entry* sce = sc->getSCE(SC_ITEMSCRIPT); sce != nullptr ){
 			std::shared_ptr<item_data> data = item_db.find(sc->getSCE(SC_ITEMSCRIPT)->val1);
 
@@ -4682,7 +4686,7 @@ int32 status_calc_pc_sub(map_session_data* sd, uint8 opt)
 		sd->indexed_bonus.magic_atk_ele[ELE_POISON] += skill;
 	}
 
-	if(sc->count) {
+	if(!sc->empty()) {
 		if(sc->getSCE(SC_CONCENTRATE)) { // Update the card-bonus data
 			sc->getSCE(SC_CONCENTRATE)->val3 = sd->indexed_bonus.param_bonus[1]; // Agi
 			sc->getSCE(SC_CONCENTRATE)->val4 = sd->indexed_bonus.param_bonus[4]; // Dex
@@ -5219,7 +5223,7 @@ void status_calc_regen(struct block_list *bl, struct status_data *status, struct
 		if( (skill=pc_checkskill(sd,SM_RECOVERY)) > 0 )
 			val += skill*5 + skill*status->max_hp/500;
 
-		if (sc && sc->count) {
+		if (sc != nullptr && !sc->empty()) {
 			if (sc->getSCE(SC_INCREASE_MAXHP))
 				val += val * sc->getSCE(SC_INCREASE_MAXHP)->val2 / 100;
 		}
@@ -5234,7 +5238,7 @@ void status_calc_regen(struct block_list *bl, struct status_data *status, struct
 		if( (skill=pc_checkskill(sd,WM_LESSON)) > 0 )
 			val += 3 + 3 * skill;
 
-		if (sc && sc->count) {
+		if (sc != nullptr && !sc->empty()) {
 			if (sc->getSCE(SC_ANCILLA))
 				val += sc->getSCE(SC_ANCILLA)->val2 / 100;
 			if (sc->getSCE(SC_INCREASE_MAXSP))
@@ -5320,7 +5324,7 @@ void status_calc_regen_rate(struct block_list *bl, struct regen_data *regen, sta
 	}
 	regen->rate.hp = regen->rate.sp = 100;
 
-	if (!sc || !sc->count)
+	if (sc == nullptr || sc->empty())
 		return;
 
 	// No HP or SP regen
@@ -5449,7 +5453,7 @@ void status_calc_state( struct block_list *bl, status_change *sc, std::bitset<SC
 {
 
 	/// No sc at all, we can zero without any extra weight over our conciousness
-	if( !sc->count ) {
+	if( sc->empty() ) {
 		sc->cant = {};
 		return;
 	}
@@ -6489,7 +6493,7 @@ void status_calc_bl_(struct block_list* bl, std::bitset<SCB_MAX> flag, uint8 opt
  */
 static unsigned short status_calc_str(struct block_list *bl, status_change *sc, int32 str)
 {
-	if(!sc || !sc->count)
+	if(sc == nullptr || sc->empty())
 		return cap_value(str,0,USHRT_MAX);
 
 	if(sc->getSCE(SC_HARMONIZE)) {
@@ -6574,7 +6578,7 @@ static unsigned short status_calc_str(struct block_list *bl, status_change *sc,
  */
 static unsigned short status_calc_agi(struct block_list *bl, status_change *sc, int32 agi)
 {
-	if(!sc || !sc->count)
+	if(sc == nullptr || sc->empty())
 		return cap_value(agi,0,USHRT_MAX);
 
 	if(sc->getSCE(SC_HARMONIZE)) {
@@ -6653,7 +6657,7 @@ static unsigned short status_calc_agi(struct block_list *bl, status_change *sc,
  */
 static unsigned short status_calc_vit(struct block_list *bl, status_change *sc, int32 vit)
 {
-	if(!sc || !sc->count)
+	if(sc == nullptr || sc->empty())
 		return cap_value(vit,0,USHRT_MAX);
 
 	if(sc->getSCE(SC_HARMONIZE)) {
@@ -6724,7 +6728,7 @@ static unsigned short status_calc_vit(struct block_list *bl, status_change *sc,
  */
 static unsigned short status_calc_int(struct block_list *bl, status_change *sc, int32 int_)
 {
-	if(!sc || !sc->count)
+	if(sc == nullptr || sc->empty())
 		return cap_value(int_,0,USHRT_MAX);
 
 	if(sc->getSCE(SC_HARMONIZE)) {
@@ -6812,7 +6816,7 @@ static unsigned short status_calc_int(struct block_list *bl, status_change *sc,
  */
 static unsigned short status_calc_dex(struct block_list *bl, status_change *sc, int32 dex)
 {
-	if(!sc || !sc->count)
+	if(sc == nullptr || sc->empty())
 		return cap_value(dex,0,USHRT_MAX);
 
 	if(sc->getSCE(SC_HARMONIZE)) {
@@ -6895,7 +6899,7 @@ static unsigned short status_calc_dex(struct block_list *bl, status_change *sc,
  */
 static unsigned short status_calc_luk(struct block_list *bl, status_change *sc, int32 luk)
 {
-	if(!sc || !sc->count)
+	if(sc == nullptr || sc->empty())
 		return cap_value(luk,0,USHRT_MAX);
 
 	if(sc->getSCE(SC_HARMONIZE)) {
@@ -6966,7 +6970,7 @@ static unsigned short status_calc_luk(struct block_list *bl, status_change *sc,
 */
 static unsigned short status_calc_pow(struct block_list *bl, status_change *sc, int32 pow)
 {
-	if (!sc || !sc->count)
+	if (sc == nullptr || sc->empty())
 		return cap_value(pow, 0, USHRT_MAX);
 
 	if (sc->getSCE(SC_BENEDICTUM))
@@ -6984,7 +6988,7 @@ static unsigned short status_calc_pow(struct block_list *bl, status_change *sc,
 */
 static unsigned short status_calc_sta(struct block_list *bl, status_change *sc, int32 sta)
 {
-	if (!sc || !sc->count)
+	if (sc == nullptr || sc->empty())
 		return cap_value(sta, 0, USHRT_MAX);
 
 	if (sc->getSCE(SC_RELIGIO))
@@ -7002,7 +7006,7 @@ static unsigned short status_calc_sta(struct block_list *bl, status_change *sc,
 */
 static unsigned short status_calc_wis(struct block_list *bl, status_change *sc, int32 wis)
 {
-	if (!sc || !sc->count)
+	if (sc == nullptr || sc->empty())
 		return cap_value(wis, 0, USHRT_MAX);
 
 	if (sc->getSCE(SC_RELIGIO))
@@ -7020,7 +7024,7 @@ static unsigned short status_calc_wis(struct block_list *bl, status_change *sc,
 */
 static unsigned short status_calc_spl(struct block_list *bl, status_change *sc, int32 spl)
 {
-	if (!sc || !sc->count)
+	if (sc == nullptr || sc->empty())
 		return cap_value(spl, 0, USHRT_MAX);
 
 	if (sc->getSCE(SC_RELIGIO))
@@ -7038,7 +7042,7 @@ static unsigned short status_calc_spl(struct block_list *bl, status_change *sc,
 */
 static unsigned short status_calc_con(struct block_list *bl, status_change *sc, int32 con)
 {
-	if (!sc || !sc->count)
+	if (sc == nullptr || sc->empty())
 		return cap_value(con, 0, USHRT_MAX);
 
 	if (sc->getSCE(SC_BENEDICTUM))
@@ -7056,7 +7060,7 @@ static unsigned short status_calc_con(struct block_list *bl, status_change *sc,
 */
 static unsigned short status_calc_crt(struct block_list *bl, status_change *sc, int32 crt)
 {
-	if (!sc || !sc->count)
+	if (sc == nullptr || sc->empty())
 		return cap_value(crt, 0, USHRT_MAX);
 
 	if (sc->getSCE(SC_BENEDICTUM))
@@ -7074,7 +7078,7 @@ static unsigned short status_calc_crt(struct block_list *bl, status_change *sc,
  */
 static unsigned short status_calc_batk(struct block_list *bl, status_change *sc, int32 batk)
 {
-	if(!sc || !sc->count)
+	if(sc == nullptr || sc->empty())
 		return cap_value(batk,0,USHRT_MAX);
 
 	if(sc->getSCE(SC_ATKPOTION))
@@ -7136,7 +7140,7 @@ static unsigned short status_calc_batk(struct block_list *bl, status_change *sc,
  */
 static unsigned short status_calc_watk(struct block_list *bl, status_change *sc, int32 watk)
 {
-	if(!sc || !sc->count)
+	if(sc == nullptr || sc->empty())
 		return cap_value(watk,0,USHRT_MAX);
 
 #ifndef RENEWAL
@@ -7234,7 +7238,7 @@ uint16 status_calc_pseudobuff_matk( map_session_data* sd, status_change *sc, int
 		matk += 15 * skill_lv + (skill_lv > 4 ? 25 : 0);
 	}
 
-	if (!sc || !sc->count)
+	if (sc == nullptr || sc->empty())
 		return static_cast<uint16>( cap_value(matk,0,USHRT_MAX) );
 
 	struct status_change_entry* sce;
@@ -7286,7 +7290,7 @@ uint16 status_calc_pseudobuff_matk( map_session_data* sd, status_change *sc, int
  * @return modified matk with cap_value(matk,0,USHRT_MAX)
  */
 uint16 status_calc_consumablematk( status_change *sc, int32 matk ){
-	if (!sc || !sc->count)
+	if (sc == nullptr || sc->empty())
 		return static_cast<uint16>( cap_value(matk,0,USHRT_MAX) );
 
 	struct status_change_entry* sce;
@@ -7328,7 +7332,7 @@ uint16 status_calc_consumablematk( status_change *sc, int32 matk ){
  */
 static signed short status_calc_critical(struct block_list *bl, status_change *sc, int32 critical)
 {
-	if(!sc || !sc->count)
+	if(sc == nullptr || sc->empty())
 		return cap_value(critical,10,SHRT_MAX);
 
 	if (sc->getSCE(SC_INCCRI))
@@ -7380,7 +7384,7 @@ static signed short status_calc_critical(struct block_list *bl, status_change *s
  */
 static signed short status_calc_hit(struct block_list *bl, status_change *sc, int32 hit)
 {
-	if(!sc || !sc->count)
+	if(sc == nullptr || sc->empty())
 		return cap_value(hit,1,SHRT_MAX);
 
 	if(sc->getSCE(SC_INCHIT))
@@ -7467,7 +7471,7 @@ static signed short status_calc_flee(struct block_list *bl, status_change *sc, i
 			flee -= flee * battle_config.bg_flee_penalty/100;
 	}
 
-	if(!sc || !sc->count)
+	if(sc == nullptr || sc->empty())
 		return cap_value(flee,1,SHRT_MAX);
 	if (sc->getSCE(SC_POISON_MIST))
 		return 0;
@@ -7576,7 +7580,7 @@ static signed short status_calc_flee(struct block_list *bl, status_change *sc, i
  */
 static signed short status_calc_flee2(struct block_list *bl, status_change *sc, int32 flee2)
 {
-	if(!sc || !sc->count)
+	if(sc == nullptr || sc->empty())
 		return cap_value(flee2,10,SHRT_MAX);
 
 	if(sc->getSCE(SC_INCFLEE2))
@@ -7602,7 +7606,7 @@ static signed short status_calc_flee2(struct block_list *bl, status_change *sc,
  */
 static defType status_calc_def(struct block_list *bl, status_change *sc, int32 def)
 {
-	if(!sc || !sc->count)
+	if(sc == nullptr || sc->empty())
 		return (defType)cap_value(def,DEFTYPE_MIN,DEFTYPE_MAX);
 
 	if(sc->getSCE(SC_BERSERK))
@@ -7717,7 +7721,7 @@ static defType status_calc_def(struct block_list *bl, status_change *sc, int32 d
  */
 static signed short status_calc_def2(struct block_list *bl, status_change *sc, int32 def2)
 {
-	if(!sc || !sc->count)
+	if(sc == nullptr || sc->empty())
 #ifdef RENEWAL
 		return (short)cap_value(def2,SHRT_MIN,SHRT_MAX);
 #else
@@ -7783,7 +7787,7 @@ static signed short status_calc_def2(struct block_list *bl, status_change *sc, i
  */
 static defType status_calc_mdef(struct block_list *bl, status_change *sc, int32 mdef)
 {
-	if(!sc || !sc->count)
+	if(sc == nullptr || sc->empty())
 		return (defType)cap_value(mdef,DEFTYPE_MIN,DEFTYPE_MAX);
 
 	if(sc->getSCE(SC_BERSERK))
@@ -7847,7 +7851,7 @@ static defType status_calc_mdef(struct block_list *bl, status_change *sc, int32
  */
 static signed short status_calc_mdef2(struct block_list *bl, status_change *sc, int32 mdef2)
 {
-	if(!sc || !sc->count)
+	if(sc == nullptr || sc->empty())
 #ifdef RENEWAL
 		return (short)cap_value(mdef2,SHRT_MIN,SHRT_MAX);
 #else
@@ -8106,7 +8110,7 @@ static short status_calc_aspd(struct block_list *bl, status_change *sc, bool fix
 {
 	int32 bonus = 0;
 
-	if (!sc || !sc->count)
+	if (sc == nullptr || sc->empty())
 		return 0;
 
 	if (fixed) {
@@ -8257,7 +8261,7 @@ static short status_calc_aspd(struct block_list *bl, status_change *sc, bool fix
  */
 static short status_calc_fix_aspd(struct block_list *bl, status_change *sc, int32 aspd)
 {
-	if (!sc || !sc->count)
+	if (sc == nullptr || sc->empty())
 		return cap_value(aspd, 0, 2000);
 	if (sc->getSCE(SC_OVERED_BOOST))
 		return cap_value(2000 - sc->getSCE(SC_OVERED_BOOST)->val3 * 10, 0, 2000);
@@ -8297,7 +8301,7 @@ static short status_calc_aspd_rate(struct block_list *bl, status_change *sc, int
 {
 	int32 i;
 
-	if(!sc || !sc->count)
+	if(sc == nullptr || sc->empty())
 		return cap_value(aspd_rate,0,SHRT_MAX);
 
 	int32 max = 0;
@@ -8464,7 +8468,7 @@ static unsigned short status_calc_dmotion(struct block_list *bl, status_change *
 			return 0;
 	}
 
-	if (sc && sc->count > 0 && (sc->getSCE(SC_ENDURE) || sc->getSCE(SC_RUN) || sc->getSCE(SC_WUGDASH) || sc->getSCE(SC_SPARKCANDY)))
+	if (sc != nullptr && !sc->empty() && (sc->getSCE(SC_ENDURE) || sc->getSCE(SC_RUN) || sc->getSCE(SC_WUGDASH) || sc->getSCE(SC_SPARKCANDY)))
 		return 0;
 
 	return (unsigned short)cap_value(dmotion,0,USHRT_MAX);
@@ -8479,7 +8483,7 @@ static unsigned short status_calc_dmotion(struct block_list *bl, status_change *
 */
 static signed short status_calc_patk(struct block_list *bl, status_change *sc, int32 patk)
 {
-	if (!sc || !sc->count)
+	if (sc == nullptr || sc->empty())
 		return cap_value(patk, 0, SHRT_MAX);
 
 	if (sc->getSCE(SC_POWERFUL_FAITH))
@@ -8510,7 +8514,7 @@ static signed short status_calc_patk(struct block_list *bl, status_change *sc, i
 */
 static signed short status_calc_smatk(struct block_list *bl, status_change *sc, int32 smatk)
 {
-	if (!sc || !sc->count)
+	if (sc == nullptr || sc->empty())
 		return cap_value(smatk, 0, SHRT_MAX);
 
 	if (sc->getSCE(SC_COMPETENTIA))
@@ -8537,7 +8541,7 @@ static signed short status_calc_smatk(struct block_list *bl, status_change *sc,
 */
 static signed short status_calc_res(struct block_list *bl, status_change *sc, int32 res)
 {
-	if (!sc || !sc->count)
+	if (sc == nullptr || sc->empty())
 		return cap_value(res, 0, SHRT_MAX);
 
 	if (sc->getSCE(SC_FIRM_FAITH))
@@ -8567,7 +8571,7 @@ static signed short status_calc_res(struct block_list *bl, status_change *sc, in
 */
 static signed short status_calc_mres(struct block_list *bl, status_change *sc, int32 mres)
 {
-	if (!sc || !sc->count)
+	if (sc == nullptr || sc->empty())
 		return cap_value(mres, 0, SHRT_MAX);
 
 	if (sc->getSCE(SC_GOLDENE_TONE))
@@ -8589,7 +8593,7 @@ static signed short status_calc_mres(struct block_list *bl, status_change *sc, i
 */
 static signed short status_calc_hplus(struct block_list *bl, status_change *sc, int32 hplus)
 {
-	if (!sc || !sc->count)
+	if (sc == nullptr || sc->empty())
 		return cap_value(hplus, 0, SHRT_MAX);
 
 	return (short)cap_value(hplus, 0, SHRT_MAX);
@@ -8604,7 +8608,7 @@ static signed short status_calc_hplus(struct block_list *bl, status_change *sc,
 */
 static signed short status_calc_crate(struct block_list *bl, status_change *sc, int32 crate)
 {
-	if (!sc || !sc->count)
+	if (sc == nullptr || sc->empty())
 		return cap_value(crate, 0, SHRT_MAX);
 
 	if (sc->getSCE(SC_PRE_ACIES))
@@ -8679,7 +8683,7 @@ static uint32 status_calc_maxap(struct block_list *bl, uint64 maxap)
  */
 static unsigned char status_calc_element(struct block_list *bl, status_change *sc, int32 element)
 {
-	if(!sc || !sc->count)
+	if(sc == nullptr || sc->empty())
 		return cap_value(element, 0, UCHAR_MAX);
 
 	if(sc->getSCE(SC_FREEZE) || sc->getSCE(SC_CRYSTAL_ARMOR_OPTION))
@@ -8713,7 +8717,7 @@ static unsigned char status_calc_element(struct block_list *bl, status_change *s
  */
 static unsigned char status_calc_element_lv(struct block_list *bl, status_change *sc, int32 lv)
 {
-	if(!sc || !sc->count)
+	if(sc == nullptr || sc->empty())
 		return cap_value(lv, 1, 4);
 
 	if(sc->getSCE(SC_FREEZE))
@@ -8746,7 +8750,7 @@ static unsigned char status_calc_element_lv(struct block_list *bl, status_change
  */
 unsigned char status_calc_attack_element(struct block_list *bl, status_change *sc, int32 element)
 {
-	if(!sc || !sc->count)
+	if(sc == nullptr || sc->empty())
 		return cap_value(element, 0, UCHAR_MAX);
 	if(sc->getSCE(SC_ENCHANTARMS))
 		return sc->getSCE(SC_ENCHANTARMS)->val1;
@@ -8784,7 +8788,7 @@ unsigned char status_calc_attack_element(struct block_list *bl, status_change *s
  */
 static int32 status_calc_mode(struct block_list *bl, status_change *sc, int32 mode)
 {
-	if(!sc || !sc->count)
+	if(sc == nullptr || sc->empty())
 		return cap_value(mode, MD_NONE,INT_MAX);
 	if(sc->getSCE(SC_MODECHANGE)) {
 		if (sc->getSCE(SC_MODECHANGE)->val2)
@@ -9477,7 +9481,7 @@ t_tick status_get_sc_def(struct block_list *src, struct block_list *bl, enum sc_
 	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 )
+	if( sc != nullptr && sc->empty() )
 		sc = nullptr;
 
 #ifdef RENEWAL
@@ -11210,10 +11214,15 @@ int32 status_change_start(struct block_list* src, struct block_list* bl,enum sc_
 
 		case SC_DEVOTION:
 		{
-			struct block_list *d_bl;
-			status_change *d_sc;
+			block_list* d_bl = map_id2bl( val1 );
+
+			if( d_bl == nullptr ){
+				break;
+			}
+			status_change* d_sc = status_get_sc( d_bl );
 
-			if( (d_bl = map_id2bl(val1)) && (d_sc = status_get_sc(d_bl)) && d_sc->count ) { // Inherits Status From Source
+			if( d_sc != nullptr && !d_sc->empty() ){
+				// Inherits status from source
 				const enum sc_type types[] = { SC_AUTOGUARD, SC_DEFENDER, SC_REFLECTSHIELD, SC_ENDURE };
 				int32 i = (map_flag_gvg2(bl->m) || map_getmapflag(bl->m, MF_BATTLEGROUND))?2:3;
 				while( i >= 0 ) {
@@ -13098,7 +13107,7 @@ int32 status_change_clear(struct block_list* bl, int32 type)
 	sc->sg_counter = 0;
 #endif
 
-	if (!sc->count)
+	if (sc->empty())
 		return 0;
 
 	for (const auto &it : status_db) {
@@ -15000,7 +15009,7 @@ void status_change_clear_buffs(struct block_list* bl, uint8 type)
 {
 	status_change *sc= status_get_sc(bl);
 
-	if (!sc || !sc->count)
+	if (sc == nullptr || sc->empty())
 		return;
 
 	//Clears buffs with specified flag and type
@@ -15075,7 +15084,7 @@ int32 status_change_spread(block_list *src, block_list *bl)
 
 	status_change *sc = status_get_sc(src);
 
-	if (sc == nullptr || sc->count == 0)
+	if (sc == nullptr || sc->empty())
 		return 0;
 
 	bool hasSpread = false;
@@ -15133,7 +15142,7 @@ static int32 status_natural_heal(struct block_list* bl, va_list args)
 	status_data* status = status_get_status_data(*bl);
 
 	sc = status_get_sc(bl);
-	if (sc && !sc->count)
+	if (sc != nullptr && sc->empty())
 		sc = nullptr;
 	sd = BL_CAST(BL_PC,bl);
 
@@ -15395,7 +15404,7 @@ void status_change_clear_onChangeMap(struct block_list *bl, status_change *sc)
 {
 	nullpo_retv(bl);
 
-	if (sc && sc->count) {
+	if (sc != nullptr && !sc->empty()) {
 		struct map_data *mapdata = map_getmapdata(bl->m);
 		bool mapIsVS = mapdata_flag_vs2(mapdata);
 		bool mapIsPVP = mapdata->getMapFlag(MF_PVP) != 0;

+ 1 - 0
src/map/status.hpp

@@ -3374,6 +3374,7 @@ public:
 	status_change_entry * createSCE(enum sc_type type);
 	void deleteSCE(enum sc_type type);
 	void clearSCE(enum sc_type type);
+	bool empty();
 };
 #ifndef ONLY_CONSTANTS
 int32 status_damage( struct block_list *src, struct block_list *target, int64 dhp, int64 dsp, int64 dap, t_tick walkdelay, int32 flag, uint16 skill_id );

+ 3 - 3
src/map/unit.cpp

@@ -1746,7 +1746,7 @@ int32 unit_skilluse_id2(struct block_list *src, int32 target_id, uint16 skill_id
 
 	sc = status_get_sc(src);
 
-	if (sc && !sc->count)
+	if (sc != nullptr && sc->empty())
 		sc = nullptr; // Unneeded
 
 	int32 inf = skill_get_inf(skill_id);
@@ -2269,7 +2269,7 @@ int32 unit_skilluse_pos2( struct block_list *src, short skill_x, short skill_y,
 
 	sc = status_get_sc(src);
 
-	if (sc && !sc->count)
+	if (sc != nullptr && sc->empty())
 		sc = nullptr;
 
 	if (!skill_db.find(skill_id))
@@ -3212,7 +3212,7 @@ int32 unit_remove_map_(struct block_list *bl, clr_type clrtype, const char* file
 	// Do not reset can-act delay. [Skotlex]
 	ud->attackabletime = ud->canmove_tick /*= ud->canact_tick*/ = gettick();
 
-	if(sc && sc->count ) { // map-change/warp dispells.
+	if(sc != nullptr && !sc->empty() ) { // map-change/warp dispells.
 		status_db.removeByStatusFlag(bl, { SCF_REMOVEONCHANGEMAP });
 
 		// Ensure the bl is a PC; if so, we'll handle the removal of cloaking and cloaking exceed later