Have fun in attacking the remaining classes

Moderator: Moderators
Sounds like a good solution.jcnossen wrote:For the actual savegame stuff, I was thinking that the easiest way is probably to write a memberless CGameSerializer class, register a serializer function to it, and call serializer.SerializeObjectInstance on all those global handler classes (readmap, uh, ph, featureHandler....). That way you can serialize only the synced parts of those, and maintain the original created objects.
Code: Select all
CR_REG_METADATA(CBitmapMuzzleFlame,
(
CR_MEMBER_BEGINFLAG(CM_Config),
CR_MEMBER(sideTexture),
....
CR_MEMBER(frontOffset),
CR_MEMBER_ENDFLAG(CM_Config)
));
IMO, we should try the simple case first, such an optimization probably requires quite a lot of additional work.Also it would be a waste to delete the entire game state only to recreate it by deserialization immediately after, so I think there must be a method designed to reserialize an object (ie. assume things have already been allocated and only fill in the primitive types or something.. tho it should probably handle e.g. a missing unit too).
Actually we don't really have to save everything, as long as we save an acceptable version of the current game, and have it synced. With that i mean that we could ignore certain parts if they are a lot of work (such as CommandAI).A lot of time will be in bugfixing/testing loading code I fear.
Code: Select all
void CLosHandler::creg_Serialize(creg::ISerializer& s)
{
// NOTE This could be tricky if gs is serialized after losHandler.
for (int a = 0; a < gs->activeAllyTeams; ++a) {
s.Serialize(losMap, losSizeX*losSizeY*2);
s.Serialize(airLosMap, airSizeX*airSizeY*2);
}
}
Code: Select all
unsigned short* losMap[MAX_TEAMS];
unsigned short* airLosMap[MAX_TEAMS];
Code: Select all
...
CR_MEMBER(losMap), // to serialize the array of pointers...
CR_MEMBER(airLosMap), // to serialize the array of pointers...
...
void CLosHandler::creg_Serialize(creg::ISerializer& s)
{
// and now serialize the pointers content...
// NOTE This could be tricky if gs is serialized after losHandler.
for (int a = 0; a < gs->activeAllyTeams; ++a) {
s.Serialize(losMap[a], losSizeX*losSizeY*2);
s.Serialize(airLosMap[a], airSizeX*airSizeY*2);
}
}
Code: Select all
// NOTE This could be tricky if gs is serialized after losHandler.
s.Serialize(losMap,sizeof(unsigned short*)*MAX_PLAYERS);
s.Serialize(airLosMap,sizeof(unsigned short*)*MAX_PLAYERS);
for (int a = 0; a < gs->activeAllyTeams; ++a) {
s.Serialize(losMap[a], losSizeX*losSizeY*2);
s.Serialize(airLosMap[a], airSizeX*airSizeY*2);
}
Code: Select all
s.Serialize(losMap,sizeof(unsigned short*)*MAX_PLAYERS);
Code: Select all
for (int a = 0; a < gs->activeAllyTeams; ++a) {
s.Serialize(losMap[a], losSizeX*losSizeY*2);
s.Serialize(airLosMap[a], airSizeX*airSizeY*2);
}