Save Load

BlitzMax Forums/BlitzMax Programming/Save Load

Jay Kyburz(Posted 2005) [#1]
Hey Guys,

I'm at that stage where I need to write my save load system. Just wondering if you guys are doing anything tricky and cool.

My current plan is to just iterate over each of my "entities" and save off every field value. For Objects within other objects I plan to just recursively step down through them recoding each objects state.

I'm not sure if I want to have one central function that understands the structure of every type, or if I should add a method to each object that returns data that can be stuffed in a save game some how.

Perhaps I could just pass the file handle around and let every object write its own data to disk.

Anybody have any experience with this?


Perturbatio(Posted 2005) [#2]
I would tend to create a save and load method for each of my types and pass the stream to them as appropriate, then all you need to do is tell them where to save.

i.e.
myParentType.Save(mystream)


in myParentType Save method:

for local myChildType:TChildType = eachin typelist
   myChildType.Save(mystream)
next



Booticus(Posted 2005) [#3]
Thanks! I never would have thought about building the save routine actually INTO my Type! Thanks for the tip!


Perturbatio(Posted 2005) [#4]
np :)