major rewrite

This commit is contained in:
wish
2024-07-28 22:15:14 +10:00
parent 80e83f656e
commit b6a963b131
9 changed files with 350 additions and 1071 deletions

View File

@@ -10,10 +10,8 @@ import (
// MsgMhfAcquireItem represents the MSG_MHF_ACQUIRE_ITEM
type MsgMhfAcquireItem struct {
AckHandle uint32
NullPadding uint16 //0 in Z2
Length uint16
Unk1 []uint32
AckHandle uint32
RewardIDs []uint32
}
// Opcode returns the ID associated with this packet type.
@@ -24,10 +22,10 @@ func (m *MsgMhfAcquireItem) Opcode() network.PacketID {
// Parse parses the packet from binary
func (m *MsgMhfAcquireItem) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
m.AckHandle = bf.ReadUint32()
m.NullPadding = bf.ReadUint16()
m.Length = bf.ReadUint16()
for i := 0; i < int(m.Length); i++ {
m.Unk1 = append(m.Unk1, bf.ReadUint32())
bf.ReadUint16() // Zeroed
ids := bf.ReadUint16()
for i := uint16(0); i < ids; i++ {
m.RewardIDs = append(m.RewardIDs, bf.ReadUint32())
}
return nil
}

View File

@@ -2,18 +2,17 @@ package mhfpacket
import (
"errors"
"erupe-ce/common/bfutil"
"erupe-ce/common/byteframe"
"erupe-ce/common/stringsupport"
"erupe-ce/network"
"erupe-ce/network/clientctx"
)
// MsgMhfApplyCampaign represents the MSG_MHF_APPLY_CAMPAIGN
type MsgMhfApplyCampaign struct {
AckHandle uint32
CampaignID uint32
NullPadding uint16 // set as 0 in z2
CodeString string
AckHandle uint32
CampaignID uint32
Code string
}
// Opcode returns the ID associated with this packet type.
@@ -25,9 +24,8 @@ func (m *MsgMhfApplyCampaign) Opcode() network.PacketID {
func (m *MsgMhfApplyCampaign) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
m.AckHandle = bf.ReadUint32()
m.CampaignID = bf.ReadUint32()
m.NullPadding = bf.ReadUint16()
m.CodeString = stringsupport.SJISToUTF8(bf.ReadNullTerminatedBytes())
bf.ReadInt8()
bf.ReadUint16() // Zeroed
m.Code = string(bfutil.UpToNull(bf.ReadBytes(16)))
return nil
}

View File

@@ -10,10 +10,8 @@ import (
// MsgMhfEnumerateItem represents the MSG_MHF_ENUMERATE_ITEM
type MsgMhfEnumerateItem struct {
AckHandle uint32
NullPadding uint16 // 0 in Z2
Unk1 uint16 //0002
CampaignID uint32
AckHandle uint32
CampaignID uint32
}
// Opcode returns the ID associated with this packet type.
@@ -24,8 +22,8 @@ func (m *MsgMhfEnumerateItem) Opcode() network.PacketID {
// Parse parses the packet from binary
func (m *MsgMhfEnumerateItem) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
m.AckHandle = bf.ReadUint32()
m.NullPadding = bf.ReadUint16()
m.Unk1 = bf.ReadUint16()
bf.ReadUint16() // Zeroed
bf.ReadUint16() // Always 2
m.CampaignID = bf.ReadUint32()
return nil
}

View File

@@ -11,12 +11,9 @@ import (
// MsgMhfTransferItem represents the MSG_MHF_TRANSFER_ITEM
type MsgMhfTransferItem struct {
AckHandle uint32
// looking at packets, these were static across sessions and did not actually
// correlate with any item IDs that would make sense to get after quests so
// I have no idea what this actually does
Unk0 uint32
Unk1 uint8
Unk2 uint16
QuestID uint32
ItemType uint8
Quantity uint16
}
// Opcode returns the ID associated with this packet type.
@@ -27,10 +24,10 @@ func (m *MsgMhfTransferItem) Opcode() network.PacketID {
// Parse parses the packet from binary
func (m *MsgMhfTransferItem) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
m.AckHandle = bf.ReadUint32()
m.Unk0 = bf.ReadUint32()
m.Unk1 = bf.ReadUint8()
m.QuestID = bf.ReadUint32()
m.ItemType = bf.ReadUint8()
bf.ReadUint8() // Zeroed
m.Unk2 = bf.ReadUint16()
m.Quantity = bf.ReadUint16()
return nil
}