From 6cc48a6e893999f3b35a2305d2539b081fe07aa2 Mon Sep 17 00:00:00 2001 From: Eidolon Date: Thu, 26 Jan 2023 19:26:21 -0600 Subject: [PATCH] Revert "Merge branch 'gamepad-refactor-lua-rumble' into 'next'" This reverts commit 7d8e8e20b7c1b40231ac47c812225cd63358b12a, reversing changes made to 7f1cafcd3d0a0738bf106b8edcaf9a23f9cefa19. --- src/lua_baselib.c | 82 +---------------------------------------------- src/lua_script.h | 1 - 2 files changed, 1 insertion(+), 82 deletions(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index c94e9e91e..6212a77f0 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -15,7 +15,6 @@ #include "p_local.h" #include "p_setup.h" // So we can have P_SetupLevelSky #include "p_slopes.h" // P_GetSlopeZAt -#include "p_haptic.h" #include "z_zone.h" #include "r_main.h" #include "r_draw.h" @@ -1734,78 +1733,6 @@ static int lib_pPlayerShouldUseSpinHeight(lua_State *L) return 1; } -// P_HAPTIC -/////////// -#define GET_OPTIONAL_PLAYER(arg) \ - player_t *player = NULL; \ - if (!lua_isnoneornil(L, arg)) { \ - player = *((player_t **)luaL_checkudata(L, arg, META_PLAYER)); \ - if (!player) \ - return LUA_ErrInvalid(L, "player_t"); \ - } - -static int lib_pDoRumble(lua_State *L) -{ - GET_OPTIONAL_PLAYER(1); - fixed_t large_magnitude = luaL_checkfixed(L, 2); - fixed_t small_magnitude = luaL_optfixed(L, 3, large_magnitude); - tic_t duration = luaL_optinteger(L, 4, 0); - -#define CHECK_MAGNITUDE(which) \ - if (which##_magnitude < 0 || which##_magnitude > FRACUNIT) \ - return luaL_error(L, va(#which " motor frequency %f out of range (minimum is 0.0, maximum is 1.0)", \ - FixedToFloat(which##_magnitude))) - - CHECK_MAGNITUDE(large); - CHECK_MAGNITUDE(small); - -#undef CHECK_MAGNITUDE - - lua_pushboolean(L, P_DoRumble(player, large_magnitude, small_magnitude, duration)); - return 1; -} - -static int lib_pPauseRumble(lua_State *L) -{ - GET_OPTIONAL_PLAYER(1); - P_PauseRumble(player); - return 0; -} - -static int lib_pUnpauseRumble(lua_State *L) -{ - GET_OPTIONAL_PLAYER(1); - P_UnpauseRumble(player); - return 0; -} - -static int lib_pIsRumbleEnabled(lua_State *L) -{ - GET_OPTIONAL_PLAYER(1); - if (player && P_IsLocalPlayer(player)) - lua_pushboolean(L, P_IsRumbleEnabled(player)); - else - lua_pushnil(L); - return 1; -} - -static int lib_pIsRumblePaused(lua_State *L) -{ - GET_OPTIONAL_PLAYER(1); - if (player && P_IsLocalPlayer(player)) - lua_pushboolean(L, P_IsRumblePaused(player)); - else - lua_pushnil(L); - return 1; -} - -static int lib_pStopRumble(lua_State *L) -{ - GET_OPTIONAL_PLAYER(1); - P_StopRumble(player); - return 0; -} - // P_MAP /////////// @@ -3442,6 +3369,7 @@ static int lib_sResumeMusic(lua_State *L) // G_GAME //////////// +// Copypasted from lib_cvRegisterVar :] static int lib_gAddGametype(lua_State *L) { const char *k; @@ -4163,14 +4091,6 @@ static luaL_Reg lib[] = { {"P_PlayerCanEnterSpinGaps",lib_pPlayerCanEnterSpinGaps}, {"P_PlayerShouldUseSpinHeight",lib_pPlayerShouldUseSpinHeight}, - // p_haptic - {"P_DoRumble",lib_pDoRumble}, - {"P_PauseRumble",lib_pPauseRumble}, - {"P_UnpauseRumble",lib_pUnpauseRumble}, - {"P_IsRumbleEnabled",lib_pIsRumbleEnabled}, - {"P_IsRumblePaused",lib_pIsRumblePaused}, - {"P_StopRumble",lib_pStopRumble}, - // p_map {"P_CheckPosition",lib_pCheckPosition}, {"P_TryMove",lib_pTryMove}, diff --git a/src/lua_script.h b/src/lua_script.h index 1c98a32f3..080427039 100644 --- a/src/lua_script.h +++ b/src/lua_script.h @@ -36,7 +36,6 @@ // angle_t casting // TODO deal with signedness #define luaL_checkangle(L, i) ((angle_t)luaL_checkinteger(L, i)) -#define luaL_optangle(L, i, o) ((angle_t)luaL_optinteger(L, i, o)) #define lua_pushangle(L, a) lua_pushinteger(L, a) #ifdef _DEBUG