diff options
Diffstat (limited to 'engines/wintermute/base/base_surface_storage.cpp')
-rw-r--r-- | engines/wintermute/base/base_surface_storage.cpp | 38 |
1 files changed, 18 insertions, 20 deletions
diff --git a/engines/wintermute/base/base_surface_storage.cpp b/engines/wintermute/base/base_surface_storage.cpp index 4e795ca813..8dbd6a6d2a 100644 --- a/engines/wintermute/base/base_surface_storage.cpp +++ b/engines/wintermute/base/base_surface_storage.cpp @@ -30,6 +30,7 @@ #include "engines/wintermute/base/gfx/base_surface.h" #include "engines/wintermute/base/gfx/base_renderer.h" #include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_engine.h" #include "engines/wintermute/base/base_file_manager.h" #include "engines/wintermute/platform_osystem.h" #include "common/str.h" @@ -54,7 +55,7 @@ BaseSurfaceStorage::~BaseSurfaceStorage() { bool BaseSurfaceStorage::cleanup(bool warn) { for (uint32 i = 0; i < _surfaces.size(); i++) { if (warn) { - _gameRef->LOG(0, "BaseSurfaceStorage warning: purging surface '%s', usage:%d", _surfaces[i]->getFileName(), _surfaces[i]->_referenceCount); + BaseEngine::LOG(0, "BaseSurfaceStorage warning: purging surface '%s', usage:%d", _surfaces[i]->getFileName(), _surfaces[i]->_referenceCount); } delete _surfaces[i]; } @@ -66,15 +67,15 @@ bool BaseSurfaceStorage::cleanup(bool warn) { ////////////////////////////////////////////////////////////////////////// bool BaseSurfaceStorage::initLoop() { - if (_gameRef->_smartCache && _gameRef->_liveTimer - _lastCleanupTime >= _gameRef->_surfaceGCCycleTime) { - _lastCleanupTime = _gameRef->_liveTimer; + if (_gameRef->_smartCache && _gameRef->getLiveTimer()->getTime() - _lastCleanupTime >= _gameRef->_surfaceGCCycleTime) { + _lastCleanupTime = _gameRef->getLiveTimer()->getTime(); sortSurfaces(); for (uint32 i = 0; i < _surfaces.size(); i++) { if (_surfaces[i]->_lifeTime <= 0) { break; } - if (_surfaces[i]->_lifeTime > 0 && _surfaces[i]->_valid && (int)(_gameRef->_liveTimer - _surfaces[i]->_lastUsedTime) >= _surfaces[i]->_lifeTime) { + if (_surfaces[i]->_lifeTime > 0 && _surfaces[i]->_valid && (int)(_gameRef->getLiveTimer()->getTime() - _surfaces[i]->_lastUsedTime) >= _surfaces[i]->_lifeTime) { //_gameRef->QuickMessageForm("Invalidating: %s", _surfaces[i]->_filename); _surfaces[i]->invalidate(); } @@ -111,7 +112,7 @@ BaseSurface *BaseSurfaceStorage::addSurface(const Common::String &filename, bool if (!BaseFileManager::getEngineInstance()->hasFile(filename)) { if (filename.size()) { - _gameRef->LOG(0, "Missing image: '%s'", filename.c_str()); + BaseEngine::LOG(0, "Missing image: '%s'", filename.c_str()); } if (_gameRef->_debugDebugMode) { return addSurface("invalid_debug.bmp", defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded); @@ -121,15 +122,15 @@ BaseSurface *BaseSurfaceStorage::addSurface(const Common::String &filename, bool } BaseSurface *surface; - surface = _gameRef->_renderer->createSurface(); + surface = BaseEngine::getRenderer()->createSurface(); if (!surface) { - return NULL; + return nullptr; } if (DID_FAIL(surface->create(filename, defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded))) { delete surface; - return NULL; + return nullptr; } else { surface->_referenceCount = 1; _surfaces.push_back(surface); @@ -144,7 +145,7 @@ bool BaseSurfaceStorage::restoreAll() { for (uint32 i = 0; i < _surfaces.size(); i++) { ret = _surfaces[i]->restore(); if (ret != STATUS_OK) { - _gameRef->LOG(0, "BaseSurfaceStorage::RestoreAll failed"); + BaseEngine::LOG(0, "BaseSurfaceStorage::RestoreAll failed"); return ret; } } @@ -176,32 +177,29 @@ bool BaseSurfaceStorage::sortSurfaces() { ////////////////////////////////////////////////////////////////////////// -int BaseSurfaceStorage::surfaceSortCB(const void *arg1, const void *arg2) { - const BaseSurface *s1 = *((const BaseSurface *const *)arg1); - const BaseSurface *s2 = *((const BaseSurface *const *)arg2); - +bool BaseSurfaceStorage::surfaceSortCB(const BaseSurface *s1, const BaseSurface *s2) { // sort by life time if (s1->_lifeTime <= 0 && s2->_lifeTime > 0) { - return 1; + return false; } else if (s1->_lifeTime > 0 && s2->_lifeTime <= 0) { - return -1; + return true; } // sort by validity if (s1->_valid && !s2->_valid) { - return -1; + return true; } else if (!s1->_valid && s2->_valid) { - return 1; + return false; } // sort by time else if (s1->_lastUsedTime > s2->_lastUsedTime) { - return 1; + return false; } else if (s1->_lastUsedTime < s2->_lastUsedTime) { - return -1; + return true; } else { - return 0; + return false; } } |