diff --git a/.gitignore b/.gitignore index 1730521918..a0d5a37b3c 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ distribution/windows/*.exe # Build artifacts artifacts .cache +.dependencies #lib lib diff --git a/openrct2.proj b/openrct2.proj index 8706156080..1577ecbe39 100644 --- a/openrct2.proj +++ b/openrct2.proj @@ -67,6 +67,8 @@ $(LibsPath)libversion 1.8.0 https://github.com/google/googletest/archive/release-$(GtestVersion).zip + https://github.com/OpenRCT2/title-sequences/releases/download/v0.0.5/title-sequence-v0.0.5.zip + 79ffb2585d12abcbfce205d7696e3472a504b005 @@ -221,37 +223,13 @@ StandardOutputImportance="low" /> - - https://github.com/OpenRCT2/title-sequences/releases/download/v0.0.5/title-sequence-v0.0.5.zip - $(TargetDir)data\title - $(TargetDir)data\title\seqs.zip - $(TargetDir)sequencesversion - - - - - $([System.IO.File]::ReadAllText($(SequencesVersionPath)).Trim()) - true - - - - - - - - - - - - - - - - - - + @@ -123,4 +124,207 @@ + + + + + + + + + + + + + + + + + + + + + + 0) + { + Array.Resize(ref lines, lines.Length + 1); + } + lineIndex = lines.Length - 1; + + // End with new line + Array.Resize(ref lines, lines.Length + 1); + } + lines[lineIndex] = newLine; + File.WriteAllLines(checkFile, lines); + } + catch (Exception ex) + { + Log.LogWarningFromException(ex, showStackTrace: false); + } + } + + private int GetCheckFileLineIndexSha1(string[] lines, string name, out string sha1) + { + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + string[] lineParts = line.Split('='); + if (lineParts.Length == 2) + { + string lineTag = lineParts[0].Trim(); + string lineSha1 = lineParts[1].Trim(); + if (lineTag == name) + { + sha1 = lineSha1; + return i; + } + } + } + sha1 = null; + return -1; + } + + private bool CheckFileSha1(string file, string expectedSha1, out string actualSha1) + { + using (var fs = new FileStream(file, FileMode.Open)) + { + var hasher = System.Security.Cryptography.SHA1.Create(); + byte[] hash = hasher.ComputeHash(fs); + actualSha1 = BytesToHexString(hash); + if (String.Equals(actualSha1, expectedSha1, StringComparison.OrdinalIgnoreCase)) + { + return true; + } + } + return false; + } + + private string BytesToHexString(byte[] data) + { + var sb = new StringBuilder(); + foreach (byte b in data) + { + sb.Append(b.ToString("x2")); + } + return sb.ToString(); + } + + private static void ExtractZip(string zipPath, string destinationDirectory, bool overwrite) + { + var archive = ZipFile.OpenRead(zipPath); + if (!overwrite) + { + archive.ExtractToDirectory(destinationDirectory); + return; + } + foreach (ZipArchiveEntry file in archive.Entries) + { + string fileName = Path.Combine(destinationDirectory, file.FullName); + if (file.Name == String.Empty) + { + string directory = Path.GetDirectoryName(fileName); + Directory.CreateDirectory(directory); + continue; + } + file.ExtractToFile(fileName, true); + } + } + ]]> + + +