diff options
Diffstat (limited to 'engines/wintermute/base')
40 files changed, 301 insertions, 129 deletions
diff --git a/engines/wintermute/base/base.cpp b/engines/wintermute/base/base.cpp index 074bd0db68..8fa26f04a6 100644 --- a/engines/wintermute/base/base.cpp +++ b/engines/wintermute/base/base.cpp @@ -101,7 +101,7 @@ bool BaseClass::parseEditorProperty(byte *buffer, bool complete) { byte *params;
int cmd;
- BaseParser parser(_gameRef);
+ BaseParser parser;
if (complete) {
if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_EDITOR_PROPERTY) {
diff --git a/engines/wintermute/base/base_dynamic_buffer.cpp b/engines/wintermute/base/base_dynamic_buffer.cpp index 949548b68b..d953483be8 100644 --- a/engines/wintermute/base/base_dynamic_buffer.cpp +++ b/engines/wintermute/base/base_dynamic_buffer.cpp @@ -26,13 +26,13 @@ * Copyright (c) 2011 Jan Nedoma
*/
-#include "engines/wintermute/base/base_game.h"
+#include "engines/wintermute/base/base_engine.h"
#include "engines/wintermute/base/base_dynamic_buffer.h"
namespace WinterMute {
//////////////////////////////////////////////////////////////////////////
-BaseDynamicBuffer::BaseDynamicBuffer(BaseGame *inGame, uint32 initSize, uint32 growBy) : BaseClass(inGame) {
+BaseDynamicBuffer::BaseDynamicBuffer(BaseGame *inGame, uint32 initSize, uint32 growBy) {
_buffer = NULL;
_size = 0;
_realSize = 0;
@@ -80,7 +80,7 @@ bool BaseDynamicBuffer::init(uint32 initSize) { _buffer = (byte *)malloc(initSize);
if (!_buffer) {
- _gameRef->LOG(0, "BaseDynamicBuffer::Init - Error allocating %d bytes", initSize);
+ BaseEngine::LOG(0, "BaseDynamicBuffer::Init - Error allocating %d bytes", initSize);
return STATUS_FAILED;
}
@@ -101,7 +101,7 @@ bool BaseDynamicBuffer::putBytes(byte *buffer, uint32 size) { _realSize += _growBy;
_buffer = (byte *)realloc(_buffer, _realSize);
if (!_buffer) {
- _gameRef->LOG(0, "BaseDynamicBuffer::PutBytes - Error reallocating buffer to %d bytes", _realSize);
+ BaseEngine::LOG(0, "BaseDynamicBuffer::PutBytes - Error reallocating buffer to %d bytes", _realSize);
return STATUS_FAILED;
}
}
@@ -121,7 +121,7 @@ bool BaseDynamicBuffer::getBytes(byte *buffer, uint32 size) { }
if (_offset + size > _size) {
- _gameRef->LOG(0, "BaseDynamicBuffer::GetBytes - Buffer underflow");
+ BaseEngine::LOG(0, "BaseDynamicBuffer::GetBytes - Buffer underflow");
return STATUS_FAILED;
}
diff --git a/engines/wintermute/base/base_dynamic_buffer.h b/engines/wintermute/base/base_dynamic_buffer.h index 0567f874df..ff3897e71b 100644 --- a/engines/wintermute/base/base_dynamic_buffer.h +++ b/engines/wintermute/base/base_dynamic_buffer.h @@ -34,7 +34,7 @@ namespace WinterMute {
-class BaseDynamicBuffer : public BaseClass {
+class BaseDynamicBuffer {
public:
bool _initialized;
void putText(const char *fmt, ...);
diff --git a/engines/wintermute/base/base_engine.cpp b/engines/wintermute/base/base_engine.cpp new file mode 100644 index 0000000000..cd6e9c9e3b --- /dev/null +++ b/engines/wintermute/base/base_engine.cpp @@ -0,0 +1,108 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_registry.h" +#include "engines/wintermute/base/base_engine.h" +#include "engines/wintermute/wintermute.h" +#include "common/system.h" + +namespace WinterMute { + +BaseEngine *BaseEngine::_instance = 0; + /* +class BaseEngine { + static BaseEngine *_instance; + BaseEngine(); + BaseFileManager *_fileManager; + BaseRegistry *_registry; +public: + ~BaseEngine(); + BaseEngine *getInstance(); + BaseFileManager *getFileMan() { return _fileManager; } + BaseRegistry *getRegistry() { return _registry; } +};*/ +BaseEngine::BaseEngine() { + +} + +void BaseEngine::init() { + _registry = new BaseRegistry(); + // File-manager depends on registry. + _fileManager = new BaseFileManager(); +} + +BaseEngine::~BaseEngine() { + delete _fileManager; + delete _registry; +} + +BaseEngine *BaseEngine::getInstance() { + if (!_instance) + assert(0); + return _instance; +} + +void BaseEngine::createInstance(const Common::String &gameid) { + if (_instance) { + delete _instance; + _instance = NULL; + } + _instance = new BaseEngine(); + _instance->_gameId = gameid; + _instance->init(); +} + +void BaseEngine::destroyInstance() { + delete _instance; + _instance = NULL; +} + +void BaseEngine::LOG(bool res, const char *fmt, ...) { + uint32 secs = g_system->getMillis() / 1000; + uint32 hours = secs / 3600; + secs = secs % 3600; + uint32 mins = secs / 60; + secs = secs % 60; + + char buff[512]; + va_list va; + + va_start(va, fmt); + vsprintf(buff, fmt, va); + va_end(va); + + if (_instance && _instance->_gameRef) { + _instance->_gameRef->LOG("%s", buff); + } else { + debugCN(kWinterMuteDebugLog, "%02d:%02d:%02d: %s\n", hours, mins, secs, buff); + } +} + +} // end of namespace WinterMute
\ No newline at end of file diff --git a/engines/wintermute/base/base_engine.h b/engines/wintermute/base/base_engine.h new file mode 100644 index 0000000000..5782c012d8 --- /dev/null +++ b/engines/wintermute/base/base_engine.h @@ -0,0 +1,59 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + + #include "common/str.h" + +namespace WinterMute { + +class BaseFileManager; +class BaseRegistry; +class BaseGame; +class BaseEngine { + static BaseEngine *_instance; + BaseEngine(); + void init(); + BaseFileManager *_fileManager; + BaseRegistry *_registry; + Common::String _gameId; + BaseGame *_gameRef; +public: + ~BaseEngine(); + static void createInstance(const Common::String &gameid); + static BaseEngine *getInstance(); + static void destroyInstance(); + + void setGameRef(BaseGame *gameRef) { _gameRef = gameRef; } + + BaseGame *getGameRef() { return _gameRef; } + BaseFileManager *getFileManager() { return _fileManager; } + BaseRegistry *getRegistry() { return _registry; } + static void LOG(bool res, const char *fmt, ...); + const char *getGameId() { return _gameId.c_str(); } +}; + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index 7fe7b3ab98..83047ca75c 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -27,13 +27,15 @@ */
#include "engines/wintermute/base/base_file_manager.h"
+#include "engines/wintermute/base/base_persistence_manager.h"
#include "engines/wintermute/base/file/base_disk_file.h"
#include "engines/wintermute/base/file/base_save_thumb_file.h"
#include "engines/wintermute/base/file/base_package.h"
#include "engines/wintermute/base/file/base_resources.h"
#include "engines/wintermute/base/base_registry.h"
-#include "engines/wintermute/base/base_game.h"
+#include "engines/wintermute/base/base_engine.h"
#include "engines/wintermute/wintermute.h"
+#include "common/debug.h"
#include "common/str.h"
#include "common/tokenizer.h"
#include "common/textconsole.h"
@@ -52,7 +54,7 @@ namespace WinterMute { //////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
-BaseFileManager::BaseFileManager(BaseGame *inGame) : _gameRef(inGame) {
+BaseFileManager::BaseFileManager() {
initPaths();
registerPackages();
}
@@ -145,14 +147,15 @@ bool BaseFileManager::reloadPaths() { //////////////////////////////////////////////////////////////////////////
bool BaseFileManager::initPaths() {
- if (!_gameRef) { // This function only works when the game-registry is loaded
+ BaseEngine *enginePtr = BaseEngine::getInstance();
+ if (!enginePtr) { // This function only works when the game-registry is loaded
return STATUS_FAILED;
}
AnsiString pathList;
// single files paths
- pathList = _gameRef->_registry->readString("Resource", "CustomPaths", "");
+ pathList = enginePtr->getRegistry()->readString("Resource", "CustomPaths", "");
Common::StringTokenizer *entries = new Common::StringTokenizer(pathList, ";");
// numPaths = BaseUtils::strNumEntries(pathList.c_str(), ';');
while (!entries->empty()) {
@@ -169,7 +172,7 @@ bool BaseFileManager::initPaths() { const Common::FSNode gameData(ConfMan.get("path"));
addPath(PATH_PACKAGE, gameData);
- pathList = _gameRef->_registry->readString("Resource", "PackagePaths", "");
+ pathList = enginePtr->getRegistry()->readString("Resource", "PackagePaths", "");
entries = new Common::StringTokenizer(pathList, ";");
while (!entries->empty()) {
Common::String path = entries->nextToken();
@@ -268,7 +271,7 @@ Common::SeekableReadStream *BaseFileManager::openPkgFile(const Common::String &f bool BaseFileManager::hasFile(const Common::String &filename) {
if (scumm_strnicmp(filename.c_str(), "savegame:", 9) == 0) {
- BasePersistenceManager pm(_gameRef);
+ BasePersistenceManager pm(BaseEngine::getInstance()->getGameId());
if (filename.size() <= 9) {
return false;
}
@@ -320,10 +323,10 @@ Common::SeekableReadStream *BaseFileManager::openFileRaw(const Common::String &f Common::SeekableReadStream *ret = NULL;
if (scumm_strnicmp(filename.c_str(), "savegame:", 9) == 0) {
- if (!_gameRef) {
- error("Attempt to load filename: %s without BaseGame-object, this is unsupported", filename.c_str());
+ if (!BaseEngine::getInstance()) {
+ error("Attempt to load filename: %s without BaseEngine-object, this is unsupported", filename.c_str());
}
- BaseSaveThumbFile *saveThumbFile = new BaseSaveThumbFile(_gameRef);
+ BaseSaveThumbFile *saveThumbFile = new BaseSaveThumbFile();
if (DID_SUCCEED(saveThumbFile->open(filename))) {
ret = saveThumbFile->getMemStream();
}
@@ -350,4 +353,11 @@ Common::SeekableReadStream *BaseFileManager::openFileRaw(const Common::String &f return NULL;
}
+BaseFileManager *BaseFileManager::getEngineInstance() {
+ if (BaseEngine::getInstance()) {
+ return BaseEngine::getInstance()->getFileManager();
+ }
+ return NULL;
+}
+
} // end of namespace WinterMute
diff --git a/engines/wintermute/base/base_file_manager.h b/engines/wintermute/base/base_file_manager.h index c49bbe3815..23032ca65a 100644 --- a/engines/wintermute/base/base_file_manager.h +++ b/engines/wintermute/base/base_file_manager.h @@ -35,7 +35,6 @@ #include "common/file.h"
namespace WinterMute {
-class BaseGame;
class BaseFileManager {
public:
bool cleanup();
@@ -45,10 +44,11 @@ public: Common::SeekableReadStream *openFile(const Common::String &filename, bool absPathWarning = true, bool keepTrackOf = true);
byte *readWholeFile(const Common::String &filename, uint32 *size = NULL, bool mustExist = true);
- BaseFileManager(BaseGame *inGame = NULL);
+ BaseFileManager();
virtual ~BaseFileManager();
// Used only for detection
bool registerPackages(const Common::FSList &fslist);
+ static BaseFileManager *getEngineInstance();
private:
typedef enum {
PATH_PACKAGE,
@@ -67,7 +67,6 @@ private: Common::Array<Common::SeekableReadStream *> _openFiles;
// This class is intentionally not a subclass of Base, as it needs to be used by
// the detector too, without launching the entire engine:
- BaseGame *_gameRef;
};
} // end of namespace WinterMute
diff --git a/engines/wintermute/base/base_frame.cpp b/engines/wintermute/base/base_frame.cpp index 27e07790bb..87213b1421 100644 --- a/engines/wintermute/base/base_frame.cpp +++ b/engines/wintermute/base/base_frame.cpp @@ -162,7 +162,7 @@ bool BaseFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { char *params;
int cmd;
- BaseParser parser(_gameRef);
+ BaseParser parser;
Rect32 rect;
int r = 255, g = 255, b = 255;
int ar = 255, ag = 255, ab = 255, alpha = 255;
diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index fdf638f94f..687e394920 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -27,6 +27,7 @@ */
#include "engines/wintermute/dcgf.h"
+#include "engines/wintermute/base/base_engine.h"
#include "engines/wintermute/base/base_game.h"
#include "engines/wintermute/base/base_fader.h"
#include "engines/wintermute/base/base_file_manager.h"
@@ -94,7 +95,6 @@ BaseGame::BaseGame(const Common::String &gameId) : BaseObject(this), _gameId(gam _fontStorage = NULL;
_renderer = NULL;
_soundMgr = NULL;
- _fileManager = NULL;
_transMgr = NULL;
_debugMgr = NULL;
_scEngine = NULL;
@@ -144,7 +144,6 @@ BaseGame::BaseGame(const Common::String &gameId) : BaseObject(this), _gameId(gam _useD3D = false;
- _registry = new BaseRegistry(this);
_stringTable = new BaseStringTable(this);
for (int i = 0; i < NUM_MUSIC_CHANNELS; i++) {
@@ -280,7 +279,7 @@ BaseGame::~BaseGame() { getDebugMgr()->onGameShutdown();
- _registry->writeBool("System", "LastRun", true);
+ BaseEngine::getInstance()->getRegistry()->writeBool("System", "LastRun", true);
cleanup();
@@ -304,8 +303,6 @@ BaseGame::~BaseGame() { //SAFE_DELETE(_keyboardState);
delete _renderer;
- delete _fileManager;
- delete _registry;
delete _stringTable;
_localSaveDir = NULL;
@@ -327,8 +324,6 @@ BaseGame::~BaseGame() { _debugMgr = NULL;
_renderer = NULL;
- _fileManager = NULL;
- _registry = NULL;
_stringTable = NULL;
DEBUG_DebugDisable();
@@ -429,11 +424,6 @@ bool BaseGame::initialize1() { break;
}
- _fileManager = new BaseFileManager(this);
- if (_fileManager == NULL) {
- break;
- }
-
_soundMgr = new BaseSoundMgr(this);
if (_soundMgr == NULL) {
break;
@@ -487,7 +477,6 @@ bool BaseGame::initialize1() { delete _surfaceStorage;
delete _fontStorage;
delete _soundMgr;
- delete _fileManager;
delete _scEngine;
delete _videoPlayer;
return STATUS_FAILED;
@@ -701,7 +690,7 @@ void BaseGame::getOffset(int *offsetX, int *offsetY) { //////////////////////////////////////////////////////////////////////////
bool BaseGame::loadFile(const char *filename) {
- byte *buffer = _gameRef->_fileManager->readWholeFile(filename);
+ byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename);
if (buffer == NULL) {
_gameRef->LOG(0, "BaseGame::LoadFile failed for file '%s'", filename);
return STATUS_FAILED;
@@ -809,7 +798,7 @@ bool BaseGame::loadBuffer(byte *buffer, bool complete) { byte *params;
int cmd;
- BaseParser parser(_gameRef);
+ BaseParser parser;
if (complete) {
if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_GAME) {
@@ -1560,7 +1549,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack stack->correctParams(2);
const char *key = stack->pop()->getString();
int val = stack->pop()->getInt();
- _registry->writeInt("PrivateSettings", key, val);
+ BaseEngine::getInstance()->getRegistry()->writeInt("PrivateSettings", key, val);
stack->pushNULL();
return STATUS_OK;
}
@@ -1572,7 +1561,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack stack->correctParams(2);
const char *key = stack->pop()->getString();
int initVal = stack->pop()->getInt();
- stack->pushInt(_registry->readInt("PrivateSettings", key, initVal));
+ stack->pushInt(BaseEngine::getInstance()->getRegistry()->readInt("PrivateSettings", key, initVal));
return STATUS_OK;
}
@@ -1583,7 +1572,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack stack->correctParams(2);
const char *key = stack->pop()->getString();
const char *val = stack->pop()->getString();
- _registry->writeString("PrivateSettings", key, val);
+ BaseEngine::getInstance()->getRegistry()->writeString("PrivateSettings", key, val);
stack->pushNULL();
return STATUS_OK;
}
@@ -1595,7 +1584,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack stack->correctParams(2);
const char *key = stack->pop()->getString();
const char *initVal = stack->pop()->getString();
- AnsiString val = _registry->readString("PrivateSettings", key, initVal);
+ AnsiString val = BaseEngine::getInstance()->getRegistry()->readString("PrivateSettings", key, initVal);
stack->pushString(val.c_str());
return STATUS_OK;
}
@@ -1818,7 +1807,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack stack->correctParams(1);
const char *filename = stack->pop()->getString();
- bool exists = _fileManager->hasFile(filename); // Had absPathWarning = false
+ bool exists = BaseFileManager::getEngineInstance()->hasFile(filename); // Had absPathWarning = false
stack->pushBool(exists);
return STATUS_OK;
}
@@ -2190,7 +2179,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack const char *filename = stack->pop()->getString();
bool asHex = stack->pop()->getBool(false);
- Common::SeekableReadStream *file = _fileManager->openFile(filename, false);
+ Common::SeekableReadStream *file = BaseFileManager::getEngineInstance()->openFile(filename, false);
if (file) {
crc remainder = crc_initialize();
byte buf[1024];
@@ -2214,7 +2203,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack stack->pushInt(checksum);
}
- _fileManager->closeFile(file);
+ BaseFileManager::getEngineInstance()->closeFile(file);
file = NULL;
} else {
stack->pushNULL();
@@ -2653,7 +2642,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { // MostRecentSaveSlot (RO)
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "MostRecentSaveSlot") == 0) {
- _scValue->setInt(_registry->readInt("System", "MostRecentSaveSlot", -1));
+ _scValue->setInt(BaseEngine::getInstance()->getRegistry()->readInt("System", "MostRecentSaveSlot", -1));
return _scValue;
}
@@ -3342,7 +3331,7 @@ bool BaseGame::saveGame(int slot, const char *desc, bool quickSave) { _indicatorDisplay = true;
_indicatorProgress = 0;
- BasePersistenceManager *pm = new BasePersistenceManager(_gameRef);
+ BasePersistenceManager *pm = new BasePersistenceManager();
if (DID_SUCCEED(ret = pm->initSave(desc))) {
if (!quickSave) {
delete _saveLoadImage;
@@ -3360,7 +3349,7 @@ bool BaseGame::saveGame(int slot, const char *desc, bool quickSave) { if (DID_SUCCEED(ret = SystemClassRegistry::getInstance()->saveTable(_gameRef, pm, quickSave))) {
if (DID_SUCCEED(ret = SystemClassRegistry::getInstance()->saveInstances(_gameRef, pm, quickSave))) {
if (DID_SUCCEED(ret = pm->saveFile(filename))) {
- _registry->writeInt("System", "MostRecentSaveSlot", slot);
+ BaseEngine::getInstance()->getRegistry()->writeInt("System", "MostRecentSaveSlot", slot);
}
}
}
@@ -3412,7 +3401,7 @@ bool BaseGame::loadGame(const char *filename) { _loadInProgress = true;
_indicatorDisplay = true;
_indicatorProgress = 0;
- BasePersistenceManager *pm = new BasePersistenceManager(_gameRef);
+ BasePersistenceManager *pm = new BasePersistenceManager();
if (DID_SUCCEED(ret = pm->initLoad(filename))) {
//if (DID_SUCCEED(ret = cleanup())) {
if (DID_SUCCEED(ret = SystemClassRegistry::getInstance()->loadTable(_gameRef, pm))) {
@@ -3628,7 +3617,7 @@ bool BaseGame::loadSettings(const char *filename) { TOKEN_TABLE_END
- byte *origBuffer = _gameRef->_fileManager->readWholeFile(filename);
+ byte *origBuffer = BaseFileManager::getEngineInstance()->readWholeFile(filename);
if (origBuffer == NULL) {
_gameRef->LOG(0, "BaseGame::LoadSettings failed for file '%s'", filename);
return STATUS_FAILED;
@@ -3639,7 +3628,7 @@ bool BaseGame::loadSettings(const char *filename) { byte *buffer = origBuffer;
byte *params;
int cmd;
- BaseParser parser(_gameRef);
+ BaseParser parser;
if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SETTINGS) {
_gameRef->LOG(0, "'SETTINGS' keyword expected in game settings file.");
@@ -3699,7 +3688,7 @@ bool BaseGame::loadSettings(const char *filename) { break;
case TOKEN_REGISTRY_PATH:
- _registry->setBasePath((char *)params);
+ BaseEngine::getInstance()->getRegistry()->setBasePath((char *)params);
break;
case TOKEN_RICH_SAVED_GAMES:
@@ -3723,8 +3712,8 @@ bool BaseGame::loadSettings(const char *filename) { ret = STATUS_FAILED;
}
- _settingsAllowWindowed = _registry->readBool("Debug", "AllowWindowed", _settingsAllowWindowed);
- _compressedSavegames = _registry->readBool("Debug", "CompressedSavegames", _compressedSavegames);
+ _settingsAllowWindowed = BaseEngine::getInstance()->getRegistry()->readBool("Debug", "AllowWindowed", _settingsAllowWindowed);
+ _compressedSavegames = BaseEngine::getInstance()->getRegistry()->readBool("Debug", "CompressedSavegames", _compressedSavegames);
//_compressedSavegames = false;
delete[] origBuffer;
@@ -4004,7 +3993,7 @@ void BaseGame::setWindowTitle() { //////////////////////////////////////////////////////////////////////////
bool BaseGame::getSaveSlotFilename(int slot, char *buffer) {
- BasePersistenceManager *pm = new BasePersistenceManager(_gameRef);
+ BasePersistenceManager *pm = new BasePersistenceManager();
Common::String filename = pm->getFilenameForSlot(slot);
delete pm;
strcpy(buffer, filename.c_str());
@@ -4018,7 +4007,7 @@ bool BaseGame::getSaveSlotDescription(int slot, char *buffer) { char filename[MAX_PATH_LENGTH + 1];
getSaveSlotFilename(slot, filename);
- BasePersistenceManager *pm = new BasePersistenceManager(_gameRef);
+ BasePersistenceManager *pm = new BasePersistenceManager();
if (!pm) {
return STATUS_FAILED;
}
@@ -4039,7 +4028,7 @@ bool BaseGame::getSaveSlotDescription(int slot, char *buffer) { bool BaseGame::isSaveSlotUsed(int slot) {
char filename[MAX_PATH_LENGTH + 1];
getSaveSlotFilename(slot, filename);
- BasePersistenceManager *pm = new BasePersistenceManager(_gameRef);
+ BasePersistenceManager *pm = new BasePersistenceManager();
bool ret = pm->getSaveExists(slot);
delete pm;
return ret;
@@ -4050,7 +4039,7 @@ bool BaseGame::isSaveSlotUsed(int slot) { bool BaseGame::emptySaveSlot(int slot) {
char filename[MAX_PATH_LENGTH + 1];
getSaveSlotFilename(slot, filename);
- BasePersistenceManager *pm = new BasePersistenceManager(this);
+ BasePersistenceManager *pm = new BasePersistenceManager();
g_wintermute->getSaveFileMan()->removeSavefile(pm->getFilenameForSlot(slot));
delete pm;
return STATUS_OK;
@@ -4724,7 +4713,7 @@ bool BaseGame::isDoubleClick(int buttonIndex) { //////////////////////////////////////////////////////////////////////////
void BaseGame::autoSaveOnExit() {
_soundMgr->saveSettings();
- _registry->saveValues();
+ BaseEngine::getInstance()->getRegistry()->saveValues();
if (!_autoSaveOnExit) {
return;
diff --git a/engines/wintermute/base/base_game.h b/engines/wintermute/base/base_game.h index 9adca0743c..40c9e254c4 100644 --- a/engines/wintermute/base/base_game.h +++ b/engines/wintermute/base/base_game.h @@ -135,7 +135,6 @@ public: bool initialize1();
bool initialize2();
bool initialize3();
- BaseFileManager *_fileManager;
BaseTransitionMgr *_transMgr;
BaseDebugger *getDebugMgr();
@@ -205,7 +204,6 @@ public: bool loadSettings(const char *filename);
bool displayWindows(bool inGame = false);
- BaseRegistry *_registry;
bool _useD3D;
virtual bool cleanup();
virtual bool loadGame(int slot);
diff --git a/engines/wintermute/base/base_parser.cpp b/engines/wintermute/base/base_parser.cpp index 3bd4f0441f..5dba8f9317 100644 --- a/engines/wintermute/base/base_parser.cpp +++ b/engines/wintermute/base/base_parser.cpp @@ -28,6 +28,7 @@ #include "engines/wintermute/base/base_parser.h"
#include "engines/wintermute/base/base_game.h"
+#include "engines/wintermute/base/base_engine.h"
#include "engines/wintermute/platform_osystem.h"
#include "common/str.h"
#include "common/util.h"
@@ -42,7 +43,7 @@ namespace WinterMute { //////////////////////////////////////////////////////////////////////
-BaseParser::BaseParser(BaseGame *inGame) : BaseClass(inGame) {
+BaseParser::BaseParser() {
_whiteSpace = new char [strlen(WHITESPACE) + 1];
strcpy(_whiteSpace, WHITESPACE);
}
@@ -122,7 +123,7 @@ int32 BaseParser::getCommand(char **buf, TokenDesc *tokens, char **params) { if (!*buf) {
return PARSERR_TOKENNOTFOUND;
}
- _gameRef->miniUpdate();
+ BaseEngine::getInstance()->getGameRef()->miniUpdate();
char *name;
return getObject(buf, tokens, &name, params);
}
diff --git a/engines/wintermute/base/base_parser.h b/engines/wintermute/base/base_parser.h index 03ca71b48d..3b1979efa1 100644 --- a/engines/wintermute/base/base_parser.h +++ b/engines/wintermute/base/base_parser.h @@ -52,12 +52,11 @@ #define PARSERR_EOF -2
#define PARSERR_TOKENNOTFOUND -1
-#include "engines/wintermute/base/base.h"
#include "engines/wintermute/coll_templ.h"
namespace WinterMute {
-class BaseParser : public BaseClass {
+class BaseParser {
public:
struct TokenDesc {
int32 id;
@@ -67,7 +66,7 @@ public: public:
int scanStr(const char *in, const char *format, ...);
int32 getCommand(char **buf, TokenDesc *tokens, char **params);
- BaseParser(BaseGame *inGame = NULL);
+ BaseParser();
virtual ~BaseParser();
private:
char *getLastOffender();
diff --git a/engines/wintermute/base/base_persistence_manager.cpp b/engines/wintermute/base/base_persistence_manager.cpp index ce7c66b7dd..2d30395928 100644 --- a/engines/wintermute/base/base_persistence_manager.cpp +++ b/engines/wintermute/base/base_persistence_manager.cpp @@ -29,6 +29,7 @@ #include "engines/wintermute/dcgf.h"
#include "engines/wintermute/base/base_file_manager.h"
#include "engines/wintermute/base/base_game.h"
+#include "engines/wintermute/base/base_engine.h"
#include "engines/wintermute/base/base_persistence_manager.h"
#include "engines/wintermute/base/base_save_thumb_helper.h"
#include "engines/wintermute/platform_osystem.h"
@@ -52,14 +53,18 @@ namespace WinterMute { #define SAVE_MAGIC_2 0x32564153
//////////////////////////////////////////////////////////////////////////
-BasePersistenceManager::BasePersistenceManager(BaseGame *inGame, const char *savePrefix) {
+BasePersistenceManager::BasePersistenceManager(const char *savePrefix) {
_saving = false;
// _buffer = NULL;
// _bufferSize = 0;
_offset = 0;
_saveStream = NULL;
_loadStream = NULL;
- _gameRef = inGame;
+ if (BaseEngine::getInstance()) {
+ _gameRef = BaseEngine::getInstance()->getGameRef();
+ } else {
+ _gameRef = NULL;
+ }
_richBuffer = NULL;
_richBufferSize = 0;
@@ -263,7 +268,7 @@ bool BasePersistenceManager::readHeader(const Common::String &filename) { _saving = false;
_loadStream = g_system->getSavefileManager()->openForLoading(filename);
- //_buffer = _gameRef->_fileManager->readWholeFile(filename, &_bufferSize);
+ //_buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename, &_bufferSize);
if (_loadStream) {
uint32 magic;
magic = getDWORD();
diff --git a/engines/wintermute/base/base_persistence_manager.h b/engines/wintermute/base/base_persistence_manager.h index cdb29fde6b..30fac6e191 100644 --- a/engines/wintermute/base/base_persistence_manager.h +++ b/engines/wintermute/base/base_persistence_manager.h @@ -87,7 +87,7 @@ public: bool transfer(const char *name, Common::String *val);
bool transfer(const char *name, Vector2 *val);
bool transfer(const char *name, AnsiStringArray &Val);
- BasePersistenceManager(BaseGame *inGame = NULL, const char *savePrefix = NULL);
+ BasePersistenceManager(const char *savePrefix = NULL);
virtual ~BasePersistenceManager();
bool checkVersion(byte verMajor, byte verMinor, byte verBuild);
diff --git a/engines/wintermute/base/base_region.cpp b/engines/wintermute/base/base_region.cpp index 7335d904c7..82dc359eb0 100644 --- a/engines/wintermute/base/base_region.cpp +++ b/engines/wintermute/base/base_region.cpp @@ -102,7 +102,7 @@ bool BaseRegion::pointInRegion(int x, int y) { //////////////////////////////////////////////////////////////////////////
bool BaseRegion::loadFile(const char *filename) {
- byte *buffer = _gameRef->_fileManager->readWholeFile(filename);
+ byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename);
if (buffer == NULL) {
_gameRef->LOG(0, "BaseRegion::LoadFile failed for file '%s'", filename);
return STATUS_FAILED;
@@ -150,7 +150,7 @@ bool BaseRegion::loadBuffer(byte *buffer, bool complete) { byte *params;
int cmd;
- BaseParser parser(_gameRef);
+ BaseParser parser;
if (complete) {
if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_REGION) {
diff --git a/engines/wintermute/base/base_registry.cpp b/engines/wintermute/base/base_registry.cpp index afaa01f06d..495f68b486 100644 --- a/engines/wintermute/base/base_registry.cpp +++ b/engines/wintermute/base/base_registry.cpp @@ -27,7 +27,7 @@ */
#include "engines/wintermute/tinyxml/tinyxml.h"
-#include "engines/wintermute/base/base_game.h"
+#include "engines/wintermute/base/base_engine.h"
#include "engines/wintermute/base/base_registry.h"
#include "engines/wintermute/utils/path_util.h"
#include "engines/wintermute/utils/string_util.h"
@@ -40,7 +40,7 @@ namespace WinterMute {
//////////////////////////////////////////////////////////////////////////
-BaseRegistry::BaseRegistry(BaseGame *inGame) : BaseClass(inGame) {
+BaseRegistry::BaseRegistry() {
_iniName = NULL;
setIniName("./wme.ini");
@@ -175,13 +175,13 @@ char *BaseRegistry::getIniName() { //////////////////////////////////////////////////////////////////////////
void BaseRegistry::loadValues(bool local) {
- Common::String filename = Common::String(_gameRef->getGameId()) + "-settings.xml";
+ Common::String filename = Common::String(BaseEngine::getInstance()->getGameId()) + "-settings.xml";
loadXml(filename, _values);
}
//////////////////////////////////////////////////////////////////////////
void BaseRegistry::saveValues() {
- Common::String filename = Common::String(_gameRef->getGameId()) + "-settings.xml";
+ Common::String filename = Common::String(BaseEngine::getInstance()->getGameId()) + "-settings.xml";
saveXml(filename, _values);
}
diff --git a/engines/wintermute/base/base_registry.h b/engines/wintermute/base/base_registry.h index 1d67c18e85..5e235c2a68 100644 --- a/engines/wintermute/base/base_registry.h +++ b/engines/wintermute/base/base_registry.h @@ -29,11 +29,14 @@ #ifndef WINTERMUTE_BREGISTRY_H
#define WINTERMUTE_BREGISTRY_H
-#include "engines/wintermute/base/base.h"
+#include "engines/wintermute/dctypes.h"
+#include "common/hashmap.h"
+#include "common/hash-str.h"
+#include "common/str.h"
namespace WinterMute {
-class BaseRegistry : public BaseClass {
+class BaseRegistry {
public:
void setIniName(const char *name);
char *getIniName();
@@ -43,7 +46,7 @@ public: int readInt(const AnsiString &subKey, const AnsiString &key, int init = 0);
bool writeString(const AnsiString &subKey, const AnsiString &key, const AnsiString &value);
AnsiString readString(const AnsiString &subKey, const AnsiString &key, const AnsiString &init = "");
- BaseRegistry(BaseGame *inGame);
+ BaseRegistry();
virtual ~BaseRegistry();
void setBasePath(const char *basePath);
diff --git a/engines/wintermute/base/base_save_thumb_helper.cpp b/engines/wintermute/base/base_save_thumb_helper.cpp index 8b71c73818..0d580e8db3 100644 --- a/engines/wintermute/base/base_save_thumb_helper.cpp +++ b/engines/wintermute/base/base_save_thumb_helper.cpp @@ -66,7 +66,7 @@ bool BaseSaveThumbHelper::storeThumbnail(bool doFlip) { // normal thumbnail
if (_gameRef->_thumbnailWidth > 0 && _gameRef->_thumbnailHeight > 0) {
- _thumbnail = new BaseImage(_gameRef->_fileManager);
+ _thumbnail = new BaseImage();
_thumbnail->copyFrom(screenshot, _gameRef->_thumbnailWidth, _gameRef->_thumbnailHeight);
}
diff --git a/engines/wintermute/base/base_script_holder.cpp b/engines/wintermute/base/base_script_holder.cpp index 51d1b32814..614ee7c7b8 100644 --- a/engines/wintermute/base/base_script_holder.cpp +++ b/engines/wintermute/base/base_script_holder.cpp @@ -380,7 +380,7 @@ bool BaseScriptHolder::parseProperty(byte *buffer, bool complete) { byte *params;
int cmd;
- BaseParser parser(_gameRef);
+ BaseParser parser;
if (complete) {
if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_PROPERTY) {
diff --git a/engines/wintermute/base/base_sprite.cpp b/engines/wintermute/base/base_sprite.cpp index 6ab8e60a17..bc2167c618 100644 --- a/engines/wintermute/base/base_sprite.cpp +++ b/engines/wintermute/base/base_sprite.cpp @@ -125,7 +125,7 @@ bool BaseSprite::draw(int x, int y, BaseObject *registerOwner, float zoomX, floa //////////////////////////////////////////////////////////////////////
bool BaseSprite::loadFile(const Common::String &filename, int lifeTime, TSpriteCacheType cacheType) {
- Common::SeekableReadStream *file = _gameRef->_fileManager->openFile(filename);
+ Common::SeekableReadStream *file = BaseFileManager::getEngineInstance()->openFile(filename);
if (!file) {
_gameRef->LOG(0, "BaseSprite::LoadFile failed for file '%s'", filename.c_str());
if (_gameRef->_debugDebugMode) {
@@ -134,7 +134,7 @@ bool BaseSprite::loadFile(const Common::String &filename, int lifeTime, TSpriteC return loadFile("invalid.bmp", lifeTime, cacheType);
}
} else {
- _gameRef->_fileManager->closeFile(file);
+ BaseFileManager::getEngineInstance()->closeFile(file);
file = NULL;
}
@@ -158,7 +158,7 @@ bool BaseSprite::loadFile(const Common::String &filename, int lifeTime, TSpriteC ret = STATUS_OK;
}
} else {
- byte *buffer = _gameRef->_fileManager->readWholeFile(filename);
+ byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename);
if (buffer) {
if (DID_FAIL(ret = loadBuffer(buffer, true, lifeTime, cacheType))) {
_gameRef->LOG(0, "Error parsing SPRITE file '%s'", filename.c_str());
@@ -213,7 +213,7 @@ bool BaseSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteCa byte *params;
int cmd;
- BaseParser parser(_gameRef);
+ BaseParser parser;
cleanup();
diff --git a/engines/wintermute/base/base_string_table.cpp b/engines/wintermute/base/base_string_table.cpp index 8dc9e25e4b..8fa69e5288 100644 --- a/engines/wintermute/base/base_string_table.cpp +++ b/engines/wintermute/base/base_string_table.cpp @@ -193,7 +193,7 @@ bool BaseStringTable::loadFile(const char *filename, bool clearOld) { }
uint32 size;
- byte *buffer = _gameRef->_fileManager->readWholeFile(filename, &size);
+ byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename, &size);
if (buffer == NULL) {
_gameRef->LOG(0, "BaseStringTable::LoadFile failed for file '%s'", filename);
return STATUS_FAILED;
diff --git a/engines/wintermute/base/base_sub_frame.cpp b/engines/wintermute/base/base_sub_frame.cpp index 6ce8c78b3b..333e2f4f9c 100644 --- a/engines/wintermute/base/base_sub_frame.cpp +++ b/engines/wintermute/base/base_sub_frame.cpp @@ -110,7 +110,7 @@ bool BaseSubFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { char *params;
int cmd;
- BaseParser parser(_gameRef);
+ BaseParser parser;
Rect32 rect;
int r = 255, g = 255, b = 255;
int ar = 255, ag = 255, ab = 255, alpha = 255;
diff --git a/engines/wintermute/base/base_surface_storage.cpp b/engines/wintermute/base/base_surface_storage.cpp index 7d6f499012..e3c3692892 100644 --- a/engines/wintermute/base/base_surface_storage.cpp +++ b/engines/wintermute/base/base_surface_storage.cpp @@ -108,7 +108,7 @@ BaseSurface *BaseSurfaceStorage::addSurface(const Common::String &filename, bool }
}
- if (!_gameRef->_fileManager->hasFile(filename)) {
+ if (!BaseFileManager::getEngineInstance()->hasFile(filename)) {
if (filename.size()) {
_gameRef->LOG(0, "Missing image: '%s'", filename.c_str());
}
diff --git a/engines/wintermute/base/file/base_file.cpp b/engines/wintermute/base/file/base_file.cpp index 11d095e70b..185a21ad57 100644 --- a/engines/wintermute/base/file/base_file.cpp +++ b/engines/wintermute/base/file/base_file.cpp @@ -37,7 +37,7 @@ namespace WinterMute { //////////////////////////////////////////////////////////////////////////
-BaseFile::BaseFile(BaseGame *inGame) : BaseClass(inGame) {
+BaseFile::BaseFile() {
_pos = 0;
_size = 0;
}
diff --git a/engines/wintermute/base/file/base_file.h b/engines/wintermute/base/file/base_file.h index 1a144414fc..0c1ab2a045 100644 --- a/engines/wintermute/base/file/base_file.h +++ b/engines/wintermute/base/file/base_file.h @@ -40,7 +40,7 @@ class SeekableReadStream; namespace WinterMute {
-class BaseFile : public BaseClass {
+class BaseFile {
protected:
uint32 _pos;
uint32 _size;
@@ -56,7 +56,7 @@ public: virtual bool close() = 0;
virtual bool open(const Common::String &filename) = 0;
virtual bool isEOF();
- BaseFile(BaseGame *inGame);
+ BaseFile();
virtual ~BaseFile();
// Temporary solution to allow usage in ScummVM-code:
virtual Common::SeekableReadStream *getMemStream();
diff --git a/engines/wintermute/base/file/base_save_thumb_file.cpp b/engines/wintermute/base/file/base_save_thumb_file.cpp index a285a93923..1f7288a6ff 100644 --- a/engines/wintermute/base/file/base_save_thumb_file.cpp +++ b/engines/wintermute/base/file/base_save_thumb_file.cpp @@ -26,7 +26,7 @@ * Copyright (c) 2011 Jan Nedoma
*/
-#include "engines/wintermute/base/base_game.h"
+#include "engines/wintermute/base/base_persistence_manager.h"
#include "engines/wintermute/base/file/base_save_thumb_file.h"
#include "engines/wintermute/platform_osystem.h"
@@ -38,7 +38,7 @@ namespace WinterMute { //////////////////////////////////////////////////////////////////////////
-BaseSaveThumbFile::BaseSaveThumbFile(BaseGame *inGame) : BaseFile(inGame) {
+BaseSaveThumbFile::BaseSaveThumbFile() {
_data = NULL;
}
@@ -70,7 +70,7 @@ bool BaseSaveThumbFile::open(const Common::String &filename) { int slot = atoi(tempFilename);
delete[] tempFilename;
- BasePersistenceManager *pm = new BasePersistenceManager(_gameRef);
+ BasePersistenceManager *pm = new BasePersistenceManager();
Common::String slotFilename = pm->getFilenameForSlot(slot);
if (!pm) {
return STATUS_FAILED;
diff --git a/engines/wintermute/base/file/base_save_thumb_file.h b/engines/wintermute/base/file/base_save_thumb_file.h index 6065f10f81..d95958d95f 100644 --- a/engines/wintermute/base/file/base_save_thumb_file.h +++ b/engines/wintermute/base/file/base_save_thumb_file.h @@ -37,7 +37,7 @@ namespace WinterMute { //TODO: Get rid of this
class BaseSaveThumbFile : public BaseFile {
public:
- BaseSaveThumbFile(BaseGame *Game);
+ BaseSaveThumbFile();
virtual ~BaseSaveThumbFile();
virtual bool seek(uint32 pos, int whence = SEEK_SET);
virtual bool read(void *buffer, uint32 size);
diff --git a/engines/wintermute/base/font/base_font.cpp b/engines/wintermute/base/font/base_font.cpp index 4a5cd31002..fa9242366e 100644 --- a/engines/wintermute/base/font/base_font.cpp +++ b/engines/wintermute/base/font/base_font.cpp @@ -31,7 +31,6 @@ #include "engines/wintermute/base/font/base_font_truetype.h"
#include "engines/wintermute/base/base_parser.h"
#include "engines/wintermute/base/base_file_manager.h"
-#include "engines/wintermute/base/base_game.h"
namespace WinterMute {
@@ -72,7 +71,7 @@ int BaseFont::getTextWidth(byte *text, int maxLength) { //////////////////////////////////////////////////////////////////////
bool BaseFont::loadFile(const char * Filename)
{
- BYTE* Buffer = _gameRef->_fileManager->readWholeFile(filename);
+ BYTE* Buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename);
if (Buffer==NULL){
_gameRef->LOG(0, "BaseFont::LoadFile failed for file '%s'", filename);
return STATUS_FAILED;
@@ -103,7 +102,7 @@ bool BaseFont::loadBuffer(byte * Buffer) char* params;
int cmd;
- BaseParser parser(_gameRef);
+ BaseParser parser;
if (parser.GetCommand ((char**)&Buffer, commands, (char**)¶ms)!=TOKEN_FONT){
_gameRef->LOG(0, "'FONT' keyword expected.");
@@ -186,7 +185,7 @@ bool BaseFont::isTrueType(BaseGame *gameRef, const Common::String &filename) { TOKEN_TABLE_END
- byte *buffer = gameRef->_fileManager->readWholeFile(filename);
+ byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename);
if (buffer == NULL) {
return false;
}
@@ -194,7 +193,7 @@ bool BaseFont::isTrueType(BaseGame *gameRef, const Common::String &filename) { byte *workBuffer = buffer;
char *params;
- BaseParser parser(gameRef);
+ BaseParser parser;
bool ret = false;
if (parser.getCommand((char **)&workBuffer, commands, (char **)¶ms) == TOKEN_TTFONT) {
diff --git a/engines/wintermute/base/font/base_font_bitmap.cpp b/engines/wintermute/base/font/base_font_bitmap.cpp index e7bf362b32..6585d7cb0a 100644 --- a/engines/wintermute/base/font/base_font_bitmap.cpp +++ b/engines/wintermute/base/font/base_font_bitmap.cpp @@ -271,7 +271,7 @@ void BaseFontBitmap::drawChar(byte c, int x, int y) { //////////////////////////////////////////////////////////////////////
bool BaseFontBitmap::loadFile(const Common::String &filename) {
- byte *buffer = _gameRef->_fileManager->readWholeFile(filename);
+ byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename);
if (buffer == NULL) {
_gameRef->LOG(0, "BaseFontBitmap::LoadFile failed for file '%s'", filename.c_str());
return STATUS_FAILED;
@@ -332,7 +332,7 @@ bool BaseFontBitmap::loadBuffer(byte *buffer) { char *params;
int cmd;
- BaseParser parser(_gameRef);
+ BaseParser parser;
if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_FONT) {
_gameRef->LOG(0, "'FONT' keyword expected.");
diff --git a/engines/wintermute/base/font/base_font_truetype.cpp b/engines/wintermute/base/font/base_font_truetype.cpp index 793c044839..a141c68db7 100644 --- a/engines/wintermute/base/font/base_font_truetype.cpp +++ b/engines/wintermute/base/font/base_font_truetype.cpp @@ -293,7 +293,7 @@ int BaseFontTT::getLetterHeight() { //////////////////////////////////////////////////////////////////////
bool BaseFontTT::loadFile(const Common::String &filename) {
- byte *buffer = _gameRef->_fileManager->readWholeFile(filename);
+ byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename);
if (buffer == NULL) {
_gameRef->LOG(0, "BaseFontTT::LoadFile failed for file '%s'", filename.c_str());
return STATUS_FAILED;
@@ -348,7 +348,7 @@ bool BaseFontTT::loadBuffer(byte *buffer) { char *params;
int cmd;
- BaseParser parser(_gameRef);
+ BaseParser parser;
if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_TTFONT) {
_gameRef->LOG(0, "'TTFONT' keyword expected.");
@@ -451,7 +451,7 @@ bool BaseFontTT::parseLayer(BaseTTFontLayer *layer, byte *buffer) { char *params;
int cmd;
- BaseParser parser(_gameRef);
+ BaseParser parser;
while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) {
switch (cmd) {
@@ -538,13 +538,13 @@ bool BaseFontTT::initFont() { return STATUS_FAILED;
}
- Common::SeekableReadStream *file = _gameRef->_fileManager->openFile(_fontFile);
+ Common::SeekableReadStream *file = BaseFileManager::getEngineInstance()->openFile(_fontFile);
if (!file) {
//TODO: Try to fallback from Arial to FreeSans
/*
// the requested font file is not in wme file space; try loading a system font
AnsiString fontFileName = PathUtil::combine(BasePlatform::getSystemFontPath(), PathUtil::getFileName(_fontFile));
- file = _gameRef->_fileManager->openFile(fontFileName.c_str(), false);
+ file = BaseFileManager::getEngineInstance()->openFile(fontFileName.c_str(), false);
if (!file) {
_gameRef->LOG(0, "Error loading TrueType font '%s'", _fontFile);
//return STATUS_FAILED;
diff --git a/engines/wintermute/base/gfx/base_image.cpp b/engines/wintermute/base/gfx/base_image.cpp index 1fff59d85b..2167503dc8 100644 --- a/engines/wintermute/base/gfx/base_image.cpp +++ b/engines/wintermute/base/gfx/base_image.cpp @@ -42,8 +42,8 @@ namespace WinterMute {
//////////////////////////////////////////////////////////////////////
-BaseImage::BaseImage(BaseFileManager *fileManager) {
- _fileManager = fileManager;
+BaseImage::BaseImage() {
+ _fileManager = BaseFileManager::getEngineInstance();
_palette = NULL;
_surface = NULL;
_decoder = NULL;
diff --git a/engines/wintermute/base/gfx/base_image.h b/engines/wintermute/base/gfx/base_image.h index ed0142ea95..76a389977d 100644 --- a/engines/wintermute/base/gfx/base_image.h +++ b/engines/wintermute/base/gfx/base_image.h @@ -42,7 +42,7 @@ class BaseFileManager; class BaseImage {
public:
- BaseImage(BaseFileManager *fileManager);
+ BaseImage();
~BaseImage();
bool loadFile(const Common::String &filename);
diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index 58839d5ffe..51b0c2dd36 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -28,6 +28,7 @@ #include "engines/wintermute/base/gfx/osystem/base_render_osystem.h"
#include "engines/wintermute/base/base_registry.h"
+#include "engines/wintermute/base/base_engine.h"
#include "engines/wintermute/base/gfx/osystem/base_surface_osystem.h"
#include "engines/wintermute/base/base_surface_storage.h"
#include "engines/wintermute/base/gfx/base_image.h"
@@ -126,8 +127,8 @@ bool BaseRenderOSystem::initRenderer(int width, int height, bool windowed) { //TODO: Tiny resolution-displays might want to do some resolution-selection logic here
- _realWidth = _gameRef->_registry->readInt("Debug", "ForceResWidth", _width);
- _realHeight = _gameRef->_registry->readInt("Debug", "ForceResHeight", _height);
+ _realWidth = BaseEngine::getInstance()->getRegistry()->readInt("Debug", "ForceResWidth", _width);
+ _realHeight = BaseEngine::getInstance()->getRegistry()->readInt("Debug", "ForceResHeight", _height);
float origAspect = (float)_width / (float)_height;
float realAspect = (float)_realWidth / (float)_realHeight;
@@ -152,7 +153,7 @@ bool BaseRenderOSystem::initRenderer(int width, int height, bool windowed) { _ratioX = (float)(_realWidth - _borderLeft - _borderRight) / (float)_width;
_ratioY = (float)(_realHeight - _borderTop - _borderBottom) / (float)_height;
- //_windowed = _gameRef->_registry->readBool("Video", "Windowed", true); TODO
+ //_windowed = BaseEngine::getInstance()->getRegistry()->readBool("Video", "Windowed", true); TODO
Graphics::PixelFormat format(4, 8, 8, 8, 8, 24, 16, 8, 0);
g_system->beginGFXTransaction();
@@ -496,7 +497,7 @@ bool BaseRenderOSystem::drawLine(int x1, int y1, int x2, int y2, uint32 color) { BaseImage *BaseRenderOSystem::takeScreenshot() {
// TODO: Clip by viewport.
warning("BaseRenderOSystem::TakeScreenshot() - not ported yet");
- BaseImage *screenshot = new BaseImage(_gameRef->_fileManager);
+ BaseImage *screenshot = new BaseImage();
screenshot->copyFrom(_renderSurface);
return screenshot;
}
diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp index 642f2179e6..c449f6471c 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp @@ -119,7 +119,7 @@ bool BaseSurfaceOSystem::create(const Common::String &filename, bool defaultCK, }
bool BaseSurfaceOSystem::finishLoad() {
- BaseImage *image = new BaseImage(_gameRef->_fileManager);
+ BaseImage *image = new BaseImage();
if (!image->loadFile(_filename)) {
return false;
}
diff --git a/engines/wintermute/base/particles/part_emitter.cpp b/engines/wintermute/base/particles/part_emitter.cpp index 7389885f5a..ced01b7fd9 100644 --- a/engines/wintermute/base/particles/part_emitter.cpp +++ b/engines/wintermute/base/particles/part_emitter.cpp @@ -128,12 +128,12 @@ bool PartEmitter::addSprite(const char *filename) { }
// check if file exists
- Common::SeekableReadStream *File = _gameRef->_fileManager->openFile(filename);
+ Common::SeekableReadStream *File = BaseFileManager::getEngineInstance()->openFile(filename);
if (!File) {
_gameRef->LOG(0, "Sprite '%s' not found", filename);
return STATUS_FAILED;
} else {
- _gameRef->_fileManager->closeFile(File);
+ BaseFileManager::getEngineInstance()->closeFile(File);
}
char *str = new char[strlen(filename) + 1];
diff --git a/engines/wintermute/base/particles/part_particle.cpp b/engines/wintermute/base/particles/part_particle.cpp index 2b05edd61f..1a449a50a5 100644 --- a/engines/wintermute/base/particles/part_particle.cpp +++ b/engines/wintermute/base/particles/part_particle.cpp @@ -29,7 +29,6 @@ #include "engines/wintermute/base/particles/part_particle.h"
#include "engines/wintermute/base/particles/part_emitter.h"
#include "engines/wintermute/base/base_sprite.h"
-#include "engines/wintermute/base/base_game.h"
#include "engines/wintermute/utils/utils.h"
#include "engines/wintermute/platform_osystem.h"
#include "common/str.h"
@@ -80,7 +79,7 @@ bool PartParticle::setSprite(const Common::String &filename) { _sprite = NULL;
SystemClassRegistry::getInstance()->_disabled = true;
- _sprite = new BaseSprite(_gameRef, _gameRef);
+ _sprite = new BaseSprite(_gameRef, (BaseObject*)_gameRef);
if (_sprite && DID_SUCCEED(_sprite->loadFile(filename))) {
SystemClassRegistry::getInstance()->_disabled = false;
return STATUS_OK;
diff --git a/engines/wintermute/base/scriptables/script_engine.cpp b/engines/wintermute/base/scriptables/script_engine.cpp index 01f647c110..9e11a7c5b4 100644 --- a/engines/wintermute/base/scriptables/script_engine.cpp +++ b/engines/wintermute/base/scriptables/script_engine.cpp @@ -33,6 +33,7 @@ #include "engines/wintermute/base/scriptables/script_stack.h"
#include "engines/wintermute/base/scriptables/script_ext_math.h"
#include "engines/wintermute/base/base_registry.h"
+#include "engines/wintermute/base/base_engine.h"
#include "engines/wintermute/base/base_game.h"
#include "engines/wintermute/base/sound/base_sound.h"
#include "engines/wintermute/base/base_file_manager.h"
@@ -128,7 +129,7 @@ bool ScEngine::cleanup() { //////////////////////////////////////////////////////////////////////////
byte *ScEngine::loadFile(void *data, char *filename, uint32 *size) {
BaseGame *gameRef = (BaseGame *)data;
- return gameRef->_fileManager->readWholeFile(filename, size);
+ return BaseFileManager::getEngineInstance()->readWholeFile(filename, size);
}
@@ -200,7 +201,7 @@ byte *ScEngine::getCompiledScript(const char *filename, uint32 *outSize, bool ig uint32 size;
- byte *buffer = _gameRef->_fileManager->readWholeFile(filename, &size);
+ byte *buffer = BaseEngine::getInstance()->getFileManager()->readWholeFile(filename, &size);
if (!buffer) {
_gameRef->LOG(0, "ScEngine::GetCompiledScript - error opening script '%s'", filename);
return NULL;
@@ -689,10 +690,10 @@ bool ScEngine::saveBreakpoints() { sprintf(key, "Breakpoint%d", count);
sprintf(text, "%s:%d", _breakpoints[i]->_filename.c_str(), _breakpoints[i]->_lines[j]);
- _gameRef->_registry->writeString("Debug", key, text);
+ BaseEngine::getInstance()->getRegistry()->writeString("Debug", key, text);
}
}
- _gameRef->_registry->writeInt("Debug", "NumBreakpoints", count);
+ BaseEngine::getInstance()->getRegistry()->writeInt("Debug", "NumBreakpoints", count);
return STATUS_OK;
}
@@ -705,11 +706,11 @@ bool ScEngine::loadBreakpoints() { char key[100];
- int count = _gameRef->_registry->readInt("Debug", "NumBreakpoints", 0);
+ int count = BaseEngine::getInstance()->getRegistry()->readInt("Debug", "NumBreakpoints", 0);
for (int i = 1; i <= count; i++) {
/* uint32 bufSize = 512; */
sprintf(key, "Breakpoint%d", i);
- AnsiString breakpoint = _gameRef->_registry->readString("Debug", key, "");
+ AnsiString breakpoint = BaseEngine::getInstance()->getRegistry()->readString("Debug", key, "");
char *path = BaseUtils::strEntry(0, breakpoint.c_str(), ':');
char *line = BaseUtils::strEntry(1, breakpoint.c_str(), ':');
diff --git a/engines/wintermute/base/scriptables/script_ext_file.cpp b/engines/wintermute/base/scriptables/script_ext_file.cpp index 5743722d6f..50d89921e1 100644 --- a/engines/wintermute/base/scriptables/script_ext_file.cpp +++ b/engines/wintermute/base/scriptables/script_ext_file.cpp @@ -82,7 +82,7 @@ void SXFile::cleanup() { //////////////////////////////////////////////////////////////////////////
void SXFile::close() {
if (_readFile) {
- _gameRef->_fileManager->closeFile(_readFile);
+ BaseFileManager::getEngineInstance()->closeFile(_readFile);
_readFile = NULL;
}
if (_writeFile) {
@@ -130,7 +130,7 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, _mode = 1;
}
if (_mode == 1) {
- _readFile = _gameRef->_fileManager->openFile(_filename);
+ _readFile = BaseFileManager::getEngineInstance()->openFile(_filename);
if (!_readFile) {
//script->runtimeError("File.%s: Error opening file '%s' for reading.", Name, _filename);
close();
@@ -785,7 +785,7 @@ bool SXFile::persist(BasePersistenceManager *persistMgr) { if (_mode != 0) {
// open for reading
if (_mode == 1) {
- _readFile = _gameRef->_fileManager->openFile(_filename);
+ _readFile = BaseFileManager::getEngineInstance()->openFile(_filename);
if (!_readFile) {
close();
}
diff --git a/engines/wintermute/base/sound/base_sound_buffer.cpp b/engines/wintermute/base/sound/base_sound_buffer.cpp index 5f36eb96d4..ac329704bc 100644 --- a/engines/wintermute/base/sound/base_sound_buffer.cpp +++ b/engines/wintermute/base/sound/base_sound_buffer.cpp @@ -96,7 +96,7 @@ bool BaseSoundBuffer::loadFromFile(const Common::String &filename, bool forceRel debugC(kWinterMuteDebugAudio, "BSoundBuffer::LoadFromFile(%s,%d)", filename.c_str(), forceReload);
// Load a file, but avoid having the File-manager handle the disposal of it.
- _file = _gameRef->_fileManager->openFile(filename, true, false);
+ _file = BaseFileManager::getEngineInstance()->openFile(filename, true, false);
if (!_file) {
_gameRef->LOG(0, "Error opening sound file '%s'", filename.c_str());
return STATUS_FAILED;
diff --git a/engines/wintermute/base/sound/base_sound_manager.cpp b/engines/wintermute/base/sound/base_sound_manager.cpp index 8df9f299ef..61c7376c79 100644 --- a/engines/wintermute/base/sound/base_sound_manager.cpp +++ b/engines/wintermute/base/sound/base_sound_manager.cpp @@ -28,6 +28,7 @@ #include "engines/wintermute/base/sound/base_sound_manager.h"
#include "engines/wintermute/base/base_registry.h"
+#include "engines/wintermute/base/base_engine.h"
#include "engines/wintermute/utils/path_util.h"
#include "engines/wintermute/utils/string_util.h"
#include "engines/wintermute/base/base_game.h"
@@ -71,7 +72,7 @@ bool BaseSoundMgr::cleanup() { //////////////////////////////////////////////////////////////////////////
void BaseSoundMgr::saveSettings() {
if (_soundAvailable) {
- _gameRef->_registry->writeInt("Audio", "MasterVolume", _volumeMaster);
+ BaseEngine::getInstance()->getRegistry()->writeInt("Audio", "MasterVolume", _volumeMaster);
}
}
@@ -82,7 +83,7 @@ bool BaseSoundMgr::initialize() { if (!g_system->getMixer()->isReady()) {
return STATUS_FAILED;
}
- _volumeMaster = _gameRef->_registry->readInt("Audio", "MasterVolume", 255);
+ _volumeMaster = BaseEngine::getInstance()->getRegistry()->readInt("Audio", "MasterVolume", 255);
_soundAvailable = true;
return STATUS_OK;
@@ -104,7 +105,7 @@ BaseSoundBuffer *BaseSoundMgr::addSound(const Common::String &filename, Audio::M AnsiString name = PathUtil::getFileNameWithoutExtension(filename);
AnsiString newFile = PathUtil::combine(path, name + "ogg");
- if (_gameRef->_fileManager->hasFile(newFile)) {
+ if (BaseFileManager::getEngineInstance()->hasFile(newFile)) {
useFilename = newFile;
}
}
|