From e4647a15352430dfd968743c4b6bfb2bd94ca9da Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Wed, 28 Oct 2026 22:37:25 +0000 Subject: [PATCH] Decompile fn_19598 (CNavigationManager::RequestRoute) Batch #1781 by ragnarok-clanker: 0 byte-identical, 1 confirmed by peer review. - fn_19598 CNavigationManager::RequestRoute: logic confirmed by peer review Peer-reviewed-by: Yommy Reviewed-by: ragnarok-clanker --- Source/Contents/NavigationManager.h | 1 + Source/Contents/NavigationRequest.cpp | 67 +++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) diff --git a/Source/Contents/NavigationManager.h b/Source/Contents/NavigationManager.h index ae7815f..7fa6a00 100644 --- a/Source/Contents/NavigationManager.h +++ b/Source/Contents/NavigationManager.h @@ -254,6 +254,7 @@ public: float FitToSquare(int* offsetX, int* offsetY, int width, int height, float size) const; void LoadSettings(); bool BuildRoute(int startX, int startY, int destX, int destY, bool collectCells); + int RequestRoute(int cellX, int cellY); NaviCell* MapCellToView(NaviCell* out, const char* mapName, int cellX, int cellY, float size); std::string RouteText(); void Reset(bool clearAll); diff --git a/Source/Contents/NavigationRequest.cpp b/Source/Contents/NavigationRequest.cpp index 4ed22a1..4aa4a23 100644 --- a/Source/Contents/NavigationRequest.cpp +++ b/Source/Contents/NavigationRequest.cpp @@ -2,6 +2,8 @@ #include "Client/Mode/ActiveGameMode.h" #include "Client/Mode/CGameMode.h" #include "Contents/World/WorldScene.h" +#include "Client/Session.h" +#include "Resource/ResourceMgr.h" #include @@ -94,6 +96,71 @@ bool CNavigationManager::UpdateGround() { return true; } +// OFFSET: 0x00B97200 +// FUNCTION: fn_19598 +int CNavigationManager::RequestRoute(int cellX, int cellY) { + this->selectedNode = -1; + CNaviInfo* info = this->FindObject(g_session.m_navigationPlayerMap); + if (info == nullptr) { + const std::string resolved = ResourceMgr::Instance().aliases.ResolveMapName(g_session.m_navigationPlayerMap); + info = this->FindObject(resolved.c_str()); + if (info == nullptr) { + return -93; + } + } + + CNaviInfo* target = nullptr; + int destX = cellX; + int destY = cellY; + const int type = this->savedTarget.type; + if (type == 3) { + if (info == static_cast(this->savedTarget.object)->GetInfo()) { + return 2; + } + return -99; + } + if (type == 1) { + if (info == this->savedTarget.object) { + return 3; + } + return -99; + } + if (type == 0) { + if (cellX < 0 || cellY < 0) { + return -97; + } + target = static_cast(this->savedTarget.object); + } else if (type == 2) { + CNavi_Object* object = static_cast(this->savedTarget.object); + target = object->GetInfo(); + NaviCell cell; + const NaviCell* result = object->GetCell(&cell); + destX = result->x; + destY = result->y; + } + if (info != target) { + return -99; + } + + int startX = 0; + int startY = 0; + CGameMode* mode = static_cast(g_world.ActiveGameMode()); + if (mode == nullptr) { + return -95; + } + mode->PlayerCell(&startX, &startY); + this->UpdateGround(); + if (!this->BuildRoute(startX, startY, destX, destY, false)) { + return -99; + } + this->data.SetDestination(target, destX, destY); + this->unknown_117C = true; + this->unknown_115C = true; + this->unknown_12B4 = true; + this->unknown_1258 = 2; + return 9; +} + // OFFSET: 0x00B8E350 // FUNCTION: fn_19466 std::vector::iterator CNaviInfo::LinksBegin() {