Update GaCy-GO
This commit is contained in:
1 parent
da8a32f60d
commit
0cbe460e49
345 files changed
+98202
-77559
No files matched your search
@@ -0,0 +1,54 @@
|
||||
package gameserver
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
_ "embed"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
|
||||
"gac-hkrpg-go/internal/common"
|
||||
)
|
||||
|
||||
//go:embed aa_round_sync.lua
|
||||
var aaRoundRefreshAdapter []byte
|
||||
|
||||
// loadAARoundRefreshLua invalidates only the AA module's cached data, through
|
||||
// its observed native request API. It never rewrites an incoming PeakId,
|
||||
// starts a challenge, changes a scene or modifies saved selection/progression.
|
||||
func loadAARoundRefreshLua(s *Session) ([]byte, error) {
|
||||
selection, err := common.ReadAARoundSelection()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
groups := map[uint32]bool{}
|
||||
var defaultGroup uint32
|
||||
for _, stage := range getChallengeData().Peak {
|
||||
if stage.GroupID != 0 {
|
||||
groups[stage.GroupID] = true
|
||||
if defaultGroup == 0 || stage.GroupID < defaultGroup {
|
||||
defaultGroup = stage.GroupID
|
||||
}
|
||||
}
|
||||
}
|
||||
if defaultGroup == 0 {
|
||||
return nil, fmt.Errorf("AA refresh has no resource-backed round")
|
||||
}
|
||||
desired := defaultGroup
|
||||
if selection != nil {
|
||||
if !groups[selection.PeakGroupID] {
|
||||
return nil, fmt.Errorf("selected AA round %d is absent from loaded challenge data", selection.PeakGroupID)
|
||||
}
|
||||
desired = selection.PeakGroupID
|
||||
}
|
||||
cfg, err := common.LoadRuntimeConfig()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
digest := sha256.Sum256([]byte(fmt.Sprintf("%s/%d", cfg.ClientVersion, desired)))
|
||||
deferred := s.ChallengeRun != nil || s.currencyWarsOpen
|
||||
if _, active := CURRENT_BATTLE.Load(s.Token); active {
|
||||
deferred = true
|
||||
}
|
||||
payload := fmt.Sprintf("\n_G.__GAC_AA_ROUND_REFRESH={desired_group=%d,revision=%s,deferred=%t}\n", desired, luaQuotedString(hex.EncodeToString(digest[:])), deferred)
|
||||
return append([]byte(payload), aaRoundRefreshAdapter...), nil
|
||||
}
|
||||
Reference in new issue
Block a user