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

Switching from infinite erroneously updates map dimensions that are less than 16x16. #2051

Closed
drakbar opened this issue Jan 2, 2019 · 3 comments

Comments

2 participants
@drakbar
Copy link

commented Jan 2, 2019

This appears to be a bug in 1.2.1.
I am using JSON as the file format.
OS Windows 10

Edit:
Steps to reproduce:
Create a map of 10 x 10.
Create a new tileset.
Place a tile on the map.

Go to map properties and check infinite.
Save the Map.

Open the JSON file.
The chunks' width and height should read 16 x 16, while the map's width and height 10 x 10.

The map's width and height will update to 16 x 16 if you uncheck the infinite property.

It is interesting that a tile needs to be in the tile layer in order for this to occur.
Also that the minimum size for a chunk is 16 x 16.

@bjorn

This comment has been minimized.

Copy link
Owner

commented Jan 3, 2019

The map's width and height will update to 16 x 16 if you uncheck the infinite property.

Yeah, that shouldn't happen. It happens because this size is based on the bounding rectangle of the allocated chunks, rather than the exact area used by the tile layers. I should probably just fix this to determine the exact area instead.

However, the title of your issue reads "Switching to infinite", whereas this bug happens when switching FROM infinite. Is there also an issue when switching TO infinite?

It is interesting that a tile needs to be in the tile layer in order for this to occur.

Right, if there is no tile placed, there is no chunk allocated. So the bounding rectangle of the chunks is empty.

Also that the minimum size for a chunk is 16 x 16.

A chunk is currently always 16x16.

@bjorn bjorn added the bug label Jan 3, 2019

@bjorn bjorn added this to Tiled 1.2 (bugfixes) in Roadmap Jan 3, 2019

@drakbar

This comment has been minimized.

Copy link
Author

commented Jan 4, 2019

However, the title of your issue reads "Switching to infinite", whereas this bug happens when switching FROM infinite. Is there also an issue when switching TO infinite?

I found this issue because I am writing a package for golang like go-tmx.
Instead of decoding xml it decodes json.

Whilst reading the documentation I came across the section about tile flipping and clearing the high-bits.

// Here you should check that the data has the right size
// (map_width * map_height * 4)

And indeed I take this approach in my implementation as shown by the excerpt below.

// make sure there is enough data for every tile
if len(b) != (m.Width * m.Height * 4) {
  return DataSizeMismatch
}   

Currently, I have both chunk data and tile layer data running through through this check. So when the map is set to infinite, len(b) will always be 1024. However, m.Width * m.Height * 4 in this case will equal 400 and throw the error. I can easily adjust for this fact with:

// make sure there is enough data for every tile
if m.Infinite && len(b) != InfiniteChunkSize {
  return DataSizeMismatch
}
if !m.Infinite && len(b) != (m.Width * m.Height * 4) {
  return DataSizeMismatch
} 

Having said all of that I agree that it is a bug when you switch from infinite.

@drakbar drakbar changed the title Switching to infinite updates chunk width and height but not map width and height. Switching from infinite erroneously updates map dimensions that are less than 16x16. Jan 4, 2019

@bjorn

This comment has been minimized.

Copy link
Owner

commented Jan 15, 2019

Hmm, I guess the documentation could be updated, but modifying that code to support both infinite and fixed-size maps is going to make it a little too complicated for my tastes and goes beyond what it was trying to demonstrate. In that case it may be more helpful to link to the Tiled source code directly for all the details, and reduce the example shown in the docs.

@bjorn bjorn closed this in ef07f8d May 15, 2019

Roadmap automation moved this from Tiled 1.2 (bugfixes) to Recently Completed May 15, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.