From 048db6760930d3446dd39f24eeddaf7fe9f38081 Mon Sep 17 00:00:00 2001 From: Pancakes Date: Thu, 6 Jun 2024 03:45:59 -0400 Subject: [PATCH] Remove timestamp guard --- db/savedata.go | 35 ++--------------------------------- 1 file changed, 2 insertions(+), 33 deletions(-) diff --git a/db/savedata.go b/db/savedata.go index 78bf8fb..bb792c5 100644 --- a/db/savedata.go +++ b/db/savedata.go @@ -20,9 +20,6 @@ package db import ( "bytes" "encoding/gob" - "errors" - "fmt" - "time" "github.com/pagefaultgames/rogueserver/defs" ) @@ -72,31 +69,8 @@ func ReadSystemSaveData(uuid []byte) (defs.SystemSaveData, error) { } func StoreSystemSaveData(uuid []byte, data defs.SystemSaveData) error { - currentTime := time.Now() - futureTime := currentTime.Add(time.Hour * 24).UnixMilli() - pastTime := currentTime.Add(-time.Hour * 24).UnixMilli() - - systemData, err := ReadSystemSaveData(uuid) - if err == nil { // system save exists - // Check if the new data timestamp is in the past against the system save but only if the system save is not past 24 hours from now - if systemData.Timestamp > data.Timestamp && systemData.Timestamp < int(futureTime) { - // Error if the new data timestamp is older than the current system save timestamp - return fmt.Errorf("attempted to save an older system save from %d when the current system save is from %d", data.Timestamp, systemData.Timestamp) - } - } - - // Check if the data.Timestamp is too far in the future - if data.Timestamp > int(futureTime) { - return fmt.Errorf("attempted to save a system save in the future from %d", data.Timestamp) - } - - // Check if the data.Timestamp is too far in the past - if data.Timestamp < int(pastTime) { - return fmt.Errorf("attempted to save a system save in the past from %d", data.Timestamp) - } - var buf bytes.Buffer - err = gob.NewEncoder(&buf).Encode(data) + err := gob.NewEncoder(&buf).Encode(data) if err != nil { return err } @@ -146,13 +120,8 @@ func GetLatestSessionSaveDataSlot(uuid []byte) (int, error) { } func StoreSessionSaveData(uuid []byte, data defs.SessionSaveData, slot int) error { - session, err := ReadSessionSaveData(uuid, slot) - if err == nil && session.Seed == data.Seed && session.WaveIndex > data.WaveIndex { - return errors.New("attempted to save an older session") - } - var buf bytes.Buffer - err = gob.NewEncoder(&buf).Encode(data) + err := gob.NewEncoder(&buf).Encode(data) if err != nil { return err }