2016-03-26 23:26:22 +01:00
|
|
|
/* 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 2
|
|
|
|
* 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, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2016-03-31 15:39:46 +02:00
|
|
|
#include "common/debug-channels.h"
|
|
|
|
|
2016-03-26 23:26:22 +01:00
|
|
|
#include "adl/console.h"
|
2016-03-27 14:36:14 +02:00
|
|
|
#include "adl/adl.h"
|
2016-03-26 23:26:22 +01:00
|
|
|
|
|
|
|
namespace Adl {
|
|
|
|
|
|
|
|
Console::Console(AdlEngine *engine) : GUI::Debugger() {
|
|
|
|
_engine = engine;
|
2016-03-27 14:36:14 +02:00
|
|
|
|
|
|
|
registerCmd("nouns", WRAP_METHOD(Console, Cmd_Nouns));
|
|
|
|
registerCmd("verbs", WRAP_METHOD(Console, Cmd_Verbs));
|
2016-03-31 15:39:46 +02:00
|
|
|
registerCmd("dump_scripts", WRAP_METHOD(Console, Cmd_DumpScripts));
|
2016-03-27 14:36:14 +02:00
|
|
|
}
|
|
|
|
|
2016-03-31 15:39:46 +02:00
|
|
|
Common::String Console::toAscii(const Common::String &str) {
|
2016-03-27 14:36:14 +02:00
|
|
|
Common::String ascii(str);
|
|
|
|
|
|
|
|
for (uint i = 0; i < ascii.size(); ++i)
|
|
|
|
ascii.setChar(ascii[i] & 0x7f, i);
|
|
|
|
|
|
|
|
return ascii;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Console::Cmd_Verbs(int argc, const char **argv) {
|
|
|
|
if (argc != 1) {
|
|
|
|
debugPrintf("Usage: %s\n", argv[0]);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
debugPrintf("Verbs in alphabetical order:\n");
|
|
|
|
printWordMap(_engine->_verbs);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Console::Cmd_Nouns(int argc, const char **argv) {
|
|
|
|
if (argc != 1) {
|
|
|
|
debugPrintf("Usage: %s\n", argv[0]);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
debugPrintf("Nouns in alphabetical order:\n");
|
|
|
|
printWordMap(_engine->_nouns);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-03-31 15:39:46 +02:00
|
|
|
bool Console::Cmd_DumpScripts(int argc, const char **argv) {
|
|
|
|
if (argc != 1) {
|
|
|
|
debugPrintf("Usage: %s\n", argv[0]);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool oldFlag = DebugMan.isDebugChannelEnabled(kDebugChannelScript);
|
|
|
|
|
|
|
|
DebugMan.enableDebugChannel("Script");
|
|
|
|
|
|
|
|
_engine->_dumpFile = new Common::DumpFile();
|
|
|
|
|
2016-04-01 00:29:46 +02:00
|
|
|
for (byte roomNr = 1; roomNr <= _engine->_state.rooms.size(); ++roomNr) {
|
2016-04-01 00:13:21 +02:00
|
|
|
_engine->loadRoom(roomNr);
|
|
|
|
if (_engine->_roomData.commands.size() != 0) {
|
|
|
|
_engine->_dumpFile->open(Common::String::format("%03d.ADL", roomNr).c_str());
|
|
|
|
_engine->doAllCommands(_engine->_roomData.commands, IDI_ANY, IDI_ANY);
|
|
|
|
_engine->_dumpFile->close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_engine->loadRoom(_engine->_state.room);
|
|
|
|
|
2016-03-31 15:39:46 +02:00
|
|
|
_engine->_dumpFile->open("GLOBAL.ADL");
|
|
|
|
_engine->doAllCommands(_engine->_globalCommands, IDI_ANY, IDI_ANY);
|
|
|
|
_engine->_dumpFile->close();
|
|
|
|
|
|
|
|
_engine->_dumpFile->open("RESPONSE.ADL");
|
|
|
|
_engine->doAllCommands(_engine->_roomCommands, IDI_ANY, IDI_ANY);
|
|
|
|
_engine->_dumpFile->close();
|
|
|
|
|
|
|
|
delete _engine->_dumpFile;
|
|
|
|
_engine->_dumpFile = nullptr;
|
|
|
|
|
|
|
|
if (!oldFlag)
|
|
|
|
DebugMan.disableDebugChannel("Script");
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-03-27 14:36:14 +02:00
|
|
|
void Console::printWordMap(const WordMap &wordMap) {
|
|
|
|
Common::StringArray words;
|
|
|
|
WordMap::const_iterator verb;
|
|
|
|
|
|
|
|
for (verb = wordMap.begin(); verb != wordMap.end(); ++verb)
|
|
|
|
words.push_back(verb->_key);
|
|
|
|
|
|
|
|
Common::sort(words.begin(), words.end());
|
|
|
|
|
|
|
|
Common::StringArray::const_iterator word;
|
|
|
|
for (word = words.begin(); word != words.end(); ++word)
|
|
|
|
debugPrintf("%s: %d\n", toAscii(*word).c_str(), wordMap[*word]);
|
2016-03-26 23:26:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
} // End of namespace Adl
|