/// Serialization read void CvProcessProductionAI::Read(FDataStream& kStream) { // Version number to maintain backwards compatibility uint uiVersion; kStream >> uiVersion; MOD_SERIALIZE_INIT_READ(kStream); int iWeight; // Reset vector m_ProcessAIWeights.clear(); m_ProcessAIWeights.resize(GC.getNumProcessInfos()); for(int i = 0; i < GC.getNumProcessInfos(); ++i) m_ProcessAIWeights.SetWeight(i, 0); // Loop through reading each one and adding it to our vector int iNumProcess; kStream >> iNumProcess; for(int i = 0; i < iNumProcess; i++) { int iType = CvInfosSerializationHelper::ReadHashed(kStream); kStream >> iWeight; if (iType >= 0 && iType < m_ProcessAIWeights.size()) m_ProcessAIWeights.SetWeight(iType, iWeight); } }
/// Serialization read void CvPolicyAI::Read(FDataStream& kStream) { // Version number to maintain backwards compatibility uint uiVersion; kStream >> uiVersion; MOD_SERIALIZE_INIT_READ(kStream); //mod00 int iWeight; CvAssertMsg(m_pCurrentPolicies->GetPolicies() != NULL, "Policy AI serialization failure: no policy data"); CvAssertMsg(m_pCurrentPolicies->GetPolicies()->GetNumPolicies() > 0, "Policy AI serialization failure: number of policies not greater than 0"); // Reset vector m_PolicyAIWeights.clear(); uint uiPolicyArraySize = m_pCurrentPolicies->GetPolicies()->GetNumPolicies(); // Must set to the final size because we might not be adding in sequentially m_PolicyAIWeights.resize(uiPolicyArraySize); // Clear the contents in case we are loading a smaller set for(uint uiIndex = 0; uiIndex < uiPolicyArraySize; ++uiIndex) m_PolicyAIWeights.SetWeight(uiIndex, 0); uint uiPolicyCount; kStream >> uiPolicyCount; for(uint uiIndex = 0; uiIndex < uiPolicyCount; ++uiIndex) { PolicyTypes ePolicy = (PolicyTypes)CvInfosSerializationHelper::ReadHashed(kStream); kStream >> iWeight; if(ePolicy != NO_POLICY && (uint)ePolicy < uiPolicyArraySize) m_PolicyAIWeights.SetWeight((uint)ePolicy, iWeight); } }
/// Read from binary data store void CvArmyAI::Read(FDataStream& kStream) { // Init saved data Reset(); // Version number to maintain backwards compatibility uint uiVersion; kStream >> uiVersion; MOD_SERIALIZE_INIT_READ(kStream); kStream >> m_iID; kStream >> m_eOwner; kStream >> m_iCurrentX; kStream >> m_iCurrentY; kStream >> m_iGoalX; kStream >> m_iGoalY; kStream >> m_eDomainType; kStream >> m_iFormationIndex; kStream >> m_eAIState; kStream >> m_iOperationID; int iEntriesToRead; kStream >> iEntriesToRead; for(int iI = 0; iI < iEntriesToRead; iI++) { CvArmyFormationSlot slot; kStream >> slot; m_FormationEntries.push_back(slot); } }
/// Serialization read void CvTechAI::Read(FDataStream& kStream) { // Version number to maintain backwards compatibility uint uiVersion; kStream >> uiVersion; MOD_SERIALIZE_INIT_READ(kStream); int iWeight; CvAssertMsg(m_pCurrentTechs->GetTechs() != NULL, "Tech AI serialization failure: no tech data"); CvAssertMsg(m_pCurrentTechs->GetTechs()->GetNumTechs() > 0, "Tech AI serialization failure: number of techs not greater than 0"); // Reset vector m_TechAIWeights.clear(); int iTechCount = m_pCurrentTechs->GetTechs()->GetNumTechs(); m_TechAIWeights.resize(iTechCount); for(int i = 0; i < iTechCount; ++i) m_TechAIWeights.SetWeight(i, 0); int iCount; kStream >> iCount; for(int i = 0; i < iCount; i++) { int iIndex = CvInfosSerializationHelper::ReadHashed(kStream); kStream >> iWeight; if(iIndex >= 0 && iIndex < iCount) m_TechAIWeights.SetWeight(iIndex, iWeight); } }
/// reads in danger plots info void CvDangerPlots::Read(FDataStream& kStream) { // Version number to maintain backwards compatibility uint uiVersion; kStream >> uiVersion; MOD_SERIALIZE_INIT_READ(kStream); kStream >> m_ePlayer; kStream >> m_bArrayAllocated; int iGridSize; kStream >> iGridSize; Uninit(); m_DangerPlots = FNEW(CvDangerPlotContents[iGridSize], c_eCiv5GameplayDLL, 0); m_bArrayAllocated = true; for (int i = 0; i < iGridSize; i++) { kStream >> m_DangerPlots[i]; } m_knownUnits.clear(); int iCount; kStream >> iCount; for (int i=0; i<iCount; i++) { int iTemp1,iTemp2; kStream >> iTemp1; kStream >> iTemp2; m_knownUnits.insert( std::make_pair((PlayerTypes)iTemp1,iTemp2) ); } m_bDirty = false; }
/// Serialization read void CvTreasury::Read(FDataStream& kStream) { // Version number to maintain backwards compatibility uint uiVersion; kStream >> uiVersion; MOD_SERIALIZE_INIT_READ(kStream); kStream >> m_iGold; kStream >> m_iGoldPerTurnFromDiplomacy; kStream >> m_iExpensePerTurnUnitMaintenance; kStream >> m_iExpensePerTurnUnitSupply; kStream >> m_iCityConnectionGoldTimes100; kStream >> m_iCityConnectionTradeRouteGoldModifier; kStream >> m_iCityConnectionTradeRouteGoldChange; kStream >> m_iBaseBuildingGoldMaintenance; kStream >> m_iBaseImprovementGoldMaintenance; kStream >> m_GoldBalanceForTurnTimes100; kStream >> m_GoldChangeForTurnTimes100; kStream >> m_iLifetimeGrossGoldIncome; #if defined(MOD_BALANCE_CORE) kStream >> m_iInternalTradeGoldBonus; #endif #if defined(MOD_DIPLOMACY_CIV4_FEATURES) MOD_SERIALIZE_READ(73, kStream, m_iExpensePerTurnFromVassalTax, 0); #endif }
/// Serialization read void CvGrandStrategyAI::Read(FDataStream& kStream) { // Version number to maintain backwards compatibility uint uiVersion; kStream >> uiVersion; MOD_SERIALIZE_INIT_READ(kStream); kStream >> m_iNumTurnsSinceActiveSet; kStream >> (int&)m_eActiveGrandStrategy; FAssertMsg(m_pAIGrandStrategies != NULL && m_pAIGrandStrategies->GetNumAIGrandStrategies() > 0, "Number of AIGrandStrategies to serialize is expected to greater than 0"); #ifdef _MSC_VER // JAR - if m_pAIGrandStrategies can be NULL at this point, // the load will fail if the data isn't read. Better to crash // here where the problem is than defer it. #pragma warning ( push ) #pragma warning ( disable : 6011 ) #endif//_MSC_VER ArrayWrapper<int> wrapm_paiGrandStrategyPriority(m_pAIGrandStrategies->GetNumAIGrandStrategies(), m_paiGrandStrategyPriority); #ifdef _MSC_VER #pragma warning ( pop ) #endif//_MSC_VER kStream >> wrapm_paiGrandStrategyPriority; ArrayWrapper<int> wrapm_eGuessOtherPlayerActiveGrandStrategy(MAX_MAJOR_CIVS, m_eGuessOtherPlayerActiveGrandStrategy); kStream >> wrapm_eGuessOtherPlayerActiveGrandStrategy; ArrayWrapper<int> wrapm_eGuessOtherPlayerActiveGrandStrategyConfidence(MAX_MAJOR_CIVS, m_eGuessOtherPlayerActiveGrandStrategyConfidence); kStream >> wrapm_eGuessOtherPlayerActiveGrandStrategyConfidence; }
//------------------------------------------------------------------------------ void CvPlayerAchievements::Read(FDataStream& kStream) { int iVersion = 0; kStream >> iVersion; MOD_SERIALIZE_INIT_READ(kStream); kStream >> m_iAchievement_XP1_32_Progress; kStream >> m_iAchievement_XP1_33_Progress; }
bool CvReplayInfo::read(FDataStream& kStream) { bool bSuccess = true; int iVersion; kStream >> iVersion; MOD_SERIALIZE_INIT_READ(kStream); //mod00 kStream >> m_iActivePlayer; kStream >> m_strMapScriptName; kStream >> m_eWorldSize; kStream >> m_eClimate; kStream >> m_eSeaLevel; kStream >> m_eEra; kStream >> m_eGameSpeed; kStream >> m_listGameOptions; kStream >> m_listVictoryTypes; kStream >> m_eVictoryType; kStream >> m_eGameType; kStream >> m_iInitialTurn; kStream >> m_iStartYear; kStream >> m_iFinalTurn; kStream >> m_strFinalDate; kStream >> m_eCalendar; kStream >> m_iNormalizedScore; kStream >> m_listPlayerInfo; kStream >> m_dataSetMap; kStream >> m_listPlayerDataSets; unsigned int uiReplayMessageVersion = 2; kStream >> uiReplayMessageVersion; unsigned int uiReplayMessageCount = 0; kStream >> uiReplayMessageCount; m_listReplayMessages.clear(); m_listReplayMessages.reserve(uiReplayMessageCount); for(unsigned int ui = 0; ui < uiReplayMessageCount; ++ui) { CvReplayMessage message; message.read(kStream, uiReplayMessageVersion); m_listReplayMessages.push_back(message); } kStream >> m_iMapWidth; kStream >> m_iMapHeight; kStream >> m_listPlots; return bSuccess; }
void CvRandom::read(FDataStream& kStream) { reset(); // Version number to maintain backwards compatibility uint uiVersion; kStream >> uiVersion; MOD_SERIALIZE_INIT_READ(kStream); kStream >> m_ullRandomSeed; kStream >> m_ulCallCount; kStream >> m_ulResetCount; bool bDummy; kStream >> bDummy; }
/// Serialization read void CvBuildingProductionAI::Read(FDataStream& kStream) { // Version number to maintain backwards compatibility uint uiVersion; kStream >> uiVersion; MOD_SERIALIZE_INIT_READ(kStream); // Reset vector m_BuildingAIWeights.clear(); // Loop through reading each one and adding it to our vector if(m_pCityBuildings) { for(int i = 0; i < m_pCityBuildings->GetPossibleBuildings()->GetNumBuildings(); i++) { m_BuildingAIWeights.push_back(i, 0); } int iNumEntries; FStringFixedBuffer(sTemp, 64); int iType; kStream >> iNumEntries; for(int iI = 0; iI < iNumEntries; iI++) { bool bValid = true; iType = CvInfosSerializationHelper::ReadHashed(kStream, &bValid); if(iType != -1 || !bValid) { int iWeight; kStream >> iWeight; if(iType != -1) { m_BuildingAIWeights.IncreaseWeight(iType, iWeight); } else { CvString szError; szError.Format("LOAD ERROR: Building Type not found"); GC.LogMessage(szError.GetCString()); CvAssertMsg(false, szError); } } } }
/// Serialization read void CvFlavorManager::Read(FDataStream& kStream) { // Version number to maintain backwards compatibility uint uiVersion; kStream >> uiVersion; MOD_SERIALIZE_INIT_READ(kStream); CvAssertMsg(GC.getNumFlavorTypes() > 0, "Number of flavors to serialize is expected to greater than 0)"); int iNumFlavors; kStream >> iNumFlavors; ArrayWrapper<int> wrapm_piPersonalityFlavor(iNumFlavors, m_piPersonalityFlavor); kStream >> wrapm_piPersonalityFlavor; ArrayWrapper<int> wrapm_piActiveFlavor(iNumFlavors, m_piActiveFlavor); kStream >> wrapm_piActiveFlavor; }
/// Serialization read void CvProjectProductionAI::Read(FDataStream& kStream) { // Version number to maintain backwards compatibility uint uiVersion; kStream >> uiVersion; MOD_SERIALIZE_INIT_READ(kStream); //mod00 int iWeight; // Reset vector m_ProjectAIWeights.clear(); // Loop through reading each one and adding it to our vector for(int i = 0; i < GC.GetGameProjects()->GetNumProjects(); i++) { kStream >> iWeight; m_ProjectAIWeights.push_back(i, iWeight); } }
void VoteSelectionData::read(FDataStream& kStream) { // Version number to maintain backwards compatibility uint uiVersion; kStream >> uiVersion; MOD_SERIALIZE_INIT_READ(kStream); kStream >> iId; kStream >> eVoteSource; size_t iSize; kStream >> iSize; size_t i = 0; for(i = 0; i < iSize; ++i) { VoteSelectionSubData kData; kStream >> kData.eVote; kStream >> kData.ePlayer; kStream >> kData.iCityId; kStream >> kData.eOtherPlayer; kStream >> kData.strText; aVoteOptions.push_back(kData); } }
void CvRandom::read(FDataStream& kStream) { reset(); // Version number to maintain backwards compatibility uint uiVersion; kStream >> uiVersion; MOD_SERIALIZE_INIT_READ(kStream); //mod00 kStream >> m_ulRandomSeed; kStream >> m_ulCallCount; kStream >> m_ulResetCount; #ifdef _DEBUG kStream >> m_bExtendedCallStackDebugging; if(m_bExtendedCallStackDebugging) { kStream >> m_seedHistory; kStream >> m_resolvedCallStacks; } #else bool b; kStream >> b; #endif//_DEBUG }
// // read object from a stream // void PopupReturn::read(FDataStream& kStream) { // Version number to maintain backwards compatibility uint uiVersion; kStream >> uiVersion; MOD_SERIALIZE_INIT_READ(kStream); int iSize; int iValue; int i; kStream >> iSize ; for(i = 0; i < iSize; i++) { kStream >> iValue ; CvPopup_SetAtGrow(m_aiSelectedRadioButton, i, iValue); } kStream >> iSize ; for(i = 0; i < iSize; i++) { kStream >> iValue ; CvPopup_SetAtGrow(m_aiBitField, i, iValue); } kStream >> iSize ; for(i = 0; i < iSize; i++) { CvString strValue; kStream >> strValue ; CvPopup_SetAtGrow(m_aszEditBoxString, i, strValue); } kStream >> iSize ; for(i = 0; i < iSize; i++) { kStream >> iValue ; CvPopup_SetAtGrow(m_aiSpinnerWidgetValues, i, iValue); } kStream >> iSize ; for(i = 0; i < iSize; i++) { kStream >> iValue ; CvPopup_SetAtGrow(m_aiPulldownID, i, iValue); } kStream >> iSize ; for(i = 0; i < iSize; i++) { kStream >> iValue ; CvPopup_SetAtGrow(m_aiListBoxID, i, iValue); } kStream >> iSize ; for(i = 0; i < iSize; i++) { kStream >> iValue ; CvPopup_SetAtGrow(m_aiSpinBoxID, i, iValue); } kStream >> iSize ; for(i = 0; i < iSize; i++) { kStream >> iValue ; CvPopup_SetAtGrow(m_aiButtonID, i, iValue); } }