summaryrefslogtreecommitdiff
path: root/src/map.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-04-30 20:25:52 +0300
committerAndrei Karas <akaras@inbox.ru>2011-04-30 20:26:14 +0300
commit761af2264f8e85ac3cacde047b9bb5700487eae6 (patch)
treef446d951dccb986f734d799f05fed836b38c8bd9 /src/map.cpp
parent2032f0bab7b603f536996079d658c653b5e4e6c6 (diff)
downloadmv-761af2264f8e85ac3cacde047b9bb5700487eae6.tar.gz
mv-761af2264f8e85ac3cacde047b9bb5700487eae6.tar.bz2
mv-761af2264f8e85ac3cacde047b9bb5700487eae6.tar.xz
mv-761af2264f8e85ac3cacde047b9bb5700487eae6.zip
Fix overlaped tiles indexes issue.
Diffstat (limited to 'src/map.cpp')
-rw-r--r--src/map.cpp24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/map.cpp b/src/map.cpp
index f79539567..8d2031019 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -1486,25 +1486,39 @@ void Map::indexTilesets()
it_end = mTilesets.end(); it < it_end;
++it)
{
- if (!s || s->getFirstGid() < (*it)->getFirstGid())
+ if (!s || s->getFirstGid() + s->size()
+ < (*it)->getFirstGid() + (*it)->size())
+ {
s = *it;
+ }
}
if (!s)
+ {
+ mIndexedTilesetsSize = 0;
+ mIndexedTilesets = 0;
return;
+ }
const int size = s->getFirstGid() + s->size();
mIndexedTilesetsSize = size;
mIndexedTilesets = new Tileset*[size];
std::fill_n(mIndexedTilesets, size, static_cast<Tileset*>(0));
+
for (Tilesets::const_iterator it = mTilesets.begin(),
it_end = mTilesets.end(); it < it_end;
++it)
{
s = *it;
- const int start = s->getFirstGid();
- const int end = start + s->size();
- for (int f = start; f < end; f ++)
- mIndexedTilesets[f] = s;
+ if (s)
+ {
+ const int start = s->getFirstGid();
+ const int end = start + s->size();
+ for (int f = start; f < end; f ++)
+ {
+ if (f < size)
+ mIndexedTilesets[f] = s;
+ }
+ }
}
}