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 function newScan(adEnv, entry)
local field, fieldId = entry.field, entry.id local field, fieldId = entry.field, entry.id
local scan = {id = fieldId, queue = {}, head = 1, tail = 0, points = {}, fruitVotes = {}, 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} local info = {id = fieldId, field = field, points = scan.points, verts = {}, mowable = false, readyRatio = 0}
scan.info = info scan.info = info
-- 1) polygon og kandidatpunkter (centroid + halvvejs mod op til 8 hjørner) -- 1) polygon og kandidatpunkter (centroid + halvvejs mod op til 8 hjørner)
@@ -387,7 +387,9 @@ function ADFields.scanPerFruit(scan)
push(scan, function() push(scan, function()
local x, z = point.x, point.z local x, z = point.x, point.z
if fruitIndex ~= nil then 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 if okA and anyPixels then
scan.anySum = scan.anySum + anyPixels scan.anySum = scan.anySum + anyPixels
if not ADFields.isPrime(pointState, prime) then scan.immatureSum = scan.immatureSum + anyPixels end 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.readyRatio = scan.anySum > 0 and scan.readySum / scan.anySum or 0
info.immatureRatio = scan.anySum > 0 and scan.immatureSum / scan.anySum or 0 info.immatureRatio = scan.anySum > 0 and scan.immatureSum / scan.anySum or 0
info.anyPixels = scan.anySum 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) fruit = g_fruitTypeManager:getFruitTypeByIndex(info.fruitIndex)
info.fruitName = fruit ~= nil and fruit.name or nil info.fruitName = fruit ~= nil and fruit.name or nil
info.harvestFillType = fruit ~= nil and fruit.fillType ~= nil and fruit.fillType.index 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" return "ok"
end end
-- Fremdrift 0-1: Courseplays egen (gennemsnit af sættene) vinder; høst/slåning ellers ud fra hvor meget -- Fremdrift 0-1. Høst/slåning: andelen af HELE arealet der stadig står (standingRatio) — readyRatio duer ikke,
-- af afgrøden der er væk; ellers ukendt (nil). -- 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) 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 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)) return math.max(0, math.min(1, 1 - info.readyRatio))
end end
return nil return nil
+1 -1
View File
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?> <?xml version="1.0" encoding="utf-8" standalone="no"?>
<modDesc descVersion="107"> <modDesc descVersion="107">
<author>masterdraco</author> <author>masterdraco</author>
<version>1.35.0.0</version> <version>1.35.1.0</version>
<title> <title>
<en>AD Smart Pickup</en> <en>AD Smart Pickup</en>
</title> </title>
+5 -1
View File
@@ -28,7 +28,11 @@ check("MV3 ukendte data", V.withersIn({witheredState = 7}, 7, 6), false)
-- MV4: fremdrift -- MV4: fremdrift
local harvest = M.with(M.newField(15), {stage = "harvesting", kind = "harvest"}) local harvest = M.with(M.newField(15), {stage = "harvesting", kind = "harvest"})
check("MV4 CP vinder", V.progress(harvest, {readyRatio = 0.9}, 0.5), 0.5) check("MV4 CP vinder uden arealtal", V.progress(harvest, {readyRatio = 0.9}, 0.5), 0.5)
-- in-game 27/9 F90: halvt slået græs viste 0 % — slået græs tæller ikke i readyRatio's nævner
check("MV4 slåning ud fra hele arealet", V.progress(M.with(harvest, {stage = "mowing"}), {readyRatio = 1, standingRatio = 0.5}, nil), 0.5)
check("MV4 areal slår CP (kursus genstartet = 0)", V.progress(harvest, {readyRatio = 1, standingRatio = 0.4}, 0), 0.6)
check("MV4 pleje bruger stadig CP", V.progress(M.with(harvest, {stage = "fertilizing"}), {standingRatio = 0.4}, 0.3), 0.3)
check("MV4 høst ud fra afgrøde", V.progress(harvest, {readyRatio = 0.25}, nil), 0.75) check("MV4 høst ud fra afgrøde", V.progress(harvest, {readyRatio = 0.25}, nil), 0.75)
check("MV4 kultivering ukendt", V.progress(M.with(harvest, {stage = "cultivating"}), {readyRatio = 0}, nil), nil) check("MV4 kultivering ukendt", V.progress(M.with(harvest, {stage = "cultivating"}), {readyRatio = 0}, nil), nil)
check("MV4 tekst", V.percentText(0.504), "50 %") check("MV4 tekst", V.percentText(0.504), "50 %")