Bazaar developer reference

CvCityStrategyAI::LogPossibleBuilds()

Defined in
CvCityStrategyAI.cpp, line 1924
Class
CvCityStrategyAI
Hook name
CivHooks::CvCityStrategyAI_LogPossibleBuilds

Hooks

static bool BeforeCvCityStrategyAI_LogPossibleBuilds(CvCityStrategyAI* self);static void AfterCvCityStrategyAI_LogPossibleBuilds(CvCityStrategyAI* self);static void ReplaceCvCityStrategyAI_LogPossibleBuilds(void (*original)(CvCityStrategyAI*), CvCityStrategyAI* self);CivRegisterBefore<CivHooks::CvCityStrategyAI_LogPossibleBuilds>(host, &BeforeCvCityStrategyAI_LogPossibleBuilds);CivRegisterAfter<CivHooks::CvCityStrategyAI_LogPossibleBuilds>(host, &AfterCvCityStrategyAI_LogPossibleBuilds);CivRegisterReplace<CivHooks::CvCityStrategyAI_LogPossibleBuilds>(host, &ReplaceCvCityStrategyAI_LogPossibleBuilds);

Code

1923/// Log all potential builds1924void CvCityStrategyAI::LogPossibleBuilds()1925{1926	if(GC.getLogging() && GC.getAILogging())1927	{1928		CvString strOutBuf;1929		CvString strBaseString;1930		CvString strTemp;1931		CvString playerName;1932		CvString cityName;1933		CvString strDesc;19341935		// Find the name of this civ and city1936		playerName = GET_PLAYER(m_pCity->getOwner()).getCivilizationShortDescription();1937		cityName = m_pCity->getName();19381939		// Open the log file1940		FILogFile* pLog;1941		pLog = LOGFILEMGR.GetLog(GetLogFileName(playerName, cityName), FILogFile::kDontTimeStamp);19421943		// Get the leading info for this line1944		strBaseString.Format("%03d, ", GC.getGame().getElapsedGameTurns());1945		strBaseString += playerName + ", " + cityName + ", ";19461947		// Dump out the weight of each buildable item1948		for(int iI = 0; iI < m_Buildables.size(); iI++)1949		{1950			CvCityBuildable buildable = m_Buildables.GetElement(iI);19511952			switch(buildable.m_eBuildableType)1953			{1954			case CITY_BUILDABLE_BUILDING:1955			{1956				CvBuildingEntry* pEntry = GC.GetGameBuildings()->GetEntry(buildable.m_iIndex);1957				if(pEntry != NULL)1958				{1959					strDesc = pEntry->GetDescription();1960					strTemp.Format("Building, %s, %d, %d", strDesc.GetCString(), m_Buildables.GetWeight(iI), buildable.m_iTurnsToConstruct);1961				}1962			}1963			break;1964			case CITY_BUILDABLE_UNIT:1965			{1966				CvUnitEntry* pEntry = GC.GetGameUnits()->GetEntry(buildable.m_iIndex);1967				if(pEntry != NULL)1968				{1969					strDesc = pEntry->GetDescription();1970					strTemp.Format("Unit, %s, %d, %d", strDesc.GetCString(), m_Buildables.GetWeight(iI), buildable.m_iTurnsToConstruct);1971				}1972			}1973			break;1974			case CITY_BUILDABLE_PROJECT:1975			{1976				CvProjectEntry* pEntry = GC.GetGameProjects()->GetEntry(buildable.m_iIndex);1977				if(pEntry != NULL)1978				{1979					strDesc = pEntry->GetDescription();1980					strTemp.Format("Project, %s, %d, %d", strDesc.GetCString(), m_Buildables.GetWeight(iI), buildable.m_iTurnsToConstruct);1981				}1982			}1983			break;1984			case CITY_BUILDABLE_PROCESS:1985			{1986				CvProcessInfo* pProcess = GC.getProcessInfo((ProcessTypes)buildable.m_iIndex);1987				if (pProcess != NULL)1988				{1989					strDesc = pProcess->GetDescription();1990					strTemp.Format("Process, %s, %d, %d", strDesc.GetCString(), m_Buildables.GetWeight(iI), buildable.m_iTurnsToConstruct);1991				}1992			}1993			break;1994			case CITY_BUILDABLE_UNIT_FOR_OPERATION:1995			{1996				CvUnitEntry* pEntry = GC.GetGameUnits()->GetEntry(buildable.m_iIndex);1997				if(pEntry != NULL)1998				{1999					strDesc = pEntry->GetDescription();2000					strTemp.Format("Operation unit, %s, %d, %d", strDesc.GetCString(), m_Buildables.GetWeight(iI), buildable.m_iTurnsToConstruct);2001				}2002			}2003			break;2004			case CITY_BUILDABLE_UNIT_FOR_ARMY:2005			{2006				CvUnitEntry* pEntry = GC.GetGameUnits()->GetEntry(buildable.m_iIndex);2007				if(pEntry != NULL)2008				{2009					strDesc = pEntry->GetDescription();2010					strTemp.Format("Army unit, %s, %d, %d", strDesc.GetCString(), m_Buildables.GetWeight(iI), buildable.m_iTurnsToConstruct);2011				}2012			}2013			break;2014			}2015			strOutBuf = strBaseString + strTemp;2016			pLog->Msg(strOutBuf);2017		}2018	}2019}

Calls

Called by