Add mhfpacket wrapper for party join message

This commit is contained in:
Sophie
2020-03-06 21:23:57 +00:00
parent 2d9a26df75
commit ac40e679fe
2 changed files with 59 additions and 18 deletions

View File

@@ -0,0 +1,46 @@
package binpacket
import (
"github.com/Andoryuuta/Erupe/network"
"github.com/Andoryuuta/Erupe/network/mhfpacket"
"github.com/Andoryuuta/byteframe"
)
type PartyJoinType uint8
const (
JoinedLocalParty PartyJoinType = 0x01
JoinedYourParty PartyJoinType = 0x04
)
type MsgBinPlayerJoinedParty struct {
CharID uint32
PartyJoinType PartyJoinType
}
// Opcode returns the ID associated with this packet type.
func (m *MsgBinPlayerJoinedParty) Opcode() network.PacketID {
return network.MSG_SYS_CASTED_BINARY
}
func (m *MsgBinPlayerJoinedParty) Parse(bf *byteframe.ByteFrame) error {
panic("Not implemented")
}
// Build builds a binary packet from the current data.
func (m *MsgBinPlayerJoinedParty) Build(bf *byteframe.ByteFrame) error {
payload := byteframe.NewByteFrame()
payload.WriteUint16(0x2)
payload.WriteUint8(uint8(m.PartyJoinType))
payload.WriteBytes([]byte{0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})
pkt := &mhfpacket.MsgSysCastedBinary{
CharID: m.CharID,
Type0: 0x03,
Type1: 0x03,
RawDataPayload: payload.Data(),
}
return pkt.Build(bf)
}

View File

@@ -6,6 +6,7 @@ import (
"encoding/base64"
"encoding/hex"
"fmt"
"github.com/Andoryuuta/Erupe/network/binpacket"
"io"
"io/ioutil"
"os"
@@ -700,29 +701,20 @@ func handleMsgSysReserveStage(s *Session, p mhfpacket.MHFPacket) {
s.stage.BroadcastMHF(notify, s)
joinMsgA := &mhfpacket.MsgSysCastedBinary{
CharID: s.charID,
Type0: 0x03,
Type1: 0x03,
RawDataPayload: []byte{
0x00, 0x02, 0x01, 0x00, 0x01, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
},
//TODO these messages should be directed to the correct recipients
joinedAPartyMessage := &binpacket.MsgBinPlayerJoinedParty{
CharID: s.charID,
PartyJoinType: binpacket.JoinedLocalParty,
}
s.stage.BroadcastMHF(joinMsgA, s)
s.stage.BroadcastMHF(joinedAPartyMessage, s)
joinMsgB := &mhfpacket.MsgSysCastedBinary{
CharID: s.charID,
Type0: 0x03,
Type1: 0x03,
RawDataPayload: []byte{
0x00, 0x02, 0x04, 0x00, 0x01, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
},
joinedYourPartyMessage := &binpacket.MsgBinPlayerJoinedParty{
CharID: s.charID,
PartyJoinType: binpacket.JoinedYourParty,
}
s.stage.BroadcastMHF(joinMsgB, s)
s.stage.BroadcastMHF(joinedYourPartyMessage, s)
}
func handleMsgSysUnreserveStage(s *Session, p mhfpacket.MHFPacket) {}
@@ -814,7 +806,10 @@ func handleMsgSysGetStageBinary(s *Session, p mhfpacket.MHFPacket) {
if gotBinary {
doSizedAckResp(s, pkt.AckHandle, stageBinary)
} else if pkt.BinaryType1 == 4 {
// This particular type seems to be expecting data that isn't set
// is it required before the party joining can be completed
s.QueueAck(pkt.AckHandle, []byte{0x01, 0x00, 0x00, 0x00, 0x10})
} else {
s.logger.Warn("Failed to get stage binary", zap.Uint8("BinaryType0", pkt.BinaryType0), zap.Uint8("pkt.BinaryType1", pkt.BinaryType1))