@ -19,9 +19,8 @@ import (
const sessionSlotCount = 3
const sessionSlotCount = 3
// /savedata/get - get save data
// /savedata/get - get save data
func ( s * Server ) handleSavedataGet ( w http . ResponseWriter , r * http . Request ) {
func ( s * Server ) HandleSavedataGet ( w http . ResponseWriter , r * http . Request ) {
uuid , err := getUuidFromRequest ( r )
uuid , err := GetUuidFromRequest ( r )
if err != nil {
if err != nil {
http . Error ( w , err . Error ( ) , http . StatusBadRequest )
http . Error ( w , err . Error ( ) , http . StatusBadRequest )
return
return
@ -29,7 +28,7 @@ func (s *Server) HandleSavedataGet(w http.ResponseWriter, r *http.Request) {
switch r . URL . Query ( ) . Get ( "datatype" ) {
switch r . URL . Query ( ) . Get ( "datatype" ) {
case "0" : // System
case "0" : // System
system , err := R eadSystemSaveData( uuid )
system , err := r eadSystemSaveData( uuid )
if err != nil {
if err != nil {
http . Error ( w , err . Error ( ) , http . StatusInternalServerError )
http . Error ( w , err . Error ( ) , http . StatusInternalServerError )
return
return
@ -54,7 +53,7 @@ func (s *Server) HandleSavedataGet(w http.ResponseWriter, r *http.Request) {
return
return
}
}
session , err := R eadSessionSaveData( uuid , slotId )
session , err := r eadSessionSaveData( uuid , slotId )
if err != nil {
if err != nil {
http . Error ( w , err . Error ( ) , http . StatusInternalServerError )
http . Error ( w , err . Error ( ) , http . StatusInternalServerError )
return
return
@ -74,9 +73,8 @@ func (s *Server) HandleSavedataGet(w http.ResponseWriter, r *http.Request) {
}
}
// /savedata/update - update save data
// /savedata/update - update save data
func ( s * Server ) handleSavedataUpdate ( w http . ResponseWriter , r * http . Request ) {
func ( s * Server ) HandleSavedataUpdate ( w http . ResponseWriter , r * http . Request ) {
uuid , err := getUuidFromRequest ( r )
uuid , err := GetUuidFromRequest ( r )
if err != nil {
if err != nil {
http . Error ( w , err . Error ( ) , http . StatusBadRequest )
http . Error ( w , err . Error ( ) , http . StatusBadRequest )
return
return
@ -188,9 +186,8 @@ func (s *Server) HandleSavedataUpdate(w http.ResponseWriter, r *http.Request) {
}
}
// /savedata/delete - delete save data
// /savedata/delete - delete save data
func ( s * Server ) handleSavedataDelete ( w http . ResponseWriter , r * http . Request ) {
func ( s * Server ) HandleSavedataDelete ( w http . ResponseWriter , r * http . Request ) {
uuid , err := getUuidFromRequest ( r )
uuid , err := GetUuidFromRequest ( r )
if err != nil {
if err != nil {
http . Error ( w , err . Error ( ) , http . StatusBadRequest )
http . Error ( w , err . Error ( ) , http . StatusBadRequest )
return
return
@ -245,9 +242,8 @@ type SavedataClearResponse struct {
}
}
// /savedata/clear - mark session save data as cleared and delete
// /savedata/clear - mark session save data as cleared and delete
func ( s * Server ) handleSavedataClear ( w http . ResponseWriter , r * http . Request ) {
func ( s * Server ) HandleSavedataClear ( w http . ResponseWriter , r * http . Request ) {
uuid , err := getUuidFromRequest ( r )
uuid , err := GetUuidFromRequest ( r )
if err != nil {
if err != nil {
http . Error ( w , err . Error ( ) , http . StatusBadRequest )
http . Error ( w , err . Error ( ) , http . StatusBadRequest )
return
return
@ -276,7 +272,7 @@ func (s *Server) HandleSavedataClear(w http.ResponseWriter, r *http.Request) {
return
return
}
}
sessionCompleted := V alidateSessionCompleted( session )
sessionCompleted := v alidateSessionCompleted( session )
newCompletion := false
newCompletion := false
if session . GameMode == 3 && session . Seed == dailyRunSeed {
if session . GameMode == 3 && session . Seed == dailyRunSeed {
@ -286,14 +282,14 @@ func (s *Server) HandleSavedataClear(w http.ResponseWriter, r *http.Request) {
}
}
err = db . AddOrUpdateAccountDailyRun ( uuid , session . Score , waveCompleted )
err = db . AddOrUpdateAccountDailyRun ( uuid , session . Score , waveCompleted )
if err != nil {
if err != nil {
log . Printf ( "failed to add or update daily run record: %s" , err .Error ( ) )
log . Printf ( "failed to add or update daily run record: %s" , err )
}
}
}
}
if sessionCompleted {
if sessionCompleted {
newCompletion , err = db . TryAddSeedCompletion ( uuid , session . Seed , int ( session . GameMode ) )
newCompletion , err = db . TryAddSeedCompletion ( uuid , session . Seed , int ( session . GameMode ) )
if err != nil {
if err != nil {
log . Printf ( "failed to mark seed as completed: %s" , err .Error ( ) )
log . Printf ( "failed to mark seed as completed: %s" , err )
}
}
}
}