convert other Warehouse types to new system

This commit is contained in:
wish
2024-02-25 14:12:37 +11:00
parent a9b9c94347
commit 40d4aba3c4
6 changed files with 94 additions and 188 deletions

View File

@@ -2,24 +2,18 @@ package mhfpacket
import (
"errors"
"erupe-ce/common/mhfitem"
"erupe-ce/common/byteframe"
"erupe-ce/network"
"erupe-ce/network/clientctx"
)
type Item struct {
Unk0 uint32
ItemID uint16
Amount uint16
Unk1 uint32
}
// MsgMhfUpdateGuildItem represents the MSG_MHF_UPDATE_GUILD_ITEM
type MsgMhfUpdateGuildItem struct {
AckHandle uint32
GuildID uint32
Items []Item
AckHandle uint32
GuildID uint32
UpdatedItems []mhfitem.MHFItemStack
}
// Opcode returns the ID associated with this packet type.
@@ -31,18 +25,12 @@ func (m *MsgMhfUpdateGuildItem) Opcode() network.PacketID {
func (m *MsgMhfUpdateGuildItem) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
m.AckHandle = bf.ReadUint32()
m.GuildID = bf.ReadUint32()
itemCount := int(bf.ReadUint16())
changes := int(bf.ReadUint16())
bf.ReadUint8() // Zeroed
bf.ReadUint8() // Zeroed
m.Items = make([]Item, itemCount)
for i := 0; i < itemCount; i++ {
m.Items[i].Unk0 = bf.ReadUint32()
m.Items[i].ItemID = bf.ReadUint16()
m.Items[i].Amount = bf.ReadUint16()
m.Items[i].Unk1 = bf.ReadUint32()
for i := 0; i < changes; i++ {
m.UpdatedItems = append(m.UpdatedItems, mhfitem.ReadWarehouseItem(bf))
}
return nil
}

View File

@@ -2,6 +2,7 @@ package mhfpacket
import (
"errors"
"erupe-ce/common/mhfitem"
"erupe-ce/common/byteframe"
"erupe-ce/network"
@@ -10,8 +11,8 @@ import (
// MsgMhfUpdateUnionItem represents the MSG_MHF_UPDATE_UNION_ITEM
type MsgMhfUpdateUnionItem struct {
AckHandle uint32
Items []Item
AckHandle uint32
UpdatedItems []mhfitem.MHFItemStack
}
// Opcode returns the ID associated with this packet type.
@@ -22,18 +23,12 @@ func (m *MsgMhfUpdateUnionItem) Opcode() network.PacketID {
// Parse parses the packet from binary
func (m *MsgMhfUpdateUnionItem) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
m.AckHandle = bf.ReadUint32()
itemCount := int(bf.ReadUint16())
changes := int(bf.ReadUint16())
bf.ReadUint8() // Zeroed
bf.ReadUint8() // Zeroed
m.Items = make([]Item, itemCount)
for i := 0; i < itemCount; i++ {
m.Items[i].Unk0 = bf.ReadUint32()
m.Items[i].ItemID = bf.ReadUint16()
m.Items[i].Amount = bf.ReadUint16()
m.Items[i].Unk1 = bf.ReadUint32()
for i := 0; i < changes; i++ {
m.UpdatedItems = append(m.UpdatedItems, mhfitem.ReadWarehouseItem(bf))
}
return nil
}

View File

@@ -28,7 +28,8 @@ func (m *MsgMhfUpdateWarehouse) Parse(bf *byteframe.ByteFrame, ctx *clientctx.Cl
m.BoxType = bf.ReadUint8()
m.BoxIndex = bf.ReadUint8()
changes := int(bf.ReadUint16())
bf.ReadBytes(2) // Zeroed
bf.ReadUint8() // Zeroed
bf.ReadUint8() // Zeroed
for i := 0; i < changes; i++ {
switch m.BoxType {
case 0: