diff --git a/lib/battle/Unit.h b/lib/battle/Unit.h index f8092ab6b..aa42fedd7 100644 --- a/lib/battle/Unit.h +++ b/lib/battle/Unit.h @@ -44,17 +44,15 @@ namespace BattlePhases // Healed HP (also drained life) and resurrected units info struct HealInfo { - HealInfo() - : healedHealthPoints(0), resurrectedCount(0) - { } + HealInfo() = default; HealInfo(int64_t healedHP, int32_t resurrected) : healedHealthPoints(healedHP), resurrectedCount(resurrected) { } - int64_t healedHealthPoints; - int32_t resurrectedCount; + int64_t healedHealthPoints = 0; + int32_t resurrectedCount = 0; - HealInfo& operator +=(const HealInfo& other) + HealInfo & operator+=(const HealInfo & other) { healedHealthPoints += other.healedHealthPoints; resurrectedCount += other.resurrectedCount; diff --git a/lib/spells/effects/Summon.cpp b/lib/spells/effects/Summon.cpp index 2293a151b..dc0dfc153 100644 --- a/lib/spells/effects/Summon.cpp +++ b/lib/spells/effects/Summon.cpp @@ -122,7 +122,6 @@ int32_t Summon::summonedCreatureAmount(const Mechanics * m) const void Summon::apply(ServerCallback * server, const Mechanics * m, const EffectTarget & target) const { - using battle::HealInfo; BattleUnitsChanged pack; pack.battleID = m->battle()->getBattle()->getBattleID(); diff --git a/server/battles/BattleActionProcessor.cpp b/server/battles/BattleActionProcessor.cpp index 7d029302d..d97d9530b 100644 --- a/server/battles/BattleActionProcessor.cpp +++ b/server/battles/BattleActionProcessor.cpp @@ -960,14 +960,14 @@ void BattleActionProcessor::makeAttack(const CBattleInfoCallback & battle, const // only primary target if(defender->alive()) - applyBattleEffects(battle, bat, attackerState, fireShield, defender, &healInfo, distance, false); + applyBattleEffects(battle, bat, attackerState, fireShield, defender, healInfo, distance, false); //multiple-hex normal attack std::set attackedCreatures = battle.getAttackedCreatures(attacker, targetHex, bat.shot()); //creatures other than primary target for(const CStack * stack : attackedCreatures) { if(stack != defender && stack->alive()) //do not hit same stack twice - applyBattleEffects(battle, bat, attackerState, fireShield, stack, &healInfo, distance, true); + applyBattleEffects(battle, bat, attackerState, fireShield, stack, healInfo, distance, true); } std::shared_ptr bonus = attacker->getFirstBonus(Selector::type()(BonusType::SPELL_LIKE_ATTACK)); @@ -995,7 +995,7 @@ void BattleActionProcessor::makeAttack(const CBattleInfoCallback & battle, const { if(stack != defender && stack->alive()) //do not hit same stack twice { - applyBattleEffects(battle, bat, attackerState, fireShield, stack, &healInfo, distance, true); + applyBattleEffects(battle, bat, attackerState, fireShield, stack, healInfo, distance, true); } } @@ -1425,7 +1425,7 @@ void BattleActionProcessor::handleAfterAttackCasting(const CBattleInfoCallback & } } -void BattleActionProcessor::applyBattleEffects(const CBattleInfoCallback & battle, BattleAttack & bat, std::shared_ptr attackerState, FireShieldInfo & fireShield, const CStack * def, battle::HealInfo * healInfo, int distance, bool secondary) const +void BattleActionProcessor::applyBattleEffects(const CBattleInfoCallback & battle, BattleAttack & bat, std::shared_ptr attackerState, FireShieldInfo & fireShield, const CStack * def, battle::HealInfo & healInfo, int distance, bool secondary) const { BattleStackAttacked bsa; if(secondary) @@ -1446,13 +1446,11 @@ void BattleActionProcessor::applyBattleEffects(const CBattleInfoCallback & battl CStack::prepareAttacked(bsa, gameHandler->getRandomGenerator(), bai.defender->acquireState()); //calculate casualties } - battle::HealInfo tmpHealInfo; - //life drain handling if(attackerState->hasBonusOfType(BonusType::LIFE_DRAIN) && def->isLiving()) { int64_t toHeal = bsa.damageAmount * attackerState->valOfBonuses(BonusType::LIFE_DRAIN) / 100; - tmpHealInfo += attackerState->heal(toHeal, EHealLevel::RESURRECT, EHealPower::PERMANENT); + healInfo += attackerState->heal(toHeal, EHealLevel::RESURRECT, EHealPower::PERMANENT); } //soul steal handling @@ -1466,12 +1464,11 @@ void BattleActionProcessor::applyBattleEffects(const CBattleInfoCallback & battl { int64_t toHeal = bsa.killedAmount * attackerState->valOfBonuses(BonusType::SOUL_STEAL, subtype) * attackerState->getMaxHealth(); bool permanent = subtype == BonusCustomSubtype::soulStealPermanent; - tmpHealInfo += attackerState->heal(toHeal, EHealLevel::OVERHEAL, (permanent ? EHealPower::PERMANENT : EHealPower::ONE_BATTLE)); + healInfo += attackerState->heal(toHeal, EHealLevel::OVERHEAL, (permanent ? EHealPower::PERMANENT : EHealPower::ONE_BATTLE)); break; } } } - *healInfo += tmpHealInfo; bat.bsa.push_back(bsa); //add this stack to the list of victims after drain life has been calculated //fire shield handling diff --git a/server/battles/BattleActionProcessor.h b/server/battles/BattleActionProcessor.h index b4cd0d852..e7eaa7e78 100644 --- a/server/battles/BattleActionProcessor.h +++ b/server/battles/BattleActionProcessor.h @@ -54,7 +54,7 @@ class BattleActionProcessor : boost::noncopyable std::set getSpellsForAttackCasting(TConstBonusListPtr spells, const CStack *defender); // damage, drain life & fire shield; returns amount of drained life - void applyBattleEffects(const CBattleInfoCallback & battle, BattleAttack & bat, std::shared_ptr attackerState, FireShieldInfo & fireShield, const CStack * def, battle::HealInfo * healInfo, int distance, bool secondary) const; + void applyBattleEffects(const CBattleInfoCallback & battle, BattleAttack & bat, std::shared_ptr attackerState, FireShieldInfo & fireShield, const CStack * def, battle::HealInfo & healInfo, int distance, bool secondary) const; void sendGenericKilledLog(const CBattleInfoCallback & battle, const CStack * defender, int32_t killed, bool multiple); void addGenericKilledLog(BattleLogMessage & blm, const CStack * defender, int32_t killed, bool multiple) const;