Hooks
static bool BeforePathNodeAdd(CvAStarNode* parent, CvAStarNode* node, int data, const void* pointer, CvAStar* finder, int& result);static void AfterPathNodeAdd(CvAStarNode* parent, CvAStarNode* node, int data, const void* pointer, CvAStar* finder, int& result);static int ReplacePathNodeAdd(int (*original)(CvAStarNode*, CvAStarNode*, int, const void*, CvAStar*), CvAStarNode* parent, CvAStarNode* node, int data, const void* pointer, CvAStar* finder);CivRegisterBefore<CivHooks::PathNodeAdd>(host, &BeforePathNodeAdd);CivRegisterAfter<CivHooks::PathNodeAdd>(host, &AfterPathNodeAdd);CivRegisterReplace<CivHooks::PathNodeAdd>(host, &ReplacePathNodeAdd);
Code
1600/// Two layer path finder - if add a new open node with movement left, add a second one assuming stop for turn here1601int PathNodeAdd(CvAStarNode* parent, CvAStarNode* node, int data, const void* pointer, CvAStar* finder)1602{1603 CvAStarNode* pNode;16041605 if(data == ASNL_ADDOPEN || data == ASNL_STARTOPEN)1606 {1607 // Are there movement points left and we're worried about stacking or mountains?1608 if(node->m_iData1 > 0 && !finder->IsPathDest(node->m_iX, node->m_iY) && (!(finder->GetInfo() & MOVE_IGNORE_STACKING) || GC.getMap().plotUnchecked(node->m_iX, node->m_iY)->isMountain()))1609 {1610 // Retrieve another node1611 CvTwoLayerPathFinder* twoLayerFinder = static_cast<CvTwoLayerPathFinder*>(finder);1612 pNode = twoLayerFinder->GetPartialMoveNode(node->m_iX, node->m_iY);1613 pNode->m_iData1 = 0; // Zero out movement1614 pNode->m_iData2 = node->m_iData2;1615 pNode->m_iHeuristicCost = node->m_iHeuristicCost;1616 pNode->m_iKnownCost = node->m_iKnownCost + (PATH_MOVEMENT_WEIGHT * node->m_iData1);1617 pNode->m_iTotalCost = node->m_iTotalCost;1618 pNode->m_iX = node->m_iX;1619 pNode->m_iY = node->m_iY;1620 pNode->m_pParent = node->m_pParent;1621 pNode->m_eCvAStarListType = CVASTARLIST_OPEN;1622 pNode->m_kCostCacheData = node->m_kCostCacheData;1623 finder->AddToOpen(pNode);1624 }1625 }16261627 return 1;1628}