aboutsummaryrefslogtreecommitdiff
path: root/scumm
diff options
context:
space:
mode:
authorTravis Howell2005-03-06 00:46:13 +0000
committerTravis Howell2005-03-06 00:46:13 +0000
commit81262457d3819ed44d5bbe7ec1506eb526a323c7 (patch)
treeb47b855770344ae2acd840c5af4e118e83e85809 /scumm
parent88498dc62248179e1aa73cb3bf1984e7925f0afe (diff)
downloadscummvm-rg350-81262457d3819ed44d5bbe7ec1506eb526a323c7.tar.gz
scummvm-rg350-81262457d3819ed44d5bbe7ec1506eb526a323c7.tar.bz2
scummvm-rg350-81262457d3819ed44d5bbe7ec1506eb526a323c7.zip
Add extra safety checks from original games, to copyVirtScreenBuffers()
svn-id: r16993
Diffstat (limited to 'scumm')
-rw-r--r--scumm/gfx.cpp29
-rw-r--r--scumm/gfx.h2
2 files changed, 28 insertions, 3 deletions
diff --git a/scumm/gfx.cpp b/scumm/gfx.cpp
index 790faffce2..dec67688c5 100644
--- a/scumm/gfx.cpp
+++ b/scumm/gfx.cpp
@@ -1569,11 +1569,36 @@ void Gdi::drawBMAPObject(const byte *ptr, VirtScreen *vs, int obj, int x, int y,
}
}
-void Gdi::copyVirtScreenBuffers(const Common::Rect &rect) {
+void Gdi::copyVirtScreenBuffers(Common::Rect rect) {
+ byte *src, *dst;
+ VirtScreen *vs = &_vm->virtscr[0];
+
+ debug(1,"copyVirtScreenBuffers: Left %d Right %d Top %d Bottom %d", rect.left, rect.right, rect.top, rect.bottom);
+
+ if (rect.top > vs->h || rect.bottom < 0)
+ return;
+
+ if (rect.left > vs->w || rect.right < 0)
+ return;
+
+ rect.left = MAX(0, (int)rect.left);
+ rect.left = MIN((int)rect.left, (int)vs->w - 1);
+
+ rect.right = MAX(0, (int)rect.right);
+ rect.right = MIN((int)rect.right, (int)vs->w);
+
+ rect.top = MAX(0, (int)rect.top);
+ rect.top = MIN((int)rect.top, (int)vs->h - 1);
+
+ rect.bottom = MAX(0, (int)rect.bottom);
+ rect.bottom = MIN((int)rect.bottom, (int)vs->h);
+
const int rw = rect.width();
const int rh = rect.height();
- byte *src, *dst;
+ if (rw == 0 || rh == 0)
+ return;
+
src = _vm->virtscr[0].getBackPixels(rect.left, rect.top);
dst = _vm->virtscr[0].getPixels(rect.left, rect.top);
diff --git a/scumm/gfx.h b/scumm/gfx.h
index 6bac0b54fa..a715d94651 100644
--- a/scumm/gfx.h
+++ b/scumm/gfx.h
@@ -279,7 +279,7 @@ public:
void drawBMAPBg(const byte *ptr, VirtScreen *vs, int startstrip);
void drawBMAPObject(const byte *ptr, VirtScreen *vs, int obj, int x, int y, int w, int h);
- void copyVirtScreenBuffers(const Common::Rect &rect);
+ void copyVirtScreenBuffers(Common::Rect rect);
void disableZBuffer() { _zbufferDisabled = true; }
void enableZBuffer() { _zbufferDisabled = false; }