ID:2556608
 
Code:
mob/proc
Choose_Login()
switch(alert(src,"Make your choice","","New","Load","Exit"))
if("New")
if(fexists("Data/Saves/[key]/[src.ckey]")) if(!Confirm("Do you want to erase your current save?"))
Choose_Login()
return
New_Character()
if("Load")
if(fexists("Data/Saves/[key]/[src.ckey]"))
client.LoadChar()//this is line 37
else
alert("You have no saved characters")
Choose_Login()


client
proc
LoadChar(var/Auto=0)
if(fexists("Data/Saves/[key]/[src.ckey]"))
src<<"Loading..."
var/savefile/F=new("Data/Saves/[key]/[src.ckey]")
F["mob"] >> src.mob
var/version = F["savefile_version"]
if(!version) version = 0


Problem description:
runtime error: Cannot execute null.LoadChar().
proc name: Choose Login (/mob/proc/Choose_Login)
source file: Better Saves.dm,37
usr: (src)
src: Kvng1 (/mob/player)
src.loc: null
call stack:
Kvng1 (/mob/player): Choose Login()
Kvng1 (/mob/player): Login()
Kvng1 (/mob/player): Login()


I don't understand why it is generating this error. To me this implies there is no client attached to the mob but this is called from mob login.
That is strange. What happens if you spawn() Choose_Login() from mob/Login()?
Also wanted to let you know that by writing the whole mob to a savefile you are asking for a whole host of bugs that are hard to track down. Save only the variable you need.
It's not an error that consistently happens. Someone else suggested trying to change it from a mob/proc to a client one so I am giving that a shot.

And what if I wanted to save everything that's not temp or default anyway? What sort of issues specifically would arise or are you just implying its a bad design practice?
It runs fine on my PC, it's only when it is put up to a live game server with 100+ connections that it actually will give the error. It seems to start after 10+ users have connected, so unsure if it is something under load or just has to with installed build or what. The thing that gets me is the inability to replicate it on my end.
src.client or even src has changed somehow. That could happen for any number of reasons but I can't tell just from the code posted above. Perhaps the login code? I would think that somehow mobs are getting switched around.

You're friend is correct too. My code organization (and I think the same applies to many developers) has me put everything that happens before and during character selection as a client process, after which I would switch to mob procedures for everything unless I had code that pertained to the client portion of information specifically, like keypress tracking or GM controls.

I suppose you didn't try spawning it off, but one thing at a time for elusive bugs.


So, here is the reality about saving mobs. It saves everything that has been changed from the default and is not specified by /tmp. This includes icons, but most importantly it includes references to other objects which may themselves contain references and icons, so it can cascade a bit.

These references, however, had lead me to all sorts of bugs in the past, including phantom mobs popping around with no clients controlling them, random loss of controls, frozen characters, permanent access to temporary verbs, and many mishaps due to slight errors in logic or understanding when writing procs and verbs (including confusing usr and src).

Plus, it is simpler to version savefiles without an entire mob in there. Versioning is nice because in the event of a savefile-breaking change in the code, you can choose to have a program run through every savefile on a server and convert them to new formats or convert upon client Login(). Thos is also a way of journaling changes with code itself. This event is rare though.