From dc75d034dad5b24f397b5c048733cdd482a38410 Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Fri, 30 Oct 2026 03:15:09 +0000 Subject: [PATCH] Decompile 4 functions in Source/Client/Mode/GameMode.cpp, Source/Client/Mode/CGameMode.h Batch #4433 by Snow: 0 byte-identical, 4 confirmed by peer review. - fn_21420 CGameMode::IsActiveSkillEffectId: logic confirmed by peer review - fn_21414 CGameMode::GetActiveSkillEffectTimeText: logic confirmed by peer review - fn_21582 CGameMode::IsExcludedSkillEffectId: logic confirmed by peer review - fn_21583 CGameMode::SubD07740: logic confirmed by peer review Peer-reviewed-by: eAthena, willerthal Reviewed-by: ragnarok-clanker --- Source/Client/Mode/CGameMode.h | 4 ++ Source/Client/Mode/GameMode.cpp | 113 ++++++++++++++++++++++++++++++++ 2 files changed, 117 insertions(+) diff --git a/Source/Client/Mode/CGameMode.h b/Source/Client/Mode/CGameMode.h index d05e1f7b..fca102d1 100644 --- a/Source/Client/Mode/CGameMode.h +++ b/Source/Client/Mode/CGameMode.h @@ -82,6 +82,10 @@ public: void PushUnknown01A4(int value); bool IsOverWeight(bool notify); void CompleteUnknown0194(std::uint32_t id, const std::string& text); + std::string GetActiveSkillEffectTimeText(int skillId, int* activeSkillId); + bool IsActiveSkillEffectId(std::uint32_t id); + bool IsExcludedSkillEffectId(std::uint32_t id); + int SubD07740(int id, int defaultResult); bool AppendGuildEmblem(std::vector& output, std::vector& names, int guildId, int unused); void ReceiveResultNotice(int result); void RefreshWindow16(const unsigned char* packet); diff --git a/Source/Client/Mode/GameMode.cpp b/Source/Client/Mode/GameMode.cpp index a4072fc0..fe0df6d1 100644 --- a/Source/Client/Mode/GameMode.cpp +++ b/Source/Client/Mode/GameMode.cpp @@ -1,10 +1,19 @@ #include "Client/Mode/CGameMode.h" +#include "Client/Replay.h" #include "Client/Session.h" #include "Contents/MessageTable.h" +#include "Contents/Skills/ClientSkills.h" #include "UI/Window/UIWindowMgr.h" +#include "Utility/Text/FormatString.h" #include #include +#include + +#include + +// GLOBAL: gl_24661 +std::vector g_activeSkillEffects; // OFFSET: 0x00CCF480 // FUNCTION: fn_21242 @@ -51,3 +60,107 @@ void CGameMode::UpdateUnknown0628(int id, bool add) { this->unknown_0628.erase(id); } } + +// OFFSET: 0x00CF0380 +// FUNCTION: fn_21414 +std::string CGameMode::GetActiveSkillEffectTimeText(int skillId, int* activeSkillId) { + std::string output; + *activeSkillId = skillId; + + for (const ActiveSkillEffect& effect : g_activeSkillEffects) { + const int effectId = static_cast(effect.id); + if (skillId != (effectId == 0x2A ? 0x0C : effectId)) { + continue; + } + + *activeSkillId = effectId; + const std::uint32_t expiration = effect.unknown_0004; + if (expiration == 999999 || expiration == 0) { + return output; + } + + std::uint32_t remainingSeconds = 0; + if (g_replayAnimationScaling == 0) { + remainingSeconds = (expiration - timeGetTime()) / 1000; + } else { + const int remainingMilliseconds = static_cast(expiration) - static_cast(Replay::Instance().elapsed); + if (remainingMilliseconds >= 1000) { + remainingSeconds = static_cast(remainingMilliseconds) / 1000; + } + } + + const int signedSeconds = static_cast(remainingSeconds); + const int hours = signedSeconds / 3600; + if (hours != 0) { + output.append(FormatOwnedString("%d %s", hours, LookupMessage(0x6A1))); + } + + const int remainder = signedSeconds - hours * 3600; + const int minutes = remainder / 60; + const int seconds = remainder % 60; + if (minutes != 0) { + output.append(FormatOwnedString(" %d %s", minutes, LookupMessage(0x70F))); + } + if (seconds != 0) { + output.append(FormatOwnedString(" %d %s", seconds, LookupMessage(0x710))); + } + + break; + } + + return output; +} + +// OFFSET: 0x00CF0A80 +// FUNCTION: fn_21420 +bool CGameMode::IsActiveSkillEffectId(std::uint32_t id) { + if (this->IsExcludedSkillEffectId(id)) { + return false; + } + + for (const ActiveSkillEffect& effect : g_activeSkillEffects) { + if (effect.id == id) { + return true; + } + } + + return false; +} + +// OFFSET: 0x00D07720 +// FUNCTION: fn_21582 +bool CGameMode::IsExcludedSkillEffectId(std::uint32_t id) { + return id == 0x28 || id == 0x2A; +} + +// OFFSET: 0x00D07740 +// FUNCTION: fn_21583 +int CGameMode::SubD07740(int id, int defaultResult) { + if (id < 0xFB5) { + if (id == 0xFB4 || id == 0x13) { + return 1; + } + + if (id == 0x14) { + return 0; + } + } else { + switch (id) { + case 0xFB5: + case 0xFCB: + case 0xFE5: + case 0xFEC: + case 0x1009: + case 0x10A8: + return 0; + case 0xFCA: + case 0xFE4: + case 0xFEB: + case 0x1008: + case 0x10A7: + return 1; + } + } + + return defaultResult; +}