Browse Source

engine: common: static-ize common.c functions, set GAME_EXPORT to API functions

pull/2/head
Alibek Omarov 1 year ago
parent
commit
7e06d049f5
  1. 16
      engine/client/cl_game.c
  2. 11
      engine/client/cl_gameui.c
  3. 36
      engine/common/common.c
  4. 2
      engine/common/common.h

16
engine/client/cl_game.c

@ -1685,6 +1685,22 @@ static void GAME_EXPORT pfnSetCrosshair( HSPRITE hspr, wrect_t rc, int r, int g, @@ -1685,6 +1685,22 @@ static void GAME_EXPORT pfnSetCrosshair( HSPRITE hspr, wrect_t rc, int r, int g,
clgame.ds.rcCrosshair = rc;
}
/*
=============
pfnCvar_RegisterVariable
=============
*/
static cvar_t *GAME_EXPORT pfnCvar_RegisterClientVariable( const char *szName, const char *szValue, int flags )
{
// a1ba: try to mitigate outdated client.dll vulnerabilities
if( !Q_stricmp( szName, "motdfile" ))
flags |= FCVAR_PRIVILEGED;
return (cvar_t *)Cvar_Get( szName, szValue, flags|FCVAR_CLIENTDLL, Cvar_BuildAutoDescription( szName, flags|FCVAR_CLIENTDLL ));
}
/*
=============
pfnHookUserMsg

11
engine/client/cl_gameui.c

@ -642,6 +642,17 @@ static void GAME_EXPORT pfnFillRGBA( int x, int y, int width, int height, int r, @@ -642,6 +642,17 @@ static void GAME_EXPORT pfnFillRGBA( int x, int y, int width, int height, int r,
ref.dllFuncs.Color4ub( 255, 255, 255, 255 );
}
/*
=============
pfnCvar_RegisterVariable
=============
*/
static cvar_t *GAME_EXPORT pfnCvar_RegisterGameUIVariable( const char *szName, const char *szValue, int flags )
{
return (cvar_t *)Cvar_Get( szName, szValue, flags|FCVAR_GAMEUIDLL, Cvar_BuildAutoDescription( szName, flags|FCVAR_GAMEUIDLL ));
}
/*
=============
pfnClientCmd

36
engine/common/common.c

@ -104,7 +104,7 @@ static float fran1( void ) @@ -104,7 +104,7 @@ static float fran1( void )
return temp;
}
void COM_SetRandomSeed( int lSeed )
void GAME_EXPORT COM_SetRandomSeed( int lSeed )
{
if( lSeed ) idum = lSeed;
else idum = -time( NULL );
@ -267,7 +267,7 @@ static void LZSS_BuildHash( lzss_state_t *state, const byte *source ) @@ -267,7 +267,7 @@ static void LZSS_BuildHash( lzss_state_t *state, const byte *source )
list->start = node;
}
byte *LZSS_CompressNoAlloc( lzss_state_t *state, byte *pInput, int input_length, byte *pOutputBuf, uint *pOutputSize )
static byte *LZSS_CompressNoAlloc( lzss_state_t *state, byte *pInput, int input_length, byte *pOutputBuf, uint *pOutputSize )
{
byte *pStart = pOutputBuf; // allocate the output buffer, compressed buffer is expected to be less, caller will free
byte *pEnd = pStart + input_length - sizeof( lzss_header_t ) - 8; // prevent compression failure
@ -613,7 +613,7 @@ COM_Nibble @@ -613,7 +613,7 @@ COM_Nibble
Returns the 4 bit nibble for a hex character
==================
*/
byte COM_Nibble( char c )
static byte COM_Nibble( char c )
{
if(( c >= '0' ) && ( c <= '9' ))
{
@ -715,7 +715,7 @@ Cache_Check @@ -715,7 +715,7 @@ Cache_Check
consistency check
====================
*/
void *Cache_Check( poolhandle_t mempool, cache_user_t *c )
void *GAME_EXPORT Cache_Check( poolhandle_t mempool, cache_user_t *c )
{
if( !c->data )
return NULL;
@ -858,32 +858,6 @@ void GAME_EXPORT pfnGetModelBounds( model_t *mod, float *mins, float *maxs ) @@ -858,32 +858,6 @@ void GAME_EXPORT pfnGetModelBounds( model_t *mod, float *mins, float *maxs )
}
}
/*
=============
pfnCvar_RegisterVariable
=============
*/
cvar_t *pfnCvar_RegisterClientVariable( const char *szName, const char *szValue, int flags )
{
// a1ba: try to mitigate outdated client.dll vulnerabilities
if( !Q_stricmp( szName, "motdfile" ))
flags |= FCVAR_PRIVILEGED;
return (cvar_t *)Cvar_Get( szName, szValue, flags|FCVAR_CLIENTDLL, Cvar_BuildAutoDescription( szName, flags|FCVAR_CLIENTDLL ));
}
/*
=============
pfnCvar_RegisterVariable
=============
*/
cvar_t *pfnCvar_RegisterGameUIVariable( const char *szName, const char *szValue, int flags )
{
return (cvar_t *)Cvar_Get( szName, szValue, flags|FCVAR_GAMEUIDLL, Cvar_BuildAutoDescription( szName, flags|FCVAR_GAMEUIDLL ));
}
/*
=============
pfnCVarGetPointer
@ -891,7 +865,7 @@ pfnCVarGetPointer @@ -891,7 +865,7 @@ pfnCVarGetPointer
can return NULL
=============
*/
cvar_t *pfnCVarGetPointer( const char *szVarName )
cvar_t *GAME_EXPORT pfnCVarGetPointer( const char *szVarName )
{
return (cvar_t *)Cvar_FindVar( szVarName );
}

2
engine/common/common.h

@ -626,8 +626,6 @@ qboolean SV_Active( void ); @@ -626,8 +626,6 @@ qboolean SV_Active( void );
==============================================================
*/
cvar_t *pfnCvar_RegisterClientVariable( const char *szName, const char *szValue, int flags );
cvar_t *pfnCvar_RegisterGameUIVariable( const char *szName, const char *szValue, int flags );
char *COM_MemFgets( byte *pMemFile, int fileSize, int *filePos, char *pBuffer, int bufferSize );
void COM_HexConvert( const char *pszInput, int nInputLength, byte *pOutput );
int COM_SaveFile( const char *filename, const void *data, int len );

Loading…
Cancel
Save