aboutsummaryrefslogtreecommitdiff
path: root/engines/kyra
diff options
context:
space:
mode:
authorJohannes Schickel2006-10-23 23:12:12 +0000
committerJohannes Schickel2006-10-23 23:12:12 +0000
commit8fb07286cc5a6aaa508bcff5e8c91791e7303704 (patch)
treed64bc47da208846d29ed31110ef620a55efa2731 /engines/kyra
parent67041f96a905c27e2f744cc88dfb57e12f93d6af (diff)
downloadscummvm-rg350-8fb07286cc5a6aaa508bcff5e8c91791e7303704.tar.gz
scummvm-rg350-8fb07286cc5a6aaa508bcff5e8c91791e7303704.tar.bz2
scummvm-rg350-8fb07286cc5a6aaa508bcff5e8c91791e7303704.zip
Fix for bug #1582726 ("KYRA1: Crash when entering Castle screen").
svn-id: r24475
Diffstat (limited to 'engines/kyra')
-rw-r--r--engines/kyra/animator.cpp21
-rw-r--r--engines/kyra/screen.cpp10
2 files changed, 21 insertions, 10 deletions
diff --git a/engines/kyra/animator.cpp b/engines/kyra/animator.cpp
index a11e56d65e..8d28bcc934 100644
--- a/engines/kyra/animator.cpp
+++ b/engines/kyra/animator.cpp
@@ -389,9 +389,8 @@ void ScreenAnimator::prepDrawAllObjects() {
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,14 +401,22 @@ void ScreenAnimator::copyChangedObjectsForward(int refreshFlag) {
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);
@@ -417,8 +424,8 @@ void ScreenAnimator::copyChangedObjectsForward(int refreshFlag) {
_updateScreen = true;
}
}
- curObject = curObject->nextAnimObject;
}
+
if (_updateScreen) {
_screen->updateScreen();
_updateScreen = false;
diff --git a/engines/kyra/screen.cpp b/engines/kyra/screen.cpp
index c36e8366c5..ebfcb63351 100644
--- a/engines/kyra/screen.cpp
+++ b/engines/kyra/screen.cpp
@@ -2340,15 +2340,19 @@ void Screen::addDirtyRect(int x, int y, int w, int h) {
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;