fix: alle salgssteder slår deres markør op fra stationen; lån ikke naboens markør (v1.62.60)
This commit is contained in:
@@ -709,7 +709,7 @@ function ADSources.findSellMarkers(adEnv, farmId)
|
||||
foreign = foreign[marker.id] == true})
|
||||
end
|
||||
end
|
||||
local picked = ADSources.pickStationMarkers(ADSources.addStationMarkers(adEnv, foreign, entries))
|
||||
local picked = ADSources.pickStationMarkers(ADSources.addStationMarkers(adEnv, foreign, entries, ADSources.sellStations(farmId)))
|
||||
pcall(ADSources.logSellMarkers, picked)
|
||||
return picked
|
||||
end
|
||||
@@ -740,7 +740,23 @@ end
|
||||
-- stationen: den der kører gennem triggeren, ellers den nærmeste der ikke er en anden bygnings eller en
|
||||
-- parkering/kobling (pickStationMarkers vælger så laget). In-game 7/10: "Buy All" blev kun bulkmarkedets, og
|
||||
-- senere vandt "Connect P Tippevogn 2" over spillerens nye "Liquid Buy" ved væsketanken.
|
||||
function ADSources.addStationMarkers(adEnv, foreign, entries)
|
||||
-- Alle salgssteder gården kan bruge (og ikke har slået fra) — også dem ingen markør slås op til fra markørsiden.
|
||||
function ADSources.sellStations(farmId)
|
||||
local result = {}
|
||||
local storage = g_currentMission ~= nil and g_currentMission.storageSystem or nil
|
||||
if storage == nil or storage.getUnloadingStations == nil then return result end
|
||||
for _, station in pairs(storage:getUnloadingStations() or {}) do
|
||||
if ADPrices.isSellingStation(station) and not ADSources.isSellBlocked(station)
|
||||
and (ADSmartPickup.canUseStation == nil or ADSmartPickup.canUseStation(farmId, station)) then
|
||||
table.insert(result, station)
|
||||
end
|
||||
end
|
||||
return result
|
||||
end
|
||||
|
||||
-- extraStations: salgssteder der også slås op fra stationen, selv om ingen markør pegede på dem (in-game 7/10 19:18:
|
||||
-- væskemarkedet manglede helt, så gyllen havde intet salgssted).
|
||||
function ADSources.addStationMarkers(adEnv, foreign, entries, extraStations)
|
||||
if ADFieldWork == nil or ADFieldWork.stationMarkerAt == nil then
|
||||
return entries
|
||||
end
|
||||
@@ -752,6 +768,15 @@ function ADSources.addStationMarkers(adEnv, foreign, entries)
|
||||
end
|
||||
byStation[entry.station][entry.marker.id] = entry
|
||||
end
|
||||
for _, station in ipairs(extraStations or {}) do
|
||||
if byStation[station] == nil then
|
||||
byStation[station] = {}
|
||||
table.insert(stations, station)
|
||||
end
|
||||
end
|
||||
-- markører andre salgssteder allerede har valgt (efter lag): lånes kun ved gennemkørsel
|
||||
local claimedBy = {}
|
||||
for _, entry in ipairs(ADSources.pickStationMarkers(entries)) do claimedBy[entry.marker.id] = entry.station end
|
||||
local accept = function(marker) return not isServiceMarker(marker) and not (foreign or {})[marker.id] end
|
||||
local result = {}
|
||||
for _, entry in ipairs(entries) do table.insert(result, entry) end
|
||||
@@ -759,7 +784,8 @@ function ADSources.addStationMarkers(adEnv, foreign, entries)
|
||||
local ok, id, through = pcall(ADFieldWork.stationMarkerAt, adEnv, ADSmartPickup.unloadTriggerPoints(station),
|
||||
ADSmartPickup.MAX_MARKER_TO_TRIGGER_DISTANCE or 40, accept)
|
||||
local marker = ok and id ~= nil and adEnv.ADGraphManager:getMapMarkerByWayPointId(id) or nil
|
||||
if marker ~= nil then
|
||||
local borrowed = marker ~= nil and through ~= true and claimedBy[id] ~= nil and claimedBy[id] ~= station
|
||||
if marker ~= nil and not borrowed then
|
||||
local existing = byStation[station][id]
|
||||
if existing ~= nil then
|
||||
existing.through = existing.through or through == true
|
||||
|
||||
Reference in New Issue
Block a user