Skip to content

Commit 9da89ce

Browse files
authored
[GEN] Backport command line arguments from Zero Hour (#744)
1 parent bea27c1 commit 9da89ce

File tree

7 files changed

+225
-19
lines changed

7 files changed

+225
-19
lines changed

Generals/Code/GameEngine/Include/Common/CommandLine.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
** Command & Conquer Generals(tm)
2+
** Command & Conquer Generals Zero Hour(tm)
33
** Copyright 2025 Electronic Arts Inc.
44
**
55
** This program is free software: you can redistribute it and/or modify

Generals/Code/GameEngine/Include/Common/GlobalData.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ class GlobalData : public SubsystemInterface
326326
AsciiString m_shellMapName; ///< Holds the shell map name
327327
Bool m_shellMapOn; ///< User can set the shell map not to load
328328
Bool m_playIntro; ///< Flag to say if we're to play the intro or not
329+
Bool m_playSizzle; ///< Flag to say whether we play the sizzle movie after the logo movie.
329330
Bool m_afterIntro; ///< we need to tell the game our intro is done
330331
Bool m_allowExitOutOfMovies; ///< flag to allow exit out of movies only after the Intro has played
331332

@@ -480,6 +481,7 @@ class GlobalData : public SubsystemInterface
480481
Int m_latencyPeriod; ///< Period of sinusoidal modulation of latency
481482
Int m_latencyNoise; ///< Max amplitude of jitter to throw in
482483
Int m_packetLoss; ///< Percent of packets to drop
484+
Bool m_extraLogging; ///< More expensive debug logging to catch crashes.
483485
#endif
484486

485487
#ifdef DEBUG_CRASHING

Generals/Code/GameEngine/Source/Common/CommandLine.cpp

Lines changed: 106 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
** Command & Conquer Generals(tm)
2+
** Command & Conquer Generals Zero Hour(tm)
33
** Copyright 2025 Electronic Arts Inc.
44
**
55
** This program is free software: you can redistribute it and/or modify
@@ -34,6 +34,14 @@
3434
#include "GameClient/GameText.h"
3535
#include "GameNetwork/NetworkDefs.h"
3636

37+
#ifdef _INTERNAL
38+
// for occasional debugging...
39+
//#pragma optimize("", off)
40+
//#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes")
41+
#endif
42+
43+
44+
3745
Bool TheDebugIgnoreSyncErrors = FALSE;
3846
extern Int DX8Wrapper_PreserveFPU;
3947

@@ -644,7 +652,18 @@ Int parseBuildMapCache(char *args[], int)
644652
return 1;
645653
}
646654

647-
#if defined(_DEBUG) || defined(_INTERNAL)
655+
656+
#if defined(_DEBUG) || defined(_INTERNAL) || defined(_ALLOW_DEBUG_CHEATS_IN_RELEASE)
657+
Int parsePreload( char *args[], int num )
658+
{
659+
if( TheWritableGlobalData )
660+
TheWritableGlobalData->m_preloadAssets = TRUE;
661+
return 1;
662+
}
663+
#endif
664+
665+
666+
#if defined(_DEBUG) || defined(_INTERNAL)
648667
Int parseDisplayDebug(char *args[], int)
649668
{
650669
if (TheWritableGlobalData)
@@ -664,12 +683,6 @@ Int parseFile(char *args[], int num)
664683
return 2;
665684
}
666685

667-
Int parsePreload( char *args[], int num )
668-
{
669-
if( TheWritableGlobalData )
670-
TheWritableGlobalData->m_preloadAssets = TRUE;
671-
return 1;
672-
}
673686

674687
Int parsePreloadEverything( char *args[], int num )
675688
{
@@ -777,18 +790,37 @@ Int parseNoShellMap(char *args[], int)
777790
return 1;
778791
}
779792

