MCPcopy Create free account
hub / github.com/TombEngine/TombEngine / UpdateLOT

Function UpdateLOT

TombEngine/Game/control/box.cpp:1676–1703  ·  view source on GitHub ↗

* @brief Updates the pathfinding data when the target changes. * * When RequiredBox changes (new target selected), this function: * 1. Sets it as the new TargetBox. * 2. Adds it to the front of the search queue (Head). * 3. Increments SearchNumber to invalidate old search data. * 4. Calls SearchLOT to expand the search. * * The search works BACKWARDS from target to creature - each node's e

Source from the content-addressed store, hash-verified

1674 * @return true if search queue still has nodes to expand, false if exhausted.
1675 */
1676bool UpdateLOT(LOTInfo* LOT, int depth)
1677{
1678 if (LOT->RequiredBox != NO_VALUE && LOT->RequiredBox != LOT->TargetBox)
1679 {
1680 // New target - reset search from this box.
1681 LOT->TargetBox = LOT->RequiredBox;
1682
1683 auto* node = &LOT->Node[LOT->RequiredBox];
1684
1685 // Add target box to front of search queue.
1686 if (node->nextExpansion == NO_VALUE && LOT->Tail != LOT->RequiredBox)
1687 {
1688 node->nextExpansion = LOT->Head;
1689
1690 if (LOT->Head == NO_VALUE)
1691 LOT->Tail = LOT->TargetBox;
1692
1693 LOT->Head = LOT->TargetBox;
1694 }
1695
1696 // New search number invalidates all previous search data.
1697 node->searchNumber = ++LOT->SearchNumber;
1698 node->exitBox = NO_VALUE; // Target has no exit (it IS the destination).
1699 node->cost = 0.0f; // Target box has zero cost.
1700 }
1701
1702 return SearchLOT(LOT, depth);
1703}
1704
1705bool SearchLOT(LOTInfo* LOT, int depth)
1706{

Callers 1

CalculateTargetFunction · 0.85

Calls 1

SearchLOTFunction · 0.85

Tested by

no test coverage detected