- Duke: Remove casts from setting RR vehicle velocities and consolidate setup into an inline.

This commit is contained in:
Mitchell Richters 2023-10-04 22:05:03 +11:00 committed by Christoph Oelckers
parent 6a06df0e45
commit 7e393e04a5
3 changed files with 16 additions and 5 deletions

View file

@ -219,7 +219,7 @@ inline int monsterCheatCheck(DDukeActor* self)
return false;
}
inline void processinputvel(DDukePlayer* const p)
inline void rotateInputVel(DDukePlayer* const p)
{
p->cmd.ucmd.vel.XY() = p->cmd.ucmd.vel.XY().Rotated(p->GetActor()->spr.Angles.Yaw) + p->fric;
}

View file

@ -1539,7 +1539,7 @@ void processinput_d(DDukePlayer* const p)
const auto strafeVel = p->cmd.ucmd.vel.Y;
constexpr auto maxVel = (117351124. / 10884538.);
processinputvel(p);
rotateInputVel(p);
auto psectp = p->cursector;
if (psectp == nullptr)

View file

@ -963,6 +963,17 @@ static void doVehicleThrottling(DDukePlayer* p, DDukeActor* pact, unsigned& flag
//
//---------------------------------------------------------------------------
static inline void setVehicleInputVel(DDukePlayer* const p)
{
p->cmd.ucmd.vel.X = clamp(p->MotoSpeed, -15., 120.) * (1. / 40.);
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
static void onMotorcycle(DDukePlayer* const p, ESyncBits &actions)
{
auto pact = p->GetActor();
@ -1032,7 +1043,7 @@ static void onMotorcycle(DDukePlayer* const p, ESyncBits &actions)
}
p->moto_on_mud = p->moto_on_oil = 0;
p->cmd.ucmd.vel.X = clamp<float>((float)p->MotoSpeed, -15.f, 120.f) * (1.f / 40.f);
setVehicleInputVel(p);
}
//---------------------------------------------------------------------------
@ -1101,7 +1112,7 @@ static void onBoat(DDukePlayer* const p, ESyncBits &actions)
if (p->NotOnWater && p->MotoSpeed > 50)
p->MotoSpeed *= 0.5;
p->cmd.ucmd.vel.X = clamp<float>((float)p->MotoSpeed, -15.f, 120.f) * (1.f / 40.f);
setVehicleInputVel(p);
}
//---------------------------------------------------------------------------
@ -2278,7 +2289,7 @@ void processinput_r(DDukePlayer* const p)
onBoat(p, actions);
}
processinputvel(p);
rotateInputVel(p);
if (psectp == nullptr)
{