RouteGetNumExtraChildren(CvAStarNode *, CvAStar *)
- Defined in
- CvAStar.cpp, line 2497
- Hook name
CivHooks::RouteGetNumExtraChildren
Hooks
static bool BeforeRouteGetNumExtraChildren(CvAStarNode* node, CvAStar* finder, int& result);static void AfterRouteGetNumExtraChildren(CvAStarNode* node, CvAStar* finder, int& result);static int ReplaceRouteGetNumExtraChildren(int (*original)(CvAStarNode*, CvAStar*), CvAStarNode* node, CvAStar* finder);CivRegisterBefore<CivHooks::RouteGetNumExtraChildren>(host, &BeforeRouteGetNumExtraChildren);CivRegisterAfter<CivHooks::RouteGetNumExtraChildren>(host, &AfterRouteGetNumExtraChildren);CivRegisterReplace<CivHooks::RouteGetNumExtraChildren>(host, &ReplaceRouteGetNumExtraChildren);
Code
2495// Route - find the number of additional children. In this case, the node is at a city, push all other cities that the city has a water connection to2496// This function does not require the global Tactical Analysis Map.2497int RouteGetNumExtraChildren(CvAStarNode* node, CvAStar* finder)2498{2499 PlayerTypes ePlayer = ((PlayerTypes)(finder->GetInfo() & 0xFF));2500 CvPlayerAI& kPlayer = GET_PLAYER(ePlayer);2501 TeamTypes eTeam = kPlayer.getTeam();2502 CvPlot* pPlot = GC.getMap().plotCheckInvalid(node->m_iX, node->m_iY);25032504 if(!pPlot)2505 {2506 return 0;2507 }25082509 // slewis - don't allow the minor civ to use harbors2510 if(kPlayer.isMinorCiv())2511 {2512 return 0;2513 }25142515 CvCityConnections* pCityConnections = kPlayer.GetCityConnections();2516 if(pCityConnections->IsEmpty())2517 {2518 return 0;2519 }25202521 int iResultNum = 0;25222523 CvCity* pCity = pPlot->getPlotCity();25242525 // if there isn't a city there or the city isn't on our team2526 if(!pCity || pCity->getTeam() != eTeam)2527 {2528 return 0;2529 }25302531 uint uiFirstCityIndex = pCityConnections->GetIndexFromCity(pCity);2532 if(uiFirstCityIndex >= pCityConnections->m_aiCityPlotIDs.size())2533 {2534 CvAssertMsg(false, "City index out of bounds");2535 return 0;2536 }25372538 for(uint uiSecondCityIndex = 0; uiSecondCityIndex < pCityConnections->m_aiCityPlotIDs.size(); uiSecondCityIndex++)2539 {2540 if(uiFirstCityIndex == uiSecondCityIndex)2541 {2542 continue;2543 }25442545 CvCityConnections::RouteInfo* pRouteInfo = pCityConnections->GetRouteInfo(uiFirstCityIndex, uiSecondCityIndex);2546 if(!pRouteInfo)2547 {2548 continue;2549 }25502551 // get the two cities2552 CvCity* pFirstCity = pCityConnections->GetCityFromIndex(uiFirstCityIndex);2553 CvCity* pSecondCity = pCityConnections->GetCityFromIndex(uiSecondCityIndex);25542555 if(!pFirstCity || !pSecondCity)2556 {2557 continue;2558 }25592560#if defined(MOD_EVENTS_CITY_CONNECTIONS)2561 if(pRouteInfo->m_cRouteState & CvCityConnections::HAS_INDIRECT_ROUTE)2562#else2563 if(pRouteInfo->m_cRouteState & CvCityConnections::HAS_WATER_ROUTE)2564#endif2565 {2566 iResultNum++;2567 }2568 }25692570 return iResultNum;2571}
Calls
BaseVector::size- CvAStar::GetInfo()
- CvCity::getTeam() const
- CvCityConnections::GetCityFromIndex(int)
- CvCityConnections::GetIndexFromCity(CvCity *)
- CvCityConnections::GetRouteInfo(uint, uint)
- CvCityConnections::IsEmpty()
- CvGlobals::getMap()
- CvMap::plotCheckInvalid(int, int) const
- CvPlayer::GetCityConnections() const
- CvPlayer::getTeam() const
- CvPlayer::isMinorCiv() const
- CvPlayerAI::getPlayer(PlayerTypes)
- CvPlot::getPlotCity() const