diff options
| author | historia <[not public]> | 2026-09-15 13:56:10 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-09-15 13:56:48 -0400 |
| commit | b3568f03e4103dd46db2ccc680fbab0a6454d604 (patch) | |
| tree | db3f6bb4f3d7c1deefbcd50de0f5022756d6b9ae /internal/game/core_login_account.go | |
| parent | f4ea40c4b3589104dfaced3481ba19c5735889ae (diff) | |
| download | thehouseoficarus-b3568f03e4103dd46db2ccc680fbab0a6454d604.tar.gz | |
fix: telnet buffer reuse, bank stack handling,
transport casino gate, and admin cache invalidation
Diffstat (limited to 'internal/game/core_login_account.go')
| -rw-r--r-- | internal/game/core_login_account.go | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/internal/game/core_login_account.go b/internal/game/core_login_account.go index 186a5c3..77b72d3 100644 --- a/internal/game/core_login_account.go +++ b/internal/game/core_login_account.go @@ -340,6 +340,25 @@ func (g *Game) handleRenameAccount(sess *net.Session, input string) { return } + // Persist the new name inside the account file itself; otherwise the next + // login adopts the old name again and account lookup drifts apart from + // the filename. Roll the rename back if the file cannot be updated so the + // account never ends up in a half-renamed state. + acc, err := g.AccountStore.LoadAccount(newName) + if err != nil { + sess.WriteLine(fmt.Sprintf("Error renaming account: %v", err)) + os.Rename(newPath, oldPath) + g.showMenu(sess) + return + } + acc.Name = newName + if err := g.AccountStore.SaveAccount(acc); err != nil { + sess.WriteLine(fmt.Sprintf("Error renaming account: %v", err)) + os.Rename(newPath, oldPath) + g.showMenu(sess) + return + } + sess.Account.Name = newName sess.WriteLine(fmt.Sprintf("Account renamed to %s.", newName)) g.showMenu(sess) @@ -354,6 +373,16 @@ func (g *Game) handlePurgeAccount(sess *net.Session, input string) { return } + // Refuse to purge while any character is connected: a live session would + // keep playing (and saving) a character whose file is about to vanish. + for _, name := range sess.Account.Characters { + if g.characterOnline(name) { + sess.WriteLine(fmt.Sprintf("%s is logged in. Log all characters out before purging.", name)) + g.showMenu(sess) + return + } + } + for _, name := range sess.Account.Characters { os.Remove(g.AccountStore.CharPath(name)) } |
