engine: clean up common.h header from unused function prototypes, or move them to appropriate header or C file

This commit is contained in:
Alibek Omarov 2024-01-28 09:59:51 +03:00
parent 7200f0da7e
commit 2b6a550405
17 changed files with 83 additions and 126 deletions

View File

@ -107,6 +107,8 @@ struct
int angle_position;
} demo;
static qboolean CL_NextDemo( void );
/*
====================
CL_StartupDemoHeader
@ -1264,7 +1266,7 @@ CL_NextDemo
Called when a demo finishes
==================
*/
qboolean CL_NextDemo( void )
static qboolean CL_NextDemo( void )
{
char str[MAX_QPATH];

View File

@ -1492,9 +1492,3 @@ qboolean CL_GetMovieSpatialization( rawchan_t *ch )
return true;
}
void CL_ExtraUpdate( void )
{
clgame.dllFuncs.IN_Accumulate();
S_ExtraUpdate();
}

View File

@ -2671,6 +2671,48 @@ static model_t *pfnLoadMapSprite( const char *filename )
return NULL;
}
/*
=============
COM_AddAppDirectoryToSearchPath
=============
*/
static void GAME_EXPORT COM_AddAppDirectoryToSearchPath( const char *pszBaseDir, const char *appName )
{
FS_AddGameHierarchy( pszBaseDir, FS_NOWRITE_PATH );
}
/*
===========
COM_ExpandFilename
Finds the file in the search path, copies over the name with the full path name.
This doesn't search in the pak file.
===========
*/
static int GAME_EXPORT COM_ExpandFilename( const char *fileName, char *nameOutBuffer, int nameOutBufferSize )
{
char result[MAX_SYSPATH];
if( !COM_CheckString( fileName ) || !nameOutBuffer || nameOutBufferSize <= 0 )
return 0;
// filename examples:
// media\sierra.avi - D:\Xash3D\valve\media\sierra.avi
// models\barney.mdl - D:\Xash3D\bshift\models\barney.mdl
if( g_fsapi.GetFullDiskPath( result, sizeof( result ), fileName, false ))
{
// check for enough room
if( Q_strlen( result ) > nameOutBufferSize )
return 0;
Q_strncpy( nameOutBuffer, result, nameOutBufferSize );
return 1;
}
return 0;
}
/*
=============
PlayerInfo_ValueForKey

View File

@ -790,6 +790,7 @@ void CL_Demos_f( void );
void CL_DeleteDemo_f( void );
void CL_Record_f( void );
void CL_Stop_f( void );
int CL_GetDemoComment( const char *demoname, char *comment );
//
// cl_events.c
@ -859,6 +860,7 @@ movevars_t *pfnGetMoveVars( void );
void CL_EnableScissor( scissor_state_t *scissor, int x, int y, int width, int height );
void CL_DisableScissor( scissor_state_t *scissor );
qboolean CL_Scissor( const scissor_state_t *scissor, float *x, float *y, float *width, float *height, float *u0, float *v0, float *u1, float *v1 );
struct cl_entity_s *CL_GetEntityByIndex( int index );
_inline cl_entity_t *CL_EDICT_NUM( int n )
{

View File

@ -109,6 +109,12 @@ static void *pfnMod_Extradata( int type, model_t *m )
return NULL;
}
static void CL_ExtraUpdate( void )
{
clgame.dllFuncs.IN_Accumulate();
S_ExtraUpdate();
}
static void pfnCL_GetScreenInfo( int *width, int *height ) // clgame.scrInfo, ptrs may be NULL
{
if( width ) *width = clgame.scrInfo.iWidth;

View File

@ -53,7 +53,7 @@ static void Cmd_ExecuteStringWithPrivilegeCheck( const char *text, qboolean isPr
Cbuf_Init
============
*/
void Cbuf_Init( void )
static void Cbuf_Init( void )
{
cmd_text.data = cmd_text_buf;
filteredcmd_text.data = filteredcmd_text_buf;

View File

@ -531,47 +531,6 @@ int GAME_EXPORT COM_FileSize( const char *filename )
return FS_FileSize( filename, false );
}
/*
=============
COM_AddAppDirectoryToSearchPath
=============
*/
void GAME_EXPORT COM_AddAppDirectoryToSearchPath( const char *pszBaseDir, const char *appName )
{
FS_AddGameHierarchy( pszBaseDir, FS_NOWRITE_PATH );
}
/*
===========
COM_ExpandFilename
Finds the file in the search path, copies over the name with the full path name.
This doesn't search in the pak file.
===========
*/
int GAME_EXPORT COM_ExpandFilename( const char *fileName, char *nameOutBuffer, int nameOutBufferSize )
{
char result[MAX_SYSPATH];
if( !COM_CheckString( fileName ) || !nameOutBuffer || nameOutBufferSize <= 0 )
return 0;
// filename examples:
// media\sierra.avi - D:\Xash3D\valve\media\sierra.avi
// models\barney.mdl - D:\Xash3D\bshift\models\barney.mdl
if( g_fsapi.GetFullDiskPath( result, sizeof( result ), fileName, false ))
{
// check for enough room
if( Q_strlen( result ) > nameOutBufferSize )
return 0;
Q_strncpy( nameOutBuffer, result, nameOutBufferSize );
return 1;
}
return 0;
}
/*
=============
COM_TrimSpace
@ -869,18 +828,6 @@ cvar_t *GAME_EXPORT pfnCVarGetPointer( const char *szVarName )
return (cvar_t *)Cvar_FindVar( szVarName );
}
/*
=============
pfnCVarDirectSet
allow to set cvar directly
=============
*/
void GAME_EXPORT pfnCVarDirectSet( cvar_t *var, const char *szValue )
{
Cvar_DirectSet( (convar_t *)var, szValue );
}
/*
=============
COM_CompareFileTime
@ -996,21 +943,6 @@ qboolean COM_IsSafeFileToDownload( const char *filename )
return true;
}
const char *COM_GetResourceTypeName( resourcetype_t restype )
{
switch( restype )
{
case t_decal: return "decal";
case t_eventscript: return "eventscript";
case t_generic: return "generic";
case t_model: return "model";
case t_skin: return "skin";
case t_sound: return "sound";
case t_world: return "world";
default: return "unknown";
}
}
char *_copystring( poolhandle_t mempool, const char *s, const char *filename, int fileline )
{
size_t size;

View File

@ -388,7 +388,6 @@ void *FS_GetNativeObject( const char *obj );
//
// cmd.c
//
void Cbuf_Init( void );
void Cbuf_Clear( void );
void Cbuf_AddText( const char *text );
void Cbuf_AddTextf( const char *text, ... ) _format( 1 );
@ -412,9 +411,6 @@ void Cmd_RemoveCommand( const char *cmd_name );
qboolean Cmd_Exists( const char *cmd_name );
void Cmd_LookupCmds( void *buffer, void *ptr, setpair_t callback );
int Cmd_ListMaps( search_t *t , char *lastmapname, size_t len );
qboolean Cmd_GetMapList( const char *s, char *completedname, int length );
qboolean Cmd_GetDemoList( const char *s, char *completedname, int length );
qboolean Cmd_GetMovieList( const char *s, char *completedname, int length );
void Cmd_TokenizeString( const char *text );
void Cmd_ExecuteString( const char *text );
void Cmd_ForwardToServer( void );
@ -461,13 +457,12 @@ void FS_FreeImage( rgbdata_t *pack );
extern const bpc_desc_t PFDesc[]; // image get pixelformat
qboolean Image_Process( rgbdata_t **pix, int width, int height, uint flags, float reserved );
void Image_PaletteHueReplace( byte *palSrc, int newHue, int start, int end, int pal_size );
void Image_PaletteTranslate( byte *palSrc, int top, int bottom, int pal_size );
void Image_SetForceFlags( uint flags ); // set image force flags on loading
size_t Image_DXTGetLinearSize( int type, int width, int height, int depth );
qboolean Image_CustomPalette( void );
void Image_ClearForceFlags( void );
void Image_SetMDLPointer( byte *p );
void Image_CheckPaletteQ1( void );
/*
========================================================================
@ -543,7 +538,6 @@ qboolean Host_IsQuakeCompatible( void );
void EXPORT Host_Shutdown( void );
int EXPORT Host_Main( int argc, char **argv, const char *progname, int bChangeGame, pfnChangeGame func );
int Host_CompareFileTime( int ft1, int ft2 );
void Host_NewInstance( const char *name, const char *finalmsg );
void Host_EndGame( qboolean abort, const char *message, ... ) _format( 2 );
void Host_AbortCurrentFrame( void ) NORETURN;
void Host_WriteServerConfig( const char *name );
@ -556,7 +550,6 @@ void Host_ShutdownServer( void );
void Host_Error( const char *error, ... ) _format( 1 );
void Host_ValidateEngineFeatures( uint32_t features );
void Host_Frame( float time );
void Host_InitDecals( void );
void Host_Credits( void );
//
@ -600,7 +593,6 @@ void COM_HexConvert( const char *pszInput, int nInputLength, byte *pOutput );
int COM_SaveFile( const char *filename, const void *data, int len );
byte* COM_LoadFileForMe( const char *filename, int *pLength );
qboolean COM_IsSafeFileToDownload( const char *filename );
const char *COM_GetResourceTypeName( resourcetype_t restype );
cvar_t *pfnCVarGetPointer( const char *szVarName );
int pfnDrawConsoleString( int x, int y, char *string );
void pfnDrawSetTextColor( float r, float g, float b );
@ -608,7 +600,6 @@ void pfnDrawConsoleStringLen( const char *pText, int *length, int *height );
void *Cache_Check( poolhandle_t mempool, struct cache_user_s *c );
void COM_TrimSpace( const char *source, char *dest );
void pfnGetModelBounds( model_t *mod, float *mins, float *maxs );
void pfnCVarDirectSet( cvar_t *var, const char *szValue );
int COM_CheckParm( char *parm, char **ppnext );
void pfnGetGameDir( char *szGetGameDir );
int pfnGetModelType( model_t *mod );
@ -650,7 +641,6 @@ void pfnResetTutorMessageDecayData( void );
//
// con_utils.c
//
qboolean Cmd_AutocompleteName( const char *source, int arg, char *buffer, size_t bufsize );
void Con_CompleteCommand( field_t *field );
void Cmd_AutoComplete( char *complete_string );
void Cmd_AutoCompleteClear( void );
@ -706,24 +696,15 @@ void CL_LegacyUpdateInfo( void );
void CL_CharEvent( int key );
qboolean CL_DisableVisibility( void );
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 );
int COM_ExpandFilename( const char *fileName, char *nameOutBuffer, int nameOutBufferSize );
struct cmd_s *Cmd_GetFirstFunctionHandle( void );
struct cmd_s *Cmd_GetNextFunctionHandle( struct cmd_s *cmd );
struct cmdalias_s *Cmd_AliasGetList( void );
const char *Cmd_GetName( struct cmd_s *cmd );
void SV_StartSound( edict_t *ent, int chan, const char *sample, float vol, float attn, int flags, int pitch );
void SV_CreateDecal( sizebuf_t *msg, const float *origin, int decalIndex, int entityIndex, int modelIndex, int flags, float scale );
void Log_Printf( const char *fmt, ... ) _format( 1 );
void SV_BroadcastCommand( const char *fmt, ... ) _format( 1 );
qboolean SV_RestoreCustomDecal( struct decallist_s *entry, edict_t *pEdict, qboolean adjacent );
void SV_BroadcastPrintf( struct sv_client_s *ignore, const char *fmt, ... ) _format( 2 );
int R_CreateDecalList( struct decallist_s *pList );
void R_ClearAllDecals( void );
void CL_ClearStaticEntities( void );
qboolean S_StreamGetCurrentState( char *currentTrack, char *loopTrack, int *position );
struct cl_entity_s *CL_GetEntityByIndex( int index );
void CL_ServerCommand( qboolean reliable, const char *fmt, ... ) _format( 2 );
void CL_HudMessage( const char *pMessage );
const char *CL_MsgInfo( int cmd );
@ -732,17 +713,14 @@ void SV_DrawOrthoTriangles( void );
double CL_GetDemoFramerate( void );
qboolean UI_CreditsActive( void );
void CL_StopPlayback( void );
void CL_ExtraUpdate( void );
int CL_GetMaxClients( void );
int SV_GetMaxClients( void );
qboolean CL_IsRecordDemo( void );
qboolean CL_IsTimeDemo( void );
qboolean CL_IsPlaybackDemo( void );
qboolean SV_Initialized( void );
qboolean CL_LoadProgs( const char *name );
void CL_ProcessFile( qboolean successfully_received, const char *filename );
int SV_GetSaveComment( const char *savename, char *comment );
qboolean SV_NewGame( const char *mapName, qboolean loadGame );
void SV_ClipPMoveToEntity( struct physent_s *pe, const vec3_t start, vec3_t mins, vec3_t maxs, const vec3_t end, struct pmtrace_s *tr );
void CL_ClipPMoveToEntity( struct physent_s *pe, const vec3_t start, vec3_t mins, vec3_t maxs, const vec3_t end, struct pmtrace_s *tr );
void SV_SysError( const char *error_string );
@ -751,11 +729,9 @@ void SV_ExecLoadLevel( void );
void SV_ExecLoadGame( void );
void SV_ExecChangeLevel( void );
void CL_WriteMessageHistory( void );
void CL_SendCmd( void );
void CL_Disconnect( void );
void CL_ClearEdicts( void );
void CL_Crashed( void );
qboolean CL_NextDemo( void );
char *SV_Serverinfo( void );
void CL_Drop( void );
void Con_Init( void );
@ -780,7 +756,6 @@ qboolean Info_SetValueForStarKey( char *s, const char *key, const char *value, i
qboolean Info_IsValid( const char *s );
void Info_WriteVars( file_t *f );
void Info_Print( const char *s );
void Cmd_WriteVariables( file_t *f );
int Cmd_CheckMapsList( int fRefresh );
void COM_SetRandomSeed( int lSeed );
int COM_RandomLong( int lMin, int lMax );

View File

@ -184,7 +184,7 @@ Cmd_GetMapList
Prints or complete map filename
=====================================
*/
qboolean Cmd_GetMapList( const char *s, char *completedname, int length )
static qboolean Cmd_GetMapList( const char *s, char *completedname, int length )
{
search_t *t;
string matchbuf;
@ -220,7 +220,7 @@ Cmd_GetDemoList
Prints or complete demo filename
=====================================
*/
qboolean Cmd_GetDemoList( const char *s, char *completedname, int length )
static qboolean Cmd_GetDemoList( const char *s, char *completedname, int length )
{
search_t *t;
string matchbuf;
@ -267,7 +267,7 @@ Cmd_GetMovieList
Prints or complete movie filename
=====================================
*/
qboolean Cmd_GetMovieList( const char *s, char *completedname, int length )
static qboolean Cmd_GetMovieList( const char *s, char *completedname, int length )
{
search_t *t;
string matchbuf;
@ -754,10 +754,6 @@ static qboolean Cmd_GetGamesList( const char *s, char *completedname, int length
string matchbuf;
int len;
// stand-alone games doesn't have cmd "game"
if( !Cmd_Exists( "game" ))
return false;
// compare gamelist with current keyword
len = Q_strlen( s );
@ -1061,7 +1057,7 @@ Autocomplete filename
for various cmds
============
*/
qboolean Cmd_AutocompleteName( const char *source, int arg, char *buffer, size_t bufsize )
static qboolean Cmd_AutocompleteName( const char *source, int arg, char *buffer, size_t bufsize )
{
autocomplete_list_t *list;

View File

@ -685,7 +685,7 @@ Cvar_DirectSet
way to change value for many cvars
============
*/
void Cvar_DirectSet( convar_t *var, const char *value )
void GAME_EXPORT Cvar_DirectSet( convar_t *var, const char *value )
{
const char *pszValue;

View File

@ -134,15 +134,6 @@ void Con_Init( void )
}
void R_ClearAllDecals( void )
{
}
int R_CreateDecalList( struct decallist_s *pList )
{
return 0;
}
void GAME_EXPORT S_StopSound(int entnum, int channel, const char *soundname)
{

View File

@ -348,7 +348,7 @@ static int Host_CalcSleep( void )
return host_sleeptime.value;
}
void Host_NewInstance( const char *name, const char *finalmsg )
static void Host_NewInstance( const char *name, const char *finalmsg )
{
if( !pChangeGame ) return;
@ -582,7 +582,7 @@ static qboolean Host_RegisterDecal( const char *name, int *count )
Host_InitDecals
=================
*/
void Host_InitDecals( void )
static void Host_InitDecals( void )
{
int i, num_decals = 0;
search_t *t;

View File

@ -530,7 +530,7 @@ void Image_PaletteHueReplace( byte *palSrc, int newHue, int start, int end, int
}
}
void Image_PaletteTranslate( byte *palSrc, int top, int bottom, int pal_size )
static void Image_PaletteTranslate( byte *palSrc, int top, int bottom, int pal_size )
{
byte dst[256], src[256];
int i;

View File

@ -166,7 +166,7 @@ Some modders use _i?86 suffix in game library name
So strip it to follow library naming for non-Intel CPUs
==============
*/
static void COM_StripIntelSuffix( char *out )
static inline void COM_StripIntelSuffix( char *out )
{
char *suffix = Q_strrchr( out, '_' );

View File

@ -651,6 +651,8 @@ int pfnDropToFloor( edict_t* e );
edict_t *SV_EdictNum( int n );
void SV_SetModel( edict_t *ent, const char *name );
int pfnDecalIndex( const char *m );
void SV_CreateDecal( sizebuf_t *msg, const float *origin, int decalIndex, int entityIndex, int modelIndex, int flags, float scale );
qboolean SV_RestoreCustomDecal( struct decallist_s *entry, edict_t *pEdict, qboolean adjacent );
//
// sv_log.c

View File

@ -4796,7 +4796,7 @@ static enginefuncs_t gEngfuncs =
Delta_UnsetFieldByIndex,
pfnSetGroupMask,
pfnCreateInstancedBaseline,
pfnCVarDirectSet,
(void*)Cvar_DirectSet,
pfnForceUnmodified,
pfnGetPlayerStats,
Cmd_AddServerCommand,

View File

@ -284,6 +284,21 @@ static resourcetype_t SV_DetermineResourceType( const char *filename )
return t_generic;
}
static const char *SV_GetResourceTypeName( resourcetype_t restype )
{
switch( restype )
{
case t_decal: return "decal";
case t_eventscript: return "eventscript";
case t_generic: return "generic";
case t_model: return "model";
case t_skin: return "skin";
case t_sound: return "sound";
case t_world: return "world";
default: return "unknown";
}
}
static void SV_ReadResourceList( const char *filename )
{
string token;
@ -306,7 +321,7 @@ static void SV_ReadResourceList( const char *filename )
COM_FixSlashes( token );
restype = SV_DetermineResourceType( token );
Con_DPrintf( " %s (%s)\n", token, COM_GetResourceTypeName( restype ));
Con_DPrintf( " %s (%s)\n", token, SV_GetResourceTypeName( restype ));
switch( restype )
{
// TODO do we need to handle other resource types specifically too?