Players expect to be able to save their game. Which creates the question of, “Where do we store those saves?” Previously we’ve seen some surprisingly lively debates around the subject in the comments. I can’t find it now, but one person even went so far as to say that if a game doesn’t save in the /My Documents/ folder then the game is broken.
I can understand this. Microsoft created the /My Documents/ folder as a place for applications to store their crap. In an ideal world, someone wanting to back up their computer ought to be able to back up /My Documents/ and be reasonably certain they have everything. It’s supposed to be a general dumping ground for text documents, spreadsheets, game saves, configuration settings, power point presentations, email archives, web bookmarks, drawings, photographs, and whatever other data people create with their computers. It’s one location where users should be able to look and find ALL their files.
Unfortunately, /My Documents/ suffers from all the same problems that plague the Windows registry. Microsoft created “one system to rule them all”, and then made the implementation ambiguous. And it didn’t really do everything it needed to do. And it created security concerns. And then they changed how it worked from one version of Windows to the next.
For one thing, it’s not even called /My Documents/ these days. It’s /Users/. The location keeps changing. The internal structure keeps changing. The rules governing access keep changing. All of this creates problems for would-be game designers. Where do I put the user’s saves?
I can dump them into the root of the current logged in user:
(For this discussion, Let’s assume the current user is “Bob” and the game we’re making is called “Foo”
Or one of these.
/Users/Bob/My Documents/my games/Foo
I can find examples of most of these on my computer, by the way. And this is to say nothing of non-English versions of Windows where SOME of the above will be replaced with localized values, thus multiplying the number of possible permutations. What a mess.
|For the record, the game in the misspelled folder is Dead Space.|
But maybe I shouldn’t put it in Bob’s directory. Maybe the saves ought to go someplace public so that all users can access the same saves?
/Users/Public/Public Documents/[all the permutations from above]
In my current version of Windows 7, some of the directories are hidden by default, so when the user goes searching for “batman” or “minecraft” to back up specific games, they won’t find the files they need, even if they’re lucky enough to be looking in the right place and using the correct search terms.
Even if I do the homework and figure out what Microsoft really expects me to do, and even if the docs are clear, is it really going to offer me a reliable, predictable, sensible place to put these files? Will it be backwards compatible? What if the directory doesn’t exist because the user “cleaned up” this mess? Will my program have permission to create the needed directories? The odd thing about user permissions in Windows is that they pretty much ONLY apply to the /Users/ area and a couple of system folders. I could fill all hard drives with thousands of folders and the OS would never raise an eyebrow. From my perspective, /Users/ is the most dangerous place to save data because it’s the ONLY place where some unforeseen edge-case configuration might cause the game to crash or be unable to save, thus creating maddening support problems for ME. I could save files literally anywhere else with no risk.
This creates a testing nightmare for anyone. Maybe Windows Vista Home Edition has some fussy difference that needs to be accounted for. Maybe I’d need a completely different solution for Windows XP.
Bah, Windows XP is ancient. You shouldn’t support people that can’t be bothered to upgrade.
You make it sound like I’m punishing THEM for not upgrading, but that’s no what’s going on. I’m the one being punished. XP still has a respectable market share and I’d be giving up a lot of potential sales by refusing to support those people. By cutting off XP users I’m hurting myself and rewarding Microsoft for their half-assery. (By creating additional pressure for the user to upgrade.) I’m giving up sales so I can be a shill for the idiots who created the problem in the first place. That’s messed up.
Worse, all of this extra work, worry, testing, and support, applies only to Microsoft-based systems. It’s work that doesn’t need to be done for (say) Mac or Linux. (Assuming a developer is planning on developing for those platforms.)
The path of least resistance is to just ignore all of these Microsoft shenanigans. Just create a save game folder wherever the program is currently running. This way the game will work the same way on all platforms, I’ll always have read/write permission, and we don’t have to worry about littering the user’s documents directory with abandoned files when the game is uninstalled. It’s neat, it’s clean, it’s easy, and it’s self-contained.
Looking at the /Users/ directory on my computer, it looks like a lot of indies have come to the same conclusion. I have a lot of indie games installed, and precious few of them appear in /Users/. That space is overwhelmingly dominated by AAA titles, and I’m willing to bet that indies are just saving the game under the current working directory.
The CWD is where THIS program is running. If you base everything off the CWD, then you never need to know about or care what drive you’re on.
If the game is installed to:
Then that will be the CWD when the game is run. If I create a “save” folder without telling the OS specifically where to put it, then it will end up in the CWD like so:
If the user moves the game to (say)
…then the game won’t suffer or get confused. In fact, the game won’t even know that the move took place. Saves will appear in:
and everything will be fine.
So that’s what I’ve been doing. Cutting corners and cursing Microsoft. I strongly suspect that it’s no accident that the more you try to be cross-platform, the more of a pain in the ass it is to support Microsoft.
EDIT: As someone pointed out below, with my current setup if the game is installed to /Program Files/ then the user would need to run as administrator in order to save the game. That won’t do.
Screw this. I’ll just hard-code the game to save everything to
That should make everyone happy.
Fixing Match 3
For one of the most popular casual games in existence, Match 3 is actually really broken. Until one developer fixed it.
The Best of 2016
My picks for what was important, awesome, or worth talking about in 2016.
Skylines of the Future
Cities: Skylines is bound to have a sequel sooner or later. Where can this series go next, and what changes would I like to see?
I Was Wrong About Borderlands 3
I really thought one thing, but then something else. There's a bunch more to it, but you'll have to read the article.
The Game That Ruined Me
Be careful what you learn with your muscle-memory, because it will be very hard to un-learn it.