1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +02:00

Fix handling of bonuses with negative values

This commit is contained in:
Ivan Savenko
2025-06-26 15:45:04 +03:00
parent 31786c8135
commit d1f9c497a3
4 changed files with 19 additions and 6 deletions

View File

@@ -70,7 +70,10 @@ int BonusList::totalValue(int baseValue) const
};
auto applyPercentageRoundUp = [](int base, int percent) -> int {
return (static_cast<int64_t>(base) * (100 + percent) + 99) / 100;
if (base >= 0)
return (static_cast<int64_t>(base) * (100 + percent) + 99) / 100;
else
return (static_cast<int64_t>(base) * (100 + percent) - 99) / 100;
};
auto applyPercentageRoundDown = [](int base, int percent) -> int {