diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/tmxcopy/map.cpp | 15 | ||||
-rw-r--r-- | tools/tmxcopy/map.hpp | 12 |
2 files changed, 21 insertions, 6 deletions
diff --git a/tools/tmxcopy/map.cpp b/tools/tmxcopy/map.cpp index 109d1742..9e01944c 100644 --- a/tools/tmxcopy/map.cpp +++ b/tools/tmxcopy/map.cpp @@ -392,6 +392,8 @@ bool Map::randomFill(Map* templateMap, const std::string& destLayerName, /* Now generate extra tiles. * TODO Need to configure this for desired density. For 2x1 trees, dW*dH/10 is very sparse, dW*dH/2 is dense */ srand(time(NULL)); + int patternsGenerated = 0; + int occupiedAreas = 0; for (int i = destWidth*destHeight / 10; i > 0; i--) { /* Pick a random location, with enough tiles left and down from it to @@ -429,14 +431,16 @@ bool Map::randomFill(Map* templateMap, const std::string& destLayerName, destTile.index = srcTile.index; } } + patternsGenerated++; } else { + occupiedAreas++; std::cout <<"Area occupied "<<x<<", "<<y<<std::endl; } } - std::clog<<"copying successful!"<<std::endl; + std::clog<<"Generated " << patternsGenerated << " new objects" <<std::endl; return true; } @@ -469,11 +473,14 @@ bool Map::translateAllLayers(Map* templateMap, const std::string& destLayerName, for (int xy = (templateMap->getWidth() * templateMap->getHeight() -1); xy >= 0; xy--) { - Tile& fromTile = fromLayer->at(xy); - Tile& toTile = toLayer->at(xy); + Tile fromTile = fromLayer->at(xy); + Tile toTile = toLayer->at(xy); if (!fromTile.empty()) { - collisionTranslation[fromTile] = toTile; //FIXME - just getting it compiling so far + fromTile.tileset = tilesetTranslation[fromTile.tileset]; + toTile.tileset = tilesetTranslation[toTile.tileset]; + + collisionTranslation[fromTile] = toTile; } } diff --git a/tools/tmxcopy/map.hpp b/tools/tmxcopy/map.hpp index d6cd3d1a..3be932ab 100644 --- a/tools/tmxcopy/map.hpp +++ b/tools/tmxcopy/map.hpp @@ -69,6 +69,13 @@ struct Tileset }; +/** + * A tile in a layer of a map. + * + * With the exception of the emptyTile and empty() function, + * interpreting what this tile represents depends on the map it + * belongs to (specifically the ordering of that map's tilesets). + */ struct Tile { int tileset; // number of tileset @@ -82,7 +89,8 @@ struct Tile /* This is to allow std::map<Tile,Tile> */ bool operator< (const Tile& b) const { - return ((tileset < b.tileset) || (index < b.index)); + return ((tileset < b.tileset) || + ((tileset == b.tileset) && (index < b.index))); } bool operator!= (const Tile& b) const @@ -144,7 +152,7 @@ class Map /** * Translates a layer - using the template, generates collision from visible layers (for example). - * TODO - avoid confusion with the math term "translate" + * TODO - avoid confusion with the geometry term "translate" */ bool translateAllLayers(Map* templateMap, const std::string& destLayerName, const ConfigurationOptions& config); |