From 48ae55bdc2618130fab37df5ccf5e18a58b647ad Mon Sep 17 00:00:00 2001 From: zhexu14 <64713351+zhexu14@users.noreply.github.com> Date: Thu, 21 Dec 2023 21:51:34 +1100 Subject: [PATCH] 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. --- game/dcs/aircrafttype.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/game/dcs/aircrafttype.py b/game/dcs/aircrafttype.py index c454167c..09a0f228 100644 --- a/game/dcs/aircrafttype.py +++ b/game/dcs/aircrafttype.py @@ -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"