ValveSoftware / halflife

Half-Life 1 engine based games
Other
3.59k stars 598 forks source link

Gauss charge sound is not always reset. #3188

Open malortie opened 2 years ago

malortie commented 2 years ago

The following code sends an event to stop the gauss charge sound on the client.

https://github.com/ValveSoftware/halflife/blob/c7240b965743a53a29491dd49320c88eecf6257b/dlls/gauss.cpp#L392-L392

There are several places where the secondary attack is interrupted and does not send this event. The sound will keep playing indefinitely unless PrimaryAttack or SecondaryAttack is called.

The event should be sent at the following places:

  1. When a static discharge occurs:

    https://github.com/ValveSoftware/halflife/blob/c7240b965743a53a29491dd49320c88eecf6257b/dlls/gauss.cpp#L280-L284

  2. When the weapon is charging and the player goes underwater:

    https://github.com/ValveSoftware/halflife/blob/c7240b965743a53a29491dd49320c88eecf6257b/dlls/gauss.cpp#L177-L182

SamVanheer commented 2 years ago

Under what conditions does the sound keep playing? I tested this with fakelag 50 (~100 ping) and the sound is stopped in both cases.

SamVanheer commented 2 years ago

Looks like this doesn't happen when there's lag. It's a race condition of sorts, but it does happen.

SamVanheer commented 2 years ago

Note that when stopping the sound because the player is underwater the event flag FEV_NOTHOST should not be used because the client will predict the frame with m_fInAttack == 0 so it won't run the sound stop logic locally, the server has to order the client to stop it.

The zap sound played when going underwater with a charging Gauss won't play if there is no lag because the empty sound plays on the same channel, and the client will run that branch instead of the zap: https://github.com/ValveSoftware/halflife/blob/c7240b965743a53a29491dd49320c88eecf6257b/dlls/gauss.cpp#L177-L186