Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Generals/Code/GameEngine/Include/GameLogic/GameLogic.h
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,6 @@ class GameLogic : public SubsystemInterface, public Snapshot

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

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

void destroyAllObjectsImmediate(); ///< destroy, and process destroy list immediately
Expand Down
141 changes: 49 additions & 92 deletions Generals/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,36 +249,6 @@ GameLogic::GameLogic( void )
#endif
}

// ------------------------------------------------------------------------------------------------
/** Utility function to set class variables to default values. */
// ------------------------------------------------------------------------------------------------
void GameLogic::setDefaults( Bool saveGame )
{
m_frame = 0;
m_hasUpdated = FALSE;
m_width = DEFAULT_WORLD_WIDTH;
m_height = DEFAULT_WORLD_HEIGHT;
m_objList = NULL;
#ifdef ALLOW_NONSLEEPY_UPDATES
m_normalUpdates.clear();
#endif
for (std::vector<UpdateModulePtr>::iterator it = m_sleepyUpdates.begin(); it != m_sleepyUpdates.end(); ++it)
{
(*it)->friend_setIndexInLogic(-1);
}
m_sleepyUpdates.clear();
m_curUpdateModule = NULL;

//
// only reset the next object ID allocater counter when we're not loading a save game.
// for save games, we read this value out of the save game file and it is important
// that we preserve it as we load and execute the game
//
if( saveGame == FALSE )
m_nextObjID = (ObjectID)1;

}

//-------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------
Bool GameLogic::isInSinglePlayerGame( void )
Expand Down Expand Up @@ -370,9 +340,6 @@ void GameLogic::init( void )

setFPMode();

/// @todo Clear object and destroy lists
setDefaults( FALSE );

// create the partition manager
ThePartitionManager = NEW PartitionManager;
ThePartitionManager->init();
Expand Down Expand Up @@ -400,32 +367,8 @@ void GameLogic::init( void )
//DEBUG_ASSERTCRASH(ThePlayerList, ("null ThePlayerList"));
//ThePlayerList->setLocalPlayer(0);

m_CRC = 0;
m_pauseFrame = 0;
m_gamePaused = FALSE;
m_pauseSound = FALSE;
m_pauseMusic = FALSE;
m_pauseInput = FALSE;
m_inputEnabledMemory = TRUE;
m_mouseVisibleMemory = TRUE;
m_logicTimeScaleEnabledMemory = FALSE;

for(Int i = 0; i < MAX_SLOTS; ++i)
{
m_progressComplete[i] = FALSE;
m_progressCompleteTimeout[i] = 0;
}
m_forceGameStartByTimeOut = FALSE;

m_isScoringEnabled = TRUE;
m_showBehindBuildingMarkers = TRUE;
m_drawIconUI = TRUE;
m_showDynamicLOD = TRUE;
m_scriptHulkMaxLifetimeOverride = -1;

reset();
m_isInUpdate = FALSE;

m_rankPointsToAddAtGameStart = 0;
}

//-------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -482,7 +425,20 @@ void GameLogic::reset( void )
// clear any table of contents we have
m_objectTOC.clear();

setDefaults( FALSE );
m_frame = 0;
m_hasUpdated = FALSE;
m_width = DEFAULT_WORLD_WIDTH;
m_height = DEFAULT_WORLD_HEIGHT;
m_objList = NULL;
#ifdef ALLOW_NONSLEEPY_UPDATES
m_normalUpdates.clear();
#endif
for (std::vector<UpdateModulePtr>::iterator it = m_sleepyUpdates.begin(); it != m_sleepyUpdates.end(); ++it)
{
(*it)->friend_setIndexInLogic(-1);
}
m_sleepyUpdates.clear();
m_curUpdateModule = NULL;

m_isScoringEnabled = TRUE;
m_showBehindBuildingMarkers = TRUE;
Expand Down Expand Up @@ -1076,59 +1032,60 @@ void GameLogic::startNewGame( Bool saveGame )
}

m_rankLevelLimit = 1000; // this is reset every game.
setDefaults( saveGame );

//
// only reset the next object ID allocater counter when we're not loading a save game.
// for save games, we read this value out of the save game file and it is important
// that we preserve it as we load and execute the game
//
if( saveGame == FALSE )
m_nextObjID = (ObjectID)1;

TheWritableGlobalData->m_loadScreenRender = TRUE; ///< mark it so only a few select things are rendered during load
TheWritableGlobalData->m_TiVOFastMode = FALSE; //always disable the TIVO fast-forward mode at the start of a new game.

