[skip ci] export player store data

This commit is contained in:
HolographicHat
2025-01-11 19:24:42 +08:00
parent 2e2be07161
commit 32ceae074e
7 changed files with 174 additions and 25 deletions

View File

@@ -1,5 +1,4 @@
using System.Runtime.CompilerServices;
using System.Text.Json;
using System.Text.Json;
using System.Text.Json.Serialization;
using Google.Protobuf;
using YaeAchievement.res;
@@ -27,6 +26,12 @@ public class AchievementAllDataNotify {
public List<AchievementItem> AchievementList { get; private init; } = [];
public static bool OnReceive(byte[] bytes) {
GlobalVars.AchievementDataCache.Write(bytes);
Export.Choose(ParseFrom(bytes));
return true;
}
public static AchievementAllDataNotify ParseFrom(byte[] bytes) {
using var stream = new CodedInputStream(bytes);
var data = new List<Dictionary<uint, uint>>();
@@ -36,7 +41,7 @@ public class AchievementAllDataNotify {
while ((tag = stream.ReadTag()) != 0) {
if ((tag & 7) == 2) { // is LengthDelimited
var dict = new Dictionary<uint, uint>();
using var eStream = new CodedInputStream(ReadRawBytes(stream, stream.ReadLength()));
using var eStream = stream.ReadLengthDelimitedAsStream();
try {
while ((tag = eStream.ReadTag()) != 0) {
if ((tag & 7) != 0) { // not VarInt
@@ -107,9 +112,6 @@ public class AchievementAllDataNotify {
};
}
[UnsafeAccessor(UnsafeAccessorKind.Method)]
private static extern byte[] ReadRawBytes(CodedInputStream stream, int size);
}
[JsonSerializable(typeof(AchievementAllDataNotify))]