diff options
| author | historia <[not public]> | 2026-07-07 05:50:37 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-07-07 05:50:37 -0400 |
| commit | 3f30fa3eec9c2e2acf9a984ccefb9529a25e688a (patch) | |
| tree | b6c146ec7f3dc2ea21dbf8ee7612c3889d93ca1a /internal/world/grid.go | |
| parent | a51f7a53aa2c487ebf94ba0363038574ae8bb590 (diff) | |
| download | thehouseoficarus-3f30fa3eec9c2e2acf9a984ccefb9529a25e688a.tar.gz | |
feat: add insert/remove room to context menu in admin web GUI to 'push' or 'pull' map rooms
Diffstat (limited to 'internal/world/grid.go')
| -rw-r--r-- | internal/world/grid.go | 26 |
1 files changed, 21 insertions, 5 deletions
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 +} |
