2
0
Эх сурвалжийг харах

Removed CStack::totalHealth()

AlexVinS 8 жил өмнө
parent
commit
ea3502ed60

+ 0 - 5
lib/CStack.cpp

@@ -589,11 +589,6 @@ const CGHeroInstance * CStack::getMyHero() const
 	return nullptr;
 }
 
-ui32 CStack::totalHealth() const
-{
-	return health.available();//do not hide possible invalid firstHPleft for dead stack
-}
-
 std::string CStack::nodeName() const
 {
 	std::ostringstream oss;

+ 0 - 1
lib/CStack.h

@@ -186,7 +186,6 @@ public:
 	si32 magicResistance() const override; //include aura of resistance
 	std::vector<si32> activeSpells() const; //returns vector of active spell IDs sorted by time of cast
 	const CGHeroInstance * getMyHero() const; //if stack belongs to hero (directly or was by him summoned) returns hero, nullptr otherwise
-	ui32 totalHealth() const; // total health for all creatures in stack;
 
 	static bool isMeleeAttackPossible(const CStack * attacker, const CStack * defender, BattleHex attackerPos = BattleHex::INVALID, BattleHex defenderPos = BattleHex::INVALID);
 

+ 2 - 2
lib/NetPacksLib.cpp

@@ -1640,8 +1640,8 @@ DLL_LINKAGE void StacksHealedOrResurrected::applyGs(CGameState *gs)
 		bool resurrected = !changedStack->alive(); //indicates if stack is resurrected or just healed
 		if(resurrected)
 		{
-			if(changedStack->getCount() > 0 || changedStack->getFirstHPleft() > 0)
-				logGlobal->warn("Dead stack %s with positive total HP %d", changedStack->nodeName(), changedStack->totalHealth());
+			if(auto totalHealth = changedStack->health.available())
+				logGlobal->warn("Dead stack %s with positive total HP %d", changedStack->nodeName(), totalHealth);
 
 			changedStack->state.insert(EBattleStackState::ALIVE);
 		}

+ 3 - 3
lib/spells/BattleSpellMechanics.cpp

@@ -442,10 +442,10 @@ ESpellCastProblem::ESpellCastProblem HypnotizeMechanics::isImmuneByStack(const I
 	if(nullptr != caster)
 	{
 		//TODO: what with other creatures casting hypnotize, Faerie Dragons style?
-		ui32 subjectHealth = obj->totalHealth();
+		int64_t subjectHealth = obj->health.available();
 		//apply 'damage' bonus for hypnotize, including hero specialty
-		ui32 maxHealth = caster->getSpellBonus(owner, owner->calculateRawEffectValue(caster->getEffectLevel(owner), caster->getEffectPower(owner)), obj);
-		if (subjectHealth > maxHealth)
+		int64_t maxHealth = caster->getSpellBonus(owner, owner->calculateRawEffectValue(caster->getEffectLevel(owner), caster->getEffectPower(owner)), obj);
+		if(subjectHealth > maxHealth)
 			return ESpellCastProblem::STACK_IMMUNE_TO_SPELL;
 	}
 	return DefaultSpellMechanics::isImmuneByStack(caster, obj);

+ 1 - 1
server/CGameHandler.cpp

@@ -1014,7 +1014,7 @@ void CGameHandler::applyBattleEffects(BattleAttack &bat, const CStack *att, cons
 		bsa2.flags |= BattleStackAttacked::EFFECT; //FIXME: play animation upon efreet and not attacker
 		bsa2.effect = 11;
 
-		bsa2.damageAmount = (std::min<si32>(def->totalHealth(), bsa.damageAmount) * def->valOfBonuses(Bonus::FIRE_SHIELD)) / 100; //TODO: scale with attack/defense
+		bsa2.damageAmount = (std::min<int64_t>(def->health.available(), bsa.damageAmount) * def->valOfBonuses(Bonus::FIRE_SHIELD)) / 100; //TODO: scale with attack/defense
 		att->prepareAttacked(bsa2, getRandomGenerator());
 		bat.bsa.push_back(bsa2);
 	}