[Scummvm-cvs-logs] SF.net SVN: scummvm:[33280] scummvm/trunk/engines/tinsel

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Fri Jul 25 11:17:48 CEST 2008


Revision: 33280
          http://scummvm.svn.sourceforge.net/scummvm/?rev=33280&view=rev
Author:   fingolfin
Date:     2008-07-25 09:17:47 +0000 (Fri, 25 Jul 2008)

Log Message:
-----------
More tinsel cleanup

Modified Paths:
--------------
    scummvm/trunk/engines/tinsel/cliprect.cpp
    scummvm/trunk/engines/tinsel/polygons.cpp
    scummvm/trunk/engines/tinsel/rince.h
    scummvm/trunk/engines/tinsel/scene.h

Modified: scummvm/trunk/engines/tinsel/cliprect.cpp
===================================================================
--- scummvm/trunk/engines/tinsel/cliprect.cpp	2008-07-25 09:16:33 UTC (rev 33279)
+++ scummvm/trunk/engines/tinsel/cliprect.cpp	2008-07-25 09:17:47 UTC (rev 33280)
@@ -61,12 +61,12 @@
  * @param pSrc2			Pointer to a source rectangle
  */
 bool IntersectRectangle(Common::Rect &pDest, const Common::Rect &pSrc1, const Common::Rect &pSrc2) {
-	pDest.left   = (pSrc1.left > pSrc2.left) ? pSrc1.left : pSrc2.left;
-	pDest.top    = (pSrc1.top > pSrc2.top) ? pSrc1.top : pSrc2.top;
-	pDest.right  = (pSrc1.right < pSrc2.right) ? pSrc1.right : pSrc2.right;
-	pDest.bottom = (pSrc1.bottom < pSrc2.bottom) ? pSrc1.bottom : pSrc2.bottom;
+	pDest.left   = MAX(pSrc1.left, pSrc2.left);
+	pDest.top    = MAX(pSrc1.top, pSrc2.top);
+	pDest.right  = MIN(pSrc1.right, pSrc2.right);
+	pDest.bottom = MIN(pSrc1.bottom, pSrc2.bottom);
 
-	return (pDest.right > pDest.left && pDest.bottom > pDest.top);
+	return !pDest.isEmpty();
 }
 
 /**
@@ -77,12 +77,12 @@
  * @param pSrc2			a source rectangle
  */
 bool UnionRectangle(Common::Rect &pDest, const Common::Rect &pSrc1, const Common::Rect &pSrc2) {
-	pDest.left   = (pSrc1.left < pSrc2.left) ? pSrc1.left : pSrc2.left;
-	pDest.top    = (pSrc1.top < pSrc2.top) ? pSrc1.top : pSrc2.top;
-	pDest.right  = (pSrc1.right > pSrc2.right) ? pSrc1.right : pSrc2.right;
-	pDest.bottom = (pSrc1.bottom > pSrc2.bottom) ? pSrc1.bottom : pSrc2.bottom;
+	pDest.left   = MIN(pSrc1.left, pSrc2.left);
+	pDest.top    = MIN(pSrc1.top, pSrc2.top);
+	pDest.right  = MAX(pSrc1.right, pSrc2.right);
+	pDest.bottom = MAX(pSrc1.bottom, pSrc2.bottom);
 
-	return (pDest.right > pDest.left && pDest.bottom > pDest.top);
+	return !pDest.isEmpty();
 }
 
 /**
@@ -93,12 +93,12 @@
 static bool LooseIntersectRectangle(const Common::Rect &pSrc1, const Common::Rect &pSrc2) {
 	Common::Rect pDest;
 
-	pDest.left   = (pSrc1.left > pSrc2.left) ? pSrc1.left : pSrc2.left;
-	pDest.top    = (pSrc1.top > pSrc2.top) ? pSrc1.top : pSrc2.top;
-	pDest.right  = (pSrc1.right < pSrc2.right) ? pSrc1.right : pSrc2.right;
-	pDest.bottom = (pSrc1.bottom < pSrc2.bottom) ? pSrc1.bottom : pSrc2.bottom;
+	pDest.left   = MAX(pSrc1.left, pSrc2.left);
+	pDest.top    = MAX(pSrc1.top, pSrc2.top);
+	pDest.right  = MIN(pSrc1.right, pSrc2.right);
+	pDest.bottom = MIN(pSrc1.bottom, pSrc2.bottom);
 
-	return (pDest.right >= pDest.left && pDest.bottom >= pDest.top);
+	return pDest.isValidRect();
 }
 
 /**
@@ -174,26 +174,27 @@
  * Merges any clipping rectangles that overlap to try and reduce
  * the total number of clip rectangles.
  */
