From b62d72a4a5ab56a8e761ba7cbd3a4f3202d2b6f5 Mon Sep 17 00:00:00 2001 From: MoneyWasted <45946092+MoneyWasted@users.noreply.github.com> Date: Sat, 15 Feb 2025 17:44:48 -0500 Subject: [PATCH 1/2] Adding New & Improved Water Structures --- ChaosMod/Effects/db/Misc/MiscNoWater.cpp | 24 +------- ChaosMod/Memory/Water.h | 75 ++++++++++++++++++++++++ 2 files changed, 77 insertions(+), 22 deletions(-) create mode 100644 ChaosMod/Memory/Water.h diff --git a/ChaosMod/Effects/db/Misc/MiscNoWater.cpp b/ChaosMod/Effects/db/Misc/MiscNoWater.cpp index daf1faa5c..ae2ebf448 100644 --- a/ChaosMod/Effects/db/Misc/MiscNoWater.cpp +++ b/ChaosMod/Effects/db/Misc/MiscNoWater.cpp @@ -7,34 +7,14 @@ #include "Effects/Register/RegisterEffect.h" -struct CWaterQuad -{ - short MinX; // 0x0 - short MinY; // 0x2 - short MaxX; // 0x4 - short MaxY; // 0x6 - uint Color; // 0x8 - char unk1[4]; // 0xC - char unk2[4]; // 0x10 - float Z; // 0x14 - uint Flags; // 0x18 -}; -static_assert(sizeof(CWaterQuad) == 0x1C); +#include "Memory/Water.h" CHAOS_VAR CWaterQuad *WaterQuads; CHAOS_VAR std::vector WaterHeights; -static CWaterQuad *GetWaterQuads() -{ - static Handle handle = Memory::FindPattern("? 6B C9 1C ? 03 0D ? ? ? ? 66 ? 03 C5 66 89 05 ? ? ? ?"); - if (handle.IsValid()) - return *handle.At(6).Into().Get(); - return nullptr; -} - static void OnStart() { - WaterQuads = GetWaterQuads(); + WaterQuads = Memory::GetAllWaterQuads(); if (WaterQuads) { for (int i = 0; i < 821; i++) // 821 = Max Water Items diff --git a/ChaosMod/Memory/Water.h b/ChaosMod/Memory/Water.h new file mode 100644 index 000000000..920ef70a5 --- /dev/null +++ b/ChaosMod/Memory/Water.h @@ -0,0 +1,75 @@ +#pragma once + +struct CWaterQuad +{ + short MinX; // 0x00 + short MinY; // 0x02 + short MaxX; // 0x04 + short MaxY; // 0x06 + uint32_t Alpha; // 0x08 + float Unk0; // 0x0C + float Unk1; // 0x10 + float Z; // 0x14 + union // Bitfield Flags + { + uint8_t Flags; // 0x18 + struct { + uint8_t UnkFlag0 : 1; // Bit 0 + uint8_t UnkFlag1 : 1; // Bit 1 + uint8_t IsAudible : 1; // Bit 2 + uint8_t IsVisible : 1; // Bit 3 + uint8_t UnkFlag4 : 1; // Bit 4 + uint8_t UnkFlag5 : 1; // Bit 5 + uint8_t UnkFlag6 : 1; // Bit 6 + uint8_t UnkFlag7 : 1; // Bit 7 + }; + }; + uint8_t Type; // 0x19 + char Pad_01A; // 0x1A + char Pad_01B; // 0x1B +}; +static_assert(sizeof(CWaterQuad) == 0x1C); + +struct CCalmingQuad +{ + short MinX; // 0x00 + short MinY; // 0x02 + short MaxX; // 0x04 + short MaxY; // 0x06 + float Unk0; // 0x08 +}; +static_assert(sizeof(CCalmingQuad) == 0xC); + +struct CWaveQuad +{ + short MinX; // 0x00 + short MinY; // 0x02 + short MaxX; // 0x04 + short MaxY; // 0x06 + uint16_t Unk0; // 0x08 + uint8_t X; // 0x0A + uint8_t Y; // 0x0B +}; +static_assert(sizeof(CWaveQuad) == 0xC); + +namespace Memory +{ + inline static CWaterQuad *GetAllWaterQuads() + { + static Handle handle = Memory::FindPattern("? 6B C9 1C ? 03 0D ? ? ? ? 66 ? 03 C5 66 89 05 ? ? ? ?"); + if (!handle.IsValid()) + return nullptr; + + return *handle.At(6).Into().Get(); + } + + inline static CCalmingQuad *GetAllCalmingQuads() + { + return nullptr; + } + + inline static CWaveQuad *GetAllWaveQuads() + { + return nullptr; + } +} \ No newline at end of file From 1c238f77c2c7828c9013510eed5faca9561c1aab Mon Sep 17 00:00:00 2001 From: MoneyWasted <45946092+MoneyWasted@users.noreply.github.com> Date: Sun, 16 Feb 2025 18:42:41 -0500 Subject: [PATCH 2/2] Completing Structure Instance Getter Functions --- ChaosMod/Memory/Water.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/ChaosMod/Memory/Water.h b/ChaosMod/Memory/Water.h index 920ef70a5..b1304d7b6 100644 --- a/ChaosMod/Memory/Water.h +++ b/ChaosMod/Memory/Water.h @@ -56,20 +56,28 @@ namespace Memory { inline static CWaterQuad *GetAllWaterQuads() { - static Handle handle = Memory::FindPattern("? 6B C9 1C ? 03 0D ? ? ? ? 66 ? 03 C5 66 89 05 ? ? ? ?"); + static Handle handle = Memory::FindPattern("4C 8B 05 ? ? ? ? 42 8B 04 03"); if (!handle.IsValid()) return nullptr; - return *handle.At(6).Into().Get(); + return *handle.At(2).Into().Get(); } inline static CCalmingQuad *GetAllCalmingQuads() { - return nullptr; + static Handle handle = Memory::FindPattern("4C 8B 05 ? ? ? ? 49 83 C1 0C"); + if (!handle.IsValid()) + return nullptr; + + return *handle.At(2).Into().Get(); } inline static CWaveQuad *GetAllWaveQuads() { - return nullptr; + static Handle handle = Memory::FindPattern("4C 8B 05 ? ? ? ? 49 83 C1 18"); + if (!handle.IsValid()) + return nullptr; + + return *handle.At(2).Into().Get(); } } \ No newline at end of file