Skip to content

Commit

Permalink
Change the way crash with CallsignGenerator was fixed to make it back…
Browse files Browse the repository at this point in the history
…wards compatible with 12.x saves
  • Loading branch information
zhexu14 committed Nov 29, 2024
1 parent b348e29 commit 96ddfe8
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions game/callsigns/callsigngenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,19 +230,24 @@ def release_callsign(self, callsign: Callsign) -> None:
class FlightCallsignGenerator:

def __init__(self, country: str):
use_western_callsigns = countries_by_name[country]().use_western_callsigns
if use_western_callsigns:
self._generator: (
WesternFlightCallsignGenerator | EasternFlightCallsignGenerator
) = WesternFlightCallsignGenerator(country)
self._use_western_callsigns = countries_by_name[country]().use_western_callsigns
self._generators: dict[
bool, WesternFlightCallsignGenerator | EasternFlightCallsignGenerator
] = {}
if self._use_western_callsigns:
self._generators[self._use_western_callsigns] = (
WesternFlightCallsignGenerator(country)
)
else:
self._generator = EasternFlightCallsignGenerator()
self._generators[self._use_western_callsigns] = (
EasternFlightCallsignGenerator()
)

def reset(self) -> None:
self._generator.reset()
self._generators[self._use_western_callsigns].reset()

def alloc_callsign(self, flight: Flight) -> Callsign:
return self._generator.alloc_callsign(flight)
return self._generators[self._use_western_callsigns].alloc_callsign(flight)

def release_callsign(self, callsign: Callsign) -> None:
self._generator.release_callsign(callsign)
self._generators[self._use_western_callsigns].release_callsign(callsign)

0 comments on commit 96ddfe8

Please sign in to comment.