Bazaar developer reference

CvPlayer::GetBestSettleAreas(int, int &, int &)

Defined in
CvPlayer.cpp, line 26898
Class
CvPlayer
Hook name
CivHooks::CvPlayer_GetBestSettleAreas

Hooks

static bool BeforeCvPlayer_GetBestSettleAreas(CvPlayer* self, int iMinScore, int& iFirstArea, int& iSecondArea, int& result);static void AfterCvPlayer_GetBestSettleAreas(CvPlayer* self, int iMinScore, int& iFirstArea, int& iSecondArea, int& result);static int ReplaceCvPlayer_GetBestSettleAreas(int (*original)(CvPlayer*, int, int&, int&), CvPlayer* self, int iMinScore, int& iFirstArea, int& iSecondArea);CivRegisterBefore<CivHooks::CvPlayer_GetBestSettleAreas>(host, &BeforeCvPlayer_GetBestSettleAreas);CivRegisterAfter<CivHooks::CvPlayer_GetBestSettleAreas>(host, &AfterCvPlayer_GetBestSettleAreas);CivRegisterReplace<CivHooks::CvPlayer_GetBestSettleAreas>(host, &ReplaceCvPlayer_GetBestSettleAreas);

Code

26897/// Find best continents to settle next two cities; returns number found over minimum26898int CvPlayer::GetBestSettleAreas(int iMinScore, int& iFirstArea, int& iSecondArea)26899{26900	CvArea* pLoopArea;26901	int iLoop;26902	int iBestScore = -1;26903	int iSecondBestScore = -1;26904	int iBestArea = -1;26905	int iSecondBestArea = -1;26906	int iNumFound = 0;26907	int iScore;2690826909	CvMap& theMap = GC.getMap();2691026911	// Find best two scores above minimum26912	for(pLoopArea = theMap.firstArea(&iLoop); pLoopArea != NULL; pLoopArea = theMap.nextArea(&iLoop))26913	{26914		if(!pLoopArea->isWater())26915		{26916			iScore = pLoopArea->getTotalFoundValue();2691726918			if(iScore >= iMinScore)26919			{26920				if(!(GC.getMap().GetAIMapHint() & 4) && !(EconomicAIHelpers::IsAreaSafeForQuickColony(pLoopArea->GetID(), this)))26921				{26922					iScore /= 3;26923				}2692426925				if(iScore > iBestScore)26926				{26927					// Already have a best area?  If so demote to 2nd26928					if(iBestScore > iMinScore)26929					{26930						iSecondBestScore = iBestScore;26931						iSecondBestArea = iBestArea;26932					}26933					iBestArea = pLoopArea->GetID();26934					iBestScore = iScore;26935				}2693626937				else if(iScore > iSecondBestScore)26938				{26939					iSecondBestArea = pLoopArea->GetID();26940					iSecondBestScore = iScore;26941				}26942			}26943		}26944	}2694526946	// Return data26947	iFirstArea = iBestArea;26948	iSecondArea = iSecondBestArea;2694926950	if(iSecondArea != -1)26951	{26952		iNumFound = 2;26953	}26954	else if(iFirstArea != -1)26955	{26956		iNumFound = 1;26957	}26958	return iNumFound;26959}

Calls

Called by