proc
topGenerator()
var/turf/Dirt/origin = new(locate(100,100,1))
for(var/iy=3; iy; iy--)
spawn(-1) Generation(origin)
var/Odir=pick(NORTH,SOUTH,WEST,EAST)
for(var/i=(15+rand(-10,10)); i; i--)
origin = get_step(origin,Odir)
Generation(var/turf/origin)
Problem description:
Every now and again, perhaps 30% of the time I run topGenerator(), it comes up with an error message or two.
runtime error: bad loc
proc name: Generation (/proc/Generation)
source file: generator.dm,26
usr: Guest-3154373468 (/mob)
src: null
call stack:
Generation(Sand (121,100,1) (/turf/Sand))
topGenerator()
topGenerator()
Guest-3154373468 (/client): NewGame()
Guest-3154373468 (/client): NewGame()
runtime error: bad loc
proc name: Generation (/proc/Generation)
source file: generator.dm,26
usr: Guest-3154373468 (/mob)
src: null
call stack:
Generation(Dirt (121,76,1) (/turf/Dirt))
topGenerator()
topGenerator()
Guest-3154373468 (/client): NewGame()
Guest-3154373468 (/client): NewGame()
Now I'm pretty sure this is due to multiple 'entities' of Generation trying to access the same location.
Line 26 is:
var/turf/Dirt/temp = new(location)
and occurs within Generation().
The reasoning for the spawn(-1) is due to the Help Guide saying "If delay is negative, the spawned code is executed before continuing in the main code." though it doesn't seem to help a lot. That said, it is not the cause of the errors as it was only added as a countermeasure to them occurring beforehand.