SaveMap()
if(Saves == 0)
Saves = 6
MapSaves += 1
var/Mobs = list()
var/Objects = list()
for(var/turf/T in Tiles)
for(var/mob/M in locate(T.x,T.y,T.z))
M.LastLoc = M.loc
M.loc = locate(0,0,0)
Mobs += M
for(var/obj/O in locate(T.x,T.y,T.z))
for(var/V in O.vars)
var/variable = V
var/typeof=O.vars[variable]
if(istype(typeof,/atom/))
if(O.LastLoc == null && typeof != T)
O.LastLoc = O.loc
O.loc = locate(0,0,0)
Objects += O
for(var/obj/I in O)
for(var/V in I.vars)
var/variable = V
var/typeof=I.vars[variable]
if(istype(typeof,/atom/))
if(I.LastLoc == null && typeof != T && typeof != O)
I.LastLoc = O
I.loc = locate(0,0,0)
Objects += I
if(O.name == "Rock")
del(O)
T.overlays -= /obj/Misc/Weather/Snow/
T.overlays -= /obj/Misc/Weather/Rain/
var/SaveDir = "map"
if(MapSaves == 3)
SaveDir = "backups"
world << "<font color = teal>Map Backed Up!<br>"
MapSaves = 0
var/find_map = "[SaveDir]/map.sav"
if(length(file(find_map)))
var/savefile/F = new(find_map)
del(F)
var/map_sav = "[SaveDir]/map.sav"
var/savefile/F = new(map_sav)
F["Tiles"] << Tiles
for(var/mob/M in Mobs)
M.loc = M.LastLoc
for(var/obj/O in Objects)
O.loc = O.LastLoc
world << "<font color = teal>Map Saved!<br>"
LoadMap()
var/map_sav = "map/map.sav"
if(length(file(map_sav)))
var/savefile/F = new(map_sav)
F["Tiles"] >> Tiles
world << "<font color =teal>Map Loaded!<br>"
for(var/turf/T in Tiles)
T.overlays = null
if(T.Type != "Dark")
if(Night == 0)
T.luminosity = 1
for(var/obj/Items/Plants/P in block(locate(1,1,1),locate(250,300,1)))
if(P.icon_state == "small stump")
P.overlays = null
P.density = 1
P.opacity = 0
if(P.icon_state == "big stump")
P.overlays = null
P.density = 1
P.opacity = 0
Problem description:
The Map saving and loading seems to work well for a while, until an object with a referance to another object is added to the Tiles list, which stores all turfs that will save. I've tried to make the Save code search the Vars within an atom thats about to be saved for any referanaces to other objects to avoid the following error, but nothing has worked.
runtime error: cannot append to list
proc name: LoadMap (/proc/LoadMap)
source file: World.dm,659
usr: null
src: null
call stack:
LoadMap()
: New()
I've been trying for a very very long time now to fix it, thinking each time I bring a new version of my game out that I had done, only to find its broken and have everyones hard work lost.
Please, any tips, suggestions or any ways to avoid or fix this are most welcome. Thank you.
Those two procs should look like this:
Any special processing you need to do when saving or loading the map should go in the Write() and Read() procedures for the specific objects.
Oh, also: it's really, really dumb to be doing locate(T.x, T.y, T.z). That just gives you T back. You should just replace that damn thing with T... well, if you weren't deleting it anyway.