From bc6e530251d39ccbc20cfb01e558318445d10a8b Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 26 Dec 2025 18:49:38 +0100 Subject: [PATCH] Fixup the doomednum lookup properly match the old linear lookup by returning the FIRST match for doomednum also shrinks the array, doomednum max is 4095, no need for such massive array, also fixed a off by should fix some join desynchs and desynchs on certain maps --- src/d_netcmd.c | 2 -- src/info.h | 2 ++ src/p_local.h | 2 +- src/p_mobj.c | 15 +++++++++------ 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 38512cb78..b579e6848 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -4409,8 +4409,6 @@ static void Command_LocateLump_f(void) } } -#define MAXDOOMEDNUM 4095 - static void Command_ListDoomednums_f(void) { INT16 i, j, k = 0, l = 0; diff --git a/src/info.h b/src/info.h index 4ee851cee..c84d63214 100644 --- a/src/info.h +++ b/src/info.h @@ -19,6 +19,8 @@ #include "sounds.h" #include "m_fixed.h" +#define MAXDOOMEDNUM 4095 + // dehacked.c now has lists for the more named enums! PLEASE keep them up to date! // For great modding!! diff --git a/src/p_local.h b/src/p_local.h index 4efe7d824..bdc691932 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -272,7 +272,7 @@ extern consvar_t cv_gravity; void P_RespawnSpecials(void); -extern mobjtype_t g_doomednum_to_mobjtype[UINT16_MAX]; +extern mobjtype_t g_doomednum_to_mobjtype[MAXDOOMEDNUM+1]; void CalculateDoomednumToMobjtype(void); mobj_t *P_AllocateMobj(void); diff --git a/src/p_mobj.c b/src/p_mobj.c index 579e94066..c7f323299 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10588,17 +10588,20 @@ void P_PrecipitationEffects(void) } } -mobjtype_t g_doomednum_to_mobjtype[UINT16_MAX] = {}; +mobjtype_t g_doomednum_to_mobjtype[MAXDOOMEDNUM+1] = {}; void CalculateDoomednumToMobjtype(void) { memset(g_doomednum_to_mobjtype, MT_NULL, sizeof(g_doomednum_to_mobjtype)); - for (size_t i = MT_NULL+1; i < NUMMOBJTYPES; i++) + for (size_t i = 0; i < NUMMOBJTYPES; i++) { - if (mobjinfo[i].doomednum > 0 && mobjinfo[i].doomednum <= UINT16_MAX) + const INT32 doomednum = mobjinfo[i].doomednum; + + if (doomednum > 0 && doomednum <= MAXDOOMEDNUM) { - g_doomednum_to_mobjtype[ mobjinfo[i].doomednum ] = i; + if (g_doomednum_to_mobjtype[doomednum] == MT_NULL) + g_doomednum_to_mobjtype[doomednum] = (mobjtype_t)i; } } } @@ -10676,7 +10679,7 @@ void P_RespawnSpecials(void) if (mthing) { - mobjtype_t i; + mobjtype_t i = MT_NULL; x = mthing->x << FRACBITS; y = mthing->y << FRACBITS; ss = R_PointInSubsector(x, y); @@ -11093,7 +11096,7 @@ INT32 numhuntemeralds = 0; // void P_SpawnMapThing(mapthing_t *mthing) { - mobjtype_t i; + mobjtype_t i = MT_NULL; mobj_t *mobj; fixed_t x, y, z; subsector_t *ss;