Skip to content

Commit

Permalink
RangeRings2 + Misc
Browse files Browse the repository at this point in the history
  • Loading branch information
KionX committed Jul 23, 2022
1 parent 828138e commit d860211
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 4 deletions.
4 changes: 4 additions & 0 deletions .gitignore
@@ -0,0 +1,4 @@
*.exe
/build
define.h
patch.ld
6 changes: 6 additions & 0 deletions README.md
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions 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)";"
);
25 changes: 25 additions & 0 deletions section/RangeRings2.cpp
@@ -0,0 +1,25 @@
#include <cstdint>

float MinCHeight, MaxCHeight;

void* _thiscall HeightCylinders(char* this_)
{
auto Sim = reinterpret_cast<char* (_thiscall *)(void*)>(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<void (_thiscall *)(void*)>(0x7EDFE0)(this_ + 0x37C);
reinterpret_cast<void (_thiscall *)(void*)>(0x81C0C0)(this_ + 0x410);
return Sim;
}
6 changes: 5 additions & 1 deletion section/include/global.h
Expand Up @@ -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
Expand Down Expand Up @@ -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 ?
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions section/include/moho.h
Expand Up @@ -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. <global> if class none
Expand All @@ -20,10 +20,10 @@ struct luaFuncDescReg

struct vtable;
struct typeInfo
{ // 0x8 bytes
{ // 0x8+ bytes
void* vtable;
int zero;
char* name;
char name[];
};

struct classDesc
Expand Down

0 comments on commit d860211

Please sign in to comment.