Skip to content

Commit

Permalink
XEEN: Added dump command to the debugger
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Sep 17, 2016
1 parent 34b266b commit ad9e00d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
31 changes: 31 additions & 0 deletions engines/xeen/debugger.cpp
Expand Up @@ -47,6 +47,7 @@ static int strToInt(const char *s) {
Debugger::Debugger(XeenEngine *vm) : GUI::Debugger(), _vm(vm) {
registerCmd("continue", WRAP_METHOD(Debugger, cmdExit));
registerCmd("spell", WRAP_METHOD(Debugger, cmdSpell));
registerCmd("dump", WRAP_METHOD(Debugger, cmdDump));

_spellId = -1;
}
Expand Down Expand Up @@ -82,4 +83,34 @@ bool Debugger::cmdSpell(int argc, const char **argv) {
return true;
}

bool Debugger::cmdDump(int argc, const char **argv) {
File f;

if (argc < 2) {
debugPrintf("Format: spell <resource name>\n");

This comment has been minimized.

Copy link
@bluegr

bluegr Sep 17, 2016

Member

Typo: "dump", not "spell" (or you could just use argv[0])

} else {
if (argc == 2)
f.open(argv[1]);
else
f.open(argv[1], *_vm->_files->_sideArchives[strToInt(argv[2]) == 0 ? 0 : 1]);

if (f.isOpen()) {
Common::DumpFile df;
df.open(argv[1]);
byte *data = new byte[f.size()];
f.read(data, f.size());
df.write(data, f.size());

f.close();
df.close();
delete[] data;
debugPrintf("Saved\n");
} else {
debugPrintf("Could not find resource with that name\n");
}
}

return true;
}

} // End of namespace Xeen
1 change: 1 addition & 0 deletions engines/xeen/debugger.h
Expand Up @@ -36,6 +36,7 @@ class Debugger : public GUI::Debugger {
int _spellId;

bool cmdSpell(int argc, const char **argv);
bool cmdDump(int argc, const char **argv);
public:
Debugger(XeenEngine *vm);

Expand Down

0 comments on commit ad9e00d

Please sign in to comment.