ID:169800
 
hey, on a projest I have been working on for a long time now, suddenly it developed a glich where that after 2 logins the save file currupted, then gnerated an infine loop of longins (and froze the game). I have been useing:
login:
X(savefile) >> src
logout
X(savefile) << src

this is makeing it very hard to play my game, HELP!
An infinite loop of logins is happening because you need a special mob type for when you first log in. You need to override that Login() to do chracter creation or loads, while the regular mob/Login() does not.

Every time a client changes mobs, Login() is called. Whenever a mob with a key is loaded from a savefile, the client with that key immediately logs into that mob.

Lummox JR
In response to Lummox JR (#1)
uh oh. well there is a problem, I have a starting mob type (Named "person") and that is where (logisticly) the login proc is called and new mob loaded. I was able to rework to code so that I have invividal player save files and it now just gives an error evertime someone logs on, not as bad as before, but still anoying. well here is the new code:

person//You
New()
src.loc = locate(125,99,1)
Login()
var
X as mob
var/savefile/F = new("[usr.key].sav") //define which savefile to load from
if(fexists(F["[usr.ckey]"]))
F["[usr.ckey]"] >> X //load the info
for(var/mob/Y in world)
if(Y.name==usr.key)
X = Y
X = src.client
src << "[news]"
if(src.client)
loc = locate(125,99,1)
world << " [src] joins!"
fight = 0
else
del(src)
Logout()
var/savefile/F = new("[src.ckey].sav")//create the save file
F["[src.ckey]"] << src // write to the save file
world << "[usr] logs out!"
del(src)

well that got trashed in the pasteing, is there a trick to posting code?
In response to Lizarus (#2)
Lizarus wrote:
well that got trashed in the pasteing, is there a trick to posting code?

Put the code in dm tags
<> put dm in that
Your code
<> put /dm in that
In response to Almasy (#3)
Or in other words:

<dm>
*code*
</dm>
In response to Lizarus (#2)
Ah, then the problem here is that you implemented saving in /mob/person, which should never save. Saving should be done in regular mobs instead when they log out, and then you need to override Logout() for /mob/person to do absolutely nothing except move the old mob to null.

Lummox JR
In response to DeathAwaitsU (#4)
so now it is
    person//You
New()
src.loc = locate(125,99,1)
Login()
var
X as mob
var/savefile/F = new("[usr.key].sav") //define which savefile to load from
if(fexists(F["[usr.ckey]"]))
F["[usr.ckey]"] >> X //load the info
for(var/mob/Y in world)
if(Y.name==usr.key)
X = Y
X = src.client
src << "[news]"
if(src.client)
loc = locate(125,99,1)
world << " [src] joins!"
fight = 0
else
del(src)
Logout()
world << "[usr] logs out!"
del(src)