DARKSEED: Rename ActionMode values to respect style convention. Remove unnecessary includes. Use typedefs

This commit is contained in:
Eric Fry 2024-09-29 09:56:28 +10:00 committed by Eugene Sandulenko
parent f3ec14a93f
commit 49b69cd5b1
8 changed files with 42 additions and 46 deletions

View File

@ -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());

View File

@ -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;

View File

@ -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"

View File

@ -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[];

View File

@ -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;

View File

@ -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;

View File

@ -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();
}

View File

@ -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);
}