From 61ab59138a1e1ba1bac9cdb0dbf3c5372667930d Mon Sep 17 00:00:00 2001 From: Greg Frieger Date: Sat, 28 Feb 2009 21:59:49 +0000 Subject: resource_t struct replaced with stub Resource class for future objectifying. Also the crash when exiting SCI1 games was fixed svn-id: r38982 --- engines/sci/engine/game.cpp | 12 ++++++------ engines/sci/engine/kmenu.cpp | 2 +- engines/sci/engine/kscripts.cpp | 2 +- engines/sci/engine/ksound.cpp | 4 ++-- engines/sci/engine/kstring.cpp | 4 ++-- engines/sci/engine/message.cpp | 2 +- engines/sci/engine/message.h | 2 +- engines/sci/engine/savegame.cpp | 2 +- engines/sci/engine/scriptconsole.cpp | 6 +++--- engines/sci/engine/scriptdebug.cpp | 6 +++--- engines/sci/engine/seg_manager.cpp | 4 ++-- engines/sci/engine/vm.cpp | 8 ++++---- 12 files changed, 27 insertions(+), 27 deletions(-) (limited to 'engines/sci/engine') diff --git a/engines/sci/engine/game.cpp b/engines/sci/engine/game.cpp index 9d5f20043b..3b53dcb659 100644 --- a/engines/sci/engine/game.cpp +++ b/engines/sci/engine/game.cpp @@ -119,7 +119,7 @@ static void _sci1_alloc_system_colors(EngineState *s) { } int _reset_graphics_input(EngineState *s) { - resource_t *resource; + Resource *resource; int font_nr; gfx_color_t transparent; sciprintf("Initializing graphics\n"); @@ -279,7 +279,7 @@ int game_init_sound(EngineState *s, int sound_flags) { /* Maps a class ID to the script the corresponding class is contained in Returns the script number suggested by vocab.996, or -1 if there's none */ -static int suggested_script(resource_t *res, unsigned int classId) { +static int suggested_script(Resource *res, unsigned int classId) { int offset; if (!res || classId >= res->size >> 2) @@ -307,7 +307,7 @@ int create_class_table_sci11(EngineState *s) { char *seeker_ptr; int classnr; - resource_t *vocab996 = s->resmgr->findResource(sci_vocab, 996, 1); + Resource *vocab996 = s->resmgr->findResource(sci_vocab, 996, 1); if (!vocab996) s->classtable_size = 20; @@ -317,7 +317,7 @@ int create_class_table_sci11(EngineState *s) { s->classtable = (Class*)sci_calloc(sizeof(Class), s->classtable_size); for (scriptnr = 0; scriptnr < 1000; scriptnr++) { - resource_t *heap = s->resmgr->findResource(sci_heap, scriptnr, 0); + Resource *heap = s->resmgr->findResource(sci_heap, scriptnr, 0); if (heap) { int global_vars = getUInt16(heap->data + 2); @@ -362,7 +362,7 @@ static int create_class_table_sci0(EngineState *s) { int classnr; int magic_offset; // For strange scripts in older SCI versions - resource_t *vocab996 = s->resmgr->findResource(sci_vocab, 996, 1); + Resource *vocab996 = s->resmgr->findResource(sci_vocab, 996, 1); if (!vocab996) s->classtable_size = 20; @@ -373,7 +373,7 @@ static int create_class_table_sci0(EngineState *s) { for (scriptnr = 0; scriptnr < 1000; scriptnr++) { int objtype = 0; - resource_t *script = s->resmgr->findResource(sci_script, scriptnr, 0); + Resource *script = s->resmgr->findResource(sci_script, scriptnr, 0); if (script) { if (s->version < SCI_VERSION_FTU_NEW_SCRIPT_HEADER) diff --git a/engines/sci/engine/kmenu.cpp b/engines/sci/engine/kmenu.cpp index 71c02e172e..cce2eb4d25 100644 --- a/engines/sci/engine/kmenu.cpp +++ b/engines/sci/engine/kmenu.cpp @@ -203,7 +203,7 @@ void about_freesci(EngineState *s) { int page; gfxw_port_t *port; int bodyfont, titlefont; - resource_t *bodyfont_res = NULL; + Resource *bodyfont_res = NULL; int i; titlefont = s->titlebar_port->font_nr; diff --git a/engines/sci/engine/kscripts.cpp b/engines/sci/engine/kscripts.cpp index f334bfddf8..9517567e21 100644 --- a/engines/sci/engine/kscripts.cpp +++ b/engines/sci/engine/kscripts.cpp @@ -129,7 +129,7 @@ reg_t kLock(EngineState *s, int funct_nr, int argc, reg_t *argv) { int resnr = UKPV(1); int state = argc > 2 ? UKPV(2) : 1; - resource_t *which; + Resource *which; switch (state) { case 1 : diff --git a/engines/sci/engine/ksound.cpp b/engines/sci/engine/ksound.cpp index 3aec1add7d..42d0da4056 100644 --- a/engines/sci/engine/ksound.cpp +++ b/engines/sci/engine/ksound.cpp @@ -93,7 +93,7 @@ namespace Sci { static void script_set_priority(EngineState *s, reg_t obj, int priority) { int song_nr = GET_SEL32V(obj, number); - resource_t *song = s->resmgr->findResource(sci_sound, song_nr, 0); + Resource *song = s->resmgr->findResource(sci_sound, song_nr, 0); int flags = GET_SEL32V(obj, flags); if (priority == -1) { @@ -110,7 +110,7 @@ static void script_set_priority(EngineState *s, reg_t obj, int priority) { } song_iterator_t *build_iterator(EngineState *s, int song_nr, int type, songit_id_t id) { - resource_t *song = s->resmgr->findResource(sci_sound, song_nr, 0); + Resource *song = s->resmgr->findResource(sci_sound, song_nr, 0); if (!song) return NULL; diff --git a/engines/sci/engine/kstring.cpp b/engines/sci/engine/kstring.cpp index ad02576f99..ac113fa9a8 100644 --- a/engines/sci/engine/kstring.cpp +++ b/engines/sci/engine/kstring.cpp @@ -41,7 +41,7 @@ namespace Sci { /* Returns the string the script intended to address */ char *kernel_lookup_text(EngineState *s, reg_t address, int index) { char *seeker; - resource_t *textres; + Resource *textres; if (address.segment) return (char *)kernel_dereference_bulk_pointer(s, address, 0); @@ -709,7 +709,7 @@ reg_t kStrLen(EngineState *s, int funct_nr, int argc, reg_t *argv) { reg_t kGetFarText(EngineState *s, int funct_nr, int argc, reg_t *argv) { - resource_t *textres = s->resmgr->findResource(sci_text, UKPV(0), 0); + Resource *textres = s->resmgr->findResource(sci_text, UKPV(0), 0); char *seeker; int counter = UKPV(1); diff --git a/engines/sci/engine/message.cpp b/engines/sci/engine/message.cpp index 4be5f10042..32bd50401b 100644 --- a/engines/sci/engine/message.cpp +++ b/engines/sci/engine/message.cpp @@ -186,7 +186,7 @@ static MessageHandler fixed_handler = { }; void message_state_initialize(ResourceManager *resmgr, MessageState *state) { - //resource_t *tester = resmgr->findResource(sci_message, 0, 0); + //Resource *tester = resmgr->findResource(sci_message, 0, 0); //int version; //if (tester == NULL) diff --git a/engines/sci/engine/message.h b/engines/sci/engine/message.h index 86ac5c752e..609757d40f 100644 --- a/engines/sci/engine/message.h +++ b/engines/sci/engine/message.h @@ -64,7 +64,7 @@ struct MessageState { int initialized; MessageHandler *handler; ResourceManager *resmgr; - resource_t *current_res; + Resource *current_res; int module; int record_count; byte *index_records; diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp index 3eaadf4c3b..dedcc84090 100644 --- a/engines/sci/engine/savegame.cpp +++ b/engines/sci/engine/savegame.cpp @@ -4942,7 +4942,7 @@ static int clone_entry_used(CloneTable *table, int n) { } static void load_script(EngineState *s, SegmentId seg) { - resource_t *script, *heap = NULL; + Resource *script, *heap = NULL; Script *scr = &(s->seg_manager->heap[seg]->data.script); scr->buf = (byte *)malloc(scr->buf_size); diff --git a/engines/sci/engine/scriptconsole.cpp b/engines/sci/engine/scriptconsole.cpp index a8c79bd962..f46c3ccf5c 100644 --- a/engines/sci/engine/scriptconsole.cpp +++ b/engines/sci/engine/scriptconsole.cpp @@ -913,7 +913,7 @@ static int c_size(EngineState *s) { if (res == -1) sciprintf("Resource type '%s' is not valid\n", cmd_params[0].str); else { - resource_t *resource = s->resmgr->findResource(res, cmd_params[1].val, 0); + Resource *resource = s->resmgr->findResource(res, cmd_params[1].val, 0); if (resource) { sciprintf("Size: %d\n", resource->size); } else @@ -929,7 +929,7 @@ static int c_dump(EngineState *s) { if (res == -1) sciprintf("Resource type '%s' is not valid\n", cmd_params[0].str); else { - resource_t *resource = s->resmgr->findResource(res, cmd_params[1].val, 0); + Resource *resource = s->resmgr->findResource(res, cmd_params[1].val, 0); if (resource) sci_hexdump(resource->data, resource->size, 0); else @@ -942,7 +942,7 @@ static int c_dump(EngineState *s) { static int c_hexgrep(EngineState *s) { int i, seeklen, resnr, restype, resmax; unsigned char *seekstr = NULL; - resource_t *script = NULL; + Resource *script = NULL; char *dot = strchr(cmd_params[0].str, '.'); if (NULL == s) { diff --git a/engines/sci/engine/scriptdebug.cpp b/engines/sci/engine/scriptdebug.cpp index 190a054e43..0accce7e94 100644 --- a/engines/sci/engine/scriptdebug.cpp +++ b/engines/sci/engine/scriptdebug.cpp @@ -245,7 +245,7 @@ static void sci01_song_header_dump(byte *data, int size) { #undef SONGDATA int c_sfx_01_header(EngineState *s) { - resource_t *song = s->resmgr->findResource(sci_sound, cmd_params[0].val, 0); + Resource *song = s->resmgr->findResource(sci_sound, cmd_params[0].val, 0); if (!song) { sciprintf("Doesn't exist\n"); @@ -258,7 +258,7 @@ int c_sfx_01_header(EngineState *s) { } int c_sfx_01_track(EngineState *s) { - resource_t *song = s->resmgr->findResource(sci_sound, cmd_params[0].val, 0); + Resource *song = s->resmgr->findResource(sci_sound, cmd_params[0].val, 0); int offset = cmd_params[1].val; @@ -2406,7 +2406,7 @@ int c_simkey(EngineState *s) { } static int c_is_sample(EngineState *s) { - resource_t *song = s->resmgr->findResource(sci_sound, cmd_params[0].val, 0); + Resource *song = s->resmgr->findResource(sci_sound, cmd_params[0].val, 0); song_iterator_t *songit; sfx_pcm_feed_t *data; diff --git a/engines/sci/engine/seg_manager.cpp b/engines/sci/engine/seg_manager.cpp index 949b04928b..57ba65573c 100644 --- a/engines/sci/engine/seg_manager.cpp +++ b/engines/sci/engine/seg_manager.cpp @@ -152,8 +152,8 @@ MemObject *SegManager::allocateScript(EngineState *s, int script_nr, int* seg_id } void SegManager::setScriptSize(MemObject *mem, EngineState *s, int script_nr) { - resource_t *script = s->resmgr->findResource(sci_script, script_nr, 0); - resource_t *heap = s->resmgr->findResource(sci_heap, script_nr, 0); + Resource *script = s->resmgr->findResource(sci_script, script_nr, 0); + Resource *heap = s->resmgr->findResource(sci_heap, script_nr, 0); mem->data.script.script_size = script->size; mem->data.script.heap_size = 0; // Set later diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp index b35736cd4a..746df27b80 100644 --- a/engines/sci/engine/vm.cpp +++ b/engines/sci/engine/vm.cpp @@ -1593,7 +1593,7 @@ SelectorType lookup_selector(EngineState *s, reg_t obj_location, Selector select // Detects SCI versions by their different script header void script_detect_versions(EngineState *s) { int c; - resource_t *script = {0}; + Resource *script = {0}; if (s->resmgr->findResource(sci_heap, 0, 0)) { version_require_later_than(s, SCI_VERSION(1, 001, 000)); @@ -1670,7 +1670,7 @@ reg_t script_lookup_export(EngineState *s, int script_nr, int export_index) { #define INST_LOOKUP_CLASS(id) ((id == 0xffff)? NULL_REG : get_class_address(s, id, SCRIPT_GET_LOCK, reg)) -int script_instantiate_common(EngineState *s, int script_nr, resource_t **script, resource_t **heap, int *was_new) { +int script_instantiate_common(EngineState *s, int script_nr, Resource **script, Resource **heap, int *was_new) { int seg; int seg_id; int marked_for_deletion; @@ -1740,7 +1740,7 @@ int script_instantiate_sci0(EngineState *s, int script_nr) { int seg_id; int relocation = -1; int magic_pos_adder; // Usually 0; 2 for older SCI versions - resource_t *script; + Resource *script; int was_new; seg_id = script_instantiate_common(s, script_nr, &script, NULL, &was_new); @@ -1888,7 +1888,7 @@ int script_instantiate_sci0(EngineState *s, int script_nr) { } int script_instantiate_sci11(EngineState *s, int script_nr) { - resource_t *script, *heap; + Resource *script, *heap; int seg_id; int heap_start; reg_t reg; -- cgit v1.2.3