ID:143242
 
Ok, when the below proc is called, it is -supposed- to save all turfs of the type /turf/build, (because after all the game Im using this in -is- a building game) but for some reason about 1 out of 3 or 4 times it will crash the server, and I dont know why, but I have put it here fully commented so hopefully someone here can help me or give me a better alternative. I -would- save the turfs directly, but for some reason the mapload proc wont let me restore a turf's location because it says you cant edit a constant variable (the turf's x, y, and z locations)... Anyway, please help, I have been struggling with this for a long time..
proc
MapSave()
var/foundobjects=0 //This increases by 1 as it loops through the turfs so it can show the amount
//to the world when its done.
var/savefile/F=new("MapSave")
var/list/L=new/list //The list that will contain the saved things.
for(var/turf/build/A)
if(prob(1)) sleep(1) //throw an occasional sleep in there for every 100 or so items
//just so it doesnt completely freeze...
var/obj/B=new/obj //Since I dont even -think- you can save turfs, since it wont let you
//restore a turfs location on the mapload() proc, I turn them into obj's, then have those
//it objects save the turfs critical information such as its type, and its location, so it
//can use that info to restore a turf of that type at that location when the map is loaded.
B.saved_x=A.x
B.saved_y=A.y
B.saved_z=A.z
B.savetype=A.type //This stores the type of turf to be restored in mapload
B.owner=A.owner //This stores the key of the person who created the turf, well, actually
//not the key, but its A.owner==usr
L.Add(B) //Add it to the list...
foundobjects+=1
F["Objects"]<<L //Put the list and everything in it into the MapSave savefile...
world<<"Map saved<br>[foundobjects] saved (65000 limit before map corruption)."


Maybe you need to check your turf.dmi for an problems?
In response to GrimmJore
That's like checking the map in your glove compartment to fix a problem with your muffler.
In response to GrimmJore
GrimmJore wrote:
Maybe you need to check your turf.dmi for an problems?

Yea I checked all buildable turfs for problems and I couldnt find any that I personally could discern to be causing any problems. I thought of two possibilities, one being that certain turfs that were being saved may have lists in them that were overloading the other list bringing it past the 65535 limit or whatever, but then I found there are no lists at all for turfs. And another was that some turfs being saved had excessive underlays/overlays attached to them, but once removed the crashing still persisted. So Im not really sure... When this code is used to save mobs or objs it works fine, but change it to turfs and you start having problems, so its a little confusing.