mirror of
https://github.com/Xevion/project-cybersyn.git
synced 2025-12-08 02:08:12 -06:00
fixed layout memory leak
This commit is contained in:
@@ -11,6 +11,7 @@ Date: 2022-12-23
|
||||
- Nonempty trains in depot are no longer put in manual mode, instead they are forced to park at the depot
|
||||
- Made several alerts persistent
|
||||
- Fixed bug with depot priority not working
|
||||
- Fixed a memory leak relating to train layouts
|
||||
---------------------------------------------------------------------------------------------------
|
||||
Version: 1.1.7
|
||||
Date: 2022-12-17
|
||||
|
||||
@@ -87,6 +87,19 @@ function remove_train(map_data, train_id, train)
|
||||
depot.available_train_id = nil
|
||||
end
|
||||
remove_available_train(map_data, train_id, train)
|
||||
|
||||
local layout_id = train.layout_id
|
||||
local count = global.layout_train_count[layout_id]
|
||||
if count <= 1 then
|
||||
global.layout_train_count[layout_id] = nil
|
||||
global.layouts[layout_id] = nil
|
||||
for _, station in pairs(global.stations) do
|
||||
station.accepted_layouts[layout_id] = nil
|
||||
end
|
||||
else
|
||||
global.layout_train_count[layout_id] = count - 1
|
||||
end
|
||||
|
||||
map_data.trains[train_id] = nil
|
||||
interface_raise_train_removed(train_id, train)
|
||||
end
|
||||
|
||||
@@ -135,7 +135,20 @@ local migrations_table = {
|
||||
control.parameters = params
|
||||
end
|
||||
for id, station in pairs(map_data.stations) do
|
||||
station.display_state = (station.display_state >= 2 and 1) + (station.display_state%2)*2
|
||||
station.display_state = (station.display_state >= 2 and 1 or 0) + (station.display_state%2)*2
|
||||
end
|
||||
|
||||
map_data.layout_train_count = {}
|
||||
for id, train in pairs(map_data.trains) do
|
||||
map_data.layout_train_count[train.layout_id] = (map_data.layout_train_count[train.layout_id] or 0) + 1
|
||||
end
|
||||
for layout_id, _ in pairs(map_data.layouts) do
|
||||
if not map_data.layout_train_count[layout_id] then
|
||||
map_data.layouts[layout_id] = nil
|
||||
for id, station in pairs(map_data.stations) do
|
||||
station.accepted_layouts[layout_id] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user