refactor(mhfpacket): rename 15 Unk fields with identified meanings

Replace unknown field names with descriptive names based on handler
logic analysis, switch dispatch patterns, DB query context, and
inline comments:

- ObjectHandleID, IsQuest, ItemIDCount, MaxCount, TokenLength,
  FormatVersion, LogoutType (high confidence from comments/constants)
- QueryType, DataType, MissionIndex, CheckOnly, RequestType,
  ExchangeType, TournamentID (confirmed by handler switch/if usage)

Also fix MsgSysLogout.Build calling ReadUint8 instead of WriteUint8.
This commit is contained in:
Houmgaor
2026-02-18 21:48:08 +01:00
parent 2bd5f98f32
commit 0d07a1f698
35 changed files with 104 additions and 104 deletions

View File

@@ -564,8 +564,8 @@ func TestMsgSysEnterStageParse(t *testing.T) {
if pkt.AckHandle != tt.wantHandle {
t.Errorf("AckHandle = %d, want %d", pkt.AckHandle, tt.wantHandle)
}
if pkt.Unk != tt.wantUnk {
t.Errorf("Unk = %v, want %v", pkt.Unk, tt.wantUnk)
if pkt.IsQuest != tt.wantUnk {
t.Errorf("Unk = %v, want %v", pkt.IsQuest, tt.wantUnk)
}
if pkt.StageID != tt.wantStageID {
t.Errorf("StageID = %q, want %q", pkt.StageID, tt.wantStageID)
@@ -754,8 +754,8 @@ func TestMsgSysLogoutParse(t *testing.T) {
t.Fatalf("Parse() error = %v", err)
}
if pkt.Unk0 != tt.wantUnk0 {
t.Errorf("Unk0 = %d, want %d", pkt.Unk0, tt.wantUnk0)
if pkt.LogoutType != tt.wantUnk0 {
t.Errorf("Unk0 = %d, want %d", pkt.LogoutType, tt.wantUnk0)
}
})
}

View File

@@ -141,7 +141,7 @@ func TestBatchParseMultiField(t *testing.T) {
if err := pkt.Parse(bf, ctx); err != nil {
t.Fatal(err)
}
if pkt.AckHandle != 1 || pkt.DistType != 2 || pkt.Unk1 != 3 || pkt.Unk2 != 4 {
if pkt.AckHandle != 1 || pkt.DistType != 2 || pkt.Unk1 != 3 || pkt.MaxCount != 4 {
t.Error("field mismatch")
}
})
@@ -206,7 +206,7 @@ func TestBatchParseMultiField(t *testing.T) {
if err := pkt.Parse(bf, ctx); err != nil {
t.Fatal(err)
}
if pkt.AckHandle != 1 || pkt.Unk0 != 2 || pkt.WorldID != 3 || pkt.LandID != 4 || !pkt.Unk1 {
if pkt.AckHandle != 1 || pkt.Unk0 != 2 || pkt.WorldID != 3 || pkt.LandID != 4 || !pkt.CheckOnly {
t.Error("field mismatch")
}
})
@@ -316,7 +316,7 @@ func TestBatchParseMultiField(t *testing.T) {
if err := pkt.Parse(bf, ctx); err != nil {
t.Fatal(err)
}
if pkt.Unk2 != 4 {
if pkt.DataType != 4 {
t.Error("field mismatch")
}
})
@@ -433,7 +433,7 @@ func TestBatchParseMultiField(t *testing.T) {
if err := pkt.Parse(bf, ctx); err != nil {
t.Fatal(err)
}
if pkt.Unk0 != 2 {
if pkt.RequestType != 2 {
t.Error("field mismatch")
}
})

View File

@@ -359,7 +359,7 @@ func TestBuildParseUpdateObjectBinary(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
original := &MsgSysUpdateObjectBinary{
Unk0: tt.unk0,
ObjectHandleID: tt.unk0,
Unk1: tt.unk1,
}
@@ -374,8 +374,8 @@ func TestBuildParseUpdateObjectBinary(t *testing.T) {
t.Fatalf("Parse() error = %v", err)
}
if parsed.Unk0 != original.Unk0 {
t.Errorf("Unk0 = %d, want %d", parsed.Unk0, original.Unk0)
if parsed.ObjectHandleID != original.ObjectHandleID {
t.Errorf("Unk0 = %d, want %d", parsed.ObjectHandleID, original.ObjectHandleID)
}
if parsed.Unk1 != original.Unk1 {
t.Errorf("Unk1 = %d, want %d", parsed.Unk1, original.Unk1)
@@ -767,7 +767,7 @@ func TestBuildParseEnumerateDistItem(t *testing.T) {
AckHandle: tt.ackHandle,
DistType: tt.distType,
Unk1: tt.unk1,
Unk2: tt.unk2,
MaxCount: tt.unk2,
}
bf := byteframe.NewByteFrame()
@@ -775,7 +775,7 @@ func TestBuildParseEnumerateDistItem(t *testing.T) {
bf.WriteUint32(original.AckHandle)
bf.WriteUint8(original.DistType)
bf.WriteUint8(original.Unk1)
bf.WriteUint16(original.Unk2)
bf.WriteUint16(original.MaxCount)
bf.WriteUint8(0) // Unk3 length (for Z1+ client mode)
_, _ = bf.Seek(0, io.SeekStart)
@@ -793,8 +793,8 @@ func TestBuildParseEnumerateDistItem(t *testing.T) {
if parsed.Unk1 != original.Unk1 {
t.Errorf("Unk1 = %d, want %d", parsed.Unk1, original.Unk1)
}
if parsed.Unk2 != original.Unk2 {
t.Errorf("Unk2 = %d, want %d", parsed.Unk2, original.Unk2)
if parsed.MaxCount != original.MaxCount {
t.Errorf("Unk2 = %d, want %d", parsed.MaxCount, original.MaxCount)
}
})
}

View File

@@ -23,8 +23,8 @@ type MsgMhfAcquireUdItem struct {
// personal achievement = 6
// guild achievement = 7
RewardType uint8
Unk2 uint8 // Number of uint32s to read?
Unk3 []byte
ItemIDCount uint8
Unk3 []byte
}
// Opcode returns the ID associated with this packet type.
@@ -37,8 +37,8 @@ func (m *MsgMhfAcquireUdItem) Parse(bf *byteframe.ByteFrame, ctx *clientctx.Clie
m.AckHandle = bf.ReadUint32()
m.Unk0 = bf.ReadUint8()
m.RewardType = bf.ReadUint8()
m.Unk2 = bf.ReadUint8()
for i := uint8(0); i < m.Unk2; i++ {
m.ItemIDCount = bf.ReadUint8()
for i := uint8(0); i < m.ItemIDCount; i++ {
bf.ReadUint32()
}
return nil

View File

@@ -13,7 +13,7 @@ type MsgMhfEnumerateDistItem struct {
AckHandle uint32
DistType uint8
Unk1 uint8
Unk2 uint16
MaxCount uint16
Unk3 []byte
}
@@ -27,7 +27,7 @@ func (m *MsgMhfEnumerateDistItem) Parse(bf *byteframe.ByteFrame, ctx *clientctx.
m.AckHandle = bf.ReadUint32()
m.DistType = bf.ReadUint8()
m.Unk1 = bf.ReadUint8()
m.Unk2 = bf.ReadUint16() // Maximum? Hardcoded to 256
m.MaxCount = bf.ReadUint16() // Hardcoded to 256
if _config.ErupeConfig.RealClientMode >= _config.Z1 {
m.Unk3 = bf.ReadBytes(uint(bf.ReadUint8()))
}

View File

@@ -12,7 +12,7 @@ import (
type MsgMhfExchangeWeeklyStamp struct {
AckHandle uint32
StampType string
Unk1 uint8
ExchangeType uint8
}
// Opcode returns the ID associated with this packet type.
@@ -30,7 +30,7 @@ func (m *MsgMhfExchangeWeeklyStamp) Parse(bf *byteframe.ByteFrame, ctx *clientct
case 2:
m.StampType = "ex"
}
m.Unk1 = bf.ReadUint8()
m.ExchangeType = bf.ReadUint8()
bf.ReadUint16() // Zeroed
return nil
}

View File

@@ -11,7 +11,7 @@ import (
// MsgMhfGetGemInfo represents the MSG_MHF_GET_GEM_INFO
type MsgMhfGetGemInfo struct {
AckHandle uint32
Unk0 uint32
QueryType uint32
Unk1 uint32
Unk2 int32
Unk3 int32
@@ -28,7 +28,7 @@ func (m *MsgMhfGetGemInfo) Opcode() network.PacketID {
// Parse parses the packet from binary
func (m *MsgMhfGetGemInfo) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
m.AckHandle = bf.ReadUint32()
m.Unk0 = bf.ReadUint32()
m.QueryType = bf.ReadUint32()
m.Unk1 = bf.ReadUint32()
m.Unk2 = bf.ReadInt32()
m.Unk3 = bf.ReadInt32()

View File

@@ -12,9 +12,9 @@ import (
type MsgMhfGetPaperData struct {
// Communicator type, multi-format. This might be valid for only one type.
AckHandle uint32
Unk0 uint32
Unk1 uint32
Unk2 uint32
Unk0 uint32
Unk1 uint32
DataType uint32
}
// Opcode returns the ID associated with this packet type.
@@ -27,7 +27,7 @@ func (m *MsgMhfGetPaperData) Parse(bf *byteframe.ByteFrame, ctx *clientctx.Clien
m.AckHandle = bf.ReadUint32()
m.Unk0 = bf.ReadUint32()
m.Unk1 = bf.ReadUint32()
m.Unk2 = bf.ReadUint32()
m.DataType = bf.ReadUint32()
return nil
}

View File

@@ -11,11 +11,11 @@ import (
// MsgMhfGetTenrouirai represents the MSG_MHF_GET_TENROUIRAI
type MsgMhfGetTenrouirai struct {
AckHandle uint32
Unk0 uint8
Unk1 uint8
GuildID uint32
Unk3 uint8
Unk4 uint8
Unk0 uint8
DataType uint8
GuildID uint32
MissionIndex uint8
Unk4 uint8
}
// Opcode returns the ID associated with this packet type.
@@ -27,9 +27,9 @@ func (m *MsgMhfGetTenrouirai) Opcode() network.PacketID {
func (m *MsgMhfGetTenrouirai) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
m.AckHandle = bf.ReadUint32()
m.Unk0 = bf.ReadUint8()
m.Unk1 = bf.ReadUint8()
m.DataType = bf.ReadUint8()
m.GuildID = bf.ReadUint32()
m.Unk3 = bf.ReadUint8()
m.MissionIndex = bf.ReadUint8()
m.Unk4 = bf.ReadUint8()
return nil
}

View File

@@ -11,8 +11,8 @@ import (
// MsgMhfInfoTournament represents the MSG_MHF_INFO_TOURNAMENT
type MsgMhfInfoTournament struct {
AckHandle uint32
Unk0 uint8
Unk1 uint32
QueryType uint8
TournamentID uint32
}
// Opcode returns the ID associated with this packet type.
@@ -23,8 +23,8 @@ func (m *MsgMhfInfoTournament) Opcode() network.PacketID {
// Parse parses the packet from binary
func (m *MsgMhfInfoTournament) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
m.AckHandle = bf.ReadUint32()
m.Unk0 = bf.ReadUint8()
m.Unk1 = bf.ReadUint32()
m.QueryType = bf.ReadUint8()
m.TournamentID = bf.ReadUint32()
return nil
}

View File

@@ -11,7 +11,7 @@ import (
// MsgMhfMercenaryHuntdata represents the MSG_MHF_MERCENARY_HUNTDATA
type MsgMhfMercenaryHuntdata struct {
AckHandle uint32
Unk0 uint8
RequestType uint8
}
// Opcode returns the ID associated with this packet type.
@@ -22,7 +22,7 @@ func (m *MsgMhfMercenaryHuntdata) Opcode() network.PacketID {
// Parse parses the packet from binary
func (m *MsgMhfMercenaryHuntdata) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
m.AckHandle = bf.ReadUint32()
m.Unk0 = bf.ReadUint8()
m.RequestType = bf.ReadUint8()
return nil
}

View File

@@ -12,7 +12,7 @@ type MsgMhfRegisterEvent struct {
Unk0 uint16
WorldID uint16
LandID uint16
Unk1 bool
CheckOnly bool
}
// Opcode returns the ID associated with this packet type.
@@ -26,7 +26,7 @@ func (m *MsgMhfRegisterEvent) Parse(bf *byteframe.ByteFrame, ctx *clientctx.Clie
m.Unk0 = bf.ReadUint16()
m.WorldID = bf.ReadUint16()
m.LandID = bf.ReadUint16()
m.Unk1 = bf.ReadBool()
m.CheckOnly = bf.ReadBool()
bf.ReadUint8() // Zeroed
return nil
}

View File

@@ -11,7 +11,7 @@ import (
// MsgMhfSetEnhancedMinidata represents the MSG_MHF_SET_ENHANCED_MINIDATA
type MsgMhfSetEnhancedMinidata struct {
AckHandle uint32
Unk0 uint16 // Hardcoded 4 in the binary.
FormatVersion uint16 // Hardcoded 4 in the binary.
RawDataPayload []byte
}
@@ -23,7 +23,7 @@ func (m *MsgMhfSetEnhancedMinidata) Opcode() network.PacketID {
// Parse parses the packet from binary
func (m *MsgMhfSetEnhancedMinidata) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
m.AckHandle = bf.ReadUint32()
m.Unk0 = bf.ReadUint16()
m.FormatVersion = bf.ReadUint16()
m.RawDataPayload = bf.ReadBytes(0x400)
return nil
}

View File

@@ -298,7 +298,7 @@ func TestBuildCoverage_Implemented(t *testing.T) {
defer func() {
_ = recover() // may panic due to bug
}()
pkt := &MsgSysLogout{Unk0: 1}
pkt := &MsgSysLogout{LogoutType: 1}
bf := byteframe.NewByteFrame()
_ = pkt.Build(bf, ctx)
})

View File

@@ -16,7 +16,7 @@ func TestParseLargeMsgSysUpdateRightBuild(t *testing.T) {
ClientRespAckHandle: 0x12345678,
Bitfield: 0xDEADBEEF,
Rights: nil,
UnkSize: 0,
TokenLength: 0,
}
bf := byteframe.NewByteFrame()

View File

@@ -123,8 +123,8 @@ func TestParseSmallLogout(t *testing.T) {
if err != nil {
t.Fatalf("Parse() error = %v", err)
}
if pkt.Unk0 != tt.unk0 {
t.Errorf("Unk0 = %d, want %d", pkt.Unk0, tt.unk0)
if pkt.LogoutType != tt.unk0 {
t.Errorf("Unk0 = %d, want %d", pkt.LogoutType, tt.unk0)
}
})
}

View File

@@ -124,8 +124,8 @@ func TestMsgSysLogoutDetailedParse(t *testing.T) {
t.Fatalf("Parse() error = %v", err)
}
if pkt.Unk0 != tt.unk0 {
t.Errorf("Unk0 = %d, want %d", pkt.Unk0, tt.unk0)
if pkt.LogoutType != tt.unk0 {
t.Errorf("Unk0 = %d, want %d", pkt.LogoutType, tt.unk0)
}
}
}

View File

@@ -11,7 +11,7 @@ import (
// MsgSysEnterStage represents the MSG_SYS_ENTER_STAGE
type MsgSysEnterStage struct {
AckHandle uint32
Unk bool
IsQuest bool
StageID string
}
@@ -23,7 +23,7 @@ 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.Unk = bf.ReadBool() // IsQuest?
m.IsQuest = bf.ReadBool()
bf.ReadUint8() // Length StageID
m.StageID = string(bf.ReadNullTerminatedBytes())
return nil

View File

@@ -8,7 +8,7 @@ import (
// MsgSysLogout represents the MSG_SYS_LOGOUT
type MsgSysLogout struct {
Unk0 uint8 // Hardcoded 1 in binary
LogoutType uint8 // Hardcoded 1 in binary
}
// Opcode returns the ID associated with this packet type.
@@ -18,12 +18,12 @@ func (m *MsgSysLogout) Opcode() network.PacketID {
// Parse parses the packet from binary
func (m *MsgSysLogout) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
m.Unk0 = bf.ReadUint8()
m.LogoutType = bf.ReadUint8()
return nil
}
// Build builds a binary packet from the current data.
func (m *MsgSysLogout) Build(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
m.Unk0 = bf.ReadUint8()
bf.WriteUint8(m.LogoutType)
return nil
}

View File

@@ -110,8 +110,8 @@ func TestMsgSysEnterStageFields(t *testing.T) {
if pkt.AckHandle != tt.handle {
t.Errorf("AckHandle = %d, want %d", pkt.AckHandle, tt.handle)
}
if pkt.Unk != tt.unk {
t.Errorf("Unk = %v, want %v", pkt.Unk, tt.unk)
if pkt.IsQuest != tt.unk {
t.Errorf("Unk = %v, want %v", pkt.IsQuest, tt.unk)
}
if pkt.StageID != tt.stageID {
t.Errorf("StageID = %q, want %q", pkt.StageID, tt.stageID)

View File

@@ -8,8 +8,8 @@ import (
// MsgSysUpdateObjectBinary represents the MSG_SYS_UPDATE_OBJECT_BINARY
type MsgSysUpdateObjectBinary struct {
Unk0 uint32 // Object handle ID
Unk1 uint32
ObjectHandleID uint32
Unk1 uint32
}
// Opcode returns the ID associated with this packet type.
@@ -19,14 +19,14 @@ func (m *MsgSysUpdateObjectBinary) Opcode() network.PacketID {
// Parse parses the packet from binary
func (m *MsgSysUpdateObjectBinary) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
m.Unk0 = bf.ReadUint32()
m.ObjectHandleID = bf.ReadUint32()
m.Unk1 = bf.ReadUint32()
return nil
}
// Build builds a binary packet from the current data.
func (m *MsgSysUpdateObjectBinary) Build(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
bf.WriteUint32(m.Unk0)
bf.WriteUint32(m.ObjectHandleID)
bf.WriteUint32(m.Unk1)
return nil
}

View File

@@ -14,7 +14,7 @@ type MsgSysUpdateRight struct {
ClientRespAckHandle uint32 // If non-0, requests the client to send back a MSG_SYS_ACK packet with this value.
Bitfield uint32
Rights []mhfcourse.Course
UnkSize uint16 // Count of some buf up to 0x800 bytes following it.
TokenLength uint16 // Length of the login token/password buffer (up to 0x800 bytes).
}
// Opcode returns the ID associated with this packet type.

View File

@@ -134,13 +134,13 @@ func TestHandleMsgMhfOperationInvGuild(t *testing.T) {
// Tests for mercenary handlers that do not require database access.
func TestHandleMsgMhfMercenaryHuntdata_Unk0Is1(t *testing.T) {
func TestHandleMsgMhfMercenaryHuntdata_RequestTypeIs1(t *testing.T) {
server := createMockServer()
session := createMockSession(1, server)
pkt := &mhfpacket.MsgMhfMercenaryHuntdata{
AckHandle: 12345,
Unk0: 1,
RequestType: 1,
}
handleMsgMhfMercenaryHuntdata(session, pkt)
@@ -155,13 +155,13 @@ func TestHandleMsgMhfMercenaryHuntdata_Unk0Is1(t *testing.T) {
}
}
func TestHandleMsgMhfMercenaryHuntdata_Unk0Is0(t *testing.T) {
func TestHandleMsgMhfMercenaryHuntdata_RequestTypeIs0(t *testing.T) {
server := createMockServer()
session := createMockSession(1, server)
pkt := &mhfpacket.MsgMhfMercenaryHuntdata{
AckHandle: 12345,
Unk0: 0,
RequestType: 0,
}
handleMsgMhfMercenaryHuntdata(session, pkt)
@@ -176,18 +176,18 @@ func TestHandleMsgMhfMercenaryHuntdata_Unk0Is0(t *testing.T) {
}
}
func TestHandleMsgMhfMercenaryHuntdata_Unk0Is2(t *testing.T) {
func TestHandleMsgMhfMercenaryHuntdata_RequestTypeIs2(t *testing.T) {
server := createMockServer()
session := createMockSession(1, server)
pkt := &mhfpacket.MsgMhfMercenaryHuntdata{
AckHandle: 12345,
Unk0: 2,
RequestType: 2,
}
handleMsgMhfMercenaryHuntdata(session, pkt)
// Unk0=2 takes the else branch (same as 0)
// RequestType=2 takes the else branch (same as 0)
select {
case p := <-session.sendPackets:
if len(p.data) == 0 {
@@ -557,7 +557,7 @@ func TestHandlersConcurrentInvocations(t *testing.T) {
handleMsgSysIssueLogkey(session, &mhfpacket.MsgSysIssueLogkey{AckHandle: id})
<-session.sendPackets
handleMsgMhfMercenaryHuntdata(session, &mhfpacket.MsgMhfMercenaryHuntdata{AckHandle: id, Unk0: 1})
handleMsgMhfMercenaryHuntdata(session, &mhfpacket.MsgMhfMercenaryHuntdata{AckHandle: id, RequestType: 1})
<-session.sendPackets
handleMsgMhfEnumerateMercenaryLog(session, &mhfpacket.MsgMhfEnumerateMercenaryLog{AckHandle: id})

View File

@@ -640,7 +640,7 @@ func TestNonTrivialHandlers_TowerGo(t *testing.T) {
handleMsgMhfGetTenrouirai(s, &mhfpacket.MsgMhfGetTenrouirai{AckHandle: 1, Unk0: 1})
}},
{"handleMsgMhfGetTenrouirai_Unknown", func(s *Session) {
handleMsgMhfGetTenrouirai(s, &mhfpacket.MsgMhfGetTenrouirai{AckHandle: 1, Unk0: 0, Unk1: 0})
handleMsgMhfGetTenrouirai(s, &mhfpacket.MsgMhfGetTenrouirai{AckHandle: 1, Unk0: 0, DataType: 0})
}},
// handleMsgMhfGetTenrouirai_Type4, handleMsgMhfPostTenrouirai, handleMsgMhfGetGemInfo removed: require DB
{"handleMsgMhfGetWeeklySeibatuRankingReward", func(s *Session) {

View File

@@ -17,7 +17,7 @@ func TestHandleMsgMhfGetPaperData_Case0(t *testing.T) {
handleMsgMhfGetPaperData(session, &mhfpacket.MsgMhfGetPaperData{
AckHandle: 1,
Unk2: 0,
DataType: 0,
})
select {
@@ -36,7 +36,7 @@ func TestHandleMsgMhfGetPaperData_Case5(t *testing.T) {
handleMsgMhfGetPaperData(session, &mhfpacket.MsgMhfGetPaperData{
AckHandle: 1,
Unk2: 5,
DataType: 5,
})
select {
@@ -55,7 +55,7 @@ func TestHandleMsgMhfGetPaperData_Case6(t *testing.T) {
handleMsgMhfGetPaperData(session, &mhfpacket.MsgMhfGetPaperData{
AckHandle: 1,
Unk2: 6,
DataType: 6,
})
select {
@@ -75,7 +75,7 @@ func TestHandleMsgMhfGetPaperData_GreaterThan1000_KnownKey(t *testing.T) {
// 6001 is a known key in paperGiftData
handleMsgMhfGetPaperData(session, &mhfpacket.MsgMhfGetPaperData{
AckHandle: 1,
Unk2: 6001,
DataType: 6001,
})
select {
@@ -95,7 +95,7 @@ func TestHandleMsgMhfGetPaperData_GreaterThan1000_UnknownKey(t *testing.T) {
// 9999 is not a known key in paperGiftData
handleMsgMhfGetPaperData(session, &mhfpacket.MsgMhfGetPaperData{
AckHandle: 1,
Unk2: 9999,
DataType: 9999,
})
select {
@@ -114,7 +114,7 @@ func TestHandleMsgMhfGetPaperData_DefaultUnknownLessThan1000(t *testing.T) {
// Unknown type < 1000, hits default case then falls to else branch
handleMsgMhfGetPaperData(session, &mhfpacket.MsgMhfGetPaperData{
AckHandle: 1,
Unk2: 99,
DataType: 99,
})
select {

View File

@@ -60,7 +60,7 @@ func handleMsgMhfGetPaperData(s *Session, p mhfpacket.MHFPacket) {
var paperMissions PaperMission
var paperGift []PaperGift
switch pkt.Unk2 {
switch pkt.DataType {
case 0:
paperMissions = PaperMission{
[]PaperMissionTimetable{{TimeMidnight(), TimeMidnight().Add(24 * time.Hour)}},
@@ -565,17 +565,17 @@ func handleMsgMhfGetPaperData(s *Session, p mhfpacket.MHFPacket) {
{4202, 2, 0, 11469, 1, 1400, 1},
}
default:
if pkt.Unk2 < 1000 {
s.logger.Info("PaperData request for unknown type", zap.Uint32("Unk2", pkt.Unk2))
if pkt.DataType < 1000 {
s.logger.Info("PaperData request for unknown type", zap.Uint32("DataType", pkt.DataType))
}
}
if pkt.Unk2 > 1000 {
_, ok := paperGiftData[pkt.Unk2]
if pkt.DataType > 1000 {
_, ok := paperGiftData[pkt.DataType]
if ok {
paperGift = paperGiftData[pkt.Unk2]
paperGift = paperGiftData[pkt.DataType]
} else {
s.logger.Info("PaperGift request for unknown type", zap.Uint32("Unk2", pkt.Unk2))
s.logger.Info("PaperGift request for unknown type", zap.Uint32("DataType", pkt.DataType))
}
for _, gift := range paperGift {
bf := byteframe.NewByteFrame()
@@ -586,7 +586,7 @@ func handleMsgMhfGetPaperData(s *Session, p mhfpacket.MHFPacket) {
data = append(data, bf)
}
doAckEarthSucceed(s, pkt.AckHandle, data)
} else if pkt.Unk2 == 0 {
} else if pkt.DataType == 0 {
bf := byteframe.NewByteFrame()
bf.WriteUint16(uint16(len(paperMissions.Timetables)))
bf.WriteUint16(uint16(len(paperMissions.Data)))

View File

@@ -70,7 +70,7 @@ func updateRights(s *Session) {
ClientRespAckHandle: 0,
Bitfield: rightsInt,
Rights: s.courses,
UnkSize: 0,
TokenLength: 0,
}
s.QueueSendMHFNonBlocking(update)
}

View File

@@ -261,7 +261,7 @@ func handleMsgMhfExchangeWeeklyStamp(s *Session, p mhfpacket.MHFPacket) {
pkt := p.(*mhfpacket.MsgMhfExchangeWeeklyStamp)
var total, redeemed uint16
var tktStack mhfitem.MHFItemStack
if pkt.Unk1 == 10 { // Yearly Sub Ex
if pkt.ExchangeType == 10 { // Yearly Sub Ex
_ = s.server.db.QueryRow("UPDATE stamps SET hl_total=hl_total-48, hl_redeemed=hl_redeemed-48 WHERE character_id=$1 RETURNING hl_total, hl_redeemed", s.charID).Scan(&total, &redeemed)
tktStack = mhfitem.MHFItemStack{Item: mhfitem.MHFItem{ItemID: 2210}, Quantity: 1}
} else {

View File

@@ -148,7 +148,7 @@ func handleMsgMhfSaveHunterNavi(s *Session, p mhfpacket.MHFPacket) {
func handleMsgMhfMercenaryHuntdata(s *Session, p mhfpacket.MHFPacket) {
pkt := p.(*mhfpacket.MsgMhfMercenaryHuntdata)
if pkt.Unk0 == 1 {
if pkt.RequestType == 1 {
// Format:
// uint8 Hunts
// struct Hunt

View File

@@ -239,7 +239,7 @@ func TestHandleMsgMhfMercenaryHuntdata_Unk0_1(t *testing.T) {
pkt := &mhfpacket.MsgMhfMercenaryHuntdata{
AckHandle: 12345,
Unk0: 1,
RequestType: 1,
}
handleMsgMhfMercenaryHuntdata(session, pkt)
@@ -261,7 +261,7 @@ func TestHandleMsgMhfMercenaryHuntdata_Unk0_0(t *testing.T) {
pkt := &mhfpacket.MsgMhfMercenaryHuntdata{
AckHandle: 12345,
Unk0: 0,
RequestType: 0,
}
handleMsgMhfMercenaryHuntdata(session, pkt)

View File

@@ -9,7 +9,7 @@ func handleMsgMhfRegisterEvent(s *Session, p mhfpacket.MHFPacket) {
pkt := p.(*mhfpacket.MsgMhfRegisterEvent)
bf := byteframe.NewByteFrame()
// Some kind of check if there's already a session
if pkt.Unk1 && s.server.getRaviSemaphore() == nil {
if pkt.CheckOnly && s.server.getRaviSemaphore() == nil {
doAckSimpleSucceed(s, pkt.AckHandle, make([]byte, 4))
return
}

View File

@@ -54,7 +54,7 @@ func handleMsgMhfInfoTournament(s *Session, p mhfpacket.MHFPacket) {
tournamentInfo21 := []TournamentInfo21{}
tournamentInfo22 := []TournamentInfo22{}
switch pkt.Unk0 {
switch pkt.QueryType {
case 0:
bf.WriteUint32(0)
bf.WriteUint32(uint32(len(tournamentInfo0)))

View File

@@ -12,7 +12,7 @@ func TestHandleMsgMhfInfoTournament_Type0(t *testing.T) {
pkt := &mhfpacket.MsgMhfInfoTournament{
AckHandle: 12345,
Unk0: 0,
QueryType: 0,
}
handleMsgMhfInfoTournament(session, pkt)
@@ -34,7 +34,7 @@ func TestHandleMsgMhfInfoTournament_Type1(t *testing.T) {
pkt := &mhfpacket.MsgMhfInfoTournament{
AckHandle: 12345,
Unk0: 1,
QueryType: 1,
}
handleMsgMhfInfoTournament(session, pkt)

View File

@@ -273,7 +273,7 @@ func handleMsgMhfGetTenrouirai(s *Session, p mhfpacket.MHFPacket) {
Ticket: []TenrouiraiTicket{{0, 0, 0}},
}
switch pkt.Unk1 {
switch pkt.DataType {
case 1:
for _, tdata := range tenrouirai.Data {
bf := byteframe.NewByteFrame()
@@ -329,13 +329,13 @@ func handleMsgMhfGetTenrouirai(s *Session, p mhfpacket.MHFPacket) {
data = append(data, bf)
}
case 5:
if pkt.Unk3 > 3 {
pkt.Unk3 %= 3
if pkt.Unk3 == 0 {
pkt.Unk3 = 3
if pkt.MissionIndex > 3 {
pkt.MissionIndex %= 3
if pkt.MissionIndex == 0 {
pkt.MissionIndex = 3
}
}
rows, err := s.server.db.Query(fmt.Sprintf(`SELECT name, tower_mission_%d FROM guild_characters gc INNER JOIN characters c ON gc.character_id = c.id WHERE guild_id=$1 AND tower_mission_%d IS NOT NULL ORDER BY tower_mission_%d DESC`, pkt.Unk3, pkt.Unk3, pkt.Unk3), pkt.GuildID)
rows, err := s.server.db.Query(fmt.Sprintf(`SELECT name, tower_mission_%d FROM guild_characters gc INNER JOIN characters c ON gc.character_id = c.id WHERE guild_id=$1 AND tower_mission_%d IS NOT NULL ORDER BY tower_mission_%d DESC`, pkt.MissionIndex, pkt.MissionIndex, pkt.MissionIndex), pkt.GuildID)
if err != nil {
s.logger.Error("Failed to query tower mission scores", zap.Error(err))
} else {
@@ -470,7 +470,7 @@ func handleMsgMhfGetGemInfo(s *Session, p mhfpacket.MHFPacket) {
gemInfo = append(gemInfo, GemInfo{uint16((i / 5 << 8) + (i%5 + 1)), uint16(v)})
}
switch pkt.Unk0 {
switch pkt.QueryType {
case 1:
for _, info := range gemInfo {
bf := byteframe.NewByteFrame()

View File

@@ -35,7 +35,7 @@ func TestHandleMsgMhfGetTenrouirai_Default(t *testing.T) {
pkt := &mhfpacket.MsgMhfGetTenrouirai{
AckHandle: 12345,
Unk0: 0,
Unk1: 0,
DataType: 0,
}
handleMsgMhfGetTenrouirai(session, pkt)