mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Fix aircraft group IDs not being reproducible.
This commit is contained in:
parent
c697a34239
commit
daba4ef09e
@ -69,7 +69,6 @@ class Operation:
|
|||||||
options_dict = loads(f.read())["options"]
|
options_dict = loads(f.read())["options"]
|
||||||
cls._set_mission(Mission(game.theater.terrain))
|
cls._set_mission(Mission(game.theater.terrain))
|
||||||
cls.game = game
|
cls.game = game
|
||||||
cls.reset_naming_ids()
|
|
||||||
cls._setup_mission_coalitions()
|
cls._setup_mission_coalitions()
|
||||||
cls.current_mission.options.load_from_dict(options_dict)
|
cls.current_mission.options.load_from_dict(options_dict)
|
||||||
|
|
||||||
@ -350,6 +349,7 @@ class Operation:
|
|||||||
cls.jtacs,
|
cls.jtacs,
|
||||||
cls.airgen
|
cls.airgen
|
||||||
)
|
)
|
||||||
|
cls.reset_naming_ids()
|
||||||
return cls.unit_map
|
return cls.unit_map
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|||||||
@ -971,8 +971,8 @@ class AircraftConflictGenerator:
|
|||||||
arrival=control_point, divert=None)
|
arrival=control_point, divert=None)
|
||||||
|
|
||||||
group = self._generate_at_airport(
|
group = self._generate_at_airport(
|
||||||
name=namegen.next_unit_name(country, control_point.id,
|
name=namegen.next_aircraft_name(country, control_point.id,
|
||||||
aircraft),
|
flight),
|
||||||
side=country,
|
side=country,
|
||||||
unit_type=aircraft,
|
unit_type=aircraft,
|
||||||
count=1,
|
count=1,
|
||||||
@ -1036,17 +1036,18 @@ class AircraftConflictGenerator:
|
|||||||
CoalitionHasAirdrome(coalition, flight.from_cp.id))
|
CoalitionHasAirdrome(coalition, flight.from_cp.id))
|
||||||
|
|
||||||
def generate_planned_flight(self, cp, country, flight:Flight):
|
def generate_planned_flight(self, cp, country, flight:Flight):
|
||||||
|
name = namegen.next_aircraft_name(country, cp.id, flight)
|
||||||
try:
|
try:
|
||||||
if flight.start_type == "In Flight":
|
if flight.start_type == "In Flight":
|
||||||
group = self._generate_inflight(
|
group = self._generate_inflight(
|
||||||
name=namegen.next_aircraft_name(country, cp.id, flight),
|
name=name,
|
||||||
side=country,
|
side=country,
|
||||||
flight=flight,
|
flight=flight,
|
||||||
origin=cp)
|
origin=cp)
|
||||||
elif isinstance(cp, NavalControlPoint):
|
elif isinstance(cp, NavalControlPoint):
|
||||||
group_name = cp.get_carrier_group_name()
|
group_name = cp.get_carrier_group_name()
|
||||||
group = self._generate_at_group(
|
group = self._generate_at_group(
|
||||||
name=namegen.next_aircraft_name(country, cp.id, flight),
|
name=name,
|
||||||
side=country,
|
side=country,
|
||||||
unit_type=flight.unit_type,
|
unit_type=flight.unit_type,
|
||||||
count=flight.count,
|
count=flight.count,
|
||||||
@ -1057,8 +1058,7 @@ class AircraftConflictGenerator:
|
|||||||
raise RuntimeError(
|
raise RuntimeError(
|
||||||
f"Attempted to spawn at airfield for non-airfield {cp}")
|
f"Attempted to spawn at airfield for non-airfield {cp}")
|
||||||
group = self._generate_at_airport(
|
group = self._generate_at_airport(
|
||||||
name=namegen.next_aircraft_name(country, cp.id,
|
name=name,
|
||||||
flight),
|
|
||||||
side=country,
|
side=country,
|
||||||
unit_type=flight.unit_type,
|
unit_type=flight.unit_type,
|
||||||
count=flight.count,
|
count=flight.count,
|
||||||
@ -1070,7 +1070,7 @@ class AircraftConflictGenerator:
|
|||||||
logging.warning("No room on runway or parking slots. Starting from the air.")
|
logging.warning("No room on runway or parking slots. Starting from the air.")
|
||||||
flight.start_type = "In Flight"
|
flight.start_type = "In Flight"
|
||||||
group = self._generate_inflight(
|
group = self._generate_inflight(
|
||||||
name=namegen.next_aircraft_name(country, cp.id, flight),
|
name=name,
|
||||||
side=country,
|
side=country,
|
||||||
flight=flight,
|
flight=flight,
|
||||||
origin=cp)
|
origin=cp)
|
||||||
|
|||||||
@ -44,6 +44,7 @@ ANIMALS = [
|
|||||||
class NameGenerator:
|
class NameGenerator:
|
||||||
number = 0
|
number = 0
|
||||||
infantry_number = 0
|
infantry_number = 0
|
||||||
|
aircraft_number = 0
|
||||||
|
|
||||||
ANIMALS = ANIMALS
|
ANIMALS = ANIMALS
|
||||||
|
|
||||||
@ -57,10 +58,11 @@ class NameGenerator:
|
|||||||
def reset_numbers(cls):
|
def reset_numbers(cls):
|
||||||
cls.number = 0
|
cls.number = 0
|
||||||
cls.infantry_number = 0
|
cls.infantry_number = 0
|
||||||
|
cls.aircraft_number = 0
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def next_aircraft_name(cls, country: Country, parent_base_id: int, flight: Flight):
|
def next_aircraft_name(cls, country: Country, parent_base_id: int, flight: Flight):
|
||||||
cls.number += 1
|
cls.aircraft_number += 1
|
||||||
try:
|
try:
|
||||||
if flight.custom_name:
|
if flight.custom_name:
|
||||||
name_str = flight.custom_name
|
name_str = flight.custom_name
|
||||||
@ -70,7 +72,7 @@ class NameGenerator:
|
|||||||
except AttributeError: # Here to maintain save compatibility with 2.3
|
except AttributeError: # Here to maintain save compatibility with 2.3
|
||||||
name_str = "{} {}".format(
|
name_str = "{} {}".format(
|
||||||
flight.package.target.name, flight.flight_type)
|
flight.package.target.name, flight.flight_type)
|
||||||
return "{}|{}|{}|{}|{}|".format(name_str, country.id, cls.number, parent_base_id, db.unit_type_name(flight.unit_type))
|
return "{}|{}|{}|{}|{}|".format(name_str, country.id, cls.aircraft_number, parent_base_id, db.unit_type_name(flight.unit_type))
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def next_unit_name(cls, country: Country, parent_base_id: int, unit_type: UnitType):
|
def next_unit_name(cls, country: Country, parent_base_id: int, unit_type: UnitType):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user