SCI: Add alloc_list command to debugger
This command lists all resources that are currently loaded into memory, plus the number of locks that exist on each loaded resource.
This commit is contained in:
parent
9e7c75cc79
commit
fcaf15aa50
3 changed files with 35 additions and 0 deletions
|
@ -112,6 +112,7 @@ Console::Console(SciEngine *engine) : GUI::Debugger(),
|
|||
registerCmd("resource_info", WRAP_METHOD(Console, cmdResourceInfo));
|
||||
registerCmd("resource_types", WRAP_METHOD(Console, cmdResourceTypes));
|
||||
registerCmd("list", WRAP_METHOD(Console, cmdList));
|
||||
registerCmd("alloc_list", WRAP_METHOD(Console, cmdAllocList));
|
||||
registerCmd("hexgrep", WRAP_METHOD(Console, cmdHexgrep));
|
||||
registerCmd("verify_scripts", WRAP_METHOD(Console, cmdVerifyScripts));
|
||||
// Game
|
||||
|
@ -364,6 +365,7 @@ bool Console::cmdHelp(int argc, const char **argv) {
|
|||
debugPrintf(" resource_info - Shows info about a resource\n");
|
||||
debugPrintf(" resource_types - Shows the valid resource types\n");
|
||||
debugPrintf(" list - Lists all the resources of a given type\n");
|
||||
debugPrintf(" alloc_list - Lists all allocated resources\n");
|
||||
debugPrintf(" hexgrep - Searches some resources for a particular sequence of bytes, represented as hexadecimal numbers\n");
|
||||
debugPrintf(" verify_scripts - Performs sanity checks on SCI1.1-SCI2.1 game scripts (e.g. if they're up to 64KB in total)\n");
|
||||
debugPrintf("\n");
|
||||
|
@ -910,6 +912,36 @@ bool Console::cmdList(int argc, const char **argv) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Console::cmdAllocList(int argc, const char **argv) {
|
||||
ResourceManager *resMan = _engine->getResMan();
|
||||
|
||||
for (int i = 0; i < kResourceTypeInvalid; ++i) {
|
||||
Common::List<ResourceId> resources = _engine->getResMan()->listResources((ResourceType)i);
|
||||
if (resources.size()) {
|
||||
Common::sort(resources.begin(), resources.end());
|
||||
bool hasAlloc = false;
|
||||
Common::List<ResourceId>::const_iterator it;
|
||||
for (it = resources.begin(); it != resources.end(); ++it) {
|
||||
Resource *resource = resMan->testResource(*it);
|
||||
if (resource != nullptr && resource->data() != nullptr) {
|
||||
if (hasAlloc) {
|
||||
debugPrintf(", ");
|
||||
} else {
|
||||
debugPrintf("%s: ", getResourceTypeName((ResourceType)i));
|
||||
}
|
||||
hasAlloc = true;
|
||||
debugPrintf("%u (%u locks)", resource->getNumber(), resource->getNumLockers());
|
||||
}
|
||||
}
|
||||
if (hasAlloc) {
|
||||
debugPrintf("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Console::cmdDissectScript(int argc, const char **argv) {
|
||||
if (argc != 2) {
|
||||
debugPrintf("Examines a script\n");
|
||||
|
|
|
@ -78,6 +78,7 @@ private:
|
|||
bool cmdResourceInfo(int argc, const char **argv);
|
||||
bool cmdResourceTypes(int argc, const char **argv);
|
||||
bool cmdList(int argc, const char **argv);
|
||||
bool cmdAllocList(int argc, const char **argv);
|
||||
bool cmdHexgrep(int argc, const char **argv);
|
||||
bool cmdVerifyScripts(int argc, const char **argv);
|
||||
// Game
|
||||
|
|
|
@ -277,6 +277,8 @@ public:
|
|||
// eases transition.
|
||||
uint32 getAudioCompressionType() const;
|
||||
|
||||
uint16 getNumLockers() const { return _lockers; }
|
||||
|
||||
protected:
|
||||
ResourceId _id; // TODO: _id could almost be made const, only readResourceInfo() modifies it...
|
||||
int32 _fileOffset; /**< Offset in file */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue