From 75de17c7a86060f1c9475350c2e1bc7a712cd6b8 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 3 Jan 2017 22:39:53 +0300 Subject: Fix special layers draw crash. --- src/resources/map/maplayer.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/resources') diff --git a/src/resources/map/maplayer.cpp b/src/resources/map/maplayer.cpp index 6557e07a6..d92184e28 100644 --- a/src/resources/map/maplayer.cpp +++ b/src/resources/map/maplayer.cpp @@ -400,11 +400,11 @@ void MapLayer::drawSpecialLayer(Graphics *const graphics, const int scrollX, const int scrollY) const restrict { - const int specialWidth = mSpecialLayer->mWidth; const int y32 = y * mapTileSize; - const int ptr = y * specialWidth; const int py1 = y32 - scrollY; int endX1 = endX; + int specialWidth = mSpecialLayer->mWidth; + int ptr = y * specialWidth; if (endX1 > specialWidth) endX1 = specialWidth; if (endX1 < 0) @@ -427,6 +427,11 @@ void MapLayer::drawSpecialLayer(Graphics *const graphics, x += mSpecialLayer->mCache[ptr + x]; } + specialWidth = mTempLayer->mWidth; + ptr = y * specialWidth; + endX1 = endX; + if (endX1 > specialWidth) + endX1 = specialWidth; item0 = mTempLayer->mTiles[ptr + startX]; if (!item0 || item0->mType == MapItemType::EMPTY) { @@ -441,7 +446,7 @@ void MapLayer::drawSpecialLayer(Graphics *const graphics, item->draw(graphics, px1, py1, mapTileSize, mapTileSize); } - x += mSpecialLayer->mCache[ptr + x]; + x += mTempLayer->mCache[ptr + x]; } } -- cgit v1.2.3-70-g09d2