Page 1 of 1

[Rseding91] [0.13.17] show_hidden_tile check wrong tile

Posted: Wed Aug 17, 2016 6:21 am
by Neemys
I was playing a bit you the new surface method get_hidden_tile when I saw some weird behavior, after some time investigating, I found that it seek the wrong tile to look under. Step to reproduce :

1) Start a new game or load a savegame.
2) Place a concrete tile one the ground.
3) Stand on the concrete tile and execute the following command

Code: Select all

/c game.player.print(game.player.surface.get_tile(game.player.position.x,game.player.position.y).name);game.player.print(game.player.surface.get_hidden_tile(game.player.position))
This command print the name of the tile the player is on, then print the name of the tile under the tile the player is on.

Expected behavior : The first print should show "concrete", the second one shoud show the tile name of what is under the concrete (in the screenshot, grass-dry).
Actual behavior : The first print show concrete, the second one show "nil".
bug_surface_method.jpg
bug_surface_method.jpg (192.56 KiB) Viewed 2489 times


With a bit of test I manage to find that you get the correct hidden tile when you request the tile position just above the concrete tile.
If you stand on the tile above the concrete and run the previous command, the print will be "name of the tile you are standing on, and the second print will show the name of the tile under the concrete.
bug_surface_method2.jpg
bug_surface_method2.jpg (183.88 KiB) Viewed 2489 times
In this screenshot we see that the first print show us the tile we are on (dirt) and the second print (hidden_tile) return the tile that is under the concrete (grass-dry)

Using numeric position instead of player position have the same result.

Edit : Changed factorio version to 0.13.17.

Re: [0.13.16] show_hidden_tile check wrong tile

Posted: Wed Aug 17, 2016 1:51 pm
by Rseding91
This is a result of C++ and how it converts floating point numbers to ints (round towards 0) so a position of {-5.5, 10} ends up at: {-5, 10} which isn't the same tile that collides with the original position.

If you give it tile positions as its expecting you'll get the values back you're expecting.

I'll see if I can make the function auto-convert non tile positions to tile positions correctly.

Re: [Rseding91] [0.13.16] show_hidden_tile check wrong tile

Posted: Wed Aug 17, 2016 10:57 pm
by Neemys
You are right, it only occur with negative value as rounding toward zero in negative jump to the other tile. If I do the exact thing as I do in the first post in an area with only positive position the bug does not occur. Why show_tile method does not have this problem ?

As a temporary workaround I remove 1 if the x or y is negative in my mod, no problem so far. But I will not release the feature until this bug is fix.

Thanks for your hard work.

Re: [Rseding91] [0.13.17] show_hidden_tile check wrong tile

Posted: Thu Aug 18, 2016 2:00 am
by Rseding91
Fixed for 0.13.18.