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
This commit is contained in:
ragnarok-clanker 2026-10-27 21:58:46 +00:00
commit 8ae06b0cc7
3 changed files with 61 additions and 0 deletions

View file

@ -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<MovementPathNode*>& open = this->openList.Nodes();
open.erase(open.begin(), open.end());
}

View file

@ -0,0 +1,50 @@
#ifndef RAGNAROK_SOURCE_CONTENTS_TERRAINPATHSEARCH_H
#define RAGNAROK_SOURCE_CONTENTS_TERRAINPATHSEARCH_H
#include "Contents/MovementRouteInterpolation.h"
#include <cstddef>
#include <cstdint>
#include <map>
#include <queue>
#include <vector>
class C3dAttr;
struct MovementPathNodeCompare {
bool operator()(const MovementPathNode* left, const MovementPathNode* right) const {
return left->estimatedCost > right->estimatedCost;
}
};
class MovementOpenList : public std::priority_queue<MovementPathNode*, std::vector<MovementPathNode*>, MovementPathNodeCompare> {
public:
std::vector<MovementPathNode*>& 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<MovementPathNode> nodePool;
/* 1090 */ std::map<int, MovementPathNode*> 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

View file

@ -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,