1. Hello Guest! It's with a heavy heart that we must announce the removal of the Legacy GMC Archive. If you wish to save anything from it, now's the time! Please see this topic for more information.
    Dismiss Notice

Large world and (auto)saving

Discussion in 'Programming' started by Dawn, Nov 27, 2017.

  1. Dawn

    Dawn Member

    Sep 5, 2016
    Given that player can save at any point freely, how do people handle autosaving when the game has a large world and many objects that player can interact? For example, if NPC are walking around and player put items in a box, damages some objects, and cut down some trees, do save files save only the changes made from the original state of the world or save the whole world in the save file? I'm not sure if autosaving will make a problem for autosaving the whole thing constantly.
  2. Becon

    Becon Member

    Jul 13, 2016
    I could be wrong but I think they save only what you tell them to save. So if you wanted to save all the trees cut down you would probably have to do some variable magic or something.
  3. samspade

    samspade Member

    Feb 26, 2017
    If you're talking about the built in function, I don't know. My guess is it wouldn't work very well. You'll have to make your own save functions. Look into ini_write_real, ini_write_string etc. There are more complicated ways to do it, but the ini commands are pretty simply and straight forward. You do have to set the game up to save what you want it to save though.

    To make an auto save just put the save into an alarm or some event that reoccurs every so often, determine how many autosaves you want, and loop through them. For example:

    //save information to an ini file
    var save_file = "save" + string(auto_save_number) + ".sav"
    /* save stuff */
    //increase save number
    auto_save_number += 1;
    if (auto_save_number >= max_auto_saves) {
        auto_save_number = 0;
    //reset alarm
    alarm[0] = room_speed * 60;

    the above code will create a save file every minute, and when the auto save number reaches the max auto saves reset and start saving over the previous auto saves.

    There are a number of other ways to save as well and ini files have some limitations, but they are very easy to use.
  4. Dawn

    Dawn Member

    Sep 5, 2016
    I'm asking about the general method of saving large amount of data. If there are hundreds of objects and some got changes with their properties like coordinates, life and status, how do other games handle the saving, especially the ones with autosaving feature? As I wrote in the original post, do they save the whole thing? If that's the case, wouldn't the size of the save be too big for periodic autosaving, e.g slowing down the game for each instance of saving?
  5. Halph-Price

    Halph-Price Member

    Mar 20, 2017
    Depends on whats the game's minimum requirements... that's an optimizing issue, that you shouldn't worry about until after you have the game done. Then you can choose what to save or not. If you want that halo-style auto saving with everything saved pixel perfect, you can understand why a lot of games don't save the entire game state like that, if you're worried about performance.

    You either lean on performance, or lean on quality. It's not that bad tho, and you can sneak in stuff to a savefile throughout the game to stop from a giant bulk dump. like health and status only need to saved when changed, other than x,y, coordinates most things can be saved to a temp file that's renamed at save.

    I still see major games that fail at saving states properly, it's really the trickiest part, what should be in the save and what isn't, because it's one of the biggest factors in performance, when done mid game. This is why you see so many games have a seperate save window.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice