diff options
author | Thierry Crozat | 2017-11-05 15:47:33 +0000 |
---|---|---|
committer | Thierry Crozat | 2018-01-23 02:15:37 +0000 |
commit | 8f7dcbe4ac77da2d5c6a0d4658ee813a17369944 (patch) | |
tree | 599fad62764e7f85af6aa013aff00074931232e5 /engines/supernova | |
parent | 841e7182f28471ffda0ecd0c692649f58fd3aea8 (diff) | |
download | scummvm-rg350-8f7dcbe4ac77da2d5c6a0d4658ee813a17369944.tar.gz scummvm-rg350-8f7dcbe4ac77da2d5c6a0d4658ee813a17369944.tar.bz2 scummvm-rg350-8f7dcbe4ac77da2d5c6a0d4658ee813a17369944.zip |
SUPERNOVA: Fix crash when displaying strings larger than the screen
Diffstat (limited to 'engines/supernova')
-rw-r--r-- | engines/supernova/supernova.cpp | 23 | ||||
-rw-r--r-- | engines/supernova/supernova.h | 4 |
2 files changed, 20 insertions, 7 deletions
diff --git a/engines/supernova/supernova.cpp b/engines/supernova/supernova.cpp index 291e18d964..5bc87872c5 100644 --- a/engines/supernova/supernova.cpp +++ b/engines/supernova/supernova.cpp @@ -967,16 +967,32 @@ ScreenBufferStack::ScreenBufferStack() : _last(_buffer) { } -void ScreenBufferStack::push(int x, int y, int width, int height, int pitch) { +void ScreenBufferStack::push(int x, int y, int width, int height) { if (_last == ARRAYEND(_buffer)) return; + Graphics::Surface* screenSurface = g_system->lockScreen(); + + if (x < 0) { + width += x; + x = 0; + } + if (x + width > screenSurface->w) + width = screenSurface->w - x; + + if (y < 0) { + height += y; + y = 0; + } + if (y + height > screenSurface->h) + height = screenSurface->h - y; + _last->_pixels = new byte[width * height]; byte *pixels = _last->_pixels; - const byte *screen = static_cast<const byte *>(g_system->lockScreen()->getBasePtr(x, y)); + const byte *screen = static_cast<const byte *>(screenSurface->getBasePtr(x, y)); for (int i = 0; i < height; ++i) { Common::copy(screen, screen + width, pixels); - screen += pitch; + screen += screenSurface->pitch; pixels += width; } g_system->unlockScreen(); @@ -985,7 +1001,6 @@ void ScreenBufferStack::push(int x, int y, int width, int height, int pitch) { _last->_y = y; _last->_width = width; _last->_height = height; - _last->_pitch = pitch; ++_last; } diff --git a/engines/supernova/supernova.h b/engines/supernova/supernova.h index 16c98887b0..b3ab3f45bf 100644 --- a/engines/supernova/supernova.h +++ b/engines/supernova/supernova.h @@ -55,7 +55,6 @@ struct ScreenBuffer { , _y(0) , _width(0) , _height(0) - , _pitch(0) , _pixels(NULL) {} @@ -64,13 +63,12 @@ struct ScreenBuffer { int _y; int _width; int _height; - int _pitch; }; class ScreenBufferStack { public: ScreenBufferStack(); - void push(int x, int y, int width, int height, int pitch = 320); + void push(int x, int y, int width, int height); void restore(); private: |