Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Researching and Implementing Structures and Functions Related to Water #3720

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 2 additions & 22 deletions ChaosMod/Effects/db/Misc/MiscNoWater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<float> 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<CWaterQuad *>();
return nullptr;
}

static void OnStart()
{
WaterQuads = GetWaterQuads();
WaterQuads = Memory::GetAllWaterQuads();
if (WaterQuads)
{
for (int i = 0; i < 821; i++) // 821 = Max Water Items
Expand Down
83 changes: 83 additions & 0 deletions ChaosMod/Memory/Water.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#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("4C 8B 05 ? ? ? ? 42 8B 04 03");
if (!handle.IsValid())
return nullptr;

return *handle.At(2).Into().Get<CWaterQuad *>();
}

inline static CCalmingQuad *GetAllCalmingQuads()
{
static Handle handle = Memory::FindPattern("4C 8B 05 ? ? ? ? 49 83 C1 0C");
if (!handle.IsValid())
return nullptr;

return *handle.At(2).Into().Get<CCalmingQuad *>();
}

inline static CWaveQuad *GetAllWaveQuads()
{
static Handle handle = Memory::FindPattern("4C 8B 05 ? ? ? ? 49 83 C1 18");
if (!handle.IsValid())
return nullptr;

return *handle.At(2).Into().Get<CWaveQuad *>();
}
}