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

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Thu Sep 17 02:46:02 CEST 2009


Revision: 44131
          http://scummvm.svn.sourceforge.net/scummvm/?rev=44131&view=rev
Author:   fingolfin
Date:     2009-09-17 00:46:01 +0000 (Thu, 17 Sep 2009)

Log Message:
-----------
SCI: Change SegmentId from int to uint16; consistently use segment 0 to indicate an invalid segment

Modified Paths:
--------------
    scummvm/trunk/engines/sci/engine/kstring.cpp
    scummvm/trunk/engines/sci/engine/memobj.h
    scummvm/trunk/engines/sci/engine/seg_manager.cpp
    scummvm/trunk/engines/sci/engine/seg_manager.h
    scummvm/trunk/engines/sci/engine/vm.cpp
    scummvm/trunk/engines/sci/engine/vm_types.h

Modified: scummvm/trunk/engines/sci/engine/kstring.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kstring.cpp	2009-09-17 00:45:12 UTC (rev 44130)
+++ scummvm/trunk/engines/sci/engine/kstring.cpp	2009-09-17 00:46:01 UTC (rev 44131)
@@ -148,7 +148,7 @@
 		script = GET_SEL32V(objpos, number);
 		seg = s->segMan->getScriptSegment(script);
 
-		if (seg >= 0)
+		if (seg > 0)
 			_numSynonyms = s->segMan->getScript(seg)->getSynonymsNr();
 
 		if (_numSynonyms) {

Modified: scummvm/trunk/engines/sci/engine/memobj.h
===================================================================
--- scummvm/trunk/engines/sci/engine/memobj.h	2009-09-17 00:45:12 UTC (rev 44130)
+++ scummvm/trunk/engines/sci/engine/memobj.h	2009-09-17 00:46:01 UTC (rev 44131)
@@ -269,7 +269,7 @@
 	Common::Array<Object> _objects;
 
 	int _localsOffset;
-	int _localsSegment; /**< The local variable segment */
+	SegmentId _localsSegment; /**< The local variable segment */
 	LocalVariables *_localsBlock;
 
 	Common::Array<CodeBlock> _codeBlocks;

Modified: scummvm/trunk/engines/sci/engine/seg_manager.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/seg_manager.cpp	2009-09-17 00:45:12 UTC (rev 44130)
+++ scummvm/trunk/engines/sci/engine/seg_manager.cpp	2009-09-17 00:46:01 UTC (rev 44131)
@@ -116,7 +116,7 @@
 Script *SegManager::allocateScript(int script_nr, SegmentId *seg_id) {
 	// Check if the script already has an allocated segment. If it
 	// does have one, return it.
-	*seg_id = _scriptSegMap.getVal(script_nr, -1);
+	*seg_id = _scriptSegMap.getVal(script_nr, 0);
 	if (*seg_id > 0) {
 		return (Script *)_heap[*seg_id];
 	}
@@ -223,7 +223,7 @@
 	for (uint i = 0; i < _heap.size(); i++)
 		if (_heap[i] && _heap[i]->getType() == type)
 			return i;
-	return -1;
+	return 0;
 }
 
 SegmentObj *SegManager::getSegmentObj(SegmentId seg) {
@@ -414,9 +414,9 @@
 	}
 }
 
-// return the seg if script_id is valid and in the map, else -1
+// return the seg if script_id is valid and in the map, else 0
 SegmentId SegManager::getScriptSegment(int script_id) const {
-	return _scriptSegMap.getVal(script_id, -1);
+	return _scriptSegMap.getVal(script_id, 0);
 }
 
 SegmentId SegManager::getScriptSegment(int script_nr, ScriptLoadType load) {
@@ -430,10 +430,8 @@
 	if (segment > 0) {
 		if ((load & SCRIPT_GET_LOCK) == SCRIPT_GET_LOCK)
 			getScript(segment)->incrementLockers();
-
-		return segment;
-	} else
-		return -1;
+	}
+	return segment;
 }
 
 reg_t SegManager::getClassAddress(int classnr, ScriptLoadType lock, reg_t caller) {

Modified: scummvm/trunk/engines/sci/engine/seg_manager.h
===================================================================
--- scummvm/trunk/engines/sci/engine/seg_manager.h	2009-09-17 00:45:12 UTC (rev 44130)
+++ scummvm/trunk/engines/sci/engine/seg_manager.h	2009-09-17 00:46:01 UTC (rev 44131)
@@ -93,7 +93,7 @@
 	/**
 	 * Determines the segment occupied by a certain script, if any.
 	 * @param script_nr		Number of the script to look up
-	 * @return				The script's segment ID, or -1 on failure
+	 * @return				The script's segment ID, or 0 on failure
 	 */
 	SegmentId getScriptSegment(int script_nr) const;
 
@@ -102,7 +102,7 @@
 	 * load it, or load & lock it.
 	 * @param[in] script_nr	Number of the script to look up
 	 * @param[in] load		flag determining whether to load/lock the script
-	 * @return				The script's segment ID, or -1 on failure
+	 * @return				The script's segment ID, or 0 on failure
 	 */
 	SegmentId getScriptSegment(int script_nr, ScriptLoadType load);
 

Modified: scummvm/trunk/engines/sci/engine/vm.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/vm.cpp	2009-09-17 00:45:12 UTC (rev 44130)
+++ scummvm/trunk/engines/sci/engine/vm.cpp	2009-09-17 00:46:01 UTC (rev 44131)
@@ -1509,9 +1509,6 @@
 #define INST_LOOKUP_CLASS(id) ((id == 0xffff)? NULL_REG : segMan->getClassAddress(id, SCRIPT_GET_LOCK, reg))
 
 int script_instantiate_common(ResourceManager *resMan, SegManager *segMan, int script_nr, Resource **script, Resource **heap, int *was_new) {
-	int seg_id;
-	reg_t reg;
-
 	*was_new = 1;
 
 	*script = resMan->findResource(ResourceId(kResourceTypeScript, script_nr), 0);
@@ -1529,7 +1526,7 @@
 		return 0;
 	}
 
-	seg_id = segMan->getScriptSegment(script_nr);
+	SegmentId seg_id = segMan->getScriptSegment(script_nr);
 	Script *scr = segMan->getScriptIfLoaded(seg_id);
 	if (scr) {
 		if (!scr->isMarkedAsDeleted()) {
@@ -1548,6 +1545,7 @@
 
 	scr->init(script_nr, resMan);
 
+	reg_t reg;
 	reg.segment = seg_id;
 	reg.offset = 0;
 

Modified: scummvm/trunk/engines/sci/engine/vm_types.h
===================================================================
--- scummvm/trunk/engines/sci/engine/vm_types.h	2009-09-17 00:45:12 UTC (rev 44130)
+++ scummvm/trunk/engines/sci/engine/vm_types.h	2009-09-17 00:46:01 UTC (rev 44131)
@@ -31,10 +31,10 @@
 namespace Sci {
 
 // Segment ID type
-typedef int SegmentId;
+typedef uint16 SegmentId;
 
 struct reg_t {
-	uint16 segment;
+	SegmentId segment;
 	uint16 offset;
 
 	bool isNull() const {


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