793+
Int parseNoShaders(char *args[], int)
794+
{
795+
if (TheWritableGlobalData)
796+
{
797+
TheWritableGlobalData->m_chipSetType = 1; //force to a voodoo card which uses least amount of features.
798+
}
799+
return 1;
800+
}
801+
780802
#if (defined(_DEBUG) || defined(_INTERNAL))
781803
Int parseNoLogo(char *args[], int)
782804
{
783805
if (TheWritableGlobalData)
784806
{
785807
TheWritableGlobalData->m_playIntro = FALSE;
786808
TheWritableGlobalData->m_afterIntro = TRUE;
809+
TheWritableGlobalData->m_playSizzle = FALSE;
787810
}
788811
return 1;
789812
}
790813
#endif
791814

815+
Int parseNoSizzle( char *args[], int )
816+
{
817+
if (TheWritableGlobalData)
818+
{
819+
TheWritableGlobalData->m_playSizzle = FALSE;
820+
}
821+
return 1;
822+
}
823+
792824
Int parseShellMap(char *args[], int num)
793825
{
794826
if (TheWritableGlobalData && num > 1)
@@ -820,6 +852,10 @@ Int parseQuickStart( char *args[], int num )
820852
{
821853
#if (defined(_DEBUG) || defined(_INTERNAL))
822854
parseNoLogo( args, num );
855+
#else
856+
//Kris: Patch 1.01 -- Allow release builds to skip the sizzle video, but still force the EA logo to show up.
857+
//This is for legal reasons.
858+
parseNoSizzle( args, num );
823859
#endif
824860
parseNoShellMap( args, num );
825861
parseNoWindowAnimation( args, num );
@@ -835,6 +871,29 @@ Int parseConstantDebug( char *args[], int num )
835871
return 1;
836872
}
837873

874+
#if (defined(_DEBUG) || defined(_INTERNAL))
875+
Int parseExtraLogging( char *args[], int num )
876+
{
877+
if (TheWritableGlobalData)
878+
{
879+
TheWritableGlobalData->m_extraLogging = TRUE;
880+
}
881+
return 1;
882+
}
883+
#endif
884+
885+
//-allAdvice feature
886+
/*
887+
Int parseAllAdvice( char *args[], int num )
888+
{
889+
if( TheWritableGlobalData )
890+
{
891+
TheWritableGlobalData->m_allAdvice = TRUE;
892+
}
893+
return 1;
894+
}
895+
*/
896+
838897
Int parseShowTeamDot( char *args[], int num )
839898
{
840899
if( TheWritableGlobalData )
@@ -973,6 +1032,20 @@ Int parseBenchmark(char *args[], int num)
9731032
}
9741033
#endif
9751034

1035+
#if defined(_DEBUG) || defined(_INTERNAL)
1036+
#ifdef DUMP_PERF_STATS
1037+
Int parseStats(char *args[], int num)
1038+
{
1039+
if (TheWritableGlobalData && num > 1)
1040+
{
1041+
TheWritableGlobalData->m_dumpStatsAtInterval = TRUE;
1042+
TheWritableGlobalData->m_statsInterval = atoi(args[1]);
1043+
}
1044+
return 2;
1045+
}
1046+
#endif
1047+
#endif
1048+
9761049
#ifdef DEBUG_CRASHING
9771050
Int parseIgnoreAsserts(char *args[], int num)
9781051
{
@@ -1056,14 +1129,14 @@ Int parseMod(char *args[], Int num)
10561129
}
10571130

10581131
// now check for dir-ness
1059-
struct stat statBuf;
1060-
if (stat(modPath.str(), &statBuf) != 0)
1132+
struct _stat statBuf;
1133+
if (_stat(modPath.str(), &statBuf) != 0)
10611134
{
10621135
DEBUG_LOG(("Could not _stat() mod.\n"));
10631136
return 2; // could not stat the file/dir.
10641137
}
10651138

1066-
if (statBuf.st_mode & S_IFDIR)
1139+
if (statBuf.st_mode & _S_IFDIR)
10671140
{
10681141
if (!modPath.endsWith("\\") && !modPath.endsWith("/"))
10691142
modPath.concat('\\');
@@ -1129,6 +1202,9 @@ static CommandLineParam params[] =
11291202
{ "-scriptDebug", parseScriptDebug },
11301203
{ "-playStats", parsePlayStats },
11311204
{ "-mod", parseMod },
1205+
{ "-noshaders", parseNoShaders },
1206+
{ "-quickstart", parseQuickStart },
1207+
11321208
#if (defined(_DEBUG) || defined(_INTERNAL))
11331209
{ "-noaudio", parseNoAudio },
11341210
{ "-map", parseMapName },
@@ -1137,7 +1213,10 @@ static CommandLineParam params[] =
11371213
{ "-noLogOrCrash", parseNoLogOrCrash },
11381214
{ "-FPUPreserve", parseFPUPreserve },
11391215
{ "-benchmark", parseBenchmark },
1140-
{ "-saveStats", parseSaveStats },
1216+
#ifdef DUMP_PERF_STATS
1217+
{ "-stats", parseStats },
1218+
#endif
1219+
{ "-saveStats", parseSaveStats },
11411220
{ "-localMOTD", parseLocalMOTD },
11421221
{ "-UseCSF", parseUseCSF },
11431222
{ "-NoInputDisable", parseNoInputDisable },
@@ -1218,8 +1297,10 @@ static CommandLineParam params[] =
12181297
{ "-munkee", parseMunkee },
12191298
{ "-displayDebug", parseDisplayDebug },
12201299
{ "-file", parseFile },
1221-
{ "-preload", parsePreload },
1222-
{ "-preloadEverything", parsePreloadEverything },
1300+
1301+
// { "-preload", parsePreload },
1302+
1303+
{ "-preloadEverything", parsePreloadEverything },
12231304
{ "-logAssets", parseLogAssets },
12241305
{ "-netMinPlayers", parseNetMinPlayers },
12251306
{ "-DemoLoadScreen", parseDemoLoadScreen },
@@ -1239,14 +1320,15 @@ static CommandLineParam params[] =
12391320
{ "-noShellAnim", parseNoWindowAnimation },
12401321
{ "-winCursors", parseWinCursors },
12411322
{ "-constantDebug", parseConstantDebug },
1242-
{ "-quickstart", parseQuickStart },
12431323
{ "-seed", parseSeed },
12441324
{ "-noagpfix", parseIncrAGPBuf },
12451325
{ "-noFPSLimit", parseNoFPSLimit },
12461326
{ "-dumpAssetUsage", parseDumpAssetUsage },
12471327
{ "-jumpToFrame", parseJumpToFrame },
12481328
{ "-updateImages", parseUpdateImages },
12491329
{ "-showTeamDot", parseShowTeamDot },
1330+
{ "-extraLogging", parseExtraLogging },
1331+
12501332
#endif
12511333

12521334
#ifdef DEBUG_LOGGING
@@ -1261,6 +1343,15 @@ static CommandLineParam params[] =
12611343
#ifdef DEBUG_STACKTRACE
12621344
{ "-ignoreStackTrace", parseIgnoreStackTrace },
12631345
#endif
1346+
1347+
//-allAdvice feature
1348+
//{ "-allAdvice", parseAllAdvice },
1349+
1350+
#if defined(_DEBUG) || defined(_INTERNAL) || defined(_ALLOW_DEBUG_CHEATS_IN_RELEASE)
1351+
{ "-preload", parsePreload },
1352+
#endif
1353+
1354+
12641355
};
12651356

12661357
// parseCommandLine ===========================================================

Generals/Code/GameEngine/Source/Common/GlobalData.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,7 @@ GlobalData* GlobalData::m_theOriginal = NULL;
518518
{ "UseLocalMOTD", INI::parseBool, NULL, offsetof( GlobalData, m_useLocalMOTD ) },
519519
{ "BaseStatsDir", INI::parseAsciiString,NULL, offsetof( GlobalData, m_baseStatsDir ) },
520520
{ "LocalMOTDPath", INI::parseAsciiString,NULL, offsetof( GlobalData, m_MOTDPath ) },
521+
{ "ExtraLogging", INI::parseBool, NULL, offsetof(GlobalData, m_extraLogging) },
521522
#endif
522523

523524
{ NULL, NULL, NULL, 0 } // keep this last
@@ -581,6 +582,7 @@ GlobalData::GlobalData()
581582
m_useLocalMOTD = FALSE;
582583
m_baseStatsDir = ".\\";
583584
m_MOTDPath = "MOTD.txt";
585+
m_extraLogging = FALSE;
584586
#endif
585587

586588
#ifdef DEBUG_CRASHING
@@ -957,6 +959,7 @@ GlobalData::GlobalData()
957959
m_shellMapName.set("Maps\\ShellMap1\\ShellMap1.map");
958960
m_shellMapOn =TRUE;
959961
m_playIntro = TRUE;
962+
m_playSizzle = TRUE;
960963
m_afterIntro = FALSE;
961964
m_allowExitOutOfMovies = FALSE;
962965
m_loadScreenRender = FALSE;

Generals/Code/GameEngine/Source/GameClient/GameClient.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ void GameClient::update( void )
514514
//Initial Game Codition. We must show the movie first and then we can display the shell
515515
if(TheGlobalData->m_afterIntro && !TheDisplay->isMoviePlaying())
516516
{
517-
if( playSizzle)
517+
if( playSizzle && TheGlobalData->m_playSizzle)
518518
{
519519
TheWritableGlobalData->m_allowExitOutOfMovies = TRUE;
520520
if(TheGameLODManager && TheGameLODManager->didMemPass())

Generals/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -852,6 +852,14 @@ AsciiString AIStateMachine::getCurrentStateName(void) const
852852
*/
853853
StateReturnType AIStateMachine::updateStateMachine()
854854
{
855+
//-extraLogging
856+
#if (defined(_DEBUG) || defined(_INTERNAL))
857+
Bool idle = getOwner()->getAI()->isIdle();
858+
if (!idle && TheGlobalData->m_extraLogging)
859+
DEBUG_LOG(("%d - %s::update() start - %s", TheGameLogic->getFrame(), getCurrentStateName().str(), getOwner()->getTemplate()->getName().str()));
860+
#endif
861+
//end -extraLogging
862+
855863
if (m_temporaryState)
856864
{
857865
// execute this state
@@ -862,13 +870,48 @@ StateReturnType AIStateMachine::updateStateMachine()
862870
status = STATE_SUCCESS;
863871
}
864872
}
865-
if (status==STATE_CONTINUE) {
873+
if (status==STATE_CONTINUE)
874+
{
875+
//-extraLogging
876+
#if (defined(_DEBUG) || defined(_INTERNAL))
877+
if (!idle && TheGlobalData->m_extraLogging)
878+
DEBUG_LOG((" - RETURN EARLY STATE_CONTINUE\n"));
879+
#endif
880+
//end -extraLogging
866881
return status;
867882
}
868883
m_temporaryState->onExit(EXIT_NORMAL);
869884
m_temporaryState = NULL;
870885
}
871-
return StateMachine::updateStateMachine();
886+
StateReturnType retType = StateMachine::updateStateMachine();
887+
888+
//-extraLogging
889+
#if (defined(_DEBUG) || defined(_INTERNAL))
890+
AsciiString result;
891+
if (TheGlobalData->m_extraLogging)
892+
{
893+
switch (retType)
894+
{
895+
case STATE_CONTINUE:
896+
result.format("CONTINUE");
897+
break;
898+
case STATE_SUCCESS:
899+
result.format("SUCCESS");
900+
break;
901+
case STATE_FAILURE:
902+
result.format("FAILURE");
903+
break;
904+
default:
905+
result.format("UNKNOWN %d", retType);
906+
break;
907+
}
908+
if (!idle)
909+
DEBUG_LOG((" - RETURNING %s\n", result.str()));
910+
}
911+
#endif
912+
//end -extraLogging
913+
914+
return retType;
872915
}
873916

874917
//----------------------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)