diff options
Diffstat (limited to 'engines/wintermute/ad')
38 files changed, 709 insertions, 604 deletions
diff --git a/engines/wintermute/ad/ad_actor.cpp b/engines/wintermute/ad/ad_actor.cpp index d175855d1e..1346a090f6 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 { @@ -753,10 +753,10 @@ bool AdActor::update() { } 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)) { + 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; @@ -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 { @@ -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..bcec9db319 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); diff --git a/engines/wintermute/ad/ad_entity.cpp b/engines/wintermute/ad/ad_entity.cpp index 9af7e034ca..259b68f291 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; } @@ -613,10 +628,10 @@ bool AdEntity::update() { } 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)) { + 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(); @@ -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..94921aaa27 100644 --- a/engines/wintermute/ad/ad_entity.h +++ b/engines/wintermute/ad/ad_entity.h @@ -37,11 +37,7 @@ 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(); @@ -53,14 +49,23 @@ public: virtual ~AdEntity(); bool loadFile(const char *filename); bool loadBuffer(byte *buffer, bool complete = true); - TEntityType _subtype; + + int32 getWalkToX() const; + int32 getWalkToY() const; + TDirection getWalkToDir() const; + const char* getItemName() 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(); - +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..b9775ba7d1 100644 --- a/engines/wintermute/ad/ad_game.cpp +++ b/engines/wintermute/ad/ad_game.cpp @@ -69,22 +69,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 +94,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 +122,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 +139,7 @@ bool AdGame::cleanup() { unregisterObject(_scene); - _scene = NULL; + _scene = nullptr; // remove items for (uint32 i = 0; i < _items.size(); i++) { @@ -150,7 +150,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 +160,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 +173,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 +207,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 +258,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 +297,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 +385,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 +402,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 +463,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 +485,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()) { @@ -542,7 +542,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 +584,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 +617,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 +639,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 +651,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 +754,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 +777,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 +797,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; @@ -983,10 +983,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 +995,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 +1036,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 +1066,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 +1158,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 +1242,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 +1316,7 @@ bool AdGame::loadBuffer(byte *buffer, bool complete) { registerObject(_responseBox); } else { delete _responseBox; - _responseBox = NULL; + _responseBox = nullptr; cmd = PARSERR_GENERIC; } break; @@ -1328,7 +1328,7 @@ bool AdGame::loadBuffer(byte *buffer, bool complete) { registerObject(_inventoryBox); } else { delete _inventoryBox; - _inventoryBox = NULL; + _inventoryBox = nullptr; cmd = PARSERR_GENERIC; } break; @@ -1338,7 +1338,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; @@ -1456,7 +1456,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 +1469,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 +1482,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); @@ -1499,7 +1499,7 @@ 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); + BaseGame::getVersion(verMajor, verMinor, nullptr, nullptr); if (extMajor) { *extMajor = 0; @@ -1515,7 +1515,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 +1567,7 @@ bool AdGame::loadItemsBuffer(byte *buffer, bool merge) { addItem(item); } else { delete item; - item = NULL; + item = nullptr; cmd = PARSERR_GENERIC; } } @@ -1599,7 +1599,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 +1615,7 @@ AdSceneState *AdGame::getSceneState(const char *filename, bool saving) { return ret; } else { delete[] filenameCor; - return NULL; + return nullptr; } } @@ -1635,7 +1635,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 +1689,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 +1703,7 @@ bool AdGame::endDlgBranch(const char *branchName, const char *scriptName, const } } - if (name == NULL) { + if (name == nullptr) { return STATUS_OK; } @@ -1719,7 +1719,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); } @@ -1760,7 +1760,7 @@ 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; } @@ -1768,10 +1768,10 @@ bool AdGame::addBranchResponse(int id) { ////////////////////////////////////////////////////////////////////////// bool AdGame::branchResponseUsed(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 < _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]->_context == nullptr) || scumm_stricmp(context, _responsesBranch[i]->_context) == 0) { return true; } } @@ -1787,7 +1787,7 @@ 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; } @@ -1795,11 +1795,11 @@ bool AdGame::addGameResponse(int id) { ////////////////////////////////////////////////////////////////////////// bool AdGame::gameResponseUsed(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++) { 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->_context == nullptr) || ((context != nullptr && respContext->_context != nullptr) && scumm_stricmp(context, respContext->_context) == 0)) { return true; } } @@ -1810,11 +1810,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]->_context == nullptr) || scumm_stricmp(context, _responsesGame[i]->_context) == 0) { delete _responsesGame[i]; _responsesGame.remove_at(i); break; @@ -1824,7 +1824,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]->_context == nullptr) || scumm_stricmp(context, _responsesBranch[i]->_context) == 0) { delete _responsesBranch[i]; _responsesBranch.remove_at(i); break; @@ -1863,7 +1863,7 @@ bool AdGame::displayContent(bool doUpdate, bool displayAll) { } if (_theoraPlayer->isFinished()) { delete _theoraPlayer; - _theoraPlayer = NULL; + _theoraPlayer = nullptr; } } else { @@ -1912,7 +1912,7 @@ bool AdGame::displayContent(bool doUpdate, bool displayAll) { _loadingIcon->display(_loadingIconX, _loadingIconY); if (!_loadingIconPersistent) { delete _loadingIcon; - _loadingIcon = NULL; + _loadingIcon = nullptr; } } @@ -1965,7 +1965,7 @@ AdItem *AdGame::getItemByName(const char *name) { return _items[i]; } } - return NULL; + return nullptr; } @@ -2026,7 +2026,7 @@ bool AdGame::deleteItem(AdItem *item) { } if (_selectedItem == item) { - _selectedItem = NULL; + _selectedItem = nullptr; } _scene->handleItemAssociations(item->getName(), false); @@ -2115,7 +2115,7 @@ char *AdGame::findSpeechFile(char *stringID) { } } delete[] ret; - return NULL; + return nullptr; } @@ -2145,14 +2145,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 +2168,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 +2198,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 +2229,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 +2246,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"); @@ -2272,7 +2272,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_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..f226a65612 100644 --- a/engines/wintermute/ad/ad_inventory.h +++ b/engines/wintermute/ad/ad_inventory.h @@ -40,7 +40,7 @@ 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; diff --git a/engines/wintermute/ad/ad_inventory_box.cpp b/engines/wintermute/ad/ad_inventory_box.cpp index 7ae8ff8d69..194d975155 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; } @@ -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); diff --git a/engines/wintermute/ad/ad_item.cpp b/engines/wintermute/ad/ad_item.cpp index 427b1c7db4..8534956120 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; } @@ -379,10 +379,10 @@ bool AdItem::update() { } 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)) { + 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()); } 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_node_state.cpp b/engines/wintermute/ad/ad_node_state.cpp index 493156c750..34e220569f 100644 --- a/engines/wintermute/ad/ad_node_state.cpp +++ b/engines/wintermute/ad/ad_node_state.cpp @@ -42,14 +42,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 +58,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 +71,7 @@ AdNodeState::~AdNodeState() { ////////////////////////////////////////////////////////////////////////// void AdNodeState::setName(const char *name) { delete[] _name; - _name = NULL; + _name = nullptr; BaseUtils::setString(&_name, name); } @@ -79,7 +79,7 @@ void AdNodeState::setName(const char *name) { ////////////////////////////////////////////////////////////////////////// void AdNodeState::setFilename(const char *filename) { delete[] _filename; - _filename = NULL; + _filename = nullptr; BaseUtils::setString(&_filename, filename); } @@ -87,7 +87,7 @@ void AdNodeState::setFilename(const char *filename) { ////////////////////////////////////////////////////////////////////////// void AdNodeState::setCursor(const char *filename) { delete[] _cursor; - _cursor = NULL; + _cursor = nullptr; BaseUtils::setString(&_cursor, filename); } @@ -132,7 +132,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..a41ed9fbc3 100644 --- a/engines/wintermute/ad/ad_object.cpp +++ b/engines/wintermute/ad/ad_object.cpp @@ -65,27 +65,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 +93,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 +109,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 +136,7 @@ AdObject::~AdObject() { if (_inventory) { ((AdGame *)_gameRef)->unregisterInventory(_inventory); - _inventory = NULL; + _inventory = nullptr; } if (_partEmitter) { @@ -159,7 +159,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 +169,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 +274,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 +286,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 +309,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 +334,7 @@ bool AdObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack } if (!regFound) { - _stickRegion = NULL; + _stickRegion = nullptr; } stack->pushBool(regFound); return STATUS_OK; @@ -348,7 +348,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 +385,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 +512,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 +533,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 +611,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 +645,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 +851,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; } } @@ -878,6 +878,9 @@ int AdObject::getHeight() { } } +TObjectType AdObject::getType() const { + return _type; +} ////////////////////////////////////////////////////////////////////////// void AdObject::talk(const char *text, const char *sound, uint32 duration, const char *stances, TTextAlign Align) { @@ -890,12 +893,12 @@ 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); @@ -904,7 +907,7 @@ void AdObject::talk(const char *text, const char *sound, uint32 duration, const _sentence->_align = Align; _sentence->_startTime = _gameRef->_timer; _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 @@ -1009,9 +1012,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(); } @@ -1154,7 +1157,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 +1180,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..39480e3446 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(); 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 void talk(const char *text, const char *sound = nullptr, uint32 duration = 0, const char *stances = nullptr, TTextAlign align = TAL_CENTER); virtual int getHeight(); - AdSentence *_sentence; + bool setFont(const char *filename); virtual bool update(); virtual bool display(); + 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]; // 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; - 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; + int _partOffsetX; + int _partOffsetY; + bool _subtitlesModRelative; + bool _subtitlesModXCenter; + int _subtitlesModX; + int _subtitlesModY; + int _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..afdd29828c 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; } } diff --git a/engines/wintermute/ad/ad_path_point.cpp b/engines/wintermute/ad/ad_path_point.cpp index a36648eb69..f3ccd264b1 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; } 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..960dde5f15 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); + 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(); +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..e4993b9ad4 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; diff --git a/engines/wintermute/ad/ad_response.h b/engines/wintermute/ad/ad_response.h index 0ba88cf2e8..2119067d3e 100644 --- a/engines/wintermute/ad/ad_response.h +++ b/engines/wintermute/ad/ad_response.h @@ -43,7 +43,7 @@ public: bool setIconHover(const char *filename); bool setIconPressed(const char *filename); void setText(const char *text); - int _iD; + int32 _iD; BaseSprite *_icon; BaseSprite *_iconHover; BaseSprite *_iconPressed; diff --git a/engines/wintermute/ad/ad_response_box.cpp b/engines/wintermute/ad/ad_response_box.cpp index fb31aa0bb8..c891d2a019 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; @@ -160,8 +163,8 @@ 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->_font = (_font == nullptr) ? _gameRef->getSystemFont() : _font; + btn->_fontHover = (_fontHover == nullptr) ? _gameRef->getSystemFont() : _fontHover; btn->_fontPress = btn->_fontHover; btn->_align = _align; @@ -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; @@ -548,7 +551,7 @@ bool AdResponseBox::listen(BaseScriptHolder *param1, uint32 param2) { _waitingScript->_stack->pushInt(_responses[param2]->_iD); } handleResponse(_responses[param2]); - _waitingScript = NULL; + _waitingScript = nullptr; _gameRef->_state = GAME_RUNNING; ((AdGame *)_gameRef)->_stateEx = GAME_NORMAL; _ready = true; @@ -627,6 +630,30 @@ 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(AdResponse *response) { + _responses.add(response); +} + +int32 AdResponseBox::getIdForResponseNum(uint32 num) const { + assert(num < _responses.size()); + return _responses[num]->_iD; +} + +bool AdResponseBox::handleResponseNum(uint32 num) { + return handleResponse(_responses[num]); +} ////////////////////////////////////////////////////////////////////////// bool AdResponseBox::handleResponse(AdResponse *response) { @@ -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..3b180062b6 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); + void addResponse(AdResponse* response); bool handleResponse(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); + + UIWindow *getResponseWindow(); + uint32 getNumResponses() const; +private: + int _spacing; + int _scrollOffset; + BaseFont *_fontHover; + BaseFont *_font; bool _horizontal; Rect32 _responseArea; int _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<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..d87651c178 100644 --- a/engines/wintermute/ad/ad_response_context.cpp +++ b/engines/wintermute/ad/ad_response_context.cpp @@ -36,14 +36,14 @@ IMPLEMENT_PERSISTENT(AdResponseContext, false) ////////////////////////////////////////////////////////////////////////// AdResponseContext::AdResponseContext(BaseGame *inGame) : BaseClass(inGame) { _id = 0; - _context = NULL; + _context = nullptr; } ////////////////////////////////////////////////////////////////////////// AdResponseContext::~AdResponseContext() { delete[] _context; - _context = NULL; + _context = nullptr; } @@ -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_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_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..5c206423cf 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); 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..f305c2f60e 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,7 +182,7 @@ void AdScene::cleanup() { _objects.clear(); delete _viewport; - _viewport = NULL; + _viewport = nullptr; setDefaults(); } @@ -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 { @@ -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,7 +749,7 @@ 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; @@ -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); } @@ -932,24 +932,34 @@ bool AdScene::traverseNodes(bool doUpdate) { if (_autoScroll) { // adjust horizontal scroll if (_gameRef->_timer - _lastTimeH >= _scrollTimeH) { + int timesMissed = (_gameRef->_timer - _lastTimeH) / _scrollTimeH; + // Cap the amount of catch-up to avoid jittery characters. + if (timesMissed > 2) { + timesMissed = 2; + } _lastTimeH = _gameRef->_timer; 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) { + int timesMissed = (_gameRef->_timer - _lastTimeV) / _scrollTimeV; + // Cap the amount of catch-up to avoid jittery characters. + if (timesMissed > 2) { + timesMissed = 2; + } _lastTimeV = _gameRef->_timer; 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); } } @@ -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(); @@ -1280,7 +1285,7 @@ void AdScene::scrollTo(int offsetX, int offsetY) { _targetOffsetTop = MIN(_targetOffsetTop, _height - viewportHeight); - if (_gameRef->_mainObject && _gameRef->_mainObject->_is3D) { + if (_gameRef->getMainObject() && _gameRef->getMainObject()->_is3D) { if (abs(origOffsetLeft - _targetOffsetLeft) < 5) { _targetOffsetLeft = origOffsetLeft; } @@ -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; } @@ -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; } @@ -1873,7 +1878,7 @@ ScValue *AdScene::scGetProperty(const Common::String &name) { ////////////////////////////////////////////////////////////////////////// else if (name == "MouseY") { int viewportY; - getViewportOffset(NULL, &viewportY); + getViewportOffset(nullptr, &viewportY); _scValue->setInt(_gameRef->_mousePos.y + _offsetTop - viewportY); return _scValue; @@ -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; } @@ -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++; @@ -2586,7 +2591,7 @@ int AdScene::getOffsetLeft() { ////////////////////////////////////////////////////////////////////////// int AdScene::getOffsetTop() { int viewportY; - getViewportOffset(NULL, &viewportY); + getViewportOffset(nullptr, &viewportY); return _offsetTop - viewportY; } @@ -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,7 +2769,7 @@ float AdScene::getRotationAt(int x, int y) { } } - if (prev == NULL || next == NULL) { + if (prev == nullptr || next == nullptr) { return 0; } @@ -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..9cc8135889 100644 --- a/engines/wintermute/ad/ad_scene.h +++ b/engines/wintermute/ad/ad_scene.h @@ -67,20 +67,20 @@ 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(int *width = nullptr, int *height = nullptr); + bool getViewportOffset(int *offsetX = nullptr, int *offsetY = nullptr); BaseViewport *_viewport; BaseFader *_fader; int _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 correctTargetPoint(int startX, int startY, int *x, int *y, bool checkFreeObjects = false, BaseObject *requester = nullptr); bool correctTargetPoint2(int startX, int startY, int *targetX, int *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); @@ -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(BasePoint source, BasePoint target, AdPath *path, BaseObject *requester = nullptr); AdScene(BaseGame *inGame); virtual ~AdScene(); BaseArray<AdLayer *> _layers; @@ -153,7 +153,7 @@ public: BaseArray<AdRotLevel *> _rotLevels; virtual bool restoreDeviceObjects(); - int getPointsDist(BasePoint p1, BasePoint p2, BaseObject *requester = NULL); + int getPointsDist(BasePoint p1, BasePoint p2, BaseObject *requester = nullptr); // scripting interface virtual ScValue *scGetProperty(const Common::String &name); @@ -164,7 +164,7 @@ public: 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; diff --git a/engines/wintermute/ad/ad_scene_node.cpp b/engines/wintermute/ad/ad_scene_node.cpp index d0202236fd..f84e9212e5 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; } 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..47b22a1ab3 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; _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') { @@ -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); @@ -345,7 +345,7 @@ bool AdSentence::update(TDirection dir) { } _currentSprite = newSprite; } else { - _currentSprite = NULL; + _currentSprite = nullptr; } } diff --git a/engines/wintermute/ad/ad_sprite_set.cpp b/engines/wintermute/ad/ad_sprite_set.cpp index 345b483a8f..ffa7bb2530 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; @@ -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..3960b5dcc7 100644 --- a/engines/wintermute/ad/ad_sprite_set.h +++ b/engines/wintermute/ad/ad_sprite_set.h @@ -41,7 +41,7 @@ public: 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..4ad5d2ccc6 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); @@ -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_holder.cpp b/engines/wintermute/ad/ad_talk_holder.cpp index cca4fdc2cb..ed2333a345 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; } diff --git a/engines/wintermute/ad/ad_talk_node.cpp b/engines/wintermute/ad/ad_talk_node.cpp index c909ee27ff..2e0985ed99 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; } } @@ -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_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..7e427313e6 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; 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: + int _editorSelectedPoint; + float _lastMimicScale; + int _lastMimicX; + int _lastMimicY; }; } // end of namespace Wintermute |