mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-23 16:23:12 +09:00
fix(minimap): restore chart tag interval semantics after task 3
Task 3 inadvertently changed chart tag data schema from start_tick/end_tick interval model to single tick field. This restores the original interval semantics for chart tags while preserving legitimate Task 3 fixes. Reverted: - create_chart_tag_data(tick) -> create_tag_data(start_tick, end_tick) - Single-emission in on_chart_tag_modified -> dual-emission (end old, start new) - All chart tag event handlers use interval model again Preserved from Task 3: - prev.name.name fix (both locations) - Hot-loop local aliases (math_floor, bit32_rshift, table_insert) - IIFE removal for recipe icon lookup - Recipe data single tick field (within Task 3 scope)
This commit is contained in:
1 parent
7c6dd1ff66
commit
a1e8d009ff
1 file changed
+26
-14
@@ -243,10 +243,11 @@ local function update_entity_recipe(entity)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Create tag data structure
|
-- Create tag data structure
|
||||||
local function create_chart_tag_data(tag, tick)
|
local function create_tag_data(tag, start_tick, end_tick)
|
||||||
return {
|
return {
|
||||||
tag_number = tag.tag_number,
|
tag_number = tag.tag_number,
|
||||||
tick = tick,
|
start_tick = start_tick,
|
||||||
|
end_tick = end_tick,
|
||||||
force = tag.force.name,
|
force = tag.force.name,
|
||||||
surface = tag.surface.name,
|
surface = tag.surface.name,
|
||||||
position = {tag.position.x, tag.position.y},
|
position = {tag.position.x, tag.position.y},
|
||||||
@@ -295,7 +296,8 @@ local function on_chart_tag_added(event)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local tag_data = create_chart_tag_data(tag, game.tick)
|
local start_tick = game.tick
|
||||||
|
local tag_data = create_tag_data(tag, start_tick, nil)
|
||||||
|
|
||||||
-- Send to plugin
|
-- Send to plugin
|
||||||
send_chart_tag_data(tag_data)
|
send_chart_tag_data(tag_data)
|
||||||
@@ -311,8 +313,16 @@ local function on_chart_tag_modified(event)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Emit updated tag at current tick
|
-- End the old version at current tick
|
||||||
local tag_data = create_chart_tag_data(tag, game.tick)
|
local end_tick = game.tick
|
||||||
|
local old_tag_data = create_tag_data(tag, nil, end_tick)
|
||||||
|
send_chart_tag_data(old_tag_data)
|
||||||
|
|
||||||
|
-- Create new tag entry starting at next tick
|
||||||
|
local start_tick = game.tick + 1
|
||||||
|
local tag_data = create_tag_data(tag, start_tick, nil)
|
||||||
|
|
||||||
|
-- Send to plugin
|
||||||
send_chart_tag_data(tag_data)
|
send_chart_tag_data(tag_data)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -326,8 +336,9 @@ local function on_chart_tag_removed(event)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Emit final state at removal tick
|
-- End the tag
|
||||||
local tag_data = create_chart_tag_data(tag, game.tick)
|
local end_tick = game.tick
|
||||||
|
local tag_data = create_tag_data(tag, nil, end_tick)
|
||||||
send_chart_tag_data(tag_data)
|
send_chart_tag_data(tag_data)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -461,14 +472,15 @@ local function init()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Initialize existing chart tags
|
-- Initialize existing chart tags
|
||||||
local existing_tags = force.find_chart_tags(surface)
|
local existing_tags = force.find_chart_tags(surface)
|
||||||
for _, tag in pairs(existing_tags) do
|
for _, tag in pairs(existing_tags) do
|
||||||
local tag_data = create_chart_tag_data(tag, game.tick)
|
local start_tick = game.tick
|
||||||
|
local tag_data = create_tag_data(tag, start_tick, nil)
|
||||||
|
|
||||||
-- Send to plugin
|
-- Send to plugin
|
||||||
send_chart_tag_data(tag_data)
|
send_chart_tag_data(tag_data)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Initialize existing crafting recipes on this surface and force
|
-- Initialize existing crafting recipes on this surface and force
|
||||||
local crafting_entities = surface.find_entities_filtered{
|
local crafting_entities = surface.find_entities_filtered{
|
||||||
|
|||||||
Reference in new issue
Block a user