fix distitem description crashes

This commit is contained in:
wish
2022-07-16 09:46:26 +10:00
parent bb3d04009e
commit 310a27bc05
2 changed files with 13 additions and 13 deletions

View File

@@ -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
}

View File

@@ -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())
}