Save state information

BlitzMax Forums/BlitzMax Programming/Save state information

Imphenzia(Posted 2010) [#1]
I'm not sure what to search for in the forum so apologies if this has been discussed and answered before.

I'm looking for a way to capture the state of a type into a buffer where all the values for each field is stored in the buffer.

Any thought of the best way to achieve this?

My own idea would be to simply have a field in the same type to flag if it's a buffered object or not, and then another field with a TMap to index all the buffered objects... Not sure.


Volker(Posted 2010) [#2]
Your could use serialization/reflection.
Brucey made a mod for this:
http://code.google.com/p/maxmods/wiki/PersistenceModule

It can capture a Type into a file or, IIRC, a ramstream.
Should fit your needs.


Imphenzia(Posted 2010) [#3]
Thanks for the suggestion - I'll have a look at it. I will have to store the state for fast recall and processing so I'm not sure XML is the best way to go but it may spawn som ideas. It's for my networking code so I can re-play logic from a past moment when a client receives updates (that occured in the past) from the game server.


Volker(Posted 2010) [#4]
I made a test in another thread. A simple type could be serialized a few thousands time in one second (~3000).
Depending on the count and complexity of your objects
it can be to slow for networking.