Skip to content
Draft
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
2 changes: 2 additions & 0 deletions Core/GameEngine/Include/GameNetwork/GameInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,8 @@ class SkirmishGameInfo : public GameInfo, public Snapshot
for (Int i = 0; i< MAX_SLOTS; ++i)
setSlotPointer(i, &m_skirmishSlot[i]);
}

void handleOriginalSetups();
};

extern SkirmishGameInfo *TheSkirmishGameInfo;
Expand Down
20 changes: 20 additions & 0 deletions Core/GameEngine/Source/GameNetwork/GameInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1645,4 +1645,24 @@ void SkirmishGameInfo::loadPostProcess()
{
}

void SkirmishGameInfo::handleOriginalSetups()
{
// 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.

for (size_t i = 0; i < ARRAY_SIZE(m_skirmishSlot); ++i)
{
GameSlot& slot = m_skirmishSlot[i];

if (slot.hasSavedOriginalSetup())
{
slot.setColor(slot.getOriginalColor());
slot.setStartPos(slot.getOriginalStartPos());
slot.setPlayerTemplate(slot.getOriginalPlayerTemplate());
}
else
{
slot.saveOriginalSetup();
}
}
}
2 changes: 2 additions & 0 deletions GeneralsMD/Code/GameEngine/Source/Common/Recorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,8 @@ void RecorderClass::startRecording(GameDifficulty diff, Int originalGameMode, In
{
if(TheSkirmishGameInfo)
{
TheSkirmishGameInfo->handleOriginalSetups();

TheSkirmishGameInfo->setCRCInterval(REPLAY_CRC_INTERVAL);
theSlotList = GameInfoToAsciiString(TheSkirmishGameInfo);
DEBUG_LOG(("GameInfo String: %s",theSlotList.str()));
Expand Down
24 changes: 7 additions & 17 deletions GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1283,28 +1283,18 @@ void GameLogic::tryStartNewGame( Bool loadingSaveGame )
Bool isSkirmishOrSkirmishReplay = FALSE;
if (TheGameInfo)
{
for (Int i=0; i<MAX_SLOTS; ++i)
if (!loadingSaveGame && m_gameMode == GAME_SKIRMISH)
{
GameSlot *slot = TheGameInfo->getSlot(i);
if (!loadingSaveGame) {
if (slot->hasSavedOriginalSetup())
{
DEBUG_ASSERTCRASH(m_gameMode == GAME_SKIRMISH, ("Expected GAME_SKIRMISH but got %s", toString(m_gameMode)));
TheSkirmishGameInfo->handleOriginalSetups();
}

// 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());
}
else
{
slot->saveOriginalSetup();
}
}
for (Int i=0; i<MAX_SLOTS; ++i)
{
GameSlot* slot = TheGameInfo->getSlot(i);
if (slot->isAI())
{
isSkirmishOrSkirmishReplay = TRUE;
break;
}
}
} else {
Expand Down
Loading