diff --git a/engine/common/common.c b/engine/common/common.c index 4bec0405c..e251b2b58 100644 --- a/engine/common/common.c +++ b/engine/common/common.c @@ -759,25 +759,6 @@ void GAME_EXPORT COM_FreeFile( void *buffer ) free( buffer ); } -/* -============= -COM_NormalizeAngles - -============= -*/ -void COM_NormalizeAngles( vec3_t angles ) -{ - int i; - - for( i = 0; i < 3; i++ ) - { - if( angles[i] > 180.0f ) - angles[i] -= 360.0f; - else if( angles[i] < -180.0f ) - angles[i] += 360.0f; - } -} - /* ============= pfnGetModelType diff --git a/engine/common/common.h b/engine/common/common.h index 82ca6dd13..393631954 100644 --- a/engine/common/common.h +++ b/engine/common/common.h @@ -769,13 +769,25 @@ void UI_ShowConnectionWarning( void ); void Cmd_Null_f( void ); void Rcon_Print( host_redirect_t *rd, const char *pMsg ); qboolean COM_ParseVector( char **pfile, float *v, size_t size ); -void COM_NormalizeAngles( vec3_t angles ); int COM_FileSize( const char *filename ); void COM_FreeFile( void *buffer ); int COM_CompareFileTime( const char *filename1, const char *filename2, int *iCompare ); char *va( const char *format, ... ) _format( 1 ); qboolean CRC32_MapFile( dword *crcvalue, const char *filename, qboolean multiplayer ); +static inline void COM_NormalizeAngles( vec3_t angles ) +{ + int i; + + for( i = 0; i < 3; i++ ) + { + if( angles[i] > 180.0f ) + angles[i] -= 360.0f; + else if( angles[i] < -180.0f ) + angles[i] += 360.0f; + } +} + #if !XASH_DEDICATED connprotocol_t CL_Protocol( void ); #else diff --git a/engine/common/pm_local.h b/engine/common/pm_local.h index 440614c25..a079c3104 100644 --- a/engine/common/pm_local.h +++ b/engine/common/pm_local.h @@ -24,7 +24,6 @@ typedef int (*pfnIgnore)( physent_t *pe ); // custom trace filter // pm_trace.c // void Pmove_Init( void ); -void PM_ClearPhysEnts( playermove_t *pmove ); void PM_InitBoxHull( void ); hull_t *PM_HullForBsp( physent_t *pe, playermove_t *pmove, float *offset ); qboolean PM_RecursiveHullCheck( hull_t *hull, int num, float p1f, float p2f, vec3_t p1, vec3_t p2, pmtrace_t *trace ); @@ -40,7 +39,29 @@ struct msurface_s *PM_TraceSurfacePmove( playermove_t *pmove, int ground, float const char *PM_TraceTexture( playermove_t *pmove, int ground, float *vstart, float *vend ); int PM_PointContentsPmove( playermove_t *pmove, const float *p, int *truecontents ); void PM_StuckTouch( playermove_t *pmove, int hitent, pmtrace_t *tr ); -void PM_ConvertTrace( trace_t *out, pmtrace_t *in, edict_t *ent ); + +static inline void PM_ConvertTrace( trace_t *out, pmtrace_t *in, edict_t *ent ) +{ + out->allsolid = in->allsolid; + out->startsolid = in->startsolid; + out->inopen = in->inopen; + out->inwater = in->inwater; + out->fraction = in->fraction; + out->plane.dist = in->plane.dist; + out->hitgroup = in->hitgroup; + out->ent = ent; + + VectorCopy( in->endpos, out->endpos ); + VectorCopy( in->plane.normal, out->plane.normal ); +} + +static inline void PM_ClearPhysEnts( playermove_t *pmove ) +{ + pmove->nummoveent = 0; + pmove->numphysent = 0; + pmove->numvisent = 0; + pmove->numtouch = 0; +} static inline void PM_InitTrace( trace_t *trace, const vec3_t end ) { diff --git a/engine/common/pm_trace.c b/engine/common/pm_trace.c index 7b8653eef..fe4b6d20d 100644 --- a/engine/common/pm_trace.c +++ b/engine/common/pm_trace.c @@ -55,14 +55,6 @@ void Pmove_Init( void ) memcpy( host.player_maxs, pm_hullmaxs, sizeof( pm_hullmaxs )); } -void PM_ClearPhysEnts( playermove_t *pmove ) -{ - pmove->nummoveent = 0; - pmove->numphysent = 0; - pmove->numvisent = 0; - pmove->numtouch = 0; -} - /* =================== PM_InitBoxHull @@ -117,21 +109,6 @@ static hull_t *PM_HullForBox( const vec3_t mins, const vec3_t maxs ) return &pm_boxhull; } -void PM_ConvertTrace( trace_t *out, pmtrace_t *in, edict_t *ent ) -{ - out->allsolid = in->allsolid; - out->startsolid = in->startsolid; - out->inopen = in->inopen; - out->inwater = in->inwater; - out->fraction = in->fraction; - out->plane.dist = in->plane.dist; - out->hitgroup = in->hitgroup; - out->ent = ent; - - VectorCopy( in->endpos, out->endpos ); - VectorCopy( in->plane.normal, out->plane.normal ); -} - /* ================== PM_HullPointContents diff --git a/engine/common/world.c b/engine/common/world.c index 37c0f533c..06275cb44 100644 --- a/engine/common/world.c +++ b/engine/common/world.c @@ -20,47 +20,6 @@ GNU General Public License for more details. #include "xash3d_mathlib.h" #include "studio.h" -/* -================== -World_MoveBounds -================== -*/ -void World_MoveBounds( const vec3_t start, vec3_t mins, vec3_t maxs, const vec3_t end, vec3_t boxmins, vec3_t boxmaxs ) -{ - int i; - - for( i = 0; i < 3; i++ ) - { - if( end[i] > start[i] ) - { - boxmins[i] = start[i] + mins[i] - 1.0f; - boxmaxs[i] = end[i] + maxs[i] + 1.0f; - } - else - { - boxmins[i] = end[i] + mins[i] - 1.0f; - boxmaxs[i] = start[i] + maxs[i] + 1.0f; - } - } -} - -trace_t World_CombineTraces( trace_t *cliptrace, trace_t *trace, edict_t *touch ) -{ - if( trace->allsolid || trace->startsolid || trace->fraction < cliptrace->fraction ) - { - trace->ent = touch; - - if( cliptrace->startsolid ) - { - *cliptrace = *trace; - cliptrace->startsolid = true; - } - else *cliptrace = *trace; - } - - return *cliptrace; -} - /* ================== World_TransformAABB @@ -107,31 +66,3 @@ void World_TransformAABB( matrix4x4 transform, const vec3_t mins, const vec3_t m } } } - -/* -================== -RankForContents - -Used for determine contents priority -================== -*/ -int RankForContents( int contents ) -{ - switch( contents ) - { - case CONTENTS_EMPTY: return 0; - case CONTENTS_WATER: return 1; - case CONTENTS_TRANSLUCENT: return 2; - case CONTENTS_CURRENT_0: return 3; - case CONTENTS_CURRENT_90: return 4; - case CONTENTS_CURRENT_180: return 5; - case CONTENTS_CURRENT_270: return 6; - case CONTENTS_CURRENT_UP: return 7; - case CONTENTS_CURRENT_DOWN: return 8; - case CONTENTS_SLIME: return 9; - case CONTENTS_LAVA: return 10; - case CONTENTS_SKY: return 11; - case CONTENTS_SOLID: return 12; - default: return 13; // any user contents has more priority than default - } -} diff --git a/engine/common/world.h b/engine/common/world.h index 199ae9f3f..30b30bcf2 100644 --- a/engine/common/world.h +++ b/engine/common/world.h @@ -36,10 +36,71 @@ ENTITY AREA CHECKING #include "lightstyle.h" // trace common -void World_MoveBounds( const vec3_t start, vec3_t mins, vec3_t maxs, const vec3_t end, vec3_t boxmins, vec3_t boxmaxs ); +static inline void World_MoveBounds( const vec3_t start, vec3_t mins, vec3_t maxs, const vec3_t end, vec3_t boxmins, vec3_t boxmaxs ) +{ + int i; + + for( i = 0; i < 3; i++ ) + { + if( end[i] > start[i] ) + { + boxmins[i] = start[i] + mins[i] - 1.0f; + boxmaxs[i] = end[i] + maxs[i] + 1.0f; + } + else + { + boxmins[i] = end[i] + mins[i] - 1.0f; + boxmaxs[i] = start[i] + maxs[i] + 1.0f; + } + } +} + +static inline trace_t World_CombineTraces( trace_t *cliptrace, trace_t *trace, edict_t *touch ) +{ + if( trace->allsolid || trace->startsolid || trace->fraction < cliptrace->fraction ) + { + trace->ent = touch; + + if( cliptrace->startsolid ) + { + *cliptrace = *trace; + cliptrace->startsolid = true; + } + else *cliptrace = *trace; + } + + return *cliptrace; +} + +/* +================== +RankForContents + +Used for determine contents priority +================== +*/ +static inline int RankForContents( int contents ) +{ + switch( contents ) + { + case CONTENTS_EMPTY: return 0; + case CONTENTS_WATER: return 1; + case CONTENTS_TRANSLUCENT: return 2; + case CONTENTS_CURRENT_0: return 3; + case CONTENTS_CURRENT_90: return 4; + case CONTENTS_CURRENT_180: return 5; + case CONTENTS_CURRENT_270: return 6; + case CONTENTS_CURRENT_UP: return 7; + case CONTENTS_CURRENT_DOWN: return 8; + case CONTENTS_SLIME: return 9; + case CONTENTS_LAVA: return 10; + case CONTENTS_SKY: return 11; + case CONTENTS_SOLID: return 12; + default: return 13; // any user contents has more priority than default + } +} + void World_TransformAABB( matrix4x4 transform, const vec3_t mins, const vec3_t maxs, vec3_t outmins, vec3_t outmaxs ); -trace_t World_CombineTraces( trace_t *cliptrace, trace_t *trace, edict_t *touch ); -int RankForContents( int contents ); #define check_angles( x ) ( (int)x == 90 || (int)x == 180 || (int)x == 270 || (int)x == -90 || (int)x == -180 || (int)x == -270 )