mirror of
https://github.com/Mezeporta/Erupe.git
synced 2025-12-23 12:24:45 +01:00
binary cast fixes and support all ravi types
This commit is contained in:
@@ -14,6 +14,7 @@ type MsgMhfAnnounce struct {
|
|||||||
IPAddress uint32
|
IPAddress uint32
|
||||||
Port uint16
|
Port uint16
|
||||||
StageID []byte
|
StageID []byte
|
||||||
|
Type uint8
|
||||||
}
|
}
|
||||||
|
|
||||||
// Opcode returns the ID associated with this packet type.
|
// Opcode returns the ID associated with this packet type.
|
||||||
@@ -30,9 +31,8 @@ func (m *MsgMhfAnnounce) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientCon
|
|||||||
_ = bf.ReadUint16()
|
_ = bf.ReadUint16()
|
||||||
m.StageID = bf.ReadNullTerminatedBytes()
|
m.StageID = bf.ReadNullTerminatedBytes()
|
||||||
for {
|
for {
|
||||||
byte := bf.ReadUint8()
|
if bf.ReadUint8() != 0 {
|
||||||
if byte != 0 {
|
m.Type = bf.ReadUint8()
|
||||||
_ = bf.ReadUint8()
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package mhfpacket
|
package mhfpacket
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"erupe-ce/network/clientctx"
|
"erupe-ce/network/clientctx"
|
||||||
"erupe-ce/network"
|
"erupe-ce/network"
|
||||||
@@ -9,7 +9,13 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// MsgMhfSetRestrictionEvent represents the MSG_MHF_SET_RESTRICTION_EVENT
|
// MsgMhfSetRestrictionEvent represents the MSG_MHF_SET_RESTRICTION_EVENT
|
||||||
type MsgMhfSetRestrictionEvent struct{}
|
type MsgMhfSetRestrictionEvent struct {
|
||||||
|
AckHandle uint32
|
||||||
|
Unk0 uint32
|
||||||
|
Unk1 uint32
|
||||||
|
Unk2 uint32
|
||||||
|
Unk3 uint8
|
||||||
|
}
|
||||||
|
|
||||||
// Opcode returns the ID associated with this packet type.
|
// Opcode returns the ID associated with this packet type.
|
||||||
func (m *MsgMhfSetRestrictionEvent) Opcode() network.PacketID {
|
func (m *MsgMhfSetRestrictionEvent) Opcode() network.PacketID {
|
||||||
@@ -18,7 +24,12 @@ func (m *MsgMhfSetRestrictionEvent) Opcode() network.PacketID {
|
|||||||
|
|
||||||
// Parse parses the packet from binary
|
// Parse parses the packet from binary
|
||||||
func (m *MsgMhfSetRestrictionEvent) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
|
func (m *MsgMhfSetRestrictionEvent) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
|
||||||
return errors.New("NOT IMPLEMENTED")
|
m.AckHandle = bf.ReadUint32()
|
||||||
|
m.Unk0 = bf.ReadUint32()
|
||||||
|
m.Unk1 = bf.ReadUint32()
|
||||||
|
m.Unk2 = bf.ReadUint32()
|
||||||
|
m.Unk3 = bf.ReadUint8()
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build builds a binary packet from the current data.
|
// Build builds a binary packet from the current data.
|
||||||
|
|||||||
@@ -346,7 +346,7 @@ func handleMsgMhfServerCommand(s *Session, p mhfpacket.MHFPacket) {}
|
|||||||
|
|
||||||
func handleMsgMhfAnnounce(s *Session, p mhfpacket.MHFPacket) {
|
func handleMsgMhfAnnounce(s *Session, p mhfpacket.MHFPacket) {
|
||||||
pkt := p.(*mhfpacket.MsgMhfAnnounce)
|
pkt := p.(*mhfpacket.MsgMhfAnnounce)
|
||||||
s.server.BroadcastRaviente(pkt.IPAddress, pkt.Port, pkt.StageID)
|
s.server.BroadcastRaviente(pkt.IPAddress, pkt.Port, pkt.StageID, pkt.Type)
|
||||||
doAckSimpleSucceed(s, pkt.AckHandle, make([]byte, 4))
|
doAckSimpleSucceed(s, pkt.AckHandle, make([]byte, 4))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -64,17 +64,22 @@ func handleMsgSysCastBinary(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Parse out the real casted binary payload
|
// Parse out the real casted binary payload
|
||||||
var realPayload []byte
|
|
||||||
var msgBinTargeted *binpacket.MsgBinTargeted
|
var msgBinTargeted *binpacket.MsgBinTargeted
|
||||||
|
var authorLen, msgLen uint16
|
||||||
|
var msg []byte
|
||||||
|
|
||||||
isDiceCommand := false
|
isDiceCommand := false
|
||||||
tmp.SetLE()
|
if pkt.MessageType == BinaryMessageTypeChat {
|
||||||
tmp.Seek(int64(0), 0)
|
tmp.SetLE()
|
||||||
_ = tmp.ReadUint32()
|
tmp.Seek(int64(0), 0)
|
||||||
authorLen := tmp.ReadUint16()
|
_ = tmp.ReadUint32()
|
||||||
msgLen := tmp.ReadUint16()
|
authorLen = tmp.ReadUint16()
|
||||||
msg := tmp.ReadNullTerminatedBytes()
|
msgLen = tmp.ReadUint16()
|
||||||
|
msg = tmp.ReadNullTerminatedBytes()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Customise payload
|
||||||
|
realPayload := pkt.RawDataPayload
|
||||||
if pkt.BroadcastType == BroadcastTypeTargeted {
|
if pkt.BroadcastType == BroadcastTypeTargeted {
|
||||||
tmp.SetBE()
|
tmp.SetBE()
|
||||||
tmp.Seek(int64(0), 0)
|
tmp.Seek(int64(0), 0)
|
||||||
@@ -85,21 +90,21 @@ func handleMsgSysCastBinary(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
realPayload = msgBinTargeted.RawDataPayload
|
realPayload = msgBinTargeted.RawDataPayload
|
||||||
} else if msgLen == 6 && string(msg) == "@dice" {
|
} else if pkt.MessageType == BinaryMessageTypeChat {
|
||||||
isDiceCommand = true
|
if msgLen == 6 && string(msg) == "@dice" {
|
||||||
roll := byteframe.NewByteFrame()
|
isDiceCommand = true
|
||||||
roll.WriteInt16(1) // Unk
|
roll := byteframe.NewByteFrame()
|
||||||
roll.SetLE()
|
roll.WriteInt16(1) // Unk
|
||||||
roll.WriteUint16(4) // Unk
|
roll.SetLE()
|
||||||
roll.WriteUint16(authorLen)
|
roll.WriteUint16(4) // Unk
|
||||||
rand.Seed(time.Now().UnixNano())
|
roll.WriteUint16(authorLen)
|
||||||
dice := fmt.Sprintf("%d", rand.Intn(100)+1)
|
rand.Seed(time.Now().UnixNano())
|
||||||
roll.WriteUint16(uint16(len(dice)+1))
|
dice := fmt.Sprintf("%d", rand.Intn(100)+1)
|
||||||
roll.WriteNullTerminatedBytes([]byte(dice))
|
roll.WriteUint16(uint16(len(dice)+1))
|
||||||
roll.WriteNullTerminatedBytes(tmp.ReadNullTerminatedBytes())
|
roll.WriteNullTerminatedBytes([]byte(dice))
|
||||||
realPayload = roll.Data()
|
roll.WriteNullTerminatedBytes(tmp.ReadNullTerminatedBytes())
|
||||||
} else {
|
realPayload = roll.Data()
|
||||||
realPayload = pkt.RawDataPayload
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make the response to forward to the other client(s).
|
// Make the response to forward to the other client(s).
|
||||||
|
|||||||
@@ -409,4 +409,7 @@ func handleMsgMhfPostBoostTimeLimit(s *Session, p mhfpacket.MHFPacket) {}
|
|||||||
|
|
||||||
func handleMsgMhfGetRestrictionEvent(s *Session, p mhfpacket.MHFPacket) {}
|
func handleMsgMhfGetRestrictionEvent(s *Session, p mhfpacket.MHFPacket) {}
|
||||||
|
|
||||||
func handleMsgMhfSetRestrictionEvent(s *Session, p mhfpacket.MHFPacket) {}
|
func handleMsgMhfSetRestrictionEvent(s *Session, p mhfpacket.MHFPacket) {
|
||||||
|
pkt := p.(*mhfpacket.MsgMhfSetRestrictionEvent)
|
||||||
|
doAckSimpleSucceed(s, pkt.AckHandle, make([]byte, 4))
|
||||||
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"sync"
|
"sync"
|
||||||
"encoding/hex"
|
|
||||||
|
|
||||||
"github.com/Andoryuuta/byteframe"
|
"github.com/Andoryuuta/byteframe"
|
||||||
"erupe-ce/config"
|
"erupe-ce/config"
|
||||||
@@ -309,15 +308,25 @@ func (s *Server) BroadcastChatMessage(message string) {
|
|||||||
}, nil)
|
}, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) BroadcastRaviente(ip uint32, port uint16, stage []byte) {
|
func (s *Server) BroadcastRaviente(ip uint32, port uint16, stage []byte, _type uint8) {
|
||||||
bf := byteframe.NewByteFrame()
|
bf := byteframe.NewByteFrame()
|
||||||
bf.SetLE()
|
bf.SetLE()
|
||||||
bf.WriteUint16(0) // Unk
|
bf.WriteUint16(0) // Unk
|
||||||
bf.WriteUint16(0x43) // Data len
|
bf.WriteUint16(0x43) // Data len
|
||||||
bf.WriteUint16(3) // Unk len
|
bf.WriteUint16(3) // Unk len
|
||||||
bf.WriteUint16(0x29) // String len
|
var d []byte
|
||||||
d, _ := hex.DecodeString("3C91E593A294B0814696D28BB68AFA81798BC9817A3E82AA8A4A8DC382B382EA82DC82B582BD814900")
|
switch _type {
|
||||||
bf.WriteBytes(d)
|
case 2:
|
||||||
|
d = []byte("<Great Slaying: Berserk> is being held!")
|
||||||
|
case 4:
|
||||||
|
d = []byte("<Great Slaying: Extreme> is being held!")
|
||||||
|
case 5:
|
||||||
|
d = []byte("<Great Slaying: Berserk Practice> is being held!")
|
||||||
|
default:
|
||||||
|
s.logger.Error("Unk raviente type", zap.Uint8("_type", _type))
|
||||||
|
}
|
||||||
|
bf.WriteUint16(uint16(len(d)+1))
|
||||||
|
bf.WriteNullTerminatedBytes(d)
|
||||||
bf.WriteBytes([]byte{0x5F, 0x53, 0x00})
|
bf.WriteBytes([]byte{0x5F, 0x53, 0x00})
|
||||||
bf.WriteUint32(ip) // IP address
|
bf.WriteUint32(ip) // IP address
|
||||||
bf.WriteUint16(port) // Port
|
bf.WriteUint16(port) // Port
|
||||||
|
|||||||
Reference in New Issue
Block a user