Return-To-The-Roots / s25client

Return To The Roots (Settlers II(R) Clone)
http://www.rttr.info
GNU General Public License v2.0
470 stars 75 forks source link

Add version to replay and recorded game commands #1677

Open Flamefire opened 1 week ago

Flamefire commented 1 week ago

For e.g. #1673 we should have some backwards compatibility to allow loading older replays even if there are some changes to serialized game commands.

The main contribution to this is the VersionedSerializer class in libutil which is an adapter over the serializer adding a version. To be as uninvasive as possible it allows to be used only for parts. E.g. an instance being passed a Serializer instance can create a VersionedSerializer on top of it for the duration of the method and afterwards the caller can use the original Serializer without even knowing about this process. This is done by recording the position of the Serializer and advancing it by the amount of bytes read through the Adapter.

I also translated/updated the docstrings and while doing that I found some places for major improvements:

Flamefire commented 20 hours ago

This is now ready