diff options
-rw-r--r-- | engines/cruise/backgroundIncrust.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/engines/cruise/backgroundIncrust.cpp b/engines/cruise/backgroundIncrust.cpp index 776aa6305d..df882ca85a 100644 --- a/engines/cruise/backgroundIncrust.cpp +++ b/engines/cruise/backgroundIncrust.cpp @@ -78,7 +78,11 @@ void restoreBackground(backgroundIncrustStruct *pIncrust) { for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { - pBackground[(i+Y)* 320 + j + X] = pIncrust->ptr[i * width + j]; + int xp = j + X; + int yp = i + Y; + + if ((xp >= 0) && (yp >= 0) && (xp < 320) && (yp < 200)) + pBackground[yp * 320 + xp] = pIncrust->ptr[i * width + j]; } } } |