Skip to content

Fix DropActivePlayerWeapon passing uninitialized vecDropMomentum - #1407

Open
Umbre11as wants to merge 2 commits into
roflmuffin:mainfrom
Umbre11as:fix/drop-active-weapon-vector
Open

Fix DropActivePlayerWeapon passing uninitialized vecDropMomentum#1407
Umbre11as wants to merge 2 commits into
roflmuffin:mainfrom
Umbre11as:fix/drop-active-weapon-vector

Conversation

@Umbre11as

Copy link
Copy Markdown

The vtable call for DropActivePlayerWeapon was missing the second parameter (const Vector& vecDropMomentum), so the native function read uninitialized stack for it — which could result in NaN entity velocity.

Passes an empty Vector to keep the public API stable, as suggested by @hzqst in the issue.

Tested on a live 1.0.373 server: weapon drops normally without abnormal velocity.

Closes #1214

@Umbre11as
Umbre11as requested a review from roflmuffin as a code owner August 30, 2026 03:43
Guard.IsValidEntity(activeWeapon);

VirtualFunction.CreateVoid<nint, nint>(Handle, GameData.GetOffset("CCSPlayer_ItemServices_DropActivePlayerWeapon"))(Handle, activeWeapon.Handle);
var dropMomentum = new Vector();

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should just pin a static vector zero here rather than making a new one on each instantiation

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pushed. Using Vector.Zero directly now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CCSPlayer_ItemServices_DropActivePlayerWeapon should be going with 2nd arg const Vector& vecDropMomentum

2 participants