From 310a27bc053d1d47d334004792da591137bf2838 Mon Sep 17 00:00:00 2001 From: wish Date: Sat, 16 Jul 2022 09:46:26 +1000 Subject: [PATCH] fix distitem description crashes --- .../mhfpacket/msg_mhf_acquire_dist_item.go | 9 ++++----- Erupe/server/channelserver/handlers_distitem.go | 17 +++++++++-------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Erupe/network/mhfpacket/msg_mhf_acquire_dist_item.go b/Erupe/network/mhfpacket/msg_mhf_acquire_dist_item.go index a6178feb7..a11bf3ba4 100644 --- a/Erupe/network/mhfpacket/msg_mhf_acquire_dist_item.go +++ b/Erupe/network/mhfpacket/msg_mhf_acquire_dist_item.go @@ -11,9 +11,8 @@ import ( // MsgMhfAcquireDistItem represents the MSG_MHF_ACQUIRE_DIST_ITEM type MsgMhfAcquireDistItem struct { AckHandle uint32 - // Valid field size(s), not sure about the types. - Unk0 uint8 - Unk1 uint32 + DistributionType uint8 + DistributionID uint32 } // Opcode returns the ID associated with this packet type. @@ -24,8 +23,8 @@ func (m *MsgMhfAcquireDistItem) Opcode() network.PacketID { // Parse parses the packet from binary func (m *MsgMhfAcquireDistItem) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error { m.AckHandle = bf.ReadUint32() - m.Unk0 = bf.ReadUint8() - m.Unk1 = bf.ReadUint32() + m.DistributionType = bf.ReadUint8() + m.DistributionID = bf.ReadUint32() return nil } diff --git a/Erupe/server/channelserver/handlers_distitem.go b/Erupe/server/channelserver/handlers_distitem.go index 4563e7227..f278c1f16 100644 --- a/Erupe/server/channelserver/handlers_distitem.go +++ b/Erupe/server/channelserver/handlers_distitem.go @@ -1,8 +1,10 @@ package channelserver import ( + "time" + "erupe-ce/network/mhfpacket" - "erupe-ce/common/stringsupport" + ps "erupe-ce/common/pascalstring" "erupe-ce/common/byteframe" "go.uber.org/zap" ) @@ -68,14 +70,13 @@ func handleMsgMhfEnumerateDistItem(s *Session, p mhfpacket.MHFPacket) { bf.WriteUint16(distData.MaxGR) bf.WriteUint32(0) // Unk bf.WriteUint32(0) // Unk - eventName, _ := stringsupport.ConvertUTF8ToShiftJIS(distData.EventName) - bf.WriteUint16(uint16(len(eventName)+1)) - bf.WriteNullTerminatedBytes(eventName) + ps.Uint16(bf, distData.EventName, true) bf.WriteBytes(make([]byte, 391)) } resp := byteframe.NewByteFrame() resp.WriteUint16(uint16(distCount)) resp.WriteBytes(bf.Data()) + resp.WriteUint8(0) doAckBufSucceed(s, pkt.AckHandle, resp.Data()) } } @@ -96,8 +97,9 @@ func handleMsgMhfApplyDistItem(s *Session, p mhfpacket.MHFPacket) { } bf := byteframe.NewByteFrame() - bf.WriteUint32(0) + bf.WriteUint32(pkt.DistributionID) bf.WriteBytes(dist.Data) + bf.WriteUint32(uint32(time.Now().Unix())) doAckBufSucceed(s, pkt.AckHandle, bf.Data()) _, err = s.server.db.Exec(` @@ -125,8 +127,7 @@ func handleMsgMhfGetDistDescription(s *Session, p mhfpacket.MHFPacket) { return } bf := byteframe.NewByteFrame() - description, _ := stringsupport.ConvertUTF8ToShiftJIS(desc) - bf.WriteUint16(uint16(len(description)+1)) - bf.WriteNullTerminatedBytes(description) + ps.Uint16(bf, desc, true) + ps.Uint16(bf, "", false) doAckBufSucceed(s, pkt.AckHandle, bf.Data()) }