aboutsummaryrefslogtreecommitdiff
path: root/internal/admin/server.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/admin/server.go')
-rw-r--r--internal/admin/server.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/internal/admin/server.go b/internal/admin/server.go
index ccad6a2..41c1e0f 100644
--- a/internal/admin/server.go
+++ b/internal/admin/server.go
@@ -58,13 +58,18 @@ type AdminServer struct {
// configPath is the on-disk config.yaml path, used by the color themer
// to persist edited default_colors back to the file the game loaded.
configPath string
+ // evictRoom evicts cached in-room games (tables/machines) when a room
+ // is deleted or renumbered: outstanding wagers are refunded through the
+ // wired game callback before the cache entries drop.
+ evictRoom func(roomID int)
+
// rebuildCraftIndex rebuilds the in-game craft index after item files
// change (create/update/delete/rename/move/undo/redo). Wired from the
// Game so the web editor's item edits stay consistent with gameplay.
rebuildCraftIndex func()
}
-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), rebuildCraftIndex func(), configPath string) (*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), evictRoom func(roomID int), rebuildCraftIndex func(), configPath string) (*AdminServer, error) {
secret := make([]byte, 32)
if _, err := rand.Read(secret); err != nil {
return nil, fmt.Errorf("cookie secret: %w", err)
@@ -109,9 +114,13 @@ func NewServer(cfg *config.Config, useTLS bool, accountStore *player.AccountStor
cookieSecret: secret,
reloadCourses: reloadCourses,
rewriteRoomIDs: rewriteRoomIDs,
+ evictRoom: evictRoom,
rebuildCraftIndex: rebuildCraftIndex,
configPath: configPath,
}
+ // Undo/redo of room-ID changes applies the (inverse) runtime migration
+ // through the same wired callback the rename uses.
+ s.undoStack.SetMigrateRoomIDs(rewriteRoomIDs)
mux := http.NewServeMux()