From 787d3bc5ddfb36a23392eec0afc230c03d7e978b Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Fri, 6 Jan 2023 00:14:49 +0300 Subject: [PATCH] engine: share playermove ClearPhysEnts function --- engine/client/cl_game.c | 1 - engine/client/cl_main.c | 3 ++- engine/client/cl_pmove.c | 16 +--------------- engine/client/client.h | 1 - engine/common/pm_local.h | 1 + engine/common/pm_trace.c | 8 ++++++++ engine/server/server.h | 1 - engine/server/sv_init.c | 3 ++- engine/server/sv_pmove.c | 8 -------- 9 files changed, 14 insertions(+), 28 deletions(-) diff --git a/engine/client/cl_game.c b/engine/client/cl_game.c index 9769efba..0a85cf21 100644 --- a/engine/client/cl_game.c +++ b/engine/client/cl_game.c @@ -2458,7 +2458,6 @@ pfnSetTraceHull void GAME_EXPORT CL_SetTraceHull( int hull ) { clgame.pmove->usehull = bound( 0, hull, 3 ); - } /* diff --git a/engine/client/cl_main.c b/engine/client/cl_main.c index 353c1350..35530d73 100644 --- a/engine/client/cl_main.c +++ b/engine/client/cl_main.c @@ -22,6 +22,7 @@ GNU General Public License for more details. #include "vgui_draw.h" #include "library.h" #include "vid_common.h" +#include "pm_local.h" #define MAX_TOTAL_CMDS 32 #define MAX_CMD_BUFFER 8000 @@ -1380,7 +1381,7 @@ void CL_ClearState( void ) CL_ClearEffects (); CL_FreeEdicts (); - CL_ClearPhysEnts (); + PM_ClearPhysEnts( clgame.pmove ); NetAPI_CancelAllRequests(); // wipe the entire cl structure diff --git a/engine/client/cl_pmove.c b/engine/client/cl_pmove.c index fdbdecbc..1bca399d 100644 --- a/engine/client/cl_pmove.c +++ b/engine/client/cl_pmove.c @@ -26,20 +26,6 @@ GNU General Public License for more details. #define MIN_PREDICTION_EPSILON 0.5f // complain if error is > this and we have cl_showerror set #define MAX_PREDICTION_ERROR 64.0f // above this is assumed to be a teleport, don't smooth, etc. -/* -============= -CL_ClearPhysEnts - -============= -*/ -void CL_ClearPhysEnts( void ) -{ - clgame.pmove->numtouch = 0; - clgame.pmove->numvisent = 0; - clgame.pmove->nummoveent = 0; - clgame.pmove->numphysent = 0; -} - /* ============= CL_PushPMStates @@ -807,7 +793,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 = PM_CL_PointContents; + clgame.pmove->PM_PointContents = (void*)PM_CL_PointContents; clgame.pmove->PM_TruePointContents = pfnTruePointContents; clgame.pmove->PM_HullPointContents = pfnHullPointContents; clgame.pmove->PM_PlayerTrace = pfnPlayerTrace; diff --git a/engine/client/client.h b/engine/client/client.h index a1439cef..68ebd016 100644 --- a/engine/client/client.h +++ b/engine/client/client.h @@ -926,7 +926,6 @@ void CL_PopTraceBounds( void ); void CL_MoveSpectatorCamera( void ); void CL_SetLastUpdate( void ); void CL_RedoPrediction( void ); -void CL_ClearPhysEnts( void ); void CL_PushPMStates( void ); void CL_PopPMStates( void ); void CL_SetUpPlayerPrediction( int dopred, int bIncludeLocalClient ); diff --git a/engine/common/pm_local.h b/engine/common/pm_local.h index b283973b..e2583e20 100644 --- a/engine/common/pm_local.h +++ b/engine/common/pm_local.h @@ -30,6 +30,7 @@ void PM_DrawBBox( const vec3_t mins, const vec3_t maxs, const vec3_t origin, int // 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 ); diff --git a/engine/common/pm_trace.c b/engine/common/pm_trace.c index fb1e29bd..375fc9bc 100644 --- a/engine/common/pm_trace.c +++ b/engine/common/pm_trace.c @@ -55,6 +55,14 @@ 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 diff --git a/engine/server/server.h b/engine/server/server.h index 9e90cc24..0ca8ee4e 100644 --- a/engine/server/server.h +++ b/engine/server/server.h @@ -697,6 +697,5 @@ void SV_RunLightStyles( void ); void SV_SetLightStyle( int style, const char* s, float f ); const char *SV_GetLightStyle( int style ); int SV_LightForEntity( edict_t *pEdict ); -void SV_ClearPhysEnts( void ); #endif//SERVER_H diff --git a/engine/server/sv_init.c b/engine/server/sv_init.c index f4ad6ba1..699b47b9 100644 --- a/engine/server/sv_init.c +++ b/engine/server/sv_init.c @@ -18,6 +18,7 @@ GNU General Public License for more details. #include "net_encode.h" #include "library.h" #include "voice.h" +#include "pm_local.h" #if XASH_LOW_MEMORY != 2 int SV_UPDATE_BACKUP = SINGLEPLAYER_BACKUP; @@ -651,7 +652,7 @@ void SV_DeactivateServer( void ) SV_FreeEdicts (); - SV_ClearPhysEnts (); + PM_ClearPhysEnts( svgame.pmove ); SV_EmptyStringPool(); diff --git a/engine/server/sv_pmove.c b/engine/server/sv_pmove.c index 53cd010d..356a4345 100644 --- a/engine/server/sv_pmove.c +++ b/engine/server/sv_pmove.c @@ -22,14 +22,6 @@ GNU General Public License for more details. static qboolean has_update = false; -void SV_ClearPhysEnts( void ) -{ - svgame.pmove->numtouch = 0; - svgame.pmove->numvisent = 0; - svgame.pmove->nummoveent = 0; - svgame.pmove->numphysent = 0; -} - qboolean SV_PlayerIsFrozen( edict_t *pClient ) { if( sv_background_freeze.value && sv.background )