Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed grenades disappearing when speed exceeds 2000 fixed units ignoring sv_maxvelocity #888

Merged
merged 5 commits into from
Nov 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions regamedll/dlls/cbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,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)
dystopm marked this conversation as resolved.
Show resolved Hide resolved
{
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;
Expand All @@ -874,6 +885,7 @@ BOOL CBaseEntity::IsInWorld()
{
return FALSE;
}
#endif

return TRUE;
}
Expand Down
2 changes: 2 additions & 0 deletions regamedll/dlls/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down Expand Up @@ -236,6 +237,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);
Expand Down
3 changes: 2 additions & 1 deletion regamedll/dlls/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
21 changes: 21 additions & 0 deletions regamedll/dlls/ggrenade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
dystopm marked this conversation as resolved.
Show resolved Hide resolved
}
#endif

if (!IsInWorld())
{
UTIL_Remove(this);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions regamedll/dlls/gib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down