diff --git a/CalamityModMusic.cs b/CalamityModMusic.cs index 1dde5fb..1cf5de0 100644 --- a/CalamityModMusic.cs +++ b/CalamityModMusic.cs @@ -138,7 +138,9 @@ namespace CalamityModMusic public override void Unload() { + IL.Terraria.Main.UpdateAudio -= TitleMusicIL; customTitleMusicSlot = MusicID.Title; + Close(); titleMusicStopped?.Set(); Instance = null; titleMusicStopped = null; @@ -345,12 +347,11 @@ namespace CalamityModMusic public override void Close() { - // Close isn't called on the main thread. Who doesn't love a bit of thread safety - // Close may be called even if we didn't reach PostSetupContent, so don't try and stop a music track which hasn't been loaded or played - if (!Main.dedServ && customTitleMusicSlot > 0) + var slot = GetSoundSlot(SoundType.Music, "Sounds/Music/Calamity"); + + if (Main.music.IndexInRange(slot) && Main.music[slot]?.IsPlaying == true) { - stopTitleMusic = true; - titleMusicStopped.WaitOne(); + Main.music[slot].Stop(AudioStopOptions.Immediate); } base.Close(); } diff --git a/build.txt b/build.txt index 2bf0deb..f552c8d 100644 --- a/build.txt +++ b/build.txt @@ -1,5 +1,5 @@ author = Fabsol and the Dev Team -version = 1.4.4.004 +version = 1.4.4.005 displayName = Calamity Mod Music homepage = https://forums.terraria.org/index.php?threads/calamity-mod.44065/ hideCode = true