Merge branch 'fix-asserts' into 'master'

Fix PARANOIA compile

See merge request KartKrew/Kart!924
This commit is contained in:
toaster 2023-02-17 00:39:02 +00:00
commit e4459933cb
10 changed files with 38 additions and 18 deletions

View file

@ -1196,6 +1196,15 @@ const char *D_GetFancyBranchName(void)
return compbranch; return compbranch;
} }
static void Command_assert(void)
{
#if !defined(NDEBUG) || defined(PARANOIA)
CONS_Printf("Yes, assertions are enabled.\n");
#else
CONS_Printf("No, ssertions are NOT enabled.\n");
#endif
}
// //
// D_SRB2Main // D_SRB2Main
// //
@ -1387,6 +1396,8 @@ void D_SRB2Main(void)
// Do this up here so that WADs loaded through the command line can use ExecCfg // Do this up here so that WADs loaded through the command line can use ExecCfg
COM_Init(); COM_Init();
COM_AddCommand("assert", Command_assert);
#ifndef TESTERS #ifndef TESTERS
// add any files specified on the command line with -file wadfile // add any files specified on the command line with -file wadfile
// to the wad list // to the wad list

View file

@ -103,6 +103,14 @@ extern "C" {
//#define NOMD5 //#define NOMD5
// If you don't disable ALL debug first, you get ALL debug enabled
#if !defined (NDEBUG)
#define PACKETDROP
#define PARANOIA
#define RANGECHECK
#define ZDEBUG
#endif
// Uncheck this to compile debugging code // Uncheck this to compile debugging code
//#define RANGECHECK //#define RANGECHECK
//#ifndef PARANOIA //#ifndef PARANOIA

View file

@ -4236,7 +4236,7 @@ static void G_DoContinued(void)
{ {
player_t *pl = &players[consoleplayer]; player_t *pl = &players[consoleplayer];
I_Assert(!netgame && !multiplayer); I_Assert(!netgame && !multiplayer);
I_Assert(pl->continues > 0); //I_Assert(pl->continues > 0);
/*if (pl->continues) /*if (pl->continues)
pl->continues--;*/ pl->continues--;*/

View file

@ -537,8 +537,6 @@ static int pivotlist_get(lua_State *L)
spriteinfo_t *sprinfo = *((spriteinfo_t **)luaL_checkudata(L, 1, META_PIVOTLIST)); spriteinfo_t *sprinfo = *((spriteinfo_t **)luaL_checkudata(L, 1, META_PIVOTLIST));
UINT8 frame = GetPivotFrame(L, 2); UINT8 frame = GetPivotFrame(L, 2);
I_Assert(framepivot != NULL);
// bypass LUA_PushUserdata // bypass LUA_PushUserdata
container = lua_newuserdata(L, sizeof *container); container = lua_newuserdata(L, sizeof *container);
container->sprinfo = sprinfo; container->sprinfo = sprinfo;
@ -563,8 +561,6 @@ static int pivotlist_set(lua_State *L)
if (hook_cmd_running) if (hook_cmd_running)
return luaL_error(L, "Do not alter spriteframepivot_t in CMD building code!"); return luaL_error(L, "Do not alter spriteframepivot_t in CMD building code!");
I_Assert(pivotlist != NULL);
frame = GetPivotFrame(L, 2); frame = GetPivotFrame(L, 2);
// pivot[] is a table // pivot[] is a table

View file

@ -429,7 +429,7 @@ void M_AddRawCondition(UINT8 set, UINT8 id, conditiontype_t c, INT32 r, INT16 x1
condition_t *cond; condition_t *cond;
UINT32 num, wnum; UINT32 num, wnum;
I_Assert(set && set <= MAXCONDITIONSETS); I_Assert(set < MAXCONDITIONSETS);
wnum = conditionSets[set].numconditions; wnum = conditionSets[set].numconditions;
num = ++conditionSets[set].numconditions; num = ++conditionSets[set].numconditions;

View file

@ -11190,12 +11190,6 @@ void P_RemoveMobj(mobj_t *mobj)
P_SetTarget(&mobj->itnext, NULL); P_SetTarget(&mobj->itnext, NULL);
// DBG: set everything in mobj_t to 0xFF instead of leaving it. debug memory error.
#ifdef SCRAMBLE_REMOVED
// Invalidate mobj_t data to cause crashes if accessed!
memset((UINT8 *)mobj + sizeof(thinker_t), 0xff, sizeof(mobj_t) - sizeof(thinker_t));
#endif
P_RemoveThingTID(mobj); P_RemoveThingTID(mobj);
R_RemoveMobjInterpolator(mobj); R_RemoveMobjInterpolator(mobj);
@ -11215,6 +11209,12 @@ void P_RemoveMobj(mobj_t *mobj)
} }
P_RemoveThinker((thinker_t *)mobj); P_RemoveThinker((thinker_t *)mobj);
// DBG: set everything in mobj_t to 0xFF instead of leaving it. debug memory error.
#ifdef SCRAMBLE_REMOVED
// Invalidate mobj_t data to cause crashes if accessed!
memset((UINT8 *)mobj + sizeof(thinker_t), 0xff, sizeof(mobj_t) - sizeof(thinker_t));
#endif
} }
// This does not need to be added to Lua. // This does not need to be added to Lua.

