GOB: Add listArchives debug console command

svn-id: r53985
This commit is contained in:
Sven Hesse 2010-10-31 20:51:35 +00:00
parent 16a3cc8a84
commit 1421312cf8
4 changed files with 44 additions and 5 deletions

View File

@ -26,15 +26,17 @@
#include "gob/console.h"
#include "gob/gob.h"
#include "gob/inter.h"
#include "gob/dataio.h"
namespace Gob {
GobConsole::GobConsole(GobEngine *vm) : GUI::Debugger(), _vm(vm) {
DCmd_Register("varSize", WRAP_METHOD(GobConsole, cmd_varSize));
DCmd_Register("var8", WRAP_METHOD(GobConsole, cmd_var8));
DCmd_Register("var16", WRAP_METHOD(GobConsole, cmd_var16));
DCmd_Register("var32", WRAP_METHOD(GobConsole, cmd_var32));
DCmd_Register("varString", WRAP_METHOD(GobConsole, cmd_varString));
DCmd_Register("varSize", WRAP_METHOD(GobConsole, cmd_varSize));
DCmd_Register("var8", WRAP_METHOD(GobConsole, cmd_var8));
DCmd_Register("var16", WRAP_METHOD(GobConsole, cmd_var16));
DCmd_Register("var32", WRAP_METHOD(GobConsole, cmd_var32));
DCmd_Register("varString", WRAP_METHOD(GobConsole, cmd_varString));
DCmd_Register("listArchives", WRAP_METHOD(GobConsole, cmd_listArchives));
}
GobConsole::~GobConsole() {
@ -144,4 +146,18 @@ bool GobConsole::cmd_varString(int argc, const char **argv) {
return true;
}
bool GobConsole::cmd_listArchives(int argc, const char **argv) {
Common::Array<ArchiveInfo> info;
_vm->_dataIO->getArchiveInfo(info);
DebugPrintf(" Archive | Base | FileCount\n");
DebugPrintf("--------------------------------\n");
for (Common::Array<ArchiveInfo>::const_iterator it = info.begin(); it != info.end(); ++it)
if (!it->name.empty())
DebugPrintf("%13s | %d | %d\n", it->name.c_str(), it->base, it->fileCount);
return true;
}
} // End of namespace Gob

View File

@ -49,6 +49,8 @@ private:
bool cmd_var16(int argc, const char **argv);
bool cmd_var32(int argc, const char **argv);
bool cmd_varString(int argc, const char **argv);
bool cmd_listArchives(int argc, const char **argv);
};
} // End of namespace Mohawk

View File

@ -60,6 +60,19 @@ DataIO::~DataIO() {
}
}
void DataIO::getArchiveInfo(Common::Array<ArchiveInfo> &info) const {
info.resize(_archives.size());
for (uint i = 0; i < _archives.size(); i++) {
if (!_archives[i])
continue;
info[i].name = _archives[i]->name;
info[i].base = _archives[i]->base;
info[i].fileCount = _archives[i]->files.size();
}
}
byte *DataIO::unpack(const byte *src, uint32 srcSize, int32 &size) {
size = READ_LE_UINT32(src);

View File

@ -38,11 +38,19 @@ namespace Common {
namespace Gob {
struct ArchiveInfo {
Common::String name;
bool base;
uint32 fileCount;
};
class DataIO {
public:
DataIO();
~DataIO();
void getArchiveInfo(Common::Array<ArchiveInfo> &info) const;
bool openArchive(Common::String name, bool base);
bool closeArchive(bool base);