Address the second inline review of the features framework

- Feature.register returns the config as a second value, so files
  write `local feature, config = Feature.register(...)`.
- The lib is ExpScenario.Features and the instance class with its
  fields sits on Feature._prototype, which is the __index, the same
  shape as exp_commands.
- update_config only looks at values whose override was added,
  removed, or replaced. _apply_field sets one value and returns it, so
  the comparison happens while applying and the second loop only
  raises. Overrides dropped from the previous set count as candidates
  because the value reverts to its default.
- The `@setting name` tags are gone from the config comments.
- Protection is guarded as a whole instead of checking config.enabled
  in one handler. The handlers also forget mined entities, so
  get_entities and is_entity_protected now drop invalid references,
  which also covers entities destroyed without an event. The list
  getters are gone, the selection overlay builds its lists from
  Protection.config.
- Chat and damage popups are one feature in control/popups.lua.
- ignore_admins and command_admin_only are removed, roles cover them.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
bbassieandClaude Fable 5.1 committed 2026-10-03 07:35:58 +00:00
1 parent bff6a1c612
commit f90b8fcee1
21 files changed
+289 -286

No files matched your search

@@ -153,6 +153,17 @@ SelectArea:on_alt_selection(function(event)
end
end)
--- The keys of a set as a list, find_entities_filtered takes a list of names
--- @param set table<string, true>
--- @return string[]
local function set_keys(set)
local keys = {}
for key in pairs(set) do
keys[#keys + 1] = key
end
return keys
end
--- When selection starts show all protected entities and protected areas
local function on_player_selection_start(event)
local player = game.players[event.player_index]
@@ -166,7 +177,7 @@ local function on_player_selection_start(event)
end
-- Show always protected entities by name
local protected_entity_names = EntityProtection.get_protected_entity_names()
local protected_entity_names = set_keys(EntityProtection.config.always_protected_names)
if #protected_entity_names > 0 then
for _, entity in pairs(surface.find_entities_filtered{ name = protected_entity_names, force = player.force }) do
show_protected_entity(player, entity)
@@ -174,7 +185,7 @@ local function on_player_selection_start(event)
end
-- Show always protected entities by type
local protected_entity_types = EntityProtection.get_protected_entity_types()
local protected_entity_types = set_keys(EntityProtection.config.always_protected_types)
if #protected_entity_types > 0 then
for _, entity in pairs(surface.find_entities_filtered{ type = protected_entity_types, force = player.force }) do
show_protected_entity(player, entity)