fix game crash when receiving mail items

This commit is contained in:
wish
2022-07-16 04:10:12 +10:00
parent 0af03955e8
commit 2592fd4e33

View File

@@ -330,10 +330,8 @@ func handleMsgMhfListMail(s *Session, p mhfpacket.MHFPacket) {
// System message, hides ID // System message, hides ID
// flags |= 0x04 // flags |= 0x04
// Mitigate game crash
flags |= 0x08
if m.AttachedItemReceived { if m.AttachedItemReceived {
// flags |= 0x08 flags |= 0x08
} }
if m.IsGuildInvite { if m.IsGuildInvite {
@@ -347,7 +345,6 @@ func handleMsgMhfListMail(s *Session, p mhfpacket.MHFPacket) {
msg.WriteNullTerminatedBytes(subject) msg.WriteNullTerminatedBytes(subject)
msg.WriteNullTerminatedBytes(sender) msg.WriteNullTerminatedBytes(sender)
// TODO: The game will crash if it attempts to receive items
if itemAttached { if itemAttached {
msg.WriteUint16(m.AttachedItemAmount) msg.WriteUint16(m.AttachedItemAmount)
msg.WriteUint16(m.AttachedItemID) msg.WriteUint16(m.AttachedItemID)
@@ -361,12 +358,10 @@ func handleMsgMhfOprtMail(s *Session, p mhfpacket.MHFPacket) {
pkt := p.(*mhfpacket.MsgMhfOprtMail) pkt := p.(*mhfpacket.MsgMhfOprtMail)
mail, err := GetMailByID(s, s.mailList[pkt.AccIndex]) mail, err := GetMailByID(s, s.mailList[pkt.AccIndex])
if err != nil { if err != nil {
doAckSimpleFail(s, pkt.AckHandle, nil) doAckSimpleFail(s, pkt.AckHandle, nil)
panic(err) panic(err)
} }
switch mhfpacket.OperateMailOperation(pkt.Operation) { switch mhfpacket.OperateMailOperation(pkt.Operation) {
case mhfpacket.OPERATE_MAIL_DELETE: case mhfpacket.OPERATE_MAIL_DELETE:
err = mail.MarkDeleted(s) err = mail.MarkDeleted(s)
@@ -393,8 +388,8 @@ func handleMsgMhfOprtMail(s *Session, p mhfpacket.MHFPacket) {
panic(err) panic(err)
} }
} }
doAckSimpleSucceed(s, pkt.AckHandle, nil) doAckSimpleSucceed(s, pkt.AckHandle, make([]byte, 4))
} }
func handleMsgMhfSendMail(s *Session, p mhfpacket.MHFPacket) { func handleMsgMhfSendMail(s *Session, p mhfpacket.MHFPacket) {