Skip to content

Commit

Permalink
Make fix to FlightCallsignGenerator to prevent crashes backwards comp…
Browse files Browse the repository at this point in the history
…atible with 12.x saves (#3469)

This PR implements #3467 to make it backwards compatible with 12.x
saves.
  • Loading branch information
zhexu14 authored Nov 30, 2024
1 parent 82258f3 commit fefe57b
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 fefe57b

Please sign in to comment.