Hooks
static bool BeforeCvAStar_CreateChildren(CvAStar* self, CvAStarNode* node);static void AfterCvAStar_CreateChildren(CvAStar* self, CvAStarNode* node);static void ReplaceCvAStar_CreateChildren(void (*original)(CvAStar*, CvAStarNode*), CvAStar* self, CvAStarNode* node);CivRegisterBefore<CivHooks::CvAStar_CreateChildren>(host, &BeforeCvAStar_CreateChildren);CivRegisterAfter<CivHooks::CvAStar_CreateChildren>(host, &AfterCvAStar_CreateChildren);CivRegisterReplace<CivHooks::CvAStar_CreateChildren>(host, &ReplaceCvAStar_CreateChildren);
Code
379/// Creates children for the node380void CvAStar::CreateChildren(CvAStarNode* node)381{382 CvAStarNode* check;383 int range = 6;384 int x, y;385 int i;386387 static int s_CvAStarChildHexX[6] = { 0, 1, 1, 0, -1, -1, };388 static int s_CvAStarChildHexY[6] = { 1, 0, -1, -1, 0, 1, };389390 for(i = 0; i < range; i++)391 {392 x = node->m_iX - ((node->m_iY >= 0) ? (node->m_iY>>1) : ((node->m_iY - 1)/2));393 x += s_CvAStarChildHexX[i];394 y = yRange(node->m_iY + s_CvAStarChildHexY[i]);395 x += ((y >= 0) ? (y>>1) : ((y - 1)/2));396 x = xRange(x);397398 PREFETCH_FASTAR_NODE(&(m_ppaaNodes[x][y]));399 if(isValid(x, y))400 {401 check = &(m_ppaaNodes[x][y]);402403 if(udFunc(udValid, node, check, 0, m_pData))404 {405 LinkChild(node, check);406 }407 }408 }409410 if(udNumExtraChildrenFunc && udGetExtraChildFunc)411 {412 int iExtraChildren = udNumExtraChildrenFunc(node, this);413 for(int i = 0; i < iExtraChildren; i++)414 {415 udGetExtraChildFunc(node, i, x, y, this);416 PREFETCH_FASTAR_NODE(&(m_ppaaNodes[x][y]));417418 if(isValid(x, y))419 {420 check = &(m_ppaaNodes[x][y]);421422 if(udFunc(udValid, node, check, 0, m_pData))423 {424 LinkChild(node, check);425 }426 }427 }428 }429}