From 8cb29103e2b8251fd32fc66f24eb0262035ab31b Mon Sep 17 00:00:00 2001 From: BjossiAlfreds Date: Thu, 19 Sep 2019 23:17:42 +0000 Subject: [PATCH] maxvelocity correctly enforced --- src/g_phys.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/g_phys.c b/src/g_phys.c index b3be126..bae1744 100644 --- a/src/g_phys.c +++ b/src/g_phys.c @@ -76,24 +76,15 @@ SV_TestEntityPosition(edict_t *ent) void SV_CheckVelocity(edict_t *ent) { - int i; - if (!ent) { return; } - /* bound velocity */ - for (i = 0; i < 3; i++) + if (VectorLength(ent->velocity) > sv_maxvelocity->value) { - if (ent->velocity[i] > sv_maxvelocity->value) - { - ent->velocity[i] = sv_maxvelocity->value; - } - else if (ent->velocity[i] < -sv_maxvelocity->value) - { - ent->velocity[i] = -sv_maxvelocity->value; - } + VectorNormalize(ent->velocity); + VectorScale(ent->velocity, sv_maxvelocity->value, ent->velocity); } }