[1.1.104] LuaForce.chart() area safety check incorrect
Posted: Fri Feb 23, 2024 10:48 pm
When trying to use the LuaForce.chart() API call with a very large high aspect ratio area (for example, 900000x1 tiles), the game fails with the message:
There are two weird things about this:
If we follow this math, the expected amount of ram for a 900000x1 tile area should be:
So the behavior that I would expect is that the game would just fulfill the request, since that amount of ram should easily fit on basically every system.
To locally reproduce this issue:
Code: Select all
Cannot execute command. Error: The given area is too large. A 900096x900096 area would require over 6413 gigabytes of RAM. If you really want to chart that area do it in smaller batches.
- the size of the area reported by the game is more than one chunk longer than the area requested, more specifically, there is a discrepancy of 96 tiles.
- the area that the game reports is a square, even though the chart command was very much non-square. this leads to the game calculating a ram usage amount that is FAR from what it should be.
Code: Select all
min_ram_usage = math.ceil(area_size_x/32) * math.ceil(area_size_y/32) * ( 512 + 32*32*8 )
Code: Select all
min_ram_usage = ceil(900096/32)*ceil(1/32)*8704 = ~223MiB
To locally reproduce this issue:
- create a new savefile with all default settings
- run in the chat. you might have to execute this twice.
Code: Select all
/c game.player.force.chart(game.player.surface,{{0,0},{900000,1}})
