mirror of
https://github.com/LostArtefacts/TRX.git
synced 2025-04-28 12:47:58 +03:00
65 lines
1.7 KiB
Python
Executable file
65 lines
1.7 KiB
Python
Executable file
#!/usr/bin/env python3
|
|
import argparse
|
|
from pathlib import Path
|
|
|
|
import pyjson5
|
|
from shared.paths import PROJECT_PATHS
|
|
|
|
|
|
def parse_args() -> argparse.Namespace:
|
|
parser = argparse.ArgumentParser(
|
|
description=(
|
|
"Compares a given configuration file with the default specifications "
|
|
"of the config tool to find changes in the default values"
|
|
)
|
|
)
|
|
parser.add_argument(
|
|
"-v",
|
|
"--version",
|
|
type=int,
|
|
help="game version to check the configuration file for",
|
|
required=True,
|
|
)
|
|
parser.add_argument(
|
|
"path",
|
|
type=Path,
|
|
help="path to the freshly written configuration file",
|
|
)
|
|
return parser.parse_args()
|
|
|
|
|
|
def main() -> None:
|
|
args = parse_args()
|
|
game_config = pyjson5.loads(args.path.read_text())
|
|
tool_spec_path = (
|
|
PROJECT_PATHS[args.version].tools_dir
|
|
/ "config/TR1X_ConfigTool/Resources/specification.json"
|
|
)
|
|
tool_spec = pyjson5.loads(tool_spec_path.read_text())
|
|
|
|
spec_map = {
|
|
option["Field"]: option["DefaultValue"]
|
|
for section in tool_spec["CategorisedProperties"]
|
|
for option in section["Properties"]
|
|
}
|
|
|
|
for key, spec_value in spec_map.items():
|
|
if (
|
|
key in game_config
|
|
and (game_value := game_config.get(key)) != spec_value
|
|
):
|
|
print(
|
|
f"(!) Wrong value: {key} (tool supplies {spec_value}, game supplies {game_value})"
|
|
)
|
|
|
|
for key, spec_value in spec_map.items():
|
|
if key not in game_config:
|
|
print(f"Surplus key: {key}")
|
|
|
|
for key, spec_value in game_config.items():
|
|
if key not in spec_map:
|
|
print(f"Missing key: {key}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|