From 172b5decf4a2136b737e9e202ed91bd38448868b Mon Sep 17 00:00:00 2001 From: Andrew Gutekanst Date: Sat, 22 Feb 2020 22:17:10 -0500 Subject: [PATCH] Implement multiple packet parsers --- network/mhfpacket/msg_mhf_get_seibattle.go | 19 +++++++++++++++--- .../msg_mhf_get_ud_bonus_quest_info.go | 9 ++++++--- network/mhfpacket/msg_mhf_post_boost_time.go | 9 +++++++-- .../msg_mhf_post_boost_time_quest_return.go | 9 ++++++--- .../msg_mhf_update_use_trend_weapon_log.go | 13 +++++++++--- network/mhfpacket/msg_sys_back_stage.go | 9 ++++++--- network/mhfpacket/msg_sys_record_log.go | 20 ++++++++++++++++--- 7 files changed, 68 insertions(+), 20 deletions(-) diff --git a/network/mhfpacket/msg_mhf_get_seibattle.go b/network/mhfpacket/msg_mhf_get_seibattle.go index f0ab6ca82..9c6efe62f 100644 --- a/network/mhfpacket/msg_mhf_get_seibattle.go +++ b/network/mhfpacket/msg_mhf_get_seibattle.go @@ -6,7 +6,14 @@ import ( ) // MsgMhfGetSeibattle represents the MSG_MHF_GET_SEIBATTLE -type MsgMhfGetSeibattle struct{} +type MsgMhfGetSeibattle struct { + AckHandle uint32 + Unk0 uint8 + Unk1 uint8 + Unk2 uint32 // Some shared ID with MSG_SYS_RECORD_LOG, world ID? + Unk3 uint8 + Unk4 uint16 +} // Opcode returns the ID associated with this packet type. func (m *MsgMhfGetSeibattle) Opcode() network.PacketID { @@ -15,10 +22,16 @@ func (m *MsgMhfGetSeibattle) Opcode() network.PacketID { // Parse parses the packet from binary func (m *MsgMhfGetSeibattle) Parse(bf *byteframe.ByteFrame) error { - panic("Not implemented") + m.AckHandle = bf.ReadUint32() + m.Unk0 = bf.ReadUint8() + m.Unk1 = bf.ReadUint8() + m.Unk2 = bf.ReadUint32() + m.Unk3 = bf.ReadUint8() + m.Unk4 = bf.ReadUint16() + return nil } // Build builds a binary packet from the current data. func (m *MsgMhfGetSeibattle) Build(bf *byteframe.ByteFrame) error { panic("Not implemented") -} \ No newline at end of file +} diff --git a/network/mhfpacket/msg_mhf_get_ud_bonus_quest_info.go b/network/mhfpacket/msg_mhf_get_ud_bonus_quest_info.go index 3f77e96ae..35f586522 100644 --- a/network/mhfpacket/msg_mhf_get_ud_bonus_quest_info.go +++ b/network/mhfpacket/msg_mhf_get_ud_bonus_quest_info.go @@ -6,7 +6,9 @@ import ( ) // MsgMhfGetUdBonusQuestInfo represents the MSG_MHF_GET_UD_BONUS_QUEST_INFO -type MsgMhfGetUdBonusQuestInfo struct{} +type MsgMhfGetUdBonusQuestInfo struct { + AckHandle uint32 +} // Opcode returns the ID associated with this packet type. func (m *MsgMhfGetUdBonusQuestInfo) Opcode() network.PacketID { @@ -15,10 +17,11 @@ func (m *MsgMhfGetUdBonusQuestInfo) Opcode() network.PacketID { // Parse parses the packet from binary func (m *MsgMhfGetUdBonusQuestInfo) Parse(bf *byteframe.ByteFrame) error { - panic("Not implemented") + m.AckHandle = bf.ReadUint32() + return nil } // Build builds a binary packet from the current data. func (m *MsgMhfGetUdBonusQuestInfo) Build(bf *byteframe.ByteFrame) error { panic("Not implemented") -} \ No newline at end of file +} diff --git a/network/mhfpacket/msg_mhf_post_boost_time.go b/network/mhfpacket/msg_mhf_post_boost_time.go index 82ad78f7d..ad298c5e2 100644 --- a/network/mhfpacket/msg_mhf_post_boost_time.go +++ b/network/mhfpacket/msg_mhf_post_boost_time.go @@ -6,7 +6,10 @@ import ( ) // MsgMhfPostBoostTime represents the MSG_MHF_POST_BOOST_TIME -type MsgMhfPostBoostTime struct{} +type MsgMhfPostBoostTime struct{ + AckHandle uint32 + BoostTime uint32 +} // Opcode returns the ID associated with this packet type. func (m *MsgMhfPostBoostTime) Opcode() network.PacketID { @@ -15,7 +18,9 @@ func (m *MsgMhfPostBoostTime) Opcode() network.PacketID { // Parse parses the packet from binary func (m *MsgMhfPostBoostTime) Parse(bf *byteframe.ByteFrame) error { - panic("Not implemented") + m.AckHandle = bf.ReadUint32() + m.BoostTime = bf.ReadUint32() + return nil } // Build builds a binary packet from the current data. diff --git a/network/mhfpacket/msg_mhf_post_boost_time_quest_return.go b/network/mhfpacket/msg_mhf_post_boost_time_quest_return.go index 1cac00928..566caa60e 100644 --- a/network/mhfpacket/msg_mhf_post_boost_time_quest_return.go +++ b/network/mhfpacket/msg_mhf_post_boost_time_quest_return.go @@ -6,7 +6,9 @@ import ( ) // MsgMhfPostBoostTimeQuestReturn represents the MSG_MHF_POST_BOOST_TIME_QUEST_RETURN -type MsgMhfPostBoostTimeQuestReturn struct{} +type MsgMhfPostBoostTimeQuestReturn struct { + AckHandle uint32 +} // Opcode returns the ID associated with this packet type. func (m *MsgMhfPostBoostTimeQuestReturn) Opcode() network.PacketID { @@ -15,10 +17,11 @@ func (m *MsgMhfPostBoostTimeQuestReturn) Opcode() network.PacketID { // Parse parses the packet from binary func (m *MsgMhfPostBoostTimeQuestReturn) Parse(bf *byteframe.ByteFrame) error { - panic("Not implemented") + m.AckHandle = bf.ReadUint32() + return nil } // Build builds a binary packet from the current data. func (m *MsgMhfPostBoostTimeQuestReturn) Build(bf *byteframe.ByteFrame) error { panic("Not implemented") -} \ No newline at end of file +} diff --git a/network/mhfpacket/msg_mhf_update_use_trend_weapon_log.go b/network/mhfpacket/msg_mhf_update_use_trend_weapon_log.go index 35bc9d1ca..be42fa1ba 100644 --- a/network/mhfpacket/msg_mhf_update_use_trend_weapon_log.go +++ b/network/mhfpacket/msg_mhf_update_use_trend_weapon_log.go @@ -6,7 +6,11 @@ import ( ) // MsgMhfUpdateUseTrendWeaponLog represents the MSG_MHF_UPDATE_USE_TREND_WEAPON_LOG -type MsgMhfUpdateUseTrendWeaponLog struct{} +type MsgMhfUpdateUseTrendWeaponLog struct { + AckHandle uint32 + Unk0 uint8 + Unk1 uint16 // Weapon/item ID probably? +} // Opcode returns the ID associated with this packet type. func (m *MsgMhfUpdateUseTrendWeaponLog) Opcode() network.PacketID { @@ -15,10 +19,13 @@ func (m *MsgMhfUpdateUseTrendWeaponLog) Opcode() network.PacketID { // Parse parses the packet from binary func (m *MsgMhfUpdateUseTrendWeaponLog) Parse(bf *byteframe.ByteFrame) error { - panic("Not implemented") + m.AckHandle = bf.ReadUint32() + m.Unk0 = bf.ReadUint8() + m.Unk1 = bf.ReadUint16() + return nil } // Build builds a binary packet from the current data. func (m *MsgMhfUpdateUseTrendWeaponLog) Build(bf *byteframe.ByteFrame) error { panic("Not implemented") -} \ No newline at end of file +} diff --git a/network/mhfpacket/msg_sys_back_stage.go b/network/mhfpacket/msg_sys_back_stage.go index 3473f46da..1d435e7f6 100644 --- a/network/mhfpacket/msg_sys_back_stage.go +++ b/network/mhfpacket/msg_sys_back_stage.go @@ -6,7 +6,9 @@ import ( ) // MsgSysBackStage represents the MSG_SYS_BACK_STAGE -type MsgSysBackStage struct{} +type MsgSysBackStage struct { + AckHandle uint32 +} // Opcode returns the ID associated with this packet type. func (m *MsgSysBackStage) Opcode() network.PacketID { @@ -15,10 +17,11 @@ func (m *MsgSysBackStage) Opcode() network.PacketID { // Parse parses the packet from binary func (m *MsgSysBackStage) Parse(bf *byteframe.ByteFrame) error { - panic("Not implemented") + m.AckHandle = bf.ReadUint32() + return nil } // Build builds a binary packet from the current data. func (m *MsgSysBackStage) Build(bf *byteframe.ByteFrame) error { panic("Not implemented") -} \ No newline at end of file +} diff --git a/network/mhfpacket/msg_sys_record_log.go b/network/mhfpacket/msg_sys_record_log.go index 711a21d7d..2f72e30da 100644 --- a/network/mhfpacket/msg_sys_record_log.go +++ b/network/mhfpacket/msg_sys_record_log.go @@ -6,7 +6,14 @@ import ( ) // MsgSysRecordLog represents the MSG_SYS_RECORD_LOG -type MsgSysRecordLog struct{} +type MsgSysRecordLog struct { + AckHandle uint32 + Unk0 uint32 + Unk1 uint16 // Hardcoded 0 + HardcodedDataSize uint16 // Hardcoded 0x4AC + Unk3 uint32 // Some shared ID with MSG_MHF_GET_SEIBATTLE. World ID?? + DataBuf []byte +} // Opcode returns the ID associated with this packet type. func (m *MsgSysRecordLog) Opcode() network.PacketID { @@ -15,10 +22,17 @@ func (m *MsgSysRecordLog) Opcode() network.PacketID { // Parse parses the packet from binary func (m *MsgSysRecordLog) Parse(bf *byteframe.ByteFrame) error { - panic("Not implemented") + m.AckHandle = bf.ReadUint32() + m.Unk0 = bf.ReadUint32() + m.Unk1 = bf.ReadUint16() + m.HardcodedDataSize = bf.ReadUint16() + m.Unk3 = bf.ReadUint32() + m.DataBuf = bf.ReadBytes(uint(m.HardcodedDataSize)) + return nil + } // Build builds a binary packet from the current data. func (m *MsgSysRecordLog) Build(bf *byteframe.ByteFrame) error { panic("Not implemented") -} \ No newline at end of file +}