mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-24 16:43:37 +01:00
refactor(mhfpacket): rename MsgSysCreateStage.Unk0 to CreateType
Wii U decompilation of all 6 callers of snj_stage_create confirms the field distinguishes new stage creation (1) from entering an existing stage (2): lobby/myhouse/quest pass 1, guild room and move operations pass 2.
This commit is contained in:
@@ -467,15 +467,15 @@ func TestMsgSysCreateStageParse(t *testing.T) {
|
|||||||
name string
|
name string
|
||||||
data []byte
|
data []byte
|
||||||
wantHandle uint32
|
wantHandle uint32
|
||||||
wantUnk0 uint8
|
wantCreateType uint8
|
||||||
wantPlayers uint8
|
wantPlayers uint8
|
||||||
wantStageID string
|
wantStageID string
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "simple stage",
|
name: "simple stage",
|
||||||
data: append([]byte{0x00, 0x00, 0x00, 0x01, 0x02, 0x04, 0x05}, append([]byte("test"), 0x00)...),
|
data: append([]byte{0x00, 0x00, 0x00, 0x01, 0x02, 0x04, 0x05}, append([]byte("test"), 0x00)...),
|
||||||
wantHandle: 1,
|
wantHandle: 1,
|
||||||
wantUnk0: 2,
|
wantCreateType: 2,
|
||||||
wantPlayers: 4,
|
wantPlayers: 4,
|
||||||
wantStageID: "test",
|
wantStageID: "test",
|
||||||
},
|
},
|
||||||
@@ -483,7 +483,7 @@ func TestMsgSysCreateStageParse(t *testing.T) {
|
|||||||
name: "empty stage ID",
|
name: "empty stage ID",
|
||||||
data: []byte{0x12, 0x34, 0x56, 0x78, 0x01, 0x02, 0x00},
|
data: []byte{0x12, 0x34, 0x56, 0x78, 0x01, 0x02, 0x00},
|
||||||
wantHandle: 0x12345678,
|
wantHandle: 0x12345678,
|
||||||
wantUnk0: 1,
|
wantCreateType: 1,
|
||||||
wantPlayers: 2,
|
wantPlayers: 2,
|
||||||
wantStageID: "",
|
wantStageID: "",
|
||||||
},
|
},
|
||||||
@@ -491,7 +491,7 @@ func TestMsgSysCreateStageParse(t *testing.T) {
|
|||||||
name: "with null terminator",
|
name: "with null terminator",
|
||||||
data: append([]byte{0x00, 0x00, 0x00, 0x0A, 0x01, 0x01, 0x08}, append([]byte("stage01"), 0x00)...),
|
data: append([]byte{0x00, 0x00, 0x00, 0x0A, 0x01, 0x01, 0x08}, append([]byte("stage01"), 0x00)...),
|
||||||
wantHandle: 10,
|
wantHandle: 10,
|
||||||
wantUnk0: 1,
|
wantCreateType: 1,
|
||||||
wantPlayers: 1,
|
wantPlayers: 1,
|
||||||
wantStageID: "stage01",
|
wantStageID: "stage01",
|
||||||
},
|
},
|
||||||
@@ -512,8 +512,8 @@ func TestMsgSysCreateStageParse(t *testing.T) {
|
|||||||
if pkt.AckHandle != tt.wantHandle {
|
if pkt.AckHandle != tt.wantHandle {
|
||||||
t.Errorf("AckHandle = %d, want %d", pkt.AckHandle, tt.wantHandle)
|
t.Errorf("AckHandle = %d, want %d", pkt.AckHandle, tt.wantHandle)
|
||||||
}
|
}
|
||||||
if pkt.Unk0 != tt.wantUnk0 {
|
if pkt.CreateType != tt.wantCreateType {
|
||||||
t.Errorf("Unk0 = %d, want %d", pkt.Unk0, tt.wantUnk0)
|
t.Errorf("CreateType = %d, want %d", pkt.CreateType, tt.wantCreateType)
|
||||||
}
|
}
|
||||||
if pkt.PlayerCount != tt.wantPlayers {
|
if pkt.PlayerCount != tt.wantPlayers {
|
||||||
t.Errorf("PlayerCount = %d, want %d", pkt.PlayerCount, tt.wantPlayers)
|
t.Errorf("PlayerCount = %d, want %d", pkt.PlayerCount, tt.wantPlayers)
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import (
|
|||||||
// MsgSysCreateStage represents the MSG_SYS_CREATE_STAGE
|
// MsgSysCreateStage represents the MSG_SYS_CREATE_STAGE
|
||||||
type MsgSysCreateStage struct {
|
type MsgSysCreateStage struct {
|
||||||
AckHandle uint32
|
AckHandle uint32
|
||||||
Unk0 uint8 // Likely only has 1 and 2 as values.
|
CreateType uint8 // 1 = new stage (lobby, my house, quest), 2 = existing stage (guild room, move)
|
||||||
PlayerCount uint8
|
PlayerCount uint8
|
||||||
StageID string
|
StageID string
|
||||||
}
|
}
|
||||||
@@ -23,7 +23,7 @@ func (m *MsgSysCreateStage) Opcode() network.PacketID {
|
|||||||
// Parse parses the packet from binary
|
// Parse parses the packet from binary
|
||||||
func (m *MsgSysCreateStage) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
|
func (m *MsgSysCreateStage) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
|
||||||
m.AckHandle = bf.ReadUint32()
|
m.AckHandle = bf.ReadUint32()
|
||||||
m.Unk0 = bf.ReadUint8()
|
m.CreateType = bf.ReadUint8()
|
||||||
m.PlayerCount = bf.ReadUint8()
|
m.PlayerCount = bf.ReadUint8()
|
||||||
bf.ReadUint8() // Length StageID
|
bf.ReadUint8() // Length StageID
|
||||||
m.StageID = string(bf.ReadNullTerminatedBytes())
|
m.StageID = string(bf.ReadNullTerminatedBytes())
|
||||||
|
|||||||
@@ -66,8 +66,8 @@ func TestMsgSysCreateStageFields(t *testing.T) {
|
|||||||
if pkt.AckHandle != tt.ackHandle {
|
if pkt.AckHandle != tt.ackHandle {
|
||||||
t.Errorf("AckHandle = %d, want %d", pkt.AckHandle, tt.ackHandle)
|
t.Errorf("AckHandle = %d, want %d", pkt.AckHandle, tt.ackHandle)
|
||||||
}
|
}
|
||||||
if pkt.Unk0 != tt.unk0 {
|
if pkt.CreateType != tt.unk0 {
|
||||||
t.Errorf("Unk0 = %d, want %d", pkt.Unk0, tt.unk0)
|
t.Errorf("CreateType = %d, want %d", pkt.CreateType, tt.unk0)
|
||||||
}
|
}
|
||||||
if pkt.PlayerCount != tt.playerCount {
|
if pkt.PlayerCount != tt.playerCount {
|
||||||
t.Errorf("PlayerCount = %d, want %d", pkt.PlayerCount, tt.playerCount)
|
t.Errorf("PlayerCount = %d, want %d", pkt.PlayerCount, tt.playerCount)
|
||||||
|
|||||||
Reference in New Issue
Block a user