@@ -683,14 +683,14 @@ namespace gf {
683683 return tile;
684684 }
685685
686- MapTileset parse_tmx_tileset_from_element (const pugi::xml_node node, TiledMap& map, const std::filesystem::path& base_directory)
686+ MapTileset parse_tmx_tileset_from_element (uint32_t first_gid, const pugi::xml_node node, TiledMap& map, const std::filesystem::path& base_directory)
687687 {
688688 assert (node.name () == " tileset" sv);
689689
690690 MapTileset tileset;
691691 tileset.type = node.attribute (" class" ).as_string ();
692692 tileset.properties_index = parse_tmx_properties (node, map);
693- tileset.first_gid = node. attribute ( " firstgid " ). as_uint () ;
693+ tileset.first_gid = first_gid ;
694694
695695 tileset.tile_size .w = node.attribute (" tilewidth" ).as_int ();
696696 tileset.tile_size .h = node.attribute (" tileheight" ).as_int ();
@@ -720,7 +720,7 @@ namespace gf {
720720 return tileset;
721721 }
722722
723- MapTileset parse_tmx_tileset_from_file (const std::filesystem::path& source, TiledMap& map, const std::filesystem::path& base_directory)
723+ MapTileset parse_tmx_tileset_from_file (uint32_t first_gid, const std::filesystem::path& source, TiledMap& map, const std::filesystem::path& base_directory)
724724 {
725725 std::filesystem::path tileset_path = base_directory / source;
726726 std::ifstream tileset_file (tileset_path);
@@ -746,19 +746,21 @@ namespace gf {
746746 Log::warning (" Attribute 'source' present in a TSX file: '{}'." , tileset_path);
747747 }
748748
749- return parse_tmx_tileset_from_element (node, map, tileset_path.parent_path ());
749+ return parse_tmx_tileset_from_element (first_gid, node, map, tileset_path.parent_path ());
750750 }
751751
752752 MapTileset parse_tmx_tileset (const pugi::xml_node node, TiledMap& map, const std::filesystem::path& base_directory)
753753 {
754754 assert (node.name () == " tileset" sv);
755755 const std::filesystem::path source = node.attribute (" source" ).as_string ();
756756
757+ const uint32_t first_gid = node.attribute (" firstgid" ).as_uint ();
758+
757759 if (!source.empty ()) {
758- return parse_tmx_tileset_from_file (source, map, base_directory);
760+ return parse_tmx_tileset_from_file (first_gid, source, map, base_directory);
759761 }
760762
761- return parse_tmx_tileset_from_element (node, map, base_directory);
763+ return parse_tmx_tileset_from_element (first_gid, node, map, base_directory);
762764 }
763765
764766 /*
0 commit comments