//---------------------------------------------------------------------------- // // Name : UnseenCell::~UnseenCell // // Description: Destructor // // Parameters : - // // Globals : - // // Returns : - // // Remark(s) : - // //---------------------------------------------------------------------------- UnseenCell::~UnseenCell() { ReleaseActor(m_actor); delete m_tileInfo; if (m_installations) { m_installations->DeleteAll(); delete m_installations; } if (m_improvements) { m_improvements->DeleteAll(); delete m_improvements; } delete [] m_cityName; }
//---------------------------------------------------------------------------- // // 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 ExplosionTasks (Actor* actor) { if (!TLN_GetAnimationState (actor->index)) ReleaseActor (actor); }