Bazaar developer reference

CvPolicyAI::LogPossiblePolicies()

Defined in
CvPolicyAI.cpp, line 890
Class
CvPolicyAI
Hook name
CivHooks::CvPolicyAI_LogPossiblePolicies

Hooks

static bool BeforeCvPolicyAI_LogPossiblePolicies(CvPolicyAI* self);static void AfterCvPolicyAI_LogPossiblePolicies(CvPolicyAI* self);static void ReplaceCvPolicyAI_LogPossiblePolicies(void (*original)(CvPolicyAI*), CvPolicyAI* self);CivRegisterBefore<CivHooks::CvPolicyAI_LogPossiblePolicies>(host, &BeforeCvPolicyAI_LogPossiblePolicies);CivRegisterAfter<CivHooks::CvPolicyAI_LogPossiblePolicies>(host, &AfterCvPolicyAI_LogPossiblePolicies);CivRegisterReplace<CivHooks::CvPolicyAI_LogPossiblePolicies>(host, &ReplaceCvPolicyAI_LogPossiblePolicies);

Code

889/// Log all possible policy choices890void CvPolicyAI::LogPossiblePolicies()891{892	if(GC.getLogging() && GC.getAILogging())893	{894		CvString strOutBuf;895		CvString strBaseString;896		CvString strTemp;897		CvString playerName;898		CvString strDesc;899900		// Find the name of this civ and city901		playerName = m_pCurrentPolicies->GetPlayer()->getCivilizationShortDescription();902903		FILogFile* pLog;904		pLog = LOGFILEMGR.GetLog(GetLogFileName(playerName), FILogFile::kDontTimeStamp);905906		// Get the leading info for this line907		strBaseString.Format("%03d, ", GC.getGame().getElapsedGameTurns());908		strBaseString += playerName + ", ";909910		int iNumBranches = GC.getNumPolicyBranchInfos();911912		// Dump out the weight of each possible policy913		for(int iI = 0; iI < m_AdoptablePolicies.size(); iI++)914		{915			int iWeight = m_AdoptablePolicies.GetWeight(iI);916917			if(m_AdoptablePolicies.GetElement(iI) < iNumBranches)918			{919				strTemp.Format("Branch %d, %d", m_AdoptablePolicies.GetElement(iI), iWeight);920			}921			else922			{923924				PolicyTypes ePolicy = (PolicyTypes)(m_AdoptablePolicies.GetElement(iI) - iNumBranches);925				CvPolicyEntry* pPolicyEntry = GC.getPolicyInfo(ePolicy);926				const char* szPolicyType = (pPolicyEntry != NULL)? pPolicyEntry->GetType() : "Unknown";927				strTemp.Format("%s, %d", szPolicyType, iWeight);928			}929			strOutBuf = strBaseString + strTemp;930			pLog->Msg(strOutBuf);931		}932	}933}

Calls

Called by