-void MergeClipRect(void) {
-	if (s_rectList.size() > 1) {
-		RectList::iterator rOuter, rInner;
+void MergeClipRect() {
+	if (s_rectList.size() <= 1)
+		return;
 
-		for (rOuter = s_rectList.begin(); rOuter != s_rectList.end(); ++rOuter) {
-			rInner = rOuter;
-			while (++rInner != s_rectList.end()) {
+	RectList::iterator rOuter, rInner;
 
-				if (LooseIntersectRectangle(*rOuter, *rInner)) {
-					// these two rectangles overlap or
-					// are next to each other - merge them
+	for (rOuter = s_rectList.begin(); rOuter != s_rectList.end(); ++rOuter) {
+		rInner = rOuter;
+		while (++rInner != s_rectList.end()) {
 
-					UnionRectangle(*rOuter, *rOuter, *rInner);
+			if (LooseIntersectRectangle(*rOuter, *rInner)) {
+				// these two rectangles overlap or
+				// are next to each other - merge them
 
-					// remove the inner rect from the list
-					s_rectList.erase(rInner);
+				UnionRectangle(*rOuter, *rOuter, *rInner);
 
-					// move back to beginning of list
-					rInner = rOuter;
-				}
+				// remove the inner rect from the list
+				s_rectList.erase(rInner);
+
+				// move back to beginning of list
+				rInner = rOuter;
 			}
 		}
 	}
@@ -298,8 +299,8 @@
 		// copy objects properties to local object
 		currentObj.width    = pObj->width;
 		currentObj.height   = pObj->height;
-		currentObj.xPos     = (short) x;
-		currentObj.yPos     = (short) y;
+		currentObj.xPos     = (short)x;
+		currentObj.yPos     = (short)y;
 		currentObj.pPal     = pObj->pPal;
 		currentObj.constant = pObj->constant;
 		currentObj.hBits    = pObj->hBits;

Modified: scummvm/trunk/engines/tinsel/polygons.cpp
===================================================================
--- scummvm/trunk/engines/tinsel/polygons.cpp	2008-07-25 09:16:33 UTC (rev 33279)
+++ scummvm/trunk/engines/tinsel/polygons.cpp	2008-07-25 09:17:47 UTC (rev 33280)
@@ -37,7 +37,13 @@
 
 //----------------- LOCAL DEFINES --------------------
 
+/** different types of polygon */
+enum POLY_TYPE {
+	POLY_PATH, POLY_NPATH, POLY_BLOCK, POLY_REFER, POLY_EFFECT,
+	POLY_EXIT, POLY_TAG
+};
 
+
 // Note 7/10/94, with adjacency reduction ANKHMAP max is 3, UNSEEN max is 4
 // so reduced this back to 6 (from 12) for now.
 #define MAXADJ	6	// Max number of known adjacent paths
@@ -1142,29 +1148,6 @@
 }
 
 /**
- * Convert a TAG to an EX_TAG poly.
- */
-void DisableTag(int tagno) {
-	TAGSTATE *pts;
-
-	for (int i = 0; i < MAX_POLY; i++) {
-		if (Polys[i] && Polys[i]->polytype == TAG && Polys[i]->polyID == tagno) {
-			Polys[i]->polytype = EX_TAG;
-			Polys[i]->tagState = TAG_OFF;
-			Polys[i]->pointState = NOT_POINTING;
-		}
-	}
-
-	pts = &TagStates[SceneTags[currentTScene].offset];
-	for (int j = 0; j < SceneTags[currentTScene].nooftags; j++, pts++) {
-		if (pts->tid == tagno) {
-			pts->enabled = false;
-			break;
-		}
-	}
-}
-
-/**
  * Convert an EX_TAG to a TAG poly.
  */
 void EnableTag(int tagno) {
@@ -1205,6 +1188,29 @@
 }
 
 /**
+ * Convert a TAG to an EX_TAG poly.
+ */
+void DisableTag(int tagno) {
+	TAGSTATE *pts;
+
+	for (int i = 0; i < MAX_POLY; i++) {
+		if (Polys[i] && Polys[i]->polytype == TAG && Polys[i]->polyID == tagno) {
+			Polys[i]->polytype = EX_TAG;
+			Polys[i]->tagState = TAG_OFF;
+			Polys[i]->pointState = NOT_POINTING;
+		}
+	}
+
+	pts = &TagStates[SceneTags[currentTScene].offset];
+	for (int j = 0; j < SceneTags[currentTScene].nooftags; j++, pts++) {
+		if (pts->tid == tagno) {
+			pts->enabled = false;
+			break;
+		}
+	}
+}
+
+/**
  * Convert a EXIT to an EX_EXIT poly.
  */
 void DisableExit(int exitno) {
@@ -1419,6 +1425,7 @@
 			return;
 		}
 	}
+	
 	i = numScenesT++;
 	currentTScene = i;
 	assert(numScenesT < MAX_SCENES); // Dead tag remembering: scene limit
@@ -1441,11 +1448,7 @@
 /**
  * Called at the start of a scene, nobbles EXIT polygons which should be dead.
  */
-#ifdef DEBUG
-void SetExExits(SCNHANDLE ph) {
-#else
 static void SetExExits(SCNHANDLE ph) {
-#endif
 	TAGSTATE *pts;
 	int i, j;
 
@@ -1488,29 +1491,29 @@
 	int	t1, t2;		// General purpose temp. variables
 
 	// Enclosing external rectangle
-	t1 = p->cx[0] > p->cx[1] ? p->cx[0] : p->cx[1];
-	t2 = p->cx[2] > p->cx[3] ? p->cx[2] : p->cx[3];
-	p->pright = (short)(t1 > t2 ? t1 : t2);
+	t1 = MAX(p->cx[0], p->cx[1]);
+	t2 = MAX(p->cx[2], p->cx[3]);
+	p->pright = MAX(t1, t2);
 
-	t1 = p->cx[0] < p->cx[1] ? p->cx[0] : p->cx[1];
-	t2 = p->cx[2] < p->cx[3] ? p->cx[2] : p->cx[3];
-	p->pleft = (short)(t1 < t2 ? t1 : t2);
+	t1 = MIN(p->cx[0], p->cx[1]);
+	t2 = MIN(p->cx[2], p->cx[3]);
+	p->pleft = MIN(t1, t2);
 
-	t1 = p->cy[0] > p->cy[1] ? p->cy[0] : p->cy[1];
-	t2 = p->cy[2] > p->cy[3] ? p->cy[2] : p->cy[3];
-	p->pbottom = (short)(t1 > t2 ? t1 : t2);
+	t1 = MAX(p->cy[0], p->cy[1]);
+	t2 = MAX(p->cy[2], p->cy[3]);
+	p->pbottom = MAX(t1, t2);
 
-	t1 = p->cy[0] < p->cy[1] ? p->cy[0] : p->cy[1];
-	t2 = p->cy[2] < p->cy[3] ? p->cy[2] : p->cy[3];
-	p->ptop = (short)(t1 < t2 ? t1 : t2);
+	t1 = MIN(p->cy[0], p->cy[1]);
+	t2 = MIN(p->cy[2], p->cy[3]);
+	p->ptop = MIN(t1, t2);
 
 	// Rectangles enclosing each side and each side's magic numbers
 	for (t1 = 0; t1 < 4; t1++) {
-		p->lright[t1]   = p->cx[t1] > p->cx[(t1+1)%4] ? p->cx[t1] : p->cx[(t1+1)%4];
-		p->lleft[t1]    = p->cx[t1] < p->cx[(t1+1)%4] ? p->cx[t1] : p->cx[(t1+1)%4];
+		p->lright[t1]   = MAX(p->cx[t1], p->cx[(t1+1)%4]);
+		p->lleft[t1]    = MIN(p->cx[t1], p->cx[(t1+1)%4]);
 
-		p->ltop[t1]     = p->cy[t1] < p->cy[(t1+1)%4] ? p->cy[t1] : p->cy[(t1+1)%4];    
-		p->lbottom[t1]  = p->cy[t1] > p->cy[(t1+1)%4] ? p->cy[t1] : p->cy[(t1+1)%4];
+		p->ltop[t1]     = MIN(p->cy[t1], p->cy[(t1+1)%4]);    
+		p->lbottom[t1]  = MAX(p->cy[t1], p->cy[(t1+1)%4]);
 
 		p->a[t1] = p->cy[t1] - p->cy[(t1+1)%4];
 		p->b[t1] = p->cx[(t1+1)%4] - p->cx[t1];
@@ -1522,11 +1525,7 @@
  * Calculate a point approximating to the centre of a polygon.
  * Not very sophisticated.
  */
-#ifdef DEBUG
-void PseudoCentre(POLYGON *p) {
-#else
 static void PseudoCentre(POLYGON *p) {
-#endif
 	p->pcentrex = (p->cx[0] + p->cx[1] + p->cx[2] + p->cx[3])/4;
 	p->pcentrey = (p->cy[0] + p->cy[1] + p->cy[2] + p->cy[3])/4;
 

Modified: scummvm/trunk/engines/tinsel/rince.h
===================================================================
--- scummvm/trunk/engines/tinsel/rince.h	2008-07-25 09:16:33 UTC (rev 33279)
+++ scummvm/trunk/engines/tinsel/rince.h	2008-07-25 09:17:47 UTC (rev 33280)
@@ -67,7 +67,7 @@
 
 	IND	InDifficulty;
 
-/* For use in 'follow nodes' polygons   */
+	/* For use in 'follow nodes' polygons   */
 	HPOLYGON hFnpath;
 	NPS	npstatus;
 	int     line;
@@ -77,7 +77,7 @@
 	bool	TagReelRunning;
 
 
-   /* Used internally */
+	/* Used internally */
 	DIRREEL	dirn;		// Current reel
 	int	scale;		// Current scale
 	int	scount;		// Step count for walking reel synchronisation

Modified: scummvm/trunk/engines/tinsel/scene.h
===================================================================
--- scummvm/trunk/engines/tinsel/scene.h	2008-07-25 09:16:33 UTC (rev 33279)
+++ scummvm/trunk/engines/tinsel/scene.h	2008-07-25 09:17:47 UTC (rev 33280)
@@ -55,12 +55,6 @@
 	ACT_ALWAYS = -2
 };
 
-/** different types of polygon */
-enum POLY_TYPE {
-	POLY_PATH, POLY_NPATH, POLY_BLOCK, POLY_REFER, POLY_EFFECT,
-	POLY_EXIT, POLY_TAG
-};
-
 /** different scales */
 enum SCALE {
 	SCALE_DEFAULT, SCALE_LARGE, SCALE_MEDIUM, SCALE_SMALL,


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