Skip to content

Commit

Permalink
Use snprintf everywhere instead of _snprintf
Browse files Browse the repository at this point in the history
  • Loading branch information
SamVanheer committed Nov 18, 2021
1 parent 3be00f1 commit 91cf9de
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 20 deletions.
2 changes: 1 addition & 1 deletion cl_dll/vgui_SpectatorPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ void SpectatorPanel::ShowMenu(bool isVisible)
{
char string[ 64 ];

_snprintf( string, sizeof( string ) - 1, "%c%s", HUD_PRINTCENTER, CHudTextMessage::BufferedLocaliseTextString( "#Spec_Duck" ) );
snprintf( string, sizeof( string ) - 1, "%c%s", HUD_PRINTCENTER, CHudTextMessage::BufferedLocaliseTextString( "#Spec_Duck" ) );
string[ sizeof( string ) - 1 ] = '\0';

gHUD.m_TextMessage.MsgFunc_TextMsg( NULL, strlen( string ) + 1, string );
Expand Down
8 changes: 4 additions & 4 deletions cl_dll/vgui_TeamFortressViewport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1534,7 +1534,7 @@ void TeamFortressViewport::UpdateSpectatorPanel()
m_pSpectatorPanel->setVisible( true ); // show spectator panel, but
m_pSpectatorPanel->ShowMenu( false ); // dsiable all menus/buttons

_snprintf( tempString, sizeof( tempString ) - 1, "%c%s", HUD_PRINTCENTER, CHudTextMessage::BufferedLocaliseTextString( "#Spec_Duck" ) );
snprintf( tempString, sizeof( tempString ) - 1, "%c%s", HUD_PRINTCENTER, CHudTextMessage::BufferedLocaliseTextString( "#Spec_Duck" ) );
tempString[ sizeof( tempString ) - 1 ] = '\0';

gHUD.m_TextMessage.MsgFunc_TextMsg( NULL, strlen( tempString ) + 1, tempString );
Expand Down Expand Up @@ -1606,15 +1606,15 @@ void TeamFortressViewport::UpdateSpectatorPanel()
if ( gEngfuncs.IsSpectateOnly() )
{
// in HLTV mode show number of spectators
_snprintf( szText, 63, "%s: %d", CHudTextMessage::BufferedLocaliseTextString( "#Spectators" ), gHUD.m_Spectator.m_iSpectatorNumber );
snprintf( szText, 63, "%s: %d", CHudTextMessage::BufferedLocaliseTextString( "#Spectators" ), gHUD.m_Spectator.m_iSpectatorNumber );
}
else
{
// otherwise show map name
char szMapName[64];
COM_FileBase( gEngfuncs.pfnGetLevelName(), szMapName );

_snprintf ( szText, 63, "%s: %s",CHudTextMessage::BufferedLocaliseTextString( "#Spec_Map" ), szMapName );
snprintf( szText, 63, "%s: %s",CHudTextMessage::BufferedLocaliseTextString( "#Spec_Map" ), szMapName );
}

szText[63] = 0;
Expand All @@ -1627,7 +1627,7 @@ void TeamFortressViewport::UpdateSpectatorPanel()
if ( timer < 0 )
timer = 0;
_snprintf ( szText, 63, "%d:%02d\n", (timer / 60), (timer % 60) );
snprintf ( szText, 63, "%d:%02d\n", (timer / 60), (timer % 60) );
szText[63] = 0;
Expand Down
6 changes: 3 additions & 3 deletions cl_dll/voice_status.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ void CVoiceStatus::UpdateSpeakerStatus( int entindex, qboolean bTalking )
if ( gEngfuncs.pfnGetCvarFloat( "voice_clientdebug" ) )
{
char msg[256];
_snprintf( msg, sizeof( msg ), "CVoiceStatus::UpdateSpeakerStatus: ent %d talking = %d\n", entindex, bTalking );
snprintf( msg, sizeof( msg ), "CVoiceStatus::UpdateSpeakerStatus: ent %d talking = %d\n", entindex, bTalking );
gEngfuncs.pfnConsolePrint( msg );
}

Expand Down Expand Up @@ -455,7 +455,7 @@ void CVoiceStatus::UpdateSpeakerStatus( int entindex, qboolean bTalking )
gEngfuncs.pfnGetPlayerInfo( entindex, &info );

char paddedName[512];
_snprintf( paddedName, sizeof( paddedName ), "%s ", info.name );
snprintf( paddedName, sizeof( paddedName ), "%s ", info.name );

int color[3];
m_pHelper->GetPlayerTextColor( entindex, color );
Expand Down Expand Up @@ -516,7 +516,7 @@ void CVoiceStatus::UpdateServerState(bool bForce)
m_bServerModEnable = bCVarModEnable;

char str[256];
_snprintf(str, sizeof(str), "VModEnable %d", m_bServerModEnable);
snprintf(str, sizeof(str), "VModEnable %d", m_bServerModEnable);
ServerCmd(str);

if(gEngfuncs.pfnGetCvarFloat("voice_clientdebug"))
Expand Down
1 change: 0 additions & 1 deletion common/Platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ typedef int BOOL;
#define stricmp strcasecmp
#define _strnicmp strncasecmp
#define strnicmp strncasecmp
#define _snprintf snprintf
#define _alloca alloca

#define DLLEXPORT __attribute__ ( ( visibility( "default" ) ) )
Expand Down
2 changes: 1 addition & 1 deletion dlls/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ void ClientDisconnect( edict_t *pEntity )

char text[256] = "" ;
if ( pEntity->v.netname )
_snprintf( text, sizeof(text), "- %s has left the game\n", STRING(pEntity->v.netname) );
snprintf( text, sizeof(text), "- %s has left the game\n", STRING(pEntity->v.netname) );
text[ sizeof(text) - 1 ] = 0;
MESSAGE_BEGIN( MSG_ALL, gmsgSayText, NULL );
WRITE_BYTE( ENTINDEX(pEntity) );
Expand Down
2 changes: 1 addition & 1 deletion dlls/weapons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,7 @@ float CBasePlayerWeapon::GetNextAttackDelay( float delay )
// store it as m_flPrevPrimaryAttack.
m_flPrevPrimaryAttack = flNextAttack - UTIL_WeaponTimeBase();
// char szMsg[256];
// _snprintf( szMsg, sizeof(szMsg), "next attack time: %0.4f\n", gpGlobals->time + flNextAttack );
// snprintf( szMsg, sizeof(szMsg), "next attack time: %0.4f\n", gpGlobals->time + flNextAttack );
// OutputDebugString( szMsg );
return flNextAttack;
}
Expand Down
4 changes: 2 additions & 2 deletions game_shared/voice_banmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ bool CVoiceBanMgr::Init(char const *pGameDir)
Term();

