Compare commits

...

535 Commits

Author SHA1 Message Date
Astro-739
ce073c24bc Update of Campaign Falcon Went over the Mountain.
Added secondary mission types to all air-to-air squadrons for more
flexibility.
2023-12-30 20:33:03 +00:00
Starfire13
8de053cc7d Add Operation Aegean Aegis.
Adds a new Apache and Harrier campaign to the Syria map.
2023-12-28 20:01:34 -08:00
Astro-739
fe6e49b22b Update of Campaign Falcon Went over the Mountain.
Campaign update of Falcon Went over the Mountain (Syria map) to v11.0

1. Added squadron sizes
2. Rebalanced scenario
3. Added (non zero) heading to all SAM and EWR sites
2023-12-28 23:03:46 +00:00
Starfire13
3653dc8cbd Campaign inversion support for Battle for No Man's Land. 2023-12-27 14:06:46 -08:00
Starfire13
d2b5eea0de Update Harrier loadout (#3316)
I had a look and the default Harrier loadouts were very outdated and
quite sub-optimal. So I fixed it up.
2023-12-27 14:05:43 -08:00
zhexu14
211ec86e2e Apache speed fix (#3315)
This PR 1) introduces a cruise_speed parameter to the AircraftType class
and uses it as an override for default TOT/Ground Speed calculations and
2) sets this for the AH64.

The reason for this change is that air starts with the Apache at a speed
>130kt seems to completely break the FCR, even if you subsequently slow
down. In the development branch, Liberation sets the Apache to travel at
168kt, so any player air starting won't be able to use their FCR and it
wouldn't be readily apparent as to why.

