summaryrefslogtreecommitdiff
path: root/src/resources/map/maplayer.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-12-30 17:08:56 +0300
committerAndrei Karas <akaras@inbox.ru>2016-12-30 17:30:05 +0300
commit728223b59f09d1460a092b5fd467c3191fcb46c9 (patch)
tree489c994a98acddb29d8c1f891a27f50bbd552d2e /src/resources/map/maplayer.cpp
parent0c06037af71273481958ba8587bbb4082d1ed822 (diff)
downloadmv-728223b59f09d1460a092b5fd467c3191fcb46c9.tar.gz
mv-728223b59f09d1460a092b5fd467c3191fcb46c9.tar.bz2
mv-728223b59f09d1460a092b5fd467c3191fcb46c9.tar.xz
mv-728223b59f09d1460a092b5fd467c3191fcb46c9.zip
Improve drawing map layers.
Pre cache repeated tiles count and width.
Diffstat (limited to 'src/resources/map/maplayer.cpp')
-rw-r--r--src/resources/map/maplayer.cpp49
1 files changed, 31 insertions, 18 deletions
diff --git a/src/resources/map/maplayer.cpp b/src/resources/map/maplayer.cpp
index 84ee5d63b..58d8a3a08 100644
--- a/src/resources/map/maplayer.cpp
+++ b/src/resources/map/maplayer.cpp
@@ -150,18 +150,20 @@ void MapLayer::draw(Graphics *const graphics,
if (mSpecialFlag ||
img->mBounds.h <= mapTileSize)
{
- int width = 0;
// here need not draw over player position
- c = getTileDrawWidth(tilePtr, endX - x, width);
+ c = tilePtr->count;
- if (!c)
+ if (c == 0)
{
graphics->drawImage(img, px, py);
}
else
{
- graphics->drawPattern(img, px, py,
- width, img->mBounds.h);
+ graphics->drawPattern(img,
+ px,
+ py,
+ tilePtr->width,
+ img->mBounds.h);
}
}
@@ -513,18 +515,20 @@ void MapLayer::drawFringe(Graphics *const graphics,
{
const int px = x32 + dx;
const int py = py0 - img->mBounds.h;
- int width = 0;
// here need not draw over player position
- c = getTileDrawWidth(tilePtr, endX - x, width);
+ c = tilePtr->count;
- if (!c)
+ if (c == 0)
{
graphics->drawImage(img, px, py);
}
else
{
- graphics->drawPattern(img, px, py,
- width, img->mBounds.h);
+ graphics->drawPattern(img,
+ px,
+ py,
+ tilePtr->width,
+ img->mBounds.h);
}
}
}
@@ -598,20 +602,19 @@ void MapLayer::drawFringe(Graphics *const graphics,
if (mSpecialFlag ||
img->mBounds.h <= mapTileSize)
{
- int width = 0;
- // here need not draw over player position
- const int c = getTileDrawWidth(tilePtr,
- endX - x,
- width);
+ const int c = tilePtr->count;
- if (!c)
+ if (c == 0)
{
graphics->drawImage(img, px, py);
}
else
{
- graphics->drawPattern(img, px, py,
- width, img->mBounds.h);
+ graphics->drawPattern(img,
+ px,
+ py,
+ tilePtr->width,
+ img->mBounds.h);
x += c;
tilePtr += c;
}
@@ -740,7 +743,17 @@ void MapLayer::updateCache(const int width,
for (int x = mX; x < width1; x ++, tilePtr ++)
{
if (tilePtr->image == nullptr)
+ {
tilePtr->isEnabled = false;
+ }
+ else
+ {
+ int tileWidth = 0;
+ tilePtr->count = getTileDrawWidth(tilePtr,
+ width1 - x,
+ tileWidth);
+ tilePtr->width = tileWidth;
+ }
}
}
}