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:
Houmgaor
2026-02-19 00:46:57 +01:00
parent c2eba51b29
commit ba9fce153d
3 changed files with 12 additions and 12 deletions

View File

@@ -467,15 +467,15 @@ func TestMsgSysCreateStageParse(t *testing.T) {
name string
data []byte
wantHandle uint32
wantUnk0 uint8
wantPlayers uint8
wantStageID string
wantCreateType uint8
wantPlayers uint8
wantStageID string
}{
{
name: "simple stage",
data: append([]byte{0x00, 0x00, 0x00, 0x01, 0x02, 0x04, 0x05}, append([]byte("test"), 0x00)...),
wantHandle: 1,
wantUnk0: 2,
wantCreateType: 2,
wantPlayers: 4,
wantStageID: "test",
},
@@ -483,7 +483,7 @@ func TestMsgSysCreateStageParse(t *testing.T) {
name: "empty stage ID",
data: []byte{0x12, 0x34, 0x56, 0x78, 0x01, 0x02, 0x00},
wantHandle: 0x12345678,
wantUnk0: 1,
wantCreateType: 1,
wantPlayers: 2,
wantStageID: "",
},
@@ -491,7 +491,7 @@ func TestMsgSysCreateStageParse(t *testing.T) {
name: "with null terminator",
data: append([]byte{0x00, 0x00, 0x00, 0x0A, 0x01, 0x01, 0x08}, append([]byte("stage01"), 0x00)...),
wantHandle: 10,
wantUnk0: 1,
wantCreateType: 1,
wantPlayers: 1,
wantStageID: "stage01",
},
@@ -512,8 +512,8 @@ func TestMsgSysCreateStageParse(t *testing.T) {
if pkt.AckHandle != tt.wantHandle {
t.Errorf("AckHandle = %d, want %d", pkt.AckHandle, tt.wantHandle)
}
if pkt.Unk0 != tt.wantUnk0 {
t.Errorf("Unk0 = %d, want %d", pkt.Unk0, tt.wantUnk0)
if pkt.CreateType != tt.wantCreateType {
t.Errorf("CreateType = %d, want %d", pkt.CreateType, tt.wantCreateType)
}
if pkt.PlayerCount != tt.wantPlayers {
t.Errorf("PlayerCount = %d, want %d", pkt.PlayerCount, tt.wantPlayers)

View File

@@ -10,7 +10,7 @@ import (
// MsgSysCreateStage represents the MSG_SYS_CREATE_STAGE
type MsgSysCreateStage struct {
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
StageID string
}
@@ -23,7 +23,7 @@ func (m *MsgSysCreateStage) Opcode() network.PacketID {
// Parse parses the packet from binary
func (m *MsgSysCreateStage) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
m.AckHandle = bf.ReadUint32()
m.Unk0 = bf.ReadUint8()
m.CreateType = bf.ReadUint8()
m.PlayerCount = bf.ReadUint8()
bf.ReadUint8() // Length StageID
m.StageID = string(bf.ReadNullTerminatedBytes())

View File

@@ -66,8 +66,8 @@ func TestMsgSysCreateStageFields(t *testing.T) {
if pkt.AckHandle != tt.ackHandle {
t.Errorf("AckHandle = %d, want %d", pkt.AckHandle, tt.ackHandle)
}
if pkt.Unk0 != tt.unk0 {
t.Errorf("Unk0 = %d, want %d", pkt.Unk0, tt.unk0)
if pkt.CreateType != tt.unk0 {
t.Errorf("CreateType = %d, want %d", pkt.CreateType, tt.unk0)
}
if pkt.PlayerCount != tt.playerCount {
t.Errorf("PlayerCount = %d, want %d", pkt.PlayerCount, tt.playerCount)