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 | Guards rank-progress division in both Special Powers UI refresh paths. |
Reviews (2): 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.
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: