From d86021174014fc42c2d9d76a79492705f2b52290 Mon Sep 17 00:00:00 2001 From: KionX <> Date: Sat, 23 Jul 2022 14:47:51 +0500 Subject: [PATCH] RangeRings2 + Misc --- .gitignore | 4 ++++ README.md | 6 ++++++ hooks/HRangeRings2.cpp | 18 ++++++++++++++++++ section/RangeRings2.cpp | 25 +++++++++++++++++++++++++ section/include/global.h | 6 +++++- section/include/moho.h | 6 +++--- 6 files changed, 61 insertions(+), 4 deletions(-) create mode 100644 .gitignore create mode 100644 hooks/HRangeRings2.cpp create mode 100644 section/RangeRings2.cpp diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d9956b3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +*.exe +/build +define.h +patch.ld \ No newline at end of file diff --git a/README.md b/README.md index e9edee9..8818247 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,9 @@ This are just the patch files for this game. I decided to separate them from pat - hooks/AirNoneCollisionFix.cpp - Prevents commander exploding for no reason. #3406 - hooks/NegativeIncomeFix.cpp +- Range ring performance improvement (reducing height cylinders) + - hooks/HRangeRings2.cpp + - section/RangeRings2.cpp - Range ring performance improvement (don't render each ring twice) - hooks/RangeRings.cpp - section/RangeRings.cpp @@ -45,6 +48,9 @@ This are just the patch files for this game. I decided to separate them from pat - hooks/WayPointArrive.cpp ## Additions +- Allowing customize colors for team color mode + - hooks/TeamColorMode.cpp + - section/TeamColorMode.cpp - GetSessionClients also output maximum sim speed(maxSP) - hooks/HOutputMaxSP.cpp - section/OutputMaxSP.cpp diff --git a/hooks/HRangeRings2.cpp b/hooks/HRangeRings2.cpp new file mode 100644 index 0000000..b79f3bc --- /dev/null +++ b/hooks/HRangeRings2.cpp @@ -0,0 +1,18 @@ +#include "../define.h" +asm +( + ".section h0; .set h0,0x73D4A0;" + "CALL "QU(HeightCylinders)";" + + ".section h1; .set h1,0x7EE2BC;" + ".4byte "QU(MinCHeight)";" + + ".section h2; .set h2,0x7EE33A;" + ".4byte "QU(MaxCHeight)";" + + ".section h3; .set h3,0x81C38E;" + ".4byte "QU(MinCHeight)";" + + ".section h4; .set h4,0x81C3C5;" + ".4byte "QU(MaxCHeight)";" +); \ No newline at end of file diff --git a/section/RangeRings2.cpp b/section/RangeRings2.cpp new file mode 100644 index 0000000..6347524 --- /dev/null +++ b/section/RangeRings2.cpp @@ -0,0 +1,25 @@ +#include + +float MinCHeight, MaxCHeight; + +void* _thiscall HeightCylinders(char* this_) +{ + auto Sim = reinterpret_cast(0x7433B0)(this_); + auto STIMap = *(uint32_t*)(Sim + 0x8CC); + auto MapData = *(uint32_t*)STIMap; + auto Heights = (uint16_t*)*(uint32_t*)MapData; + auto SizeX = *(int*)(MapData + 0x4); + auto SizeY = *(int*)(MapData + 0x8); + uint16_t MinH = -1, MaxH = 0; + for (auto I = 0; I < SizeX * SizeY; I++) { + if (*Heights < MinH) MinH = *Heights; + if (*Heights > MaxH) MaxH = *Heights; + Heights++; + } + MinCHeight = MinH * 0.0078125 - 5; + MaxCHeight = MaxH * 0.0078125; + this_ = (char*)*(uint32_t*)(0x10C7C28); + reinterpret_cast(0x7EDFE0)(this_ + 0x37C); + reinterpret_cast(0x81C0C0)(this_ + 0x410); + return Sim; +} \ No newline at end of file diff --git a/section/include/global.h b/section/include/global.h index 3109e85..00fb3d1 100644 --- a/section/include/global.h +++ b/section/include/global.h @@ -105,6 +105,7 @@ LuaObjectFinalize 00937CB0 LogF(char* str, args...) 00937D30 WarningF(char* str, args...) 0041C990 ConsoleLogF(char* str, args...) +00A9B4E6 FileWrite(int fileIndex, const char* str, int strlen) index 3 is log. 00938E00 Format 00938F10 Format+1 @@ -182,7 +183,8 @@ LuaObjectFinalize 0053E590 SetSimRate 0053E720 GetSimRate 0053E7E0 GetSimRateRequested -007EF9B0 RenderRing +007EF9B0 DrawRings +0081C660 DrawVision 008F3C40 D3DXEffect::GetPassCount ? 008F4080 D3DXEffect::BeginPass ? 008F4260 D3DXEffect::EndPass ? @@ -261,6 +263,8 @@ LuaObjectFinalize 007F66A0 InitWRenViewport 007EDFE0 GenerateRingCylinders 007EF5A0 RenderRings +005779C0 CreateMapData +004783D0 CreateTerrainHeights 00577890 InitSTIMap 005790E0 CreateCHeightField 0044FB90 GetTerrainHeight(float x, float z):int ecx diff --git a/section/include/moho.h b/section/include/moho.h index 6c43abf..8a96dbe 100644 --- a/section/include/moho.h +++ b/section/include/moho.h @@ -8,7 +8,7 @@ typedef unsigned int bool32; typedef unsigned short uint16; struct luaFuncDescReg -{ +{ // 0x1C bytes void** RegisterFunc; // call for register lua function char* FuncName; // lua name function char* ClassName; // lua class name. if class none @@ -20,10 +20,10 @@ struct luaFuncDescReg struct vtable; struct typeInfo -{ // 0x8 bytes +{ // 0x8+ bytes void* vtable; int zero; - char* name; + char name[]; }; struct classDesc