Results 1 to 11 of 11
  1. #1
    Lesser Hivemind Node Bhazor's Avatar
    Join Date
    Jun 2011
    Posts
    734

    Saving: how do it works

    Now I know nothing about game programming but one particular aspect has always puzzled me. How does saving work? Now I can understand how it would work in a simple game (a NES platformer say) . It's basically a password referring to a level with a bit of data for lives/score. But what about in a game like Morrowind/Skyrim where there are thousands of objects and AI characters. Where I leave a muffin on top of a mountain. Save the game. Reload the next day and find the exact same muffin looking at me. The only thing I could think of is saving a snapshot of the whole world Dwarf Fortress style but that would take hundreds of megs and the average Morrowind/Skyrim save is generally less than 500kb.
    “People will kill you over time, and how they’ll kill you is with tiny, harmless phrases, like “be realistic”
    Dylan Moran

  2. #2
    Secondary Hivemind Nexus Heliocentric's Avatar
    Join Date
    Jun 2011
    Posts
    9,950
    There are 2 kinds of save, the literal store where save files get monstrously big, and abstractions. In both cases the game merely needs to log "accurate" details of the world and then the loading system reads the notes and replicates the details.

    In halflife where you are, what enemies exist at the moment, how much ammo you have etc. Of course things get dropped when its not a complete memory dump. Maybe the enemy's gun is loaded to full, or all physics objects lose momentum.

    These detail errors like enemies getting bored of following you on a reload are highly common in real games and vary widely, obviously this is why games love "jumping off points" where you cant go back so the game doesn't need to remember that you stacked up 5 drink cans because you cant go back anymore.

    edit: for example, in oblivion where someone is doesn't need to be saved if they are on schedule. so someone where they are meant to be can just be drawn from the regular game data. Whereas a guard you have killed will need to be logged where he is and that he'd dead, probably some rough ragdoll data. When you leave, he'll get scrubbed from existence and thus not be a priority for saving.

    Remember, there is nothing stopping save files being compressed compare a JPG to a literal BMP, it can be 100 times smaller and contain almost exactly the same picture.
    Last edited by Heliocentric; 12-10-2012 at 10:36 PM.
    I'm failing to writing a blog, specifically about playing games the wrong way
    http://playingitwrong.wordpress.com/

  3. #3
    Network Hub
    Join Date
    Jun 2011
    Posts
    146
    To save a game, you take all the relevant game state (for Morrowind that might be the position and orientation of actors, quest variables, etc) and write them to a file in some format. To load a game, you read the file and parse its content into a valid game state.

  4. #4
    Obscure Node CaptainWaffles's Avatar
    Join Date
    Jun 2011
    Location
    Brunch
    Posts
    10
    A Skyrim save can be really small because it doesn't need to track every object. It just needs to keep track of objects that have moved from where the map files dictate they start, or have been added during play. Every such object is just a dozen or so bytes really, so unless you're spawning millions of cheese wheels or something it'll be pretty small.

  5. #5
    Secondary Hivemind Nexus Heliocentric's Avatar
    Join Date
    Jun 2011
    Posts
    9,950
    I'm failing to writing a blog, specifically about playing games the wrong way
    http://playingitwrong.wordpress.com/

  6. #6
    Secondary Hivemind Nexus Sakkura's Avatar
    Join Date
    Jul 2012
    Location
    Denmark
    Posts
    1,390
    Quote Originally Posted by CaptainWaffles View Post
    A Skyrim save can be really small because it doesn't need to track every object. It just needs to keep track of objects that have moved from where the map files dictate they start, or have been added during play. Every such object is just a dozen or so bytes really, so unless you're spawning millions of cheese wheels or something it'll be pretty small.
    It needs to save other stuff like quest state and non-respawned container contents (including merchant inventories, which are stored in inaccessible chests). So a Skyrim save does tend to end up at a few megabytes. Still manageable.

    Some games, like Paradox grand strategy games, can end up with pretty big save files. There's just a lot to store in those cases (eg. CKII - the state of every person that ever existed in the game, plus data on infrastructure, technology and available levies in every single province holding, and size and composition of armies, siege progress, yada yada yada).

  7. #7
    Lesser Hivemind Node Kodeen's Avatar
    Join Date
    Jun 2011
    Location
    USA
    Posts
    967
    Quote Originally Posted by Bhazor View Post
    Where I leave a muffin on top of a mountain. Save the game. Reload the next day and find the exact same muffin looking at me.
    For this example, all you need to store is the type of object in question, the x/y/z coordinates, and maybe the angle of rotation if you want to be able to load it on its side or something like that. Just a few bytes if you do it efficiently. Do that a few thousand times and a 500kb save is not that unreasonable.

  8. #8
    Lesser Hivemind Node
    Join Date
    Jun 2011
    Posts
    979
    Quote Originally Posted by Bhazor View Post
    The only thing I could think of is saving a snapshot of the whole world Dwarf Fortress style but that would take hundreds of megs and the average Morrowind/Skyrim save is generally less than 500kb.
    Thing to remember about storage is ultimately it all comes down to single binary blocks. There's numerous ways to exploit that to save space. Particularly when saving something like a game state, because what individual blocks contain isn't usually that important.

  9. #9
    Lesser Hivemind Node Bhazor's Avatar
    Join Date
    Jun 2011
    Posts
    734
    So it's an incremental save that records whats changed and applying it a "model world" rather than taking a snap shot of everything?

    That actually makes a lot of sense. It also explains why Skyrim had a game breaking glitch where saves would become too big to load as the player reached high levels because the game was having to record more and more data with each save.
    http://www.geek.com/articles/games/s...able-20111117/
    “People will kill you over time, and how they’ll kill you is with tiny, harmless phrases, like “be realistic”
    Dylan Moran

  10. #10
    Banned
    Join Date
    Jun 2011
    Posts
    2,069
    In case of Skyrim specifically you can catch a glimpse of the saving system by looking at quest flags.

    http://www.uesp.net/wiki/Skyrim:Unbound#Quest_Stages

    As such, the game only needs to use one double(why not integer? Don't ask me) to save quite a lot, since the quest stages decide item placements, location markers, NPC position/dialogues, etc. and are all static.

    Still, saving in a game is usually quite the dump. In an FPS it usually is almost 1:1 for example, complete with saving position and momentum of objects flying through the air and whatnot.

  11. #11
    Network Hub
    Join Date
    Jun 2011
    Posts
    233
    I guess this thread explains why Deus Ex saves took up to ten megabytes each. By the time I finished the game, the save folder was larger than the install.

    Or maybe they just didn't compress it.

    I wonder if this is a common trend with immersive sims.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •