From 0550fb21b5e38fc53345e7b140714e0bd1968bc4 Mon Sep 17 00:00:00 2001 From: wish Date: Wed, 22 Nov 2023 22:59:36 +1100 Subject: [PATCH] parse & handle PlayFreeGacha --- network/mhfpacket/msg_mhf_play_free_gacha.go | 19 +++++++++++++------ server/channelserver/handlers_shop_gacha.go | 5 ++++- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/network/mhfpacket/msg_mhf_play_free_gacha.go b/network/mhfpacket/msg_mhf_play_free_gacha.go index c96c5cefc..6d57124f3 100644 --- a/network/mhfpacket/msg_mhf_play_free_gacha.go +++ b/network/mhfpacket/msg_mhf_play_free_gacha.go @@ -1,15 +1,19 @@ package mhfpacket -import ( - "errors" +import ( + "errors" - "erupe-ce/network/clientctx" - "erupe-ce/network" "erupe-ce/common/byteframe" + "erupe-ce/network" + "erupe-ce/network/clientctx" ) // MsgMhfPlayFreeGacha represents the MSG_MHF_PLAY_FREE_GACHA -type MsgMhfPlayFreeGacha struct{} +type MsgMhfPlayFreeGacha struct { + AckHandle uint32 + GachaID uint32 + GachaType uint8 +} // Opcode returns the ID associated with this packet type. func (m *MsgMhfPlayFreeGacha) Opcode() network.PacketID { @@ -18,7 +22,10 @@ func (m *MsgMhfPlayFreeGacha) Opcode() network.PacketID { // Parse parses the packet from binary func (m *MsgMhfPlayFreeGacha) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error { - return errors.New("NOT IMPLEMENTED") + m.AckHandle = bf.ReadUint32() + m.GachaID = bf.ReadUint32() + m.GachaType = bf.ReadUint8() + return nil } // Build builds a binary packet from the current data. diff --git a/server/channelserver/handlers_shop_gacha.go b/server/channelserver/handlers_shop_gacha.go index 66e7b18ae..373eb8028 100644 --- a/server/channelserver/handlers_shop_gacha.go +++ b/server/channelserver/handlers_shop_gacha.go @@ -718,5 +718,8 @@ func handleMsgMhfGetFpointExchangeList(s *Session, p mhfpacket.MHFPacket) { } func handleMsgMhfPlayFreeGacha(s *Session, p mhfpacket.MHFPacket) { - // not sure this is used anywhere, free gachas use the MSG_MHF_PLAY_NORMAL_GACHA method in captures + pkt := p.(*mhfpacket.MsgMhfPlayFreeGacha) + bf := byteframe.NewByteFrame() + bf.WriteUint32(1) + doAckSimpleSucceed(s, pkt.AckHandle, bf.Data()) }