mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-21 20:11:12 +00:00
Merge branch 'next' of https://git.do.srb2.org/STJr/SRB2.git into prerelease
This commit is contained in:
commit
bcbbf1ec47
9 changed files with 184 additions and 18 deletions
|
@ -1671,6 +1671,26 @@ static int lib_pSwitchShield(lua_State *L)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int lib_pPlayerCanEnterSpinGaps(lua_State *L)
|
||||||
|
{
|
||||||
|
player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
|
||||||
|
INLEVEL
|
||||||
|
if (!player)
|
||||||
|
return LUA_ErrInvalid(L, "player_t");
|
||||||
|
lua_pushboolean(L, P_PlayerCanEnterSpinGaps(player));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int lib_pPlayerShouldUseSpinHeight(lua_State *L)
|
||||||
|
{
|
||||||
|
player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
|
||||||
|
INLEVEL
|
||||||
|
if (!player)
|
||||||
|
return LUA_ErrInvalid(L, "player_t");
|
||||||
|
lua_pushboolean(L, P_PlayerShouldUseSpinHeight(player));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
// P_MAP
|
// P_MAP
|
||||||
///////////
|
///////////
|
||||||
|
|
||||||
|
@ -3872,6 +3892,8 @@ static luaL_Reg lib[] = {
|
||||||
{"P_SpawnSpinMobj",lib_pSpawnSpinMobj},
|
{"P_SpawnSpinMobj",lib_pSpawnSpinMobj},
|
||||||
{"P_Telekinesis",lib_pTelekinesis},
|
{"P_Telekinesis",lib_pTelekinesis},
|
||||||
{"P_SwitchShield",lib_pSwitchShield},
|
{"P_SwitchShield",lib_pSwitchShield},
|
||||||
|
{"P_PlayerCanEnterSpinGaps",lib_pPlayerCanEnterSpinGaps},
|
||||||
|
{"P_PlayerShouldUseSpinHeight",lib_pPlayerShouldUseSpinHeight},
|
||||||
|
|
||||||
// p_map
|
// p_map
|
||||||
{"P_CheckPosition",lib_pCheckPosition},
|
{"P_CheckPosition",lib_pCheckPosition},
|
||||||
|
|
|
@ -61,6 +61,8 @@ enum hook {
|
||||||
hook_GameQuit,
|
hook_GameQuit,
|
||||||
hook_PlayerCmd,
|
hook_PlayerCmd,
|
||||||
hook_MusicChange,
|
hook_MusicChange,
|
||||||
|
hook_PlayerHeight,
|
||||||
|
hook_PlayerCanEnterSpinGaps,
|
||||||
|
|
||||||
hook_MAX // last hook
|
hook_MAX // last hook
|
||||||
};
|
};
|
||||||
|
@ -118,3 +120,5 @@ boolean LUAh_ShouldJingleContinue(player_t *player, const char *musname); // Hoo
|
||||||
void LUAh_GameQuit(boolean quitting); // Hook for game quitting
|
void LUAh_GameQuit(boolean quitting); // Hook for game quitting
|
||||||
boolean LUAh_PlayerCmd(player_t *player, ticcmd_t *cmd); // Hook for building player's ticcmd struct (Ported from SRB2Kart)
|
boolean LUAh_PlayerCmd(player_t *player, ticcmd_t *cmd); // Hook for building player's ticcmd struct (Ported from SRB2Kart)
|
||||||
boolean LUAh_MusicChange(const char *oldname, char *newname, UINT16 *mflags, boolean *looping, UINT32 *position, UINT32 *prefadems, UINT32 *fadeinms); // Hook for music changes
|
boolean LUAh_MusicChange(const char *oldname, char *newname, UINT16 *mflags, boolean *looping, UINT32 *position, UINT32 *prefadems, UINT32 *fadeinms); // Hook for music changes
|
||||||
|
fixed_t LUAh_PlayerHeight(player_t *player);
|
||||||
|
UINT8 LUAh_PlayerCanEnterSpinGaps(player_t *player);
|
||||||
|
|
|
@ -77,6 +77,8 @@ const char *const hookNames[hook_MAX+1] = {
|
||||||
"GameQuit",
|
"GameQuit",
|
||||||
"PlayerCmd",
|
"PlayerCmd",
|
||||||
"MusicChange",
|
"MusicChange",
|
||||||
|
"PlayerHeight",
|
||||||
|
"PlayerCanEnterSpinGaps",
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -221,6 +223,8 @@ 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:
|
||||||
|
@ -1971,3 +1975,89 @@ boolean LUAh_MusicChange(const char *oldname, char *newname, UINT16 *mflags, boo
|
||||||
newname[6] = 0;
|
newname[6] = 0;
|
||||||
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;
|
||||||
|
}
|
||||||
|
|
|
@ -143,6 +143,8 @@ angle_t P_GetLocalAngle(player_t *player);
|
||||||
void P_SetLocalAngle(player_t *player, angle_t angle);
|
void P_SetLocalAngle(player_t *player, angle_t angle);
|
||||||
void P_ForceLocalAngle(player_t *player, angle_t angle);
|
void P_ForceLocalAngle(player_t *player, angle_t angle);
|
||||||
boolean P_PlayerFullbright(player_t *player);
|
boolean P_PlayerFullbright(player_t *player);
|
||||||
|
boolean P_PlayerCanEnterSpinGaps(player_t *player);
|
||||||
|
boolean P_PlayerShouldUseSpinHeight(player_t *player);
|
||||||
|
|
||||||
boolean P_IsObjectInGoop(mobj_t *mo);
|
boolean P_IsObjectInGoop(mobj_t *mo);
|
||||||
boolean P_IsObjectOnGround(mobj_t *mo);
|
boolean P_IsObjectOnGround(mobj_t *mo);
|
||||||
|
|
10
src/p_map.c
10
src/p_map.c
|
@ -2723,7 +2723,10 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff)
|
||||||
if (thing->type == MT_SKIM)
|
if (thing->type == MT_SKIM)
|
||||||
maxstep = 0;
|
maxstep = 0;
|
||||||
|
|
||||||
if (tmceilingz - tmfloorz < thing->height)
|
if (tmceilingz - tmfloorz < thing->height
|
||||||
|
|| (thing->player
|
||||||
|
&& tmceilingz - tmfloorz < P_GetPlayerHeight(thing->player)
|
||||||
|
&& !P_PlayerCanEnterSpinGaps(thing->player)))
|
||||||
{
|
{
|
||||||
if (tmfloorthing)
|
if (tmfloorthing)
|
||||||
tmhitthing = tmfloorthing;
|
tmhitthing = tmfloorthing;
|
||||||
|
@ -3331,6 +3334,11 @@ static boolean PTR_LineIsBlocking(line_t *li)
|
||||||
if (openbottom - slidemo->z > FixedMul(MAXSTEPMOVE, slidemo->scale))
|
if (openbottom - slidemo->z > FixedMul(MAXSTEPMOVE, slidemo->scale))
|
||||||
return true; // too big a step up
|
return true; // too big a step up
|
||||||
|
|
||||||
|
if (slidemo->player
|
||||||
|
&& openrange < P_GetPlayerHeight(slidemo->player)
|
||||||
|
&& !P_PlayerCanEnterSpinGaps(slidemo->player))
|
||||||
|
return true; // nonspin character should not take this path
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4135,7 +4135,7 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate)
|
||||||
|
|
||||||
#ifdef HWRENDER
|
#ifdef HWRENDER
|
||||||
// Free GPU textures before freeing patches.
|
// Free GPU textures before freeing patches.
|
||||||
if (vid.glstate == VID_GL_LIBRARY_LOADED)
|
if (rendermode == render_opengl && (vid.glstate == VID_GL_LIBRARY_LOADED))
|
||||||
HWR_ClearAllTextures();
|
HWR_ClearAllTextures();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -4500,7 +4500,7 @@ boolean P_AddWadFile(const char *wadfilename)
|
||||||
|
|
||||||
#ifdef HWRENDER
|
#ifdef HWRENDER
|
||||||
// Free GPU textures before freeing patches.
|
// Free GPU textures before freeing patches.
|
||||||
if (vid.glstate == VID_GL_LIBRARY_LOADED)
|
if (rendermode == render_opengl && (vid.glstate == VID_GL_LIBRARY_LOADED))
|
||||||
HWR_ClearAllTextures();
|
HWR_ClearAllTextures();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
44
src/p_user.c
44
src/p_user.c
|
@ -8651,14 +8651,16 @@ void P_MovePlayer(player_t *player)
|
||||||
{
|
{
|
||||||
boolean atspinheight = false;
|
boolean atspinheight = false;
|
||||||
fixed_t oldheight = player->mo->height;
|
fixed_t oldheight = player->mo->height;
|
||||||
|
fixed_t luaheight = LUAh_PlayerHeight(player);
|
||||||
|
|
||||||
|
if (luaheight != -1)
|
||||||
|
{
|
||||||
|
player->mo->height = luaheight;
|
||||||
|
if (luaheight <= P_GetPlayerSpinHeight(player))
|
||||||
|
atspinheight = true; // spinning will not save you from being crushed
|
||||||
|
}
|
||||||
// Less height while spinning. Good for spinning under things...?
|
// Less height while spinning. Good for spinning under things...?
|
||||||
if ((player->mo->state == &states[player->mo->info->painstate])
|
else if (P_PlayerShouldUseSpinHeight(player))
|
||||||
|| ((player->pflags & PF_JUMPED) && !(player->pflags & PF_NOJUMPDAMAGE))
|
|
||||||
|| (player->pflags & PF_SPINNING)
|
|
||||||
|| player->powers[pw_tailsfly] || player->pflags & PF_GLIDING
|
|
||||||
|| (player->charability == CA_GLIDEANDCLIMB && player->mo->state-states == S_PLAY_GLIDE_LANDING)
|
|
||||||
|| (player->charability == CA_FLY && player->mo->state-states == S_PLAY_FLY_TIRED))
|
|
||||||
{
|
{
|
||||||
player->mo->height = P_GetPlayerSpinHeight(player);
|
player->mo->height = P_GetPlayerSpinHeight(player);
|
||||||
atspinheight = true;
|
atspinheight = true;
|
||||||
|
@ -12953,3 +12955,33 @@ boolean P_PlayerFullbright(player_t *player)
|
||||||
|| !(player->mo->state >= &states[S_PLAY_NIGHTS_TRANS1]
|
|| !(player->mo->state >= &states[S_PLAY_NIGHTS_TRANS1]
|
||||||
&& player->mo->state < &states[S_PLAY_NIGHTS_TRANS6])))); // Note the < instead of <=
|
&& player->mo->state < &states[S_PLAY_NIGHTS_TRANS6])))); // Note the < instead of <=
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define JUMPCURLED(player) ((player->pflags & PF_JUMPED)\
|
||||||
|
&& (!(player->charflags & SF_NOJUMPSPIN))\
|
||||||
|
&& (player->panim == PA_JUMP || player->panim == PA_ROLL))\
|
||||||
|
|
||||||
|
// returns true if the player can enter a sector that they could not if standing at their skin's full height
|
||||||
|
boolean P_PlayerCanEnterSpinGaps(player_t *player)
|
||||||
|
{
|
||||||
|
UINT8 canEnter = LUAh_PlayerCanEnterSpinGaps(player);
|
||||||
|
if (canEnter == 1)
|
||||||
|
return true;
|
||||||
|
else if (canEnter == 2)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return ((player->pflags & (PF_SPINNING|PF_GLIDING)) // players who are spinning or gliding
|
||||||
|
|| (player->charability == CA_GLIDEANDCLIMB && player->mo->state-states == S_PLAY_GLIDE_LANDING) // players who are landing from a glide
|
||||||
|
|| JUMPCURLED(player)); // players who are jumpcurled, but only if they would normally jump that way
|
||||||
|
}
|
||||||
|
|
||||||
|
// returns true if the player should use their skin's spinheight instead of their skin's height
|
||||||
|
boolean P_PlayerShouldUseSpinHeight(player_t *player)
|
||||||
|
{
|
||||||
|
return ((player->pflags & (PF_SPINNING|PF_GLIDING))
|
||||||
|
|| (player->mo->state == &states[player->mo->info->painstate])
|
||||||
|
|| (player->panim == PA_ROLL)
|
||||||
|
|| ((player->powers[pw_tailsfly] || (player->charability == CA_FLY && player->mo->state-states == S_PLAY_FLY_TIRED))
|
||||||
|
&& !(player->charflags & SF_NOJUMPSPIN))
|
||||||
|
|| (player->charability == CA_GLIDEANDCLIMB && player->mo->state-states == S_PLAY_GLIDE_LANDING)
|
||||||
|
|| JUMPCURLED(player));
|
||||||
|
}
|
||||||
|
|
17
src/r_main.c
17
src/r_main.c
|
@ -1089,8 +1089,6 @@ subsector_t *R_PointInSubsectorOrNull(fixed_t x, fixed_t y)
|
||||||
// 18/08/18: (No it's actually 16*viewheight, thanks Jimita for finding this out)
|
// 18/08/18: (No it's actually 16*viewheight, thanks Jimita for finding this out)
|
||||||
static void R_SetupFreelook(player_t *player, boolean skybox)
|
static void R_SetupFreelook(player_t *player, boolean skybox)
|
||||||
{
|
{
|
||||||
INT32 dy = 0;
|
|
||||||
|
|
||||||
#ifndef HWRENDER
|
#ifndef HWRENDER
|
||||||
(void)player;
|
(void)player;
|
||||||
(void)skybox;
|
(void)skybox;
|
||||||
|
@ -1109,14 +1107,15 @@ static void R_SetupFreelook(player_t *player, boolean skybox)
|
||||||
G_SoftwareClipAimingPitch((INT32 *)&aimingangle);
|
G_SoftwareClipAimingPitch((INT32 *)&aimingangle);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rendermode == render_soft)
|
centeryfrac = (viewheight/2)<<FRACBITS;
|
||||||
{
|
|
||||||
dy = (AIMINGTODY(aimingangle)>>FRACBITS) * viewwidth/BASEVIDWIDTH;
|
|
||||||
yslope = &yslopetab[viewheight*8 - (viewheight/2 + dy)];
|
|
||||||
}
|
|
||||||
|
|
||||||
centery = (viewheight/2) + dy;
|
if (rendermode == render_soft)
|
||||||
centeryfrac = centery<<FRACBITS;
|
centeryfrac += FixedMul(AIMINGTODY(aimingangle), FixedDiv(viewwidth<<FRACBITS, BASEVIDWIDTH<<FRACBITS));
|
||||||
|
|
||||||
|
centery = FixedInt(FixedRound(centeryfrac));
|
||||||
|
|
||||||
|
if (rendermode == render_soft)
|
||||||
|
yslope = &yslopetab[viewheight*8 - centery];
|
||||||
}
|
}
|
||||||
|
|
||||||
void R_SetupFrame(player_t *player)
|
void R_SetupFrame(player_t *player)
|
||||||
|
|
|
@ -33,6 +33,11 @@
|
||||||
#include "s_sound.h" // ditto
|
#include "s_sound.h" // ditto
|
||||||
#include "g_game.h" // ditto
|
#include "g_game.h" // ditto
|
||||||
#include "p_local.h" // P_AutoPause()
|
#include "p_local.h" // P_AutoPause()
|
||||||
|
#ifdef HWRENDER
|
||||||
|
#include "hardware/hw_main.h"
|
||||||
|
#include "hardware/hw_light.h"
|
||||||
|
#include "hardware/hw_model.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if defined (USEASM) && !defined (NORUSEASM)//&& (!defined (_MSC_VER) || (_MSC_VER <= 1200))
|
#if defined (USEASM) && !defined (NORUSEASM)//&& (!defined (_MSC_VER) || (_MSC_VER <= 1200))
|
||||||
|
@ -423,6 +428,10 @@ void SCR_ChangeRenderer(void)
|
||||||
CONS_Alert(CONS_ERROR, "OpenGL never loaded\n");
|
CONS_Alert(CONS_ERROR, "OpenGL never loaded\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (rendermode == render_opengl && (vid.glstate == VID_GL_LIBRARY_LOADED)) // Clear these out before switching to software
|
||||||
|
HWR_ClearAllTextures();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Set the new render mode
|
// Set the new render mode
|
||||||
|
|
Loading…
Reference in a new issue