m_showBehindBuildingMarkers = TRUE;
m_drawIconUI = TRUE;
m_showDynamicLOD = TRUE;
m_scriptHulkMaxLifetimeOverride = -1;

// Fill in the game color and Factions before we do the Load Screen
GameInfo *game = NULL;
TheGameInfo = NULL;
Int localSlot = 0;
if (TheNetwork)
{
if (TheLAN)
{
DEBUG_LOG(("Starting network game"));
TheGameInfo = game = TheLAN->GetMyGame();
TheGameInfo = TheLAN->GetMyGame();
}
else
{
DEBUG_LOG(("Starting gamespy game"));
TheGameInfo = game = TheGameSpyGame; /// @todo: MDC add back in after demo
TheGameInfo = TheGameSpyGame; /// @todo: MDC add back in after demo
}
}
else
{
if (TheRecorder && TheRecorder->isPlaybackMode())
{
TheGameInfo = game = TheRecorder->getGameInfo();
TheGameInfo = TheRecorder->getGameInfo();
}
else if(m_gameMode == GAME_SKIRMISH)
{
TheGameInfo = game = TheSkirmishGameInfo;
TheGameInfo = TheSkirmishGameInfo;
}
}

checkForDuplicateColors( game );
checkForDuplicateColors( TheGameInfo );

Bool isSkirmishOrSkirmishReplay = FALSE;
if (game)
if (TheGameInfo)
{
for (Int i=0; i<MAX_SLOTS; ++i)
{
GameSlot *slot = game->getSlot(i);
GameSlot *slot = TheGameInfo->getSlot(i);
if (!saveGame) {
slot->saveOffOriginalInfo();
}
if (slot->isAI())
{
isSkirmishOrSkirmishReplay = TRUE;
continue;
}
}
} else {
Expand All @@ -1138,8 +1095,8 @@ void GameLogic::startNewGame( Bool saveGame )
}
}

populateRandomSideAndColor( game );
populateRandomStartPosition( game );
populateRandomSideAndColor( TheGameInfo );
populateRandomStartPosition( TheGameInfo );

//****************************//
// Start the LoadScreen Now! //
Expand All @@ -1152,7 +1109,7 @@ void GameLogic::startNewGame( Bool saveGame )
if(m_loadScreen && !TheGlobalData->m_headless)
{
TheMouse->setVisibility(FALSE);
m_loadScreen->init(game);
m_loadScreen->init(TheGameInfo);

updateLoadProgress( LOAD_PROGRESS_START );
}
Expand Down Expand Up @@ -1194,7 +1151,7 @@ void GameLogic::startNewGame( Bool saveGame )
#endif

Int progressCount = LOAD_PROGRESS_SIDE_POPULATION;
if (game)
if (TheGameInfo)
{

if (TheGameEngine->isMultiplayerSession() || isSkirmishOrSkirmishReplay)
Expand All @@ -1203,12 +1160,12 @@ void GameLogic::startNewGame( Bool saveGame )
TheSidesList->prepareForMP_or_Skirmish();
}

