mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-26 17:43:21 +01:00
fix(items): stop G-rank Workshop/Cog softlock on missing ACK
MSG_MHF_GET_EXTRA_INFO (0xA6) and MSG_MHF_GET_COG_INFO (0xC3) had Parse() returning NOT IMPLEMENTED. The dispatch loop treats any Parse error as a hard drop — no ACK is ever sent, so the client waits indefinitely and effectively soft-locks when entering the G-rank Workshop or Master Felyne (Cog) screens. Fix: parse AckHandle (the only field we can confirm from the protocol) and respond with doAckBufFail so the client receives a well-formed buf-type ACK with error code 1. The client's fail branch for these requests exits cleanly without reading response fields, avoiding the read-past-EOF crash that an empty success ACK would cause. The full response format for both packets is still unknown; a complete implementation requires further RE. The TODO comments mark the gap. Fixes #180.
This commit is contained in:
@@ -15,7 +15,7 @@ All empty handlers carry an inline comment — `// stub: unimplemented` for real
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Unimplemented (70 handlers)
|
## Unimplemented (68 handlers)
|
||||||
|
|
||||||
Grouped by handler file / game subsystem.
|
Grouped by handler file / game subsystem.
|
||||||
|
|
||||||
@@ -77,8 +77,6 @@ Grouped by handler file / game subsystem.
|
|||||||
|
|
||||||
| Handler | Notes |
|
| Handler | Notes |
|
||||||
|---------|-------|
|
|---------|-------|
|
||||||
| `handleMsgMhfGetExtraInfo` | Fetch supplemental item/character info |
|
|
||||||
| `handleMsgMhfGetCogInfo` | Fetch Cog (partner Felyne) information |
|
|
||||||
| `handleMsgMhfStampcardPrize` | Claim a stamp card prize |
|
| `handleMsgMhfStampcardPrize` | Claim a stamp card prize |
|
||||||
|
|
||||||
### Misc (`handlers_misc.go`)
|
### Misc (`handlers_misc.go`)
|
||||||
|
|||||||
@@ -1594,7 +1594,6 @@ func TestBatchParseNotImplemented(t *testing.T) {
|
|||||||
&MsgSysDispObject{}, &MsgSysHideObject{},
|
&MsgSysDispObject{}, &MsgSysHideObject{},
|
||||||
&MsgMhfServerCommand{}, &MsgMhfSetLoginwindow{}, &MsgMhfShutClient{},
|
&MsgMhfServerCommand{}, &MsgMhfSetLoginwindow{}, &MsgMhfShutClient{},
|
||||||
&MsgMhfUpdateGuildcard{},
|
&MsgMhfUpdateGuildcard{},
|
||||||
&MsgMhfGetCogInfo{},
|
|
||||||
&MsgCaExchangeItem{},
|
&MsgCaExchangeItem{},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -495,6 +495,8 @@ func TestAckHandlePacketsParse(t *testing.T) {
|
|||||||
{"MsgMhfGetUdSchedule", network.MSG_MHF_GET_UD_SCHEDULE},
|
{"MsgMhfGetUdSchedule", network.MSG_MHF_GET_UD_SCHEDULE},
|
||||||
{"MsgMhfGetUdInfo", network.MSG_MHF_GET_UD_INFO},
|
{"MsgMhfGetUdInfo", network.MSG_MHF_GET_UD_INFO},
|
||||||
{"MsgMhfGetKijuInfo", network.MSG_MHF_GET_KIJU_INFO},
|
{"MsgMhfGetKijuInfo", network.MSG_MHF_GET_KIJU_INFO},
|
||||||
|
{"MsgMhfGetExtraInfo", network.MSG_MHF_GET_EXTRA_INFO},
|
||||||
|
{"MsgMhfGetCogInfo", network.MSG_MHF_GET_COG_INFO},
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx := &clientctx.ClientContext{RealClientMode: cfg.ZZ}
|
ctx := &clientctx.ClientContext{RealClientMode: cfg.ZZ}
|
||||||
|
|||||||
@@ -9,7 +9,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// MsgMhfGetCogInfo represents the MSG_MHF_GET_COG_INFO
|
// MsgMhfGetCogInfo represents the MSG_MHF_GET_COG_INFO
|
||||||
type MsgMhfGetCogInfo struct{}
|
type MsgMhfGetCogInfo struct {
|
||||||
|
AckHandle uint32
|
||||||
|
}
|
||||||
|
|
||||||
// Opcode returns the ID associated with this packet type.
|
// Opcode returns the ID associated with this packet type.
|
||||||
func (m *MsgMhfGetCogInfo) Opcode() network.PacketID {
|
func (m *MsgMhfGetCogInfo) Opcode() network.PacketID {
|
||||||
@@ -18,7 +20,8 @@ func (m *MsgMhfGetCogInfo) Opcode() network.PacketID {
|
|||||||
|
|
||||||
// Parse parses the packet from binary
|
// Parse parses the packet from binary
|
||||||
func (m *MsgMhfGetCogInfo) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
|
func (m *MsgMhfGetCogInfo) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
|
||||||
return errors.New("NOT IMPLEMENTED")
|
m.AckHandle = bf.ReadUint32()
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build builds a binary packet from the current data.
|
// Build builds a binary packet from the current data.
|
||||||
|
|||||||
@@ -9,7 +9,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// MsgMhfGetExtraInfo represents the MSG_MHF_GET_EXTRA_INFO
|
// MsgMhfGetExtraInfo represents the MSG_MHF_GET_EXTRA_INFO
|
||||||
type MsgMhfGetExtraInfo struct{}
|
type MsgMhfGetExtraInfo struct {
|
||||||
|
AckHandle uint32
|
||||||
|
}
|
||||||
|
|
||||||
// Opcode returns the ID associated with this packet type.
|
// Opcode returns the ID associated with this packet type.
|
||||||
func (m *MsgMhfGetExtraInfo) Opcode() network.PacketID {
|
func (m *MsgMhfGetExtraInfo) Opcode() network.PacketID {
|
||||||
@@ -18,7 +20,8 @@ func (m *MsgMhfGetExtraInfo) Opcode() network.PacketID {
|
|||||||
|
|
||||||
// Parse parses the packet from binary
|
// Parse parses the packet from binary
|
||||||
func (m *MsgMhfGetExtraInfo) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
|
func (m *MsgMhfGetExtraInfo) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
|
||||||
return errors.New("NOT IMPLEMENTED")
|
m.AckHandle = bf.ReadUint32()
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build builds a binary packet from the current data.
|
// Build builds a binary packet from the current data.
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ func TestParseSmallNotImplemented(t *testing.T) {
|
|||||||
{"MsgMhfGetCaUniqueID", &MsgMhfGetCaUniqueID{}},
|
{"MsgMhfGetCaUniqueID", &MsgMhfGetCaUniqueID{}},
|
||||||
{"MsgMhfGetDailyMissionMaster", &MsgMhfGetDailyMissionMaster{}},
|
{"MsgMhfGetDailyMissionMaster", &MsgMhfGetDailyMissionMaster{}},
|
||||||
{"MsgMhfGetDailyMissionPersonal", &MsgMhfGetDailyMissionPersonal{}},
|
{"MsgMhfGetDailyMissionPersonal", &MsgMhfGetDailyMissionPersonal{}},
|
||||||
{"MsgMhfGetExtraInfo", &MsgMhfGetExtraInfo{}},
|
|
||||||
{"MsgMhfGetRestrictionEvent", &MsgMhfGetRestrictionEvent{}},
|
{"MsgMhfGetRestrictionEvent", &MsgMhfGetRestrictionEvent{}},
|
||||||
{"MsgMhfKickExportForce", &MsgMhfKickExportForce{}},
|
{"MsgMhfKickExportForce", &MsgMhfKickExportForce{}},
|
||||||
{"MsgMhfPaymentAchievement", &MsgMhfPaymentAchievement{}},
|
{"MsgMhfPaymentAchievement", &MsgMhfPaymentAchievement{}},
|
||||||
@@ -196,6 +195,38 @@ func TestParseSmallEnumerateHouse(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TestParseSmallGetExtraInfoAndCogInfo tests that MsgMhfGetExtraInfo and
|
||||||
|
// MsgMhfGetCogInfo correctly parse their AckHandle field.
|
||||||
|
func TestParseSmallGetExtraInfoAndCogInfo(t *testing.T) {
|
||||||
|
ctx := &clientctx.ClientContext{RealClientMode: cfg.ZZ}
|
||||||
|
|
||||||
|
t.Run("GetExtraInfo", func(t *testing.T) {
|
||||||
|
bf := byteframe.NewByteFrame()
|
||||||
|
bf.WriteUint32(0xDEADBEEF)
|
||||||
|
_, _ = bf.Seek(0, io.SeekStart)
|
||||||
|
pkt := &MsgMhfGetExtraInfo{}
|
||||||
|
if err := pkt.Parse(bf, ctx); err != nil {
|
||||||
|
t.Fatalf("Parse() error = %v", err)
|
||||||
|
}
|
||||||
|
if pkt.AckHandle != 0xDEADBEEF {
|
||||||
|
t.Errorf("AckHandle = 0x%X, want 0xDEADBEEF", pkt.AckHandle)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("GetCogInfo", func(t *testing.T) {
|
||||||
|
bf := byteframe.NewByteFrame()
|
||||||
|
bf.WriteUint32(0xCAFEBABE)
|
||||||
|
_, _ = bf.Seek(0, io.SeekStart)
|
||||||
|
pkt := &MsgMhfGetCogInfo{}
|
||||||
|
if err := pkt.Parse(bf, ctx); err != nil {
|
||||||
|
t.Fatalf("Parse() error = %v", err)
|
||||||
|
}
|
||||||
|
if pkt.AckHandle != 0xCAFEBABE {
|
||||||
|
t.Errorf("AckHandle = 0x%X, want 0xCAFEBABE", pkt.AckHandle)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// TestParseSmallNotImplementedDoesNotPanic ensures that calling Parse on NOT IMPLEMENTED
|
// TestParseSmallNotImplementedDoesNotPanic ensures that calling Parse on NOT IMPLEMENTED
|
||||||
// packets returns an error and does not panic.
|
// packets returns an error and does not panic.
|
||||||
func TestParseSmallNotImplementedDoesNotPanic(t *testing.T) {
|
func TestParseSmallNotImplementedDoesNotPanic(t *testing.T) {
|
||||||
|
|||||||
@@ -55,7 +55,11 @@ func handleMsgMhfEnumerateOrder(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
stubEnumerateNoResults(s, pkt.AckHandle)
|
stubEnumerateNoResults(s, pkt.AckHandle)
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleMsgMhfGetExtraInfo(s *Session, p mhfpacket.MHFPacket) {} // stub: unimplemented
|
func handleMsgMhfGetExtraInfo(s *Session, p mhfpacket.MHFPacket) {
|
||||||
|
pkt := p.(*mhfpacket.MsgMhfGetExtraInfo)
|
||||||
|
// TODO: response structure unknown; fail ACK prevents softlock without misleading client
|
||||||
|
doAckBufFail(s, pkt.AckHandle, nil)
|
||||||
|
}
|
||||||
|
|
||||||
func userGetItems(s *Session) []mhfitem.MHFItemStack {
|
func userGetItems(s *Session) []mhfitem.MHFItemStack {
|
||||||
var items []mhfitem.MHFItemStack
|
var items []mhfitem.MHFItemStack
|
||||||
@@ -91,7 +95,11 @@ func handleMsgMhfUpdateUnionItem(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
doAckSimpleSucceed(s, pkt.AckHandle, make([]byte, 4))
|
doAckSimpleSucceed(s, pkt.AckHandle, make([]byte, 4))
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleMsgMhfGetCogInfo(s *Session, p mhfpacket.MHFPacket) {} // stub: unimplemented
|
func handleMsgMhfGetCogInfo(s *Session, p mhfpacket.MHFPacket) {
|
||||||
|
pkt := p.(*mhfpacket.MsgMhfGetCogInfo)
|
||||||
|
// TODO: response structure unknown; fail ACK prevents softlock without misleading client
|
||||||
|
doAckBufFail(s, pkt.AckHandle, nil)
|
||||||
|
}
|
||||||
|
|
||||||
func handleMsgMhfCheckWeeklyStamp(s *Session, p mhfpacket.MHFPacket) {
|
func handleMsgMhfCheckWeeklyStamp(s *Session, p mhfpacket.MHFPacket) {
|
||||||
pkt := p.(*mhfpacket.MsgMhfCheckWeeklyStamp)
|
pkt := p.(*mhfpacket.MsgMhfCheckWeeklyStamp)
|
||||||
|
|||||||
@@ -494,13 +494,8 @@ func TestHandleMsgMhfGetExtraInfo(t *testing.T) {
|
|||||||
server := createMockServer()
|
server := createMockServer()
|
||||||
session := createMockSession(1, server)
|
session := createMockSession(1, server)
|
||||||
|
|
||||||
defer func() {
|
pkt := &mhfpacket.MsgMhfGetExtraInfo{AckHandle: 1}
|
||||||
if r := recover(); r != nil {
|
handleMsgMhfGetExtraInfo(session, pkt)
|
||||||
t.Errorf("handleMsgMhfGetExtraInfo panicked: %v", r)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
handleMsgMhfGetExtraInfo(session, nil)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestHandleMsgMhfTransferItem(t *testing.T) {
|
func TestHandleMsgMhfTransferItem(t *testing.T) {
|
||||||
|
|||||||
@@ -336,13 +336,8 @@ func TestHandleMsgMhfGetCogInfo(t *testing.T) {
|
|||||||
server := createMockServer()
|
server := createMockServer()
|
||||||
session := createMockSession(1, server)
|
session := createMockSession(1, server)
|
||||||
|
|
||||||
defer func() {
|
pkt := &mhfpacket.MsgMhfGetCogInfo{AckHandle: 1}
|
||||||
if r := recover(); r != nil {
|
handleMsgMhfGetCogInfo(session, pkt)
|
||||||
t.Errorf("handleMsgMhfGetCogInfo panicked: %v", r)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
handleMsgMhfGetCogInfo(session, nil)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Additional handler tests for coverage
|
// Additional handler tests for coverage
|
||||||
@@ -1032,7 +1027,7 @@ func TestEmptyHandlers_MiscFiles_Misc(t *testing.T) {
|
|||||||
name string
|
name string
|
||||||
fn func()
|
fn func()
|
||||||
}{
|
}{
|
||||||
{"handleMsgMhfGetCogInfo", func() { handleMsgMhfGetCogInfo(session, nil) }},
|
|
||||||
{"handleMsgMhfUseUdShopCoin", func() { handleMsgMhfUseUdShopCoin(session, nil) }},
|
{"handleMsgMhfUseUdShopCoin", func() { handleMsgMhfUseUdShopCoin(session, nil) }},
|
||||||
{"handleMsgMhfGetDailyMissionMaster", func() { handleMsgMhfGetDailyMissionMaster(session, nil) }},
|
{"handleMsgMhfGetDailyMissionMaster", func() { handleMsgMhfGetDailyMissionMaster(session, nil) }},
|
||||||
{"handleMsgMhfGetDailyMissionPersonal", func() { handleMsgMhfGetDailyMissionPersonal(session, nil) }},
|
{"handleMsgMhfGetDailyMissionPersonal", func() { handleMsgMhfGetDailyMissionPersonal(session, nil) }},
|
||||||
|
|||||||
@@ -1079,7 +1079,6 @@ func TestEmptyHandlers_HandlersGo(t *testing.T) {
|
|||||||
{"handleMsgSysEnumuser", func() { handleMsgSysEnumuser(session, nil) }},
|
{"handleMsgSysEnumuser", func() { handleMsgSysEnumuser(session, nil) }},
|
||||||
{"handleMsgSysInfokyserver", func() { handleMsgSysInfokyserver(session, nil) }},
|
{"handleMsgSysInfokyserver", func() { handleMsgSysInfokyserver(session, nil) }},
|
||||||
{"handleMsgMhfGetCaUniqueID", func() { handleMsgMhfGetCaUniqueID(session, nil) }},
|
{"handleMsgMhfGetCaUniqueID", func() { handleMsgMhfGetCaUniqueID(session, nil) }},
|
||||||
{"handleMsgMhfGetExtraInfo", func() { handleMsgMhfGetExtraInfo(session, nil) }},
|
|
||||||
{"handleMsgSysSetStatus", func() { handleMsgSysSetStatus(session, nil) }},
|
{"handleMsgSysSetStatus", func() { handleMsgSysSetStatus(session, nil) }},
|
||||||
{"handleMsgMhfStampcardPrize", func() { handleMsgMhfStampcardPrize(session, nil) }},
|
{"handleMsgMhfStampcardPrize", func() { handleMsgMhfStampcardPrize(session, nil) }},
|
||||||
{"handleMsgMhfKickExportForce", func() { handleMsgMhfKickExportForce(session, nil) }},
|
{"handleMsgMhfKickExportForce", func() { handleMsgMhfKickExportForce(session, nil) }},
|
||||||
@@ -1118,7 +1117,6 @@ func TestEmptyHandlers_Concurrent(t *testing.T) {
|
|||||||
handleMsgSysEnumuser,
|
handleMsgSysEnumuser,
|
||||||
handleMsgSysInfokyserver,
|
handleMsgSysInfokyserver,
|
||||||
handleMsgMhfGetCaUniqueID,
|
handleMsgMhfGetCaUniqueID,
|
||||||
handleMsgMhfGetExtraInfo,
|
|
||||||
handleMsgSysSetStatus,
|
handleMsgSysSetStatus,
|
||||||
handleMsgSysDeleteObject,
|
handleMsgSysDeleteObject,
|
||||||
handleMsgSysRotateObject,
|
handleMsgSysRotateObject,
|
||||||
|
|||||||
@@ -290,8 +290,6 @@ func TestEmptyHandlers_NoDb(t *testing.T) {
|
|||||||
{"handleMsgSysEnumuser", handleMsgSysEnumuser},
|
{"handleMsgSysEnumuser", handleMsgSysEnumuser},
|
||||||
{"handleMsgSysInfokyserver", handleMsgSysInfokyserver},
|
{"handleMsgSysInfokyserver", handleMsgSysInfokyserver},
|
||||||
{"handleMsgMhfGetCaUniqueID", handleMsgMhfGetCaUniqueID},
|
{"handleMsgMhfGetCaUniqueID", handleMsgMhfGetCaUniqueID},
|
||||||
{"handleMsgMhfGetExtraInfo", handleMsgMhfGetExtraInfo},
|
|
||||||
{"handleMsgMhfGetCogInfo", handleMsgMhfGetCogInfo},
|
|
||||||
{"handleMsgMhfStampcardPrize", handleMsgMhfStampcardPrize},
|
{"handleMsgMhfStampcardPrize", handleMsgMhfStampcardPrize},
|
||||||
{"handleMsgMhfKickExportForce", handleMsgMhfKickExportForce},
|
{"handleMsgMhfKickExportForce", handleMsgMhfKickExportForce},
|
||||||
{"handleMsgSysSetStatus", handleMsgSysSetStatus},
|
{"handleMsgSysSetStatus", handleMsgSysSetStatus},
|
||||||
|
|||||||
Reference in New Issue
Block a user