mirror of
https://github.com/Xevion/project-cybersyn.git
synced 2025-12-09 00:08:04 -06:00
Experimental 1.2.2 (#21)
---------------------------------------------------------------------------------------------------
Version: 1.2.2
Date: 2022-12-29
Features:
- Added a station combinator setting to enable or disable the inactivity condition in a train's orders, disabled by default (but not in <=1.2.1 worlds)
- Added a depot combinator setting to enable depot bypass, enabled by default
- Added a depot combinator setting to force trains to park at the same depot, enabled by default
- Added network "each" for depots
- Added a map setting to modify the default locked slots per cargo wagon value
- Added a map setting to modify the default priority value
- Added a map setting to allow trains with cargo at depots, disabled by default
Changes:
- Inverted the sign of combinator outputs, a map setting has been added to maintain backwards compatibility with <=1.2.1 worlds
- Overhauled the wagon control combinator algorithm to spread items out between cargo wagons
- Trains with cargo held in the depot now check if they have been emptied and reset when they have
- Cargo capacity is now prioritized over distance when choosing trains
- Increased the default request threshold to 2000
- Improved English localization
Bugfixes:
- Fixed a bug where trains with cargo sometimes weren't getting held at depots
- Fixed a crash caused by changing a station combinator to the "each" network during a bad tick
- Fixed a crash when changing a refueler away from network each
- Multiple rare bugs and crashes relating to wagon control combinators are fixed
- Fixed a bug with refueler direct orders not being applied after moving through a space elevator
- Fixed a bug where filtered slots sometimes weren't being removed
---------------------------------------------------------------------------------------------------
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
--By Mami
|
||||
local flib_migration = require("__flib__.migration")
|
||||
|
||||
|
||||
@@ -103,23 +104,40 @@ local migrations_table = {
|
||||
map_data.each_refuelers = {}
|
||||
map_data.se_tele_old_id = nil
|
||||
|
||||
for k, comb in pairs(map_data.to_comb) do
|
||||
for id, comb in pairs(map_data.to_comb) do
|
||||
local control = get_comb_control(comb)
|
||||
local params = control.parameters
|
||||
local params_old = map_data.to_comb_params[id]
|
||||
local bits = params.second_constant or 0
|
||||
local bits_old = params_old.second_constant or 0
|
||||
|
||||
local allows_all_trains = bits%2
|
||||
local is_pr_state = math.floor(bits/2)%3
|
||||
local allows_all_trains_old = bits_old%2
|
||||
local is_pr_state_old = math.floor(bits_old/2)%3
|
||||
|
||||
local new_bits = bit32.bor(is_pr_state, allows_all_trains*4)
|
||||
params.second_constant = new_bits
|
||||
bits = bit32.bor(is_pr_state, allows_all_trains*4)
|
||||
bits_old = bit32.bor(is_pr_state_old, allows_all_trains_old*4)
|
||||
params.second_constant = bits
|
||||
params_old.second_constant = bits_old
|
||||
|
||||
control.parameters = params
|
||||
map_data.to_comb_params[id] = params_old
|
||||
end
|
||||
for id, station in pairs(map_data.stations) do
|
||||
station.display_state = (station.display_state >= 2 and 1 or 0) + (station.display_state%2)*2
|
||||
|
||||
set_station_from_comb_state(station)
|
||||
update_stop_if_auto(map_data, station, true)
|
||||
local params = get_comb_params(station.entity_comb1)
|
||||
|
||||
local bits = params.second_constant or 0
|
||||
local is_pr_state = bit32.extract(bits, 0, 2)
|
||||
local allows_all_trains = bit32.extract(bits, SETTING_DISABLE_ALLOW_LIST) > 0
|
||||
local is_stack = bit32.extract(bits, SETTING_IS_STACK) > 0
|
||||
|
||||
station.allows_all_trains = allows_all_trains
|
||||
station.is_stack = is_stack
|
||||
station.is_p = (is_pr_state == 0 or is_pr_state == 1) or nil
|
||||
station.is_r = (is_pr_state == 0 or is_pr_state == 2) or nil
|
||||
end
|
||||
|
||||
map_data.layout_train_count = {}
|
||||
@@ -135,6 +153,77 @@ local migrations_table = {
|
||||
end
|
||||
end
|
||||
end,
|
||||
["1.2.2"] = function()
|
||||
---@type MapData
|
||||
local map_data = global
|
||||
local setting = settings.global["cybersyn-invert-sign"]
|
||||
setting.value = true
|
||||
settings.global["cybersyn-invert-sign"] = setting
|
||||
|
||||
for id, comb in pairs(map_data.to_comb) do
|
||||
local control = get_comb_control(comb)
|
||||
local params = control.parameters
|
||||
local params_old = map_data.to_comb_params[id]
|
||||
local bits = params.second_constant or 0
|
||||
local bits_old = params_old.second_constant or 0
|
||||
|
||||
bits = bit32.replace(bits, 1, SETTING_ENABLE_INACTIVE)--[[@as int]]
|
||||
bits = bit32.replace(bits, 1, SETTING_ENABLE_INACTIVE)--[[@as int]]
|
||||
bits_old = bit32.replace(bits_old, 1, SETTING_USE_ANY_DEPOT)--[[@as int]]
|
||||
bits_old = bit32.replace(bits_old, 1, SETTING_USE_ANY_DEPOT)--[[@as int]]
|
||||
params.second_constant = bits
|
||||
params_old.second_constant = bits_old
|
||||
|
||||
control.parameters = params
|
||||
map_data.to_comb_params[id] = params_old
|
||||
end
|
||||
for _, station in pairs(map_data.stations) do
|
||||
station.enable_inactive = true
|
||||
end
|
||||
for train_id, train in pairs(map_data.trains) do
|
||||
train.depot_id = train.parked_at_depot_id
|
||||
if not train.depot_id then
|
||||
local e = get_any_train_entity(train.entity)
|
||||
local stops = e.force.get_train_stops({name = train.depot_name, surface = e.surface})
|
||||
for stop in rnext_consume, stops do
|
||||
local new_depot_id = stop.unit_number
|
||||
if map_data.depots[new_depot_id] then
|
||||
train.depot_id = new_depot_id--[[@as uint]]
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
if not train.depot_id then
|
||||
train.depot_id = next(map_data.depots)
|
||||
end
|
||||
if not train.depot_id then
|
||||
train.entity.manual_mode = true
|
||||
send_alert_depot_of_train_broken(map_data, train.entity)
|
||||
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 _, stop in pairs(global.stations) do
|
||||
stop.accepted_layouts[layout_id] = nil
|
||||
end
|
||||
for _, stop in pairs(global.refuelers) do
|
||||
stop.accepted_layouts[layout_id] = nil
|
||||
end
|
||||
else
|
||||
global.layout_train_count[layout_id] = count - 1
|
||||
end
|
||||
map_data.trains[train_id] = nil
|
||||
end
|
||||
|
||||
train.use_any_depot = true
|
||||
train.disable_bypass = nil
|
||||
|
||||
train.depot_name = nil
|
||||
train.se_depot_surface_i = nil
|
||||
train.parked_at_depot_id = nil
|
||||
end
|
||||
end
|
||||
}
|
||||
--STATUS_R_TO_D = 5
|
||||
|
||||
|
||||
Reference in New Issue
Block a user