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:
Houmgaor
2026-03-19 14:35:38 +01:00
parent 7ea2660335
commit d27da5ec86
11 changed files with 60 additions and 30 deletions

View File

@@ -25,7 +25,6 @@ func TestParseSmallNotImplemented(t *testing.T) {
{"MsgMhfGetCaUniqueID", &MsgMhfGetCaUniqueID{}},
{"MsgMhfGetDailyMissionMaster", &MsgMhfGetDailyMissionMaster{}},
{"MsgMhfGetDailyMissionPersonal", &MsgMhfGetDailyMissionPersonal{}},
{"MsgMhfGetExtraInfo", &MsgMhfGetExtraInfo{}},
{"MsgMhfGetRestrictionEvent", &MsgMhfGetRestrictionEvent{}},
{"MsgMhfKickExportForce", &MsgMhfKickExportForce{}},
{"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
// packets returns an error and does not panic.
func TestParseSmallNotImplementedDoesNotPanic(t *testing.T) {