mirror of https://github.com/FWGS/hlsdk-xash3d
A little optimizations.
This commit is contained in:
parent
b22ea2889f
commit
7c66c3aa9c
|
@ -802,7 +802,7 @@ int CHudAmmo::Draw( float flTime )
|
|||
int iCrossX;
|
||||
int iCrossY;
|
||||
int iCrossLength;
|
||||
char *chCrossHair = "+"; // Heh
|
||||
const char *chCrossHair = "+"; // Heh
|
||||
|
||||
//if( !( gHUD.m_iWeaponBits & ( 1 << ( WEAPON_SUIT ) ) ) )
|
||||
// return 1;
|
||||
|
@ -845,7 +845,7 @@ int CHudAmmo::Draw( float flTime )
|
|||
y = ScreenHeight - gHUD.m_iFontHeight - gHUD.m_iFontHeight / 2;
|
||||
|
||||
/******************* DRAW CROSSHAIR *********************/
|
||||
iCrossLength = gHUD.m_scrinfo.charWidths[*chCrossHair];
|
||||
iCrossLength = gHUD.m_scrinfo.charWidths[(unsigned char)*chCrossHair];
|
||||
iCrossY = ScreenHeight / 2 - gHUD.m_scrinfo.iCharHeight / 2;
|
||||
iCrossX = ScreenWidth / 2 - iCrossLength / 2;
|
||||
|
||||
|
|
|
@ -40,9 +40,9 @@
|
|||
gHUD.y.UserCmd_##x( ); \
|
||||
}
|
||||
|
||||
inline float CVAR_GET_FLOAT( const char *x ) { return gEngfuncs.pfnGetCvarFloat( (char*)x ); }
|
||||
inline char* CVAR_GET_STRING( const char *x ) { return gEngfuncs.pfnGetCvarString( (char*)x ); }
|
||||
inline struct cvar_s *CVAR_CREATE( const char *cv, const char *val, const int flags ) { return gEngfuncs.pfnRegisterVariable( (char*)cv, (char*)val, flags ); }
|
||||
inline float CVAR_GET_FLOAT( const char *x ) { return gEngfuncs.pfnGetCvarFloat( x ); }
|
||||
inline char* CVAR_GET_STRING( const char *x ) { return gEngfuncs.pfnGetCvarString( x ); }
|
||||
inline struct cvar_s *CVAR_CREATE( const char *cv, const char *val, const int flags ) { return gEngfuncs.pfnRegisterVariable( cv, val, flags ); }
|
||||
|
||||
#define SPR_Load ( *gEngfuncs.pfnSPR_Load )
|
||||
#define SPR_Set ( *gEngfuncs.pfnSPR_Set )
|
||||
|
@ -108,16 +108,16 @@ inline int TextMessageDrawChar( int x, int y, int number, int r, int g, int b )
|
|||
inline int DrawConsoleString( int x, int y, const char *string )
|
||||
{
|
||||
if( hud_textmode->value == 1 )
|
||||
return gHUD.DrawHudString( x, y, 9999, (char*)string, 255 * g_hud_text_color[0], 255 * g_hud_text_color[1], 255 * g_hud_text_color[2] );
|
||||
return gEngfuncs.pfnDrawConsoleString( x, y, (char*) string );
|
||||
return gHUD.DrawHudString( x, y, 9999, string, 255 * g_hud_text_color[0], 255 * g_hud_text_color[1], 255 * g_hud_text_color[2] );
|
||||
return gEngfuncs.pfnDrawConsoleString( x, y, string );
|
||||
}
|
||||
|
||||
inline void GetConsoleStringSize( const char *string, int *width, int *height )
|
||||
{
|
||||
if( hud_textmode->value == 1 )
|
||||
*height = 13, *width = gHUD.DrawHudStringLen( (char*)string );
|
||||
*height = 13, *width = gHUD.DrawHudStringLen( string );
|
||||
else
|
||||
gEngfuncs.pfnDrawConsoleStringLen( (char*)string, width, height );
|
||||
gEngfuncs.pfnDrawConsoleStringLen( string, width, height );
|
||||
}
|
||||
|
||||
int DrawUtfString( int xpos, int ypos, int iMaxX, const char *szIt, int r, int g, int b );
|
||||
|
@ -126,7 +126,7 @@ inline int ConsoleStringLen( const char *string )
|
|||
{
|
||||
int _width = 0, _height = 0;
|
||||
if( hud_textmode->value == 1 )
|
||||
return gHUD.DrawHudStringLen( (char*)string );
|
||||
return gHUD.DrawHudStringLen( string );
|
||||
GetConsoleStringSize( string, &_width, &_height );
|
||||
return _width;
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -317,8 +317,8 @@ void CBasePlayerItem::AttachToPlayer ( CBasePlayer *pPlayer ) { }
|
|||
int CBasePlayerWeapon::AddDuplicate( CBasePlayerItem *pOriginal ) { return 0; }
|
||||
int CBasePlayerWeapon::AddToPlayer( CBasePlayer *pPlayer ) { return FALSE; }
|
||||
int CBasePlayerWeapon::UpdateClientData( CBasePlayer *pPlayer ) { return 0; }
|
||||
BOOL CBasePlayerWeapon :: AddPrimaryAmmo( int iCount, char *szName, int iMaxClip, int iMaxCarry ) { return TRUE; }
|
||||
BOOL CBasePlayerWeapon :: AddSecondaryAmmo( int iCount, char *szName, int iMax ) { return TRUE; }
|
||||
BOOL CBasePlayerWeapon :: AddPrimaryAmmo( int iCount, const char *szName, int iMaxClip, int iMaxCarry ) { return TRUE; }
|
||||
BOOL CBasePlayerWeapon :: AddSecondaryAmmo( int iCount, const char *szName, int iMax ) { return TRUE; }
|
||||
BOOL CBasePlayerWeapon :: IsUseable( void ) { return TRUE; }
|
||||
int CBasePlayerWeapon::PrimaryAmmoIndex( void ) { return -1; }
|
||||
int CBasePlayerWeapon::SecondaryAmmoIndex( void ) { return -1; }
|
||||
|
|
|
@ -83,21 +83,21 @@ we set up the m_pPlayer field.
|
|||
*/
|
||||
void HUD_PrepEntity( CBaseEntity *pEntity, CBasePlayer *pWeaponOwner )
|
||||
{
|
||||
memset( &ev[ num_ents ], 0, sizeof( entvars_t ) );
|
||||
pEntity->pev = &ev[ num_ents++ ];
|
||||
memset( &ev[num_ents], 0, sizeof(entvars_t) );
|
||||
pEntity->pev = &ev[num_ents++];
|
||||
|
||||
pEntity->Precache();
|
||||
pEntity->Spawn();
|
||||
|
||||
if ( pWeaponOwner )
|
||||
if( pWeaponOwner )
|
||||
{
|
||||
ItemInfo info;
|
||||
CBasePlayerWeapon *pWeapon = (CBasePlayerWeapon *)pEntity;
|
||||
pWeapon->m_pPlayer = pWeaponOwner;
|
||||
|
||||
((CBasePlayerWeapon *)pEntity)->m_pPlayer = pWeaponOwner;
|
||||
|
||||
((CBasePlayerWeapon *)pEntity)->GetItemInfo( &info );
|
||||
pWeapon->GetItemInfo( &info );
|
||||
|
||||
g_pWpns[ info.iId ] = (CBasePlayerWeapon *)pEntity;
|
||||
g_pWpns[info.iId] = pWeapon;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -121,7 +121,7 @@ CQuakeNail *CQuakeNail::CreateNail( Vector vecOrigin, Vector vecAngles, CBaseEnt
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void CBasePlayer :: Precache( void )
|
||||
void CBasePlayer::Precache( void )
|
||||
{
|
||||
m_usShotgunSingle = PRECACHE_EVENT( 1, "events/shotgun1.sc" );
|
||||
m_usShotgunDouble = PRECACHE_EVENT( 1, "events/shotgun2.sc" );
|
||||
|
@ -141,7 +141,7 @@ CBaseEntity :: Killed
|
|||
If weapons code "kills" an entity, just set its effects to EF_NODRAW
|
||||
=====================
|
||||
*/
|
||||
void CBaseEntity :: Killed( entvars_t *pevAttacker, int iGib )
|
||||
void CBaseEntity::Killed( entvars_t *pevAttacker, int iGib )
|
||||
{
|
||||
pev->effects |= EF_NODRAW;
|
||||
}
|
||||
|
@ -151,7 +151,7 @@ void CBaseEntity :: Killed( entvars_t *pevAttacker, int iGib )
|
|||
CBasePlayerWeapon :: DefaultReload
|
||||
=====================
|
||||
*/
|
||||
BOOL CBasePlayerWeapon :: DefaultReload( int iClipSize, int iAnim, float fDelay )
|
||||
BOOL CBasePlayerWeapon::DefaultReload( int iClipSize, int iAnim, float fDelay )
|
||||
{
|
||||
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + fDelay;
|
||||
|
||||
|
@ -444,7 +444,7 @@ void CBasePlayer::Spawn( void )
|
|||
BOOL CQuakeGun::Deploy( )
|
||||
{
|
||||
gEngfuncs.CL_LoadModel( "models/v_axe.mdl", &m_pPlayer->pev->viewmodel );
|
||||
strcpy( m_pPlayer->m_szAnimExtention, "onehanded" );
|
||||
m_pPlayer->m_pszAnimExtention = "onehanded";
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -168,7 +168,7 @@ struct efx_api_s
|
|||
TEMPENTITY *(*R_DefaultSprite)( float *pos, int spriteIndex, float framerate );
|
||||
TEMPENTITY *(*R_TempSprite)( float *pos, float *dir, float scale, int modelIndex, int rendermode, int renderfx, float a, float life, int flags );
|
||||
int (*Draw_DecalIndex)( int id );
|
||||
int (*Draw_DecalIndexFromName)( char *name );
|
||||
int (*Draw_DecalIndexFromName)( const char *name );
|
||||
void (*R_DecalShoot)( int textureIndex, int entity, int modelIndex, float *position, int flags );
|
||||
void (*R_AttachTentToPlayer)( int client, int modelIndex, float zoffset, float life );
|
||||
void (*R_KillAttachedTents)( int client );
|
||||
|
|
|
@ -142,18 +142,6 @@ void AgResetMap()
|
|||
while ((pEntity = UTIL_FindEntityByClassname( pEntity, "weaponbox" )) != NULL)
|
||||
UTIL_Remove(pEntity);
|
||||
|
||||
pEntity = NULL;
|
||||
while ((pEntity = UTIL_FindEntityByClassname( pEntity, "monster_satchel" )) != NULL)
|
||||
UTIL_Remove(pEntity);
|
||||
|
||||
pEntity = NULL;
|
||||
while ((pEntity = UTIL_FindEntityByClassname( pEntity, "monster_tripmine" )) != NULL)
|
||||
UTIL_Remove(pEntity);
|
||||
|
||||
pEntity = NULL;
|
||||
while ((pEntity = UTIL_FindEntityByClassname( pEntity, "monster_snark" )) != NULL)
|
||||
UTIL_Remove(pEntity);
|
||||
|
||||
pEntity = NULL;
|
||||
while ((pEntity = UTIL_FindEntityByClassname( pEntity, "beam" )) != NULL)
|
||||
UTIL_Remove(pEntity);
|
||||
|
|
|
@ -132,7 +132,7 @@ BOOL CQuakeGun::Deploy( )
|
|||
{
|
||||
m_pPlayer->pev->viewmodel = MAKE_STRING("models/v_crowbar.mdl");
|
||||
m_pPlayer->pev->weaponmodel = MAKE_STRING("models/p_9mmhandgun.mdl");
|
||||
strcpy( m_pPlayer->m_szAnimExtention, "onehanded" );
|
||||
m_pPlayer->m_pszAnimExtention = "onehanded";
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
g_flLightTime = 0.0;
|
||||
|
|
|
@ -832,9 +832,9 @@ void CItemAmmo::Spawn( void )
|
|||
void CItemAmmo::Precache( void )
|
||||
{
|
||||
if (pev->spawnflags & BIG_AMMOBOX)
|
||||
PRECACHE_MODEL( (char*)STRING(m_isLargeBox) );
|
||||
PRECACHE_MODEL( STRING(m_isLargeBox) );
|
||||
else
|
||||
PRECACHE_MODEL( (char*)STRING(m_isSmallBox) );
|
||||
PRECACHE_MODEL( STRING(m_isSmallBox) );
|
||||
}
|
||||
|
||||
BOOL CItemAmmo::MyTouch( CBasePlayer *pPlayer )
|
||||
|
|
|
@ -218,7 +218,7 @@ void CBasePlayer::W_SetCurrentAmmo( int sendanim /* = 1 */ )
|
|||
pev->viewmodel = iszViewModel;
|
||||
|
||||
pev->weaponmodel = iszWeaponModel;
|
||||
strcpy( m_szAnimExtention, szAnimExt );
|
||||
m_pszAnimExtention = szAnimExt;
|
||||
|
||||
#else
|
||||
{
|
||||
|
|
|
@ -823,7 +823,7 @@ void CBaseDoor::Blocked( CBaseEntity *pOther )
|
|||
if( m_fNextSoundPlay <= gpGlobals->time )
|
||||
{
|
||||
m_fNextSoundPlay = gpGlobals->time + 0.3;
|
||||
STOP_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseMoving ) );
|
||||
STOP_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noiseMoving ) );
|
||||
}
|
||||
|
||||
// Block all door pieces with the same targetname here.
|
||||
|
|
|
@ -87,7 +87,7 @@ CHalfLifeMultiplay::CHalfLifeMultiplay()
|
|||
#endif
|
||||
int length;
|
||||
|
||||
char *pFileList = (char*)LOAD_FILE_FOR_ME( "motd.txt", &length );
|
||||
const char *pFileList = (const char*)LOAD_FILE_FOR_ME( "motd.txt", &length );
|
||||
|
||||
if( pFileList )
|
||||
g_bHaveMOTD = true;
|
||||
|
|
|
@ -725,7 +725,7 @@ void CBasePlayer::SetAnimation( PLAYER_ANIM playerAnim )
|
|||
strcpy( szAnim, "crouch_shoot_" );
|
||||
else
|
||||
strcpy( szAnim, "ref_shoot_" );
|
||||
strcat( szAnim, m_szAnimExtention );
|
||||
strcat( szAnim, m_pszAnimExtention );
|
||||
animDesired = LookupSequence( szAnim );
|
||||
if( animDesired == -1 )
|
||||
animDesired = 0;
|
||||
|
@ -752,7 +752,7 @@ void CBasePlayer::SetAnimation( PLAYER_ANIM playerAnim )
|
|||
strcpy( szAnim, "crouch_aim_" );
|
||||
else
|
||||
strcpy( szAnim, "ref_aim_" );
|
||||
strcat( szAnim, m_szAnimExtention );
|
||||
strcat( szAnim, m_pszAnimExtention );
|
||||
animDesired = LookupSequence( szAnim );
|
||||
if( animDesired == -1 )
|
||||
animDesired = 0;
|
||||
|
|
|
@ -251,7 +251,7 @@ public:
|
|||
int Classify ( void );
|
||||
void SetAnimation( PLAYER_ANIM playerAnim );
|
||||
void SetWeaponAnimType( const char *szExtention );
|
||||
char m_szAnimExtention[32];
|
||||
const char *m_pszAnimExtention;
|
||||
|
||||
// custom player functions
|
||||
virtual void ImpulseCommands( void );
|
||||
|
|
|
@ -794,7 +794,7 @@ void CBasePlayerWeapon::SendWeaponAnim( int iAnim, int skiplocal )
|
|||
MESSAGE_END();
|
||||
}
|
||||
|
||||
BOOL CBasePlayerWeapon::AddPrimaryAmmo( int iCount, char *szName, int iMaxClip, int iMaxCarry )
|
||||
BOOL CBasePlayerWeapon::AddPrimaryAmmo( int iCount, const char *szName, int iMaxClip, int iMaxCarry )
|
||||
{
|
||||
int iIdAmmo;
|
||||
|
||||
|
@ -831,7 +831,7 @@ BOOL CBasePlayerWeapon::AddPrimaryAmmo( int iCount, char *szName, int iMaxClip,
|
|||
return iIdAmmo > 0 ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
BOOL CBasePlayerWeapon::AddSecondaryAmmo( int iCount, char *szName, int iMax )
|
||||
BOOL CBasePlayerWeapon::AddSecondaryAmmo( int iCount, const char *szName, int iMax )
|
||||
{
|
||||
int iIdAmmo;
|
||||
|
||||
|
@ -906,7 +906,7 @@ BOOL CBasePlayerWeapon::DefaultDeploy( const char *szViewModel, const char *szWe
|
|||
|
||||
m_pPlayer->pev->viewmodel = MAKE_STRING( szViewModel );
|
||||
m_pPlayer->pev->weaponmodel = MAKE_STRING( szWeaponModel );
|
||||
strcpy( m_pPlayer->m_szAnimExtention, szAnimExt );
|
||||
m_pPlayer->m_pszAnimExtention = szAnimExt;
|
||||
SendWeaponAnim( iAnim, skiplocal );
|
||||
|
||||
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5;
|
||||
|
@ -1056,13 +1056,13 @@ int CBasePlayerWeapon::ExtractAmmo( CBasePlayerWeapon *pWeapon )
|
|||
{
|
||||
// blindly call with m_iDefaultAmmo. It's either going to be a value or zero. If it is zero,
|
||||
// we only get the ammo in the weapon's clip, which is what we want.
|
||||
iReturn = pWeapon->AddPrimaryAmmo( m_iDefaultAmmo, (char *)pszAmmo1(), iMaxClip(), iMaxAmmo1() );
|
||||
iReturn = pWeapon->AddPrimaryAmmo( m_iDefaultAmmo, pszAmmo1(), iMaxClip(), iMaxAmmo1() );
|
||||
m_iDefaultAmmo = 0;
|
||||
}
|
||||
|
||||
if( pszAmmo2() != NULL )
|
||||
{
|
||||
iReturn = pWeapon->AddSecondaryAmmo( 0, (char *)pszAmmo2(), iMaxAmmo2() );
|
||||
iReturn = pWeapon->AddSecondaryAmmo( 0, pszAmmo2(), iMaxAmmo2() );
|
||||
}
|
||||
|
||||
return iReturn;
|
||||
|
@ -1084,7 +1084,7 @@ int CBasePlayerWeapon::ExtractClipAmmo( CBasePlayerWeapon *pWeapon )
|
|||
iAmmo = m_iClip;
|
||||
}
|
||||
|
||||
return pWeapon->m_pPlayer->GiveAmmo( iAmmo, (char *)pszAmmo1(), iMaxAmmo1() ); // , &m_iPrimaryAmmoType
|
||||
return pWeapon->m_pPlayer->GiveAmmo( iAmmo, pszAmmo1(), iMaxAmmo1() ); // , &m_iPrimaryAmmoType
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
|
|
|
@ -294,8 +294,8 @@ public:
|
|||
virtual int AddWeapon( void ) { ExtractAmmo( this ); return TRUE; }; // Return TRUE if you want to add yourself to the player
|
||||
|
||||
// generic "shared" ammo handlers
|
||||
BOOL AddPrimaryAmmo( int iCount, char *szName, int iMaxClip, int iMaxCarry );
|
||||
BOOL AddSecondaryAmmo( int iCount, char *szName, int iMaxCarry );
|
||||
BOOL AddPrimaryAmmo( int iCount, const char *szName, int iMaxClip, int iMaxCarry );
|
||||
BOOL AddSecondaryAmmo( int iCount, const char *szName, int iMaxCarry );
|
||||
|
||||
virtual void UpdateItemInfo( void ) {}; // updates HUD state
|
||||
|
||||
|
|
Loading…
Reference in New Issue