Npc.SetPosition(...) crashes the server with a segmentation fault (SIGSEGV / exit 139), and INpcService.AddPointToPath(...) silently stores <0, 0, 0> instead of the point passed in. Both stem from the same cause: the native proxies for these NPC APIs declare their Vector3 input argument as const Vector3& (a pointer at the ABI boundary), while the source-generated managed P/Invoke marshals Vector3 by value.
Affected APIs:
Npc.SetPosition — crashes the server.
INpcService.AddPointToPath — stores <0, 0, 0>; an NPC driven with MoveByPath glides to the world origin instead of following the path.
Npc.Shoot, Npc.AimAt, Npc.AimAtPlayer, INpcService.HasPathPointInRange — same Vector3-input mismatch.
Minimal reproduction:
// spawned NPC, valid path service
npc.SetPosition(new Vector3(1260f, -2342.25f, 16f), true); // (1) crashes the server (SIGSEGV)
var path = npcService.CreatePath();
npcService.AddPointToPath(path, new Vector3(1260.875f, -2335.375f, 16.066f), 1f);
npcService.GetPathPoint(path, 0, out var stored, out _); // (2) stored == <0, 0, 0>
Observed behavior:
SetPosition → server exits with code 139 (SIGSEGV) before the next line runs.
AddPointToPath → GetPathPoint reads back <0, 0, 0>; MoveByPath drives the NPC straight to the world origin.
Expected behavior:
SetPosition moves the NPC to the requested coordinates.
AddPointToPath stores the exact point; MoveByPath follows the path.
Notes:
- Proxies already declared by-value (e.g.
Npc.MoveTo) are unaffected and always worked.
- Native-only defect: the managed assemblies are correct; the fix is in
src/sampsharp-component/proxies/api.cpp.
- Seen on Linux with
1.0.0-prerelease2.
Npc.SetPosition(...)crashes the server with a segmentation fault (SIGSEGV / exit 139), andINpcService.AddPointToPath(...)silently stores<0, 0, 0>instead of the point passed in. Both stem from the same cause: the native proxies for these NPC APIs declare theirVector3input argument asconst Vector3&(a pointer at the ABI boundary), while the source-generated managed P/Invoke marshalsVector3by value.Affected APIs:
Npc.SetPosition— crashes the server.INpcService.AddPointToPath— stores<0, 0, 0>; an NPC driven withMoveByPathglides to the world origin instead of following the path.Npc.Shoot,Npc.AimAt,Npc.AimAtPlayer,INpcService.HasPathPointInRange— sameVector3-input mismatch.Minimal reproduction:
Observed behavior:
SetPosition→ server exits with code 139 (SIGSEGV) before the next line runs.AddPointToPath→GetPathPointreads back<0, 0, 0>;MoveByPathdrives the NPC straight to the world origin.Expected behavior:
SetPositionmoves the NPC to the requested coordinates.AddPointToPathstores the exact point;MoveByPathfollows the path.Notes:
Npc.MoveTo) are unaffected and always worked.src/sampsharp-component/proxies/api.cpp.1.0.0-prerelease2.