void AgreementPool::Serialize(CivArchive &archive) { AgreementData *newData ; sint32 i, count = 0 ; CHECKSERIALIZE #define AGREEMENTPOOL_MAGIC 0x28400399 if (archive.IsStoring()) { } else { if(g_saveFileVersion < 55) { archive.TestMagic(AGREEMENTPOOL_MAGIC) ; archive>>count; for (i=0; i<count; i++) { newData = new AgreementData(archive) ; Insert(newData) ; } } }
void ArmyPool::Serialize(CivArchive &archive) { sint32 count, i; #define ARMYPOOL_MAGIC 0xBeefCafe if(archive.IsStoring()) { archive.PerformMagic(ARMYPOOL_MAGIC); ObjPool::Serialize(archive); count = 0; for(i = 0; i < k_OBJ_POOL_TABLE_SIZE; i++) { if(m_table[i]) count++; } archive << count; for(i = 0; i < k_OBJ_POOL_TABLE_SIZE; i++) { if(m_table[i]) ((ArmyData*)(m_table[i]))->Serialize(archive); } } else { archive.TestMagic(ARMYPOOL_MAGIC); ObjPool::Serialize(archive); archive >> count; for(i = 0; i < count; i++) { ArmyData *data = new ArmyData(archive); Insert(data); } } }
void Squad_Strength::Serialize(CivArchive &archive) { if (archive.IsStoring()) { archive.Store((uint8*)this, sizeof(Squad_Strength)); } else { archive.Load((uint8*)this, sizeof(Squad_Strength)); } }
void BSetID::Serialize(CivArchive &archive) { if (archive.IsStoring()) { archive << val; } else { archive >> val; } }
void C3String::Serialize(CivArchive &archive) { if (archive.IsStoring()) { archive << m_refCount; } else { archive >> m_refCount; } }
void AchievementTracker::Serialize(CivArchive &archive) { if(archive.IsStoring()) { } else { if(g_saveFileVersion < 55) { archive >> m_achievements; } }
void TradeBids::Bid::Serialize(CivArchive &archive) { if(archive.IsStoring()) { Assert(FALSE); } else { if(g_saveFileVersion < 55) { archive.LoadChunk((uint8*)&m_id, (uint8*)&m_price + sizeof(m_price)); } } }
void TaxRate::Serialize(CivArchive &archive) { if (archive.IsStoring()) { archive << m_science; archive << m_science_before_anarchy; } else { archive >> m_science; archive >> m_science_before_anarchy; } }
void Strengths::Serialize(CivArchive &archive) { sint32 i; if(archive.IsStoring()) { archive << m_owner; } else { archive >> m_owner; } for(i = STRENGTH_CAT_NONE + 1; i < STRENGTH_CAT_MAX; i++) { m_strengthRecords[i].Serialize(archive); } }
void WonderTracker::Serialize(CivArchive &archive) { if(archive.IsStoring()) { archive << m_builtWonders; archive.Store((uint8*)m_buildingWonders, k_MAX_PLAYERS * sizeof(uint64)); archive << m_globeSatFlags; } else { archive >> m_builtWonders; if (g_saveFileVersion >= 58) { archive.Load((uint8*)m_buildingWonders, k_MAX_PLAYERS * sizeof(uint64)); if(g_saveFileVersion >= 63) { archive >> m_globeSatFlags; } else {
void Exclusions::Serialize(CivArchive &archive) { if(archive.IsStoring()) { archive << m_numUnits; archive << m_numBuildings; archive << m_numWonders; archive.Store((uint8 *)m_units, m_numUnits * sizeof(sint32)); archive.Store((uint8 *)m_buildings, m_numBuildings * sizeof(sint32)); archive.Store((uint8 *)m_wonders, m_numWonders * sizeof(sint32)); } else { archive >> m_numUnits; archive >> m_numBuildings; archive >> m_numWonders; m_units = new sint32[m_numUnits]; m_buildings = new sint32[m_numBuildings]; m_wonders = new sint32[m_numWonders]; archive.Load((uint8 *)m_units, m_numUnits * sizeof(sint32)); archive.Load((uint8 *)m_buildings, m_numBuildings * sizeof(sint32)); archive.Load((uint8 *)m_wonders, m_numWonders * sizeof(sint32)); if(m_numUnits != g_theUnitDB->NumRecords()) { sint32 *newUnits = new sint32[g_theUnitDB->NumRecords()]; memset(newUnits, 0, g_theUnitDB->NumRecords() * sizeof(sint32)); memcpy(newUnits, m_units, std::min(m_numUnits, g_theUnitDB->NumRecords()) * sizeof(sint32)); delete [] m_units; m_units = newUnits; m_numUnits = g_theUnitDB->NumRecords(); } if(m_numBuildings != g_theBuildingDB->NumRecords()) { sint32 *newBuildings = new sint32[g_theBuildingDB->NumRecords()]; memset(newBuildings, 0, g_theBuildingDB->NumRecords() * sizeof(sint32)); memcpy(newBuildings, m_buildings, std::min(m_numBuildings, g_theBuildingDB->NumRecords()) * sizeof(sint32)); delete [] m_buildings; m_buildings = newBuildings; m_numBuildings = g_theBuildingDB->NumRecords(); } if(m_numWonders != g_theWonderDB->NumRecords()) { sint32 *newWonders = new sint32[g_theWonderDB->NumRecords()]; memset(newWonders, 0, g_theWonderDB->NumRecords() * sizeof(sint32)); memcpy(newWonders, m_wonders, std::min(m_numWonders, g_theWonderDB->NumRecords()) * sizeof(sint32)); delete [] m_wonders; m_wonders = newWonders; m_numWonders = g_theWonderDB->NumRecords(); } } }
void GoalSally::Serialize(AiMain *ai,CivArchive &archive) { CHECKSERIALIZE ArmyGoal::Serialize(ai, archive); uint32 v; if (archive.IsStoring()) { archive << m_foreign_player; archive.PutSINT32(m_target_id.GetVal()); } else { archive >> m_foreign_player; v = archive.GetSINT32(); m_target_id = BSetID(v); } }
void OzoneDatabase::Serialize(CivArchive &archive) { #define UVDB_MAGIC 0x52139876 if (archive.IsStoring()) { archive.PerformMagic(UVDB_MAGIC) ; archive.StoreArrayString(m_meridian_prob, k_NUM_MERIDIANS + 1); archive.StoreArrayString(m_meridian_phase_bonus, k_NUM_MERIDIANS+1); archive.StoreArray(m_dead_food, k_MAX_RESOURCES); archive.StoreArray(m_dead_shield, k_MAX_RESOURCES); archive.StoreArray(m_dead_trade, k_MAX_RESOURCES); archive.StoreArray(m_dead_gold, k_MAX_RESOURCES); } else { } }
void TradeBids::Serialize(CivArchive &archive) { sint32 i, j, c; if(archive.IsStoring()) { } else { if(g_saveFileVersion < 55) { archive.LoadChunk((uint8*)m_nextId, (uint8*)m_nextId + sizeof(m_nextId)); for(i = 0; i < k_MAX_PLAYERS; i++) { m_table[i] = new PointerList<Bid>; archive >> c; for(j = 0; j < c; j++) { m_table[i]->AddTail(new Bid(archive)); } } } }
void FilenameDB::Serialize(CivArchive &archive) { CHECKSERIALIZE; if (archive.IsStoring()) { archive<<m_size ; archive.Store((uint8 *)m_map, sizeof(FilenameNode) * m_size) ; } else { archive>>m_size ; if (m_map) delete m_map ; m_map = new FilenameNode[m_size]; archive.Load((uint8 *)m_map, sizeof(FilenameNode) * m_size) ; } }
void Pillaged_Node::Serialize(CivArchive &archive) { if (archive.IsStoring()) { archive << m_pos.x; archive << m_pos.y; archive << m_pos.z; archive << m_fix_me_by ; archive << m_inst; archive << m_attempt_count; } else { archive >> m_pos.x; archive >> m_pos.y; archive >> m_pos.z; archive >> m_fix_me_by ; archive >> m_inst; archive >> m_attempt_count; } }
void GoalMapTarget::Serialize(AiMain *ai,CivArchive &archive) { CHECKSERIALIZE ArmyGoal::Serialize(ai, archive); sint32 index, count; sint16 v; MapPointData point; if (archive.IsStoring()) { v = (sint16) what_goal; archive << v; archive << m_moveType; archive << (sint32) m_targets.Num(); for (index=0; index < m_targets.Num(); index++) { archive << m_targets[index].x; archive << m_targets[index].y; archive << m_targets[index].z; } } else { archive >> v; what_goal = (GOAL_TYPE) v; archive >> m_moveType; archive >> (sint32) count; for (index=0; index < count; index++) { archive >> point.x; archive >> point.y; archive >> point.z; m_targets.InsertFlat(point); } if (what_goal != GOAL_TYPE_WANDER) ai->m_planner->the_strategic_map-> SetAreaGoal(point,what_goal,this); else ai->m_wanderGoalTargets->InsertFlat(this); } }
void GoalBombard::Serialize(AiMain *ai,CivArchive &archive) { CHECKSERIALIZE ArmyGoal::Serialize(ai, archive); uint32 v; if (archive.IsStoring()) { archive << m_foreign_player; archive.PutSINT32(m_target_id.GetVal()); archive.PutSINT32(m_target_type); } else { archive >> m_foreign_player; v = archive.GetSINT32(); m_target_id = v; v = archive.GetSINT32(); m_target_type = (AGENT_TYPE) v; } }
void Opportunity_Action_Repair_Installation::Serialize (CivArchive &archive) { Pillaged_Node *nth_node=NULL; #ifdef _DEBUG sint32 finite_count_oa_repair_serialize=0; #endif sint32 node_idx, num_stored_nodes; if (archive.IsStoring()) { archive << m_queue_len; for (nth_node = m_head; nth_node; nth_node = nth_node->m_next) { Assert(finite_count_oa_repair_serialize++ < m_queue_len); nth_node->Serialize(archive); } } else { archive >> num_stored_nodes; if (num_stored_nodes < 1) { m_queue_len = 0; m_head = NULL; m_tail = NULL; } else { for (node_idx=0; node_idx<num_stored_nodes; node_idx++) { nth_node = new Pillaged_Node(archive); Enqueue(nth_node); } m_dirty_tile_count = 0; for (node_idx=0, nth_node = m_head; node_idx<num_stored_nodes; node_idx++, nth_node = nth_node->m_next) { if (0 == nth_node->m_inst) { m_dirty_tile_count++; } } Assert(num_stored_nodes == m_queue_len); } } }
void Squad::Serialize(CivArchive &archive) { CHECKSERIALIZE Squad_Flat_Data::Serialize(archive); if (archive.IsStoring()) { Store(archive); } else { Load(archive); } }
void CivilisationData::Serialize(CivArchive &archive) { CHECKSERIALIZE uint8 hasChild; if (archive.IsStoring()) { GameObj::Serialize(archive); archive.StoreChunk((uint8 *)&m_owner, ((uint8 *)&m_singular_name)+sizeof(m_singular_name)); hasChild = m_lesser != NULL; archive << hasChild; if(m_lesser) { ((CivilisationData*)(m_lesser))->Serialize(archive); } hasChild = m_greater != NULL; archive << hasChild; if(m_greater) { ((CivilisationData*)(m_greater))->Serialize(archive); } } else { GameObj::Serialize(archive); archive.LoadChunk((uint8 *)&m_owner, ((uint8 *)&m_singular_name)+sizeof(m_singular_name)); archive >> hasChild; if(hasChild) { m_lesser = new CivilisationData(archive); } else { m_lesser = NULL; } archive >> hasChild; if(hasChild) { m_greater = new CivilisationData(archive); } else { m_greater = NULL; } } }
void ThroneDB::Serialize(CivArchive &archive) { CHECKSERIALIZE; if (archive.IsStoring()) { archive << m_nThroneTypes; archive << m_nThroneLevels; archive.Store((uint8 *)m_throneInfo, sizeof(ThroneInfo) * m_nThroneTypes * m_nThroneLevels) ; } else { archive >> m_nThroneTypes; archive >> m_nThroneLevels; if(m_throneInfo) delete m_throneInfo; m_throneInfo = new ThroneInfo[(m_nThroneTypes * m_nThroneLevels)]; archive.Load((uint8 *)m_throneInfo, sizeof(ThroneInfo) * m_nThroneTypes * m_nThroneLevels) ; } }
void ForeignAgent::Serialize(IC3CivArchive *archive) { CivArchive *a = (CivArchive *) archive; Agent::Serialize(*a); if (a->IsStoring()) { a->PutSINT32(m_player_index); a->PutSINT32(m_top_unit_type); (*a) << m_defense_strength; (*a) << m_attack_strength; (*a) << m_target_value; a->PutSINT32(m_has_peeked); (*a) << m_pos->x; (*a) << m_pos->y; (*a) << m_pos->z; (*a) << m_unit_num; (*a) << m_XYpos->x; (*a) << m_XYpos->y; (*a) << m_XYpos->z; a->PutSINT32(m_has_enslave_goal); a->PutSINT32(enslave_me_goal_ID); a->PutSINT32(m_bombardMeGoalID); a->PutSINT32(m_rustleMeGoalID); a->PutSINT32(m_expelMeGoalID); a->PutSINT32(m_sallyMeGoalID); a->PutSINT32(m_lastSeen); } else { m_player_index = PLAYER_INDEX(a->GetSINT32()); m_top_unit_type = a->GetSINT32(); (*a) >> m_defense_strength; (*a) >> m_attack_strength; (*a) >> m_target_value; m_has_peeked = a->GetSINT32(); (*a) >> m_pos->x; (*a) >> m_pos->y; (*a) >> m_pos->z; (*a) >> m_unit_num; (*a) >> m_XYpos->x; (*a) >> m_XYpos->y; (*a) >> m_XYpos->z; m_has_enslave_goal = a->GetSINT32(); enslave_me_goal_ID = a->GetSINT32(); m_bombardMeGoalID = a->GetSINT32(); m_rustleMeGoalID = a->GetSINT32(); m_expelMeGoalID = a->GetSINT32(); m_sallyMeGoalID = a->GetSINT32(); m_lastSeen = a->GetSINT32(); } }
void TradeRouteData::Serialize(CivArchive &archive) { if(archive.IsStoring()) { archive << m_id; archive << m_transportCost; archive << m_owner; archive.PutSINT32(m_sourceRouteType); archive << m_sourceResource; archive.Store((uint8 *)m_passesThrough, sizeof(m_passesThrough)) ; archive.PutSINT32(m_crossesWater) ; archive.PutSINT8(static_cast<sint8>(m_isActive)); archive.PutUINT32(m_color); archive.PutUINT32(m_outline); archive.PutSINT32(m_selectedIndex); archive.PutSINT32(m_path_selection_state); archive.PutSINT32(m_valid); archive << m_payingFor; archive << m_gold_in_return; m_sourceCity.Serialize(archive); m_destinationCity.Serialize(archive); m_recip.Serialize(archive); m_path.Serialize(archive); m_wayPoints.Serialize(archive) ; m_selectedPath.Serialize(archive); m_selectedWayPoints.Serialize(archive); m_astarPath->Serialize(archive); m_setPath.Serialize(archive); m_setWayPoints.Serialize(archive); uint8 hasChild; hasChild = m_lesser != NULL; archive << hasChild; if (m_lesser) { ((TradeRouteData *)(m_lesser))->Serialize(archive) ; } hasChild = m_greater != NULL; archive << hasChild; if (m_greater) ((TradeRouteData *)(m_greater))->Serialize(archive) ; } else { archive >> m_id; archive >> m_transportCost; archive >> m_owner; m_sourceRouteType = (ROUTE_TYPE)(archive.GetSINT32()) ; archive >> m_sourceResource; archive.Load((uint8 *)m_passesThrough, sizeof(m_passesThrough)) ; m_crossesWater = (BOOL)(archive.GetSINT32()) ; m_isActive = (BOOL)(archive.GetSINT8()); m_color = archive.GetUINT32(); m_outline = archive.GetUINT32(); m_selectedIndex = archive.GetSINT32(); m_path_selection_state = archive.GetSINT32(); m_valid = archive.GetSINT32(); archive >> m_payingFor; archive >> m_gold_in_return; m_sourceCity.Serialize(archive); m_destinationCity.Serialize(archive); m_recip.Serialize(archive); m_path.Serialize(archive); m_wayPoints.Serialize(archive) ; m_selectedPath.Serialize(archive); m_selectedWayPoints.Serialize(archive); m_astarPath->Serialize(archive); m_setPath.Serialize(archive); m_setWayPoints.Serialize(archive); uint8 hasChild; archive >> hasChild; if (hasChild) { m_lesser = new TradeRouteData(archive); } else { m_lesser = NULL; } archive >> hasChild; if (hasChild) m_greater = new TradeRouteData(archive); else m_greater = NULL; } }
//---------------------------------------------------------------------------- // // Name : UnseenCell::Serialize // // Description: Serialization method // // Parameters : archive : The source/target archive // // Globals : - // // Returns : - // // Remark(s) : - // //---------------------------------------------------------------------------- void UnseenCell::Serialize(CivArchive &archive) { sint32 l; if(archive.IsStoring()) { m_point.Serialize(archive); archive.StoreChunk((uint8 *)&m_env, ((uint8 *)&m_slaveBits)+sizeof(m_slaveBits)); { // A dirty workaround in order not to change the save game format. // UnseenInstallationInfo is now abused to store m_visibleCityOwner // as visibility member. As both are of type uint32 it is not a // problem. Its type is marked as -1. At least this doesn't interfere // with anything else, as the installation data is just stored in // this class but it isn't aceessed. Maybe a mistake or a left // over from CTP1. m_installations->AddTail(new UnseenInstallationInfo(-1, m_visibleCityOwner)); archive << m_installations->GetCount(); PointerList<UnseenInstallationInfo>::Walker walk(m_installations); while(walk.IsValid()) { archive.Store((uint8*)walk.GetObj(), sizeof(UnseenInstallationInfo)); walk.Next(); } } { archive << m_improvements->GetCount(); PointerList<UnseenImprovementInfo>::Walker walk(m_improvements); while(walk.IsValid()) { archive.Store((uint8*)walk.GetObj(), sizeof(UnseenImprovementInfo)); walk.Next(); } } if (m_cityName) { l = strlen(m_cityName) + 1; archive << l; archive.Store((uint8*)m_cityName, (strlen(m_cityName) + 1) * sizeof(MBCHAR)); } else { l = 0; archive << l; } archive << (sint32)(m_actor != NULL); if (m_actor) { m_actor->Serialize(archive); } m_tileInfo->Serialize(archive); } else { m_point.Serialize(archive); archive.LoadChunk((uint8 *)&m_env, ((uint8 *)&m_slaveBits)+sizeof(m_slaveBits)); if (m_installations) { m_installations->DeleteAll(); } else { m_installations = new PointerList<UnseenInstallationInfo>; } archive >> l; UnseenInstallationInfo* tmpUII; bool vCityOwnerNotSet = true; sint32 i; for(i = 0; i < l; i++) { tmpUII = new UnseenInstallationInfo(archive); // Only store the additional UnseenInstallationInfo in the // save file but not in the UnseenCell object itsself. if(tmpUII->m_type >= 0){ m_installations->AddTail(tmpUII); } else{ m_visibleCityOwner = tmpUII->m_visibility; vCityOwnerNotSet = false; delete tmpUII; } } // Backwards compartibility: If this UnseenCell didn't have an m_visibleCityOwner if(vCityOwnerNotSet) m_visibleCityOwner = g_theWorld->GetCell(m_point)->GetCityOwner().m_id; if (m_improvements) { m_improvements->DeleteAll(); } else { m_improvements = new PointerList<UnseenImprovementInfo>; } archive >> l; for(i = 0; i < l; i++) { m_improvements->AddTail(new UnseenImprovementInfo(archive)); } delete [] m_cityName; archive >> l; if (l > 0) { m_cityName = new MBCHAR[l]; archive.Load((uint8*)m_cityName, l * sizeof(MBCHAR)); } else { m_cityName = NULL; } sint32 hasActor; archive >> hasActor; ReleaseActor(m_actor); if (hasActor) { m_actor = new UnitActor(archive); } delete m_tileInfo; m_tileInfo = new TileInfo(g_theWorld->GetTileInfo(m_point)); Assert(m_tileInfo); m_tileInfo->Serialize(archive); } }
void SlicSegment::Serialize(CivArchive &archive) { sint32 l; if(archive.IsStoring()) { archive.StoreChunk((uint8 *)&m_type, ((uint8 *)&m_fromFile)+sizeof(m_fromFile)); if(m_id) { l = strlen(m_id) + 1; archive << l; archive.Store((uint8*)m_id, l); } else { l = 1; archive << l; archive.Store((uint8*)"", l); } archive.Store((uint8*)m_code, m_codeSize); archive.Store((uint8*)m_trigger_symbols_indices, m_num_trigger_symbols * sizeof(sint32)); archive.Store((uint8*)m_lastShown, k_MAX_PLAYERS * sizeof(sint32)); if(m_uiComponent) { l = strlen(m_uiComponent) + 1; archive << l; archive.Store((uint8*)m_uiComponent, l); } else { l = 0; archive << l; } archive << m_num_parameters; sint32 i; for(i = 0; i < m_num_parameters; i++) { archive.PutSINT32(((SlicParameterSymbol *)m_parameter_symbols[i])->GetIndex()); } if(!m_filename) { archive.PutSINT32(0); } else { archive.PutSINT32(strlen(m_filename)); archive.Store((uint8*)m_filename, strlen(m_filename)); } } else { archive.LoadChunk((uint8 *)&m_type, ((uint8 *)&m_fromFile)+sizeof(m_fromFile)); archive >> l; m_id = (char *)malloc(l); archive.Load((uint8*)m_id, l); m_code = (uint8*)malloc(m_codeSize); archive.Load((uint8*)m_code, m_codeSize); if (m_num_trigger_symbols < 1) { m_trigger_symbols_indices = NULL; m_trigger_symbols = NULL; } else { m_trigger_symbols_indices = new sint32[m_num_trigger_symbols]; archive.Load((uint8*)m_trigger_symbols_indices, m_num_trigger_symbols * sizeof(sint32)); } archive.Load((uint8*)m_lastShown, k_MAX_PLAYERS * sizeof(sint32)); archive >> l; if(l > 0) { m_uiComponent = (char *)malloc(l); archive.Load((uint8*)m_uiComponent, l); } else { m_uiComponent = NULL; } archive >> m_num_parameters; m_parameter_indices = (m_num_parameters > 0) ? new sint32[m_num_parameters] : NULL; sint32 i; for(i = 0; i < m_num_parameters; i++) { m_parameter_indices[i] = archive.GetSINT32(); } l = archive.GetSINT32(); if(l > 0) { m_filename = (char *)malloc(l + 1); archive.Load((uint8*)m_filename, l); m_filename[l] = 0; } else { m_filename = NULL; } if(m_type == SLIC_OBJECT_HANDLEEVENT) { g_gevManager->AddCallback(m_event, m_priority, this); } m_parameter_symbols = NULL; } }