mapeditor / rs-tiled

Reads files from the Tiled editor into Rust
https://crates.io/crates/tiled
MIT License
268 stars 103 forks source link

Putting a <tileset> after a <layer> in a <map> element causes that tileset to be ignored #169

Closed RossBrunton closed 2 years ago

RossBrunton commented 2 years ago

To reproduce:

As far as I can tell, the format for .tmx does not require the nodes to be in a specific order.

This is caused because nodes are parsed as we see them. When generating the tiles in a TileLayer, the list of already parsed tilesets is looked up to figure out which should be used. If this list is empty (if no tileset node is seen yet) or contains no elements for which first_gid < gid, it is interpreted as the tile being "empty" as if it were GID 0.

aleokdev commented 2 years ago

As far as I can tell, the format for .tmx does not require the nodes to be in a specific order.

It does, but it isn't documented. One second.

aleokdev commented 2 years ago

See https://github.com/mapeditor/rs-tiled/pull/135#discussion_r801650701. This is expected.

bjorn commented 2 years ago
  • In one of the test .tmx files, move the element after a element. For example:

Just wondering, but why would you do such a thing?

I do need to remember to put a note about this in the documentation...