diff options
Diffstat (limited to 'engines/sci/engine')
-rw-r--r-- | engines/sci/engine/game.cpp | 12 | ||||
-rw-r--r-- | engines/sci/engine/kscripts.cpp | 6 | ||||
-rw-r--r-- | engines/sci/engine/savegame.cfsml | 3 | ||||
-rw-r--r-- | engines/sci/engine/savegame.cpp | 5 | ||||
-rw-r--r-- | engines/sci/engine/scriptconsole.cpp | 16 | ||||
-rw-r--r-- | engines/sci/engine/scriptdebug.cpp | 10 | ||||
-rw-r--r-- | engines/sci/engine/vm.cpp | 4 |
7 files changed, 21 insertions, 35 deletions
diff --git a/engines/sci/engine/game.cpp b/engines/sci/engine/game.cpp index 1afc2ffe51..9c5a23ed2e 100644 --- a/engines/sci/engine/game.cpp +++ b/engines/sci/engine/game.cpp @@ -59,14 +59,11 @@ static int _init_vocabulary(EngineState *s) { // initialize vocabulary and relat s->opcodes = vocabulary_get_opcodes(s->resmgr); - if (!(s->selector_names = vocabulary_get_snames(s->resmgr, NULL, s->version))) { + if (!vocabulary_get_snames(s->resmgr, s->version, s->_selectorNames)) { sciprintf("_init_vocabulary(): Could not retrieve selector names (vocab.997)!\n"); return 1; } - for (s->selector_names_nr = 0; s->selector_names[s->selector_names_nr]; s->selector_names_nr++); - // Counts the number of selector names - script_map_selectors(s, &(s->selector_map)); // Maps a few special selectors for later use @@ -85,12 +82,11 @@ static void _free_vocabulary(EngineState *s) { vocab_free_rule_list(s->parser_rules); } - vocabulary_free_snames(s->selector_names); + s->_selectorNames.clear(); vocabulary_free_knames(s->kernel_names); vocabulary_free_opcodes(s->opcodes); s->opcodes = NULL; - s->selector_names = NULL; s->kernel_names = NULL; s->opcodes = NULL; } @@ -586,8 +582,6 @@ EngineState::EngineState() { seg_manager = 0; gc_countdown = 0; - selector_names_nr = 0; - selector_names = 0; kernel_names_nr = 0; kernel_names = 0; @@ -781,7 +775,7 @@ int game_init(EngineState *s) { srand(g_system->getMillis()); // Initialize random number generator -// script_dissect(0, s->selector_names, s->selector_names_nr); +// script_dissect(0, s->_selectorNames); game_obj = script_lookup_export(s, 0, 0); // The first entry in the export table of script 0 points to the game object diff --git a/engines/sci/engine/kscripts.cpp b/engines/sci/engine/kscripts.cpp index e231a213da..ce1ffec63b 100644 --- a/engines/sci/engine/kscripts.cpp +++ b/engines/sci/engine/kscripts.cpp @@ -41,7 +41,7 @@ reg_t read_selector(EngineState *s, reg_t object, selector_t selector_id, const void write_selector(EngineState *s, reg_t object, selector_t selector_id, reg_t value, const char *fname, int line) { reg_t *address; - if ((selector_id < 0) || (selector_id > s->selector_names_nr)) { + if ((selector_id < 0) || (selector_id > (int)s->_selectorNames.size())) { warning("Attempt to write to invalid selector %d of" " object at "PREG" (%s L%d).", selector_id, PRINT_REG(object), fname, line); return; @@ -49,7 +49,7 @@ void write_selector(EngineState *s, reg_t object, selector_t selector_id, reg_t if (lookup_selector(s, object, selector_id, &address, NULL) != SELECTOR_VARIABLE) warning("Selector '%s' of object at "PREG" could not be" - " written to (%s L%d)", s->selector_names[selector_id], PRINT_REG(object), fname, line); + " written to (%s L%d)", s->_selectorNames[selector_id].c_str(), PRINT_REG(object), fname, line); else *address = value; } @@ -72,7 +72,7 @@ int invoke_selector(EngineState *s, reg_t object, int selector_id, int noinvalid if (slc_type == SELECTOR_NONE) { SCIkwarn(SCIkERROR, "Selector '%s' of object at "PREG" could not be invoked (%s L%d)\n", - s->selector_names[selector_id], PRINT_REG(object), fname, line); + s->_selectorNames[selector_id].c_str(), PRINT_REG(object), fname, line); if (noinvalid == 0) KERNEL_OOPS("Not recoverable: VM was halted\n"); return 1; diff --git a/engines/sci/engine/savegame.cfsml b/engines/sci/engine/savegame.cfsml index 274b1a63db..8475bbd279 100644 --- a/engines/sci/engine/savegame.cfsml +++ b/engines/sci/engine/savegame.cfsml @@ -1124,8 +1124,7 @@ EngineState *gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) { retval->parser_branches = s->parser_branches; // static VM/Kernel information: - retval->selector_names_nr = s->selector_names_nr; - retval->selector_names = s->selector_names; + retval->_selectorNames = s->_selectorNames; retval->kernel_names_nr = s->kernel_names_nr; retval->kernel_names = s->kernel_names; retval->kfunct_table = s->kfunct_table; diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp index 96526f995f..6d48bbcf96 100644 --- a/engines/sci/engine/savegame.cpp +++ b/engines/sci/engine/savegame.cpp @@ -5253,8 +5253,7 @@ EngineState *gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) { retval->parser_branches = s->parser_branches; // static VM/Kernel information: - retval->selector_names_nr = s->selector_names_nr; - retval->selector_names = s->selector_names; + retval->_selectorNames = s->_selectorNames; retval->kernel_names_nr = s->kernel_names_nr; retval->kernel_names = s->kernel_names; retval->kfunct_table = s->kfunct_table; @@ -5327,7 +5326,7 @@ bool get_savegame_metadata(Common::SeekableReadStream* stream, SavegameMetadata* } } // End of auto-generated CFSML data reader code -#line 1170 "engines/sci/engine/savegame.cfsml" +#line 1169 "engines/sci/engine/savegame.cfsml" if (read_eof) return false; diff --git a/engines/sci/engine/scriptconsole.cpp b/engines/sci/engine/scriptconsole.cpp index c352f2ae9d..b81b2794d3 100644 --- a/engines/sci/engine/scriptconsole.cpp +++ b/engines/sci/engine/scriptconsole.cpp @@ -1010,28 +1010,22 @@ static int c_hexgrep(EngineState *s) { } static int c_selectornames(EngineState * s) { - int namectr; - char **snames = NULL; - int seeker = 0; + Common::StringList selectorNames; if (NULL == s) { sciprintf("console.c: c_selectornames(): NULL passed for parameter s\n"); return -1; } - snames = vocabulary_get_snames(s->resmgr, &namectr, s ? s->version : 0); - - if (!snames) { + if (!vocabulary_get_snames(s->resmgr, s ? s->version : 0, selectorNames)) { sciprintf("No selector name table found!\n"); return 1; } sciprintf("Selector names in numeric order:\n"); - while (snames[seeker]) { - sciprintf("%03x: %s\n", seeker, snames[seeker]); - seeker++; + for (uint seeker = 0; seeker < selectorNames.size(); seeker++) { + sciprintf("%03x: %s\n", seeker, selectorNames[seeker].c_str()); } - vocabulary_free_snames(snames); return 0; } @@ -1066,7 +1060,7 @@ static int c_dissectscript(EngineState * s) { return -1; } - script_dissect(s->resmgr, cmd_params[0].val, s->selector_names, s->selector_names_nr); + script_dissect(s->resmgr, cmd_params[0].val, s->_selectorNames); return 0; } diff --git a/engines/sci/engine/scriptdebug.cpp b/engines/sci/engine/scriptdebug.cpp index eaa39f777c..6de049f84e 100644 --- a/engines/sci/engine/scriptdebug.cpp +++ b/engines/sci/engine/scriptdebug.cpp @@ -1173,8 +1173,8 @@ int c_stack(EngineState *s) { } const char *selector_name(EngineState *s, int selector) { - if (selector >= 0 && selector < s->selector_names_nr) - return s->selector_names[selector]; + if (selector >= 0 && selector < (int)s->_selectorNames.size()) + return s->_selectorNames[selector].c_str(); else return "--INVALID--"; } @@ -1422,7 +1422,7 @@ reg_t disassemble(EngineState *s, reg_t pos, int print_bw_tag, int print_bytecod if (!name) name = "<invalid>"; - sciprintf(" %s::%s[", name, (selector > s->selector_names_nr) ? "<invalid>" : selector_name(s, selector)); + sciprintf(" %s::%s[", name, (selector > s->_selectorNames.size()) ? "<invalid>" : selector_name(s, selector)); switch (lookup_selector(s, called_obj_addr, selector, &val_ref, &fun_ref)) { case SELECTOR_METHOD: @@ -1557,7 +1557,7 @@ static int c_backtrace(EngineState *s) { case EXEC_STACK_TYPE_VARSELECTOR: sciprintf(" %x:[%x] vs%s %s::%s (", i, call->origin, (call->argc) ? "write" : "read", - objname, s->selector_names[call->selector]); + objname, s->_selectorNames[call->selector].c_str()); break; } @@ -2155,7 +2155,7 @@ static int c_send(EngineState *s) { reg_t *vptr; reg_t fptr; - selector_id = vocabulary_lookup_sname(s->selector_names, selector_name); + selector_id = vocabulary_lookup_sname(s->_selectorNames, selector_name); if (selector_id < 0) { sciprintf("Unknown selector: \"%s\"\n", selector_name); diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp index 29ac898abb..8669178abf 100644 --- a/engines/sci/engine/vm.cpp +++ b/engines/sci/engine/vm.cpp @@ -346,7 +346,7 @@ exec_stack_t *send_selector(EngineState *s, reg_t send_obj, reg_t work_obj, stac breakpoint_t *bp; char method_name [256]; - sprintf(method_name, "%s::%s", obj_get_name(s, send_obj), s->selector_names [selector]); + sprintf(method_name, "%s::%s", obj_get_name(s, send_obj), s->_selectorNames[selector].c_str()); bp = s->bp_list; while (bp) { @@ -365,7 +365,7 @@ exec_stack_t *send_selector(EngineState *s, reg_t send_obj, reg_t work_obj, stac } #ifdef VM_DEBUG_SEND - sciprintf("Send to "PREG", selector %04x (%s):", PRINT_REG(send_obj), selector, s->selector_names[selector]); + sciprintf("Send to "PREG", selector %04x (%s):", PRINT_REG(send_obj), selector, s->_selectorNames[selector].c_str()); #endif // VM_DEBUG_SEND if (++send_calls_nr == (send_calls_allocated - 1)) { |