Skip to main content
GameDev.net gamedev.net
🔒 Locked

saving application objects

Started by doanwon Jan 5, 2007 at 7:49 PM 1 replies 400+ views
Original Post
doanwon
doanwon
hi, first post, thanks for reading... When saving a game to file for later play, what is actually being saved by the game? For example, AgeofEmpireX saves the games to a .gmx file that can be loaded very quickly. I am writing an MFC app that creates many instances/objects (button class) on a click of a button--but takes long time. I would like to save these so the next time I run the app I don't have to create these again. I am thinking of file memory map. Is it possible to save whole or part of the app to mem map file and invoke it to run at a later time?... perhaps thru some thread? Thanks.
kvp
kvp
You are talking about persistence and serialization.

Unfortunately current mainstream (windows and unix) systems don't allow a program to be serialized out to disk. The solution is to read each object's variable data and write it out to disk, then destroy the object. During loading, the program read's the data and recreates each object in memory, like it's generated the first time.

For a game, you generate a player unit with a health of 10 at the position of 1,1. During the game it moves to 5,2 and loses health down to 4. During save, the program writes out: "playerunit,4,5,2" or something similar to a save file. During load it reads it in and creates a player unit with a health of 4 at 5,2. This is why some games use very similar formats for save and level files, because the difference between the two can be minimal.

To directly answer your question, to my best knowledge mfc object's have to be recreated every time the program runs and it's very hard to save every property. You should make your own object that contains your important data that has to be saved (and can be saved) and use that to set up the mfc objects every time you need them.
doanwon
doanwon
Thnks kvp.

Please read my next thread... It's more accurate of what I want to achieve.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.