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
This commit is contained in:
Alug committed 2025-12-26 18:58:27 +01:00
1 parent 9ff68cdf17
commit bc6e530251
4 files changed
+12 -9

No files matched your search

-2
View File
@@ -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;
+2
View File
@@ -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!!
+1 -1
View File
@@ -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);
+9 -6
View File
@@ -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;