port partial fix/mutex-rework

This commit is contained in:
wish
2023-11-26 23:22:56 +11:00
parent fc4476ed8c
commit 3c6067c8a6
9 changed files with 53 additions and 57 deletions

View File

@@ -3,7 +3,6 @@ package mhfpacket
import (
"errors"
"erupe-ce/common/byteframe"
"erupe-ce/common/bfutil"
"erupe-ce/network"
"erupe-ce/network/clientctx"
)
@@ -13,7 +12,7 @@ type MsgSysCreateStage struct {
AckHandle uint32
Unk0 uint8 // Likely only has 1 and 2 as values.
PlayerCount uint8
StageID string // NULL terminated string.
StageID string
}
// Opcode returns the ID associated with this packet type.
@@ -26,8 +25,8 @@ func (m *MsgSysCreateStage) Parse(bf *byteframe.ByteFrame, ctx *clientctx.Client
m.AckHandle = bf.ReadUint32()
m.Unk0 = bf.ReadUint8()
m.PlayerCount = bf.ReadUint8()
stageIDLength := bf.ReadUint8()
m.StageID = string(bfutil.UpToNull(bf.ReadBytes(uint(stageIDLength))))
bf.ReadUint8() // Length StageID
m.StageID = string(bf.ReadNullTerminatedBytes())
return nil
}

View File

@@ -11,7 +11,7 @@ import (
// MsgSysEnterStage represents the MSG_SYS_ENTER_STAGE
type MsgSysEnterStage struct {
AckHandle uint32
UnkBool uint8
Unk bool
StageID string
}
@@ -23,8 +23,8 @@ func (m *MsgSysEnterStage) Opcode() network.PacketID {
// Parse parses the packet from binary
func (m *MsgSysEnterStage) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
m.AckHandle = bf.ReadUint32()
m.UnkBool = bf.ReadUint8()
bf.ReadUint8()
m.Unk = bf.ReadBool() // IsQuest?
bf.ReadUint8() // Length StageID
m.StageID = string(bf.ReadNullTerminatedBytes())
return nil
}

View File

@@ -2,8 +2,6 @@ package mhfpacket
import (
"errors"
"erupe-ce/common/stringsupport"
"erupe-ce/common/byteframe"
"erupe-ce/network"
"erupe-ce/network/clientctx"
@@ -12,8 +10,7 @@ import (
// MsgSysEnumerateStage represents the MSG_SYS_ENUMERATE_STAGE
type MsgSysEnumerateStage struct {
AckHandle uint32
Unk0 uint8 // Hardcoded 1 in the binary
StagePrefix string // NULL terminated string.
StagePrefix string
}
// Opcode returns the ID associated with this packet type.
@@ -24,9 +21,9 @@ func (m *MsgSysEnumerateStage) Opcode() network.PacketID {
// Parse parses the packet from binary
func (m *MsgSysEnumerateStage) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
m.AckHandle = bf.ReadUint32()
m.Unk0 = bf.ReadUint8()
bf.ReadUint8()
m.StagePrefix = stringsupport.SJISToUTF8(bf.ReadNullTerminatedBytes())
bf.ReadUint8() // Always 1
bf.ReadUint8() // Length StagePrefix
m.StagePrefix = string(bf.ReadNullTerminatedBytes())
return nil
}

View File

@@ -1,20 +1,17 @@
package mhfpacket
import (
"errors"
import (
"errors"
"erupe-ce/network/clientctx"
"erupe-ce/network"
"erupe-ce/common/byteframe"
"erupe-ce/network"
"erupe-ce/network/clientctx"
)
// MsgSysLockStage represents the MSG_SYS_LOCK_STAGE
type MsgSysLockStage struct {
AckHandle uint32
Unk0 uint8 // Hardcoded 1 in the binary
Unk1 uint8 // Hardcoded 1 in the binary
StageIDLength uint8
StageID string
AckHandle uint32
StageID string
}
// Opcode returns the ID associated with this packet type.
@@ -25,10 +22,10 @@ func (m *MsgSysLockStage) Opcode() network.PacketID {
// Parse parses the packet from binary
func (m *MsgSysLockStage) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
m.AckHandle = bf.ReadUint32()
m.Unk0 = bf.ReadUint8()
m.Unk1 = bf.ReadUint8()
m.StageIDLength = bf.ReadUint8()
m.StageID = string(bf.ReadBytes(uint(m.StageIDLength)))
bf.ReadUint8() // Always 1
bf.ReadUint8() // Always 1
bf.ReadUint8() // Length StageID
m.StageID = string(bf.ReadNullTerminatedBytes())
return nil
}

View File

@@ -1,15 +1,14 @@
package mhfpacket
import (
"errors"
"erupe-ce/common/byteframe"
"erupe-ce/network"
"erupe-ce/network/clientctx"
"erupe-ce/common/byteframe"
)
// MsgSysUnlockStage represents the MSG_SYS_UNLOCK_STAGE
type MsgSysUnlockStage struct {
Unk0 uint16 // Hardcoded 0 in the binary.
}
type MsgSysUnlockStage struct{}
// Opcode returns the ID associated with this packet type.
func (m *MsgSysUnlockStage) Opcode() network.PacketID {
@@ -18,12 +17,11 @@ func (m *MsgSysUnlockStage) Opcode() network.PacketID {
// Parse parses the packet from binary
func (m *MsgSysUnlockStage) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
m.Unk0 = bf.ReadUint16()
bf.ReadUint16() // Zeroed
return nil
}
// Build builds a binary packet from the current data.
func (m *MsgSysUnlockStage) Build(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
bf.WriteUint16(m.Unk0)
return nil
return errors.New("NOT IMPLEMENTED")
}