-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Segmentation fault when running terraingenerator if Terrain Image is not set #3299
Comments
Terrain images are entirely optional, so if that is indeed the problem, showing an error message would not be a good solution. There's already a check for whether the Terrain image is set (https://github.com/mapeditor/tiled/blob/master/src/terraingenerator/main.cpp#L559-L560), too... |
Right, a static analysis tool would have caught this error, because after checking that pointer for null it is used two lines later without the null check... so this bug was introduced in 02e092a, where I forgot about the null check. Thanks for the report @bluecarrot16! |
* Fixed crash when a terrain in a source tileset does not have an image assigned to it. * Don't assume that the image assigned to a terrain has that terrain on all its corners. Now also other cases are handled, and the "base tile" for each terrain is looked up using the terrain information instead. Closes #3299
After fixing the crash, I noticed this still doesn't work nicely with your use-case, since the code assumed that those images were each terrain's "base image", so it would result in a black tile for each of the listed terrains. I've now fixed up the code so that it also works as expected when the terrain images are not set. |
Thanks for the quick response and the fix! A related issue---if there are multiple "base images" for a given terrain (e.g. multiple tiles where all four corners have the same terrain type), only the tile marked as the "Terrain Image" would be included in the output. It would be nice if there was a mechanism for the other images to be included as well. The use case is for "accent" tiles (for example, tiles I can't tell immediately from the code whether your change implements this behavior. If it's not hard to do while you're thinking about this, that change would also be much appreciated! I can also make a separate issue for that if you prefer. |
@bluecarrot16 I guess it makes more sense to set up a new issue about that. The thing is that the tool currently doesn't support variation tiles at all, and I'm not too fond of doing a quick implementation that just deals with the full terrain tiles currently. Also, note that the tool can extend an existing tileset (if you don't pass |
OK, thanks for that! I'll make a new issue for that request. |
Describe the bug
I get a segmentation fault when running the terraingenerator tool. Seems the cause is that one or more terrains in the tileset don't have a Terrain Image assigned.
To Reproduce
Steps to reproduce the behavior:
terraingenerator-bug.zip
Segmentation fault: 11
Expected behavior
An error message saying something to the effect of "Must assign a Terrain Image for Terrain '$TERRAIN'. Open the tileset in Tiled, select the terrain, then right-click on a tile and choose 'Use Terrain Image'"
Setting a terrain image for all tiles in the tileset fixes the problem.
Specifications:
Thanks for the great tool!
The text was updated successfully, but these errors were encountered: