[RESOLVED] How to serialise objects to memory?
I would like to save in-game data like player's health, ammo power etc into memory.
The reason is that the game is split into states with each level represented by a state. When a level loads, there will be a state change and all objects of the previous state will be released and when the new level loads, the objects are recreated and reinitialized with original values.
Hence there is a need to save gameplay data and restore them in the new level.
The resources i have come across give alot of info on serializing to file using streams. But there is little information on serializing to memory using streams.
How do I serialize object data into memory?
Re: How to serialise objects to memory?
The data is already in memory, correct ? Or is it on disk ?
If the data storage is structured, then you should be able to just assign the stored data to the structures and start using it, what is the problem >?
Re: How to serialise objects to memory?
I agree with Krishnaa that you should just store copies of the objects in memory, without serializing, but just for the record: You can use what you learned about serializing to file using streams to serialize them to a string, using the stringstream class. Then you can store the serialized string.
Re: How to serialise objects to memory?
yes, the data is in memory.
Well i guess i'll use structures instead. Thanks all for the advice :)