- SW: Migrate crouch toggling to backend solution implemented in 4ef0d20e0e.

This commit is contained in:
Mitchell Richters 2020-11-07 17:53:11 +11:00
parent 01c494e29d
commit a153ebab7e
4 changed files with 11 additions and 69 deletions

View file

@ -24,8 +24,7 @@ enum ESyncBits_ : uint32_t
SB_OPEN = 1 << 17, SB_OPEN = 1 << 17,
SB_AIMMODE = 1 << 18, SB_AIMMODE = 1 << 18,
SB_QUICK_KICK = 1 << 19, // Duke only. SB_QUICK_KICK = 1 << 19,
SB_CROUCH_LOCK = 1 << 19, // SW only.
SB_ESCAPE = 1 << 20, SB_ESCAPE = 1 << 20,
SB_AIM_UP = 1 << 21, SB_AIM_UP = 1 << 21,

View file

@ -1004,6 +1004,7 @@ struct PLAYERstruct
int cookieTime; int cookieTime;
char WpnReloadState; char WpnReloadState;
bool crouch_toggle;
}; };
extern PLAYER Player[MAX_SW_PLAYERS_REG+1]; extern PLAYER Player[MAX_SW_PLAYERS_REG+1];

View file

@ -99,11 +99,8 @@ static void processInputBits(PLAYERp const pp, ControlInfo* const hidInput)
RESET(Player[myconnectindex].Flags, PF_AUTO_AIM); RESET(Player[myconnectindex].Flags, PF_AUTO_AIM);
} }
if (buttonMap.ButtonDown(gamefunc_Toggle_Crouch)) // Handle crouch toggling.
{ checkCrouchToggle(&loc, &pp->crouch_toggle);
// this shares a bit with another function so cannot be in the common code.
loc.actions |= SB_CROUCH_LOCK;
}
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------

View file

@ -1521,7 +1521,7 @@ UpdatePlayerSpriteAngle(PLAYERp pp)
void void
DoPlayerTurn(PLAYERp pp, float const avel, double const scaleAdjust) DoPlayerTurn(PLAYERp pp, float const avel, double const scaleAdjust)
{ {
applylook(&pp->angle, avel, &pp->input.actions, scaleAdjust, pp->input.actions & (SB_CROUCH|SB_CROUCH_LOCK)); applylook(&pp->angle, avel, &pp->input.actions, scaleAdjust, pp->input.actions & SB_CROUCH || pp->crouch_toggle);
UpdatePlayerSpriteAngle(pp); UpdatePlayerSpriteAngle(pp);
} }
@ -3788,44 +3788,6 @@ DoPlayerCrawl(PLAYERp pp)
//#define PLAYER_STANDING_ROOM(pp) ((pp)->posz + PLAYER_CRAWL_HEIGHT - PLAYER_HEIGHT - PLAYER_RUN_CEILING_DIST) //#define PLAYER_STANDING_ROOM(pp) ((pp)->posz + PLAYER_CRAWL_HEIGHT - PLAYER_HEIGHT - PLAYER_RUN_CEILING_DIST)
#define PLAYER_STANDING_ROOM Z(68) #define PLAYER_STANDING_ROOM Z(68)
if (TEST(pp->Flags, PF_LOCK_CRAWL))
{
if (pp->input.actions & SB_CROUCH_LOCK)
{
if (pp->KeyPressBits & SB_CROUCH_LOCK)
{
//if (pp->hiz < PLAYER_STANDING_ROOM(pp))
if (labs(pp->loz - pp->hiz) >= PLAYER_STANDING_ROOM)
{
pp->KeyPressBits&= ~SB_CROUCH_LOCK;
RESET(pp->Flags, PF_CRAWLING);
DoPlayerBeginRun(pp);
return;
}
}
}
else
{
pp->KeyPressBits |= SB_CROUCH_LOCK;
}
// Jump to get up
if (pp->input.actions & SB_JUMP)
{
if (labs(pp->loz - pp->hiz) >= PLAYER_STANDING_ROOM)
{
//pp->posz = pp->loz - PLAYER_HEIGHT;
RESET(pp->Flags, PF_CRAWLING);
DoPlayerBeginRun(pp);
return;
}
}
}
else
{
// Let off of crawl to get up // Let off of crawl to get up
if (!(pp->input.actions & SB_CROUCH)) if (!(pp->input.actions & SB_CROUCH))
{ {
@ -3836,7 +3798,6 @@ DoPlayerCrawl(PLAYERp pp)
return; return;
} }
} }
}
if (pp->lo_sectp && TEST(pp->lo_sectp->extra, SECTFX_CURRENT)) if (pp->lo_sectp && TEST(pp->lo_sectp->extra, SECTFX_CURRENT))
{ {
@ -6785,22 +6746,6 @@ DoPlayerRun(PLAYERp pp)
pp->KeyPressBits |= SB_JUMP; pp->KeyPressBits |= SB_JUMP;
} }
// Crawl lock
if (pp->input.actions & SB_CROUCH_LOCK)
{
if (pp->KeyPressBits & SB_CROUCH_LOCK)
{
pp->KeyPressBits &= ~SB_CROUCH_LOCK;
SET(pp->Flags, PF_LOCK_CRAWL);
DoPlayerBeginCrawl(pp);
return;
}
}
else
{
pp->KeyPressBits |= SB_CROUCH_LOCK;
}
if (PlayerFlyKey()) if (PlayerFlyKey())
{ {
DoPlayerBeginFly(pp); DoPlayerBeginFly(pp);