fix(ejerskab): jord-bundne kortanlæg (boughtWithFarmland / ejer 15) er gårdens når jorden under dem er købt — Dakotas BGA500kw på jordlod 69 (v1.17.7.0)

This commit is contained in:
2026-09-24 04:57:12 +02:00
parent b603bd7765
commit c814557ae1
8 changed files with 84 additions and 13 deletions
+12 -2
View File
@@ -63,6 +63,16 @@ local function getAutoDriveEnv()
return nil
end
-- Adgang til en station: spillets adgangstjek, eller stationens bygning er gårdens efter den fælles
-- ejerregel (jord-bundne kortanlæg som Dakotas BGA står med ejer 15 selv på gårdens jord).
function ADSmartPickup.canUseStation(farmId, station)
local access = g_currentMission ~= nil and g_currentMission.accessHandler or nil
if access == nil or access:canFarmAccess(farmId, station) then
return true
end
return station.owningPlaceable ~= nil and ADPrices ~= nil and ADPrices.isOwnedBy ~= nil and ADPrices.isOwnedBy(station.owningPlaceable, farmId)
end
function ADSmartPickup.getFarmId(vehicle)
if vehicle.getOwnerFarmId ~= nil then
local farmId = vehicle:getOwnerFarmId()
@@ -140,7 +150,7 @@ local function getClosestStation(adEnv, candidateStations, triggersField, nodeFi
local maxFallbackDistance = direction ~= nil and ADSmartPickup.MAX_FALLBACK_TRIGGER_DISTANCE or ADSmartPickup.MAX_MARKER_TO_TRIGGER_DISTANCE
local best = {any = {distance = maxFallbackDistance}, behind = {distance = ADSmartPickup.MAX_MARKER_TO_TRIGGER_DISTANCE}}
for _, station in pairs(candidateStations) do
if g_currentMission.accessHandler:canFarmAccess(farmId, station) then
if ADSmartPickup.canUseStation(farmId, station) then
local closest, closestBehind = getDistancesToTriggers(station[triggersField], nodeFields, wayPoint, direction)
if closest < best.any.distance then
best.any = {distance = closest, station = station}
@@ -182,7 +192,7 @@ function ADSmartPickup.getLoadStationNearWayPointId(adEnv, wayPointId, farmId, m
end
local best, bestDistance = nil, maxDistance or ADSmartPickup.MAX_MARKER_TO_TRIGGER_DISTANCE
for _, station in pairs(g_currentMission.storageSystem:getLoadingStations()) do
if g_currentMission.accessHandler:canFarmAccess(farmId, station) then
if ADSmartPickup.canUseStation(farmId, station) then
local closest = getDistancesToTriggers(station.loadTriggers, LOAD_TRIGGER_NODE_FIELDS, wayPoint, nil)
if closest < bestDistance then
best, bestDistance = station, closest