mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Rework sim status update to not need a thread.
Rather than polling at 60Hz (which may be faster than the tick rate, wasting cycles; and also makes synchronization annoying), collect events during the tick and emit them after (rate limited, pooling events until it is time for another event to send). This can be improved by paying attention to the aircraft update list, which would allow us to avoid updating aircraft that don't have a status change. To do that we need to be able to quickly lookup a FlightJs matching a Flight through, and Flight isn't hashable. We should also be removing dead events and de-duplicating. Currently each flight has an update for every tick, but only the latest one matters. Combat update events also don't matter if the same combat is new in the update. https://github.com/dcs-liberation/dcs_liberation/issues/1680
This commit is contained in:
@@ -17,6 +17,7 @@ from game.ato.flight import Flight
|
||||
from game.ato.flighttype import FlightType
|
||||
from game.ato.package import Package
|
||||
from game.game import Game
|
||||
from game.sim.gameupdateevents import GameUpdateEvents
|
||||
from game.squadrons.squadron import Pilot, Squadron
|
||||
from game.theater.missiontarget import MissionTarget
|
||||
from game.transfers import PendingTransfers, TransferOrder
|
||||
@@ -211,7 +212,7 @@ class PackageModel(QAbstractListModel):
|
||||
for flight in self.package.flights:
|
||||
yield flight
|
||||
|
||||
def on_sim_update(self) -> None:
|
||||
def on_sim_update(self, _events: GameUpdateEvents) -> None:
|
||||
self.dataChanged.emit(self.index(0), self.index(self.rowCount()))
|
||||
|
||||
|
||||
@@ -311,7 +312,7 @@ class AtoModel(QAbstractListModel):
|
||||
for package in self.ato.packages:
|
||||
yield self.package_models.acquire(package)
|
||||
|
||||
def on_sim_update(self) -> None:
|
||||
def on_sim_update(self, _events: GameUpdateEvents) -> None:
|
||||
self.dataChanged.emit(self.index(0), self.index(self.rowCount()))
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user