diff --git a/src/GlobalVars.cs b/src/GlobalVars.cs index 63fb00a..c1715fa 100644 --- a/src/GlobalVars.cs +++ b/src/GlobalVars.cs @@ -20,8 +20,8 @@ public static class GlobalVars { public static readonly string CachePath = Path.Combine(DataPath, "cache"); public static readonly string LibFilePath = Path.Combine(DataPath, "YaeAchievement.dll"); - public const uint AppVersionCode = 34; - public const string AppVersionName = "2.4.1"; + public const uint AppVersionCode = 35; + public const string AppVersionName = "2.5"; public const string PipeName = "YaeAchievementPipe"; public const string BucketHost = "https://cn-cd-1259389942.file.myqcloud.com"; diff --git a/src/Proto/UpdateInfo.cs b/src/Proto/UpdateInfo.cs index 0166ccc..335b762 100644 --- a/src/Proto/UpdateInfo.cs +++ b/src/Proto/UpdateInfo.cs @@ -22,15 +22,16 @@ public static partial class UpdateInfoReflection { static UpdateInfoReflection() { byte[] descriptorData = global::System.Convert.FromBase64String( string.Concat( - "ChBVcGRhdGVJbmZvLnByb3RvIqwBCgpVcGRhdGVJbmZvEhMKC3ZlcnNpb25D", + "ChBVcGRhdGVJbmZvLnByb3RvIuIBCgpVcGRhdGVJbmZvEhMKC3ZlcnNpb25D", "b2RlGAEgASgNEhMKC3ZlcnNpb25OYW1lGAIgASgJEhMKC2Rlc2NyaXB0aW9u", "GAMgASgJEhMKC3BhY2thZ2VMaW5rGAQgASgJEhMKC2ZvcmNlVXBkYXRlGAUg", "ASgIEhkKEWVuYWJsZUxpYkRvd25sb2FkGAYgASgIEhoKEmVuYWJsZUF1dG9E", - "b3dubG9hZBgHIAEoCGIGcHJvdG8z")); + "b3dubG9hZBgHIAEoCBIZChFjdXJyZW50Q05HYW1lSGFzaBgIIAEoCRIZChFj", + "dXJyZW50T1NHYW1lSGFzaBgJIAEoCWIGcHJvdG8z")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::UpdateInfo), global::UpdateInfo.Parser, new[]{ "VersionCode", "VersionName", "Description", "PackageLink", "ForceUpdate", "EnableLibDownload", "EnableAutoDownload" }, null, null, null, null) + new pbr::GeneratedClrTypeInfo(typeof(global::UpdateInfo), global::UpdateInfo.Parser, new[]{ "VersionCode", "VersionName", "Description", "PackageLink", "ForceUpdate", "EnableLibDownload", "EnableAutoDownload", "CurrentCNGameHash", "CurrentOSGameHash" }, null, null, null, null) })); } #endregion @@ -78,6 +79,8 @@ public sealed partial class UpdateInfo : pb::IMessage forceUpdate_ = other.forceUpdate_; enableLibDownload_ = other.enableLibDownload_; enableAutoDownload_ = other.enableAutoDownload_; + currentCNGameHash_ = other.currentCNGameHash_; + currentOSGameHash_ = other.currentOSGameHash_; _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } @@ -171,6 +174,30 @@ public sealed partial class UpdateInfo : pb::IMessage } } + /// Field number for the "currentCNGameHash" field. + public const int CurrentCNGameHashFieldNumber = 8; + private string currentCNGameHash_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public string CurrentCNGameHash { + get { return currentCNGameHash_; } + set { + currentCNGameHash_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "currentOSGameHash" field. + public const int CurrentOSGameHashFieldNumber = 9; + private string currentOSGameHash_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public string CurrentOSGameHash { + get { return currentOSGameHash_; } + set { + currentOSGameHash_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] public override bool Equals(object other) { @@ -193,6 +220,8 @@ public sealed partial class UpdateInfo : pb::IMessage if (ForceUpdate != other.ForceUpdate) return false; if (EnableLibDownload != other.EnableLibDownload) return false; if (EnableAutoDownload != other.EnableAutoDownload) return false; + if (CurrentCNGameHash != other.CurrentCNGameHash) return false; + if (CurrentOSGameHash != other.CurrentOSGameHash) return false; return Equals(_unknownFields, other._unknownFields); } @@ -207,6 +236,8 @@ public sealed partial class UpdateInfo : pb::IMessage if (ForceUpdate != false) hash ^= ForceUpdate.GetHashCode(); if (EnableLibDownload != false) hash ^= EnableLibDownload.GetHashCode(); if (EnableAutoDownload != false) hash ^= EnableAutoDownload.GetHashCode(); + if (CurrentCNGameHash.Length != 0) hash ^= CurrentCNGameHash.GetHashCode(); + if (CurrentOSGameHash.Length != 0) hash ^= CurrentOSGameHash.GetHashCode(); if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } @@ -253,6 +284,14 @@ public sealed partial class UpdateInfo : pb::IMessage output.WriteRawTag(56); output.WriteBool(EnableAutoDownload); } + if (CurrentCNGameHash.Length != 0) { + output.WriteRawTag(66); + output.WriteString(CurrentCNGameHash); + } + if (CurrentOSGameHash.Length != 0) { + output.WriteRawTag(74); + output.WriteString(CurrentOSGameHash); + } if (_unknownFields != null) { _unknownFields.WriteTo(output); } @@ -291,6 +330,14 @@ public sealed partial class UpdateInfo : pb::IMessage output.WriteRawTag(56); output.WriteBool(EnableAutoDownload); } + if (CurrentCNGameHash.Length != 0) { + output.WriteRawTag(66); + output.WriteString(CurrentCNGameHash); + } + if (CurrentOSGameHash.Length != 0) { + output.WriteRawTag(74); + output.WriteString(CurrentOSGameHash); + } if (_unknownFields != null) { _unknownFields.WriteTo(ref output); } @@ -322,6 +369,12 @@ public sealed partial class UpdateInfo : pb::IMessage if (EnableAutoDownload != false) { size += 1 + 1; } + if (CurrentCNGameHash.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(CurrentCNGameHash); + } + if (CurrentOSGameHash.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(CurrentOSGameHash); + } if (_unknownFields != null) { size += _unknownFields.CalculateSize(); } @@ -355,6 +408,12 @@ public sealed partial class UpdateInfo : pb::IMessage if (other.EnableAutoDownload != false) { EnableAutoDownload = other.EnableAutoDownload; } + if (other.CurrentCNGameHash.Length != 0) { + CurrentCNGameHash = other.CurrentCNGameHash; + } + if (other.CurrentOSGameHash.Length != 0) { + CurrentOSGameHash = other.CurrentOSGameHash; + } _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } @@ -398,6 +457,14 @@ public sealed partial class UpdateInfo : pb::IMessage EnableAutoDownload = input.ReadBool(); break; } + case 66: { + CurrentCNGameHash = input.ReadString(); + break; + } + case 74: { + CurrentOSGameHash = input.ReadString(); + break; + } } } #endif @@ -441,6 +508,14 @@ public sealed partial class UpdateInfo : pb::IMessage EnableAutoDownload = input.ReadBool(); break; } + case 66: { + CurrentCNGameHash = input.ReadString(); + break; + } + case 74: { + CurrentOSGameHash = input.ReadString(); + break; + } } } } diff --git a/src/Utils.cs b/src/Utils.cs index 4524120..4c58fb0 100644 --- a/src/Utils.cs +++ b/src/Utils.cs @@ -79,6 +79,9 @@ public static class Utils { throw new Win32Exception(); } } + + // ReSharper disable once NotAccessedField.Local + private static UpdateInfo _updateInfo = null!; public static void CheckUpdate(bool useLocalLib) { var info = UpdateInfo.Parser.ParseFrom(GetBucketFileAsByteArray("schicksal/version"))!; @@ -110,6 +113,7 @@ public static class Utils { } else if (info.EnableLibDownload) { File.WriteAllBytes(GlobalVars.LibFilePath, GetBucketFileAsByteArray("schicksal/lib.dll")); } + _updateInfo = info; } public static void CheckSelfIsRunning() { @@ -203,9 +207,8 @@ public static class Utils { #if DEBUG return true; #else - return File.Exists(path) && File.ReadAllBytes(path).MD5Hash() - is "34433aa962523e55213c596d4e6b1f9c" - or "1fa8e1445b8121d5d1b5c1e6a8daa905"; // TODO: Use api + var hash = File.ReadAllBytes(path).MD5Hash(); + return File.Exists(path) && (hash == _updateInfo.CurrentCNGameHash || hash == _updateInfo.CurrentOSGameHash); #endif }