SV_CheckVelocity() fix (cvar SV_MAXVELOCITY)

This commit is contained in:
Maddes Buecher 2000-08-16 20:49:06 +00:00
parent e5581c8373
commit b62172b915

View file

@ -78,7 +78,8 @@ void SV_Physics_Toss (edict_t *ent);
SV_CheckAllEnts
================
*/
void SV_CheckAllEnts (void)
void
SV_CheckAllEnts ( void )
{
int e;
edict_t *check;
@ -104,9 +105,11 @@ void SV_CheckAllEnts (void)
SV_CheckVelocity
================
*/
void SV_CheckVelocity (edict_t *ent)
void
SV_CheckVelocity ( edict_t *ent )
{
int i;
float wishspeed; // 1999-10-18 SV_MAXVELOCITY fix by Maddes
//
// bound velocity
@ -123,11 +126,15 @@ void SV_CheckVelocity (edict_t *ent)
Con_Printf ("Got a NaN origin on %s\n", PR_GetString(ent->v.classname));
ent->v.origin[i] = 0;
}
if (ent->v.velocity[i] > sv_maxvelocity->value)
ent->v.velocity[i] = sv_maxvelocity->value;
else if (ent->v.velocity[i] < -sv_maxvelocity->value)
ent->v.velocity[i] = -sv_maxvelocity->value;
}
// 1999-10-18 SV_MAXVELOCITY fix by Maddes start
wishspeed = Length(ent->v.velocity);
if (wishspeed > sv_maxvelocity->value)
{
VectorScale (ent->v.velocity, sv_maxvelocity->value/wishspeed, ent->v.velocity);
}
// 1999-10-18 SV_MAXVELOCITY fix by Maddes end
}
/*
@ -140,7 +147,8 @@ in a frame. Not used for pushmove objects, because they must be exact.
Returns false if the entity removed itself.
=============
*/
qboolean SV_RunThink (edict_t *ent)
qboolean
SV_RunThink ( edict_t *ent )
{
float thinktime;
@ -176,7 +184,8 @@ SV_Impact
Two entities have touched, so run their touch functions
==================
*/
void SV_Impact (edict_t *e1, edict_t *e2)
void
SV_Impact ( edict_t *e1, edict_t *e2 )
{
int old_self, old_other;
@ -213,7 +222,8 @@ returns the blocked flags (1 = floor, 2 = step / wall)
*/
#define STOP_EPSILON 0.1
int ClipVelocity (vec3_t in, vec3_t normal, vec3_t out, float overbounce)
int
ClipVelocity ( vec3_t in, vec3_t normal, vec3_t out, float overbounce )
{
float backoff;
float change;
@ -252,7 +262,8 @@ If steptrace is not NULL, the trace of any vertical wall hit will be stored
============
*/
#define MAX_CLIP_PLANES 5
int SV_FlyMove (edict_t *ent, float time, trace_t *steptrace)
int
SV_FlyMove ( edict_t *ent, float time, trace_t *steptrace )
{
int bumpcount, numbumps;
vec3_t dir;
@ -391,7 +402,8 @@ SV_AddGravity
============
*/
void SV_AddGravity (edict_t *ent, float scale)
void
SV_AddGravity ( edict_t *ent, float scale )
{
ent->v.velocity[2] -= scale * movevars.gravity * sv_frametime;
}
@ -411,7 +423,8 @@ SV_PushEntity
Does not change the entities velocity at all
============
*/
trace_t SV_PushEntity (edict_t *ent, vec3_t push)
trace_t
SV_PushEntity ( edict_t *ent, vec3_t push )
{
trace_t trace;
vec3_t end;
@ -442,7 +455,8 @@ SV_Push
============
*/
qboolean SV_Push (edict_t *pusher, vec3_t move)
qboolean
SV_Push ( edict_t *pusher, vec3_t move )
{
int i, e;
edict_t *check, *block;
@ -571,7 +585,8 @@ SV_PushMove
============
*/
void SV_PushMove (edict_t *pusher, float movetime)
void
SV_PushMove ( edict_t *pusher, float movetime )
{
int i;
vec3_t move;
@ -596,13 +611,14 @@ SV_Physics_Pusher
================
*/
void SV_Physics_Pusher (edict_t *ent)
void
SV_Physics_Pusher ( edict_t *ent )
{
float thinktime;
float oldltime;
float movetime;
vec3_t oldorg, move;
float l;
vec3_t oldorg, move;
float l;
oldltime = ent->v.ltime;
@ -623,7 +639,7 @@ float l;
if (thinktime > oldltime && thinktime <= ent->v.ltime)
{
VectorCopy (ent->v.origin, oldorg);
VectorCopy (ent->v.origin, oldorg);
ent->v.nextthink = 0;
pr_global_struct->time = sv.time;
pr_global_struct->self = EDICT_TO_PROG(ent);
@ -631,18 +647,16 @@ VectorCopy (ent->v.origin, oldorg);
PR_ExecuteProgram (ent->v.think);
if (ent->free)
return;
VectorSubtract (ent->v.origin, oldorg, move);
VectorSubtract (ent->v.origin, oldorg, move);
l = Length(move);
if (l > 1.0/64)
{
l = Length(move);
if (l > 1.0/64)
{
// Con_Printf ("**** snap: %f\n", Length (l));
VectorCopy (oldorg, ent->v.origin);
SV_Push (ent, move);
}
}
}
}
@ -653,7 +667,8 @@ SV_Physics_None
Non moving objects can only think
=============
*/
void SV_Physics_None (edict_t *ent)
void
SV_Physics_None ( edict_t *ent )
{
// regular thinking
SV_RunThink (ent);
@ -666,7 +681,8 @@ SV_Physics_Noclip
A moving object that doesn't obey physics
=============
*/
void SV_Physics_Noclip (edict_t *ent)
void
SV_Physics_Noclip ( edict_t *ent )
{
// regular thinking
if (!SV_RunThink (ent))
@ -692,7 +708,8 @@ SV_CheckWaterTransition
=============
*/
void SV_CheckWaterTransition (edict_t *ent)
void
SV_CheckWaterTransition ( edict_t *ent )
{
int cont;
@ -731,7 +748,8 @@ SV_Physics_Toss
Toss, bounce, and fly movement. When onground, do nothing.
=============
*/
void SV_Physics_Toss (edict_t *ent)
void
SV_Physics_Toss ( edict_t *ent )
{
trace_t trace;
vec3_t move;
@ -809,7 +827,8 @@ will fall if the floor is pulled out from under them.
FIXME: is this true?
=============
*/
void SV_Physics_Step (edict_t *ent)
void
SV_Physics_Step ( edict_t *ent )
{
qboolean hitsound;
@ -839,7 +858,8 @@ void SV_Physics_Step (edict_t *ent)
SV_CheckWaterTransition (ent);
}
void SV_PPushMove (edict_t *pusher, float movetime) // player push
void
SV_PPushMove ( edict_t *pusher, float movetime ) // player push
{
int i, e;
edict_t *check;
@ -902,12 +922,13 @@ void SV_PPushMove (edict_t *pusher, float movetime) // player push
pr_global_struct->other = EDICT_TO_PROG(check);
PR_ExecuteProgram (pusher->v.blocked);
}
return;
}
}
void SV_Physics_PPusher (edict_t *ent)
void
SV_Physics_PPusher ( edict_t *ent )
{
float thinktime;
float oldltime;
@ -945,7 +966,8 @@ void SV_Physics_PPusher (edict_t *ent)
//============================================================================
void SV_ProgStartFrame (void)
void
SV_ProgStartFrame ( void )
{
// let the progs know that a new frame has started
pr_global_struct->self = EDICT_TO_PROG(sv.edicts);
@ -960,7 +982,8 @@ SV_RunEntity
================
*/
void SV_RunEntity (edict_t *ent)
void
SV_RunEntity ( edict_t *ent )
{
if (ent->v.lastruntime == (float)realtime)
return;
@ -1000,7 +1023,8 @@ SV_RunNewmis
================
*/
void SV_RunNewmis (void)
void
SV_RunNewmis ( void )
{
edict_t *ent;
@ -1019,7 +1043,8 @@ SV_Physics
================
*/
void SV_Physics (void)
void
SV_Physics ( void )
{
int i;
edict_t *ent;
@ -1061,7 +1086,8 @@ void SV_Physics (void)
pr_global_struct->force_retouch--;
}
void SV_SetMoveVars(void)
void
SV_SetMoveVars ( void )
{
movevars.gravity = sv_gravity->value;
movevars.stopspeed = sv_stopspeed->value;