From fc57d6368973574a5fb0b8dae14dedb9de874d84 Mon Sep 17 00:00:00 2001 From: wish Date: Sun, 19 Nov 2023 00:35:22 +1100 Subject: [PATCH] update parsing of many packets --- .../mhfpacket/msg_mhf_acquire_guild_tresure.go | 4 ++-- network/mhfpacket/msg_mhf_acquire_title.go | 12 ++++++------ .../mhfpacket/msg_mhf_check_daily_cafepoint.go | 7 +++---- network/mhfpacket/msg_mhf_check_monthly_item.go | 5 +++-- network/mhfpacket/msg_mhf_check_weekly_stamp.go | 3 +-- network/mhfpacket/msg_mhf_create_guild.go | 7 ++----- .../mhfpacket/msg_mhf_displayed_achievement.go | 12 +++++------- network/mhfpacket/msg_mhf_enumerate_event.go | 14 +++++--------- network/mhfpacket/msg_mhf_enumerate_price.go | 14 ++++++-------- network/mhfpacket/msg_mhf_enumerate_ranking.go | 15 +++++++-------- .../mhfpacket/msg_mhf_enumerate_union_item.go | 5 ++--- network/mhfpacket/msg_mhf_get_achievement.go | 3 +-- network/mhfpacket/msg_mhf_get_rengoku_binary.go | 11 +++++------ network/mhfpacket/msg_mhf_info_festa.go | 17 +++++++++-------- network/mhfpacket/msg_mhf_list_member.go | 13 +++++++------ network/mhfpacket/msg_mhf_read_mail.go | 3 +-- network/mhfpacket/msg_mhf_release_event.go | 3 +-- network/mhfpacket/msg_mhf_update_cafepoint.go | 14 ++++++-------- network/mhfpacket/msg_mhf_update_guacot.go | 2 +- network/mhfpacket/msg_mhf_update_guild_icon.go | 12 +++++------- network/mhfpacket/msg_mhf_update_guild_item.go | 17 ++++++++--------- network/mhfpacket/msg_mhf_update_house.go | 8 ++++---- network/mhfpacket/msg_mhf_update_union_item.go | 15 +++++++-------- network/mhfpacket/msg_sys_get_file.go | 2 +- network/mhfpacket/msg_sys_hide_client.go | 15 +++++++-------- network/mhfpacket/msg_sys_issue_logkey.go | 13 ++++++------- network/mhfpacket/msg_sys_rights_reload.go | 14 +++++++------- network/mhfpacket/msg_sys_set_stage_pass.go | 13 ++++++------- network/mhfpacket/msg_sys_terminal_log.go | 16 +++++++--------- server/channelserver/handlers.go | 6 +++--- server/channelserver/handlers_guild.go | 8 ++++---- server/channelserver/handlers_house.go | 14 ++++++++------ 32 files changed, 146 insertions(+), 171 deletions(-) diff --git a/network/mhfpacket/msg_mhf_acquire_guild_tresure.go b/network/mhfpacket/msg_mhf_acquire_guild_tresure.go index 775e98bf5..ac9feb557 100644 --- a/network/mhfpacket/msg_mhf_acquire_guild_tresure.go +++ b/network/mhfpacket/msg_mhf_acquire_guild_tresure.go @@ -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 } diff --git a/network/mhfpacket/msg_mhf_acquire_title.go b/network/mhfpacket/msg_mhf_acquire_title.go index fe3a5ca95..9b9dd84dc 100644 --- a/network/mhfpacket/msg_mhf_acquire_title.go +++ b/network/mhfpacket/msg_mhf_acquire_title.go @@ -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 } diff --git a/network/mhfpacket/msg_mhf_check_daily_cafepoint.go b/network/mhfpacket/msg_mhf_check_daily_cafepoint.go index 6e4c26b97..fee1ec222 100644 --- a/network/mhfpacket/msg_mhf_check_daily_cafepoint.go +++ b/network/mhfpacket/msg_mhf_check_daily_cafepoint.go @@ -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") } diff --git a/network/mhfpacket/msg_mhf_check_monthly_item.go b/network/mhfpacket/msg_mhf_check_monthly_item.go index 860725aa4..257e0f855 100644 --- a/network/mhfpacket/msg_mhf_check_monthly_item.go +++ b/network/mhfpacket/msg_mhf_check_monthly_item.go @@ -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 } diff --git a/network/mhfpacket/msg_mhf_check_weekly_stamp.go b/network/mhfpacket/msg_mhf_check_weekly_stamp.go index f03b1d1e7..069a17456 100644 --- a/network/mhfpacket/msg_mhf_check_weekly_stamp.go +++ b/network/mhfpacket/msg_mhf_check_weekly_stamp.go @@ -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 } diff --git a/network/mhfpacket/msg_mhf_create_guild.go b/network/mhfpacket/msg_mhf_create_guild.go index e37267885..e82f7157e 100644 --- a/network/mhfpacket/msg_mhf_create_guild.go +++ b/network/mhfpacket/msg_mhf_create_guild.go @@ -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 } diff --git a/network/mhfpacket/msg_mhf_displayed_achievement.go b/network/mhfpacket/msg_mhf_displayed_achievement.go index 03de31f39..2633c081e 100644 --- a/network/mhfpacket/msg_mhf_displayed_achievement.go +++ b/network/mhfpacket/msg_mhf_displayed_achievement.go @@ -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") } diff --git a/network/mhfpacket/msg_mhf_enumerate_event.go b/network/mhfpacket/msg_mhf_enumerate_event.go index d73f92cdc..6a863f92f 100644 --- a/network/mhfpacket/msg_mhf_enumerate_event.go +++ b/network/mhfpacket/msg_mhf_enumerate_event.go @@ -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") } diff --git a/network/mhfpacket/msg_mhf_enumerate_price.go b/network/mhfpacket/msg_mhf_enumerate_price.go index 5dcfa69f3..e36246364 100644 --- a/network/mhfpacket/msg_mhf_enumerate_price.go +++ b/network/mhfpacket/msg_mhf_enumerate_price.go @@ -1,18 +1,16 @@ package mhfpacket -import ( - "errors" +import ( + "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 } diff --git a/network/mhfpacket/msg_mhf_enumerate_ranking.go b/network/mhfpacket/msg_mhf_enumerate_ranking.go index 4baef5738..a891a0e12 100644 --- a/network/mhfpacket/msg_mhf_enumerate_ranking.go +++ b/network/mhfpacket/msg_mhf_enumerate_ranking.go @@ -1,18 +1,16 @@ package mhfpacket -import ( - "errors" +import ( + "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 } diff --git a/network/mhfpacket/msg_mhf_enumerate_union_item.go b/network/mhfpacket/msg_mhf_enumerate_union_item.go index 780539b12..38ff89f5c 100644 --- a/network/mhfpacket/msg_mhf_enumerate_union_item.go +++ b/network/mhfpacket/msg_mhf_enumerate_union_item.go @@ -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 } diff --git a/network/mhfpacket/msg_mhf_get_achievement.go b/network/mhfpacket/msg_mhf_get_achievement.go index afa49d0d4..bca41bb7b 100644 --- a/network/mhfpacket/msg_mhf_get_achievement.go +++ b/network/mhfpacket/msg_mhf_get_achievement.go @@ -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 } diff --git a/network/mhfpacket/msg_mhf_get_rengoku_binary.go b/network/mhfpacket/msg_mhf_get_rengoku_binary.go index fc43a3718..f7dda97ad 100644 --- a/network/mhfpacket/msg_mhf_get_rengoku_binary.go +++ b/network/mhfpacket/msg_mhf_get_rengoku_binary.go @@ -1,17 +1,16 @@ package mhfpacket -import ( - "errors" +import ( + "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 } diff --git a/network/mhfpacket/msg_mhf_info_festa.go b/network/mhfpacket/msg_mhf_info_festa.go index 6926f0b8d..0877e6a4c 100644 --- a/network/mhfpacket/msg_mhf_info_festa.go +++ b/network/mhfpacket/msg_mhf_info_festa.go @@ -1,18 +1,17 @@ package mhfpacket -import ( - "errors" +import ( + "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 } diff --git a/network/mhfpacket/msg_mhf_list_member.go b/network/mhfpacket/msg_mhf_list_member.go index 0eaf4ca5f..bee4a4874 100644 --- a/network/mhfpacket/msg_mhf_list_member.go +++ b/network/mhfpacket/msg_mhf_list_member.go @@ -1,17 +1,17 @@ package mhfpacket -import ( - "errors" +import ( + "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 } diff --git a/network/mhfpacket/msg_mhf_read_mail.go b/network/mhfpacket/msg_mhf_read_mail.go index 1d2b03cf5..957f144f9 100644 --- a/network/mhfpacket/msg_mhf_read_mail.go +++ b/network/mhfpacket/msg_mhf_read_mail.go @@ -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 } diff --git a/network/mhfpacket/msg_mhf_release_event.go b/network/mhfpacket/msg_mhf_release_event.go index 52178279b..20ebcdba0 100644 --- a/network/mhfpacket/msg_mhf_release_event.go +++ b/network/mhfpacket/msg_mhf_release_event.go @@ -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 } diff --git a/network/mhfpacket/msg_mhf_update_cafepoint.go b/network/mhfpacket/msg_mhf_update_cafepoint.go index 671e893aa..aea9a43aa 100644 --- a/network/mhfpacket/msg_mhf_update_cafepoint.go +++ b/network/mhfpacket/msg_mhf_update_cafepoint.go @@ -1,18 +1,16 @@ package mhfpacket -import ( - "errors" +import ( + "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 } diff --git a/network/mhfpacket/msg_mhf_update_guacot.go b/network/mhfpacket/msg_mhf_update_guacot.go index 433854ae3..685f66f1b 100644 --- a/network/mhfpacket/msg_mhf_update_guacot.go +++ b/network/mhfpacket/msg_mhf_update_guacot.go @@ -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() diff --git a/network/mhfpacket/msg_mhf_update_guild_icon.go b/network/mhfpacket/msg_mhf_update_guild_icon.go index 6e3a780e5..248bb93ea 100644 --- a/network/mhfpacket/msg_mhf_update_guild_icon.go +++ b/network/mhfpacket/msg_mhf_update_guild_icon.go @@ -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(), diff --git a/network/mhfpacket/msg_mhf_update_guild_item.go b/network/mhfpacket/msg_mhf_update_guild_item.go index 3eb37a8cb..dbea591ea 100644 --- a/network/mhfpacket/msg_mhf_update_guild_item.go +++ b/network/mhfpacket/msg_mhf_update_guild_item.go @@ -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() } diff --git a/network/mhfpacket/msg_mhf_update_house.go b/network/mhfpacket/msg_mhf_update_house.go index 320972673..2c6f0401d 100644 --- a/network/mhfpacket/msg_mhf_update_house.go +++ b/network/mhfpacket/msg_mhf_update_house.go @@ -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 } diff --git a/network/mhfpacket/msg_mhf_update_union_item.go b/network/mhfpacket/msg_mhf_update_union_item.go index 5e4d83d24..68e8de365 100644 --- a/network/mhfpacket/msg_mhf_update_union_item.go +++ b/network/mhfpacket/msg_mhf_update_union_item.go @@ -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() } diff --git a/network/mhfpacket/msg_sys_get_file.go b/network/mhfpacket/msg_sys_get_file.go index 41b2a9029..99af6aa5e 100644 --- a/network/mhfpacket/msg_sys_get_file.go +++ b/network/mhfpacket/msg_sys_get_file.go @@ -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 { diff --git a/network/mhfpacket/msg_sys_hide_client.go b/network/mhfpacket/msg_sys_hide_client.go index e01c22cab..a2c714a41 100644 --- a/network/mhfpacket/msg_sys_hide_client.go +++ b/network/mhfpacket/msg_sys_hide_client.go @@ -1,18 +1,16 @@ package mhfpacket -import ( - "errors" +import ( + "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 } diff --git a/network/mhfpacket/msg_sys_issue_logkey.go b/network/mhfpacket/msg_sys_issue_logkey.go index a22956186..d5bb6522d 100644 --- a/network/mhfpacket/msg_sys_issue_logkey.go +++ b/network/mhfpacket/msg_sys_issue_logkey.go @@ -1,18 +1,17 @@ package mhfpacket -import ( - "errors" +import ( + "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 } diff --git a/network/mhfpacket/msg_sys_rights_reload.go b/network/mhfpacket/msg_sys_rights_reload.go index 7a8ac06e0..a70be8f38 100644 --- a/network/mhfpacket/msg_sys_rights_reload.go +++ b/network/mhfpacket/msg_sys_rights_reload.go @@ -1,17 +1,17 @@ package mhfpacket -import ( - "errors" +import ( + "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 } diff --git a/network/mhfpacket/msg_sys_set_stage_pass.go b/network/mhfpacket/msg_sys_set_stage_pass.go index 5cdbb2b88..1461241b0 100644 --- a/network/mhfpacket/msg_sys_set_stage_pass.go +++ b/network/mhfpacket/msg_sys_set_stage_pass.go @@ -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 } diff --git a/network/mhfpacket/msg_sys_terminal_log.go b/network/mhfpacket/msg_sys_terminal_log.go index bc8f3f7c5..5033346b4 100644 --- a/network/mhfpacket/msg_sys_terminal_log.go +++ b/network/mhfpacket/msg_sys_terminal_log.go @@ -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() diff --git a/server/channelserver/handlers.go b/server/channelserver/handlers.go index 211fcaf79..057881723 100644 --- a/server/channelserver/handlers.go +++ b/server/channelserver/handlers.go @@ -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 } diff --git a/server/channelserver/handlers_guild.go b/server/channelserver/handlers_guild.go index b8c7c04f6..cf190aa45 100644 --- a/server/channelserver/handlers_guild.go +++ b/server/channelserver/handlers_guild.go @@ -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{ diff --git a/server/channelserver/handlers_house.go b/server/channelserver/handlers_house.go index f764a8fa1..9dc51995d 100644 --- a/server/channelserver/handlers_house.go +++ b/server/channelserver/handlers_house.go @@ -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)) }