# Tiled fails to open maps with embedded tilesets

**URL:** <https://discourse.mapeditor.org/t/tiled-fails-to-open-maps-with-embedded-tilesets/3040>\
**Category:** Bugs\
**Created:** [March 1, 2018, 10:16am UTC](https://discourse.mapeditor.org/t/tiled-fails-to-open-maps-with-embedded-tilesets/3040 "2018-03-01T10:16:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Geoffrey\_Megardon](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.mapeditor.org/geoffrey_megardon/32/1567_2.png) [@Geoffrey\_Megardon](https://discourse.mapeditor.org/u/Geoffrey_Megardon)\
**Post date:** [March 1, 2018, 10:16am UTC](https://discourse.mapeditor.org/t/tiled-fails-to-open-maps-with-embedded-tilesets/3040/1 "2018-03-01T10:16:13Z")

</div>

Hello,

I tried to open the map I was working on yesterday and I received this message:  
 ![tiled_2018-03-01_09-58-57](https://canada1.discourse-cdn.com/flex035/uploads/mapeditor/original/2X/6/641d61fa5b57a98c3187fdb1c3b5d8c34cc56900.png)

I open the tmx file with a text editor and I replaced the embedded tilesets with the actual tileset files:

> ```
> <tileset firstgid="1" source="holes_tileset.tsx"/>
> <tileset firstgid="19" source="walls_tileset.tsx"/>
> 
> ```

and now, Tiled succeeds to open the map.

To check whether it was just a problem of file corruption, I made a new map (empty) and I embedded my tilesets to it, save it, close the file and open it. This leads to the same crash and same error message.

What is funny is that if I export the map in json before to close it, the json map work perfectly in Phaser.

Any idea of what is going on?

---

<div class="post-metadata">

**Author:** ![bjorn](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.mapeditor.org/bjorn/32/1599_2.png) [@bjorn](https://discourse.mapeditor.org/u/bjorn)\
**Post date:** [March 1, 2018, 11:39am UTC](https://discourse.mapeditor.org/t/tiled-fails-to-open-maps-with-embedded-tilesets/3040/2 "2018-03-01T11:39:39Z")

</div>

This means there may be some inconsistency in the map reader and writer, or between the data and the verification checks done in the map reader. The error messages pops up if this check fails:

> <https://github.com/bjorn/tiled/blob/214fe1bd30780f7590be8c9f5834b28f8883653f/src/libtiled/wangset.cpp#L711-L723>

It would be very helpful if you could upload the files you’re using to reproduce the problem (see the Upload button in the post tool bar).

---

<div class="post-metadata">

**Author:** ![Geoffrey\_Megardon](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.mapeditor.org/geoffrey_megardon/32/1567_2.png) [@Geoffrey\_Megardon](https://discourse.mapeditor.org/u/Geoffrey_Megardon)\
**Post date:** [March 11, 2018, 5:19pm UTC](https://discourse.mapeditor.org/t/tiled-fails-to-open-maps-with-embedded-tilesets/3040/3 "2018-03-11T17:19:42Z")

</div>

Hello bjorn,

here is the file, with the embedded tilesets.  
[map2-embedded.tmx](https://canada1.discourse-cdn.com/flex035/uploads/mapeditor/original/2X/4/4b02e4ca1359f42521750f405182dd5a9472569b.tmx) (13.4 KB)

Hope that will help you 🙂 Sorry for the slow answer.

---

<div class="post-metadata">

**Author:** ![bjorn](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.mapeditor.org/bjorn/32/1599_2.png) [@bjorn](https://discourse.mapeditor.org/u/bjorn)\
**Post date:** [March 13, 2018, 11:24am UTC](https://discourse.mapeditor.org/t/tiled-fails-to-open-maps-with-embedded-tilesets/3040/4 "2018-03-13T11:24:27Z")

</div>

> [@Geoffrey\_Megardon](#):
>
> Hope that will help you 🙂 Sorry for the slow answer.

No problem, that really helped! Indeed the file was invalid and I found out how this happened. When you embed a tileset, it is internally cloned to avoid affecting the external tileset with further edits, but the cloning of Wang sets was incomplete. I fixed it in the following change:

> <https://github.com/mapeditor/tiled/commit/4ae4ff69c760483acf792baa9ba490a12e776e8e>
>
> The Wang sets were not cloned completely, missing their edge and corner
> colors. …This would result in an invalid Wang set that would fail to load.
> 
> See http://discourse.mapeditor.org/t/tiled-fails-to-open-maps-with-embedded-tilesets/3040

It will be included in a future Tiled 1.1.4 release and the next development snapshot.
