Advertisement Jump to content
Sign in to follow this  

Save or not save ... and what to save ...

This topic is 4765 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I'm looking for an insight on a general problem. If you have some 'world' in a game where the player moves through (eg. some 3-d level) what is the usual way of saving the state of the user? One way would be saving the complete world - but these would be possibly fairly too large. Another would be to have a collection of 'entities' (dynamic objects) which are needed to be saved and only walking through this list and saving them. But, is that the usual way to save everything that has changed in a level from the time the player has set his foot in it? E.g. also these things like the splatter I can do on the walls with the weapon? What is with animations that run at the time of the save operation (think NPC operations, doors, etc.) Curious Alex

Share this post

Link to post
Share on other sites

Dunno if it will ansqer your question but here's how a give parameters to *any* object in my engine.

<WindowModel name="quit">
<Property name="absolute" value="1" />
<Property name="position" value="0, 580" />
<Property name="size" value="800, 20" />
<Property name="bgcolor" value="0, 0, 0, 0" />
<Property name="text" value="Press 'Esc' to exit the engine." />
<Property name="textcolor" value="1, 1, 1, 1" />
<Property name="align" value="center" />
<Property name="font" value="verdana12" />

<Entity name="box" type="box">
<Property name="position" value="10.0 , 0.0 , 0.0" />
<Property_ name="rotation" value="0.0 , 90.0 , 45.0" />

Each object have two functions called "SetParameter(const std::string &name, const std::string &value)" and "const std::string &GetParameter(const std::string &name);". Each parameter is stored in a std::map<string, string>.

Here's an example
SetParameter("position", "10.0, 0.0, 0.0"); // Set position of the object at 10.0f, 0.0f, 0.0f
std::string pos = GetParameter("position"); // Get the position of the object
(Of course I defined others methods to get position as a vector of float to speed up things).

So with this king of approach, I think you can make a function called "void Save(void)" who looks throught the 'map' and save each value in a file *very* easily.

Here's some tips:
- Convert each "name" parameter to lower case to avoid conflicts like : "Position", "position", "pOsition", "POSITION"....
- Use a "dictionnary" where you put "legal name" values to avoid this king of situation : bool ret = SetParameter("text", "pouet pouet") applied to a sound object (it would return false here).
- Use XML (like in my example) !
- Use the force Luke ! Oops, nothing to do here that :)

Hope this will lead You to a solution...

Share this post

Link to post
Share on other sites
I dont think it's necessary to save everything including splatter on the walls. That's just excessive and players will understand if they are missing (if they notice at all). I would save only things that are necessary to the progress of the game.

As for what happens with things that go on during a save: pause the game before saving and unpause it after.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!