Skip to content

Commit b58d35b

Browse files
committed
Replicate in Generals
1 parent 54f63c2 commit b58d35b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+319
-216
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,10 @@ class BitFlags
5353
{
5454
private:
5555
std::bitset<NUMBITS> m_bits;
56-
static const char* s_bitNameList[];
5756

5857
public:
58+
CPP_11(static constexpr size_t NumBits = NUMBITS);
59+
static const char* const s_bitNameList[];
5960

6061
/*
6162
just a little syntactic sugar so that there is no "foo = 0" compatible constructor
@@ -261,7 +262,7 @@ class BitFlags
261262
return true;
262263
}
263264

264-
static const char** getBitNames()
265+
static const char* const* getBitNames()
265266
{
266267
return s_bitNameList;
267268
}
@@ -274,7 +275,7 @@ class BitFlags
274275
static Int getSingleBitFromName(const char* token)
275276
{
276277
Int i = 0;
277-
for(const char** name = s_bitNameList; *name; ++name, ++i )
278+
for(const char* const* name = s_bitNameList; *name; ++name, ++i )
278279
{
279280
if( stricmp( *name, token ) == 0 )
280281
{

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -186,20 +186,20 @@ enum
186186
// NOTE NOTE NOTE: Keep TheVeterencyNames in sync with these.
187187
enum VeterancyLevel CPP_11(: Int)
188188
{
189-
LEVEL_REGULAR = 0,
189+
LEVEL_REGULAR,
190190
LEVEL_VETERAN,
191191
LEVEL_ELITE,
192192
LEVEL_HEROIC,
193193

194194
LEVEL_COUNT,
195195
LEVEL_INVALID,
196196

197-
LEVEL_FIRST = LEVEL_REGULAR,
197+
LEVEL_FIRST = 0,
198198
LEVEL_LAST = LEVEL_HEROIC
199199
};
200200

201201
// TheVeterancyNames is defined in GameCommon.cpp
202-
extern const char *TheVeterancyNames[];
202+
extern const char *const TheVeterancyNames[];
203203

204204
//-------------------------------------------------------------------------------------------------
205205
//-------------------------------------------------------------------------------------------------
@@ -211,6 +211,7 @@ enum CommandSourceType CPP_11(: Int)
211211
CMD_FROM_AI,
212212
CMD_FROM_DOZER, // Special rare command when the dozer originates a command to attack a mine. Mines are not ai-attackable, and it seems deceitful for the dozer to generate a player or script command. jba.
213213

214+
COMMAND_SOURCE_TYPE_COUNT
214215
};
215216

216217
//-------------------------------------------------------------------------------------------------
@@ -478,14 +479,16 @@ inline Real stdAngleDiff(Real a1, Real a2)
478479
// NOTE NOTE NOTE: Keep TheRelationShipNames in sync with this enum
479480
enum Relationship CPP_11(: Int)
480481
{
481-
ENEMIES = 0,
482+
ENEMIES,
482483
NEUTRAL,
483-
ALLIES
484+
ALLIES,
485+
486+
RELATIONSHIP_COUNT
484487
};
485488

486489

487490
// TheRelationShipNames is defined in Common/GameCommon.cpp
488-
extern const char *TheRelationshipNames[];
491+
extern const char *const TheRelationshipNames[];
489492

490493
#endif // _GAMECOMMON_H_
491494

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ enum CpuType CPP_11(: Int)
6969
P3,
7070
P4,
7171
K7,
72+
73+
CPU_MAX
7274
};
7375

7476
//Keep this in sync with VideoNames in Gamelod.cpp

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,18 @@ class INI;
6767
//-------------------------------------------------------------------------------------------------
6868
enum TimeOfDay CPP_11(: Int)
6969
{
70-
TIME_OF_DAY_INVALID = 0,
71-
TIME_OF_DAY_FIRST = 1,
72-
TIME_OF_DAY_MORNING = TIME_OF_DAY_FIRST,
70+
TIME_OF_DAY_INVALID,
71+
72+
TIME_OF_DAY_MORNING,
7373
TIME_OF_DAY_AFTERNOON,
7474
TIME_OF_DAY_EVENING,
7575
TIME_OF_DAY_NIGHT,
7676

77-
TIME_OF_DAY_COUNT
77+
TIME_OF_DAY_COUNT,
78+
TIME_OF_DAY_FIRST = TIME_OF_DAY_MORNING,
7879
};
7980

80-
extern const char *TimeOfDayNames[];
81+
extern const char *const TimeOfDayNames[];
8182
// defined in Common/GameType.cpp
8283

8384
//-------------------------------------------------------------------------------------------------
@@ -89,7 +90,7 @@ enum Weather CPP_11(: Int)
8990
WEATHER_COUNT
9091
};
9192

92-
extern const char *WeatherNames[];
93+
extern const char *const WeatherNames[];
9394

9495
enum Scorches CPP_11(: Int)
9596
{

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,22 +48,23 @@ class INI;
4848
//-------------------------------------------------------------------------------------------------
4949
enum GeometryType CPP_11(: Int)
5050
{
51-
GEOMETRY_SPHERE = 0, ///< partition/collision testing as sphere. (majorRadius = radius)
51+
GEOMETRY_SPHERE, ///< partition/collision testing as sphere. (majorRadius = radius)
5252
GEOMETRY_CYLINDER, ///< partition/collision testing as cylinder. (majorRadius = radius, height = height)
5353
GEOMETRY_BOX, ///< partition/collision testing as rectangular box (majorRadius = half len in forward dir; minorRadius = half len in side dir; height = height)
5454

5555
GEOMETRY_NUM_TYPES,
56-
GEOMETRY_FIRST = GEOMETRY_SPHERE
56+
GEOMETRY_FIRST = 0
5757
};
5858

5959
#ifdef DEFINE_GEOMETRY_NAMES
60-
static const char *GeometryNames[] =
60+
static const char *const GeometryNames[] =
6161
{
6262
"SPHERE",
6363
"CYLINDER",
6464
"BOX",
6565
NULL
6666
};
67+
static_assert(ARRAY_SIZE(GeometryNames) == GEOMETRY_NUM_TYPES + 1, "Incorrect array size");
6768
#endif // end DEFINE_GEOMETRY_NAMES
6869

6970
//-------------------------------------------------------------------------------------------------

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,14 @@ enum
9191
/** Function typedef for parsing data block fields.
9292
*
9393
* buffer - the character buffer of the line from INI that we are reading and parsing
94-
* instance - instance of what we're loading (for example a thingtemplate instance)
94+
* instance - instance of what we're loading (for example a ThingTemplate instance)
9595
* store - where to store the data parsed, this is a field in the *instance* 'instance'
9696
*/
9797
//-------------------------------------------------------------------------------------------------
9898
typedef void (*INIFieldParseProc)( INI *ini, void *instance, void *store, const void* userData );
9999

100100
//-------------------------------------------------------------------------------------------------
101-
typedef const char* ConstCharPtr;
101+
typedef const char* const ConstCharPtr;
102102
typedef ConstCharPtr* ConstCharPtrArray;
103103

104104
//-------------------------------------------------------------------------------------------------

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@
4343
enum KindOfType CPP_11(: Int)
4444
{
4545
KINDOF_INVALID = -1,
46-
KINDOF_FIRST = 0,
47-
KINDOF_OBSTACLE = KINDOF_FIRST, ///< an obstacle to land-based pathfinders
46+
47+
KINDOF_OBSTACLE, ///< an obstacle to land-based pathfinders
4848
KINDOF_SELECTABLE, ///< Selectable
4949
KINDOF_IMMOBILE, ///< fixed in location
5050
KINDOF_CAN_ATTACK, ///< can attack
@@ -143,8 +143,8 @@ enum KindOfType CPP_11(: Int)
143143
KINDOF_IGNORES_SELECT_ALL, ///< Too late to figure out intelligently if something should respond to a Select All command
144144
KINDOF_DONT_AUTO_CRUSH_INFANTRY, ///< These units don't try to crush the infantry if ai.
145145

146-
KINDOF_COUNT // total number of kindofs
147-
146+
KINDOF_COUNT, // total number of kindofs
147+
KINDOF_FIRST = 0,
148148
};
149149

150150
typedef BitFlags<KINDOF_COUNT> KindOfMaskType;

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,11 @@ enum ModelConditionFlagType CPP_11(: Int)
9191
{
9292
MODELCONDITION_INVALID = -1,
9393

94-
MODELCONDITION_FIRST = 0,
95-
9694
//
9795
// Note: these values are saved in save files, so you MUST NOT REMOVE OR CHANGE
9896
// existing values!
9997
//
100-
MODELCONDITION_TOPPLED = MODELCONDITION_FIRST,
98+
MODELCONDITION_TOPPLED,
10199
MODELCONDITION_FRONTCRUSHED,
102100
MODELCONDITION_BACKCRUSHED,
103101
MODELCONDITION_DAMAGED,
@@ -214,7 +212,8 @@ enum ModelConditionFlagType CPP_11(: Int)
214212
// existing values!
215213
//
216214

217-
MODELCONDITION_COUNT
215+
MODELCONDITION_COUNT,
216+
MODELCONDITION_FIRST = 0,
218217
};
219218

220219
//-------------------------------------------------------------------------------------------------

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,14 @@ enum ScienceAvailabilityType CPP_11(: Int)
101101
};
102102

