diff --git a/src/p_local.h b/src/p_local.h index 12362a548..799f81a01 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -66,6 +66,10 @@ extern "C" { #define P_GetPlayerViewHeight(player) (41*player->mo->height/48) +#ifdef PARANOIA +#define SCRAMBLE_REMOVED // Force debug build to crash when Removed mobj is accessed +#endif + typedef enum { THINK_POLYOBJ, @@ -282,6 +286,9 @@ extern mapthing_t *itemrespawnque[ITEMQUESIZE]; extern tic_t itemrespawntime[ITEMQUESIZE]; extern size_t iquehead, iquetail; extern consvar_t cv_gravity, cv_movebob; +#ifdef SCRAMBLE_REMOVED +extern consvar_t cv_scrambleremoved; +#endif void P_RespawnBattleBoxes(void); mobjtype_t P_GetMobjtype(UINT16 mthingtype); diff --git a/src/p_mobj.c b/src/p_mobj.c index 80f413216..6e1c7b111 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -51,6 +51,8 @@ static CV_PossibleValue_t CV_BobSpeed[] = {{0, "MIN"}, {4*FRACUNIT, "MAX"}, {0, NULL}}; consvar_t cv_movebob = CVAR_INIT ("movebob", "1.0", CV_FLOAT|CV_SAVE, CV_BobSpeed, NULL); +consvar_t cv_scrambleremoved = CVAR_INIT ("scrambleremoved", "On", CV_NETVAR, CV_OnOff, NULL); + actioncache_t actioncachehead; static mobj_t *overlaycap = NULL; @@ -11059,9 +11061,6 @@ mapthing_t *itemrespawnque[ITEMQUESIZE]; tic_t itemrespawntime[ITEMQUESIZE]; size_t iquehead, iquetail; -#ifdef PARANOIA -#define SCRAMBLE_REMOVED // Force debug build to crash when Removed mobj is accessed -#endif void P_RemoveMobj(mobj_t *mobj) { I_Assert(mobj != NULL); @@ -11197,7 +11196,10 @@ void P_RemoveMobj(mobj_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)); + if (cv_scrambleremoved.value) + { + memset((UINT8 *)mobj + sizeof(thinker_t), 0xff, sizeof(mobj_t) - sizeof(thinker_t)); + } #endif } diff --git a/src/r_main.c b/src/r_main.c index b00717810..901942510 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1651,6 +1651,9 @@ void R_RegisterEngineStuff(void) CV_RegisterVar(&cv_maxportals); CV_RegisterVar(&cv_movebob); +#ifdef SCRAMBLE_REMOVED + CV_RegisterVar(&cv_scrambleremoved); +#endif // Frame interpolation/uncapped CV_RegisterVar(&cv_fpscap);