[Scummvm-cvs-logs] SF.net SVN: scummvm: [25652] scummvm/trunk/engines/parallaction

peres001 at users.sourceforge.net peres001 at users.sourceforge.net
Sat Feb 17 11:58:55 CET 2007


Revision: 25652
          http://scummvm.svn.sourceforge.net/scummvm/?rev=25652&view=rev
Author:   peres001
Date:     2007-02-17 02:58:54 -0800 (Sat, 17 Feb 2007)

Log Message:
-----------
fixed regression bug caused by ZoneTypeData being declared as a struct instead of an union. Should have taken care of this when the switch was actually made...

Modified Paths:
--------------
    scummvm/trunk/engines/parallaction/inventory.h
    scummvm/trunk/engines/parallaction/zone.cpp

Modified: scummvm/trunk/engines/parallaction/inventory.h
===================================================================
--- scummvm/trunk/engines/parallaction/inventory.h	2007-02-17 09:56:09 UTC (rev 25651)
+++ scummvm/trunk/engines/parallaction/inventory.h	2007-02-17 10:58:54 UTC (rev 25652)
@@ -27,13 +27,17 @@
 
 namespace Parallaction {
 
+
 struct Cnv;
 
 struct InventoryItem {
-	uint32		_id;
+	uint32		_id;            // lowest 16 bits are always zero
 	uint16		_index;
 };
 
+#define MAKE_INVENTORY_ID(x) (((x) & 0xFFFF) << 16)
+
+
 extern InventoryItem _inventory[];
 
 void initInventory();

Modified: scummvm/trunk/engines/parallaction/zone.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/zone.cpp	2007-02-17 09:56:09 UTC (rev 25651)
+++ scummvm/trunk/engines/parallaction/zone.cpp	2007-02-17 10:58:54 UTC (rev 25652)
@@ -128,9 +128,15 @@
 
 	for (; z; ) {
 
-		// TODO: understand and simplify this monster
-		if (((z->_limits._top == -1) || ((z->_limits._left == -2) && ((isItemInInventory(z->u.merge->_obj1) != 0) || (isItemInInventory(z->u.merge->_obj2) != 0)))) &&
-			((_engineFlags & kEngineQuit) == 0)) {
+        // WORKAROUND: this huge condition is needed because we made ZoneTypeData a collection of structs
+        // instead of an union. So, merge->_obj1 and get->_icon were just aliases in the original engine,
+        // but we need to check it separately here. The same workaround is applied in hitZone.
+		if (((z->_limits._top == -1) ||
+            ((z->_limits._left == -2) && (
+                (((z->_type & 0xFFFF) == kZoneMerge) && ((isItemInInventory(MAKE_INVENTORY_ID(z->u.merge->_obj1)) != 0) || (isItemInInventory(MAKE_INVENTORY_ID(z->u.merge->_obj2)) != 0))) ||
+                (((z->_type & 0xFFFF) == kZoneGet) && ((isItemInInventory(MAKE_INVENTORY_ID(z->u.get->_icon)) != 0)))
+            ))) &&
+            ((_engineFlags & kEngineQuit) == 0)) {
 
             debugC(1, kDebugLocation, "freeZones preserving zone '%s'", z->_label._text);
 
@@ -623,10 +629,12 @@
 
 			// out of Zone, so look for special values
 			if ((z->_limits._left == -2) || (z->_limits._left == -3)) {
-				// only merge zones have _left == -2 or _left == -3
 
-				if (((_si == z->u.merge->_obj1) && (_di == z->u.merge->_obj2)) ||
-					((_si == z->u.merge->_obj2) && (_di == z->u.merge->_obj1))) {
+				// WORKAROUND: this huge condition is needed because we made ZoneTypeData a collection of structs
+				// instead of an union. So, merge->_obj1 and get->_icon were just aliases in the original engine,
+				// but we need to check it separately here. The same workaround is applied in freeZones.
+				if ((((z->_type & 0xFFFF0000) == kZoneMerge) && (((_si == z->u.merge->_obj1) && (_di == z->u.merge->_obj2)) || ((_si == z->u.merge->_obj2) && (_di == z->u.merge->_obj1)))) ||
+                    (((z->_type & 0xFFFF0000) == kZoneGet) && ((_si == z->u.get->_icon) || (_di == z->u.get->_icon)))) {
 
 					// special Zone
 					if ((type == 0) && ((z->_type & 0xFFFF0000) == 0)) return z;


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