diff options
author | Max Horn | 2009-09-21 21:35:43 +0000 |
---|---|---|
committer | Max Horn | 2009-09-21 21:35:43 +0000 |
commit | 57dfb9bafd9eda6776ebfa1e2a5453f6fcfaf3ab (patch) | |
tree | 4e8865ee59dd9ec328e987b23af1b8bd6c15e5e9 /engines/sci | |
parent | 47e677ffccd422f63a414a9e5dc8c00b05547a2e (diff) | |
download | scummvm-rg350-57dfb9bafd9eda6776ebfa1e2a5453f6fcfaf3ab.tar.gz scummvm-rg350-57dfb9bafd9eda6776ebfa1e2a5453f6fcfaf3ab.tar.bz2 scummvm-rg350-57dfb9bafd9eda6776ebfa1e2a5453f6fcfaf3ab.zip |
SCI: Rename Object::flags and pos to _flags and _pos; tweak scriptObjInit0 and scriptObjInit11 to be more similar
svn-id: r44234
Diffstat (limited to 'engines/sci')
-rw-r--r-- | engines/sci/console.cpp | 26 | ||||
-rw-r--r-- | engines/sci/engine/gc.cpp | 2 | ||||
-rw-r--r-- | engines/sci/engine/kscripts.cpp | 12 | ||||
-rw-r--r-- | engines/sci/engine/savegame.cpp | 8 | ||||
-rw-r--r-- | engines/sci/engine/seg_manager.cpp | 60 | ||||
-rw-r--r-- | engines/sci/engine/segment.cpp | 4 | ||||
-rw-r--r-- | engines/sci/engine/segment.h | 6 |
7 files changed, 58 insertions, 60 deletions
diff --git a/engines/sci/console.cpp b/engines/sci/console.cpp index a7dd995ff9..0cee137482 100644 --- a/engines/sci/console.cpp +++ b/engines/sci/console.cpp @@ -563,8 +563,8 @@ bool Console::cmdRegisters(int argc, const char **argv) { if (!_vm->_gamestate->_executionStack.empty()) { EngineState *s = _vm->_gamestate; // for PRINT_STK - DebugPrintf("pc=%04x:%04x obj=%04x:%04x fp=ST:%04x sp=ST:%04x\n", - PRINT_REG(scriptState.xs->addr.pc), PRINT_REG(scriptState.xs->objp), + DebugPrintf("pc=%04x:%04x obj=%04x:%04x fp=ST:%04x sp=ST:%04x\n", + PRINT_REG(scriptState.xs->addr.pc), PRINT_REG(scriptState.xs->objp), PRINT_STK(scriptState.xs->fp), PRINT_STK(scriptState.xs->sp)); } else DebugPrintf("<no execution stack: pc,obj,fp omitted>\n"); @@ -897,8 +897,8 @@ bool Console::cmdClassTable(int argc, const char **argv) { DebugPrintf("Available classes:\n"); for (uint i = 0; i < _vm->_gamestate->segMan->_classtable.size(); i++) { if (_vm->_gamestate->segMan->_classtable[i].reg.segment) { - DebugPrintf(" Class 0x%x at %04x:%04x (script 0x%x)\n", i, - PRINT_REG(_vm->_gamestate->segMan->_classtable[i].reg), + DebugPrintf(" Class 0x%x at %04x:%04x (script 0x%x)\n", i, + PRINT_REG(_vm->_gamestate->segMan->_classtable[i].reg), _vm->_gamestate->segMan->_classtable[i].script); } } @@ -1053,7 +1053,7 @@ bool Console::cmdDrawRect(int argc, const char **argv) { int col = CLIP<int>(atoi(argv[5]), 0, 15); gfxop_set_clip_zone(_vm->_gamestate->gfx_state, gfx_rect_fullscreen); - gfxop_fill_box(_vm->_gamestate->gfx_state, gfx_rect(atoi(argv[1]), atoi(argv[2]), + gfxop_fill_box(_vm->_gamestate->gfx_state, gfx_rect(atoi(argv[1]), atoi(argv[2]), atoi(argv[3]), atoi(argv[4])), _vm->_gamestate->ega_colors[col]); gfxop_update(_vm->_gamestate->gfx_state); @@ -1303,7 +1303,7 @@ bool Console::cmdStatusBarColors(int argc, const char **argv) { _vm->_gamestate->status_bar_foreground = atoi(argv[1]); _vm->_gamestate->status_bar_background = atoi(argv[2]); - sciw_set_status_bar(_vm->_gamestate, _vm->_gamestate->titlebar_port, _vm->_gamestate->_statusBarText, + sciw_set_status_bar(_vm->_gamestate, _vm->_gamestate->titlebar_port, _vm->_gamestate->_statusBarText, _vm->_gamestate->status_bar_foreground, _vm->_gamestate->status_bar_background); gfxop_update(_vm->_gamestate->gfx_state); @@ -1401,10 +1401,10 @@ bool Console::segmentInfo(int nr) { for (uint i = 0; i < scr->_objects.size(); i++) { DebugPrintf(" "); // Object header - Object *obj = _vm->_gamestate->segMan->getObject(scr->_objects[i].pos); + Object *obj = _vm->_gamestate->segMan->getObject(scr->_objects[i]._pos); if (obj) - DebugPrintf("[%04x:%04x] %s : %3d vars, %3d methods\n", PRINT_REG(scr->_objects[i].pos), - _vm->_gamestate->segMan->getObjectName(scr->_objects[i].pos), + DebugPrintf("[%04x:%04x] %s : %3d vars, %3d methods\n", PRINT_REG(scr->_objects[i]._pos), + _vm->_gamestate->segMan->getObjectName(scr->_objects[i]._pos), obj->_variables.size(), obj->methods_nr); } } @@ -1448,10 +1448,10 @@ bool Console::segmentInfo(int nr) { objpos.segment = nr; DebugPrintf(" [%04x] %s; copy of ", i, _vm->_gamestate->segMan->getObjectName(objpos)); // Object header - Object *obj = _vm->_gamestate->segMan->getObject(ct->_table[i].pos); + Object *obj = _vm->_gamestate->segMan->getObject(ct->_table[i]._pos); if (obj) - DebugPrintf("[%04x:%04x] %s : %3d vars, %3d methods\n", PRINT_REG(ct->_table[i].pos), - _vm->_gamestate->segMan->getObjectName(ct->_table[i].pos), + DebugPrintf("[%04x:%04x] %s : %3d vars, %3d methods\n", PRINT_REG(ct->_table[i]._pos), + _vm->_gamestate->segMan->getObjectName(ct->_table[i]._pos), obj->_variables.size(), obj->methods_nr); } } @@ -2901,7 +2901,7 @@ int parse_reg_t(EngineState *s, const char *str, reg_t *dest) { // Returns 0 on if (mobj->getType() == SEG_TYPE_SCRIPT) { obj = &(*(Script *)mobj)._objects[idx]; - objpos.offset = obj->pos.offset; + objpos.offset = obj->_pos.offset; } else if (mobj->getType() == SEG_TYPE_CLONES) { obj = &((*(CloneTable *)mobj)._table[idx]); objpos.offset = idx; diff --git a/engines/sci/engine/gc.cpp b/engines/sci/engine/gc.cpp index d9635bff73..0f5f4a5e57 100644 --- a/engines/sci/engine/gc.cpp +++ b/engines/sci/engine/gc.cpp @@ -120,7 +120,7 @@ reg_t_hash_map *find_all_used_references(EngineState *s) { // All objects (may be classes, may be indirectly reachable) for (uint obj_nr = 0; obj_nr < script->_objects.size(); obj_nr++) { - wm.push(script->_objects[obj_nr].pos); + wm.push(script->_objects[obj_nr]._pos); } } } diff --git a/engines/sci/engine/kscripts.cpp b/engines/sci/engine/kscripts.cpp index 2978a2a2e2..f9ec052d0f 100644 --- a/engines/sci/engine/kscripts.cpp +++ b/engines/sci/engine/kscripts.cpp @@ -123,15 +123,15 @@ reg_t kClone(EngineState *s, int, int argc, reg_t *argv) { } *clone_obj = *parent_obj; - clone_obj->flags = 0; + clone_obj->_flags = 0; // Mark as clone clone_obj->setInfoSelector(make_reg(0, SCRIPT_INFO_CLONE)); - clone_obj->setSpeciesSelector(clone_obj->pos); + clone_obj->setSpeciesSelector(clone_obj->_pos); if (parent_obj->isClass()) - clone_obj->setSuperClassSelector(parent_obj->pos); - s->segMan->getScript(parent_obj->pos.segment)->incrementLockers(); - s->segMan->getScript(clone_obj->pos.segment)->incrementLockers(); + clone_obj->setSuperClassSelector(parent_obj->_pos); + s->segMan->getScript(parent_obj->_pos.segment)->incrementLockers(); + s->segMan->getScript(clone_obj->_pos.segment)->incrementLockers(); return clone_addr; } @@ -169,7 +169,7 @@ reg_t kDisposeClone(EngineState *s, int, int argc, reg_t *argv) { } #endif - victim_obj->flags |= OBJECT_FLAG_FREED; + victim_obj->_flags |= OBJECT_FLAG_FREED; _k_view_list_mark_free(s, victim_addr); // Free on view list, if neccessary diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp index 7ca50b25ca..3fc11be7fa 100644 --- a/engines/sci/engine/savegame.cpp +++ b/engines/sci/engine/savegame.cpp @@ -319,8 +319,8 @@ void LocalVariables::saveLoadWithSerializer(Common::Serializer &s) { template <> void syncWithSerializer(Common::Serializer &s, Object &obj) { - s.syncAsSint32LE(obj.flags); - sync_reg_t(s, obj.pos); + s.syncAsSint32LE(obj._flags); + sync_reg_t(s, obj._pos); s.syncAsSint32LE(obj.variable_names_nr); s.syncAsSint32LE(obj.methods_nr); @@ -580,7 +580,7 @@ static void reconstruct_scripts(EngineState *s, SegManager *self) { scr->_codeBlocks.clear(); for (j = 0; j < scr->_objects.size(); j++) { - byte *data = scr->_buf + scr->_objects[j].pos.offset; + byte *data = scr->_buf + scr->_objects[j]._pos.offset; scr->_objects[j].base = scr->_buf; scr->_objects[j].base_obj = data; } @@ -600,7 +600,7 @@ static void reconstruct_scripts(EngineState *s, SegManager *self) { Script *scr = (Script *)mobj; for (j = 0; j < scr->_objects.size(); j++) { - byte *data = scr->_buf + scr->_objects[j].pos.offset; + byte *data = scr->_buf + scr->_objects[j]._pos.offset; if (s->resMan->sciVersion() >= SCI_VERSION_1_1) { uint16 *funct_area = (uint16 *) (scr->_buf + READ_LE_UINT16( data + 6 )); diff --git a/engines/sci/engine/seg_manager.cpp b/engines/sci/engine/seg_manager.cpp index 76f85f42fe..f488f38d67 100644 --- a/engines/sci/engine/seg_manager.cpp +++ b/engines/sci/engine/seg_manager.cpp @@ -189,7 +189,7 @@ bool SegManager::isHeapObject(reg_t pos) { Object *obj = getObject(pos); if (obj == NULL) return false; - if (obj->flags & OBJECT_FLAG_FREED) + if (obj->_flags & OBJECT_FLAG_FREED) return false; Script *scr = getScriptIfLoaded(pos.segment); return !(scr && scr->_markedAsDeleted); @@ -324,7 +324,7 @@ int Script::relocateLocal(SegmentId segment, int location) { } int Script::relocateObject(Object *obj, SegmentId segment, int location) { - return relocateBlock(obj->_variables, obj->pos.offset, segment, location); + return relocateBlock(obj->_variables, obj->_pos.offset, segment, location); } void Script::scriptAddCodeBlock(reg_t location) { @@ -368,7 +368,7 @@ void Script::scriptRelocate(reg_t block) { else printf("- No locals\n"); for (k = 0; k < _objects.size(); k++) - printf("- obj#%d at %04x w/ %d vars\n", k, _objects[k].pos.offset, _objects[k]._variables.size()); + printf("- obj#%d at %04x w/ %d vars\n", k, _objects[k]._pos.offset, _objects[k]._variables.size()); // SQ3 script 71 has broken relocation entries. printf("Trying to continue anyway...\n"); } @@ -405,7 +405,7 @@ void Script::heapRelocate(reg_t block) { else printf("- No locals\n"); for (k = 0; k < _objects.size(); k++) - printf("- obj#%d at %04x w/ %d vars\n", k, _objects[k].pos.offset, _objects[k]._variables.size()); + printf("- obj#%d at %04x w/ %d vars\n", k, _objects[k]._pos.offset, _objects[k]._variables.size()); error("Breakpoint in %s, line %d", __FILE__, __LINE__); } } @@ -459,44 +459,44 @@ reg_t SegManager::getClassAddress(int classnr, ScriptLoadType lock, reg_t caller Object *Script::scriptObjInit0(reg_t obj_pos) { Object *obj; - uint base = obj_pos.offset - SCRIPT_OBJECT_MAGIC_OFFSET; - VERIFY(base < _bufSize, "Attempt to initialize object beyond end of script\n"); + obj_pos.offset -= SCRIPT_OBJECT_MAGIC_OFFSET; + VERIFY(obj_pos.offset < _bufSize, "Attempt to initialize object beyond end of script\n"); - obj = allocateObject(base); + obj = allocateObject(obj_pos.offset); - VERIFY(base + SCRIPT_FUNCTAREAPTR_OFFSET < _bufSize, "Function area pointer stored beyond end of script\n"); + VERIFY(obj_pos.offset + SCRIPT_FUNCTAREAPTR_OFFSET < (int)_bufSize, "Function area pointer stored beyond end of script\n"); { - byte *data = (byte *)(_buf + base); - int funct_area = READ_LE_UINT16(data + SCRIPT_FUNCTAREAPTR_OFFSET); + byte *data = (byte *)(_buf + obj_pos.offset); + uint16 *funct_area = (uint16 *)(data + READ_LE_UINT16(data + SCRIPT_FUNCTAREAPTR_OFFSET)); int variables_nr; int functions_nr; int is_class; - int i; - obj->flags = 0; - obj->pos = make_reg(obj_pos.segment, base); + obj->_flags = 0; + obj->_pos = obj_pos; - VERIFY(base + funct_area < _bufSize, "Function area pointer references beyond end of script"); + VERIFY((byte *)funct_area < _buf + _bufSize, "Function area pointer references beyond end of script"); variables_nr = READ_LE_UINT16(data + SCRIPT_SELECTORCTR_OFFSET); - functions_nr = READ_LE_UINT16(data + funct_area - 2); + functions_nr = READ_LE_UINT16(funct_area - 1); is_class = READ_LE_UINT16(data + SCRIPT_INFO_OFFSET) & SCRIPT_INFO_CLASS; - VERIFY(base + funct_area + functions_nr * 2 + obj->base_method = funct_area; + obj->base_vars = NULL; + + VERIFY((byte *)funct_area + functions_nr * 2 // add again for classes, since those also store selectors - + (is_class ? functions_nr * 2 : 0) < _bufSize, "Function area extends beyond end of script"); + + (is_class ? functions_nr * 2 : 0) < _buf + _bufSize, "Function area extends beyond end of script"); obj->_variables.resize(variables_nr); obj->methods_nr = functions_nr; obj->base = _buf; obj->base_obj = data; - obj->base_method = (uint16 *)(data + funct_area); - obj->base_vars = NULL; - for (i = 0; i < variables_nr; i++) + for (int i = 0; i < variables_nr; i++) obj->_variables[i] = make_reg(0, READ_LE_UINT16(data + (i * 2))); } @@ -505,27 +505,25 @@ Object *Script::scriptObjInit0(reg_t obj_pos) { Object *Script::scriptObjInit11(reg_t obj_pos) { Object *obj; - uint base = obj_pos.offset; - VERIFY(base < _bufSize, "Attempt to initialize object beyond end of script\n"); + VERIFY(obj_pos.offset < _bufSize, "Attempt to initialize object beyond end of script\n"); - obj = allocateObject(base); + obj = allocateObject(obj_pos.offset); - VERIFY(base + SCRIPT_FUNCTAREAPTR_OFFSET < _bufSize, "Function area pointer stored beyond end of script\n"); + VERIFY(obj_pos.offset + SCRIPT_FUNCTAREAPTR_OFFSET < (int)_bufSize, "Function area pointer stored beyond end of script\n"); { - byte *data = (byte *)(_buf + base); + byte *data = (byte *)(_buf + obj_pos.offset); uint16 *funct_area = (uint16 *)(_buf + READ_LE_UINT16(data + 6)); uint16 *prop_area = (uint16 *)(_buf + READ_LE_UINT16(data + 4)); int variables_nr; int functions_nr; int is_class; - int i; - obj->flags = 0; - obj->pos = obj_pos; + obj->_flags = 0; + obj->_pos = obj_pos; - VERIFY((byte *) funct_area < _buf + _bufSize, "Function area pointer references beyond end of script"); + VERIFY((byte *)funct_area < _buf + _bufSize, "Function area pointer references beyond end of script"); variables_nr = READ_LE_UINT16(data + 2); functions_nr = READ_LE_UINT16(funct_area); @@ -534,7 +532,7 @@ Object *Script::scriptObjInit11(reg_t obj_pos) { obj->base_method = funct_area; obj->base_vars = prop_area; - VERIFY(((byte *) funct_area + functions_nr) < _buf + _bufSize, "Function area extends beyond end of script"); + VERIFY(((byte *)funct_area + functions_nr) < _buf + _bufSize, "Function area extends beyond end of script"); obj->variable_names_nr = variables_nr; obj->_variables.resize(variables_nr); @@ -543,7 +541,7 @@ Object *Script::scriptObjInit11(reg_t obj_pos) { obj->base = _buf; obj->base_obj = data; - for (i = 0; i < variables_nr; i++) + for (int i = 0; i < variables_nr; i++) obj->_variables[i] = make_reg(0, READ_LE_UINT16(data + (i * 2))); } diff --git a/engines/sci/engine/segment.cpp b/engines/sci/engine/segment.cpp index 7969969ec3..087505b9df 100644 --- a/engines/sci/engine/segment.cpp +++ b/engines/sci/engine/segment.cpp @@ -362,7 +362,7 @@ void CloneTable::listAllOutgoingReferences(reg_t addr, void *param, NoteCallback (*note)(param, clone->_variables[i]); // Note that this also includes the 'base' object, which is part of the script and therefore also emits the locals. - (*note)(param, clone->pos); + (*note)(param, clone->_pos); //debugC(2, kDebugLevelGC, "[GC] Reporting clone-pos %04x:%04x\n", PRINT_REG(clone->pos)); } @@ -374,7 +374,7 @@ void CloneTable::freeAtAddress(SegManager *segMan, reg_t addr) { victim_obj = &(_table[addr.offset]); - if (!(victim_obj->flags & OBJECT_FLAG_FREED)) + if (!(victim_obj->_flags & OBJECT_FLAG_FREED)) warning("[GC] Clone %04x:%04x not reachable and not freed (freeing now)", PRINT_REG(addr)); #ifdef GC_DEBUG_VERBOSE else diff --git a/engines/sci/engine/segment.h b/engines/sci/engine/segment.h index c98c112bbc..6f051da7d9 100644 --- a/engines/sci/engine/segment.h +++ b/engines/sci/engine/segment.h @@ -185,8 +185,8 @@ public: // TODO: convert to class, perhaps? struct Object { - int flags; - reg_t pos; /**< Object offset within its script; for clones, this is their base */ + int _flags; + reg_t _pos; /**< Object offset within its script; for clones, this is their base */ int variable_names_nr; /**< Number of variable names, may be less than variables_nr */ int methods_nr; byte *base; /**< Points to a buffer all relative references (code, strings) point to */ @@ -249,7 +249,7 @@ struct Object { reg_t getFunction(uint16 i) { uint16 offset = (getSciVersion() < SCI_VERSION_1_1) ? methods_nr + 1 + i : i * 2 + 2; - return make_reg(pos.segment, READ_LE_UINT16((byte *) (base_method + offset))); + return make_reg(_pos.segment, READ_LE_UINT16((byte *) (base_method + offset))); } bool isClass() { |