calling client.Import() in client.Del() in Developer Help
|
|
Doesn't appear to work for me. Not sure if this is a code problem or a geniune BYOND bug, but I'm treating it as a code problem.
Basically, I want to save player preferences to a client side savefile, loading it at login. Eventually I'll have more than preferences in this savefile, but since I can only have one per client, I want to be ultra-safe and reload (Import) the savefile from disk just before saving back out in client.Del(). Maybe I'll forego that altogether if this doesn't end up working and just keep the savefile in memory while the player is logged in. But here's what I'm trying for now:
mob
Logout()
world.log << "[src].Logout()"
. = ..()
client
Del()
world.log << "Client [src].Del()"
// var/client_file
var/client_file = src.Import()
var/savefile/sf
if (client_file)
sf = new(client_file)
else
sf = new()
sf["/prefs/[src.ckey]"] << "prefs"
world.log << "[src] saving src.prefs in /prefs/[src.ckey]"
src.Export(sf)
del(sf)
. = ..()
world.log << "Called ..()"
Run this and type .logout, I get the following output:
Client Air Mapster.Del()
Air Mapster.Logout()
BYOND BUG: bad ref (5:0) in DecRefCount
Connection closed.
I really expected to see the messages about saving prefs and called ..() as well. If I comment out the line calling Import() and uncomment the other, I get something more like what I would expect:
Client Air Mapster.Del()
Air Mapster saving src.prefs in /prefs/airmapster
Called ..()
Air Mapster.Logout()
Connection closed.
So I thought perhaps the Import() call is taking more than one tick and by the time it's done, the client is already disconnected and deleted? If so, is there something I can do to get around that? And if not, could it be the noted BYOND BUG?
|
Looks like a bug to me. Help is on the way!