[1.1.104] Crash using Camera UI Elem at high zoom far away from spawn

Post Reply
nnotm
Burner Inserter
Burner Inserter
Posts: 12
Joined: Sat Aug 25, 2018 1:15 pm
Contact:

[1.1.104] Crash using Camera UI Elem at high zoom far away from spawn

Post by nnotm »

If you use a LuaGuiElement of type "camera" with large zoom values far away from the spawn point, the game will crash, saying

Code: Select all

Error FloatCast.hpp:123: 2159999906.000000 > 2147483647.000000
(or similar numbers).

I originally encountered this when trying to use the area outside the world map to draw graphs - at the position I randomly selected, it crashed at zoom values as low as 10. The further out you go, the lower the critical zoom value becomes, but you don't have to go outside of the playable area for this to happen (see code below).

I would have expected to be able to zoom in as far as I want to.
Reproduction steps
I have a copy of 1.1.104 with just one mod enabled containing this control.lua file:

Code: Select all

script.on_event(defines.events.on_gui_closed, function(event)
    local player = game.get_player(1)
    if player then
        local frame = player.gui.screen.add{type="frame", name="frame"}
        frame.auto_center = true
        local camera = frame.add{
            type="camera",
            position={900000, 0},
            zoom=75,
        }
        camera.style.size = {200, 200}
    end
end)
You can either make a mod containing this or just run `/c <that code>` in the console after starting a new game.

You can then reproduce the crash by opening and then closing the inventory interface.
Attachments
factorio-current.log
(8.84 KiB) Downloaded 20 times

Rseding91
Factorio Staff
Factorio Staff
Posts: 13240
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [1.1.104] Crash using Camera UI Elem at high zoom far away from spawn

Post by Rseding91 »

Thanks for the report. This is now fixed for 2.0. In the meantime you can use an empty surface and just do the rendering closer to 0,0 :)
If you want to get ahold of me I'm almost always on Discord.

nnotm
Burner Inserter
Burner Inserter
Posts: 12
Joined: Sat Aug 25, 2018 1:15 pm
Contact:

Re: [1.1.104] Crash using Camera UI Elem at high zoom far away from spawn

Post by nnotm »

Thanks! To make sure I head in the right direction with my mod, can I ask if the fix is just preventing the crash or if it also involves being able to zoom in as far as you want?

Rseding91
Factorio Staff
Factorio Staff
Posts: 13240
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [1.1.104] Crash using Camera UI Elem at high zoom far away from spawn

Post by Rseding91 »

I believe zoom should work as desired with the fix.
If you want to get ahold of me I'm almost always on Discord.

nnotm
Burner Inserter
Burner Inserter
Posts: 12
Joined: Sat Aug 25, 2018 1:15 pm
Contact:

Re: [1.1.104] Crash using Camera UI Elem at high zoom far away from spawn

Post by nnotm »

Very cool, thanks

Post Reply

Return to “Fixed for 2.0”