Skip to content

Commit

Permalink
Replace hardcoded functions names by __func__ macro
Browse files Browse the repository at this point in the history
* while we're here, fix some possible bugs
* and fix -Wformat=2

s/__FUNCTION__/__func__/g

awawawa
  • Loading branch information
a1batross committed Jun 19, 2024
1 parent 3503c72 commit d56e53a
Show file tree
Hide file tree
Showing 104 changed files with 586 additions and 584 deletions.
5 changes: 3 additions & 2 deletions common/xash3d_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,9 @@ _inline float LittleFloat( float f )
#endif


typedef unsigned int dword;
typedef unsigned int uint;
typedef unsigned int dword;
typedef unsigned int uint;
typedef unsigned long ulong;
typedef char string[MAX_STRING];
typedef struct file_s file_t; // normal file
typedef struct stream_s stream_t; // sound stream for background music playing
Expand Down
4 changes: 2 additions & 2 deletions engine/client/cl_custom.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ void CL_AddToResourceList( resource_t *pResource, resource_t *pList )
void CL_RemoveFromResourceList( resource_t *pResource )
{
if( pResource->pPrev == NULL || pResource->pNext == NULL )
Host_Error( "mislinked resource in CL_RemoveFromResourceList\n" );
Host_Error( "mislinked resource in %s\n", __func__ );

if( pResource->pNext == pResource || pResource->pPrev == pResource )
Host_Error( "attempt to free last entry in list.\n" );
Expand All @@ -120,7 +120,7 @@ void CL_MoveToOnHandList( resource_t *pResource )
{
if( !pResource )
{
Con_Reportf( "Null resource passed to CL_MoveToOnHandList\n" );
Con_Reportf( "Null resource passed to %s\n", __func__ );
return;
}

Expand Down
2 changes: 1 addition & 1 deletion engine/client/cl_demo.c
Original file line number Diff line number Diff line change
Expand Up @@ -1623,7 +1623,7 @@ void CL_StartDemos_f( void )
c = Cmd_Argc() - 1;
if( c > MAX_DEMOS )
{
Con_DPrintf( S_WARN "Host_StartDemos: max %i demos in demoloop\n", MAX_DEMOS );
Con_DPrintf( S_WARN "%s: max %i demos in demoloop\n", __func__, MAX_DEMOS );
c = MAX_DEMOS;
}

Expand Down
8 changes: 4 additions & 4 deletions engine/client/cl_events.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ static qboolean CL_FireEvent( event_info_t *ei, int slot )
if( !ev )
{
idx = bound( 1, ei->index, ( MAX_EVENTS - 1 ));
Con_Reportf( S_ERROR "CL_FireEvent: %s not precached\n", cl.event_precache[idx] );
Con_Reportf( S_ERROR "%s: %s not precached\n", __func__, cl.event_precache[idx] );
break;
}

Expand All @@ -244,7 +244,7 @@ static qboolean CL_FireEvent( event_info_t *ei, int slot )
return true;
}

Con_Reportf( S_ERROR "CL_FireEvent: %s not hooked\n", name );
Con_Reportf( S_ERROR "%s: %s not hooked\n", __func__, name );
break;
}
}
Expand Down Expand Up @@ -497,14 +497,14 @@ void GAME_EXPORT CL_PlaybackEvent( int flags, const edict_t *pInvoker, word even
// first check event for out of bounds
if( eventindex < 1 || eventindex >= MAX_EVENTS )
{
Con_DPrintf( S_ERROR "CL_PlaybackEvent: invalid eventindex %i\n", eventindex );
Con_DPrintf( S_ERROR "%s: invalid eventindex %i\n", __func__, eventindex );
return;
}

// check event for precached
if( !CL_EventIndex( cl.event_precache[eventindex] ))
{
Con_DPrintf( S_ERROR "CL_PlaybackEvent: event %i was not precached\n", eventindex );
Con_DPrintf( S_ERROR "%s: event %i was not precached\n", __func__, eventindex );
return;
}

Expand Down
10 changes: 5 additions & 5 deletions engine/client/cl_frame.c
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ static void CL_FlushEntityPacket( sizebuf_t *msg )
break; // done

if( MSG_CheckOverflow( msg ))
Host_Error( "CL_FlushEntityPacket: overflow\n" );
Host_Error( "%s: overflow\n", __func__ );

MSG_ReadDeltaEntity( msg, &from, &to, newnum, CL_IsPlayerIndex( newnum ) ? DELTA_PLAYER : DELTA_ENTITY, cl.mtime[0] );
}
Expand Down Expand Up @@ -740,7 +740,7 @@ static void CL_DeltaEntity( sizebuf_t *msg, frame_t *frame, int newnum, entity_s

if(( newnum < 0 ) || ( newnum >= clgame.maxEntities ))
{
Con_DPrintf( S_ERROR "CL_DeltaEntity: invalid newnum: %d\n", newnum );
Con_DPrintf( S_ERROR "%s: invalid newnum: %d\n", __func__, newnum );
if( has_update )
MSG_ReadDeltaEntity( msg, old, state, newnum, delta_type, cl.mtime[0] );
return;
Expand Down Expand Up @@ -885,7 +885,7 @@ int CL_ParsePacketEntities( sizebuf_t *msg, qboolean delta )
break; // done

if( MSG_CheckOverflow( msg ))
Host_Error( "CL_ParsePacketEntities: overflow\n" );
Host_Error( "%s: overflow\n", __func__ );

player = CL_IsPlayerIndex( newnum );

Expand Down Expand Up @@ -955,7 +955,7 @@ int CL_ParsePacketEntities( sizebuf_t *msg, qboolean delta )
}

if( newframe->num_entities != count && newframe->num_entities != 0 )
Con_Reportf( S_WARN "CL_Parse%sPacketEntities: (%i should be %i)\n", delta ? "Delta" : "", newframe->num_entities, count );
Con_Reportf( S_WARN "%s%s: (%i should be %i)\n", __func__, delta ? "Delta" : "", newframe->num_entities, count );

if( !newframe->valid )
return playerbytes; // frame is not valid but message was parsed
Expand Down Expand Up @@ -1187,7 +1187,7 @@ static void CL_LinkPacketEntities( frame_t *frame )

if( !ent )
{
Con_Reportf( S_ERROR "CL_LinkPacketEntity: bad entity %i\n", state->number );
Con_Reportf( S_ERROR "%s: bad entity %i\n", __func__, state->number );
continue;
}

Expand Down
42 changes: 21 additions & 21 deletions engine/client/cl_game.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ static void CL_InitCDAudio( const char *filename )

if( ++c > MAX_CDTRACKS - 1 )
{
Con_Reportf( S_WARN "CD_Init: too many tracks %i in %s\n", MAX_CDTRACKS, filename );
Con_Reportf( S_WARN "%s: too many tracks %i in %s\n", __func__, MAX_CDTRACKS, filename );
break;
}
}
Expand Down Expand Up @@ -777,14 +777,14 @@ static const char *CL_SoundFromIndex( int index )

