[Scummvm-cvs-logs] SF.net SVN: scummvm:[40688] scummvm/trunk/engines/sci/engine
fingolfin at users.sourceforge.net
fingolfin at users.sourceforge.net
Mon May 18 14:36:04 CEST 2009
Revision: 40688
http://scummvm.svn.sourceforge.net/scummvm/?rev=40688&view=rev
Author: fingolfin
Date: 2009-05-18 12:36:04 +0000 (Mon, 18 May 2009)
Log Message:
-----------
SCI: Tweaks, cleanup
Modified Paths:
--------------
scummvm/trunk/engines/sci/engine/savegame.cpp
scummvm/trunk/engines/sci/engine/seg_manager.cpp
Modified: scummvm/trunk/engines/sci/engine/savegame.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/savegame.cpp 2009-05-18 12:35:42 UTC (rev 40687)
+++ scummvm/trunk/engines/sci/engine/savegame.cpp 2009-05-18 12:36:04 UTC (rev 40688)
@@ -313,7 +313,6 @@
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);
Modified: scummvm/trunk/engines/sci/engine/seg_manager.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/seg_manager.cpp 2009-05-18 12:35:42 UTC (rev 40687)
+++ scummvm/trunk/engines/sci/engine/seg_manager.cpp 2009-05-18 12:36:04 UTC (rev 40688)
@@ -136,8 +136,7 @@
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 @@
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 @@
}
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 @@
}
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::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 @@
// 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;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list