• entries
    707
  • comments
    1173
  • views
    434010

GameSaveSystem - Alternate Implementation: Save & Swap

Sign in to follow this  
Programmer16

373 views

Github Link: https://github.com/dbeals/GameSaveSystem

The initial implementation of incremental saves is great and I'll be sticking with it for most of my games, but there are instances that it simply isn't a good fit (games that have large save files for example.) So, to get around this I have added a new implementation: save and swap. I want to point out ahead of time that the new implementation does still keep one backup copy. I'll be adding a flag to not create the backup in the next commit; I would have done so now, but I didn't think about it until afterwards. Here's the breakdown of the process, using MySave.sav as the save name:

When you save the first time, it goes directly to MySave.sav.
Every save after that creates a MySave.sav.new.
Once the save has completed, it renames MySave.sav to MySave.sav.bak.
Then it renames MySave.sav.new to MySave.sav.

The new implementation can be found in SwapSaveManagerBase and has pretty much the same interface as the incremental SaveManagerBase - SaveGame(SaveName), LoadGame(SaveName), AutoSave(), Export(ZipFilePath), and Import(ZipFilePath).

As a side note, if you're not keen on using the base classes that I've included, 99% of the work is done via the SafeSaveHelper and SwapSaveHelper static classes. You can download the library and utilize the system with those classes alone.

If there is any other implementations that you can think of, let me know!
Sign in to follow this  


0 Comments


Recommended Comments

There are no comments to display.

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