Skip to content

Commit f926932

Browse files
refactor(logic): remove setDefaults from startNewGame except for optional object ID reset
1 parent 1a1e3d6 commit f926932

File tree

4 files changed

+38
-66
lines changed

4 files changed

+38
-66
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,6 @@ class GameLogic : public SubsystemInterface, public Snapshot
329329

330330
ObjectID m_nextObjID; ///< For allocating object id's
331331

332-
void setDefaults( Bool saveGame ); ///< Set default values of class object
333332
void processDestroyList( void ); ///< Destroy all pending objects on the destroy list
334333

335334
void destroyAllObjectsImmediate(); ///< destroy, and process destroy list immediately

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

Lines changed: 19 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -249,36 +249,6 @@ GameLogic::GameLogic( void )
249249
#endif
250250
}
251251

252-
// ------------------------------------------------------------------------------------------------
253-
/** Utility function to set class variables to default values. */
254-
// ------------------------------------------------------------------------------------------------
255-
void GameLogic::setDefaults( Bool saveGame )
256-
{
257-
m_frame = 0;
258-
m_hasUpdated = FALSE;
259-
m_width = DEFAULT_WORLD_WIDTH;
260-
m_height = DEFAULT_WORLD_HEIGHT;
261-
m_objList = NULL;
262-
#ifdef ALLOW_NONSLEEPY_UPDATES
263-
m_normalUpdates.clear();
264-
#endif
265-
for (std::vector<UpdateModulePtr>::iterator it = m_sleepyUpdates.begin(); it != m_sleepyUpdates.end(); ++it)
266-
{
267-
(*it)->friend_setIndexInLogic(-1);
268-
}
269-
m_sleepyUpdates.clear();
270-
m_curUpdateModule = NULL;
271-
272-
//
273-
// only reset the next object ID allocater counter when we're not loading a save game.
274-
// for save games, we read this value out of the save game file and it is important
275-
// that we preserve it as we load and execute the game
276-
//
277-
if( saveGame == FALSE )
278-
m_nextObjID = (ObjectID)1;
279-
280-
}
281-
282252
//-------------------------------------------------------------------------------------------------
283253
//-------------------------------------------------------------------------------------------------
284254
Bool GameLogic::isInSinglePlayerGame( void )
@@ -455,7 +425,17 @@ void GameLogic::reset( void )
455425
// clear any table of contents we have
456426
m_objectTOC.clear();
457427

458-
setDefaults( FALSE );
428+
m_frame = 0;
429+
m_hasUpdated = FALSE;
430+
m_width = DEFAULT_WORLD_WIDTH;
431+
m_height = DEFAULT_WORLD_HEIGHT;
432+
m_objList = NULL;
433+
for (std::vector<UpdateModulePtr>::iterator it = m_sleepyUpdates.begin(); it != m_sleepyUpdates.end(); ++it)
434+
{
435+
(*it)->friend_setIndexInLogic(-1);
436+
}
437+
m_sleepyUpdates.clear();
438+
m_curUpdateModule = NULL;
459439

460440
m_isScoringEnabled = TRUE;
461441
m_showBehindBuildingMarkers = TRUE;
@@ -1048,7 +1028,14 @@ void GameLogic::startNewGame( Bool saveGame )
10481028

10491029
}
10501030

1051-
setDefaults( saveGame );
1031+
//
1032+
// only reset the next object ID allocater counter when we're not loading a save game.
1033+
// for save games, we read this value out of the save game file and it is important
1034+
// that we preserve it as we load and execute the game
1035+
//
1036+
if( saveGame == FALSE )
1037+
m_nextObjID = (ObjectID)1;
1038+
10521039
TheWritableGlobalData->m_loadScreenRender = TRUE; ///< mark it so only a few select things are rendered during load
10531040
TheWritableGlobalData->m_TiVOFastMode = FALSE; //always disable the TIVO fast-forward mode at the start of a new game.
10541041

