mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Clear transports when disbanding convoys.
Also changes when we clear the convoys. Because we plan when transfers are added (to plan UI orders immediately) we were planning convoys when delivering units, then clearing the convoys, then planning them again. Aside from the wasted effort, when we cleared the convoys we forgot to tell the transfer that they no longer had transport, so when replanning they did not get a new convoy.
This commit is contained in:
parent
6016ebd3b4
commit
17751e52fd
@ -291,7 +291,6 @@ class Game:
|
||||
|
||||
# Needs to happen *before* planning transfers so we don't cancel the
|
||||
self.reset_ato()
|
||||
|
||||
for control_point in self.theater.controlpoints:
|
||||
control_point.process_turn(self)
|
||||
|
||||
|
||||
@ -264,6 +264,7 @@ class Convoy(MissionTarget, Transport):
|
||||
transfer.transport = self
|
||||
|
||||
def remove_units(self, transfer: TransferOrder) -> None:
|
||||
transfer.transport = None
|
||||
self.transfers.remove(transfer)
|
||||
|
||||
def kill_unit(self, unit_type: Type[VehicleType]) -> None:
|
||||
@ -275,6 +276,11 @@ class Convoy(MissionTarget, Transport):
|
||||
pass
|
||||
raise KeyError
|
||||
|
||||
def disband(self) -> None:
|
||||
for transfer in list(self.transfers):
|
||||
self.remove_units(transfer)
|
||||
self.transfers.clear()
|
||||
|
||||
@property
|
||||
def size(self) -> int:
|
||||
return sum(sum(t.units.values()) for t in self.transfers)
|
||||
@ -337,6 +343,7 @@ class ConvoyMap:
|
||||
yield destination_dict[destination]
|
||||
|
||||
def disband_convoy(self, convoy: Convoy) -> None:
|
||||
self.convoys[convoy.origin][convoy.destination].disband()
|
||||
del self.convoys[convoy.origin][convoy.destination]
|
||||
|
||||
@staticmethod
|
||||
@ -359,7 +366,8 @@ class ConvoyMap:
|
||||
self.disband_convoy(convoy)
|
||||
|
||||
def disband_all(self) -> None:
|
||||
self.convoys = defaultdict(dict)
|
||||
for convoy in list(self):
|
||||
self.disband_convoy(convoy)
|
||||
|
||||
def __iter__(self) -> Iterator[Convoy]:
|
||||
for destination_dict in self.convoys.values():
|
||||
@ -444,9 +452,9 @@ class PendingTransfers:
|
||||
if not transfer.completed:
|
||||
incomplete.append(transfer)
|
||||
self.pending_transfers = incomplete
|
||||
self.convoys.disband_all()
|
||||
|
||||
def plan_transports(self) -> None:
|
||||
self.convoys.disband_all()
|
||||
for transfer in self.pending_transfers:
|
||||
if transfer.transport is None:
|
||||
self.arrange_transport(transfer)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user