From 63718d16151cd7b2e3232ddc865879a4ecba292d Mon Sep 17 00:00:00 2001 From: Alexander <84857900+4z0t@users.noreply.github.com> Date: Sat, 23 Nov 2024 22:09:02 +0300 Subject: [PATCH] Fix a desync caused by `ForceAltFootprint` (#107) --- hooks/EntityGetFootprint.cpp | 14 -------------- hooks/EntityGetFootprint.hook | 10 ++++++++++ section/EntityGetFootprint.cpp | 4 ++-- 3 files changed, 12 insertions(+), 16 deletions(-) delete mode 100644 hooks/EntityGetFootprint.cpp create mode 100644 hooks/EntityGetFootprint.hook diff --git a/hooks/EntityGetFootprint.cpp b/hooks/EntityGetFootprint.cpp deleted file mode 100644 index 0300961..0000000 --- a/hooks/EntityGetFootprint.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#define SECTION(index, address) ".section h"#index"; .set h"#index","#address";" -#include "../define.h" - -asm( -// Moho::Entity::Entity -SECTION(0, 0x00677BC9) - "mov dword ptr [esi+0x1F8], ebx;" // 0x1F9 bool forceAltFootprint - -// Moho::Entity::GetFootprint -SECTION(1, 0x006788A5) - "jmp "QU(asm__GetFootprint)";" - "nop;" - "nop;" -); \ No newline at end of file diff --git a/hooks/EntityGetFootprint.hook b/hooks/EntityGetFootprint.hook new file mode 100644 index 0000000..08350be --- /dev/null +++ b/hooks/EntityGetFootprint.hook @@ -0,0 +1,10 @@ +//Moho::SSTIEntityVariableData::SSTIEntityVariableData +0x00558823: + mov dword ptr [eax+0x0A4], ecx // 0x0A5 bool forceAltFootprint + + +// Moho::Entity::GetFootprint +0x006788A5: + jmp @asm__GetFootprint + nop + nop \ No newline at end of file diff --git a/section/EntityGetFootprint.cpp b/section/EntityGetFootprint.cpp index c0ae73c..26ab2ea 100644 --- a/section/EntityGetFootprint.cpp +++ b/section/EntityGetFootprint.cpp @@ -14,7 +14,7 @@ int ForceAltFootprint(lua_State *L) void *unit = res.object; bool flag = lua_toboolean(L, 2); - GetField(unit, 8+0x1F9) = flag; // bool forceAltFootprint + GetField(unit, 8+0x11D) = flag; // bool forceAltFootprint return 0; } @@ -32,7 +32,7 @@ void asm__GetFootprint() asm( "cmp byte ptr [ecx+0x11C], 0;" // this->sstiData.usingAltFp "jnz 0x006788AE;" - "cmp byte ptr [ecx+0x1F9], 0;" // bool forceAltFootprint + "cmp byte ptr [ecx+0x11D], 0;" // bool forceAltFootprint "jnz 0x006788AE;" "jmp 0x006788C2;" );