Clients in stage are now notified when player chooses a quest

This commit is contained in:
Sophie
2020-03-07 14:21:08 +00:00
parent ac40e679fe
commit 795028a1ca
3 changed files with 29 additions and 7 deletions

View File

@@ -16,6 +16,7 @@ const (
type MsgBinPlayerJoinedParty struct { type MsgBinPlayerJoinedParty struct {
CharID uint32 CharID uint32
PartyJoinType PartyJoinType PartyJoinType PartyJoinType
Unk1 uint16
} }
// Opcode returns the ID associated with this packet type. // Opcode returns the ID associated with this packet type.
@@ -31,9 +32,10 @@ func (m *MsgBinPlayerJoinedParty) Parse(bf *byteframe.ByteFrame) error {
func (m *MsgBinPlayerJoinedParty) Build(bf *byteframe.ByteFrame) error { func (m *MsgBinPlayerJoinedParty) Build(bf *byteframe.ByteFrame) error {
payload := byteframe.NewByteFrame() payload := byteframe.NewByteFrame()
payload.WriteUint16(0x2) payload.WriteUint16(0x02)
payload.WriteUint8(uint8(m.PartyJoinType)) payload.WriteUint8(uint8(m.PartyJoinType))
payload.WriteBytes([]byte{0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}) payload.WriteUint16(m.Unk1)
payload.WriteBytes([]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})
pkt := &mhfpacket.MsgSysCastedBinary{ pkt := &mhfpacket.MsgSysCastedBinary{
CharID: m.CharID, CharID: m.CharID,

View File

@@ -498,6 +498,15 @@ func handleMsgSysCreateStage(s *Session, p mhfpacket.MHFPacket) {
resp := make([]byte, 8) // Unk resp. resp := make([]byte, 8) // Unk resp.
s.QueueAck(pkt.AckHandle, resp) s.QueueAck(pkt.AckHandle, resp)
createdPartyMessage := &mhfpacket.MsgSysCastedBinary{
CharID: s.charID,
Type0: 0x03,
Type1: 0x03,
RawDataPayload: []byte{0x00, 0x02, 0x0b, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x5b, 0x27, 0xb3, 0x2e, 0x48, 0xa3, 0x17, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
}
s.stage.BroadcastMHF(createdPartyMessage, s)
} }
func handleMsgSysStageDestruct(s *Session, p mhfpacket.MHFPacket) {} func handleMsgSysStageDestruct(s *Session, p mhfpacket.MHFPacket) {}
@@ -694,17 +703,16 @@ func handleMsgSysReserveStage(s *Session, p mhfpacket.MHFPacket) {
0x00, 0x1b, 0x30, 0x15, 0xc2, 0x45, 0x03, 0x03, 0x00, 0x0c, 0x00, 0x02, 0x06, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x1b, 0x30, 0x15, 0xc2, 0x45, 0x03, 0x03, 0x00, 0x0c, 0x00, 0x02, 0x06, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
}) })
notify := &mhfpacket.MsgSysNotifyUserBinary{ // TODO remove this, temp for testing
CharID: s.charID, if s.charID == 0x02 {
BinaryType: 0x03, return
} }
s.stage.BroadcastMHF(notify, s)
//TODO these messages should be directed to the correct recipients //TODO these messages should be directed to the correct recipients
joinedAPartyMessage := &binpacket.MsgBinPlayerJoinedParty{ joinedAPartyMessage := &binpacket.MsgBinPlayerJoinedParty{
CharID: s.charID, CharID: s.charID,
PartyJoinType: binpacket.JoinedLocalParty, PartyJoinType: binpacket.JoinedLocalParty,
Unk1: 0x01,
} }
s.stage.BroadcastMHF(joinedAPartyMessage, s) s.stage.BroadcastMHF(joinedAPartyMessage, s)
@@ -712,6 +720,7 @@ func handleMsgSysReserveStage(s *Session, p mhfpacket.MHFPacket) {
joinedYourPartyMessage := &binpacket.MsgBinPlayerJoinedParty{ joinedYourPartyMessage := &binpacket.MsgBinPlayerJoinedParty{
CharID: s.charID, CharID: s.charID,
PartyJoinType: binpacket.JoinedYourParty, PartyJoinType: binpacket.JoinedYourParty,
Unk1: 0x01,
} }
s.stage.BroadcastMHF(joinedYourPartyMessage, s) s.stage.BroadcastMHF(joinedYourPartyMessage, s)
@@ -1007,6 +1016,13 @@ func handleMsgSysSetUserBinary(s *Session, p mhfpacket.MHFPacket) {
s.server.userBinaryPartsLock.Lock() s.server.userBinaryPartsLock.Lock()
s.server.userBinaryParts[userBinaryPartID{charID: s.charID, index: pkt.BinaryType}] = pkt.RawDataPayload s.server.userBinaryParts[userBinaryPartID{charID: s.charID, index: pkt.BinaryType}] = pkt.RawDataPayload
s.server.userBinaryPartsLock.Unlock() s.server.userBinaryPartsLock.Unlock()
msg := &mhfpacket.MsgSysNotifyUserBinary{
CharID: s.charID,
BinaryType: pkt.BinaryType,
}
s.stage.BroadcastMHF(msg, s)
} }
func handleMsgSysGetUserBinary(s *Session, p mhfpacket.MHFPacket) { func handleMsgSysGetUserBinary(s *Session, p mhfpacket.MHFPacket) {

View File

@@ -58,6 +58,9 @@ func (s *Session) Start() {
// QueueSend queues a packet (raw []byte) to be sent. // QueueSend queues a packet (raw []byte) to be sent.
func (s *Session) QueueSend(data []byte) { func (s *Session) QueueSend(data []byte) {
fmt.Printf("Sending To CharID: '%x'\n", s.charID)
fmt.Printf("Sent Data:\n%s\n", hex.Dump(data))
s.sendPackets <- data s.sendPackets <- data
} }
@@ -144,6 +147,7 @@ func (s *Session) handlePacketGroup(pktGroup []byte) {
opcode != network.MSG_SYS_NOP && opcode != network.MSG_SYS_NOP &&
opcode != network.MSG_SYS_TIME && opcode != network.MSG_SYS_TIME &&
opcode != network.MSG_SYS_EXTEND_THRESHOLD { opcode != network.MSG_SYS_EXTEND_THRESHOLD {
fmt.Printf("CharID: '%x'\n", s.charID)
fmt.Printf("Opcode: %s\n", opcode) fmt.Printf("Opcode: %s\n", opcode)
fmt.Printf("Data:\n%s\n", hex.Dump(pktGroup)) fmt.Printf("Data:\n%s\n", hex.Dump(pktGroup))
} }