From 49b69cd5b1998580d87a953df9c08f6a9d513055 Mon Sep 17 00:00:00 2001 From: Eric Fry Date: Sun, 29 Sep 2024 09:56:28 +1000 Subject: [PATCH] DARKSEED: Rename ActionMode values to respect style convention. Remove unnecessary includes. Use typedefs --- engines/darkseed/darkseed.cpp | 36 +++++++++++++++++----------------- engines/darkseed/darkseed.h | 12 ++++++------ engines/darkseed/detection.cpp | 4 ---- engines/darkseed/detection.h | 10 +++++----- engines/darkseed/gamefont.cpp | 4 ++-- engines/darkseed/inventory.cpp | 4 ++-- engines/darkseed/player.cpp | 2 +- engines/darkseed/room.cpp | 16 +++++++-------- 8 files changed, 42 insertions(+), 46 deletions(-) diff --git a/engines/darkseed/darkseed.cpp b/engines/darkseed/darkseed.cpp index 987712c8c06..05d49aab9c5 100644 --- a/engines/darkseed/darkseed.cpp +++ b/engines/darkseed/darkseed.cpp @@ -497,7 +497,7 @@ void DarkseedEngine::handleInput() { _player->updateSprite(); } if (_isLeftMouseClicked && _cursor.getY() > 0x28 && !_player->_actionToPerform) { // prevLeftMouseButtonState == 0 && - if (_actionMode == PointerAction) { + if (_actionMode == kPointerAction) { _player->calculateWalkTarget(); _player->playerFaceWalkTarget(); } else { @@ -537,12 +537,12 @@ void DarkseedEngine::handleInput() { } else if (objNum == 51 || objNum == 187) { _player->_sequenceRotation = 1; _cursor.updatePosition(380, 211); - } else if (objNum == 116 && _actionMode == Unk19Action) { + } else if (objNum == 116 && _actionMode == kUseStickAction) { _player->_sequenceRotation = 1; _cursor.updatePosition(285, 233); } else if (objNum == 137) { _player->_sequenceRotation = 1; - if (_actionMode == Unk27Action) { + if (_actionMode == kUseHammerAction) { _cursor.updatePosition(354, 175); } else { _cursor.updatePosition(409, 173); @@ -567,7 +567,7 @@ void DarkseedEngine::handleInput() { } } - if (objNum == 102 && _objectVar[23] != 0 && _actionMode == HandAction) { + if (objNum == 102 && _objectVar[23] != 0 && _actionMode == kHandAction) { _player->_sequenceRotation = 0; _cursor.updatePosition(331, 195); } else if (objNum < 104 || objNum > 108) { @@ -608,14 +608,14 @@ void DarkseedEngine::handleInput() { int yDistToTarget = ABS(_player->_walkTarget.y - _player->_position.y); if (_isRightMouseClicked && !_player->_actionToPerform) { - if (_actionMode == LookAction) { - _actionMode = PointerAction; - } else if (_actionMode == PointerAction) { - _actionMode = HandAction; - } else if (_actionMode == HandAction) { - _actionMode = LookAction; + if (_actionMode == kLookAction) { + _actionMode = kPointerAction; + } else if (_actionMode == kPointerAction) { + _actionMode = kHandAction; + } else if (_actionMode == kHandAction) { + _actionMode = kLookAction; } else { - _actionMode = PointerAction; + _actionMode = kPointerAction; } _cursor.setCursorType((CursorType)_actionMode); } @@ -814,12 +814,12 @@ void DarkseedEngine::handleInput() { if (objIdx == -1) { _console->printTosText(938); if (_actionMode > 3) { - _actionMode = PointerAction; + _actionMode = kPointerAction; _cursor.setCursorType((CursorType)_actionMode); } } else { if (_actionMode > 3) { - _actionMode = PointerAction; + _actionMode = kPointerAction; _cursor.setCursorType((CursorType)_actionMode); } } @@ -1452,8 +1452,8 @@ void DarkseedEngine::handleObjCollision(int targetObjNum) { if (targetObjNum == 35 && _objectVar[22] < 2 && _cursor.getY() > 40) { targetObjNum = 22; } - if (_actionMode == LookAction || _actionMode == HandAction || targetObjNum != 115) { - if (_cursor.getY() < 40 && _actionMode > LookAction) { + if (_actionMode == kLookAction || _actionMode == kHandAction || targetObjNum != 115) { + if (_cursor.getY() < 40 && _actionMode > kLookAction) { if (_objectVar[80] < 2 || ((_actionMode != 25 || targetObjNum != 19) && (_actionMode != 19 || targetObjNum != 25))) { if ((_actionMode == 25 && targetObjNum == 20) || (_actionMode == 20 && targetObjNum == 25)) { @@ -1477,10 +1477,10 @@ void DarkseedEngine::handleObjCollision(int targetObjNum) { return; } else { switch (_actionMode) { - case HandAction: + case kHandAction: _useCode->useCode(targetObjNum); break; - case LookAction: + case kLookAction: lookCode(targetObjNum); break; case 5: @@ -1898,7 +1898,7 @@ void DarkseedEngine::showFullscreenPic(const Common::Path &filename) { if (!_fullscreenPic->load(filename)) { delete _fullscreenPic; _fullscreenPic = nullptr; - error("Failed to load %s", filename.toString().c_str()); + error("DarkseedEngine::showFullscreenPic(): Failed to load %s", filename.toString().c_str()); } Common::String filePathStr = filename.toString(); debug("Loaded %s", filePathStr.c_str()); diff --git a/engines/darkseed/darkseed.h b/engines/darkseed/darkseed.h index e74416975aa..dc630b0f01e 100644 --- a/engines/darkseed/darkseed.h +++ b/engines/darkseed/darkseed.h @@ -54,11 +54,11 @@ namespace Darkseed { struct DarkseedGameDescription; enum ActionMode : uint8 { - PointerAction = 0, - HandAction = 2, - LookAction = 3, - Unk19Action = 19, - Unk27Action = 27, + kPointerAction = 0, + kHandAction = 2, + kLookAction = 3, + kUseStickAction = 19, + kUseHammerAction = 27, }; enum class FadeDirection : uint8 { @@ -101,7 +101,7 @@ public: TosText *_tosText = nullptr; Console *_console = nullptr; Room *_room = nullptr; - int _actionMode = PointerAction; + int _actionMode = kPointerAction; Player *_player = nullptr; Sprites _sprites; Objects _objectVar; diff --git a/engines/darkseed/detection.cpp b/engines/darkseed/detection.cpp index 39ccbbf73c2..947bfa20c5b 100644 --- a/engines/darkseed/detection.cpp +++ b/engines/darkseed/detection.cpp @@ -20,12 +20,8 @@ */ #include "base/plugins.h" -#include "common/config-manager.h" #include "common/file.h" -#include "common/md5.h" -#include "common/str-array.h" #include "common/translation.h" -#include "common/util.h" #include "darkseed/detection.h" #include "darkseed/detection_tables.h" diff --git a/engines/darkseed/detection.h b/engines/darkseed/detection.h index 36c7e3a3a5d..324960379d5 100644 --- a/engines/darkseed/detection.h +++ b/engines/darkseed/detection.h @@ -27,11 +27,11 @@ namespace Darkseed { enum DarkseedDebugChannels { - kDebugGraphics = 1 << 0, - kDebugPath = 1 << 1, - kDebugScan = 1 << 2, - kDebugFilePath = 1 << 3, - kDebugScript = 1 << 4, + kDebugGraphics = 1, + kDebugPath, + kDebugScan, + kDebugFilePath, + kDebugScript, }; extern const PlainGameDescriptor darkseedGames[]; diff --git a/engines/darkseed/gamefont.cpp b/engines/darkseed/gamefont.cpp index de1c8cf4a6a..f4d690fd245 100644 --- a/engines/darkseed/gamefont.cpp +++ b/engines/darkseed/gamefont.cpp @@ -33,7 +33,7 @@ bool GameFont::load() { } void GameFont::displayString(uint16 x, uint16 y, const Common::String &text) { - for (unsigned int i = 0; i < text.size(); i++) { + for (uint i = 0; i < text.size(); i++) { auto letter = getCharacterSprite(text[i]); if (letter) { letter->draw(x, y); @@ -44,7 +44,7 @@ void GameFont::displayString(uint16 x, uint16 y, const Common::String &text) { int GameFont::stringLength(const Common::String &text) { int width = 0; - for (unsigned int i = 0; i < text.size(); i++) { + for (uint i = 0; i < text.size(); i++) { const Sprite *sprite = getCharacterSprite(text[i]); if (sprite) { width += sprite->_width + 1; diff --git a/engines/darkseed/inventory.cpp b/engines/darkseed/inventory.cpp index 7f18349aea3..8eff0b4ec2b 100644 --- a/engines/darkseed/inventory.cpp +++ b/engines/darkseed/inventory.cpp @@ -150,10 +150,10 @@ void Inventory::handleClick() { (g_engine->_actionMode == 20 && icon == 25) ) { g_engine->handleObjCollision(icon); - } else if (g_engine->_actionMode == HandAction && icon == 35) { + } else if (g_engine->_actionMode == kHandAction && icon == 35) { g_engine->_objectVar[35] = 0x7080; g_engine->_console->printTosText(669); - } else if (g_engine->_actionMode == LookAction) { + } else if (g_engine->_actionMode == kLookAction) { g_engine->lookCode(icon); } else { g_engine->_actionMode = icon; diff --git a/engines/darkseed/player.cpp b/engines/darkseed/player.cpp index fb4ef7ce625..03ea31dcc9a 100644 --- a/engines/darkseed/player.cpp +++ b/engines/darkseed/player.cpp @@ -159,7 +159,7 @@ void Player::calculateWalkTarget() { _walkPathIndex = -1; _numConnectorsInWalkPath = 0; int selectedObjNum = 0; - if (g_engine->_actionMode == PointerAction) { + if (g_engine->_actionMode == kPointerAction) { selectedObjNum = g_engine->_room->getRoomExitAtCursor(); } diff --git a/engines/darkseed/room.cpp b/engines/darkseed/room.cpp index 79993a6334e..fca7b8a7629 100644 --- a/engines/darkseed/room.cpp +++ b/engines/darkseed/room.cpp @@ -235,7 +235,7 @@ void Room::draw() { int Room::checkCursorAndMoveableObjects() { int actionMode = g_engine->_actionMode; - const Sprite &cursorSprite = (actionMode == LookAction) + const Sprite &cursorSprite = (actionMode == kLookAction) ? g_engine->_cursor.getSpriteForType(ExclamationMark) : g_engine->_cursor.getSprite(); bool hasObject = false; @@ -271,7 +271,7 @@ int Room::checkCursorAndMoveableObjects() { int Room::checkCursorAndStaticObjects(int x, int y) { int actionMode = g_engine->_actionMode; - const Sprite &cursorSprite = (actionMode == LookAction) + const Sprite &cursorSprite = (actionMode == kLookAction) ? g_engine->_cursor.getSpriteForType(ExclamationMark) : g_engine->_cursor.getSprite(); bool hasObject = false; @@ -283,11 +283,11 @@ int Room::checkCursorAndStaticObjects(int x, int y) { && _roomObj[i].yOffset <= cursorSprite._height + g_engine->_cursor.getY() && g_engine->_cursor.getY() <= _roomObj[i].height + _roomObj[i].yOffset ) { - if (actionMode != PointerAction && _roomObj[i].objNum >= 5) { + if (actionMode != kPointerAction && _roomObj[i].objNum >= 5) { hasObject = true; } - if (actionMode == PointerAction && _roomObj[i].objNum < 6) { + if (actionMode == kPointerAction && _roomObj[i].objNum < 6) { hasObject = true; } @@ -321,7 +321,7 @@ int Room::checkCursorAndStaticObjects(int x, int y) { int Room::CheckCursorAndMovedObjects() { int actionMode = g_engine->_actionMode; - const Sprite &cursorSprite = (actionMode == LookAction) + const Sprite &cursorSprite = (actionMode == kLookAction) ? g_engine->_cursor.getSpriteForType(ExclamationMark) : g_engine->_cursor.getSprite(); _collisionType = 1; @@ -355,7 +355,7 @@ int Room::CheckCursorAndMovedObjects() { } void Room::update() { - if (g_engine->_actionMode == HandAction || g_engine->_actionMode > 4) { + if (g_engine->_actionMode == kHandAction || g_engine->_actionMode > 4) { int moveableObj = checkCursorAndMoveableObjects(); if (moveableObj == -1) { int objectUnderCursor = checkCursorAndStaticObjects(g_engine->_cursor.getX(), g_engine->_cursor.getY()); @@ -372,7 +372,7 @@ void Room::update() { } else { g_engine->_cursor.setCursorType(HandPointing); } - } else if (g_engine->_actionMode == LookAction) { + } else if (g_engine->_actionMode == kLookAction) { if (checkCursorAndMoveableObjects() != -1 || CheckCursorAndMovedObjects() != -1) { g_engine->_cursor.setCursorType(ExclamationMark); } else { @@ -384,7 +384,7 @@ void Room::update() { } } } else { - if (g_engine->_actionMode != PointerAction) { + if (g_engine->_actionMode != kPointerAction) { g_engine->_cursor.setCursorType(Pointer); }