mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2026-08-12 16:35:11 +09:00
Enable need-check-nil and start the burn down
`Roles.new_role` returned the result of `error`, which made it nullable, and `set_permission_group` returned nil for an unknown group, which broke the config chain with an index error rather than saying so. Positions and bounding boxes read back from the game always use the named members, so they are narrowed once where they enter a function. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -18,7 +18,6 @@
|
||||
},
|
||||
"$comment-disable": "Carried over from the luals config, which had these as editor only rather than checked in ci",
|
||||
"$comment-unnecessary-if": "Disabled by the config fmtk generates for itself, the api union types make it unreliable",
|
||||
"$comment-need-check-nil": "To be enabled once the backlog is cleared, a third of it is MapPosition and BoundingBox being aliased as struct|[double, double]",
|
||||
"diagnostics": {
|
||||
"globals": [ "__DebugAdapter", "__Profiler" ],
|
||||
"disable": [
|
||||
@@ -27,7 +26,6 @@
|
||||
"invert-if",
|
||||
"missing-parameter",
|
||||
"missing-return-value",
|
||||
"need-check-nil",
|
||||
"param-type-mismatch",
|
||||
"preferred-local-alias",
|
||||
"redefined-local",
|
||||
|
||||
@@ -719,7 +719,7 @@ local role = Roles.new_role('Moderator', 'Mod')
|
||||
]]
|
||||
function Roles.new_role(name, short_hand)
|
||||
ExpUtil.assert_not_runtime()
|
||||
if Roles.config.roles[name] then return error("Role name is non unique") end
|
||||
if Roles.config.roles[name] then error("Role name is non unique") end
|
||||
local role = setmetatable({
|
||||
name = name,
|
||||
short_hand = short_hand or name,
|
||||
@@ -896,8 +896,7 @@ function Roles._prototype:set_permission_group(name, use_factorio_api)
|
||||
if use_factorio_api then
|
||||
self.permission_group = { true, name } --[[@as [boolean, string] ]]
|
||||
else
|
||||
local group = Groups.get_group_by_name(name)
|
||||
if not group then return end
|
||||
assert(Groups.get_group_by_name(name), "Permission group not found: " .. name)
|
||||
self.permission_group = name
|
||||
end
|
||||
return self
|
||||
|
||||
@@ -68,12 +68,13 @@ local function try_deconstruct_output_chest(entity)
|
||||
end
|
||||
|
||||
-- Get all adjacent mining drills and inserters
|
||||
local target_position = target.position --[[@as MapPosition.struct]]
|
||||
local entities = target.surface.find_entities_filtered{
|
||||
type = { "mining-drill", "inserter" },
|
||||
to_be_deconstructed = false,
|
||||
area = {
|
||||
{ target.position.x - 1, target.position.y - 1 },
|
||||
{ target.position.x + 1, target.position.y + 1 }
|
||||
{ target_position.x - 1, target_position.y - 1 },
|
||||
{ target_position.x + 1, target_position.y + 1 }
|
||||
},
|
||||
}
|
||||
|
||||
@@ -159,14 +160,14 @@ local function try_deconstruct_miner(entity)
|
||||
end
|
||||
|
||||
-- Build pipes if the miner used fluid
|
||||
local position = entity.position
|
||||
local position = entity.position --[[@as MapPosition.struct]]
|
||||
local create_entity_position = { x = position.x, y = position.y }
|
||||
local create_entity_param = { name = "entity-ghost", inner_name = "pipe", force = entity.force, position = create_entity_position }
|
||||
local create_entity = surface.create_entity
|
||||
create_entity(create_entity_param)
|
||||
|
||||
-- Find all the entities to connect to
|
||||
local bounding_box = entity.bounding_box
|
||||
local bounding_box = entity.bounding_box --[[@as ExpUtil_AABB.Box]]
|
||||
local search_area = {
|
||||
{ bounding_box.left_top.x - 1, bounding_box.left_top.y - 1 },
|
||||
{ bounding_box.right_bottom.x + 1, bounding_box.right_bottom.y + 1 },
|
||||
@@ -246,7 +247,7 @@ local function on_resource_depleted(event)
|
||||
end
|
||||
|
||||
-- Find all mining drills within the area
|
||||
local position = resource.position
|
||||
local position = resource.position --[[@as MapPosition.struct]]
|
||||
local drills = resource.surface.find_entities_filtered{
|
||||
type = "mining-drill",
|
||||
area = {
|
||||
@@ -258,8 +259,9 @@ local function on_resource_depleted(event)
|
||||
-- Check which could have reached this resource
|
||||
for _, drill in pairs(drills) do
|
||||
local radius = drill.prototype.mining_drill_radius
|
||||
local dx = math.abs(drill.position.x - position.x)
|
||||
local dy = math.abs(drill.position.y - position.y)
|
||||
local drill_position = drill.position --[[@as MapPosition.struct]]
|
||||
local dx = math.abs(drill_position.x - position.x)
|
||||
local dy = math.abs(drill_position.y - position.y)
|
||||
if dx <= radius and dy <= radius then
|
||||
try_deconstruct_miner(drill)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user