CvUnitProductionAI::Read(FDataStream &)
- Defined in
- CvUnitProductionAI.cpp, line 50
- Class
- CvUnitProductionAI
- Hook name
CivHooks::CvUnitProductionAI_Read
Hooks
static bool BeforeCvUnitProductionAI_Read(CvUnitProductionAI* self, FDataStream& kStream);static void AfterCvUnitProductionAI_Read(CvUnitProductionAI* self, FDataStream& kStream);static void ReplaceCvUnitProductionAI_Read(void (*original)(CvUnitProductionAI*, FDataStream&), CvUnitProductionAI* self, FDataStream& kStream);CivRegisterBefore<CivHooks::CvUnitProductionAI_Read>(host, &BeforeCvUnitProductionAI_Read);CivRegisterAfter<CivHooks::CvUnitProductionAI_Read>(host, &AfterCvUnitProductionAI_Read);CivRegisterReplace<CivHooks::CvUnitProductionAI_Read>(host, &ReplaceCvUnitProductionAI_Read);
Code
49/// Serialization read50void CvUnitProductionAI::Read(FDataStream& kStream)51{52 // Version number to maintain backwards compatibility53 uint uiVersion;54 kStream >> uiVersion;55 MOD_SERIALIZE_INIT_READ(kStream);5657 int iWeight;5859 // Reset vector60 m_UnitAIWeights.clear();6162 // Loop through reading each one and adding it to our vector63 if(m_pUnits)64 {65 for(int i = 0; i < m_pUnits->GetNumUnits(); i++)66 {67 m_UnitAIWeights.push_back(i, 0);68 }6970 int iNumEntries;71 int iType;7273 kStream >> iNumEntries;7475 for(int iI = 0; iI < iNumEntries; iI++)76 {77 bool bValid = true;78 iType = CvInfosSerializationHelper::ReadHashed(kStream, &bValid);79 if(iType != -1 || !bValid)80 {81 kStream >> iWeight;82 if(iType != -1)83 {84 m_UnitAIWeights.IncreaseWeight(iType, iWeight);85 }86 else87 {88 CvString szError;89 szError.Format("LOAD ERROR: Unit Type not found");90 GC.LogMessage(szError.GetCString());91 CvAssertMsg(false, szError);92 }93 }94 }95 }96 else97 {98 CvAssertMsg(m_pUnits != NULL, "Unit Production AI init failure: unit entries are NULL");99 }100}
Calls
- CvGlobals::LogMessage(const char *)
- CvInfosSerializationHelper::ReadHashed(FDataStream &, bool *)
CvString::CvStringCvString::FormatCvString::GetCString- CvUnitXMLEntries::GetNumUnits()
CvWeightedVector::clearCvWeightedVector::IncreaseWeightCvWeightedVector::push_backFDataStream::operator>>FDataStream::operator>>