Topic: [QUESTION] About a total save game

I have to save the Engine status for have a complete photo of game status? This means I have to save each pointed address from each pointer in engine and so on for each pointer pointed by engine right?


ar &g-> getSoundContext();
    ar &g-> getRenderingContext();
      ar &g-> getPhysicsContext();
      ar &g-> getScriptContext();
      ar &g-> getInputContext();
      ar &g-> getSystemContext();

    // data loaders
     ar &g-> getFontLoader();
     ar &g-> getImageLoader();
     ar &g-> getSoundLoader();
     ar &g-> getMeshLoader();
     ar &g-> getArmatureAnimLoader();
     ar &g-> getTexturesAnimLoader();
     ar &g-> getMaterialsAnimLoader();
     ar &g-> getLevelLoader();
         // behavior manager
    ar &g-> getBehaviorManager();

    // renderer manager
      ar &g-> getRendererManager();

    // package manager
    
      ar &g-> getPackageManager()
      ar &g-> getLevel()
      ar &g-> getGame()
      ar &g-> getRenderer();

And then continue for each pointer...
Or there is another way I cannot figure out?

Re: [QUESTION] About a total save game

Hi,

no the pointer adress are not safe to save, the data is inside the pointer, not the pointer itself.
If you want to save some data, you have to identity the data before. If it's the scene, you need to parse the scene, all the objects and save the objects values (position, rotation etc), you have to parse your game values etc.

As an exemple you can see how Maratis editor saves a level in xml :
https://code.google.com/p/maratis/sourc … elSave.cpp

Re: [QUESTION] About a total save game

in the code you wrote there is a compatibility problem with c++ standard.

writeFloatValues(file, "color", *text->getColor(), 4);

This is an example of an instruction that doesn't compile with microsoft visual c++ 2010. I had to rewrite it in

writeFloatValues(file, "color", (float*)text->getColor(), 4);

I don't know if it's good because I didn't test yet. However if my solution isn't good, how may I fix it?

I included MLevelLoad and MLevelSave so I can reuse your code for saving the game.

Re: [QUESTION] About a total save game

originally it's without '*' (svn version) :

writeFloatValues(file, "color", text->getColor(), 4);

but older code was *text->getColor(), so you maybe got a older code version.

anyways, what you wrote is also correct (but normally unnecessary as MVector4 returns a (float*)) :

writeFloatValues(file, "color", (float*)text->getColor(), 4);