void CvGlobals::swapMaps()
{
int i, iLoop;
CvUnit* pLoopUnit;
CvCity* pLoopCity;
for (i = 0; i < MAX_TEAMS; i++)
{
GC.getMapINLINE().setRevealedPlots(((TeamTypes)i), false);
}
for (i = 0; i < MAX_PLAYERS; i++) // destroying all the unit/city entities currently on the map
{
if (GET_PLAYER((PlayerTypes)i).isAlive())
{
for (pLoopCity = GET_PLAYER((PlayerTypes)i).firstCity(&iLoop); pLoopCity != NULL; pLoopCity = GET_PLAYER((PlayerTypes)i).nextCity(&iLoop))
{
pLoopCity->removeEntity();
pLoopCity->destroyEntity();
}
for (pLoopUnit = GET_PLAYER((PlayerTypes)i).firstUnit(&iLoop); pLoopUnit != NULL; pLoopUnit = GET_PLAYER((PlayerTypes)i).nextUnit(&iLoop))
{
if (gDLL->getEntityIFace()->IsSelected(pLoopUnit->getEntity()))
{
gDLL->getInterfaceIFace()->selectUnit(pLoopUnit, true, true);
}
if (GC.IsGraphicsInitialized())
{
gDLL->getEntityIFace()->RemoveUnitFromBattle(pLoopUnit);
pLoopUnit->removeEntity();
}
pLoopUnit->destroyEntity();
}
GET_PLAYER((PlayerTypes)i).swapInfo(); // function to swap the player's units' and cities' list with another list for the alternate map
}
}
gDLL->getInterfaceIFace()->setInterfaceMode(INTERFACEMODE_GLOBELAYER_INPUT);
for (i = 0; i < GC.getMap().numPlots(); i++)
{
gDLL->callUpdater();
GC.getMap().plotByIndex(i)->destroyGraphics(); // this function included below.
gDLL->getEngineIFace()->MarkPlotTextureAsDirty(GC.getMap().plotByIndex(i)->getX(), GC.getMap().plotByIndex(i)->getY());
}
for (i = 0; i < NUM_AREA_BORDER_LAYERS; i++)
{
gDLL->getEngineIFace()->clearAreaBorderPlots((AreaBorderLayers)i);
}
gDLL->getEngineIFace()->clearColoredPlots(PLOT_LANDSCAPE_LAYER_ALL);
gDLL->getEngineIFace()->clearSigns();
CvMap* tempMap = m_map; // switching the map object
m_map = m_altMap;
m_altMap = tempMap;
GC.getMapINLINE().rebuild(15, 15, 45, -45, false, false, (WorldSizeTypes)0, (ClimateTypes)0, (SeaLevelTypes)0, 0, NULL);
for (i = 0; i < GC.getMapINLINE().numPlots(); i++)
{
gDLL->callUpdater();
GC.getMapINLINE().plotByIndex(i)->setTerrainType((TerrainTypes)GC.getInfoTypeForString("TERRAIN_GRASS"), false, false);
gDLL->getEngineIFace()->MarkPlotTextureAsDirty(GC.getMap().plotByIndex(i)->getX(), GC.getMap().plotByIndex(i)->getY());
gDLL->getEngineIFace()->RebuildTileArt(GC.getMap().plotByIndex(i)->getX(), GC.getMap().plotByIndex(i)->getY());
}
gDLL->getEngineIFace()->RebuildAllPlots();
GC.getMapINLINE().setupGraphical();
gDLL->getEngineIFace()->SetDirty(GlobeTexture_DIRTY_BIT, true);
gDLL->getEngineIFace()->SetDirty(CultureBorders_DIRTY_BIT, true);
gDLL->getEngineIFace()->SetDirty(GlobePartialTexture_DIRTY_BIT, true);
gDLL->getEngineIFace()->SetDirty(MinimapTexture_DIRTY_BIT, true);
for (i = 0; i < NUM_INTERFACE_DIRTY_BITS; i++)
{
gDLL->getInterfaceIFace()->setDirty((InterfaceDirtyBits)i, true);
}
gDLL->getInterfaceIFace()->makeInterfaceDirty();
for (i = 0; i < MAX_PLAYERS; i++) // creating new entities for the units/cities on this map
{
if (GET_PLAYER((PlayerTypes)i).isAlive())
{
for (pLoopCity = GET_PLAYER((PlayerTypes)i).firstCity(&iLoop); pLoopCity != NULL; pLoopCity = GET_PLAYER((PlayerTypes)i).nextCity(&iLoop))
{
gDLL->getEntityIFace()->createCityEntity(pLoopCity);
pLoopCity->setupGraphical();
}
for (pLoopUnit = GET_PLAYER((PlayerTypes)i).firstUnit(&iLoop); pLoopUnit != NULL; pLoopUnit = GET_PLAYER((PlayerTypes)i).nextUnit(&iLoop))
{
gDLL->getEntityIFace()->createUnitEntity(pLoopUnit);
pLoopUnit->setupGraphical();
}
}
}
}
void CvPlot::destroyGraphics() // everything copied from the destructor
{
gDLL->getFeatureIFace()->destroy(m_pFeatureSymbol);
if(m_pPlotBuilder)
{
gDLL->getPlotBuilderIFace()->destroy(m_pPlotBuilder);
}
gDLL->getRouteIFace()->destroy(m_pRouteSymbol);
gDLL->getRiverIFace()->destroy(m_pRiverSymbol);
gDLL->getFlagEntityIFace()->destroy(m_pFlagSymbol);
gDLL->getFlagEntityIFace()->destroy(m_pFlagSymbolOffset);
m_pCenterUnit = NULL;
deleteAllSymbols();
}