//DEBUG_LOG(("Starting LAN game with %d players", game->getNumPlayers()));
//DEBUG_LOG(("Starting LAN game with %d players", TheGameInfo->getNumPlayers()));
Dict d;
for (int i=0; i<MAX_SLOTS; ++i)
{
// Add a Side to TheSidesList
GameSlot *slot = game->getSlot(i);
GameSlot *slot = TheGameInfo->getSlot(i);

if (!slot || !slot->isHuman())
{
Expand All @@ -1235,7 +1192,7 @@ void GameLogic::startNewGame( Bool saveGame )
d.setAsciiString(TheKey_playerFaction, KEYNAME(pt->getNameKey()));
}

if (game->isPlayerPreorder(i))
if (TheGameInfo->isPlayerPreorder(i))
{
d.setBool(TheKey_playerIsPreorder, TRUE);
}
Expand All @@ -1245,7 +1202,7 @@ void GameLogic::startNewGame( Bool saveGame )
DEBUG_LOG(("Looking for allies of player %d, team %d", i, team));
for(int j=0; j < MAX_SLOTS; ++j)
{
GameSlot *teamSlot = game->getSlot(j);
GameSlot *teamSlot = TheGameInfo->getSlot(j);
// for check to see if we're trying to add ourselves
if(i == j || !teamSlot->isOccupied())
continue;
Expand Down Expand Up @@ -1299,7 +1256,7 @@ void GameLogic::startNewGame( Bool saveGame )
d.setInt(TheKey_multiplayerStartIndex, slot->getStartPos());
// d.setBool(TheKey_multiplayerIsLocal, slot->isLocalPlayer());
// d.setBool(TheKey_multiplayerIsLocal, slot->getIP() == game->getLocalIP());
d.setBool(TheKey_multiplayerIsLocal, slot->isHuman() && (slot->getName().compare(game->getSlot(game->getLocalSlotNum())->getName().str()) == 0));
d.setBool(TheKey_multiplayerIsLocal, slot->isHuman() && (slot->getName().compare(TheGameInfo->getSlot(TheGameInfo->getLocalSlotNum())->getName().str()) == 0));

/*
if (slot->getIP() == game->getLocalIP())
Expand All @@ -1322,7 +1279,7 @@ void GameLogic::startNewGame( Bool saveGame )

AsciiString slotNameAscii;
slotNameAscii.translate(slot->getName());
if (slot->isHuman() && game->getSlotNum(slotNameAscii) == game->getLocalSlotNum()) {
if (slot->isHuman() && TheGameInfo->getSlotNum(slotNameAscii) == TheGameInfo->getLocalSlotNum()) {
localSlot = i;
}
TheSidesList->addSide(&d);
Expand Down Expand Up @@ -1392,11 +1349,11 @@ void GameLogic::startNewGame( Bool saveGame )
// if there are no other teams (happens for debugging) don't end the game immediately
Int numTeams = 0; // this can be higher than expected, but is accurate for determining 0, 1, 2+
Int lastTeam = -1;
if (game)
if (TheGameInfo)
{
for (int i=0; i<MAX_SLOTS; ++i)
{
const GameSlot *slot = game->getConstSlot(i);
const GameSlot *slot = TheGameInfo->getConstSlot(i);
if (slot->isOccupied() && slot->getPlayerTemplate() != PLAYERTEMPLATE_OBSERVER)
{
if (slot->getTeamNumber() == -1 || slot->getTeamNumber() != lastTeam)
Expand Down Expand Up @@ -1625,11 +1582,11 @@ void GameLogic::startNewGame( Bool saveGame )
ThePartitionManager->revealMapForPlayerPermanently( observerPlayer->getPlayerIndex() );
DEBUG_LOG(("Reveal shroud for %ls whose index is %d", observerPlayer->getPlayerDisplayName().str(), observerPlayer->getPlayerIndex()));

if (game)
if (TheGameInfo)
{
for (int i=0; i<MAX_SLOTS; ++i)
{
GameSlot *slot = game->getSlot(i);
GameSlot *slot = TheGameInfo->getSlot(i);

if (!slot || !slot->isOccupied())
continue;
Expand Down Expand Up @@ -1763,11 +1720,11 @@ void GameLogic::startNewGame( Bool saveGame )

progressCount = LOAD_PROGRESS_LOOP_INITIAL_NETWORK_BUILDINGS;
// place initial network buildings/units
if (game && !saveGame)
if (TheGameInfo && !saveGame)
{
for (int i=0; i<MAX_SLOTS; ++i)
{
GameSlot *slot = game->getSlot(i);
GameSlot *slot = TheGameInfo->getSlot(i);

if (!slot || !slot->isOccupied())
continue;
Expand Down Expand Up @@ -1842,9 +1799,9 @@ void GameLogic::startNewGame( Bool saveGame )
// Note - We construct the multiplayer start spot name manually here, so change this if you
// change TheKey_Player_1_Start etc. mdc
AsciiString startingCamName = TheNameKeyGenerator->keyToName(TheKey_InitialCameraPosition);
if (game)
if (TheGameInfo)
{
GameSlot *slot = game->getSlot(localSlot);
GameSlot *slot = TheGameInfo->getSlot(localSlot);
DEBUG_ASSERTCRASH(slot, ("Starting a LAN game without ourselves!"));

if (slot->isHuman())
Expand Down
1 change: 0 additions & 1 deletion GeneralsMD/Code/GameEngine/Include/GameLogic/GameLogic.h
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,6 @@ class GameLogic : public SubsystemInterface, public Snapshot

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

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

void destroyAllObjectsImmediate(); ///< destroy, and process destroy list immediately
Expand Down
Loading
Loading