Browse Source

A little optimizations.

half-secret
Andrey Akhmichin 5 years ago
parent
commit
c9fdcd91e8
  1. 2
      cl_dll/hud_spectator.cpp
  2. 2
      cl_dll/input.cpp
  3. 2
      dlls/animation.cpp
  4. 2
      dlls/bmodels.cpp
  5. 2
      dlls/buttons.cpp
  6. 6
      dlls/doors.cpp
  7. 15
      dlls/h_battery.cpp
  8. 15
      dlls/multiplay_gamerules.cpp
  9. 3
      dlls/plats.cpp
  10. 4
      dlls/player.cpp
  11. 5
      dlls/scripted.cpp
  12. 6
      dlls/sound.cpp
  13. 4
      dlls/teamplay_gamerules.cpp
  14. 6
      dlls/triggers.cpp
  15. 4
      dlls/util.cpp

2
cl_dll/hud_spectator.cpp

@ -842,7 +842,7 @@ bool CHudSpectator::ParseOverviewFile()
m_OverviewData.layersHeights[0] = 0.0f; m_OverviewData.layersHeights[0] = 0.0f;
strcpy( m_OverviewData.map, gEngfuncs.pfnGetLevelName() ); strcpy( m_OverviewData.map, gEngfuncs.pfnGetLevelName() );
if( strlen( m_OverviewData.map ) == 0 ) if( m_OverviewData.map[0] == '\0' )
return false; // not active yet return false; // not active yet
strcpy( levelname, m_OverviewData.map + 5 ); strcpy( levelname, m_OverviewData.map + 5 );

2
cl_dll/input.cpp

