mirror of
https://github.com/ZDoom/Raze.git
synced 2025-02-20 18:42:26 +00:00
- Exhumed: Split out velocity updating to static function.
This commit is contained in:
parent
187710e9e2
commit
eed1d14b9d
2 changed files with 31 additions and 18 deletions
|
@ -351,6 +351,33 @@ void GameMove(void)
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
static void updatePlayerVelocity(Player* const pPlayer)
|
||||
{
|
||||
const auto pInput = &pPlayer->input;
|
||||
|
||||
if (pPlayer->nHealth > 0)
|
||||
{
|
||||
const auto inputvect = DVector2(pInput->fvel, pInput->svel).Rotated(pPlayer->pActor->spr.Angles.Yaw) * 0.375;
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
pPlayer->vel += inputvect;
|
||||
pPlayer->vel *= 0.953125;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pInput->fvel = pInput->svel = pInput->avel = pInput->horz = 0;
|
||||
pPlayer->vel.Zero();
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
static void updatePlayerInventory(Player* const pPlayer)
|
||||
{
|
||||
if (const auto invDir = !!(pPlayer->input.actions & SB_INVNEXT) - !!(pPlayer->input.actions & SB_INVPREV))
|
||||
|
@ -444,7 +471,6 @@ void GameInterface::Ticker()
|
|||
{
|
||||
// Shorten some constant array accesses.
|
||||
const auto pPlayer = &PlayerList[nLocalPlayer];
|
||||
auto& pInput = pPlayer->input;
|
||||
|
||||
// this must be done before the view is backed up.
|
||||
pPlayer->Angles.resetCameraAngles();
|
||||
|
@ -453,26 +479,11 @@ void GameInterface::Ticker()
|
|||
resetForcedSyncInput();
|
||||
|
||||
// set new player input.
|
||||
pInput = playercmds[nLocalPlayer].ucmd;
|
||||
pPlayer->input = playercmds[nLocalPlayer].ucmd;
|
||||
|
||||
const auto inputvect = DVector2(pInput.fvel, pInput.svel).Rotated(pPlayer->pActor->spr.Angles.Yaw) * 0.375;
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
// Velocities are stored as Q14.18
|
||||
pPlayer->vel += inputvect;
|
||||
pPlayer->vel *= 0.953125;
|
||||
}
|
||||
UpdateInterpolations();
|
||||
|
||||
if (pPlayer->nHealth <= 0)
|
||||
{
|
||||
setForcedSyncInput();
|
||||
auto& packet = pInput;
|
||||
packet.fvel = packet.svel = packet.avel = packet.horz = 0;
|
||||
pPlayer->vel.Zero();
|
||||
}
|
||||
|
||||
updatePlayerVelocity(pPlayer);
|
||||
updatePlayerInventory(pPlayer);
|
||||
updatePlayerWeapon(pPlayer);
|
||||
|
||||
|
|
|
@ -2491,6 +2491,8 @@ sectdone:
|
|||
}
|
||||
else // else, player's health is less than 0
|
||||
{
|
||||
setForcedSyncInput();
|
||||
|
||||
// loc_1C0E9
|
||||
if (actions & SB_OPEN)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue