ID:263748
 
Code:
mob/player/Logout()
var/obj/item/CTF = /obj/item/accessory/CTF_Flag
if(src.housestuff != null)
src << "Saving your house layout."
for(var/obj/item/furniture/f in world)
if(locate(f) in src.housestuff)
f.Sloc = f.loc
del f
break
for(var/obj/house/h in world)
if(locate(h) in src.housestuff && h.owner == src.name)
h.Sloc = h.loc
del h
break
if(src.Teamcolor != null)
if(src.Teamcolor == "Red")
RTP -= 1
CTF_players -= 1
src.overlays = list()
if(locate(CTF) in src.contents)
CTF.loc = locate(93,118,3)
world << "A spot has opened up in the Red team!"
if(src.Teamcolor == "Green")
GTP -= 1
CTF_players -= 1
src.overlays = list()
if(locate(CTF) in src.contents)
CTF.loc = locate(93,118,3)
world << "A spot has opened up on the Green team!"
src.JCTF = 0
Teamcolor = null
src.LI = 0
src.runwalk = 0
src.Sdir = src.dir
src.overlays = null
src.guard = 0
src.verbs -= /mob/special/verb/Leave_CTF
src.isdef = 0
src.moved = 0
src.is_struck = 0
src.cooldown = 0
src.Judgement = 0
src.HasItUp = 0
src.killer = null
src.attacker = null
src.allowedby = null
src.allowenter = null
src.HPmeter1 = null
src.MPmeter = null
src.EXPMeter = null
src.Mmeter = null
src.Smeter = null
src.Celesmeter = null
world << "<font color = blue>[usr] has logged out.</font>"
var/L = locate(typesof(/obj/item/Estone) in src.contents)
if(L)
for(var/obj/item/Estone/E in src.contents)
E.loc = src.loc
break
if(src.client)
src.client.base_SaveMob()
del(src)
return ..()

else
var/L = locate(typesof(/obj/item/Estone) in src.contents)
if(L)
for(var/obj/item/Estone/E in src.contents)
E.loc = src.loc
break
world << "<font color = blue>[usr] has logged out.</font>"
src.JCTF = 0
Teamcolor = null
src.LI = 0
src.runwalk = 0
src.Sdir = src.dir
src.guard = 0
src.isdef = 0
src.verbs -= /mob/special/verb/Leave_CTF
src.moved = 0
src.overlays = null
src.is_struck = 0
src.cooldown = 0
src.Judgement = 0
src.HasItUp = 0
src.firstlogin = 0
src.arenatype = null
src.killer = null
src.attacker = null
src.allowedby = null
src.allowenter = null
src.HPmeter1 = null
src.MPmeter = null
src.EXPMeter = null
src.Mmeter = null
src.Smeter = null
src.Celesmeter = null
if(src.client)
src.client.base_SaveMob()
del(src)
return ..()

mob/login
base_save_allowed = 0
New()
spawn(3000)
src.Logout()
..()
mob/player
base_save_allowed = 1
New()
..()
spawn(600)
while(src)
if(!src.client)
del src
sleep(300)


mob/login/Logout()
src.HasItUp = 0
src.base_save_allowed = 0
del src
..()
mob/login/Login()
..()
src.HasItUp = 0
if(src.key in Banned)
src << " You are banned!"
del(src)
return
world << "<font color = blue>[src] has logged in"
src << sound('Titlescreen2.ogg',1)
src.loc = locate(43,74,1)
src.client.show_verb_panel = 0
src.paralyzed = 1
src.HasItUp = 0
spawn(3000)
src.Logout()

mob/player/Login()
src.HasItUp = 0
if(src.Ban)
src << " You are banned!"
src.Logout()
return
if(src.client.Ban)
if(!(src.key in Banned))
src.client.Ban = 0
else
src << " You are key banned!"
src.Logout()
return
if(src.housestuff)
src << "Loading your house layout."
for(var/obj/item/furniture/f in src.housestuff)
var/obj/item/furniture/i = new f.type
i.loc = f.Sloc
break
for(var/obj/house/h in src.housestuff)
var/obj/house/p = new h.type
p.loc = h.Sloc
break
if(src.gainatk)
src.Attack -= src.gainatk
src.gainatk = 0
if(src.gaindef)
src.Defense -= src.gaindef
src.gaindef = 0
if(locate(src.Guild) in disbanded)
src << "<font color = lime>[src.Guild] was disbanded while you were logged out.</font>"
src.Guild = null
src.GS = null
src.GR = null
spawn()
src.SGV()
src.LI = 1
src.sight&=~BLIND
if(src.JCTF || src.Teamcolor)
src.Restore_Stats()
spawn(10)
src.Create_HUD()
spawn(20)
src.HUD_Check()
spawn()
src.Call_Ailement()
spawn()
src.Regive_GM()
spawn(20)
src.Unstick_vars()
spawn(20)
src.Regain_Fatigue()
spawn()
src.Readd_Overlays()
spawn()
src.Hair_Check()
spawn()
src.Load_Stuff()
spawn()
src.Add_Hair()
spawn()
if(src.isceles)
src.Drain_Celes()
return ..()


