mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-21 23:22:34 +01:00
ByteFrame previously panicked on out-of-bounds reads, which crashed
the server when parsing malformed client packets. Now sets a sticky
error (checked via Err()) and returns zero values, matching the
encoding/binary scanner pattern. The session recv loop checks Err()
after parsing to reject malformed packets gracefully.
Also replaces remaining panic("Not implemented") stubs in network
packet Build/Parse methods with proper error returns.
32 lines
804 B
Go
32 lines
804 B
Go
package binpacket
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"erupe-ce/common/byteframe"
|
|
"erupe-ce/common/stringsupport"
|
|
"erupe-ce/network"
|
|
)
|
|
|
|
// MsgBinMailNotify is a binpacket broadcast to notify a player of new mail.
|
|
type MsgBinMailNotify struct {
|
|
SenderName string
|
|
}
|
|
|
|
// Parse parses the packet from binary.
|
|
func (m MsgBinMailNotify) Parse(bf *byteframe.ByteFrame) error {
|
|
return fmt.Errorf("MsgBinMailNotify.Parse: not implemented")
|
|
}
|
|
|
|
// Build builds a binary packet from the current data.
|
|
func (m MsgBinMailNotify) Build(bf *byteframe.ByteFrame) error {
|
|
bf.WriteUint8(0x01) // Unk
|
|
bf.WriteBytes(stringsupport.PaddedString(m.SenderName, 21, true))
|
|
return nil
|
|
}
|
|
|
|
// Opcode returns the ID associated with this packet type.
|
|
func (m MsgBinMailNotify) Opcode() network.PacketID {
|
|
return network.MSG_SYS_CASTED_BINARY
|
|
}
|