ID:139649
 
Code:
        var/savefile/F3 = new/savefile("savepoints.dat")    // Loads the save points
var/SaveCount = 0
F3["SaveCount"] >> SaveCount
if(SaveCount)
for(var/N = 1;N<=SaveCount;N++)
var/X,Y,Z
var/obj/Misc/SavePoint/O = new()
F3["[N] x"] >> X
F3["[N] y"] >> Y
F3["[N] z"] >> Z
world << "[N] - [X],[Y],[Z]" //testing
O.loc = locate(X,Y,Z)
    var/SaveCount = 0                                    // Saves the savepoints
var/savefile/F3 = new/savefile("savepoints.dat")
for(var/obj/Misc/SavePoint/O in world)
SaveCount++
F3["[SaveCount] x"] << O.x
F3["[SaveCount] y"] << O.y
F3["[SaveCount] z"] << O.z
world << "[SaveCount] - [O.x], [O.y], [O.z]" //testing
F3["SaveCount"] << SaveCount


Problem description:

I've never been all that great with save files. First off, the code compiles and seems to run just fine. I open the world, create a few savepoints and click a verb to save them (second piece of code). When I restart the world, for some reason the X variable for the first savepoint it loads goes missing (null), so that point vanishes from the map. Since the savepoint never makes it to the map, when the world is restarted again it ceases to exist (and therefore isn't saved). The cycle continues over and over as the world is loaded until all the savepoints have effectively disappeared.
What you should probably do instead is just load every SavePoint into a list (probably best to do it in their New() proc), and then just save that list to the savefile. Have the SavePoint's Write() and Read() procs handle saving and loading their location. So:

var/list/savepoints = list()

obj/Misc/SavePoint
New()
..()
savepoints += src
Del()
savepoints -= src
..()

Write(var/savefile/F)
F["x"] << x
F["y"] << y
F["z"] << z
Read(var/savefile/F)
loc = locate(F["x"], F["y"], F["z"])


Saving would then involve just saving the savepoints list itself, and loading would involve just writing F["savepoints"], though you'll get an (incorrect) warning about that, so you can instead do F["savepoints"] >> L, where L is just a throwaway list (don't load into the savepoints list itself, as the list will then contain duplicates).
In response to Garthor
Didn't think about trying to go about it that way. I've been tinkering with it trying to do the workaround you've got and now I can't seem to get any points to load back up. Seems to be a problem with writing/reading the savepoints list. All the files get created and seems like they save, but I have a check in there as you can see below, and returns the length of L as 0. Maybe I'm retarded and overlooking something. File handling has always been a slap in the face for me.

in World/New()
        var/savefile/F3 = new/savefile("savepoints.dat")
var/list/L
F3["savepoints"] >> L
world << "Check - [length(L)]"
var/i = 0
for(var/obj/Misc/SavePoint/O in L)
i++
O.Read(new/savefile("./savepoints/[i].dat"))


in proc/SaveWorld()
    var/savefile/F3 = new/savefile("savepoints.dat")
F3["savepoints"] << savepoints
var/i = 0
for(var/obj/Misc/SavePoint/O in savepoints)
i++
O.Write(new/savefile("./savepoints/[i].dat"))

for(var/mob/M in world)
if (M.GM)
M << "\red World saved."


and the object itself
        SavePoint
New()
..()
savepoints += src
Del()
savepoints -= src
..()
Write(var/savefile/F)
F["x"] << x
F["y"] << y
F["z"] << z
Read(var/savefile/F)
loc = locate(F["x"], F["y"], F["z"])

icon = 'save.dmi'
verb/save()
set src in view(0)
set hidden = 1
usr << "\red Your character has been saved... or would be if this feature was implemented."
In response to Aegiris
        var/i = 0
for(var/obj/Misc/SavePoint/O in L)
i++
O.Read(new/savefile("./savepoints/[i].dat"))


    var/i = 0
for(var/obj/Misc/SavePoint/O in savepoints)
i++
O.Write(new/savefile("./savepoints/[i].dat"))


This is all entirely unnecessary. Read() and Write() are automatically called by the >> and << savefile operators.
In response to Garthor
Got it working with a slightly different approach, but very similar.

Thanks for the help.