Add more clarity + check the length of the const_str enumeration and the length of the const string array to make sure they both match

This commit is contained in:
smallmodel 2024-09-19 21:23:19 +02:00
parent 0049348de5
commit 17d623bf85
No known key found for this signature in database
GPG key ID: 9F2D623CEDF08512
2 changed files with 11 additions and 6 deletions

View file

@ -399,12 +399,12 @@ const char *ScriptMaster::ConstStrings[] = {
"anim/no_anim_killed.scr",
"mg42",
"mp40",
// Added in 2.0
"auto",
"both",
// Added in 2.30
"runandshoot",
//
// Added in OPM
//
"respawn",
"viewmodelanim_done"
};
@ -525,8 +525,11 @@ void ScriptMaster::InitConstStrings(void)
const_str name;
unsigned int eventnum;
con_map_enum<Event *, EventDef> en;
int i;
for (int i = 0; i < sizeof(ConstStrings) / sizeof(ConstStrings[0]); i++) {
static_assert(ARRAY_LEN(ConstStrings) == (STRING_LENGTH_ - 1), "Constant strings don't match. Make sure the 'const_str' enum match with the 'ConstStrings' string array");
for (i = 0; i < ARRAY_LEN(ConstStrings); i++) {
AddString(ConstStrings[i]);
}

View file

@ -306,14 +306,16 @@ enum {
STRING_ANIM_NO_KILLED_SCR,
STRING_MG42,
STRING_MP40,
// Added in 2.0
STRING_AUTO,
STRING_BOTH,
// Added in 2.30
STRING_RUNANDSHOOT,
//
// Openmohaa additions
//
// Added in OPM
STRING_RESPAWN,
STRING_VIEWMODELANIM_DONE,
// The number of strings
STRING_LENGTH_
};