From 9fd53ced8095dec0c778cd9f22e59aeec7f00fa7 Mon Sep 17 00:00:00 2001 From: Nick Gal Date: Fri, 21 Jul 2023 08:56:07 -0700 Subject: [PATCH] Fallback to defaults.eal for newer clients --- LanternExtractor/EQ/ArchiveExtractor.cs | 8 +++++++- LanternExtractor/EQ/Sound/EnvAudio.cs | 13 ++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/LanternExtractor/EQ/ArchiveExtractor.cs b/LanternExtractor/EQ/ArchiveExtractor.cs index a3ae39c..1a7f7cc 100644 --- a/LanternExtractor/EQ/ArchiveExtractor.cs +++ b/LanternExtractor/EQ/ArchiveExtractor.cs @@ -310,10 +310,16 @@ public static void WriteWldTextures(PfsArchive s3dArchive, WldFile wldFile, stri private static void ExtractSoundData(string shortName, string rootFolder, ILogger logger, Settings settings) { var envAudio = EnvAudio.Instance; - envAudio.Load(Path.Combine(settings.EverQuestDirectory, "defaults.dat")); + var ealFilePath = Path.Combine(settings.EverQuestDirectory, "defaults.dat"); + if (!envAudio.Load(ealFilePath)) + { + envAudio.Load(Path.ChangeExtension(ealFilePath, ".eal")); + } + var sounds = new EffSndBnk(settings.EverQuestDirectory + shortName + "_sndbnk" + LanternStrings.SoundFormatExtension); sounds.Initialize(); + var soundEntries = new EffSounds( settings.EverQuestDirectory + shortName + "_sounds" + LanternStrings.SoundFormatExtension, diff --git a/LanternExtractor/EQ/Sound/EnvAudio.cs b/LanternExtractor/EQ/Sound/EnvAudio.cs index 60ee7bb..a058fbc 100644 --- a/LanternExtractor/EQ/Sound/EnvAudio.cs +++ b/LanternExtractor/EQ/Sound/EnvAudio.cs @@ -13,6 +13,7 @@ public class EnvAudio public EalData Data { get; private set; } + private bool _loaded; private string _ealFilePath; private EalFile _ealFile; private Dictionary _sourceLevels; @@ -29,16 +30,16 @@ public bool Load(string ealFilePath) { if (_ealFilePath == ealFilePath) { - return false; + return _loaded; } - _ealFilePath = ealFilePath; - - if (_ealFilePath == null || !File.Exists(_ealFilePath)) + if (ealFilePath == null || !File.Exists(ealFilePath)) { return false; } + _ealFilePath = ealFilePath; + // Allow other threads to open the same file for reading _ealFile = new EalFile(new FileStream( _ealFilePath, FileMode.Open, FileAccess.Read, FileShare.Read)); @@ -60,7 +61,9 @@ public bool Load(string ealFilePath) s => s.SourceAttributes.EaxAttributes.DirectPathLevel ); - return true; + _loaded = true; + + return _loaded; } private int GetVolumeEq(string soundFile)