diff options
author | Paul Gilbert | 2009-05-15 04:54:45 +0000 |
---|---|---|
committer | Paul Gilbert | 2009-05-15 04:54:45 +0000 |
commit | b7af9831da9d460509aafdac58b9ff6c927744f3 (patch) | |
tree | 38e153fc5f2917509a06d4f7cf694b1052fd7674 /engines/cruise | |
parent | bb45be960d1762a480ec3523d97955754c7ce9f2 (diff) | |
download | scummvm-rg350-b7af9831da9d460509aafdac58b9ff6c927744f3.tar.gz scummvm-rg350-b7af9831da9d460509aafdac58b9ff6c927744f3.tar.bz2 scummvm-rg350-b7af9831da9d460509aafdac58b9ff6c927744f3.zip |
Fixes for the backupBackground method when X < 0
svn-id: r40590
Diffstat (limited to 'engines/cruise')
-rw-r--r-- | engines/cruise/backgroundIncrust.cpp | 6 | ||||
-rw-r--r-- | engines/cruise/backgroundIncrust.h | 4 |
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; |