genplanundersterrain()
for(var/celestial/planet/P in world)
genplanunderterrain(P)
genplanunderterrain(var/celestial/planet/O)
if(O.name!="volcanic" && O.name!="temperate") return
var/max=O.pMaxZ-1
var/min=O.pMinZ
for(var/iz=max,iz>=min,iz--)
for(var/ix=1,ix<=world.maxx,ix++)
for(var/iy=1,iy<=world.maxy,iy++)
var/a=text2path("/turf/land/dirt")
new a(locate(ix,iy,iz))
sleep(world.tick_lag)
genplanundersores()
for(var/celestial/planet/P in world)
genplanunderores(P)
genplanunderores(var/celestial/planet/O)
if(O.name!="temperate") return
var/max=O.pMaxZ-1
var/min=O.pMinZ
for(var/iz=min,iz<=max,iz++)
for(var/ix=1,ix<=world.maxx,ix++)
for(var/iy=1,iy<=world.maxy,iy++)
var/b=text2path("/obj/harvestable/Dirt")
new b(locate(ix,iy,iz))
sleep(1)
Problem description:
Okay so let me explain what's going on here. In my project, every planet has 5 z levels. The first z level is for the surface, the other 4 z levels is for below the surface, which is particularly used for digging, mining and/or underground construction.
Currently only temperate/volcanic planets spawn a surface and underground terrain. Only temperate planets spawn objects for dirt (and eventually ores). This is to make it easier for me to see the effects immediately.
So I have a 500x500 map, and that means that one million 'things' need to be spawned for each underground z level set per planet. Currently, I run two passes. One pass for turfs, the second pass for objects. My problem is that objects take 3-4x the amount of time to generate (probably more) VS turfs. Due to this, a generation proc wont cause a loop check problem if it's with turfs, but as soon as I use objects I start seeing them. I don't have a full understanding of why objects are so much more intensive, but I've been assuming there's much more information attached to them.
Should I rig turfs to use them for what I want and gain a generation speed increase (they don't need to move o.O)? Or is there something else I can be doing to make this overall better?
I cannot use pre-made maps. The entire universe (space, suns, planets, planet surface, planet underground) is generated at run-time.
P.S. I'm using a loading screen so I don't expect this process to go all that fast. It's updated periodically throughout the process to show where we are in the generation stages. Currently universe generation takes up to 2 minutes to complete (per planet that has underground objects spawned).
P.S.P.S. I'm using text2path because those entries will be dynamic to each planet later.