From 8fa0641e99b47573184238ce03eb563ab3d890f4 Mon Sep 17 00:00:00 2001
From: toaster <rollerorbital@gmail.com>
Date: Thu, 1 Aug 2019 18:12:12 +0100
Subject: [PATCH] Instead of checking whether mobj->spawnpoint->extrainfo is in
 the correct range every tic, have a lua error for trying to set it outside
 (since there'll no doubt be other consequences to being outside the range
 too)

---
 src/lua_mobjlib.c | 7 ++++++-
 src/p_mobj.c      | 2 +-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c
index 8bbbebe1d4..5fc3babd3b 100644
--- a/src/lua_mobjlib.c
+++ b/src/lua_mobjlib.c
@@ -804,7 +804,12 @@ static int mapthing_set(lua_State *L)
 	else if(fastcmp(field,"z"))
 		mt->z = (INT16)luaL_checkinteger(L, 3);
 	else if(fastcmp(field,"extrainfo"))
-		mt->extrainfo = (UINT8)luaL_checkinteger(L, 3);
+	{
+		INT32 extrainfo = luaL_checkinteger(L, 3);
+		if (extrainfo & ~15)
+			return luaL_error(L, "mapthing_t extrainfo set %d out of range (%d - %d)", extrainfo, 0, 15);
+		mt->extrainfo = (UINT8)extrainfo;
+	}
 	else if(fastcmp(field,"mobj"))
 		mt->mobj = *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ));
 	else
diff --git a/src/p_mobj.c b/src/p_mobj.c
index fe45a799a7..5b924c3eb5 100644
--- a/src/p_mobj.c
+++ b/src/p_mobj.c
@@ -7011,7 +7011,7 @@ void P_MobjThinker(mobj_t *mobj)
 	if (mobj->flags & MF_NOTHINK)
 		return;
 
-	if ((mobj->flags & MF_BOSS) && mobj->spawnpoint && !(mobj->spawnpoint->extrainfo & ~15) && (bossdisabled & (1<<mobj->spawnpoint->extrainfo)))
+	if ((mobj->flags & MF_BOSS) && mobj->spawnpoint && (bossdisabled & (1<<mobj->spawnpoint->extrainfo)))
 		return;
 
 	// Remove dead target/tracer.
-- 
GitLab