@ -169,7 +169,7 @@ int KB_ConvertString( char *in, char **ppout )
*pEnd = '\0'; *pEnd = '\0';
pBinding = NULL; pBinding = NULL;
if( strlen( binding + 1 ) > 0 ) if( binding[1] != '\0' )
{ {
// See if there is a binding for binding? // See if there is a binding for binding?
pBinding = gEngfuncs.Key_LookupBinding( binding + 1 ); pBinding = gEngfuncs.Key_LookupBinding( binding + 1 );

2
dlls/animation.cpp

@ -203,7 +203,7 @@ void SequencePrecache( void *pmodel, const char *pSequenceName )
// of it's name if it is. // of it's name if it is.
if( IsSoundEvent( pevent[i].event ) ) if( IsSoundEvent( pevent[i].event ) )
{ {
if( !strlen( pevent[i].options ) ) if( pevent[i].options[0] == '\0' )
{ {
ALERT( at_error, "Bad sound event %d in sequence %s :: %s (sound is \"%s\")\n", pevent[i].event, pstudiohdr->name, pSequenceName, pevent[i].options ); ALERT( at_error, "Bad sound event %d in sequence %s :: %s (sound is \"%s\")\n", pevent[i].event, pstudiohdr->name, pSequenceName, pevent[i].options );
} }

2
dlls/bmodels.cpp

@ -434,7 +434,7 @@ void CFuncRotating::Precache( void )
BOOL NullSound = FALSE; BOOL NullSound = FALSE;
// set up fan sounds // set up fan sounds
if( !FStringNull( pev->message ) && strlen( szSoundFile ) > 0 ) if( !FStringNull( pev->message ) && szSoundFile[0] != '\0' )
{ {
// if a path is set for a wave, use it // if a path is set for a wave, use it
} }

2
dlls/buttons.cpp

@ -694,7 +694,7 @@ CBaseButton::BUTTON_CODE CBaseButton::ButtonResponseToTouch( void )
void CBaseButton::ButtonTouch( CBaseEntity *pOther ) void CBaseButton::ButtonTouch( CBaseEntity *pOther )
{ {
// Ignore touches by anything but players // Ignore touches by anything but players
if( !FClassnameIs( pOther->pev, "player" ) ) if( !pOther->IsPlayer() )
return; return;
m_hActivator = pOther; m_hActivator = pOther;

6
dlls/doors.cpp

@ -520,10 +520,8 @@ void CBaseDoor::Precache( void )
// //
void CBaseDoor::DoorTouch( CBaseEntity *pOther ) void CBaseDoor::DoorTouch( CBaseEntity *pOther )
{ {
entvars_t *pevToucher = pOther->pev;
// Ignore touches by anything but players // Ignore touches by anything but players
if( !FClassnameIs( pevToucher, "player" ) ) if( !pOther->IsPlayer() )
return; return;
// If door has master, and it's not ready to trigger, // If door has master, and it's not ready to trigger,
@ -542,7 +540,7 @@ void CBaseDoor::DoorTouch( CBaseEntity *pOther )
m_hActivator = pOther;// remember who activated the door m_hActivator = pOther;// remember who activated the door
if( DoorActivate()) if( DoorActivate() )
SetTouch( NULL ); // Temporarily disable the touch function, until movement is finished. SetTouch( NULL ); // Temporarily disable the touch function, until movement is finished.
} }

15
dlls/h_battery.cpp

@ -106,8 +106,12 @@ void CRecharge::Precache()
void CRecharge::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) void CRecharge::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{ {
// Make sure that we have a caller
if( !pActivator )
return;
// if it's not a player, ignore // if it's not a player, ignore
if( !FClassnameIs( pActivator->pev, "player" ) ) if( !pActivator->IsPlayer() )
return; return;
// if there is no juice left, turn it off // if there is no juice left, turn it off
@ -135,16 +139,8 @@ void CRecharge::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE use
if( m_flNextCharge >= gpGlobals->time ) if( m_flNextCharge >= gpGlobals->time )
return; return;
// Make sure that we have a caller
if( !pActivator )
return;
m_hActivator = pActivator; m_hActivator = pActivator;
//only recharge the player
if( !m_hActivator->IsPlayer() )
return;
// Play the on sound or the looping charging sound // Play the on sound or the looping charging sound
if( !m_iOn ) if( !m_iOn )
{ {
@ -152,6 +148,7 @@ void CRecharge::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE use
EMIT_SOUND( ENT( pev ), CHAN_ITEM, "items/suitchargeok1.wav", 0.85, ATTN_NORM ); EMIT_SOUND( ENT( pev ), CHAN_ITEM, "items/suitchargeok1.wav", 0.85, ATTN_NORM );
m_flSoundTime = 0.56 + gpGlobals->time; m_flSoundTime = 0.56 + gpGlobals->time;
} }
if( ( m_iOn == 1 ) && ( m_flSoundTime <= gpGlobals->time ) ) if( ( m_iOn == 1 ) && ( m_flSoundTime <= gpGlobals->time ) )
{ {
m_iOn++; m_iOn++;

15
dlls/multiplay_gamerules.cpp

@ -1331,7 +1331,8 @@ int ReloadMapCycleFile( const char *filename, mapcycle_t *cycle )
hasbuffer = 0; hasbuffer = 0;
pFileList = COM_Parse( pFileList ); pFileList = COM_Parse( pFileList );
if( strlen( com_token ) <= 0 )
if( com_token[0] == '\0' )
break; break;
strcpy( szMap, com_token ); strcpy( szMap, com_token );
@ -1340,7 +1341,8 @@ int ReloadMapCycleFile( const char *filename, mapcycle_t *cycle )
if( COM_TokenWaiting( pFileList ) ) if( COM_TokenWaiting( pFileList ) )
{ {
pFileList = COM_Parse( pFileList ); pFileList = COM_Parse( pFileList );
if( strlen( com_token ) > 0 )
if( com_token[0] != '\0' )
{ {
hasbuffer = 1; hasbuffer = 1;
strcpy( szBuffer, com_token ); strcpy( szBuffer, com_token );
@ -1496,7 +1498,8 @@ void ExtractCommandString( char *s, char *szCommand )
*o = 0; *o = 0;
strcat( szCommand, pkey ); strcat( szCommand, pkey );
if( strlen( value ) > 0 )
if( value[0] != '\0' )
{ {
strcat( szCommand, " " ); strcat( szCommand, " " );
strcat( szCommand, value ); strcat( szCommand, value );
@ -1631,13 +1634,15 @@ void CHalfLifeMultiplay::ChangeLevel( void )
{ {
ALERT( at_console, "PLAYER COUNT: min %i max %i current %i\n", minplayers, maxplayers, curplayers ); ALERT( at_console, "PLAYER COUNT: min %i max %i current %i\n", minplayers, maxplayers, curplayers );
} }
if( strlen( szRules ) > 0 )
if( szRules != '\0' )
{ {
ALERT( at_console, "RULES: %s\n", szRules ); ALERT( at_console, "RULES: %s\n", szRules );
} }
CHANGE_LEVEL( szNextMap, NULL ); CHANGE_LEVEL( szNextMap, NULL );
if( strlen( szCommands ) > 0 )
if( szCommands[0] != '\0' )
{ {
SERVER_COMMAND( szCommands ); SERVER_COMMAND( szCommands );
} }

3
dlls/plats.cpp

@ -358,8 +358,7 @@ void CPlatTrigger::SpawnInsideTrigger( CFuncPlat *pPlatform )
void CPlatTrigger::Touch( CBaseEntity *pOther ) void CPlatTrigger::Touch( CBaseEntity *pOther )
{ {
// Ignore touches by non-players // Ignore touches by non-players
entvars_t *pevToucher = pOther->pev; if( !pOther->IsPlayer() )
if( !FClassnameIs( pevToucher, "player" ) )
return; return;
CFuncPlat *pPlatform = (CFuncPlat*)(CBaseEntity*)m_hPlatform; CFuncPlat *pPlatform = (CFuncPlat*)(CBaseEntity*)m_hPlatform;

4
dlls/player.cpp

@ -2762,7 +2762,7 @@ edict_t *EntSelectSpawnPoint( CBaseEntity *pPlayer )
} }
// If startspot is set, (re)spawn there. // If startspot is set, (re)spawn there.
if( FStringNull( gpGlobals->startspot ) || !strlen(STRING( gpGlobals->startspot ) ) ) if( FStringNull( gpGlobals->startspot ) || (STRING( gpGlobals->startspot ) )[0] == '\0')
{ {
pSpot = UTIL_FindEntityByClassname( NULL, "info_player_start" ); pSpot = UTIL_FindEntityByClassname( NULL, "info_player_start" );
if( !FNullEnt( pSpot ) ) if( !FNullEnt( pSpot ) )
@ -4432,7 +4432,7 @@ void CBasePlayer::DropPlayerItem( char *pszItemName )
return; return;
} }
if( !strlen( pszItemName ) ) if( pszItemName[0] == '\0' )
{ {
// if this string has no length, the client didn't type a name! // if this string has no length, the client didn't type a name!
// assume player wants to drop the active item. // assume player wants to drop the active item.

5
dlls/scripted.cpp

@ -1068,14 +1068,17 @@ BOOL CScriptedSentence::AcceptableSpeaker( CBaseMonster *pMonster )
{ {
if( pev->spawnflags & SF_SENTENCE_FOLLOWERS ) if( pev->spawnflags & SF_SENTENCE_FOLLOWERS )
{ {
if( pMonster->m_hTargetEnt == 0 || !FClassnameIs( pMonster->m_hTargetEnt->pev, "player" ) ) if( pMonster->m_hTargetEnt == 0 || !pMonster->m_hTargetEnt->IsPlayer() )
return FALSE; return FALSE;
} }
BOOL override; BOOL override;
if( pev->spawnflags & SF_SENTENCE_INTERRUPT ) if( pev->spawnflags & SF_SENTENCE_INTERRUPT )
override = TRUE; override = TRUE;
else else
override = FALSE; override = FALSE;
if( pMonster->CanPlaySentence( override ) ) if( pMonster->CanPlaySentence( override ) )
return TRUE; return TRUE;
} }

6
dlls/sound.cpp

@ -184,7 +184,7 @@ void CAmbientGeneric::Spawn( void )
const char *szSoundFile = STRING( pev->message ); const char *szSoundFile = STRING( pev->message );
if( FStringNull( pev->message ) || strlen( szSoundFile ) < 1 ) if( FStringNull( pev->message ) || szSoundFile[0] == '\0' )
{ {
ALERT( at_error, "EMPTY AMBIENT AT: %f, %f, %f\n", pev->origin.x, pev->origin.y, pev->origin.z ); ALERT( at_error, "EMPTY AMBIENT AT: %f, %f, %f\n", pev->origin.x, pev->origin.y, pev->origin.z );
pev->nextthink = gpGlobals->time + 0.1; pev->nextthink = gpGlobals->time + 0.1;
@ -218,7 +218,7 @@ void CAmbientGeneric::Precache( void )
{ {
const char *szSoundFile = STRING( pev->message ); const char *szSoundFile = STRING( pev->message );
if( !FStringNull( pev->message ) && strlen( szSoundFile ) > 1 ) if( !FStringNull( pev->message ) && szSoundFile[0] != '\0' )
{ {
if( *szSoundFile != '!' ) if( *szSoundFile != '!' )
PRECACHE_SOUND( szSoundFile ); PRECACHE_SOUND( szSoundFile );
@ -1732,7 +1732,7 @@ void CSpeaker::Spawn( void )
{ {
const char *szSoundFile = STRING( pev->message ); const char *szSoundFile = STRING( pev->message );
if( !m_preset && ( FStringNull( pev->message ) || strlen( szSoundFile ) < 1 ) ) if( !m_preset && ( FStringNull( pev->message ) || szSoundFile[0] == '\0' ) )
{ {
ALERT( at_error, "SPEAKER with no Level/Sentence! at: %f, %f, %f\n", pev->origin.x, pev->origin.y, pev->origin.z ); ALERT( at_error, "SPEAKER with no Level/Sentence! at: %f, %f, %f\n", pev->origin.x, pev->origin.y, pev->origin.z );
pev->nextthink = gpGlobals->time + 0.1; pev->nextthink = gpGlobals->time + 0.1;

4
dlls/teamplay_gamerules.cpp

@ -52,14 +52,14 @@ CHalfLifeTeamplay::CHalfLifeTeamplay()
if( teamoverride.value ) if( teamoverride.value )
{ {
const char *pTeamList = STRING( pWorld->v.team ); const char *pTeamList = STRING( pWorld->v.team );
if( pTeamList && strlen( pTeamList ) ) if( pTeamList && pTeamList[0] != '\0' )
{ {
strncpy( m_szTeamList, pTeamList, TEAMPLAY_TEAMLISTLENGTH ); strncpy( m_szTeamList, pTeamList, TEAMPLAY_TEAMLISTLENGTH );
} }
} }
} }
// Has the server set teams // Has the server set teams
if( strlen( m_szTeamList ) ) if( m_szTeamList[0] != '\0' )
m_teamLimit = TRUE; m_teamLimit = TRUE;
else else
m_teamLimit = FALSE; m_teamLimit = FALSE;

6
dlls/triggers.cpp

@ -1124,7 +1124,7 @@ void CBaseTrigger::ActivateMultiTrigger( CBaseEntity *pActivator )
if( pev->nextthink > gpGlobals->time ) if( pev->nextthink > gpGlobals->time )
return; // still waiting for reset time return; // still waiting for reset time
if( !UTIL_IsMasterTriggered( m_sMaster,pActivator ) ) if( !UTIL_IsMasterTriggered( m_sMaster, pActivator ) )
return; return;
if( FClassnameIs( pev, "trigger_secret" ) ) if( FClassnameIs( pev, "trigger_secret" ) )
@ -1191,7 +1191,7 @@ void CBaseTrigger::CounterUse( CBaseEntity *pActivator, CBaseEntity *pCaller, US
BOOL fTellActivator = BOOL fTellActivator =
( m_hActivator != 0 ) && ( m_hActivator != 0 ) &&
FClassnameIs( m_hActivator->pev, "player" ) && m_hActivator->IsPlayer() &&
!FBitSet( pev->spawnflags, SPAWNFLAG_NOMESSAGE ); !FBitSet( pev->spawnflags, SPAWNFLAG_NOMESSAGE );
if( m_cTriggersLeft != 0 ) if( m_cTriggersLeft != 0 )
{ {
@ -1499,7 +1499,7 @@ void CChangeLevel::ChangeLevelNow( CBaseEntity *pActivator )
// //
void CChangeLevel::TouchChangeLevel( CBaseEntity *pOther ) void CChangeLevel::TouchChangeLevel( CBaseEntity *pOther )
{ {
if( !FClassnameIs( pOther->pev, "player" ) ) if( !pOther->IsPlayer() )
return; return;
ChangeLevelNow( pOther ); ChangeLevelNow( pOther );

4
dlls/util.cpp

@ -2196,7 +2196,7 @@ int CRestore::ReadField( void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCou
pString++; pString++;
} }
pInputData = pString; pInputData = pString;
if( strlen( (char *)pInputData ) == 0 ) if( ( (char *)pInputData )[0] == '\0' )
*( (string_t *)pOutputData ) = 0; *( (string_t *)pOutputData ) = 0;
else else
{ {
@ -2291,7 +2291,7 @@ int CRestore::ReadField( void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCou
*( (void**)pOutputData ) = *(void **)pInputData; *( (void**)pOutputData ) = *(void **)pInputData;
break; break;
case FIELD_FUNCTION: case FIELD_FUNCTION:
if( strlen( (char *)pInputData ) == 0 ) if( ( (char *)pInputData )[0] == '\0' )
*( (void**)pOutputData ) = 0; *( (void**)pOutputData ) = 0;
else else
*( (void**)pOutputData ) = (void*)FUNCTION_FROM_NAME( (char *)pInputData ); *( (void**)pOutputData ) = (void*)FUNCTION_FROM_NAME( (char *)pInputData );

Loading…
Cancel
Save