diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/sci/engine/kernel.cpp | 11 | ||||
-rw-r--r-- | engines/sci/engine/klists.cpp | 4 | ||||
-rw-r--r-- | engines/sci/engine/kmovement.cpp | 2 | ||||
-rw-r--r-- | engines/sci/engine/kscripts.cpp | 2 | ||||
-rw-r--r-- | engines/sci/engine/scriptconsole.cpp | 10 | ||||
-rw-r--r-- | engines/sci/engine/seg_manager.cpp | 8 | ||||
-rw-r--r-- | engines/sci/engine/seg_manager.h | 12 | ||||
-rw-r--r-- | engines/sci/engine/vm.cpp | 22 |
8 files changed, 35 insertions, 36 deletions
diff --git a/engines/sci/engine/kernel.cpp b/engines/sci/engine/kernel.cpp index 39d6ee3c9a..8089fc2d6e 100644 --- a/engines/sci/engine/kernel.cpp +++ b/engines/sci/engine/kernel.cpp @@ -239,10 +239,9 @@ bool has_kernel_function(EngineState *s, const char *kname) { // Returns a pointer to the memory indicated by the specified handle byte *kmem(EngineState *s, reg_t handle) { - MemObject *mobj = GET_SEGMENT(*s->seg_manager, handle.segment, MEM_OBJ_HUNK); - HunkTable *ht = &(mobj->data.hunks); + HunkTable *ht = (HunkTable *)GET_SEGMENT(*s->seg_manager, handle.segment, MEM_OBJ_HUNK); - if (!mobj || !ENTRY_IS_VALID(ht, handle.offset)) { + if (!ht || !ENTRY_IS_VALID(ht, handle.offset)) { SCIkwarn(SCIkERROR, "Error: kmem() with invalid handle\n"); return NULL; } @@ -686,7 +685,7 @@ int determine_reg_type(EngineState *s, reg_t reg, int allow_invalid) { return KSIG_REF; case MEM_OBJ_CLONES: - if (allow_invalid || ENTRY_IS_VALID(&(mobj->data.clones), reg.offset)) + if (allow_invalid || ENTRY_IS_VALID((CloneTable *)mobj, reg.offset)) return KSIG_OBJECT; else return KSIG_OBJECT | KSIG_INVALID; @@ -711,13 +710,13 @@ int determine_reg_type(EngineState *s, reg_t reg, int allow_invalid) { return KSIG_REF | KSIG_INVALID; case MEM_OBJ_LISTS: - if (allow_invalid || ENTRY_IS_VALID(&(mobj->data.lists), reg.offset)) + if (allow_invalid || ENTRY_IS_VALID((ListTable *)mobj, reg.offset)) return KSIG_LIST; else return KSIG_LIST | KSIG_INVALID; case MEM_OBJ_NODES: - if (allow_invalid || ENTRY_IS_VALID(&(mobj->data.nodes), reg.offset)) + if (allow_invalid || ENTRY_IS_VALID((NodeTable *)mobj, reg.offset)) return KSIG_NODE; else return KSIG_NODE | KSIG_INVALID; diff --git a/engines/sci/engine/klists.cpp b/engines/sci/engine/klists.cpp index fc27067475..20d8b97c0c 100644 --- a/engines/sci/engine/klists.cpp +++ b/engines/sci/engine/klists.cpp @@ -42,7 +42,7 @@ Node *lookup_node(EngineState *s, reg_t addr, const char *file, int line) { return NULL; } - NodeTable *nt = &(mobj->data.nodes); + NodeTable *nt = (NodeTable *)mobj; if (!ENTRY_IS_VALID(nt, addr.offset)) { sciprintf("%s, L%d: Attempt to use non-node "PREG" as list node\n", __FILE__, __LINE__, PRINT_REG(addr)); @@ -62,7 +62,7 @@ List *lookup_list(EngineState *s, reg_t addr, const char *file, int line) { return NULL; } - ListTable *lt = &(mobj->data.lists); + ListTable *lt = (ListTable *)mobj; if (!ENTRY_IS_VALID(lt, addr.offset)) { sciprintf("%s, L%d: Attempt to use non-list "PREG" as list\n", __FILE__, __LINE__, PRINT_REG(addr)); diff --git a/engines/sci/engine/kmovement.cpp b/engines/sci/engine/kmovement.cpp index 8b0291cc51..48aebef000 100644 --- a/engines/sci/engine/kmovement.cpp +++ b/engines/sci/engine/kmovement.cpp @@ -270,7 +270,7 @@ static void bresenham_autodetect(EngineState *s) { return; } - buf = s->seg_manager->heap[fptr.segment]->data.script.buf + fptr.offset; + buf = s->seg_manager->getScript(fptr.segment, SEG_ID)->buf + fptr.offset; handle_movecnt = (SCI_VERSION_MAJOR(s->version) == 0 || checksum_bytes(buf, 8) == 0x216) ? INCREMENT_MOVECNT : IGNORE_MOVECNT; sciprintf("b-moveCnt action based on checksum: %s\n", handle_movecnt == IGNORE_MOVECNT ? "ignore" : "increment"); } else { diff --git a/engines/sci/engine/kscripts.cpp b/engines/sci/engine/kscripts.cpp index 9559c792c9..0477430dbb 100644 --- a/engines/sci/engine/kscripts.cpp +++ b/engines/sci/engine/kscripts.cpp @@ -246,7 +246,7 @@ reg_t kScriptID(EngineState *s, int funct_nr, int argc, reg_t *argv) { if (!scriptid) return NULL_REG; - scr = &(s->seg_manager->heap[scriptid]->data.script); + scr = s->seg_manager->getScript(scriptid, SEG_ID); if (!scr->exports_nr) { SCIkdebug(SCIkERROR, "Script 0x%x does not have a dispatch table\n", script); diff --git a/engines/sci/engine/scriptconsole.cpp b/engines/sci/engine/scriptconsole.cpp index bbe1b36cb0..b3e334cda9 100644 --- a/engines/sci/engine/scriptconsole.cpp +++ b/engines/sci/engine/scriptconsole.cpp @@ -312,9 +312,9 @@ int parse_reg_t(EngineState *s, const char *str, reg_t *dest) { // Returns 0 on if (mobj) { if (mobj->getType() == MEM_OBJ_SCRIPT) - max_index = mobj->data.script.objects_nr; + max_index = (*(Script *)mobj).objects_nr; else if (mobj->getType() == MEM_OBJ_CLONES) - max_index = mobj->data.clones.max_entry; + max_index = (*(CloneTable *)mobj).max_entry; } while (idx < max_index) { @@ -325,12 +325,12 @@ int parse_reg_t(EngineState *s, const char *str, reg_t *dest) { // Returns 0 on objpos.segment = i; if (mobj->getType() == MEM_OBJ_SCRIPT) { - obj = mobj->data.script.objects + idx; + obj = (*(Script *)mobj).objects + idx; objpos.offset = obj->pos.offset; } else if (mobj->getType() == MEM_OBJ_CLONES) { - obj = &(mobj->data.clones.table[idx]); + obj = &((*(CloneTable *)mobj).table[idx]); objpos.offset = idx; - valid = clone_is_used(&mobj->data.clones, idx); + valid = clone_is_used((CloneTable *)mobj, idx); } if (valid) { diff --git a/engines/sci/engine/seg_manager.cpp b/engines/sci/engine/seg_manager.cpp index be4a9d8693..e6899d6920 100644 --- a/engines/sci/engine/seg_manager.cpp +++ b/engines/sci/engine/seg_manager.cpp @@ -1084,7 +1084,7 @@ Clone *SegManager::alloc_Clone(reg_t *addr) { offset = table->allocEntry(); *addr = make_reg(Clones_seg_id, offset); - return &(mobj->data.clones.table[offset]); + return &(table->table[offset]); } List *SegManager::alloc_List(reg_t *addr) { @@ -1102,7 +1102,7 @@ List *SegManager::alloc_List(reg_t *addr) { offset = table->allocEntry(); *addr = make_reg(Lists_seg_id, offset); - return &(mobj->data.lists.table[offset]); + return &(table->table[offset]); } Node *SegManager::alloc_Node(reg_t *addr) { @@ -1120,7 +1120,7 @@ Node *SegManager::alloc_Node(reg_t *addr) { offset = table->allocEntry(); *addr = make_reg(Nodes_seg_id, offset); - return &(mobj->data.nodes.table[offset]); + return &(table->table[offset]); } Hunk *SegManager::alloc_Hunk(reg_t *addr) { @@ -1138,7 +1138,7 @@ Hunk *SegManager::alloc_Hunk(reg_t *addr) { offset = table->allocEntry(); *addr = make_reg(Hunks_seg_id, offset); - return &(mobj->data.hunks.table[offset]); + return &(table->table[offset]); } diff --git a/engines/sci/engine/seg_manager.h b/engines/sci/engine/seg_manager.h index 679bb947e8..5477c0b2a4 100644 --- a/engines/sci/engine/seg_manager.h +++ b/engines/sci/engine/seg_manager.h @@ -38,15 +38,15 @@ enum idFlag { SEG_ID }; -#define GET_SEGMENT(mgr, index, rtype) ((index) > 0 && (mgr).heap_size > index) ? \ - (((mgr).heap[index] && (mgr).heap[index]->getType() == rtype)? (mgr).heap[index] : NULL) : NULL +#define GET_SEGMENT(mgr, index, rtype) (((index) > 0 && (mgr).heap_size > index) ? \ + (((mgr).heap[index] && (mgr).heap[index]->getType() == rtype)? (mgr).heap[index] : NULL) : NULL) -#define GET_SEGMENT_ANY(mgr, index) ((index) > 0 && (mgr).heap_size > index) ? \ - (((mgr).heap[index])? (mgr).heap[index] : NULL) : NULL +#define GET_SEGMENT_ANY(mgr, index) (((index) > 0 && (mgr).heap_size > index) ? \ + (((mgr).heap[index])? (mgr).heap[index] : NULL) : NULL) -#define GET_OBJECT_SEGMENT(mgr, index) ((index) > 0 && (mgr).heap_size > index) ? \ +#define GET_OBJECT_SEGMENT(mgr, index) (((index) > 0 && (mgr).heap_size > index) ? \ (((mgr).heap[index] && ((mgr).heap[index]->getType() == MEM_OBJ_SCRIPT || (mgr).heap[index]->getType() == MEM_OBJ_CLONES))? (mgr).heap[index] \ - : NULL): NULL + : NULL): NULL) class SegInterface; diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp index 80be41215c..a3411e7776 100644 --- a/engines/sci/engine/vm.cpp +++ b/engines/sci/engine/vm.cpp @@ -530,7 +530,7 @@ void vm_handle_fatal_error(EngineState *s, int line, const char *file) { static Script *script_locate_by_segment(EngineState *s, SegmentId seg) { MemObject *memobj = GET_SEGMENT(*s->seg_manager, seg, MEM_OBJ_SCRIPT); if (memobj) - return &(memobj->data.script); + return (Script *)memobj; return NULL; } @@ -1640,7 +1640,7 @@ reg_t script_lookup_export(EngineState *s, int script_nr, int export_index) { memobj = GET_SEGMENT(*s->seg_manager, seg, MEM_OBJ_SCRIPT); if (memobj) - script = &(memobj->data.script); + script = (Script *)memobj; #ifndef DISABLE_VALIDATIONS if (script @@ -1703,7 +1703,7 @@ int script_instantiate_common(EngineState *s, int script_nr, Resource **script, seg_id = seg; mem = s->seg_manager->heap[seg]; assert(mem); - s->seg_manager->freeScript(mem->data.script); + s->seg_manager->freeScript(*(Script *)mem); } } else if (!(mem = s->seg_manager->allocateScript(s, script_nr, &seg_id))) { // ALL YOUR SCRIPT BASE ARE BELONG TO US sciprintf("Not enough heap space for script size 0x%x of script 0x%x, should this happen?`\n", (*script)->size, script_nr); @@ -1711,7 +1711,7 @@ int script_instantiate_common(EngineState *s, int script_nr, Resource **script, return 0; } - s->seg_manager->initialiseScript(mem->data.script, s, script_nr); + s->seg_manager->initialiseScript(*(Script *)mem, s, script_nr); reg.segment = seg_id; reg.offset = 0; @@ -2088,14 +2088,14 @@ Object *obj_get(EngineState *s, reg_t offset) { int idx; if (memobj != NULL) { - if (memobj->getType() == MEM_OBJ_CLONES && ENTRY_IS_VALID(&memobj->data.clones, offset.offset)) - obj = &(memobj->data.clones.table[offset.offset]); + if (memobj->getType() == MEM_OBJ_CLONES && ENTRY_IS_VALID((CloneTable *)memobj, offset.offset)) + obj = &((*(CloneTable *)memobj).table[offset.offset]); else if (memobj->getType() == MEM_OBJ_SCRIPT) { - if (offset.offset <= memobj->data.script.buf_size && offset.offset >= -SCRIPT_OBJECT_MAGIC_OFFSET - && RAW_IS_OBJECT(memobj->data.script.buf + offset.offset)) { - idx = RAW_GET_CLASS_INDEX(&(memobj->data.script), offset); - if (idx >= 0 && idx < memobj->data.script.objects_nr) - obj = memobj->data.script.objects + idx; + if (offset.offset <= (*(Script *)memobj).buf_size && offset.offset >= -SCRIPT_OBJECT_MAGIC_OFFSET + && RAW_IS_OBJECT((*(Script *)memobj).buf + offset.offset)) { + idx = RAW_GET_CLASS_INDEX((Script *)memobj, offset); + if (idx >= 0 && idx < (*(Script *)memobj).objects_nr) + obj = (*(Script *)memobj).objects + idx; } } } |