From 81f36b3e56fd1e5ddbb7c42693c8f99ddacbfbaa Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Wed, 11 Nov 2026 09:01:44 +0000 Subject: [PATCH] Decompile 4 functions in Source/Contents/AdventureGuide/AdventureGuideMgr.cpp Batch #16786 by eAthena: 2 byte-identical, 2 confirmed by peer review. - fn_05189 FindMapped: byte-identical - fn_05190 FindMapped: byte-identical - fn_05242 CAdventureGuideMgr::InsertDungeonSubMenu: logic confirmed by peer review - fn_05255 CAdventureGuideMgr::InsertQuestSubMenu: logic confirmed by peer review Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes). --- .../AdventureGuide/AdventureGuideMgr.cpp | 34 ++++++++++--------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/Source/Contents/AdventureGuide/AdventureGuideMgr.cpp b/Source/Contents/AdventureGuide/AdventureGuideMgr.cpp index 83b99a82f..160b592bd 100644 --- a/Source/Contents/AdventureGuide/AdventureGuideMgr.cpp +++ b/Source/Contents/AdventureGuide/AdventureGuideMgr.cpp @@ -11,6 +11,8 @@ #include #include +extern template bool std::string_view::_Equal(std::string_view) const noexcept; + // GLOBAL: gl_24502 CAdventureGuideMgr* g_adventureGuideMgr; @@ -1134,20 +1136,20 @@ AdventureGuideEpisode::AdventureGuideEpisode(AdventureGuideEpisodeSource&& sourc // FUNCTION: fn_05189 static std::optional FindMapped(AdventureGuideEntryTable& map, const int& key) { auto it = map.find(key); - if (it == map.end()) { - return std::nullopt; + if (it != map.end()) { + return &it->second; } - return &it->second; + return std::nullopt; } // OFFSET: 0x0065F6D0 // FUNCTION: fn_05190 static std::optional FindMapped(AdventureGuideContentsTable& map, const int& key) { auto it = map.find(key); - if (it == map.end()) { - return std::nullopt; + if (it != map.end()) { + return &it->second; } - return &it->second; + return std::nullopt; } // OFFSET: 0x00660F70 @@ -1312,11 +1314,11 @@ AdventureGuideResult CAdventureGuideMgr::InsertDungeonSubMenu(int id, int minLev detail.maxLevel = maxLevel; detail.questId = 0; detail.text = text; - for (auto& [key, intro] : m_intros) { - if (intro.type == 4) { - intro.details.try_emplace(id, std::as_const(detail)); - break; - } + const auto it = std::find_if(m_intros.begin(), m_intros.end(), [](const auto& entry) { + return entry.second.type == 4; + }); + if (it != m_intros.end()) { + it->second.details.try_emplace(id, std::as_const(detail)); } return AdventureGuideResult(true, "good"); @@ -1520,11 +1522,11 @@ AdventureGuideResult CAdventureGuideMgr::InsertQuestSubMenu(int id, int minLevel detail.maxLevel = maxLevel; detail.questId = 0; detail.text = text; - for (auto& [key, intro] : m_intros) { - if (intro.type == 3) { - intro.details.try_emplace(id, std::as_const(detail)); - break; - } + const auto it = std::find_if(m_intros.begin(), m_intros.end(), [](const auto& entry) { + return entry.second.type == 3; + }); + if (it != m_intros.end()) { + it->second.details.try_emplace(id, std::as_const(detail)); } return AdventureGuideResult(true, "good");