diff --git a/changelog.md b/changelog.md index 55ca2695..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 @@ -22,6 +23,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. 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: diff --git a/game/factions/faction_loader.py b/game/factions/faction_loader.py index fa4cf04f..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,15 +24,22 @@ 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: 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: 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) ) 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() 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 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"