mirror of
https://github.com/Mezeporta/Erupe.git
synced 2025-12-13 07:25:03 +01:00
fix nil savedata error proper
This commit is contained in:
@@ -253,7 +253,7 @@ func logoutPlayer(s *Session) {
|
||||
removeSessionFromStage(s)
|
||||
|
||||
saveData, err := GetCharacterSaveData(s, s.charID)
|
||||
if err != nil || saveData == nil {
|
||||
if err != nil {
|
||||
s.logger.Error("Failed to get savedata")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package channelserver
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"erupe-ce/common/bfutil"
|
||||
"erupe-ce/common/stringsupport"
|
||||
|
||||
@@ -58,6 +59,7 @@ func GetCharacterSaveData(s *Session, charID uint32) (*CharacterSaveData, error)
|
||||
}
|
||||
defer result.Close()
|
||||
if !result.Next() {
|
||||
err = errors.New("no savedata found")
|
||||
s.logger.Error("No savedata found", zap.Uint32("charID", charID))
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -785,7 +785,7 @@ func handleDonateRP(s *Session, amount uint16, guild *Guild, isEvent bool) []byt
|
||||
bf := byteframe.NewByteFrame()
|
||||
bf.WriteUint32(0)
|
||||
saveData, err := GetCharacterSaveData(s, s.charID)
|
||||
if err != nil || saveData == nil {
|
||||
if err != nil {
|
||||
return bf.Data()
|
||||
}
|
||||
saveData.RP -= amount
|
||||
|
||||
Reference in New Issue
Block a user