diff options
author | Max Horn | 2009-05-18 12:36:04 +0000 |
---|---|---|
committer | Max Horn | 2009-05-18 12:36:04 +0000 |
commit | 99713ca7fa078adf7c2e2b29f210bf8aa85d89ac (patch) | |
tree | 7d47449c901da9b9949596bbb06177c3b6493551 /engines | |
parent | a0b6f21a1a6d9e102bc30df963d011b988e1aae6 (diff) | |
download | scummvm-rg350-99713ca7fa078adf7c2e2b29f210bf8aa85d89ac.tar.gz scummvm-rg350-99713ca7fa078adf7c2e2b29f210bf8aa85d89ac.tar.bz2 scummvm-rg350-99713ca7fa078adf7c2e2b29f210bf8aa85d89ac.zip |
SCI: Tweaks, cleanup
svn-id: r40688
Diffstat (limited to 'engines')
-rw-r--r-- | engines/sci/engine/savegame.cpp | 1 | ||||
-rw-r--r-- | engines/sci/engine/seg_manager.cpp | 53 |
2 files changed, 11 insertions, 43 deletions
diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp index ef1738b06d..1339b0368a 100644 --- a/engines/sci/engine/savegame.cpp +++ b/engines/sci/engine/savegame.cpp @@ -313,7 +313,6 @@ void syncWithSerializer(Common::Serializer &s, Table<Node>::Entry &obj) { template <typename T> void sync_Table(Common::Serializer &s, T &obj) { - // TODO: Change this to use syncArray. This involves breaking the savegame format compatibility. s.syncAsSint32LE(obj.first_free); s.syncAsSint32LE(obj.entries_used); diff --git a/engines/sci/engine/seg_manager.cpp b/engines/sci/engine/seg_manager.cpp index d56f51ce8e..610cd86d31 100644 --- a/engines/sci/engine/seg_manager.cpp +++ b/engines/sci/engine/seg_manager.cpp @@ -136,8 +136,7 @@ void SegManager::setScriptSize(Script &scr, EngineState *s, int script_nr) { scr.heap_size = 0; // Set later if (!script || (s->version >= SCI_VERSION_1_1 && !heap)) { - sciprintf("%s: failed to load %s\n", __FUNCTION__, !script ? "script" : "heap"); - return; + error("SegManager::setScriptSize: failed to load %s", !script ? "script" : "heap"); } if (s->flags & GF_SCI0_OLD) { scr.buf_size = script->size + READ_LE_UINT16(script->data) * 2; @@ -205,36 +204,10 @@ int SegManager::deallocate(SegmentId seg, bool recursive) { mobj = _heap[seg]; id_seg_map->removeKey(mobj->getSegMgrId()); - switch (mobj->getType()) { - case MEM_OBJ_SCRIPT: - // FIXME: Get rid of the recursive flag, so that we can move the - // following into the destructor. The only time it is set to false - // is in the SegManager destructor. - if (recursive && (*(Script *)mobj).locals_segment) - deallocate((*(Script *)mobj).locals_segment, recursive); - break; - - case MEM_OBJ_LOCALS: - break; - - case MEM_OBJ_DYNMEM: - break; - case MEM_OBJ_SYS_STRINGS: - break; - case MEM_OBJ_STACK: - break; - case MEM_OBJ_LISTS: - break; - case MEM_OBJ_NODES: - break; - case MEM_OBJ_CLONES: - break; - case MEM_OBJ_HUNK: - break; - case MEM_OBJ_STRING_FRAG: - break; - default: - error("Deallocating segment type %d not supported", mobj->getType()); + if (mobj->getType() == MEM_OBJ_SCRIPT) { + Script *scr = (Script *)mobj; + if (recursive && scr->locals_segment) + deallocate(scr->locals_segment, recursive); } delete mobj; @@ -244,16 +217,9 @@ int SegManager::deallocate(SegmentId seg, bool recursive) { } bool SegManager::scriptIsMarkedAsDeleted(SegmentId seg) { - Script *scr; - - if (!check(seg)) + Script *scr = getScriptIfLoaded(seg); + if (!scr) return false; - - if (_heap[seg]->getType() != MEM_OBJ_SCRIPT) - return false; - - scr = (Script *)_heap[seg]; - return scr->_markedAsDeleted; } @@ -361,6 +327,7 @@ SegmentId SegManager::segGet(int script_id) const { } Script *SegManager::getScript(const SegmentId seg) { + // FIXME: We accept segment 0, but that is actually an invalid segment... if (seg < 0 || (uint)seg >= _heap.size()) { error("SegManager::getScript(): seg id %x out of bounds", seg); } @@ -374,6 +341,7 @@ Script *SegManager::getScript(const SegmentId seg) { } Script *SegManager::getScriptIfLoaded(const SegmentId seg) { + // FIXME: We accept segment 0, but that is actually an invalid segment... if (seg < 0 || (uint)seg >= _heap.size() || !_heap[seg] || _heap[seg]->getType() != MEM_OBJ_SCRIPT) return 0; return (Script *)_heap[seg]; @@ -384,11 +352,12 @@ Script *SegManager::getScriptIfLoaded(const SegmentId seg) { // false - invalid seg // true - valid seg bool SegManager::check(SegmentId seg) { + // FIXME: We accept segment 0, but that is actually an invalid segment... if (seg < 0 || (uint)seg >= _heap.size()) { return false; } if (!_heap[seg]) { - sciprintf("SegManager: seg %x is removed from memory, but not removed from hash_map\n", seg); + warning("SegManager: seg %x is removed from memory, but not removed from hash_map", seg); return false; } return true; |