From 522495fd117091ea5bbf8c48345f46c56e067e2a Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Sat, 1 May 2021 11:05:10 -0700 Subject: [PATCH 1/7] Update pyinstaller. Need a version smart enough to handle pyproj. Fixes https://github.com/Khopa/dcs_liberation/issues/1049. --- requirements.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 7630d67d..d1698206 100644 --- a/requirements.txt +++ b/requirements.txt @@ -17,7 +17,8 @@ pathspec==0.8.1 pefile==2019.4.18 Pillow==8.1.1 pre-commit==2.10.1 -PyInstaller==3.6 +pyinstaller==4.3 +pyinstaller-hooks-contrib==2021.1 pyproj==3.0.1 PySide2==5.15.2 pywin32-ctypes==0.2.0 From c245531d651032e211d1efb2897d5ddec348c601 Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Sun, 2 May 2021 13:17:35 -0700 Subject: [PATCH 2/7] Update changelog for 2.5.1. (cherry picked from commit 4555a4968d231a3a361a73ebc8729eeaf156d45b) --- changelog.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/changelog.md b/changelog.md index 55ca2695..0e836160 100644 --- a/changelog.md +++ b/changelog.md @@ -22,6 +22,9 @@ Saves from 2.5 are not compatible with 3.0. ## Fixes +* **[Campaigns]** EWRs associated with a base will now only be generated near the base. +* **[Flight Planner]** Fixed error when generating AEW&C flight plans in campaigns with no front lines. + # 2.5.0 Saves from 2.4 are not compatible with 2.5. From ef1c70123ce69f25d2bda73abec29210ae8633d9 Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Sun, 2 May 2021 14:19:47 -0700 Subject: [PATCH 3/7] Remove duplicate SH-60s from factions. --- resources/factions/usa_2005.json | 1 - resources/factions/usa_2005_c130.json | 1 - 2 files changed, 2 deletions(-) diff --git a/resources/factions/usa_2005.json b/resources/factions/usa_2005.json index e8af8e95..57869deb 100644 --- a/resources/factions/usa_2005.json +++ b/resources/factions/usa_2005.json @@ -21,7 +21,6 @@ "F_15E", "F_16C_50", "SH_60B", - "SH_60B", "S_3B", "UH_1H", "UH_60A" diff --git a/resources/factions/usa_2005_c130.json b/resources/factions/usa_2005_c130.json index d2ceeaf0..54e4823e 100644 --- a/resources/factions/usa_2005_c130.json +++ b/resources/factions/usa_2005_c130.json @@ -22,7 +22,6 @@ "F_16C_50", "Hercules", "SH_60B", - "SH_60B", "S_3B", "UH_1H", "UH_60A" From b9822cd5d1417d7562a6ee948667d20c32877c02 Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Sun, 2 May 2021 14:31:08 -0700 Subject: [PATCH 4/7] Python 3.9 compatibility. This argument was removed and wasn't needed anyway since the file itself is already opened UTF-8. --- game/factions/faction_loader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/game/factions/faction_loader.py b/game/factions/faction_loader.py index fa4cf04f..35fb2830 100644 --- a/game/factions/faction_loader.py +++ b/game/factions/faction_loader.py @@ -31,7 +31,7 @@ class FactionLoader: for f in files: try: with f.open("r", encoding="utf-8") as fdata: - data = json.load(fdata, encoding="utf-8") + data = json.load(fdata) factions[data["name"]] = Faction.from_json(data) logging.info("Loaded faction : " + str(f)) except Exception: From 1c31cffe4b9c6a7f58489219a1c49ffd1aa9430c Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Sun, 2 May 2021 14:33:24 -0700 Subject: [PATCH 5/7] More Python 3.9 compat. --- game/db.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/game/db.py b/game/db.py index ffeecd8c..0a46473e 100644 --- a/game/db.py +++ b/game/db.py @@ -1548,7 +1548,7 @@ def unit_get_expanded_info(country_name: str, unit_type, request_type: str) -> s default_value = None faction_value = None with UNITINFOTEXT_PATH.open("r", encoding="utf-8") as fdata: - data = json.load(fdata, encoding="utf-8") + data = json.load(fdata) type_exists = data.get(original_name) if type_exists is not None: for faction in type_exists: From b10e86e484149741b5b7482a284493dae0717117 Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Sun, 2 May 2021 14:35:21 -0700 Subject: [PATCH 6/7] Add support for user faction directory. This allows users to install custom factions to their home directory rather than the Liberation install directory. Makes it easier to keep mods across Liberation downloads, and easier for us devs to keep custom factions without git always wanting us to add them. --- changelog.md | 1 + game/factions/faction_loader.py | 12 ++++++++++-- qt_ui/main.py | 3 --- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/changelog.md b/changelog.md index 0e836160..022a919f 100644 --- a/changelog.md +++ b/changelog.md @@ -9,6 +9,7 @@ Saves from 2.5 are not compatible with 3.0. * **[Campaign]** Ground units must now be recruited at a base with a factory and transferred to their destination. When buying units in the UI, the purchase will automatically be fulfilled at the closest factory, and a transfer will be created on the next turn. * **[UI]** Campaigns generated for an older or newer version of the game will now be marked as incompatible. They can still be played, but bugs may be present. * **[Modding]** Campaigns now choose locations for factories to spawn. +* **[Modding]** Can now install custom factions to /Liberation/Factions instead of the Liberation install directory. ## Fixes diff --git a/game/factions/faction_loader.py b/game/factions/faction_loader.py index 35fb2830..d0722a00 100644 --- a/game/factions/faction_loader.py +++ b/game/factions/faction_loader.py @@ -2,8 +2,9 @@ from __future__ import annotations import json import logging from pathlib import Path -from typing import Dict, Iterator, Optional, Type +from typing import Dict, Iterator, List, Optional, Type +from game import persistency from game.factions.faction import Faction FACTION_DIRECTORY = Path("./resources/factions/") @@ -23,9 +24,16 @@ class FactionLoader: if self._factions is None: self._factions = self.load_factions() + @staticmethod + def find_faction_files_in(path: Path) -> List[Path]: + return [f for f in path.glob("*.json") if f.is_file()] + @classmethod def load_factions(cls: Type[FactionLoader]) -> Dict[str, Faction]: - files = [f for f in FACTION_DIRECTORY.glob("*.json") if f.is_file()] + user_faction_path = Path(persistency.base_path()) / "Liberation/Factions" + files = cls.find_faction_files_in( + FACTION_DIRECTORY + ) + cls.find_faction_files_in(user_faction_path) factions = {} for f in files: diff --git a/qt_ui/main.py b/qt_ui/main.py index 5acfba73..826e455b 100644 --- a/qt_ui/main.py +++ b/qt_ui/main.py @@ -213,9 +213,6 @@ def lint_weapon_data() -> None: def main(): logging_config.init_logging(VERSION) - # Load eagerly to catch errors early. - db.FACTIONS.initialize() - game: Optional[Game] = None args = parse_args() From b8e6c2fe78ca3a3d49d302239403777e46bd12ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Sigueros=20Fern=C3=A1ndez?= Date: Mon, 3 May 2021 20:01:41 +0200 Subject: [PATCH 7/7] Check for empty package before estimating TOT. Fixes https://github.com/Khopa/dcs_liberation/issues/1014. --- gen/flights/traveltime.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gen/flights/traveltime.py b/gen/flights/traveltime.py index 98e74fac..6b6f0463 100644 --- a/gen/flights/traveltime.py +++ b/gen/flights/traveltime.py @@ -72,6 +72,9 @@ class TotEstimator: return startup_time def earliest_tot(self) -> timedelta: + if not self.package.flights: + return timedelta(0) + earliest_tot = max( (self.earliest_tot_for_flight(f) for f in self.package.flights) )