diff --git a/cl_dll/hl/hl_weapons.cpp b/cl_dll/hl/hl_weapons.cpp index c712b76f..5a17e858 100644 --- a/cl_dll/hl/hl_weapons.cpp +++ b/cl_dll/hl/hl_weapons.cpp @@ -688,11 +688,9 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm int buttonsChanged; CBasePlayerWeapon *pWeapon = NULL; CBasePlayerWeapon *pCurrent; - weapon_data_t nulldata, *pfrom, *pto; + weapon_data_t nulldata = {0}, *pfrom, *pto; static int lasthealth; - memset( &nulldata, 0, sizeof(nulldata) ); - HUD_InitClientWeapons(); // Get current clock diff --git a/cl_dll/hud_servers.cpp b/cl_dll/hud_servers.cpp index 3cdab827..67973c75 100644 --- a/cl_dll/hud_servers.cpp +++ b/cl_dll/hud_servers.cpp @@ -914,8 +914,7 @@ void CHudServers::RequestBroadcastList( int clearpending ) m_nDone = 0; m_dStarted = m_fElapsed; - netadr_t adr; - memset( &adr, 0, sizeof(adr) ); + netadr_t adr = {0}; if( clearpending ) { diff --git a/cl_dll/statusbar.cpp b/cl_dll/statusbar.cpp index e730f05e..98b317c5 100644 --- a/cl_dll/statusbar.cpp +++ b/cl_dll/statusbar.cpp @@ -73,8 +73,7 @@ void CHudStatusBar::Reset( void ) void CHudStatusBar::ParseStatusString( int line_num ) { // localise string first - char szBuffer[MAX_STATUSTEXT_LENGTH]; - memset( szBuffer, 0, sizeof szBuffer ); + char szBuffer[MAX_STATUSTEXT_LENGTH] = {0}; gHUD.m_TextMessage.LocaliseTextString( m_szStatusText[line_num], szBuffer, MAX_STATUSTEXT_LENGTH ); // parse m_szStatusText & m_iStatusValues into m_szStatusBar diff --git a/dlls/client.cpp b/dlls/client.cpp index 908769db..21e5d810 100644 --- a/dlls/client.cpp +++ b/dlls/client.cpp @@ -1489,8 +1489,6 @@ int GetWeaponData( struct edict_s *player, struct weapon_data_s *info ) CBasePlayer *pl = (CBasePlayer *)CBasePlayer::Instance( pev ); CBasePlayerWeapon *gun; - ItemInfo II; - memset( info, 0, 32 * sizeof(weapon_data_t) ); if( !pl ) @@ -1509,8 +1507,8 @@ int GetWeaponData( struct edict_s *player, struct weapon_data_s *info ) gun = (CBasePlayerWeapon *)pPlayerItem->GetWeaponPtr(); if( gun && gun->UseDecrement() ) { + ItemInfo II = {0}; // Get The ID. - memset( &II, 0, sizeof(II) ); gun->GetItemInfo( &II ); if( II.iId >= 0 && II.iId < 32 ) @@ -1610,8 +1608,7 @@ void UpdateClientData( const struct edict_s *ent, int sendweapons, struct client gun = (CBasePlayerWeapon *)pl->m_pActiveItem->GetWeaponPtr(); if( gun && gun->UseDecrement() ) { - ItemInfo II; - memset( &II, 0, sizeof(II) ); + ItemInfo II = {0}; gun->GetItemInfo( &II ); cd->m_iId = II.iId; diff --git a/dlls/multiplay_gamerules.cpp b/dlls/multiplay_gamerules.cpp index 43a24077..929c2bf6 100644 --- a/dlls/multiplay_gamerules.cpp +++ b/dlls/multiplay_gamerules.cpp @@ -1319,7 +1319,6 @@ Parses mapcycle.txt file into mapcycle_t structure */ int ReloadMapCycleFile( char *filename, mapcycle_t *cycle ) { - char szBuffer[MAX_RULE_BUFFER]; char szMap[32]; int length; char *pFileList; @@ -1332,8 +1331,8 @@ int ReloadMapCycleFile( char *filename, mapcycle_t *cycle ) // the first map name in the file becomes the default while( 1 ) { + char szBuffer[MAX_RULE_BUFFER] = {0}; hasbuffer = 0; - memset( szBuffer, 0, MAX_RULE_BUFFER ); pFileList = COM_Parse( pFileList ); if( strlen( com_token ) <= 0 ) diff --git a/dlls/player.cpp b/dlls/player.cpp index 708096b2..2f097072 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -660,12 +660,11 @@ void CBasePlayer::PackDeadPlayerItems( void ) int iWeaponRules; int iAmmoRules; int i; - CBasePlayerWeapon *rgpPackWeapons[20];// 20 hardcoded for now. How to determine exactly how many weapons we have? + CBasePlayerWeapon *rgpPackWeapons[20] = {0};// 20 hardcoded for now. How to determine exactly how many weapons we have? int iPackAmmo[MAX_AMMO_SLOTS + 1]; int iPW = 0;// index into packweapons array int iPA = 0;// index into packammo array - memset( rgpPackWeapons, NULL, sizeof(rgpPackWeapons) ); memset( iPackAmmo, -1, sizeof(iPackAmmo) ); // get the game rules @@ -1624,11 +1623,10 @@ void CBasePlayer::InitStatusBar() void CBasePlayer::UpdateStatusBar() { - int newSBarState[SBAR_END]; + int newSBarState[SBAR_END] = {0}; char sbuf0[SBAR_STRING_SIZE]; char sbuf1[ SBAR_STRING_SIZE ]; - memset( newSBarState, 0, sizeof(newSBarState) ); strcpy( sbuf0, m_SbarString0 ); strcpy( sbuf1, m_SbarString1 ); diff --git a/dlls/sound.cpp b/dlls/sound.cpp index 7ca01410..5f0d3da3 100644 --- a/dlls/sound.cpp +++ b/dlls/sound.cpp @@ -1261,8 +1261,6 @@ void SENTENCEG_Init() gcallsentences = 0; memset( rgsentenceg, 0, CSENTENCEG_MAX * sizeof(SENTENCEG) ); - memset( buffer, 0, 512 ); - memset( szgroup, 0, 64 ); isentencegs = -1; int filePos = 0, fileSize; @@ -1270,6 +1268,7 @@ void SENTENCEG_Init() if( !pMemFile ) return; + memset( buffer, 0, 512 ); // for each line in the file... while( memfgets( pMemFile, fileSize, filePos, buffer, 511 ) != NULL ) { @@ -1322,6 +1321,7 @@ void SENTENCEG_Init() buffer[j + 1] = 0; + memset( szgroup, 0, 64 ); // if new name doesn't match previous group name, // make a new group. if( strcmp( szgroup, &( buffer[i] ) ) ) @@ -1527,12 +1527,12 @@ void TEXTURETYPE_Init() memset( grgchTextureType, 0, CTEXTURESMAX ); gcTextures = 0; - memset( buffer, 0, 512 ); pMemFile = g_engfuncs.pfnLoadFileForMe( "sound/materials.txt", &fileSize ); if( !pMemFile ) return; + memset( buffer, 0, 512 ); // for each line in the file... while( memfgets( pMemFile, fileSize, filePos, buffer, 511 ) != NULL && ( gcTextures < CTEXTURESMAX) ) { diff --git a/dlls/stats.cpp b/dlls/stats.cpp index cdb42d82..038e1667 100644 --- a/dlls/stats.cpp +++ b/dlls/stats.cpp @@ -99,9 +99,8 @@ void UpdateStats( CBasePlayer *pPlayer ) CBasePlayerItem *p = pPlayer->m_rgpPlayerItems[i]; while( p ) { - ItemInfo II; + ItemInfo II = {0}; - memset( &II, 0, sizeof(II) ); p->GetItemInfo( &II ); int index = pPlayer->GetAmmoIndex( II.pszAmmo1 ); diff --git a/dlls/teamplay_gamerules.cpp b/dlls/teamplay_gamerules.cpp index 6c9d72af..614bd7bb 100644 --- a/dlls/teamplay_gamerules.cpp +++ b/dlls/teamplay_gamerules.cpp @@ -518,11 +518,9 @@ const char *CHalfLifeTeamplay::TeamWithFewestPlayers( void ) { int i; int minPlayers = MAX_TEAMS; - int teamCount[MAX_TEAMS]; + int teamCount[MAX_TEAMS] = {0}; char *pTeamName = NULL; - memset( teamCount, 0, MAX_TEAMS * sizeof(int) ); - // loop through all clients, count number of players on each team for( i = 1; i <= gpGlobals->maxClients; i++ ) { diff --git a/dlls/weapons.cpp b/dlls/weapons.cpp index b1ba1385..3e2ef386 100644 --- a/dlls/weapons.cpp +++ b/dlls/weapons.cpp @@ -263,9 +263,8 @@ void UTIL_PrecacheOtherWeapon( const char *szClassname ) if( pEntity ) { - ItemInfo II; + ItemInfo II = {0}; pEntity->Precache(); - memset( &II, 0, sizeof II ); if( ( (CBasePlayerItem*)pEntity )->GetItemInfo( &II ) ) { CBasePlayerItem::ItemInfoArray[II.iId] = II; @@ -279,8 +278,6 @@ void UTIL_PrecacheOtherWeapon( const char *szClassname ) { AddAmmoNameToAmmoRegistry( II.pszAmmo2 ); } - - memset( &II, 0, sizeof II ); } } diff --git a/pm_shared/pm_shared.c b/pm_shared/pm_shared.c index 2ac023a2..92377197 100644 --- a/pm_shared/pm_shared.c +++ b/pm_shared/pm_shared.c @@ -192,7 +192,7 @@ void PM_InitTextureTypes() char buffer[512]; int i, j; byte *pMemFile; - int fileSize, filePos = 0; + int fileSize, filePos; static qboolean bTextureTypeInit = false; if( bTextureTypeInit ) @@ -202,13 +202,13 @@ void PM_InitTextureTypes() memset( grgchTextureType, 0, CTEXTURESMAX ); gcTextures = 0; - memset( buffer, 0, 512 ); fileSize = pmove->COM_FileSize( "sound/materials.txt" ); pMemFile = pmove->COM_LoadFile( "sound/materials.txt", 5, NULL ); if( !pMemFile ) return; + memset( buffer, 0, 512 ); filePos = 0; // for each line in the file... while( pmove->memfgets( pMemFile, fileSize, &filePos, buffer, 511 ) != NULL && (gcTextures < CTEXTURESMAX ) )