瀏覽代碼

Change nix rounding, revert assert comment

M 1 年之前
父節點
當前提交
815fa26fb3
共有 2 個文件被更改,包括 5 次插入8 次删除
  1. 1 1
      client/battle/BattleInterface.cpp
  2. 4 7
      lib/battle/DamageCalculator.cpp

+ 1 - 1
client/battle/BattleInterface.cpp

@@ -791,7 +791,7 @@ void BattleInterface::waitForAnimations()
 	}
 
 	assert(!hasAnimations());
-	//assert(awaitingEvents.empty());
+	assert(awaitingEvents.empty());
 
 	if (!awaitingEvents.empty())
 	{

+ 4 - 7
lib/battle/DamageCalculator.cpp

@@ -132,15 +132,12 @@ int DamageCalculator::getActorAttackEffective() const
 
 int DamageCalculator::getActorAttackIgnored() const
 {
-	double multAttackReduction = battleBonusValue(info.defender, Selector::type()(BonusType::ENEMY_ATTACK_REDUCTION)) / 100.0;
+	int multAttackReductionPercent = battleBonusValue(info.defender, Selector::type()(BonusType::ENEMY_ATTACK_REDUCTION));
 
-	if(multAttackReduction > 0)
+	if(multAttackReductionPercent > 0)
 	{
-		int defaultRoundingMode = std::fegetround();
-		std::fesetround(FE_TOWARDZERO);
-		int reduction = std::nearbyint(multAttackReduction * getActorAttackBase());
-		std::fesetround(defaultRoundingMode);
-		return -std::min(reduction,getActorAttackBase());
+		int reduction = (getActorAttackBase() * multAttackReductionPercent + 49) / 100; //using ints so 1.5 for 5 attack is rounded down as in HotA / h3assist etc. (keep in mind h3assist 1.2 shows wrong value for 15 attack points and unupg. nix)
+		return -std::min(reduction, getActorAttackBase());
 	}
 	return 0;
 }