From 9defc3ee295457b13fa19d5c1f8ba7869885d646 Mon Sep 17 00:00:00 2001 From: David Pierron Date: Tue, 24 Nov 2026 13:16:56 +0100 Subject: [PATCH 1/7] chore(backlog): open FIX-FAT-COW-STRANDED Co-Authored-By: Claude Opus 5.5 --- .backlog/FIX-FAT-COW-STRANDED/PRD.md | 42 +++++++++++++++++++ .../tickets/01-log-orders-and-phases.md | 13 ++++++ .../tickets/02-orphan-check-in-the-loop.md | 13 ++++++ .../tickets/03-bingo-fuel.md | 13 ++++++ .../tickets/04-live-check.md | 19 +++++++++ .backlog/README.md | 1 + 6 files changed, 101 insertions(+) create mode 100644 .backlog/FIX-FAT-COW-STRANDED/PRD.md create mode 100644 .backlog/FIX-FAT-COW-STRANDED/tickets/01-log-orders-and-phases.md create mode 100644 .backlog/FIX-FAT-COW-STRANDED/tickets/02-orphan-check-in-the-loop.md create mode 100644 .backlog/FIX-FAT-COW-STRANDED/tickets/03-bingo-fuel.md create mode 100644 .backlog/FIX-FAT-COW-STRANDED/tickets/04-live-check.md diff --git a/.backlog/FIX-FAT-COW-STRANDED/PRD.md b/.backlog/FIX-FAT-COW-STRANDED/PRD.md new file mode 100644 index 00000000..dc8af20a --- /dev/null +++ b/.backlog/FIX-FAT-COW-STRANDED/PRD.md @@ -0,0 +1,42 @@ +# FIX-FAT-COW-STRANDED — an AI Fat Cow lifted off its FARP and hovered until it ran out of fuel + +**Status:** 🟡 ready — analysis and decisions by the control session on 2026-11-24 (below, each with its reason). They are defaults, not questions: apply them unless the code or a measurement proves one wrong, and then say why in the PR. + +Reported by Zip through VMCT, Campagne server, evening of 2026-11-22: "a Fat Cow took off again from where its FARP (CTLD Fat Cow 1) had been, and stopped in a hover until it ran out of fuel". + +## What the log says + +`dcs.log` of the Campagne server, 2026-11-22, UTC, filtered on "Fat Cow" (the file was overwritten at the 22:28 mission restart; these lines are all that is left): + +- 15:12:07 cow `Fat Cow Hatay_AH-64D BLK.II_26 #1-1` lands in a clearing 105 m from the asked point. +- 15:25:05 scene `Fat Cow FARP#1` starts; 15:25:07 the cow is deployed, FARP `CTLD_FatCow_FARP_1`, 4,800 kg of fuel. +- 15:54:23 the FARP is packed (`packScene`, 5 objects destroyed); cow `packed`, 4,494 kg left. +- 15:54 → 21:16: no line from `CTLDFatCowManager`. +- 21:16:55 `WARN` cow `… #1-1` is no longer in the world, with no event: forgotten. + +## Analysis (control session, from the code at `e2126be`) + +- **It is an AI cow**, requested by the flight of the Apache `Hatay_AH-64D BLK.II_26` (the `Fat Cow #n` name of `requestAICow`). The piloted path of FEAT-FAT-COW-LEAVE-FARP (#286) is not involved. FIX-FAT-COW-AI-LANDING is merged (#278), not in progress. +- **What packed it at 15:54.** On an AI cow, `pack` is called by: the F10 orders **Take off** (orbit where it stands), **Hold here** (orbit over the requester), **Join us** (follow), **RTB** (land at home); the leader's take-off (`_onAITakeoff`, AI flights only, not this one); the orphan return (`_returnHome(cow, true)`, which logs "offered for take-over" — absent). So it was **one of the four F10 orders**, and none of them writes a log line. **Take off** fits the report best: it orbits at the cow's own position, 150 m AGL, 40 m/s — whether a DCS AI CH-47 flies that `Orbit` as a circle or sits in a hover is **not measured**. +- **Why it stayed up for 5 h 20 min.** A holding or following cow waits for the next order forever: nothing in the manager looks at its fuel. If the Apache player left, the orphan check should have sent it home — but that check runs **once, 2 s after** an `S_EVENT_PLAYER_LEAVE_UNIT` / `S_EVENT_DEAD`, and never again. If the client group still answers `getUnit(1)` at that instant, the cow is never sent home. Not measured either. +- **Why "no event".** The 10 s loop (`_forgetVanishedCows`) did its job: the unit vanished without `S_EVENT_DEAD` / `S_EVENT_CRASH` reaching the manager. What DCS fires for an AI helicopter that runs dry is not known; the defect is upstream (it should never have run dry). + +## Implementation Decisions + +1. **Log every order and every phase change of an AI cow** (`INFO`, cow name, order or phase, who gave it). Reason: the 5 h hole in the log made the cause unprovable; the next report must be readable. +2. **The orphan check also runs in the 10 s loop**, next to `_forgetVanishedCows`, not only 2 s after an event. Reason: one check at a fixed delay is a race against DCS removing the client unit; the loop already exists. +3. **Bingo fuel: a cow in the air with less than 25 % internal fuel (`Unit:getFuel()`) packs nothing, goes home (`_returnHome`) and tells its flight** ("The Fat Cow is low on fuel and returns home."). A constant, not a setting. Reason: whatever the order and whatever the player does, a cow must never fall out of the sky; 25 % of a CH-47 is enough to cross a map. The new text goes through `ctld.tr` and the four dictionaries. +4. **Measure, in the live check, the two premises above**: what an AI CH-47 does with the `Orbit` task of `_orbit` (circle or hover), and whether a client group still answers `getUnit(1)` 2 s after its player leaves (this one needs Zip in a slot). If the orbit is a hover, say so in the PR and propose the fix as a follow-up; do not change the orbit in this lot without the measurement. +- **No ADR.** + +## Testing Decisions + +- TDD in the existing Fat Cow spec: each order and phase change writes its line; a cow whose flight's group still exists at 2 s but is gone at the next loop tick is sent home; a cow in the air below 25 % goes home and the flight reads the message, a cow on the ground or above 25 % does not. +- Coverage ratchet only goes up; `busted tests/ci/`, luacheck, Lua 5.1 lint, the build, the i18n guard green. + +## Tickets + +- [01 log the orders and phases](tickets/01-log-orders-and-phases.md) +- [02 orphan check in the loop](tickets/02-orphan-check-in-the-loop.md) +- [03 bingo fuel](tickets/03-bingo-fuel.md) +- [04 live check](tickets/04-live-check.md) diff --git a/.backlog/FIX-FAT-COW-STRANDED/tickets/01-log-orders-and-phases.md b/.backlog/FIX-FAT-COW-STRANDED/tickets/01-log-orders-and-phases.md new file mode 100644 index 00000000..ffd457b0 --- /dev/null +++ b/.backlog/FIX-FAT-COW-STRANDED/tickets/01-log-orders-and-phases.md @@ -0,0 +1,13 @@ +# 01 — Log the orders and phases of an AI cow + +**Status:** 🟡 ready · **Type:** AFK + +## Parent +[PRD](../PRD.md), decision 1. + +## What to build +An `INFO` line for every F10 order given to an AI cow (Land here, Take off, Hold here, Join us, RTB, Release, Take over: cow name, order, requesting unit) and for every change of `cow.ai.phase` (old → new). One helper, called where the phase is set. + +## Acceptance criteria +- [ ] Each order and each phase change writes exactly one line naming the cow. +- [ ] No line per loop tick (no noise when nothing changes). diff --git a/.backlog/FIX-FAT-COW-STRANDED/tickets/02-orphan-check-in-the-loop.md b/.backlog/FIX-FAT-COW-STRANDED/tickets/02-orphan-check-in-the-loop.md new file mode 100644 index 00000000..2b290602 --- /dev/null +++ b/.backlog/FIX-FAT-COW-STRANDED/tickets/02-orphan-check-in-the-loop.md @@ -0,0 +1,13 @@ +# 02 — The orphan check also runs in the 10 s loop + +**Status:** 🟡 ready · **Type:** AFK + +## Parent +[PRD](../PRD.md), decision 2. + +## What to build +`_sendHomeOrphans` is also called by the 10 s loop that calls `_forgetVanishedCows`, so a cow whose flight disappears is sent home even when the one-shot check 2 s after the event ran too early. + +## Acceptance criteria +- [ ] A flight still present at the 2 s check and gone at the next loop tick: its cow goes home and is offered for take-over, once. +- [ ] A cow already returning is not sent home again. diff --git a/.backlog/FIX-FAT-COW-STRANDED/tickets/03-bingo-fuel.md b/.backlog/FIX-FAT-COW-STRANDED/tickets/03-bingo-fuel.md new file mode 100644 index 00000000..8ad3aebd --- /dev/null +++ b/.backlog/FIX-FAT-COW-STRANDED/tickets/03-bingo-fuel.md @@ -0,0 +1,13 @@ +# 03 — Bingo fuel: a cow low on fuel goes home + +**Status:** 🟡 ready · **Type:** AFK + +## Parent +[PRD](../PRD.md), decision 3. + +## What to build +In the 10 s loop, an AI cow in the air (`ctld.utils.inAir`) whose `getFuel()` is below 25 %, and not already returning, goes home through `_returnHome` and its flight reads "The Fat Cow is low on fuel and returns home." (new `ctld.tr` key, four dictionaries). Logged as `WARN` with the fuel fraction. Pilot guide EN+FR: one sentence on it. CHANGELOG *Fixed* entry. + +## Acceptance criteria +- [ ] Holding, following or released cow in the air below 25 %: goes home, message once, log once. +- [ ] A cow on the ground, already returning, or at 25 % or more: unchanged. diff --git a/.backlog/FIX-FAT-COW-STRANDED/tickets/04-live-check.md b/.backlog/FIX-FAT-COW-STRANDED/tickets/04-live-check.md new file mode 100644 index 00000000..3a422a8f --- /dev/null +++ b/.backlog/FIX-FAT-COW-STRANDED/tickets/04-live-check.md @@ -0,0 +1,19 @@ +# 04 — Live check and the two measurements + +**Status:** 🟡 ready · **Type:** HITL for (b) (Zip in a slot), AFK otherwise; Zip launches DCS, the session launches dcs-serve + +## Parent +[PRD](../PRD.md), decision 4. Blocked by 01-03. + +## What to build +On `Test_CTLDNEXT_01.miz`, over the DCS bridge: + +- (a) An AI cow given **Take off**: record its speed and position over two minutes. Circle or hover? +- (b) With Zip in a helicopter slot that requested a cow: Zip leaves the slot; record whether his group still answers `getUnit(1)` at 2 s, 5 s, 10 s, and that the cow goes home. +- (c) Bingo: set the cow's fuel low (or wait with a reduced fuel load) and check it goes home with the message. +- (d) The orders and phases appear in `dcs.log`. + +## Acceptance criteria +- [ ] (a)-(d) recorded PASS/FAIL or as measured values, with the log lines. +- [ ] If (a) is a hover, the PR says so and proposes the fix as a follow-up lot. +- [ ] Nothing left in the mission afterwards. diff --git a/.backlog/README.md b/.backlog/README.md index 8359f043..08790ab7 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-STRANDED`](FIX-FAT-COW-STRANDED/PRD.md) | ready — 4 tickets (01 [log the orders and phases](FIX-FAT-COW-STRANDED/tickets/01-log-orders-and-phases.md), 02 [orphan check in the loop](FIX-FAT-COW-STRANDED/tickets/02-orphan-check-in-the-loop.md), 03 [bingo fuel](FIX-FAT-COW-STRANDED/tickets/03-bingo-fuel.md), 04 [live check](FIX-FAT-COW-STRANDED/tickets/04-live-check.md)) | Zip via VMCT, Campagne server, 2026-11-22: an AI cow packed its FARP on an F10 order nobody logged, lifted off and hovered for 5 h until it ran out of fuel. Log every order and phase, run the orphan check in the 10 s loop, send a cow home below 25 % fuel, and measure what the `Orbit` task and a player leaving really do. | `fix/FIX-FAT-COW-STRANDED` | | [`FIX-VMCT-REVIEW-FINDINGS`](FIX-VMCT-REVIEW-FINDINGS/PRD.md) | merged (PR #330) — 06 ✅ live scenario PASS 10/10 (2026-11-23) — 7 tickets (01 [parachuted troops keep their template](FIX-VMCT-REVIEW-FINDINGS/tickets/01-parachuted-troops-keep-their-template.md), 02 [inactive zones stay inactive](FIX-VMCT-REVIEW-FINDINGS/tickets/02-inactive-zones-stay-inactive.md), 03 [repair crates from the menu](FIX-VMCT-REVIEW-FINDINGS/tickets/03-repair-crates-from-the-menu.md), 04 [unique AA group name](FIX-VMCT-REVIEW-FINDINGS/tickets/04-unique-aa-group-name.md), 05 [player name in coalition messages](FIX-VMCT-REVIEW-FINDINGS/tickets/05-player-name-in-coalition-messages.md), 06 [live check](FIX-VMCT-REVIEW-FINDINGS/tickets/06-live-check.md), 07 [backlog housekeeping](FIX-VMCT-REVIEW-FINDINGS/tickets/07-backlog-housekeeping.md)) | Issues #322-#326 (VMCT review of `develop`, 2026-11-19): parachuted troops all land as "Soldier AK"; inactive troop/waypoint zones load active; the six "… Repair" crates cannot be requested from the menu; two AA systems of the same type spawned in the same second share a group name; FOB and SAM coalition messages name the unit instead of the player. | `fix/FIX-VMCT-REVIEW-FINDINGS` | | [`FEAT-VMCT-V1-PARITY`](FEAT-VMCT-V1-PARITY/PRD.md) | merged (PR #329) — verified in game (live scenario 15/15, 2026-11-23) — 3 tickets (01 [spawned units player can drive](FEAT-VMCT-V1-PARITY/tickets/01-spawned-units-player-can-drive.md), 02 [link crates and groups in events](FEAT-VMCT-V1-PARITY/tickets/02-link-crates-and-groups-in-events.md), 03 [live check](FEAT-VMCT-V1-PARITY/tickets/03-live-check.md)) | Issues #327, #328 (VMCT): units spawned by a CTLD gesture are drivable again (new setting `spawnedUnitsPlayerCanDrive`, default `true` as in v1); unpack, rearm and repair events carry both the crates and the spawned group. | `feat/FEAT-VMCT-V1-PARITY` | From c7c498acb664b20194c3ead4f89dbbced5d52326 Mon Sep 17 00:00:00 2001 From: David Pierron Date: Tue, 24 Nov 2026 13:23:15 +0100 Subject: [PATCH 2/7] feat(fatcow): log every order and phase change of an AI cow (FIX-FAT-COW-STRANDED 01) --- src/CTLD_fatCow.lua | 31 +++++++++-- tests/ci/unit/fatcow_ai_spec.lua | 92 ++++++++++++++++++++++++++++++++ 2 files changed, 118 insertions(+), 5 deletions(-) diff --git a/src/CTLD_fatCow.lua b/src/CTLD_fatCow.lua index fb4e872b..792ede6d 100644 --- a/src/CTLD_fatCow.lua +++ b/src/CTLD_fatCow.lua @@ -1041,12 +1041,26 @@ function CTLDFatCowManager:aiCowOfFlight(flightGroup) return self._aiByFlight and self._aiByFlight[flightGroup] or nil end +--- Sets the phase of an AI cow and logs the change; nothing is written when the phase does not change +-- (FIX-FAT-COW-STRANDED: a cow that hovered for 5 h left no trace of what had sent it there). +function CTLDFatCowManager:_setPhase(cow, phase) + local old = cow.ai.phase + if old == phase then return end + cow.ai.phase = phase + ctld.utils.log("INFO", "CTLDFatCowManager: cow '%s' phase %s -> %s", cow.unitName, tostring(old), tostring(phase)) +end + +--- Logs an order given to an AI cow, with the unit that gave it. +function CTLDFatCowManager:_logOrder(cow, order, fromUnit) + ctld.utils.log("INFO", "CTLDFatCowManager: cow '%s' order '%s' from '%s'", cow.unitName, order, tostring(fromUnit)) +end + function CTLDFatCowManager:_follow(cow) local flight = Group.getByName(cow.ai.flightGroup) local ctrl = controllerOf(cow.ai.groupName) if not (flight and flight:isExist() and ctrl) then return false end ctrl:setTask({ id = "Follow", params = { groupId = flight:getID(), pos = FOLLOW_OFFSET, lastWptIndexFlag = false } }) - cow.ai.phase = CTLDFatCowManager.PHASE_FOLLOWING + self:_setPhase(cow, CTLDFatCowManager.PHASE_FOLLOWING) return true end @@ -1145,7 +1159,7 @@ function CTLDFatCowManager:_landNextTo(cow, leader) LZ_SEARCH_M, cow.unitName) end ctrl:setTask(landMission(point)) - cow.ai.phase = CTLDFatCowManager.PHASE_LANDING + self:_setPhase(cow, CTLDFatCowManager.PHASE_LANDING) end -- @param orphaned boolean its flight is lost: the flights that could take it over are told @@ -1154,7 +1168,7 @@ function CTLDFatCowManager:_returnHome(cow, orphaned) if cow.state ~= CTLDFatCow.STATE_STOWED then self:pack(cow.unitName) end local ctrl = controllerOf(cow.ai.groupName) if ctrl and cow.ai.home then ctrl:setTask(landMission(cow.ai.home)) end - cow.ai.phase = CTLDFatCowManager.PHASE_RETURNING + self:_setPhase(cow, CTLDFatCowManager.PHASE_RETURNING) if self._aiByFlight then self._aiByFlight[cow.ai.flightGroup] = nil end if orphaned then self:_announceOrphan(cow) end self:_rebuildMenus(cow.coalitionId) @@ -1234,7 +1248,7 @@ function CTLDFatCowManager:onLand(event) if g and g:isExist() then g:destroy() end self:_rebuildMenus(cow.coalitionId) elseif cow.ai.phase == CTLDFatCowManager.PHASE_LANDING then - cow.ai.phase = CTLDFatCowManager.PHASE_LANDED + self:_setPhase(cow, CTLDFatCowManager.PHASE_LANDED) local mgr = self cow.ai.deployTimer = ctld.scheduler.schedule(function() cow.ai.deployTimer = nil @@ -1288,7 +1302,7 @@ function CTLDFatCowManager:_orbit(cow, point) if not ctrl then return end ctrl:setTask({ id = "Orbit", params = { pattern = "Circle", point = { x = point.x, y = point.z }, altitude = land.getHeight({ x = point.x, y = point.z }) + CRUISE_ALT_M, speed = ORBIT_SPEED_MPS } }) - cow.ai.phase = CTLDFatCowManager.PHASE_HOLDING + self:_setPhase(cow, CTLDFatCowManager.PHASE_HOLDING) end --- The cow of the requester's flight, or nil after telling the requester there is none. @@ -1306,6 +1320,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 + self:_logOrder(cow, "Land here", unitName) 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 @@ -1321,6 +1336,7 @@ function CTLDFatCowManager:orderTakeOff(unitName) if not (t and t:isExist()) then return end local cow, u = self:_flightCowFor(t) if not cow then return end + self:_logOrder(cow, "Take off", unitName) self:_readyToMove(cow) self:_orbit(cow, u:getPoint()) trigger.action.outTextForGroup(ctld.utils.getGroupId(t), ctld.tr("Fat Cow taking off: it orbits where it stands."), 10) @@ -1332,6 +1348,7 @@ function CTLDFatCowManager:orderHoldHere(unitName) if not (t and t:isExist()) then return end local cow = self:_flightCowFor(t) if not cow then return end + self:_logOrder(cow, "Hold here", unitName) self:_readyToMove(cow) self:_orbit(cow, t:getPoint()) trigger.action.outTextForGroup(ctld.utils.getGroupId(t), ctld.tr("Fat Cow holding over your position."), 10) @@ -1343,6 +1360,7 @@ function CTLDFatCowManager:orderJoin(unitName) if not (t and t:isExist()) then return end local cow = self:_flightCowFor(t) if not cow then return end + self:_logOrder(cow, "Join us", unitName) self:_readyToMove(cow) self:_follow(cow) trigger.action.outTextForGroup(ctld.utils.getGroupId(t), ctld.tr("Fat Cow joining your flight."), 10) @@ -1450,6 +1468,7 @@ function CTLDFatCowManager:releaseAICow(unitName) trigger.action.outTextForGroup(ctld.utils.getGroupId(t), ctld.tr("Your flight has no Fat Cow."), 10) return end + self:_logOrder(cow, "RTB", unitName) self:_returnHome(cow) trigger.action.outTextForGroup(ctld.utils.getGroupId(t), ctld.tr("Fat Cow RTB."), 10) end @@ -1462,6 +1481,7 @@ function CTLDFatCowManager:freeAICow(unitName) local gid = ctld.utils.getGroupId(t) local cow, u = self:_flightCowFor(t) if not cow then return end + self:_logOrder(cow, "Release", unitName) self._aiByFlight[cow.ai.flightGroup] = nil cow.ai.released = true if ctld.utils.inAir(u) and cow.ai.phase ~= CTLDFatCowManager.PHASE_LANDING then self:_orbit(cow, u:getPoint()) end @@ -1572,6 +1592,7 @@ function CTLDFatCowManager:takeOverAICow(unitName, cowUnitName) local d = ctld.utils.getDistance("CTLDFatCowManager", t:getPoint(), u:getPoint()) ctld.utils.log("INFO", "CTLDFatCowManager: cow '%s' taken over by flight '%s' (was '%s')", cow.unitName, flight, cow.ai.flightGroup) + self:_logOrder(cow, "Take over", unitName) cow.ai.flightGroup = flight cow.ai.released = nil self._aiByFlight = self._aiByFlight or {} diff --git a/tests/ci/unit/fatcow_ai_spec.lua b/tests/ci/unit/fatcow_ai_spec.lua index 7c7ad429..2b77e563 100644 --- a/tests/ci/unit/fatcow_ai_spec.lua +++ b/tests/ci/unit/fatcow_ai_spec.lua @@ -1357,4 +1357,96 @@ describe("AI Fat Cow", function() mgr:freeAICow("Gunfighter-1") assert.is_not_nil(messages[#messages].text:find("no Fat Cow", 1, true)) end) + + -- FIX-FAT-COW-STRANDED 01: a cow that hovered for 5 h left no line in the log (Campagne, 2026-11-22). + describe("logs every order and phase change of the cow", function() + local logs, savedLog + + before_each(function() + logs, savedLog = {}, ctld.utils.log + ctld.utils.log = function(level, fmt, ...) + local ok, text = pcall(string.format, fmt, ...) + logs[#logs + 1] = { level = level, text = ok and text or fmt } + end + end) + after_each(function() ctld.utils.log = savedLog end) + + -- The INFO lines that name `cow` and contain every needle. + local function lines(cow, ...) + local needles, out = { ... }, {} + for _, l in ipairs(logs) do + local all = l.level == "INFO" and l.text:find(cow.unitName, 1, true) ~= nil + for _, n in ipairs(needles) do all = all and l.text:find(n, 1, true) ~= nil end + if all then out[#out + 1] = l.text end + end + return out + end + + it("writes one order line naming the cow and the requester, and one phase line, for Take off", function() + local _, cow = flightWithCow(true) + logs = {} + mgr:orderTakeOff("Gunfighter-1") + local order = lines(cow, "order", "Take off", "Gunfighter-1") + assert.equals(1, #order) + local phase = lines(cow, "phase following -> holding") + assert.equals(1, #phase) + end) + + it("logs Hold here, Join us and Land here with the unit that gave them", function() + local _, cow = flightWithCow(true) + units[cow.unitName].airborne = true + logs = {} + mgr:orderHoldHere("Gunfighter-1") + assert.equals(1, #lines(cow, "order", "Hold here", "Gunfighter-1")) + mgr:orderJoin("Gunfighter-1") + assert.equals(1, #lines(cow, "order", "Join us", "Gunfighter-1")) + assert.equals(1, #lines(cow, "phase holding -> following")) + mgr:orderLandHere("Gunfighter-1") + assert.equals(1, #lines(cow, "order", "Land here", "Gunfighter-1")) + assert.equals(1, #lines(cow, "phase following -> landing")) + end) + + it("logs RTB, Release and Take over", function() + local _, cow = flightWithCow(true) + units[cow.unitName].airborne = true + logs = {} + mgr:freeAICow("Gunfighter-1") + assert.equals(1, #lines(cow, "order", "Release", "Gunfighter-1")) + newGroup("Viper", 8, "Viper-1") + newUnit("Viper-1", "Viper") + mgr:takeOverAICow("Viper-1", cow.unitName) + assert.equals(1, #lines(cow, "order", "Take over", "Viper-1")) + logs = {} + mgr:releaseAICow("Viper-1") + assert.equals(1, #lines(cow, "order", "RTB", "Viper-1")) + assert.equals(1, #lines(cow, "phase following -> returning")) + end) + + it("logs the landing and the end of the landing as phase changes", function() + local leader, cow = flightWithCow() + logs = {} + mgr:onLand({ initiator = leader }) + assert.equals(1, #lines(cow, "phase following -> landing")) + mgr:onLand({ initiator = units[cow.unitName] }) + assert.equals(1, #lines(cow, "phase landing -> landed")) + end) + + it("writes nothing more while nothing changes, loop ticks included", function() + local _, cow = flightWithCow(true) + mgr:orderHoldHere("Gunfighter-1") + logs = {} + mgr:_resyncFarps() + mgr:_resyncFarps() + assert.equals(0, #lines(cow)) + end) + + it("writes no phase line when an order leaves the phase as it was", function() + local _, cow = flightWithCow(true) + mgr:orderHoldHere("Gunfighter-1") + logs = {} + mgr:orderHoldHere("Gunfighter-1") + assert.equals(1, #lines(cow, "order", "Hold here")) + assert.equals(0, #lines(cow, "phase")) + end) + end) end) From 3a35e7165cfdef8c249703dd9dbce223c273f5c4 Mon Sep 17 00:00:00 2001 From: David Pierron Date: Tue, 24 Nov 2026 13:24:15 +0100 Subject: [PATCH 3/7] fix(fatcow): run the orphan check in the 10 s loop too (FIX-FAT-COW-STRANDED 02) --- src/CTLD_fatCow.lua | 4 ++- tests/ci/unit/fatcow_ai_spec.lua | 60 ++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 1 deletion(-) diff --git a/src/CTLD_fatCow.lua b/src/CTLD_fatCow.lua index 792ede6d..598066a0 100644 --- a/src/CTLD_fatCow.lua +++ b/src/CTLD_fatCow.lua @@ -361,6 +361,7 @@ local RESYNC_PERIOD_S = 10 -- emptied (it stays in the world, and a refill would make it serve next to another cow's depot). function CTLDFatCowManager:_resyncFarps() self:_forgetVanishedCows() + self:_sendHomeOrphans() local open = {} for _, cow in pairs(self._cows) do if cow.state == CTLDFatCow.STATE_DEPLOYED then @@ -825,7 +826,8 @@ function CTLDFatCowManager:_checkFlightsLater() ctld.scheduler.schedule(function() mgr:_sendHomeOrphans() end, nil, timer.getTime() + 2) end ---- An AI cow whose flight is no longer in the world packs and goes home. +--- An AI cow whose flight is no longer in the world packs and goes home. Run 2 s after a death or a player leaving, and +-- by the 10 s loop: that one check is a race against DCS removing the client unit (FIX-FAT-COW-STRANDED, 2026-11-22). function CTLDFatCowManager:_sendHomeOrphans() for flight, cow in pairs(self._aiByFlight or {}) do local g = Group.getByName(flight) diff --git a/tests/ci/unit/fatcow_ai_spec.lua b/tests/ci/unit/fatcow_ai_spec.lua index 2b77e563..c9fd35a5 100644 --- a/tests/ci/unit/fatcow_ai_spec.lua +++ b/tests/ci/unit/fatcow_ai_spec.lua @@ -1449,4 +1449,64 @@ describe("AI Fat Cow", function() assert.equals(0, #lines(cow, "phase")) end) end) + + -- FIX-FAT-COW-STRANDED 02: the orphan check ran once, 2 s after the event, a race against DCS removing the unit. + describe("sends home a cow whose flight is gone, also from the 10 s loop", function() + local logs, savedLog + + before_each(function() + logs, savedLog = {}, ctld.utils.log + ctld.utils.log = function(level, fmt, ...) + local ok, text = pcall(string.format, fmt, ...) + logs[#logs + 1] = { level = level, text = ok and text or fmt } + end + end) + after_each(function() ctld.utils.log = savedLog end) + + local function offers() + local n = 0 + for _, l in ipairs(logs) do if l.text:find("offered for take-over", 1, true) then n = n + 1 end end + return n + end + + it("catches a flight still there at the 2 s check and gone at the next tick, once", function() + local _, cow = flightWithCow(true) + mgr:onPlayerLeave({}) -- the player left; the group still answers + runScheduled() -- the 2 s check finds it there + assert.equals(CTLDFatCowManager.PHASE_FOLLOWING, cow.ai.phase) + groups["Gunfighter"].destroyed = true -- DCS removes the client group a moment later + mgr:_resyncFarps() -- the 10 s loop + assert.equals(CTLDFatCowManager.PHASE_RETURNING, cow.ai.phase) + assert.is_nil(mgr:aiCowOfFlight("Gunfighter")) + assert.equals(1, offers()) + mgr:_resyncFarps() + mgr:_resyncFarps() + assert.equals(1, offers()) + end) + + it("catches a flight whose first unit is gone while the group still exists", function() + local _, cow = flightWithCow(true) + units["Gunfighter-1"] = nil + mgr:_resyncFarps() + assert.equals(CTLDFatCowManager.PHASE_RETURNING, cow.ai.phase) + assert.equals(1, offers()) + end) + + it("leaves a cow already returning alone", function() + local _, cow = flightWithCow(true) + mgr:releaseAICow("Gunfighter-1") -- RTB: no longer the flight's cow + groups["Gunfighter"].destroyed = true + logs = {} + mgr:_resyncFarps() + assert.equals(0, offers()) + assert.equals(CTLDFatCowManager.PHASE_RETURNING, cow.ai.phase) + end) + + it("leaves a cow whose flight is still there alone", function() + local _, cow = flightWithCow(true) + mgr:_resyncFarps() + assert.equals(CTLDFatCowManager.PHASE_FOLLOWING, cow.ai.phase) + assert.equals(0, offers()) + end) + end) end) From 276cc93f2b08a49bd4342e820a37feebf1b76979 Mon Sep 17 00:00:00 2001 From: David Pierron Date: Tue, 24 Nov 2026 13:25:42 +0100 Subject: [PATCH 4/7] fix(fatcow): an AI cow low on fuel in the air goes home (FIX-FAT-COW-STRANDED 03) --- CHANGELOG.md | 7 ++ docs/pilot/fat-cow.fr.md | 2 + docs/pilot/fat-cow.md | 2 + src/CTLD_fatCow.lua | 34 +++++++- src/CTLD_i18n_en.lua | 5 +- src/CTLD_i18n_es.lua | 5 +- src/CTLD_i18n_fr.lua | 5 +- src/CTLD_i18n_ko.lua | 5 +- tests/ci/unit/fatcow_ai_spec.lua | 129 +++++++++++++++++++++++++++++++ 9 files changed, 189 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b4491326..f0737248 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,13 @@ Versioning follows [Semantic Versioning](https://semver.org/). ## [Unreleased] +### Fixed — an AI Fat Cow no longer hovers until it runs dry (FIX-FAT-COW-STRANDED) + +- Campagne server, 2026-11-22: an AI cow packed its FARP on an F10 order, then flew on for 5 h 20 min until it ran out of fuel and vanished, and the log had no line in between. Three changes: + **Bingo fuel**: an AI cow in the air with less than 25 % of its internal fuel (`Unit.getFuel`) goes home whatever it was told (holding, following or released; one that is landing lands), and its flight reads "The Fat Cow is low on fuel and returns home." (new text, four dictionaries). Logged as a `WARN` with the fuel fraction. The pilot guide says so, in English and French. + **Orphan check in the loop**: a cow whose flight is gone was sent home by a single check 2 s after the event, a race against DCS removing the client unit. The 10 s loop now runs the same check, so the cow goes home even when the one-shot ran too early. + **A readable log**: every F10 order given to an AI cow (Land here, Take off, Hold here, Join us, RTB, Release, Take over: cow, order, requesting unit) and every change of its phase writes one `INFO` line, none per loop tick. + --- ## [2.1.0] — 2026-11-23 diff --git a/docs/pilot/fat-cow.fr.md b/docs/pilot/fat-cow.fr.md index 9852893b..475d4466 100644 --- a/docs/pilot/fat-cow.fr.md +++ b/docs/pilot/fat-cow.fr.md @@ -69,6 +69,8 @@ Vous pouvez donc redécoller pour vous déplacer en stationnaire jusqu'à sa FAR Une cow qui n'a plus rien n'ouvre pas de FARP : vous le lisez quand le délai s'écoule, avec le conseil de la renvoyer avec **Rentre à la base**. +Une cow en l'air qui a moins d'un quart de son carburant rentre toute seule à la base, quel que soit l'ordre reçu (en attente, en suivi ou libérée), et votre patrouille lit « La Fat Cow n'a presque plus de carburant et rentre à la base. » + **Statut Fat Cow** dit où est la cow de votre patrouille (phase, distance et relèvement), quand elle devrait vous rejoindre, et ce qu'elle contient encore, y compris avant qu'elle se soit posée. **Demander une Fat Cow** ouvre la liste des lots, les mêmes que ceux d'une cow pilotée (Apache en tête, **Russes** et **Mixtes** un niveau plus bas) : choisissez ce dont votre patrouille a besoin. diff --git a/docs/pilot/fat-cow.md b/docs/pilot/fat-cow.md index aa7a98dd..42efe2e5 100644 --- a/docs/pilot/fat-cow.md +++ b/docs/pilot/fat-cow.md @@ -69,6 +69,8 @@ So you can lift off to hover-taxi onto its FARP, or reposition, without the cow A cow with nothing left opens no FARP: you are told when the delay runs out, with the advice to send it home with **RTB**. +A cow in the air with less than a quarter of its fuel left goes home by itself, whatever it was told (holding, following or released), and your flight reads "The Fat Cow is low on fuel and returns home." + **Fat Cow status** tells where your flight's cow is (phase, distance and bearing), when it should join, and what it still holds, before it has landed too. **Request a Fat Cow** opens the list of loadouts, the same as a piloted cow's (Apache at the top, **Russian** and **Mixed** one level down): pick what your flight needs. diff --git a/src/CTLD_fatCow.lua b/src/CTLD_fatCow.lua index 598066a0..8a53d313 100644 --- a/src/CTLD_fatCow.lua +++ b/src/CTLD_fatCow.lua @@ -362,6 +362,7 @@ local RESYNC_PERIOD_S = 10 function CTLDFatCowManager:_resyncFarps() self:_forgetVanishedCows() self:_sendHomeOrphans() + self:_sendHomeLowFuel() local open = {} for _, cow in pairs(self._cows) do if cow.state == CTLDFatCow.STATE_DEPLOYED then @@ -1171,7 +1172,7 @@ function CTLDFatCowManager:_returnHome(cow, orphaned) local ctrl = controllerOf(cow.ai.groupName) if ctrl and cow.ai.home then ctrl:setTask(landMission(cow.ai.home)) end self:_setPhase(cow, CTLDFatCowManager.PHASE_RETURNING) - if self._aiByFlight then self._aiByFlight[cow.ai.flightGroup] = nil end + if self._aiByFlight and self._aiByFlight[cow.ai.flightGroup] == cow then self._aiByFlight[cow.ai.flightGroup] = nil end if orphaned then self:_announceOrphan(cow) end self:_rebuildMenus(cow.coalitionId) end @@ -1226,6 +1227,37 @@ function CTLDFatCowManager:_reportRefusedDeploy(cow, why) or ctld.tr("The Fat Cow FARP could not be deployed.")) end +-- Below this fraction of its internal fuel (Unit.getFuel), an AI cow in the air goes home whatever it was told: a +-- holding or following cow waits for the next order forever, and one ran dry after 5 h (FIX-FAT-COW-STRANDED, +-- 2026-11-22). A quarter of a CH-47's tanks crosses a map. +local BINGO_FUEL = 0.25 + +--- An AI cow in the air with less than BINGO_FUEL left packs nothing (it is not deployed in the air), goes home and +-- tells its flight, one that holds, follows or was released alike. One that is landing lands, a returning one is +-- already on its way. Run by the 10 s loop, so once per cow: it is returning afterwards. +function CTLDFatCowManager:_sendHomeLowFuel() + local low = {} + for name, cow in pairs(self._cows) do + local phase = cow.ai and cow.ai.phase + if phase and phase ~= CTLDFatCowManager.PHASE_RETURNING and phase ~= CTLDFatCowManager.PHASE_LANDING then + local u = Unit.getByName(name) + if u and u:isExist() and ctld.utils.inAir(u) then + local ok, fuel = pcall(function() return u:getFuel() end) + if ok and type(fuel) == "number" and fuel < BINGO_FUEL then low[#low + 1] = { cow = cow, fuel = fuel } end + end + end + end + for _, l in ipairs(low) do + local cow = l.cow + ctld.utils.log("WARN", "CTLDFatCowManager: cow '%s' is low on fuel (%.2f of its tanks, phase %s): sent home", + cow.unitName, l.fuel, tostring(cow.ai.phase)) + local gid = flightGroupId(cow) + if gid then trigger.action.outTextForGroup(gid, ctld.tr("The Fat Cow is low on fuel and returns home."), 15) end + cow.ai.released = nil + self:_returnHome(cow) + end +end + --- S_EVENT_LAND: the cow lands → it deploys after fatCowDeployDelay, or despawns when it was going home; -- an AI flight's leader lands → its cow lands next to it (a player flight uses "Land here"). function CTLDFatCowManager:onLand(event) diff --git a/src/CTLD_i18n_en.lua b/src/CTLD_i18n_en.lua index fd0f784f..42b928b9 100644 --- a/src/CTLD_i18n_en.lua +++ b/src/CTLD_i18n_en.lua @@ -15,7 +15,7 @@ if not ctld then ctld = {} end if not ctld.i18n then ctld.i18n = {} end ctld.i18n["en"] = {} -ctld.i18n["en"].translation_version = "1.41" +ctld.i18n["en"].translation_version = "1.42" --- groups names ctld.i18n["en"]["Standard Group"] = "Standard Group" @@ -747,3 +747,6 @@ ctld.i18n["en"]["Fat Cow #%1 — waiting"] = "Fat Cow #%1 — waiting" --- Keys added by generate_i18n_dicts.ps1 on 2026-11-18 ctld.i18n["en"]["The Fat Cow is empty: send it home with RTB."] = "The Fat Cow is empty: send it home with RTB." + +--- Keys added by generate_i18n_dicts.ps1 on 2026-11-24 +ctld.i18n["en"]["The Fat Cow is low on fuel and returns home."] = "The Fat Cow is low on fuel and returns home." diff --git a/src/CTLD_i18n_es.lua b/src/CTLD_i18n_es.lua index 0bbd6372..3279b9c3 100644 --- a/src/CTLD_i18n_es.lua +++ b/src/CTLD_i18n_es.lua @@ -10,7 +10,7 @@ if not ctld then ctld = {} end if not ctld.i18n then ctld.i18n = {} end ctld.i18n["es"] = {} -ctld.i18n["es"].translation_version = "1.41" +ctld.i18n["es"].translation_version = "1.42" --- groups names ctld.i18n["es"]["Standard Group"] = "Grupo estándar" @@ -754,3 +754,6 @@ ctld.i18n["es"]["Fat Cow #%1 — waiting"] = "Fat Cow #%1 — en espera" --- Keys added by generate_i18n_dicts.ps1 on 2026-11-18 ctld.i18n["es"]["The Fat Cow is empty: send it home with RTB."] = "El Fat Cow está vacío: envíalo de vuelta con « Regresa a la base »." + +--- Keys added by generate_i18n_dicts.ps1 on 2026-11-24 +ctld.i18n["es"]["The Fat Cow is low on fuel and returns home."] = "El Fat Cow tiene poco combustible y regresa a la base." diff --git a/src/CTLD_i18n_fr.lua b/src/CTLD_i18n_fr.lua index 349c62a3..657e41a1 100644 --- a/src/CTLD_i18n_fr.lua +++ b/src/CTLD_i18n_fr.lua @@ -9,7 +9,7 @@ if not ctld then ctld = {} end if not ctld.i18n then ctld.i18n = {} end ctld.i18n["fr"] = {} -ctld.i18n["fr"].translation_version = "1.41" +ctld.i18n["fr"].translation_version = "1.42" --- groups names ctld.i18n["fr"]["Standard Group"] = "Groupe standard" @@ -779,3 +779,6 @@ ctld.i18n["fr"]["Fat Cow #%1 — waiting"] = "Fat Cow #%1 — en attente" --- Keys added by generate_i18n_dicts.ps1 on 2026-11-18 ctld.i18n["fr"]["The Fat Cow is empty: send it home with RTB."] = "La Fat Cow est vide : renvoyez-la avec « Rentre à la base »." + +--- Keys added by generate_i18n_dicts.ps1 on 2026-11-24 +ctld.i18n["fr"]["The Fat Cow is low on fuel and returns home."] = "La Fat Cow n'a presque plus de carburant et rentre à la base." diff --git a/src/CTLD_i18n_ko.lua b/src/CTLD_i18n_ko.lua index a31c54b5..0b82c4b9 100644 --- a/src/CTLD_i18n_ko.lua +++ b/src/CTLD_i18n_ko.lua @@ -10,7 +10,7 @@ if not ctld then ctld = {} end if not ctld.i18n then ctld.i18n = {} end ctld.i18n["ko"] = {} -ctld.i18n["ko"].translation_version = "1.41" +ctld.i18n["ko"].translation_version = "1.42" --- groups names ctld.i18n["ko"]["Standard Group"] = "표준 그룹" @@ -637,3 +637,6 @@ ctld.i18n["ko"]["Fat Cow #%1 — waiting"] = "Fat Cow #%1 — 대기 중" --- Keys added by generate_i18n_dicts.ps1 on 2026-11-18 ctld.i18n["ko"]["The Fat Cow is empty: send it home with RTB."] = "Fat Cow가 비었습니다. « 기지로 귀환 »으로 돌려보내세요." + +--- Keys added by generate_i18n_dicts.ps1 on 2026-11-24 +ctld.i18n["ko"]["The Fat Cow is low on fuel and returns home."] = "Fat Cow의 연료가 부족하여 기지로 귀환합니다." diff --git a/tests/ci/unit/fatcow_ai_spec.lua b/tests/ci/unit/fatcow_ai_spec.lua index c9fd35a5..d644861a 100644 --- a/tests/ci/unit/fatcow_ai_spec.lua +++ b/tests/ci/unit/fatcow_ai_spec.lua @@ -1509,4 +1509,133 @@ describe("AI Fat Cow", function() assert.equals(0, offers()) end) end) + + -- FIX-FAT-COW-STRANDED 03: a cow in the air must never fall out of the sky, whatever it was last told. + describe("goes home when low on fuel", function() + local logs, savedLog + local LOW = "The Fat Cow is low on fuel and returns home." + + before_each(function() + logs, savedLog = {}, ctld.utils.log + ctld.utils.log = function(level, fmt, ...) + local ok, text = pcall(string.format, fmt, ...) + logs[#logs + 1] = { level = level, text = ok and text or fmt } + end + end) + after_each(function() ctld.utils.log = savedLog end) + + local function said() + local n = 0 + for _, m in ipairs(messages) do if m.text == LOW then n = n + 1 end end + return n + end + + local function warned(needle) + local n = 0 + for _, l in ipairs(logs) do + if l.level == "WARN" and l.text:find(needle, 1, true) then n = n + 1 end + end + return n + end + + -- A player flight's cow, in the air with `fuel` (a fraction of the internal tanks). + local function airborneCow(fuel, order) + local _, cow = flightWithCow(true) + local u = units[cow.unitName] + u.airborne = true + u.fuel = fuel + function u:getFuel() return self.fuel end + if order then mgr[order](mgr, "Gunfighter-1") end + messages, logs = {}, {} + return cow, u + end + + it("sends a holding cow home, tells its flight and logs the fuel, once", function() + local cow = airborneCow(0.2, "orderHoldHere") + mgr:_resyncFarps() + assert.equals(CTLDFatCowManager.PHASE_RETURNING, cow.ai.phase) + assert.equals("Mission", lastTask(cow.ai.groupName).id) + assert.equals(1, said()) + assert.equals(7, messages[1].gid) + assert.equals(1, warned(cow.unitName)) + assert.equals(1, warned("0.20")) + mgr:_resyncFarps() + mgr:_resyncFarps() + assert.equals(1, said()) + assert.equals(1, warned(cow.unitName)) + end) + + it("sends a following cow home, and frees its flight to ask for another", function() + local cow = airborneCow(0.1) + mgr:_resyncFarps() + assert.equals(CTLDFatCowManager.PHASE_RETURNING, cow.ai.phase) + assert.is_nil(mgr:aiCowOfFlight("Gunfighter")) + assert.equals(1, said()) + end) + + it("sends home a released cow in the air, and offers it as going home, not waiting", function() + local cow = airborneCow(0.2) + mgr:freeAICow("Gunfighter-1") + messages, logs = {}, {} + mgr:_resyncFarps() + assert.equals(CTLDFatCowManager.PHASE_RETURNING, cow.ai.phase) + assert.is_nil(cow.ai.released) + assert.equals(1, said()) + assert.equals(1, warned(cow.unitName)) + end) + + it("keeps the cow a flight asked for after it released the low one", function() + local old = airborneCow(0.2) + mgr:freeAICow("Gunfighter-1") + mgr:requestAICow("Gunfighter-1", 1) + runScheduled() + local new = mgr:aiCowOfFlight("Gunfighter") + assert.is_not_nil(new) + assert.is_false(new == old) + mgr:_resyncFarps() + assert.equals(CTLDFatCowManager.PHASE_RETURNING, old.ai.phase) + assert.equals(new, mgr:aiCowOfFlight("Gunfighter")) + end) + + it("does nothing at 25 % or more", function() + local cow = airborneCow(0.25, "orderHoldHere") + mgr:_resyncFarps() + assert.equals(CTLDFatCowManager.PHASE_HOLDING, cow.ai.phase) + assert.equals(0, said()) + end) + + it("does nothing for a cow on the ground", function() + local cow, u = airborneCow(0.1) + u.airborne = false + mgr:_resyncFarps() + assert.equals(CTLDFatCowManager.PHASE_FOLLOWING, cow.ai.phase) + assert.equals(0, said()) + end) + + it("does nothing for a cow already going home", function() + local cow = airborneCow(0.1) + mgr:releaseAICow("Gunfighter-1") + messages, logs = {}, {} + mgr:_resyncFarps() + assert.equals(0, said()) + assert.equals(0, warned(cow.unitName)) + end) + + it("lets a cow that is landing land", function() + local cow = airborneCow(0.1) + mgr:orderLandHere("Gunfighter-1") + messages, logs = {}, {} + mgr:_resyncFarps() + assert.equals(CTLDFatCowManager.PHASE_LANDING, cow.ai.phase) + assert.equals(0, said()) + end) + + it("does nothing when DCS gives no fuel reading", function() + local cow, u = airborneCow(0.1) + u.getFuel = nil + mgr:_resyncFarps() + assert.equals(CTLDFatCowManager.PHASE_FOLLOWING, cow.ai.phase) + assert.equals(0, said()) + end) + end) end) From 52537e7c8923de398115b550cd10380017f60d8d Mon Sep 17 00:00:00 2001 From: David Pierron Date: Tue, 24 Nov 2026 13:26:05 +0100 Subject: [PATCH 5/7] chore(backlog): FIX-FAT-COW-STRANDED index line (PR #334) --- .backlog/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.backlog/README.md b/.backlog/README.md index 08790ab7..278eacc6 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-STRANDED`](FIX-FAT-COW-STRANDED/PRD.md) | ready — 4 tickets (01 [log the orders and phases](FIX-FAT-COW-STRANDED/tickets/01-log-orders-and-phases.md), 02 [orphan check in the loop](FIX-FAT-COW-STRANDED/tickets/02-orphan-check-in-the-loop.md), 03 [bingo fuel](FIX-FAT-COW-STRANDED/tickets/03-bingo-fuel.md), 04 [live check](FIX-FAT-COW-STRANDED/tickets/04-live-check.md)) | Zip via VMCT, Campagne server, 2026-11-22: an AI cow packed its FARP on an F10 order nobody logged, lifted off and hovered for 5 h until it ran out of fuel. Log every order and phase, run the orphan check in the 10 s loop, send a cow home below 25 % fuel, and measure what the `Orbit` task and a player leaving really do. | `fix/FIX-FAT-COW-STRANDED` | +| [`FIX-FAT-COW-STRANDED`](FIX-FAT-COW-STRANDED/PRD.md) | merged (PR #334) — 01-03 done, 04 [live check] pending (01 [log the orders and phases](FIX-FAT-COW-STRANDED/tickets/01-log-orders-and-phases.md), 02 [orphan check in the loop](FIX-FAT-COW-STRANDED/tickets/02-orphan-check-in-the-loop.md), 03 [bingo fuel](FIX-FAT-COW-STRANDED/tickets/03-bingo-fuel.md), 04 [live check](FIX-FAT-COW-STRANDED/tickets/04-live-check.md)) | Zip via VMCT, Campagne server, 2026-11-22: an AI cow packed its FARP on an F10 order nobody logged, lifted off and hovered for 5 h until it ran out of fuel. Log every order and phase, run the orphan check in the 10 s loop, send a cow home below 25 % fuel, and measure what the `Orbit` task and a player leaving really do. | `fix/FIX-FAT-COW-STRANDED` | | [`FIX-VMCT-REVIEW-FINDINGS`](FIX-VMCT-REVIEW-FINDINGS/PRD.md) | merged (PR #330) — 06 ✅ live scenario PASS 10/10 (2026-11-23) — 7 tickets (01 [parachuted troops keep their template](FIX-VMCT-REVIEW-FINDINGS/tickets/01-parachuted-troops-keep-their-template.md), 02 [inactive zones stay inactive](FIX-VMCT-REVIEW-FINDINGS/tickets/02-inactive-zones-stay-inactive.md), 03 [repair crates from the menu](FIX-VMCT-REVIEW-FINDINGS/tickets/03-repair-crates-from-the-menu.md), 04 [unique AA group name](FIX-VMCT-REVIEW-FINDINGS/tickets/04-unique-aa-group-name.md), 05 [player name in coalition messages](FIX-VMCT-REVIEW-FINDINGS/tickets/05-player-name-in-coalition-messages.md), 06 [live check](FIX-VMCT-REVIEW-FINDINGS/tickets/06-live-check.md), 07 [backlog housekeeping](FIX-VMCT-REVIEW-FINDINGS/tickets/07-backlog-housekeeping.md)) | Issues #322-#326 (VMCT review of `develop`, 2026-11-19): parachuted troops all land as "Soldier AK"; inactive troop/waypoint zones load active; the six "… Repair" crates cannot be requested from the menu; two AA systems of the same type spawned in the same second share a group name; FOB and SAM coalition messages name the unit instead of the player. | `fix/FIX-VMCT-REVIEW-FINDINGS` | | [`FEAT-VMCT-V1-PARITY`](FEAT-VMCT-V1-PARITY/PRD.md) | merged (PR #329) — verified in game (live scenario 15/15, 2026-11-23) — 3 tickets (01 [spawned units player can drive](FEAT-VMCT-V1-PARITY/tickets/01-spawned-units-player-can-drive.md), 02 [link crates and groups in events](FEAT-VMCT-V1-PARITY/tickets/02-link-crates-and-groups-in-events.md), 03 [live check](FEAT-VMCT-V1-PARITY/tickets/03-live-check.md)) | Issues #327, #328 (VMCT): units spawned by a CTLD gesture are drivable again (new setting `spawnedUnitsPlayerCanDrive`, default `true` as in v1); unpack, rearm and repair events carry both the crates and the spawned group. | `feat/FEAT-VMCT-V1-PARITY` | From dd6868fb3986eef873c97b845ce4249580f8e9cf Mon Sep 17 00:00:00 2001 From: David Pierron Date: Tue, 24 Nov 2026 13:27:55 +0100 Subject: [PATCH 6/7] test(dcs): FIX-FAT-COW-STRANDED live scenarios for ticket 04 --- .../dcs/noPlayer/scenario_fatcow_stranded.lua | 180 ++++++++++++++++++ .../scenario_fatcow_player_leave.lua | 75 ++++++++ 2 files changed, 255 insertions(+) create mode 100644 tests/dcs/noPlayer/scenario_fatcow_stranded.lua create mode 100644 tests/dcs/pilotPassive/scenario_fatcow_player_leave.lua diff --git a/tests/dcs/noPlayer/scenario_fatcow_stranded.lua b/tests/dcs/noPlayer/scenario_fatcow_stranded.lua new file mode 100644 index 00000000..c2656c8a --- /dev/null +++ b/tests/dcs/noPlayer/scenario_fatcow_stranded.lua @@ -0,0 +1,180 @@ +---@diagnostic disable +-- @tier: auto-slow +-- ============================================================================= +-- tests/dcs/noPlayer/scenario_fatcow_stranded.lua +-- FIX-FAT-COW-STRANDED live check, ticket 04 (a), (c) and (d). Nobody flies. +-- +-- Re-injection step machine: inject again until PASS / FAIL (each answer says what it waits for). +-- 1 an AI Apache flight `Stranded` is spawned airborne near a BLUE logistic zone and requests an AI cow +-- 2 the cow exists: it is given the F10 order "Take off" (orbit where it stands); a sampler then records +-- its position and speed every 5 s for 120 s +-- 3 (a) verdict by measurement: circle (speed, bounded distance from the orbit point) or hover +-- 4 (c) a CH-47 with 400 kg of fuel is spawned airborne, registered as the cow of a second Apache flight +-- `Stranded2`: the 10 s loop must send it home and tell the flight, within 40 s +-- 5 clean up (groups destroyed, cows forgotten) +-- (d) is read in dcs.log: lines "CTLDFatCowManager: cow '...' order ..." and "... phase ... -> ...". +-- +-- @scenario FATCOW-STRANDED +-- @version 1.0 — 2026-11-24 +-- ============================================================================= + +local TAG = "[FATCOW-STRANDED]" +local function done(v) _SCN_FATCOW_STRANDED_RESULT = TAG .. " " .. v; return _SCN_FATCOW_STRANDED_RESULT end + +if not (CTLDFatCowManager and ctld and ctld.utils) then return done("ABORT: CTLD not initialized") end +local mgr = CTLDFatCowManager.getInstance() +local S = _SCN_FATCOW_STRANDED or { step = 1, notes = {}, msgs = {}, samples = {} } +_SCN_FATCOW_STRANDED = S +local now = timer.getTime() + +local function note(s) S.notes[#S.notes + 1] = s end +local function alive(name) local u = Unit.getByName(name); return u and u:isExist() and u or nil end +local function dist2(a, b) return math.sqrt((a.x - b.x) ^ 2 + (a.z - b.z) ^ 2) end + +if not S.hooked then + S.hooked = true + local orig = trigger.action.outTextForGroup + trigger.action.outTextForGroup = function(gid, text, d, c) + if type(text) == "string" and text:find("Fat Cow", 1, true) then S.msgs[#S.msgs + 1] = gid .. ": " .. text end + return orig(gid, text, d, c) + end + S.origOut = orig +end + +local function apache(name, x, z) + return { + name = name, task = "CAS", + route = { points = { { type = "Turning Point", action = "Turning Point", x = x, y = z + 50000, + alt = 150, alt_type = "RADIO", speed = 40, task = { id = "ComboTask", params = { tasks = {} } } } } }, + units = { { name = name .. "-1", type = "AH-64D_BLK_II", skill = "High", x = x, y = z, + alt = 150, alt_type = "RADIO", speed = 40, heading = 0, + payload = { fuel = 1000, flare = 0, chaff = 0, gun = 100, pylons = {} } } }, + } +end + +local function cleanup() + for _, g in ipairs({ "Stranded", "Stranded2", "Bingo Cow" }) do + local grp = Group.getByName(g) + if grp and grp:isExist() then grp:destroy() end + end + for _, c in ipairs({ S.cow, S.bingo }) do if c and mgr:getCow(c) then mgr:_cowGone(c) end end + if S.origOut then trigger.action.outTextForGroup = S.origOut end + S.hooked = false +end + +if S.step == 1 then + local zone = mgr:nearestHomeZone({ x = 0, y = 0, z = 0 }, coalition.side.BLUE) + if not zone then return done("ABORT: no BLUE logistic zone in the mission") end + local c = zone:getCenter() + S.zone = c + coalition.addGroup(country.id.USA, Group.Category.HELICOPTER, apache("Stranded", c.x + 4000, c.z)) + S.t1, S.step = now, 2 + return done("RUNNING: step=2 flight Stranded spawned, inject again in 3 s") +end + +if S.step == 2 then + if now - S.t1 < 3 then return done("RUNNING: step=2 waiting a frame") end + if not alive("Stranded-1") then return done("FAIL: Stranded not spawned") end + if not S.requested then + S.requested = true + mgr:requestAICow("Stranded-1", 1) + S.t1 = now + return done("RUNNING: step=2 cow requested, inject again in 4 s") + end + local cow = mgr:aiCowOfFlight("Stranded") + if not cow then + if now - S.t1 > 20 then return done("FAIL: no cow after 20 s") end + return done("RUNNING: step=2 waiting for the cow") + end + local u = alive(cow.unitName) + if not u then return done("FAIL: the cow unit is not there") end + S.cow = cow.unitName + local p = u:getPoint() + S.orbit = { x = p.x, z = p.z } + mgr:orderTakeOff("Stranded-1") + note(string.format("Take off given at (%.0f, %.0f), phase %s", p.x, p.z, tostring(cow.ai.phase))) + S.t2 = now + local function sample() + local c = alive(S.cow) + if c then + local v, q = c:getVelocity(), c:getPoint() + S.samples[#S.samples + 1] = { t = timer.getTime() - S.t2, d = dist2(q, S.orbit), + speed = math.sqrt(v.x ^ 2 + v.z ^ 2), alt = q.y, fuel = c:getFuel() } + end + if timer.getTime() - S.t2 < 120 then return timer.getTime() + 5 end + end + timer.scheduleFunction(sample, nil, timer.getTime() + 5) + S.step = 3 + return done("RUNNING: step=3 sampling the orbit for 120 s") +end + +if S.step == 3 then + if now - S.t2 < 125 then return done(string.format("RUNNING: step=3 sampling (%.0f s of 120)", now - S.t2)) end + local n, sumV, maxV, minV, maxD = #S.samples, 0, 0, 1e9, 0 + local cow = mgr:getCow(S.cow) + for _, s in ipairs(S.samples) do + sumV = sumV + s.speed + if s.speed > maxV then maxV = s.speed end + if s.speed < minV then minV = s.speed end + if s.d > maxD then maxD = s.d end + end + if n == 0 then return done("FAIL: no sample, the cow vanished | " .. table.concat(S.notes, "; ")) end + local last = S.samples[n] + S.measuredA = string.format("(a) %d samples over 120 s: speed mean %.1f m/s (min %.1f, max %.1f), max %.0f m from the orbit point, last %.0f m at %.0f m, fuel %.2f, phase %s => %s", + n, sumV / n, minV, maxV, maxD, last.d, last.alt, last.fuel or -1, cow and tostring(cow.ai.phase) or "?", + (sumV / n < 3 and maxD < 100) and "HOVER" or "MOVES (circle or drift: see the samples)") + note(S.measuredA) + local pts = {} + for _, s in ipairs(S.samples) do pts[#pts + 1] = string.format("%.0fs:%.0fm/%.1fm/s", s.t, s.d, s.speed) end + note("samples " .. table.concat(pts, " ")) + -- (c) bingo + local cx, cz = S.zone.x, S.zone.z + coalition.addGroup(country.id.USA, Group.Category.HELICOPTER, apache("Stranded2", cx + 8000, cz)) + local alt = land.getHeight({ x = cx, y = cz }) + 150 + coalition.addGroup(country.id.USA, Group.Category.HELICOPTER, { + name = "Bingo Cow", task = "Transport", + route = { points = { { type = "Turning Point", action = "Turning Point", x = cx + 8000, y = cz, + alt = alt, alt_type = "BARO", speed = 40, task = { id = "ComboTask", params = { tasks = {} } } } } }, + units = { { name = "Bingo Cow-1", type = ctld.gs("fatCowAIType"), skill = "High", x = cx + 8000, y = cz, + alt = alt, alt_type = "BARO", speed = 40, heading = 0, + payload = { fuel = 400, flare = 0, chaff = 0, gun = 100, pylons = {} } } }, + }) + S.t4, S.step = now, 4 + return done("RUNNING: step=4 low-fuel cow and its flight spawned, inject again in 3 s") +end + +if S.step == 4 then + if now - S.t4 < 3 then return done("RUNNING: step=4 waiting a frame") end + if not S.registered then + local u = alive("Bingo Cow-1") + if not (u and alive("Stranded2-1")) then return done("FAIL: bingo cow or its flight not spawned | " .. table.concat(S.notes, "; ")) end + local cow = mgr:addAICow("Bingo Cow", "Stranded2", S.zone, 1) + if not cow then return done("FAIL: addAICow refused the bingo cow") end + S.bingo, S.registered, S.t5 = cow.unitName, true, now + S.fuel0 = u:getFuel() + note(string.format("bingo cow registered, fuel %.2f, in air %s, phase %s", S.fuel0, tostring(ctld.utils.inAir(u)), tostring(cow.ai.phase))) + return done("RUNNING: step=4 waiting for the 10 s loop to send it home") + end + local cow = mgr:getCow(S.bingo) + if cow and cow.ai.phase == CTLDFatCowManager.PHASE_RETURNING then + local said = false + for _, m in ipairs(S.msgs) do if m:find("low on fuel", 1, true) then said = true end end + note(string.format("sent home %.0f s after registration, message read: %s", now - S.t5, tostring(said))) + S.verdictC = said + S.step = 5 + elseif now - S.t5 > 40 then + return done(string.format("FAIL: (c) the low-fuel cow is still %s after 40 s | %s", + cow and tostring(cow.ai.phase) or "gone", table.concat(S.notes, "; "))) + else + return done(string.format("RUNNING: step=4 (%.0f s) phase %s", now - S.t5, cow and tostring(cow.ai.phase) or "gone")) + end +end + +if S.step == 5 then + local msgs = table.concat(S.msgs, " || ") + cleanup() + local v = S.verdictC and "PASS" or "FAIL: the flight did not read the low-fuel message" + return done(v .. " | " .. table.concat(S.notes, "; ") .. " | messages: " .. msgs) +end + +return done("ABORT: unknown step") diff --git a/tests/dcs/pilotPassive/scenario_fatcow_player_leave.lua b/tests/dcs/pilotPassive/scenario_fatcow_player_leave.lua new file mode 100644 index 00000000..c4cb5d45 --- /dev/null +++ b/tests/dcs/pilotPassive/scenario_fatcow_player_leave.lua @@ -0,0 +1,75 @@ +---@diagnostic disable +-- @tier: ia (menu) +-- ============================================================================= +-- tests/dcs/pilotPassive/scenario_fatcow_player_leave.lua +-- FIX-FAT-COW-STRANDED live check, ticket 04 (b): does a client group still answer getUnit(1) 2 s, 5 s, 10 s +-- after its player leaves the slot, and does the cow then go home? +-- +-- Zip sits in a BLUE helicopter slot (any, in the air or on the ground). Inject once: the flight requests a cow +-- and a handler waits for the player leaving. Zip then leaves the slot (ESC > "Change slot" or "Exit to spectators"). +-- The handler samples the group every 0.5 s for 30 s from that instant. Inject again to read the verdict. +-- +-- @scenario FATCOW-PLAYER-LEAVE +-- @version 1.0 — 2026-11-24 +-- ============================================================================= + +local TAG = "[FATCOW-PLAYER-LEAVE]" +local function done(v) _SCN_FATCOW_PLAYER_LEAVE_RESULT = TAG .. " " .. v; return _SCN_FATCOW_PLAYER_LEAVE_RESULT end + +if not (CTLDFatCowManager and ctld and ctld.utils) then return done("ABORT: CTLD not initialized") end +local mgr = CTLDFatCowManager.getInstance() +local S = _SCN_FATCOW_PLAYER_LEAVE + +if not S then + local player + for _, u in ipairs(coalition.getPlayers(coalition.side.BLUE) or {}) do + if u:isExist() and u:getDesc().category == Unit.Category.HELICOPTER then player = u break end + end + if not player then return done("ABORT: no BLUE helicopter player (sit in a helicopter slot)") end + S = { unit = player:getName(), flight = player:getGroup():getName(), samples = {}, state = "armed" } + _SCN_FATCOW_PLAYER_LEAVE = S + mgr:requestAICow(S.unit, 1) + S.handler = { onEvent = function(_, e) + if e.id ~= world.event.S_EVENT_PLAYER_LEAVE_UNIT or S.t0 then return end + S.t0 = timer.getTime() + S.state = "sampling" + local function sample() + local t = timer.getTime() - S.t0 + local g = Group.getByName(S.flight) + local gx = g and g:isExist() + local cow = mgr:aiCowOfFlight(S.flight) + local named + for _, c in pairs(mgr._cows) do if c.ai and c.ai.flightGroup == S.flight then named = c end end + S.samples[#S.samples + 1] = { t = t, group = gx and true or false, + unit1 = (gx and g:getUnit(1)) and true or false, + phase = named and named.ai.phase or "-", registered = cow ~= nil } + if t < 30 then return timer.getTime() + 0.5 end + S.state = "done" + end + timer.scheduleFunction(sample, nil, timer.getTime()) + end } + world.addEventHandler(S.handler) + return done("STARTED: cow requested for flight '" .. S.flight .. "'. Zip: leave the slot now (wait for the cow message first).") +end + +if S.state == "armed" then return done("RUNNING: waiting for the player to leave the slot") end +if S.state == "sampling" then return done(string.format("RUNNING: sampling (%.0f s of 30)", timer.getTime() - S.t0)) end + +-- done: the readings nearest to 2, 5 and 10 s, and when each thing changed +local function at(t) + local best + for _, s in ipairs(S.samples) do if not best or math.abs(s.t - t) < math.abs(best.t - t) then best = s end end + return best and string.format("t=%.1fs group=%s getUnit(1)=%s cow=%s registered=%s", best.t, tostring(best.group), + tostring(best.unit1), best.phase, tostring(best.registered)) or "no sample" +end +local firstGone, firstHome +for _, s in ipairs(S.samples) do + if not s.unit1 and not firstGone then firstGone = s.t end + if s.phase == CTLDFatCowManager.PHASE_RETURNING and not firstHome then firstHome = s.t end +end +world.removeEventHandler(S.handler) +local verdict = string.format("MEASURED | 2 s: %s | 5 s: %s | 10 s: %s | getUnit(1) first nil at %s s | cow first RETURNING at %s s", + at(2), at(5), at(10), firstGone and string.format("%.1f", firstGone) or "never (30 s)", + firstHome and string.format("%.1f", firstHome) or "never (30 s)") +_SCN_FATCOW_PLAYER_LEAVE = nil +return done(verdict) From 26722595d115e940a2863606de615a6b6635459a Mon Sep 17 00:00:00 2001 From: David Pierron Date: Tue, 24 Nov 2026 15:42:25 +0100 Subject: [PATCH 7/7] test(dcs): FIX-FAT-COW-STRANDED player-leave sampler fix, ticket 04 measurements --- .../tickets/04-live-check.md | 17 +++++++++++++---- .backlog/README.md | 2 +- .../scenario_fatcow_player_leave.lua | 10 ++++++++-- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/.backlog/FIX-FAT-COW-STRANDED/tickets/04-live-check.md b/.backlog/FIX-FAT-COW-STRANDED/tickets/04-live-check.md index 3a422a8f..6c98354e 100644 --- a/.backlog/FIX-FAT-COW-STRANDED/tickets/04-live-check.md +++ b/.backlog/FIX-FAT-COW-STRANDED/tickets/04-live-check.md @@ -1,6 +1,6 @@ # 04 — Live check and the two measurements -**Status:** 🟡 ready · **Type:** HITL for (b) (Zip in a slot), AFK otherwise; Zip launches DCS, the session launches dcs-serve +**Status:** ✅ done 2026-11-24 · **Type:** HITL for (b) (Zip in a slot), AFK otherwise; Zip launches DCS, the session launches dcs-serve ## Parent [PRD](../PRD.md), decision 4. Blocked by 01-03. @@ -14,6 +14,15 @@ On `Test_CTLDNEXT_01.miz`, over the DCS bridge: - (d) The orders and phases appear in `dcs.log`. ## Acceptance criteria -- [ ] (a)-(d) recorded PASS/FAIL or as measured values, with the log lines. -- [ ] If (a) is a hover, the PR says so and proposes the fix as a follow-up lot. -- [ ] Nothing left in the mission afterwards. +- [x] (a)-(d) recorded PASS/FAIL or as measured values, with the log lines. +- [x] If (a) is a hover, the PR says so and proposes the fix as a follow-up lot. +- [x] Nothing left in the mission afterwards. + +## Measured, 2026-11-24 (`Test_CTLDNEXT_01.miz`, DCS bridge, build of this PR) + +- **(a) PASS, circle, not a hover.** An AI CH-47 given *Take off* flew at 35.7-42.9 m/s (mean 39.7) over 120 s; its distance from the orbit point grew from 249 m to 1741 m at 120 s and 2077 m at 210 s, its heading turning about 1.2 deg/s: a circle of roughly 1.9 km radius. It burns fuel while it circles. No follow-up lot needed. +- **(b) The client group is gone at once.** Player leaves the slot: at the first sample (0.1 s) and at 2.1 s, 5.1 s and 10.1 s `Group.getByName` already returns nothing (`group=false`, `getUnit(1)=false`), and the cow is already `returning` and no longer registered to the flight. The 2 s check therefore does not race the removal in this setup (a first pass, whose sampler recorded nothing, logged the cow going home 3.1 s after the leave). The 10 s loop check stays as the safety net for the slower cases of the 2026-11-22 incident. +- **(c) PASS.** A CH-47 at 0.13 of its tanks, in the air, registered as the cow of a flight: the 10 s loop sent it home and its flight read "The Fat Cow is low on fuel and returns home." Log: `cow 'Bingo Cow-1' is low on fuel (0.13 of its tanks, phase following): sent home` (WARN), then `phase following -> returning`. +- **(d) PASS.** `dcs.log` shows `cow 'Fat Cow Stranded #1-1' order 'Take off' from 'Stranded-1'`, `phase following -> holding`, and for (b) `cow 'Fat Cow uh1 #3-1' lost flight 'uh1', offered for take-over`. + +Nothing is left in the mission: the scenarios destroy their groups and forget their cows, and the player-leave handler is removed. diff --git a/.backlog/README.md b/.backlog/README.md index 278eacc6..a71bbef4 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-STRANDED`](FIX-FAT-COW-STRANDED/PRD.md) | merged (PR #334) — 01-03 done, 04 [live check] pending (01 [log the orders and phases](FIX-FAT-COW-STRANDED/tickets/01-log-orders-and-phases.md), 02 [orphan check in the loop](FIX-FAT-COW-STRANDED/tickets/02-orphan-check-in-the-loop.md), 03 [bingo fuel](FIX-FAT-COW-STRANDED/tickets/03-bingo-fuel.md), 04 [live check](FIX-FAT-COW-STRANDED/tickets/04-live-check.md)) | Zip via VMCT, Campagne server, 2026-11-22: an AI cow packed its FARP on an F10 order nobody logged, lifted off and hovered for 5 h until it ran out of fuel. Log every order and phase, run the orphan check in the 10 s loop, send a cow home below 25 % fuel, and measure what the `Orbit` task and a player leaving really do. | `fix/FIX-FAT-COW-STRANDED` | +| [`FIX-FAT-COW-STRANDED`](FIX-FAT-COW-STRANDED/PRD.md) | merged (PR #334) (01 [log the orders and phases](FIX-FAT-COW-STRANDED/tickets/01-log-orders-and-phases.md), 02 [orphan check in the loop](FIX-FAT-COW-STRANDED/tickets/02-orphan-check-in-the-loop.md), 03 [bingo fuel](FIX-FAT-COW-STRANDED/tickets/03-bingo-fuel.md), 04 [live check](FIX-FAT-COW-STRANDED/tickets/04-live-check.md)) | Zip via VMCT, Campagne server, 2026-11-22: an AI cow packed its FARP on an F10 order nobody logged, lifted off and hovered for 5 h until it ran out of fuel. Log every order and phase, run the orphan check in the 10 s loop, send a cow home below 25 % fuel, and measure what the `Orbit` task and a player leaving really do. | `fix/FIX-FAT-COW-STRANDED` | | [`FIX-VMCT-REVIEW-FINDINGS`](FIX-VMCT-REVIEW-FINDINGS/PRD.md) | merged (PR #330) — 06 ✅ live scenario PASS 10/10 (2026-11-23) — 7 tickets (01 [parachuted troops keep their template](FIX-VMCT-REVIEW-FINDINGS/tickets/01-parachuted-troops-keep-their-template.md), 02 [inactive zones stay inactive](FIX-VMCT-REVIEW-FINDINGS/tickets/02-inactive-zones-stay-inactive.md), 03 [repair crates from the menu](FIX-VMCT-REVIEW-FINDINGS/tickets/03-repair-crates-from-the-menu.md), 04 [unique AA group name](FIX-VMCT-REVIEW-FINDINGS/tickets/04-unique-aa-group-name.md), 05 [player name in coalition messages](FIX-VMCT-REVIEW-FINDINGS/tickets/05-player-name-in-coalition-messages.md), 06 [live check](FIX-VMCT-REVIEW-FINDINGS/tickets/06-live-check.md), 07 [backlog housekeeping](FIX-VMCT-REVIEW-FINDINGS/tickets/07-backlog-housekeeping.md)) | Issues #322-#326 (VMCT review of `develop`, 2026-11-19): parachuted troops all land as "Soldier AK"; inactive troop/waypoint zones load active; the six "… Repair" crates cannot be requested from the menu; two AA systems of the same type spawned in the same second share a group name; FOB and SAM coalition messages name the unit instead of the player. | `fix/FIX-VMCT-REVIEW-FINDINGS` | | [`FEAT-VMCT-V1-PARITY`](FEAT-VMCT-V1-PARITY/PRD.md) | merged (PR #329) — verified in game (live scenario 15/15, 2026-11-23) — 3 tickets (01 [spawned units player can drive](FEAT-VMCT-V1-PARITY/tickets/01-spawned-units-player-can-drive.md), 02 [link crates and groups in events](FEAT-VMCT-V1-PARITY/tickets/02-link-crates-and-groups-in-events.md), 03 [live check](FEAT-VMCT-V1-PARITY/tickets/03-live-check.md)) | Issues #327, #328 (VMCT): units spawned by a CTLD gesture are drivable again (new setting `spawnedUnitsPlayerCanDrive`, default `true` as in v1); unpack, rearm and repair events carry both the crates and the spawned group. | `feat/FEAT-VMCT-V1-PARITY` | diff --git a/tests/dcs/pilotPassive/scenario_fatcow_player_leave.lua b/tests/dcs/pilotPassive/scenario_fatcow_player_leave.lua index c4cb5d45..6ce80f5d 100644 --- a/tests/dcs/pilotPassive/scenario_fatcow_player_leave.lua +++ b/tests/dcs/pilotPassive/scenario_fatcow_player_leave.lua @@ -33,7 +33,7 @@ if not S then if e.id ~= world.event.S_EVENT_PLAYER_LEAVE_UNIT or S.t0 then return end S.t0 = timer.getTime() S.state = "sampling" - local function sample() + local function sample0() local t = timer.getTime() - S.t0 local g = Group.getByName(S.flight) local gx = g and g:isExist() @@ -46,7 +46,12 @@ if not S then if t < 30 then return timer.getTime() + 0.5 end S.state = "done" end - timer.scheduleFunction(sample, nil, timer.getTime()) + local function sample() + local ok, nxt = pcall(sample0) + if not ok then S.err = tostring(nxt); S.state = "done"; return nil end + return nxt + end + timer.scheduleFunction(sample, nil, timer.getTime() + 0.1) end } world.addEventHandler(S.handler) return done("STARTED: cow requested for flight '" .. S.flight .. "'. Zip: leave the slot now (wait for the cow message first).") @@ -71,5 +76,6 @@ world.removeEventHandler(S.handler) local verdict = string.format("MEASURED | 2 s: %s | 5 s: %s | 10 s: %s | getUnit(1) first nil at %s s | cow first RETURNING at %s s", at(2), at(5), at(10), firstGone and string.format("%.1f", firstGone) or "never (30 s)", firstHome and string.format("%.1f", firstHome) or "never (30 s)") +if S.err then verdict = verdict .. " | sampler error: " .. S.err end _SCN_FATCOW_PLAYER_LEAVE = nil return done(verdict)