diff --git a/regamedll/dlls/cbase.cpp b/regamedll/dlls/cbase.cpp index a779c69c5..77a499448 100644 --- a/regamedll/dlls/cbase.cpp +++ b/regamedll/dlls/cbase.cpp @@ -870,6 +870,17 @@ BOOL CBaseEntity::IsInWorld() } // speed +#ifdef REGAMEDLL_FIXES + float maxvel = g_psv_maxvelocity->value; + if (pev->velocity.x > maxvel || pev->velocity.y > maxvel || pev->velocity.z > maxvel) + { + return FALSE; + } + if (pev->velocity.x < -maxvel || pev->velocity.y < -maxvel || pev->velocity.z < -maxvel) + { + return FALSE; + } +#else if (pev->velocity.x >= 2000.0 || pev->velocity.y >= 2000.0 || pev->velocity.z >= 2000.0) { return FALSE; @@ -878,6 +889,7 @@ BOOL CBaseEntity::IsInWorld() { return FALSE; } +#endif return TRUE; } diff --git a/regamedll/dlls/game.cpp b/regamedll/dlls/game.cpp index 5d9238196..55c2600c1 100644 --- a/regamedll/dlls/game.cpp +++ b/regamedll/dlls/game.cpp @@ -9,6 +9,7 @@ cvar_t *g_psv_friction = nullptr; cvar_t *g_psv_stopspeed = nullptr; cvar_t *g_psv_stepsize = nullptr; cvar_t *g_psv_clienttrace = nullptr; +cvar_t *g_psv_maxvelocity = nullptr; cvar_t displaysoundlist = { "displaysoundlist", "0", 0, 0.0f, nullptr }; cvar_t timelimit = { "mp_timelimit", "0", FCVAR_SERVER, 0.0f, nullptr }; @@ -238,6 +239,7 @@ void EXT_FUNC GameDLLInit() g_psv_stopspeed = CVAR_GET_POINTER("sv_stopspeed"); g_psv_stepsize = CVAR_GET_POINTER("sv_stepsize"); g_psv_clienttrace = CVAR_GET_POINTER("sv_clienttrace"); + g_psv_maxvelocity = CVAR_GET_POINTER("sv_maxvelocity"); CVAR_REGISTER(&displaysoundlist); CVAR_REGISTER(&timelimit); diff --git a/regamedll/dlls/game.h b/regamedll/dlls/game.h index 3791a3c1f..cff031fbb 100644 --- a/regamedll/dlls/game.h +++ b/regamedll/dlls/game.h @@ -43,12 +43,13 @@ extern cvar_t *g_pskill; extern cvar_t *g_psv_gravity; extern cvar_t *g_psv_aim; +extern cvar_t *g_footsteps; extern cvar_t *g_psv_accelerate; extern cvar_t *g_psv_friction; extern cvar_t *g_psv_stopspeed; extern cvar_t *g_psv_stepsize; extern cvar_t *g_psv_clienttrace; -extern cvar_t *g_footsteps; +extern cvar_t *g_psv_maxvelocity; extern cvar_t displaysoundlist; extern cvar_t timelimit; diff --git a/regamedll/dlls/ggrenade.cpp b/regamedll/dlls/ggrenade.cpp index 678a78d58..41e92f27d 100644 --- a/regamedll/dlls/ggrenade.cpp +++ b/regamedll/dlls/ggrenade.cpp @@ -772,6 +772,13 @@ void CGrenade::BounceSound() void CGrenade::TumbleThink() { +#ifdef REGAMEDLL_FIXES + if (pev->velocity.IsLengthGreaterThan(g_psv_maxvelocity->value)) + { + pev->velocity = pev->velocity.Normalize() * g_psv_maxvelocity->value; + } +#endif + if (!IsInWorld()) { UTIL_Remove(this); @@ -809,6 +816,13 @@ void CGrenade::TumbleThink() void CGrenade::SG_TumbleThink() { +#ifdef REGAMEDLL_FIXES + if (pev->velocity.IsLengthGreaterThan(g_psv_maxvelocity->value)) + { + pev->velocity = pev->velocity.Normalize() * g_psv_maxvelocity->value; + } +#endif + if (!IsInWorld()) { UTIL_Remove(this); @@ -1322,6 +1336,13 @@ void AnnounceFlashInterval(float interval, float offset) void CGrenade::C4Think() { +#ifdef REGAMEDLL_FIXES + if (pev->velocity.IsLengthGreaterThan(g_psv_maxvelocity->value)) + { + pev->velocity = pev->velocity.Normalize() * g_psv_maxvelocity->value; + } +#endif + if (!IsInWorld()) { #ifdef REGAMEDLL_FIXES diff --git a/regamedll/dlls/gib.cpp b/regamedll/dlls/gib.cpp index 069b118d9..9301e283f 100644 --- a/regamedll/dlls/gib.cpp +++ b/regamedll/dlls/gib.cpp @@ -4,12 +4,11 @@ LINK_ENTITY_TO_CLASS(gib, CGib, CCSGib) void CGib::LimitVelocity() { - float length = pev->velocity.Length(); - float topspeed = CVAR_GET_FLOAT("sv_maxvelocity") * 0.75f; + float topspeed = g_psv_maxvelocity->value * 0.75f; // ceiling at topspeed. The gib velocity equation is not bounded properly. Rather than tune it // in 3 separate places again, I'll just limit it here. - if (length > topspeed) + if (pev->velocity.IsLengthGreaterThan(topspeed)) { // DONE: This should really be sv_maxvelocity * 0.75 or something pev->velocity = pev->velocity.Normalize() * topspeed;