Merge remote-tracking branch 'khopa/develop' into develop

This commit is contained in:
Khopa 2021-05-07 01:01:00 +02:00
commit b289e41a0d
8 changed files with 21 additions and 10 deletions

View File

@ -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 <DCS saved games>/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.

View File

@ -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:

View File

@ -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:

View File

@ -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)
)

View File

@ -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()

View File

@ -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

View File

@ -21,7 +21,6 @@
"F_15E",
"F_16C_50",
"SH_60B",
"SH_60B",
"S_3B",
"UH_1H",
"UH_60A"

View File

@ -22,7 +22,6 @@
"F_16C_50",
"Hercules",
"SH_60B",
"SH_60B",
"S_3B",
"UH_1H",
"UH_60A"