[0.14.20] Surface creation with invalid autoplace_controls
Posted: Tue Nov 22, 2016 12:54 pm
Adding an invalid autoplace_control to a MapGenSettings object (MapGenSettings.autoplace_controls["NAME"]) causes the program to hang and rapidly increase in RAM size (so much that my whole computer hang for a while)
This code (from my WIP mod) produced the hang/error:
More specifically, these lines were the problem:
There aren't any autoplace_controls defined with those names (the "-page" part shouldn't be there)
The log file doesn't show anything, but I'll include it just in case it's needed.
Computer specs:
OS: Windows 7
Processor: Intel i3-2120
RAM: 8 GB
System Type: 64-bit
This code (from my WIP mod) produced the hang/error:
Code: Select all
function SurfaceData.create(surface, pages)
pages = pages or {}
if type(surface) == "string" then
if game.surfaces[surface] ~= nil then
return false
end
local mapGenSettings = game.surfaces["nauvis"].map_gen_settings
mapGenSettings.terrain_segmentation = "none"
mapGenSettings.water = "none"
mapGenSettings.seed = 0
mapGenSettings.starting_area = "medium"
-- THIS CODE BELOW CAUSES HANG --
for name, _ in pairs(mapGenSettings.autoplace_controls) do
if pages[name] == nil then
mapGenSettings.autoplace_controls[name .. "-page"] = { frequency = "none", size = "none", richness = "none" }
else
mapGenSettings.autoplace_controls[name .. "-page"] = { frequency = "normal", size = "medium", richness = "regular" }
end
end
if pages["water-page"] ~= nil then
mapGenSettings.water = "medium"
end
if pages["no-enemies-page"] == nil then
mapGenSettings.autoplace_controls["enemy-base"] = { frequency = "normal", size = "medium", richness = "regular" }
end
surface = game.create_surface(surface, mapGenSettings)
end
local sd = {}
setmetatable(sd, SurfaceData)
sd.type = "SurfaceData"
sd.name = surface.name
sd.pages = pages
return sd
end
Code: Select all
for name, _ in pairs(mapGenSettings.autoplace_controls) do
if pages[name] == nil then
mapGenSettings.autoplace_controls[name .. "-page"] = { frequency = "none", size = "none", richness = "none" }
else
mapGenSettings.autoplace_controls[name .. "-page"] = { frequency = "normal", size = "medium", richness = "regular" }
end
end
The log file doesn't show anything, but I'll include it just in case it's needed.
Computer specs:
OS: Windows 7
Processor: Intel i3-2120
RAM: 8 GB
System Type: 64-bit