Browse Source

Rework initialization.

wantedhl
Night Owl 9 years ago
parent
commit
7c17f6e042
  1. 4
      cl_dll/hl/hl_weapons.cpp
  2. 3
      cl_dll/hud_servers.cpp
  3. 3
      cl_dll/statusbar.cpp
  4. 7
      dlls/client.cpp
  5. 3
      dlls/multiplay_gamerules.cpp
  6. 6
      dlls/player.cpp
  7. 6
      dlls/sound.cpp
  8. 3
      dlls/stats.cpp
  9. 4
      dlls/teamplay_gamerules.cpp
  10. 5
      dlls/weapons.cpp
  11. 4
      pm_shared/pm_shared.c

4
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; int buttonsChanged;
CBasePlayerWeapon *pWeapon = NULL; CBasePlayerWeapon *pWeapon = NULL;
CBasePlayerWeapon *pCurrent; CBasePlayerWeapon *pCurrent;
weapon_data_t nulldata, *pfrom, *pto; weapon_data_t nulldata = {0}, *pfrom, *pto;
static int lasthealth; static int lasthealth;
memset( &nulldata, 0, sizeof(nulldata) );
HUD_InitClientWeapons(); HUD_InitClientWeapons();
// Get current clock // Get current clock

3
cl_dll/hud_servers.cpp