Problem description:
Can anyone see anything in there that could possibly cause some players to revert to previous saves when another one logs in? I've checked every single mob related var and changed ones related to other mobs (mob to mob) ones to tmp so they don't save. None of the vars I use are referenced to players either (IE saving the attacker to the players as the player itself instead of the name)
Besides a server crash, which will not be able to call mob.Logout(), another way a "rollback" can occur is if something had a mob reference loaded, that mob referenced being older than the latest mob (meaning it saved the mob reference).

Try making any variable that holds atoms, particularly any mob references, as a /tmp variable so it is unsavable.
In response to GhostAnime
I have, yet it still get rollback.
Simple truth: Your mob has a reference it shouldn't save with. Most likely that belongs to the mob itself. You haven't actually shown what any of the mob vars are, and I bet one of those is an atom.

If it's not a mob var, it could be a var belonging to an obj in inventory, too. That's less common but not out of the realm of possibility.

I should point out that you have some broken code anyway in your post:

if(locate(h) in src.housestuff && h.owner == src.name)


You need parentheses around the first part of that if, since the in operator has extremely low precedence. Of course, this begs the question why you're using those locate() statements in the first place. Why are you looping through all furniture and all houses in the world instead of looping through the housestuff list?

And is housestuff an actual list of objects belonging to that player? If so, I think you've got a good suspect on the rollback right there.

Lummox JR
In response to Lummox JR
Lummox JR wrote:
Simple truth: Your mob has a reference it shouldn't save with. Most likely that belongs to the mob itself. You haven't actually shown what any of the mob vars are, and I bet one of those is an atom.

The only variable that is an atom is the HUB meter reference, but that is turned to null at logout.

If it's not a mob var, it could be a var belonging to an obj in inventory, too. That's less common but not out of the realm of possibility.

Upon further inspection of my ownership procedures, I ran across a single line that saved the owner as a reference, and did it to all furniture. It is possible that this was the cause, but we'll see.

I should point out that you have some broken code anyway in your post:

if(locate(h) in src.housestuff && h.owner == src.name)

You need parentheses around the first part of that if, since the in operator has extremely low precedence. Of course, this begs the question why you're using those locate() statements in the first place. Why are you looping through all furniture and all houses in the world instead of looping through the housestuff list?

Just as a precaution. Prior to doing it as I am now, I had cases where players would end up without furniture that they had acquired because something prevented it from being added to the players housestuff variable. So I have it loop through all furniture in the world just to be sure that it doesn't skip out over anything, instead of just checking the players house stuff variable.
In response to Pyro_dragons
Pyro_dragons wrote:
Upon further inspection of my ownership procedures, I ran across a single line that saved the owner as a reference, and did it to all furniture. It is possible that this was the cause, but we'll see.

That sort of thing is a very easy way to cause rollback. You should be keeping track of the owner's key, or the owner's unique character name, instead.

You need parentheses around the first part of that if, since the in operator has extremely low precedence. Of course, this begs the question why you're using those locate() statements in the first place. Why are you looping through all furniture and all houses in the world instead of looping through the housestuff list?

Just as a precaution. Prior to doing it as I am now, I had cases where players would end up without furniture that they had acquired because something prevented it from being added to the players housestuff variable. So I have it loop through all furniture in the world just to be sure that it doesn't skip out over anything, instead of just checking the players house stuff variable.

It's pretty moot because the way you're handling those loops, you're still looking to see if the item is included in that list. If it's not, it's just as skipped as it was before. So you've taken the long way around for no reason.

Lummox JR
In response to Lummox JR
Lummox JR wrote:
Pyro_dragons wrote:
Upon further inspection of my ownership procedures, I ran across a single line that saved the owner as a reference, and did it to all furniture. It is possible that this was the cause, but we'll see.

That sort of thing is a very easy way to cause rollback. You should be keeping track of the owner's key, or the owner's unique character name, instead.

It was supposed to and does keep track via the character name, but I had accidentally delete or forgot to add the .name after usr.