From 0a6b036a412d6602ee484eec1bb692acfa6e86fa Mon Sep 17 00:00:00 2001 From: MIDIMan <miditheman2.0@gmail.com> Date: Wed, 31 Jan 2024 14:29:35 -0500 Subject: [PATCH] Expose P_PathTraverse to Lua --- src/CMakeLists.txt | 1 + src/Sourcefile | 1 + src/deh_tables.c | 6 ++++++ src/lua_baselib.c | 2 ++ src/lua_libs.h | 3 +++ src/lua_script.c | 1 + src/p_local.h | 2 ++ src/p_map.c | 2 +- src/p_maputl.c | 2 +- src/sdl/Srb2SDL-vc10.vcxproj | 1 + src/sdl/Srb2SDL-vc10.vcxproj.filters | 3 +++ 11 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 21f7c6c45f..3fed07bcc2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -103,6 +103,7 @@ add_executable(SRB2SDL2 MACOSX_BUNDLE WIN32 lua_hudlib_drawlist.c lua_colorlib.c lua_inputlib.c + lua_interceptlib.c ) # This updates the modification time for comptime.c at the diff --git a/src/Sourcefile b/src/Sourcefile index ad5eacfeb9..68ffe0f3f6 100644 --- a/src/Sourcefile +++ b/src/Sourcefile @@ -97,3 +97,4 @@ lua_hudlib.c lua_hudlib_drawlist.c lua_inputlib.c lua_colorlib.c +lua_interceptlib.c diff --git a/src/deh_tables.c b/src/deh_tables.c index fa86518e2e..3fdb1ab0bd 100644 --- a/src/deh_tables.c +++ b/src/deh_tables.c @@ -25,6 +25,7 @@ #include "g_game.h" // Joystick axes (for lua) #include "i_joy.h" #include "g_input.h" // Game controls (for lua) +#include "p_maputl.h" // P_PathTraverse constants (for lua) #include "deh_tables.h" @@ -5797,6 +5798,11 @@ struct int_const_s const INT_CONST[] = { {"MB_BUTTON8",MB_BUTTON8}, {"MB_SCROLLUP",MB_SCROLLUP}, {"MB_SCROLLDOWN",MB_SCROLLDOWN}, + + // P_PathTraverse constants + {"PT_ADDLINES",PT_ADDLINES}, + {"PT_ADDTHINGS",PT_ADDTHINGS}, + {"PT_EARLYOUT",PT_EARLYOUT}, {NULL,0} }; diff --git a/src/lua_baselib.c b/src/lua_baselib.c index b70c63ece1..26b8682909 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -222,6 +222,8 @@ static const struct { {META_KEYEVENT, "keyevent_t"}, {META_MOUSE, "mouse_t"}, + + {META_INTERCEPT, "intercept_t"}, {NULL, NULL} }; diff --git a/src/lua_libs.h b/src/lua_libs.h index a90d8ac7fb..5b4045f016 100644 --- a/src/lua_libs.h +++ b/src/lua_libs.h @@ -95,6 +95,8 @@ extern boolean ignoregameinputs; #define META_KEYEVENT "KEYEVENT_T*" #define META_MOUSE "MOUSE_T*" +#define META_INTERCEPT "INTERCEPT_T*" + boolean luaL_checkboolean(lua_State *L, int narg); int LUA_EnumLib(lua_State *L); @@ -115,3 +117,4 @@ int LUA_BlockmapLib(lua_State *L); int LUA_HudLib(lua_State *L); int LUA_ColorLib(lua_State *L); int LUA_InputLib(lua_State *L); +int LUA_InterceptLib(lua_State *L); diff --git a/src/lua_script.c b/src/lua_script.c index 11ced70f25..7db9624407 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -62,6 +62,7 @@ static lua_CFunction liblist[] = { LUA_HudLib, // HUD stuff LUA_ColorLib, // general color functions LUA_InputLib, // inputs + LUA_InterceptLib, // intercept_t NULL }; diff --git a/src/p_local.h b/src/p_local.h index 8bdc89841f..2be99ff4a5 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -446,6 +446,8 @@ boolean PIT_PushableMoved(mobj_t *thing); boolean P_DoSpring(mobj_t *spring, mobj_t *object); +boolean PTR_SlideTraverse(intercept_t *in); + INT32 P_GetSectorLightNumAt(sector_t *sector, fixed_t x, fixed_t y, fixed_t z); INT32 P_GetLightLevelFromSectorAt(sector_t *sector, fixed_t x, fixed_t y, fixed_t z); INT32 P_GetSectorLightLevelAt(fixed_t x, fixed_t y, fixed_t z); diff --git a/src/p_map.c b/src/p_map.c index e28f4ae450..bfb3ccf10c 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -3535,7 +3535,7 @@ static void PTR_GlideClimbTraverse(line_t *li) } } -static boolean PTR_SlideTraverse(intercept_t *in) +boolean PTR_SlideTraverse(intercept_t *in) { line_t *li; diff --git a/src/p_maputl.c b/src/p_maputl.c index 9c30d3ead0..2d9f23c7b9 100644 --- a/src/p_maputl.c +++ b/src/p_maputl.c @@ -1170,7 +1170,7 @@ static boolean P_TraverseIntercepts(traverser_t func, fixed_t maxfrac) if (dist > maxfrac) return true; // Checked everything in range. - + if (!func(in)) return false; // Don't bother going farther. diff --git a/src/sdl/Srb2SDL-vc10.vcxproj b/src/sdl/Srb2SDL-vc10.vcxproj index 7142cb64cb..d282b3b4a1 100644 --- a/src/sdl/Srb2SDL-vc10.vcxproj +++ b/src/sdl/Srb2SDL-vc10.vcxproj @@ -449,6 +449,7 @@ <ClCompile Include="..\lua_hudlib_drawlist.c" /> <ClCompile Include="..\lua_infolib.c" /> <ClCompile Include="..\lua_inputlib.c" /> + <ClCompile Include="..\lua_interceptlib.c" /> <ClCompile Include="..\lua_maplib.c" /> <ClCompile Include="..\lua_mathlib.c" /> <ClCompile Include="..\lua_mobjlib.c" /> diff --git a/src/sdl/Srb2SDL-vc10.vcxproj.filters b/src/sdl/Srb2SDL-vc10.vcxproj.filters index 44c353ae29..4a2a5d5950 100644 --- a/src/sdl/Srb2SDL-vc10.vcxproj.filters +++ b/src/sdl/Srb2SDL-vc10.vcxproj.filters @@ -779,6 +779,9 @@ </ClCompile> <ClCompile Include="..\lua_inputlib.c"> <Filter>LUA</Filter> + </ClCompile> + <ClCompile Include="..\lua_interceptlib.c"> + <Filter>LUA</Filter> </ClCompile> <ClCompile Include="..\lua_maplib.c"> <Filter>LUA</Filter> -- GitLab