update parsing of many packets

This commit is contained in:
wish
2023-11-19 00:35:22 +11:00
parent 734b60bee1
commit fc57d63689
32 changed files with 146 additions and 171 deletions

View File

@@ -12,7 +12,7 @@ import (
type MsgMhfAcquireGuildTresure struct {
AckHandle uint32
HuntID uint32
Unk uint8
Unk bool
}
// Opcode returns the ID associated with this packet type.
@@ -24,7 +24,7 @@ func (m *MsgMhfAcquireGuildTresure) Opcode() network.PacketID {
func (m *MsgMhfAcquireGuildTresure) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
m.AckHandle = bf.ReadUint32()
m.HuntID = bf.ReadUint32()
m.Unk = bf.ReadUint8()
m.Unk = bf.ReadBool()
return nil
}

View File

@@ -11,9 +11,7 @@ import (
// MsgMhfAcquireTitle represents the MSG_MHF_ACQUIRE_TITLE
type MsgMhfAcquireTitle struct {
AckHandle uint32
Unk0 uint16
Unk1 uint16
TitleID uint16
TitleIDs []uint16
}
// Opcode returns the ID associated with this packet type.
@@ -24,9 +22,11 @@ func (m *MsgMhfAcquireTitle) Opcode() network.PacketID {
// Parse parses the packet from binary
func (m *MsgMhfAcquireTitle) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
m.AckHandle = bf.ReadUint32()
m.Unk0 = bf.ReadUint16()
m.Unk1 = bf.ReadUint16()
m.TitleID = bf.ReadUint16()
titles := int(bf.ReadUint16())
bf.ReadUint16() // Zeroed
for i := 0; i < titles; i++ {
m.TitleIDs = append(m.TitleIDs, bf.ReadUint16())
}
return nil
}

View File

@@ -1,9 +1,10 @@
package mhfpacket
import (
"errors"
"erupe-ce/common/byteframe"
"erupe-ce/network"
"erupe-ce/network/clientctx"
"erupe-ce/common/byteframe"
)
// MsgMhfCheckDailyCafepoint represents the MSG_MHF_CHECK_DAILY_CAFEPOINT
@@ -25,7 +26,5 @@ func (m *MsgMhfCheckDailyCafepoint) Parse(bf *byteframe.ByteFrame, ctx *clientct
}
func (m *MsgMhfCheckDailyCafepoint) Build(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
bf.WriteUint32(m.AckHandle)
bf.WriteUint32(m.Unk)
return nil
return errors.New("NOT IMPLEMENTED")
}

View File

@@ -12,7 +12,6 @@ import (
type MsgMhfCheckMonthlyItem struct {
AckHandle uint32
Type uint8
Unk []byte
}
// Opcode returns the ID associated with this packet type.
@@ -24,7 +23,9 @@ func (m *MsgMhfCheckMonthlyItem) Opcode() network.PacketID {
func (m *MsgMhfCheckMonthlyItem) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
m.AckHandle = bf.ReadUint32()
m.Type = bf.ReadUint8()
m.Unk = bf.ReadBytes(3)
bf.ReadUint8() // Zeroed
bf.ReadUint8() // Zeroed
bf.ReadUint8() // Zeroed
return nil
}

View File

@@ -12,7 +12,6 @@ type MsgMhfCheckWeeklyStamp struct {
AckHandle uint32
StampType string
Unk1 bool
Unk2 uint16 // Hardcoded 0 in the binary
}
// Opcode returns the ID associated with this packet type.
@@ -31,7 +30,7 @@ func (m *MsgMhfCheckWeeklyStamp) Parse(bf *byteframe.ByteFrame, ctx *clientctx.C
m.StampType = "ex"
}
m.Unk1 = bf.ReadBool()
m.Unk2 = bf.ReadUint16()
bf.ReadUint16() // Zeroed
return nil
}

View File

@@ -12,8 +12,6 @@ import (
// MsgMhfCreateGuild represents the MSG_MHF_CREATE_GUILD
type MsgMhfCreateGuild struct {
AckHandle uint32
Unk0 uint8
Unk1 uint8
Name string
}
@@ -25,9 +23,8 @@ func (m *MsgMhfCreateGuild) Opcode() network.PacketID {
// Parse parses the packet from binary
func (m *MsgMhfCreateGuild) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
m.AckHandle = bf.ReadUint32()
m.Unk0 = bf.ReadUint8()
m.Unk1 = bf.ReadUint8()
_ = bf.ReadUint16() // len
bf.ReadUint16() // Zeroed
bf.ReadUint16() // Name length
m.Name = stringsupport.SJISToUTF8(bf.ReadNullTerminatedBytes())
return nil
}

View File

@@ -1,15 +1,14 @@
package mhfpacket
import (
"errors"
"erupe-ce/common/byteframe"
"erupe-ce/network"
"erupe-ce/network/clientctx"
"erupe-ce/common/byteframe"
)
// MsgMhfDisplayedAchievement represents the MSG_MHF_DISPLAYED_ACHIEVEMENT
type MsgMhfDisplayedAchievement struct {
Unk0 uint8
}
type MsgMhfDisplayedAchievement struct{}
// Opcode returns the ID associated with this packet type.
func (m *MsgMhfDisplayedAchievement) Opcode() network.PacketID {
@@ -18,12 +17,11 @@ func (m *MsgMhfDisplayedAchievement) Opcode() network.PacketID {
// Parse parses the packet from binary
func (m *MsgMhfDisplayedAchievement) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
m.Unk0 = bf.ReadUint8()
bf.ReadUint8() // Zeroed
return nil
}
// Build builds a binary packet from the current data.
func (m *MsgMhfDisplayedAchievement) Build(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
bf.WriteUint8(m.Unk0)
return nil
return errors.New("NOT IMPLEMENTED")
}

View File

@@ -1,16 +1,15 @@
package mhfpacket
import (
"errors"
"erupe-ce/common/byteframe"
"erupe-ce/network"
"erupe-ce/network/clientctx"
"erupe-ce/common/byteframe"
)
// MsgMhfEnumerateEvent represents the MSG_MHF_ENUMERATE_EVENT
type MsgMhfEnumerateEvent struct {
AckHandle uint32
Unk0 uint16 // Hardcoded 0 in the binary
Unk1 uint16 // Hardcoded 0 in the binary
}
// Opcode returns the ID associated with this packet type.
@@ -21,15 +20,12 @@ func (m *MsgMhfEnumerateEvent) Opcode() network.PacketID {
// Parse parses the packet from binary
func (m *MsgMhfEnumerateEvent) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
m.AckHandle = bf.ReadUint32()
m.Unk0 = bf.ReadUint16()
m.Unk1 = bf.ReadUint16()
bf.ReadUint16() // Zeroed
bf.ReadUint16() // Zeroed
return nil
}
// Build builds a binary packet from the current data.
func (m *MsgMhfEnumerateEvent) Build(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
bf.WriteUint32(m.AckHandle)
bf.WriteUint16(m.Unk0)
bf.WriteUint16(m.Unk1)
return nil
return errors.New("NOT IMPLEMENTED")
}

View File

@@ -1,18 +1,16 @@
package mhfpacket
import (
"errors"
"errors"
"erupe-ce/network/clientctx"
"erupe-ce/network"
"erupe-ce/common/byteframe"
"erupe-ce/network"
"erupe-ce/network/clientctx"
)
// MsgMhfEnumeratePrice represents the MSG_MHF_ENUMERATE_PRICE
type MsgMhfEnumeratePrice struct {
AckHandle uint32
Unk0 uint16 // Hardcoded 0 in the binary
Unk1 uint16 // Hardcoded 0 in the binary
}
// Opcode returns the ID associated with this packet type.
@@ -23,8 +21,8 @@ func (m *MsgMhfEnumeratePrice) Opcode() network.PacketID {
// Parse parses the packet from binary
func (m *MsgMhfEnumeratePrice) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
m.AckHandle = bf.ReadUint32()
m.Unk0 = bf.ReadUint16()
m.Unk1 = bf.ReadUint16()
bf.ReadUint16() // Zeroed
bf.ReadUint16() // Zeroed
return nil
}

View File

@@ -1,18 +1,16 @@
package mhfpacket
import (
"errors"
"errors"
"erupe-ce/network/clientctx"
"erupe-ce/network"
"erupe-ce/common/byteframe"
"erupe-ce/network"
"erupe-ce/network/clientctx"
)
// MsgMhfEnumerateRanking represents the MSG_MHF_ENUMERATE_RANKING
type MsgMhfEnumerateRanking struct {
AckHandle uint32
Unk0 uint16 // Hardcoded 0 in the binary
Unk1 uint16 // Hardcoded 0 in the binary
}
// Opcode returns the ID associated with this packet type.
@@ -23,8 +21,9 @@ func (m *MsgMhfEnumerateRanking) Opcode() network.PacketID {
// Parse parses the packet from binary
func (m *MsgMhfEnumerateRanking) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
m.AckHandle = bf.ReadUint32()
m.Unk0 = bf.ReadUint16()
m.Unk1 = bf.ReadUint16()
bf.ReadUint16() // Zeroed
bf.ReadUint8() // Zeroed
bf.ReadUint8() // Zeroed
return nil
}

View File

@@ -11,7 +11,6 @@ import (
// MsgMhfEnumerateUnionItem represents the MSG_MHF_ENUMERATE_UNION_ITEM
type MsgMhfEnumerateUnionItem struct {
AckHandle uint32
Unk0 uint16
}
// Opcode returns the ID associated with this packet type.
@@ -22,8 +21,8 @@ func (m *MsgMhfEnumerateUnionItem) Opcode() network.PacketID {
// Parse parses the packet from binary
func (m *MsgMhfEnumerateUnionItem) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
m.AckHandle = bf.ReadUint32()
m.Unk0 = bf.ReadUint16()
bf.ReadUint8() // Zeroed
bf.ReadUint8() // Zeroed
return nil
}

View File

@@ -12,7 +12,6 @@ import (
type MsgMhfGetAchievement struct {
AckHandle uint32
CharID uint32
Unk1 uint32 // char?
}
// Opcode returns the ID associated with this packet type.
@@ -24,7 +23,7 @@ func (m *MsgMhfGetAchievement) Opcode() network.PacketID {
func (m *MsgMhfGetAchievement) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
m.AckHandle = bf.ReadUint32()
m.CharID = bf.ReadUint32()
m.Unk1 = bf.ReadUint32()
bf.ReadUint32() // Zeroed
return nil
}

View File

@@ -1,17 +1,16 @@
package mhfpacket
import (
"errors"
"errors"
"erupe-ce/network/clientctx"
"erupe-ce/network"
"erupe-ce/common/byteframe"
"erupe-ce/network"
"erupe-ce/network/clientctx"
)
// MsgMhfGetRengokuBinary represents the MSG_MHF_GET_RENGOKU_BINARY
type MsgMhfGetRengokuBinary struct {
AckHandle uint32
Unk0 uint8 // Hardcoded 0 in binary
}
// Opcode returns the ID associated with this packet type.
@@ -22,7 +21,7 @@ func (m *MsgMhfGetRengokuBinary) Opcode() network.PacketID {
// Parse parses the packet from binary
func (m *MsgMhfGetRengokuBinary) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
m.AckHandle = bf.ReadUint32()
m.Unk0 = bf.ReadUint8()
bf.ReadUint8() // Zeroed
return nil
}

View File

@@ -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"
)
// MsgMhfInfoFesta represents the MSG_MHF_INFO_FESTA
type MsgMhfInfoFesta struct {
AckHandle uint32
Unk0 uint16 // Hardcoded 0 in the binary
Unk1 uint16 // Hardcoded 0 in the binary
Unk0 uint8
}
// Opcode returns the ID associated with this packet type.
@@ -23,8 +22,10 @@ func (m *MsgMhfInfoFesta) Opcode() network.PacketID {
// Parse parses the packet from binary
func (m *MsgMhfInfoFesta) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
m.AckHandle = bf.ReadUint32()
m.Unk0 = bf.ReadUint16()
m.Unk1 = bf.ReadUint16()
m.Unk0 = bf.ReadUint8()
bf.ReadUint8() // Zeroed
bf.ReadUint8() // Zeroed
bf.ReadUint8() // Zeroed
return nil
}

View File

@@ -1,17 +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"
)
// MsgMhfListMember represents the MSG_MHF_LIST_MEMBER
type MsgMhfListMember struct {
AckHandle uint32
Unk0 uint16 // Hardcoded 01 00 in the JP client.
Unk0 uint8 // Hardcoded 01 in the JP client.
}
// Opcode returns the ID associated with this packet type.
@@ -22,7 +22,8 @@ func (m *MsgMhfListMember) Opcode() network.PacketID {
// Parse parses the packet from binary
func (m *MsgMhfListMember) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
m.AckHandle = bf.ReadUint32()
m.Unk0 = bf.ReadUint16()
m.Unk0 = bf.ReadUint8()
bf.ReadUint8() // Zeroed
return nil
}

View File

@@ -19,7 +19,6 @@ type MsgMhfReadMail struct {
// This is the index within the current mail list
Index uint8
Unk0 uint16
}
// Opcode returns the ID associated with this packet type.
@@ -32,7 +31,7 @@ func (m *MsgMhfReadMail) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientCon
m.AckHandle = bf.ReadUint32()
m.AccIndex = bf.ReadUint8()
m.Index = bf.ReadUint8()
m.Unk0 = bf.ReadUint16()
bf.ReadUint16() // Zeroed
return nil
}

View File

@@ -12,7 +12,6 @@ import (
type MsgMhfReleaseEvent struct {
AckHandle uint32
RaviID uint32
Unk1 uint32
}
// Opcode returns the ID associated with this packet type.
@@ -24,7 +23,7 @@ func (m *MsgMhfReleaseEvent) Opcode() network.PacketID {
func (m *MsgMhfReleaseEvent) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
m.AckHandle = bf.ReadUint32()
m.RaviID = bf.ReadUint32()
m.Unk1 = bf.ReadUint32()
bf.ReadUint32() // Zeroed
return nil
}

View File

@@ -1,18 +1,16 @@
package mhfpacket
import (
"errors"
"errors"
"erupe-ce/network/clientctx"
"erupe-ce/network"
"erupe-ce/common/byteframe"
"erupe-ce/network"
"erupe-ce/network/clientctx"
)
// MsgMhfUpdateCafepoint represents the MSG_MHF_UPDATE_CAFEPOINT
type MsgMhfUpdateCafepoint struct {
AckHandle uint32
Unk0 uint16 // Hardcoded 0 in binary
Unk1 uint16 // Hardcoded 0 in binary
}
// Opcode returns the ID associated with this packet type.
@@ -23,8 +21,8 @@ func (m *MsgMhfUpdateCafepoint) Opcode() network.PacketID {
// Parse parses the packet from binary
func (m *MsgMhfUpdateCafepoint) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
m.AckHandle = bf.ReadUint32()
m.Unk0 = bf.ReadUint16()
m.Unk1 = bf.ReadUint16()
bf.ReadUint16() // Zeroed
bf.ReadUint16() // Zeroed
return nil
}

View File

@@ -30,7 +30,7 @@ func (m *MsgMhfUpdateGuacot) Opcode() network.PacketID {
func (m *MsgMhfUpdateGuacot) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
m.AckHandle = bf.ReadUint32()
m.EntryCount = bf.ReadUint16()
_ = bf.ReadUint16() // Zero
bf.ReadUint16() // Zeroed
var temp Goocoo
for i := 0; i < int(m.EntryCount); i++ {
temp.Index = bf.ReadUint32()

View File

@@ -25,8 +25,6 @@ type GuildIconMsgPart struct {
type MsgMhfUpdateGuildIcon struct {
AckHandle uint32
GuildID uint32
PartCount uint16
Unk1 uint16
IconParts []GuildIconMsgPart
}
@@ -39,12 +37,12 @@ func (m *MsgMhfUpdateGuildIcon) Opcode() network.PacketID {
func (m *MsgMhfUpdateGuildIcon) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
m.AckHandle = bf.ReadUint32()
m.GuildID = bf.ReadUint32()
m.PartCount = bf.ReadUint16()
m.Unk1 = bf.ReadUint16()
partCount := int(bf.ReadUint16())
bf.ReadUint8() // Zeroed
bf.ReadUint8() // Zeroed
m.IconParts = make([]GuildIconMsgPart, partCount)
m.IconParts = make([]GuildIconMsgPart, m.PartCount)
for i := 0; i < int(m.PartCount); i++ {
for i := 0; i < partCount; i++ {
m.IconParts[i] = GuildIconMsgPart{
Index: bf.ReadUint16(),
ID: bf.ReadUint16(),

View File

@@ -10,7 +10,7 @@ import (
type Item struct {
Unk0 uint32
ItemId uint16
ItemID uint16
Amount uint16
Unk1 uint32
}
@@ -19,9 +19,7 @@ type Item struct {
type MsgMhfUpdateGuildItem struct {
AckHandle uint32
GuildId uint32
Amount uint16
Unk1 uint16 // 0x00 0x00
Items []Item // Array of updated item IDs
Items []Item
}
// Opcode returns the ID associated with this packet type.
@@ -33,13 +31,14 @@ 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()
m.Amount = bf.ReadUint16()
m.Unk1 = bf.ReadUint16()
m.Items = make([]Item, int(m.Amount))
itemCount := int(bf.ReadUint16())
bf.ReadUint8() // Zeroed
bf.ReadUint8() // Zeroed
m.Items = make([]Item, itemCount)
for i := 0; i < int(m.Amount); i++ {
for i := 0; i < itemCount; i++ {
m.Items[i].Unk0 = bf.ReadUint32()
m.Items[i].ItemId = bf.ReadUint16()
m.Items[i].ItemID = bf.ReadUint16()
m.Items[i].Amount = bf.ReadUint16()
m.Items[i].Unk1 = bf.ReadUint32()
}

View File

@@ -13,8 +13,7 @@ import (
type MsgMhfUpdateHouse struct {
AckHandle uint32
State uint8
Unk1 uint8 // Always 0x01
Unk2 uint16 // Always 0x0000
Unk1 uint8 // Always 0x01
Password string
}
@@ -28,8 +27,9 @@ func (m *MsgMhfUpdateHouse) Parse(bf *byteframe.ByteFrame, ctx *clientctx.Client
m.AckHandle = bf.ReadUint32()
m.State = bf.ReadUint8()
m.Unk1 = bf.ReadUint8()
m.Unk2 = bf.ReadUint16()
_ = bf.ReadUint8() // Password length
bf.ReadUint8() // Zeroed
bf.ReadUint8() // Zeroed
bf.ReadUint8() // Password length
m.Password = stringsupport.SJISToUTF8(bf.ReadNullTerminatedBytes())
return nil
}

View File

@@ -11,9 +11,7 @@ import (
// MsgMhfUpdateUnionItem represents the MSG_MHF_UPDATE_UNION_ITEM
type MsgMhfUpdateUnionItem struct {
AckHandle uint32
Amount uint16
Unk1 uint16 // 0x00 0x00
Items []Item // Array of updated item IDs
Items []Item
}
// Opcode returns the ID associated with this packet type.
@@ -24,13 +22,14 @@ 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()
m.Amount = bf.ReadUint16()
m.Unk1 = bf.ReadUint16()
m.Items = make([]Item, int(m.Amount))
itemCount := int(bf.ReadUint16())
bf.ReadUint8() // Zeroed
bf.ReadUint8() // Zeroed
m.Items = make([]Item, itemCount)
for i := 0; i < int(m.Amount); i++ {
for i := 0; i < itemCount; i++ {
m.Items[i].Unk0 = bf.ReadUint32()
m.Items[i].ItemId = bf.ReadUint16()
m.Items[i].ItemID = bf.ReadUint16()
m.Items[i].Amount = bf.ReadUint16()
m.Items[i].Unk1 = bf.ReadUint32()
}

View File

@@ -4,9 +4,9 @@ import (
"errors"
"erupe-ce/common/bfutil"
"erupe-ce/common/byteframe"
"erupe-ce/network"
"erupe-ce/network/clientctx"
"erupe-ce/common/byteframe"
)
type scenarioFileIdentifer struct {

View File

@@ -1,18 +1,16 @@
package mhfpacket
import (
"errors"
"errors"
"erupe-ce/network/clientctx"
"erupe-ce/network"
"erupe-ce/common/byteframe"
"erupe-ce/network"
"erupe-ce/network/clientctx"
)
// MsgSysHideClient represents the MSG_SYS_HIDE_CLIENT
type MsgSysHideClient struct {
Hide bool
Unk0 uint16 // Hardcoded 0 in binary
Unk1 uint8 // Hardcoded 0 in binary
}
// Opcode returns the ID associated with this packet type.
@@ -23,8 +21,9 @@ func (m *MsgSysHideClient) Opcode() network.PacketID {
// Parse parses the packet from binary
func (m *MsgSysHideClient) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
m.Hide = bf.ReadBool()
m.Unk0 = bf.ReadUint16()
m.Unk1 = bf.ReadUint8()
bf.ReadUint8() // Zeroed
bf.ReadUint8() // Zeroed
bf.ReadUint8() // Zeroed
return nil
}

View File

@@ -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"
)
// MsgSysIssueLogkey represents the MSG_SYS_ISSUE_LOGKEY
type MsgSysIssueLogkey struct {
AckHandle uint32
Unk0 uint16 // Hardcoded 00 01 in binary
Unk1 uint16 // Hardcoded 0 in binary.
Unk0 uint16
}
// Opcode returns the ID associated with this packet type.
@@ -24,7 +23,7 @@ func (m *MsgSysIssueLogkey) Opcode() network.PacketID {
func (m *MsgSysIssueLogkey) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
m.AckHandle = bf.ReadUint32()
m.Unk0 = bf.ReadUint16()
m.Unk1 = bf.ReadUint16()
bf.ReadUint16() // Zeroed
return nil
}

View File

@@ -1,17 +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"
)
// MsgSysRightsReload represents the MSG_SYS_RIGHTS_RELOAD
type MsgSysRightsReload struct{
type MsgSysRightsReload struct {
AckHandle uint32
Unk0 byte
Unk0 []byte
}
// Opcode returns the ID associated with this packet type.
@@ -22,7 +22,7 @@ func (m *MsgSysRightsReload) Opcode() network.PacketID {
// Parse parses the packet from binary
func (m *MsgSysRightsReload) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
m.AckHandle = bf.ReadUint32()
m.Unk0 = bf.ReadUint8()
m.Unk0 = bf.ReadBytes(uint(bf.ReadUint8()))
return nil
}

View File

@@ -1,17 +1,16 @@
package mhfpacket
import (
"errors"
"errors"
"erupe-ce/network/clientctx"
"erupe-ce/network"
"erupe-ce/common/byteframe"
"erupe-ce/network"
"erupe-ce/network/clientctx"
)
// MsgSysSetStagePass represents the MSG_SYS_SET_STAGE_PASS
type MsgSysSetStagePass struct {
Unk0 uint8 // Hardcoded 0 in the binary
Password string // NULL-terminated string
Password string // NULL-terminated string
}
// Opcode returns the ID associated with this packet type.
@@ -21,8 +20,8 @@ func (m *MsgSysSetStagePass) Opcode() network.PacketID {
// Parse parses the packet from binary
func (m *MsgSysSetStagePass) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
m.Unk0 = bf.ReadUint8()
_ = bf.ReadUint8() // Password length
bf.ReadUint8() // Zeroed
bf.ReadUint8() // Password length
m.Password = string(bf.ReadNullTerminatedBytes())
return nil
}

View File

@@ -23,11 +23,9 @@ type TerminalLogEntry struct {
// MsgSysTerminalLog represents the MSG_SYS_TERMINAL_LOG
type MsgSysTerminalLog struct {
AckHandle uint32
LogID uint32 // 0 on the first packet, and the server sends back a value to use for subsequent requests.
EntryCount uint16
Unk0 uint16 // Hardcoded 0 in the binary
Entries []*TerminalLogEntry
AckHandle uint32
LogID uint32 // 0 on the first packet, and the server sends back a value to use for subsequent requests.
Entries []TerminalLogEntry
}
// Opcode returns the ID associated with this packet type.
@@ -39,11 +37,11 @@ func (m *MsgSysTerminalLog) Opcode() network.PacketID {
func (m *MsgSysTerminalLog) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
m.AckHandle = bf.ReadUint32()
m.LogID = bf.ReadUint32()
m.EntryCount = bf.ReadUint16()
m.Unk0 = bf.ReadUint16()
entryCount := int(bf.ReadUint16())
bf.ReadUint16() // Zeroed
for i := 0; i < int(m.EntryCount); i++ {
e := &TerminalLogEntry{}
var e TerminalLogEntry
for i := 0; i < entryCount; i++ {
e.Index = bf.ReadUint32()
e.Type1 = bf.ReadUint8()
e.Type2 = bf.ReadUint8()

View File

@@ -705,16 +705,16 @@ func handleMsgMhfUpdateUnionItem(s *Session, p mhfpacket.MHFPacket) {
// Update item stacks
newItems := make([]Item, len(oldItems))
copy(newItems, oldItems)
for i := 0; i < int(pkt.Amount); i++ {
for i := 0; i < len(pkt.Items); i++ {
for j := 0; j <= len(oldItems); j++ {
if j == len(oldItems) {
var newItem Item
newItem.ItemId = pkt.Items[i].ItemId
newItem.ItemId = pkt.Items[i].ItemID
newItem.Amount = pkt.Items[i].Amount
newItems = append(newItems, newItem)
break
}
if pkt.Items[i].ItemId == oldItems[j].ItemId {
if pkt.Items[i].ItemID == oldItems[j].ItemId {
newItems[j].Amount = pkt.Items[i].Amount
break
}

View File

@@ -1609,16 +1609,16 @@ func handleMsgMhfUpdateGuildItem(s *Session, p mhfpacket.MHFPacket) {
// Update item stacks
newItems := make([]Item, len(oldItems))
copy(newItems, oldItems)
for i := 0; i < int(pkt.Amount); i++ {
for i := 0; i < len(pkt.Items); i++ {
for j := 0; j <= len(oldItems); j++ {
if j == len(oldItems) {
var newItem Item
newItem.ItemId = pkt.Items[i].ItemId
newItem.ItemId = pkt.Items[i].ItemID
newItem.Amount = pkt.Items[i].Amount
newItems = append(newItems, newItem)
break
}
if pkt.Items[i].ItemId == oldItems[j].ItemId {
if pkt.Items[i].ItemID == oldItems[j].ItemId {
newItems[j].Amount = pkt.Items[i].Amount
break
}
@@ -1677,7 +1677,7 @@ func handleMsgMhfUpdateGuildIcon(s *Session, p mhfpacket.MHFPacket) {
icon := &GuildIcon{}
icon.Parts = make([]GuildIconPart, pkt.PartCount)
icon.Parts = make([]GuildIconPart, len(pkt.IconParts))
for i, p := range pkt.IconParts {
icon.Parts[i] = GuildIconPart{

View File

@@ -355,12 +355,14 @@ func handleMsgMhfEnumerateTitle(s *Session, p mhfpacket.MHFPacket) {
func handleMsgMhfAcquireTitle(s *Session, p mhfpacket.MHFPacket) {
pkt := p.(*mhfpacket.MsgMhfAcquireTitle)
var exists int
err := s.server.db.QueryRow(`SELECT count(*) FROM titles WHERE id=$1 AND char_id=$2`, pkt.TitleID, s.charID).Scan(&exists)
if err != nil || exists == 0 {
s.server.db.Exec(`INSERT INTO titles VALUES ($1, $2, now(), now())`, pkt.TitleID, s.charID)
} else {
s.server.db.Exec(`UPDATE titles SET updated_at=now() WHERE id=$1 AND char_id=$2`, pkt.TitleID, s.charID)
for _, title := range pkt.TitleIDs {
var exists int
err := s.server.db.QueryRow(`SELECT count(*) FROM titles WHERE id=$1 AND char_id=$2`, title, s.charID).Scan(&exists)
if err != nil || exists == 0 {
s.server.db.Exec(`INSERT INTO titles VALUES ($1, $2, now(), now())`, title, s.charID)
} else {
s.server.db.Exec(`UPDATE titles SET updated_at=now() WHERE id=$1 AND char_id=$2`, title, s.charID)
}
}
doAckSimpleSucceed(s, pkt.AckHandle, make([]byte, 4))
}