Store mod settings so mod properties can be injected again on game load, in case mods like CJS F/A-18E/F/G or IDF F-16I are selected by the player.

This commit is contained in:
MetalStormGhost 2022-04-23 15:00:27 +03:00
parent 1dd1ef6933
commit 204060665f
3 changed files with 17 additions and 0 deletions

View File

@ -122,6 +122,10 @@ class Faction:
#: both will use it. #: both will use it.
unrestricted_satnav: bool = False unrestricted_satnav: bool = False
# Store mod settings so mod properties can be injected again on game load,
# in case mods like CJS F/A-18E/F/G or IDF F-16I are selected by the player
mod_settings: ModSettings = field(default=None)
def has_access_to_dcs_type(self, unit_type: Type[DcsUnitType]) -> bool: def has_access_to_dcs_type(self, unit_type: Type[DcsUnitType]) -> bool:
# Vehicle and Ship Units # Vehicle and Ship Units
if any(unit_type == u.dcs_unit_type for u in self.accessible_units): if any(unit_type == u.dcs_unit_type for u in self.accessible_units):
@ -283,7 +287,14 @@ class Faction:
if unit.unit_class is unit_class: if unit.unit_class is unit_class:
yield unit yield unit
def apply_mod_settings(self) -> None:
self.apply_mod_settings(self.mod_settings)
def apply_mod_settings(self, mod_settings: ModSettings) -> None: def apply_mod_settings(self, mod_settings: ModSettings) -> None:
# Update the mod settings of this faction
# so the settings can be applied again on load, if needed
self.mod_settings = mod_settings
# aircraft # aircraft
if not mod_settings.a4_skyhawk: if not mod_settings.a4_skyhawk:
self.remove_aircraft("A-4E-C") self.remove_aircraft("A-4E-C")

View File

@ -218,6 +218,10 @@ class Game:
LuaPluginManager.load_settings(self.settings) LuaPluginManager.load_settings(self.settings)
ObjectiveDistanceCache.set_theater(self.theater) ObjectiveDistanceCache.set_theater(self.theater)
self.compute_unculled_zones(GameUpdateEvents()) self.compute_unculled_zones(GameUpdateEvents())
# Apply mod settings again so mod properties get injected again,
# in case mods like CJS F/A-18E/F/G or IDF F-16I are selected by the player
self.blue.faction.apply_mod_settings()
self.red.faction.apply_mod_settings()
if not game_still_initializing: if not game_still_initializing:
# We don't need to push events that happen during load. The UI will fully # We don't need to push events that happen during load. The UI will fully
# reset when we're done. # reset when we're done.

View File

@ -83,6 +83,7 @@ class GameGenerator:
self.air_wing_config = air_wing_config self.air_wing_config = air_wing_config
self.settings = settings self.settings = settings
self.generator_settings = generator_settings self.generator_settings = generator_settings
self.mod_settings = mod_settings
self.player.apply_mod_settings(mod_settings) self.player.apply_mod_settings(mod_settings)
self.enemy.apply_mod_settings(mod_settings) self.enemy.apply_mod_settings(mod_settings)
@ -104,6 +105,7 @@ class GameGenerator:
GroundObjectGenerator(game, self.generator_settings).generate() GroundObjectGenerator(game, self.generator_settings).generate()
game.settings.version = VERSION game.settings.version = VERSION
game.mod_settings = self.mod_settings
return game return game
def should_remove_carrier(self, player: bool) -> bool: def should_remove_carrier(self, player: bool) -> bool: