1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-26 22:57:00 +02:00

Fix floating point rounding for 5 attack points and unupgraded nix

This commit is contained in:
Dydzio 2024-01-08 20:50:37 +01:00
parent 675f9b11fa
commit dbba1164ef

View File

@ -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;