mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-14 08:30:35 +00:00
- Tidy up PlayerAngles::doPitchKeys()
interface by passing the whole sync packet through.
This commit is contained in:
parent
9ffc65fa48
commit
62561d863e
7 changed files with 20 additions and 19 deletions
|
@ -167,30 +167,31 @@ void processMovement(InputPacket* const currInput, InputPacket* const inputBuffe
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void PlayerAngles::doPitchKeys(ESyncBits* actions, const bool stopcentering)
|
||||
void PlayerAngles::doPitchKeys(InputPacket* const input)
|
||||
{
|
||||
// Cancel return to center if conditions met.
|
||||
if (stopcentering) *actions &= ~SB_CENTERVIEW;
|
||||
if (input->horz)
|
||||
input->actions &= ~SB_CENTERVIEW;
|
||||
|
||||
// Process keyboard input.
|
||||
if (auto aiming = !!(*actions & SB_AIM_DOWN) - !!(*actions & SB_AIM_UP))
|
||||
if (const auto aiming = !!(input->actions & SB_AIM_DOWN) - !!(input->actions & SB_AIM_UP))
|
||||
{
|
||||
pActor->spr.Angles.Pitch += DAngle::fromDeg(getTicrateScale(PITCH_AIMSPEED)) * aiming;
|
||||
*actions &= ~SB_CENTERVIEW;
|
||||
pActor->spr.Angles.Pitch += DAngle::fromDeg(getTicrateScale(PITCH_AIMSPEED) * aiming);
|
||||
input->actions &= ~SB_CENTERVIEW;
|
||||
}
|
||||
if (auto looking = !!(*actions & SB_LOOK_DOWN) - !!(*actions & SB_LOOK_UP))
|
||||
if (const auto looking = !!(input->actions & SB_LOOK_DOWN) - !!(input->actions & SB_LOOK_UP))
|
||||
{
|
||||
pActor->spr.Angles.Pitch += DAngle::fromDeg(getTicrateScale(PITCH_LOOKSPEED)) * looking;
|
||||
*actions |= SB_CENTERVIEW;
|
||||
pActor->spr.Angles.Pitch += DAngle::fromDeg(getTicrateScale(PITCH_LOOKSPEED) * looking);
|
||||
input->actions |= SB_CENTERVIEW;
|
||||
}
|
||||
|
||||
// Do return to centre.
|
||||
if ((*actions & SB_CENTERVIEW) && !(*actions & (SB_LOOK_UP|SB_LOOK_DOWN)))
|
||||
if ((input->actions & SB_CENTERVIEW) && !(input->actions & (SB_LOOK_UP|SB_LOOK_DOWN)))
|
||||
{
|
||||
const auto pitch = abs(pActor->spr.Angles.Pitch);
|
||||
const auto scale = pitch > PITCH_CNTRSINEOFFSET ? (pitch - PITCH_CNTRSINEOFFSET).Cos() : 1.;
|
||||
if (scaletozero(pActor->spr.Angles.Pitch, PITCH_CENTERSPEED * scale))
|
||||
*actions &= ~SB_CENTERVIEW;
|
||||
input->actions &= ~SB_CENTERVIEW;
|
||||
}
|
||||
|
||||
// clamp before we finish, factoring in the player's view pitch offset.
|
||||
|
|
|
@ -20,7 +20,7 @@ struct PlayerAngles
|
|||
friend FSerializer& Serialize(FSerializer& arc, const char* keyname, PlayerAngles& w, PlayerAngles* def);
|
||||
|
||||
// Prototypes.
|
||||
void doPitchKeys(ESyncBits* actions, const bool stopcentering);
|
||||
void doPitchKeys(InputPacket* const input);
|
||||
void doYawKeys(ESyncBits* actions);
|
||||
void doViewPitch(const bool canslopetilt, const bool climbing = false);
|
||||
void doViewYaw(const ESyncBits actions);
|
||||
|
|
|
@ -1705,7 +1705,7 @@ void ProcessInput(PLAYER* pPlayer)
|
|||
|
||||
const int florhit = pPlayer->actor->hit.florhit.type;
|
||||
pPlayer->Angles.doViewPitch(actor->xspr.height < 16 && (florhit == kHitSector || florhit == 0));
|
||||
pPlayer->Angles.doPitchKeys(&pInput->actions, pInput->horz);
|
||||
pPlayer->Angles.doPitchKeys(pInput);
|
||||
|
||||
pPlayer->slope = pPlayer->actor->spr.Angles.Pitch.Tan();
|
||||
if (pInput->actions & SB_INVPREV)
|
||||
|
|
|
@ -2988,7 +2988,7 @@ HORIZONLY:
|
|||
p->GetActor()->spr.Angles.Pitch += GetPlayerHorizon(snum);
|
||||
}
|
||||
|
||||
p->Angles.doPitchKeys(&actions, GetPlayerHorizon(snum).Sgn());
|
||||
p->Angles.doPitchKeys(&p->sync);
|
||||
|
||||
p->checkhardlanding();
|
||||
|
||||
|
|
|
@ -3802,7 +3802,7 @@ HORIZONLY:
|
|||
p->GetActor()->spr.Angles.Pitch += GetPlayerHorizon(snum);
|
||||
}
|
||||
|
||||
p->Angles.doPitchKeys(&actions, GetPlayerHorizon(snum).Sgn());
|
||||
p->Angles.doPitchKeys(&p->sync);
|
||||
|
||||
p->checkhardlanding();
|
||||
|
||||
|
|
|
@ -2471,7 +2471,7 @@ sectdone:
|
|||
pPlayer->pActor->spr.Angles.Pitch += DAngle::fromDeg(PlayerList[nPlayer].input.horz);
|
||||
}
|
||||
|
||||
pPlayer->Angles.doPitchKeys(&PlayerList[nLocalPlayer].input.actions, PlayerList[nPlayer].input.pan);
|
||||
pPlayer->Angles.doPitchKeys(&PlayerList[nLocalPlayer].input);
|
||||
|
||||
if (actions & (SB_AIM_UP | SB_AIM_DOWN) || PlayerList[nPlayer].input.horz)
|
||||
{
|
||||
|
|
|
@ -2163,7 +2163,7 @@ void DoPlayerMove(PLAYER* pp)
|
|||
pp->actor->spr.Angles.Pitch += DAngle::fromDeg(pp->input.horz);
|
||||
}
|
||||
|
||||
pp->Angles.doPitchKeys(&pp->input.actions, pp->input.horz);
|
||||
pp->Angles.doPitchKeys(&pp->input);
|
||||
|
||||
DoPlayerSlopeTilting(pp);
|
||||
|
||||
|
@ -2750,7 +2750,7 @@ void DoPlayerMoveVehicle(PLAYER* pp)
|
|||
pp->actor->spr.Angles.Pitch += DAngle::fromDeg(pp->input.horz);
|
||||
}
|
||||
|
||||
pp->Angles.doPitchKeys(&pp->input.actions, pp->input.horz);
|
||||
pp->Angles.doPitchKeys(&pp->input);
|
||||
|
||||
DoPlayerSlopeTilting(pp);
|
||||
|
||||
|
@ -2796,7 +2796,7 @@ void DoPlayerMoveTurret(PLAYER* pp)
|
|||
pp->actor->spr.Angles.Pitch += DAngle::fromDeg(pp->input.horz);
|
||||
}
|
||||
|
||||
pp->Angles.doPitchKeys(&pp->input.actions, pp->input.horz);
|
||||
pp->Angles.doPitchKeys(&pp->input);
|
||||
|
||||
DoPlayerSlopeTilting(pp);
|
||||
}
|
||||
|
@ -3398,7 +3398,7 @@ void DoPlayerClimb(PLAYER* pp)
|
|||
pp->actor->spr.Angles.Pitch += DAngle::fromDeg(pp->input.horz);
|
||||
}
|
||||
|
||||
pp->Angles.doPitchKeys(&pp->input.actions, pp->input.horz);
|
||||
pp->Angles.doPitchKeys(&pp->input);
|
||||
|
||||
DoPlayerSlopeTilting(pp);
|
||||
|
||||
|
|
Loading…
Reference in a new issue