aboutsummaryrefslogtreecommitdiff
path: root/internal/game/core_login_char.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/game/core_login_char.go')
-rw-r--r--internal/game/core_login_char.go23
1 files changed, 20 insertions, 3 deletions
diff --git a/internal/game/core_login_char.go b/internal/game/core_login_char.go
index b1d3d26..90c06be 100644
--- a/internal/game/core_login_char.go
+++ b/internal/game/core_login_char.go
@@ -51,7 +51,13 @@ func (g *Game) handleNewCharName(sess *net.Session, input string) {
return
}
- acc, _ := g.AccountStore.LoadAccount(sess.Account.Name)
+ acc, err := g.AccountStore.LoadAccount(sess.Account.Name)
+ if err != nil {
+ sess.WriteLine(fmt.Sprintf("Error creating character: %v", err))
+ sess.State = net.StateMenu
+ g.showMenu(sess)
+ return
+ }
acc.Characters = append(acc.Characters, name)
g.AccountStore.SaveAccount(acc)
sess.Account.Characters = acc.Characters
@@ -188,7 +194,12 @@ func (g *Game) handleRenameCharName(sess *net.Session, input string) {
g.AccountStore.SaveCharacter(p)
}
- acc, _ := g.AccountStore.LoadAccount(sess.Account.Name)
+ acc, err := g.AccountStore.LoadAccount(sess.Account.Name)
+ if err != nil {
+ sess.WriteLine(fmt.Sprintf("Error renaming: %v", err))
+ g.showMenu(sess)
+ return
+ }
for i, c := range acc.Characters {
if c == oldName {
acc.Characters[i] = newName
@@ -250,7 +261,13 @@ func (g *Game) handleDeleteChar(sess *net.Session, input string) {
return
}
- acc, _ := g.AccountStore.LoadAccount(sess.Account.Name)
+ acc, err := g.AccountStore.LoadAccount(sess.Account.Name)
+ if err != nil {
+ sess.WriteLine(fmt.Sprintf("Error deleting: %v", err))
+ sess.PendingChar = ""
+ g.showMenu(sess)
+ return
+ }
var newChars []string
for _, c := range acc.Characters {
if c != sess.PendingChar {