Skip to content

Commit

Permalink
fix bug with anointment de/reserialization
Browse files Browse the repository at this point in the history
  • Loading branch information
cfi2017 committed Apr 18, 2020
1 parent 5d849c2 commit 34fd347
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions internal/item/item.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,15 @@ func Deserialize(data []byte) (item Item, err error) {
item.Level = int(readNBits(r, 7))

if k, e := btik[strings.ToLower(item.Balance)]; e {
bits := db.GetData(k).GetBits(item.Version)
bits := getBits(k, item.Version)
partCount := int(readNBits(r, 6))
item.Parts = make([]string, partCount)
for i := 0; i < partCount; i++ {
item.Parts[i] = getPart(k, readNBits(r, bits)-1)
}
genericCount := int(readNBits(r, 4))
item.Generics = make([]string, genericCount)
bits = getBits("InventoryGenericPartData", item.Version)
for i := 0; i < genericCount; i++ {
// looks like the bits are the same
// for all the parts and generics
Expand Down Expand Up @@ -211,7 +212,7 @@ func Serialize(item Item, seed int32) ([]byte, error) {
})

if k, e := btik[strings.ToLower(item.Balance)]; e {
bits := getBits(k, item.Version)
bits := getBits("InventoryGenericPartData", item.Version)
for i := len(item.Generics) - 1; i >= 0; i-- {
index := getIndexFor("InventoryGenericPartData", item.Generics[i]) + 1
err := w.WriteInt(index, bits)
Expand All @@ -224,6 +225,7 @@ func Serialize(item Item, seed int32) ([]byte, error) {
if err != nil {
panic(err)
}
bits = getBits(k, item.Version)
for i := len(item.Parts) - 1; i >= 0; i-- {
err := w.WriteInt(getIndexFor(k, item.Parts[i])+1, bits)
if err != nil {
Expand Down

0 comments on commit 34fd347

Please sign in to comment.