mirror of
https://github.com/ZDoom/Raze.git
synced 2025-02-20 10:32:27 +00:00
- Remove backend crouch toggle solution redeploy with Duke/Exhumed/Blood using new ESyncBit
bit.
* I tried to make this work in 2020 but its been nothing but headache. It's something for the game to control via a flag, not the backend to determine. * For SW, this restores its original implementation.
This commit is contained in:
parent
b9cf8a13c6
commit
272dfa762d
14 changed files with 91 additions and 41 deletions
|
@ -27,7 +27,6 @@ extern bool GUICapture;
|
|||
extern bool AppActive;
|
||||
extern cycle_t drawtime, actortime, thinktime, gameupdatetime;
|
||||
extern bool r_NoInterpolate;
|
||||
extern bool crouch_toggle;
|
||||
|
||||
struct MapRecord;
|
||||
extern MapRecord* g_nextmap;
|
||||
|
|
|
@ -58,7 +58,6 @@ static double turnheldtime = 0;
|
|||
static int WeaponToSend = 0;
|
||||
static int dpad_lock = 0;
|
||||
ESyncBits ActionsToSend = 0;
|
||||
bool crouch_toggle = false;
|
||||
|
||||
static constexpr float backendmousescale = 1.f / 16.f;
|
||||
static constexpr double YAW_TURNSPEEDS[3] = { 41.1987304, 156.555175, 272.24121 };
|
||||
|
@ -309,18 +308,15 @@ static void ApplyGlobalInput(HIDInput* const hidInput)
|
|||
if (buttonMap.ButtonDown(gamefunc_Jump))
|
||||
inputBuffer.actions |= SB_JUMP;
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Crouch) || buttonMap.ButtonDown(gamefunc_Toggle_Crouch) || crouch_toggle)
|
||||
if (buttonMap.ButtonDown(gamefunc_Crouch))
|
||||
inputBuffer.actions |= SB_CROUCH;
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Toggle_Crouch))
|
||||
{
|
||||
crouch_toggle = !crouch_toggle;
|
||||
inputBuffer.actions |= SB_CROUCH_LOCK;
|
||||
buttonMap.ClearButton(gamefunc_Toggle_Crouch);
|
||||
}
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Crouch) || buttonMap.ButtonDown(gamefunc_Jump))
|
||||
crouch_toggle = false;
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Fire))
|
||||
inputBuffer.actions |= SB_FIRE;
|
||||
|
||||
|
@ -355,6 +351,31 @@ static void ApplyGlobalInput(HIDInput* const hidInput)
|
|||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// Handle all the game-side crouch requirements.
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void processCrouchToggle(bool& toggle, ESyncBits& actions, const bool crouchable, const bool disabletoggle)
|
||||
{
|
||||
if (actions & SB_CROUCH_LOCK)
|
||||
{
|
||||
toggle = !toggle && crouchable;
|
||||
actions &= ~SB_CROUCH_LOCK;
|
||||
}
|
||||
|
||||
if ((actions & (SB_CROUCH|SB_JUMP)) || disabletoggle)
|
||||
{
|
||||
toggle = 0;
|
||||
}
|
||||
|
||||
if (toggle)
|
||||
{
|
||||
actions |= SB_CROUCH;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// Processes input and returns a packet if provided.
|
||||
|
@ -364,7 +385,6 @@ static void ApplyGlobalInput(HIDInput* const hidInput)
|
|||
void clearLocalInputBuffer()
|
||||
{
|
||||
inputBuffer = {};
|
||||
crouch_toggle = false;
|
||||
ActionsToSend = 0;
|
||||
WeaponToSend = 0;
|
||||
dpad_lock = 0;
|
||||
|
|
|
@ -89,5 +89,6 @@ struct HIDInput
|
|||
FVector2 mouse;
|
||||
};
|
||||
|
||||
void processCrouchToggle(bool& toggle, ESyncBits& actions, const bool crouchable, const bool disabletoggle);
|
||||
void processVehicleInput(HIDInput* const hidInput, InputPacket* const currInput, const double scaleAdjust, const float baseVel, const float velScale, const bool canMove, const bool canTurn, const bool attenuate);
|
||||
void getInput(const double scaleAdjust, PlayerAngles* const plrAngles, InputPacket* packet = nullptr);
|
||||
|
|
|
@ -33,11 +33,12 @@ enum ESyncBits_ : uint32_t
|
|||
SB_LOOK_RIGHT = 1 << 24,
|
||||
SB_LOOK_UP = SB_AIM_UP|SB_CENTERVIEW,
|
||||
SB_LOOK_DOWN = SB_AIM_DOWN|SB_CENTERVIEW,
|
||||
SB_CROUCH = 1 << 25,
|
||||
SB_CROUCH_LOCK = 1 << 26,
|
||||
SB_RUN = 1 << 27,
|
||||
SB_JUMP = 1 << 28,
|
||||
SB_CROUCH = 1 << 29,
|
||||
SB_FIRE = 1 << 30,
|
||||
SB_ALTFIRE = 1u << 31,
|
||||
SB_FIRE = 1 << 29,
|
||||
SB_ALTFIRE = 1 << 30,
|
||||
|
||||
SB_WEAPONMASK_BITS = (15u * SB_FIRST_WEAPON_BIT), // Weapons take up 4 bits
|
||||
SB_ITEMUSE_BITS = (127u * SB_ITEM_BIT_1),
|
||||
|
|
|
@ -89,21 +89,6 @@ END_BLD_NS
|
|||
//
|
||||
//=============================================================================
|
||||
|
||||
static void SerializeGlobals(FSerializer& arc)
|
||||
{
|
||||
if (arc.BeginObject("globals"))
|
||||
{
|
||||
arc("crouch_toggle", crouch_toggle)
|
||||
.EndObject();
|
||||
}
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
static void SerializeSession(FSerializer& arc)
|
||||
{
|
||||
// In Duke and Blood we now have reliable sound names.
|
||||
|
@ -118,7 +103,6 @@ static void SerializeSession(FSerializer& arc)
|
|||
S_SerializeSounds(arc);
|
||||
SerializeAutomap(arc);
|
||||
SerializeHud(arc);
|
||||
SerializeGlobals(arc);
|
||||
gi->SerializeGameState(arc);
|
||||
}
|
||||
|
||||
|
|
|
@ -901,6 +901,7 @@ void playerStart(int nPlayer, int bNewLevel)
|
|||
#endif
|
||||
pPlayer->hand = 0;
|
||||
pPlayer->nWaterPal = 0;
|
||||
pPlayer->crouch_toggle = false;
|
||||
playerResetPowerUps(pPlayer);
|
||||
|
||||
if (nPlayer == myconnectindex)
|
||||
|
@ -1584,6 +1585,8 @@ void ProcessInput(PLAYER* pPlayer)
|
|||
if (!(pInput->actions & SB_JUMP))
|
||||
pPlayer->cantJump = 0;
|
||||
|
||||
processCrouchToggle(pPlayer->crouch_toggle, pInput->actions, pPlayer->posture != kPostureSwim, pPlayer->posture == kPostureSwim);
|
||||
|
||||
switch (pPlayer->posture) {
|
||||
case 1:
|
||||
if (pInput->actions & SB_JUMP)
|
||||
|
@ -2485,6 +2488,7 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, PLAYER& w, PLAYER*
|
|||
("quakeeffect", w.quakeEffect)
|
||||
("player_par", w.player_par)
|
||||
("waterpal", w.nWaterPal)
|
||||
("crouch_toggle", w.crouch_toggle)
|
||||
.Array("posturedata", &w.pPosture[0][0], &gPostureDefaults[0][0], kModeMax * kPostureMax) // only save actual changes in this.
|
||||
.EndObject();
|
||||
}
|
||||
|
|
|
@ -178,6 +178,7 @@ struct PLAYER
|
|||
int quakeEffect;
|
||||
int player_par;
|
||||
int nWaterPal;
|
||||
bool crouch_toggle;
|
||||
POSTURE pPosture[kModeMax][kPostureMax];
|
||||
};
|
||||
|
||||
|
|
|
@ -69,16 +69,12 @@ void hud_input(int plnum)
|
|||
|
||||
// Set-up crouch bools.
|
||||
const int sectorLotag = p->insector() ? p->cursector->lotag : 0;
|
||||
const bool crouchable = sectorLotag != ST_2_UNDERWATER && (sectorLotag != ST_1_ABOVE_WATER || p->spritebridge);
|
||||
const bool crouchable = sectorLotag != ST_2_UNDERWATER && (sectorLotag != ST_1_ABOVE_WATER || p->spritebridge) && !p->jetpack_on;
|
||||
const bool disableToggle = p->jetpack_on || (!crouchable && p->on_ground) || (isRRRA() && (p->OnMotorcycle || p->OnBoat));
|
||||
|
||||
if (isRR() && (p->sync.actions & SB_CROUCH)) p->sync.actions &= ~SB_JUMP;
|
||||
processCrouchToggle(p->crouch_toggle, p->sync.actions, crouchable, disableToggle);
|
||||
|
||||
if (crouch_toggle && (!crouchable || disableToggle))
|
||||
{
|
||||
crouch_toggle = false;
|
||||
p->sync.actions &= ~SB_CROUCH;
|
||||
}
|
||||
if (isRR() && (p->sync.actions & SB_CROUCH)) p->sync.actions &= ~SB_JUMP;
|
||||
|
||||
if ((isRR() && p->drink_amt > 88))
|
||||
p->sync.actions |= SB_LOOK_LEFT;
|
||||
|
|
|
@ -90,6 +90,7 @@ void resetplayerstats(int snum)
|
|||
p = &ps[snum];
|
||||
|
||||
gFullMap = 0;
|
||||
p->crouch_toggle = 0;
|
||||
p->dead_flag = 0;
|
||||
p->wackedbyactor = nullptr;
|
||||
p->falling_counter = 0;
|
||||
|
|
|
@ -240,6 +240,7 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, player_struct& w,
|
|||
.Array("frags", w.frags, MAXPLAYERS)
|
||||
("uservars", w.uservars)
|
||||
("fistsign", w.fistsign)
|
||||
("crouch_toggle", w.crouch_toggle)
|
||||
.EndObject();
|
||||
|
||||
w.invdisptime = 0;
|
||||
|
|
|
@ -312,6 +312,7 @@ struct player_struct
|
|||
|
||||
TArray<GameVarValue> uservars;
|
||||
|
||||
bool crouch_toggle;
|
||||
|
||||
// input stuff.
|
||||
InputPacket sync;
|
||||
|
|
|
@ -304,6 +304,7 @@ void RestartPlayer(int nPlayer)
|
|||
pPlayer->nQuake = 0;
|
||||
pPlayer->nTemperature = 0;
|
||||
pPlayer->nStandHeight = GetActorHeight(pPlayerActor);
|
||||
pPlayer->crouch_toggle = false;
|
||||
SetTorch(nPlayer, 0);
|
||||
|
||||
if (nNetPlayerCount)
|
||||
|
@ -1217,6 +1218,8 @@ static void updatePlayerAction(Player* const pPlayer, const bool bUnderwater)
|
|||
|
||||
if (!pPlayer->bIsMummified)
|
||||
{
|
||||
processCrouchToggle(pPlayer->crouch_toggle, pPlayer->input.actions, !bUnderwater, bUnderwater);
|
||||
|
||||
if (pPlayer->input.actions & SB_JUMP)
|
||||
{
|
||||
if (bUnderwater)
|
||||
|
@ -2098,6 +2101,7 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, Player& w, Player*
|
|||
("save", w.sPlayerSave)
|
||||
("totalvel", w.totalvel)
|
||||
("grenade", w.pPlayerGrenade)
|
||||
("crouch_toggle", w.crouch_toggle)
|
||||
|
||||
.EndObject();
|
||||
}
|
||||
|
|
|
@ -103,6 +103,7 @@ struct Player
|
|||
PlayerSave sPlayerSave;
|
||||
int ototalvel;
|
||||
int totalvel;
|
||||
bool crouch_toggle;
|
||||
TObjPtr<DExhumedActor*> pPlayerGrenade;
|
||||
TObjPtr<DExhumedActor*> pPlayerFloorSprite;
|
||||
TObjPtr<DExhumedActor*> pDoppleSprite;
|
||||
|
|
|
@ -3535,18 +3535,38 @@ void DoPlayerCrawl(PLAYER* pp)
|
|||
return;
|
||||
}
|
||||
|
||||
// Current Z position, adjust down to the floor, adjust to player height,
|
||||
// adjust for "bump head"
|
||||
|
||||
// Let off of crawl to get up
|
||||
if (!(pp->input.actions & SB_CROUCH))
|
||||
if (pp->Flags & PF_LOCK_CRAWL)
|
||||
{
|
||||
if (abs(pp->loz - pp->hiz) >= PLAYER_STANDING_ROOM)
|
||||
if (pp->input.actions & SB_CROUCH_LOCK)
|
||||
{
|
||||
pp->Flags &= ~(PF_CRAWLING);
|
||||
if ((pp->KeyPressBits & SB_CROUCH_LOCK) && abs(pp->loz - pp->hiz) >= PLAYER_STANDING_ROOM)
|
||||
{
|
||||
pp->KeyPressBits &= ~SB_CROUCH_LOCK;
|
||||
pp->Flags &= ~PF_CRAWLING;
|
||||
DoPlayerBeginRun(pp);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pp->KeyPressBits |= SB_CROUCH_LOCK;
|
||||
}
|
||||
|
||||
// Jump to get up
|
||||
if ((pp->input.actions & (SB_JUMP|SB_CROUCH)) && abs(pp->loz - pp->hiz) >= PLAYER_STANDING_ROOM)
|
||||
{
|
||||
pp->Flags &= ~PF_CRAWLING;
|
||||
DoPlayerBeginRun(pp);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
else if (!(pp->input.actions & SB_CROUCH) && abs(pp->loz - pp->hiz) >= PLAYER_STANDING_ROOM)
|
||||
{
|
||||
// Let off of crawl to get up
|
||||
pp->Flags &= ~PF_CRAWLING;
|
||||
DoPlayerBeginRun(pp);
|
||||
return;
|
||||
}
|
||||
|
||||
if (pp->lo_sectp && (pp->lo_sectp->extra & SECTFX_CURRENT))
|
||||
|
@ -6494,6 +6514,22 @@ void DoPlayerRun(PLAYER* 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;
|
||||
pp->Flags |= PF_LOCK_CRAWL;
|
||||
DoPlayerBeginCrawl(pp);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pp->KeyPressBits |= SB_CROUCH_LOCK;
|
||||
}
|
||||
|
||||
if (PlayerFlyKey())
|
||||
{
|
||||
DoPlayerBeginFly(pp);
|
||||
|
|
Loading…
Reference in a new issue