summaryrefslogtreecommitdiff
path: root/src/resources
diff options
context:
space:
mode:
Diffstat (limited to 'src/resources')
-rw-r--r--src/resources/db/mapdb.cpp17
-rw-r--r--src/resources/db/mapdb.h2
-rw-r--r--src/resources/map/tileset.h13
-rw-r--r--src/resources/mapreader.cpp22
4 files changed, 45 insertions, 9 deletions
diff --git a/src/resources/db/mapdb.cpp b/src/resources/db/mapdb.cpp
index 0ca328dcf..971fa4578 100644
--- a/src/resources/db/mapdb.cpp
+++ b/src/resources/db/mapdb.cpp
@@ -34,6 +34,7 @@ namespace
MapDB::Maps mMaps;
MapDB::MapInfos mInfos;
MapDB::Atlases mAtlases;
+ std::set<std::string> mEmptyTilesets;
} // namespace
namespace MapDB
@@ -137,7 +138,16 @@ void MapDB::readAtlas(XmlNodePtrConst node)
mAtlases[atlas].push_back(file);
}
}
- if (atlas != "all" && atlas != paths.getStringValue("emptyAtlasName"))
+ if (atlas == paths.getStringValue("emptyAtlasName"))
+ {
+ const StringVect *files = &mAtlases[atlas];
+ FOR_EACHP (StringVectCIter, it, files)
+ {
+ mEmptyTilesets.insert(*it);
+ logger->log("empty tileset: " + *it);
+ }
+ }
+ else if (atlas != "all")
{
const AtlasCIter &allAtlas = mAtlases.find("all");
if (allAtlas != mAtlases.end())
@@ -223,3 +233,8 @@ const MapInfo *MapDB::getAtlas(const std::string &name)
info->files = &(*it).second;
return info;
}
+
+bool MapDB::isEmptyTileset(const std::string &name)
+{
+ return mEmptyTilesets.find(name) != mEmptyTilesets.end();
+}
diff --git a/src/resources/db/mapdb.h b/src/resources/db/mapdb.h
index 97a8f0cb1..e7ccf972c 100644
--- a/src/resources/db/mapdb.h
+++ b/src/resources/db/mapdb.h
@@ -57,6 +57,8 @@ namespace MapDB
const MapInfo *getAtlas(const std::string &name) A_WARN_UNUSED;
+ bool isEmptyTileset(const std::string &name);
+
// Maps DB
typedef std::map<std::string, std::string> Maps;
typedef Maps::iterator MapIterator;
diff --git a/src/resources/map/tileset.h b/src/resources/map/tileset.h
index 6acf52c41..50eb112e3 100644
--- a/src/resources/map/tileset.h
+++ b/src/resources/map/tileset.h
@@ -43,8 +43,9 @@ class Tileset final : public ImageSet
const int margin,
const int spacing) :
ImageSet(img, w, h, margin, spacing),
+ mProperties(),
mFirstGid(firstGid),
- mProperties()
+ mIsEmpty(false)
{
}
@@ -92,10 +93,16 @@ class Tileset final : public ImageSet
return sz;
}
- private:
- int mFirstGid;
+ void setEmpty(const bool b)
+ { mIsEmpty = b; }
+
+ bool isEmpty() const
+ { return mIsEmpty; }
+ private:
std::map<std::string, std::string> mProperties;
+ int mFirstGid;
+ bool mIsEmpty;
};
#endif // RESOURCES_MAP_TILESET_H
diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp
index e5e7374fe..9393e781b 100644
--- a/src/resources/mapreader.cpp
+++ b/src/resources/mapreader.cpp
@@ -565,10 +565,18 @@ inline static void setTile(Map *const map,
{
case MapLayerType::TILES:
{
- Image *const img = set != nullptr ?
- set->get(gid - set->getFirstGid()) : nullptr;
- if (layer != nullptr)
+ if (layer == nullptr)
+ break;
+ if (set != nullptr &&
+ !set->isEmpty())
+ {
+ Image *const img = set->get(gid - set->getFirstGid());
layer->setTile(x, y, img);
+ }
+ else
+ {
+ layer->setTile(x, y, nullptr);
+ }
break;
}
@@ -1112,10 +1120,12 @@ Tileset *MapReader::readTileset(XmlNodePtr node,
const std::string source = XML::getProperty(
childNode, "source", "");
+ const std::string sourceResolved = resolveRelativePath(pathDir,
+ source);
+
if (!source.empty())
{
- Image *const tilebmp = Loader::getImage(
- resolveRelativePath(pathDir, source));
+ Image *const tilebmp = Loader::getImage(sourceResolved);
if (tilebmp != nullptr)
{
@@ -1126,6 +1136,8 @@ Tileset *MapReader::readTileset(XmlNodePtr node,
spacing);
tilebmp->decRef();
#ifdef USE_OPENGL
+ if (MapDB::isEmptyTileset(sourceResolved))
+ set->setEmpty(true);
if (tilebmp->getType() == ImageType::Image &&
map->haveAtlas() == true &&
graphicsManager.getUseAtlases())