You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Melee weapons in all Half-Life 1 games play back their swing events incorrectly in some cases.
Specifically, melee weapons work by swinging twice: the first time when the player presses the attack button, the second time if the first swing didn't hit so the weapon can still hit something 0.1 seconds later since the weapon is swinging for half a second, so something could be hit the second time. Logically this is a single swing and to players it will appear to be one.
This event playback call will be executed for both swings. The second time the engine's internal state will be invalid for this function call, which results in the event sometimes being sent to the player to whom the weapon belongs. The FEV_NOTHOST flag is supposed to prevent this from happening.
The problem is that the engine's global host_client variable is not always set to the player that owns the weapon when the playback call is given. The global is modified in several places and likely left pointing at the last player slot available which is always the local player in singleplayer, so this bug doesn't happen there. The logic that deals with the FEV_NOTHOST flag relies on the global to check which players to skip, so it gets sent anyway.
The result is that the event is executed by both the server and client version of the weapons code, which manifests itself as the swing animation and sounds starting from the beginning again.
In Steam Half-Life this bug has already been fixed by changing the code to this:
This fix has not been applied to Opposing Force's Knife and Pipe Wrench weapons. Other GoldSource engine games either use different logic that doesn't involve events or don't swing twice so they don't appear to be affected.
Melee weapons in all Half-Life 1 games play back their swing events incorrectly in some cases.
Specifically, melee weapons work by swinging twice: the first time when the player presses the attack button, the second time if the first swing didn't hit so the weapon can still hit something 0.1 seconds later since the weapon is swinging for half a second, so something could be hit the second time. Logically this is a single swing and to players it will appear to be one.
The second swing is where the problem occurs:
halflife/dlls/crowbar.cpp
Lines 196 to 198 in c7240b9
This event playback call will be executed for both swings. The second time the engine's internal state will be invalid for this function call, which results in the event sometimes being sent to the player to whom the weapon belongs. The
FEV_NOTHOST
flag is supposed to prevent this from happening.The problem is that the engine's global
host_client
variable is not always set to the player that owns the weapon when the playback call is given. The global is modified in several places and likely left pointing at the last player slot available which is always the local player in singleplayer, so this bug doesn't happen there. The logic that deals with theFEV_NOTHOST
flag relies on the global to check which players to skip, so it gets sent anyway.The result is that the event is executed by both the server and client version of the weapons code, which manifests itself as the swing animation and sounds starting from the beginning again.
In Steam Half-Life this bug has already been fixed by changing the code to this:
This is the correct behavior for this code.
This fix has not been applied to Opposing Force's Knife and Pipe Wrench weapons. Other GoldSource engine games either use different logic that doesn't involve events or don't swing twice so they don't appear to be affected.
This is not related to #3173 and #3041.
The text was updated successfully, but these errors were encountered: