From 64344ee2ee37dcaf2019b09986bee0433fc55e40 Mon Sep 17 00:00:00 2001 From: wish Date: Sun, 28 May 2023 14:41:35 +1000 Subject: [PATCH] parse and stub various packets --- network/mhfpacket/msg_mhf_caravan_my_rank.go | 21 +++++-- network/mhfpacket/msg_mhf_caravan_my_score.go | 29 +++++++-- network/mhfpacket/msg_mhf_caravan_ranking.go | 21 +++++-- network/mhfpacket/msg_mhf_get_seibattle.go | 17 +++--- network/mhfpacket/msg_mhf_present_box.go | 8 +-- server/channelserver/handlers_caravan.go | 59 ++++++++++++++++++- server/channelserver/handlers_tower.go | 40 ++++++++++++- 7 files changed, 159 insertions(+), 36 deletions(-) diff --git a/network/mhfpacket/msg_mhf_caravan_my_rank.go b/network/mhfpacket/msg_mhf_caravan_my_rank.go index 3eb0074d4..d3e261caa 100644 --- a/network/mhfpacket/msg_mhf_caravan_my_rank.go +++ b/network/mhfpacket/msg_mhf_caravan_my_rank.go @@ -1,15 +1,20 @@ package mhfpacket -import ( - "errors" +import ( + "errors" - "erupe-ce/network/clientctx" - "erupe-ce/network" "erupe-ce/common/byteframe" + "erupe-ce/network" + "erupe-ce/network/clientctx" ) // MsgMhfCaravanMyRank represents the MSG_MHF_CARAVAN_MY_RANK -type MsgMhfCaravanMyRank struct{} +type MsgMhfCaravanMyRank struct { + AckHandle uint32 + Unk0 uint32 + Unk1 uint32 + Unk2 uint32 +} // Opcode returns the ID associated with this packet type. func (m *MsgMhfCaravanMyRank) Opcode() network.PacketID { @@ -18,7 +23,11 @@ func (m *MsgMhfCaravanMyRank) Opcode() network.PacketID { // Parse parses the packet from binary func (m *MsgMhfCaravanMyRank) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error { - return errors.New("NOT IMPLEMENTED") + m.AckHandle = bf.ReadUint32() + m.Unk0 = bf.ReadUint32() + m.Unk1 = bf.ReadUint32() + m.Unk2 = bf.ReadUint32() + return nil } // Build builds a binary packet from the current data. diff --git a/network/mhfpacket/msg_mhf_caravan_my_score.go b/network/mhfpacket/msg_mhf_caravan_my_score.go index bb83d0992..dfa2333b4 100644 --- a/network/mhfpacket/msg_mhf_caravan_my_score.go +++ b/network/mhfpacket/msg_mhf_caravan_my_score.go @@ -1,15 +1,24 @@ package mhfpacket -import ( - "errors" +import ( + "errors" - "erupe-ce/network/clientctx" - "erupe-ce/network" "erupe-ce/common/byteframe" + "erupe-ce/network" + "erupe-ce/network/clientctx" ) // MsgMhfCaravanMyScore represents the MSG_MHF_CARAVAN_MY_SCORE -type MsgMhfCaravanMyScore struct{} +type MsgMhfCaravanMyScore struct { + AckHandle uint32 + Unk0 uint32 + Unk1 uint32 + Unk2 int32 + Unk3 int32 + Unk4 uint32 + Unk5 int32 + Unk6 int32 +} // Opcode returns the ID associated with this packet type. func (m *MsgMhfCaravanMyScore) Opcode() network.PacketID { @@ -18,7 +27,15 @@ func (m *MsgMhfCaravanMyScore) Opcode() network.PacketID { // Parse parses the packet from binary func (m *MsgMhfCaravanMyScore) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error { - return errors.New("NOT IMPLEMENTED") + m.AckHandle = bf.ReadUint32() + m.Unk0 = bf.ReadUint32() + m.Unk1 = bf.ReadUint32() + m.Unk2 = bf.ReadInt32() + m.Unk3 = bf.ReadInt32() + m.Unk4 = bf.ReadUint32() + m.Unk5 = bf.ReadInt32() + m.Unk6 = bf.ReadInt32() + return nil } // Build builds a binary packet from the current data. diff --git a/network/mhfpacket/msg_mhf_caravan_ranking.go b/network/mhfpacket/msg_mhf_caravan_ranking.go index 7b5564bb6..1f86771af 100644 --- a/network/mhfpacket/msg_mhf_caravan_ranking.go +++ b/network/mhfpacket/msg_mhf_caravan_ranking.go @@ -1,15 +1,20 @@ package mhfpacket -import ( - "errors" +import ( + "errors" - "erupe-ce/network/clientctx" - "erupe-ce/network" "erupe-ce/common/byteframe" + "erupe-ce/network" + "erupe-ce/network/clientctx" ) // MsgMhfCaravanRanking represents the MSG_MHF_CARAVAN_RANKING -type MsgMhfCaravanRanking struct{} +type MsgMhfCaravanRanking struct { + AckHandle uint32 + Unk0 uint32 + Unk1 uint32 + Unk2 int32 +} // Opcode returns the ID associated with this packet type. func (m *MsgMhfCaravanRanking) Opcode() network.PacketID { @@ -18,7 +23,11 @@ func (m *MsgMhfCaravanRanking) Opcode() network.PacketID { // Parse parses the packet from binary func (m *MsgMhfCaravanRanking) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error { - return errors.New("NOT IMPLEMENTED") + m.AckHandle = bf.ReadUint32() + m.Unk0 = bf.ReadUint32() + m.Unk1 = bf.ReadUint32() + m.Unk2 = bf.ReadInt32() + return nil } // Build builds a binary packet from the current data. diff --git a/network/mhfpacket/msg_mhf_get_seibattle.go b/network/mhfpacket/msg_mhf_get_seibattle.go index 6a7a80380..1398b477d 100644 --- a/network/mhfpacket/msg_mhf_get_seibattle.go +++ b/network/mhfpacket/msg_mhf_get_seibattle.go @@ -1,20 +1,19 @@ package mhfpacket -import ( - "errors" +import ( + "errors" - "erupe-ce/network/clientctx" - "erupe-ce/network" "erupe-ce/common/byteframe" + "erupe-ce/network" + "erupe-ce/network/clientctx" ) // MsgMhfGetSeibattle represents the MSG_MHF_GET_SEIBATTLE type MsgMhfGetSeibattle struct { - // Communicator type, multi-format. This might be valid for only one type. AckHandle uint32 Unk0 uint8 - Unk1 uint8 - Unk2 uint32 // Some shared ID with MSG_SYS_RECORD_LOG, world ID? + Type uint8 + GuildID uint32 Unk3 uint8 Unk4 uint16 } @@ -28,8 +27,8 @@ func (m *MsgMhfGetSeibattle) Opcode() network.PacketID { func (m *MsgMhfGetSeibattle) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error { m.AckHandle = bf.ReadUint32() m.Unk0 = bf.ReadUint8() - m.Unk1 = bf.ReadUint8() - m.Unk2 = bf.ReadUint32() + m.Type = bf.ReadUint8() + m.GuildID = bf.ReadUint32() m.Unk3 = bf.ReadUint8() m.Unk4 = bf.ReadUint16() return nil diff --git a/network/mhfpacket/msg_mhf_present_box.go b/network/mhfpacket/msg_mhf_present_box.go index c3da92e31..d0064799c 100644 --- a/network/mhfpacket/msg_mhf_present_box.go +++ b/network/mhfpacket/msg_mhf_present_box.go @@ -18,8 +18,7 @@ type MsgMhfPresentBox struct { Unk4 uint32 Unk5 uint32 Unk6 uint32 - Unk7 uint32 - Unk8 uint32 + Unk7 []uint32 } // Opcode returns the ID associated with this packet type. @@ -37,8 +36,9 @@ func (m *MsgMhfPresentBox) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientC m.Unk4 = bf.ReadUint32() m.Unk5 = bf.ReadUint32() m.Unk6 = bf.ReadUint32() - m.Unk7 = bf.ReadUint32() - m.Unk8 = bf.ReadUint32() + for i := uint32(0); i < m.Unk2; i++ { + m.Unk7 = append(m.Unk7, bf.ReadUint32()) + } return nil } diff --git a/server/channelserver/handlers_caravan.go b/server/channelserver/handlers_caravan.go index 86cf73249..87a45ce49 100644 --- a/server/channelserver/handlers_caravan.go +++ b/server/channelserver/handlers_caravan.go @@ -2,6 +2,7 @@ package channelserver import ( "encoding/hex" + "erupe-ce/common/byteframe" "erupe-ce/network/mhfpacket" ) @@ -31,8 +32,60 @@ func handleMsgMhfPostTinyBin(s *Session, p mhfpacket.MHFPacket) { doAckSimpleSucceed(s, pkt.AckHandle, make([]byte, 4)) } -func handleMsgMhfCaravanMyScore(s *Session, p mhfpacket.MHFPacket) {} +func handleMsgMhfCaravanMyScore(s *Session, p mhfpacket.MHFPacket) { + pkt := p.(*mhfpacket.MsgMhfCaravanMyScore) + bf := byteframe.NewByteFrame() + bf.WriteUint32(0) + bf.WriteUint32(0) + bf.WriteUint32(0) + bf.WriteUint32(0) // Entries -func handleMsgMhfCaravanRanking(s *Session, p mhfpacket.MHFPacket) {} + /* + bf.WriteInt32(0) + bf.WriteInt32(0) + bf.WriteUint32(0) + bf.WriteInt32(0) + bf.WriteInt32(0) + bf.WriteInt32(0) + */ -func handleMsgMhfCaravanMyRank(s *Session, p mhfpacket.MHFPacket) {} + doAckBufSucceed(s, pkt.AckHandle, bf.Data()) +} + +func handleMsgMhfCaravanRanking(s *Session, p mhfpacket.MHFPacket) { + pkt := p.(*mhfpacket.MsgMhfCaravanRanking) + bf := byteframe.NewByteFrame() + bf.WriteUint32(0) + bf.WriteUint32(0) + bf.WriteUint32(0) + bf.WriteUint32(0) // Entries + + /* RYOUDAN + bf.WriteInt32(1) + bf.WriteUint32(2) + bf.WriteBytes(stringsupport.PaddedString("Test", 26, true)) + */ + + /* PERSONAL + bf.WriteInt32(1) + bf.WriteBytes(stringsupport.PaddedString("Test", 14, true)) + */ + doAckBufSucceed(s, pkt.AckHandle, bf.Data()) +} + +func handleMsgMhfCaravanMyRank(s *Session, p mhfpacket.MHFPacket) { + pkt := p.(*mhfpacket.MsgMhfCaravanMyRank) + bf := byteframe.NewByteFrame() + bf.WriteUint32(0) + bf.WriteUint32(0) + bf.WriteUint32(0) + bf.WriteUint32(0) // Entries + + /* + bf.WriteInt32(0) + bf.WriteInt32(0) + bf.WriteInt32(0) + */ + + doAckBufSucceed(s, pkt.AckHandle, bf.Data()) +} diff --git a/server/channelserver/handlers_tower.go b/server/channelserver/handlers_tower.go index 0a2675812..b4525c93b 100644 --- a/server/channelserver/handlers_tower.go +++ b/server/channelserver/handlers_tower.go @@ -2,6 +2,7 @@ package channelserver import ( "encoding/hex" + "erupe-ce/common/byteframe" "erupe-ce/network/mhfpacket" ) @@ -86,12 +87,47 @@ func handleMsgMhfGetBreakSeibatuLevelReward(s *Session, p mhfpacket.MHFPacket) { func handleMsgMhfGetWeeklySeibatuRankingReward(s *Session, p mhfpacket.MHFPacket) { pkt := p.(*mhfpacket.MsgMhfGetWeeklySeibatuRankingReward) - doAckSimpleSucceed(s, pkt.AckHandle, make([]byte, 4)) + bf := byteframe.NewByteFrame() + bf.WriteUint32(0) + bf.WriteUint32(0) + bf.WriteUint32(0) + bf.WriteUint32(0) // Entries + + /* + bf.WriteInt32(0) + bf.WriteInt32(0) + bf.WriteUint32(0) + bf.WriteInt32(0) + bf.WriteInt32(0) + bf.WriteInt32(0) + */ + + doAckBufSucceed(s, pkt.AckHandle, bf.Data()) } func handleMsgMhfPresentBox(s *Session, p mhfpacket.MHFPacket) { pkt := p.(*mhfpacket.MsgMhfPresentBox) - doAckSimpleSucceed(s, pkt.AckHandle, make([]byte, 4)) + bf := byteframe.NewByteFrame() + bf.WriteUint32(0) + bf.WriteUint32(0) + bf.WriteUint32(0) + bf.WriteUint32(0) // Entries + + /* + bf.WriteUint32(0) + bf.WriteInt32(0) + bf.WriteInt32(0) + bf.WriteInt32(0) + bf.WriteInt32(0) + bf.WriteInt32(0) + bf.WriteInt32(0) + bf.WriteInt32(0) + bf.WriteInt32(0) + bf.WriteInt32(0) + bf.WriteInt32(0) + */ + + doAckBufSucceed(s, pkt.AckHandle, bf.Data()) } func handleMsgMhfGetGemInfo(s *Session, p mhfpacket.MHFPacket) {