From 1382e99fc6f59fdbfb7b6ce7146e84fbd0bd7e36 Mon Sep 17 00:00:00 2001 From: wish Date: Sun, 29 Jan 2023 12:22:07 +1100 Subject: [PATCH] further decode merc packets --- network/mhfpacket/msg_mhf_contract_mercenary.go | 4 ++-- network/mhfpacket/msg_mhf_read_mercenary_w.go | 4 ++-- server/channelserver/handlers_mercenary.go | 16 +++++++++++----- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/network/mhfpacket/msg_mhf_contract_mercenary.go b/network/mhfpacket/msg_mhf_contract_mercenary.go index 60b935861..a139dabb9 100644 --- a/network/mhfpacket/msg_mhf_contract_mercenary.go +++ b/network/mhfpacket/msg_mhf_contract_mercenary.go @@ -13,7 +13,7 @@ type MsgMhfContractMercenary struct { AckHandle uint32 PactMercID uint32 CID uint32 - Unk bool + Cancel bool } // Opcode returns the ID associated with this packet type. @@ -26,7 +26,7 @@ func (m *MsgMhfContractMercenary) Parse(bf *byteframe.ByteFrame, ctx *clientctx. m.AckHandle = bf.ReadUint32() m.PactMercID = bf.ReadUint32() m.CID = bf.ReadUint32() - m.Unk = bf.ReadBool() + m.Cancel = bf.ReadBool() return nil } diff --git a/network/mhfpacket/msg_mhf_read_mercenary_w.go b/network/mhfpacket/msg_mhf_read_mercenary_w.go index fee9fc19d..3aa9597d9 100644 --- a/network/mhfpacket/msg_mhf_read_mercenary_w.go +++ b/network/mhfpacket/msg_mhf_read_mercenary_w.go @@ -11,7 +11,7 @@ import ( // MsgMhfReadMercenaryW represents the MSG_MHF_READ_MERCENARY_W type MsgMhfReadMercenaryW struct { AckHandle uint32 - GetPact bool + Op uint8 Unk1 uint8 Unk2 uint16 // Hardcoded 0 in the binary } @@ -24,7 +24,7 @@ func (m *MsgMhfReadMercenaryW) Opcode() network.PacketID { // Parse parses the packet from binary func (m *MsgMhfReadMercenaryW) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error { m.AckHandle = bf.ReadUint32() - m.GetPact = bf.ReadBool() + m.Op = bf.ReadUint8() m.Unk1 = bf.ReadUint8() m.Unk2 = bf.ReadUint16() return nil diff --git a/server/channelserver/handlers_mercenary.go b/server/channelserver/handlers_mercenary.go index 3f79d5502..f13687d04 100644 --- a/server/channelserver/handlers_mercenary.go +++ b/server/channelserver/handlers_mercenary.go @@ -165,7 +165,7 @@ func handleMsgMhfSaveMercenary(s *Session, p mhfpacket.MHFPacket) { func handleMsgMhfReadMercenaryW(s *Session, p mhfpacket.MHFPacket) { pkt := p.(*mhfpacket.MsgMhfReadMercenaryW) - if pkt.GetPact { + if pkt.Op > 0 { var pactID uint32 s.server.db.QueryRow("SELECT pact_id FROM characters WHERE id=$1", s.charID).Scan(&pactID) if pactID > 0 { @@ -177,10 +177,12 @@ func handleMsgMhfReadMercenaryW(s *Session, p mhfpacket.MHFPacket) { bf.WriteUint32(pactID) bf.WriteUint32(cid) bf.WriteBool(true) - bf.WriteUint32(uint32(Time_Current_Adjusted().Unix())) - bf.WriteUint32(uint32(Time_Current_Adjusted().Add(time.Hour * 24 * 7).Unix())) + bf.WriteUint32(uint32(Time_Current_Adjusted().Add(time.Hour * 24 * -8).Unix())) + bf.WriteUint32(uint32(Time_Current_Adjusted().Add(time.Hour * 24 * -1).Unix())) bf.WriteBytes(stringsupport.PaddedString(name, 18, true)) - bf.WriteBool(false) + if pkt.Op == 1 { + bf.WriteBool(false) + } doAckBufSucceed(s, pkt.AckHandle, bf.Data()) } else { doAckBufSucceed(s, pkt.AckHandle, make([]byte, 2)) @@ -219,7 +221,11 @@ func handleMsgMhfReadMercenaryM(s *Session, p mhfpacket.MHFPacket) { func handleMsgMhfContractMercenary(s *Session, p mhfpacket.MHFPacket) { pkt := p.(*mhfpacket.MsgMhfContractMercenary) - s.server.db.Exec("UPDATE characters SET pact_id=0 WHERE id=$1", s.charID) + if pkt.Cancel { + s.server.db.Exec("UPDATE characters SET pact_id=0 WHERE id=$1", s.charID) + } else { + s.server.db.Exec("UPDATE characters SET pact_id=$1 WHERE id=$2", pkt.PactMercID, s.charID) + } doAckSimpleSucceed(s, pkt.AckHandle, make([]byte, 4)) }