[Scummvm-cvs-logs] SF.net SVN: scummvm:[40685] scummvm/trunk/engines/sci/engine

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Mon May 18 14:34:56 CEST 2009


Revision: 40685
          http://scummvm.svn.sourceforge.net/scummvm/?rev=40685&view=rev
Author:   fingolfin
Date:     2009-05-18 12:34:56 +0000 (Mon, 18 May 2009)

Log Message:
-----------
SCI: Removed the unused member SegManager::gc_mark_bits; changed some int params to SegmentId

Modified Paths:
--------------
    scummvm/trunk/engines/sci/engine/savegame.cpp
    scummvm/trunk/engines/sci/engine/seg_manager.cpp
    scummvm/trunk/engines/sci/engine/seg_manager.h

Modified: scummvm/trunk/engines/sci/engine/savegame.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/savegame.cpp	2009-05-18 12:34:25 UTC (rev 40684)
+++ scummvm/trunk/engines/sci/engine/savegame.cpp	2009-05-18 12:34:56 UTC (rev 40685)
@@ -160,7 +160,7 @@
 void MenuItem::saveLoadWithSerializer(Common::Serializer &s) {
 	s.syncAsSint32LE(_type);
 	s.syncString(_keytext);
-	s.skip(4); 	// Used to be keytext_size (an already unused field)
+	s.skip(4); 	// Obsolete: Used to be keytext_size
 
 	s.syncAsSint32LE(_flags);
 	s.syncBytes(_said, MENU_SAID_SPEC_SIZE);
@@ -189,7 +189,7 @@
 void SegManager::saveLoadWithSerializer(Common::Serializer &s) {
 	s.syncAsSint32LE(reserved_id);
 	s.syncAsSint32LE(exports_wide);
-	s.syncAsSint32LE(gc_mark_bits);
+	s.skip(4);	// Obsolete: Used to be gc_mark_bits
 
 	id_seg_map->saveLoadWithSerializer(s);
 
@@ -587,8 +587,7 @@
 					scr->export_table = 0;
 					scr->synonyms = 0;
 					if (READ_LE_UINT16(scr->buf + 6) > 0) {
-						scr->export_table = (uint16 *)(scr->buf + 8);
-						scr->exports_nr = READ_LE_UINT16((byte *)(scr->export_table - 1));
+						scr->setExportTableOffset(6);
 					}
 				} else {
 					scr->export_table = (uint16 *) find_unique_script_block(s, scr->buf, SCI_OBJ_EXPORTS);

Modified: scummvm/trunk/engines/sci/engine/seg_manager.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/seg_manager.cpp	2009-05-18 12:34:25 UTC (rev 40684)
+++ scummvm/trunk/engines/sci/engine/seg_manager.cpp	2009-05-18 12:34:56 UTC (rev 40685)
@@ -92,9 +92,6 @@
 
 	exports_wide = 0;
 	isSci1_1 = sci1_1;
-
-	// gc initialisation
-	gc_mark_bits = 0;
 }
 
 // Destroy the object, free the memorys if allocated before
@@ -114,25 +111,22 @@
 // Returns   : 0 - allocation failure
 //             1 - allocated successfully
 //             seg_id - allocated segment id
-Script *SegManager::allocateScript(EngineState *s, int script_nr, int* seg_id) {
-	int seg;
+Script *SegManager::allocateScript(EngineState *s, int script_nr, SegmentId *seg_id) {
 	bool was_added;
-	MemObject* mem;
+	MemObject *mem;
 
-	seg = id_seg_map->checkKey(script_nr, true, &was_added);
+	*seg_id = id_seg_map->checkKey(script_nr, true, &was_added);
 	if (!was_added) {
-		*seg_id = seg;
 		return (Script *)_heap[*seg_id];
 	}
 
 	// allocate the MemObject
-	mem = memObjAllocate(seg, script_nr, MEM_OBJ_SCRIPT);
+	mem = memObjAllocate(*seg_id, script_nr, MEM_OBJ_SCRIPT);
 	if (!mem) {
 		sciprintf("%s, %d, Not enough memory, ", __FILE__, __LINE__);
 		return NULL;
 	}
 
-	*seg_id = seg;
 	return (Script *)mem;
 }
 
@@ -206,7 +200,7 @@
 	return 1;
 }
 
-int SegManager::deallocate(int seg, bool recursive) {
+int SegManager::deallocate(SegmentId seg, bool recursive) {
 	MemObject *mobj;
 	VERIFY(check(seg), "invalid seg id");
 
@@ -267,7 +261,7 @@
 
 
 int SegManager::deallocateScript(int script_nr) {
-	int seg = segGet(script_nr);
+	SegmentId seg = segGet(script_nr);
 
 	deallocate(seg, true);
 
@@ -370,11 +364,11 @@
 }
 
 // return the seg if script_id is valid and in the map, else -1
-int SegManager::segGet(int script_id) const {
+SegmentId SegManager::segGet(int script_id) const {
 	return id_seg_map->lookupKey(script_id);
 }
 
-Script *SegManager::getScript(const int seg) {
+Script *SegManager::getScript(const SegmentId seg) {
 	if (seg < 0 || (uint)seg >= _heap.size()) {
 		error("SegManager::getScript(): seg id %x out of bounds", seg);
 	}
@@ -387,7 +381,7 @@
 	return (Script *)_heap[seg];
 }
 
-Script *SegManager::getScriptIfLoaded(const int seg) {
+Script *SegManager::getScriptIfLoaded(const SegmentId seg) {
 	if (seg < 0 || (uint)seg >= _heap.size() || !_heap[seg] || _heap[seg]->getType() != MEM_OBJ_SCRIPT)
 		return 0;
 	return (Script *)_heap[seg];
@@ -397,7 +391,7 @@
 // return:
 //	false - invalid seg
 //	true  - valid seg
-bool SegManager::check(int seg) {
+bool SegManager::check(SegmentId seg) {
 	if (seg < 0 || (uint)seg >= _heap.size()) {
 		return false;
 	}
@@ -408,7 +402,7 @@
 	return true;
 }
 
-bool SegManager::scriptIsLoaded(int seg) {
+bool SegManager::scriptIsLoaded(SegmentId seg) {
 	return getScriptIfLoaded(seg) != 0;
 }
 
@@ -768,7 +762,7 @@
 	}
 }
 
-void SegManager::scriptRelocateExportsSci11(int seg) {
+void SegManager::scriptRelocateExportsSci11(SegmentId seg) {
 	Script *scr = getScript(seg);
 	for (int i = 0; i < scr->exports_nr; i++) {
 		/* We are forced to use an ugly heuristic here to distinguish function
@@ -784,7 +778,7 @@
 	}
 }
 
-void SegManager::scriptInitialiseObjectsSci11(EngineState *s, int seg) {
+void SegManager::scriptInitialiseObjectsSci11(EngineState *s, SegmentId seg) {
 	Script *scr = getScript(seg);
 	byte *seeker = scr->heap_start + 4 + READ_LE_UINT16(scr->heap_start + 2) * 2;
 
@@ -875,7 +869,7 @@
 	return segid;
 }
 
-uint16 SegManager::validateExportFunc(int pubfunct, int seg) {
+uint16 SegManager::validateExportFunc(int pubfunct, SegmentId seg) {
 	Script *scr = getScript(seg);
 	if (scr->exports_nr <= pubfunct) {
 		sciprintf("pubfunct is invalid");

Modified: scummvm/trunk/engines/sci/engine/seg_manager.h
===================================================================
--- scummvm/trunk/engines/sci/engine/seg_manager.h	2009-05-18 12:34:25 UTC (rev 40684)
+++ scummvm/trunk/engines/sci/engine/seg_manager.h	2009-05-18 12:34:56 UTC (rev 40685)
@@ -60,7 +60,7 @@
 	//			      script data
 	// Returns   : (int) 0 on failure, 1 on success
 	//	       (int) *seg_id: The segment ID of the newly allocated segment, on success
-	Script *allocateScript(EngineState *s, int script_nr, int* seg_id);
+	Script *allocateScript(EngineState *s, int script_nr, SegmentId *seg_id);
 
 	// The script must then be initialised; see section (1b.), below.
 
@@ -73,19 +73,19 @@
 	 * Determines whether a script has been loaded yet.
 	 * @param seg	ID of the script segment to check for
 	 */
-	bool scriptIsLoaded(int seg);
+	bool scriptIsLoaded(SegmentId seg);
 
 	// Validate whether the specified public function is exported by the script in the specified segment
 	// Parameters:	(int) pubfunct: Index of the function to validate
 	//		(int) seg: Segment ID of the script the check is to be performed for
 	// Returns   :  (uint16) 0 if the public function is invalid, its offset into the script's segment
 	//			 otherwise
-	uint16 validateExportFunc(int pubfunct, int seg);
+	uint16 validateExportFunc(int pubfunct, SegmentId seg);
 
 	// 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
-	int segGet(int script_nr) const;
+	SegmentId segGet(int script_nr) const;
 
 	/**
 	 * Return a pointer to the specified script. If the id is invalid, does not refer
@@ -93,14 +93,14 @@
 	 * @param seg	ID of the script segment to check for
 	 * @return pointer to the Script object
 	 */
-	Script *getScript(int seg);
+	Script *getScript(SegmentId seg);
 
 	/**
 	 * Return a pointer to the specified script. If the id is invalid, does not refer
 	 * @param seg	ID of the script segment to check for
 	 * @return pointer to the Script object, or NULL
 	 */
-	Script *getScriptIfLoaded(int seg);
+	Script *getScriptIfLoaded(SegmentId seg);
 
 
 
@@ -260,8 +260,8 @@
 
 
 	void heapRelocate(reg_t block);
-	void scriptRelocateExportsSci11(int seg);
-	void scriptInitialiseObjectsSci11(EngineState *s, int seg);
+	void scriptRelocateExportsSci11(SegmentId seg);
+	void scriptInitialiseObjectsSci11(EngineState *s, SegmentId seg);
 	int initialiseScript(Script &scr, EngineState *s, int script_nr);
 
 private:
@@ -272,11 +272,6 @@
 	int exports_wide;
 	bool isSci1_1;
 
-	int gc_mark_bits;
-	// For standard Mark&Sweep:
-	// 1 or 0, depending on what unreachable/freshly allocated
-	// memory is tagged as
-
 	SegmentId Clones_seg_id; // ID of the (a) clones segment
 	SegmentId Lists_seg_id; // ID of the (a) list segment
 	SegmentId Nodes_seg_id; // ID of the (a) node segment
@@ -286,7 +281,7 @@
 	MemObject *allocNonscriptSegment(MemObjectType type, SegmentId *segid);
 	LocalVariables *allocLocalsSegment(Script *scr, int count);
 	MemObject *memObjAllocate(SegmentId segid, int hash_id, MemObjectType type);
-	int deallocate(int seg, bool recursive);
+	int deallocate(SegmentId seg, bool recursive);
 
 	Hunk *alloc_Hunk(reg_t *);
 
@@ -304,7 +299,7 @@
 	** Returns   : (bool)	false if 'seg' is an invalid segment
 	**			true  if 'seg' is a valid segment
 	*/
-	bool check(int seg);
+	bool check(SegmentId seg);
 
 	void dbgPrint(const char* msg, void *i);	// for debug only
 


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