Explorar o código

Fix floating point rounding for 5 attack points and unupgraded nix

Dydzio hai 1 ano
pai
achega
dbba1164ef
Modificáronse 1 ficheiros con 7 adicións e 1 borrados
  1. 7 1
      lib/battle/DamageCalculator.cpp

+ 7 - 1
lib/battle/DamageCalculator.cpp

@@ -9,6 +9,9 @@
  */
 
 #include "StdInc.h"
+
+#include <cfenv>
+
 #include "DamageCalculator.h"
 #include "CBattleInfoCallback.h"
 #include "Unit.h"
@@ -133,7 +136,10 @@ int DamageCalculator::getActorAttackIgnored() const
 
 	if(multAttackReduction > 0)
 	{
-		int reduction = std::round(multAttackReduction * getActorAttackBase());
+		int defaultRoundingMode = std::fegetround();
+		std::fesetround(FE_TOWARDZERO);
+		int reduction = std::nearbyint(multAttackReduction * getActorAttackBase());
+		std::fesetround(defaultRoundingMode);
 		return -std::min(reduction,getActorAttackBase());
 	}
 	return 0;