ID:1997123
 
Is it possible to find a var that has a: changed from it's defined value, and b: if it's a built-in var, changed from its engine-default.

I.e

mob
step_size = 5
var
changed = 1
notChanged = 1
New()
changed = 5


The way savefiles work, they automatically skip any var that is either tmp, or the same as the initial value, so if I saved this mob, step_size and changed would be added to the savefile, however if I use initial() on step_size, it'll return 5, and not the compiler default.

The reason I ask is I want to be able to modify a savefile to create hashes at runtime, and I'm going to split the savefile into a list and parse it, compare it against everything in mob.vars, and if it isn't initial (aka if it's queued for saving), create an additional entry in the savefile for the hash.

The problem is that step_size wouldn't be caught by initial(), but it would be saved. Not sure if it's possible, and if not I'll create a feature request.
some byond games used to have a "version" variable in the savefile to keep track of this and then they'd just update the savefile to newer version standards
Right, but the idea is to have a global ranking in my game, and if the host files ever got leaked (As they're bound to), it'd be nice to insure against savefile editors.

I'm leaving this open because I still want to know, and if not I'll make a feature request, but for anyone interested, I accomplished the same thing above by just hashing the entire darn thing, lol.

        saveGame()
var/savefile/HS = new("Savefiles/Player/[ckey]/[key].sav")
HS["Data"] << mob
HS["Savekey"] << md5("[HASH_KEY][HS.ExportText("/")][HASH_KEY]")

loadGame()
if(fexists("Savefiles/Player/[ckey]/[key].sav"))
var/savefile/S = new("Savefiles/Player/[ckey]/[key].sav")
var/savekey = S["Savekey"]
if(savekey != md5("[HASH_KEY][copytext(S.ExportText("/"),1,findtext(S.ExportText("/"),"Savekey"))][HASH_KEY]"))
var/savefile/BS = new("Savefiles/Player/[ckey]/Backup/[key]-[world.timeofday].sav")
BS.ImportText("/",S.ExportText("/"))
mob << "ERROR. SAVEFILE POSSIBLY CORRUPT. BACKUP CREATED, CONTACT AN ADMINISTRATOR."
else
S["Data"] >> mob
In response to Rushnut
Rushnut wrote:
Right, but the idea is to have a global ranking in my game, and if the host files ever got leaked (As they're bound to), it'd be nice to insure against savefile editors.

Honestly, the only truly secure option I can think of involves asymmetric cryptosystems where the encryption key is never stored in code anywhere. Anything else is gonna be fairly insecure AFAICT, including hashing, as the means to do that are stored right in the code. Hashing in a case like this can't really do much except insure data integrity, not data security.
Right, anyone dedicated enough is always going to find their way in, but I'd still like to try and do as much as I can with the tools I'm given. This stops any Tom, Dick and Harry from fuckin' wit my scorez, bruh.
In response to Rushnut
Rushnut wrote:
Right, anyone dedicated enough is always going to find their way in, but I'd still like to try and do as much as I can with the tools I'm given. This stops any Tom, Dick and Harry from fuckin' wit my scorez, bruh.

Then just hash the contents of the savefile along with a salt, and if the hash fails reject the savefile.
In response to Popisfizzy
Is that not exactly what I'm doing?

md5("[HASH_KEY][HS.ExportText("/")][HASH_KEY]")


#define HASH_KEY "PopIsntFizzy,PopIsFlat"
In response to Rushnut
Rushnut wrote:
Is that not exactly what I'm doing?

I guess? From looking at the ref, it looks like it. Though for some dumb reason you're including the salt twice, which does literally nothing of value due to the avalanche effect.
In response to Popisfizzy
Ah see that's where you are wrong, it is a demonstration of my ultimate will to protect against invasive users.

People will see the salt twice and be like "...but why?" and then realize my game isn't worth cheating on in the first place.

It's just another layer man, a whole 'nother layer.