diff options
author | Bendegúz Nagy | 2016-08-10 14:44:54 +0200 |
---|---|---|
committer | Bendegúz Nagy | 2016-08-26 23:02:22 +0200 |
commit | a5c0a324462b9f149eea3ef78589999d193de71e (patch) | |
tree | 4f92b0946735a68508f549c0cddf1127a1000981 /engines | |
parent | 0eea48a59b83861f3b488ab7d5beae71c620bccc (diff) | |
download | scummvm-rg350-a5c0a324462b9f149eea3ef78589999d193de71e.tar.gz scummvm-rg350-a5c0a324462b9f149eea3ef78589999d193de71e.tar.bz2 scummvm-rg350-a5c0a324462b9f149eea3ef78589999d193de71e.zip |
DM: Add debug command .pos
Diffstat (limited to 'engines')
-rw-r--r-- | engines/dm/console.cpp | 42 | ||||
-rw-r--r-- | engines/dm/console.h | 3 | ||||
-rw-r--r-- | engines/dm/dm.cpp | 11 | ||||
-rw-r--r-- | engines/dm/dm.h | 1 |
4 files changed, 53 insertions, 4 deletions
diff --git a/engines/dm/console.cpp b/engines/dm/console.cpp index 7bafc3c48e..afc6b80a8b 100644 --- a/engines/dm/console.cpp +++ b/engines/dm/console.cpp @@ -26,6 +26,10 @@ */ #include "console.h" +#include "dm.h" +#include "champion.h" +#include "dungeonman.h" +#include "movesens.h" namespace DM { @@ -35,7 +39,7 @@ bool cstrEquals(const char* a, const char *b) { return strcmp(a, b) == 0; } class SingleUseFlag { bool _flag; public: - SingleUseFlag(): _flag(true) {} + SingleUseFlag() : _flag(true) {} bool check() { bool currFlagState = _flag; _flag = false; @@ -52,6 +56,7 @@ Console::Console(DM::DMEngine* vm) : _vm(vm) { registerCmd(".godmode", WRAP_METHOD(Console, Cmd_godmode)); registerCmd(".noclip", WRAP_METHOD(Console, Cmd_noclip)); + registerCmd(".pos", WRAP_METHOD(Console, Cmd_pos)); } bool Console::Cmd_godmode(int argc, const char** argv) { @@ -94,7 +99,7 @@ bool Console::Cmd_noclip(int argc, const char** argv) { _debugNoclip = true; static SingleUseFlag warnedForNoclip; if (warnedForNoclip.check()) - debugPrintf("Noclip can cause unexpected glitches and crashes.\n"); + debugPrintf("Noclip can cause glitches and crashes.\n"); } else if (cstrEquals("off", argv[1])) { _debugNoclip = false; } else @@ -108,5 +113,38 @@ argumentError: return true; } +bool Console::Cmd_pos(int argc, const char** argv) { + if (argc == 2 && cstrEquals("get", argv[1])) { + debugPrintf("Position: (%d, %d) Direction: %s\n", _vm->_dungeonMan->_g306_partyMapX, + _vm->_dungeonMan->_g307_partyMapY, debugGetDirectionName(_vm->_dungeonMan->_g308_partyDir)); + } else if (argc == 4 && cstrEquals("set", argv[1])) { + int x = atoi(argv[2]); + int y = atoi(argv[3]); + if (x == 0 || y == 0) { + debugPrintf("Error, supply two non-null numbers to '%s set' command\n", argv[0]); + return true; + } + + Map &currMap = *_vm->_dungeonMan->_g269_currMap; + // not >= because dimensions are inslucsive + if (x > currMap._width || y > currMap._height) { + debugPrintf("Position (%d, %d) is out of bounds, possible values: ([1-%d],[1-%d])\n", x, y, + currMap._width, currMap._height); + return true; + } + + static SingleUseFlag warnForSettingPos; + if (warnForSettingPos.check()) + debugPrintf("Setting position directly can cause glitches and crashes.\n"); + debugPrintf("Position set to (%d, %d)\n", x, y); + _vm->_moveSens->f267_getMoveResult(Thing::_party, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, x, y); + } else + goto argumentError; + + return true; +argumentError: + debugPrintf("Usage: %s get\nUsage: %s set <#> <#>\n", argv[0], argv[0]); + return true; +} } diff --git a/engines/dm/console.h b/engines/dm/console.h index 8ee4857d8d..a11d334cce 100644 --- a/engines/dm/console.h +++ b/engines/dm/console.h @@ -51,6 +51,9 @@ public: bool _debugNoclip; bool Cmd_noclip(int argc, const char **argv); + // Cmd_pos + bool Cmd_pos(int argc, const char **argv); + }; } diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 8cd5771302..f4ab7f4fbc 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -76,6 +76,13 @@ void warning(bool repeat, const char* s, ...) { } } +const char* debugGetDirectionName(Direction dir) { + static const char* directionNames[] = {"North", "East", "South", "West"}; + if (dir < 0 || dir > 3) + return "Invalid direction"; + return directionNames[dir]; +} + void turnDirRight(Direction &dir) { dir = (Direction)((dir + 1) & 3); } @@ -367,7 +374,7 @@ void DMEngine::f2_gameloop() { while (true) { if (_engineShouldQuit) return; - + // DEBUG CODE for (int16 i = 0; i < _championMan->_g305_partyChampionCount; ++i) { Champion &champ = _championMan->_gK71_champions[i]; @@ -380,7 +387,7 @@ void DMEngine::f2_gameloop() { } for (;;) { - + if (_g327_newPartyMapIndex != kM1_mapIndexNone) { f3_processNewPartyMap(_g327_newPartyMapIndex); diff --git a/engines/dm/dm.h b/engines/dm/dm.h index ae16e13e60..08fb3c52e4 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -63,6 +63,7 @@ enum Direction { kDirSouth = 2, kDirWest = 3 }; +const char *debugGetDirectionName(Direction dir); |