From 80be424ecc9945fa1f0597037dfd553f36105f59 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 19 Jun 2026 18:31:14 +0200 Subject: [PATCH] add flag "COMPAT_VANILLA" undefine to enable features that are not vanilla compatible --- src/doomdef.h | 11 ++++++++++ src/p_mobj.c | 8 +++++++ src/p_setup.c | 61 +++++++++++++++++++++++++++++++++++++++++---------- src/p_spec.c | 2 ++ src/p_tick.c | 2 ++ 5 files changed, 72 insertions(+), 12 deletions(-) diff --git a/src/doomdef.h b/src/doomdef.h index 76d426665..565fb6997 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -602,6 +602,9 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; // None of these that are disabled in the normal build are guaranteed to work perfectly // Compile them at your own risk! +// undefine to enable fixes and features that are not vanilla compatible +#define COMPAT_VANILLA + //-- SATURN __ /// Detect if a client is on Saturn in the clientconfig. /// To seperately allow them to join or block joining from vanilla clients. @@ -666,6 +669,14 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; #undef UPDATE_ALERT #endif +// overwrite some of those +// when not compiling in vanilla compat mode +#ifndef COMPAT_VANILLA + #define SATURNJOIN + #define SATURNPAK + #undef SEENAMES +#endif + #ifdef __cplusplus } // extern "C" #endif diff --git a/src/p_mobj.c b/src/p_mobj.c index 27b076b4a..23fdc685b 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -11181,7 +11181,11 @@ void P_SpawnMapThing(mapthing_t *mthing) { if (mthing->type > MAXPLAYERS) // be wary of playerstarts size! playerstarts[MAXPLAYERS] { +#ifdef COMPAT_VANILLA CONS_Alert(CONS_ERROR, "Excess player start detected %d This will crash vanilla clients!\n", mthing->type); +#else + CONS_Debug(DBG_SETUP, "Excess player start detected %d\n", mthing->type); +#endif } else { @@ -11432,7 +11436,11 @@ void P_SpawnMapThing(mapthing_t *mthing) if (P_MobjWasRemoved(mobj)) { +#ifdef COMPAT_VANILLA CONS_Alert(CONS_ERROR, "Failed to spawn map thing #%d at %d, %d. This will crash vanilla clients!\n", mthing->type, x>>FRACBITS, y>>FRACBITS); +#else + CONS_Debug(DBG_SETUP, "Failed to spawn map thing #%d at %d, %d.\n", mthing->type, x>>FRACBITS, y>>FRACBITS); +#endif return; } diff --git a/src/p_setup.c b/src/p_setup.c index c20b50e1d..86869693c 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -448,12 +448,17 @@ static void P_LoadSegs(UINT8 *data) // http://www.doomworld.com/idgames/index.php?id=12647 if ((unsigned)v1 >= numvertexes || (unsigned)v2 >= numvertexes) { +#ifdef COMPAT_VANILLA if ((unsigned)v1 >= numvertexes) I_Error("P_LoadSegs: seg %s references a non-existent vertex %d\n", sizeu1(i), v1); if ((unsigned)v2 >= numvertexes) I_Error("P_LoadSegs: seg %s references a non-existent vertex %d\n", sizeu1(i), v2); +#else + if ((unsigned)v1 >= numvertexes) + CONS_Debug(DBG_SETUP, "P_LoadSegs: seg %s references a non-existent vertex %d\n", sizeu1(i), v1); + if ((unsigned)v2 >= numvertexes) + CONS_Debug(DBG_SETUP, "P_LoadSegs: seg %s references a non-existent vertex %d\n", sizeu1(i), v2); - /* if (li->sidedef == &sides[li->linedef->sidenum[0]]) { li->v1 = lines[ml->linedef].v1; @@ -464,7 +469,7 @@ static void P_LoadSegs(UINT8 *data) li->v1 = lines[ml->linedef].v2; li->v2 = lines[ml->linedef].v1; } - */ +#endif } else { @@ -502,8 +507,12 @@ static void P_LoadSegs(UINT8 *data) //e6y: fix wrong side index if (rawside != 0 && rawside != 1) { +#ifdef COMPAT_VANILLA I_Error("P_LoadSegs: seg %s contains wrong side index %d.\n", sizeu1(i), rawside); - //rawside = 1; +#else + rawside = 1; + CONS_Debug(DBG_SETUP, "P_LoadSegs: seg %s contains wrong side index %d.\n", sizeu1(i), rawside); +#endif } //e6y: check for wrong indexes @@ -521,8 +530,12 @@ static void P_LoadSegs(UINT8 *data) * referencing the back of a 1S line */ if (ldef->sidenum[rawside] == NO_INDEX) { +#ifdef COMPAT_VANILLA I_Error("P_LoadSegs: front of seg %s has no sidedef\n", sizeu1(i)); - //li->frontsector = 0; +#else + li->frontsector = NULL; + CONS_Debug(DBG_SETUP, "P_LoadSegs: front of seg %s has no sidedef\n", sizeu1(i)); +#endif } else { @@ -533,9 +546,16 @@ static void P_LoadSegs(UINT8 *data) { if (ldef->sidenum[rawside^1] == NO_INDEX) { +#ifdef COMPAT_VANILLA I_Error("P_LoadSegs: back of seg %s has no sidedef while being marked as double sided\n", sizeu1(i)); +#else + I_Error("P_LoadSegs: back of seg %s has no sidedef while being marked as double sided\n", sizeu1(i)); + + // FIXME: port GetSectorAtNullAddress // this is wrong //li->backsector = GetSectorAtNullAddress(); + //CONS_Debug(DBG_SETUP, "P_LoadSegs: back of seg %s has no sidedef while being marked as double sided\n", sizeu1(i)); +#endif } else { @@ -832,17 +852,25 @@ static void P_LoadNodes(UINT8 *data) // haleyjd 11/06/10: check for invalid subsector reference if (child >= numsubsectors) { +#ifdef COMPAT_VANILLA I_Error("P_LoadNodes: BSP tree %s references invalid subsector %d\n", sizeu1(i), child); - //child = 0; +#else + child = 0; + CONS_Debug(DBG_SETUP, "P_LoadNodes: BSP tree %s references invalid subsector %d\n", sizeu1(i), child); +#endif } child |= NF_SUBSECTOR; } else if (child >= numnodes) { +#ifdef COMPAT_VANILLA I_Error("P_LoadNodes: BSP node %s references invalid node.\n", sizeu1(i)); //I_Error("P_LoadNodes: BSP node %d references invalid node %d.\n", sizeu1(i), Index(((node_t *)no->children[j]))); - //child = 0; +#else + child = 0; + CONS_Debug(DBG_SETUP, "P_LoadNodes: BSP node %s references invalid node.\n", sizeu1(i)); +#endif } no->children[j] = child; @@ -1855,16 +1883,19 @@ static boolean P_LoadRawBlockMap(UINT8 *data, size_t count) // http://www.doomworld.com/idgames/index.php?id=12935 if (!P_VerifyBlockMap(count)) { +#ifdef COMPAT_VANILLA #ifdef PARANOIA I_Error("P_LoadBlockMap: erroneous BLOCKMAP lump may cause crashes.\n"); #endif CONS_Alert(CONS_ERROR, "P_LoadBlockMap: erroneous BLOCKMAP lump may cause crashes.\n"); - - //Z_Free(blockmaplump); - //blockmaplump = NULL; - //return false; // ideally we would just let the game rebuild the blockmap +#else + CONS_Debug(DBG_SETUP, "P_LoadBlockMap: corrupted or invalid BLOCKMAP lump!\nRebuilding...\n"); + Z_Free(blockmaplump); + blockmaplump = NULL; + return false; // ideally we would just let the game rebuild the blockmap // but this has a chance of desynching vanilla clients // not sure whats worse honestly and i do not want to decide that :chaosleep: +#endif } // clear out mobj chains @@ -2007,11 +2038,17 @@ static void P_LoadReject(UINT8 *data, size_t rejectsize) { if (rejectsize < neededsize) { +#ifdef COMPAT_VANILLA #ifdef PARANOIA - I_Error("REJECT is %s byte%s too small. REJECT might be invalid and crash vanilla clients!\n", sizeu1(neededsize - rejectsize), (neededsize - rejectsize) == 1 ? "" : "s"); + I_Error("P_LoadReject: REJECT is %s byte%s too small. REJECT might be invalid and crash vanilla clients!\n", sizeu1(neededsize - rejectsize), (neededsize - rejectsize) == 1 ? "" : "s"); #endif - CONS_Alert(CONS_ERROR, "REJECT is %s byte%s too small. REJECT might be invalid and crash vanilla clients!\n", sizeu1(neededsize - rejectsize), (neededsize - rejectsize) == 1 ? "" : "s"); + CONS_Alert(CONS_ERROR, "P_LoadReject: REJECT is %s byte%s too small. REJECT might be invalid and crash vanilla clients!\n", sizeu1(neededsize - rejectsize), (neededsize - rejectsize) == 1 ? "" : "s"); allocsize = neededsize; +#else + CONS_Debug(DBG_SETUP, "P_LoadReject: REJECT is %s byte%s too small and might be invalid, will not be loaded\n", sizeu1(neededsize - rejectsize), (neededsize - rejectsize) == 1 ? "" : "s"); + rejectmatrix = NULL; + return; +#endif } rejectmatrix = Z_Calloc(allocsize, PU_LEVEL, NULL); // allocate memory for the reject matrix diff --git a/src/p_spec.c b/src/p_spec.c index 25daf7f26..919abf48b 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -4609,11 +4609,13 @@ void P_UpdateSpecials(void) // POINT LIMIT P_CheckPointLimit(); +#ifdef COMPAT_VANILLA // Dynamic slopeness // we run this here only when not joined midrace // for vanilla compat reasons :chaosleep: if (!midgamejoin) P_RunDynamicSlopes(); +#endif P_UpdateAnimFlats(); } diff --git a/src/p_tick.c b/src/p_tick.c index 3692f9205..d0d25be69 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -646,7 +646,9 @@ void P_Ticker(boolean run) if (run) { // Dynamic slopeness +#ifdef COMPAT_VANILLA if (midgamejoin) // only run here if we joined midgame to fix some desynchs +#endif P_RunDynamicSlopes(); PS_START_TIMING(ps_thinkertime);