diff options
author | Einar Johan Trøan Sømåen | 2013-01-26 18:06:42 +0100 |
---|---|---|
committer | Einar Johan Trøan Sømåen | 2013-01-26 18:07:07 +0100 |
commit | 980dc4a456f55a8b6526d2bc6f7694a0b2d666b3 (patch) | |
tree | bef13619df90984b731795e72721da7d39089041 /engines/wintermute/ad/ad_game.cpp | |
parent | 6ae97cdfbe88fa34363aabc46847b0c9a32eefe5 (diff) | |
download | scummvm-rg350-980dc4a456f55a8b6526d2bc6f7694a0b2d666b3.tar.gz scummvm-rg350-980dc4a456f55a8b6526d2bc6f7694a0b2d666b3.tar.bz2 scummvm-rg350-980dc4a456f55a8b6526d2bc6f7694a0b2d666b3.zip |
WINTERMUTE: Replace all NULLs with nullptr.
Diffstat (limited to 'engines/wintermute/ad/ad_game.cpp')
-rw-r--r-- | engines/wintermute/ad/ad_game.cpp | 156 |
1 files changed, 78 insertions, 78 deletions
diff --git a/engines/wintermute/ad/ad_game.cpp b/engines/wintermute/ad/ad_game.cpp index 1fd776e386..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()) { @@ -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(); @@ -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; @@ -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); @@ -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; } } @@ -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; |