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 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; } }
//---------------------------------------------------------------------------- // // 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); } }