Fix aim pose desync when a weapon is given while the aim/fire button is held#4972
Open
TheCrazy17 wants to merge 1 commit into
Open
Fix aim pose desync when a weapon is given while the aim/fire button is held#4972TheCrazy17 wants to merge 1 commit into
TheCrazy17 wants to merge 1 commit into
Conversation
…is already held GTA:SA's TASK_SIMPLE_USE_GUN only starts on a fresh aim/fire button press, not while the button is continuously held. If a ped receives a weapon while already holding aim from before it had one, the local engine never starts the use-gun task and the local pose looks right. The on-foot puresync protocol has no explicit "is aiming" wire bit - every reader independently rederives it from the raw RightShoulder1/ ButtonCircle keysync bits, which were still "held" from before the weapon change. WritePlayerPuresync now clears those bits in the outgoing copy when the local ped's actual secondary attack task isn't TASK_SIMPLE_USE_GUN, keeping every downstream consumer's independently-derived aim bit consistent with what the local client is actually doing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CNetAPI::WritePlayerPuresyncnow clears the aim/fire (RightShoulder1/ButtonCircle) keysync bits in the outgoing on-foot puresync packet when the local ped's secondary attack task isn't actuallyTASK_SIMPLE_USE_GUN, instead of blindly forwarding the raw button state.Motivation
Fixes #518, an ancient bug open since 2018.
GTA:SA only starts
TASK_SIMPLE_USE_GUNon a fresh button press, not while held. If a weapon is given while aim is already held from before, the local pose looks right but the puresync protocol has no explicit "is aiming" wire bit - every reader rederives it from the raw keysync bits, which were still "held", so everyone else saw the player stuck aiming/running-aiming.Before
Test plan
Reproduced locally with two clients:
giveWeapon(player, 34, 30, true)(sniper) via a server-sidebindKeytest script while still holding aim.CPickup.cppcalls the sameCStaticFunctionDefinitions::GiveWeaponpath used by the scripted function.Checklist