Skip to content

Commit

Permalink
Fallback to defaults.eal for newer clients
Browse files Browse the repository at this point in the history
  • Loading branch information
nickgal committed Jul 21, 2023
1 parent f3d8542 commit 9fd53ce
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
8 changes: 7 additions & 1 deletion LanternExtractor/EQ/ArchiveExtractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
13 changes: 8 additions & 5 deletions LanternExtractor/EQ/Sound/EnvAudio.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class EnvAudio

public EalData Data { get; private set; }

private bool _loaded;
private string _ealFilePath;
private EalFile _ealFile;
private Dictionary<string, int> _sourceLevels;
Expand All @@ -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));
Expand All @@ -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)
Expand Down

0 comments on commit 9fd53ce

Please sign in to comment.