ID:318642
 
BYOND Version:493
Operating System:Windows server 2003 Web edition
Web Browser:Firefox 10.0.2
Applies to:Dream Daemon
Status: Unverified

Thus far we've been unable to verify or reproduce this bug. Or, it has been observed but it cannot be triggered with a reliable test case. You can help us out by editing your report or adding a comment with more information.
Descriptive Problem Summary:
On Ganing's Byond Martial Arts I get a constant error message from a cache.
Numbered Steps to Reproduce Problem:
Not sure about reproduction. As soon as I start hosting it goes.
Code Snippet (if applicable) to Reproduce Problem: BYOND Error:(Sfile.cpp,1138) C:\Documents and Settings\Administrator\My Documents\BYOND\cache\27D079C0
BYOND Error:(Sfile.cpp,1138) failed to open file:


Expected Results:
To not have an overflow of errors?

Actual Results:
Its overflowing after about 17 hours I have to stop it and redownload host files.
Does the problem occur: Every time
Every time? Or how often?
In other games? No
In other user accounts? All of mine do that same.
On other computers? I host on a shell.

When does the problem NOT occur? When the game isnt running.

Did the problem NOT occur in any earlier versions? If so, what was the last version that worked? (Visit http://www.byond.com/download/build to download old versions for testing.)
No.
Workarounds:
None known currently.
It could just be the game.
But it's not the game. :P
I'm not certain there's not a significant factor of author error involved. Based on the error message, it looks like you're trying to load a savefile directly from the cache, which doesn't seem like a good idea. Of course without seeing the relevant code I don't know for sure what's going on.
Here is my save system:
mob
proc
Save()
if(src.rank=="")
return
var/savefile/F = new()
F << src
var/savefile/F2 = safe_save(F, "[key]")
src.client.Export(F2)


Here is my load:

mob/proc
NewLoad()
var/savefile/F1 = new(client.Import())
var/savefile/F2 = safe_load(F1)
if(F2)
usr << "Load Successful"
winshow(src,"login",0)
winshow(src,"default",1)
winset(src,"default","alpha=255")
src.Update_Rank()
src.UpdateBars()
src.Update_Who()
F2>>src
else
usr << "HASH HAS FAILED"


Of course there is more to the loading. I used a modified version of Garthor's library. Here is his side:

proc
//proc to make a hash from a text string, end-user should override to be unique
make_hash(var/text)
return md5("[world.hub_password][text]")

//saves the savefile F in a safe format under the specified name. Safe savefile is returned.
safe_save(var/savefile/F, var/name)
var/savefile/F2 = new()
F2["file"] << F
var/hash = make_hash(F2.ExportText("file"))
F2["hash"] << hash
return F2

//loads a savefile saved using safe_save. Readable savefile is returned.
safe_load(var/savefile/F)
//ensure that we have a file where we say we do
var/text = F.ExportText("file")
if(copytext(text,1,14) != ". = filedata(")
return null

//grab the savefile
var/savefile/F2 = new(F["file"])
//check its md5
var/check = F.ExportText("hash")
var/hash = make_hash(text)
if(check != {". = "[hash]"\n"})
return null

//file passes the check, so return it
return F2


I also save and load scoreboards at the beginning of the game. Here's the code for that: (It's a library as well)

    scoreboard_handling(action)
if(action=="save")
var/savefile/s=new("savefiles/server/scoreboard2.sav")
s["scoreboard"]<<scoreboard
if(action=="load")
if(fexists("savefiles/server/scoreboard2.sav"))
var/savefile/s=new("savefiles/server/scoreboard2.sav")
s["scoreboard"]>>scoreboard
scoreboard=sort_scoreboard()


Do you see a problem Lummox?
I think the problem may be intrinsic to Garthor's library. He's storing a savefile in another savefile, which turns it into a cache entry. At that point the "unsafe" savefile really needs to be made local to the server (via fcopy() perhaps) so it can be read normally.
So do you mean like this?
        Save()
if(src.rank=="")
return
var/savefile/F = new()
F << src
var/savefile/F2 = fcopy(F,safe_save(F, "[key]"))
src.client.Export(F2)
No, you'd want the server to still export the files created via the library, I think; the problem is in that the server is trying to read the files created by the library, and at least in some cases it looks like the cache ref has expired. So I think you need to make a local copy of the savefile on the server end--I'd say it's save to clean those up when the server starts up, or when their owner is not logged in.
Yeah, you're going out of my range on how far I am with savefiles and whatnot.
Lummox JR changed status to 'Unverified'