Skip to content
Open
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
4 changes: 4 additions & 0 deletions Core/GameEngine/Include/Common/AudioEventInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ enum SoundType CPP_11(: Int)
ST_ALLIES = 0x0040,
ST_ENEMIES = 0x0080,
ST_EVERYONE = 0x0100,

SOUND_TYPE_END // keep after the last named flag

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming SOUND_TYPE_END is now 0x101, I don't know what that value signifies.

There are many _END additions to binary enums in this pr.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It marks the end of the flags

@Caball009 Caball009 Sep 29, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that's useful for regular enums, but not ones with binary values.

SOUND_TYPE_END == (ST_UI | ST_EVERYONE), so what's 'end' useful for here?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is used in static_assert:

static_assert(1 << (ARRAY_SIZE(theSoundTypeNames) - 2) == SOUND_TYPE_END - 1, "Incorrect array size");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, that looks a bit clunky to me, but it works.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes looks quite a bit unholy. I can wrap it into a helper function to simplify the call sites.

};

extern const char *const theAudioControlNames[];
Expand All @@ -80,6 +82,8 @@ enum AudioControl CPP_11(: Int)
AC_ALL = 0x0004,
AC_POSTDELAY = 0x0008,
AC_INTERRUPT = 0x0010,

AUDIO_CONTROL_END // keep after the last named flag
};

class DynamicAudioEventInfo;
Expand Down
2 changes: 1 addition & 1 deletion Core/GameEngine/Include/Common/Debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class AsciiString;
DEBUG_LEVEL_NET = 0, // in-game network
DEBUG_LEVEL_MAX
};
extern const char *TheDebugLevels[DEBUG_LEVEL_MAX];
extern const char *TheDebugLevels[];

#define DEBUG_LOG(m) do { { DebugLog m ; } } while (0) // Log message with trailing new line character (LF)
#define DEBUG_LOG_RAW(m) do { { DebugLogRaw m ; } } while (0) // Log message without trailing new line character (LF)
Expand Down
4 changes: 3 additions & 1 deletion Core/GameEngine/Include/Common/Dict.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ class Dict
DICT_INT,
DICT_REAL,
DICT_ASCIISTRING,
DICT_UNICODESTRING
DICT_UNICODESTRING,

DICT_TYPE_COUNT
};

