Skip to content

Commit

Permalink
Revert "Remove front line minimum distance."
Browse files Browse the repository at this point in the history
This reverts commit dbe9691
  • Loading branch information
RndName committed Jan 7, 2022
1 parent 8aca036 commit 7bb41d0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
1 change: 0 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ Saves from 5.0.0 are compatible with 5.1.0
* **[Mission Generation]** Fixed mission scripting error when using a dedicated server.
* **[Mission Generation]** Fixed an issue where empty convoys lead to an index error when a point capture made a pending transfer of units not completable anymore.
* **[Mission Generation]** Corrected Viggen FR22 & FR24 preset channels for the DCS 2.7.9 update
* **[Mission Generation]** Fixed an issue which prevented the mission generation if two controlpoints are really close to each other (e.g. Marianas campaigns)
* **[Mission Generation]** Fixed the SA-5 Generator to use the P-19 FlatFace SR as a Fallback radar if the faction does not have access to the TinShield SR.
* **[UI]** Enable / Disable the settings, save and stats actions if no game is loaded to prevent an error as these functions can only be used on a valid game.

Expand Down
24 changes: 21 additions & 3 deletions game/theater/frontline.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
from ..utils import Heading, pairwise


FRONTLINE_MIN_CP_DISTANCE = 5000


@dataclass
class FrontLineSegment:
"""
Expand Down Expand Up @@ -169,8 +172,23 @@ def _position_distance(self) -> float:
"""
total_strength = self.blue_cp.base.strength + self.red_cp.base.strength
if self.blue_cp.base.strength == 0:
return 0
return self._adjust_for_min_dist(0)
if self.red_cp.base.strength == 0:
return self.attack_distance
return self._adjust_for_min_dist(self.attack_distance)
strength_pct = self.blue_cp.base.strength / total_strength
return strength_pct * self.attack_distance
return self._adjust_for_min_dist(strength_pct * self.attack_distance)

def _adjust_for_min_dist(self, distance: float) -> float:
"""
Ensures the frontline conflict is never located within the minimum distance
constant of either end control point.
"""
if (distance > self.attack_distance / 2) and (
distance + FRONTLINE_MIN_CP_DISTANCE > self.attack_distance
):
distance = self.attack_distance - FRONTLINE_MIN_CP_DISTANCE
elif (distance < self.attack_distance / 2) and (
distance < FRONTLINE_MIN_CP_DISTANCE
):
distance = FRONTLINE_MIN_CP_DISTANCE
return distance

0 comments on commit 7bb41d0

Please sign in to comment.