mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Fix unculled zones not updating when needed.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/1034.
This commit is contained in:
parent
7387c2ed8f
commit
5d291846d5
13
game/game.py
13
game/game.py
@ -208,7 +208,7 @@ class Game:
|
|||||||
naming.namegen = self.name_generator
|
naming.namegen = self.name_generator
|
||||||
LuaPluginManager.load_settings(self.settings)
|
LuaPluginManager.load_settings(self.settings)
|
||||||
ObjectiveDistanceCache.set_theater(self.theater)
|
ObjectiveDistanceCache.set_theater(self.theater)
|
||||||
self.compute_conflicts_position()
|
self.compute_unculled_zones()
|
||||||
if not game_still_initializing:
|
if not game_still_initializing:
|
||||||
self.compute_threat_zones()
|
self.compute_threat_zones()
|
||||||
|
|
||||||
@ -347,8 +347,6 @@ class Game:
|
|||||||
return self.process_win_loss(turn_state)
|
return self.process_win_loss(turn_state)
|
||||||
|
|
||||||
# Plan flights & combat for next turn
|
# Plan flights & combat for next turn
|
||||||
with logged_duration("Computing conflict positions"):
|
|
||||||
self.compute_conflicts_position()
|
|
||||||
with logged_duration("Threat zone computation"):
|
with logged_duration("Threat zone computation"):
|
||||||
self.compute_threat_zones()
|
self.compute_threat_zones()
|
||||||
|
|
||||||
@ -366,6 +364,10 @@ class Game:
|
|||||||
gplanner.plan_groundwar()
|
gplanner.plan_groundwar()
|
||||||
self.ground_planners[cp.id] = gplanner
|
self.ground_planners[cp.id] = gplanner
|
||||||
|
|
||||||
|
# Update cull zones
|
||||||
|
with logged_duration("Computing culling positions"):
|
||||||
|
self.compute_unculled_zones()
|
||||||
|
|
||||||
def message(self, title: str, text: str = "") -> None:
|
def message(self, title: str, text: str = "") -> None:
|
||||||
self.informations.append(Information(title, text, turn=self.turn))
|
self.informations.append(Information(title, text, turn=self.turn))
|
||||||
|
|
||||||
@ -406,10 +408,9 @@ class Game:
|
|||||||
def navmesh_for(self, player: bool) -> NavMesh:
|
def navmesh_for(self, player: bool) -> NavMesh:
|
||||||
return self.coalition_for(player).nav_mesh
|
return self.coalition_for(player).nav_mesh
|
||||||
|
|
||||||
def compute_conflicts_position(self) -> None:
|
def compute_unculled_zones(self) -> None:
|
||||||
"""
|
"""
|
||||||
Compute the current conflict center position(s), mainly used for culling calculation
|
Compute the current conflict position(s) used for culling calculation
|
||||||
:return: List of points of interests
|
|
||||||
"""
|
"""
|
||||||
from game.missiongenerator.frontlineconflictdescription import (
|
from game.missiongenerator.frontlineconflictdescription import (
|
||||||
FrontLineConflictDescription,
|
FrontLineConflictDescription,
|
||||||
|
|||||||
@ -19,6 +19,7 @@ def bounded_int_option(
|
|||||||
max: int,
|
max: int,
|
||||||
detail: Optional[str] = None,
|
detail: Optional[str] = None,
|
||||||
tooltip: Optional[str] = None,
|
tooltip: Optional[str] = None,
|
||||||
|
causes_expensive_game_update: bool = False,
|
||||||
**kwargs: Any,
|
**kwargs: Any,
|
||||||
) -> int:
|
) -> int:
|
||||||
return field(
|
return field(
|
||||||
@ -29,7 +30,7 @@ def bounded_int_option(
|
|||||||
text,
|
text,
|
||||||
detail,
|
detail,
|
||||||
tooltip,
|
tooltip,
|
||||||
causes_expensive_game_update=False,
|
causes_expensive_game_update,
|
||||||
min=min,
|
min=min,
|
||||||
max=max,
|
max=max,
|
||||||
)
|
)
|
||||||
|
|||||||
@ -448,6 +448,7 @@ class Settings:
|
|||||||
default=100,
|
default=100,
|
||||||
min=10,
|
min=10,
|
||||||
max=10000,
|
max=10000,
|
||||||
|
causes_expensive_game_update=True,
|
||||||
)
|
)
|
||||||
perf_do_not_cull_carrier: bool = boolean_option(
|
perf_do_not_cull_carrier: bool = boolean_option(
|
||||||
"Do not cull carrier's surroundings",
|
"Do not cull carrier's surroundings",
|
||||||
|
|||||||
@ -222,6 +222,7 @@ class AtoModel(QAbstractListModel):
|
|||||||
PackageRole = Qt.UserRole
|
PackageRole = Qt.UserRole
|
||||||
|
|
||||||
client_slots_changed = Signal()
|
client_slots_changed = Signal()
|
||||||
|
packages_changed = Signal()
|
||||||
|
|
||||||
def __init__(self, game_model: GameModel, ato: AirTaskingOrder) -> None:
|
def __init__(self, game_model: GameModel, ato: AirTaskingOrder) -> None:
|
||||||
super().__init__()
|
super().__init__()
|
||||||
@ -254,6 +255,7 @@ class AtoModel(QAbstractListModel):
|
|||||||
self.endInsertRows()
|
self.endInsertRows()
|
||||||
# noinspection PyUnresolvedReferences
|
# noinspection PyUnresolvedReferences
|
||||||
self.client_slots_changed.emit()
|
self.client_slots_changed.emit()
|
||||||
|
self.on_packages_changed()
|
||||||
|
|
||||||
def delete_package_at_index(self, index: QModelIndex) -> None:
|
def delete_package_at_index(self, index: QModelIndex) -> None:
|
||||||
"""Removes the package at the given index from the ATO."""
|
"""Removes the package at the given index from the ATO."""
|
||||||
@ -272,6 +274,12 @@ class AtoModel(QAbstractListModel):
|
|||||||
self.endRemoveRows()
|
self.endRemoveRows()
|
||||||
# noinspection PyUnresolvedReferences
|
# noinspection PyUnresolvedReferences
|
||||||
self.client_slots_changed.emit()
|
self.client_slots_changed.emit()
|
||||||
|
self.on_packages_changed()
|
||||||
|
|
||||||
|
def on_packages_changed(self) -> None:
|
||||||
|
if self.game is not None:
|
||||||
|
self.game.compute_unculled_zones()
|
||||||
|
self.packages_changed.emit()
|
||||||
|
|
||||||
def package_at_index(self, index: QModelIndex) -> Package:
|
def package_at_index(self, index: QModelIndex) -> Package:
|
||||||
"""Returns the package at the given index."""
|
"""Returns the package at the given index."""
|
||||||
|
|||||||
@ -106,6 +106,12 @@ class MapModel(QObject):
|
|||||||
GameUpdateSignal.get_instance().flight_selection_changed.connect(
|
GameUpdateSignal.get_instance().flight_selection_changed.connect(
|
||||||
self.set_flight_selection
|
self.set_flight_selection
|
||||||
)
|
)
|
||||||
|
self.game_model.ato_model_for(True).packages_changed.connect(
|
||||||
|
self.on_package_change
|
||||||
|
),
|
||||||
|
self.game_model.ato_model_for(False).packages_changed.connect(
|
||||||
|
self.on_package_change
|
||||||
|
),
|
||||||
sim_controller.sim_update.connect(self.on_sim_update)
|
sim_controller.sim_update.connect(self.on_sim_update)
|
||||||
self.reset()
|
self.reset()
|
||||||
|
|
||||||
@ -374,6 +380,9 @@ class MapModel(QObject):
|
|||||||
def mapZones(self) -> NavMeshJs:
|
def mapZones(self) -> NavMeshJs:
|
||||||
return self._map_zones
|
return self._map_zones
|
||||||
|
|
||||||
|
def on_package_change(self) -> None:
|
||||||
|
self.reset_unculled_zones()
|
||||||
|
|
||||||
def reset_unculled_zones(self) -> None:
|
def reset_unculled_zones(self) -> None:
|
||||||
self._unculled_zones = list(UnculledZone.each_from_game(self.game))
|
self._unculled_zones = list(UnculledZone.each_from_game(self.game))
|
||||||
self.unculledZonesChanged.emit()
|
self.unculledZonesChanged.emit()
|
||||||
|
|||||||
@ -169,6 +169,8 @@ class AutoSettingsLayout(QGridLayout):
|
|||||||
) -> None:
|
) -> None:
|
||||||
def on_changed(value: int) -> None:
|
def on_changed(value: int) -> None:
|
||||||
self.settings.__dict__[name] = value
|
self.settings.__dict__[name] = value
|
||||||
|
if description.causes_expensive_game_update:
|
||||||
|
self.write_full_settings()
|
||||||
|
|
||||||
spinner = QSpinBox()
|
spinner = QSpinBox()
|
||||||
spinner.setMinimum(description.min)
|
spinner.setMinimum(description.min)
|
||||||
@ -354,7 +356,7 @@ class QSettingsWindow(QDialog):
|
|||||||
self.cheat_options.show_base_capture_cheat
|
self.cheat_options.show_base_capture_cheat
|
||||||
)
|
)
|
||||||
|
|
||||||
self.game.compute_conflicts_position()
|
self.game.compute_unculled_zones()
|
||||||
GameUpdateSignal.get_instance().updateGame(self.game)
|
GameUpdateSignal.get_instance().updateGame(self.game)
|
||||||
|
|
||||||
def onSelectionChanged(self):
|
def onSelectionChanged(self):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user