FFXIVClientStructs icon indicating copy to clipboard operation
FFXIVClientStructs copied to clipboard

Pass Vector3 pointers to Raycast functions

Open Haselnussbomber opened this issue 1 year ago • 2 comments

This is a confusing one, because it works, even though it shouldn't. According to Pohky, C# (the caller) creates a copy of Vector3 on the stack, because struct is a value type and too big to be passed via the register itself. It passes it as a "stack pointer" instead, which happens to be exactly what the game needs - a pointer. For me, it simply should be a Vector3*, because this is what I see in the games assembly - a dereference. That it gets converted automatically and becomes a pointer is just ridiculous in my opinion, and should not be relied on, and instead the types should be fixed.

asm

Discussion in #plugin-dev where I try to understand what is happening (not very useful and basically explained above): https://discord.com/channels/581875019861328007/653504487352303619/1219332724792229900

Haselnussbomber avatar Mar 18 '24 17:03 Haselnussbomber

In the original game code, the parameters are likely passed by-reference (so the function signature is using &), so they should probably be pointers here..? I think you're actually right..

aers avatar Mar 22 '24 11:03 aers

Leaving this open then for Dawntrail.

Haselnussbomber avatar Mar 22 '24 12:03 Haselnussbomber