In the longer run this parameter may also be useful for other aircraft
e.g. to override the cruise speed to the most efficient etc.
2023-12-27 14:04:16 -08:00
Starfire13
03caddc1b4 Update F-15E Suite 4+ loadouts to add the fixed GBU31v3 (#3314) 2023-12-21 22:15:16 -08:00
Dan Albert
3f7618d75d Update pydcs.
Has the __eq__ implementation for Task which fixes inconsistent save
loading issues.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/3288.
2023-12-21 21:48:17 -08:00
Dan Albert
dcf23c655d Describe non-airport "runways" better.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/3290.
2023-12-21 16:46:06 -08:00
Dan Albert
ef69275f34 Don't send the selected flight plan to the back.
We want the selected flight plan to show on top of all the other flight
plans, and because we can't properly z-order with the other elements of
the map (see the code comment), this is probably the best we can do.

This means that the selected flight will be drawn on top of the front
line again, and will in some cases intercept mouse clicks meant for the
front line, but it's much less of a problem than when all the paths were
drawn on top.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/3305.
2023-12-21 15:43:12 -08:00
Dan Albert
167cea08f6 Update pydcs.
Normandy terrain update.
2023-12-21 15:34:47 -08:00
zhexu14
48ae55bdc2 Default overrides fix (#3307)
This PR makes sure that the Payload tab of the Edit Flight window shows
the correct property values (with `default_overrides` applied in the
aircraft YAML). It looks like the issue only affects an obscure
parameter on F14s (INS reference alignment stored) so may not have been
noticed until now.
2023-12-21 02:51:34 -08:00
zhexu14
ff2bd3f815 Enable AH-64 FCR by default. 2023-12-20 21:42:18 -08:00
Starfire13
ba5d0bed4d Add Battle for No Man's Land campaign. 2023-12-20 18:40:31 -08:00
Dan Albert
4a07b8a2d8 Update pydcs. 2023-12-20 18:01:39 -08:00
Dan Albert
1efce862fb Send flight plan paths to the back of the map.
This fixes the unusual case where the `interactive: false` property had
no effect, which would make it impossible to plan missions against UI
elements that were overflown by many flights (such as the front line).

As an added bonus, it looks a bit nicer.

This impacts the test in an odd way, but the cure for that is probably
rewriting the test to not use a mock now that we've figured out how to
do that.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/3295.
2023-12-18 20:16:08 -08:00
Starfire13
80cb440e7d Adds Private Military Company - Russian (Hard) faction.
This is a new faction that expands on the current PMC Russian faction by
adding in a substantial number of new units for additional variety and
challenge. It'll be the default faction for my helicopter campaign (I'll
open a PR for that tomorrow. It's all done apart from the campaign
description).
2023-12-18 17:49:12 -08:00
Starfire13
e970c281e8 Add DEAD loadouts to AH-64D, KA-50, and KA-50 BS3 (#3301) 2023-12-18 17:41:19 -08:00
dependabot[bot]
b863e2fb83 Bump pyinstaller from 5.13.0 to 5.13.1
Bumps [pyinstaller](https://github.com/pyinstaller/pyinstaller) from 5.13.0 to 5.13.1.
- [Release notes](https://github.com/pyinstaller/pyinstaller/releases)
- [Changelog](https://github.com/pyinstaller/pyinstaller/blob/develop/doc/CHANGES.rst)
- [Commits](https://github.com/pyinstaller/pyinstaller/compare/v5.13.0...v5.13.1)

---
updated-dependencies:
- dependency-name: pyinstaller
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-17 18:45:43 -08:00
Starfire13
3007a96343 Add DEAD capability to AH-64D Blk II 2023-12-17 18:43:16 -08:00
Starfire13
463981f4bf Add DEAD mission capability to Blackshark 3 2023-12-17 18:43:05 -08:00
Starfire13
816d1cd787 Add DEAD mission capability to KA-50 2023-12-17 18:42:54 -08:00
zhexu14
4631ee0d74 Doctrine load from YAML (#3291)
This PR refactors the Doctrine class to load from YAML files in the
resources folder instead of being hardcoded as a step towards making
doctrines moddable (Issue #829).

I haven't added anything to the changelog as a couple of things should
get cleaned up first:
- As far as I can tell, the flags in the Doctrine class (cap, cas, sead
etc.) aren't used anywhere. Need to test further, and if they're truly
not used, will remove them.
- Probably need to update the Wiki
2023-12-17 18:42:31 -08:00
zhexu14
a213215c3f Fix exception when campaign has only off map CPs.
This PR fixes an exception in custom campaigns that only contain off map
spawns.
2023-12-15 14:25:11 -08:00
Starfire13
b014f2e543 Improve F-15E S4+ loadouts (#3286)
I've come to realise that two external tanks is overkill for pretty much
all A2G mission types. The AI no longer have a problem with fuel, and
player flights will essentially never run out of fuel with the 2 CFTs
and a single external tank. I have done 700+ mile trips at mil power the
whole way with fuel to spare. I have therefore switched all A2G mission
loadouts to a single tank. A2A loadouts still carry 2 tanks, as players
may require the extra fuel if they make very extensive use of
afterburner in air combat.

It turns out the GBU31v3 JDAMs are bugged in more than one way. We've
known that they vanish if carried in pairs on the CFT pylons, but now it
turns out their penetration doesn't actually work. This means they are
no better in any way than the GBU31v1s, which are not bugged on CFT
pylons.

I have therefore removed the penetrator JDAMs from all loadouts,
replacing them with regular JDAMs.
2023-12-06 16:46:16 -08:00
Nosajthedevil
f3d3c5f43a Aim-9 Updates (#3287)
Adds the Aim-9P3 between the Aim-9P5 and the Aim-9P. Also adds fallback
support for sidewinder versions for the VSN 104 mod, the JAS39 mod, and
the AJS-37.
2023-12-06 16:45:38 -08:00
Dan Albert
5ee3afeddb Disconnect log signals on exit.
If we don't do this, the uvicorn server may log its shutdown after the
Qt application has closed, and the signal this attempts to emit may not
be valid. Disconnect the log signals when the application exits to
prevent that.

There's actually another solution that I thought would be better, but I
couldn't get it to work:
https://www.pyinstaller.org/en/stable/feature-notes.html#automatic-hiding-and-minimization-of-console-window-under-windows
describes a way to have pyinstaller hide or minimize the console rather
than disabling it entirely. I was never really fond of getting rid of
the console window in the first place, but it did bother some users. If
we could get the hide or minimize option working, that'd probably avoid
bothering users, but also make the logs much easier to find, get us out
of the trouble of maintaining our own log viewer, and fix the problem
mentioned in the comment I add here (the log window only works if
there's only one in memory log handler).

Another option would be ditching our log window and instead just having
that menu item open the log file or directory in whatever program the OS
defaults to (probably notepad). It would still have the quirk of maybe
needing to open more than one location, since logging is use
configurable.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/3278.
2023-12-02 15:59:00 -08:00
Dan Albert
88591fd18c Downgrade Qt.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/3276.
2023-12-02 15:01:07 -08:00
Dan Albert
f5573cfc19 Revert "Update to Python 3.12."
Might fix https://github.com/dcs-liberation/dcs_liberation/issues/3276.
If not, we need to revert the Qt upgrade too, and if we downgrade Qt we
can't use Python 3.12 anyway.

This reverts commit 65eb10639b.
2023-12-02 15:01:07 -08:00
Dan Albert
f7141a9882 Fix a few more Pydantic conversions.
One of the newer versions got a lot more strict. It now only expects
dicts that match the model, or objects of the model. Previously it also
accepted objects which had the same properties as the model. Convert a
few more LatLngs to LeafletPoints.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/3279.
2023-12-02 12:25:01 -08:00
dependabot[bot]
a599b503f8 Bump @adobe/css-tools from 4.3.1 to 4.3.2 in /client
Bumps [@adobe/css-tools](https://github.com/adobe/css-tools) from 4.3.1 to 4.3.2.
- [Changelog](https://github.com/adobe/css-tools/blob/main/History.md)
- [Commits](https://github.com/adobe/css-tools/commits)

---
updated-dependencies:
- dependency-name: "@adobe/css-tools"
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-01 16:15:04 -08:00
Dan Albert
6c4b8c81ee Update mypy.
Needed so mypy can recognize the new Python 3.12 generic syntax.
2023-12-01 16:14:54 -08:00
Dan Albert
2447cc156d Update black.
Required for the new syntax in Python 3.12.
2023-11-30 21:10:14 -08:00
Dan Albert
28954d05eb Downgrade pyinstaller.
I forgot to test the pyinstaller binary when I upgraded all the other
dependencies, and there's a breaking change in 6.0.0:

https://pyinstaller.org/en/latest/CHANGES.html#incompatible-changes

> All of onedir build's contents except for the executable are now moved
> into a sub-directory (called _internal by default). sys._MEIPASS is
> adjusted to point to this _internal directory. The breaking
> implications for this are:
>
> * Assumptions that os.path.dirname(sys.executable) == sys._MEIPASS
>   will break. Code locating application resources using
>   os.path.dirname(sys.executable) should be adjusted to use __file__
>   or sys._MEIPASS and any code locating the original executable using
>   sys._MEIPASS should use sys.executable directly.
> * Any custom post processing steps (either in the .spec file or
>   externally) which modify the bundle will likely need adjusting to
>   accommodate the new directory.

This is actually great because it declutters the top level directory to
just `dcs_liberation.exe` and a directory named `_internal` that has all
the guts, but the CWD is no longer the directory that has `resources/`
in it, so we can't find any of our resources. There are a few options
for fixing that (cd into that directory probably being the easiest, or
we could stop relying on CWD relative paths), but for now just downgrade
to unbreak the build.
2023-11-30 21:01:13 -08:00
Dan Albert
65eb10639b Update to Python 3.12. 2023-11-30 20:45:19 -08:00
Dan Albert
7bc35ef7f4 Update most Python dependencies.
A lot of the dependency versions we have pinned don't have wheels for
Python 3.12. Update almost all of them so we can upgrade Python.

The few that weren't upgraded here are black and mypy, since those will
be a bit invasive, and Pillow, which has an API change I don't want to
deal with right now (I've got a commit on another machine that has
already done the migration, so I'll do it later).
2023-11-30 20:24:28 -08:00
Starfire13
46766ecbd4 Remove AI F-15E from Starfire's campaigns.
Now that the F-15E Suite 4+ has JDAMs and the bug preventing AI from
using LGBs has been fixed, I have removed the AI-only F-15Es from my
campaigns. Also minor tweaks to a couple of squadron types/sizes based
on play-testing results.
2023-11-30 19:12:45 -08:00
Dan Albert
3469d08461 Remove recommendation to dedicated server.
DCS multithreading made this unnecessary.
2023-11-30 19:10:26 -08:00
Dan Albert
28d959bba0 Fix disappearing aircraft when deleting packages.
There are a few different code paths for deleting packages depending on
the state of the package, and two of them were deleting items from a
list they were iterating over without first making a copy, causing each
iteration of the loop to skip over a flight, making it still used since
the flight was never deleted, but unreachable since the package that
owned it was deleted.

This only happened when the package was canceled in its draft state
(the user clicked the X without ever saving the package), or if the user
canceled a package mid fast forward (the controls for which aren't even
visible to users) while only a portion of the package was active. In
both cases, only even numbered flights were lost.

There's a better fix lurking in here somewhere but the interaction with
the Qt model complicates it. Fortunately that mess would be cleaned up
automatically by moving this dialog into React, which we'll do some day.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/3257.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/3258.
2023-11-30 19:00:58 -08:00
Dan Albert
b99eb49dcf Renumber flight members for meatbags.
Puny humans count wrong, but we ought to match DCS.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/3244.
2023-11-30 18:47:43 -08:00
Starfire13
c6f812238c Update Exercise Vegas Nerve.
Updated Exercise Vegas Nerve with off map spawns for B-52 and B-1.
2023-12-01 02:02:21 +00:00
Starfire13
cc5b5fa3bb Add new Mariana Islands campaign - Operation Velvet Thunder.
Vietnam War era campaign for the Mariana Islands map, utilising the two
new Vietnam War factions.
2023-12-01 01:57:50 +00:00
Starfire13
5271b3d32c Switch F-15E S4+ loadouts from LGBs to JDAMs (AI still won't use LGBs) (#3259)
It appears the AI is still incapable of using LGBs (and laser JDAMs),
even though Razbam had said the issues was fixed. I have switched
loadouts to JDAMs because the AI will use those.
2023-11-30 17:56:34 -08:00
Starfire13
8f4192edc3 Fix Operation Grabthar's Hammer map object strike target.
This fixes a map object strike target (yes, just one. Fortunately!) that
was broken by the latest DCS open beta update that removed the buildings
the strike target was using.
2023-11-30 17:51:55 -08:00
Starfire13
183d6df8bf Add guided bombs to F-15E Suite 4+ loadouts.
GBUs have been added to the F-15E Suite 4+ loadouts

Also switched CAP loadouts to 2 external tanks instead of 3 to improve
aircraft performance, as 2 tanks is plenty for players and the AI has
infinite fuel now.
2023-11-18 18:51:42 -08:00
Dan Albert
a825651330 Update pydcs.
Terrain updates for Normandy and South Atlantic.
2023-11-18 15:00:21 -08:00
Dan Albert
f3c02816fc Update pydcs.
Includes F-15E JDAM support.
2023-11-18 14:54:14 -08:00
Starfire13
c4e2e45650 Add Vietnam War factions for USA and NVA.
This adds factions for Vietnam War for both the US and North Vietnamese
Army.
2023-11-18 14:20:14 -08:00
Starfire13
6613642517 Add LARC-V and Speedboat.
This adds LARC-V to Liberation (required by USA 1970)
Also adds Speedboat to Liberation (required by NVA 1970)

Both units are available via pydcs but have not been added to Liberation
thus far as no factions used them (until now).
2023-11-18 22:12:40 +00:00
Dan Albert
b73ca2c62e Update bug templates. 2023-11-11 13:32:10 -08:00
Dan Albert
8abd3c7cf9 Fix typo in changelog. 2023-11-11 13:28:57 -08:00
Dan Albert
f8a72d8f22 Bump version to 10.0.0. 2023-11-10 19:15:41 -08:00
dependabot[bot]
a29fd7a14c Bump axios from 1.1.2 to 1.6.0 in /client
Bumps [axios](https://github.com/axios/axios) from 1.1.2 to 1.6.0.
- [Release notes](https://github.com/axios/axios/releases)
- [Changelog](https://github.com/axios/axios/blob/v1.x/CHANGELOG.md)
- [Commits](https://github.com/axios/axios/compare/v1.1.2...v1.6.0)

---
updated-dependencies:
- dependency-name: axios
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-10 19:03:42 -08:00
Dan Albert
f2a879fc6f Add Linebacker to bluefor modern. 2023-11-10 15:07:49 -08:00
Dan Albert
fdea746323 Add C-RAM LPWS.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/3233.
2023-11-10 15:07:49 -08:00
Starfire13
7f8c2f073c Updates and fixes to Operation Grabthar's Hammer 2023-11-10 12:43:53 -08:00
dependabot[bot]
7db4d438ce Bump @babel/traverse and @trivago/prettier-plugin-sort-imports
Bumps [@babel/traverse](https://github.com/babel/babel/tree/HEAD/packages/babel-traverse) to 7.23.2 and updates ancestor dependencies [@babel/traverse](https://github.com/babel/babel/tree/HEAD/packages/babel-traverse) and [@trivago/prettier-plugin-sort-imports](https://github.com/trivago/prettier-plugin-sort-imports). These dependencies need to be updated together.


Updates `@babel/traverse` from 7.19.3 to 7.23.2
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.23.2/packages/babel-traverse)

Updates `@babel/traverse` from 7.17.3 to 7.23.2
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.23.2/packages/babel-traverse)

Updates `@trivago/prettier-plugin-sort-imports` from 3.3.0 to 4.2.1
- [Release notes](https://github.com/trivago/prettier-plugin-sort-imports/releases)
- [Changelog](https://github.com/trivago/prettier-plugin-sort-imports/blob/main/CHANGELOG.md)
- [Commits](https://github.com/trivago/prettier-plugin-sort-imports/compare/v3.3.0...v4.2.1)

---
updated-dependencies:
- dependency-name: "@babel/traverse"
  dependency-type: indirect
- dependency-name: "@babel/traverse"
  dependency-type: indirect
- dependency-name: "@trivago/prettier-plugin-sort-imports"
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-01 19:12:10 -07:00
Dan Albert
efa47e1550 Fix allocation range for Link 4.
Prior to DCS 2.9 Jester was able to use datalink frequencies outside the
range the aircraft was capable of, but this has presumably always been
broken for human RIOs.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/3222.
2023-11-01 18:47:00 -07:00
Dan Albert
c010ef9994 Add support for DCS 2.9's AI unlimited fuel.
This is enabled by default because I can't think of a time where it's
ever been more fun to watch the AI run out of fuel after cycling between
afterburner and speedbrake for twenty minutes.

This is only lightly tested (I verified that the task shows up
appropriately in the ME when set, not when unset, and never for
players), since the interesting part of the implementation is up to ED.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/3201.
2023-11-01 18:08:04 -07:00
Dan Albert
82a200c53a Update pydcs.
The new version has support for the unlimited fuel option for AI
flights.
2023-11-01 18:08:04 -07:00
Starfire13
c2c0119132 Add naval vessels to Egypt faction 2023-11-01 17:03:21 -07:00
Starfire13
8dca91f533 Starfire's campaign updates 2023-11-01 16:59:34 -07:00
zhexu14
ac2fbc2940 Support planning TARCAP at last airfield.
This PR addresses #771 by adding special handling for the scenario where
there is only one remaining enemy airfield. An example of the race track
generated using this logic is shown below.

![Screenshot 2023-10-31
230938](https://github.com/dcs-liberation/dcs_liberation/assets/64713351/3fb2027e-f496-4325-a3c5-2abe2a45b58f)

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/771.
2023-11-01 16:52:35 -07:00
MetalStormGhost
da22b8ba43 Update A-4E-C mod support to version 2.2.0.
Updated Community A-4E-C mod version pydcs extension to 2.2.0 release.
2023-11-01 16:47:31 -07:00
Starfire13
7bcd669e6e Updated YAMLs for some of Starfire's campaigns
Updates for:
Final Countdown 2
Operation Vectron's Claw
Exercise Bright Star
Operation Grabthar's Hammer
2023-10-24 21:53:42 -07:00
Starfire13
66f175fd65 Add F-4E to Egypt 2000 faction
Add F-4E Phantom II to Egypt 2000 faction as they were in active service
until 2014.
2023-10-24 21:45:12 -07:00
Starfire13
2af5d8ae01 Update S-3 DEAD task priority.
Bumping from 100 to 200 so it's preferred over WW2 aircraft but less
preferred than B-52.
2023-10-23 20:36:45 -07:00
Starfire13
30a4110c57 B1 loadout updates.
Updates B1 loadout, replacing iron bombs with JDAMs. Also switches DEAD
loadout to JSOW-C.
2023-10-23 20:36:08 -07:00
Starfire13
61f6184f9b Update B52 loadout.
Updates anti-ship loadout as harpoons are now mounted on wing pylons on
the new model rather than in the bomb bay
2023-10-23 20:35:38 -07:00
Dan Albert
b42a8c78d1 Fix task priority script for display name split.
`name` was split into an ID and a display name a while back, but this
was never updated to account for that.
2023-10-23 17:26:25 -07:00
Starfire13
bf8a07fe15 S3 Viking loadout and mission type update
Updates the S3 Viking so they can now do DEAD (since the new model can carry SLAMs). Also updates the loadouts for all the other mission types as they are outdated (2000 pounders for anti-runway, 500 pounders for strike, Mavericks for BAI/CAS, etc).
2023-10-23 17:19:14 -07:00
Starfire13
6122c8c42d Add DEAD task capability to the S-3. 2023-10-23 17:19:14 -07:00
Thomas MONZIE
dce4206130 Tripoint update : carrier + compatibility 2023-10-22 13:02:45 -07:00
Thomas MONZIE
eada2ba9ae Bump campaign version number up to 11 2023-10-22 13:02:45 -07:00
Dan Albert
376c1137d7 Fix stale waypoint tasks for custom flight plans.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/3189.
2023-10-21 15:35:05 -07:00
Dan Albert
884993dd46 Fix empty string CLSID issue for default loadouts.
We had two different paths for converting pydcs loadouts because pydcs's
APIs for some reason return the loadouts in different shapes which made
it difficult to share the code for converting them. Rather than fix the
bug in both places, extract the common code and adapt the result of one
API to match the other.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/3171.
2023-10-20 14:47:40 -07:00
Dan Albert
c5d5ea81de Ensure speed lock for waypoint 0.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/3195.
2023-10-20 14:28:19 -07:00
Dan Albert
0e01aaf9cd Filter out empty string CLSIDs.
There's more detail in the comment, but this fixes an issue where some
Mosquito loadouts could not be loaded.

Might fix https://github.com/dcs-liberation/dcs_liberation/issues/3171.
There aren't enough instructions in the bug for me to be sure, but it
sounds like a similar problem, although I came across it with bombs
rather than rockets.
2023-10-20 14:22:36 -07:00
Dan Albert
f9e7370b35 Update pydcs for 2.9.0.46801 Open Beta.
F-22 mod data is out of date. Removed the broken bits, but someone
should probably update that mod.
2023-10-19 19:48:27 -07:00
Dan Albert
dfb74cfd48 Fix kneeboard generation following Pillow update.
We don't have tests for this, so dependabot broke it and we didn't
notice.
2023-10-19 19:47:36 -07:00
zhexu14
32b3793082 Fix issues with waypoint editing.
fix a number of regressions in the flight waypoint list by changing the
indexing and finding a work-around to blocking of signals

This PR addresses some (but not all) recently reported issues with the
waypoints screen reported in Issue #3188 . This PR was tested by:

- Changing the waypoint altitude and confirming it shows up correctly
when reloading the waypoint list window and on the map
- Adding a waypoint and confirming that it shows up immediately and
persists on reload
- Deleting a waypoint (except the first waypoint) and confirming that it
is removed immediately and persists on reload,

Known issues: first waypoint (typically hold) cannot be deleted -- still
looking into this one.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/3188.
2023-10-10 18:05:57 -07:00
dependabot[bot]
990f1c37b8 Bump electron from 21.1.0 to 22.3.25 in /client
Bumps [electron](https://github.com/electron/electron) from 21.1.0 to 22.3.25.
- [Release notes](https://github.com/electron/electron/releases)
- [Changelog](https://github.com/electron/electron/blob/main/docs/breaking-changes.md)
- [Commits](https://github.com/electron/electron/compare/v21.1.0...v22.3.25)

---
updated-dependencies:
- dependency-name: electron
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-05 20:12:14 -07:00
dependabot[bot]
4d7e1e1946 Bump pillow from 9.3.0 to 10.0.1
Bumps [pillow](https://github.com/python-pillow/Pillow) from 9.3.0 to 10.0.1.
- [Release notes](https://github.com/python-pillow/Pillow/releases)
- [Changelog](https://github.com/python-pillow/Pillow/blob/main/CHANGES.rst)
- [Commits](https://github.com/python-pillow/Pillow/compare/9.3.0...10.0.1)

---
updated-dependencies:
- dependency-name: pillow
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-05 20:11:55 -07:00
Dan Albert
ca268a2252 Add changelog note for finance menu UI fix. 2023-10-03 22:05:37 -07:00
zhexu14
2686a1ea77 Fix odd whitespace in finance menu.
Moves the stretch to the bottom of the page to avoid awkward whitespace
in the middle. Presumably the totals used to be at the bottom (since
that's a normal place for a total), but it was moved to the top,
probably since that was the most interesting data and we didn't want to
scroll though all the details to find that one point.

This also removes the unused code path where the total would be shown at
the bottom.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/1288.
2023-10-03 21:55:59 -07:00
Dan Albert
256c9ce73d Add a package kneeboard page.
The package page shows each flight member in the whole package. The data
shown for now is the callsign, task, radio frequency, and laser code.
The STN for each flight will be added once that's done.

This does generate one package page per flight. That means that packages
where multiple flights have players and use the same aircraft type will
have some duplicated pages, but the alternative is that some players
would need to skip past all their flight members' pages to find their
package page instead of having it grouped with their own.
2023-10-03 21:50:29 -07:00
Dan Albert
e9133bffab Group briefing data by package.
This is just the refactor to make way for the real change: adding a
package page to the kneeboard so players can get package-level
information like other radio, laser, and STNs.
2023-10-03 21:50:29 -07:00
zhexu14
f9916e47d8 address issue 3175 by introducing special divide by zero handling 2023-10-01 23:08:05 -07:00
tmz42
b1b88c4335 Updates for tmz's campaigns.
Updated Fuzzle's campaigns for new squadron rules compatibility.
2023-10-01 23:16:41 +00:00
zhexu14
20574e3fbb address issue 3162 by applying threshold to CVN position check 2023-10-01 16:10:10 -07:00
Starfire13
1ed37ff75e Final Countdown 2 update for campaign inversion
Fixes incorrect airfield assignment when campaign is inverted
2023-10-01 16:09:35 -07:00
Dan Albert
69ec9adec7 Remove code for old squadron rules. 2023-10-01 12:21:37 -07:00
Dan Albert
63584321c6 Bump campaign version for squadron sizes.
The old mode where squadrons started empty and had no size limit is
going away.

I bumped the campaign versions for the ones that claimed support and
tested a handful. All of Fuzzle's campaigns actually had the wrong
version in the yaml. They claim support for this but none that I tested
actually fit within the limits (despite having sizes defined). Either it
was supposed to be 10.7, or maybe the airports lost some parking.
2023-10-01 12:21:37 -07:00
Dan Albert
2344fc0b5c Add campaign support for ferry-only bases.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/3170.
2023-09-21 21:34:31 -07:00
Dan Albert
e43874e553 Increase max distance for waypoint solver.
1000km isn't large enough in the case where there's an off-map spawn
that's a long way from the target, but still in range for aircraft like
the B-1. Double it, which for now is enough to fix the one pathological
case we know.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/3156.
2023-09-20 22:02:01 -07:00
Dan Albert
3862ec1b2e Convert escort request to a waypoint property.
Another step in reducing the rigidity of FlightPlan and making it
testable.

There is one intentional behavior change here: escort flights no longer
request escorts. That actually has a very minimal effect because these
properties are only used for two things: determining if a package needs
escorts or not, and determining when the TARCAP should show up and
leave. Since escorts won't have been in the package when the first part
happens anyway, that has no effect. The only change is that TARCAP won't
show up earlier or stay later just because of a TOT offset for an escort
flight.
2023-09-11 22:25:58 -07:00
Dan Albert
502d37058c Remove dead code. 2023-09-11 20:51:16 -07:00
Dan Albert
b7723843c6 Migrate sweep ingress's tasks to waypoint actions. 2023-08-29 21:57:17 -07:00
Dan Albert
c00f853f34 Roll-over excess time from tasks. 2023-08-29 21:57:17 -07:00
dependabot[bot]
8c6b360e65 Bump @adobe/css-tools from 4.0.1 to 4.3.1 in /client
Bumps [@adobe/css-tools](https://github.com/adobe/css-tools) from 4.0.1 to 4.3.1.
- [Changelog](https://github.com/adobe/css-tools/blob/main/History.md)
- [Commits](https://github.com/adobe/css-tools/commits)

---
updated-dependencies:
- dependency-name: "@adobe/css-tools"
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-29 21:43:02 -07:00
Dan Albert
cb9063b5be Remove bingo estimates from FlightPlan.
This doesn't need to be a part of FlightPlan, and it's easier to test if
it isn't. Move it out and add the tests.

It's pretty misleading to allow this in the core of the flight plan code
anything. This is an extremely unreliable estimate for most aircraft so
it should be more clearly just for briefing purposes.
2023-08-23 20:14:16 -07:00
Dan Albert
99eed33241 Remove useless TravelTime class.
This is only called for real in one spot. The other callers should have
been deferring to the one real caller.
2023-08-22 20:31:20 -07:00
Dan Albert
1902618f45 Remove dead code. 2023-08-21 22:42:00 -07:00
Starfire13
782389bd89 Update up_the_coast enemy faction
Switch default enemy faction to Russia 1975 from the now-removed Russia 1975 (Mi-24).
2023-08-19 19:14:50 -07:00
Starfire13
5025fe9e34 Update russia_1975.yaml
Adds Mi-24P flyable Hind
2023-08-19 11:31:07 -07:00
Starfire13
27689b675e Delete russia_1975 (Mi-24P).yaml
Rather than having a separate faction file that is identical to the Russia 1975 faction file but includes the Hind, might as well just add the Hind to the standard Russia 1975 faction.
2023-08-19 11:31:07 -07:00
Starfire13
6791af16d1 Delete final_countdown_2.yaml
No longer needed as this custom faction is already included in the campaign yaml
2023-08-19 11:31:07 -07:00
Starfire13
53580b2088 Update Sweden 1970
Change the Mirage 2000 (a stand in for the Draken) to the Mirage F1 as that is a closer match in terms of capabilities and era.
2023-08-19 11:31:07 -07:00
Starfire13
42bffa06ae Delete russia_1970_limited_air.yaml 2023-08-19 11:31:07 -07:00
Starfire13
626e73d641 Delete normandy_small.miz 2023-08-18 16:26:25 -07:00
Starfire13
667d6e3b8a Delete normandy_full.miz 2023-08-18 16:26:25 -07:00
Dan Albert
eebb172333 Remove flight-size-specific formations.
No reason to do this, and it's making the task rework annoying.
2023-08-17 20:27:34 -07:00
Dan Albert
5f3e342a0e Use SEAD for SEAD.
The F-14 was fixed to allow this in the latest patch.
2023-08-16 19:42:11 -07:00
Dan Albert
d3b4d45bd6 Update pydcs. 2023-08-16 16:50:49 -07:00
Starfire13
a5a3b09379 New version of Exercise Bright Star with carrier 2023-08-15 16:51:28 -07:00
Dan Albert
87441b8939 Formalize waypoint actions.
Create a WaypointAction class that defines the actions taken at a
waypoint. These will often map one-to-one with DCS waypoint actions but
can also be higher level and generate multiple actions. Once everything
has migrated all waypoint-type-specific behaviors of
PydcsWaypointBuilder will be gone, and it'll be easier to keep the sim
behaviors in sync with the mission generator behaviors.

For now only hold has been migrated. This is actually probably the most
complicated action we have (starting with this may have been a mistake,
but it did find all the rough edges quickly) since it affects waypoint
timings and flight position during simulation. That part isn't handled
as neatly as I'd like because the FlightState still has to special case
LOITER points to avoid simulating the wrong waypoint position. At some
point we should probably start tracking real positions in FlightState,
and when we do that will be solved.
2023-08-13 12:43:59 -07:00
Dan Albert
2f385086fd Don't flag negative starts for active flights.
If the flight has already passed its start up time, this isn't a
negative start.
2023-08-13 12:39:56 -07:00
Dan Albert
aaf66107ad Improve type inference in loiter flight plans. 2023-08-13 12:28:43 -07:00
Dan Albert
59756ce14c Differentiate total time and travel time.
There's an ugly special case in flight simulation to handle hold points
because we don't differentiate between the total time between two
waypoints (which can include delays from actions like holding) and
travel time. Split those up and remove the special case.
2023-08-13 11:36:05 -07:00
Dan Albert
bf1e559a41 Remove dead code. 2023-08-13 11:36:05 -07:00
Dan Albert
5f4a75601b Show the real front line bounds on the map.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/1067.
2023-08-10 21:01:44 -07:00
Dan Albert
c4358daccc Revert "Remove dead code."
Not used by python, but is used by jinja templates.

This reverts commit 1f3eee90f1.
2023-08-10 00:53:29 -07:00
Dan Albert
723b96cd51 Fix faction templates for unit type prop changes. 2023-08-10 00:52:45 -07:00
Dan Albert
3f0b565b82 Drop save compat hacks.
The CAS flight plan tweaks break save compat in a way that's not as easy
to fix. Accept it and drop the existing hacks since they won't be useful
any more.
2023-08-10 00:47:13 -07:00
Dan Albert
cb3bf56d84 Add a real CAS ingress point.
Putting the ingress point directly on one end of the FLOT means that AI
flights won't start searching and engaging targets until they reach that
point. If the front line has advanced toward the flight's departure
airfield, it might overfly targets on its way to the IP.

Instead, place an IP for CAS the same way we place any other IP. The AI
will fly to that and start searching from there.

This also:

* Removes the midpoint waypoint, since it didn't serve any real purpose
* Names the FLOT boundary waypoints for what they actually are

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2231.
2023-08-10 00:47:13 -07:00
Dan Albert
9460586cfe Mark the AI-only F-15E more clearly. 2023-08-09 22:50:05 -07:00
Dan Albert
3c2ace09f3 Add display name property for unit types.
Unlike the variant ID, this can be changed without breaking save compat.
2023-08-09 22:50:05 -07:00
Dan Albert
58d8203c83 Fix unit variants to actually allow variance.
This was always the intent, but apparently it wasn't implemented
correctly. All properties of the unit type can now be overridden per
variant.
2023-08-09 22:50:05 -07:00
Dan Albert
1f3eee90f1 Remove dead code. 2023-08-09 22:27:21 -07:00
Dan Albert
0be6952a93 Rename UnitType.name what it is: the variant ID.
This property affects safe compat because the ID is what gets preserved
in the save, but it's unfortunately also used as the display name, which
means changing the display name breaks save compat. It also prevents us
from changing display names without breaking faction definitions.

This is the first step in fixing that. The next is adding a separate
display_name property that can be updated without breaking either of
those.
2023-08-09 21:53:25 -07:00
Dan Albert
09f1af37fd Force dumping debug info on recreate.
We need a way to debug successful solvers that's still targeting to a
specific flight. This will do for now.
2023-08-08 21:46:52 -07:00
Dan Albert
257f2072e8 Add test cases found by fuzzer. 2023-08-08 21:46:52 -07:00
Dan Albert
1708baf772 Add fuzz testing for waypoint solvers.
This fuzz test generates random inputs for waypoint solvers to check if
they can find a solution. If they can't, the debug info for the solver
is dumped to the testcases directory. Another test loads those test
cases, creates a solver from them, and checks that a solution is found.
Obviously it won't be immediately, but it's a starting point for fixing
the bug and serves as a regression test afterward.
2023-08-08 21:46:52 -07:00
Dan Albert
6b6c4f4112 Migrate IP placement to WaypointSolver. 2023-08-08 21:46:52 -07:00
Dan Albert
5cb4c363e3 Build common interface for waypoint geometry constraints.
This is a replacement for the existing "zone geometry" classes that are
currently used for choosing locations for IP, hold, and join points.
The older approach required the author to define the methods for
choosing locations at a rather low level using shapely APIs to merge or
mask geometries. Debug UIs had to be defined manually which was a great
deal of work. Worse, those debug UIs were only useable for *successful*
waypoint placement. If there was a bug in the solver (which was pretty
much unavoidable during development or tuning), it wasn't possible to
use the debug UI.

This new system adds a (very simple) geometric constraint solver to
allow the author to describe the requirements for a waypoint at a high
level. Each waypoint type will define a waypoint solver that defines one
or more waypoint strategies which will be tried in order. For example,
the IP solver might have the following strategies:

1. Safe IP
2. Threat tolerant IP
3. Unsafe IP
4. Safe backtracking IP
5. Unsafe backtracking IP

We prefer those in the order defined, but the preferred strategies won't
always have a valid solution. When that happens, the next one is tried.

The strategies define the constraints for the waypoint location. For
example, the safe IP strategy could be defined as (in pseudo code):

* At least 5 NM away from the departure airfield
* Not farther from the departure airfield than the target is
* Within 10 NM and 45 NM of the target (doctrine dependent)
* Safe
* Within the permissible region, select the point nearest the departure
  airfield

When a solver fails to find a solution using any strategy, debug
information is automatically written in a GeoJSON format which can be
viewed on geojson.io.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/3085.
2023-08-08 21:46:52 -07:00
Dan Albert
13ccf3f536 Add __str__ for Distance. 2023-08-08 01:56:18 -07:00
Dan Albert
42fa5dce94 Add name to Doctrine. 2023-08-08 01:56:06 -07:00
Starfire13
d1baf33d86 Add F-15E Suite 4+ to Allied Sword faction.
Fuzzle's Allied Sword campaign has a custom faction in the campaign
yaml, and it wasn't updated when Razbam's Mudhen was released. I've
added it in.
2023-08-07 21:02:28 -07:00
Dan Albert
a0ab46af8f Note the ARA Veinticinco de Mayo in the changelog. 2023-08-01 18:33:00 -07:00
Nosajthedevil
58ede1b888 Add support for ARA Veinticinco de Mayo.
Includes an Argentina 1982 faction for testing purposes, although it's
sparse because of a lack of assets in DCS.

Note that the carrier is mispelled as the Vienticinco in the game.

Includes prerequisite pydcs update.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/3123.
2023-08-02 01:26:08 +00:00
Dan Albert
e72b1b3ae7 Update pyinstaller and hooks.
3149c93016
is needed to fix the pyinstaller package for shapely 2.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/3127.
2023-08-01 18:15:08 -07:00
Dan Albert
2c51e126b7 Fix shapely error during mission generation.
It seems shapely doesn't allow `unary_union` on collections any more.
2023-07-31 17:32:46 -07:00
Dan Albert
4f04a2d142 This brace belonged to the now deleted "settings". 2023-07-30 14:34:58 -07:00
Dan Albert
899620c242 Add TODO note to joinzonegeometry. 2023-07-29 21:56:56 -07:00
Dan Albert
431165ab83 Add __str__ for Heading. 2023-07-29 21:56:43 -07:00
Dan Albert
703bb98b62 Update Shapely.
I need the new to_geojson API.
2023-07-29 21:45:20 -07:00
Starfire13
6610162c44 Add Operation Noisy Cricket campaign. 2023-07-29 19:43:35 -07:00
Starfire13
09f0b0b315 Add BLU-107 to OCA/Runway loadout
I had originally opted for iron bombs for anti-runway as the AI sometimes miss with the Durandals because they release them from too high an altitude. But after using them for a while, I am finding they appear to do no worse than with iron bombs. So, might as well let them use the dedicated anti-runway weapon.
2023-07-29 17:35:51 -07:00
Dan Albert
d81ed26fa6 Stop gap fix for AI speed to nav points.
This isn't a great fix for the reason I mention in the comment, but it's
quick and actually is accurate since it looks like we don't actually
handle formation speeds correctly in most cases...

This is probably as "fixed" as this is going to get for now since most
of the flight planning code is in the process of being rewritten.

https://github.com/dcs-liberation/dcs_liberation/issues/3113
2023-07-29 10:31:05 -07:00
Dan Albert
159120b487 Always re-enable loadout UI for member 0. 2023-07-27 22:28:29 -07:00
Dan Albert
160d464f9a Fix synchronization of loadouts on change.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/3111.
2023-07-27 22:25:51 -07:00
dependabot[bot]
b893378abe Bump certifi from 2022.12.7 to 2023.7.22
Bumps [certifi](https://github.com/certifi/python-certifi) from 2022.12.7 to 2023.7.22.
- [Commits](https://github.com/certifi/python-certifi/compare/2022.12.07...2023.07.22)

---
updated-dependencies:
- dependency-name: certifi
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-27 21:36:24 -07:00
Starfire13
f9f2c79aeb Add Mirage F1 to Iran 2015 2023-07-23 20:10:47 -07:00
Dan Albert
c7a991687c Configure target points for F-15E S4+.
We don't need explicit configuration of initial points. The plane
automatically configures any steerpoint immediately before a target
point as an initial point.

Target offset points and aim points have not been implemented because I
can't find any information the describes their intent.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/3088.
2023-07-23 14:51:56 -07:00
Dan Albert
d2152a259c Handle TOT offsets for patrolling flight plans.
https://github.com/dcs-liberation/dcs_liberation/issues/3107
2023-07-23 11:51:07 -07:00
Dan Albert
5fd29d8c9d Fix negative starts when changing TOT offsets. 2023-07-23 11:51:07 -07:00
Dan Albert
d74ba4a6c9 Fix altering negative TOT offsets.
https://github.com/dcs-liberation/dcs_liberation/issues/3107
2023-07-23 11:51:07 -07:00
Dan Albert
e1dba91b25 Add laser code support for the viper. 2023-07-22 18:34:14 -07:00
Dan Albert
ca5ec65ed1 Remove unused config data from laser code yamls. 2023-07-22 18:23:07 -07:00
Dan Albert
374dd6da9a Clarify that the assigned code is for the TGP. 2023-07-22 18:21:46 -07:00
Dan Albert
e8df6a3d54 Hide properties that have better controls.
The weapon laser codes can be set more easily from the weapon laser code
combo box. Setting the properties explicitly here will just cause
conflicts and annoying UI bugs. Hide those properties from the UI.
2023-07-22 18:14:26 -07:00
Dan Albert
e901d1f538 Add UI for selecting weapon laser codes.
This makes it possible to have the right laser code set for hot start
aircraft that (typically) do not allow changing laser codes when the
engine is on.
2023-07-22 18:14:26 -07:00
Dan Albert
efc2915628 Do not draw empty property rows. 2023-07-22 18:14:26 -07:00
Dan Albert
6c5b35d704 Add laser code property info for the Strike Eagle. 2023-07-22 18:14:26 -07:00
Dan Albert
01e4ebc706 Add laser code config parsing and prop generation. 2023-07-22 18:14:26 -07:00
zhexu14
b10395715d In NewUnitTransferDialog, only list reachable control points.
This PR addresses #3066 by restricting the list of control points in the
new unit transfer dialog to control points reachable from the origin.
This change centralizes the logic for reachable nodes to the
TransitNetworkBuilder class.

This PR was tested by:

1. Loading save from #3066 
2. Using cheat menu to destroy runway at Wadi al Jandali
3. Purchasing units at any of the other control points
4. Pass the turn to allow the purchase to complete
5. Initiating a unit transfer from the other control point and
confirming that Wadi al Jandali does not show up in the list

Steps 2-4 are needed as no ground units show up at Melez when loading
the save directly from the latest dev build.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/3066.
2023-07-22 17:58:38 -07:00
Dan Albert
ad8f3d61ea Add UI for acquiring/releasing TGP laser codes. 2023-07-22 17:57:02 -07:00
Dan Albert
85e11711b6 Pre-allocate laser codes for FLOTs and flights. 2023-07-22 17:57:02 -07:00
Dan Albert
31289adb50 Create a checked, releasable type for laser codes.
The release behavior isn't used yet, but I'm working on pre-allocating
laser codes for front lines and flights to make it easier for players to
pick the laser codes for their weapons.
2023-07-22 17:57:02 -07:00
Dan Albert
d3269bca93 Fix crash when changing squadrons in new flight. 2023-07-22 17:36:56 -07:00
Dan Albert
e35e49e05e Add missing LANTIRN clsid. 2023-07-22 14:28:43 -07:00
Dan Albert
91b56b1573 Add tests for LaserCodeRegistry, clean up.
* Store a deque rather than an iterator so it can be pickled
* Remove mangling from staticmethod (and rename now that it's no longer
  a generator)
* Rename "get" to "alloc" to make the mutation clear
* Move to its own package (the changes I'm working on make this no
  longer mission generator specific)
* Remove useless exception class. It's never caught so the unique type
  isn't needed
2023-07-22 13:44:17 -07:00
zhexu14
6475c6d1ac Fix default faction selection when changing campaigns.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/1491.
2023-07-22 12:35:44 -07:00
Dan Albert
48fff39409 Allow per pilot loadouts and properties.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/3092.
2023-07-20 23:41:21 -07:00
Dan Albert
2d8cc12a37 Update pydcs.
Needed for the fix for all aircraft of the same type sharing whatever
properties were last set.
2023-07-20 23:41:21 -07:00
Dan Albert
f7d5db7f1e Improve UI for flight properties.
Use the new data from pydcs to improve the properties UI:

* Use human readable names
* Use appropriate control types
* Limit min and max values as appropriate for each property
* Show labels

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/3090.
2023-07-19 22:24:44 -07:00
dependabot[bot]
0a82c2b3d1 Bump word-wrap from 1.2.3 to 1.2.4 in /client
Bumps [word-wrap](https://github.com/jonschlinkert/word-wrap) from 1.2.3 to 1.2.4.
- [Release notes](https://github.com/jonschlinkert/word-wrap/releases)
- [Commits](https://github.com/jonschlinkert/word-wrap/compare/1.2.3...1.2.4)

---
updated-dependencies:
- dependency-name: word-wrap
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-19 09:17:50 -07:00
zhexu14
a5eeb83783 Fix anti-runway task generation for LGBs.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/894.
2023-07-17 17:07:01 -07:00
Dan Albert
1f73e02d15 Add cheats for destroying and repairing runways. 2023-07-13 22:08:13 -07:00
Dan Albert
aced4d3ef5 Fix canceling transfers when the airbase is full.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2955.
2023-07-13 21:25:45 -07:00
Dan Albert
5b935db923 Add warnings for invalid fast-forward settings.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2739.
2023-07-13 21:03:08 -07:00
Dan Albert
2a29dd4886 Fix off-by-one error in waypoint deletion.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/3067.
2023-07-13 20:52:39 -07:00
zhexu14
fa5cabace3 Allow more helicopters to operate from LHAs and CVs.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/3072.
2023-07-13 20:16:27 -07:00
Dan Albert
8c6d854732 Always initialize IADS coalition lua tables.
These are read unconditionally, but were only initialized when the
coalition had nodes. When a coalition had no nodes, this caused a nil
access. It's unclear if that had any symptoms, but I expect at the very
least it would break the remainder of the script (so a non-functioning
blue IADS if the red IADS had no nodes).

There's a very small chance this is the culprit behind
https://github.com/dcs-liberation/dcs_liberation/issues/3073.
2023-07-12 19:55:27 -07:00
Dan Albert
9a59db1ed8 Generate anti-ship missions with group attack.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/3068.
2023-07-12 10:33:32 -07:00
Dan Albert
82daa631bf Request DCS log file for mission issues.
Not that anyone reads this.
2023-07-12 01:12:47 -07:00
Dan Albert
19976989ca Improve IP selection near threat zone centers.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2754.
2023-07-11 22:16:18 -07:00
Dan Albert
adabb617f3 Update bug templates for 8.1.0. 2023-07-10 09:52:03 -07:00
dependabot[bot]
dc6a18ccb0 Bump tough-cookie from 4.0.0 to 4.1.3 in /client
Bumps [tough-cookie](https://github.com/salesforce/tough-cookie) from 4.0.0 to 4.1.3.
- [Release notes](https://github.com/salesforce/tough-cookie/releases)
- [Changelog](https://github.com/salesforce/tough-cookie/blob/master/CHANGELOG.md)
- [Commits](https://github.com/salesforce/tough-cookie/compare/v4.0.0...v4.1.3)

---
updated-dependencies:
- dependency-name: tough-cookie
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-09 11:02:17 -07:00
Dan Albert
b549af9cb7 Clean up remaining Flight.from_cp users.
The preferred API for this has been `Flight.departure` for a while.
2023-07-05 22:45:06 -07:00
Dan Albert
de8d42e3e5 Test (most of) the rest of WaypointMarker.
There isn't any UI observable behavior of the dragend of the waypoint,
but we can test that the backend was called. The only uncovered parts of
that component are now error paths, but the error handling in that
component is to just ignore errors, so there's also nothing to test
there.
2023-06-28 22:44:02 -07:00
Dan Albert
02c9fe93c5 Fix waypoint drag and drop.
The fix for https://github.com/dcs-liberation/dcs_liberation/issues/3037
wasn't complete. It seems this `- 1` was here to work around the UI
wrongly having two takeoff points... Now that we fixed that, this also
needs to go.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/3059.
2023-06-27 23:42:14 -07:00
Dan Albert
374759df0f Test most of WaypointMarker.
Unlike the other map tests which heavily rely on mocks, this one uses
React refs to inspect the constructed leaflet objects. The DOM itself
doesn't appear to contain anything worth testing against (react-leaflet
rendering doesn't work like typical React rendering).

This required some infrastructure changes:

1. Forwarded ref from WaypointMarker to Marker so the test can observe
   it. Added a mergeRefs helper (and its own tests) to make that easier.
2. Switched from identity-obj-proxy to jest-transform-stub, because the
   former doesn't produce a useable image for imports, and we need
   usable images for leaflet to be able to render.

This doesn't yet test drag and drop behavior since that requires mocking
the backend, and this commit is already complicated enough. That'll be
next.
2023-06-27 22:41:33 -07:00
Dan Albert
82c234b09e Make save game requirement even more obvious. 2023-06-27 18:12:58 -07:00
Starfire13
427df21da5 Add F-15E Suite 4+ squadrons. 2023-06-27 18:04:31 -07:00
Starfire13
13a6400286 Add LST to final_countdown_2.yaml 2023-06-27 17:55:21 -07:00
Dan Albert
f1e9abd157 Test SupplyRoute. 2023-06-27 00:28:07 -07:00
Dan Albert
eeacc79cb6 Add test for SplitLines. 2023-06-26 23:53:38 -07:00
Dan Albert
054b422cad Move WW2 factions to WW2 transports.
Only for those that require the WW2 asset pack. There don't appear to be
any free WW2 transports.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/3039.
2023-06-26 23:04:35 -07:00
Dan Albert
d54d906593 Make loadout/properties tab scrollable.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/3044.
2023-06-26 22:51:35 -07:00
Dan Albert
bb36b8cad3 Allow factions to specify their cargo ship type.
https://github.com/dcs-liberation/dcs_liberation/issues/3039
2023-06-26 22:16:47 -07:00
Dan Albert
c482b497db Add unit data for the Handy Wind. 2023-06-26 22:16:47 -07:00
Dan Albert
27a60fd91e Prevent Samuel Chase from being in AAA/SHORAD.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2938.
2023-06-26 21:56:57 -07:00
Dan Albert
cc2dfa5d35 Fix off-by-one error in livery selector. 2023-06-26 19:36:44 -07:00
Dan Albert
f7b0dfc3a5 Fix UI waypoint numbering.
The flight plan used to not include a waypoint for departure, so a few
places would create one for the sake of the UI, or were built to assume
there was a missing waypoint that was okay to ignore. At some point we
added them to the flight plan, but never updated the UI, so the waypoint
list in the flight dialog started counting from 1 instead of 0, and the
openapi endpoint wrongly reported two departure waypoints to the front-
end.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/3037.
2023-06-26 18:50:06 -07:00
Dan Albert
4e90c724bf Undo addition of "(AI)" F-15E variant.
This interacts badly with the built-in squadrons:
https://github.com/dcs-liberation/dcs_liberation/issues/3033. Better to
split the display name and "ID" (which is effectively how the key here
is treated), but that's a more invasive change than I'd like to tackle
in this release.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/3033.
2023-06-26 17:54:34 -07:00
Starfire13
fc90b6f2df Update Starfire's campaigns.
* Added Razbam Strike Eagle options.
2023-06-26 17:54:22 -07:00
Starfire13
266c453c99 Fix F-15E Suite 4+ loadouts for the DCS AI.
DCS AI cannot yet use LGBs.

A2G loadouts for anti-unit have been switched to CBU-97s, which appear
to be the most effective weapon type.
A2G loadouts against static targets (OCA/aircraft, OCA/runway, strike)
have been change to Mk82s and Mk84s.
2023-06-25 23:05:15 -07:00
Dan Albert
658a86dff5 Add radio config for the new F-15E.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/3028.
2023-06-22 20:53:06 -07:00
Dan Albert
d31644c46a Razbam F-15E banner and icon.
Just reusing the old one.

https://github.com/dcs-liberation/dcs_liberation/issues/3028
2023-06-22 20:45:47 -07:00
Dan Albert
f27c9f5a3d Add Razbam F-15E to factions with the old F-15E.
https://github.com/dcs-liberation/dcs_liberation/issues/3028
2023-06-22 20:45:47 -07:00
Dan Albert
f805febd43 Add YAML file for Razbam Strike Eagle.
The old DCS AI F-15E is sticking around because the two have very
different weapon sets for now, so it's probably better to use the AI-
only one for squadrons that don't expect players.

I've avoided renaming the old one (we probably should name it "... (AI)"
for clarity) because the rename will break save compat. I have added a
_new_ name that new campaigns can use though.

https://github.com/dcs-liberation/dcs_liberation/issues/3028
2023-06-22 20:45:47 -07:00
Dan Albert
dca02fea31 Update pydcs (Strike Eagle).
https://github.com/dcs-liberation/dcs_liberation/issues/3028
2023-06-22 20:45:47 -07:00
Starfire13
f97cd5d28f Add loadouts for Razbam F-15E Strike Eagle. 2023-06-22 17:47:05 -07:00
Dan Albert
acd40fd9ea Update bug templates for 8.0.0. 2023-06-21 17:19:17 -07:00
Dan Albert
dc0e41c8c1 Dump develop version to 9.0.0. 2023-06-20 18:47:07 -07:00
Dan Albert
59c10f5d71 Remove save compat hacks for saves from 7.
Save compat was broken by pydcs anyway, so these now do nothing but hide
initialization bugs.
2023-06-20 18:47:07 -07:00
Dan Albert
001e7dfed9 Ignore inconsistent DCS beacon information.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/3021.
2023-06-20 18:28:17 -07:00
Dan Albert
cf985d3d37 Test NavMeshLayer. 2023-06-16 22:18:46 -07:00
Dan Albert
1044a1f45f Test FrontLinesLayer. 2023-06-16 22:05:12 -07:00
Starfire13
9fe31859d3 Add Sinai campaign: Exercise Bright Star. 2023-06-16 21:49:13 -07:00
Dan Albert
09417322e7 Partial tests for FrontLine.
We need to mock the backend to usefully test the contextmenu handler.
I'd like to finish all the low hanging fruit before going for that.
2023-06-16 21:39:50 -07:00
Dan Albert
136a9b5f02 Test FlightPlansLayer. 2023-06-16 11:18:16 -07:00
Dan Albert
02f22d4930 Test CullingExclusionZones. 2023-06-16 10:35:31 -07:00
Dan Albert
ca133b9fd1 Add a coverage badge to the readme. 2023-06-15 23:54:19 -07:00
Dan Albert
b1af6dfbe1 Test ControlPointsLayer. 2023-06-15 22:50:39 -07:00
Dan Albert
647d1f57f9 Add tests for CombatLayer. 2023-06-15 22:50:39 -07:00
zhexu14
b250fe2f1e Make waypoint altitudes editable. 2023-06-15 22:41:49 -07:00
Starfire13
3be57bf6bb Add S-300 SAM to Egypt 2000 (#3004)
Adds S-300 as an alternative to Egypt's S-300VM for those who are not
using the High Digits SAM mod.
2023-06-15 22:39:50 -07:00
Dan Albert
3c8d0b023e Test Combat. 2023-06-15 22:24:37 -07:00
Dan Albert
adceb3a224 Add tests for AirDefenseRangeLayer. 2023-06-15 21:58:05 -07:00
zhexu14
ab02cd34c5 bump pyinstaller version
This PR bumps pyinstaller version to fix issues with build.
2023-06-15 12:57:32 -07:00
zhexu14
c74b603d81 restore killed_ground_units as it is relied on to track scenery kills
This PR fixes a regression introduced in
https://github.com/dcs-liberation/dcs_liberation/pull/2792 where
refactoring meant that scenery deaths were not tracked correctly.

This PR has been tested by striking a scenery target and confirming that
it appears in state.json and is updated in Liberation. I've also
confirmed that ground units are tracked.
2023-06-15 03:07:54 +00:00
Nosajthedevil
5815401e73 Update OV10A Weapons files 2023-06-14 20:01:16 -07:00
Starfire13
f463fe50f2 Add Chengdu J-7B to Egypt_2000 2023-06-14 20:00:47 -07:00
Starfire13
f60bf62897 Add missing units to Bluefor Modern 2023-06-14 20:00:32 -07:00
Dan Albert
9d43eb8f03 Handle game over.
The contents are completely uninteresting, but at least it's visible.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/978.
2023-06-12 23:43:26 -07:00
Dan Albert
8f0ca08b89 Move turn passing to post-debrief.
If we're going to show a game over dialog, we need to do so before
moving to the next turn, but we will still want to show the debriefing
window. Move those steps to happen after the debrief window.

https://github.com/dcs-liberation/dcs_liberation/issues/978
2023-06-12 23:43:26 -07:00
Dan Albert
0534f66b30 Allow NGW to be called from anywhere.
Any real end game dialog needs a "new game" button. If only the main
window can usefully call the NGW we'd have to plumb that object through
and call into it from that dialog, which is gross. Just make it easier
to call the wizard.

https://github.com/dcs-liberation/dcs_liberation/issues/978
2023-06-12 22:39:17 -07:00
Nosajthedevil
1162e0aa29 Added and updated weapons files.
Added or updated weapons files including 

The various Hellfire II iterations - this covers fallbacks to rockets
for all 3 Apache variants, the Supercobra, and the Kiowa.
This also adds the 184 Long and 131 pods. 
Lastly, this adds date and fallback information to the shrikes in
advance of the AGM-45B being added to the A-4E mod.
2023-06-13 01:04:14 +00:00
Dan Albert
36c4bb88be Sinai support.
The rest of the work is done, so bump the campaign version and update
the changelog.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2979.
2023-06-12 17:56:38 -07:00
Dan Albert
dc6624a159 Fix Sinai timezone offset.
https://github.com/dcs-liberation/dcs_liberation/issues/2979
2023-06-12 17:56:38 -07:00
Nosajthedevil
8b55331326 Fix F-16A icons, loadouts, and tasking.
Updates the filename of the F-16A banner so that liberation can read
it.

Updates the F-16A.yaml resource file to add BAI / CAS / antiship
mission types - since the 15A is capable of these.

Updated the F-16A payload provide more capability - primarily adding
jamming pods to the centerline, moving the fuel tanks from the
centerline to the inner wings, replacing the AIS_ASQ_T50 on the
wingtips with 120Bs, and changing the CAP loadout to have 120Bs on
pylons 8 and 3 so they fall back to sparrows on historical campaigns.
2023-06-12 17:54:47 -07:00
Starfire13
33ca77e3d1 Add Egyptian faction.
I figured it's a good time to add an Egyptian faction since we now have
the Sinai map.
2023-06-12 17:52:19 -07:00
Dan Albert
b92b01b245 Add Sinai landmap.
https://github.com/dcs-liberation/dcs_liberation/issues/2979
2023-06-12 17:44:57 -07:00
Dan Albert
b18b371904 Basic Sinai support.
Not ready (most importantly no landmap).

https://github.com/dcs-liberation/dcs_liberation/issues/2979
2023-06-11 23:54:41 -07:00
Dan Albert
9c7e16d121 Beacons for Sinai.
https://github.com/dcs-liberation/dcs_liberation/issues/2979
2023-06-11 23:54:41 -07:00
Dan Albert
87e869d963 Fix Scenic Inland yaml, fixing NGW. 2023-06-11 23:48:56 -07:00
Dan Albert
4a059a4f8b Update pydcs.
Includes Sinai terrain export.

https://github.com/dcs-liberation/dcs_liberation/issues/2979
2023-06-11 23:44:37 -07:00
Dan Albert
674254e55b Note button relocation in the changelog. 2023-06-11 21:31:46 -07:00
Dan Albert
9fd0e06c05 Make patch coverage task informational.
Not reasonable to require all PRs to avoid regressing coverage yet...
2023-06-11 21:23:31 -07:00
Dan Albert
ecaf84ea55 Update Fuzzle's campaigns.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2970.
2023-06-11 21:07:46 -07:00
Dan Albert
e4028cb013 Update pydcs.
Includes the updates needed to fix the Gazelle, and a terrain export for
Normandy for the new airfields added in the latest update.

No Sinai support yet.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2984.
2023-06-11 20:48:40 -07:00
Dan Albert
c45ac50370 Make overfull airbase display scrollable.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2974.
2023-06-08 04:59:34 +00:00
Dan Albert
6640609caf Move misc buttons to the toolbar.
The top panel is a bit overfull on some displays whenever the weather
description is verbose.
2023-06-08 04:50:31 +00:00
Dan Albert
e44b6b416b Stop preloading images that are rarely used.
The aircraft banners are only used for the unit info window, and that's
not a normal part of gameplay. We spend a bit over 1.5 seconds
preloading this data at startup (about 25% of the non-game load startup
time). This data is only expensive to load in aggregate, and we never
need all of it. The unit info window is not noticeably slowed by this,
but startup is noticeably faster without it.
2023-06-07 05:01:06 +00:00
Dan Albert
8a861d3da5 Remove pointless suffixes on banner files.
I think someone just copied this pattern from the icons where the suffix
represented the icon size. These are definitely not 24px banners, and
some of the suffixes are even wrong (_25).
2023-06-07 05:01:06 +00:00
Dan Albert
380d6551be Add tests for AircraftLayer. 2023-06-06 07:08:57 +00:00
Dan Albert
4cb035b955 Fix Python coverage reporting.
Apparently the fact that I want the coverage report to be XML isn't
enough of a hint that I want coverage.
2023-06-06 03:12:49 +00:00
Dan Albert
e50be9bbde Update bug templates for 7.1.0 release. 2023-06-03 22:27:14 +00:00
Dan Albert
ec49a10135 Configure squadron sizes for Abu Dhabi. 2023-06-03 22:01:15 +00:00
Dan Albert
23e3630169 Fix Black Sea LHA parking limits.
Everything else was within the limits, but I had forgotten to check the
LHAs.
2023-06-03 21:56:53 +00:00
Dan Albert
e20ab5fbc0 Ack campaign versions for new squadron limits.
I haven't tested all of them, but I know these are compatible, so
advertise them as such.
2023-06-03 21:53:49 +00:00
Dan Albert
4fd2bb131b Warn for new squadron rules with old campaigns.
It's not feasible to actually check the parking limits because we can't
identify parking limits for carriers until the theater is populated.
Doing so is expensive (and depends on other NGW inputs). Instead,
compare against the version of the campaign and guess.

A new (minor) campaign version has been introduced which makes this
required to improve the UI hint. Campaigns that are compatible with the
new rules should update their version to advertise support.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2909.
2023-06-03 21:32:42 +00:00
Dan Albert
42a7102948 Disallow air wing generation with overfull bases.
This also changes the window close button of the air wing configuration
dialog to cancel rather than revert and continue, because otherwise
there's no way for the user to back out of the dialog without fixing all
the overfull bases first.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2910.
2023-06-03 20:55:23 +00:00
Dan Albert
d271ff17c2 Show overfull airbase details in air wing config.
https://github.com/dcs-liberation/dcs_liberation/issues/2910
2023-06-03 20:47:56 +00:00
Dan Albert
cb61dfccc4 Show parking capacities in air wing config.
This does show the theoretical parking use of full squadrons even when
the new rules are not enabled. Since limits can be enabled manually
later in the game, it's still useful information, even if it's a bit
misleading.

https://github.com/dcs-liberation/dcs_liberation/issues/2910
2023-06-03 19:31:35 +00:00
Dan Albert
56f93c76eb Add new-game option to show air wing config.
Working on this UI was a huge pain because it required manually creating
a game before the UI could be used.
2023-06-03 19:11:29 +00:00
Dan Albert
36cb3a386c Move CLI game generation after UI init. 2023-06-03 19:11:29 +00:00
Dan Albert
c25e830e6c Factor out game creation parameters in main.
Want to move this deeper into the launch process so that it can use the
UI, but don't want to pass the loosely typed argparse namespace any
more than we have to.
2023-06-03 19:11:29 +00:00
Dan Albert
5d08990cd0 Fix line endings. 2023-06-01 22:49:27 -07:00
Starfire13
2a45cd8899 Add Final Countdown II campaign.
Designed for Normandy 2.0
2023-06-01 22:34:42 -07:00
ColonelAkirNakesh
90b880ec3c Updates china_2010.yaml
Replaces T-55 with Type 59 MBT, adds Type 093 attack sub from China Assets pack
2023-06-01 22:33:11 -07:00
ColonelAkirNakesh
5f0c570d65 Update russia_2010.yaml
Adds Ropucha landing ship, Improved Kilo sub
2023-06-01 22:32:40 -07:00
ColonelAkirNakesh
ce102fcc50 Update allies_1944.yaml
Adds 105mm field howitzer to allies
2023-06-01 22:32:23 -07:00
ColonelAkirNakesh
30c792c15a Enforces Topgun: Maverick Rogue Nation livery for Iranian Tomcat 2023-06-01 22:32:09 -07:00
ColonelAkirNakesh
2f45b856d6 Adds support for Chinese sub Type_093.yaml 2023-06-01 22:31:52 -07:00
ColonelAkirNakesh
31d2b756ab Create TYPE-59.yaml 2023-06-01 22:31:30 -07:00
ColonelAkirNakesh
b5cf889c09 Create Horch_901_typ_40_kfz_21.yaml 2023-06-01 22:31:20 -07:00
ColonelAkirNakesh
19958f91ca Create Pak40.yaml 2023-06-01 22:31:08 -07:00
ColonelAkirNakesh
c775a898a4 Create Wespe124.yaml 2023-06-01 22:30:55 -07:00
ColonelAkirNakesh
535244f6f3 Create LeFH_18-40-105.yaml 2023-06-01 22:30:42 -07:00
ColonelAkirNakesh
9d1d3bdcfa Create Higgins_boat.yaml 2023-06-01 22:29:45 -07:00
ColonelAkirNakesh
36eef2b1b9 Create M2A1-105.yaml 2023-06-01 22:29:27 -07:00
ColonelAkirNakesh
7788425c5c Create IMPROVED_KILO.yaml 2023-06-01 22:28:57 -07:00
ColonelAkirNakesh
ee0c21b3e5 Create BDK-775.yaml 2023-06-01 22:28:43 -07:00
ColonelAkirNakesh
54cd619f75 Create santafe.yaml 2023-06-01 22:28:27 -07:00
ColonelAkirNakesh
051940e23c Create leander-gun-condell.yaml 2023-06-01 22:28:13 -07:00
ColonelAkirNakesh
4fbd7defa3 Create leander-gun-lynch.yaml 2023-06-01 22:27:59 -07:00
Dan Albert
90bda9383d Add missing note about 7.0.0 -> 7.1.0 save compat. 2023-05-31 00:17:02 -07:00
Dan Albert
7798e2970c Minor campaign version bump for Normandy 2.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2804.
2023-05-30 23:49:42 -07:00
Dan Albert
410c25b331 Update beacon data.
Did this for Normandy 2... but unsurprisingly there aren't a whole lot
of beacons in a WW2 map.
2023-05-30 23:49:42 -07:00
Dan Albert
cff74525d6 Update pydcs.
Normandy 2 support.

https://github.com/dcs-liberation/dcs_liberation/issues/2804
2023-05-30 23:49:42 -07:00
Dan Albert
8b7f107044 Update Normandy landmap for Normandy 2.
https://github.com/dcs-liberation/dcs_liberation/issues/2804
2023-05-30 23:24:58 -07:00
Dan Albert
c365a0d739 Add Normandy 2 landmap inputs.
https://github.com/dcs-liberation/dcs_liberation/issues/2804
2023-05-30 23:24:58 -07:00
Dan Albert
1f4fd0fd04 Force polygons into validity during GIS import.
Not sure why, but some polygons become invalid (which usually means a
self-intersecting "polygon", such as two triangles that meet at a point)
during this transformation. Shapely includes a tool to reshape polygons
into validity, so use that.
2023-05-30 23:24:58 -07:00
Dan Albert
4bb60cb500 Tolerate empty settings files. 2023-05-30 23:24:58 -07:00
Dan Albert
fe96a415be Add settings for battlefield commander slots.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2235.
2023-05-30 22:06:47 -07:00
Dan Albert
6699289bf7 Add performance option to prevent missile tasks.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2508.
2023-05-30 21:47:16 -07:00
Dan Albert
a85d3243fb Add changelog note for BAI fix.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2922.
2023-05-30 21:12:45 -07:00
Dan Albert
7f2607cf08 Replace more Patriot STRs with real EWRs.
Not all of these nations actually field this radar (according to
Wikipedia), but at least it's a real EWR, and it's the only blue one
we've got.
2023-05-30 21:05:15 -07:00
zhexu14
e50ee976ed Add ability to convert landmap to/from miz.
This PR adds utility functions that import/export landmap files to .miz
polygons. In addition to the unit test, this PR has been tested by
writing the Caucuses & Syria landmaps to a .miz file, loading the
generated .miz file back in and checking that the loaded landmap object
is identical to the original files.
2023-05-30 21:01:05 -07:00
ColonelAkirNakesh
29ffb526f2 Replaces Patriot STR with AN/FPS-117 EWR, adds USS Harry Truman 2023-05-30 20:41:00 -07:00
zhexu14
e024013093 issue 2922: make BAI plannable against missile and costal sites 2023-05-30 20:39:39 -07:00
Dan Albert
257dabe4fa Fix formatting of takeoff time. 2023-05-25 22:35:50 -07:00
Dan Albert
406fb61fa4 Add UI for TOT offset adjustment.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2912.
2023-05-25 22:35:50 -07:00
Dan Albert
49dfa95c61 Save the TOT offset in the flight plan.
Prep work for exposing this to the UI.
2023-05-25 22:35:50 -07:00
Dan Albert
c80e5b259f Allow save compat to exist for two versions.
We want to clean up eventually, but allowing it to exist in both develop
and the release branch makes cherry picks easier.
2023-05-25 22:35:50 -07:00
Dan Albert
64e2213f28 Make the flight details menu modal.
Prevents players from accidentally deleting flights they're currently
viewing, which would cause an error.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2911.
2023-05-25 21:10:21 -07:00
Dan Albert
ced93afd49 Update bug templates now that 7.0.0 is out. 2023-05-25 21:10:21 -07:00
Dan Albert
f719a5ec34 Update bug templates now that 7.0.0 is out. 2023-05-23 01:38:16 -07:00
Dan Albert
6f4ac1dc39 Fix line endings.
These get broken whenever someone uses the GitHub file upload editor,
since that doesn't understand .gitattributes.
2023-05-23 00:37:28 -07:00
Starfire13
f831c8efdd Update Golan Heights and Caen to Evreux campaigns.
I had asked Khopa for permission to edit two of his campaigns to fix
some issues. Only the YAMLs have been edited, .miz files did not need
changes. I have tested both YAMLs to make sure campaigns will generate.
Also tested generating turn 1 .miz and ran it in DCS.

Golan Heights:
1. Removed the 2 problematic squadrons from Marj Ruhayyil that were
causing aircraft losses due to larger aircraft sizes not fitting at that
airfield (which is intended for helicopters).
2. Implemented squadron limits.

Caen to Evreux:
1. Re-arranged squadrons for better force distribution and revised
primary and secondary mission types for better default play experience.
2. Implemented squadron limits.
2023-05-23 00:23:41 -07:00
Starfire13
e3c6b03603 Update Apache loadouts.
BAI loadout updated to use the new radar guided hellfires. Aux tanks
removed in favour of extra cannon ammo.
2023-05-20 09:21:16 +00:00
Dan Albert
7a2e8279cd Fix syntax error in bluefor_modern.yaml. 2023-05-19 17:51:22 -07:00
Dan Albert
24e72475b4 Checkpoint game before sim, auto-revert on abort.
An alternative to
https://github.com/dcs-liberation/dcs_liberation/pull/2891 that I ended
up liking much better (I had assumed some part of the UI would fail or
at least look terrible with this approach, but it seems to work quite
well).

On by default now since it's far less frightening than the previous
thing.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2735.
2023-05-19 17:44:18 -07:00
Starfire13
f10350dac4 Update scenic_inland.yaml
A formatting fix for scenic route 2 that was preventing new campaign start. Fixing at Fuzzle's request as he doesn't have the time for it right now.
2023-05-19 17:36:29 -07:00
Dan Albert
f068976749 Fuzzle campaign updates.
https://github.com/dcs-liberation/dcs_liberation/issues/2889
2023-05-19 01:17:51 -07:00
Dan Albert
4b4c45e90f Attempt to reset the simulation on abort.
This is optional because I really don't know if I trust it. I don't see
much wrong with it (aside from the warning about not using it with auto-
resolve, because it won't restore lost aircraft), but it's really not
something I'd built for since it's not going to be possible as the RTS
features grow.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2735.
2023-05-19 01:05:25 -07:00
Dan Albert
527eac1f4a Fix docs version.
This ought to be auto-imported but that requires liberation being
importable here and that's proving non-trivial.
2023-05-18 23:17:08 -07:00
Dan Albert
92c3087187 Advance develop to 8.0.0-preview. 2023-05-18 22:44:39 -07:00
Dan Albert
8dc3fca290 Update contributors list.
<3
2023-05-18 22:24:00 -07:00
dependabot[bot]
0d18b57074 Bump starlette from 0.26.1 to 0.27.0
Includes dependent update to fastapi.

Bumps [starlette](https://github.com/encode/starlette) from 0.26.1 to 0.27.0.
- [Release notes](https://github.com/encode/starlette/releases)
- [Changelog](https://github.com/encode/starlette/blob/master/docs/release-notes.md)
- [Commits](https://github.com/encode/starlette/compare/0.26.1...0.27.0)

---
updated-dependencies:
- dependency-name: starlette
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-18 22:23:08 -07:00
Dan Albert
b745e7c8ec Rehiding speed controls for 7.
7 is shipping sooner than expected, so re-hide these since it's not
ready yet.

https://github.com/dcs-liberation/dcs_liberation/issues/2746
2023-05-18 22:02:37 -07:00
Dan Albert
800ca598ef Add missing changlog note for C-47.
https://github.com/dcs-liberation/dcs_liberation/pull/2812
2023-05-18 21:38:08 -07:00
Dan Albert
212813e31d Update pydcs.
Support for DCS 2.8.5.40170, including laser hellfire, pylon 5 for the
apache, and a more tolerant livery scanner (not all liveries will be
discovered, but Liberation at least won't crash).

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2880.
2023-05-18 21:30:18 -07:00
Dan Albert
571fe21d57 Fix campaign line endings. 2023-05-18 21:16:29 -07:00
Starfire13
cd952312b7 Update Starfire's campaign updates for 10.7. 2023-05-17 19:03:48 -07:00
Dan Albert
23982fdac6 Add changelog note for pydcs livery scanner crash fix.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2747.
2023-05-16 21:28:29 -07:00
Dan Albert
8724b458a8 Add changelog note for TALD overfly fix.
https://github.com/dcs-liberation/dcs_liberation/issues/2781
2023-05-16 20:56:33 -07:00
Dan Albert
ef64899701 Add changelog note for "recreate as" fix.
https://github.com/dcs-liberation/dcs_liberation/issues/2779
2023-05-16 20:56:33 -07:00
Dan Albert
51e4dc5c22 Add changelog note for fixed recovery tanker tasks.
https://github.com/dcs-liberation/dcs_liberation/issues/2771
2023-05-16 20:56:33 -07:00
Dan Albert
ac5edeb936 Add changelog note for improved dead event handling.
https://github.com/dcs-liberation/dcs_liberation/issues/2765
2023-05-16 20:56:33 -07:00
Dan Albert
f7364d04ed Add changelog note for air wing reset fix.
https://github.com/dcs-liberation/dcs_liberation/issues/2751
2023-05-16 20:56:33 -07:00
Dan Albert
483bf73213 Add changelog note for BAI planning fix.
https://github.com/dcs-liberation/dcs_liberation/issues/2618
2023-05-16 20:56:33 -07:00
Dan Albert
0b87f90d4f Add changelog note for built-in TGP fix. 2023-05-16 20:56:33 -07:00
Dan Albert
202fe1109b Add changelog note for AEW&C planning fix.
https://github.com/dcs-liberation/dcs_liberation/issues/2048
2023-05-16 20:56:33 -07:00
Dan Albert
5a8863b07e Add changelog note for TALD fix.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2780.
2023-05-16 20:56:33 -07:00
Dan Albert
889e1f5da2 Finish wiring up SAM orientation control.
The UI works beautifully, but that's not worth much if it doesn't
actually change the data...

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2479.
2023-05-16 18:28:18 -07:00
ColonelAkirNakesh
418d78f99b Adds J-11 flyable, Jeff and BS3 liveries
Adds J-11 to CJTF Blue. Enforces fictional USAF Aggressor livery for J-11, fictional US livery for Jeff, non-Russian 'neutral black' livery for BS3.
2023-05-16 18:10:53 -07:00
ColonelAkirNakesh
a4b5bc198c Restores Flak 18 to free German faction 2023-05-16 18:09:37 -07:00
zhexu14
fcb2f21d36 add unit tests for mission_types function in controlpoint objects (#2870)
This PR adds unit tests that can be planned against control points.
2023-05-16 18:09:03 -07:00
zhexu14
15abf3d6fe Update ADM141 data to include clsids for hornet 2023-05-16 18:06:50 -07:00
Dan Albert
a8b7aca4fb Make wind speed moddable.
These should probably be overridable per theater and per season, but
even with that we'll want some defaults.

https://github.com/dcs-liberation/dcs_liberation/issues/2862
2023-05-16 00:52:51 -07:00
Dan Albert
799dbfa99c Move and split up weather.py.
This is getting out of hand, and I'm about to make it worse.
2023-05-16 00:52:51 -07:00
Dan Albert
eb31a0f038 Rework wind speed Weibull inputs, tune.
The previous method of using a uniform scalar of the MSL wind speed for
higher altitudes didn't offer enough control. In particular, the shape
needs to be quite different to skew low, mid, high.

This patch reworks that system so the parameters of each distribution
are configured per-altitude level. To keep some continuity between
altitudes (on a windy day, all levels should have higher wind speeds on
average), the wind speed of the lower altitude will be added to the
scale value of the higher altitude.

Since it wasn't practical to approximate the previous behavior with the
new system, this also handles the tuning of each. The low altitude
speeds remain mostly unchanged (typically around 5 knots expect for
thunderstorms), but the average speeds for other altitudes went up to
more closely match the previous intent but without the massive
overshoot. At 2000m wind speeds are typically in the 20-25 knot range
now, and 8000m 30-50 knots.

https://www.quora.com/What-is-the-average-wind-speed-at-different-altitudes
has some of the source data, and Quora is the most authoritative source
there is. It claims that cruise altitude winds can get "as high as 150
knots", but doesn't claim anything about the average. I had a
surprisingly difficult time finding good data for cruise altitude air
speeds for non-jet stream paths (though many of our maps are in jet
streams), so I just eyeballed it from
https://turbli.com/wind-during-flights/.

https://github.com/dcs-liberation/dcs_liberation/issues/2861

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2863.
2023-05-15 22:44:17 -07:00
Dan Albert
78e2da9196 Use weibull distribution for wind generation.
Wind speeds should not be uniformly distributed. This switches to a
Weibull distribution which allegedly (see the bug) is good enough.
Experimentally that seems true as well, though I know nothing about how
wind works irl. This at least looks like it'll generate reasonable
variation in missions while keeping the 1st through 3rd quartile
behaviors from getting out of hand.

I'm very uncertain about the scaling factor aspect of this. Naively the
wind speeds at different altitudes ought to be somewhat correlated, but
I'm not sure how much, and whether this kind of scaling is at all the
right way to do it. As before, meh, close enough?

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2861.
2023-05-15 21:37:43 -07:00
Dan Albert
ca96a232f0 Revert "Use the actual Country type instead of the name."
This reverts commit bd2ec12e0f.

Country is both the data (name, ID, etc) and the container for groups
added to the miz, so it can't be used across multiple mission
generations. See https://github.com/pydcs/dcs/issues/314 for potential
follow up work that would let us do this.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2864.
2023-05-15 18:23:48 -07:00
Dan Albert
03671bbfb0 Allow manual SAM orientation.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2479.
2023-05-13 17:20:03 -07:00
Dan Albert
97c4168d13 Wrap settings titles. 2023-05-13 16:59:49 -07:00
Dan Albert
e0edfa68b1 Make settings scrollable. 2023-05-13 16:59:49 -07:00
Dan Albert
97c238a4bb Warn players that take off disallows new flights. 2023-05-13 16:47:56 -07:00
Dan Albert
a6c5b03212 Do not create refueling tasks without tankers.
If the package does not have a tanker, the refueling task will cause AI
flights to go to an arbitrary tanker, which may cause them to fly
through enemy territory or even go farther than their arrival airbase.

It's also not remotely possible for every AI flight in the game to
refuel in most missions. There's typically one tanker and dozens of
aircraft that would previously attempt to refuel.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2716.
2023-05-13 16:23:31 -07:00
zhexu14
5b148a74aa add tests for mission_types for various theather ground objects 2023-05-13 12:56:38 -07:00
ColonelAkirNakesh
33242048e7 Makes guard tower (house2arm) a AAA unit 2023-05-13 12:50:49 -07:00
Dan Albert
4f7932ad8a Remove old aircraft selection mode.
New mode seems to be working well.
2023-05-13 12:47:51 -07:00
Dan Albert
8158cc7112 Add livery selection dropdown to air wing config.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/1861.
2023-05-13 12:33:02 -07:00
Dan Albert
50d7a3e46f Update pydcs.
More livery APIs...
2023-05-13 12:24:24 -07:00
Starfire13
b6b9a22668 Update B-52H.yaml
Added antiship mission type to B52
2023-05-12 22:21:36 -07:00
Dan Albert
bd2ec12e0f Use the actual Country type instead of the name.
We want other pieces of country information (in particular the short
names). This cleans up a lot of code anyway.

As an added bonus, this now catches squadrons that used invalid names
which would previously be passed through to pydcs and... then I don't
know what would happen.
2023-05-12 22:18:40 -07:00
Dan Albert
752a90cddb Fix broken squadron.
It's "The Netherlands", not "Netherlands".
2023-05-12 22:18:40 -07:00
Dan Albert
004594639e Update pydcs.
Includes the rewritten livery scanning code. It might need some more
tweaks to be fast enough, but it at least now doesn't spam the log for
machines that don't have DCS (or Liberation) installed, and it's not
slow until something tries to use it, so until we add the UI we won't
have to pay for it during startup.
2023-05-12 18:10:11 -07:00
ColonelAkirNakesh
6943adf6df Germany 1944 free unit list fixes.
1. Removes Flak18 as these currently require Kdo.G.40. (part of the WW2
Asset Pack) to fire at player. ED-supplied single missions are having
Flak18s w/out WW2 Asset Pack firing at a point in the air.

2. Adds Opel Blitz to frontline for more variety, balance, and some
little bit of historical accuracy. My understanding is late war was more
truck strafing than HVARing Panzers.

3. Adds guard tower to AAA units to have a functioning AAA since Flak18s
don't work.
2023-05-12 18:05:12 -07:00
Dan Albert
5ad57d2878 Move code docs to a readthedocs project.
Ported the existing docs, but the real goal is getting the docs for
campaign version moved here, as well as the manual. RTD will have an
"edit on github" button that'll keep this accessible to players, but
it'll be much easier to keep docs up to date while developing features
if it's part of the code base.
2023-05-10 23:14:04 -07:00
Dan Albert
acb2d01d92 Update pydcs.
No new data (I think), but includes a bunch of fixes for the lua parser
and rewrites some suspicious looking (but probably safe) code in the
livery scanner.

Also changes this dependency to non-editable by default. Pip chose this
automatically for me at some point, but the rules for whether or not a
py.typed file will actually be detected for an editable install are
complicated and sometimes this won't work, leading too a lot of mypy
errors. There's no need for this to be editable anyway.
2023-05-10 23:03:14 -07:00
Dan Albert
15fa73a514 Add option to limit squadron sizes and begin full.
Adding temporarily as an option to make sure it's not a terrible idea,
but the old mode will probably go away.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/1583.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2808.
2023-05-05 18:16:42 -07:00
Dan Albert
7f94b34277 Add an option to prefer primary tasked aircraft.
We're still using mostly the same aircraft selection as we have before
we added squadrons: the closest aircraft is the best choice.

This adds an option to obey the primary task set by the campaign
designer (can be overridden by players), even if the squadron is farther
away than one that is capable of it as a secondary task.

I don't expect this option to live very long. I'm making it optional for
now to give people a chance to test it, but it'll either replace the old
selection strategy or will be removed.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/1892.
2023-05-04 23:08:11 -07:00
Dan Albert
4d2ed64a70 Fix the command line campaign generator. 2023-05-04 23:05:21 -07:00
Dan Albert
e444761059 Support replacing squadrons in-place. 2023-05-04 20:44:27 -07:00
zhexu14
c9e4b5eba4 enable AEWC missions on FOBs 2023-05-04 20:35:51 -07:00
Dan Albert
c14c7cc73d Make patch check informational as well. 2023-05-04 18:41:27 -07:00
Dan Albert
5e459c2390 Expand python coverage, use coveragerc. 2023-05-04 10:07:34 -07:00
Dan Albert
4ee6de2c84 Make coverage checks informational.
PRs shouldn't be failing because coverage dropped. Not until our tests
aren't terrible, anyway.
2023-05-04 10:07:34 -07:00
Dan Albert
a7d2eca209 Add a test for the Aircraft component.
Leaflet (or maybe react-leaflet?) isn't very testable, so we can really
only test that mocks were called with the right props for the leaflet
components we expect, but that's still better than nothing.
2023-05-04 01:18:45 -07:00
Dan Albert
57a4a7c282 Test typescript and collect coverage.
We don't actually have any tests yet :(
2023-05-03 23:18:15 -07:00
Dan Albert
b4c5236d8b Don't fail PRs that regress coverage.
Most of our code is barely testable and our coverage isn't anything to
brag about.
2023-05-03 23:18:15 -07:00
Dan Albert
de2a779715 Gather and upload coverage of python tests. 2023-05-03 21:54:52 -07:00
zhexu14
352c2ddc56 make BAI plannable against vehicles only 2023-05-03 10:12:15 -07:00
Dan Albert
76e6aff9d7 Ignore parse errors of preferences file.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2613.
2023-05-02 00:39:18 -07:00
Dan Albert
b4c02767ac Update pydcs.
Includes the fix to prevent the livery scanner from crashing on import
when the Liberation preferences file cannot be parsed.

https://github.com/dcs-liberation/dcs_liberation/issues/2613
2023-05-02 00:39:18 -07:00
zhexu14
aa2a888ed0 Handle edge case where aircraft have built in TPGs 2023-05-02 00:34:18 -07:00
zhexu14
b50d82feff Add GBU-27 yaml 2023-05-02 00:34:18 -07:00
Dan Albert
cce9592ac8 Use task priorities from aircraft yamls.
Preferred aircraft per task are now determined by a ranking of weights
stored in the aircraft yaml files. To aid in visualizing the priorities
across aircraft, Liberation can be run with the argument
dump-task-priorities to dump a yaml file in Saved
Games/DCS/Liberation/Debug/priorities.yaml, which will show each task
along with priority sorted aircraft and their weights.

The current weights in the data were exported from the existing lists,
where each position from the bottom of the list was worth 10 (to allow
some games for less shuffling later).

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2809.
2023-04-26 23:26:23 -07:00
Dan Albert
b69def652e Add debug command to dump aircraft priorities.
https://github.com/dcs-liberation/dcs_liberation/issues/2809
2023-04-26 23:26:23 -07:00
Dan Albert
6df83485e1 Load task priorities from YAML.
Not used yet.

https://github.com/dcs-liberation/dcs_liberation/issues/2809
2023-04-26 23:26:23 -07:00
Dan Albert
e297fcbff8 Export current task priorities to aircraft yamls.
Nothing fancy. Rank in reversed (so earliest items in the original list
have the highest index) list * 10 (to leave gaps for balancing).

https://github.com/dcs-liberation/dcs_liberation/issues/2809
2023-04-26 23:26:23 -07:00
Dan Albert
2f2ebff674 Fix merged classvars in UnitType descendants.
```
>>> class Foo:
...     bar = 0
...     @classmethod
...     def set_bar(cls, v):
...             cls.bar = v
...
>>> class Bar(Foo):
...     ...
...
>>> Bar.set_bar(1)
>>> Bar.bar
1
>>> Foo.bar
0
>>> class Foo:
...     bar = {}
...     @classmethod
...     def add(cls, k, v):
...             cls.bar[k] = v
...
>>> class Bar(Foo):
...     pass
...
>>> Bar.add(0, 1)
>>> Bar.bar
{0: 1}
>>> Foo.bar
{0: 1}
```

The collections are copied by reference into the descendants, whereas
_loaded is copied by value, so that one can stay. Before this patch,
every subtype was loading because _loaded was set per subclass, but they
were all registering with a common collection defined by UnitType rather
than their own class.
2023-04-26 23:09:57 -07:00
Dan Albert
06b74c4ca6 Update mypy, fastapi, pydantic.
mypy update is needed for typing.Self support. It caught an existing bug
(missing @property on override), and fixed a bug so we can drop an
ignore.

Upgrading mypy requires upgrading pydantic to get the newest pydantic
mypy plugin, and since that's what's driving fastapi it's probably smart
to upgrade those together.
2023-04-26 23:00:23 -07:00
Dan Albert
7ddfc5e5ad Fix pydcs extension packages.
pydcs_extensions.__init__ wasn't actually doing anything because without
an __init__.py each of these "packages" was empty. This has been working
by accident because of ai_flight_planner_db.py.
2023-04-26 22:08:56 -07:00
zhexu14
f86709ebd0 Prevent decoy flights from overflying the target.
Force decoy flights to the next waypoints 120 seconds after the IP.
The duration is just an approximation, but it seems to work.

See discussion in https://github.com/dcs-liberation/dcs_liberation/pull/2810
for more details.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2781.
2023-04-26 19:30:34 -07:00
Dan Albert
7266de42f5 Format aircraft yamls. 2023-04-26 19:12:13 -07:00
Dan Albert
47831d43b5 Remember mod choices in the NGW. 2023-04-26 00:36:34 -07:00
Dan Albert
cf47dd82d7 Remember player preferences for plugins. 2023-04-26 00:24:46 -07:00
Dan Albert
081c97583b Add a plugins page to the NGW. 2023-04-26 00:07:36 -07:00
Dan Albert
77f1706cbb Extract plugins from settings.
There isn't really any need for these two types to interact. The lua
plugin manager effectively fully owned its properties, it just delegated
all reads and writes to the settings object.

Instead, break the plugin settings out into the plugin manager and
preserve the manager in the Game. This will make it possible to expose
plugin options in the NGW without breaking the game on cancel.
2023-04-25 23:28:01 -07:00
Dan Albert
664efa3ace Document Lua plugin APIs.
Trying to fix the singleton-ness in the plugin manager because it
prevents injecting settings until the game is fully committed (new game
wizard completed). Added the docs describing what I think I've been able
to discover.
2023-04-25 21:32:36 -07:00
Pekka Kiviniemi
b6059f692e Create unit tests for pilot class.
DCS Liberation does not have much unit tests. Pilot class is not very
exiting but it was a good place to start.
2023-04-26 03:03:25 +00:00
zhexu14
4bf8f25d31 Add decoy weapon type and configure AI tasks.
See https://github.com/dcs-liberation/dcs_liberation/pull/2810
for more discussion.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2780.
2023-04-25 20:02:30 -07:00
Dan Albert
e2c6d6788c Persist some campaign creation options.
We should also persist mod options, but those will go in a separate file
because they aren't a part of Settings.

Plugins need some work before that can be saved here. They're not
configurable in the NGW currently, so that needs to be fixed first. It
also appears that it may not be safe to inject the settings object with
plugin options until the game is created, but that needs more
investigation (see the comment in Settings.save_player_settings).

Another obvious candidate would be the desired player mission duration,
but we need to implement custom serialization for that first.
2023-04-24 22:49:30 -07:00
Nosajthedevil
1c20bc3966 Add DCS AI C-47 support 2023-04-24 22:49:09 -07:00
zhexu14
c31d76ec83 Reset flight's flight plan builder when changing task type.
The mechanism for how this bug arises is that the *WaypointGenerator*
uses the *FlightWaypoint.waypoint_type* to decide whether to generate
the waypoint in the .miz file using a *DeadIngressBuilder* or a
*SeadIngressBuilder*. This *waypoint_type* is set by
*ato.flightplans.<sead|dead>.Builder*, which is set when *ato.flight* is
initialised in the *Flight._flight_plan_builder* member variable based
on *Flight.flight_type*. When *Flight.flight_type* is updated when the
flight is changed from SEAD->DEAD, *Flight._flight_plan_builder* is not
updated in the development build, resulting in it continuing to generate
SEAD waypoints.

This PR adds *set_flight_type()* which sets the *flight_type* property
and updates *Flight._flight_plan_builder* and uses this function when
converting flight types. Ideally, *flight_type* should be made private
and only accessed through getter/setter functions that encapsulate this
behavior, but that would mess up any existing liberation save files.

This PR was tested by:
1. Opening the save file from Issue 2779 in the development build
2. Clicking "Take Off" and confirming that the Weapon Release Type is
"Guided" at the Ingress Waypoint as described in the issue.
3. Opening the save file from Issue 2779 in this PR
4. Converting the SEAD2DEAD flight from DEAD back to SEAD, and then from
SEAD to DEAD
5. Clicking "Take Off" and confirming in the mission editor that the
SEAD2DEAD flight has Weapon Release Type set to "Auto" at the Ingress
Waypoint.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2779.
2023-04-22 10:54:42 -07:00
zhexu14
ada8f9f8ee Fix error when resetting air wing configuration.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2751.
2023-04-22 10:51:26 -07:00
zhexu14
1b72598803 Add missing argument when fixing TOTs.
Part of https://github.com/dcs-liberation/dcs_liberation/issues/2746.
2023-04-22 10:50:20 -07:00
zhexu14
4bc8bf52e7 Also use Tanker task for recovery tankers.
DCS apparently needs both to function.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2771.
2023-04-20 17:59:14 -07:00
zhexu14
0d257a2c3b Track S_EVENT_KILL and S_EVENT_UNIT_LOST as well.
Catch a few more death signals. Still not perfect but a bit better.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2765.
2023-04-19 06:16:41 +00:00
Nosajthedevil
0ba602d3aa Added many premade squadrons.
Added a number of squadrons - US Vietnam War era squadrons for the
OV-10A and F-4B/C, US squadrons for the A-10A, iran squadrons for the
F-4E, and russian, iranian, vietnamese, syrian, and north korean
squadrons for the Mig-21.
2023-04-18 23:07:29 -07:00
dependabot[bot]
38d18ba767 Bump webpack from 5.69.1 to 5.76.1 in /client
Bumps [webpack](https://github.com/webpack/webpack) from 5.69.1 to 5.76.1.
- [Release notes](https://github.com/webpack/webpack/releases)
- [Commits](https://github.com/webpack/webpack/compare/v5.69.1...v5.76.1)

---
updated-dependencies:
- dependency-name: webpack
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-18 11:36:12 -07:00
Dan Albert
94b8aa7213 Disallow squadrons from disabling mission types.
After this change, players will always have the final say in what
missions a squadron can be assigned to. Squadrons are not able to
influence the default auto-assignable missions either because that
property is always overridden by the campaign's air wing configuration
(the primary and secondary task properties). The `mission-types` field
of the squadron definition has been removed since it is no longer
capable of influencing anything. I haven't bothered cleaning up the now
useless data in all the existing squadrons though.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2785.
2023-04-18 11:35:41 -07:00
Dan Albert
1ac36d03da Allow in-line definitions of campaign factions.
A lot of campaigns want to define custom factions. This allows them to
do so without us having to fill the built-in factions list with a bunch
of campaign-specific factions. It also makes custom campaigns more
portable as they don't need to also distribute the custom faction files.
2023-04-17 23:52:25 -07:00
Dan Albert
dca256364a Convert existing factions to YAML. 2023-04-17 22:40:02 -07:00
Dan Albert
652e7d8d7b Allow factions to use YAML.
Comments! No more failures because you accidentally used a trailing
comma!

JSON still supported since it's basically free, but we should probably
remove that in 8 just so the docs can be less confusing for users who
will be confused if only one format is documented (and we definitely
won't maintain duplicate docs).
2023-04-17 22:40:02 -07:00
Dan Albert
42e9a6294b Remove eager loading of factions.
Eager loading meant that users would need to restart Liberation to pick
up changes to faction files. That's annoying for modders, slows down
start up, and uselessly sits in RAM when it's not needed after game
creation.

Also removes the __getitem__ and __iter__ methods in favor of named
methods, since the dunder methods are more or less impenetrable for IDEs
and grep.
2023-04-17 22:40:02 -07:00
Dan Albert
f3d2952579 Fix typo in Germany 1944.
Oops.
2023-04-17 19:31:03 -07:00
Dan Albert
ee1d4cd3e4 Replace a bunch of escape sequences.
Unify on using the real letter instead of an escape sequence for better
searchability/readability. There should be no functional change here (if
any, they should be bug fixes).

https://github.com/dcs-liberation/dcs_liberation/issues/2786
2023-04-17 18:10:25 -07:00
Dan Albert
4e067eaaa8 Remove GroundPlanners from the save state.
These are only used during mission generation. Remove them from the save
state to reduce compatibility requirements. We also have at least one
report of this data being corrupted... somehow. I don't know how that
could have happened, but if there's no data to corrupt in the first
place that's not a problem. If the corruption _does_ recur, it'll be
much easier to repro if it corrupts during mission generation rather
than during turn initialization.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2729.
2023-04-15 14:27:20 -07:00
dependabot[bot]
4a0975b21b Update Starlette and FastAPI. 2023-04-15 13:50:34 -07:00
Dan Albert
dd9ad2f0be Update pydcs for the plane helipad spawning fix.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2782.
2023-04-15 13:47:24 -07:00
Dan Albert
d1fe267072 Fix unit details screen for Qt6.
The `setMargin` shorthand was apparently to simple, so Qt6 removed it in
favor of `setContentMargins`, which does the same thing?

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2784.
2023-04-15 13:41:09 -07:00
Dan Albert
28ba100864 Fix bad character escape in Caen to Evreux.
The escape sequence looks to be valid according to the spec (although it
would need to be double quoted, but that doesn't fix it), but Python's
parser doesn't appear to handle that. Just use ü.

https://github.com/dcs-liberation/dcs_liberation/issues/2786
2023-04-15 13:27:08 -07:00
Dan Albert
99ea06c0d5 Fix file encoding for some loads.
We've actually been pretty good at getting this right in most of the
code base, but we've missed it in a few places. Python defaults to the
encoding of the current locale unless otherwise specified, and for a US
English Windows install that's cp1252, not UTF-8. I'm not brave enough
to change the locale at startup because I don't know how that might
affect CJK encoding users (or for that matter, non-Latin derived
alphabet UTF-8 variants).

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2786.
2023-04-15 13:27:08 -07:00
Dan Albert
fa070b2126 Improve logging in defaultsquadronassigner.py.
https://github.com/dcs-liberation/dcs_liberation/issues/2786
2023-04-15 13:27:08 -07:00
Dan Albert
5405632434 Improve comments in defaultsquadronassigner.py. 2023-04-15 12:33:52 -07:00
Dan Albert
ca2cec5d7d Organize imports in defaultsquadronassigner.py. 2023-04-15 12:33:52 -07:00
Starfire13
8150176fc6 Fixes F-14B squadrons that don't have SEAD as available mission type (#2777)
Fixes the YAMLs for 3 F-14B squadrons that didn't have SEAD as an
available mission type. F-14s use SEAD for TALD deployment. The other
F-14B squadrons and all the F-14A squadrons are fine. I also removed
"Bases:" from one of the squadrons as the other squadron yamls don't
have it and it's unecessary (F-14Bs can already be based at airfields
and carriers.
2023-04-09 19:18:06 -07:00
Dan Albert
5c72e0754a Fix iteration error when splitting transfers.
If one type of unit is zeroed but there are still other units to check
in the dict, the dict will have changed size during iteration. Iterate
on a copy of the dict instead.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2773.
2023-03-31 16:09:33 -07:00
Dan Albert
af2e195f90 Update pydcs to fix Falklands airport data.
The Falklands data in pydcs was missing an (unfinished, unusable)
airport, and that was breaking miz loading of campaigns that were edited
or created with a version of DCS to include these airports which have
incomplete data.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2732.
2023-03-30 17:26:05 -07:00
Nosajthedevil
8523c11357 Support for the updated F-4B/C mod (#2769)
Updated the F4.py pydcs extension to match the updated F-4B/C mod and
reworked the standard payloads to add "clean" to new F-4B pylons 11 and
12.

This includes a workaround to allow Liberation to use the new VSN F-4B
weapons with combined 2x Aim-9js on pylons 3 and 9 underslung with bombs
on ters on new pylons 11 and 12. In mission editor the combined weapons
are selected in pylons 3 and 9 and their under-slung counterparts are
forced onto 11 and 12 using "required" arguments in the mod's lua. All
other pylon 3 and 9 weapons use "required clean" arguments. Liberation
doesn't have a way to force these linkages onto pylons 11 and 12 and
without them, even without clean, no weapons will load on 3 and 9 or 11
and 12.

The workaround for normal weapons on the F-4B is to set the standard
load-outs to "clean" on pylons 11 and 12. This allows all normal weapons
to work on pylons 3 and 9 so long as pylons 11 and 12 are left as Clean.
It also allows Clean into the Liberation dropdown so it can be selected
later if necessary.

The workaround for the 4 new weapons that combines pylons 3 with 11 and
9 with 12 is that the user has to use the matching pair on each set of
pylons. For example - if F4B_LAU105_AIM9J_2_BRU42A_MK82_3 is selected
for pylon 3, BRU 42A MK823 LAU105 AIM9J2 must be selected for pylon 11.
Failure to do this correctly doesn't crash liberation or DCS, the result
will just be either no weapons at all on either pylon or the underslung
weapons on 11 and 12 floating without a pylon attaching it to the plane.

When updating f4.py in the future, note that running the pydcs database
export doesn't pull any data for Pylons 11 and 12. Those matching
weapons / classes have to be manually defined in those pylons for the
F-4B. This is noted in f4.py.
2023-03-24 18:41:03 -07:00
Dan Albert
b860d72c2d Prevent transfer splitting from leaving empty units.
If the transport were able to move exactly the quantity of units of the
given type remaining in the transfer without moving the whole order, the
transfer order would be left with instructions to transfer zero of that
unit. That's an invariant violation, and was resulting in _later_
transfers attempting to create a convoy with zero units, which pydcs
rightly rejects.

For example: if 2 Abrams and 2 Paladins are ordered to transfer from a
disconnected FOB to a distant location that is connected by road, and
only two cargo slots are available, that transfer could be split into:

```
{
    Abrams: 2
}
```

and

```
{
    Abrams: 0,
    Paladin: 2
}
```

Depending on the route, those airlifted units might end up still needing
road transit (we prefer short airlifts rather than direct routes because
it gives the player more opportunities to intercept enemy convoys). The
current turn would airlift the Abrams-only group and the Paladin group
would wait. On the next turn the Abrams would travel by road and the
Paladins would be airlifted. On the _third_ turn, the Paladins (and zero
Abrams) would generate an invalid convoy.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2761.
2023-03-18 14:03:41 -07:00
Dan Albert
bcb7d059c0 Tolerate saving when temp is on another FS.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2748.
2023-03-14 16:21:24 -07:00
Dan Albert
bc0dacf974 Fix saving of saves from other machines.
Need to reset the persisted save paths on load, since the file that was
loaded may have been moved since it was saved and the original location
may no longer be accessible.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2756.
2023-03-13 19:41:28 -07:00
Dan Albert
2d9b0177ec Add channel naming for the warthogs.
The manual for the legacy warthog usually calls these VHF 1/2 and UHF,
or VHF AM/FM and UHF. The AM/FM nomenclature is what I usually hear
people call them and it's clearer, so go with that.

For the A-10C II, that manual hasn't been updated for the AN/ARC-210
yet, so I'm not really sure what that ought to be called. The UFC calls
it COM 1 though, so I went with that. The alternative would be something
like VHF/UHF for the 210 and UHF for the 164, but I don't know if that's
actually better. Could be completely explicit and call them by their
full names, but that's probably less clear to people that aren't
fiddling with the radio implementation constantly (and even I confuse
the 164 and the 186 all the damn time).
2023-03-13 18:48:20 -07:00
Dan Albert
2fed84c676 Fix radio data for the A-10Cs.
My earlier tests were not accurate enough. It turns out that yes, DCS
does still do some channel clobbering with these, so fix the radio
selection to account for that.

I also fumbled some copy paste between the A-10Cs so the A-10C II
channel assignment ended up in the wrong section doing nothing...
2023-03-13 18:48:20 -07:00
Dan Albert
a73c06223d Update radio configuration for the A-10s.
The latest DCS update both added support for preset radios (two both
A-10C modules!), and re-ordered the legacy A-10C's radios so we can use
the VHF radio for intra-flight.

After this patch, the legacy A-10C will use VHF for intra-flight, the
new module will use one AN/ARC-210 for intra-flight and the other for
inter-flight comms, and both modules will have preset channels assigned.
2023-03-11 15:30:36 -08:00
Dan Albert
e129c02109 Update pydcs.
Includes the new A-10C radios. Will follow up to make Liberation
actually use them.

This manually removes some weapons from mod files that were removed from
DCS. Those mods may need re-exporting, and may also need updating by
their authors, but for now this should keep them functioning.
2023-03-11 15:30:36 -08:00
Dan Albert
67dae80b76 Rework the speed controls for 1080p friendliness.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2396.
2023-02-19 12:35:21 -08:00
Nosajthedevil
088b69a6ef Russian Weapon Fixes
R-24R weapons file correction to R-3R fallback name - now matches name used in R-3R file.

Remove KH-28 weapons file due to removal from DCS.

Update KH-25MP weapons file to  fallback to KH-29L instead of Kh-28. Kh-28 previously fell back to Kh-29L.
2023-02-11 16:43:12 -08:00
Nosajthedevil
db64f37a95 Update AIM-9Juli.yaml 2023-02-11 16:42:55 -08:00
Nosajthedevil
af6c42f49b Update AIM-9Juli-2X.yaml 2023-02-11 16:42:55 -08:00
Nosajthedevil
4503170075 Added US Weapons Files
Adds US Weapons files with fallbacks in order of capability.

Aim-7P added by ED for several US fighters. Falls back to 7MH, and Aim-120B fallback adjusted from MH to P.

Aim-9J and Aim-9Juli added by ED for the Mirage F-1, also used by F-4 mod and will likely be added to the F-4E whenever it ships. Aim-9J placed between  9P and 9B, Aim-9 Juli placed between 9L and 9P5.

2x9j and 2x9Juli added by VSN for F-4 mod. Placed between 2x versions of same missiles as above.

Aim-7E now falls back to 2xAim9x instead of single Aim9x so that it runs through the entire loop of Aim-9s.
2023-02-11 16:42:55 -08:00
dependabot[bot]
c07f343d0e Bump @sideway/formula from 3.0.0 to 3.0.1 in /client
Bumps [@sideway/formula](https://github.com/sideway/formula) from 3.0.0 to 3.0.1.
- [Release notes](https://github.com/sideway/formula/releases)
- [Commits](https://github.com/sideway/formula/compare/v3.0.0...v3.0.1)

---
updated-dependencies:
- dependency-name: "@sideway/formula"
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-02-08 20:06:27 -08:00
Dan Albert
725f6c55a5 Enable sim speed controls by default.
https://github.com/dcs-liberation/dcs_liberation/issues/1680
2023-02-06 00:51:47 -08:00
Dan Albert
364742a98b Do not allow adding flights after package start.
https://github.com/dcs-liberation/dcs_liberation/issues/1680
2023-02-06 00:47:53 -08:00
Dan Albert
7b35a749e2 Prevent past startup when adding new flights.
When a new flight is added to a package, if the TOT is early enough the
new flight might have a startup time in the past. Clamp the TOT when
adding new flights to the package to avoid this.

https://github.com/dcs-liberation/dcs_liberation/issues/1680
2023-02-06 00:47:53 -08:00
Dan Albert
23ac510d26 Don't allow changing TOT for started packages.
https://github.com/dcs-liberation/dcs_liberation/issues/1680
2023-02-06 00:33:08 -08:00
Dan Albert
ba10298dbc Allow adjusting TOTs after sim start.
This makes the start time in WaitingForStart dynamic, which is more
expensive but probably still cheap enough.

It also checks that the new TOT will not result in a start time in the
past when the player changes the TOT.

https://github.com/dcs-liberation/dcs_liberation/issues/1680
2023-02-06 00:33:08 -08:00
Dan Albert
c6a8aeac1d Update bug templates for 6.1.1. 2023-02-05 15:18:09 -08:00
Raffson
b41ef0ab13 Fix heli spawn/landing at FOB/FARP
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2719.

(cherry picked from commit 34de855b8f889b72406c101d0cea385988e24bf9)
2023-02-05 14:09:01 -08:00
Dan Albert
c33a0d5deb Don't generate runway data for heliports.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2710.
2023-02-05 13:19:18 -08:00
Nosajthedevil
70b9d4c174 Add VSN F-4 Mod Support
Added VSN F-4 Mod support
2023-02-02 17:15:21 -08:00
dependabot[bot]
1462bedd97 Bump http-cache-semantics from 4.1.0 to 4.1.1 in /client
Bumps [http-cache-semantics](https://github.com/kornelski/http-cache-semantics) from 4.1.0 to 4.1.1.
- [Release notes](https://github.com/kornelski/http-cache-semantics/releases)
- [Commits](https://github.com/kornelski/http-cache-semantics/compare/v4.1.0...v4.1.1)

---
updated-dependencies:
- dependency-name: http-cache-semantics
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-02-02 17:08:17 -08:00
Dan Albert
937bacacb7 Pin version of black used in GHA.
Black rolls out style changes every year, and using "stable" means that
the check run on PRs might start formatting differently than we do
locally, or require a reformat of the codebase to make a PR submittable.

Pin to the version that we've been using. We should update to 23 at some
point, but we want to do that deliberately.
2023-02-02 16:35:51 -08:00
Dan Albert
e8824e5d03 Fix line endings. 2023-01-31 18:44:33 -08:00
Dan Albert
e030cfebb8 Update pydcs.
Export from DCS 2.8.2.35632.
2023-01-28 14:03:38 -08:00
Dan Albert
eea98b01f6 Fix invalid tanker planning.
All three refueling missions share a common task type and differentiate
their behavior based on the type and allegiance of the package target.
This means that if the theater commander identifies a carrier as the
best location for a theater refueling task, a recovery tanker will be
planned by mistake.

If this happens on a sunken carrier, mission generation will fail
because a recovery tanker cannot be generated for a sunken carrier.

Fix the crash and the misplanned theater tanker by preventing the
commander from choosing fleet control points as refueling targets.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2693.
2023-01-28 12:57:03 -08:00
Dan Albert
f8c1d291ed Update the versions listed in the bug template. 2023-01-28 11:46:37 -08:00
Dan Albert
0df268f331 Fix unit ID of the KS-19.
It seems like this unit has never worked because of the unit ID
mismatch.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2701.
2023-01-28 11:44:31 -08:00
Dan Albert
be2ad226f4 Export game.persistence.mission_path_for.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2699.
2023-01-27 16:52:45 -08:00
dependabot[bot]
a4df23361e Bump future from 0.18.2 to 0.18.3
Bumps [future](https://github.com/PythonCharmers/python-future) from 0.18.2 to 0.18.3.
- [Release notes](https://github.com/PythonCharmers/python-future/releases)
- [Changelog](https://github.com/PythonCharmers/python-future/blob/master/docs/changelog.rst)
- [Commits](https://github.com/PythonCharmers/python-future/compare/v0.18.2...v0.18.3)

---
updated-dependencies:
- dependency-name: future
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-01-16 17:26:34 -08:00
Dan Albert
0f34946127 Restructure save games into a zipped bundle.
This is the first step toward bundling all assets related to a save game
into a single item. That makes it easier to avoid clobbering "temporary"
assets from other games like the state.json, but also makes it easier
for players to file bug reports, since there's only a single asset to
upload.

This is only the first step because so far it only includes the various
save files: start of turn, end of last turn before results processing,
and "latest" (the game saved explicitly by the player).
2023-01-16 13:59:16 -08:00
MetalStormGhost
575470ae1b Updated Community A-4E-C mod version support to 2.1.0 release. 2023-01-09 23:28:22 -08:00
dependabot[bot]
31c59e7380 Bump json5 from 1.0.1 to 1.0.2 in /client
Bumps [json5](https://github.com/json5/json5) from 1.0.1 to 1.0.2.
- [Release notes](https://github.com/json5/json5/releases)
- [Changelog](https://github.com/json5/json5/blob/main/CHANGELOG.md)
- [Commits](https://github.com/json5/json5/compare/v1.0.1...v1.0.2)

---
updated-dependencies:
- dependency-name: json5
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-01-07 21:25:21 -08:00
Dan Albert
4b542b70ae Fix post-results "last turn" save. 2023-01-04 15:15:56 -08:00
Dan Albert
9cb641bddf Allow flights to self-initialize.
This makes it possible to add new packages to a running sim.

https://github.com/dcs-liberation/dcs_liberation/issues/1680
2023-01-04 12:58:36 -08:00
Dan Albert
7a8b3591cd Add locking to some UI actions.
This is by no means complete. The bugs that this solves were already in
6.x, but we'd hidden the speed controls for the sim in that release, and
have always said that anything done after pressing "go" the first time
is undefined behavior. This is the first step on making those mid-sim
actions behave correctly.

UI actions such as creating a new package need to be executed between
ticks of the sim. We can either do this synchronously by blocking the UI
until the tick is done executing, acquiring a lock on the sim, executing
the action, then releasing the lock; or asynchronously by queueing
events and letting the sim execute them when it completes the current
tick (or instantly if the sim is paused).

Anything that comes from the new UI (currently just the map) must be
asynchronous because it goes through the REST API, but for the old UI
it's simpler (and because the lock will only be acquired as quickly as
the user can act, shouldn't slow anything down) to do this
synchronously, since it's difficult to use coroutines in Qt.

https://github.com/dcs-liberation/dcs_liberation/issues/1680
2023-01-04 12:58:36 -08:00
Dan Albert
fd2ba6b2b2 Convert TOTs to datetime.
https://github.com/dcs-liberation/dcs_liberation/issues/1680
2023-01-04 12:58:36 -08:00
Dan Albert
ac6cc39616 Fix AdjustToContents use for Qt6.
This is no longer a property exposed directly on QComboBox.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2684.
2023-01-04 12:30:43 -08:00
Dan Albert
0be9e1985a Upgrade to Python 3.11.
Supposedly much faster. Probably other cool stuff.
2022-12-29 17:47:49 -08:00
Dan Albert
a1af4e563a Python 3.11 compatibility.
https://docs.python.org/3/library/asyncio-task.html#asyncio.wait says:

> Changed in version 3.11: Passing coroutine objects to wait() directly
> is forbidden.
2022-12-29 17:47:49 -08:00
Dan Albert
7167e84a8f Add back asgiref.
uvicorn now needs this for type information. Not sure why this works
with Python 3.10.
2022-12-29 17:47:49 -08:00
Dan Albert
7eeb84de47 Upgrade lots of dependencies.
Cleared the requirements.txt and rebuilt from scratch. The only thing
left un-upgraded is mypy, which I'll deal with separately because it
catches new issues.
2022-12-29 17:09:42 -08:00
Dan Albert
45aabf369b Upgrade Shapely. 2022-12-29 16:48:42 -08:00
Dan Albert
e396a21791 Update pyproj. 2022-12-29 16:47:29 -08:00
Dan Albert
c6635a4885 Update FastAPI and friends. 2022-12-29 16:43:43 -08:00
Dan Albert
306971230b Update to PySide6.
It sounds like PySide2 will not be moving to Python 3.11, so we're stuck
on 3.10 without this. Upgrading to a newer Qt also fixes some high DPI
bugs (the file browser dialog for save/load is no longer tiny on 4k).

https://github.com/pyinstaller/pyinstaller/issues/5414 previously
blocked this, but the bug appears to be fixed now.
2022-12-29 16:26:50 -08:00
Dan Albert
e0c13846a7 Upgrade pyinstaller.
Should include https://github.com/pyinstaller/pyinstaller/issues/5414.
2022-12-29 15:39:50 -08:00
Dan Albert
4aa42e6573 Remove isinstance use in flight support data.
mypy struggles to prove this cast correct when there are two or'd
isinstance checks where both types coincidentally have properties of the
same name (but no defined protocol making that explicit). I'm not really
sure why mypy is happy with this in its current state, but it isn't
after a change I'm making.

All our isinstance use is a bit of an anti-pattern anyway, so extract a
method that exposes the data we care about.

The start/end times for tankers aren't actually used, so this could be
simplified even more, but that data _should_ be used.
2022-12-28 14:02:31 -08:00
Dan Albert
24a04fb8c6 Workaround pycharm debugger issue when used.
Works around
https://youtrack.jetbrains.com/issue/PY-53232/Debugger-doesnt-work-when-pyproj-is-imported
whenever the pycharm debugger is detected.
2022-12-28 14:00:45 -08:00
SnappyComebacks
321de8d4ec Set units on the frontline to Hidden On MFD. (#2669)
All groups (friendly and enemy) that are part of the front line are set
to `Hidden On MFD`. This is a group level filter, and can not be applied
on a per unit basis.
2022-12-28 14:19:33 -07:00
Dan Albert
5db82f733f Revert "Fix for orbit's broken stop condition"
ED fixed the bug.

This reverts commit 73ee2ba4c0.
2022-12-28 12:28:39 -08:00
Dan Albert
d65fbf299c Note that we don't support stable DCS. 2022-12-21 18:06:52 -08:00
Dan Albert
7c2bb3bd85 Remove note about DCS bug.
This was fixed in
https://www.digitalcombatsimulator.com/en/news/changelog/openbeta/2.8.1.34437/

> Fixed: Stop Condition "Time More" is broken.
2022-12-21 13:29:23 -08:00
RndName
f9903f1e19 Only check for ground units in capture trigger zone
requires pydcs update: https://github.com/pydcs/dcs/pull/279
2022-12-21 13:04:09 -08:00
RndName
4a4935f165 Change iads command unit type 2022-12-21 13:04:09 -08:00
RndName
09f92cc5e4 Only add skynet iads command unit when advanced iads is in use 2022-12-21 13:04:09 -08:00
Dan Albert
887e5997c2 Update pydcs.
Includes UnitType parameter of AllOfCoalition in/out zone condition.
2022-12-21 12:56:17 -08:00
Dan Albert
f88a50dd07 Update changelog for Blackshark 3.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2657.
2022-12-21 12:29:45 -08:00
Dan Albert
3f12a5ae3d Add icons and banners for BS3.
https://github.com/dcs-liberation/dcs_liberation/issues/2657
2022-12-21 12:29:45 -08:00
Dan Albert
f2946817bf Add BS3 loadouts.
https://github.com/dcs-liberation/dcs_liberation/issues/2657
2022-12-21 12:29:45 -08:00
Dan Albert
935a9b0631 Add BS3 to factions that have BS2.
https://github.com/dcs-liberation/dcs_liberation/issues/2657
2022-12-21 12:29:45 -08:00
Dan Albert
c0dc411102 Add blackshark 3 yaml.
There are no significant notable changes from Blackshark 2, so this is
the same YAML.

https://github.com/dcs-liberation/dcs_liberation/issues/2657
2022-12-21 12:29:45 -08:00
Dan Albert
55037626a4 Add Blackshark 3 to the mission planning DB.
https://github.com/dcs-liberation/dcs_liberation/issues/2657
2022-12-21 12:29:45 -08:00
Dan Albert
fc3e72bacf Fix type-only import that needs to be real.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2660.
2022-12-21 12:26:41 -08:00
SnappyComebacks
0fd0f0e7c0 Recovery tanker follow up (#2659)
Fix timing issues for RecoveryTankerFlightPlan.

AEWC and Refueling can be planned on LHA.
2022-12-20 21:47:50 -07:00
Dan Albert
22503d4e95 Save the last turn for bug reports.
We often get save games uploaded with bug reports that are already in a
broken state with nothing we can do about it. This saves that turn to
`last_turn.liberation` so users are less likely to have clobbered the
useful data before filing the report.
2022-12-20 13:46:21 -08:00
Dan Albert
de9236e93a Fix the channel's landmap.
Caused by a bad rename when I did the migration. The landmap in 6.0.0
was actually a GIF...

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2612.
2022-12-20 12:59:38 -08:00
Dan Albert
66523301aa Update changelog for pydcs update. 2022-12-20 12:31:22 -08:00
SnappyComebacks
9a81121ac1 Recovery Tanker for carriers. (#2649)
Implement recovery tankers for carriers.

UnitMap gets a little more data to store.  Recovery tankers depend on the unit map.
2022-12-19 21:08:19 -07:00
SnappyComebacks
a245ba80c3 Update F-15E loadouts. 2022-12-14 21:45:49 -07:00
Dan Albert
9a1860fc5e Add new British navy units to the UK faction.
I haven't removed the old US navy stuff from this faction, since all the
new UK ships are frigates, and removing the US stuff would deprive the
faction of cruisers and destroyers, which might break generation (I'm
not familiar enough with the new system to say for sure).

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2571.
2022-12-13 00:05:44 -08:00
Dan Albert
f3f5ab70ea Add HMS Invincible as a valid runway. 2022-12-13 00:05:44 -08:00
Dan Albert
6ce7638fdc Fix changelog formatting. 2022-12-12 23:35:37 -08:00
ColonelAkirNakesh
7f916d55e7 Add HMS Invincible. 2022-12-12 23:19:29 -08:00
Dan Albert
43ea019091 Add missing changelog note. 2022-12-12 19:32:29 -08:00
Dan Albert
6025cad716 Fix livery for VF-33 F-14A squadron.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2610.
2022-12-12 19:11:46 -08:00
Dan Albert
9365aea724 Fix encoding issues with the Peru faction.
Not really sure what's going on here, but presumably it's UTF-16 and
UTF-8 fighting.
2022-12-12 18:53:18 -08:00
Dan Albert
28859a8a9c Add changelog notes that were missed in PRs. 2022-12-12 18:52:28 -08:00
DillieKoe
304fd7ea80 Add Peru faction.
A new Peru faction with a mirage squadon
2022-12-12 18:39:21 -08:00
ColonelAkirNakesh
5e345263a7 Override liveries for Russian aircraft in bluefor faction. 2022-12-12 18:21:12 -08:00
dependabot[bot]
445ee25bbf Bump certifi from 2022.6.15 to 2022.12.7
Bumps [certifi](https://github.com/certifi/python-certifi) from 2022.6.15 to 2022.12.7.
- [Release notes](https://github.com/certifi/python-certifi/releases)
- [Commits](https://github.com/certifi/python-certifi/compare/2022.06.15...2022.12.07)

---
updated-dependencies:
- dependency-name: certifi
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-08 23:21:18 -08:00
Dan Albert
20937815f8 Fix CAS not having landing waypoints.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2611.
2022-12-03 16:30:51 -08:00
RndName
3863b8ef40 Fix manual debrief submit not ending mission 2022-11-30 13:20:31 +01:00
Dan Albert
d91ccaa70f Changelog section for 6.1. 2022-11-27 21:15:22 -08:00
ColonelAkirNakesh
7673ca5481 Add support for Leander class HMS Andromeda.
https://github.com/dcs-liberation/dcs_liberation/issues/2571
2022-11-27 14:22:41 -08:00
ColonelAkirNakesh
774a37a7d2 Add support for Leander class HMS Ariadne.
https://github.com/dcs-liberation/dcs_liberation/issues/2571
2022-11-27 14:11:19 -08:00
ColonelAkirNakesh
905094f63f Add support for Castle Class.
https://github.com/dcs-liberation/dcs_liberation/issues/2571
2022-11-27 14:10:52 -08:00
ColonelAkirNakesh
fd5b7ba49d Add support for Leander class HMS Achilles.
https://github.com/dcs-liberation/dcs_liberation/issues/2571
2022-11-27 14:00:36 -08:00
SnappyComebacks
1b828b95b3 Add F-15E to DEAD_CAPABLE in AI flight planner. 2022-11-26 09:47:08 -07:00
Dan Albert
54546aaefb Expand gitattributes to cover common files.
Specifically adding this so that yaml changes stop being uploaded as
CRLF, but the rest is likely useful too.
2022-11-25 15:36:04 -08:00
Dan Albert
ded5fc8b1d Update bug templates to 6.0.0.
We're not fixing 5.x bugs any more.
2022-11-25 15:26:20 -08:00
Dan Albert
68fc4f6950 Remove incompatible campaigns.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2558.
2022-11-25 15:17:30 -08:00
Starfire13
5d07238ab8 Updates Khopa's Normandy and Channel campaign to 10.0
Note that Operation Dynamo only requires a yaml file update. The .miz file is fine and is not included here.
2022-11-25 15:08:25 -08:00
Dan Albert
5e7e5e2636 Unfilter the custom waypoint targets.
There doesn't appear to be any reason for us to be poking at
implementation details here aside from changing the name from "unit" to
"building" for that case. Just iterate over the known strike targets.

Making this change uncovered some latent type errors.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2564.
2022-11-25 14:14:38 -08:00
Dan Albert
ca5c0055d1 Remove dead code. 2022-11-25 14:14:38 -08:00
Dan Albert
e208df16b2 Add radios for the MB-339A.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2511.
2022-11-25 14:07:56 -08:00
Dan Albert
11632b0ef1 Update RoleplayingPleb's campaigns.
https://github.com/dcs-liberation/dcs_liberation/issues/2558
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2561.
2022-11-25 13:05:20 -08:00
Dan Albert
b0bc46f539 Make the casualty report scrollable.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2567.
2022-11-25 13:00:04 -08:00
SnappyComebacks
627ed45065 Add banner for MB-339A. 2022-11-25 11:58:56 -07:00
RndName
fc9ad5b519 Remove dcs capture event from state json
With the latest change we added capture zones and corresponding trigger rules for all Airfields as well so we do not need to rely on the dcs capture event S_EVENT_BASE_CAPTURED anymore.
2022-11-24 11:14:50 +01:00
RndName
40ddad1d9a Add Airfield to list of capture zone types
This will create capture zones and the trigger rules to check for a base capture. Will fix an issue where the dcs capture event is not fired and therefore the capture not recognized by liberation
2022-11-24 11:14:50 +01:00
RndName
eb997db703 Fix carrier group generation 2022-11-23 12:57:43 +01:00
MetalStormGhost
e53dc5b80b Attempt at fixing Carrier killed in state.json but not being removed from game, issue #2405. GenericCarrierGenerator.generate() will now generate the ship group with an array that only contains alive ship units, just like GroundObjectGenerator.generate() has previously done.
Carrier groups will now also show up as destroyed/damaged on the map when the carrier is sunk.
2022-11-23 12:57:43 +01:00
RndName
ab64655f05 Validate primary and secondary nodes for iads network 2022-11-21 12:13:49 +01:00
RndName
e1b530e4fc Fix IADS network error caused by dead groups
Fixed an error which would occur when dead units which are non static would be added as secondary node during the skynet lua data generation. This should in general not be possible as connection nodes and power sources are currently most of the time static.
2022-11-21 12:13:49 +01:00
SnappyComebacks
4414853e45 Update pydcs.
Added ice halo generation.
2022-11-20 17:27:35 -07:00
Dan Albert
35adcd2c7f Move develop forward to 7.0. 2022-11-20 12:57:42 -08:00
1174 changed files with 37926 additions and 14838 deletions

8
.coveragerc Normal file
View File

@@ -0,0 +1,8 @@
[report]
exclude_lines =
pragma: no cover
if TYPE_CHECKING:
[run]
branch = True
source = game,pydcs_extensions,qt_ui,resources/tools

76
.gitattributes vendored
View File

@@ -14,3 +14,79 @@
*.pyo binary export-ignore
*.pyd binary
unshipped_data/arcgis_maps/ filter=lfs diff=lfs merge=lfs -text
# https://github.com/alexkaratarakis/gitattributes/blob/master/Common.gitattributes
# Documents
*.bibtex text diff=bibtex
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain
*.md text diff=markdown
*.mdx text diff=markdown
*.tex text diff=tex
*.adoc text
*.textile text
*.mustache text
*.csv text
*.tab text
*.tsv text
*.txt text
*.sql text
*.epub diff=astextplain
# Graphics
*.png binary
*.jpg binary
*.jpeg binary
*.gif binary
*.tif binary
*.tiff binary
*.ico binary
# SVG treated as text by default.
*.svg text
# If you want to treat it as binary,
# use the following line instead.
# *.svg binary
*.eps binary
# Scripts
*.bash text eol=lf
*.fish text eol=lf
*.sh text eol=lf
*.zsh text eol=lf
# These are explicitly windows files and should use crlf
*.bat text eol=crlf
*.cmd text eol=crlf
*.ps1 text eol=crlf
# Serialisation
*.json text
*.toml text
*.xml text
*.yaml text
*.yml text
# Archives
*.7z binary
*.gz binary
*.tar binary
*.tgz binary
*.zip binary
# Text files where line endings should be preserved
*.patch -text
#
# Exclude files from exporting
#
.gitattributes export-ignore
.gitignore export-ignore
.gitkeep export-ignore

View File

@@ -31,12 +31,13 @@ body:
If the bug was found in a development build, select "Development build"
and provide a link to the build in the field below.
options:
- 5.2.0
- 9.0.0
- Development build
- type: textarea
attributes:
label: Build information
description: The build information from the Help -> Report an issue window.
description:
The build information from the Help -> Report an issue window.
- type: textarea
attributes:
label: Description
@@ -48,22 +49,27 @@ body:
required: true
- type: textarea
attributes:
label: Save game and other files
label: Save game and other files (save game required, bugs without saves will be closed)
description: >
Attach any files needed to reproduce the bug here. **A save game is
required.** We typically cannot help without a save game (the
`.liberation` file found in
`%USERPROFILE%/Saved Games/DCS/Liberation/Saves`), so most bugs filed
without saved games will be closed without investigation.
required.** Even if it seems unnecessary to you, this is required.
Repro steps that are obvious to you might not be obvious to anyone
else, and it is impossible for us to know what default settings or mods
may be impacting behavior without a save game. Bugs filed without a
save game are very often not reproducible, and those waste scarce
developer time. It is **much** easier for you to attach a save game
than it is for us to recreate your save state by guessing at what you
did. As such, bug reports that do not attach a saved game will be
closed without investigation. Attach the `.liberation.zip` file found
in `%USERPROFILE%/Saved Games/DCS/Liberation/Saves`.
Other useful files to include are:
The Liberation log file. The log file is located at
`<Liberation install directory>/logs/liberation.log`. The log often
includes data about non-fatal errors that could be the root cause of the
problem.
The Liberation log file. The log file is located at `<Liberation install
directory>/logs/liberation.log`. The log often includes data about
non-fatal errors that could be the root cause of the problem.
The `liberation_nextturn.miz` or a track file. This should always be
@@ -76,8 +82,12 @@ body:
investigating any issues with end-of-turn results processing.
You can attach files to the bug by dragging and dropping the file
into this text box. GitHub will not allow uploads of all file types, so
If reporting an issue that occurred during or after flying the mission
in DCS, the DCS log file found in `%USERPROFILE%/Saved Games/DCS/Logs`.
You can attach files to the bug by dragging and dropping the file into
this text box. GitHub will not allow uploads of all file types, so
attach a zip of the files if needed.
validations:
required: true

View File

@@ -39,12 +39,13 @@ body:
If the bug was found in a development build, select "Development build"
and provide a link to the build in the field below.
options:
- 5.2.0
- 9.0.0
- Development build
- type: textarea
attributes:
label: Build information
description: The build information from the Help -> Report an issue window.
description:
The build information from the Help -> Report an issue window.
- type: input
attributes:
label: Campaign name
@@ -59,8 +60,8 @@ body:
label: Blue faction
description: >
The name of the blue faction you selected. If the bug only occurs with a
custom faction (or modifications to a stock faction), upload the
faction file as an attachment to the bug description field.
custom faction (or modifications to a stock faction), upload the faction
file as an attachment to the bug description field.
validations:
required: true
- type: input
@@ -68,8 +69,8 @@ body:
label: Red faction
description: >
The name of the red faction you selected. If the bug only occurs with a
custom faction (or modifications to a stock faction), upload the
faction file as an attachment to the bug description field.
custom faction (or modifications to a stock faction), upload the faction
file as an attachment to the bug description field.
validations:
required: true
- type: textarea
@@ -102,11 +103,11 @@ body:
attributes:
label: Log file
description: >
Attach the Liberation log file. The log file is located at
`<Liberation install directory>/logs/liberation.log`.
Attach the Liberation log file. The log file is located at `<Liberation
install directory>/logs/liberation.log`.
You can attach files to the bug by dragging and dropping the file
into this text box.
You can attach files to the bug by dragging and dropping the file into
this text box.
validations:
required: true

View File

@@ -6,7 +6,7 @@ runs:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.10"
python-version: "3.11"
cache: pip
- name: Install environment
@@ -19,5 +19,3 @@ runs:
run: |
./venv/scripts/activate
python -m pip install -r requirements.txt
# For some reason the shiboken2.abi3.dll is not found properly, so I copy it instead
Copy-Item .\venv\Lib\site-packages\shiboken2\shiboken2.abi3.dll .\venv\Lib\site-packages\PySide2\ -Force

View File

@@ -11,6 +11,7 @@ jobs:
- uses: actions/setup-python@v2
- uses: psf/black@stable
with:
version: ~=23.11
src: "."
options: "--check"

View File

@@ -15,4 +15,24 @@ jobs:
- name: run tests
run: |
./venv/scripts/activate
pytest tests
pytest --cov --cov-report=xml tests
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
ts-tests:
name: Typescript tests
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: Set up JS environment
uses: ./.github/actions/setup-liberation-js
- name: run tests
run: |
cd client
npm test -- --coverage
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3

4
.gitignore vendored
View File

@@ -1,11 +1,15 @@
*.pyc
__pycache__
build/**
# Sphinx
docs/_build
resources/payloads/*.lua
venv
.DS_Store
.vscode/settings.json
dist/**
/.coverage
/coverage.xml
# User-specific stuff
.idea/
.env

View File

@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/psf/black
rev: 22.6.0
rev: 23.11.0
hooks:
- id: black
language_version: python3

13
.readthedocs.yaml Normal file
View File

@@ -0,0 +1,13 @@
version: 2
build:
os: ubuntu-22.04
tools:
python: "3.11"
sphinx:
configuration: docs/conf.py
python:
install:
- requirements: docs/requirements.txt

View File

@@ -8,13 +8,19 @@
[![Discord](https://img.shields.io/discord/595702951800995872?label=Discord&logo=discord)](https://discord.gg/bKrtrkJ)
[![codecov](https://codecov.io/gh/dcs-liberation/dcs_liberation/branch/develop/graph/badge.svg?token=EEQ7G76K2L)](https://codecov.io/gh/dcs-liberation/dcs_liberation)
[![GitHub pull requests](https://img.shields.io/github/issues-pr/dcs-liberation/dcs_liberation)](https://github.com/dcs-liberation/dcs_liberation)
[![GitHub issues](https://img.shields.io/github/issues/dcs-liberation/dcs_liberation)](https://github.com/dcs-liberation/dcs_liberation/issues)
![GitHub stars](https://img.shields.io/github/stars/dcs-liberation/dcs_liberation?style=social)
## About DCS Liberation
DCS Liberation is a [DCS World](https://www.digitalcombatsimulator.com/en/products/world/) turn based single-player or co-op dynamic campaign.
It is an external program that generates full and complex DCS missions and manage a persistent combat environment.
It is an external program that generates full and complex DCS missions and manage a persistent combat environment.
**Note that DCS Liberation does not support the stable release of DCS. We can
only guarantee compatibility with either the open beta or the stable release,
and more people play the open beta. DCS stable _might_ work sometimes, but it's
untested, and we will be unable to fix any bugs unique to stable DCS.**
![Screenshot](https://user-images.githubusercontent.com/315852/120939254-0b4a9f80-c6cc-11eb-82f5-ce3f8d714bfe.png)
@@ -29,7 +35,6 @@ To download preview builds of the next version of DCS Liberation, see https://gi
These DCS bugs prevent us from improving AI behavior. Please upvote them! (But please
_don't_ spam them with comments):
* [Hold points do not work in DCS 2.8](https://forum.dcs.world/topic/311458-humvee-ground-unit-holdstop-conditiontime-more-bug-28-mission-editor/)
* [A2A and SEAD escorts don't escort](https://forums.eagle.ru/topic/251798-options-for-alternate-ai-escort-behavior/?tab=comments#comment-4668033)
* [DEAD can't use mixed loadouts effectively](https://forums.eagle.ru/topic/271941-ai-rtbs-after-firing-decoys-despite-full-load-of-bombs/)

View File

@@ -1,3 +1,209 @@
# 10.0.0
Saves from 9.x are not compatible with 10.0.0.
## Features/Improvements
* **[Engine]** Support for DCS 2.9.2.49629 Open Beta. (F-15E JDAM and JSOW, F-16 AIM-9P, updated Falklands and Normandy airfields).
* **[UI]** Improved the description of "runway" state for FARPs, FOBs, carriers, and off-map spawns.
## Fixes
* **[Flight Planning]** Aircraft from even numbered flights will no longer become inaccessible when canceling a draft package.
* **[UI]** Flight members in the loadout menu are now numbered starting from 1 instead of 0.
* **[UI]** Flight plan paths are now drawn behind all other map elements, fixing rare cases where they could prevent other UI elements from being clickable.
# 9.0.0
Saves from 8.x are not compatible with 9.0.0.
## Features/Improvements
* **[Engine]** Support for DCS Open Beta 2.9.0.46801.
* **[Campaign]** Added ferry only control points, which offer campaign designers a way to add squadrons that can be brought in after additional airfields are captured.
* **[Campaign]** The new squadron rules (size limits, beginning the campaign at full strength) are now the default and required. The old style of unlimited squadron sizes and starting with zero aircraft has been removed.
* **[Data]** Added support for the ARA Veinticinco de Mayo.
* **[Data]** Changed display name of the AI-only F-15E Strike Eagle for clarity.
* **[Flight Planning]** Improved IP selection for targets that are near the center of a threat zone.
* **[Flight Planning]** Moved CAS ingress point off the front line so that the AI begins their target search earlier.
* **[Flight Planning]** Loadouts and aircraft properties can now be set per-flight member. Warning: AI flights should not use mixed loadouts.
* **[Flight Planning]** Laser codes that are pre-assigned to weapons at mission start can now be chosen from a list in the loadout UI. This does not affect the aircraft's TGP, just the weapons. Currently only implemented for the F-15E S4+ and F-16C.
* **[Mission Generation]** Configured target and initial points for F-15E S4+.
* **[Mission Generation]** Added a package kneeboard page that shows the radio frequencies, tasks, and laser codes for each member of your package.
* **[Mission Generation]** Added option to generate AI flights with unlimited fuel (enabled by default).
* **[Modding]** Factions can now specify the ship type to be used for cargo shipping. The Handy Wind will be used by default, but WW2 factions can pick something more appropriate.
* **[Modding]** Unit variants can now set a display name separate from their ID.
* **[Modding]** Updated Community A-4E-C mod version support to 2.2.0 release.
* **[UI]** An error will be displayed when invalid fast-forward options are selected rather than beginning a never ending simulation.
* **[UI]** Added cheats for instantly repairing and destroying runways.
* **[UI]** Improved usability of the flight properties UI. It now shows human-readable names and uses more appropriate UI elements.
* **[UI]** The map now shows the real front line bounds.
## Fixes
* **[Campaign]** Fixed error when canceling squadron transfer if the current location would be exactly full.
* **[Data]** Fixed the class of the Samuel Chase so it can't be picked for a AAA or SHORAD site.
* **[Data]** Allow CH-47D, CH-53E and UH-60A to operate from carriers and LHAs.
* **[Data]** Added the F-15E's LANTIRN to the list of known targeting pods. Player F-15E flight with TGPs will now be assigned laser codes.
* **[Flight Planning]** Patrolling flight plans (CAS, CAP, refueling, etc) now handle TOT offsets.
* **[Loadouts]** Fixed error when loading certain DCS loadouts which contained an empty pylon (notably the Mosquito).
* **[Mission Generation]** Restored previous AI behavior for anti-ship missions. A DCS update caused only a single aircraft in a flight to attack. The full flight will now attack like they used to.
* **[Mission Generation]** Fix generation of OCA Runway missions to allow LGBs to be used.
* **[Mission Generation]** Fixed AI flights flying far too slowly toward NAV points.
* **[Mission Generation]** Fixed Recovery Tanker mission type intermittently failing due to not being able to find the CVN.
* **[Mission Generation]** Fixed "division by zero" error on mission generation when a flight has an "In-Flight" start type and starts on top of a mission waypoint.
* **[Mission Generation]** Fixed flights not being selectable in the mission editor if fast-forward was used and they were generated at a waypoint that had a fixed TOT (such as a BARCAP that was on-station).
* **[Mission Generation]** Fixed error when planning TARCAPs on the sole remaining enemy airfield.
* **[Mission Generation]** Fixed allocation range for carrier Link 4 datalink.
* **[Modding]** Unit variants can now actually override base unit type properties.
* **[New Game Wizard]** Factions are reset to default after clicking "Back" to Theater Configuration screen.
* **[Plugins]** Fixed Lua errors in Skynet plugin that would occur whenever one coalition had no IADS nodes.
* **[UI]** Fixed deleting waypoints in custom flight plans deleting the wrong waypoint.
* **[UI]** Fixed flight properties UI to support F-15E S4+ laser codes.
* **[UI]** In unit transfer dialog, only list control points that are reachable from the control point units are being transferred from.
* **[UI]** Fixed UI bug where altering an "ahead of package" TOT offset would change the offset back to a "behind package" offset.
* **[UI]** Fixed bug where changing TOT offsets could result in flight startup times that are in the past.
* **[UI]** Fixed odd spacing of the finance window when there were not enough items to fill the page.
* **[UI]** Fixed regression where waypoint altitude changes in the waypoint list screen are applied to the wrong waypoint.
* **[UI]** Fixed regression where waypoint additions in custom flight plans are not reflected until the window is reloaded.
# 8.1.0
Saves from 8.0.0 are compatible with 8.1.0
## Features/Improvements
* **[Engine]** Support for DCS 2.8.6.41363, including F-15E support.
* **[UI]** Flight loadout/properties tab is now scrollable.
## Fixes
* **[Campaign]** Fixed liveries for premade squadrons all being off-by-one.
* **[UI]** Fixed numbering of waypoints in the map and flight dialog (first waypoint is now 0 rather than 1).
# 8.0.0
Saves from 7.x are not compatible with 8.0.
## Features/Improvements
* **[Engine]** Support for DCS 2.8.6.41066, including the new Sinai map.
* **[UI]** Limited size of overfull airbase display and added scrollbar.
* **[UI]** Waypoint altitudes can be edited in Waypoints tab of Edit Flight window.
* **[UI]** Moved air wing and transfer menus to the toolbar to improve UI fit on low resolution displays.
* **[UI]** Added basic game over dialog.
## Fixes
* **[Campaign]** Fix bug introduced in 7.0 where map strike target deaths are no longer tracked.
* **[Mission Generation]** Fix crash during mission generation caused by out of date DCS data for the Gazelle.
* **[Mission Generation]** Fix crash during mission generation when DCS beacon data is inconsistent.
# 7.1.0
Saves from 7.0.0 are compatible with 7.1.0
## Features/Improvements
* **[Engine]** Support for Normandy 2 airfields.
* **[Factions]** Replaced Patriot STRs "EWRs" with AN/FPS-117 for blue factions 1980 or newer.
* **[Mission Generation]** Added option to prevent scud and V2 sites from firing at the start of the mission.
* **[Mission Generation]** Added settings for controlling number of tactical commander, observer, JTAC, and game master slots.
* **[Mission Planning]** Per-flight TOT offsets can now be set in the flight details UI. This allows individual flights to be scheduled ahead of or behind the rest of the package.
* **[New Game Wizard]** The air wing configuration dialog will check for and reject overfull airbases before continuing when the new squadron rules are used.
* **[New Game Wizard]** Closing the air wing configuration dialog will now cancel and return to the new game wizard rather than reverting changes and continuing.
* **[New Game Wizard]** A warning will be displayed next to the new squadron rules button if the campaign predates the new rules and will likely require user intervention before continuing.
* **[UI]** Parking capacity of each squadron's base is now shown during air wing configuration to avoid overcrowding bases when beginning the game with full squadrons.
## Fixes
* **[Mission Planning]** BAI is once again plannable against missile sites and coastal defense batteries.
* **[UI]** Fixed formatting of departure time in flight details dialog.
# 7.0.0
Saves from 6.x are not compatible with 7.0.
## Features/Improvements
* **[Engine]** Support for DCS 2.8.5.40170.
* **[Engine]** Saved games are now a zip file of save assets for easier bug reporting. The new extension is .liberation.zip. Drag and drop that file into bug reports.
* **[Campaign]** Added options to limit squadron sizes and to begin all squadrons at maximum strength. Maximum squadron size is defined during air wing configuration with default values provided by the campaign.
* **[Campaign]** Added handling for more DCS death events. This probably does not catch any deaths that weren't previously tracked, but it should record them sooner, which will improve results for game crashes or other early exits.
* **[Campaign AI]** The campaign AI now prefers fulfilling missions with squadrons which have a matching primary task. Previously distance from target held a stronger influence than task preference. Primary tasks for squadrons are set by campaign designers but are user-configurable.
* **[Flight Planning]** Package TOT and composition can be modified after advancing time in Liberation.
* **[Mission Generation]** Units on the front line are now hidden on MFDs.
* **[Mission Generation]** Preset radio channels will now be configured for both A-10C modules.
* **[Mission Generation]** The A-10C II now uses separate radios for inter- and intra-flight comms (similar to other modern aircraft).
* **[Mission Generation]** Wind speeds no longer follow a uniform distribution. Median wind speeds are now much lower and the standard deviation has been reduced considerably at altitude but increased somewhat at MSL.
* **[Mission Generation]** Improved task generation for SEAD flights carrying TALDs.
* **[Mission Generation]** Added task timeout for SEAD flights with TALDs to prevent AI from overflying the target.
* **[Mission Generation]** Game state will automatically be checkpointed before fast-forwarding the mission, and restored on mission abort. This means that it's now possible to abort a mission and make changes without needing to manually re-load your game.
* **[Modding]** Updated Community A-4E-C mod version support to 2.1.0 release.
* **[Modding]** Add support for VSN F-4B and F-4C mod.
* **[Modding]** Added support for AI C-47 mod.
* **[Modding]** Custom factions can now be defined in YAML as well as JSON. JSON support may be removed in the future if having both formats causes confusion.
* **[Modding]** Campaigns which require custom factions can now define those factions directly in the campaign YAML. See Operation Aliied Sword for an example.
* **[Modding]** The `mission_types` field in squadron files has been removed. Squadron task capability is now determined by airframe, and the auto-assignable list has always been overridden by the campaign settings.
* **[Modding]** Aircraft task capabilities and preferred aircraft for each task are now moddable in the aircraft unit yaml files. Each aircraft has a weight per task. Higher weights are given higher preference.
* **[Modding]** Wind speed generation inputs are now moddable. See https://dcs-liberation.rtfd.io/en/latest/modding/weather.html.
* **[New Game Wizard]** Choices for some options will be remembered for the next new game. Not all settings will be preserved, as many are campaign dependent.
* **[New Game Wizard]** Lua plugins can now be set while creating a new game.
* **[New Game Wizard]** Squadrons can be directly replaced with a preset during air wing configuration rather than needing to remove and create a new squadron.
* **[New Game Wizard]** Squadron liveries can now be selected during air wing configuration.
* **[Squadrons]** Squadron-specific mission capability lists no longer restrict players from assigning missions outside the squadron's preferences.
* **[UI]** The orientation of objects like SAMs, EWRs, garrisons, and ships can now be manually adjusted.
## Fixes
* **[Campaign]** Fixed a longstanding bug where oversized airlifts could corrupt a save with empty convoys.
* **[Campaign]** Aircraft with built-in TGPs but without an external pod will no longer degrade automatic loadouts to iron bombs.
* **[Engine]** Fixed crash in startup caused by a corrupted Liberation preferences file.
* **[Flight Planning]** AEW&C missions are now plannable over FOBs and LHAs.
* **[Flight Planning]** BAI is no longer plannable against buildings.
* **[Modding]** Fixed an issue where Falklands campaigns created or edited with new versions of DCS could not be loaded.
* **[Modding]** Fixed decoding of campaign yaml files to use UTF-8 rather than the system locale's default. It's now possible to use "Bf 109 K-4 Kurfürst" as a preferred aircraft type.
* **[Mission Generation]** Planes will no longer spawn in helipads that are not also designated for fixed wing parking.
* **[Mission Generation]** Potentially an issue where ground war planning game state could become corrupted, preventing mission generation.
* **[Mission Generation]** Refueling tasks will now only be created for flights that have a tanker in their package.
* **[Mission Generation]** Fixed missing Tanker task on recovery tanker missions.
* **[UI]** Fixed error when resetting air wing configuration during game setup.
* **[UI]** Fixed flight plan recreation when changing mission type with "Recreate as" flight options.
* **[UI]** Fixed failure to launch UI when Liberation persistent preferences file was corrupt.
# 6.1.1
## Fixes
* **[Data]** Fixed unit ID for the KS-19 AAA. KS-19 would not previously generate correctly in missions. A new game is required for this fix to take effect.
* **[Flight Planning]** Automatic flight planning will no longer accidentally plan a recovery tanker instead of a theater refueling package. This fixes a potential crash during mission generation when opfor plans a refueling task at a sunk carrier. You'll need to skip the current turn to force opfor to replan their flights to get the fix.
* **[Mission Generation]** Using heliports (airports without any runways) will no longer cause mission generation to fail.
* **[Mission Generation]** Prevent helicopters from spawning into collisions at FARPs when more than one flight uses the same FARP.
# 6.1.0
Saves from 6.0.0 are compatible with 6.1.0
## Features/Improvements
* **[Engine]** Support for DCS 2.8.1.34437, including Blackshark 3.
* **[Factions]** Defaulted bluefor modern to use Georgian and Ukrainian liveries for Russian aircraft.
* **[Factions]** Added Peru.
* **[Flight Planning]** AEW&C and Refueling flights are now plannable on LHA carriers.
* **[Flight Planning]** Refueling flights planned on aircraft carriers will act as a recovery tanker for the carrier.
* **[Loadouts]** Adjusted F-15E loadouts.
* **[Mission Generation]** The previous turn will now be saved as last_turn.liberation when submitting mission results. This is often essential for debugging bug reports. **Include this file in the bug report whenever it is available.**
* **[Modding]** Added support for the HMS Ariadne, Achilles, and Castle class.
* **[Modding]** Added HMS Invincible to the game data as a helicopter carrier.
## Fixes
* **[Flight Planning]** Fixes CAS flights not having landing waypoints.
* **[Mission Generation]** Airbase and FOB capture is no longer blocked by grounded aircraft / helicopters.
* **[Squadrons]** Fixed the livery for the VF-33 F-14A squadron.
* **[Theaters]** Fixed Channel campaigns not having data for land/sea/obstacle boundaries, causing front lines to extend into forests and water. Requires a new campaign to get the fix.
* **[UI]** Fixed an issue where manual submit of mission results did not end the mission correctly.
# 6.0.0
Saves from 5.x are not compatible with 6.0.
@@ -16,6 +222,7 @@ Saves from 5.x are not compatible with 6.0.
* **[Mission Generation]** Added performance option to not cull IADS when culling would affect how mission is played at target area.
* **[Mission Generation]** Reworked the ground object generation which now uses a new layout system
* **[Mission Generation]** Added information about the modulation (AM/FM) of the assigned frequencies to the kneeboard and assign AM modulation instead of FM for JTAC.
* **[Mission Generation]** Added ice halos.
* **[Mission Generation]** Adjusted wind speeds. Wind speeds at high altitude are generally higher now.
* **[Mission Generation]** Added turbulence. Higher in Summer and Winter, also higher at day time than at nighttime.
* **[Modding]** Updated UH-60L mod version support to 1.3.1

2719
client/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -15,7 +15,7 @@
"@types/react": "^18.0.21",
"@types/react-dom": "^18.0.6",
"@types/react-redux": "^7.1.24",
"axios": "^1.1.2",
"axios": "^1.6.0",
"electron-window-state": "^5.0.3",
"esri-leaflet": "^3.0.8",
"leaflet": "^1.9.2",
@@ -62,16 +62,26 @@
},
"devDependencies": {
"@rtk-query/codegen-openapi": "^1.0.0",
"@trivago/prettier-plugin-sort-imports": "^3.3.0",
"@trivago/prettier-plugin-sort-imports": "^4.2.1",
"@types/leaflet": "^1.8.0",
"@types/redux-logger": "^3.0.9",
"@types/websocket": "^1.0.5",
"electron": "^21.1.0",
"electron": "^22.3.25",
"electron-is-dev": "^2.0.0",
"generate-license-file": "^2.0.0",
"jest-transform-stub": "^2.0.0",
"license-checker": "^25.0.1",
"msw": "^1.2.2",
"react-scripts": "5.0.1",
"ts-node": "^10.9.1",
"wait-on": "^6.0.1"
},
"jest": {
"transformIgnorePatterns": [
"node_modules/(?!(@?react-leaflet|axios)/)"
],
"moduleNameMapper": {
".+\\.(css|styl|less|sass|scss|png|jpg|ttf|woff|woff2)$": "jest-transform-stub"
}
}
}

View File

@@ -1,11 +1,11 @@
import App from "./App";
import { store } from "./app/store";
import { setupStore } from "./app/store";
import { render } from "@testing-library/react";
import { Provider } from "react-redux";
test("app renders", () => {
render(
<Provider store={store}>
<Provider store={setupStore()}>
<App />
</Provider>
);

View File

@@ -50,14 +50,6 @@ const injectedRtkApi = api.injectEndpoints({
url: `/debug/waypoint-geometries/hold/${queryArg.flightId}`,
}),
}),
getDebugIpZones: build.query<
GetDebugIpZonesApiResponse,
GetDebugIpZonesApiArg
>({
query: (queryArg) => ({
url: `/debug/waypoint-geometries/ip/${queryArg.flightId}`,
}),
}),
getDebugJoinZones: build.query<
GetDebugJoinZonesApiResponse,
GetDebugJoinZonesApiArg
@@ -245,11 +237,6 @@ export type GetDebugHoldZonesApiResponse =
export type GetDebugHoldZonesApiArg = {
flightId: string;
};
export type GetDebugIpZonesApiResponse =
/** status 200 Successful Response */ IpZones;
export type GetDebugIpZonesApiArg = {
flightId: string;
};
export type GetDebugJoinZonesApiResponse =
/** status 200 Successful Response */ JoinZones;
export type GetDebugJoinZonesApiArg = {
@@ -379,12 +366,6 @@ export type HoldZones = {
permissibleZones: LatLng[][][];
preferredLines: LatLng[][];
};
export type IpZones = {
homeBubble: LatLng[][];
ipBubble: LatLng[][];
permissibleZone: LatLng[][];
safeZones: LatLng[][][];
};
export type JoinZones = {
homeBubble: LatLng[][];
targetBubble: LatLng[][];
@@ -497,7 +478,6 @@ export const {
useSetControlPointDestinationMutation,
useClearControlPointDestinationMutation,
useGetDebugHoldZonesQuery,
useGetDebugIpZonesQuery,
useGetDebugJoinZonesQuery,
useListFlightsQuery,
useGetFlightByIdQuery,

View File

@@ -4,7 +4,10 @@ const backendAddr =
new URL(window.location.toString()).searchParams.get("server") ??
"[::1]:16880";
export const HTTP_URL = `http://${backendAddr}/`;
// MSW can't handle IPv6 URLs...
// https://github.com/mswjs/msw/issues/1388
export const HTTP_URL =
process.env.NODE_ENV === "test" ? "" : `http://${backendAddr}/`;
export const backend = axios.create({
baseURL: HTTP_URL,

View File

@@ -30,11 +30,6 @@ export const liberationApi = _liberationApi.enhanceEndpoints({
{ type: Tags.FLIGHT_PLAN, id: arg.flightId },
],
},
getDebugIpZones: {
providesTags: (result, error, arg) => [
{ type: Tags.FLIGHT_PLAN, id: arg.flightId },
],
},
getDebugJoinZones: {
providesTags: (result, error, arg) => [
{ type: Tags.FLIGHT_PLAN, id: arg.flightId },

View File

@@ -3,36 +3,48 @@ import combatReducer from "../api/combatSlice";
import controlPointsReducer from "../api/controlPointsSlice";
import flightsReducer from "../api/flightsSlice";
import frontLinesReducer from "../api/frontLinesSlice";
import iadsNetworkReducer from "../api/iadsNetworkSlice";
import mapReducer from "../api/mapSlice";
import navMeshReducer from "../api/navMeshSlice";
import supplyRoutesReducer from "../api/supplyRoutesSlice";
import tgosReducer from "../api/tgosSlice";
import iadsNetworkReducer from "../api/iadsNetworkSlice";
import threatZonesReducer from "../api/threatZonesSlice";
import unculledZonesReducer from "../api/unculledZonesSlice";
import { Action, ThunkAction, configureStore } from "@reduxjs/toolkit";
import unculledZonesReducer from "../api/unculledZonesSlice";
import {
Action,
PreloadedState,
ThunkAction,
combineReducers,
configureStore,
} from "@reduxjs/toolkit";
export const store = configureStore({
reducer: {
combat: combatReducer,
controlPoints: controlPointsReducer,
flights: flightsReducer,
frontLines: frontLinesReducer,
map: mapReducer,
navmeshes: navMeshReducer,
supplyRoutes: supplyRoutesReducer,
iadsNetwork: iadsNetworkReducer,
tgos: tgosReducer,
threatZones: threatZonesReducer,
[baseApi.reducerPath]: baseApi.reducer,
unculledZones: unculledZonesReducer,
},
middleware: (getDefaultMiddleware) =>
getDefaultMiddleware().concat(baseApi.middleware),
const rootReducer = combineReducers({
combat: combatReducer,
controlPoints: controlPointsReducer,
flights: flightsReducer,
frontLines: frontLinesReducer,
map: mapReducer,
navmeshes: navMeshReducer,
supplyRoutes: supplyRoutesReducer,
iadsNetwork: iadsNetworkReducer,
tgos: tgosReducer,
threatZones: threatZonesReducer,
[baseApi.reducerPath]: baseApi.reducer,
unculledZones: unculledZonesReducer,
});
export type AppDispatch = typeof store.dispatch;
export type RootState = ReturnType<typeof store.getState>;
export function setupStore(preloadedState?: PreloadedState<RootState>) {
return configureStore({
reducer: rootReducer,
middleware: (getDefaultMiddleware) =>
getDefaultMiddleware().concat(baseApi.middleware),
preloadedState: preloadedState,
});
}
export type AppStore = ReturnType<typeof setupStore>;
export type AppDispatch = AppStore["dispatch"];
export type RootState = ReturnType<typeof rootReducer>;
export type AppThunk<ReturnType = void> = ThunkAction<
ReturnType,
RootState,

View File

@@ -0,0 +1,53 @@
import Aircraft from "./Aircraft";
import { render } from "@testing-library/react";
import { Icon } from "leaflet";
const mockMarker = jest.fn();
jest.mock("react-leaflet", () => ({
Marker: (props: any) => {
mockMarker(props);
},
}));
test("grounded aircraft do not render", async () => {
const { container } = render(
<Aircraft
flight={{
id: "",
blue: true,
position: undefined,
sidc: "",
waypoints: [],
}}
/>
);
expect(container).toBeEmptyDOMElement();
});
test("in-flight aircraft render", async () => {
render(
<Aircraft
flight={{
id: "",
blue: true,
position: {
lat: 10,
lng: 20,
},
sidc: "foobar",
waypoints: [],
}}
/>
);
expect(mockMarker).toHaveBeenCalledWith(
expect.objectContaining({
position: {
lat: 10,
lng: 20,
},
icon: expect.any(Icon),
})
);
});

View File

@@ -0,0 +1,53 @@
import { renderWithProviders } from "../../testutils";
import AircraftLayer from "./AircraftLayer";
import { PropsWithChildren } from "react";
const mockLayerGroup = jest.fn();
const mockMarker = jest.fn();
jest.mock("react-leaflet", () => ({
LayerGroup: (props: PropsWithChildren<any>) => {
mockLayerGroup(props);
return <>{props.children}</>;
},
Marker: (props: any) => {
mockMarker(props);
},
}));
test("layer is empty by default", async () => {
renderWithProviders(<AircraftLayer />);
expect(mockLayerGroup).toHaveBeenCalledTimes(1);
expect(mockMarker).not.toHaveBeenCalled();
});
test("layer has aircraft if non-empty", async () => {
renderWithProviders(<AircraftLayer />, {
preloadedState: {
flights: {
flights: {
foo: {
id: "foo",
blue: true,
sidc: "",
position: {
lat: 0,
lng: 0,
},
},
bar: {
id: "bar",
blue: false,
sidc: "",
position: {
lat: 0,
lng: 0,
},
},
},
selected: null,
},
},
});
expect(mockLayerGroup).toHaveBeenCalledTimes(1);
expect(mockMarker).toHaveBeenCalledTimes(2);
});

View File

@@ -0,0 +1,146 @@
import { renderWithProviders } from "../../testutils";
import AirDefenseRangeLayer, { colorFor } from "./AirDefenseRangeLayer";
import { PropsWithChildren } from "react";
const mockLayerGroup = jest.fn();
const mockCircle = jest.fn();
jest.mock("react-leaflet", () => ({
LayerGroup: (props: PropsWithChildren<any>) => {
mockLayerGroup(props);
return <>{props.children}</>;
},
Circle: (props: any) => {
mockCircle(props);
},
}));
describe("colorFor", () => {
it("has a unique color for each configuration", () => {
const params = [
[false, false],
[false, true],
[true, false],
[true, true],
];
var colors = new Set<string>();
for (const [blue, detection] of params) {
colors.add(colorFor(blue, detection));
}
expect(colors.size).toEqual(4);
});
});
describe("AirDefenseRangeLayer", () => {
it("draws nothing when there are no TGOs", () => {
renderWithProviders(<AirDefenseRangeLayer blue={true} />);
expect(mockLayerGroup).toHaveBeenCalledTimes(1);
expect(mockCircle).not.toHaveBeenCalled();
});
it("does not draw wrong range types", () => {
renderWithProviders(<AirDefenseRangeLayer blue={true} />, {
preloadedState: {
tgos: {
tgos: {
foo: {
id: "foo",
name: "Foo",
control_point_name: "Bar",
category: "AA",
blue: false,
position: {
lat: 0,
lng: 0,
},
units: [],
threat_ranges: [],
detection_ranges: [20],
dead: false,
sidc: "",
},
},
},
},
});
expect(mockLayerGroup).toHaveBeenCalledTimes(1);
expect(mockCircle).not.toHaveBeenCalled();
});
it("draws threat ranges", () => {
renderWithProviders(<AirDefenseRangeLayer blue={true} />, {
preloadedState: {
tgos: {
tgos: {
foo: {
id: "foo",
name: "Foo",
control_point_name: "Bar",
category: "AA",
blue: true,
position: {
lat: 10,
lng: 20,
},
units: [],
threat_ranges: [10],
detection_ranges: [20],
dead: false,
sidc: "",
},
},
},
},
});
expect(mockLayerGroup).toHaveBeenCalledTimes(1);
expect(mockCircle).toHaveBeenCalledWith(
expect.objectContaining({
center: {
lat: 10,
lng: 20,
},
radius: 10,
color: colorFor(true, false),
interactive: false,
})
);
});
it("draws detection ranges", () => {
renderWithProviders(<AirDefenseRangeLayer blue={true} detection />, {
preloadedState: {
tgos: {
tgos: {
foo: {
id: "foo",
name: "Foo",
control_point_name: "Bar",
category: "AA",
blue: true,
position: {
lat: 10,
lng: 20,
},
units: [],
threat_ranges: [10],
detection_ranges: [20],
dead: false,
sidc: "",
},
},
},
},
});
expect(mockLayerGroup).toHaveBeenCalledTimes(1);
expect(mockCircle).toHaveBeenCalledWith(
expect.objectContaining({
center: {
lat: 10,
lng: 20,
},
radius: 20,
color: colorFor(true, true),
interactive: false,
})
);
});
});

View File

@@ -9,7 +9,7 @@ interface TgoRangeCirclesProps {
detection?: boolean;
}
function colorFor(blue: boolean, detection: boolean) {
export function colorFor(blue: boolean, detection: boolean) {
if (blue) {
return detection ? "#bb89ff" : "#0084ff";
}

View File

@@ -0,0 +1,132 @@
import { renderWithProviders } from "../../testutils";
import Combat from "./Combat";
import { LatLng } from "leaflet";
const mockPolyline = jest.fn();
const mockPolygon = jest.fn();
jest.mock("react-leaflet", () => ({
Polyline: (props: any) => {
mockPolyline(props);
},
Polygon: (props: any) => {
mockPolygon(props);
},
}));
describe("Combat", () => {
describe("footprint", () => {
it("is not interactive", () => {
renderWithProviders(
<Combat
combat={{
id: "foo",
flight_position: null,
target_positions: null,
footprint: [[new LatLng(0, 0), new LatLng(0, 1), new LatLng(1, 0)]],
}}
/>
);
expect(mockPolygon).toBeCalledWith(
expect.objectContaining({ interactive: false })
);
});
// Fails because we don't handle multi-poly combat footprints correctly.
it.skip("renders single polygons", () => {
const boundary = [new LatLng(0, 0), new LatLng(0, 1), new LatLng(1, 0)];
renderWithProviders(
<Combat
combat={{
id: "foo",
flight_position: null,
target_positions: null,
footprint: [boundary],
}}
/>
);
expect(mockPolygon).toBeCalledWith(
expect.objectContaining({ positions: boundary })
);
});
// Fails because we don't handle multi-poly combat footprints correctly.
it.skip("renders multiple polygons", () => {
const boundary = [new LatLng(0, 0), new LatLng(0, 1), new LatLng(1, 0)];
renderWithProviders(
<Combat
combat={{
id: "foo",
flight_position: null,
target_positions: null,
footprint: [boundary, boundary],
}}
/>
);
expect(mockPolygon).toBeCalledTimes(2);
});
});
describe("lines", () => {
it("is not interactive", () => {
renderWithProviders(
<Combat
combat={{
id: "foo",
flight_position: new LatLng(0, 0),
target_positions: [new LatLng(1, 0)],
footprint: null,
}}
/>
);
expect(mockPolyline).toBeCalledWith(
expect.objectContaining({ interactive: false })
);
});
it("renders single line", () => {
renderWithProviders(
<Combat
combat={{
id: "foo",
flight_position: new LatLng(0, 0),
target_positions: [new LatLng(0, 1)],
footprint: null,
}}
/>
);
expect(mockPolyline).toBeCalledWith(
expect.objectContaining({
positions: [new LatLng(0, 0), new LatLng(0, 1)],
})
);
});
it("renders multiple lines", () => {
renderWithProviders(
<Combat
combat={{
id: "foo",
flight_position: new LatLng(0, 0),
target_positions: [new LatLng(0, 1), new LatLng(1, 0)],
footprint: null,
}}
/>
);
expect(mockPolyline).toBeCalledTimes(2);
});
});
it("renders nothing if no footprint or targets", () => {
const { container } = renderWithProviders(
<Combat
combat={{
id: "foo",
flight_position: new LatLng(0, 0),
target_positions: null,
footprint: null,
}}
/>
);
expect(container).toBeEmptyDOMElement();
});
});

View File

@@ -0,0 +1,48 @@
import { renderWithProviders } from "../../testutils";
import CombatLayer from "./CombatLayer";
import { LatLng } from "leaflet";
import { PropsWithChildren } from "react";
const mockPolyline = jest.fn();
const mockLayerGroup = jest.fn();
jest.mock("react-leaflet", () => ({
LayerGroup: (props: PropsWithChildren<any>) => {
mockLayerGroup(props);
return <>{props.children}</>;
},
Polyline: (props: any) => {
mockPolyline(props);
},
}));
describe("CombatLayer", () => {
it("renders each combat", () => {
renderWithProviders(<CombatLayer />, {
preloadedState: {
combat: {
combat: {
foo: {
id: "foo",
flight_position: new LatLng(0, 0),
target_positions: [new LatLng(0, 1)],
footprint: null,
},
bar: {
id: "foo",
flight_position: new LatLng(0, 0),
target_positions: [new LatLng(0, 1)],
footprint: null,
},
},
},
},
});
expect(mockPolyline).toBeCalledTimes(2);
});
it("renders LayerGroup but no contents if no combat", () => {
renderWithProviders(<CombatLayer />);
expect(mockLayerGroup).toBeCalledTimes(1);
expect(mockPolyline).not.toHaveBeenCalled();
});
});

View File

@@ -0,0 +1,52 @@
import { renderWithProviders } from "../../testutils";
import ControlPointsLayer from "./ControlPointsLayer";
import { LatLng } from "leaflet";
import { PropsWithChildren } from "react";
const mockMarker = jest.fn();
const mockLayerGroup = jest.fn();
jest.mock("react-leaflet", () => ({
LayerGroup: (props: PropsWithChildren<any>) => {
mockLayerGroup(props);
return <>{props.children}</>;
},
Marker: (props: any) => {
mockMarker(props);
},
}));
describe("ControlPointsLayer", () => {
it("renders each control point", () => {
renderWithProviders(<ControlPointsLayer />, {
preloadedState: {
controlPoints: {
controlPoints: {
foo: {
id: "foo",
name: "Foo",
blue: true,
position: new LatLng(0, 0),
mobile: false,
sidc: "",
},
bar: {
id: "bar",
name: "Bar",
blue: false,
position: new LatLng(1, 0),
mobile: false,
sidc: "",
},
},
},
},
});
expect(mockMarker).toBeCalledTimes(2);
});
it("renders LayerGroup but no contents if no combat", () => {
renderWithProviders(<ControlPointsLayer />);
expect(mockLayerGroup).toBeCalledTimes(1);
expect(mockMarker).not.toHaveBeenCalled();
});
});

View File

@@ -0,0 +1,78 @@
import { renderWithProviders } from "../../testutils";
import CullingExclusionZones from "./CullingExclusionZones";
import { PropsWithChildren } from "react";
const mockCircle = jest.fn();
const mockLayerGroup = jest.fn();
const mockLayerControlOverlay = jest.fn();
jest.mock("react-leaflet", () => ({
LayerGroup: (props: PropsWithChildren<any>) => {
mockLayerGroup(props);
return <>{props.children}</>;
},
LayersControl: {
Overlay: (props: PropsWithChildren<any>) => {
mockLayerControlOverlay(props);
return <>{props.children}</>;
},
},
Circle: (props: any) => {
mockCircle(props);
},
}));
describe("CullingExclusionZones", () => {
it("is empty there are no exclusion zones", () => {
renderWithProviders(<CullingExclusionZones />);
expect(mockCircle).not.toHaveBeenCalled();
expect(mockLayerGroup).toHaveBeenCalledTimes(1);
expect(mockLayerControlOverlay).toHaveBeenCalledTimes(1);
});
describe("zone circles", () => {
it("are drawn in the correct locations", () => {
renderWithProviders(<CullingExclusionZones />, {
preloadedState: {
unculledZones: {
zones: [
{
position: {
lat: 0,
lng: 0,
},
radius: 10,
},
{
position: {
lat: 1,
lng: 1,
},
radius: 2,
},
],
},
},
});
expect(mockCircle).toHaveBeenCalledTimes(2);
expect(mockCircle).toHaveBeenCalledWith(
expect.objectContaining({
center: {
lat: 0,
lng: 0,
},
radius: 10,
})
);
expect(mockCircle).toHaveBeenCalledWith(
expect.objectContaining({
center: {
lat: 1,
lng: 1,
},
radius: 2,
})
);
});
it("are not interactive", () => {});
});
});

View File

@@ -30,18 +30,10 @@ const CullingExclusionCircles = (props: CullingExclusionCirclesProps) => {
export default function CullingExclusionZones() {
const data = useAppSelector(selectUnculledZones).zones;
var cez = <></>;
if (!data) {
console.log("Empty response when loading culling exclusion zones");
} else {
cez = (
<CullingExclusionCircles zones={data}></CullingExclusionCircles>
);
}
return (
<LayersControl.Overlay name="Culling exclusion zones">
{cez}
<CullingExclusionCircles zones={data}></CullingExclusionCircles>
</LayersControl.Overlay>
);
}

View File

@@ -1,7 +1,8 @@
import { Flight } from "../../api/liberationApi";
import { useGetCommitBoundaryForFlightQuery } from "../../api/liberationApi";
import WaypointMarker from "../waypointmarker";
import { ReactElement } from "react";
import { Polyline as LPolyline } from "leaflet";
import { ReactElement, useEffect, useRef } from "react";
import { Polyline } from "react-leaflet";
const BLUE_PATH = "#0084ff";
@@ -27,16 +28,41 @@ const pathColor = (props: FlightPlanProps) => {
function FlightPlanPath(props: FlightPlanProps) {
const color = pathColor(props);
const waypoints = props.flight.waypoints;
const polylineRef = useRef<LPolyline | null>(null);
// Flight paths should be drawn under everything else. There seems to be an
// issue where `interactive: false` doesn't do as its told (there's nuance,
// see the bug for details). It looks better if we draw the other elements on
// top of the flight plans anyway, so just push the flight plan to the back.
//
// https://github.com/dcs-liberation/dcs_liberation/issues/3295
//
// It's not possible to z-index a polyline (and leaflet says it never will be,
// because this is a limitation of SVG, not leaflet:
// https://github.com/Leaflet/Leaflet/issues/185), so we need to use
// bringToBack() to push the flight paths to the back of the drawing once
// they've been added to the map. They'll still draw on top of the map, but
// behind everything than was added before them. Anything added after always
// goes on top.
useEffect(() => {
if (!props.selected) {
polylineRef.current?.bringToBack();
}
});
if (waypoints == null) {
return <></>;
}
const points = waypoints
.filter((waypoint) => waypoint.include_in_path)
.map((waypoint) => waypoint.position);
return (
<Polyline
positions={points}
pathOptions={{ color: color, interactive: false }}
ref={polylineRef}
/>
);
}

View File

@@ -0,0 +1,409 @@
import { renderWithProviders } from "../../testutils";
import FlightPlansLayer from "./FlightPlansLayer";
import { PropsWithChildren } from "react";
const mockPolyline = jest.fn();
const mockLayerGroup = jest.fn();
jest.mock("react-leaflet", () => ({
LayerGroup: (props: PropsWithChildren<any>) => {
mockLayerGroup(props);
return <>{props.children}</>;
},
Polyline: (props: any) => {
mockPolyline(props);
},
}));
// The waypoints in test data below should all use `should_make: false`. Markers
// need useMap() to check the zoom level to decide if they should be drawn or
// not, and we don't have good options here for mocking that behavior.
describe("FlightPlansLayer", () => {
describe("unselected flights", () => {
it("are drawn", () => {
renderWithProviders(<FlightPlansLayer blue={true} />, {
preloadedState: {
flights: {
flights: {
foo: {
id: "foo",
blue: true,
sidc: "",
waypoints: [
{
name: "",
position: {
lat: 0,
lng: 0,
},
altitude_ft: 0,
altitude_reference: "MSL",
is_movable: true,
should_mark: false,
include_in_path: true,
timing: "",
},
{
name: "",
position: {
lat: 1,
lng: 1,
},
altitude_ft: 0,
altitude_reference: "MSL",
is_movable: true,
should_mark: false,
include_in_path: true,
timing: "",
},
],
},
bar: {
id: "bar",
blue: true,
sidc: "",
waypoints: [
{
name: "",
position: {
lat: 0,
lng: 0,
},
altitude_ft: 0,
altitude_reference: "MSL",
is_movable: true,
should_mark: false,
include_in_path: true,
timing: "",
},
{
name: "",
position: {
lat: 1,
lng: 1,
},
altitude_ft: 0,
altitude_reference: "MSL",
is_movable: true,
should_mark: false,
include_in_path: true,
timing: "",
},
],
},
},
selected: null,
},
},
});
// For some reason passing ref to PolyLine causes it and its group to be
// redrawn, so these numbers don't match what you'd expect from the test.
// It probably needs to be rewritten without mocks.
expect(mockPolyline).toHaveBeenCalledTimes(3);
expect(mockLayerGroup).toBeCalledTimes(2);
});
it("are not drawn if wrong coalition", () => {
renderWithProviders(<FlightPlansLayer blue={true} />, {
preloadedState: {
flights: {
flights: {
foo: {
id: "foo",
blue: true,
sidc: "",
waypoints: [
{
name: "",
position: {
lat: 0,
lng: 0,
},
altitude_ft: 0,
altitude_reference: "MSL",
is_movable: true,
should_mark: false,
include_in_path: true,
timing: "",
},
{
name: "",
position: {
lat: 1,
lng: 1,
},
altitude_ft: 0,
altitude_reference: "MSL",
is_movable: true,
should_mark: false,
include_in_path: true,
timing: "",
},
],
},
bar: {
id: "bar",
blue: false,
sidc: "",
waypoints: [
{
name: "",
position: {
lat: 0,
lng: 0,
},
altitude_ft: 0,
altitude_reference: "MSL",
is_movable: true,
should_mark: false,
include_in_path: true,
timing: "",
},
{
name: "",
position: {
lat: 1,
lng: 1,
},
altitude_ft: 0,
altitude_reference: "MSL",
is_movable: true,
should_mark: false,
include_in_path: true,
timing: "",
},
],
},
},
selected: null,
},
},
});
expect(mockPolyline).toHaveBeenCalledTimes(1);
expect(mockLayerGroup).toBeCalledTimes(1);
});
it("are not drawn when only selected flights are to be drawn", () => {
renderWithProviders(<FlightPlansLayer blue={true} selectedOnly />, {
preloadedState: {
flights: {
flights: {
foo: {
id: "foo",
blue: true,
sidc: "",
waypoints: [
{
name: "",
position: {
lat: 0,
lng: 0,
},
altitude_ft: 0,
altitude_reference: "MSL",
is_movable: true,
should_mark: false,
include_in_path: true,
timing: "",
},
{
name: "",
position: {
lat: 1,
lng: 1,
},
altitude_ft: 0,
altitude_reference: "MSL",
is_movable: true,
should_mark: false,
include_in_path: true,
timing: "",
},
],
},
},
selected: null,
},
},
});
expect(mockPolyline).not.toHaveBeenCalled();
expect(mockLayerGroup).toBeCalledTimes(1);
});
});
describe("selected flights", () => {
it("are drawn", () => {
renderWithProviders(<FlightPlansLayer blue={true} />, {
preloadedState: {
flights: {
flights: {
foo: {
id: "foo",
blue: true,
sidc: "",
waypoints: [
{
name: "",
position: {
lat: 0,
lng: 0,
},
altitude_ft: 0,
altitude_reference: "MSL",
is_movable: true,
should_mark: false,
include_in_path: true,
timing: "",
},
{
name: "",
position: {
lat: 1,
lng: 1,
},
altitude_ft: 0,
altitude_reference: "MSL",
is_movable: true,
should_mark: false,
include_in_path: true,
timing: "",
},
],
},
bar: {
id: "bar",
blue: true,
sidc: "",
waypoints: [
{
name: "",
position: {
lat: 0,
lng: 0,
},
altitude_ft: 0,
altitude_reference: "MSL",
is_movable: true,
should_mark: false,
include_in_path: true,
timing: "",
},
{
name: "",
position: {
lat: 1,
lng: 1,
},
altitude_ft: 0,
altitude_reference: "MSL",
is_movable: true,
should_mark: false,
include_in_path: true,
timing: "",
},
],
},
},
selected: "foo",
},
},
});
expect(mockPolyline).toHaveBeenCalledTimes(2);
expect(mockLayerGroup).toBeCalledTimes(1);
});
it("are not drawn twice", () => {
renderWithProviders(<FlightPlansLayer blue={true} />, {
preloadedState: {
flights: {
flights: {
foo: {
id: "foo",
blue: true,
sidc: "",
waypoints: [
{
name: "",
position: {
lat: 0,
lng: 0,
},
altitude_ft: 0,
altitude_reference: "MSL",
is_movable: true,
should_mark: false,
include_in_path: true,
timing: "",
},
{
name: "",
position: {
lat: 1,
lng: 1,
},
altitude_ft: 0,
altitude_reference: "MSL",
is_movable: true,
should_mark: false,
include_in_path: true,
timing: "",
},
],
},
},
selected: "foo",
},
},
});
expect(mockPolyline).toHaveBeenCalledTimes(1);
expect(mockLayerGroup).toBeCalledTimes(1);
});
it("are not drawn if red", () => {
renderWithProviders(<FlightPlansLayer blue={false} selectedOnly />, {
preloadedState: {
flights: {
flights: {
foo: {
id: "foo",
blue: false,
sidc: "",
waypoints: [
{
name: "",
position: {
lat: 0,
lng: 0,
},
altitude_ft: 0,
altitude_reference: "MSL",
is_movable: true,
should_mark: false,
include_in_path: true,
timing: "",
},
{
name: "",
position: {
lat: 1,
lng: 1,
},
altitude_ft: 0,
altitude_reference: "MSL",
is_movable: true,
should_mark: false,
include_in_path: true,
timing: "",
},
],
},
},
selected: "foo",
},
},
});
expect(mockPolyline).not.toHaveBeenCalled();
expect(mockLayerGroup).toBeCalledTimes(1);
});
});
it("are not drawn if there are no flights", () => {
renderWithProviders(<FlightPlansLayer blue={true} />);
expect(mockPolyline).not.toHaveBeenCalled();
expect(mockLayerGroup).toBeCalledTimes(1);
});
});

View File

@@ -0,0 +1,32 @@
import { renderWithProviders } from "../../testutils";
import FrontLine from "./FrontLine";
import { PolylineProps } from "react-leaflet";
const mockPolyline = jest.fn();
jest.mock("react-leaflet", () => ({
Polyline: (props: PolylineProps) => {
mockPolyline(props);
},
}));
describe("FrontLine", () => {
it("is drawn in the correct location", () => {
const extents = [
{ lat: 0, lng: 0 },
{ lat: 1, lng: 0 },
];
renderWithProviders(
<FrontLine
front={{
id: "",
extents: extents,
}}
/>
);
expect(mockPolyline).toHaveBeenCalledWith(
expect.objectContaining({
positions: extents,
})
);
});
});

View File

@@ -0,0 +1,56 @@
import { renderWithProviders } from "../../testutils";
import FrontLinesLayer from "./FrontLinesLayer";
import { PropsWithChildren } from "react";
const mockPolyline = jest.fn();
const mockLayerGroup = jest.fn();
jest.mock("react-leaflet", () => ({
LayerGroup: (props: PropsWithChildren<any>) => {
mockLayerGroup(props);
return <>{props.children}</>;
},
Polyline: (props: any) => {
mockPolyline(props);
},
}));
// The waypoints in test data below should all use `should_make: false`. Markers
// need useMap() to check the zoom level to decide if they should be drawn or
// not, and we don't have good options here for mocking that behavior.
describe("FrontLinesLayer", () => {
it("draws nothing when there are no front lines", () => {
renderWithProviders(<FrontLinesLayer />);
expect(mockPolyline).not.toHaveBeenCalled();
expect(mockLayerGroup).toHaveBeenCalledTimes(1);
});
it("draws front lines", () => {
const extents = [
{ lat: 0, lng: 0 },
{ lat: 1, lng: 1 },
];
renderWithProviders(<FrontLinesLayer />, {
preloadedState: {
frontLines: {
fronts: {
foo: {
id: "foo",
extents: extents,
},
bar: {
id: "bar",
extents: extents,
},
},
},
},
});
expect(mockPolyline).toHaveBeenCalledTimes(2);
expect(mockPolyline).toHaveBeenCalledWith(
expect.objectContaining({
positions: extents,
})
);
expect(mockLayerGroup).toHaveBeenCalledTimes(1);
});
});

View File

@@ -3,7 +3,7 @@ import { useAppSelector } from "../../app/hooks";
import FrontLine from "../frontline";
import { LayerGroup } from "react-leaflet";
export default function SupplyRoutesLayer() {
export default function FrontLinesLayer() {
const fronts = useAppSelector(selectFrontLines).fronts;
return (
<LayerGroup>

View File

@@ -0,0 +1,125 @@
import { renderWithProviders } from "../../testutils";
import NavMeshLayer from "./NavMeshLayer";
import { PropsWithChildren } from "react";
const mockPolygon = jest.fn();
const mockLayerGroup = jest.fn();
jest.mock("react-leaflet", () => ({
LayerGroup: (props: PropsWithChildren<any>) => {
mockLayerGroup(props);
return <>{props.children}</>;
},
Polygon: (props: any) => {
mockPolygon(props);
},
}));
// The waypoints in test data below should all use `should_make: false`. Markers
// need useMap() to check the zoom level to decide if they should be drawn or
// not, and we don't have good options here for mocking that behavior.
describe("NavMeshLayer", () => {
it("draws blue meshes", () => {
const poly1 = [
[
{ lat: -1, lng: 0 },
{ lat: 0, lng: 1 },
{ lat: 1, lng: 0 },
],
];
const poly2 = [
[
{ lat: -1, lng: 0 },
{ lat: 0, lng: -1 },
{ lat: 1, lng: 0 },
],
];
renderWithProviders(<NavMeshLayer blue={true} />, {
preloadedState: {
navmeshes: {
blue: [
{
poly: poly1,
threatened: false,
},
{
poly: poly2,
threatened: true,
},
],
red: [
{
poly: [
[
{ lat: -1, lng: 0 },
{ lat: 0, lng: 2 },
{ lat: 1, lng: 0 },
],
],
threatened: false,
},
],
},
},
});
expect(mockPolygon).toHaveBeenCalledTimes(2);
expect(mockPolygon).toHaveBeenCalledWith(
expect.objectContaining({
fillColor: "#00ff00",
positions: poly1,
interactive: false,
})
);
expect(mockPolygon).toHaveBeenCalledWith(
expect.objectContaining({
fillColor: "#ff0000",
positions: poly2,
interactive: false,
})
);
expect(mockLayerGroup).toHaveBeenCalledTimes(1);
});
it("draws red navmesh", () => {
renderWithProviders(<NavMeshLayer blue={false} />, {
preloadedState: {
navmeshes: {
blue: [
{
poly: [
[
{ lat: -1, lng: 0 },
{ lat: 0, lng: 1 },
{ lat: 1, lng: 0 },
],
],
threatened: false,
},
{
poly: [
[
{ lat: -1, lng: 0 },
{ lat: 0, lng: -1 },
{ lat: 1, lng: 0 },
],
],
threatened: true,
},
],
red: [
{
poly: [
[
{ lat: -1, lng: 0 },
{ lat: 0, lng: 2 },
{ lat: 1, lng: 0 },
],
],
threatened: false,
},
],
},
},
});
expect(mockPolygon).toHaveBeenCalledTimes(1);
expect(mockLayerGroup).toHaveBeenCalledTimes(1);
});
});

View File

@@ -0,0 +1,16 @@
import SplitLines from "./SplitLines";
import { screen } from "@testing-library/dom";
import { render } from "@testing-library/react";
describe("SplitLines", () => {
it("joins items with line break tags", () => {
render(
<div data-testid={"container"}>
<SplitLines items={["foo", "bar", "baz"]} />
</div>
);
const container = screen.getByTestId("container");
expect(container).toContainHTML("foo<br />bar<br />baz<br />");
});
});

View File

@@ -0,0 +1,159 @@
import { renderWithProviders } from "../../testutils";
import SupplyRoute, { RouteColor } from "./SupplyRoute";
import { screen } from "@testing-library/react";
import { PropsWithChildren } from "react";
const mockPolyline = jest.fn();
jest.mock("react-leaflet", () => ({
Polyline: (props: PropsWithChildren<any>) => {
mockPolyline(props);
return <>{props.children}</>;
},
Tooltip: (props: PropsWithChildren<any>) => {
return <p data-testid="tooltip">{props.children}</p>;
},
}));
describe("SupplyRoute", () => {
it("is red when inactive and owned by opfor", () => {
renderWithProviders(
<SupplyRoute
route={{
id: "",
points: [],
front_active: false,
is_sea: false,
blue: false,
active_transports: [],
}}
/>
);
expect(mockPolyline).toHaveBeenCalledWith(
expect.objectContaining({
color: RouteColor.Red,
})
);
});
it("is blue when inactive and owned by bluefor", () => {
renderWithProviders(
<SupplyRoute
route={{
id: "",
points: [],
front_active: false,
is_sea: false,
blue: true,
active_transports: [],
}}
/>
);
expect(mockPolyline).toHaveBeenCalledWith(
expect.objectContaining({
color: RouteColor.Blue,
})
);
});
it("is orange when contested", () => {
renderWithProviders(
<SupplyRoute
route={{
id: "",
points: [],
front_active: true,
is_sea: false,
blue: false,
active_transports: [],
}}
/>
);
expect(mockPolyline).toHaveBeenCalledWith(
expect.objectContaining({
color: RouteColor.Contested,
})
);
});
it("is highlighted when the route has active transports", () => {
renderWithProviders(
<SupplyRoute
route={{
id: "",
points: [],
front_active: false,
is_sea: false,
blue: false,
active_transports: ["foo"],
}}
/>
);
expect(mockPolyline).toHaveBeenCalledTimes(2);
expect(mockPolyline).toHaveBeenCalledWith(
expect.objectContaining({
color: RouteColor.Highlight,
})
);
});
it("is drawn in the right place", () => {
const points = [
{ lat: 0, lng: 0 },
{ lat: 1, lng: 1 },
];
renderWithProviders(
<SupplyRoute
route={{
id: "",
points: points,
front_active: false,
is_sea: false,
blue: false,
active_transports: ["foo"],
}}
/>
);
expect(mockPolyline).toHaveBeenCalledTimes(2);
expect(mockPolyline).toHaveBeenCalledWith(
expect.objectContaining({
positions: points,
})
);
});
it("has a tooltip describing an inactive supply route", () => {
renderWithProviders(
<SupplyRoute
route={{
id: "",
points: [],
front_active: false,
is_sea: false,
blue: false,
active_transports: [],
}}
/>
);
const tooltip = screen.getByTestId("tooltip");
expect(tooltip).toHaveTextContent("This supply route is inactive.");
});
it("has a tooltip describing active supply routes", () => {
renderWithProviders(
<SupplyRoute
route={{
id: "",
points: [],
front_active: false,
is_sea: false,
blue: false,
active_transports: ["foo", "bar"],
}}
/>
);
const tooltip = screen.getByTestId("tooltip");
expect(tooltip).toContainHTML("foo<br />bar");
});
});

View File

@@ -4,6 +4,13 @@ import { Polyline as LPolyline } from "leaflet";
import { useEffect, useRef } from "react";
import { Polyline, Tooltip } from "react-leaflet";
export enum RouteColor {
Blue = "#2d3e50",
Contested = "#c85050",
Highlight = "#ffffff",
Red = "#8c1414",
}
interface SupplyRouteProps {
route: SupplyRouteModel;
}
@@ -26,18 +33,22 @@ function ActiveSupplyRouteHighlight(props: SupplyRouteProps) {
}
return (
<Polyline positions={props.route.points} color={"#ffffff"} weight={2} />
<Polyline
positions={props.route.points}
color={RouteColor.Highlight}
weight={2}
/>
);
}
function colorFor(route: SupplyRouteModel) {
if (route.front_active) {
return "#c85050";
return RouteColor.Contested;
}
if (route.blue) {
return "#2d3e50";
return RouteColor.Blue;
}
return "#8c1414";
return RouteColor.Red;
}
export default function SupplyRoute(props: SupplyRouteProps) {

View File

@@ -1,73 +0,0 @@
import { useGetDebugIpZonesQuery } from "../../api/liberationApi";
import { LayerGroup, Polygon } from "react-leaflet";
interface IpZonesProps {
flightId: string;
}
function IpZones(props: IpZonesProps) {
const { data, error, isLoading } = useGetDebugIpZonesQuery({
flightId: props.flightId,
});
if (isLoading) {
return <></>;
}
if (error) {
console.error("Error while loading waypoint IP zone info", error);
return <></>;
}
if (!data) {
console.log("Waypoint IP zone returned empty response");
return <></>;
}
return (
<>
<Polygon
positions={data.homeBubble}
color="#ffff00"
fillOpacity={0.1}
interactive={false}
/>
<Polygon
positions={data.ipBubble}
color="#bb89ff"
fillOpacity={0.1}
interactive={false}
/>
<Polygon
positions={data.permissibleZone}
color="#ffffff"
fillOpacity={0.1}
interactive={false}
/>
{data.safeZones.map((zone, idx) => {
return (
<Polygon
key={idx}
positions={zone}
color="#80BA80"
fillOpacity={0.1}
interactive={false}
/>
);
})}
</>
);
}
interface IpZonesLayerProps {
flightId: string | null;
}
export function IpZonesLayer(props: IpZonesLayerProps) {
return (
<LayerGroup>
{props.flightId ? <IpZones flightId={props.flightId} /> : <></>}
</LayerGroup>
);
}

View File

@@ -1,7 +1,6 @@
import { selectSelectedFlightId } from "../../api/flightsSlice";
import { useAppSelector } from "../../app/hooks";
import { HoldZonesLayer } from "./HoldZones";
import { IpZonesLayer } from "./IpZones";
import { JoinZonesLayer } from "./JoinZones";
import { LayersControl } from "react-leaflet";
@@ -16,9 +15,6 @@ export function WaypointDebugZonesControls() {
return (
<>
<LayersControl.Overlay name="IP zones">
<IpZonesLayer flightId={selectedFlightId} />
</LayersControl.Overlay>
<LayersControl.Overlay name="Join zones">
<JoinZonesLayer flightId={selectedFlightId} />
</LayersControl.Overlay>

View File

@@ -0,0 +1,277 @@
import { HTTP_URL } from "../../api/backend";
import { renderWithProviders } from "../../testutils";
import WaypointMarker, { TOOLTIP_ZOOM_LEVEL } from "./WaypointMarker";
import { Map, Marker } from "leaflet";
import { rest, MockedRequest, matchRequestUrl } from "msw";
import { setupServer } from "msw/node";
import React from "react";
import { MapContainer } from "react-leaflet";
// https://mswjs.io/docs/extensions/life-cycle-events#asserting-request-payload
const waitForRequest = (method: string, url: string) => {
let requestId = "";
return new Promise<MockedRequest>((resolve, reject) => {
server.events.on("request:start", (req) => {
const matchesMethod = req.method.toLowerCase() === method.toLowerCase();
const matchesUrl = matchRequestUrl(req.url, url).matches;
if (matchesMethod && matchesUrl) {
requestId = req.id;
}
});
server.events.on("request:match", (req) => {
if (req.id === requestId) {
resolve(req);
}
});
server.events.on("request:unhandled", (req) => {
if (req.id === requestId) {
reject(
new Error(`The ${req.method} ${req.url.href} request was unhandled.`)
);
}
});
});
};
const server = setupServer(
rest.post(
`${HTTP_URL}/waypoints/:flightId/:waypointIdx/position`,
(req, res, ctx) => {
if (req.params.flightId === "") {
return res(ctx.status(500));
}
if (req.params.waypointIdx === "0") {
return res(ctx.status(403));
}
return res(ctx.status(204));
}
)
);
beforeAll(() => server.listen({ onUnhandledRequest: "error" }));
afterEach(() => server.resetHandlers());
afterAll(() => server.close());
describe("WaypointMarker", () => {
it("is placed in the correct location", () => {
const waypoint = {
name: "",
position: { lat: 0, lng: 0 },
altitude_ft: 0,
altitude_reference: "MSL",
is_movable: false,
should_mark: false,
include_in_path: true,
timing: "",
};
const marker = React.createRef<Marker>();
renderWithProviders(
<MapContainer>
<WaypointMarker
number={0}
waypoint={waypoint}
flight={{
id: "",
blue: true,
sidc: "",
waypoints: [waypoint],
}}
ref={marker}
/>
</MapContainer>
);
expect(marker.current?.getLatLng()).toEqual({ lat: 0, lng: 0 });
});
it("tooltip is hidden when zoomed out", () => {
const waypoint = {
name: "",
position: { lat: 0, lng: 0 },
altitude_ft: 0,
altitude_reference: "MSL",
is_movable: false,
should_mark: false,
include_in_path: true,
timing: "",
};
const map = React.createRef<Map>();
const marker = React.createRef<Marker>();
renderWithProviders(
<MapContainer zoom={0} ref={map}>
<WaypointMarker
number={0}
waypoint={waypoint}
flight={{
id: "",
blue: true,
sidc: "",
waypoints: [waypoint],
}}
ref={marker}
/>
</MapContainer>
);
map.current?.setView({ lat: 0, lng: 0 }, TOOLTIP_ZOOM_LEVEL - 1);
expect(marker.current?.getTooltip()?.isOpen()).toBeFalsy();
});
it("tooltip is shown when zoomed in", () => {
const waypoint = {
name: "",
position: { lat: 0, lng: 0 },
altitude_ft: 0,
altitude_reference: "MSL",
is_movable: false,
should_mark: false,
include_in_path: true,
timing: "",
};
const map = React.createRef<Map>();
const marker = React.createRef<Marker>();
renderWithProviders(
<MapContainer ref={map}>
<WaypointMarker
number={0}
waypoint={waypoint}
flight={{
id: "",
blue: true,
sidc: "",
waypoints: [waypoint],
}}
ref={marker}
/>
</MapContainer>
);
map.current?.setView({ lat: 0, lng: 0 }, TOOLTIP_ZOOM_LEVEL);
expect(marker.current?.getTooltip()?.isOpen()).toBeTruthy();
});
it("tooltip has correct contents", () => {
const waypoint = {
name: "",
position: { lat: 0, lng: 0 },
altitude_ft: 25000,
altitude_reference: "MSL",
is_movable: false,
should_mark: false,
include_in_path: true,
timing: "09:00:00",
};
const map = React.createRef<Map>();
const marker = React.createRef<Marker>();
renderWithProviders(
<MapContainer ref={map}>
<WaypointMarker
number={0}
waypoint={waypoint}
flight={{
id: "",
blue: true,
sidc: "",
waypoints: [waypoint],
}}
ref={marker}
/>
</MapContainer>
);
expect(marker.current?.getTooltip()?.getContent()).toEqual(
"0 <br />25000 ft MSL<br />09:00:00"
);
});
it("resets the tooltip while dragging", () => {
const waypoint = {
name: "",
position: { lat: 0, lng: 0 },
altitude_ft: 25000,
altitude_reference: "MSL",
is_movable: false,
should_mark: false,
include_in_path: true,
timing: "09:00:00",
};
const marker = React.createRef<Marker>();
renderWithProviders(
<MapContainer>
<WaypointMarker
number={0}
waypoint={waypoint}
flight={{
id: "",
blue: true,
sidc: "",
waypoints: [waypoint],
}}
ref={marker}
/>
</MapContainer>
);
marker.current?.fireEvent("dragstart");
expect(marker.current?.getTooltip()?.getContent()).toEqual(
"Waiting to recompute TOT..."
);
});
it("sends the new position to the backend on dragend", async () => {
const departure = {
name: "",
position: { lat: 0, lng: 0 },
altitude_ft: 25000,
altitude_reference: "MSL",
is_movable: false,
should_mark: false,
include_in_path: true,
timing: "09:00:00",
};
const waypoint = {
name: "",
position: { lat: 1, lng: 1 },
altitude_ft: 25000,
altitude_reference: "MSL",
is_movable: false,
should_mark: false,
include_in_path: true,
timing: "09:00:00",
};
const flight = {
id: "1234",
blue: true,
sidc: "",
waypoints: [departure, waypoint],
};
const marker = React.createRef<Marker>();
// There is no observable UI change from moving a waypoint, just a message
// to the backend to record the frontend change. The real backend will then
// push an updated game state which will update redux, but that's not part
// of this component's behavior.
const pendingRequest = waitForRequest(
"POST",
`${HTTP_URL}/waypoints/1234/1/position`
);
renderWithProviders(
<MapContainer>
<WaypointMarker number={0} waypoint={departure} flight={flight} />
<WaypointMarker
number={1}
waypoint={waypoint}
flight={flight}
ref={marker}
/>
</MapContainer>
);
marker.current?.fireEvent("dragstart");
marker.current?.fireEvent("dragend", { target: marker.current });
const request = await pendingRequest;
const response = await request.json();
expect(response).toEqual({ lat: 1, lng: 1 });
});
});

View File

@@ -3,13 +3,23 @@ import {
Waypoint,
useSetWaypointPositionMutation,
} from "../../api/liberationApi";
import mergeRefs from "../../mergeRefs";
import { Icon } from "leaflet";
import { Marker as LMarker } from "leaflet";
import icon from "leaflet/dist/images/marker-icon.png";
import iconShadow from "leaflet/dist/images/marker-shadow.png";
import { MutableRefObject, useCallback, useEffect, useRef } from "react";
import {
ForwardedRef,
MutableRefObject,
forwardRef,
useCallback,
useEffect,
useRef,
} from "react";
import { Marker, Tooltip, useMap, useMapEvent } from "react-leaflet";
export const TOOLTIP_ZOOM_LEVEL = 9;
const WAYPOINT_ICON = new Icon({
iconUrl: icon,
shadowUrl: iconShadow,
@@ -22,84 +32,84 @@ interface WaypointMarkerProps {
flight: Flight;
}
const WaypointMarker = (props: WaypointMarkerProps) => {
// Most props of react-leaflet types are immutable and components will not
// update to account for changes, so we can't simply use the `permanent`
// property of the tooltip to control tooltip visibility based on the zoom
// level.
//
// On top of that, listening for zoom changes and opening/closing is not
// sufficient because clicking anywhere will close any opened tooltips (even
// if they are permanent; once openTooltip has been called that seems to no
// longer have any effect).
//
// Instead, listen for zoom changes and rebind the tooltip when the zoom level
// changes.
const map = useMap();
const marker: MutableRefObject<LMarker | undefined> = useRef();
const WaypointMarker = forwardRef(
(props: WaypointMarkerProps, ref: ForwardedRef<LMarker>) => {
// Most props of react-leaflet types are immutable and components will not
// update to account for changes, so we can't simply use the `permanent`
// property of the tooltip to control tooltip visibility based on the zoom
// level.
//
// On top of that, listening for zoom changes and opening/closing is not
// sufficient because clicking anywhere will close any opened tooltips (even
// if they are permanent; once openTooltip has been called that seems to no
// longer have any effect).
//
// Instead, listen for zoom changes and rebind the tooltip when the zoom level
// changes.
const map = useMap();
const marker: MutableRefObject<LMarker | null> = useRef(null);
const [putDestination] = useSetWaypointPositionMutation();
const [putDestination] = useSetWaypointPositionMutation();
const rebindTooltip = useCallback(() => {
if (marker.current === undefined) {
return;
}
const rebindTooltip = useCallback(() => {
if (marker.current === null) {
return;
}
const tooltip = marker.current.getTooltip();
if (tooltip === undefined) {
return;
}
const tooltip = marker.current.getTooltip();
if (tooltip === undefined) {
return;
}
const permanent = map.getZoom() >= 9;
marker.current
.unbindTooltip()
.bindTooltip(tooltip, { permanent: permanent });
}, [map]);
useMapEvent("zoomend", rebindTooltip);
const permanent = map.getZoom() >= TOOLTIP_ZOOM_LEVEL;
marker.current
.unbindTooltip()
.bindTooltip(tooltip, { permanent: permanent });
}, [map]);
useMapEvent("zoomend", rebindTooltip);
useEffect(() => {
const waypoint = props.waypoint;
marker.current?.setTooltipContent(
`${props.number} ${waypoint.name}<br />` +
`${waypoint.altitude_ft.toFixed()} ft ${
waypoint.altitude_reference
}<br />` +
waypoint.timing
);
});
useEffect(() => {
const waypoint = props.waypoint;
marker.current?.setTooltipContent(
`${props.number} ${waypoint.name}<br />` +
`${waypoint.altitude_ft.toFixed()} ft ${waypoint.altitude_reference}<br />` +
waypoint.timing
return (
<Marker
position={waypoint.position}
icon={WAYPOINT_ICON}
draggable
eventHandlers={{
dragstart: (e) => {
const m: LMarker = e.target;
m.setTooltipContent("Waiting to recompute TOT...");
},
dragend: async (e) => {
const m: LMarker = e.target;
const destination = m.getLatLng();
try {
await putDestination({
flightId: props.flight.id,
waypointIdx: props.number,
leafletPoint: { lat: destination.lat, lng: destination.lng },
});
} catch (e) {
console.error("Failed to set waypoint position", e);
}
},
}}
ref={mergeRefs(ref, marker)}
>
<Tooltip position={waypoint.position} />
</Marker>
);
});
const waypoint = props.waypoint;
return (
<Marker
position={waypoint.position}
icon={WAYPOINT_ICON}
draggable
eventHandlers={{
dragstart: (e) => {
const m: LMarker = e.target;
m.setTooltipContent("Waiting to recompute TOT...");
},
dragend: async (e) => {
const m: LMarker = e.target;
const destination = m.getLatLng();
try {
await putDestination({
flightId: props.flight.id,
waypointIdx: props.number,
leafletPoint: { lat: destination.lat, lng: destination.lng },
});
} catch (e) {
console.error("Failed to set waypoint position", e);
}
},
}}
ref={(ref) => {
if (ref != null) {
marker.current = ref;
}
}}
>
<Tooltip position={waypoint.position} />
</Marker>
);
};
}
);
export default WaypointMarker;

View File

@@ -1,5 +1,5 @@
import App from "./App";
import { store } from "./app/store";
import { setupStore } from "./app/store";
import { SocketProvider } from "./components/socketprovider/socketprovider";
import "./index.css";
import * as serviceWorker from "./serviceWorker";
@@ -12,7 +12,7 @@ const root = ReactDOM.createRoot(
);
root.render(
<React.StrictMode>
<Provider store={store}>
<Provider store={setupStore()}>
<SocketProvider>
<App />
</SocketProvider>

View File

@@ -0,0 +1,17 @@
import mergeRefs from "./mergeRefs";
describe("mergeRefs", () => {
it("merges all kinds of refs", () => {
const referent = "foobar";
const ref = { current: null };
var callbackResult = null;
const callbackRef = (node: string | null) => {
if (node != null) {
callbackResult = node;
}
};
mergeRefs(ref, callbackRef)(referent);
expect(callbackResult).toEqual("foobar");
expect(ref.current).toEqual("foobar");
});
});

16
client/src/mergeRefs.ts Normal file
View File

@@ -0,0 +1,16 @@
import { ForwardedRef } from "react";
const mergeRefs = <T extends any>(...refs: ForwardedRef<T>[]) => {
return (node: T) => {
for (const ref of refs) {
if (ref == null) {
} else if (typeof ref === "function") {
ref(node);
} else {
ref.current = node;
}
}
};
};
export default mergeRefs;

View File

@@ -0,0 +1,30 @@
// https://redux.js.org/usage/writing-tests
import { setupStore } from "../app/store";
import type { AppStore, RootState } from "../app/store";
import type { PreloadedState } from "@reduxjs/toolkit";
import { render } from "@testing-library/react";
import type { RenderOptions } from "@testing-library/react";
import React, { PropsWithChildren } from "react";
import { Provider } from "react-redux";
// This type interface extends the default options for render from RTL, as well
// as allows the user to specify other things such as initialState, store.
interface ExtendedRenderOptions extends Omit<RenderOptions, "queries"> {
preloadedState?: PreloadedState<RootState>;
store?: AppStore;
}
export function renderWithProviders(
ui: React.ReactElement,
{
preloadedState = {},
// Automatically create a store instance if no store was passed in
store = setupStore(preloadedState),
...renderOptions
}: ExtendedRenderOptions = {}
) {
function Wrapper({ children }: PropsWithChildren<{}>): JSX.Element {
return <Provider store={store}>{children}</Provider>;
}
return { store, ...render(ui, { wrapper: Wrapper, ...renderOptions }) };
}

8
codecov.yaml Normal file
View File

@@ -0,0 +1,8 @@
coverage:
status:
patch:
default:
informational: true
project:
default:
informational: true

20
docs/Makefile Normal file
View File

@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#
# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build
# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
.PHONY: help Makefile
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

34
docs/conf.py Normal file
View File

@@ -0,0 +1,34 @@
# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
project = "DCS Liberation"
copyright = "2023, DCS Liberation Team"
author = "DCS Liberation Team"
release = "10.0.0"
# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
extensions = [
"myst_parser",
"sphinx_rtd_theme",
"sphinx.ext.autosectionlabel",
"sphinx.ext.todo",
]
templates_path = ["_templates"]
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
html_theme = "sphinx_rtd_theme"
html_static_path = ["_static"]
todo_include_todos = True

View File

@@ -0,0 +1,8 @@
Design docs
===========
.. toctree::
:maxdepth: 2
:caption: Contents:
turnless.md

8
docs/dev/index.rst Normal file
View File

@@ -0,0 +1,8 @@
Developer documentation
=======================
.. toctree::
:maxdepth: 2
:caption: Contents:
design/index.rst

6
docs/game/index.rst Normal file
View File

@@ -0,0 +1,6 @@
Manual
======
.. toctree::
:maxdepth: 2
:caption: Contents:

16
docs/index.rst Normal file
View File

@@ -0,0 +1,16 @@
DCS Liberation
==============
.. toctree::
:maxdepth: 2
:caption: Contents:
game/index.rst
modding/index.rst
dev/index.rst
Indices and tables
==================
* :ref:`genindex`
* :ref:`search`

35
docs/make.bat Normal file
View File

@@ -0,0 +1,35 @@
@ECHO OFF
pushd %~dp0
REM Command file for Sphinx documentation
if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=.
set BUILDDIR=_build
%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.https://www.sphinx-doc.org/
exit /b 1
)
if "%1" == "" goto help
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end
:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
:end
popd

View File

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

View File

Before

Width:  |  Height:  |  Size: 57 KiB

After

Width:  |  Height:  |  Size: 57 KiB

View File

Before

Width:  |  Height:  |  Size: 54 KiB

After

Width:  |  Height:  |  Size: 54 KiB

10
docs/modding/index.rst Normal file
View File

@@ -0,0 +1,10 @@
Modding guide
=============
.. toctree::
:maxdepth: 2
:caption: Contents:
fuel-consumption-measurement.md
layouts.rst
weather.rst

397
docs/modding/layouts.rst Normal file
View File

@@ -0,0 +1,397 @@
The Layout System
=================
.. note::
The documentation of the layout system is still WIP and not
complete as the development of this feature involves a major refactoring
of the base code. Therefore this documentation is currently used for
development purpose primarily. The documentation will be updated soon.
Any help in updating this wiki page is appreciated!
The Layout System is a new way of defining how ground objects like SAM
Sites or other Vehicle / Ship Groups will be generated (which type of
units, how many units, alignment and orientation). It is a complete
rework of the previous generator-based logic which was written in python
code. The new system allows to define layouts with easy to write yaml
code and the use of the DCS Mission Editor for easier placement of the
units. The layout system also introduced a new logical grouping of Units
and layouts for them, the Armed Forces, which will allow major
improvements to the Ground Warfare in upcoming features.
**Armed Forces**
The Armed Forces is a new system introduced with the layout system which will
allow to identitfy and group possible units from the faction together with
available layouts for these groups. It is comparable to the AirWing and Squadron
implementation but just for Ground and Naval Forces. All possible Force Groups
(grouping of 1 or more units and and the available layouts for them) will be
generated during campaign initialization and will be used later by many
different systems. A Force Group can also include static objects which was not
possible before the introduction of the layout system. It is also possible to
define presets of these Force Groups within the faction file which is handy for
more complex groups like a SA-10 Battery or similar. Example: `SA-10.yaml`_.
which includes all the units like SR, TR, LN and has the layout of a
`S-300_Site.yaml`_.
.. _SA-10.yaml: https://github.com/dcs-liberation/dcs_liberation/blob/develop/resources/groups/SA-10.yaml
.. _S-300_Site.yaml: https://github.com/dcs-liberation/dcs_liberation/blob/develop/resources/layouts/anti_air/S-300_Site.yaml
**The Layout System**
In the previous system the generator which created the ground object was written
in python which made modifications and reusability very complicated. To allow
easier handling of the layouts and decoupling of alignment of units and the
actual unit type (for example Ural-375) the layout system was introduced.
Previously we had a generator for every different SAM Site, now we can just
reuse the alignemnt (e.g. 6 Launchers in a circle alignment) for multiple SAM
Systems and introduce more variety.
This new System allows Users and Designers to easily create or modify
layouts as the new alginment and orientation of units is defined with
the DCS Mission editor. An additional .yaml file allows the
configuration of the layout with settings like allow unit types or
random amounts of units. In total the new system reduces the complexity
and allows to precisely align / orient units as needed and create
realistic looking ground units.
As the whole ground unit generation and handling was reworked it is now
also possible to add static units to a ground object, so even
Fortifcation or similar can be added to templates in the future.
General Concept
~~~~~~~~~~~~~~~
.. figure:: images/layouts.png
:alt: Overview
Overview
All possible Force Groups will be generated during campaign
initialization by checking all possible units for the specific faction
and all available layouts. The code will automatically match general
layouts with available units. It is also possible to define preset
groups within the faction files which group many units and the prefered
layouts for the group. This is especially handy for unique layouts which
are not defined as ``global``. For example complex sam sites like the
S-300 or Patriot which have very specific alignment of the different
units.
Layouts will be matched to units based on the special definition given
in the corresponding yaml file. For example a layout which is defined as
global and allows the unit_class SHORAD will automatically be used for
all available SHORAD units which are defined in the faction file.
.. todo:: Describe the optional flag.
All these generated ForceGroups will be managed by the ArmedForces class
of the specific coalition. This class will be used by other parts of the
system like the start_generator or the BuyMenu. The ArmedForces class
will then generate the TheaterGroundObject which will be used by
liberation.
Example for a customized Ground Object Buy Menu which makes use of
Templates and UnitGroups:
.. figure:: images/ground_object_buy_menu.png
:alt: Ground object buy menu
Ground object buy menu
How to modify or add layouts
----------------------------
.. warning::
Whenever changes were made to layouts they have to be re-imported into
Liberation. See :ref:`Import Layouts into Liberation`.
A layout consists of two special files:
- layout.miz which defines the actual positioning and alignment of the
groups / units
- layout.yaml which defines the necessary information like amount of
units, possible types or classes.
To add a new template a new yaml has to be created as every yaml can
only define exact one template. Best practice is to copy paste an
existing template which is similar to the one to be created as starting
point. The next step is to create a new .miz file and align Units and
statics to the wishes. Even if existing ones can be reused, best
practice is to always create a fresh one to prevent side effects. The
most important part is to use a new Group for every different Unit Type.
It is not possible to mix Unit Types in one group within a template. For
example it is not possible to have a logistic truck and a AAA in the
same group. The miz file will only be used to get the exact position and
orientation of the units, therefore it is irrelevant which type of unit
will be used. The unit type will be later defined inside the yaml file.
For the next step all Group names have to be added to the yaml file.
Take care to that these names match exactly! Assign the unit_types or
unit_classes properties to math the needs.
The Layout miz
~~~~~~~~~~~~~~
The miz file is used to define the positioning and orientation of the
different units for the template. The actual unit which is used is
irrelevant. It is important to use a unique and meaningful name for the
groups as this will be used in the yaml file as well. The information
which will be extracted from the miz file are just the coordinates and
heading of the units.
*Important*: Every different unit type has to be in a separate Group for
the template to work. You can not add units of different types to the
same group. They can get merged back together during generation by
setting the group property. In the example below both groups
``AAA Site 0`` and ``AAA Site 1`` have the group = 1 which means that
they will be in the same dcs group during generation.
*Important*: Liberation expects every template to be designed with an
orientation of heading 0 (North) in mind. The complete GroundObject will
during the campaign generation process be rotated to match the
orientation defined by the campaign designer. If the layout was not
created with an orientation of heading 0 the later generated
GroundObject will likely be misaligned and not work properly.
.. todo::
max amount of possible units is defined from the miz. Example if later the
group should have 6 units than there have to be 6 defined in the miz.
.. figure:: images/layout_miz_example.png
:alt: Example template mission
Example template mission
The Layout configuration file
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. todo:: Description about the layout yaml file.
Possible Information:
.. list-table::
:header-rows: 1
* - Property
- Type
- Required
- Description
- Example
* - name
- ``str``
- Yes
- A name to identify the template
- .. code:: yaml
name: Armor Group
* - tasks
- list of ``GroupTask``
- Yes
- A list of tasks which the template can fulfill
- .. code:: yaml
tasks:
- AAA
- SHORAD
* - generic
- ``bool``, default false
- No
- True if this template will be used to create general ``UnitGroups``
-
* - description
- ``str``
- No
- Short description of the template
-
* - groups
- List of ``Groups``
- Yes
- See below for definition of a group
-
* - layout_file
- ``str``
- No
- The .miz file which has the groups/units of the layout included. Only
needed if the file has a different name than the yaml file
- .. code:: yaml
layout_file: resources/layouts/naval/legacy_naval_templates.miz
.. todo:: Group and SubGroup
A group has 1..N sub groups. The name of the Group will be used later
within the DCS group name.
All SubGroups will be merged into one DCS Group
Every unit type has to be defined as a sub group as following:
.. list-table::
:header-rows: 1
* - Property
- Type
- Required
- Description
* - name
- ``str``
- Yes
- The group name used in the .miz. Must match exactly!
* - optional
- ``bool``, default: false
- No
- Defines wether the layout can be used without this group if the faction
has no access to the unit type or the user wants to disable this group
* - fill
- ``bool``, default: false
- No
- If the group is optional the layout is used from a PresetGroup this
property tells the system if it should use any possible faction
accessible unit to fill up this slot if no capable one was defined in
the preset yaml.
* - unit_count
- list of ``int``
- No
- Amount of units to be generated for this group. Can be fixed or a range
where it will be picked randomly
* - unit_types
- list of DCS unit type IDs
- No
- Specific unit_types for ground units. Complete list from `vehicles.py`_.
This list is extended by all supported mods!
* - unit_classes
- list of unit classes
- No
- Unit classes of supported units. Defined by ``UnitClass`` in
`game/data/units.py`_.
* - statics
- list of static types
- No
- Specific unit_types of statics. Complete list from `statics.py`_
.. _vehicles.py: https://github.com/pydcs/dcs/blob/master/dcs/vehicles.py
.. _game/data/units.py: https://github.com/dcs-liberation/dcs_liberation/blob/develop/game/data/units.py
.. _statics.py: https://github.com/pydcs/dcs/blob/master/dcs/statics.py
Complete example of a generic template for an Aircraft Carrier group:
.. code:: yaml
name: Carrier Group
generic: true
tasks:
- AircraftCarrier
groups:
- Carrier: # Group Name of the DCS Group
- name: Carrier Group 0 # Sub Group used in the layout.miz
unit_count:
- 1
unit_classes:
- AircraftCarrier
- Escort: # Group name of the 2nd Group
- name: Carrier Group 1
unit_count:
- 4
unit_classes:
- Destroyer
layout_file: resources/layouts/naval/legacy_naval_templates.miz
Import Layouts into Liberation
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
For performance improvements all layouts are serialized to a so called
pickle file inside the save folder defined in the liberation
preferences. Every time changes are made to the layouts this file has to
be recreated. It can be recreated by either deleting the layouts.p file
manually or using the special option in the Liberation Toolbar
(Developer Tools -> Import Layouts). It will also be recreated after
each Liberation update as it will check the Version Number and recreate
it when changes are recognized.
Migration from Generators
-------------------------
The previous generators were migrated using a script which build a group using
the generator. All of these groups were save into one .miz file
`original_generator_layouts.miz`_. This miz file can be used to verify the
templates and to generalize similar templates to decouple the layout from the
actual units. As this is a time-consuming and sphisticated task this will be
done over time. With the first step the technical requirements will be fulfilled
so that the generalization can happen afterwards the technical pr gets merged.
.. _original_generator_layouts.miz: https://github.com/dcs-liberation/dcs_liberation/blob/develop/resources/layouts/original_generator_layouts.miz
Updates for Factions
~~~~~~~~~~~~~~~~~~~~
With the rework there were also some changes to the faction file
definitions. Older faction files can not be loaded anymore and have to
be adopted to the new changes. During migration all default factions
were automatically updated, so they will work out of the box.
You can find more detailed information about how to customize the
faction file in `Custom factions`_.
What was changed:
* Removed the ``ewrs`` list. All EWRs are now defined in the list
``air_defense_units``.
* Added the ``air_defense_units`` list. All units with the Role AntiAir can be
defined here as `GroundUnitType`_. All possible units are defined in
`resources/units/ground_units`_.
* Added ``preset_groups``. This list allows to define Preset Groups (described
above) like SAM Systems consisting of Launcher, SR, TR and so on instead of
adding them each to “air_defense_units”. The presets are defined in
`resources/groups`_
* Migrated ``air_defenses`` to air_defense_units and preset_sets.
* ``Missiles`` are migrated to GroundUnitTypes instead of Generator names (see
air_defense_units for how to use)
* Removed ``cruisers``, ``destroyers`` and ``naval_generators``. Migrated them
to naval_units and preset_groups
* Added ``naval_units`` with the correct ship name found in
`resources/units/ships`_.
* ``aircraft_carrier`` and ``helicopter_carrier`` were moved to ``naval_units``
as well.
.. _Custom factions: https://github.com/dcs-liberation/dcs_liberation/wiki/Custom-Factions
.. _GroundUnitType: https://github.com/dcs-liberation/dcs_liberation/blob/develop/game/dcs/groundunittype.py
.. _resources/units/ground_units: https://github.com/dcs-liberation/dcs_liberation/blob/develop/resources/units/ground_units
.. _resources/units/ships: https://github.com/dcs-liberation/dcs_liberation/blob/develop/resources/units/ships
.. _resources/groups: https://github.com/dcs-liberation/dcs_liberation/blob/develop/resources/groups
Preset Groups
-------------
Instead of adding the exact name of the previous generator to add
complex groups like SAM sites or similar to the faction it is now
possible to add preset groups to the faction file. As described earlier
such a preset group (Force Group) can be defined very easy with a yaml
file. This file allows to define the name, tasking, units, statics and
the prefered layouts. The first task defines the primary role of the
ForceGroup which gets generated from the preset.
Example:
.. code:: yaml
name: SA-10/S-300PS # The name of the group
tasks: # Define at least 1 task
- LORAD # The task(s) the Group can fulfill
units: # Define at least 1 unit
- SAM SA-10 S-300 "Grumble" Clam Shell SR
- SAM SA-10 S-300 "Grumble" Big Bird SR
- SAM SA-10 S-300 "Grumble" C2
- SAM SA-10 S-300 "Grumble" Flap Lid TR
- SAM SA-10 S-300 "Grumble" TEL D
- SAM SA-10 S-300 "Grumble" TEL C
statics: # Optional
- # Add some statics here
layouts: # Define at least one layout
- S-300 Site # prefered layouts for these groups
Resources:
* A list of all available preset groups can be found here: `resources/groups`_
* All possible tasks can be found in the `game/data/groups.py`_
* Units are defined with the variant name found in `resources/units`_
.. _game/data/groups.py: https://github.com/dcs-liberation/dcs_liberation/blob/develop/game/data/groups.py
.. _resources/units: https://github.com/dcs-liberation/dcs_liberation/tree/develop/resources/units

76
docs/modding/weather.rst Normal file
View File

@@ -0,0 +1,76 @@
#######
Weather
#######
Weather conditions in DCS Liberation are randomly generated at the start of each
turn. Some of the inputs to that generator (more to come) can be controlled via
the config files in ``resources/weather``.
**********
Archetypes
**********
A weather archetype defines the the conditions for a style of weather, such as
"clear", or "raining". There are currently four archetypes:
1. clear
2. cloudy
3. raining
4. thunderstorm
The odds of each archetype appearing in each season are defined in the theater
yaml files (``resources/theaters/*/info.yaml``).
.. literalinclude:: ../../resources/weather/archetypes/clear.yaml
:language: yaml
:linenos:
:caption: resources/weather/archetypes/clear.yaml
Wind speeds
===========
DCS missions define wind with a speed and heading at each of three altitudes:
1. MSL
2. 2000 meters
3. 8000 meters
Blending between each altitude band is done in a manner defined by DCS.
Liberation randomly generates a direction for the wind at MSL, and each other
altitude band will have wind within +/- 90 degrees of that heading.
Wind speeds can be modded by altering the ``speed`` dict in the archetype yaml.
The only random distribution currently supported is the Weibull distribution, so
all archetypes currently use:
.. code:: yaml
speed:
weibull:
...
The Weibull distribution has two parameters: a shape and a scale.
The scale is simplest to understand. 63.2% of all outcomes of the distribution
are below the scale parameter.
The shape controls where the peak of the distribution is. See the examples in
the links below for illustrations and guidelines, but generally speaking low
values (between 1 and 2.6) will cause low speeds to be more common, medium
values (around 3) will be fairly evenly distributed around the median, and high
values (greater than 3.7) will cause high speeds to be more common. As wind
speeds tend to be higher at higher altitudes and fairly slow close to the
ground, you typically want a low value for MSL, a medium value for 2000m, and a
high value for 8000m.
For examples, see https://statisticsbyjim.com/probability/weibull-distribution/.
To experiment with different inputs, use Wolfram Alpha, e.g.
https://www.wolframalpha.com/input?i=weibull+distribution+1.5+5.
When generating wind speeds, each subsequent altitude band will have the lower
band's speed added to its scale parameter. That is, for the example above, the
actual scale parameter of ``at_2000m`` will be ``20 + wind speed at MSL``, and
the scale parameter of ``at_8000m`` will be ``20 + wind speed at 2000m``. This
is to ensure that a generally windy day (high wind speed at MSL) will create
similarly high winds at higher altitudes and vice versa.

2
docs/requirements.txt Normal file
View File

@@ -0,0 +1,2 @@
myst-parser
sphinx_rtd_theme

View File

@@ -10,19 +10,18 @@ import yaml
from dcs.unittype import ShipType, StaticType, UnitType as DcsUnitType, VehicleType
from game.data.groups import GroupTask
from game.data.radar_db import UNITS_WITH_RADAR
from game.dcs.groundunittype import GroundUnitType
from game.dcs.helpers import static_type_from_name
from game.dcs.shipunittype import ShipUnitType
from game.dcs.unittype import UnitType
from game.layout import LAYOUTS
from game.layout.layout import TgoLayout, TgoLayoutUnitGroup
from game.point_with_heading import PointWithHeading
from game.theater.theatergroundobject import (
IadsGroundObject,
IadsBuildingGroundObject,
NavalGroundObject,
)
from game.layout import LAYOUTS
from game.layout.layout import TgoLayout, TgoLayoutUnitGroup
from game.point_with_heading import PointWithHeading
from game.theater.theatergroup import IadsGroundGroup, IadsRole, TheaterGroup
from game.utils import escape_string_for_lua
@@ -288,7 +287,7 @@ class ForceGroup:
unit.id = game.next_unit_id()
# Add unit name escaped so that we do not have scripting issues later
unit.name = escape_string_for_lua(
unit.unit_type.name if unit.unit_type else unit.type.name
unit.unit_type.variant_id if unit.unit_type else unit.type.name
)
unit.position = PointWithHeading.from_point(
ground_object.position + unit.position,

View File

@@ -1,627 +0,0 @@
import logging
from collections.abc import Sequence
from typing import Type
from dcs.helicopters import (
AH_1W,
AH_64A,
AH_64D,
AH_64D_BLK_II,
CH_47D,
CH_53E,
Ka_50,
Mi_24P,
Mi_24V,
Mi_26,
Mi_28N,
Mi_8MT,
OH_58D,
SA342L,
SA342M,
SH_60B,
UH_1H,
UH_60A,
)
from dcs.planes import (
AJS37,
AV8BNA,
A_10A,
A_10C,
A_10C_2,
A_20G,
A_50,
An_26B,
B_17G,
B_1B,
B_52H,
Bf_109K_4,
C_101CC,
C_130,
C_17A,
E_2C,
E_3A,
FA_18C_hornet,
FW_190A8,
FW_190D9,
F_117A,
F_14A_135_GR,
F_14B,
F_15C,
F_15E,
F_16A,
F_16C_50,
F_4E,
F_5E_3,
F_86F_Sabre,
H_6J,
IL_76MD,
IL_78M,
I_16,
JF_17,
J_11A,
Ju_88A4,
KC130,
KC135MPRS,
KC_135,
KJ_2000,
L_39ZA,
MB_339A,
MQ_9_Reaper,
M_2000C,
MiG_15bis,
MiG_19P,
MiG_21Bis,
MiG_23MLD,
MiG_25PD,
MiG_27K,
MiG_29A,
MiG_29G,
MiG_29S,
MiG_31,
Mirage_2000_5,
Mirage_F1B,
Mirage_F1BE,
Mirage_F1CE,
Mirage_F1CT,
Mirage_F1C_200,
Mirage_F1EE,
Mirage_F1EQ,
Mirage_F1M_CE,
Mirage_F1M_EE,
MosquitoFBMkVI,
P_47D_30,
P_47D_30bl1,
P_47D_40,
P_51D,
P_51D_30_NA,
RQ_1A_Predator,
S_3B,
S_3B_Tanker,
SpitfireLFMkIX,
SpitfireLFMkIXCW,
Su_17M4,
Su_24M,
Su_25,
Su_25T,
Su_25TM,
Su_27,
Su_30,
Su_33,
Su_34,
Tornado_GR4,
Tornado_IDS,
Tu_142,
Tu_160,
Tu_22M3,
Tu_95MS,
WingLoong_I,
Yak_40,
)
from dcs.unittype import FlyingType
from game.dcs.aircrafttype import AircraftType
from pydcs_extensions.a4ec.a4ec import A_4E_C
from pydcs_extensions.f104.f104 import VSN_F104G, VSN_F104S, VSN_F104S_AG
from pydcs_extensions.f22a.f22a import F_22A
from pydcs_extensions.hercules.hercules import Hercules
from pydcs_extensions.jas39.jas39 import JAS39Gripen, JAS39Gripen_AG
from pydcs_extensions.ov10a.ov10a import Bronco_OV_10A
from pydcs_extensions.su57.su57 import Su_57
from pydcs_extensions.uh60l.uh60l import KC130J, UH_60L
from .flighttype import FlightType
# All aircraft lists are in priority order. Aircraft higher in the list will be
# preferred over those lower in the list.
# TODO: These lists really ought to be era (faction) dependent.
# Factions which have F-5s, F-86s, and A-4s will should prefer F-5s for CAP, but
# factions that also have F-4s should not.
# Used for CAP, Escort, and intercept if there is not a specialised aircraft available
CAP_CAPABLE = [
Su_57,
F_22A,
F_15C,
F_14B,
F_14A_135_GR,
Su_33,
J_11A,
Su_30,
Su_27,
MiG_29S,
F_16C_50,
FA_18C_hornet,
JF_17,
JAS39Gripen,
F_16A,
F_4E,
MiG_31,
MiG_25PD,
MiG_29G,
MiG_29A,
MiG_23MLD,
MiG_21Bis,
Mirage_2000_5,
Mirage_F1B,
Mirage_F1BE,
Mirage_F1CE,
Mirage_F1EE,
Mirage_F1EQ,
Mirage_F1M_CE,
Mirage_F1M_EE,
Mirage_F1C_200,
Mirage_F1CT,
F_15E,
M_2000C,
F_5E_3,
VSN_F104S,
VSN_F104G,
MiG_19P,
A_4E_C,
F_86F_Sabre,
MiG_15bis,
C_101CC,
L_39ZA,
P_51D_30_NA,
P_51D,
SpitfireLFMkIXCW,
SpitfireLFMkIX,
MosquitoFBMkVI,
Bf_109K_4,
FW_190D9,
FW_190A8,
P_47D_30,
P_47D_30bl1,
P_47D_40,
I_16,
]
# Used for CAS (Close air support) and BAI (Battlefield Interdiction)
CAS_CAPABLE = [
A_10C_2,
A_10C,
Hercules,
Su_34,
Su_25TM,
Su_25T,
Su_25,
F_15E,
F_16C_50,
FA_18C_hornet,
Tornado_GR4,
Tornado_IDS,
JAS39Gripen_AG,
JF_17,
AV8BNA,
A_10A,
B_1B,
A_4E_C,
Bronco_OV_10A,
F_14B,
F_14A_135_GR,
AJS37,
Su_24M,
Su_17M4,
Su_33,
F_4E,
S_3B,
Su_30,
MiG_29S,
MiG_27K,
MiG_29A,
MiG_21Bis,
AH_64D_BLK_II,
AH_64D,
AH_64A,
AH_1W,
OH_58D,
SA342M,
SA342L,
Ka_50,
Mi_28N,
Mi_24P,
Mi_24V,
Mi_8MT,
H_6J,
MiG_19P,
MiG_15bis,
M_2000C,
Mirage_F1B,
Mirage_F1BE,
Mirage_F1CE,
Mirage_F1EE,
Mirage_F1EQ,
Mirage_F1M_CE,
Mirage_F1M_EE,
Mirage_F1CT,
F_5E_3,
F_86F_Sabre,
MB_339A,
C_101CC,
L_39ZA,
UH_1H,
VSN_F104S_AG,
VSN_F104G,
A_20G,
Ju_88A4,
P_47D_40,
P_47D_30bl1,
P_47D_30,
P_51D_30_NA,
P_51D,
SpitfireLFMkIXCW,
SpitfireLFMkIX,
MosquitoFBMkVI,
I_16,
Bf_109K_4,
FW_190D9,
FW_190A8,
WingLoong_I,
MQ_9_Reaper,
RQ_1A_Predator,
]
# Aircraft used for SEAD and SEAD Escort tasks. Must be capable of the CAS DCS task.
SEAD_CAPABLE = [
JF_17,
F_16C_50,
FA_18C_hornet,
Tornado_IDS,
Su_25T,
Su_25TM,
F_4E,
A_4E_C,
F_14B,
F_14A_135_GR,
JAS39Gripen_AG,
AV8BNA,
Su_24M,
Su_17M4,
Su_34,
Su_30,
MiG_27K,
Tornado_GR4,
]
# Aircraft used for DEAD tasks. Must be capable of the CAS DCS task.
DEAD_CAPABLE = SEAD_CAPABLE + [
AJS37,
F_14B,
F_14A_135_GR,
JAS39Gripen_AG,
B_1B,
B_52H,
Tu_160,
Tu_95MS,
H_6J,
A_20G,
Ju_88A4,
VSN_F104S_AG,
VSN_F104G,
P_47D_40,
P_47D_30bl1,
P_47D_30,
P_51D_30_NA,
P_51D,
Bronco_OV_10A,
SpitfireLFMkIXCW,
SpitfireLFMkIX,
MosquitoFBMkVI,
Bf_109K_4,
FW_190D9,
FW_190A8,
]
# Aircraft used for Strike mission
STRIKE_CAPABLE = [
F_117A,
B_1B,
B_52H,
Tu_160,
Tu_95MS,
Tu_22M3,
H_6J,
F_15E,
AJS37,
Tornado_GR4,
F_16C_50,
FA_18C_hornet,
AV8BNA,
JF_17,
F_16A,
F_14B,
F_14A_135_GR,
JAS39Gripen_AG,
Tornado_IDS,
Su_17M4,
Su_24M,
Su_25TM,
Su_25T,
Su_25,
Su_34,
Su_33,
Su_30,
Su_27,
MiG_29S,
MiG_29G,
MiG_29A,
F_4E,
A_10C_2,
A_10C,
S_3B,
A_4E_C,
Bronco_OV_10A,
M_2000C,
Mirage_F1B,
Mirage_F1BE,
Mirage_F1CE,
Mirage_F1EE,
Mirage_F1EQ,
Mirage_F1M_CE,
Mirage_F1M_EE,
Mirage_F1CT,
MiG_27K,
MiG_21Bis,
MiG_15bis,
F_5E_3,
F_86F_Sabre,
MB_339A,
C_101CC,
L_39ZA,
B_17G,
A_20G,
Ju_88A4,
VSN_F104S_AG,
VSN_F104G,
P_47D_40,
P_47D_30bl1,
P_47D_30,
P_51D_30_NA,
P_51D,
SpitfireLFMkIXCW,
SpitfireLFMkIX,
MosquitoFBMkVI,
Bf_109K_4,
FW_190D9,
FW_190A8,
]
ANTISHIP_CAPABLE = [
AJS37,
Tu_142,
Tu_22M3,
H_6J,
FA_18C_hornet,
JAS39Gripen_AG,
Su_24M,
Su_17M4,
JF_17,
Su_34,
Su_30,
Tornado_IDS,
Tornado_GR4,
AV8BNA,
S_3B,
A_20G,
Ju_88A4,
MosquitoFBMkVI,
C_101CC,
SH_60B,
]
# This list does not "inherit" from the strike list because some strike aircraft can
# only carry guided weapons, and the AI cannot do runway attack with dguided weapons.
# https://github.com/dcs-liberation/dcs_liberation/issues/1703
RUNWAY_ATTACK_CAPABLE = [
JF_17,
Su_34,
Su_30,
Tornado_IDS,
M_2000C,
H_6J,
B_1B,
B_52H,
Tu_22M3,
H_6J,
F_15E,
AJS37,
F_16C_50,
FA_18C_hornet,
AV8BNA,
JF_17,
F_16A,
F_14B,
F_14A_135_GR,
JAS39Gripen_AG,
Tornado_IDS,
Su_17M4,
Su_24M,
Su_25TM,
Su_25T,
Su_25,
Su_34,
Su_33,
Su_30,
Su_27,
MiG_29S,
MiG_29G,
MiG_29A,
F_4E,
A_10C_2,
A_10C,
S_3B,
A_4E_C,
Bronco_OV_10A,
M_2000C,
Mirage_F1B,
Mirage_F1BE,
Mirage_F1CE,
Mirage_F1EE,
Mirage_F1EQ,
Mirage_F1M_CE,
Mirage_F1M_EE,
Mirage_F1CT,
MiG_27K,
MiG_21Bis,
MiG_15bis,
MB_339A,
F_5E_3,
F_86F_Sabre,
C_101CC,
L_39ZA,
B_17G,
A_20G,
Ju_88A4,
VSN_F104S_AG,
VSN_F104G,
P_47D_40,
P_47D_30bl1,
P_47D_30,
P_51D_30_NA,
P_51D,
SpitfireLFMkIXCW,
SpitfireLFMkIX,
MosquitoFBMkVI,
Bf_109K_4,
FW_190D9,
FW_190A8,
]
# For any aircraft that isn't necessarily directly involved in strike
# missions in a direct combat sense, but can transport objects and infantry.
TRANSPORT_CAPABLE = [
C_17A,
Hercules,
C_130,
IL_76MD,
An_26B,
Yak_40,
CH_53E,
CH_47D,
UH_60L,
SH_60B,
UH_60A,
UH_1H,
Mi_8MT,
Mi_8MT,
Mi_26,
]
AIR_ASSAULT_CAPABLE = [
CH_53E,
CH_47D,
UH_60L,
SH_60B,
UH_60A,
UH_1H,
Mi_8MT,
Mi_26,
Mi_24P,
Mi_24V,
Hercules,
]
DRONES = [MQ_9_Reaper, RQ_1A_Predator, WingLoong_I]
AEWC_CAPABLE = [
E_3A,
E_2C,
A_50,
KJ_2000,
]
# Priority is given to the tankers that can carry the most fuel.
REFUELING_CAPABALE = [
KC_135,
KC135MPRS,
IL_78M,
KC130J,
KC130,
S_3B_Tanker,
]
def dcs_types_for_task(task: FlightType) -> Sequence[Type[FlyingType]]:
cap_missions = (
FlightType.BARCAP,
FlightType.INTERCEPTION,
FlightType.SWEEP,
FlightType.TARCAP,
)
if task in cap_missions:
return CAP_CAPABLE
elif task == FlightType.ANTISHIP:
return ANTISHIP_CAPABLE
elif task == FlightType.BAI:
return CAS_CAPABLE
elif task == FlightType.CAS:
return CAS_CAPABLE
elif task == FlightType.SEAD:
return SEAD_CAPABLE
elif task == FlightType.SEAD_ESCORT:
return SEAD_CAPABLE
elif task == FlightType.DEAD:
return DEAD_CAPABLE
elif task == FlightType.OCA_AIRCRAFT:
return CAS_CAPABLE
elif task == FlightType.OCA_RUNWAY:
return RUNWAY_ATTACK_CAPABLE
elif task == FlightType.STRIKE:
return STRIKE_CAPABLE
elif task == FlightType.ESCORT:
return CAP_CAPABLE
elif task == FlightType.AEWC:
return AEWC_CAPABLE
elif task == FlightType.REFUELING:
return REFUELING_CAPABALE
elif task == FlightType.TRANSPORT:
return TRANSPORT_CAPABLE
elif task == FlightType.AIR_ASSAULT:
return AIR_ASSAULT_CAPABLE
else:
logging.error(f"Unplannable flight type: {task}")
return []
def aircraft_for_task(task: FlightType) -> list[AircraftType]:
dcs_types = dcs_types_for_task(task)
types: list[AircraftType] = []
for dcs_type in dcs_types:
types.extend(AircraftType.for_dcs_type(dcs_type))
return types
def tasks_for_aircraft(aircraft: AircraftType) -> list[FlightType]:
tasks: list[FlightType] = []
for task in FlightType:
if task is FlightType.FERRY:
# Not a plannable task, so skip it.
continue
if aircraft in aircraft_for_task(task):
tasks.append(task)
return tasks

View File

@@ -1,16 +1,17 @@
from __future__ import annotations
import uuid
from collections.abc import Iterator
from datetime import datetime, timedelta
from typing import Any, List, Optional, TYPE_CHECKING
from dcs import Point
from dcs.planes import C_101CC, C_101EB, Su_33
from .flightmembers import FlightMembers
from .flightroster import FlightRoster
from .flightstate import FlightState, Navigating, Uninitialized
from .flightstate.killed import Killed
from .loadouts import Loadout
from ..sidc import (
Entity,
SidcDescribable,
@@ -26,6 +27,8 @@ if TYPE_CHECKING:
from game.squadrons import Squadron, Pilot
from game.theater import ControlPoint
from game.transfers import TransferOrder
from game.data.weapons import WeaponType
from .flightmember import FlightMember
from .flightplans.flightplan import FlightPlan
from .flighttype import FlightType
from .flightwaypoint import FlightWaypoint
@@ -52,17 +55,16 @@ class Flight(SidcDescribable):
self.country = country
self.coalition = squadron.coalition
self.squadron = squadron
self.flight_type = flight_type
self.squadron.claim_inventory(count)
if roster is None:
self.roster = FlightRoster(self.squadron, initial_size=count)
self.roster = FlightMembers(self, initial_size=count)
else:
self.roster = roster
self.roster = FlightMembers.from_roster(self, roster)
self.divert = divert
self.flight_type = flight_type
self.loadout = Loadout.default_for(self)
self.start_type = start_type
self.use_custom_loadout = False
self.custom_name = custom_name
self.use_same_loadout_for_all_members = True
# Only used by transport missions.
self.cargo = cargo
@@ -95,6 +97,13 @@ class Flight(SidcDescribable):
self._flight_plan_builder = CustomBuilder(self, self.flight_plan.waypoints[1:])
self.recreate_flight_plan()
# We need to clear the existing actions/options when moving the waypoints into
# the new flight plan because the actions/options that are currently set will be
# the actions of whatever flight plan was previously used.
# https://github.com/dcs-liberation/dcs_liberation/issues/3189
for waypoint in self.flight_plan.iter_waypoints():
waypoint.actions.clear()
waypoint.options.clear()
def __getstate__(self) -> dict[str, Any]:
state = self.__dict__.copy()
@@ -149,10 +158,6 @@ class Flight(SidcDescribable):
def is_helo(self) -> bool:
return self.unit_type.dcs_unit_type.helicopter
@property
def from_cp(self) -> ControlPoint:
return self.departure
@property
def points(self) -> List[FlightWaypoint]:
return self.flight_plan.waypoints[1:]
@@ -171,6 +176,18 @@ class Flight(SidcDescribable):
def missing_pilots(self) -> int:
return self.roster.missing_pilots
def iter_members(self) -> Iterator[FlightMember]:
yield from self.roster.members
def set_flight_type(self, var: FlightType) -> None:
self.flight_type = var
# Update _flight_plan_builder so that the builder class remains relevant
# to the flight type
from .flightplans.flightplanbuildertypes import FlightPlanBuilderTypes
self._flight_plan_builder = FlightPlanBuilderTypes.for_flight(self)(self)
def return_pilots_and_aircraft(self) -> None:
self.roster.clear()
self.squadron.claim_inventory(-self.count)
@@ -187,6 +204,11 @@ class Flight(SidcDescribable):
return unit_type.fuel_max * 0.5
return None
def any_member_has_weapon_of_type(self, weapon_type: WeaponType) -> bool:
return any(
m.loadout.has_weapon_of_type(weapon_type) for m in self.iter_members()
)
def __repr__(self) -> str:
if self.custom_name:
return f"{self.custom_name} {self.count} x {self.unit_type}"
@@ -247,9 +269,9 @@ class Flight(SidcDescribable):
Killed(self.state.estimate_position(), self, self.squadron.settings)
)
events.update_flight(self)
for pilot in self.roster.pilots:
for pilot in self.roster.iter_pilots():
if pilot is not None:
results.kill_pilot(self, pilot)
def recreate_flight_plan(self) -> None:
self._flight_plan_builder.regenerate()
def recreate_flight_plan(self, dump_debug_info: bool = False) -> None:
self._flight_plan_builder.regenerate(dump_debug_info)

42
game/ato/flightmember.py Normal file
View File

@@ -0,0 +1,42 @@
from __future__ import annotations
from typing import TYPE_CHECKING
from game.ato.loadouts import Loadout
from game.lasercodes import LaserCode
if TYPE_CHECKING:
from game.squadrons import Pilot
class FlightMember:
def __init__(self, pilot: Pilot | None, loadout: Loadout) -> None:
self.pilot = pilot
self.loadout = loadout
self.use_custom_loadout = False
self.tgp_laser_code: LaserCode | None = None
self.weapon_laser_code: LaserCode | None = None
self.properties: dict[str, bool | float | int] = {}
def assign_tgp_laser_code(self, code: LaserCode) -> None:
if self.tgp_laser_code is not None:
raise RuntimeError(
f"{self.pilot} already has already been assigned laser code "
f"{self.tgp_laser_code}"
)
self.tgp_laser_code = code
def release_tgp_laser_code(self) -> None:
if self.tgp_laser_code is None:
raise RuntimeError(f"{self.pilot} has no assigned laser code")
if self.weapon_laser_code == self.tgp_laser_code:
self.weapon_laser_code = None
self.tgp_laser_code.release()
self.tgp_laser_code = None
@property
def is_player(self) -> bool:
if self.pilot is None:
return False
return self.pilot.player

91
game/ato/flightmembers.py Normal file
View File

@@ -0,0 +1,91 @@
from __future__ import annotations
from collections.abc import Iterator
from typing import Optional, TYPE_CHECKING
from .flightmember import FlightMember
from .flightroster import FlightRoster
from .iflightroster import IFlightRoster
from .loadouts import Loadout
if TYPE_CHECKING:
from game.squadrons import Pilot
from .flight import Flight
class FlightMembers(IFlightRoster):
def __init__(self, flight: Flight, initial_size: int = 0) -> None:
self.flight = flight
self.members: list[FlightMember] = []
self.resize(initial_size)
@staticmethod
def from_roster(flight: Flight, roster: FlightRoster) -> FlightMembers:
members = FlightMembers(flight)
loadout = Loadout.default_for(flight)
members.members = [FlightMember(p, loadout) for p in roster.pilots]
return members
def iter_pilots(self) -> Iterator[Pilot | None]:
yield from (m.pilot for m in self.members)
def pilot_at(self, idx: int) -> Pilot | None:
return self.members[idx].pilot
@property
def max_size(self) -> int:
return len(self.members)
@property
def player_count(self) -> int:
return len([m for m in self.members if m.is_player])
@property
def missing_pilots(self) -> int:
return len([m for m in self.members if m.pilot is None])
def resize(self, new_size: int) -> None:
if self.max_size > new_size:
for member in self.members[new_size:]:
if (pilot := member.pilot) is not None:
self.flight.squadron.return_pilot(pilot)
if (code := member.tgp_laser_code) is not None:
code.release()
self.members = self.members[:new_size]
return
if self.max_size:
loadout = self.members[0].loadout.clone()
else:
loadout = Loadout.default_for(self.flight)
for _ in range(new_size - self.max_size):
member = FlightMember(self.flight.squadron.claim_available_pilot(), loadout)
member.use_custom_loadout = loadout.is_custom
self.members.append(member)
def set_pilot(self, index: int, pilot: Optional[Pilot]) -> None:
if pilot is not None:
self.flight.squadron.claim_pilot(pilot)
if (current_pilot := self.pilot_at(index)) is not None:
self.flight.squadron.return_pilot(current_pilot)
self.members[index].pilot = pilot
def clear(self) -> None:
self.flight.squadron.return_pilots(
[p for p in self.iter_pilots() if p is not None]
)
for member in self.members:
if (code := member.tgp_laser_code) is not None:
code.release()
def use_same_loadout_for_all_members(self) -> None:
if not self.members:
return
loadout = self.members[0].loadout
for member in self.members[1:]:
# Do not clone the loadout, we want any changes in the UI to be mirrored
# across all flight members.
member.loadout = loadout
def use_distinct_loadouts_for_each_member(self) -> None:
for member in self.members:
member.loadout = member.loadout.clone()

View File

@@ -90,5 +90,5 @@ class Builder(IBuilder[AewcFlightPlan, PatrollingLayout]):
bullseye=builder.bullseye(),
)
def build(self) -> AewcFlightPlan:
def build(self, dump_debug_info: bool = False) -> AewcFlightPlan:
return AewcFlightPlan(self.flight, self.layout())

View File

@@ -1,7 +1,7 @@
from __future__ import annotations
from dataclasses import dataclass
from datetime import timedelta
from datetime import datetime
from typing import Iterator, TYPE_CHECKING, Type
from game.ato.flightplans.standard import StandardFlightPlan, StandardLayout
@@ -55,12 +55,12 @@ class AirAssaultFlightPlan(StandardFlightPlan[AirAssaultLayout], UiZoneDisplay):
def tot_waypoint(self) -> FlightWaypoint:
return self.layout.drop_off
def tot_for_waypoint(self, waypoint: FlightWaypoint) -> timedelta | None:
def tot_for_waypoint(self, waypoint: FlightWaypoint) -> datetime | None:
if waypoint == self.tot_waypoint:
return self.tot
return None
def depart_time_for_waypoint(self, waypoint: FlightWaypoint) -> timedelta | None:
def depart_time_for_waypoint(self, waypoint: FlightWaypoint) -> datetime | None:
return None
@property
@@ -68,7 +68,11 @@ class AirAssaultFlightPlan(StandardFlightPlan[AirAssaultLayout], UiZoneDisplay):
return meters(2500)
@property
def mission_departure_time(self) -> timedelta:
def mission_begin_on_station_time(self) -> datetime | None:
return None
@property
def mission_departure_time(self) -> datetime:
return self.package.time_over_target
def ui_zone(self) -> UiZone:
@@ -148,5 +152,5 @@ class Builder(IBuilder[AirAssaultFlightPlan, AirAssaultLayout]):
bullseye=builder.bullseye(),
)
def build(self) -> AirAssaultFlightPlan:
def build(self, dump_debug_info: bool = False) -> AirAssaultFlightPlan:
return AirAssaultFlightPlan(self.flight, self.layout())

View File

@@ -2,7 +2,7 @@ from __future__ import annotations
from collections.abc import Iterator
from dataclasses import dataclass
from datetime import timedelta
from datetime import datetime
from typing import TYPE_CHECKING, Type
from game.theater.missiontarget import MissionTarget
@@ -67,16 +67,20 @@ class AirliftFlightPlan(StandardFlightPlan[AirliftLayout]):
# drop-off waypoint.
return self.layout.drop_off or self.layout.arrival
def tot_for_waypoint(self, waypoint: FlightWaypoint) -> timedelta | None:
def tot_for_waypoint(self, waypoint: FlightWaypoint) -> datetime | None:
# TOT planning isn't really useful for transports. They're behind the front
# lines so no need to wait for escorts or for other missions to complete.
return None
def depart_time_for_waypoint(self, waypoint: FlightWaypoint) -> timedelta | None:
def depart_time_for_waypoint(self, waypoint: FlightWaypoint) -> datetime | None:
return None
@property
def mission_departure_time(self) -> timedelta:
def mission_begin_on_station_time(self) -> datetime | None:
return None
@property
def mission_departure_time(self) -> datetime:
return self.package.time_over_target
@@ -151,5 +155,5 @@ class Builder(IBuilder[AirliftFlightPlan, AirliftLayout]):
bullseye=builder.bullseye(),
)
def build(self) -> AirliftFlightPlan:
def build(self, dump_debug_info: bool = False) -> AirliftFlightPlan:
return AirliftFlightPlan(self.flight, self.layout())

View File

@@ -35,11 +35,11 @@ class Builder(FormationAttackBuilder[AntiShipFlightPlan, FormationAttackLayout])
else:
raise InvalidObjectiveLocation(self.flight.flight_type, location)
return self._build(FlightWaypointType.INGRESS_BAI, targets)
return self._build(FlightWaypointType.INGRESS_ANTI_SHIP, targets)
@staticmethod
def anti_ship_targets_for_tgo(tgo: NavalGroundObject) -> list[StrikeTarget]:
return [StrikeTarget(f"{g.group_name} at {tgo.name}", g) for g in tgo.groups]
def build(self) -> AntiShipFlightPlan:
def build(self, dump_debug_info: bool = False) -> AntiShipFlightPlan:
return AntiShipFlightPlan(self.flight, self.layout())

View File

@@ -39,5 +39,5 @@ class Builder(FormationAttackBuilder[BaiFlightPlan, FormationAttackLayout]):
return self._build(FlightWaypointType.INGRESS_BAI, targets)
def build(self) -> BaiFlightPlan:
def build(self, dump_debug_info: bool = False) -> BaiFlightPlan:
return BaiFlightPlan(self.flight, self.layout())

View File

@@ -66,5 +66,5 @@ class Builder(CapBuilder[BarCapFlightPlan, PatrollingLayout]):
bullseye=builder.bullseye(),
)
def build(self) -> BarCapFlightPlan:
def build(self, dump_debug_info: bool = False) -> BarCapFlightPlan:
return BarCapFlightPlan(self.flight, self.layout())

View File

@@ -1,5 +1,6 @@
from __future__ import annotations
import copy
import random
from abc import ABC
from typing import Any, TYPE_CHECKING, TypeVar
@@ -26,6 +27,9 @@ class CapBuilder(IBuilder[FlightPlanT, LayoutT], ABC):
self, location: MissionTarget, barcap: bool
) -> tuple[Point, Point]:
closest_cache = ObjectiveDistanceCache.get_closest_airfields(location)
closest_friendly_field = (
None # keep track of closest frieldly airfield in case we need it
)
for airfield in closest_cache.operational_airfields:
# If the mission is a BARCAP of an enemy airfield, find the *next*
# closest enemy airfield.
@@ -34,8 +38,43 @@ class CapBuilder(IBuilder[FlightPlanT, LayoutT], ABC):
if airfield.captured != self.is_player:
closest_airfield = airfield
break
elif closest_friendly_field is None:
closest_friendly_field = airfield
else:
raise PlanningError("Could not find any enemy airfields")
if barcap:
# If planning a BARCAP, we should be able to find at least one enemy
# airfield. If we can't, it's an error.
raise PlanningError("Could not find any enemy airfields")
else:
# if we cannot find any friendly or enemy airfields other than the target,
# there's nothing we can do
if closest_friendly_field is None:
raise PlanningError(
"Could not find any enemy or friendly airfields"
)
# If planning other race tracks (TARCAPs, currently), the target may be
# the only enemy airfield. In this case, set the race track orientation using
# a virtual point equi-distant from but opposite to the target from the closest
# friendly airfield like below, where F is the closest friendly airfield, T is
# the sole enemy airfield and V the virtual point
#
# F ---- T ----- V
#
# We need to create this virtual point, rather than using F to make sure
# the race track is aligned towards the target.
closest_friendly_field_position = copy.deepcopy(
closest_friendly_field.position
)
closest_airfield = closest_friendly_field
closest_airfield.position.x = (
2 * self.package.target.position.x
- closest_friendly_field_position.x
)
closest_airfield.position.y = (
2 * self.package.target.position.y
- closest_friendly_field_position.y
)
heading = Heading.from_degrees(
location.position.heading_between_point(closest_airfield.position)

View File

@@ -6,13 +6,15 @@ from datetime import timedelta
from typing import TYPE_CHECKING, Type
from game.theater import FrontLine
from game.utils import Distance, Speed, kph, meters
from game.utils import Distance, Speed, kph, meters, dcs_to_shapely_point
from .ibuilder import IBuilder
from .invalidobjectivelocation import InvalidObjectiveLocation
from .patrolling import PatrollingFlightPlan, PatrollingLayout
from .uizonedisplay import UiZone, UiZoneDisplay
from .waypointbuilder import WaypointBuilder
from ..flightwaypointtype import FlightWaypointType
from ...flightplan.ipsolver import IpSolver
from ...persistence.paths import waypoint_debug_directory
if TYPE_CHECKING:
from ..flightwaypoint import FlightWaypoint
@@ -20,16 +22,16 @@ if TYPE_CHECKING:
@dataclass(frozen=True)
class CasLayout(PatrollingLayout):
target: FlightWaypoint
ingress: FlightWaypoint
def iter_waypoints(self) -> Iterator[FlightWaypoint]:
yield self.departure
yield from self.nav_to
yield self.ingress
yield self.patrol_start
yield self.target
yield self.patrol_end
yield from self.nav_from
yield self.departure
yield self.arrival
if self.divert is not None:
yield self.divert
yield self.bullseye
@@ -59,23 +61,20 @@ class CasFlightPlan(PatrollingFlightPlan[CasLayout], UiZoneDisplay):
@property
def combat_speed_waypoints(self) -> set[FlightWaypoint]:
return {self.layout.patrol_start, self.layout.target, self.layout.patrol_end}
def request_escort_at(self) -> FlightWaypoint | None:
return self.layout.patrol_start
def dismiss_escort_at(self) -> FlightWaypoint | None:
return self.layout.patrol_end
return {self.layout.ingress, self.layout.patrol_start, self.layout.patrol_end}
def ui_zone(self) -> UiZone:
midpoint = (
self.layout.patrol_start.position + self.layout.patrol_end.position
) / 2
return UiZone(
[self.layout.target.position],
[midpoint],
self.engagement_distance,
)
class Builder(IBuilder[CasFlightPlan, CasLayout]):
def layout(self) -> CasLayout:
def layout(self, dump_debug_info: bool) -> CasLayout:
location = self.package.target
if not isinstance(location, FrontLine):
@@ -86,46 +85,79 @@ class Builder(IBuilder[CasFlightPlan, CasLayout]):
)
bounds = FrontLineConflictDescription.frontline_bounds(location, self.theater)
ingress = bounds.left_position
center = bounds.center
egress = bounds.right_position
patrol_start = bounds.left_position
patrol_end = bounds.right_position
ingress_distance = ingress.distance_to_point(self.flight.departure.position)
egress_distance = egress.distance_to_point(self.flight.departure.position)
if egress_distance < ingress_distance:
ingress, egress = egress, ingress
start_distance = patrol_start.distance_to_point(self.flight.departure.position)
end_distance = patrol_end.distance_to_point(self.flight.departure.position)
if end_distance < start_distance:
patrol_start, patrol_end = patrol_end, patrol_start
builder = WaypointBuilder(self.flight, self.coalition)
is_helo = self.flight.unit_type.dcs_unit_type.helicopter
ingress_egress_altitude = (
self.doctrine.ingress_altitude if not is_helo else meters(50)
patrol_altitude = self.doctrine.ingress_altitude if not is_helo else meters(50)
use_agl_patrol_altitude = is_helo
ip_solver = IpSolver(
dcs_to_shapely_point(self.flight.departure.position),
dcs_to_shapely_point(patrol_start),
self.doctrine,
self.threat_zones.all,
)
use_agl_ingress_egress = is_helo
ip_solver.set_debug_properties(
waypoint_debug_directory() / "IP", self.theater.terrain
)
ingress_point_shapely = ip_solver.solve()
if dump_debug_info:
ip_solver.dump_debug_info()
ingress_point = patrol_start.new_in_same_map(
ingress_point_shapely.x, ingress_point_shapely.y
)
patrol_start_waypoint = builder.nav(
patrol_start, patrol_altitude, use_agl_patrol_altitude
)
patrol_start_waypoint.name = "FLOT START"
patrol_start_waypoint.pretty_name = "FLOT start"
patrol_start_waypoint.description = "FLOT boundary"
patrol_start_waypoint.wants_escort = True
patrol_end_waypoint = builder.nav(
patrol_end, patrol_altitude, use_agl_patrol_altitude
)
patrol_end_waypoint.name = "FLOT END"
patrol_end_waypoint.pretty_name = "FLOT end"
patrol_end_waypoint.description = "FLOT boundary"
patrol_end_waypoint.wants_escort = True
ingress = builder.ingress(
FlightWaypointType.INGRESS_CAS, ingress_point, location
)
ingress.description = f"Ingress to provide CAS at {location}"
return CasLayout(
departure=builder.takeoff(self.flight.departure),
nav_to=builder.nav_path(
self.flight.departure.position,
ingress,
ingress_egress_altitude,
use_agl_ingress_egress,
ingress_point,
patrol_altitude,
use_agl_patrol_altitude,
),
nav_from=builder.nav_path(
egress,
patrol_end,
self.flight.arrival.position,
ingress_egress_altitude,
use_agl_ingress_egress,
patrol_altitude,
use_agl_patrol_altitude,
),
patrol_start=builder.ingress(
FlightWaypointType.INGRESS_CAS, ingress, location
),
target=builder.cas(center),
patrol_end=builder.egress(egress, location),
ingress=ingress,
patrol_start=patrol_start_waypoint,
patrol_end=patrol_end_waypoint,
arrival=builder.land(self.flight.arrival),
divert=builder.divert(self.flight.divert),
bullseye=builder.bullseye(),
)
def build(self) -> CasFlightPlan:
return CasFlightPlan(self.flight, self.layout())
def build(self, dump_debug_info: bool = False) -> CasFlightPlan:
return CasFlightPlan(self.flight, self.layout(dump_debug_info))

View File

@@ -2,7 +2,7 @@ from __future__ import annotations
from collections.abc import Iterator
from dataclasses import dataclass
from datetime import timedelta
from datetime import datetime
from typing import TYPE_CHECKING, Type
from .flightplan import FlightPlan, Layout
@@ -42,16 +42,20 @@ class CustomFlightPlan(FlightPlan[CustomLayout]):
return waypoint
return self.layout.departure
def tot_for_waypoint(self, waypoint: FlightWaypoint) -> timedelta | None:
def tot_for_waypoint(self, waypoint: FlightWaypoint) -> datetime | None:
if waypoint == self.tot_waypoint:
return self.package.time_over_target
return None
def depart_time_for_waypoint(self, waypoint: FlightWaypoint) -> timedelta | None:
def depart_time_for_waypoint(self, waypoint: FlightWaypoint) -> datetime | None:
return None
@property
def mission_departure_time(self) -> timedelta:
def mission_begin_on_station_time(self) -> datetime | None:
return None
@property
def mission_departure_time(self) -> datetime:
return self.package.time_over_target
@@ -68,5 +72,5 @@ class Builder(IBuilder[CustomFlightPlan, CustomLayout]):
builder = WaypointBuilder(self.flight, self.coalition)
return CustomLayout(builder.takeoff(self.flight.departure), self.waypoints)
def build(self) -> CustomFlightPlan:
def build(self, dump_debug_info: bool = False) -> CustomFlightPlan:
return CustomFlightPlan(self.flight, self.layout())

View File

@@ -37,5 +37,5 @@ class Builder(FormationAttackBuilder[DeadFlightPlan, FormationAttackLayout]):
return self._build(FlightWaypointType.INGRESS_DEAD)
def build(self) -> DeadFlightPlan:
def build(self, dump_debug_info: bool = False) -> DeadFlightPlan:
return DeadFlightPlan(self.flight, self.layout())

View File

@@ -50,5 +50,5 @@ class Builder(FormationAttackBuilder[EscortFlightPlan, FormationAttackLayout]):
bullseye=builder.bullseye(),
)
def build(self) -> EscortFlightPlan:
def build(self, dump_debug_info: bool = False) -> EscortFlightPlan:
return EscortFlightPlan(self.flight, self.layout())

View File

@@ -2,7 +2,7 @@ from __future__ import annotations
from collections.abc import Iterator
from dataclasses import dataclass
from datetime import timedelta
from datetime import datetime
from typing import TYPE_CHECKING, Type
from game.utils import feet
@@ -37,16 +37,20 @@ class FerryFlightPlan(StandardFlightPlan[FerryLayout]):
def tot_waypoint(self) -> FlightWaypoint:
return self.layout.arrival
def tot_for_waypoint(self, waypoint: FlightWaypoint) -> timedelta | None:
def tot_for_waypoint(self, waypoint: FlightWaypoint) -> datetime | None:
# TOT planning isn't really useful for ferries. They're behind the front
# lines so no need to wait for escorts or for other missions to complete.
return None
def depart_time_for_waypoint(self, waypoint: FlightWaypoint) -> timedelta | None:
def depart_time_for_waypoint(self, waypoint: FlightWaypoint) -> datetime | None:
return None
@property
def mission_departure_time(self) -> timedelta:
def mission_begin_on_station_time(self) -> datetime | None:
return None
@property
def mission_departure_time(self) -> datetime:
return self.package.time_over_target
@@ -79,5 +83,5 @@ class Builder(IBuilder[FerryFlightPlan, FerryLayout]):
bullseye=builder.bullseye(),
)
def build(self) -> FerryFlightPlan:
def build(self, dump_debug_info: bool = False) -> FerryFlightPlan:
return FerryFlightPlan(self.flight, self.layout())

View File

@@ -8,11 +8,10 @@ generating the waypoints for the mission.
from __future__ import annotations
import math
from abc import ABC
from abc import ABC, abstractmethod
from collections.abc import Iterator
from dataclasses import dataclass
from datetime import timedelta
from functools import cached_property
from datetime import datetime, timedelta
from typing import Any, Generic, TYPE_CHECKING, TypeGuard, TypeVar
from game.typeguard import self_type_guard
@@ -20,10 +19,9 @@ from game.utils import Distance, Speed, meters
from .planningerror import PlanningError
from ..flightwaypointtype import FlightWaypointType
from ..starttype import StartType
from ..traveltime import GroundSpeed, TravelTime
from ..traveltime import GroundSpeed
if TYPE_CHECKING:
from game.dcs.aircrafttype import FuelConsumption
from game.theater import ControlPoint
from ..flight import Flight
from ..flightwaypoint import FlightWaypoint
@@ -32,14 +30,6 @@ if TYPE_CHECKING:
from .loiter import LoiterFlightPlan
from .patrolling import PatrollingFlightPlan
INGRESS_TYPES = {
FlightWaypointType.INGRESS_CAS,
FlightWaypointType.INGRESS_ESCORT,
FlightWaypointType.INGRESS_SEAD,
FlightWaypointType.INGRESS_STRIKE,
FlightWaypointType.INGRESS_DEAD,
}
@dataclass(frozen=True)
class Layout(ABC):
@@ -62,6 +52,7 @@ class FlightPlan(ABC, Generic[LayoutT]):
def __init__(self, flight: Flight, layout: LayoutT) -> None:
self.flight = flight
self.layout = layout
self.tot_offset = self.default_tot_offset()
@property
def package(self) -> Package:
@@ -149,42 +140,9 @@ class FlightPlan(ABC, Generic[LayoutT]):
raise NotImplementedError
@property
def tot(self) -> timedelta:
def tot(self) -> datetime:
return self.package.time_over_target + self.tot_offset
@cached_property
def bingo_fuel(self) -> int:
"""Bingo fuel value for the FlightPlan"""
if (fuel := self.flight.unit_type.fuel_consumption) is not None:
return self._bingo_estimate(fuel)
return self._legacy_bingo_estimate()
def _bingo_estimate(self, fuel: FuelConsumption) -> int:
distance_to_arrival = self.max_distance_from(self.flight.arrival)
fuel_consumed = fuel.cruise * distance_to_arrival.nautical_miles
bingo = fuel_consumed + fuel.min_safe
return math.ceil(bingo / 100) * 100
def _legacy_bingo_estimate(self) -> int:
distance_to_arrival = self.max_distance_from(self.flight.arrival)
bingo = 1000.0 # Minimum Emergency Fuel
bingo += 500 # Visual Traffic
bingo += 15 * distance_to_arrival.nautical_miles
# TODO: Per aircraft tweaks.
if self.flight.divert is not None:
max_divert_distance = self.max_distance_from(self.flight.divert)
bingo += 10 * max_divert_distance.nautical_miles
return round(bingo / 100) * 100
@cached_property
def joker_fuel(self) -> int:
"""Joker fuel value for the FlightPlan"""
return self.bingo_fuel + 1000
def max_distance_from(self, cp: ControlPoint) -> Distance:
"""Returns the farthest waypoint of the flight plan from a ControlPoint.
:arg cp The ControlPoint to measure distance from.
@@ -195,8 +153,7 @@ class FlightPlan(ABC, Generic[LayoutT]):
[meters(cp.position.distance_to_point(w.position)) for w in self.waypoints]
)
@property
def tot_offset(self) -> timedelta:
def default_tot_offset(self) -> timedelta:
"""This flight's offset from the package's TOT.
Positive values represent later TOTs. An offset of -2 minutes is used
@@ -214,70 +171,70 @@ class FlightPlan(ABC, Generic[LayoutT]):
)
for previous_waypoint, waypoint in self.edges(until=destination):
total += self.travel_time_between_waypoints(previous_waypoint, waypoint)
return total
total += self.total_time_between_waypoints(previous_waypoint, waypoint)
# Trim microseconds. Our simulation tick rate is 1 second, so anything that
# takes 100.1 or 100.9 seconds will take 100 seconds. DCS doesn't handle
# sub-second resolution for tasks anyway, nor are they interesting from a
# mission planning perspective, so there's little value to keeping them in the
# model.
return timedelta(seconds=math.floor(total.total_seconds()))
def total_time_between_waypoints(
self, a: FlightWaypoint, b: FlightWaypoint
) -> timedelta:
"""Returns the total time spent between a and b.
The total time between waypoints differs from the travel time in that it may
include additional time for actions such as loitering.
"""
return self.travel_time_between_waypoints(a, b)
def travel_time_between_waypoints(
self, a: FlightWaypoint, b: FlightWaypoint
) -> timedelta:
return TravelTime.between_points(
a.position, b.position, self.speed_between_waypoints(a, b)
)
error_factor = 1.05
speed = self.speed_between_waypoints(a, b)
distance = meters(a.position.distance_to_point(b.position))
return timedelta(hours=distance.nautical_miles / speed.knots * error_factor)
def tot_for_waypoint(self, waypoint: FlightWaypoint) -> timedelta | None:
def tot_for_waypoint(self, waypoint: FlightWaypoint) -> datetime | None:
raise NotImplementedError
def depart_time_for_waypoint(self, waypoint: FlightWaypoint) -> timedelta | None:
def depart_time_for_waypoint(self, waypoint: FlightWaypoint) -> datetime | None:
raise NotImplementedError
def request_escort_at(self) -> FlightWaypoint | None:
return None
try:
return next(self.escorted_waypoints())
except StopIteration:
return None
def dismiss_escort_at(self) -> FlightWaypoint | None:
return None
try:
return list(self.escorted_waypoints())[-1]
except IndexError:
return None
def escorted_waypoints(self) -> Iterator[FlightWaypoint]:
begin = self.request_escort_at()
end = self.dismiss_escort_at()
if begin is None or end is None:
return
escorting = False
for waypoint in self.waypoints:
if waypoint == begin:
escorting = True
if escorting:
for waypoint in self.iter_waypoints():
if waypoint.wants_escort:
yield waypoint
if waypoint == end:
return
def takeoff_time(self) -> timedelta:
def takeoff_time(self) -> datetime:
return self.tot - self._travel_time_to_waypoint(self.tot_waypoint)
def startup_time(self) -> timedelta:
start_time = (
self.takeoff_time() - self.estimate_startup() - self.estimate_ground_ops()
def minimum_duration_from_start_to_tot(self) -> timedelta:
return (
self._travel_time_to_waypoint(self.tot_waypoint)
+ self.estimate_startup()
+ self.estimate_ground_ops()
)
# In case FP math has given us some barely below zero time, round to
# zero.
if math.isclose(start_time.total_seconds(), 0):
start_time = timedelta()
# Trim microseconds. DCS doesn't handle sub-second resolution for tasks,
# and they're not interesting from a mission planning perspective so we
# don't want them in the UI.
#
# Round down so *barely* above zero start times are just zero.
start_time = timedelta(seconds=math.floor(start_time.total_seconds()))
# Feature request #1309: Carrier planes should start at +1s
# This is a workaround to a DCS problem: some AI planes spawn on
# the 'sixpack' when start_time is zero and cause a deadlock.
# Workaround: force the start_time to 1 second for these planes.
if self.flight.from_cp.is_fleet and start_time.total_seconds() == 0:
start_time = timedelta(seconds=1)
return start_time
def startup_time(self) -> datetime:
return (
self.takeoff_time() - self.estimate_startup() - self.estimate_ground_ops()
)
def estimate_startup(self) -> timedelta:
if self.flight.start_type is StartType.COLD:
@@ -291,18 +248,30 @@ class FlightPlan(ABC, Generic[LayoutT]):
def estimate_ground_ops(self) -> timedelta:
if self.flight.start_type in {StartType.RUNWAY, StartType.IN_FLIGHT}:
return timedelta()
if self.flight.from_cp.is_fleet:
if self.flight.departure.is_fleet:
return timedelta(minutes=2)
else:
return timedelta(minutes=8)
@property
def mission_departure_time(self) -> timedelta:
@abstractmethod
def mission_begin_on_station_time(self) -> datetime | None:
"""The time that the mission is first on-station.
Not all mission types will have a time when they can be considered on-station.
Missions that patrol or loiter (CAPs, CAS, refueling, AEW&C, etc) will have this
defined, but strike-like missions will not.
"""
@property
def mission_departure_time(self) -> datetime:
"""The time that the mission is complete and the flight RTBs."""
raise NotImplementedError
@self_type_guard
def is_loiter(self, flight_plan: FlightPlan[Any]) -> TypeGuard[LoiterFlightPlan]:
def is_loiter(
self, flight_plan: FlightPlan[Any]
) -> TypeGuard[LoiterFlightPlan[Any]]:
return False
@self_type_guard
@@ -314,5 +283,8 @@ class FlightPlan(ABC, Generic[LayoutT]):
@self_type_guard
def is_formation(
self, flight_plan: FlightPlan[Any]
) -> TypeGuard[FormationFlightPlan]:
) -> TypeGuard[FormationFlightPlan[Any]]:
return False
def add_waypoint_actions(self) -> None:
pass

View File

@@ -3,6 +3,8 @@ from __future__ import annotations
from typing import Any, TYPE_CHECKING, Type
from game.ato import FlightType
from game.theater.controlpoint import NavalControlPoint
from game.theater.frontline import FrontLine
from .aewc import AewcFlightPlan
from .airassault import AirAssaultFlightPlan
from .airlift import AirliftFlightPlan
@@ -19,6 +21,7 @@ from .ocarunway import OcaRunwayFlightPlan
from .packagerefueling import PackageRefuelingFlightPlan
from .planningerror import PlanningError
from .sead import SeadFlightPlan
from .shiprecoverytanker import RecoveryTankerFlightPlan
from .strike import StrikeFlightPlan
from .sweep import SweepFlightPlan
from .tarcap import TarCapFlightPlan
@@ -26,15 +29,19 @@ from .theaterrefueling import TheaterRefuelingFlightPlan
if TYPE_CHECKING:
from game.ato import Flight
from game.theater import FrontLine
class FlightPlanBuilderTypes:
@staticmethod
def for_flight(flight: Flight) -> Type[IBuilder[Any, Any]]:
if flight.flight_type is FlightType.REFUELING:
if flight.package.target.is_friendly(flight.squadron.player) or isinstance(
flight.package.target, FrontLine
target = flight.package.target
if target.is_friendly(flight.squadron.player) and isinstance(
target, NavalControlPoint
):
return RecoveryTankerFlightPlan.builder_type()
if target.is_friendly(flight.squadron.player) or isinstance(
target, FrontLine
):
return TheaterRefuelingFlightPlan.builder_type()
return PackageRefuelingFlightPlan.builder_type()

View File

@@ -2,15 +2,14 @@ from __future__ import annotations
from abc import ABC, abstractmethod
from dataclasses import dataclass
from datetime import timedelta
from datetime import datetime, timedelta
from functools import cached_property
from typing import Any, TYPE_CHECKING, TypeGuard
from typing import Any, TYPE_CHECKING, TypeGuard, TypeVar
from game.typeguard import self_type_guard
from game.utils import Speed
from .flightplan import FlightPlan
from .loiter import LoiterFlightPlan, LoiterLayout
from ..traveltime import GroundSpeed, TravelTime
if TYPE_CHECKING:
from ..flightwaypoint import FlightWaypoint
@@ -25,7 +24,10 @@ class FormationLayout(LoiterLayout, ABC):
nav_from: list[FlightWaypoint]
class FormationFlightPlan(LoiterFlightPlan, ABC):
LayoutT = TypeVar("LayoutT", bound=FormationLayout)
class FormationFlightPlan(LoiterFlightPlan[LayoutT], ABC):
@property
@abstractmethod
def package_speed_waypoints(self) -> set[FlightWaypoint]:
@@ -35,12 +37,6 @@ class FormationFlightPlan(LoiterFlightPlan, ABC):
def combat_speed_waypoints(self) -> set[FlightWaypoint]:
return self.package_speed_waypoints
def request_escort_at(self) -> FlightWaypoint | None:
return self.layout.join
def dismiss_escort_at(self) -> FlightWaypoint | None:
return self.layout.split
@cached_property
def best_flight_formation_speed(self) -> Speed:
"""The best speed this flight is capable at all formation waypoints.
@@ -73,15 +69,15 @@ class FormationFlightPlan(LoiterFlightPlan, ABC):
@property
@abstractmethod
def join_time(self) -> timedelta:
def join_time(self) -> datetime:
...
@property
@abstractmethod
def split_time(self) -> timedelta:
def split_time(self) -> datetime:
...
def tot_for_waypoint(self, waypoint: FlightWaypoint) -> timedelta | None:
def tot_for_waypoint(self, waypoint: FlightWaypoint) -> datetime | None:
if waypoint == self.layout.join:
return self.join_time
elif waypoint == self.layout.split:
@@ -89,19 +85,21 @@ class FormationFlightPlan(LoiterFlightPlan, ABC):
return None
@property
def push_time(self) -> timedelta:
return self.join_time - TravelTime.between_points(
self.layout.hold.position,
self.layout.join.position,
GroundSpeed.for_flight(self.flight, self.layout.hold.alt),
def push_time(self) -> datetime:
return self.join_time - self.travel_time_between_waypoints(
self.layout.hold, self.layout.join
)
@property
def mission_departure_time(self) -> timedelta:
def mission_begin_on_station_time(self) -> datetime | None:
return None
@property
def mission_departure_time(self) -> datetime:
return self.split_time
@self_type_guard
def is_formation(
self, flight_plan: FlightPlan[Any]
) -> TypeGuard[FormationFlightPlan]:
) -> TypeGuard[FormationFlightPlan[Any]]:
return True

View File

@@ -3,7 +3,7 @@ from __future__ import annotations
from abc import ABC
from collections.abc import Iterator
from dataclasses import dataclass
from datetime import timedelta
from datetime import datetime, timedelta
from typing import TYPE_CHECKING, TypeVar
from dcs import Point
@@ -14,7 +14,6 @@ from game.utils import Speed, meters
from .flightplan import FlightPlan
from .formation import FormationFlightPlan, FormationLayout
from .ibuilder import IBuilder
from .planningerror import PlanningError
from .waypointbuilder import StrikeTarget, WaypointBuilder
from .. import FlightType
from ..flightwaypoint import FlightWaypoint
@@ -24,112 +23,6 @@ if TYPE_CHECKING:
from ..flight import Flight
class FormationAttackFlightPlan(FormationFlightPlan, ABC):
@property
def lead_time(self) -> timedelta:
return timedelta()
@property
def package_speed_waypoints(self) -> set[FlightWaypoint]:
return {
self.layout.ingress,
self.layout.split,
} | set(self.layout.targets)
def speed_between_waypoints(self, a: FlightWaypoint, b: FlightWaypoint) -> Speed:
# FlightWaypoint is only comparable by identity, so adding
# target_area_waypoint to package_speed_waypoints is useless.
if b.waypoint_type == FlightWaypointType.TARGET_GROUP_LOC:
# Should be impossible, as any package with at least one
# FormationFlightPlan flight needs a formation speed.
assert self.package.formation_speed is not None
return self.package.formation_speed
return super().speed_between_waypoints(a, b)
@property
def tot_waypoint(self) -> FlightWaypoint:
return self.layout.targets[0]
@property
def tot_offset(self) -> timedelta:
try:
return -self.lead_time
except AttributeError:
return timedelta()
@property
def target_area_waypoint(self) -> FlightWaypoint:
return FlightWaypoint(
"TARGET AREA",
FlightWaypointType.TARGET_GROUP_LOC,
self.package.target.position,
meters(0),
"RADIO",
)
@property
def travel_time_to_target(self) -> timedelta:
"""The estimated time between the first waypoint and the target."""
destination = self.tot_waypoint
total = timedelta()
for previous_waypoint, waypoint in self.edges():
if waypoint == self.tot_waypoint:
# For anything strike-like the TOT waypoint is the *flight's*
# mission target, but to synchronize with the rest of the
# package we need to use the travel time to the same position as
# the others.
total += self.travel_time_between_waypoints(
previous_waypoint, self.target_area_waypoint
)
break
total += self.travel_time_between_waypoints(previous_waypoint, waypoint)
else:
raise PlanningError(
f"Did not find destination waypoint {destination} in "
f"waypoints for {self.flight}"
)
return total
@property
def join_time(self) -> timedelta:
travel_time = self.travel_time_between_waypoints(
self.layout.join, self.layout.ingress
)
return self.ingress_time - travel_time
@property
def split_time(self) -> timedelta:
travel_time_ingress = self.travel_time_between_waypoints(
self.layout.ingress, self.target_area_waypoint
)
travel_time_egress = self.travel_time_between_waypoints(
self.target_area_waypoint, self.layout.split
)
minutes_at_target = 0.75 * len(self.layout.targets)
timedelta_at_target = timedelta(minutes=minutes_at_target)
return (
self.ingress_time
+ travel_time_ingress
+ timedelta_at_target
+ travel_time_egress
)
@property
def ingress_time(self) -> timedelta:
tot = self.tot
travel_time = self.travel_time_between_waypoints(
self.layout.ingress, self.target_area_waypoint
)
return tot - travel_time
def tot_for_waypoint(self, waypoint: FlightWaypoint) -> timedelta | None:
if waypoint == self.layout.ingress:
return self.ingress_time
elif waypoint in self.layout.targets:
return self.tot
return super().tot_for_waypoint(waypoint)
@dataclass(frozen=True)
class FormationAttackLayout(FormationLayout):
ingress: FlightWaypoint
@@ -152,6 +45,78 @@ class FormationAttackLayout(FormationLayout):
yield self.bullseye
class FormationAttackFlightPlan(FormationFlightPlan[FormationAttackLayout], ABC):
@property
def package_speed_waypoints(self) -> set[FlightWaypoint]:
return {
self.layout.ingress,
self.layout.split,
} | set(self.layout.targets)
def speed_between_waypoints(self, a: FlightWaypoint, b: FlightWaypoint) -> Speed:
# FlightWaypoint is only comparable by identity, so adding
# target_area_waypoint to package_speed_waypoints is useless.
if b.waypoint_type == FlightWaypointType.TARGET_GROUP_LOC:
# Should be impossible, as any package with at least one
# FormationFlightPlan flight needs a formation speed.
assert self.package.formation_speed is not None
return self.package.formation_speed
return super().speed_between_waypoints(a, b)
@property
def tot_waypoint(self) -> FlightWaypoint:
return self.layout.targets[0]
@property
def target_area_waypoint(self) -> FlightWaypoint:
return FlightWaypoint(
"TARGET AREA",
FlightWaypointType.TARGET_GROUP_LOC,
self.package.target.position,
meters(0),
"RADIO",
)
@property
def join_time(self) -> datetime:
travel_time = self.total_time_between_waypoints(
self.layout.join, self.layout.ingress
)
return self.ingress_time - travel_time
@property
def split_time(self) -> datetime:
travel_time_ingress = self.total_time_between_waypoints(
self.layout.ingress, self.target_area_waypoint
)
travel_time_egress = self.total_time_between_waypoints(
self.target_area_waypoint, self.layout.split
)
minutes_at_target = 0.75 * len(self.layout.targets)
timedelta_at_target = timedelta(minutes=minutes_at_target)
return (
self.ingress_time
+ travel_time_ingress
+ timedelta_at_target
+ travel_time_egress
)
@property
def ingress_time(self) -> datetime:
tot = self.tot
travel_time = self.total_time_between_waypoints(
self.layout.ingress, self.target_area_waypoint
)
return tot - travel_time
def tot_for_waypoint(self, waypoint: FlightWaypoint) -> datetime | None:
if waypoint == self.layout.ingress:
return self.ingress_time
elif waypoint in self.layout.targets:
return self.tot
return super().tot_for_waypoint(waypoint)
FlightPlanT = TypeVar("FlightPlanT", bound=FlightPlan[FormationAttackLayout])
LayoutT = TypeVar("LayoutT", bound=FormationAttackLayout)
@@ -180,7 +145,18 @@ class FormationAttackBuilder(IBuilder[FlightPlanT, LayoutT], ABC):
hold = builder.hold(self._hold_point())
join = builder.join(self.package.waypoints.join)
join.wants_escort = True
ingress = builder.ingress(
ingress_type, self.package.waypoints.ingress, self.package.target
)
ingress.wants_escort = True
for target_waypoint in target_waypoints:
target_waypoint.wants_escort = True
split = builder.split(self.package.waypoints.split)
split.wants_escort = True
refuel = builder.refuel(self.package.waypoints.refuel)
return FormationAttackLayout(
@@ -190,9 +166,7 @@ class FormationAttackBuilder(IBuilder[FlightPlanT, LayoutT], ABC):
hold.position, join.position, self.doctrine.ingress_altitude
),
join=join,
ingress=builder.ingress(
ingress_type, self.package.waypoints.ingress, self.package.target
),
ingress=ingress,
targets=target_waypoints,
split=split,
refuel=refuel,

View File

@@ -32,10 +32,11 @@ class IBuilder(ABC, Generic[FlightPlanT, LayoutT]):
assert self._flight_plan is not None
return self._flight_plan
def regenerate(self) -> None:
def regenerate(self, dump_debug_info: bool = False) -> None:
try:
self._generate_package_waypoints_if_needed()
self._flight_plan = self.build()
self._generate_package_waypoints_if_needed(dump_debug_info)
self._flight_plan = self.build(dump_debug_info)
self._flight_plan.add_waypoint_actions()
except NavMeshError as ex:
color = "blue" if self.flight.squadron.player else "red"
raise PlanningError(
@@ -43,10 +44,15 @@ class IBuilder(ABC, Generic[FlightPlanT, LayoutT]):
f"{self.flight.departure} to {self.package.target}"
) from ex
def _generate_package_waypoints_if_needed(self) -> None:
if self.package.waypoints is None:
def _generate_package_waypoints_if_needed(self, dump_debug_info: bool) -> None:
# Package waypoints are only valid for offensive missions. Skip this if the
# target is friendly.
if self.package.target.is_friendly(self.is_player):
return
if self.package.waypoints is None or dump_debug_info:
self.package.waypoints = PackageWaypoints.create(
self.package, self.coalition
self.package, self.coalition, dump_debug_info
)
@property
@@ -54,11 +60,7 @@ class IBuilder(ABC, Generic[FlightPlanT, LayoutT]):
return self.flight.departure.theater
@abstractmethod
def layout(self) -> LayoutT:
...
@abstractmethod
def build(self) -> FlightPlanT:
def build(self, dump_debug_info: bool = False) -> FlightPlanT:
...
@property

View File

@@ -2,10 +2,12 @@ from __future__ import annotations
from abc import ABC, abstractmethod
from dataclasses import dataclass
from datetime import timedelta
from typing import Any, TYPE_CHECKING, TypeGuard
from datetime import datetime, timedelta
from typing import Any, TYPE_CHECKING, TypeGuard, TypeVar
from game.flightplan.waypointactions.hold import Hold
from game.typeguard import self_type_guard
from game.utils import Speed
from .flightplan import FlightPlan
from .standard import StandardFlightPlan, StandardLayout
@@ -18,29 +20,44 @@ class LoiterLayout(StandardLayout, ABC):
hold: FlightWaypoint
class LoiterFlightPlan(StandardFlightPlan[Any], ABC):
LayoutT = TypeVar("LayoutT", bound=LoiterLayout)
class LoiterFlightPlan(StandardFlightPlan[LayoutT], ABC):
@property
def hold_duration(self) -> timedelta:
return timedelta(minutes=5)
@property
@abstractmethod
def push_time(self) -> timedelta:
def push_time(self) -> datetime:
...
def depart_time_for_waypoint(self, waypoint: FlightWaypoint) -> timedelta | None:
def depart_time_for_waypoint(self, waypoint: FlightWaypoint) -> datetime | None:
if waypoint == self.layout.hold:
return self.push_time
return None
def travel_time_between_waypoints(
def total_time_between_waypoints(
self, a: FlightWaypoint, b: FlightWaypoint
) -> timedelta:
travel_time = super().travel_time_between_waypoints(a, b)
travel_time = super().total_time_between_waypoints(a, b)
if a != self.layout.hold:
return travel_time
return travel_time + self.hold_duration
@self_type_guard
def is_loiter(self, flight_plan: FlightPlan[Any]) -> TypeGuard[LoiterFlightPlan]:
def is_loiter(
self, flight_plan: FlightPlan[Any]
) -> TypeGuard[LoiterFlightPlan[Any]]:
return True
def provide_push_time(self) -> datetime:
return self.push_time
def add_waypoint_actions(self) -> None:
hold = self.layout.hold
speed = self.flight.unit_type.patrol_speed
if speed is None:
speed = Speed.from_mach(0.6, hold.alt)
hold.add_action(Hold(self.provide_push_time, hold.alt, speed))

View File

@@ -32,5 +32,5 @@ class Builder(FormationAttackBuilder[OcaAircraftFlightPlan, FormationAttackLayou
return self._build(FlightWaypointType.INGRESS_OCA_AIRCRAFT)
def build(self) -> OcaAircraftFlightPlan:
def build(self, dump_debug_info: bool = False) -> OcaAircraftFlightPlan:
return OcaAircraftFlightPlan(self.flight, self.layout())

View File

@@ -32,5 +32,5 @@ class Builder(FormationAttackBuilder[OcaRunwayFlightPlan, FormationAttackLayout]
return self._build(FlightWaypointType.INGRESS_OCA_RUNWAY)
def build(self) -> OcaRunwayFlightPlan:
def build(self, dump_debug_info: bool = False) -> OcaRunwayFlightPlan:
return OcaRunwayFlightPlan(self.flight, self.layout())

View File

@@ -1,6 +1,6 @@
from __future__ import annotations
from datetime import timedelta
from datetime import datetime, timedelta
from typing import Type
from dcs import Point
@@ -39,7 +39,7 @@ class PackageRefuelingFlightPlan(RefuelingFlightPlan):
)
@property
def patrol_start_time(self) -> timedelta:
def patrol_start_time(self) -> datetime:
altitude = self.flight.unit_type.patrol_altitude
if altitude is None:
@@ -59,10 +59,10 @@ class PackageRefuelingFlightPlan(RefuelingFlightPlan):
"REFUEL", FlightWaypointType.REFUEL, refuel, altitude
)
delay_target_to_split: timedelta = self.travel_time_between_waypoints(
delay_target_to_split: timedelta = self.total_time_between_waypoints(
self.target_area_waypoint(), split_waypoint
)
delay_split_to_refuel: timedelta = self.travel_time_between_waypoints(
delay_split_to_refuel: timedelta = self.total_time_between_waypoints(
split_waypoint, refuel_waypoint
)
@@ -121,5 +121,5 @@ class Builder(IBuilder[PackageRefuelingFlightPlan, PatrollingLayout]):
bullseye=builder.bullseye(),
)
def build(self) -> PackageRefuelingFlightPlan:
def build(self, dump_debug_info: bool = False) -> PackageRefuelingFlightPlan:
return PackageRefuelingFlightPlan(self.flight, self.layout())

View File

@@ -3,7 +3,7 @@ from __future__ import annotations
from abc import ABC, abstractmethod
from collections.abc import Iterator
from dataclasses import dataclass
from datetime import timedelta
from datetime import datetime, timedelta
from typing import Any, TYPE_CHECKING, TypeGuard, TypeVar
from game.ato.flightplans.standard import StandardFlightPlan, StandardLayout
@@ -61,22 +61,22 @@ class PatrollingFlightPlan(StandardFlightPlan[LayoutT], UiZoneDisplay, ABC):
"""
@property
def patrol_start_time(self) -> timedelta:
return self.package.time_over_target
def patrol_start_time(self) -> datetime:
return self.tot
@property
def patrol_end_time(self) -> timedelta:
def patrol_end_time(self) -> datetime:
# TODO: This is currently wrong for CAS.
# CAS missions end when they're winchester or bingo. We need to
# configure push tasks for the escorts rather than relying on timing.
return self.patrol_start_time + self.patrol_duration
def tot_for_waypoint(self, waypoint: FlightWaypoint) -> timedelta | None:
def tot_for_waypoint(self, waypoint: FlightWaypoint) -> datetime | None:
if waypoint == self.layout.patrol_start:
return self.patrol_start_time
return None
def depart_time_for_waypoint(self, waypoint: FlightWaypoint) -> timedelta | None:
def depart_time_for_waypoint(self, waypoint: FlightWaypoint) -> datetime | None:
if waypoint == self.layout.patrol_end:
return self.patrol_end_time
return None
@@ -90,7 +90,11 @@ class PatrollingFlightPlan(StandardFlightPlan[LayoutT], UiZoneDisplay, ABC):
return self.layout.patrol_start
@property
def mission_departure_time(self) -> timedelta:
def mission_begin_on_station_time(self) -> datetime:
return self.patrol_start_time
@property
def mission_departure_time(self) -> datetime:
return self.patrol_end_time
@self_type_guard

View File

@@ -2,7 +2,7 @@ from __future__ import annotations
from collections.abc import Iterator
from dataclasses import dataclass
from datetime import timedelta
from datetime import datetime
from typing import TYPE_CHECKING, Type
from game.utils import feet
@@ -43,15 +43,19 @@ class RtbFlightPlan(StandardFlightPlan[RtbLayout]):
def tot_waypoint(self) -> FlightWaypoint:
return self.layout.abort_location
def tot_for_waypoint(self, waypoint: FlightWaypoint) -> timedelta | None:
def tot_for_waypoint(self, waypoint: FlightWaypoint) -> datetime | None:
return None
def depart_time_for_waypoint(self, waypoint: FlightWaypoint) -> timedelta | None:
def depart_time_for_waypoint(self, waypoint: FlightWaypoint) -> datetime | None:
return None
@property
def mission_departure_time(self) -> timedelta:
return timedelta()
def mission_begin_on_station_time(self) -> datetime | None:
return None
@property
def mission_departure_time(self) -> datetime:
return self.tot
class Builder(IBuilder[RtbFlightPlan, RtbLayout]):
@@ -89,5 +93,5 @@ class Builder(IBuilder[RtbFlightPlan, RtbLayout]):
bullseye=builder.bullseye(),
)
def build(self) -> RtbFlightPlan:
def build(self, dump_debug_info: bool = False) -> RtbFlightPlan:
return RtbFlightPlan(self.flight, self.layout())

View File

@@ -16,14 +16,13 @@ class SeadFlightPlan(FormationAttackFlightPlan):
def builder_type() -> Type[Builder]:
return Builder
@property
def lead_time(self) -> timedelta:
return timedelta(minutes=1)
def default_tot_offset(self) -> timedelta:
return -timedelta(minutes=1)
class Builder(FormationAttackBuilder[SeadFlightPlan, FormationAttackLayout]):
def layout(self) -> FormationAttackLayout:
return self._build(FlightWaypointType.INGRESS_SEAD)
def build(self) -> SeadFlightPlan:
def build(self, dump_debug_info: bool = False) -> SeadFlightPlan:
return SeadFlightPlan(self.flight, self.layout())

View File

@@ -0,0 +1,94 @@
from __future__ import annotations
from dataclasses import dataclass
from datetime import datetime, timedelta
from typing import Iterator, Type
from game.ato.flightplans.ibuilder import IBuilder
from game.ato.flightplans.standard import StandardFlightPlan, StandardLayout
from game.ato.flightplans.waypointbuilder import WaypointBuilder
from game.ato.flightwaypoint import FlightWaypoint
@dataclass(frozen=True)
class RecoveryTankerLayout(StandardLayout):
nav_to: list[FlightWaypoint]
recovery_ship: FlightWaypoint
nav_from: list[FlightWaypoint]
def iter_waypoints(self) -> Iterator[FlightWaypoint]:
yield self.departure
yield from self.nav_to
yield self.recovery_ship
yield from self.nav_from
yield self.arrival
if self.divert is not None:
yield self.divert
yield self.bullseye
class RecoveryTankerFlightPlan(StandardFlightPlan[RecoveryTankerLayout]):
@staticmethod
def builder_type() -> Type[Builder]:
return Builder
@property
def tot_waypoint(self) -> FlightWaypoint:
return self.layout.recovery_ship
@property
def mission_begin_on_station_time(self) -> datetime:
return self.package.time_over_target
@property
def mission_departure_time(self) -> datetime:
return self.patrol_end_time
@property
def patrol_start_time(self) -> datetime:
return self.package.time_over_target
@property
def patrol_end_time(self) -> datetime:
return self.tot + timedelta(hours=2)
def tot_for_waypoint(self, waypoint: FlightWaypoint) -> datetime | None:
if waypoint == self.tot_waypoint:
return self.tot
return None
def depart_time_for_waypoint(self, waypoint: FlightWaypoint) -> datetime | None:
if waypoint == self.tot_waypoint:
return self.mission_departure_time
return None
class Builder(IBuilder[RecoveryTankerFlightPlan, RecoveryTankerLayout]):
def layout(self) -> RecoveryTankerLayout:
builder = WaypointBuilder(self.flight, self.coalition)
# TODO: Propagate the ship position to the Tanker's TOT,
# so that we minimize the tanker's need to catch up to the carrier.
recovery_ship = self.package.target.position
recovery_tanker = builder.recovery_tanker(recovery_ship)
# We don't have per aircraft cruise altitudes, so just reuse patrol altitude?
tanker_type = self.flight.unit_type
nav_cruise_altitude = tanker_type.preferred_patrol_altitude
return RecoveryTankerLayout(
departure=builder.takeoff(self.flight.departure),
nav_to=builder.nav_path(
self.flight.departure.position, recovery_ship, nav_cruise_altitude
),
nav_from=builder.nav_path(
recovery_ship, self.flight.arrival.position, nav_cruise_altitude
),
recovery_ship=recovery_tanker,
arrival=builder.land(self.flight.arrival),
divert=builder.divert(self.flight.divert),
bullseye=builder.bullseye(),
)
def build(self, dump_debug_info: bool = False) -> RecoveryTankerFlightPlan:
return RecoveryTankerFlightPlan(self.flight, self.layout())

View File

@@ -32,5 +32,5 @@ class Builder(FormationAttackBuilder[StrikeFlightPlan, FormationAttackLayout]):
return self._build(FlightWaypointType.INGRESS_STRIKE, targets)
def build(self) -> StrikeFlightPlan:
def build(self, dump_debug_info: bool = False) -> StrikeFlightPlan:
return StrikeFlightPlan(self.flight, self.layout())

View File

@@ -1,17 +1,19 @@
from __future__ import annotations
from dataclasses import dataclass
from datetime import timedelta
from datetime import datetime, timedelta
from typing import Iterator, TYPE_CHECKING, Type
from dcs import Point
from dcs.task import Targets
from game.utils import Heading
from game.flightplan import HoldZoneGeometry
from game.flightplan.waypointactions.engagetargets import EngageTargets
from game.flightplan.waypointoptions.formation import Formation
from game.utils import Heading, nautical_miles
from .ibuilder import IBuilder
from .loiter import LoiterFlightPlan, LoiterLayout
from .waypointbuilder import WaypointBuilder
from ..traveltime import GroundSpeed, TravelTime
from ...flightplan import HoldZoneGeometry
if TYPE_CHECKING:
from ..flightwaypoint import FlightWaypoint
@@ -37,11 +39,7 @@ class SweepLayout(LoiterLayout):
yield self.bullseye
class SweepFlightPlan(LoiterFlightPlan):
@property
def lead_time(self) -> timedelta:
return timedelta(minutes=5)
class SweepFlightPlan(LoiterFlightPlan[SweepLayout]):
@staticmethod
def builder_type() -> Type[Builder]:
return Builder
@@ -54,44 +52,59 @@ class SweepFlightPlan(LoiterFlightPlan):
def tot_waypoint(self) -> FlightWaypoint:
return self.layout.sweep_end
@property
def tot_offset(self) -> timedelta:
return -self.lead_time
def default_tot_offset(self) -> timedelta:
return -timedelta(minutes=5)
@property
def sweep_start_time(self) -> timedelta:
travel_time = self.travel_time_between_waypoints(
def sweep_start_time(self) -> datetime:
travel_time = self.total_time_between_waypoints(
self.layout.sweep_start, self.layout.sweep_end
)
return self.sweep_end_time - travel_time
@property
def sweep_end_time(self) -> timedelta:
def sweep_end_time(self) -> datetime:
return self.tot
def tot_for_waypoint(self, waypoint: FlightWaypoint) -> timedelta | None:
def tot_for_waypoint(self, waypoint: FlightWaypoint) -> datetime | None:
if waypoint == self.layout.sweep_start:
return self.sweep_start_time
if waypoint == self.layout.sweep_end:
return self.sweep_end_time
return None
def depart_time_for_waypoint(self, waypoint: FlightWaypoint) -> timedelta | None:
def depart_time_for_waypoint(self, waypoint: FlightWaypoint) -> datetime | None:
if waypoint == self.layout.hold:
return self.push_time
return None
@property
def push_time(self) -> timedelta:
return self.sweep_end_time - TravelTime.between_points(
self.layout.hold.position,
self.layout.sweep_end.position,
GroundSpeed.for_flight(self.flight, self.layout.hold.alt),
def push_time(self) -> datetime:
return self.sweep_end_time - self.travel_time_between_waypoints(
self.layout.hold, self.layout.sweep_end
)
def mission_departure_time(self) -> timedelta:
@property
def mission_begin_on_station_time(self) -> datetime | None:
return None
@property
def mission_departure_time(self) -> datetime:
return self.sweep_end_time
def add_waypoint_actions(self) -> None:
super().add_waypoint_actions()
self.layout.sweep_start.set_option(Formation.LINE_ABREAST_OPEN)
self.layout.sweep_start.add_action(
EngageTargets(
nautical_miles(50),
[
Targets.All.Air.Planes.Fighters,
Targets.All.Air.Planes.MultiroleFighters,
],
)
)
class Builder(IBuilder[SweepFlightPlan, SweepLayout]):
def layout(self) -> SweepLayout:
@@ -137,5 +150,5 @@ class Builder(IBuilder[SweepFlightPlan, SweepLayout]):
target, origin, ip, join, self.coalition, self.theater
).find_best_hold_point()
def build(self) -> SweepFlightPlan:
def build(self, dump_debug_info: bool = False) -> SweepFlightPlan:
return SweepFlightPlan(self.flight, self.layout())

View File

@@ -3,7 +3,7 @@ from __future__ import annotations
import random
from collections.abc import Iterator
from dataclasses import dataclass
from datetime import timedelta
from datetime import datetime, timedelta
from typing import TYPE_CHECKING, Type
from game.utils import Distance, Speed, feet
@@ -34,10 +34,6 @@ class TarCapLayout(PatrollingLayout):
class TarCapFlightPlan(PatrollingFlightPlan[TarCapLayout]):
@property
def lead_time(self) -> timedelta:
return timedelta(minutes=2)
@property
def patrol_duration(self) -> timedelta:
# Note that this duration only has an effect if there are no
@@ -64,24 +60,23 @@ class TarCapFlightPlan(PatrollingFlightPlan[TarCapLayout]):
def combat_speed_waypoints(self) -> set[FlightWaypoint]:
return {self.layout.patrol_start, self.layout.patrol_end}
@property
def tot_offset(self) -> timedelta:
return -self.lead_time
def default_tot_offset(self) -> timedelta:
return -timedelta(minutes=2)
def depart_time_for_waypoint(self, waypoint: FlightWaypoint) -> timedelta | None:
def depart_time_for_waypoint(self, waypoint: FlightWaypoint) -> datetime | None:
if waypoint == self.layout.patrol_end:
return self.patrol_end_time
return super().depart_time_for_waypoint(waypoint)
@property
def patrol_start_time(self) -> timedelta:
def patrol_start_time(self) -> datetime:
start = self.package.escort_start_time
if start is not None:
return start + self.tot_offset
return self.tot
@property
def patrol_end_time(self) -> timedelta:
def patrol_end_time(self) -> datetime:
end = self.package.escort_end_time
if end is not None:
return end
@@ -127,5 +122,5 @@ class Builder(CapBuilder[TarCapFlightPlan, TarCapLayout]):
bullseye=builder.bullseye(),
)
def build(self) -> TarCapFlightPlan:
def build(self, dump_debug_info: bool = False) -> TarCapFlightPlan:
return TarCapFlightPlan(self.flight, self.layout())

View File

@@ -79,5 +79,5 @@ class Builder(IBuilder[TheaterRefuelingFlightPlan, PatrollingLayout]):
bullseye=builder.bullseye(),
)
def build(self) -> TheaterRefuelingFlightPlan:
def build(self, dump_debug_info: bool = False) -> TheaterRefuelingFlightPlan:
return TheaterRefuelingFlightPlan(self.flight, self.layout())

View File

@@ -23,7 +23,7 @@ from game.theater import (
TheaterGroundObject,
TheaterUnit,
)
from game.utils import Distance, meters, nautical_miles
from game.utils import Distance, feet, meters, nautical_miles
if TYPE_CHECKING:
from game.coalition import Coalition
@@ -168,6 +168,9 @@ class WaypointBuilder:
"HOLD",
FlightWaypointType.LOITER,
position,
# Bug: DCS only accepts MSL altitudes for the orbit task and 500 meters is
# below the ground for most if not all of NTTR (and lots of places in other
# maps).
meters(500) if self.is_helo else self.doctrine.rendezvous_altitude,
alt_type,
description="Wait until push time",
@@ -204,6 +207,19 @@ class WaypointBuilder:
pretty_name="Refuel",
)
def recovery_tanker(self, position: Point) -> FlightWaypoint:
alt_type: AltitudeReference = "BARO"
return FlightWaypoint(
"RECOVERY",
FlightWaypointType.RECOVERY_TANKER,
position,
feet(6000),
alt_type,
description="Recovery tanker for aircraft carriers",
pretty_name="Recovery",
)
def split(self, position: Point) -> FlightWaypoint:
alt_type: AltitudeReference = "BARO"
if self.is_helo:
@@ -240,21 +256,6 @@ class WaypointBuilder:
targets=objective.strike_targets,
)
def egress(self, position: Point, target: MissionTarget) -> FlightWaypoint:
alt_type: AltitudeReference = "BARO"
if self.is_helo:
alt_type = "RADIO"
return FlightWaypoint(
"EGRESS",
FlightWaypointType.EGRESS,
position,
meters(60) if self.is_helo else self.doctrine.ingress_altitude,
alt_type,
description=f"EGRESS from {target.name}",
pretty_name=f"EGRESS from {target.name}",
)
def bai_group(self, target: StrikeTarget) -> FlightWaypoint:
return self._target_point(target, f"ATTACK {target.name}")
@@ -344,17 +345,6 @@ class WaypointBuilder:
waypoint.only_for_player = True
return waypoint
def cas(self, position: Point) -> FlightWaypoint:
return FlightWaypoint(
"CAS",
FlightWaypointType.CAS,
position,
meters(60) if self.is_helo else meters(1000),
"RADIO",
description="Provide CAS",
pretty_name="CAS",
)
@staticmethod
def race_track_start(position: Point, altitude: Distance) -> FlightWaypoint:
"""Creates a racetrack start waypoint.

View File

@@ -1,29 +1,30 @@
from __future__ import annotations
from collections.abc import Iterator
from typing import Optional, TYPE_CHECKING
from game.ato.iflightroster import IFlightRoster
if TYPE_CHECKING:
from game.squadrons import Squadron, Pilot
class FlightRoster:
class FlightRoster(IFlightRoster):
def __init__(self, squadron: Squadron, initial_size: int = 0) -> None:
self.squadron = squadron
self.pilots: list[Optional[Pilot]] = []
self.resize(initial_size)
def iter_pilots(self) -> Iterator[Pilot | None]:
yield from self.pilots
def pilot_at(self, idx: int) -> Pilot | None:
return self.pilots[idx]
@property
def max_size(self) -> int:
return len(self.pilots)
@property
def player_count(self) -> int:
return len([p for p in self.pilots if p is not None and p.player])
@property
def missing_pilots(self) -> int:
return len([p for p in self.pilots if p is None])
def resize(self, new_size: int) -> None:
if self.max_size > new_size:
self.squadron.return_pilots(

View File

@@ -0,0 +1,25 @@
from __future__ import annotations
from datetime import datetime, timedelta
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from game.flightplan.waypointactions.waypointaction import WaypointAction
class ActionState:
def __init__(self, action: WaypointAction) -> None:
self.action = action
self._finished = False
def describe(self) -> str:
return self.action.describe()
def finish(self) -> None:
self._finished = True
def is_finished(self) -> bool:
return self._finished
def on_game_tick(self, time: datetime, duration: timedelta) -> timedelta:
return self.action.update_state(self, time, duration)

Some files were not shown because too many files have changed in this diff Show More