Clear the last of the nil checks

Guards now cover the statements that follow them, and a couple of reads
are restructured so the narrowing survives.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
bbassie
2026-08-07 15:31:43 +00:00
co-authored by Claude Opus 5
parent 76ecc37d3f
commit f5656025ee
9 changed files with 31 additions and 22 deletions
+8 -5
View File
@@ -149,11 +149,13 @@ local function create_entities(surface, offset)
local pos = apply_offset({ entity_details[2], entity_details[3] }, offset)
local entity = surface.create_entity{ name = entity_details[1], position = pos, force = "neutral" }
if entity and config.entities.protected then
protect_entity(entity)
end
if entity then
if config.entities.protected then
protect_entity(entity)
end
entity.operable = config.entities.operable
entity.operable = config.entities.operable
end
end
end
@@ -276,7 +278,8 @@ local function on_player_created(event)
if config.resource_patches.enabled then create_resource_patches(surface, offset) end
if config.turrets.enabled then update_turrets() end
(player.force --[[@as LuaForce]]).set_spawn_position(offset, surface)
local force = player.force --[[@as LuaForce]]
force.set_spawn_position(offset, surface)
player.teleport(offset, surface)
end
+1 -1
View File
@@ -106,7 +106,7 @@ Elements.reason_confirm = Gui.define("player_list/reason_confirm")
if reason == nil or not reason:find("%S") then reason = "no reason given" end
button_data.reason_callback(player, reason)
end
element.parent.entry.text = ""
assert(assert(element.parent).entry).text = ""
Elements.container.set_selected_player(player, nil)
Elements.player_table.refresh_player(player)
end) --[[@as any]]
@@ -193,7 +193,8 @@ Elements.science_table = Gui.define("science_production/science_table")
local science_table = Gui.elements.scroll_table(parent, 190, 4)
local no_production_label = Elements.no_production_label(science_table)
Elements.no_production_label.refresh(no_production_label)
(science_table.style --[[@as LuaStyle]]).column_alignments[3] = "right"
local science_table_style = science_table.style --[[@as LuaStyle]]
science_table_style.column_alignments[3] = "right"
return science_table
end)
:element_data{} --[[@as any]]
@@ -280,7 +281,8 @@ function Elements.science_table.add_row(science_table, row_data)
column_count = 2,
}
delta_table.style.padding = 0
(delta_table.style --[[@as LuaStyle]]).column_alignments[1] = "right"
local delta_table_style = delta_table.style --[[@as LuaStyle]]
delta_table_style.column_alignments[1] = "right"
-- Draw the net production label
local net = Elements.production_label(science_table, row_data.net)
@@ -429,8 +431,10 @@ do local _display_data = {} --- @type table<string, Elements.eta_label.display_d
-- Update the eta labels
for player, eta_label in Elements.eta_label:online_elements() do
local display_data = _display_data[player.force.name]
eta_label.caption = display_data.caption
eta_label.tooltip = display_data.tooltip
if display_data then
eta_label.caption = display_data.caption
eta_label.tooltip = display_data.tooltip
end
end
end
end