View file

@ -3135,8 +3135,8 @@ static void P_NetArchiveThinkers(savebuffer_t *save)
continue; continue;
} }
#ifdef PARANOIA #ifdef PARANOIA
else if (th->function.acp1 != (actionf_p1)P_RemoveThinkerDelayed) // wait garbage collection else
I_Error("unknown thinker type %p", th->function.acp1); I_Assert(th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed); // wait garbage collection
#endif #endif
} }

View file

@ -234,7 +234,7 @@ void R_SetColumnFunc(size_t id, boolean brightmapped)
void R_SetSpanFunc(size_t id, boolean npo2, boolean brightmapped) void R_SetSpanFunc(size_t id, boolean npo2, boolean brightmapped)
{ {
I_Assert(id < COLDRAWFUNC_MAX); I_Assert(id < SPANDRAWFUNC_MAX);
if (spanfuncs_npo2[id] != NULL && npo2 == true) if (spanfuncs_npo2[id] != NULL && npo2 == true)
{ {

View file

@ -1700,7 +1700,10 @@ INT32 I_StartupSystem(void)
#endif #endif
I_StartupConsole(); I_StartupConsole();
#ifdef NEWSIGNALHANDLER #ifdef NEWSIGNALHANDLER
I_Fork(); // This is useful when debugging. It lets GDB attach to
// the correct process easily.
if (!M_CheckParm("-nofork"))
I_Fork();
#endif #endif
I_RegisterSignals(); I_RegisterSignals();
I_OutputMsg("Compiled for SDL version: %d.%d.%d\n", I_OutputMsg("Compiled for SDL version: %d.%d.%d\n",
@ -1993,9 +1996,10 @@ void I_ShutdownSystem(void)
{ {
INT32 c; INT32 c;
#ifndef NEWSIGNALHANDLER #ifdef NEWSIGNALHANDLER
I_ShutdownConsole(); if (M_CheckParm("-nofork"))
#endif #endif
I_ShutdownConsole();
for (c = MAX_QUIT_FUNCS-1; c >= 0; c--) for (c = MAX_QUIT_FUNCS-1; c >= 0; c--)
if (quit_funcs[c]) if (quit_funcs[c])

View file

@ -15,6 +15,7 @@
#define __Z_ZONE__ #define __Z_ZONE__
#include <stdio.h> #include <stdio.h>
#include "doomdef.h"
#include "doomtype.h" #include "doomtype.h"
#ifdef __cplusplus #ifdef __cplusplus