Re: No Saves makes it impossible to play the greatest games.
Posted: 11 Dec 2011, 17:44
Engine assisted save/load has existed for ages but noone has updated the lua solutions to utilise it.
End of story.
End of story.
Open Source Realtime Strategy Game Engine
https://springrts.com/phpbb/
We can wait a few weeks.Fast2 wrote:I didn’t look into the source code yet, because I don’t think I will have the time to contribute in a useful way at all in the next few weeks anyway.
I just wanted to suggest an approach to fix saving (and to show that there is at least one person more who would like to save his progress) and hear what you think about this proposal.
Oh, I didn’t want to put this in question.Tim Blokdjik wrote:People here and especially the engine developers understand what serialization is.
Not to be a jerk, but everyone reading this just rolled his eyes, no matter how pure your intentions.Fast2 wrote: Edit:
I didn’t look into the source code yet, because I don’t think I will have the time to contribute in a useful way at all in the next few weeks anyway.
Well, well, if it is so easy in theory, maybee you could do explanations for me. About Floating Point determinism, about synchronized deterministic simulations and the whole theory, that doesent come as easily to me.Fast2 wrote:Tim Blokdjik wrote: I just wanted to emphasize that – in theory – it should be easy and that I don’t really know what is hindering the integration of some means of saving.
With kind regards,
Fast2
This could be partly fixed by adding a validation test that errors when the CREG registered members are unequal to sizeof(class). And it could warn about registered pointer members.Tobi wrote:First, it likely won't get updated before decent tests for it are in place, so effectively it breaks every release (if just one field of one class isn't serialized properly it is end of story, in particular if it is a pointer).
You don't understand.hoijui wrote:i dont think that this is a solution, jk.
we do not want to serialize all class members, as some might point to memory allocated by a 3rd party lib, or some might contain..
What? Why doesn’t it? I really have to look into the code, this seems almost impossible to me.hoijui wrote:no, a class does no know at all what it should save, and how, and how to reload it.
I think your complaint is valid.Fast2 wrote:Hm, firstly, I have to complain that seemingly everybody (of course it’s just a few people, the exaggeration should emphasize it’s annoying nature) accuses me of being a troll. What am I doing wrong?
so i have this idea.... BWA HA HAPicassoCT wrote:the honor to do there work for free.
This still has the main problem that the reflection-based approach also has: there will be a duplicate list of members (one in the class definition, one in the Serialize method, and one in the Deserialize method), which are bound to get out of sync unless tests are in place.Fast2 wrote:Tobi:
Using my method, I don’t think this would be an issue.
Every class knows about what to save from itself and about its members.
The framework and each class should give back to each depending class what it got from it.
So, for example, suppose the map, here called Map, has a member, Heightmap, which is a subclass, another one, Texture, also a subclass, and one called Length, a long.
It should have two methods, commonly named Serialize and Deserialize, I assume.
That’s what you should have already had.
So, I think of Map.Serialize’s job as to call Heightmap.Serialize and Texture.Serialize, to collect what they return, and to add Length’s data.
So, in Map.Serialize(Savegame) (Savegame being the required object):
Heightmap.Serialize(Savegame); Texture.Serialize(Savegame); Savegame.Serialize(Length);
Texture and Heightmap will do the trick by theirselves, maybe they would just use something like Savegame.Serialize(Filename);
Deserialization would be the other way round:
Heightmap.Deserialize(Savegame); Texture.Deserialize(Savegame); Savegame.Deserialize(Length);
With Texture just reading the name of the texture file and reloading it like it does when the engine starts a game from scratch. If it shouldn’t touch the files directly, then it would redo whatever it does when starting freshly.
What I was trying to express is that I didn’t know what hinders the implementation, as I don’t think that I, myself, with my extraordinary ingeniusness (;)), am really telling something completely new.
Now, you have given a few reasons, which I tried to counter.
It seems at least like I’m proposing another way of doing it, which would hopefully work better than this reflection-based approach you already had.
I think the point is that although technically all this information is implicitly encoded into the definition and the semantics of the class, a developer needs to have this information in an understandable form to be able to implement serialization/deserialization.Fast2 wrote:What? Why doesn’t it? I really have to look into the code, this seems almost impossible to me.hoijui wrote:no, a class does no know at all what it should save, and how, and how to reload it.
Or did you just want to say that sometimes, the caller only has some plain reference to a baseclass, so without the use of virtual methods, it can’t properly save? There is probably a way to overcome this hurdle, but I believe that this will also need a glance at the code.
this!Tobi wrote:Classes don't "know" things - developers know things about classes, and developers will have to specify exactly how a class should serialize/deserialize itself. (which is work, takes time, is prone to errors, etc. etc.)
I look upon this like writing destructors, just some additional code.Tobi wrote:In other words: Classes don't "know" things - developers know things about classes
Code: Select all
class Map
{
STDSAVE
{
long Length;
}
CTMSAVE
{
Image Texture;
Image Heightmap;
}
NOSAVE
{
bool Had_to_make_sth_up;
}
void Serialize_Texture(Save_t& Savegame)
{ /* Just needed some usecase*/ }
void Serialize_Heightmap(Save_t& Savegame)
{/*...*/}
/*and the deserialization methods*/
}
//Would result in
class Map
{
long Length;
Image Texture;
Image Heightmap;
bool Had_to_make_sth_up;
void Serialize(Save_t& Savegame)
{
Serialize<long>(Length);
/*Serialize doing some stuff with boost::mpl to determine whether
Serialize should be called or Savegame.Serialize(...) is the right choice */
Serialize_Texture(Savegame);
Serialize_Heightmap(Savegame);
}
void Deserialize(Save_t& Savegame)
{ /*...*/ }
}