[Scummvm-cvs-logs] SF.net SVN: scummvm: [28886] scummvm/trunk/engines/scumm/object.cpp

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Mon Sep 10 15:16:07 CEST 2007


Revision: 28886
          http://scummvm.svn.sourceforge.net/scummvm/?rev=28886&view=rev
Author:   fingolfin
Date:     2007-09-10 06:16:06 -0700 (Mon, 10 Sep 2007)

Log Message:
-----------
Added some comments

Modified Paths:
--------------
    scummvm/trunk/engines/scumm/object.cpp

Modified: scummvm/trunk/engines/scumm/object.cpp
===================================================================
--- scummvm/trunk/engines/scumm/object.cpp	2007-09-10 13:15:40 UTC (rev 28885)
+++ scummvm/trunk/engines/scumm/object.cpp	2007-09-10 13:16:06 UTC (rev 28886)
@@ -156,11 +156,14 @@
 }
 
 void ScummEngine::clearOwnerOf(int obj) {
-	int i, j;
+	int i;
 	uint16 *a;
 
+	// Stop the associated object script code (else crashes might occurs)
 	stopObjectScript(obj);
 
+	// If the object is "owned" by a the current room, we scan the
+	// object list and (only if it's a floating object) nuke it.
 	if (getOwner(obj) == OF_OWNER_ROOM) {
 		for (i = 0; i < _numLocalObjects; i++)  {
 			if (_objs[i].obj_nr == obj && _objs[i].fl_object_index) {
@@ -170,26 +173,28 @@
 				_objs[i].fl_object_index = 0;
 			}
 		}
-		return;
-	}
-
-	for (i = 0; i < _numInventory; i++) {
-		if (_inventory[i] == obj) {
-			j = whereIsObject(obj);
-			if (j == WIO_INVENTORY) {
+	} else {
+	
+		// Alternatively, scan the inventory to see if the object is in there...
+		for (i = 0; i < _numInventory; i++) {
+			if (_inventory[i] == obj) {
+				assert(WIO_INVENTORY == whereIsObject(obj));
+				// Found the object! Nuke it from the inventory.
 				_res->nukeResource(rtInventory, i);
 				_inventory[i] = 0;
-			}
-			a = _inventory;
-			for (i = 0; i < _numInventory - 1; i++, a++) {
-				if (!a[0] && a[1]) {
-					a[0] = a[1];
-					a[1] = 0;
-					_res->address[rtInventory][i] = _res->address[rtInventory][i + 1];
-					_res->address[rtInventory][i + 1] = NULL;
+	
+				// Now fill up the gap removing the object from the inventory created.
+				a = _inventory;
+				for (i = 0; i < _numInventory - 1; i++, a++) {
+					if (!_inventory[i] && _inventory[i+1]) {
+						_inventory[i] = _inventory[i+1];
+						_inventory[i+1] = 0;
+						_res->address[rtInventory][i] = _res->address[rtInventory][i + 1];
+						_res->address[rtInventory][i + 1] = NULL;
+					}
 				}
+				break;
 			}
-			return;
 		}
 	}
 }
@@ -583,12 +588,8 @@
 		return;
 
 	ptr = getOBIMFromObjectData(od);
+	ptr = getObjectImage(ptr, getState(od.obj_nr));
 
-	if (_game.features & GF_OLD_BUNDLE)
-		ptr += 0;
-	else
-		ptr = getObjectImage(ptr, getState(od.obj_nr));
-
 	if (!ptr)
 		return;
 


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