diff --git a/src/lua_maplib.c b/src/lua_maplib.c index d92cd1f8b..a6bca2ff6 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -281,7 +281,7 @@ static int lib_iterateSectorThinglist(lua_State *L) if (!lua_isnil(L, 1)) { thing = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); - if (P_MobjWasRemoved(thing)) + if (!thing) return luaL_error(L, "current entry in thinglist was removed; avoid calling P_RemoveMobj on entries!"); thing = thing->snext; } diff --git a/src/p_mobj.c b/src/p_mobj.c index a2ce82464..3b06c3737 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3384,7 +3384,7 @@ static void P_PlayerMobjThinker(mobj_t *mobj) I_Assert(mobj->player != NULL); I_Assert(!P_MobjWasRemoved(mobj)); - if (P_MobjWasRemoved(mobj)) + if (!mobj) return; P_MobjCheckWater(mobj); @@ -11126,7 +11126,8 @@ void P_SpawnMapThing(mapthing_t *mthing) mobj = P_SpawnMobj(x, y, z, i); - if (!mobj || P_MobjWasRemoved(mobj)) { + if (!mobj || P_MobjWasRemoved(mobj)) + { 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); return; }