diff --git a/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/GUI/GUICallbacks/W3DControlBar.cpp b/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/GUI/GUICallbacks/W3DControlBar.cpp index 52c3eab4ce..071cb170cf 100644 --- a/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/GUI/GUICallbacks/W3DControlBar.cpp +++ b/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/GUI/GUICallbacks/W3DControlBar.cpp @@ -497,8 +497,14 @@ void W3DCommandBarGenExpDraw( GameWindow *window, WinInstanceData *instData ) static const Image *endBar = TheMappedImageCollection->findImageByName("GenExpBarTop1"); static const Image *beginBar = TheMappedImageCollection->findImageByName("GenExpBarBottom1"); static const Image *centerBar = TheMappedImageCollection->findImageByName("GenExpBar1"); - Int progress; - progress = ((player->getSkillPoints() - player->getSkillPointsLevelDown()) * 100) /(player->getSkillPointsLevelUp() - player->getSkillPointsLevelDown()); + Int progress = 0; + Int skillPointsRequired = player->getSkillPointsLevelUp() - player->getSkillPointsLevelDown(); + + // TheSuperHackers @bugfix Mauller 04/05/2025 Prevent possible division by zero + if ( skillPointsRequired > 0) + { + progress = ( ((player->getSkillPoints() - player->getSkillPointsLevelDown()) * 100) / skillPointsRequired ); + } if(progress <= 0) return; diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/GUI/GUICallbacks/W3DControlBar.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/GUI/GUICallbacks/W3DControlBar.cpp index c75781a694..383df79c0e 100644 --- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/GUI/GUICallbacks/W3DControlBar.cpp +++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/GUI/GUICallbacks/W3DControlBar.cpp @@ -497,8 +497,14 @@ void W3DCommandBarGenExpDraw( GameWindow *window, WinInstanceData *instData ) static const Image *endBar = TheMappedImageCollection->findImageByName("GenExpBarTop1"); static const Image *beginBar = TheMappedImageCollection->findImageByName("GenExpBarBottom1"); static const Image *centerBar = TheMappedImageCollection->findImageByName("GenExpBar1"); - Int progress; - progress = ((player->getSkillPoints() - player->getSkillPointsLevelDown()) * 100) /(player->getSkillPointsLevelUp() - player->getSkillPointsLevelDown()); + Int progress = 0; + Int skillPointsRequired = player->getSkillPointsLevelUp() - player->getSkillPointsLevelDown(); + + // TheSuperHackers @bugfix Mauller 04/05/2025 Prevent possible division by zero + if ( skillPointsRequired > 0) + { + progress = ( ((player->getSkillPoints() - player->getSkillPointsLevelDown()) * 100) / skillPointsRequired ); + } if(progress <= 0) return;