mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Add a per-aircraft weapon linter.
Run with `main.py lint-weapons $AIRCRAFT` to show all the weapons the aircraft can carry that do not have data.
This commit is contained in:
parent
5e2ed04d72
commit
fab550157a
@ -13,8 +13,9 @@ from PySide2.QtWidgets import QApplication, QSplashScreen
|
|||||||
from dcs.payloads import PayloadDirectories
|
from dcs.payloads import PayloadDirectories
|
||||||
|
|
||||||
from game import Game, VERSION, persistency
|
from game import Game, VERSION, persistency
|
||||||
from game.data.weapons import WeaponGroup
|
from game.data.weapons import WeaponGroup, Pylon, Weapon
|
||||||
from game.db import FACTIONS
|
from game.db import FACTIONS
|
||||||
|
from game.dcs.aircrafttype import AircraftType
|
||||||
from game.profiling import logged_duration
|
from game.profiling import logged_duration
|
||||||
from game.settings import Settings
|
from game.settings import Settings
|
||||||
from game.theater.start_generator import GameGenerator, GeneratorSettings, ModSettings
|
from game.theater.start_generator import GameGenerator, GeneratorSettings, ModSettings
|
||||||
@ -198,6 +199,9 @@ def parse_args() -> argparse.Namespace:
|
|||||||
|
|
||||||
new_game.add_argument("--cheats", action="store_true", help="Enable cheats.")
|
new_game.add_argument("--cheats", action="store_true", help="Enable cheats.")
|
||||||
|
|
||||||
|
lint_weapons = subparsers.add_parser("lint-weapons")
|
||||||
|
lint_weapons.add_argument("aircraft", help="Name of the aircraft variant to lint.")
|
||||||
|
|
||||||
return parser.parse_args()
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
@ -267,11 +271,21 @@ def create_game(
|
|||||||
return game
|
return game
|
||||||
|
|
||||||
|
|
||||||
def lint_weapon_data() -> None:
|
def lint_all_weapon_data() -> None:
|
||||||
for weapon in WeaponGroup.named("Unknown").weapons:
|
for weapon in WeaponGroup.named("Unknown").weapons:
|
||||||
logging.warning(f"No weapon data for {weapon}: {weapon.clsid}")
|
logging.warning(f"No weapon data for {weapon}: {weapon.clsid}")
|
||||||
|
|
||||||
|
|
||||||
|
def lint_weapon_data_for_aircraft(aircraft: AircraftType) -> None:
|
||||||
|
all_weapons: set[Weapon] = set()
|
||||||
|
for pylon in Pylon.iter_pylons(aircraft):
|
||||||
|
all_weapons |= pylon.allowed
|
||||||
|
|
||||||
|
for weapon in all_weapons:
|
||||||
|
if weapon.weapon_group.name == "Unknown":
|
||||||
|
logging.warning(f'{weapon.clsid} "{weapon.name}" has no weapon data')
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
logging_config.init_logging(VERSION)
|
logging_config.init_logging(VERSION)
|
||||||
|
|
||||||
@ -283,7 +297,7 @@ def main():
|
|||||||
|
|
||||||
# TODO: Flesh out data and then make unconditional.
|
# TODO: Flesh out data and then make unconditional.
|
||||||
if args.warn_missing_weapon_data:
|
if args.warn_missing_weapon_data:
|
||||||
lint_weapon_data()
|
lint_all_weapon_data()
|
||||||
|
|
||||||
if args.subcommand == "new-game":
|
if args.subcommand == "new-game":
|
||||||
with logged_duration("New game creation"):
|
with logged_duration("New game creation"):
|
||||||
@ -298,6 +312,9 @@ def main():
|
|||||||
args.date,
|
args.date,
|
||||||
args.restrict_weapons_by_date,
|
args.restrict_weapons_by_date,
|
||||||
)
|
)
|
||||||
|
if args.subcommand == "lint-weapons":
|
||||||
|
lint_weapon_data_for_aircraft(AircraftType.named(args.aircraft))
|
||||||
|
return
|
||||||
|
|
||||||
run_ui(game)
|
run_ui(game)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user