Merge branch 'develop' into you_won

This commit is contained in:
walterroach
2020-12-09 18:12:18 -06:00
8 changed files with 203 additions and 48 deletions

View File

@@ -7,45 +7,31 @@ from typing import Optional
_dcs_saved_game_folder: Optional[str] = None
_file_abs_path = None
def setup(user_folder: str):
global _dcs_saved_game_folder
_dcs_saved_game_folder = user_folder
_file_abs_path = os.path.join(base_path(), "default.liberation")
def base_path() -> str:
global _dcs_saved_game_folder
assert _dcs_saved_game_folder
return _dcs_saved_game_folder
def _save_file() -> str:
return os.path.join(base_path(), "default.liberation")
def _temporary_save_file() -> str:
return os.path.join(base_path(), "tmpsave.liberation")
def _autosave_path() -> str:
return os.path.join(base_path(), "autosave.liberation")
def _save_file_exists() -> bool:
return os.path.exists(_save_file())
def mission_path_for(name: str) -> str:
return os.path.join(base_path(), "Missions", "{}".format(name))
def restore_game():
if not _save_file_exists():
return None
with open(_save_file(), "rb") as f:
try:
save = pickle.load(f)
return save
except Exception:
logging.exception("Invalid Save game")
return None
def load_game(path):
with open(path, "rb") as f:
try:

View File

@@ -438,6 +438,10 @@ class ConflictTheater:
if self.is_on_land(point):
return False
for exclusion_zone in self.landmap[1]:
if poly_contains(point.x, point.y, exclusion_zone):
return False
for sea in self.landmap[2]:
if poly_contains(point.x, point.y, sea):
return True

View File

@@ -29,7 +29,7 @@ from .theatergroundobject import (
EwrGroundObject,
SamGroundObject,
TheaterGroundObject,
VehicleGroupGroundObject,
VehicleGroupGroundObject, GenericCarrierGroundObject,
)
from ..weather import Conditions
@@ -443,6 +443,20 @@ class ControlPoint(MissionTarget, ABC):
if runway_status is not None:
runway_status.process_turn()
# Process movements for ships control points group
if self.target_position is not None:
delta = self.target_position - self.position
self.position = self.target_position
self.target_position = None
# Move the linked unit groups
for ground_object in self.ground_objects:
if isinstance(ground_object, GenericCarrierGroundObject):
for group in ground_object.groups:
for u in group.units:
u.position.x = u.position.x + delta.x
u.position.y = u.position.y + delta.y
class Airfield(ControlPoint):