[Scummvm-cvs-logs] SF.net SVN: scummvm: [24475] scummvm/trunk/engines/kyra

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Tue Oct 24 01:12:20 CEST 2006


Revision: 24475
          http://svn.sourceforge.net/scummvm/?rev=24475&view=rev
Author:   lordhoto
Date:     2006-10-23 16:12:12 -0700 (Mon, 23 Oct 2006)

Log Message:
-----------
Fix for bug #1582726 ("KYRA1: Crash when entering Castle screen").

Modified Paths:
--------------
    scummvm/trunk/engines/kyra/animator.cpp
    scummvm/trunk/engines/kyra/screen.cpp

Modified: scummvm/trunk/engines/kyra/animator.cpp
===================================================================
--- scummvm/trunk/engines/kyra/animator.cpp	2006-10-23 13:42:50 UTC (rev 24474)
+++ scummvm/trunk/engines/kyra/animator.cpp	2006-10-23 23:12:12 UTC (rev 24475)
@@ -389,9 +389,8 @@
 
 void ScreenAnimator::copyChangedObjectsForward(int refreshFlag) {
 	debugC(9, kDebugLevelAnimator, "ScreenAnimator::copyChangedObjectsForward(%d)", refreshFlag);
-	AnimObject *curObject = _objectQueue;
 
-	while (curObject) {
+	for (AnimObject *curObject = _objectQueue; curObject; curObject = curObject->nextAnimObject) {
 		if (curObject->active) {
 			if (curObject->refreshFlag || refreshFlag) {
 				int xpos = 0, ypos = 0, width = 0, height = 0;
@@ -402,23 +401,31 @@
 				
 				if (xpos < 1) {
 					xpos = 1;
-				} else if (xpos + width > 39) {
-					width = width - (xpos + width - 39);
+				} else if (xpos > 39) {
+					continue;
 				}
+
+				if (xpos + width > 39) {
+					width = 39 - xpos;
+				}
 				
 				if (ypos < 8) {
 					ypos = 8;
-				} else if (ypos + height > 135) {
-					height = height - (ypos + height - 136);
+				} else if (ypos > 136) {
+					continue;
 				}
+
+				if (ypos + height > 136) {
+					height = 136 - ypos;
+				}
 				
 				_screen->copyRegion(xpos << 3, ypos, xpos << 3, ypos, width << 3, height, 2, 0, Screen::CR_CLIPPED);
 				curObject->refreshFlag = 0;
 				_updateScreen = true;
 			}
 		}
-		curObject = curObject->nextAnimObject;
 	}
+
 	if (_updateScreen) {
 		_screen->updateScreen();
 		_updateScreen = false;

Modified: scummvm/trunk/engines/kyra/screen.cpp
===================================================================
--- scummvm/trunk/engines/kyra/screen.cpp	2006-10-23 13:42:50 UTC (rev 24474)
+++ scummvm/trunk/engines/kyra/screen.cpp	2006-10-23 23:12:12 UTC (rev 24475)
@@ -2340,15 +2340,19 @@
 		return;
 	}
 	
-	if (w == 0 || h == 0)
+	if (w == 0 || h == 0 || x >= SCREEN_W || y >= SCREEN_H || x + w < 0 || y + h < 0)
 		return;
 
-	if (x < 0)
+	if (x < 0) {
+		w += x;
 		x = 0;
+	}
 	if (x + w >= 320)
 		w = 320 - x;
-	if (y < 0)
+	if (y < 0) {
+		h += y;
 		y = 0;
+	}
 	if (y + h >= 200)
 		h = 200 - y;
 	


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