2007-09-17 22:00:00 +02:00
|
|
|
|
//=======================================================================
|
|
|
|
|
// Copyright XashXT Group 2007 <20>
|
|
|
|
|
// sv_physics.c - server physic
|
|
|
|
|
//=======================================================================
|
|
|
|
|
|
2008-06-09 22:00:00 +02:00
|
|
|
|
#include "common.h"
|
2007-09-17 22:00:00 +02:00
|
|
|
|
#include "server.h"
|
2008-11-25 22:00:00 +01:00
|
|
|
|
#include "matrix_lib.h"
|
2008-08-30 22:00:00 +02:00
|
|
|
|
#include "const.h"
|
2007-09-28 22:00:00 +02:00
|
|
|
|
|
2007-09-17 22:00:00 +02:00
|
|
|
|
/*
|
2009-11-02 22:00:00 +01:00
|
|
|
|
|
|
|
|
|
pushmove objects do not obey gravity, and do not interact with each other or trigger fields,
|
|
|
|
|
but block normal movement and push normal objects when they move.
|
2007-09-17 22:00:00 +02:00
|
|
|
|
|
2008-07-30 22:00:00 +02:00
|
|
|
|
onground is set for toss objects when they come to a complete rest. it is set for steping or walking objects
|
|
|
|
|
|
|
|
|
|
doors, plats, etc are SOLID_BSP, and MOVETYPE_PUSH
|
|
|
|
|
bonus items are SOLID_TRIGGER touch, and MOVETYPE_TOSS
|
|
|
|
|
corpses are SOLID_NOT and MOVETYPE_TOSS
|
|
|
|
|
crates are SOLID_BBOX and MOVETYPE_TOSS
|
|
|
|
|
walking monsters are SOLID_BBOX and MOVETYPE_STEP
|
|
|
|
|
flying/floating monsters are SOLID_BBOX and MOVETYPE_FLY
|
|
|
|
|
|
|
|
|
|
solid_edge items only clip against bsp models.
|
2007-09-17 22:00:00 +02:00
|
|
|
|
*/
|
2009-11-02 22:00:00 +01:00
|
|
|
|
#define DIST_EPSILON (0.03125) // 1/32 epsilon to keep floating point happy
|
2008-07-30 22:00:00 +02:00
|
|
|
|
#define MOVE_EPSILON 0.01
|
2009-12-01 22:00:00 +01:00
|
|
|
|
#define MAX_CLIP_PLANES 5
|
2009-11-02 22:00:00 +01:00
|
|
|
|
|
2007-09-28 22:00:00 +02:00
|
|
|
|
/*
|
2008-07-30 22:00:00 +02:00
|
|
|
|
===============================================================================
|
2007-09-28 22:00:00 +02:00
|
|
|
|
|
2008-07-30 22:00:00 +02:00
|
|
|
|
Utility functions
|
|
|
|
|
|
|
|
|
|
===============================================================================
|
|
|
|
|
*/
|
|
|
|
|
/*
|
|
|
|
|
============
|
|
|
|
|
SV_TestEntityPosition
|
|
|
|
|
|
|
|
|
|
returns true if the entity is in solid currently
|
|
|
|
|
============
|
2007-09-28 22:00:00 +02:00
|
|
|
|
*/
|
2010-06-16 22:00:00 +02:00
|
|
|
|
bool SV_TestEntityPosition( edict_t *ent )
|
2007-09-28 22:00:00 +02:00
|
|
|
|
{
|
2009-11-02 22:00:00 +01:00
|
|
|
|
trace_t trace;
|
2009-10-28 22:00:00 +01:00
|
|
|
|
|
2010-06-16 22:00:00 +02:00
|
|
|
|
trace = SV_Move( ent->v.origin, ent->v.mins, ent->v.maxs, ent->v.origin, MOVE_NORMAL|FMOVE_SIMPLEBOX, ent );
|
2010-03-09 22:00:00 +01:00
|
|
|
|
|
2010-06-16 22:00:00 +02:00
|
|
|
|
return trace.fStartSolid;
|
2009-11-23 22:00:00 +01:00
|
|
|
|
}
|
|
|
|
|
|
2008-07-30 22:00:00 +02:00
|
|
|
|
/*
|
|
|
|
|
================
|
|
|
|
|
SV_CheckAllEnts
|
|
|
|
|
================
|
|
|
|
|
*/
|
|
|
|
|
void SV_CheckAllEnts( void )
|
|
|
|
|
{
|
2009-11-02 22:00:00 +01:00
|
|
|
|
int i;
|
|
|
|
|
edict_t *e;
|
2008-07-30 22:00:00 +02:00
|
|
|
|
|
2009-11-29 22:00:00 +01:00
|
|
|
|
if( !sv_check_errors->integer ) return;
|
|
|
|
|
|
2008-07-30 22:00:00 +02:00
|
|
|
|
// see if any solid entities are inside the final position
|
2009-11-29 22:00:00 +01:00
|
|
|
|
for( i = svgame.globals->maxClients + 1; i < svgame.globals->numEntities; i++ )
|
2008-07-30 22:00:00 +02:00
|
|
|
|
{
|
2009-11-02 22:00:00 +01:00
|
|
|
|
e = EDICT_NUM( i );
|
2010-04-13 22:00:00 +02:00
|
|
|
|
|
2009-12-01 22:00:00 +01:00
|
|
|
|
if( !SV_IsValidEdict( e )) continue;
|
2009-11-02 22:00:00 +01:00
|
|
|
|
|
|
|
|
|
switch( e->v.movetype )
|
2008-07-30 22:00:00 +02:00
|
|
|
|
{
|
|
|
|
|
case MOVETYPE_PUSH:
|
|
|
|
|
case MOVETYPE_NONE:
|
|
|
|
|
case MOVETYPE_FOLLOW:
|
|
|
|
|
case MOVETYPE_NOCLIP:
|
|
|
|
|
continue;
|
2010-04-13 22:00:00 +02:00
|
|
|
|
default:
|
2010-04-17 22:00:00 +02:00
|
|
|
|
break;
|
2008-07-30 22:00:00 +02:00
|
|
|
|
}
|
2010-04-17 22:00:00 +02:00
|
|
|
|
|
2010-06-16 22:00:00 +02:00
|
|
|
|
if( SV_TestEntityPosition( e ))
|
2010-04-17 22:00:00 +02:00
|
|
|
|
MsgDev( D_INFO, "Stuck entity %s\n", SV_ClassName( e ));
|
2008-07-30 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2007-09-28 22:00:00 +02:00
|
|
|
|
|
2008-07-30 22:00:00 +02:00
|
|
|
|
/*
|
|
|
|
|
================
|
|
|
|
|
SV_CheckVelocity
|
|
|
|
|
================
|
|
|
|
|
*/
|
|
|
|
|
void SV_CheckVelocity( edict_t *ent )
|
2007-09-28 22:00:00 +02:00
|
|
|
|
{
|
|
|
|
|
int i;
|
2009-11-02 22:00:00 +01:00
|
|
|
|
float maxvel;
|
|
|
|
|
|
2009-11-26 22:00:00 +01:00
|
|
|
|
maxvel = fabs( svgame.movevars.maxvelocity );
|
2007-09-28 22:00:00 +02:00
|
|
|
|
|
|
|
|
|
// bound velocity
|
2008-07-30 22:00:00 +02:00
|
|
|
|
for( i = 0; i < 3; i++ )
|
2007-09-28 22:00:00 +02:00
|
|
|
|
{
|
2009-11-02 22:00:00 +01:00
|
|
|
|
if( IS_NAN( ent->v.velocity[i] ))
|
2007-09-28 22:00:00 +02:00
|
|
|
|
{
|
2009-11-02 22:00:00 +01:00
|
|
|
|
MsgDev( D_INFO, "Got a NaN velocity on %s\n", STRING( ent->v.classname ));
|
2009-11-29 22:00:00 +01:00
|
|
|
|
ent->v.velocity[i] = 0.0f;
|
2007-09-28 22:00:00 +02:00
|
|
|
|
}
|
2009-11-02 22:00:00 +01:00
|
|
|
|
if( IS_NAN( ent->v.origin[i] ))
|
2007-09-28 22:00:00 +02:00
|
|
|
|
{
|
2009-11-02 22:00:00 +01:00
|
|
|
|
MsgDev( D_INFO, "Got a NaN origin on %s\n", STRING( ent->v.classname ));
|
2009-11-29 22:00:00 +01:00
|
|
|
|
ent->v.origin[i] = 0.0f;
|
2007-09-28 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-02 22:00:00 +01:00
|
|
|
|
if( VectorLength( ent->v.velocity ) > maxvel )
|
|
|
|
|
VectorScale( ent->v.velocity, maxvel / VectorLength( ent->v.velocity ), ent->v.velocity );
|
2007-09-28 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
2009-12-01 22:00:00 +01:00
|
|
|
|
/*
|
|
|
|
|
================
|
|
|
|
|
SV_UpdateBaseVelocity
|
|
|
|
|
================
|
|
|
|
|
*/
|
|
|
|
|
void SV_UpdateBaseVelocity( edict_t *ent )
|
|
|
|
|
{
|
|
|
|
|
if( ent->v.flags & FL_ONGROUND )
|
|
|
|
|
{
|
|
|
|
|
edict_t *groundentity = ent->v.groundentity;
|
|
|
|
|
|
|
|
|
|
if( SV_IsValidEdict( groundentity ))
|
|
|
|
|
{
|
|
|
|
|
// On conveyor belt that's moving?
|
|
|
|
|
if( groundentity->v.flags & FL_CONVEYOR )
|
|
|
|
|
{
|
|
|
|
|
vec3_t new_basevel;
|
|
|
|
|
|
|
|
|
|
VectorScale( groundentity->v.movedir, groundentity->v.speed, new_basevel );
|
|
|
|
|
if( ent->v.flags & FL_BASEVELOCITY )
|
|
|
|
|
VectorAdd( new_basevel, ent->v.basevelocity, new_basevel );
|
|
|
|
|
|
|
|
|
|
ent->v.flags |= FL_BASEVELOCITY;
|
|
|
|
|
VectorCopy( new_basevel, ent->v.basevelocity );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-09-28 22:00:00 +02:00
|
|
|
|
/*
|
2008-07-30 22:00:00 +02:00
|
|
|
|
=============
|
|
|
|
|
SV_RunThink
|
2007-09-28 22:00:00 +02:00
|
|
|
|
|
2008-07-30 22:00:00 +02:00
|
|
|
|
Runs thinking code if time. There is some play in the exact time the think
|
|
|
|
|
function will be called, because it is called before any movement is done
|
|
|
|
|
in a frame. Not used for pushmove objects, because they must be exact.
|
|
|
|
|
Returns false if the entity removed itself.
|
|
|
|
|
=============
|
2007-09-28 22:00:00 +02:00
|
|
|
|
*/
|
2008-07-30 22:00:00 +02:00
|
|
|
|
bool SV_RunThink( edict_t *ent )
|
2007-09-28 22:00:00 +02:00
|
|
|
|
{
|
2010-04-12 22:00:00 +02:00
|
|
|
|
float thinktime;
|
|
|
|
|
|
|
|
|
|
thinktime = ent->v.nextthink;
|
2010-06-20 22:00:00 +02:00
|
|
|
|
if( thinktime <= 0.0f || thinktime > sv.time + sv.frametime )
|
2010-04-12 22:00:00 +02:00
|
|
|
|
return true;
|
|
|
|
|
|
2010-06-20 22:00:00 +02:00
|
|
|
|
if( thinktime < sv.time )
|
|
|
|
|
thinktime = sv.time; // don't let things stay in the past.
|
|
|
|
|
// it is possible to start that way
|
|
|
|
|
// by a trigger with a local time.
|
2010-04-12 22:00:00 +02:00
|
|
|
|
ent->v.nextthink = 0;
|
|
|
|
|
svgame.globals->time = thinktime;
|
|
|
|
|
svgame.dllFuncs.pfnThink( ent );
|
2009-01-14 22:00:00 +01:00
|
|
|
|
|
2009-11-29 22:00:00 +01:00
|
|
|
|
return !ent->free;
|
2007-09-28 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
==================
|
|
|
|
|
SV_Impact
|
|
|
|
|
|
|
|
|
|
Two entities have touched, so run their touch functions
|
|
|
|
|
==================
|
|
|
|
|
*/
|
2009-11-29 22:00:00 +01:00
|
|
|
|
bool SV_Impact( edict_t *e1, trace_t *trace )
|
2007-09-28 22:00:00 +02:00
|
|
|
|
{
|
2009-11-29 22:00:00 +01:00
|
|
|
|
edict_t *e2 = trace->pHit;
|
|
|
|
|
vec3_t org;
|
|
|
|
|
|
2010-04-13 22:00:00 +02:00
|
|
|
|
// custom user filter
|
|
|
|
|
if( !svgame.dllFuncs.pfnShouldCollide( e1, e2 ))
|
|
|
|
|
return false;
|
|
|
|
|
|
2009-11-29 22:00:00 +01:00
|
|
|
|
SV_CopyTraceToGlobal( trace );
|
|
|
|
|
VectorCopy( e1->v.origin, org );
|
2007-09-28 22:00:00 +02:00
|
|
|
|
|
2009-11-29 22:00:00 +01:00
|
|
|
|
if( !e1->free && !e2->free && e1->v.solid != SOLID_NOT )
|
|
|
|
|
{
|
2008-12-26 22:00:00 +01:00
|
|
|
|
svgame.dllFuncs.pfnTouch( e1, e2 );
|
2009-11-29 22:00:00 +01:00
|
|
|
|
}
|
2008-07-30 22:00:00 +02:00
|
|
|
|
|
2009-11-29 22:00:00 +01:00
|
|
|
|
if( !e1->free && !e2->free && e2->v.solid != SOLID_NOT )
|
|
|
|
|
{
|
2010-04-13 22:00:00 +02:00
|
|
|
|
// inverse plane and normal for second contacted edict
|
2009-11-29 22:00:00 +01:00
|
|
|
|
VectorCopy( e2->v.origin, svgame.globals->trace_endpos );
|
|
|
|
|
VectorNegate( trace->vecPlaneNormal, svgame.globals->trace_plane_normal );
|
|
|
|
|
svgame.globals->trace_plane_dist = -trace->flPlaneDist;
|
|
|
|
|
svgame.globals->trace_ent = e1;
|
2010-04-13 22:00:00 +02:00
|
|
|
|
|
2008-12-26 22:00:00 +01:00
|
|
|
|
svgame.dllFuncs.pfnTouch( e2, e1 );
|
2009-11-29 22:00:00 +01:00
|
|
|
|
}
|
|
|
|
|
return VectorCompare( e1->v.origin, org );
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-30 22:00:00 +01:00
|
|
|
|
/*
|
|
|
|
|
============
|
|
|
|
|
SV_TransformedBBox
|
|
|
|
|
|
|
|
|
|
Returns the actual bounding box of a bmodel. This is a big improvement over
|
|
|
|
|
what quake normally does with rotating bmodels - quake sets absmin, absmax to a cube
|
|
|
|
|
that will completely contain the bmodel at *any* rotation on *any* axis, whether
|
|
|
|
|
the bmodel can actually rotate to that angle or not. This leads to a lot of
|
|
|
|
|
false block tests in SV_MovePush if another bmodel is in the vicinity.
|
|
|
|
|
============
|
|
|
|
|
*/
|
|
|
|
|
void SV_TransformedBBox( edict_t *ent, vec3_t mins, vec3_t maxs )
|
|
|
|
|
{
|
|
|
|
|
vec3_t forward, left, up, f1, l1, u1;
|
|
|
|
|
int i, j, k, j2, k4;
|
|
|
|
|
vec3_t p[8];
|
|
|
|
|
|
|
|
|
|
for( k = 0; k < 2; k++ )
|
|
|
|
|
{
|
|
|
|
|
k4 = k * 4;
|
|
|
|
|
if( k ) p[k4][2] = ent->v.maxs[2];
|
|
|
|
|
else p[k4][2] = ent->v.mins[2];
|
|
|
|
|
|
|
|
|
|
p[k4+1][2] = p[k4][2];
|
|
|
|
|
p[k4+2][2] = p[k4][2];
|
|
|
|
|
p[k4+3][2] = p[k4][2];
|
|
|
|
|
|
|
|
|
|
for( j = 0; j < 2; j++ )
|
|
|
|
|
{
|
|
|
|
|
j2 = j * 2;
|
|
|
|
|
if( j ) p[j2+k4][1] = ent->v.maxs[1];
|
|
|
|
|
else p[j2+k4][1] = ent->v.mins[1];
|
|
|
|
|
p[j2+k4+1][1] = p[j2+k4][1];
|
|
|
|
|
|
|
|
|
|
for( i = 0; i < 2; i++ )
|
|
|
|
|
{
|
|
|
|
|
if( i ) p[i+j2+k4][0] = ent->v.maxs[0];
|
|
|
|
|
else p[i+j2+k4][0] = ent->v.mins[0];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AngleVectorsFLU( ent->v.angles, forward, left, up );
|
|
|
|
|
|
|
|
|
|
for( i = 0; i < 8; i++ )
|
|
|
|
|
{
|
|
|
|
|
VectorScale( forward, p[i][0], f1 );
|
|
|
|
|
VectorScale( left, -p[i][1], l1 );
|
|
|
|
|
VectorScale( up, p[i][2], u1 );
|
|
|
|
|
VectorAdd( ent->v.origin, f1, p[i] );
|
|
|
|
|
VectorAdd( p[i], l1, p[i] );
|
|
|
|
|
VectorAdd( p[i], u1, p[i] );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
VectorCopy( p[0], mins );
|
|
|
|
|
VectorCopy( p[0], maxs );
|
|
|
|
|
|
|
|
|
|
for( i = 1; i < 8; i++ )
|
|
|
|
|
{
|
|
|
|
|
mins[0] = min( mins[0], p[i][0] );
|
|
|
|
|
mins[1] = min( mins[1], p[i][1] );
|
|
|
|
|
mins[2] = min( mins[2], p[i][2] );
|
|
|
|
|
maxs[0] = max( maxs[0], p[i][0] );
|
|
|
|
|
maxs[1] = max( maxs[1], p[i][1] );
|
|
|
|
|
maxs[2] = max( maxs[2], p[i][2] );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-01 22:00:00 +01:00
|
|
|
|
/*
|
|
|
|
|
=============
|
|
|
|
|
SV_AngularMove
|
|
|
|
|
|
|
|
|
|
may use friction for smooth stopping
|
|
|
|
|
=============
|
|
|
|
|
*/
|
|
|
|
|
void SV_AngularMove( edict_t *ent, float frametime, float friction )
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
float adjustment;
|
|
|
|
|
|
|
|
|
|
VectorMA( ent->v.angles, frametime, ent->v.avelocity, ent->v.angles );
|
|
|
|
|
if( friction == 0.0f ) return;
|
|
|
|
|
adjustment = frametime * (sv_stopspeed->value / 10) * sv_friction->value * fabs( friction );
|
|
|
|
|
|
|
|
|
|
for( i = 0; i < 3; i++ )
|
|
|
|
|
{
|
|
|
|
|
if( ent->v.avelocity[i] > 0.0f )
|
|
|
|
|
{
|
|
|
|
|
ent->v.avelocity[i] -= adjustment;
|
2010-04-13 22:00:00 +02:00
|
|
|
|
if( ent->v.avelocity[i] < 0.0f ) ent->v.avelocity[i] = 0.0f;
|
2009-12-01 22:00:00 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ent->v.avelocity[i] += adjustment;
|
2010-04-13 22:00:00 +02:00
|
|
|
|
if( ent->v.avelocity[i] > 0.0f ) ent->v.avelocity[i] = 0.0f;
|
2009-12-01 22:00:00 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
=============
|
|
|
|
|
SV_LinearMove
|
|
|
|
|
|
|
|
|
|
use friction for smooth stopping
|
|
|
|
|
=============
|
|
|
|
|
*/
|
|
|
|
|
void SV_LinearMove( edict_t *ent, float frametime, float friction )
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
float adjustment;
|
|
|
|
|
|
|
|
|
|
VectorMA( ent->v.origin, frametime, ent->v.velocity, ent->v.origin );
|
|
|
|
|
if( friction == 0.0f ) return;
|
|
|
|
|
adjustment = frametime * (sv_stopspeed->value / 10) * sv_friction->value * fabs( friction );
|
|
|
|
|
|
|
|
|
|
for( i = 0; i < 3; i++ )
|
|
|
|
|
{
|
|
|
|
|
if( ent->v.velocity[i] > 0.0f )
|
|
|
|
|
{
|
|
|
|
|
ent->v.velocity[i] -= adjustment;
|
2010-04-13 22:00:00 +02:00
|
|
|
|
if( ent->v.velocity[i] < 0.0f ) ent->v.velocity[i] = 0.0f;
|
2009-12-01 22:00:00 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ent->v.velocity[i] += adjustment;
|
2010-04-13 22:00:00 +02:00
|
|
|
|
if( ent->v.velocity[i] > 0.0f ) ent->v.velocity[i] = 0.0f;
|
2009-12-01 22:00:00 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-30 22:00:00 +01:00
|
|
|
|
/*
|
|
|
|
|
=============
|
|
|
|
|
SV_CheckWater
|
|
|
|
|
=============
|
|
|
|
|
*/
|
|
|
|
|
bool SV_CheckWater( edict_t *ent )
|
|
|
|
|
{
|
|
|
|
|
int cont;
|
|
|
|
|
vec3_t point;
|
|
|
|
|
|
2010-04-02 22:00:00 +02:00
|
|
|
|
point[0] = (ent->v.absmin[0] + ent->v.absmax[0]) * 0.5f;
|
|
|
|
|
point[1] = (ent->v.absmin[1] + ent->v.absmax[1]) * 0.5f;
|
|
|
|
|
point[2] = ent->v.absmin[2] + 1;
|
2009-11-30 22:00:00 +01:00
|
|
|
|
|
|
|
|
|
ent->v.waterlevel = 0;
|
|
|
|
|
ent->v.watertype = CONTENTS_EMPTY;
|
2010-06-16 22:00:00 +02:00
|
|
|
|
cont = SV_TruePointContents( point );
|
2009-11-30 22:00:00 +01:00
|
|
|
|
|
|
|
|
|
if( cont <= CONTENTS_WATER )
|
|
|
|
|
{
|
|
|
|
|
ent->v.watertype = cont;
|
|
|
|
|
ent->v.waterlevel = 1;
|
2010-04-02 22:00:00 +02:00
|
|
|
|
|
|
|
|
|
// point sized entities are always fully submerged
|
|
|
|
|
if( ent->v.absmin[2] == ent->v.absmax[2] )
|
2009-11-30 22:00:00 +01:00
|
|
|
|
{
|
2010-04-02 22:00:00 +02:00
|
|
|
|
ent->v.waterlevel = 3;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// check the exact center of the box
|
|
|
|
|
point[2] = (ent->v.absmin[2] + ent->v.absmax[2]) * 0.5f;
|
2009-11-30 22:00:00 +01:00
|
|
|
|
|
2010-04-01 22:00:00 +02:00
|
|
|
|
if( SV_PointContents( point ) <= CONTENTS_WATER )
|
2010-04-02 22:00:00 +02:00
|
|
|
|
{
|
|
|
|
|
ent->v.waterlevel = 2;
|
|
|
|
|
point[2] = ent->v.origin[2] + ent->v.view_ofs[2];
|
2010-04-01 22:00:00 +02:00
|
|
|
|
|
2010-04-02 22:00:00 +02:00
|
|
|
|
// now check where the eyes are...
|
|
|
|
|
if( SV_PointContents( point ) <= CONTENTS_WATER )
|
|
|
|
|
ent->v.waterlevel = 3;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( cont <= CONTENTS_CURRENT_0 && cont >= CONTENTS_CURRENT_DOWN )
|
2009-11-30 22:00:00 +01:00
|
|
|
|
{
|
2010-04-02 22:00:00 +02:00
|
|
|
|
static vec3_t current_table[] =
|
|
|
|
|
{
|
|
|
|
|
{ 1, 0, 0 },
|
|
|
|
|
{ 0, 1, 0 },
|
|
|
|
|
{-1, 0, 0 },
|
|
|
|
|
{ 0, -1, 0 },
|
|
|
|
|
{ 0, 0, 1 },
|
|
|
|
|
{ 0, 0, -1}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
float speed = ent->v.waterlevel * 50.0f;
|
|
|
|
|
float *dir = current_table[CONTENTS_CURRENT_0 - cont];
|
|
|
|
|
|
|
|
|
|
VectorMA( ent->v.basevelocity, speed, dir, ent->v.basevelocity );
|
|
|
|
|
}
|
2009-11-30 22:00:00 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
2010-04-01 22:00:00 +02:00
|
|
|
|
|
2009-11-30 22:00:00 +01:00
|
|
|
|
return ent->v.waterlevel > 1;
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-29 22:00:00 +01:00
|
|
|
|
/*
|
|
|
|
|
============
|
|
|
|
|
SV_ClampOrigin
|
|
|
|
|
|
|
|
|
|
clamp the move to 1/32 units, so the position will
|
|
|
|
|
be accurate for client side prediction
|
|
|
|
|
============
|
|
|
|
|
*/
|
|
|
|
|
void SV_ClampOrigin( vec3_t origin )
|
|
|
|
|
{
|
2010-04-13 22:00:00 +02:00
|
|
|
|
origin[0] -= 32.0f * floor( origin[0] * ( 1.0f / 32.0f ));
|
|
|
|
|
origin[1] -= 32.0f * floor( origin[1] * ( 1.0f / 32.0f ));
|
|
|
|
|
origin[2] -= 32.0f * floor( origin[2] * ( 1.0f / 32.0f ));
|
2009-11-29 22:00:00 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
============
|
|
|
|
|
SV_ClampAngles
|
|
|
|
|
|
|
|
|
|
clamp the angles to 1/360 degrees, so the position will
|
|
|
|
|
be accurate for client side prediction
|
|
|
|
|
============
|
|
|
|
|
*/
|
|
|
|
|
void SV_ClampAngles( vec3_t angles )
|
|
|
|
|
{
|
|
|
|
|
angles[0] -= 360.0f * floor( angles[0] * ( 1.0f / 360.0f ));
|
|
|
|
|
angles[1] -= 360.0f * floor( angles[1] * ( 1.0f / 360.0f ));
|
|
|
|
|
angles[2] -= 360.0f * floor( angles[2] * ( 1.0f / 360.0f ));
|
2007-09-28 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
2008-07-30 22:00:00 +02:00
|
|
|
|
==================
|
|
|
|
|
SV_ClipVelocity
|
|
|
|
|
|
|
|
|
|
Slide off of the impacting object
|
|
|
|
|
==================
|
2007-09-28 22:00:00 +02:00
|
|
|
|
*/
|
2009-11-29 22:00:00 +01:00
|
|
|
|
void SV_ClipVelocity( vec3_t in, vec3_t normal, vec3_t out, float overbounce )
|
2007-09-28 22:00:00 +02:00
|
|
|
|
{
|
2009-11-29 22:00:00 +01:00
|
|
|
|
int i;
|
|
|
|
|
float backoff;
|
2007-09-28 22:00:00 +02:00
|
|
|
|
|
2009-11-29 22:00:00 +01:00
|
|
|
|
backoff = -DotProduct (in, normal) * overbounce;
|
|
|
|
|
VectorMA( in, backoff, normal, out );
|
2007-09-28 22:00:00 +02:00
|
|
|
|
|
2008-07-30 22:00:00 +02:00
|
|
|
|
for( i = 0; i < 3; i++ )
|
2007-09-28 22:00:00 +02:00
|
|
|
|
{
|
2008-07-30 22:00:00 +02:00
|
|
|
|
if( out[i] > -STOP_EPSILON && out[i] < STOP_EPSILON )
|
2009-11-29 22:00:00 +01:00
|
|
|
|
out[i] = 0.0f;
|
2007-09-28 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-30 22:00:00 +01:00
|
|
|
|
/*
|
|
|
|
|
===============================================================================
|
|
|
|
|
|
|
|
|
|
FLYING MOVEMENT CODE
|
|
|
|
|
|
|
|
|
|
===============================================================================
|
|
|
|
|
*/
|
2007-09-28 22:00:00 +02:00
|
|
|
|
/*
|
|
|
|
|
============
|
2010-04-01 22:00:00 +02:00
|
|
|
|
SV_TryMove
|
2007-09-28 22:00:00 +02:00
|
|
|
|
|
|
|
|
|
The basic solid body movement clip that slides along multiple planes
|
2010-04-01 22:00:00 +02:00
|
|
|
|
*steptrace - if not NULL, the trace results of any vertical wall hit will be stored
|
2007-09-28 22:00:00 +02:00
|
|
|
|
Returns the clipflags if the velocity was modified (hit something solid)
|
|
|
|
|
1 = floor
|
|
|
|
|
2 = wall / step
|
|
|
|
|
4 = dead stop
|
|
|
|
|
============
|
|
|
|
|
*/
|
2010-04-01 22:00:00 +02:00
|
|
|
|
int SV_TryMove( edict_t *ent, float time, trace_t *steptrace )
|
2007-09-28 22:00:00 +02:00
|
|
|
|
{
|
2009-12-01 22:00:00 +01:00
|
|
|
|
int i, j, numplanes, bumpcount, blocked;
|
2009-11-02 22:00:00 +01:00
|
|
|
|
vec3_t dir, end, planes[MAX_CLIP_PLANES];
|
|
|
|
|
vec3_t primal_velocity, original_velocity, new_velocity;
|
2009-12-05 22:00:00 +01:00
|
|
|
|
float d, time_left, allFraction;
|
2009-11-02 22:00:00 +01:00
|
|
|
|
trace_t trace;
|
2007-09-28 22:00:00 +02:00
|
|
|
|
|
2009-12-01 22:00:00 +01:00
|
|
|
|
blocked = 0;
|
2008-12-21 22:00:00 +01:00
|
|
|
|
VectorCopy( ent->v.velocity, original_velocity );
|
|
|
|
|
VectorCopy( ent->v.velocity, primal_velocity );
|
2007-09-28 22:00:00 +02:00
|
|
|
|
numplanes = 0;
|
2009-11-02 22:00:00 +01:00
|
|
|
|
|
2009-12-05 22:00:00 +01:00
|
|
|
|
allFraction = 0;
|
2007-09-28 22:00:00 +02:00
|
|
|
|
time_left = time;
|
2008-07-30 22:00:00 +02:00
|
|
|
|
|
2009-12-05 22:00:00 +01:00
|
|
|
|
for( bumpcount = 0; bumpcount < MAX_CLIP_PLANES - 1; bumpcount++ )
|
2007-09-28 22:00:00 +02:00
|
|
|
|
{
|
2009-11-02 22:00:00 +01:00
|
|
|
|
if( VectorIsNull( ent->v.velocity ))
|
2007-09-28 22:00:00 +02:00
|
|
|
|
break;
|
|
|
|
|
|
2008-12-15 22:00:00 +01:00
|
|
|
|
VectorMA( ent->v.origin, time_left, ent->v.velocity, end );
|
2009-11-02 22:00:00 +01:00
|
|
|
|
trace = SV_Move( ent->v.origin, ent->v.mins, ent->v.maxs, end, MOVE_NORMAL, ent );
|
2007-09-28 22:00:00 +02:00
|
|
|
|
|
2009-12-05 22:00:00 +01:00
|
|
|
|
allFraction += trace.flFraction;
|
|
|
|
|
|
2010-04-18 22:00:00 +02:00
|
|
|
|
|
2009-12-01 22:00:00 +01:00
|
|
|
|
if( trace.fAllSolid )
|
|
|
|
|
{
|
|
|
|
|
// entity is trapped in another solid
|
|
|
|
|
VectorClear( ent->v.velocity );
|
2009-12-05 22:00:00 +01:00
|
|
|
|
return 4;
|
2009-12-01 22:00:00 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( trace.flFraction > 0.0f )
|
|
|
|
|
{
|
|
|
|
|
// actually covered some distance
|
2009-10-28 22:00:00 +01:00
|
|
|
|
VectorCopy( trace.vecEndPos, ent->v.origin );
|
2009-12-01 22:00:00 +01:00
|
|
|
|
VectorCopy( ent->v.velocity, original_velocity );
|
|
|
|
|
numplanes = 0;
|
2007-09-28 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
2009-12-01 22:00:00 +01:00
|
|
|
|
if( trace.flFraction == 1.0f )
|
|
|
|
|
break; // moved the entire distance
|
|
|
|
|
|
2009-10-28 22:00:00 +01:00
|
|
|
|
if( !trace.pHit )
|
2007-09-28 22:00:00 +02:00
|
|
|
|
{
|
2010-04-01 22:00:00 +02:00
|
|
|
|
MsgDev( D_WARN, "SV_TryMove: trace.pHit == NULL\n" );
|
|
|
|
|
return 4;
|
2007-09-28 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
2009-12-01 22:00:00 +01:00
|
|
|
|
if( trace.vecPlaneNormal[2] > 0.7f )
|
2007-09-28 22:00:00 +02:00
|
|
|
|
{
|
2009-12-01 22:00:00 +01:00
|
|
|
|
blocked |= 1; // floor
|
|
|
|
|
if( trace.pHit->v.solid == SOLID_BSP )
|
2007-09-28 22:00:00 +02:00
|
|
|
|
{
|
2008-12-15 22:00:00 +01:00
|
|
|
|
ent->v.flags |= FL_ONGROUND;
|
2009-10-28 22:00:00 +01:00
|
|
|
|
ent->v.groundentity = trace.pHit;
|
2007-09-28 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-01 22:00:00 +01:00
|
|
|
|
if( trace.vecPlaneNormal[2] == 0.0f )
|
2007-09-28 22:00:00 +02:00
|
|
|
|
{
|
2009-12-01 22:00:00 +01:00
|
|
|
|
blocked |= 2; // step
|
|
|
|
|
if( steptrace ) *steptrace = trace; // save for player extrafriction
|
2007-09-28 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// run the impact function
|
2009-12-01 22:00:00 +01:00
|
|
|
|
SV_Impact( ent, &trace );
|
2008-07-30 22:00:00 +02:00
|
|
|
|
|
2009-12-01 22:00:00 +01:00
|
|
|
|
// break if removed by the impact function
|
|
|
|
|
if( ent->free ) break;
|
2007-09-28 22:00:00 +02:00
|
|
|
|
|
2009-12-05 22:00:00 +01:00
|
|
|
|
time_left -= time_left * trace.flFraction;
|
2007-09-28 22:00:00 +02:00
|
|
|
|
|
|
|
|
|
// clipped to another plane
|
2008-07-30 22:00:00 +02:00
|
|
|
|
if( numplanes >= MAX_CLIP_PLANES )
|
2007-09-28 22:00:00 +02:00
|
|
|
|
{
|
|
|
|
|
// this shouldn't really happen
|
2008-12-15 22:00:00 +01:00
|
|
|
|
VectorClear( ent->v.velocity );
|
2009-12-05 22:00:00 +01:00
|
|
|
|
break;
|
2007-09-28 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
2009-10-28 22:00:00 +01:00
|
|
|
|
VectorCopy( trace.vecPlaneNormal, planes[numplanes] );
|
2007-09-28 22:00:00 +02:00
|
|
|
|
numplanes++;
|
|
|
|
|
|
|
|
|
|
// modify original_velocity so it parallels all of the clip planes
|
2008-07-30 22:00:00 +02:00
|
|
|
|
for( i = 0; i < numplanes; i++ )
|
2007-09-28 22:00:00 +02:00
|
|
|
|
{
|
2009-12-05 22:00:00 +01:00
|
|
|
|
SV_ClipVelocity( original_velocity, planes[i], new_velocity, 1.0f );
|
2008-07-30 22:00:00 +02:00
|
|
|
|
for( j = 0; j < numplanes; j++ )
|
2007-09-28 22:00:00 +02:00
|
|
|
|
{
|
2008-07-30 22:00:00 +02:00
|
|
|
|
if( j != i )
|
2007-09-28 22:00:00 +02:00
|
|
|
|
{
|
2009-11-02 22:00:00 +01:00
|
|
|
|
if( DotProduct( new_velocity, planes[j] ) < 0.0f )
|
2009-12-01 22:00:00 +01:00
|
|
|
|
break; // not ok
|
2007-09-28 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2009-12-05 22:00:00 +01:00
|
|
|
|
if( j == numplanes )
|
|
|
|
|
break;
|
2007-09-28 22:00:00 +02:00
|
|
|
|
}
|
2009-11-02 22:00:00 +01:00
|
|
|
|
|
2008-07-30 22:00:00 +02:00
|
|
|
|
if( i != numplanes )
|
2007-09-28 22:00:00 +02:00
|
|
|
|
{
|
|
|
|
|
// go along this plane
|
2009-11-02 22:00:00 +01:00
|
|
|
|
VectorCopy( new_velocity, ent->v.velocity );
|
2007-09-28 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// go along the crease
|
2008-07-30 22:00:00 +02:00
|
|
|
|
if( numplanes != 2 )
|
2007-09-28 22:00:00 +02:00
|
|
|
|
{
|
2008-12-15 22:00:00 +01:00
|
|
|
|
VectorClear( ent->v.velocity );
|
2009-12-05 22:00:00 +01:00
|
|
|
|
break;
|
2007-09-28 22:00:00 +02:00
|
|
|
|
}
|
2009-11-02 22:00:00 +01:00
|
|
|
|
|
2008-07-30 22:00:00 +02:00
|
|
|
|
CrossProduct( planes[0], planes[1], dir );
|
2008-12-15 22:00:00 +01:00
|
|
|
|
d = DotProduct( dir, ent->v.velocity );
|
|
|
|
|
VectorScale( dir, d, ent->v.velocity );
|
2007-09-28 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// if current velocity is against the original velocity,
|
|
|
|
|
// stop dead to avoid tiny occilations in sloping corners
|
2009-11-02 22:00:00 +01:00
|
|
|
|
if( DotProduct( ent->v.velocity, primal_velocity ) <= 0.0f )
|
2007-09-28 22:00:00 +02:00
|
|
|
|
{
|
2008-12-15 22:00:00 +01:00
|
|
|
|
VectorClear( ent->v.velocity );
|
2009-12-05 22:00:00 +01:00
|
|
|
|
break;
|
2007-09-28 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-17 22:00:00 +02:00
|
|
|
|
if( allFraction == 0 )
|
2009-12-05 22:00:00 +01:00
|
|
|
|
VectorClear( ent->v.velocity );
|
|
|
|
|
|
2007-09-28 22:00:00 +02:00
|
|
|
|
return blocked;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
============
|
|
|
|
|
SV_AddGravity
|
|
|
|
|
|
|
|
|
|
============
|
|
|
|
|
*/
|
2008-07-30 22:00:00 +02:00
|
|
|
|
void SV_AddGravity( edict_t *ent )
|
2007-09-28 22:00:00 +02:00
|
|
|
|
{
|
2008-12-21 22:00:00 +01:00
|
|
|
|
if( ent->v.gravity ) // gravity modifier
|
2010-06-20 22:00:00 +02:00
|
|
|
|
ent->v.velocity[2] -= sv_gravity->value * ent->v.gravity * sv.frametime;
|
|
|
|
|
else ent->v.velocity[2] -= sv_gravity->value * sv.frametime;
|
2007-09-28 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
2010-04-01 22:00:00 +02:00
|
|
|
|
void SV_AddHalfGravity( edict_t *ent, float timestep )
|
|
|
|
|
{
|
|
|
|
|
float ent_gravity;
|
|
|
|
|
|
|
|
|
|
if( ent->v.gravity )
|
|
|
|
|
ent_gravity = ent->v.gravity;
|
|
|
|
|
else ent_gravity = 1.0f;
|
|
|
|
|
|
|
|
|
|
// Add 1/2 of the total gravitational effects over this timestep
|
|
|
|
|
ent->v.velocity[2] -= ( 0.5f * ent_gravity * sv_gravity->value * timestep );
|
2010-06-20 22:00:00 +02:00
|
|
|
|
ent->v.velocity[2] += ent->v.basevelocity[2] * sv.frametime;
|
2010-04-01 22:00:00 +02:00
|
|
|
|
ent->v.basevelocity[2] = 0.0f;
|
|
|
|
|
|
|
|
|
|
// bound velocity
|
|
|
|
|
SV_CheckVelocity( ent );
|
|
|
|
|
}
|
|
|
|
|
|
2007-09-28 22:00:00 +02:00
|
|
|
|
/*
|
2008-07-30 22:00:00 +02:00
|
|
|
|
===============================================================================
|
2007-09-28 22:00:00 +02:00
|
|
|
|
|
2008-07-30 22:00:00 +02:00
|
|
|
|
PUSHMOVE
|
|
|
|
|
|
|
|
|
|
===============================================================================
|
|
|
|
|
*/
|
|
|
|
|
/*
|
|
|
|
|
============
|
2010-04-17 22:00:00 +02:00
|
|
|
|
PM_PushEntity
|
2008-07-30 22:00:00 +02:00
|
|
|
|
|
|
|
|
|
Does not change the entities velocity at all
|
|
|
|
|
============
|
2007-09-28 22:00:00 +02:00
|
|
|
|
*/
|
2010-04-17 22:00:00 +02:00
|
|
|
|
trace_t SV_PushEntity( edict_t *ent, const vec3_t lpush, const vec3_t apush, int *blocked )
|
2007-09-28 22:00:00 +02:00
|
|
|
|
{
|
2010-04-17 22:00:00 +02:00
|
|
|
|
trace_t trace;
|
|
|
|
|
sv_client_t *cl;
|
|
|
|
|
int type;
|
|
|
|
|
vec3_t end;
|
2009-11-30 22:00:00 +01:00
|
|
|
|
|
2010-04-17 22:00:00 +02:00
|
|
|
|
VectorAdd( ent->v.origin, lpush, end );
|
2007-09-28 22:00:00 +02:00
|
|
|
|
|
2009-11-29 22:00:00 +01:00
|
|
|
|
if( ent->v.movetype == MOVETYPE_FLYMISSILE )
|
2009-11-30 22:00:00 +01:00
|
|
|
|
type = MOVE_MISSILE;
|
2009-11-29 22:00:00 +01:00
|
|
|
|
else if( ent->v.solid == SOLID_TRIGGER || ent->v.solid == SOLID_NOT )
|
2009-11-30 22:00:00 +01:00
|
|
|
|
type = MOVE_NOMONSTERS; // only clip against bmodels
|
|
|
|
|
else type = MOVE_NORMAL;
|
2007-09-28 22:00:00 +02:00
|
|
|
|
|
2010-05-04 22:00:00 +02:00
|
|
|
|
trace = SV_Move( ent->v.origin, ent->v.mins, ent->v.maxs, end, type|FMOVE_SIMPLEBOX, ent );
|
2010-04-17 22:00:00 +02:00
|
|
|
|
VectorCopy( trace.vecEndPos, ent->v.origin );
|
|
|
|
|
SV_LinkEdict( ent, true );
|
2009-11-30 22:00:00 +01:00
|
|
|
|
|
2010-04-17 22:00:00 +02:00
|
|
|
|
if( apush[YAW] && ent->v.flags & FL_CLIENT && ( cl = SV_ClientFromEdict( ent, true )) != NULL )
|
2009-11-30 22:00:00 +01:00
|
|
|
|
{
|
2010-06-20 22:00:00 +02:00
|
|
|
|
cl->addangle = apush[1];
|
2010-04-17 22:00:00 +02:00
|
|
|
|
ent->v.fixangle = 2;
|
2008-07-30 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
2010-04-17 22:00:00 +02:00
|
|
|
|
ent->v.angles[YAW] += trace.flFraction * apush[YAW];
|
2009-10-29 22:00:00 +01:00
|
|
|
|
|
2010-04-17 22:00:00 +02:00
|
|
|
|
if( blocked ) *blocked = !VectorCompare( ent->v.origin, end ); // can't move full distance
|
2009-11-02 22:00:00 +01:00
|
|
|
|
|
2010-04-17 22:00:00 +02:00
|
|
|
|
// so we can run impact function afterwards.
|
2010-05-04 22:00:00 +02:00
|
|
|
|
if( trace.pHit ) SV_Impact( ent, &trace );
|
2009-11-02 22:00:00 +01:00
|
|
|
|
|
2010-04-17 22:00:00 +02:00
|
|
|
|
return trace;
|
2008-07-30 22:00:00 +02:00
|
|
|
|
}
|
2007-09-28 22:00:00 +02:00
|
|
|
|
|
2010-06-16 22:00:00 +02:00
|
|
|
|
static bool SV_CanPushed( edict_t *ent )
|
|
|
|
|
{
|
|
|
|
|
// filter movetypes to collide with
|
|
|
|
|
switch( ent->v.movetype )
|
|
|
|
|
{
|
|
|
|
|
case MOVETYPE_NONE:
|
|
|
|
|
case MOVETYPE_PUSH:
|
|
|
|
|
case MOVETYPE_FOLLOW:
|
|
|
|
|
case MOVETYPE_NOCLIP:
|
|
|
|
|
case MOVETYPE_COMPOUND:
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool SV_CanBlock( edict_t *ent )
|
|
|
|
|
{
|
|
|
|
|
if( ent->v.solid == SOLID_NOT || ent->v.solid == SOLID_TRIGGER )
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
// deadbody
|
|
|
|
|
if( ent->v.deadflag >= DEAD_DEAD )
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
// point entities never block push
|
|
|
|
|
if( VectorCompare( ent->v.mins, ent->v.maxs ))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-09 22:00:00 +01:00
|
|
|
|
/*
|
|
|
|
|
============
|
2010-06-16 22:00:00 +02:00
|
|
|
|
SV_PushMove
|
2010-03-09 22:00:00 +01:00
|
|
|
|
|
|
|
|
|
============
|
|
|
|
|
*/
|
2010-06-16 22:00:00 +02:00
|
|
|
|
static edict_t *SV_PushMove( edict_t *pusher, float movetime )
|
2010-03-09 22:00:00 +01:00
|
|
|
|
{
|
2010-04-17 22:00:00 +02:00
|
|
|
|
int i, e, block;
|
2010-06-16 22:00:00 +02:00
|
|
|
|
int num_moved, oldsolid;
|
|
|
|
|
vec3_t mins, maxs, lmove;
|
|
|
|
|
vec3_t entorg, pushorg;
|
|
|
|
|
edict_t *check, *moved_edict[MAX_EDICTS];
|
2010-03-09 22:00:00 +01:00
|
|
|
|
|
2010-06-16 22:00:00 +02:00
|
|
|
|
if( VectorIsNull( pusher->v.velocity ))
|
2010-04-17 22:00:00 +02:00
|
|
|
|
{
|
|
|
|
|
pusher->v.ltime += movetime;
|
2010-06-16 22:00:00 +02:00
|
|
|
|
return NULL;
|
2010-04-17 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for( i = 0; i < 3; i++ )
|
|
|
|
|
{
|
2010-06-16 22:00:00 +02:00
|
|
|
|
lmove[i] = pusher->v.velocity[i] * movetime;
|
|
|
|
|
mins[i] = pusher->v.absmin[i] + lmove[i];
|
|
|
|
|
maxs[i] = pusher->v.absmax[i] + lmove[i];
|
2010-04-17 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
2010-06-16 22:00:00 +02:00
|
|
|
|
VectorCopy( pusher->v.origin, pushorg );
|
|
|
|
|
|
2010-03-09 22:00:00 +01:00
|
|
|
|
// move the pusher to it's final position
|
2010-06-16 22:00:00 +02:00
|
|
|
|
SV_LinearMove( pusher, movetime, pusher->v.friction );
|
2010-03-09 22:00:00 +01:00
|
|
|
|
SV_LinkEdict( pusher, false );
|
2010-06-16 22:00:00 +02:00
|
|
|
|
pusher->v.ltime += movetime;
|
|
|
|
|
oldsolid = pusher->v.solid;
|
2010-03-09 22:00:00 +01:00
|
|
|
|
|
|
|
|
|
// see if any solid entities are inside the final position
|
2010-06-16 22:00:00 +02:00
|
|
|
|
num_moved = 0;
|
2010-03-09 22:00:00 +01:00
|
|
|
|
for( e = 1; e < svgame.globals->numEntities; e++ )
|
|
|
|
|
{
|
|
|
|
|
check = EDICT_NUM( e );
|
2010-06-16 22:00:00 +02:00
|
|
|
|
if( !SV_IsValidEdict( check )) continue;
|
2010-03-09 22:00:00 +01:00
|
|
|
|
|
|
|
|
|
// filter movetypes to collide with
|
2010-06-16 22:00:00 +02:00
|
|
|
|
if( !SV_CanPushed( check ))
|
2010-03-09 22:00:00 +01:00
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
pusher->v.solid = SOLID_NOT;
|
2010-06-16 22:00:00 +02:00
|
|
|
|
block = SV_TestEntityPosition( check );
|
2010-03-09 22:00:00 +01:00
|
|
|
|
pusher->v.solid = oldsolid;
|
|
|
|
|
if( block ) continue;
|
|
|
|
|
|
2010-06-16 22:00:00 +02:00
|
|
|
|
// if the entity is standing on the pusher, it will definately be moved
|
|
|
|
|
if( !(( check->v.flags & FL_ONGROUND ) && check->v.groundentity == pusher ))
|
2010-03-09 22:00:00 +01:00
|
|
|
|
{
|
|
|
|
|
if( check->v.absmin[0] >= maxs[0]
|
|
|
|
|
|| check->v.absmin[1] >= maxs[1]
|
|
|
|
|
|| check->v.absmin[2] >= maxs[2]
|
|
|
|
|
|| check->v.absmax[0] <= mins[0]
|
|
|
|
|
|| check->v.absmax[1] <= mins[1]
|
|
|
|
|
|| check->v.absmax[2] <= mins[2] )
|
|
|
|
|
continue;
|
2010-06-16 22:00:00 +02:00
|
|
|
|
|
|
|
|
|
// see if the ent's bbox is inside the pusher's final position
|
|
|
|
|
if( !SV_TestEntityPosition( check ))
|
|
|
|
|
continue;
|
2010-03-09 22:00:00 +01:00
|
|
|
|
}
|
|
|
|
|
|
2010-06-16 22:00:00 +02:00
|
|
|
|
VectorCopy( check->v.origin, entorg );
|
|
|
|
|
VectorCopy( check->v.origin, check->pvServerData->moved_origin );
|
|
|
|
|
moved_edict[num_moved] = check;
|
|
|
|
|
num_moved++;
|
|
|
|
|
|
|
|
|
|
// try moving the contacted entity
|
|
|
|
|
pusher->v.solid = SOLID_NOT;
|
|
|
|
|
SV_PushEntity( check, lmove, vec3_origin, &block );
|
|
|
|
|
pusher->v.solid = oldsolid;
|
|
|
|
|
|
|
|
|
|
// if it is still inside the pusher, block
|
|
|
|
|
if( block || SV_TestEntityPosition( check ))
|
|
|
|
|
{
|
|
|
|
|
if( !SV_CanBlock( check ))
|
|
|
|
|
continue;
|
2010-03-09 22:00:00 +01:00
|
|
|
|
|
2010-06-16 22:00:00 +02:00
|
|
|
|
// fail the move
|
|
|
|
|
VectorCopy( entorg, check->v.origin );
|
|
|
|
|
SV_LinkEdict( check, true );
|
|
|
|
|
|
|
|
|
|
VectorCopy( pushorg, pusher->v.origin );
|
|
|
|
|
SV_LinkEdict( pusher, false );
|
|
|
|
|
pusher->v.ltime -= movetime;
|
2010-03-09 22:00:00 +01:00
|
|
|
|
|
2010-06-16 22:00:00 +02:00
|
|
|
|
// move back any entities we already moved
|
|
|
|
|
for( i = 0; i < num_moved; i++ )
|
2010-04-12 22:00:00 +02:00
|
|
|
|
{
|
2010-06-16 22:00:00 +02:00
|
|
|
|
edict_t *ed = moved_edict[i];
|
2010-04-12 22:00:00 +02:00
|
|
|
|
|
2010-06-16 22:00:00 +02:00
|
|
|
|
VectorCopy( ed->pvServerData->moved_origin, ed->v.origin );
|
|
|
|
|
SV_LinkEdict( ed, false );
|
2010-04-12 22:00:00 +02:00
|
|
|
|
}
|
2010-06-16 22:00:00 +02:00
|
|
|
|
return check;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// if leaving it where it was, allow it to drop to the floor again
|
|
|
|
|
// (useful for plats that move downward)
|
|
|
|
|
check->v.flags &= ~FL_ONGROUND;
|
|
|
|
|
check->v.groundentity = NULL;
|
2010-04-12 22:00:00 +02:00
|
|
|
|
|
2010-06-16 22:00:00 +02:00
|
|
|
|
num_moved--;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2010-03-09 22:00:00 +01:00
|
|
|
|
|
2010-06-16 22:00:00 +02:00
|
|
|
|
/*
|
|
|
|
|
============
|
|
|
|
|
SV_PushRotate
|
|
|
|
|
|
|
|
|
|
============
|
|
|
|
|
*/
|
|
|
|
|
static edict_t *SV_PushRotate( edict_t *pusher, float movetime )
|
|
|
|
|
{
|
|
|
|
|
int i, e, block;
|
|
|
|
|
int num_moved, oldsolid;
|
|
|
|
|
vec3_t lmove, a, amove, entorg, pushang;
|
|
|
|
|
edict_t *check, *moved_edict[MAX_EDICTS];
|
|
|
|
|
vec3_t forward, right, up;
|
|
|
|
|
vec3_t org, org2;
|
2010-03-09 22:00:00 +01:00
|
|
|
|
|
2010-06-16 22:00:00 +02:00
|
|
|
|
if( VectorIsNull( pusher->v.avelocity ))
|
|
|
|
|
{
|
|
|
|
|
pusher->v.ltime += movetime;
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2010-03-09 22:00:00 +01:00
|
|
|
|
|
2010-06-16 22:00:00 +02:00
|
|
|
|
for( i = 0; i < 3; i++ )
|
|
|
|
|
amove[i] = pusher->v.avelocity[i] * movetime;
|
|
|
|
|
|
|
|
|
|
VectorNegate( amove, a );
|
|
|
|
|
AngleVectors( a, forward, right, up );
|
|
|
|
|
|
|
|
|
|
VectorCopy( pusher->v.angles, pushang );
|
|
|
|
|
|
|
|
|
|
// move the pusher to it's final position
|
|
|
|
|
SV_AngularMove( pusher, movetime, pusher->v.friction );
|
|
|
|
|
SV_LinkEdict( pusher, false );
|
|
|
|
|
pusher->v.ltime += movetime;
|
|
|
|
|
oldsolid = pusher->v.solid;
|
|
|
|
|
|
|
|
|
|
// see if any solid entities are inside the final position
|
|
|
|
|
num_moved = 0;
|
|
|
|
|
for( e = 1; e < svgame.globals->numEntities; e++ )
|
|
|
|
|
{
|
|
|
|
|
check = EDICT_NUM( e );
|
|
|
|
|
if( !SV_IsValidEdict( check )) continue;
|
|
|
|
|
|
|
|
|
|
// filter movetypes to collide with
|
|
|
|
|
if( !SV_CanPushed( check ))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
// if the entity is standing on the pusher, it will definately be moved
|
|
|
|
|
if( !(( check->v.flags & FL_ONGROUND ) && check->v.groundentity == pusher ))
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if( check->v.absmin[0] >= pusher->v.absmax[0]
|
|
|
|
|
|| check->v.absmin[1] >= pusher->v.absmax[1]
|
|
|
|
|
|| check->v.absmin[2] >= pusher->v.absmax[2]
|
|
|
|
|
|| check->v.absmax[0] <= pusher->v.absmin[0]
|
|
|
|
|
|| check->v.absmax[1] <= pusher->v.absmin[1]
|
|
|
|
|
|| check->v.absmax[2] <= pusher->v.absmin[2] )
|
2010-03-09 22:00:00 +01:00
|
|
|
|
continue;
|
|
|
|
|
|
2010-06-16 22:00:00 +02:00
|
|
|
|
// see if the ent's bbox is inside the pusher's final position
|
|
|
|
|
if( !SV_TestEntityPosition( check ))
|
2010-03-09 22:00:00 +01:00
|
|
|
|
continue;
|
|
|
|
|
}
|
2010-06-16 22:00:00 +02:00
|
|
|
|
|
|
|
|
|
VectorCopy( check->v.origin, entorg );
|
|
|
|
|
VectorCopy( check->v.origin, check->pvServerData->moved_origin );
|
|
|
|
|
VectorCopy( check->v.angles, check->pvServerData->moved_angles );
|
|
|
|
|
moved_edict[num_moved] = check;
|
|
|
|
|
num_moved++;
|
|
|
|
|
|
|
|
|
|
// calculate destination position
|
|
|
|
|
VectorSubtract( check->v.origin, pusher->v.origin, org );
|
|
|
|
|
org2[0] = DotProduct( org, forward );
|
|
|
|
|
org2[1] = -DotProduct( org, right );
|
|
|
|
|
org2[2] = DotProduct( org, up );
|
|
|
|
|
VectorSubtract( org2, org, lmove );
|
|
|
|
|
|
|
|
|
|
// try moving the contacted entity
|
|
|
|
|
#if 0
|
|
|
|
|
VectorAdd( check->v.angles, amove, check->v.angles );
|
|
|
|
|
VectorAdd( check->v.origin, lmove, check->v.origin );
|
|
|
|
|
block = false;
|
|
|
|
|
#else
|
|
|
|
|
pusher->v.solid = SOLID_NOT;
|
|
|
|
|
SV_PushEntity( check, lmove, amove, &block );
|
|
|
|
|
pusher->v.solid = oldsolid;
|
|
|
|
|
#endif
|
|
|
|
|
// if it is still inside the pusher, block
|
|
|
|
|
if( block || SV_TestEntityPosition( check ))
|
|
|
|
|
{
|
|
|
|
|
if( !SV_CanBlock( check ))
|
|
|
|
|
continue;
|
2010-03-09 22:00:00 +01:00
|
|
|
|
|
2010-06-16 22:00:00 +02:00
|
|
|
|
// fail the move
|
|
|
|
|
VectorCopy( entorg, check->v.origin );
|
|
|
|
|
SV_LinkEdict( check, true );
|
2010-03-09 22:00:00 +01:00
|
|
|
|
|
2010-06-16 22:00:00 +02:00
|
|
|
|
VectorCopy( pushang, pusher->v.angles );
|
|
|
|
|
SV_LinkEdict( pusher, false );
|
|
|
|
|
pusher->v.ltime -= movetime;
|
|
|
|
|
|
|
|
|
|
// move back any entities we already moved
|
|
|
|
|
for( i = 0; i < num_moved; i++ )
|
|
|
|
|
{
|
|
|
|
|
edict_t *ed = moved_edict[i];
|
|
|
|
|
sv_client_t *cl;
|
|
|
|
|
|
|
|
|
|
if( ed->v.flags & FL_CLIENT && ( cl = SV_ClientFromEdict( ed, true )) != NULL )
|
|
|
|
|
{
|
2010-06-20 22:00:00 +02:00
|
|
|
|
cl->addangle = 0.0f;
|
2010-06-16 22:00:00 +02:00
|
|
|
|
ed->v.fixangle = 0;
|
|
|
|
|
}
|
2010-03-09 22:00:00 +01:00
|
|
|
|
|
2010-06-16 22:00:00 +02:00
|
|
|
|
VectorCopy( ed->pvServerData->moved_origin, ed->v.origin );
|
|
|
|
|
VectorCopy( ed->pvServerData->moved_angles, ed->v.angles );
|
|
|
|
|
SV_LinkEdict( ed, false );
|
|
|
|
|
}
|
|
|
|
|
return check;
|
|
|
|
|
}
|
|
|
|
|
else
|
2010-03-09 22:00:00 +01:00
|
|
|
|
{
|
2010-06-16 22:00:00 +02:00
|
|
|
|
SV_AngularMove( check, movetime, pusher->v.friction );
|
2010-03-09 22:00:00 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
2010-06-16 22:00:00 +02:00
|
|
|
|
return NULL;
|
2010-03-09 22:00:00 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
============
|
2010-06-16 22:00:00 +02:00
|
|
|
|
SV_PushComplex
|
2010-03-09 22:00:00 +01:00
|
|
|
|
|
|
|
|
|
============
|
|
|
|
|
*/
|
2010-06-16 22:00:00 +02:00
|
|
|
|
void SV_PushComplex( edict_t *pusher, float movetime )
|
2010-03-09 22:00:00 +01:00
|
|
|
|
{
|
2010-04-17 22:00:00 +02:00
|
|
|
|
int i, e, oldsolid, num_moved;
|
|
|
|
|
vec3_t a, lmove, amove, org, org2, move2;
|
2010-06-16 22:00:00 +02:00
|
|
|
|
vec3_t forward, right, up, pushorg, pushang, test;
|
2010-04-17 22:00:00 +02:00
|
|
|
|
edict_t *check, *pusherowner, *moved_edict[MAX_EDICTS];
|
|
|
|
|
bool rotated, blocked;
|
|
|
|
|
vec3_t mins, maxs;
|
|
|
|
|
float pushltime;
|
|
|
|
|
trace_t trace;
|
2010-06-16 22:00:00 +02:00
|
|
|
|
chull_t *hull;
|
2010-04-17 22:00:00 +02:00
|
|
|
|
|
|
|
|
|
switch( pusher->v.solid )
|
|
|
|
|
{
|
|
|
|
|
case SOLID_BSP:
|
|
|
|
|
case SOLID_BBOX:
|
|
|
|
|
case SOLID_SLIDEBOX:
|
|
|
|
|
break;
|
|
|
|
|
case SOLID_NOT:
|
|
|
|
|
case SOLID_TRIGGER:
|
|
|
|
|
SV_LinearMove( pusher, movetime, pusher->v.friction );
|
|
|
|
|
SV_AngularMove( pusher, movetime, pusher->v.friction );
|
|
|
|
|
pusher->v.ltime += movetime;
|
|
|
|
|
SV_LinkEdict( pusher, false );
|
|
|
|
|
return;
|
|
|
|
|
default:
|
|
|
|
|
Host_Error( "SV_PushMove: invalid solid type %i\n", pusher->v.solid );
|
|
|
|
|
}
|
2010-03-09 22:00:00 +01:00
|
|
|
|
|
|
|
|
|
if( VectorIsNull( pusher->v.velocity ) && VectorIsNull( pusher->v.avelocity ))
|
|
|
|
|
{
|
2010-04-17 22:00:00 +02:00
|
|
|
|
// advances ltime when stop too for thinking
|
2010-03-09 22:00:00 +01:00
|
|
|
|
pusher->v.ltime += movetime;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for( i = 0; i < 3; i++ )
|
|
|
|
|
{
|
2010-04-17 22:00:00 +02:00
|
|
|
|
lmove[i] = pusher->v.velocity[i] * movetime;
|
2010-03-09 22:00:00 +01:00
|
|
|
|
amove[i] = pusher->v.avelocity[i] * movetime;
|
2010-04-17 22:00:00 +02:00
|
|
|
|
mins[i] = pusher->v.absmin[i] + lmove[i];
|
|
|
|
|
maxs[i] = pusher->v.absmax[i] + lmove[i];
|
2010-03-09 22:00:00 +01:00
|
|
|
|
}
|
|
|
|
|
|
2010-04-17 22:00:00 +02:00
|
|
|
|
pusherowner = pusher->v.owner;
|
|
|
|
|
rotated = !VectorIsNull( amove );
|
2010-03-09 22:00:00 +01:00
|
|
|
|
|
2010-04-17 22:00:00 +02:00
|
|
|
|
VectorNegate( amove, a );
|
|
|
|
|
AngleVectors( a, forward, right, up );
|
2007-09-17 22:00:00 +02:00
|
|
|
|
|
2010-04-17 22:00:00 +02:00
|
|
|
|
// save pusher parms
|
|
|
|
|
VectorCopy( pusher->v.origin, pushorg );
|
|
|
|
|
VectorCopy( pusher->v.angles, pushang );
|
|
|
|
|
pushltime = pusher->v.ltime;
|
2010-03-09 22:00:00 +01:00
|
|
|
|
|
2010-04-17 22:00:00 +02:00
|
|
|
|
// getting real bbox size
|
2010-06-16 22:00:00 +02:00
|
|
|
|
// SV_TransformedBBox( pusher, mins, maxs );
|
2010-03-09 22:00:00 +01:00
|
|
|
|
|
2010-04-17 22:00:00 +02:00
|
|
|
|
// move the pusher to it's final position
|
|
|
|
|
SV_LinearMove( pusher, movetime, pusher->v.friction );
|
|
|
|
|
SV_AngularMove( pusher, movetime, pusher->v.friction );
|
|
|
|
|
pusher->v.ltime += movetime;
|
|
|
|
|
SV_LinkEdict( pusher, false );
|
2010-03-09 22:00:00 +01:00
|
|
|
|
|
2010-04-17 22:00:00 +02:00
|
|
|
|
num_moved = 0;
|
|
|
|
|
oldsolid = pusher->v.solid;
|
2010-03-09 22:00:00 +01:00
|
|
|
|
|
2010-04-17 22:00:00 +02:00
|
|
|
|
// see if any solid entities are inside the final position
|
|
|
|
|
for( e = 1; e < svgame.globals->numEntities; e++ )
|
2010-03-09 22:00:00 +01:00
|
|
|
|
{
|
2010-04-17 22:00:00 +02:00
|
|
|
|
check = EDICT_NUM( e );
|
|
|
|
|
if( !SV_IsValidEdict( check )) continue;
|
2010-03-09 22:00:00 +01:00
|
|
|
|
|
2010-04-17 22:00:00 +02:00
|
|
|
|
// filter movetypes to collide with
|
|
|
|
|
switch( check->v.movetype )
|
|
|
|
|
{
|
|
|
|
|
case MOVETYPE_NONE:
|
|
|
|
|
case MOVETYPE_PUSH:
|
|
|
|
|
case MOVETYPE_FOLLOW:
|
|
|
|
|
case MOVETYPE_NOCLIP:
|
|
|
|
|
case MOVETYPE_COMPOUND:
|
|
|
|
|
continue;
|
|
|
|
|
default: break;
|
|
|
|
|
}
|
2010-03-09 22:00:00 +01:00
|
|
|
|
|
2010-04-17 22:00:00 +02:00
|
|
|
|
if( check->v.owner == pusher )
|
|
|
|
|
continue;
|
|
|
|
|
if( pusherowner == check )
|
|
|
|
|
continue;
|
2010-03-09 22:00:00 +01:00
|
|
|
|
|
2010-06-16 22:00:00 +02:00
|
|
|
|
// if the entity is standing on the pusher, it will definately be moved
|
2010-04-17 22:00:00 +02:00
|
|
|
|
if( !(( check->v.flags & FL_ONGROUND ) && check->v.groundentity == pusher ))
|
2010-03-09 22:00:00 +01:00
|
|
|
|
{
|
2010-04-17 22:00:00 +02:00
|
|
|
|
// see if the ent needs to be tested
|
2010-06-16 22:00:00 +02:00
|
|
|
|
if( !BoundsIntersect( check->v.absmin, check->v.absmax, mins, maxs ))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
hull = CM_HullForBsp( pusher, check->v.mins, check->v.maxs, test );
|
|
|
|
|
|
|
|
|
|
// offset the test point appropriately for this hull.
|
|
|
|
|
VectorSubtract( check->v.origin, test, test );
|
|
|
|
|
|
|
|
|
|
// test hull for intersection with this model
|
|
|
|
|
if( CM_HullPointContents( hull, hull->firstclipnode, test ) == CONTENTS_EMPTY )
|
|
|
|
|
continue;
|
|
|
|
|
/*
|
2010-04-17 22:00:00 +02:00
|
|
|
|
if( check->v.absmin[0] >= maxs[0]
|
|
|
|
|
|| check->v.absmin[1] >= maxs[1]
|
|
|
|
|
|| check->v.absmin[2] >= maxs[2]
|
|
|
|
|
|| check->v.absmax[0] <= mins[0]
|
|
|
|
|
|| check->v.absmax[1] <= mins[1]
|
|
|
|
|
|| check->v.absmax[2] <= mins[2] )
|
|
|
|
|
continue;
|
2010-06-16 22:00:00 +02:00
|
|
|
|
*/
|
|
|
|
|
// see if the ent's bbox is inside the pusher's final position
|
|
|
|
|
// if( !SV_TestEntityPosition( check ))
|
|
|
|
|
// continue;
|
2010-04-17 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
VectorCopy( check->v.origin, check->pvServerData->moved_origin );
|
|
|
|
|
VectorCopy( check->v.angles, check->pvServerData->moved_angles );
|
|
|
|
|
moved_edict[num_moved++] = check;
|
|
|
|
|
|
|
|
|
|
// try moving the contacted entity
|
|
|
|
|
pusher->v.solid = SOLID_NOT;
|
|
|
|
|
trace = SV_PushEntity( check, lmove, amove, &blocked );
|
|
|
|
|
pusher->v.solid = oldsolid; // was SOLID_BSP
|
|
|
|
|
|
|
|
|
|
if( check->v.groundentity == pusher )
|
|
|
|
|
{
|
|
|
|
|
blocked = false; // probably groundents can't block pusher
|
|
|
|
|
check->v.flags |= FL_ONGROUND;
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-18 22:00:00 +02:00
|
|
|
|
if( rotated && !blocked )
|
2010-04-17 22:00:00 +02:00
|
|
|
|
{
|
|
|
|
|
// figure movement due to the pusher's amove
|
|
|
|
|
VectorSubtract( check->v.origin, pusher->v.origin, org );
|
|
|
|
|
org2[0] = DotProduct( org, forward );
|
|
|
|
|
org2[1] = -DotProduct( org, right );
|
|
|
|
|
org2[2] = DotProduct( org, up );
|
|
|
|
|
VectorSubtract( org2, org, move2 );
|
|
|
|
|
|
|
|
|
|
pusher->v.solid = SOLID_NOT;
|
|
|
|
|
trace = SV_PushEntity( check, move2, vec3_origin, &blocked );
|
|
|
|
|
pusher->v.solid = oldsolid; // was SOLID_BSP
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// remove the onground flag for non-players
|
|
|
|
|
if( check->v.movetype != MOVETYPE_WALK && ( trace.flFraction < 1.0f || check->v.groundentity != pusher ))
|
|
|
|
|
check->v.flags &= ~FL_ONGROUND;
|
|
|
|
|
|
|
|
|
|
// if it is still inside the pusher, block
|
2010-06-16 22:00:00 +02:00
|
|
|
|
if( blocked || SV_TestEntityPosition( check ))
|
2010-04-17 22:00:00 +02:00
|
|
|
|
{
|
|
|
|
|
// fail the move
|
|
|
|
|
if( check->v.mins[0] == check->v.maxs[0] )
|
|
|
|
|
continue;
|
|
|
|
|
|
2010-06-16 22:00:00 +02:00
|
|
|
|
if( check->v.solid == SOLID_NOT || check->v.solid == SOLID_TRIGGER || check->v.deadflag >= DEAD_DEAD )
|
2010-04-17 22:00:00 +02:00
|
|
|
|
{
|
|
|
|
|
// corpse
|
|
|
|
|
check->v.mins[0] = check->v.mins[1] = 0;
|
|
|
|
|
VectorCopy( check->v.mins, check->v.maxs );
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// restore oldpos
|
|
|
|
|
VectorCopy( pushorg, pusher->v.origin );
|
|
|
|
|
VectorCopy( pushang, pusher->v.angles );
|
|
|
|
|
pusher->v.ltime = pushltime;
|
|
|
|
|
SV_LinkEdict( pusher, false );
|
|
|
|
|
|
|
|
|
|
// move back any entities we already moved
|
|
|
|
|
for( i = 0; i < num_moved; i++ )
|
|
|
|
|
{
|
2010-04-18 22:00:00 +02:00
|
|
|
|
edict_t *ed = moved_edict[i];
|
|
|
|
|
sv_client_t *cl;
|
|
|
|
|
|
|
|
|
|
if( ed->v.flags & FL_CLIENT && ( cl = SV_ClientFromEdict( ed, true )) != NULL )
|
|
|
|
|
{
|
2010-06-20 22:00:00 +02:00
|
|
|
|
cl->addangle = 0.0f;
|
2010-04-18 22:00:00 +02:00
|
|
|
|
ed->v.fixangle = 0;
|
|
|
|
|
}
|
2010-04-17 22:00:00 +02:00
|
|
|
|
|
|
|
|
|
VectorCopy( ed->pvServerData->moved_origin, ed->v.origin );
|
|
|
|
|
VectorCopy( ed->pvServerData->moved_angles, ed->v.angles );
|
|
|
|
|
SV_LinkEdict( ed, false );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// call the pusher "blocked" function
|
|
|
|
|
svgame.dllFuncs.pfnBlocked( pusher, check );
|
|
|
|
|
return;
|
2010-03-09 22:00:00 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
================
|
|
|
|
|
SV_Physics_Pusher
|
|
|
|
|
|
|
|
|
|
================
|
|
|
|
|
*/
|
2010-04-17 22:00:00 +02:00
|
|
|
|
void SV_Physics_Pusher( edict_t *ent )
|
2007-09-17 22:00:00 +02:00
|
|
|
|
{
|
2010-06-16 22:00:00 +02:00
|
|
|
|
float oldtime, oldtime2;
|
|
|
|
|
float thinktime, movetime;
|
|
|
|
|
edict_t *pBlocker;
|
2007-09-17 22:00:00 +02:00
|
|
|
|
|
2010-06-16 22:00:00 +02:00
|
|
|
|
pBlocker = NULL;
|
|
|
|
|
oldtime = ent->v.ltime;
|
2008-12-15 22:00:00 +01:00
|
|
|
|
thinktime = ent->v.nextthink;
|
2007-09-28 22:00:00 +02:00
|
|
|
|
|
2010-06-20 22:00:00 +02:00
|
|
|
|
if( thinktime < ent->v.ltime + sv.frametime )
|
2008-07-30 22:00:00 +02:00
|
|
|
|
{
|
2008-12-15 22:00:00 +01:00
|
|
|
|
movetime = thinktime - ent->v.ltime;
|
2010-04-17 22:00:00 +02:00
|
|
|
|
if( movetime < 0.0f ) movetime = 0.0f;
|
2008-07-30 22:00:00 +02:00
|
|
|
|
}
|
2010-06-20 22:00:00 +02:00
|
|
|
|
else movetime = sv.frametime;
|
2007-09-17 22:00:00 +02:00
|
|
|
|
|
2010-04-17 22:00:00 +02:00
|
|
|
|
if( movetime )
|
|
|
|
|
{
|
2010-06-16 22:00:00 +02:00
|
|
|
|
if( VectorLength2( ent->v.avelocity ) > STOP_EPSILON )
|
|
|
|
|
{
|
|
|
|
|
if( VectorLength2( ent->v.velocity ) > STOP_EPSILON )
|
|
|
|
|
{
|
|
|
|
|
pBlocker = SV_PushRotate( ent, movetime );
|
|
|
|
|
|
|
|
|
|
if( !pBlocker )
|
|
|
|
|
{
|
|
|
|
|
oldtime2 = ent->v.ltime;
|
|
|
|
|
|
|
|
|
|
// reset the local time to what it was before we rotated
|
|
|
|
|
ent->v.ltime = oldtime;
|
|
|
|
|
pBlocker = SV_PushMove( ent, movetime );
|
|
|
|
|
if( ent->v.ltime < oldtime2 )
|
|
|
|
|
ent->v.ltime = oldtime2;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
pBlocker = SV_PushRotate( ent, movetime );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
pBlocker = SV_PushMove( ent, movetime );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// if the pusher has a "blocked" function, call it
|
|
|
|
|
// otherwise, just stay in place until the obstacle is gone
|
|
|
|
|
if( pBlocker )
|
|
|
|
|
{
|
|
|
|
|
Msg( "%s is blocked by %s\n", SV_ClassName( ent ), SV_ClassName( pBlocker ));
|
|
|
|
|
svgame.dllFuncs.pfnBlocked( ent, pBlocker );
|
2010-04-17 22:00:00 +02:00
|
|
|
|
}
|
2009-11-02 22:00:00 +01:00
|
|
|
|
|
2010-06-17 22:00:00 +02:00
|
|
|
|
if(( thinktime > oldtime && thinktime <= ent->v.ltime ) || ( ent->v.flags & FL_ALWAYSTHINK ))
|
2008-07-30 22:00:00 +02:00
|
|
|
|
{
|
2010-04-17 22:00:00 +02:00
|
|
|
|
ent->v.nextthink = 0.0f;
|
2008-12-26 22:00:00 +01:00
|
|
|
|
svgame.dllFuncs.pfnThink( ent );
|
2010-04-17 22:00:00 +02:00
|
|
|
|
if( ent->free ) return;
|
2009-11-02 22:00:00 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
2007-09-17 22:00:00 +02:00
|
|
|
|
|
2008-07-30 22:00:00 +02:00
|
|
|
|
/*
|
|
|
|
|
=============
|
2010-04-17 22:00:00 +02:00
|
|
|
|
SV_Physics_Compound
|
2008-07-30 22:00:00 +02:00
|
|
|
|
|
2009-11-02 22:00:00 +01:00
|
|
|
|
Entities that are "stuck" to another entity
|
2010-04-13 22:00:00 +02:00
|
|
|
|
assume oldorigin as originoffset and oldangles as angle difference
|
2008-07-30 22:00:00 +02:00
|
|
|
|
=============
|
|
|
|
|
*/
|
2010-04-17 22:00:00 +02:00
|
|
|
|
void SV_Physics_Compound( edict_t *ent )
|
2008-07-30 22:00:00 +02:00
|
|
|
|
{
|
2010-04-17 22:00:00 +02:00
|
|
|
|
vec3_t vf, vr, vu, angles;
|
2010-04-13 22:00:00 +02:00
|
|
|
|
edict_t *parent;
|
2008-07-30 22:00:00 +02:00
|
|
|
|
|
2009-11-02 22:00:00 +01:00
|
|
|
|
// regular thinking
|
2010-04-13 22:00:00 +02:00
|
|
|
|
if( !SV_RunThink( ent )) return;
|
|
|
|
|
|
2010-04-17 22:00:00 +02:00
|
|
|
|
parent = ent->v.aiment;
|
|
|
|
|
if( !SV_IsValidEdict( parent )) return;
|
|
|
|
|
|
2010-04-13 22:00:00 +02:00
|
|
|
|
// force to hold current values as offsets
|
2010-04-17 22:00:00 +02:00
|
|
|
|
if( ent->v.effects & EF_NOINTERP )
|
2010-04-13 22:00:00 +02:00
|
|
|
|
{
|
2010-04-17 22:00:00 +02:00
|
|
|
|
VectorSubtract( ent->v.origin, parent->v.origin, ent->v.oldorigin );
|
|
|
|
|
VectorSubtract( ent->v.angles, parent->v.angles, ent->v.oldangles );
|
|
|
|
|
ent->v.effects &= ~EF_NOINTERP; // done
|
2010-04-13 22:00:00 +02:00
|
|
|
|
}
|
2007-09-17 22:00:00 +02:00
|
|
|
|
|
2010-04-13 22:00:00 +02:00
|
|
|
|
if( VectorCompare( parent->v.angles, ent->v.oldangles ))
|
2007-09-17 22:00:00 +02:00
|
|
|
|
{
|
2009-11-02 22:00:00 +01:00
|
|
|
|
// quick case for no rotation
|
2010-04-13 22:00:00 +02:00
|
|
|
|
VectorAdd( parent->v.origin, ent->v.oldorigin, ent->v.origin );
|
2009-11-02 22:00:00 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2010-04-17 22:00:00 +02:00
|
|
|
|
vec3_t org, org2, move;
|
|
|
|
|
|
|
|
|
|
VectorAdd( parent->v.origin, ent->v.oldorigin, ent->v.origin );
|
2010-04-13 22:00:00 +02:00
|
|
|
|
|
2010-04-17 22:00:00 +02:00
|
|
|
|
VectorSubtract( ent->v.origin, parent->v.origin, org );
|
|
|
|
|
VectorNegate( parent->v.angles, angles );
|
2009-11-02 22:00:00 +01:00
|
|
|
|
AngleVectors( angles, vf, vr, vu );
|
2010-04-17 22:00:00 +02:00
|
|
|
|
org2[0] = DotProduct( ent->v.oldorigin, vf );
|
|
|
|
|
org2[1] = -DotProduct( ent->v.oldorigin, vr );
|
|
|
|
|
org2[2] = DotProduct( ent->v.oldorigin, vu );
|
|
|
|
|
VectorSubtract( org2, ent->v.oldorigin, move );
|
|
|
|
|
VectorAdd( ent->v.origin, move, ent->v.origin );
|
2009-11-02 22:00:00 +01:00
|
|
|
|
}
|
2009-11-30 22:00:00 +01:00
|
|
|
|
|
2010-04-13 22:00:00 +02:00
|
|
|
|
VectorAdd( parent->v.angles, ent->v.oldangles, ent->v.angles );
|
2009-11-30 22:00:00 +01:00
|
|
|
|
SV_LinkEdict( ent, false );
|
2009-11-02 22:00:00 +01:00
|
|
|
|
}
|
|
|
|
|
|
2010-04-17 22:00:00 +02:00
|
|
|
|
/*
|
|
|
|
|
=============
|
|
|
|
|
SV_Physics_Follow
|
|
|
|
|
|
|
|
|
|
just copy angles and origin of parent
|
|
|
|
|
=============
|
|
|
|
|
*/
|
|
|
|
|
void SV_Physics_Follow( edict_t *ent )
|
|
|
|
|
{
|
|
|
|
|
edict_t *parent;
|
|
|
|
|
|
|
|
|
|
// regular thinking
|
|
|
|
|
if( !SV_RunThink( ent )) return;
|
|
|
|
|
|
|
|
|
|
parent = ent->v.aiment;
|
|
|
|
|
if( !SV_IsValidEdict( parent )) return;
|
|
|
|
|
|
|
|
|
|
VectorCopy( parent->v.origin, ent->v.origin );
|
|
|
|
|
VectorCopy( parent->v.angles, ent->v.angles );
|
|
|
|
|
|
|
|
|
|
SV_LinkEdict( ent, false ); // nocip ents never touch triggers
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-02 22:00:00 +01:00
|
|
|
|
/*
|
|
|
|
|
=============
|
|
|
|
|
SV_PhysicsNoclip
|
|
|
|
|
|
|
|
|
|
A moving object that doesn't obey physics
|
|
|
|
|
=============
|
|
|
|
|
*/
|
|
|
|
|
void SV_Physics_Noclip( edict_t *ent )
|
|
|
|
|
{
|
|
|
|
|
// regular thinking
|
|
|
|
|
if( !SV_RunThink( ent )) return;
|
|
|
|
|
|
|
|
|
|
SV_CheckWater( ent );
|
|
|
|
|
|
2010-06-20 22:00:00 +02:00
|
|
|
|
VectorMA( ent->v.origin, sv.frametime, ent->v.velocity, ent->v.origin );
|
|
|
|
|
VectorMA( ent->v.angles, sv.frametime, ent->v.avelocity, ent->v.angles );
|
2010-04-17 22:00:00 +02:00
|
|
|
|
|
2009-11-02 22:00:00 +01:00
|
|
|
|
SV_LinkEdict( ent, false ); // nocip ents never touch triggers
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
==============================================================================
|
|
|
|
|
|
|
|
|
|
TOSS / BOUNCE
|
|
|
|
|
|
|
|
|
|
==============================================================================
|
|
|
|
|
*/
|
|
|
|
|
/*
|
|
|
|
|
=============
|
|
|
|
|
SV_CheckWaterTransition
|
|
|
|
|
|
|
|
|
|
=============
|
|
|
|
|
*/
|
|
|
|
|
void SV_CheckWaterTransition( edict_t *ent )
|
|
|
|
|
{
|
|
|
|
|
int cont = SV_PointContents( ent->v.origin );
|
|
|
|
|
|
|
|
|
|
if( !ent->v.watertype )
|
|
|
|
|
{
|
|
|
|
|
// just spawned here
|
|
|
|
|
ent->v.watertype = cont;
|
|
|
|
|
ent->v.waterlevel = 1;
|
2007-09-17 22:00:00 +02:00
|
|
|
|
return;
|
|
|
|
|
}
|
2008-12-26 22:00:00 +01:00
|
|
|
|
|
2009-11-02 22:00:00 +01:00
|
|
|
|
// check if the entity crossed into or out of water
|
|
|
|
|
if( ent->v.watertype <= CONTENTS_WATER )
|
|
|
|
|
{
|
|
|
|
|
ent->v.watertype = cont;
|
|
|
|
|
ent->v.waterlevel = 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ent->v.watertype = CONTENTS_EMPTY;
|
2009-11-29 22:00:00 +01:00
|
|
|
|
ent->v.waterlevel = 0;
|
2009-11-02 22:00:00 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-01 22:00:00 +01:00
|
|
|
|
/*
|
|
|
|
|
=============
|
|
|
|
|
SV_Physics_Toss
|
|
|
|
|
|
|
|
|
|
Toss, bounce, and fly movement. When onground, do nothing.
|
|
|
|
|
=============
|
|
|
|
|
*/
|
|
|
|
|
void SV_Physics_Toss( edict_t *ent )
|
|
|
|
|
{
|
|
|
|
|
trace_t trace;
|
|
|
|
|
vec3_t move;
|
|
|
|
|
float backoff;
|
|
|
|
|
|
|
|
|
|
// regular thinking
|
|
|
|
|
if( !SV_RunThink( ent )) return;
|
|
|
|
|
|
2010-04-17 22:00:00 +02:00
|
|
|
|
SV_CheckWaterTransition( ent );
|
|
|
|
|
SV_CheckWater( ent );
|
2009-12-01 22:00:00 +01:00
|
|
|
|
|
|
|
|
|
if( ent->v.velocity[2] > DIST_EPSILON )
|
|
|
|
|
{
|
|
|
|
|
ent->v.flags &= ~FL_ONGROUND;
|
|
|
|
|
ent->v.groundentity = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-17 22:00:00 +02:00
|
|
|
|
// if on ground and not moving, return.
|
|
|
|
|
if( ent->v.flags & FL_ONGROUND && SV_IsValidEdict( ent->v.groundentity ))
|
2009-12-01 22:00:00 +01:00
|
|
|
|
{
|
|
|
|
|
if( VectorIsNull( ent->v.basevelocity ) && VectorIsNull( ent->v.velocity ))
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SV_CheckVelocity( ent );
|
|
|
|
|
|
|
|
|
|
// add gravity
|
|
|
|
|
switch( ent->v.movetype )
|
|
|
|
|
{
|
|
|
|
|
case MOVETYPE_FLY:
|
|
|
|
|
case MOVETYPE_FLYMISSILE:
|
2010-04-17 22:00:00 +02:00
|
|
|
|
case MOVETYPE_BOUNCEMISSILE:
|
2009-12-01 22:00:00 +01:00
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
SV_AddGravity( ent );
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// move angles (with friction)
|
|
|
|
|
switch( ent->v.movetype )
|
|
|
|
|
{
|
|
|
|
|
case MOVETYPE_TOSS:
|
|
|
|
|
case MOVETYPE_BOUNCE:
|
2010-06-20 22:00:00 +02:00
|
|
|
|
SV_AngularMove( ent, sv.frametime, ent->v.friction );
|
2009-12-01 22:00:00 +01:00
|
|
|
|
break;
|
|
|
|
|
default:
|
2010-06-20 22:00:00 +02:00
|
|
|
|
SV_AngularMove( ent, sv.frametime, 0.0f );
|
2009-12-01 22:00:00 +01:00
|
|
|
|
break;
|
|
|
|
|
}
|
2010-04-17 22:00:00 +02:00
|
|
|
|
|
2009-12-01 22:00:00 +01:00
|
|
|
|
// move origin
|
|
|
|
|
// Base velocity is not properly accounted for since this entity will move again
|
|
|
|
|
// after the bounce without taking it into account
|
|
|
|
|
VectorAdd( ent->v.velocity, ent->v.basevelocity, ent->v.velocity );
|
|
|
|
|
|
|
|
|
|
SV_CheckVelocity( ent );
|
2010-06-20 22:00:00 +02:00
|
|
|
|
VectorScale( ent->v.velocity, sv.frametime, move );
|
2009-12-01 22:00:00 +01:00
|
|
|
|
VectorSubtract( ent->v.velocity, ent->v.basevelocity, ent->v.velocity );
|
|
|
|
|
|
2010-04-17 22:00:00 +02:00
|
|
|
|
trace = SV_PushEntity( ent, move, vec3_origin, NULL );
|
2009-12-01 22:00:00 +01:00
|
|
|
|
if( ent->free ) return;
|
|
|
|
|
|
|
|
|
|
SV_CheckVelocity( ent );
|
|
|
|
|
|
|
|
|
|
if( trace.fAllSolid )
|
|
|
|
|
{
|
|
|
|
|
// entity is trapped in another solid
|
|
|
|
|
ent->v.flags |= FL_ONGROUND;
|
|
|
|
|
ent->v.groundentity = trace.pHit;
|
|
|
|
|
VectorClear( ent->v.velocity );
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( trace.flFraction == 1.0f )
|
|
|
|
|
{
|
2010-04-17 22:00:00 +02:00
|
|
|
|
SV_CheckWater( ent );
|
2009-12-01 22:00:00 +01:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( ent->v.movetype == MOVETYPE_BOUNCE )
|
|
|
|
|
backoff = 2.0f - ent->v.friction;
|
|
|
|
|
else if( ent->v.movetype == MOVETYPE_BOUNCEMISSILE )
|
|
|
|
|
backoff = 2.0f;
|
|
|
|
|
else backoff = 1.0f;
|
|
|
|
|
|
|
|
|
|
SV_ClipVelocity( ent->v.velocity, trace.vecPlaneNormal, ent->v.velocity, backoff );
|
|
|
|
|
|
|
|
|
|
// stop if on ground
|
|
|
|
|
if( trace.vecPlaneNormal[2] > 0.7f )
|
|
|
|
|
{
|
|
|
|
|
float vel;
|
|
|
|
|
|
2010-06-20 22:00:00 +02:00
|
|
|
|
if( ent->v.velocity[2] < sv_gravity->value * sv.frametime )
|
2009-12-01 22:00:00 +01:00
|
|
|
|
{
|
|
|
|
|
// we're rolling on the ground, add static friction.
|
|
|
|
|
ent->v.groundentity = trace.pHit;
|
|
|
|
|
ent->v.flags |= FL_ONGROUND;
|
2010-04-17 22:00:00 +02:00
|
|
|
|
ent->v.velocity[2] = 0.0f;
|
2009-12-01 22:00:00 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
vel = DotProduct( ent->v.velocity, ent->v.velocity );
|
|
|
|
|
|
|
|
|
|
if( vel < 900 || ( ent->v.movetype != MOVETYPE_BOUNCE && ent->v.movetype != MOVETYPE_BOUNCEMISSILE ))
|
|
|
|
|
{
|
|
|
|
|
ent->v.flags |= FL_ONGROUND;
|
|
|
|
|
ent->v.groundentity = trace.pHit;
|
2010-04-17 22:00:00 +02:00
|
|
|
|
VectorClear( ent->v.velocity ); // avelocity clearing in server.dll
|
2009-12-01 22:00:00 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2010-06-20 22:00:00 +02:00
|
|
|
|
VectorScale( ent->v.velocity, (1.0f - trace.flFraction) * sv.frametime * 0.9f, move );
|
2010-04-17 22:00:00 +02:00
|
|
|
|
trace = SV_PushEntity( ent, move, vec3_origin, NULL );
|
2009-12-01 22:00:00 +01:00
|
|
|
|
if( ent->free ) return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// check for in water
|
|
|
|
|
SV_CheckWater( ent );
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-02 22:00:00 +01:00
|
|
|
|
/*
|
|
|
|
|
===============================================================================
|
|
|
|
|
|
|
|
|
|
STEPPING MOVEMENT
|
|
|
|
|
|
|
|
|
|
===============================================================================
|
|
|
|
|
*/
|
|
|
|
|
/*
|
|
|
|
|
=============
|
|
|
|
|
SV_Physics_Step
|
|
|
|
|
|
|
|
|
|
Monsters freefall when they don't have a ground entity, otherwise
|
|
|
|
|
all movement is done with discrete steps.
|
|
|
|
|
|
|
|
|
|
This is also used for objects that have become still on the ground, but
|
|
|
|
|
will fall if the floor is pulled out from under them.
|
|
|
|
|
=============
|
|
|
|
|
*/
|
2010-04-17 22:00:00 +02:00
|
|
|
|
void SV_Physics_Step( edict_t *ent )
|
2009-11-02 22:00:00 +01:00
|
|
|
|
{
|
2010-04-01 22:00:00 +02:00
|
|
|
|
bool wasonground;
|
|
|
|
|
bool inwater;
|
|
|
|
|
bool hitsound = false;
|
|
|
|
|
bool isfalling = false;
|
|
|
|
|
trace_t trace;
|
2009-11-02 22:00:00 +01:00
|
|
|
|
|
2010-04-01 22:00:00 +02:00
|
|
|
|
SV_CheckVelocity( ent );
|
2009-11-02 22:00:00 +01:00
|
|
|
|
|
2010-04-01 22:00:00 +02:00
|
|
|
|
wasonground = (ent->v.flags & FL_ONGROUND) ? true : false;
|
2009-11-02 22:00:00 +01:00
|
|
|
|
|
2009-12-01 22:00:00 +01:00
|
|
|
|
// add gravity except:
|
|
|
|
|
// flying monsters
|
|
|
|
|
// swimming monsters who are in the water
|
|
|
|
|
inwater = SV_CheckWater( ent );
|
|
|
|
|
|
|
|
|
|
if( !wasonground )
|
2009-11-02 22:00:00 +01:00
|
|
|
|
{
|
2009-12-01 22:00:00 +01:00
|
|
|
|
if( !( ent->v.flags & FL_FLY ))
|
2009-11-02 22:00:00 +01:00
|
|
|
|
{
|
2009-12-02 22:00:00 +01:00
|
|
|
|
if(!( ent->v.flags & (FL_SWIM|FL_FLOAT) && ent->v.waterlevel > 0 ))
|
2010-04-01 22:00:00 +02:00
|
|
|
|
{
|
2010-06-20 22:00:00 +02:00
|
|
|
|
if( ent->v.velocity[2] < ( sv_gravity->value * -sv.frametime ))
|
2010-04-01 22:00:00 +02:00
|
|
|
|
{
|
|
|
|
|
hitsound = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( !inwater )
|
|
|
|
|
{
|
2010-06-20 22:00:00 +02:00
|
|
|
|
SV_AddHalfGravity( ent, sv.frametime );
|
2010-04-01 22:00:00 +02:00
|
|
|
|
isfalling = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-04-02 22:00:00 +02:00
|
|
|
|
else if( ent->v.waterlevel > 0 )
|
2010-04-01 22:00:00 +02:00
|
|
|
|
{
|
2010-04-02 22:00:00 +02:00
|
|
|
|
if( ent->v.waterlevel > 1 )
|
|
|
|
|
{
|
|
|
|
|
VectorScale( ent->v.velocity, 0.9f, ent->v.velocity );
|
2010-06-20 22:00:00 +02:00
|
|
|
|
ent->v.velocity[2] += ( ent->v.skin * sv.frametime );
|
2010-04-02 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
else if( ent->v.waterlevel == 1 )
|
|
|
|
|
{
|
|
|
|
|
if( ent->v.velocity[2] > 0.0f )
|
2010-06-20 22:00:00 +02:00
|
|
|
|
ent->v.velocity[2] = sv.frametime;
|
|
|
|
|
ent->v.velocity[2] -= ( ent->v.skin * sv.frametime );
|
2010-04-02 22:00:00 +02:00
|
|
|
|
}
|
2010-04-01 22:00:00 +02:00
|
|
|
|
}
|
2009-11-30 22:00:00 +01:00
|
|
|
|
}
|
2009-12-01 22:00:00 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( !VectorIsNull( ent->v.velocity ) || !VectorIsNull( ent->v.basevelocity ))
|
|
|
|
|
{
|
|
|
|
|
vec3_t mins, maxs, point;
|
2010-04-01 22:00:00 +02:00
|
|
|
|
float friction = sv_friction->value;
|
2009-12-01 22:00:00 +01:00
|
|
|
|
int x, y;
|
|
|
|
|
|
2010-04-01 22:00:00 +02:00
|
|
|
|
if( ent->v.friction != 0.0f )
|
|
|
|
|
friction *= ent->v.friction;
|
|
|
|
|
|
2009-12-01 22:00:00 +01:00
|
|
|
|
ent->v.flags &= ~FL_ONGROUND;
|
|
|
|
|
|
|
|
|
|
// apply friction
|
|
|
|
|
// let dead monsters who aren't completely onground slide
|
|
|
|
|
if( wasonground )
|
2009-11-30 22:00:00 +01:00
|
|
|
|
{
|
2010-04-01 22:00:00 +02:00
|
|
|
|
float speed, newspeed;
|
|
|
|
|
float control;
|
|
|
|
|
|
|
|
|
|
speed = VectorLength( ent->v.velocity );
|
2009-12-01 22:00:00 +01:00
|
|
|
|
|
2010-04-01 22:00:00 +02:00
|
|
|
|
if( speed )
|
|
|
|
|
{
|
|
|
|
|
control = speed < sv_stopspeed->value ? sv_stopspeed->value : speed;
|
2010-06-20 22:00:00 +02:00
|
|
|
|
newspeed = speed - sv.frametime * control * friction;
|
2009-12-01 22:00:00 +01:00
|
|
|
|
|
2010-04-01 22:00:00 +02:00
|
|
|
|
if( newspeed < 0.0f )
|
|
|
|
|
newspeed = 0.0f;
|
|
|
|
|
newspeed /= speed;
|
2009-12-01 22:00:00 +01:00
|
|
|
|
|
2010-04-01 22:00:00 +02:00
|
|
|
|
ent->v.velocity[0] *= newspeed;
|
|
|
|
|
ent->v.velocity[1] *= newspeed;
|
2009-12-01 22:00:00 +01:00
|
|
|
|
}
|
2010-04-01 22:00:00 +02:00
|
|
|
|
}
|
2009-12-01 22:00:00 +01:00
|
|
|
|
|
|
|
|
|
VectorAdd( ent->v.velocity, ent->v.basevelocity, ent->v.velocity );
|
2010-04-01 22:00:00 +02:00
|
|
|
|
|
2010-06-20 22:00:00 +02:00
|
|
|
|
SV_AngularMove( ent, sv.frametime, friction );
|
2010-04-01 22:00:00 +02:00
|
|
|
|
|
|
|
|
|
SV_CheckVelocity( ent );
|
2010-06-20 22:00:00 +02:00
|
|
|
|
SV_TryMove( ent, sv.frametime, NULL );
|
2010-04-01 22:00:00 +02:00
|
|
|
|
SV_CheckVelocity( ent );
|
|
|
|
|
|
|
|
|
|
VectorSubtract( ent->v.velocity, ent->v.basevelocity, ent->v.velocity );
|
|
|
|
|
SV_CheckVelocity( ent );
|
2009-11-02 22:00:00 +01:00
|
|
|
|
|
2009-12-01 22:00:00 +01:00
|
|
|
|
// determine if it's on solid ground at all
|
|
|
|
|
VectorAdd( ent->v.origin, ent->v.mins, mins );
|
|
|
|
|
VectorAdd( ent->v.origin, ent->v.maxs, maxs );
|
2009-11-02 22:00:00 +01:00
|
|
|
|
|
2009-12-01 22:00:00 +01:00
|
|
|
|
point[2] = mins[2] - 1;
|
|
|
|
|
for( x = 0; x <= 1; x++ )
|
|
|
|
|
{
|
2010-04-01 22:00:00 +02:00
|
|
|
|
if( ent->v.flags & FL_ONGROUND )
|
|
|
|
|
break;
|
|
|
|
|
|
2009-12-01 22:00:00 +01:00
|
|
|
|
for( y = 0; y <= 1; y++ )
|
2009-11-02 22:00:00 +01:00
|
|
|
|
{
|
2009-12-01 22:00:00 +01:00
|
|
|
|
point[0] = x ? maxs[0] : mins[0];
|
|
|
|
|
point[1] = y ? maxs[1] : mins[1];
|
2010-04-01 22:00:00 +02:00
|
|
|
|
|
|
|
|
|
trace = SV_Move( point, vec3_origin, vec3_origin, point, MOVE_NORMAL, ent );
|
|
|
|
|
|
|
|
|
|
if( trace.fStartSolid )
|
2009-12-01 22:00:00 +01:00
|
|
|
|
{
|
|
|
|
|
ent->v.flags |= FL_ONGROUND;
|
2010-04-01 22:00:00 +02:00
|
|
|
|
ent->v.groundentity = trace.pHit;
|
2009-12-01 22:00:00 +01:00
|
|
|
|
break;
|
|
|
|
|
}
|
2009-11-02 22:00:00 +01:00
|
|
|
|
}
|
2009-12-01 22:00:00 +01:00
|
|
|
|
|
2009-11-02 22:00:00 +01:00
|
|
|
|
}
|
2009-12-01 22:00:00 +01:00
|
|
|
|
SV_LinkEdict( ent, true );
|
2009-11-02 22:00:00 +01:00
|
|
|
|
}
|
|
|
|
|
|
2010-06-17 22:00:00 +02:00
|
|
|
|
if(!( ent->v.flags & FL_ONGROUND ) && isfalling )
|
2010-04-01 22:00:00 +02:00
|
|
|
|
{
|
2010-06-20 22:00:00 +02:00
|
|
|
|
SV_AddHalfGravity( ent, sv.frametime );
|
2010-04-01 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( !SV_RunThink( ent )) return;
|
2009-11-02 22:00:00 +01:00
|
|
|
|
|
2010-04-17 22:00:00 +02:00
|
|
|
|
SV_CheckWaterTransition( ent );
|
2009-11-02 22:00:00 +01:00
|
|
|
|
}
|
|
|
|
|
|
2007-09-28 22:00:00 +02:00
|
|
|
|
/*
|
|
|
|
|
====================
|
|
|
|
|
SV_Physics_Conveyor
|
|
|
|
|
|
|
|
|
|
REAL simple - all we do is check for player riders and adjust their position.
|
|
|
|
|
Only gotcha here is we have to make sure we don't end up embedding player in
|
|
|
|
|
*another* object that's being moved by the conveyor.
|
|
|
|
|
|
|
|
|
|
====================
|
|
|
|
|
*/
|
2008-07-30 22:00:00 +02:00
|
|
|
|
void SV_Physics_Conveyor( edict_t *ent )
|
2007-09-28 22:00:00 +02:00
|
|
|
|
{
|
|
|
|
|
edict_t *player;
|
|
|
|
|
int i;
|
2009-11-02 22:00:00 +01:00
|
|
|
|
trace_t tr;
|
2007-09-28 22:00:00 +02:00
|
|
|
|
vec3_t v, move;
|
|
|
|
|
vec3_t point, end;
|
|
|
|
|
|
2008-12-15 22:00:00 +01:00
|
|
|
|
VectorScale( ent->v.movedir, ent->v.speed, v );
|
2010-06-20 22:00:00 +02:00
|
|
|
|
VectorScale( v, sv.frametime, move );
|
2007-09-28 22:00:00 +02:00
|
|
|
|
|
2010-01-31 22:00:00 +01:00
|
|
|
|
for( i = 0; i < svgame.globals->maxClients; i++ )
|
2007-09-28 22:00:00 +02:00
|
|
|
|
{
|
2010-01-31 22:00:00 +01:00
|
|
|
|
player = EDICT_NUM( i + 1 );
|
2008-12-15 22:00:00 +01:00
|
|
|
|
if( player->free ) continue;
|
|
|
|
|
if( !player->v.groundentity ) continue;
|
|
|
|
|
if( player->v.groundentity != ent )
|
2008-07-30 22:00:00 +02:00
|
|
|
|
continue;
|
2007-09-28 22:00:00 +02:00
|
|
|
|
|
|
|
|
|
// Look below player; make sure he's on a conveyor
|
2008-12-15 22:00:00 +01:00
|
|
|
|
VectorCopy( player->v.origin, point );
|
2007-09-28 22:00:00 +02:00
|
|
|
|
point[2] += 1;
|
2008-07-30 22:00:00 +02:00
|
|
|
|
VectorCopy( point, end );
|
2007-09-28 22:00:00 +02:00
|
|
|
|
end[2] -= 256;
|
|
|
|
|
|
2009-11-02 22:00:00 +01:00
|
|
|
|
tr = SV_Move( point, player->v.mins, player->v.maxs, end, MOVE_NORMAL, player );
|
2009-10-28 22:00:00 +01:00
|
|
|
|
// tr.pHit HAS to be conveyor, but just in case we screwed something up:
|
|
|
|
|
if( tr.pHit == ent )
|
2007-09-28 22:00:00 +02:00
|
|
|
|
{
|
2009-10-28 22:00:00 +01:00
|
|
|
|
if( tr.vecPlaneNormal[2] > 0 )
|
2007-09-28 22:00:00 +02:00
|
|
|
|
{
|
2009-11-02 22:00:00 +01:00
|
|
|
|
v[2] = ent->v.speed * com.sqrt( 1.0f - tr.vecPlaneNormal[2] * tr.vecPlaneNormal[2] ) / tr.vecPlaneNormal[2];
|
|
|
|
|
if(DotProduct( ent->v.movedir, tr.vecPlaneNormal) > 0.0f )
|
2008-07-30 22:00:00 +02:00
|
|
|
|
v[2] = -v[2]; // then we're moving down
|
2010-06-20 22:00:00 +02:00
|
|
|
|
move[2] = v[2] * sv.frametime;
|
2007-09-28 22:00:00 +02:00
|
|
|
|
}
|
2008-12-15 22:00:00 +01:00
|
|
|
|
VectorAdd( player->v.origin, move, end );
|
2009-11-02 22:00:00 +01:00
|
|
|
|
tr = SV_Move( player->v.origin, player->v.mins, player->v.maxs, end, MOVE_NORMAL, player );
|
2009-10-28 22:00:00 +01:00
|
|
|
|
VectorCopy( tr.vecEndPos, player->v.origin );
|
2009-11-02 22:00:00 +01:00
|
|
|
|
SV_LinkEdict( player, false );
|
2007-09-28 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
=============
|
|
|
|
|
SV_PhysicsNone
|
|
|
|
|
|
|
|
|
|
Non moving objects can only think
|
|
|
|
|
=============
|
|
|
|
|
*/
|
2008-07-30 22:00:00 +02:00
|
|
|
|
void SV_Physics_None( edict_t *ent )
|
2007-09-28 22:00:00 +02:00
|
|
|
|
{
|
2010-04-13 22:00:00 +02:00
|
|
|
|
SV_RunThink( ent );
|
2007-09-28 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
2008-07-30 22:00:00 +02:00
|
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
|
|
static void SV_Physics_Entity( edict_t *ent )
|
2007-09-28 22:00:00 +02:00
|
|
|
|
{
|
2009-12-01 22:00:00 +01:00
|
|
|
|
SV_UpdateBaseVelocity( ent );
|
|
|
|
|
|
|
|
|
|
if(!( ent->v.flags & FL_BASEVELOCITY ) && !VectorIsNull( ent->v.basevelocity ))
|
|
|
|
|
{
|
|
|
|
|
// Apply momentum (add in half of the previous frame of velocity first)
|
2010-06-20 22:00:00 +02:00
|
|
|
|
VectorMA( ent->v.velocity, 1.0f + (sv.frametime * 0.5f), ent->v.basevelocity, ent->v.velocity );
|
2009-12-01 22:00:00 +01:00
|
|
|
|
VectorClear( ent->v.basevelocity );
|
|
|
|
|
}
|
|
|
|
|
ent->v.flags &= ~FL_BASEVELOCITY;
|
|
|
|
|
|
2010-04-13 22:00:00 +02:00
|
|
|
|
// user dll can override movement type
|
2010-03-21 22:00:00 +01:00
|
|
|
|
if( svgame.dllFuncs.pfnPhysicsEntity( ent ))
|
|
|
|
|
return;
|
|
|
|
|
|
2008-12-17 22:00:00 +01:00
|
|
|
|
switch( ent->v.movetype )
|
2007-09-28 22:00:00 +02:00
|
|
|
|
{
|
|
|
|
|
case MOVETYPE_NONE:
|
2008-07-30 22:00:00 +02:00
|
|
|
|
SV_Physics_None( ent );
|
2007-09-28 22:00:00 +02:00
|
|
|
|
break;
|
|
|
|
|
case MOVETYPE_NOCLIP:
|
2008-07-30 22:00:00 +02:00
|
|
|
|
SV_Physics_Noclip( ent );
|
2007-09-28 22:00:00 +02:00
|
|
|
|
break;
|
2010-04-13 22:00:00 +02:00
|
|
|
|
case MOVETYPE_FOLLOW:
|
|
|
|
|
SV_Physics_Follow( ent );
|
|
|
|
|
break;
|
2010-04-17 22:00:00 +02:00
|
|
|
|
case MOVETYPE_COMPOUND:
|
|
|
|
|
SV_Physics_Compound( ent );
|
|
|
|
|
break;
|
2007-09-28 22:00:00 +02:00
|
|
|
|
case MOVETYPE_STEP:
|
2009-11-02 22:00:00 +01:00
|
|
|
|
case MOVETYPE_PUSHSTEP:
|
2008-07-30 22:00:00 +02:00
|
|
|
|
SV_Physics_Step( ent );
|
2007-09-28 22:00:00 +02:00
|
|
|
|
break;
|
2009-11-02 22:00:00 +01:00
|
|
|
|
case MOVETYPE_FLY:
|
2008-07-30 22:00:00 +02:00
|
|
|
|
case MOVETYPE_TOSS:
|
|
|
|
|
case MOVETYPE_BOUNCE:
|
2009-11-02 22:00:00 +01:00
|
|
|
|
case MOVETYPE_FLYMISSILE:
|
|
|
|
|
case MOVETYPE_BOUNCEMISSILE:
|
|
|
|
|
SV_Physics_Toss( ent );
|
2008-07-30 22:00:00 +02:00
|
|
|
|
break;
|
2010-04-13 22:00:00 +02:00
|
|
|
|
case MOVETYPE_PUSH:
|
|
|
|
|
SV_Physics_Pusher( ent );
|
|
|
|
|
break;
|
2007-09-28 22:00:00 +02:00
|
|
|
|
case MOVETYPE_CONVEYOR:
|
2008-07-30 22:00:00 +02:00
|
|
|
|
SV_Physics_Conveyor( ent );
|
|
|
|
|
break;
|
2009-12-01 22:00:00 +01:00
|
|
|
|
case MOVETYPE_WALK:
|
|
|
|
|
Host_Error( "SV_Physics: bad movetype %i\n", ent->v.movetype );
|
|
|
|
|
break;
|
2008-07-30 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-24 22:00:00 +01:00
|
|
|
|
void SV_FreeOldEntities( void )
|
|
|
|
|
{
|
|
|
|
|
edict_t *ent;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
// at end of frame kill all entities which supposed to it
|
|
|
|
|
for( i = svgame.globals->maxClients + 1; i < svgame.globals->numEntities; i++ )
|
|
|
|
|
{
|
|
|
|
|
ent = EDICT_NUM( i );
|
|
|
|
|
if( ent->free ) continue;
|
|
|
|
|
|
|
|
|
|
if( ent->v.flags & FL_KILLME )
|
|
|
|
|
SV_FreeEdict( ent );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// decrement svgame.globals->numEntities if the highest number entities died
|
|
|
|
|
for( ; EDICT_NUM( svgame.globals->numEntities - 1)->free; svgame.globals->numEntities-- );
|
|
|
|
|
}
|
|
|
|
|
|
2008-07-30 22:00:00 +02:00
|
|
|
|
/*
|
|
|
|
|
================
|
|
|
|
|
SV_Physics
|
|
|
|
|
|
|
|
|
|
================
|
|
|
|
|
*/
|
|
|
|
|
void SV_Physics( void )
|
|
|
|
|
{
|
2009-12-01 22:00:00 +01:00
|
|
|
|
int i;
|
2010-04-03 22:00:00 +02:00
|
|
|
|
edict_t *ent;
|
2008-07-30 22:00:00 +02:00
|
|
|
|
|
2010-06-20 22:00:00 +02:00
|
|
|
|
svgame.globals->time = sv.time;
|
|
|
|
|
svgame.globals->frametime = sv.frametime;
|
|
|
|
|
|
2008-07-30 22:00:00 +02:00
|
|
|
|
// let the progs know that a new frame has started
|
2010-04-12 22:00:00 +02:00
|
|
|
|
svgame.dllFuncs.pfnStartFrame();
|
2010-04-09 22:00:00 +02:00
|
|
|
|
|
2009-11-29 22:00:00 +01:00
|
|
|
|
SV_CheckAllEnts ();
|
|
|
|
|
|
2008-07-30 22:00:00 +02:00
|
|
|
|
// treat each object in turn
|
2009-11-30 22:00:00 +01:00
|
|
|
|
for( i = 1; ( svgame.globals->force_retouch > 0 ) && i < svgame.globals->numEntities; i++ )
|
2008-07-30 22:00:00 +02:00
|
|
|
|
{
|
2008-12-15 22:00:00 +01:00
|
|
|
|
ent = EDICT_NUM( i );
|
2010-04-13 22:00:00 +02:00
|
|
|
|
if( !SV_IsValidEdict( ent )) continue;
|
2008-07-30 22:00:00 +02:00
|
|
|
|
|
2010-04-13 22:00:00 +02:00
|
|
|
|
// force retouch even for stationary
|
|
|
|
|
SV_LinkEdict( ent, true );
|
2009-11-30 22:00:00 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// treat each object in turn
|
2010-04-12 22:00:00 +02:00
|
|
|
|
if( !( sv.hostflags & SVF_PLAYERSONLY ))
|
2009-11-30 22:00:00 +01:00
|
|
|
|
{
|
2010-04-02 22:00:00 +02:00
|
|
|
|
for( i = svgame.globals->maxClients + 1; i < svgame.globals->numEntities; i++ )
|
|
|
|
|
{
|
|
|
|
|
ent = EDICT_NUM( i );
|
2010-04-13 22:00:00 +02:00
|
|
|
|
if( !SV_IsValidEdict( ent )) continue;
|
|
|
|
|
|
2010-04-02 22:00:00 +02:00
|
|
|
|
SV_Physics_Entity( ent );
|
|
|
|
|
}
|
2008-07-30 22:00:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
2008-08-01 22:00:00 +02:00
|
|
|
|
// let everything in the world think and move
|
2010-06-20 22:00:00 +02:00
|
|
|
|
CM_Frame( sv.frametime );
|
2008-12-20 22:00:00 +01:00
|
|
|
|
|
2008-12-15 22:00:00 +01:00
|
|
|
|
// at end of frame kill all entities which supposed to it
|
2010-03-24 22:00:00 +01:00
|
|
|
|
SV_FreeOldEntities();
|
2008-12-15 22:00:00 +01:00
|
|
|
|
|
2009-11-30 22:00:00 +01:00
|
|
|
|
if( svgame.globals->force_retouch > 0 )
|
|
|
|
|
svgame.globals->force_retouch = max( 0, svgame.globals->force_retouch - 1 );
|
|
|
|
|
|
|
|
|
|
svgame.dllFuncs.pfnEndFrame();
|
2007-09-17 22:00:00 +02:00
|
|
|
|
}
|