diff options
Diffstat (limited to 'internal/game/core_login_char.go')
| -rw-r--r-- | internal/game/core_login_char.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/internal/game/core_login_char.go b/internal/game/core_login_char.go index 3a2e324..41e25b8 100644 --- a/internal/game/core_login_char.go +++ b/internal/game/core_login_char.go @@ -2,6 +2,7 @@ package game import ( "fmt" + "log" "strings" "thehouseoficarus/internal/net" @@ -128,6 +129,18 @@ func (g *Game) connectCharacter(sess *net.Session, name string) { } } + // Rescue a character whose saved room no longer exists (the room was + // deleted, or a code-referenced teleport target was removed). Persisting + // a nonexistent RoomID soft-locks the character on every later login + // because movement and every room lookup fail. + if _, err := g.World.LoadRoom(p.RoomID); err != nil { + log.Printf("character %s: saved room %d no longer exists; relocating to starting room %d", p.Name, p.RoomID, g.StartingRoom) + p.RoomID = g.StartingRoom + if _, err := g.World.LoadRoom(p.RoomID); err != nil { + log.Printf("character %s: starting room %d also missing; leaving room as %d", p.Name, g.StartingRoom, p.RoomID) + } + } + p.Stats.RecordRoomVisit(p.RoomID) g.World.SeedGroundItems(p.RoomID) g.seedRoomMobs(p.RoomID) |
