Resource And Save File Location (and maybe also encrypting)

Hey, I was wondering if there are some best practices for classic type save files and on how and where to store resources. Also, what and how should be encrypted?

Thanks in advance. :)

Tagged:

Comments

  • edited March 2020

    Hey @magic_m,

    So that's a bit of an open ended question, but let's see where it'll bring us. :)

    To begin with, by calling orxConfig_Save() you can save all or part of the content of config in memory, as you already know.
    However, by default, the file will be saved next to the executable, for platforms that allow it.

    The best practice is probably to get a better place for save files by calling orxFile_GetApplicationSaveDirectory().
    Let's say you want to save a MyGame/HighScore.sav file, you could locate it in the usual application save directory by calling:

    const orxSTRING SaveLocation = orxFile_GetApplicationSaveDirectory("MyGame/HighScore.sav");
    orxConfig_Save(SaveLocation, ...);
    

    The actual physical location will vary depending on the host OS but it should be following the best practice on all of them.

    However, let's say you wanted to save it to a very specific place inside a given storage by calling orxResource_LocateInStorage(). As this will require knowledge of the resource system and how storage work inside it, I'll not get into more detail here right now. However lemme know if the application save directory doesn't work in your case and I'll elaborate on that topic.

    Lastly, the encryption is mostly to prevent direct tinkering by regular users, but it's not that hard to bypass.
    It'll use the key you provide when calling orxConfig_SetEncryptionKey(). That key is used for both writing and reading config to/from disk. You can find some more details here.

Sign In or Register to comment.