correctly parse some ravi packets & ignore zeroes

This commit is contained in:
wish
2023-08-21 21:39:22 +10:00
parent ab81ca9233
commit 192e68ba86
3 changed files with 9 additions and 32 deletions

View File

@@ -1,8 +1,7 @@
package mhfpacket
import (
"fmt"
"errors"
"erupe-ce/common/byteframe"
"erupe-ce/network"
"erupe-ce/network/clientctx"
@@ -12,7 +11,6 @@ import (
type MsgSysOperateRegister struct {
AckHandle uint32
SemaphoreID uint32
fixedZero uint16
RawDataPayload []byte
}
@@ -25,12 +23,7 @@ func (m *MsgSysOperateRegister) Opcode() network.PacketID {
func (m *MsgSysOperateRegister) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
m.AckHandle = bf.ReadUint32()
m.SemaphoreID = bf.ReadUint32()
m.fixedZero = bf.ReadUint16()
if m.fixedZero != 0 {
return fmt.Errorf("expected fixed-0 values, got %d", m.fixedZero)
}
_ = bf.ReadUint16()
dataSize := bf.ReadUint16()
m.RawDataPayload = bf.ReadBytes(uint(dataSize))
return nil
@@ -38,11 +31,5 @@ func (m *MsgSysOperateRegister) Parse(bf *byteframe.ByteFrame, ctx *clientctx.Cl
// Build builds a binary packet from the current data.
func (m *MsgSysOperateRegister) Build(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
bf.WriteUint32(m.AckHandle)
bf.WriteUint32(m.SemaphoreID)
bf.WriteUint16(0)
bf.WriteUint16(uint16(len(m.RawDataPayload)))
bf.WriteBytes(m.RawDataPayload)
return nil
return errors.New("NOT IMPLEMENTED")
}