Skip to content

Commit 3896a36

Browse files
GUI: Add null checks for m_playerRank and m_playerOfficerMedal in LoadScreen
1 parent ea1377d commit 3896a36

2 files changed

Lines changed: 12 additions & 8 deletions

File tree

‎Generals/Code/GameEngine/Source/GameClient/GUI/LoadScreen.cpp‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,12 +1018,12 @@ GameSlot *lSlot = game->getSlot(game->getLocalSlotNum());
10181018
// Load the Player's m_playerWinLosses
10191019
winName.format( "GameSpyLoadScreen.wnd:WinRank%d",i);
10201020
m_playerRank[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
1021-
DEBUG_ASSERTCRASH(m_playerRank[i], ("Can't initialize the m_playerRank for the GameSpyLoadScreen loadscreen"));
1021+
// NOTE: m_playerRank[i] can be NULL if the GUI element is missing - we'll check before using it
10221022

10231023
// Load the Player's m_playerOfficerMedal
10241024
winName.format( "GameSpyLoadScreen.wnd:WinOfficer%d",i);
10251025
m_playerOfficerMedal[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
1026-
DEBUG_ASSERTCRASH(m_playerOfficerMedal[i], ("Can't initialize the m_playerOfficerMedal for the GameSpyLoadScreen loadscreen"));
1026+
// NOTE: m_playerOfficerMedal[i] can be NULL if the GUI element is missing - we'll check before using it
10271027

10281028
winName.format( "MultiplayerLoadScreen.wnd:StaticTextTeam%d",i);
10291029
teamWin[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
@@ -1051,8 +1051,10 @@ GameSlot *lSlot = game->getSlot(game->getLocalSlotNum());
10511051
if (!isPreorder)
10521052
preorderImg = NULL;
10531053
const Image *rankImg = LookupSmallRankImage(favSide, rankPoints);
1054-
m_playerOfficerMedal[i]->winSetEnabledImage(0, preorderImg);
1055-
m_playerRank[i]->winSetEnabledImage(0, rankImg);
1054+
if (m_playerOfficerMedal[i])
1055+
m_playerOfficerMedal[i]->winSetEnabledImage(0, preorderImg);
1056+
if (m_playerRank[i])
1057+
m_playerRank[i]->winSetEnabledImage(0, rankImg);
10561058

10571059
UnicodeString formatString;
10581060

‎GeneralsMD/Code/GameEngine/Source/GameClient/GUI/LoadScreen.cpp‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1654,12 +1654,12 @@ GameSlot *lSlot = game->getSlot(game->getLocalSlotNum());
16541654
// Load the Player's m_playerWinLosses
16551655
winName.format( "GameSpyLoadScreen.wnd:WinRank%d",i);
16561656
m_playerRank[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
1657-
DEBUG_ASSERTCRASH(m_playerRank[i], ("Can't initialize the m_playerRank for the GameSpyLoadScreen loadscreen"));
1657+
// NOTE: m_playerRank[i] can be NULL if the GUI element is missing - we'll check before using it
16581658

16591659
// Load the Player's m_playerOfficerMedal
16601660
winName.format( "GameSpyLoadScreen.wnd:WinOfficer%d",i);
16611661
m_playerOfficerMedal[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
1662-
DEBUG_ASSERTCRASH(m_playerOfficerMedal[i], ("Can't initialize the m_playerOfficerMedal for the GameSpyLoadScreen loadscreen"));
1662+
// NOTE: m_playerOfficerMedal[i] can be NULL if the GUI element is missing - we'll check before using it
16631663

16641664
winName.format( "MultiplayerLoadScreen.wnd:StaticTextTeam%d",i);
16651665
teamWin[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( winName ));
@@ -1711,8 +1711,10 @@ GameSlot *lSlot = game->getSlot(game->getLocalSlotNum());
17111711
if (!isPreorder)
17121712
preorderImg = NULL;
17131713
const Image *rankImg = LookupSmallRankImage(favSide, rankPoints);
1714-
m_playerOfficerMedal[i]->winSetEnabledImage(0, preorderImg);
1715-
m_playerRank[i]->winSetEnabledImage(0, rankImg);
1714+
if (m_playerOfficerMedal[i])
1715+
m_playerOfficerMedal[i]->winSetEnabledImage(0, preorderImg);
1716+
if (m_playerRank[i])
1717+
m_playerRank[i]->winSetEnabledImage(0, rankImg);
17161718

17171719
UnicodeString formatString;
17181720

0 commit comments

Comments
 (0)