feat(mp): etape 1 - automatik kun på serveren, fælles gård via ADUtil.farmId, klienter skriver aldrig modens filer
This commit is contained in:
@@ -64,7 +64,7 @@ end
|
||||
-- Siloer der tager markens vare: marksilo først, gæringssiloer, så de nærmeste (samme regel som før).
|
||||
function SmartPickupFrame:fieldStoreContext(adEnv, info, plan, chosenIds)
|
||||
local fillType = fieldFillType(info, plan)
|
||||
local farmId = g_currentMission:getFarmId()
|
||||
local farmId = ADUtil.farmId()
|
||||
local fieldSilos, silosById = {}, {}
|
||||
for _, building in ipairs(ADFields.fieldSilos(adEnv, farmId, info)) do
|
||||
local markers = ADBuildings.getMarkers ~= nil and ADBuildings.getMarkers(building, "unload") or {}
|
||||
|
||||
@@ -83,7 +83,7 @@ function SmartPickupFrame:fillFieldSiloRows(adEnv)
|
||||
end
|
||||
|
||||
self:addTextRow(i18n:getText("spu_fs_storesTitle"))
|
||||
local farmId = g_currentMission:getFarmId()
|
||||
local farmId = ADUtil.farmId()
|
||||
for _, building in ipairs(ADBuildings.list(adEnv, farmId)) do
|
||||
if building.kind == "silo" then
|
||||
local option = self:addToggleRow("fsStore", ADBuildings.labelWithPlace(building), onOff, ADFieldSiloConfig.hasStore(cfg, building.id))
|
||||
|
||||
@@ -398,7 +398,7 @@ end
|
||||
function SmartPickupFrame:onAutoAllResult(yes)
|
||||
self:safe(function(frame)
|
||||
if not yes then return end
|
||||
local result = ADAutoCrop.applyAll(g_currentMission:getFarmId(), frame.getAdEnv(), {resetUser = frame.autoAllResetUser == true})
|
||||
local result = ADAutoCrop.applyAll(ADUtil.farmId(), frame.getAdEnv(), {resetUser = frame.autoAllResetUser == true})
|
||||
if result.scanning then
|
||||
frame.statusOverride = frame.i18n:getText("spu_field_autoAllScanning")
|
||||
frame.statusOverrideTicks = SmartPickupFrame.STATUS_OVERRIDE_TICKS
|
||||
|
||||
@@ -174,7 +174,7 @@ end
|
||||
-- og kan bære flowets varer. Bedste først (navnematch, så "Disponibel"). In-game 29/9: flowet kunne ikke oprettes
|
||||
-- uden at omdøbe en vogns parkering til flowets navn.
|
||||
function SmartPickupFrame:flowWagonContext(adEnv, preview)
|
||||
local farmId = g_currentMission:getFarmId()
|
||||
local farmId = ADUtil.farmId()
|
||||
local markers = adEnv.ADGraphManager:getMapMarkers()
|
||||
local wanted = flowFillTypes(adEnv, preview)
|
||||
local candidates = {}
|
||||
@@ -242,7 +242,7 @@ end
|
||||
|
||||
-- draft: kladden (eller selve run'et — samme feltnavne).
|
||||
function SmartPickupFrame:flowGuideContext(adEnv, draft)
|
||||
local farmId = g_currentMission:getFarmId()
|
||||
local farmId = ADUtil.farmId()
|
||||
local preview = ADFlowGuide.previewRun(draft, function(buildingId, role)
|
||||
local building = ADBuildings.find(adEnv, farmId, buildingId)
|
||||
local ids = {}
|
||||
|
||||
@@ -14,7 +14,7 @@ SmartPickupFrame.SELL_MARKERS_CACHE_MS = 30000
|
||||
function SmartPickupFrame:getSellMarkersCached(adEnv)
|
||||
local time = g_time or (os.clock ~= nil and os.clock() * 1000) or 0
|
||||
if self.sellMarkersCache == nil or (time - (self.sellMarkersCacheTime or 0)) > SmartPickupFrame.SELL_MARKERS_CACHE_MS then
|
||||
self.sellMarkersCache = ADSources.getSellMarkers(adEnv, g_currentMission:getFarmId())
|
||||
self.sellMarkersCache = ADSources.getSellMarkers(adEnv, ADUtil.farmId())
|
||||
self.sellMarkersCacheTime = time
|
||||
end
|
||||
return self.sellMarkersCache
|
||||
|
||||
@@ -36,7 +36,7 @@ end
|
||||
-- silo). Fast rækkefølge også for ens navne (sted, så id — review)
|
||||
local function collectBarns(adEnv)
|
||||
local barns, animalBarns = {}, {}
|
||||
for _, building in ipairs(ADBuildings.list(adEnv, g_currentMission:getFarmId()) or {}) do
|
||||
for _, building in ipairs(ADBuildings.list(adEnv, ADUtil.farmId()) or {}) do
|
||||
if building.kind == "husbandry" then table.insert(barns, building) end
|
||||
if building.kind == "husbandry" or (building.placeable ~= nil and building.placeable.spec_husbandryAnimals ~= nil) then
|
||||
table.insert(animalBarns, building)
|
||||
|
||||
@@ -50,7 +50,7 @@ function SmartPickupFrame:getInventory(adEnv)
|
||||
if ADSources == nil or ADSources.getFarmInventory == nil then
|
||||
return {}
|
||||
end
|
||||
return ADSources.getFarmInventory(adEnv, g_currentMission:getFarmId())
|
||||
return ADSources.getFarmInventory(adEnv, ADUtil.farmId())
|
||||
end
|
||||
|
||||
-- ---- detaljer for den valgte bygning ----
|
||||
@@ -71,7 +71,7 @@ end
|
||||
|
||||
-- Beregner stats for alle varer i bygningen (gårdens totaler og rater regnes én gang pr. opdatering).
|
||||
function SmartPickupFrame:computeBuildingStats(adEnv, entry, inventory)
|
||||
local farmId = g_currentMission:getFarmId()
|
||||
local farmId = ADUtil.farmId()
|
||||
local totals = ADStorageStats.farmTotals(inventory)
|
||||
local rates = ADSources.getFarmRates ~= nil and ADSources.getFarmRates(adEnv, farmId) or {}
|
||||
local stats = {}
|
||||
@@ -120,7 +120,7 @@ end
|
||||
function SmartPickupFrame:storageLabels(inventory, adEnv)
|
||||
local counts, seen, labels = {}, {}, {}
|
||||
for _, entry in ipairs(inventory) do counts[entry.name] = (counts[entry.name] or 0) + 1 end
|
||||
local farmId = g_currentMission ~= nil and g_currentMission.getFarmId ~= nil and g_currentMission:getFarmId() or nil
|
||||
local farmId = ADUtil.farmId()
|
||||
for index, entry in ipairs(inventory) do
|
||||
seen[entry.name] = (seen[entry.name] or 0) + 1
|
||||
local base = counts[entry.name] > 1 and string.format("%s #%d", entry.name, seen[entry.name]) or entry.name
|
||||
|
||||
@@ -77,7 +77,7 @@ end
|
||||
-- Fanens varer med statistik; gårdens totaler/kapacitet/rater regnes over HELE gården.
|
||||
function SmartPickupFrame:computeItemStats(adEnv, inventory, fullInventory)
|
||||
self.lastFullInventory = fullInventory -- til "kræver handling" -> flow (hvem bruger varen)
|
||||
local farmId = g_currentMission:getFarmId()
|
||||
local farmId = ADUtil.farmId()
|
||||
local totals = ADStorageStats.farmTotals(fullInventory)
|
||||
local capacities = ADStorageStats.farmCapacities(fullInventory)
|
||||
local rates = ADSources.getFarmRates ~= nil and ADSources.getFarmRates(adEnv, farmId) or {}
|
||||
|
||||
Reference in New Issue
Block a user