ID:264421
 
Code:
mob/proc/FillMine()
set background=1

var/turf/T=pick(/turf/mine/stone/Slate, /turf/mine/stone/Chert,/turf/mine/stone/Chalk,/turf/mine/stone/Schist,/turf/mine/stone/Sandstone,/turf/mine/stone/Limestone)


var/xx
var/yy
var/xsize=1
var/ysize=1
var/zz=2
var/typ=1
for(zz=2,zz<=5,zz++)
for(xx=1,xx<=1000,xx+=xsize)
for(yy=1,yy<=1000,yy+=ysize)
typ=pick(prob(70,1),prob(25,2),prob(5,3))
if(typ==1)
xsize=rand(8,44)
ysize=rand(8,44)
T=pick(/turf/mine/stone/Slate, /turf/mine/stone/Claystone,/turf/mine/stone/Coal,/turf/mine/stone/Diorite,/turf/mine/stone/Gabbro,/turf/mine/stone/Marble,/turf/mine/stone/Granite,/turf/mine/stone/Chert,/turf/mine/stone/Chalk,/turf/mine/stone/Schist,/turf/mine/stone/Sandstone,/turf/mine/stone/Limestone)
for(var/turf/W in block(locate(xx,yy,zz),locate(min(xx+xsize,1000),min(yy+ysize,1000),zz)))
if(T) new T(locate(W.x,W.y,W.z))
if(typ==2)
xsize=rand(6,25)
ysize=rand(6,25)
T=pick(prob(40,/turf/mine/ore/Iron),prob(24,/turf/mine/ore/Copper),prob(24,/turf/mine/ore/Tin),prob(2,/turf/mine/ore/Gold),prob(4,/turf/mine/ore/Silver),prob(4,/turf/mine/ore/Mithril),prob(1,/turf/mine/ore/Platinum),prob(1,/turf/mine/ore/Adamantite))
for(var/turf/W in block(locate(xx,yy,zz),locate(min(xx+xsize,1000),min(yy+ysize,1000),zz)))
if(T) new T(locate(W.x,W.y,W.z))
if(typ==3)
xsize=rand(1,3)
ysize=rand(1,3)
T=pick(prob(6,/turf/mine/precious/Diamond),prob(13,/turf/mine/precious/Agate),prob(12,/turf/mine/precious/Citrine),prob(8,/turf/mine/precious/Emerald),prob(10,/turf/mine/precious/Onyx),prob(20,/turf/mine/precious/Quartz),prob(8,/turf/mine/precious/Ruby),prob(8,/turf/mine/precious/Sapphire),prob(15,/turf/mine/precious/Sard))
for(var/turf/W in block(locate(xx,yy,zz),locate(min(xx+xsize,1000),min(yy+ysize,1000),zz)))
if(T) new T(locate(W.x,W.y,W.z))


Above is the code, here is the error message...

runtime error: BYOND BUG: bad turf
proc name: FillMine (/mob/proc/FillMine)
source file: water.dm,454
usr: Minsc (/mob/PC)
src: Minsc (/mob/PC)
call stack:
Minsc (/mob/PC): FillMine()
Minsc (/mob/PC): GenWorld(Minsc (/mob/PC))
Minsc (/mob/PC): GenerateWorld()

Here is the exact line of code it points too,

if(T) new T(locate(W.x,W.y,W.z))

This error is highly random, sometimes it happens, sometimes it does not.
The error message is one of the most useless I have ever seen, what the hell is a bad turf? Why is it bad? What makes it bad? How the hell can it be fixed?

Someone explain this to me, because this has to be the most annoying error I have ever encountered.

Strangely enough, if I remove all areas from the world (except for /area), this error never happens, ever.
Since W is already a turf, why are you trying to use locate on it's coordinates? Why not just put new T(W)?
Would you mind terribly testing something for me?
I had a similar issue that involved areas, I found that if I left the area at 1,1,1 as /area I didn't get the problem. Try making the areas along the z axis into /area and tell me if you get the same problem.

Along the z-axis: (1,1,1), (1,1,2), .., (1,1, world.maxz)

It's just a hunch I have but it goes hand-in-hand with your odd /area behavior.

Other than that all I can offer is to make sure that you aren't going out of bounds somehow. Output your x,y,z values before the suspect line is executed to see where this is happening, or if you get an error.
In response to Vermolius
Already tested that out, and not on purpose either.
I use 60x60 sized areas, all placed side by side starting at location 200,200,1, finishing at 800,800,1.
The error still occurs.

Also, I am making sure that no turfs outside of bounds are either being checked, or created.

Notice the lines...
for(var/turf/W in block(locate(xx,yy,zz),locate(min(xx+xsize,1000),min(yy+ysize,1000),zz)))
This should make it only check/create turfs upto a maximum x/y position of 1000.

And now I'll ask you something, in the similar case you had, how many different types of area did you have in the world when this similarissue occured?
In response to The Magic Man
I believe it was 5-6.