Revert "Add PlayerHeight and PlayerCanEnterSpinGaps Lua hooks"

This reverts commit b5c61a8a2a.
This commit is contained in:
James R 2021-04-05 17:03:31 -07:00
parent 22eb12c6a8
commit 79e4ca6d13
2 changed files with 0 additions and 94 deletions

View file

@ -59,8 +59,6 @@ enum hook {
hook_ShouldJingleContinue, hook_ShouldJingleContinue,
hook_GameQuit, hook_GameQuit,
hook_PlayerCmd, hook_PlayerCmd,
hook_PlayerHeight,
hook_PlayerCanEnterSpinGaps,
// SRB2Kart // SRB2Kart
hook_IntermissionThinker, hook_IntermissionThinker,
@ -127,5 +125,3 @@ UINT8 LUAh_ViewpointSwitch(player_t *player, player_t *newdisplayplayer, boolean
#define LUAh_PlayerThink(player) LUAh_PlayerHook(player, hook_PlayerThink) // Hook for P_PlayerThink #define LUAh_PlayerThink(player) LUAh_PlayerHook(player, hook_PlayerThink) // Hook for P_PlayerThink
boolean LUAh_ShouldJingleContinue(player_t *player, const char *musname); // Hook for whether a jingle of the given music should continue playing boolean LUAh_ShouldJingleContinue(player_t *player, const char *musname); // Hook for whether a jingle of the given music should continue playing
void LUAh_GameQuit(boolean quitting); // Hook for game quitting void LUAh_GameQuit(boolean quitting); // Hook for game quitting
fixed_t LUAh_PlayerHeight(player_t *player);
UINT8 LUAh_PlayerCanEnterSpinGaps(player_t *player);

View file

@ -75,8 +75,6 @@ const char *const hookNames[hook_MAX+1] = {
"ShouldJingleContinue", "ShouldJingleContinue",
"GameQuit", "GameQuit",
"PlayerCmd", "PlayerCmd",
"PlayerHeight",
"PlayerCanEnterSpinGaps",
// SRB2Kart // SRB2Kart
"IntermissionThinker", "IntermissionThinker",
@ -225,8 +223,6 @@ static int lib_addHook(lua_State *L)
case hook_ShieldSpawn: case hook_ShieldSpawn:
case hook_ShieldSpecial: case hook_ShieldSpecial:
case hook_PlayerThink: case hook_PlayerThink:
case hook_PlayerHeight:
case hook_PlayerCanEnterSpinGaps:
lastp = &playerhooks; lastp = &playerhooks;
break; break;
case hook_LinedefExecute: case hook_LinedefExecute:
@ -1879,92 +1875,6 @@ boolean LUAh_MusicChange(const char *oldname, char *newname, UINT16 *mflags, boo
return hooked; return hooked;
} }
// Hook for determining player height
fixed_t LUAh_PlayerHeight(player_t *player)
{
hook_p hookp;
fixed_t newheight = -1;
if (!gL || !(hooksAvailable[hook_PlayerHeight/8] & (1<<(hook_PlayerHeight%8))))
return newheight;
lua_settop(gL, 0);
lua_pushcfunction(gL, LUA_GetErrorMessage);
for (hookp = playerhooks; hookp; hookp = hookp->next)
{
if (hookp->type != hook_PlayerHeight)
continue;
ps_lua_mobjhooks++;
if (lua_gettop(gL) == 1)
LUA_PushUserdata(gL, player, META_PLAYER);
PushHook(gL, hookp);
lua_pushvalue(gL, -2);
if (lua_pcall(gL, 1, 1, 1)) {
if (!hookp->error || cv_debug & DBG_LUA)
CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1));
lua_pop(gL, 1);
hookp->error = true;
continue;
}
if (!lua_isnil(gL, -1))
{
fixed_t returnedheight = lua_tonumber(gL, -1);
// 0 height has... strange results, but it's not problematic like negative heights are.
// when an object's height is set to a negative number directly with lua, it's forced to 0 instead.
// here, I think it's better to ignore negatives so that they don't replace any results of previous hooks!
if (returnedheight >= 0)
newheight = returnedheight;
}
lua_pop(gL, 1);
}
lua_settop(gL, 0);
return newheight;
}
// Hook for determining whether players are allowed passage through spin gaps
UINT8 LUAh_PlayerCanEnterSpinGaps(player_t *player)
{
hook_p hookp;
UINT8 canEnter = 0; // 0 = default, 1 = force yes, 2 = force no.
if (!gL || !(hooksAvailable[hook_PlayerCanEnterSpinGaps/8] & (1<<(hook_PlayerCanEnterSpinGaps%8))))
return 0;
lua_settop(gL, 0);
lua_pushcfunction(gL, LUA_GetErrorMessage);
for (hookp = playerhooks; hookp; hookp = hookp->next)
{
if (hookp->type != hook_PlayerCanEnterSpinGaps)
continue;
ps_lua_mobjhooks++;
if (lua_gettop(gL) == 1)
LUA_PushUserdata(gL, player, META_PLAYER);
PushHook(gL, hookp);
lua_pushvalue(gL, -2);
if (lua_pcall(gL, 1, 1, 1)) {
if (!hookp->error || cv_debug & DBG_LUA)
CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1));
lua_pop(gL, 1);
hookp->error = true;
continue;
}
if (!lua_isnil(gL, -1))
{ // if nil, leave canEnter = 0.
if (lua_toboolean(gL, -1))
canEnter = 1; // Force yes
else
canEnter = 2; // Force no
}
lua_pop(gL, 1);
}
lua_settop(gL, 0);
return canEnter;
}
// Hook for Y_VoteTicker // Hook for Y_VoteTicker
void LUAh_VoteThinker(void) void LUAh_VoteThinker(void)
{ {