Bazaar developer reference

CvTechAI::Read(FDataStream &)

Defined in
CvTechAI.cpp, line 47
Class
CvTechAI
Hook name
CivHooks::CvTechAI_Read

Hooks

static bool BeforeCvTechAI_Read(CvTechAI* self, FDataStream& kStream);static void AfterCvTechAI_Read(CvTechAI* self, FDataStream& kStream);static void ReplaceCvTechAI_Read(void (*original)(CvTechAI*, FDataStream&), CvTechAI* self, FDataStream& kStream);CivRegisterBefore<CivHooks::CvTechAI_Read>(host, &BeforeCvTechAI_Read);CivRegisterAfter<CivHooks::CvTechAI_Read>(host, &AfterCvTechAI_Read);CivRegisterReplace<CivHooks::CvTechAI_Read>(host, &ReplaceCvTechAI_Read);

Code

46/// Serialization read47void CvTechAI::Read(FDataStream& kStream)48{49	// Version number to maintain backwards compatibility50	uint uiVersion;51	kStream >> uiVersion;52	MOD_SERIALIZE_INIT_READ(kStream);5354	int iWeight;5556	CvAssertMsg(m_pCurrentTechs->GetTechs() != NULL, "Tech AI serialization failure: no tech data");57	CvAssertMsg(m_pCurrentTechs->GetTechs()->GetNumTechs() > 0, "Tech AI serialization failure: number of techs not greater than 0");5859	// Reset vector60	m_TechAIWeights.clear();61	int iTechCount = m_pCurrentTechs->GetTechs()->GetNumTechs();62	m_TechAIWeights.resize(iTechCount);63	for(int i = 0; i < iTechCount; ++i)64		m_TechAIWeights.SetWeight(i, 0);6566	int iCount;67	kStream >> iCount;6869	for(int i = 0; i < iCount; i++)70	{71		int iIndex = CvInfosSerializationHelper::ReadHashed(kStream);72		kStream >> iWeight;73		if(iIndex >= 0 && iIndex < iCount)74			m_TechAIWeights.SetWeight(iIndex, iWeight);75	}76}

Calls

Called by