if( !hSound )
{
Con_DPrintf( S_ERROR "CL_SoundFromIndex: invalid sound index %i\n", index );
Con_DPrintf( S_ERROR "%s: invalid sound index %i\n", __func__, index );
return NULL;
}

sfx = S_GetSfxByHandle( hSound );
if( !sfx )
{
Con_DPrintf( S_ERROR "CL_SoundFromIndex: bad sfx for index %i\n", index );
Con_DPrintf( S_ERROR "%s: bad sfx for index %i\n", __func__, index );
return NULL;
}

Expand Down Expand Up @@ -1041,10 +1041,10 @@ void CL_LinkUserMessage( char *pszName, const int svc_num, int iSize )
int i;

if( !pszName || !*pszName )
Host_Error( "CL_LinkUserMessage: bad message name\n" );
Host_Error( "%s: bad message name\n", __func__ );

if( svc_num <= svc_lastmsg )
Host_Error( "CL_LinkUserMessage: tried to hook a system message \"%s\"\n", svc_strings[svc_num] );
Host_Error( "%s: tried to hook a system message \"%s\"\n", __func__, svc_strings[svc_num] );

// see if already hooked
for( i = 0; i < MAX_USER_MESSAGES && clgame.msg[i].name[0]; i++ )
Expand All @@ -1061,7 +1061,7 @@ void CL_LinkUserMessage( char *pszName, const int svc_num, int iSize )

if( i == MAX_USER_MESSAGES )
{
Host_Error( "CL_LinkUserMessage: MAX_USER_MESSAGES hit!\n" );
Host_Error( "%s: MAX_USER_MESSAGES hit!\n", __func__ );
return;
}

