mirror of
https://github.com/pagefaultgames/rogueserver.git
synced 2025-07-05 16:02:23 +02:00
Compare commits
No commits in common. "56b94e33c7b54ae5180d0454bc3b7782c6407da6" and "90a061d04782085680cfd7b0eec80c845f71f19c" have entirely different histories.
56b94e33c7
...
90a061d047
@ -21,7 +21,6 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"encoding/gob"
|
"encoding/gob"
|
||||||
|
|
||||||
"github.com/klauspost/compress/zstd"
|
|
||||||
"github.com/pagefaultgames/rogueserver/defs"
|
"github.com/pagefaultgames/rogueserver/defs"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -61,19 +60,6 @@ func ReadSystemSaveData(uuid []byte) (defs.SystemSaveData, error) {
|
|||||||
return system, err
|
return system, err
|
||||||
}
|
}
|
||||||
|
|
||||||
dec, err := zstd.NewReader(nil)
|
|
||||||
if err != nil {
|
|
||||||
return system, err
|
|
||||||
}
|
|
||||||
|
|
||||||
defer dec.Close()
|
|
||||||
|
|
||||||
decompressed, err := dec.DecodeAll(data, nil)
|
|
||||||
if err == nil {
|
|
||||||
// replace if it worked, otherwise use the original data
|
|
||||||
data = decompressed
|
|
||||||
}
|
|
||||||
|
|
||||||
err = gob.NewDecoder(bytes.NewReader(data)).Decode(&system)
|
err = gob.NewDecoder(bytes.NewReader(data)).Decode(&system)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return system, err
|
return system, err
|
||||||
@ -89,14 +75,7 @@ func StoreSystemSaveData(uuid []byte, data defs.SystemSaveData) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
enc, err := zstd.NewWriter(nil)
|
_, err = handle.Exec("INSERT INTO systemSaveData (uuid, data, timestamp) VALUES (?, ?, UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE data = ?, timestamp = UTC_TIMESTAMP()", uuid, buf.Bytes(), buf.Bytes())
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
defer enc.Close()
|
|
||||||
|
|
||||||
_, err = handle.Exec("REPLACE INTO systemSaveData (uuid, data, timestamp) VALUES (?, ?, UTC_TIMESTAMP())", uuid, enc.EncodeAll(buf.Bytes(), nil))
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -122,19 +101,6 @@ func ReadSessionSaveData(uuid []byte, slot int) (defs.SessionSaveData, error) {
|
|||||||
return session, err
|
return session, err
|
||||||
}
|
}
|
||||||
|
|
||||||
dec, err := zstd.NewReader(nil)
|
|
||||||
if err != nil {
|
|
||||||
return session, err
|
|
||||||
}
|
|
||||||
|
|
||||||
defer dec.Close()
|
|
||||||
|
|
||||||
decompressed, err := dec.DecodeAll(data, nil)
|
|
||||||
if err == nil {
|
|
||||||
// replace if it worked, otherwise use the original data
|
|
||||||
data = decompressed
|
|
||||||
}
|
|
||||||
|
|
||||||
err = gob.NewDecoder(bytes.NewReader(data)).Decode(&session)
|
err = gob.NewDecoder(bytes.NewReader(data)).Decode(&session)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return session, err
|
return session, err
|
||||||
@ -160,14 +126,7 @@ func StoreSessionSaveData(uuid []byte, data defs.SessionSaveData, slot int) erro
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
enc, err := zstd.NewWriter(nil)
|
_, err = handle.Exec("INSERT INTO sessionSaveData (uuid, slot, data, timestamp) VALUES (?, ?, ?, UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE data = ?, timestamp = UTC_TIMESTAMP()", uuid, slot, buf.Bytes(), buf.Bytes())
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
defer enc.Close()
|
|
||||||
|
|
||||||
_, err = handle.Exec("REPLACE INTO sessionSaveData (uuid, slot, data, timestamp) VALUES (?, ?, ?, UTC_TIMESTAMP())", uuid, slot, enc.EncodeAll(buf.Bytes(), nil))
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
5
go.mod
5
go.mod
@ -8,9 +8,6 @@ require (
|
|||||||
golang.org/x/crypto v0.22.0
|
golang.org/x/crypto v0.22.0
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require github.com/golang-jwt/jwt/v5 v5.2.1
|
||||||
github.com/golang-jwt/jwt/v5 v5.2.1
|
|
||||||
github.com/klauspost/compress v1.17.9
|
|
||||||
)
|
|
||||||
|
|
||||||
require golang.org/x/sys v0.19.0 // indirect
|
require golang.org/x/sys v0.19.0 // indirect
|
||||||
|
2
go.sum
2
go.sum
@ -2,8 +2,6 @@ github.com/go-sql-driver/mysql v1.7.1 h1:lUIinVbN1DY0xBg0eMOzmmtGoHwWBbvnWubQUrt
|
|||||||
github.com/go-sql-driver/mysql v1.7.1/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
|
github.com/go-sql-driver/mysql v1.7.1/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
|
||||||
github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk=
|
github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk=
|
||||||
github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
|
github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
|
||||||
github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA=
|
|
||||||
github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
|
|
||||||
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
|
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
|
||||||
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
|
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
|
||||||
golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30=
|
golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30=
|
||||||
|
Loading…
Reference in New Issue
Block a user