aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/cruise/backgroundIncrust.cpp6
-rw-r--r--engines/cruise/backgroundIncrust.h4
2 files changed, 7 insertions, 3 deletions
diff --git a/engines/cruise/backgroundIncrust.cpp b/engines/cruise/backgroundIncrust.cpp
index 8d4bb70128..776aa6305d 100644
--- a/engines/cruise/backgroundIncrust.cpp
+++ b/engines/cruise/backgroundIncrust.cpp
@@ -52,7 +52,11 @@ void backupBackground(backgroundIncrustStruct *pIncrust, int X, int Y, int width
pIncrust->ptr = (uint8*)malloc(width * height);
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
- pIncrust->ptr[i * width + j] = pBackground[(i+Y) * 320 + j + X];
+ int xp = j + X;
+ int yp = i + Y;
+
+ pIncrust->ptr[i * width + j] = ((xp < 0) || (yp < 0) || (xp >= 320) || (yp >= 200)) ?
+ 0 : pBackground[yp * 320 + xp];
}
}
}
diff --git a/engines/cruise/backgroundIncrust.h b/engines/cruise/backgroundIncrust.h
index 81b53815d9..92db79cf13 100644
--- a/engines/cruise/backgroundIncrust.h
+++ b/engines/cruise/backgroundIncrust.h
@@ -35,8 +35,8 @@ struct backgroundIncrustStruct {
uint16 objectIdx;
int16 type;
uint16 overlayIdx;
- uint16 X;
- uint16 Y;
+ int16 X;
+ int16 Y;
uint16 field_E;
uint16 scale;
uint16 backgroundIdx;