Add decorator for tracking save compat.

Used to decorate functions or methods that have save compat code for a
given major version.

```
@has_save_compat_for(5)
def foo() -> None:
    ...
```

This function will raise an error at startup if it is decorated as
having save compat for a version other than the current major version of
the game. A new major version is the definition of a save compat break,
so keeping around the old compat code serves no purpose other than
hiding initialization bugs. The compat code and the decorator should be
removed in the branch raising the error.
This commit is contained in:
Dan Albert
2021-07-12 13:35:31 -07:00
parent dda5955121
commit cd558daf5a
2 changed files with 56 additions and 1 deletions

View File

@@ -1,8 +1,15 @@
from pathlib import Path
MAJOR_VERSION = 5
MINOR_VERSION = 0
MICRO_VERSION = 0
def _build_version_string() -> str:
components = ["5.0.0"]
components = [
".".join(str(v) for v in (MAJOR_VERSION, MINOR_VERSION, MICRO_VERSION))
]
build_number_path = Path("resources/buildnumber")
if build_number_path.exists():
with build_number_path.open("r") as build_number_file: