From 8be1ff109f21e061259af397480624b251ed7fab Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Mon, 7 Mar 2016 23:39:39 +0100 Subject: [PATCH] SCI32: Fix adding too many items to drawlist --- engines/sci/graphics/plane32.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/engines/sci/graphics/plane32.cpp b/engines/sci/graphics/plane32.cpp index 6961a9ac1a1e..09d8dc0b96b3 100644 --- a/engines/sci/graphics/plane32.cpp +++ b/engines/sci/graphics/plane32.cpp @@ -382,6 +382,10 @@ void Plane::calcLists(Plane &visiblePlane, const PlaneList &planeList, DrawList breakEraseListByPlanes(eraseList, planeList); breakDrawListByPlanes(drawList, planeList); + // We store the current size of the drawlist, as we want to loop + // over the currently inserted entries later. + DrawList::size_type drawListSizePrimary = drawList.size(); + // NOTE: Setting this to true fixes the menu bars in GK1 if (/* TODO: dword_C6288 */ false) { // "high resolution pictures"???? _screenItemList.sort(); @@ -437,8 +441,12 @@ void Plane::calcLists(Plane &visiblePlane, const PlaneList &planeList, DrawList } if (/* TODO: g_Remap_numActiveRemaps == 0 */ true) { // no remaps active? // Add all items that overlap with items in the drawlist and have higher - // priority - for (DrawList::size_type i = 0; i < drawList.size(); ++i) { + // priority. + + // We only loop over "primary" items in the draw list, skipping + // those that were added because of the erase list in the previous loop, + // or those to be added in this loop. + for (DrawList::size_type i = 0; i < drawListSizePrimary; ++i) { DrawItem *dli = drawList[i]; for (PlaneList::size_type j = 0; j < planeItemCount; ++j) {