Alternative to serialization?

Started by
3 comments, last by Instruo 18 years ago
I have been using serialization to save and load save states for my game. Now I want to start loading monster, skill, and item data from files, but I am using a different program to create those files. Thus, whenever I try to deserialize these files I get an error. I have really liked serialization until this came along, so it would be great if there was something that I could do make the serialization work. If not, what would be a good alternative that would allow me to do this?
"Duty is as heavy as a mountain, death is as light as a feather"-Al'' Lan Mandragoran
Advertisement
How are you serializing?
I hope this is enough info...

BinaryFormatter *formatter = new BinaryFormatter();
String *filename = S"Monsters.mon";
FileStream *output = new FileStream(filename, FileMode::OpenOrCreate, FileAccess::Write);
formatter->Serialize(output, monstercopylist);
output->Close();

Also, I'm using Visual C++.net 2003.
"Duty is as heavy as a mountain, death is as light as a feather"-Al'' Lan Mandragoran
Write a tool to convert it for you.

You can use the files you have already and just write a tool to convert them after you make them. Reading them into a dummy program with the same class structure then emitting it should do the trick. Or you can have the main program do this instead, and skip that step.

If you have the source code for the programs to make the files you want to read, then edit the source code to have the same structure as the main program (enough so that serialization will be possible) and then spit it out from there.

You should only need the classes that are used in your monster, skill, and item data classes. Not anything that uses them.

Hopefully you made the tool to make those files, in which case it "should" only be a few includes and editing the save feature for the program to serialize.
Perhaps XML, instead? There's even an XMLSerializer in .Net you can user
"Game Programming" in an of itself does not exist. We learn to program and then use that knowledge to make games.

This topic is closed to new replies.

Advertisement