fixed a crash relating to space elevators

This commit is contained in:
Monica Moniot
2022-12-01 14:18:13 -05:00
parent 44d2d043e7
commit 5ea40971f1
3 changed files with 30 additions and 1 deletions

View File

@@ -41,7 +41,7 @@ cybersyn-request-threshold=Request threshold
cybersyn-locked-slots=Locked slots per cargo wagon
[cybersyn-messages]
missing-trains=No trains available to make a delivery from __2__ to __1__
missing-trains=Could not find a train to make a delivery from __2__ to __1__
lost-train=A train from depot __1__ has become lost
nonempty-train=A train is being held in the depot because it still has cargo
unexpected-train=A train has unexpectedly returned to the depot before completing its delivery

View File

@@ -998,6 +998,14 @@ local function main()
local train = map_data.trains[old_id]
if not train then return end
if train.is_available then
local network = map_data.available_trains[train.network_name--[[@as string]]]
if network then
network[new_id] = true
network[old_id] = nil
end
end
map_data.trains[new_id] = train
map_data.trains[old_id] = nil
train.entity = train_entity

View File

@@ -142,6 +142,27 @@ local migrations_table = {
end
end
end,
["1.0.7"] = function()
---@type MapData
local map_data = global
map_data.tick_state = STATE_INIT
map_data.tick_data = {}
if IS_SE_PRESENT then
for k, v in pairs(map_data.available_trains) do
for id, _ in pairs(v) do
local train = map_data.trains[id]
if not train then
v[id] = nil
end
end
end
for id, v in pairs(map_data.trains) do
if v.is_available then
map_data.available_trains[v.network_name--[[@as string]]][id] = true
end
end
end
end,
}
---@param data ConfigurationChangedData