Skip to content

Commit c52fb6a

Browse files
unify(logic): Merge game loading related variables and functions from Zero Hour (#2444)
1 parent 5febc14 commit c52fb6a

5 files changed

Lines changed: 47 additions & 28 deletions

File tree

Generals/Code/GameEngine/Include/GameLogic/GameLogic.h

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,18 @@ class GameLogic : public SubsystemInterface, public Snapshot
152152
ObjectID allocateObjectID(); ///< Returns a new unique object id
153153

154154
// super hack
155-
void startNewGame( Bool saveGame );
155+
void startNewGame( Bool loadSaveGame );
156156
void loadMapINI( AsciiString mapName );
157157

158158
void updateLoadProgress( Int progress );
159159
void deleteLoadScreen();
160160

161-
void setGameLoading( Bool loading );
161+
//Kris: Cut setGameLoading() and replaced with setLoadingMap() and setLoadingSave() -- reason: nomenclature
162+
//void setGameLoading( Bool loading ) { m_loadingScene = loading; }
163+
void setLoadingMap( Bool loading ) { m_loadingMap = loading; }
164+
void setLoadingSave( Bool loading ) { m_loadingSave = loading; }
165+
void setClearingGameData( Bool clearing ) { m_clearingGameData = clearing; }
166+
162167
void setGameMode( GameMode mode );
163168
GameMode getGameMode();
164169

@@ -174,7 +179,12 @@ class GameLogic : public SubsystemInterface, public Snapshot
174179

175180
static Bool isInInteractiveGame(GameMode mode) { return mode != GAME_NONE && mode != GAME_SHELL; }
176181

177-
Bool isLoadingGame();
182+
//Kris: Cut isLoadingGame() and replaced with isLoadingMap() and isLoadingSave() -- reason: nomenclature
183+
//Bool isLoadingGame() const { return m_loadingScene; } // This is the old function that isn't very clear on it's definition.
184+
Bool isLoadingMap() const { return m_loadingMap; } // Whenever a map is in the process of loading.
185+
Bool isLoadingSave() const { return m_loadingSave; } // Whenever a saved game is in the process of loading.
186+
Bool isClearingGameData() const { return m_clearingGameData; }
187+
178188
void enableScoring(Bool score) { m_isScoringEnabled = score; }
179189
Bool isScoringEnabled() const { return m_isScoringEnabled; }
180190

@@ -292,7 +302,10 @@ class GameLogic : public SubsystemInterface, public Snapshot
292302
std::map<Int, UnsignedInt> m_cachedCRCs; ///< CRCs we've seen this frame
293303
Bool m_shouldValidateCRCs; ///< Should we validate CRCs this frame?
294304
//-----------------------------------------------------------------------------------------------
295-
Bool m_loadingScene;
305+
//Bool m_loadingScene;
306+
Bool m_loadingMap;
307+
Bool m_loadingSave;
308+
Bool m_clearingGameData;
296309

297310
Bool m_isInUpdate;
298311
Bool m_hasUpdated;
@@ -398,8 +411,6 @@ inline Bool GameLogic::isInInteractiveGame() const { return isInInteractiveGame(
398411
inline Bool GameLogic::isInReplayGame() { return (m_gameMode == GAME_REPLAY); }
399412
inline Bool GameLogic::isInInternetGame() { return (m_gameMode == GAME_INTERNET); }
400413
inline Bool GameLogic::isInShellGame() { return (m_gameMode == GAME_SHELL); }
401-
//Check for loading scene
402-
inline Bool GameLogic::isLoadingGame(){ return m_loadingScene;}
403414

404415
inline Object* GameLogic::findObjectByID( ObjectID id )
405416
{

Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Diplomacy.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ void UpdateDiplomacyBriefingText(AsciiString newText, Bool clear)
194194
void ShowDiplomacy( Bool immediate )
195195
{
196196
if (!TheInGameUI->getInputEnabled() || TheGameLogic->isIntroMoviePlaying() ||
197-
TheGameLogic->isLoadingGame())
197+
TheGameLogic->isLoadingMap())
198198
return;
199199

200200

Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/QuitMenu.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ void HideQuitMenu()
281281
//-------------------------------------------------------------------------------------------------
282282
void ToggleQuitMenu()
283283
{
284-
if (TheGameLogic->isIntroMoviePlaying() || TheGameLogic->isLoadingGame() ||TheScriptEngine->isGameEnding())
284+
if (TheGameLogic->isIntroMoviePlaying() || TheGameLogic->isLoadingMap() ||TheScriptEngine->isGameEnding())
285285
return;
286286

287287
// BGC- If we are currently in the disconnect screen, don't let the quit menu come up.

Generals/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,10 @@ GameLogic::GameLogic()
247247
#ifdef DUMP_PERF_STATS
248248
m_overallFailedPathfinds = 0;
249249
#endif
250+
251+
m_loadingMap = FALSE;
252+
m_loadingSave = FALSE;
253+
m_clearingGameData = FALSE;
250254
}
251255

252256
//-------------------------------------------------------------------------------------------------
@@ -933,11 +937,6 @@ void GameLogic::deleteLoadScreen()
933937

934938
}
935939

936-
void GameLogic::setGameLoading( Bool loading )
937-
{
938-
m_loadingScene = loading;
939-
}
940-
941940
// ------------------------------------------------------------------------------------------------
942941
// ------------------------------------------------------------------------------------------------
943942
void GameLogic::updateDisplayBusyState()
@@ -964,7 +963,7 @@ void GameLogic::setGameMode( GameMode mode )
964963
/** Entry point for starting a new game, the engine is already in clean state at this
965964
* point and ready to load up with all the data */
966965
// ------------------------------------------------------------------------------------------------
967-
void GameLogic::startNewGame( Bool saveGame )
966+
void GameLogic::startNewGame( Bool loadingSaveGame )
968967
{
969968

970969
#ifdef DUMP_PERF_STATS
@@ -984,7 +983,9 @@ void GameLogic::startNewGame( Bool saveGame )
984983
CRCDebugStartNewGame();
985984
#endif
986985

987-
if( saveGame == FALSE )
986+
setLoadingMap( TRUE );
987+
988+
if( loadingSaveGame == FALSE )
988989
{
989990

990991
// record pristine map name when we're loading from the map (not a save game)
@@ -1015,7 +1016,7 @@ void GameLogic::startNewGame( Bool saveGame )
10151016
deleteInstance(m_background);
10161017
m_background = nullptr;
10171018
}
1018-
m_loadScreen = getLoadScreen( saveGame );
1019+
m_loadScreen = getLoadScreen( loadingSaveGame );
10191020
if(m_loadScreen)
10201021
{
10211022
TheWritableGlobalData->m_loadScreenRender = TRUE; ///< mark it so only a few select things are rendered during load
@@ -1038,7 +1039,7 @@ void GameLogic::startNewGame( Bool saveGame )
10381039
// for save games, we read this value out of the save game file and it is important
10391040
// that we preserve it as we load and execute the game
10401041
//
1041-
if( saveGame == FALSE )
1042+
if( loadingSaveGame == FALSE )
10421043
m_nextObjID = (ObjectID)1;
10431044

10441045
TheWritableGlobalData->m_loadScreenRender = TRUE; ///< mark it so only a few select things are rendered during load
@@ -1079,7 +1080,7 @@ void GameLogic::startNewGame( Bool saveGame )
10791080
for (Int i=0; i<MAX_SLOTS; ++i)
10801081
{
10811082
GameSlot *slot = TheGameInfo->getSlot(i);
1082-
if (!saveGame) {
1083+
if (!loadingSaveGame) {
10831084
slot->saveOffOriginalInfo();
10841085
}
10851086
if (slot->isAI())
@@ -1104,7 +1105,7 @@ void GameLogic::startNewGame( Bool saveGame )
11041105
// Get the m_loadScreen for this kind of game
11051106
if(!m_loadScreen && !(TheRecorder && TheRecorder->getMode() == RECORDERMODETYPE_SIMULATION_PLAYBACK))
11061107
{
1107-
m_loadScreen = getLoadScreen( saveGame );
1108+
m_loadScreen = getLoadScreen( loadingSaveGame );
11081109
if(m_loadScreen && !TheGlobalData->m_headless)
11091110
{
11101111
TheMouse->setVisibility(FALSE);
@@ -1510,7 +1511,7 @@ void GameLogic::startNewGame( Bool saveGame )
15101511
updateLoadProgress(LOAD_PROGRESS_POST_GHOST_OBJECT_MANAGER_RESET);
15111512

15121513
// update the terrain logic now that all is loaded
1513-
TheTerrainLogic->newMap( saveGame );
1514+
TheTerrainLogic->newMap( loadingSaveGame );
15141515

15151516
// update the loadscreen
15161517
updateLoadProgress(LOAD_PROGRESS_POST_TERRAIN_LOGIC_NEW_MAP);
@@ -1613,7 +1614,7 @@ void GameLogic::startNewGame( Bool saveGame )
16131614
DEBUG_LOG(("%s", Buf));
16141615
#endif
16151616

1616-
if( saveGame == FALSE )
1617+
if( loadingSaveGame == FALSE )
16171618
{
16181619
Int progressCount = LOAD_PROGRESS_LOOP_ALL_THE_FREAKN_OBJECTS;
16191620
Int timer = timeGetTime();
@@ -1716,7 +1717,7 @@ void GameLogic::startNewGame( Bool saveGame )
17161717
#endif
17171718

17181719
// place initial network buildings/units
1719-
if (TheGameInfo && !saveGame)
1720+
if (TheGameInfo && !loadingSaveGame)
17201721
{
17211722
Int progressCount = LOAD_PROGRESS_LOOP_INITIAL_NETWORK_BUILDINGS;
17221723
for (int i=0; i<MAX_SLOTS; ++i)
@@ -1852,11 +1853,11 @@ void GameLogic::startNewGame( Bool saveGame )
18521853

18531854

18541855
// final step, run newMap for all players
1855-
if( saveGame == FALSE )
1856+
if( loadingSaveGame == FALSE )
18561857
ThePlayerList->newMap();
18571858

18581859
// reset all the skill points in a single player game
1859-
if(saveGame == FALSE && isInSinglePlayerGame())
1860+
if(loadingSaveGame == FALSE && isInSinglePlayerGame())
18601861
{
18611862
for (Int i=0; i<MAX_PLAYER_COUNT; ++i)
18621863
{
@@ -1889,7 +1890,7 @@ void GameLogic::startNewGame( Bool saveGame )
18891890
}
18901891

18911892
// if we're in a load game, don't fade yet
1892-
if(saveGame == FALSE && TheTransitionHandler != nullptr && m_loadScreen)
1893+
if(loadingSaveGame == FALSE && TheTransitionHandler != nullptr && m_loadScreen)
18931894
{
18941895
TheTransitionHandler->setGroup("FadeWholeScreen");
18951896
while(!TheTransitionHandler->isFinished())
@@ -1915,7 +1916,7 @@ void GameLogic::startNewGame( Bool saveGame )
19151916
// have more work to do and the load screen will be deleted elsewhere after
19161917
// we're all done with the load game progress
19171918
//
1918-
if( saveGame == FALSE )
1919+
if( loadingSaveGame == FALSE )
19191920
*/
19201921
deleteLoadScreen();
19211922

@@ -2048,7 +2049,8 @@ void GameLogic::startNewGame( Bool saveGame )
20482049
}
20492050

20502051
//ReAllows quit menu to work during loading scene
2051-
setGameLoading(FALSE);
2052+
//setGameLoading(FALSE);
2053+
setLoadingMap( FALSE );
20522054

20532055
#ifdef DUMP_PERF_STATS
20542056
GetPrecisionTimer(&endTime64);

Generals/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,8 @@ void GameLogic::clearGameData( Bool showScoreScreen )
248248
return;
249249
}
250250

251+
setClearingGameData( TRUE );
252+
251253
// m_background = TheWindowManager->winCreateLayout("Menus/BlankWindow.wnd");
252254
// DEBUG_ASSERTCRASH(m_background,("We Couldn't Load Menus/BlankWindow.wnd"));
253255
// m_background->hide(FALSE);
@@ -292,14 +294,18 @@ void GameLogic::clearGameData( Bool showScoreScreen )
292294
m_background = nullptr;
293295
}
294296

297+
setClearingGameData( FALSE );
298+
295299
}
296300

297301
// ------------------------------------------------------------------------------------------------
298302
/** Prepare for a new game */
299303
// ------------------------------------------------------------------------------------------------
300304
void GameLogic::prepareNewGame( GameMode gameMode, GameDifficulty diff, Int rankPoints )
301305
{
302-
setGameLoading(TRUE);
306+
//Kris: Commented this out, but leaving it around incase it bites us later. I cleaned up the
307+
// nomenclature. Look for setLoadingMap() and setLoadingSave()
308+
//setGameLoading(TRUE);
303309

304310
TheScriptEngine->setGlobalDifficulty(diff);
305311

0 commit comments

Comments
 (0)