Alternative to serialization?
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?
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.
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.
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement