From ee48eb434035f61ddcc848f51cabc347fc217334 Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Thu, 5 Nov 2026 16:18:10 +0000 Subject: [PATCH] Decompile fn_17882 (CPathFinder::AddNeighbor) Batch #12513 by cremane: 0 byte-identical, 1 confirmed by peer review. - fn_17882 CPathFinder::AddNeighbor: logic confirmed by peer review Peer-reviewed-by: Yommy, dori Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes). --- Source/Contents/TerrainPathSearch.cpp | 52 +++++++++++++-------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/Source/Contents/TerrainPathSearch.cpp b/Source/Contents/TerrainPathSearch.cpp index 57e49348..d91fd32b 100644 --- a/Source/Contents/TerrainPathSearch.cpp +++ b/Source/Contents/TerrainPathSearch.cpp @@ -133,35 +133,35 @@ bool CPathFinder::AddNeighbor(PathNode* current, int cost, int nextX, int nextY, return false; } - if (next->state == 0) { - next->parent = current; - next->state = 1; - next->cost = totalCost; - next->estimatedCost = totalCost + 10 * (std::abs(nextX - this->destinationX) + std::abs(nextY - this->destinationY)); - next->metadata = metadata; - this->openList.Push(next); + if (next->state != 0) { + if (next->cost > totalCost) { + next->parent = current; + next->cost = totalCost; + next->estimatedCost = totalCost + 10 * (std::abs(nextX - this->destinationX) + std::abs(nextY - this->destinationY)); + next->metadata = metadata; + + if (next->state == 1) { + std::vector& open = this->openList.Nodes(); + for (auto it = open.begin(); it != open.end(); ++it) { + if ((*it)->x == next->x && (*it)->y == next->y) { + std::push_heap(open.begin(), it + 1, NodeTotalGreater()); + return true; + } + } + } else if (next->state == 2) { + next->state = 1; + } + } + return true; } - if (next->cost > totalCost) { - next->parent = current; - next->cost = totalCost; - next->estimatedCost = totalCost + 10 * (std::abs(nextX - this->destinationX) + std::abs(nextY - this->destinationY)); - next->metadata = metadata; - - if (next->state == 1) { - std::vector& open = this->openList.Nodes(); - for (auto it = open.begin(); it != open.end(); ++it) { - if ((*it)->x == next->x && (*it)->y == next->y) { - std::push_heap(open.begin(), it + 1, NodeTotalGreater()); - return true; - } - } - } else if (next->state == 2) { - next->state = 1; - } - } - + next->parent = current; + next->state = 1; + next->cost = totalCost; + next->estimatedCost = totalCost + 10 * (std::abs(nextX - this->destinationX) + std::abs(nextY - this->destinationY)); + next->metadata = metadata; + this->openList.Push(next); return true; }