diff --git a/README.md b/README.md index 8da18b0b..a5a5b51c 100644 --- a/README.md +++ b/README.md @@ -122,6 +122,9 @@ These don't matter except for other assembly patches - hooks/WallSelection.cpp - Make `LOWSELECTPRIO` apply to units under construction - hooks/selectionPriority.cpp +- Allow mass extractor template snapping + - hooks/BuildTemplateSnap.cpp + - section/BuildTemplateSnap.cpp ## Lua - Change `SUBCOMMANDER` category name to `SACU_BEHAVIOR` (FAF makes this transparent) diff --git a/hooks/BuildTemplateSnap.cpp b/hooks/BuildTemplateSnap.cpp new file mode 100644 index 00000000..89bad65f --- /dev/null +++ b/hooks/BuildTemplateSnap.cpp @@ -0,0 +1,18 @@ +#define SECTION(index, address) ".section h"#index"; .set h"#index","#address";" +#include "../define.h" + +asm( + SECTION(0, 0x0086FFF0) + "NOP;" + "NOP;" + "NOP;" + "NOP;" + "NOP;" + "NOP;" + SECTION(1, 0x00870044) + "jmp "QU(HookHydroCondition)";" + "nop;" + "nop;" + "nop;" + "nop;" +); \ No newline at end of file diff --git a/section/BuildTemplateSnap.cpp b/section/BuildTemplateSnap.cpp new file mode 100644 index 00000000..ba53af75 --- /dev/null +++ b/section/BuildTemplateSnap.cpp @@ -0,0 +1,24 @@ +void HookHydroCondition() +{ + asm( + "sub eax, 1;" // check if hydro + "jnz 0x008701E1;" // not hydro, jump out + // Check if we have any templates + "mov ecx, [esp+0x260];" // build_template.finish + "sub ecx, [esp+0x25C];" // build_template.start + "mov eax, 0x2E8BA2E9;" + "imul ecx;" + "sar edx, 3;" + "mov eax, edx;" + "shr eax, 0x1F;" + "add eax, edx;" + // end + "jnz 0x008701E1;" + // snap hydro + "mov ecx, [esp+0x1E4];" // comDat.blueprint + "xor eax, eax;" + "jmp 0x0087004D;" + : + : + :); +} \ No newline at end of file