From a51f7a53aa2c487ebf94ba0363038574ae8bb590 Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Tue, 7 Jul 2026 00:22:32 -0400 Subject: feat: hidden exits (and related flags) work with commands that change room ids. exit code simplified and unified between impassable and blocked exits. --- internal/admin/server.go | 56 +++++++++++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 25 deletions(-) (limited to 'internal/admin/server.go') diff --git a/internal/admin/server.go b/internal/admin/server.go index f0fa58e..6ad20f5 100644 --- a/internal/admin/server.go +++ b/internal/admin/server.go @@ -36,22 +36,27 @@ import ( var embedded embed.FS type AdminServer struct { - cfg *config.Config - useTLS bool - accountStore *player.AccountStore - world *world.World - itemStore *item.ItemStore - objectStore *object.ObjectStore - mobStore *world.MobStore - dataDir string - httpServer *http.Server - undoStack *UndoStack - tmpl *template.Template - cookieSecret []byte + cfg *config.Config + useTLS bool + accountStore *player.AccountStore + world *world.World + itemStore *item.ItemStore + objectStore *object.ObjectStore + mobStore *world.MobStore + dataDir string + httpServer *http.Server + undoStack *UndoStack + tmpl *template.Template + cookieSecret []byte reloadCourses func() + // rewriteRoomIDs migrates room-ID-embedded state across all characters + // (online + offline) when a room ID changes. Wired from the Game so the + // admin web GUI can trigger the same migration as the swapid command + // without the admin package depending on game. + rewriteRoomIDs func(idMap map[int]int) } -func NewServer(cfg *config.Config, useTLS bool, accountStore *player.AccountStore, w *world.World, is *item.ItemStore, os *object.ObjectStore, ms *world.MobStore, dataDir string, reloadCourses func()) (*AdminServer, error) { +func NewServer(cfg *config.Config, useTLS bool, accountStore *player.AccountStore, w *world.World, is *item.ItemStore, os *object.ObjectStore, ms *world.MobStore, dataDir string, reloadCourses func(), rewriteRoomIDs func(map[int]int)) (*AdminServer, error) { secret := make([]byte, 32) if _, err := rand.Read(secret); err != nil { return nil, fmt.Errorf("cookie secret: %w", err) @@ -83,18 +88,19 @@ func NewServer(cfg *config.Config, useTLS bool, accountStore *player.AccountStor } s := &AdminServer{ - cfg: cfg, - useTLS: useTLS, - accountStore: accountStore, - world: w, - itemStore: is, - objectStore: os, - mobStore: ms, - dataDir: dataDir, - undoStack: NewUndoStack(dataDir), - tmpl: tmpl, - cookieSecret: secret, - reloadCourses: reloadCourses, + cfg: cfg, + useTLS: useTLS, + accountStore: accountStore, + world: w, + itemStore: is, + objectStore: os, + mobStore: ms, + dataDir: dataDir, + undoStack: NewUndoStack(dataDir), + tmpl: tmpl, + cookieSecret: secret, + reloadCourses: reloadCourses, + rewriteRoomIDs: rewriteRoomIDs, } mux := http.NewServeMux() -- cgit v1.2.3