Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

EDI

Serialization Game Saving

This topic is 5690 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi All, i have a game engine ive been working on and i now need to implement some type of save, i know some basic concepts of serialization and i wonder if this is the ''best'' way to make the game save. i would like it so that if i serialize my game object it will serialize all the sprite objects and everything else associated with it, my problem is deserialization say that when i serialize my object it contains a pointer to some object this pointer is a shared pointer meaning i dont techincly own the object im just referencing it i could save the object to file by serializing the object the pointer points to but latter when i unpack the first object how do i know what object the pointer was mean to reference, sure i have that object''s data but it doesnt corespond to an actual object any more *for all accounts it''s an empty pointer* so it seems like im doing things wrong, is thier an easier way to do all this? is serialization the ''wrong'' aproach for saving games, any help is apreciated=) thanks, Raymond Jacobs, Profesional Web Applications Developer, Weekend Game Developer, www.EtherealDarkness.com

Share this post


Link to post
Share on other sites
Advertisement
Don''t use pointers, use object IDs. Of cource you use pointers internally but objects always reference other objects by their ID which is resolved at runtime

Basically each array item is assigned a unique arbitrary number. Search through the array untill you find the requested ID. Yes its slower, but there is lots of optimizations, computers are fast as heck now, and you can save the game

Share this post


Link to post
Share on other sites
I see,

that makes sense, seems a little bit painful to implement and manage tho,

ok another thing, lets say my game creates 2 new characters

and then i save the game

a new game is started and said characters dont exist, so when i load the game i will have to create them, but since the characters are classes *and possibly subclasses of the base engine sprite class* how can i make new ones, since you cant instantiate a class by name in C++ right? i could have methods that 'vend' a new character but thats gonna clutter things up, since i would need things like CreateNewPlayer CreateNewNPC

also correct me if im wrong i cant just allocate memory for a class using malloc, you need to use new to have all initilization done first right?


perhaps im looking at this the wrong way and need to rethink how my engine is structured?




Raymond Jacobs,
Profesional Web Applications Developer,
Weekend Game Developer,
www.EtherealDarkness.com

[edited by - EDI on January 22, 2003 4:22:55 PM]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!