Skip to content

Commit

Permalink
print out unserializable items
Browse files Browse the repository at this point in the history
  • Loading branch information
cfi2017 committed Apr 12, 2020
1 parent df58627 commit dd6d578
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 17 deletions.
24 changes: 12 additions & 12 deletions internal/item/item.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ package item

import (
"encoding/binary"
"encoding/hex"
"encoding/json"
"errors"
"fmt"
"hash/crc32"
"io/ioutil"
"log"
"strings"
"sync"

Expand All @@ -22,15 +20,15 @@ var (
)

type Item struct {
Level int
Balance string
Manufacturer string
InvData string
Parts []string
Generics []string
Overflow string
Version uint64
Wrapper *pb.OakInventoryItemSaveGameData
Level int `json:"level"`
Balance string `json:"balance"`
Manufacturer string `json:"manufacturer"`
InvData string `json:"inv_data"`
Parts []string `json:"parts"`
Generics []string `json:"generics"`
Overflow string `json:"overflow"`
Version uint64 `json:"version"`
Wrapper *pb.OakInventoryItemSaveGameData `json:"wrapper"`
}

func DecryptSerial(data []byte) ([]byte, error) {
Expand All @@ -44,7 +42,6 @@ func DecryptSerial(data []byte) ([]byte, error) {
decrypted := bogoDecrypt(seed, data[5:])
crc := binary.BigEndian.Uint16(decrypted) // first two bytes of decrypted data are crc checksum
combined := append(append(data[:5], 0xFF, 0xFF), decrypted[2:]...) // combined data with checksum replaced with 0xFF to compute checksum
log.Println(hex.EncodeToString(combined))
computedChecksum := crc32.ChecksumIEEE(combined)
check := uint16(((computedChecksum) >> 16) ^ ((computedChecksum & 0xFFFF) >> 0))

Expand Down Expand Up @@ -151,6 +148,9 @@ func getBits(k string, v uint64) int {

func getPart(key string, index uint64) string {
data := db.GetData(key)
if int(index) >= len(data.Assets) {
return ""
}
return data.GetPart(index)
}

Expand Down
16 changes: 11 additions & 5 deletions internal/server/character.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package server

import (
"encoding/base64"
"io/ioutil"
"log"
"math"
"os"
"regexp"
Expand Down Expand Up @@ -126,17 +128,21 @@ func getItems(c *gin.Context) {
c.AbortWithStatus(500)
}
_, char := character.Deserialize(f)
items := make([]item.Item, len(char.InventoryItems))
items := make([]item.Item, 0)
for _, data := range char.InventoryItems {
i, err := item.Deserialize(data.ItemSerialNumber)
d := make([]byte, len(data.ItemSerialNumber))
copy(d, data.ItemSerialNumber)
i, err := item.Deserialize(d)
if err != nil {
c.AbortWithStatus(500)
return
log.Println(err)
log.Println(base64.StdEncoding.EncodeToString(data.ItemSerialNumber))
// c.AbortWithStatus(500)
// return
}
i.Wrapper = data
items = append(items, i)
}
c.JSON(200, items)
c.JSON(200, &items)
return
}

Expand Down

0 comments on commit dd6d578

Please sign in to comment.