From 2625025e9d2acd55fdf1a49b7acdd83fa2ef9013 Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Sat, 31 Oct 2026 06:59:40 +0000 Subject: [PATCH] Decompile 3 functions in Source/Contents/NavigationRoute.cpp, Source/Contents/NavigationManager.h Batch #7346 by gordaoprogramas: 0 byte-identical, 3 confirmed by peer review. - fn_19636 CNavigationManager::RouteToSavedTarget: logic confirmed by peer review - fn_19637 CNavigationManager::SelectTarget: logic confirmed by peer review - fn_19641 CNavigationManager::CancelRoute: logic confirmed by peer review Peer-reviewed-by: eAthena, aDw Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes). --- Source/Contents/NavigationManager.h | 5 +- Source/Contents/NavigationRoute.cpp | 99 +++++++++++++++++++++++++++++ 2 files changed, 103 insertions(+), 1 deletion(-) diff --git a/Source/Contents/NavigationManager.h b/Source/Contents/NavigationManager.h index 324ec4ce..a667d905 100644 --- a/Source/Contents/NavigationManager.h +++ b/Source/Contents/NavigationManager.h @@ -266,7 +266,7 @@ public: CNavi_Link* FindLink(unsigned int key, bool byId); int FindRoute(std::vector* route, bool direct, bool allowGates, bool includeObjects, bool allowWarps, int side); void ResetLinkDepths(); - bool CollectLinksTo(CNaviInfo* target, std::vector* out); + __declspec(noinline) bool CollectLinksTo(CNaviInfo* target, std::vector* out); bool Search(std::string query, int type, std::vector& out); int ParseSearchKind(std::vector& tokens); CNavi_Object* FindMobByTitle(std::string title); @@ -358,6 +358,9 @@ public: bool SetDestinationMap(std::string mapName, int x, int y); bool LoadTargetPreview(); bool BuildTargetRouteLines(); + bool RouteToSavedTarget(int cellX, int cellY); + void SelectTarget(int nodeIndex); + void CancelRoute(); /* 0000 */ CNaviData data; /* 004C */ CPathFinder pathFinder; diff --git a/Source/Contents/NavigationRoute.cpp b/Source/Contents/NavigationRoute.cpp index f28406ba..aef81bda 100644 --- a/Source/Contents/NavigationRoute.cpp +++ b/Source/Contents/NavigationRoute.cpp @@ -1284,3 +1284,102 @@ bool CNavigationManager::BuildTargetRouteLines() { } return true; } + +// OFFSET: 0x00BA0C90 +// FUNCTION: fn_19636 +bool CNavigationManager::RouteToSavedTarget(int cellX, int cellY) { + if (this->savedTarget.object == nullptr) { + return false; + } + + this->data.endLinks.clear(); + const int type = this->savedTarget.type; + int x = -1; + int y = -1; + CNaviInfo* info; + if (type == 2) { + CNavi_Object* object = static_cast(this->savedTarget.object); + if (object->LinkCount() == 0) { + return false; + } + info = object->GetInfo(); + NaviCell cell; + const NaviCell* position = object->GetCell(&cell); + x = position->x; + y = position->y; + this->data.endLinks = object->CopyLinks(); + } else { + if (type == 3) { + info = static_cast(this->savedTarget.object)->GetInfo(); + } else if (type == 1) { + info = static_cast(this->savedTarget.object); + } else if (type == 0) { + info = static_cast(this->savedTarget.object); + x = cellX; + y = cellY; + std::string name(info->GetName()); + name = ResourceMgr::Instance().aliases.ResolveMapName(name.c_str()); + if (!this->pathFinder.LoadAttr(name) || !this->pathFinder.Walkable(cellX, cellY)) { + return false; + } + } else { + return false; + } + + std::vector links; + if (!this->data.CollectLinksTo(info, &links)) { + return false; + } + + MovementRouteInterpolation route; + int cost = 0; + for (CNavi_Link* link : links) { + if (this->savedTarget.type == 0) { + this->pathFinder.Reset(); + cost = 0; + if (link->GetLinkedCell().x == x && link->GetLinkedCell().y == y) { + cost = 1; + } else if (this->pathFinder.FindPath(1, link->GetLinkedCell().x, link->GetLinkedCell().y, 8, 8, x, y, 10, route, 15)) { + cost = static_cast(route.points.size()); + } else { + continue; + } + } + NaviLink entry; + entry.link = link; + entry.cost = cost; + this->data.endLinks.push_back(entry); + } + } + + if (this->data.endLinks.empty()) { + return false; + } + return this->data.SetDestination(info, x, y); +} + +// OFFSET: 0x00BA10C0 +// FUNCTION: fn_19637 +void CNavigationManager::SelectTarget(int nodeIndex) { + this->currentTarget = this->savedTarget; + if (nodeIndex >= 0 && static_cast(nodeIndex) < this->nodes.size()) { + this->currentTarget.type = 6; + this->currentTarget.object = this->nodes[nodeIndex]; + } + this->currentTarget = NavigationTarget(this->currentTarget); + this->LoadTargetPreview(); +} + +// OFFSET: 0x00BA12D0 +// FUNCTION: fn_19641 +void CNavigationManager::CancelRoute() { + this->Reset(false); + this->unknown_125C = 0; + if (!this->unknown_1248) { + this->unknown_1258 = 1; + if (g_navigationWindow != nullptr) { + static_cast(g_navigationWindow)->RefreshLayout(); + } + } + g_windowMgr.SendNotice(1, reinterpret_cast(LookupMessage(2309)), 0x62B0FF, 0, 0, 0); +}