From dab70b8cd8998c16fe5469d6531ec8f82cd6b826 Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Tue, 3 Nov 2026 12:45:41 +0000 Subject: [PATCH] Maintenance: [forced, user-approved] Family G28: remove EmblemCache (inventory row 71). Its fields are CGuildMgr members (g_guildMgr Batch #10253 by ragnarok-clanker: forced by an admin (2 lower score(s), 8 changed function(s)); checked with 24 compiled unit(s), including every includer of Source/Contents/GuildMgr.h, Source/Contents/Emblems/EmblemCache.h. Deletes: Source/Contents/Emblems/EmblemCache.h --- Source/Contents/Emblems/EmblemCache.cpp | 59 +++++++++++++------------ Source/Contents/Emblems/EmblemCache.h | 31 ------------- Source/Contents/GuildEmblemLookup.cpp | 3 +- Source/Contents/GuildMgr.h | 24 +++++----- Source/Resource/EmblemResource.cpp | 12 +---- 5 files changed, 48 insertions(+), 81 deletions(-) delete mode 100644 Source/Contents/Emblems/EmblemCache.h diff --git a/Source/Contents/Emblems/EmblemCache.cpp b/Source/Contents/Emblems/EmblemCache.cpp index 0f1dc191..6cb3a1d1 100644 --- a/Source/Contents/Emblems/EmblemCache.cpp +++ b/Source/Contents/Emblems/EmblemCache.cpp @@ -1,8 +1,11 @@ -#include "Contents/Emblems/EmblemCache.h" +#include "Client/Application/Launcher.h" +#include "Client/Mode/CGameMode.h" +#include "Client/Mode/ModeMgr.h" +#include "Client/Session.h" #include "Contents/Emblems/GuildEmblemReqBundle.h" #include "Contents/GuildMgr.h" #include "UI/Window/UIWindow.h" -#include "UI/Window/WindowManagerWindows.h" +#include "UI/Window/UIWindowMgr.h" #include #include @@ -29,34 +32,34 @@ namespace { // OFFSET: 0x0065ED00 // FUNCTION: fn_05178 -std::string EmblemCache::Filename(std::uint32_t guild, std::uint32_t revision) const { +std::string CGuildMgr::EmblemFilename(std::uint32_t guild, std::uint32_t revision) const { std::ostringstream name; - name << this->accountName << '_' << guild << '_' << (revision + 0x7FFFFFFFu) << ".ebm"; + name << g_session.m_accountName << '_' << guild << '_' << (revision + 0x7FFFFFFFu) << ".ebm"; return name.str(); } // OFFSET: 0x0065E6F0 // FUNCTION: fn_05176 -bool EmblemCache::IsInvalid(std::string path) const { - return this->invalid.contains(Basename(path)); +bool CGuildMgr::IsInvalidEmblem(std::string path) const { + return this->m_invalidEmblems.contains(Basename(path)); } // OFFSET: 0x0065DFB0 // FUNCTION: fn_05171 -void EmblemCache::MarkInvalid(std::string path) { - this->invalid.insert(Basename(path)); +void CGuildMgr::MarkInvalidEmblem(std::string path) { + this->m_invalidEmblems.insert(Basename(path)); } // OFFSET: 0x0065E890 // FUNCTION: fn_05177 -void EmblemCache::Store(const void* bytes, std::uint32_t size, std::uint32_t guild, std::uint32_t revision) { - const std::string directory = std::string(this->rootDirectory) + "\\_tmpEmblem\\"; - const std::string filename = this->Filename(guild, revision); +void CGuildMgr::StoreEmblem(const void* bytes, std::uint32_t size, std::uint32_t guild, std::uint32_t revision) { + const std::string directory = std::string(g_applicationDirectory) + "\\_tmpEmblem\\"; + const std::string filename = g_guildMgr->EmblemFilename(guild, revision); uLongf compressedSize = compressBound(size); std::unique_ptr compressed(new unsigned char[compressedSize]); if (compress(compressed.get(), &compressedSize, static_cast(bytes), size) != Z_OK) { - this->MarkInvalid(filename); + g_guildMgr->MarkInvalidEmblem(filename); return; } @@ -65,7 +68,7 @@ void EmblemCache::Store(const void* bytes, std::uint32_t size, std::uint32_t gui } std::ostringstream pattern; - pattern << this->accountName << '_' << guild << "_*.ebm"; + pattern << g_session.m_accountName << '_' << guild << "_*.ebm"; WIN32_FIND_DATAA found{}; const HANDLE search = FindFirstFileA((directory + pattern.str()).c_str(), &found); std::list names; @@ -97,18 +100,20 @@ void EmblemCache::Store(const void* bytes, std::uint32_t size, std::uint32_t gui // OFFSET: 0x00D588E0 // FUNCTION: fn_21954 -void EmblemCache::Receive(std::uint16_t state, std::uint32_t guild, std::uint32_t revision, const unsigned char* bytes, int size) { +void __stdcall CGuildMgr::ReceiveEmblem(std::uint16_t state, std::uint32_t guild, std::uint32_t revision, const unsigned char* bytes, int size) { + CGuildMgr* manager = g_guildMgr; + if (state == 0) { - this->guildId = guild; - this->version = revision; - this->data.clear(); + manager->m_receiveGuildId = guild; + manager->m_receiveVersion = revision; + manager->m_receiveData.clear(); } else if (state == 1) { - if (guild == this->guildId && revision == this->version) { - this->data.insert(this->data.end(), bytes, bytes + size); + if (guild == manager->m_receiveGuildId && revision == manager->m_receiveVersion) { + manager->m_receiveData.insert(manager->m_receiveData.end(), bytes, bytes + size); } - } else if (state == 2 && guild == this->guildId && revision == this->version) { - this->Store(this->data.data(), static_cast(this->data.size()), guild, revision); - this->Refresh(guild); + } else if (state == 2 && guild == manager->m_receiveGuildId && revision == manager->m_receiveVersion) { + StoreEmblem(manager->m_receiveData.data(), static_cast(manager->m_receiveData.size()), guild, revision); + RefreshEmblem(guild); } } @@ -122,14 +127,12 @@ void CGuildMgr::UpdateEmblemRequests( // OFFSET: 0x0065EE50 // FUNCTION: fn_05180 -void EmblemCache::Refresh(std::uint32_t guild) { - if (this->modeWindows) { - for (UIWindow* window : *this->modeWindows) { - window->SendMsg(nullptr, 60, guild, 0, 0, 0); - } +void CGuildMgr::RefreshEmblem(std::uint32_t guild) { + if (g_modeMgr.GetGameMode()) { + static_cast(g_modeMgr.GetGameMode())->NotifyUnknown0604(guild); } - UIWindow* window = this->windows.LookupWindow(60); + UIWindow* window = g_windowMgr.LookupWindow(60); if (window) { window->Invalidate(); diff --git a/Source/Contents/Emblems/EmblemCache.h b/Source/Contents/Emblems/EmblemCache.h deleted file mode 100644 index de684168..00000000 --- a/Source/Contents/Emblems/EmblemCache.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef RAGNAROK_SOURCE_CONTENTS_EMBLEMS_EMBLEMCACHE_H -#define RAGNAROK_SOURCE_CONTENTS_EMBLEMS_EMBLEMCACHE_H - -#include -#include -#include -#include -#include - -class UIWindow; -#include "UI/Window/WindowManagerWindows.h" - -struct EmblemCache { - std::uint32_t& guildId; - std::uint32_t& version; - std::vector& data; - std::set& invalid; - const std::string& accountName; - const char* rootDirectory; - const std::list* const& modeWindows; - WindowManagerWindows& windows; - - std::string Filename(std::uint32_t guild, std::uint32_t revision) const; - bool IsInvalid(std::string path) const; - void MarkInvalid(std::string path); - void Store(const void* bytes, std::uint32_t size, std::uint32_t guild, std::uint32_t revision); - void Receive(std::uint16_t state, std::uint32_t guild, std::uint32_t revision, const unsigned char* bytes, int size); - void Refresh(std::uint32_t guild); -}; - -#endif diff --git a/Source/Contents/GuildEmblemLookup.cpp b/Source/Contents/GuildEmblemLookup.cpp index 07a29408..782e79ac 100644 --- a/Source/Contents/GuildEmblemLookup.cpp +++ b/Source/Contents/GuildEmblemLookup.cpp @@ -1,5 +1,4 @@ #include "Client/Replay.h" -#include "Contents/Emblems/EmblemCache.h" #include "Contents/Emblems/GuildEmblemReqBundle.h" #include "Contents/GuildMgr.h" #include "Resource/ResourceMgr.h" @@ -12,7 +11,7 @@ std::string CGuildMgr::GetEmblemFilename(std::uint32_t guildId) { return std::string(); } - std::string filename = reinterpret_cast(this)->Filename(guildId, found->second.m_emblemVersion); + std::string filename = this->EmblemFilename(guildId, found->second.m_emblemVersion); if (!ResourceMgr::Instance().Load(filename) && g_replayAnimationScaling == 0) { this->m_reqBundle->Add(guildId, this->GetEmblemVersion(guildId)); } diff --git a/Source/Contents/GuildMgr.h b/Source/Contents/GuildMgr.h index 0ba9dca4..0648d354 100644 --- a/Source/Contents/GuildMgr.h +++ b/Source/Contents/GuildMgr.h @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -31,19 +32,23 @@ public: int GetEmblemVersion(std::uint32_t guildId) const; std::string GetEmblemFilename(std::uint32_t guildId); void SetEmblemVersion(std::uint32_t guildId, int version); + std::string EmblemFilename(std::uint32_t guild, std::uint32_t revision) const; + bool IsInvalidEmblem(std::string path) const; + void MarkInvalidEmblem(std::string path); + static void StoreEmblem(const void* bytes, std::uint32_t size, std::uint32_t guild, std::uint32_t revision); + static void __stdcall ReceiveEmblem(std::uint16_t state, std::uint32_t guild, std::uint32_t revision, const unsigned char* bytes, int size); + static void RefreshEmblem(std::uint32_t guild); void UpdateEmblemRequests( CEmblemDataMgr& emblems, std::uint32_t accountId, const std::string& accountName, const char* token16, CConnection& connection, CAsyncWorkMgr& manager ); - 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; + /* 0014 */ std::set m_invalidEmblems; + /* 001C */ std::uint32_t m_receiveGuildId; + /* 0020 */ std::uint32_t m_receiveVersion; + /* 0024 */ std::vector m_receiveData; /* 0030 */ int m_timeout; }; @@ -53,13 +58,12 @@ extern CGuildMgr* g_guildMgr; 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_invalidEmblems) == 0x14); +static_assert(offsetof(CGuildMgr, m_receiveGuildId) == 0x1C); +static_assert(offsetof(CGuildMgr, m_receiveData) == 0x24); static_assert(offsetof(CGuildMgr, m_timeout) == 0x30); #endif diff --git a/Source/Resource/EmblemResource.cpp b/Source/Resource/EmblemResource.cpp index d9a6f430..4fbfa07b 100644 --- a/Source/Resource/EmblemResource.cpp +++ b/Source/Resource/EmblemResource.cpp @@ -1,6 +1,5 @@ #include "Resource/EmblemResource.h" -#include "Contents/Emblems/EmblemCache.h" #include "Contents/GuildMgr.h" #include "File/File.h" @@ -9,13 +8,6 @@ #include #include -namespace { - // INLINED - EmblemCache& GuildEmblemCache() { - return *reinterpret_cast(g_guildMgr); - } -} - // INLINED CEmblemRes::~CEmblemRes() = default; @@ -28,7 +20,7 @@ CEmblemRes* CEmblemRes::Create() { // OFFSET: 0x0074CA90 // FUNCTION: fn_07881 bool CEmblemRes::Load(const char* name) { - if (GuildEmblemCache().IsInvalid(name) == true) { + if (g_guildMgr->IsInvalidEmblem(name) == true) { this->gif.CreateBlank(24, 24); return true; } @@ -42,7 +34,7 @@ bool CEmblemRes::Load(const char* name) { Bytef* buffer = static_cast(std::malloc(size)); if (uncompress(buffer, &size, static_cast(file.GetData()), file.GetSize()) != Z_OK || this->gif.Decode("_emblem.bmp", buffer, size, true) != true) { - GuildEmblemCache().MarkInvalid(name); + g_guildMgr->MarkInvalidEmblem(name); this->gif.CreateBlank(24, 24); }