• entries
    707
  • comments
    1173
  • views
    434024

GameSaveSystem on GitHub

Sign in to follow this  
Programmer16

555 views

I've just posted the core of our game save system to GitHub.

One of the things that's really annoyed me (and I'm sure others) is the complete loss of a game save. Two recent instances where this has happened to myself: I completely lost a Fallout 3 save due to a save failure and I completely lost my Darksiders 2 game save due to a glitch (I picked up a sword I needed and when I loaded I still "had" the sword, but didn't have anything and couldn't move forward.)

To get around this, our game save system implements incremental saves. We tell the system that we want to save "DonnyAwesomeSave.sav" and the system will automatically create incremental saves for us each time we save. So, the first time it will create DonnyAwesomeSave.1.sav, then the 2nd will be DonnyAwesomeSave.2.sav, etc. There is a configurable maximum so that you're not creating TONS of saves (our standard is 3.) Then, the system will automatically rollback to the most previous save if the system fails to load (we display a message in this case, stating that the save failed to load and we are rolling back to a previous save.)

The system also provides a simply interface for auto-saves, utilizing the underlying system.

The other major thing I hate is trying to roundup all of my game saves when it comes time to move to a new computer/fresh install. So, the system has a built in mechanism for zipping up and exporting as well as unzipping and importing game saves. As noted, the export only exports the most recent version and the import cleanses existing files that match the imported file name.

There is still a bit that needs to be added, but for the most part it's all there. We'll be adding examples and such when we get some free time.
Sign in to follow this  


4 Comments


Recommended Comments

Could it handle games which try to implement permadeath by deleting saved game files? I had a game which did this but its save file also got corrupted. They tried to implement a "tamper proof" system which detects if a save file has been overwritten with an older save file, but I didn't put enough time into figuring out where or how that meta data was being saved.

Share this comment


Link to comment

Could it handle games which try to implement permadeath by deleting saved game files? I had a game which did this but its save file also got corrupted. They tried to implement a "tamper proof" system which detects if a save file has been overwritten with an older save file, but I didn't put enough time into figuring out where or how that meta data was being saved.

Sorry, this is just the code for someone to implement this in their engine/game.

 

The software solution I use is http://www.gamesave-manager.com/ but I'm not sure it would help with the perma-death issue. There are a lot of different ways for a developer to manage that (file times, registry, etc) so I don't think it would help much with that.

Share this comment


Link to comment

I can see why so many games do a poor job of save/load AKA serialization. It's a tough problem, it's not so fun to work on (it's in the database & OS realm), and it doesn't impress anyone when you get it right. Also, I'd bet it's an afterthought in most games; better to deal with it when designing data structures; enforce a strict separation between initial state, saveable world/character state, and throwaway/transient/runtime state; and give the system a workout during development so issues can be found and fixed well before release.

 

You make a great point about rounding up save files. OSes have default folders for Downloads, Pictures, etc - I wonder when they'll put Savegames on the same level. Within that folder, it'd be nice to have subfolders for autosaves, latest, "starred" savegames, and clutter - so you can just copy the important stuff.

Share this comment


Link to comment

I can see why so many games do a poor job of save/load AKA serialization. It's a tough problem, it's not so fun to work on (it's in the database & OS realm), and it doesn't impress anyone when you get it right. Also, I'd bet it's an afterthought in most games; better to deal with it when designing data structures; enforce a strict separation between initial state, saveable world/character state, and throwaway/transient/runtime state; and give the system a workout during development so issues can be found and fixed well before release.

I actually find this kind of work fun (along with GUI, which is another thing that lots of developers dislike working on), but then I am usually the odd man out. It's usually one of the first items tested in my projects as I've lost save data too many times to count. I actually started doing this when I was working on an earlier project, The Mysterious Life of Aaron James, as there were several releases where my save games completely broke. So now, whenever I add/change something to do with the game state, my save/load system is tested.
 

You make a great point about rounding up save files. OSes have default folders for Downloads, Pictures, etc - I wonder when they'll put Savegames on the same level. Within that folder, it'd be nice to have subfolders for autosaves, latest, "starred" savegames, and clutter - so you can just copy the important stuff.

This is exactly why I designed my system as it is. It doesn't really matter where the data is stored as, with the click of an export button (as long as the dev adds said button) you can export the files to a predetermined (or, if you're feeling froggy, a user-selected) folder as a zip file. You can then move the zip file to another computer, run the game and click the import button (again, if the dev adds said button) and it imports the saves into the proper place.

 

The current version on GitHub doesn't support multiple folders, but I'm porting the code out of our engine which does support multiple folders. So, in the near future you could utilize the system to simply call "Export(destinationFolder)" and it'll export all of the folders specified by the dev (saves, screenshots, etc) to the destination, in a zip file.

 

We're also going to add support for multi-file saves as I can see where that would be helpful.

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now