From 3f30fa3eec9c2e2acf9a984ccefb9529a25e688a Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Tue, 7 Jul 2026 05:50:37 -0400 Subject: feat: add insert/remove room to context menu in admin web GUI to 'push' or 'pull' map rooms --- internal/world/grid.go | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'internal/world/grid.go') diff --git a/internal/world/grid.go b/internal/world/grid.go index 2ea897a..7be8eed 100644 --- a/internal/world/grid.go +++ b/internal/world/grid.go @@ -87,12 +87,28 @@ func BuildGrid(seed int, load func(int) (*Room, bool), include func(int) bool, e continue } - g.Coord[target] = want - g.RoomAt[want] = target - g.Dist[target] = g.Dist[rid] + 1 - queue = append(queue, target) - } + g.Coord[target] = want + g.RoomAt[want] = target + g.Dist[target] = g.Dist[rid] + 1 + queue = append(queue, target) + } } return g } + +// BuildGridConflicts lays out the rooms reachable from seed exactly like +// BuildGrid but returns every twist/overlap conflict encountered instead of +// silently skipping them. Callers pass a load closure that may return *edited +// copies* of rooms to model a hypothetical edit (e.g. an insert or a remove) +// without writing anything to disk; a non-empty result means the modeled world +// cannot be embedded on the grid. include and edgeInclude default to "place +// and follow everything" (geometry is independent of gating), matching the +// startup validator's validateRoomGrid. +func BuildGridConflicts(seed int, load func(int) (*Room, bool)) []GridConflict { + var conflicts []GridConflict + BuildGrid(seed, load, nil, nil, func(gc GridConflict) { + conflicts = append(conflicts, gc) + }) + return conflicts +} -- cgit v1.2.3