/**
Expand Down
3 changes: 3 additions & 0 deletions Core/GameEngine/Include/GameClient/ControlBar.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ enum CommandOption CPP_11(: Int)
USES_MINE_CLEARING_WEAPONSET= 0x00200000, // uses the special mine-clearing weaponset, even if not current
CAN_USE_WAYPOINTS = 0x00400000, // button has option to use a waypoint path
MUST_BE_STOPPED = 0x00800000, // Unit must be stopped in order to be able to use button.

COMMAND_OPTION_END // keep after the last named flag
};

#ifdef DEFINE_COMMAND_OPTION_NAMES
Expand Down Expand Up @@ -135,6 +137,7 @@ static const char *const TheCommandOptionNames[] =

nullptr
};
static_assert(1 << (ARRAY_SIZE(TheCommandOptionNames) - 2) == COMMAND_OPTION_END - 1, "Incorrect array size");
#endif // end DEFINE_COMMAND_OPTION_NAMES

// convenient bit masks to group some command options together
Expand Down
1 change: 1 addition & 0 deletions Core/GameEngine/Include/GameClient/Gadget.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ enum
GWS_TAB_PANE = 0x00004000,
GWS_COMBO_BOX = 0x00008000,

GWS_END, // keep after the last named flag

GWS_ALL_SLIDER = GWS_VERT_SLIDER | GWS_HORZ_SLIDER, // for convenience

Expand Down
7 changes: 4 additions & 3 deletions Core/GameEngine/Include/GameClient/GameWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ enum WinInputReturnCode CPP_11(: Int)
enum
{

// when you edit this, remember to edit WindowStatusNames[]
WIN_STATUS_NONE = 0x00000000, // No status bits set at all
WIN_STATUS_ACTIVE = 0x00000001, // At the top of the window list
WIN_STATUS_TOGGLE = 0x00000002, // If set, click to toggle
Expand Down Expand Up @@ -181,9 +180,11 @@ enum
WIN_STATUS_FLASHING = 0x00800000, // Used for buttons that do cameo flashes.
WIN_STATUS_ALWAYS_COLOR = 0x01000000, // Never render these buttons using greyscale renderer when button disabled.
WIN_STATUS_ON_MOUSE_DOWN = 0x02000000, // Pushbutton triggers on mouse down.
WIN_STATUS_SHORTCUT_BUTTON = 0x04000000, // Oh god... this is a total hack for shortcut buttons to handle rendering text top left corner...
// when you edit this, remember to edit WindowStatusNames[]

WIN_STATUS_END, // keep after the last named flag

// Code only flags without a name in WindowStatusNames[]
WIN_STATUS_SHORTCUT_BUTTON = 0x04000000, // Oh god... this is a total hack for shortcut buttons to handle rendering text top left corner...
};


Expand Down
1 change: 1 addition & 0 deletions Core/GameEngine/Include/GameClient/GlobalLanguage.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class GlobalLanguage : public SubsystemInterface
ResolutionFontSizeMethod_Strict, // Uses a strict scaling method. Width and height are strictly bounded on upscales. Works well for accurate UI layouts and with large resolutions.
ResolutionFontSizeMethod_Balanced, // Uses a balanced scaling method. Width and height are evenly weighted for upscales. Works well for the original Game UI and with large resolutions.

ResolutionFontSizeMethod_Count,
ResolutionFontSizeMethod_Default = ResolutionFontSizeMethod_ClassicNoCeiling,
};

Expand Down
2 changes: 2 additions & 0 deletions Core/GameEngine/Include/GameClient/Image.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ typedef enum
IMAGE_STATUS_ROTATED_90_CLOCKWISE = 0x00000001, // image should be treated as rotated
IMAGE_STATUS_RAW_TEXTURE = 0x00000002, // image struct contains raw texture data

IMAGE_STATUS_END // keep after the last named flag
} ImageStatus;
#ifdef DEFINE_IMAGE_STATUS_NAMES
static const char *const imageStatusNames[] =
Expand All @@ -55,6 +56,7 @@ static const char *const imageStatusNames[] =
"RAW_TEXTURE",
nullptr
};
static_assert(1 << (ARRAY_SIZE(imageStatusNames) - 2) == IMAGE_STATUS_END - 1, "Incorrect array size");
#endif // end DEFINE_IMAGE_STATUS_NAMES

//-------------------------------------------------------------------------------------------------
Expand Down
4 changes: 4 additions & 0 deletions Core/GameEngine/Include/GameClient/MetaEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ static const LookupListRec CategoryListName[] =
{"DEBUG", CATEGORY_DEBUG},
{ nullptr, 0}
};
static_assert(ARRAY_SIZE(CategoryListName) == CATEGORY_NUM_CATEGORIES + 1, "Incorrect array size");


// -------------------------------------------------------------------------------
Expand Down Expand Up @@ -319,6 +320,8 @@ enum CommandUsableInType CPP_11(: Int)
COMMANDUSABLE_GAME = (1 << 1), // Command is usable when not in Shell
COMMANDUSABLE_OBSERVER = (1 << 2), // TheSuperHackers @feature Command is usable when observing

COMMAND_USABLE_IN_TYPE_END, // keep after the last named flag

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe name consistency needs looking at.


COMMANDUSABLE_EVERYWHERE = ~0,
};

Expand All @@ -330,6 +333,7 @@ static const char* const TheCommandUsableInNames[] =

nullptr
};
static_assert(1 << (ARRAY_SIZE(TheCommandUsableInNames) - 2) == COMMAND_USABLE_IN_TYPE_END - 1, "Incorrect array size");

// -------------------------------------------------------------------------------
class MetaMapRec : public MemoryPoolObject
Expand Down
2 changes: 1 addition & 1 deletion Core/GameEngine/Include/GameNetwork/GameSpy/PeerDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ enum GameSpyColors CPP_11(: Int) {
GSCOLOR_MAX
};

extern Color GameSpyColor[GSCOLOR_MAX];
extern Color GameSpyColor[];

enum GameSpyBuddyStatus CPP_11(: Int) {
BUDDY_OFFLINE,
Expand Down
2 changes: 2 additions & 0 deletions Core/GameEngine/Source/Common/INI/INIAudioEventInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ const char *const theSoundTypeNames[] =
"EVERYONE",
nullptr
};
static_assert(1 << (ARRAY_SIZE(theSoundTypeNames) - 2) == SOUND_TYPE_END - 1, "Incorrect array size");

const char *const theAudioControlNames[] =
{
Expand All @@ -213,4 +214,5 @@ const char *const theAudioControlNames[] =
"INTERRUPT",
nullptr
};
static_assert(1 << (ARRAY_SIZE(theAudioControlNames) - 2) == AUDIO_CONTROL_END - 1, "Incorrect array size");

3 changes: 2 additions & 1 deletion Core/GameEngine/Source/Common/System/Debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,10 @@ static DWORD theMainThreadID = 0;
char* TheCurrentIgnoreCrashPtr = nullptr;
#ifdef DEBUG_LOGGING
UnsignedInt DebugLevelMask = 0;
const char *TheDebugLevels[DEBUG_LEVEL_MAX] = {
const char *TheDebugLevels[] = {
"NET"
};
static_assert(ARRAY_SIZE(TheDebugLevels) == DEBUG_LEVEL_MAX, "Incorrect array size");
#endif

// ----------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions Core/GameEngine/Source/Common/System/Radar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -882,6 +882,7 @@ static RadarColorLookup radarColorLookupTable[] =
{ RADAR_EVENT_FAKE, { 0, 0, 0, 0 }, { 0, 0, 0, 0 } },
{ RADAR_EVENT_INVALID, { 0, 0, 0, 0 }, { 0, 0, 0, 0 } }
};
static_assert(ARRAY_SIZE(radarColorLookupTable) == RADAR_EVENT_NUM_EVENTS, "Incorrect array size");

//-------------------------------------------------------------------------------------------------
/** Create a new radar event */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ const char *const WindowStatusNames[] = { "ACTIVE", "TOGGLE", "DRAGABLE", "ENABL
"USE_OVERLAY_STATES", "NOT_READY", "FLASHING", "ALWAYS_COLOR",
"ON_MOUSE_DOWN", /*"SHORTCUT_BUTTON",*/
nullptr };
static_assert(1 << (ARRAY_SIZE(WindowStatusNames) - 2) == WIN_STATUS_END - 1, "Incorrect array size");

