Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions Core/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,8 +424,15 @@ void ControlBar::populatePurchaseScience( Player* player )
win = TheWindowManager->winGetWindowFromId( m_contextParent[ CP_PURCHASE_SCIENCE ], TheNameKeyGenerator->nameToKey( "GeneralsExpPoints.wnd:ProgressBarExperience" ) );
if(win)
{
Int progress;
progress = ((player->getSkillPoints() - player->getSkillPointsLevelDown()) * 100) /(player->getSkillPointsLevelUp() - player->getSkillPointsLevelDown());
const Int skillPointsRequired = player->getSkillPointsLevelUp() - player->getSkillPointsLevelDown();
Int progress = 0;

// TheSuperHackers @bugfix Caball009 12/07/2026 Prevent possible division by zero.
if (skillPointsRequired > 0)
{
progress = ((player->getSkillPoints() - player->getSkillPointsLevelDown()) * 100) / skillPointsRequired;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code now exists at 3 locations. Maybe consolidate it to one?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

}
Comment thread
greptile-apps[bot] marked this conversation as resolved.

GadgetProgressBarSetProgress(win, progress);
}

Expand Down Expand Up @@ -483,8 +490,15 @@ void ControlBar::updateContextPurchaseScience()
win = TheWindowManager->winGetWindowFromId( m_contextParent[ CP_PURCHASE_SCIENCE ], TheNameKeyGenerator->nameToKey( "GeneralsExpPoints.wnd:ProgressBarExperience" ) );
if(win)
{
Int progress;
progress = ((player->getSkillPoints() - player->getSkillPointsLevelDown()) * 100) /(player->getSkillPointsLevelUp() - player->getSkillPointsLevelDown());
const Int skillPointsRequired = player->getSkillPointsLevelUp() - player->getSkillPointsLevelDown();
Int progress = 0;

// TheSuperHackers @bugfix Caball009 12/07/2026 Prevent possible division by zero.
if (skillPointsRequired > 0)
{
progress = ((player->getSkillPoints() - player->getSkillPointsLevelDown()) * 100) / skillPointsRequired;
}

GadgetProgressBarSetProgress(win, progress);
}

Expand Down
Loading