From 8ae06b0cc7eabb0c18fc8be57123215618ffae3a Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Tue, 27 Oct 2026 21:58:46 +0000 Subject: [PATCH] Decompile fn_17885 (CPathFinder::Reset) Batch #1214 by eAthena: 0 byte-identical, 1 confirmed by peer review. - fn_17885 CPathFinder::Reset: logic confirmed by peer review Peer-reviewed-by: ragnarok-clanker Reviewed-by: ragnarok-clanker Adds to the build: Source/Contents/TerrainPathSearch.cpp --- Source/Contents/TerrainPathSearch.cpp | 10 ++++++ Source/Contents/TerrainPathSearch.h | 50 +++++++++++++++++++++++++++ data/compile.json | 1 + 3 files changed, 61 insertions(+) create mode 100644 Source/Contents/TerrainPathSearch.cpp create mode 100644 Source/Contents/TerrainPathSearch.h diff --git a/Source/Contents/TerrainPathSearch.cpp b/Source/Contents/TerrainPathSearch.cpp new file mode 100644 index 0000000..5157e6e --- /dev/null +++ b/Source/Contents/TerrainPathSearch.cpp @@ -0,0 +1,10 @@ +#include "Contents/TerrainPathSearch.h" + +// OFFSET: 0x00AD9840 +// FUNCTION: fn_17885 +void CPathFinder::Reset() { + this->nodePool.erase(this->nodePool.begin(), this->nodePool.end()); + this->nodeMap.erase(this->nodeMap.begin(), this->nodeMap.end()); + std::vector& open = this->openList.Nodes(); + open.erase(open.begin(), open.end()); +} diff --git a/Source/Contents/TerrainPathSearch.h b/Source/Contents/TerrainPathSearch.h new file mode 100644 index 0000000..222d2e6 --- /dev/null +++ b/Source/Contents/TerrainPathSearch.h @@ -0,0 +1,50 @@ +#ifndef RAGNAROK_SOURCE_CONTENTS_TERRAINPATHSEARCH_H +#define RAGNAROK_SOURCE_CONTENTS_TERRAINPATHSEARCH_H + +#include "Contents/MovementRouteInterpolation.h" + +#include +#include +#include +#include +#include + +class C3dAttr; + +struct MovementPathNodeCompare { + bool operator()(const MovementPathNode* left, const MovementPathNode* right) const { + return left->estimatedCost > right->estimatedCost; + } +}; + +class MovementOpenList : public std::priority_queue, MovementPathNodeCompare> { +public: + std::vector& Nodes() { + return this->c; + } +}; + +class CPathFinder { +public: + /* 0000 */ C3dAttr* attr; + /* 0004 */ int destinationX; + /* 0008 */ int destinationY; + /* 000C */ int nodeCount; + /* 0010 */ MovementPathNode nodes[150]; + /* 1078 */ std::uint8_t unknown_1078[8]; + /* 1080 */ bool useNodePool; + /* 1084 */ std::vector nodePool; + /* 1090 */ std::map nodeMap; + /* 1098 */ MovementOpenList openList; + + void Reset(); +}; + +#if defined(_WIN32) && !defined(_WIN64) +static_assert(offsetof(CPathFinder, unknown_1078) == 0x1078); +static_assert(offsetof(CPathFinder, nodePool) == 0x1084); +static_assert(offsetof(CPathFinder, nodeMap) == 0x1090); +static_assert(offsetof(CPathFinder, openList) == 0x1098); +#endif + +#endif diff --git a/data/compile.json b/data/compile.json index 7ea22e3..6403c08 100644 --- a/data/compile.json +++ b/data/compile.json @@ -397,6 +397,7 @@ "Source/Contents/Store/MCStoreInfoBackup.cpp": 4, "Source/Contents/Store/MCStoreInfoBackupAsyncWork.cpp": 4, "Source/Contents/Store/StoreBackupData.cpp": 4, + "Source/Contents/TerrainPathSearch.cpp": 4, "Source/Contents/TipBoxTitles.cpp": 4, "Source/Contents/UserData/AccountLinkedUserDataLoadAsyncWork.cpp": 4, "Source/Contents/UserData/AccountLinkedUserDataMgr.cpp": 4,