[1.1.104] Crash when camera UI elem tries to render position beyond edge of valid coordinates

Things that we don't consider worth fixing at this moment.
Post Reply
nnotm
Burner Inserter
Burner Inserter
Posts: 12
Joined: Sat Aug 25, 2018 1:15 pm
Contact:

[1.1.104] Crash when camera UI elem tries to render position beyond edge of valid coordinates

Post by nnotm »

The game crashes with "Unhandled exception: vector<T> too long" if you point a camera UI element near the 2^23-1 tile limit of the coordinates, and the UI element is large enough that the camera tries to render something beyond that limit.

Quick backstory on why this affects me: I'm trying to make a library that makes it easier for other mods to render images/graphs (via cameras), and I'm keeping track of those images on a surface. Since I'm using a quadtree, it's easiest to use powers of two, so ideally I'd like to go all the way to the edge of the map. Normally, this crash wouldn't prevent me from doing that, since I can just render things inside the map - except that a change in interface scale while the UI is open can change what a camera sees. This means that starting in the right state, this crash can be reliably triggered by changing the size of the game window.

I'm sure I'll find a way around that (e.g. only using one quarter of the surface), it would just be slightly more convenient if I didn't have to, but I won't lose any sleep if this doesn't get fixed.
Reproduction Steps
Start a new game and type these four command:

Code: Select all

/c frame = game.player.gui.screen.add{type="frame", name="frame"}
/c frame.style.size = {100, 100}
/c camera = frame.add{type="camera", position={2^23-1, 0}, zoom=game.player.display_scale}
/c camera.style.size = {100, 100}
Edit: fixed typo 2^32 -> 2^23
Attachments
factorio-current.log
(12.82 KiB) Downloaded 23 times
Last edited by nnotm on Mon Feb 05, 2024 5:12 pm, edited 1 time in total.

Genhis
Factorio Staff
Factorio Staff
Posts: 120
Joined: Wed Dec 24, 2014 8:19 am
Contact:

Re: [1.1.104] Crash when camera UI elem tries to render position beyond edge of valid coordinates

Post by Genhis »

You are far beyond the edge of valid coordinates. We assume a valid map position is within 2^20 radius - the maximum radius of the map is 1 million tiles and there is a safety margin of 48,576 tiles. If I were to fix it, I would restrict the position to this range - not sure if this was your intention.

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

Re: [1.1.104] Crash when camera UI elem tries to render position beyond edge of valid coordinates

Post by nnotm »

That may have been poor choice of words, by "valid coordinates" I meant coordinates that are in the range of the 24+8 bit number used to store the coordinates.

You probably don't need to do anything then, since the crash does not happen within 2^20 tiles of the origin.

Edit: Actually I made a mistake in the report by using 2^31-1 where I meant to use 2^23-1, since 2^31-1 is far outside the range of that number type, rather than just far outside the playable area. Either way, it's outside of 2^20.

Post Reply

Return to “Won't fix.”