Skip to content

Commit

Permalink
update parsing of many packets
Browse files Browse the repository at this point in the history
  • Loading branch information
sekaiwish committed Nov 18, 2023
1 parent fc57d63 commit 85fc76e
Show file tree
Hide file tree
Showing 44 changed files with 272 additions and 278 deletions.
25 changes: 13 additions & 12 deletions network/mhfpacket/msg_mhf_acquire_festa.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package mhfpacket

import (
"errors"
"errors"

"erupe-ce/network/clientctx"
"erupe-ce/network"
"erupe-ce/common/byteframe"
"erupe-ce/network"
"erupe-ce/network/clientctx"
)

// MsgMhfAcquireFesta represents the MSG_MHF_ACQUIRE_FESTA
type MsgMhfAcquireFesta struct {
AckHandle uint32
FestaID uint32
GuildID uint32
Unk uint16
AckHandle uint32
FestaID uint32
GuildID uint32
Unk uint8
}

// Opcode returns the ID associated with this packet type.
Expand All @@ -23,11 +23,12 @@ func (m *MsgMhfAcquireFesta) Opcode() network.PacketID {

// Parse parses the packet from binary
func (m *MsgMhfAcquireFesta) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
m.AckHandle = bf.ReadUint32()
m.FestaID = bf.ReadUint32()
m.GuildID = bf.ReadUint32()
m.Unk = bf.ReadUint16()
return nil
m.AckHandle = bf.ReadUint32()
m.FestaID = bf.ReadUint32()
m.GuildID = bf.ReadUint32()
m.Unk = bf.ReadUint8()
bf.ReadUint8() // Zeroed
return nil
}

// Build builds a binary packet from the current data.
Expand Down
13 changes: 7 additions & 6 deletions network/mhfpacket/msg_mhf_acquire_monthly_item.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import (
// MsgMhfAcquireMonthlyItem represents the MSG_MHF_ACQUIRE_MONTHLY_ITEM
type MsgMhfAcquireMonthlyItem struct {
AckHandle uint32
Unk0 uint16
Unk1 uint16
Unk2 uint32
Unk0 uint8
Unk1 uint8
Unk2 uint16
Unk3 uint32
}

Expand All @@ -25,10 +25,11 @@ func (m *MsgMhfAcquireMonthlyItem) Opcode() network.PacketID {
// Parse parses the packet from binary
func (m *MsgMhfAcquireMonthlyItem) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
m.AckHandle = bf.ReadUint32()
m.Unk0 = bf.ReadUint16()
m.Unk1 = bf.ReadUint16()
m.Unk2 = bf.ReadUint32()
m.Unk0 = bf.ReadUint8()
m.Unk1 = bf.ReadUint8()
m.Unk2 = bf.ReadUint16()
m.Unk3 = bf.ReadUint32()
bf.ReadUint32() // Zeroed
return nil
}

Expand Down
5 changes: 2 additions & 3 deletions network/mhfpacket/msg_mhf_announce.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type MsgMhfAnnounce struct {
IPAddress uint32
Port uint16
StageID []byte
Type uint8
Data *byteframe.ByteFrame
}

// Opcode returns the ID associated with this packet type.
Expand All @@ -31,8 +31,7 @@ func (m *MsgMhfAnnounce) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientCon
_ = bf.ReadUint8()
_ = bf.ReadUint8()
m.StageID = bf.ReadBytes(32)
_ = bf.ReadUint32()
m.Type = bf.ReadUint8()
m.Data = byteframe.NewByteFrameFromBytes(bf.ReadBytes(uint(bf.ReadUint32())))
return nil
}

Expand Down
19 changes: 6 additions & 13 deletions network/mhfpacket/msg_mhf_arrange_guild_member.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package mhfpacket

import (
"errors"
"erupe-ce/common/byteframe"
"erupe-ce/network"
"erupe-ce/network/clientctx"
"erupe-ce/common/byteframe"
)

