@@ -683,14 +683,14 @@ namespace gf {
683
683
return tile;
684
684
}
685
685
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)
687
687
{
688
688
assert (node.name () == " tileset" sv);
689
689
690
690
MapTileset tileset;
691
691
tileset.type = node.attribute (" class" ).as_string ();
692
692
tileset.properties_index = parse_tmx_properties (node, map);
693
- tileset.first_gid = node. attribute ( " firstgid " ). as_uint () ;
693
+ tileset.first_gid = first_gid ;
694
694
695
695
tileset.tile_size .w = node.attribute (" tilewidth" ).as_int ();
696
696
tileset.tile_size .h = node.attribute (" tileheight" ).as_int ();
@@ -720,7 +720,7 @@ namespace gf {
720
720
return tileset;
721
721
}
722
722
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)
724
724
{
725
725
std::filesystem::path tileset_path = base_directory / source;
726
726
std::ifstream tileset_file (tileset_path);
@@ -746,19 +746,21 @@ namespace gf {
746
746
Log::warning (" Attribute 'source' present in a TSX file: '{}'." , tileset_path);
747
747
}
748
748
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 ());
750
750
}
751
751
752
752
MapTileset parse_tmx_tileset (const pugi::xml_node node, TiledMap& map, const std::filesystem::path& base_directory)
753
753
{
754
754
assert (node.name () == " tileset" sv);
755
755
const std::filesystem::path source = node.attribute (" source" ).as_string ();
756
756
757
+ const uint32_t first_gid = node.attribute (" firstgid" ).as_uint ();
758
+
757
759
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);
759
761
}
760
762
761
- return parse_tmx_tileset_from_element (node, map, base_directory);
763
+ return parse_tmx_tileset_from_element (first_gid, node, map, base_directory);
762
764
}
763
765
764
766
/*
0 commit comments