mirror of
https://github.com/Mezeporta/Erupe.git
synced 2025-12-15 16:34:51 +01:00
terminate session on save corruption
This commit is contained in:
@@ -2,6 +2,8 @@ package channelserver
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
|
"erupe-ce/common/bfutil"
|
||||||
|
"erupe-ce/common/stringsupport"
|
||||||
|
|
||||||
"erupe-ce/network/mhfpacket"
|
"erupe-ce/network/mhfpacket"
|
||||||
"erupe-ce/server/channelserver/compression/nullcomp"
|
"erupe-ce/server/channelserver/compression/nullcomp"
|
||||||
@@ -135,6 +137,7 @@ func (save *CharacterSaveData) updateSaveDataWithStruct() {
|
|||||||
|
|
||||||
// This will update the save struct with the values stored in the character save
|
// This will update the save struct with the values stored in the character save
|
||||||
func (save *CharacterSaveData) updateStructWithSaveData() {
|
func (save *CharacterSaveData) updateStructWithSaveData() {
|
||||||
|
save.Name = stringsupport.SJISToUTF8(bfutil.UpToNull(save.decompSave[88:100]))
|
||||||
if save.decompSave[pointerGender] == 1 {
|
if save.decompSave[pointerGender] == 1 {
|
||||||
save.Gender = true
|
save.Gender = true
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package channelserver
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"erupe-ce/common/bfutil"
|
|
||||||
"erupe-ce/common/stringsupport"
|
"erupe-ce/common/stringsupport"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
@@ -46,10 +45,14 @@ func handleMsgMhfSavedata(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
characterSaveData.decompSave = saveData
|
characterSaveData.decompSave = saveData
|
||||||
}
|
}
|
||||||
characterSaveData.updateStructWithSaveData()
|
characterSaveData.updateStructWithSaveData()
|
||||||
|
if characterSaveData.Name == s.Name {
|
||||||
characterSaveData.Save(s)
|
characterSaveData.Save(s)
|
||||||
s.logger.Info("Wrote recompressed savedata back to DB.")
|
s.logger.Info("Wrote recompressed savedata back to DB.")
|
||||||
|
} else {
|
||||||
characterSaveData.Name = stringsupport.SJISToUTF8(bfutil.UpToNull(characterSaveData.decompSave[88:100]))
|
s.logger.Warn("Save cancelled due to corruption.")
|
||||||
|
s.rawConn.Close()
|
||||||
|
return
|
||||||
|
}
|
||||||
_, err = s.server.db.Exec("UPDATE characters SET name=$1 WHERE id=$2", characterSaveData.Name, s.charID)
|
_, err = s.server.db.Exec("UPDATE characters SET name=$1 WHERE id=$2", characterSaveData.Name, s.charID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.logger.Fatal("Failed to update character name in db", zap.Error(err))
|
s.logger.Fatal("Failed to update character name in db", zap.Error(err))
|
||||||
|
|||||||
Reference in New Issue
Block a user