bugfix(controlbar): Fix possible divisions by zero in Control Bar code#2867
bugfix(controlbar): Fix possible divisions by zero in Control Bar code#2867Caball009 wants to merge 1 commit into
Conversation
|
| Filename | Overview |
|---|---|
| Core/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp | Makes the purchase-science progress locals immutable while retaining the existing calculation. |
| Core/GameEngineDevice/Source/W3DDevice/GameClient/GUI/GUICallbacks/W3DControlBar.cpp | Uses the player rank interval directly for general experience progress rendering. |
| Generals/Code/GameEngine/Source/Common/RTS/Player.cpp | Normalizes invalid rank thresholds during rank reset and rank changes. |
| GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp | Mirrors the rank threshold normalization for the Zero Hour player implementation. |
Reviews (6): Last reviewed commit: "bugfix(controlbar): Fix possible divisio..." | Re-trigger Greptile
47b4cdc to
2ac70a7
Compare
|
If skillPointsRequired is 0, than this implies that a rank up didn't go through - after all the player has enough points to rank up to the next level. So I wonder if the fix is at the wrong place |
| // TheSuperHackers @bugfix Caball009 12/07/2026 Prevent possible division by zero. | ||
| if (skillPointsRequired > 0) | ||
| { | ||
| progress = ((player->getSkillPoints() - player->getSkillPointsLevelDown()) * 100) / skillPointsRequired; |
There was a problem hiding this comment.
This code now exists at 3 locations. Maybe consolidate it to one?
| // TheSuperHackers @bugfix Caball009 12/07/2026 Prevent possible division by zero. | ||
| if (skillPointsRequired > 0) | ||
| { | ||
| progress = ((player->getSkillPoints() - player->getSkillPointsLevelDown()) * 100) / skillPointsRequired; |
There was a problem hiding this comment.
I wonder if this should be even a bit smarter and set progress to zero if the max skill points have been reached. Currently It looks like getSkillPointsLevelUp will become INT_MAX after the last level so it is not totally clean.
There was a problem hiding this comment.
Not sure if the new implementation is any better.
2ac70a7 to
ed174e2
Compare
ed174e2 to
ede4635
Compare
ede4635 to
480a9a7
Compare
|
@greptileai re-review this pull request. |
Using the modified rank file in #797, there are two more places the game would crash because of a division by zero; in
ControlBar::populatePurchaseScienceandControlBar::updateContextPurchaseScience.Issue reproduction steps:
Callstacks: