Trilarion / imperialism-remake

Imperialism remake
https://remake.twelvepm.de/
GNU General Public License v3.0
53 stars 19 forks source link

How to best version scenario files and upgrading them? #27

Open Trilarion opened 6 years ago

Trilarion commented 6 years ago

Between version of the game, the structure of scenario files might differ. A first step is storing the game version in the scenario file, the other step is converting older scenario files to newer versions.

Outline a strategy for how this could be done most efficiently and most safely (so we do not get into a chaotic state where either older scenarios are lost or we get unintended behavior).

krs013 commented 6 years ago

As long as the scenario object can read older versions and fill in the gaps, I think it would be ok, right?

Provided the file is not too tightly coupled with the object itself, it shouldn't have to be changed often in destructive ways. Internal changes to the game can be handled at the object layer.

In the case where there are enough changes that we need a generalized updating, perhaps we could devise some mechanism by which a new class can inherit or extend its old version... but that sounds complicated enough that it would only be fun, but not useful. 😬

Trilarion commented 6 years ago

About the scenario file version number, one question is if it should be the same as the game version number or if it needs to be more fine-grained. It would mean that we could introduce a new file version only if the version number is also increased.

Regarding the updates of older versions, I would chain them. Kind of writing a updater from last version to this version, and then upon loading of an old version apply the incremental updates in a chain. This should be least effort but can lead to some losses, if e.g. we remove a feature and then add it again in the course.

Overall, I think, it highlights the importance of thinking carefully and designing the scenario data structure (the file is mostly just a yaml representation of the data structure) in such a way that it doesn't need to be changed often.

krs013 commented 6 years ago

To your first point, I think that is one of the stipulations of semantic versioning, so it seems appropriate.