Until I introduce areas to the equation. First I tried to place them at the end of the map generation, I was given "BYOND BUG: Bad turf" errors, along with an error pointing to this section of the code.
for(var/turf/T in block(locate(xx,yy,1),locate(xx+60,yy+60,1)))
if(V) new V(locate(T.x,T.y,1))
However, this problem is random at best. Sometimes it happens, sometimes it does not, it is a 50/50 chance really.
So I tried adding area generation to the start of the map generation process. It worked, but steps that came after, specifically those that generated turfs gave errors such as BYOND BUG: Bad Turf or Bad Loc, pointing to the code...
while(i)
new/turf/ground/Grass(locate(rand(250,550),rand(250,550),1))
i--
So I tried changing it to...
while(i)
T=locate(rand(250,550),rand(250,550),1)
if(T) new/turf/ground/Grass(locate(T.x,T.y,T.z))
i--
It resulted in no error message being given, but the proc does not finish executing, after which the entire map generation process stops (no reported CPU usage), the profiler reports no procs being run either. By using debug messages, it seems the proc stops running at the T=locate(rand(250,550),rand(250,550),1) line of code, and it is not an infinite loop either, as the debug messages after this line (or before) are not being output.
The best part is once this happens, things systematically start failing with BYOND. I cannot open the profiler, the map element stops working (verbs report I am moving around the map, and indeed interactions with the map report so too, but the map just does not change, whatever was on the map before it stopped working stays ecxactly as it was). Shortly after this, BYOND basically crashes.
If I manually place areas in the map editor, this exact same behaviour occurs.
If I remove areas from the process entirely, everything works fine. There is no errors, no problems, the map generator works exactly like it is intended too.
The only problem I can assume it is so far is that there is a lot of areas on the map (the map is 1000x1000, divided into 60x60 areas, but there is a border around the map with no areas, there is a total of 197 different areas on the map, including the border).
I thought maybe it'd be related to any procs the areas had and were possibly running. So I commented them out, and it had no effect at all.
So, anyone think they could explain this, and what is happening? Am I doing something wrong, or is it some sort of BYOND related bug?
Also, locate(T.x,T.y,T.z) is redundant when T is a turf, as it will just return T.