summaryrefslogtreecommitdiff
path: root/src/map.cpp
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2010-07-09 21:03:36 -0600
committerJared Adams <jaxad0127@gmail.com>2010-07-09 21:03:36 -0600
commit93e1a2a9e5f379945a6efb24598319b605be1dfa (patch)
tree89cfde43f80531a612d636bd3cd231ab5140c7eb /src/map.cpp
parent2315dee9135c42223757021ea8b1e3094936cb7c (diff)
downloadmana-93e1a2a9e5f379945a6efb24598319b605be1dfa.tar.gz
mana-93e1a2a9e5f379945a6efb24598319b605be1dfa.tar.bz2
mana-93e1a2a9e5f379945a6efb24598319b605be1dfa.tar.xz
mana-93e1a2a9e5f379945a6efb24598319b605be1dfa.zip
Fix tileset gid handling to better match Tiled
This change allows extending tilesets without causing issues. Reviewed-by: Freeyorp
Diffstat (limited to 'src/map.cpp')
-rw-r--r--src/map.cpp22
1 files changed, 6 insertions, 16 deletions
diff --git a/src/map.cpp b/src/map.cpp
index 52459415..f1f8d091 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -474,25 +474,15 @@ void Map::drawAmbientLayers(Graphics *graphics, LayerType type,
}
}
-class ContainsGidFunctor
-{
- public:
- bool operator() (const Tileset *set) const
- {
- return (set->getFirstGid() <= gid &&
- gid - set->getFirstGid() < (int)set->size());
- }
- int gid;
-} containsGid;
-
Tileset *Map::getTilesetWithGid(int gid) const
{
- containsGid.gid = gid;
-
- Tilesets::const_iterator i = find_if(mTilesets.begin(), mTilesets.end(),
- containsGid);
+ Tileset *s = NULL;
+ for (Tilesets::const_iterator it = mTilesets.begin(),
+ it_end = mTilesets.end(); it < it_end && (*it)->getFirstGid() <= gid;
+ it++)
+ s = *it;
- return (i == mTilesets.end()) ? NULL : *i;
+ return s;
}
void Map::blockTile(int x, int y, BlockType type)