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 // MsgMhfAcquireDistItem represents the MSG_MHF_ACQUIRE_DIST_ITEM
type MsgMhfAcquireDistItem struct { type MsgMhfAcquireDistItem struct {
AckHandle uint32 AckHandle uint32
// Valid field size(s), not sure about the types. DistributionType uint8
Unk0 uint8 DistributionID uint32
Unk1 uint32
} }
// Opcode returns the ID associated with this packet type. // 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 // Parse parses the packet from binary
func (m *MsgMhfAcquireDistItem) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error { func (m *MsgMhfAcquireDistItem) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
m.AckHandle = bf.ReadUint32() m.AckHandle = bf.ReadUint32()
m.Unk0 = bf.ReadUint8() m.DistributionType = bf.ReadUint8()
m.Unk1 = bf.ReadUint32() m.DistributionID = bf.ReadUint32()
return nil return nil
} }

View File

@@ -1,8 +1,10 @@
package channelserver package channelserver
import ( import (
"time"
"erupe-ce/network/mhfpacket" "erupe-ce/network/mhfpacket"
"erupe-ce/common/stringsupport" ps "erupe-ce/common/pascalstring"
"erupe-ce/common/byteframe" "erupe-ce/common/byteframe"
"go.uber.org/zap" "go.uber.org/zap"
) )
@@ -68,14 +70,13 @@ func handleMsgMhfEnumerateDistItem(s *Session, p mhfpacket.MHFPacket) {
bf.WriteUint16(distData.MaxGR) bf.WriteUint16(distData.MaxGR)
bf.WriteUint32(0) // Unk bf.WriteUint32(0) // Unk
bf.WriteUint32(0) // Unk bf.WriteUint32(0) // Unk
eventName, _ := stringsupport.ConvertUTF8ToShiftJIS(distData.EventName) ps.Uint16(bf, distData.EventName, true)
bf.WriteUint16(uint16(len(eventName)+1))
bf.WriteNullTerminatedBytes(eventName)
bf.WriteBytes(make([]byte, 391)) bf.WriteBytes(make([]byte, 391))
} }
resp := byteframe.NewByteFrame() resp := byteframe.NewByteFrame()
resp.WriteUint16(uint16(distCount)) resp.WriteUint16(uint16(distCount))
resp.WriteBytes(bf.Data()) resp.WriteBytes(bf.Data())
resp.WriteUint8(0)
doAckBufSucceed(s, pkt.AckHandle, resp.Data()) doAckBufSucceed(s, pkt.AckHandle, resp.Data())
} }
} }
@@ -96,8 +97,9 @@ func handleMsgMhfApplyDistItem(s *Session, p mhfpacket.MHFPacket) {
} }
bf := byteframe.NewByteFrame() bf := byteframe.NewByteFrame()
bf.WriteUint32(0) bf.WriteUint32(pkt.DistributionID)
bf.WriteBytes(dist.Data) bf.WriteBytes(dist.Data)
bf.WriteUint32(uint32(time.Now().Unix()))
doAckBufSucceed(s, pkt.AckHandle, bf.Data()) doAckBufSucceed(s, pkt.AckHandle, bf.Data())
_, err = s.server.db.Exec(` _, err = s.server.db.Exec(`
@@ -125,8 +127,7 @@ func handleMsgMhfGetDistDescription(s *Session, p mhfpacket.MHFPacket) {
return return
} }
bf := byteframe.NewByteFrame() bf := byteframe.NewByteFrame()
description, _ := stringsupport.ConvertUTF8ToShiftJIS(desc) ps.Uint16(bf, desc, true)
bf.WriteUint16(uint16(len(description)+1)) ps.Uint16(bf, "", false)
bf.WriteNullTerminatedBytes(description)
doAckBufSucceed(s, pkt.AckHandle, bf.Data()) doAckBufSucceed(s, pkt.AckHandle, bf.Data())
} }