Skip to content

Commit 09f3a84

Browse files
authored
bugfix(player): Fix rounding inaccuracies with money awarded by Cash Bounty (TheSuperHackers#2330)
1 parent 0b8af6d commit 09f3a84

File tree

2 files changed

+10
-0
lines changed
  • GeneralsMD/Code/GameEngine/Source/Common/RTS
  • Generals/Code/GameEngine/Source/Common/RTS

2 files changed

+10
-0
lines changed

Generals/Code/GameEngine/Source/Common/RTS/Player.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2028,7 +2028,12 @@ void Player::doBountyForKill(const Object* killer, const Object* victim)
20282028
return;
20292029

20302030
Int costToBuild = victim->getTemplate()->calcCostToBuild(victim->getControllingPlayer());
2031+
#if RETAIL_COMPATIBLE_CRC
20312032
Int bounty = REAL_TO_INT_CEIL(costToBuild * m_cashBountyPercent);
2033+
#else
2034+
// TheSuperHackers @bugfix Stubbjax 20/02/2026 Subtract epsilon to ensure bounty is rounded up correctly.
2035+
Int bounty = ceil((costToBuild * m_cashBountyPercent) - WWMATH_EPSILON);
2036+
#endif
20322037

20332038
if( bounty )
20342039
{

GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2427,7 +2427,12 @@ void Player::doBountyForKill(const Object* killer, const Object* victim)
24272427
return;
24282428

24292429
Int costToBuild = victim->getTemplate()->calcCostToBuild(victim->getControllingPlayer());
2430+
#if RETAIL_COMPATIBLE_CRC
24302431
Int bounty = REAL_TO_INT_CEIL(costToBuild * m_cashBountyPercent);
2432+
#else
2433+
// TheSuperHackers @bugfix Stubbjax 20/02/2026 Subtract epsilon to ensure bounty is rounded up correctly.
2434+
Int bounty = ceil((costToBuild * m_cashBountyPercent) - WWMATH_EPSILON);
2435+
#endif
24312436

24322437
if( bounty )
24332438
{

0 commit comments

Comments
 (0)