From ccd5ad5162652dd3bcc06136ed1917b9f0f0b2ac Mon Sep 17 00:00:00 2001 From: Borja Lorente Date: Fri, 19 Aug 2016 15:09:07 +0200 Subject: [PATCH] MACVENTURE: Fix double overflow when blitting --- engines/macventure/image.cpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/engines/macventure/image.cpp b/engines/macventure/image.cpp index aeb5a501a85..172121af0b3 100644 --- a/engines/macventure/image.cpp +++ b/engines/macventure/image.cpp @@ -530,27 +530,24 @@ void ImageAsset::calculateSectionToDraw(Graphics::ManagedSurface *target, int &o } void ImageAsset::calculateSectionInDirection(uint targetWhole, uint originWhole, int &originPosition, uint &startPosition, uint &blittedWhole) { + startPosition = 0; blittedWhole = originWhole; - if (originPosition + blittedWhole > targetWhole) { - if (originPosition > (int)targetWhole) { - blittedWhole = 0; - } else { - blittedWhole = (blittedWhole) - ((blittedWhole + originPosition) - targetWhole); - } - } if (originPosition < 0) { if (ABS(originPosition) > (int)blittedWhole) { blittedWhole = 0; } else { blittedWhole -= -originPosition; } - } - - startPosition = 0; - if (originPosition < 0) { startPosition = -originPosition; originPosition = 0; } + if (originPosition + blittedWhole > targetWhole) { + if (originPosition > (int)targetWhole) { + blittedWhole = 0; + } else { + blittedWhole = targetWhole - originPosition; + } + } } } // End of namespace MacVenture