Skip to content

Commit

Permalink
engine: common: static-ize common.c functions, set GAME_EXPORT to API…
Browse files Browse the repository at this point in the history
… functions
  • Loading branch information
a1batross committed Jun 20, 2023
1 parent 5a4c443 commit 7e06d04
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 34 deletions.
16 changes: 16 additions & 0 deletions engine/client/cl_game.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions engine/client/cl_gameui.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
38 changes: 6 additions & 32 deletions engine/common/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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' ))
{
Expand Down Expand Up @@ -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;
Expand All @@ -732,7 +732,7 @@ COM_LoadFileForMe
=============
*/
byte* GAME_EXPORT COM_LoadFileForMe( const char *filename, int *pLength )
byte *GAME_EXPORT COM_LoadFileForMe( const char *filename, int *pLength )
{
string name;
byte *file, *pfile;
Expand Down Expand Up @@ -858,40 +858,14 @@ 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
can return NULL
=============
*/
cvar_t *pfnCVarGetPointer( const char *szVarName )
cvar_t *GAME_EXPORT pfnCVarGetPointer( const char *szVarName )
{
return (cvar_t *)Cvar_FindVar( szVarName );
}
Expand Down
2 changes: 0 additions & 2 deletions engine/common/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down

0 comments on commit 7e06d04

Please sign in to comment.