aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBendegúz Nagy2016-08-11 10:57:16 +0200
committerBendegúz Nagy2016-08-26 23:02:22 +0200
commit9e333a6216df0363e9fd07876308ab5966de5c42 (patch)
tree0157fef5989ab367ee0e7394d381d86379b81516
parent834595a7f9de4835e93823caa8df5c0e175102c8 (diff)
downloadscummvm-rg350-9e333a6216df0363e9fd07876308ab5966de5c42.tar.gz
scummvm-rg350-9e333a6216df0363e9fd07876308ab5966de5c42.tar.bz2
scummvm-rg350-9e333a6216df0363e9fd07876308ab5966de5c42.zip
DM: Add search by substring in listItems debug command
-rw-r--r--engines/dm/console.cpp33
1 files changed, 28 insertions, 5 deletions
diff --git a/engines/dm/console.cpp b/engines/dm/console.cpp
index e9a937c823..b8fae4285b 100644
--- a/engines/dm/console.cpp
+++ b/engines/dm/console.cpp
@@ -195,16 +195,39 @@ argumentError:
}
bool Console::Cmd_listItems(int argc, const char** argv) {
- debugPrintf("| %s", _vm->_objectMan->_g352_objectNames[0]);
+ Common::String searchedString = "";
+ for (int16 i = 1; i < argc; ++i) {
+ searchedString += argv[i];
+ searchedString += " ";
+ }
+ searchedString.deleteLastChar();
+
+ bool atleastOneFound = false;
+ int16 namesPrintedInLine = 0;
+
+ if(strstr(_vm->_objectMan->_g352_objectNames[0], searchedString.c_str()) != nullptr)
+ debugPrintf("| %s", _vm->_objectMan->_g352_objectNames[0]);
+
for (uint16 i = 1; i < k199_ObjectNameCount; ++i) {
const char *name = _vm->_objectMan->_g352_objectNames[i - 1];
const char *prevName = _vm->_objectMan->_g352_objectNames[i];
- if (!cstrEquals(prevName, name))
+
+ if (!cstrEquals(name, prevName) && (strstr(name, searchedString.c_str()) != nullptr)) {
debugPrintf(" | %s", name);
- if (i % 5 == 0)
- debugPrintf("\n");
+ atleastOneFound = true;
+
+ if ((++namesPrintedInLine % 6) == 0) {
+ namesPrintedInLine = 0;
+ debugPrintf("\n");
+ }
+ }
+ }
+
+ if (atleastOneFound) {
+ debugPrintf("\n");
+ } else {
+ debugPrintf("No itemnames found containing '%s'\n", searchedString.c_str());
}
- debugPrintf("\n");
return true;
}