GeneralsMD/Code/GameEngine/Include/GameLogic/GameLogic.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,6 @@ class GameLogic : public SubsystemInterface, public Snapshot
353353

354354
ObjectID m_nextObjID; ///< For allocating object id's
355355

356-
void setDefaults( Bool loadSaveGame ); ///< Set default values of class object
357356
void processDestroyList( void ); ///< Destroy all pending objects on the destroy list
358357

359358
void destroyAllObjectsImmediate(); ///< destroy, and process destroy list immediately

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

Lines changed: 19 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -264,36 +264,6 @@ GameLogic::GameLogic( void )
264264
m_clearingGameData = FALSE;
265265
}
266266

267-
// ------------------------------------------------------------------------------------------------
268-
/** Utility function to set class variables to default values. */
269-
// ------------------------------------------------------------------------------------------------
270-
void GameLogic::setDefaults( Bool loadingSaveGame )
271-
{
272-
m_frame = 0;
273-
m_hasUpdated = FALSE;
274-
m_width = DEFAULT_WORLD_WIDTH;
275-
m_height = DEFAULT_WORLD_HEIGHT;
276-
m_objList = NULL;
277-
#ifdef ALLOW_NONSLEEPY_UPDATES
278-
m_normalUpdates.clear();
279-
#endif
280-
for (std::vector<UpdateModulePtr>::iterator it = m_sleepyUpdates.begin(); it != m_sleepyUpdates.end(); ++it)
281-
{
282-
(*it)->friend_setIndexInLogic(-1);
283-
}
284-
m_sleepyUpdates.clear();
285-
m_curUpdateModule = NULL;
286-
287-
//
288-
// only reset the next object ID allocater counter when we're not loading a save game.
289-
// for save games, we read this value out of the save game file and it is important
290-
// that we preserve it as we load and execute the game
291-
//
292-
if( loadingSaveGame == FALSE )
293-
m_nextObjID = (ObjectID)1;
294-
295-
}
296-
297267
//-------------------------------------------------------------------------------------------------
298268
//-------------------------------------------------------------------------------------------------
299269
Bool GameLogic::isInSinglePlayerGame( void )
@@ -461,7 +431,17 @@ void GameLogic::reset( void )
461431
// clear any table of contents we have
462432
m_objectTOC.clear();
463433

464-
setDefaults( FALSE );
434+
m_frame = 0;
435+
m_hasUpdated = FALSE;
436+
m_width = DEFAULT_WORLD_WIDTH;
437+
m_height = DEFAULT_WORLD_HEIGHT;
438+
m_objList = NULL;
439+
for (std::vector<UpdateModulePtr>::iterator it = m_sleepyUpdates.begin(); it != m_sleepyUpdates.end(); ++it)
440+
{
441+
(*it)->friend_setIndexInLogic(-1);
442+
}
443+
m_sleepyUpdates.clear();
444+
m_curUpdateModule = NULL;
465445

466446
m_isScoringEnabled = TRUE;
467447
m_showBehindBuildingMarkers = TRUE;
@@ -1180,7 +1160,14 @@ void GameLogic::startNewGame( Bool loadingSaveGame )
11801160

11811161
}
11821162

1183-
setDefaults( loadingSaveGame );
1163+
//
1164+
// only reset the next object ID allocater counter when we're not loading a save game.
1165+
// for save games, we read this value out of the save game file and it is important
1166+
// that we preserve it as we load and execute the game
1167+
//
1168+
if( loadingSaveGame == FALSE )
1169+
m_nextObjID = (ObjectID)1;
1170+
11841171
TheWritableGlobalData->m_loadScreenRender = TRUE; ///< mark it so only a few select things are rendered during load
11851172
TheWritableGlobalData->m_TiVOFastMode = FALSE; //always disable the TIVO fast-forward mode at the start of a new game.
11861173

0 commit comments

Comments
 (0)