fix(mazenet): auto-layout nets + deckies in a deterministic grid

Dropping more than one LAN near the same spot stacked the NetBox
rectangles on top of each other, and multiple deckies in a LAN
landed on identical per-LAN coordinates. Since canvas position
persistence is deferred (localStorage pass), the stored x/y are
not load-bearing — compute layout from the topology graph instead.

adaptTopology now lays LANs out in a 3-col grid with the DMZ first
and stacks deckies 2-wide inside their home LAN. New LAN palette
drops append to the same grid, ignoring the raw drop point.
This commit is contained in:
2026-04-20 23:47:29 -04:00
parent b261e8e5fa
commit c4be1c721d
2 changed files with 54 additions and 21 deletions

View File

@@ -67,9 +67,14 @@ const MazeNET: React.FC = () => {
flashErr(null, 'topology already has a DMZ');
return;
}
const w = 320, h = 240;
const x = Math.round(world.x - w / 2);
const y = Math.round(world.y - h / 2);
// Append to the 3-col grid matching adaptTopology so new drops
// never land on top of existing LANs. The raw drop point is
// ignored — cleaner than trying to resolve collisions after.
const w = 300, h = 240;
const GAP = 40, COLS = 3;
const i = nets.filter((n) => n.kind !== 'internet').length;
const x = GAP + (i % COLS) * (w + GAP);
const y = GAP + Math.floor(i / COLS) * (h + GAP);
const name = isDmz ? `dmz-${hex4()}` : `subnet-${hex4()}`;
try {
const subnet = await api.getNextSubnet().catch(() => undefined);