[0.14.20] Surface creation with invalid autoplace_controls

This subforum contains all the issues which we already resolved.
Zinal
Inserter
Inserter
Posts: 28
Joined: Mon Sep 01, 2014 5:42 pm
Contact:

[0.14.20] Surface creation with invalid autoplace_controls

Post by Zinal »

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:

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
More specifically, these lines were the problem:

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
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
Attachments
factorio-current.log
(5.13 KiB) Downloaded 104 times
User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5405
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: [0.14.20] Surface creation with invalid autoplace_controls

Post by Klonan »

Thanks for the report,

This should be fixed in 0.15,
If the issue happens again please make a new bug report
Post Reply

Return to “Resolved Problems and Bugs”