[Scummvm-cvs-logs] SF.net SVN: scummvm: [32848] scummvm/trunk/engines/cine

buddha_ at users.sourceforge.net buddha_ at users.sourceforge.net
Mon Jun 30 05:33:08 CEST 2008


Revision: 32848
          http://scummvm.svn.sourceforge.net/scummvm/?rev=32848&view=rev
Author:   buddha_
Date:     2008-06-29 20:33:08 -0700 (Sun, 29 Jun 2008)

Log Message:
-----------
Implemented resetGfxEntityEntry and made it used where appropriate (The function wasn't very easy to reverse engineer so it may have flaws still, but let's hope it doesn't ;-)).

Modified Paths:
--------------
    scummvm/trunk/engines/cine/object.cpp
    scummvm/trunk/engines/cine/various.cpp
    scummvm/trunk/engines/cine/various.h

Modified: scummvm/trunk/engines/cine/object.cpp
===================================================================
--- scummvm/trunk/engines/cine/object.cpp	2008-06-30 01:36:50 UTC (rev 32847)
+++ scummvm/trunk/engines/cine/object.cpp	2008-06-30 03:33:08 UTC (rev 32848)
@@ -179,8 +179,12 @@
 	objectTable[objIdx].mask = param3;
 	objectTable[objIdx].frame = param4;
 
-	if (removeOverlay(objIdx, 0)) {
-		addOverlay(objIdx, 0);
+	if (g_cine->getGameType() == Cine::GType_OS) {
+		resetGfxEntityEntry(objIdx);
+	} else { // Future Wars
+		if (removeOverlay(objIdx, 0)) {
+			addOverlay(objIdx, 0);
+		}
 	}
 }
 
@@ -208,9 +212,12 @@
 	case 3:
 		objectTable[objIdx].mask = newValue;
 
-		// TODO: Check this part against disassembly
-		if (removeOverlay(objIdx, 0)) {
-			addOverlay(objIdx, 0);
+		if (g_cine->getGameType() == Cine::GType_OS) { // Operation Stealth specific
+			resetGfxEntityEntry(objIdx);
+		} else { // Future Wars specific
+			if (removeOverlay(objIdx, 0)) {
+				addOverlay(objIdx, 0);
+			}
 		}
 		break;
 	case 4:

Modified: scummvm/trunk/engines/cine/various.cpp
===================================================================
--- scummvm/trunk/engines/cine/various.cpp	2008-06-30 01:36:50 UTC (rev 32847)
+++ scummvm/trunk/engines/cine/various.cpp	2008-06-30 03:33:08 UTC (rev 32848)
@@ -1682,78 +1682,6 @@
 	return returnVar;
 }
 
-// sort all the gfx stuff...
-
-void resetGfxEntityEntry(uint16 objIdx) {
-#if 0
-	overlayHeadElement* tempHead = &overlayHead;
-	byte* var_16 = NULL;
-	uint16 var_10 = 0;
-	uint16 var_12 = 0;
-	overlayHeadElement* currentHead = tempHead->next;
-	byte* var_1A = NULL;
-	overlayHeadElement* var1E = &overlayHead;
-
-	while (currentHead) {
-		tempHead2 = currentHead->next;
-
-		if (currentHead->objIdx == objIdx && currentHead->type!=2 && currentHead->type!=3 && currentHead->type!=0x14) {
-			tempHead->next = tempHead2;
-
-			if (tempHead2) {
-				tempHead2->previous = currentHead->previous;
-			} else {
-				seqVar0 = currentHead->previous;
-			}
-
-			var_22 = var_16;
-
-			if (!var_22) {
-				// todo: goto?
-			}
-
-			var_22->previous = currentHead;
-		} else {
-		}
-
-		if (currentHead->type == 0x14) {
-		} else {
-		}
-
-		if (currentHead->type == 0x2 || currentHead->type == 0x3) {
-			si = 10000;
-		} else {
-			si = objectTable[currentHead->objIdx];
-		}
-
-		if (objectTable[objIdx]>si) {
-			var1E = currentHead;
-		}
-
-		tempHead = tempHead->next;
-
-	}
-
-	if (var_1A) {
-		currentHead = var_16;
-		var_22 = var_1E->next;
-		var_1E->next = currentHead;
-		var_1A->next = var_22;
-
-		if (var_1E != &gfxEntityHead) {
-			currentHead->previous = var_1E;
-		}
-
-		if (!var_22) {
-			seqVar0 = var_1A;
-		} else {
-			var_22->previous = var_1A;
-		}
-
-	}
-#endif
-}
-
 uint16 addAni(uint16 param1, uint16 objIdx, const byte *ptr, SeqListElement &element, uint16 param3, int16 *param4) {
 	const byte *currentPtr = ptr;
 	const byte *ptrData;
@@ -1795,6 +1723,52 @@
 	return 1;
 }
 
+/*! 
+ * Permutates the overlay list into a different order according to some logic.
+ * \todo Check this function for correctness (Wasn't very easy to reverse engineer so there may be errors)
+ */
+void resetGfxEntityEntry(uint16 objIdx) {
+	Common::List<overlay>::iterator it, bObjsCutPoint;
+	Common::List<overlay> aReverseObjs, bObjs;
+	bool foundCutPoint = false;	
+
+	// Go through the overlay list and partition the whole list into two categories (Type A and type B objects)
+	for (it = overlayList.begin(); it != overlayList.end(); ++it) {
+		if (it->objIdx == objIdx && it->type != 2 && it->type != 3) { // Type A object
+			aReverseObjs.push_front(*it);
+		} else { // Type B object
+			bObjs.push_back(*it);
+			uint16 objectMask;
+			if (it->type == 2 || it->type == 3) {
+				objectMask = 10000;
+			} else {
+				objectMask = objectTable[it->objIdx].mask;
+			}
+	
+			if (objectTable[objIdx].mask > objectMask) { // Check for B objects' cut point
+				bObjsCutPoint = bObjs.reverse_begin();
+				foundCutPoint = true;
+			}
+		}
+	}
+	
+	// Recreate the overlay list in a different order.
+	overlayList.clear();
+	if (foundCutPoint) {
+		// If a cut point was found the order is:
+		// B objects before the cut point, the cut point, A objects in reverse order, B objects after cut point.
+		++bObjsCutPoint; // Include the cut point in the first list insertion
+		overlayList.insert(overlayList.end(), bObjs.begin(), bObjsCutPoint);
+		overlayList.insert(overlayList.end(), aReverseObjs.begin(), aReverseObjs.end());
+		overlayList.insert(overlayList.end(), bObjsCutPoint, bObjs.end());
+	} else {
+		// If no cut point was found the order is:
+		// A objects in reverse order, B objects.
+		overlayList.insert(overlayList.end(), aReverseObjs.begin(), aReverseObjs.end());
+		overlayList.insert(overlayList.end(), bObjs.begin(), bObjs.end());
+	}
+}
+
 void processSeqListElement(SeqListElement &element) {
 	int16 x = objectTable[element.objIdx].x;
 	int16 y = objectTable[element.objIdx].y;

Modified: scummvm/trunk/engines/cine/various.h
===================================================================
--- scummvm/trunk/engines/cine/various.h	2008-06-30 01:36:50 UTC (rev 32847)
+++ scummvm/trunk/engines/cine/various.h	2008-06-30 03:33:08 UTC (rev 32848)
@@ -142,6 +142,8 @@
 void modifySeqListElement(uint16 objIdx, int16 var4Test, int16 param1, int16 param2, int16 param3, int16 param4);
 void processSeqList(void);
 
+void resetGfxEntityEntry(uint16 objIdx);
+
 bool makeTextEntryMenu(const char *caption, char *string, int strLen, int y);
 
 } // End of namespace Cine


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