|
-
February 6th, 2009, 05:07 AM
#1
[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?
-
February 6th, 2009, 05:15 AM
#2
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 >?
Regards,
Ramkrishna Pawar
-
February 6th, 2009, 09:01 AM
#3
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.
More computing sins are committed in the name of efficiency (without necessarily achieving it) than for any other single reason - including blind stupidity. --W.A.Wulf
Premature optimization is the root of all evil --Donald E. Knuth
Please read Information on posting before posting, especially the info on using [code] tags.
-
February 9th, 2009, 03:32 AM
#4
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|