diff options
author | Max Horn | 2004-09-24 22:31:42 +0000 |
---|---|---|
committer | Max Horn | 2004-09-24 22:31:42 +0000 |
commit | 6749efe84c65434bcbf54fa7130fb072a4e22fb0 (patch) | |
tree | 02abe42b1d51442187d8908f029a8a097df7c68d | |
parent | bad5721c63e2e8c494e30f69fc529b4e54617f35 (diff) | |
download | scummvm-rg350-6749efe84c65434bcbf54fa7130fb072a4e22fb0.tar.gz scummvm-rg350-6749efe84c65434bcbf54fa7130fb072a4e22fb0.tar.bz2 scummvm-rg350-6749efe84c65434bcbf54fa7130fb072a4e22fb0.zip |
Avoid out-of-bounds access in V7_SMOOTH_SCROLLING_HACK mode
svn-id: r15258
-rw-r--r-- | scumm/gfx.cpp | 18 | ||||
-rw-r--r-- | scumm/gfx.h | 1 | ||||
-rw-r--r-- | scumm/scumm.h | 3 |
3 files changed, 10 insertions, 12 deletions
diff --git a/scumm/gfx.cpp b/scumm/gfx.cpp index 1d0df670c7..5ee02201b1 100644 --- a/scumm/gfx.cpp +++ b/scumm/gfx.cpp @@ -232,18 +232,13 @@ void Gdi::init() { _numStrips = _vm->_screenWidth / 8; #ifdef V7_SMOOTH_SCROLLING_HACK - if (_vm->_version >= 7) - _numStrips += 1; - // TODO: Just increasing _numStrips isn't sufficient, and will cause - // problems in some cases. For example in In rooms which are *exactly* of - // width equal to _screenWidth, we now may cause an out-of-bounds access. - // One possible soution might be to replace _numStrips by a method - // Gdi::getNumStrips() which then returns the proper value, computed - // dynamically. + if (_vm->_version >= 7) { + //if (_vm->_screenWidth < _vm->virtscr[0].w) + _numStrips += 1; + } #endif } - void ScummEngine::initVirtScreen(VirtScreenNumber slot, int number, int top, int width, int height, bool twobufs, bool scrollable) { VirtScreen *vs = &virtscr[slot]; @@ -267,8 +262,9 @@ void ScummEngine::initVirtScreen(VirtScreenNumber slot, int number, int top, int vs->bytesPerPixel = 1; vs->pitch = width; #ifdef V7_SMOOTH_SCROLLING_HACK - if (_version >= 7) + if (_version >= 7) { vs->pitch += 8; + } #endif size = vs->pitch * vs->h; @@ -1212,7 +1208,7 @@ void Gdi::drawBitmap(const byte *ptr, VirtScreen *vs, int x, int y, const int wi sx = 0; } - while (numstrip && sx < _numStrips) { + while (numstrip && sx < _numStrips && x * 8 < _vm->_roomWidth) { CHECK_HEAP; if (y < vs->tdirty[sx]) diff --git a/scumm/gfx.h b/scumm/gfx.h index be9fec580b..8ae09d136b 100644 --- a/scumm/gfx.h +++ b/scumm/gfx.h @@ -272,7 +272,6 @@ protected: public: void init(); - void updateNumStrips(); void drawBitmap(const byte *ptr, VirtScreen *vs, int x, int y, const int width, const int height, int stripnr, int numstrip, byte flag, StripTable *table = 0); diff --git a/scumm/scumm.h b/scumm/scumm.h index b0ca63b037..d1ae4d498c 100644 --- a/scumm/scumm.h +++ b/scumm/scumm.h @@ -900,6 +900,9 @@ public: protected: /* Should be in Graphics class? */ uint16 _screenB, _screenH; +#ifdef V7_SMOOTH_SCROLLING_HACK +public: // HACK HACK HACK +#endif int _roomHeight, _roomWidth; public: int _screenHeight, _screenWidth; |