@@ -201,6 +201,7 @@ namespace gf {
201201 MapLayer layer;
202202 layer.properties_index = parse_tmx_properties (node, map);
203203 layer.name = node.attribute (" name" ).as_string ();
204+ layer.type = node.attribute (" class" ).as_string ();
204205 layer.offset .x = node.attribute (" offsetx" ).as_int (0 );
205206 layer.offset .y = node.attribute (" offsety" ).as_int (0 );
206207 unsupported_attribute (node, " opacity" );
@@ -682,10 +683,15 @@ namespace gf {
682683 return tile;
683684 }
684685
685- void parse_tmx_tileset_from_element (MapTileset& tileset, const pugi::xml_node node, TiledMap& map, const std::filesystem::path& base_directory)
686+ MapTileset parse_tmx_tileset_from_element (const pugi::xml_node node, TiledMap& map, const std::filesystem::path& base_directory)
686687 {
687688 assert (node.name () == " tileset" sv);
688689
690+ MapTileset tileset;
691+ tileset.type = node.attribute (" class" ).as_string ();
692+ tileset.properties_index = parse_tmx_properties (node, map);
693+ tileset.first_gid = node.attribute (" firstgid" ).as_uint ();
694+
689695 tileset.tile_size .w = node.attribute (" tilewidth" ).as_int ();
690696 tileset.tile_size .h = node.attribute (" tileheight" ).as_int ();
691697
@@ -710,9 +716,11 @@ namespace gf {
710716 std::sort (tileset.tiles .begin (), tileset.tiles .end (), MapTilesetTileComparator ());
711717
712718 unsupported_node (node, " wangsets" );
719+
720+ return tileset;
713721 }
714722
715- void parse_tmx_tileset_from_file (MapTileset& tileset, const std::filesystem::path& source, TiledMap& map, const std::filesystem::path& base_directory)
723+ MapTileset parse_tmx_tileset_from_file (const std::filesystem::path& source, TiledMap& map, const std::filesystem::path& base_directory)
716724 {
717725 std::filesystem::path tileset_path = base_directory / source;
718726 std::ifstream tileset_file (tileset_path);
@@ -738,25 +746,19 @@ namespace gf {
738746 Log::warning (" Attribute 'source' present in a TSX file: '{}'." , tileset_path);
739747 }
740748
741- parse_tmx_tileset_from_element (tileset, node, map, tileset_path.parent_path ());
749+ return parse_tmx_tileset_from_element (node, map, tileset_path.parent_path ());
742750 }
743751
744752 MapTileset parse_tmx_tileset (const pugi::xml_node node, TiledMap& map, const std::filesystem::path& base_directory)
745753 {
746754 assert (node.name () == " tileset" sv);
747- MapTileset tileset;
748- tileset.properties_index = parse_tmx_properties (node, map);
749- tileset.first_gid = node.attribute (" firstgid" ).as_uint ();
750-
751755 const std::filesystem::path source = node.attribute (" source" ).as_string ();
752756
753757 if (!source.empty ()) {
754- parse_tmx_tileset_from_file (tileset, source, map, base_directory);
755- } else {
756- parse_tmx_tileset_from_element (tileset, node, map, base_directory);
758+ return parse_tmx_tileset_from_file (source, map, base_directory);
757759 }
758760
759- return tileset ;
761+ return parse_tmx_tileset_from_element (node, map, base_directory) ;
760762 }
761763
762764 /*
@@ -767,6 +769,7 @@ namespace gf {
767769 {
768770 assert (node.name () == " map" sv);
769771
772+ map.type = node.attribute (" class" ).as_string ();
770773 map.properties_index = parse_tmx_properties (node, map);
771774
772775 std::string orientation = node.attribute (" orientation" ).as_string ();
0 commit comments