Game Development Community

Save/Load System (SinglePlayer) thoughts?

by Steve Acaster · in Torque 3D Professional · 05/02/2010 (2:18 pm) · 10 replies

Slowly but surely I'm getting together something that feels a bit like a game ... so started wondering about a save/load system for single player mode ...

Anyone have any idea if I have to worry about UAC? Does it matter where I try to save or update files?
eg:c:\Program Files\my game
Isn't Torque defaulting to install to base C: for a reason? I can't actually remember what that reason is ... every time my brain learns new stuff it pushes older info out ...

Obviously I don't want to save user levels over the originals ... so I'd want to create a "saved game" folder where files can be repeatedly written to, and have some sort of "continue" button in main menu that you could reload the last save from - and some sort of "load mission" if you want to replay a level which wasn't the last save ... which also bring me on to unlocking levels as part of a singleplayer campaign ... but one thing at a time.

I'm thinking of just using a triggered/checkpoint system for saving, rather than a player inputted "anywhere/anytime" save (so more like CoD rather than Crysis). I'm also thinking of not reloading on player death, but really respawning at the last "save trigger" with previous inventory -- so actual reloading is likely to be reserved solely for resuming the game after having exited it completey.

I believe that there is an old TGE resource for save/load, and will go hunt it down for a looksee in due course.

Not sure if I'll tackle this immediately or redo my Ai first, but it's getting closer to the top of the list.

Anyhoo, your thoughts, dreams, desires, vices ... well, maybe not that one ... but general input is welcome before I start.

#1
05/02/2010 (3:30 pm)
The current engine should be defaulting to %Appdata% on Windows, wherever that may be, when you use the regular file operation functions. Don't even think of saving anywhere else. (If that's not the case, somebody has some fixing to do ;)

Licorice for me. Can't stop eating the stuff. Totally addicted.
#2
05/02/2010 (4:21 pm)
I second licourice.

I also see Platform::getUserDataDirectory() has a mention of appdata under source\platformWin32\winUser.cpp.
#3
05/02/2010 (4:24 pm)
Have you tried to ask to the UAC, to run as administrator?

From the property of your .EXE, must just set the UAC option in the linker settings:

img24.imageshack.us/img24/3493/immagine3xwf.png

This, however, i seem to remember it is valid only with VS2008. With VS2005 you need use the tool mt.exe
#4
05/02/2010 (7:52 pm)
Requiring admin rights is the wrong way. You want per-user savegames to land somewhere in the user's home directory, not the game installation path.
#5
05/03/2010 (4:55 am)
It's very, very easy to save to the user directory. I did that in my last TGEA game using Platform::getUserDataDirectory() (I also modified the exportPrefs() function to save there instead). You should also route the procedural shaders and console.log file there too.
#6
05/03/2010 (12:06 pm)
While not exactly best practice, you can typically get around this problem by installing out of Program Files to c:\My Game. It won't enforce the UAC rules then. They will still need read/write to that directory, but most people are running admin on Windows machines still. If you don't want to do that, rerouting as everyone has posted is the best bet. You can use something like filemon to grab any other files that might be trying to write to that location as well.
#7
05/03/2010 (2:17 pm)
The user's home directory has been the default and recommended way for the past ten years on Windows, hasn't it?
#8
05/03/2010 (3:05 pm)
I'll have to check it out, but I think I used Torque's virtual filesystem to "mount" a game-specific directory in the user's directory, making the rest of the code not really care about it.
#9
05/04/2010 (9:51 am)
Yes, if the virtual filesystem handles it, you shouldn't have to do anything special (as long as you use those special paths). But if some files are written to the binary dir, and some to the userdir, there's a bit of fixing to do still. I'd mark it as a bug (10 years old!) if console logs still go to the program directory.
#10
05/05/2010 (6:08 am)
Right, so yes - I do need to worry about UAC, and the user directory (%appdata%, documents, whatever) should be the place to store these things.