const char *const WindowStyleNames[] = { "PUSHBUTTON", "RADIOBUTTON", "CHECKBOX",
"VERTSLIDER", "HORZSLIDER", "SCROLLLISTBOX",
Expand All @@ -152,6 +153,7 @@ const char *const WindowStyleNames[] = { "PUSHBUTTON", "RADIOBUTTON", "CHECKBOX"
"TABSTOP", "TABCONTROL", "TABPANE",
"COMBOBOX",
nullptr };
static_assert(1 << (ARRAY_SIZE(WindowStyleNames) - 2) == GWS_END - 1, "Incorrect array size");

// Implement a stack to keep track of parent/child nested window descriptions.
static GameWindow *windowStack[ WIN_STACK_DEPTH ];
Expand Down
1 change: 1 addition & 0 deletions Core/GameEngine/Source/GameClient/GlobalLanguage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ static const LookupListRec ResolutionFontSizeMethodNames[] =
{ "BALANCED", GlobalLanguage::ResolutionFontSizeMethod_Balanced },
{ nullptr, 0 }
};
static_assert(ARRAY_SIZE(ResolutionFontSizeMethodNames) == GlobalLanguage::ResolutionFontSizeMethod_Count + 1, "Incorrect array size");

static const FieldParse TheGlobalLanguageDataFieldParseTable[] =
{
Expand Down
3 changes: 2 additions & 1 deletion Core/GameEngine/Source/GameClient/Input/Mouse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1266,7 +1266,7 @@ Int Mouse::getCursorIndex(const AsciiString& name)

/** @todo This is silly to have to define these names from INI in the code ...
* that should be changed (CBD) */
static const char *CursorININames[NUM_MOUSE_CURSORS] =
static const char *CursorININames[] =
{
//"InvalidMouseCursor", // this entry is not actually a mouse cursor, but just a
// reminder that it does exist
Expand Down Expand Up @@ -1323,6 +1323,7 @@ Int Mouse::getCursorIndex(const AsciiString& name)
"ParticleUplinkCannon",

};
static_assert(ARRAY_SIZE(CursorININames) == NUM_MOUSE_CURSORS, "Incorrect array size");

for (Int i=0; i<NUM_MOUSE_CURSORS; ++i)
{
Expand Down
3 changes: 2 additions & 1 deletion Core/GameEngine/Source/GameNetwork/ConnectionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ struct TransferFileRule
UnsignedInt maxSize;
};

static const TransferFileRule transferFileRules[TransferFileType_Count] =
static const TransferFileRule transferFileRules[] =
{
{ ".map", 5 * 1024 * 1024 },
{ ".ini", 2 * 1024 * 1024 },
Expand All @@ -113,6 +113,7 @@ static const TransferFileRule transferFileRules[TransferFileType_Count] =
{ ".tga", 2 * 1024 * 1024 },
{ ".wak", 128 * 1024 },
};
static_assert(ARRAY_SIZE(transferFileRules) == TransferFileType_Count, "Incorrect array size");

static TransferFileType getTransferFileType(const char* extension)
{
Expand Down
4 changes: 3 additions & 1 deletion Core/GameEngine/Source/GameNetwork/GameSpy/Chat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ static const FieldParse GameSpyColorFieldParse[] =
{ nullptr, nullptr, nullptr, 0 }

};
static_assert(ARRAY_SIZE(GameSpyColorFieldParse) == GSCOLOR_MAX + 1, "Incorrect array size");

void INI::parseOnlineChatColorDefinition( INI* ini )
{
Expand All @@ -81,7 +82,7 @@ void INI::parseOnlineChatColorDefinition( INI* ini )
}


Color GameSpyColor[GSCOLOR_MAX] =
Color GameSpyColor[] =
{
GameMakeColor(255,255,255,255), // GSCOLOR_DEFAULT
GameMakeColor(255,255, 0,255), // GSCOLOR_CURRENTROOM
Expand Down Expand Up @@ -119,6 +120,7 @@ Color GameSpyColor[GSCOLOR_MAX] =
GameMakeColor(255,255,255,255), // GSCOLOR_MOTD,
GameMakeColor(255,255, 0,255), // GSCOLOR_MOTD_HEADING,
};
static_assert(ARRAY_SIZE(GameSpyColor) == GSCOLOR_MAX, "Incorrect array size");

Bool GameSpyInfo::sendChat( UnicodeString message, Bool isAction, GameWindow *playerListbox )
{
Expand Down
3 changes: 2 additions & 1 deletion Core/GameEngine/Source/GameNetwork/GameSpyOverlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ void RaiseGSMessageBox()
* gsOverlays holds a list of the .wnd files used in GS overlays.
* The entries *MUST* be in the same order as the GSOverlayType enum.
*/
static const char * gsOverlays[GSOVERLAY_MAX] =
static const char * gsOverlays[] =
{
"Menus/PopupPlayerInfo.wnd", // Player info (right-click)
"Menus/WOLMapSelectMenu.wnd", // Map select
Expand All @@ -169,6 +169,7 @@ static const char * gsOverlays[GSOVERLAY_MAX] =
"Menus/PopupLocaleSelect.wnd",// Prompt for user's locale
"Menus/OptionsMenu.wnd", // popup options
};
static_assert(ARRAY_SIZE(gsOverlays) == GSOVERLAY_MAX, "Incorrect array size");

static WindowLayout *overlayLayouts[GSOVERLAY_MAX] =
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,12 +226,13 @@ void W3DDebrisDraw::doDrawModule(const Matrix3D* transformMtx)
}
m_renderObject->Set_Transform(*transformMtx);

static const RenderObjClass::AnimMode TheAnimModes[STATECOUNT] =
static const RenderObjClass::AnimMode TheAnimModes[] =
{
RenderObjClass::ANIM_MODE_ONCE,
RenderObjClass::ANIM_MODE_LOOP,
RenderObjClass::ANIM_MODE_ONCE
};
static_assert(ARRAY_SIZE(TheAnimModes) == STATECOUNT, "Incorrect array size");

Int oldState = m_state;
Object* obj = getDrawable()->getObject();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ inline Bool isCommonMaintainFrameFlagSet(Int a, Int b)
// Note: these values are saved in save files, so you MUST NOT REMOVE OR CHANGE
// existing values!
//
static const char *TerrainDecalTextureName[TERRAIN_DECAL_MAX]=
static const char *TerrainDecalTextureName[]=
{
#ifdef ALLOW_DEMORALIZE
"DM_RING",//demoralized
Expand All @@ -289,6 +289,7 @@ static const char *TerrainDecalTextureName[TERRAIN_DECAL_MAX]=
#endif
"" //dummy entry for TERRAIN_DECAL_SHADOW_TEXTURE
};
static_assert(ARRAY_SIZE(TerrainDecalTextureName) == TERRAIN_DECAL_MAX, "Incorrect array size");

const UnsignedInt NO_NEXT_DURATION = 0xffffffff;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,16 @@ struct waveInfo
const char *m_waveTypeName; //name of this wave type.
};

