tileson
tileson copied to clipboard
Full image filepath for an embedded tileset is incorrect
Description
The m_imagePath
member variable in Tileset::parse is incorrect when parsing an external tileset. This issue is caused by the concatenation of m_path
and m_imagePath
, and m_path
not being set for internal tilesets.
if(json.count("source") > 0)
{
...
std::string sourceStr = json["source"].get<std::string>();
m_source = fs::path(sourceStr);
m_path = json.directory() / m_source;
...
}
...
if (json.count("image") > 0)
{
m_image = fs::path(json["image"].get<std::string>());
m_imagePath = m_path.parent_path() / m_image;
}
Solution
Use json.directory()
to construct the filepath instead of m_path
. This code change will resolve the correct image filepath for both internal and external tilesets.
if (json.count("image") > 0)
{
m_image = fs::path(json["image"].get<std::string>());
m_imagePath = json.directory() / m_image;
}