continue on existing save (#3)

* long blob

* fix continue

* one slot only?

* fallback if there is no slot data yet

* Revert "one slot only?"

This reverts commit 20997e9cd8.
This commit is contained in:
Up authored and GitHub committed 2024-05-07 19:14:07 -04:00
1 parent 1f95f7c042
commit 0d6539a87b
3 files changed
+22 -24

No files matched your search

+2 -2
View File
@@ -42,8 +42,8 @@ func Init(username, password, protocol, address, database string) error {
if err != nil {
panic(err)
}
tx.Exec("CREATE TABLE IF NOT EXISTS systemSaveData (uuid BINARY(16) PRIMARY KEY, data BLOB, timestamp TIMESTAMP)")
tx.Exec("CREATE TABLE IF NOT EXISTS sessionSaveData (uuid BINARY(16), slot TINYINT, data BLOB, timestamp TIMESTAMP, PRIMARY KEY (uuid, slot))")
tx.Exec("CREATE TABLE IF NOT EXISTS systemSaveData (uuid BINARY(16) PRIMARY KEY, data LONGBLOB, timestamp TIMESTAMP)")
tx.Exec("CREATE TABLE IF NOT EXISTS sessionSaveData (uuid BINARY(16), slot TINYINT, data LONGBLOB, timestamp TIMESTAMP, PRIMARY KEY (uuid, slot))")
err = tx.Commit()
if err != nil {
panic(err)
+10
View File
@@ -79,6 +79,16 @@ func ReadSessionSaveData(uuid []byte, slot int) (defs.SessionSaveData, error) {
return save, err
}
func GetLatestSessionSaveDataSlot(uuid []byte) (int, error) {
var slot int
err := handle.QueryRow("SELECT slot FROM sessionSaveData WHERE uuid = ? ORDER BY timestamp DESC, slot ASC LIMIT 1", uuid).Scan(&slot)
if err != nil {
return -1, err
}
return slot, nil
}
func StoreSessionSaveData(uuid []byte, data defs.SessionSaveData, slot int) error {
var buf bytes.Buffer