From bab5dd653039d026eb3d4e46da7aafef7137fe7c Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Sat, 19 Sep 2026 03:52:04 -0400 Subject: fix: journal in-game room insert/remove, rewrite non-room room refs on rename/swap, seed admin grid from edited room, type action switches --- internal/game/cmd_swapid.go | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'internal/game/cmd_swapid.go') 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)) } -- cgit v1.2.3