From 4e86b5211c4c03bd506f99228357f109c9e4d6af Mon Sep 17 00:00:00 2001 From: zhexu14 <64713351+zhexu14@users.noreply.github.com> Date: Fri, 29 Nov 2024 22:30:04 +1100 Subject: [PATCH] Fix callsign generator (#3467) Fix crash in CallsignGenerator when player uses faction that uses Eastern callsign conventions. --- changelog.md | 13 +++++++++++++ game/callsigns/callsigngenerator.py | 20 ++++++++++---------- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/changelog.md b/changelog.md index 4cb28fb9c..3280a0773 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,16 @@ +# 12.1.0 + +Saves from 12.x are not compatible with 12.1.0. + +## Features/Improvements + + + +## Fixes + +* **[Data]** Added/updated CBU weapons data. +* **[Mission Generation]** Fixed crash when using factions that have Eastern callsign conventions. + # 12.0.0 Saves from 11.x are not compatible with 12.0.0. diff --git a/game/callsigns/callsigngenerator.py b/game/callsigns/callsigngenerator.py index caa2fac97..eb1e264ff 100644 --- a/game/callsigns/callsigngenerator.py +++ b/game/callsigns/callsigngenerator.py @@ -230,19 +230,19 @@ def release_callsign(self, callsign: Callsign) -> None: class FlightCallsignGenerator: def __init__(self, country: str): - self._generators: dict[ - bool, WesternFlightCallsignGenerator | EasternFlightCallsignGenerator - ] = { - True: WesternFlightCallsignGenerator(country), - False: EasternFlightCallsignGenerator(), - } - self._use_western_callsigns = countries_by_name[country]().use_western_callsigns + use_western_callsigns = countries_by_name[country]().use_western_callsigns + if use_western_callsigns: + self._generator: ( + WesternFlightCallsignGenerator | EasternFlightCallsignGenerator + ) = WesternFlightCallsignGenerator(country) + else: + self._generator = EasternFlightCallsignGenerator() def reset(self) -> None: - self._generators[self._use_western_callsigns].reset() + self._generator.reset() def alloc_callsign(self, flight: Flight) -> Callsign: - return self._generators[self._use_western_callsigns].alloc_callsign(flight) + return self._generator.alloc_callsign(flight) def release_callsign(self, callsign: Callsign) -> None: - self._generators[self._use_western_callsigns].release_callsign(callsign) + self._generator.release_callsign(callsign)