aboutsummaryrefslogtreecommitdiff
path: root/engines/wintermute/Base
diff options
context:
space:
mode:
Diffstat (limited to 'engines/wintermute/Base')
-rw-r--r--engines/wintermute/Base/BActiveRect.cpp4
-rw-r--r--engines/wintermute/Base/BBase.cpp16
-rw-r--r--engines/wintermute/Base/BBase.h2
-rw-r--r--engines/wintermute/Base/BDynBuffer.cpp6
-rw-r--r--engines/wintermute/Base/BFader.cpp8
-rw-r--r--engines/wintermute/Base/BFileManager.cpp44
-rw-r--r--engines/wintermute/Base/BFrame.cpp26
-rw-r--r--engines/wintermute/Base/BGame.cpp196
-rw-r--r--engines/wintermute/Base/BImage.cpp4
-rw-r--r--engines/wintermute/Base/BObject.cpp22
-rw-r--r--engines/wintermute/Base/BPackage.cpp6
-rw-r--r--engines/wintermute/Base/BParser.cpp2
-rw-r--r--engines/wintermute/Base/BPersistMgr.cpp44
-rw-r--r--engines/wintermute/Base/BQuickMsg.cpp2
-rw-r--r--engines/wintermute/Base/BRegion.cpp12
-rw-r--r--engines/wintermute/Base/BRegistry.cpp4
-rw-r--r--engines/wintermute/Base/BRenderSDL.cpp22
-rw-r--r--engines/wintermute/Base/BSaveThumbHelper.cpp18
-rw-r--r--engines/wintermute/Base/BScriptHolder.cpp28
-rw-r--r--engines/wintermute/Base/BScriptable.cpp10
-rw-r--r--engines/wintermute/Base/BSound.cpp10
-rw-r--r--engines/wintermute/Base/BSoundBuffer.cpp18
-rw-r--r--engines/wintermute/Base/BSoundMgr.cpp12
-rw-r--r--engines/wintermute/Base/BSprite.cpp48
-rw-r--r--engines/wintermute/Base/BStringTable.cpp26
-rw-r--r--engines/wintermute/Base/BSubFrame.cpp24
-rw-r--r--engines/wintermute/Base/BSurface.cpp4
-rw-r--r--engines/wintermute/Base/BSurfaceSDL.cpp24
-rw-r--r--engines/wintermute/Base/BSurfaceStorage.cpp22
-rw-r--r--engines/wintermute/Base/BTransitionMgr.cpp10
-rw-r--r--engines/wintermute/Base/BViewport.cpp6
-rw-r--r--engines/wintermute/Base/file/BSaveThumbFile.cpp10
-rw-r--r--engines/wintermute/Base/font/BFont.cpp26
-rw-r--r--engines/wintermute/Base/font/BFontBitmap.cpp32
-rw-r--r--engines/wintermute/Base/font/BFontStorage.cpp8
-rw-r--r--engines/wintermute/Base/font/BFontTT.cpp38
-rw-r--r--engines/wintermute/Base/particles/PartEmitter.cpp22
-rw-r--r--engines/wintermute/Base/particles/PartParticle.cpp2
-rw-r--r--engines/wintermute/Base/scriptables/SXArray.cpp4
-rw-r--r--engines/wintermute/Base/scriptables/SXFile.cpp6
-rw-r--r--engines/wintermute/Base/scriptables/SXMemBuffer.cpp2
-rw-r--r--engines/wintermute/Base/scriptables/SXString.cpp36
-rw-r--r--engines/wintermute/Base/scriptables/ScEngine.cpp78
-rw-r--r--engines/wintermute/Base/scriptables/ScScript.cpp92
-rw-r--r--engines/wintermute/Base/scriptables/ScStack.cpp24
-rw-r--r--engines/wintermute/Base/scriptables/ScValue.cpp30
46 files changed, 545 insertions, 545 deletions
diff --git a/engines/wintermute/Base/BActiveRect.cpp b/engines/wintermute/Base/BActiveRect.cpp
index be9c543469..ca0dcddc28 100644
--- a/engines/wintermute/Base/BActiveRect.cpp
+++ b/engines/wintermute/Base/BActiveRect.cpp
@@ -88,8 +88,8 @@ CBActiveRect::~CBActiveRect() {
void CBActiveRect::clipRect() {
Rect32 rc;
bool customViewport;
- Game->getCurrentViewportRect(&rc, &customViewport);
- CBRenderer *Rend = Game->_renderer;
+ _gameRef->getCurrentViewportRect(&rc, &customViewport);
+ CBRenderer *Rend = _gameRef->_renderer;
if (!customViewport) {
rc.left -= Rend->_drawOffsetX;
diff --git a/engines/wintermute/Base/BBase.cpp b/engines/wintermute/Base/BBase.cpp
index a43a9d78db..bdfcfccdd5 100644
--- a/engines/wintermute/Base/BBase.cpp
+++ b/engines/wintermute/Base/BBase.cpp
@@ -35,15 +35,15 @@
namespace WinterMute {
//////////////////////////////////////////////////////////////////////
-CBBase::CBBase(CBGame *GameOwner) {
- Game = GameOwner;
+CBBase::CBBase(CBGame *gameOwner) {
+ _gameRef = gameOwner;
_persistable = true;
}
//////////////////////////////////////////////////////////////////////////
CBBase::CBBase() {
- Game = NULL;
+ _gameRef = NULL;
_persistable = true;
}
@@ -92,17 +92,17 @@ ERRORCODE CBBase::parseEditorProperty(byte *buffer, bool complete) {
TOKEN_TABLE_END
- if (!Game->_editorMode)
+ if (!_gameRef->_editorMode)
return STATUS_OK;
byte *params;
int cmd;
- CBParser parser(Game);
+ CBParser parser(_gameRef);
if (complete) {
if (parser.getCommand((char **)&buffer, commands, (char **)&params) != TOKEN_EDITOR_PROPERTY) {
- Game->LOG(0, "'EDITOR_PROPERTY' keyword expected.");
+ _gameRef->LOG(0, "'EDITOR_PROPERTY' keyword expected.");
return STATUS_FAILED;
}
buffer = params;
@@ -134,7 +134,7 @@ ERRORCODE CBBase::parseEditorProperty(byte *buffer, bool complete) {
delete[] propValue;
propName = NULL;
propValue = NULL;
- Game->LOG(0, "Syntax error in EDITOR_PROPERTY definition");
+ _gameRef->LOG(0, "Syntax error in EDITOR_PROPERTY definition");
return STATUS_FAILED;
}
if (cmd == PARSERR_GENERIC || propName == NULL || propValue == NULL) {
@@ -142,7 +142,7 @@ ERRORCODE CBBase::parseEditorProperty(byte *buffer, bool complete) {
delete[] propValue;
propName = NULL;
propValue = NULL;
- Game->LOG(0, "Error loading EDITOR_PROPERTY definition");
+ _gameRef->LOG(0, "Error loading EDITOR_PROPERTY definition");
return STATUS_FAILED;
}
diff --git a/engines/wintermute/Base/BBase.h b/engines/wintermute/Base/BBase.h
index d505ec0b1d..afbe277529 100644
--- a/engines/wintermute/Base/BBase.h
+++ b/engines/wintermute/Base/BBase.h
@@ -49,7 +49,7 @@ public:
ERRORCODE parseEditorProperty(byte *buffer, bool complete = true);
virtual ERRORCODE saveAsText(CBDynBuffer *buffer, int indent = 0);
CBBase();
- CBGame *Game;
+ CBGame *_gameRef;
CBBase(CBGame *GameOwner);
virtual ~CBBase();
diff --git a/engines/wintermute/Base/BDynBuffer.cpp b/engines/wintermute/Base/BDynBuffer.cpp
index 291712c6c8..ff13f96d6c 100644
--- a/engines/wintermute/Base/BDynBuffer.cpp
+++ b/engines/wintermute/Base/BDynBuffer.cpp
@@ -76,7 +76,7 @@ ERRORCODE CBDynBuffer::init(uint32 initSize) {
_buffer = (byte *)malloc(initSize);
if (!_buffer) {
- Game->LOG(0, "CBDynBuffer::Init - Error allocating %d bytes", initSize);
+ _gameRef->LOG(0, "CBDynBuffer::Init - Error allocating %d bytes", initSize);
return STATUS_FAILED;
}
@@ -95,7 +95,7 @@ ERRORCODE CBDynBuffer::putBytes(byte *buffer, uint32 size) {
_realSize += _growBy;
_buffer = (byte *)realloc(_buffer, _realSize);
if (!_buffer) {
- Game->LOG(0, "CBDynBuffer::PutBytes - Error reallocating buffer to %d bytes", _realSize);
+ _gameRef->LOG(0, "CBDynBuffer::PutBytes - Error reallocating buffer to %d bytes", _realSize);
return STATUS_FAILED;
}
}
@@ -113,7 +113,7 @@ ERRORCODE CBDynBuffer::getBytes(byte *buffer, uint32 size) {
if (!_initialized) init();
if (_offset + size > _size) {
- Game->LOG(0, "CBDynBuffer::GetBytes - Buffer underflow");
+ _gameRef->LOG(0, "CBDynBuffer::GetBytes - Buffer underflow");
return STATUS_FAILED;
}
diff --git a/engines/wintermute/Base/BFader.cpp b/engines/wintermute/Base/BFader.cpp
index 9538e4b398..d8bfbf412d 100644
--- a/engines/wintermute/Base/BFader.cpp
+++ b/engines/wintermute/Base/BFader.cpp
@@ -68,7 +68,7 @@ ERRORCODE CBFader::update() {
uint32 time;
if (_system) time = CBPlatform::getTime() - _startTime;
- else time = Game->_timer - _startTime;
+ else time = _gameRef->_timer - _startTime;
if (time >= _duration) _currentAlpha = _targetAlpha;
else {
@@ -87,7 +87,7 @@ ERRORCODE CBFader::update() {
ERRORCODE CBFader::display() {
if (!_active) return STATUS_OK;
- if (_currentAlpha > 0x00) return Game->_renderer->fadeToColor(BYTETORGBA(_red, _green, _blue, _currentAlpha));
+ if (_currentAlpha > 0x00) return _gameRef->_renderer->fadeToColor(BYTETORGBA(_red, _green, _blue, _currentAlpha));
else return STATUS_OK;
}
@@ -116,7 +116,7 @@ ERRORCODE CBFader::fadeIn(uint32 sourceColor, uint32 duration, bool system) {
_system = system;
if (_system) _startTime = CBPlatform::getTime();
- else _startTime = Game->_timer;
+ else _startTime = _gameRef->_timer;
return STATUS_OK;
}
@@ -139,7 +139,7 @@ ERRORCODE CBFader::fadeOut(uint32 targetColor, uint32 duration, bool system) {
_system = system;
if (_system) _startTime = CBPlatform::getTime();
- else _startTime = Game->_timer;
+ else _startTime = _gameRef->_timer;
return STATUS_OK;
diff --git a/engines/wintermute/Base/BFileManager.cpp b/engines/wintermute/Base/BFileManager.cpp
index 1e477e9038..e652ff8301 100644
--- a/engines/wintermute/Base/BFileManager.cpp
+++ b/engines/wintermute/Base/BFileManager.cpp
@@ -119,13 +119,13 @@ byte *CBFileManager::readWholeFile(const Common::String &filename, uint32 *size,
Common::SeekableReadStream *file = openFile(filename);
if (!file) {
- if (mustExist) Game->LOG(0, "Error opening file '%s'", filename.c_str());
+ if (mustExist) _gameRef->LOG(0, "Error opening file '%s'", filename.c_str());
return NULL;
}
/*
if (File->GetSize() > MAX_FILE_SIZE) {
- Game->LOG(0, "File '%s' exceeds the maximum size limit (%d bytes)", Filename, MAX_FILE_SIZE);
+ _gameRef->LOG(0, "File '%s' exceeds the maximum size limit (%d bytes)", Filename, MAX_FILE_SIZE);
CloseFile(File);
return NULL;
}
@@ -134,13 +134,13 @@ byte *CBFileManager::readWholeFile(const Common::String &filename, uint32 *size,
buffer = new byte[file->size() + 1];
if (buffer == NULL) {
- Game->LOG(0, "Error allocating buffer for file '%s' (%d bytes)", filename.c_str(), file->size() + 1);
+ _gameRef->LOG(0, "Error allocating buffer for file '%s' (%d bytes)", filename.c_str(), file->size() + 1);
closeFile(file);
return NULL;
}
if (file->read(buffer, (uint32)file->size()) != (uint32)file->size()) {
- Game->LOG(0, "Error reading file '%s'", filename.c_str());
+ _gameRef->LOG(0, "Error reading file '%s'", filename.c_str());
closeFile(file);
delete [] buffer;
return NULL;
@@ -177,7 +177,7 @@ ERRORCODE CBFileManager::saveFile(const Common::String &filename, byte *buffer,
FILE *f = fopen(filename, "wb");
if (!f) {
- Game->LOG(0, "Error opening file '%s' for writing.", filename);
+ _gameRef->LOG(0, "Error opening file '%s' for writing.", filename);
return STATUS_FAILED;
}
@@ -189,7 +189,7 @@ ERRORCODE CBFileManager::saveFile(const Common::String &filename, byte *buffer,
uint32 CompSize = BufferSize + (BufferSize / 100) + 12; // 1% extra space
byte *CompBuffer = new byte[CompSize];
if (!CompBuffer) {
- Game->LOG(0, "Error allocating compression buffer while saving '%s'", filename);
+ _gameRef->LOG(0, "Error allocating compression buffer while saving '%s'", filename);
Compressed = false;
} else {
if (compress(CompBuffer, (uLongf *)&CompSize, Buffer, BufferSize) == Z_OK) {
@@ -206,7 +206,7 @@ ERRORCODE CBFileManager::saveFile(const Common::String &filename, byte *buffer,
fwrite(CompBuffer, CompSize, 1, f);
} else {
- Game->LOG(0, "Error compressing data while saving '%s'", filename);
+ _gameRef->LOG(0, "Error compressing data while saving '%s'", filename);
Compressed = false;
}
@@ -283,7 +283,7 @@ ERRORCODE CBFileManager::initPaths() {
int numPaths;
// single files paths
- pathList = Game->_registry->readString("Resource", "CustomPaths", "");
+ pathList = _gameRef->_registry->readString("Resource", "CustomPaths", "");
numPaths = CBUtils::strNumEntries(pathList.c_str(), ';');
for (int i = 0; i < numPaths; i++) {
@@ -300,7 +300,7 @@ ERRORCODE CBFileManager::initPaths() {
// package files paths
addPath(PATH_PACKAGE, "./");
- pathList = Game->_registry->readString("Resource", "PackagePaths", "");
+ pathList = _gameRef->_registry->readString("Resource", "PackagePaths", "");
numPaths = CBUtils::strNumEntries(pathList.c_str(), ';');
for (int i = 0; i < numPaths; i++) {
@@ -321,7 +321,7 @@ ERRORCODE CBFileManager::initPaths() {
ERRORCODE CBFileManager::registerPackages() {
restoreCurrentDir();
- Game->LOG(0, "Scanning packages...");
+ _gameRef->LOG(0, "Scanning packages...");
warning("Scanning packages");
Common::ArchiveMemberList files;
@@ -336,7 +336,7 @@ ERRORCODE CBFileManager::registerPackages() {
for (int i = 0; i < _packagePaths.getSize(); i++) {
boost::filesystem::path absPath = boost::filesystem::syste_complete(_packagePaths[i]);
- //Game->LOG(0, "Scanning: %s", absPath.string().c_str());
+ //_gameRef->LOG(0, "Scanning: %s", absPath.string().c_str());
//printf("Scanning: %s\n", absPath.string().c_str());
if (!exists(absPath)) continue;
@@ -359,7 +359,7 @@ ERRORCODE CBFileManager::registerPackages() {
}
#endif
warning(" Registered %d files in %d package(s)", _files.size(), _packages.getSize());
- Game->LOG(0, " Registered %d files in %d package(s)", _files.size(), _packages.getSize());
+ _gameRef->LOG(0, " Registered %d files in %d package(s)", _files.size(), _packages.getSize());
warning(" Registered %d files in %d package(s)", _files.size(), _packages.getSize());
return STATUS_OK;
@@ -371,7 +371,7 @@ ERRORCODE CBFileManager::registerPackage(const Common::String &filename , bool s
Common::File *package = new Common::File();
package->open(filename);
if (!package->isOpen()) {
- Game->LOG(0, " Error opening package file '%s'. Ignoring.", filename.c_str());
+ _gameRef->LOG(0, " Error opening package file '%s'. Ignoring.", filename.c_str());
return STATUS_OK;
}
@@ -394,13 +394,13 @@ ERRORCODE CBFileManager::registerPackage(const Common::String &filename , bool s
hdr.readFromStream(package);
// package->read(&hdr, sizeof(TPackageHeader), 1, f);
if (hdr.Magic1 != PACKAGE_MAGIC_1 || hdr.Magic2 != PACKAGE_MAGIC_2 || hdr.PackageVersion > PACKAGE_VERSION) {
- Game->LOG(0, " Invalid header in package file '%s'. Ignoring.", filename.c_str());
+ _gameRef->LOG(0, " Invalid header in package file '%s'. Ignoring.", filename.c_str());
delete package;
return STATUS_OK;
}
if (hdr.PackageVersion != PACKAGE_VERSION) {
- Game->LOG(0, " Warning: package file '%s' is outdated.", filename.c_str());
+ _gameRef->LOG(0, " Warning: package file '%s' is outdated.", filename.c_str());
}
// new in v2
@@ -412,7 +412,7 @@ ERRORCODE CBFileManager::registerPackage(const Common::String &filename , bool s
}
for (uint32 i = 0; i < hdr.NumDirs; i++) {
- CBPackage *pkg = new CBPackage(Game);
+ CBPackage *pkg = new CBPackage(_gameRef);
if (!pkg) return STATUS_FAILED;
pkg->_boundToExe = boundToExe;
@@ -465,7 +465,7 @@ ERRORCODE CBFileManager::registerPackage(const Common::String &filename , bool s
}
_filesIter = _files.find(name);
if (_filesIter == _files.end()) {
- CBFileEntry *file = new CBFileEntry(Game);
+ CBFileEntry *file = new CBFileEntry(_gameRef);
file->_package = pkg;
file->_offset = offset;
file->_length = length;
@@ -498,7 +498,7 @@ bool CBFileManager::isValidPackage(const AnsiString &fileName) const {
// check for device-type specific packages
if (StringUtil::startsWith(plainName, "xdevice_", true)) {
- return StringUtil::compareNoCase(plainName, "xdevice_" + Game->getDeviceType());
+ return StringUtil::compareNoCase(plainName, "xdevice_" + _gameRef->getDeviceType());
}
return true;
}
@@ -614,13 +614,13 @@ bool CBFileManager::hasFile(const Common::String &filename) {
//////////////////////////////////////////////////////////////////////////
Common::SeekableReadStream *CBFileManager::openFile(const Common::String &filename, bool absPathWarning, bool keepTrackOf) {
if (strcmp(filename.c_str(), "") == 0) return NULL;
- //Game->LOG(0, "open file: %s", filename);
+ //_gameRef->LOG(0, "open file: %s", filename);
/*#ifdef __WIN32__
- if (Game->_dEBUG_DebugMode && Game->_dEBUG_AbsolutePathWarning && AbsPathWarning) {
+ if (_gameRef->_dEBUG_DebugMode && _gameRef->_dEBUG_AbsolutePathWarning && AbsPathWarning) {
char Drive[_MAX_DRIVE];
_splitpath(filename, Drive, NULL, NULL, NULL);
if (Drive[0] != '\0') {
- Game->LOG(0, "WARNING: Referencing absolute path '%s'. The game will NOT work on another computer.", filename);
+ _gameRef->LOG(0, "WARNING: Referencing absolute path '%s'. The game will NOT work on another computer.", filename);
}
}
#endif*/
@@ -651,7 +651,7 @@ Common::SeekableReadStream *CBFileManager::openFileRaw(const Common::String &fil
Common::SeekableReadStream *ret = NULL;
if (scumm_strnicmp(filename.c_str(), "savegame:", 9) == 0) {
- CBSaveThumbFile *SaveThumbFile = new CBSaveThumbFile(Game);
+ CBSaveThumbFile *SaveThumbFile = new CBSaveThumbFile(_gameRef);
if (DID_SUCCEED(SaveThumbFile->open(filename))) {
ret = SaveThumbFile->getMemStream();
}
diff --git a/engines/wintermute/Base/BFrame.cpp b/engines/wintermute/Base/BFrame.cpp
index b57d2e41f3..e77235efa7 100644
--- a/engines/wintermute/Base/BFrame.cpp
+++ b/engines/wintermute/Base/BFrame.cpp
@@ -92,7 +92,7 @@ ERRORCODE CBFrame::oneTimeDisplay(CBObject *owner, bool muted) {
if (owner) owner->updateOneSound(_sound);
_sound->play();
/*
- if (Game->_state == GAME_FROZEN) {
+ if (_gameRef->_state == GAME_FROZEN) {
_sound->Pause(true);
}
*/
@@ -158,7 +158,7 @@ ERRORCODE CBFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) {
char *params;
int cmd;
- CBParser parser(Game);
+ CBParser parser(_gameRef);
Rect32 rect;
int r = 255, g = 255, b = 255;
int ar = 255, ag = 255, ab = 255, alpha = 255;
@@ -237,7 +237,7 @@ ERRORCODE CBFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) {
break;
case TOKEN_SUBFRAME: {
- CBSubFrame *subframe = new CBSubFrame(Game);
+ CBSubFrame *subframe = new CBSubFrame(_gameRef);
if (!subframe || DID_FAIL(subframe->loadBuffer((byte *)params, lifeTime, keepLoaded))) {
delete subframe;
cmd = PARSERR_GENERIC;
@@ -250,9 +250,9 @@ ERRORCODE CBFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) {
delete _sound;
_sound = NULL;
}
- _sound = new CBSound(Game);
+ _sound = new CBSound(_gameRef);
if (!_sound || DID_FAIL(_sound->setSound(params, Audio::Mixer::kSFXSoundType, false))) {
- if (Game->_soundMgr->_soundAvailable) Game->LOG(0, "Error loading sound '%s'.", params);
+ if (_gameRef->_soundMgr->_soundAvailable) _gameRef->LOG(0, "Error loading sound '%s'.", params);
delete _sound;
_sound = NULL;
}
@@ -280,24 +280,24 @@ ERRORCODE CBFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) {
}
}
if (cmd == PARSERR_TOKENNOTFOUND) {
- Game->LOG(0, "Syntax error in FRAME definition");
+ _gameRef->LOG(0, "Syntax error in FRAME definition");
return STATUS_FAILED;
}
if (cmd == PARSERR_GENERIC) {
- Game->LOG(0, "Error loading FRAME definition");
+ _gameRef->LOG(0, "Error loading FRAME definition");
return STATUS_FAILED;
}
- CBSubFrame *sub = new CBSubFrame(Game);
+ CBSubFrame *sub = new CBSubFrame(_gameRef);
if (surface_file != NULL) {
if (custoTrans) sub->setSurface(surface_file, false, r, g, b, lifeTime, keepLoaded);
else sub->setSurface(surface_file, true, 0, 0, 0, lifeTime, keepLoaded);
if (!sub->_surface) {
delete sub;
- Game->LOG(0, "Error loading SUBFRAME");
+ _gameRef->LOG(0, "Error loading SUBFRAME");
return STATUS_FAILED;
}
@@ -422,7 +422,7 @@ ERRORCODE CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
_sound = NULL;
if (!val->isNULL()) {
- _sound = new CBSound(Game);
+ _sound = new CBSound(_gameRef);
if (!_sound || DID_FAIL(_sound->setSound(val->getString(), Audio::Mixer::kSFXSoundType, false))) {
stack->pushBool(false);
delete _sound;
@@ -480,7 +480,7 @@ ERRORCODE CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
const char *filename = NULL;
if (!val->isNULL()) filename = val->getString();
- CBSubFrame *sub = new CBSubFrame(Game);
+ CBSubFrame *sub = new CBSubFrame(_gameRef);
if (filename != NULL) {
sub->setSurface(filename);
sub->setDefaultRect();
@@ -503,7 +503,7 @@ ERRORCODE CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
const char *filename = NULL;
if (!val->isNULL()) filename = val->getString();
- CBSubFrame *sub = new CBSubFrame(Game);
+ CBSubFrame *sub = new CBSubFrame(_gameRef);
if (filename != NULL) {
sub->setSurface(filename);
}
@@ -572,7 +572,7 @@ ERRORCODE CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
//////////////////////////////////////////////////////////////////////////
CScValue *CBFrame::scGetProperty(const char *name) {
- if (!_scValue) _scValue = new CScValue(Game);
+ if (!_scValue) _scValue = new CScValue(_gameRef);
_scValue->setNULL();
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp
index c262c6de91..4abfdf4507 100644
--- a/engines/wintermute/Base/BGame.cpp
+++ b/engines/wintermute/Base/BGame.cpp
@@ -624,7 +624,7 @@ ERRORCODE CBGame::initLoop() {
_framesRendered = 0;
_fpsTime = 0;
}
- //Game->LOG(0, "%d", _fps);
+ //_gameRef->LOG(0, "%d", _fps);
getMousePos(&_mousePos);
@@ -671,9 +671,9 @@ void CBGame::getOffset(int *offsetX, int *offsetY) {
//////////////////////////////////////////////////////////////////////////
ERRORCODE CBGame::loadFile(const char *filename) {
- byte *buffer = Game->_fileManager->readWholeFile(filename);
+ byte *buffer = _gameRef->_fileManager->readWholeFile(filename);
if (buffer == NULL) {
- Game->LOG(0, "CBGame::LoadFile failed for file '%s'", filename);
+ _gameRef->LOG(0, "CBGame::LoadFile failed for file '%s'", filename);
return STATUS_FAILED;
}
@@ -682,7 +682,7 @@ ERRORCODE CBGame::loadFile(const char *filename) {
_filename = new char [strlen(filename) + 1];
strcpy(_filename, filename);
- if (DID_FAIL(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing GAME file '%s'", filename);
+ if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing GAME file '%s'", filename);
delete [] buffer;
@@ -778,11 +778,11 @@ ERRORCODE CBGame::loadBuffer(byte *buffer, bool complete) {
byte *params;
int cmd;
- CBParser parser(Game);
+ CBParser parser(_gameRef);
if (complete) {
if (parser.getCommand((char **)&buffer, commands, (char **)&params) != TOKEN_GAME) {
- Game->LOG(0, "'GAME' keyword expected.");
+ _gameRef->LOG(0, "'GAME' keyword expected.");
return STATUS_FAILED;
}
buffer = params;
@@ -806,20 +806,20 @@ ERRORCODE CBGame::loadBuffer(byte *buffer, bool complete) {
if (_systemFont) _fontStorage->removeFont(_systemFont);
_systemFont = NULL;
- _systemFont = Game->_fontStorage->addFont((char *)params);
+ _systemFont = _gameRef->_fontStorage->addFont((char *)params);
break;
case TOKEN_VIDEO_FONT:
if (_videoFont) _fontStorage->removeFont(_videoFont);
_videoFont = NULL;
- _videoFont = Game->_fontStorage->addFont((char *)params);
+ _videoFont = _gameRef->_fontStorage->addFont((char *)params);
break;
case TOKEN_CURSOR:
delete _cursor;
- _cursor = new CBSprite(Game);
+ _cursor = new CBSprite(_gameRef);
if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) {
delete _cursor;
_cursor = NULL;
@@ -830,7 +830,7 @@ ERRORCODE CBGame::loadBuffer(byte *buffer, bool complete) {
case TOKEN_ACTIVE_CURSOR:
delete _activeCursor;
_activeCursor = NULL;
- _activeCursor = new CBSprite(Game);
+ _activeCursor = new CBSprite(_gameRef);
if (!_activeCursor || DID_FAIL(_activeCursor->loadFile((char *)params))) {
delete _activeCursor;
_activeCursor = NULL;
@@ -840,7 +840,7 @@ ERRORCODE CBGame::loadBuffer(byte *buffer, bool complete) {
case TOKEN_NONINTERACTIVE_CURSOR:
delete _cursorNoninteractive;
- _cursorNoninteractive = new CBSprite(Game);
+ _cursorNoninteractive = new CBSprite(_gameRef);
if (!_cursorNoninteractive || DID_FAIL(_cursorNoninteractive->loadFile((char *)params))) {
delete _cursorNoninteractive;
_cursorNoninteractive = NULL;
@@ -941,15 +941,15 @@ ERRORCODE CBGame::loadBuffer(byte *buffer, bool complete) {
}
}
- if (!_systemFont) _systemFont = Game->_fontStorage->addFont("system_font.fnt");
+ if (!_systemFont) _systemFont = _gameRef->_fontStorage->addFont("system_font.fnt");
if (cmd == PARSERR_TOKENNOTFOUND) {
- Game->LOG(0, "Syntax error in GAME definition");
+ _gameRef->LOG(0, "Syntax error in GAME definition");
return STATUS_FAILED;
}
if (cmd == PARSERR_GENERIC) {
- Game->LOG(0, "Error loading GAME definition");
+ _gameRef->LOG(0, "Error loading GAME definition");
return STATUS_FAILED;
}
@@ -994,7 +994,7 @@ ERRORCODE CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// RunScript
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "RunScript") == 0) {
- Game->LOG(0, "**Warning** The 'RunScript' method is now obsolete. Use 'AttachScript' instead (same syntax)");
+ _gameRef->LOG(0, "**Warning** The 'RunScript' method is now obsolete. Use 'AttachScript' instead (same syntax)");
stack->correctParams(1);
if (DID_FAIL(addScript(stack->pop()->getString())))
stack->pushBool(false);
@@ -1067,7 +1067,7 @@ ERRORCODE CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "LoadWindow") == 0) {
stack->correctParams(1);
- CUIWindow *win = new CUIWindow(Game);
+ CUIWindow *win = new CUIWindow(_gameRef);
if (win && DID_SUCCEED(win->loadFile(stack->pop()->getString()))) {
_windows.add(win);
registerObject(win);
@@ -1311,7 +1311,7 @@ ERRORCODE CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
int length = 0;
const char *filename = stack->pop()->getString();
- CBSound *sound = new CBSound(Game);
+ CBSound *sound = new CBSound(_gameRef);
if (sound && DID_SUCCEED(sound->setSound(filename, Audio::Mixer::kMusicSoundType, true))) {
length = sound->getLength();
delete sound;
@@ -1372,7 +1372,7 @@ ERRORCODE CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// TODO: ADDVIDEO
*/
- Game->LOG(0, "Warning: Game.PlayVideo() is now deprecated. Use Game.PlayTheora() instead.");
+ _gameRef->LOG(0, "Warning: Game.PlayVideo() is now deprecated. Use Game.PlayTheora() instead.");
stack->correctParams(6);
const char *filename = stack->pop()->getString();
@@ -1392,8 +1392,8 @@ ERRORCODE CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
if (Type < (int)VID_PLAY_POS || Type > (int)VID_PLAY_CENTER)
Type = (int)VID_PLAY_STRETCH;
- if (DID_SUCCEED(Game->_videoPlayer->initialize(filename, SubtitleFile))) {
- if (DID_SUCCEED(Game->_videoPlayer->play((TVideoPlayback)Type, xVal, yVal, FreezeMusic))) {
+ if (DID_SUCCEED(_gameRef->_videoPlayer->initialize(filename, SubtitleFile))) {
+ if (DID_SUCCEED(_gameRef->_videoPlayer->play((TVideoPlayback)Type, xVal, yVal, FreezeMusic))) {
stack->pushBool(true);
script->sleep(0);
} else stack->pushBool(false);
@@ -1575,7 +1575,7 @@ ERRORCODE CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "SetGlobalSFXVolume") == 0) {
stack->correctParams(1);
- Game->_soundMgr->setVolumePercent(Audio::Mixer::kSFXSoundType, (byte)stack->pop()->getInt());
+ _gameRef->_soundMgr->setVolumePercent(Audio::Mixer::kSFXSoundType, (byte)stack->pop()->getInt());
stack->pushNULL();
return STATUS_OK;
}
@@ -1585,7 +1585,7 @@ ERRORCODE CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "SetGlobalSpeechVolume") == 0) {
stack->correctParams(1);
- Game->_soundMgr->setVolumePercent(Audio::Mixer::kSpeechSoundType, (byte)stack->pop()->getInt());
+ _gameRef->_soundMgr->setVolumePercent(Audio::Mixer::kSpeechSoundType, (byte)stack->pop()->getInt());
stack->pushNULL();
return STATUS_OK;
}
@@ -1595,7 +1595,7 @@ ERRORCODE CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "SetGlobalMusicVolume") == 0) {
stack->correctParams(1);
- Game->_soundMgr->setVolumePercent(Audio::Mixer::kMusicSoundType, (byte)stack->pop()->getInt());
+ _gameRef->_soundMgr->setVolumePercent(Audio::Mixer::kMusicSoundType, (byte)stack->pop()->getInt());
stack->pushNULL();
return STATUS_OK;
}
@@ -1605,7 +1605,7 @@ ERRORCODE CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "SetGlobalMasterVolume") == 0) {
stack->correctParams(1);
- Game->_soundMgr->setMasterVolumePercent((byte)stack->pop()->getInt());
+ _gameRef->_soundMgr->setMasterVolumePercent((byte)stack->pop()->getInt());
stack->pushNULL();
return STATUS_OK;
}
@@ -1789,7 +1789,7 @@ ERRORCODE CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
}
bool ret = false;
- CBImage *image = Game->_renderer->takeScreenshot();
+ CBImage *image = _gameRef->_renderer->takeScreenshot();
if (image) {
ret = DID_SUCCEED(image->saveBMPFile(filename));
delete image;
@@ -1809,7 +1809,7 @@ ERRORCODE CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
int sizeY = stack->pop()->getInt(_renderer->_height);
bool ret = false;
- CBImage *image = Game->_renderer->takeScreenshot();
+ CBImage *image = _gameRef->_renderer->takeScreenshot();
if (image) {
ret = DID_SUCCEED(image->resize(sizeX, sizeY));
if (ret) ret = DID_SUCCEED(image->saveBMPFile(filename));
@@ -1827,7 +1827,7 @@ ERRORCODE CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
stack->correctParams(1);
CScValue *val = stack->pop();
- CUIWindow *win = new CUIWindow(Game);
+ CUIWindow *win = new CUIWindow(_gameRef);
_windows.add(win);
registerObject(win);
if (!val->isNULL()) win->setName(val->getString());
@@ -1982,8 +1982,8 @@ ERRORCODE CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
_loadingIcon = NULL;
} else {
displayContent(false, true);
- Game->_renderer->flip();
- Game->_renderer->initLoop();
+ _gameRef->_renderer->flip();
+ _gameRef->_renderer->initLoop();
}
stack->pushNULL();
@@ -2273,7 +2273,7 @@ CScValue *CBGame::scGetProperty(const char *name) {
// SFXVolume
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "SFXVolume") == 0) {
- Game->LOG(0, "**Warning** The SFXVolume attribute is obsolete");
+ _gameRef->LOG(0, "**Warning** The SFXVolume attribute is obsolete");
_scValue->setInt(_soundMgr->getVolumePercent(Audio::Mixer::kSFXSoundType));
return _scValue;
}
@@ -2282,7 +2282,7 @@ CScValue *CBGame::scGetProperty(const char *name) {
// SpeechVolume
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "SpeechVolume") == 0) {
- Game->LOG(0, "**Warning** The SpeechVolume attribute is obsolete");
+ _gameRef->LOG(0, "**Warning** The SpeechVolume attribute is obsolete");
_scValue->setInt(_soundMgr->getVolumePercent(Audio::Mixer::kSpeechSoundType));
return _scValue;
}
@@ -2291,7 +2291,7 @@ CScValue *CBGame::scGetProperty(const char *name) {
// MusicVolume
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "MusicVolume") == 0) {
- Game->LOG(0, "**Warning** The MusicVolume attribute is obsolete");
+ _gameRef->LOG(0, "**Warning** The MusicVolume attribute is obsolete");
_scValue->setInt(_soundMgr->getVolumePercent(Audio::Mixer::kMusicSoundType));
return _scValue;
}
@@ -2300,7 +2300,7 @@ CScValue *CBGame::scGetProperty(const char *name) {
// MasterVolume
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "MasterVolume") == 0) {
- Game->LOG(0, "**Warning** The MasterVolume attribute is obsolete");
+ _gameRef->LOG(0, "**Warning** The MasterVolume attribute is obsolete");
_scValue->setInt(_soundMgr->getMasterVolumePercent());
return _scValue;
}
@@ -2597,8 +2597,8 @@ ERRORCODE CBGame::scSetProperty(const char *name, CScValue *value) {
// SFXVolume
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "SFXVolume") == 0) {
- Game->LOG(0, "**Warning** The SFXVolume attribute is obsolete");
- Game->_soundMgr->setVolumePercent(Audio::Mixer::kSFXSoundType, (byte)value->getInt());
+ _gameRef->LOG(0, "**Warning** The SFXVolume attribute is obsolete");
+ _gameRef->_soundMgr->setVolumePercent(Audio::Mixer::kSFXSoundType, (byte)value->getInt());
return STATUS_OK;
}
@@ -2606,8 +2606,8 @@ ERRORCODE CBGame::scSetProperty(const char *name, CScValue *value) {
// SpeechVolume
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "SpeechVolume") == 0) {
- Game->LOG(0, "**Warning** The SpeechVolume attribute is obsolete");
- Game->_soundMgr->setVolumePercent(Audio::Mixer::kSpeechSoundType, (byte)value->getInt());
+ _gameRef->LOG(0, "**Warning** The SpeechVolume attribute is obsolete");
+ _gameRef->_soundMgr->setVolumePercent(Audio::Mixer::kSpeechSoundType, (byte)value->getInt());
return STATUS_OK;
}
@@ -2615,8 +2615,8 @@ ERRORCODE CBGame::scSetProperty(const char *name, CScValue *value) {
// MusicVolume
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "MusicVolume") == 0) {
- Game->LOG(0, "**Warning** The MusicVolume attribute is obsolete");
- Game->_soundMgr->setVolumePercent(Audio::Mixer::kMusicSoundType, (byte)value->getInt());
+ _gameRef->LOG(0, "**Warning** The MusicVolume attribute is obsolete");
+ _gameRef->_soundMgr->setVolumePercent(Audio::Mixer::kMusicSoundType, (byte)value->getInt());
return STATUS_OK;
}
@@ -2624,8 +2624,8 @@ ERRORCODE CBGame::scSetProperty(const char *name, CScValue *value) {
// MasterVolume
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "MasterVolume") == 0) {
- Game->LOG(0, "**Warning** The MasterVolume attribute is obsolete");
- Game->_soundMgr->setMasterVolumePercent((byte)value->getInt());
+ _gameRef->LOG(0, "**Warning** The MasterVolume attribute is obsolete");
+ _gameRef->_soundMgr->setMasterVolumePercent((byte)value->getInt());
return STATUS_OK;
}
@@ -2772,7 +2772,7 @@ void CBGame::quickMessage(const char *text) {
delete _quickMessages[0];
_quickMessages.removeAt(0);
}
- _quickMessages.add(new CBQuickMsg(Game, text));
+ _quickMessages.add(new CBQuickMsg(_gameRef, text));
}
@@ -2867,7 +2867,7 @@ ERRORCODE CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thi
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "LOG") == 0) {
stack->correctParams(1);
- Game->LOG(0, "sc: %s", stack->pop()->getString());
+ _gameRef->LOG(0, "sc: %s", stack->pop()->getString());
stack->pushNULL();
}
@@ -2877,7 +2877,7 @@ ERRORCODE CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thi
else if (strcmp(name, "String") == 0) {
thisObj = thisStack->getTop();
- thisObj->setNative(makeSXString(Game, stack));
+ thisObj->setNative(makeSXString(_gameRef, stack));
stack->pushNULL();
}
@@ -2887,7 +2887,7 @@ ERRORCODE CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thi
else if (strcmp(name, "MemBuffer") == 0) {
thisObj = thisStack->getTop();
- thisObj->setNative(makeSXMemBuffer(Game, stack));
+ thisObj->setNative(makeSXMemBuffer(_gameRef, stack));
stack->pushNULL();
}
@@ -2897,7 +2897,7 @@ ERRORCODE CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thi
else if (strcmp(name, "File") == 0) {
thisObj = thisStack->getTop();
- thisObj->setNative(makeSXFile(Game, stack));
+ thisObj->setNative(makeSXFile(_gameRef, stack));
stack->pushNULL();
}
@@ -2907,7 +2907,7 @@ ERRORCODE CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thi
else if (strcmp(name, "Date") == 0) {
thisObj = thisStack->getTop();
- thisObj->setNative(makeSXDate(Game, stack));
+ thisObj->setNative(makeSXDate(_gameRef, stack));
stack->pushNULL();
}
@@ -2917,7 +2917,7 @@ ERRORCODE CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thi
else if (strcmp(name, "Array") == 0) {
thisObj = thisStack->getTop();
- thisObj->setNative(makeSXArray(Game, stack));
+ thisObj->setNative(makeSXArray(_gameRef, stack));
stack->pushNULL();
}
@@ -2927,7 +2927,7 @@ ERRORCODE CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thi
else if (strcmp(name, "Object") == 0) {
thisObj = thisStack->getTop();
- thisObj->setNative(makeSXObject(Game, stack));
+ thisObj->setNative(makeSXObject(_gameRef, stack));
stack->pushNULL();
}
@@ -3084,8 +3084,8 @@ ERRORCODE CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thi
else if (strcmp(name, "Debug") == 0) {
stack->correctParams(0);
- if (Game->getDebugMgr()->_enabled) {
- Game->getDebugMgr()->onScriptHitBreakpoint(script);
+ if (_gameRef->getDebugMgr()->_enabled) {
+ _gameRef->getDebugMgr()->onScriptHitBreakpoint(script);
script->sleep(0);
}
stack->pushNULL();
@@ -3146,7 +3146,7 @@ ERRORCODE CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thi
ERRORCODE CBGame::showCursor() {
if (_cursorHidden) return STATUS_OK;
- if (!_interactive && Game->_state == GAME_RUNNING) {
+ if (!_interactive && _gameRef->_state == GAME_RUNNING) {
if (_cursorNoninteractive) return drawCursor(_cursorNoninteractive);
} else {
if (_activeObject && !DID_FAIL(_activeObject->showCursor())) return STATUS_OK;
@@ -3166,13 +3166,13 @@ ERRORCODE CBGame::SaveGame(int slot, const char *desc, bool quickSave) {
LOG(0, "Saving game '%s'...", filename);
- Game->applyEvent("BeforeSave", true);
+ _gameRef->applyEvent("BeforeSave", true);
ERRORCODE ret;
_indicatorDisplay = true;
_indicatorProgress = 0;
- CBPersistMgr *pm = new CBPersistMgr(Game);
+ CBPersistMgr *pm = new CBPersistMgr(_gameRef);
if (DID_FAIL(ret = pm->initSave(desc))) goto save_finish;
if (!quickSave) {
@@ -3188,8 +3188,8 @@ ERRORCODE CBGame::SaveGame(int slot, const char *desc, bool quickSave) {
}
}
- if (DID_FAIL(ret = CSysClassRegistry::getInstance()->saveTable(Game, pm, quickSave))) goto save_finish;
- if (DID_FAIL(ret = CSysClassRegistry::getInstance()->saveInstances(Game, pm, quickSave))) goto save_finish;
+ if (DID_FAIL(ret = CSysClassRegistry::getInstance()->saveTable(_gameRef, pm, quickSave))) goto save_finish;
+ if (DID_FAIL(ret = CSysClassRegistry::getInstance()->saveInstances(_gameRef, pm, quickSave))) goto save_finish;
if (DID_FAIL(ret = pm->saveFile(filename))) goto save_finish;
_registry->writeInt("System", "MostRecentSaveSlot", slot);
@@ -3207,7 +3207,7 @@ save_finish: // TODO: Remove gotos
//////////////////////////////////////////////////////////////////////////
ERRORCODE CBGame::loadGame(int slot) {
- //Game->LOG(0, "Load start %d", CBUtils::GetUsedMemMB());
+ //_gameRef->LOG(0, "Load start %d", CBUtils::GetUsedMemMB());
_loading = false;
_scheduledLoadSlot = -1;
@@ -3241,18 +3241,18 @@ ERRORCODE CBGame::loadGame(const char *filename) {
_loadInProgress = true;
_indicatorDisplay = true;
_indicatorProgress = 0;
- CBPersistMgr *pm = new CBPersistMgr(Game);
+ CBPersistMgr *pm = new CBPersistMgr(_gameRef);
_dEBUG_AbsolutePathWarning = false;
if (DID_FAIL(ret = pm->initLoad(filename))) goto load_finish;
//if(DID_FAIL(ret = cleanup())) goto load_finish;
- if (DID_FAIL(ret = CSysClassRegistry::getInstance()->loadTable(Game, pm))) goto load_finish;
- if (DID_FAIL(ret = CSysClassRegistry::getInstance()->loadInstances(Game, pm))) goto load_finish;
+ if (DID_FAIL(ret = CSysClassRegistry::getInstance()->loadTable(_gameRef, pm))) goto load_finish;
+ if (DID_FAIL(ret = CSysClassRegistry::getInstance()->loadInstances(_gameRef, pm))) goto load_finish;
// data initialization after load
initAfterLoad();
- Game->applyEvent("AfterLoad", true);
+ _gameRef->applyEvent("AfterLoad", true);
displayContent(true, false);
//_renderer->flip();
@@ -3269,7 +3269,7 @@ load_finish:
delete _saveLoadImage;
_saveLoadImage = NULL;
- //Game->LOG(0, "Load end %d", CBUtils::GetUsedMemMB());
+ //_gameRef->LOG(0, "Load end %d", CBUtils::GetUsedMemMB());
return ret;
}
@@ -3347,14 +3347,14 @@ ERRORCODE CBGame::displayWindows(bool inGame) {
//////////////////////////////////////////////////////////////////////////
ERRORCODE CBGame::playMusic(int channel, const char *filename, bool looping, uint32 loopStart) {
if (channel >= NUM_MUSIC_CHANNELS) {
- Game->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS);
+ _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS);
return STATUS_FAILED;
}
delete _music[channel];
_music[channel] = NULL;
- _music[channel] = new CBSound(Game);
+ _music[channel] = new CBSound(_gameRef);
if (_music[channel] && DID_SUCCEED(_music[channel]->setSound(filename, Audio::Mixer::kMusicSoundType, true))) {
if (_musicStartTime[channel]) {
_music[channel]->setPositionTime(_musicStartTime[channel]);
@@ -3373,7 +3373,7 @@ ERRORCODE CBGame::playMusic(int channel, const char *filename, bool looping, uin
//////////////////////////////////////////////////////////////////////////
ERRORCODE CBGame::stopMusic(int channel) {
if (channel >= NUM_MUSIC_CHANNELS) {
- Game->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS);
+ _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS);
return STATUS_FAILED;
}
@@ -3389,7 +3389,7 @@ ERRORCODE CBGame::stopMusic(int channel) {
//////////////////////////////////////////////////////////////////////////
ERRORCODE CBGame::pauseMusic(int channel) {
if (channel >= NUM_MUSIC_CHANNELS) {
- Game->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS);
+ _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS);
return STATUS_FAILED;
}
@@ -3401,7 +3401,7 @@ ERRORCODE CBGame::pauseMusic(int channel) {
//////////////////////////////////////////////////////////////////////////
ERRORCODE CBGame::resumeMusic(int channel) {
if (channel >= NUM_MUSIC_CHANNELS) {
- Game->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS);
+ _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS);
return STATUS_FAILED;
}
@@ -3413,7 +3413,7 @@ ERRORCODE CBGame::resumeMusic(int channel) {
//////////////////////////////////////////////////////////////////////////
ERRORCODE CBGame::setMusicStartTime(int channel, uint32 time) {
if (channel >= NUM_MUSIC_CHANNELS) {
- Game->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS);
+ _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS);
return STATUS_FAILED;
}
@@ -3445,9 +3445,9 @@ ERRORCODE CBGame::loadSettings(const char *filename) {
TOKEN_TABLE_END
- byte *origBuffer = Game->_fileManager->readWholeFile(filename);
+ byte *origBuffer = _gameRef->_fileManager->readWholeFile(filename);
if (origBuffer == NULL) {
- Game->LOG(0, "CBGame::LoadSettings failed for file '%s'", filename);
+ _gameRef->LOG(0, "CBGame::LoadSettings failed for file '%s'", filename);
return STATUS_FAILED;
}
@@ -3456,10 +3456,10 @@ ERRORCODE CBGame::loadSettings(const char *filename) {
byte *buffer = origBuffer;
byte *params;
int cmd;
- CBParser parser(Game);
+ CBParser parser(_gameRef);
if (parser.getCommand((char **)&buffer, commands, (char **)&params) != TOKEN_SETTINGS) {
- Game->LOG(0, "'SETTINGS' keyword expected in game settings file.");
+ _gameRef->LOG(0, "'SETTINGS' keyword expected in game settings file.");
return STATUS_FAILED;
}
buffer = params;
@@ -3528,11 +3528,11 @@ ERRORCODE CBGame::loadSettings(const char *filename) {
}
}
if (cmd == PARSERR_TOKENNOTFOUND) {
- Game->LOG(0, "Syntax error in game settings '%s'", filename);
+ _gameRef->LOG(0, "Syntax error in game settings '%s'", filename);
ret = STATUS_FAILED;
}
if (cmd == PARSERR_GENERIC) {
- Game->LOG(0, "Error loading game settings '%s'", filename);
+ _gameRef->LOG(0, "Error loading game settings '%s'", filename);
ret = STATUS_FAILED;
}
@@ -3649,10 +3649,10 @@ ERRORCODE CBGame::focusWindow(CUIWindow *Window) {
_windows.removeAt(i);
_windows.add(Window);
- Game->_focusedWindow = Window;
+ _gameRef->_focusedWindow = Window;
}
- if (Window->_mode == WINDOW_NORMAL && Prev != Window && Game->validObject(Prev) && (Prev->_mode == WINDOW_EXCLUSIVE || Prev->_mode == WINDOW_SYSTEM_EXCLUSIVE))
+ if (Window->_mode == WINDOW_NORMAL && Prev != Window && _gameRef->validObject(Prev) && (Prev->_mode == WINDOW_EXCLUSIVE || Prev->_mode == WINDOW_SYSTEM_EXCLUSIVE))
return focusWindow(Prev);
else return STATUS_OK;
}
@@ -3718,10 +3718,10 @@ bool CBGame::handleKeypress(Common::Event *event, bool printable) {
// TODO
if (_focusedWindow) {
- if (!Game->_focusedWindow->handleKeypress(event, _keyboardState->_currentPrintable)) {
+ if (!_gameRef->_focusedWindow->handleKeypress(event, _keyboardState->_currentPrintable)) {
/*if (event->type != SDL_TEXTINPUT) {*/
- if (Game->_focusedWindow->canHandleEvent("Keypress"))
- Game->_focusedWindow->applyEvent("Keypress");
+ if (_gameRef->_focusedWindow->canHandleEvent("Keypress"))
+ _gameRef->_focusedWindow->applyEvent("Keypress");
else
applyEvent("Keypress");
/*}*/
@@ -3744,14 +3744,14 @@ void CBGame::handleKeyRelease(Common::Event *event) {
bool CBGame::handleMouseWheel(int Delta) {
bool handled = false;
if (_focusedWindow) {
- handled = Game->_focusedWindow->handleMouseWheel(Delta);
+ handled = _gameRef->_focusedWindow->handleMouseWheel(Delta);
if (!handled) {
- if (Delta < 0 && Game->_focusedWindow->canHandleEvent("MouseWheelDown")) {
- Game->_focusedWindow->applyEvent("MouseWheelDown");
+ if (Delta < 0 && _gameRef->_focusedWindow->canHandleEvent("MouseWheelDown")) {
+ _gameRef->_focusedWindow->applyEvent("MouseWheelDown");
handled = true;
- } else if (Game->_focusedWindow->canHandleEvent("MouseWheelUp")) {
- Game->_focusedWindow->applyEvent("MouseWheelUp");
+ } else if (_gameRef->_focusedWindow->canHandleEvent("MouseWheelUp")) {
+ _gameRef->_focusedWindow->applyEvent("MouseWheelUp");
handled = true;
}
@@ -3833,7 +3833,7 @@ ERRORCODE CBGame::getSaveSlotDescription(int slot, char *buffer) {
char filename[MAX_PATH_LENGTH + 1];
getSaveSlotFilename(slot, filename);
- CBPersistMgr *pm = new CBPersistMgr(Game);
+ CBPersistMgr *pm = new CBPersistMgr(_gameRef);
if (!pm) return STATUS_FAILED;
_dEBUG_AbsolutePathWarning = false;
@@ -3878,7 +3878,7 @@ ERRORCODE CBGame::emptySaveSlot(int slot) {
//////////////////////////////////////////////////////////////////////////
ERRORCODE CBGame::setActiveObject(CBObject *obj) {
// not-active when game is frozen
- if (obj && !Game->_interactive && !obj->_nonIntMouseEvents) {
+ if (obj && !_gameRef->_interactive && !obj->_nonIntMouseEvents) {
obj = NULL;
}
@@ -3910,7 +3910,7 @@ ERRORCODE CBGame::pushViewport(CBViewport *viewport) {
//////////////////////////////////////////////////////////////////////////
ERRORCODE CBGame::popViewport() {
_viewportSP--;
- if (_viewportSP < -1) Game->LOG(0, "Fatal: Viewport stack underflow!");
+ if (_viewportSP < -1) _gameRef->LOG(0, "Fatal: Viewport stack underflow!");
if (_viewportSP >= 0 && _viewportSP < _viewportStack.getSize()) _renderer->setViewport(_viewportStack[_viewportSP]->getRect());
else _renderer->setViewport(_renderer->_drawOffsetX,
@@ -4038,7 +4038,7 @@ ERRORCODE CBGame::updateMusicCrossfade() {
if (!_music[_musicCrossfadeChannel1]->isPlaying()) _music[_musicCrossfadeChannel1]->play();
if (!_music[_musicCrossfadeChannel2]->isPlaying()) _music[_musicCrossfadeChannel2]->play();
- uint32 currentTime = Game->_liveTimer - _musicCrossfadeStartTime;
+ uint32 currentTime = _gameRef->_liveTimer - _musicCrossfadeStartTime;
if (currentTime >= _musicCrossfadeLength) {
_musicCrossfadeRunning = false;
@@ -4067,7 +4067,7 @@ ERRORCODE CBGame::updateMusicCrossfade() {
_music[_musicCrossfadeChannel1]->setVolumePercent((int)(100.0f - (float)currentTime / (float)_musicCrossfadeLength * 100.0f));
_music[_musicCrossfadeChannel2]->setVolumePercent((int)((float)currentTime / (float)_musicCrossfadeLength * 100.0f));
- //Game->QuickMessageForm("%d %d", _music[_musicCrossfadeChannel1]->GetVolume(), _music[_musicCrossfadeChannel2]->GetVolume());
+ //_gameRef->QuickMessageForm("%d %d", _music[_musicCrossfadeChannel1]->GetVolume(), _music[_musicCrossfadeChannel2]->GetVolume());
}
return STATUS_OK;
@@ -4093,7 +4093,7 @@ void CBGame::DEBUG_DumpClassRegistry() {
f->close();
delete f;
- Game->quickMessage("Classes dump completed.");
+ _gameRef->quickMessage("Classes dump completed.");
}
@@ -4119,7 +4119,7 @@ ERRORCODE CBGame::setWaitCursor(const char *filename) {
delete _cursorNoninteractive;
_cursorNoninteractive = NULL;
- _cursorNoninteractive = new CBSprite(Game);
+ _cursorNoninteractive = new CBSprite(_gameRef);
if (!_cursorNoninteractive || DID_FAIL(_cursorNoninteractive->loadFile(filename))) {
delete _cursorNoninteractive;
_cursorNoninteractive = NULL;
@@ -4309,7 +4309,7 @@ ERRORCODE CBGame::onPaint() {
//////////////////////////////////////////////////////////////////////////
ERRORCODE CBGame::onWindowClose() {
if (canHandleEvent("QuitGame")) {
- if (_state != GAME_FROZEN) Game->applyEvent("QuitGame");
+ if (_state != GAME_FROZEN) _gameRef->applyEvent("QuitGame");
return STATUS_OK;
} else return STATUS_FAILED;
}
@@ -4319,12 +4319,12 @@ ERRORCODE CBGame::displayDebugInfo() {
char str[100];
if (_dEBUG_ShowFPS) {
- sprintf(str, "FPS: %d", Game->_fps);
+ sprintf(str, "FPS: %d", _gameRef->_fps);
_systemFont->drawText((byte *)str, 0, 0, 100, TAL_LEFT);
}
- if (Game->_dEBUG_DebugMode) {
- if (!Game->_renderer->_windowed)
+ if (_gameRef->_dEBUG_DebugMode) {
+ if (!_gameRef->_renderer->_windowed)
sprintf(str, "Mode: %dx%dx%d", _renderer->_width, _renderer->_height, _renderer->_bPP);
else
sprintf(str, "Mode: %dx%d windowed", _renderer->_width, _renderer->_height);
@@ -4343,7 +4343,7 @@ ERRORCODE CBGame::displayDebugInfo() {
sprintf(str, "Timer: %d", _timer);
- Game->_systemFont->drawText((byte *)str, 0, 130, _renderer->_width, TAL_RIGHT);
+ _gameRef->_systemFont->drawText((byte *)str, 0, 130, _renderer->_width, TAL_RIGHT);
if (_activeObject != NULL) _systemFont->drawText((byte *)_activeObject->_name, 0, 150, _renderer->_width, TAL_RIGHT);
@@ -4375,9 +4375,9 @@ void CBGame::getMousePos(Point32 *pos) {
if (_renderer->_windowed && ::IsZoomed(_renderer->_window)) {
Common::Rect rc;
::GetClientRect(_renderer->_window, &rc);
- Pos->x *= Game->_renderer->_realWidth;
+ Pos->x *= _gameRef->_renderer->_realWidth;
Pos->x /= (rc.right - rc.left);
- Pos->y *= Game->_renderer->_realHeight;
+ Pos->y *= _gameRef->_renderer->_realHeight;
Pos->y /= (rc.bottom - rc.top);
}
*/
diff --git a/engines/wintermute/Base/BImage.cpp b/engines/wintermute/Base/BImage.cpp
index 337a157536..57a2694aa8 100644
--- a/engines/wintermute/Base/BImage.cpp
+++ b/engines/wintermute/Base/BImage.cpp
@@ -86,13 +86,13 @@ ERRORCODE CBImage::loadFile(const Common::String &filename) {
error("CBImage::loadFile : Unsupported fileformat %s", filename.c_str());
}
_filename = filename;
- Common::SeekableReadStream *file = Game->_fileManager->openFile(filename.c_str());
+ Common::SeekableReadStream *file = _gameRef->_fileManager->openFile(filename.c_str());
if (!file) return STATUS_FAILED;
_decoder->loadStream(*file);
_surface = _decoder->getSurface();
_palette = _decoder->getPalette();
- Game->_fileManager->closeFile(file);
+ _gameRef->_fileManager->closeFile(file);
return STATUS_OK;
}
diff --git a/engines/wintermute/Base/BObject.cpp b/engines/wintermute/Base/BObject.cpp
index 60a9fe7f32..35a2e257d6 100644
--- a/engines/wintermute/Base/BObject.cpp
+++ b/engines/wintermute/Base/BObject.cpp
@@ -63,7 +63,7 @@ CBObject::CBObject(CBGame *inGame): CBScriptHolder(inGame) {
_soundEvent = NULL;
- _iD = Game->getSequence();
+ _iD = _gameRef->getSequence();
CBPlatform::setRectEmpty(&_rect);
_rectSet = false;
@@ -108,8 +108,8 @@ CBObject::~CBObject() {
//////////////////////////////////////////////////////////////////////////
ERRORCODE CBObject::cleanup() {
- if (Game && Game->_activeObject == this)
- Game->_activeObject = NULL;
+ if (_gameRef && _gameRef->_activeObject == this)
+ _gameRef->_activeObject = NULL;
CBScriptHolder::cleanup();
delete[] _soundEvent;
@@ -146,7 +146,7 @@ void CBObject::setCaption(const char *caption, int caseVal) { // TODO: rename Ca
_caption[caseVal - 1] = new char[strlen(caption) + 1];
if (_caption[caseVal - 1]) {
strcpy(_caption[caseVal - 1], caption);
- Game->_stringTable->expand(&_caption[caseVal - 1]);
+ _gameRef->_stringTable->expand(&_caption[caseVal - 1]);
}
}
@@ -857,7 +857,7 @@ const char *CBObject::scToString() {
//////////////////////////////////////////////////////////////////////////
ERRORCODE CBObject::showCursor() {
- if (_cursor) return Game->drawCursor(_cursor);
+ if (_cursor) return _gameRef->drawCursor(_cursor);
else return STATUS_FAILED;
}
@@ -932,7 +932,7 @@ ERRORCODE CBObject::setCursor(const char *filename) {
}
_sharedCursors = false;
- _cursor = new CBSprite(Game);
+ _cursor = new CBSprite(_gameRef);
if (!_cursor || DID_FAIL(_cursor->loadFile(filename))) {
delete _cursor;
_cursor = NULL;
@@ -944,7 +944,7 @@ ERRORCODE CBObject::setCursor(const char *filename) {
//////////////////////////////////////////////////////////////////////////
ERRORCODE CBObject::setActiveCursor(const char *filename) {
delete _activeCursor;
- _activeCursor = new CBSprite(Game);
+ _activeCursor = new CBSprite(_gameRef);
if (!_activeCursor || DID_FAIL(_activeCursor->loadFile(filename))) {
delete _activeCursor;
_activeCursor = NULL;
@@ -981,10 +981,10 @@ bool CBObject::handleMouseWheel(int delta) {
ERRORCODE CBObject::playSFX(const char *filename, bool looping, bool playNow, const char *eventName, uint32 loopStart) {
// just play loaded sound
if (filename == NULL && _sFX) {
- if (Game->_editorMode || _sFXStart) {
+ if (_gameRef->_editorMode || _sFXStart) {
_sFX->setVolumePercent(_sFXVolume);
_sFX->setPositionTime(_sFXStart);
- if (!Game->_editorMode) _sFXStart = 0;
+ if (!_gameRef->_editorMode) _sFXStart = 0;
}
if (playNow) {
setSoundEvent(eventName);
@@ -998,7 +998,7 @@ ERRORCODE CBObject::playSFX(const char *filename, bool looping, bool playNow, co
// create new sound
delete _sFX;
- _sFX = new CBSound(Game);
+ _sFX = new CBSound(_gameRef);
if (_sFX && DID_SUCCEED(_sFX->setSound(filename, Audio::Mixer::kSFXSoundType, true))) {
_sFX->setVolumePercent(_sFXVolume);
if (_sFXStart) {
@@ -1082,7 +1082,7 @@ ERRORCODE CBObject::updateOneSound(CBSound *sound) {
if (sound) {
if (_autoSoundPanning)
- Ret = sound->setPan(Game->_soundMgr->posToPan(_posX - Game->_offsetX, _posY - Game->_offsetY));
+ Ret = sound->setPan(_gameRef->_soundMgr->posToPan(_posX - _gameRef->_offsetX, _posY - _gameRef->_offsetY));
Ret = sound->ApplyFX(_sFXType, _sFXParam1, _sFXParam2, _sFXParam3, _sFXParam4);
}
diff --git a/engines/wintermute/Base/BPackage.cpp b/engines/wintermute/Base/BPackage.cpp
index 1122ebc16d..0727417025 100644
--- a/engines/wintermute/Base/BPackage.cpp
+++ b/engines/wintermute/Base/BPackage.cpp
@@ -87,10 +87,10 @@ ERRORCODE CBPackage::read(Common::SeekableReadStream *file, uint32 offset, byte
//////////////////////////////////////////////////////////////////////////
Common::SeekableReadStream *CBPackage::getFilePointer() {
- Common::File *file = Game->_fileManager->openPackage(_name);
+ Common::File *file = _gameRef->_fileManager->openPackage(_name);
if (!file) {
- Game->_fileManager->requestCD(_cD, _name, "");
- file = Game->_fileManager->openPackage(_name);
+ _gameRef->_fileManager->requestCD(_cD, _name, "");
+ file = _gameRef->_fileManager->openPackage(_name);
}
return file;
}
diff --git a/engines/wintermute/Base/BParser.cpp b/engines/wintermute/Base/BParser.cpp
index 45c0577f92..114c5054ca 100644
--- a/engines/wintermute/Base/BParser.cpp
+++ b/engines/wintermute/Base/BParser.cpp
@@ -115,7 +115,7 @@ int32 CBParser::getObject(char **buf, TokenDesc *tokens, char **name, char **dat
//////////////////////////////////////////////////////////////////////
int32 CBParser::getCommand(char **buf, TokenDesc *tokens, char **params) {
if (!*buf) return PARSERR_TOKENNOTFOUND;
- Game->miniUpdate();
+ _gameRef->miniUpdate();
char *name;
return getObject(buf, tokens, &name, params);
}
diff --git a/engines/wintermute/Base/BPersistMgr.cpp b/engines/wintermute/Base/BPersistMgr.cpp
index 7308a8bbb7..b58534ea90 100644
--- a/engines/wintermute/Base/BPersistMgr.cpp
+++ b/engines/wintermute/Base/BPersistMgr.cpp
@@ -180,11 +180,11 @@ ERRORCODE CBPersistMgr::initSave(const char *desc) {
if (_saveStream) {
// get thumbnails
- if (!Game->_cachedThumbnail) {
- Game->_cachedThumbnail = new CBSaveThumbHelper(Game);
- if (DID_FAIL(Game->_cachedThumbnail->storeThumbnail(true))) {
- delete Game->_cachedThumbnail;
- Game->_cachedThumbnail = NULL;
+ if (!_gameRef->_cachedThumbnail) {
+ _gameRef->_cachedThumbnail = new CBSaveThumbHelper(_gameRef);
+ if (DID_FAIL(_gameRef->_cachedThumbnail->storeThumbnail(true))) {
+ delete _gameRef->_cachedThumbnail;
+ _gameRef->_cachedThumbnail = NULL;
}
}
@@ -195,7 +195,7 @@ ERRORCODE CBPersistMgr::initSave(const char *desc) {
putDWORD(magic);
byte VerMajor, VerMinor, ExtMajor, ExtMinor;
- Game->getVersion(&VerMajor, &VerMinor, &ExtMajor, &ExtMinor);
+ _gameRef->getVersion(&VerMajor, &VerMinor, &ExtMajor, &ExtMinor);
//uint32 Version = MAKELONG(MAKEWORD(VerMajor, VerMinor), MAKEWORD(ExtMajor, ExtMinor));
_saveStream->writeByte(VerMajor);
_saveStream->writeByte(VerMinor);
@@ -204,15 +204,15 @@ ERRORCODE CBPersistMgr::initSave(const char *desc) {
// new in ver 2
putDWORD((uint32)DCGF_VER_BUILD);
- putString(Game->_name);
+ putString(_gameRef->_name);
// thumbnail data size
bool thumbnailOK = false;
- if (Game->_cachedThumbnail) {
- if (Game->_cachedThumbnail->_thumbnail) {
+ if (_gameRef->_cachedThumbnail) {
+ if (_gameRef->_cachedThumbnail->_thumbnail) {
Common::MemoryWriteStreamDynamic thumbStream(DisposeAfterUse::YES);
- if (Game->_cachedThumbnail->_thumbnail->writeBMPToStream(&thumbStream)) {
+ if (_gameRef->_cachedThumbnail->_thumbnail->writeBMPToStream(&thumbStream)) {
_saveStream->writeUint32LE(thumbStream.size());
_saveStream->write(thumbStream.getData(), thumbStream.size());
} else {
@@ -225,8 +225,8 @@ ERRORCODE CBPersistMgr::initSave(const char *desc) {
if (!thumbnailOK) putDWORD(0);
// in any case, destroy the cached thumbnail once used
- delete Game->_cachedThumbnail;
- Game->_cachedThumbnail = NULL;
+ delete _gameRef->_cachedThumbnail;
+ _gameRef->_cachedThumbnail = NULL;
uint32 dataOffset = _offset +
sizeof(uint32) + // data offset
@@ -250,7 +250,7 @@ ERRORCODE CBPersistMgr::readHeader(const Common::String &filename) {
_saving = false;
_loadStream = g_system->getSavefileManager()->openForLoading(filename);
- //_buffer = Game->_fileManager->readWholeFile(filename, &_bufferSize);
+ //_buffer = _gameRef->_fileManager->readWholeFile(filename, &_bufferSize);
if (_loadStream) {
uint32 magic;
magic = getDWORD();
@@ -306,8 +306,8 @@ ERRORCODE CBPersistMgr::initLoad(const char *filename) {
}
_saving = false;
- if (_savedName == "" || scumm_stricmp(_savedName.c_str(), Game->_name) != 0) {
- Game->LOG(0, "ERROR: Saved game name doesn't match current game");
+ if (_savedName == "" || scumm_stricmp(_savedName.c_str(), _gameRef->_name) != 0) {
+ _gameRef->LOG(0, "ERROR: Saved game name doesn't match current game");
cleanup();
return STATUS_FAILED;
}
@@ -317,8 +317,8 @@ ERRORCODE CBPersistMgr::initLoad(const char *filename) {
(_savedVerMajor == DCGF_VER_MAJOR && _savedVerMinor > DCGF_VER_MINOR) ||
(_savedVerMajor == DCGF_VER_MAJOR && _savedVerMinor == DCGF_VER_MINOR && _savedVerBuild > DCGF_VER_BUILD)
) {
- Game->LOG(0, "ERROR: Saved game version is newer than current game");
- Game->LOG(0, "ERROR: Expected %d.%d.%d got %d.%d.%d", DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, _savedVerMajor, _savedVerMinor, _savedVerBuild);
+ _gameRef->LOG(0, "ERROR: Saved game version is newer than current game");
+ _gameRef->LOG(0, "ERROR: Expected %d.%d.%d got %d.%d.%d", DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, _savedVerMajor, _savedVerMinor, _savedVerBuild);
cleanup();
return STATUS_FAILED;
}
@@ -328,8 +328,8 @@ ERRORCODE CBPersistMgr::initLoad(const char *filename) {
(_savedVerMajor == SAVEGAME_VER_MAJOR && _savedVerMinor < SAVEGAME_VER_MINOR) ||
(_savedVerMajor == SAVEGAME_VER_MAJOR && _savedVerMinor == SAVEGAME_VER_MINOR && _savedVerBuild < SAVEGAME_VER_BUILD)
) {
- Game->LOG(0, "ERROR: Saved game is too old and cannot be used by this version of game engine");
- Game->LOG(0, "ERROR: Expected %d.%d.%d got %d.%d.%d", DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, _savedVerMajor, _savedVerMinor, _savedVerBuild);
+ _gameRef->LOG(0, "ERROR: Saved game is too old and cannot be used by this version of game engine");
+ _gameRef->LOG(0, "ERROR: Expected %d.%d.%d got %d.%d.%d", DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, _savedVerMajor, _savedVerMinor, _savedVerBuild);
cleanup();
return STATUS_FAILED;
@@ -338,7 +338,7 @@ ERRORCODE CBPersistMgr::initLoad(const char *filename) {
/*
if ( _savedVerMajor != DCGF_VER_MAJOR || _savedVerMinor != DCGF_VER_MINOR)
{
- Game->LOG(0, "ERROR: Saved game is created by other WME version");
+ _gameRef->LOG(0, "ERROR: Saved game is created by other WME version");
goto init_fail;
}
*/
@@ -349,7 +349,7 @@ ERRORCODE CBPersistMgr::initLoad(const char *filename) {
//////////////////////////////////////////////////////////////////////////
ERRORCODE CBPersistMgr::saveFile(const char *filename) {
- return Game->_fileManager->saveFile(filename, ((Common::MemoryWriteStreamDynamic *)_saveStream)->getData(), ((Common::MemoryWriteStreamDynamic *)_saveStream)->size(), Game->_compressedSavegames, _richBuffer, _richBufferSize);
+ return _gameRef->_fileManager->saveFile(filename, ((Common::MemoryWriteStreamDynamic *)_saveStream)->getData(), ((Common::MemoryWriteStreamDynamic *)_saveStream)->size(), _gameRef->_compressedSavegames, _richBuffer, _richBufferSize);
}
@@ -738,7 +738,7 @@ ERRORCODE CBPersistMgr::transfer(const char *name, void *val) {
if (_saving) {
CSysClassRegistry::getInstance()->getPointerID(*(void **)val, &classID, &instanceID);
if (*(void **)val != NULL && (classID == -1 || instanceID == -1)) {
- Game->LOG(0, "Warning: invalid instance '%s'", name);
+ _gameRef->LOG(0, "Warning: invalid instance '%s'", name);
}
_saveStream->writeUint32LE(classID);
diff --git a/engines/wintermute/Base/BQuickMsg.cpp b/engines/wintermute/Base/BQuickMsg.cpp
index cee37a0222..dd87a10dad 100644
--- a/engines/wintermute/Base/BQuickMsg.cpp
+++ b/engines/wintermute/Base/BQuickMsg.cpp
@@ -36,7 +36,7 @@ namespace WinterMute {
CBQuickMsg::CBQuickMsg(CBGame *inGame, const char *text): CBBase(inGame) {
_text = new char [strlen(text) + 1];
if (_text) strcpy(_text, text);
- _startTime = Game->_currentTime;
+ _startTime = _gameRef->_currentTime;
}
diff --git a/engines/wintermute/Base/BRegion.cpp b/engines/wintermute/Base/BRegion.cpp
index 65ba2c8825..1db15abae0 100644
--- a/engines/wintermute/Base/BRegion.cpp
+++ b/engines/wintermute/Base/BRegion.cpp
@@ -96,9 +96,9 @@ bool CBRegion::pointInRegion(int x, int y) {
//////////////////////////////////////////////////////////////////////////
ERRORCODE CBRegion::loadFile(const char *filename) {
- byte *buffer = Game->_fileManager->readWholeFile(filename);
+ byte *buffer = _gameRef->_fileManager->readWholeFile(filename);
if (buffer == NULL) {
- Game->LOG(0, "CBRegion::LoadFile failed for file '%s'", filename);
+ _gameRef->LOG(0, "CBRegion::LoadFile failed for file '%s'", filename);
return STATUS_FAILED;
}
@@ -107,7 +107,7 @@ ERRORCODE CBRegion::loadFile(const char *filename) {
_filename = new char [strlen(filename) + 1];
strcpy(_filename, filename);
- if (DID_FAIL(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing REGION file '%s'", filename);
+ if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing REGION file '%s'", filename);
delete [] buffer;
@@ -143,11 +143,11 @@ ERRORCODE CBRegion::loadBuffer(byte *buffer, bool complete) {
byte *params;
int cmd;
- CBParser parser(Game);
+ CBParser parser(_gameRef);
if (complete) {
if (parser.getCommand((char **)&buffer, commands, (char **)&params) != TOKEN_REGION) {
- Game->LOG(0, "'REGION' keyword expected.");
+ _gameRef->LOG(0, "'REGION' keyword expected.");
return STATUS_FAILED;
}
buffer = params;
@@ -197,7 +197,7 @@ ERRORCODE CBRegion::loadBuffer(byte *buffer, bool complete) {
}
}
if (cmd == PARSERR_TOKENNOTFOUND) {
- Game->LOG(0, "Syntax error in REGION definition");
+ _gameRef->LOG(0, "Syntax error in REGION definition");
return STATUS_FAILED;
}
diff --git a/engines/wintermute/Base/BRegistry.cpp b/engines/wintermute/Base/BRegistry.cpp
index b8520b07fd..c7ec0c2675 100644
--- a/engines/wintermute/Base/BRegistry.cpp
+++ b/engines/wintermute/Base/BRegistry.cpp
@@ -167,12 +167,12 @@ char *CBRegistry::getIniName() {
//////////////////////////////////////////////////////////////////////////
void CBRegistry::loadValues(bool local) {
if (local) loadXml("settings.xml", _localValues);
- else loadXml(PathUtil::combine(Game->getDataDir(), "settings.xml"), _values);
+ else loadXml(PathUtil::combine(_gameRef->getDataDir(), "settings.xml"), _values);
}
//////////////////////////////////////////////////////////////////////////
void CBRegistry::saveValues() {
- saveXml(PathUtil::combine(Game->getDataDir(), "settings.xml"), _values);
+ saveXml(PathUtil::combine(_gameRef->getDataDir(), "settings.xml"), _values);
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/wintermute/Base/BRenderSDL.cpp b/engines/wintermute/Base/BRenderSDL.cpp
index 5d7c16849c..4174bab71b 100644
--- a/engines/wintermute/Base/BRenderSDL.cpp
+++ b/engines/wintermute/Base/BRenderSDL.cpp
@@ -154,8 +154,8 @@ ERRORCODE CBRenderSDL::initRenderer(int width, int height, bool windowed) {
}
}
#else*/
- _realWidth = Game->_registry->readInt("Debug", "ForceResWidth", _width);
- _realHeight = Game->_registry->readInt("Debug", "ForceResHeight", _height);
+ _realWidth = _gameRef->_registry->readInt("Debug", "ForceResWidth", _width);
+ _realHeight = _gameRef->_registry->readInt("Debug", "ForceResHeight", _height);
//#endif
/*
@@ -194,7 +194,7 @@ ERRORCODE CBRenderSDL::initRenderer(int width, int height, bool windowed) {
//flags |= SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS;
#endif
- //_windowed = Game->_registry->readBool("Video", "Windowed", true);
+ //_windowed = _gameRef->_registry->readBool("Video", "Windowed", true);
// if (!windowed) flags |= SDL_WINDOW_FULLSCREEN;
Graphics::PixelFormat format(4, 8, 8, 8, 8, 24, 16, 8, 0);
@@ -311,7 +311,7 @@ ERRORCODE CBRenderSDL::fadeToColor(uint32 Color, Common::Rect *rect) {
fillRect.setHeight(rect->height());
} else {
Rect32 rc;
- Game->getCurrentViewportRect(&rc);
+ _gameRef->getCurrentViewportRect(&rc);
fillRect.left = (int16)rc.left;
fillRect.top = (int16)rc.top;
fillRect.setWidth((int16)(rc.right - rc.left));
@@ -553,7 +553,7 @@ ERRORCODE CBRenderSDL::drawLine(int x1, int y1, int x2, int y2, uint32 color) {
CBImage *CBRenderSDL::takeScreenshot() {
// TODO: Fix this
warning("CBRenderSDL::TakeScreenshot() - not ported yet");
- CBImage *screenshot = new CBImage(Game);
+ CBImage *screenshot = new CBImage(_gameRef);
screenshot->copyFrom(_renderSurface);
return screenshot;
#if 0
@@ -576,7 +576,7 @@ CBImage *CBRenderSDL::takeScreenshot() {
memcpy(bits, src, bytespp * viewport.w);
}
- return new CBImage(Game, dib);
+ return new CBImage(_gameRef, dib);
#endif
return NULL;
}
@@ -588,7 +588,7 @@ ERRORCODE CBRenderSDL::switchFullscreen() {
_windowed = !_windowed;
*/
- Game->_registry->writeBool("Video", "Windowed", _windowed);
+ _gameRef->_registry->writeBool("Video", "Windowed", _windowed);
return STATUS_OK;
}
@@ -666,7 +666,7 @@ void CBRenderSDL::dumpData(const char *filename) {
FILE *f = fopen(filename, "wt");
if (!f) return;
- CBSurfaceStorage *Mgr = Game->_surfaceStorage;
+ CBSurfaceStorage *Mgr = _gameRef->_surfaceStorage;
int TotalKB = 0;
int TotalLoss = 0;
@@ -689,13 +689,13 @@ void CBRenderSDL::dumpData(const char *filename) {
fclose(f);
- Game->LOG(0, "Texture Stats Dump completed.");
- Game->QuickMessage("Texture Stats Dump completed.");
+ _gameRef->LOG(0, "Texture Stats Dump completed.");
+ _gameRef->QuickMessage("Texture Stats Dump completed.");
#endif
}
CBSurface *CBRenderSDL::createSurface() {
- return new CBSurfaceSDL(Game);
+ return new CBSurfaceSDL(_gameRef);
}
} // end of namespace WinterMute
diff --git a/engines/wintermute/Base/BSaveThumbHelper.cpp b/engines/wintermute/Base/BSaveThumbHelper.cpp
index f53ffda52c..6c7b572475 100644
--- a/engines/wintermute/Base/BSaveThumbHelper.cpp
+++ b/engines/wintermute/Base/BSaveThumbHelper.cpp
@@ -49,24 +49,24 @@ ERRORCODE CBSaveThumbHelper::storeThumbnail(bool doFlip) {
delete _thumbnail;
_thumbnail = NULL;
- if (Game->_thumbnailWidth > 0 && Game->_thumbnailHeight > 0) {
+ if (_gameRef->_thumbnailWidth > 0 && _gameRef->_thumbnailHeight > 0) {
if (doFlip) {
// when using opengl on windows it seems to be necessary to do this twice
// works normally for direct3d
- Game->displayContent(false);
- Game->_renderer->flip();
+ _gameRef->displayContent(false);
+ _gameRef->_renderer->flip();
- Game->displayContent(false);
- Game->_renderer->flip();
+ _gameRef->displayContent(false);
+ _gameRef->_renderer->flip();
}
- CBImage *screenshot = Game->_renderer->takeScreenshot();
+ CBImage *screenshot = _gameRef->_renderer->takeScreenshot();
if (!screenshot) return STATUS_FAILED;
// normal thumbnail
- if (Game->_thumbnailWidth > 0 && Game->_thumbnailHeight > 0) {
- _thumbnail = new CBImage(Game);
- _thumbnail->copyFrom(screenshot, Game->_thumbnailWidth, Game->_thumbnailHeight);
+ if (_gameRef->_thumbnailWidth > 0 && _gameRef->_thumbnailHeight > 0) {
+ _thumbnail = new CBImage(_gameRef);
+ _thumbnail->copyFrom(screenshot, _gameRef->_thumbnailWidth, _gameRef->_thumbnailHeight);
}
diff --git a/engines/wintermute/Base/BScriptHolder.cpp b/engines/wintermute/Base/BScriptHolder.cpp
index 40e7d5d392..8e2a8f6adb 100644
--- a/engines/wintermute/Base/BScriptHolder.cpp
+++ b/engines/wintermute/Base/BScriptHolder.cpp
@@ -94,7 +94,7 @@ ERRORCODE CBScriptHolder::applyEvent(const char *eventName, bool unbreakable) {
}
}
}
- if (numHandlers > 0 && unbreakable) Game->_scEngine->tickUnbreakable();
+ if (numHandlers > 0 && unbreakable) _gameRef->_scEngine->tickUnbreakable();
return ret;
}
@@ -280,24 +280,24 @@ ERRORCODE CBScriptHolder::addScript(const char *filename) {
for (int i = 0; i < _scripts.getSize(); i++) {
if (scumm_stricmp(_scripts[i]->_filename, filename) == 0) {
if (_scripts[i]->_state != SCRIPT_FINISHED) {
- Game->LOG(0, "CBScriptHolder::AddScript - trying to add script '%s' mutiple times (obj: '%s')", filename, _name);
+ _gameRef->LOG(0, "CBScriptHolder::AddScript - trying to add script '%s' mutiple times (obj: '%s')", filename, _name);
return STATUS_OK;
}
}
}
- CScScript *scr = Game->_scEngine->runScript(filename, this);
+ CScScript *scr = _gameRef->_scEngine->runScript(filename, this);
if (!scr) {
- if (Game->_editorForceScripts) {
+ if (_gameRef->_editorForceScripts) {
// editor hack
- scr = new CScScript(Game, Game->_scEngine);
+ scr = new CScScript(_gameRef, _gameRef->_scEngine);
scr->_filename = new char[strlen(filename) + 1];
strcpy(scr->_filename, filename);
scr->_state = SCRIPT_ERROR;
scr->_owner = this;
_scripts.add(scr);
- Game->_scEngine->_scripts.add(scr);
- Game->getDebugMgr()->onScriptInit(scr);
+ _gameRef->_scEngine->_scripts.add(scr);
+ _gameRef->getDebugMgr()->onScriptInit(scr);
return STATUS_OK;
}
@@ -354,11 +354,11 @@ ERRORCODE CBScriptHolder::parseProperty(byte *buffer, bool complete) {
byte *params;
int cmd;
- CBParser parser(Game);
+ CBParser parser(_gameRef);
if (complete) {
if (parser.getCommand((char **)&buffer, commands, (char **)&params) != TOKEN_PROPERTY) {
- Game->LOG(0, "'PROPERTY' keyword expected.");
+ _gameRef->LOG(0, "'PROPERTY' keyword expected.");
return STATUS_FAILED;
}
buffer = params;
@@ -390,7 +390,7 @@ ERRORCODE CBScriptHolder::parseProperty(byte *buffer, bool complete) {
delete[] propValue;
propName = NULL;
propValue = NULL;
- Game->LOG(0, "Syntax error in PROPERTY definition");
+ _gameRef->LOG(0, "Syntax error in PROPERTY definition");
return STATUS_FAILED;
}
if (cmd == PARSERR_GENERIC || propName == NULL || propValue == NULL) {
@@ -398,12 +398,12 @@ ERRORCODE CBScriptHolder::parseProperty(byte *buffer, bool complete) {
delete[] propValue;
propName = NULL;
propValue = NULL;
- Game->LOG(0, "Error loading PROPERTY definition");
+ _gameRef->LOG(0, "Error loading PROPERTY definition");
return STATUS_FAILED;
}
- CScValue *val = new CScValue(Game);
+ CScValue *val = new CScValue(_gameRef);
val->setString(propValue);
scSetProperty(propName, val);
@@ -431,12 +431,12 @@ CScScript *CBScriptHolder::invokeMethodThread(const char *methodName) {
for (int i = _scripts.getSize() - 1; i >= 0; i--) {
if (_scripts[i]->canHandleMethod(methodName)) {
- CScScript *thread = new CScScript(Game, _scripts[i]->_engine);
+ CScScript *thread = new CScScript(_gameRef, _scripts[i]->_engine);
if (thread) {
ERRORCODE ret = thread->createMethodThread(_scripts[i], methodName);
if (DID_SUCCEED(ret)) {
_scripts[i]->_engine->_scripts.add(thread);
- Game->getDebugMgr()->onScriptMethodThreadInit(thread, _scripts[i], methodName);
+ _gameRef->getDebugMgr()->onScriptMethodThreadInit(thread, _scripts[i], methodName);
return thread;
} else {
diff --git a/engines/wintermute/Base/BScriptable.cpp b/engines/wintermute/Base/BScriptable.cpp
index 8e93a8914e..b61398c9b2 100644
--- a/engines/wintermute/Base/BScriptable.cpp
+++ b/engines/wintermute/Base/BScriptable.cpp
@@ -40,7 +40,7 @@ CBScriptable::CBScriptable(CBGame *inGame, bool noValue, bool persistable): CBNa
_refCount = 0;
if (noValue) _scValue = NULL;
- else _scValue = new CScValue(Game);
+ else _scValue = new CScValue(_gameRef);
_persistable = persistable;
@@ -50,7 +50,7 @@ CBScriptable::CBScriptable(CBGame *inGame, bool noValue, bool persistable): CBNa
//////////////////////////////////////////////////////////////////////////
CBScriptable::~CBScriptable() {
- //if(_refCount>0) Game->LOG(0, "Warning: Destroying object, _refCount=%d", _refCount);
+ //if(_refCount>0) _gameRef->LOG(0, "Warning: Destroying object, _refCount=%d", _refCount);
delete _scValue;
delete _scProp;
_scValue = NULL;
@@ -75,7 +75,7 @@ ERRORCODE CBScriptable::scCallMethod(CScScript *script, CScStack *stack, CScStac
//////////////////////////////////////////////////////////////////////////
CScValue *CBScriptable::scGetProperty(const char *name) {
- if (!_scProp) _scProp = new CScValue(Game);
+ if (!_scProp) _scProp = new CScValue(_gameRef);
if (_scProp) return _scProp->getProp(name);
else return NULL;
}
@@ -83,7 +83,7 @@ CScValue *CBScriptable::scGetProperty(const char *name) {
//////////////////////////////////////////////////////////////////////////
ERRORCODE CBScriptable::scSetProperty(const char *name, CScValue *value) {
- if (!_scProp) _scProp = new CScValue(Game);
+ if (!_scProp) _scProp = new CScValue(_gameRef);
if (_scProp) return _scProp->setProp(name, value);
else return STATUS_FAILED;
}
@@ -140,7 +140,7 @@ void CBScriptable::scSetBool(bool val) {
//////////////////////////////////////////////////////////////////////////
ERRORCODE CBScriptable::persist(CBPersistMgr *persistMgr) {
- persistMgr->transfer(TMEMBER(Game));
+ persistMgr->transfer(TMEMBER(_gameRef));
persistMgr->transfer(TMEMBER(_refCount));
persistMgr->transfer(TMEMBER(_scProp));
persistMgr->transfer(TMEMBER(_scValue));
diff --git a/engines/wintermute/Base/BSound.cpp b/engines/wintermute/Base/BSound.cpp
index c5fdb11ade..9f9fa1a050 100644
--- a/engines/wintermute/Base/BSound.cpp
+++ b/engines/wintermute/Base/BSound.cpp
@@ -57,7 +57,7 @@ CBSound::CBSound(CBGame *inGame): CBBase(inGame) {
//////////////////////////////////////////////////////////////////////////
CBSound::~CBSound() {
- if (_sound) Game->_soundMgr->removeSound(_sound);
+ if (_sound) _gameRef->_soundMgr->removeSound(_sound);
_sound = NULL;
delete[] _soundFilename;
@@ -68,13 +68,13 @@ CBSound::~CBSound() {
//////////////////////////////////////////////////////////////////////////
ERRORCODE CBSound::setSound(const char *filename, Audio::Mixer::SoundType type, bool streamed) {
if (_sound) {
- Game->_soundMgr->removeSound(_sound);
+ _gameRef->_soundMgr->removeSound(_sound);
_sound = NULL;
}
delete[] _soundFilename;
_soundFilename = NULL;
- _sound = Game->_soundMgr->addSound(filename, type, streamed);
+ _sound = _gameRef->_soundMgr->addSound(filename, type, streamed);
if (_sound) {
_soundFilename = new char[strlen(filename) + 1];
strcpy(_soundFilename, filename);
@@ -89,7 +89,7 @@ ERRORCODE CBSound::setSound(const char *filename, Audio::Mixer::SoundType type,
//////////////////////////////////////////////////////////////////////////
ERRORCODE CBSound::setSoundSimple() {
- _sound = Game->_soundMgr->addSound(_soundFilename, _soundType, _soundStreamed);
+ _sound = _gameRef->_soundMgr->addSound(_soundFilename, _soundType, _soundStreamed);
if (_sound) {
if (_soundPosition) _sound->setPosition(_soundPosition);
_sound->setLooping(_soundLooping);
@@ -164,7 +164,7 @@ ERRORCODE CBSound::persist(CBPersistMgr *persistMgr) {
_sFXParam1 = _sFXParam2 = _sFXParam3 = _sFXParam4 = 0;
}
- persistMgr->transfer(TMEMBER(Game));
+ persistMgr->transfer(TMEMBER(_gameRef));
persistMgr->transfer(TMEMBER(_soundFilename));
persistMgr->transfer(TMEMBER(_soundLooping));
diff --git a/engines/wintermute/Base/BSoundBuffer.cpp b/engines/wintermute/Base/BSoundBuffer.cpp
index 2448451784..77ff119e7b 100644
--- a/engines/wintermute/Base/BSoundBuffer.cpp
+++ b/engines/wintermute/Base/BSoundBuffer.cpp
@@ -104,9 +104,9 @@ ERRORCODE CBSoundBuffer::loadFromFile(const char *filename, bool forceReload) {
#endif
// Load a file, but avoid having the File-manager handle the disposal of it.
- _file = Game->_fileManager->openFile(filename, true, false);
+ _file = _gameRef->_fileManager->openFile(filename, true, false);
if (!_file) {
- Game->LOG(0, "Error opening sound file '%s'", filename);
+ _gameRef->LOG(0, "Error opening sound file '%s'", filename);
return STATUS_FAILED;
}
Common::String strFilename(filename);
@@ -144,7 +144,7 @@ ERRORCODE CBSoundBuffer::loadFromFile(const char *filename, bool forceReload) {
_stream = BASS_StreamCreateFileUser(STREAMFILE_NOBUFFER, 0, &fileProc, (void *)_file);
if (!_stream) {
- Game->LOG(0, "BASS error: %d while loading '%s'", BASS_ErrorGetCode(), filename);
+ _gameRef->LOG(0, "BASS error: %d while loading '%s'", BASS_ErrorGetCode(), filename);
return STATUS_FAILED;
}
@@ -155,13 +155,13 @@ ERRORCODE CBSoundBuffer::loadFromFile(const char *filename, bool forceReload) {
bool NewlyCreated = false;
if(!_soundBuffer || ForceReload || _streamed){
- if(!_file) _file = Game->_fileManager->openFile(filename);
+ if(!_file) _file = _gameRef->_fileManager->openFile(filename);
if(!_file){
- Game->LOG(0, "Error opening sound file '%s'", filename);
+ _gameRef->LOG(0, "Error opening sound file '%s'", filename);
return STATUS_FAILED;
}
// switch to streamed for big files
- if(!_streamed && (_file->GetSize() > MAX_NONSTREAMED_FILE_SIZE && !Game->_forceNonStreamedSounds)) SetStreaming(true);
+ if(!_streamed && (_file->GetSize() > MAX_NONSTREAMED_FILE_SIZE && !_gameRef->_forceNonStreamedSounds)) SetStreaming(true);
}
// create buffer
@@ -170,7 +170,7 @@ ERRORCODE CBSoundBuffer::loadFromFile(const char *filename, bool forceReload) {
res = InitializeBuffer(_file);
if(DID_FAIL(res)){
- Game->LOG(res, "Error creating sound buffer for file '%s'", filename);
+ _gameRef->LOG(res, "Error creating sound buffer for file '%s'", filename);
return res;
}
}
@@ -185,7 +185,7 @@ ERRORCODE CBSoundBuffer::loadFromFile(const char *filename, bool forceReload) {
// close file (if not streaming)
if(!_streamed && _file){
- Game->_fileManager->closeFile(_file);
+ _gameRef->_fileManager->closeFile(_file);
_file = NULL;
}
*/
@@ -281,7 +281,7 @@ void CBSoundBuffer::updateVolume() {
//////////////////////////////////////////////////////////////////////////
ERRORCODE CBSoundBuffer::setVolume(int volume) {
- _volume = volume * Game->_soundMgr->getMasterVolume() / 255;
+ _volume = volume * _gameRef->_soundMgr->getMasterVolume() / 255;
if (_stream && _handle) {
byte vol = (byte)(_volume);
g_system->getMixer()->setChannelVolume(*_handle, vol);
diff --git a/engines/wintermute/Base/BSoundMgr.cpp b/engines/wintermute/Base/BSoundMgr.cpp
index 0cc0020e1e..02fd146701 100644
--- a/engines/wintermute/Base/BSoundMgr.cpp
+++ b/engines/wintermute/Base/BSoundMgr.cpp
@@ -74,7 +74,7 @@ ERRORCODE CBSoundMgr::cleanup() {
//////////////////////////////////////////////////////////////////////////
void CBSoundMgr::saveSettings() {
if (_soundAvailable) {
- Game->_registry->writeInt("Audio", "MasterVolume", _volumeMaster);
+ _gameRef->_registry->writeInt("Audio", "MasterVolume", _volumeMaster);
}
}
@@ -85,7 +85,7 @@ ERRORCODE CBSoundMgr::initialize() {
if (!g_system->getMixer()->isReady()) {
return STATUS_FAILED;
}
- _volumeMaster = Game->_registry->readInt("Audio", "MasterVolume", 255);
+ _volumeMaster = _gameRef->_registry->readInt("Audio", "MasterVolume", 255);
_soundAvailable = true;
return STATUS_OK;
@@ -118,12 +118,12 @@ CBSoundBuffer *CBSoundMgr::addSound(const char *filename, Audio::Mixer::SoundTyp
AnsiString name = PathUtil::getFileNameWithoutExtension(filename);
AnsiString newFile = PathUtil::combine(path, name + "ogg");
- if (Game->_fileManager->hasFile(newFile)) {
+ if (_gameRef->_fileManager->hasFile(newFile)) {
filename = newFile.c_str();
}
}
- sound = new CBSoundBuffer(Game);
+ sound = new CBSoundBuffer(_gameRef);
if (!sound) return NULL;
sound->setStreaming(streamed);
@@ -132,7 +132,7 @@ CBSoundBuffer *CBSoundMgr::addSound(const char *filename, Audio::Mixer::SoundTyp
ERRORCODE res = sound->loadFromFile(filename);
if (DID_FAIL(res)) {
- Game->LOG(res, "Error loading sound '%s'", filename);
+ _gameRef->LOG(res, "Error loading sound '%s'", filename);
delete sound;
return NULL;
}
@@ -281,7 +281,7 @@ ERRORCODE CBSoundMgr::resumeAll() {
//////////////////////////////////////////////////////////////////////////
float CBSoundMgr::posToPan(int x, int y) {
- float relPos = (float)x / ((float)Game->_renderer->_width);
+ float relPos = (float)x / ((float)_gameRef->_renderer->_width);
float minPan = -0.7f;
float maxPan = 0.7f;
diff --git a/engines/wintermute/Base/BSprite.cpp b/engines/wintermute/Base/BSprite.cpp
index f33b5764c6..d2dd619517 100644
--- a/engines/wintermute/Base/BSprite.cpp
+++ b/engines/wintermute/Base/BSprite.cpp
@@ -123,13 +123,13 @@ ERRORCODE CBSprite::draw(int x, int y, CBObject *registerOwner, float zoomX, flo
//////////////////////////////////////////////////////////////////////
ERRORCODE CBSprite::loadFile(const char *filename, int lifeTime, TSpriteCacheType cacheType) {
- Common::SeekableReadStream *file = Game->_fileManager->openFile(filename);
+ Common::SeekableReadStream *file = _gameRef->_fileManager->openFile(filename);
if (!file) {
- Game->LOG(0, "CBSprite::LoadFile failed for file '%s'", filename);
- if (Game->_dEBUG_DebugMode) return loadFile("invalid_debug.bmp", lifeTime, cacheType);
+ _gameRef->LOG(0, "CBSprite::LoadFile failed for file '%s'", filename);
+ if (_gameRef->_dEBUG_DebugMode) return loadFile("invalid_debug.bmp", lifeTime, cacheType);
else return loadFile("invalid.bmp", lifeTime, cacheType);
} else {
- Game->_fileManager->closeFile(file);
+ _gameRef->_fileManager->closeFile(file);
file = NULL;
}
@@ -137,11 +137,11 @@ ERRORCODE CBSprite::loadFile(const char *filename, int lifeTime, TSpriteCacheTyp
AnsiString ext = PathUtil::getExtension(filename);
if (StringUtil::startsWith(filename, "savegame:", true) || StringUtil::compareNoCase(ext, "bmp") || StringUtil::compareNoCase(ext, "tga") || StringUtil::compareNoCase(ext, "png") || StringUtil::compareNoCase(ext, "jpg")) {
- CBFrame *frame = new CBFrame(Game);
- CBSubFrame *subframe = new CBSubFrame(Game);
+ CBFrame *frame = new CBFrame(_gameRef);
+ CBSubFrame *subframe = new CBSubFrame(_gameRef);
subframe->setSurface(filename, true, 0, 0, 0, lifeTime, true);
if (subframe->_surface == NULL) {
- Game->LOG(0, "Error loading simple sprite '%s'", filename);
+ _gameRef->LOG(0, "Error loading simple sprite '%s'", filename);
ret = STATUS_FAILED;
delete frame;
delete subframe;
@@ -153,9 +153,9 @@ ERRORCODE CBSprite::loadFile(const char *filename, int lifeTime, TSpriteCacheTyp
ret = STATUS_OK;
}
} else {
- byte *buffer = Game->_fileManager->readWholeFile(filename);
+ byte *buffer = _gameRef->_fileManager->readWholeFile(filename);
if (buffer) {
- if (DID_FAIL(ret = loadBuffer(buffer, true, lifeTime, cacheType))) Game->LOG(0, "Error parsing SPRITE file '%s'", filename);
+ if (DID_FAIL(ret = loadBuffer(buffer, true, lifeTime, cacheType))) _gameRef->LOG(0, "Error parsing SPRITE file '%s'", filename);
delete [] buffer;
}
}
@@ -208,14 +208,14 @@ ERRORCODE CBSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSprit
byte *params;
int cmd;
- CBParser parser(Game);
+ CBParser parser(_gameRef);
cleanup();
if (complete) {
if (parser.getCommand((char **)&buffer, commands, (char **)&params) != TOKEN_SPRITE) {
- Game->LOG(0, "'SPRITE' keyword expected.");
+ _gameRef->LOG(0, "'SPRITE' keyword expected.");
return STATUS_FAILED;
}
buffer = params;
@@ -262,7 +262,7 @@ ERRORCODE CBSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSprit
break;
case TOKEN_EDITOR_BG_FILE:
- if (Game->_editorMode) {
+ if (_gameRef->_editorMode) {
delete[] _editorBgFile;
_editorBgFile = new char[strlen((char *)params) + 1];
if (_editorBgFile) strcpy(_editorBgFile, (char *)params);
@@ -287,11 +287,11 @@ ERRORCODE CBSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSprit
int FrameLifeTime = lifeTime;
if (cacheType == CACHE_HALF && frameCount % 2 != 1) FrameLifeTime = -1;
- frame = new CBFrame(Game);
+ frame = new CBFrame(_gameRef);
if (DID_FAIL(frame->loadBuffer(params, FrameLifeTime, _streamedKeepLoaded))) {
delete frame;
- Game->LOG(0, "Error parsing frame %d", frameCount);
+ _gameRef->LOG(0, "Error parsing frame %d", frameCount);
return STATUS_FAILED;
}
@@ -308,7 +308,7 @@ ERRORCODE CBSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSprit
}
if (cmd == PARSERR_TOKENNOTFOUND) {
- Game->LOG(0, "Syntax error in SPRITE definition");
+ _gameRef->LOG(0, "Syntax error in SPRITE definition");
return STATUS_FAILED;
}
_canBreak = !_continuous;
@@ -332,13 +332,13 @@ void CBSprite::reset() {
//////////////////////////////////////////////////////////////////////
bool CBSprite::GetCurrentFrame(float zoomX, float zoomY) {
- //if(_owner && _owner->_freezable && Game->_state == GAME_FROZEN) return true;
+ //if(_owner && _owner->_freezable && _gameRef->_state == GAME_FROZEN) return true;
if (_currentFrame == -1) return false;
uint32 timer;
- if (_owner && _owner->_freezable) timer = Game->_timer;
- else timer = Game->_liveTimer;
+ if (_owner && _owner->_freezable) timer = _gameRef->_timer;
+ else timer = _gameRef->_liveTimer;
int lastFrame = _currentFrame;
@@ -392,11 +392,11 @@ ERRORCODE CBSprite::display(int X, int Y, CBObject *Register, float ZoomX, float
killAllSounds();
}
applyEvent("FrameChanged");
- _frames[_currentFrame]->oneTimeDisplay(_owner, Game->_editorMode && _editorMuted);
+ _frames[_currentFrame]->oneTimeDisplay(_owner, _gameRef->_editorMode && _editorMuted);
}
// draw frame
- return _frames[_currentFrame]->draw(X - Game->_offsetX, Y - Game->_offsetY, Register, ZoomX, ZoomY, _precise, Alpha, _editorAllFrames, Rotate, BlendMode);
+ return _frames[_currentFrame]->draw(X - _gameRef->_offsetX, Y - _gameRef->_offsetY, Register, ZoomX, ZoomY, _precise, Alpha, _editorAllFrames, Rotate, BlendMode);
}
@@ -566,9 +566,9 @@ ERRORCODE CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *t
const char *filename = NULL;
if (!val->isNULL()) filename = val->getString();
- CBFrame *frame = new CBFrame(Game);
+ CBFrame *frame = new CBFrame(_gameRef);
if (filename != NULL) {
- CBSubFrame *sub = new CBSubFrame(Game);
+ CBSubFrame *sub = new CBSubFrame(_gameRef);
if (DID_SUCCEED(sub->setSurface(filename))) {
sub->setDefaultRect();
frame->_subframes.add(sub);
@@ -594,9 +594,9 @@ ERRORCODE CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *t
if (!val->isNULL())
filename = val->getString();
- CBFrame *frame = new CBFrame(Game);
+ CBFrame *frame = new CBFrame(_gameRef);
if (filename != NULL) {
- CBSubFrame *sub = new CBSubFrame(Game);
+ CBSubFrame *sub = new CBSubFrame(_gameRef);
if (DID_SUCCEED(sub->setSurface(filename))) frame->_subframes.add(sub);
else delete sub;
}
diff --git a/engines/wintermute/Base/BStringTable.cpp b/engines/wintermute/Base/BStringTable.cpp
index 9098994054..e2cbec3691 100644
--- a/engines/wintermute/Base/BStringTable.cpp
+++ b/engines/wintermute/Base/BStringTable.cpp
@@ -54,7 +54,7 @@ ERRORCODE CBStringTable::addString(const char *key, const char *val, bool report
if (key == NULL || val == NULL) return STATUS_FAILED;
if (scumm_stricmp(key, "@right-to-left") == 0) {
- Game->_textRTL = true;
+ _gameRef->_textRTL = true;
return STATUS_OK;
}
@@ -62,7 +62,7 @@ ERRORCODE CBStringTable::addString(const char *key, const char *val, bool report
finalKey.toLowercase();
_stringsIter = _strings.find(finalKey);
- if (_stringsIter != _strings.end() && reportDuplicities) Game->LOG(0, " Warning: Duplicate definition of string '%s'.", finalKey.c_str());
+ if (_stringsIter != _strings.end() && reportDuplicities) _gameRef->LOG(0, " Warning: Duplicate definition of string '%s'.", finalKey.c_str());
_strings[finalKey] = val;
@@ -103,7 +103,7 @@ char *CBStringTable::getKey(const char *str) {
//////////////////////////////////////////////////////////////////////////
void CBStringTable::expand(char **str, bool forceExpand) {
- if (Game->_doNotExpandStrings && !forceExpand) return;
+ if (_gameRef->_doNotExpandStrings && !forceExpand) return;
if (str == NULL || *str == NULL || *str[0] != '/') return;
@@ -138,7 +138,7 @@ void CBStringTable::expand(char **str, bool forceExpand) {
//////////////////////////////////////////////////////////////////////////
const char *CBStringTable::expandStatic(const char *string, bool forceExpand) {
- if (Game->_doNotExpandStrings && !forceExpand) return string;
+ if (_gameRef->_doNotExpandStrings && !forceExpand) return string;
if (string == NULL || string[0] == '\0' || string[0] != '/') return string;
@@ -170,14 +170,14 @@ const char *CBStringTable::expandStatic(const char *string, bool forceExpand) {
//////////////////////////////////////////////////////////////////////////
ERRORCODE CBStringTable::loadFile(const char *filename, bool clearOld) {
- Game->LOG(0, "Loading string table...");
+ _gameRef->LOG(0, "Loading string table...");
if (clearOld) _strings.clear();
uint32 size;
- byte *buffer = Game->_fileManager->readWholeFile(filename, &size);
+ byte *buffer = _gameRef->_fileManager->readWholeFile(filename, &size);
if (buffer == NULL) {
- Game->LOG(0, "CBStringTable::LoadFile failed for file '%s'", filename);
+ _gameRef->LOG(0, "CBStringTable::LoadFile failed for file '%s'", filename);
return STATUS_FAILED;
}
@@ -185,12 +185,12 @@ ERRORCODE CBStringTable::loadFile(const char *filename, bool clearOld) {
if (size > 3 && buffer[0] == 0xEF && buffer[1] == 0xBB && buffer[2] == 0xBF) {
pos += 3;
- if (Game->_textEncoding != TEXT_UTF8) {
- Game->_textEncoding = TEXT_UTF8;
- //Game->_textEncoding = TEXT_ANSI;
- Game->LOG(0, " UTF8 file detected, switching to UTF8 text encoding");
+ if (_gameRef->_textEncoding != TEXT_UTF8) {
+ _gameRef->_textEncoding = TEXT_UTF8;
+ //_gameRef->_textEncoding = TEXT_ANSI;
+ _gameRef->LOG(0, " UTF8 file detected, switching to UTF8 text encoding");
}
- } else Game->_textEncoding = TEXT_ANSI;
+ } else _gameRef->_textEncoding = TEXT_ANSI;
uint32 lineLength = 0;
while (pos < size) {
@@ -221,7 +221,7 @@ ERRORCODE CBStringTable::loadFile(const char *filename, bool clearOld) {
delete [] buffer;
- Game->LOG(0, " %d strings loaded", _strings.size());
+ _gameRef->LOG(0, " %d strings loaded", _strings.size());
return STATUS_OK;
}
diff --git a/engines/wintermute/Base/BSubFrame.cpp b/engines/wintermute/Base/BSubFrame.cpp
index 19c1bcc5f2..62bf0d9f87 100644
--- a/engines/wintermute/Base/BSubFrame.cpp
+++ b/engines/wintermute/Base/BSubFrame.cpp
@@ -68,7 +68,7 @@ CBSubFrame::CBSubFrame(CBGame *inGame): CBScriptable(inGame, true) {
//////////////////////////////////////////////////////////////////////////
CBSubFrame::~CBSubFrame() {
- if (_surface) Game->_surfaceStorage->removeSurface(_surface);
+ if (_surface) _gameRef->_surfaceStorage->removeSurface(_surface);
delete[] _surfaceFilename;
_surfaceFilename = NULL;
}
@@ -109,7 +109,7 @@ ERRORCODE CBSubFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) {
char *params;
int cmd;
- CBParser parser(Game);
+ CBParser parser(_gameRef);
Rect32 rect;
int r = 255, g = 255, b = 255;
int ar = 255, ag = 255, ab = 255, alpha = 255;
@@ -177,7 +177,7 @@ ERRORCODE CBSubFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) {
}
}
if (cmd == PARSERR_TOKENNOTFOUND) {
- Game->LOG(0, "Syntax error in SUBFRAME definition");
+ _gameRef->LOG(0, "Syntax error in SUBFRAME definition");
return STATUS_FAILED;
}
@@ -192,7 +192,7 @@ ERRORCODE CBSubFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) {
/*
if(_surface == NULL)
{
- Game->LOG(0, "Error parsing sub-frame. Image not set.");
+ _gameRef->LOG(0, "Error parsing sub-frame. Image not set.");
return STATUS_FAILED;
}
*/
@@ -209,12 +209,12 @@ ERRORCODE CBSubFrame::draw(int x, int y, CBObject *registerOwner, float zoomX, f
if (registerOwner != NULL && !_decoration) {
if (zoomX == 100 && zoomY == 100) {
- Game->_renderer->_rectList.add(new CBActiveRect(Game, registerOwner, this, x - _hotspotX + _rect.left, y - _hotspotY + _rect.top, _rect.right - _rect.left, _rect.bottom - _rect.top, zoomX, zoomY, precise));
+ _gameRef->_renderer->_rectList.add(new CBActiveRect(_gameRef, registerOwner, this, x - _hotspotX + _rect.left, y - _hotspotY + _rect.top, _rect.right - _rect.left, _rect.bottom - _rect.top, zoomX, zoomY, precise));
} else {
- Game->_renderer->_rectList.add(new CBActiveRect(Game, registerOwner, this, (int)(x - (_hotspotX + _rect.left) * (zoomX / 100)), (int)(y - (_hotspotY + _rect.top) * (zoomY / 100)), (int)((_rect.right - _rect.left) * (zoomX / 100)), (int)((_rect.bottom - _rect.top) * (zoomY / 100)), zoomX, zoomY, precise));
+ _gameRef->_renderer->_rectList.add(new CBActiveRect(_gameRef, registerOwner, this, (int)(x - (_hotspotX + _rect.left) * (zoomX / 100)), (int)(y - (_hotspotY + _rect.top) * (zoomY / 100)), (int)((_rect.right - _rect.left) * (zoomX / 100)), (int)((_rect.bottom - _rect.top) * (zoomY / 100)), zoomX, zoomY, precise));
}
}
- if (Game->_suspendedRendering) return STATUS_OK;
+ if (_gameRef->_suspendedRendering) return STATUS_OK;
ERRORCODE res;
@@ -363,7 +363,7 @@ ERRORCODE CBSubFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack
CScValue *Val = stack->pop();
if (Val->isNULL()) {
- if (_surface) Game->_surfaceStorage->removeSurface(_surface);
+ if (_surface) _gameRef->_surfaceStorage->removeSurface(_surface);
delete[] _surfaceFilename;
_surfaceFilename = NULL;
stack->pushBool(true);
@@ -384,7 +384,7 @@ ERRORCODE CBSubFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack
//////////////////////////////////////////////////////////////////////////
CScValue *CBSubFrame::scGetProperty(const char *name) {
- if (!_scValue) _scValue = new CScValue(Game);
+ if (!_scValue) _scValue = new CScValue(_gameRef);
_scValue->setNULL();
//////////////////////////////////////////////////////////////////////////
@@ -551,14 +551,14 @@ const char *CBSubFrame::scToString() {
//////////////////////////////////////////////////////////////////////////
ERRORCODE CBSubFrame::setSurface(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) {
if (_surface) {
- Game->_surfaceStorage->removeSurface(_surface);
+ _gameRef->_surfaceStorage->removeSurface(_surface);
_surface = NULL;
}
delete[] _surfaceFilename;
_surfaceFilename = NULL;
- _surface = Game->_surfaceStorage->addSurface(filename, defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded);
+ _surface = _gameRef->_surfaceStorage->addSurface(filename, defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded);
if (_surface) {
_surfaceFilename = new char[strlen(filename) + 1];
strcpy(_surfaceFilename, filename);
@@ -581,7 +581,7 @@ ERRORCODE CBSubFrame::setSurfaceSimple() {
_surface = NULL;
return STATUS_OK;
}
- _surface = Game->_surfaceStorage->addSurface(_surfaceFilename, _cKDefault, _cKRed, _cKGreen, _cKBlue, _lifeTime, _keepLoaded);
+ _surface = _gameRef->_surfaceStorage->addSurface(_surfaceFilename, _cKDefault, _cKRed, _cKGreen, _cKBlue, _lifeTime, _keepLoaded);
if (_surface) return STATUS_OK;
else return STATUS_FAILED;
}
diff --git a/engines/wintermute/Base/BSurface.cpp b/engines/wintermute/Base/BSurface.cpp
index 0d96a73d41..8a6d2b2f1d 100644
--- a/engines/wintermute/Base/BSurface.cpp
+++ b/engines/wintermute/Base/BSurface.cpp
@@ -134,10 +134,10 @@ ERRORCODE CBSurface::invalidate() {
//////////////////////////////////////////////////////////////////////////
ERRORCODE CBSurface::prepareToDraw() {
- _lastUsedTime = Game->_liveTimer;
+ _lastUsedTime = _gameRef->_liveTimer;
if (!_valid) {
- //Game->LOG(0, "Reviving: %s", _filename);
+ //_gameRef->LOG(0, "Reviving: %s", _filename);
return create(_filename.c_str(), _ckDefault, _ckRed, _ckGreen, _ckBlue, _lifeTime, _keepLoaded);
} else return STATUS_OK;
}
diff --git a/engines/wintermute/Base/BSurfaceSDL.cpp b/engines/wintermute/Base/BSurfaceSDL.cpp
index bbdfeca3d7..58a09dbe56 100644
--- a/engines/wintermute/Base/BSurfaceSDL.cpp
+++ b/engines/wintermute/Base/BSurfaceSDL.cpp
@@ -67,8 +67,8 @@ CBSurfaceSDL::~CBSurfaceSDL() {
delete[] _alphaMask;
_alphaMask = NULL;
- Game->addMem(-_width * _height * 4);
- CBRenderSDL *renderer = static_cast<CBRenderSDL *>(Game->_renderer);
+ _gameRef->addMem(-_width * _height * 4);
+ CBRenderSDL *renderer = static_cast<CBRenderSDL *>(_gameRef->_renderer);
renderer->invalidateTicketsFromSurface(this);
}
@@ -92,7 +92,7 @@ bool hasTransparency(Graphics::Surface *surf) {
//////////////////////////////////////////////////////////////////////////
ERRORCODE CBSurfaceSDL::create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) {
- /* CBRenderSDL *renderer = static_cast<CBRenderSDL *>(Game->_renderer); */
+ /* CBRenderSDL *renderer = static_cast<CBRenderSDL *>(_gameRef->_renderer); */
_filename = filename;
// const Graphics::Surface *surface = image->getSurface();
@@ -117,7 +117,7 @@ ERRORCODE CBSurfaceSDL::create(const char *filename, bool defaultCK, byte ckRed,
}
void CBSurfaceSDL::finishLoad() {
- CBImage *image = new CBImage(Game);
+ CBImage *image = new CBImage(_gameRef);
image->loadFile(_filename);
_width = image->getSurface()->w;
@@ -183,7 +183,7 @@ void CBSurfaceSDL::finishLoad() {
_valid = true;
- Game->addMem(_width * _height * 4);
+ _gameRef->addMem(_width * _height * 4);
delete image;
@@ -276,13 +276,13 @@ uint32 CBSurfaceSDL::getPixel(Graphics::Surface *surface, int x, int y) {
ERRORCODE CBSurfaceSDL::create(int width, int height) {
warning("SurfaceSDL::Create not ported yet"); //TODO
#if 0
- CBRenderSDL *renderer = static_cast<CBRenderSDL *>(Game->_renderer);
+ CBRenderSDL *renderer = static_cast<CBRenderSDL *>(_gameRef->_renderer);
_texture = SDL_CreateTexture(renderer->GetSdlRenderer(), SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, Width, Height);
#endif
_width = width;
_height = height;
- Game->addMem(_width * _height * 4);
+ _gameRef->addMem(_width * _height * 4);
_valid = true;
@@ -293,7 +293,7 @@ ERRORCODE CBSurfaceSDL::create(int width, int height) {
ERRORCODE CBSurfaceSDL::createFromSDLSurface(Graphics::Surface *surface) {
warning("CBSurfaceSDL::CreateFromSDLSurface not ported yet"); //TODO
#if 0
- CBRenderSDL *renderer = static_cast<CBRenderSDL *>(Game->_renderer);
+ CBRenderSDL *renderer = static_cast<CBRenderSDL *>(_gameRef->_renderer);
_texture = SDL_CreateTextureFromSurface(renderer->GetSdlRenderer(), surface);
#endif
if (_surface) {
@@ -306,7 +306,7 @@ ERRORCODE CBSurfaceSDL::createFromSDLSurface(Graphics::Surface *surface) {
_width = surface->w;
_height = surface->h;
#if 0
- Game->AddMem(_width * _height * 4);
+ _gameRef->AddMem(_width * _height * 4);
#endif
_valid = true;
@@ -390,7 +390,7 @@ bool CBSurfaceSDL::isTransparentAtLite(int x, int y) {
ERRORCODE CBSurfaceSDL::startPixelOp() {
//SDL_LockTexture(_texture, NULL, &_lockPixels, &_lockPitch);
// Any pixel-op makes the caching useless:
- CBRenderSDL *renderer = static_cast<CBRenderSDL *>(Game->_renderer);
+ CBRenderSDL *renderer = static_cast<CBRenderSDL *>(_gameRef->_renderer);
renderer->invalidateTicketsFromSurface(this);
return STATUS_OK;
}
@@ -437,7 +437,7 @@ ERRORCODE CBSurfaceSDL::displayTransform(int x, int y, int hotX, int hotY, Rect3
//////////////////////////////////////////////////////////////////////////
ERRORCODE CBSurfaceSDL::drawSprite(int x, int y, Rect32 *rect, float zoomX, float zoomY, uint32 alpha, bool alphaDisable, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX, int offsetY) {
- CBRenderSDL *renderer = static_cast<CBRenderSDL *>(Game->_renderer);
+ CBRenderSDL *renderer = static_cast<CBRenderSDL *>(_gameRef->_renderer);
if (!_loaded) {
finishLoad();
@@ -523,7 +523,7 @@ ERRORCODE CBSurfaceSDL::putSurface(const Graphics::Surface &surface, bool hasAlp
_loaded = true;
_surface->copyFrom(surface);
_hasAlpha = hasAlpha;
- CBRenderSDL *renderer = static_cast<CBRenderSDL *>(Game->_renderer);
+ CBRenderSDL *renderer = static_cast<CBRenderSDL *>(_gameRef->_renderer);
renderer->invalidateTicketsFromSurface(this);
return STATUS_OK;
diff --git a/engines/wintermute/Base/BSurfaceStorage.cpp b/engines/wintermute/Base/BSurfaceStorage.cpp
index 20a905b62a..cb48f3657b 100644
--- a/engines/wintermute/Base/BSurfaceStorage.cpp
+++ b/engines/wintermute/Base/BSurfaceStorage.cpp
@@ -53,7 +53,7 @@ CBSurfaceStorage::~CBSurfaceStorage() {
//////////////////////////////////////////////////////////////////////////
ERRORCODE CBSurfaceStorage::cleanup(bool warn) {
for (int i = 0; i < _surfaces.getSize(); i++) {
- if (warn) Game->LOG(0, "CBSurfaceStorage warning: purging surface '%s', usage:%d", _surfaces[i]->getFileName(), _surfaces[i]->_referenceCount);
+ if (warn) _gameRef->LOG(0, "CBSurfaceStorage warning: purging surface '%s', usage:%d", _surfaces[i]->getFileName(), _surfaces[i]->_referenceCount);
delete _surfaces[i];
}
_surfaces.removeAll();
@@ -64,14 +64,14 @@ ERRORCODE CBSurfaceStorage::cleanup(bool warn) {
//////////////////////////////////////////////////////////////////////////
ERRORCODE CBSurfaceStorage::initLoop() {
- if (Game->_smartCache && Game->_liveTimer - _lastCleanupTime >= Game->_surfaceGCCycleTime) {
- _lastCleanupTime = Game->_liveTimer;
+ if (_gameRef->_smartCache && _gameRef->_liveTimer - _lastCleanupTime >= _gameRef->_surfaceGCCycleTime) {
+ _lastCleanupTime = _gameRef->_liveTimer;
sortSurfaces();
for (int i = 0; i < _surfaces.getSize(); i++) {
if (_surfaces[i]->_lifeTime <= 0) break;
- if (_surfaces[i]->_lifeTime > 0 && _surfaces[i]->_valid && Game->_liveTimer - _surfaces[i]->_lastUsedTime >= _surfaces[i]->_lifeTime) {
- //Game->QuickMessageForm("Invalidating: %s", _surfaces[i]->_filename);
+ if (_surfaces[i]->_lifeTime > 0 && _surfaces[i]->_valid && _gameRef->_liveTimer - _surfaces[i]->_lastUsedTime >= _surfaces[i]->_lifeTime) {
+ //_gameRef->QuickMessageForm("Invalidating: %s", _surfaces[i]->_filename);
_surfaces[i]->invalidate();
}
}
@@ -105,16 +105,16 @@ CBSurface *CBSurfaceStorage::addSurface(const char *filename, bool defaultCK, by
}
}
- if (!Game->_fileManager->hasFile(filename)) {
- if (filename) Game->LOG(0, "Missing image: '%s'", filename);
- if (Game->_dEBUG_DebugMode)
+ if (!_gameRef->_fileManager->hasFile(filename)) {
+ if (filename) _gameRef->LOG(0, "Missing image: '%s'", filename);
+ if (_gameRef->_dEBUG_DebugMode)
return addSurface("invalid_debug.bmp", defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded);
else
return addSurface("invalid.bmp", defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded);
}
CBSurface *surface;
- surface = new CBSurfaceSDL(Game);
+ surface = new CBSurfaceSDL(_gameRef);
if (!surface) return NULL;
@@ -135,7 +135,7 @@ ERRORCODE CBSurfaceStorage::restoreAll() {
for (int i = 0; i < _surfaces.getSize(); i++) {
ret = _surfaces[i]->restore();
if (ret != STATUS_OK) {
- Game->LOG(0, "CBSurfaceStorage::RestoreAll failed");
+ _gameRef->LOG(0, "CBSurfaceStorage::RestoreAll failed");
return ret;
}
}
@@ -150,7 +150,7 @@ ERRORCODE CBSurfaceStorage::persist(CBPersistMgr *persistMgr)
if(!persistMgr->_saving) cleanup(false);
- persistMgr->transfer(TMEMBER(Game));
+ persistMgr->transfer(TMEMBER(_gameRef));
//_surfaces.persist(persistMgr);
diff --git a/engines/wintermute/Base/BTransitionMgr.cpp b/engines/wintermute/Base/BTransitionMgr.cpp
index 778ac33a3f..537fb0f2f5 100644
--- a/engines/wintermute/Base/BTransitionMgr.cpp
+++ b/engines/wintermute/Base/BTransitionMgr.cpp
@@ -68,8 +68,8 @@ ERRORCODE CBTransitionMgr::start(TTransitionType type, bool nonInteractive) {
if (nonInteractive) {
_preserveInteractive = true;
- _origInteractive = Game->_interactive;
- Game->_interactive = false;
+ _origInteractive = _gameRef->_interactive;
+ _gameRef->_interactive = false;
} /*else _preserveInteractive */;
@@ -100,7 +100,7 @@ ERRORCODE CBTransitionMgr::update() {
uint32 time = CBPlatform::getTime() - _lastTime;
int alpha = (int)(255 - (float)time / (float)FADE_DURATION * 255);
alpha = MIN(255, MAX(alpha, 0));
- Game->_renderer->fade((uint16)alpha);
+ _gameRef->_renderer->fade((uint16)alpha);
if (time > FADE_DURATION)
_state = TRANS_MGR_READY;
@@ -111,7 +111,7 @@ ERRORCODE CBTransitionMgr::update() {
uint32 time = CBPlatform::getTime() - _lastTime;
int alpha = (int)((float)time / (float)FADE_DURATION * 255);
alpha = MIN(255, MAX(alpha, 0));
- Game->_renderer->fade((uint16)alpha);
+ _gameRef->_renderer->fade((uint16)alpha);
if (time > FADE_DURATION)
_state = TRANS_MGR_READY;
@@ -123,7 +123,7 @@ ERRORCODE CBTransitionMgr::update() {
if (isReady()) {
if (_preserveInteractive)
- Game->_interactive = _origInteractive;
+ _gameRef->_interactive = _origInteractive;
}
return STATUS_OK;
}
diff --git a/engines/wintermute/Base/BViewport.cpp b/engines/wintermute/Base/BViewport.cpp
index f1f28bc78b..a245baf26d 100644
--- a/engines/wintermute/Base/BViewport.cpp
+++ b/engines/wintermute/Base/BViewport.cpp
@@ -51,7 +51,7 @@ CBViewport::~CBViewport() {
//////////////////////////////////////////////////////////////////////////
ERRORCODE CBViewport::persist(CBPersistMgr *persistMgr) {
- persistMgr->transfer(TMEMBER(Game));
+ persistMgr->transfer(TMEMBER(_gameRef));
persistMgr->transfer(TMEMBER(_mainObject));
persistMgr->transfer(TMEMBER(_offsetX));
@@ -67,8 +67,8 @@ ERRORCODE CBViewport::setRect(int left, int top, int right, int bottom, bool noC
if (!noCheck) {
left = MAX(left, 0);
top = MAX(top, 0);
- right = MIN(right, Game->_renderer->_width);
- bottom = MIN(bottom, Game->_renderer->_height);
+ right = MIN(right, _gameRef->_renderer->_width);
+ bottom = MIN(bottom, _gameRef->_renderer->_height);
}
CBPlatform::setRect(&_rect, left, top, right, bottom);
diff --git a/engines/wintermute/Base/file/BSaveThumbFile.cpp b/engines/wintermute/Base/file/BSaveThumbFile.cpp
index 266d19b46c..3768578987 100644
--- a/engines/wintermute/Base/file/BSaveThumbFile.cpp
+++ b/engines/wintermute/Base/file/BSaveThumbFile.cpp
@@ -70,17 +70,17 @@ ERRORCODE CBSaveThumbFile::open(const Common::String &filename) {
delete [] tempFilename;
char slotFilename[MAX_PATH_LENGTH + 1];
- Game->getSaveSlotFilename(slot, slotFilename);
- CBPersistMgr *pm = new CBPersistMgr(Game);
+ _gameRef->getSaveSlotFilename(slot, slotFilename);
+ CBPersistMgr *pm = new CBPersistMgr(_gameRef);
if (!pm) return STATUS_FAILED;
- Game->_dEBUG_AbsolutePathWarning = false;
+ _gameRef->_dEBUG_AbsolutePathWarning = false;
if (DID_FAIL(pm->initLoad(slotFilename))) {
- Game->_dEBUG_AbsolutePathWarning = true;
+ _gameRef->_dEBUG_AbsolutePathWarning = true;
delete pm;
return STATUS_FAILED;
}
- Game->_dEBUG_AbsolutePathWarning = true;
+ _gameRef->_dEBUG_AbsolutePathWarning = true;
ERRORCODE res;
diff --git a/engines/wintermute/Base/font/BFont.cpp b/engines/wintermute/Base/font/BFont.cpp
index b59188d0c1..b910bdbd90 100644
--- a/engines/wintermute/Base/font/BFont.cpp
+++ b/engines/wintermute/Base/font/BFont.cpp
@@ -73,9 +73,9 @@ int CBFont::getTextWidth(byte *text, int maxLength) {
//////////////////////////////////////////////////////////////////////
ERRORCODE CBFont::loadFile(const char * Filename)
{
- BYTE* Buffer = Game->_fileManager->readWholeFile(filename);
+ BYTE* Buffer = _gameRef->_fileManager->readWholeFile(filename);
if(Buffer==NULL){
- Game->LOG(0, "CBFont::LoadFile failed for file '%s'", filename);
+ _gameRef->LOG(0, "CBFont::LoadFile failed for file '%s'", filename);
return STATUS_FAILED;
}
@@ -84,7 +84,7 @@ ERRORCODE CBFont::loadFile(const char * Filename)
_filename = new char [strlen(filename)+1];
strcpy(_filename, filename);
- if(DID_FAIL(ret = loadBuffer(Buffer))) Game->LOG(0, "Error parsing FONT file '%s'", filename);
+ if(DID_FAIL(ret = loadBuffer(Buffer))) _gameRef->LOG(0, "Error parsing FONT file '%s'", filename);
delete [] Buffer;
@@ -104,10 +104,10 @@ ERRORCODE CBFont::loadBuffer(byte * Buffer)
char* params;
int cmd;
- CBParser parser(Game);
+ CBParser parser(_gameRef);
if(parser.GetCommand ((char**)&Buffer, commands, (char**)&params)!=TOKEN_FONT){
- Game->LOG(0, "'FONT' keyword expected.");
+ _gameRef->LOG(0, "'FONT' keyword expected.");
return STATUS_FAILED;
}
Buffer = (byte *)params;
@@ -129,7 +129,7 @@ ERRORCODE CBFont::loadBuffer(byte * Buffer)
}
if (cmd == PARSERR_TOKENNOTFOUND){
- Game->LOG(0, "Syntax error in FONT definition");
+ _gameRef->LOG(0, "Syntax error in FONT definition");
return STATUS_FAILED;
}
@@ -152,9 +152,9 @@ ERRORCODE CBFont::persist(CBPersistMgr *persistMgr) {
//////////////////////////////////////////////////////////////////////////
-CBFont *CBFont::createFromFile(CBGame *Game, const char *filename) {
- if (isTrueType(Game, filename)) {
- CBFontTT *font = new CBFontTT(Game);
+CBFont *CBFont::createFromFile(CBGame *gameRef, const char *filename) {
+ if (isTrueType(gameRef, filename)) {
+ CBFontTT *font = new CBFontTT(gameRef);
if (font) {
if (DID_FAIL(font->loadFile(filename))) {
delete font;
@@ -163,7 +163,7 @@ CBFont *CBFont::createFromFile(CBGame *Game, const char *filename) {
}
return font;
} else {
- CBFontBitmap *font = new CBFontBitmap(Game);
+ CBFontBitmap *font = new CBFontBitmap(gameRef);
if (font) {
if (DID_FAIL(font->loadFile(filename))) {
delete font;
@@ -180,20 +180,20 @@ TOKEN_DEF(FONT)
TOKEN_DEF(TTFONT)
TOKEN_DEF_END
//////////////////////////////////////////////////////////////////////////
-bool CBFont::isTrueType(CBGame *Game, const char *filename) {
+bool CBFont::isTrueType(CBGame *gameRef, const char *filename) {
TOKEN_TABLE_START(commands)
TOKEN_TABLE(FONT)
TOKEN_TABLE(TTFONT)
TOKEN_TABLE_END
- byte *buffer = Game->_fileManager->readWholeFile(filename);
+ byte *buffer = gameRef->_fileManager->readWholeFile(filename);
if (buffer == NULL) return false;
byte *WorkBuffer = buffer;
char *params;
- CBParser parser(Game);
+ CBParser parser(gameRef);
bool ret = false;
if (parser.getCommand((char **)&WorkBuffer, commands, (char **)&params) == TOKEN_TTFONT)
diff --git a/engines/wintermute/Base/font/BFontBitmap.cpp b/engines/wintermute/Base/font/BFontBitmap.cpp
index 681f2580bf..96a6387070 100644
--- a/engines/wintermute/Base/font/BFontBitmap.cpp
+++ b/engines/wintermute/Base/font/BFontBitmap.cpp
@@ -85,7 +85,7 @@ int CBFontBitmap::getTextHeight(byte *text, int width) {
int CBFontBitmap::getTextWidth(byte *text, int maxLength) {
AnsiString str;
- if (Game->_textEncoding == TEXT_UTF8) {
+ if (_gameRef->_textEncoding == TEXT_UTF8) {
WideString wstr = StringUtil::utf8ToWide(Utf8String((char *)text));
str = StringUtil::wideToAnsi(wstr);
} else {
@@ -113,7 +113,7 @@ int CBFontBitmap::textHeightDraw(byte *text, int x, int y, int width, TTextAlign
AnsiString str;
- if (Game->_textEncoding == TEXT_UTF8) {
+ if (_gameRef->_textEncoding == TEXT_UTF8) {
WideString wstr = StringUtil::utf8ToWide(Utf8String((char *)text));
str = StringUtil::wideToAnsi(wstr);
} else {
@@ -136,11 +136,11 @@ int CBFontBitmap::textHeightDraw(byte *text, int x, int y, int width, TTextAlign
bool new_line = false;
bool long_line = false;
- if (draw) Game->_renderer->startSpriteBatch();
+ if (draw) _gameRef->_renderer->startSpriteBatch();
while (!done) {
if (maxHeight > 0 && (NumLines + 1)*_tileHeight > maxHeight) {
- if (draw) Game->_renderer->endSpriteBatch();
+ if (draw) _gameRef->_renderer->endSpriteBatch();
return NumLines * _tileHeight;
}
@@ -206,7 +206,7 @@ int CBFontBitmap::textHeightDraw(byte *text, int x, int y, int width, TTextAlign
}
}
- if (draw) Game->_renderer->endSpriteBatch();
+ if (draw) _gameRef->_renderer->endSpriteBatch();
return NumLines * _tileHeight;
}
@@ -244,9 +244,9 @@ void CBFontBitmap::drawChar(byte c, int x, int y) {
//////////////////////////////////////////////////////////////////////
ERRORCODE CBFontBitmap::loadFile(const char *filename) {
- byte *buffer = Game->_fileManager->readWholeFile(filename);
+ byte *buffer = _gameRef->_fileManager->readWholeFile(filename);
if (buffer == NULL) {
- Game->LOG(0, "CBFontBitmap::LoadFile failed for file '%s'", filename);
+ _gameRef->LOG(0, "CBFontBitmap::LoadFile failed for file '%s'", filename);
return STATUS_FAILED;
}
@@ -255,7 +255,7 @@ ERRORCODE CBFontBitmap::loadFile(const char *filename) {
_filename = new char [strlen(filename) + 1];
strcpy(_filename, filename);
- if (DID_FAIL(ret = loadBuffer(buffer))) Game->LOG(0, "Error parsing FONT file '%s'", filename);
+ if (DID_FAIL(ret = loadBuffer(buffer))) _gameRef->LOG(0, "Error parsing FONT file '%s'", filename);
delete [] buffer;
@@ -304,10 +304,10 @@ ERRORCODE CBFontBitmap::loadBuffer(byte *buffer) {
char *params;
int cmd;
- CBParser parser(Game);
+ CBParser parser(_gameRef);
if (parser.getCommand((char **)&buffer, commands, (char **)&params) != TOKEN_FONT) {
- Game->LOG(0, "'FONT' keyword expected.");
+ _gameRef->LOG(0, "'FONT' keyword expected.");
return STATUS_FAILED;
}
buffer = (byte *)params;
@@ -395,13 +395,13 @@ ERRORCODE CBFontBitmap::loadBuffer(byte *buffer) {
}
if (cmd == PARSERR_TOKENNOTFOUND) {
- Game->LOG(0, "Syntax error in FONT definition");
+ _gameRef->LOG(0, "Syntax error in FONT definition");
return STATUS_FAILED;
}
if (spriteFile != NULL) {
delete _sprite;
- _sprite = new CBSprite(Game, this);
+ _sprite = new CBSprite(_gameRef, this);
if (!_sprite || DID_FAIL(_sprite->loadFile(spriteFile))) {
delete _sprite;
_sprite = NULL;
@@ -409,14 +409,14 @@ ERRORCODE CBFontBitmap::loadBuffer(byte *buffer) {
}
if (surfaceFile != NULL && !_sprite) {
- _subframe = new CBSubFrame(Game);
+ _subframe = new CBSubFrame(_gameRef);
if (custoTrans) _subframe->setSurface(surfaceFile, false, r, g, b);
else _subframe->setSurface(surfaceFile);
}
if (((_subframe == NULL || _subframe->_surface == NULL) && _sprite == NULL) || _numColumns == 0 || _tileWidth == 0 || _tileHeight == 0) {
- Game->LOG(0, "Incomplete font definition");
+ _gameRef->LOG(0, "Incomplete font definition");
return STATUS_FAILED;
}
@@ -523,10 +523,10 @@ ERRORCODE CBFontBitmap::getWidths() {
}
surf->endPixelOp();
/*
- Game->LOG(0, "----- %s ------", _filename);
+ _gameRef->LOG(0, "----- %s ------", _filename);
for(int j=0; j<16; j++)
{
- Game->LOG(0, "%02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d", _widths[j*16+0], _widths[j*16+1], _widths[j*16+2], _widths[j*16+3], _widths[j*16+4], _widths[j*16+5], _widths[j*16+6], _widths[j*16+7], _widths[j*16+8], _widths[j*16+9], _widths[j*16+10], _widths[j*16+11], _widths[j*16+12], _widths[j*16+13], _widths[j*16+14], _widths[j*16+15]);
+ _gameRef->LOG(0, "%02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d", _widths[j*16+0], _widths[j*16+1], _widths[j*16+2], _widths[j*16+3], _widths[j*16+4], _widths[j*16+5], _widths[j*16+6], _widths[j*16+7], _widths[j*16+8], _widths[j*16+9], _widths[j*16+10], _widths[j*16+11], _widths[j*16+12], _widths[j*16+13], _widths[j*16+14], _widths[j*16+15]);
}
*/
return STATUS_OK;
diff --git a/engines/wintermute/Base/font/BFontStorage.cpp b/engines/wintermute/Base/font/BFontStorage.cpp
index 5a0a1e327f..c9c6df9f6e 100644
--- a/engines/wintermute/Base/font/BFontStorage.cpp
+++ b/engines/wintermute/Base/font/BFontStorage.cpp
@@ -53,7 +53,7 @@ CBFontStorage::~CBFontStorage() {
//////////////////////////////////////////////////////////////////////////
ERRORCODE CBFontStorage::cleanup(bool warn) {
for (int i = 0; i < _fonts.getSize(); i++) {
- if (warn) Game->LOG(0, "Removing orphan font '%s'", _fonts[i]->_filename);
+ if (warn) _gameRef->LOG(0, "Removing orphan font '%s'", _fonts[i]->_filename);
delete _fonts[i];
}
_fonts.removeAll();
@@ -81,7 +81,7 @@ CBFont *CBFontStorage::addFont(const char *filename) {
}
/*
- CBFont* font = new CBFont(Game);
+ CBFont* font = new CBFont(_gameRef);
if (!font) return NULL;
if (DID_FAIL(font->loadFile(filename))) {
@@ -94,7 +94,7 @@ CBFont *CBFontStorage::addFont(const char *filename) {
return font;
}
*/
- CBFont *font = CBFont::createFromFile(Game, filename);
+ CBFont *font = CBFont::createFromFile(_gameRef, filename);
if (font) {
font->_refCount = 1;
_fonts.add(font);
@@ -126,7 +126,7 @@ ERRORCODE CBFontStorage::persist(CBPersistMgr *persistMgr) {
if (!persistMgr->_saving) cleanup(false);
- persistMgr->transfer(TMEMBER(Game));
+ persistMgr->transfer(TMEMBER(_gameRef));
_fonts.persist(persistMgr);
return STATUS_OK;
diff --git a/engines/wintermute/Base/font/BFontTT.cpp b/engines/wintermute/Base/font/BFontTT.cpp
index c87a5b4a5f..e77d95985b 100644
--- a/engines/wintermute/Base/font/BFontTT.cpp
+++ b/engines/wintermute/Base/font/BFontTT.cpp
@@ -106,7 +106,7 @@ void CBFontTT::clearCache() {
//////////////////////////////////////////////////////////////////////////
void CBFontTT::initLoop() {
// we need more aggressive cache management on iOS not to waste too much memory on fonts
- if (Game->_constrainedMemory) {
+ if (_gameRef->_constrainedMemory) {
// purge all cached images not used in the last frame
for (int i = 0; i < NUM_CACHED_TEXTS; i++) {
if (_cachedTexts[i] == NULL) continue;
@@ -123,7 +123,7 @@ void CBFontTT::initLoop() {
int CBFontTT::getTextWidth(byte *text, int maxLength) {
WideString textStr;
- if (Game->_textEncoding == TEXT_UTF8) textStr = StringUtil::utf8ToWide((char *)text);
+ if (_gameRef->_textEncoding == TEXT_UTF8) textStr = StringUtil::utf8ToWide((char *)text);
else textStr = StringUtil::ansiToWide((char *)text);
if (maxLength >= 0 && textStr.size() > (uint32)maxLength)
@@ -140,7 +140,7 @@ int CBFontTT::getTextWidth(byte *text, int maxLength) {
int CBFontTT::getTextHeight(byte *text, int width) {
WideString textStr;
- if (Game->_textEncoding == TEXT_UTF8) textStr = StringUtil::utf8ToWide((char *)text);
+ if (_gameRef->_textEncoding == TEXT_UTF8) textStr = StringUtil::utf8ToWide((char *)text);
else textStr = StringUtil::ansiToWide((char *)text);
@@ -158,14 +158,14 @@ void CBFontTT::drawText(byte *text, int x, int y, int width, TTextAlign align, i
WideString textStr = (char *)text;
// TODO: Why do we still insist on Widestrings everywhere?
- /* if (Game->_textEncoding == TEXT_UTF8) text = StringUtil::Utf8ToWide((char *)Text);
+ /* if (_gameRef->_textEncoding == TEXT_UTF8) text = StringUtil::Utf8ToWide((char *)Text);
else text = StringUtil::AnsiToWide((char *)Text);*/
if (maxLength >= 0 && textStr.size() > (uint32)maxLength)
textStr = Common::String(textStr.c_str(), (uint32)maxLength);
//text = text.substr(0, MaxLength); // TODO: Remove
- CBRenderer *renderer = Game->_renderer;
+ CBRenderer *renderer = _gameRef->_renderer;
// find cached surface, if exists
int minPriority = INT_MAX;
@@ -272,7 +272,7 @@ CBSurface *CBFontTT::renderTextToTexture(const WideString &text, int width, TTex
heightOffset += (int)_lineHeight;
}
- CBSurface *retSurface = Game->_renderer->createSurface();
+ CBSurface *retSurface = _gameRef->_renderer->createSurface();
Graphics::Surface *convertedSurface = surface->convertTo(Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8 , 0));
retSurface->putSurface(*convertedSurface, true);
convertedSurface->free();
@@ -361,7 +361,7 @@ CBSurface *CBFontTT::renderTextToTexture(const WideString &text, int width, TTex
posY += GetLineHeight();
}
- CBSurfaceSDL *wmeSurface = new CBSurfaceSDL(Game);
+ CBSurfaceSDL *wmeSurface = new CBSurfaceSDL(_gameRef);
if (DID_SUCCEED(wmeSurface->CreateFromSDLSurface(surface))) {
SDL_FreeSurface(surface);
return wmeSurface;
@@ -406,9 +406,9 @@ int CBFontTT::getLetterHeight() {
//////////////////////////////////////////////////////////////////////
ERRORCODE CBFontTT::loadFile(const char *filename) {
- byte *buffer = Game->_fileManager->readWholeFile(filename);
+ byte *buffer = _gameRef->_fileManager->readWholeFile(filename);
if (buffer == NULL) {
- Game->LOG(0, "CBFontTT::LoadFile failed for file '%s'", filename);
+ _gameRef->LOG(0, "CBFontTT::LoadFile failed for file '%s'", filename);
return STATUS_FAILED;
}
@@ -417,7 +417,7 @@ ERRORCODE CBFontTT::loadFile(const char *filename) {
_filename = new char [strlen(filename) + 1];
strcpy(_filename, filename);
- if (DID_FAIL(ret = loadBuffer(buffer))) Game->LOG(0, "Error parsing TTFONT file '%s'", filename);
+ if (DID_FAIL(ret = loadBuffer(buffer))) _gameRef->LOG(0, "Error parsing TTFONT file '%s'", filename);
delete [] buffer;
@@ -460,10 +460,10 @@ ERRORCODE CBFontTT::loadBuffer(byte *buffer) {
char *params;
int cmd;
- CBParser parser(Game);
+ CBParser parser(_gameRef);
if (parser.getCommand((char **)&buffer, commands, (char **)&params) != TOKEN_TTFONT) {
- Game->LOG(0, "'TTFONT' keyword expected.");
+ _gameRef->LOG(0, "'TTFONT' keyword expected.");
return STATUS_FAILED;
}
buffer = (byte *)params;
@@ -532,7 +532,7 @@ ERRORCODE CBFontTT::loadBuffer(byte *buffer) {
}
}
if (cmd == PARSERR_TOKENNOTFOUND) {
- Game->LOG(0, "Syntax error in TTFONT definition");
+ _gameRef->LOG(0, "Syntax error in TTFONT definition");
return STATUS_FAILED;
}
@@ -560,7 +560,7 @@ ERRORCODE CBFontTT::parseLayer(CBTTFontLayer *layer, byte *buffer) {
char *params;
int cmd;
- CBParser parser(Game);
+ CBParser parser(_gameRef);
while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)&params)) > 0) {
switch (cmd) {
@@ -638,13 +638,13 @@ void CBFontTT::afterLoad() {
ERRORCODE CBFontTT::initFont() {
if (!_fontFile) return STATUS_FAILED;
- Common::SeekableReadStream *file = Game->_fileManager->openFile(_fontFile);
+ Common::SeekableReadStream *file = _gameRef->_fileManager->openFile(_fontFile);
if (!file) {
// the requested font file is not in wme file space; try loading a system font
AnsiString fontFileName = PathUtil::combine(CBPlatform::getSystemFontPath(), PathUtil::getFileName(_fontFile));
- file = Game->_fileManager->openFile(fontFileName.c_str(), false);
+ file = _gameRef->_fileManager->openFile(fontFileName.c_str(), false);
if (!file) {
- Game->LOG(0, "Error loading TrueType font '%s'", _fontFile);
+ _gameRef->LOG(0, "Error loading TrueType font '%s'", _fontFile);
//return STATUS_FAILED;
}
}
@@ -680,10 +680,10 @@ ERRORCODE CBFontTT::initFont() {
args.flags = FT_OPEN_STREAM;
args.stream = _fTStream;
- error = FT_Open_Face(Game->_fontStorage->GetFTLibrary(), &args, 0, &_fTFace);
+ error = FT_Open_Face(_gameRef->_fontStorage->GetFTLibrary(), &args, 0, &_fTFace);
if (error) {
SAFE_DELETE_ARRAY(_fTStream);
- Game->_fileManager->closeFile(file);
+ _gameRef->_fileManager->closeFile(file);
return STATUS_FAILED;
}
diff --git a/engines/wintermute/Base/particles/PartEmitter.cpp b/engines/wintermute/Base/particles/PartEmitter.cpp
index 9a92d2aa6e..dc76dd696d 100644
--- a/engines/wintermute/Base/particles/PartEmitter.cpp
+++ b/engines/wintermute/Base/particles/PartEmitter.cpp
@@ -125,11 +125,11 @@ ERRORCODE CPartEmitter::addSprite(const char *filename) {
}
// check if file exists
- Common::SeekableReadStream *File = Game->_fileManager->openFile(filename);
+ Common::SeekableReadStream *File = _gameRef->_fileManager->openFile(filename);
if (!File) {
- Game->LOG(0, "Sprite '%s' not found", filename);
+ _gameRef->LOG(0, "Sprite '%s' not found", filename);
return STATUS_FAILED;
- } else Game->_fileManager->closeFile(File);
+ } else _gameRef->_fileManager->closeFile(File);
char *Str = new char[strlen(filename) + 1];
strcpy(Str, filename);
@@ -228,7 +228,7 @@ ERRORCODE CPartEmitter::initParticle(CPartParticle *particle, uint32 currentTime
//////////////////////////////////////////////////////////////////////////
ERRORCODE CPartEmitter::update() {
if (!_running) return STATUS_OK;
- else return updateInternal(Game->_timer, Game->_timerDelta);
+ else return updateInternal(_gameRef->_timer, _gameRef->_timerDelta);
}
//////////////////////////////////////////////////////////////////////////
@@ -266,7 +266,7 @@ ERRORCODE CPartEmitter::updateInternal(uint32 currentTime, uint32 timerDelta) {
CPartParticle *particle;
if (firstDeadIndex >= 0) particle = _particles[firstDeadIndex];
else {
- particle = new CPartParticle(Game);
+ particle = new CPartParticle(_gameRef);
_particles.add(particle);
}
initParticle(particle, currentTime, timerDelta);
@@ -289,7 +289,7 @@ ERRORCODE CPartEmitter::updateInternal(uint32 currentTime, uint32 timerDelta) {
//////////////////////////////////////////////////////////////////////////
ERRORCODE CPartEmitter::display(CBRegion *region) {
- if (_sprites.getSize() <= 1) Game->_renderer->startSpriteBatch();
+ if (_sprites.getSize() <= 1) _gameRef->_renderer->startSpriteBatch();
for (int i = 0; i < _particles.getSize(); i++) {
if (region != NULL && _useRegion) {
@@ -299,7 +299,7 @@ ERRORCODE CPartEmitter::display(CBRegion *region) {
_particles[i]->display(this);
}
- if (_sprites.getSize() <= 1) Game->_renderer->endSpriteBatch();
+ if (_sprites.getSize() <= 1) _gameRef->_renderer->endSpriteBatch();
return STATUS_OK;
}
@@ -316,7 +316,7 @@ ERRORCODE CPartEmitter::start() {
if (_overheadTime > 0) {
uint32 delta = 500;
int steps = _overheadTime / delta;
- uint32 currentTime = Game->_timer - _overheadTime;
+ uint32 currentTime = _gameRef->_timer - _overheadTime;
for (int i = 0; i < steps; i++) {
updateInternal(currentTime, delta);
@@ -373,7 +373,7 @@ CPartForce *CPartEmitter::addForceByName(const char *name) {
}
}
if (!force) {
- force = new CPartForce(Game);
+ force = new CPartForce(_gameRef);
if (force) {
force->setName(name);
_forces.add(force);
@@ -1171,7 +1171,7 @@ ERRORCODE CPartEmitter::persist(CBPersistMgr *persistMgr) {
} else {
persistMgr->transfer(TMEMBER(numForces));
for (int i = 0; i < numForces; i++) {
- CPartForce *force = new CPartForce(Game);
+ CPartForce *force = new CPartForce(_gameRef);
force->persist(persistMgr);
_forces.add(force);
}
@@ -1187,7 +1187,7 @@ ERRORCODE CPartEmitter::persist(CBPersistMgr *persistMgr) {
} else {
persistMgr->transfer(TMEMBER(numParticles));
for (int i = 0; i < numParticles; i++) {
- CPartParticle *particle = new CPartParticle(Game);
+ CPartParticle *particle = new CPartParticle(_gameRef);
particle->persist(persistMgr);
_particles.add(particle);
}
diff --git a/engines/wintermute/Base/particles/PartParticle.cpp b/engines/wintermute/Base/particles/PartParticle.cpp
index 10a8e6f51b..ebb7fe9f7a 100644
--- a/engines/wintermute/Base/particles/PartParticle.cpp
+++ b/engines/wintermute/Base/particles/PartParticle.cpp
@@ -82,7 +82,7 @@ ERRORCODE CPartParticle::setSprite(const char *filename) {
_sprite = NULL;
CSysClassRegistry::getInstance()->_disabled = true;
- _sprite = new CBSprite(Game, Game);
+ _sprite = new CBSprite(_gameRef, _gameRef);
if (_sprite && DID_SUCCEED(_sprite->loadFile(filename))) {
CSysClassRegistry::getInstance()->_disabled = false;
return STATUS_OK;
diff --git a/engines/wintermute/Base/scriptables/SXArray.cpp b/engines/wintermute/Base/scriptables/SXArray.cpp
index 204a1170e2..a52a83db0a 100644
--- a/engines/wintermute/Base/scriptables/SXArray.cpp
+++ b/engines/wintermute/Base/scriptables/SXArray.cpp
@@ -43,7 +43,7 @@ CBScriptable *makeSXArray(CBGame *inGame, CScStack *stack) {
//////////////////////////////////////////////////////////////////////////
CSXArray::CSXArray(CBGame *inGame, CScStack *stack): CBScriptable(inGame) {
_length = 0;
- _values = new CScValue(Game);
+ _values = new CScValue(_gameRef);
int numParams = stack->pop()->getInt(0);
@@ -61,7 +61,7 @@ CSXArray::CSXArray(CBGame *inGame, CScStack *stack): CBScriptable(inGame) {
//////////////////////////////////////////////////////////////////////////
CSXArray::CSXArray(CBGame *inGame): CBScriptable(inGame) {
_length = 0;
- _values = new CScValue(Game);
+ _values = new CScValue(_gameRef);
}
diff --git a/engines/wintermute/Base/scriptables/SXFile.cpp b/engines/wintermute/Base/scriptables/SXFile.cpp
index caab59a89e..cc30c14e93 100644
--- a/engines/wintermute/Base/scriptables/SXFile.cpp
+++ b/engines/wintermute/Base/scriptables/SXFile.cpp
@@ -80,7 +80,7 @@ void CSXFile::cleanup() {
//////////////////////////////////////////////////////////////////////////
void CSXFile::close() {
if (_readFile) {
- Game->_fileManager->closeFile(_readFile);
+ _gameRef->_fileManager->closeFile(_readFile);
_readFile = NULL;
}
if (_writeFile) {
@@ -125,7 +125,7 @@ ERRORCODE CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
_mode = 1;
}
if (_mode == 1) {
- _readFile = Game->_fileManager->openFile(_filename);
+ _readFile = _gameRef->_fileManager->openFile(_filename);
if (!_readFile) {
//script->runtimeError("File.%s: Error opening file '%s' for reading.", Name, _filename);
close();
@@ -739,7 +739,7 @@ ERRORCODE CSXFile::persist(CBPersistMgr *persistMgr) {
if (_mode != 0) {
// open for reading
if (_mode == 1) {
- _readFile = Game->_fileManager->openFile(_filename);
+ _readFile = _gameRef->_fileManager->openFile(_filename);
if (!_readFile)
close();
}
diff --git a/engines/wintermute/Base/scriptables/SXMemBuffer.cpp b/engines/wintermute/Base/scriptables/SXMemBuffer.cpp
index 0854cfb505..428a58a997 100644
--- a/engines/wintermute/Base/scriptables/SXMemBuffer.cpp
+++ b/engines/wintermute/Base/scriptables/SXMemBuffer.cpp
@@ -264,7 +264,7 @@ ERRORCODE CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStac
stack->pushNULL();
else {
void *pointer = *(void **)((byte *)_buffer + start);
- CSXMemBuffer *buf = new CSXMemBuffer(Game, pointer);
+ CSXMemBuffer *buf = new CSXMemBuffer(_gameRef, pointer);
stack->pushNative(buf, false);
}
return STATUS_OK;
diff --git a/engines/wintermute/Base/scriptables/SXString.cpp b/engines/wintermute/Base/scriptables/SXString.cpp
index 2ad8a36ff7..5e7043ee19 100644
--- a/engines/wintermute/Base/scriptables/SXString.cpp
+++ b/engines/wintermute/Base/scriptables/SXString.cpp
@@ -112,7 +112,7 @@ ERRORCODE CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *
//try {
WideString str;
- if (Game->_textEncoding == TEXT_UTF8)
+ if (_gameRef->_textEncoding == TEXT_UTF8)
str = StringUtil::utf8ToWide(_string);
else
str = StringUtil::ansiToWide(_string);
@@ -120,7 +120,7 @@ ERRORCODE CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *
//WideString subStr = str.substr(start, end - start + 1);
WideString subStr(str.c_str() + start, end - start + 1);
- if (Game->_textEncoding == TEXT_UTF8)
+ if (_gameRef->_textEncoding == TEXT_UTF8)
stack->pushString(StringUtil::wideToUtf8(subStr).c_str());
else
stack->pushString(StringUtil::wideToAnsi(subStr).c_str());
@@ -150,7 +150,7 @@ ERRORCODE CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *
// try {
WideString str;
- if (Game->_textEncoding == TEXT_UTF8)
+ if (_gameRef->_textEncoding == TEXT_UTF8)
str = StringUtil::utf8ToWide(_string);
else
str = StringUtil::ansiToWide(_string);
@@ -158,7 +158,7 @@ ERRORCODE CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *
// WideString subStr = str.substr(start, len);
WideString subStr(str.c_str() + start, len);
- if (Game->_textEncoding == TEXT_UTF8)
+ if (_gameRef->_textEncoding == TEXT_UTF8)
stack->pushString(StringUtil::wideToUtf8(subStr).c_str());
else
stack->pushString(StringUtil::wideToAnsi(subStr).c_str());
@@ -176,14 +176,14 @@ ERRORCODE CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *
stack->correctParams(0);
WideString str;
- if (Game->_textEncoding == TEXT_UTF8)
+ if (_gameRef->_textEncoding == TEXT_UTF8)
str = StringUtil::utf8ToWide(_string);
else
str = StringUtil::ansiToWide(_string);
str.toUppercase();
- if (Game->_textEncoding == TEXT_UTF8)
+ if (_gameRef->_textEncoding == TEXT_UTF8)
stack->pushString(StringUtil::wideToUtf8(str).c_str());
else
stack->pushString(StringUtil::wideToAnsi(str).c_str());
@@ -198,14 +198,14 @@ ERRORCODE CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *
stack->correctParams(0);
WideString str;
- if (Game->_textEncoding == TEXT_UTF8)
+ if (_gameRef->_textEncoding == TEXT_UTF8)
str = StringUtil::utf8ToWide(_string);
else
str = StringUtil::ansiToWide(_string);
str.toLowercase();
- if (Game->_textEncoding == TEXT_UTF8)
+ if (_gameRef->_textEncoding == TEXT_UTF8)
stack->pushString(StringUtil::wideToUtf8(str).c_str());
else
stack->pushString(StringUtil::wideToAnsi(str).c_str());
@@ -223,13 +223,13 @@ ERRORCODE CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *
int index = stack->pop()->getInt();
WideString str;
- if (Game->_textEncoding == TEXT_UTF8)
+ if (_gameRef->_textEncoding == TEXT_UTF8)
str = StringUtil::utf8ToWide(_string);
else
str = StringUtil::ansiToWide(_string);
WideString toFind;
- if (Game->_textEncoding == TEXT_UTF8)
+ if (_gameRef->_textEncoding == TEXT_UTF8)
toFind = StringUtil::utf8ToWide(strToFind);
else
toFind = StringUtil::ansiToWide(strToFind);
@@ -249,7 +249,7 @@ ERRORCODE CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *
char separators[MAX_PATH_LENGTH] = ",";
if (!val->isNULL()) strcpy(separators, val->getString());
- CSXArray *array = new CSXArray(Game);
+ CSXArray *array = new CSXArray(_gameRef);
if (!array) {
stack->pushNULL();
return STATUS_OK;
@@ -257,13 +257,13 @@ ERRORCODE CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *
WideString str;
- if (Game->_textEncoding == TEXT_UTF8)
+ if (_gameRef->_textEncoding == TEXT_UTF8)
str = StringUtil::utf8ToWide(_string);
else
str = StringUtil::ansiToWide(_string);
WideString delims;
- if (Game->_textEncoding == TEXT_UTF8)
+ if (_gameRef->_textEncoding == TEXT_UTF8)
delims = StringUtil::utf8ToWide(separators);
else
delims = StringUtil::ansiToWide(separators);
@@ -298,10 +298,10 @@ ERRORCODE CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *
for (Common::Array<WideString>::iterator it = parts.begin(); it != parts.end(); ++it) {
WideString &part = (*it);
- if (Game->_textEncoding == TEXT_UTF8)
- val = new CScValue(Game, StringUtil::wideToUtf8(part).c_str());
+ if (_gameRef->_textEncoding == TEXT_UTF8)
+ val = new CScValue(_gameRef, StringUtil::wideToUtf8(part).c_str());
else
- val = new CScValue(Game, StringUtil::wideToAnsi(part).c_str());
+ val = new CScValue(_gameRef, StringUtil::wideToAnsi(part).c_str());
array->push(val);
delete val;
@@ -331,7 +331,7 @@ CScValue *CSXString::scGetProperty(const char *name) {
// Length (RO)
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "Length") == 0) {
- if (Game->_textEncoding == TEXT_UTF8) {
+ if (_gameRef->_textEncoding == TEXT_UTF8) {
WideString wstr = StringUtil::utf8ToWide(_string);
_scValue->setInt(wstr.size());
} else
@@ -358,7 +358,7 @@ ERRORCODE CSXString::scSetProperty(const char *name, CScValue *value) {
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "Capacity") == 0) {
int32 newCap = (uint32)value->getInt();
- if (newCap < (int32)(strlen(_string) + 1)) Game->LOG(0, "Warning: cannot lower string capacity");
+ if (newCap < (int32)(strlen(_string) + 1)) _gameRef->LOG(0, "Warning: cannot lower string capacity");
else if (newCap != _capacity) {
char *newStr = new char[newCap];
if (newStr) {
diff --git a/engines/wintermute/Base/scriptables/ScEngine.cpp b/engines/wintermute/Base/scriptables/ScEngine.cpp
index ea651e69bf..d976707ce2 100644
--- a/engines/wintermute/Base/scriptables/ScEngine.cpp
+++ b/engines/wintermute/Base/scriptables/ScEngine.cpp
@@ -46,25 +46,25 @@ IMPLEMENT_PERSISTENT(CScEngine, true)
#define COMPILER_DLL "dcscomp.dll"
//////////////////////////////////////////////////////////////////////////
CScEngine::CScEngine(CBGame *inGame): CBBase(inGame) {
- Game->LOG(0, "Initializing scripting engine...");
+ _gameRef->LOG(0, "Initializing scripting engine...");
- if (_compilerAvailable) Game->LOG(0, " Script compiler bound successfuly");
- else Game->LOG(0, " Script compiler is NOT available");
+ if (_compilerAvailable) _gameRef->LOG(0, " Script compiler bound successfuly");
+ else _gameRef->LOG(0, " Script compiler is NOT available");
- _globals = new CScValue(Game);
+ _globals = new CScValue(_gameRef);
// register 'Game' as global variable
if (!_globals->propExists("Game")) {
- CScValue val(Game);
- val.setNative(Game, true);
+ CScValue val(_gameRef);
+ val.setNative(_gameRef, true);
_globals->setProp("Game", &val);
}
// register 'Math' as global variable
if (!_globals->propExists("Math")) {
- CScValue val(Game);
- val.setNative(Game->_mathClass, true);
+ CScValue val(_gameRef);
+ val.setNative(_gameRef->_mathClass, true);
_globals->setProp("Math", &val);
}
@@ -82,7 +82,7 @@ CScEngine::CScEngine(CBGame *inGame): CBBase(inGame) {
//////////////////////////////////////////////////////////////////////////
CScEngine::~CScEngine() {
- Game->LOG(0, "Shutting down scripting engine");
+ _gameRef->LOG(0, "Shutting down scripting engine");
saveBreakpoints();
disableProfiling();
@@ -121,8 +121,8 @@ ERRORCODE CScEngine::cleanup() {
//////////////////////////////////////////////////////////////////////////
byte *CScEngine::loadFile(void *data, char *filename, uint32 *size) {
- CBGame *Game = (CBGame *)data;
- return Game->_fileManager->readWholeFile(filename, size);
+ CBGame *gameRef = (CBGame *)data;
+ return gameRef->_fileManager->readWholeFile(filename, size);
}
@@ -147,15 +147,15 @@ CScScript *CScEngine::runScript(const char *filename, CBScriptHolder *owner) {
if (!compBuffer) return NULL;
// add new script
- CScScript *script = new CScScript(Game, this);
+ CScScript *script = new CScScript(_gameRef, this);
ERRORCODE ret = script->create(filename, compBuffer, compSize, owner);
if (DID_FAIL(ret)) {
- Game->LOG(ret, "Error running script '%s'...", filename);
+ _gameRef->LOG(ret, "Error running script '%s'...", filename);
delete script;
return NULL;
} else {
// publish the "self" pseudo-variable
- CScValue val(Game);
+ CScValue val(_gameRef);
if (owner)val.setNative(owner, true);
else val.setNULL();
@@ -163,7 +163,7 @@ CScScript *CScEngine::runScript(const char *filename, CBScriptHolder *owner) {
script->_globals->setProp("this", &val);
_scripts.add(script);
- Game->getDebugMgr()->onScriptInit(script);
+ _gameRef->getDebugMgr()->onScriptInit(script);
return script;
}
@@ -189,9 +189,9 @@ byte *CScEngine::getCompiledScript(const char *filename, uint32 *outSize, bool i
uint32 size;
- byte *buffer = Game->_fileManager->readWholeFile(filename, &size);
+ byte *buffer = _gameRef->_fileManager->readWholeFile(filename, &size);
if (!buffer) {
- Game->LOG(0, "CScEngine::GetCompiledScript - error opening script '%s'", filename);
+ _gameRef->LOG(0, "CScEngine::GetCompiledScript - error opening script '%s'", filename);
return NULL;
}
@@ -201,7 +201,7 @@ byte *CScEngine::getCompiledScript(const char *filename, uint32 *outSize, bool i
compSize = size;
} else {
if (!_compilerAvailable) {
- Game->LOG(0, "CScEngine::GetCompiledScript - script '%s' needs to be compiled but compiler is not available", filename);
+ _gameRef->LOG(0, "CScEngine::GetCompiledScript - script '%s' needs to be compiled but compiler is not available", filename);
delete [] buffer;
return NULL;
}
@@ -256,18 +256,18 @@ ERRORCODE CScEngine::tick() {
case SCRIPT_WAITING: {
/*
bool obj_found=false;
- for(int j=0; j<Game->_regObjects.getSize(); j++)
+ for(int j=0; j<_gameRef->_regObjects.getSize(); j++)
{
- if(Game->_regObjects[j] == _scripts[i]->_waitObject)
+ if(_gameRef->_regObjects[j] == _scripts[i]->_waitObject)
{
- if(Game->_regObjects[j]->IsReady()) _scripts[i]->Run();
+ if(_gameRef->_regObjects[j]->IsReady()) _scripts[i]->Run();
obj_found = true;
break;
}
}
if(!obj_found) _scripts[i]->finish(); // _waitObject no longer exists
*/
- if (Game->validObject(_scripts[i]->_waitObject)) {
+ if (_gameRef->validObject(_scripts[i]->_waitObject)) {
if (_scripts[i]->_waitObject->isReady()) _scripts[i]->run();
} else _scripts[i]->finish();
break;
@@ -277,7 +277,7 @@ ERRORCODE CScEngine::tick() {
if (_scripts[i]->_waitFrozen) {
if (_scripts[i]->_waitTime <= CBPlatform::getTime()) _scripts[i]->run();
} else {
- if (_scripts[i]->_waitTime <= Game->_timer) _scripts[i]->run();
+ if (_scripts[i]->_waitTime <= _gameRef->_timer) _scripts[i]->run();
}
break;
}
@@ -368,7 +368,7 @@ ERRORCODE CScEngine::removeFinishedScripts() {
for (int i = 0; i < _scripts.getSize(); i++) {
if (_scripts[i]->_state == SCRIPT_FINISHED || _scripts[i]->_state == SCRIPT_ERROR) {
if (!_scripts[i]->_thread && _scripts[i]->_owner) _scripts[i]->_owner->removeScript(_scripts[i]);
- Game->getDebugMgr()->onScriptShutdown(_scripts[i]);
+ _gameRef->getDebugMgr()->onScriptShutdown(_scripts[i]);
delete _scripts[i];
_scripts.removeAt(i);
i--;
@@ -427,7 +427,7 @@ ERRORCODE CScEngine::resetObject(CBObject *Object) {
// terminate all scripts waiting for this object
for (int i = 0; i < _scripts.getSize(); i++) {
if (_scripts[i]->_state == SCRIPT_WAITING && _scripts[i]->_waitObject == Object) {
- if (!Game->_compatKillMethodThreads) resetScript(_scripts[i]);
+ if (!_gameRef->_compatKillMethodThreads) resetScript(_scripts[i]);
bool IsThread = _scripts[i]->_methodThread || _scripts[i]->_thread;
_scripts[i]->finish(!IsThread); // 1.9b1 - top-level script kills its threads as well
@@ -451,7 +451,7 @@ ERRORCODE CScEngine::resetScript(CScScript *script) {
ERRORCODE CScEngine::persist(CBPersistMgr *persistMgr) {
if (!persistMgr->_saving) cleanup();
- persistMgr->transfer(TMEMBER(Game));
+ persistMgr->transfer(TMEMBER(_gameRef));
persistMgr->transfer(TMEMBER(_currentScript));
persistMgr->transfer(TMEMBER(_globals));
_scripts.persist(persistMgr);
@@ -527,7 +527,7 @@ ERRORCODE CScEngine::dbgSendScripts(IWmeDebugClient *client) {
//////////////////////////////////////////////////////////////////////////
ERRORCODE CScEngine::addBreakpoint(const char *scriptFilename, int line) {
- if (!Game->getDebugMgr()->_enabled) return STATUS_OK;
+ if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK;
CScBreakpoint *bp = NULL;
for (int i = 0; i < _breakpoints.getSize(); i++) {
@@ -554,7 +554,7 @@ ERRORCODE CScEngine::addBreakpoint(const char *scriptFilename, int line) {
//////////////////////////////////////////////////////////////////////////
ERRORCODE CScEngine::removeBreakpoint(const char *scriptFilename, int line) {
- if (!Game->getDebugMgr()->_enabled) return STATUS_OK;
+ if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK;
for (int i = 0; i < _breakpoints.getSize(); i++) {
if (scumm_stricmp(_breakpoints[i]->_filename.c_str(), scriptFilename) == 0) {
@@ -579,7 +579,7 @@ ERRORCODE CScEngine::removeBreakpoint(const char *scriptFilename, int line) {
//////////////////////////////////////////////////////////////////////////
ERRORCODE CScEngine::refreshScriptBreakpoints() {
- if (!Game->getDebugMgr()->_enabled) return STATUS_OK;
+ if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK;
for (int i = 0; i < _scripts.getSize(); i++) {
refreshScriptBreakpoints(_scripts[i]);
@@ -589,7 +589,7 @@ ERRORCODE CScEngine::refreshScriptBreakpoints() {
//////////////////////////////////////////////////////////////////////////
ERRORCODE CScEngine::refreshScriptBreakpoints(CScScript *script) {
- if (!Game->getDebugMgr()->_enabled) return STATUS_OK;
+ if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK;
if (!script || !script->_filename) return STATUS_FAILED;
@@ -606,7 +606,7 @@ ERRORCODE CScEngine::refreshScriptBreakpoints(CScScript *script) {
//////////////////////////////////////////////////////////////////////////
ERRORCODE CScEngine::saveBreakpoints() {
- if (!Game->getDebugMgr()->_enabled) return STATUS_OK;
+ if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK;
char text[512];
@@ -619,25 +619,25 @@ ERRORCODE CScEngine::saveBreakpoints() {
sprintf(key, "Breakpoint%d", count);
sprintf(text, "%s:%d", _breakpoints[i]->_filename.c_str(), _breakpoints[i]->_lines[j]);
- Game->_registry->writeString("Debug", key, text);
+ _gameRef->_registry->writeString("Debug", key, text);
}
}
- Game->_registry->writeInt("Debug", "NumBreakpoints", count);
+ _gameRef->_registry->writeInt("Debug", "NumBreakpoints", count);
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
ERRORCODE CScEngine::loadBreakpoints() {
- if (!Game->getDebugMgr()->_enabled) return STATUS_OK;
+ if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK;
char key[100];
- int count = Game->_registry->readInt("Debug", "NumBreakpoints", 0);
+ int count = _gameRef->_registry->readInt("Debug", "NumBreakpoints", 0);
for (int i = 1; i <= count; i++) {
/* uint32 BufSize = 512; */
sprintf(key, "Breakpoint%d", i);
- AnsiString breakpoint = Game->_registry->readString("Debug", key, "");
+ AnsiString breakpoint = _gameRef->_registry->readString("Debug", key, "");
char *path = CBUtils::strEntry(0, breakpoint.c_str(), ':');
char *line = CBUtils::strEntry(1, breakpoint.c_str(), ':');
@@ -701,11 +701,11 @@ void CScEngine::dumpStats() {
TimeVector::reverse_iterator tit;
- Game->LOG(0, "***** Script profiling information: *****");
- Game->LOG(0, " %-40s %fs", "Total execution time", (float)totalTime / 1000);
+ _gameRef->LOG(0, "***** Script profiling information: *****");
+ _gameRef->LOG(0, " %-40s %fs", "Total execution time", (float)totalTime / 1000);
for (tit = times.rbegin(); tit != times.rend(); tit++) {
- Game->LOG(0, " %-40s %fs (%f%%)", tit->second.c_str(), (float)tit->first / 1000, (float)tit->first / (float)totalTime * 100);
+ _gameRef->LOG(0, " %-40s %fs (%f%%)", tit->second.c_str(), (float)tit->first / 1000, (float)tit->first / (float)totalTime * 100);
}*/
}
diff --git a/engines/wintermute/Base/scriptables/ScScript.cpp b/engines/wintermute/Base/scriptables/ScScript.cpp
index 40803cded6..e1cf791e31 100644
--- a/engines/wintermute/Base/scriptables/ScScript.cpp
+++ b/engines/wintermute/Base/scriptables/ScScript.cpp
@@ -125,13 +125,13 @@ ERRORCODE CScScript::initScript() {
readHeader();
if (_header.magic != SCRIPT_MAGIC) {
- Game->LOG(0, "File '%s' is not a valid compiled script", _filename);
+ _gameRef->LOG(0, "File '%s' is not a valid compiled script", _filename);
cleanup();
return STATUS_FAILED;
}
if (_header.version > SCRIPT_VERSION) {
- Game->LOG(0, "Script '%s' has a wrong version %d.%d (expected %d.%d)", _filename, _header.version / 256, _header.version % 256, SCRIPT_VERSION / 256, SCRIPT_VERSION % 256);
+ _gameRef->LOG(0, "Script '%s' has a wrong version %d.%d (expected %d.%d)", _filename, _header.version / 256, _header.version % 256, SCRIPT_VERSION / 256, SCRIPT_VERSION % 256);
cleanup();
return STATUS_FAILED;
}
@@ -139,13 +139,13 @@ ERRORCODE CScScript::initScript() {
initTables();
// init stacks
- _scopeStack = new CScStack(Game);
- _callStack = new CScStack(Game);
- _thisStack = new CScStack(Game);
- _stack = new CScStack(Game);
+ _scopeStack = new CScStack(_gameRef);
+ _callStack = new CScStack(_gameRef);
+ _thisStack = new CScStack(_gameRef);
+ _stack = new CScStack(_gameRef);
- _operand = new CScValue(Game);
- _reg1 = new CScValue(Game);
+ _operand = new CScValue(_gameRef);
+ _reg1 = new CScValue(_gameRef);
// skip to the beginning
@@ -263,7 +263,7 @@ ERRORCODE CScScript::create(const char *filename, byte *buffer, uint32 size, CBS
if (DID_FAIL(res)) return res;
// establish global variables table
- _globals = new CScValue(Game);
+ _globals = new CScValue(_gameRef);
_owner = owner;
@@ -476,7 +476,7 @@ ERRORCODE CScScript::executeInstruction() {
uint32 dw;
const char *str = NULL;
- //CScValue* op = new CScValue(Game);
+ //CScValue* op = new CScValue(_gameRef);
_operand->cleanup();
CScValue *op1;
@@ -490,12 +490,12 @@ ERRORCODE CScScript::executeInstruction() {
dw = getDWORD();
if (_scopeStack->_sP < 0) {
_globals->setProp(_symbols[dw], _operand);
- if (Game->getDebugMgr()->_enabled)
- Game->getDebugMgr()->onVariableInit(WME_DBGVAR_SCRIPT, this, NULL, _globals->getProp(_symbols[dw]), _symbols[dw]);
+ if (_gameRef->getDebugMgr()->_enabled)
+ _gameRef->getDebugMgr()->onVariableInit(WME_DBGVAR_SCRIPT, this, NULL, _globals->getProp(_symbols[dw]), _symbols[dw]);
} else {
_scopeStack->getTop()->setProp(_symbols[dw], _operand);
- if (Game->getDebugMgr()->_enabled)
- Game->getDebugMgr()->onVariableInit(WME_DBGVAR_SCOPE, this, _scopeStack->getTop(), _scopeStack->getTop()->getProp(_symbols[dw]), _symbols[dw]);
+ if (_gameRef->getDebugMgr()->_enabled)
+ _gameRef->getDebugMgr()->onVariableInit(WME_DBGVAR_SCOPE, this, _scopeStack->getTop(), _scopeStack->getTop()->getProp(_symbols[dw]), _symbols[dw]);
}
break;
@@ -509,21 +509,21 @@ ERRORCODE CScScript::executeInstruction() {
_operand->setNULL();
_engine->_globals->setProp(_symbols[dw], _operand, false, inst == II_DEF_CONST_VAR);
- if (Game->getDebugMgr()->_enabled)
- Game->getDebugMgr()->onVariableInit(WME_DBGVAR_GLOBAL, this, NULL, _engine->_globals->getProp(_symbols[dw]), _symbols[dw]);
+ if (_gameRef->getDebugMgr()->_enabled)
+ _gameRef->getDebugMgr()->onVariableInit(WME_DBGVAR_GLOBAL, this, NULL, _engine->_globals->getProp(_symbols[dw]), _symbols[dw]);
}
break;
}
case II_RET:
if (_scopeStack->_sP >= 0 && _callStack->_sP >= 0) {
- Game->getDebugMgr()->onScriptShutdownScope(this, _scopeStack->getTop());
+ _gameRef->getDebugMgr()->onScriptShutdownScope(this, _scopeStack->getTop());
_scopeStack->pop();
_iP = (uint32)_callStack->pop()->getInt();
- if (_scopeStack->_sP < 0) Game->getDebugMgr()->onScriptChangeScope(this, NULL);
- else Game->getDebugMgr()->onScriptChangeScope(this, _scopeStack->getTop());
+ if (_scopeStack->_sP < 0) _gameRef->getDebugMgr()->onScriptChangeScope(this, NULL);
+ else _gameRef->getDebugMgr()->onScriptChangeScope(this, _scopeStack->getTop());
} else {
if (_thread) {
_state = SCRIPT_THREAD_FINISHED;
@@ -601,7 +601,7 @@ ERRORCODE CScScript::executeInstruction() {
}
else{
// not an internal nor external, try for native function
- Game->ExternalCall(this, _stack, _thisStack, val->getString());
+ _gameRef->ExternalCall(this, _stack, _thisStack, val->getString());
}
}
else{
@@ -632,7 +632,7 @@ ERRORCODE CScScript::executeInstruction() {
TExternalFunction *f = getExternal(_symbols[SymbolIndex]);
if (f) {
externalCall(_stack, _thisStack, f);
- } else Game->ExternalCall(this, _stack, _thisStack, _symbols[SymbolIndex]);
+ } else _gameRef->ExternalCall(this, _stack, _thisStack, _symbols[SymbolIndex]);
break;
}
@@ -640,8 +640,8 @@ ERRORCODE CScScript::executeInstruction() {
_operand->setNULL();
_scopeStack->push(_operand);
- if (_scopeStack->_sP < 0) Game->getDebugMgr()->onScriptChangeScope(this, NULL);
- else Game->getDebugMgr()->onScriptChangeScope(this, _scopeStack->getTop());
+ if (_scopeStack->_sP < 0) _gameRef->getDebugMgr()->onScriptChangeScope(this, NULL);
+ else _gameRef->getDebugMgr()->onScriptChangeScope(this, _scopeStack->getTop());
break;
@@ -691,8 +691,8 @@ ERRORCODE CScScript::executeInstruction() {
}
}
- if (Game->getDebugMgr()->_enabled)
- Game->getDebugMgr()->onVariableChangeValue(var, val);
+ if (_gameRef->getDebugMgr()->_enabled)
+ _gameRef->getDebugMgr()->onVariableChangeValue(var, val);
}
break;
@@ -757,8 +757,8 @@ ERRORCODE CScScript::executeInstruction() {
var->setNULL();
} else var->setProp(str, val);
- if (Game->getDebugMgr()->_enabled)
- Game->getDebugMgr()->onVariableChangeValue(var, NULL);
+ if (_gameRef->getDebugMgr()->_enabled)
+ _gameRef->getDebugMgr()->onVariableChangeValue(var, NULL);
break;
}
@@ -1027,17 +1027,17 @@ ERRORCODE CScScript::executeInstruction() {
int newLine = getDWORD();
if (newLine != _currentLine) {
_currentLine = newLine;
- if (Game->getDebugMgr()->_enabled) {
- Game->getDebugMgr()->onScriptChangeLine(this, _currentLine);
+ if (_gameRef->getDebugMgr()->_enabled) {
+ _gameRef->getDebugMgr()->onScriptChangeLine(this, _currentLine);
for (int i = 0; i < _breakpoints.getSize(); i++) {
if (_breakpoints[i] == _currentLine) {
- Game->getDebugMgr()->onScriptHitBreakpoint(this);
+ _gameRef->getDebugMgr()->onScriptHitBreakpoint(this);
sleep(0);
break;
}
}
if (_tracingMode) {
- Game->getDebugMgr()->onScriptHitBreakpoint(this);
+ _gameRef->getDebugMgr()->onScriptHitBreakpoint(this);
sleep(0);
break;
}
@@ -1047,7 +1047,7 @@ ERRORCODE CScScript::executeInstruction() {
}
default:
- Game->LOG(0, "Fatal: Invalid instruction %d ('%s', line %d, IP:0x%x)\n", inst, _filename, _currentLine, _iP - sizeof(uint32));
+ _gameRef->LOG(0, "Fatal: Invalid instruction %d ('%s', line %d, IP:0x%x)\n", inst, _filename, _currentLine, _iP - sizeof(uint32));
_state = SCRIPT_FINISHED;
ret = STATUS_FAILED;
} // switch(instruction)
@@ -1102,8 +1102,8 @@ CScValue *CScScript::getVar(char *name) {
if (ret == NULL) {
//RuntimeError("Variable '%s' is inaccessible in the current block. Consider changing the script.", name);
- Game->LOG(0, "Warning: variable '%s' is inaccessible in the current block. Consider changing the script (script:%s, line:%d)", name, _filename, _currentLine);
- CScValue *val = new CScValue(Game);
+ _gameRef->LOG(0, "Warning: variable '%s' is inaccessible in the current block. Consider changing the script (script:%s, line:%d)", name, _filename, _currentLine);
+ CScValue *val = new CScValue(_gameRef);
CScValue *scope = _scopeStack->getTop();
if (scope) {
scope->setProp(name, val);
@@ -1147,11 +1147,11 @@ ERRORCODE CScScript::sleep(uint32 duration) {
}
_state = SCRIPT_SLEEPING;
- if (Game->_state == GAME_FROZEN) {
+ if (_gameRef->_state == GAME_FROZEN) {
_waitTime = CBPlatform::getTime() + duration;
_waitFrozen = true;
} else {
- _waitTime = Game->_timer + duration;
+ _waitTime = _gameRef->_timer + duration;
_waitFrozen = false;
}
return STATUS_OK;
@@ -1186,18 +1186,18 @@ void CScScript::runtimeError(const char *fmt, ...) {
vsprintf(buff, fmt, va);
va_end(va);
- Game->LOG(0, "Runtime error. Script '%s', line %d", _filename, _currentLine);
- Game->LOG(0, " %s", buff);
+ _gameRef->LOG(0, "Runtime error. Script '%s', line %d", _filename, _currentLine);
+ _gameRef->LOG(0, " %s", buff);
- if (!Game->_suppressScriptErrors)
- Game->quickMessage("Script runtime error. View log for details.");
+ if (!_gameRef->_suppressScriptErrors)
+ _gameRef->quickMessage("Script runtime error. View log for details.");
}
//////////////////////////////////////////////////////////////////////////
ERRORCODE CScScript::persist(CBPersistMgr *persistMgr) {
- persistMgr->transfer(TMEMBER(Game));
+ persistMgr->transfer(TMEMBER(_gameRef));
// buffer
if (persistMgr->_saving) {
@@ -1263,13 +1263,13 @@ CScScript *CScScript::invokeEventHandler(const char *eventName, bool unbreakable
uint32 pos = getEventPos(eventName);
if (!pos) return NULL;
- CScScript *thread = new CScScript(Game, _engine);
+ CScScript *thread = new CScScript(_gameRef, _engine);
if (thread) {
ERRORCODE ret = thread->createThread(this, pos, eventName);
if (DID_SUCCEED(ret)) {
thread->_unbreakable = unbreakable;
_engine->_scripts.add(thread);
- Game->getDebugMgr()->onScriptEventThreadInit(thread, this, eventName);
+ _gameRef->getDebugMgr()->onScriptEventThreadInit(thread, this, eventName);
return thread;
} else {
delete thread;
@@ -1304,7 +1304,7 @@ bool CScScript::canHandleMethod(const char *methodName) {
//////////////////////////////////////////////////////////////////////////
ERRORCODE CScScript::pause() {
if (_state == SCRIPT_PAUSED) {
- Game->LOG(0, "Attempting to pause a paused script ('%s', line %d)", _filename, _currentLine);
+ _gameRef->LOG(0, "Attempting to pause a paused script ('%s', line %d)", _filename, _currentLine);
return STATUS_FAILED;
}
@@ -1339,7 +1339,7 @@ CScScript::TExternalFunction *CScScript::getExternal(char *name) {
//////////////////////////////////////////////////////////////////////////
ERRORCODE CScScript::externalCall(CScStack *stack, CScStack *thisStack, CScScript::TExternalFunction *function) {
- Game->LOG(0, "External functions are not supported on this platform.");
+ _gameRef->LOG(0, "External functions are not supported on this platform.");
stack->correctParams(0);
stack->pushNULL();
return STATUS_FAILED;
@@ -1443,7 +1443,7 @@ void CScScript::afterLoad() {
if (_buffer == NULL) {
byte *buffer = _engine->getCompiledScript(_filename, &_bufferSize);
if (!buffer) {
- Game->LOG(0, "Error reinitializing script '%s' after load. Script will be terminated.", _filename);
+ _gameRef->LOG(0, "Error reinitializing script '%s' after load. Script will be terminated.", _filename);
_state = SCRIPT_ERROR;
return;
}
diff --git a/engines/wintermute/Base/scriptables/ScStack.cpp b/engines/wintermute/Base/scriptables/ScStack.cpp
index 33fe9f44e8..c889b5ea9e 100644
--- a/engines/wintermute/Base/scriptables/ScStack.cpp
+++ b/engines/wintermute/Base/scriptables/ScStack.cpp
@@ -44,7 +44,7 @@ CScStack::CScStack(CBGame *inGame): CBBase(inGame) {
CScStack::~CScStack() {
#if _DEBUG
- //Game->LOG(0, "STAT: Stack size: %d, SP=%d", _values.getSize(), _sP);
+ //_gameRef->LOG(0, "STAT: Stack size: %d, SP=%d", _values.getSize(), _sP);
#endif
for (int i = 0; i < _values.getSize(); i++) {
@@ -57,7 +57,7 @@ CScStack::~CScStack() {
//////////////////////////////////////////////////////////////////////////
CScValue *CScStack::pop() {
if (_sP < 0) {
- Game->LOG(0, "Fatal: Stack underflow");
+ _gameRef->LOG(0, "Fatal: Stack underflow");
return NULL;
}
@@ -73,7 +73,7 @@ void CScStack::push(CScValue *val) {
_values[_sP]->cleanup();
_values[_sP]->copy(val);
} else {
- CScValue *copyVal = new CScValue(Game);
+ CScValue *copyVal = new CScValue(_gameRef);
copyVal->copy(val);
_values.add(copyVal);
}
@@ -85,7 +85,7 @@ CScValue *CScStack::getPushValue() {
_sP++;
if (_sP >= _values.getSize()) {
- CScValue *val = new CScValue(Game);
+ CScValue *val = new CScValue(_gameRef);
_values.add(val);
}
_values[_sP]->cleanup();
@@ -124,7 +124,7 @@ void CScStack::correctParams(uint32 expectedParams) {
} else if (expectedParams > nuParams) { // need more params
while (expectedParams > nuParams) {
//Push(null_val);
- CScValue *nullVal = new CScValue(Game);
+ CScValue *nullVal = new CScValue(_gameRef);
nullVal->setNULL();
_values.insertAt(_sP - nuParams + 1, nullVal);
nuParams++;
@@ -142,7 +142,7 @@ void CScStack::correctParams(uint32 expectedParams) {
//////////////////////////////////////////////////////////////////////////
void CScStack::pushNULL() {
/*
- CScValue* val = new CScValue(Game);
+ CScValue* val = new CScValue(_gameRef);
val->setNULL();
Push(val);
delete val;
@@ -154,7 +154,7 @@ void CScStack::pushNULL() {
//////////////////////////////////////////////////////////////////////////
void CScStack::pushInt(int val) {
/*
- CScValue* val = new CScValue(Game);
+ CScValue* val = new CScValue(_gameRef);
val->setInt(Val);
Push(val);
delete val;
@@ -166,7 +166,7 @@ void CScStack::pushInt(int val) {
//////////////////////////////////////////////////////////////////////////
void CScStack::pushFloat(double val) {
/*
- CScValue* val = new CScValue(Game);
+ CScValue* val = new CScValue(_gameRef);
val->setFloat(Val);
Push(val);
delete val;
@@ -178,7 +178,7 @@ void CScStack::pushFloat(double val) {
//////////////////////////////////////////////////////////////////////////
void CScStack::pushBool(bool val) {
/*
- CScValue* val = new CScValue(Game);
+ CScValue* val = new CScValue(_gameRef);
val->setBool(Val);
Push(val);
delete val;
@@ -190,7 +190,7 @@ void CScStack::pushBool(bool val) {
//////////////////////////////////////////////////////////////////////////
void CScStack::pushString(const char *val) {
/*
- CScValue* val = new CScValue(Game);
+ CScValue* val = new CScValue(_gameRef);
val->setString(Val);
Push(val);
delete val;
@@ -202,7 +202,7 @@ void CScStack::pushString(const char *val) {
//////////////////////////////////////////////////////////////////////////
void CScStack::pushNative(CBScriptable *val, bool persistent) {
/*
- CScValue* val = new CScValue(Game);
+ CScValue* val = new CScValue(_gameRef);
val->setNative(Val, Persistent);
Push(val);
delete val;
@@ -215,7 +215,7 @@ void CScStack::pushNative(CBScriptable *val, bool persistent) {
//////////////////////////////////////////////////////////////////////////
ERRORCODE CScStack::persist(CBPersistMgr *persistMgr) {
- persistMgr->transfer(TMEMBER(Game));
+ persistMgr->transfer(TMEMBER(_gameRef));
persistMgr->transfer(TMEMBER(_sP));
_values.persist(persistMgr);
diff --git a/engines/wintermute/Base/scriptables/ScValue.cpp b/engines/wintermute/Base/scriptables/ScValue.cpp
index ba698fdd8d..2c5f388c3d 100644
--- a/engines/wintermute/Base/scriptables/ScValue.cpp
+++ b/engines/wintermute/Base/scriptables/ScValue.cpp
@@ -160,20 +160,20 @@ CScValue *CScValue::getProp(const char *name) {
if (_type == VAL_VARIABLE_REF) return _valRef->getProp(name);
if (_type == VAL_STRING && strcmp(name, "Length") == 0) {
- Game->_scValue->_type = VAL_INT;
+ _gameRef->_scValue->_type = VAL_INT;
#if 0 // TODO: Remove FreeType-dependency
- if (Game->_textEncoding == TEXT_ANSI) {
+ if (_gameRef->_textEncoding == TEXT_ANSI) {
#else
if (true) {
#endif
- Game->_scValue->setInt(strlen(_valString));
+ _gameRef->_scValue->setInt(strlen(_valString));
} else {
WideString wstr = StringUtil::utf8ToWide(_valString);
- Game->_scValue->setInt(wstr.size());
+ _gameRef->_scValue->setInt(wstr.size());
}
- return Game->_scValue;
+ return _gameRef->_scValue;
}
CScValue *ret = NULL;
@@ -220,7 +220,7 @@ ERRORCODE CScValue::setProp(const char *name, CScValue *val, bool copyWhole, boo
newVal = _valIter->_value;
}
if (!newVal)
- newVal = new CScValue(Game);
+ newVal = new CScValue(_gameRef);
else newVal->cleanup();
newVal->copy(val, copyWhole);
@@ -235,7 +235,7 @@ ERRORCODE CScValue::setProp(const char *name, CScValue *val, bool copyWhole, boo
delete _valIter->_value;
_valIter->_value = NULL;
}
- CScValue* val = new CScValue(Game);
+ CScValue* val = new CScValue(_gameRef);
val->Copy(Val, CopyWhole);
val->_isConstVar = SetAsConst;
_valObject[Name] = val;
@@ -663,7 +663,7 @@ TValType CScValue::getType() {
//////////////////////////////////////////////////////////////////////////
void CScValue::copy(CScValue *orig, bool copyWhole) {
- Game = orig->Game;
+ _gameRef = orig->_gameRef;
if (_valNative && !_persistent) {
_valNative->_refCount--;
@@ -694,7 +694,7 @@ void CScValue::copy(CScValue *orig, bool copyWhole) {
if (orig->_type == VAL_OBJECT && orig->_valObject.size() > 0) {
orig->_valIter = orig->_valObject.begin();
while (orig->_valIter != orig->_valObject.end()) {
- _valObject[orig->_valIter->_key] = new CScValue(Game);
+ _valObject[orig->_valIter->_key] = new CScValue(_gameRef);
_valObject[orig->_valIter->_key]->copy(orig->_valIter->_value);
orig->_valIter++;
}
@@ -736,7 +736,7 @@ void CScValue::setValue(CScValue *val) {
//////////////////////////////////////////////////////////////////////////
ERRORCODE CScValue::persist(CBPersistMgr *persistMgr) {
- persistMgr->transfer(TMEMBER(Game));
+ persistMgr->transfer(TMEMBER(_gameRef));
persistMgr->transfer(TMEMBER(_persistent));
persistMgr->transfer(TMEMBER(_isConstVar));
@@ -890,7 +890,7 @@ ERRORCODE CScValue::dbgSendVariables(IWmeDebugClient *client, EWmeDebuggerVariab
//////////////////////////////////////////////////////////////////////////
bool CScValue::setProperty(const char *propName, int value) {
- CScValue *val = new CScValue(Game, value);
+ CScValue *val = new CScValue(_gameRef, value);
bool ret = DID_SUCCEED(setProp(propName, val));
delete val;
return ret;
@@ -898,7 +898,7 @@ bool CScValue::setProperty(const char *propName, int value) {
//////////////////////////////////////////////////////////////////////////
bool CScValue::setProperty(const char *propName, const char *value) {
- CScValue *val = new CScValue(Game, value);
+ CScValue *val = new CScValue(_gameRef, value);
bool ret = DID_SUCCEED(setProp(propName, val));
delete val;
return ret;
@@ -906,7 +906,7 @@ bool CScValue::setProperty(const char *propName, const char *value) {
//////////////////////////////////////////////////////////////////////////
bool CScValue::setProperty(const char *propName, double value) {
- CScValue *val = new CScValue(Game, value);
+ CScValue *val = new CScValue(_gameRef, value);
bool ret = DID_SUCCEED(setProp(propName, val));
delete val;
return ret;
@@ -915,7 +915,7 @@ bool CScValue::setProperty(const char *propName, double value) {
//////////////////////////////////////////////////////////////////////////
bool CScValue::setProperty(const char *propName, bool value) {
- CScValue *val = new CScValue(Game, value);
+ CScValue *val = new CScValue(_gameRef, value);
bool ret = DID_SUCCEED(setProp(propName, val));
delete val;
return ret;
@@ -924,7 +924,7 @@ bool CScValue::setProperty(const char *propName, bool value) {
//////////////////////////////////////////////////////////////////////////
bool CScValue::setProperty(const char *propName) {
- CScValue *val = new CScValue(Game);
+ CScValue *val = new CScValue(_gameRef);
bool ret = DID_SUCCEED(setProp(propName, val));
delete val;
return ret;