Skip to content

Commit

Permalink
Add mechanism to prevent double counting of damage induced kills when… (
Browse files Browse the repository at this point in the history
#3371)

… 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.
  • Loading branch information
zhexu14 committed Apr 10, 2024
1 parent 3234a2b commit 9611c01
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions game/debriefing.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,9 @@ def dead_aircraft(self) -> AirLosses:
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:
Expand All @@ -399,6 +402,9 @@ def dead_aircraft(self) -> AirLosses:
# 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:
Expand Down

0 comments on commit 9611c01

Please sign in to comment.