Hooks
static bool BeforeCvReligionAIHelpers_GetBestCityFaithBuildingPurchase(CvPlayer & kPlayer, BuildingTypes eBuilding, ReligionTypes eReligion, CvCity *& result);static void AfterCvReligionAIHelpers_GetBestCityFaithBuildingPurchase(CvPlayer & kPlayer, BuildingTypes eBuilding, ReligionTypes eReligion, CvCity *& result);static CvCity * ReplaceCvReligionAIHelpers_GetBestCityFaithBuildingPurchase(CvCity * (*original)(CvPlayer &, BuildingTypes, ReligionTypes), CvPlayer & kPlayer, BuildingTypes eBuilding, ReligionTypes eReligion);CivRegisterBefore<CivHooks::CvReligionAIHelpers_GetBestCityFaithBuildingPurchase>(host, &BeforeCvReligionAIHelpers_GetBestCityFaithBuildingPurchase);CivRegisterAfter<CivHooks::CvReligionAIHelpers_GetBestCityFaithBuildingPurchase>(host, &AfterCvReligionAIHelpers_GetBestCityFaithBuildingPurchase);CivRegisterReplace<CivHooks::CvReligionAIHelpers_GetBestCityFaithBuildingPurchase>(host, &ReplaceCvReligionAIHelpers_GetBestCityFaithBuildingPurchase);
Code
7396CvCity *CvReligionAIHelpers::GetBestCityFaithBuildingPurchase(CvPlayer &kPlayer, BuildingTypes eBuilding, ReligionTypes eReligion)7397{7398 CvCity *pHolyCity = NULL;7399 CvGameReligions* pReligions = GC.getGame().GetGameReligions();7400 const CvReligion* pMyReligion = pReligions->GetReligion(eReligion, kPlayer.GetID());74017402 // Try to buy in the holy city first7403 if (pMyReligion)7404 {7405 CvPlot* pHolyCityPlot = GC.getMap().plot(pMyReligion->m_iHolyCityX, pMyReligion->m_iHolyCityY);7406 if (pHolyCityPlot)7407 {7408 pHolyCity = pHolyCityPlot->getPlotCity();74097410 if (pHolyCity && (pHolyCity->getOwner() == kPlayer.GetID()) && pHolyCity->IsCanPurchase(true, true, NO_UNIT, eBuilding, NO_PROJECT, YIELD_FAITH))7411 {7412 return pHolyCity;7413 }7414 }7415 }74167417 // Now see if there is another city with our majority religion7418 int iLoop;7419 CvCity* pLoopCity;7420 for(pLoopCity = kPlayer.firstCity(&iLoop); pLoopCity != NULL; pLoopCity = kPlayer.nextCity(&iLoop))7421 {7422 if(pLoopCity == pHolyCity)7423 {7424 continue;7425 }74267427 if(pLoopCity->getOwner() != kPlayer.GetID())7428 {7429 continue;7430 }74317432 if(pLoopCity->IsCanPurchase(true, true, NO_UNIT, eBuilding, NO_PROJECT, YIELD_FAITH))7433 {7434 return pLoopCity;7435 }7436 }74377438 return NULL;7439}