From 9611c01b932417572cf3babbd33da61745c7b500 Mon Sep 17 00:00:00 2001 From: zhexu14 <64713351+zhexu14@users.noreply.github.com> Date: Wed, 10 Apr 2024 16:28:21 +1000 Subject: [PATCH] =?UTF-8?q?Add=20mechanism=20to=20prevent=20double=20count?= =?UTF-8?q?ing=20of=20damage=20induced=20kills=20when=E2=80=A6=20(#3371)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit … DCS reports multiple hits This PR fixes a bug introduced when tracking OCA/Aircraft kills that results in double counting when DCS reports multiple hits, typically when guns are used. --- game/debriefing.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/game/debriefing.py b/game/debriefing.py index 78f14e82..64c78385 100644 --- a/game/debriefing.py +++ b/game/debriefing.py @@ -391,6 +391,9 @@ class Debriefing: else: enemy_losses.append(aircraft) + # Keep track of damaged units that are counted as killed so we don't double count + # when DCS reports damage multiple times. + units_killed_by_damage = set() for unit_data in self.state_data.unit_hit_point_updates: damaged_unit = FlyingUnitHitPointUpdate.from_json(unit_data, self.unit_map) if damaged_unit is None: @@ -399,6 +402,9 @@ class Debriefing: # If unit already killed, nothing to do. if unit_data["name"] in self.state_data.killed_aircraft: continue + if unit_data["name"] in units_killed_by_damage: + continue + units_killed_by_damage.add(unit_data["name"]) if damaged_unit.is_friendly(to_player=True): player_losses.append(damaged_unit.unit) else: