From 59c35e4628a806412700fb4d9d4e8e61509d1ab2 Mon Sep 17 00:00:00 2001 From: vtxe02023274 <344562942+vtxe02023274@users.noreply.github.com> Date: Wed, 18 Nov 2026 09:15:13 +0800 Subject: [PATCH] resolve template tileset source relative to the template file Tiled writes the tileset source inside a .tx file relative to the template, but it was resolved against the map directory, so a template in a subfolder failed to load its tileset. The template path itself was built with map dir + "/", which became "/templates/x.tx" when the map was loaded from the current directory. Use resolveFilePath for both. --- tmxlite/src/Object.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tmxlite/src/Object.cpp b/tmxlite/src/Object.cpp index ef54743..d179c47 100644 --- a/tmxlite/src/Object.cpp +++ b/tmxlite/src/Object.cpp @@ -222,7 +222,7 @@ void Object::parseTemplate(const std::string& path, Map* map) //load the template if not already loaded if (templateObjects.count(path) == 0) { - auto templatePath = map->getWorkingDirectory() + "/" + path; + auto templatePath = resolveFilePath(path, map->getWorkingDirectory()); pugi::xml_document doc; if (!doc.load_file(templatePath.c_str())) @@ -247,7 +247,8 @@ void Object::parseTemplate(const std::string& path, Map* map) if (!tilesetName.empty() && templateTilesets.count(tilesetName) == 0) { - templateTilesets.insert(std::make_pair(tilesetName, Tileset(map->getWorkingDirectory()))); + //tileset source is relative to the template file, not the map + templateTilesets.insert(std::make_pair(tilesetName, Tileset(getFilePath(templatePath)))); templateTilesets.at(tilesetName).parse(tileset, map); } }