aboutsummaryrefslogtreecommitdiff
path: root/engines/neverhood
diff options
context:
space:
mode:
authorjohndoe1232014-06-26 19:16:44 +0200
committerjohndoe1232014-06-26 19:19:28 +0200
commitbdee71f27922d1ba146323374e4501ec462d687d (patch)
tree68802cb9a11dba7bef0500deb2851b5568b17a28 /engines/neverhood
parentd6ec21d4d0e65ae6877c2977438698c200871561 (diff)
downloadscummvm-rg350-bdee71f27922d1ba146323374e4501ec462d687d.tar.gz
scummvm-rg350-bdee71f27922d1ba146323374e4501ec462d687d.tar.bz2
scummvm-rg350-bdee71f27922d1ba146323374e4501ec462d687d.zip
NEVERHOOD: Implement clipping in BaseSurface::copyFrom
This should hopefully fix the crashes in the Hall of Records as mentioned in bug #6513.
Diffstat (limited to 'engines/neverhood')
-rw-r--r--engines/neverhood/graphics.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/engines/neverhood/graphics.cpp b/engines/neverhood/graphics.cpp
index 939428ed19..89792d2659 100644
--- a/engines/neverhood/graphics.cpp
+++ b/engines/neverhood/graphics.cpp
@@ -114,7 +114,15 @@ void BaseSurface::drawMouseCursorResource(MouseCursorResource &mouseCursorResour
}
void BaseSurface::copyFrom(Graphics::Surface *sourceSurface, int16 x, int16 y, NDrawRect &sourceRect) {
- // Copy a rectangle from sourceSurface, no clipping is performed, 0 is the transparent color
+ // Copy a rectangle from sourceSurface, 0 is the transparent color
+ // Clipping is performed against the right/bottom border since x, y will always be >= 0
+
+ if (x + sourceRect.width > _surface->w)
+ sourceRect.width = _surface->w - x - 1;
+
+ if (y + sourceRect.height > _surface->h)
+ sourceRect.height = _surface->h - y - 1;
+
byte *source = (byte*)sourceSurface->getBasePtr(sourceRect.x, sourceRect.y);
byte *dest = (byte*)_surface->getBasePtr(x, y);
int height = sourceRect.height;