From 34f8464cbfc01adf1650da1311a0751fce5b0678 Mon Sep 17 00:00:00 2001 From: SteelT Date: Wed, 2 Mar 2022 12:35:03 -0500 Subject: [PATCH 1/2] Spawn MT_RAY when attempting to spawn MT_NULL Some code assumes that P_SpawnMobj can never return NULL So spawn MT_RAY in it's place when attempting to spawn MT_NULL and show a console warning --- src/p_mobj.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/p_mobj.c b/src/p_mobj.c index 04e02f847..e8fd5fd13 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10474,10 +10474,17 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) if (type == MT_NULL) { +#if 0 #ifdef PARANOIA I_Error("Tried to spawn MT_NULL\n"); #endif return NULL; +#endif + // Hack: Some code assumes that P_SpawnMobj can never return NULL + // So replace MT_NULL with MT_RAY in the meantime + // Remove when dealt properly + CONS_Alert(CONS_WARNING, "Tried to spawn MT_NULL, using MT_RAY\n"); + type = MT_RAY; } mobj = Z_Calloc(sizeof (*mobj), PU_LEVEL, NULL); From 893ea10a677274b8cb3aa0987f22f162521b6311 Mon Sep 17 00:00:00 2001 From: SteelT Date: Wed, 2 Mar 2022 12:46:24 -0500 Subject: [PATCH 2/2] Turn the console warning into a devmode print because turns out it happens more often than I thought --- src/p_mobj.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index e8fd5fd13..96683a123 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10483,7 +10483,7 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) // Hack: Some code assumes that P_SpawnMobj can never return NULL // So replace MT_NULL with MT_RAY in the meantime // Remove when dealt properly - CONS_Alert(CONS_WARNING, "Tried to spawn MT_NULL, using MT_RAY\n"); + CONS_Debug(DBG_GAMELOGIC, "Tried to spawn MT_NULL, using MT_RAY\n"); type = MT_RAY; }