aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/console.cpp
diff options
context:
space:
mode:
authorMartin Kiewitz2015-05-04 21:19:05 +0200
committerMartin Kiewitz2015-05-04 21:19:05 +0200
commited7007162a092e4b9e3d9306b078af5a8984cad0 (patch)
tree466c6b93adb5ee00550ee428e188896ae655b2a9 /engines/sci/console.cpp
parent3d0c691694ddcf00a5bfc347626d38625f057dee (diff)
downloadscummvm-rg350-ed7007162a092e4b9e3d9306b078af5a8984cad0.tar.gz
scummvm-rg350-ed7007162a092e4b9e3d9306b078af5a8984cad0.tar.bz2
scummvm-rg350-ed7007162a092e4b9e3d9306b078af5a8984cad0.zip
SCI: Scripts: identify strings + debug command
debug command is called "script_strings" / "scrs"
Diffstat (limited to 'engines/sci/console.cpp')
-rw-r--r--engines/sci/console.cpp67
1 files changed, 67 insertions, 0 deletions
diff --git a/engines/sci/console.cpp b/engines/sci/console.cpp
index 3f5548aac7..bc9ad362ab 100644
--- a/engines/sci/console.cpp
+++ b/engines/sci/console.cpp
@@ -209,6 +209,8 @@ Console::Console(SciEngine *engine) : GUI::Debugger(),
registerCmd("bpe", WRAP_METHOD(Console, cmdBreakpointFunction)); // alias
// VM
registerCmd("script_steps", WRAP_METHOD(Console, cmdScriptSteps));
+ registerCmd("script_strings", WRAP_METHOD(Console, cmdScriptStrings));
+ registerCmd("scrs", WRAP_METHOD(Console, cmdScriptStrings));
registerCmd("vm_varlist", WRAP_METHOD(Console, cmdVMVarlist));
registerCmd("vmvarlist", WRAP_METHOD(Console, cmdVMVarlist)); // alias
registerCmd("vl", WRAP_METHOD(Console, cmdVMVarlist)); // alias
@@ -2828,6 +2830,71 @@ bool Console::cmdScriptSteps(int argc, const char **argv) {
return true;
}
+bool Console::cmdScriptStrings(int argc, const char **argv) {
+ SegManager *segMan = _engine->_gamestate->_segMan;
+ int curScriptNr = -1;
+ SegmentId curSegmentNr;
+ Common::List<SegmentId> segmentNrList;
+
+ SegmentType curSegmentType = SEG_TYPE_INVALID;
+ SegmentObj *curSegmentObj = NULL;
+ Script *curScriptObj = NULL;
+
+ if (argc < 2) {
+ debugPrintf("Shows the strings inside a specified script.\n");
+ debugPrintf("Usage: %s <script number>\n", argv[0]);
+ debugPrintf("Example: %s 999\n", argv[0]);
+ debugPrintf("<script number> may be * to show strings inside all loaded scripts\n");
+ return true;
+ }
+
+ segmentNrList.clear();
+
+ if (strcmp(argv[1], "*") == 0) {
+ // get strings of all currently loaded scripts
+ for (curSegmentNr = 0; curSegmentNr < segMan->_heap.size(); curSegmentNr++) {
+ curSegmentObj = segMan->_heap[curSegmentNr];
+ if (curSegmentObj && curSegmentObj->getType() == SEG_TYPE_SCRIPT) {
+ segmentNrList.push_back(curSegmentNr);
+ }
+ }
+
+ } else {
+ curScriptNr = atoi(argv[1]);
+ curSegmentNr = segMan->getScriptSegment(curScriptNr);
+ if (!curSegmentNr) {
+ debugPrintf("Script %d is currently not loaded/available\n", curScriptNr);
+ return true;
+ }
+ segmentNrList.push_back(curSegmentNr);
+ }
+
+ Common::List<SegmentId>::iterator it;
+ const Common::List<SegmentId>::iterator end = segmentNrList.end();
+
+ for (it = segmentNrList.begin(); it != end; it++) {
+ curSegmentNr = *it;
+ // get object of this segment
+ curSegmentObj = segMan->getSegmentObj(curSegmentNr);
+ if (!curSegmentObj)
+ continue;
+
+ curSegmentType = curSegmentObj->getType();
+ if (curSegmentType != SEG_TYPE_SCRIPT) // safety check
+ continue;
+
+ curScriptObj = (Script *)curSegmentObj;
+ debugPrintf("=== SCRIPT %d from Segment %d ===\n", curScriptObj->getScriptNumber(), curSegmentNr);
+ debugN("=== SCRIPT %d from Segment %d ===\n", curScriptObj->getScriptNumber(), curSegmentNr);
+
+ // now print the string list
+ curScriptObj->debugPrintStrings(this);
+ debugPrintf("\n");
+ debugN("\n");
+ }
+ return true;
+}
+
bool Console::cmdBacktrace(int argc, const char **argv) {
debugPrintf("Call stack (current base: 0x%x):\n", _engine->_gamestate->executionStackBase);
Common::List<ExecStack>::const_iterator iter;