docs & feat: add license & attribution notice (Apache-2.0 / GPL-3.0) and core system enhancements

This commit is contained in:
CAtlas0784 committed 2026-11-01 20:14:36 +07:00
1 parent 507836d367
commit ce6aabfc55
47 files changed
+5674 -724

No files matched your search

+40 -56
View File
@@ -11,15 +11,30 @@ import (
func init() {
handle("GetGachaInfo", func(s *Session, req *pb.GetGachaInfoCsReq, rsp *pb.GetGachaInfoScRsp) error {
banners, _, err := common.LoadBrowsableGachaBanners()
player := s.JSON()
mode := 0
if player != nil {
mode = player.WarpUnlockMode
}
// Read API changes on reopening Warp without requiring a full login.
savedMode, err := common.ReadWarpUnlockMode()
if err != nil {
return err
}
if savedMode != nil {
mode = *savedMode
}
banners, err := common.LoadVisibleGachaBanners(mode)
if err != nil {
return err
}
if len(banners) == 0 {
rsp.Retcode = uint32(pb.Retcode_RET_GACHA_NOT_SUPPORT)
PacketLog("GACHA entry rejected: no verified installed banner assets")
PacketLog("GACHA entry rejected: no visible banners configured")
return nil
}
config, err := common.LoadRuntimeConfig()
if err != nil {
return err
@@ -32,73 +47,42 @@ func init() {
}
rsp.GachaInfoList = append(rsp.GachaInfoList, info)
}
// Synthetic IDs are not native Client config rows. The presentation
// adapter registers its own pools; sending these IDs in GetGachaInfo has
// caused Client response handlers to throw. Keep the preview opt-in.
mapped, _, err := common.LoadLimitedGachaBanners()
randVal, err := rand.Int(rand.Reader, big.NewInt(1000))
if err != nil {
return err
}
_, _, policy, err := common.LoadSandboxDrawPool()
if err != nil {
return err
}
count := policy.MappedBannerPreviewCount
if count > uint32(len(mapped)) {
count = uint32(len(mapped))
}
for i := uint32(0); i < count; i++ {
banner := mapped[i]
info := &pb.GachaInfo{GachaId: banner.GachaID, BeginTime: *config.ActivitySchedule.BeginTime, EndTime: *config.ActivitySchedule.EndTime, GachaCeiling: &pb.GachaCeiling{}}
info.PrizeItemList = []uint32{banner.AvatarID}
info.ItemDetailList = append([]uint32{banner.AvatarID}, banner.FourStarIDs...)
rsp.GachaInfoList = append(rsp.GachaInfoList, info)
}
PacketLog(fmt.Sprintf("GACHA_INFO banners=%d mapped_preview=%d", len(banners), count))
rsp.GachaRandom = 1000 + uint32(randVal.Int64())
rsp.Retcode = 0
PacketLog(fmt.Sprintf("GACHA_INFO count=%d mode=%d", len(rsp.GachaInfoList), mode))
return nil
})
handle("DoGacha", func(s *Session, req *pb.DoGachaCsReq, rsp *pb.DoGachaScRsp) error {
rsp.GachaId = req.GachaId
rsp.GachaNum = req.GachaNum
rsp.Retcode = uint32(pb.Retcode_RET_GACHA_ID_NOT_EXIST)
banners, _, err := common.LoadFeaturedGachaBanners()
if err != nil {
return err
}
var avatarID uint32
for _, row := range banners {
if row.ID == req.GachaId {
avatarID = row.AvatarID
break
}
}
if avatarID == 0 {
mapped, _, err := common.LoadLimitedGachaBanners()
if err != nil {
return err
}
for _, row := range mapped {
if row.GachaID == req.GachaId {
return drawLimitedAvatar(s, req, rsp, row)
}
}
}
if avatarID != 0 {
return drawFeaturedAvatar(s, req, rsp, avatarID)
}
// Featured-only path found nothing. Verified browsable banners may
// still draw from the policy-declared sandbox pool: every pick is a
// duplicate grant on an avatar from the live imported roster, so no
// invented IDs or first-acquisition synthesis are involved.
sandboxDrawn, err := drawSandboxPool(s, req, rsp)
if err != nil {
return err
}
if sandboxDrawn {
if _, active := CURRENT_BATTLE.Load(s.Token); active {
rsp.Retcode = uint32(pb.Retcode_RET_GACHA_NOT_SUPPORT)
return nil
}
if req.GachaNum != 1 && req.GachaNum != 10 {
rsp.Retcode = uint32(pb.Retcode_RET_GACHA_NUM_INVALID)
return nil
}
player := s.JSON()
if player == nil {
return nil
}
// The imported banner lists target another Client. Reject draws until
// their pools, grants and protocol fields are verified for this Client.
rsp.Retcode = uint32(pb.Retcode_RET_GACHA_NOT_SUPPORT)
return nil
})
}
// drawFeaturedAvatar grants req.GachaNum copies of one featured avatar using