Merge branch 'debugmode-reborn' into 'next'

Make DEBUGMODE=1 builds (finally) compile, run and work in netgames

See merge request STJr/SRB2!1405
This commit is contained in:
LJ Sonic 2021-02-26 17:43:45 -05:00
commit dc9b2443ce
7 changed files with 92 additions and 86 deletions

View file

@ -415,7 +415,7 @@ ifdef GCC48
else else
CFLAGS+=-O0 CFLAGS+=-O0
endif endif
CFLAGS+= -Wall -DPARANOIA -DRANGECHECK -DPACKETDROP -DMOBJCONSISTANCY CFLAGS+= -Wall -DPARANOIA -DRANGECHECK -DPACKETDROP
else else

View file

@ -4480,70 +4480,73 @@ static INT16 Consistancy(void)
ret += P_GetRandSeed(); ret += P_GetRandSeed();
#ifdef MOBJCONSISTANCY #ifdef MOBJCONSISTANCY
for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) if (gamestate == GS_LEVEL)
{ {
if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next)
continue;
mo = (mobj_t *)th;
if (mo->flags & (MF_SPECIAL | MF_SOLID | MF_PUSHABLE | MF_BOSS | MF_MISSILE | MF_SPRING | MF_MONITOR | MF_FIRE | MF_ENEMY | MF_PAIN | MF_STICKY))
{ {
ret -= mo->type; if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed)
ret += mo->x; continue;
ret -= mo->y;
ret += mo->z; mo = (mobj_t *)th;
ret -= mo->momx;
ret += mo->momy; if (mo->flags & (MF_SPECIAL | MF_SOLID | MF_PUSHABLE | MF_BOSS | MF_MISSILE | MF_SPRING | MF_MONITOR | MF_FIRE | MF_ENEMY | MF_PAIN | MF_STICKY))
ret -= mo->momz;
ret += mo->angle;
ret -= mo->flags;
ret += mo->flags2;
ret -= mo->eflags;
if (mo->target)
{ {
ret += mo->target->type; ret -= mo->type;
ret -= mo->target->x; ret += mo->x;
ret += mo->target->y; ret -= mo->y;
ret -= mo->target->z; ret += mo->z;
ret += mo->target->momx; ret -= mo->momx;
ret -= mo->target->momy; ret += mo->momy;
ret += mo->target->momz; ret -= mo->momz;
ret -= mo->target->angle; ret += mo->angle;
ret += mo->target->flags; ret -= mo->flags;
ret -= mo->target->flags2; ret += mo->flags2;
ret += mo->target->eflags; ret -= mo->eflags;
ret -= mo->target->state - states; if (mo->target)
ret += mo->target->tics; {
ret -= mo->target->sprite; ret += mo->target->type;
ret += mo->target->frame; ret -= mo->target->x;
ret += mo->target->y;
ret -= mo->target->z;
ret += mo->target->momx;
ret -= mo->target->momy;
ret += mo->target->momz;
ret -= mo->target->angle;
ret += mo->target->flags;
ret -= mo->target->flags2;
ret += mo->target->eflags;
ret -= mo->target->state - states;
ret += mo->target->tics;
ret -= mo->target->sprite;
ret += mo->target->frame;
}
else
ret ^= 0x3333;
if (mo->tracer && mo->tracer->type != MT_OVERLAY)
{
ret += mo->tracer->type;
ret -= mo->tracer->x;
ret += mo->tracer->y;
ret -= mo->tracer->z;
ret += mo->tracer->momx;
ret -= mo->tracer->momy;
ret += mo->tracer->momz;
ret -= mo->tracer->angle;
ret += mo->tracer->flags;
ret -= mo->tracer->flags2;
ret += mo->tracer->eflags;
ret -= mo->tracer->state - states;
ret += mo->tracer->tics;
ret -= mo->tracer->sprite;
ret += mo->tracer->frame;
}
else
ret ^= 0xAAAA;
ret -= mo->state - states;
ret += mo->tics;
ret -= mo->sprite;
ret += mo->frame;
} }
else
ret ^= 0x3333;
if (mo->tracer && mo->tracer->type != MT_OVERLAY)
{
ret += mo->tracer->type;
ret -= mo->tracer->x;
ret += mo->tracer->y;
ret -= mo->tracer->z;
ret += mo->tracer->momx;
ret -= mo->tracer->momy;
ret += mo->tracer->momz;
ret -= mo->tracer->angle;
ret += mo->tracer->flags;
ret -= mo->tracer->flags2;
ret += mo->tracer->eflags;
ret -= mo->tracer->state - states;
ret += mo->tracer->tics;
ret -= mo->tracer->sprite;
ret += mo->tracer->frame;
}
else
ret ^= 0xAAAA;
ret -= mo->state - states;
ret += mo->tics;
ret -= mo->sprite;
ret += mo->frame;
} }
} }
#endif #endif

View file

@ -1072,7 +1072,7 @@ void D_SRB2Main(void)
G_LoadGameSettings(); G_LoadGameSettings();
// Test Dehacked lists // Test Dehacked lists
DEH_Check(); DEH_TableCheck();
// Netgame URL special case: change working dir to EXE folder. // Netgame URL special case: change working dir to EXE folder.
ChangeDirForUrlHandler(); ChangeDirForUrlHandler();

View file

@ -5457,3 +5457,27 @@ struct int_const_s const INT_CONST[] = {
{NULL,0} {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
}

View file

@ -72,4 +72,7 @@ extern const char *const MENUTYPES_LIST[];
extern struct int_const_s const INT_CONST[]; 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 #endif

View file

@ -645,25 +645,3 @@ void DEH_LoadDehackedLump(lumpnum_t lumpnum)
{ {
DEH_LoadDehackedLumpPwad(WADFILENUM(lumpnum),LUMPNUM(lumpnum), false); 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
}

View file

@ -30,8 +30,6 @@ typedef enum
void DEH_LoadDehackedLump(lumpnum_t lumpnum); void DEH_LoadDehackedLump(lumpnum_t lumpnum);
void DEH_LoadDehackedLumpPwad(UINT16 wad, UINT16 lump, boolean mainfile); void DEH_LoadDehackedLumpPwad(UINT16 wad, UINT16 lump, boolean mainfile);
void DEH_Check(void);
fixed_t get_number(const char *word); fixed_t get_number(const char *word);
FUNCPRINTF void deh_warning(const char *first, ...); FUNCPRINTF void deh_warning(const char *first, ...);
void deh_strlcpy(char *dst, const char *src, size_t size, const char *warntext); void deh_strlcpy(char *dst, const char *src, size_t size, const char *warntext);