From 0c8d8bbd40e4806e1b63196e283bcbff21431080 Mon Sep 17 00:00:00 2001 From: Bastien Bouclet Date: Sat, 6 Feb 2016 11:27:51 +0100 Subject: MOHAWK: Use nullptr where applicable in the Myst code --- engines/mohawk/myst.cpp | 56 ++++++++++++++++---------------- engines/mohawk/myst_areas.cpp | 2 +- engines/mohawk/myst_graphics.cpp | 6 ++-- engines/mohawk/myst_scripts.cpp | 34 +++++++++---------- engines/mohawk/myst_scripts.h | 4 +-- engines/mohawk/myst_stacks/myst.cpp | 12 +++---- engines/mohawk/myst_stacks/selenitic.cpp | 4 +-- engines/mohawk/myst_state.cpp | 6 ++-- 8 files changed, 62 insertions(+), 62 deletions(-) diff --git a/engines/mohawk/myst.cpp b/engines/mohawk/myst.cpp index 2f6444a223..8df6b01507 100644 --- a/engines/mohawk/myst.cpp +++ b/engines/mohawk/myst.cpp @@ -77,26 +77,26 @@ MohawkEngine_Myst::MohawkEngine_Myst(OSystem *syst, const MohawkGameDescription _curCard = 0; _needsUpdate = false; _curResource = -1; - _hoverResource = 0; + _hoverResource = nullptr; - _gfx = NULL; - _console = NULL; - _scriptParser = NULL; - _gameState = NULL; - _loadDialog = NULL; - _optionsDialog = NULL; + _gfx = nullptr; + _console = nullptr; + _scriptParser = nullptr; + _gameState = nullptr; + _loadDialog = nullptr; + _optionsDialog = nullptr; _cursorHintCount = 0; - _cursorHints = NULL; + _cursorHints = nullptr; - _prevStack = NULL; + _prevStack = nullptr; _view.conditionalImageCount = 0; - _view.conditionalImages = NULL; - _view.soundList = NULL; - _view.soundListVolume = NULL; + _view.conditionalImages = nullptr; + _view.soundList = nullptr; + _view.soundListVolume = nullptr; _view.scriptResCount = 0; - _view.scriptResources = NULL; + _view.scriptResources = nullptr; } MohawkEngine_Myst::~MohawkEngine_Myst() { @@ -137,7 +137,7 @@ Common::SeekableReadStream *MohawkEngine_Myst::getResource(uint32 tag, uint16 id } error("Could not find a \'%s\' resource with ID %04x", tag2str(tag), id); - return NULL; + return nullptr; } void MohawkEngine_Myst::cachePreload(uint32 tag, uint16 id) { @@ -501,7 +501,7 @@ void MohawkEngine_Myst::changeToStack(uint16 stack, uint16 card, uint16 linkSrcS if (getFeatures() & GF_ME) { // Play Flyby Entry Movie on Masterpiece Edition. - const char *flyby = 0; + const char *flyby = nullptr; switch (_curStack) { case kSeleniticStack: @@ -643,7 +643,7 @@ void MohawkEngine_Myst::changeToCard(uint16 card, TransitionType transition) { } // Make sure we have the right cursor showing - _hoverResource = 0; + _hoverResource = nullptr; _curResource = -1; checkCurrentResource(); @@ -669,7 +669,7 @@ void MohawkEngine_Myst::checkCurrentResource() { // Tell previous resource the mouse is no longer hovering it if (_hoverResource && !_hoverResource->contains(mouse)) { _hoverResource->handleMouseLeave(); - _hoverResource = 0; + _hoverResource = nullptr; } for (uint16 i = 0; i < _resources.size(); i++) @@ -698,7 +698,7 @@ MystResource *MohawkEngine_Myst::updateCurrentResource() { if (_curResource >= 0) return _resources[_curResource]; else - return 0; + return nullptr; } void MohawkEngine_Myst::loadCard() { @@ -810,7 +810,7 @@ void MohawkEngine_Myst::loadCard() { debugC(kDebugView, "\t\t Resource List %d: %d", j, _view.scriptResources[i].resource_list[j]); } } else { - _view.scriptResources[i].resource_list = NULL; + _view.scriptResources[i].resource_list = nullptr; _view.scriptResources[i].id = viewStream->readUint16LE(); debugC(kDebugView, "\t\t Id: %d", _view.scriptResources[i].id); } @@ -881,18 +881,18 @@ void MohawkEngine_Myst::unloadCard() { delete[] _view.conditionalImages; _view.conditionalImageCount = 0; - _view.conditionalImages = NULL; + _view.conditionalImages = nullptr; delete[] _view.soundList; - _view.soundList = NULL; + _view.soundList = nullptr; delete[] _view.soundListVolume; - _view.soundListVolume = NULL; + _view.soundListVolume = nullptr; for (uint16 i = 0; i < _view.scriptResCount; i++) delete[] _view.scriptResources[i].resource_list; delete[] _view.scriptResources; - _view.scriptResources = NULL; + _view.scriptResources = nullptr; _view.scriptResCount = 0; } @@ -973,7 +973,7 @@ void MohawkEngine_Myst::loadCursorHints() { delete[] _cursorHints[i].variableHint.values; _cursorHintCount = 0; delete[] _cursorHints; - _cursorHints = NULL; + _cursorHints = nullptr; if (!_view.hint) { debugC(kDebugHint, "No HINT Present"); @@ -1008,7 +1008,7 @@ void MohawkEngine_Myst::loadCursorHints() { } else { _cursorHints[i].variableHint.var = 0; _cursorHints[i].variableHint.numStates = 0; - _cursorHints[i].variableHint.values = NULL; + _cursorHints[i].variableHint.values = nullptr; } } @@ -1085,11 +1085,11 @@ void MohawkEngine_Myst::redrawArea(uint16 var, bool update) { } MystResource *MohawkEngine_Myst::loadResource(Common::SeekableReadStream *rlstStream, MystResource *parent) { - MystResource *resource = 0; + MystResource *resource = nullptr; ResourceType type = static_cast(rlstStream->readUint16LE()); debugC(kDebugResource, "\tType: %d", type); - debugC(kDebugResource, "\tSub_Record: %d", (parent == NULL) ? 0 : 1); + debugC(kDebugResource, "\tSub_Record: %d", (parent == nullptr) ? 0 : 1); switch (type) { case kMystAction: @@ -1143,7 +1143,7 @@ void MohawkEngine_Myst::loadResources() { for (uint16 i = 0; i < resourceCount; i++) { debugC(kDebugResource, "Resource #%d:", i); - _resources.push_back(loadResource(rlstStream, NULL)); + _resources.push_back(loadResource(rlstStream, nullptr)); } delete rlstStream; diff --git a/engines/mohawk/myst_areas.cpp b/engines/mohawk/myst_areas.cpp index 802e5e96cd..2221ef1165 100644 --- a/engines/mohawk/myst_areas.cpp +++ b/engines/mohawk/myst_areas.cpp @@ -36,7 +36,7 @@ MystResource::MystResource(MohawkEngine_Myst *vm, Common::SeekableReadStream *rl _vm = vm; _parent = parent; - if (parent == NULL) { + if (parent == nullptr) { _flags = rlstStream->readUint16LE(); _rect.left = rlstStream->readSint16LE(); _rect.top = rlstStream->readSint16LE(); diff --git a/engines/mohawk/myst_graphics.cpp b/engines/mohawk/myst_graphics.cpp index 49f97cca63..7cb32800a8 100644 --- a/engines/mohawk/myst_graphics.cpp +++ b/engines/mohawk/myst_graphics.cpp @@ -40,7 +40,7 @@ MystGraphics::MystGraphics(MohawkEngine_Myst* vm) : GraphicsManager(), _vm(vm) { if (_vm->getFeatures() & GF_ME) { // High color - initGraphics(_viewport.width(), _viewport.height(), true, NULL); + initGraphics(_viewport.width(), _viewport.height(), true, nullptr); if (_vm->_system->getScreenFormat().bytesPerPixel == 1) error("Myst ME requires greater than 256 colors to run"); @@ -73,7 +73,7 @@ MohawkSurface *MystGraphics::decodeImage(uint16 id) { // if it's a PICT or WDIB resource. If it's Myst ME it's most likely a PICT, and if it's // original it's definitely a WDIB. However, Myst ME throws us another curve ball in // that PICT resources can contain WDIB's instead of PICT's. - Common::SeekableReadStream *dataStream = NULL; + Common::SeekableReadStream *dataStream = nullptr; if (_vm->getFeatures() & GF_ME && _vm->hasResource(ID_PICT, id)) { // The PICT resource exists. However, it could still contain a MystBitmap @@ -95,7 +95,7 @@ MohawkSurface *MystGraphics::decodeImage(uint16 id) { dataStream->seek(0); } - MohawkSurface *mhkSurface = 0; + MohawkSurface *mhkSurface = nullptr; if (isPict) { Image::PICTDecoder pict; diff --git a/engines/mohawk/myst_scripts.cpp b/engines/mohawk/myst_scripts.cpp index 99970e68b3..14a95ee582 100644 --- a/engines/mohawk/myst_scripts.cpp +++ b/engines/mohawk/myst_scripts.cpp @@ -38,7 +38,7 @@ MystScriptEntry::MystScriptEntry() { type = kMystScriptNone; var = 0; argc = 0; - argv = 0; + argv = nullptr; resourceId = 0; u1 = 0; } @@ -81,7 +81,7 @@ MystScriptParser::MystScriptParser(MohawkEngine_Myst *vm) : _vm(vm), _globals(vm->_gameState->_globals) { setupCommonOpcodes(); - _invokingResource = NULL; + _invokingResource = nullptr; _savedCardId = 0; _savedCursorId = 0; _tempVar = 0; @@ -322,7 +322,7 @@ void MystScriptParser::o_changeCardSwitch4(uint16 op, uint16 var, uint16 argc, u if (value) _vm->changeToCard(argv[value -1 ], kTransitionDissolve); - else if (_invokingResource != NULL) + else if (_invokingResource != nullptr) _vm->changeToCard(_invokingResource->getDest(), kTransitionDissolve); else warning("Missing invokingResource in altDest call"); @@ -335,7 +335,7 @@ void MystScriptParser::o_changeCardSwitchLtR(uint16 op, uint16 var, uint16 argc, if (value) _vm->changeToCard(argv[value -1 ], kTransitionLeftToRight); - else if (_invokingResource != NULL) + else if (_invokingResource != nullptr) _vm->changeToCard(_invokingResource->getDest(), kTransitionLeftToRight); else warning("Missing invokingResource in altDest call"); @@ -348,7 +348,7 @@ void MystScriptParser::o_changeCardSwitchRtL(uint16 op, uint16 var, uint16 argc, if (value) _vm->changeToCard(argv[value -1 ], kTransitionRightToLeft); - else if (_invokingResource != NULL) + else if (_invokingResource != nullptr) _vm->changeToCard(_invokingResource->getDest(), kTransitionRightToLeft); else warning("Missing invokingResource in altDest call"); @@ -389,7 +389,7 @@ void MystScriptParser::o_redrawCard(uint16 op, uint16 var, uint16 argc, uint16 * void MystScriptParser::o_goToDest(uint16 op, uint16 var, uint16 argc, uint16 *argv) { debugC(kDebugScript, "Opcode %d: Change To Dest of Invoking Resource", op); - if (_invokingResource != NULL) + if (_invokingResource != nullptr) _vm->changeToCard(_invokingResource->getDest(), kTransitionCopy); else warning("Opcode %d: Missing invokingResource", op); @@ -398,7 +398,7 @@ void MystScriptParser::o_goToDest(uint16 op, uint16 var, uint16 argc, uint16 *ar void MystScriptParser::o_goToDestForward(uint16 op, uint16 var, uint16 argc, uint16 *argv) { debugC(kDebugScript, "Opcode %d: Change To Dest of Invoking Resource", op); - if (_invokingResource != NULL) + if (_invokingResource != nullptr) _vm->changeToCard(_invokingResource->getDest(), kTransitionDissolve); else warning("Opcode %d: Missing invokingResource", op); @@ -407,7 +407,7 @@ void MystScriptParser::o_goToDestForward(uint16 op, uint16 var, uint16 argc, uin void MystScriptParser::o_goToDestLeft(uint16 op, uint16 var, uint16 argc, uint16 *argv) { debugC(kDebugScript, "Opcode %d: Change To Dest of Invoking Resource", op); - if (_invokingResource != NULL) + if (_invokingResource != nullptr) _vm->changeToCard(_invokingResource->getDest(), kTransitionPartToRight); else warning("Opcode %d: Missing invokingResource", op); @@ -416,7 +416,7 @@ void MystScriptParser::o_goToDestLeft(uint16 op, uint16 var, uint16 argc, uint16 void MystScriptParser::o_goToDestRight(uint16 op, uint16 var, uint16 argc, uint16 *argv) { debugC(kDebugScript, "Opcode %d: Change To Dest of Invoking Resource", op); - if (_invokingResource != NULL) + if (_invokingResource != nullptr) _vm->changeToCard(_invokingResource->getDest(), kTransitionPartToLeft); else warning("Opcode %d: Missing invokingResource", op); @@ -425,7 +425,7 @@ void MystScriptParser::o_goToDestRight(uint16 op, uint16 var, uint16 argc, uint1 void MystScriptParser::o_goToDestUp(uint16 op, uint16 var, uint16 argc, uint16 *argv) { debugC(kDebugScript, "Opcode %d: Change To Dest of Invoking Resource", op); - if (_invokingResource != NULL) + if (_invokingResource != nullptr) _vm->changeToCard(_invokingResource->getDest(), kTransitionTopToBottom); else warning("Opcode %d: Missing invokingResource", op); @@ -522,7 +522,7 @@ void MystScriptParser::o_enableAreas(uint16 op, uint16 var, uint16 argc, uint16 for (uint16 i = 0; i < count; i++) { debugC(kDebugScript, "Enable hotspot index %d", argv[i + 1]); - MystResource *resource = 0; + MystResource *resource = nullptr; if (argv[i + 1] == 0xFFFF) resource = _invokingResource; else @@ -547,7 +547,7 @@ void MystScriptParser::o_disableAreas(uint16 op, uint16 var, uint16 argc, uint16 for (uint16 i = 0; i < count; i++) { debugC(kDebugScript, "Disable hotspot index %d", argv[i + 1]); - MystResource *resource = 0; + MystResource *resource = nullptr; if (argv[i + 1] == 0xFFFF) resource = _invokingResource; else @@ -578,7 +578,7 @@ void MystScriptParser::o_toggleAreasActivation(uint16 op, uint16 var, uint16 arg for (uint16 i = 0; i < count; i++) { debugC(kDebugScript, "Enable/Disable hotspot index %d", argv[i + 1]); - MystResource *resource = 0; + MystResource *resource = nullptr; if (argv[i + 1] == 0xFFFF) resource = _invokingResource; else @@ -681,8 +681,8 @@ void MystScriptParser::o_copyImageToBackBuffer(uint16 op, uint16 var, uint16 arg // by Channelwood Card 3280 (Tank Valve) and water flow sound behavior in pipe // on cards leading from shed... void MystScriptParser::o_changeBackgroundSound(uint16 op, uint16 var, uint16 argc, uint16 *argv) { - int16 *soundList = NULL; - uint16 *soundListVolume = NULL; + int16 *soundList = nullptr; + uint16 *soundListVolume = nullptr; // Used on Stoneship Card 2080 // Used on Channelwood Card 3225 with argc = 8 i.e. Conditional Sound List @@ -746,9 +746,9 @@ void MystScriptParser::o_changeBackgroundSound(uint16 op, uint16 var, uint16 arg warning("Unknown arg count in opcode %d", op); delete[] soundList; - soundList = NULL; + soundList = nullptr; delete[] soundListVolume; - soundListVolume = NULL; + soundListVolume = nullptr; } void MystScriptParser::o_soundPlaySwitch(uint16 op, uint16 var, uint16 argc, uint16 *argv) { diff --git a/engines/mohawk/myst_scripts.h b/engines/mohawk/myst_scripts.h index cce4d7f436..3cf5c2d7f2 100644 --- a/engines/mohawk/myst_scripts.h +++ b/engines/mohawk/myst_scripts.h @@ -63,8 +63,8 @@ public: MystScriptParser(MohawkEngine_Myst *vm); virtual ~MystScriptParser(); - void runScript(MystScript script, MystResource *invokingResource = NULL); - void runOpcode(uint16 op, uint16 var = 0, uint16 argc = 0, uint16 *argv = NULL); + void runScript(MystScript script, MystResource *invokingResource = nullptr); + void runOpcode(uint16 op, uint16 var = 0, uint16 argc = 0, uint16 *argv = nullptr); const Common::String getOpcodeDesc(uint16 op); MystScript readScript(Common::SeekableReadStream *stream, MystScriptType type); void setInvokingResource(MystResource *resource) { _invokingResource = resource; } diff --git a/engines/mohawk/myst_stacks/myst.cpp b/engines/mohawk/myst_stacks/myst.cpp index 9ad1635757..c449cccbf9 100644 --- a/engines/mohawk/myst_stacks/myst.cpp +++ b/engines/mohawk/myst_stacks/myst.cpp @@ -52,12 +52,12 @@ Myst::Myst(MohawkEngine_Myst *vm) : _cabinDoorOpened = 0; _cabinMatchState = 2; _matchBurning = false; - _tree = 0; - _treeAlcove = 0; + _tree = nullptr; + _treeAlcove = nullptr; _treeStopped = false; _treeMinPosition = 0; _imagerValidationStep = 0; - _observatoryCurrentSlider = 0; + _observatoryCurrentSlider = nullptr; _butterfliesMoviePlayed = false; _state.treeLastMoveTime = _vm->_system->getMillis(); } @@ -2838,7 +2838,7 @@ void Myst::o_observatoryChangeSettingStop(uint16 op, uint16 var, uint16 argc, ui _vm->_gfx->copyBackBufferToScreen(_invokingResource->getRect()); if (_observatoryCurrentSlider) { _vm->redrawResource(_observatoryCurrentSlider); - _observatoryCurrentSlider = 0; + _observatoryCurrentSlider = nullptr; } _vm->_sound->resumeBackgroundMyst(); } @@ -3828,13 +3828,13 @@ void Myst::o_bookAddSpecialPage_exit(uint16 op, uint16 var, uint16 argc, uint16 void Myst::o_treeCard_exit(uint16 op, uint16 var, uint16 argc, uint16 *argv) { debugC(kDebugScript, "Opcode %d: Exit tree card", op); - _tree = 0; + _tree = nullptr; } void Myst::o_treeEntry_exit(uint16 op, uint16 var, uint16 argc, uint16 *argv) { debugC(kDebugScript, "Opcode %d: Exit tree card with entry", op); - _treeAlcove = 0; + _treeAlcove = nullptr; } void Myst::o_boiler_exit(uint16 op, uint16 var, uint16 argc, uint16 *argv) { diff --git a/engines/mohawk/myst_stacks/selenitic.cpp b/engines/mohawk/myst_stacks/selenitic.cpp index 8b95c7fa53..0cf89eb0a1 100644 --- a/engines/mohawk/myst_stacks/selenitic.cpp +++ b/engines/mohawk/myst_stacks/selenitic.cpp @@ -39,7 +39,7 @@ namespace MystStacks { Selenitic::Selenitic(MohawkEngine_Myst *vm) : MystScriptParser(vm), _state(vm->_gameState->_selenitic) { setupOpcodes(); - _invokingResource = NULL; + _invokingResource = nullptr; _mazeRunnerPosition = 288; _mazeRunnerDirection = 8; } @@ -784,7 +784,7 @@ MystResourceType10 *Selenitic::soundLockSliderFromVar(uint16 var) { return _soundLockSlider5; } - return 0; + return nullptr; } void Selenitic::o_soundLockMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) { diff --git a/engines/mohawk/myst_state.cpp b/engines/mohawk/myst_state.cpp index 3e54017df8..9bfbba67b6 100644 --- a/engines/mohawk/myst_state.cpp +++ b/engines/mohawk/myst_state.cpp @@ -96,7 +96,7 @@ bool MystGameState::load(const Common::String &filename) { return false; } - Common::Serializer s(loadFile, 0); + Common::Serializer s(loadFile, nullptr); syncGameState(s, size == 664); delete loadFile; @@ -131,7 +131,7 @@ bool MystGameState::save(const Common::String &fname) { debugC(kDebugSaveLoad, "Saving game to '%s'", filename.c_str()); - Common::Serializer s(0, saveFile); + Common::Serializer s(nullptr, saveFile); syncGameState(s, _vm->getFeatures() & GF_ME); saveFile->finalize(); delete saveFile; @@ -321,7 +321,7 @@ void MystGameState::deleteSave(const Common::String &saveName) { } void MystGameState::addZipDest(uint16 stack, uint16 view) { - ZipDests *zipDests = 0; + ZipDests *zipDests = nullptr; // The demo has no zip dest storage if (_vm->getFeatures() & GF_DEMO) -- cgit v1.2.3