From d1effd6696a11609fb93b46d4856ae6caf7ad655 Mon Sep 17 00:00:00 2001 From: Simon Brodtmann Date: Tue, 24 Feb 2026 22:36:20 +0100 Subject: [PATCH] Remove unused power-rails code --- Bio_Industries_2/common.lua | 85 ------------------- Bio_Industries_2/control.lua | 19 ----- .../compound_entities/hidden_poles.lua | 18 ---- 3 files changed, 122 deletions(-) diff --git a/Bio_Industries_2/common.lua b/Bio_Industries_2/common.lua index dbd8620..41d2d19 100644 --- a/Bio_Industries_2/common.lua +++ b/Bio_Industries_2/common.lua @@ -54,34 +54,6 @@ return function(mod_name) end end - ------------------------------------------------------------------------------------ - -- Same values for collision masks - -- Default: {"item-layer", "object-layer", "rail-layer", "floor-layer", "water-tile"} - common.RAIL_BRIDGE_MASK = { "object-layer", "consider-tile-transitions" } - - -- "Transport Drones" removes "object-layer" from rails, so if bridges have only - -- {"object-layer"}, there collision mask will be empty, and they can be built even - -- over cliffs. So we need to add another layer to bridges ("floor-layer"). - -- As of Factorio 1.1.0, rails need to have "rail-layer" in their mask. This will work - -- alright, but isn't available in earlier versions of Factorio, so we will use - -- "floor-layer" there instead. - local need = common.check_version("base", ">=", "1.1.0") and "rail-layer" or "floor-layer" - table.insert(common.RAIL_BRIDGE_MASK, need) - - -- Rails use basically the same mask as rail bridges, ... - common.RAIL_MASK = util.table.deepcopy(common.RAIL_BRIDGE_MASK) - -- ... we just need to add some layers so our rails have the same mask as vanilla rails. - table.insert(common.RAIL_MASK, "item-layer") - table.insert(common.RAIL_MASK, "water-tile") - - - - ------------------------------------------------------------------------------------ - -- Set maximum_wire_distance of Power-to-rail connectors - common.POWER_TO_RAIL_WIRE_DISTANCE = 4 - - - ------------------------------------------------------------------------------------ -- List of compound entities -- Key: name of the base entity @@ -660,7 +632,6 @@ return function(mod_name) filter = "name", name = { -- Poles named here will be ignored! - "bi-rail-power-hidden-pole", "bi-musk-mat-hidden-pole", "bi-bio-garden-hidden-pole" }, @@ -739,62 +710,6 @@ return function(mod_name) end end - -------------------------------------------------------------------- - -- Connect hidden poles of powered rails -- this is also used in - -- migration scripts, so make it a function in common.lua! - -- (This function may be called for hidden poles that have not been - -- added to the table yet if the pole has just been built. In this - -- case, we pass on the new pole explicitly!) - common.connect_power_rail = function(base, new_pole) - local pole = storage.bi_power_rail_table[base.unit_number].pole or new_pole - if pole and pole.valid then - -- Remove all copper wires from new pole - pole.disconnect_neighbour() - common.writeDebug("Removed all wires from %s %g", { pole.name, pole.unit_number }) - - -- Look for connecting rails at front and back of the new rail - for s, side in ipairs({ "front", "back" }) do - common.writeDebug("Looking for rails at %s", { side }) - local neighbour - -- Look in all three directions - for d, direction in ipairs({ "left", "straight", "right" }) do - common.writeDebug("Looking for rails in %s direction", { direction }) - neighbour = base.get_connected_rail { - rail_direction = defines.rail_direction[side], - rail_connection_direction = defines.rail_connection_direction[direction] - } - common.writeDebug("Rail %s of %s (%s): %s (%s)", - { direction, base.name, base.unit_number, (neighbour and neighbour.name or "nil"), (neighbour and neighbour.unit_number or "nil") }) - - -- Only make a connection if found rail is a powered rail - -- (We'll know it's the right type if we find it in our table!) - neighbour = neighbour and neighbour.valid and storage.bi_power_rail_table[neighbour.unit_number] - if neighbour and neighbour.pole and neighbour.pole.valid then - pole.connect_neighbour(neighbour.pole) - common.writeDebug("Connected poles!") - end - end - end - - -- Look for Power-rail connectors - local connector = base.surface.find_entities_filtered { - position = base.position, - radius = common.POWER_TO_RAIL_WIRE_DISTANCE, -- maximum_wire_distance of Power-to-rail-connectors - name = "bi-power-to-rail-pole" - } - -- Connect to first Power-rail connector we've found - if connector and next(connector) then - pole.connect_neighbour(connector[1]) - common.writeDebug("Connected " .. pole.name .. " (" .. pole.unit_number .. - ") to " .. connector[1].name .. " (" .. connector[1].unit_number .. ")") - common.writeDebug("Connected %s (%g) to %s (%g)", - { pole.name, pole.unit_number, connector[1].name, connector[1].unit_number }) - end - common.writeDebug("Stored %s (%g) in global table", { base.name, base.unit_number }) - end - end - - ------------------------------------------------------------------------------------ -- Get the value of a startup setting common.get_startup_setting = function(setting_name) diff --git a/Bio_Industries_2/control.lua b/Bio_Industries_2/control.lua index c9237e1..a404b7e 100644 --- a/Bio_Industries_2/control.lua +++ b/Bio_Industries_2/control.lua @@ -534,16 +534,6 @@ local function On_Pre_Remove(event) BioInd.show("Removed arboretum radar! Table", storage.bi_arboretum_radar_table) end - -- Power rails: Connections must be explicitely removed, otherwise the poles - -- from the remaining rails will automatically connect and bridge the gap in - -- the power supply! - if entity.name:match("bi%-%a+%-rail%-power") and base_entry.pole and base_entry.pole.valid then - BioInd.writeDebug("Before") - BioInd.writeDebug("Disconnecting %s!", { BioInd.print_name_id(base_entry.pole) }) - base_entry.pole.disconnect_neighbour() - BioInd.writeDebug("After") - end - -- Default: Remove all hidden entities! for hidden, h_name in pairs(compound_entity.hidden or {}) do BioInd.show("hidden", hidden) @@ -554,14 +544,6 @@ local function On_Pre_Remove(event) end storage[compound_entity.tab][entity.unit_number] = nil - -- Rail-to-power: Connections must be explicitely removed, otherwise the poles - -- from the different rail tracks hooked up to this connector will automatically - -- keep the separate power networks connected! - elseif entity.name == "bi-power-to-rail-pole" then - BioInd.writeDebug("Rail-to-power connector has been removed") - entity.disconnect_neighbour() - BioInd.writeDebug("Removed copper wires from %s (%g)", { entity.name, entity.unit_number }) - -- Removed seedling elseif entity.name == "seedling" then BioInd.writeDebug("Seedling has been removed") @@ -632,7 +614,6 @@ local function On_Death(event) storage.bi.trees[entity.name] or -- Entity checks entity.name == storage.compound_entities["bi-arboretum"].hidden.radar.name or - entity.name == "bi-power-to-rail-pole" or entity.name == "seedling" then BioInd.writeDebug("Divert to On_Pre_Remove!") On_Pre_Remove(event) diff --git a/Bio_Industries_2/prototypes/compound_entities/hidden_poles.lua b/Bio_Industries_2/prototypes/compound_entities/hidden_poles.lua index 7818844..1ce19f6 100644 --- a/Bio_Industries_2/prototypes/compound_entities/hidden_poles.lua +++ b/Bio_Industries_2/prototypes/compound_entities/hidden_poles.lua @@ -140,24 +140,6 @@ BioInd.show("locale_name", locale_name) BioInd.show("Adjusted properties of", pole_name) end - ------------------------------------------------------------------------------------ - -- Adjust properties for hidden power-rail pole - ------------------------------------------------------------------------------------ - elseif (c_entities["bi-straight-rail-power"] and - c_entities["bi-straight-rail-power"].hidden[h_key] and - pole_name == c_entities["bi-straight-rail-power"].hidden[h_key].name) or - (c_entities["bi-curved-rail-power"] and - c_entities["bi-curved-rail-power"].hidden[h_key] and - pole_name == c_entities["bi-curved-rail-power"].hidden[h_key].name) then - --~ elseif pole_name == c_entities["bi-straight-rail-power"].hidden[h_key].name then - - --~ pole.localised_name = {"entity-name.bi-rail-power"} - --~ pole.localised_description = {"entity-description.bi-rail-power"} - pole.maximum_wire_distance = 9 - pole.supply_area_distance = 2 - shift_picture(pole) - BioInd.show("Adjusted properties of", pole_name) - ------------------------------------------------------------------------------------ -- Adjust properties for hidden pole of bio gardens ------------------------------------------------------------------------------------