@ -914,8 +914,7 @@ void CHudServers::RequestBroadcastList( int clearpending )
m_nDone = 0; m_nDone = 0;
m_dStarted = m_fElapsed; m_dStarted = m_fElapsed;
netadr_t adr; netadr_t adr = {0};
memset( &adr, 0, sizeof(adr) );
if( clearpending ) if( clearpending )
{ {

3
cl_dll/statusbar.cpp

@ -73,8 +73,7 @@ void CHudStatusBar::Reset( void )
void CHudStatusBar::ParseStatusString( int line_num ) void CHudStatusBar::ParseStatusString( int line_num )
{ {
// localise string first // localise string first
char szBuffer[MAX_STATUSTEXT_LENGTH]; char szBuffer[MAX_STATUSTEXT_LENGTH] = {0};
memset( szBuffer, 0, sizeof szBuffer );
gHUD.m_TextMessage.LocaliseTextString( m_szStatusText[line_num], szBuffer, MAX_STATUSTEXT_LENGTH ); gHUD.m_TextMessage.LocaliseTextString( m_szStatusText[line_num], szBuffer, MAX_STATUSTEXT_LENGTH );
// parse m_szStatusText & m_iStatusValues into m_szStatusBar // parse m_szStatusText & m_iStatusValues into m_szStatusBar

7
dlls/client.cpp

@ -1489,8 +1489,6 @@ int GetWeaponData( struct edict_s *player, struct weapon_data_s *info )
CBasePlayer *pl = (CBasePlayer *)CBasePlayer::Instance( pev ); CBasePlayer *pl = (CBasePlayer *)CBasePlayer::Instance( pev );
CBasePlayerWeapon *gun; CBasePlayerWeapon *gun;
ItemInfo II;
memset( info, 0, 32 * sizeof(weapon_data_t) ); memset( info, 0, 32 * sizeof(weapon_data_t) );
if( !pl ) if( !pl )
@ -1509,8 +1507,8 @@ int GetWeaponData( struct edict_s *player, struct weapon_data_s *info )
gun = (CBasePlayerWeapon *)pPlayerItem->GetWeaponPtr(); gun = (CBasePlayerWeapon *)pPlayerItem->GetWeaponPtr();
if( gun && gun->UseDecrement() ) if( gun && gun->UseDecrement() )
{ {
ItemInfo II = {0};
// Get The ID. // Get The ID.
memset( &II, 0, sizeof(II) );
gun->GetItemInfo( &II ); gun->GetItemInfo( &II );
if( II.iId >= 0 && II.iId < 32 ) 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(); gun = (CBasePlayerWeapon *)pl->m_pActiveItem->GetWeaponPtr();
if( gun && gun->UseDecrement() ) if( gun && gun->UseDecrement() )
{ {
ItemInfo II; ItemInfo II = {0};
memset( &II, 0, sizeof(II) );
gun->GetItemInfo( &II ); gun->GetItemInfo( &II );
cd->m_iId = II.iId; cd->m_iId = II.iId;

3
dlls/multiplay_gamerules.cpp

@ -1319,7 +1319,6 @@ Parses mapcycle.txt file into mapcycle_t structure
*/ */
int ReloadMapCycleFile( char *filename, mapcycle_t *cycle ) int ReloadMapCycleFile( char *filename, mapcycle_t *cycle )
{ {
char szBuffer[MAX_RULE_BUFFER];
char szMap[32]; char szMap[32];
int length; int length;
char *pFileList; char *pFileList;
@ -1332,8 +1331,8 @@ int ReloadMapCycleFile( char *filename, mapcycle_t *cycle )
// the first map name in the file becomes the default // the first map name in the file becomes the default
while( 1 ) while( 1 )
{ {
char szBuffer[MAX_RULE_BUFFER] = {0};
hasbuffer = 0; hasbuffer = 0;
memset( szBuffer, 0, MAX_RULE_BUFFER );
pFileList = COM_Parse( pFileList ); pFileList = COM_Parse( pFileList );
if( strlen( com_token ) <= 0 ) if( strlen( com_token ) <= 0 )

6
dlls/player.cpp

@ -660,12 +660,11 @@ void CBasePlayer::PackDeadPlayerItems( void )
int iWeaponRules; int iWeaponRules;
int iAmmoRules; int iAmmoRules;
int i; 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 iPackAmmo[MAX_AMMO_SLOTS + 1];
int iPW = 0;// index into packweapons array int iPW = 0;// index into packweapons array
int iPA = 0;// index into packammo array int iPA = 0;// index into packammo array
memset( rgpPackWeapons, NULL, sizeof(rgpPackWeapons) );
memset( iPackAmmo, -1, sizeof(iPackAmmo) ); memset( iPackAmmo, -1, sizeof(iPackAmmo) );
// get the game rules // get the game rules
@ -1624,11 +1623,10 @@ void CBasePlayer::InitStatusBar()
void CBasePlayer::UpdateStatusBar() void CBasePlayer::UpdateStatusBar()
{ {
int newSBarState[SBAR_END]; int newSBarState[SBAR_END] = {0};
char sbuf0[SBAR_STRING_SIZE]; char sbuf0[SBAR_STRING_SIZE];
char sbuf1[ SBAR_STRING_SIZE ]; char sbuf1[ SBAR_STRING_SIZE ];
memset( newSBarState, 0, sizeof(newSBarState) );
strcpy( sbuf0, m_SbarString0 ); strcpy( sbuf0, m_SbarString0 );
strcpy( sbuf1, m_SbarString1 ); strcpy( sbuf1, m_SbarString1 );

6
dlls/sound.cpp

@ -1261,8 +1261,6 @@ void SENTENCEG_Init()
gcallsentences = 0; gcallsentences = 0;
memset( rgsentenceg, 0, CSENTENCEG_MAX * sizeof(SENTENCEG) ); memset( rgsentenceg, 0, CSENTENCEG_MAX * sizeof(SENTENCEG) );
memset( buffer, 0, 512 );
memset( szgroup, 0, 64 );
isentencegs = -1; isentencegs = -1;
int filePos = 0, fileSize; int filePos = 0, fileSize;
@ -1270,6 +1268,7 @@ void SENTENCEG_Init()
if( !pMemFile ) if( !pMemFile )
return; return;
memset( buffer, 0, 512 );
// for each line in the file... // for each line in the file...
while( memfgets( pMemFile, fileSize, filePos, buffer, 511 ) != NULL ) while( memfgets( pMemFile, fileSize, filePos, buffer, 511 ) != NULL )
{ {
@ -1322,6 +1321,7 @@ void SENTENCEG_Init()
buffer[j + 1] = 0; buffer[j + 1] = 0;
memset( szgroup, 0, 64 );
// if new name doesn't match previous group name, // if new name doesn't match previous group name,
// make a new group. // make a new group.
if( strcmp( szgroup, &( buffer[i] ) ) ) if( strcmp( szgroup, &( buffer[i] ) ) )
@ -1527,12 +1527,12 @@ void TEXTURETYPE_Init()
memset( grgchTextureType, 0, CTEXTURESMAX ); memset( grgchTextureType, 0, CTEXTURESMAX );
gcTextures = 0; gcTextures = 0;
memset( buffer, 0, 512 );
pMemFile = g_engfuncs.pfnLoadFileForMe( "sound/materials.txt", &fileSize ); pMemFile = g_engfuncs.pfnLoadFileForMe( "sound/materials.txt", &fileSize );
if( !pMemFile ) if( !pMemFile )
return; return;
memset( buffer, 0, 512 );
// for each line in the file... // for each line in the file...
while( memfgets( pMemFile, fileSize, filePos, buffer, 511 ) != NULL && ( gcTextures < CTEXTURESMAX) ) while( memfgets( pMemFile, fileSize, filePos, buffer, 511 ) != NULL && ( gcTextures < CTEXTURESMAX) )
{ {

3
dlls/stats.cpp

@ -99,9 +99,8 @@ void UpdateStats( CBasePlayer *pPlayer )
CBasePlayerItem *p = pPlayer->m_rgpPlayerItems[i]; CBasePlayerItem *p = pPlayer->m_rgpPlayerItems[i];
while( p ) while( p )
{ {
ItemInfo II; ItemInfo II = {0};
memset( &II, 0, sizeof(II) );
p->GetItemInfo( &II ); p->GetItemInfo( &II );
int index = pPlayer->GetAmmoIndex( II.pszAmmo1 ); int index = pPlayer->GetAmmoIndex( II.pszAmmo1 );

4
dlls/teamplay_gamerules.cpp

@ -518,11 +518,9 @@ const char *CHalfLifeTeamplay::TeamWithFewestPlayers( void )
{ {
int i; int i;
int minPlayers = MAX_TEAMS; int minPlayers = MAX_TEAMS;
int teamCount[MAX_TEAMS]; int teamCount[MAX_TEAMS] = {0};
char *pTeamName = NULL; char *pTeamName = NULL;
memset( teamCount, 0, MAX_TEAMS * sizeof(int) );
// loop through all clients, count number of players on each team // loop through all clients, count number of players on each team
for( i = 1; i <= gpGlobals->maxClients; i++ ) for( i = 1; i <= gpGlobals->maxClients; i++ )
{ {

5
dlls/weapons.cpp

@ -263,9 +263,8 @@ void UTIL_PrecacheOtherWeapon( const char *szClassname )
if( pEntity ) if( pEntity )
{ {
ItemInfo II; ItemInfo II = {0};
pEntity->Precache(); pEntity->Precache();
memset( &II, 0, sizeof II );
if( ( (CBasePlayerItem*)pEntity )->GetItemInfo( &II ) ) if( ( (CBasePlayerItem*)pEntity )->GetItemInfo( &II ) )
{ {
CBasePlayerItem::ItemInfoArray[II.iId] = II; CBasePlayerItem::ItemInfoArray[II.iId] = II;
@ -279,8 +278,6 @@ void UTIL_PrecacheOtherWeapon( const char *szClassname )
{ {
AddAmmoNameToAmmoRegistry( II.pszAmmo2 ); AddAmmoNameToAmmoRegistry( II.pszAmmo2 );
} }
memset( &II, 0, sizeof II );
} }
} }

4
pm_shared/pm_shared.c

@ -192,7 +192,7 @@ void PM_InitTextureTypes()
char buffer[512]; char buffer[512];
int i, j; int i, j;
byte *pMemFile; byte *pMemFile;
int fileSize, filePos = 0; int fileSize, filePos;
static qboolean bTextureTypeInit = false; static qboolean bTextureTypeInit = false;
if( bTextureTypeInit ) if( bTextureTypeInit )
@ -202,13 +202,13 @@ void PM_InitTextureTypes()
memset( grgchTextureType, 0, CTEXTURESMAX ); memset( grgchTextureType, 0, CTEXTURESMAX );
gcTextures = 0; gcTextures = 0;
memset( buffer, 0, 512 );
fileSize = pmove->COM_FileSize( "sound/materials.txt" ); fileSize = pmove->COM_FileSize( "sound/materials.txt" );
pMemFile = pmove->COM_LoadFile( "sound/materials.txt", 5, NULL ); pMemFile = pmove->COM_LoadFile( "sound/materials.txt", 5, NULL );
if( !pMemFile ) if( !pMemFile )
return; return;
memset( buffer, 0, 512 );
filePos = 0; filePos = 0;
// for each line in the file... // for each line in the file...
while( pmove->memfgets( pMemFile, fileSize, &filePos, buffer, 511 ) != NULL && (gcTextures < CTEXTURESMAX ) ) while( pmove->memfgets( pMemFile, fileSize, &filePos, buffer, 511 ) != NULL && (gcTextures < CTEXTURESMAX ) )

Loading…
Cancel
Save