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

runtime app on mem map file

Started by doanwon Jan 5, 2007 at 7:50 PM 3 replies 450+ 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.
Palidine
Palidine
//savingfor each object{    save an ID that indicates the object type    dump the object's data}//loadingwhile ( not done ){    read ID    create instance of that type    have instance parse it's data}


basically each object knows how to save and load itself. you just pass the file stream around and have everyone save/load themselves.

if you don't already know how do to binary file i/o you should read up on it before attempting this.

-me
doanwon
doanwon
Thanks for your reply, me.

I have millions of these instances, would it take a long time?

Is there a way to load a whole app directly form file mem map?

Nypyren
Nypyren
Your main problem when loading/saving a lot of data are that pointers can potentially be in different places when you load the data back up.

If you have no pointers in your data, you can fwrite(...) your entire array of structs in a single call.

(edit) although... millions of anything will probably take a while to save or load.
doanwon
doanwon
Thanks, nypyren.

I have just realized the problem you stated. Maybe the only sure way to do it is Palidine's way in the first reply.

Topic Locked

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

Sign in to reply to this topic.