mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Fix invalid weapons fallback names
Also add logging to detect invalid fallback names more easily
This commit is contained in:
parent
60de35ddf3
commit
9ffaec6d16
@ -173,16 +173,21 @@ class WeaponGroup:
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _each_weapon_group(cls) -> Iterator[WeaponGroup]:
|
def _each_weapon_group(cls) -> Iterator[WeaponGroup]:
|
||||||
|
names = []
|
||||||
|
links = []
|
||||||
for group_file_path in Path("resources/weapons").glob("**/*.yaml"):
|
for group_file_path in Path("resources/weapons").glob("**/*.yaml"):
|
||||||
with group_file_path.open(encoding="utf8") as group_file:
|
with group_file_path.open(encoding="utf8") as group_file:
|
||||||
data = yaml.safe_load(group_file)
|
data = yaml.safe_load(group_file)
|
||||||
name = data["name"]
|
name = data["name"]
|
||||||
|
names.append(name)
|
||||||
try:
|
try:
|
||||||
weapon_type = WeaponType(data["type"])
|
weapon_type = WeaponType(data["type"])
|
||||||
except KeyError:
|
except KeyError:
|
||||||
weapon_type = WeaponType.UNKNOWN
|
weapon_type = WeaponType.UNKNOWN
|
||||||
year = data.get("year")
|
year = data.get("year")
|
||||||
fallback_name = data.get("fallback")
|
fallback_name = data.get("fallback")
|
||||||
|
if fallback_name:
|
||||||
|
links.append((name, fallback_name))
|
||||||
group = WeaponGroup(name, weapon_type, year, fallback_name)
|
group = WeaponGroup(name, weapon_type, year, fallback_name)
|
||||||
for clsid in data["clsids"]:
|
for clsid in data["clsids"]:
|
||||||
weapon = Weapon(clsid, group)
|
weapon = Weapon(clsid, group)
|
||||||
@ -190,6 +195,17 @@ class WeaponGroup:
|
|||||||
group.weapons.append(weapon)
|
group.weapons.append(weapon)
|
||||||
yield group
|
yield group
|
||||||
|
|
||||||
|
for name, fb in links:
|
||||||
|
if fb not in names:
|
||||||
|
sn = "Unknown"
|
||||||
|
for n in names:
|
||||||
|
if fb in n:
|
||||||
|
sn = n
|
||||||
|
break
|
||||||
|
logging.error(
|
||||||
|
f"Weapon '{name}' has invalid fallback '{fb}': suggested = {sn}"
|
||||||
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def register_clean_pylon(cls) -> None:
|
def register_clean_pylon(cls) -> None:
|
||||||
group = WeaponGroup(
|
group = WeaponGroup(
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
name: R-24R
|
name: R-24R
|
||||||
year: 1981
|
year: 1981
|
||||||
fallback: R-3R
|
fallback: R-3R - AAM, radar guided
|
||||||
clsids:
|
clsids:
|
||||||
- "{CCF898C9-5BC7-49A4-9D1E-C3ED3D5166A1}"
|
- "{CCF898C9-5BC7-49A4-9D1E-C3ED3D5166A1}"
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
name: 2xGBU-10
|
name: 2xGBU-10
|
||||||
type: LGB
|
type: LGB
|
||||||
year: 1976
|
year: 1976
|
||||||
fallback: 2xMk 84
|
fallback: Mk 84
|
||||||
clsids:
|
clsids:
|
||||||
- "{62BE78B1-9258-48AE-B882-279534C0D278}"
|
- "{62BE78B1-9258-48AE-B882-279534C0D278}"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user