From 2ecbed35ef0337aa28596df80130ffb0c71db158 Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Sat, 31 Oct 2026 19:49:12 +0000 Subject: [PATCH] Decompile fn_23916 (CSession::RefreshTrackedAchievement) Batch #8617 by youko: 0 byte-identical, 1 confirmed by peer review. - fn_23916 CSession::RefreshTrackedAchievement: logic confirmed by peer review Peer-reviewed-by: ragnarok-clanker, Lumen, dori Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes). --- Source/Client/Session.h | 1 + Source/Contents/ClientTiming.cpp | 43 ++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/Source/Client/Session.h b/Source/Client/Session.h index dcb2a3c7..17a43679 100644 --- a/Source/Client/Session.h +++ b/Source/Client/Session.h @@ -670,6 +670,7 @@ public: const char* GetPetString(int id); int AddUnknown6160(int id); bool ToggleTrackedAchievement(int id); + void RefreshTrackedAchievement(int id); const char* GetPetTalkName(int job); const char* GetPetTalkActionName(int action); void GetPetTalkText(int job, int hungerState, int action, char* text); diff --git a/Source/Contents/ClientTiming.cpp b/Source/Contents/ClientTiming.cpp index 44d3572e..984bfcd9 100644 --- a/Source/Contents/ClientTiming.cpp +++ b/Source/Contents/ClientTiming.cpp @@ -1,5 +1,6 @@ #include "Client/Application/ApplicationWindow.h" #include "Client/Session.h" +#include "Contents/AchievementMgr.h" #include "Contents/Configuration/ServiceConfiguration.h" #include "Contents/MapInfoMgr.h" #include "Contents/NavigationManager.h" @@ -559,6 +560,48 @@ void CSession::SetHotkeySkillLevel(std::uint32_t skillLevel, int index) { this->unknown_0420[index] = skillLevel; } +// OFFSET: 0x00E265C0 +// FUNCTION: fn_23916 +void CSession::RefreshTrackedAchievement(int id) { + std::vector& tracked = this->unknown_6178; + auto found = std::find_if(tracked.begin(), tracked.end(), [id](SessionRecord6178 record) { return id == record.id; }); + if (found == tracked.end()) { + return; + } + + auto record = g_session.unknown_6144.find(id); + SessionRecord6144 progress = record != g_session.unknown_6144.end() ? record->second : SessionRecord6144(); + + AchievementInfo info; + g_achievementMgr->GetAchievement(info, id); + found->unknown_0001 = reinterpret_cast(&progress.unknown_0000)[1]; + + for (unsigned int i = 0; i < info.rewards.size(); ++i) { + const AchievementReward& reward = info.rewards[i]; + SessionRecord6178Entry& entry = found->unknown_0020[i]; + + if (info.unknown_0064 == 0) { + if (reward.text.size() > 40) { + entry.text = static_cast(FormatOwnedString("- %s...", reward.text.substr(0, 40).c_str())); + } else { + entry.text = static_cast(FormatOwnedString("- %s", reward.text.c_str())); + } + + entry.completed = static_cast(progress.unknown_0004[i]) > 0; + } else if (info.unknown_0064 == 1) { + int value = progress.unknown_0004[i]; + std::string count = FormatOwnedString("(%d/%d)", value, reward.unknown_0018); + if (reward.text.size() + count.size() > 40) { + entry.text = static_cast(FormatOwnedString("- %s...%s", reward.text.substr(0, 40 - count.size()).c_str(), count.c_str())); + } else { + entry.text = static_cast(FormatOwnedString("- %s %s", reward.text.c_str(), count.c_str())); + } + + entry.completed = value == reward.unknown_0018; + } + } +} + // OFFSET: 0x00E00320 // FUNCTION: fn_23639 void CSession::AddItemSlot(ITEM_INFO item) {