diff options
| author | Willem Jan Palenstijn | 2016-02-20 12:26:54 +0100 |
|---|---|---|
| committer | Willem Jan Palenstijn | 2016-02-20 12:26:54 +0100 |
| commit | 53ed7f6ac171b0a6478763121873692b535ec798 (patch) | |
| tree | 1d07c25769906cbc5e77f24433de84583e68639e /engines/sci/graphics | |
| parent | 19283b94a975d778f4882dedabe07be68cf1822e (diff) | |
| download | scummvm-rg350-53ed7f6ac171b0a6478763121873692b535ec798.tar.gz scummvm-rg350-53ed7f6ac171b0a6478763121873692b535ec798.tar.bz2 scummvm-rg350-53ed7f6ac171b0a6478763121873692b535ec798.zip | |
SCI: Rewrite Plane::mergeToRectList
The old one would continue reading from outerRect after it was deleted.
Diffstat (limited to 'engines/sci/graphics')
| -rw-r--r-- | engines/sci/graphics/plane32.cpp | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/engines/sci/graphics/plane32.cpp b/engines/sci/graphics/plane32.cpp index 0ab9ea4bae..40cb56522f 100644 --- a/engines/sci/graphics/plane32.cpp +++ b/engines/sci/graphics/plane32.cpp @@ -629,18 +629,26 @@ void Plane::mergeToRectList(const Common::Rect &rect, RectList &rectList) const temp.add(rect); for (RectList::size_type i = 0; i < temp.size(); ++i) { - Common::Rect *outerRect = temp[i]; + Common::Rect r = *temp[i]; + for (RectList::size_type j = 0; j < rectList.size(); ++j) { - Common::Rect *innerRect = rectList[i]; - if (innerRect->intersects(*outerRect)) { - Common::Rect out[4]; - int count = splitRects(*outerRect, *innerRect, out); + Common::Rect *innerRect = rectList[j]; + if (innerRect->contains(r)) { + temp.erase_at(i); + break; + } + + Common::Rect out[4]; + int count = splitRects(r, *innerRect, out); + if (count != -1) { for (int k = count - 1; k >= 0; --k) { temp.add(out[k]); } + temp.erase_at(i); - } else { - temp.erase_at(i); + + // proceed to the next rect + r = *temp[++i]; } } } |
