engine: server: minor refactoring

This commit is contained in:
Alibek Omarov
2025-05-20 20:24:42 +05:00
parent 7ba48e00bc
commit a4ad537e59
3 changed files with 11 additions and 12 deletions

View File

@@ -492,7 +492,7 @@ get model by handle
*/
static inline model_t *GAME_EXPORT SV_ModelHandle( int modelindex )
{
if( modelindex < 0 || modelindex >= MAX_MODELS )
if( unlikely( modelindex < 0 || modelindex >= MAX_MODELS ))
return NULL;
return sv.models[modelindex];
}

View File

@@ -241,7 +241,7 @@ qboolean SV_MoveStep( edict_t *ent, vec3_t move, qboolean relink )
monsterClip = FBitSet( ent->v.flags, FL_MONSTERCLIP ) ? true : false;
// well, try it. Flying and swimming monsters are easiest.
if( ent->v.flags & ( FL_SWIM|FL_FLY ))
if( FBitSet( ent->v.flags, FL_SWIM|FL_FLY ))
{
// try one move with vertical motion, then one without
for( i = 0; i < 2; i++ )
@@ -265,7 +265,7 @@ qboolean SV_MoveStep( edict_t *ent, vec3_t move, qboolean relink )
// that move takes us out of the water.
// apparently though, it's okay to travel into solids, lava, sky, etc :)
if(( ent->v.flags & FL_SWIM ) && SV_PointContents( trace.endpos ) == CONTENTS_EMPTY )
if( FBitSet( ent->v.flags, FL_SWIM ) && SV_PointContents( trace.endpos ) == CONTENTS_EMPTY )
return 0;
VectorCopy( trace.endpos, ent->v.origin );
@@ -303,11 +303,11 @@ qboolean SV_MoveStep( edict_t *ent, vec3_t move, qboolean relink )
if( trace.fraction == 1.0f )
{
if( ent->v.flags & FL_PARTIALGROUND )
if( FBitSet( ent->v.flags, FL_PARTIALGROUND ))
{
VectorAdd( ent->v.origin, move, ent->v.origin );
if( relink ) SV_LinkEdict( ent, true );
ent->v.flags &= ~FL_ONGROUND;
ClearBits( ent->v.flags, FL_ONGROUND );
return 1;
}
return 0;
@@ -318,7 +318,7 @@ qboolean SV_MoveStep( edict_t *ent, vec3_t move, qboolean relink )
if( SV_CheckBottom( ent, WALKMOVE_NORMAL ) == 0 )
{
if( ent->v.flags & FL_PARTIALGROUND )
if( FBitSet( ent->v.flags, FL_PARTIALGROUND ))
{
if( relink ) SV_LinkEdict( ent, true );
return 1;
@@ -329,7 +329,7 @@ qboolean SV_MoveStep( edict_t *ent, vec3_t move, qboolean relink )
}
else
{
ent->v.flags &= ~FL_PARTIALGROUND;
ClearBits( ent->v.flags, FL_PARTIALGROUND );
ent->v.groundentity = trace.ent;
if( relink ) SV_LinkEdict( ent, true );

View File

@@ -1313,17 +1313,16 @@ SV_Move
*/
trace_t SV_Move( const vec3_t start, vec3_t mins, vec3_t maxs, const vec3_t end, int type, edict_t *e, qboolean monsterclip )
{
moveclip_t clip;
vec3_t trace_endpos;
float trace_fraction;
moveclip_t clip = { 0 };
memset( &clip, 0, sizeof( moveclip_t ));
SV_ClipMoveToEntity( EDICT_NUM( 0 ), start, mins, maxs, end, &clip.trace );
if( clip.trace.fraction != 0.0f )
{
const float trace_fraction = clip.trace.fraction;
vec3_t trace_endpos;
VectorCopy( clip.trace.endpos, trace_endpos );
trace_fraction = clip.trace.fraction;
clip.trace.fraction = 1.0f;
clip.start = start;
clip.end = trace_endpos;