Bazaar developer reference

CvBuilderTaskingAI::Update()

Defined in
CvBuilderTaskingAI.cpp, line 160
Class
CvBuilderTaskingAI
Hook name
CivHooks::CvBuilderTaskingAI_Update

Hooks

static bool BeforeCvBuilderTaskingAI_Update(CvBuilderTaskingAI* self);static void AfterCvBuilderTaskingAI_Update(CvBuilderTaskingAI* self);static void ReplaceCvBuilderTaskingAI_Update(void (*original)(CvBuilderTaskingAI*), CvBuilderTaskingAI* self);CivRegisterBefore<CivHooks::CvBuilderTaskingAI_Update>(host, &BeforeCvBuilderTaskingAI_Update);CivRegisterAfter<CivHooks::CvBuilderTaskingAI_Update>(host, &AfterCvBuilderTaskingAI_Update);CivRegisterReplace<CivHooks::CvBuilderTaskingAI_Update>(host, &ReplaceCvBuilderTaskingAI_Update);

Code

159/// Update160void CvBuilderTaskingAI::Update(void)161{162	UpdateRoutePlots();163	m_iNumCities = m_pPlayer->getNumCities();164165	int iLoop;166	CvCity* pCity;167	for(pCity = m_pPlayer->firstCity(&iLoop); pCity != NULL; pCity = m_pPlayer->nextCity(&iLoop))168	{169		pCity->GetCityStrategyAI()->UpdateBestYields();170	}171172	if(m_bLogging)173	{174		bool bShowOutput = m_pPlayer->isHuman();175176		if(m_pPlayer->IsEmpireUnhappy())177		{178			CvString str = "// Empire Unhappy! //";179			LogInfo(str, m_pPlayer, bShowOutput);180		}181182		// show crisis states183		CvCity* pLoopCity;184		for(pLoopCity = m_pPlayer->firstCity(&iLoop); pLoopCity != NULL; pLoopCity = m_pPlayer->nextCity(&iLoop))185		{186			CvString str;187			str += "// ";188			CvString strCityName;189			strCityName = pLoopCity->getName();190			str += strCityName;191			str += " \\\\";192193			LogInfo(str, m_pPlayer, bShowOutput);194195			for(uint ui = 0; ui < NUM_YIELD_TYPES; ui++)196			{197				//double fYield = pLoopCity->GetCityStrategyAI()->GetYieldAverage((YieldTypes)ui);198				//double fYieldDeficient = pLoopCity->GetCityStrategyAI()->GetDeficientYieldValue((YieldTypes)ui);199				CvString strYield;200				switch(ui)201				{202				case YIELD_FOOD:203					strYield = "food       ";204					break;205				case YIELD_PRODUCTION:206					strYield = "production ";207					break;208				case YIELD_SCIENCE:209					strYield = "science    ";210					break;211				case YIELD_GOLD:212					strYield = "gold       ";213					break;214				case YIELD_CULTURE:215					strYield = "culture    ";216					break;217				case YIELD_FAITH:218					strYield = "faith      ";219					break;220#if defined(MOD_API_UNIFIED_YIELDS_TOURISM)221				case YIELD_TOURISM:222					strYield = "tourism    ";223					break;224#endif225#if defined(MOD_API_UNIFIED_YIELDS_GOLDEN_AGE)226				case YIELD_GOLDEN_AGE_POINTS:227					strYield = "goldenage  ";228					break;229#endif230				}231232				CvString strNumbers;233				strNumbers.Format("%d, %d", pLoopCity->GetCityStrategyAI()->GetBestYieldAverageTimes100((YieldTypes)ui), pLoopCity->GetCityStrategyAI()->GetYieldDeltaTimes100((YieldTypes)ui));234235				//int iYieldAdjusted = (int)workerround(fYield * 100);236				//int iYieldDeficientAdjacent = (int)workerround(fYieldDeficient * 100);237238				//strNumbers.Format("%d / %d", iYieldAdjusted, iYieldDeficientAdjacent);239				strYield += strNumbers;240241				if(ui == pLoopCity->GetCityStrategyAI()->GetFocusYield())242				{243					strYield += " *";244				}245246				//if (iYieldAdjusted < iYieldDeficientAdjacent)247				//{248				//if (GetDeficientYield(pLoopCity, false) != GetDeficientYield(pLoopCity, true))249				//{250				//	strYield += "  Problem, but happiness over is overriding it";251				//}252				//else253				//{254				//	strYield += "  PROBLEM!!";255				//}256				//}257				LogInfo(strYield, m_pPlayer, bShowOutput);258			}259260			str = "\\\\ end ";261			str += strCityName;262			str += " //";263			LogInfo(str, m_pPlayer, bShowOutput);264		}265	}266}

Calls

Called by