waveInfo waveTypeInfo[WaveTypeMax]=
waveInfo waveTypeInfo[]=
{
{28.0f, 18.0f, 25.0f, 0.018f, 900, 0.01f, 0.18f, 1500, 0,"wave256.tga","Pond"}, //pond
{55.0f, 36.0f, 80.0f, 0.015f, 2000, 0.5f, 0.18f, 1000, 6267,"wave256.tga","Ocean"}, //ocean
{55.0f, 36.0f, 80.0f, 0.015f, 2000, 0.05f, 0.18f, 1000, 6267,"wave256.tga","Close Ocean"},
{55.0f, 36.0f, 80.0f, 0.015f, 4000, 0.01f, 0.18f, 2000, 6267,"wave256.tga","Close Ocean Double"},
{55.0f, 27.0f, 80.0f, 0.015f, 2000, 0.01f, 8.0f, 2000, 5367,"wave256.tga","Radial"},
{0.0f, 0.0f, 0.0f, 0.0f, 0, 0.0f, 0.0f, 0, 0, nullptr, nullptr}, //stationary
};
static_assert(ARRAY_SIZE(waveTypeInfo) == WaveTypeMax, "Incorrect array size");

//=============================================================================
// WaterTracksObj::~WaterTracksObj
Expand Down
6 changes: 4 additions & 2 deletions Core/Libraries/Source/Compression/CompressionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

