From 4afb6e3be9a65f2e9581c460bfe5bd46324e00d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Mu=C3=B1oz?= Date: Mon, 9 Dec 2024 09:20:17 -0300 Subject: [PATCH] Move SV_CheckMovingGround into SV_Physics (#1045) --- rehlds/engine/sv_phys.cpp | 23 +---------------------- rehlds/engine/sv_user.cpp | 24 +++++++++++------------- 2 files changed, 12 insertions(+), 35 deletions(-) diff --git a/rehlds/engine/sv_phys.cpp b/rehlds/engine/sv_phys.cpp index 8fff595..520bbf3 100644 --- a/rehlds/engine/sv_phys.cpp +++ b/rehlds/engine/sv_phys.cpp @@ -1491,28 +1491,7 @@ void SV_Physics() if (i > 0 && i <= g_psvs.maxclients) continue; - if (ent->v.flags & FL_ONGROUND) - { - edict_t *groundentity = ent->v.groundentity; - if (groundentity && (groundentity->v.flags & FL_CONVEYOR)) - { - if (ent->v.flags & FL_BASEVELOCITY) - VectorMA(ent->v.basevelocity, groundentity->v.speed, groundentity->v.movedir, ent->v.basevelocity); - else - VectorScale(groundentity->v.movedir, groundentity->v.speed, ent->v.basevelocity); - - ent->v.flags |= FL_BASEVELOCITY; - } - } - - if (!(ent->v.flags & FL_BASEVELOCITY)) - { - // Apply momentum (add in half of the previous frame of velocity first) - VectorMA(ent->v.velocity, (host_frametime * 0.5f + 1.0f), ent->v.basevelocity, ent->v.velocity); - VectorClear(ent->v.basevelocity); - } - - ent->v.flags &= ~FL_BASEVELOCITY; + SV_CheckMovingGround(ent, host_frametime); switch (ent->v.movetype) { diff --git a/rehlds/engine/sv_user.cpp b/rehlds/engine/sv_user.cpp index e6bd874..adc90ca 100644 --- a/rehlds/engine/sv_user.cpp +++ b/rehlds/engine/sv_user.cpp @@ -686,35 +686,33 @@ qboolean SV_PlayerRunThink(edict_t *ent, float frametime, double clienttimebase) return ent->free == 0; } -void SV_CheckMovingGround(edict_t *player, float frametime) +void SV_CheckMovingGround(edict_t *ent, float frametime) { edict_t *groundentity; - if (player->v.flags & FL_ONGROUND) + if (ent->v.flags & FL_ONGROUND) { - groundentity = player->v.groundentity; + groundentity = ent->v.groundentity; if (groundentity) { if (groundentity->v.flags & FL_CONVEYOR) { - if (player->v.flags & FL_BASEVELOCITY) - VectorMA(player->v.basevelocity, groundentity->v.speed, groundentity->v.movedir, player->v.basevelocity); + if (ent->v.flags & FL_BASEVELOCITY) + VectorMA(ent->v.basevelocity, groundentity->v.speed, groundentity->v.movedir, ent->v.basevelocity); else - VectorScale(groundentity->v.movedir, groundentity->v.speed, player->v.basevelocity); - player->v.flags |= FL_BASEVELOCITY; + VectorScale(groundentity->v.movedir, groundentity->v.speed, ent->v.basevelocity); + ent->v.flags |= FL_BASEVELOCITY; } } } - if (!(player->v.flags & FL_BASEVELOCITY)) + if (!(ent->v.flags & FL_BASEVELOCITY)) { - VectorMA(player->v.velocity, frametime * 0.5f + 1.0f, player->v.basevelocity, player->v.velocity); - player->v.basevelocity[0] = 0; - player->v.basevelocity[1] = 0; - player->v.basevelocity[2] = 0; + VectorMA(ent->v.velocity, frametime * 0.5f + 1.0f, ent->v.basevelocity, ent->v.velocity); + VectorClear(ent->v.basevelocity); } - player->v.flags &= ~FL_BASEVELOCITY; + ent->v.flags &= ~FL_BASEVELOCITY; } void SV_ConvertPMTrace(trace_t *dest, pmtrace_t *src, edict_t *ent)