mirror of
https://github.com/Mezeporta/Erupe.git
synced 2025-12-16 08:55:31 +01:00
Add mhfpacket wrapper for party join message
This commit is contained in:
46
network/binpacket/msg_bin_player_joined_party.go
Normal file
46
network/binpacket/msg_bin_player_joined_party.go
Normal 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)
|
||||||
|
}
|
||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/Andoryuuta/Erupe/network/binpacket"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
@@ -700,29 +701,20 @@ func handleMsgSysReserveStage(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
|
|
||||||
s.stage.BroadcastMHF(notify, s)
|
s.stage.BroadcastMHF(notify, s)
|
||||||
|
|
||||||
joinMsgA := &mhfpacket.MsgSysCastedBinary{
|
//TODO these messages should be directed to the correct recipients
|
||||||
|
joinedAPartyMessage := &binpacket.MsgBinPlayerJoinedParty{
|
||||||
CharID: s.charID,
|
CharID: s.charID,
|
||||||
Type0: 0x03,
|
PartyJoinType: binpacket.JoinedLocalParty,
|
||||||
Type1: 0x03,
|
|
||||||
RawDataPayload: []byte{
|
|
||||||
0x00, 0x02, 0x01, 0x00, 0x01, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
s.stage.BroadcastMHF(joinMsgA, s)
|
s.stage.BroadcastMHF(joinedAPartyMessage, s)
|
||||||
|
|
||||||
joinMsgB := &mhfpacket.MsgSysCastedBinary{
|
joinedYourPartyMessage := &binpacket.MsgBinPlayerJoinedParty{
|
||||||
CharID: s.charID,
|
CharID: s.charID,
|
||||||
Type0: 0x03,
|
PartyJoinType: binpacket.JoinedYourParty,
|
||||||
Type1: 0x03,
|
|
||||||
RawDataPayload: []byte{
|
|
||||||
0x00, 0x02, 0x04, 0x00, 0x01, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
s.stage.BroadcastMHF(joinMsgB, s)
|
s.stage.BroadcastMHF(joinedYourPartyMessage, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleMsgSysUnreserveStage(s *Session, p mhfpacket.MHFPacket) {}
|
func handleMsgSysUnreserveStage(s *Session, p mhfpacket.MHFPacket) {}
|
||||||
@@ -814,7 +806,10 @@ func handleMsgSysGetStageBinary(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
|
|
||||||
if gotBinary {
|
if gotBinary {
|
||||||
doSizedAckResp(s, pkt.AckHandle, stageBinary)
|
doSizedAckResp(s, pkt.AckHandle, stageBinary)
|
||||||
|
|
||||||
} else if pkt.BinaryType1 == 4 {
|
} 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})
|
s.QueueAck(pkt.AckHandle, []byte{0x01, 0x00, 0x00, 0x00, 0x10})
|
||||||
} else {
|
} else {
|
||||||
s.logger.Warn("Failed to get stage binary", zap.Uint8("BinaryType0", pkt.BinaryType0), zap.Uint8("pkt.BinaryType1", pkt.BinaryType1))
|
s.logger.Warn("Failed to get stage binary", zap.Uint8("BinaryType0", pkt.BinaryType0), zap.Uint8("pkt.BinaryType1", pkt.BinaryType1))
|
||||||
|
|||||||
Reference in New Issue
Block a user