2
0
mirror of https://github.com/FWGS/hlsdk-xash3d synced 2024-11-22 01:47:45 +01:00

Rework initialization.

This commit is contained in:
Night Owl 2016-08-02 16:59:22 +05:00
parent acd54c6edf
commit 7c17f6e042
11 changed files with 16 additions and 32 deletions

View File

@ -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

View File

@ -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 )
{

View File

@ -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

View File

@ -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;

View File

@ -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 )

View File

@ -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 );

View File

@ -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) )
{

View File

@ -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 );

View File

@ -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++ )
{

View File

@ -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 );
}
}

View File

@ -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 ) )