ID:1142267
 
When this is called, are all turfs that are originally on the map already existing?

I am running into some situations where sometimes some tile logic isn't working properly when it occurs in turf.New() because things like get_step() return null at first (or some similar situation)... Some code such as

turf/New()
..()
while(world.time <= 0)
sleep(1)
//initialize here


actually initializes as expected...

I'm having troubling figuring out just what has happened before a given turf/New()
Well in the reference for New() it says that by the time the proc is called, the object has already been created at whatever location, with its variables initialized and everything. So, according to that, all turfs should have been created by the time the first New() is called.

I would get around this by manually having a proc loop through the turfs...however I don't see why using New() would cause this issue. Maybe it's a bug?
As far as I can tell, turfs appear on the map one-by-one, and turf.New() is called as they appear. This can cause problems with things like auto-joining, as you're probably aware of.

A decent solution is to just do turf initializing in world/New().
//  for example
world/New()
..()
for(var/atom/o)
o.MapLoaded()

atom/proc/MapLoaded()

This simply makes sure all objects are created and in place before letting them interact with other objects.
In response to Kaiochao
Kaiochao wrote:
As far as I can tell, turfs appear on the map one-by-one, and turf.New() is called as they appear. This can cause problems with things like auto-joining, as you're probably aware of.

A decent solution is to just do turf initializing in world/New().
> //  for example
> world/New()
> ..()
> for(var/atom/o)
> o.MapLoaded()
>
> atom/proc/MapLoaded()
>

This simply makes sure all objects are created and in place before letting them interact with other objects.

Just to clarify, are you suggesting all initializing steps occur in MapLoaded() in your example? Thanks.
Of course...even though the object itself has been fully initialized (excepting your own stuff), the rest of the world has not. Silly me!
In response to FIREking
At least, the initialization steps that take other objects into account should be placed in MapLoaded(). It's just something that's called after the map is completely finished loading. Simple stuff like randomizing a repetitive turf's appearance, which may not have anything to do with external objects, would be fine to be placed in turf.New().