mirror of
https://github.com/pagefaultgames/rogueserver.git
synced 2025-04-27 22:56:18 +08:00
New GetPlaytime function
This commit is contained in:
parent
f6e35d3c7a
commit
4141d13a69
@ -338,7 +338,7 @@ func handleUpdateAll(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
existingPlaytime, err := db.RetrievePlaytime(uuid)
|
||||
existingPlaytime, err := savedata.GetPlaytime(uuid)
|
||||
if err != nil && !errors.Is(err, sql.ErrNoRows) {
|
||||
httpError(w, r, fmt.Errorf("failed to retrieve playtime: %s", err), http.StatusInternalServerError)
|
||||
return
|
||||
@ -440,7 +440,7 @@ func handleSystem(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
existingPlaytime, err := db.RetrievePlaytime(uuid)
|
||||
existingPlaytime, err := savedata.GetPlaytime(uuid)
|
||||
if err != nil && !errors.Is(err, sql.ErrNoRows) {
|
||||
httpError(w, r, fmt.Errorf("failed to retrieve playtime: %s", err), http.StatusInternalServerError)
|
||||
return
|
||||
|
@ -71,3 +71,12 @@ func DeleteSystem(uuid []byte) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func GetPlaytime(uuid []byte) (int, error) {
|
||||
system, err := GetSystem(uuid)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return int(system.GameStats.(map[string]interface{})["playTime"].(float64)), nil
|
||||
}
|
||||
|
@ -211,15 +211,6 @@ func DeleteSessionSaveData(uuid []byte, slot int) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func RetrievePlaytime(uuid []byte) (int, error) {
|
||||
system, err := ReadSystemSaveData(uuid)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return int(system.GameStats.(map[string]interface{})["playTime"].(float64)), nil
|
||||
}
|
||||
|
||||
func GetSystemSaveFromS3(uuid []byte) (defs.SystemSaveData, error) {
|
||||
var system defs.SystemSaveData
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user