[1.1.104] Crash when camera UI elem tries to render position beyond edge of valid coordinates
Posted: Sun Feb 04, 2024 3:44 am
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.
Edit: fixed typo 2^32 -> 2^23
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}