ID:143704
 
I could have sworn this was working properly yesterday but here we go..

Removed
It seems your problem is that you're loading under both Load() and Save(). For Save(), I believe something like this should work:

var/savefile/mySave=new("[src.name].Mail")
mySave["Messages"] << src.mcontents


You also might want to make it a procedure so you can call it when you need it, instead of having those multiple lines of redundant code.
In response to Volte
Yeah those verbs are just temporary untill I can get it working 100%. Shortly afterposting this I realized my Save() was the same, but regardless...It still doesnt work. I know it's saving properly because I added a new verb where you can see the contents of the save. It just wont load for some reason here's what I have now:

Removed
In response to Dession
Copied your code and fixed it (at least the list saving part. Changes you see, is because of some weird sensitivity with lists. :/)
mob
player
var
dblclicked = 0//Keeps track of the players clicks
tmp/checkingmail = 0//Keeps track of the mail statpanel, temporary variable means it is not saved
list/mcontents = new()//The users mail
list/addresses = new()//Stores all the addresses a player has
obj/mailicon//Stores the mail HUD icon
newmail = 0//Keeps track of having new mail or not

verb
New_Mail()
src.addresses.Add(src)
var/mob/player/P = input("Who would you like to send a mail to?") in src.addresses + "Cancel"
if(!P || P == "Cancel") return
var/obj/notitems/Mail/Mail = new
Mail.subject = input("Subject:") as text
if(!Mail.subject) Mail.subject = "No Subject"
Mail.body = input("Body: \[No HTML. Leave blank to cancel\]") as message
if(!Mail.body)
del(Mail)
return
Mail.sender = src
Mail.name = "[Mail.subject] from [Mail.sender]"
if(P in world)
P.mcontents.Add(Mail)
src << "<b>You have sent [P] mail.</b>"
P << "<b>You have new mail.</b>"
if(!P.newmail)
P.newmail = 1
P.mailicon.icon_state = "new mail"
else
if(fexists("saves/[P]/Mail.dession"))
var/list/mailstuff = new()
var/savefile/F = new("saves/[P]/Mail.dession")
mailstuff.Add(F["/Mail"])
mailstuff.Add(Mail)
F["/Mail"] << mailstuff
F["NewMail"] << 1
else
var/savefile/F = new("saves/[P]/Mail.dession")
F["/Mail"] << Mail
F["NewMail"] << 1
src << "<b>You have sent [P] mail.</b>"
Save()
var/savefile/F = new("saves/[src]/Mail.dession")
F["/Mail"] << src.mcontents

DelMail()
src.mcontents = new()

Load()
if(fexists("saves/[src]/Mail.dession"))
var/savefile/F = new("saves/[src]/Mail.dession")
F["/Mail"] >> src.mcontents
SaveFile()
var/savefile/F = new("saves/[src]/Mail.dession")
input(src,"","",F.ExportText("/")) as null|message
AddHud()
src.AddHUD()
Login()
if(fexists("saves/[src]/Mail.dession"))
var/savefile/F = new("saves/[src]/Mail.dession")
F["/Mail"] >> src.mcontents
if(F["NewMail"])
src << "<b>You have new mail.</b>"
src.newmail = 1
else src.newmail = 0
Logout()
if(src.mcontents)
var/savefile/F = new("saves/[src]/Mail.dession")
F["/Mail"] << src.mcontents
else if(!src.mcontents && fexists("saves/[src]/Mail.dession"))
fdel("saves/[src.name]/Mail.dession")
del(src)
In response to Dession
Not sure what to tell you -- this local test ran fine:

mob
var
list/mcontents=new()

obj
mail
var
subject
message



mob
verb
SaveIt()
var/obj/mail/myMail = new
myMail.subject = "Subject is here"
myMail.message = "This is a test message."
mcontents.Add(myMail)
var/savefile/F = new("saves/[src]/Mail.dession")
F["Mail"] << mcontents
src << "Saved."
LoadIt()
var/savefile/F = new("saves/[src]/Mail.dession")
F["Mail"] >> mcontents
for(var/obj/mail/M in mcontents)
src << "Mail subject: [M.subject]"
src << "Mail body: [M.message]"


You also may want to change this:

        Logout()
if(src.mcontents)
var/savefile/F = new("saves/[src]/Mail.dession")
F["Mail"] << src.mcontents
else if(!src.mcontents && fexists("saves/[src]/Mail.dession"))
fdel("saves/[src.name]/Mail.dession")
del(src)


src.mcontents is going to return true, because the list exists. You're probably looking for src.mcontents.len, which is the length of the list (though that probably isn't related to this problem, it will help you with a few head-scratches down the road).

I can't see the problem here -- I don't know if it's just because I'm not seeing it, or the fact that looking at big blocks of code that I didn't write like this makes my head hurt. Are you sure the problem isn't elsewhere?


In response to Volte
I have no idea why, but I took out it loading in Login() and it works 100%. Then I put the Login() loading back and it still wouldn't load, even when pressing load. So I guess the Login() messes with it or something. But yeah I fixed it now and thanks for the help.