Revert "Use the actual Country type instead of the name."

This reverts commit bd2ec12e0f.

Country is both the data (name, ID, etc) and the container for groups
added to the miz, so it can't be used across multiple mission
generations. See https://github.com/pydcs/dcs/issues/314 for potential
follow up work that would let us do this.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2864.
This commit is contained in:
Dan Albert
2023-05-15 18:06:31 -07:00
parent 03671bbfb0
commit ca96a232f0
24 changed files with 82 additions and 64 deletions

View File

@@ -17,8 +17,8 @@ from game.ato.flighttype import FlightType
from game.ato.package import Package
from game.ato.starttype import StartType
from game.factions.faction import Faction
from game.missiongenerator.lasercoderegistry import LaserCodeRegistry
from game.missiongenerator.missiondata import MissionData
from game.missiongenerator.lasercoderegistry import LaserCodeRegistry
from game.radio.radios import RadioRegistry
from game.radio.tacan import TacanRegistry
from game.runways import RunwayData
@@ -143,6 +143,7 @@ class AircraftGenerator:
# TODO: Special flight type?
flight = Flight(
Package(squadron.location, self.game.db.flights),
faction.country,
squadron,
1,
FlightType.BARCAP,

View File

@@ -73,7 +73,7 @@ class AirSupportGenerator:
else self.conflict.red_cp
)
country = self.game.blue.faction.country
country = self.mission.country(self.game.blue.country_name)
if not self.game.settings.disable_legacy_tanker:
fallback_tanker_number = 0

View File

@@ -29,9 +29,12 @@ class CargoShipGenerator:
self.generate_cargo_ship(ship)
def generate_cargo_ship(self, ship: CargoShip) -> ShipGroup:
country = self.mission.country(
self.game.coalition_for(ship.player_owned).country_name
)
waypoints = ship.route
group = self.mission.ship_group(
self.game.coalition_for(ship.player_owned).faction.country,
country,
ship.name,
HandyWind,
position=waypoints[0],

View File

@@ -70,11 +70,13 @@ class ConvoyGenerator:
units: dict[GroundUnitType, int],
for_player: bool,
) -> VehicleGroup:
country = self.mission.country(self.game.coalition_for(for_player).country_name)
unit_types = list(units.items())
main_unit_type, main_unit_count = unit_types[0]
group = self.mission.vehicle_group(
self.game.coalition_for(for_player).faction.country,
country,
name,
main_unit_type.dcs_unit_type,
position=position,

View File

@@ -151,7 +151,7 @@ class FlotGenerator:
utype = AircraftType.named("MQ-9 Reaper")
jtac = self.mission.flight_group(
country=self.game.blue.faction.country,
country=self.mission.country(self.game.blue.country_name),
name=namegen.next_jtac_name(),
aircraft_type=utype.dcs_unit_type,
position=position[0],
@@ -716,7 +716,7 @@ class FlotGenerator:
spawn_heading = (
self.conflict.heading.left if is_player else self.conflict.heading.right
)
country = self.game.coalition_for(is_player).faction.country
country = self.game.coalition_for(is_player).country_name
for group in groups:
if group.role == CombatGroupRole.ARTILLERY:
distance_from_frontline = (
@@ -734,7 +734,7 @@ class FlotGenerator:
g = self._generate_group(
is_player,
country,
self.mission.country(country),
group.unit_type,
group.size,
final_position,
@@ -750,7 +750,7 @@ class FlotGenerator:
self.gen_infantry_group_for_group(
g,
is_player,
country,
self.mission.country(country),
spawn_heading.opposite,
)

View File

@@ -93,8 +93,9 @@ class LogisticsGenerator:
"ctld", "logisticunit"
):
# Spawn logisticsunit at pickup zones
country = self.mission.country(self.flight.country)
logistic_unit = self.mission.static_group(
self.flight.squadron.coalition.faction.country,
country,
f"{self.group.name}logistic",
Fortification.FARP_Ammo_Dump_Coating,
pickup_point,

View File

@@ -135,12 +135,19 @@ class MissionGenerator:
"neutrals", bullseye=Bullseye(Point(0, 0, self.mission.terrain)).to_pydcs()
)
p_country = self.game.blue.faction.country
e_country = self.game.red.faction.country
self.mission.coalition["blue"].add_country(p_country)
self.mission.coalition["red"].add_country(e_country)
p_country = self.game.blue.country_name
e_country = self.game.red.country_name
self.mission.coalition["blue"].add_country(
country_dict[country_id_from_name(p_country)]()
)
self.mission.coalition["red"].add_country(
country_dict[country_id_from_name(e_country)]()
)
belligerents = {p_country, e_country}
belligerents = [
country_id_from_name(p_country),
country_id_from_name(e_country),
]
for country in country_dict.keys():
if country not in belligerents:
self.mission.coalition["neutrals"].add_country(country_dict[country]())
@@ -264,18 +271,18 @@ class MissionGenerator:
aircraft_generator.clear_parking_slots()
aircraft_generator.generate_flights(
self.game.blue.faction.country,
self.mission.country(self.game.blue.country_name),
self.game.blue.ato,
tgo_generator.runways,
)
aircraft_generator.generate_flights(
self.game.red.faction.country,
self.mission.country(self.game.red.country_name),
self.game.red.ato,
tgo_generator.runways,
)
aircraft_generator.spawn_unused_aircraft(
self.game.blue.faction.country,
self.game.red.faction.country,
self.mission.country(self.game.blue.country_name),
self.mission.country(self.game.red.country_name),
)
for flight in aircraft_generator.flights:
@@ -307,7 +314,7 @@ class MissionGenerator:
pos = Point(cast(float, d["x"]), cast(float, d["z"]), self.mission.terrain)
if utype is not None and not self.game.position_culled(pos):
self.mission.static_group(
country=self.game.blue.faction.country,
country=self.mission.country(self.game.blue.country_name),
name="",
_type=utype,
hidden=True,

View File

@@ -599,7 +599,7 @@ class HelipadGenerator:
return
# Note: Helipad are generated as neutral object in order not to interfer with
# capture triggers
country = self.game.coalition_for(self.cp.captured).faction.country
country = self.m.country(self.game.coalition_for(self.cp.captured).country_name)
for i, helipad in enumerate(self.cp.helipads):
heading = helipad.heading.degrees
@@ -675,7 +675,7 @@ class TgoGenerator:
def generate(self) -> None:
for cp in self.game.theater.controlpoints:
country = self.game.coalition_for(cp.captured).faction.country
country = self.m.country(self.game.coalition_for(cp.captured).country_name)
# Generate helipads
helipad_gen = HelipadGenerator(

View File

@@ -99,7 +99,7 @@ class VisualsGenerator:
break
self.mission.static_group(
self.game.red.faction.country,
self.mission.country(self.game.red.country_name),
"",
_type=v,
position=pos,