fix: gylle som gødning — påfyldningsmarkør pr. vare, puljen følger fortrinsreglen, omnummererede markører er ikke kapring — 1.62.321
- adFieldRefill: ADFieldWork.triggersFor filtrerer stationens triggere på varen; markerAtStation/findRefillMarker/findBuyMarker tager fillType (in-game 17/10: Supercis fik 'Cow 5 Milk' og kørte tom til F64) - adPool/adFieldWork: ADPool.pairFor(..., prefer) foretrukne redskaber først; fertilizerPrefer fælles for pickRigs og dispatchPool; puljeposter bærer sprayNames - adHitch: samme markørnavn med nyt id (AD omnummererer ved sletning) følges i stedet for 'AD fik et andet mål undervejs'; kun når det gamle id ikke længere bærer navnet - tests: TF1-8, PP1-4, omnummereret/navnebror
This commit is contained in:
@@ -80,10 +80,24 @@ end
|
||||
ADFieldWork.STATION_MARKER_M = 30
|
||||
ADFieldWork.STATION_MATCH_M = 80 -- markører så tæt på bygningen tjekkes med markør->station-opslaget
|
||||
|
||||
-- Stationens læssetriggere i verden (buying-/loading-station) -> {{x, z}}.
|
||||
local function loadTriggerPoints(station)
|
||||
-- Triggerne der giver varen ud: trigger.fillTypes = {[fillType] = true} eller nil (= alle varer). Uden fillType, eller
|
||||
-- når ingen trigger nævner varen, alle triggere. In-game 17/10: Kostald 5 har mælke- OG gylletrigger; gyllevognen fik
|
||||
-- markøren ved mælketriggeren ("Cow 5 Milk") og kørte tom til marken.
|
||||
function ADFieldWork.triggersFor(triggers, fillType)
|
||||
local list = {}
|
||||
for _, trigger in pairs(triggers or {}) do
|
||||
if fillType == nil or trigger.fillTypes == nil or trigger.fillTypes[fillType] then table.insert(list, trigger) end
|
||||
end
|
||||
if #list == 0 then
|
||||
for _, trigger in pairs(triggers or {}) do table.insert(list, trigger) end
|
||||
end
|
||||
return list
|
||||
end
|
||||
|
||||
-- Stationens læssetriggere i verden (buying-/loading-station) -> {{x, z}}; med fillType kun dem der giver varen ud.
|
||||
local function loadTriggerPoints(station, fillType)
|
||||
local points = {}
|
||||
for _, trigger in pairs(station.loadTriggers or {}) do
|
||||
for _, trigger in ipairs(ADFieldWork.triggersFor(station.loadTriggers, fillType)) do
|
||||
local node = trigger.triggerNode or trigger.aiNode
|
||||
if node ~= nil then
|
||||
local ok, x, _, z = pcall(getWorldTranslation, node)
|
||||
@@ -227,13 +241,13 @@ local function markerOfOther(adEnv, markerId, station, placeable)
|
||||
return owner ~= nil and not sameStation(owner, station, placeable)
|
||||
end
|
||||
|
||||
local function markerAtStationRaw(adEnv, vehicle, station, placeable)
|
||||
local function markerAtStationRaw(adEnv, vehicle, station, placeable, fillType)
|
||||
local farmId = vehicle ~= nil and ADSmartPickup ~= nil and ADSmartPickup.getFarmId ~= nil and ADSmartPickup.getFarmId(vehicle) or nil
|
||||
-- 1) markør ved stationens egne triggere, der hører til stationen. Uden filteret vandt en markør, hvis vej kører
|
||||
-- GENNEM triggeren videre til nabostationen (in-game 16/10: frø fra "Bulk Fill Station" ved "Liquid Buy Silo")
|
||||
local points = nil
|
||||
local okOwn, ownId = pcall(function()
|
||||
points = loadTriggerPoints(station)
|
||||
points = loadTriggerPoints(station, fillType)
|
||||
local list = {}
|
||||
for _, entry in ipairs(markerList(adEnv, points, ADFieldWork.STATION_MARKER_M)) do
|
||||
if not isServiceMarker(entry) and markerBelongsTo(adEnv, farmId, entry.id, station, placeable) then table.insert(list, entry) end
|
||||
@@ -264,7 +278,7 @@ local function markerAtStationRaw(adEnv, vehicle, station, placeable)
|
||||
if okMatch and matchId ~= nil then return matchId, 2 end
|
||||
-- 3) som før: markør ved triggerne (også gennemkørsel), ellers nærmeste ikke-Wait markør inden for 40 m af bygningen
|
||||
local okAny, anyId = pcall(function()
|
||||
local pts = points or loadTriggerPoints(station)
|
||||
local pts = points or loadTriggerPoints(station, fillType)
|
||||
local list = {}
|
||||
for _, entry in ipairs(markerList(adEnv, pts, ADFieldWork.STATION_MARKER_M)) do
|
||||
if not markerOfOther(adEnv, entry.id, station, placeable) then table.insert(list, entry) end
|
||||
@@ -288,16 +302,20 @@ end
|
||||
-- Til loggen: valgt markør pr. station (kun når valget ændrer sig) — trin 1 = ved triggeren og hører til stationen,
|
||||
-- 2 = hører til stationen (80 m), 3 = gammel regel ved triggeren, 4 = nærmest bygningen.
|
||||
local loggedStationMarker = {}
|
||||
local function markerAtStation(adEnv, vehicle, station, placeable)
|
||||
local id, step = markerAtStationRaw(adEnv, vehicle, station, placeable)
|
||||
local function markerAtStation(adEnv, vehicle, station, placeable, fillType)
|
||||
local id, step = markerAtStationRaw(adEnv, vehicle, station, placeable, fillType)
|
||||
pcall(function()
|
||||
local key = placeable or station
|
||||
if key ~= nil and loggedStationMarker[key] ~= tostring(id) then
|
||||
loggedStationMarker[key] = tostring(id)
|
||||
local logged = key ~= nil and (loggedStationMarker[key] or {}) or nil
|
||||
if logged ~= nil and logged[fillType or 0] ~= tostring(id) then
|
||||
logged[fillType or 0] = tostring(id)
|
||||
loggedStationMarker[key] = logged
|
||||
local marker = id ~= nil and adEnv.ADGraphManager:getMapMarkerByWayPointId(id) or nil
|
||||
local name = placeable ~= nil and placeable.getName ~= nil and placeable:getName() or "?"
|
||||
Logging.info("ADSmartPickup: påfyldning: station '%s' -> markør '%s' (trin %s)", tostring(name),
|
||||
tostring(marker ~= nil and marker.name or id), tostring(step))
|
||||
local goods = fillType ~= nil and g_fillTypeManager ~= nil and g_fillTypeManager.getFillTypeNameByIndex ~= nil
|
||||
and g_fillTypeManager:getFillTypeNameByIndex(fillType) or nil
|
||||
Logging.info("ADSmartPickup: påfyldning: station '%s' -> markør '%s' (trin %s%s)", tostring(name),
|
||||
tostring(marker ~= nil and marker.name or id), tostring(step), goods ~= nil and (", " .. tostring(goods)) or "")
|
||||
end
|
||||
end)
|
||||
return id
|
||||
@@ -367,7 +385,7 @@ function ADFieldWork.findRefillMarker(adEnv, vehicle, fillType, x, z, skipRoute,
|
||||
local level = (not isShop and supported[fillType] and g_currentMission.accessHandler:canFarmAccess(farmId, station))
|
||||
and (station:getFillLevel(fillType, farmId) or 0) or 0
|
||||
if level >= ADFieldWork.MIN_REFILL_STOCK_L then
|
||||
local id = markerAtStation(adEnv, vehicle, station, station.owningPlaceable)
|
||||
local id = markerAtStation(adEnv, vehicle, station, station.owningPlaceable, fillType)
|
||||
local distance = usable(id)
|
||||
if distance ~= nil then table.insert(own, {id = id, distance = distance, level = level}) end
|
||||
end
|
||||
@@ -380,7 +398,7 @@ function ADFieldWork.findRefillMarker(adEnv, vehicle, fillType, x, z, skipRoute,
|
||||
local spec = placeable.spec_buyingStation
|
||||
local station = spec ~= nil and spec.buyingStation or nil
|
||||
if station ~= nil and ADFieldWork.buyingSupports(station, fillType) then
|
||||
consider(markerAtStation(adEnv, vehicle, station, placeable))
|
||||
consider(markerAtStation(adEnv, vehicle, station, placeable, fillType))
|
||||
end
|
||||
end
|
||||
end)
|
||||
@@ -462,7 +480,7 @@ function ADFieldWork.findBuyMarker(adEnv, vehicle, fillType, x, z, skipRoute)
|
||||
local station = spec ~= nil and spec.buyingStation or nil
|
||||
if station ~= nil and ADFieldWork.buyingSupports(station, fillType) then
|
||||
info.stations = info.stations + 1
|
||||
local wayPointId = markerAtStation(adEnv, vehicle, station, placeable)
|
||||
local wayPointId = markerAtStation(adEnv, vehicle, station, placeable, fillType)
|
||||
local wayPoint = wayPointId ~= nil and wayPointId > 0 and adEnv.ADGraphManager:getWayPointById(wayPointId) or nil
|
||||
if wayPoint ~= nil then
|
||||
info.withMarker = info.withMarker + 1
|
||||
|
||||
Reference in New Issue
Block a user