mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-01-19 07:51:43 +00:00
Move Dehacked table sanity check to deh_tables.c
This commit is contained in:
parent
d380405b2f
commit
205ccc2727
5 changed files with 28 additions and 25 deletions
|
@ -1072,7 +1072,7 @@ void D_SRB2Main(void)
|
|||
G_LoadGameSettings();
|
||||
|
||||
// Test Dehacked lists
|
||||
DEH_Check();
|
||||
DEH_TableCheck();
|
||||
|
||||
// Netgame URL special case: change working dir to EXE folder.
|
||||
ChangeDirForUrlHandler();
|
||||
|
|
|
@ -5457,3 +5457,27 @@ struct int_const_s const INT_CONST[] = {
|
|||
|
||||
{NULL,0}
|
||||
};
|
||||
|
||||
// For this to work compile-time without being in this file,
|
||||
// this function would need to check sizes at runtime, without sizeof
|
||||
void DEH_TableCheck(void)
|
||||
{
|
||||
#if defined(_DEBUG) || defined(PARANOIA)
|
||||
const size_t dehstates = sizeof(STATE_LIST)/sizeof(const char*);
|
||||
const size_t dehmobjs = sizeof(MOBJTYPE_LIST)/sizeof(const char*);
|
||||
const size_t dehpowers = sizeof(POWERS_LIST)/sizeof(const char*);
|
||||
const size_t dehcolors = sizeof(COLOR_ENUMS)/sizeof(const char*);
|
||||
|
||||
if (dehstates != S_FIRSTFREESLOT)
|
||||
I_Error("You forgot to update the Dehacked states list, you dolt!\n(%d states defined, versus %s in the Dehacked list)\n", S_FIRSTFREESLOT, sizeu1(dehstates));
|
||||
|
||||
if (dehmobjs != MT_FIRSTFREESLOT)
|
||||
I_Error("You forgot to update the Dehacked mobjtype list, you dolt!\n(%d mobj types defined, versus %s in the Dehacked list)\n", MT_FIRSTFREESLOT, sizeu1(dehmobjs));
|
||||
|
||||
if (dehpowers != NUMPOWERS)
|
||||
I_Error("You forgot to update the Dehacked powers list, you dolt!\n(%d powers defined, versus %s in the Dehacked list)\n", NUMPOWERS, sizeu1(dehpowers));
|
||||
|
||||
if (dehcolors != SKINCOLOR_FIRSTFREESLOT)
|
||||
I_Error("You forgot to update the Dehacked colors list, you dolt!\n(%d colors defined, versus %s in the Dehacked list)\n", SKINCOLOR_FIRSTFREESLOT, sizeu1(dehcolors));
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -72,4 +72,7 @@ extern const char *const MENUTYPES_LIST[];
|
|||
|
||||
extern struct int_const_s const INT_CONST[];
|
||||
|
||||
// Moved to this file because it can't work compile-time otherwise
|
||||
void DEH_TableCheck(void);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -645,25 +645,3 @@ void DEH_LoadDehackedLump(lumpnum_t lumpnum)
|
|||
{
|
||||
DEH_LoadDehackedLumpPwad(WADFILENUM(lumpnum),LUMPNUM(lumpnum), false);
|
||||
}
|
||||
|
||||
void DEH_Check(void)
|
||||
{
|
||||
#if defined(_DEBUG) || defined(PARANOIA)
|
||||
const size_t dehstates = sizeof(STATE_LIST)/sizeof(const char*);
|
||||
const size_t dehmobjs = sizeof(MOBJTYPE_LIST)/sizeof(const char*);
|
||||
const size_t dehpowers = sizeof(POWERS_LIST)/sizeof(const char*);
|
||||
const size_t dehcolors = sizeof(COLOR_ENUMS)/sizeof(const char*);
|
||||
|
||||
if (dehstates != S_FIRSTFREESLOT)
|
||||
I_Error("You forgot to update the Dehacked states list, you dolt!\n(%d states defined, versus %s in the Dehacked list)\n", S_FIRSTFREESLOT, sizeu1(dehstates));
|
||||
|
||||
if (dehmobjs != MT_FIRSTFREESLOT)
|
||||
I_Error("You forgot to update the Dehacked mobjtype list, you dolt!\n(%d mobj types defined, versus %s in the Dehacked list)\n", MT_FIRSTFREESLOT, sizeu1(dehmobjs));
|
||||
|
||||
if (dehpowers != NUMPOWERS)
|
||||
I_Error("You forgot to update the Dehacked powers list, you dolt!\n(%d powers defined, versus %s in the Dehacked list)\n", NUMPOWERS, sizeu1(dehpowers));
|
||||
|
||||
if (dehcolors != SKINCOLOR_FIRSTFREESLOT)
|
||||
I_Error("You forgot to update the Dehacked colors list, you dolt!\n(%d colors defined, versus %s in the Dehacked list)\n", SKINCOLOR_FIRSTFREESLOT, sizeu1(dehcolors));
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -30,8 +30,6 @@ typedef enum
|
|||
void DEH_LoadDehackedLump(lumpnum_t lumpnum);
|
||||
void DEH_LoadDehackedLumpPwad(UINT16 wad, UINT16 lump, boolean mainfile);
|
||||
|
||||
void DEH_Check(void);
|
||||
|
||||
fixed_t get_number(const char *word);
|
||||
FUNCPRINTF void deh_warning(const char *first, ...);
|
||||
void deh_strlcpy(char *dst, const char *src, size_t size, const char *warntext);
|
||||
|
|
Loading…
Reference in a new issue