Bazaar developer reference

CvPlayerAI::AI_updateFoundValues(bool)

Defined in
CvPlayerAI.cpp, line 167
Class
CvPlayerAI
Hook name
CivHooks::CvPlayerAI_AI_updateFoundValues
Overrides
CvPlayer::AI_updateFoundValues(bool)

Hooks

static bool BeforeCvPlayerAI_AI_updateFoundValues(CvPlayerAI* self, bool bStartingLoc);static void AfterCvPlayerAI_AI_updateFoundValues(CvPlayerAI* self, bool bStartingLoc);static void ReplaceCvPlayerAI_AI_updateFoundValues(void (*original)(CvPlayerAI*, bool), CvPlayerAI* self, bool bStartingLoc);CivRegisterBefore<CivHooks::CvPlayerAI_AI_updateFoundValues>(host, &BeforeCvPlayerAI_AI_updateFoundValues);CivRegisterAfter<CivHooks::CvPlayerAI_AI_updateFoundValues>(host, &AfterCvPlayerAI_AI_updateFoundValues);CivRegisterReplace<CivHooks::CvPlayerAI_AI_updateFoundValues>(host, &ReplaceCvPlayerAI_AI_updateFoundValues);

Code

167void CvPlayerAI::AI_updateFoundValues(bool bStartingLoc)168{169	int iGoodEnoughToBeWorthOurTime = GC.getAI_STRATEGY_MINIMUM_SETTLE_FERTILITY();170	int iLoop;171	const int iNumPlots = GC.getMap().numPlots();172	for(CvArea* pLoopArea = GC.getMap().firstArea(&iLoop); pLoopArea != NULL; pLoopArea = GC.getMap().nextArea(&iLoop))173	{174		pLoopArea->setTotalFoundValue(0);175	}176177	const PlayerTypes eID = GetID();178	if(bStartingLoc)179	{180		for(int iI = 0; iI < iNumPlots; iI++)181		{182			GC.getMap().plotByIndexUnchecked(iI)->setFoundValue(eID, -1);183		}184	}185	else186	{187		const TeamTypes eTeam = getTeam();188		GC.getGame().GetSettlerSiteEvaluator()->ComputeFlavorMultipliers(this);189		for (int iI = 0; iI < iNumPlots; iI++)190		{191			CvPlot* pLoopPlot = GC.getMap().plotByIndexUnchecked(iI);192193			if (pLoopPlot->isRevealed(eTeam))194			{195				const int iValue = GC.getGame().GetSettlerSiteEvaluator()->PlotFoundValue(pLoopPlot, this, NO_YIELD, false);196				pLoopPlot->setFoundValue(eID, iValue);197				if (iValue >= iGoodEnoughToBeWorthOurTime)198				{199					CvArea* pLoopArea = GC.getMap().getArea(pLoopPlot->getArea());200					if(pLoopArea && !pLoopArea->isWater())201					{202						pLoopArea->setTotalFoundValue(pLoopArea->getTotalFoundValue() + iValue);203					}204				}205			}206			else207			{208				pLoopPlot->setFoundValue(eID, -1);209			}210		}211	}212}

Calls

Called by