const char *CompressionManager::getCompressionNameByType( CompressionType compType )
{
static const char *s_compressionNames[COMPRESSION_MAX+1] = {
static const char *s_compressionNames[] = {
"No compression",
"RefPack",
"LZHL",
Expand All @@ -57,13 +57,14 @@ const char *CompressionManager::getCompressionNameByType( CompressionType compTy
"BTree",
"Huff",
};
static_assert(ARRAY_SIZE(s_compressionNames) == COMPRESSION_MAX + 1, "Incorrect array size");
return s_compressionNames[compType];
}

// For perf timers, so we can have separate ones for compression/decompression
const char *CompressionManager::getDecompressionNameByType( CompressionType compType )
{
static const char *s_decompressionNames[COMPRESSION_MAX+1] = {
static const char *s_decompressionNames[] = {
"d_None",
"d_RefPack",
"d_NoxLZW",
Expand All @@ -79,6 +80,7 @@ const char *CompressionManager::getDecompressionNameByType( CompressionType comp
"d_BTree",
"d_Huff",
};
static_assert(ARRAY_SIZE(s_decompressionNames) == COMPRESSION_MAX + 1, "Incorrect array size");
return s_decompressionNames[compType];
}

Expand Down
3 changes: 2 additions & 1 deletion Core/Libraries/Source/WWVegas/WW3D2/assetstatus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@

AssetStatusClass AssetStatusClass::Instance;

const char* ReportCategoryNames[AssetStatusClass::REPORT_COUNT]={
const char* ReportCategoryNames[]={
"LOAD_ON_DEMAND_ROBJ",
"LOAD_ON_DEMAND_HANIM",
"LOAD_ON_DEMAND_HTREE",
"MISSING_ROBJ",
"MISSING_HANIM",
"MISSING_HTREE"
};
static_assert(ARRAY_SIZE(ReportCategoryNames) == AssetStatusClass::REPORT_COUNT, "Incorrect array size");

AssetStatusClass::AssetStatusClass()
:
Expand Down
Loading
Loading