aboutsummaryrefslogtreecommitdiff
path: root/internal/game/core_login_account.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/game/core_login_account.go')
-rw-r--r--internal/game/core_login_account.go23
1 files changed, 16 insertions, 7 deletions
diff --git a/internal/game/core_login_account.go b/internal/game/core_login_account.go
index 0224a06..67e692d 100644
--- a/internal/game/core_login_account.go
+++ b/internal/game/core_login_account.go
@@ -49,6 +49,7 @@ func (g *Game) handleAccountName(sess *net.Session, input string) {
// after the account is gone.
func (g *Game) resetToAccountName(sess *net.Session) {
sess.Account = nil
+ sess.SetAuthName("")
sess.PendingChar = ""
sess.PendingMenu = nil
sess.PendingPass = ""
@@ -361,15 +362,21 @@ func (g *Game) handleColorChoice(sess *net.Session, input string) {
}
input = strings.ToLower(strings.TrimSpace(input))
if input == "y" || input == "yes" {
- sess.Account.Options["color"] = "none"
acc, err := g.AccountStore.LoadAccount(sess.Account.Name)
- if err == nil {
- if acc.Options == nil {
- acc.Options = make(map[string]any)
- }
- acc.Options["color"] = "none"
- g.saveAccount(acc)
+ if err != nil {
+ sess.WriteLine("Error loading account.")
+ g.resetToAccountName(sess)
+ return
+ }
+ if acc.Options == nil {
+ acc.Options = make(map[string]any)
}
+ acc.Options["color"] = "none"
+ g.saveAccount(acc)
+ if sess.Account.Options == nil {
+ sess.Account.Options = make(map[string]any)
+ }
+ sess.Account.Options["color"] = "none"
}
g.showMenu(sess)
}
@@ -479,6 +486,7 @@ func (g *Game) handleMenu(sess *net.Session, input string) {
sess.Write("New name: ")
return
}
+ sess.PendingChar = ""
sess.SetState(net.StateRenameChar)
sess.WriteLine("\nRename which character?")
for i, name := range sess.Account.Characters {
@@ -495,6 +503,7 @@ func (g *Game) handleMenu(sess *net.Session, input string) {
if len(sess.Account.Characters) == 1 {
sess.PendingChar = sess.Account.Characters[0]
} else {
+ sess.PendingChar = ""
sess.SetState(net.StateDeleteChar)
sess.WriteLine("\nDelete which character?")
for i, name := range sess.Account.Characters {