ID:264157
 
Code:
client/New()
var/client_file = Import()
if(client_file)
var/savefile/F = new(client_file) //the line in question
F >> src.mob //read the player's mob
..()


Problem description:
After hosting for a bit, this run time error pops up:

proc name: New (/client/New)
source file: procs - save load system.dm,4
usr: null
src: Bloodyest1 (/client)
call stack:
Bloodyest1 (/client): New()


I keep Debug Mode on to get more information during run times, but this one doesn't give too much information. I'm not entirely sure why it occurs, but it goes on for a while and then, at least in one instance, crashed Dream Daemon itself.

Could it be extremely old save files? Or is the above flawed in some very real way?

What does client_file look like? thats probably your problem.
In response to Quiet Screams (#1)
Care to elaborate or are you just guessing?
Devourer Of Souls wrote:
Code:
> client/New()
> var/client_file = Import()
> if(client_file)
> var/savefile/F = new(client_file) //the line in question
> F >> src.mob //read the player's mob
> ..()
>


Problem description:
After hosting for a bit, this run time error pops up:

proc name: New (/client/New)
> source file: procs - save load system.dm,4
> usr: null
> src: Bloodyest1 (/client)
> call stack:
> Bloodyest1 (/client): New()


I keep Debug Mode on to get more information during run times, but this one doesn't give too much information. I'm not entirely sure why it occurs, but it goes on for a while and then, at least in one instance, crashed Dream Daemon itself.

Could it be extremely old save files? Or is the above flawed in some very real way?

Well, i found this a while ago in an old demo i once used for a game, i hope it would be some use to you.

mob
proc
saveclient()
var/savefile/F = new()//make a new one
hash=CalculateSavefileHash()
F["usr"] << src
client.Export(F)


/* Below is the code for loading the saved file */


client
proc
importsave()
var/savefile/client_file = new(Import())
if(client_file)
client_file["usr"] >> mob
src << "Import Finished. Checking save. And logging in."

return ..()


mob/verb
saveinport()
set name = "Import save"
set category = "Other"
src << "Importing Save."
spawn()client.importsave()

mob/proc/CalculateSavefileHash()
var/secret="bnjldfgsdfremzsa"
return "[secret]_[maxpowerlevel/maxki]_[key]_[name]"

mob/var/hash=""

mob/Write(savefile/S)
hash=CalculateSavefileHash()
.=..()

mob/Read(savefile/S)
.=..()
if (hash!=CalculateSavefileHash())
src << "Save bad either edited or to old."
sleep(5)
del(src)


i uh, edited it a bit because there was usr abuse in it :(

In response to Devourer Of Souls (#2)
Well its an educated guess, a hypothesis but heres my reasoning:
  source file: procs - save load system.dm,4

This means the error is in 'procs - save load system.dm'
Line 4

Assuming this is the begining of the file:
client/New()
var/client_file = Import()
if(client_file)
var/savefile/F = new(client_file) //the line in question
F >> src.mob //read the player's mob
..()

The 4th line is:
var/savefile/F = new(client_file) //the line in question


You defined a var, F which isn't the problem, otherwise it wouldnt have compiled. the new() proc is fine but the var thats being created with new() could be anything. So if you showed me what it is, I'll take a look at it and go from there.
In response to Quiet Screams (#4)
It's a file retrieved by client.Import(). Indeed, we should see the code used to earlier Export() it, because the file might be invalid as a savefile.
In response to Kaioken (#5)
It's very old code, but the weird thing is that this is happening to keys on which people have never joined the game. I changed the code around a bit for the loading, but it seems it's still sticking around;

client/New()
var/savefile/F = new(Import()) // This is now the line that gives the error.
if(F)
F["usr"] >> mob //read the player's mob
..()


mob/verb/save()
set desc = "Save your character."
if(SwapMaps_Find("[src.key]"))
SwapMaps_Save("[src.key]")
// A bunch of hashing here.
src.useruniquecode="[temp4]"
var/savefile/F = new/savefile()//make a new one
F["usr"] << src
src.client.Export(F)
src << output("<b>[Get_Realtime()]</b> - Character Saved","server_output")


By the way, I've been waiting for you to come and save the day. :p
In response to Devourer Of Souls (#6)
i have a feeling it's something with BYOND because it doesn't even work on the game that it was used on anymore(it worked fine before).
In response to Axerob (#7)
I'm not sure either. It very well could be, in which case I would be happy if Lummox or someone could help.

Another odd development when Guests try to connect.

proc name: New (/client/New)
source file: procs - save load system.dm,2
usr: null
src: Guest-1238238172 (/client)
call stack:
Guest-1238238172 (/client): New("/?byondcert=b1454f0907d7f7fcb7...")


It's still around, either way, which is sad. If Lummox happens to glance over this post, could you please offer some insight?
In response to Devourer Of Souls (#6)
Your old implementation (the one from the DM Reference) was better. <_<; Anyway, try adding in debug info, as it should technically work. Looks like you're not getting a correct value from Import(), try and check what it is:
var/savefile/F = src.Import()
if(F)

src << "isfile([isfile(F)]) value:{[F]}"
else src << "no savefile"


If all is well, you should get an output like this:
isfile(1) value:{savefile_name_or_path}"
Not sure about how isfile() actually handles this, it should detect this file like any resource file and return 1 (if all's well) but for the other value, it can be normal to get a path to the BYOND program directory's cache folder.
In response to Devourer Of Souls (#6)
Devourer Of Souls wrote:
It's very old code, but the weird thing is that this is happening to keys on which people have never joined the game.

This gives me the creeping suspicion that you're not accounting for null, which is a potential value returned by client.Import when there is no file to offer to the calling proc.
In response to Mobius Evalon (#10)
He accounted for it in his initial code (see first post), which had the same problem.
In response to Kaioken (#9)
Using this debugging code, and on your suggestion that the reference's version is better;

client/New()
var/client_file = src.Import()
if(client_file)
world.log << "isfile([isfile(client_file)]) value:{[client_file]}"

var/savefile/F = new(client_file) // This is the line that crashes.
F["usr"] >> mob //read the player's mob
else
world.log << "No savefile for [src]"
..()


Here is said debug information for the past twenty minutes. It's weird. The 'isfile(1) value:{36649.sav}' are all legitimate log ins, and you'll notice that we get 'isfile(1) value:{}' just before the procedure crashes.

Logging in...connected
Logged in as Devourer Of Souls.
Thu Aug 07 23:07:11 2008
World opened on network port 1703.
Welcome BYOND! (4.0 Version 424.993)
BYOND hub reports port 1703 can be reached by players.
isfile(1) value:{36649.sav}
No savefile for Scelus Sceleris
No savefile for DawnTiger
isfile(1) value:{savefile}
isfile(1) value:{36649.sav}
isfile(1) value:{}
proc name: New (/client/New)
source file: procs - save load system.dm,6
usr: null
src: Geintz (/client)
call stack:
Geintz (/client): New()
isfile(1) value:{}
proc name: New (/client/New)
source file: procs - save load system.dm,6
usr: null
src: Gold92 (/client)
call stack:
Gold92 (/client): New()
isfile(1) value:{36649.sav}
isfile(1) value:{}
proc name: New (/client/New)
source file: procs - save load system.dm,6
usr: null
src: Keiko Seisha (/client)
call stack:
Keiko Seisha (/client): New()
isfile(1) value:{}
proc name: New (/client/New)
source file: procs - save load system.dm,6
usr: null
src: Geintz (/client)
call stack:
Geintz (/client): New()
isfile(1) value:{}
proc name: New (/client/New)
source file: procs - save load system.dm,6
usr: null
src: Kvothe (/client)
call stack:
Kvothe (/client): New()
In response to Devourer Of Souls (#12)
Weird indeed, it's a resource file but it seems it may be invalid. Do you have access to the savefile in question that triggers this (ie get the physical file manually and check it out instead of trying to get it from Export())? Perhaps indeed it's an old one generated some time ago, and is corrupted in one way or another. You could verify its contents by quickly using the savefile's ExportText() proc.
In response to Kaioken (#13)
Unfortunately, I do not, and I no longer suspect old save files to be the case simply because these keys are not ones which have had access to the game, nor saved a file inside of it. That was clarified to me yesterday when someone who was having trouble logging in could not connect to the game with a key they had just recently made.