Skip to content

Fix CPedDamageResponse& argument deduction in ComputeWillKillPed - #329

Open
Akionka wants to merge 1 commit into
DK22Pac:masterfrom
Akionka:fix-computewillkillped-callmethod-argument-types
Open

Fix CPedDamageResponse& argument deduction in ComputeWillKillPed#329
Akionka wants to merge 1 commit into
DK22Pac:masterfrom
Akionka:fix-computewillkillped-callmethod-argument-types

Conversation

@Akionka

@Akionka Akionka commented Aug 21, 2026

Copy link
Copy Markdown

Summary

Fixes an incorrect argument type deduction in CPedDamageResponseCalculator::ComputeWillKillPed.

plugin::CallMethod takes its argument pack as Args... args, so when the argument types are not specified explicitly, the reference on CPedDamageResponse& is stripped during template argument deduction.

As a result, the current code deduces CPedDamageResponse by value instead of CPedDamageResponse&, producing an incorrect function signature/ABI for the call to 0x4B3210.

Verification

The original gta_sa.exe confirms that 0x4B3210 expects the second argument as a single pointer/reference-sized stack argument.

A native call site passes three DWORD arguments:

push eax        ; bSpeak
push ebp        ; &response
push edi        ; ped
mov  ecx, esi   ; this
call 0x4B3210

Inside 0x4B3210, the second argument is loaded into EDI and then dereferenced:

mov edi, DWORD PTR [esp+0x18]
...
mov BYTE PTR [edi+0x9], al
...
fstp DWORD PTR [edi]

The function also ends with:

ret 0xC

which confirms that it expects exactly three 4-byte stack arguments.

Without explicitly specifying CPedDamageResponse&, CallMethod deduces the argument pack as approximately:

CPed*, CPedDamageResponse, bool

instead of:

CPed*, CPedDamageResponse&, bool

which results in an incompatible call ABI.

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.

1 participant