diff options
Diffstat (limited to 'engines/wintermute/ad')
50 files changed, 1054 insertions, 900 deletions
diff --git a/engines/wintermute/ad/ad_actor.cpp b/engines/wintermute/ad/ad_actor.cpp index d175855d1e..e4c18d6287 100644 --- a/engines/wintermute/ad/ad_actor.cpp +++ b/engines/wintermute/ad/ad_actor.cpp @@ -57,15 +57,15 @@ AdActor::AdActor(BaseGame *inGame) : AdTalkHolder(inGame) { _type = OBJECT_ACTOR; _dir = DI_LEFT; - _walkSprite = NULL; - _standSprite = NULL; - _turnLeftSprite = NULL; - _turnRightSprite = NULL; + _walkSprite = nullptr; + _standSprite = nullptr; + _turnLeftSprite = nullptr; + _turnRightSprite = nullptr; _targetPoint = new BasePoint; _afterWalkDir = DI_NONE; - _animSprite2 = NULL; + _animSprite2 = nullptr; setDefaultAnimNames(); } @@ -84,19 +84,19 @@ bool AdActor::setDefaultAnimNames() { AdActor::~AdActor() { delete _path; delete _targetPoint; - _path = NULL; - _targetPoint = NULL; + _path = nullptr; + _targetPoint = nullptr; delete _walkSprite; delete _standSprite; delete _turnLeftSprite; delete _turnRightSprite; - _walkSprite = NULL; - _standSprite = NULL; - _turnLeftSprite = NULL; - _turnRightSprite = NULL; + _walkSprite = nullptr; + _standSprite = nullptr; + _turnLeftSprite = nullptr; + _turnRightSprite = nullptr; - _animSprite2 = NULL; // ref only + _animSprite2 = nullptr; // ref only for (uint32 i = 0; i < _talkSprites.size(); i++) { delete _talkSprites[i]; @@ -110,7 +110,7 @@ AdActor::~AdActor() { for (uint32 i = 0; i < _anims.size(); i++) { delete _anims[i]; - _anims[i] = NULL; + _anims[i] = nullptr; } _anims.clear(); @@ -120,7 +120,7 @@ AdActor::~AdActor() { ////////////////////////////////////////////////////////////////////////// bool AdActor::loadFile(const char *filename) { byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); - if (buffer == NULL) { + if (buffer == nullptr) { _gameRef->LOG(0, "AdActor::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -232,7 +232,7 @@ bool AdActor::loadBuffer(byte *buffer, bool complete) { } AdGame *adGame = (AdGame *)_gameRef; - AdSpriteSet *spr = NULL; + AdSpriteSet *spr = nullptr; int ar = 0, ag = 0, ab = 0, alpha = 0; while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { @@ -287,7 +287,7 @@ bool AdActor::loadBuffer(byte *buffer, bool complete) { case TOKEN_WALK: delete _walkSprite; - _walkSprite = NULL; + _walkSprite = nullptr; spr = new AdSpriteSet(_gameRef, this); if (!spr || DID_FAIL(spr->loadBuffer(params, true, adGame->_texWalkLifeTime, CACHE_HALF))) { cmd = PARSERR_GENERIC; @@ -316,7 +316,7 @@ bool AdActor::loadBuffer(byte *buffer, bool complete) { case TOKEN_STAND: delete _standSprite; - _standSprite = NULL; + _standSprite = nullptr; spr = new AdSpriteSet(_gameRef, this); if (!spr || DID_FAIL(spr->loadBuffer(params, true, adGame->_texStandLifeTime))) { cmd = PARSERR_GENERIC; @@ -327,7 +327,7 @@ bool AdActor::loadBuffer(byte *buffer, bool complete) { case TOKEN_TURN_LEFT: delete _turnLeftSprite; - _turnLeftSprite = NULL; + _turnLeftSprite = nullptr; spr = new AdSpriteSet(_gameRef, this); if (!spr || DID_FAIL(spr->loadBuffer(params, true))) { cmd = PARSERR_GENERIC; @@ -338,7 +338,7 @@ bool AdActor::loadBuffer(byte *buffer, bool complete) { case TOKEN_TURN_RIGHT: delete _turnRightSprite; - _turnRightSprite = NULL; + _turnRightSprite = nullptr; spr = new AdSpriteSet(_gameRef, this); if (!spr || DID_FAIL(spr->loadBuffer(params, true))) { cmd = PARSERR_GENERIC; @@ -356,7 +356,7 @@ bool AdActor::loadBuffer(byte *buffer, bool complete) { _cursor = new BaseSprite(_gameRef); if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { delete _cursor; - _cursor = NULL; + _cursor = nullptr; cmd = PARSERR_GENERIC; } break; @@ -392,15 +392,15 @@ bool AdActor::loadBuffer(byte *buffer, bool complete) { case TOKEN_BLOCKED_REGION: { delete _blockRegion; delete _currentBlockRegion; - _blockRegion = NULL; - _currentBlockRegion = NULL; + _blockRegion = nullptr; + _currentBlockRegion = nullptr; BaseRegion *rgn = new BaseRegion(_gameRef); BaseRegion *crgn = new BaseRegion(_gameRef); if (!rgn || !crgn || DID_FAIL(rgn->loadBuffer(params, false))) { delete _blockRegion; delete _currentBlockRegion; - _blockRegion = NULL; - _currentBlockRegion = NULL; + _blockRegion = nullptr; + _currentBlockRegion = nullptr; cmd = PARSERR_GENERIC; } else { _blockRegion = rgn; @@ -413,15 +413,15 @@ bool AdActor::loadBuffer(byte *buffer, bool complete) { case TOKEN_WAYPOINTS: { delete _wptGroup; delete _currentWptGroup; - _wptGroup = NULL; - _currentWptGroup = NULL; + _wptGroup = nullptr; + _currentWptGroup = nullptr; AdWaypointGroup *wpt = new AdWaypointGroup(_gameRef); AdWaypointGroup *cwpt = new AdWaypointGroup(_gameRef); if (!wpt || !cwpt || DID_FAIL(wpt->loadBuffer(params, false))) { delete _wptGroup; delete _currentWptGroup; - _wptGroup = NULL; - _currentWptGroup = NULL; + _wptGroup = nullptr; + _currentWptGroup = nullptr; cmd = PARSERR_GENERIC; } else { _wptGroup = wpt; @@ -502,7 +502,7 @@ void AdActor::turnTo(TDirection dir) { _targetDir = dir; _state = delta < 0 ? STATE_TURNING_LEFT : STATE_TURNING_RIGHT; - _tempSprite2 = NULL; + _tempSprite2 = nullptr; } @@ -566,7 +566,7 @@ bool AdActor::display() { _currentSprite->display(_posX, _posY, - reg ? _registerAlias : NULL, + reg ? _registerAlias : nullptr, scaleX, scaleY, alpha, @@ -589,26 +589,26 @@ bool AdActor::display() { ////////////////////////////////////////////////////////////////////////// bool AdActor::update() { - _currentSprite = NULL; + _currentSprite = nullptr; if (_state == STATE_READY) { if (_animSprite) { delete _animSprite; - _animSprite = NULL; + _animSprite = nullptr; } if (_animSprite2) { - _animSprite2 = NULL; + _animSprite2 = nullptr; } } // finished playing animation? - if (_state == STATE_PLAYING_ANIM && _animSprite != NULL && _animSprite->isFinished()) { + if (_state == STATE_PLAYING_ANIM && _animSprite != nullptr && _animSprite->isFinished()) { _state = _nextState; _nextState = STATE_READY; _currentSprite = _animSprite; } - if (_state == STATE_PLAYING_ANIM_SET && _animSprite2 != NULL && _animSprite2->isFinished()) { + if (_state == STATE_PLAYING_ANIM_SET && _animSprite2 != nullptr && _animSprite2->isFinished()) { _state = _nextState; _nextState = STATE_READY; _currentSprite = _animSprite2; @@ -649,7 +649,7 @@ bool AdActor::update() { ////////////////////////////////////////////////////////////////////////// case STATE_TURNING_LEFT: - if (_tempSprite2 == NULL || _tempSprite2->isFinished()) { + if (_tempSprite2 == nullptr || _tempSprite2->isFinished()) { if (_dir > 0) { _dir = (TDirection)(_dir - 1); } else { @@ -657,7 +657,7 @@ bool AdActor::update() { } if (_dir == _targetDir) { - _tempSprite2 = NULL; + _tempSprite2 = nullptr; _state = _nextState; _nextState = STATE_READY; } else { @@ -686,7 +686,7 @@ bool AdActor::update() { ////////////////////////////////////////////////////////////////////////// case STATE_TURNING_RIGHT: - if (_tempSprite2 == NULL || _tempSprite2->isFinished()) { + if (_tempSprite2 == nullptr || _tempSprite2->isFinished()) { _dir = (TDirection)(_dir + 1); if ((int)_dir >= (int)NUM_DIRECTIONS) { @@ -694,7 +694,7 @@ bool AdActor::update() { } if (_dir == _targetDir) { - _tempSprite2 = NULL; + _tempSprite2 = nullptr; _state = _nextState; _nextState = STATE_READY; } else { @@ -752,11 +752,11 @@ bool AdActor::update() { _tempSprite2 = _sentence->_currentSprite; } - bool timeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->isPlaying() && !_sentence->_sound->isPaused())) || (!_sentence->_sound && _sentence->_duration <= _gameRef->_timer - _sentence->_startTime); - if (_tempSprite2 == NULL || _tempSprite2->isFinished() || (/*_tempSprite2->_looping &&*/ timeIsUp)) { + bool timeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->isPlaying() && !_sentence->_sound->isPaused())) || (!_sentence->_sound && _sentence->_duration <= _gameRef->getTimer()->getTime() - _sentence->_startTime); + if (_tempSprite2 == nullptr || _tempSprite2->isFinished() || (/*_tempSprite2->_looping &&*/ timeIsUp)) { if (timeIsUp) { _sentence->finish(); - _tempSprite2 = NULL; + _tempSprite2 = nullptr; _state = _nextState; _nextState = STATE_READY; } else { @@ -821,7 +821,7 @@ bool AdActor::update() { void AdActor::followPath() { // skip current position _path->getFirst(); - while (_path->getCurrent() != NULL) { + while (_path->getCurrent() != nullptr) { if (_path->getCurrent()->x != _posX || _path->getCurrent()->y != _posY) { break; } @@ -829,7 +829,7 @@ void AdActor::followPath() { } // are there points to follow? - if (_path->getCurrent() != NULL) { + if (_path->getCurrent() != nullptr) { _state = STATE_FOLLOWING_PATH; initLine(BasePoint(_posX, _posY), *_path->getCurrent()); } else { @@ -896,7 +896,7 @@ void AdActor::getNextStep() { if (_pFCount == 0) { - if (_path->getNext() == NULL) { + if (_path->getNext() == nullptr) { _posX = _targetPoint->x; _posY = _targetPoint->y; @@ -915,7 +915,7 @@ void AdActor::getNextStep() { ////////////////////////////////////////////////////////////////////////// -void AdActor::initLine(BasePoint startPt, BasePoint endPt) { +void AdActor::initLine(const BasePoint &startPt, const BasePoint &endPt) { _pFCount = MAX((abs(endPt.x - startPt.x)) , (abs(endPt.y - startPt.y))); _pFStepX = (double)(endPt.x - startPt.x) / _pFCount; @@ -963,16 +963,16 @@ bool AdActor::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, return STATUS_OK; } AdObject *obj = (AdObject *)val->getNative(); - if (!obj || obj->_type != OBJECT_ENTITY) { + if (!obj || obj->getType() != OBJECT_ENTITY) { script->runtimeError("actor.%s method accepts an entity refrence only", name); stack->pushNULL(); return STATUS_OK; } AdEntity *ent = (AdEntity *)obj; - if (ent->_walkToX == 0 && ent->_walkToY == 0) { + if (ent->getWalkToX() == 0 && ent->getWalkToY() == 0) { goTo(ent->_posX, ent->_posY); } else { - goTo(ent->_walkToX, ent->_walkToY, ent->_walkToDir); + goTo(ent->getWalkToX(), ent->getWalkToY(), ent->getWalkToDir()); } if (strcmp(name, "GoToObjectAsync") != 0) { script->waitForExclusive(this); @@ -1040,17 +1040,17 @@ bool AdActor::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, if (scumm_stricmp(_anims[i]->getName(), animName) == 0) { // invalidate sprites in use if (_anims[i]->containsSprite(_tempSprite2)) { - _tempSprite2 = NULL; + _tempSprite2 = nullptr; } if (_anims[i]->containsSprite(_currentSprite)) { - _currentSprite = NULL; + _currentSprite = nullptr; } if (_anims[i]->containsSprite(_animSprite2)) { - _animSprite2 = NULL; + _animSprite2 = nullptr; } delete _anims[i]; - _anims[i] = NULL; + _anims[i] = nullptr; _anims.remove_at(i); i--; found = true; @@ -1066,7 +1066,7 @@ bool AdActor::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, else if (strcmp(name, "HasAnim") == 0) { stack->correctParams(1); const char *animName = stack->pop()->getString(); - stack->pushBool(getAnimByName(animName) != NULL); + stack->pushBool(getAnimByName(animName) != nullptr); return STATUS_OK; } else { return AdTalkHolder::scCallMethod(script, stack, thisStack, name); @@ -1231,7 +1231,7 @@ BaseSprite *AdActor::getTalkStance(const char *stance) { if (DID_FAIL(res)) { _gameRef->LOG(res, "AdActor::GetTalkStance: error loading talk sprite (object:\"%s\" sprite:\"%s\")", getName(), _forcedTalkAnimName); delete _animSprite; - _animSprite = NULL; + _animSprite = nullptr; } else { return _animSprite; } @@ -1244,7 +1244,7 @@ BaseSprite *AdActor::getTalkStance(const char *stance) { } // new way - BaseSprite *ret = NULL; + BaseSprite *ret = nullptr; // do we have an animation with this name? AdSpriteSet *anim = getAnimByName(stance); @@ -1280,9 +1280,9 @@ BaseSprite *AdActor::getTalkStance(const char *stance) { ////////////////////////////////////////////////////////////////////////// BaseSprite *AdActor::getTalkStanceOld(const char *stance) { - BaseSprite *ret = NULL; + BaseSprite *ret = nullptr; - if (stance != NULL) { + if (stance != nullptr) { // search special stances for (uint32 i = 0; i < _talkSpritesEx.size(); i++) { if (scumm_stricmp(_talkSpritesEx[i]->getName(), stance) == 0) { @@ -1290,7 +1290,7 @@ BaseSprite *AdActor::getTalkStanceOld(const char *stance) { break; } } - if (ret == NULL) { + if (ret == nullptr) { // search generic stances for (uint32 i = 0; i < _talkSprites.size(); i++) { if (scumm_stricmp(_talkSprites[i]->getName(), stance) == 0) { @@ -1302,7 +1302,7 @@ BaseSprite *AdActor::getTalkStanceOld(const char *stance) { } // not a valid stance? get a random one - if (ret == NULL) { + if (ret == nullptr) { if (_talkSprites.size() < 1) { ret = _standSprite->getSprite(_dir); } else { @@ -1320,23 +1320,23 @@ bool AdActor::persist(BasePersistenceManager *persistMgr) { AdTalkHolder::persist(persistMgr); persistMgr->transfer(TMEMBER_INT(_dir)); - persistMgr->transfer(TMEMBER(_path)); + persistMgr->transferPtr(TMEMBER_PTR(_path)); persistMgr->transfer(TMEMBER(_pFCount)); persistMgr->transfer(TMEMBER(_pFStepX)); persistMgr->transfer(TMEMBER(_pFStepY)); persistMgr->transfer(TMEMBER(_pFX)); persistMgr->transfer(TMEMBER(_pFY)); - persistMgr->transfer(TMEMBER(_standSprite)); + persistMgr->transferPtr(TMEMBER_PTR(_standSprite)); _talkSprites.persist(persistMgr); _talkSpritesEx.persist(persistMgr); persistMgr->transfer(TMEMBER_INT(_targetDir)); persistMgr->transfer(TMEMBER_INT(_afterWalkDir)); - persistMgr->transfer(TMEMBER(_targetPoint)); - persistMgr->transfer(TMEMBER(_turnLeftSprite)); - persistMgr->transfer(TMEMBER(_turnRightSprite)); - persistMgr->transfer(TMEMBER(_walkSprite)); + persistMgr->transferPtr(TMEMBER_PTR(_targetPoint)); + persistMgr->transferPtr(TMEMBER_PTR(_turnLeftSprite)); + persistMgr->transferPtr(TMEMBER_PTR(_turnRightSprite)); + persistMgr->transferPtr(TMEMBER_PTR(_walkSprite)); - persistMgr->transfer(TMEMBER(_animSprite2)); + persistMgr->transferPtr(TMEMBER_PTR(_animSprite2)); persistMgr->transfer(TMEMBER(_talkAnimName)); persistMgr->transfer(TMEMBER(_idleAnimName)); persistMgr->transfer(TMEMBER(_walkAnimName)); @@ -1378,7 +1378,7 @@ TDirection AdActor::angleToDirection(int angle) { ////////////////////////////////////////////////////////////////////////// int AdActor::getHeight() { // if no current sprite is set, set some - if (_currentSprite == NULL) { + if (_currentSprite == nullptr) { if (_standSprite) { _currentSprite = _standSprite->getSprite(_dir); } else { @@ -1400,7 +1400,7 @@ AdSpriteSet *AdActor::getAnimByName(const Common::String &animName) { return _anims[i]; } } - return NULL; + return nullptr; } ////////////////////////////////////////////////////////////////////////// @@ -1411,7 +1411,7 @@ bool AdActor::mergeAnims(const char *animsFilename) { byte *fileBuffer = BaseFileManager::getEngineInstance()->readWholeFile(animsFilename); - if (fileBuffer == NULL) { + if (fileBuffer == nullptr) { _gameRef->LOG(0, "AdActor::MergeAnims failed for file '%s'", animsFilename); return STATUS_FAILED; } diff --git a/engines/wintermute/ad/ad_actor.h b/engines/wintermute/ad/ad_actor.h index 543c9d063a..3630c6665b 100644 --- a/engines/wintermute/ad/ad_actor.h +++ b/engines/wintermute/ad/ad_actor.h @@ -54,7 +54,7 @@ public: virtual bool update(); virtual bool display(); virtual void turnTo(TDirection dir); - AdActor(BaseGame *inGame/*=NULL*/); + AdActor(BaseGame *inGame/*=nullptr*/); virtual ~AdActor(); bool loadFile(const char *filename); bool loadBuffer(byte *buffer, bool complete = true); @@ -83,24 +83,24 @@ private: AdSpriteSet *getAnimByName(const Common::String &animName); // scripting interface - virtual ScValue *scGetProperty(const Common::String &name); - virtual bool scSetProperty(const char *name, ScValue *value); - virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); - virtual const char *scToString(); + virtual ScValue *scGetProperty(const Common::String &name) override; + virtual bool scSetProperty(const char *name, ScValue *value) override; + virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) override; + virtual const char *scToString() override; bool setDefaultAnimNames(); BaseSprite *getTalkStanceOld(const char *stance); bool mergeAnims(const char *animsFilename); BaseSprite *_animSprite2; - void initLine(BasePoint startPt, BasePoint endPt); + void initLine(const BasePoint &startPt, const BasePoint &endPt); void getNextStep(); void followPath(); double _pFStepX; double _pFStepY; double _pFX; double _pFY; - int _pFCount; + int32 _pFCount; }; } // end of namespace Wintermute diff --git a/engines/wintermute/ad/ad_entity.cpp b/engines/wintermute/ad/ad_entity.cpp index 9af7e034ca..c43f74b620 100644 --- a/engines/wintermute/ad/ad_entity.cpp +++ b/engines/wintermute/ad/ad_entity.cpp @@ -61,13 +61,13 @@ IMPLEMENT_PERSISTENT(AdEntity, false) AdEntity::AdEntity(BaseGame *inGame) : AdTalkHolder(inGame) { _type = OBJECT_ENTITY; _subtype = ENTITY_NORMAL; - _region = NULL; - _item = NULL; + _region = nullptr; + _item = nullptr; _walkToX = _walkToY = 0; _walkToDir = DI_NONE; - _theora = NULL; + _theora = nullptr; } @@ -76,17 +76,32 @@ AdEntity::~AdEntity() { _gameRef->unregisterObject(_region); delete _theora; - _theora = NULL; + _theora = nullptr; delete[] _item; - _item = NULL; + _item = nullptr; } +int32 AdEntity::getWalkToX() const { + return _walkToX; +} + +int32 AdEntity::getWalkToY() const { + return _walkToY; +} + +TDirection AdEntity::getWalkToDir() const { + return _walkToDir; +} + +const char *AdEntity::getItemName() const { + return _item; +} ////////////////////////////////////////////////////////////////////////// bool AdEntity::loadFile(const char *filename) { byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); - if (buffer == NULL) { + if (buffer == nullptr) { _gameRef->LOG(0, "AdEntity::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -210,7 +225,7 @@ bool AdEntity::loadBuffer(byte *buffer, bool complete) { } AdGame *adGame = (AdGame *)_gameRef; - BaseSprite *spr = NULL; + BaseSprite *spr = nullptr; int ar = 0, ag = 0, ab = 0, alpha = 0; while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { @@ -230,7 +245,7 @@ bool AdEntity::loadBuffer(byte *buffer, bool complete) { case TOKEN_SPRITE: { delete _sprite; - _sprite = NULL; + _sprite = nullptr; spr = new BaseSprite(_gameRef, this); if (!spr || DID_FAIL(spr->loadFile((char *)params))) { cmd = PARSERR_GENERIC; @@ -320,7 +335,7 @@ bool AdEntity::loadBuffer(byte *buffer, bool complete) { _cursor = new BaseSprite(_gameRef); if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { delete _cursor; - _cursor = NULL; + _cursor = nullptr; cmd = PARSERR_GENERIC; } break; @@ -333,7 +348,7 @@ bool AdEntity::loadBuffer(byte *buffer, bool complete) { if (_region) { _gameRef->unregisterObject(_region); } - _region = NULL; + _region = nullptr; BaseRegion *rgn = new BaseRegion(_gameRef); if (!rgn || DID_FAIL(rgn->loadBuffer(params, false))) { cmd = PARSERR_GENERIC; @@ -346,16 +361,16 @@ bool AdEntity::loadBuffer(byte *buffer, bool complete) { case TOKEN_BLOCKED_REGION: { delete _blockRegion; - _blockRegion = NULL; + _blockRegion = nullptr; delete _currentBlockRegion; - _currentBlockRegion = NULL; + _currentBlockRegion = nullptr; BaseRegion *rgn = new BaseRegion(_gameRef); BaseRegion *crgn = new BaseRegion(_gameRef); if (!rgn || !crgn || DID_FAIL(rgn->loadBuffer(params, false))) { delete _blockRegion; - _blockRegion = NULL; + _blockRegion = nullptr; delete _currentBlockRegion; - _currentBlockRegion = NULL; + _currentBlockRegion = nullptr; cmd = PARSERR_GENERIC; } else { _blockRegion = rgn; @@ -367,16 +382,16 @@ bool AdEntity::loadBuffer(byte *buffer, bool complete) { case TOKEN_WAYPOINTS: { delete _wptGroup; - _wptGroup = NULL; + _wptGroup = nullptr; delete _currentWptGroup; - _currentWptGroup = NULL; + _currentWptGroup = nullptr; AdWaypointGroup *wpt = new AdWaypointGroup(_gameRef); AdWaypointGroup *cwpt = new AdWaypointGroup(_gameRef); if (!wpt || !cwpt || DID_FAIL(wpt->loadBuffer(params, false))) { delete _wptGroup; - _wptGroup = NULL; + _wptGroup = nullptr; delete _currentWptGroup; - _currentWptGroup = NULL; + _currentWptGroup = nullptr; cmd = PARSERR_GENERIC; } else { _wptGroup = wpt; @@ -393,7 +408,7 @@ bool AdEntity::loadBuffer(byte *buffer, bool complete) { case TOKEN_SUBTYPE: { if (scumm_stricmp((char *)params, "sound") == 0) { delete _sprite; - _sprite = NULL; + _sprite = nullptr; if (_gameRef->_editorMode) { spr = new BaseSprite(_gameRef, this); if (!spr || DID_FAIL(spr->loadFile("entity_sound.sprite"))) { @@ -550,7 +565,7 @@ bool AdEntity::display() { } else if (_currentSprite) { _currentSprite->display(_posX, _posY, - (reg || _editorAlwaysRegister) ? _registerAlias : NULL, + (reg || _editorAlwaysRegister) ? _registerAlias : nullptr, scaleX, scaleY, alpha, @@ -570,15 +585,15 @@ bool AdEntity::display() { ////////////////////////////////////////////////////////////////////////// bool AdEntity::update() { - _currentSprite = NULL; + _currentSprite = nullptr; if (_state == STATE_READY && _animSprite) { delete _animSprite; - _animSprite = NULL; + _animSprite = nullptr; } // finished playing animation? - if (_state == STATE_PLAYING_ANIM && _animSprite != NULL && _animSprite->isFinished()) { + if (_state == STATE_PLAYING_ANIM && _animSprite != nullptr && _animSprite->isFinished()) { _state = STATE_READY; _currentSprite = _animSprite; } @@ -612,11 +627,11 @@ bool AdEntity::update() { _tempSprite2 = _sentence->_currentSprite; } - bool timeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->isPlaying() && !_sentence->_sound->isPaused())) || (!_sentence->_sound && _sentence->_duration <= _gameRef->_timer - _sentence->_startTime); - if (_tempSprite2 == NULL || _tempSprite2->isFinished() || (/*_tempSprite2->_looping &&*/ timeIsUp)) { + bool timeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->isPlaying() && !_sentence->_sound->isPaused())) || (!_sentence->_sound && _sentence->_duration <= _gameRef->getTimer()->getTime() - _sentence->_startTime); + if (_tempSprite2 == nullptr || _tempSprite2->isFinished() || (/*_tempSprite2->_looping &&*/ timeIsUp)) { if (timeIsUp) { _sentence->finish(); - _tempSprite2 = NULL; + _tempSprite2 = nullptr; _state = STATE_READY; } else { _tempSprite2 = getTalkStance(_sentence->getNextStance()); @@ -658,7 +673,7 @@ bool AdEntity::update() { if (_theora->isFinished()) { _theora->stop(); delete _theora; - _theora = NULL; + _theora = nullptr; } } @@ -722,7 +737,7 @@ bool AdEntity::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack if (_theora) { _theora->stop(); delete _theora; - _theora = NULL; + _theora = nullptr; stack->pushBool(true); } else { stack->pushBool(false); @@ -815,7 +830,7 @@ bool AdEntity::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack stack->correctParams(0); if (_region) { _gameRef->unregisterObject(_region); - _region = NULL; + _region = nullptr; stack->pushBool(true); } else { stack->pushBool(false); @@ -1056,7 +1071,7 @@ int AdEntity::getHeight() { if (_region && !_sprite) { return _region->_rect.bottom - _region->_rect.top; } else { - if (_currentSprite == NULL) { + if (_currentSprite == nullptr) { _currentSprite = _sprite; } return AdObject::getHeight(); @@ -1078,7 +1093,7 @@ bool AdEntity::persist(BasePersistenceManager *persistMgr) { AdTalkHolder::persist(persistMgr); persistMgr->transfer(TMEMBER(_item)); - persistMgr->transfer(TMEMBER(_region)); + persistMgr->transferPtr(TMEMBER_PTR(_region)); //persistMgr->transfer(TMEMBER(_sprite)); persistMgr->transfer(TMEMBER_INT(_subtype)); _talkSprites.persist(persistMgr); @@ -1088,7 +1103,7 @@ bool AdEntity::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_walkToY)); persistMgr->transfer(TMEMBER_INT(_walkToDir)); - persistMgr->transfer(TMEMBER(_theora)); + persistMgr->transferPtr(TMEMBER_PTR(_theora)); return STATUS_OK; } @@ -1102,15 +1117,15 @@ void AdEntity::setItem(const char *itemName) { ////////////////////////////////////////////////////////////////////////// bool AdEntity::setSprite(const char *filename) { if (_currentSprite == _sprite) { - _currentSprite = NULL; + _currentSprite = nullptr; } delete _sprite; - _sprite = NULL; + _sprite = nullptr; BaseSprite *spr = new BaseSprite(_gameRef, this); if (!spr || DID_FAIL(spr->loadFile(filename))) { delete _sprite; - _sprite = NULL; + _sprite = nullptr; return STATUS_FAILED; } else { _sprite = spr; diff --git a/engines/wintermute/ad/ad_entity.h b/engines/wintermute/ad/ad_entity.h index 415987e50a..c23b37366d 100644 --- a/engines/wintermute/ad/ad_entity.h +++ b/engines/wintermute/ad/ad_entity.h @@ -37,30 +37,35 @@ class AdEntity : public AdTalkHolder { public: VideoTheoraPlayer *_theora; bool setSprite(const char *filename); - int _walkToX; - int _walkToY; - TDirection _walkToDir; void setItem(const char *itemName); - char *_item; DECLARE_PERSISTENT(AdEntity, AdTalkHolder) void updatePosition(); virtual int getHeight(); BaseRegion *_region; - virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); + virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent) override; virtual bool update(); virtual bool display(); AdEntity(BaseGame *inGame); virtual ~AdEntity(); bool loadFile(const char *filename); bool loadBuffer(byte *buffer, bool complete = true); - TEntityType _subtype; - // scripting interface - virtual ScValue *scGetProperty(const Common::String &name); - virtual bool scSetProperty(const char *name, ScValue *value); - virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); - virtual const char *scToString(); + int32 getWalkToX() const; + int32 getWalkToY() const; + TDirection getWalkToDir() const; + const char* getItemName() const; + // scripting interface + virtual ScValue *scGetProperty(const Common::String &name) override; + virtual bool scSetProperty(const char *name, ScValue *value) override; + virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) override; + virtual const char *scToString() override; +private: + int32 _walkToX; + int32 _walkToY; + TDirection _walkToDir; + char *_item; + TEntityType _subtype; }; } // end of namespace Wintermute diff --git a/engines/wintermute/ad/ad_game.cpp b/engines/wintermute/ad/ad_game.cpp index 4481b774c1..ead68f7729 100644 --- a/engines/wintermute/ad/ad_game.cpp +++ b/engines/wintermute/ad/ad_game.cpp @@ -43,7 +43,6 @@ #include "engines/wintermute/base/base_object.h" #include "engines/wintermute/base/base_parser.h" #include "engines/wintermute/base/sound/base_sound.h" -#include "engines/wintermute/base/base_string_table.h" #include "engines/wintermute/base/base_surface_storage.h" #include "engines/wintermute/base/base_transition_manager.h" #include "engines/wintermute/base/base_sprite.h" @@ -69,22 +68,22 @@ IMPLEMENT_PERSISTENT(AdGame, true) ////////////////////////////////////////////////////////////////////////// AdGame::AdGame(const Common::String &gameId) : BaseGame(gameId) { - _responseBox = NULL; - _inventoryBox = NULL; + _responseBox = nullptr; + _inventoryBox = nullptr; _scene = new AdScene(_gameRef); _scene->setName(""); registerObject(_scene); - _prevSceneName = NULL; - _prevSceneFilename = NULL; - _scheduledScene = NULL; + _prevSceneName = nullptr; + _prevSceneFilename = nullptr; + _scheduledScene = nullptr; _scheduledFadeIn = false; _stateEx = GAME_NORMAL; - _selectedItem = NULL; + _selectedItem = nullptr; _texItemLifeTime = 10000; @@ -94,17 +93,17 @@ AdGame::AdGame(const Common::String &gameId) : BaseGame(gameId) { _talkSkipButton = TALK_SKIP_LEFT; - _sceneViewport = NULL; + _sceneViewport = nullptr; _initialScene = true; - _debugStartupScene = NULL; - _startupScene = NULL; + _debugStartupScene = nullptr; + _startupScene = nullptr; _invObject = new AdObject(this); _inventoryOwner = _invObject; _tempDisableSaveState = false; - _itemsFile = NULL; + _itemsFile = nullptr; _smartItemCursor = false; @@ -122,7 +121,7 @@ AdGame::~AdGame() { bool AdGame::cleanup() { for (uint32 i = 0; i < _objects.size(); i++) { unregisterObject(_objects[i]); - _objects[i] = NULL; + _objects[i] = nullptr; } _objects.clear(); @@ -139,7 +138,7 @@ bool AdGame::cleanup() { unregisterObject(_scene); - _scene = NULL; + _scene = nullptr; // remove items for (uint32 i = 0; i < _items.size(); i++) { @@ -150,7 +149,7 @@ bool AdGame::cleanup() { // clear remaining inventories delete _invObject; - _invObject = NULL; + _invObject = nullptr; for (uint32 i = 0; i < _inventories.size(); i++) { delete _inventories[i]; @@ -160,12 +159,12 @@ bool AdGame::cleanup() { if (_responseBox) { _gameRef->unregisterObject(_responseBox); - _responseBox = NULL; + _responseBox = nullptr; } if (_inventoryBox) { _gameRef->unregisterObject(_inventoryBox); - _inventoryBox = NULL; + _inventoryBox = nullptr; } delete[] _prevSceneName; @@ -173,15 +172,15 @@ bool AdGame::cleanup() { delete[] _scheduledScene; delete[] _debugStartupScene; delete[] _itemsFile; - _prevSceneName = NULL; - _prevSceneFilename = NULL; - _scheduledScene = NULL; - _debugStartupScene = NULL; - _startupScene = NULL; - _itemsFile = NULL; + _prevSceneName = nullptr; + _prevSceneFilename = nullptr; + _scheduledScene = nullptr; + _debugStartupScene = nullptr; + _startupScene = nullptr; + _itemsFile = nullptr; delete _sceneViewport; - _sceneViewport = NULL; + _sceneViewport = nullptr; for (uint32 i = 0; i < _sceneStates.size(); i++) { delete _sceneStates[i]; @@ -207,9 +206,9 @@ bool AdGame::initLoop() { if (_scheduledScene && _transMgr->isReady()) { changeScene(_scheduledScene, _scheduledFadeIn); delete[] _scheduledScene; - _scheduledScene = NULL; + _scheduledScene = nullptr; - _gameRef->_activeObject = NULL; + _gameRef->_activeObject = nullptr; } @@ -258,7 +257,7 @@ bool AdGame::removeObject(AdObject *object) { ////////////////////////////////////////////////////////////////////////// bool AdGame::changeScene(const char *filename, bool fadeIn) { - if (_scene == NULL) { + if (_scene == nullptr) { _scene = new AdScene(_gameRef); registerObject(_scene); } else { @@ -297,7 +296,7 @@ bool AdGame::changeScene(const char *filename, bool fadeIn) { // invalidate references to the original scene for (uint32 i = 0; i < _objects.size(); i++) { _objects[i]->invalidateCurrRegions(); - _objects[i]->_stickRegion = NULL; + _objects[i]->_stickRegion = nullptr; } _scene->loadState(); @@ -385,7 +384,7 @@ bool AdGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, stack->pushNative(act, true); } else { delete act; - act = NULL; + act = nullptr; stack->pushNULL(); } return STATUS_OK; @@ -402,7 +401,7 @@ bool AdGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, stack->pushNative(ent, true); } else { delete ent; - ent = NULL; + ent = nullptr; stack->pushNULL(); } return STATUS_OK; @@ -463,7 +462,7 @@ bool AdGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, stack->correctParams(1); ScValue *val = stack->pop(); - AdItem *item = NULL; + AdItem *item = nullptr; if (val->isNative()) { item = (AdItem *)val->getNative(); } else { @@ -485,7 +484,7 @@ bool AdGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, stack->correctParams(1); ScValue *val = stack->pop(); - AdItem *item = NULL; + AdItem *item = nullptr; if (val->isInt()) { int index = val->getInt(); if (index >= 0 && index < (int32)_items.size()) { @@ -520,9 +519,14 @@ bool AdGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, if (_responseBox) { AdResponse *res = new AdResponse(_gameRef); if (res) { - res->_iD = id; - res->setText(text); - _stringTable->expand(&res->_text); + res->setID(id); + + char *expandedText = new char[strlen(text) + 1]; + Common::strlcpy(expandedText, text, strlen(text) + 1); + expandStringByStringTable(&expandedText); + res->setText(expandedText); + delete[] expandedText; + if (!val1->isNULL()) { res->setIcon(val1->getString()); } @@ -542,7 +546,7 @@ bool AdGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, res->_responseType = RESPONSE_ONCE_GAME; } - _responseBox->_responses.add(res); + _responseBox->addResponse(res); } } else { script->runtimeError("Game.AddResponse: response box is not defined"); @@ -584,15 +588,15 @@ bool AdGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, if (_responseBox) { _responseBox->weedResponses(); - if (_responseBox->_responses.size() == 0) { + if (_responseBox->getNumResponses() == 0) { stack->pushNULL(); return STATUS_OK; } - if (_responseBox->_responses.size() == 1 && autoSelectLast) { - stack->pushInt(_responseBox->_responses[0]->_iD); - _responseBox->handleResponse(_responseBox->_responses[0]); + if (_responseBox->getNumResponses() == 1 && autoSelectLast) { + stack->pushInt(_responseBox->getIdForResponseNum(0)); + _responseBox->handleResponseNum(0); _responseBox->clearResponses(); return STATUS_OK; } @@ -617,7 +621,7 @@ bool AdGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, stack->correctParams(0); if (_responseBox) { _responseBox->weedResponses(); - stack->pushInt(_responseBox->_responses.size()); + stack->pushInt(_responseBox->getNumResponses()); } else { script->runtimeError("Game.GetNumResponses: response box is not defined"); stack->pushNULL(); @@ -639,7 +643,7 @@ bool AdGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, branchName = val->getString(); } - startDlgBranch(branchName.c_str(), script->_filename == NULL ? "" : script->_filename, script->_threadEvent == NULL ? "" : script->_threadEvent); + startDlgBranch(branchName.c_str(), script->_filename == nullptr ? "" : script->_filename, script->_threadEvent == nullptr ? "" : script->_threadEvent); stack->pushNULL(); return STATUS_OK; @@ -651,12 +655,12 @@ bool AdGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, else if (strcmp(name, "EndDlgBranch") == 0) { stack->correctParams(1); - const char *branchName = NULL; + const char *branchName = nullptr; ScValue *val = stack->pop(); if (!val->isNULL()) { branchName = val->getString(); } - endDlgBranch(branchName, script->_filename == NULL ? "" : script->_filename, script->_threadEvent == NULL ? "" : script->_threadEvent); + endDlgBranch(branchName, script->_filename == nullptr ? "" : script->_filename, script->_threadEvent == nullptr ? "" : script->_threadEvent); stack->pushNULL(); @@ -754,8 +758,8 @@ bool AdGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetResponsesWindow") == 0 || strcmp(name, "GetResponseWindow") == 0) { stack->correctParams(0); - if (_responseBox && _responseBox->_window) { - stack->pushNative(_responseBox->_window, true); + if (_responseBox && _responseBox->getResponseWindow()) { + stack->pushNative(_responseBox->getResponseWindow(), true); } else { stack->pushNULL(); } @@ -777,7 +781,7 @@ bool AdGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, stack->pushBool(true); } else { delete _responseBox; - _responseBox = NULL; + _responseBox = nullptr; stack->pushBool(false); } return STATUS_OK; @@ -797,7 +801,7 @@ bool AdGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, stack->pushBool(true); } else { delete _inventoryBox; - _inventoryBox = NULL; + _inventoryBox = nullptr; stack->pushBool(false); } return STATUS_OK; @@ -850,10 +854,10 @@ bool AdGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, int height = stack->pop()->getInt(); if (width <= 0) { - width = _renderer->_width; + width = _renderer->getWidth(); } if (height <= 0) { - height = _renderer->_height; + height = _renderer->getHeight(); } if (!_sceneViewport) { @@ -983,10 +987,10 @@ ScValue *AdGame::scGetProperty(const Common::String &name) { // LastResponse (RO) ////////////////////////////////////////////////////////////////////////// else if (name == "LastResponse") { - if (!_responseBox || !_responseBox->_lastResponseText) { + if (!_responseBox || !_responseBox->getLastResponseText()) { _scValue->setString(""); } else { - _scValue->setString(_responseBox->_lastResponseText); + _scValue->setString(_responseBox->getLastResponseText()); } return _scValue; } @@ -995,10 +999,10 @@ ScValue *AdGame::scGetProperty(const Common::String &name) { // LastResponseOrig (RO) ////////////////////////////////////////////////////////////////////////// else if (name == "LastResponseOrig") { - if (!_responseBox || !_responseBox->_lastResponseTextOrig) { + if (!_responseBox || !_responseBox->getLastResponseTextOrig()) { _scValue->setString(""); } else { - _scValue->setString(_responseBox->_lastResponseTextOrig); + _scValue->setString(_responseBox->getLastResponseTextOrig()); } return _scValue; } @@ -1036,7 +1040,7 @@ ScValue *AdGame::scGetProperty(const Common::String &name) { // ChangingScene ////////////////////////////////////////////////////////////////////////// else if (name == "ChangingScene") { - _scValue->setBool(_scheduledScene != NULL); + _scValue->setBool(_scheduledScene != nullptr); return _scValue; } @@ -1066,10 +1070,10 @@ bool AdGame::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "SelectedItem") == 0) { if (value->isNULL()) { - _selectedItem = NULL; + _selectedItem = nullptr; } else { if (value->isNative()) { - _selectedItem = NULL; + _selectedItem = nullptr; for (uint32 i = 0; i < _items.size(); i++) { if (_items[i] == value->getNative()) { _selectedItem = (AdItem *)value->getNative(); @@ -1158,9 +1162,9 @@ bool AdGame::scSetProperty(const char *name, ScValue *value) { // StartupScene ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "StartupScene") == 0) { - if (value == NULL) { + if (value == nullptr) { delete[] _startupScene; - _startupScene = NULL; + _startupScene = nullptr; } else { BaseUtils::setString(&_startupScene, value->getString()); } @@ -1242,7 +1246,7 @@ bool AdGame::showCursor() { ////////////////////////////////////////////////////////////////////////// bool AdGame::loadFile(const char *filename) { byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); - if (buffer == NULL) { + if (buffer == nullptr) { _gameRef->LOG(0, "AdGame::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -1316,7 +1320,7 @@ bool AdGame::loadBuffer(byte *buffer, bool complete) { registerObject(_responseBox); } else { delete _responseBox; - _responseBox = NULL; + _responseBox = nullptr; cmd = PARSERR_GENERIC; } break; @@ -1328,7 +1332,7 @@ bool AdGame::loadBuffer(byte *buffer, bool complete) { registerObject(_inventoryBox); } else { delete _inventoryBox; - _inventoryBox = NULL; + _inventoryBox = nullptr; cmd = PARSERR_GENERIC; } break; @@ -1338,7 +1342,7 @@ bool AdGame::loadBuffer(byte *buffer, bool complete) { BaseUtils::setString(&_itemsFile, (char *)params2); if (DID_FAIL(loadItemsFile(_itemsFile))) { delete[] _itemsFile; - _itemsFile = NULL; + _itemsFile = nullptr; cmd = PARSERR_GENERIC; } break; @@ -1409,32 +1413,32 @@ bool AdGame::persist(BasePersistenceManager *persistMgr) { _dlgPendingBranches.persist(persistMgr); _inventories.persist(persistMgr); - persistMgr->transfer(TMEMBER(_inventoryBox)); + persistMgr->transferPtr(TMEMBER_PTR(_inventoryBox)); _objects.persist(persistMgr); persistMgr->transfer(TMEMBER(_prevSceneName)); persistMgr->transfer(TMEMBER(_prevSceneFilename)); - persistMgr->transfer(TMEMBER(_responseBox)); + persistMgr->transferPtr(TMEMBER_PTR(_responseBox)); _responsesBranch.persist(persistMgr); _responsesGame.persist(persistMgr); - persistMgr->transfer(TMEMBER(_scene)); + persistMgr->transferPtr(TMEMBER_PTR(_scene)); _sceneStates.persist(persistMgr); persistMgr->transfer(TMEMBER(_scheduledFadeIn)); persistMgr->transfer(TMEMBER(_scheduledScene)); - persistMgr->transfer(TMEMBER(_selectedItem)); + persistMgr->transferPtr(TMEMBER_PTR(_selectedItem)); persistMgr->transfer(TMEMBER_INT(_talkSkipButton)); _sentences.persist(persistMgr); - persistMgr->transfer(TMEMBER(_sceneViewport)); + persistMgr->transferPtr(TMEMBER_PTR(_sceneViewport)); persistMgr->transfer(TMEMBER_INT(_stateEx)); persistMgr->transfer(TMEMBER(_initialScene)); persistMgr->transfer(TMEMBER(_debugStartupScene)); - persistMgr->transfer(TMEMBER(_invObject)); - persistMgr->transfer(TMEMBER(_inventoryOwner)); + persistMgr->transferPtr(TMEMBER_PTR(_invObject)); + persistMgr->transferPtr(TMEMBER_PTR(_inventoryOwner)); persistMgr->transfer(TMEMBER(_tempDisableSaveState)); _items.persist(persistMgr); @@ -1456,7 +1460,7 @@ bool AdGame::persist(BasePersistenceManager *persistMgr) { ////////////////////////////////////////////////////////////////////////// void AdGame::setPrevSceneName(const char *name) { delete[] _prevSceneName; - _prevSceneName = NULL; + _prevSceneName = nullptr; if (name) { _prevSceneName = new char[strlen(name) + 1]; if (_prevSceneName) { @@ -1469,7 +1473,7 @@ void AdGame::setPrevSceneName(const char *name) { ////////////////////////////////////////////////////////////////////////// void AdGame::setPrevSceneFilename(const char *name) { delete[] _prevSceneFilename; - _prevSceneFilename = NULL; + _prevSceneFilename = nullptr; if (name) { _prevSceneFilename = new char[strlen(name) + 1]; if (_prevSceneFilename) { @@ -1482,7 +1486,7 @@ void AdGame::setPrevSceneFilename(const char *name) { ////////////////////////////////////////////////////////////////////////// bool AdGame::scheduleChangeScene(const char *filename, bool fadeIn) { delete[] _scheduledScene; - _scheduledScene = NULL; + _scheduledScene = nullptr; if (_scene && !_scene->_initialized) { return changeScene(filename, fadeIn); @@ -1498,8 +1502,8 @@ bool AdGame::scheduleChangeScene(const char *filename, bool fadeIn) { ////////////////////////////////////////////////////////////////////////// -bool AdGame::getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor) { - BaseGame::getVersion(verMajor, verMinor, NULL, NULL); +bool AdGame::getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor) const { + BaseGame::getVersion(verMajor, verMinor, nullptr, nullptr); if (extMajor) { *extMajor = 0; @@ -1515,7 +1519,7 @@ bool AdGame::getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *ex ////////////////////////////////////////////////////////////////////////// bool AdGame::loadItemsFile(const char *filename, bool merge) { byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); - if (buffer == NULL) { + if (buffer == nullptr) { _gameRef->LOG(0, "AdGame::LoadItemsFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -1567,7 +1571,7 @@ bool AdGame::loadItemsBuffer(byte *buffer, bool merge) { addItem(item); } else { delete item; - item = NULL; + item = nullptr; cmd = PARSERR_GENERIC; } } @@ -1599,7 +1603,7 @@ AdSceneState *AdGame::getSceneState(const char *filename, bool saving) { } for (uint32 i = 0; i < _sceneStates.size(); i++) { - if (scumm_stricmp(_sceneStates[i]->_filename, filenameCor) == 0) { + if (scumm_stricmp(_sceneStates[i]->getFilename(), filenameCor) == 0) { delete[] filenameCor; return _sceneStates[i]; } @@ -1615,7 +1619,7 @@ AdSceneState *AdGame::getSceneState(const char *filename, bool saving) { return ret; } else { delete[] filenameCor; - return NULL; + return nullptr; } } @@ -1635,7 +1639,7 @@ bool AdGame::windowLoadHook(UIWindow *win, char **buffer, char **params) { UIEntity *ent = new UIEntity(_gameRef); if (!ent || DID_FAIL(ent->loadBuffer((byte *)*params, false))) { delete ent; - ent = NULL; + ent = nullptr; cmd = PARSERR_GENERIC; } else { ent->_parent = win; @@ -1689,12 +1693,12 @@ bool AdGame::startDlgBranch(const char *branchName, const char *scriptName, cons ////////////////////////////////////////////////////////////////////////// bool AdGame::endDlgBranch(const char *branchName, const char *scriptName, const char *eventName) { - char *name = NULL; + char *name = nullptr; bool deleteName = false; - if (branchName == NULL && _dlgPendingBranches.size() > 0) { + if (branchName == nullptr && _dlgPendingBranches.size() > 0) { name = _dlgPendingBranches[_dlgPendingBranches.size() - 1]; } else { - if (branchName != NULL) { + if (branchName != nullptr) { name = new char[strlen(branchName) + 1 + strlen(scriptName) + 1 + strlen(eventName) + 1]; if (name) { sprintf(name, "%s.%s.%s", branchName, scriptName, eventName); @@ -1703,7 +1707,7 @@ bool AdGame::endDlgBranch(const char *branchName, const char *scriptName, const } } - if (name == NULL) { + if (name == nullptr) { return STATUS_OK; } @@ -1719,7 +1723,7 @@ bool AdGame::endDlgBranch(const char *branchName, const char *scriptName, const for (uint32 i = startIndex; i < _dlgPendingBranches.size(); i++) { //ClearBranchResponses(_dlgPendingBranches[i]); delete[] _dlgPendingBranches[i]; - _dlgPendingBranches[i] = NULL; + _dlgPendingBranches[i] = nullptr; } _dlgPendingBranches.remove_at(startIndex, _dlgPendingBranches.size() - startIndex); } @@ -1743,7 +1747,7 @@ bool AdGame::endDlgBranch(const char *branchName, const char *scriptName, const ////////////////////////////////////////////////////////////////////////// bool AdGame::clearBranchResponses(char *name) { for (uint32 i = 0; i < _responsesBranch.size(); i++) { - if (scumm_stricmp(name, _responsesBranch[i]->_context) == 0) { + if (scumm_stricmp(name, _responsesBranch[i]->getContext()) == 0) { delete _responsesBranch[i]; _responsesBranch.remove_at(i); i--; @@ -1760,18 +1764,18 @@ bool AdGame::addBranchResponse(int id) { } AdResponseContext *r = new AdResponseContext(_gameRef); r->_id = id; - r->setContext(_dlgPendingBranches.size() > 0 ? _dlgPendingBranches[_dlgPendingBranches.size() - 1] : NULL); + r->setContext(_dlgPendingBranches.size() > 0 ? _dlgPendingBranches[_dlgPendingBranches.size() - 1] : nullptr); _responsesBranch.add(r); return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool AdGame::branchResponseUsed(int id) { - char *context = _dlgPendingBranches.size() > 0 ? _dlgPendingBranches[_dlgPendingBranches.size() - 1] : NULL; +bool AdGame::branchResponseUsed(int id) const { + char *context = _dlgPendingBranches.size() > 0 ? _dlgPendingBranches[_dlgPendingBranches.size() - 1] : nullptr; for (uint32 i = 0; i < _responsesBranch.size(); i++) { if (_responsesBranch[i]->_id == id) { - if ((context == NULL && _responsesBranch[i]->_context == NULL) || scumm_stricmp(context, _responsesBranch[i]->_context) == 0) { + if ((context == nullptr && _responsesBranch[i]->getContext() == nullptr) || scumm_stricmp(context, _responsesBranch[i]->getContext()) == 0) { return true; } } @@ -1787,19 +1791,19 @@ bool AdGame::addGameResponse(int id) { } AdResponseContext *r = new AdResponseContext(_gameRef); r->_id = id; - r->setContext(_dlgPendingBranches.size() > 0 ? _dlgPendingBranches[_dlgPendingBranches.size() - 1] : NULL); + r->setContext(_dlgPendingBranches.size() > 0 ? _dlgPendingBranches[_dlgPendingBranches.size() - 1] : nullptr); _responsesGame.add(r); return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool AdGame::gameResponseUsed(int id) { - char *context = _dlgPendingBranches.size() > 0 ? _dlgPendingBranches[_dlgPendingBranches.size() - 1] : NULL; +bool AdGame::gameResponseUsed(int id) const { + char *context = _dlgPendingBranches.size() > 0 ? _dlgPendingBranches[_dlgPendingBranches.size() - 1] : nullptr; for (uint32 i = 0; i < _responsesGame.size(); i++) { - AdResponseContext *respContext = _responsesGame[i]; + const AdResponseContext *respContext = _responsesGame[i]; if (respContext->_id == id) { - if ((context == NULL && respContext->_context == NULL) || ((context != NULL && respContext->_context != NULL) && scumm_stricmp(context, respContext->_context) == 0)) { + if ((context == nullptr && respContext->getContext() == nullptr) || ((context != nullptr && respContext->getContext() != nullptr) && scumm_stricmp(context, respContext->getContext()) == 0)) { return true; } } @@ -1810,11 +1814,11 @@ bool AdGame::gameResponseUsed(int id) { ////////////////////////////////////////////////////////////////////////// bool AdGame::resetResponse(int id) { - char *context = _dlgPendingBranches.size() > 0 ? _dlgPendingBranches[_dlgPendingBranches.size() - 1] : NULL; + char *context = _dlgPendingBranches.size() > 0 ? _dlgPendingBranches[_dlgPendingBranches.size() - 1] : nullptr; for (uint32 i = 0; i < _responsesGame.size(); i++) { if (_responsesGame[i]->_id == id) { - if ((context == NULL && _responsesGame[i]->_context == NULL) || scumm_stricmp(context, _responsesGame[i]->_context) == 0) { + if ((context == nullptr && _responsesGame[i]->getContext() == nullptr) || scumm_stricmp(context, _responsesGame[i]->getContext()) == 0) { delete _responsesGame[i]; _responsesGame.remove_at(i); break; @@ -1824,7 +1828,7 @@ bool AdGame::resetResponse(int id) { for (uint32 i = 0; i < _responsesBranch.size(); i++) { if (_responsesBranch[i]->_id == id) { - if ((context == NULL && _responsesBranch[i]->_context == NULL) || scumm_stricmp(context, _responsesBranch[i]->_context) == 0) { + if ((context == nullptr && _responsesBranch[i]->getContext() == nullptr) || scumm_stricmp(context, _responsesBranch[i]->getContext()) == 0) { delete _responsesBranch[i]; _responsesBranch.remove_at(i); break; @@ -1863,7 +1867,7 @@ bool AdGame::displayContent(bool doUpdate, bool displayAll) { } if (_theoraPlayer->isFinished()) { delete _theoraPlayer; - _theoraPlayer = NULL; + _theoraPlayer = nullptr; } } else { @@ -1912,7 +1916,7 @@ bool AdGame::displayContent(bool doUpdate, bool displayAll) { _loadingIcon->display(_loadingIconX, _loadingIconY); if (!_loadingIconPersistent) { delete _loadingIcon; - _loadingIcon = NULL; + _loadingIcon = nullptr; } } @@ -1959,13 +1963,13 @@ bool AdGame::isItemTaken(char *itemName) { } ////////////////////////////////////////////////////////////////////////// -AdItem *AdGame::getItemByName(const char *name) { +AdItem *AdGame::getItemByName(const char *name) const { for (uint32 i = 0; i < _items.size(); i++) { if (scumm_stricmp(_items[i]->getName(), name) == 0) { return _items[i]; } } - return NULL; + return nullptr; } @@ -2026,7 +2030,7 @@ bool AdGame::deleteItem(AdItem *item) { } if (_selectedItem == item) { - _selectedItem = NULL; + _selectedItem = nullptr; } _scene->handleItemAssociations(item->getName(), false); @@ -2115,7 +2119,7 @@ char *AdGame::findSpeechFile(char *stringID) { } } delete[] ret; - return NULL; + return nullptr; } @@ -2145,14 +2149,14 @@ bool AdGame::onMouseLeftDown() { bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("LeftClick")); if (!handled) { - if (_activeObject != NULL) { + if (_activeObject != nullptr) { _activeObject->applyEvent("LeftClick"); } else if (_state == GAME_RUNNING && _scene && _scene->pointInViewport(_mousePos.x, _mousePos.y)) { _scene->applyEvent("LeftClick"); } } - if (_activeObject != NULL) { + if (_activeObject != nullptr) { _gameRef->_capturedObject = _gameRef->_activeObject; } _mouseLeftDown = true; @@ -2168,12 +2172,12 @@ bool AdGame::onMouseLeftUp() { } BasePlatform::releaseCapture(); - _capturedObject = NULL; + _capturedObject = nullptr; _mouseLeftDown = false; bool handled = /*_state==GAME_RUNNING &&*/ DID_SUCCEED(applyEvent("LeftRelease")); if (!handled) { - if (_activeObject != NULL) { + if (_activeObject != nullptr) { _activeObject->applyEvent("LeftRelease"); } else if (_state == GAME_RUNNING && _scene && _scene->pointInViewport(_mousePos.x, _mousePos.y)) { _scene->applyEvent("LeftRelease"); @@ -2198,7 +2202,7 @@ bool AdGame::onMouseLeftDblClick() { bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("LeftDoubleClick")); if (!handled) { - if (_activeObject != NULL) { + if (_activeObject != nullptr) { _activeObject->applyEvent("LeftDoubleClick"); } else if (_state == GAME_RUNNING && _scene && _scene->pointInViewport(_mousePos.x, _mousePos.y)) { _scene->applyEvent("LeftDoubleClick"); @@ -2229,7 +2233,7 @@ bool AdGame::onMouseRightDown() { bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("RightClick")); if (!handled) { - if (_activeObject != NULL) { + if (_activeObject != nullptr) { _activeObject->applyEvent("RightClick"); } else if (_state == GAME_RUNNING && _scene && _scene->pointInViewport(_mousePos.x, _mousePos.y)) { _scene->applyEvent("RightClick"); @@ -2246,7 +2250,7 @@ bool AdGame::onMouseRightUp() { bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("RightRelease")); if (!handled) { - if (_activeObject != NULL) { + if (_activeObject != nullptr) { _activeObject->applyEvent("RightRelease"); } else if (_state == GAME_RUNNING && _scene && _scene->pointInViewport(_mousePos.x, _mousePos.y)) { _scene->applyEvent("RightRelease"); @@ -2260,10 +2264,10 @@ bool AdGame::displayDebugInfo() { char str[100]; if (_gameRef->_debugDebugMode) { 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); + _systemFont->drawText((byte *)str, 0, 90, _renderer->getWidth(), TAL_RIGHT); sprintf(str, "Scene: %s (prev: %s)", (_scene && _scene->getName()) ? _scene->getName() : "???", _prevSceneName ? _prevSceneName : "???"); - _systemFont->drawText((byte *)str, 0, 110, _renderer->_width, TAL_RIGHT); + _systemFont->drawText((byte *)str, 0, 110, _renderer->getWidth(), TAL_RIGHT); } return BaseGame::displayDebugInfo(); } @@ -2272,7 +2276,7 @@ bool AdGame::displayDebugInfo() { ////////////////////////////////////////////////////////////////////////// bool AdGame::onScriptShutdown(ScScript *script) { if (_responseBox && _responseBox->_waitingScript == script) { - _responseBox->_waitingScript = NULL; + _responseBox->_waitingScript = nullptr; } return STATUS_OK; diff --git a/engines/wintermute/ad/ad_game.h b/engines/wintermute/ad/ad_game.h index 81c79a3da8..2032a1723f 100644 --- a/engines/wintermute/ad/ad_game.h +++ b/engines/wintermute/ad/ad_game.h @@ -44,15 +44,15 @@ class AdResponseContext; class AdResponseBox; class AdGame : public BaseGame { public: - virtual bool onScriptShutdown(ScScript *script); + virtual bool onScriptShutdown(ScScript *script) override; - virtual bool onMouseLeftDown(); - virtual bool onMouseLeftUp(); - virtual bool onMouseLeftDblClick(); - virtual bool onMouseRightDown(); - virtual bool onMouseRightUp(); + virtual bool onMouseLeftDown() override; + virtual bool onMouseLeftUp() override; + virtual bool onMouseLeftDblClick() override; + virtual bool onMouseRightDown() override; + virtual bool onMouseRightUp() override; - virtual bool displayDebugInfo(); + virtual bool displayDebugInfo() override; bool addSpeechDir(const char *dir); bool removeSpeechDir(const char *dir); @@ -63,37 +63,37 @@ public: bool _tempDisableSaveState; virtual bool resetContent(); bool addItem(AdItem *item); - AdItem *getItemByName(const char *name); + AdItem *getItemByName(const char *name) const; AdObject *_inventoryOwner; bool isItemTaken(char *itemName); bool registerInventory(AdInventory *inv); bool unregisterInventory(AdInventory *inv); - virtual bool displayContent(bool update = true, bool displayAll = false); + virtual bool displayContent(bool update = true, bool displayAll = false) override; - bool gameResponseUsed(int ID); + bool gameResponseUsed(int ID) const; bool addGameResponse(int ID); bool resetResponse(int ID); - bool branchResponseUsed(int ID); + bool branchResponseUsed(int ID) const; bool addBranchResponse(int ID); bool clearBranchResponses(char *name); bool startDlgBranch(const char *branchName, const char *scriptName, const char *eventName); bool endDlgBranch(const char *branchName, const char *scriptName, const char *eventName); - virtual bool windowLoadHook(UIWindow *win, char **buf, char **params); - virtual bool windowScriptMethodHook(UIWindow *win, ScScript *script, ScStack *stack, const char *name); + virtual bool windowLoadHook(UIWindow *win, char **buf, char **params) override; + virtual bool windowScriptMethodHook(UIWindow *win, ScScript *script, ScStack *stack, const char *name) override; AdSceneState *getSceneState(const char *filename, bool saving); BaseViewport *_sceneViewport; - int _texItemLifeTime; - int _texWalkLifeTime; - int _texStandLifeTime; - int _texTalkLifeTime; + int32 _texItemLifeTime; + int32 _texWalkLifeTime; + int32 _texStandLifeTime; + int32 _texTalkLifeTime; TTalkSkipButton _talkSkipButton; - virtual bool getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor); + virtual bool getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor) const override; bool scheduleChangeScene(const char *filename, bool fadeIn); void setPrevSceneName(const char *name); void setPrevSceneFilename(const char *name); @@ -126,12 +126,12 @@ public: bool loadItemsBuffer(byte *buffer, bool merge = false); // scripting interface - virtual ScValue *scGetProperty(const Common::String &name); - virtual bool scSetProperty(const char *name, ScValue *value); - virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); + virtual ScValue *scGetProperty(const Common::String &name) override; + virtual bool scSetProperty(const char *name, ScValue *value) override; + virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) override; bool validMouse(); private: - virtual bool externalCall(ScScript *script, ScStack *stack, ScStack *thisStack, char *name); + virtual bool externalCall(ScScript *script, ScStack *stack, ScStack *thisStack, char *name) override; AdObject *_invObject; BaseArray<AdInventory *> _inventories; @@ -151,8 +151,8 @@ private: BaseArray<AdSceneState *> _sceneStates; BaseArray<char *> _dlgPendingBranches; - BaseArray<AdResponseContext *> _responsesBranch; - BaseArray<AdResponseContext *> _responsesGame; + BaseArray<const AdResponseContext *> _responsesBranch; + BaseArray<const AdResponseContext *> _responsesGame; AdResponseBox *_responseBox; AdInventoryBox *_inventoryBox; diff --git a/engines/wintermute/ad/ad_inventory.cpp b/engines/wintermute/ad/ad_inventory.cpp index 72f8fa0fb4..e9b6e56f16 100644 --- a/engines/wintermute/ad/ad_inventory.cpp +++ b/engines/wintermute/ad/ad_inventory.cpp @@ -50,12 +50,12 @@ AdInventory::~AdInventory() { ////////////////////////////////////////////////////////////////////////// bool AdInventory::insertItem(const char *name, const char *insertAfter) { - if (name == NULL) { + if (name == nullptr) { return STATUS_FAILED; } AdItem *item = ((AdGame *)_gameRef)->getItemByName(name); - if (item == NULL) { + if (item == nullptr) { return STATUS_FAILED; } @@ -84,14 +84,14 @@ bool AdInventory::insertItem(const char *name, const char *insertAfter) { ////////////////////////////////////////////////////////////////////////// bool AdInventory::removeItem(const char *name) { - if (name == NULL) { + if (name == nullptr) { return STATUS_FAILED; } for (uint32 i = 0; i < _takenItems.size(); i++) { if (scumm_stricmp(_takenItems[i]->getName(), name) == 0) { if (((AdGame *)_gameRef)->_selectedItem == _takenItems[i]) { - ((AdGame *)_gameRef)->_selectedItem = NULL; + ((AdGame *)_gameRef)->_selectedItem = nullptr; } _takenItems.remove_at(i); return STATUS_OK; @@ -105,14 +105,14 @@ bool AdInventory::removeItem(const char *name) { ////////////////////////////////////////////////////////////////////////// bool AdInventory::removeItem(AdItem *item) { - if (item == NULL) { + if (item == nullptr) { return STATUS_FAILED; } for (uint32 i = 0; i < _takenItems.size(); i++) { if (_takenItems[i] == item) { if (((AdGame *)_gameRef)->_selectedItem == _takenItems[i]) { - ((AdGame *)_gameRef)->_selectedItem = NULL; + ((AdGame *)_gameRef)->_selectedItem = nullptr; } _takenItems.remove_at(i); return STATUS_OK; diff --git a/engines/wintermute/ad/ad_inventory.h b/engines/wintermute/ad/ad_inventory.h index 4017d914bc..999200b465 100644 --- a/engines/wintermute/ad/ad_inventory.h +++ b/engines/wintermute/ad/ad_inventory.h @@ -40,11 +40,11 @@ public: DECLARE_PERSISTENT(AdInventory, BaseObject) bool removeItem(const char *name); bool removeItem(AdItem *Item); - bool insertItem(const char *name, const char *insertAfter = NULL); + bool insertItem(const char *name, const char *insertAfter = nullptr); AdInventory(BaseGame *inGame); virtual ~AdInventory(); BaseArray<AdItem *> _takenItems; - int _scrollOffset; + int32 _scrollOffset; }; } // end of namespace Wintermute diff --git a/engines/wintermute/ad/ad_inventory_box.cpp b/engines/wintermute/ad/ad_inventory_box.cpp index 7ae8ff8d69..110359917b 100644 --- a/engines/wintermute/ad/ad_inventory_box.cpp +++ b/engines/wintermute/ad/ad_inventory_box.cpp @@ -54,8 +54,8 @@ AdInventoryBox::AdInventoryBox(BaseGame *inGame) : BaseObject(inGame) { _itemWidth = _itemHeight = 50; _scrollBy = 1; - _window = NULL; - _closeButton = NULL; + _window = nullptr; + _closeButton = nullptr; _hideSelected = false; @@ -67,10 +67,10 @@ AdInventoryBox::AdInventoryBox(BaseGame *inGame) : BaseObject(inGame) { ////////////////////////////////////////////////////////////////////////// AdInventoryBox::~AdInventoryBox() { _gameRef->unregisterObject(_window); - _window = NULL; + _window = nullptr; delete _closeButton; - _closeButton = NULL; + _closeButton = nullptr; } @@ -84,7 +84,7 @@ bool AdInventoryBox::listen(BaseScriptHolder *param1, uint32 param2) { _visible = false; } else if (scumm_stricmp(obj->getName(), "prev") == 0) { _scrollOffset -= _scrollBy; - _scrollOffset = MAX(_scrollOffset, 0); + _scrollOffset = MAX<int32>(_scrollOffset, 0); } else if (scumm_stricmp(obj->getName(), "next") == 0) { _scrollOffset += _scrollBy; } else { @@ -120,8 +120,8 @@ bool AdInventoryBox::display() { if (_closeButton) { _closeButton->_posX = _closeButton->_posY = 0; - _closeButton->_width = _gameRef->_renderer->_width; - _closeButton->_height = _gameRef->_renderer->_height; + _closeButton->_width = _gameRef->_renderer->getWidth(); + _closeButton->_height = _gameRef->_renderer->getHeight(); _closeButton->display(); } @@ -166,7 +166,7 @@ bool AdInventoryBox::display() { ////////////////////////////////////////////////////////////////////////// bool AdInventoryBox::loadFile(const char *filename) { byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); - if (buffer == NULL) { + if (buffer == nullptr) { _gameRef->LOG(0, "AdInventoryBox::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -256,7 +256,7 @@ bool AdInventoryBox::loadBuffer(byte *buffer, bool complete) { _window = new UIWindow(_gameRef); if (!_window || DID_FAIL(_window->loadBuffer(params, false))) { delete _window; - _window = NULL; + _window = nullptr; cmd = PARSERR_GENERIC; } else { _gameRef->registerObject(_window); @@ -371,7 +371,7 @@ bool AdInventoryBox::saveAsText(BaseDynamicBuffer *buffer, int indent) { bool AdInventoryBox::persist(BasePersistenceManager *persistMgr) { BaseObject::persist(persistMgr); - persistMgr->transfer(TMEMBER(_closeButton)); + persistMgr->transferPtr(TMEMBER_PTR(_closeButton)); persistMgr->transfer(TMEMBER(_hideSelected)); persistMgr->transfer(TMEMBER(_itemHeight)); persistMgr->transfer(TMEMBER(_itemsArea)); @@ -380,7 +380,7 @@ bool AdInventoryBox::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_scrollOffset)); persistMgr->transfer(TMEMBER(_spacing)); persistMgr->transfer(TMEMBER(_visible)); - persistMgr->transfer(TMEMBER(_window)); + persistMgr->transferPtr(TMEMBER_PTR(_window)); persistMgr->transfer(TMEMBER(_exclusive)); return STATUS_OK; diff --git a/engines/wintermute/ad/ad_inventory_box.h b/engines/wintermute/ad/ad_inventory_box.h index cb6d084562..9792b1ea66 100644 --- a/engines/wintermute/ad/ad_inventory_box.h +++ b/engines/wintermute/ad/ad_inventory_box.h @@ -43,8 +43,8 @@ public: bool _visible; virtual bool display(); UIButton *_closeButton; - int _spacing; - int _scrollOffset; + int32 _spacing; + int32 _scrollOffset; Rect32 _itemsArea; bool listen(BaseScriptHolder *param1, uint32 param2); UIWindow *_window; @@ -52,12 +52,12 @@ public: virtual ~AdInventoryBox(); bool loadFile(const char *filename); bool loadBuffer(byte *buffer, bool complete = true); - virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); + virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent) override; private: bool _exclusive; - int _scrollBy; - int _itemHeight; - int _itemWidth; + int32 _scrollBy; + int32 _itemHeight; + int32 _itemWidth; }; } // end of namespace Wintermute diff --git a/engines/wintermute/ad/ad_item.cpp b/engines/wintermute/ad/ad_item.cpp index 427b1c7db4..1a46eb783b 100644 --- a/engines/wintermute/ad/ad_item.cpp +++ b/engines/wintermute/ad/ad_item.cpp @@ -49,8 +49,8 @@ IMPLEMENT_PERSISTENT(AdItem, false) ////////////////////////////////////////////////////////////////////////// AdItem::AdItem(BaseGame *inGame) : AdTalkHolder(inGame) { - _spriteHover = NULL; - _cursorNormal = _cursorHover = NULL; + _spriteHover = nullptr; + _cursorNormal = _cursorHover = nullptr; _cursorCombined = true; _inInventory = false; @@ -60,7 +60,7 @@ AdItem::AdItem(BaseGame *inGame) : AdTalkHolder(inGame) { _amountOffsetX = 0; _amountOffsetY = 0; _amountAlign = TAL_RIGHT; - _amountString = NULL; + _amountString = nullptr; _state = STATE_READY; @@ -73,19 +73,19 @@ AdItem::~AdItem() { delete _spriteHover; delete _cursorNormal; delete _cursorHover; - _spriteHover = NULL; - _cursorNormal = NULL; - _cursorHover = NULL; + _spriteHover = nullptr; + _cursorNormal = nullptr; + _cursorHover = nullptr; delete[] _amountString; - _amountString = NULL; + _amountString = nullptr; } ////////////////////////////////////////////////////////////////////////// bool AdItem::loadFile(const char *filename) { byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); - if (buffer == NULL) { + if (buffer == nullptr) { _gameRef->LOG(0, "AdItem::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -272,7 +272,7 @@ bool AdItem::loadBuffer(byte *buffer, bool complete) { _cursorNormal = new BaseSprite(_gameRef); if (!_cursorNormal || DID_FAIL(_cursorNormal->loadFile((char *)params, ((AdGame *)_gameRef)->_texItemLifeTime))) { delete _cursorNormal; - _cursorNormal = NULL; + _cursorNormal = nullptr; cmd = PARSERR_GENERIC; } break; @@ -282,7 +282,7 @@ bool AdItem::loadBuffer(byte *buffer, bool complete) { _cursorHover = new BaseSprite(_gameRef); if (!_cursorHover || DID_FAIL(_cursorHover->loadFile((char *)params, ((AdGame *)_gameRef)->_texItemLifeTime))) { delete _cursorHover; - _cursorHover = NULL; + _cursorHover = nullptr; cmd = PARSERR_GENERIC; } break; @@ -332,15 +332,15 @@ bool AdItem::loadBuffer(byte *buffer, bool complete) { ////////////////////////////////////////////////////////////////////////// bool AdItem::update() { - _currentSprite = NULL; + _currentSprite = nullptr; if (_state == STATE_READY && _animSprite) { delete _animSprite; - _animSprite = NULL; + _animSprite = nullptr; } // finished playing animation? - if (_state == STATE_PLAYING_ANIM && _animSprite != NULL && _animSprite->isFinished()) { + if (_state == STATE_PLAYING_ANIM && _animSprite != nullptr && _animSprite->isFinished()) { _state = STATE_READY; _currentSprite = _animSprite; } @@ -378,11 +378,11 @@ bool AdItem::update() { _tempSprite2 = _sentence->_currentSprite; } - bool timeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->isPlaying() && !_sentence->_sound->isPaused())) || (!_sentence->_sound && _sentence->_duration <= _gameRef->_timer - _sentence->_startTime); - if (_tempSprite2 == NULL || _tempSprite2->isFinished() || (/*_tempSprite2->_looping &&*/ timeIsUp)) { + bool timeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->isPlaying() && !_sentence->_sound->isPaused())) || (!_sentence->_sound && _sentence->_duration <= _gameRef->getTimer()->getTime() - _sentence->_startTime); + if (_tempSprite2 == nullptr || _tempSprite2->isFinished() || (/*_tempSprite2->_looping &&*/ timeIsUp)) { if (timeIsUp) { _sentence->finish(); - _tempSprite2 = NULL; + _tempSprite2 = nullptr; _state = STATE_READY; } else { _tempSprite2 = getTalkStance(_sentence->getNextStance()); @@ -435,7 +435,7 @@ bool AdItem::display(int x, int y) { } amountX += _amountOffsetX; - BaseFont *font = _font ? _font : _gameRef->_systemFont; + BaseFont *font = _font ? _font : _gameRef->getSystemFont(); if (font) { if (_amountString) { font->drawText((byte *)_amountString, amountX, amountY, width, _amountAlign); @@ -469,7 +469,7 @@ bool AdItem::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *filename = stack->pop()->getString(); delete _spriteHover; - _spriteHover = NULL; + _spriteHover = nullptr; BaseSprite *spr = new BaseSprite(_gameRef, this); if (!spr || DID_FAIL(spr->loadFile(filename))) { stack->pushBool(false); @@ -520,7 +520,7 @@ bool AdItem::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *filename = stack->pop()->getString(); delete _cursorNormal; - _cursorNormal = NULL; + _cursorNormal = nullptr; BaseSprite *spr = new BaseSprite(_gameRef); if (!spr || DID_FAIL(spr->loadFile(filename))) { stack->pushBool(false); @@ -569,7 +569,7 @@ bool AdItem::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *filename = stack->pop()->getString(); delete _cursorHover; - _cursorHover = NULL; + _cursorHover = nullptr; BaseSprite *spr = new BaseSprite(_gameRef); if (!spr || DID_FAIL(spr->loadFile(filename))) { stack->pushBool(false); @@ -753,7 +753,7 @@ bool AdItem::scSetProperty(const char *name, ScValue *value) { else if (strcmp(name, "AmountString") == 0) { if (value->isNULL()) { delete[] _amountString; - _amountString = NULL; + _amountString = nullptr; } else { BaseUtils::setString(&_amountString, value->getString()); } @@ -784,9 +784,9 @@ bool AdItem::persist(BasePersistenceManager *persistMgr) { AdTalkHolder::persist(persistMgr); persistMgr->transfer(TMEMBER(_cursorCombined)); - persistMgr->transfer(TMEMBER(_cursorHover)); - persistMgr->transfer(TMEMBER(_cursorNormal)); - persistMgr->transfer(TMEMBER(_spriteHover)); + persistMgr->transferPtr(TMEMBER_PTR(_cursorHover)); + persistMgr->transferPtr(TMEMBER_PTR(_cursorNormal)); + persistMgr->transferPtr(TMEMBER_PTR(_spriteHover)); persistMgr->transfer(TMEMBER(_inInventory)); persistMgr->transfer(TMEMBER(_displayAmount)); persistMgr->transfer(TMEMBER(_amount)); diff --git a/engines/wintermute/ad/ad_item.h b/engines/wintermute/ad/ad_item.h index 79978f9f72..b8351448a7 100644 --- a/engines/wintermute/ad/ad_item.h +++ b/engines/wintermute/ad/ad_item.h @@ -51,15 +51,15 @@ public: bool loadBuffer(byte *buffer, bool complete = true); // scripting interface - virtual ScValue *scGetProperty(const Common::String &name); - virtual bool scSetProperty(const char *name, ScValue *value); - virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); - virtual const char *scToString(); + virtual ScValue *scGetProperty(const Common::String &name) override; + virtual bool scSetProperty(const char *name, ScValue *value) override; + virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) override; + virtual const char *scToString() override; private: bool _displayAmount; - int _amount; - int _amountOffsetX; - int _amountOffsetY; + int32 _amount; + int32 _amountOffsetX; + int32 _amountOffsetY; TTextAlign _amountAlign; char *_amountString; }; diff --git a/engines/wintermute/ad/ad_layer.cpp b/engines/wintermute/ad/ad_layer.cpp index 209c12b7a2..7bf79e4ae5 100644 --- a/engines/wintermute/ad/ad_layer.cpp +++ b/engines/wintermute/ad/ad_layer.cpp @@ -63,7 +63,7 @@ AdLayer::~AdLayer() { ////////////////////////////////////////////////////////////////////////// bool AdLayer::loadFile(const char *filename) { byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); - if (buffer == NULL) { + if (buffer == nullptr) { _gameRef->LOG(0, "AdLayer::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -174,8 +174,8 @@ bool AdLayer::loadBuffer(byte *buffer, bool complete) { cmd = PARSERR_GENERIC; delete region; delete node; - region = NULL; - node = NULL; + region = nullptr; + node = nullptr; } else { node->setRegion(region); _nodes.add(node); @@ -193,8 +193,8 @@ bool AdLayer::loadBuffer(byte *buffer, bool complete) { cmd = PARSERR_GENERIC; delete entity; delete node; - entity = NULL; - node = NULL; + entity = nullptr; + node = nullptr; } else { node->setEntity(entity); _nodes.add(node); @@ -339,7 +339,7 @@ bool AdLayer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, stack->correctParams(1); ScValue *val = stack->pop(); - AdSceneNode *toDelete = NULL; + AdSceneNode *toDelete = nullptr; if (val->isNative()) { BaseScriptable *temp = val->getNative(); for (uint32 i = 0; i < _nodes.size(); i++) { @@ -354,7 +354,7 @@ bool AdLayer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, toDelete = _nodes[index]; } } - if (toDelete == NULL) { + if (toDelete == nullptr) { stack->pushBool(false); return STATUS_OK; } @@ -362,7 +362,7 @@ bool AdLayer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, for (uint32 i = 0; i < _nodes.size(); i++) { if (_nodes[i] == toDelete) { delete _nodes[i]; - _nodes[i] = NULL; + _nodes[i] = nullptr; _nodes.remove_at(i); break; } diff --git a/engines/wintermute/ad/ad_layer.h b/engines/wintermute/ad/ad_layer.h index de65e2822f..8fe4d4f91e 100644 --- a/engines/wintermute/ad/ad_layer.h +++ b/engines/wintermute/ad/ad_layer.h @@ -36,21 +36,21 @@ public: bool _closeUp; DECLARE_PERSISTENT(AdLayer, BaseObject) bool _active; - int _height; - int _width; + int32 _height; + int32 _width; bool _main; AdLayer(BaseGame *inGame); virtual ~AdLayer(); BaseArray<AdSceneNode *> _nodes; bool loadFile(const char *filename); bool loadBuffer(byte *buffer, bool complete = true); - virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); + virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent) override; // scripting interface - virtual ScValue *scGetProperty(const Common::String &name); - virtual bool scSetProperty(const char *name, ScValue *value); - virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); - virtual const char *scToString(); + virtual ScValue *scGetProperty(const Common::String &name) override; + virtual bool scSetProperty(const char *name, ScValue *value) override; + virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) override; + virtual const char *scToString() override; }; } // end of namespace Wintermute diff --git a/engines/wintermute/ad/ad_node_state.cpp b/engines/wintermute/ad/ad_node_state.cpp index 493156c750..d52201a08d 100644 --- a/engines/wintermute/ad/ad_node_state.cpp +++ b/engines/wintermute/ad/ad_node_state.cpp @@ -29,7 +29,6 @@ #include "engines/wintermute/base/base_game.h" #include "engines/wintermute/ad/ad_node_state.h" #include "engines/wintermute/ad/ad_entity.h" -#include "engines/wintermute/base/base_string_table.h" #include "engines/wintermute/base/base_sprite.h" #include "engines/wintermute/utils/utils.h" #include "engines/wintermute/platform_osystem.h" @@ -42,14 +41,14 @@ IMPLEMENT_PERSISTENT(AdNodeState, false) ////////////////////////////////////////////////////////////////////////// AdNodeState::AdNodeState(BaseGame *inGame) : BaseClass(inGame) { - _name = NULL; + _name = nullptr; _active = false; for (int i = 0; i < 7; i++) { - _caption[i] = NULL; + _caption[i] = nullptr; } _alphaColor = 0; - _filename = NULL; - _cursor = NULL; + _filename = nullptr; + _cursor = nullptr; } @@ -58,12 +57,12 @@ AdNodeState::~AdNodeState() { delete[] _name; delete[] _filename; delete[] _cursor; - _name = NULL; - _filename = NULL; - _cursor = NULL; + _name = nullptr; + _filename = nullptr; + _cursor = nullptr; for (int i = 0; i < 7; i++) { delete[] _caption[i]; - _caption[i] = NULL; + _caption[i] = nullptr; } } @@ -71,7 +70,7 @@ AdNodeState::~AdNodeState() { ////////////////////////////////////////////////////////////////////////// void AdNodeState::setName(const char *name) { delete[] _name; - _name = NULL; + _name = nullptr; BaseUtils::setString(&_name, name); } @@ -79,7 +78,7 @@ void AdNodeState::setName(const char *name) { ////////////////////////////////////////////////////////////////////////// void AdNodeState::setFilename(const char *filename) { delete[] _filename; - _filename = NULL; + _filename = nullptr; BaseUtils::setString(&_filename, filename); } @@ -87,14 +86,14 @@ void AdNodeState::setFilename(const char *filename) { ////////////////////////////////////////////////////////////////////////// void AdNodeState::setCursor(const char *filename) { delete[] _cursor; - _cursor = NULL; + _cursor = nullptr; BaseUtils::setString(&_cursor, filename); } ////////////////////////////////////////////////////////////////////////// bool AdNodeState::persist(BasePersistenceManager *persistMgr) { - persistMgr->transfer(TMEMBER(_gameRef)); + persistMgr->transferPtr(TMEMBER_PTR(_gameRef)); persistMgr->transfer(TMEMBER(_active)); persistMgr->transfer(TMEMBER(_name)); @@ -122,7 +121,7 @@ void AdNodeState::setCaption(const char *caption, int caseVal) { _caption[caseVal - 1] = new char[strlen(caption) + 1]; if (_caption[caseVal - 1]) { strcpy(_caption[caseVal - 1], caption); - _gameRef->_stringTable->expand(&_caption[caseVal - 1]); + _gameRef->expandStringByStringTable(&_caption[caseVal - 1]); } } @@ -132,7 +131,7 @@ const char *AdNodeState::getCaption(int caseVal) { if (caseVal == 0) { caseVal = 1; } - if (caseVal < 1 || caseVal > 7 || _caption[caseVal - 1] == NULL) { + if (caseVal < 1 || caseVal > 7 || _caption[caseVal - 1] == nullptr) { return ""; } else { return _caption[caseVal - 1]; diff --git a/engines/wintermute/ad/ad_object.cpp b/engines/wintermute/ad/ad_object.cpp index 7b91daab2e..741d6e6fc6 100644 --- a/engines/wintermute/ad/ad_object.cpp +++ b/engines/wintermute/ad/ad_object.cpp @@ -38,7 +38,6 @@ #include "engines/wintermute/base/base_game.h" #include "engines/wintermute/base/base_frame.h" #include "engines/wintermute/base/base_sprite.h" -#include "engines/wintermute/base/base_string_table.h" #include "engines/wintermute/base/base_sub_frame.h" #include "engines/wintermute/base/base_surface_storage.h" #include "engines/wintermute/base/font/base_font.h" @@ -65,27 +64,27 @@ AdObject::AdObject(BaseGame *inGame) : BaseObject(inGame) { _active = true; _drawn = false; - _currentSprite = NULL; - _animSprite = NULL; - _tempSprite2 = NULL; + _currentSprite = nullptr; + _animSprite = nullptr; + _tempSprite2 = nullptr; - _font = NULL; + _font = nullptr; - _sentence = NULL; + _sentence = nullptr; - _forcedTalkAnimName = NULL; + _forcedTalkAnimName = nullptr; _forcedTalkAnimUsed = false; - _blockRegion = NULL; - _wptGroup = NULL; + _blockRegion = nullptr; + _wptGroup = nullptr; - _currentBlockRegion = NULL; - _currentWptGroup = NULL; + _currentBlockRegion = nullptr; + _currentWptGroup = nullptr; _ignoreItems = false; _sceneIndependent = false; - _stickRegion = NULL; + _stickRegion = nullptr; _subtitlesModRelative = true; _subtitlesModX = 0; @@ -93,13 +92,13 @@ AdObject::AdObject(BaseGame *inGame) : BaseObject(inGame) { _subtitlesWidth = 0; _subtitlesModXCenter = true; - _inventory = NULL; + _inventory = nullptr; for (int i = 0; i < MAX_NUM_REGIONS; i++) { - _currentRegions[i] = NULL; + _currentRegions[i] = nullptr; } - _partEmitter = NULL; + _partEmitter = nullptr; _partFollowParent = false; _partOffsetX = _partOffsetY = 0; @@ -109,26 +108,26 @@ AdObject::AdObject(BaseGame *inGame) : BaseObject(inGame) { ////////////////////////////////////////////////////////////////////////// AdObject::~AdObject() { - _currentSprite = NULL; // reference only, don't delete + _currentSprite = nullptr; // reference only, don't delete delete _animSprite; - _animSprite = NULL; + _animSprite = nullptr; delete _sentence; - _sentence = NULL; + _sentence = nullptr; delete[] _forcedTalkAnimName; - _forcedTalkAnimName = NULL; + _forcedTalkAnimName = nullptr; delete _blockRegion; - _blockRegion = NULL; + _blockRegion = nullptr; delete _wptGroup; - _wptGroup = NULL; + _wptGroup = nullptr; delete _currentBlockRegion; - _currentBlockRegion = NULL; + _currentBlockRegion = nullptr; delete _currentWptGroup; - _currentWptGroup = NULL; + _currentWptGroup = nullptr; - _tempSprite2 = NULL; // reference only - _stickRegion = NULL; + _tempSprite2 = nullptr; // reference only + _stickRegion = nullptr; if (_font) { _gameRef->_fontStorage->removeFont(_font); @@ -136,7 +135,7 @@ AdObject::~AdObject() { if (_inventory) { ((AdGame *)_gameRef)->unregisterInventory(_inventory); - _inventory = NULL; + _inventory = nullptr; } if (_partEmitter) { @@ -159,7 +158,7 @@ AdObject::~AdObject() { ////////////////////////////////////////////////////////////////////////// bool AdObject::playAnim(const char *filename) { delete _animSprite; - _animSprite = NULL; + _animSprite = nullptr; _animSprite = new BaseSprite(_gameRef, this); if (!_animSprite) { _gameRef->LOG(0, "AdObject::PlayAnim: error creating temp sprite (object:\"%s\" sprite:\"%s\")", getName(), filename); @@ -169,7 +168,7 @@ bool AdObject::playAnim(const char *filename) { if (DID_FAIL(res)) { _gameRef->LOG(res, "AdObject::PlayAnim: error loading temp sprite (object:\"%s\" sprite:\"%s\")", getName(), filename); delete _animSprite; - _animSprite = NULL; + _animSprite = nullptr; return res; } _state = STATE_PLAYING_ANIM; @@ -274,7 +273,7 @@ bool AdObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack int duration = stack->pop()->getInt(); ScValue *valStances = stack->pop(); - const char *stances = valStances->isNULL() ? NULL : valStances->getString(); + const char *stances = valStances->isNULL() ? nullptr : valStances->getString(); int align = 0; ScValue *val = stack->pop(); @@ -286,7 +285,7 @@ bool AdObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack align = MIN(MAX(0, align), NUM_TEXT_ALIGN - 1); - const char *sound = soundVal->isNULL() ? NULL : soundVal->getString(); + const char *sound = soundVal->isNULL() ? nullptr : soundVal->getString(); talk(text, sound, duration, stances, (TTextAlign)align); if (strcmp(name, "TalkAsync") != 0) { @@ -309,7 +308,7 @@ bool AdObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack uint32 i; ScValue *val = stack->pop(); if (val->isNULL() || !main) { - _stickRegion = NULL; + _stickRegion = nullptr; regFound = true; } else if (val->isString()) { const char *regionName = val->getString(); @@ -334,7 +333,7 @@ bool AdObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack } if (!regFound) { - _stickRegion = NULL; + _stickRegion = nullptr; } stack->pushBool(regFound); return STATUS_OK; @@ -348,7 +347,7 @@ bool AdObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ScValue *val = stack->pop(); if (val->isNULL()) { - setFont(NULL); + setFont(nullptr); } else { setFont(val->getString()); } @@ -385,7 +384,7 @@ bool AdObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack if (!val->isNULL()) { const char *itemName = val->getString(); val = stack->pop(); - const char *insertAfter = val->isNULL() ? NULL : val->getString(); + const char *insertAfter = val->isNULL() ? nullptr : val->getString(); if (DID_FAIL(_inventory->insertItem(itemName, insertAfter))) { script->runtimeError("Cannot add item '%s' to inventory", itemName); } else { @@ -512,7 +511,7 @@ bool AdObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack stack->correctParams(0); if (_partEmitter) { _gameRef->unregisterObject(_partEmitter); - _partEmitter = NULL; + _partEmitter = nullptr; } stack->pushNULL(); @@ -533,7 +532,7 @@ bool AdObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack AdEntity *ent = new AdEntity(_gameRef); if (DID_FAIL(res = ent->loadFile(filename))) { delete ent; - ent = NULL; + ent = nullptr; script->runtimeError("AddAttachment() failed loading entity '%s'", filename); stack->pushBool(false); } else { @@ -611,7 +610,7 @@ bool AdObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack stack->correctParams(1); ScValue *val = stack->pop(); - AdObject *ret = NULL; + AdObject *ret = nullptr; if (val->isInt()) { int index = val->getInt(); int currIndex = 0; @@ -645,7 +644,7 @@ bool AdObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack } } - if (ret != NULL) { + if (ret != nullptr) { stack->pushNative(ret, true); } else { stack->pushNULL(); @@ -851,9 +850,9 @@ bool AdObject::setFont(const char *filename) { } if (filename) { _font = _gameRef->_fontStorage->addFont(filename); - return _font == NULL ? STATUS_FAILED : STATUS_OK; + return _font == nullptr ? STATUS_FAILED : STATUS_OK; } else { - _font = NULL; + _font = nullptr; return STATUS_OK; } } @@ -865,19 +864,22 @@ int AdObject::getHeight() { return 0; } else { BaseFrame *frame = _currentSprite->_frames[_currentSprite->_currentFrame]; - int ret = 0; + int32 ret = 0; for (uint32 i = 0; i < frame->_subframes.size(); i++) { ret = MAX(ret, frame->_subframes[i]->_hotspotY); } if (_zoomable) { float zoom = ((AdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY); - ret = (int)(ret * zoom / 100); + ret = (int32)(ret * zoom / 100); } return ret; } } +TObjectType AdObject::getType() const { + return _type; +} ////////////////////////////////////////////////////////////////////////// void AdObject::talk(const char *text, const char *sound, uint32 duration, const char *stances, TTextAlign Align) { @@ -890,27 +892,27 @@ void AdObject::talk(const char *text, const char *sound, uint32 duration, const if (_forcedTalkAnimName && _forcedTalkAnimUsed) { delete[] _forcedTalkAnimName; - _forcedTalkAnimName = NULL; + _forcedTalkAnimName = nullptr; _forcedTalkAnimUsed = false; } delete(_sentence->_sound); - _sentence->_sound = NULL; + _sentence->_sound = nullptr; _sentence->setText(text); - _gameRef->_stringTable->expand(&_sentence->_text); + _gameRef->expandStringByStringTable(&_sentence->_text); _sentence->setStances(stances); _sentence->_duration = duration; _sentence->_align = Align; - _sentence->_startTime = _gameRef->_timer; + _sentence->_startTime = _gameRef->getTimer()->getTime(); _sentence->_currentStance = -1; - _sentence->_font = _font == NULL ? _gameRef->_systemFont : _font; + _sentence->_font = _font == nullptr ? _gameRef->getSystemFont() : _font; _sentence->_freezable = _freezable; // try to locate speech file automatically bool deleteSound = false; if (!sound) { - char *key = _gameRef->_stringTable->getKey(text); + char *key = _gameRef->getKeyFromStringTable(text); if (key) { sound = ((AdGame *)_gameRef)->findSpeechFile(key); delete[] key; @@ -939,11 +941,11 @@ void AdObject::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, _gameRef->_subtitlesSpeed * strlen(_sentence->_text)); + _sentence->_duration = MAX<int32>((size_t)1000, _gameRef->_subtitlesSpeed * strlen(_sentence->_text)); } - int x, y, width, height; + int32 x, y, width, height; x = _posX; y = _posY; @@ -957,10 +959,10 @@ void AdObject::talk(const char *text, const char *sound, uint32 duration, const if (_subtitlesWidth > 0) { width = _subtitlesWidth; } else { - 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)); + if ((x < _gameRef->_renderer->getWidth() / 4 || x > _gameRef->_renderer->getWidth() * 0.75) && !_gameRef->_touchInterface) { + width = MAX(_gameRef->_renderer->getWidth() / 4, MIN(x * 2, (_gameRef->_renderer->getWidth() - x) * 2)); } else { - width = _gameRef->_renderer->_width / 2; + width = _gameRef->_renderer->getWidth() / 2; } } @@ -979,8 +981,8 @@ void AdObject::talk(const char *text, const char *sound, uint32 duration, const } - x = MIN(MAX(0, x), _gameRef->_renderer->_width - width); - y = MIN(MAX(0, y), _gameRef->_renderer->_height - height); + x = MIN(MAX<int32>(0, x), _gameRef->_renderer->getWidth() - width); + y = MIN(MAX<int32>(0, y), _gameRef->_renderer->getHeight() - height); _sentence->_width = width; @@ -1009,9 +1011,9 @@ void AdObject::talk(const char *text, const char *sound, uint32 duration, const ////////////////////////////////////////////////////////////////////////// bool AdObject::reset() { - if (_state == STATE_PLAYING_ANIM && _animSprite != NULL) { + if (_state == STATE_PLAYING_ANIM && _animSprite != nullptr) { delete _animSprite; - _animSprite = NULL; + _animSprite = nullptr; } else if (_state == STATE_TALKING && _sentence) { _sentence->finish(); } @@ -1029,39 +1031,39 @@ bool AdObject::persist(BasePersistenceManager *persistMgr) { BaseObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_active)); - persistMgr->transfer(TMEMBER(_blockRegion)); - persistMgr->transfer(TMEMBER(_currentBlockRegion)); - persistMgr->transfer(TMEMBER(_currentWptGroup)); - persistMgr->transfer(TMEMBER(_currentSprite)); + persistMgr->transferPtr(TMEMBER_PTR(_blockRegion)); + persistMgr->transferPtr(TMEMBER_PTR(_currentBlockRegion)); + persistMgr->transferPtr(TMEMBER_PTR(_currentWptGroup)); + persistMgr->transferPtr(TMEMBER_PTR(_currentSprite)); persistMgr->transfer(TMEMBER(_drawn)); - persistMgr->transfer(TMEMBER(_font)); + persistMgr->transferPtr(TMEMBER_PTR(_font)); persistMgr->transfer(TMEMBER(_ignoreItems)); persistMgr->transfer(TMEMBER_INT(_nextState)); - persistMgr->transfer(TMEMBER(_sentence)); + persistMgr->transferPtr(TMEMBER_PTR(_sentence)); persistMgr->transfer(TMEMBER_INT(_state)); - persistMgr->transfer(TMEMBER(_animSprite)); + persistMgr->transferPtr(TMEMBER_PTR(_animSprite)); persistMgr->transfer(TMEMBER(_sceneIndependent)); persistMgr->transfer(TMEMBER(_forcedTalkAnimName)); persistMgr->transfer(TMEMBER(_forcedTalkAnimUsed)); - persistMgr->transfer(TMEMBER(_tempSprite2)); + persistMgr->transferPtr(TMEMBER_PTR(_tempSprite2)); persistMgr->transfer(TMEMBER_INT(_type)); - persistMgr->transfer(TMEMBER(_wptGroup)); - persistMgr->transfer(TMEMBER(_stickRegion)); + persistMgr->transferPtr(TMEMBER_PTR(_wptGroup)); + persistMgr->transferPtr(TMEMBER_PTR(_stickRegion)); persistMgr->transfer(TMEMBER(_subtitlesModRelative)); persistMgr->transfer(TMEMBER(_subtitlesModX)); persistMgr->transfer(TMEMBER(_subtitlesModY)); persistMgr->transfer(TMEMBER(_subtitlesModXCenter)); persistMgr->transfer(TMEMBER(_subtitlesWidth)); - persistMgr->transfer(TMEMBER(_inventory)); - persistMgr->transfer(TMEMBER(_partEmitter)); + persistMgr->transferPtr(TMEMBER_PTR(_inventory)); + persistMgr->transferPtr(TMEMBER_PTR(_partEmitter)); for (int i = 0; i < MAX_NUM_REGIONS; i++) { - persistMgr->transfer(TMEMBER(_currentRegions[i])); + persistMgr->transferPtr(TMEMBER_PTR(_currentRegions[i])); } _attachmentsPre.persist(persistMgr); _attachmentsPost.persist(persistMgr); - persistMgr->transfer(TMEMBER(_registerAlias)); + persistMgr->transferPtr(TMEMBER_PTR(_registerAlias)); persistMgr->transfer(TMEMBER(_partFollowParent)); persistMgr->transfer(TMEMBER(_partOffsetX)); @@ -1154,7 +1156,7 @@ bool AdObject::afterMove() { bool regFound = false; for (int j = 0; j < MAX_NUM_REGIONS; j++) { if (_currentRegions[j] == newRegions[i]) { - _currentRegions[j] = NULL; + _currentRegions[j] = nullptr; regFound = true; break; } @@ -1177,7 +1179,7 @@ bool AdObject::afterMove() { ////////////////////////////////////////////////////////////////////////// bool AdObject::invalidateCurrRegions() { for (int i = 0; i < MAX_NUM_REGIONS; i++) { - _currentRegions[i] = NULL; + _currentRegions[i] = nullptr; } return STATUS_OK; } diff --git a/engines/wintermute/ad/ad_object.h b/engines/wintermute/ad/ad_object.h index d1a20908e1..c6573315da 100644 --- a/engines/wintermute/ad/ad_object.h +++ b/engines/wintermute/ad/ad_object.h @@ -46,77 +46,81 @@ class PartEmitter; class AdObject : public BaseObject { public: - PartEmitter *_partEmitter; virtual PartEmitter *createParticleEmitter(bool followParent = false, int offsetX = 0, int offsetY = 0); virtual bool updatePartEmitter(); - bool _partFollowParent; - int _partOffsetX; - int _partOffsetY; bool invalidateCurrRegions(); - bool _subtitlesModRelative; - bool _subtitlesModXCenter; - int _subtitlesModX; - int _subtitlesModY; - int _subtitlesWidth; AdRegion *_stickRegion; bool _sceneIndependent; - bool _ignoreItems; + bool updateBlockRegion(); - bool _forcedTalkAnimUsed; - char *_forcedTalkAnimName; - virtual bool getExtendedFlag(const char *flagName); - virtual bool resetSoundPan(); - virtual bool updateSounds(); + + virtual bool getExtendedFlag(const char *flagName) override; + virtual bool resetSoundPan() override; + virtual bool updateSounds() override; bool reset(); DECLARE_PERSISTENT(AdObject, BaseObject) - virtual void talk(const char *text, const char *sound = NULL, uint32 duration = 0, const char *stances = NULL, TTextAlign align = TAL_CENTER); - virtual int getHeight(); - AdSentence *_sentence; + virtual void talk(const char *text, const char *sound = nullptr, uint32 duration = 0, const char *stances = nullptr, TTextAlign align = TAL_CENTER); + virtual int getHeight() override; + bool setFont(const char *filename); - virtual bool update(); - virtual bool display(); + virtual bool update() override; + virtual bool display() override; + bool _drawn; bool _active; virtual bool playAnim(const char *filename); - BaseSprite *_animSprite; - BaseSprite *_currentSprite; - TObjectState _state; - TObjectState _nextState; - TObjectType _type; + + TObjectType getType() const; AdObject(BaseGame *inGame); virtual ~AdObject(); - BaseFont *_font; - BaseSprite *_tempSprite2; - BaseRegion *_blockRegion; - AdWaypointGroup *_wptGroup; + BaseRegion *_currentBlockRegion; AdWaypointGroup *_currentWptGroup; AdInventory *getInventory(); - virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); - - virtual bool afterMove(); - AdRegion *_currentRegions[MAX_NUM_REGIONS]; + virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent) override; + virtual bool afterMove() override; // scripting interface - virtual ScValue *scGetProperty(const Common::String &name); - virtual bool scSetProperty(const char *name, ScValue *value); - virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); - virtual const char *scToString(); - - BaseArray<AdObject *> _attachmentsPre; - BaseArray<AdObject *> _attachmentsPost; - + virtual ScValue *scGetProperty(const Common::String &name) override; + virtual bool scSetProperty(const char *name, ScValue *value) override; + virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) override; + virtual const char *scToString() override; bool updateSpriteAttachments(); bool displaySpriteAttachments(bool preDisplay); + +protected: + PartEmitter *_partEmitter; + bool _ignoreItems; + bool _forcedTalkAnimUsed; + char *_forcedTalkAnimName; + BaseSprite *_animSprite; + BaseSprite *_currentSprite; + AdSentence *_sentence; + TObjectState _state; + TObjectState _nextState; + TObjectType _type; + BaseFont *_font; + BaseSprite *_tempSprite2; + BaseRegion *_blockRegion; + AdWaypointGroup *_wptGroup; AdObject *_registerAlias; + bool getScale(float *scaleX, float *scaleY); private: + bool _partFollowParent; + int32 _partOffsetX; + int32 _partOffsetY; + bool _subtitlesModRelative; + bool _subtitlesModXCenter; + int32 _subtitlesModX; + int32 _subtitlesModY; + int32 _subtitlesWidth; + AdRegion *_currentRegions[MAX_NUM_REGIONS]; + BaseArray<AdObject *> _attachmentsPre; + BaseArray<AdObject *> _attachmentsPost; bool displaySpriteAttachment(AdObject *attachment); AdInventory *_inventory; - -protected: - bool getScale(float *scaleX, float *scaleY); }; } // end of namespace Wintermute diff --git a/engines/wintermute/ad/ad_path.cpp b/engines/wintermute/ad/ad_path.cpp index c931213456..5b36ed6471 100644 --- a/engines/wintermute/ad/ad_path.cpp +++ b/engines/wintermute/ad/ad_path.cpp @@ -64,7 +64,7 @@ BasePoint *AdPath::getFirst() { _currIndex = 0; return _points[_currIndex]; } else { - return NULL; + return nullptr; } } @@ -75,7 +75,7 @@ BasePoint *AdPath::getNext() { if (_currIndex < (int32)_points.size()) { return _points[_currIndex]; } else { - return NULL; + return nullptr; } } @@ -85,7 +85,7 @@ BasePoint *AdPath::getCurrent() { if (_currIndex >= 0 && _currIndex < (int32)_points.size()) { return _points[_currIndex]; } else { - return NULL; + return nullptr; } } @@ -108,7 +108,7 @@ bool AdPath::setReady(bool ready) { ////////////////////////////////////////////////////////////////////////// bool AdPath::persist(BasePersistenceManager *persistMgr) { - persistMgr->transfer(TMEMBER(_gameRef)); + persistMgr->transferPtr(TMEMBER_PTR(_gameRef)); persistMgr->transfer(TMEMBER(_currIndex)); _points.persist(persistMgr); diff --git a/engines/wintermute/ad/ad_path.h b/engines/wintermute/ad/ad_path.h index 6b043197aa..3f38355b94 100644 --- a/engines/wintermute/ad/ad_path.h +++ b/engines/wintermute/ad/ad_path.h @@ -47,7 +47,7 @@ public: AdPath(BaseGame *inGame); virtual ~AdPath(); BaseArray<BasePoint *> _points; - int _currIndex; + int32 _currIndex; bool _ready; }; diff --git a/engines/wintermute/ad/ad_path_point.cpp b/engines/wintermute/ad/ad_path_point.cpp index a36648eb69..be4b487466 100644 --- a/engines/wintermute/ad/ad_path_point.cpp +++ b/engines/wintermute/ad/ad_path_point.cpp @@ -39,7 +39,7 @@ AdPathPoint::AdPathPoint() { _distance = 0; _marked = false; - _origin = NULL; + _origin = nullptr; } @@ -50,13 +50,13 @@ AdPathPoint::AdPathPoint(int initX, int initY, int initDistance) { _distance = initDistance; _marked = false; - _origin = NULL; + _origin = nullptr; } ////////////////////////////////////////////////////////////////////////// AdPathPoint::~AdPathPoint() { - _origin = NULL; + _origin = nullptr; } @@ -67,7 +67,7 @@ bool AdPathPoint::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_distance)); persistMgr->transfer(TMEMBER(_marked)); - persistMgr->transfer(TMEMBER(_origin)); + persistMgr->transferPtr(TMEMBER_PTR(_origin)); return STATUS_OK; } diff --git a/engines/wintermute/ad/ad_path_point.h b/engines/wintermute/ad/ad_path_point.h index 58457976c8..04648b1733 100644 --- a/engines/wintermute/ad/ad_path_point.h +++ b/engines/wintermute/ad/ad_path_point.h @@ -42,7 +42,7 @@ public: virtual ~AdPathPoint(); AdPathPoint *_origin; bool _marked; - int _distance; + int32 _distance; }; } // end of namespace Wintermute diff --git a/engines/wintermute/ad/ad_region.cpp b/engines/wintermute/ad/ad_region.cpp index c9f1553c9a..acd5f13397 100644 --- a/engines/wintermute/ad/ad_region.cpp +++ b/engines/wintermute/ad/ad_region.cpp @@ -51,11 +51,26 @@ AdRegion::AdRegion(BaseGame *inGame) : BaseRegion(inGame) { AdRegion::~AdRegion() { } +uint32 AdRegion::getAlpha() const { + return _alpha; +} + +float AdRegion::getZoom() const { + return _zoom; +} + +bool AdRegion::isBlocked() const { + return _blocked; +} + +bool AdRegion::hasDecoration() const { + return _decoration; +} ////////////////////////////////////////////////////////////////////////// bool AdRegion::loadFile(const char *filename) { byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); - if (buffer == NULL) { + if (buffer == nullptr) { _gameRef->LOG(0, "AdRegion::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } diff --git a/engines/wintermute/ad/ad_region.h b/engines/wintermute/ad/ad_region.h index 6112900361..bc9eab085e 100644 --- a/engines/wintermute/ad/ad_region.h +++ b/engines/wintermute/ad/ad_region.h @@ -36,21 +36,27 @@ namespace Wintermute { class AdRegion : public BaseRegion { public: DECLARE_PERSISTENT(AdRegion, BaseRegion) - uint32 _alpha; - float _zoom; - bool _blocked; - bool _decoration; + AdRegion(BaseGame *inGame); virtual ~AdRegion(); bool loadFile(const char *filename); bool loadBuffer(byte *buffer, bool complete = true); - virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); + virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent) override; + bool hasDecoration() const; + bool isBlocked() const; + uint32 getAlpha() const; + float getZoom() const; // scripting interface - virtual ScValue *scGetProperty(const Common::String &name); - virtual bool scSetProperty(const char *name, ScValue *value); - virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); - virtual const char *scToString(); + virtual ScValue *scGetProperty(const Common::String &name) override; + virtual bool scSetProperty(const char *name, ScValue *value) override; + virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) override; + virtual const char *scToString() override; +private: + uint32 _alpha; + float _zoom; + bool _blocked; + bool _decoration; }; } // end of namespace Wintermute diff --git a/engines/wintermute/ad/ad_response.cpp b/engines/wintermute/ad/ad_response.cpp index a2225f2632..4483bbc667 100644 --- a/engines/wintermute/ad/ad_response.cpp +++ b/engines/wintermute/ad/ad_response.cpp @@ -38,10 +38,10 @@ IMPLEMENT_PERSISTENT(AdResponse, false) ////////////////////////////////////////////////////////////////////////// AdResponse::AdResponse(BaseGame *inGame) : BaseObject(inGame) { - _text = NULL; - _textOrig = NULL; - _icon = _iconHover = _iconPressed = NULL; - _font = NULL; + _text = nullptr; + _textOrig = nullptr; + _icon = _iconHover = _iconPressed = nullptr; + _font = nullptr; _iD = 0; _responseType = RESPONSE_ALWAYS; } @@ -54,11 +54,11 @@ AdResponse::~AdResponse() { delete _icon; delete _iconHover; delete _iconPressed; - _text = NULL; - _textOrig = NULL; - _icon = NULL; - _iconHover = NULL; - _iconPressed = NULL; + _text = nullptr; + _textOrig = nullptr; + _icon = nullptr; + _iconHover = nullptr; + _iconPressed = nullptr; if (_font) { _gameRef->_fontStorage->removeFont(_font); } @@ -79,7 +79,7 @@ bool AdResponse::setIcon(const char *filename) { if (!_icon || DID_FAIL(_icon->loadFile(filename))) { _gameRef->LOG(0, "AdResponse::setIcon failed for file '%s'", filename); delete _icon; - _icon = NULL; + _icon = nullptr; return STATUS_FAILED; } return STATUS_OK; @@ -105,7 +105,7 @@ bool AdResponse::setIconHover(const char *filename) { if (!_iconHover || DID_FAIL(_iconHover->loadFile(filename))) { _gameRef->LOG(0, "AdResponse::setIconHover failed for file '%s'", filename); delete _iconHover; - _iconHover = NULL; + _iconHover = nullptr; return STATUS_FAILED; } return STATUS_OK; @@ -119,7 +119,7 @@ bool AdResponse::setIconPressed(const char *filename) { if (!_iconPressed || DID_FAIL(_iconPressed->loadFile(filename))) { _gameRef->LOG(0, "AdResponse::setIconPressed failed for file '%s'", filename); delete _iconPressed; - _iconPressed = NULL; + _iconPressed = nullptr; return STATUS_FAILED; } return STATUS_OK; @@ -131,16 +131,48 @@ bool AdResponse::persist(BasePersistenceManager *persistMgr) { BaseObject::persist(persistMgr); - persistMgr->transfer(TMEMBER(_icon)); - persistMgr->transfer(TMEMBER(_iconHover)); - persistMgr->transfer(TMEMBER(_iconPressed)); + persistMgr->transferPtr(TMEMBER_PTR(_icon)); + persistMgr->transferPtr(TMEMBER_PTR(_iconHover)); + persistMgr->transferPtr(TMEMBER_PTR(_iconPressed)); persistMgr->transfer(TMEMBER(_iD)); persistMgr->transfer(TMEMBER(_text)); persistMgr->transfer(TMEMBER(_textOrig)); persistMgr->transfer(TMEMBER_INT(_responseType)); - persistMgr->transfer(TMEMBER(_font)); + persistMgr->transferPtr(TMEMBER_PTR(_font)); return STATUS_OK; } +void AdResponse::setID(int32 id) { + _iD = id; +} + +BaseSprite *AdResponse::getIcon() const { + return _icon; +} + +BaseSprite *AdResponse::getIconHover() const { + return _iconHover; +} + +BaseSprite *AdResponse::getIconPressed() const { + return _iconPressed; +} + +BaseFont *AdResponse::getFont() const { + return _font; +} + +int32 AdResponse::getID() const { + return _iD; +} + +const char *AdResponse::getText() const { + return _text; +} + +const char *AdResponse::getTextOrig() const { + return _textOrig; +} + } // end of namespace Wintermute diff --git a/engines/wintermute/ad/ad_response.h b/engines/wintermute/ad/ad_response.h index 0ba88cf2e8..57cd302e9d 100644 --- a/engines/wintermute/ad/ad_response.h +++ b/engines/wintermute/ad/ad_response.h @@ -43,17 +43,29 @@ public: bool setIconHover(const char *filename); bool setIconPressed(const char *filename); void setText(const char *text); - int _iD; + void setID(int32 id); + BaseSprite *getIcon() const; + BaseSprite *getIconHover() const; + BaseSprite *getIconPressed() const; + BaseFont *getFont() const; + int32 getID() const; + + const char *getText() const; + const char *getTextOrig() const; + + AdResponse(BaseGame *inGame); + virtual ~AdResponse(); + TResponseType _responseType; +private: BaseSprite *_icon; BaseSprite *_iconHover; BaseSprite *_iconPressed; BaseFont *_font; + + int32 _iD; + char *_text; char *_textOrig; - AdResponse(BaseGame *inGame); - virtual ~AdResponse(); - TResponseType _responseType; - }; } // end of namespace Wintermute diff --git a/engines/wintermute/ad/ad_response_box.cpp b/engines/wintermute/ad/ad_response_box.cpp index fb31aa0bb8..a589bf3a30 100644 --- a/engines/wintermute/ad/ad_response_box.cpp +++ b/engines/wintermute/ad/ad_response_box.cpp @@ -52,9 +52,9 @@ IMPLEMENT_PERSISTENT(AdResponseBox, false) ////////////////////////////////////////////////////////////////////////// AdResponseBox::AdResponseBox(BaseGame *inGame) : BaseObject(inGame) { - _font = _fontHover = NULL; + _font = _fontHover = nullptr; - _window = NULL; + _window = nullptr; _shieldWindow = new UIWindow(_gameRef); _horizontal = false; @@ -62,9 +62,9 @@ AdResponseBox::AdResponseBox(BaseGame *inGame) : BaseObject(inGame) { _scrollOffset = 0; _spacing = 0; - _waitingScript = NULL; - _lastResponseText = NULL; - _lastResponseTextOrig = NULL; + _waitingScript = nullptr; + _lastResponseText = nullptr; + _lastResponseTextOrig = nullptr; _verticalAlign = VAL_BOTTOM; _align = TAL_LEFT; @@ -75,13 +75,13 @@ AdResponseBox::AdResponseBox(BaseGame *inGame) : BaseObject(inGame) { AdResponseBox::~AdResponseBox() { delete _window; - _window = NULL; + _window = nullptr; delete _shieldWindow; - _shieldWindow = NULL; + _shieldWindow = nullptr; delete[] _lastResponseText; - _lastResponseText = NULL; + _lastResponseText = nullptr; delete[] _lastResponseTextOrig; - _lastResponseTextOrig = NULL; + _lastResponseTextOrig = nullptr; if (_font) { _gameRef->_fontStorage->removeFont(_font); @@ -93,9 +93,12 @@ AdResponseBox::~AdResponseBox() { clearResponses(); clearButtons(); - _waitingScript = NULL; + _waitingScript = nullptr; } +uint32 AdResponseBox::getNumResponses() const { + return _responses.size(); +} ////////////////////////////////////////////////////////////////////////// void AdResponseBox::clearResponses() { @@ -118,11 +121,11 @@ void AdResponseBox::clearButtons() { ////////////////////////////////////////////////////////////////////////// bool AdResponseBox::invalidateButtons() { for (uint32 i = 0; i < _respButtons.size(); i++) { - _respButtons[i]->_image = NULL; - _respButtons[i]->_cursor = NULL; - _respButtons[i]->_font = NULL; - _respButtons[i]->_fontHover = NULL; - _respButtons[i]->_fontPress = NULL; + _respButtons[i]->_image = nullptr; + _respButtons[i]->_cursor = nullptr; + _respButtons[i]->_font = nullptr; + _respButtons[i]->_fontHover = nullptr; + _respButtons[i]->_fontPress = nullptr; _respButtons[i]->setText(""); } return STATUS_OK; @@ -141,16 +144,16 @@ bool AdResponseBox::createButtons() { btn->_sharedFonts = btn->_sharedImages = true; btn->_sharedCursors = true; // iconic - if (_responses[i]->_icon) { - btn->_image = _responses[i]->_icon; - if (_responses[i]->_iconHover) { - btn->_imageHover = _responses[i]->_iconHover; + if (_responses[i]->getIcon()) { + btn->_image = _responses[i]->getIcon(); + if (_responses[i]->getIconHover()) { + btn->_imageHover = _responses[i]->getIconHover(); } - if (_responses[i]->_iconPressed) { - btn->_imagePress = _responses[i]->_iconPressed; + if (_responses[i]->getIconPressed()) { + btn->_imagePress = _responses[i]->getIconPressed(); } - btn->setCaption(_responses[i]->_text); + btn->setCaption(_responses[i]->getText()); if (_cursor) { btn->_cursor = _cursor; } else if (_gameRef->_activeCursor) { @@ -159,9 +162,9 @@ bool AdResponseBox::createButtons() { } // textual else { - btn->setText(_responses[i]->_text); - btn->_font = (_font == NULL) ? _gameRef->_systemFont : _font; - btn->_fontHover = (_fontHover == NULL) ? _gameRef->_systemFont : _fontHover; + btn->setText(_responses[i]->getText()); + btn->_font = (_font == nullptr) ? _gameRef->getSystemFont() : _font; + btn->_fontHover = (_fontHover == nullptr) ? _gameRef->getSystemFont() : _fontHover; btn->_fontPress = btn->_fontHover; btn->_align = _align; @@ -170,13 +173,13 @@ bool AdResponseBox::createButtons() { } - if (_responses[i]->_font) { - btn->_font = _responses[i]->_font; + if (_responses[i]->getFont()) { + btn->_font = _responses[i]->getFont(); } btn->_width = _responseArea.right - _responseArea.left; if (btn->_width <= 0) { - btn->_width = _gameRef->_renderer->_width; + btn->_width = _gameRef->_renderer->getWidth(); } } btn->setName("response"); @@ -184,7 +187,7 @@ bool AdResponseBox::createButtons() { // make the responses touchable if (_gameRef->_touchInterface) { - btn->_height = MAX(btn->_height, 50); + btn->_height = MAX<int32>(btn->_height, 50); } //btn->SetListener(this, btn, _responses[i]->_iD); @@ -193,7 +196,7 @@ bool AdResponseBox::createButtons() { _respButtons.add(btn); if (_responseArea.bottom - _responseArea.top < btn->_height) { - _gameRef->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]->getText()); _responseArea.bottom += (btn->_height - (_responseArea.bottom - _responseArea.top)); } } @@ -207,7 +210,7 @@ bool AdResponseBox::createButtons() { ////////////////////////////////////////////////////////////////////////// bool AdResponseBox::loadFile(const char *filename) { byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); - if (buffer == NULL) { + if (buffer == nullptr) { _gameRef->LOG(0, "AdResponseBox::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -284,7 +287,7 @@ bool AdResponseBox::loadBuffer(byte *buffer, bool complete) { _window = new UIWindow(_gameRef); if (!_window || DID_FAIL(_window->loadBuffer(params, false))) { delete _window; - _window = NULL; + _window = nullptr; cmd = PARSERR_GENERIC; } else if (_shieldWindow) { _shieldWindow->_parent = _window; @@ -352,7 +355,7 @@ bool AdResponseBox::loadBuffer(byte *buffer, bool complete) { _cursor = new BaseSprite(_gameRef); if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { delete _cursor; - _cursor = NULL; + _cursor = nullptr; cmd = PARSERR_GENERIC; } break; @@ -512,8 +515,8 @@ bool AdResponseBox::display() { // go exclusive if (_shieldWindow) { _shieldWindow->_posX = _shieldWindow->_posY = 0; - _shieldWindow->_width = _gameRef->_renderer->_width; - _shieldWindow->_height = _gameRef->_renderer->_height; + _shieldWindow->_width = _gameRef->_renderer->getWidth(); + _shieldWindow->_height = _gameRef->_renderer->getHeight(); _shieldWindow->display(); } @@ -545,10 +548,10 @@ bool AdResponseBox::listen(BaseScriptHolder *param1, uint32 param2) { _scrollOffset++; } else if (scumm_stricmp(obj->getName(), "response") == 0) { if (_waitingScript) { - _waitingScript->_stack->pushInt(_responses[param2]->_iD); + _waitingScript->_stack->pushInt(_responses[param2]->getID()); } handleResponse(_responses[param2]); - _waitingScript = NULL; + _waitingScript = nullptr; _gameRef->_state = GAME_RUNNING; ((AdGame *)_gameRef)->_stateEx = GAME_NORMAL; _ready = true; @@ -570,8 +573,8 @@ bool AdResponseBox::listen(BaseScriptHolder *param1, uint32 param2) { bool AdResponseBox::persist(BasePersistenceManager *persistMgr) { BaseObject::persist(persistMgr); - persistMgr->transfer(TMEMBER(_font)); - persistMgr->transfer(TMEMBER(_fontHover)); + persistMgr->transferPtr(TMEMBER_PTR(_font)); + persistMgr->transferPtr(TMEMBER_PTR(_fontHover)); persistMgr->transfer(TMEMBER(_horizontal)); persistMgr->transfer(TMEMBER(_lastResponseText)); persistMgr->transfer(TMEMBER(_lastResponseTextOrig)); @@ -579,10 +582,10 @@ bool AdResponseBox::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_responseArea)); _responses.persist(persistMgr); persistMgr->transfer(TMEMBER(_scrollOffset)); - persistMgr->transfer(TMEMBER(_shieldWindow)); + persistMgr->transferPtr(TMEMBER_PTR(_shieldWindow)); persistMgr->transfer(TMEMBER(_spacing)); - persistMgr->transfer(TMEMBER(_waitingScript)); - persistMgr->transfer(TMEMBER(_window)); + persistMgr->transferPtr(TMEMBER_PTR(_waitingScript)); + persistMgr->transferPtr(TMEMBER_PTR(_window)); persistMgr->transfer(TMEMBER_INT(_verticalAlign)); persistMgr->transfer(TMEMBER_INT(_align)); @@ -598,7 +601,7 @@ bool AdResponseBox::weedResponses() { for (uint32 i = 0; i < _responses.size(); i++) { switch (_responses[i]->_responseType) { case RESPONSE_ONCE: - if (adGame->branchResponseUsed(_responses[i]->_iD)) { + if (adGame->branchResponseUsed(_responses[i]->getID())) { delete _responses[i]; _responses.remove_at(i); i--; @@ -606,7 +609,7 @@ bool AdResponseBox::weedResponses() { break; case RESPONSE_ONCE_GAME: - if (adGame->gameResponseUsed(_responses[i]->_iD)) { + if (adGame->gameResponseUsed(_responses[i]->getID())) { delete _responses[i]; _responses.remove_at(i); i--; @@ -627,20 +630,44 @@ void AdResponseBox::setLastResponseText(const char *text, const char *textOrig) BaseUtils::setString(&_lastResponseTextOrig, textOrig); } +const char *AdResponseBox::getLastResponseText() const { + return _lastResponseText; +} + +const char *AdResponseBox::getLastResponseTextOrig() const { + return _lastResponseTextOrig; +} + +UIWindow *AdResponseBox::getResponseWindow() { + return _window; +} + +void AdResponseBox::addResponse(const AdResponse *response) { + _responses.add(response); +} + +int32 AdResponseBox::getIdForResponseNum(uint32 num) const { + assert(num < _responses.size()); + return _responses[num]->getID(); +} + +bool AdResponseBox::handleResponseNum(uint32 num) { + return handleResponse(_responses[num]); +} ////////////////////////////////////////////////////////////////////////// -bool AdResponseBox::handleResponse(AdResponse *response) { - setLastResponseText(response->_text, response->_textOrig); +bool AdResponseBox::handleResponse(const AdResponse *response) { + setLastResponseText(response->getText(), response->getTextOrig()); AdGame *adGame = (AdGame *)_gameRef; switch (response->_responseType) { case RESPONSE_ONCE: - adGame->addBranchResponse(response->_iD); + adGame->addBranchResponse(response->getID()); break; case RESPONSE_ONCE_GAME: - adGame->addGameResponse(response->_iD); + adGame->addGameResponse(response->getID()); break; default: debugC(kWintermuteDebugGeneral, "AdResponseBox::HandleResponse - Unhandled enum"); @@ -656,9 +683,9 @@ BaseObject *AdResponseBox::getNextAccessObject(BaseObject *currObject) { getObjects(objects, true); if (objects.size() == 0) { - return NULL; + return nullptr; } else { - if (currObject != NULL) { + if (currObject != nullptr) { for (uint32 i = 0; i < objects.size(); i++) { if (objects[i] == currObject) { if (i < objects.size() - 1) { @@ -671,7 +698,7 @@ BaseObject *AdResponseBox::getNextAccessObject(BaseObject *currObject) { } return objects[0]; } - return NULL; + return nullptr; } ////////////////////////////////////////////////////////////////////////// @@ -680,9 +707,9 @@ BaseObject *AdResponseBox::getPrevAccessObject(BaseObject *currObject) { getObjects(objects, true); if (objects.size() == 0) { - return NULL; + return nullptr; } else { - if (currObject != NULL) { + if (currObject != nullptr) { for (int i = objects.size() - 1; i >= 0; i--) { if (objects[i] == currObject) { if (i > 0) { @@ -695,7 +722,7 @@ BaseObject *AdResponseBox::getPrevAccessObject(BaseObject *currObject) { } return objects[objects.size() - 1]; } - return NULL; + return nullptr; } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/ad/ad_response_box.h b/engines/wintermute/ad/ad_response_box.h index 35f8cb6347..cb57b98924 100644 --- a/engines/wintermute/ad/ad_response_box.h +++ b/engines/wintermute/ad/ad_response_box.h @@ -44,10 +44,14 @@ public: BaseObject *getPrevAccessObject(BaseObject *CurrObject); bool getObjects(BaseArray<UIObject *> &objects, bool interactiveOnly); - bool handleResponse(AdResponse *response); + void addResponse(const AdResponse* response); + bool handleResponse(const AdResponse *response); + bool handleResponseNum(uint32 num); + int32 getIdForResponseNum(uint32 num) const; void setLastResponseText(const char *text, const char *textOrig); - char *_lastResponseText; - char *_lastResponseTextOrig; + const char *getLastResponseText() const; + const char *getLastResponseTextOrig() const; + DECLARE_PERSISTENT(AdResponseBox, BaseObject) ScScript *_waitingScript; virtual bool listen(BaseScriptHolder *param1, uint32 param2); @@ -59,27 +63,35 @@ public: bool weedResponses(); bool display(); - int _spacing; - int _scrollOffset; - BaseFont *_fontHover; - BaseFont *_font; + bool createButtons(); bool invalidateButtons(); void clearButtons(); void clearResponses(); AdResponseBox(BaseGame *inGame); virtual ~AdResponseBox(); - BaseArray<AdResponse *> _responses; - BaseArray<UIButton *> _respButtons; - UIWindow *_window; - UIWindow *_shieldWindow; + + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete = true); + virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent) override; + + UIWindow *getResponseWindow(); + uint32 getNumResponses() const; +private: + int32 _spacing; + int32 _scrollOffset; + BaseFont *_fontHover; + BaseFont *_font; bool _horizontal; Rect32 _responseArea; - int _verticalAlign; + int32 _verticalAlign; TTextAlign _align; - bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete = true); - virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); + BaseArray<UIButton *> _respButtons; + BaseArray<const AdResponse *> _responses; + UIWindow *_shieldWindow; + char *_lastResponseText; + char *_lastResponseTextOrig; + UIWindow *_window; }; } // end of namespace Wintermute diff --git a/engines/wintermute/ad/ad_response_context.cpp b/engines/wintermute/ad/ad_response_context.cpp index ebfa03feea..663ef49a24 100644 --- a/engines/wintermute/ad/ad_response_context.cpp +++ b/engines/wintermute/ad/ad_response_context.cpp @@ -36,20 +36,20 @@ IMPLEMENT_PERSISTENT(AdResponseContext, false) ////////////////////////////////////////////////////////////////////////// AdResponseContext::AdResponseContext(BaseGame *inGame) : BaseClass(inGame) { _id = 0; - _context = NULL; + _context = nullptr; } ////////////////////////////////////////////////////////////////////////// AdResponseContext::~AdResponseContext() { delete[] _context; - _context = NULL; + _context = nullptr; } ////////////////////////////////////////////////////////////////////////// bool AdResponseContext::persist(BasePersistenceManager *persistMgr) { - persistMgr->transfer(TMEMBER(_gameRef)); + persistMgr->transferPtr(TMEMBER_PTR(_gameRef)); persistMgr->transfer(TMEMBER(_context)); persistMgr->transfer(TMEMBER(_id)); @@ -59,7 +59,7 @@ bool AdResponseContext::persist(BasePersistenceManager *persistMgr) { ////////////////////////////////////////////////////////////////////////// void AdResponseContext::setContext(const char *context) { delete[] _context; - _context = NULL; + _context = nullptr; if (context) { _context = new char [strlen(context) + 1]; if (_context) { diff --git a/engines/wintermute/ad/ad_response_context.h b/engines/wintermute/ad/ad_response_context.h index 14bc1abd93..dd0008a728 100644 --- a/engines/wintermute/ad/ad_response_context.h +++ b/engines/wintermute/ad/ad_response_context.h @@ -37,12 +37,14 @@ namespace Wintermute { class AdResponseContext : public BaseClass { public: void setContext(const char *context); - int _id; - char *_context; + const char *getContext() const { return _context; } + int32 _id; + DECLARE_PERSISTENT(AdResponseContext, BaseClass) AdResponseContext(BaseGame *inGame); virtual ~AdResponseContext(); - +private: + char *_context; }; } // end of namespace Wintermute diff --git a/engines/wintermute/ad/ad_rot_level.cpp b/engines/wintermute/ad/ad_rot_level.cpp index fb9a4a47b9..4d7f27aec7 100644 --- a/engines/wintermute/ad/ad_rot_level.cpp +++ b/engines/wintermute/ad/ad_rot_level.cpp @@ -54,7 +54,7 @@ AdRotLevel::~AdRotLevel() { ////////////////////////////////////////////////////////////////////////// bool AdRotLevel::loadFile(const char *filename) { byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); - if (buffer == NULL) { + if (buffer == nullptr) { _gameRef->LOG(0, "AdRotLevel::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } diff --git a/engines/wintermute/ad/ad_rot_level.h b/engines/wintermute/ad/ad_rot_level.h index d7f5f8edf0..3466e46ba5 100644 --- a/engines/wintermute/ad/ad_rot_level.h +++ b/engines/wintermute/ad/ad_rot_level.h @@ -34,12 +34,13 @@ namespace Wintermute { class AdRotLevel : public BaseObject { + float _rotation; public: DECLARE_PERSISTENT(AdRotLevel, BaseObject) AdRotLevel(BaseGame *inGame); virtual ~AdRotLevel(); - float _rotation; - virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); + float getRotation() const { return _rotation; } + virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent) override; bool loadFile(const char *filename); bool loadBuffer(byte *buffer, bool complete = true); }; diff --git a/engines/wintermute/ad/ad_scale_level.cpp b/engines/wintermute/ad/ad_scale_level.cpp index 4e9293d875..e80f38bd0f 100644 --- a/engines/wintermute/ad/ad_scale_level.cpp +++ b/engines/wintermute/ad/ad_scale_level.cpp @@ -48,11 +48,14 @@ AdScaleLevel::~AdScaleLevel() { } +float AdScaleLevel::getScale() const { + return _scale; +} ////////////////////////////////////////////////////////////////////////// bool AdScaleLevel::loadFile(const char *filename) { byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); - if (buffer == NULL) { + if (buffer == nullptr) { _gameRef->LOG(0, "AdScaleLevel::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } diff --git a/engines/wintermute/ad/ad_scale_level.h b/engines/wintermute/ad/ad_scale_level.h index 628a385eb4..516f507a5a 100644 --- a/engines/wintermute/ad/ad_scale_level.h +++ b/engines/wintermute/ad/ad_scale_level.h @@ -37,12 +37,14 @@ namespace Wintermute { class AdScaleLevel : public BaseObject { public: DECLARE_PERSISTENT(AdScaleLevel, BaseObject) - float _scale; AdScaleLevel(BaseGame *inGame); virtual ~AdScaleLevel(); - virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); + virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent) override; bool loadFile(const char *filename); bool loadBuffer(byte *buffer, bool complete = true); + float getScale() const; +private: + float _scale; }; } // end of namespace Wintermute diff --git a/engines/wintermute/ad/ad_scene.cpp b/engines/wintermute/ad/ad_scene.cpp index 8e9beca0c0..4d0068fad1 100644 --- a/engines/wintermute/ad/ad_scene.cpp +++ b/engines/wintermute/ad/ad_scene.cpp @@ -77,7 +77,7 @@ AdScene::~AdScene() { cleanup(); _gameRef->unregisterObject(_fader); delete _pfTarget; - _pfTarget = NULL; + _pfTarget = nullptr; } @@ -85,9 +85,9 @@ AdScene::~AdScene() { void AdScene::setDefaults() { _initialized = false; _pfReady = true; - _pfTargetPath = NULL; - _pfRequester = NULL; - _mainLayer = NULL; + _pfTargetPath = nullptr; + _pfRequester = nullptr; + _mainLayer = nullptr; _pfPointsNum = 0; _persistentState = false; @@ -127,12 +127,12 @@ void AdScene::setDefaults() { _editorShowEntities = true; _editorShowScale = true; - _shieldWindow = NULL; + _shieldWindow = nullptr; _fader = new BaseFader(_gameRef); _gameRef->registerObject(_fader); - _viewport = NULL; + _viewport = nullptr; } @@ -140,13 +140,13 @@ void AdScene::setDefaults() { void AdScene::cleanup() { BaseObject::cleanup(); - _mainLayer = NULL; // reference only + _mainLayer = nullptr; // reference only delete _shieldWindow; - _shieldWindow = NULL; + _shieldWindow = nullptr; _gameRef->unregisterObject(_fader); - _fader = NULL; + _fader = nullptr; for (uint32 i = 0; i < _layers.size(); i++) { _gameRef->unregisterObject(_layers[i]); @@ -182,14 +182,14 @@ void AdScene::cleanup() { _objects.clear(); delete _viewport; - _viewport = NULL; + _viewport = nullptr; setDefaults(); } ////////////////////////////////////////////////////////////////////////// -bool AdScene::getPath(BasePoint source, BasePoint target, AdPath *path, BaseObject *requester) { +bool AdScene::getPath(const BasePoint &source, const BasePoint &target, AdPath *path, BaseObject *requester) { if (!_pfReady) { return false; } else { @@ -287,9 +287,9 @@ float AdScene::getZoomAt(int x, int y) { if (_mainLayer) { for (int i = _mainLayer->_nodes.size() - 1; i >= 0; i--) { AdSceneNode *node = _mainLayer->_nodes[i]; - if (node->_type == OBJECT_REGION && node->_region->_active && !node->_region->_blocked && node->_region->pointInRegion(x, y)) { - if (node->_region->_zoom != 0) { - ret = node->_region->_zoom; + if (node->_type == OBJECT_REGION && node->_region->_active && !node->_region->isBlocked() && node->_region->pointInRegion(x, y)) { + if (node->_region->getZoom() != 0) { + ret = node->_region->getZoom(); found = true; break; } @@ -320,9 +320,9 @@ uint32 AdScene::getAlphaAt(int x, int y, bool colorCheck) { if (_mainLayer) { for (int i = _mainLayer->_nodes.size() - 1; i >= 0; i--) { AdSceneNode *node = _mainLayer->_nodes[i]; - if (node->_type == OBJECT_REGION && node->_region->_active && (colorCheck || !node->_region->_blocked) && node->_region->pointInRegion(x, y)) { - if (!node->_region->_blocked) { - ret = node->_region->_alpha; + if (node->_type == OBJECT_REGION && node->_region->_active && (colorCheck || !node->_region->isBlocked()) && node->_region->pointInRegion(x, y)) { + if (!node->_region->isBlocked()) { + ret = node->_region->getAlpha(); } break; } @@ -365,8 +365,8 @@ bool AdScene::isBlockedAt(int x, int y, bool checkFreeObjects, BaseObject *reque break; } */ - if (node->_type == OBJECT_REGION && node->_region->_active && !node->_region->_decoration && node->_region->pointInRegion(x, y)) { - if (node->_region->_blocked) { + if (node->_type == OBJECT_REGION && node->_region->_active && !node->_region->hasDecoration() && node->_region->pointInRegion(x, y)) { + if (node->_region->isBlocked()) { ret = true; break; } else { @@ -405,8 +405,8 @@ bool AdScene::isWalkableAt(int x, int y, bool checkFreeObjects, BaseObject *requ if (_mainLayer) { for (uint32 i = 0; i < _mainLayer->_nodes.size(); i++) { AdSceneNode *node = _mainLayer->_nodes[i]; - if (node->_type == OBJECT_REGION && node->_region->_active && !node->_region->_decoration && node->_region->pointInRegion(x, y)) { - if (node->_region->_blocked) { + if (node->_type == OBJECT_REGION && node->_region->_active && !node->_region->hasDecoration() && node->_region->pointInRegion(x, y)) { + if (node->_region->isBlocked()) { ret = false; break; } else { @@ -420,7 +420,7 @@ bool AdScene::isWalkableAt(int x, int y, bool checkFreeObjects, BaseObject *requ ////////////////////////////////////////////////////////////////////////// -int AdScene::getPointsDist(BasePoint p1, BasePoint p2, BaseObject *requester) { +int AdScene::getPointsDist(const BasePoint &p1, const BasePoint &p2, BaseObject *requester) { double xStep, yStep, x, y; int xLength, yLength, xCount, yCount; int x1, y1, x2, y2; @@ -473,7 +473,7 @@ void AdScene::pathFinderStep() { int i; // get lowest unmarked int lowestDist = INT_MAX; - AdPathPoint *lowestPt = NULL; + AdPathPoint *lowestPt = nullptr; for (i = 0; i < _pfPointsNum; i++) if (!_pfPath[i]->_marked && _pfPath[i]->_distance < lowestDist) { @@ -481,7 +481,7 @@ void AdScene::pathFinderStep() { lowestPt = _pfPath[i]; } - if (lowestPt == NULL) { // no path -> terminate PathFinder + if (lowestPt == nullptr) { // no path -> terminate PathFinder _pfReady = true; _pfTargetPath->setReady(true); return; @@ -491,7 +491,7 @@ void AdScene::pathFinderStep() { // target point marked, generate path and terminate if (lowestPt->x == _pfTarget->x && lowestPt->y == _pfTarget->y) { - while (lowestPt != NULL) { + while (lowestPt != nullptr) { _pfTargetPath->_points.insert_at(0, new BasePoint(lowestPt->x, lowestPt->y)); lowestPt = lowestPt->_origin; } @@ -539,7 +539,7 @@ bool AdScene::initLoop() { ////////////////////////////////////////////////////////////////////////// bool AdScene::loadFile(const char *filename) { byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); - if (buffer == NULL) { + if (buffer == nullptr) { _gameRef->LOG(0, "AdScene::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -680,7 +680,7 @@ bool AdScene::loadBuffer(byte *buffer, bool complete) { if (!layer || DID_FAIL(layer->loadBuffer(params, false))) { cmd = PARSERR_GENERIC; delete layer; - layer = NULL; + layer = nullptr; } else { _gameRef->registerObject(layer); _layers.add(layer); @@ -698,7 +698,7 @@ bool AdScene::loadBuffer(byte *buffer, bool complete) { if (!wpt || DID_FAIL(wpt->loadBuffer(params, false))) { cmd = PARSERR_GENERIC; delete wpt; - wpt = NULL; + wpt = nullptr; } else { _gameRef->registerObject(wpt); _waypointGroups.add(wpt); @@ -711,7 +711,7 @@ bool AdScene::loadBuffer(byte *buffer, bool complete) { if (!sl || DID_FAIL(sl->loadBuffer(params, false))) { cmd = PARSERR_GENERIC; delete sl; - sl = NULL; + sl = nullptr; } else { _gameRef->registerObject(sl); _scaleLevels.add(sl); @@ -724,7 +724,7 @@ bool AdScene::loadBuffer(byte *buffer, bool complete) { if (!rl || DID_FAIL(rl->loadBuffer(params, false))) { cmd = PARSERR_GENERIC; delete rl; - rl = NULL; + rl = nullptr; } else { _gameRef->registerObject(rl); _rotLevels.add(rl); @@ -737,7 +737,7 @@ bool AdScene::loadBuffer(byte *buffer, bool complete) { if (!entity || DID_FAIL(entity->loadBuffer(params, false))) { cmd = PARSERR_GENERIC; delete entity; - entity = NULL; + entity = nullptr; } else { addObject(entity); } @@ -749,13 +749,13 @@ bool AdScene::loadBuffer(byte *buffer, bool complete) { _cursor = new BaseSprite(_gameRef); if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { delete _cursor; - _cursor = NULL; + _cursor = nullptr; cmd = PARSERR_GENERIC; } break; case TOKEN_CAMERA: - strcpy(camera, (char *)params); + Common::strlcpy(camera, (char *)params, MAX_PATH_LENGTH); break; case TOKEN_EDITOR_MARGIN_H: @@ -884,7 +884,7 @@ bool AdScene::loadBuffer(byte *buffer, bool complete) { return STATUS_FAILED; } - if (_mainLayer == NULL) { + if (_mainLayer == nullptr) { _gameRef->LOG(0, "Warning: scene '%s' has no main layer.", getFilename()); } @@ -923,7 +923,7 @@ bool AdScene::traverseNodes(bool doUpdate) { // *** adjust scroll offset if (doUpdate) { /* - if (_autoScroll && _gameRef->_mainObject != NULL) + if (_autoScroll && _gameRef->_mainObject != nullptr) { ScrollToObject(_gameRef->_mainObject); } @@ -931,25 +931,35 @@ bool AdScene::traverseNodes(bool doUpdate) { if (_autoScroll) { // adjust horizontal scroll - if (_gameRef->_timer - _lastTimeH >= _scrollTimeH) { - _lastTimeH = _gameRef->_timer; + if (_gameRef->getTimer()->getTime() - _lastTimeH >= _scrollTimeH) { + int timesMissed = (_gameRef->getTimer()->getTime() - _lastTimeH) / _scrollTimeH; + // Cap the amount of catch-up to avoid jittery characters. + if (timesMissed > 2) { + timesMissed = 2; + } + _lastTimeH = _gameRef->getTimer()->getTime(); if (_offsetLeft < _targetOffsetLeft) { - _offsetLeft += _scrollPixelsH; + _offsetLeft += _scrollPixelsH * timesMissed; _offsetLeft = MIN(_offsetLeft, _targetOffsetLeft); } else if (_offsetLeft > _targetOffsetLeft) { - _offsetLeft -= _scrollPixelsH; + _offsetLeft -= _scrollPixelsH * timesMissed; _offsetLeft = MAX(_offsetLeft, _targetOffsetLeft); } } // adjust vertical scroll - if (_gameRef->_timer - _lastTimeV >= _scrollTimeV) { - _lastTimeV = _gameRef->_timer; + if (_gameRef->getTimer()->getTime() - _lastTimeV >= _scrollTimeV) { + int timesMissed = (_gameRef->getTimer()->getTime() - _lastTimeV) / _scrollTimeV; + // Cap the amount of catch-up to avoid jittery characters. + if (timesMissed > 2) { + timesMissed = 2; + } + _lastTimeV = _gameRef->getTimer()->getTime(); if (_offsetTop < _targetOffsetTop) { - _offsetTop += _scrollPixelsV; + _offsetTop += _scrollPixelsV * timesMissed; _offsetTop = MIN(_offsetTop, _targetOffsetTop); } else if (_offsetTop > _targetOffsetTop) { - _offsetTop -= _scrollPixelsV; + _offsetTop -= _scrollPixelsV * timesMissed; _offsetTop = MAX(_offsetTop, _targetOffsetTop); } } @@ -966,14 +976,14 @@ bool AdScene::traverseNodes(bool doUpdate) { ////////////////////////////////////////////////////////////////////////// - int viewportWidth, viewportHeight; + int32 viewportWidth, viewportHeight; getViewportSize(&viewportWidth, &viewportHeight); - int viewportX, viewportY; + int32 viewportX, viewportY; getViewportOffset(&viewportX, &viewportY); - int scrollableX = _width - viewportWidth; - int scrollableY = _height - viewportHeight; + int32 scrollableX = _width - viewportWidth; + int32 scrollableY = _height - viewportHeight; double widthRatio = scrollableX <= 0 ? 0 : ((double)(_offsetLeft) / (double)scrollableX); double heightRatio = scrollableY <= 0 ? 0 : ((double)(_offsetTop) / (double)scrollableY); @@ -1004,8 +1014,8 @@ bool AdScene::traverseNodes(bool doUpdate) { } if (_shieldWindow) { _shieldWindow->_posX = _shieldWindow->_posY = 0; - _shieldWindow->_width = _gameRef->_renderer->_width; - _shieldWindow->_height = _gameRef->_renderer->_height; + _shieldWindow->_width = _gameRef->_renderer->getWidth(); + _shieldWindow->_height = _gameRef->_renderer->getHeight(); _shieldWindow->display(); } } @@ -1045,10 +1055,10 @@ bool AdScene::traverseNodes(bool doUpdate) { break; case OBJECT_REGION: { - if (node->_region->_blocked) { + if (node->_region->isBlocked()) { break; } - if (node->_region->_decoration) { + if (node->_region->hasDecoration()) { break; } @@ -1068,7 +1078,7 @@ bool AdScene::traverseNodes(bool doUpdate) { if (doUpdate) { updateFreeObjects(); } else { - displayRegionContent(NULL); + displayRegionContent(nullptr); } } } // each layer @@ -1128,8 +1138,8 @@ bool AdScene::updateFreeObjects() { } - if (_autoScroll && _gameRef->_mainObject != NULL) { - scrollToObject(_gameRef->_mainObject); + if (_autoScroll && _gameRef->getMainObject() != nullptr) { + scrollToObject(_gameRef->getMainObject()); } @@ -1140,22 +1150,22 @@ bool AdScene::updateFreeObjects() { ////////////////////////////////////////////////////////////////////////// bool AdScene::displayRegionContent(AdRegion *region, bool display3DOnly) { AdGame *adGame = (AdGame *)_gameRef; - BaseArray<AdObject *> objects; + Common::Array<AdObject *> objects; AdObject *obj; // global objects for (uint32 i = 0; i < adGame->_objects.size(); i++) { obj = adGame->_objects[i]; - if (obj->_active && !obj->_drawn && (obj->_stickRegion == region || region == NULL || (obj->_stickRegion == NULL && region->pointInRegion(obj->_posX, obj->_posY)))) { - objects.add(obj); + if (obj->_active && !obj->_drawn && (obj->_stickRegion == region || region == nullptr || (obj->_stickRegion == nullptr && region->pointInRegion(obj->_posX, obj->_posY)))) { + objects.push_back(obj); } } // scene objects for (uint32 i = 0; i < _objects.size(); i++) { obj = _objects[i]; - if (obj->_active && !obj->_editorOnly && !obj->_drawn && (obj->_stickRegion == region || region == NULL || (obj->_stickRegion == NULL && region->pointInRegion(obj->_posX, obj->_posY)))) { - objects.add(obj); + if (obj->_active && !obj->_editorOnly && !obj->_drawn && (obj->_stickRegion == region || region == nullptr || (obj->_stickRegion == nullptr && region->pointInRegion(obj->_posX, obj->_posY)))) { + objects.push_back(obj); } } @@ -1181,7 +1191,7 @@ bool AdScene::displayRegionContent(AdRegion *region, bool display3DOnly) { // display design only objects if (!display3DOnly) { - if (_gameRef->_editorMode && region == NULL) { + if (_gameRef->_editorMode && region == nullptr) { for (uint32 i = 0; i < _objects.size(); i++) { if (_objects[i]->_active && _objects[i]->_editorOnly) { _objects[i]->display(); @@ -1195,16 +1205,11 @@ bool AdScene::displayRegionContent(AdRegion *region, bool display3DOnly) { } ////////////////////////////////////////////////////////////////////////// -int AdScene::compareObjs(const void *obj1, const void *obj2) { - const AdObject *object1 = *(const AdObject *const *)obj1; - const AdObject *object2 = *(const AdObject *const *)obj2; - - if (object1->_posY < object2->_posY) { - return -1; - } else if (object1->_posY > object2->_posY) { - return 1; +bool AdScene::compareObjs(const AdObject *obj1, const AdObject *obj2) { + if (obj1->_posY < obj2->_posY) { + return true; } else { - return 0; + return false; } } @@ -1215,12 +1220,12 @@ bool AdScene::displayRegionContentOld(AdRegion *region) { // display all objects in region sorted by _posY do { - obj = NULL; + obj = nullptr; int minY = INT_MAX; // global objects for (uint32 i = 0; i < adGame->_objects.size(); i++) { - if (adGame->_objects[i]->_active && !adGame->_objects[i]->_drawn && adGame->_objects[i]->_posY < minY && (adGame->_objects[i]->_stickRegion == region || region == NULL || (adGame->_objects[i]->_stickRegion == NULL && region->pointInRegion(adGame->_objects[i]->_posX, adGame->_objects[i]->_posY)))) { + if (adGame->_objects[i]->_active && !adGame->_objects[i]->_drawn && adGame->_objects[i]->_posY < minY && (adGame->_objects[i]->_stickRegion == region || region == nullptr || (adGame->_objects[i]->_stickRegion == nullptr && region->pointInRegion(adGame->_objects[i]->_posX, adGame->_objects[i]->_posY)))) { obj = adGame->_objects[i]; minY = adGame->_objects[i]->_posY; } @@ -1228,14 +1233,14 @@ bool AdScene::displayRegionContentOld(AdRegion *region) { // scene objects for (uint32 i = 0; i < _objects.size(); i++) { - if (_objects[i]->_active && !_objects[i]->_editorOnly && !_objects[i]->_drawn && _objects[i]->_posY < minY && (_objects[i]->_stickRegion == region || region == NULL || (_objects[i]->_stickRegion == NULL && region->pointInRegion(_objects[i]->_posX, _objects[i]->_posY)))) { + if (_objects[i]->_active && !_objects[i]->_editorOnly && !_objects[i]->_drawn && _objects[i]->_posY < minY && (_objects[i]->_stickRegion == region || region == nullptr || (_objects[i]->_stickRegion == nullptr && region->pointInRegion(_objects[i]->_posX, _objects[i]->_posY)))) { obj = _objects[i]; minY = _objects[i]->_posY; } } - if (obj != NULL) { + if (obj != nullptr) { _gameRef->_renderer->setup2D(); if (_gameRef->_editorMode || !obj->_editorOnly) { @@ -1243,11 +1248,11 @@ bool AdScene::displayRegionContentOld(AdRegion *region) { } obj->_drawn = true; } - } while (obj != NULL); + } while (obj != nullptr); // design only objects - if (_gameRef->_editorMode && region == NULL) { + if (_gameRef->_editorMode && region == nullptr) { for (uint32 i = 0; i < _objects.size(); i++) { if (_objects[i]->_active && _objects[i]->_editorOnly) { _objects[i]->display(); @@ -1267,20 +1272,20 @@ bool AdScene::update() { ////////////////////////////////////////////////////////////////////////// void AdScene::scrollTo(int offsetX, int offsetY) { - int viewportWidth, viewportHeight; + int32 viewportWidth, viewportHeight; getViewportSize(&viewportWidth, &viewportHeight); - int origOffsetLeft = _targetOffsetLeft; - int origOffsetTop = _targetOffsetTop; + int32 origOffsetLeft = _targetOffsetLeft; + int32 origOffsetTop = _targetOffsetTop; - _targetOffsetLeft = MAX(0, offsetX - viewportWidth / 2); + _targetOffsetLeft = MAX<int32>(0, offsetX - viewportWidth / 2); _targetOffsetLeft = MIN(_targetOffsetLeft, _width - viewportWidth); - _targetOffsetTop = MAX(0, offsetY - viewportHeight / 2); + _targetOffsetTop = MAX<int32>(0, offsetY - viewportHeight / 2); _targetOffsetTop = MIN(_targetOffsetTop, _height - viewportHeight); - if (_gameRef->_mainObject && _gameRef->_mainObject->_is3D) { + if (_gameRef->getMainObject() && _gameRef->getMainObject()->_is3D) { if (abs(origOffsetLeft - _targetOffsetLeft) < 5) { _targetOffsetLeft = origOffsetLeft; } @@ -1312,13 +1317,13 @@ void AdScene::skipToObject(BaseObject *object) { ////////////////////////////////////////////////////////////////////////// void AdScene::skipTo(int offsetX, int offsetY) { - int viewportWidth, viewportHeight; + int32 viewportWidth, viewportHeight; getViewportSize(&viewportWidth, &viewportHeight); - _offsetLeft = MAX(0, offsetX - viewportWidth / 2); + _offsetLeft = MAX<int32>(0, offsetX - viewportWidth / 2); _offsetLeft = MIN(_offsetLeft, _width - viewportWidth); - _offsetTop = MAX(0, offsetY - viewportHeight / 2); + _offsetTop = MAX<int32>(0, offsetY - viewportHeight / 2); _offsetTop = MIN(_offsetTop, _height - viewportHeight); _targetOffsetLeft = _offsetLeft; @@ -1341,7 +1346,7 @@ bool AdScene::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, stack->pushNative(act, true); } else { delete act; - act = NULL; + act = nullptr; stack->pushNULL(); } return STATUS_OK; @@ -1358,7 +1363,7 @@ bool AdScene::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, stack->pushNative(ent, true); } else { delete ent; - ent = NULL; + ent = nullptr; stack->pushNULL(); } return STATUS_OK; @@ -1499,7 +1504,7 @@ bool AdScene::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, stack->correctParams(1); ScValue *val = stack->pop(); - AdObject *ret = NULL; + AdObject *ret = nullptr; if (val->isInt()) { int index = val->getInt(); if (index >= 0 && index < (int32)_objects.size()) { @@ -1541,7 +1546,7 @@ bool AdScene::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, for (int i = _mainLayer->_nodes.size() - 1; i >= 0; i--) { AdSceneNode *node = _mainLayer->_nodes[i]; if (node->_type == OBJECT_REGION && node->_region->_active && node->_region->pointInRegion(x, y)) { - if (node->_region->_decoration && !includeDecors) { + if (node->_region->hasDecoration() && !includeDecors) { continue; } @@ -1689,10 +1694,10 @@ bool AdScene::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, int height = stack->pop()->getInt(); if (width <= 0) { - width = _gameRef->_renderer->_width; + width = _gameRef->_renderer->getWidth(); } if (height <= 0) { - height = _gameRef->_renderer->_height; + height = _gameRef->_renderer->getHeight(); } if (!_viewport) { @@ -1767,7 +1772,7 @@ bool AdScene::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, stack->correctParams(1); ScValue *val = stack->pop(); - AdLayer *toDelete = NULL; + AdLayer *toDelete = nullptr; if (val->isNative()) { BaseScriptable *temp = val->getNative(); for (uint32 i = 0; i < _layers.size(); i++) { @@ -1782,7 +1787,7 @@ bool AdScene::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, toDelete = _layers[index]; } } - if (toDelete == NULL) { + if (toDelete == nullptr) { stack->pushBool(false); return STATUS_OK; } @@ -1861,7 +1866,7 @@ ScValue *AdScene::scGetProperty(const Common::String &name) { // MouseX (RO) ////////////////////////////////////////////////////////////////////////// else if (name == "MouseX") { - int viewportX; + int32 viewportX; getViewportOffset(&viewportX); _scValue->setInt(_gameRef->_mousePos.x + _offsetLeft - viewportX); @@ -1872,8 +1877,8 @@ ScValue *AdScene::scGetProperty(const Common::String &name) { // MouseY (RO) ////////////////////////////////////////////////////////////////////////// else if (name == "MouseY") { - int viewportY; - getViewportOffset(NULL, &viewportY); + int32 viewportY; + getViewportOffset(nullptr, &viewportY); _scValue->setInt(_gameRef->_mousePos.y + _offsetTop - viewportY); return _scValue; @@ -2052,10 +2057,10 @@ bool AdScene::scSetProperty(const char *name, ScValue *value) { else if (strcmp(name, "OffsetX") == 0) { _offsetLeft = value->getInt(); - int viewportWidth, viewportHeight; + int32 viewportWidth, viewportHeight; getViewportSize(&viewportWidth, &viewportHeight); - _offsetLeft = MAX(0, _offsetLeft - viewportWidth / 2); + _offsetLeft = MAX<int32>(0, _offsetLeft - viewportWidth / 2); _offsetLeft = MIN(_offsetLeft, _width - viewportWidth); _targetOffsetLeft = _offsetLeft; @@ -2068,10 +2073,10 @@ bool AdScene::scSetProperty(const char *name, ScValue *value) { else if (strcmp(name, "OffsetY") == 0) { _offsetTop = value->getInt(); - int viewportWidth, viewportHeight; + int32 viewportWidth, viewportHeight; getViewportSize(&viewportWidth, &viewportHeight); - _offsetTop = MAX(0, _offsetTop - viewportHeight / 2); + _offsetTop = MAX<int32>(0, _offsetTop - viewportHeight / 2); _offsetTop = MIN(_offsetTop, _height - viewportHeight); _targetOffsetTop = _offsetTop; @@ -2202,7 +2207,7 @@ bool AdScene::saveAsText(BaseDynamicBuffer *buffer, int indent) { // free entities buffer->putTextIndent(indent + 2, "; ----- free entities\n"); for (uint32 i = 0; i < _objects.size(); i++) { - if (_objects[i]->_type == OBJECT_ENTITY) { + if (_objects[i]->getType() == OBJECT_ENTITY) { _objects[i]->saveAsText(buffer, indent + 2); } @@ -2263,8 +2268,8 @@ bool AdScene::sortRotLevels() { ////////////////////////////////////////////////////////////////////////// float AdScene::getScaleAt(int Y) { - AdScaleLevel *prev = NULL; - AdScaleLevel *next = NULL; + AdScaleLevel *prev = nullptr; + AdScaleLevel *next = nullptr; for (uint32 i = 0; i < _scaleLevels.size(); i++) { /* AdScaleLevel *xxx = _scaleLevels[i];*/ @@ -2277,16 +2282,16 @@ float AdScene::getScaleAt(int Y) { } } - if (prev == NULL || next == NULL) { + if (prev == nullptr || next == nullptr) { return 100; } int delta_y = next->_posY - prev->_posY; - float delta_scale = next->_scale - prev->_scale; + float delta_scale = next->getScale() - prev->getScale(); Y -= prev->_posY; float percent = (float)Y / ((float)delta_y / 100.0f); - return prev->_scale + delta_scale / 100 * percent; + return prev->getScale() + delta_scale / 100 * percent; } @@ -2314,13 +2319,13 @@ bool AdScene::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_editorShowEntities)); persistMgr->transfer(TMEMBER(_editorShowRegions)); persistMgr->transfer(TMEMBER(_editorShowScale)); - persistMgr->transfer(TMEMBER(_fader)); + persistMgr->transferPtr(TMEMBER_PTR(_fader)); persistMgr->transfer(TMEMBER(_height)); persistMgr->transfer(TMEMBER(_initialized)); persistMgr->transfer(TMEMBER(_lastTimeH)); persistMgr->transfer(TMEMBER(_lastTimeV)); _layers.persist(persistMgr); - persistMgr->transfer(TMEMBER(_mainLayer)); + persistMgr->transferPtr(TMEMBER_PTR(_mainLayer)); _objects.persist(persistMgr); persistMgr->transfer(TMEMBER(_offsetLeft)); persistMgr->transfer(TMEMBER(_offsetTop)); @@ -2331,20 +2336,20 @@ bool AdScene::persist(BasePersistenceManager *persistMgr) { _pfPath.persist(persistMgr); persistMgr->transfer(TMEMBER(_pfPointsNum)); persistMgr->transfer(TMEMBER(_pfReady)); - persistMgr->transfer(TMEMBER(_pfRequester)); - persistMgr->transfer(TMEMBER(_pfTarget)); - persistMgr->transfer(TMEMBER(_pfTargetPath)); + persistMgr->transferPtr(TMEMBER_PTR(_pfRequester)); + persistMgr->transferPtr(TMEMBER_PTR(_pfTarget)); + persistMgr->transferPtr(TMEMBER_PTR(_pfTargetPath)); _rotLevels.persist(persistMgr); _scaleLevels.persist(persistMgr); persistMgr->transfer(TMEMBER(_scrollPixelsH)); persistMgr->transfer(TMEMBER(_scrollPixelsV)); persistMgr->transfer(TMEMBER(_scrollTimeH)); persistMgr->transfer(TMEMBER(_scrollTimeV)); - persistMgr->transfer(TMEMBER(_shieldWindow)); + persistMgr->transferPtr(TMEMBER_PTR(_shieldWindow)); persistMgr->transfer(TMEMBER(_targetOffsetLeft)); persistMgr->transfer(TMEMBER(_targetOffsetTop)); _waypointGroups.persist(persistMgr); - persistMgr->transfer(TMEMBER(_viewport)); + persistMgr->transferPtr(TMEMBER_PTR(_viewport)); persistMgr->transfer(TMEMBER(_width)); return STATUS_OK; @@ -2356,10 +2361,10 @@ bool AdScene::afterLoad() { } ////////////////////////////////////////////////////////////////////////// -bool AdScene::correctTargetPoint2(int startX, int startY, int *targetX, int *targetY, bool checkFreeObjects, BaseObject *requester) { +bool AdScene::correctTargetPoint2(int32 startX, int32 startY, int32 *targetX, int32 *targetY, bool checkFreeObjects, BaseObject *requester) { double xStep, yStep, x, y; - int xLength, yLength, xCount, yCount; - int x1, y1, x2, y2; + int32 xLength, yLength, xCount, yCount; + int32 x1, y1, x2, y2; x1 = *targetX; y1 = *targetY; @@ -2402,9 +2407,9 @@ bool AdScene::correctTargetPoint2(int startX, int startY, int *targetX, int *tar } ////////////////////////////////////////////////////////////////////////// -bool AdScene::correctTargetPoint(int startX, int startY, int *argX, int *argY, bool checkFreeObjects, BaseObject *requester) { - int x = *argX; - int y = *argY; +bool AdScene::correctTargetPoint(int32 startX, int32 startY, int32 *argX, int32 *argY, bool checkFreeObjects, BaseObject *requester) { + int32 x = *argX; + int32 y = *argY; if (isWalkableAt(x, y, checkFreeObjects, requester) || !_mainLayer) { return STATUS_OK; @@ -2509,7 +2514,7 @@ void AdScene::pfPointsAdd(int x, int y, int distance) { _pfPath[_pfPointsNum]->y = y; _pfPath[_pfPointsNum]->_distance = distance; _pfPath[_pfPointsNum]->_marked = false; - _pfPath[_pfPointsNum]->_origin = NULL; + _pfPath[_pfPointsNum]->_origin = nullptr; } _pfPointsNum++; @@ -2517,7 +2522,7 @@ void AdScene::pfPointsAdd(int x, int y, int distance) { ////////////////////////////////////////////////////////////////////////// -bool AdScene::getViewportOffset(int *offsetX, int *offsetY) { +bool AdScene::getViewportOffset(int32 *offsetX, int32 *offsetY) { AdGame *adGame = (AdGame *)_gameRef; if (_viewport && !_gameRef->_editorMode) { if (offsetX) { @@ -2546,7 +2551,7 @@ bool AdScene::getViewportOffset(int *offsetX, int *offsetY) { ////////////////////////////////////////////////////////////////////////// -bool AdScene::getViewportSize(int *width, int *height) { +bool AdScene::getViewportSize(int32 *width, int32 *height) { AdGame *adGame = (AdGame *)_gameRef; if (_viewport && !_gameRef->_editorMode) { if (width) { @@ -2564,10 +2569,10 @@ bool AdScene::getViewportSize(int *width, int *height) { } } else { if (width) { - *width = _gameRef->_renderer->_width; + *width = _gameRef->_renderer->getWidth(); } if (height) { - *height = _gameRef->_renderer->_height; + *height = _gameRef->_renderer->getHeight(); } } return STATUS_OK; @@ -2576,7 +2581,7 @@ bool AdScene::getViewportSize(int *width, int *height) { ////////////////////////////////////////////////////////////////////////// int AdScene::getOffsetLeft() { - int viewportX; + int32 viewportX; getViewportOffset(&viewportX); return _offsetLeft - viewportX; @@ -2585,8 +2590,8 @@ int AdScene::getOffsetLeft() { ////////////////////////////////////////////////////////////////////////// int AdScene::getOffsetTop() { - int viewportY; - getViewportOffset(NULL, &viewportY); + int32 viewportY; + getViewportOffset(nullptr, &viewportY); return _offsetTop - viewportY; } @@ -2594,7 +2599,7 @@ int AdScene::getOffsetTop() { ////////////////////////////////////////////////////////////////////////// bool AdScene::pointInViewport(int x, int y) { - int left, top, width, height; + int32 left, top, width, height; getViewportOffset(&left, &top); getViewportSize(&width, &height); @@ -2612,7 +2617,7 @@ void AdScene::setOffset(int offsetLeft, int offsetTop) { ////////////////////////////////////////////////////////////////////////// BaseObject *AdScene::getNodeByName(const char *name) { - BaseObject *ret = NULL; + BaseObject *ret = nullptr; // dependent objects for (uint32 i = 0; i < _layers.size(); i++) { @@ -2629,7 +2634,7 @@ BaseObject *AdScene::getNodeByName(const char *name) { ret = node->_region; break; default: - ret = NULL; + ret = nullptr; } return ret; } @@ -2638,7 +2643,7 @@ BaseObject *AdScene::getNodeByName(const char *name) { // free entities for (uint32 i = 0; i < _objects.size(); i++) { - if (_objects[i]->_type == OBJECT_ENTITY && !scumm_stricmp(name, _objects[i]->getName())) { + if (_objects[i]->getType() == OBJECT_ENTITY && !scumm_stricmp(name, _objects[i]->getName())) { return _objects[i]; } } @@ -2650,7 +2655,7 @@ BaseObject *AdScene::getNodeByName(const char *name) { } } - return NULL; + return nullptr; } @@ -2722,7 +2727,7 @@ bool AdScene::persistState(bool saving) { if (!_objects[i]->_saveState) { continue; } - if (_objects[i]->_type == OBJECT_ENTITY) { + if (_objects[i]->getType() == OBJECT_ENTITY) { nodeState = state->getNodeState(_objects[i]->getName(), saving); if (nodeState) { nodeState->transferEntity((AdEntity *)_objects[i], _persistentStateSprites, saving); @@ -2750,8 +2755,8 @@ bool AdScene::persistState(bool saving) { ////////////////////////////////////////////////////////////////////////// float AdScene::getRotationAt(int x, int y) { - AdRotLevel *prev = NULL; - AdRotLevel *next = NULL; + AdRotLevel *prev = nullptr; + AdRotLevel *next = nullptr; for (uint32 i = 0; i < _rotLevels.size(); i++) { /* AdRotLevel *xxx = _rotLevels[i]; @@ -2764,16 +2769,16 @@ float AdScene::getRotationAt(int x, int y) { } } - if (prev == NULL || next == NULL) { + if (prev == nullptr || next == nullptr) { return 0; } int delta_x = next->_posX - prev->_posX; - float delta_rot = next->_rotation - prev->_rotation; + float delta_rot = next->getRotation() - prev->getRotation(); x -= prev->_posX; float percent = (float)x / ((float)delta_x / 100.0f); - return prev->_rotation + delta_rot / 100 * percent; + return prev->getRotation() + delta_rot / 100 * percent; } @@ -2785,7 +2790,7 @@ bool AdScene::handleItemAssociations(const char *itemName, bool show) { if (layer->_nodes[j]->_type == OBJECT_ENTITY) { AdEntity *ent = layer->_nodes[j]->_entity; - if (ent->_item && strcmp(ent->_item, itemName) == 0) { + if (ent->getItemName() && strcmp(ent->getItemName(), itemName) == 0) { ent->_active = show; } } @@ -2793,9 +2798,9 @@ bool AdScene::handleItemAssociations(const char *itemName, bool show) { } for (uint32 i = 0; i < _objects.size(); i++) { - if (_objects[i]->_type == OBJECT_ENTITY) { + if (_objects[i]->getType() == OBJECT_ENTITY) { AdEntity *ent = (AdEntity *)_objects[i]; - if (ent->_item && strcmp(ent->_item, itemName) == 0) { + if (ent->getItemName() && strcmp(ent->getItemName(), itemName) == 0) { ent->_active = show; } } @@ -2822,7 +2827,7 @@ bool AdScene::getRegionsAt(int x, int y, AdRegion **regionList, int numRegions) } } for (int i = numUsed; i < numRegions; i++) { - regionList[i] = NULL; + regionList[i] = nullptr; } return STATUS_OK; @@ -2840,9 +2845,9 @@ BaseObject *AdScene::getNextAccessObject(BaseObject *currObject) { getSceneObjects(objects, true); if (objects.size() == 0) { - return NULL; + return nullptr; } else { - if (currObject != NULL) { + if (currObject != nullptr) { for (uint32 i = 0; i < objects.size(); i++) { if (objects[i] == currObject) { if (i < objects.size() - 1) { @@ -2855,7 +2860,7 @@ BaseObject *AdScene::getNextAccessObject(BaseObject *currObject) { } return objects[0]; } - return NULL; + return nullptr; } ////////////////////////////////////////////////////////////////////////// @@ -2864,9 +2869,9 @@ BaseObject *AdScene::getPrevAccessObject(BaseObject *currObject) { getSceneObjects(objects, true); if (objects.size() == 0) { - return NULL; + return nullptr; } else { - if (currObject != NULL) { + if (currObject != nullptr) { for (int i = objects.size() - 1; i >= 0; i--) { if (objects[i] == currObject) { if (i > 0) { @@ -2879,7 +2884,7 @@ BaseObject *AdScene::getPrevAccessObject(BaseObject *currObject) { } return objects[objects.size() - 1]; } - return NULL; + return nullptr; } @@ -2957,7 +2962,7 @@ bool AdScene::getRegionObjects(AdRegion *region, BaseArray<AdObject *> &objects, // global objects for (uint32 i = 0; i < adGame->_objects.size(); i++) { obj = adGame->_objects[i]; - if (obj->_active && (obj->_stickRegion == region || region == NULL || (obj->_stickRegion == NULL && region->pointInRegion(obj->_posX, obj->_posY)))) { + if (obj->_active && (obj->_stickRegion == region || region == nullptr || (obj->_stickRegion == nullptr && region->pointInRegion(obj->_posX, obj->_posY)))) { if (interactiveOnly && !obj->_registrable) { continue; } @@ -2969,7 +2974,7 @@ bool AdScene::getRegionObjects(AdRegion *region, BaseArray<AdObject *> &objects, // scene objects for (uint32 i = 0; i < _objects.size(); i++) { obj = _objects[i]; - if (obj->_active && !obj->_editorOnly && (obj->_stickRegion == region || region == NULL || (obj->_stickRegion == NULL && region->pointInRegion(obj->_posX, obj->_posY)))) { + if (obj->_active && !obj->_editorOnly && (obj->_stickRegion == region || region == nullptr || (obj->_stickRegion == nullptr && region->pointInRegion(obj->_posX, obj->_posY)))) { if (interactiveOnly && !obj->_registrable) { continue; } diff --git a/engines/wintermute/ad/ad_scene.h b/engines/wintermute/ad/ad_scene.h index 3b482403b5..cd144b77ef 100644 --- a/engines/wintermute/ad/ad_scene.h +++ b/engines/wintermute/ad/ad_scene.h @@ -67,27 +67,27 @@ public: bool pointInViewport(int x, int y); int getOffsetTop(); int getOffsetLeft(); - bool getViewportSize(int *width = NULL, int *height = NULL); - bool getViewportOffset(int *offsetX = NULL, int *offsetY = NULL); + bool getViewportSize(int32 *width = nullptr, int32 *height = nullptr); + bool getViewportOffset(int32 *offsetX = nullptr, int32 *offsetY = nullptr); BaseViewport *_viewport; BaseFader *_fader; - int _pfPointsNum; + int32 _pfPointsNum; void pfPointsAdd(int x, int y, int distance); void pfPointsStart(); bool _initialized; - bool correctTargetPoint(int startX, int startY, int *x, int *y, bool checkFreeObjects = false, BaseObject *requester = NULL); - bool correctTargetPoint2(int startX, int startY, int *targetX, int *targetY, bool checkFreeObjects, BaseObject *requester); + bool correctTargetPoint(int32 startX, int32 startY, int32 *x, int32 *y, bool checkFreeObjects = false, BaseObject *requester = nullptr); + bool correctTargetPoint2(int32 startX, int32 startY, int32 *targetX, int32 *targetY, bool checkFreeObjects, BaseObject *requester); DECLARE_PERSISTENT(AdScene, BaseObject) - bool displayRegionContent(AdRegion *region = NULL, bool display3DOnly = false); - bool displayRegionContentOld(AdRegion *region = NULL); - static int compareObjs(const void *obj1, const void *obj2); + bool displayRegionContent(AdRegion *region = nullptr, bool display3DOnly = false); + bool displayRegionContentOld(AdRegion *region = nullptr); + static bool compareObjs(const AdObject *obj1, const AdObject *obj2); bool updateFreeObjects(); bool traverseNodes(bool update = false); float getScaleAt(int y); bool sortScaleLevels(); bool sortRotLevels(); - virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); + virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent) override; uint32 getAlphaAt(int x, int y, bool colorCheck = false); bool _paralaxScrolling; void skipTo(int offsetX, int offsetY); @@ -96,16 +96,16 @@ public: void skipToObject(BaseObject *object); void scrollToObject(BaseObject *object); void scrollTo(int offsetX, int offsetY); - virtual bool update(); + virtual bool update() override; bool _autoScroll; - int _targetOffsetTop; - int _targetOffsetLeft; + int32 _targetOffsetTop; + int32 _targetOffsetLeft; - int _scrollPixelsV; + int32 _scrollPixelsV; uint32 _scrollTimeV; uint32 _lastTimeV; - int _scrollPixelsH; + int32 _scrollPixelsH; uint32 _scrollTimeH; uint32 _lastTimeH; @@ -113,11 +113,11 @@ public: uint32 _pfMaxTime; bool initLoop(); void pathFinderStep(); - bool isBlockedAt(int x, int y, bool checkFreeObjects = false, BaseObject *requester = NULL); - bool isWalkableAt(int x, int y, bool checkFreeObjects = false, BaseObject *requester = NULL); + bool isBlockedAt(int x, int y, bool checkFreeObjects = false, BaseObject *requester = nullptr); + bool isWalkableAt(int x, int y, bool checkFreeObjects = false, BaseObject *requester = nullptr); AdLayer *_mainLayer; float getZoomAt(int x, int y); - bool getPath(BasePoint source, BasePoint target, AdPath *path, BaseObject *requester = NULL); + bool getPath(const BasePoint &source, const BasePoint &target, AdPath *path, BaseObject *requester = nullptr); AdScene(BaseGame *inGame); virtual ~AdScene(); BaseArray<AdLayer *> _layers; @@ -125,12 +125,12 @@ public: BaseArray<AdWaypointGroup *> _waypointGroups; bool loadFile(const char *filename); bool loadBuffer(byte *buffer, bool complete = true); - int _width; - int _height; + int32 _width; + int32 _height; bool addObject(AdObject *Object); bool removeObject(AdObject *Object); - int _editorMarginH; - int _editorMarginV; + int32 _editorMarginH; + int32 _editorMarginV; uint32 _editorColFrame; uint32 _editorColEntity; uint32 _editorColRegion; @@ -153,26 +153,26 @@ public: BaseArray<AdRotLevel *> _rotLevels; virtual bool restoreDeviceObjects(); - int getPointsDist(BasePoint p1, BasePoint p2, BaseObject *requester = NULL); + int getPointsDist(const BasePoint &p1, const BasePoint &p2, BaseObject *requester = nullptr); // scripting interface - virtual ScValue *scGetProperty(const Common::String &name); - virtual bool scSetProperty(const char *name, ScValue *value); - virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); - virtual const char *scToString(); + virtual ScValue *scGetProperty(const Common::String &name) override; + virtual bool scSetProperty(const char *name, ScValue *value) override; + virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) override; + virtual const char *scToString() override; private: bool persistState(bool saving = true); - void pfAddWaypointGroup(AdWaypointGroup *Wpt, BaseObject *requester = NULL); + void pfAddWaypointGroup(AdWaypointGroup *Wpt, BaseObject *requester = nullptr); bool _pfReady; BasePoint *_pfTarget; AdPath *_pfTargetPath; BaseObject *_pfRequester; BaseArray<AdPathPoint *> _pfPath; - int _offsetTop; - int _offsetLeft; + int32 _offsetTop; + int32 _offsetLeft; }; diff --git a/engines/wintermute/ad/ad_scene_node.cpp b/engines/wintermute/ad/ad_scene_node.cpp index d0202236fd..e9b80b3cc8 100644 --- a/engines/wintermute/ad/ad_scene_node.cpp +++ b/engines/wintermute/ad/ad_scene_node.cpp @@ -36,18 +36,18 @@ IMPLEMENT_PERSISTENT(AdSceneNode, false) ////////////////////////////////////////////////////////////////////////// AdSceneNode::AdSceneNode(BaseGame *inGame) : BaseObject(inGame) { _type = OBJECT_NONE; - _region = NULL; - _entity = NULL; + _region = nullptr; + _entity = nullptr; } ////////////////////////////////////////////////////////////////////////// AdSceneNode::~AdSceneNode() { _gameRef->unregisterObject(_region); - _region = NULL; + _region = nullptr; _gameRef->unregisterObject(_entity); - _entity = NULL; + _entity = nullptr; } @@ -72,8 +72,8 @@ bool AdSceneNode::persist(BasePersistenceManager *persistMgr) { BaseObject::persist(persistMgr); - persistMgr->transfer(TMEMBER(_entity)); - persistMgr->transfer(TMEMBER(_region)); + persistMgr->transferPtr(TMEMBER_PTR(_entity)); + persistMgr->transferPtr(TMEMBER_PTR(_region)); persistMgr->transfer(TMEMBER_INT(_type)); return STATUS_OK; diff --git a/engines/wintermute/ad/ad_scene_state.cpp b/engines/wintermute/ad/ad_scene_state.cpp index 6b34f1af53..8e022ab115 100644 --- a/engines/wintermute/ad/ad_scene_state.cpp +++ b/engines/wintermute/ad/ad_scene_state.cpp @@ -38,14 +38,14 @@ IMPLEMENT_PERSISTENT(AdSceneState, false) ////////////////////////////////////////////////////////////////////////// AdSceneState::AdSceneState(BaseGame *inGame) : BaseClass(inGame) { - _filename = NULL; + _filename = nullptr; } ////////////////////////////////////////////////////////////////////////// AdSceneState::~AdSceneState() { delete[] _filename; - _filename = NULL; + _filename = nullptr; for (uint32 i = 0; i < _nodeStates.size(); i++) { delete _nodeStates[i]; @@ -72,6 +72,9 @@ void AdSceneState::setFilename(const char *filename) { } } +const char *AdSceneState::getFilename() const { + return _filename; +} ////////////////////////////////////////////////////////////////////////// AdNodeState *AdSceneState::getNodeState(const char *name, bool saving) { @@ -88,7 +91,7 @@ AdNodeState *AdSceneState::getNodeState(const char *name, bool saving) { return ret; } else { - return NULL; + return nullptr; } } diff --git a/engines/wintermute/ad/ad_scene_state.h b/engines/wintermute/ad/ad_scene_state.h index 2b25393c5a..600aa4b581 100644 --- a/engines/wintermute/ad/ad_scene_state.h +++ b/engines/wintermute/ad/ad_scene_state.h @@ -39,9 +39,11 @@ class AdSceneState : public BaseClass { public: AdNodeState *getNodeState(const char *name, bool saving); void setFilename(const char *filename); + const char *getFilename() const; DECLARE_PERSISTENT(AdSceneState, BaseClass) AdSceneState(BaseGame *inGame); virtual ~AdSceneState(); +private: char *_filename; BaseArray<AdNodeState *> _nodeStates; }; diff --git a/engines/wintermute/ad/ad_sentence.cpp b/engines/wintermute/ad/ad_sentence.cpp index cfe4191b07..70a57a624d 100644 --- a/engines/wintermute/ad/ad_sentence.cpp +++ b/engines/wintermute/ad/ad_sentence.cpp @@ -45,27 +45,27 @@ IMPLEMENT_PERSISTENT(AdSentence, false) ////////////////////////////////////////////////////////////////////////// AdSentence::AdSentence(BaseGame *inGame) : BaseClass(inGame) { - _text = NULL; - _stances = NULL; - _tempStance = NULL; + _text = nullptr; + _stances = nullptr; + _tempStance = nullptr; _duration = 0; _startTime = 0; _currentStance = 0; - _font = NULL; + _font = nullptr; _pos.x = _pos.y = 0; - _width = _gameRef->_renderer->_width; + _width = _gameRef->_renderer->getWidth(); _align = (TTextAlign)TAL_CENTER; - _sound = NULL; + _sound = nullptr; _soundStarted = false; - _talkDef = NULL; - _currentSprite = NULL; - _currentSkelAnim = NULL; + _talkDef = nullptr; + _currentSprite = nullptr; + _currentSkelAnim = nullptr; _fixedPos = false; _freezable = true; } @@ -78,15 +78,15 @@ AdSentence::~AdSentence() { delete[] _stances; delete[] _tempStance; delete _talkDef; - _sound = NULL; - _text = NULL; - _stances = NULL; - _tempStance = NULL; - _talkDef = NULL; - - _currentSprite = NULL; // ref only - _currentSkelAnim = NULL; - _font = NULL; // ref only + _sound = nullptr; + _text = nullptr; + _stances = nullptr; + _tempStance = nullptr; + _talkDef = nullptr; + + _currentSprite = nullptr; // ref only + _currentSkelAnim = nullptr; + _font = nullptr; // ref only } @@ -113,7 +113,7 @@ void AdSentence::setStances(const char *stances) { strcpy(_stances, stances); } } else { - _stances = NULL; + _stances = nullptr; } } @@ -133,14 +133,14 @@ char *AdSentence::getNextStance() { ////////////////////////////////////////////////////////////////////////// char *AdSentence::getStance(int stance) { - if (_stances == NULL) { - return NULL; + if (_stances == nullptr) { + return nullptr; } if (_tempStance) { delete[] _tempStance; } - _tempStance = NULL; + _tempStance = nullptr; char *start; char *curr; @@ -150,7 +150,7 @@ char *AdSentence::getStance(int stance) { start = _stances; } else { pos = 0; - start = NULL; + start = nullptr; curr = _stances; while (pos < stance) { if (*curr == '\0') { @@ -166,8 +166,8 @@ char *AdSentence::getStance(int stance) { } } - if (start == NULL) { - return NULL; + if (start == nullptr) { + return nullptr; } while (*start == ' ' && *start != ',' && *start != '\0') { @@ -204,8 +204,8 @@ bool AdSentence::display() { } if (_gameRef->_subtitles) { - int x = _pos.x; - int y = _pos.y; + int32 x = _pos.x; + int32 y = _pos.y; if (!_fixedPos) { x = x - ((AdGame *)_gameRef)->_scene->getOffsetLeft(); @@ -213,9 +213,9 @@ bool AdSentence::display() { } - x = MAX(x, 0); - x = MIN(x, _gameRef->_renderer->_width - _width); - y = MAX(y, 0); + x = MAX<int32>(x, 0); + x = MIN(x, _gameRef->_renderer->getWidth() - _width); + y = MAX<int32>(y, 0); _font->drawText((byte *)_text, x, y, _width, _align); } @@ -247,20 +247,20 @@ bool AdSentence::finish() { ////////////////////////////////////////////////////////////////////////// bool AdSentence::persist(BasePersistenceManager *persistMgr) { - persistMgr->transfer(TMEMBER(_gameRef)); + persistMgr->transferPtr(TMEMBER_PTR(_gameRef)); persistMgr->transfer(TMEMBER_INT(_align)); persistMgr->transfer(TMEMBER(_currentStance)); - persistMgr->transfer(TMEMBER(_currentSprite)); + persistMgr->transferPtr(TMEMBER_PTR(_currentSprite)); persistMgr->transfer(TMEMBER(_currentSkelAnim)); persistMgr->transfer(TMEMBER(_duration)); - persistMgr->transfer(TMEMBER(_font)); + persistMgr->transferPtr(TMEMBER_PTR(_font)); persistMgr->transfer(TMEMBER(_pos)); - persistMgr->transfer(TMEMBER(_sound)); + persistMgr->transferPtr(TMEMBER_PTR(_sound)); persistMgr->transfer(TMEMBER(_soundStarted)); persistMgr->transfer(TMEMBER(_stances)); persistMgr->transfer(TMEMBER(_startTime)); - persistMgr->transfer(TMEMBER(_talkDef)); + persistMgr->transferPtr(TMEMBER_PTR(_talkDef)); persistMgr->transfer(TMEMBER(_tempStance)); persistMgr->transfer(TMEMBER(_text)); persistMgr->transfer(TMEMBER(_width)); @@ -274,8 +274,8 @@ bool AdSentence::persist(BasePersistenceManager *persistMgr) { ////////////////////////////////////////////////////////////////////////// bool AdSentence::setupTalkFile(const char *soundFilename) { delete _talkDef; - _talkDef = NULL; - _currentSprite = NULL; + _talkDef = nullptr; + _currentSprite = nullptr; if (!soundFilename) { return STATUS_OK; @@ -294,7 +294,7 @@ bool AdSentence::setupTalkFile(const char *soundFilename) { _talkDef = new AdTalkDef(_gameRef); if (!_talkDef || DID_FAIL(_talkDef->loadFile(talkDefFileName.c_str()))) { delete _talkDef; - _talkDef = NULL; + _talkDef = nullptr; return STATUS_FAILED; } //_gameRef->LOG(0, "Using .talk file: %s", TalkDefFile); @@ -314,9 +314,9 @@ bool AdSentence::update(TDirection dir) { /* if (_sound) CurrentTime = _sound->GetPositionTime(); - else CurrentTime = _gameRef->_timer - _startTime; + else CurrentTime = _gameRef->getTimer()->getTime() - _startTime; */ - currentTime = _gameRef->_timer - _startTime; + currentTime = _gameRef->getTimer()->getTime() - _startTime; bool talkNodeFound = false; for (uint32 i = 0; i < _talkDef->_nodes.size(); i++) { @@ -345,7 +345,7 @@ bool AdSentence::update(TDirection dir) { } _currentSprite = newSprite; } else { - _currentSprite = NULL; + _currentSprite = nullptr; } } @@ -355,7 +355,7 @@ bool AdSentence::update(TDirection dir) { ////////////////////////////////////////////////////////////////////////// bool AdSentence::canSkip() { // prevent accidental sentence skipping (TODO make configurable) - return (_gameRef->_timer - _startTime) > 300; + return (_gameRef->getTimer()->getTime() - _startTime) > 300; } } // end of namespace Wintermute diff --git a/engines/wintermute/ad/ad_sentence.h b/engines/wintermute/ad/ad_sentence.h index e7c94030b9..6f255578f7 100644 --- a/engines/wintermute/ad/ad_sentence.h +++ b/engines/wintermute/ad/ad_sentence.h @@ -56,14 +56,14 @@ public: BaseSound *_sound; TTextAlign _align; bool display(); - int _width; + int32 _width; Point32 _pos; BaseFont *_font; char *getNextStance(); char *getCurrentStance(); void setStances(const char *stances); void setText(const char *text); - int _currentStance; + int32 _currentStance; uint32 _startTime; char *_stances; char *_text; diff --git a/engines/wintermute/ad/ad_sprite_set.cpp b/engines/wintermute/ad/ad_sprite_set.cpp index 345b483a8f..6c802c4863 100644 --- a/engines/wintermute/ad/ad_sprite_set.cpp +++ b/engines/wintermute/ad/ad_sprite_set.cpp @@ -42,7 +42,7 @@ AdSpriteSet::AdSpriteSet(BaseGame *inGame, BaseObject *owner) : BaseObject(inGam _owner = owner; for (int i = 0; i < NUM_DIRECTIONS; i++) { - _sprites[i] = NULL; + _sprites[i] = nullptr; } } @@ -51,17 +51,17 @@ AdSpriteSet::AdSpriteSet(BaseGame *inGame, BaseObject *owner) : BaseObject(inGam AdSpriteSet::~AdSpriteSet() { for (int i = 0; i < NUM_DIRECTIONS; i++) { delete _sprites[i]; - _sprites[i] = NULL; + _sprites[i] = nullptr; } - _owner = NULL; + _owner = nullptr; } ////////////////////////////////////////////////////////////////////////// bool AdSpriteSet::loadFile(const char *filename, int lifeTime, TSpriteCacheType cacheType) { byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); - if (buffer == NULL) { + if (buffer == nullptr) { _gameRef->LOG(0, "AdSpriteSet::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -121,7 +121,7 @@ bool AdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteC buffer = params; } - BaseSprite *spr = NULL; + BaseSprite *spr = nullptr; while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: @@ -136,7 +136,7 @@ bool AdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteC case TOKEN_LEFT: delete _sprites[DI_LEFT]; - _sprites[DI_LEFT] = NULL; + _sprites[DI_LEFT] = nullptr; spr = new BaseSprite(_gameRef, _owner); if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, cacheType))) { cmd = PARSERR_GENERIC; @@ -147,7 +147,7 @@ bool AdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteC case TOKEN_RIGHT: delete _sprites[DI_RIGHT]; - _sprites[DI_RIGHT] = NULL; + _sprites[DI_RIGHT] = nullptr; spr = new BaseSprite(_gameRef, _owner); if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, cacheType))) { cmd = PARSERR_GENERIC; @@ -158,7 +158,7 @@ bool AdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteC case TOKEN_UP: delete _sprites[DI_UP]; - _sprites[DI_UP] = NULL; + _sprites[DI_UP] = nullptr; spr = new BaseSprite(_gameRef, _owner); if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, cacheType))) { cmd = PARSERR_GENERIC; @@ -169,7 +169,7 @@ bool AdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteC case TOKEN_DOWN: delete _sprites[DI_DOWN]; - _sprites[DI_DOWN] = NULL; + _sprites[DI_DOWN] = nullptr; spr = new BaseSprite(_gameRef, _owner); if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, cacheType))) { cmd = PARSERR_GENERIC; @@ -180,7 +180,7 @@ bool AdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteC case TOKEN_UP_LEFT: delete _sprites[DI_UPLEFT]; - _sprites[DI_UPLEFT] = NULL; + _sprites[DI_UPLEFT] = nullptr; spr = new BaseSprite(_gameRef, _owner); if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, cacheType))) { cmd = PARSERR_GENERIC; @@ -191,7 +191,7 @@ bool AdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteC case TOKEN_UP_RIGHT: delete _sprites[DI_UPRIGHT]; - _sprites[DI_UPRIGHT] = NULL; + _sprites[DI_UPRIGHT] = nullptr; spr = new BaseSprite(_gameRef, _owner); if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, cacheType))) { cmd = PARSERR_GENERIC; @@ -202,7 +202,7 @@ bool AdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteC case TOKEN_DOWN_LEFT: delete _sprites[DI_DOWNLEFT]; - _sprites[DI_DOWNLEFT] = NULL; + _sprites[DI_DOWNLEFT] = nullptr; spr = new BaseSprite(_gameRef, _owner); if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, cacheType))) { cmd = PARSERR_GENERIC; @@ -213,7 +213,7 @@ bool AdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteC case TOKEN_DOWN_RIGHT: delete _sprites[DI_DOWNRIGHT]; - _sprites[DI_DOWNRIGHT] = NULL; + _sprites[DI_DOWNRIGHT] = nullptr; spr = new BaseSprite(_gameRef, _owner); if (!spr || DID_FAIL(spr->loadFile((char *)params, lifeTime, cacheType))) { cmd = PARSERR_GENERIC; @@ -249,9 +249,9 @@ bool AdSpriteSet::persist(BasePersistenceManager *persistMgr) { BaseObject::persist(persistMgr); - persistMgr->transfer(TMEMBER(_owner)); + persistMgr->transferPtr(TMEMBER_PTR(_owner)); for (int i = 0; i < NUM_DIRECTIONS; i++) { - persistMgr->transfer("", &_sprites[i]); + persistMgr->transferPtr("", &_sprites[i]); } return STATUS_OK; @@ -268,12 +268,12 @@ BaseSprite *AdSpriteSet::getSprite(TDirection direction) { dir = NUM_DIRECTIONS - 1; } - BaseSprite *ret = NULL; + BaseSprite *ret = nullptr; // find nearest set sprite int numSteps = 0; for (int i = dir; i >= 0; i--) { - if (_sprites[i] != NULL) { + if (_sprites[i] != nullptr) { ret = _sprites[i]; numSteps = dir - i; break; @@ -281,8 +281,8 @@ BaseSprite *AdSpriteSet::getSprite(TDirection direction) { } for (int i = dir; i < NUM_DIRECTIONS; i++) { - if (_sprites[i] != NULL) { - if (ret == NULL || numSteps > i - dir) { + if (_sprites[i] != nullptr) { + if (ret == nullptr || numSteps > i - dir) { return _sprites[i]; } else { return ret; diff --git a/engines/wintermute/ad/ad_sprite_set.h b/engines/wintermute/ad/ad_sprite_set.h index ba5da0ff2e..61043aa3d6 100644 --- a/engines/wintermute/ad/ad_sprite_set.h +++ b/engines/wintermute/ad/ad_sprite_set.h @@ -37,11 +37,11 @@ class BaseSprite; class AdSpriteSet : public BaseObject { public: bool containsSprite(BaseSprite *sprite); - virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent = 0); + virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent = 0) override; BaseSprite *getSprite(TDirection direction); DECLARE_PERSISTENT(AdSpriteSet, BaseObject) BaseObject *_owner; - AdSpriteSet(BaseGame *inGame, BaseObject *owner = NULL); + AdSpriteSet(BaseGame *inGame, BaseObject *owner = nullptr); virtual ~AdSpriteSet(); bool loadFile(const char *filename, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); bool loadBuffer(byte *buffer, bool complete = true, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); diff --git a/engines/wintermute/ad/ad_talk_def.cpp b/engines/wintermute/ad/ad_talk_def.cpp index a85cd7f986..bf72b2916b 100644 --- a/engines/wintermute/ad/ad_talk_def.cpp +++ b/engines/wintermute/ad/ad_talk_def.cpp @@ -42,11 +42,11 @@ IMPLEMENT_PERSISTENT(AdTalkDef, false) ////////////////////////////////////////////////////////////////////////// AdTalkDef::AdTalkDef(BaseGame *inGame) : BaseObject(inGame) { - _defaultSpriteFilename = NULL; - _defaultSprite = NULL; + _defaultSpriteFilename = nullptr; + _defaultSprite = nullptr; - _defaultSpriteSetFilename = NULL; - _defaultSpriteSet = NULL; + _defaultSpriteSetFilename = nullptr; + _defaultSpriteSet = nullptr; } @@ -59,20 +59,20 @@ AdTalkDef::~AdTalkDef() { delete[] _defaultSpriteFilename; delete _defaultSprite; - _defaultSpriteFilename = NULL; - _defaultSprite = NULL; + _defaultSpriteFilename = nullptr; + _defaultSprite = nullptr; delete[] _defaultSpriteSetFilename; delete _defaultSpriteSet; - _defaultSpriteSetFilename = NULL; - _defaultSpriteSet = NULL; + _defaultSpriteSetFilename = nullptr; + _defaultSpriteSet = nullptr; } ////////////////////////////////////////////////////////////////////////// bool AdTalkDef::loadFile(const char *filename) { byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); - if (buffer == NULL) { + if (buffer == nullptr) { _gameRef->LOG(0, "AdTalkDef::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -138,7 +138,7 @@ bool AdTalkDef::loadBuffer(byte *buffer, bool complete) { _nodes.add(node); } else { delete node; - node = NULL; + node = nullptr; cmd = PARSERR_GENERIC; } } @@ -157,7 +157,7 @@ bool AdTalkDef::loadBuffer(byte *buffer, bool complete) { _defaultSpriteSet = new AdSpriteSet(_gameRef); if (!_defaultSpriteSet || DID_FAIL(_defaultSpriteSet->loadBuffer(params, false))) { delete _defaultSpriteSet; - _defaultSpriteSet = NULL; + _defaultSpriteSet = nullptr; cmd = PARSERR_GENERIC; } } @@ -181,8 +181,8 @@ bool AdTalkDef::loadBuffer(byte *buffer, bool complete) { delete _defaultSprite; delete _defaultSpriteSet; - _defaultSprite = NULL; - _defaultSpriteSet = NULL; + _defaultSprite = nullptr; + _defaultSpriteSet = nullptr; if (_defaultSpriteFilename) { _defaultSprite = new BaseSprite(_gameRef); @@ -208,9 +208,9 @@ bool AdTalkDef::persist(BasePersistenceManager *persistMgr) { BaseObject::persist(persistMgr); - persistMgr->transfer(TMEMBER(_defaultSprite)); + persistMgr->transferPtr(TMEMBER_PTR(_defaultSprite)); persistMgr->transfer(TMEMBER(_defaultSpriteFilename)); - persistMgr->transfer(TMEMBER(_defaultSpriteSet)); + persistMgr->transferPtr(TMEMBER_PTR(_defaultSpriteSet)); persistMgr->transfer(TMEMBER(_defaultSpriteSetFilename)); _nodes.persist(persistMgr); @@ -250,7 +250,7 @@ bool AdTalkDef::loadDefaultSprite() { _defaultSprite = new BaseSprite(_gameRef); if (!_defaultSprite || DID_FAIL(_defaultSprite->loadFile(_defaultSpriteFilename))) { delete _defaultSprite; - _defaultSprite = NULL; + _defaultSprite = nullptr; return STATUS_FAILED; } else { return STATUS_OK; @@ -259,7 +259,7 @@ bool AdTalkDef::loadDefaultSprite() { _defaultSpriteSet = new AdSpriteSet(_gameRef); if (!_defaultSpriteSet || DID_FAIL(_defaultSpriteSet->loadFile(_defaultSpriteSetFilename))) { delete _defaultSpriteSet; - _defaultSpriteSet = NULL; + _defaultSpriteSet = nullptr; return STATUS_FAILED; } else { return STATUS_OK; @@ -278,7 +278,7 @@ BaseSprite *AdTalkDef::getDefaultSprite(TDirection dir) { } else if (_defaultSpriteSet) { return _defaultSpriteSet->getSprite(dir); } else { - return NULL; + return nullptr; } } diff --git a/engines/wintermute/ad/ad_talk_def.h b/engines/wintermute/ad/ad_talk_def.h index d147212775..2375360d89 100644 --- a/engines/wintermute/ad/ad_talk_def.h +++ b/engines/wintermute/ad/ad_talk_def.h @@ -50,7 +50,7 @@ public: BaseArray<AdTalkNode *> _nodes; char *_defaultSpriteFilename; BaseSprite *_defaultSprite; - virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent = 0); + virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent = 0) override; }; } // end of namespace Wintermute diff --git a/engines/wintermute/ad/ad_talk_holder.cpp b/engines/wintermute/ad/ad_talk_holder.cpp index cca4fdc2cb..33deab7805 100644 --- a/engines/wintermute/ad/ad_talk_holder.cpp +++ b/engines/wintermute/ad/ad_talk_holder.cpp @@ -43,14 +43,14 @@ IMPLEMENT_PERSISTENT(AdTalkHolder, false) ////////////////////////////////////////////////////////////////////////// AdTalkHolder::AdTalkHolder(BaseGame *inGame) : AdObject(inGame) { - _sprite = NULL; + _sprite = nullptr; } ////////////////////////////////////////////////////////////////////////// AdTalkHolder::~AdTalkHolder() { delete _sprite; - _sprite = NULL; + _sprite = nullptr; for (uint32 i = 0; i < _talkSprites.size(); i++) { delete _talkSprites[i]; @@ -65,7 +65,7 @@ AdTalkHolder::~AdTalkHolder() { ////////////////////////////////////////////////////////////////////////// BaseSprite *AdTalkHolder::getTalkStance(const char *stance) { - BaseSprite *ret = NULL; + BaseSprite *ret = nullptr; // forced stance? @@ -78,7 +78,7 @@ BaseSprite *AdTalkHolder::getTalkStance(const char *stance) { if (DID_FAIL(res)) { _gameRef->LOG(res, "AdTalkHolder::GetTalkStance: error loading talk sprite (object:\"%s\" sprite:\"%s\")", getName(), _forcedTalkAnimName); delete _animSprite; - _animSprite = NULL; + _animSprite = nullptr; } else { return _animSprite; } @@ -86,7 +86,7 @@ BaseSprite *AdTalkHolder::getTalkStance(const char *stance) { } - if (stance != NULL) { + if (stance != nullptr) { // search special talk stances for (uint32 i = 0; i < _talkSpritesEx.size(); i++) { if (scumm_stricmp(_talkSpritesEx[i]->getName(), stance) == 0) { @@ -94,7 +94,7 @@ BaseSprite *AdTalkHolder::getTalkStance(const char *stance) { break; } } - if (ret == NULL) { + if (ret == nullptr) { // serach generic talk stances for (uint32 i = 0; i < _talkSprites.size(); i++) { if (scumm_stricmp(_talkSprites[i]->getName(), stance) == 0) { @@ -106,7 +106,7 @@ BaseSprite *AdTalkHolder::getTalkStance(const char *stance) { } // not a valid stance? get a random one - if (ret == NULL) { + if (ret == nullptr) { if (_talkSprites.size() < 1) { ret = _sprite; } else { @@ -138,12 +138,12 @@ bool AdTalkHolder::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisS } delete _sprite; - _sprite = NULL; + _sprite = nullptr; if (val->isNULL()) { - _sprite = NULL; + _sprite = nullptr; if (setCurrent) { - _currentSprite = NULL; + _currentSprite = nullptr; } stack->pushBool(true); } else { @@ -355,7 +355,7 @@ bool AdTalkHolder::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// // Item ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Item")==0){ + if (strcmp(name, "Item")==0) { SetItem(value->getString()); return STATUS_OK; } @@ -392,7 +392,7 @@ bool AdTalkHolder::saveAsText(BaseDynamicBuffer *buffer, int indent) { bool AdTalkHolder::persist(BasePersistenceManager *persistMgr) { AdObject::persist(persistMgr); - persistMgr->transfer(TMEMBER(_sprite)); + persistMgr->transferPtr(TMEMBER_PTR(_sprite)); _talkSprites.persist(persistMgr); _talkSpritesEx.persist(persistMgr); diff --git a/engines/wintermute/ad/ad_talk_holder.h b/engines/wintermute/ad/ad_talk_holder.h index d52ebf63c0..501acbc885 100644 --- a/engines/wintermute/ad/ad_talk_holder.h +++ b/engines/wintermute/ad/ad_talk_holder.h @@ -37,7 +37,7 @@ class AdTalkHolder : public AdObject { public: DECLARE_PERSISTENT(AdTalkHolder, AdObject) virtual BaseSprite *getTalkStance(const char *stance); - virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); + virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent) override; BaseSprite *_sprite; BaseArray<BaseSprite *> _talkSprites; BaseArray<BaseSprite *> _talkSpritesEx; @@ -45,10 +45,10 @@ public: virtual ~AdTalkHolder(); // scripting interface - virtual ScValue *scGetProperty(const Common::String &name); - virtual bool scSetProperty(const char *name, ScValue *value); - virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); - virtual const char *scToString(); + virtual ScValue *scGetProperty(const Common::String &name) override; + virtual bool scSetProperty(const char *name, ScValue *value) override; + virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) override; + virtual const char *scToString() override; }; diff --git a/engines/wintermute/ad/ad_talk_node.cpp b/engines/wintermute/ad/ad_talk_node.cpp index c909ee27ff..f03c24ea94 100644 --- a/engines/wintermute/ad/ad_talk_node.cpp +++ b/engines/wintermute/ad/ad_talk_node.cpp @@ -39,11 +39,11 @@ IMPLEMENT_PERSISTENT(AdTalkNode, false) ////////////////////////////////////////////////////////////////////////// AdTalkNode::AdTalkNode(BaseGame *inGame) : BaseClass(inGame) { - _sprite = NULL; - _spriteFilename = NULL; - _spriteSet = NULL; - _spriteSetFilename = NULL; - _comment = NULL; + _sprite = nullptr; + _spriteFilename = nullptr; + _spriteSet = nullptr; + _spriteSetFilename = nullptr; + _comment = nullptr; _startTime = _endTime = 0; _playToEnd = false; @@ -58,11 +58,11 @@ AdTalkNode::~AdTalkNode() { delete[] _spriteSetFilename; delete _spriteSet; delete _comment; - _spriteFilename = NULL; - _sprite = NULL; - _spriteSetFilename = NULL; - _spriteSet = NULL; - _comment = NULL; + _spriteFilename = nullptr; + _sprite = nullptr; + _spriteSetFilename = nullptr; + _spriteSet = nullptr; + _comment = nullptr; } @@ -123,7 +123,7 @@ bool AdTalkNode::loadBuffer(byte *buffer, bool complete) { _spriteSet = new AdSpriteSet(_gameRef); if (!_spriteSet || DID_FAIL(_spriteSet->loadBuffer(params, false))) { delete _spriteSet; - _spriteSet = NULL; + _spriteSet = nullptr; cmd = PARSERR_GENERIC; } } @@ -195,9 +195,9 @@ bool AdTalkNode::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_startTime)); persistMgr->transfer(TMEMBER(_endTime)); persistMgr->transfer(TMEMBER(_playToEnd)); - persistMgr->transfer(TMEMBER(_sprite)); + persistMgr->transferPtr(TMEMBER_PTR(_sprite)); persistMgr->transfer(TMEMBER(_spriteFilename)); - persistMgr->transfer(TMEMBER(_spriteSet)); + persistMgr->transferPtr(TMEMBER_PTR(_spriteSet)); persistMgr->transfer(TMEMBER(_spriteSetFilename)); return STATUS_OK; @@ -240,7 +240,7 @@ bool AdTalkNode::loadSprite() { _sprite = new BaseSprite(_gameRef); if (!_sprite || DID_FAIL(_sprite->loadFile(_spriteFilename))) { delete _sprite; - _sprite = NULL; + _sprite = nullptr; return STATUS_FAILED; } else { return STATUS_OK; @@ -249,7 +249,7 @@ bool AdTalkNode::loadSprite() { _spriteSet = new AdSpriteSet(_gameRef); if (!_spriteSet || DID_FAIL(_spriteSet->loadFile(_spriteSetFilename))) { delete _spriteSet; - _spriteSet = NULL; + _spriteSet = nullptr; return STATUS_FAILED; } else { return STATUS_OK; @@ -264,9 +264,9 @@ bool AdTalkNode::loadSprite() { bool AdTalkNode::isInTimeInterval(uint32 time, TDirection dir) { if (time >= _startTime) { if (_playToEnd) { - if ((_spriteFilename && _sprite == NULL) || (_sprite && _sprite->isFinished() == false)) { + if ((_spriteFilename && _sprite == nullptr) || (_sprite && _sprite->isFinished() == false)) { return true; - } else if ((_spriteSetFilename && _spriteSet == NULL) || (_spriteSet && _spriteSet->getSprite(dir) && _spriteSet->getSprite(dir)->isFinished() == false)) { + } else if ((_spriteSetFilename && _spriteSet == nullptr) || (_spriteSet && _spriteSet->getSprite(dir) && _spriteSet->getSprite(dir)->isFinished() == false)) { return true; } else { return false; @@ -288,7 +288,7 @@ BaseSprite *AdTalkNode::getSprite(TDirection dir) { } else if (_spriteSet) { return _spriteSet->getSprite(dir); } else { - return NULL; + return nullptr; } } diff --git a/engines/wintermute/ad/ad_talk_node.h b/engines/wintermute/ad/ad_talk_node.h index 7dfd861f85..012fa2133e 100644 --- a/engines/wintermute/ad/ad_talk_node.h +++ b/engines/wintermute/ad/ad_talk_node.h @@ -47,7 +47,7 @@ public: AdTalkNode(BaseGame *inGame); virtual ~AdTalkNode(); bool loadBuffer(byte *buffer, bool complete = true); - virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent = 0); + virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent = 0) override; char *_spriteFilename; BaseSprite *_sprite; uint32 _startTime; diff --git a/engines/wintermute/ad/ad_waypoint_group.cpp b/engines/wintermute/ad/ad_waypoint_group.cpp index 81493ce769..96dece34b8 100644 --- a/engines/wintermute/ad/ad_waypoint_group.cpp +++ b/engines/wintermute/ad/ad_waypoint_group.cpp @@ -67,7 +67,7 @@ void AdWaypointGroup::cleanup() { ////////////////////////////////////////////////////////////////////////// bool AdWaypointGroup::loadFile(const char *filename) { byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); - if (buffer == NULL) { + if (buffer == nullptr) { _gameRef->LOG(0, "AdWaypointGroup::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } diff --git a/engines/wintermute/ad/ad_waypoint_group.h b/engines/wintermute/ad/ad_waypoint_group.h index 13d6bbadd7..79b28e0d22 100644 --- a/engines/wintermute/ad/ad_waypoint_group.h +++ b/engines/wintermute/ad/ad_waypoint_group.h @@ -35,22 +35,25 @@ namespace Wintermute { class BasePoint; class AdWaypointGroup : public BaseObject { public: - float _lastMimicScale; - int _lastMimicX; - int _lastMimicY; void cleanup(); bool mimic(AdWaypointGroup *wpt, float scale = 100.0f, int x = 0, int y = 0); DECLARE_PERSISTENT(AdWaypointGroup, BaseObject) - virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); - bool _active; + virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent) override; AdWaypointGroup(BaseGame *inGame); bool loadFile(const char *filename); bool loadBuffer(byte *buffer, bool complete = true); virtual ~AdWaypointGroup(); + + bool _active; BaseArray<BasePoint *> _points; - int _editorSelectedPoint; + virtual ScValue *scGetProperty(const Common::String &name); virtual bool scSetProperty(const char *name, ScValue *value); +private: + int32 _editorSelectedPoint; + float _lastMimicScale; + int32 _lastMimicX; + int32 _lastMimicY; }; } // end of namespace Wintermute |