Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bit shifts processing tile flips break down around gid=>2^28 #30

Closed
pgainullin opened this issue Mar 10, 2021 · 3 comments · Fixed by #45
Closed

Bit shifts processing tile flips break down around gid=>2^28 #30

pgainullin opened this issue Mar 10, 2021 · 3 comments · Fixed by #45

Comments

@pgainullin
Copy link

See this example including sample data:

https://gist.github.com/pgainullin/bdf8ac141e9501958c993bb4467685fb

Running it in DartPad shows several IDs turn to 268435492 and 268435498 post flag-clearing. Given that there are bit shifts in this code and 2^28=268435456 it looks like some sort of an overflow error.

I can't see any issues just by looking at the code in tiled/src/layer.dart assempleTileMatrix vs the docs (https://doc.mapeditor.org/en/stable/reference/tmx-map-format/) but I don't know enough about bitwise operations in Dart to really understand it

@luanpotter
Copy link
Member

This is an issue with the underlying https://github.com/flame-engine/tiled.dart/ library, not with flame_tiled. I will link this issue there, and close this one.

@luanpotter luanpotter transferred this issue from flame-engine/flame_tiled Sep 25, 2021
@luanpotter
Copy link
Member

Bringing this from the old flame_tiled repo

@luanpotter luanpotter reopened this Sep 25, 2021
@natebot13
Copy link
Contributor

The root issue is from this section of the tiled documentation: https://doc.mapeditor.org/en/stable/reference/global-tile-ids/#gid-tile-flipping
The tile data probably comes from a hexagonal map, meaning the 29th bit is on, but tiled.dart only handles orthogonal maps, and only clears the top 3 bits. It should clear the top 4, and possibly even save the status of the bit into a new Flips flag in case a user wants to parse a hexagonal map.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants