aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBendegúz Nagy2016-08-10 13:42:46 +0200
committerBendegúz Nagy2016-08-26 23:02:22 +0200
commit1c3c33c76d5390a62fd34d18a31fc3604b298e05 (patch)
tree70397dbec776d15fb25c6727b8b58eb9773d5bee
parent50f3cfa625e338276e8a4d38836227877ab93e3a (diff)
downloadscummvm-rg350-1c3c33c76d5390a62fd34d18a31fc3604b298e05.tar.gz
scummvm-rg350-1c3c33c76d5390a62fd34d18a31fc3604b298e05.tar.bz2
scummvm-rg350-1c3c33c76d5390a62fd34d18a31fc3604b298e05.zip
DM: Add noclip debug command
-rw-r--r--engines/dm/console.cpp42
-rw-r--r--engines/dm/console.h13
-rw-r--r--engines/dm/eventman.cpp3
3 files changed, 47 insertions, 11 deletions
diff --git a/engines/dm/console.cpp b/engines/dm/console.cpp
index a1600661bc..d9bd8e2524 100644
--- a/engines/dm/console.cpp
+++ b/engines/dm/console.cpp
@@ -30,34 +30,39 @@
namespace DM {
+bool cstrEquals(const char* a, const char *b) { return strcmp(a, b) == 0; }
+
Console::Console(DM::DMEngine* vm) : _vm(vm) {
_debugGodmodeMana = false;
_debugGodmodeHP = false;
_debugGodmodeStamina = false;
+ _debugNoclip = false;
+
registerCmd("godmode", WRAP_METHOD(Console, Cmd_godmode));
+ registerCmd("noclip", WRAP_METHOD(Console, Cmd_noclip));
}
bool Console::Cmd_godmode(int argc, const char** argv) {
- if (argc < 3)
+ if (argc != 3)
goto argumentError;
bool setFlagTo;
- if (strcmp("on", argv[2]) == 0) {
+ if (cstrEquals("on", argv[2])) {
setFlagTo = true;
- } else if (strcmp("off", argv[2]) == 0) {
+ } else if (cstrEquals("off", argv[2])) {
setFlagTo = false;
} else
goto argumentError;
- if (strcmp("all", argv[1]) == 0) {
+ if (cstrEquals("all", argv[1])) {
_debugGodmodeHP = _debugGodmodeMana = _debugGodmodeStamina = setFlagTo;
- } else if (strcmp("mana", argv[1]) == 0) {
+ } else if (cstrEquals("mana", argv[1])) {
_debugGodmodeMana = setFlagTo;
- } else if (strcmp("hp", argv[1]) == 0) {
+ } else if (cstrEquals("hp", argv[1])) {
_debugGodmodeHP = setFlagTo;
- } else if (strcmp("stamina", argv[1]) == 0) {
+ } else if (cstrEquals("stamina", argv[1])) {
_debugGodmodeStamina = setFlagTo;
} else
goto argumentError;
@@ -70,4 +75,27 @@ argumentError:
return true;
}
+bool Console::Cmd_noclip(int argc, const char** argv) {
+ if (argc != 2)
+ goto argumentError;
+
+ if (cstrEquals("on", argv[1])) {
+ _debugNoclip = true;
+ static bool warnedForNoclip = false;
+ if (!warnedForNoclip) {
+ debugPrintf("Noclip can cause unexpected glitches and crashes.\n");
+ warnedForNoclip = true;
+ }
+ } else if (cstrEquals("off", argv[1])) {
+ _debugNoclip = false;
+ } else
+ goto argumentError;
+
+ debugPrintf("Noclip set to %s\n", argv[1]);
+ return true;
+
+argumentError:
+ debugPrintf("Usage: %s <on/off>\n", argv[0]);
+ return true;
+}
}
diff --git a/engines/dm/console.h b/engines/dm/console.h
index 0bfcfcef64..96fb677fd4 100644
--- a/engines/dm/console.h
+++ b/engines/dm/console.h
@@ -35,13 +35,20 @@ class DMEngine;
class Console : public GUI::Debugger {
DMEngine *_vm;
+
public:
+ explicit Console(DM::DMEngine *vm);
+ virtual ~Console(void) {}
+
+ // Cmd_godmode
bool _debugGodmodeMana;
bool _debugGodmodeHP;
bool _debugGodmodeStamina;
-
- explicit Console(DM::DMEngine *vm);
- virtual ~Console(void) {}
bool Cmd_godmode(int argc, const char **argv);
+
+ // Cmd_noclip
+ bool _debugNoclip;
+ bool Cmd_noclip(int argc, const char **argv);
+
};
}
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index af875a94e5..e0ac2c45bd 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -918,7 +918,8 @@ void EventManager::f366_commandMoveParty(CommandType cmdType) {
}
}
}
- if (L1117_B_MovementBlocked) {
+ // DEBUG CODE: check for Console flag
+ if (L1117_B_MovementBlocked && !_vm->_console->_debugNoclip) {
f357_discardAllInput();
_vm->_g321_stopWaitingForPlayerInput = false;
return;