Skip to content

Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.

fix(gameengine): -file starts a map in release builds

Olcay Seygan83abace1dba4
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ea2d87563..259df864e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -187,6 +187,7 @@ found and fixed, EA's own, not port damage.**
- The "Mission Start" saves the campaign makes after each victory load again, from the original game and from every earlier version of Reforged. They hold only the campaign, the mission and the difficulty, none of which the 60-step battle changed. A game saved in the middle of a mission on an earlier version still does not load, and the message that refuses it now says which saves do.
- A mission with moving water (China's third, GLA's first, America's sixth) loads from a save with its water still running and at the height the mission had raised it to. A load used to freeze the water until the next wave came through and drop it back to the level the map started at, and saving while a script was raising it tore the game down.
- Load the same save twice and the same battle plays out both times. The dice, the paths units were waiting for and the computer players' calls to each other are saved now, so two loads no longer drift apart within a minute. A load also stopped switching a powered player's radar off, stopped forgetting which targets a mission's computer player was told to go after, and no longer counts every unit's sight twice for the first seconds. Saves from earlier versions still load; a save from this version does not load in an earlier one.
+- Zero Hour's second GLA mission leaves its opening scene again. The scene ends only when the three terrorists have blown up all three American tanks, and the tanks shoot at the tunnel the terrorists climb out of as they drive past it. From 3.2.0 to 3.4.0 a tank shell did its full 60 to a soldier, so two shells kill one: two shots at the tunnel took out two terrorists as they came out, the third was shot down on his way in, the tanks then wrecked the tunnel and the scene waited for ever. At 18 a shell the terrorists reach the tanks with 102 of their 120 health, and the scene hands you the controls on all three difficulties.
## Health bars you can read at a glance
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/CommandLine.cpp b/GeneralsMD/Code/GameEngine/Source/Common/CommandLine.cpp
index c2f7574e5..921f0cd14 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/CommandLine.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/CommandLine.cpp
@@ -768,6 +768,16 @@ Int parseBuildMapCache(char *args[], int)
return 1;
}
+Int parseFile(char *args[], int num)
+{
+ if (TheWritableGlobalData && num > 1)
+ {
+ TheWritableGlobalData->m_initialFile = args[1];
+ ConvertShortMapPathToLongMapPath(TheWritableGlobalData->m_initialFile);
+ }
+ return 2;
+}
+
#if defined(_DEBUG) || defined(_INTERNAL)
Int parseDisplayDebug(char *args[], int)
@@ -779,16 +789,6 @@ Int parseDisplayDebug(char *args[], int)
return 1;
}
-Int parseFile(char *args[], int num)
-{
- if (TheWritableGlobalData && num > 1)
- {
- TheWritableGlobalData->m_initialFile = args[1];
- ConvertShortMapPathToLongMapPath(TheWritableGlobalData->m_initialFile);
- }
- return 2;
-}
-
Int parsePreloadEverything( char *args[], int num )
{
@@ -2928,7 +2928,6 @@ static CommandLineParam params[] =
{ "-jabber", parseJabber },
{ "-munkee", parseMunkee },
{ "-displayDebug", parseDisplayDebug },
- { "-file", parseFile },
{ "-preloadEverything", parsePreloadEverything },
{ "-logAssets", parseLogAssets },
@@ -3026,6 +3025,9 @@ static CommandLineParam params[] =
{ "-takeover", parseTakeover },
{ "-replay", parseReplay },
{ "-loadsave", parseLoadSave },
+ // EA kept -file to Debug and Internal, so a Release run had no way into a campaign mission
+ // without clicking through the shell
+ { "-file", parseFile },
{ "-netgame", parseNetGame },
{ "-netslot", parseNetSlot },
{ "-netai", parseNetAI },
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp b/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp
index a5862e881..317fa08f3 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp
@@ -575,6 +575,10 @@ static AsciiString thePendingReplayFile;
that before init()'s resetAll() would have resetAll tear it straight back down again. */
static AsciiString thePendingSaveFile;
+/* -file <map>: a single player game on that map, queued after init()'s resetAll() as the replay
+ and the save are, so nothing the reset tears down is set up for it beforehand. */
+static AsciiString thePendingMapFile;
+
/** Open the save game -loadsave named, once every subsystem has been reset.
*
* This is doLoadGame() in PopupSaveLoad.cpp without the menu: prepare a single player game, load,
@@ -1430,17 +1434,7 @@ void GameEngine::init( int argc, char *argv[] )
{
TheWritableGlobalData->m_shellMapOn = FALSE;
TheWritableGlobalData->m_playIntro = FALSE;
- TheWritableGlobalData->m_pendingFile = TheGlobalData->m_initialFile;
-
- // shutdown the top, but do not pop it off the stack
- // TheShell->hideShell();
-
- // send a message to the logic for a new game
- GameMessage *msg = TheMessageStream->appendMessage( GameMessage::MSG_NEW_GAME );
- msg->appendIntegerArgument(GAME_SINGLE_PLAYER);
- msg->appendIntegerArgument(DIFFICULTY_NORMAL);
- msg->appendIntegerArgument(0);
- InitRandom(0);
+ thePendingMapFile = TheGlobalData->m_initialFile;
}
else if (fname.endsWithNoCase(".rep"))
{
@@ -1568,6 +1562,17 @@ void GameEngine::init( int argc, char *argv[] )
thePendingSaveFile.clear();
}
+ if (thePendingMapFile.isNotEmpty())
+ {
+ TheWritableGlobalData->m_pendingFile = thePendingMapFile;
+ GameMessage *msg = TheMessageStream->appendMessage( GameMessage::MSG_NEW_GAME );
+ msg->appendIntegerArgument( GAME_SINGLE_PLAYER );
+ msg->appendIntegerArgument( DIFFICULTY_NORMAL );
+ msg->appendIntegerArgument( 0 );
+ InitRandom( 0 );
+ thePendingMapFile.clear();
+ }
+
if (TheGlobalData->m_netGameHosts.isNotEmpty() && TheGlobalData->m_initialFile.isEmpty())
{
startAutoNetGame();