diff options
author | Einar Johan Trøan Sømåen | 2012-07-18 18:25:09 +0200 |
---|---|---|
committer | Einar Johan Trøan Sømåen | 2012-07-18 18:25:09 +0200 |
commit | 301af17d4c8b7746fde6592dce558d968753c3f0 (patch) | |
tree | 3ab2cbedb1288f1e7b84f8fcccccc4dbeb9cc1bb /engines | |
parent | 23c9bff22637c5bb1e3c3caf93adab7088a2e711 (diff) | |
download | scummvm-rg350-301af17d4c8b7746fde6592dce558d968753c3f0.tar.gz scummvm-rg350-301af17d4c8b7746fde6592dce558d968753c3f0.tar.bz2 scummvm-rg350-301af17d4c8b7746fde6592dce558d968753c3f0.zip |
WINTERMUTE: Rename the Game-variable to _gameRef/gameRef
Diffstat (limited to 'engines')
84 files changed, 1343 insertions, 1343 deletions
diff --git a/engines/wintermute/Ad/AdActor.cpp b/engines/wintermute/Ad/AdActor.cpp index 16ea49f6ff..55a8ac8443 100644 --- a/engines/wintermute/Ad/AdActor.cpp +++ b/engines/wintermute/Ad/AdActor.cpp @@ -57,7 +57,7 @@ IMPLEMENT_PERSISTENT(CAdActor, false) //////////////////////////////////////////////////////////////////////////
CAdActor::CAdActor(CBGame *inGame): CAdTalkHolder(inGame) {
- _path = new CAdPath(Game);
+ _path = new CAdPath(_gameRef);
_type = OBJECT_ACTOR;
_dir = DI_LEFT;
@@ -124,9 +124,9 @@ CAdActor::~CAdActor() { //////////////////////////////////////////////////////////////////////////
ERRORCODE CAdActor::loadFile(const char *filename) {
- byte *buffer = Game->_fileManager->readWholeFile(filename);
+ byte *buffer = _gameRef->_fileManager->readWholeFile(filename);
if (buffer == NULL) {
- Game->LOG(0, "CAdActor::LoadFile failed for file '%s'", filename);
+ _gameRef->LOG(0, "CAdActor::LoadFile failed for file '%s'", filename);
return STATUS_FAILED;
}
@@ -135,7 +135,7 @@ ERRORCODE CAdActor::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 ACTOR file '%s'", filename);
+ if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing ACTOR file '%s'", filename);
delete [] buffer;
@@ -225,17 +225,17 @@ ERRORCODE CAdActor::loadBuffer(byte *buffer, bool complete) { byte *params;
int cmd;
- CBParser parser(Game);
+ CBParser parser(_gameRef);
if (complete) {
if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ACTOR) {
- Game->LOG(0, "'ACTOR' keyword expected.");
+ _gameRef->LOG(0, "'ACTOR' keyword expected.");
return STATUS_FAILED;
}
buffer = params;
}
- CAdGame *adGame = (CAdGame *)Game;
+ CAdGame *adGame = (CAdGame *)_gameRef;
CAdSpriteSet *spr = NULL;
int ar = 0, ag = 0, ab = 0, alpha = 0;
while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) {
@@ -290,19 +290,19 @@ ERRORCODE CAdActor::loadBuffer(byte *buffer, bool complete) { case TOKEN_WALK:
delete _walkSprite;
_walkSprite = NULL;
- spr = new CAdSpriteSet(Game, this);
+ spr = new CAdSpriteSet(_gameRef, this);
if (!spr || DID_FAIL(spr->loadBuffer(params, true, adGame->_texWalkLifeTime, CACHE_HALF))) cmd = PARSERR_GENERIC;
else _walkSprite = spr;
break;
case TOKEN_TALK:
- spr = new CAdSpriteSet(Game, this);
+ spr = new CAdSpriteSet(_gameRef, this);
if (!spr || DID_FAIL(spr->loadBuffer(params, true, adGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC;
else _talkSprites.add(spr);
break;
case TOKEN_TALK_SPECIAL:
- spr = new CAdSpriteSet(Game, this);
+ spr = new CAdSpriteSet(_gameRef, this);
if (!spr || DID_FAIL(spr->loadBuffer(params, true, adGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC;
else _talkSpritesEx.add(spr);
break;
@@ -310,7 +310,7 @@ ERRORCODE CAdActor::loadBuffer(byte *buffer, bool complete) { case TOKEN_STAND:
delete _standSprite;
_standSprite = NULL;
- spr = new CAdSpriteSet(Game, this);
+ spr = new CAdSpriteSet(_gameRef, this);
if (!spr || DID_FAIL(spr->loadBuffer(params, true, adGame->_texStandLifeTime))) cmd = PARSERR_GENERIC;
else _standSprite = spr;
break;
@@ -318,7 +318,7 @@ ERRORCODE CAdActor::loadBuffer(byte *buffer, bool complete) { case TOKEN_TURN_LEFT:
delete _turnLeftSprite;
_turnLeftSprite = NULL;
- spr = new CAdSpriteSet(Game, this);
+ spr = new CAdSpriteSet(_gameRef, this);
if (!spr || DID_FAIL(spr->loadBuffer(params, true))) cmd = PARSERR_GENERIC;
else _turnLeftSprite = spr;
break;
@@ -326,7 +326,7 @@ ERRORCODE CAdActor::loadBuffer(byte *buffer, bool complete) { case TOKEN_TURN_RIGHT:
delete _turnRightSprite;
_turnRightSprite = NULL;
- spr = new CAdSpriteSet(Game, this);
+ spr = new CAdSpriteSet(_gameRef, this);
if (!spr || DID_FAIL(spr->loadBuffer(params, true))) cmd = PARSERR_GENERIC;
else _turnRightSprite = spr;
break;
@@ -337,7 +337,7 @@ ERRORCODE CAdActor::loadBuffer(byte *buffer, bool complete) { 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;
@@ -378,8 +378,8 @@ ERRORCODE CAdActor::loadBuffer(byte *buffer, bool complete) { delete _currentBlockRegion;
_blockRegion = NULL;
_currentBlockRegion = NULL;
- CBRegion *rgn = new CBRegion(Game);
- CBRegion *crgn = new CBRegion(Game);
+ CBRegion *rgn = new CBRegion(_gameRef);
+ CBRegion *crgn = new CBRegion(_gameRef);
if (!rgn || !crgn || DID_FAIL(rgn->loadBuffer(params, false))) {
delete _blockRegion;
delete _currentBlockRegion;
@@ -399,8 +399,8 @@ ERRORCODE CAdActor::loadBuffer(byte *buffer, bool complete) { delete _currentWptGroup;
_wptGroup = NULL;
_currentWptGroup = NULL;
- CAdWaypointGroup *wpt = new CAdWaypointGroup(Game);
- CAdWaypointGroup *cwpt = new CAdWaypointGroup(Game);
+ CAdWaypointGroup *wpt = new CAdWaypointGroup(_gameRef);
+ CAdWaypointGroup *cwpt = new CAdWaypointGroup(_gameRef);
if (!wpt || !cwpt || DID_FAIL(wpt->loadBuffer(params, false))) {
delete _wptGroup;
delete _currentWptGroup;
@@ -432,7 +432,7 @@ ERRORCODE CAdActor::loadBuffer(byte *buffer, bool complete) { break;
case TOKEN_ANIMATION: {
- CAdSpriteSet *Anim = new CAdSpriteSet(Game, this);
+ CAdSpriteSet *Anim = new CAdSpriteSet(_gameRef, this);
if (!Anim || DID_FAIL(Anim->loadBuffer(params, false))) cmd = PARSERR_GENERIC;
else _anims.add(Anim);
}
@@ -440,12 +440,12 @@ ERRORCODE CAdActor::loadBuffer(byte *buffer, bool complete) { }
}
if (cmd == PARSERR_TOKENNOTFOUND) {
- Game->LOG(0, "Syntax error in ACTOR definition");
+ _gameRef->LOG(0, "Syntax error in ACTOR definition");
return STATUS_FAILED;
}
if (cmd == PARSERR_GENERIC) {
if (spr) delete spr;
- Game->LOG(0, "Error loading ACTOR definition");
+ _gameRef->LOG(0, "Error loading ACTOR definition");
return STATUS_FAILED;
}
@@ -496,7 +496,7 @@ void CAdActor::goTo(int x, int y, TDirection afterWalkDir) { _targetPoint->x = x;
_targetPoint->y = y;
- ((CAdGame *)Game)->_scene->correctTargetPoint(_posX, _posY, &_targetPoint->x, &_targetPoint->y, true, this);
+ ((CAdGame *)_gameRef)->_scene->correctTargetPoint(_posX, _posY, &_targetPoint->x, &_targetPoint->y, true, this);
_state = STATE_SEARCHING_PATH;
@@ -509,7 +509,7 @@ ERRORCODE CAdActor::display() { uint32 alpha;
if (_alphaColor != 0) alpha = _alphaColor;
- else alpha = _shadowable ? ((CAdGame *)Game)->_scene->getAlphaAt(_posX, _posY, true) : 0xFFFFFFFF;
+ else alpha = _shadowable ? ((CAdGame *)_gameRef)->_scene->getAlphaAt(_posX, _posY, true) : 0xFFFFFFFF;
float scaleX, scaleY;
getScale(&scaleX, &scaleY);
@@ -518,14 +518,14 @@ ERRORCODE CAdActor::display() { float rotate;
if (_rotatable) {
if (_rotateValid) rotate = _rotate;
- else rotate = ((CAdGame *)Game)->_scene->getRotationAt(_posX, _posY) + _relativeRotate;
+ else rotate = ((CAdGame *)_gameRef)->_scene->getRotationAt(_posX, _posY) + _relativeRotate;
} else rotate = 0.0f;
if (_active) displaySpriteAttachments(true);
if (_currentSprite && _active) {
bool reg = _registrable;
- if (_ignoreItems && ((CAdGame *)Game)->_selectedItem) reg = false;
+ if (_ignoreItems && ((CAdGame *)_gameRef)->_selectedItem) reg = false;
_currentSprite->display(_posX,
_posY,
@@ -661,7 +661,7 @@ ERRORCODE CAdActor::update() { //////////////////////////////////////////////////////////////////////////
case STATE_SEARCHING_PATH:
// keep asking scene for the path
- if (((CAdGame *)Game)->_scene->getPath(CBPoint(_posX, _posY), *_targetPoint, _path, this))
+ if (((CAdGame *)_gameRef)->_scene->getPath(CBPoint(_posX, _posY), *_targetPoint, _path, this))
_state = STATE_WAITING_PATH;
break;
@@ -684,7 +684,7 @@ ERRORCODE CAdActor::update() { _sentence->update(_dir);
if (_sentence->_currentSprite) _tempSprite2 = _sentence->_currentSprite;
- bool TimeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->isPlaying() && !_sentence->_sound->isPaused())) || (!_sentence->_sound && _sentence->_duration <= Game->_timer - _sentence->_startTime);
+ bool TimeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->isPlaying() && !_sentence->_sound->isPaused())) || (!_sentence->_sound && _sentence->_duration <= _gameRef->_timer - _sentence->_startTime);
if (_tempSprite2 == NULL || _tempSprite2->_finished || (/*_tempSprite2->_looping &&*/ TimeIsUp)) {
if (TimeIsUp) {
_sentence->finish();
@@ -696,12 +696,12 @@ ERRORCODE CAdActor::update() { if (_tempSprite2) {
_tempSprite2->reset();
_currentSprite = _tempSprite2;
- ((CAdGame *)Game)->addSentence(_sentence);
+ ((CAdGame *)_gameRef)->addSentence(_sentence);
}
}
} else {
_currentSprite = _tempSprite2;
- ((CAdGame *)Game)->addSentence(_sentence);
+ ((CAdGame *)_gameRef)->addSentence(_sentence);
}
}
break;
@@ -726,7 +726,7 @@ ERRORCODE CAdActor::update() { if (_currentSprite && !already_moved) {
- _currentSprite->GetCurrentFrame(_zoomable ? ((CAdGame *)Game)->_scene->getZoomAt(_posX, _posY) : 100, _zoomable ? ((CAdGame *)Game)->_scene->getZoomAt(_posX, _posY) : 100);
+ _currentSprite->GetCurrentFrame(_zoomable ? ((CAdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) : 100, _zoomable ? ((CAdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) : 100);
if (_currentSprite->_changed) {
_posX += _currentSprite->_moveX;
_posY += _currentSprite->_moveY;
@@ -734,7 +734,7 @@ ERRORCODE CAdActor::update() { }
}
- //Game->QuickMessageForm("%s", _currentSprite->_filename);
+ //_gameRef->QuickMessageForm("%s", _currentSprite->_filename);
updateBlockRegion();
_ready = (_state == STATE_READY);
@@ -777,7 +777,7 @@ void CAdActor::getNextStep() { if (!_currentSprite) return;
- _currentSprite->GetCurrentFrame(_zoomable ? ((CAdGame *)Game)->_scene->getZoomAt(_posX, _posY) : 100, _zoomable ? ((CAdGame *)Game)->_scene->getZoomAt(_posX, _posY) : 100);
+ _currentSprite->GetCurrentFrame(_zoomable ? ((CAdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) : 100, _zoomable ? ((CAdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) : 100);
if (!_currentSprite->_changed) return;
@@ -796,7 +796,7 @@ void CAdActor::getNextStep() { maxStepX--;
}
- if (((CAdGame *)Game)->_scene->isBlockedAt((int)_pFX,(int) _pFY, true, this)) {
+ if (((CAdGame *)_gameRef)->_scene->isBlockedAt((int)_pFX,(int) _pFY, true, this)) {
if (_pFCount == 0) {
_state = _nextState;
_nextState = STATE_READY;
@@ -898,7 +898,7 @@ ERRORCODE CAdActor::scCallMethod(CScScript *script, CScStack *stack, CScStack *t CScValue *val = stack->pop();
// turn to object?
- if (val->isNative() && Game->validObject((CBObject *)val->getNative())) {
+ if (val->isNative() && _gameRef->validObject((CBObject *)val->getNative())) {
CBObject *obj = (CBObject *)val->getNative();
int angle = (int)(atan2((double)(obj->_posY - _posY), (double)(obj->_posX - _posX)) * (180 / 3.14));
dir = (int)angleToDirection(angle);
@@ -1106,11 +1106,11 @@ CBSprite *CAdActor::getTalkStance(const char *stance) { if (_forcedTalkAnimName && !_forcedTalkAnimUsed) {
_forcedTalkAnimUsed = true;
delete _animSprite;
- _animSprite = new CBSprite(Game, this);
+ _animSprite = new CBSprite(_gameRef, this);
if (_animSprite) {
ERRORCODE res = _animSprite->loadFile(_forcedTalkAnimName);
if (DID_FAIL(res)) {
- Game->LOG(res, "CAdActor::GetTalkStance: error loading talk sprite (object:\"%s\" sprite:\"%s\")", _name, _forcedTalkAnimName);
+ _gameRef->LOG(res, "CAdActor::GetTalkStance: error loading talk sprite (object:\"%s\" sprite:\"%s\")", _name, _forcedTalkAnimName);
delete _animSprite;
_animSprite = NULL;
} else return _animSprite;
@@ -1268,23 +1268,23 @@ ERRORCODE CAdActor::mergeAnims(const char *animsFilename) { TOKEN_TABLE_END
- byte *fileBuffer = Game->_fileManager->readWholeFile(animsFilename);
+ byte *fileBuffer = _gameRef->_fileManager->readWholeFile(animsFilename);
if (fileBuffer == NULL) {
- Game->LOG(0, "CAdActor::MergeAnims failed for file '%s'", animsFilename);
+ _gameRef->LOG(0, "CAdActor::MergeAnims failed for file '%s'", animsFilename);
return STATUS_FAILED;
}
byte *buffer = fileBuffer;
byte *params;
int cmd;
- CBParser parser(Game);
+ CBParser parser(_gameRef);
ERRORCODE Ret = STATUS_OK;
while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) {
switch (cmd) {
case TOKEN_ANIMATION: {
- CAdSpriteSet *Anim = new CAdSpriteSet(Game, this);
+ CAdSpriteSet *Anim = new CAdSpriteSet(_gameRef, this);
if (!Anim || DID_FAIL(Anim->loadBuffer(params, false))) {
cmd = PARSERR_GENERIC;
Ret = STATUS_FAILED;
diff --git a/engines/wintermute/Ad/AdEntity.cpp b/engines/wintermute/Ad/AdEntity.cpp index 3d9c7f5055..ccffe58efe 100644 --- a/engines/wintermute/Ad/AdEntity.cpp +++ b/engines/wintermute/Ad/AdEntity.cpp @@ -73,7 +73,7 @@ CAdEntity::CAdEntity(CBGame *inGame): CAdTalkHolder(inGame) { //////////////////////////////////////////////////////////////////////////
CAdEntity::~CAdEntity() {
- Game->unregisterObject(_region);
+ _gameRef->unregisterObject(_region);
delete _theora;
_theora = NULL;
@@ -85,9 +85,9 @@ CAdEntity::~CAdEntity() { //////////////////////////////////////////////////////////////////////////
ERRORCODE CAdEntity::loadFile(const char *filename) {
- byte *buffer = Game->_fileManager->readWholeFile(filename);
+ byte *buffer = _gameRef->_fileManager->readWholeFile(filename);
if (buffer == NULL) {
- Game->LOG(0, "CAdEntity::LoadFile failed for file '%s'", filename);
+ _gameRef->LOG(0, "CAdEntity::LoadFile failed for file '%s'", filename);
return STATUS_FAILED;
}
@@ -96,7 +96,7 @@ ERRORCODE CAdEntity::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 ENTITY file '%s'", filename);
+ if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing ENTITY file '%s'", filename);
delete [] buffer;
@@ -198,17 +198,17 @@ ERRORCODE CAdEntity::loadBuffer(byte *buffer, bool complete) { byte *params;
int cmd;
- CBParser parser(Game);
+ CBParser parser(_gameRef);
if (complete) {
if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ENTITY) {
- Game->LOG(0, "'ENTITY' keyword expected.");
+ _gameRef->LOG(0, "'ENTITY' keyword expected.");
return STATUS_FAILED;
}
buffer = params;
}
- CAdGame *adGame = (CAdGame *)Game;
+ CAdGame *adGame = (CAdGame *)_gameRef;
CBSprite *spr = NULL;
int ar = 0, ag = 0, ab = 0, alpha = 0;
while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) {
@@ -228,21 +228,21 @@ ERRORCODE CAdEntity::loadBuffer(byte *buffer, bool complete) { case TOKEN_SPRITE: {
delete _sprite;
_sprite = NULL;
- spr = new CBSprite(Game, this);
+ spr = new CBSprite(_gameRef, this);
if (!spr || DID_FAIL(spr->loadFile((char *)params))) cmd = PARSERR_GENERIC;
else _sprite = spr;
}
break;
case TOKEN_TALK: {
- spr = new CBSprite(Game, this);
+ spr = new CBSprite(_gameRef, this);
if (!spr || DID_FAIL(spr->loadFile((char *)params, adGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC;
else _talkSprites.add(spr);
}
break;
case TOKEN_TALK_SPECIAL: {
- spr = new CBSprite(Game, this);
+ spr = new CBSprite(_gameRef, this);
if (!spr || DID_FAIL(spr->loadFile((char *)params, adGame->_texTalkLifeTime))) cmd = PARSERR_GENERIC;
else _talkSpritesEx.add(spr);
}
@@ -305,7 +305,7 @@ ERRORCODE CAdEntity::loadBuffer(byte *buffer, bool complete) { 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;
@@ -318,13 +318,13 @@ ERRORCODE CAdEntity::loadBuffer(byte *buffer, bool complete) { break;
case TOKEN_REGION: {
- if (_region) Game->unregisterObject(_region);
+ if (_region) _gameRef->unregisterObject(_region);
_region = NULL;
- CBRegion *rgn = new CBRegion(Game);
+ CBRegion *rgn = new CBRegion(_gameRef);
if (!rgn || DID_FAIL(rgn->loadBuffer(params, false))) cmd = PARSERR_GENERIC;
else {
_region = rgn;
- Game->registerObject(_region);
+ _gameRef->registerObject(_region);
}
}
break;
@@ -334,8 +334,8 @@ ERRORCODE CAdEntity::loadBuffer(byte *buffer, bool complete) { _blockRegion = NULL;
delete _currentBlockRegion;
_currentBlockRegion = NULL;
- CBRegion *rgn = new CBRegion(Game);
- CBRegion *crgn = new CBRegion(Game);
+ CBRegion *rgn = new CBRegion(_gameRef);
+ CBRegion *crgn = new CBRegion(_gameRef);
if (!rgn || !crgn || DID_FAIL(rgn->loadBuffer(params, false))) {
delete _blockRegion;
_blockRegion = NULL;
@@ -355,8 +355,8 @@ ERRORCODE CAdEntity::loadBuffer(byte *buffer, bool complete) { _wptGroup = NULL;
delete _currentWptGroup;
_currentWptGroup = NULL;
- CAdWaypointGroup *wpt = new CAdWaypointGroup(Game);
- CAdWaypointGroup *cwpt = new CAdWaypointGroup(Game);
+ CAdWaypointGroup *wpt = new CAdWaypointGroup(_gameRef);
+ CAdWaypointGroup *cwpt = new CAdWaypointGroup(_gameRef);
if (!wpt || !cwpt || DID_FAIL(wpt->loadBuffer(params, false))) {
delete _wptGroup;
_wptGroup = NULL;
@@ -379,15 +379,15 @@ ERRORCODE CAdEntity::loadBuffer(byte *buffer, bool complete) { if (scumm_stricmp((char *)params, "sound") == 0) {
delete _sprite;
_sprite = NULL;
- if (Game->_editorMode) {
- spr = new CBSprite(Game, this);
+ if (_gameRef->_editorMode) {
+ spr = new CBSprite(_gameRef, this);
if (!spr || DID_FAIL(spr->loadFile("entity_sound.sprite"))) cmd = PARSERR_GENERIC;
else _sprite = spr;
}
- if (Game->_editorMode) _editorOnly = true;
+ if (_gameRef->_editorMode) _editorOnly = true;
_zoomable = false;
_rotatable = false;
- _registrable = Game->_editorMode;
+ _registrable = _gameRef->_editorMode;
_shadowable = false;
_subtype = ENTITY_SOUND;
}
@@ -453,17 +453,17 @@ ERRORCODE CAdEntity::loadBuffer(byte *buffer, bool complete) { }
}
if (cmd == PARSERR_TOKENNOTFOUND) {
- Game->LOG(0, "Syntax error in ENTITY definition");
+ _gameRef->LOG(0, "Syntax error in ENTITY definition");
return STATUS_FAILED;
}
if (cmd == PARSERR_GENERIC) {
- Game->LOG(0, "Error loading ENTITY definition");
+ _gameRef->LOG(0, "Error loading ENTITY definition");
if (spr) delete spr;
return STATUS_FAILED;
}
if (_region && _sprite) {
- Game->LOG(0, "Warning: Entity '%s' has both sprite and region.", _name);
+ _gameRef->LOG(0, "Warning: Entity '%s' has both sprite and region.", _name);
}
updatePosition();
@@ -474,7 +474,7 @@ ERRORCODE CAdEntity::loadBuffer(byte *buffer, bool complete) { _alphaColor = BYTETORGBA(ar, ag, ab, alpha);
_state = STATE_READY;
- if (_item && ((CAdGame *)Game)->isItemTaken(_item)) _active = false;
+ if (_item && ((CAdGame *)_gameRef)->isItemTaken(_item)) _active = false;
return STATUS_OK;
}
@@ -487,7 +487,7 @@ ERRORCODE CAdEntity::display() { uint32 Alpha;
if (_alphaColor != 0) Alpha = _alphaColor;
- else Alpha = _shadowable ? ((CAdGame *)Game)->_scene->getAlphaAt(_posX, _posY) : 0xFFFFFFFF;
+ else Alpha = _shadowable ? ((CAdGame *)_gameRef)->_scene->getAlphaAt(_posX, _posY) : 0xFFFFFFFF;
float ScaleX, ScaleY;
getScale(&ScaleX, &ScaleY);
@@ -495,15 +495,15 @@ ERRORCODE CAdEntity::display() { float Rotate;
if (_rotatable) {
if (_rotateValid) Rotate = _rotate;
- else Rotate = ((CAdGame *)Game)->_scene->getRotationAt(_posX, _posY) + _relativeRotate;
+ else Rotate = ((CAdGame *)_gameRef)->_scene->getRotationAt(_posX, _posY) + _relativeRotate;
} else Rotate = 0.0f;
bool Reg = _registrable;
- if (_ignoreItems && ((CAdGame *)Game)->_selectedItem) Reg = false;
+ if (_ignoreItems && ((CAdGame *)_gameRef)->_selectedItem) Reg = false;
if (_region && (Reg || _editorAlwaysRegister)) {
- Game->_renderer->_rectList.add(new CBActiveRect(Game, _registerAlias, _region, Game->_offsetX, Game->_offsetY));
+ _gameRef->_renderer->_rectList.add(new CBActiveRect(_gameRef, _registerAlias, _region, _gameRef->_offsetX, _gameRef->_offsetY));
}
displaySpriteAttachments(true);
@@ -565,7 +565,7 @@ ERRORCODE CAdEntity::update() { _sentence->update();
if (_sentence->_currentSprite) _tempSprite2 = _sentence->_currentSprite;
- bool TimeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->isPlaying() && !_sentence->_sound->isPaused())) || (!_sentence->_sound && _sentence->_duration <= Game->_timer - _sentence->_startTime);
+ bool TimeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->isPlaying() && !_sentence->_sound->isPaused())) || (!_sentence->_sound && _sentence->_duration <= _gameRef->_timer - _sentence->_startTime);
if (_tempSprite2 == NULL || _tempSprite2->_finished || (/*_tempSprite2->_looping &&*/ TimeIsUp)) {
if (TimeIsUp) {
_sentence->finish();
@@ -577,11 +577,11 @@ ERRORCODE CAdEntity::update() { _tempSprite2->reset();
_currentSprite = _tempSprite2;
}
- ((CAdGame *)Game)->addSentence(_sentence);
+ ((CAdGame *)_gameRef)->addSentence(_sentence);
}
} else {
_currentSprite = _tempSprite2;
- ((CAdGame *)Game)->addSentence(_sentence);
+ ((CAdGame *)_gameRef)->addSentence(_sentence);
}
}
break;
@@ -591,7 +591,7 @@ ERRORCODE CAdEntity::update() { if (_currentSprite) {
- _currentSprite->GetCurrentFrame(_zoomable ? ((CAdGame *)Game)->_scene->getZoomAt(_posX, _posY) : 100);
+ _currentSprite->GetCurrentFrame(_zoomable ? ((CAdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) : 100);
if (_currentSprite->_changed) {
_posX += _currentSprite->_moveX;
_posY += _currentSprite->_moveY;
@@ -603,7 +603,7 @@ ERRORCODE CAdEntity::update() { if (_theora) {
int OffsetX, OffsetY;
- Game->getOffset(&OffsetX, &OffsetY);
+ _gameRef->getOffset(&OffsetX, &OffsetY);
_theora->_posX = _posX - OffsetX;
_theora->_posY = _posY - OffsetY;
@@ -648,7 +648,7 @@ ERRORCODE CAdEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack * int startTime = stack->pop()->getInt();
delete _theora;
- _theora = new CVidTheoraPlayer(Game);
+ _theora = new CVidTheoraPlayer(_gameRef);
if (_theora && DID_SUCCEED(_theora->initialize(filename))) {
if (!valAlpha->isNULL()) _theora->setAlphaImage(valAlpha->getString());
_theora->play(VID_PLAY_POS, 0, 0, false, false, looping, startTime, _scale >= 0.0f ? _scale : -1.0f, _sFXVolume);
@@ -732,8 +732,8 @@ ERRORCODE CAdEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack * else if (strcmp(name, "CreateRegion") == 0) {
stack->correctParams(0);
if (!_region) {
- _region = new CBRegion(Game);
- Game->registerObject(_region);
+ _region = new CBRegion(_gameRef);
+ _gameRef->registerObject(_region);
}
if (_region) stack->pushNative(_region, true);
else stack->pushNULL();
@@ -747,7 +747,7 @@ ERRORCODE CAdEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack * else if (strcmp(name, "DeleteRegion") == 0) {
stack->correctParams(0);
if (_region) {
- Game->unregisterObject(_region);
+ _gameRef->unregisterObject(_region);
_region = NULL;
stack->pushBool(true);
} else stack->pushBool(false);
@@ -1012,7 +1012,7 @@ ERRORCODE CAdEntity::setSprite(const char *filename) { delete _sprite;
_sprite = NULL;
- CBSprite *spr = new CBSprite(Game, this);
+ CBSprite *spr = new CBSprite(_gameRef, this);
if (!spr || DID_FAIL(spr->loadFile(filename))) {
delete _sprite;
_sprite = NULL;
diff --git a/engines/wintermute/Ad/AdGame.cpp b/engines/wintermute/Ad/AdGame.cpp index 759c212de8..953dd92179 100644 --- a/engines/wintermute/Ad/AdGame.cpp +++ b/engines/wintermute/Ad/AdGame.cpp @@ -70,7 +70,7 @@ CAdGame::CAdGame(): CBGame() { _responseBox = NULL;
_inventoryBox = NULL;
- _scene = new CAdScene(Game);
+ _scene = new CAdScene(_gameRef);
_scene->setName("");
registerObject(_scene);
@@ -142,7 +142,7 @@ ERRORCODE CAdGame::cleanup() { _scene = NULL;
// remove items
- for (i = 0; i < _items.getSize(); i++) Game->unregisterObject(_items[i]);
+ for (i = 0; i < _items.getSize(); i++) _gameRef->unregisterObject(_items[i]);
_items.removeAll();
@@ -157,12 +157,12 @@ ERRORCODE CAdGame::cleanup() { if (_responseBox) {
- Game->unregisterObject(_responseBox);
+ _gameRef->unregisterObject(_responseBox);
_responseBox = NULL;
}
if (_inventoryBox) {
- Game->unregisterObject(_inventoryBox);
+ _gameRef->unregisterObject(_inventoryBox);
_inventoryBox = NULL;
}
@@ -201,7 +201,7 @@ ERRORCODE CAdGame::initLoop() { delete[] _scheduledScene;
_scheduledScene = NULL;
- Game->_activeObject = NULL;
+ _gameRef->_activeObject = NULL;
}
@@ -245,7 +245,7 @@ ERRORCODE CAdGame::removeObject(CAdObject *object) { //////////////////////////////////////////////////////////////////////////
ERRORCODE CAdGame::changeScene(const char *filename, bool fadeIn) {
if (_scene == NULL) {
- _scene = new CAdScene(Game);
+ _scene = new CAdScene(_gameRef);
registerObject(_scene);
} else {
_scene->applyEvent("SceneShutdown", true);
@@ -280,7 +280,7 @@ ERRORCODE CAdGame::changeScene(const char *filename, bool fadeIn) { _scene->loadState();
}
- if (fadeIn) Game->_transMgr->start(TRANSITION_FADE_IN);
+ if (fadeIn) _gameRef->_transMgr->start(TRANSITION_FADE_IN);
return ret;
} else return STATUS_FAILED;
}
@@ -346,7 +346,7 @@ ERRORCODE CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *th //////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "LoadActor") == 0) {
stack->correctParams(1);
- CAdActor *act = new CAdActor(Game);
+ CAdActor *act = new CAdActor(_gameRef);
if (act && DID_SUCCEED(act->loadFile(stack->pop()->getString()))) {
addObject(act);
stack->pushNative(act, true);
@@ -363,7 +363,7 @@ ERRORCODE CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *th //////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "LoadEntity") == 0) {
stack->correctParams(1);
- CAdEntity *ent = new CAdEntity(Game);
+ CAdEntity *ent = new CAdEntity(_gameRef);
if (ent && DID_SUCCEED(ent->loadFile(stack->pop()->getString()))) {
addObject(ent);
stack->pushNative(ent, true);
@@ -396,7 +396,7 @@ ERRORCODE CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *th stack->correctParams(1);
CScValue *val = stack->pop();
- CAdEntity *ent = new CAdEntity(Game);
+ CAdEntity *ent = new CAdEntity(_gameRef);
addObject(ent);
if (!val->isNULL()) ent->setName(val->getString());
stack->pushNative(ent, true);
@@ -410,7 +410,7 @@ ERRORCODE CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *th stack->correctParams(1);
CScValue *val = stack->pop();
- CAdItem *item = new CAdItem(Game);
+ CAdItem *item = new CAdItem(_gameRef);
addItem(item);
if (!val->isNULL()) item->setName(val->getString());
stack->pushNative(item, true);
@@ -471,7 +471,7 @@ ERRORCODE CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *th CScValue *val4 = stack->pop();
if (_responseBox) {
- CAdResponse *res = new CAdResponse(Game);
+ CAdResponse *res = new CAdResponse(_gameRef);
if (res) {
res->_iD = id;
res->setText(text);
@@ -702,8 +702,8 @@ ERRORCODE CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *th stack->correctParams(1);
const char *filename = stack->pop()->getString();
- Game->unregisterObject(_responseBox);
- _responseBox = new CAdResponseBox(Game);
+ _gameRef->unregisterObject(_responseBox);
+ _responseBox = new CAdResponseBox(_gameRef);
if (_responseBox && !DID_FAIL(_responseBox->loadFile(filename))) {
registerObject(_responseBox);
stack->pushBool(true);
@@ -722,8 +722,8 @@ ERRORCODE CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *th stack->correctParams(1);
const char *filename = stack->pop()->getString();
- Game->unregisterObject(_inventoryBox);
- _inventoryBox = new CAdInventoryBox(Game);
+ _gameRef->unregisterObject(_inventoryBox);
+ _inventoryBox = new CAdInventoryBox(_gameRef);
if (_inventoryBox && !DID_FAIL(_inventoryBox->loadFile(filename))) {
registerObject(_inventoryBox);
stack->pushBool(true);
@@ -784,7 +784,7 @@ ERRORCODE CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *th if (width <= 0) width = _renderer->_width;
if (height <= 0) height = _renderer->_height;
- if (!_sceneViewport) _sceneViewport = new CBViewport(Game);
+ if (!_sceneViewport) _sceneViewport = new CBViewport(_gameRef);
if (_sceneViewport) _sceneViewport->setRect(x, y, x + width, y + height);
stack->pushBool(true);
@@ -1003,7 +1003,7 @@ ERRORCODE CAdGame::scSetProperty(const char *name, CScValue *value) { else {
CBObject *Obj = (CBObject *)value->getNative();
if (Obj == this) _inventoryOwner = _invObject;
- else if (Game->validObject(Obj)) _inventoryOwner = (CAdObject *)Obj;
+ else if (_gameRef->validObject(Obj)) _inventoryOwner = (CAdObject *)Obj;
}
if (_inventoryOwner && _inventoryBox) _inventoryBox->_scrollOffset = _inventoryOwner->getInventory()->_scrollOffset;
@@ -1057,7 +1057,7 @@ ERRORCODE CAdGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *th stack->correctParams(0);
this_obj = thisStack->getTop();
- this_obj->setNative(new CAdActor(Game));
+ this_obj->setNative(new CAdActor(_gameRef));
stack->pushNULL();
}
@@ -1068,7 +1068,7 @@ ERRORCODE CAdGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *th stack->correctParams(0);
this_obj = thisStack->getTop();
- this_obj->setNative(new CAdEntity(Game));
+ this_obj->setNative(new CAdEntity(_gameRef));
stack->pushNULL();
}
@@ -1086,7 +1086,7 @@ ERRORCODE CAdGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *th ERRORCODE CAdGame::showCursor() {
if (_cursorHidden) return STATUS_OK;
- if (_selectedItem && Game->_state == GAME_RUNNING && _stateEx == GAME_NORMAL && _interactive) {
+ if (_selectedItem && _gameRef->_state == GAME_RUNNING && _stateEx == GAME_NORMAL && _interactive) {
if (_selectedItem->_cursorCombined) {
CBSprite *origLastCursor = _lastCursor;
CBGame::showCursor();
@@ -1106,7 +1106,7 @@ ERRORCODE CAdGame::showCursor() { ERRORCODE CAdGame::loadFile(const char *filename) {
byte *buffer = _fileManager->readWholeFile(filename);
if (buffer == NULL) {
- Game->LOG(0, "CAdGame::LoadFile failed for file '%s'", filename);
+ _gameRef->LOG(0, "CAdGame::LoadFile failed for file '%s'", filename);
return STATUS_FAILED;
}
@@ -1115,7 +1115,7 @@ ERRORCODE CAdGame::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;
@@ -1156,7 +1156,7 @@ ERRORCODE CAdGame::loadBuffer(byte *buffer, bool complete) { byte *params;
byte *params2;
int cmd = 1;
- CBParser parser(Game);
+ CBParser parser(_gameRef);
bool itemFound = false, itemsFound = false;
@@ -1171,7 +1171,7 @@ ERRORCODE CAdGame::loadBuffer(byte *buffer, bool complete) { switch (cmd) {
case TOKEN_RESPONSE_BOX:
delete _responseBox;
- _responseBox = new CAdResponseBox(Game);
+ _responseBox = new CAdResponseBox(_gameRef);
if (_responseBox && !DID_FAIL(_responseBox->loadFile((char *)params2)))
registerObject(_responseBox);
else {
@@ -1183,7 +1183,7 @@ ERRORCODE CAdGame::loadBuffer(byte *buffer, bool complete) { case TOKEN_INVENTORY_BOX:
delete _inventoryBox;
- _inventoryBox = new CAdInventoryBox(Game);
+ _inventoryBox = new CAdInventoryBox(_gameRef);
if (_inventoryBox && !DID_FAIL(_inventoryBox->loadFile((char *)params2)))
registerObject(_inventoryBox);
else {
@@ -1212,7 +1212,7 @@ ERRORCODE CAdGame::loadBuffer(byte *buffer, bool complete) { case TOKEN_SCENE_VIEWPORT: {
Rect32 rc;
parser.scanStr((char *)params2, "%d,%d,%d,%d", &rc.left, &rc.top, &rc.right, &rc.bottom);
- if (!_sceneViewport) _sceneViewport = new CBViewport(Game);
+ if (!_sceneViewport) _sceneViewport = new CBViewport(_gameRef);
if (_sceneViewport) _sceneViewport->setRect(rc.left, rc.top, rc.right, rc.bottom);
}
break;
@@ -1235,16 +1235,16 @@ ERRORCODE CAdGame::loadBuffer(byte *buffer, bool complete) { }
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;
}
if (itemFound && !itemsFound) {
- Game->LOG(0, "**Warning** Please put the items definition to a separate file.");
+ _gameRef->LOG(0, "**Warning** Please put the items definition to a separate file.");
}
return STATUS_OK;
@@ -1374,9 +1374,9 @@ ERRORCODE CAdGame::getVersion(byte *verMajor, byte *verMinor, byte *extMajor, by //////////////////////////////////////////////////////////////////////////
ERRORCODE CAdGame::loadItemsFile(const char *filename, bool merge) {
- byte *buffer = Game->_fileManager->readWholeFile(filename);
+ byte *buffer = _gameRef->_fileManager->readWholeFile(filename);
if (buffer == NULL) {
- Game->LOG(0, "CAdGame::LoadItemsFile failed for file '%s'", filename);
+ _gameRef->LOG(0, "CAdGame::LoadItemsFile failed for file '%s'", filename);
return STATUS_FAILED;
}
@@ -1385,7 +1385,7 @@ ERRORCODE CAdGame::loadItemsFile(const char *filename, bool merge) { //_filename = new char [strlen(filename)+1];
//strcpy(_filename, filename);
- if (DID_FAIL(ret = loadItemsBuffer(buffer, merge))) Game->LOG(0, "Error parsing ITEMS file '%s'", filename);
+ if (DID_FAIL(ret = loadItemsBuffer(buffer, merge))) _gameRef->LOG(0, "Error parsing ITEMS file '%s'", filename);
delete [] buffer;
@@ -1402,7 +1402,7 @@ ERRORCODE CAdGame::loadItemsBuffer(byte *buffer, bool merge) { byte *params;
int cmd;
- CBParser parser(Game);
+ CBParser parser(_gameRef);
if (!merge) {
while (_items.getSize() > 0) deleteItem(_items[0]);
@@ -1411,7 +1411,7 @@ ERRORCODE CAdGame::loadItemsBuffer(byte *buffer, bool merge) { while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) {
switch (cmd) {
case TOKEN_ITEM: {
- CAdItem *item = new CAdItem(Game);
+ CAdItem *item = new CAdItem(_gameRef);
if (item && !DID_FAIL(item->loadBuffer(params, false))) {
// delete item with the same name, if exists
if (merge) {
@@ -1430,11 +1430,11 @@ ERRORCODE CAdGame::loadItemsBuffer(byte *buffer, bool merge) { }
if (cmd == PARSERR_TOKENNOTFOUND) {
- Game->LOG(0, "Syntax error in ITEMS definition");
+ _gameRef->LOG(0, "Syntax error in ITEMS definition");
return STATUS_FAILED;
}
if (cmd == PARSERR_GENERIC) {
- Game->LOG(0, "Error loading ITEMS definition");
+ _gameRef->LOG(0, "Error loading ITEMS definition");
return STATUS_FAILED;
}
@@ -1458,7 +1458,7 @@ CAdSceneState *CAdGame::getSceneState(const char *filename, bool saving) { }
if (saving) {
- CAdSceneState *ret = new CAdSceneState(Game);
+ CAdSceneState *ret = new CAdSceneState(_gameRef);
ret->setFilename(filenameCor);
_sceneStates.add(ret);
@@ -1479,12 +1479,12 @@ ERRORCODE CAdGame::windowLoadHook(CUIWindow *win, char **buffer, char **params) TOKEN_TABLE_END
int cmd = PARSERR_GENERIC;
- CBParser parser(Game);
+ CBParser parser(_gameRef);
cmd = parser.getCommand(buffer, commands, params);
switch (cmd) {
case TOKEN_ENTITY_CONTAINER: {
- CUIEntity *ent = new CUIEntity(Game);
+ CUIEntity *ent = new CUIEntity(_gameRef);
if (!ent || DID_FAIL(ent->loadBuffer((byte *)*params, false))) {
delete ent;
ent = NULL;
@@ -1512,7 +1512,7 @@ ERRORCODE CAdGame::windowScriptMethodHook(CUIWindow *win, CScScript *script, CSc stack->correctParams(1);
CScValue *val = stack->pop();
- CUIEntity *ent = new CUIEntity(Game);
+ CUIEntity *ent = new CUIEntity(_gameRef);
if (!val->isNULL()) ent->setName(val->getString());
stack->pushNative(ent, true);
@@ -1598,7 +1598,7 @@ ERRORCODE CAdGame::clearBranchResponses(char *name) { //////////////////////////////////////////////////////////////////////////
ERRORCODE CAdGame::addBranchResponse(int ID) {
if (branchResponseUsed(ID)) return STATUS_OK;
- CAdResponseContext *r = new CAdResponseContext(Game);
+ CAdResponseContext *r = new CAdResponseContext(_gameRef);
r->_iD = ID;
r->setContext(_dlgPendingBranches.getSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.getSize() - 1] : NULL);
_responsesBranch.add(r);
@@ -1621,7 +1621,7 @@ bool CAdGame::branchResponseUsed(int ID) { //////////////////////////////////////////////////////////////////////////
ERRORCODE CAdGame::addGameResponse(int ID) {
if (gameResponseUsed(ID)) return STATUS_OK;
- CAdResponseContext *r = new CAdResponseContext(Game);
+ CAdResponseContext *r = new CAdResponseContext(_gameRef);
r->_iD = ID;
r->setContext(_dlgPendingBranches.getSize() > 0 ? _dlgPendingBranches[_dlgPendingBranches.getSize() - 1] : NULL);
_responsesGame.add(r);
@@ -1716,7 +1716,7 @@ ERRORCODE CAdGame::displayContent(bool doUpdate, bool displayAll) { // display normal windows
displayWindows(false);
- setActiveObject(Game->_renderer->getObjectAt(p.x, p.y));
+ setActiveObject(_gameRef->_renderer->getObjectAt(p.x, p.y));
// textual info
displaySentences(_state == GAME_FROZEN);
@@ -1788,7 +1788,7 @@ CAdItem *CAdGame::getItemByName(const char *name) { //////////////////////////////////////////////////////////////////////////
ERRORCODE CAdGame::addItem(CAdItem *item) {
_items.add(item);
- return Game->registerObject(item);
+ return _gameRef->registerObject(item);
}
@@ -1951,7 +1951,7 @@ ERRORCODE CAdGame::onMouseLeftDown() { }
}
- if (_activeObject != NULL) Game->_capturedObject = Game->_activeObject;
+ if (_activeObject != NULL) _gameRef->_capturedObject = _gameRef->_activeObject;
_mouseLeftDown = true;
CBPlatform::setCapture(/*_renderer->_window*/);
@@ -2039,7 +2039,7 @@ ERRORCODE CAdGame::onMouseRightUp() { //////////////////////////////////////////////////////////////////////////
ERRORCODE CAdGame::displayDebugInfo() {
char str[100];
- if (Game->_dEBUG_DebugMode) {
+ if (_gameRef->_dEBUG_DebugMode) {
sprintf(str, "Mouse: %d, %d (scene: %d, %d)", _mousePos.x, _mousePos.y, _mousePos.x + _scene->getOffsetLeft(), _mousePos.y + _scene->getOffsetTop());
_systemFont->drawText((byte *)str, 0, 90, _renderer->_width, TAL_RIGHT);
diff --git a/engines/wintermute/Ad/AdInventory.cpp b/engines/wintermute/Ad/AdInventory.cpp index 1c14cb710c..24cf919165 100644 --- a/engines/wintermute/Ad/AdInventory.cpp +++ b/engines/wintermute/Ad/AdInventory.cpp @@ -52,7 +52,7 @@ CAdInventory::~CAdInventory() { ERRORCODE CAdInventory::insertItem(const char *name, const char *insertAfter) {
if (name == NULL) return STATUS_FAILED;
- CAdItem *item = ((CAdGame *)Game)->getItemByName(name);
+ CAdItem *item = ((CAdGame *)_gameRef)->getItemByName(name);
if (item == NULL) return STATUS_FAILED;
int insertIndex = -1;
@@ -79,7 +79,7 @@ ERRORCODE CAdInventory::removeItem(const char *name) { for (int i = 0; i < _takenItems.getSize(); i++) {
if (scumm_stricmp(_takenItems[i]->_name, name) == 0) {
- if (((CAdGame *)Game)->_selectedItem == _takenItems[i])((CAdGame *)Game)->_selectedItem = NULL;
+ if (((CAdGame *)_gameRef)->_selectedItem == _takenItems[i])((CAdGame *)_gameRef)->_selectedItem = NULL;
_takenItems.removeAt(i);
return STATUS_OK;
}
@@ -96,7 +96,7 @@ ERRORCODE CAdInventory::removeItem(CAdItem *item) { for (int i = 0; i < _takenItems.getSize(); i++) {
if (_takenItems[i] == item) {
- if (((CAdGame *)Game)->_selectedItem == _takenItems[i])((CAdGame *)Game)->_selectedItem = NULL;
+ if (((CAdGame *)_gameRef)->_selectedItem == _takenItems[i])((CAdGame *)_gameRef)->_selectedItem = NULL;
_takenItems.removeAt(i);
return STATUS_OK;
}
diff --git a/engines/wintermute/Ad/AdInventoryBox.cpp b/engines/wintermute/Ad/AdInventoryBox.cpp index 222d91800d..3b38903bbf 100644 --- a/engines/wintermute/Ad/AdInventoryBox.cpp +++ b/engines/wintermute/Ad/AdInventoryBox.cpp @@ -65,7 +65,7 @@ CAdInventoryBox::CAdInventoryBox(CBGame *inGame): CBObject(inGame) { //////////////////////////////////////////////////////////////////////////
CAdInventoryBox::~CAdInventoryBox() {
- Game->unregisterObject(_window);
+ _gameRef->unregisterObject(_window);
_window = NULL;
delete _closeButton;
@@ -99,7 +99,7 @@ ERRORCODE CAdInventoryBox::listen(CBScriptHolder *param1, uint32 param2) { //////////////////////////////////////////////////////////////////////////
ERRORCODE CAdInventoryBox::display() {
- CAdGame *adGame = (CAdGame *)Game;
+ CAdGame *adGame = (CAdGame *)_gameRef;
if (!_visible) return STATUS_OK;
@@ -115,8 +115,8 @@ ERRORCODE CAdInventoryBox::display() { if (_closeButton) {
_closeButton->_posX = _closeButton->_posY = 0;
- _closeButton->_width = Game->_renderer->_width;
- _closeButton->_height = Game->_renderer->_height;
+ _closeButton->_width = _gameRef->_renderer->_width;
+ _closeButton->_height = _gameRef->_renderer->_height;
_closeButton->display();
}
@@ -130,7 +130,7 @@ ERRORCODE CAdInventoryBox::display() { }
// display items
- if (_window && _window->_alphaColor != 0) Game->_renderer->_forceAlphaColor = _window->_alphaColor;
+ if (_window && _window->_alphaColor != 0) _gameRef->_renderer->_forceAlphaColor = _window->_alphaColor;
int yyy = rect.top;
for (int j = 0; j < itemsY; j++) {
int xxx = rect.left;
@@ -138,7 +138,7 @@ ERRORCODE CAdInventoryBox::display() { int itemIndex = _scrollOffset + j * itemsX + i;
if (itemIndex >= 0 && itemIndex < adGame->_inventoryOwner->getInventory()->_takenItems.getSize()) {
CAdItem *item = adGame->_inventoryOwner->getInventory()->_takenItems[itemIndex];
- if (item != ((CAdGame *)Game)->_selectedItem || !_hideSelected) {
+ if (item != ((CAdGame *)_gameRef)->_selectedItem || !_hideSelected) {
item->update();
item->display(xxx, yyy);
}
@@ -148,7 +148,7 @@ ERRORCODE CAdInventoryBox::display() { }
yyy += (_itemHeight + _spacing);
}
- if (_window && _window->_alphaColor != 0) Game->_renderer->_forceAlphaColor = 0;
+ if (_window && _window->_alphaColor != 0) _gameRef->_renderer->_forceAlphaColor = 0;
return STATUS_OK;
}
@@ -156,9 +156,9 @@ ERRORCODE CAdInventoryBox::display() { //////////////////////////////////////////////////////////////////////////
ERRORCODE CAdInventoryBox::loadFile(const char *filename) {
- byte *buffer = Game->_fileManager->readWholeFile(filename);
+ byte *buffer = _gameRef->_fileManager->readWholeFile(filename);
if (buffer == NULL) {
- Game->LOG(0, "CAdInventoryBox::LoadFile failed for file '%s'", filename);
+ _gameRef->LOG(0, "CAdInventoryBox::LoadFile failed for file '%s'", filename);
return STATUS_FAILED;
}
@@ -167,7 +167,7 @@ ERRORCODE CAdInventoryBox::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 INVENTORY_BOX file '%s'", filename);
+ if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing INVENTORY_BOX file '%s'", filename);
delete [] buffer;
@@ -213,13 +213,13 @@ ERRORCODE CAdInventoryBox::loadBuffer(byte *buffer, bool complete) { byte *params;
int cmd = 2;
- CBParser parser(Game);
+ CBParser parser(_gameRef);
bool always_visible = false;
_exclusive = false;
if (complete) {
if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_INVENTORY_BOX) {
- Game->LOG(0, "'INVENTORY_BOX' keyword expected.");
+ _gameRef->LOG(0, "'INVENTORY_BOX' keyword expected.");
return STATUS_FAILED;
}
buffer = params;
@@ -241,12 +241,12 @@ ERRORCODE CAdInventoryBox::loadBuffer(byte *buffer, bool complete) { case TOKEN_WINDOW:
delete _window;
- _window = new CUIWindow(Game);
+ _window = new CUIWindow(_gameRef);
if (!_window || DID_FAIL(_window->loadBuffer(params, false))) {
delete _window;
_window = NULL;
cmd = PARSERR_GENERIC;
- } else Game->registerObject(_window);
+ } else _gameRef->registerObject(_window);
break;
case TOKEN_AREA:
@@ -287,17 +287,17 @@ ERRORCODE CAdInventoryBox::loadBuffer(byte *buffer, bool complete) { }
}
if (cmd == PARSERR_TOKENNOTFOUND) {
- Game->LOG(0, "Syntax error in INVENTORY_BOX definition");
+ _gameRef->LOG(0, "Syntax error in INVENTORY_BOX definition");
return STATUS_FAILED;
}
if (cmd == PARSERR_GENERIC) {
- Game->LOG(0, "Error loading INVENTORY_BOX definition");
+ _gameRef->LOG(0, "Error loading INVENTORY_BOX definition");
return STATUS_FAILED;
}
if (_exclusive) {
delete _closeButton;
- _closeButton = new CUIButton(Game);
+ _closeButton = new CUIButton(_gameRef);
if (_closeButton) {
_closeButton->setName("close");
_closeButton->setListener(this, _closeButton, 0);
diff --git a/engines/wintermute/Ad/AdItem.cpp b/engines/wintermute/Ad/AdItem.cpp index a728a8d048..1727950191 100644 --- a/engines/wintermute/Ad/AdItem.cpp +++ b/engines/wintermute/Ad/AdItem.cpp @@ -85,9 +85,9 @@ CAdItem::~CAdItem() { //////////////////////////////////////////////////////////////////////////
ERRORCODE CAdItem::loadFile(const char *filename) {
- byte *buffer = Game->_fileManager->readWholeFile(filename);
+ byte *buffer = _gameRef->_fileManager->readWholeFile(filename);
if (buffer == NULL) {
- Game->LOG(0, "CAdItem::LoadFile failed for file '%s'", filename);
+ _gameRef->LOG(0, "CAdItem::LoadFile failed for file '%s'", filename);
return STATUS_FAILED;
}
@@ -96,7 +96,7 @@ ERRORCODE CAdItem::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 ITEM file '%s'", filename);
+ if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing ITEM file '%s'", filename);
delete [] buffer;
@@ -166,11 +166,11 @@ ERRORCODE CAdItem::loadBuffer(byte *buffer, bool complete) { byte *params;
int cmd = 2;
- CBParser parser(Game);
+ CBParser parser(_gameRef);
if (complete) {
if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ITEM) {
- Game->LOG(0, "'ITEM' keyword expected.");
+ _gameRef->LOG(0, "'ITEM' keyword expected.");
return STATUS_FAILED;
}
buffer = params;
@@ -198,8 +198,8 @@ ERRORCODE CAdItem::loadBuffer(byte *buffer, bool complete) { case TOKEN_IMAGE:
case TOKEN_SPRITE:
delete _sprite;
- _sprite = new CBSprite(Game, this);
- if (!_sprite || DID_FAIL(_sprite->loadFile((char *)params, ((CAdGame *)Game)->_texItemLifeTime))) {
+ _sprite = new CBSprite(_gameRef, this);
+ if (!_sprite || DID_FAIL(_sprite->loadFile((char *)params, ((CAdGame *)_gameRef)->_texItemLifeTime))) {
delete _sprite;
cmd = PARSERR_GENERIC;
}
@@ -208,8 +208,8 @@ ERRORCODE CAdItem::loadBuffer(byte *buffer, bool complete) { case TOKEN_IMAGE_HOVER:
case TOKEN_SPRITE_HOVER:
delete _spriteHover;
- _spriteHover = new CBSprite(Game, this);
- if (!_spriteHover || DID_FAIL(_spriteHover->loadFile((char *)params, ((CAdGame *)Game)->_texItemLifeTime))) {
+ _spriteHover = new CBSprite(_gameRef, this);
+ if (!_spriteHover || DID_FAIL(_spriteHover->loadFile((char *)params, ((CAdGame *)_gameRef)->_texItemLifeTime))) {
delete _spriteHover;
cmd = PARSERR_GENERIC;
}
@@ -242,23 +242,23 @@ ERRORCODE CAdItem::loadBuffer(byte *buffer, bool complete) { break;
case TOKEN_TALK: {
- CBSprite *spr = new CBSprite(Game, this);
- if (!spr || DID_FAIL(spr->loadFile((char *)params, ((CAdGame *)Game)->_texTalkLifeTime))) cmd = PARSERR_GENERIC;
+ CBSprite *spr = new CBSprite(_gameRef, this);
+ if (!spr || DID_FAIL(spr->loadFile((char *)params, ((CAdGame *)_gameRef)->_texTalkLifeTime))) cmd = PARSERR_GENERIC;
else _talkSprites.add(spr);
}
break;
case TOKEN_TALK_SPECIAL: {
- CBSprite *spr = new CBSprite(Game, this);
- if (!spr || DID_FAIL(spr->loadFile((char *)params, ((CAdGame *)Game)->_texTalkLifeTime))) cmd = PARSERR_GENERIC;
+ CBSprite *spr = new CBSprite(_gameRef, this);
+ if (!spr || DID_FAIL(spr->loadFile((char *)params, ((CAdGame *)_gameRef)->_texTalkLifeTime))) cmd = PARSERR_GENERIC;
else _talkSpritesEx.add(spr);
}
break;
case TOKEN_CURSOR:
delete _cursorNormal;
- _cursorNormal = new CBSprite(Game);
- if (!_cursorNormal || DID_FAIL(_cursorNormal->loadFile((char *)params, ((CAdGame *)Game)->_texItemLifeTime))) {
+ _cursorNormal = new CBSprite(_gameRef);
+ if (!_cursorNormal || DID_FAIL(_cursorNormal->loadFile((char *)params, ((CAdGame *)_gameRef)->_texItemLifeTime))) {
delete _cursorNormal;
_cursorNormal = NULL;
cmd = PARSERR_GENERIC;
@@ -267,8 +267,8 @@ ERRORCODE CAdItem::loadBuffer(byte *buffer, bool complete) { case TOKEN_CURSOR_HOVER:
delete _cursorHover;
- _cursorHover = new CBSprite(Game);
- if (!_cursorHover || DID_FAIL(_cursorHover->loadFile((char *)params, ((CAdGame *)Game)->_texItemLifeTime))) {
+ _cursorHover = new CBSprite(_gameRef);
+ if (!_cursorHover || DID_FAIL(_cursorHover->loadFile((char *)params, ((CAdGame *)_gameRef)->_texItemLifeTime))) {
delete _cursorHover;
_cursorHover = NULL;
cmd = PARSERR_GENERIC;
@@ -301,11 +301,11 @@ ERRORCODE CAdItem::loadBuffer(byte *buffer, bool complete) { }
}
if (cmd == PARSERR_TOKENNOTFOUND) {
- Game->LOG(0, "Syntax error in ITEM definition");
+ _gameRef->LOG(0, "Syntax error in ITEM definition");
return STATUS_FAILED;
}
if (cmd == PARSERR_GENERIC) {
- Game->LOG(0, "Error loading ITEM definition");
+ _gameRef->LOG(0, "Error loading ITEM definition");
return STATUS_FAILED;
}
@@ -347,7 +347,7 @@ ERRORCODE CAdItem::update() { //////////////////////////////////////////////////////////////////////////
case STATE_READY:
if (!_animSprite) {
- if (Game->_activeObject == this && _spriteHover) _currentSprite = _spriteHover;
+ if (_gameRef->_activeObject == this && _spriteHover) _currentSprite = _spriteHover;
else _currentSprite = _sprite;
}
break;
@@ -357,7 +357,7 @@ ERRORCODE CAdItem::update() { _sentence->update();
if (_sentence->_currentSprite) _tempSprite2 = _sentence->_currentSprite;
- bool TimeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->isPlaying() && !_sentence->_sound->isPaused())) || (!_sentence->_sound && _sentence->_duration <= Game->_timer - _sentence->_startTime);
+ bool TimeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->isPlaying() && !_sentence->_sound->isPaused())) || (!_sentence->_sound && _sentence->_duration <= _gameRef->_timer - _sentence->_startTime);
if (_tempSprite2 == NULL || _tempSprite2->_finished || (/*_tempSprite2->_looping &&*/ TimeIsUp)) {
if (TimeIsUp) {
_sentence->finish();
@@ -369,11 +369,11 @@ ERRORCODE CAdItem::update() { _tempSprite2->reset();
_currentSprite = _tempSprite2;
}
- ((CAdGame *)Game)->addSentence(_sentence);
+ ((CAdGame *)_gameRef)->addSentence(_sentence);
}
} else {
_currentSprite = _tempSprite2;
- ((CAdGame *)Game)->addSentence(_sentence);
+ ((CAdGame *)_gameRef)->addSentence(_sentence);
}
}
default:
@@ -412,7 +412,7 @@ ERRORCODE CAdItem::display(int x, int y) { }
amountX += _amountOffsetX;
- CBFont *font = _font ? _font : Game->_systemFont;
+ CBFont *font = _font ? _font : _gameRef->_systemFont;
if (font) {
if (_amountString) font->drawText((byte *)_amountString, amountX, amountY, width, _amountAlign);
else {
@@ -444,7 +444,7 @@ ERRORCODE CAdItem::scCallMethod(CScScript *script, CScStack *stack, CScStack *th delete _spriteHover;
_spriteHover = NULL;
- CBSprite *spr = new CBSprite(Game, this);
+ CBSprite *spr = new CBSprite(_gameRef, this);
if (!spr || DID_FAIL(spr->loadFile(filename))) {
stack->pushBool(false);
script->runtimeError("Item.SetHoverSprite failed for file '%s'", filename);
@@ -487,7 +487,7 @@ ERRORCODE CAdItem::scCallMethod(CScScript *script, CScStack *stack, CScStack *th delete _cursorNormal;
_cursorNormal = NULL;
- CBSprite *spr = new CBSprite(Game);
+ CBSprite *spr = new CBSprite(_gameRef);
if (!spr || DID_FAIL(spr->loadFile(filename))) {
stack->pushBool(false);
script->runtimeError("Item.SetNormalCursor failed for file '%s'", filename);
@@ -530,7 +530,7 @@ ERRORCODE CAdItem::scCallMethod(CScScript *script, CScStack *stack, CScStack *th delete _cursorHover;
_cursorHover = NULL;
- CBSprite *spr = new CBSprite(Game);
+ CBSprite *spr = new CBSprite(_gameRef);
if (!spr || DID_FAIL(spr->loadFile(filename))) {
stack->pushBool(false);
script->runtimeError("Item.SetHoverCursor failed for file '%s'", filename);
diff --git a/engines/wintermute/Ad/AdLayer.cpp b/engines/wintermute/Ad/AdLayer.cpp index fd37d21550..b7d8eb3cc2 100644 --- a/engines/wintermute/Ad/AdLayer.cpp +++ b/engines/wintermute/Ad/AdLayer.cpp @@ -62,9 +62,9 @@ CAdLayer::~CAdLayer() { //////////////////////////////////////////////////////////////////////////
ERRORCODE CAdLayer::loadFile(const char *filename) {
- byte *buffer = Game->_fileManager->readWholeFile(filename);
+ byte *buffer = _gameRef->_fileManager->readWholeFile(filename);
if (buffer == NULL) {
- Game->LOG(0, "CAdLayer::LoadFile failed for file '%s'", filename);
+ _gameRef->LOG(0, "CAdLayer::LoadFile failed for file '%s'", filename);
return STATUS_FAILED;
}
@@ -73,7 +73,7 @@ ERRORCODE CAdLayer::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 LAYER file '%s'", filename);
+ if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing LAYER file '%s'", filename);
delete [] buffer;
@@ -120,11 +120,11 @@ ERRORCODE CAdLayer::loadBuffer(byte *buffer, bool complete) { byte *params;
int cmd;
- CBParser parser(Game);
+ CBParser parser(_gameRef);
if (complete) {
if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_LAYER) {
- Game->LOG(0, "'LAYER' keyword expected.");
+ _gameRef->LOG(0, "'LAYER' keyword expected.");
return STATUS_FAILED;
}
buffer = params;
@@ -165,8 +165,8 @@ ERRORCODE CAdLayer::loadBuffer(byte *buffer, bool complete) { break;
case TOKEN_REGION: {
- CAdRegion *region = new CAdRegion(Game);
- CAdSceneNode *node = new CAdSceneNode(Game);
+ CAdRegion *region = new CAdRegion(_gameRef);
+ CAdSceneNode *node = new CAdSceneNode(_gameRef);
if (!region || !node || DID_FAIL(region->loadBuffer(params, false))) {
cmd = PARSERR_GENERIC;
delete region;
@@ -181,8 +181,8 @@ ERRORCODE CAdLayer::loadBuffer(byte *buffer, bool complete) { break;
case TOKEN_ENTITY: {
- CAdEntity *entity = new CAdEntity(Game);
- CAdSceneNode *node = new CAdSceneNode(Game);
+ CAdEntity *entity = new CAdEntity(_gameRef);
+ CAdSceneNode *node = new CAdSceneNode(_gameRef);
if (entity) entity->_zoomable = false; // scene entites default to NOT zoom
if (!entity || !node || DID_FAIL(entity->loadBuffer(params, false))) {
cmd = PARSERR_GENERIC;
@@ -215,7 +215,7 @@ ERRORCODE CAdLayer::loadBuffer(byte *buffer, bool complete) { }
}
if (cmd == PARSERR_TOKENNOTFOUND) {
- Game->LOG(0, "Syntax error in LAYER definition");
+ _gameRef->LOG(0, "Syntax error in LAYER definition");
return STATUS_FAILED;
}
@@ -269,14 +269,14 @@ ERRORCODE CAdLayer::scCallMethod(CScScript *script, CScStack *stack, CScStack *t stack->correctParams(1);
CScValue *val = stack->pop();
- CAdSceneNode *node = new CAdSceneNode(Game);
+ CAdSceneNode *node = new CAdSceneNode(_gameRef);
if (strcmp(name, "AddRegion") == 0) {
- CAdRegion *region = new CAdRegion(Game);
+ CAdRegion *region = new CAdRegion(_gameRef);
if (!val->isNULL()) region->setName(val->getString());
node->setRegion(region);
stack->pushNative(region, true);
} else {
- CAdEntity *entity = new CAdEntity(Game);
+ CAdEntity *entity = new CAdEntity(_gameRef);
if (!val->isNULL()) entity->setName(val->getString());
node->setEntity(entity);
stack->pushNative(entity, true);
@@ -293,14 +293,14 @@ ERRORCODE CAdLayer::scCallMethod(CScScript *script, CScStack *stack, CScStack *t int index = stack->pop()->getInt();
CScValue *val = stack->pop();
- CAdSceneNode *node = new CAdSceneNode(Game);
+ CAdSceneNode *node = new CAdSceneNode(_gameRef);
if (strcmp(name, "InsertRegion") == 0) {
- CAdRegion *region = new CAdRegion(Game);
+ CAdRegion *region = new CAdRegion(_gameRef);
if (!val->isNULL()) region->setName(val->getString());
node->setRegion(region);
stack->pushNative(region, true);
} else {
- CAdEntity *entity = new CAdEntity(Game);
+ CAdEntity *entity = new CAdEntity(_gameRef);
if (!val->isNULL()) entity->setName(val->getString());
node->setEntity(entity);
stack->pushNative(entity, true);
@@ -461,7 +461,7 @@ ERRORCODE CAdLayer::scSetProperty(const char *name, CScValue *value) { else if (strcmp(name, "Active") == 0) {
bool b = value->getBool();
if (b == false && _main) {
- Game->LOG(0, "Warning: cannot deactivate scene's main layer");
+ _gameRef->LOG(0, "Warning: cannot deactivate scene's main layer");
} else _active = b;
return STATUS_OK;
}
diff --git a/engines/wintermute/Ad/AdNodeState.cpp b/engines/wintermute/Ad/AdNodeState.cpp index 7c190285ae..6d96c041a1 100644 --- a/engines/wintermute/Ad/AdNodeState.cpp +++ b/engines/wintermute/Ad/AdNodeState.cpp @@ -93,7 +93,7 @@ void CAdNodeState::setCursor(const char *filename) { //////////////////////////////////////////////////////////////////////////
ERRORCODE CAdNodeState::persist(CBPersistMgr *persistMgr) {
- persistMgr->transfer(TMEMBER(Game));
+ persistMgr->transfer(TMEMBER(_gameRef));
persistMgr->transfer(TMEMBER(_active));
persistMgr->transfer(TMEMBER(_name));
@@ -115,7 +115,7 @@ void CAdNodeState::setCaption(const char *caption, int caseVal) { _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]);
}
}
@@ -133,7 +133,7 @@ ERRORCODE CAdNodeState::transferEntity(CAdEntity *entity, bool includingSprites, if (!entity) return STATUS_FAILED;
// hack!
- if (this->Game != entity->Game) this->Game = entity->Game;
+ if (this->_gameRef != entity->_gameRef) this->_gameRef = entity->_gameRef;
if (saving) {
for (int i = 0; i < 7; i++) {
diff --git a/engines/wintermute/Ad/AdObject.cpp b/engines/wintermute/Ad/AdObject.cpp index 2f536cd74a..3321e5871f 100644 --- a/engines/wintermute/Ad/AdObject.cpp +++ b/engines/wintermute/Ad/AdObject.cpp @@ -127,24 +127,24 @@ CAdObject::~CAdObject() { _tempSprite2 = NULL; // reference only
_stickRegion = NULL;
- if (_font) Game->_fontStorage->removeFont(_font);
+ if (_font) _gameRef->_fontStorage->removeFont(_font);
if (_inventory) {
- ((CAdGame *)Game)->unregisterInventory(_inventory);
+ ((CAdGame *)_gameRef)->unregisterInventory(_inventory);
_inventory = NULL;
}
if (_partEmitter)
- Game->unregisterObject(_partEmitter);
+ _gameRef->unregisterObject(_partEmitter);
for (int i = 0; i < _attachmentsPre.getSize(); i++) {
- Game->unregisterObject(_attachmentsPre[i]);
+ _gameRef->unregisterObject(_attachmentsPre[i]);
}
_attachmentsPre.removeAll();
for (int i = 0; i < _attachmentsPost.getSize(); i++) {
- Game->unregisterObject(_attachmentsPost[i]);
+ _gameRef->unregisterObject(_attachmentsPost[i]);
}
_attachmentsPost.removeAll();
}
@@ -154,14 +154,14 @@ CAdObject::~CAdObject() { ERRORCODE CAdObject::playAnim(const char *filename) {
delete _animSprite;
_animSprite = NULL;
- _animSprite = new CBSprite(Game, this);
+ _animSprite = new CBSprite(_gameRef, this);
if (!_animSprite) {
- Game->LOG(0, "CAdObject::PlayAnim: error creating temp sprite (object:\"%s\" sprite:\"%s\")", _name, filename);
+ _gameRef->LOG(0, "CAdObject::PlayAnim: error creating temp sprite (object:\"%s\" sprite:\"%s\")", _name, filename);
return STATUS_FAILED;
}
ERRORCODE res = _animSprite->loadFile(filename);
if (DID_FAIL(res)) {
- Game->LOG(res, "CAdObject::PlayAnim: error loading temp sprite (object:\"%s\" sprite:\"%s\")", _name, filename);
+ _gameRef->LOG(res, "CAdObject::PlayAnim: error loading temp sprite (object:\"%s\" sprite:\"%s\")", _name, filename);
delete _animSprite;
_animSprite = NULL;
return res;
@@ -285,7 +285,7 @@ ERRORCODE CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack * else if (strcmp(name, "StickToRegion") == 0) {
stack->correctParams(1);
- CAdLayer *main = ((CAdGame *)Game)->_scene->_mainLayer;
+ CAdLayer *main = ((CAdGame *)_gameRef)->_scene->_mainLayer;
bool regFound = false;
int i;
@@ -351,8 +351,8 @@ ERRORCODE CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack * stack->correctParams(2);
if (!_inventory) {
- _inventory = new CAdInventory(Game);
- ((CAdGame *)Game)->registerInventory(_inventory);
+ _inventory = new CAdInventory(_gameRef);
+ ((CAdGame *)_gameRef)->registerInventory(_inventory);
}
CScValue *val = stack->pop();
@@ -363,7 +363,7 @@ ERRORCODE CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack * if (DID_FAIL(_inventory->insertItem(itemName, insertAfter))) script->runtimeError("Cannot add item '%s' to inventory", itemName);
else {
// hide associated entities
- ((CAdGame *)Game)->_scene->handleItemAssociations(itemName, false);
+ ((CAdGame *)_gameRef)->_scene->handleItemAssociations(itemName, false);
}
} else script->runtimeError("TakeItem: item name expected");
@@ -379,8 +379,8 @@ ERRORCODE CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack * stack->correctParams(1);
if (!_inventory) {
- _inventory = new CAdInventory(Game);
- ((CAdGame *)Game)->registerInventory(_inventory);
+ _inventory = new CAdInventory(_gameRef);
+ ((CAdGame *)_gameRef)->registerInventory(_inventory);
}
CScValue *val = stack->pop();
@@ -388,7 +388,7 @@ ERRORCODE CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack * if (DID_FAIL(_inventory->removeItem(val->getString()))) script->runtimeError("Cannot remove item '%s' from inventory", val->getString());
else {
// show associated entities
- ((CAdGame *)Game)->_scene->handleItemAssociations(val->getString(), true);
+ ((CAdGame *)_gameRef)->_scene->handleItemAssociations(val->getString(), true);
}
} else script->runtimeError("DropItem: item name expected");
@@ -403,13 +403,13 @@ ERRORCODE CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack * stack->correctParams(1);
if (!_inventory) {
- _inventory = new CAdInventory(Game);
- ((CAdGame *)Game)->registerInventory(_inventory);
+ _inventory = new CAdInventory(_gameRef);
+ ((CAdGame *)_gameRef)->registerInventory(_inventory);
}
CScValue *val = stack->pop();
if (val->_type == VAL_STRING) {
- CAdItem *item = ((CAdGame *)Game)->getItemByName(val->getString());
+ CAdItem *item = ((CAdGame *)_gameRef)->getItemByName(val->getString());
if (item) stack->pushNative(item, true);
else stack->pushNULL();
} else if (val->isNULL() || val->getInt() < 0 || val->getInt() >= _inventory->_takenItems.getSize())
@@ -427,8 +427,8 @@ ERRORCODE CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack * stack->correctParams(1);
if (!_inventory) {
- _inventory = new CAdInventory(Game);
- ((CAdGame *)Game)->registerInventory(_inventory);
+ _inventory = new CAdInventory(_gameRef);
+ ((CAdGame *)_gameRef)->registerInventory(_inventory);
}
CScValue *val = stack->pop();
@@ -470,7 +470,7 @@ ERRORCODE CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack * else if (strcmp(name, "DeleteParticleEmitter") == 0) {
stack->correctParams(0);
if (_partEmitter) {
- Game->unregisterObject(_partEmitter);
+ _gameRef->unregisterObject(_partEmitter);
_partEmitter = NULL;
}
stack->pushNULL();
@@ -489,14 +489,14 @@ ERRORCODE CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack * int offsetY = stack->pop()->getInt();
ERRORCODE res;
- CAdEntity *ent = new CAdEntity(Game);
+ CAdEntity *ent = new CAdEntity(_gameRef);
if (DID_FAIL(res = ent->loadFile(filename))) {
delete ent;
ent = NULL;
script->runtimeError("AddAttachment() failed loading entity '%s'", filename);
stack->pushBool(false);
} else {
- Game->registerObject(ent);
+ _gameRef->registerObject(ent);
ent->_posX = offsetX;
ent->_posY = offsetY;
@@ -523,7 +523,7 @@ ERRORCODE CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack * for (int i = 0; i < _attachmentsPre.getSize(); i++) {
if (_attachmentsPre[i] == obj) {
found = true;
- Game->unregisterObject(_attachmentsPre[i]);
+ _gameRef->unregisterObject(_attachmentsPre[i]);
_attachmentsPre.removeAt(i);
i--;
}
@@ -531,7 +531,7 @@ ERRORCODE CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack * for (int i = 0; i < _attachmentsPost.getSize(); i++) {
if (_attachmentsPost[i] == obj) {
found = true;
- Game->unregisterObject(_attachmentsPost[i]);
+ _gameRef->unregisterObject(_attachmentsPost[i]);
_attachmentsPost.removeAt(i);
i--;
}
@@ -541,7 +541,7 @@ ERRORCODE CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack * for (int i = 0; i < _attachmentsPre.getSize(); i++) {
if (_attachmentsPre[i]->_name && scumm_stricmp(_attachmentsPre[i]->_name, attachmentName) == 0) {
found = true;
- Game->unregisterObject(_attachmentsPre[i]);
+ _gameRef->unregisterObject(_attachmentsPre[i]);
_attachmentsPre.removeAt(i);
i--;
}
@@ -549,7 +549,7 @@ ERRORCODE CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack * for (int i = 0; i < _attachmentsPost.getSize(); i++) {
if (_attachmentsPost[i]->_name && scumm_stricmp(_attachmentsPost[i]->_name, attachmentName) == 0) {
found = true;
- Game->unregisterObject(_attachmentsPost[i]);
+ _gameRef->unregisterObject(_attachmentsPost[i]);
_attachmentsPost.removeAt(i);
i--;
}
@@ -793,9 +793,9 @@ const char *CAdObject::scToString() { //////////////////////////////////////////////////////////////////////////
ERRORCODE CAdObject::SetFont(const char *filename) {
- if (_font) Game->_fontStorage->removeFont(_font);
+ if (_font) _gameRef->_fontStorage->removeFont(_font);
if (filename) {
- _font = Game->_fontStorage->addFont(filename);
+ _font = _gameRef->_fontStorage->addFont(filename);
return _font == NULL ? STATUS_FAILED : STATUS_OK;
} else {
_font = NULL;
@@ -815,7 +815,7 @@ int CAdObject::getHeight() { }
if (_zoomable) {
- float zoom = ((CAdGame *)Game)->_scene->getZoomAt(_posX, _posY);
+ float zoom = ((CAdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY);
ret = (int)(ret * zoom / 100);
}
return ret;
@@ -825,7 +825,7 @@ int CAdObject::getHeight() { //////////////////////////////////////////////////////////////////////////
void CAdObject::talk(const char *text, const char *sound, uint32 duration, const char *stances, TTextAlign Align) {
- if (!_sentence) _sentence = new CAdSentence(Game);
+ if (!_sentence) _sentence = new CAdSentence(_gameRef);
if (!_sentence) return;
if (_forcedTalkAnimName && _forcedTalkAnimUsed) {
@@ -838,21 +838,21 @@ void CAdObject::talk(const char *text, const char *sound, uint32 duration, const _sentence->_sound = NULL;
_sentence->setText(text);
- Game->_stringTable->expand(&_sentence->_text);
+ _gameRef->_stringTable->expand(&_sentence->_text);
_sentence->setStances(stances);
_sentence->_duration = duration;
_sentence->_align = Align;
- _sentence->_startTime = Game->_timer;
+ _sentence->_startTime = _gameRef->_timer;
_sentence->_currentStance = -1;
- _sentence->_font = _font == NULL ? Game->_systemFont : _font;
+ _sentence->_font = _font == NULL ? _gameRef->_systemFont : _font;
_sentence->_freezable = _freezable;
// try to locate speech file automatically
bool deleteSound = false;
if (!sound) {
- char *key = Game->_stringTable->getKey(text);
+ char *key = _gameRef->_stringTable->getKey(text);
if (key) {
- sound = ((CAdGame *)Game)->findSpeechFile(key);
+ sound = ((CAdGame *)_gameRef)->findSpeechFile(key);
delete [] key;
if (sound) deleteSound = true;
@@ -861,7 +861,7 @@ void CAdObject::talk(const char *text, const char *sound, uint32 duration, const // load sound and set duration appropriately
if (sound) {
- CBSound *snd = new CBSound(Game);
+ CBSound *snd = new CBSound(_gameRef);
if (snd && DID_SUCCEED(snd->setSound(sound, Audio::Mixer::kSpeechSoundType, true))) {
_sentence->setSound(snd);
if (_sentence->_duration <= 0) {
@@ -873,7 +873,7 @@ void CAdObject::talk(const char *text, const char *sound, uint32 duration, const // set duration by text length
if (_sentence->_duration <= 0) {// TODO: Avoid longs.
- _sentence->_duration = MAX((size_t)1000, Game->_subtitlesSpeed * strlen(_sentence->_text));
+ _sentence->_duration = MAX((size_t)1000, _gameRef->_subtitlesSpeed * strlen(_sentence->_text));
}
@@ -883,16 +883,16 @@ void CAdObject::talk(const char *text, const char *sound, uint32 duration, const y = _posY;
if (!_sceneIndependent && _subtitlesModRelative) {
- x -= ((CAdGame *)Game)->_scene->getOffsetLeft();
- y -= ((CAdGame *)Game)->_scene->getOffsetTop();
+ x -= ((CAdGame *)_gameRef)->_scene->getOffsetLeft();
+ y -= ((CAdGame *)_gameRef)->_scene->getOffsetTop();
}
if (_subtitlesWidth > 0) width = _subtitlesWidth;
else {
- if ((x < Game->_renderer->_width / 4 || x > Game->_renderer->_width * 0.75) && !Game->_touchInterface) {
- width = MAX(Game->_renderer->_width / 4, MIN(x * 2, (Game->_renderer->_width - x) * 2));
- } else width = Game->_renderer->_width / 2;
+ if ((x < _gameRef->_renderer->_width / 4 || x > _gameRef->_renderer->_width * 0.75) && !_gameRef->_touchInterface) {
+ width = MAX(_gameRef->_renderer->_width / 4, MIN(x * 2, (_gameRef->_renderer->_width - x) * 2));
+ } else width = _gameRef->_renderer->_width / 2;
}
height = _sentence->_font->getTextHeight((byte *)_sentence->_text, width);
@@ -909,8 +909,8 @@ void CAdObject::talk(const char *text, const char *sound, uint32 duration, const x = x - width / 2;
- x = MIN(MAX(0, x), Game->_renderer->_width - width);
- y = MIN(MAX(0, y), Game->_renderer->_height - height);
+ x = MIN(MAX(0, x), _gameRef->_renderer->_width - width);
+ y = MIN(MAX(0, y), _gameRef->_renderer->_height - height);
_sentence->_width = width;
@@ -920,8 +920,8 @@ void CAdObject::talk(const char *text, const char *sound, uint32 duration, const if (_subtitlesModRelative) {
- _sentence->_pos.x += ((CAdGame *)Game)->_scene->getOffsetLeft();
- _sentence->_pos.y += ((CAdGame *)Game)->_scene->getOffsetTop();
+ _sentence->_pos.x += ((CAdGame *)_gameRef)->_scene->getOffsetLeft();
+ _sentence->_pos.y += ((CAdGame *)_gameRef)->_scene->getOffsetTop();
}
_sentence->_fixedPos = !_subtitlesModRelative;
@@ -946,7 +946,7 @@ ERRORCODE CAdObject::reset() { _state = _nextState = STATE_READY;
- Game->_scEngine->resetObject(this);
+ _gameRef->_scEngine->resetObject(this);
return STATUS_OK;
}
@@ -1037,7 +1037,7 @@ ERRORCODE CAdObject::saveAsText(CBDynBuffer *buffer, int indent) { //////////////////////////////////////////////////////////////////////////
ERRORCODE CAdObject::updateBlockRegion() {
- CAdGame *adGame = (CAdGame *)Game;
+ CAdGame *adGame = (CAdGame *)_gameRef;
if (adGame->_scene) {
if (_blockRegion && _currentBlockRegion)
_currentBlockRegion->mimic(_blockRegion, _zoomable ? adGame->_scene->getScaleAt(_posY) : 100.0f, _posX, _posY);
@@ -1051,8 +1051,8 @@ ERRORCODE CAdObject::updateBlockRegion() { //////////////////////////////////////////////////////////////////////////
CAdInventory *CAdObject::getInventory() {
if (!_inventory) {
- _inventory = new CAdInventory(Game);
- ((CAdGame *)Game)->registerInventory(_inventory);
+ _inventory = new CAdInventory(_gameRef);
+ ((CAdGame *)_gameRef)->registerInventory(_inventory);
}
return _inventory;
}
@@ -1062,7 +1062,7 @@ CAdInventory *CAdObject::getInventory() { ERRORCODE CAdObject::afterMove() {
CAdRegion *newRegions[MAX_NUM_REGIONS];
- ((CAdGame *)Game)->_scene->getRegionsAt(_posX, _posY, newRegions, MAX_NUM_REGIONS);
+ ((CAdGame *)_gameRef)->_scene->getRegionsAt(_posX, _posY, newRegions, MAX_NUM_REGIONS);
for (int i = 0; i < MAX_NUM_REGIONS; i++) {
if (!newRegions[i]) break;
bool regFound = false;
@@ -1077,7 +1077,7 @@ ERRORCODE CAdObject::afterMove() { }
for (int i = 0; i < MAX_NUM_REGIONS; i++) {
- if (_currentRegions[i] && Game->validObject(_currentRegions[i])) {
+ if (_currentRegions[i] && _gameRef->validObject(_currentRegions[i])) {
_currentRegions[i]->applyEvent("ActorLeave");
}
_currentRegions[i] = newRegions[i];
@@ -1100,7 +1100,7 @@ ERRORCODE CAdObject::getScale(float *scaleX, float *scaleY) { *scaleX = _scaleX < 0 ? 100 : _scaleX;
*scaleY = _scaleY < 0 ? 100 : _scaleY;
} else if (_scale >= 0) *scaleX = *scaleY = _scale;
- else *scaleX = *scaleY = ((CAdGame *)Game)->_scene->getZoomAt(_posX, _posY) + _relativeScale;
+ else *scaleX = *scaleY = ((CAdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) + _relativeScale;
} else {
*scaleX = *scaleY = 100;
}
@@ -1177,9 +1177,9 @@ CPartEmitter *CAdObject::createParticleEmitter(bool followParent, int offsetX, i _partOffsetY = offsetY;
if (!_partEmitter) {
- _partEmitter = new CPartEmitter(Game, this);
+ _partEmitter = new CPartEmitter(_gameRef, this);
if (_partEmitter) {
- Game->registerObject(_partEmitter);
+ _gameRef->registerObject(_partEmitter);
}
}
updatePartEmitter();
diff --git a/engines/wintermute/Ad/AdPath.cpp b/engines/wintermute/Ad/AdPath.cpp index 5ce603609f..0aced4cabc 100644 --- a/engines/wintermute/Ad/AdPath.cpp +++ b/engines/wintermute/Ad/AdPath.cpp @@ -100,7 +100,7 @@ bool CAdPath::setReady(bool ready) { //////////////////////////////////////////////////////////////////////////
ERRORCODE CAdPath::persist(CBPersistMgr *persistMgr) {
- persistMgr->transfer(TMEMBER(Game));
+ persistMgr->transfer(TMEMBER(_gameRef));
persistMgr->transfer(TMEMBER(_currIndex));
_points.persist(persistMgr);
diff --git a/engines/wintermute/Ad/AdRegion.cpp b/engines/wintermute/Ad/AdRegion.cpp index 5ca4a56367..a37386e7b3 100644 --- a/engines/wintermute/Ad/AdRegion.cpp +++ b/engines/wintermute/Ad/AdRegion.cpp @@ -55,9 +55,9 @@ CAdRegion::~CAdRegion() { //////////////////////////////////////////////////////////////////////////
ERRORCODE CAdRegion::loadFile(const char *filename) {
- byte *buffer = Game->_fileManager->readWholeFile(filename);
+ byte *buffer = _gameRef->_fileManager->readWholeFile(filename);
if (buffer == NULL) {
- Game->LOG(0, "CAdRegion::LoadFile failed for file '%s'", filename);
+ _gameRef->LOG(0, "CAdRegion::LoadFile failed for file '%s'", filename);
return STATUS_FAILED;
}
@@ -66,7 +66,7 @@ ERRORCODE CAdRegion::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;
@@ -118,11 +118,11 @@ ERRORCODE CAdRegion::loadBuffer(byte *buffer, bool complete) { byte *params;
int cmd;
- CBParser parser(Game);
+ CBParser parser(_gameRef);
if (complete) {
if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_REGION) {
- Game->LOG(0, "'REGION' keyword expected.");
+ _gameRef->LOG(0, "'REGION' keyword expected.");
return STATUS_FAILED;
}
buffer = params;
@@ -204,7 +204,7 @@ ERRORCODE CAdRegion::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/Ad/AdResponse.cpp b/engines/wintermute/Ad/AdResponse.cpp index 0b0bea2f57..0fd2245282 100644 --- a/engines/wintermute/Ad/AdResponse.cpp +++ b/engines/wintermute/Ad/AdResponse.cpp @@ -60,7 +60,7 @@ CAdResponse::~CAdResponse() { _icon = NULL;
_iconHover = NULL;
_iconPressed = NULL;
- if (_font) Game->_fontStorage->removeFont(_font);
+ if (_font) _gameRef->_fontStorage->removeFont(_font);
}
@@ -74,9 +74,9 @@ void CAdResponse::setText(const char *text) { //////////////////////////////////////////////////////////////////////////
ERRORCODE CAdResponse::setIcon(const char *filename) {
delete _icon;
- _icon = new CBSprite(Game);
+ _icon = new CBSprite(_gameRef);
if (!_icon || DID_FAIL(_icon->loadFile(filename))) {
- Game->LOG(0, "CAdResponse::setIcon failed for file '%s'", filename);
+ _gameRef->LOG(0, "CAdResponse::setIcon failed for file '%s'", filename);
delete _icon;
_icon = NULL;
return STATUS_FAILED;
@@ -86,10 +86,10 @@ ERRORCODE CAdResponse::setIcon(const char *filename) { //////////////////////////////////////////////////////////////////////////
ERRORCODE CAdResponse::setFont(const char *filename) {
- if (_font) Game->_fontStorage->removeFont(_font);
- _font = Game->_fontStorage->addFont(filename);
+ if (_font) _gameRef->_fontStorage->removeFont(_font);
+ _font = _gameRef->_fontStorage->addFont(filename);
if (!_font) {
- Game->LOG(0, "CAdResponse::setFont failed for file '%s'", filename);
+ _gameRef->LOG(0, "CAdResponse::setFont failed for file '%s'", filename);
return STATUS_FAILED;
}
return STATUS_OK;
@@ -98,9 +98,9 @@ ERRORCODE CAdResponse::setFont(const char *filename) { //////////////////////////////////////////////////////////////////////////
ERRORCODE CAdResponse::setIconHover(const char *filename) {
delete _iconHover;
- _iconHover = new CBSprite(Game);
+ _iconHover = new CBSprite(_gameRef);
if (!_iconHover || DID_FAIL(_iconHover->loadFile(filename))) {
- Game->LOG(0, "CAdResponse::setIconHover failed for file '%s'", filename);
+ _gameRef->LOG(0, "CAdResponse::setIconHover failed for file '%s'", filename);
delete _iconHover;
_iconHover = NULL;
return STATUS_FAILED;
@@ -112,9 +112,9 @@ ERRORCODE CAdResponse::setIconHover(const char *filename) { //////////////////////////////////////////////////////////////////////////
ERRORCODE CAdResponse::setIconPressed(const char *filename) {
delete _iconPressed;
- _iconPressed = new CBSprite(Game);
+ _iconPressed = new CBSprite(_gameRef);
if (!_iconPressed || DID_FAIL(_iconPressed->loadFile(filename))) {
- Game->LOG(0, "CAdResponse::setIconPressed failed for file '%s'", filename);
+ _gameRef->LOG(0, "CAdResponse::setIconPressed failed for file '%s'", filename);
delete _iconPressed;
_iconPressed = NULL;
return STATUS_FAILED;
diff --git a/engines/wintermute/Ad/AdResponseBox.cpp b/engines/wintermute/Ad/AdResponseBox.cpp index c055c2f363..ef9d3a32c6 100644 --- a/engines/wintermute/Ad/AdResponseBox.cpp +++ b/engines/wintermute/Ad/AdResponseBox.cpp @@ -54,7 +54,7 @@ CAdResponseBox::CAdResponseBox(CBGame *inGame): CBObject(inGame) { _font = _fontHover = NULL;
_window = NULL;
- _shieldWindow = new CUIWindow(Game);
+ _shieldWindow = new CUIWindow(_gameRef);
_horizontal = false;
CBPlatform::setRectEmpty(&_responseArea);
@@ -82,8 +82,8 @@ CAdResponseBox::~CAdResponseBox() { delete[] _lastResponseTextOrig;
_lastResponseTextOrig = NULL;
- if (_font) Game->_fontStorage->removeFont(_font);
- if (_fontHover) Game->_fontStorage->removeFont(_fontHover);
+ if (_font) _gameRef->_fontStorage->removeFont(_font);
+ if (_fontHover) _gameRef->_fontStorage->removeFont(_fontHover);
clearResponses();
clearButtons();
@@ -130,7 +130,7 @@ ERRORCODE CAdResponseBox::createButtons() { _scrollOffset = 0;
for (int i = 0; i < _responses.getSize(); i++) {
- CUIButton *btn = new CUIButton(Game);
+ CUIButton *btn = new CUIButton(_gameRef);
if (btn) {
btn->_parent = _window;
btn->_sharedFonts = btn->_sharedImages = true;
@@ -143,30 +143,30 @@ ERRORCODE CAdResponseBox::createButtons() { btn->setCaption(_responses[i]->_text);
if (_cursor) btn->_cursor = _cursor;
- else if (Game->_activeCursor) btn->_cursor = Game->_activeCursor;
+ else if (_gameRef->_activeCursor) btn->_cursor = _gameRef->_activeCursor;
}
// textual
else {
btn->setText(_responses[i]->_text);
- btn->_font = (_font == NULL) ? Game->_systemFont : _font;
- btn->_fontHover = (_fontHover == NULL) ? Game->_systemFont : _fontHover;
+ btn->_font = (_font == NULL) ? _gameRef->_systemFont : _font;
+ btn->_fontHover = (_fontHover == NULL) ? _gameRef->_systemFont : _fontHover;
btn->_fontPress = btn->_fontHover;
btn->_align = _align;
- if (Game->_touchInterface)
+ if (_gameRef->_touchInterface)
btn->_fontHover = btn->_font;
if (_responses[i]->_font) btn->_font = _responses[i]->_font;
btn->_width = _responseArea.right - _responseArea.left;
- if (btn->_width <= 0) btn->_width = Game->_renderer->_width;
+ if (btn->_width <= 0) btn->_width = _gameRef->_renderer->_width;
}
btn->setName("response");
btn->correctSize();
// make the responses touchable
- if (Game->_touchInterface)
+ if (_gameRef->_touchInterface)
btn->_height = MAX(btn->_height, 50);
//btn->SetListener(this, btn, _responses[i]->_iD);
@@ -175,7 +175,7 @@ ERRORCODE CAdResponseBox::createButtons() { _respButtons.add(btn);
if (_responseArea.bottom - _responseArea.top < btn->_height) {
- Game->LOG(0, "Warning: Response '%s' is too high to be displayed within response box. Correcting.", _responses[i]->_text);
+ _gameRef->LOG(0, "Warning: Response '%s' is too high to be displayed within response box. Correcting.", _responses[i]->_text);
_responseArea.bottom += (btn->_height - (_responseArea.bottom - _responseArea.top));
}
}
@@ -188,9 +188,9 @@ ERRORCODE CAdResponseBox::createButtons() { //////////////////////////////////////////////////////////////////////////
ERRORCODE CAdResponseBox::loadFile(const char *filename) {
- byte *buffer = Game->_fileManager->readWholeFile(filename);
+ byte *buffer = _gameRef->_fileManager->readWholeFile(filename);
if (buffer == NULL) {
- Game->LOG(0, "CAdResponseBox::LoadFile failed for file '%s'", filename);
+ _gameRef->LOG(0, "CAdResponseBox::LoadFile failed for file '%s'", filename);
return STATUS_FAILED;
}
@@ -199,7 +199,7 @@ ERRORCODE CAdResponseBox::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 RESPONSE_BOX file '%s'", filename);
+ if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing RESPONSE_BOX file '%s'", filename);
delete [] buffer;
@@ -242,11 +242,11 @@ ERRORCODE CAdResponseBox::loadBuffer(byte *buffer, bool complete) { byte *params;
int cmd;
- CBParser parser(Game);
+ CBParser parser(_gameRef);
if (complete) {
if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_RESPONSE_BOX) {
- Game->LOG(0, "'RESPONSE_BOX' keyword expected.");
+ _gameRef->LOG(0, "'RESPONSE_BOX' keyword expected.");
return STATUS_FAILED;
}
buffer = params;
@@ -260,7 +260,7 @@ ERRORCODE CAdResponseBox::loadBuffer(byte *buffer, bool complete) { case TOKEN_WINDOW:
delete _window;
- _window = new CUIWindow(Game);
+ _window = new CUIWindow(_gameRef);
if (!_window || DID_FAIL(_window->loadBuffer(params, false))) {
delete _window;
_window = NULL;
@@ -269,14 +269,14 @@ ERRORCODE CAdResponseBox::loadBuffer(byte *buffer, bool complete) { break;
case TOKEN_FONT:
- if (_font) Game->_fontStorage->removeFont(_font);
- _font = Game->_fontStorage->addFont((char *)params);
+ if (_font) _gameRef->_fontStorage->removeFont(_font);
+ _font = _gameRef->_fontStorage->addFont((char *)params);
if (!_font) cmd = PARSERR_GENERIC;
break;
case TOKEN_FONT_HOVER:
- if (_fontHover) Game->_fontStorage->removeFont(_fontHover);
- _fontHover = Game->_fontStorage->addFont((char *)params);
+ if (_fontHover) _gameRef->_fontStorage->removeFont(_fontHover);
+ _fontHover = _gameRef->_fontStorage->addFont((char *)params);
if (!_fontHover) cmd = PARSERR_GENERIC;
break;
@@ -310,7 +310,7 @@ ERRORCODE CAdResponseBox::loadBuffer(byte *buffer, bool complete) { 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;
@@ -320,7 +320,7 @@ ERRORCODE CAdResponseBox::loadBuffer(byte *buffer, bool complete) { }
}
if (cmd == PARSERR_TOKENNOTFOUND) {
- Game->LOG(0, "Syntax error in RESPONSE_BOX definition");
+ _gameRef->LOG(0, "Syntax error in RESPONSE_BOX definition");
return STATUS_FAILED;
}
@@ -462,8 +462,8 @@ ERRORCODE CAdResponseBox::display() { // go exclusive
if (_shieldWindow) {
_shieldWindow->_posX = _shieldWindow->_posY = 0;
- _shieldWindow->_width = Game->_renderer->_width;
- _shieldWindow->_height = Game->_renderer->_height;
+ _shieldWindow->_width = _gameRef->_renderer->_width;
+ _shieldWindow->_height = _gameRef->_renderer->_height;
_shieldWindow->display();
}
@@ -495,8 +495,8 @@ ERRORCODE CAdResponseBox::listen(CBScriptHolder *param1, uint32 param2) { if (_waitingScript) _waitingScript->_stack->pushInt(_responses[param2]->_iD);
handleResponse(_responses[param2]);
_waitingScript = NULL;
- Game->_state = GAME_RUNNING;
- ((CAdGame *)Game)->_stateEx = GAME_NORMAL;
+ _gameRef->_state = GAME_RUNNING;
+ ((CAdGame *)_gameRef)->_stateEx = GAME_NORMAL;
_ready = true;
invalidateButtons();
clearResponses();
@@ -537,7 +537,7 @@ ERRORCODE CAdResponseBox::persist(CBPersistMgr *persistMgr) { //////////////////////////////////////////////////////////////////////////
ERRORCODE CAdResponseBox::weedResponses() {
- CAdGame *adGame = (CAdGame *)Game;
+ CAdGame *adGame = (CAdGame *)_gameRef;
for (int i = 0; i < _responses.getSize(); i++) {
switch (_responses[i]->_responseType) {
@@ -576,7 +576,7 @@ void CAdResponseBox::setLastResponseText(const char *text, const char *textOrig) ERRORCODE CAdResponseBox::handleResponse(CAdResponse *response) {
setLastResponseText(response->_text, response->_textOrig);
- CAdGame *adGame = (CAdGame *)Game;
+ CAdGame *adGame = (CAdGame *)_gameRef;
switch (response->_responseType) {
case RESPONSE_ONCE:
diff --git a/engines/wintermute/Ad/AdResponseContext.cpp b/engines/wintermute/Ad/AdResponseContext.cpp index 5615777daf..d44eb33403 100644 --- a/engines/wintermute/Ad/AdResponseContext.cpp +++ b/engines/wintermute/Ad/AdResponseContext.cpp @@ -50,7 +50,7 @@ CAdResponseContext::~CAdResponseContext() { //////////////////////////////////////////////////////////////////////////
ERRORCODE CAdResponseContext::persist(CBPersistMgr *persistMgr) {
- persistMgr->transfer(TMEMBER(Game));
+ persistMgr->transfer(TMEMBER(_gameRef));
persistMgr->transfer(TMEMBER(_context));
persistMgr->transfer(TMEMBER(_iD));
diff --git a/engines/wintermute/Ad/AdRotLevel.cpp b/engines/wintermute/Ad/AdRotLevel.cpp index 26e4bca48d..aa1727cc3e 100644 --- a/engines/wintermute/Ad/AdRotLevel.cpp +++ b/engines/wintermute/Ad/AdRotLevel.cpp @@ -54,9 +54,9 @@ CAdRotLevel::~CAdRotLevel() { //////////////////////////////////////////////////////////////////////////
ERRORCODE CAdRotLevel::loadFile(const char *filename) {
- byte *buffer = Game->_fileManager->readWholeFile(filename);
+ byte *buffer = _gameRef->_fileManager->readWholeFile(filename);
if (buffer == NULL) {
- Game->LOG(0, "CAdRotLevel::LoadFile failed for file '%s'", filename);
+ _gameRef->LOG(0, "CAdRotLevel::LoadFile failed for file '%s'", filename);
return STATUS_FAILED;
}
@@ -65,7 +65,7 @@ ERRORCODE CAdRotLevel::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 ROTATION_LEVEL file '%s'", filename);
+ if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing ROTATION_LEVEL file '%s'", filename);
delete [] buffer;
@@ -93,11 +93,11 @@ ERRORCODE CAdRotLevel::loadBuffer(byte *buffer, bool complete) { byte *params;
int cmd;
- CBParser parser(Game);
+ CBParser parser(_gameRef);
if (complete) {
if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ROTATION_LEVEL) {
- Game->LOG(0, "'ROTATION_LEVEL' keyword expected.");
+ _gameRef->LOG(0, "'ROTATION_LEVEL' keyword expected.");
return STATUS_FAILED;
}
buffer = params;
@@ -126,7 +126,7 @@ ERRORCODE CAdRotLevel::loadBuffer(byte *buffer, bool complete) { }
}
if (cmd == PARSERR_TOKENNOTFOUND) {
- Game->LOG(0, "Syntax error in ROTATION_LEVEL definition");
+ _gameRef->LOG(0, "Syntax error in ROTATION_LEVEL definition");
return STATUS_FAILED;
}
diff --git a/engines/wintermute/Ad/AdScaleLevel.cpp b/engines/wintermute/Ad/AdScaleLevel.cpp index 2cfbbb05e1..c756219382 100644 --- a/engines/wintermute/Ad/AdScaleLevel.cpp +++ b/engines/wintermute/Ad/AdScaleLevel.cpp @@ -52,9 +52,9 @@ CAdScaleLevel::~CAdScaleLevel() { //////////////////////////////////////////////////////////////////////////
ERRORCODE CAdScaleLevel::loadFile(const char *filename) {
- byte *buffer = Game->_fileManager->readWholeFile(filename);
+ byte *buffer = _gameRef->_fileManager->readWholeFile(filename);
if (buffer == NULL) {
- Game->LOG(0, "CAdScaleLevel::LoadFile failed for file '%s'", filename);
+ _gameRef->LOG(0, "CAdScaleLevel::LoadFile failed for file '%s'", filename);
return STATUS_FAILED;
}
@@ -63,7 +63,7 @@ ERRORCODE CAdScaleLevel::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 SCALE_LEVEL file '%s'", filename);
+ if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing SCALE_LEVEL file '%s'", filename);
delete [] buffer;
@@ -91,11 +91,11 @@ ERRORCODE CAdScaleLevel::loadBuffer(byte *buffer, bool complete) { byte *params;
int cmd;
- CBParser parser(Game);
+ CBParser parser(_gameRef);
if (complete) {
if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SCALE_LEVEL) {
- Game->LOG(0, "'SCALE_LEVEL' keyword expected.");
+ _gameRef->LOG(0, "'SCALE_LEVEL' keyword expected.");
return STATUS_FAILED;
}
buffer = params;
@@ -124,7 +124,7 @@ ERRORCODE CAdScaleLevel::loadBuffer(byte *buffer, bool complete) { }
}
if (cmd == PARSERR_TOKENNOTFOUND) {
- Game->LOG(0, "Syntax error in SCALE_LEVEL definition");
+ _gameRef->LOG(0, "Syntax error in SCALE_LEVEL definition");
return STATUS_FAILED;
}
diff --git a/engines/wintermute/Ad/AdScene.cpp b/engines/wintermute/Ad/AdScene.cpp index b338232c98..f50b854db3 100644 --- a/engines/wintermute/Ad/AdScene.cpp +++ b/engines/wintermute/Ad/AdScene.cpp @@ -74,7 +74,7 @@ CAdScene::CAdScene(CBGame *inGame): CBObject(inGame) { //////////////////////////////////////////////////////////////////////////
CAdScene::~CAdScene() {
cleanup();
- Game->unregisterObject(_fader);
+ _gameRef->unregisterObject(_fader);
delete _pfTarget;
_pfTarget = NULL;
}
@@ -128,8 +128,8 @@ void CAdScene::setDefaults() { _shieldWindow = NULL;
- _fader = new CBFader(Game);
- Game->registerObject(_fader);
+ _fader = new CBFader(_gameRef);
+ _gameRef->registerObject(_fader);
_viewport = NULL;
}
@@ -146,24 +146,24 @@ void CAdScene::cleanup() { delete _shieldWindow;
_shieldWindow = NULL;
- Game->unregisterObject(_fader);
+ _gameRef->unregisterObject(_fader);
_fader = NULL;
for (i = 0; i < _layers.getSize(); i++)
- Game->unregisterObject(_layers[i]);
+ _gameRef->unregisterObject(_layers[i]);
_layers.removeAll();
for (i = 0; i < _waypointGroups.getSize(); i++)
- Game->unregisterObject(_waypointGroups[i]);
+ _gameRef->unregisterObject(_waypointGroups[i]);
_waypointGroups.removeAll();
for (i = 0; i < _scaleLevels.getSize(); i++)
- Game->unregisterObject(_scaleLevels[i]);
+ _gameRef->unregisterObject(_scaleLevels[i]);
_scaleLevels.removeAll();
for (i = 0; i < _rotLevels.getSize(); i++)
- Game->unregisterObject(_rotLevels[i]);
+ _gameRef->unregisterObject(_rotLevels[i]);
_rotLevels.removeAll();
@@ -173,7 +173,7 @@ void CAdScene::cleanup() { _pfPointsNum = 0;
for (i = 0; i < _objects.getSize(); i++)
- Game->unregisterObject(_objects[i]);
+ _gameRef->unregisterObject(_objects[i]);
_objects.removeAll();
delete _viewport;
@@ -245,7 +245,7 @@ bool CAdScene::getPath(CBPoint source, CBPoint target, CAdPath *path, CBObject * pfAddWaypointGroup(_objects[i]->_currentWptGroup, requester);
}
}
- CAdGame *adGame = (CAdGame *)Game;
+ CAdGame *adGame = (CAdGame *)_gameRef;
for (i = 0; i < adGame->_objects.getSize(); i++) {
if (adGame->_objects[i]->_active && adGame->_objects[i] != requester && adGame->_objects[i]->_currentWptGroup) {
pfAddWaypointGroup(adGame->_objects[i]->_currentWptGroup, requester);
@@ -295,7 +295,7 @@ float CAdScene::getZoomAt(int x, int y) { //////////////////////////////////////////////////////////////////////////
uint32 CAdScene::getAlphaAt(int x, int y, bool colorCheck) {
- if (!Game->_dEBUG_DebugMode) colorCheck = false;
+ if (!_gameRef->_dEBUG_DebugMode) colorCheck = false;
uint32 ret;
if (colorCheck) ret = 0xFFFF0000;
@@ -325,7 +325,7 @@ bool CAdScene::isBlockedAt(int x, int y, bool checkFreeObjects, CBObject *reques if (_objects[i]->_currentBlockRegion->pointInRegion(x, y)) return true;
}
}
- CAdGame *adGame = (CAdGame *)Game;
+ CAdGame *adGame = (CAdGame *)_gameRef;
for (int i = 0; i < adGame->_objects.getSize(); i++) {
if (adGame->_objects[i]->_active && adGame->_objects[i] != requester && adGame->_objects[i]->_currentBlockRegion) {
if (adGame->_objects[i]->_currentBlockRegion->pointInRegion(x, y)) return true;
@@ -366,7 +366,7 @@ bool CAdScene::isWalkableAt(int x, int y, bool checkFreeObjects, CBObject *reque if (_objects[i]->_currentBlockRegion->pointInRegion(x, y)) return false;
}
}
- CAdGame *adGame = (CAdGame *)Game;
+ CAdGame *adGame = (CAdGame *)_gameRef;
for (int i = 0; i < adGame->_objects.getSize(); i++) {
if (adGame->_objects[i]->_active && adGame->_objects[i] != requester && adGame->_objects[i]->_currentBlockRegion) {
if (adGame->_objects[i]->_currentBlockRegion->pointInRegion(x, y)) return false;
@@ -484,14 +484,14 @@ void CAdScene::pathFinderStep() { ERRORCODE CAdScene::initLoop() {
#ifdef _DEBUGxxxx
int nu_steps = 0;
- uint32 start = Game->_currentTime;
+ uint32 start = _gameRef->_currentTime;
while (!_pfReady && CBPlatform::getTime() - start <= _pfMaxTime) {
PathFinderStep();
nu_steps++;
}
- if (nu_steps > 0) Game->LOG(0, "STAT: PathFinder iterations in one loop: %d (%s) _pfMaxTime=%d", nu_steps, _pfReady ? "finished" : "not yet done", _pfMaxTime);
+ if (nu_steps > 0) _gameRef->LOG(0, "STAT: PathFinder iterations in one loop: %d (%s) _pfMaxTime=%d", nu_steps, _pfReady ? "finished" : "not yet done", _pfMaxTime);
#else
- uint32 start = Game->_currentTime;
+ uint32 start = _gameRef->_currentTime;
while (!_pfReady && CBPlatform::getTime() - start <= _pfMaxTime) pathFinderStep();
#endif
@@ -501,9 +501,9 @@ ERRORCODE CAdScene::initLoop() { //////////////////////////////////////////////////////////////////////////
ERRORCODE CAdScene::loadFile(const char *filename) {
- byte *buffer = Game->_fileManager->readWholeFile(filename);
+ byte *buffer = _gameRef->_fileManager->readWholeFile(filename);
if (buffer == NULL) {
- Game->LOG(0, "CAdScene::LoadFile failed for file '%s'", filename);
+ _gameRef->LOG(0, "CAdScene::LoadFile failed for file '%s'", filename);
return STATUS_FAILED;
}
@@ -513,7 +513,7 @@ ERRORCODE CAdScene::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 SCENE file '%s'", filename);
+ if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing SCENE file '%s'", filename);
_filename = new char [strlen(filename) + 1];
strcpy(_filename, filename);
@@ -610,11 +610,11 @@ ERRORCODE CAdScene::loadBuffer(byte *buffer, bool complete) { byte *params;
int cmd;
- CBParser parser(Game);
+ CBParser parser(_gameRef);
if (complete) {
if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SCENE) {
- Game->LOG(0, "'SCENE' keyword expected.");
+ _gameRef->LOG(0, "'SCENE' keyword expected.");
return STATUS_FAILED;
}
buffer = params;
@@ -639,13 +639,13 @@ ERRORCODE CAdScene::loadBuffer(byte *buffer, bool complete) { break;
case TOKEN_LAYER: {
- CAdLayer *layer = new CAdLayer(Game);
+ CAdLayer *layer = new CAdLayer(_gameRef);
if (!layer || DID_FAIL(layer->loadBuffer(params, false))) {
cmd = PARSERR_GENERIC;
delete layer;
layer = NULL;
} else {
- Game->registerObject(layer);
+ _gameRef->registerObject(layer);
_layers.add(layer);
if (layer->_main) {
_mainLayer = layer;
@@ -657,46 +657,46 @@ ERRORCODE CAdScene::loadBuffer(byte *buffer, bool complete) { break;
case TOKEN_WAYPOINTS: {
- CAdWaypointGroup *wpt = new CAdWaypointGroup(Game);
+ CAdWaypointGroup *wpt = new CAdWaypointGroup(_gameRef);
if (!wpt || DID_FAIL(wpt->loadBuffer(params, false))) {
cmd = PARSERR_GENERIC;
delete wpt;
wpt = NULL;
} else {
- Game->registerObject(wpt);
+ _gameRef->registerObject(wpt);
_waypointGroups.add(wpt);
}
}
break;
case TOKEN_SCALE_LEVEL: {
- CAdScaleLevel *sl = new CAdScaleLevel(Game);
+ CAdScaleLevel *sl = new CAdScaleLevel(_gameRef);
if (!sl || DID_FAIL(sl->loadBuffer(params, false))) {
cmd = PARSERR_GENERIC;
delete sl;
sl = NULL;
} else {
- Game->registerObject(sl);
+ _gameRef->registerObject(sl);
_scaleLevels.add(sl);
}
}
break;
case TOKEN_ROTATION_LEVEL: {
- CAdRotLevel *rl = new CAdRotLevel(Game);
+ CAdRotLevel *rl = new CAdRotLevel(_gameRef);
if (!rl || DID_FAIL(rl->loadBuffer(params, false))) {
cmd = PARSERR_GENERIC;
delete rl;
rl = NULL;
} else {
- Game->registerObject(rl);
+ _gameRef->registerObject(rl);
_rotLevels.add(rl);
}
}
break;
case TOKEN_ENTITY: {
- CAdEntity *entity = new CAdEntity(Game);
+ CAdEntity *entity = new CAdEntity(_gameRef);
if (!entity || DID_FAIL(entity->loadBuffer(params, false))) {
cmd = PARSERR_GENERIC;
delete entity;
@@ -709,7 +709,7 @@ ERRORCODE CAdScene::loadBuffer(byte *buffer, bool complete) { 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;
@@ -820,7 +820,7 @@ ERRORCODE CAdScene::loadBuffer(byte *buffer, bool complete) { case TOKEN_VIEWPORT: {
Rect32 rc;
parser.scanStr((char *)params, "%d,%d,%d,%d", &rc.left, &rc.top, &rc.right, &rc.bottom);
- if (!_viewport) _viewport = new CBViewport(Game);
+ if (!_viewport) _viewport = new CBViewport(_gameRef);
if (_viewport) _viewport->setRect(rc.left, rc.top, rc.right, rc.bottom, true);
}
@@ -839,11 +839,11 @@ ERRORCODE CAdScene::loadBuffer(byte *buffer, bool complete) { }
}
if (cmd == PARSERR_TOKENNOTFOUND) {
- Game->LOG(0, "Syntax error in SCENE definition");
+ _gameRef->LOG(0, "Syntax error in SCENE definition");
return STATUS_FAILED;
}
- if (_mainLayer == NULL) Game->LOG(0, "Warning: scene '%s' has no main layer.", _filename);
+ if (_mainLayer == NULL) _gameRef->LOG(0, "Warning: scene '%s' has no main layer.", _filename);
sortScaleLevels();
@@ -860,17 +860,17 @@ ERRORCODE CAdScene::traverseNodes(bool doUpdate) { if (!_initialized) return STATUS_OK;
int j, k;
- CAdGame *adGame = (CAdGame *)Game;
+ CAdGame *adGame = (CAdGame *)_gameRef;
//////////////////////////////////////////////////////////////////////////
// prepare viewport
bool PopViewport = false;
- if (_viewport && !Game->_editorMode) {
- Game->pushViewport(_viewport);
+ if (_viewport && !_gameRef->_editorMode) {
+ _gameRef->pushViewport(_viewport);
PopViewport = true;
- } else if (adGame->_sceneViewport && !Game->_editorMode) {
- Game->pushViewport(adGame->_sceneViewport);
+ } else if (adGame->_sceneViewport && !_gameRef->_editorMode) {
+ _gameRef->pushViewport(adGame->_sceneViewport);
PopViewport = true;
}
@@ -879,16 +879,16 @@ ERRORCODE CAdScene::traverseNodes(bool doUpdate) { // *** adjust scroll offset
if (doUpdate) {
/*
- if (_autoScroll && Game->_mainObject != NULL)
+ if (_autoScroll && _gameRef->_mainObject != NULL)
{
- ScrollToObject(Game->_mainObject);
+ ScrollToObject(_gameRef->_mainObject);
}
*/
if (_autoScroll) {
// adjust horizontal scroll
- if (Game->_timer - _lastTimeH >= _scrollTimeH) {
- _lastTimeH = Game->_timer;
+ if (_gameRef->_timer - _lastTimeH >= _scrollTimeH) {
+ _lastTimeH = _gameRef->_timer;
if (_offsetLeft < _targetOffsetLeft) {
_offsetLeft += _scrollPixelsH;
_offsetLeft = MIN(_offsetLeft, _targetOffsetLeft);
@@ -899,8 +899,8 @@ ERRORCODE CAdScene::traverseNodes(bool doUpdate) { }
// adjust vertical scroll
- if (Game->_timer - _lastTimeV >= _scrollTimeV) {
- _lastTimeV = Game->_timer;
+ if (_gameRef->_timer - _lastTimeV >= _scrollTimeV) {
+ _lastTimeV = _gameRef->_timer;
if (_offsetTop < _targetOffsetTop) {
_offsetTop += _scrollPixelsV;
_offsetTop = MIN(_offsetTop, _targetOffsetTop);
@@ -931,13 +931,13 @@ ERRORCODE CAdScene::traverseNodes(bool doUpdate) { double heightRatio = scrollableY <= 0 ? 0 : ((double)(_offsetTop) / (double)scrollableY);
int origX, origY;
- Game->getOffset(&origX, &origY);
+ _gameRef->getOffset(&origX, &origY);
//////////////////////////////////////////////////////////////////////////
// *** display/update everything
- Game->_renderer->setup2D();
+ _gameRef->_renderer->setup2D();
// for each layer
/* int MainOffsetX = 0; */
@@ -948,12 +948,12 @@ ERRORCODE CAdScene::traverseNodes(bool doUpdate) { // make layer exclusive
if (!doUpdate) {
- if (_layers[j]->_closeUp && !Game->_editorMode) {
- if (!_shieldWindow) _shieldWindow = new CUIWindow(Game);
+ if (_layers[j]->_closeUp && !_gameRef->_editorMode) {
+ if (!_shieldWindow) _shieldWindow = new CUIWindow(_gameRef);
if (_shieldWindow) {
_shieldWindow->_posX = _shieldWindow->_posY = 0;
- _shieldWindow->_width = Game->_renderer->_width;
- _shieldWindow->_height = Game->_renderer->_height;
+ _shieldWindow->_width = _gameRef->_renderer->_width;
+ _shieldWindow->_height = _gameRef->_renderer->_height;
_shieldWindow->display();
}
}
@@ -962,17 +962,17 @@ ERRORCODE CAdScene::traverseNodes(bool doUpdate) { if (_paralaxScrolling) {
int offsetX = (int)(widthRatio * (_layers[j]->_width - viewportWidth) - viewportX);
int offsetY = (int)(heightRatio * (_layers[j]->_height - viewportHeight) - viewportY);
- Game->setOffset(offsetX, offsetY);
+ _gameRef->setOffset(offsetX, offsetY);
- Game->_offsetPercentX = (float)offsetX / ((float)_layers[j]->_width - viewportWidth) * 100.0f;
- Game->_offsetPercentY = (float)offsetY / ((float)_layers[j]->_height - viewportHeight) * 100.0f;
+ _gameRef->_offsetPercentX = (float)offsetX / ((float)_layers[j]->_width - viewportWidth) * 100.0f;
+ _gameRef->_offsetPercentY = (float)offsetY / ((float)_layers[j]->_height - viewportHeight) * 100.0f;
- //Game->QuickMessageForm("%d %f", OffsetX+ViewportX, Game->_offsetPercentX);
+ //_gameRef->QuickMessageForm("%d %f", OffsetX+ViewportX, _gameRef->_offsetPercentX);
} else {
- Game->setOffset(_offsetLeft - viewportX, _offsetTop - viewportY);
+ _gameRef->setOffset(_offsetLeft - viewportX, _offsetTop - viewportY);
- Game->_offsetPercentX = (float)(_offsetLeft - viewportX) / ((float)_layers[j]->_width - viewportWidth) * 100.0f;
- Game->_offsetPercentY = (float)(_offsetTop - viewportY) / ((float)_layers[j]->_height - viewportHeight) * 100.0f;
+ _gameRef->_offsetPercentX = (float)(_offsetLeft - viewportX) / ((float)_layers[j]->_width - viewportWidth) * 100.0f;
+ _gameRef->_offsetPercentY = (float)(_offsetTop - viewportY) / ((float)_layers[j]->_height - viewportHeight) * 100.0f;
}
@@ -981,8 +981,8 @@ ERRORCODE CAdScene::traverseNodes(bool doUpdate) { CAdSceneNode *node = _layers[j]->_nodes[k];
switch (node->_type) {
case OBJECT_ENTITY:
- if (node->_entity->_active && (Game->_editorMode || !node->_entity->_editorOnly)) {
- Game->_renderer->setup2D();
+ if (node->_entity->_active && (_gameRef->_editorMode || !node->_entity->_editorOnly)) {
+ _gameRef->_renderer->setup2D();
if (doUpdate) node->_entity->update();
else node->_entity->display();
@@ -1014,8 +1014,8 @@ ERRORCODE CAdScene::traverseNodes(bool doUpdate) { // restore state
- Game->setOffset(origX, origY);
- Game->_renderer->setup2D();
+ _gameRef->setOffset(origX, origY);
+ _gameRef->_renderer->setup2D();
// display/update fader
if (_fader) {
@@ -1023,7 +1023,7 @@ ERRORCODE CAdScene::traverseNodes(bool doUpdate) { else _fader->display();
}
- if (PopViewport) Game->popViewport();
+ if (PopViewport) _gameRef->popViewport();
return STATUS_OK;
}
@@ -1036,7 +1036,7 @@ ERRORCODE CAdScene::display() { //////////////////////////////////////////////////////////////////////////
ERRORCODE CAdScene::updateFreeObjects() {
- CAdGame *adGame = (CAdGame *)Game;
+ CAdGame *adGame = (CAdGame *)_gameRef;
bool is3DSet;
// *** update all active objects
@@ -1057,8 +1057,8 @@ ERRORCODE CAdScene::updateFreeObjects() { }
- if (_autoScroll && Game->_mainObject != NULL) {
- scrollToObject(Game->_mainObject);
+ if (_autoScroll && _gameRef->_mainObject != NULL) {
+ scrollToObject(_gameRef->_mainObject);
}
@@ -1068,7 +1068,7 @@ ERRORCODE CAdScene::updateFreeObjects() { //////////////////////////////////////////////////////////////////////////
ERRORCODE CAdScene::displayRegionContent(CAdRegion *region, bool display3DOnly) {
- CAdGame *adGame = (CAdGame *)Game;
+ CAdGame *adGame = (CAdGame *)_gameRef;
CBArray<CAdObject *, CAdObject *> objects;
CAdObject *obj;
@@ -1097,16 +1097,16 @@ ERRORCODE CAdScene::displayRegionContent(CAdRegion *region, bool display3DOnly) if (display3DOnly && !obj->_is3D) continue;
- Game->_renderer->setup2D();
+ _gameRef->_renderer->setup2D();
- if (Game->_editorMode || !obj->_editorOnly) obj->display();
+ if (_gameRef->_editorMode || !obj->_editorOnly) obj->display();
obj->_drawn = true;
}
// display design only objects
if (!display3DOnly) {
- if (Game->_editorMode && region == NULL) {
+ if (_gameRef->_editorMode && region == NULL) {
for (int i = 0; i < _objects.getSize(); i++) {
if (_objects[i]->_active && _objects[i]->_editorOnly) {
_objects[i]->display();
@@ -1131,7 +1131,7 @@ int CAdScene::compareObjs(const void *obj1, const void *obj2) { //////////////////////////////////////////////////////////////////////////
ERRORCODE CAdScene::displayRegionContentOld(CAdRegion *region) {
- CAdGame *adGame = (CAdGame *)Game;
+ CAdGame *adGame = (CAdGame *)_gameRef;
CAdObject *obj;
// display all objects in region sorted by _posY
@@ -1157,16 +1157,16 @@ ERRORCODE CAdScene::displayRegionContentOld(CAdRegion *region) { if (obj != NULL) {
- Game->_renderer->setup2D();
+ _gameRef->_renderer->setup2D();
- if (Game->_editorMode || !obj->_editorOnly) obj->display();
+ if (_gameRef->_editorMode || !obj->_editorOnly) obj->display();
obj->_drawn = true;
}
} while (obj != NULL);
// design only objects
- if (Game->_editorMode && region == NULL) {
+ if (_gameRef->_editorMode && region == NULL) {
for (int i = 0; i < _objects.getSize(); i++) {
if (_objects[i]->_active && _objects[i]->_editorOnly) {
_objects[i]->display();
@@ -1199,7 +1199,7 @@ void CAdScene::scrollTo(int offsetX, int offsetY) { _targetOffsetTop = MIN(_targetOffsetTop, _height - viewportHeight);
- if (Game->_mainObject && Game->_mainObject->_is3D) {
+ if (_gameRef->_mainObject && _gameRef->_mainObject->_is3D) {
if (abs(origOffsetLeft - _targetOffsetLeft) < 5) _targetOffsetLeft = origOffsetLeft;
if (abs(origOffsetTop - _targetOffsetTop) < 5) _targetOffsetTop = origOffsetTop;
//_targetOffsetTop = 0;
@@ -1246,7 +1246,7 @@ ERRORCODE CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *t //////////////////////////////////////////////////////////////////////////
if (strcmp(name, "LoadActor") == 0) {
stack->correctParams(1);
- CAdActor *act = new CAdActor(Game);
+ CAdActor *act = new CAdActor(_gameRef);
if (act && DID_SUCCEED(act->loadFile(stack->pop()->getString()))) {
addObject(act);
stack->pushNative(act, true);
@@ -1263,7 +1263,7 @@ ERRORCODE CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *t //////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "LoadEntity") == 0) {
stack->correctParams(1);
- CAdEntity *ent = new CAdEntity(Game);
+ CAdEntity *ent = new CAdEntity(_gameRef);
if (ent && DID_SUCCEED(ent->loadFile(stack->pop()->getString()))) {
addObject(ent);
stack->pushNative(ent, true);
@@ -1282,7 +1282,7 @@ ERRORCODE CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *t stack->correctParams(1);
CScValue *val = stack->pop();
- CAdEntity *ent = new CAdEntity(Game);
+ CAdEntity *ent = new CAdEntity(_gameRef);
addObject(ent);
if (!val->isNULL()) ent->setName(val->getString());
stack->pushNative(ent, true);
@@ -1567,10 +1567,10 @@ ERRORCODE CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *t int width = stack->pop()->getInt();
int height = stack->pop()->getInt();
- if (width <= 0) width = Game->_renderer->_width;
- if (height <= 0) height = Game->_renderer->_height;
+ if (width <= 0) width = _gameRef->_renderer->_width;
+ if (height <= 0) height = _gameRef->_renderer->_height;
- if (!_viewport) _viewport = new CBViewport(Game);
+ if (!_viewport) _viewport = new CBViewport(_gameRef);
if (_viewport) _viewport->setRect(x, y, x + width, y + height);
stack->pushBool(true);
@@ -1585,14 +1585,14 @@ ERRORCODE CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *t stack->correctParams(1);
CScValue *val = stack->pop();
- CAdLayer *layer = new CAdLayer(Game);
+ CAdLayer *layer = new CAdLayer(_gameRef);
if (!val->isNULL()) layer->setName(val->getString());
if (_mainLayer) {
layer->_width = _mainLayer->_width;
layer->_height = _mainLayer->_height;
}
_layers.add(layer);
- Game->registerObject(layer);
+ _gameRef->registerObject(layer);
stack->pushNative(layer, true);
return STATUS_OK;
@@ -1606,7 +1606,7 @@ ERRORCODE CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *t int index = stack->pop()->getInt();
CScValue *val = stack->pop();
- CAdLayer *layer = new CAdLayer(Game);
+ CAdLayer *layer = new CAdLayer(_gameRef);
if (!val->isNULL()) layer->setName(val->getString());
if (_mainLayer) {
layer->_width = _mainLayer->_width;
@@ -1616,7 +1616,7 @@ ERRORCODE CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *t if (index <= _layers.getSize() - 1) _layers.insertAt(index, layer);
else _layers.add(layer);
- Game->registerObject(layer);
+ _gameRef->registerObject(layer);
stack->pushNative(layer, true);
return STATUS_OK;
@@ -1658,7 +1658,7 @@ ERRORCODE CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *t for (int i = 0; i < _layers.getSize(); i++) {
if (_layers[i] == toDelete) {
_layers.removeAt(i);
- Game->unregisterObject(toDelete);
+ _gameRef->unregisterObject(toDelete);
break;
}
}
@@ -1723,7 +1723,7 @@ CScValue *CAdScene::scGetProperty(const char *name) { int viewportX;
getViewportOffset(&viewportX);
- _scValue->setInt(Game->_mousePos.x + _offsetLeft - viewportX);
+ _scValue->setInt(_gameRef->_mousePos.x + _offsetLeft - viewportX);
return _scValue;
}
@@ -1734,7 +1734,7 @@ CScValue *CAdScene::scGetProperty(const char *name) { int viewportY;
getViewportOffset(NULL, &viewportY);
- _scValue->setInt(Game->_mousePos.y + _offsetTop - viewportY);
+ _scValue->setInt(_gameRef->_mousePos.y + _offsetTop - viewportY);
return _scValue;
}
@@ -1944,7 +1944,7 @@ const char *CAdScene::scToString() { //////////////////////////////////////////////////////////////////////////
ERRORCODE CAdScene::addObject(CAdObject *object) {
_objects.add(object);
- return Game->registerObject(object);
+ return _gameRef->registerObject(object);
}
@@ -1953,7 +1953,7 @@ ERRORCODE CAdScene::removeObject(CAdObject *object) { for (int i = 0; i < _objects.getSize(); i++) {
if (_objects[i] == object) {
_objects.removeAt(i);
- return Game->unregisterObject(object);
+ return _gameRef->unregisterObject(object);
}
}
return STATUS_FAILED;
@@ -2351,11 +2351,11 @@ void CAdScene::pfPointsAdd(int x, int y, int distance) { //////////////////////////////////////////////////////////////////////////
ERRORCODE CAdScene::getViewportOffset(int *offsetX, int *offsetY) {
- CAdGame *adGame = (CAdGame *)Game;
- if (_viewport && !Game->_editorMode) {
+ CAdGame *adGame = (CAdGame *)_gameRef;
+ if (_viewport && !_gameRef->_editorMode) {
if (offsetX) *offsetX = _viewport->_offsetX;
if (offsetY) *offsetY = _viewport->_offsetY;
- } else if (adGame->_sceneViewport && !Game->_editorMode) {
+ } else if (adGame->_sceneViewport && !_gameRef->_editorMode) {
if (offsetX) *offsetX = adGame->_sceneViewport->_offsetX;
if (offsetY) *offsetY = adGame->_sceneViewport->_offsetY;
} else {
@@ -2368,16 +2368,16 @@ ERRORCODE CAdScene::getViewportOffset(int *offsetX, int *offsetY) { //////////////////////////////////////////////////////////////////////////
ERRORCODE CAdScene::getViewportSize(int *width, int *height) {
- CAdGame *adGame = (CAdGame *)Game;
- if (_viewport && !Game->_editorMode) {
+ CAdGame *adGame = (CAdGame *)_gameRef;
+ if (_viewport && !_gameRef->_editorMode) {
if (width) *width = _viewport->getWidth();
if (height) *height = _viewport->getHeight();
- } else if (adGame->_sceneViewport && !Game->_editorMode) {
+ } else if (adGame->_sceneViewport && !_gameRef->_editorMode) {
if (width) *width = adGame->_sceneViewport->getWidth();
if (height) *height = adGame->_sceneViewport->getHeight();
} else {
- if (width) *width = Game->_renderer->_width;
- if (height) *height = Game->_renderer->_height;
+ if (width) *width = _gameRef->_renderer->_width;
+ if (height) *height = _gameRef->_renderer->_height;
}
return STATUS_OK;
}
@@ -2479,7 +2479,7 @@ ERRORCODE CAdScene::loadState() { ERRORCODE CAdScene::persistState(bool saving) {
if (!_persistentState) return STATUS_OK;
- CAdGame *adGame = (CAdGame *)Game;
+ CAdGame *adGame = (CAdGame *)_gameRef;
CAdSceneState *state = adGame->getSceneState(_filename, saving);
if (!state) return STATUS_OK;
@@ -2720,7 +2720,7 @@ ERRORCODE CAdScene::getSceneObjects(CBArray<CAdObject *, CAdObject *> &objects, //////////////////////////////////////////////////////////////////////////
ERRORCODE CAdScene::getRegionObjects(CAdRegion *region, CBArray<CAdObject *, CAdObject *> &objects, bool interactiveOnly) {
- CAdGame *adGame = (CAdGame *)Game;
+ CAdGame *adGame = (CAdGame *)_gameRef;
CAdObject *obj;
// global objects
diff --git a/engines/wintermute/Ad/AdSceneNode.cpp b/engines/wintermute/Ad/AdSceneNode.cpp index 60ab2891f5..687dbdaeef 100644 --- a/engines/wintermute/Ad/AdSceneNode.cpp +++ b/engines/wintermute/Ad/AdSceneNode.cpp @@ -44,10 +44,10 @@ CAdSceneNode::CAdSceneNode(CBGame *inGame): CBObject(inGame) { //////////////////////////////////////////////////////////////////////////
CAdSceneNode::~CAdSceneNode() {
- Game->unregisterObject(_region);
+ _gameRef->unregisterObject(_region);
_region = NULL;
- Game->unregisterObject(_entity);
+ _gameRef->unregisterObject(_entity);
_entity = NULL;
}
@@ -56,7 +56,7 @@ CAdSceneNode::~CAdSceneNode() { ERRORCODE CAdSceneNode::setEntity(CAdEntity *entity) {
_type = OBJECT_ENTITY;
_entity = entity;
- return Game->registerObject(entity);
+ return _gameRef->registerObject(entity);
}
@@ -64,7 +64,7 @@ ERRORCODE CAdSceneNode::setEntity(CAdEntity *entity) { ERRORCODE CAdSceneNode::setRegion(CAdRegion *region) {
_type = OBJECT_REGION;
_region = region;
- return Game->registerObject(region);
+ return _gameRef->registerObject(region);
}
diff --git a/engines/wintermute/Ad/AdSceneState.cpp b/engines/wintermute/Ad/AdSceneState.cpp index 00b1b6c250..b10da397b8 100644 --- a/engines/wintermute/Ad/AdSceneState.cpp +++ b/engines/wintermute/Ad/AdSceneState.cpp @@ -77,7 +77,7 @@ CAdNodeState *CAdSceneState::getNodeState(char *name, bool saving) { }
if (saving) {
- CAdNodeState *ret = new CAdNodeState(Game);
+ CAdNodeState *ret = new CAdNodeState(_gameRef);
ret->setName(name);
_nodeStates.add(ret);
diff --git a/engines/wintermute/Ad/AdSentence.cpp b/engines/wintermute/Ad/AdSentence.cpp index 7d37efce49..cfff93b488 100644 --- a/engines/wintermute/Ad/AdSentence.cpp +++ b/engines/wintermute/Ad/AdSentence.cpp @@ -56,7 +56,7 @@ CAdSentence::CAdSentence(CBGame *inGame): CBBase(inGame) { _font = NULL;
_pos.x = _pos.y = 0;
- _width = Game->_renderer->_width;
+ _width = _gameRef->_renderer->_width;
_align = (TTextAlign)TAL_CENTER;
@@ -173,18 +173,18 @@ ERRORCODE CAdSentence::display() { _soundStarted = true;
}
- if (Game->_subtitles) {
+ if (_gameRef->_subtitles) {
int x = _pos.x;
int y = _pos.y;
if (!_fixedPos) {
- x = x - ((CAdGame *)Game)->_scene->getOffsetLeft();
- y = y - ((CAdGame *)Game)->_scene->getOffsetTop();
+ x = x - ((CAdGame *)_gameRef)->_scene->getOffsetLeft();
+ y = y - ((CAdGame *)_gameRef)->_scene->getOffsetTop();
}
x = MAX(x, 0);
- x = MIN(x, Game->_renderer->_width - _width);
+ x = MIN(x, _gameRef->_renderer->_width - _width);
y = MAX(y, 0);
_font->drawText((byte *)_text, x, y, _width, _align);
@@ -213,7 +213,7 @@ ERRORCODE CAdSentence::finish() { //////////////////////////////////////////////////////////////////////////
ERRORCODE CAdSentence::persist(CBPersistMgr *persistMgr) {
- persistMgr->transfer(TMEMBER(Game));
+ persistMgr->transfer(TMEMBER(_gameRef));
persistMgr->transfer(TMEMBER_INT(_align));
persistMgr->transfer(TMEMBER(_currentStance));
@@ -251,19 +251,19 @@ ERRORCODE CAdSentence::setupTalkFile(const char *soundFilename) { AnsiString talkDefFileName = PathUtil::combine(path, name + ".talk");
- Common::SeekableReadStream *file = Game->_fileManager->openFile(talkDefFileName.c_str());
+ Common::SeekableReadStream *file = _gameRef->_fileManager->openFile(talkDefFileName.c_str());
if (file) {
- Game->_fileManager->closeFile(file);
+ _gameRef->_fileManager->closeFile(file);
} else return STATUS_OK; // no talk def file found
- _talkDef = new CAdTalkDef(Game);
+ _talkDef = new CAdTalkDef(_gameRef);
if (!_talkDef || DID_FAIL(_talkDef->loadFile(talkDefFileName.c_str()))) {
delete _talkDef;
_talkDef = NULL;
return STATUS_FAILED;
}
- //Game->LOG(0, "Using .talk file: %s", TalkDefFile);
+ //_gameRef->LOG(0, "Using .talk file: %s", TalkDefFile);
return STATUS_OK;
}
@@ -278,9 +278,9 @@ ERRORCODE CAdSentence::update(TDirection dir) { /*
if (_sound) CurrentTime = _sound->GetPositionTime();
- else CurrentTime = Game->_timer - _startTime;
+ else CurrentTime = _gameRef->_timer - _startTime;
*/
- currentTime = Game->_timer - _startTime;
+ currentTime = _gameRef->_timer - _startTime;
bool talkNodeFound = false;
for (int i = 0; i < _talkDef->_nodes.getSize(); i++) {
@@ -311,7 +311,7 @@ ERRORCODE CAdSentence::update(TDirection dir) { //////////////////////////////////////////////////////////////////////////
bool CAdSentence::CanSkip() {
// prevent accidental sentence skipping (TODO make configurable)
- return (Game->_timer - _startTime) > 300;
+ return (_gameRef->_timer - _startTime) > 300;
}
} // end of namespace WinterMute
diff --git a/engines/wintermute/Ad/AdSpriteSet.cpp b/engines/wintermute/Ad/AdSpriteSet.cpp index 29026a9508..f93530c449 100644 --- a/engines/wintermute/Ad/AdSpriteSet.cpp +++ b/engines/wintermute/Ad/AdSpriteSet.cpp @@ -59,15 +59,15 @@ CAdSpriteSet::~CAdSpriteSet() { //////////////////////////////////////////////////////////////////////////
ERRORCODE CAdSpriteSet::loadFile(const char *filename, int lifeTime, TSpriteCacheType cacheType) {
- byte *buffer = Game->_fileManager->readWholeFile(filename);
+ byte *buffer = _gameRef->_fileManager->readWholeFile(filename);
if (buffer == NULL) {
- Game->LOG(0, "CAdSpriteSet::LoadFile failed for file '%s'", filename);
+ _gameRef->LOG(0, "CAdSpriteSet::LoadFile failed for file '%s'", filename);
return STATUS_FAILED;
}
ERRORCODE ret;
- if (DID_FAIL(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing SPRITESET file '%s'", filename);
+ if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing SPRITESET file '%s'", filename);
delete [] buffer;
@@ -108,11 +108,11 @@ ERRORCODE CAdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TS byte *params;
int cmd;
- CBParser parser(Game);
+ CBParser parser(_gameRef);
if (complete) {
if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SPRITESET) {
- Game->LOG(0, "'SPRITESET' keyword expected.");
+ _gameRef->LOG(0, "'SPRITESET' keyword expected.");
return STATUS_FAILED;
}
buffer = params;
@@ -132,7 +132,7 @@ ERRORCODE CAdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TS case TOKEN_LEFT:
delete _sprites[DI_LEFT];
_sprites[DI_LEFT] = NULL;
- spr = new CBSprite(Game, _owner);
+ spr = new CBSprite(_gameRef, _owner);
if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC;
else _sprites[DI_LEFT] = spr;
break;
@@ -140,7 +140,7 @@ ERRORCODE CAdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TS case TOKEN_RIGHT:
delete _sprites[DI_RIGHT];
_sprites[DI_RIGHT] = NULL;
- spr = new CBSprite(Game, _owner);
+ spr = new CBSprite(_gameRef, _owner);
if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC;
else _sprites[DI_RIGHT] = spr;
break;
@@ -148,7 +148,7 @@ ERRORCODE CAdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TS case TOKEN_UP:
delete _sprites[DI_UP];
_sprites[DI_UP] = NULL;
- spr = new CBSprite(Game, _owner);
+ spr = new CBSprite(_gameRef, _owner);
if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC;
else _sprites[DI_UP] = spr;
break;
@@ -156,7 +156,7 @@ ERRORCODE CAdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TS case TOKEN_DOWN:
delete _sprites[DI_DOWN];
_sprites[DI_DOWN] = NULL;
- spr = new CBSprite(Game, _owner);
+ spr = new CBSprite(_gameRef, _owner);
if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC;
else _sprites[DI_DOWN] = spr;
break;
@@ -164,7 +164,7 @@ ERRORCODE CAdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TS case TOKEN_UP_LEFT:
delete _sprites[DI_UPLEFT];
_sprites[DI_UPLEFT] = NULL;
- spr = new CBSprite(Game, _owner);
+ spr = new CBSprite(_gameRef, _owner);
if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC;
else _sprites[DI_UPLEFT] = spr;
break;
@@ -172,7 +172,7 @@ ERRORCODE CAdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TS case TOKEN_UP_RIGHT:
delete _sprites[DI_UPRIGHT];
_sprites[DI_UPRIGHT] = NULL;
- spr = new CBSprite(Game, _owner);
+ spr = new CBSprite(_gameRef, _owner);
if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC;
else _sprites[DI_UPRIGHT] = spr;
break;
@@ -180,7 +180,7 @@ ERRORCODE CAdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TS case TOKEN_DOWN_LEFT:
delete _sprites[DI_DOWNLEFT];
_sprites[DI_DOWNLEFT] = NULL;
- spr = new CBSprite(Game, _owner);
+ spr = new CBSprite(_gameRef, _owner);
if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC;
else _sprites[DI_DOWNLEFT] = spr;
break;
@@ -188,7 +188,7 @@ ERRORCODE CAdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TS case TOKEN_DOWN_RIGHT:
delete _sprites[DI_DOWNRIGHT];
_sprites[DI_DOWNRIGHT] = NULL;
- spr = new CBSprite(Game, _owner);
+ spr = new CBSprite(_gameRef, _owner);
if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, CacheType))) cmd = PARSERR_GENERIC;
else _sprites[DI_DOWNRIGHT] = spr;
break;
@@ -199,12 +199,12 @@ ERRORCODE CAdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TS }
}
if (cmd == PARSERR_TOKENNOTFOUND) {
- Game->LOG(0, "Syntax error in SPRITESET definition");
+ _gameRef->LOG(0, "Syntax error in SPRITESET definition");
return STATUS_FAILED;
}
if (cmd == PARSERR_GENERIC) {
- Game->LOG(0, "Error loading SPRITESET definition");
+ _gameRef->LOG(0, "Error loading SPRITESET definition");
if (spr) delete spr;
return STATUS_FAILED;
}
diff --git a/engines/wintermute/Ad/AdTalkDef.cpp b/engines/wintermute/Ad/AdTalkDef.cpp index 62b6ea8b67..09ef66a946 100644 --- a/engines/wintermute/Ad/AdTalkDef.cpp +++ b/engines/wintermute/Ad/AdTalkDef.cpp @@ -70,9 +70,9 @@ CAdTalkDef::~CAdTalkDef() { //////////////////////////////////////////////////////////////////////////
ERRORCODE CAdTalkDef::loadFile(const char *filename) {
- byte *buffer = Game->_fileManager->readWholeFile(filename);
+ byte *buffer = _gameRef->_fileManager->readWholeFile(filename);
if (buffer == NULL) {
- Game->LOG(0, "CAdTalkDef::LoadFile failed for file '%s'", filename);
+ _gameRef->LOG(0, "CAdTalkDef::LoadFile failed for file '%s'", filename);
return STATUS_FAILED;
}
@@ -80,7 +80,7 @@ ERRORCODE CAdTalkDef::loadFile(const char *filename) { CBUtils::setString(&_filename, filename);
- if (DID_FAIL(ret = loadBuffer(buffer, true))) Game->LOG(0, "Error parsing TALK file '%s'", filename);
+ if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing TALK file '%s'", filename);
delete [] buffer;
@@ -111,11 +111,11 @@ ERRORCODE CAdTalkDef::loadBuffer(byte *buffer, bool complete) { byte *params;
int cmd;
- CBParser parser(Game);
+ CBParser parser(_gameRef);
if (complete) {
if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_TALK) {
- Game->LOG(0, "'TALK' keyword expected.");
+ _gameRef->LOG(0, "'TALK' keyword expected.");
return STATUS_FAILED;
}
buffer = params;
@@ -128,7 +128,7 @@ ERRORCODE CAdTalkDef::loadBuffer(byte *buffer, bool complete) { break;
case TOKEN_ACTION: {
- CAdTalkNode *Node = new CAdTalkNode(Game);
+ CAdTalkNode *Node = new CAdTalkNode(_gameRef);
if (Node && DID_SUCCEED(Node->loadBuffer(params, false))) _nodes.add(Node);
else {
delete Node;
@@ -148,7 +148,7 @@ ERRORCODE CAdTalkDef::loadBuffer(byte *buffer, bool complete) { case TOKEN_DEFAULT_SPRITESET: {
delete _defaultSpriteSet;
- _defaultSpriteSet = new CAdSpriteSet(Game);
+ _defaultSpriteSet = new CAdSpriteSet(_gameRef);
if (!_defaultSpriteSet || DID_FAIL(_defaultSpriteSet->loadBuffer(params, false))) {
delete _defaultSpriteSet;
_defaultSpriteSet = NULL;
@@ -164,12 +164,12 @@ ERRORCODE CAdTalkDef::loadBuffer(byte *buffer, bool complete) { }
}
if (cmd == PARSERR_TOKENNOTFOUND) {
- Game->LOG(0, "Syntax error in TALK definition");
+ _gameRef->LOG(0, "Syntax error in TALK definition");
return STATUS_FAILED;
}
if (cmd == PARSERR_GENERIC) {
- Game->LOG(0, "Error loading TALK definition");
+ _gameRef->LOG(0, "Error loading TALK definition");
return STATUS_FAILED;
}
@@ -179,12 +179,12 @@ ERRORCODE CAdTalkDef::loadBuffer(byte *buffer, bool complete) { _defaultSpriteSet = NULL;
if (_defaultSpriteFilename) {
- _defaultSprite = new CBSprite(Game);
+ _defaultSprite = new CBSprite(_gameRef);
if (!_defaultSprite || DID_FAIL(_defaultSprite->loadFile(_defaultSpriteFilename))) return STATUS_FAILED;
}
if (_defaultSpriteSetFilename) {
- _defaultSpriteSet = new CAdSpriteSet(Game);
+ _defaultSpriteSet = new CAdSpriteSet(_gameRef);
if (!_defaultSpriteSet || DID_FAIL(_defaultSpriteSet->loadFile(_defaultSpriteSetFilename))) return STATUS_FAILED;
}
@@ -232,14 +232,14 @@ ERRORCODE CAdTalkDef::saveAsText(CBDynBuffer *buffer, int indent) { //////////////////////////////////////////////////////////////////////////
ERRORCODE CAdTalkDef::loadDefaultSprite() {
if (_defaultSpriteFilename && !_defaultSprite) {
- _defaultSprite = new CBSprite(Game);
+ _defaultSprite = new CBSprite(_gameRef);
if (!_defaultSprite || DID_FAIL(_defaultSprite->loadFile(_defaultSpriteFilename))) {
delete _defaultSprite;
_defaultSprite = NULL;
return STATUS_FAILED;
} else return STATUS_OK;
} else if (_defaultSpriteSetFilename && !_defaultSpriteSet) {
- _defaultSpriteSet = new CAdSpriteSet(Game);
+ _defaultSpriteSet = new CAdSpriteSet(_gameRef);
if (!_defaultSpriteSet || DID_FAIL(_defaultSpriteSet->loadFile(_defaultSpriteSetFilename))) {
delete _defaultSpriteSet;
_defaultSpriteSet = NULL;
diff --git a/engines/wintermute/Ad/AdTalkHolder.cpp b/engines/wintermute/Ad/AdTalkHolder.cpp index eb4860b5d6..d7e13a5af4 100644 --- a/engines/wintermute/Ad/AdTalkHolder.cpp +++ b/engines/wintermute/Ad/AdTalkHolder.cpp @@ -71,11 +71,11 @@ CBSprite *CAdTalkHolder::getTalkStance(const char *stance) { if (_forcedTalkAnimName && !_forcedTalkAnimUsed) {
_forcedTalkAnimUsed = true;
delete _animSprite;
- _animSprite = new CBSprite(Game, this);
+ _animSprite = new CBSprite(_gameRef, this);
if (_animSprite) {
ERRORCODE res = _animSprite->loadFile(_forcedTalkAnimName);
if (DID_FAIL(res)) {
- Game->LOG(res, "CAdTalkHolder::GetTalkStance: error loading talk sprite (object:\"%s\" sprite:\"%s\")", _name, _forcedTalkAnimName);
+ _gameRef->LOG(res, "CAdTalkHolder::GetTalkStance: error loading talk sprite (object:\"%s\" sprite:\"%s\")", _name, _forcedTalkAnimName);
delete _animSprite;
_animSprite = NULL;
} else return _animSprite;
@@ -140,7 +140,7 @@ ERRORCODE CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScSta stack->pushBool(true);
} else {
const char *filename = val->getString();
- CBSprite *spr = new CBSprite(Game, this);
+ CBSprite *spr = new CBSprite(_gameRef, this);
if (!spr || DID_FAIL(spr->loadFile(filename))) {
script->runtimeError("SetSprite method failed for file '%s'", filename);
stack->pushBool(false);
@@ -184,7 +184,7 @@ ERRORCODE CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScSta const char *filename = stack->pop()->getString();
bool Ex = stack->pop()->getBool();
- CBSprite *spr = new CBSprite(Game, this);
+ CBSprite *spr = new CBSprite(_gameRef, this);
if (!spr || DID_FAIL(spr->loadFile(filename))) {
stack->pushBool(false);
script->runtimeError("AddTalkSprite method failed for file '%s'", filename);
@@ -255,7 +255,7 @@ ERRORCODE CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScSta bool setCurrent = false;
bool setTemp2 = false;
- CBSprite *spr = new CBSprite(Game, this);
+ CBSprite *spr = new CBSprite(_gameRef, this);
if (!spr || DID_FAIL(spr->loadFile(filename))) {
stack->pushBool(false);
script->runtimeError("SetTalkSprite method failed for file '%s'", filename);
diff --git a/engines/wintermute/Ad/AdTalkNode.cpp b/engines/wintermute/Ad/AdTalkNode.cpp index 7f4198b0f1..30c32c4db4 100644 --- a/engines/wintermute/Ad/AdTalkNode.cpp +++ b/engines/wintermute/Ad/AdTalkNode.cpp @@ -95,11 +95,11 @@ ERRORCODE CAdTalkNode::loadBuffer(byte *buffer, bool complete) { byte *params;
int cmd;
- CBParser parser(Game);
+ CBParser parser(_gameRef);
if (complete) {
if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ACTION) {
- Game->LOG(0, "'ACTION' keyword expected.");
+ _gameRef->LOG(0, "'ACTION' keyword expected.");
return STATUS_FAILED;
}
buffer = params;
@@ -121,7 +121,7 @@ ERRORCODE CAdTalkNode::loadBuffer(byte *buffer, bool complete) { case TOKEN_SPRITESET: {
delete _spriteSet;
- _spriteSet = new CAdSpriteSet(Game);
+ _spriteSet = new CAdSpriteSet(_gameRef);
if (!_spriteSet || DID_FAIL(_spriteSet->loadBuffer(params, false))) {
delete _spriteSet;
_spriteSet = NULL;
@@ -143,7 +143,7 @@ ERRORCODE CAdTalkNode::loadBuffer(byte *buffer, bool complete) { break;
case TOKEN_COMMENT:
- if (Game->_editorMode) CBUtils::setString(&_comment, (char *)params);
+ if (_gameRef->_editorMode) CBUtils::setString(&_comment, (char *)params);
break;
case TOKEN_EDITOR_PROPERTY:
@@ -152,12 +152,12 @@ ERRORCODE CAdTalkNode::loadBuffer(byte *buffer, bool complete) { }
}
if (cmd == PARSERR_TOKENNOTFOUND) {
- Game->LOG(0, "Syntax error in ACTION definition");
+ _gameRef->LOG(0, "Syntax error in ACTION definition");
return STATUS_FAILED;
}
if (cmd == PARSERR_GENERIC) {
- Game->LOG(0, "Error loading ACTION definition");
+ _gameRef->LOG(0, "Error loading ACTION definition");
return STATUS_FAILED;
}
@@ -168,14 +168,14 @@ ERRORCODE CAdTalkNode::loadBuffer(byte *buffer, bool complete) { if (_preCache && _spriteFilename) {
delete _sprite;
- _sprite = new CBSprite(Game);
+ _sprite = new CBSprite(_gameRef);
if (!_sprite || DID_FAIL(_sprite->loadFile(_spriteFilename)))
return STATUS_FAILED;
}
if (_preCache && _spriteSetFilename) {
delete _spriteSet;
- _spriteSet = new CAdSpriteSet(Game);
+ _spriteSet = new CAdSpriteSet(_gameRef);
if (!_spriteSet || DID_FAIL(_spriteSet->loadFile(_spriteSetFilename)))
return STATUS_FAILED;
}
@@ -222,7 +222,7 @@ ERRORCODE CAdTalkNode::saveAsText(CBDynBuffer *buffer, int indent) { //////////////////////////////////////////////////////////////////////////
ERRORCODE CAdTalkNode::loadSprite() {
if (_spriteFilename && !_sprite) {
- _sprite = new CBSprite(Game);
+ _sprite = new CBSprite(_gameRef);
if (!_sprite || DID_FAIL(_sprite->loadFile(_spriteFilename))) {
delete _sprite;
_sprite = NULL;
@@ -231,7 +231,7 @@ ERRORCODE CAdTalkNode::loadSprite() { }
else if (_spriteSetFilename && !_spriteSet) {
- _spriteSet = new CAdSpriteSet(Game);
+ _spriteSet = new CAdSpriteSet(_gameRef);
if (!_spriteSet || DID_FAIL(_spriteSet->loadFile(_spriteSetFilename))) {
delete _spriteSet;
_spriteSet = NULL;
diff --git a/engines/wintermute/Ad/AdWaypointGroup.cpp b/engines/wintermute/Ad/AdWaypointGroup.cpp index 4ad2dc1749..0210095c28 100644 --- a/engines/wintermute/Ad/AdWaypointGroup.cpp +++ b/engines/wintermute/Ad/AdWaypointGroup.cpp @@ -65,9 +65,9 @@ void CAdWaypointGroup::cleanup() { //////////////////////////////////////////////////////////////////////////
ERRORCODE CAdWaypointGroup::loadFile(const char *filename) {
- byte *buffer = Game->_fileManager->readWholeFile(filename);
+ byte *buffer = _gameRef->_fileManager->readWholeFile(filename);
if (buffer == NULL) {
- Game->LOG(0, "CAdWaypointGroup::LoadFile failed for file '%s'", filename);
+ _gameRef->LOG(0, "CAdWaypointGroup::LoadFile failed for file '%s'", filename);
return STATUS_FAILED;
}
@@ -76,7 +76,7 @@ ERRORCODE CAdWaypointGroup::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 WAYPOINTS file '%s'", filename);
+ if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing WAYPOINTS file '%s'", filename);
delete [] buffer;
@@ -110,11 +110,11 @@ ERRORCODE CAdWaypointGroup::loadBuffer(byte *buffer, bool complete) { byte *params;
int cmd;
- CBParser parser(Game);
+ CBParser parser(_gameRef);
if (complete) {
if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_WAYPOINTS) {
- Game->LOG(0, "'WAYPOINTS' keyword expected.");
+ _gameRef->LOG(0, "'WAYPOINTS' keyword expected.");
return STATUS_FAILED;
}
buffer = params;
@@ -155,7 +155,7 @@ ERRORCODE CAdWaypointGroup::loadBuffer(byte *buffer, bool complete) { }
}
if (cmd == PARSERR_TOKENNOTFOUND) {
- Game->LOG(0, "Syntax error in WAYPOINTS definition");
+ _gameRef->LOG(0, "Syntax error in WAYPOINTS definition");
return STATUS_FAILED;
}
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 **)¶ms) != 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 **)¶ms) != 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 **)¶ms) != 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 **)¶ms) != 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 **)¶ms) != 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 **)¶ms) != 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**)¶ms)!=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 **)¶ms) == 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 **)¶ms) != 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 **)¶ms) != 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 **)¶ms)) > 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;
diff --git a/engines/wintermute/PlatformSDL.cpp b/engines/wintermute/PlatformSDL.cpp index 0bf3f95e9e..df656d13f6 100644 --- a/engines/wintermute/PlatformSDL.cpp +++ b/engines/wintermute/PlatformSDL.cpp @@ -40,11 +40,11 @@ namespace WinterMute {
-CBGame *CBPlatform::Game = NULL;
+CBGame *CBPlatform::_gameRef = NULL;
#define CLASS_NAME "GF_FRAME"
int CBPlatform::initialize(CBGame *inGame, int argc, char *argv[]) {
- Game = inGame;
+ _gameRef = inGame;
return true;
}
@@ -53,48 +53,48 @@ void CBPlatform::handleEvent(Common::Event *event) { switch (event->type) {
case Common::EVENT_LBUTTONDOWN:
- if (Game) {
- if (Game->isLeftDoubleClick()) Game->onMouseLeftDblClick();
- else Game->onMouseLeftDown();
+ if (_gameRef) {
+ if (_gameRef->isLeftDoubleClick()) _gameRef->onMouseLeftDblClick();
+ else _gameRef->onMouseLeftDown();
}
break;
case Common::EVENT_RBUTTONDOWN:
- if (Game) {
- if (Game->isRightDoubleClick()) Game->onMouseRightDblClick();
- else Game->onMouseRightDown();
+ if (_gameRef) {
+ if (_gameRef->isRightDoubleClick()) _gameRef->onMouseRightDblClick();
+ else _gameRef->onMouseRightDown();
}
break;
case Common::EVENT_MBUTTONDOWN:
- if (Game) Game->onMouseMiddleDown();
+ if (_gameRef) _gameRef->onMouseMiddleDown();
break;
case Common::EVENT_LBUTTONUP:
- if (Game) Game->onMouseLeftUp();
+ if (_gameRef) _gameRef->onMouseLeftUp();
break;
case Common::EVENT_RBUTTONUP:
- if (Game) Game->onMouseRightUp();
+ if (_gameRef) _gameRef->onMouseRightUp();
break;
case Common::EVENT_MBUTTONUP:
- if (Game) Game->onMouseMiddleUp();
+ if (_gameRef) _gameRef->onMouseMiddleUp();
break;
case Common::EVENT_KEYDOWN:
- if (Game) Game->handleKeypress(event);
+ if (_gameRef) _gameRef->handleKeypress(event);
break;
case Common::EVENT_KEYUP:
- if (Game) Game->handleKeyRelease(event);
+ if (_gameRef) _gameRef->handleKeyRelease(event);
break;
case Common::EVENT_WHEELUP:
case Common::EVENT_WHEELDOWN:
- if (Game) Game->handleMouseWheel(event->mouse.y);
+ if (_gameRef) _gameRef->handleMouseWheel(event->mouse.y);
break;
/*#ifdef __IPHONEOS__
{
- CBRenderSDL *renderer = static_cast<CBRenderSDL *>(Game->_renderer);
+ CBRenderSDL *renderer = static_cast<CBRenderSDL *>(_gameRef->_renderer);
POINT p;
GetCursorPos(&p);
- Game->SetActiveObject(renderer->GetObjectAt(p.x, p.y));
+ _gameRef->SetActiveObject(renderer->GetObjectAt(p.x, p.y));
- if (Game->_activeObject != NULL && strcmp(Game->_activeObject->getClassName(), "CUIButton") == 0) {
- CUIButton *btn = static_cast<CUIButton *>(Game->_activeObject);
+ if (_gameRef->_activeObject != NULL && strcmp(_gameRef->_activeObject->getClassName(), "CUIButton") == 0) {
+ CUIButton *btn = static_cast<CUIButton *>(_gameRef->_activeObject);
if (btn->_visible && !btn->_disable) btn->_press = true;
}
}
@@ -102,25 +102,25 @@ void CBPlatform::handleEvent(Common::Event *event) { //TODO
/* case SDL_MOUSEWHEEL:
- if (Game) Game->handleMouseWheel(event->wheel.y);
+ if (_gameRef) _gameRef->handleMouseWheel(event->wheel.y);
break;
case SDL_KEYDOWN:
case SDL_TEXTINPUT:
- if (Game) Game->handleKeypress(event);
+ if (_gameRef) _gameRef->handleKeypress(event);
break;
case SDL_WINDOWEVENT:
switch (event->window.event) {
case SDL_WINDOWEVENT_FOCUS_GAINED:
case SDL_WINDOWEVENT_RESTORED:
- if (Game) Game->OnActivate(true, true);
+ if (_gameRef) _gameRef->OnActivate(true, true);
SDL_ShowCursor(SDL_DISABLE);
break;
case SDL_WINDOWEVENT_FOCUS_LOST:
case SDL_WINDOWEVENT_MINIMIZED:
#ifndef __IPHONEOS__
- if (Game) Game->OnActivate(false, false);
+ if (_gameRef) _gameRef->OnActivate(false, false);
SDL_ShowCursor(SDL_ENABLE);
#endif
break;
@@ -134,12 +134,12 @@ void CBPlatform::handleEvent(Common::Event *event) { case Common::EVENT_QUIT:
case Common::EVENT_RTL:
/*#ifdef __IPHONEOS__
- if (Game) {
- Game->AutoSaveOnExit();
- Game->_quitting = true;
+ if (_gameRef) {
+ _gameRef->AutoSaveOnExit();
+ _gameRef->_quitting = true;
}
#else*/
- if (Game) Game->onWindowClose();
+ if (_gameRef) _gameRef->onWindowClose();
//#endif
break;
@@ -154,8 +154,8 @@ void CBPlatform::handleEvent(Common::Event *event) { int CBPlatform::SDLEventWatcher(void *userdata, Common::Event *event) {
//TODO
/* if (event->type == SDL_WINDOWEVENT && event->window.event == SDL_WINDOWEVENT_MINIMIZED) {
- if (Game) Game->AutoSaveOnExit();
- if (Game) Game->OnActivate(false, false);
+ if (_gameRef) _gameRef->AutoSaveOnExit();
+ if (_gameRef) _gameRef->OnActivate(false, false);
SDL_ShowCursor(SDL_ENABLE);
}
*/
@@ -182,7 +182,7 @@ uint32 CBPlatform::getTime() { //////////////////////////////////////////////////////////////////////////
bool CBPlatform::getCursorPos(Point32 *lpPoint) {
- CBRenderSDL *renderer = static_cast<CBRenderSDL *>(Game->_renderer);
+ CBRenderSDL *renderer = static_cast<CBRenderSDL *>(_gameRef->_renderer);
Common::Point p = g_system->getEventManager()->getMousePos();
lpPoint->x = p.x;
@@ -195,7 +195,7 @@ bool CBPlatform::getCursorPos(Point32 *lpPoint) { //////////////////////////////////////////////////////////////////////////
bool CBPlatform::setCursorPos(int X, int Y) {
- CBRenderSDL *renderer = static_cast<CBRenderSDL *>(Game->_renderer);
+ CBRenderSDL *renderer = static_cast<CBRenderSDL *>(_gameRef->_renderer);
Point32 p;
p.x = X;
diff --git a/engines/wintermute/PlatformSDL.h b/engines/wintermute/PlatformSDL.h index 547f6b81b1..155c4e0f06 100644 --- a/engines/wintermute/PlatformSDL.h +++ b/engines/wintermute/PlatformSDL.h @@ -80,7 +80,7 @@ public: static int SDLEventWatcher(void *userdata, Common::Event *event);
private:
- static CBGame *Game;
+ static CBGame *_gameRef;
};
} // end of namespace WinterMute
diff --git a/engines/wintermute/Sys/SysClass.cpp b/engines/wintermute/Sys/SysClass.cpp index 91639bc0ba..dee4b7d2d0 100644 --- a/engines/wintermute/Sys/SysClass.cpp +++ b/engines/wintermute/Sys/SysClass.cpp @@ -128,7 +128,7 @@ void CSysClass::dump(Common::WriteStream *stream) { }
//////////////////////////////////////////////////////////////////////////
-void CSysClass::saveTable(CBGame *Game, CBPersistMgr *persistMgr) {
+void CSysClass::saveTable(CBGame *gameRef, CBPersistMgr *persistMgr) {
persistMgr->putString(_name.c_str());
persistMgr->putDWORD(_iD);
persistMgr->putDWORD(_instances.size());
@@ -140,7 +140,7 @@ void CSysClass::saveTable(CBGame *Game, CBPersistMgr *persistMgr) { }
//////////////////////////////////////////////////////////////////////////
-void CSysClass::loadTable(CBGame *Game, CBPersistMgr *persistMgr) {
+void CSysClass::loadTable(CBGame *gameRef, CBPersistMgr *persistMgr) {
_savedID = persistMgr->getDWORD();
int numInstances = persistMgr->getDWORD();
@@ -149,7 +149,7 @@ void CSysClass::loadTable(CBGame *Game, CBPersistMgr *persistMgr) { if (_persistent) {
if (i > 0) {
- Game->LOG(0, "Warning: attempting to load multiple instances of persistent class %s (%d)", _name.c_str(), numInstances);
+ gameRef->LOG(0, "Warning: attempting to load multiple instances of persistent class %s (%d)", _name.c_str(), numInstances);
continue;
}
@@ -157,7 +157,7 @@ void CSysClass::loadTable(CBGame *Game, CBPersistMgr *persistMgr) { if (it != _instances.end()) {
(it->_value)->setSavedID(instID);
CSysClassRegistry::getInstance()->addInstanceToTable((it->_value), (it->_value)->getInstance());
- } else Game->LOG(0, "Warning: instance %d of persistent class %s not found", i, _name.c_str());
+ } else gameRef->LOG(0, "Warning: instance %d of persistent class %s not found", i, _name.c_str());
}
// normal instances, create empty objects
else {
diff --git a/engines/wintermute/Sys/SysClassRegistry.cpp b/engines/wintermute/Sys/SysClassRegistry.cpp index 4bdb571df4..b829aece35 100644 --- a/engines/wintermute/Sys/SysClassRegistry.cpp +++ b/engines/wintermute/Sys/SysClassRegistry.cpp @@ -167,7 +167,7 @@ bool checkHeader(const char *tag, CBPersistMgr *pm) { }
//////////////////////////////////////////////////////////////////////////
-ERRORCODE CSysClassRegistry::saveTable(CBGame *Game, CBPersistMgr *persistMgr, bool quickSave) {
+ERRORCODE CSysClassRegistry::saveTable(CBGame *gameRef, CBPersistMgr *persistMgr, bool quickSave) {
persistMgr->putString("<CLASS_REGISTRY_TABLE>");
persistMgr->putDWORD(_classes.size());
@@ -178,12 +178,12 @@ ERRORCODE CSysClassRegistry::saveTable(CBGame *Game, CBPersistMgr *persistMgr, b counter++;
if (!quickSave) {
- Game->_indicatorProgress = (int)(50.0f / (float)((float)_classes.size() / (float)counter));
- Game->displayContent(false);
- Game->_renderer->flip();
+ gameRef->_indicatorProgress = (int)(50.0f / (float)((float)_classes.size() / (float)counter));
+ gameRef->displayContent(false);
+ gameRef->_renderer->flip();
}
- (it->_value)->saveTable(Game, persistMgr);
+ (it->_value)->saveTable(gameRef, persistMgr);
}
persistMgr->putString("</CLASS_REGISTRY_TABLE>");
return STATUS_OK;
@@ -191,7 +191,7 @@ ERRORCODE CSysClassRegistry::saveTable(CBGame *Game, CBPersistMgr *persistMgr, b //////////////////////////////////////////////////////////////////////////
-ERRORCODE CSysClassRegistry::loadTable(CBGame *Game, CBPersistMgr *persistMgr) {
+ERRORCODE CSysClassRegistry::loadTable(CBGame *gameRef, CBPersistMgr *persistMgr) {
checkHeader("<CLASS_REGISTRY_TABLE>", persistMgr);
// reset SavedID of current instances
@@ -210,13 +210,13 @@ ERRORCODE CSysClassRegistry::loadTable(CBGame *Game, CBPersistMgr *persistMgr) { uint32 numClasses = persistMgr->getDWORD();
for (uint32 i = 0; i < numClasses; i++) {
- Game->_indicatorProgress = (int)(50.0f / (float)((float)numClasses / (float)i));
- Game->displayContentSimple();
- Game->_renderer->flip();
+ gameRef->_indicatorProgress = (int)(50.0f / (float)((float)numClasses / (float)i));
+ gameRef->displayContentSimple();
+ gameRef->_renderer->flip();
Common::String className = persistMgr->getStringObj();
NameMap::iterator mapIt = _nameMap.find(className);
- if (mapIt != _nameMap.end())(*mapIt)._value->loadTable(Game, persistMgr);
+ if (mapIt != _nameMap.end())(*mapIt)._value->loadTable(gameRef, persistMgr);
}
checkHeader("</CLASS_REGISTRY_TABLE>", persistMgr);
@@ -226,7 +226,7 @@ ERRORCODE CSysClassRegistry::loadTable(CBGame *Game, CBPersistMgr *persistMgr) { //////////////////////////////////////////////////////////////////////////
-ERRORCODE CSysClassRegistry::saveInstances(CBGame *Game, CBPersistMgr *persistMgr, bool quickSave) {
+ERRORCODE CSysClassRegistry::saveInstances(CBGame *gameRef, CBPersistMgr *persistMgr, bool quickSave) {
Classes::iterator it;
@@ -244,29 +244,29 @@ ERRORCODE CSysClassRegistry::saveInstances(CBGame *Game, CBPersistMgr *persistMg if (!quickSave) {
if (counter % 20 == 0) {
- Game->_indicatorProgress = (int)(50.0f + 50.0f / (float)((float)_classes.size() / (float)counter));
- Game->displayContent(false);
- Game->_renderer->flip();
+ gameRef->_indicatorProgress = (int)(50.0f + 50.0f / (float)((float)_classes.size() / (float)counter));
+ gameRef->displayContent(false);
+ gameRef->_renderer->flip();
}
}
- Game->miniUpdate();
+ gameRef->miniUpdate();
- (it->_value)->saveInstances(Game, persistMgr);
+ (it->_value)->saveInstances(gameRef, persistMgr);
}
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
-ERRORCODE CSysClassRegistry::loadInstances(CBGame *Game, CBPersistMgr *persistMgr) {
+ERRORCODE CSysClassRegistry::loadInstances(CBGame *gameRef, CBPersistMgr *persistMgr) {
// get total instances
int numInstances = persistMgr->getDWORD();
for (int i = 0; i < numInstances; i++) {
if (i % 20 == 0) {
- Game->_indicatorProgress = (int)(50.0f + 50.0f / (float)((float)numInstances / (float)i));
- Game->displayContentSimple();
- Game->_renderer->flip();
+ gameRef->_indicatorProgress = (int)(50.0f + 50.0f / (float)((float)numInstances / (float)i));
+ gameRef->displayContentSimple();
+ gameRef->_renderer->flip();
}
checkHeader("<INSTANCE_HEAD>", persistMgr);
diff --git a/engines/wintermute/UI/UIButton.cpp b/engines/wintermute/UI/UIButton.cpp index 85932ca603..5a8b994344 100644 --- a/engines/wintermute/UI/UIButton.cpp +++ b/engines/wintermute/UI/UIButton.cpp @@ -79,10 +79,10 @@ CUIButton::~CUIButton() { delete _backFocus;
if (!_sharedFonts) {
- if (_fontHover) Game->_fontStorage->removeFont(_fontHover);
- if (_fontPress) Game->_fontStorage->removeFont(_fontPress);
- if (_fontDisable) Game->_fontStorage->removeFont(_fontDisable);
- if (_fontFocus) Game->_fontStorage->removeFont(_fontFocus);
+ if (_fontHover) _gameRef->_fontStorage->removeFont(_fontHover);
+ if (_fontPress) _gameRef->_fontStorage->removeFont(_fontPress);
+ if (_fontDisable) _gameRef->_fontStorage->removeFont(_fontDisable);
+ if (_fontFocus) _gameRef->_fontStorage->removeFont(_fontFocus);
}
if (!_sharedImages) {
@@ -96,9 +96,9 @@ CUIButton::~CUIButton() { //////////////////////////////////////////////////////////////////////////
ERRORCODE CUIButton::loadFile(const char *filename) {
- byte *buffer = Game->_fileManager->readWholeFile(filename);
+ byte *buffer = _gameRef->_fileManager->readWholeFile(filename);
if (buffer == NULL) {
- Game->LOG(0, "CUIButton::LoadFile failed for file '%s'", filename);
+ _gameRef->LOG(0, "CUIButton::LoadFile failed for file '%s'", filename);
return STATUS_FAILED;
}
@@ -107,7 +107,7 @@ ERRORCODE CUIButton::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 BUTTON file '%s'", filename);
+ if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing BUTTON file '%s'", filename);
delete [] buffer;
@@ -196,11 +196,11 @@ ERRORCODE CUIButton::loadBuffer(byte *buffer, bool complete) { byte *params;
int cmd = 2;
- CBParser parser(Game);
+ CBParser parser(_gameRef);
if (complete) {
if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_BUTTON) {
- Game->LOG(0, "'BUTTON' keyword expected.");
+ _gameRef->LOG(0, "'BUTTON' keyword expected.");
return STATUS_FAILED;
}
buffer = params;
@@ -222,7 +222,7 @@ ERRORCODE CUIButton::loadBuffer(byte *buffer, bool complete) { case TOKEN_BACK:
delete _back;
- _back = new CUITiledImage(Game);
+ _back = new CUITiledImage(_gameRef);
if (!_back || DID_FAIL(_back->loadFile((char *)params))) {
delete _back;
_back = NULL;
@@ -232,7 +232,7 @@ ERRORCODE CUIButton::loadBuffer(byte *buffer, bool complete) { case TOKEN_BACK_HOVER:
delete _backHover;
- _backHover = new CUITiledImage(Game);
+ _backHover = new CUITiledImage(_gameRef);
if (!_backHover || DID_FAIL(_backHover->loadFile((char *)params))) {
delete _backHover;
_backHover = NULL;
@@ -242,7 +242,7 @@ ERRORCODE CUIButton::loadBuffer(byte *buffer, bool complete) { case TOKEN_BACK_PRESS:
delete _backPress;
- _backPress = new CUITiledImage(Game);
+ _backPress = new CUITiledImage(_gameRef);
if (!_backPress || DID_FAIL(_backPress->loadFile((char *)params))) {
delete _backPress;
_backPress = NULL;
@@ -252,7 +252,7 @@ ERRORCODE CUIButton::loadBuffer(byte *buffer, bool complete) { case TOKEN_BACK_DISABLE:
delete _backDisable;
- _backDisable = new CUITiledImage(Game);
+ _backDisable = new CUITiledImage(_gameRef);
if (!_backDisable || DID_FAIL(_backDisable->loadFile((char *)params))) {
delete _backDisable;
_backDisable = NULL;
@@ -262,7 +262,7 @@ ERRORCODE CUIButton::loadBuffer(byte *buffer, bool complete) { case TOKEN_BACK_FOCUS:
delete _backFocus;
- _backFocus = new CUITiledImage(Game);
+ _backFocus = new CUITiledImage(_gameRef);
if (!_backFocus || DID_FAIL(_backFocus->loadFile((char *)params))) {
delete _backFocus;
_backFocus = NULL;
@@ -272,7 +272,7 @@ ERRORCODE CUIButton::loadBuffer(byte *buffer, bool complete) { case TOKEN_IMAGE:
delete _image;
- _image = new CBSprite(Game);
+ _image = new CBSprite(_gameRef);
if (!_image || DID_FAIL(_image->loadFile((char *)params))) {
delete _image;
_image = NULL;
@@ -282,7 +282,7 @@ ERRORCODE CUIButton::loadBuffer(byte *buffer, bool complete) { case TOKEN_IMAGE_HOVER:
delete _imageHover;
- _imageHover = new CBSprite(Game);
+ _imageHover = new CBSprite(_gameRef);
if (!_imageHover || DID_FAIL(_imageHover->loadFile((char *)params))) {
delete _imageHover;
_imageHover = NULL;
@@ -292,7 +292,7 @@ ERRORCODE CUIButton::loadBuffer(byte *buffer, bool complete) { case TOKEN_IMAGE_PRESS:
delete _imagePress;
- _imagePress = new CBSprite(Game);
+ _imagePress = new CBSprite(_gameRef);
if (!_imagePress || DID_FAIL(_imagePress->loadFile((char *)params))) {
delete _imagePress;
_imagePress = NULL;
@@ -302,7 +302,7 @@ ERRORCODE CUIButton::loadBuffer(byte *buffer, bool complete) { case TOKEN_IMAGE_DISABLE:
delete _imageDisable;
- _imageDisable = new CBSprite(Game);
+ _imageDisable = new CBSprite(_gameRef);
if (!_imageDisable || DID_FAIL(_imageDisable->loadFile((char *)params))) {
delete _imageDisable;
_imageDisable = NULL;
@@ -312,7 +312,7 @@ ERRORCODE CUIButton::loadBuffer(byte *buffer, bool complete) { case TOKEN_IMAGE_FOCUS:
delete _imageFocus;
- _imageFocus = new CBSprite(Game);
+ _imageFocus = new CBSprite(_gameRef);
if (!_imageFocus || DID_FAIL(_imageFocus->loadFile((char *)params))) {
delete _imageFocus;
_imageFocus = NULL;
@@ -321,38 +321,38 @@ ERRORCODE CUIButton::loadBuffer(byte *buffer, bool complete) { break;
case TOKEN_FONT:
- if (_font) Game->_fontStorage->removeFont(_font);
- _font = Game->_fontStorage->addFont((char *)params);
+ if (_font) _gameRef->_fontStorage->removeFont(_font);
+ _font = _gameRef->_fontStorage->addFont((char *)params);
if (!_font) cmd = PARSERR_GENERIC;
break;
case TOKEN_FONT_HOVER:
- if (_fontHover) Game->_fontStorage->removeFont(_fontHover);
- _fontHover = Game->_fontStorage->addFont((char *)params);
+ if (_fontHover) _gameRef->_fontStorage->removeFont(_fontHover);
+ _fontHover = _gameRef->_fontStorage->addFont((char *)params);
if (!_fontHover) cmd = PARSERR_GENERIC;
break;
case TOKEN_FONT_PRESS:
- if (_fontPress) Game->_fontStorage->removeFont(_fontPress);
- _fontPress = Game->_fontStorage->addFont((char *)params);
+ if (_fontPress) _gameRef->_fontStorage->removeFont(_fontPress);
+ _fontPress = _gameRef->_fontStorage->addFont((char *)params);
if (!_fontPress) cmd = PARSERR_GENERIC;
break;
case TOKEN_FONT_DISABLE:
- if (_fontDisable) Game->_fontStorage->removeFont(_fontDisable);
- _fontDisable = Game->_fontStorage->addFont((char *)params);
+ if (_fontDisable) _gameRef->_fontStorage->removeFont(_fontDisable);
+ _fontDisable = _gameRef->_fontStorage->addFont((char *)params);
if (!_fontDisable) cmd = PARSERR_GENERIC;
break;
case TOKEN_FONT_FOCUS:
- if (_fontFocus) Game->_fontStorage->removeFont(_fontFocus);
- _fontFocus = Game->_fontStorage->addFont((char *)params);
+ if (_fontFocus) _gameRef->_fontStorage->removeFont(_fontFocus);
+ _fontFocus = _gameRef->_fontStorage->addFont((char *)params);
if (!_fontFocus) cmd = PARSERR_GENERIC;
break;
case TOKEN_TEXT:
setText((char *)params);
- Game->_stringTable->expand(&_text);
+ _gameRef->_stringTable->expand(&_text);
break;
case TOKEN_TEXT_ALIGN:
@@ -379,7 +379,7 @@ ERRORCODE CUIButton::loadBuffer(byte *buffer, bool complete) { 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;
@@ -425,11 +425,11 @@ ERRORCODE CUIButton::loadBuffer(byte *buffer, bool complete) { }
}
if (cmd == PARSERR_TOKENNOTFOUND) {
- Game->LOG(0, "Syntax error in BUTTON definition");
+ _gameRef->LOG(0, "Syntax error in BUTTON definition");
return STATUS_FAILED;
}
if (cmd == PARSERR_GENERIC) {
- Game->LOG(0, "Error loading BUTTON definition");
+ _gameRef->LOG(0, "Error loading BUTTON definition");
return STATUS_FAILED;
}
@@ -565,7 +565,7 @@ void CUIButton::correctSize() { if (_text) {
int text_height;
if (_font) text_height = _font->getTextHeight((byte *)_text, _width);
- else text_height = Game->_systemFont->getTextHeight((byte *)_text, _width);
+ else text_height = _gameRef->_systemFont->getTextHeight((byte *)_text, _width);
if (text_height > _height) _height = text_height;
}
@@ -587,10 +587,10 @@ ERRORCODE CUIButton::display(int offsetX, int offsetY) { //RECT rect;
//CBPlatform::setRect(&rect, OffsetX + _posX, OffsetY + _posY, OffsetX+_posX+_width, OffsetY+_posY+_height);
- //_hover = (!_disable && CBPlatform::ptInRect(&rect, Game->_mousePos)!=FALSE);
- _hover = (!_disable && Game->_activeObject == this && (Game->_interactive || Game->_state == GAME_SEMI_FROZEN));
+ //_hover = (!_disable && CBPlatform::ptInRect(&rect, _gameRef->_mousePos)!=FALSE);
+ _hover = (!_disable && _gameRef->_activeObject == this && (_gameRef->_interactive || _gameRef->_state == GAME_SEMI_FROZEN));
- if ((_press && _hover && !Game->_mouseLeftDown) ||
+ if ((_press && _hover && !_gameRef->_mouseLeftDown) ||
(_oneTimePress && CBPlatform::getTime() - _oneTimePressTime >= 100)) press();
@@ -616,7 +616,7 @@ ERRORCODE CUIButton::display(int offsetX, int offsetY) { if (!image && _image) image = _image;
if (_text && !font) {
if (_font) font = _font;
- else font = Game->_systemFont;
+ else font = _gameRef->_systemFont;
}
int imageX = offsetX + _posX;
@@ -638,7 +638,7 @@ ERRORCODE CUIButton::display(int offsetX, int offsetY) { font->drawText((byte *)_text, offsetX + _posX + ((_press || _oneTimePress) ? 1 : 0), offsetY + _posY + text_offset + ((_press || _oneTimePress) ? 1 : 0), _width, _align);
}
- if (!_pixelPerfect || !_image) Game->_renderer->_rectList.add(new CBActiveRect(Game, this, NULL, offsetX + _posX, offsetY + _posY, _width, _height, 100, 100, false));
+ if (!_pixelPerfect || !_image) _gameRef->_renderer->_rectList.add(new CBActiveRect(_gameRef, this, NULL, offsetX + _posX, offsetY + _posY, _width, _height, 100, 100, false));
// reset unused sprites
if (_image && _image != image) _image->reset();
@@ -647,7 +647,7 @@ ERRORCODE CUIButton::display(int offsetX, int offsetY) { if (_imagePress && _imagePress != image) _imagePress->reset();
if (_imageHover && _imageHover != image) _imageHover->reset();
- _press = _hover && Game->_mouseLeftDown && Game->_capturedObject == this;
+ _press = _hover && _gameRef->_mouseLeftDown && _gameRef->_capturedObject == this;
return STATUS_OK;
}
@@ -674,12 +674,12 @@ ERRORCODE CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack * stack->correctParams(1);
CScValue *Val = stack->pop();
- if (_fontDisable) Game->_fontStorage->removeFont(_fontDisable);
+ if (_fontDisable) _gameRef->_fontStorage->removeFont(_fontDisable);
if (Val->isNULL()) {
_fontDisable = NULL;
stack->pushBool(true);
} else {
- _fontDisable = Game->_fontStorage->addFont(Val->getString());
+ _fontDisable = _gameRef->_fontStorage->addFont(Val->getString());
stack->pushBool(_fontDisable != NULL);
}
return STATUS_OK;
@@ -692,12 +692,12 @@ ERRORCODE CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack * stack->correctParams(1);
CScValue *val = stack->pop();
- if (_fontHover) Game->_fontStorage->removeFont(_fontHover);
+ if (_fontHover) _gameRef->_fontStorage->removeFont(_fontHover);
if (val->isNULL()) {
_fontHover = NULL;
stack->pushBool(true);
} else {
- _fontHover = Game->_fontStorage->addFont(val->getString());
+ _fontHover = _gameRef->_fontStorage->addFont(val->getString());
stack->pushBool(_fontHover != NULL);
}
return STATUS_OK;
@@ -710,12 +710,12 @@ ERRORCODE CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack * stack->correctParams(1);
CScValue *Val = stack->pop();
- if (_fontPress) Game->_fontStorage->removeFont(_fontPress);
+ if (_fontPress) _gameRef->_fontStorage->removeFont(_fontPress);
if (Val->isNULL()) {
_fontPress = NULL;
stack->pushBool(true);
} else {
- _fontPress = Game->_fontStorage->addFont(Val->getString());
+ _fontPress = _gameRef->_fontStorage->addFont(Val->getString());
stack->pushBool(_fontPress != NULL);
}
return STATUS_OK;
@@ -728,12 +728,12 @@ ERRORCODE CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack * stack->correctParams(1);
CScValue *val = stack->pop();
- if (_fontFocus) Game->_fontStorage->removeFont(_fontFocus);
+ if (_fontFocus) _gameRef->_fontStorage->removeFont(_fontFocus);
if (val->isNULL()) {
_fontFocus = NULL;
stack->pushBool(true);
} else {
- _fontFocus = Game->_fontStorage->addFont(val->getString());
+ _fontFocus = _gameRef->_fontStorage->addFont(val->getString());
stack->pushBool(_fontFocus != NULL);
}
return STATUS_OK;
@@ -746,7 +746,7 @@ ERRORCODE CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack * stack->correctParams(1);
delete _imageDisable;
- _imageDisable = new CBSprite(Game);
+ _imageDisable = new CBSprite(_gameRef);
const char *filename = stack->pop()->getString();
if (!_imageDisable || DID_FAIL(_imageDisable->loadFile(filename))) {
delete _imageDisable;
@@ -787,7 +787,7 @@ ERRORCODE CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack * stack->correctParams(1);
delete _imageHover;
- _imageHover = new CBSprite(Game);
+ _imageHover = new CBSprite(_gameRef);
const char *filename = stack->pop()->getString();
if (!_imageHover || DID_FAIL(_imageHover->loadFile(filename))) {
delete _imageHover;
@@ -827,7 +827,7 @@ ERRORCODE CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack * stack->correctParams(1);
delete _imagePress;
- _imagePress = new CBSprite(Game);
+ _imagePress = new CBSprite(_gameRef);
const char *filename = stack->pop()->getString();
if (!_imagePress || DID_FAIL(_imagePress->loadFile(filename))) {
delete _imagePress;
@@ -867,7 +867,7 @@ ERRORCODE CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack * stack->correctParams(1);
delete _imageFocus;
- _imageFocus = new CBSprite(Game);
+ _imageFocus = new CBSprite(_gameRef);
const char *filename = stack->pop()->getString();
if (!_imageFocus || DID_FAIL(_imageFocus->loadFile(filename))) {
delete _imageFocus;
diff --git a/engines/wintermute/UI/UIEdit.cpp b/engines/wintermute/UI/UIEdit.cpp index b47885b4dc..c3cb3ad810 100644 --- a/engines/wintermute/UI/UIEdit.cpp +++ b/engines/wintermute/UI/UIEdit.cpp @@ -82,7 +82,7 @@ CUIEdit::CUIEdit(CBGame *inGame): CUIObject(inGame) { //////////////////////////////////////////////////////////////////////////
CUIEdit::~CUIEdit() {
if (!_sharedFonts) {
- if (_fontSelected) Game->_fontStorage->removeFont(_fontSelected);
+ if (_fontSelected) _gameRef->_fontStorage->removeFont(_fontSelected);
}
delete[] _cursorChar;
@@ -92,9 +92,9 @@ CUIEdit::~CUIEdit() { //////////////////////////////////////////////////////////////////////////
ERRORCODE CUIEdit::loadFile(const char *filename) {
- byte *buffer = Game->_fileManager->readWholeFile(filename);
+ byte *buffer = _gameRef->_fileManager->readWholeFile(filename);
if (buffer == NULL) {
- Game->LOG(0, "CUIEdit::LoadFile failed for file '%s'", filename);
+ _gameRef->LOG(0, "CUIEdit::LoadFile failed for file '%s'", filename);
return STATUS_FAILED;
}
@@ -103,7 +103,7 @@ ERRORCODE CUIEdit::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 EDIT file '%s'", filename);
+ if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing EDIT file '%s'", filename);
delete [] buffer;
@@ -164,11 +164,11 @@ ERRORCODE CUIEdit::loadBuffer(byte *buffer, bool complete) { byte *params;
int cmd = 2;
- CBParser parser(Game);
+ CBParser parser(_gameRef);
if (complete) {
if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_EDIT) {
- Game->LOG(0, "'EDIT' keyword expected.");
+ _gameRef->LOG(0, "'EDIT' keyword expected.");
return STATUS_FAILED;
}
buffer = params;
@@ -186,7 +186,7 @@ ERRORCODE CUIEdit::loadBuffer(byte *buffer, bool complete) { case TOKEN_BACK:
delete _back;
- _back = new CUITiledImage(Game);
+ _back = new CUITiledImage(_gameRef);
if (!_back || DID_FAIL(_back->loadFile((char *)params))) {
delete _back;
_back = NULL;
@@ -196,7 +196,7 @@ ERRORCODE CUIEdit::loadBuffer(byte *buffer, bool complete) { case TOKEN_IMAGE:
delete _image;
- _image = new CBSprite(Game);
+ _image = new CBSprite(_gameRef);
if (!_image || DID_FAIL(_image->loadFile((char *)params))) {
delete _image;
_image = NULL;
@@ -205,20 +205,20 @@ ERRORCODE CUIEdit::loadBuffer(byte *buffer, bool complete) { break;
case TOKEN_FONT:
- if (_font) Game->_fontStorage->removeFont(_font);
- _font = Game->_fontStorage->addFont((char *)params);
+ if (_font) _gameRef->_fontStorage->removeFont(_font);
+ _font = _gameRef->_fontStorage->addFont((char *)params);
if (!_font) cmd = PARSERR_GENERIC;
break;
case TOKEN_FONT_SELECTED:
- if (_fontSelected) Game->_fontStorage->removeFont(_fontSelected);
- _fontSelected = Game->_fontStorage->addFont((char *)params);
+ if (_fontSelected) _gameRef->_fontStorage->removeFont(_fontSelected);
+ _fontSelected = _gameRef->_fontStorage->addFont((char *)params);
if (!_fontSelected) cmd = PARSERR_GENERIC;
break;
case TOKEN_TEXT:
setText((char *)params);
- Game->_stringTable->expand(&_text);
+ _gameRef->_stringTable->expand(&_text);
break;
case TOKEN_X:
@@ -247,7 +247,7 @@ ERRORCODE CUIEdit::loadBuffer(byte *buffer, bool complete) { 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;
@@ -285,11 +285,11 @@ ERRORCODE CUIEdit::loadBuffer(byte *buffer, bool complete) { }
}
if (cmd == PARSERR_TOKENNOTFOUND) {
- Game->LOG(0, "Syntax error in EDIT definition");
+ _gameRef->LOG(0, "Syntax error in EDIT definition");
return STATUS_FAILED;
}
if (cmd == PARSERR_GENERIC) {
- Game->LOG(0, "Error loading EDIT definition");
+ _gameRef->LOG(0, "Error loading EDIT definition");
return STATUS_FAILED;
}
@@ -365,8 +365,8 @@ ERRORCODE CUIEdit::scCallMethod(CScScript *script, CScStack *stack, CScStack *th if (strcmp(name, "SetSelectedFont") == 0) {
stack->correctParams(1);
- if (_fontSelected) Game->_fontStorage->removeFont(_fontSelected);
- _fontSelected = Game->_fontStorage->addFont(stack->pop()->getString());
+ if (_fontSelected) _gameRef->_fontStorage->removeFont(_fontSelected);
+ _fontSelected = _gameRef->_fontStorage->addFont(stack->pop()->getString());
stack->pushBool(_fontSelected != NULL);
return STATUS_OK;
@@ -440,7 +440,7 @@ CScValue *CUIEdit::scGetProperty(const char *name) { // Text
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "Text") == 0) {
- if (Game->_textEncoding == TEXT_UTF8) {
+ if (_gameRef->_textEncoding == TEXT_UTF8) {
WideString wstr = StringUtil::ansiToWide(_text);
_scValue->setString(StringUtil::wideToUtf8(wstr).c_str());
} else {
@@ -511,7 +511,7 @@ ERRORCODE CUIEdit::scSetProperty(const char *name, CScValue *value) { // Text
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "Text") == 0) {
- if (Game->_textEncoding == TEXT_UTF8) {
+ if (_gameRef->_textEncoding == TEXT_UTF8) {
WideString wstr = StringUtil::utf8ToWide(value->getString());
setText(StringUtil::wideToAnsi(wstr).c_str());
} else {
@@ -545,8 +545,8 @@ ERRORCODE CUIEdit::display(int offsetX, int offsetY) { // hack!
- TTextEncoding OrigEncoding = Game->_textEncoding;
- Game->_textEncoding = TEXT_ANSI;
+ TTextEncoding OrigEncoding = _gameRef->_textEncoding;
+ _gameRef->_textEncoding = TEXT_ANSI;
if (_back) _back->display(offsetX + _posX, offsetY + _posY, _width, _height);
if (_image) _image->draw(offsetX + _posX, offsetY + _posY, NULL);
@@ -556,7 +556,7 @@ ERRORCODE CUIEdit::display(int offsetX, int offsetY) { CBFont *sfont;
if (_font) font = _font;
- else font = Game->_systemFont;
+ else font = _gameRef->_systemFont;
if (_fontSelected) sfont = _fontSelected;
else sfont = font;
@@ -615,7 +615,7 @@ ERRORCODE CUIEdit::display(int offsetX, int offsetY) { width = _posX + _width + offsetX - _frameWidth;
height = MAX(font->getLetterHeight(), sfont->getLetterHeight());
- if (Game->_textRTL) xxx += AlignOffset;
+ if (_gameRef->_textRTL) xxx += AlignOffset;
TTextAlign Align = TAL_LEFT;
@@ -673,10 +673,10 @@ ERRORCODE CUIEdit::display(int offsetX, int offsetY) { }
- Game->_renderer->_rectList.add(new CBActiveRect(Game, this, NULL, offsetX + _posX, offsetY + _posY, _width, _height, 100, 100, false));
+ _gameRef->_renderer->_rectList.add(new CBActiveRect(_gameRef, this, NULL, offsetX + _posX, offsetY + _posY, _width, _height, 100, 100, false));
- Game->_textEncoding = OrigEncoding;
+ _gameRef->_textEncoding = OrigEncoding;
return STATUS_OK;
}
@@ -704,7 +704,7 @@ bool CUIEdit::handleKeypress(Common::Event *event, bool printable) { case Common::KEYCODE_BACKSPACE:
if (_selStart == _selEnd) {
- if (Game->_textRTL) deleteChars(_selStart, _selStart + 1);
+ if (_gameRef->_textRTL) deleteChars(_selStart, _selStart + 1);
else deleteChars(_selStart - 1, _selStart);
} else deleteChars(_selStart, _selEnd);
if (_selEnd >= _selStart) _selEnd -= MAX(1, _selEnd - _selStart);
@@ -728,7 +728,7 @@ bool CUIEdit::handleKeypress(Common::Event *event, bool printable) { break;
case Common::KEYCODE_HOME:
- if (Game->_textRTL) {
+ if (_gameRef->_textRTL) {
_selEnd = strlen(_text);
if (!CBKeyboardState::isShiftDown()) _selStart = _selEnd;
} else {
@@ -739,7 +739,7 @@ bool CUIEdit::handleKeypress(Common::Event *event, bool printable) { break;
case Common::KEYCODE_END:
- if (Game->_textRTL) {
+ if (_gameRef->_textRTL) {
_selEnd = 0;
if (!CBKeyboardState::isShiftDown()) _selStart = _selEnd;
} else {
@@ -751,7 +751,7 @@ bool CUIEdit::handleKeypress(Common::Event *event, bool printable) { case Common::KEYCODE_DELETE:
if (_selStart == _selEnd) {
- if (Game->_textRTL) {
+ if (_gameRef->_textRTL) {
deleteChars(_selStart - 1, _selStart);
_selEnd--;
if (_selEnd < 0) _selEnd = 0;
@@ -774,7 +774,7 @@ bool CUIEdit::handleKeypress(Common::Event *event, bool printable) { wstr += (char)event->kbd.ascii;
_selEnd += insertChars(_selEnd, (byte *)StringUtil::wideToAnsi(wstr).c_str(), 1);
- if (Game->_textRTL) _selEnd = _selStart;
+ if (_gameRef->_textRTL) _selEnd = _selStart;
else _selStart = _selEnd;
return true;
diff --git a/engines/wintermute/UI/UIEntity.cpp b/engines/wintermute/UI/UIEntity.cpp index f30aca122c..7df6493fd5 100644 --- a/engines/wintermute/UI/UIEntity.cpp +++ b/engines/wintermute/UI/UIEntity.cpp @@ -49,16 +49,16 @@ CUIEntity::CUIEntity(CBGame *inGame): CUIObject(inGame) { //////////////////////////////////////////////////////////////////////////
CUIEntity::~CUIEntity() {
- if (_entity) Game->unregisterObject(_entity);
+ if (_entity) _gameRef->unregisterObject(_entity);
_entity = NULL;
}
//////////////////////////////////////////////////////////////////////////
ERRORCODE CUIEntity::loadFile(const char *filename) {
- byte *buffer = Game->_fileManager->readWholeFile(filename);
+ byte *buffer = _gameRef->_fileManager->readWholeFile(filename);
if (buffer == NULL) {
- Game->LOG(0, "CUIEntity::LoadFile failed for file '%s'", filename);
+ _gameRef->LOG(0, "CUIEntity::LoadFile failed for file '%s'", filename);
return STATUS_FAILED;
}
@@ -67,7 +67,7 @@ ERRORCODE CUIEntity::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 ENTITY container file '%s'", filename);
+ if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing ENTITY container file '%s'", filename);
delete [] buffer;
@@ -105,11 +105,11 @@ ERRORCODE CUIEntity::loadBuffer(byte *buffer, bool complete) { byte *params;
int cmd = 2;
- CBParser parser(Game);
+ CBParser parser(_gameRef);
if (complete) {
if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ENTITY_CONTAINER) {
- Game->LOG(0, "'ENTITY_CONTAINER' keyword expected.");
+ _gameRef->LOG(0, "'ENTITY_CONTAINER' keyword expected.");
return STATUS_FAILED;
}
buffer = params;
@@ -155,17 +155,17 @@ ERRORCODE CUIEntity::loadBuffer(byte *buffer, bool complete) { }
}
if (cmd == PARSERR_TOKENNOTFOUND) {
- Game->LOG(0, "Syntax error in ENTITY_CONTAINER definition");
+ _gameRef->LOG(0, "Syntax error in ENTITY_CONTAINER definition");
return STATUS_FAILED;
}
if (cmd == PARSERR_GENERIC) {
- Game->LOG(0, "Error loading ENTITY_CONTAINER definition");
+ _gameRef->LOG(0, "Error loading ENTITY_CONTAINER definition");
return STATUS_FAILED;
}
correctSize();
- if (Game->_editorMode) {
+ if (_gameRef->_editorMode) {
_width = 50;
_height = 50;
}
@@ -209,8 +209,8 @@ ERRORCODE CUIEntity::saveAsText(CBDynBuffer *buffer, int indent) { //////////////////////////////////////////////////////////////////////////
ERRORCODE CUIEntity::setEntity(const char *filename) {
- if (_entity) Game->unregisterObject(_entity);
- _entity = new CAdEntity(Game);
+ if (_entity) _gameRef->unregisterObject(_entity);
+ _entity = new CAdEntity(_gameRef);
if (!_entity || DID_FAIL(_entity->loadFile(filename))) {
delete _entity;
_entity = NULL;
@@ -219,7 +219,7 @@ ERRORCODE CUIEntity::setEntity(const char *filename) { _entity->_nonIntMouseEvents = true;
_entity->_sceneIndependent = true;
_entity->makeFreezable(false);
- Game->registerObject(_entity);
+ _gameRef->registerObject(_entity);
}
return STATUS_OK;
}
diff --git a/engines/wintermute/UI/UIObject.cpp b/engines/wintermute/UI/UIObject.cpp index 6c33bd9509..e7e6fa3b7a 100644 --- a/engines/wintermute/UI/UIObject.cpp +++ b/engines/wintermute/UI/UIObject.cpp @@ -71,10 +71,10 @@ CUIObject::CUIObject(CBGame *inGame): CBObject(inGame) { //////////////////////////////////////////////////////////////////////////
CUIObject::~CUIObject() {
- if (!Game->_loadInProgress) CSysClassRegistry::getInstance()->enumInstances(CBGame::invalidateValues, "CScValue", (void *)this);
+ if (!_gameRef->_loadInProgress) CSysClassRegistry::getInstance()->enumInstances(CBGame::invalidateValues, "CScValue", (void *)this);
if (_back) delete _back;
- if (_font && !_sharedFonts) Game->_fontStorage->removeFont(_font);
+ if (_font && !_sharedFonts) _gameRef->_fontStorage->removeFont(_font);
if (_image && !_sharedImages) delete _image;
@@ -145,12 +145,12 @@ ERRORCODE CUIObject::scCallMethod(CScScript *script, CScStack *stack, CScStack * stack->correctParams(1);
CScValue *Val = stack->pop();
- if (_font) Game->_fontStorage->removeFont(_font);
+ if (_font) _gameRef->_fontStorage->removeFont(_font);
if (Val->isNULL()) {
_font = NULL;
stack->pushBool(true);
} else {
- _font = Game->_fontStorage->addFont(Val->getString());
+ _font = _gameRef->_fontStorage->addFont(Val->getString());
stack->pushBool(_font != NULL);
}
return STATUS_OK;
@@ -172,7 +172,7 @@ ERRORCODE CUIObject::scCallMethod(CScScript *script, CScStack *stack, CScStack * return STATUS_OK;
}
- _image = new CBSprite(Game);
+ _image = new CBSprite(_gameRef);
if (!_image || DID_FAIL(_image->loadFile(val->getString()))) {
delete _image;
_image = NULL;
@@ -487,10 +487,10 @@ const char *CUIObject::scToString() { //////////////////////////////////////////////////////////////////////////
bool CUIObject::isFocused() {
- if (!Game->_focusedWindow) return false;
- if (Game->_focusedWindow == this) return true;
+ if (!_gameRef->_focusedWindow) return false;
+ if (_gameRef->_focusedWindow == this) return true;
- CUIObject *obj = Game->_focusedWindow;
+ CUIObject *obj = _gameRef->_focusedWindow;
while (obj) {
if (obj == this) return true;
else obj = obj->_focusedWidget;
@@ -526,7 +526,7 @@ ERRORCODE CUIObject::focus() { if (obj->_parent) {
if (!obj->_disable && obj->_canFocus) obj->_parent->_focusedWidget = obj;
} else {
- if (obj->_type == UI_WINDOW) Game->focusWindow((CUIWindow *)obj);
+ if (obj->_type == UI_WINDOW) _gameRef->focusWindow((CUIWindow *)obj);
}
obj = obj->_parent;
diff --git a/engines/wintermute/UI/UIText.cpp b/engines/wintermute/UI/UIText.cpp index ba8191c204..e219adb262 100644 --- a/engines/wintermute/UI/UIText.cpp +++ b/engines/wintermute/UI/UIText.cpp @@ -67,7 +67,7 @@ ERRORCODE CUIText::display(int offsetX, int offsetY) { CBFont *font = _font;
- if (!font) font = Game->_systemFont;
+ if (!font) font = _gameRef->_systemFont;
if (_back) _back->display(offsetX + _posX, offsetY + _posY, _width, _height);
if (_image) _image->draw(offsetX + _posX, offsetY + _posY, NULL);
@@ -87,7 +87,7 @@ ERRORCODE CUIText::display(int offsetX, int offsetY) { font->drawText((byte *)_text, offsetX + _posX, offsetY + _posY + textOffset, _width, _textAlign, _height);
}
- //Game->_renderer->_rectList.add(new CBActiveRect(Game, this, NULL, OffsetX + _posX, OffsetY + _posY, _width, _height, 100, 100, false));
+ //_gameRef->_renderer->_rectList.add(new CBActiveRect(_gameRef, this, NULL, OffsetX + _posX, OffsetY + _posY, _width, _height, 100, 100, false));
return STATUS_OK;
}
@@ -96,9 +96,9 @@ ERRORCODE CUIText::display(int offsetX, int offsetY) { //////////////////////////////////////////////////////////////////////////
ERRORCODE CUIText::loadFile(const char *filename) {
- byte *buffer = Game->_fileManager->readWholeFile(filename);
+ byte *buffer = _gameRef->_fileManager->readWholeFile(filename);
if (buffer == NULL) {
- Game->LOG(0, "CUIText::LoadFile failed for file '%s'", filename);
+ _gameRef->LOG(0, "CUIText::LoadFile failed for file '%s'", filename);
return STATUS_FAILED;
}
@@ -107,7 +107,7 @@ ERRORCODE CUIText::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 STATIC file '%s'", filename);
+ if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing STATIC file '%s'", filename);
delete [] buffer;
@@ -164,11 +164,11 @@ ERRORCODE CUIText::loadBuffer(byte *buffer, bool complete) { byte *params;
int cmd = 2;
- CBParser parser(Game);
+ CBParser parser(_gameRef);
if (complete) {
if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_STATIC) {
- Game->LOG(0, "'STATIC' keyword expected.");
+ _gameRef->LOG(0, "'STATIC' keyword expected.");
return STATUS_FAILED;
}
buffer = params;
@@ -190,7 +190,7 @@ ERRORCODE CUIText::loadBuffer(byte *buffer, bool complete) { case TOKEN_BACK:
delete _back;
- _back = new CUITiledImage(Game);
+ _back = new CUITiledImage(_gameRef);
if (!_back || DID_FAIL(_back->loadFile((char *)params))) {
delete _back;
_back = NULL;
@@ -200,7 +200,7 @@ ERRORCODE CUIText::loadBuffer(byte *buffer, bool complete) { case TOKEN_IMAGE:
delete _image;
- _image = new CBSprite(Game);
+ _image = new CBSprite(_gameRef);
if (!_image || DID_FAIL(_image->loadFile((char *)params))) {
delete _image;
_image = NULL;
@@ -209,14 +209,14 @@ ERRORCODE CUIText::loadBuffer(byte *buffer, bool complete) { break;
case TOKEN_FONT:
- if (_font) Game->_fontStorage->removeFont(_font);
- _font = Game->_fontStorage->addFont((char *)params);
+ if (_font) _gameRef->_fontStorage->removeFont(_font);
+ _font = _gameRef->_fontStorage->addFont((char *)params);
if (!_font) cmd = PARSERR_GENERIC;
break;
case TOKEN_TEXT:
setText((char *)params);
- Game->_stringTable->expand(&_text);
+ _gameRef->_stringTable->expand(&_text);
break;
case TOKEN_TEXT_ALIGN:
@@ -249,7 +249,7 @@ ERRORCODE CUIText::loadBuffer(byte *buffer, bool complete) { 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;
@@ -279,11 +279,11 @@ ERRORCODE CUIText::loadBuffer(byte *buffer, bool complete) { }
}
if (cmd == PARSERR_TOKENNOTFOUND) {
- Game->LOG(0, "Syntax error in STATIC definition");
+ _gameRef->LOG(0, "Syntax error in STATIC definition");
return STATUS_FAILED;
}
if (cmd == PARSERR_GENERIC) {
- Game->LOG(0, "Error loading STATIC definition");
+ _gameRef->LOG(0, "Error loading STATIC definition");
return STATUS_FAILED;
}
diff --git a/engines/wintermute/UI/UITiledImage.cpp b/engines/wintermute/UI/UITiledImage.cpp index 05f6a0bed5..fc8f43ee2f 100644 --- a/engines/wintermute/UI/UITiledImage.cpp +++ b/engines/wintermute/UI/UITiledImage.cpp @@ -75,7 +75,7 @@ ERRORCODE CUITiledImage::display(int x, int y, int width, int height) { int col, row;
- Game->_renderer->startSpriteBatch();
+ _gameRef->_renderer->startSpriteBatch();
// top left/right
_image->_surface->displayTrans(x, y, _upLeft);
@@ -112,7 +112,7 @@ ERRORCODE CUITiledImage::display(int x, int y, int width, int height) { yyy += tileWidth;
}
- Game->_renderer->endSpriteBatch();
+ _gameRef->_renderer->endSpriteBatch();
return STATUS_OK;
}
@@ -120,9 +120,9 @@ ERRORCODE CUITiledImage::display(int x, int y, int width, int height) { //////////////////////////////////////////////////////////////////////////
ERRORCODE CUITiledImage::loadFile(const char *filename) {
- byte *buffer = Game->_fileManager->readWholeFile(filename);
+ byte *buffer = _gameRef->_fileManager->readWholeFile(filename);
if (buffer == NULL) {
- Game->LOG(0, "CUITiledImage::LoadFile failed for file '%s'", filename);
+ _gameRef->LOG(0, "CUITiledImage::LoadFile failed for file '%s'", filename);
return STATUS_FAILED;
}
@@ -131,7 +131,7 @@ ERRORCODE CUITiledImage::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 TILED_IMAGE file '%s'", filename);
+ if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing TILED_IMAGE file '%s'", filename);
delete [] buffer;
@@ -179,14 +179,14 @@ ERRORCODE CUITiledImage::loadBuffer(byte *buffer, bool complete) { byte *params;
int cmd;
- CBParser parser(Game);
+ CBParser parser(_gameRef);
bool hTiles = false, vTiles = false;
int h1 = 0, h2 = 0, h3 = 0;
int v1 = 0, v2 = 0, v3 = 0;
if (complete) {
if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_TILED_IMAGE) {
- Game->LOG(0, "'TILED_IMAGE' keyword expected.");
+ _gameRef->LOG(0, "'TILED_IMAGE' keyword expected.");
return STATUS_FAILED;
}
buffer = params;
@@ -200,7 +200,7 @@ ERRORCODE CUITiledImage::loadBuffer(byte *buffer, bool complete) { case TOKEN_IMAGE:
delete _image;
- _image = new CBSubFrame(Game);
+ _image = new CBSubFrame(_gameRef);
if (!_image || DID_FAIL(_image->setSurface((char *)params))) {
delete _image;
_image = NULL;
@@ -260,11 +260,11 @@ ERRORCODE CUITiledImage::loadBuffer(byte *buffer, bool complete) { }
}
if (cmd == PARSERR_TOKENNOTFOUND) {
- Game->LOG(0, "Syntax error in TILED_IMAGE definition");
+ _gameRef->LOG(0, "Syntax error in TILED_IMAGE definition");
return STATUS_FAILED;
}
if (cmd == PARSERR_GENERIC) {
- Game->LOG(0, "Error loading TILED_IMAGE definition");
+ _gameRef->LOG(0, "Error loading TILED_IMAGE definition");
return STATUS_FAILED;
}
diff --git a/engines/wintermute/UI/UIWindow.cpp b/engines/wintermute/UI/UIWindow.cpp index f16e3afba1..9126a1ca7b 100644 --- a/engines/wintermute/UI/UIWindow.cpp +++ b/engines/wintermute/UI/UIWindow.cpp @@ -104,7 +104,7 @@ void CUIWindow::cleanup() { _viewport = NULL;
delete _backInactive;
- if (!_sharedFonts && _fontInactive) Game->_fontStorage->removeFont(_fontInactive);
+ if (!_sharedFonts && _fontInactive) _gameRef->_fontStorage->removeFont(_fontInactive);
if (!_sharedImages && _imageInactive) delete _imageInactive;
for (int i = 0; i < _widgets.getSize(); i++) delete _widgets[i];
@@ -116,25 +116,25 @@ void CUIWindow::cleanup() { ERRORCODE CUIWindow::display(int offsetX, int offsetY) {
// go exclusive
if (_mode == WINDOW_EXCLUSIVE || _mode == WINDOW_SYSTEM_EXCLUSIVE) {
- if (!_shieldWindow) _shieldWindow = new CUIWindow(Game);
+ if (!_shieldWindow) _shieldWindow = new CUIWindow(_gameRef);
if (_shieldWindow) {
_shieldWindow->_posX = _shieldWindow->_posY = 0;
- _shieldWindow->_width = Game->_renderer->_width;
- _shieldWindow->_height = Game->_renderer->_height;
+ _shieldWindow->_width = _gameRef->_renderer->_width;
+ _shieldWindow->_height = _gameRef->_renderer->_height;
_shieldWindow->display();
}
} else if (_isMenu) {
if (!_shieldButton) {
- _shieldButton = new CUIButton(Game);
+ _shieldButton = new CUIButton(_gameRef);
_shieldButton->setName("close");
_shieldButton->setListener(this, _shieldButton, 0);
_shieldButton->_parent = this;
}
if (_shieldButton) {
_shieldButton->_posX = _shieldButton->_posY = 0;
- _shieldButton->_width = Game->_renderer->_width;
- _shieldButton->_height = Game->_renderer->_height;
+ _shieldButton->_width = _gameRef->_renderer->_width;
+ _shieldButton->_height = _gameRef->_renderer->_height;
_shieldButton->display();
}
@@ -143,14 +143,14 @@ ERRORCODE CUIWindow::display(int offsetX, int offsetY) { if (!_visible)
return STATUS_OK;
- if (_fadeBackground) Game->_renderer->fadeToColor(_fadeColor);
+ if (_fadeBackground) _gameRef->_renderer->fadeToColor(_fadeColor);
if (_dragging) {
- _posX += (Game->_mousePos.x - _dragFrom.x);
- _posY += (Game->_mousePos.y - _dragFrom.y);
+ _posX += (_gameRef->_mousePos.x - _dragFrom.x);
+ _posY += (_gameRef->_mousePos.y - _dragFrom.y);
- _dragFrom.x = Game->_mousePos.x;
- _dragFrom.y = Game->_mousePos.y;
+ _dragFrom.x = _gameRef->_mousePos.x;
+ _dragFrom.y = _gameRef->_mousePos.y;
}
if (!_focusedWidget || (!_focusedWidget->_canFocus || _focusedWidget->_disable || !_focusedWidget->_visible)) {
@@ -159,10 +159,10 @@ ERRORCODE CUIWindow::display(int offsetX, int offsetY) { bool popViewport = false;
if (_clipContents) {
- if (!_viewport) _viewport = new CBViewport(Game);
+ if (!_viewport) _viewport = new CBViewport(_gameRef);
if (_viewport) {
_viewport->setRect(_posX + offsetX, _posY + offsetY, _posX + _width + offsetX, _posY + _height + offsetY);
- Game->pushViewport(_viewport);
+ _gameRef->pushViewport(_viewport);
popViewport = true;
}
}
@@ -179,7 +179,7 @@ ERRORCODE CUIWindow::display(int offsetX, int offsetY) { }
if (_alphaColor != 0)
- Game->_renderer->_forceAlphaColor = _alphaColor;
+ _gameRef->_renderer->_forceAlphaColor = _alphaColor;
if (back)
back->display(_posX + offsetX, _posY + offsetY, _width, _height);
if (image)
@@ -190,17 +190,17 @@ ERRORCODE CUIWindow::display(int offsetX, int offsetY) { }
if (!_transparent && !image)
- Game->_renderer->_rectList.add(new CBActiveRect(Game, this, NULL, _posX + offsetX, _posY + offsetY, _width, _height, 100, 100, false));
+ _gameRef->_renderer->_rectList.add(new CBActiveRect(_gameRef, this, NULL, _posX + offsetX, _posY + offsetY, _width, _height, 100, 100, false));
for (int i = 0; i < _widgets.getSize(); i++) {
_widgets[i]->display(_posX + offsetX, _posY + offsetY);
}
if (_alphaColor != 0)
- Game->_renderer->_forceAlphaColor = 0;
+ _gameRef->_renderer->_forceAlphaColor = 0;
if (popViewport)
- Game->popViewport();
+ _gameRef->popViewport();
return STATUS_OK;
}
@@ -208,9 +208,9 @@ ERRORCODE CUIWindow::display(int offsetX, int offsetY) { //////////////////////////////////////////////////////////////////////////
ERRORCODE CUIWindow::loadFile(const char *filename) {
- byte *buffer = Game->_fileManager->readWholeFile(filename);
+ byte *buffer = _gameRef->_fileManager->readWholeFile(filename);
if (buffer == NULL) {
- Game->LOG(0, "CUIWindow::LoadFile failed for file '%s'", filename);
+ _gameRef->LOG(0, "CUIWindow::LoadFile failed for file '%s'", filename);
return STATUS_FAILED;
}
@@ -219,7 +219,7 @@ ERRORCODE CUIWindow::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 WINDOW file '%s'", filename);
+ if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing WINDOW file '%s'", filename);
delete [] buffer;
@@ -308,14 +308,14 @@ ERRORCODE CUIWindow::loadBuffer(byte *buffer, bool complete) { byte *params;
int cmd = 2;
- CBParser parser(Game);
+ CBParser parser(_gameRef);
int fadeR = 0, fadeG = 0, fadeB = 0, fadeA = 0;
int ar = 0, ag = 0, ab = 0, alpha = 0;
if (complete) {
if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_WINDOW) {
- Game->LOG(0, "'WINDOW' keyword expected.");
+ _gameRef->LOG(0, "'WINDOW' keyword expected.");
return STATUS_FAILED;
}
buffer = params;
@@ -337,7 +337,7 @@ ERRORCODE CUIWindow::loadBuffer(byte *buffer, bool complete) { case TOKEN_BACK:
delete _back;
- _back = new CUITiledImage(Game);
+ _back = new CUITiledImage(_gameRef);
if (!_back || DID_FAIL(_back->loadFile((char *)params))) {
delete _back;
_back = NULL;
@@ -347,7 +347,7 @@ ERRORCODE CUIWindow::loadBuffer(byte *buffer, bool complete) { case TOKEN_BACK_INACTIVE:
delete _backInactive;
- _backInactive = new CUITiledImage(Game);
+ _backInactive = new CUITiledImage(_gameRef);
if (!_backInactive || DID_FAIL(_backInactive->loadFile((char *)params))) {
delete _backInactive;
_backInactive = NULL;
@@ -357,7 +357,7 @@ ERRORCODE CUIWindow::loadBuffer(byte *buffer, bool complete) { case TOKEN_IMAGE:
delete _image;
- _image = new CBSprite(Game);
+ _image = new CBSprite(_gameRef);
if (!_image || DID_FAIL(_image->loadFile((char *)params))) {
delete _image;
_image = NULL;
@@ -367,7 +367,7 @@ ERRORCODE CUIWindow::loadBuffer(byte *buffer, bool complete) { case TOKEN_IMAGE_INACTIVE:
delete _imageInactive,
- _imageInactive = new CBSprite(Game);
+ _imageInactive = new CBSprite(_gameRef);
if (!_imageInactive || DID_FAIL(_imageInactive->loadFile((char *)params))) {
delete _imageInactive;
_imageInactive = NULL;
@@ -376,20 +376,20 @@ ERRORCODE CUIWindow::loadBuffer(byte *buffer, bool complete) { break;
case TOKEN_FONT:
- if (_font) Game->_fontStorage->removeFont(_font);
- _font = Game->_fontStorage->addFont((char *)params);
+ if (_font) _gameRef->_fontStorage->removeFont(_font);
+ _font = _gameRef->_fontStorage->addFont((char *)params);
if (!_font) cmd = PARSERR_GENERIC;
break;
case TOKEN_FONT_INACTIVE:
- if (_fontInactive) Game->_fontStorage->removeFont(_fontInactive);
- _fontInactive = Game->_fontStorage->addFont((char *)params);
+ if (_fontInactive) _gameRef->_fontStorage->removeFont(_fontInactive);
+ _fontInactive = _gameRef->_fontStorage->addFont((char *)params);
if (!_fontInactive) cmd = PARSERR_GENERIC;
break;
case TOKEN_TITLE:
setText((char *)params);
- Game->_stringTable->expand(&_text);
+ _gameRef->_stringTable->expand(&_text);
break;
case TOKEN_TITLE_ALIGN:
@@ -424,7 +424,7 @@ ERRORCODE CUIWindow::loadBuffer(byte *buffer, bool complete) { 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;
@@ -433,7 +433,7 @@ ERRORCODE CUIWindow::loadBuffer(byte *buffer, bool complete) { break;
case TOKEN_BUTTON: {
- CUIButton *btn = new CUIButton(Game);
+ CUIButton *btn = new CUIButton(_gameRef);
if (!btn || DID_FAIL(btn->loadBuffer(params, false))) {
delete btn;
btn = NULL;
@@ -446,7 +446,7 @@ ERRORCODE CUIWindow::loadBuffer(byte *buffer, bool complete) { break;
case TOKEN_STATIC: {
- CUIText *text = new CUIText(Game);
+ CUIText *text = new CUIText(_gameRef);
if (!text || DID_FAIL(text->loadBuffer(params, false))) {
delete text;
text = NULL;
@@ -459,7 +459,7 @@ ERRORCODE CUIWindow::loadBuffer(byte *buffer, bool complete) { break;
case TOKEN_EDIT: {
- CUIEdit *edit = new CUIEdit(Game);
+ CUIEdit *edit = new CUIEdit(_gameRef);
if (!edit || DID_FAIL(edit->loadBuffer(params, false))) {
delete edit;
edit = NULL;
@@ -472,7 +472,7 @@ ERRORCODE CUIWindow::loadBuffer(byte *buffer, bool complete) { break;
case TOKEN_WINDOW: {
- CUIWindow *win = new CUIWindow(Game);
+ CUIWindow *win = new CUIWindow(_gameRef);
if (!win || DID_FAIL(win->loadBuffer(params, false))) {
delete win;
win = NULL;
@@ -545,17 +545,17 @@ ERRORCODE CUIWindow::loadBuffer(byte *buffer, bool complete) { default:
- if (DID_FAIL(Game->windowLoadHook(this, (char **)&buffer, (char **)params))) {
+ if (DID_FAIL(_gameRef->windowLoadHook(this, (char **)&buffer, (char **)params))) {
cmd = PARSERR_GENERIC;
}
}
}
if (cmd == PARSERR_TOKENNOTFOUND) {
- Game->LOG(0, "Syntax error in WINDOW definition");
+ _gameRef->LOG(0, "Syntax error in WINDOW definition");
return STATUS_FAILED;
}
if (cmd == PARSERR_GENERIC) {
- Game->LOG(0, "Error loading WINDOW definition");
+ _gameRef->LOG(0, "Error loading WINDOW definition");
return STATUS_FAILED;
}
@@ -728,8 +728,8 @@ ERRORCODE CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack * else if (strcmp(name, "SetInactiveFont") == 0) {
stack->correctParams(1);
- if (_fontInactive) Game->_fontStorage->removeFont(_fontInactive);
- _fontInactive = Game->_fontStorage->addFont(stack->pop()->getString());
+ if (_fontInactive) _gameRef->_fontStorage->removeFont(_fontInactive);
+ _fontInactive = _gameRef->_fontStorage->addFont(stack->pop()->getString());
stack->pushBool(_fontInactive != NULL);
return STATUS_OK;
@@ -742,7 +742,7 @@ ERRORCODE CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack * stack->correctParams(1);
delete _imageInactive;
- _imageInactive = new CBSprite(Game);
+ _imageInactive = new CBSprite(_gameRef);
const char *filename = stack->pop()->getString();
if (!_imageInactive || DID_FAIL(_imageInactive->loadFile(filename))) {
delete _imageInactive;
@@ -812,8 +812,8 @@ ERRORCODE CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack * //////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "Center") == 0) {
stack->correctParams(0);
- _posX = (Game->_renderer->_width - _width) / 2;
- _posY = (Game->_renderer->_height - _height) / 2;
+ _posX = (_gameRef->_renderer->_width - _width) / 2;
+ _posY = (_gameRef->_renderer->_height - _height) / 2;
stack->pushNULL();
return STATUS_OK;
}
@@ -840,7 +840,7 @@ ERRORCODE CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack * stack->correctParams(1);
CScValue *val = stack->pop();
- CUIButton *btn = new CUIButton(Game);
+ CUIButton *btn = new CUIButton(_gameRef);
if (!val->isNULL()) btn->setName(val->getString());
stack->pushNative(btn, true);
@@ -857,7 +857,7 @@ ERRORCODE CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack * stack->correctParams(1);
CScValue *val = stack->pop();
- CUIText *sta = new CUIText(Game);
+ CUIText *sta = new CUIText(_gameRef);
if (!val->isNULL()) sta->setName(val->getString());
stack->pushNative(sta, true);
@@ -874,7 +874,7 @@ ERRORCODE CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack * stack->correctParams(1);
CScValue *val = stack->pop();
- CUIEdit *edi = new CUIEdit(Game);
+ CUIEdit *edi = new CUIEdit(_gameRef);
if (!val->isNULL()) edi->setName(val->getString());
stack->pushNative(edi, true);
@@ -891,7 +891,7 @@ ERRORCODE CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack * stack->correctParams(1);
CScValue *val = stack->pop();
- CUIWindow *win = new CUIWindow(Game);
+ CUIWindow *win = new CUIWindow(_gameRef);
if (!val->isNULL()) win->setName(val->getString());
stack->pushNative(win, true);
@@ -918,7 +918,7 @@ ERRORCODE CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack * }
stack->pushNULL();
return STATUS_OK;
- } else if DID_SUCCEED(Game->windowScriptMethodHook(this, script, stack, name)) return STATUS_OK;
+ } else if DID_SUCCEED(_gameRef->windowScriptMethodHook(this, script, stack, name)) return STATUS_OK;
else return CUIObject::scCallMethod(script, stack, thisStack, name);
}
@@ -1140,9 +1140,9 @@ ERRORCODE CUIWindow::handleMouse(TMouseEvent event, TMouseButton button) { getTotalOffset(&offsetX, &offsetY);
CBPlatform::offsetRect(&dragRect, _posX + offsetX, _posY + offsetY);
- if (CBPlatform::ptInRect(&dragRect, Game->_mousePos)) {
- _dragFrom.x = Game->_mousePos.x;
- _dragFrom.y = Game->_mousePos.y;
+ if (CBPlatform::ptInRect(&dragRect, _gameRef->_mousePos)) {
+ _dragFrom.x = _gameRef->_mousePos.x;
+ _dragFrom.y = _gameRef->_mousePos.y;
_dragging = true;
}
}
@@ -1238,7 +1238,7 @@ ERRORCODE CUIWindow::goExclusive() { _mode = WINDOW_EXCLUSIVE;
_visible = true;
_disable = false;
- Game->focusWindow(this);
+ _gameRef->focusWindow(this);
return STATUS_OK;
} else return STATUS_FAILED;
}
@@ -1254,9 +1254,9 @@ ERRORCODE CUIWindow::goSystemExclusive() { _ready = false;
_visible = true;
_disable = false;
- Game->focusWindow(this);
+ _gameRef->focusWindow(this);
- Game->freeze(_pauseMusic);
+ _gameRef->freeze(_pauseMusic);
return STATUS_OK;
}
@@ -1264,7 +1264,7 @@ ERRORCODE CUIWindow::goSystemExclusive() { //////////////////////////////////////////////////////////////////////////
ERRORCODE CUIWindow::close() {
if (_mode == WINDOW_SYSTEM_EXCLUSIVE) {
- Game->unfreeze();
+ _gameRef->unfreeze();
}
_mode = WINDOW_NORMAL;
diff --git a/engines/wintermute/video/VidPlayer.cpp b/engines/wintermute/video/VidPlayer.cpp index eed2ddce86..a962608691 100644 --- a/engines/wintermute/video/VidPlayer.cpp +++ b/engines/wintermute/video/VidPlayer.cpp @@ -129,23 +129,23 @@ ERRORCODE CVidPlayer::initialize(const char *inFilename, const char *SubtitleFil cleanup(); char Filename[MAX_PATH_LENGTH]; - Game->_fileManager->GetFullPath(inFilename, filename); + _gameRef->_fileManager->GetFullPath(inFilename, filename); // open file if (AVIFileOpen(&_aviFile, Filename, OF_READ, NULL) != 0) { - Game->LOG(0, "Error opening AVI file '%s'", filename); + _gameRef->LOG(0, "Error opening AVI file '%s'", filename); return STATUS_FAILED; } // get video stream if (AVIFileGetStream(_aviFile, &_videoStream, streamtypeVIDEO, 0) != 0) { - Game->LOG(0, "Error finding video stream in AVI file '%s'", filename); + _gameRef->LOG(0, "Error finding video stream in AVI file '%s'", filename); return STATUS_FAILED; } _totalVideoTime = AVIStreamEndTime(_videoStream); // get audio stream - if (Game->m_SoundMgr->_soundAvailable && AVIFileGetStream(_aviFile, &_audioStream, streamtypeAUDIO, 0) == 0) + if (_gameRef->m_SoundMgr->_soundAvailable && AVIFileGetStream(_aviFile, &_audioStream, streamtypeAUDIO, 0) == 0) _soundAvailable = true; else _soundAvailable = false; @@ -155,7 +155,7 @@ ERRORCODE CVidPlayer::initialize(const char *inFilename, const char *SubtitleFil // get video format if (AVIStreamReadFormat(m_VideoStream, 0, NULL, &Size)) { - Game->LOG(0, "Error obtaining video stream format in AVI file '%s'", filename); + _gameRef->LOG(0, "Error obtaining video stream format in AVI file '%s'", filename); return STATUS_FAILED; } _videoFormat = (LPBITMAPINFO)new BYTE[Size]; @@ -170,13 +170,13 @@ ERRORCODE CVidPlayer::initialize(const char *inFilename, const char *SubtitleFil m_TargetFormat->bV4BitCount = 24; m_TargetFormat->bV4V4Compression = BI_RGB; - if (Game->m_UseD3D) - m_VidRenderer = new CVidRendererD3D(Game); + if (_gameRef->m_UseD3D) + m_VidRenderer = new CVidRendererD3D(_gameRef); else - m_VidRenderer = new CVidRendererDD(Game); + m_VidRenderer = new CVidRendererDD(_gameRef); if (!m_VidRenderer || DID_FAIL(m_VidRenderer->Initialize(m_VideoFormat, m_TargetFormat))) { - Game->LOG(0, "Error initializing video renderer for AVI file '%s'", filename); + _gameRef->LOG(0, "Error initializing video renderer for AVI file '%s'", filename); SAFE_DELETE(m_VidRenderer); return STATUS_FAILED; } @@ -186,15 +186,15 @@ ERRORCODE CVidPlayer::initialize(const char *inFilename, const char *SubtitleFil ERRORCODE res; if (_soundAvailable) { - _sound = new CBSoundAVI(Game); + _sound = new CBSoundAVI(_gameRef); if (DID_FAIL(res = _sound->InitializeBuffer(_audioStream))) { SAFE_DELETE(_sound); _soundAvailable = false; - Game->LOG(res, "Error initializing sound buffer for AVI file '%s'", filename); + _gameRef->LOG(res, "Error initializing sound buffer for AVI file '%s'", filename); } } - if (Game->_videoSubtitles) LoadSubtitles(inFilename, SubtitleFile); + if (_gameRef->_videoSubtitles) LoadSubtitles(inFilename, SubtitleFile); _filename = new char[strlen(filename) + 1]; if (_filename) strcpy(_filename, filename); @@ -284,9 +284,9 @@ ERRORCODE CVidPlayer::display() { // display subtitle if (m_ShowSubtitle) { - CBFont *font = Game->_videoFont ? Game->_videoFont : Game->_systemFont; - int Height = font->GetTextHeight((BYTE *)m_Subtitles[_currentSubtitle]->_text, Game->_renderer->_width); - font->drawText((byte *)_subtitles[m_CurrentSubtitle]->_text, 0, Game->_renderer->_height - Height - 5, Game->_renderer->_width, TAL_CENTER); + CBFont *font = _gameRef->_videoFont ? _gameRef->_videoFont : _gameRef->_systemFont; + int Height = font->GetTextHeight((BYTE *)m_Subtitles[_currentSubtitle]->_text, _gameRef->_renderer->_width); + font->drawText((byte *)_subtitles[m_CurrentSubtitle]->_text, 0, _gameRef->_renderer->_height - Height - 5, _gameRef->_renderer->_width, TAL_CENTER); } return res; @@ -310,18 +310,18 @@ ERRORCODE CVidPlayer::play(TVideoPlayback Type, int X, int Y, bool FreezeMusic) break; case VID_PLAY_STRETCH: { - float ZoomX = (float)((float)Game->_renderer->m_Width / (float)_videoFormat->bmiHeader.biWidth * 100); - float ZoomY = (float)((float)Game->_renderer->m_Height / (float)_videoFormat->bmiHeader.biHeight * 100); + float ZoomX = (float)((float)_gameRef->_renderer->m_Width / (float)_videoFormat->bmiHeader.biWidth * 100); + float ZoomY = (float)((float)_gameRef->_renderer->m_Height / (float)_videoFormat->bmiHeader.biHeight * 100); _playZoom = min(ZoomX, ZoomY); - _playPosX = (Game->_renderer->_width - _videoFormat->bmiHeader.biWidth * (_playZoom / 100)) / 2; - _playPosY = (Game->_renderer->_height - _videoFormat->bmiHeader.biHeight * (_playZoom / 100)) / 2; + _playPosX = (_gameRef->_renderer->_width - _videoFormat->bmiHeader.biWidth * (_playZoom / 100)) / 2; + _playPosY = (_gameRef->_renderer->_height - _videoFormat->bmiHeader.biHeight * (_playZoom / 100)) / 2; } break; case VID_PLAY_CENTER: _playZoom = 100.0f; - _playPosX = (Game->_renderer->_width - _videoFormat->bmiHeader.biWidth) / 2; - _playPosY = (Game->_renderer->_height - _videoFormat->bmiHeader.biHeight) / 2; + _playPosX = (_gameRef->_renderer->_width - _videoFormat->bmiHeader.biWidth) / 2; + _playPosY = (_gameRef->_renderer->_height - _videoFormat->bmiHeader.biHeight) / 2; break; } @@ -333,11 +333,11 @@ ERRORCODE CVidPlayer::play(TVideoPlayback Type, int X, int Y, bool FreezeMusic) if (!_videoPGF) { _videoPGF = AVIStreamGetFrameOpen(_videoStream, NULL); if (!_videoPGF) { - Game->LOG(0, "Error: Unsupported AVI format (file '%s')", m_Filename); + _gameRef->LOG(0, "Error: Unsupported AVI format (file '%s')", m_Filename); cleanup(); return STATUS_FAILED; } else { - Game->LOG(0, "Performance warning: non-optimal AVI format, using generic (i.e. slow) rendering routines (file '%s')", m_Filename); + _gameRef->LOG(0, "Performance warning: non-optimal AVI format, using generic (i.e. slow) rendering routines (file '%s')", m_Filename); _slowRendering = true; } } else _slowRendering = false; @@ -348,7 +348,7 @@ ERRORCODE CVidPlayer::play(TVideoPlayback Type, int X, int Y, bool FreezeMusic) _currentSubtitle = 0; - Game->Freeze(FreezeMusic); + _gameRef->Freeze(FreezeMusic); _playing = true; if (_sound) _sound->Play(); @@ -365,7 +365,7 @@ ERRORCODE CVidPlayer::stop() { cleanup(); - Game->Unfreeze(); + _gameRef->Unfreeze(); #endif return STATUS_OK; } @@ -395,7 +395,7 @@ ERRORCODE CVidPlayer::loadSubtitles(const char *filename, const char *SubtitleFi } DWORD Size; - BYTE *Buffer = Game->m_FileManager->readWholeFile(NewFile, &Size, false); + BYTE *Buffer = _gameRef->m_FileManager->readWholeFile(NewFile, &Size, false); if (Buffer == NULL) return STATUS_OK; // no subtitles @@ -455,7 +455,7 @@ ERRORCODE CVidPlayer::loadSubtitles(const char *filename, const char *SubtitleFi } Text[TextLength] = '\0'; - if (Start != -1 && TextLength > 0) _subtitles.add(new CVidSubtitle(Game, Text, Start, End)); + if (Start != -1 && TextLength > 0) _subtitles.add(new CVidSubtitle(_gameRef, Text, Start, End)); delete [] Text; diff --git a/engines/wintermute/video/VidTheoraPlayer.cpp b/engines/wintermute/video/VidTheoraPlayer.cpp index 0250aac5b2..6a622449ab 100644 --- a/engines/wintermute/video/VidTheoraPlayer.cpp +++ b/engines/wintermute/video/VidTheoraPlayer.cpp @@ -109,7 +109,7 @@ CVidTheoraPlayer::~CVidTheoraPlayer(void) { ////////////////////////////////////////////////////////////////////////// void CVidTheoraPlayer::cleanup() { if (_file) { - Game->_fileManager->closeFile(_file); + _gameRef->_fileManager->closeFile(_file); _file = NULL; } @@ -122,7 +122,7 @@ void CVidTheoraPlayer::cleanup() { _texture = NULL; #if 0 if (m_Sound) { - Game->m_SoundMgr->RemoveSound(m_Sound); + _gameRef->m_SoundMgr->RemoveSound(m_Sound); m_Sound = NULL; } @@ -137,7 +137,7 @@ ERRORCODE CVidTheoraPlayer::initialize(const Common::String &filename, const Com cleanup(); _filename = filename; - _file = Game->_fileManager->openFile(filename, true, false); + _file = _gameRef->_fileManager->openFile(filename, true, false); if (!_file) return STATUS_FAILED; //if (Filename != _filename) CBUtils::setString(&_filename, filename); @@ -155,7 +155,7 @@ ERRORCODE CVidTheoraPlayer::initialize(const Common::String &filename, const Com // Additional setup. _surface.create(_theoraDecoder->getWidth(), _theoraDecoder->getHeight(), _theoraDecoder->getPixelFormat()); - _texture = new CBSurfaceSDL(Game); + _texture = new CBSurfaceSDL(_gameRef); _texture->create(_theoraDecoder->getWidth(), _theoraDecoder->getHeight()); _state = THEORA_STATE_PLAYING; _playZoom = 100; @@ -164,7 +164,7 @@ ERRORCODE CVidTheoraPlayer::initialize(const Common::String &filename, const Com #if 0 cleanup(); - _file = Game->_fileManager->openFile(filename); + _file = _gameRef->_fileManager->openFile(filename); if (!_file) return STATUS_FAILED; if (Filename != _filename) CBUtils::setString(&_filename, filename); @@ -232,11 +232,11 @@ ERRORCODE CVidTheoraPlayer::initialize(const Common::String &filename, const Com // look for further theora headers while (m_TheoraStreams && (m_TheoraStreams < 3) && (Ret = ogg_stream_packetout(&m_TheoraStreamState, &TempOggPacket))) { if (Ret < 0) { - Game->LOG(0, "Error parsing Theora stream headers; corrupt stream?"); + _gameRef->LOG(0, "Error parsing Theora stream headers; corrupt stream?"); return STATUS_FAILED; } if (theora_decode_header(&m_TheoraInfo, &m_TheoraComment, &TempOggPacket)) { - Game->LOG(0, "Error parsing Theora stream headers; corrupt stream?"); + _gameRef->LOG(0, "Error parsing Theora stream headers; corrupt stream?"); return STATUS_FAILED; } m_TheoraStreams++; @@ -246,11 +246,11 @@ ERRORCODE CVidTheoraPlayer::initialize(const Common::String &filename, const Com /* look for more vorbis header packets */ while (m_VorbisStreams && (m_VorbisStreams < 3) && (Ret = ogg_stream_packetout(&m_VorbisStreamState, &TempOggPacket))) { if (Ret < 0) { - Game->LOG(0, "Error parsing Vorbis stream headers; corrupt stream?"); + _gameRef->LOG(0, "Error parsing Vorbis stream headers; corrupt stream?"); return STATUS_FAILED; } if (vorbis_synthesis_headerin(&m_VorbisInfo, &m_VorbisComment, &TempOggPacket)) { - Game->LOG(0, "Error parsing Vorbis stream headers; corrupt stream?"); + _gameRef->LOG(0, "Error parsing Vorbis stream headers; corrupt stream?"); return STATUS_FAILED; } m_VorbisStreams++; @@ -267,7 +267,7 @@ ERRORCODE CVidTheoraPlayer::initialize(const Common::String &filename, const Com } else { int Ret = BufferData(&m_OggSyncState); // someone needs more data if (Ret == 0) { - Game->LOG(0, "End of file while searching for codec headers"); + _gameRef->LOG(0, "End of file while searching for codec headers"); return STATUS_FAILED; } } @@ -297,13 +297,13 @@ ERRORCODE CVidTheoraPlayer::initialize(const Common::String &filename, const Com ERRORCODE Res = STATUS_OK; // create sound buffer - if (m_VorbisStreams && Game->m_SoundMgr->m_SoundAvailable) { - m_Sound = new CBSoundTheora(Game); - Game->m_SoundMgr->AddSound(m_Sound); + if (m_VorbisStreams && _gameRef->m_SoundMgr->m_SoundAvailable) { + m_Sound = new CBSoundTheora(_gameRef); + _gameRef->m_SoundMgr->AddSound(m_Sound); if (DID_FAIL(Res = m_Sound->InitializeBuffer(this))) { - Game->m_SoundMgr->RemoveSound(m_Sound); + _gameRef->m_SoundMgr->RemoveSound(m_Sound); m_Sound = NULL; - Game->LOG(Res, "Error initializing sound buffer for Theora file '%s'", filename); + _gameRef->LOG(Res, "Error initializing sound buffer for Theora file '%s'", filename); } else { SAFE_DELETE_ARRAY(m_AudioBuf); m_AudioBufSize = m_Sound->m_StreamBlockSize; @@ -313,10 +313,10 @@ ERRORCODE CVidTheoraPlayer::initialize(const Common::String &filename, const Com // create texture if (m_TheoraStreams && !m_Texture) { - if (Game->m_UseD3D) - m_Texture = new CBSurfaceD3D(Game); + if (_gameRef->m_UseD3D) + m_Texture = new CBSurfaceD3D(_gameRef); else - m_Texture = new CBSurfaceDD(Game); + m_Texture = new CBSurfaceDD(_gameRef); if (!m_Texture || DID_FAIL(Res = m_Texture->Create(m_TheoraInfo.width, m_TheoraInfo.height))) { SAFE_DELETE(m_Texture); @@ -324,8 +324,8 @@ ERRORCODE CVidTheoraPlayer::initialize(const Common::String &filename, const Com } - if (!m_Subtitler) m_Subtitler = new CVidSubtitler(Game); - if (m_Subtitler && Game->m_VideoSubtitles) m_Subtitler->LoadSubtitles(filename, SubtitleFile); + if (!m_Subtitler) m_Subtitler = new CVidSubtitler(_gameRef); + if (m_Subtitler && _gameRef->m_VideoSubtitles) m_Subtitler->LoadSubtitles(filename, SubtitleFile); return Res; #endif @@ -351,13 +351,13 @@ ERRORCODE CVidTheoraPlayer::play(TVideoPlayback type, int x, int y, bool freezeG if (forceZoom < 0.0f) forceZoom = 100.0f; if (volume < 0) - _volume = Game->_soundMgr->getVolumePercent(Audio::Mixer::kSFXSoundType); + _volume = _gameRef->_soundMgr->getVolumePercent(Audio::Mixer::kSFXSoundType); else _volume = volume; _freezeGame = freezeGame; if (!_playbackStarted && _freezeGame) - Game->freeze(freezeMusic); + _gameRef->freeze(freezeMusic); _playbackStarted = false; float width, height; @@ -376,8 +376,8 @@ ERRORCODE CVidTheoraPlayer::play(TVideoPlayback type, int x, int y, bool freezeG width = (float)_theoraDecoder->getWidth(); height = (float)_theoraDecoder->getHeight(); } else { - width = (float)Game->_renderer->_width; - height = (float)Game->_renderer->_height; + width = (float)_gameRef->_renderer->_width; + height = (float)_gameRef->_renderer->_height; } switch (type) { @@ -388,18 +388,18 @@ ERRORCODE CVidTheoraPlayer::play(TVideoPlayback type, int x, int y, bool freezeG break; case VID_PLAY_STRETCH: { - float ZoomX = (float)((float)Game->_renderer->_width / width * 100); - float ZoomY = (float)((float)Game->_renderer->_height / height * 100); + float ZoomX = (float)((float)_gameRef->_renderer->_width / width * 100); + float ZoomY = (float)((float)_gameRef->_renderer->_height / height * 100); _playZoom = MIN(ZoomX, ZoomY); - _posX = (int)((Game->_renderer->_width - width * (_playZoom / 100)) / 2); - _posY = (int)((Game->_renderer->_height - height * (_playZoom / 100)) / 2); + _posX = (int)((_gameRef->_renderer->_width - width * (_playZoom / 100)) / 2); + _posY = (int)((_gameRef->_renderer->_height - height * (_playZoom / 100)) / 2); } break; case VID_PLAY_CENTER: _playZoom = 100.0f; - _posX = (int)((Game->_renderer->_width - width) / 2); - _posY = (int)((Game->_renderer->_height - height) / 2); + _posX = (int)((_gameRef->_renderer->_width - width) / 2); + _posY = (int)((_gameRef->_renderer->_height - height) / 2); break; } return STATUS_OK; @@ -415,8 +415,8 @@ ERRORCODE CVidTheoraPlayer::play(TVideoPlayback type, int x, int y, bool freezeG Width = (float)m_TheoraInfo.width; Height = (float)m_TheoraInfo.height; } else { - Width = (float)Game->m_Renderer->m_Width; - Height = (float)Game->m_Renderer->m_Height; + Width = (float)_gameRef->m_Renderer->m_Width; + Height = (float)_gameRef->m_Renderer->m_Height; } switch (Type) { @@ -427,18 +427,18 @@ ERRORCODE CVidTheoraPlayer::play(TVideoPlayback type, int x, int y, bool freezeG break; case VID_PLAY_STRETCH: { - float ZoomX = (float)((float)Game->m_Renderer->m_Width / Width * 100); - float ZoomY = (float)((float)Game->m_Renderer->m_Height / Height * 100); + float ZoomX = (float)((float)_gameRef->m_Renderer->m_Width / Width * 100); + float ZoomY = (float)((float)_gameRef->m_Renderer->m_Height / Height * 100); m_PlayZoom = min(ZoomX, ZoomY); - m_PosX = (Game->m_Renderer->m_Width - Width * (m_PlayZoom / 100)) / 2; - m_PosY = (Game->m_Renderer->m_Height - Height * (m_PlayZoom / 100)) / 2; + m_PosX = (_gameRef->m_Renderer->m_Width - Width * (m_PlayZoom / 100)) / 2; + m_PosY = (_gameRef->m_Renderer->m_Height - Height * (m_PlayZoom / 100)) / 2; } break; case VID_PLAY_CENTER: m_PlayZoom = 100.0f; - m_PosX = (Game->m_Renderer->m_Width - Width) / 2; - m_PosY = (Game->m_Renderer->m_Height - Height) / 2; + m_PosX = (_gameRef->m_Renderer->m_Width - Width) / 2; + m_PosY = (_gameRef->m_Renderer->m_Height - Height) / 2; break; } @@ -455,25 +455,25 @@ ERRORCODE CVidTheoraPlayer::stop() { _theoraDecoder->close(); _state = THEORA_STATE_FINISHED; if (_freezeGame) { - Game->unfreeze(); + _gameRef->unfreeze(); } #if 0 if (m_Sound) m_Sound->Stop(); m_State = THEORA_STATE_FINISHED; - if (m_FreezeGame) Game->Unfreeze(); + if (m_FreezeGame) _gameRef->Unfreeze(); #endif return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// ERRORCODE CVidTheoraPlayer::update() { - _currentTime = _freezeGame ? Game->_liveTimer : Game->_timer; + _currentTime = _freezeGame ? _gameRef->_liveTimer : _gameRef->_timer; if (!isPlaying()) return STATUS_OK; if (_playbackStarted /*&& m_Sound && !m_Sound->IsPlaying()*/) return STATUS_OK; - if (_playbackStarted && !_freezeGame && Game->_state == GAME_FROZEN) return STATUS_OK; + if (_playbackStarted && !_freezeGame && _gameRef->_state == GAME_FROZEN) return STATUS_OK; if (_theoraDecoder) { if (_theoraDecoder->endOfVideo() && _looping) { @@ -483,7 +483,7 @@ ERRORCODE CVidTheoraPlayer::update() { warning("Finished movie"); _state = THEORA_STATE_FINISHED; _playbackStarted = false; - if (_freezeGame) Game->unfreeze(); + if (_freezeGame) _gameRef->unfreeze(); } if (_state == THEORA_STATE_PLAYING) { if (_theoraDecoder->getTimeToNextFrame() == 0) { @@ -500,7 +500,7 @@ ERRORCODE CVidTheoraPlayer::update() { // end playback if (!_looping) { _state = THEORA_STATE_FINISHED; - if (_freezeGame) Game->unfreeze(); + if (_freezeGame) _gameRef->unfreeze(); return STATUS_OK; } else { resetStream(); @@ -509,13 +509,13 @@ ERRORCODE CVidTheoraPlayer::update() { } #if 0 - m_CurrentTime = m_FreezeGame ? Game->m_LiveTimer : Game->m_Timer; + m_CurrentTime = m_FreezeGame ? _gameRef->m_LiveTimer : _gameRef->m_Timer; if (!IsPlaying()) return STATUS_OK; if (m_PlaybackStarted && m_Sound && !m_Sound->IsPlaying()) return STATUS_OK; - if (m_PlaybackStarted && !m_FreezeGame && Game->m_State == GAME_FROZEN) return STATUS_OK; + if (m_PlaybackStarted && !m_FreezeGame && _gameRef->m_State == GAME_FROZEN) return STATUS_OK; int Counter = 0; while (true) { @@ -530,7 +530,7 @@ ERRORCODE CVidTheoraPlayer::update() { if (!m_Looping) { m_State = THEORA_STATE_FINISHED; if (m_Sound) m_Sound->Stop(); - if (m_FreezeGame) Game->Unfreeze(); + if (m_FreezeGame) _gameRef->Unfreeze(); break; } else { ResetStream(); @@ -551,7 +551,7 @@ ERRORCODE CVidTheoraPlayer::update() { // are we at or past time for this video frame? if (m_PlaybackStarted && m_VideoFrameReady && (!m_FrameRendered || m_VideobufTime <= GetMovieTime())) { - //Game->LOG(0, "%f %f", m_VideobufTime, GetMovieTime()); + //_gameRef->LOG(0, "%f %f", m_VideobufTime, GetMovieTime()); if (m_Texture) WriteVideo(); m_VideoFrameReady = false; @@ -583,7 +583,7 @@ ERRORCODE CVidTheoraPlayer::update() { m_PlaybackStarted = true; } - if (m_Subtitler && Game->m_VideoSubtitles) m_Subtitler->update(GetMovieFrame()); + if (m_Subtitler && _gameRef->m_VideoSubtitles) m_Subtitler->update(GetMovieFrame()); #endif return STATUS_OK; } @@ -661,7 +661,7 @@ ERRORCODE CVidTheoraPlayer::display(uint32 alpha) { else res = _texture->displayTransZoom(_posX, _posY, rc, _playZoom, _playZoom, alpha); } else res = STATUS_FAILED; #if 0 - if (m_Subtitler && Game->m_VideoSubtitles) m_Subtitler->display(); + if (m_Subtitler && _gameRef->m_VideoSubtitles) m_Subtitler->display(); #endif return res; } @@ -671,7 +671,7 @@ ERRORCODE CVidTheoraPlayer::setAlphaImage(const Common::String &filename) { warning("CVidTheoraPlayer::SetAlphaImage(%s) - Not implemented", filename.c_str()); delete _alphaImage; - _alphaImage = new CBImage(Game); + _alphaImage = new CBImage(_gameRef); if (!_alphaImage || DID_FAIL(_alphaImage->loadFile(filename))) { delete _alphaImage; _alphaImage = NULL; @@ -685,7 +685,7 @@ ERRORCODE CVidTheoraPlayer::setAlphaImage(const Common::String &filename) { //TODO: Conversion. #if 0 SAFE_DELETE(m_AlphaImage); - m_AlphaImage = new CBImage(Game); + m_AlphaImage = new CBImage(_gameRef); if (!m_AlphaImage || DID_FAIL(m_AlphaImage->loadFile(filename))) { SAFE_DELETE(m_AlphaImage); SAFE_DELETE_ARRAY(m_AlphaFilename); @@ -812,7 +812,7 @@ ERRORCODE CVidTheoraPlayer::persist(CBPersistMgr *persistMgr) { SetDefaults(); } - persistMgr->transfer(TMEMBER(Game)); + persistMgr->transfer(TMEMBER(_gameRef)); persistMgr->transfer(TMEMBER(_savedPos)); persistMgr->transfer(TMEMBER(_savedState)); persistMgr->transfer(TMEMBER(_filename)); |