From 189eed53b4885a7037c4f002e7a47c02dcc1ab74 Mon Sep 17 00:00:00 2001 From: Alexander <84857900+4z0t@users.noreply.github.com> Date: Sun, 31 Mar 2024 11:16:38 +0300 Subject: [PATCH] Fix weak tables not being garbage collected (#73) --- README.md | 2 ++ hooks/weakgcmarkerFix.cpp | 41 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 hooks/weakgcmarkerFix.cpp diff --git a/README.md b/README.md index c979bce0..3dd26988 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,8 @@ These don't matter except for other assembly patches - hooks/aiinitattack.cpp ## Bugs +- Fix [problem described here](https://www.lua.org/bugs.html#5.0.2-5) + - hooks/weakgcmarkerFix.cpp - Fix CUIWorldMesh:GetInterpolatedAlignedBox return table to properly store `ymax` and `zMax` - hooks/FixGetInterpolatedAlignedBox.cpp - Make `TestCommandCaps` test commands caps instead of toggle caps diff --git a/hooks/weakgcmarkerFix.cpp b/hooks/weakgcmarkerFix.cpp new file mode 100644 index 00000000..2b977ec0 --- /dev/null +++ b/hooks/weakgcmarkerFix.cpp @@ -0,0 +1,41 @@ +#include "../define.h" + +asm( + "; arg_0 = 4;" + "; limit = 8;" + ";.section h0; .set h0,0x00915A00 " + "; push ebp " + "; mov ebp, [esp+4+arg_0]" + "; push esi " + "; mov esi, eax " + "; mov eax, [esi]" + "; push edi " + "; xor edi, edi " + "; cmp eax, ebx " + "; jz short loc_915A3B " + ";loc_915A11:" + "; mov cl, [eax+5]" + "; movzx edx, cl " + "; and edx, -7 " //the fixing line + "; cmp edx, [esp+0x0C+limit]" + "; jle short loc_915A27 " + "; and cl, 0x0FE " + "; mov [eax+5], cl " + "; mov esi, eax " + "; jmp short loc_915A35 " + ";loc_915A27:" + "; mov ecx, [eax]" + "; mov [esi], ecx " + "; mov ecx, ebp " + "; add edi, 1 " + "; call 0x915950 " + ";loc_915A35:" + "; mov eax, [esi]" + "; cmp eax, ebx " + "; jnz short loc_915A11 " + ";loc_915A3B:" + "; mov eax, edi " + "; pop edi " + "; pop esi " + "; pop ebp " + "; ret "); \ No newline at end of file