|
|
@ -29,8 +29,6 @@ func Update(uuid []byte, slot int, save any) error {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var filename string
|
|
|
|
var filename string
|
|
|
|
var buf bytes.Buffer
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch save := save.(type) {
|
|
|
|
switch save := save.(type) {
|
|
|
|
case defs.SystemSaveData: // System
|
|
|
|
case defs.SystemSaveData: // System
|
|
|
|
if save.TrainerId == 0 && save.SecretId == 0 {
|
|
|
|
if save.TrainerId == 0 && save.SecretId == 0 {
|
|
|
@ -48,11 +46,6 @@ func Update(uuid []byte, slot int, save any) error {
|
|
|
|
|
|
|
|
|
|
|
|
filename = "system"
|
|
|
|
filename = "system"
|
|
|
|
|
|
|
|
|
|
|
|
err = gob.NewEncoder(&buf).Encode(save)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return fmt.Errorf("failed to serialize save: %s", err)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
db.DeleteClaimedAccountCompensations(uuid)
|
|
|
|
db.DeleteClaimedAccountCompensations(uuid)
|
|
|
|
case defs.SessionSaveData: // Session
|
|
|
|
case defs.SessionSaveData: // Session
|
|
|
|
if slot < 0 || slot >= defs.SessionSlotCount {
|
|
|
|
if slot < 0 || slot >= defs.SessionSlotCount {
|
|
|
@ -63,15 +56,16 @@ func Update(uuid []byte, slot int, save any) error {
|
|
|
|
if slot != 0 {
|
|
|
|
if slot != 0 {
|
|
|
|
filename += strconv.Itoa(slot)
|
|
|
|
filename += strconv.Itoa(slot)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
err = gob.NewEncoder(&buf).Encode(save)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return fmt.Errorf("failed to serialize save: %s", err)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
return fmt.Errorf("invalid data type")
|
|
|
|
return fmt.Errorf("invalid data type")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var buf bytes.Buffer
|
|
|
|
|
|
|
|
err = gob.NewEncoder(&buf).Encode(save)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return fmt.Errorf("failed to serialize save: %s", err)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if buf.Len() == 0 {
|
|
|
|
if buf.Len() == 0 {
|
|
|
|
return fmt.Errorf("tried to write empty save file")
|
|
|
|
return fmt.Errorf("tried to write empty save file")
|
|
|
|
}
|
|
|
|
}
|
|
|
|