mirror of
https://github.com/ZDoom/Raze.git
synced 2025-01-19 07:01:09 +00:00
- Internalise player InputPacket
access.
This commit is contained in:
parent
531c95c7ca
commit
ce75f7d7ef
8 changed files with 51 additions and 52 deletions
|
@ -68,40 +68,40 @@ CUSTOM_CVAR(Int, cl_viewtilting, 0, CVAR_GLOBALCONFIG | CVAR_ARCHIVE)
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void DCorePlayer::doPitchInput(InputPacket* const input)
|
||||
void DCorePlayer::doPitchInput()
|
||||
{
|
||||
// Add player's mouse/device input.
|
||||
if (input->ang.Pitch.Degrees())
|
||||
if (cmd.ucmd.ang.Pitch.Degrees())
|
||||
{
|
||||
actor->spr.Angles.Pitch += input->ang.Pitch * gameInput.SyncInput();
|
||||
input->actions &= ~SB_CENTERVIEW;
|
||||
actor->spr.Angles.Pitch += cmd.ucmd.ang.Pitch * gameInput.SyncInput();
|
||||
cmd.ucmd.actions &= ~SB_CENTERVIEW;
|
||||
}
|
||||
|
||||
// Set up a myriad of bools.
|
||||
const auto aimingUp = (input->actions & SB_LOOK_UP) == SB_AIM_UP;
|
||||
const auto aimingDown = (input->actions & SB_LOOK_DOWN) == SB_AIM_DOWN;
|
||||
const auto lookingUp = (input->actions & SB_LOOK_UP) == SB_LOOK_UP;
|
||||
const auto lookingDown = (input->actions & SB_LOOK_DOWN) == SB_LOOK_DOWN;
|
||||
const auto aimingUp = (cmd.ucmd.actions & SB_LOOK_UP) == SB_AIM_UP;
|
||||
const auto aimingDown = (cmd.ucmd.actions & SB_LOOK_DOWN) == SB_AIM_DOWN;
|
||||
const auto lookingUp = (cmd.ucmd.actions & SB_LOOK_UP) == SB_LOOK_UP;
|
||||
const auto lookingDown = (cmd.ucmd.actions & SB_LOOK_DOWN) == SB_LOOK_DOWN;
|
||||
|
||||
// Process keyboard input.
|
||||
if (const auto aiming = aimingDown - aimingUp)
|
||||
{
|
||||
actor->spr.Angles.Pitch += getTicrateAngle(PITCH_AIMSPEED * aiming);
|
||||
input->actions &= ~SB_CENTERVIEW;
|
||||
cmd.ucmd.actions &= ~SB_CENTERVIEW;
|
||||
}
|
||||
if (const auto looking = lookingDown - lookingUp)
|
||||
{
|
||||
actor->spr.Angles.Pitch += getTicrateAngle(PITCH_LOOKSPEED * looking);
|
||||
input->actions |= SB_CENTERVIEW;
|
||||
cmd.ucmd.actions |= SB_CENTERVIEW;
|
||||
}
|
||||
|
||||
// Do return to centre.
|
||||
if ((input->actions & SB_CENTERVIEW) && !(lookingUp || lookingDown))
|
||||
if ((cmd.ucmd.actions & SB_CENTERVIEW) && !(lookingUp || lookingDown))
|
||||
{
|
||||
const auto pitch = abs(actor->spr.Angles.Pitch);
|
||||
const auto scale = pitch > PITCH_CNTRSINEOFFSET ? (pitch - PITCH_CNTRSINEOFFSET).Cos() : 1.;
|
||||
if (scaletozero(actor->spr.Angles.Pitch, PITCH_CENTERSPEED * scale))
|
||||
input->actions &= ~SB_CENTERVIEW;
|
||||
cmd.ucmd.actions &= ~SB_CENTERVIEW;
|
||||
}
|
||||
|
||||
// clamp before we finish, factoring in the player's view pitch offset.
|
||||
|
@ -117,25 +117,25 @@ void DCorePlayer::doPitchInput(InputPacket* const input)
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void DCorePlayer::doYawInput(InputPacket* const input)
|
||||
void DCorePlayer::doYawInput()
|
||||
{
|
||||
// Add player's mouse/device input.
|
||||
actor->spr.Angles.Yaw += input->ang.Yaw * gameInput.SyncInput();
|
||||
actor->spr.Angles.Yaw += cmd.ucmd.ang.Yaw * gameInput.SyncInput();
|
||||
|
||||
if (input->actions & SB_TURNAROUND)
|
||||
if (cmd.ucmd.actions & SB_TURNAROUND)
|
||||
{
|
||||
if (YawSpin == nullAngle)
|
||||
{
|
||||
// currently not spinning, so start a spin
|
||||
YawSpin = -DAngle180;
|
||||
}
|
||||
input->actions &= ~SB_TURNAROUND;
|
||||
cmd.ucmd.actions &= ~SB_TURNAROUND;
|
||||
}
|
||||
|
||||
if (YawSpin < nullAngle)
|
||||
{
|
||||
// return spin to 0
|
||||
DAngle add = getTicrateAngle(!(input->actions & SB_CROUCH) ? YAW_SPINSTAND : YAW_SPINCROUCH);
|
||||
DAngle add = getTicrateAngle(!(cmd.ucmd.actions & SB_CROUCH) ? YAW_SPINSTAND : YAW_SPINCROUCH);
|
||||
YawSpin += add;
|
||||
if (YawSpin > nullAngle)
|
||||
{
|
||||
|
@ -206,14 +206,14 @@ void DCorePlayer::doViewPitch(const bool canslopetilt, const bool climbing)
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void DCorePlayer::doViewYaw(InputPacket* const input)
|
||||
void DCorePlayer::doViewYaw()
|
||||
{
|
||||
// Process angle return to zeros.
|
||||
scaletozero(ViewAngles.Yaw, YAW_LOOKRETURN);
|
||||
scaletozero(ViewAngles.Roll, YAW_LOOKRETURN);
|
||||
|
||||
// Process keyboard input.
|
||||
if (const auto looking = !!(input->actions & SB_LOOK_RIGHT) - !!(input->actions & SB_LOOK_LEFT))
|
||||
if (const auto looking = !!(cmd.ucmd.actions & SB_LOOK_RIGHT) - !!(cmd.ucmd.actions & SB_LOOK_LEFT))
|
||||
{
|
||||
ViewAngles.Yaw += getTicrateAngle(YAW_LOOKINGSPEED * looking);
|
||||
ViewAngles.Roll += getTicrateAngle(YAW_ROTATESPEED * looking);
|
||||
|
@ -227,20 +227,20 @@ void DCorePlayer::doViewYaw(InputPacket* const input)
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void DCorePlayer::doRollInput(InputPacket* const input, const DVector2& nVelVect, const double nMaxVel, const bool bUnderwater)
|
||||
void DCorePlayer::doRollInput(const DVector2& nVelVect, const double nMaxVel, const bool bUnderwater)
|
||||
{
|
||||
// Allow viewtilting if we're not in a VR mode.
|
||||
if (!vr_mode)
|
||||
{
|
||||
// Scale/attenuate tilting based on player actions.
|
||||
const auto rollAmp = cl_viewtiltscale / (1 + bUnderwater);
|
||||
const auto runScale = 1. / (1 + !(input->actions & SB_RUN));
|
||||
const auto strafeScale = 1 + !!input->vel.Y;
|
||||
const auto runScale = 1. / (1 + !(cmd.ucmd.actions & SB_RUN));
|
||||
const auto strafeScale = 1 + !!cmd.ucmd.vel.Y;
|
||||
|
||||
if (cl_viewtilting == 1)
|
||||
{
|
||||
// Console-like yaw rolling. Adjustment == ~(90/32) for keyboard turning. Clamp is 1.5x this value.
|
||||
const auto rollAdj = input->ang.Yaw * ROLL_TILTAVELSCALE * rollAmp;
|
||||
const auto rollAdj = cmd.ucmd.ang.Yaw * ROLL_TILTAVELSCALE * rollAmp;
|
||||
const auto rollMax = ROLL_TILTAVELMAX * cl_viewtiltscale;
|
||||
scaletozero(actor->spr.Angles.Roll, ROLL_TILTRETURN);
|
||||
actor->spr.Angles.Roll = clamp(actor->spr.Angles.Roll + rollAdj, -rollMax, rollMax);
|
||||
|
@ -268,6 +268,6 @@ void DCorePlayer::doRollInput(InputPacket* const input, const DVector2& nVelVect
|
|||
else
|
||||
{
|
||||
// Add player's device input.
|
||||
actor->spr.Angles.Roll += input->ang.Roll * gameInput.SyncInput();
|
||||
actor->spr.Angles.Roll += cmd.ucmd.ang.Roll * gameInput.SyncInput();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,11 +38,11 @@ public:
|
|||
virtual DCoreActor* GetActor() = 0;
|
||||
|
||||
// Angle prototypes.
|
||||
void doPitchInput(InputPacket* const input);
|
||||
void doYawInput(InputPacket* const input);
|
||||
void doPitchInput();
|
||||
void doYawInput();
|
||||
void doViewPitch(const bool canslopetilt, const bool climbing = false);
|
||||
void doViewYaw(InputPacket* const input);
|
||||
void doRollInput(InputPacket* const input, const DVector2& nVelVect, const double nMaxVel, const bool bUnderwater);
|
||||
void doViewYaw();
|
||||
void doRollInput(const DVector2& nVelVect, const double nMaxVel, const bool bUnderwater);
|
||||
|
||||
// Angle methods.
|
||||
void InitAngles(const DAngle viewyaw = nullAngle)
|
||||
|
|
|
@ -6055,7 +6055,7 @@ static void actCheckDudes()
|
|||
nDrag -= Scale(nDrag, (double)actor->xspr.height, 256.);
|
||||
|
||||
constexpr auto maxVel = (36211. / 3000.);
|
||||
pPlayer->doRollInput(&pPlayer->cmd.ucmd, actor->vel.XY(), maxVel, false);
|
||||
pPlayer->doRollInput(actor->vel.XY(), maxVel, false);
|
||||
pPlayer->StrafeVel -= pPlayer->StrafeVel * nDrag;
|
||||
}
|
||||
|
||||
|
|
|
@ -1581,8 +1581,8 @@ void ProcessInput(DBloodPlayer* pPlayer)
|
|||
pPlayer->StrafeVel += pInput->vel.Y * svAccel * speed;
|
||||
}
|
||||
|
||||
pPlayer->doViewYaw(pInput);
|
||||
pPlayer->doYawInput(pInput);
|
||||
pPlayer->doViewYaw();
|
||||
pPlayer->doYawInput();
|
||||
|
||||
if (!(pInput->actions & SB_JUMP))
|
||||
pPlayer->cantJump = 0;
|
||||
|
@ -1707,7 +1707,7 @@ void ProcessInput(DBloodPlayer* pPlayer)
|
|||
|
||||
const int florhit = pPlayer->GetActor()->hit.florhit.type;
|
||||
pPlayer->doViewPitch(actor->xspr.height < 16 && (florhit == kHitSector || florhit == 0));
|
||||
pPlayer->doPitchInput(pInput);
|
||||
pPlayer->doPitchInput();
|
||||
|
||||
pPlayer->slope = pPlayer->GetActor()->spr.Angles.Pitch.Tan();
|
||||
if (pInput->actions & SB_INVPREV)
|
||||
|
|
|
@ -1665,7 +1665,7 @@ void processinput_d(DDukePlayer* const p)
|
|||
doubvel = TICSPERFRAME;
|
||||
|
||||
checklook(p, actions);
|
||||
p->doViewYaw(&p->cmd.ucmd);
|
||||
p->doViewYaw();
|
||||
|
||||
p->updatecentering();
|
||||
|
||||
|
@ -1708,7 +1708,7 @@ void processinput_d(DDukePlayer* const p)
|
|||
gameInput.ForceInputSync(p->pnum);
|
||||
}
|
||||
|
||||
p->doYawInput(&p->cmd.ucmd);
|
||||
p->doYawInput();
|
||||
|
||||
purplelavacheck(p);
|
||||
|
||||
|
@ -1812,7 +1812,7 @@ void processinput_d(DDukePlayer* const p)
|
|||
}
|
||||
}
|
||||
|
||||
p->doRollInput(&p->cmd.ucmd, p->vel.XY(), maxVel, (psectlotag == 1) || (psectlotag == 2));
|
||||
p->doRollInput(p->vel.XY(), maxVel, (psectlotag == 1) || (psectlotag == 2));
|
||||
|
||||
HORIZONLY:
|
||||
|
||||
|
@ -1928,7 +1928,7 @@ HORIZONLY:
|
|||
playerAimDown(p, actions);
|
||||
}
|
||||
|
||||
p->doPitchInput(&p->cmd.ucmd);
|
||||
p->doPitchInput();
|
||||
|
||||
p->checkhardlanding();
|
||||
|
||||
|
|
|
@ -2486,7 +2486,7 @@ void processinput_r(DDukePlayer* const p)
|
|||
doubvel = TICSPERFRAME;
|
||||
|
||||
checklook(p, actions);
|
||||
p->doViewYaw(&p->cmd.ucmd);
|
||||
p->doViewYaw();
|
||||
p->apply_seasick();
|
||||
|
||||
p->updatecentering();
|
||||
|
@ -2545,7 +2545,7 @@ void processinput_r(DDukePlayer* const p)
|
|||
gameInput.ForceInputSync(p->pnum);
|
||||
}
|
||||
|
||||
p->doYawInput(&p->cmd.ucmd);
|
||||
p->doYawInput();
|
||||
|
||||
purplelavacheck(p);
|
||||
|
||||
|
@ -2703,7 +2703,7 @@ void processinput_r(DDukePlayer* const p)
|
|||
|
||||
if (!p->OnMotorcycle && !p->OnBoat)
|
||||
{
|
||||
p->doRollInput(&p->cmd.ucmd, p->vel.XY(), maxVel, (psectlotag == 1) || (psectlotag == 2));
|
||||
p->doRollInput(p->vel.XY(), maxVel, (psectlotag == 1) || (psectlotag == 2));
|
||||
}
|
||||
|
||||
HORIZONLY:
|
||||
|
@ -2895,7 +2895,7 @@ HORIZONLY:
|
|||
pact->spr.Angles.Pitch += maphoriz(d);
|
||||
}
|
||||
|
||||
p->doPitchInput(&p->cmd.ucmd);
|
||||
p->doPitchInput();
|
||||
|
||||
p->checkhardlanding();
|
||||
|
||||
|
|
|
@ -1555,7 +1555,7 @@ static void doPlayerCameraEffects(DExhumedPlayer* const pPlayer, const double nD
|
|||
doPlayerVertPanning(pPlayer, nDestVertPan * cl_slopetilting);
|
||||
|
||||
// Roll tilting effect, either console or Quake-style.
|
||||
pPlayer->doRollInput(&pPlayer->cmd.ucmd, pPlayerActor->vel.XY(), maxVel, nUnderwater);
|
||||
pPlayer->doRollInput(pPlayerActor->vel.XY(), maxVel, nUnderwater);
|
||||
|
||||
// Update Z bobbing.
|
||||
if (cl_viewbob)
|
||||
|
@ -1813,10 +1813,9 @@ static bool doPlayerInput(DExhumedPlayer* const pPlayer)
|
|||
return false;
|
||||
|
||||
// update player yaw here as per the original workflow.
|
||||
const auto pInput = &pPlayer->cmd.ucmd;
|
||||
pPlayer->doViewYaw(pInput);
|
||||
pPlayer->doYawInput(pInput);
|
||||
pPlayer->doPitchInput(pInput);
|
||||
pPlayer->doViewYaw();
|
||||
pPlayer->doYawInput();
|
||||
pPlayer->doPitchInput();
|
||||
|
||||
if (nMove.type || nMove.exbits)
|
||||
{
|
||||
|
|
|
@ -1850,8 +1850,8 @@ void DoPlayerMove(DSWPlayer* pp)
|
|||
|
||||
SlipSlope(pp);
|
||||
|
||||
pp->doViewYaw(&pp->cmd.ucmd);
|
||||
pp->doYawInput(&pp->cmd.ucmd);
|
||||
pp->doViewYaw();
|
||||
pp->doYawInput();
|
||||
UpdatePlayerSpriteAngle(pp);
|
||||
|
||||
pp->lastcursector = pp->cursector;
|
||||
|
@ -1900,7 +1900,7 @@ void DoPlayerMove(DSWPlayer* pp)
|
|||
actor->vel.X = pp->vect.Length();
|
||||
|
||||
constexpr auto maxVel = (380401538. / 36022361.);
|
||||
pp->doRollInput(&pp->cmd.ucmd, pp->vect, maxVel, pp->Flags & (PF_SWIMMING|PF_DIVING));
|
||||
pp->doRollInput(pp->vect, maxVel, pp->Flags & (PF_SWIMMING|PF_DIVING));
|
||||
|
||||
if (pp->Flags & (PF_CLIP_CHEAT))
|
||||
{
|
||||
|
@ -1981,7 +1981,7 @@ void DoPlayerMove(DSWPlayer* pp)
|
|||
DoPlayerSetWadeDepth(pp);
|
||||
|
||||
DoPlayerSlopeTilting(pp);
|
||||
pp->doPitchInput(&pp->cmd.ucmd);
|
||||
pp->doPitchInput();
|
||||
|
||||
if (pp->insector() && (pp->cursector->extra & SECTFX_DYNAMIC_AREA))
|
||||
{
|
||||
|
@ -2567,7 +2567,7 @@ void DoPlayerMoveVehicle(DSWPlayer* pp)
|
|||
pp->cursector = save_sect; // for speed
|
||||
|
||||
DoPlayerSlopeTilting(pp);
|
||||
pp->doPitchInput(&pp->cmd.ucmd);
|
||||
pp->doPitchInput();
|
||||
|
||||
DoTankTreads(pp);
|
||||
}
|
||||
|
@ -2623,7 +2623,7 @@ void DoPlayerMoveTurret(DSWPlayer* pp)
|
|||
pp->Flags |= (PF_PLAYER_MOVED);
|
||||
|
||||
DoPlayerSlopeTilting(pp);
|
||||
pp->doPitchInput(&pp->cmd.ucmd);
|
||||
pp->doPitchInput();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
@ -3208,7 +3208,7 @@ void DoPlayerClimb(DSWPlayer* pp)
|
|||
ChangeActorSect(pp->GetActor(), pp->cursector);
|
||||
|
||||
DoPlayerSlopeTilting(pp);
|
||||
pp->doPitchInput(&pp->cmd.ucmd);
|
||||
pp->doPitchInput();
|
||||
|
||||
if (FAF_ConnectArea(pp->cursector))
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue