fix(stald): mængde = læssestationens samlede beholdning (stald + Milk Tank Extension); gamle kilde-id'er skal være AD-markører (omnummerering efter slettede waypoints) (v1.16.3.0)
This commit is contained in:
@@ -327,8 +327,11 @@ function ADRunsController.resolveMarkers(adEnv, run)
|
||||
for _, wayPointId in ipairs(existing or {}) do
|
||||
if not seen[wayPointId] and ADBuildings.byMarker(adEnv, farmId, wayPointId, role) == nil then
|
||||
local keep = true
|
||||
-- et rå id skal være en AD-markør: sletter man waypoints i AutoDrive, omnummereres alle
|
||||
-- senere punkter, og et gammelt markør-id peger så på et tilfældigt vejpunkt
|
||||
local isMarker = adEnv.ADGraphManager.getMapMarkerByWayPointId == nil or adEnv.ADGraphManager:getMapMarkerByWayPointId(wayPointId) ~= nil
|
||||
if role == "load" and ADSources ~= nil and ADSources.identify ~= nil then
|
||||
local source = ADSources.identify(adEnv, wayPointId, farmId)
|
||||
local source = isMarker and ADSources.identify(adEnv, wayPointId, farmId) or nil
|
||||
keep = source ~= nil and not (source.placeable ~= nil and chosenPlaceables[source.placeable])
|
||||
elseif role == "unload" then
|
||||
-- mål skal være en AD-MARKØR med aflæsningsstation (et slettet markør-id er kun et waypoint,
|
||||
|
||||
@@ -368,14 +368,21 @@ local function getHusbandryProducts(adEnv, source)
|
||||
end
|
||||
end
|
||||
table.sort(fillTypes)
|
||||
-- Læssestationen trækker fra staldens beholder OG tilknyttede udvidelser (fx Milk Tank Extension,
|
||||
-- en siloExtension inden for storageRadius). getHusbandryFillLevel ser kun staldens egen beholder.
|
||||
local stationLevels = nil
|
||||
if station ~= nil and station.getAllFillLevels ~= nil then
|
||||
local ok, levels = pcall(station.getAllFillLevels, station, g_currentMission ~= nil and g_currentMission.getFarmId ~= nil and g_currentMission:getFarmId() or 1)
|
||||
if ok and type(levels) == "table" then stationLevels = levels end
|
||||
end
|
||||
local products = {}
|
||||
for _, fillType in ipairs(fillTypes) do
|
||||
local level = placeable:getHusbandryFillLevel(fillType) or 0
|
||||
local level = math.max(placeable:getHusbandryFillLevel(fillType) or 0, stationLevels ~= nil and stationLevels[fillType] or 0)
|
||||
local capacity = placeable.getHusbandryCapacity ~= nil and (placeable:getHusbandryCapacity(fillType) or 0) or 0
|
||||
if capacity <= 0 and placeable.getHusbandryFreeCapacity ~= nil then
|
||||
capacity = level + (placeable:getHusbandryFreeCapacity(fillType) or 0)
|
||||
end
|
||||
table.insert(products, newProduct(fillType, level, level, capacity, false))
|
||||
table.insert(products, newProduct(fillType, level, level, math.max(capacity, level), false))
|
||||
end
|
||||
return products
|
||||
end
|
||||
@@ -828,8 +835,25 @@ local function objectStorageEntries(placeable)
|
||||
return entries
|
||||
end
|
||||
|
||||
-- Stald + udvidelsestanke: højeste niveau pr. vare blandt staldens læssestationer (de deler beholdere).
|
||||
local function getHusbandryStationLevels(placeable)
|
||||
local storage = g_currentMission ~= nil and g_currentMission.storageSystem or nil
|
||||
local result = {}
|
||||
if storage == nil or storage.getLoadingStations == nil then return result end
|
||||
for _, station in pairs(storage:getLoadingStations()) do
|
||||
if station.owningPlaceable == placeable and station.getAllFillLevels ~= nil then
|
||||
local ok, levels = pcall(station.getAllFillLevels, station, g_currentMission:getFarmId())
|
||||
for fillType, level in pairs(ok and type(levels) == "table" and levels or {}) do
|
||||
result[fillType] = math.max(result[fillType] or 0, level or 0)
|
||||
end
|
||||
end
|
||||
end
|
||||
return result
|
||||
end
|
||||
|
||||
local function husbandryEntries(placeable)
|
||||
local entries, seen = {}, {}
|
||||
local stationLevels = getHusbandryStationLevels(placeable)
|
||||
local food = placeable.spec_husbandryFood
|
||||
if food ~= nil then
|
||||
local total = 0
|
||||
@@ -850,10 +874,11 @@ local function husbandryEntries(placeable)
|
||||
end
|
||||
end
|
||||
if fillType ~= nil and not seen[fillType] and placeable.getHusbandryIsFillTypeSupported ~= nil and placeable:getHusbandryIsFillTypeSupported(fillType) then
|
||||
local level = placeable.getHusbandryFillLevel ~= nil and (placeable:getHusbandryFillLevel(fillType) or 0) or 0
|
||||
local own = placeable.getHusbandryFillLevel ~= nil and (placeable:getHusbandryFillLevel(fillType) or 0) or 0
|
||||
local level = math.max(own, stationLevels[fillType] or 0)
|
||||
if level > 0 then
|
||||
local free = placeable.getHusbandryFreeCapacity ~= nil and (placeable:getHusbandryFreeCapacity(fillType) or 0) or 0
|
||||
addEntry(entries, fillType, level, level + free)
|
||||
addEntry(entries, fillType, level, math.max(level, own + free))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||
<modDesc descVersion="107">
|
||||
<author>masterdraco</author>
|
||||
<version>1.16.2.0</version>
|
||||
<version>1.16.3.0</version>
|
||||
<title>
|
||||
<en>AD Smart Pickup</en>
|
||||
</title>
|
||||
|
||||
Reference in New Issue
Block a user