Default overrides fix (#3307)

This PR makes sure that the Payload tab of the Edit Flight window shows
the correct property values (with `default_overrides` applied in the
aircraft YAML). It looks like the issue only affects an obscure
parameter on F14s (INS reference alignment stored) so may not have been
noticed until now.
This commit is contained in:
zhexu14 2023-12-21 21:51:34 +11:00 committed by GitHub
parent ff2bd3f815
commit 48ae55bdc2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,7 +2,7 @@ from __future__ import annotations
import logging
from collections import defaultdict
from dataclasses import dataclass
from dataclasses import dataclass, replace as dataclasses_replace
from functools import cache, cached_property
from pathlib import Path
from typing import Any, ClassVar, Dict, Iterator, Optional, TYPE_CHECKING, Type
@ -400,6 +400,12 @@ class AircraftType(UnitType[Type[FlyingType]]):
for k in config:
if k in aircraft.property_defaults:
aircraft.property_defaults[k] = config[k]
# In addition to setting the property_defaults, we have to set the "default" property in the
# value of aircraft.properties for the key, as this is used in parts of the codebase to get
# the default value.
aircraft.properties[k] = dataclasses_replace(
aircraft.properties[k], default=config[k]
)
else:
logging.warning(
f"'{aircraft.id}' attempted to set default prop '{k}' that does not exist"