[Scummvm-cvs-logs] SF.net SVN: scummvm:[39485] scummvm/trunk/engines/sci/engine
fingolfin at users.sourceforge.net
fingolfin at users.sourceforge.net
Tue Mar 17 17:08:25 CET 2009
Revision: 39485
http://scummvm.svn.sourceforge.net/scummvm/?rev=39485&view=rev
Author: fingolfin
Date: 2009-03-17 16:08:25 +0000 (Tue, 17 Mar 2009)
Log Message:
-----------
SCI: Added TODO: Merge SegInterface and MemObject? And some cleanup
Modified Paths:
--------------
scummvm/trunk/engines/sci/engine/intmap.cpp
scummvm/trunk/engines/sci/engine/intmap.h
scummvm/trunk/engines/sci/engine/seg_manager.cpp
scummvm/trunk/engines/sci/engine/seg_manager.h
Modified: scummvm/trunk/engines/sci/engine/intmap.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/intmap.cpp 2009-03-17 16:07:58 UTC (rev 39484)
+++ scummvm/trunk/engines/sci/engine/intmap.cpp 2009-03-17 16:08:25 UTC (rev 39485)
@@ -70,9 +70,9 @@
if (was_added)
*was_added = false;
- if (*node) {
+ if (*node)
return (*node)->idx;
- }
+
// Not found
if (!add)
@@ -96,6 +96,18 @@
return (*node)->idx;
}
+int IntMapper::lookupKey(int key) const {
+ Node *const *node = &(nodes[HASH(key)]);
+
+ while (*node && (key != (*node)->key))
+ node = &((*node)->next);
+
+ if (*node)
+ return (*node)->idx;
+
+ return -1;
+}
+
void IntMapper::saveLoadWithSerializer(Common::Serializer &s) {
s.syncAsSint32LE(base_value);
if (s.isLoading()) {
Modified: scummvm/trunk/engines/sci/engine/intmap.h
===================================================================
--- scummvm/trunk/engines/sci/engine/intmap.h 2009-03-17 16:07:58 UTC (rev 39484)
+++ scummvm/trunk/engines/sci/engine/intmap.h 2009-03-17 16:08:25 UTC (rev 39485)
@@ -93,6 +93,9 @@
*/
int checkKey(int key, bool add, bool *wasAdded = 0);
+ int lookupKey(int key) const;
+
+
/**
* Removes a key from the map.
* @param key The key to remove
Modified: scummvm/trunk/engines/sci/engine/seg_manager.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/seg_manager.cpp 2009-03-17 16:07:58 UTC (rev 39484)
+++ scummvm/trunk/engines/sci/engine/seg_manager.cpp 2009-03-17 16:08:25 UTC (rev 39485)
@@ -568,8 +568,8 @@
#endif
// return the seg if script_id is valid and in the map, else -1
-int SegManager::segGet(int script_id) {
- return id_seg_map->checkKey(script_id, false);
+int SegManager::segGet(int script_id) const {
+ return id_seg_map->lookupKey(script_id);
}
// validate the seg
Modified: scummvm/trunk/engines/sci/engine/seg_manager.h
===================================================================
--- scummvm/trunk/engines/sci/engine/seg_manager.h 2009-03-17 16:07:58 UTC (rev 39484)
+++ scummvm/trunk/engines/sci/engine/seg_manager.h 2009-03-17 16:08:25 UTC (rev 39485)
@@ -103,8 +103,7 @@
// Get the segment ID associated with a script number
// Parameters: (int) script_nr: Number of the script to look up
// Returns : (int) The associated segment ID, or -1 if no matching segment exists
- // This function is "pure" (i.e, it doesn't modify anything).
- int segGet(int script_nr);
+ int segGet(int script_nr) const;
// script lock operations
@@ -445,6 +444,11 @@
// 11. Segment interface, primarily for GC
+// TODO: Merge SegInterface and MemObject?
+// After all, _mobj->type == _typeId
+// and we make very little use of _segmgr (-> could get rid of that).
+// Other code would benefit, e.g. the saveload code.
+// But note that _mobj->segmgr_id != _segId !
class SegInterface {
protected:
SegInterface(SegManager *segmgr, MemObject *mobj, SegmentId segId, memObjType typeId);
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