From aa146dee419e6a29409fac962b526ebcc79a98a1 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Thu, 24 Nov 2016 21:11:44 +0000 Subject: [PATCH] Disabled all seg_t/node_t-related Lua code for now To re-enable support for the above, uncomment the define HAVE_LUA_SEGS line in lua_script.h. Plain bbox userdata stuff is not disabled (though currently it's not used anyway) --- src/lua_libs.h | 4 ++++ src/lua_maplib.c | 10 ++++++++++ src/lua_script.c | 10 ++++++++++ src/lua_script.h | 3 +++ 4 files changed, 27 insertions(+) diff --git a/src/lua_libs.h b/src/lua_libs.h index fc8da25c1..fd4937b63 100644 --- a/src/lua_libs.h +++ b/src/lua_libs.h @@ -38,16 +38,20 @@ extern lua_State *gL; #define META_SUBSECTOR "SUBSECTOR_T*" #define META_SECTOR "SECTOR_T*" #define META_FFLOOR "FFLOOR_T*" +#ifdef HAVE_LUA_SEGS #define META_SEG "SEG_T*" #define META_NODE "NODE_T*" +#endif #define META_MAPHEADER "MAPHEADER_T*" #define META_CVAR "CONSVAR_T*" #define META_SECTORLINES "SECTOR_T*LINES" #define META_SIDENUM "LINE_T*SIDENUM" +#ifdef HAVE_LUA_SEGS #define META_NODEBBOX "NODE_T*BBOX" #define META_NODECHILDREN "NODE_T*CHILDREN" +#endif #define META_BBOX "BOUNDING_BOX" diff --git a/src/lua_maplib.c b/src/lua_maplib.c index 2679e4ba9..d6119bd11 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -185,6 +185,7 @@ static const char *const ffloor_opt[] = { "alpha", NULL}; +#ifdef HAVE_LUA_SEGS enum seg_e { seg_valid = 0, seg_v1, @@ -242,6 +243,7 @@ static const char *const nodechild_opt[] = { "right", "left", NULL}; +#endif enum bbox_e { bbox_valid = 0, @@ -892,6 +894,7 @@ static int vertex_num(lua_State *L) return 1; } +#ifdef HAVE_LUA_SEGS static int seg_get(lua_State *L) { seg_t *seg = *((seg_t **)luaL_checkudata(L, 1, META_SEG)); @@ -1108,6 +1111,7 @@ static int nodechildren_get(lua_State *L) lua_pushinteger(L, children[i]); return 1; } +#endif // bounding box (aka fixed_t array with four elements) // NOTE: may be useful for polyobjects or other things later @@ -1376,6 +1380,7 @@ static int lib_numvertexes(lua_State *L) return 1; } +#ifdef HAVE_LUA_SEGS static int lib_iterateSegs(lua_State *L) { size_t i = 0; @@ -1467,6 +1472,7 @@ static int lib_numnodes(lua_State *L) lua_pushinteger(L, numnodes); return 1; } +#endif static int ffloor_get(lua_State *L) { @@ -1787,6 +1793,7 @@ int LUA_MapLib(lua_State *L) lua_setfield(L, -2, "__newindex"); lua_pop(L, 1); +#ifdef HAVE_LUA_SEGS luaL_newmetatable(L, META_SEG); lua_pushcfunction(L, seg_get); lua_setfield(L, -2, "__index"); @@ -1814,6 +1821,7 @@ int LUA_MapLib(lua_State *L) lua_pushcfunction(L, nodechildren_get); lua_setfield(L, -2, "__index"); lua_pop(L, 1); +#endif luaL_newmetatable(L, META_BBOX); lua_pushcfunction(L, bbox_get); @@ -1878,6 +1886,7 @@ int LUA_MapLib(lua_State *L) lua_setmetatable(L, -2); lua_setglobal(L, "vertexes"); +#ifdef HAVE_LUA_SEGS lua_newuserdata(L, 0); lua_createtable(L, 0, 2); lua_pushcfunction(L, lib_getSeg); @@ -1897,6 +1906,7 @@ int LUA_MapLib(lua_State *L) lua_setfield(L, -2, "__len"); lua_setmetatable(L, -2); lua_setglobal(L, "nodes"); +#endif lua_newuserdata(L, 0); lua_createtable(L, 0, 2); diff --git a/src/lua_script.c b/src/lua_script.c index 6252330a4..d30790be1 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -426,6 +426,7 @@ void LUA_InvalidateLevel(void) LUA_InvalidateUserdata(&sides[i]); for (i = 0; i < numvertexes; i++) LUA_InvalidateUserdata(&vertexes[i]); +#ifdef HAVE_LUA_SEGS for (i = 0; i < numsegs; i++) LUA_InvalidateUserdata(&segs[i]); for (i = 0; i < numnodes; i++) @@ -434,6 +435,7 @@ void LUA_InvalidateLevel(void) LUA_InvalidateUserdata(nodes[i].bbox); LUA_InvalidateUserdata(nodes[i].children); } +#endif } void LUA_InvalidateMapthings(void) @@ -473,8 +475,10 @@ enum ARCH_SIDE, ARCH_SUBSECTOR, ARCH_SECTOR, +#ifdef HAVE_LUA_SEGS ARCH_SEG, ARCH_NODE, +#endif ARCH_FFLOOR, ARCH_MAPHEADER, @@ -495,8 +499,10 @@ static const struct { {META_SIDE, ARCH_SIDE}, {META_SUBSECTOR,ARCH_SUBSECTOR}, {META_SECTOR, ARCH_SECTOR}, +#ifdef HAVE_LUA_SEGS {META_SEG, ARCH_SEG}, {META_NODE, ARCH_NODE}, +#endif {META_FFLOOR, ARCH_FFLOOR}, {META_MAPHEADER, ARCH_MAPHEADER}, {NULL, ARCH_NULL} @@ -688,6 +694,7 @@ static UINT8 ArchiveValue(int TABLESINDEX, int myindex) } break; } +#ifdef HAVE_LUA_SEGS case ARCH_SEG: { seg_t *seg = *((seg_t **)lua_touserdata(gL, myindex)); @@ -710,6 +717,7 @@ static UINT8 ArchiveValue(int TABLESINDEX, int myindex) } break; } +#endif case ARCH_FFLOOR: { ffloor_t *rover = *((ffloor_t **)lua_touserdata(gL, myindex)); @@ -914,12 +922,14 @@ static UINT8 UnArchiveValue(int TABLESINDEX) case ARCH_SECTOR: LUA_PushUserdata(gL, §ors[READUINT16(save_p)], META_SECTOR); break; +#ifdef HAVE_LUA_SEGS case ARCH_SEG: LUA_PushUserdata(gL, &segs[READUINT16(save_p)], META_SEG); break; case ARCH_NODE: LUA_PushUserdata(gL, &nodes[READUINT16(save_p)], META_NODE); break; +#endif case ARCH_FFLOOR: { sector_t *sector = §ors[READUINT16(save_p)]; diff --git a/src/lua_script.h b/src/lua_script.h index 3b159234a..d143ed879 100644 --- a/src/lua_script.h +++ b/src/lua_script.h @@ -92,4 +92,7 @@ void COM_Lua_f(void); }\ } +// uncomment if you want seg_t/node_t in Lua +// #define HAVE_LUA_SEGS + #endif