From 0b990c826d355e8ce394813f125ba53380d8db65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franti=C5=A1ek=20Boh=C3=A1=C4=8Dek?= Date: Thu, 20 Jan 2022 21:05:16 +0100 Subject: [PATCH] fix(localbinding): represent walk function correctly to prevent bug of not walking --- .../Objects/CharacterBinding.cs | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/Local/NosSmooth.LocalBinding/Objects/CharacterBinding.cs b/Local/NosSmooth.LocalBinding/Objects/CharacterBinding.cs index b7b9cee943d201ee47d3958f6cfdfb3e15a7cd90..152afc53486d4b9f24c0e75174c142928353e1e0 100644 --- a/Local/NosSmooth.LocalBinding/Objects/CharacterBinding.cs +++ b/Local/NosSmooth.LocalBinding/Objects/CharacterBinding.cs @@ -20,11 +20,11 @@ public class CharacterBinding { [Function ( - new[] { FunctionAttribute.Register.eax, FunctionAttribute.Register.edx }, + new[] { FunctionAttribute.Register.eax, FunctionAttribute.Register.edx, FunctionAttribute.Register.ecx }, FunctionAttribute.Register.eax, FunctionAttribute.StackCleanup.Callee )] - private delegate void WalkDelegate(IntPtr characterObject, int position, int unknown = 1); + private delegate bool WalkDelegate(IntPtr characterObject, int position, short unknown0 = 0, int unknown1 = 1); /// /// Create the network binding with finding the network object and functions. @@ -119,19 +119,27 @@ public class CharacterBinding /// The x coordinate. /// The y coordinate. /// A result that may or may not have succeeded. - public Result Walk(ushort x, ushort y) + public Result Walk(ushort x, ushort y) { int param = (y << 16) | x; - _originalWalk(GetCharacterAddress(), param); - return Result.FromSuccess(); + try + { + return _originalWalk(GetCharacterAddress(), param); + } + catch (Exception e) + { + return e; + } } - private void WalkDetour(IntPtr characterObject, int position, int unknown) + private bool WalkDetour(IntPtr characterObject, int position, short unknown0, int unknown1) { var result = WalkCall?.Invoke((ushort)(position & 0xFFFF), (ushort)((position >> 16) & 0xFFFF)); if (result ?? true) { - _originalWalk(characterObject, position, unknown); + return _originalWalk(characterObject, position, unknown0, unknown1); } + + return false; } } \ No newline at end of file