warehouse item updates

This commit is contained in:
wish
2022-08-15 20:09:19 +10:00
parent 86cb254d1a
commit b7d41c1c7f
3 changed files with 91 additions and 15 deletions

View File

@@ -11,7 +11,7 @@ import (
// MsgMhfEnumerateWarehouse represents the MSG_MHF_ENUMERATE_WAREHOUSE
type MsgMhfEnumerateWarehouse struct {
AckHandle uint32
BoxType uint8
BoxType string
BoxIndex uint8
}
@@ -23,7 +23,13 @@ func (m *MsgMhfEnumerateWarehouse) Opcode() network.PacketID {
// Parse parses the packet from binary
func (m *MsgMhfEnumerateWarehouse) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
m.AckHandle = bf.ReadUint32()
m.BoxType = bf.ReadUint8()
boxType := bf.ReadUint8()
switch boxType {
case 0:
m.BoxType = "item"
case 1:
m.BoxType = "equip"
}
m.BoxIndex = bf.ReadUint8()
_ = bf.ReadUint16()
return nil

View File

@@ -2,25 +2,24 @@ package mhfpacket
import (
"errors"
"erupe-ce/common/byteframe"
"erupe-ce/network"
"erupe-ce/network/clientctx"
)
type UpdatedStack struct {
type WarehouseStack struct {
ID uint32
Index uint16
ItemID uint16
Quantity uint16
Unk uint16
}
// MsgMhfUpdateWarehouse represents the MSG_MHF_UPDATE_WAREHOUSE
type MsgMhfUpdateWarehouse struct {
AckHandle uint32
BoxID uint16
Items []UpdatedStack
BoxType string
BoxIndex uint8
Updates []WarehouseStack
}
// Opcode returns the ID associated with this packet type.
@@ -31,16 +30,23 @@ func (m *MsgMhfUpdateWarehouse) Opcode() network.PacketID {
// Parse parses the packet from binary
func (m *MsgMhfUpdateWarehouse) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
m.AckHandle = bf.ReadUint32()
m.BoxID = bf.ReadUint16()
boxType := bf.ReadUint8()
switch boxType {
case 0:
m.BoxType = "item"
case 1:
m.BoxType = "equip"
}
m.BoxIndex = bf.ReadUint8()
changes := int(bf.ReadUint16())
var stackUpdate UpdatedStack
var stackUpdate WarehouseStack
for i := 0; i < changes; i++ {
stackUpdate.ID = bf.ReadUint32()
stackUpdate.Index = bf.ReadUint16()
stackUpdate.ItemID = bf.ReadUint16()
stackUpdate.Quantity = bf.ReadUint16()
stackUpdate.Unk = bf.ReadUint16()
m.Items = append(m.Items, stackUpdate)
_ = bf.ReadUint16() // Unk
m.Updates = append(m.Updates, stackUpdate)
}
_ = bf.ReadUint16()
return nil