From 6ed21357dbe0ba5ca07859a00c0281651a230615 Mon Sep 17 00:00:00 2001 From: Indev Date: Wed, 19 Nov 2025 22:07:48 +0300 Subject: [PATCH] Check if mobj was actually spawned before setting islocal --- src/lua_baselib.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 9ab63ce52..055b8cdf3 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -385,7 +385,7 @@ static int lib_pSpawnMobj(lua_State *L) if (type >= NUMMOBJTYPES) return luaL_error(L, "mobj type %d out of range (0 - %d)", type, NUMMOBJTYPES-1); mobj_t *th = P_SpawnMobj(x, y, z, type); - th->islocal = !hook_important; + if (!P_MobjWasRemoved(th)) th->islocal = !hook_important; LUA_PushUserdata(L, th, META_MOBJ); return 1; } @@ -413,7 +413,7 @@ static int lib_pSpawnMissile(lua_State *L) if (type >= NUMMOBJTYPES) return luaL_error(L, "mobj type %d out of range (0 - %d)", type, NUMMOBJTYPES-1); mobj_t *th = P_SpawnMissile(source, dest, type); - th->islocal = !hook_important; + if (!P_MobjWasRemoved(th)) th->islocal = !hook_important; LUA_PushUserdata(L, th, META_MOBJ); return 1; } @@ -432,7 +432,7 @@ static int lib_pSpawnXYZMissile(lua_State *L) if (type >= NUMMOBJTYPES) return luaL_error(L, "mobj type %d out of range (0 - %d)", type, NUMMOBJTYPES-1); mobj_t *th = P_SpawnXYZMissile(source, dest, type, x, y, z); - th->islocal = !hook_important; + if (!P_MobjWasRemoved(th)) th->islocal = !hook_important; LUA_PushUserdata(L, th, META_MOBJ); return 1; } @@ -453,7 +453,7 @@ static int lib_pSpawnPointMissile(lua_State *L) if (type >= NUMMOBJTYPES) return luaL_error(L, "mobj type %d out of range (0 - %d)", type, NUMMOBJTYPES-1); mobj_t *th = P_SpawnPointMissile(source, xa, ya, za, type, x, y, z); - th->islocal = !hook_important; + if (!P_MobjWasRemoved(th)) th->islocal = !hook_important; LUA_PushUserdata(L, th, META_MOBJ); return 1; } @@ -472,7 +472,7 @@ static int lib_pSpawnAlteredDirectionMissile(lua_State *L) if (type >= NUMMOBJTYPES) return luaL_error(L, "mobj type %d out of range (0 - %d)", type, NUMMOBJTYPES-1); mobj_t *th = P_SpawnAlteredDirectionMissile(source, type, x, y, z, shiftingAngle); - th->islocal = !hook_important; + if (!P_MobjWasRemoved(th)) th->islocal = !hook_important; LUA_PushUserdata(L, th, META_MOBJ); return 1; } @@ -503,7 +503,7 @@ static int lib_pSPMAngle(lua_State *L) if (type >= NUMMOBJTYPES) return luaL_error(L, "mobj type %d out of range (0 - %d)", type, NUMMOBJTYPES-1); mobj_t *th = P_SPMAngle(source, type, angle, allowaim, flags2); - th->islocal = !hook_important; + if (!P_MobjWasRemoved(th)) th->islocal = !hook_important; LUA_PushUserdata(L, th, META_MOBJ); return 1; } @@ -519,7 +519,7 @@ static int lib_pSpawnPlayerMissile(lua_State *L) if (type >= NUMMOBJTYPES) return luaL_error(L, "mobj type %d out of range (0 - %d)", type, NUMMOBJTYPES-1); mobj_t *th = P_SpawnPlayerMissile(source, type, flags2); - th->islocal = !hook_important; + if (!P_MobjWasRemoved(th)) th->islocal = !hook_important; LUA_PushUserdata(L, th, META_MOBJ); return 1; }