Skip to content

Commit

Permalink
Fix momentary_door restarting movement sound repeatedly when moving b…
Browse files Browse the repository at this point in the history
…ack to starting position

Resolves ValveSoftware/halflife#3265
  • Loading branch information
SamVanheer committed Mar 28, 2022
1 parent 88df0a2 commit 6a6336a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions dlls/doors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -936,6 +936,7 @@ class CMomentaryDoor : public CBaseToggle
static TYPEDESCRIPTION m_SaveData[];

void EXPORT DoorMoveDone();
void EXPORT StopMoveSound();

byte m_bMoveSnd; // sound a door makes while moving
};
Expand Down Expand Up @@ -1083,6 +1084,15 @@ void CMomentaryDoor::Use(CBaseEntity* pActivator, CBaseEntity* pCaller, USE_TYPE
// The door has reached needed position.
//
void CMomentaryDoor::DoorMoveDone()
{
// Stop sounds at the next think, rather than here as another
// Use call might immediately follow the end of this move
//This think function will be replaced by LinearMove if that happens.
SetThink(&CMomentaryDoor::StopMoveSound);
pev->nextthink = pev->ltime + 0.1f;
}

void CMomentaryDoor::StopMoveSound()
{
STOP_SOUND(ENT(pev), CHAN_STATIC, (char*)STRING(pev->noiseMoving));
EMIT_SOUND(ENT(pev), CHAN_STATIC, (char*)STRING(pev->noiseArrived), 1, ATTN_NORM);
Expand Down

0 comments on commit 6a6336a

Please sign in to comment.