From 0bec78a9588de25aa26c977ca2142e4a7d6242d6 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Fri, 6 Jan 2023 00:09:36 +0300 Subject: [PATCH] engine: client: make few function between pmove and client interface shared, remove unused CL_PointContents wrapper --- engine/client/cl_game.c | 50 ++++------------------------------------ engine/client/cl_pmove.c | 12 +--------- engine/client/cl_tent.c | 2 +- engine/client/client.h | 2 +- engine/common/common.h | 1 - 5 files changed, 8 insertions(+), 59 deletions(-) diff --git a/engine/client/cl_game.c b/engine/client/cl_game.c index e3c437a7..9769efba 100644 --- a/engine/client/cl_game.c +++ b/engine/client/cl_game.c @@ -234,22 +234,6 @@ void CL_InitCDAudio( const char *filename ) Mem_Free( afile ); } -/* -==================== -CL_PointContents - -Return contents for point -==================== -*/ -int CL_PointContents( const vec3_t p ) -{ - int cont = PM_PointContents( clgame.pmove, p ); - - if( cont <= CONTENTS_CURRENT_0 && cont >= CONTENTS_CURRENT_DOWN ) - cont = CONTENTS_WATER; - return cont; -} - /* ============= CL_AdjustXPos @@ -2220,38 +2204,14 @@ pfnPointContents ============= */ -static int GAME_EXPORT pfnPointContents( const float *p, int *truecontents ) +int GAME_EXPORT PM_CL_PointContents( const float *p, int *truecontents ) { return PM_PointContentsPmove( clgame.pmove, p, truecontents ); } -/* -============= -pfnTraceLine - -============= -*/ -static pmtrace_t *pfnTraceLine( float *start, float *end, int flags, int usehull, int ignore_pe ) +pmtrace_t *PM_CL_TraceLine( float *start, float *end, int flags, int usehull, int ignore_pe ) { - static pmtrace_t tr; - int old_usehull; - - old_usehull = clgame.pmove->usehull; - clgame.pmove->usehull = usehull; - - switch( flags ) - { - case PM_TRACELINE_PHYSENTSONLY: - tr = PM_PlayerTraceExt( clgame.pmove, start, end, 0, clgame.pmove->numphysent, clgame.pmove->physents, ignore_pe, NULL ); - break; - case PM_TRACELINE_ANYVISIBLE: - tr = PM_PlayerTraceExt( clgame.pmove, start, end, 0, clgame.pmove->numvisent, clgame.pmove->visents, ignore_pe, NULL ); - break; - } - - clgame.pmove->usehull = old_usehull; - - return &tr; + return PM_TraceLine( clgame.pmove, start, end, flags, usehull, ignore_pe ); } static void GAME_EXPORT pfnPlaySoundByNameAtLocation( char *szSound, float volume, float *origin ) @@ -3827,9 +3787,9 @@ static cl_enginefunc_t gEngfuncs = pfnGetClientTime, pfnCalcShake, pfnApplyShake, - pfnPointContents, + PM_CL_PointContents, CL_WaterEntity, - pfnTraceLine, + PM_CL_TraceLine, CL_LoadModel, CL_AddEntity, CL_GetSpritePointer, diff --git a/engine/client/cl_pmove.c b/engine/client/cl_pmove.c index ce9a2744..fdbdecbc 100644 --- a/engine/client/cl_pmove.c +++ b/engine/client/cl_pmove.c @@ -716,11 +716,6 @@ static void GAME_EXPORT pfnStuckTouch( int hitent, pmtrace_t *tr ) return PM_StuckTouch( clgame.pmove, hitent, tr ); } -static int GAME_EXPORT pfnPointContents( float *p, int *truecontents ) -{ - return PM_PointContentsPmove( clgame.pmove, p, truecontents ); -} - static int GAME_EXPORT pfnTruePointContents( float *p ) { return PM_TruePointContents( clgame.pmove, p ); @@ -736,11 +731,6 @@ static pmtrace_t GAME_EXPORT pfnPlayerTrace( float *start, float *end, int trace return PM_PlayerTraceExt( clgame.pmove, start, end, traceFlags, clgame.pmove->numphysent, clgame.pmove->physents, ignore_pe, NULL ); } -pmtrace_t *PM_CL_TraceLine( float *start, float *end, int flags, int usehull, int ignore_pe ) -{ - return PM_TraceLine( clgame.pmove, start, end, flags, usehull, ignore_pe ); -} - static void *pfnHullForBsp( physent_t *pe, float *offset ) { return PM_HullForBsp( pe, clgame.pmove, offset ); @@ -817,7 +807,7 @@ void CL_InitClientMove( void ) clgame.pmove->Con_Printf = Con_Printf; clgame.pmove->Sys_FloatTime = Sys_DoubleTime; clgame.pmove->PM_StuckTouch = pfnStuckTouch; - clgame.pmove->PM_PointContents = pfnPointContents; + clgame.pmove->PM_PointContents = PM_CL_PointContents; clgame.pmove->PM_TruePointContents = pfnTruePointContents; clgame.pmove->PM_HullPointContents = pfnHullPointContents; clgame.pmove->PM_PlayerTrace = pfnPlayerTrace; diff --git a/engine/client/cl_tent.c b/engine/client/cl_tent.c index e8bde1fc..e0e10c4c 100644 --- a/engine/client/cl_tent.c +++ b/engine/client/cl_tent.c @@ -1037,7 +1037,7 @@ void GAME_EXPORT R_BreakModel( const vec3_t pos, const vec3_t size, const vec3_t vecSpot[1] = pos[1] + COM_RandomFloat( -0.5f, 0.5f ) * size[1]; vecSpot[2] = pos[2] + COM_RandomFloat( -0.5f, 0.5f ) * size[2]; - if( CL_PointContents( vecSpot ) != CONTENTS_SOLID ) + if( PM_CL_PointContents( vecSpot, NULL ) != CONTENTS_SOLID ) break; // valid spot } diff --git a/engine/client/client.h b/engine/client/client.h index 957a8719..a1439cef 100644 --- a/engine/client/client.h +++ b/engine/client/client.h @@ -832,6 +832,7 @@ void CL_PlayerTrace( float *start, float *end, int traceFlags, int ignore_pe, pm void CL_PlayerTraceExt( float *start, float *end, int traceFlags, int (*pfnIgnore)( physent_t *pe ), pmtrace_t *tr ); pmtrace_t *PM_CL_TraceLine( float *start, float *end, int flags, int usehull, int ignore_pe ); const char *PM_CL_TraceTexture( int ground, float *vstart, float *vend ); +int PM_CL_PointContents( const float *p, int *truecontents ); void CL_SetTraceHull( int hull ); void CL_GetMousePosition( int *mx, int *my ); // TODO: move to input cl_entity_t* CL_GetViewModel( void ); @@ -914,7 +915,6 @@ void CL_PredictMovement( qboolean repredicting ); void CL_CheckPredictionError( void ); qboolean CL_IsPredicted( void ); int CL_TruePointContents( const vec3_t p ); -int CL_PointContents( const vec3_t p ); int CL_WaterEntity( const float *rgflPos ); cl_entity_t *CL_GetWaterEntity( const float *rgflPos ); void CL_SetupPMove( playermove_t *pmove, local_state_t *from, usercmd_t *ucmd, qboolean runfuncs, double time ); diff --git a/engine/common/common.h b/engine/common/common.h index 856e5a4a..b54b9b99 100644 --- a/engine/common/common.h +++ b/engine/common/common.h @@ -744,7 +744,6 @@ char *CL_Userinfo( void ); void CL_LegacyUpdateInfo( void ); void CL_CharEvent( int key ); qboolean CL_DisableVisibility( void ); -int CL_PointContents( const vec3_t point ); byte *COM_LoadFile( const char *filename, int usehunk, int *pLength ); int CL_GetDemoComment( const char *demoname, char *comment ); void COM_AddAppDirectoryToSearchPath( const char *pszBaseDir, const char *appName );