diff --git a/Modules/CustomSounds.cs b/Modules/CustomSounds.cs index c227deea2..d34513b93 100644 --- a/Modules/CustomSounds.cs +++ b/Modules/CustomSounds.cs @@ -1,8 +1,9 @@ +using Hazel; +using Il2CppInterop.Runtime.InteropTypes.Arrays; using System; using System.Collections.Generic; using System.IO; using System.Reflection; -using Hazel; using UnityEngine; namespace EHR.Modules; @@ -92,7 +93,7 @@ public static class CustomSoundsManager private static AudioClip LoadWAV(string path) { - byte[] fileData = File.ReadAllBytes(path); + var fileData = Il2CppSystem.IO.File.ReadAllBytes(path); WAV wav = new(fileData); Logger.Info($"[WAV: LeftChannel={wav.LeftChannel}, RightChannel={wav.RightChannel}, ChannelCount={wav.ChannelCount}, SampleCount={wav.SampleCount}, Frequency={wav.Frequency}]", "CustomSounds"); @@ -114,7 +115,7 @@ public static class CustomSoundsManager return s / 32768.0F; } - private static int BytesToInt(byte[] bytes, int offset = 0) + private static int BytesToInt(Il2CppStructArray bytes, int offset = 0) { int value = 0; @@ -124,13 +125,13 @@ public static class CustomSoundsManager } // Properties - public float[] LeftChannel { get; } - public float[] RightChannel { get; } + public Il2CppStructArray LeftChannel { get; } + public Il2CppStructArray RightChannel { get; } public int ChannelCount { get; } public int SampleCount { get; } public int Frequency { get; } - public WAV(byte[] wav) + public WAV(Il2CppStructArray wav) { // Determine if mono or stereo ChannelCount = wav[22]; // Forget byte 23 as 99.999% of WAVs are 1 or 2 channels @@ -156,8 +157,8 @@ public static class CustomSoundsManager if (ChannelCount == 2) SampleCount /= 2; // 4 bytes per sample (16 bit stereo) // Allocate memory (right will be null if only mono sound) - LeftChannel = new float[SampleCount]; - if (ChannelCount == 2) RightChannel = new float[SampleCount]; + LeftChannel = new Il2CppStructArray(SampleCount); + if (ChannelCount == 2) RightChannel = new Il2CppStructArray(SampleCount); else RightChannel = null; int end = pos + dataSize; @@ -179,11 +180,11 @@ public static class CustomSoundsManager } // Returns left and right double arrays. 'right' will be null if sound is mono. - public float[] GetStereoData() + public Il2CppStructArray GetStereoData() { if (RightChannel == null) return LeftChannel; - float[] stereoData = new float[SampleCount * 2]; + var stereoData = new Il2CppStructArray(SampleCount * 2); for (int i = 0; i < SampleCount; i++) { diff --git a/Modules/LobbySharingAPI.cs b/Modules/LobbySharingAPI.cs index 645064076..cb392cf7f 100644 --- a/Modules/LobbySharingAPI.cs +++ b/Modules/LobbySharingAPI.cs @@ -150,11 +150,11 @@ public enum LobbyStatus [HarmonyPatch(typeof(InnerNetClient), nameof(InnerNetClient.DisconnectInternal))] internal static class ExitGamePatch { - public static void Prefix(InnerNetClient __instance) + public static void Prefix(InnerNetClient __instance, DisconnectReasons reason) { if (__instance is not AmongUsClient) return; - Logger.Msg("Exiting game", "ExitGamePatch.Prefix"); + Logger.Msg($"Exiting game - reason: {reason}", "ExitGamePatch.Prefix"); GameStates.InGame = false; Main.RealOptionsData?.Restore(GameOptionsManager.Instance.CurrentGameOptions); diff --git a/Patches/Crowded.cs b/Patches/Crowded.cs index b23ee94dc..80eee9381 100644 --- a/Patches/Crowded.cs +++ b/Patches/Crowded.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; +using Il2CppInterop.Runtime.InteropTypes.Arrays; using System.Linq; using AmongUs.GameOptions; using HarmonyLib; @@ -284,7 +285,7 @@ internal static class Crowded [SuppressMessage("ReSharper", "UnusedMember.Global")] public static void Postfix(ref SecurityLogger __instance) { - __instance.Timers = new float[127]; + __instance.Timers = new Il2CppStructArray(127); } }