In a clean 0.17.74 vanilla game.
Enable heavy mode (toggle-heavy-mode)
Run the below script a few times (up to 5) and a desync will be reported.
Code: Select all
/c
global.groups = global.groups or {}
local surface = game.player.surface
local force = game.player.force
for i = 1, 100 do
local unit = surface.create_entity{name="small-biter", position={10,10}, force=force}
local group = surface.create_unit_group{position={10,10}, force=force}
group.add_member(unit)
global.groups[#global.groups+1] = group
end
game.print("#global.groups: " .. #global.groups)
local toDestroy = math.random(10,30)
for i=1, toDestroy do
local groupIndex = math.random(1, #global.groups)
local group = global.groups[groupIndex]
if group ~= nil and group.valid then
group.destroy()
global.groups[groupIndex] = nil
end
end
This issue and their identification of the Lua code triggering the desync was pointed out to me by a fan of Comfy.
If the line "global.groups[groupIndex] = nil" isn't present the desync doesn't occur. So I assume its some internal lua/c++ game engine thing?