- Interalise slope tilting checks for DCorePlayer::doViewPitch().

This commit is contained in:
Mitchell Richters 2023-10-29 20:25:43 +11:00 committed by Christoph Oelckers
parent 59366d3ffc
commit 1c725377ea
9 changed files with 25 additions and 25 deletions

View file

@ -154,9 +154,9 @@ void DCorePlayer::doYawInput()
//
//---------------------------------------------------------------------------
void DCorePlayer::doViewPitch(const bool canslopetilt, const bool climbing)
void DCorePlayer::doViewPitch(const bool climbing)
{
if (cl_slopetilting && canslopetilt)
if (cl_slopetilting && canSlopeTilt())
{
const auto actorsect = actor->sector();
if (actorsect && (actorsect->floorstat & CSTAT_SECTOR_SLOPE)) // If the floor is sloped

View file

@ -36,13 +36,14 @@ public:
// All overridable methods.
virtual DCoreActor* GetActor() = 0;
virtual const bool canSlopeTilt() const { return false; }
virtual const DVector2& GetInputVelocity() const { return actor->vel.XY(); }
virtual const double GetMaxInputVel() const = 0;
// Angle prototypes.
void doPitchInput();
void doYawInput();
void doViewPitch(const bool canslopetilt, const bool climbing = false);
void doViewPitch(const bool climbing = false);
void doViewYaw();
void doRollInput(const bool bUnderwater);

View file

@ -276,6 +276,13 @@ public:
{
return (36211. / 3000.);
}
const bool canSlopeTilt() const override
{
const auto pActor = static_cast<DBloodActor*>(actor);
const int florhit = pActor->hit.florhit.type;
return pActor->xspr.height < 16 && (florhit == kHitSector || florhit == 0);
}
};
inline DBloodPlayer* getPlayer(int index)

View file

@ -1705,8 +1705,7 @@ void ProcessInput(DBloodPlayer* pPlayer)
pInput->actions &= ~SB_OPEN;
}
const int florhit = pPlayer->GetActor()->hit.florhit.type;
pPlayer->doViewPitch(actor->xspr.height < 16 && (florhit == kHitSector || florhit == 0));
pPlayer->doViewPitch();
pPlayer->doPitchInput();
pPlayer->slope = pPlayer->GetActor()->spr.Angles.Pitch.Tan();

View file

@ -1569,7 +1569,7 @@ void processinput_d(DDukePlayer* const p)
pact->floorz = floorz;
pact->ceilingz = ceilingz;
p->doslopetilting();
p->doViewPitch();
if (chz.type == kHitSprite)
{

View file

@ -2346,7 +2346,7 @@ void processinput_r(DDukePlayer* const p)
pact->floorz = floorz;
pact->ceilingz = ceilingz;
p->doslopetilting();
p->doViewPitch();
if (chz.type == kHitSprite)
{

View file

@ -405,9 +405,9 @@ public:
}
}
inline void doslopetilting()
const bool canSlopeTilt() const override
{
doViewPitch(aim_mode == 0 && on_ground && cursector->lotag != ST_2_UNDERWATER);
return aim_mode == 0 && on_ground && cursector->lotag != ST_2_UNDERWATER;
}
inline bool itemUsed(int num)

View file

@ -1856,6 +1856,11 @@ public:
return vect;
}
const bool canSlopeTilt() const override
{
return (cmd.ucmd.actions & SB_AIMMODE) && !(Flags & (PF_FLYING|PF_SWIMMING|PF_DIVING|PF_CLIMBING|PF_JUMPING|PF_FALLING));
}
inline DSWActor* GetActor() override
{
return static_cast<DSWActor*>(actor);

View file

@ -1487,18 +1487,6 @@ void SlipSlope(DSWPlayer* pp)
//
//---------------------------------------------------------------------------
void DoPlayerSlopeTilting(DSWPlayer* pp)
{
const bool canslopetilt = (pp->cmd.ucmd.actions & SB_AIMMODE) && !(pp->Flags & (PF_FLYING|PF_SWIMMING|PF_DIVING|PF_CLIMBING|PF_JUMPING|PF_FALLING));
pp->doViewPitch(canslopetilt, pp->Flags & PF_CLIMBING);
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void DoPlayerBob(DSWPlayer* pp)
{
double amt;
@ -1979,7 +1967,7 @@ void DoPlayerMove(DSWPlayer* pp)
DoPlayerSetWadeDepth(pp);
DoPlayerSlopeTilting(pp);
pp->doViewPitch(pp->Flags & PF_CLIMBING);
pp->doPitchInput();
if (pp->insector() && (pp->cursector->extra & SECTFX_DYNAMIC_AREA))
@ -2565,7 +2553,7 @@ void DoPlayerMoveVehicle(DSWPlayer* pp)
OperateSectorObject(pp->sop, plActor->spr.Angles.Yaw, plActor->spr.pos.XY());
pp->cursector = save_sect; // for speed
DoPlayerSlopeTilting(pp);
pp->doViewPitch(pp->Flags & PF_CLIMBING);
pp->doPitchInput();
DoTankTreads(pp);
@ -2621,7 +2609,7 @@ void DoPlayerMoveTurret(DSWPlayer* pp)
else
pp->Flags |= (PF_PLAYER_MOVED);
DoPlayerSlopeTilting(pp);
pp->doViewPitch(pp->Flags & PF_CLIMBING);
pp->doPitchInput();
}
@ -3206,7 +3194,7 @@ void DoPlayerClimb(DSWPlayer* pp)
// setsprite to players location
ChangeActorSect(pp->GetActor(), pp->cursector);
DoPlayerSlopeTilting(pp);
pp->doViewPitch(pp->Flags & PF_CLIMBING);
pp->doPitchInput();
if (FAF_ConnectArea(pp->cursector))