Expand Down Expand Up @@ -1242,7 +1242,7 @@ static model_t *CL_LoadSpriteModel( const char *filename, uint type, uint texFla

if( !COM_CheckString( filename ))
{
Con_Reportf( S_ERROR "CL_LoadSpriteModel: bad name!\n" );
Con_Reportf( S_ERROR "%s: bad name!\n", __func__ );
return NULL;
}

Expand Down Expand Up @@ -1503,12 +1503,12 @@ static void GAME_EXPORT pfnSPR_DrawAdditive( int frame, int x, int y, const wrec

/*
=========
pfnSPR_GetList
SPR_GetList
for parsing half-life scripts - hud.txt etc
=========
*/
static client_sprite_t *pfnSPR_GetList( char *psz, int *piCount )
static client_sprite_t *SPR_GetList( char *psz, int *piCount )
{
cached_spritelist_t *pEntry = &clgame.sprlist[0];
int slot, index, numSprites = 0;
Expand All @@ -1534,7 +1534,7 @@ static client_sprite_t *pfnSPR_GetList( char *psz, int *piCount )

if( slot == MAX_CLIENT_SPRITES )
{
Con_Printf( S_ERROR "SPR_GetList: overflow cache!\n" );
Con_Printf( S_ERROR "%s: overflow cache!\n", __func__ );
return NULL;
}

Expand Down Expand Up @@ -1743,7 +1743,7 @@ static int GAME_EXPORT pfnHookUserMsg( const char *pszName, pfnUserMsgHook pfn )

if( i == MAX_USER_MESSAGES )
{
Host_Error( "HookUserMsg: MAX_USER_MESSAGES hit!\n" );
Host_Error( "%s: MAX_USER_MESSAGES hit!\n", __func__ );
return 0;
}

Expand Down Expand Up @@ -2293,7 +2293,7 @@ static void GAME_EXPORT pfnHookEvent( const char *filename, pfnEventHook pfn )

if( !Q_stricmp( name, ev->name ) && ev->func != NULL )
{
Con_Reportf( S_WARN "CL_HookEvent: %s already hooked!\n", name );
Con_Reportf( S_WARN "%s: %s already hooked!\n", __func__, name );
return;
}
}
Expand Down Expand Up @@ -3420,7 +3420,7 @@ static void GAME_EXPORT NetAPI_SendRequest( int context, int request, int flags,

if( !response )
{
Con_DPrintf( S_ERROR "Net_SendRequest: no callbcak specified for request with context %i!\n", context );
Con_DPrintf( S_ERROR "%s: no callbcak specified for request with context %i!\n", __func__, context );
return;
}

Expand Down Expand Up @@ -3808,7 +3808,7 @@ static cl_enginefunc_t gEngfuncs =
pfnSPR_DrawAdditive,
SPR_EnableScissor,
SPR_DisableScissor,
pfnSPR_GetList,
SPR_GetList,
CL_FillRGBA,
CL_GetScreenInfo,
pfnSetCrosshair,
Expand Down Expand Up @@ -4030,14 +4030,14 @@ qboolean CL_LoadProgs( const char *name )
// trying to get single export
if(( GetClientAPI = (void *)COM_GetProcAddress( clgame.hInstance, "GetClientAPI" )) != NULL )
{
Con_Reportf( "CL_LoadProgs: found single callback export\n" );
Con_Reportf( "%s: found single callback export\n", __func__ );

// trying to fill interface now
GetClientAPI( &clgame.dllFuncs );
}
else if(( GetClientAPI = (void *)COM_GetProcAddress( clgame.hInstance, "F" )) != NULL )
{
Con_Reportf( "CL_LoadProgs: found single callback export (secured client dlls)\n" );
Con_Reportf( "%s: found single callback export (secured client dlls)\n", __func__ );

// trying to fill interface now
CL_GetSecuredClientAPI( GetClientAPI );
Expand Down Expand Up @@ -4065,7 +4065,7 @@ qboolean CL_LoadProgs( const char *name )
// functions are cleared before all the extensions are evaluated
if(( *func->func = (void *)COM_GetProcAddress( clgame.hInstance, func->name )) == NULL )
{
Con_Reportf( "CL_LoadProgs: failed to get address of %s proc\n", func->name );
Con_Reportf( "%s: failed to get address of %s proc\n", __func__, func->name );

if( critical_exports )
{
Expand All @@ -4092,13 +4092,13 @@ qboolean CL_LoadProgs( const char *name )
// functions are cleared before all the extensions are evaluated
// NOTE: new exports can be missed without stop the engine
if(( *func->func = (void *)COM_GetProcAddress( clgame.hInstance, func->name )) == NULL )
Con_Reportf( "CL_LoadProgs: failed to get address of %s proc\n", func->name );
Con_Reportf( "%s: failed to get address of %s proc\n", __func__, func->name );
}

if( !clgame.dllFuncs.pfnInitialize( &gEngfuncs, CLDLL_INTERFACE_VERSION ))
{
COM_FreeLibrary( clgame.hInstance );
Con_Reportf( "CL_LoadProgs: can't init client API\n" );
Con_Reportf( "%s: can't init client API\n", __func__ );
clgame.hInstance = NULL;
return false;
}
Expand All @@ -4115,10 +4115,10 @@ qboolean CL_LoadProgs( const char *name )
CL_InitTempEnts ();

if( !R_InitRenderAPI()) // Xash3D extension
Con_Reportf( S_WARN "CL_LoadProgs: couldn't get render API\n" );
Con_Reportf( S_WARN "%s: couldn't get render API\n", __func__ );

if( !Mobile_Init() ) // Xash3D FWGS extension: mobile interface
Con_Reportf( S_WARN "CL_LoadProgs: couldn't get mobility API\n" );
Con_Reportf( S_WARN "%s: couldn't get mobility API\n", __func__ );

CL_InitEdicts( cl.maxclients ); // initailize local player and world
CL_InitClientMove(); // initialize pm_shared
Expand Down
18 changes: 9 additions & 9 deletions engine/client/cl_gameui.c
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ static HIMAGE GAME_EXPORT pfnPIC_Load( const char *szPicName, const byte *image_

if( !COM_CheckString( szPicName ))
{
Con_Reportf( S_ERROR "CL_LoadImage: refusing to load image with empty name\n" );
Con_Reportf( S_ERROR "%s: refusing to load image with empty name\n", __func__ );
return 0;
}

Expand Down Expand Up @@ -1013,7 +1013,7 @@ pfnChangeInstance
*/
static void GAME_EXPORT pfnChangeInstance( const char *newInstance, const char *szFinalMessage )
{
Con_Reportf( S_ERROR "ChangeInstance menu call is deprecated!\n" );
Con_Reportf( S_ERROR "%s menu call is deprecated!\n", __func__ );
}

/*
Expand Down Expand Up @@ -1296,7 +1296,7 @@ qboolean UI_LoadProgs( void )
if(( GetMenuAPI = (MENUAPI)COM_GetProcAddress( gameui.hInstance, "GetMenuAPI" )) == NULL )
{
COM_FreeLibrary( gameui.hInstance );
Con_Reportf( "UI_LoadProgs: can't init menu API\n" );
Con_Reportf( "%s: can't init menu API\n", __func__ );
gameui.hInstance = NULL;
return false;
}
Expand All @@ -1312,7 +1312,7 @@ qboolean UI_LoadProgs( void )
if( !GetMenuAPI( &gameui.dllFuncs, &gpEngfuncs, gameui.globals ))
{
COM_FreeLibrary( gameui.hInstance );
Con_Reportf( "UI_LoadProgs: can't init menu API\n" );
Con_Reportf( "%s: can't init menu API\n", __func__ );
Mem_FreePool( &gameui.mempool );
gameui.hInstance = NULL;
return false;
Expand All @@ -1325,30 +1325,30 @@ qboolean UI_LoadProgs( void )
// try to initialize new extended API
if( ( GetExtAPI = (UIEXTENEDEDAPI)COM_GetProcAddress( gameui.hInstance, "GetExtAPI" ) ) )
{
Con_Reportf( "UI_LoadProgs: extended Menu API found\n" );
Con_Reportf( "%s: extended Menu API found\n", __func__ );
if( GetExtAPI( MENU_EXTENDED_API_VERSION, &gameui.dllFuncs2, &gpExtendedfuncs ) )
{
Con_Reportf( "UI_LoadProgs: extended Menu API initialized\n" );
Con_Reportf( "%s: extended Menu API initialized\n", __func__ );
gameui.use_extended_api = true;
}
}
else // otherwise, fallback to old and deprecated extensions
{
if( ( GiveTextApi = (UITEXTAPI)COM_GetProcAddress( gameui.hInstance, "GiveTextAPI" ) ) )
{
Con_Reportf( "UI_LoadProgs: extended text API found\n" );
Con_Reportf( "%s: extended text API found\n", __func__ );
Con_Reportf( S_WARN "Text API is deprecated! If you are mod developer, consider moving to Extended Menu API!\n" );
if( GiveTextApi( &gpExtendedfuncs ) ) // they are binary compatible, so we can just pass extended funcs API to menu
{
Con_Reportf( "UI_LoadProgs: extended text API initialized\n" );
Con_Reportf( "%s: extended text API initialized\n", __func__ );
gameui.use_extended_api = true;
}
}

gameui.dllFuncs2.pfnAddTouchButtonToList = (ADDTOUCHBUTTONTOLIST)COM_GetProcAddress( gameui.hInstance, "AddTouchButtonToList" );
if( gameui.dllFuncs2.pfnAddTouchButtonToList )
{
Con_Reportf( "UI_LoadProgs: AddTouchButtonToList call found\n" );
Con_Reportf( "%s: AddTouchButtonToList call found\n", __func__ );
Con_Reportf( S_WARN "AddTouchButtonToList is deprecated! If you are mod developer, consider moving to Extended Menu API!\n" );
}
}
Expand Down
Loading

0 comments on commit d56e53a

Please sign in to comment.