WINTERMUTE: Avoid including BaseGame in BaseFrame.

This commit is contained in:
Einar Johan Trøan Sømåen 2013-04-18 11:13:32 +02:00
parent 4783d643f6
commit a8f4f20f38
3 changed files with 17 additions and 6 deletions

View file

@ -90,4 +90,12 @@ uint32 BaseEngine::randInt(int from, int to) {
return _rnd->getRandomNumberRng(from, to);
}
BaseSoundMgr *BaseEngine::getSoundMgr() {
if (instance()._gameRef) {
return _gameRef->_soundMgr;
} else {
return nullptr;
}
}
} // end of namespace Wintermute

View file

@ -39,6 +39,7 @@ namespace Wintermute {
class BaseFileManager;
class BaseRegistry;
class BaseGame;
class BaseSoundMgr;
class SystemClassRegistry;
class BaseEngine : public Common::Singleton<Wintermute::BaseEngine> {
void init(Common::Language lang);
@ -60,6 +61,7 @@ public:
SystemClassRegistry *getClassRegistry() { return _classReg; }
BaseGame *getGameRef() { return _gameRef; }
BaseFileManager *getFileManager() { return _fileManager; }
BaseSoundMgr *getSoundMgr();
static void LOG(bool res, const char *fmt, ...);
const char *getGameId() { return _gameId.c_str(); }
};

View file

@ -27,8 +27,9 @@
*/
#include "engines/wintermute/base/base_parser.h"
#include "engines/wintermute/base/base_engine.h"
#include "engines/wintermute/base/base_frame.h"
#include "engines/wintermute/base/base_game.h"
#include "engines/wintermute/base/base_object.h"
#include "engines/wintermute/base/base_dynamic_buffer.h"
#include "engines/wintermute/base/sound/base_sound_manager.h"
#include "engines/wintermute/base/sound/base_sound.h"
@ -264,8 +265,8 @@ bool BaseFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) {
}
_sound = new BaseSound(_gameRef);
if (!_sound || DID_FAIL(_sound->setSound(params, Audio::Mixer::kSFXSoundType, false))) {
if (_gameRef->_soundMgr->_soundAvailable) {
_gameRef->LOG(0, "Error loading sound '%s'.", params);
if (BaseEngine::instance().getSoundMgr()->_soundAvailable) {
BaseEngine::LOG(0, "Error loading sound '%s'.", params);
}
delete _sound;
_sound = nullptr;
@ -294,12 +295,12 @@ bool BaseFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) {
}
}
if (cmd == PARSERR_TOKENNOTFOUND) {
_gameRef->LOG(0, "Syntax error in FRAME definition");
BaseEngine::LOG(0, "Syntax error in FRAME definition");
return STATUS_FAILED;
}
if (cmd == PARSERR_GENERIC) {
_gameRef->LOG(0, "Error loading FRAME definition");
BaseEngine::LOG(0, "Error loading FRAME definition");
return STATUS_FAILED;
}
@ -314,7 +315,7 @@ bool BaseFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) {
if (!sub->_surface) {
delete sub;
_gameRef->LOG(0, "Error loading SUBFRAME");
BaseEngine::LOG(0, "Error loading SUBFRAME");
return STATUS_FAILED;
}