Skip to content

Commit

Permalink
add more logging, set seed to 0 if non existant (case create item)
Browse files Browse the repository at this point in the history
  • Loading branch information
cfi2017 committed May 10, 2020
1 parent 1f94d12 commit 216aed8
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions internal/server/character.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,25 +160,29 @@ func updateItemsRequest(c *gin.Context) {
id := c.Param("id")
f, err := getSaveById(id)
if err != nil {
c.AbortWithStatus(500)
log.Printf("error getting save: %v", err)
c.AbortWithStatusJSON(500, &err)
return
}
s, char := character.Deserialize(f)
err = f.Close()
if err != nil {
c.AbortWithStatus(500)
log.Printf("error deserializing save: %v", err)
c.AbortWithStatusJSON(500, &err)
return
}
var ir ItemRequest
err = c.BindJSON(&ir)
if err != nil {
c.AbortWithStatus(500)
log.Printf("error deserializing request json: %v", err)
c.AbortWithStatusJSON(500, &err)
return
}
backup(pwd, id)
char.InventoryItems, err = itemsToPBArray(ir.Items)
if err != nil {
c.AbortWithStatus(500)
log.Printf("error converting items to save format: %v", err)
c.AbortWithStatusJSON(500, &err)
return
}
char.ActiveWeaponList = ir.Active
Expand All @@ -201,7 +205,8 @@ func itemsToPBArray(items []item.Item) ([]*pb.OakInventoryItemSaveGameData, erro
result[index] = i.Wrapper
seed, err := item.GetSeedFromSerial(i.Wrapper.ItemSerialNumber)
if err != nil {
return nil, err
// set seed to be 0
seed = 0
}
if i.Balance == "" {
// sanity check, if the balance is empty, just write the original item back
Expand Down

0 comments on commit 216aed8

Please sign in to comment.