103103
#ifdef DEFINE_SCIENCE_AVAILABILITY_NAMES
104-
static const char *ScienceAvailabilityNames[] =
104+
static const char *const ScienceAvailabilityNames[] =
105105
{
106106
"Available",
107107
"Disabled",
108108
"Hidden",
109109
NULL
110110
};
111+
static_assert(ARRAY_SIZE(ScienceAvailabilityNames) == SCIENCE_AVAILABILITY_COUNT + 1, "Incorrect array size");
111112
#endif // end DEFINE_SCIENCE_AVAILABILITY_NAMES
112113

113114
static const Int NUM_HOTKEY_SQUADS = 10;

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ enum RadarPriorityType CPP_11(: Int)
145145
RADAR_PRIORITY_NUM_PRIORITIES
146146
};
147147
#ifdef DEFINE_RADAR_PRIORITY_NAMES
148-
static const char *RadarPriorityNames[] =
148+
static const char *const RadarPriorityNames[] =
149149
{
150150
"INVALID", // a priority that has not been set (in general it won't show up on the radar)
151151
"NOT_ON_RADAR", // object specifically forbidden from being on the radar
@@ -155,6 +155,7 @@ static const char *RadarPriorityNames[] =
155155

156156
NULL
157157
};
158+
static_assert(ARRAY_SIZE(RadarPriorityNames) == RADAR_PRIORITY_NUM_PRIORITIES + 1, "Incorrect array size");
158159
#endif // DEFINE_RADAR_PRIOTITY_NAMES
159160

160161
//-------------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)