🌐Khemia: Age of Alchemy


Khemia is a barren planet, with strange energies pulsing below the sand. Here, you must harness the power of Alchemy: Breaking materials down into magical energy and reconstructing them. Glyphs act as pipes, allowing you to transport energy, but placing them is often more art than science. As your factory grows, connecting glyphs becomes a unique puzzle. Alchemy also unlocks useful new tech, like spoilage-preventing brine tanks, massive cargo cranes, and surface-to-orbit teleportation.

Content
5 days ago
2.0 - 2.1
10.5K
Planets Logistics Mining Fluids Manufacturing Storage

b Desync in multiplayer when a glyph is removed (fixed by disabling glyph visuals)

9 days ago

Hi! Reporting a reproducible multiplayer desync caused by the glyph visual system.

ENVIRONMENT
- Factorio 2.1.25 (headless server + Windows clients)
- alchemy-khemia 0.3.8 and 0.3.9
- ~95 mods, but the issue is isolated to Khemia (see below)

REPRO
1. Multiplayer server with 2+ players.
2. Remove/deconstruct any glyph (pipe).
3. Desync within seconds — every time, 100% reproducible.

EVIDENCE
- "Multiplayer desynchronisation: crc test (heuristic) failed", tick 39414881.
- No Lua errors in the log.
- Comparing server-level.zip and client-level.zip from the desync report: map data differs only in chunks 168–182 (the Khemia area) and level-heuristic-39424392.
- Desync report (456 MB) available on request.

BISECTION RESULT (the important part)
Commenting out the visual subsystem completely eliminates the desync:
- createFluidVisuals() (rendering.draw_sprite / draw_animation + surface.create_entity{name="glyph-lamp"}), and
- the per-tick ManageGlyphs() colour update.
Glyph pipe logic itself is fine — the problem is only in the visuals.

WORKAROUND THAT WAS TESTED AND WORKS
Keeping rendering.draw_sprite/draw_animation but NOT creating the "glyph-lamp" entities:
- visuals are back (glow/colour works),
- desync is gone,
- no other changes needed.
So the prime suspect is creation/removal of glyph-lamp entities (created per glyph and per overlay) and their ordering vs. on_object_destroyed.

OTHER POSSIBLE CONTRIBUTORS (in the same area)
- storage.fluidVisuals cleanup via table.remove() while iterating with: for i = inital, #storage.fluidVisuals, glyphStep
- re-entrant destruction inside the on_object_destroyed loop (k.overlayEntity.destroy() while storage.overlays is being rebuilt)

SUGGESTION
- Drop glyph-lamp entities entirely and drive the glow with rendering only (e.g. rendering.draw_light / tinted sprites), or
- defer all entity creation/destruction out of the iteration (collect first, mutate after), and avoid table.remove during index loops.

I can share the exact diff of my local workaround and the desync report — just tell me where to send them.
Thanks for the mod, it's great apart from this!

Thanks for such a detailed report!
Desync stuff is always difficult to test, I really appreciate it!

I'd love to just remove the lamp entities, but I'd rather not mess with older saves if I can help it :P

I'm guessing it problem is the table.remove() in the loop you mentioned. Although, the clean-up on line 456 is meant to be a redundancy... if that's the culprit then something larger is going wrong D:

I'll try to come up with a better system for catching those orphaned entities.

Thanks again!

New response