From b19641300efc5b1e4a7164f5bbc52dc827aa4f73 Mon Sep 17 00:00:00 2001 From: FullGas1 <51051389+FullGas1@users.noreply.github.com> Date: Wed, 18 Nov 2026 19:38:57 +0100 Subject: [PATCH 1/3] docs(backlog): FIX-FAT-COW-GROUND-TEST lot (issue #295) PRD and one ticket: the Fat Cow asks ctld.utils.inAir instead of DCS's raw inAir() at its three places. Co-Authored-By: Claude Sonnet 5.5 --- .backlog/FIX-FAT-COW-GROUND-TEST/PRD.md | 80 +++++++++++++++++++ .../01-ask-the-shared-ground-helper.md | 33 ++++++++ .backlog/README.md | 1 + 3 files changed, 114 insertions(+) create mode 100644 .backlog/FIX-FAT-COW-GROUND-TEST/PRD.md create mode 100644 .backlog/FIX-FAT-COW-GROUND-TEST/tickets/01-ask-the-shared-ground-helper.md diff --git a/.backlog/FIX-FAT-COW-GROUND-TEST/PRD.md b/.backlog/FIX-FAT-COW-GROUND-TEST/PRD.md new file mode 100644 index 00000000..9bec978b --- /dev/null +++ b/.backlog/FIX-FAT-COW-GROUND-TEST/PRD.md @@ -0,0 +1,80 @@ +# FIX-FAT-COW-GROUND-TEST — the Fat Cow tests for the ground with DCS's raw `inAir()`, the case `ctld.utils.inAir` exists for + +**Status:** ⬜ ready — decisions taken in the grill of 2026-11-18 (no ADR, no `CONTEXT.md` term). + +GitHub issue #295 (found by an automated review of `develop`; the code has moved since, the analysis holds). + +## Problem Statement + +DCS gives every unit an `inAir()` answer. For a high-chassis helicopter such as the CH-47, which is the cow of the whole feature (`fatCowTypes` and `fatCowAIType` are both `CH-47Fbl1`), it can answer "in the air" while the aircraft sits landed and stationary. CTLD has a replacement for exactly this, `ctld.utils.inAir`: when DCS says "in the air" but the unit is below the configured `groundAglThreshold` and nearly still (under 0.5 m/s), it counts as on the ground. The helper's own header names the CH-47, and the rest of the code goes through it. This is inherited knowledge from v1, and it was not re-measured on the current DCS for this lot. + +The Fat Cow code calls DCS's raw `inAir()` at three places: + +1. **Deploying the FARP.** A landed CH-47 is refused with "airborne": its FARP never opens. +2. **Land here.** The guard "The Fat Cow is already on the ground." never fires for a landed CH-47, so the cow is told to land while it is on the ground. +3. **Release the Fat Cow** (not in the issue, found in the grill). A landed cow is taken for an airborne one and given an orbit task: on release it **lifts off from its open FARP** and leaves it behind. The pilot guide says the opposite: on the ground its FARP stays open, in the air it orbits there. + +What a pilot sees: + +- **AI cow.** The deployment timer gets "airborne". Since the previous lot (FIX-FAT-COW-DEPLOY-REFUSALS) that refusal is no longer silent: the flight reads "The Fat Cow FARP could not be deployed." and the log says the cow did not deploy because it is airborne. The defect is now visible, but the FARP still never opens, and **Take off** then **Land here** meets the same refusal. +- **Piloted cow.** The pilot's own path lets a landed CH-47 through with the shared helper, and the deployment that follows then rejects it as "airborne", which the pilot's path turns into the catch-all "The Fat Cow FARP could not be deployed.". The pilot is on the ground with his crates in the hold, and reads that the deployment failed. + +The tests cannot see any of this: they stub DCS's `inAir()` and the shared helper on **the same flag**, so the two are indistinguishable. A test needs a unit for which they disagree: the CH-47 at rest. + +## Solution + +The Fat Cow code asks the shared helper, like the rest of CTLD, at its three places: + +- a cow that has landed deploys its FARP, AI or piloted, whatever DCS's raw answer; +- **Land here** tells a flight whose cow is already on the ground so; +- **Release the Fat Cow** leaves a landed cow where it is, its FARP open, and makes only a cow in the air orbit. + +A cow that is really in the air is treated exactly as before. + +## User Stories + +1. As a pilot whose flight's AI cow has landed, I want its FARP to open when the delay runs out, so that I can rearm and refuel. +2. As a pilot of a piloted cow, I want my landed CH-47 to deploy its FARP from the crates in my hold, so that the FARP opens. +3. As a piloted cow's pilot, I do not want to read that the FARP could not be deployed when I am on the ground and everything is in order. +4. As a pilot, I want **Land here** to tell me "The Fat Cow is already on the ground." when it is, so that I do not re-task a cow that is where I want it. +5. As a pilot, I want **Release the Fat Cow** to leave a landed cow where it is, with its FARP open, as the guide says, so that another flight can use it. +6. As a pilot, I want a cow that is really in the air to orbit where it stands when I release it, so that this behaviour is unchanged. +7. As a pilot, I want **Land here** to still land a cow that is really in the air, so that the command keeps working. +8. As a server administrator, I want an AI cow that has landed not to be logged as "airborne", so that the log does not report a problem that is not one. +9. As a maintainer, I want the Fat Cow code to ask the same question about the ground as the rest of CTLD, so that one definition of "on the ground" applies everywhere. +10. As a maintainer, I want the deployment to keep refusing a cow that is really in the air with the reason "airborne", so that the contract is unchanged. +11. As a maintainer, I want tests with a unit for which DCS's raw answer and the shared helper disagree, so that the divergence can be seen and cannot come back unseen. +12. As a maintainer, I want no new setting, text or translation, so that the catalogue, the dictionaries and the saved configurations stay as they are. + +## Implementation Decisions + +- **Three places go through the shared helper**: the deployment of the FARP, the **Land here** guard, and the **Release the Fat Cow** test of whether to orbit. Nothing else in the Fat Cow code changes. +- **Rejected: the two places of the issue only.** It would leave **Release the Fat Cow** making a landed cow take off from its open FARP. +- **Rejected: also the mine field scene**, which has two raw calls of its own. It is another component, not analysed here and older than this lot; if it turns out to be a problem it deserves its own lot. +- **No other behaviour changes**: a cow really in the air is refused by the deployment with the reason "airborne" as before, **Land here** still lands it, and **Release the Fat Cow** still makes it orbit. Messages, labels and order are unchanged. +- **No live probe.** The premise (DCS's raw answer for a landed CH-47) is documented in the helper and not re-measured on the current DCS; measuring it would mean spawning a parked CH-47 far from the player and removing it again, and would not change the decision: going through the helper the rest of CTLD uses is right whether or not DCS still misreports. The pull request says the DCS behaviour was not re-measured; unit tests, not a measurement, prove the fix. +- **CHANGELOG**: one *Fixed* entry under `[Unreleased]`. No text, no configuration key, no catalogue shape, no dictionary change; the pilot guide is already right. + +## Testing Decisions + +- **A good test** observes what the cow does and what the flight reads, with a unit that tells DCS's raw answer apart from the shared helper's. +- **Seams**: the existing AI cow spec and the existing piloted cow spec. The mock is the one the issue describes: a unit whose raw `inAir()` says "in the air" while the helper says "on the ground", the CH-47 at rest. +- **Cases, red first for the right reason** (today the cow is taken for airborne): + - an AI cow that has landed deploys its FARP when the delay expires; + - a piloted cow with cow crates in its hold, landed, deploys its FARP and does not read "could not be deployed"; + - **Land here** on a landed cow answers "The Fat Cow is already on the ground." and gives no new landing task; + - **Release the Fat Cow** on a landed cow gives no orbit task and leaves the FARP open; + - controls with a cow really in the air (both answers say so): the deployment still refuses it as airborne, **Land here** lands it, **Release the Fat Cow** makes it orbit. +- **No live DCS check**; the pull request says so. + +## Out of Scope + +- The two raw calls of the mine field scene. +- Re-measuring DCS's `inAir()` for the CH-47. +- Changing the shared helper or the `groundAglThreshold` setting. +- Any other Fat Cow behaviour. + +## Further Notes + +- One ticket is planned; the `to-issues` quiz is short. +- Since the previous lot, a landed AI cow refused as "airborne" is at least reported to the flight and logged. That is what makes this defect visible on a server: a log line "did not deploy after the delay: airborne" for a cow standing on the ground is this lot's symptom. diff --git a/.backlog/FIX-FAT-COW-GROUND-TEST/tickets/01-ask-the-shared-ground-helper.md b/.backlog/FIX-FAT-COW-GROUND-TEST/tickets/01-ask-the-shared-ground-helper.md new file mode 100644 index 00000000..98dd3684 --- /dev/null +++ b/.backlog/FIX-FAT-COW-GROUND-TEST/tickets/01-ask-the-shared-ground-helper.md @@ -0,0 +1,33 @@ +# 01 — The Fat Cow asks the shared helper whether it is on the ground + +**Status:** ⬜ ready · **Type:** AFK + +## Parent + +[PRD — FIX-FAT-COW-GROUND-TEST](../PRD.md). Stories 1 to 12. GitHub issue #295. + +## What to build + +The Fat Cow code asks `ctld.utils.inAir`, as the rest of CTLD does, instead of DCS's raw `inAir()`, at its three places. A landed CH-47 is then on the ground for the cow, whatever DCS's raw answer. + +- **Deploying the FARP.** A cow that has landed deploys, AI or piloted. A cow really in the air is still refused with the reason "airborne". +- **Land here.** A flight whose cow is already on the ground reads "The Fat Cow is already on the ground." and the cow is not re-tasked. A cow really in the air is still sent to land. +- **Release the Fat Cow.** A landed cow stays where it is, its FARP open, with no orbit task. A cow really in the air still orbits where it stands. +- **Nothing else changes.** Messages, labels and order are unchanged, and so is the mine field scene (two raw calls of its own, out of scope). The shared helper and its threshold are not touched. +- **The tests.** The existing AI cow and piloted cow specs stub DCS's `inAir()` and the shared helper on the same flag, so they cannot tell them apart. The new cases use a unit for which they disagree, the CH-47 at rest: its raw `inAir()` says "in the air" while the helper says "on the ground". +- **The CHANGELOG** records it under *Fixed*. No text, no dictionary, no configuration key, no catalogue shape. No live check and no probe: the pull request says that DCS's behaviour for the CH-47 was not re-measured. + +## Acceptance criteria + +- [ ] An AI cow that has landed deploys its FARP when the delay expires, with a unit whose raw `inAir()` says "in the air" and whose helper says "on the ground". +- [ ] A piloted cow, landed, with cow crates in its hold, deploys its FARP from **Deploy the Fat Cow FARP** and the pilot does not read "The Fat Cow FARP could not be deployed.". +- [ ] **Land here** on a landed cow answers "The Fat Cow is already on the ground." and gives the cow no new landing task. +- [ ] **Release the Fat Cow** on a landed cow gives it no orbit task and leaves its FARP open. +- [ ] A cow really in the air (both answers say so) is still refused by the deployment as "airborne", is still sent to land by **Land here**, and still orbits when released. +- [ ] The new cases fail before the change, for the right reason (the landed cow is taken for airborne), and pass after it; the other Fat Cow specs pass unchanged. +- [ ] The `CHANGELOG` entry is there; no dictionary, text or configuration change. +- [ ] `busted tests/ci/` green; luacheck clean. + +## Blocked by + +None - can start immediately. diff --git a/.backlog/README.md b/.backlog/README.md index 9b1926ea..63ca7d9e 100644 --- a/.backlog/README.md +++ b/.backlog/README.md @@ -14,6 +14,7 @@ authored **per lot, when the lot is started** (not in batch). | Lot | Status | Description | Branch | |-----|--------|-------------|--------| +| [`FIX-FAT-COW-GROUND-TEST`](FIX-FAT-COW-GROUND-TEST/PRD.md) | in progress — 1 ticket ([ask the shared ground helper](FIX-FAT-COW-GROUND-TEST/tickets/01-ask-the-shared-ground-helper.md)) | Issue #295 (found by an automated review): the Fat Cow called DCS's raw `inAir()` at three places (deploying the FARP, Land here, Release the Fat Cow) instead of `ctld.utils.inAir`, which exists for high-chassis aircraft such as the CH-47 that read "in the air" at rest. A landed cow could be refused as airborne (its FARP never opened, the piloted cow read a wrong message), or, on release, lifted off from its open FARP. The three go through the shared helper; the tests used one flag for both forms and could not tell them apart. | `fix/FIX-FAT-COW-GROUND-TEST` | | [`FIX-FAT-COW-DEPLOY-REFUSALS`](FIX-FAT-COW-DEPLOY-REFUSALS/PRD.md) | merged (PR #319) — 1 ticket ([report a refused deployment](FIX-FAT-COW-DEPLOY-REFUSALS/tickets/01-report-a-refused-deployment.md)) | Issue #296 (found by an automated review): the AI cow's deployment timer dropped the answer of `deploy`, so five of the six refusals (empty cow, airborne, scene, deployed, unknown) were silent, for the flight and for the log; the piloted cow's path already reported them. A flight whose cow was emptied, folded with Take off, then landed with Land here waited for an announced FARP that never came. The timer now reads the answer: an empty cow says so and advises RTB, the other refusals reuse the existing message, all are logged. | `fix/FIX-FAT-COW-DEPLOY-REFUSALS` | | [`FIX-FAT-COW-EMPTY-AI-TYPE`](FIX-FAT-COW-EMPTY-AI-TYPE/PRD.md) | merged (PR #318) — 1 ticket ([keep the menu with an empty type](FIX-FAT-COW-EMPTY-AI-TYPE/tickets/01-keep-the-menu-with-an-empty-type.md)) | Issue #297 (found by an automated review): an empty `fatCowAIType` removed the whole Fat Cow menu from the pilots a cow serves (eight commands, FARP status included, and the commands of cows placed by the mission), while the guide, the schema and the editor say it removes only "Request a Fat Cow". The guard moves onto that one command; the rest of the menu stays, and the four texts say why. | `fix/FIX-FAT-COW-EMPTY-AI-TYPE` | | [`FIX-FAT-COW-TAKEOVER-LABELS`](FIX-FAT-COW-TAKEOVER-LABELS/PRD.md) | merged (PR #317) — 2 tickets (01 [number the cows](FIX-FAT-COW-TAKEOVER-LABELS/tickets/01-number-the-cows.md), 02 [a stable take-over list](FIX-FAT-COW-TAKEOVER-LABELS/tickets/02-stable-take-over-list.md)) | Issue #298 (found by an automated review): the "Take over a Fat Cow" entries carried the cow's distance in their label, which is their identity (ADR 0027), and a 30 s timer rebuilt them, so an entry was recreated under the pilot's finger (a click fired a parked command and nothing happened), and two cows at the same rounded km shared a label and could be swapped. Every AI cow now has a number; the entry reads "Fat Cow #N — state", in the order of the numbers, with no distance and no periodic refresh; the three announcements name the cow and keep its distance. | `fix/FIX-FAT-COW-TAKEOVER-LABELS` | From 60296378f147c50799111e5120fe12cc1a8ea1d8 Mon Sep 17 00:00:00 2001 From: FullGas1 <51051389+FullGas1@users.noreply.github.com> Date: Wed, 18 Nov 2026 19:40:46 +0100 Subject: [PATCH 2/3] fix(fatcow): the cow asks the shared helper whether it is on the ground DCS's raw inAir() can answer "in the air" for a landed CH-47, the cow of the whole feature; ctld.utils.inAir exists for that case and the rest of CTLD uses it. The Fat Cow called the raw form at three places: the FARP deployment (a landed cow was refused as airborne: an AI cow's FARP never opened, a piloted cow's pilot read "could not be deployed"), the Land here guard ("already on the ground" never fired) and Release the Fat Cow (a landed cow was given an orbit task and lifted off from its open FARP). All three now go through the helper; a cow really in the air is treated as before. The mine field scene's raw calls are untouched. The specs now tell the two forms apart with a unit that disagrees with itself, the CH-47 at rest. Issue #295. Co-Authored-By: Claude Sonnet 5.5 --- .../01-ask-the-shared-ground-helper.md | 18 +++--- CHANGELOG.md | 5 ++ src/CTLD_fatCow.lua | 7 ++- tests/ci/unit/fatcow_ai_spec.lua | 61 +++++++++++++++++++ tests/ci/unit/fatcow_core_spec.lua | 14 ++++- tests/ci/unit/fatcow_piloted_spec.lua | 14 +++++ 6 files changed, 106 insertions(+), 13 deletions(-) diff --git a/.backlog/FIX-FAT-COW-GROUND-TEST/tickets/01-ask-the-shared-ground-helper.md b/.backlog/FIX-FAT-COW-GROUND-TEST/tickets/01-ask-the-shared-ground-helper.md index 98dd3684..97ff8129 100644 --- a/.backlog/FIX-FAT-COW-GROUND-TEST/tickets/01-ask-the-shared-ground-helper.md +++ b/.backlog/FIX-FAT-COW-GROUND-TEST/tickets/01-ask-the-shared-ground-helper.md @@ -1,6 +1,6 @@ # 01 — The Fat Cow asks the shared helper whether it is on the ground -**Status:** ⬜ ready · **Type:** AFK +**Status:** ✅ done (PR #NN) · **Type:** AFK ## Parent @@ -19,14 +19,14 @@ The Fat Cow code asks `ctld.utils.inAir`, as the rest of CTLD does, instead of D ## Acceptance criteria -- [ ] An AI cow that has landed deploys its FARP when the delay expires, with a unit whose raw `inAir()` says "in the air" and whose helper says "on the ground". -- [ ] A piloted cow, landed, with cow crates in its hold, deploys its FARP from **Deploy the Fat Cow FARP** and the pilot does not read "The Fat Cow FARP could not be deployed.". -- [ ] **Land here** on a landed cow answers "The Fat Cow is already on the ground." and gives the cow no new landing task. -- [ ] **Release the Fat Cow** on a landed cow gives it no orbit task and leaves its FARP open. -- [ ] A cow really in the air (both answers say so) is still refused by the deployment as "airborne", is still sent to land by **Land here**, and still orbits when released. -- [ ] The new cases fail before the change, for the right reason (the landed cow is taken for airborne), and pass after it; the other Fat Cow specs pass unchanged. -- [ ] The `CHANGELOG` entry is there; no dictionary, text or configuration change. -- [ ] `busted tests/ci/` green; luacheck clean. +- [x] An AI cow that has landed deploys its FARP when the delay expires, with a unit whose raw `inAir()` says "in the air" and whose helper says "on the ground". +- [x] A piloted cow, landed, with cow crates in its hold, deploys its FARP from **Deploy the Fat Cow FARP** and the pilot does not read "The Fat Cow FARP could not be deployed.". +- [x] **Land here** on a landed cow answers "The Fat Cow is already on the ground." and gives the cow no new landing task. +- [x] **Release the Fat Cow** on a landed cow gives it no orbit task and leaves its FARP open. +- [x] A cow really in the air (both answers say so) is still refused by the deployment as "airborne", is still sent to land by **Land here**, and still orbits when released. +- [x] The new cases fail before the change, for the right reason (the landed cow is taken for airborne), and pass after it; the other Fat Cow specs pass unchanged. +- [x] The `CHANGELOG` entry is there; no dictionary, text or configuration change. +- [x] `busted tests/ci/` green; luacheck clean. ## Blocked by diff --git a/CHANGELOG.md b/CHANGELOG.md index 90014809..81dfbfc3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,11 @@ Versioning follows [Semantic Versioning](https://semver.org/). ## [Unreleased] +### Fixed — the Fat Cow no longer takes a landed CH-47 for an airborne one (FIX-FAT-COW-GROUND-TEST, issue #295) + +- DCS's own `inAir()` can answer "in the air" for a high-chassis helicopter such as the CH-47, the cow of the whole feature, while it is landed and at rest. CTLD has `ctld.utils.inAir` for exactly that case, and the rest of the code uses it; the Fat Cow called the raw `inAir()` at three places. A landed cow was therefore refused by the FARP deployment as "airborne" (an AI cow's FARP never opened, and a piloted cow's pilot, on the ground with his crates in the hold, read "The Fat Cow FARP could not be deployed."), the "The Fat Cow is already on the ground." guard of **Land here** never fired, and **Release the Fat Cow** gave a landed cow an orbit task, so it lifted off from its open FARP and left it behind. + The three places now ask the shared helper. A cow really in the air is treated as before: refused by the deployment as airborne, sent to land by **Land here**, orbiting where it stands when released. The two raw calls of the mine field scene are untouched. DCS's behaviour for the CH-47 was not re-measured: the shared helper's own documentation is the premise. + ### Fixed — an AI cow that cannot open its FARP says so (FIX-FAT-COW-DEPLOY-REFUSALS, issue #296) - When an AI cow lands, a timer waits for `fatCowDeployDelay` and then asks it to open its FARP. The answer can be a refusal with a reason (empty, in the air, its scene did not start, already deployed, no such cow), and the timer threw it away: neither the flight nor the log heard of it. The piloted cow's own path already told its pilot. The simplest way to meet it needs no DCS failure: a flight empties its cow, orders **Take off** (the cow folds its FARP and stays, empty, as a player flight's cow does nothing on its own), then **Land here**; it reads "FARP open 60 s after touchdown" and waits for a FARP that never comes. diff --git a/src/CTLD_fatCow.lua b/src/CTLD_fatCow.lua index 371edb1f..fb4e872b 100644 --- a/src/CTLD_fatCow.lua +++ b/src/CTLD_fatCow.lua @@ -249,7 +249,8 @@ end function CTLDFatCowManager:deploy(unit, cow, farpName) cow = cow or self._cows[unit:getName()] if not cow then return false, "unknown" end - if unit:inAir() then return false, "airborne" end + -- The shared helper, not DCS's raw inAir(): a landed CH-47 can read "in the air" there (FIX-FAT-COW-GROUND-TEST). + if ctld.utils.inAir(unit) then return false, "airborne" end if cow.state ~= CTLDFatCow.STATE_STOWED then return false, "deployed" end if cow:isEmpty() then return false, "empty" end cow.state = CTLDFatCow.STATE_DEPLOYING @@ -1305,7 +1306,7 @@ function CTLDFatCowManager:orderLandHere(unitName) if not (t and t:isExist()) then return end local cow, u = self:_flightCowFor(t) if not cow then return end - if not u:inAir() then + if not ctld.utils.inAir(u) then trigger.action.outTextForGroup(ctld.utils.getGroupId(t), ctld.tr("The Fat Cow is already on the ground."), 10) return end @@ -1463,7 +1464,7 @@ function CTLDFatCowManager:freeAICow(unitName) if not cow then return end self._aiByFlight[cow.ai.flightGroup] = nil cow.ai.released = true - if u:inAir() and cow.ai.phase ~= CTLDFatCowManager.PHASE_LANDING then self:_orbit(cow, u:getPoint()) end + if ctld.utils.inAir(u) and cow.ai.phase ~= CTLDFatCowManager.PHASE_LANDING then self:_orbit(cow, u:getPoint()) end trigger.action.outTextForGroup(gid, ctld.tr("Fat Cow released: it stays where it is, for another flight to take over."), 10) self:_announceOrphan(cow, true) self:_rebuildMenus(cow.coalitionId) diff --git a/tests/ci/unit/fatcow_ai_spec.lua b/tests/ci/unit/fatcow_ai_spec.lua index 7ee3ff2c..7c7ad429 100644 --- a/tests/ci/unit/fatcow_ai_spec.lua +++ b/tests/ci/unit/fatcow_ai_spec.lua @@ -1025,6 +1025,67 @@ describe("AI Fat Cow", function() end) end) + -- FIX-FAT-COW-GROUND-TEST (issue #295): a landed CH-47 can read "in the air" to DCS's raw inAir(). The cow asks the + -- shared helper, which counts it as on the ground. The mock tells the two apart: its raw inAir() always says + -- "in the air", while `airborne` (what the helper reads, as in every spec of this file) says it is landed. + describe("a landed CH-47 whose raw inAir() says it flies", function() + local function atRest(cow) units[cow.unitName].inAir = function() return true end end + + it("deploys its FARP when the delay expires", function() + local leader, cow = flightWithCow() + mgr:onLand({ initiator = leader }) + mgr:onLand({ initiator = units[cow.unitName] }) + atRest(cow) + runScheduled() + assert.equals(CTLDFatCow.STATE_DEPLOYED, cow.state) + end) + + it("is told by Land here that it is already on the ground, and is not re-tasked", function() + local _, cow = flightWithCow(true) + atRest(cow) + local tasks = #groups[cow.ai.groupName].tasks + messages = {} + mgr:orderLandHere("Gunfighter-1") + assert.is_not_nil(messages[#messages].text:find("already on the ground", 1, true)) + assert.equals(tasks, #groups[cow.ai.groupName].tasks) + end) + + it("stays on the ground, its FARP open, when released", function() + local leader, cow = flightWithCow() + mgr:onLand({ initiator = leader }) + mgr:onLand({ initiator = units[cow.unitName] }) + runScheduled() + assert.equals(CTLDFatCow.STATE_DEPLOYED, cow.state) + atRest(cow) + local tasks = #groups[cow.ai.groupName].tasks + mgr:freeAICow("Gunfighter-1") + assert.equals(tasks, #groups[cow.ai.groupName].tasks) -- no orbit task: it does not lift off + assert.equals(CTLDFatCow.STATE_DEPLOYED, cow.state) + end) + + it("is still refused as airborne by the deployment when it really flies (control)", function() + local _, cow = flightWithCow() + units[cow.unitName].airborne = true + local ok, why = mgr:deploy(units[cow.unitName]) + assert.is_false(ok) + assert.equals("airborne", why) + end) + + it("is still sent to land by Land here when it really flies (control)", function() + local _, cow = flightWithCow(true) + units[cow.unitName].airborne = true + mgr:orderLandHere("Gunfighter-1") + assert.equals("Mission", lastTask(cow.ai.groupName).id) + end) + + it("still orbits where it stands when released while it really flies (control)", function() + local _, cow = flightWithCow() + units[cow.unitName].airborne = true + mgr:freeAICow("Gunfighter-1") + assert.equals("Orbit", lastTask(cow.ai.groupName).id) + end) + end) + -- ── FIX-FAT-COW-AI-LANDING ─────────────────────────────────────────────────────────────────── -- The Land task point the cow was last given, as { x, z }. diff --git a/tests/ci/unit/fatcow_core_spec.lua b/tests/ci/unit/fatcow_core_spec.lua index 2e12e44d..69b1c2f5 100644 --- a/tests/ci/unit/fatcow_core_spec.lua +++ b/tests/ci/unit/fatcow_core_spec.lua @@ -294,15 +294,27 @@ describe("CTLDFatCowManager deploy / pack", function() assert.equals("empty", why) end) + -- The deployment asks ctld.utils.inAir (FIX-FAT-COW-GROUND-TEST, issue #295), which also reads the position and + -- the speed: a cow in the air is high and moving. it("refuses to deploy a cow in the air", function() local unit = cowUnit("Cow-1") - unit.inAir = function() return true end + unit.inAir = function() return true end + unit.getPoint = function() return { x = 0, y = 150, z = 0 } end + unit.getVelocity = function() return { x = 60, y = 0, z = 0 } end mgr:addCow(unit, { fuelKg = 100, items = {} }) local ok, why = mgr:deploy(unit) assert.is_false(ok) assert.equals("airborne", why) end) + it("deploys a landed CH-47 whose raw inAir() says it flies: low and at rest, it is on the ground", function() + local unit = cowUnit("Cow-1") + unit.inAir = function() return true end -- DCS's raw answer for a high chassis + unit.getVelocity = function() return { x = 0, y = 0, z = 0 } end + mgr:addCow(unit, { fuelKg = 100, items = {} }) + assert.is_true(mgr:deploy(unit)) + end) + it("packs: reads what is left back into the stock and removes the scene", function() local unit = cowUnit("Cow-1") mgr:addCow(unit, { fuelKg = 7200, items = { [HELLFIRE] = 6 } }) diff --git a/tests/ci/unit/fatcow_piloted_spec.lua b/tests/ci/unit/fatcow_piloted_spec.lua index 176c865e..60d060cd 100644 --- a/tests/ci/unit/fatcow_piloted_spec.lua +++ b/tests/ci/unit/fatcow_piloted_spec.lua @@ -184,6 +184,20 @@ describe("Piloted cow commands", function() assert.is_not_nil(cm.crates["a"]) -- still on board end) + -- FIX-FAT-COW-GROUND-TEST (issue #295): a landed CH-47 can read "in the air" to DCS's raw inAir(); the shared helper + -- (what `airborne` stands for here) counts it as on the ground, and so must the deployment. + it("deploys a landed CH-47 whose raw inAir() says it flies, and does not tell its pilot it failed", function() + loadCrateInto("a") + units["Cow-1"].inAir = function() return true end + mgr:deployFromHold("Cow-1") + local cow = openFarp("CTLD_FatCow_FARP_1") + assert.is_not_nil(cow, "no FARP was opened") + assert.equals(CTLDFatCow.STATE_DEPLOYED, cow.state) + for _, text in ipairs(messages) do + assert.is_nil(text:find("could not be deployed", 1, true)) + end + end) + it("leaves out of the FARP a crate DCS still holds in its own cargo system", function() local native = loadCrateInto("n") native.loadedByDCSNative = true From 86cc5489b8827da3145bcae4a144f0a929572f82 Mon Sep 17 00:00:00 2001 From: FullGas1 <51051389+FullGas1@users.noreply.github.com> Date: Wed, 18 Nov 2026 19:41:02 +0100 Subject: [PATCH 3/3] docs(backlog): FIX-FAT-COW-GROUND-TEST merged (PR #320) Co-Authored-By: Claude Sonnet 5.5 --- .backlog/FIX-FAT-COW-GROUND-TEST/PRD.md | 2 +- .../tickets/01-ask-the-shared-ground-helper.md | 4 ++-- .backlog/README.md | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.backlog/FIX-FAT-COW-GROUND-TEST/PRD.md b/.backlog/FIX-FAT-COW-GROUND-TEST/PRD.md index 9bec978b..b1908252 100644 --- a/.backlog/FIX-FAT-COW-GROUND-TEST/PRD.md +++ b/.backlog/FIX-FAT-COW-GROUND-TEST/PRD.md @@ -1,6 +1,6 @@ # FIX-FAT-COW-GROUND-TEST — the Fat Cow tests for the ground with DCS's raw `inAir()`, the case `ctld.utils.inAir` exists for -**Status:** ⬜ ready — decisions taken in the grill of 2026-11-18 (no ADR, no `CONTEXT.md` term). +**Status:** ✅ done (PR #320) — decisions taken in the grill of 2026-11-18 (no ADR, no `CONTEXT.md` term). GitHub issue #295 (found by an automated review of `develop`; the code has moved since, the analysis holds). diff --git a/.backlog/FIX-FAT-COW-GROUND-TEST/tickets/01-ask-the-shared-ground-helper.md b/.backlog/FIX-FAT-COW-GROUND-TEST/tickets/01-ask-the-shared-ground-helper.md index 97ff8129..ad9691e5 100644 --- a/.backlog/FIX-FAT-COW-GROUND-TEST/tickets/01-ask-the-shared-ground-helper.md +++ b/.backlog/FIX-FAT-COW-GROUND-TEST/tickets/01-ask-the-shared-ground-helper.md @@ -1,6 +1,6 @@ # 01 — The Fat Cow asks the shared helper whether it is on the ground -**Status:** ✅ done (PR #NN) · **Type:** AFK +**Status:** ✅ done (PR #320) · **Type:** AFK ## Parent @@ -24,7 +24,7 @@ The Fat Cow code asks `ctld.utils.inAir`, as the rest of CTLD does, instead of D - [x] **Land here** on a landed cow answers "The Fat Cow is already on the ground." and gives the cow no new landing task. - [x] **Release the Fat Cow** on a landed cow gives it no orbit task and leaves its FARP open. - [x] A cow really in the air (both answers say so) is still refused by the deployment as "airborne", is still sent to land by **Land here**, and still orbits when released. -- [x] The new cases fail before the change, for the right reason (the landed cow is taken for airborne), and pass after it; the other Fat Cow specs pass unchanged. +- [x] The new cases fail before the change, for the right reason (the landed cow is taken for airborne), and pass after it; the other Fat Cow specs pass (one existing mock, which lacked a velocity, is completed now that the deployment reads it). - [x] The `CHANGELOG` entry is there; no dictionary, text or configuration change. - [x] `busted tests/ci/` green; luacheck clean. diff --git a/.backlog/README.md b/.backlog/README.md index 63ca7d9e..54da469c 100644 --- a/.backlog/README.md +++ b/.backlog/README.md @@ -14,7 +14,7 @@ authored **per lot, when the lot is started** (not in batch). | Lot | Status | Description | Branch | |-----|--------|-------------|--------| -| [`FIX-FAT-COW-GROUND-TEST`](FIX-FAT-COW-GROUND-TEST/PRD.md) | in progress — 1 ticket ([ask the shared ground helper](FIX-FAT-COW-GROUND-TEST/tickets/01-ask-the-shared-ground-helper.md)) | Issue #295 (found by an automated review): the Fat Cow called DCS's raw `inAir()` at three places (deploying the FARP, Land here, Release the Fat Cow) instead of `ctld.utils.inAir`, which exists for high-chassis aircraft such as the CH-47 that read "in the air" at rest. A landed cow could be refused as airborne (its FARP never opened, the piloted cow read a wrong message), or, on release, lifted off from its open FARP. The three go through the shared helper; the tests used one flag for both forms and could not tell them apart. | `fix/FIX-FAT-COW-GROUND-TEST` | +| [`FIX-FAT-COW-GROUND-TEST`](FIX-FAT-COW-GROUND-TEST/PRD.md) | merged (PR #320) — 1 ticket ([ask the shared ground helper](FIX-FAT-COW-GROUND-TEST/tickets/01-ask-the-shared-ground-helper.md)) | Issue #295 (found by an automated review): the Fat Cow called DCS's raw `inAir()` at three places (deploying the FARP, Land here, Release the Fat Cow) instead of `ctld.utils.inAir`, which exists for high-chassis aircraft such as the CH-47 that read "in the air" at rest. A landed cow could be refused as airborne (its FARP never opened, the piloted cow read a wrong message), or, on release, lifted off from its open FARP. The three go through the shared helper; the tests used one flag for both forms and could not tell them apart. | `fix/FIX-FAT-COW-GROUND-TEST` | | [`FIX-FAT-COW-DEPLOY-REFUSALS`](FIX-FAT-COW-DEPLOY-REFUSALS/PRD.md) | merged (PR #319) — 1 ticket ([report a refused deployment](FIX-FAT-COW-DEPLOY-REFUSALS/tickets/01-report-a-refused-deployment.md)) | Issue #296 (found by an automated review): the AI cow's deployment timer dropped the answer of `deploy`, so five of the six refusals (empty cow, airborne, scene, deployed, unknown) were silent, for the flight and for the log; the piloted cow's path already reported them. A flight whose cow was emptied, folded with Take off, then landed with Land here waited for an announced FARP that never came. The timer now reads the answer: an empty cow says so and advises RTB, the other refusals reuse the existing message, all are logged. | `fix/FIX-FAT-COW-DEPLOY-REFUSALS` | | [`FIX-FAT-COW-EMPTY-AI-TYPE`](FIX-FAT-COW-EMPTY-AI-TYPE/PRD.md) | merged (PR #318) — 1 ticket ([keep the menu with an empty type](FIX-FAT-COW-EMPTY-AI-TYPE/tickets/01-keep-the-menu-with-an-empty-type.md)) | Issue #297 (found by an automated review): an empty `fatCowAIType` removed the whole Fat Cow menu from the pilots a cow serves (eight commands, FARP status included, and the commands of cows placed by the mission), while the guide, the schema and the editor say it removes only "Request a Fat Cow". The guard moves onto that one command; the rest of the menu stays, and the four texts say why. | `fix/FIX-FAT-COW-EMPTY-AI-TYPE` | | [`FIX-FAT-COW-TAKEOVER-LABELS`](FIX-FAT-COW-TAKEOVER-LABELS/PRD.md) | merged (PR #317) — 2 tickets (01 [number the cows](FIX-FAT-COW-TAKEOVER-LABELS/tickets/01-number-the-cows.md), 02 [a stable take-over list](FIX-FAT-COW-TAKEOVER-LABELS/tickets/02-stable-take-over-list.md)) | Issue #298 (found by an automated review): the "Take over a Fat Cow" entries carried the cow's distance in their label, which is their identity (ADR 0027), and a 30 s timer rebuilt them, so an entry was recreated under the pilot's finger (a click fired a parked command and nothing happened), and two cows at the same rounded km shared a label and could be swapped. Every AI cow now has a number; the entry reads "Fat Cow #N — state", in the order of the numbers, with no distance and no periodic refresh; the three announcements name the cow and keep its distance. | `fix/FIX-FAT-COW-TAKEOVER-LABELS` |