From 63fe11702cc38f258f0cddac4258bd7ddcb9bb10 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 12 May 2009 08:14:24 +0000 Subject: Moved the "suffixes" and "words" console commands to ScummVM's debug console svn-id: r40473 --- engines/sci/console.cpp | 50 +++++++++++++++++++++++++++++++++++ engines/sci/console.h | 2 ++ engines/sci/engine/scriptconsole.cpp | 51 ------------------------------------ 3 files changed, 52 insertions(+), 51 deletions(-) diff --git a/engines/sci/console.cpp b/engines/sci/console.cpp index 5aef1919f1..038cb09da9 100644 --- a/engines/sci/console.cpp +++ b/engines/sci/console.cpp @@ -82,6 +82,8 @@ Console::Console(SciEngine *vm) : GUI::Debugger() { DCmd_Register("version", WRAP_METHOD(Console, cmdGetVersion)); DCmd_Register("selectors", WRAP_METHOD(Console, cmdSelectors)); DCmd_Register("kernelnames", WRAP_METHOD(Console, cmdKernelNames)); + DCmd_Register("suffixes", WRAP_METHOD(Console, cmdSuffixes)); + DCmd_Register("words", WRAP_METHOD(Console, cmdWords)); DCmd_Register("man", WRAP_METHOD(Console, cmdMan)); } @@ -146,6 +148,54 @@ bool Console::cmdKernelNames(int argc, const char **argv) { return true; } +bool Console::cmdSuffixes(int argc, const char **argv) { + SuffixList suffixes; + char word_buf[256], alt_buf[256]; + + if (!vocab_get_suffixes(_vm->getResMgr(), suffixes)) { + DebugPrintf("No suffix vocabulary.\n"); + return true; + } + + int i = 0; + for (SuffixList::const_iterator suf = suffixes.begin(); suf != suffixes.end(); ++suf) { + strncpy(word_buf, suf->word_suffix, suf->word_suffix_length); + word_buf[suf->word_suffix_length] = 0; + strncpy(alt_buf, suf->alt_suffix, suf->alt_suffix_length); + alt_buf[suf->alt_suffix_length] = 0; + + DebugPrintf("%4d: (%03x) -%12s => -%12s (%03x)\n", i, suf->class_mask, word_buf, alt_buf, suf->result_class); + ++i; + } + + vocab_free_suffixes(_vm->getResMgr(), suffixes); + + return true; +} + +bool Console::cmdWords(int argc, const char **argv) { + WordMap words; + + vocab_get_words(_vm->getResMgr(), words); + + if (words.empty()) { + DebugPrintf("No vocabulary.\n"); + return true; + } + + int j = 0; + for (WordMap::iterator i = words.begin(); i != words.end(); ++i) { + DebugPrintf("%4d: %03x [%03x] %20s |", j, i->_value._class, i->_value._group, i->_key.c_str()); + if (j % 3 == 0) + DebugPrintf("\n"); + j++; + } + + DebugPrintf("\n"); + + return true; +} + bool Console::cmdMan(int argc, const char **argv) { #if 0 int section = 0; diff --git a/engines/sci/console.h b/engines/sci/console.h index 45e8bc6981..e1890ac4c2 100644 --- a/engines/sci/console.h +++ b/engines/sci/console.h @@ -46,6 +46,8 @@ private: bool cmdGetVersion(int argc, const char **argv); bool cmdSelectors(int argc, const char **argv); bool cmdKernelNames(int argc, const char **argv); + bool cmdSuffixes(int argc, const char **argv); + bool cmdWords(int argc, const char **argv); bool cmdMan(int argc, const char **argv); private: diff --git a/engines/sci/engine/scriptconsole.cpp b/engines/sci/engine/scriptconsole.cpp index 1894c0e8aa..6ba2afcf1c 100644 --- a/engines/sci/engine/scriptconsole.cpp +++ b/engines/sci/engine/scriptconsole.cpp @@ -679,50 +679,6 @@ static ResourceType parseResourceType(const char *resid) { return res; } -static int c_list_words(EngineState *s, const Common::Array &cmdParams) { - WordMap words; - - vocab_get_words(s->resmgr, words); - - if (words.empty()) { - sciprintf("No vocabulary.\n"); - return 1; - } - - int j = 0; - for (WordMap::iterator i = words.begin(); i != words.end(); ++i) { - sciprintf("%4d: %03x [%03x] %s\n", j, i->_value._class, i->_value._group, i->_key.c_str()); - j++; - } - - return 0; -} - -int c_list_suffixes(EngineState *s, const Common::Array &cmdParams) { - SuffixList suffixes; - char word_buf[256], alt_buf[256]; - - if (!vocab_get_suffixes(s->resmgr, suffixes)) { - sciprintf("No suffix vocabulary.\n"); - return 1; - } - - int i = 0; - for (SuffixList::const_iterator suf = suffixes.begin(); suf != suffixes.end(); ++suf) { - strncpy(word_buf, suf->word_suffix, suf->word_suffix_length); - word_buf[suf->word_suffix_length] = 0; - strncpy(alt_buf, suf->alt_suffix, suf->alt_suffix_length); - alt_buf[suf->alt_suffix_length] = 0; - - sciprintf("%4d: (%03x) -%12s => -%12s (%03x)\n", i, suf->class_mask, word_buf, alt_buf, suf->result_class); - ++i; - } - - vocab_free_suffixes(s->resmgr, suffixes); - - return 0; -} - static void _cmd_print_command(cmd_mm_entry_t *data, int full) { const char *paramseeker = ((cmd_command_t *)data)->param; @@ -787,8 +743,6 @@ static int c_list(EngineState *s, const Common::Array &cmdParams) { "docs - lists all misc. documentation\n" "\n" "restypes - lists all resource types\n" - "words - lists all kernel words\n" - "suffixes - lists all suffix replacements\n" "[resource] - lists all [resource]s"); } else if (cmdParams.size() == 1) { const char *mm_subsects[3] = {"cmds", "vars", "docs"}; @@ -808,11 +762,6 @@ static int c_list(EngineState *s, const Common::Array &cmdParams) { return 1; } - else if (!strcmp("suffixes", cmdParams[0].str) || !strcmp("suffices", cmdParams[0].str) || !strcmp("sufficos", cmdParams[0].str)) - // sufficos: Accusative Plural of 'suffix' - return c_list_suffixes(s, cmdParams); - else if (!strcmp("words", cmdParams[0].str)) - return c_list_words(s, cmdParams); else if (strcmp("restypes", cmdParams[0].str) == 0) { for (i = 0; i < kResourceTypeInvalid; i++) sciprintf("%s\n", getResourceTypeName((ResourceType)i)); -- cgit v1.2.3