aboutsummaryrefslogtreecommitdiff
path: root/internal/game/core_login_char.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-09-15 13:56:10 -0400
committerhistoria <[not public]>2026-09-15 13:56:48 -0400
commitb3568f03e4103dd46db2ccc680fbab0a6454d604 (patch)
treedb3f6bb4f3d7c1deefbcd50de0f5022756d6b9ae /internal/game/core_login_char.go
parentf4ea40c4b3589104dfaced3481ba19c5735889ae (diff)
downloadthehouseoficarus-b3568f03e4103dd46db2ccc680fbab0a6454d604.tar.gz
fix: telnet buffer reuse, bank stack handling,
transport casino gate, and admin cache invalidation
Diffstat (limited to 'internal/game/core_login_char.go')
-rw-r--r--internal/game/core_login_char.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/internal/game/core_login_char.go b/internal/game/core_login_char.go
index 38499e2..9d7c211 100644
--- a/internal/game/core_login_char.go
+++ b/internal/game/core_login_char.go
@@ -144,6 +144,16 @@ func (g *Game) handleRenameChar(sess *net.Session, input string) {
sess.Write("New name: ")
}
+// characterOnline reports whether the named character is currently connected
+// through a live session. Menu operations that rename or delete character
+// files must refuse while the character is online, otherwise the in-memory
+// player later overwrites or resurrects the moved/removed file.
+func (g *Game) characterOnline(name string) bool {
+ g.charsMu.Lock()
+ defer g.charsMu.Unlock()
+ return g.loggedInChars[name] != nil
+}
+
func (g *Game) handleRenameCharName(sess *net.Session, input string) {
newName := strings.TrimSpace(input)
oldName := sess.PendingChar
@@ -166,6 +176,12 @@ func (g *Game) handleRenameCharName(sess *net.Session, input string) {
sess.Write("New name: ")
return
}
+ if g.characterOnline(oldName) {
+ sess.WriteLine("That character is logged in elsewhere. Log them out first.")
+ sess.PendingChar = ""
+ g.showMenu(sess)
+ return
+ }
oldPath := g.AccountStore.CharPath(oldName)
newPath := g.AccountStore.CharPath(newName)
@@ -240,6 +256,13 @@ func (g *Game) handleDeleteChar(sess *net.Session, input string) {
return
}
+ if g.characterOnline(sess.PendingChar) {
+ sess.WriteLine("That character is logged in elsewhere. Log them out first.")
+ sess.PendingChar = ""
+ g.showMenu(sess)
+ return
+ }
+
charPath := g.AccountStore.CharPath(sess.PendingChar)
if err := os.Remove(charPath); err != nil {
sess.WriteLine(fmt.Sprintf("Error deleting: %v", err))