Hooks
static bool BeforeCvWonderProductionAI_Read(CvWonderProductionAI* self, FDataStream& kStream);static void AfterCvWonderProductionAI_Read(CvWonderProductionAI* self, FDataStream& kStream);static void ReplaceCvWonderProductionAI_Read(void (*original)(CvWonderProductionAI*, FDataStream&), CvWonderProductionAI* self, FDataStream& kStream);CivRegisterBefore<CivHooks::CvWonderProductionAI_Read>(host, &BeforeCvWonderProductionAI_Read);CivRegisterAfter<CivHooks::CvWonderProductionAI_Read>(host, &AfterCvWonderProductionAI_Read);CivRegisterReplace<CivHooks::CvWonderProductionAI_Read>(host, &ReplaceCvWonderProductionAI_Read);
Code
65/// Serialization read66void CvWonderProductionAI::Read(FDataStream& kStream)67{68 // Version number to maintain backwards compatibility69 uint uiVersion;70 kStream >> uiVersion;71 MOD_SERIALIZE_INIT_READ(kStream);7273 int iWeight;7475 CvAssertMsg(m_piLatestFlavorValues != NULL && GC.getNumFlavorTypes() > 0, "Number of flavor values to serialize is expected to greater than 0");7677 int iNumFlavors;78 kStream >> iNumFlavors;7980 ArrayWrapper<int> wrapm_piLatestFlavorValues(iNumFlavors, m_piLatestFlavorValues);81 kStream >> wrapm_piLatestFlavorValues;8283 CvAssertMsg(m_pBuildings != NULL, "Wonder Production AI init failure: building entries are NULL");8485 // Reset vector86 m_WonderAIWeights.clear();8788 // Loop through reading each one and adding it to our vector89 if(m_pBuildings)90 {91 for(int i = 0; i < m_pBuildings->GetNumBuildings(); i++)92 {93 m_WonderAIWeights.push_back(i, 0);94 }9596 int iNumEntries;97 int iType;9899 kStream >> iNumEntries;100101 for(int iI = 0; iI < iNumEntries; iI++)102 {103 bool bValid = true;104 iType = CvInfosSerializationHelper::ReadHashed(kStream, &bValid);105 if(iType != -1 || !bValid)106 {107 kStream >> iWeight;108 if(iType != -1)109 {110 m_WonderAIWeights.IncreaseWeight(iType, iWeight);111 }112 else113 {114 CvString szError;115 szError.Format("LOAD ERROR: Building Type not found");116 GC.LogMessage(szError.GetCString());117 CvAssertMsg(false, szError);118 }119 }120 }121 }122}