TMPE icon indicating copy to clipboard operation
TMPE copied to clipboard

New persistence strategy

Open Elesbaan70 opened this issue 2 years ago • 4 comments

Resolves #1502

This PR provides a new way to save data so that changes can be made to the model without breaking old savegames.

The complete task list for this project is at #1502.

Also see this wiki page: https://github.com/CitiesSkylinesMods/TMPE/wiki/Loading-and-Saving-Data

Elesbaan70 avatar May 07 '22 19:05 Elesbaan70

Can add tests to your checklist (at least run manual test once):

  • [ ] Old save in new serialization code (should read)
  • [ ] New save in old serialization code (should do what? ignore new and load old, or have no old and load blank settings)
  • [ ] New save in new serialization code

kvakvs avatar Jun 01 '22 00:06 kvakvs

Can add tests to your checklist (at least run manual test once):

Here's what I tested:

  1. Transition from binary to XML:
    1. Reading old data:
      1. Load old data in new version. No XML found, so it reads the binary data.
    2. Saving new data with backward compatibility:
      1. Save new (XML) and old (binary) data to same file (default behavior until we decide we don't need to write the binary data anymore).
      2. Load in old version. It completely ignores the XML data.
      3. Load in new version. It sees the XML data and ignores the binary data.
  2. Versioning in XML (currently only tested in #1392 code):
    1. Reading old data:
      1. Load old data into new version. It detects the absence of the new feature, and reads the old way.
    2. Saving new data with backward compatibility:
      1. Save XML elements with and without the new feature.
      2. Load in old version. It skips elements with the new feature and reads elements without.
      3. Load in new version. It reads elements with the new feature and skips elements without.

Elesbaan70 avatar Jun 01 '22 13:06 Elesbaan70

@kvakvs If you weren't already aware, the original issue that prompted this was, as indicated in #1502, the inability to revise the save format without breaking older builds. While we don't support old versions, this still creates a problem for anyone (including ourselves) who wants to run test builds.

But since we don't support old versions, the intention is that once a feature is released to stable, the legacy code that writes data the old way gets removed. (The code to read the old way has to stay pretty much forever, though I imagine we'll identify exceptions on a case-by-case basis.)

Elesbaan70 avatar Jun 01 '22 13:06 Elesbaan70

I am converting this to draft, since TrafficManager.Util.Record was not addressed.

Elesbaan70 avatar Jun 17 '22 14:06 Elesbaan70