Bazaar developer reference

CvPolicyAI::Reset()

Defined in
CvPolicyAI.cpp, line 29
Class
CvPolicyAI
Hook name
CivHooks::CvPolicyAI_Reset

Hooks

static bool BeforeCvPolicyAI_Reset(CvPolicyAI* self);static void AfterCvPolicyAI_Reset(CvPolicyAI* self);static void ReplaceCvPolicyAI_Reset(void (*original)(CvPolicyAI*), CvPolicyAI* self);CivRegisterBefore<CivHooks::CvPolicyAI_Reset>(host, &BeforeCvPolicyAI_Reset);CivRegisterAfter<CivHooks::CvPolicyAI_Reset>(host, &AfterCvPolicyAI_Reset);CivRegisterReplace<CivHooks::CvPolicyAI_Reset>(host, &ReplaceCvPolicyAI_Reset);

Code

28/// Clear out AI local variables29void CvPolicyAI::Reset()30{31	m_PolicyAIWeights.clear();32	m_iPolicyWeightPropagationLevels = GC.getPOLICY_WEIGHT_PROPAGATION_LEVELS();33	m_iPolicyWeightPercentDropNewBranch = GC.getPOLICY_WEIGHT_PERCENT_DROP_NEW_BRANCH();3435	CvAssertMsg(m_pCurrentPolicies != NULL, "Policy AI init failure: player policy data is NULL");36	if(m_pCurrentPolicies != NULL)37	{38		CvPolicyXMLEntries* pPolicyEntries = m_pCurrentPolicies->GetPolicies();39		CvAssertMsg(pPolicyEntries != NULL, "Policy AI init failure: no policy data");40		if(pPolicyEntries != NULL)41		{42			// Loop through reading each one and add an entry with 0 weight to our vector43			const int nPolicyEntries = pPolicyEntries->GetNumPolicies();44			for(int i = 0; i < nPolicyEntries; i++)45			{46				m_PolicyAIWeights.push_back(i, 0);47			}48		}49	}50}

Calls

Called by