aboutsummaryrefslogtreecommitdiff
path: root/internal/game/cmd_swapid.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-09-19 03:52:04 -0400
committerhistoria <[not public]>2026-09-19 03:52:04 -0400
commitbab5dd653039d026eb3d4e46da7aafef7137fe7c (patch)
tree9a1d8686dbcef8c145e3593511153768ae08962c /internal/game/cmd_swapid.go
parent0e60567a7a0addb9421769ee7be7853bfa8788cb (diff)
downloadthehouseoficarus-bab5dd653039d026eb3d4e46da7aafef7137fe7c.tar.gz
fix: journal in-game room insert/remove, rewrite non-room room refs on rename/swap, seed admin grid from edited room, type action switches
Diffstat (limited to 'internal/game/cmd_swapid.go')
-rw-r--r--internal/game/cmd_swapid.go24
1 files changed, 23 insertions, 1 deletions
diff --git a/internal/game/cmd_swapid.go b/internal/game/cmd_swapid.go
index d1dbd68..b0863d4 100644
--- a/internal/game/cmd_swapid.go
+++ b/internal/game/cmd_swapid.go
@@ -3,10 +3,12 @@ package game
import (
"fmt"
"os"
+ "path/filepath"
"strconv"
"gopkg.in/yaml.v3"
+ "thehouseoficarus/internal/behavior"
"thehouseoficarus/internal/net"
)
@@ -149,6 +151,26 @@ func (g *Game) executeSwapID(sess *net.Session, args []string, rawInput string)
}
updated++
}
+ // Non-room content (courses, modules, triggers, items, objects, mobs)
+ // carries structural room references too. Stage it into the SAME journal
+ // transaction as the room files, so a swap never leaves a course obstacle,
+ // transport destination, or trigger teleport pointing at the wrong room
+ // even if one side's write fails.
+ contentUpdated := 0
+ for _, sub := range behavior.RoomRefContentDirs {
+ changes, cerr := behavior.RewriteRoomRefsInDir(filepath.Join(g.DataDir, sub), idMap)
+ if cerr != nil {
+ sess.WriteLine(fmt.Sprintf("Error scanning %s for room references: %v", sub, cerr))
+ return
+ }
+ for _, ch := range changes {
+ if werr := rewriteTxn.Replace(ch.Path, ch.Content, 0644); werr != nil {
+ sess.WriteLine(fmt.Sprintf("Error rewriting %s: %v", ch.Path, werr))
+ return
+ }
+ contentUpdated++
+ }
+ }
if rerr := rewriteTxn.Commit(); rerr != nil {
sess.WriteLine(fmt.Sprintf("Error rewriting room references: %v", rerr))
return
@@ -162,5 +184,5 @@ func (g *Game) executeSwapID(sess *net.Session, args []string, rawInput string)
// from the owner command loop) and must not dispatch again.
g.MigrateRoomIDsOnOwner(idMap)
- sess.WriteLine(fmt.Sprintf("Swapped room IDs %d and %d (%d files updated).", id1, id2, updated))
+ sess.WriteLine(fmt.Sprintf("Swapped room IDs %d and %d (%d room files, %d content files updated).", id1, id2, updated, contentUpdated))
}