fix parsing and handling of DistItem packets

This commit is contained in:
wish
2023-10-24 21:24:35 +11:00
parent 94f9174afa
commit ba50dc419a
3 changed files with 37 additions and 24 deletions

View File

@@ -1,18 +1,19 @@
package mhfpacket
import (
"errors"
"erupe-ce/common/byteframe"
"erupe-ce/network"
"erupe-ce/network/clientctx"
"erupe-ce/common/byteframe"
)
// MsgMhfApplyDistItem represents the MSG_MHF_APPLY_DIST_ITEM
type MsgMhfApplyDistItem struct {
AckHandle uint32
AckHandle uint32
DistributionType uint8
DistributionID uint32
Unk2 uint32
Unk3 uint32
DistributionID uint32
Unk2 uint32
Unk3 uint32
}
// Opcode returns the ID associated with this packet type.
@@ -32,10 +33,5 @@ func (m *MsgMhfApplyDistItem) Parse(bf *byteframe.ByteFrame, ctx *clientctx.Clie
// Build builds a binary packet from the current data.
func (m *MsgMhfApplyDistItem) Build(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
bf.WriteUint32(m.AckHandle)
bf.WriteUint8(m.DistributionType)
bf.WriteUint32(m.DistributionID)
bf.WriteUint32(m.Unk2)
bf.WriteUint32(m.Unk3)
return nil
}
return errors.New("NOT IMPLEMENTED")
}

View File

@@ -1,17 +1,19 @@
package mhfpacket
import (
"errors"
"erupe-ce/common/byteframe"
"erupe-ce/network"
"erupe-ce/network/clientctx"
"erupe-ce/common/byteframe"
)
// MsgMhfEnumerateDistItem represents the MSG_MHF_ENUMERATE_DIST_ITEM
type MsgMhfEnumerateDistItem struct {
AckHandle uint32
Unk0 uint8
Unk1 uint16
Unk1 uint8
Unk2 uint16
Unk3 []byte
}
// Opcode returns the ID associated with this packet type.
@@ -23,16 +25,13 @@ func (m *MsgMhfEnumerateDistItem) Opcode() network.PacketID {
func (m *MsgMhfEnumerateDistItem) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
m.AckHandle = bf.ReadUint32()
m.Unk0 = bf.ReadUint8()
m.Unk1 = bf.ReadUint16()
m.Unk1 = bf.ReadUint8()
m.Unk2 = bf.ReadUint16()
m.Unk3 = bf.ReadBytes(uint(bf.ReadUint8()))
return nil
}
// Build builds a binary packet from the current data.
func (m *MsgMhfEnumerateDistItem) Build(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
bf.WriteUint32(m.AckHandle)
bf.WriteUint8(m.Unk0)
bf.WriteUint16(m.Unk1)
bf.WriteUint16(m.Unk2)
return nil
return errors.New("NOT IMPLEMENTED")
}

View File

@@ -67,10 +67,28 @@ func handleMsgMhfEnumerateDistItem(s *Session, p mhfpacket.MHFPacket) {
bf.WriteUint16(distData.MaxSR)
bf.WriteUint16(distData.MinGR)
bf.WriteUint16(distData.MaxGR)
bf.WriteUint32(0) // Unk
bf.WriteUint32(0) // Unk
ps.Uint16(bf, distData.EventName, true)
bf.WriteBytes(make([]byte, 391))
bf.WriteUint8(0)
bf.WriteUint16(0)
bf.WriteUint8(0)
bf.WriteUint16(0)
bf.WriteUint16(0)
bf.WriteUint8(0)
ps.Uint8(bf, distData.EventName, true)
for i := 0; i < 6; i++ {
for j := 0; j < 13; j++ {
bf.WriteUint8(0)
bf.WriteUint32(0)
}
}
i := uint8(0)
bf.WriteUint8(i)
if i <= 10 {
for j := uint8(0); j < i; j++ {
bf.WriteUint32(0)
bf.WriteUint32(0)
bf.WriteUint32(0)
}
}
}
resp := byteframe.NewByteFrame()
resp.WriteUint16(uint16(distCount))