Skip to content
Open
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
3 changes: 2 additions & 1 deletion Core/GameEngine/Include/GameNetwork/GameInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class GameSlot
void setNATBehavior( FirewallHelperClass::FirewallBehaviorType NATBehavior) { m_NATBehavior = NATBehavior; }
FirewallHelperClass::FirewallBehaviorType getNATBehavior() const { return m_NATBehavior; }

void saveOffOriginalInfo();
Bool saveOffOriginalInfo();
Int getOriginalPlayerTemplate() const { return m_origPlayerTemplate; }
Int getOriginalColor() const { return m_origColor; }
Int getOriginalStartPos() const { return m_origStartPos; }
Expand Down Expand Up @@ -130,6 +130,7 @@ class GameSlot
Bool m_isAccepted;
Bool m_hasMap;
Bool m_isMuted;
Bool m_saveOffOriginalInfo;
Int m_color; ///< color, or -1 for random
Int m_startPos; ///< start position, or -1 for random
Int m_playerTemplate; ///< PlayerTemplate
Expand Down
25 changes: 17 additions & 8 deletions Core/GameEngine/Source/GameNetwork/GameInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,20 +70,29 @@ void GameSlot::reset()
m_disconnected = FALSE;
m_port = 0;
m_isMuted = FALSE;
m_saveOffOriginalInfo = TRUE;
m_origPlayerTemplate = -1;
m_origStartPos = -1;
m_origColor = -1;
}

void GameSlot::saveOffOriginalInfo()
Bool GameSlot::saveOffOriginalInfo()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this mean? saveOffOriginalInfo?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This probably won't be more informative than a quick glance at the code; it stores the original player color, position and faction, because those values may be overwritten if they're set to random.

{
DEBUG_LOG(("GameSlot::saveOffOriginalInfo() - orig was color=%d, pos=%d, house=%d",
m_origColor, m_origStartPos, m_origPlayerTemplate));
m_origPlayerTemplate = m_playerTemplate;
m_origStartPos = m_startPos;
m_origColor = m_color;
DEBUG_LOG(("GameSlot::saveOffOriginalInfo() - color=%d, pos=%d, house=%d",
m_color, m_startPos, m_playerTemplate));
if (m_saveOffOriginalInfo)
{
DEBUG_LOG(("GameSlot::saveOffOriginalInfo() - orig was color=%d, pos=%d, house=%d",
m_origColor, m_origStartPos, m_origPlayerTemplate));
m_origPlayerTemplate = m_playerTemplate;
m_origStartPos = m_startPos;
m_origColor = m_color;
DEBUG_LOG(("GameSlot::saveOffOriginalInfo() - color=%d, pos=%d, house=%d",
m_color, m_startPos, m_playerTemplate));

m_saveOffOriginalInfo = FALSE;
return TRUE;
}

return FALSE;
}

static Int getSlotIndex(const GameSlot *slot)
Expand Down
2 changes: 2 additions & 0 deletions GeneralsMD/Code/GameEngine/Include/GameLogic/GameLogic.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ enum GameMode CPP_11(: Int)
GAME_NONE
};

const char* gameModeToString(GameMode mode);

enum
{
CRC_CACHED,
Expand Down
35 changes: 34 additions & 1 deletion GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,30 @@ void setFPMode()
_controlfp(newVal, _MCW_PC | _MCW_RC);
}

//-------------------------------------------------------------------------------------------------
const char* gameModeToString(GameMode mode)
{
switch (mode)
{
case GAME_SINGLE_PLAYER:
return "GAME_SINGLE_PLAYER";
case GAME_LAN:
return "GAME_LAN";
case GAME_SKIRMISH:
return "GAME_SKIRMISH";
case GAME_REPLAY:
return "GAME_REPLAY";
case GAME_SHELL:
return "GAME_SHELL";
case GAME_INTERNET:
return "GAME_INTERNET";
case GAME_NONE:
return "GAME_NONE";
default:
return "GAME_UNKNOWN";
}
}

// ------------------------------------------------------------------------------------------------
/** GameLogic class constructor */
// ------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -1241,7 +1265,16 @@ void GameLogic::startNewGame( Bool loadingSaveGame )
{
GameSlot *slot = TheGameInfo->getSlot(i);
if (!loadingSaveGame) {
slot->saveOffOriginalInfo();
if (!slot->saveOffOriginalInfo())
{
DEBUG_ASSERTCRASH(m_gameMode == GAME_SKIRMISH, ("Expected GAME_SKIRMISH but got %s", gameModeToString(m_gameMode)));

// TheSuperHackers @fix Caball009 19/03/2026 Random color, position and faction are based on the logical seed. For improved determinism,
// restarted games now set the original values so that the games start with the exact same logical seed values as the first time.
slot->setColor(slot->getOriginalColor());
slot->setStartPos(slot->getOriginalStartPos());
slot->setPlayerTemplate(slot->getOriginalPlayerTemplate());
}
}
if (slot->isAI())
{
Expand Down
Loading