HDB: Complete Map::restartSystem()

This commit is contained in:
Eugene Sandulenko 2019-07-13 16:04:05 +02:00
parent 5fa5f6fb39
commit 62a6a36463
3 changed files with 32 additions and 2 deletions

View File

@ -406,7 +406,7 @@ Tile *Gfx::getTile(int index) {
}
void Gfx::emptyGfxCaches() {
warning("STUB: mptyGfxCaches()");
// We have plenty of memory, so do not do it
}
void Gfx::cacheTileSequence(int tileIndex, int count) {
@ -510,6 +510,15 @@ Tile *Gfx::getTileGfx(const char *name, int32 size) {
return gc->tileGfx;
}
void Gfx::markGfxCacheFreeable() {
for (Common::Array<GfxCache *>::iterator it = _gfxCache->begin(); it != _gfxCache->end(); it++)
(*it)->loaded = -1;
}
void Gfx::markTileCacheFreeable() {
// we have plenty of memory, so do not do it
}
Picture *Gfx::getPicGfx(const char *name, int32 size) {
// Try to find graphic
for (Common::Array<GfxCache *>::iterator it = _gfxCache->begin(); it != _gfxCache->end(); it++) {

View File

@ -122,6 +122,8 @@ public:
Picture *getPicture(const char *name);
void emptyGfxCaches();
void markTileCacheFreeable();
void markGfxCacheFreeable();
// Returns: true->Tile, false->Pic
bool selectGfxType(const char *name);

View File

@ -217,7 +217,22 @@ int Map::loadTiles() {
}
void Map::restartSystem() {
warning("STUB: Map::restartSystem()");
_listBGAnimFast.clear();
_listBGAnimMedium.clear();
_listBGAnimSlow.clear();
_listFGAnimFast.clear();
_listFGAnimMedium.clear();
_listFGAnimSlow.clear();
delete _background;
_background = NULL;
delete _foreground;
_foreground = NULL;
delete _iconList;
_iconList = NULL;
_width = _height = 0;
_animCycle = 0;
free(_mapExplosions);
free(_mapExpBarrels);
@ -227,6 +242,10 @@ void Map::restartSystem() {
_mapExpBarrels = NULL;
_mapLaserBeams = NULL;
// mark all in-memory tiles as being in memory, but able to be freed
g_hdb->_gfx->markTileCacheFreeable();
g_hdb->_gfx->markGfxCacheFreeable();
_mapLoaded = false;
}