• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Large world and (auto)saving

D

Dawn

Guest
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.
 
B

Becon

Guest
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.
 

samspade

Member
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.
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:

Code:
///alarm[0]

//save information to an ini file
var save_file = "save" + string(auto_save_number) + ".sav"
ini_open(save_file);
/* save stuff */
ini_close();


//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.
 
D

Dawn

Guest
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?
 
H

Halph-Price

Guest
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?
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.
 
Top