From 8f062a4e3b26ce471cf3dfeb776507086d2a382f Mon Sep 17 00:00:00 2001 From: Yui <50331474+SirYodaJedi@users.noreply.github.com> Date: Tue, 9 Dec 2025 14:41:29 -0500 Subject: [PATCH 1/3] HL1Port - fix (un)locked sounds for old doors A few doors weren't changed to use an explicitly defined WAV or soundscript instead of a button index for the locked/unlocked sounds. The existing fallback behavior hardcoded such doors to use "buttons/button2.wav", instead of the proper button soundscript that matches the array that GoldSrc used; this edit uses the code from buttons.cpp to properly chose the correct soundscript to restore the "designer's original selection". --- src/game/server/doors.cpp | 44 ++++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/src/game/server/doors.cpp b/src/game/server/doors.cpp index 60ac7298c60..2797f268730 100644 --- a/src/game/server/doors.cpp +++ b/src/game/server/doors.cpp @@ -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" ), @@ -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( (int)m_bLockedSound ); + PrecacheScriptSound(m_ls.sLockedSound.ToCStr()); + } + 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( (int)m_bUnlockedSound ); + PrecacheScriptSound(m_ls.sUnlockedSound.ToCStr()); + } +#endif//HL1_DLL + //Fill in a default value if necessary if ( IsRotatingDoor() ) { @@ -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) ); From ddbfc7275f04b16e52a595129419bf8e7c25f599 Mon Sep 17 00:00:00 2001 From: Yui <50331474+SirYodaJedi@users.noreply.github.com> Date: Wed, 10 Dec 2025 13:35:10 -0500 Subject: [PATCH 2/3] Fix input variable names for MakeButtonSound --- src/game/server/doors.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/game/server/doors.cpp b/src/game/server/doors.cpp index 2797f268730..8d7fa7b9978 100644 --- a/src/game/server/doors.cpp +++ b/src/game/server/doors.cpp @@ -558,7 +558,7 @@ void CBaseDoor::Precache( void ) // 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( (int)m_bLockedSound ); + m_ls.sLockedSound = MakeButtonSound( (int)m_ls.sLockedSound ); PrecacheScriptSound(m_ls.sLockedSound.ToCStr()); } if( m_ls.sUnlockedSound != NULL_STRING && strlen((char*)STRING(m_ls.sUnlockedSound)) < 4 ) @@ -566,7 +566,7 @@ void CBaseDoor::Precache( void ) // 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( (int)m_bUnlockedSound ); + m_ls.sUnlockedSound = MakeButtonSound( (int)m_ls.sUnlockedSound ); PrecacheScriptSound(m_ls.sUnlockedSound.ToCStr()); } #endif//HL1_DLL From e2d9e427f79b1d3702f8b8b07e20fe9abffdea30 Mon Sep 17 00:00:00 2001 From: Yui <50331474+SirYodaJedi@users.noreply.github.com> Date: Wed, 10 Dec 2025 13:48:05 -0500 Subject: [PATCH 3/3] Properly pipe (un)locked sound indicies to MakeButtonSound as actual integers --- src/game/server/doors.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/game/server/doors.cpp b/src/game/server/doors.cpp index 8d7fa7b9978..f9e531de445 100644 --- a/src/game/server/doors.cpp +++ b/src/game/server/doors.cpp @@ -558,16 +558,16 @@ void CBaseDoor::Precache( void ) // 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( (int)m_ls.sLockedSound ); - PrecacheScriptSound(m_ls.sLockedSound.ToCStr()); + 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( (int)m_ls.sUnlockedSound ); - PrecacheScriptSound(m_ls.sUnlockedSound.ToCStr()); + m_ls.sUnlockedSound = MakeButtonSound( atoi(STRING(m_ls.sUnlockedSound)) ); + PrecacheScriptSound(STRING(m_ls.sUnlockedSound)); } #endif//HL1_DLL