Browse Source

Use MAKE_STRING for literals. Remove duplicated code.

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

10
dlls/buttons.cpp

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

192
dlls/doors.cpp

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

160
dlls/maprules.cpp

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

119
dlls/plats.cpp

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

2
dlls/triggers.cpp

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

Loading…
Cancel
Save