mirror of
https://github.com/Xevion/project-cybersyn.git
synced 2025-12-08 06:08:03 -06:00
fixed display bug
This commit is contained in:
@@ -24,8 +24,8 @@ function remove_manifest(map_data, station, manifest, sign)
|
||||
end
|
||||
set_comb2(map_data, station)
|
||||
station.deliveries_total = station.deliveries_total - 1
|
||||
if station.deliveries_total == 0 and band(station.display_state, 4) > 0 then
|
||||
station.display_state = station.display_state - 4
|
||||
if station.deliveries_total == 0 and band(station.display_state, 1) > 0 then
|
||||
station.display_state = station.display_state - 1
|
||||
update_display(map_data, station)
|
||||
end
|
||||
end
|
||||
@@ -100,14 +100,11 @@ function create_delivery(map_data, r_station_id, p_station_id, train_id, manifes
|
||||
set_comb2(map_data, p_station)
|
||||
set_comb2(map_data, r_station)
|
||||
|
||||
if band(p_station.display_state, 4) == 0 then
|
||||
p_station.display_state = 4
|
||||
p_station.display_state = 1
|
||||
update_display(map_data, p_station)
|
||||
end
|
||||
if band(r_station.display_state, 4) == 0 then
|
||||
r_station.display_state = 4
|
||||
r_station.display_state = 1
|
||||
update_display(map_data, r_station)
|
||||
end
|
||||
|
||||
interface_raise_train_status_changed(train_id, old_status, STATUS_TO_P)
|
||||
else
|
||||
interface_raise_train_dispatch_failed(train_id)
|
||||
@@ -244,8 +241,8 @@ local function tick_dispatch(map_data, mod_settings)
|
||||
else
|
||||
for i, id in ipairs(r_stations) do
|
||||
local station = stations[id]
|
||||
if station and band(station.display_state, 1) == 0 then
|
||||
station.display_state = station.display_state + 1
|
||||
if station and band(station.display_state, 2) == 0 then
|
||||
station.display_state = station.display_state + 2
|
||||
update_display(map_data, station)
|
||||
end
|
||||
end
|
||||
@@ -290,8 +287,8 @@ local function tick_dispatch(map_data, mod_settings)
|
||||
if not r_station_i then
|
||||
for _, id in ipairs(r_stations) do
|
||||
local station = stations[id]
|
||||
if station and band(station.display_state, 1) == 0 then
|
||||
station.display_state = station.display_state + 1
|
||||
if station and band(station.display_state, 2) == 0 then
|
||||
station.display_state = station.display_state + 2
|
||||
update_display(map_data, station)
|
||||
end
|
||||
end
|
||||
@@ -303,7 +300,6 @@ local function tick_dispatch(map_data, mod_settings)
|
||||
---@type string
|
||||
local network_name
|
||||
if r_station.network_name == NETWORK_EVERY then
|
||||
--TODO: here
|
||||
_, _, network_name = string.find(item_network_name, "(^.*):")
|
||||
else
|
||||
network_name = r_station.network_name
|
||||
@@ -420,23 +416,18 @@ local function tick_dispatch(map_data, mod_settings)
|
||||
|
||||
effective_count = p_station.item_p_counts[item_name]
|
||||
override_threshold = p_station.item_thresholds and p_station.item_thresholds[item_name]
|
||||
if override_threshold and p_station.is_stack and item_type == "item" then
|
||||
if override_threshold and p_station.is_stack and not is_fluid then
|
||||
override_threshold = override_threshold*get_stack_size(map_data, item_name)
|
||||
end
|
||||
if effective_count < (override_threshold or r_threshold) then
|
||||
--this p station should have serviced the current r station, lock it so it can't serve any others
|
||||
--this will lock stations even when the r station manages to find a p station, this not a problem because all stations will be unlocked before it could be an issue
|
||||
table_remove(p_stations, j)
|
||||
if band(p_station.display_state, 2) == 0 then
|
||||
p_station.display_state = p_station.display_state + 2
|
||||
if band(p_station.display_state, 4) == 0 then
|
||||
p_station.display_state = p_station.display_state + 4
|
||||
update_display(map_data, p_station)
|
||||
end
|
||||
goto p_continue_remove
|
||||
else
|
||||
if band(p_station.display_state, 2) == 1 then
|
||||
p_station.display_state = p_station.display_state - 2
|
||||
update_display(map_data, p_station)
|
||||
end
|
||||
end
|
||||
|
||||
p_prior = p_station.priority
|
||||
@@ -476,8 +467,8 @@ local function tick_dispatch(map_data, mod_settings)
|
||||
elseif correctness == 4 then
|
||||
send_alert_no_train_matches_p_layout(r_station.entity_stop, closest_to_correct_p_station.entity_stop)
|
||||
end
|
||||
if band(r_station.display_state, 1) == 0 then
|
||||
r_station.display_state = r_station.display_state + 1
|
||||
if band(r_station.display_state, 2) == 0 then
|
||||
r_station.display_state = r_station.display_state + 2
|
||||
update_display(map_data, r_station)
|
||||
end
|
||||
end
|
||||
@@ -633,10 +624,22 @@ local function tick_poll_station(map_data, mod_settings)
|
||||
end
|
||||
end
|
||||
end
|
||||
if is_requesting_nothing and band(station.display_state, 1) == 1 then
|
||||
station.display_state = station.display_state - 1
|
||||
if station.display_state > 1 then
|
||||
if is_requesting_nothing and band(station.display_state, 2) == 1 then
|
||||
station.display_state = station.display_state - 2
|
||||
update_display(map_data, station)
|
||||
end
|
||||
if band(station.display_state, 8) == 1 then
|
||||
if band(station.display_state, 4) == 1 then
|
||||
station.display_state = station.display_state - 4
|
||||
else
|
||||
station.display_state = station.display_state - 8
|
||||
update_display(map_data, station)
|
||||
end
|
||||
elseif band(station.display_state, 4) == 1 then
|
||||
station.display_state = station.display_state + 4
|
||||
end
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
@@ -392,12 +392,12 @@ function update_display(map_data, station)
|
||||
local params = control.parameters
|
||||
--NOTE: the following check can cause a bug where the display desyncs if the player changes the operation of the combinator and then changes it back before the mod can notice, however removing it causes a bug where the user's change is overwritten and ignored. Everything's bad we need an event to catch copy-paste by blueprint.
|
||||
if params.operation == MODE_PRIMARY_IO or params.operation == MODE_PRIMARY_IO_ACTIVE or params.operation == MODE_PRIMARY_IO_FAILED_REQUEST then
|
||||
if station.display_state >= 4 then
|
||||
params.operation = MODE_PRIMARY_IO_ACTIVE
|
||||
elseif station.display_state >= 1 then
|
||||
params.operation = MODE_PRIMARY_IO_FAILED_REQUEST
|
||||
else
|
||||
if station.display_state == 0 then
|
||||
params.operation = MODE_PRIMARY_IO
|
||||
elseif station.display_state%2 == 1 then
|
||||
params.operation = MODE_PRIMARY_IO_ACTIVE
|
||||
else
|
||||
params.operation = MODE_PRIMARY_IO_FAILED_REQUEST
|
||||
end
|
||||
control.parameters = params
|
||||
end
|
||||
|
||||
@@ -65,7 +65,7 @@ function gui_opened(comb, player)
|
||||
on_click = {"close", comb.unit_number}
|
||||
}}
|
||||
}},
|
||||
{type="frame", name="frame", style="inside_shallow_frame_with_padding", style_mods={padding=12}, children={
|
||||
{type="frame", name="frame", style="inside_shallow_frame_with_padding", style_mods={padding=12, bottom_padding=10}, children={
|
||||
{type="flow", name="vflow", direction="vertical", style_mods={horizontal_align="left"}, children={
|
||||
--status
|
||||
{type="flow", style="status_flow", direction="horizontal", style_mods={vertical_align="center", horizontally_stretchable=true, bottom_padding=4}, children={
|
||||
@@ -95,11 +95,11 @@ function gui_opened(comb, player)
|
||||
---choose-elem-button
|
||||
{type="line", style_mods={top_padding=10}},
|
||||
{type="label", name="network_label", ref={"network_label"}, style="heading_3_label", caption={"cybersyn-gui.network"}, style_mods={top_padding=8}},
|
||||
{type="flow", name="bottom", direction="horizontal", style_mods={vertical_align="center", top_margin=0, top_padding=0}, children={
|
||||
{type="flow", name="bottom", direction="horizontal", style_mods={vertical_align="center"}, children={
|
||||
{type="choose-elem-button", name="network", style="slot_button_in_shallow_frame", ref={"network"}, elem_type="signal", tooltip={"cybersyn-gui.network-tooltip"}, signal=signal, style_mods={bottom_margin=1, right_margin=6}, actions={
|
||||
on_elem_changed={"choose-elem-button", comb.unit_number}
|
||||
}},
|
||||
{type="flow", name="right", direction="vertical", style_mods={horizontal_align="left", top_margin=0, top_padding=0}, children={
|
||||
{type="flow", name="right", direction="vertical", style_mods={horizontal_align="left"}, children={
|
||||
{type="flow", name="allow_list", direction="horizontal", style_mods={vertical_align="center"}, children={
|
||||
{type="checkbox", name="allow_list", ref={"allow_list"}, state=allow_list, tooltip={"cybersyn-gui.allow-list-tooltip"}, actions={
|
||||
on_checked_state_changed={"allow_list", comb.unit_number}
|
||||
|
||||
@@ -363,12 +363,12 @@ function combinator_update(map_data, comb, reset_display)
|
||||
station = map_data.stations[id]
|
||||
if should_reset and station and station.entity_comb1 == comb then
|
||||
--make sure only MODE_PRIMARY_IO gets stored on map_data.to_comb_params
|
||||
if station.display_state >= 2 then
|
||||
params.operation = MODE_PRIMARY_IO_ACTIVE
|
||||
elseif station.display_state == 1 then
|
||||
params.operation = MODE_PRIMARY_IO_FAILED_REQUEST
|
||||
else
|
||||
if station.display_state == 0 then
|
||||
params.operation = MODE_PRIMARY_IO
|
||||
elseif station.display_state%2 == 1 then
|
||||
params.operation = MODE_PRIMARY_IO_ACTIVE
|
||||
else
|
||||
params.operation = MODE_PRIMARY_IO_FAILED_REQUEST
|
||||
end
|
||||
control.parameters = params
|
||||
should_reset = false
|
||||
|
||||
@@ -135,7 +135,7 @@ local migrations_table = {
|
||||
control.parameters = params
|
||||
end
|
||||
for id, station in pairs(map_data.stations) do
|
||||
station.display_state = (station.display_state >= 2 and 4) + station.display_state%2
|
||||
station.display_state = (station.display_state >= 2 and 1) + (station.display_state%2)*2
|
||||
end
|
||||
end,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user