Update GaCy-GO

This commit is contained in:
CAtlas0784 committed 2026-10-28 18:54:43 +07:00
1 parent da8a32f60d
commit 0cbe460e49
345 files changed
+98202 -77559

No files matched your search

+34
View File
@@ -0,0 +1,34 @@
package common
import (
"encoding/json"
"fmt"
)
// Patch selected top-level fields against the latest file, under the same lock
// used by game saves. Raw JSON retains 64-bit scores and unknown save sections.
func PatchPersistentFields(patch map[string]json.RawMessage) error {
if patch == nil {
return fmt.Errorf("persistent patch must be a JSON object")
}
for _, raw := range patch {
if !json.Valid(raw) {
return fmt.Errorf("invalid persistent field JSON")
}
}
persistentWriteMu.Lock()
defer persistentWriteMu.Unlock()
unlock, err := lockPersistentFile()
if err != nil {
return err
}
defer unlock()
root, err := readCurrencyWarsPersistentRoot()
if err != nil {
return err
}
for key, value := range patch {
root[key] = value
}
return writeJSONAtomic("persistent", root)
}