ID:139318
 
Code:
loging proc
Login()
..()
world<<"INFO: [key] has joined the server"
//simple alert proc asking if they want to load or creat a player. This calls the load proc or the create proc

Logout()
world<<"INFO: [src]([key]) has left the server."
del(src)
//I've also tried this with ..() at the end but for some reason that causes the players mob to stay in the game for some reason.

//loading...
if(fexists("Players/[src.key].sav"))
var/savefile/F = new("Players/[src.key].sav")
Read(F)
loc=locate(xco,yco,zco)
src.cansave=1
src.save()
world<<"INFO: [src] ([key]) has loaded their character"


//saving...
if(src.cansave)
var/savefile/F = new("Players/[src.key].sav")
src.xco = src.x
src.yco = src.y
src.zco = src.z
Write(F)


Problem description:
My players' savefile are continuously becoming corrupt. When they load their character it says (forAosuke)

INFO: Aosuke () has left the server.
INFO: Aosuke has joined the server.
INFO: Aosuke (NASHIE) has loaded their character.


every time this happens it seems to bog down the server and then the client that is loading their character gets disconnected from the game.


Should I be using .=..() instead of ..() and if so then which portion should I be using it?

EDIT: I may have fixed it, I wont know until tomorrow so please, any suggestions are still welcome
As a side effect of reading a savefile, the client will be disconnected from their current mob. This is a result of the savefile creating a new mob for the client, and then moving them over to it. The issue, then, is that you are conflating "Login()" with "a player has connected to my sever". They are not the same, as the Reference will tell you.

If you want something to occur ONLY when a player connects to your server, you either need to put it in client/New(), or put it in the Login() procedure for a mob subtype which is ONLY used for players newly connecting to the server.

Furthermore, you should not be calling Read() or Write() directly, as it results in mangled savefiles and unpredictable behavior, as you now have. You should instead be using the << and >> savefile operators, like so:

client/New()
if(fexists("[key].sav"))
var/savefile/F = new("[key].sav")
F["mob"] >> mob
return ..()

client/Del()
var/savefile/F = new("[key].sav")
F["mob"] << mob

mob/Write(var/savefile/F)
..()
// Any special processing required to save a mob goes here, like so:
F["x"] << x
F["y"] << y
F["z"] << z

mob/Read(var/savefile/F)
..()
// Any special processing required to load a mob goes here, like so:
loc = locate(F["x"],F["y"],F["z"])
In response to Garthor
All right then, just to kind of let you know the save system I was using was from an old project I had that I never really had a problem with, I didn't think adding so much to it would cause any issues so I didn't realize the issue. It's good to know that it wasn't because of my current knowledge of a coder but because I was under the assumption that my prior knowledge as a coder was correct. Four years has taught me a lot and I've learned something else today. Thanks.