1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
|
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "glk/comprehend/debugger.h"
#include "glk/comprehend/comprehend.h"
#include "glk/comprehend/pics.h"
namespace Glk {
namespace Comprehend {
Debugger *g_debugger;
Debugger::Debugger() : Glk::Debugger(), _invLimit(true) {
g_debugger = this;
registerCmd("dump", WRAP_METHOD(Debugger, cmdDump));
registerCmd("floodfills", WRAP_METHOD(Debugger, cmdFloodfills));
registerCmd("room", WRAP_METHOD(Debugger, cmdRoom));
registerCmd("itemroom", WRAP_METHOD(Debugger, cmdItemRoom));
registerCmd("findstring", WRAP_METHOD(Debugger, cmdFindString));
registerCmd("draw", WRAP_METHOD(Debugger, cmdDraw));
registerCmd("invlimit", WRAP_METHOD(Debugger, cmdInventoryLimit));
}
Debugger::~Debugger() {
g_debugger = nullptr;
}
void Debugger::print(const char *fmt, ...) {
va_list argp;
va_start(argp, fmt);
Common::String msg = Common::String::vformat(fmt, argp);
va_end(argp);
debugPrintf("%s", msg.c_str());
debugN("%s", msg.c_str());
}
bool Debugger::cmdDump(int argc, const char **argv) {
Common::String type = (argc >= 2) ? argv[1] : "";
uint param = (argc == 3) ? strToInt(argv[2]) : 0;
ComprehendGame *game = g_comprehend->_game;
if (!dumpGameData(game, type, param))
debugPrintf("Unknown dump option\n");
return true;
}
bool Debugger::cmdFloodfills(int argc, const char **argv) {
if (argc == 2 && !strcmp(argv[1], "off")) {
g_comprehend->_drawFlags |= IMAGEF_NO_PAINTING;
debugPrintf("Floodfills are off\n");
} else {
g_comprehend->_drawFlags &= ~IMAGEF_NO_PAINTING;
debugPrintf("Floodfills are on\n");
}
return true;
}
bool Debugger::cmdRoom(int argc, const char **argv) {
ComprehendGame *game = g_comprehend->getGame();
if (argc == 1) {
debugPrintf("Current room = %d\n", game->_currentRoom);
return true;
} else {
game->move_to(strToInt(argv[1]));
game->update_graphics();
return false;
}
}
bool Debugger::cmdItemRoom(int argc, const char **argv) {
ComprehendGame *game = g_comprehend->getGame();
if (argc == 1) {
debugPrintf("itemroom <item> [<room>]\n");
} else {
Item *item = game->get_item(strToInt(argv[1]));
if (argc == 2) {
debugPrintf("Item room = %d\n", item->_room);
} else {
int room = strToInt(argv[2]);
if (room == 0)
room = game->_currentRoom;
bool visibleChange = item->_room == game->_currentRoom ||
room == game->_currentRoom;
item->_room = room;
if (visibleChange) {
game->_updateFlags |= UPDATE_GRAPHICS_ITEMS;
game->update_graphics();
}
return false;
}
}
return true;
}
bool Debugger::cmdFindString(int argc, const char **argv) {
ComprehendGame *game = g_comprehend->getGame();
if (argc == 1) {
debugPrintf("findstring <string>\n");
} else {
for (int arrNum = 0; arrNum < 2; ++arrNum) {
const StringTable &table = (arrNum == 0) ? game->_strings : game->_strings2;
const char *name = (arrNum == 0) ? "_strings" : "_strings2";
for (uint idx = 0; idx < table.size(); ++idx) {
if (table[idx].contains(argv[1]))
debugPrintf("%s[%u] = %s\n", name, idx, table[idx].c_str());
}
}
}
return true;
}
bool Debugger::cmdDraw(int argc, const char **argv) {
if (argc == 1) {
debugPrintf("draw <number>\n");
return true;
} else {
g_comprehend->drawLocationPicture(strToInt(argv[1]), true);
return false;
}
}
bool Debugger::cmdInventoryLimit(int argc, const char **argv) {
if (argc == 1) {
debugPrintf("invlimit on|off\n");
} else {
_invLimit = !strcmp(argv[1], "on") || !strcmp(argv[1], "true");
debugPrintf("inventory limit is now %s\n", _invLimit ? "on" : "off");
}
return true;
}
} // namespace Comprehend
} // namespace Glk
|