fix: sync current handlers, repair relic data and restore visible launcher consoles

This commit is contained in:
CAtlas0784 committed 2026-10-16 22:19:52 +07:00
1 parent 163d4433e6
commit 74f3c4411b
46 files changed
+4599 -1402

No files matched your search

+35 -162
View File
@@ -39,94 +39,43 @@ func init() {
dummy(name)
}
// ---- fixed-body raw replies (cmd -> rsp cmd + body bytes) ----
simpleReply := func(reqIDs []uint16, rspID uint16, body []byte) {
for _, id := range reqIDs {
id := id
rawHandlers[id] = func(s *Session, payload []byte) error {
return s.SendRaw(&NetPacket{CmdType: rspID, Body: body})
}
}
}
// Bind requests by the current command names; do not retain numeric aliases
// from earlier builds, which may now identify responses or notifications.
rawNamed("GetChallengeGroupStatisticsCsReq", challengeGroupStatsReply)
rawNamed("GetChallengeTierceDataCsReq", challengeTierceReply)
rawNamed("StartChallengeCsReq", handleStartChallenge)
rawNamed("StartChallengeTierceCsReq", handleStartChallengeTierce)
rawNamed("SetChallengeTierceLineupCsReq", handleSetChallengeTierceLineup)
rawNamed("LeaveChallengeCsReq", handleLeaveChallenge)
rawNamed("LeaveChallengeTierceCsReq", handleLeaveChallengeTierce)
rawNamed("TakeChallengeCumulativeRewardCsReq", handleTakeChallengeReward)
// The request/response names remain obfuscated in the upstream schema.
rawNamed("HIGLJHLNODG", handleExRankUnlock)
simpleReply([]uint16{8909}, 8923, []byte{0x60, 0x00}) // tag 12 retcode 0
simpleReply([]uint16{8924, 8968}, 8920, []byte{0x10, 0x00}) // tag 2 retcode 0
simpleReply([]uint16{8935}, 8915, []byte{0x08, 0x00}) // tag 1 retcode 0
simpleReply([]uint16{8917}, 8929, []byte{0x08, 0x00}) // tag 1 retcode 0
simpleReply([]uint16{8933}, 8906, []byte{0x08, 0x00}) // tag 1 retcode 0
simpleReply([]uint16{8919}, 8948, []byte{0x08, 0x00}) // tag 1 retcode 0
simpleReply([]uint16{8910}, 8921, []byte{0x08, 0x00}) // tag 1 retcode 0
simpleReply([]uint16{8975}, 8992, []byte{0x40, 0x00}) // tag 8 retcode 0
simpleReply([]uint16{8990}, 8977, []byte{0x40, 0x00}) // tag 8 retcode 0
simpleReply([]uint16{8977}, 8999, []byte{0x50, 0x00}) // tag 10 retcode 0
simpleReply([]uint16{2966}, 2955, []byte{0x30, 0x00}) // tag 6 retcode 0
simpleReply([]uint16{2916}, 2906, []byte{0x18, 0x00}) // tag 3 retcode 0
simpleReply([]uint16{2919}, 2928, []byte{0x48, 0x00}) // tag 9 retcode 0
simpleReply([]uint16{2974}, 2919, []byte{0x18, 0x00}) // GetFriendListInfo tag 3 retcode 0
simpleReply([]uint16{740}, 733, []byte{0x58, 0x00}) // tag 11 retcode 0
simpleReply([]uint16{1748}, 1745, []byte{0x08, 0x00}) // tag 1 retcode 0
simpleReply([]uint16{1765}, 1730, []byte{0x08, 0x00}) // tag 1 retcode 0
simpleReply([]uint16{1742}, 1772, []byte{0x08, 0x00}) // tag 1 retcode 0
simpleReply([]uint16{1738}, 1748, nil) // empty body
simpleReply([]uint16{188}, 181, []byte{0x50, 0x00}) // tag 10 retcode 0
simpleReply([]uint16{4130}, 4124, []byte{0x70, 0x00}) // tag 14 retcode 0
simpleReply([]uint16{8110, 8115}, 8108, []byte{0x18, 0x00}) // GetSwitchHandData tag 3 retcode 0 (4.6.51 CmdID: 8108)
simpleReply([]uint16{8993, 8991}, 8981, []byte{0x70, 0x00}) // 4.6.51: tag 14 retcode 0
simpleReply([]uint16{8987}, 8986, []byte{0x38, 0x00}) // ConfirmChallengeTierceStageSettle tag 7 retcode 0
rawNamed("GetSwitchHandDataCsReq", func(s *Session, payload []byte) error {
return s.Send(&goproto.GetSwitchHandDataScRsp{})
})
// ---- 1775 | 1711 -> GetChallengeGroupStatisticsScRsp (cmd 1708) ----
rawHandlers[1775] = challengeGroupStatsReply
rawHandlers[1711] = challengeGroupStatsReply
handle("GetChallengeTierceController", func(s *Session, req *goproto.GetChallengeTierceControllerCsReq, rsp *goproto.GetChallengeTierceControllerScRsp) error {
rsp.Retcode = 0
return nil
})
handle("StartChallengePeak", handleStartChallengePeak)
rawNamed("LeaveChallengePeakCsReq", func(s *Session, payload []byte) error {
return leaveChallengeScene(s, &goproto.LeaveChallengePeakScRsp{})
})
// ---- 8995 | 8979 | 8981 -> tierce data (cmd 8996 + legacy 8994) ----
rawHandlers[8995] = challengeTierceReply
rawHandlers[8979] = challengeTierceReply
rawHandlers[8981] = challengeTierceReply
// ---- challenge flow (StartChallenge family) ----
rawHandlers[1731] = handleStartChallenge
rawHandlers[1793] = handleStartChallenge
rawHandlers[8986] = handleStartChallengeTierce
rawHandlers[8988] = handleStartChallengeTierce
rawHandlers[8978] = handleSetChallengeTierceLineup
rawHandlers[9000] = handleSetChallengeTierceLineup
rawHandlers[1705] = handleLeaveChallenge
rawHandlers[1760] = handleLeaveChallenge
rawHandlers[1788] = handleLeaveChallenge
rawHandlers[8989] = handleLeaveChallengeTierce
rawHandlers[1739] = handleTakeChallengeReward
// ---- 400 -> Ex-Rank / Affinitive Eidolon Unlock ----
rawHandlers[400] = handleExRankUnlock
}
// handleExRankUnlock handles CmdID 400 (Affinitive Eidolon / Ex-Rank unlock request from client).
func handleExRankUnlock(s *Session, payload []byte) error {
Log(fmt.Sprintf("[EX-RANK] Received cmd 400 (len: %d) payload: %x", len(payload), payload))
var parsedVal uint32
buf := payload
for len(buf) > 0 {
tag, n := readUvarint(buf)
if n == 0 {
break
}
buf = buf[n:]
wireType := tag & 0x7
fieldNum := tag >> 3
if wireType == 0 {
v, n2 := readUvarint(buf)
if n2 > 0 {
buf = buf[n2:]
Log(fmt.Sprintf("[EX-RANK] field %d = %d", fieldNum, v))
if v >= 100000 || (v >= 1000 && v < 10000 && parsedVal == 0) {
parsedVal = uint32(v)
}
continue
}
}
skipWireField(uint32(wireType), &buf)
var req goproto.HIGLJHLNODG
if err := proto.Unmarshal(payload, &req); err != nil {
return err
}
parsedVal := req.OJFIGABCKLG
var avatarID uint32
if parsedVal >= 100000 {
@@ -162,99 +111,23 @@ func handleExRankUnlock(s *Session, payload []byte) error {
player.SavePersistent()
}
// Send candidate response packets so client RPC callback resolves without spinning
// Candidates in CmdAvatarType: 395 (CmdAvatarType_ENKEIJOLCNO), 354, 355, 364, 341
for _, rspID := range []uint16{395, 354, 355, 364, 341} {
_ = s.SendRaw(&NetPacket{CmdType: rspID, Body: []byte{}})
}
return nil
// The matching response is declared by the current upstream schema.
return s.Send(&goproto.LPOLGDLAADM{})
}
// challengeGroupStatsReply handles CmdGetChallengeGroupStatisticsCsReq (1775/1711)
// and returns GetChallengeGroupStatisticsScRsp (1708) using standard 4.6.51 proto.
// challengeGroupStatsReply uses the current typed statistics response.
func challengeGroupStatsReply(s *Session, payload []byte) error {
groupID := uint32(100)
var req goproto.GetChallengeGroupStatisticsCsReq
if err := proto.Unmarshal(payload, &req); err == nil && req.GroupId != 0 {
groupID = req.GroupId
} else {
buf := payload
for len(buf) > 0 {
tag, n := readUvarint(buf)
if n == 0 {
break
}
buf = buf[n:]
fieldNumber := tag >> 3
wireType := tag & 0x7
if (fieldNumber == 5 || fieldNumber == 12) && wireType == 0 {
v, n2 := readUvarint(buf)
if n2 > 0 {
groupID = uint32(v)
break
}
}
skipWireField(uint32(wireType), &buf)
}
}
rsp := &goproto.GetChallengeGroupStatisticsScRsp{
GroupId: groupID,
Retcode: 0,
}
switch {
case groupID >= 3000:
// Apocalyptic Shadow: challenge_boss (field 1)
rsp.ChallengeBoss = &goproto.ChallengeBossStatistics{
RecordId: 1,
PPBHLLOJNEK: &goproto.AANLJBLOOFO{
Level: 4,
ScoreId: 8000,
},
}
case groupID >= 2000 && groupID < 3000:
// Pure Fiction: challenge_story (field 3)
rsp.ChallengeStory = &goproto.ChallengeStoryStatistics{
RecordId: 1,
PPBHLLOJNEK: &goproto.EIKPHEMHIOH{
ScoreId: 80000,
},
}
case groupID >= 1000 && groupID < 2000:
// Memory of Chaos: challenge_default (field 11)
rsp.ChallengeDefault = &goproto.ChallengeStatistics{
RecordId: 1,
PPBHLLOJNEK: &goproto.ADKJKMKBFDC{
RoundCount: 20,
Level: 12,
},
}
}
body, err := proto.Marshal(rsp)
if err != nil {
if err := proto.Unmarshal(payload, &req); err != nil {
return err
}
return s.SendRaw(&NetPacket{CmdType: 1708, Body: body})
// Match upstream: echo the group without fabricating historical scores.
return s.Send(&goproto.GetChallengeGroupStatisticsScRsp{GroupId: req.GroupId})
}
// challengeTierceReply ports the 8995/8979/8981 arm: cmd 8996 (4.6.51) plus
// legacy cmd 8994 with the same tierce body.
// challengeTierceReply sends only the response paired with the current request.
func challengeTierceReply(s *Session, payload []byte) error {
body := buildGetChallengeTierceDataScRsp()
if err := s.SendRaw(&NetPacket{CmdType: 8996, Body: body}); err != nil {
return err
}
_ = s.SendRaw(&NetPacket{CmdType: 8994, Body: body})
return nil
}
// buildGetChallengeTierceDataScRsp mirrors challenge::build_get_challenge_tierce_data_sc_rsp
// (hand-built protobuf, verified against the 4.6.51 client).
func buildGetChallengeTierceDataScRsp() []byte {
return buildGetChallengeTierceDataScRspReal()
return s.Send(buildGetChallengeTierceDataScRspReal())
}
func readUvarint(b []byte) (uint64, int) {