Tiled csv format has exceptionally large tile values (SOLVED)

I am having an issue where Tiled maps saved in csv format have tile values which are exceptionally large and don’t correspond to the tilemap offsets I’m using in my game. Looking at the data inside I’m seeing values such as “3221225645” and “2147483863” (the second value looking very close to the max int32 value.) Has anyone seen this or now how to fix it? Important to note, the map saves/loads in Tiled just fine. However, when I import it into my game the very large tile values don’t map to anything meaningful.

Those large values are tiles with flip flags set, they’re telling you which way(s) the tile is flipped. To extract the flip flags and then extract just the tileID, you’ll need to do some bitwise logic:

horizontalFlip = tile & 0x80000000;
verticalFlip = tile & 0x40000000;
diagonalFlip = tile & 0x20000000;
tileID = tile & ~(0x80000000 | 0x40000000 | 0x20000000); //clear the flags

Edit: Documentation: https://doc.mapeditor.org/en/stable/reference/tmx-map-format/#tile-flipping

3 Likes

Thank you this was the case :smiley:
Do you know if there’s a way to modify the flipping feature so that a certain tile is modified to another when flipped vs flipping the graphic/tile value flip flags instead? Otherwise I can just modify my importer script to do this manually.

1 Like

Tiled currently can’t choose alternative tiles instead of setting flipping bits.

I imagine it could be something that it could do based on Wang IDs, though currently a tile can be in multiple Wang sets so I guess it’d need to search all of them. This approach would not be intuitive for anything else but terrain-like tiles though…

Doing this in an importing script sounds like a good idea to me.

1 Like

You could also set up an automap rule set that replaces flipped tiles with different tiles.

1 Like