fix(måned): fremdrift for høst/slåning ud fra hele arealet — slået græs faldt ud af readyRatio's nævner, så halvt slået F90 viste 0 %; Courseplays kursus-position bruges kun til øvrige trin (v1.35.1.0)

This commit is contained in:
2026-09-27 09:25:34 +02:00
parent 5df4fdc7c3
commit 2beca0924a
4 changed files with 20 additions and 7 deletions
+6 -2
View File
@@ -318,7 +318,7 @@ end
local function newScan(adEnv, entry)
local field, fieldId = entry.field, entry.id
local scan = {id = fieldId, queue = {}, head = 1, tail = 0, points = {}, fruitVotes = {},
anySum = 0, readySum = 0, immatureSum = 0, soil = {fert = {0, 0}, lime = {0, 0}, plowLevel = {0, 0}, weed = {0, 0}}}
anySum = 0, readySum = 0, immatureSum = 0, totalSum = 0, soil = {fert = {0, 0}, lime = {0, 0}, plowLevel = {0, 0}, weed = {0, 0}}}
local info = {id = fieldId, field = field, points = scan.points, verts = {}, mowable = false, readyRatio = 0}
scan.info = info
-- 1) polygon og kandidatpunkter (centroid + halvvejs mod op til 8 hjørner)
@@ -387,7 +387,9 @@ function ADFields.scanPerFruit(scan)
push(scan, function()
local x, z = point.x, point.z
if fruitIndex ~= nil then
local okA, _, anyPixels, _, pointState = pcall(FSDensityMapUtil.getFruitArea, fruitIndex, x - 2, z - 2, x + 2, z, x, z + 2, true, true)
-- returnerer fruitValue, numPixels (afgrøde i høsthøjde), totalNumPixels (hele arealet), growthState
local okA, _, anyPixels, totalPixels, pointState = pcall(FSDensityMapUtil.getFruitArea, fruitIndex, x - 2, z - 2, x + 2, z, x, z + 2, true, true)
if okA and type(totalPixels) == "number" then scan.totalSum = scan.totalSum + totalPixels end
if okA and anyPixels then
scan.anySum = scan.anySum + anyPixels
if not ADFields.isPrime(pointState, prime) then scan.immatureSum = scan.immatureSum + anyPixels end
@@ -433,6 +435,8 @@ local function finishScan(adEnv, scan)
info.readyRatio = scan.anySum > 0 and scan.readySum / scan.anySum or 0
info.immatureRatio = scan.anySum > 0 and scan.immatureSum / scan.anySum or 0
info.anyPixels = scan.anySum
-- andel af hele arealet der stadig står i høsthøjde (fremdrift på fanen Måned)
info.standingRatio = scan.totalSum > 0 and scan.readySum / scan.totalSum or nil
fruit = g_fruitTypeManager:getFruitTypeByIndex(info.fruitIndex)
info.fruitName = fruit ~= nil and fruit.name or nil
info.harvestFillType = fruit ~= nil and fruit.fillType ~= nil and fruit.fillType.index or nil
+8 -3
View File
@@ -82,11 +82,16 @@ function ADMonthView.window(field, info, ctx)
return "ok"
end
-- Fremdrift 0-1: Courseplays egen (gennemsnit af sættene) vinder; høst/slåning ellers ud fra hvor meget
-- af afgrøden der er væk; ellers ukendt (nil).
-- Fremdrift 0-1. Høst/slåning: andelen af HELE arealet der stadig står (standingRatio) — readyRatio duer ikke,
-- for slået/høstet afgrøde forsvinder også fra dens nævner (in-game 27/9 F90: halvt slået = 0 %), og
-- Courseplays tal er kun positionen i kurset (starter forfra på 0 ved genstart). Øvrige trin: Courseplay.
function ADMonthView.progress(field, info, cpProgress)
local cropStage = field.stage == "harvesting" or field.stage == "mowing"
if cropStage and type(info.standingRatio) == "number" then
return math.max(0, math.min(1, 1 - info.standingRatio))
end
if type(cpProgress) == "number" then return math.max(0, math.min(1, cpProgress)) end
if (field.stage == "harvesting" or field.stage == "mowing") and type(info.readyRatio) == "number" then
if cropStage and type(info.readyRatio) == "number" then
return math.max(0, math.min(1, 1 - info.readyRatio))
end
return nil
+1 -1
View File
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<modDesc descVersion="107">
<author>masterdraco</author>
<version>1.35.0.0</version>
<version>1.35.1.0</version>
<title>
<en>AD Smart Pickup</en>
</title>