ID:154711
 
I have a game where players can change their icons in-game to whatever they like, which is all fine and dandy. Savefiles get extremely bloated though when you save icons, and since we change icons a lot the savefiles tend to get massive.

While I'm aware you can use Write() to not include the icon, this causes the player to have to change their icon again if they load their file. Is there a way to somehow reference their icon without saving the icon itself in the savefile?
Well, by using fcopy_rsc you can retrieve an address from a file uploaded to the rsc's cache. Unfortunately, the address behaves like a file itself so saving it would not solve your bloating problem. Instead you can associate a unique identifier text string to each address through an associative list and instead save the unique identifier which would greatly reduce bloating in these savefiles. From then on you would only need to use the unique identifier as an index into the list whenever you want to access that icon. The problem is that when your server goes down the list obviously goes away permanently. Therefore you would have to save the list itself whenever the server dies...therefore you would have one massively bloated save file instead of a few minor bloated save files. Furthermore, since you're saving files that are already saved into the rsc's cache you're basically doubling the memory used by uploading icons(which is still done by saving them in individual savefiles anyways). So if you're okay with having all the icons disappear every time the server goes down go for it.

var/icons/list = new/list()
var/file = input(src,"Select File","Please select an icon file") as icon
address = fcopy_rsc(file)
icons["unique_reference"] = address


If the address returned by fcopy_rsc was actually a hexadecimal or other numerical address that you could use as an index into the rsc's cache then you could just do that without the need for an associative list by saving the address itself and accessing the entry at that address, but unfortunately it's not.

tl;dr Saving the addresses returned by fcopy_rsc seems to save the file itself instead of an index into the cache meaning you'll have to save the icons yourself anyways either when the player logs off or the server goes down.

EDIT: On that note, I have found this recent feature request that you might like to upvote.