Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 34 additions & 10 deletions src/game/server/doors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,21 @@

#define CLOSE_AREAPORTAL_THINK_CONTEXT "CloseAreaportalThink"

#ifdef HL1_DLL
//-----------------------------------------------------------------------------
// Purpose: Button sound table. Used by CBaseDoor in HL1Port
// to get 'touched' door lock/unlock sounds
// Input : sound - index of sound to look up.
// Output : Returns a pointer to the corresponding sound file.
//-----------------------------------------------------------------------------
string_t MakeButtonSound( int sound )
{
char tmp[1024];
Q_snprintf( tmp, sizeof(tmp), "Buttons.snd%d", sound );
return AllocPooledString(tmp);
}
#endif

BEGIN_DATADESC( CBaseDoor )

DEFINE_KEYFIELD( m_vecMoveDir, FIELD_VECTOR, "movedir" ),
Expand Down Expand Up @@ -537,6 +552,25 @@ void CBaseDoor::SetToggleState( int state )
//-----------------------------------------------------------------------------
void CBaseDoor::Precache( void )
{
#ifdef HL1_DLL
if( m_ls.sLockedSound != NULL_STRING && strlen((char*)STRING(m_ls.sLockedSound)) < 4 )
{
// Too short to be ANYTHING ".wav", so it must be an old button index.
// Call appropriate button soundscript to respect the designer's original
// selection, so we don't get unresponsive doors.
m_ls.sLockedSound = MakeButtonSound( atoi(STRING(m_ls.sLockedSound)) );
PrecacheScriptSound(STRING(m_ls.sLockedSound));
}
if( m_ls.sUnlockedSound != NULL_STRING && strlen((char*)STRING(m_ls.sUnlockedSound)) < 4 )
{
// Too short to be ANYTHING ".wav", so it must be an old button index.
// Call appropriate button soundscript to respect the designer's original
// selection, so we don't get unresponsive doors.
m_ls.sUnlockedSound = MakeButtonSound( atoi(STRING(m_ls.sUnlockedSound)) );
PrecacheScriptSound(STRING(m_ls.sUnlockedSound));
}
#endif//HL1_DLL

//Fill in a default value if necessary
if ( IsRotatingDoor() )
{
Expand All @@ -555,16 +589,6 @@ void CBaseDoor::Precache( void )
UTIL_ValidateSoundName( m_ls.sUnlockedSound,"DoorSound.Null" );
}

#ifdef HL1_DLL
if( m_ls.sLockedSound != NULL_STRING && strlen((char*)STRING(m_ls.sLockedSound)) < 4 )
{
// Too short to be ANYTHING ".wav", so it must be an old index into a long-lost
// array of sound choices. slam it to a known "deny" sound. We lose the designer's
// original selection, but we don't get unresponsive doors.
m_ls.sLockedSound = AllocPooledString("buttons/button2.wav");
}
#endif//HL1_DLL

//Precache them all
PrecacheScriptSound( (char *) STRING(m_NoiseMoving) );
PrecacheScriptSound( (char *) STRING(m_NoiseArrived) );
Expand Down