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).
This commit is contained in:
parent
f437beac8b
commit
ee48eb4340
1 changed files with 24 additions and 24 deletions
|
|
@ -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<PathNode*>& 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<PathNode*>& 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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue