Skip to content

Commit 83c058f

Browse files
authored
[GEN][ZH] Refactor and clean up Command Line parsing (#1068)
1 parent 1b60047 commit 83c058f

File tree

10 files changed

+627
-779
lines changed

10 files changed

+627
-779
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@
3131
#ifndef _COMMAND_LINE_H_
3232
#define _COMMAND_LINE_H_
3333

34-
void parseCommandLine(int argc, char *argv[]); ///< Parse command-line parameters
34+
class CommandLine
35+
{
36+
public:
37+
38+
static void parseCommandLineForStartup();
39+
static void parseCommandLineForEngineInit();
40+
};
3541

3642
#endif // _COMMAND_LINE_H_

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

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
// FORWARD DECLARATIONS ///////////////////////////////////////////////////////////////////////////
4444
struct FieldParse;
4545
enum _TerrainLOD CPP_11(: Int);
46+
class CommandLine;
4647
class GlobalData;
4748
class INI;
4849
class WeaponBonusSet;
@@ -53,6 +54,21 @@ enum AIDebugOptions CPP_11(: Int);
5354

5455
const Int MAX_GLOBAL_LIGHTS = 3;
5556

57+
//-------------------------------------------------------------------------------------------------
58+
class CommandLineData
59+
{
60+
friend class CommandLine;
61+
friend class GlobalData;
62+
63+
CommandLineData()
64+
: m_hasParsedCommandLineForStartup(false)
65+
, m_hasParsedCommandLineForEngineInit(false)
66+
{}
67+
68+
Bool m_hasParsedCommandLineForStartup;
69+
Bool m_hasParsedCommandLineForEngineInit;
70+
};
71+
5672
//-------------------------------------------------------------------------------------------------
5773
/** Global data container class
5874
* Defines all global game data used by the system
@@ -67,9 +83,9 @@ class GlobalData : public SubsystemInterface
6783
GlobalData();
6884
virtual ~GlobalData();
6985

70-
void init();
71-
void reset();
72-
void update() { }
86+
virtual void init();
87+
virtual void reset();
88+
virtual void update() { }
7389

7490
Bool setTimeOfDay( TimeOfDay tod ); ///< Use this function to set the Time of day;
7591

@@ -87,6 +103,8 @@ class GlobalData : public SubsystemInterface
87103
//-----------------------------------------------------------------------------------------------
88104
//-----------------------------------------------------------------------------------------------
89105

106+
CommandLineData m_commandLineData;
107+
90108
AsciiString m_mapName; ///< hack for now, this whole this is going away
91109
AsciiString m_moveHintName;
92110
Bool m_useTrees;

0 commit comments

Comments
 (0)