mirror of
https://github.com/Mezeporta/Erupe.git
synced 2025-12-14 16:04:38 +01:00
rewrite CastBinary payload handling
This commit is contained in:
@@ -11,7 +11,8 @@ type ChatType uint8
|
|||||||
|
|
||||||
// Chat types
|
// Chat types
|
||||||
const (
|
const (
|
||||||
ChatTypeLocal ChatType = 1
|
ChatTypeWorld ChatType = 0
|
||||||
|
ChatTypeStage = 1
|
||||||
ChatTypeGuild = 2
|
ChatTypeGuild = 2
|
||||||
ChatTypeAlliance = 3
|
ChatTypeAlliance = 3
|
||||||
ChatTypeParty = 4
|
ChatTypeParty = 4
|
||||||
|
|||||||
@@ -377,24 +377,20 @@ func handleMsgSysCastBinary(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
|
|
||||||
// Parse out the real casted binary payload
|
// Parse out the real casted binary payload
|
||||||
var msgBinTargeted *binpacket.MsgBinTargeted
|
var msgBinTargeted *binpacket.MsgBinTargeted
|
||||||
var authorLen, msgLen uint16
|
var message, author string
|
||||||
var msg []byte
|
var returnToSender bool
|
||||||
|
|
||||||
isDiceCommand := false
|
|
||||||
if pkt.MessageType == BinaryMessageTypeChat {
|
if pkt.MessageType == BinaryMessageTypeChat {
|
||||||
tmp.SetLE()
|
tmp.SetLE()
|
||||||
tmp.Seek(int64(0), 0)
|
tmp.Seek(8, 0)
|
||||||
_ = tmp.ReadUint32()
|
message = string(tmp.ReadNullTerminatedBytes())
|
||||||
authorLen = tmp.ReadUint16()
|
author = string(tmp.ReadNullTerminatedBytes())
|
||||||
msgLen = tmp.ReadUint16()
|
|
||||||
msg = tmp.ReadNullTerminatedBytes()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Customise payload
|
// Customise payload
|
||||||
realPayload := pkt.RawDataPayload
|
realPayload := pkt.RawDataPayload
|
||||||
if pkt.BroadcastType == BroadcastTypeTargeted {
|
if pkt.BroadcastType == BroadcastTypeTargeted {
|
||||||
tmp.SetBE()
|
tmp.SetBE()
|
||||||
tmp.Seek(int64(0), 0)
|
tmp.Seek(0, 0)
|
||||||
msgBinTargeted = &binpacket.MsgBinTargeted{}
|
msgBinTargeted = &binpacket.MsgBinTargeted{}
|
||||||
err := msgBinTargeted.Parse(tmp)
|
err := msgBinTargeted.Parse(tmp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -403,18 +399,18 @@ func handleMsgSysCastBinary(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
}
|
}
|
||||||
realPayload = msgBinTargeted.RawDataPayload
|
realPayload = msgBinTargeted.RawDataPayload
|
||||||
} else if pkt.MessageType == BinaryMessageTypeChat {
|
} else if pkt.MessageType == BinaryMessageTypeChat {
|
||||||
if msgLen == 6 && string(msg) == "@dice" {
|
if message == "@dice" {
|
||||||
isDiceCommand = true
|
returnToSender = true
|
||||||
roll := byteframe.NewByteFrame()
|
m := binpacket.MsgBinChat{
|
||||||
roll.WriteInt16(1) // Unk
|
Type: BinaryMessageTypeChat,
|
||||||
roll.SetLE()
|
Flags: 4,
|
||||||
roll.WriteUint16(4) // Unk
|
Message: fmt.Sprintf(`%d`, token.RNG().Intn(100)+1),
|
||||||
roll.WriteUint16(authorLen)
|
SenderName: author,
|
||||||
dice := fmt.Sprintf("%d", token.RNG().Intn(100)+1)
|
}
|
||||||
roll.WriteUint16(uint16(len(dice) + 1))
|
bf := byteframe.NewByteFrame()
|
||||||
roll.WriteNullTerminatedBytes([]byte(dice))
|
bf.SetLE()
|
||||||
roll.WriteNullTerminatedBytes(tmp.ReadNullTerminatedBytes())
|
m.Build(bf)
|
||||||
realPayload = roll.Data()
|
realPayload = bf.Data()
|
||||||
} else {
|
} else {
|
||||||
bf := byteframe.NewByteFrameFromBytes(pkt.RawDataPayload)
|
bf := byteframe.NewByteFrameFromBytes(pkt.RawDataPayload)
|
||||||
bf.SetLE()
|
bf.SetLE()
|
||||||
|
|||||||
Reference in New Issue
Block a user