// MsgMhfArrangeGuildMember represents the MSG_MHF_ARRANGE_GUILD_MEMBER
Expand All @@ -22,11 +23,11 @@ func (m *MsgMhfArrangeGuildMember) Opcode() network.PacketID {
func (m *MsgMhfArrangeGuildMember) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
m.AckHandle = bf.ReadUint32()
m.GuildID = bf.ReadUint32()
charCount := bf.ReadUint16()

bf.ReadUint8() // Zeroed
charCount := int(bf.ReadUint8())
m.CharIDs = make([]uint32, charCount)

for i := uint16(0); i < charCount; i++ {
for i := 0; i < charCount; i++ {
m.CharIDs[i] = bf.ReadUint32()
}

Expand All @@ -35,13 +36,5 @@ func (m *MsgMhfArrangeGuildMember) Parse(bf *byteframe.ByteFrame, ctx *clientctx

// Build builds a binary packet from the current data.
func (m *MsgMhfArrangeGuildMember) Build(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
bf.WriteUint32(m.AckHandle)
bf.WriteUint32(m.GuildID)
bf.WriteUint16(uint16(len(m.CharIDs)))

for _, charID := range m.CharIDs {
bf.WriteUint32(charID)
}

return nil
return errors.New("NOT IMPLEMENTED")
}
25 changes: 13 additions & 12 deletions network/mhfpacket/msg_mhf_create_joint.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package mhfpacket

import (
"errors"
"errors"

"erupe-ce/network/clientctx"
"erupe-ce/common/stringsupport"
"erupe-ce/network"
"erupe-ce/common/byteframe"
"erupe-ce/common/stringsupport"
"erupe-ce/network"
"erupe-ce/network/clientctx"
)

// MsgMhfCreateJoint represents the MSG_MHF_CREATE_JOINT
type MsgMhfCreateJoint struct {
AckHandle uint32
GuildID uint32
Name string
AckHandle uint32
GuildID uint32
Name string
}

// Opcode returns the ID associated with this packet type.
Expand All @@ -23,11 +23,12 @@ func (m *MsgMhfCreateJoint) Opcode() network.PacketID {

// Parse parses the packet from binary
func (m *MsgMhfCreateJoint) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
m.AckHandle = bf.ReadUint32()
m.GuildID = bf.ReadUint32()
_ = bf.ReadUint32() // len
m.Name = stringsupport.SJISToUTF8(bf.ReadNullTerminatedBytes())
return nil
m.AckHandle = bf.ReadUint32()
m.GuildID = bf.ReadUint32()
bf.ReadUint16() // Zeroed
bf.ReadUint16() // Name length
m.Name = stringsupport.SJISToUTF8(bf.ReadNullTerminatedBytes())
return nil
}

// Build builds a binary packet from the current data.
Expand Down
22 changes: 11 additions & 11 deletions network/mhfpacket/msg_mhf_entry_festa.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package mhfpacket

import (
"errors"
"errors"

"erupe-ce/network/clientctx"
"erupe-ce/network"
"erupe-ce/common/byteframe"
"erupe-ce/network"
"erupe-ce/network/clientctx"
)

// MsgMhfEntryFesta represents the MSG_MHF_ENTRY_FESTA
type MsgMhfEntryFesta struct {
AckHandle uint32
FestaID uint32
GuildID uint32
AckHandle uint32
FestaID uint32
GuildID uint32
}

// Opcode returns the ID associated with this packet type.
Expand All @@ -22,11 +22,11 @@ func (m *MsgMhfEntryFesta) Opcode() network.PacketID {

// Parse parses the packet from binary
func (m *MsgMhfEntryFesta) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
m.AckHandle = bf.ReadUint32()
m.FestaID = bf.ReadUint32()
m.GuildID = bf.ReadUint32()
_ = bf.ReadUint16() // Always 0
return nil
m.AckHandle = bf.ReadUint32()
m.FestaID = bf.ReadUint32()
m.GuildID = bf.ReadUint32()
bf.ReadUint16() // Zeroed
return nil
}

// Build builds a binary packet from the current data.
Expand Down
18 changes: 9 additions & 9 deletions network/mhfpacket/msg_mhf_enumerate_festa_member.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package mhfpacket

import (
"errors"
"errors"

"erupe-ce/network/clientctx"
"erupe-ce/network"
"erupe-ce/common/byteframe"
"erupe-ce/network"
"erupe-ce/network/clientctx"
)

// MsgMhfEnumerateFestaMember represents the MSG_MHF_ENUMERATE_FESTA_MEMBER
type MsgMhfEnumerateFestaMember struct {
AckHandle uint32
FestaID uint32
GuildID uint32
AckHandle uint32
FestaID uint32
GuildID uint32
}

// Opcode returns the ID associated with this packet type.
Expand All @@ -22,11 +22,11 @@ func (m *MsgMhfEnumerateFestaMember) Opcode() network.PacketID {

// Parse parses the packet from binary
func (m *MsgMhfEnumerateFestaMember) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
m.AckHandle = bf.ReadUint32()
m.AckHandle = bf.ReadUint32()
m.FestaID = bf.ReadUint32()
m.GuildID = bf.ReadUint32()
_ = bf.ReadUint16() // Hardcoded 0 in the binary.
return nil
bf.ReadUint16() // Zeroed
return nil
}

// Build builds a binary packet from the current data.
Expand Down
5 changes: 2 additions & 3 deletions network/mhfpacket/msg_mhf_enumerate_guacot.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import (
// MsgMhfEnumerateGuacot represents the MSG_MHF_ENUMERATE_GUACOT
type MsgMhfEnumerateGuacot struct {
AckHandle uint32
Unk0 uint32 // Hardcoded 0 in binary
Unk1 uint16 // Hardcoded 0 in binary
Unk0 uint32
}

// Opcode returns the ID associated with this packet type.
Expand All @@ -23,7 +22,7 @@ func (m *MsgMhfEnumerateGuacot) Opcode() network.PacketID {
func (m *MsgMhfEnumerateGuacot) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
m.AckHandle = bf.ReadUint32()
m.Unk0 = bf.ReadUint32()
m.Unk1 = bf.ReadUint16()
bf.ReadUint16() // Zeroed
return nil
}

Expand Down
18 changes: 8 additions & 10 deletions network/mhfpacket/msg_mhf_enumerate_guild.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ package mhfpacket

import (
"errors"
"erupe-ce/common/bfutil"
"erupe-ce/common/byteframe"
"erupe-ce/common/stringsupport"
"erupe-ce/network"
"erupe-ce/network/clientctx"
)
Expand Down Expand Up @@ -34,8 +32,8 @@ type MsgMhfEnumerateGuild struct {
Type EnumerateGuildType
Page uint8
Sorting bool
Data1 []byte
Data2 string
Data1 *byteframe.ByteFrame
Data2 *byteframe.ByteFrame
}

// Opcode returns the ID associated with this packet type.
Expand All @@ -49,12 +47,12 @@ func (m *MsgMhfEnumerateGuild) Parse(bf *byteframe.ByteFrame, ctx *clientctx.Cli
m.Type = EnumerateGuildType(bf.ReadUint8())
m.Page = bf.ReadUint8()
m.Sorting = bf.ReadBool()
_ = bf.ReadBytes(1)
m.Data1 = bf.ReadBytes(4)
_ = bf.ReadBytes(2)
lenData2 := uint(bf.ReadUint8())
_ = bf.ReadBytes(1)
m.Data2 = stringsupport.SJISToUTF8(bfutil.UpToNull(bf.ReadBytes(lenData2)))
bf.ReadUint8() // Zeroed
m.Data1 = byteframe.NewByteFrameFromBytes(bf.ReadBytes(4))
bf.ReadUint16() // Zeroed
dataLen := uint(bf.ReadUint8())
bf.ReadUint8() // Zeroed
m.Data2 = byteframe.NewByteFrameFromBytes(bf.ReadBytes(dataLen))
return nil
}

Expand Down
16 changes: 8 additions & 8 deletions network/mhfpacket/msg_mhf_enumerate_guild_item.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
package mhfpacket

import (
"errors"
"errors"

"erupe-ce/network/clientctx"
"erupe-ce/network"
"erupe-ce/common/byteframe"
"erupe-ce/network"
"erupe-ce/network/clientctx"
)

// MsgMhfEnumerateGuildItem represents the MSG_MHF_ENUMERATE_GUILD_ITEM
type MsgMhfEnumerateGuildItem struct {
AckHandle uint32
GuildId uint32
Unk0 uint16
GuildID uint32
}

// Opcode returns the ID associated with this packet type.
Expand All @@ -22,9 +21,10 @@ func (m *MsgMhfEnumerateGuildItem) Opcode() network.PacketID {

// Parse parses the packet from binary
func (m *MsgMhfEnumerateGuildItem) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
m.AckHandle = bf.ReadUint32()
m.GuildId = bf.ReadUint32()
m.Unk0 = bf.ReadUint16()
m.AckHandle = bf.ReadUint32()
m.GuildID = bf.ReadUint32()
bf.ReadUint8() // Zeroed
bf.ReadUint8() // Zeroed
return nil
}

Expand Down
Loading

0 comments on commit 85fc76e

Please sign in to comment.