[TF2] Fix Engineer melee swing storage/double swing exploit #1463
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.
Fixes ValveSoftware/Source-1-Games#4039
CBaseCombatWeapon::ItemPostFrame()is responsible for calling bothSecondaryAttack()andPrimaryAttack(), in that order, depending on the player's input. Engineer's building pickup ability (CTFPlayer::DoClassSpecialSkill()) is called from within the active weapon'sSecondaryAttack(), but if it activates (and switches totf_weapon_builder, callingHolster()on the previous weapon in the process), it doesn't do anything to block a subsequent primary attack, so if both attack inputs are pressed simultaneously,ItemPostFrame()ends up callingPrimaryAttack()immediately afterwards too. This results in the previous weapon attacking after it has supposedly been switched away from and holstered.PrimaryAttack()then schedules the melee hit by settingm_flSmackTime.Holster()would normally unsetm_flSmackTimeto prevent this attack from being stored between weapon switches, but since this is being done afterHolster()was already called, it stays stored, and activates as soon as the weapon is deployed again.Fixed by blocking primary attacks on the same frame as a building pickup by setting
m_flNextPrimaryAttack.