char filename[512];
_snprintf(filename, sizeof(filename), "%s/%s", pGameDir, g_pBanMgrFilename);
snprintf(filename, sizeof(filename), "%s/%s", pGameDir, g_pBanMgrFilename);

// Load in the squelch file.
FILE *fp = fopen(filename, "rb");
Expand Down Expand Up @@ -101,7 +101,7 @@ void CVoiceBanMgr::SaveState(char const *pGameDir)
{
// Save the file out.
char filename[512];
_snprintf(filename, sizeof(filename), "%s/%s", pGameDir, g_pBanMgrFilename);
snprintf(filename, sizeof(filename), "%s/%s", pGameDir, g_pBanMgrFilename);

FILE *fp = fopen(filename, "wb");
if(fp)
Expand Down
10 changes: 5 additions & 5 deletions public/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,13 @@ CSysModule *Sys_LoadModule( const char *pModuleName )
if ( szCwd[ strlen( szCwd ) - 1 ] == '/' )
szCwd[ strlen( szCwd ) - 1 ] = 0;

_snprintf( szAbsoluteModuleName, sizeof(szAbsoluteModuleName), "%s/%s", szCwd, pModuleName );
snprintf( szAbsoluteModuleName, sizeof(szAbsoluteModuleName), "%s/%s", szCwd, pModuleName );

hDLL = dlopen( szAbsoluteModuleName, RTLD_NOW );
}
else
{
_snprintf( szAbsoluteModuleName, sizeof(szAbsoluteModuleName), "%s", pModuleName );
snprintf( szAbsoluteModuleName, sizeof(szAbsoluteModuleName), "%s", pModuleName );
hDLL = dlopen( pModuleName, RTLD_NOW );
}
#endif
Expand All @@ -174,15 +174,15 @@ CSysModule *Sys_LoadModule( const char *pModuleName )
{
char str[512];
#if defined ( _WIN32 )
_snprintf( str, sizeof(str), "%s.dll", pModuleName );
snprintf( str, sizeof(str), "%s.dll", pModuleName );
hDLL = LoadLibrary( str );
#elif defined(OSX)
printf("Error:%s\n",dlerror());
_snprintf( str, sizeof(str), "%s.dylib", szAbsoluteModuleName );
snprintf( str, sizeof(str), "%s.dylib", szAbsoluteModuleName );
hDLL = dlopen(str, RTLD_NOW);
#else
printf("Error:%s\n",dlerror());
_snprintf( str, sizeof(str), "%s.so", szAbsoluteModuleName );
snprintf( str, sizeof(str), "%s.so", szAbsoluteModuleName );
hDLL = dlopen(str, RTLD_NOW);
#endif
}
Expand Down
2 changes: 0 additions & 2 deletions public/interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
#define HMODULE void *
#define GetProcAddress dlsym

#define _snprintf snprintf

#endif

void *Sys_GetProcAddress( void *pModuleHandle, const char *pName );
Expand Down

0 comments on commit 91cf9de

Please sign in to comment.