feat: kørsler følger markørnavne efter AD-omnummerering (v1.62.135)
This commit is contained in:
@@ -8,6 +8,7 @@ står i [docs/BRUGERMANUAL.md](docs/BRUGERMANUAL.md) (dansk) og [docs/USER_MANUA
|
|||||||
|
|
||||||
## 1.62 — Kæder slås selv til
|
## 1.62 — Kæder slås selv til
|
||||||
|
|
||||||
|
- **1.62.135** Kørslernes kilder og mål gemmes nu også med markørens NAVN (runs.xml: sourceNames/targetNames). Sletter eller flytter spilleren vejpunkter i AutoDrive, omnummereres alle senere punkter, og et gemt id peger på et tilfældigt punkt; modden følger nu navnet og logger "markøren er flyttet (vejpunkt a -> b) — fulgt". In-game 10/10: æg-runden mistede alle 7 kilder, Milk Run 2, "gra&s to Hay" sit mål, mens vejnettet blev rettet live.
|
||||||
- **1.62.134** Genindlæsning: et puljesæt (traktor med puljeredskab), hvis gemte Courseplay-kursus ikke hører til en mark i gang med dets rolle, genstartes ikke længere, men sendes hjem. In-game 10/10: 6230 TTV 5 med læssevogn fra F13 (færdig kl. 21:19) blev genstartet ved hver genindlæsning og kørte det gamle kursus over F11 under såning.
|
- **1.62.134** Genindlæsning: et puljesæt (traktor med puljeredskab), hvis gemte Courseplay-kursus ikke hører til en mark i gang med dets rolle, genstartes ikke længere, men sendes hjem. In-game 10/10: 6230 TTV 5 med læssevogn fra F13 (færdig kl. 21:19) blev genstartet ved hver genindlæsning og kørte det gamle kursus over F11 under såning.
|
||||||
- **1.62.133** Marksilo: en vogn med last, der efter en genindlæsning holder ved et Wait-punkt (lageret var fuldt før gemningen, og ventetilstanden gik tabt), sendes nu videre til et lager med plads. In-game 10/10: 6230 TTV 7 stod ved Sheep Wait 3 med 52.000 l TMR.
|
- **1.62.133** Marksilo: en vogn med last, der efter en genindlæsning holder ved et Wait-punkt (lageret var fuldt før gemningen, og ventetilstanden gik tabt), sendes nu videre til et lager med plads. In-game 10/10: 6230 TTV 7 stod ved Sheep Wait 3 med 52.000 l TMR.
|
||||||
- **1.62.132** Ny konsolkommando `spuForgetCourses <marknr>` (uden argument: alle marker): glemmer de gemte Courseplay-kurser, så næste start beregner nyt. Til marker, der har fået bygninger: formen ændres ikke, så kurset blev genbrugt og gik gennem bygningerne (in-game 9/10).
|
- **1.62.132** Ny konsolkommando `spuForgetCourses <marknr>` (uden argument: alle marker): glemmer de gemte Courseplay-kurser, så næste start beregner nyt. Til marker, der har fået bygninger: formen ændres ikke, så kurset blev genbrugt og gik gennem bygningerne (in-game 9/10).
|
||||||
|
|||||||
@@ -92,6 +92,7 @@ local function copyRun(run)
|
|||||||
name = run.name,
|
name = run.name,
|
||||||
kind = run.kind,
|
kind = run.kind,
|
||||||
sourceWayPointIds = copyList(run.sourceWayPointIds),
|
sourceWayPointIds = copyList(run.sourceWayPointIds),
|
||||||
|
sourceNames = copyList(run.sourceNames),
|
||||||
sourceBuildingIds = copyList(run.sourceBuildingIds),
|
sourceBuildingIds = copyList(run.sourceBuildingIds),
|
||||||
targetBuildingIds = copyList(run.targetBuildingIds),
|
targetBuildingIds = copyList(run.targetBuildingIds),
|
||||||
storeBuildingIds = copyList(run.storeBuildingIds),
|
storeBuildingIds = copyList(run.storeBuildingIds),
|
||||||
@@ -103,6 +104,7 @@ local function copyRun(run)
|
|||||||
collectRound = run.collectRound,
|
collectRound = run.collectRound,
|
||||||
targetWayPointId = run.targetWayPointId,
|
targetWayPointId = run.targetWayPointId,
|
||||||
targetWayPointIds = copyList(run.targetWayPointIds),
|
targetWayPointIds = copyList(run.targetWayPointIds),
|
||||||
|
targetNames = copyList(run.targetNames),
|
||||||
ingredientMode = run.ingredientMode,
|
ingredientMode = run.ingredientMode,
|
||||||
ingredients = copyList(run.ingredients),
|
ingredients = copyList(run.ingredients),
|
||||||
waitPoolGroup = run.waitPoolGroup,
|
waitPoolGroup = run.waitPoolGroup,
|
||||||
@@ -145,6 +147,7 @@ function ADRuns.createRun(store, name, kind)
|
|||||||
name = name,
|
name = name,
|
||||||
kind = ADRuns.KINDS[kind] and kind or "supply",
|
kind = ADRuns.KINDS[kind] and kind or "supply",
|
||||||
sourceWayPointIds = {},
|
sourceWayPointIds = {},
|
||||||
|
sourceNames = {},
|
||||||
sourceBuildingIds = {},
|
sourceBuildingIds = {},
|
||||||
targetBuildingIds = {},
|
targetBuildingIds = {},
|
||||||
storeBuildingIds = {},
|
storeBuildingIds = {},
|
||||||
@@ -156,6 +159,7 @@ function ADRuns.createRun(store, name, kind)
|
|||||||
collectRound = false,
|
collectRound = false,
|
||||||
targetWayPointId = nil,
|
targetWayPointId = nil,
|
||||||
targetWayPointIds = {},
|
targetWayPointIds = {},
|
||||||
|
targetNames = {},
|
||||||
ingredientMode = "auto",
|
ingredientMode = "auto",
|
||||||
ingredients = {},
|
ingredients = {},
|
||||||
waitPoolGroup = "",
|
waitPoolGroup = "",
|
||||||
@@ -207,6 +211,10 @@ function ADRuns.updateRun(store, runId, changes)
|
|||||||
run.targetWayPointIds = {changes.targetWayPointId}
|
run.targetWayPointIds = {changes.targetWayPointId}
|
||||||
end
|
end
|
||||||
run.targetWayPointId = run.targetWayPointIds[1]
|
run.targetWayPointId = run.targetWayPointIds[1]
|
||||||
|
if changes.targetNames ~= nil then run.targetNames = copyList(changes.targetNames)
|
||||||
|
elseif changes.targetWayPointIds ~= nil or changes.targetWayPointId ~= nil then run.targetNames = {} end
|
||||||
|
if changes.sourceNames ~= nil then run.sourceNames = copyList(changes.sourceNames)
|
||||||
|
elseif changes.sourceWayPointIds ~= nil then run.sourceNames = {} end
|
||||||
if ADRuns.INGREDIENT_MODES[changes.ingredientMode] then run.ingredientMode = changes.ingredientMode end
|
if ADRuns.INGREDIENT_MODES[changes.ingredientMode] then run.ingredientMode = changes.ingredientMode end
|
||||||
if changes.ingredients ~= nil then run.ingredients = copyList(changes.ingredients) end
|
if changes.ingredients ~= nil then run.ingredients = copyList(changes.ingredients) end
|
||||||
if changes.waitPoolGroup ~= nil then run.waitPoolGroup = changes.waitPoolGroup end
|
if changes.waitPoolGroup ~= nil then run.waitPoolGroup = changes.waitPoolGroup end
|
||||||
@@ -435,6 +443,34 @@ function ADRuns.parseIngredients(text)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Flade poster (kun strenge/tal) til XML-laget, i store'ens rækkefølge.
|
-- Flade poster (kun strenge/tal) til XML-laget, i store'ens rækkefølge.
|
||||||
|
-- Markørnavne gemt ved siden af vejpunkt-id'erne ("a|b|c" -> liste). AutoDrive omnummererer alle senere vejpunkter,
|
||||||
|
-- når spilleren sletter et, så et gemt id kan pege på et tilfældigt punkt (in-game 10/10: æg-runden mistede alle
|
||||||
|
-- 7 kilder, mælk 2, græs-til-hø sit mål, mens spilleren rettede vejnettet).
|
||||||
|
function ADRuns.splitNames(text)
|
||||||
|
local names = {}
|
||||||
|
for token in string.gmatch(tostring(text or ""), "[^|]+") do table.insert(names, token) end
|
||||||
|
return names
|
||||||
|
end
|
||||||
|
|
||||||
|
-- ids + names (parallelle lister) -> nye ids: står markøren med det gemte navn ikke længere på id'et, følges navnet.
|
||||||
|
-- idOfName(name) -> id | nil; nameOfId(id) -> navn | nil. -> nye ids, flytninger {{name, from, to}}
|
||||||
|
function ADRuns.remapByName(ids, names, idOfName, nameOfId)
|
||||||
|
local result, moves = {}, {}
|
||||||
|
for index, id in ipairs(ids or {}) do
|
||||||
|
local wanted = names ~= nil and names[index] or nil
|
||||||
|
local newId = id
|
||||||
|
if wanted ~= nil and wanted ~= "" and nameOfId(id) ~= wanted then
|
||||||
|
local found = idOfName(wanted)
|
||||||
|
if found ~= nil and found ~= id then
|
||||||
|
newId = found
|
||||||
|
table.insert(moves, {name = wanted, from = id, to = found})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
table.insert(result, newId)
|
||||||
|
end
|
||||||
|
return result, moves
|
||||||
|
end
|
||||||
|
|
||||||
function ADRuns.toRecords(store)
|
function ADRuns.toRecords(store)
|
||||||
local records = {}
|
local records = {}
|
||||||
for index, run in ipairs(store.runs) do
|
for index, run in ipairs(store.runs) do
|
||||||
@@ -451,6 +487,8 @@ function ADRuns.toRecords(store)
|
|||||||
vehicleIds = copyList(run.vehicleIds),
|
vehicleIds = copyList(run.vehicleIds),
|
||||||
kind = run.kind,
|
kind = run.kind,
|
||||||
sources = table.concat(run.sourceWayPointIds or {}, " "),
|
sources = table.concat(run.sourceWayPointIds or {}, " "),
|
||||||
|
sourceNames = table.concat(run.sourceNames or {}, "|"),
|
||||||
|
targetNames = table.concat(run.targetNames or {}, "|"),
|
||||||
sourceBuildings = table.concat(run.sourceBuildingIds or {}, " "),
|
sourceBuildings = table.concat(run.sourceBuildingIds or {}, " "),
|
||||||
targetBuildings = table.concat(run.targetBuildingIds or {}, " "),
|
targetBuildings = table.concat(run.targetBuildingIds or {}, " "),
|
||||||
storeBuildings = table.concat(run.storeBuildingIds or {}, " "),
|
storeBuildings = table.concat(run.storeBuildingIds or {}, " "),
|
||||||
@@ -500,6 +538,8 @@ function ADRuns.fromRecords(records)
|
|||||||
name = record.name,
|
name = record.name,
|
||||||
kind = ADRuns.KINDS[record.kind] and record.kind or "supply",
|
kind = ADRuns.KINDS[record.kind] and record.kind or "supply",
|
||||||
sourceWayPointIds = sources,
|
sourceWayPointIds = sources,
|
||||||
|
sourceNames = ADRuns.splitNames(record.sourceNames),
|
||||||
|
targetNames = ADRuns.splitNames(record.targetNames),
|
||||||
sourceBuildingIds = parseIds(record.sourceBuildings),
|
sourceBuildingIds = parseIds(record.sourceBuildings),
|
||||||
targetBuildingIds = parseIds(record.targetBuildings),
|
targetBuildingIds = parseIds(record.targetBuildings),
|
||||||
storeBuildingIds = parseIds(record.storeBuildings),
|
storeBuildingIds = parseIds(record.storeBuildings),
|
||||||
|
|||||||
@@ -483,6 +483,21 @@ function ADRunsController.resolveMarkers(adEnv, run)
|
|||||||
local role = run.kind == "outbound" and "load" or "unload"
|
local role = run.kind == "outbound" and "load" or "unload"
|
||||||
local buildingIds = run.kind == "outbound" and run.sourceBuildingIds or run.targetBuildingIds
|
local buildingIds = run.kind == "outbound" and run.sourceBuildingIds or run.targetBuildingIds
|
||||||
local existing = run.kind == "outbound" and run.sourceWayPointIds or ADRunsController.getRunTargets(run)
|
local existing = run.kind == "outbound" and run.sourceWayPointIds or ADRunsController.getRunTargets(run)
|
||||||
|
-- gemte markørnavne følges, når AutoDrive har omnummereret vejpunkterne (spilleren sletter/flytter punkter live)
|
||||||
|
local graph = adEnv.ADGraphManager
|
||||||
|
local storedNames = run.kind == "outbound" and run.sourceNames or run.targetNames
|
||||||
|
if storedNames ~= nil and #storedNames > 0 and graph ~= nil and graph.getMapMarkerByWayPointId ~= nil then
|
||||||
|
local byName = {}
|
||||||
|
for _, marker in pairs(graph:getMapMarkers() or {}) do
|
||||||
|
if marker.name ~= nil and byName[marker.name] == nil then byName[marker.name] = marker.id end
|
||||||
|
end
|
||||||
|
local moves
|
||||||
|
existing, moves = ADRuns.remapByName(existing, storedNames, function(name) return byName[name] end,
|
||||||
|
function(id) local marker = graph:getMapMarkerByWayPointId(id) return marker ~= nil and marker.name or nil end)
|
||||||
|
for _, move in ipairs(moves) do
|
||||||
|
Logging.info(ADRunsController.LOG_PREFIX .. "run '%s': markøren '%s' er flyttet (vejpunkt %d -> %d) — fulgt", tostring(run.name), tostring(move.name), move.from, move.to)
|
||||||
|
end
|
||||||
|
end
|
||||||
local resolved, seen = {}, {}
|
local resolved, seen = {}, {}
|
||||||
for _, buildingId in ipairs(buildingIds or {}) do
|
for _, buildingId in ipairs(buildingIds or {}) do
|
||||||
local building = ADBuildings.find(adEnv, farmId, buildingId)
|
local building = ADBuildings.find(adEnv, farmId, buildingId)
|
||||||
@@ -533,12 +548,20 @@ function ADRunsController.resolveMarkers(adEnv, run)
|
|||||||
if #pruned > 0 then
|
if #pruned > 0 then
|
||||||
Logging.info(ADRunsController.LOG_PREFIX .. "run '%s': gamle markører fjernet (ingen kilde eller dublet af valgt bygning): %s", tostring(run.name), table.concat(pruned, " "))
|
Logging.info(ADRunsController.LOG_PREFIX .. "run '%s': gamle markører fjernet (ingen kilde eller dublet af valgt bygning): %s", tostring(run.name), table.concat(pruned, " "))
|
||||||
end
|
end
|
||||||
if not listEquals(resolved, existing or {}) then
|
-- navnene gemmes sammen med id'erne, så de kan følges efter en omnummerering
|
||||||
local changes = run.kind == "outbound" and {sourceWayPointIds = resolved} or {targetWayPointIds = resolved}
|
local names = {}
|
||||||
|
for _, wayPointId in ipairs(resolved) do
|
||||||
|
local marker = graph ~= nil and graph.getMapMarkerByWayPointId ~= nil and graph:getMapMarkerByWayPointId(wayPointId) or nil
|
||||||
|
table.insert(names, marker ~= nil and tostring(marker.name) or "")
|
||||||
|
end
|
||||||
|
local current = run.kind == "outbound" and run.sourceWayPointIds or ADRunsController.getRunTargets(run)
|
||||||
|
if not listEquals(resolved, current or {}) or not listEquals(names, storedNames or {}) then
|
||||||
|
local changes = run.kind == "outbound" and {sourceWayPointIds = resolved, sourceNames = names} or {targetWayPointIds = resolved, targetNames = names}
|
||||||
ADRunsController.store = ADRuns.updateRun(ADRunsController.store, run.id, changes)
|
ADRunsController.store = ADRuns.updateRun(ADRunsController.store, run.id, changes)
|
||||||
local updated = ADRuns.getRun(ADRunsController.store, run.id)
|
local updated = ADRuns.getRun(ADRunsController.store, run.id)
|
||||||
if updated ~= nil then
|
if updated ~= nil then
|
||||||
run.sourceWayPointIds, run.targetWayPointIds, run.targetWayPointId = updated.sourceWayPointIds, updated.targetWayPointIds, updated.targetWayPointId
|
run.sourceWayPointIds, run.targetWayPointIds, run.targetWayPointId = updated.sourceWayPointIds, updated.targetWayPointIds, updated.targetWayPointId
|
||||||
|
run.sourceNames, run.targetNames = updated.sourceNames, updated.targetNames
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return {missing = missing}
|
return {missing = missing}
|
||||||
|
|||||||
@@ -39,6 +39,9 @@ function ADRunsStorage.writeRecords(xmlFile, records)
|
|||||||
-- v2: udkørsel
|
-- v2: udkørsel
|
||||||
xmlFile:setString(key .. "#kind", record.kind or "supply")
|
xmlFile:setString(key .. "#kind", record.kind or "supply")
|
||||||
xmlFile:setString(key .. "#sources", record.sources or "")
|
xmlFile:setString(key .. "#sources", record.sources or "")
|
||||||
|
-- v4: markørnavne (følger markøren, når AutoDrive omnummererer vejpunkter)
|
||||||
|
xmlFile:setString(key .. "#sourceNames", record.sourceNames or "")
|
||||||
|
xmlFile:setString(key .. "#targetNames", record.targetNames or "")
|
||||||
-- v3: bygninger (flow-tavlen)
|
-- v3: bygninger (flow-tavlen)
|
||||||
xmlFile:setString(key .. "#sourceBuildings", record.sourceBuildings or "")
|
xmlFile:setString(key .. "#sourceBuildings", record.sourceBuildings or "")
|
||||||
xmlFile:setString(key .. "#targetBuildings", record.targetBuildings or "")
|
xmlFile:setString(key .. "#targetBuildings", record.targetBuildings or "")
|
||||||
@@ -75,6 +78,8 @@ function ADRunsStorage.readRecords(xmlFile)
|
|||||||
returnBelow = xmlFile:getInt(key .. "#returnBelow"),
|
returnBelow = xmlFile:getInt(key .. "#returnBelow"),
|
||||||
kind = xmlFile:getString(key .. "#kind"),
|
kind = xmlFile:getString(key .. "#kind"),
|
||||||
sources = xmlFile:getString(key .. "#sources"),
|
sources = xmlFile:getString(key .. "#sources"),
|
||||||
|
sourceNames = xmlFile:getString(key .. "#sourceNames"),
|
||||||
|
targetNames = xmlFile:getString(key .. "#targetNames"),
|
||||||
sourceBuildings = xmlFile:getString(key .. "#sourceBuildings"),
|
sourceBuildings = xmlFile:getString(key .. "#sourceBuildings"),
|
||||||
targetBuildings = xmlFile:getString(key .. "#targetBuildings"),
|
targetBuildings = xmlFile:getString(key .. "#targetBuildings"),
|
||||||
storeBuildings = xmlFile:getString(key .. "#storeBuildings"),
|
storeBuildings = xmlFile:getString(key .. "#storeBuildings"),
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||||
<modDesc descVersion="107">
|
<modDesc descVersion="107">
|
||||||
<author>masterdraco</author>
|
<author>masterdraco</author>
|
||||||
<version>1.62.134.0</version>
|
<version>1.62.135.0</version>
|
||||||
<title>
|
<title>
|
||||||
<en>AD Smart Pickup</en>
|
<en>AD Smart Pickup</en>
|
||||||
</title>
|
</title>
|
||||||
|
|||||||
Reference in New Issue
Block a user