diff --git a/source/Vignette/Audio/AudioManager.cs b/source/Vignette/Audio/AudioManager.cs index e461756..47ab475 100644 --- a/source/Vignette/Audio/AudioManager.cs +++ b/source/Vignette/Audio/AudioManager.cs @@ -166,7 +166,7 @@ public void Dispose() source.Stop(); - while(source.TryDequeue(out var buffer)) + while (source.TryDequeue(out var buffer)) { bufferPool.Return(buffer); } diff --git a/source/Vignette/Content/AsarLoader.cs b/source/Vignette/Content/AsarLoader.cs new file mode 100644 index 0000000..08cc7ee --- /dev/null +++ b/source/Vignette/Content/AsarLoader.cs @@ -0,0 +1,26 @@ +// Copyright (c) Cosyne +// Licensed under GPL 3.0 with SDK Exception. See LICENSE for details. + +using System; +using System.IO; +using craftersmine.Asar.Net; + +namespace Vignette.Content; +internal class AsarLoader : IContentLoader +{ + // while the library is capable of verifying if its a valid archive, we would like to do + // it in the content loader level too so we can catch masquerading malicious files as we + // load them. + // The first 4 bytes of an asar archive is 04 00 00 00. + private static readonly byte[] signature = new byte[] { 0x04, 0x00, 0x00, 0x00 }; + + public AsarArchive Load(ReadOnlySpan bytes) + { + if (!MemoryExtensions.SequenceEqual(bytes[0..4], signature)) + throw new ArgumentException("Failed to find sequence \"04 00 00 00\" in byte sequence.", nameof(bytes)); + + // read the bytes into a stream + var stream = new MemoryStream(bytes.ToArray()); + return new AsarArchive(stream); + } +} diff --git a/source/Vignette/Graphics/IProjector.cs b/source/Vignette/Graphics/IProjector.cs index 17601b1..2590b55 100644 --- a/source/Vignette/Graphics/IProjector.cs +++ b/source/Vignette/Graphics/IProjector.cs @@ -19,7 +19,7 @@ public interface IProjector /// /// The projector's rotation. /// - Vector3 Rotation { get; } + Vector3 Rotation { get; } /// /// The projector's view matrix. diff --git a/source/Vignette/Vignette.csproj b/source/Vignette/Vignette.csproj index 0bd80f1..acb8829 100644 --- a/source/Vignette/Vignette.csproj +++ b/source/Vignette/Vignette.csproj @@ -8,6 +8,7 @@ +