diff --git a/config.json b/config.json index b6967be68..d79aa2a51 100644 --- a/config.json +++ b/config.json @@ -9,6 +9,7 @@ "PatchServerManifest": "", "PatchServerFile": "", "ScreenshotAPIURL": "", + "DeleteOnSaveCorruption": false, "DevMode": true, "DevModeOptions": { "AutoCreateAccount": true, diff --git a/config/config.go b/config/config.go index c2c66f925..749eaaa81 100644 --- a/config/config.go +++ b/config/config.go @@ -12,17 +12,18 @@ import ( // Config holds the global server-wide config. type Config struct { - Host string `mapstructure:"Host"` - BinPath string `mapstructure:"BinPath"` - Language string - DisableSoftCrash bool // Disables the 'Press Return to exit' dialog allowing scripts to reboot the server automatically - FeaturedWeapons int // Number of Active Feature weapons to generate daily - HideLoginNotice bool // Hide the Erupe notice on login - LoginNotice string // MHFML string of the login notice displayed - PatchServerManifest string // Manifest patch server override - PatchServerFile string // File patch server override - ScreenshotAPIURL string // Destination for screenshots uploaded to BBS - DevMode bool + Host string `mapstructure:"Host"` + BinPath string `mapstructure:"BinPath"` + Language string + DisableSoftCrash bool // Disables the 'Press Return to exit' dialog allowing scripts to reboot the server automatically + FeaturedWeapons int // Number of Active Feature weapons to generate daily + HideLoginNotice bool // Hide the Erupe notice on login + LoginNotice string // MHFML string of the login notice displayed + PatchServerManifest string // Manifest patch server override + PatchServerFile string // File patch server override + ScreenshotAPIURL string // Destination for screenshots uploaded to BBS + DeleteOnSaveCorruption bool // Attempts to save corrupted data will flag the save for deletion + DevMode bool DevModeOptions DevModeOptions Discord Discord diff --git a/server/channelserver/handlers_data.go b/server/channelserver/handlers_data.go index 83981a580..ebab0c4c4 100644 --- a/server/channelserver/handlers_data.go +++ b/server/channelserver/handlers_data.go @@ -49,8 +49,11 @@ func handleMsgMhfSavedata(s *Session, p mhfpacket.MHFPacket) { characterSaveData.Save(s) s.logger.Info("Wrote recompressed savedata back to DB.") } else { - s.logger.Warn("Save cancelled due to corruption.") s.rawConn.Close() + s.logger.Warn("Save cancelled due to corruption.") + if s.server.erupeConfig.DeleteOnSaveCorruption { + s.server.db.Exec("UPDATE characters SET deleted=true WHERE id=$1", s.charID) + } return } _, err = s.server.db.Exec("UPDATE characters SET name=$1 WHERE id=$2", characterSaveData.Name, s.charID)