From 88d8e9e378fca96c3177b90df4889ffd7dcfefb9 Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Thu, 29 Oct 2026 08:58:09 +0000 Subject: [PATCH] Decompile 2 functions in Source/Contents/EffectResourceSwitcher.cpp, Source/Contents/EffectResourceSwitcher.h, ... Batch #1977 by Yommy: 0 byte-identical, 2 confirmed by peer review. - fn_03113 EffectResourceSwitcher::Slot16: logic confirmed by peer review - fn_03115 Singleton::GetInstance: logic confirmed by peer review Peer-reviewed-by: ragnarok-clanker, eAthena Reviewed-by: ragnarok-clanker --- Source/Contents/EffectResourceSwitcher.cpp | 25 ++++++++++++ Source/Contents/EffectResourceSwitcher.h | 44 ++++++++++++++++++++++ Source/Utility/Singleton.h | 14 +++++++ 3 files changed, 83 insertions(+) create mode 100644 Source/Contents/EffectResourceSwitcher.h create mode 100644 Source/Utility/Singleton.h diff --git a/Source/Contents/EffectResourceSwitcher.cpp b/Source/Contents/EffectResourceSwitcher.cpp index e2536f3..e26aea9 100644 --- a/Source/Contents/EffectResourceSwitcher.cpp +++ b/Source/Contents/EffectResourceSwitcher.cpp @@ -1,8 +1,14 @@ +#include "Contents/EffectResourceSwitcher.h" #include "Contents/Effects/Effect.h" #include "Contents/Effects/EffectPrimitiveState.h" +#include #include +// GLOBAL: gl_24485 +template <> +CEZ2STREffectMgr* Singleton::s_instance = nullptr; + // OFFSET: 0x005A2110 // FUNCTION: fn_03083 void CEffect::Slot10(int) { @@ -120,7 +126,26 @@ void CEffect::Slot22(int) { void CEffect::Slot13(int) { } +// OFFSET: 0x005A2520 +// FUNCTION: fn_03113 +void EffectResourceSwitcher::Slot16(int argument) { + if (this->effect) { + this->effect->Slot16(argument); + } +} + // OFFSET: 0x005A2540 // FUNCTION: fn_03114 void CEffect::Slot20(int) { } + +// OFFSET: 0x005A2630 +// FUNCTION: fn_03115 +template <> +CEZ2STREffectMgr* Singleton::GetInstance() { + if (!s_instance) { + s_instance = new (std::nothrow) CEZ2STREffectMgr; + } + + return s_instance; +} diff --git a/Source/Contents/EffectResourceSwitcher.h b/Source/Contents/EffectResourceSwitcher.h new file mode 100644 index 0000000..0e41722 --- /dev/null +++ b/Source/Contents/EffectResourceSwitcher.h @@ -0,0 +1,44 @@ +#ifndef RAGNAROK_SOURCE_CONTENTS_EFFECTRESOURCESWITCHER_H +#define RAGNAROK_SOURCE_CONTENTS_EFFECTRESOURCESWITCHER_H + +#include "Contents/Effects/Effect.h" +#include "Utility/Singleton.h" + +#include +#include +#include + +struct EZ2STREffectInfo { + /* 0000 */ int id; + /* 0004 */ std::string name; + /* 001C */ int unknown_001C[3]; + /* 0028 */ std::string unknown_0028; + /* 0040 */ int unknown_0040[2]; +}; + +class CEZ2STREffectMgr : public Singleton { +public: + /* 0004 */ std::map effects; +}; + +class EffectResourceSwitcher : public CEffect { +public: + /* 00CC */ unsigned char active; + /* 00CD */ unsigned char unknown_00CD[3]; + /* 00D0 */ CEffect* effect; + /* 00D4 */ int unknown_00D4[3]; + /* 00E0 */ std::string sourceName; + /* 00F8 */ std::string targetName; + + void Slot16(int argument) override; +}; + +#if defined(_WIN32) && !defined(_WIN64) +static_assert(sizeof(EZ2STREffectInfo) == 0x48); +static_assert(sizeof(CEZ2STREffectMgr) == 0xC); +static_assert(offsetof(EffectResourceSwitcher, effect) == 0xD0); +static_assert(offsetof(EffectResourceSwitcher, targetName) == 0xF8); +static_assert(sizeof(EffectResourceSwitcher) == 0x110); +#endif + +#endif diff --git a/Source/Utility/Singleton.h b/Source/Utility/Singleton.h new file mode 100644 index 0000000..982b657 --- /dev/null +++ b/Source/Utility/Singleton.h @@ -0,0 +1,14 @@ +#ifndef RAGNAROK_SOURCE_UTILITY_SINGLETON_H +#define RAGNAROK_SOURCE_UTILITY_SINGLETON_H + +template +class Singleton { +public: + static T* s_instance; + + static T* GetInstance(); + + virtual ~Singleton() {} +}; + +#endif