Browse Source

Use MAKE_STRING for literals. Remove duplicated code.

halloween
Night Owl 8 years ago
parent
commit
d062757f52
  1. 40
      dlls/bmodels.cpp
  2. 10
      dlls/buttons.cpp
  3. 192
      dlls/doors.cpp
  4. 160
      dlls/maprules.cpp
  5. 119
      dlls/plats.cpp
  6. 2
      dlls/triggers.cpp

40
dlls/bmodels.cpp

@ -430,15 +430,13 @@ void CFuncRotating::Spawn() @@ -430,15 +430,13 @@ void CFuncRotating::Spawn()
void CFuncRotating::Precache( void )
{
char* szSoundFile = (char*)STRING( pev->message );
const char* szSoundFile = STRING( pev->message );
BOOL NullSound = FALSE;
// set up fan sounds
if( !FStringNull( pev->message ) && strlen( szSoundFile ) > 0 )
{
// if a path is set for a wave, use it
PRECACHE_SOUND( szSoundFile );
pev->noiseRunning = ALLOC_STRING( szSoundFile );
}
else
{
@ -446,42 +444,32 @@ void CFuncRotating::Precache( void ) @@ -446,42 +444,32 @@ void CFuncRotating::Precache( void )
switch( m_sounds )
{
case 1:
PRECACHE_SOUND( "fans/fan1.wav" );
pev->noiseRunning = ALLOC_STRING( "fans/fan1.wav" );
szSoundFile = "fans/fan1.wav";
break;
case 2:
PRECACHE_SOUND( "fans/fan2.wav" );
pev->noiseRunning = ALLOC_STRING( "fans/fan2.wav" );
szSoundFile = "fans/fan2.wav";
break;
case 3:
PRECACHE_SOUND( "fans/fan3.wav" );
pev->noiseRunning = ALLOC_STRING( "fans/fan3.wav" );
szSoundFile = "fans/fan3.wav";
break;
case 4:
PRECACHE_SOUND( "fans/fan4.wav" );
pev->noiseRunning = ALLOC_STRING( "fans/fan4.wav" );
szSoundFile = "fans/fan4.wav";
break;
case 5:
PRECACHE_SOUND( "fans/fan5.wav" );
pev->noiseRunning = ALLOC_STRING( "fans/fan5.wav" );
szSoundFile = "fans/fan5.wav";
break;
case 0:
default:
if( !FStringNull( pev->message ) && strlen( szSoundFile ) > 0 )
{
PRECACHE_SOUND( szSoundFile );
pev->noiseRunning = ALLOC_STRING( szSoundFile );
break;
}
else
{
pev->noiseRunning = ALLOC_STRING( "common/null.wav" );
break;
}
szSoundFile = "common/null.wav";
NullSound = TRUE;
break;
}
}
if( !NullSound )
PRECACHE_SOUND( szSoundFile );
pev->noiseRunning = MAKE_STRING( szSoundFile );
if( pev->avelocity != g_vecZero )
{
// if fan was spinning, and we went through transition or save/restore,

10
dlls/buttons.cpp

@ -292,14 +292,14 @@ void CBaseButton::Precache( void ) @@ -292,14 +292,14 @@ void CBaseButton::Precache( void )
{
pszSound = ButtonSound( (int)m_bLockedSound );
PRECACHE_SOUND( pszSound );
m_ls.sLockedSound = ALLOC_STRING( pszSound );
m_ls.sLockedSound = MAKE_STRING( pszSound );
}
if( m_bUnlockedSound )
{
pszSound = ButtonSound( (int)m_bUnlockedSound );
PRECACHE_SOUND( pszSound );
m_ls.sUnlockedSound = ALLOC_STRING( pszSound );
m_ls.sUnlockedSound = MAKE_STRING( pszSound );
}
// get sentence group names, for doors which are directly 'touched' to open
@ -469,7 +469,7 @@ void CBaseButton::Spawn() @@ -469,7 +469,7 @@ void CBaseButton::Spawn()
//----------------------------------------------------
pszSound = ButtonSound( m_sounds );
PRECACHE_SOUND( pszSound );
pev->noise = ALLOC_STRING( pszSound );
pev->noise = MAKE_STRING( pszSound );
Precache();
@ -876,7 +876,7 @@ void CRotButton::Spawn( void ) @@ -876,7 +876,7 @@ void CRotButton::Spawn( void )
//----------------------------------------------------
pszSound = ButtonSound( m_sounds );
PRECACHE_SOUND( pszSound );
pev->noise = ALLOC_STRING( pszSound );
pev->noise = MAKE_STRING( pszSound );
// set the axis of rotation
CBaseToggle::AxisDir( pev );
@ -1012,7 +1012,7 @@ void CMomentaryRotButton::Spawn( void ) @@ -1012,7 +1012,7 @@ void CMomentaryRotButton::Spawn( void )
const char *pszSound = ButtonSound( m_sounds );
PRECACHE_SOUND( pszSound );
pev->noise = ALLOC_STRING( pszSound );
pev->noise = MAKE_STRING( pszSound );
m_lastUsed = 0;
}

192
dlls/doors.cpp

@ -330,114 +330,104 @@ void CBaseDoor::SetToggleState( int state ) @@ -330,114 +330,104 @@ void CBaseDoor::SetToggleState( int state )
void CBaseDoor::Precache( void )
{
const char *pszSound;
BOOL NullSound = FALSE;
// set the door's "in-motion" sound
switch( m_bMoveSnd )
{
case 0:
pev->noiseMoving = ALLOC_STRING( "common/null.wav" );
break;
case 1:
PRECACHE_SOUND( "doors/doormove1.wav" );
pev->noiseMoving = ALLOC_STRING( "doors/doormove1.wav" );
pszSound = "doors/doormove1.wav";
break;
case 2:
PRECACHE_SOUND( "doors/doormove2.wav" );
pev->noiseMoving = ALLOC_STRING( "doors/doormove2.wav" );
pszSound = "doors/doormove2.wav";
break;
case 3:
PRECACHE_SOUND( "doors/doormove3.wav" );
pev->noiseMoving = ALLOC_STRING( "doors/doormove3.wav" );
pszSound = "doors/doormove3.wav";
break;
case 4:
PRECACHE_SOUND( "doors/doormove4.wav" );
pev->noiseMoving = ALLOC_STRING( "doors/doormove4.wav" );
pszSound = "doors/doormove4.wav";
break;
case 5:
PRECACHE_SOUND( "doors/doormove5.wav" );
pev->noiseMoving = ALLOC_STRING( "doors/doormove5.wav" );
pszSound = "doors/doormove5.wav";
break;
case 6:
PRECACHE_SOUND( "doors/doormove6.wav" );
pev->noiseMoving = ALLOC_STRING( "doors/doormove6.wav" );
pszSound = "doors/doormove6.wav";
break;
case 7:
PRECACHE_SOUND( "doors/doormove7.wav" );
pev->noiseMoving = ALLOC_STRING( "doors/doormove7.wav" );
pszSound = "doors/doormove7.wav";
break;
case 8:
PRECACHE_SOUND( "doors/doormove8.wav" );
pev->noiseMoving = ALLOC_STRING( "doors/doormove8.wav" );
pszSound = "doors/doormove8.wav";
break;
case 9:
PRECACHE_SOUND( "doors/doormove9.wav" );
pev->noiseMoving = ALLOC_STRING( "doors/doormove9.wav" );
pszSound = "doors/doormove9.wav";
break;
case 10:
PRECACHE_SOUND( "doors/doormove10.wav" );
pev->noiseMoving = ALLOC_STRING( "doors/doormove10.wav" );
pszSound = "doors/doormove10.wav";
break;
case 0:
default:
pev->noiseMoving = ALLOC_STRING( "common/null.wav" );
pszSound = "common/null.wav";
NullSound = TRUE;
break;
}
if( !NullSound )
PRECACHE_SOUND( pszSound );
pev->noiseMoving = MAKE_STRING( pszSound );
NullSound = FALSE;
// set the door's 'reached destination' stop sound
switch( m_bStopSnd )
{
case 0:
pev->noiseArrived = ALLOC_STRING( "common/null.wav" );
break;
case 1:
PRECACHE_SOUND( "doors/doorstop1.wav" );
pev->noiseArrived = ALLOC_STRING( "doors/doorstop1.wav" );
pszSound = "doors/doorstop1.wav";
break;
case 2:
PRECACHE_SOUND( "doors/doorstop2.wav" );
pev->noiseArrived = ALLOC_STRING( "doors/doorstop2.wav" );
pszSound = "doors/doorstop2.wav";
break;
case 3:
PRECACHE_SOUND( "doors/doorstop3.wav" );
pev->noiseArrived = ALLOC_STRING( "doors/doorstop3.wav" );
pszSound = "doors/doorstop3.wav";
break;
case 4:
PRECACHE_SOUND( "doors/doorstop4.wav" );
pev->noiseArrived = ALLOC_STRING( "doors/doorstop4.wav" );
pszSound = "doors/doorstop4.wav";
break;
case 5:
PRECACHE_SOUND( "doors/doorstop5.wav" );
pev->noiseArrived = ALLOC_STRING( "doors/doorstop5.wav" );
pszSound = "doors/doorstop5.wav";
break;
case 6:
PRECACHE_SOUND( "doors/doorstop6.wav" );
pev->noiseArrived = ALLOC_STRING( "doors/doorstop6.wav");
pszSound = "doors/doorstop6.wav"
break;
case 7:
PRECACHE_SOUND( "doors/doorstop7.wav" );
pev->noiseArrived = ALLOC_STRING( "doors/doorstop7.wav" );
pszSound = "doors/doorstop7.wav";
break;
case 8:
PRECACHE_SOUND( "doors/doorstop8.wav" );
pev->noiseArrived = ALLOC_STRING( "doors/doorstop8.wav" );
pszSound = "doors/doorstop8.wav";
break;
case 0:
default:
pev->noiseArrived = ALLOC_STRING( "common/null.wav" );
pszSound = "common/null.wav";
NullSound = TRUE;
break;
}
if( !NullSound )
PRECACHE_SOUND( pszSound );
pev->noiseArrived = MAKE_STRING( pszSound );
// get door button sounds, for doors which are directly 'touched' to open
if( m_bLockedSound )
{
pszSound = ButtonSound( (int)m_bLockedSound );
PRECACHE_SOUND( pszSound );
m_ls.sLockedSound = ALLOC_STRING( pszSound );
m_ls.sLockedSound = MAKE_STRING( pszSound );
}
if( m_bUnlockedSound )
{
pszSound = ButtonSound( (int)m_bUnlockedSound );
PRECACHE_SOUND( pszSound );
m_ls.sUnlockedSound = ALLOC_STRING( pszSound );
m_ls.sUnlockedSound = MAKE_STRING( pszSound );
}
// get sentence group names, for doors which are directly 'touched' to open
@ -445,39 +435,39 @@ void CBaseDoor::Precache( void ) @@ -445,39 +435,39 @@ void CBaseDoor::Precache( void )
{
case 1:
// access denied
m_ls.sLockedSentence = ALLOC_STRING( "NA" );
m_ls.sLockedSentence = MAKE_STRING( "NA" );
break;
case 2:
// security lockout
m_ls.sLockedSentence = ALLOC_STRING( "ND" );
m_ls.sLockedSentence = MAKE_STRING( "ND" );
break;
case 3:
// blast door
m_ls.sLockedSentence = ALLOC_STRING( "NF" );
m_ls.sLockedSentence = MAKE_STRING( "NF" );
break;
case 4:
// fire door
m_ls.sLockedSentence = ALLOC_STRING( "NFIRE" );
m_ls.sLockedSentence = MAKE_STRING( "NFIRE" );
break;
case 5:
// chemical door
m_ls.sLockedSentence = ALLOC_STRING( "NCHEM" );
m_ls.sLockedSentence = MAKE_STRING( "NCHEM" );
break;
case 6:
// radiation door
m_ls.sLockedSentence = ALLOC_STRING( "NRAD" );
m_ls.sLockedSentence = MAKE_STRING( "NRAD" );
break;
case 7:
// gen containment
m_ls.sLockedSentence = ALLOC_STRING( "NCON" );
m_ls.sLockedSentence = MAKE_STRING( "NCON" );
break;
case 8:
// maintenance door
m_ls.sLockedSentence = ALLOC_STRING( "NH" );
m_ls.sLockedSentence = MAKE_STRING( "NH" );
break;
case 9:
// broken door
m_ls.sLockedSentence = ALLOC_STRING( "NG" );
m_ls.sLockedSentence = MAKE_STRING( "NG" );
break;
default:
m_ls.sLockedSentence = 0;
@ -488,35 +478,35 @@ void CBaseDoor::Precache( void ) @@ -488,35 +478,35 @@ void CBaseDoor::Precache( void )
{
case 1:
// access granted
m_ls.sUnlockedSentence = ALLOC_STRING( "EA" );
m_ls.sUnlockedSentence = MAKE_STRING( "EA" );
break;
case 2:
// security door
m_ls.sUnlockedSentence = ALLOC_STRING( "ED" );
m_ls.sUnlockedSentence = MAKE_STRING( "ED" );
break;
case 3:
// blast door
m_ls.sUnlockedSentence = ALLOC_STRING( "EF" );
m_ls.sUnlockedSentence = MAKE_STRING( "EF" );
break;
case 4:
// fire door
m_ls.sUnlockedSentence = ALLOC_STRING( "EFIRE" );
m_ls.sUnlockedSentence = MAKE_STRING( "EFIRE" );
break;
case 5:
// chemical door
m_ls.sUnlockedSentence = ALLOC_STRING( "ECHEM" );
m_ls.sUnlockedSentence = MAKE_STRING( "ECHEM" );
break;
case 6:
// radiation door
m_ls.sUnlockedSentence = ALLOC_STRING( "ERAD" );
m_ls.sUnlockedSentence = MAKE_STRING( "ERAD" );
break;
case 7:
// gen containment
m_ls.sUnlockedSentence = ALLOC_STRING( "ECON" );
m_ls.sUnlockedSentence = MAKE_STRING( "ECON" );
break;
case 8:
// maintenance door
m_ls.sUnlockedSentence = ALLOC_STRING( "EH" );
m_ls.sUnlockedSentence = MAKE_STRING( "EH" );
break;
default:
m_ls.sUnlockedSentence = 0;
@ -985,94 +975,88 @@ void CMomentaryDoor::Spawn( void ) @@ -985,94 +975,88 @@ void CMomentaryDoor::Spawn( void )
Precache();
}
void CMomentaryDoor::Precache( void )
{
const char *pszSound;
BOOL NullSound = FALSE;
// set the door's "in-motion" sound
switch( m_bMoveSnd )
{
case 0:
pev->noiseMoving = ALLOC_STRING( "common/null.wav" );
break;
case 1:
PRECACHE_SOUND( "doors/doormove1.wav" );
pev->noiseMoving = ALLOC_STRING( "doors/doormove1.wav" );
pszSound = "doors/doormove1.wav";
break;
case 2:
PRECACHE_SOUND( "doors/doormove2.wav" );
pev->noiseMoving = ALLOC_STRING( "doors/doormove2.wav" );
pszSound = "doors/doormove2.wav";
break;
case 3:
PRECACHE_SOUND( "doors/doormove3.wav" );
pev->noiseMoving = ALLOC_STRING( "doors/doormove3.wav" );
pszSound = "doors/doormove3.wav";
break;
case 4:
PRECACHE_SOUND( "doors/doormove4.wav" );
pev->noiseMoving = ALLOC_STRING( "doors/doormove4.wav" );
pszSound = "doors/doormove4.wav";
break;
case 5:
PRECACHE_SOUND( "doors/doormove5.wav" );
pev->noiseMoving = ALLOC_STRING( "doors/doormove5.wav" );
pszSound = "doors/doormove5.wav";
break;
case 6:
PRECACHE_SOUND( "doors/doormove6.wav" );
pev->noiseMoving = ALLOC_STRING( "doors/doormove6.wav" );
pszSound = "doors/doormove6.wav";
break;
case 7:
PRECACHE_SOUND( "doors/doormove7.wav" );
pev->noiseMoving = ALLOC_STRING( "doors/doormove7.wav" );
pszSound = "doors/doormove7.wav";
break;
case 8:
PRECACHE_SOUND( "doors/doormove8.wav" );
pev->noiseMoving = ALLOC_STRING( "doors/doormove8.wav" );
pszSound = "doors/doormove8.wav";
break;
case 0:
default:
pev->noiseMoving = ALLOC_STRING( "common/null.wav" );
pszSound = "common/null.wav";
NullSound = TRUE;
break;
}
if( !NullSound )
PRECACHE_SOUND( pszSound );
pev->noiseMoving = MAKE_STRING( pszSound );
NullSound = FALSE;
// set the door's 'reached destination' stop sound
switch( m_bStopSnd )
{
case 0:
pev->noiseArrived = ALLOC_STRING( "common/null.wav" );
break;
case 1:
PRECACHE_SOUND( "doors/doorstop1.wav" );
pev->noiseArrived = ALLOC_STRING( "doors/doorstop1.wav" );
pszSound = "doors/doorstop1.wav";
break;
case 2:
PRECACHE_SOUND( "doors/doorstop2.wav" );
pev->noiseArrived = ALLOC_STRING( "doors/doorstop2.wav" );
pszSound = "doors/doorstop2.wav";
break;
case 3:
PRECACHE_SOUND( "doors/doorstop3.wav" );
pev->noiseArrived = ALLOC_STRING("doors/doorstop3.wav");
pszSound = "doors/doorstop3.wav";
break;
case 4:
PRECACHE_SOUND( "doors/doorstop4.wav" );
pev->noiseArrived = ALLOC_STRING( "doors/doorstop4.wav" );
pszSound = "doors/doorstop4.wav";
break;
case 5:
PRECACHE_SOUND( "doors/doorstop5.wav" );
pev->noiseArrived = ALLOC_STRING( "doors/doorstop5.wav" );
pszSound = "doors/doorstop5.wav";
break;
case 6:
PRECACHE_SOUND( "doors/doorstop6.wav" );
pev->noiseArrived = ALLOC_STRING( "doors/doorstop6.wav" );
pszSound = "doors/doorstop6.wav";
break;
case 7:
PRECACHE_SOUND( "doors/doorstop7.wav" );
pev->noiseArrived = ALLOC_STRING( "doors/doorstop7.wav" );
pszSound = "doors/doorstop7.wav";
break;
case 8:
PRECACHE_SOUND( "doors/doorstop8.wav" );
pev->noiseArrived = ALLOC_STRING( "doors/doorstop8.wav" );
pszSound = "doors/doorstop8.wav";
break;
case 0:
default:
pev->noiseArrived = ALLOC_STRING( "common/null.wav" );
pszSound = "common/null.wav";
NullSound = TRUE;
break;
}
if( !NullSound )
PRECACHE_SOUND( pszSound );
pev->noiseArrived = MAKE_STRING( pszSound );
}
void CMomentaryDoor::KeyValue( KeyValueData *pkvd )

160
dlls/maprules.cpp

@ -153,9 +153,9 @@ void CGameScore::Spawn( void ) @@ -153,9 +153,9 @@ void CGameScore::Spawn( void )
void CGameScore::KeyValue( KeyValueData *pkvd )
{
if (FStrEq(pkvd->szKeyName, "points"))
if( FStrEq( pkvd->szKeyName, "points" ) )
{
SetPoints( atoi(pkvd->szValue) );
SetPoints( atoi( pkvd->szValue ) );
pkvd->fHandled = TRUE;
}
else
@ -164,13 +164,13 @@ void CGameScore::KeyValue( KeyValueData *pkvd ) @@ -164,13 +164,13 @@ void CGameScore::KeyValue( KeyValueData *pkvd )
void CGameScore::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{
if ( !CanFireForActivator( pActivator ) )
if( !CanFireForActivator( pActivator ) )
return;
// Only players can use this
if ( pActivator->IsPlayer() )
if( pActivator->IsPlayer() )
{
if ( AwardToTeam() )
if( AwardToTeam() )
{
pActivator->AddPointsToTeam( Points(), AllowNegativeScore() );
}
@ -194,7 +194,7 @@ LINK_ENTITY_TO_CLASS( game_end, CGameEnd ) @@ -194,7 +194,7 @@ LINK_ENTITY_TO_CLASS( game_end, CGameEnd )
void CGameEnd::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{
if ( !CanFireForActivator( pActivator ) )
if( !CanFireForActivator( pActivator ) )
return;
g_pGameRules->EndMultiplayerGame();
@ -239,27 +239,27 @@ IMPLEMENT_SAVERESTORE( CGameText, CRulePointEntity ) @@ -239,27 +239,27 @@ IMPLEMENT_SAVERESTORE( CGameText, CRulePointEntity )
void CGameText::KeyValue( KeyValueData *pkvd )
{
if (FStrEq(pkvd->szKeyName, "channel"))
if( FStrEq( pkvd->szKeyName, "channel" ) )
{
m_textParms.channel = atoi( pkvd->szValue );
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "x"))
else if( FStrEq( pkvd->szKeyName, "x" ) )
{
m_textParms.x = atof( pkvd->szValue );
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "y"))
else if( FStrEq(pkvd->szKeyName, "y" ) )
{
m_textParms.y = atof( pkvd->szValue );
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "effect"))
else if( FStrEq( pkvd->szKeyName, "effect" ) )
{
m_textParms.effect = atoi( pkvd->szValue );
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "color"))
else if( FStrEq( pkvd->szKeyName, "color" ) )
{
int color[4];
UTIL_StringToIntArray( color, 4, pkvd->szValue );
@ -269,7 +269,7 @@ void CGameText::KeyValue( KeyValueData *pkvd ) @@ -269,7 +269,7 @@ void CGameText::KeyValue( KeyValueData *pkvd )
m_textParms.a1 = color[3];
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "color2"))
else if( FStrEq( pkvd->szKeyName, "color2" ) )
{
int color[4];
UTIL_StringToIntArray( color, 4, pkvd->szValue );
@ -279,22 +279,22 @@ void CGameText::KeyValue( KeyValueData *pkvd ) @@ -279,22 +279,22 @@ void CGameText::KeyValue( KeyValueData *pkvd )
m_textParms.a2 = color[3];
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "fadein"))
else if( FStrEq( pkvd->szKeyName, "fadein" ) )
{
m_textParms.fadeinTime = atof( pkvd->szValue );
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "fadeout"))
else if( FStrEq( pkvd->szKeyName, "fadeout" ) )
{
m_textParms.fadeoutTime = atof( pkvd->szValue );
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "holdtime"))
else if( FStrEq( pkvd->szKeyName, "holdtime" ) )
{
m_textParms.holdTime = atof( pkvd->szValue );
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "fxtime"))
else if( FStrEq(pkvd->szKeyName, "fxtime" ) )
{
m_textParms.fxTime = atof( pkvd->szValue );
pkvd->fHandled = TRUE;
@ -305,16 +305,16 @@ void CGameText::KeyValue( KeyValueData *pkvd ) @@ -305,16 +305,16 @@ void CGameText::KeyValue( KeyValueData *pkvd )
void CGameText::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{
if ( !CanFireForActivator( pActivator ) )
if( !CanFireForActivator( pActivator ) )
return;
if ( MessageToAll() )
if( MessageToAll() )
{
UTIL_HudMessageAll( m_textParms, MessageGet() );
}
else
{
if ( pActivator->IsNetClient() )
if( pActivator->IsNetClient() )
{
UTIL_HudMessage( pActivator, m_textParms, MessageGet() );
}
@ -356,12 +356,12 @@ LINK_ENTITY_TO_CLASS( game_team_master, CGameTeamMaster ) @@ -356,12 +356,12 @@ LINK_ENTITY_TO_CLASS( game_team_master, CGameTeamMaster )
void CGameTeamMaster::KeyValue( KeyValueData *pkvd )
{
if (FStrEq(pkvd->szKeyName, "teamindex"))
if( FStrEq( pkvd->szKeyName, "teamindex" ) )
{
m_teamIndex = atoi( pkvd->szValue );
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "triggerstate"))
else if( FStrEq( pkvd->szKeyName, "triggerstate" ) )
{
int type = atoi( pkvd->szValue );
switch( type )
@ -384,12 +384,12 @@ void CGameTeamMaster::KeyValue( KeyValueData *pkvd ) @@ -384,12 +384,12 @@ void CGameTeamMaster::KeyValue( KeyValueData *pkvd )
void CGameTeamMaster::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{
if ( !CanFireForActivator( pActivator ) )
if( !CanFireForActivator( pActivator ) )
return;
if ( useType == USE_SET )
if( useType == USE_SET )
{
if ( value < 0 )
if( value < 0 )
{
m_teamIndex = -1;
}
@ -400,10 +400,10 @@ void CGameTeamMaster::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TY @@ -400,10 +400,10 @@ void CGameTeamMaster::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TY
return;
}
if ( TeamMatch( pActivator ) )
if( TeamMatch( pActivator ) )
{
SUB_UseTargets( pActivator, triggerType, value );
if ( RemoveOnFire() )
if( RemoveOnFire() )
UTIL_Remove( this );
}
}
@ -415,7 +415,7 @@ BOOL CGameTeamMaster::IsTriggered( CBaseEntity *pActivator ) @@ -415,7 +415,7 @@ BOOL CGameTeamMaster::IsTriggered( CBaseEntity *pActivator )
const char *CGameTeamMaster::TeamID( void )
{
if ( m_teamIndex < 0 ) // Currently set to "no team"
if( m_teamIndex < 0 ) // Currently set to "no team"
return "";
return g_pGameRules->GetIndexedTeamName( m_teamIndex ); // UNDONE: Fill this in with the team from the "teamlist"
@ -423,10 +423,10 @@ const char *CGameTeamMaster::TeamID( void ) @@ -423,10 +423,10 @@ const char *CGameTeamMaster::TeamID( void )
BOOL CGameTeamMaster::TeamMatch( CBaseEntity *pActivator )
{
if ( m_teamIndex < 0 && AnyTeam() )
if( m_teamIndex < 0 && AnyTeam() )
return TRUE;
if ( !pActivator )
if( !pActivator )
return FALSE;
return UTIL_TeamsMatch( pActivator->TeamID(), TeamID() );
@ -443,7 +443,7 @@ BOOL CGameTeamMaster::TeamMatch( CBaseEntity *pActivator ) @@ -443,7 +443,7 @@ BOOL CGameTeamMaster::TeamMatch( CBaseEntity *pActivator )
class CGameTeamSet : public CRulePointEntity
{
public:
void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
inline BOOL RemoveOnFire( void ) { return (pev->spawnflags & SF_TEAMSET_FIREONCE) ? TRUE : FALSE; }
inline BOOL ShouldClearTeam( void ) { return (pev->spawnflags & SF_TEAMSET_CLEARTEAM) ? TRUE : FALSE; }
@ -454,10 +454,10 @@ LINK_ENTITY_TO_CLASS( game_team_set, CGameTeamSet ) @@ -454,10 +454,10 @@ LINK_ENTITY_TO_CLASS( game_team_set, CGameTeamSet )
void CGameTeamSet::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{
if ( !CanFireForActivator( pActivator ) )
if( !CanFireForActivator( pActivator ) )
return;
if ( ShouldClearTeam() )
if( ShouldClearTeam() )
{
SUB_UseTargets( pActivator, USE_SET, -1 );
}
@ -466,7 +466,7 @@ void CGameTeamSet::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE @@ -466,7 +466,7 @@ void CGameTeamSet::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE
SUB_UseTargets( pActivator, USE_SET, 0 );
}
if ( RemoveOnFire() )
if( RemoveOnFire() )
{
UTIL_Remove( this );
}
@ -506,22 +506,22 @@ IMPLEMENT_SAVERESTORE( CGamePlayerZone, CRuleBrushEntity ) @@ -506,22 +506,22 @@ IMPLEMENT_SAVERESTORE( CGamePlayerZone, CRuleBrushEntity )
void CGamePlayerZone::KeyValue( KeyValueData *pkvd )
{
if (FStrEq(pkvd->szKeyName, "intarget"))
if( FStrEq(pkvd->szKeyName, "intarget" ) )
{
m_iszInTarget = ALLOC_STRING( pkvd->szValue );
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "outtarget"))
else if( FStrEq( pkvd->szKeyName, "outtarget" ) )
{
m_iszOutTarget = ALLOC_STRING( pkvd->szValue );
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "incount"))
else if( FStrEq( pkvd->szKeyName, "incount" ) )
{
m_iszInCount = ALLOC_STRING( pkvd->szValue );
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "outcount"))
else if( FStrEq( pkvd->szKeyName, "outcount" ) )
{
m_iszOutCount = ALLOC_STRING( pkvd->szValue );
pkvd->fHandled = TRUE;
@ -535,12 +535,12 @@ void CGamePlayerZone::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TY @@ -535,12 +535,12 @@ void CGamePlayerZone::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TY
int playersInCount = 0;
int playersOutCount = 0;
if ( !CanFireForActivator( pActivator ) )
if( !CanFireForActivator( pActivator ) )
return;
CBaseEntity *pPlayer = NULL;
for ( int i = 1; i <= gpGlobals->maxClients; i++ )
for( int i = 1; i <= gpGlobals->maxClients; i++ )
{
pPlayer = UTIL_PlayerByIndex( i );
if ( pPlayer )
@ -549,40 +549,40 @@ void CGamePlayerZone::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TY @@ -549,40 +549,40 @@ void CGamePlayerZone::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TY
int hullNumber;
hullNumber = human_hull;
if ( pPlayer->pev->flags & FL_DUCKING )
if( pPlayer->pev->flags & FL_DUCKING )
{
hullNumber = head_hull;
}
UTIL_TraceModel( pPlayer->pev->origin, pPlayer->pev->origin, hullNumber, edict(), &trace );
if ( trace.fStartSolid )
if( trace.fStartSolid )
{
playersInCount++;
if ( m_iszInTarget )
if( m_iszInTarget )
{
FireTargets( STRING(m_iszInTarget), pPlayer, pActivator, useType, value );
FireTargets( STRING( m_iszInTarget ), pPlayer, pActivator, useType, value );
}
}
else
{
playersOutCount++;
if ( m_iszOutTarget )
if( m_iszOutTarget )
{
FireTargets( STRING(m_iszOutTarget), pPlayer, pActivator, useType, value );
FireTargets( STRING( m_iszOutTarget ), pPlayer, pActivator, useType, value );
}
}
}
}
if ( m_iszInCount )
if( m_iszInCount )
{
FireTargets( STRING(m_iszInCount), pActivator, this, USE_SET, playersInCount );
FireTargets( STRING( m_iszInCount ), pActivator, this, USE_SET, playersInCount );
}
if ( m_iszOutCount )
if( m_iszOutCount )
{
FireTargets( STRING(m_iszOutCount), pActivator, this, USE_SET, playersOutCount );
FireTargets( STRING( m_iszOutCount ), pActivator, this, USE_SET, playersOutCount );
}
}
@ -605,12 +605,12 @@ LINK_ENTITY_TO_CLASS( game_player_hurt, CGamePlayerHurt ) @@ -605,12 +605,12 @@ LINK_ENTITY_TO_CLASS( game_player_hurt, CGamePlayerHurt )
void CGamePlayerHurt::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{
if ( !CanFireForActivator( pActivator ) )
if( !CanFireForActivator( pActivator ) )
return;
if ( pActivator->IsPlayer() )
if( pActivator->IsPlayer() )
{
if ( pev->dmg < 0 )
if( pev->dmg < 0 )
pActivator->TakeHealth( -pev->dmg, DMG_GENERIC );
else
pActivator->TakeDamage( pev, pev, pev->dmg, DMG_GENERIC );
@ -618,7 +618,7 @@ void CGamePlayerHurt::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TY @@ -618,7 +618,7 @@ void CGamePlayerHurt::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TY
SUB_UseTargets( pActivator, useType, value );
if ( RemoveOnFire() )
if( RemoveOnFire() )
{
UTIL_Remove( this );
}
@ -665,7 +665,7 @@ void CGameCounter::Spawn( void ) @@ -665,7 +665,7 @@ void CGameCounter::Spawn( void )
void CGameCounter::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{
if ( !CanFireForActivator( pActivator ) )
if( !CanFireForActivator( pActivator ) )
return;
switch( useType )
@ -681,16 +681,16 @@ void CGameCounter::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE @@ -681,16 +681,16 @@ void CGameCounter::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE
SetCountValue( (int)value );
break;
}
if ( HitLimit() )
if( HitLimit() )
{
SUB_UseTargets( pActivator, USE_TOGGLE, 0 );
if ( RemoveOnFire() )
if( RemoveOnFire() )
{
UTIL_Remove( this );
}
if ( ResetOnFire() )
if( ResetOnFire() )
{
ResetCount();
}
@ -716,12 +716,12 @@ LINK_ENTITY_TO_CLASS( game_counter_set, CGameCounterSet ) @@ -716,12 +716,12 @@ LINK_ENTITY_TO_CLASS( game_counter_set, CGameCounterSet )
void CGameCounterSet::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{
if ( !CanFireForActivator( pActivator ) )
if( !CanFireForActivator( pActivator ) )
return;
SUB_UseTargets( pActivator, USE_SET, pev->frags );
if ( RemoveOnFire() )
if( RemoveOnFire() )
{
UTIL_Remove( this );
}
@ -756,19 +756,19 @@ void CGamePlayerEquip::KeyValue( KeyValueData *pkvd ) @@ -756,19 +756,19 @@ void CGamePlayerEquip::KeyValue( KeyValueData *pkvd )
{
CRulePointEntity::KeyValue( pkvd );
if ( !pkvd->fHandled )
if( !pkvd->fHandled )
{
for ( int i = 0; i < MAX_EQUIP; i++ )
for( int i = 0; i < MAX_EQUIP; i++ )
{
if ( !m_weaponNames[i] )
if( !m_weaponNames[i] )
{
char tmp[128];
UTIL_StripToken( pkvd->szKeyName, tmp );
m_weaponNames[i] = ALLOC_STRING(tmp);
m_weaponCount[i] = atoi(pkvd->szValue);
m_weaponCount[i] = max(1,m_weaponCount[i]);
m_weaponNames[i] = ALLOC_STRING( tmp );
m_weaponCount[i] = atoi( pkvd->szValue );
m_weaponCount[i] = max( 1, m_weaponCount[i] );
pkvd->fHandled = TRUE;
break;
}
@ -778,10 +778,10 @@ void CGamePlayerEquip::KeyValue( KeyValueData *pkvd ) @@ -778,10 +778,10 @@ void CGamePlayerEquip::KeyValue( KeyValueData *pkvd )
void CGamePlayerEquip::Touch( CBaseEntity *pOther )
{
if ( !CanFireForActivator( pOther ) )
if( !CanFireForActivator( pOther ) )
return;
if ( UseOnly() )
if( UseOnly() )
return;
EquipPlayer( pOther );
@ -791,21 +791,21 @@ void CGamePlayerEquip::EquipPlayer( CBaseEntity *pEntity ) @@ -791,21 +791,21 @@ void CGamePlayerEquip::EquipPlayer( CBaseEntity *pEntity )
{
CBasePlayer *pPlayer = NULL;
if ( pEntity->IsPlayer() )
if( pEntity->IsPlayer() )
{
pPlayer = (CBasePlayer *)pEntity;
}
if ( !pPlayer )
if( !pPlayer )
return;
for ( int i = 0; i < MAX_EQUIP; i++ )
for( int i = 0; i < MAX_EQUIP; i++ )
{
if ( !m_weaponNames[i] )
if( !m_weaponNames[i] )
break;
for ( int j = 0; j < m_weaponCount[i]; j++ )
for( int j = 0; j < m_weaponCount[i]; j++ )
{
pPlayer->GiveNamedItem( STRING(m_weaponNames[i]) );
pPlayer->GiveNamedItem( STRING( m_weaponNames[i] ) );
}
}
}
@ -844,9 +844,9 @@ const char *CGamePlayerTeam::TargetTeamName( const char *pszTargetName ) @@ -844,9 +844,9 @@ const char *CGamePlayerTeam::TargetTeamName( const char *pszTargetName )
{
CBaseEntity *pTeamEntity = NULL;
while ((pTeamEntity = UTIL_FindEntityByTargetname( pTeamEntity, pszTargetName )) != NULL)
while( ( pTeamEntity = UTIL_FindEntityByTargetname( pTeamEntity, pszTargetName ) ) != NULL )
{
if ( FClassnameIs( pTeamEntity->pev, "game_team_master" ) )
if( FClassnameIs( pTeamEntity->pev, "game_team_master" ) )
return pTeamEntity->TeamID();
}
@ -855,10 +855,10 @@ const char *CGamePlayerTeam::TargetTeamName( const char *pszTargetName ) @@ -855,10 +855,10 @@ const char *CGamePlayerTeam::TargetTeamName( const char *pszTargetName )
void CGamePlayerTeam::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{
if ( !CanFireForActivator( pActivator ) )
if( !CanFireForActivator( pActivator ) )
return;
if ( pActivator->IsPlayer() )
if( pActivator->IsPlayer() )
{
const char *pszTargetTeam = TargetTeamName( STRING(pev->target) );
if ( pszTargetTeam )
@ -868,7 +868,7 @@ void CGamePlayerTeam::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TY @@ -868,7 +868,7 @@ void CGamePlayerTeam::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TY
}
}
if ( RemoveOnFire() )
if( RemoveOnFire() )
{
UTIL_Remove( this );
}

119
dlls/plats.cpp

@ -104,111 +104,100 @@ void CBasePlatTrain::KeyValue( KeyValueData *pkvd ) @@ -104,111 +104,100 @@ void CBasePlatTrain::KeyValue( KeyValueData *pkvd )
void CBasePlatTrain::Precache( void )
{
const char *pszSound;
BOOL NullSound = FALSE;
// set the plat's "in-motion" sound
switch( m_bMoveSnd )
{
case 0:
pev->noiseMoving = MAKE_STRING( "common/null.wav" );
break;
case 1:
PRECACHE_SOUND( "plats/bigmove1.wav" );
pev->noiseMoving = MAKE_STRING( "plats/bigmove1.wav" );
pszSound = "plats/bigmove1.wav";
break;
case 2:
PRECACHE_SOUND( "plats/bigmove2.wav" );
pev->noiseMoving = MAKE_STRING( "plats/bigmove2.wav" );
pszSound = "plats/bigmove2.wav";
break;
case 3:
PRECACHE_SOUND( "plats/elevmove1.wav" );
pev->noiseMoving = MAKE_STRING( "plats/elevmove1.wav" );
pszSound = "plats/elevmove1.wav";
break;
case 4:
PRECACHE_SOUND( "plats/elevmove2.wav" );
pev->noiseMoving = MAKE_STRING( "plats/elevmove2.wav" );
pszSound = "plats/elevmove2.wav";
break;
case 5:
PRECACHE_SOUND( "plats/elevmove3.wav" );
pev->noiseMoving = MAKE_STRING( "plats/elevmove3.wav" );
pszSound = "plats/elevmove3.wav";
break;
case 6:
PRECACHE_SOUND( "plats/freightmove1.wav" );
pev->noiseMoving = MAKE_STRING( "plats/freightmove1.wav" );
pszSound = "plats/freightmove1.wav";
break;
case 7:
PRECACHE_SOUND( "plats/freightmove2.wav" );
pev->noiseMoving = MAKE_STRING( "plats/freightmove2.wav" );
pszSound = "plats/freightmove2.wav";
break;
case 8:
PRECACHE_SOUND( "plats/heavymove1.wav" );
pev->noiseMoving = MAKE_STRING( "plats/heavymove1.wav" );
pszSound = "plats/heavymove1.wav";
break;
case 9:
PRECACHE_SOUND( "plats/rackmove1.wav" );
pev->noiseMoving = MAKE_STRING( "plats/rackmove1.wav" );
pszSound = "plats/rackmove1.wav";
break;
case 10:
PRECACHE_SOUND( "plats/railmove1.wav" );
pev->noiseMoving = MAKE_STRING( "plats/railmove1.wav" );
pszSound = "plats/railmove1.wav";
break;
case 11:
PRECACHE_SOUND( "plats/squeekmove1.wav" );
pev->noiseMoving = MAKE_STRING( "plats/squeekmove1.wav" );
pszSound = "plats/squeekmove1.wav";
break;
case 12:
PRECACHE_SOUND( "plats/talkmove1.wav" );
pev->noiseMoving = MAKE_STRING( "plats/talkmove1.wav" );
pszSound = "plats/talkmove1.wav";
break;
case 13:
PRECACHE_SOUND( "plats/talkmove2.wav" );
pev->noiseMoving = MAKE_STRING( "plats/talkmove2.wav" );
pszSound = "plats/talkmove2.wav";
break;
case 0:
default:
pev->noiseMoving = MAKE_STRING( "common/null.wav" );
pszSound = "common/null.wav";
NullSound = TRUE;
break;
}
if( !NullSound )
PRECACHE_SOUND( pszSound );
pev->noiseMoving = MAKE_STRING( pszSound );
NullSound = FALSE;
// set the plat's 'reached destination' stop sound
switch( m_bStopSnd )
{
case 0:
pev->noiseArrived = MAKE_STRING( "common/null.wav" );
break;
case 1:
PRECACHE_SOUND( "plats/bigstop1.wav" );
pev->noiseArrived = MAKE_STRING( "plats/bigstop1.wav" );
pszSound = "plats/bigstop1.wav";
break;
case 2:
PRECACHE_SOUND( "plats/bigstop2.wav" );
pev->noiseArrived = MAKE_STRING( "plats/bigstop2.wav" );
pszSound = "plats/bigstop2.wav";
break;
case 3:
PRECACHE_SOUND( "plats/freightstop1.wav" );
pev->noiseArrived = MAKE_STRING( "plats/freightstop1.wav" );
pszSound = "plats/freightstop1.wav";
break;
case 4:
PRECACHE_SOUND( "plats/heavystop2.wav" );
pev->noiseArrived = MAKE_STRING( "plats/heavystop2.wav" );
pszSound = "plats/heavystop2.wav";
break;
case 5:
PRECACHE_SOUND( "plats/rackstop1.wav" );
pev->noiseArrived = MAKE_STRING( "plats/rackstop1.wav" );
pszSound = "plats/rackstop1.wav";
break;
case 6:
PRECACHE_SOUND( "plats/railstop1.wav" );
pev->noiseArrived = MAKE_STRING( "plats/railstop1.wav" );
pszSound = "plats/railstop1.wav";
break;
case 7:
PRECACHE_SOUND( "plats/squeekstop1.wav" );
pev->noiseArrived = MAKE_STRING( "plats/squeekstop1.wav" );
pszSound = "plats/squeekstop1.wav";
break;
case 8:
PRECACHE_SOUND( "plats/talkstop1.wav" );
pev->noiseArrived = MAKE_STRING( "plats/talkstop1.wav" );
pszSound = "plats/talkstop1.wav";
break;
case 0:
default:
pev->noiseArrived = MAKE_STRING( "common/null.wav" );
pszSound = "common/null.wav";
NullSound = TRUE;
break;
}
if( !NullSound )
PRECACHE_SOUND( pszSound );
pev->noiseArrived = MAKE_STRING( pszSound );
}
//
@ -1482,6 +1471,8 @@ void CFuncTrackTrain::Spawn( void ) @@ -1482,6 +1471,8 @@ void CFuncTrackTrain::Spawn( void )
void CFuncTrackTrain::Precache( void )
{
const char *pszSound;
if( m_flVolume == 0.0 )
m_flVolume = 1.0;
@ -1489,34 +1480,36 @@ void CFuncTrackTrain::Precache( void ) @@ -1489,34 +1480,36 @@ void CFuncTrackTrain::Precache( void )
{
default:
// no sound
pev->noise = 0;
pszSound = NULL;
break;
case 1:
PRECACHE_SOUND( "plats/ttrain1.wav" );
pev->noise = MAKE_STRING("plats/ttrain1.wav" );
pszSound = "plats/ttrain1.wav";
break;
case 2:
PRECACHE_SOUND( "plats/ttrain2.wav" );
pev->noise = MAKE_STRING( "plats/ttrain2.wav" );
pszSound = "plats/ttrain2.wav";
break;
case 3:
PRECACHE_SOUND( "plats/ttrain3.wav" );
pev->noise = MAKE_STRING( "plats/ttrain3.wav" );
pszSound = "plats/ttrain3.wav";
break;
case 4:
PRECACHE_SOUND( "plats/ttrain4.wav" );
pev->noise = MAKE_STRING( "plats/ttrain4.wav" );
pszSound = "plats/ttrain4.wav";
break;
case 5:
PRECACHE_SOUND( "plats/ttrain6.wav" );
pev->noise = MAKE_STRING( "plats/ttrain6.wav" );
pszSound = "plats/ttrain6.wav";
break;
case 6:
PRECACHE_SOUND( "plats/ttrain7.wav" );
pev->noise = MAKE_STRING( "plats/ttrain7.wav" );
pszSound = "plats/ttrain7.wav";
break;
}
if( !pszSound )
{
PRECACHE_SOUND( pszSound );
pev->noise = MAKE_STRING( pszSound );
}
else
pev->noise = 0;
PRECACHE_SOUND( "plats/ttrain_brake1.wav" );
PRECACHE_SOUND( "plats/ttrain_start1.wav" );

2
dlls/triggers.cpp

@ -1689,7 +1689,7 @@ void NextLevel( void ) @@ -1689,7 +1689,7 @@ void NextLevel( void )
// go back to start if no trigger_changelevel
if( FNullEnt( pent ) )
{
gpGlobals->mapname = ALLOC_STRING( "start" );
gpGlobals->mapname = MAKE_STRING( "start" );
pChange = GetClassPtr( (CChangeLevel *)NULL );
strcpy( pChange->m_szMapName, "start" );
}

Loading…
Cancel
Save