diff --git a/Source/Contents/GuildEmblemState.cpp b/Source/Contents/GuildEmblemState.cpp new file mode 100644 index 0000000..4fb9dc6 --- /dev/null +++ b/Source/Contents/GuildEmblemState.cpp @@ -0,0 +1,22 @@ +#include "Contents/GuildMgr.h" + +// FUNCTION: fn_05147 +CGuild::CGuild() : m_emblemVersion(0) { +} + +// FUNCTION: fn_05148 +CGuild::~CGuild() = default; + +// FUNCTION: fn_05175 +int CGuildMgr::GetEmblemVersion(std::uint32_t guildId) const { + const auto it = this->m_guilds.find(guildId); + if (it != this->m_guilds.end()) { + return it->second.m_emblemVersion; + } + return 0; +} + +// FUNCTION: fn_05181 +void CGuildMgr::SetEmblemVersion(std::uint32_t guildId, int version) { + this->m_guilds[guildId].m_emblemVersion = version; +} diff --git a/Source/Contents/GuildMgr.cpp b/Source/Contents/GuildMgr.cpp new file mode 100644 index 0000000..a597281 --- /dev/null +++ b/Source/Contents/GuildMgr.cpp @@ -0,0 +1,52 @@ +#include "Contents/GuildMgr.h" +#include "Contents/Emblems/GuildEmblemReqBundle.h" + +#include + +// GLOBAL: gl_24555 +CGuildMgr* g_guildMgr = nullptr; + +// INLINED +CGuildMgr::CGuildMgr() : m_reqBundle(nullptr), m_timeout(0xC800) { + this->m_initialized = false; + this->m_reqBundle = new (std::nothrow) CGuildEmblemReqBundle(); + if (this->m_reqBundle) { + this->m_initialized = true; + } +} + +// INLINED +CGuildMgr::~CGuildMgr() { + if (this->m_reqBundle) { + delete this->m_reqBundle; + this->m_reqBundle = nullptr; + } +} + +// FUNCTION: fn_05172 +bool CGuildMgr::Create() { + if (g_guildMgr) { + return false; + } + + g_guildMgr = new (std::nothrow) CGuildMgr(); + if (!g_guildMgr) { + return false; + } + + if (!g_guildMgr->m_initialized) { + delete g_guildMgr; + g_guildMgr = nullptr; + return false; + } + + return true; +} + +// FUNCTION: fn_05173 +void CGuildMgr::Destroy() { + if (g_guildMgr) { + delete g_guildMgr; + g_guildMgr = nullptr; + } +} diff --git a/Source/Contents/GuildMgr.h b/Source/Contents/GuildMgr.h new file mode 100644 index 0000000..6f5039d --- /dev/null +++ b/Source/Contents/GuildMgr.h @@ -0,0 +1,58 @@ +#ifndef RAGNAROK_SOURCE_CONTENTS_GUILDMGR_H +#define RAGNAROK_SOURCE_CONTENTS_GUILDMGR_H + +#include +#include +#include +#include + +class CGuildEmblemReqBundle; + +class CGuild { +public: + CGuild(); + virtual ~CGuild(); + + /* 0004 */ int m_emblemVersion; +}; + +class CGuildMgr { +public: + CGuildMgr(); + virtual ~CGuildMgr(); + + static bool Create(); + static void Destroy(); + + int GetEmblemVersion(std::uint32_t guildId) const; + void SetEmblemVersion(std::uint32_t guildId, int version); + + struct MemberData { + /* 0000 */ int unknown_0000[5]; + }; + /* 0004 */ bool m_initialized; + /* 0008 */ std::map m_guilds; + /* 0010 */ CGuildEmblemReqBundle* m_reqBundle; + /* 0014 */ std::map m_members; + /* 001C */ int unknown_001C[2]; + /* 0024 */ std::vector m_unknownVector; + /* 0030 */ int m_timeout; +}; + +extern CGuildMgr* g_guildMgr; + +#if defined(_WIN32) && !defined(_WIN64) +static_assert(sizeof(CGuild) == 8); +static_assert(offsetof(CGuild, m_emblemVersion) == 0x04); +static_assert(sizeof(CGuildMgr) == 52); +static_assert(sizeof(CGuildMgr::MemberData) == 20); +static_assert(offsetof(CGuildMgr, m_initialized) == 0x04); +static_assert(offsetof(CGuildMgr, m_guilds) == 0x08); +static_assert(offsetof(CGuildMgr, m_reqBundle) == 0x10); +static_assert(offsetof(CGuildMgr, m_members) == 0x14); +static_assert(offsetof(CGuildMgr, unknown_001C) == 0x1C); +static_assert(offsetof(CGuildMgr, m_unknownVector) == 0x24); +static_assert(offsetof(CGuildMgr, m_timeout) == 0x30); +#endif + +#endif diff --git a/compile.json b/compile.json index c684c8f..ac5d365 100644 --- a/compile.json +++ b/compile.json @@ -295,6 +295,8 @@ "Source/Contents/Ground/TerrainHeight.cpp": 4, "Source/Contents/Ground/TerrainPicking.cpp": 4, "Source/Contents/Ground/TerrainPlane.cpp": 4, + "Source/Contents/GuildEmblemState.cpp": 4, + "Source/Contents/GuildMgr.cpp": 4, "Source/Contents/Hotkeys/EmotionHotkeys.cpp": 4, "Source/Contents/Hotkeys/HotkeyInfo.cpp": 4, "Source/Contents/Hotkeys/UserHotkeyMgr.cpp": 4,