Pulsar4xDevs / Pulsar4x

A Fan work recreation of Aurora4x in C#
Other
159 stars 67 forks source link

Static Data Versioning #81

Open DifferentLevelDan opened 9 years ago

DifferentLevelDan commented 9 years ago

Static data currently loads based on DataSet name only.

So, if we load Pulsar4X DataSet, and the RodsEpicRebalanceMod DataSet, and save the game, only the names of the datasets are saved.

If RodsEpicRebalanceMod changes for whatever reason, it may introduce incompatible static data, as there is no actual version checking between previously used static data, and currently loading static data.

We need a Static Data Version system capable of handling this. VersionInfo is one possibility, but the ambiguity between compatible Game versions, and compatible StaticData versions is not currently addressed. Example: Pulsar4X Game Version 0.4 is loaded. Pulsar4X StaticData 0.1 is loaded. All is saved. Pulsar4X Game Version 0.4 is loaded. Previous game is loaded. Is Pulsar4x StaticData 0.2 compatible with a savegame saved with Pulsar4X StaticData 0.1?

SnopyDogy commented 9 years ago

The current versioning system is just about weather the static data being loaded is compatible with the current version of the core library. It was never meant to ensure that static data is compatible with other static data for 2 reasons:

1) Making sure that all static data is compatible with each other is the responsibility of the player (i.e. if they install modded data its their problem). 2) All static data was to be included in the save file, so subsequent changes to static data would have no effect.

Since we have decided not to do item 2 in future we do need to extend the versioning system. I would recommend we do the following:

1) Extend the version info json file to include the static data version in addition to the version(s) of the lib it is compatible with. 2) have the save game save out a list of mod names (and guids, to allow mod renaming maybe?) and mod versions for all currently loaded static data. 3) On load this list can be checked against a list of static data currently loaded. if all the static data is not loaded throw an error.

DifferentLevelDan commented 8 years ago

I wanted to update this with recent changes (currently on the new-game-mods branch, soon to be merged into ECS-Crossover)

Recent changes have addressed many issues with the previous system. In regards to the first points 1) Making sure all static data is compatible is the responsibility of the player, but recent changes allow developers to explicitly flag incompatible data. I believe this is the best option of both end-user responsibility and allowing the developer of any mods to help the end-user in troubleshooting situations by preventing "Known Bad" incompatibilities.

In regards to the last three points. 1) Version info json file has been expanded. The game now uses VersionInfo for the library version, and StaticData uses a derived DataVersionInfo class for itself. DataVersionInfo includes both minimum and maximum VersionInfos that the library can be for the DataVersionInfo to be considered compatible. 2) Save games save the list of DataVersionInfo's being loaded. It uses directory as the main loading platform. Mods can be renamed without changing the the mod being loaded so long as the directory doesn't change. 3) On load, the StaticData is reloaded from this list. Failure to load a static data will throw an exception.

Areas still needing improvement: The saved DataVersionInfo are not good at being modified. If a user installs 1.0 of AwesomeMod, the DataVersionInfo is saved to the game. If they then upgrade to 1.1 of AwesomeMod (same directory), the StaticDataStore will try to load the mod info twice (1.0 and 1.1) as the DataVersionInfos are considered different.