From 5bec0cbb9d9b2d29e7ffab4d1c0a0db803960754 Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Thu, 7 May 2015 00:29:34 +0200 Subject: GOB: Make coordinate parameters in Surface::fillRect() signed And clip to [0, width), [0, height) before drawing. This fixes bug #6864, which is a regression I introduced in 51fd528fe56e00466255d54e1e71b19f34729bfd when I changed all the drawing code to use the Surface class. I thought that having unsigned coordinates makes sense, but for some reason, Fascination sets _destSpriteX (which maps to left in fillRect()) to -1, expecting the drawing code to clip. --- engines/gob/surface.cpp | 7 ++++++- engines/gob/surface.h | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/gob/surface.cpp b/engines/gob/surface.cpp index 42ac2b0d74..ed83e8255c 100644 --- a/engines/gob/surface.cpp +++ b/engines/gob/surface.cpp @@ -470,7 +470,7 @@ void Surface::blitScaled(const Surface &from, Common::Rational scale, int32 tran blitScaled(from, 0, 0, from._width - 1, from._height - 1, 0, 0, scale, transp); } -void Surface::fillRect(uint16 left, uint16 top, uint16 right, uint16 bottom, uint32 color) { +void Surface::fillRect(int16 left, int16 top, int16 right, int16 bottom, uint32 color) { // Just in case those are swapped if (left > right) SWAP(left, right); @@ -481,6 +481,11 @@ void Surface::fillRect(uint16 left, uint16 top, uint16 right, uint16 bottom, uin // Nothing to do return; + left = CLIP(left , 0, _width - 1); + top = CLIP(top , 0, _height - 1); + right = CLIP(right , 0, _width - 1); + bottom = CLIP(bottom, 0, _height - 1); + // Area to actually fill uint16 width = CLIP(right - left + 1, 0, _width - left); uint16 height = CLIP(bottom - top + 1, 0, _height - top); diff --git a/engines/gob/surface.h b/engines/gob/surface.h index c931731908..eb0a5bf1a4 100644 --- a/engines/gob/surface.h +++ b/engines/gob/surface.h @@ -121,7 +121,7 @@ public: void blitScaled(const Surface &from, int16 x, int16 y, Common::Rational scale, int32 transp = -1); void blitScaled(const Surface &from, Common::Rational scale, int32 transp = -1); - void fillRect(uint16 left, uint16 top, uint16 right, uint16 bottom, uint32 color); + void fillRect(int16 left, int16 top, int16 right, int16 bottom, uint32 color); void fill(uint32 color); void clear(); -- cgit v1.2.3