diff --git a/source/core/packet.h b/source/core/packet.h index a3704b23c..162656b6a 100644 --- a/source/core/packet.h +++ b/source/core/packet.h @@ -24,8 +24,7 @@ enum ESyncBits_ : uint32_t SB_OPEN = 1 << 17, SB_AIMMODE = 1 << 18, - SB_QUICK_KICK = 1 << 19, // Duke only. - SB_CROUCH_LOCK = 1 << 19, // SW only. + SB_QUICK_KICK = 1 << 19, SB_ESCAPE = 1 << 20, SB_AIM_UP = 1 << 21, diff --git a/source/sw/src/game.h b/source/sw/src/game.h index e0a150b9b..cf3f28bcd 100644 --- a/source/sw/src/game.h +++ b/source/sw/src/game.h @@ -1004,6 +1004,7 @@ struct PLAYERstruct int cookieTime; char WpnReloadState; + bool crouch_toggle; }; extern PLAYER Player[MAX_SW_PLAYERS_REG+1]; diff --git a/source/sw/src/input.cpp b/source/sw/src/input.cpp index 2a2454347..f46ecb461 100644 --- a/source/sw/src/input.cpp +++ b/source/sw/src/input.cpp @@ -99,11 +99,8 @@ static void processInputBits(PLAYERp const pp, ControlInfo* const hidInput) RESET(Player[myconnectindex].Flags, PF_AUTO_AIM); } - if (buttonMap.ButtonDown(gamefunc_Toggle_Crouch)) - { - // this shares a bit with another function so cannot be in the common code. - loc.actions |= SB_CROUCH_LOCK; - } + // Handle crouch toggling. + checkCrouchToggle(&loc, &pp->crouch_toggle); } //--------------------------------------------------------------------------- diff --git a/source/sw/src/player.cpp b/source/sw/src/player.cpp index 8131f6f95..73c1a24b1 100644 --- a/source/sw/src/player.cpp +++ b/source/sw/src/player.cpp @@ -1521,7 +1521,7 @@ UpdatePlayerSpriteAngle(PLAYERp pp) void 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); } @@ -3788,53 +3788,14 @@ DoPlayerCrawl(PLAYERp pp) //#define PLAYER_STANDING_ROOM(pp) ((pp)->posz + PLAYER_CRAWL_HEIGHT - PLAYER_HEIGHT - PLAYER_RUN_CEILING_DIST) #define PLAYER_STANDING_ROOM Z(68) - if (TEST(pp->Flags, PF_LOCK_CRAWL)) + // Let off of crawl to get up + if (!(pp->input.actions & SB_CROUCH)) { - if (pp->input.actions & SB_CROUCH_LOCK) + if (labs(pp->loz - pp->hiz) >= PLAYER_STANDING_ROOM) { - 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 - if (!(pp->input.actions & SB_CROUCH)) - { - if (labs(pp->loz - pp->hiz) >= PLAYER_STANDING_ROOM) - { - RESET(pp->Flags, PF_CRAWLING); - DoPlayerBeginRun(pp); - return; - } + RESET(pp->Flags, PF_CRAWLING); + DoPlayerBeginRun(pp); + return; } } @@ -6785,22 +6746,6 @@ DoPlayerRun(PLAYERp pp) 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()) { DoPlayerBeginFly(pp);