feat(markarbejde): bygget-over marker (groundType NONE / ingen markjord — stald, biogas, gårdsplads) er ikke med i oversigten eller arbejdet (v1.29.0.0)

This commit is contained in:
2026-09-26 12:59:43 +02:00
parent 5d06c46fa9
commit e02d8af3d5
3 changed files with 27 additions and 3 deletions
+14 -2
View File
@@ -159,7 +159,17 @@ function ADFields.readFieldState(field)
local state = field ~= nil and field.fieldState or nil local state = field ~= nil and field.fieldState or nil
if type(state) ~= "table" or type(state.fruitTypeIndex) ~= "number" then return nil end if type(state) ~= "table" or type(state.fruitTypeIndex) ~= "number" then return nil end
local fruitIndex = state.fruitTypeIndex > 0 and state.fruitTypeIndex or nil local fruitIndex = state.fruitTypeIndex > 0 and state.fruitTypeIndex or nil
return {fruitIndex = fruitIndex, growthState = fruitIndex ~= nil and state.growthState or nil} local groundNone = type(FieldGroundType) == "table" and FieldGroundType.NONE or 0
return {fruitIndex = fruitIndex, growthState = fruitIndex ~= nil and state.growthState or nil,
noFieldGround = type(state.groundType) == "number" and state.groundType == groundNone}
end
-- Kan marken dyrkes? Nej hvis spillet siger "ingen markjord" (groundType NONE: bygget over — gårdsplads,
-- stald, biogasanlæg), eller hvis intet prøvepunkt ligger på markjord. En markensilo i et hjørne ændrer
-- intet: resten af marken er stadig markjord.
function ADFields.isCultivable(state, onFieldPoints)
if state ~= nil and state.noFieldGround then return false end
return (onFieldPoints or 0) > 0
end end
-- Markens omrids som {{x, z}, ...}. FS25: field:getDensityMapPolygon():getVerticesList() (flad liste -- Markens omrids som {{x, z}, ...}. FS25: field:getDensityMapPolygon():getVerticesList() (flad liste
@@ -302,6 +312,7 @@ function ADFields.scanPerFruit(scan)
-- (getFieldDataAtWorldPosition giver isOnField, densityBits, groundType — IKKE vækststadie) -- (getFieldDataAtWorldPosition giver isOnField, densityBits, groundType — IKKE vækststadie)
local state = ADFields.readFieldState(info.field) local state = ADFields.readFieldState(info.field)
info.growthState = state ~= nil and state.growthState or nil info.growthState = state ~= nil and state.growthState or nil
info.cultivable = ADFields.isCultivable(state, #scan.points)
if state ~= nil then if state ~= nil then
info.fruitIndex = state.fruitIndex info.fruitIndex = state.fruitIndex
else else
@@ -486,7 +497,8 @@ function ADFields.list()
local infos = {} local infos = {}
for _, entry in ipairs(ADFields.order) do for _, entry in ipairs(ADFields.order) do
local info = ADFields.cache[entry.id] local info = ADFields.cache[entry.id]
if info ~= nil then table.insert(infos, info) end -- bygget-over marker (stald, biogas, gårdsplads) kan ikke dyrkes: ikke med i oversigt/arbejde
if info ~= nil and info.cultivable ~= false then table.insert(infos, info) end
end end
ADFields.listCache = infos ADFields.listCache = infos
return infos return infos
+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.28.9.0</version> <version>1.29.0.0</version>
<title> <title>
<en>AD Smart Pickup</en> <en>AD Smart Pickup</en>
</title> </title>
+12
View File
@@ -82,5 +82,17 @@ field.fieldState = {fruitTypeIndex = 0, growthState = 0}
cropAt = function() return nil end cropAt = function() return nil end
info = rescan() info = rescan()
check("PG9 ingen afgrøde = bar uden stub", info and info.kind .. "/" .. tostring(info.stubbleOf), "bare/nil") check("PG9 ingen afgrøde = bar uden stub", info and info.kind .. "/" .. tostring(info.stubbleOf), "bare/nil")
-- PG10-12: bygget-over mark (fields.xml: groundType NONE — gårdsplads/stald/biogas) er ikke med i listen
field.fieldState = {fruitTypeIndex = 0, growthState = 0, groundType = 0}
info = rescan()
check("PG10 ingen markjord = kan ikke dyrkes", info and info.cultivable, false)
check("PG10 ikke i marklisten", #ADFields.list(), 0)
field.fieldState = {fruitTypeIndex = MAIZE, growthState = 2, groundType = 7}
cropAt = function(x) return MAIZE end
info = rescan()
check("PG11 markjord = kan dyrkes", info and info.cultivable, true)
check("PG11 i marklisten", #ADFields.list(), 1)
check("PG12 ingen punkter på markjord", ADFields.isCultivable(nil, 0), false)
print(failures == 0 and "\nALLE TESTS OK" or ("\n" .. failures .. " FEJL")) print(failures == 0 and "\nALLE TESTS OK" or ("\n" .. failures .. " FEJL"))
os.exit(failures == 0 and 0 or 1) os.exit(failures == 0 and 0 or 1)