pre cw with probe and a bunch script to read game behavior
This commit is contained in:
1 parent
5120219ae2
commit
da8a32f60d
310 files changed
+219693
-872
No files matched your search
@@ -0,0 +1,52 @@
|
||||
package sdkserver
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
pb "gac-hkrpg-go/protocol/proto"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
func applyLiveServantStatistics(statistics *pb.BattleStatistics, encoded []string, breakdowns []liveAvatarBreakdown) error {
|
||||
if len(encoded) == 0 && len(breakdowns) == 0 {
|
||||
return nil
|
||||
}
|
||||
if len(encoded) > 64 || (len(breakdowns) != 0 && len(breakdowns) != len(encoded)) {
|
||||
return fmt.Errorf("invalid servant statistics count")
|
||||
}
|
||||
if statistics.GetIAGKLJEKAOL() != nil && len(statistics.IAGKLJEKAOL.GFOAHHHNBJC) != 0 {
|
||||
return fmt.Errorf("servant statistics must use a single source")
|
||||
}
|
||||
servants := make([]*pb.BattleAvatarServantInfo, 0, len(encoded))
|
||||
totalBytes := 0
|
||||
for i, value := range encoded {
|
||||
wire, err := base64.StdEncoding.Strict().DecodeString(value)
|
||||
if err != nil || len(wire) == 0 || len(wire) > 2<<20-totalBytes {
|
||||
return fmt.Errorf("invalid or oversized servant protobuf")
|
||||
}
|
||||
totalBytes += len(wire)
|
||||
servant := &pb.BattleAvatarServantInfo{}
|
||||
if err := proto.Unmarshal(wire, servant); err != nil || servant.AvatarId == 0 {
|
||||
return fmt.Errorf("invalid BattleAvatarServantInfo protobuf")
|
||||
}
|
||||
if len(breakdowns) != 0 {
|
||||
// Reuse the validation and dictionary hydration used for avatars.
|
||||
temporary := &pb.AvatarBattleInfo{}
|
||||
if err := applyLiveAvatarBreakdowns([]*pb.AvatarBattleInfo{temporary}, breakdowns[i:i+1]); err != nil {
|
||||
return err
|
||||
}
|
||||
if breakdowns[i].Damage != nil {
|
||||
servant.AttackTypeDamage = temporary.AttackTypeDamage
|
||||
}
|
||||
if breakdowns[i].BreakDamage != nil {
|
||||
servant.AttackTypeBreakDamage = temporary.AttackTypeBreakDamage
|
||||
}
|
||||
if breakdowns[i].MaxDamage != nil {
|
||||
servant.AttackTypeMaxDamage = temporary.AttackTypeMaxDamage
|
||||
}
|
||||
}
|
||||
servants = append(servants, servant)
|
||||
}
|
||||
statistics.IAGKLJEKAOL = &pb.OHDHNDMJFAP{GFOAHHHNBJC: servants}
|
||||
return nil
|
||||
}
|
||||
Reference in new issue
Block a user