• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Steam Steam cloud general best practice

Flaick

Member
Hi guys, wanna ask you about best practice for Steam cloud.

1. Do you check first local save then Steam cloud?
2. Do you use some custom timestamp to know which is newer? Cause the user can turnoff Steam and maybe the save will not syncronized with cloud.
3. Do you use Steam auto-cloud? I try it and it works fine, but has some limitations, for example won't work is the file is saved with ds_map_secure_save().

I'm thinking about using steam_file_read() / steam_file_write_file() functions to sync my saves.
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
1. Do you check first local save then Steam cloud?
I usually do the opposite actually! First check for the STeam file, then if that's not available, check for a local file.

2. Do you use some custom timestamp to know which is newer? Cause the user can turnoff Steam and maybe the save will not syncronized with cloud.
Yes. 100% yes. All save data should contain at the very least the build version of the game and the date/time the save was made. You should then always compare them and present the user with the opportunity to update the STeam save if the local save has a later date, otherwise overwrite the local save with the steam save data. Having this information also makes it a lot easier to debug issues later.

3. Do you use Steam auto-cloud? I try it and it works fine, but has some limitations, for example won't work is the file is saved with ds_map_secure_save().
Yes I have used this and it's usually fine. However, it will NOT work with ds_map_secure_save as you've noted. You should never use this function for ANY cloud based saving as this function locks the save file to the machine it was created on and so if the user logs in on a different machine, their cloud save is useless and won't open.
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
So instead of using auto-cloud is better go with steam_file_write_file() and steam_file_read() functions to a manual cloud manage?
Personally I prefer these as it gives a much more granular control. Of my three games on STeam, only one uses auto-cloud and although I've not had any issues, I prefer to use the more specific functions just so everything is explicit... Makes debugging and testing easier. :)
 
All save data should contain at the very least the build version of the game and the date/time the save was made. You should then always compare them and present the user with the opportunity to update the STeam save if the local save has a later date, otherwise overwrite the local save with the steam save data. Having this information also makes it a lot easier to debug issues later.
Hey, so I know this post is kinda old, but from looking around online, this is the only information I could find pertaining using such a system. Recently, my players have started to have issues. When moving to a new device, such as a Steam Deck or another PC, for some reason the game does not initially detect a Cloud Save on Steam, it's like it just doesn't load fast enough (I didn't have these issues a month ago, so I'm not sure what's going on with Steam there), so because the game doesn't think there's a Cloud Save, it loads a local save instead. But, there is no local save, because this is a new device. The player thus starts over.

The next time the game saves, it manages to save to the Cloud, overwriting the Cloud Save that has all of the players data, and just like that, their data is essentially wiped.

This is the system I'm currently using. It's simple and just does what I explained: https://pastebin.com/wVv5FzWU

My problems are that I don't know how I would do the approach you're suggesting. This sort of stuff just isn't really available from what I've seen and on the subject of Cloud Saves, there's not a whole lot of posts being made (I can only assume because most people who start working on a game don't make it that far). So, I'm trying to do my research but there's just nothing for me to go on.

Like, for example. You suggest perhaps having the save include a timestamp. How would I include that into the save file?

Then, when it comes time to load Cloud Saves, how would it know to find these files when they're all going to be named differently due to the time stamps?

I don't know how to compare the Cloud Saves, either. Like, I think it'd be perfect if when it came time for the game to save, the game could detect that, oh, your latest Cloud Save actually has way more data, would you prefer to load that instead of saving? That sorta thing.

But, I just can't find any info on this subject. I'm at a total wall. I'd really appreciate any help that you could offer.
 

Flaick

Member
Hi,

I'm checking the Steam cloud save each time the game saves, so if there is a delay issue at the game starts, it will check and save on the cloud on demand.

Have you updated with new steelworks extension I presume? Is it worked correctly after you updated?
 
Hi,

I'm checking the Steam cloud save each time the game saves, so if there is a delay issue at the game starts, it will check and save on the cloud on demand.

Have you updated with new steelworks extension I presume? Is it worked correctly after you updated?
Thanks for the reply. I am using the Steamworks extension.

Checking the Steam Cloud Save each time the game saves sounds like a good and obvious idea. However, how do you check to see if there's a save in the Cloud and then do something about it? Like, even if the system was working 100%, there'd be a Cloud Save in the Cloud whenever you saved, but you're somehow detecting that the save about to be pushed into the Cloud is much newer?
 

Flaick

Member
Here my code:

GML:
if DEBUG_STEAM_CLOUD_ENABLED {
        if steam_is_cloud_enabled_for_account() && steam_is_cloud_enabled_for_app() {
            if (steam_file_exists(_steam_file)) steam_file_delete(_steam_file);
            steam_file_write_file(_steam_file,_filename);
            show_debug_message(_steam_file + " saved on Steam Cloud");
        }else{
            show_debug_message("Steam Cloud not enabled");
        }
    }
First I save locally then I push into Steam Cloud. Locally saves are used only if the player had turned off manually the Steam Cloud. Yes I know that couldn't be synchronised, but at least he doesn't have to start from the beginning.

DEBUG_STEAM_CLOUD_ENABLED is only a macro that I use to turn Steam Cloud on/off based if I build for itch.io or console for example.

I don't check if the save is newer, because if Steam Cloud works, my current save is the newest one. Of course I previously downloaded the latest save from Cloud at game start.
 
Top