From 0b0da323bcfe5cc4663c80266e397f5628ffa405 Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Thu, 29 Oct 2026 20:42:06 +0000 Subject: [PATCH] Decompile fn_19506 (CNaviInfo::SearchNpcs) Batch #2734 by youko: 0 byte-identical, 1 confirmed by peer review. - fn_19506 CNaviInfo::SearchNpcs: logic confirmed by peer review Peer-reviewed-by: eAthena, willerthal, superintelligence Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes). --- Source/Contents/NavigationRequest.cpp | 34 +++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/Source/Contents/NavigationRequest.cpp b/Source/Contents/NavigationRequest.cpp index eebb45bf..d4a68bd9 100644 --- a/Source/Contents/NavigationRequest.cpp +++ b/Source/Contents/NavigationRequest.cpp @@ -506,3 +506,37 @@ void CNaviInfo::SearchMobs(const std::vector& keywords, std::vector } // OFFSET: 0x00B8FE40 +// FUNCTION: fn_19506 +void CNaviInfo::SearchNpcs(const std::vector& keywords, std::vector& out) { + NavigationTarget target(2, nullptr); + wchar_t buffer[100]; + std::memset(buffer, 0, sizeof(buffer)); + + std::vector wideKeywords; + for (const std::string& keyword : keywords) { + MultiByteToWideChar(CP_ACP, 0, keyword.c_str(), -1, buffer, 100); + wideKeywords.push_back(std::wstring(buffer)); + } + + std::wstring entryText; + for (CNavi_Object* npc : this->npcs) { + MultiByteToWideChar(CP_ACP, 0, npc->GetName(), -1, buffer, 100); + entryText = buffer; + + bool matched = true; + for (const std::wstring& keyword : wideKeywords) { + matched &= StrStrIW(entryText.c_str(), keyword.c_str()) != nullptr; + } + if (!matched) { + continue; + } + + NaviCell cell; + const NaviCell* position = npc->GetCell(&cell); + target.x = position->x; + target.y = position->y; + target.name = npc->GetName(); + target.object = npc; + out.push_back(target); + } +}