summaryrefslogtreecommitdiff
path: root/src/resources/map/maplayer.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-10-11 20:05:29 +0300
committerAndrei Karas <akaras@inbox.ru>2015-10-11 20:05:29 +0300
commit2c302cc6cb54881fbe354cc9d5a9997788f63e56 (patch)
tree9cef7d73dca25c523038ddb2ce13d49349596b27 /src/resources/map/maplayer.cpp
parent3bbfd3d36990113d7e91724625f4a347412dd883 (diff)
downloadplus-2c302cc6cb54881fbe354cc9d5a9997788f63e56.tar.gz
plus-2c302cc6cb54881fbe354cc9d5a9997788f63e56.tar.bz2
plus-2c302cc6cb54881fbe354cc9d5a9997788f63e56.tar.xz
plus-2c302cc6cb54881fbe354cc9d5a9997788f63e56.zip
Add structure for tile object.
Now it contains only image pointer.
Diffstat (limited to 'src/resources/map/maplayer.cpp')
-rw-r--r--src/resources/map/maplayer.cpp31
1 files changed, 17 insertions, 14 deletions
diff --git a/src/resources/map/maplayer.cpp b/src/resources/map/maplayer.cpp
index 97c2ba5f1..51691925b 100644
--- a/src/resources/map/maplayer.cpp
+++ b/src/resources/map/maplayer.cpp
@@ -52,7 +52,7 @@ MapLayer::MapLayer(const int x, const int y,
mY(y),
mWidth(width),
mHeight(height),
- mTiles(new Image*[mWidth * mHeight]),
+ mTiles(new TileInfo[mWidth * mHeight]),
mDrawLayerFlags(MapType::NORMAL),
mSpecialLayer(nullptr),
mTempLayer(nullptr),
@@ -63,7 +63,7 @@ MapLayer::MapLayer(const int x, const int y,
mHighlightAttackRange(config.getBoolValue("highlightAttackRange")),
mSpecialFlag(true)
{
- std::fill_n(mTiles, mWidth * mHeight, static_cast<Image*>(nullptr));
+// std::fill_n(mTiles, mWidth * mHeight, static_cast<Image*>(nullptr));
config.addListener("highlightAttackRange", this);
}
@@ -72,7 +72,10 @@ MapLayer::~MapLayer()
{
config.removeListener("highlightAttackRange", this);
CHECKLISTENERS
- delete [] mTiles;
+// const int sz = mWidth * mHeight;
+// for (int f = 0; f < sz; f ++)
+// delete mTiles[f].image;
+ delete []mTiles;
delete_all(mTempRows);
mTempRows.clear();
}
@@ -88,7 +91,7 @@ void MapLayer::optionChanged(const std::string &value)
void MapLayer::setTile(const int x, const int y, Image *const img)
{
- mTiles[x + y * mWidth] = img;
+ mTiles[x + y * mWidth].image = img;
}
void MapLayer::draw(Graphics *const graphics,
@@ -123,14 +126,14 @@ void MapLayer::draw(Graphics *const graphics,
const int py0 = y32 + dy;
- Image **tilePtr = mTiles + static_cast<size_t>(startX + yWidth);
+ TileInfo *tilePtr = &mTiles[static_cast<size_t>(startX + yWidth)];
for (int x = startX; x < endX; x++, tilePtr++)
{
const int x32 = x * mapTileSize;
int c = 0;
- const Image *const img = *tilePtr;
+ const Image *const img = (*tilePtr).image;
if (img)
{
const int px = x32 + dx;
@@ -216,11 +219,11 @@ void MapLayer::updateSDL(const Graphics *const graphics,
const int yWidth = y * mWidth;
const int py0 = y * mapTileSize + dy;
- Image **tilePtr = mTiles + static_cast<size_t>(startX + yWidth);
+ TileInfo *tilePtr = &mTiles[static_cast<size_t>(startX + yWidth)];
for (int x = startX; x < endX; x++, tilePtr++)
{
- Image *const img = *tilePtr;
+ Image *const img = (*tilePtr).image;
if (img)
{
const int px = x * mapTileSize + dx;
@@ -279,10 +282,10 @@ void MapLayer::updateOGL(Graphics *const graphics,
{
const int yWidth = y * mWidth;
const int py0 = y * mapTileSize + dy;
- Image **tilePtr = mTiles + static_cast<size_t>(startX + yWidth);
+ TileInfo *tilePtr = &mTiles[static_cast<size_t>(startX + yWidth)];
for (int x = startX; x < endX; x++, tilePtr++)
{
- Image *const img = *tilePtr;
+ Image *const img = (*tilePtr).image;
if (img)
{
const int px = x * mapTileSize + dx;
@@ -480,14 +483,14 @@ void MapLayer::drawFringe(Graphics *const graphics,
const int py0 = y32 + dy;
const int py1 = y32 - scrollY;
- Image **tilePtr = mTiles + static_cast<size_t>(startX + yWidth);
+ TileInfo *tilePtr = &mTiles[static_cast<size_t>(startX + yWidth)];
for (int x = startX; x < endX; x++, tilePtr++)
{
const int x32 = x * mapTileSize;
const int px1 = x32 - scrollX;
int c = 0;
- const Image *const img = *tilePtr;
+ const Image *const img = (*tilePtr).image;
if (img)
{
if (mSpecialFlag || img->mBounds.h <= mapTileSize)
@@ -565,11 +568,11 @@ void MapLayer::drawFringe(Graphics *const graphics,
const int py0 = y32 + dy;
- Image **tilePtr = mTiles + static_cast<size_t>(startX + yWidth);
+ TileInfo *tilePtr = &mTiles[static_cast<size_t>(startX + yWidth)];
for (int x = startX; x < endX; x++, tilePtr++)
{
const int x32 = x * mapTileSize;
- const Image *const img = *tilePtr;
+ const Image *const img = (*tilePtr).image;
if (img)
{
const int px = x32 + dx;