34 lines
2.0 KiB
Go
34 lines
2.0 KiB
Go
//go:build ignore
|
|
|
|
// Export the observed basic merge contract from an isolated native sync.
|
|
package main
|
|
|
|
import (
|
|
"crypto/sha256"
|
|
"encoding/hex"
|
|
"encoding/json"
|
|
"fmt"
|
|
"os"
|
|
pb "gac-hkrpg-go/protocol/proto"
|
|
"google.golang.org/protobuf/proto"
|
|
)
|
|
|
|
func main() {
|
|
if len(os.Args)!=4 { panic("usage: exporter <sync.bin> <catalog.json> <output.json>") }
|
|
raw,e:=os.ReadFile(os.Args[1]);if e!=nil{panic(e)}
|
|
var sync pb.GridFightSyncUpdateResultScNotify;if e=proto.Unmarshal(raw,&sync);e!=nil{panic(e)}
|
|
var copies int
|
|
for _,group:=range sync.GCPNIHHBGGD {
|
|
if group.GridUpdateSrc!=pb.JJDFGMMMCMI_JJDFGMMMCMI_NJBMBFFLNGM {continue}
|
|
removed:=map[uint32]bool{};var added *pb.CDEAABODKCP
|
|
for _,v:=range group.JKPJFKCBIEM {if id:=v.GetHFCBOIOAECK();id!=0{if removed[id]{panic("duplicate removal")};removed[id]=true};if v.GetPIDDDHKPDDM()!=nil{if added!=nil{panic("multiple merged roles")};added=v.GetPIDDDHKPDDM()}}
|
|
if added==nil||len(removed)<2||removed[added.UniqueId]||added.RoleStar!=2{panic("not an observed first-star merge")}
|
|
if copies!=0&&copies!=len(removed){panic("merge counts differ")};copies=len(removed)
|
|
}
|
|
if copies==0{panic("merge group missing")}
|
|
b,e:=os.ReadFile(os.Args[2]);if e!=nil{panic(e)};var catalog struct{Client string `json:"client_version"`; Provenance struct{Assembly string `json:"game_assembly_sha256"`} `json:"provenance"`};if e=json.Unmarshal(b,&catalog);e!=nil{panic(e)}
|
|
digest:=sha256.Sum256(raw)
|
|
out:=map[string]any{"format_version":1,"target_client_version":catalog.Client,"target_assembly_sha256":catalog.Provenance.Assembly,"source_capture_sha256":hex.EncodeToString(digest[:]),"copies_required":copies,"ordinary_max_star":3,"scope":"Basic identical-role merges: source native MergeRoles and captured remove/add sync. Ordinary maximum 3 follows the reference implementation; Spotlight/trait higher-star exceptions require their own engine. No ID-specific rules."}
|
|
b,e=json.MarshalIndent(out,""," ");if e!=nil{panic(e)};if e=os.WriteFile(os.Args[3],append(b,'\n'),0644);e!=nil{panic(e)};fmt.Println("Exported native copies required:",copies)
|
|
}
|