From 93e1a2a9e5f379945a6efb24598319b605be1dfa Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Fri, 9 Jul 2010 21:03:36 -0600 Subject: Fix tileset gid handling to better match Tiled This change allows extending tilesets without causing issues. Reviewed-by: Freeyorp --- src/map.cpp | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) (limited to 'src/map.cpp') 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) -- cgit v1.2.3-70-g09d2