[Scummvm-cvs-logs] SF.net SVN: scummvm:[45473] scummvm/trunk/engines/sci/gui/gui_picture.cpp

m_kiewitz at users.sourceforge.net m_kiewitz at users.sourceforge.net
Wed Oct 28 16:07:24 CET 2009


Revision: 45473
          http://scummvm.svn.sourceforge.net/scummvm/?rev=45473&view=rev
Author:   m_kiewitz
Date:     2009-10-28 15:07:24 +0000 (Wed, 28 Oct 2009)

Log Message:
-----------
SCI/newgui: floodfill fixed (hopefully), fixes kq5 priority issues

Modified Paths:
--------------
    scummvm/trunk/engines/sci/gui/gui_picture.cpp

Modified: scummvm/trunk/engines/sci/gui/gui_picture.cpp
===================================================================
--- scummvm/trunk/engines/sci/gui/gui_picture.cpp	2009-10-28 15:01:13 UTC (rev 45472)
+++ scummvm/trunk/engines/sci/gui/gui_picture.cpp	2009-10-28 15:07:24 UTC (rev 45473)
@@ -522,6 +522,11 @@
 		default:
 			error("Unsupported pic-operation %X", pic_op);
 		}
+		//printf("picop %X\n", pic_op);
+		// for debug purposes
+		//_screen->copyToScreen();
+		//g_system->updateScreen();
+		//g_system->delayMillis(500);
 	}
 	error("picture vector data without terminator");
 }
@@ -586,7 +591,7 @@
 	Common::Stack<Common::Point> stack;
 	Common::Point p, p1;
 	byte screenMask = _screen->getDrawingMask(color, priority, control);
-	byte matchedMask;
+	byte matchedMask, matchMask;
 	int16 w, e, a_set, b_set;
 
 	p.x = x + curPort->left;
@@ -597,6 +602,18 @@
 	byte searchPriority = _screen->getPriority(p.x, p.y);
 	byte searchControl = _screen->getControl(p.x, p.y);
 
+	// Now remove screens, that already got the right color/priority/control
+	if ((screenMask & SCI_SCREEN_MASK_VISUAL) && (searchColor == color))
+		screenMask ^= SCI_SCREEN_MASK_VISUAL;
+	if ((screenMask & SCI_SCREEN_MASK_PRIORITY) && (searchPriority == priority))
+		screenMask ^= SCI_SCREEN_MASK_PRIORITY;
+	if ((screenMask & SCI_SCREEN_MASK_CONTROL) && (searchControl == control))
+		screenMask ^= SCI_SCREEN_MASK_CONTROL;
+
+	// Exit, if no screens left
+	if (!screenMask)
+		return;
+
 	// This logic was taken directly from sierra sci, floodfill will get aborted on various occations
 	if (screenMask & SCI_SCREEN_MASK_VISUAL) {
 		if (_resMan->isVGA()) {
@@ -606,22 +623,17 @@
 			if ((color == 15) || (searchColor != 15))
 				return;
 		}
+		matchMask = SCI_SCREEN_MASK_VISUAL;
 	} else if (screenMask & SCI_SCREEN_MASK_PRIORITY) {
 		if ((priority == 0) || (searchPriority != 0))
 			return;
+		matchMask = SCI_SCREEN_MASK_PRIORITY;
 	} else if (screenMask & SCI_SCREEN_MASK_CONTROL) {
 		if ((control == 0) || (searchControl != 0))
 			return;
+		matchMask = SCI_SCREEN_MASK_CONTROL;
 	}
 
-	// Now remove screens, that already got the right color/priority/control
-	if ((screenMask & SCI_SCREEN_MASK_VISUAL) && (searchColor == color))
-		screenMask ^= SCI_SCREEN_MASK_VISUAL;
-	if ((screenMask & SCI_SCREEN_MASK_PRIORITY) && (searchPriority == priority))
-		screenMask ^= SCI_SCREEN_MASK_PRIORITY;
-	if ((screenMask & SCI_SCREEN_MASK_CONTROL) && (searchControl == control))
-		screenMask ^= SCI_SCREEN_MASK_CONTROL;
-
 	// hard borders for filling
 	int l = curPort->rect.left + curPort->left;
 	int t = curPort->rect.top + curPort->top;
@@ -629,20 +641,20 @@
 	int b = curPort->rect.bottom + curPort->top - 1;
 	while (stack.size()) {
 		p = stack.pop();
-		if ((matchedMask = _screen->isFillMatch(p.x, p.y, screenMask, searchColor, searchPriority, searchControl)) == 0) // already filled
+		if ((matchedMask = _screen->isFillMatch(p.x, p.y, matchMask, searchColor, searchPriority, searchControl)) == 0) // already filled
 			continue;
 		_screen->putPixel(p.x, p.y, screenMask, color, priority, control);
 		w = p.x;
 		e = p.x;
 		// moving west and east pointers as long as there is a matching color to fill
-		while (w > l && (matchedMask == _screen->isFillMatch(w - 1, p.y, screenMask, searchColor, searchPriority, searchControl)))
+		while (w > l && (matchedMask = _screen->isFillMatch(w - 1, p.y, matchMask, searchColor, searchPriority, searchControl)))
 			_screen->putPixel(--w, p.y, screenMask, color, priority, control);
-		while (e < r && (matchedMask == _screen->isFillMatch(e + 1, p.y, screenMask, searchColor, searchPriority, searchControl)))
+		while (e < r && (matchedMask = _screen->isFillMatch(e + 1, p.y, matchMask, searchColor, searchPriority, searchControl)))
 			_screen->putPixel(++e, p.y, screenMask, color, priority, control);
 		// checking lines above and below for possible flood targets
 		a_set = b_set = 0;
 		while (w <= e) {
-			if (p.y > t && (matchedMask == _screen->isFillMatch(w, p.y - 1, screenMask, searchColor, searchPriority, searchControl))) { // one line above
+			if (p.y > t && (matchedMask = _screen->isFillMatch(w, p.y - 1, matchMask, searchColor, searchPriority, searchControl))) { // one line above
 				if (a_set == 0) {
 					p1.x = w;
 					p1.y = p.y - 1;
@@ -652,7 +664,7 @@
 			} else
 				a_set = 0;
 
-			if (p.y < b && (matchedMask == _screen->isFillMatch(w, p.y + 1, screenMask, searchColor, searchPriority, searchControl))) { // one line below
+			if (p.y < b && (matchedMask = _screen->isFillMatch(w, p.y + 1, matchMask, searchColor, searchPriority, searchControl))) { // one line below
 				if (b_set == 0) {
 					p1.x = w;
 					p1.y = p.y + 1;


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