@@ -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// -------------------------------------------------------------------------------------------------
284254Bool GameLogic::isInSinglePlayerGame ( void )
@@ -370,9 +340,6 @@ void GameLogic::init( void )
370340
371341 setFPMode ();
372342
373- // / @todo Clear object and destroy lists
374- setDefaults ( FALSE );
375-
376343 // create the partition manager
377344 ThePartitionManager = NEW PartitionManager;
378345 ThePartitionManager->init ();
@@ -400,32 +367,8 @@ void GameLogic::init( void )
400367 // DEBUG_ASSERTCRASH(ThePlayerList, ("null ThePlayerList"));
401368 // ThePlayerList->setLocalPlayer(0);
402369
403- m_CRC = 0 ;
404- m_pauseFrame = 0 ;
405- m_gamePaused = FALSE ;
406- m_pauseSound = FALSE ;
407- m_pauseMusic = FALSE ;
408- m_pauseInput = FALSE ;
409- m_inputEnabledMemory = TRUE ;
410- m_mouseVisibleMemory = TRUE ;
411- m_logicTimeScaleEnabledMemory = FALSE ;
412-
413- for (Int i = 0 ; i < MAX_SLOTS; ++i)
414- {
415- m_progressComplete[i] = FALSE ;
416- m_progressCompleteTimeout[i] = 0 ;
417- }
418- m_forceGameStartByTimeOut = FALSE ;
419-
420- m_isScoringEnabled = TRUE ;
421- m_showBehindBuildingMarkers = TRUE ;
422- m_drawIconUI = TRUE ;
423- m_showDynamicLOD = TRUE ;
424- m_scriptHulkMaxLifetimeOverride = -1 ;
425-
370+ reset ();
426371 m_isInUpdate = FALSE ;
427-
428- m_rankPointsToAddAtGameStart = 0 ;
429372}
430373
431374// -------------------------------------------------------------------------------------------------
@@ -482,7 +425,20 @@ void GameLogic::reset( void )
482425 // clear any table of contents we have
483426 m_objectTOC.clear ();
484427
485- 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+ #ifdef ALLOW_NONSLEEPY_UPDATES
434+ m_normalUpdates.clear ();
435+ #endif
436+ for (std::vector<UpdateModulePtr>::iterator it = m_sleepyUpdates.begin (); it != m_sleepyUpdates.end (); ++it)
437+ {
438+ (*it)->friend_setIndexInLogic (-1 );
439+ }
440+ m_sleepyUpdates.clear ();
441+ m_curUpdateModule = NULL ;
486442
487443 m_isScoringEnabled = TRUE ;
488444 m_showBehindBuildingMarkers = TRUE ;
@@ -1076,59 +1032,60 @@ void GameLogic::startNewGame( Bool saveGame )
10761032 }
10771033
10781034 m_rankLevelLimit = 1000 ; // this is reset every game.
1079- setDefaults ( saveGame );
1035+
1036+ //
1037+ // only reset the next object ID allocater counter when we're not loading a save game.
1038+ // for save games, we read this value out of the save game file and it is important
1039+ // that we preserve it as we load and execute the game
1040+ //
1041+ if ( saveGame == FALSE )
1042+ m_nextObjID = (ObjectID)1 ;
1043+
10801044 TheWritableGlobalData->m_loadScreenRender = TRUE ; // /< mark it so only a few select things are rendered during load
10811045 TheWritableGlobalData->m_TiVOFastMode = FALSE ; // always disable the TIVO fast-forward mode at the start of a new game.
10821046
1083- m_showBehindBuildingMarkers = TRUE ;
1084- m_drawIconUI = TRUE ;
1085- m_showDynamicLOD = TRUE ;
1086- m_scriptHulkMaxLifetimeOverride = -1 ;
1087-
10881047 // Fill in the game color and Factions before we do the Load Screen
1089- GameInfo *game = NULL ;
10901048 TheGameInfo = NULL ;
10911049 Int localSlot = 0 ;
10921050 if (TheNetwork)
10931051 {
10941052 if (TheLAN)
10951053 {
10961054 DEBUG_LOG ((" Starting network game" ));
1097- TheGameInfo = game = TheLAN->GetMyGame ();
1055+ TheGameInfo = TheLAN->GetMyGame ();
10981056 }
10991057 else
11001058 {
11011059 DEBUG_LOG ((" Starting gamespy game" ));
1102- TheGameInfo = game = TheGameSpyGame; // / @todo: MDC add back in after demo
1060+ TheGameInfo = TheGameSpyGame; // / @todo: MDC add back in after demo
11031061 }
11041062 }
11051063 else
11061064 {
11071065 if (TheRecorder && TheRecorder->isPlaybackMode ())
11081066 {
1109- TheGameInfo = game = TheRecorder->getGameInfo ();
1067+ TheGameInfo = TheRecorder->getGameInfo ();
11101068 }
11111069 else if (m_gameMode == GAME_SKIRMISH)
11121070 {
1113- TheGameInfo = game = TheSkirmishGameInfo;
1071+ TheGameInfo = TheSkirmishGameInfo;
11141072 }
11151073 }
11161074
1117- checkForDuplicateColors ( game );
1075+ checkForDuplicateColors ( TheGameInfo );
11181076
11191077 Bool isSkirmishOrSkirmishReplay = FALSE ;
1120- if (game )
1078+ if (TheGameInfo )
11211079 {
11221080 for (Int i=0 ; i<MAX_SLOTS; ++i)
11231081 {
1124- GameSlot *slot = game ->getSlot (i);
1082+ GameSlot *slot = TheGameInfo ->getSlot (i);
11251083 if (!saveGame) {
11261084 slot->saveOffOriginalInfo ();
11271085 }
11281086 if (slot->isAI ())
11291087 {
11301088 isSkirmishOrSkirmishReplay = TRUE ;
1131- continue ;
11321089 }
11331090 }
11341091 } else {
@@ -1138,8 +1095,8 @@ void GameLogic::startNewGame( Bool saveGame )
11381095 }
11391096 }
11401097
1141- populateRandomSideAndColor ( game );
1142- populateRandomStartPosition ( game );
1098+ populateRandomSideAndColor ( TheGameInfo );
1099+ populateRandomStartPosition ( TheGameInfo );
11431100
11441101 // ****************************//
11451102 // Start the LoadScreen Now! //
@@ -1152,7 +1109,7 @@ void GameLogic::startNewGame( Bool saveGame )
11521109 if (m_loadScreen && !TheGlobalData->m_headless )
11531110 {
11541111 TheMouse->setVisibility (FALSE );
1155- m_loadScreen->init (game );
1112+ m_loadScreen->init (TheGameInfo );
11561113
11571114 updateLoadProgress ( LOAD_PROGRESS_START );
11581115 }
@@ -1194,7 +1151,7 @@ void GameLogic::startNewGame( Bool saveGame )
11941151 #endif
11951152
11961153 Int progressCount = LOAD_PROGRESS_SIDE_POPULATION;
1197- if (game )
1154+ if (TheGameInfo )
11981155 {
11991156
12001157 if (TheGameEngine->isMultiplayerSession () || isSkirmishOrSkirmishReplay)
@@ -1203,12 +1160,12 @@ void GameLogic::startNewGame( Bool saveGame )
12031160 TheSidesList->prepareForMP_or_Skirmish ();
12041161 }
12051162
1206- // DEBUG_LOG(("Starting LAN game with %d players", game ->getNumPlayers()));
1163+ // DEBUG_LOG(("Starting LAN game with %d players", TheGameInfo ->getNumPlayers()));
12071164 Dict d;
12081165 for (int i=0 ; i<MAX_SLOTS; ++i)
12091166 {
12101167 // Add a Side to TheSidesList
1211- GameSlot *slot = game ->getSlot (i);
1168+ GameSlot *slot = TheGameInfo ->getSlot (i);
12121169
12131170 if (!slot || !slot->isHuman ())
12141171 {
@@ -1235,7 +1192,7 @@ void GameLogic::startNewGame( Bool saveGame )
12351192 d.setAsciiString (TheKey_playerFaction, KEYNAME (pt->getNameKey ()));
12361193 }
12371194
1238- if (game ->isPlayerPreorder (i))
1195+ if (TheGameInfo ->isPlayerPreorder (i))
12391196 {
12401197 d.setBool (TheKey_playerIsPreorder, TRUE );
12411198 }
@@ -1245,7 +1202,7 @@ void GameLogic::startNewGame( Bool saveGame )
12451202 DEBUG_LOG ((" Looking for allies of player %d, team %d" , i, team));
12461203 for (int j=0 ; j < MAX_SLOTS; ++j)
12471204 {
1248- GameSlot *teamSlot = game ->getSlot (j);
1205+ GameSlot *teamSlot = TheGameInfo ->getSlot (j);
12491206 // for check to see if we're trying to add ourselves
12501207 if (i == j || !teamSlot->isOccupied ())
12511208 continue ;
@@ -1299,7 +1256,7 @@ void GameLogic::startNewGame( Bool saveGame )
12991256 d.setInt (TheKey_multiplayerStartIndex, slot->getStartPos ());
13001257// d.setBool(TheKey_multiplayerIsLocal, slot->isLocalPlayer());
13011258// d.setBool(TheKey_multiplayerIsLocal, slot->getIP() == game->getLocalIP());
1302- d.setBool (TheKey_multiplayerIsLocal, slot->isHuman () && (slot->getName ().compare (game ->getSlot (game ->getLocalSlotNum ())->getName ().str ()) == 0 ));
1259+ d.setBool (TheKey_multiplayerIsLocal, slot->isHuman () && (slot->getName ().compare (TheGameInfo ->getSlot (TheGameInfo ->getLocalSlotNum ())->getName ().str ()) == 0 ));
13031260
13041261/*
13051262 if (slot->getIP() == game->getLocalIP())
@@ -1322,7 +1279,7 @@ void GameLogic::startNewGame( Bool saveGame )
13221279
13231280 AsciiString slotNameAscii;
13241281 slotNameAscii.translate (slot->getName ());
1325- if (slot->isHuman () && game ->getSlotNum (slotNameAscii) == game ->getLocalSlotNum ()) {
1282+ if (slot->isHuman () && TheGameInfo ->getSlotNum (slotNameAscii) == TheGameInfo ->getLocalSlotNum ()) {
13261283 localSlot = i;
13271284 }
13281285 TheSidesList->addSide (&d);
@@ -1392,11 +1349,11 @@ void GameLogic::startNewGame( Bool saveGame )
13921349 // if there are no other teams (happens for debugging) don't end the game immediately
13931350 Int numTeams = 0 ; // this can be higher than expected, but is accurate for determining 0, 1, 2+
13941351 Int lastTeam = -1 ;
1395- if (game )
1352+ if (TheGameInfo )
13961353 {
13971354 for (int i=0 ; i<MAX_SLOTS; ++i)
13981355 {
1399- const GameSlot *slot = game ->getConstSlot (i);
1356+ const GameSlot *slot = TheGameInfo ->getConstSlot (i);
14001357 if (slot->isOccupied () && slot->getPlayerTemplate () != PLAYERTEMPLATE_OBSERVER)
14011358 {
14021359 if (slot->getTeamNumber () == -1 || slot->getTeamNumber () != lastTeam)
@@ -1625,11 +1582,11 @@ void GameLogic::startNewGame( Bool saveGame )
16251582 ThePartitionManager->revealMapForPlayerPermanently ( observerPlayer->getPlayerIndex () );
16261583 DEBUG_LOG ((" Reveal shroud for %ls whose index is %d" , observerPlayer->getPlayerDisplayName ().str (), observerPlayer->getPlayerIndex ()));
16271584
1628- if (game )
1585+ if (TheGameInfo )
16291586 {
16301587 for (int i=0 ; i<MAX_SLOTS; ++i)
16311588 {
1632- GameSlot *slot = game ->getSlot (i);
1589+ GameSlot *slot = TheGameInfo ->getSlot (i);
16331590
16341591 if (!slot || !slot->isOccupied ())
16351592 continue ;
@@ -1763,11 +1720,11 @@ void GameLogic::startNewGame( Bool saveGame )
17631720
17641721 progressCount = LOAD_PROGRESS_LOOP_INITIAL_NETWORK_BUILDINGS;
17651722 // place initial network buildings/units
1766- if (game && !saveGame)
1723+ if (TheGameInfo && !saveGame)
17671724 {
17681725 for (int i=0 ; i<MAX_SLOTS; ++i)
17691726 {
1770- GameSlot *slot = game ->getSlot (i);
1727+ GameSlot *slot = TheGameInfo ->getSlot (i);
17711728
17721729 if (!slot || !slot->isOccupied ())
17731730 continue ;
@@ -1842,9 +1799,9 @@ void GameLogic::startNewGame( Bool saveGame )
18421799 // Note - We construct the multiplayer start spot name manually here, so change this if you
18431800 // change TheKey_Player_1_Start etc. mdc
18441801 AsciiString startingCamName = TheNameKeyGenerator->keyToName (TheKey_InitialCameraPosition);
1845- if (game )
1802+ if (TheGameInfo )
18461803 {
1847- GameSlot *slot = game ->getSlot (localSlot);
1804+ GameSlot *slot = TheGameInfo ->getSlot (localSlot);
18481805 DEBUG_ASSERTCRASH (slot, (" Starting a LAN game without ourselves!" ));
18491806
18501807 if (slot->isHuman ())
0 commit comments