Skip to content

Commit

Permalink
Merge pull request #284 from Laupetin/fix/guessing-sound-filenames
Browse files Browse the repository at this point in the history
fix: stop removing extensions of soundaliases
  • Loading branch information
Laupetin authored Oct 12, 2024
2 parents dadce3d + 0a42393 commit bc0f42a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 19 deletions.
4 changes: 1 addition & 3 deletions src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderSoundBank.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -515,9 +515,7 @@ namespace
if (!aliasFileName.m_value.empty())
{

fs::path p(aliasFileName.m_value);
p.replace_extension();
alias.assetFileName = memory.Dup(p.string().c_str());
alias.assetFileName = memory.Dup(aliasFileName.m_value.c_str());
alias.assetId = Common::SND_HashName(alias.assetFileName);
}

Expand Down
17 changes: 1 addition & 16 deletions src/ObjLoading/ObjContainer/SoundBank/SoundBankWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,21 +225,6 @@ class SoundBankWriterImpl : public SoundBankWriter
return false;
}

bool GuessFilenameAndLoadFile(const std::string& filePath, const SoundBankEntryInfo& sound, std::unique_ptr<char[]>& soundData, size_t& soundSize)
{
fs::path pathWithExtension = fs::path(filePath).concat(".wav");
auto file = m_asset_search_path->Open(pathWithExtension.string());
if (file.IsOpen())
return LoadWavFile(file, sound, soundData, soundSize);

pathWithExtension = fs::path(filePath).concat(".flac");
file = m_asset_search_path->Open(pathWithExtension.string());
if (file.IsOpen())
return LoadFlacFile(file, pathWithExtension.string(), sound, soundData, soundSize);

return false;
}

bool WriteEntries()
{
GoTo(DATA_OFFSET);
Expand All @@ -251,7 +236,7 @@ class SoundBankWriterImpl : public SoundBankWriter
size_t soundSize;
std::unique_ptr<char[]> soundData;

if (!LoadFileByExtension(soundFilePath, sound, soundData, soundSize) && !GuessFilenameAndLoadFile(soundFilePath, sound, soundData, soundSize))
if (!LoadFileByExtension(soundFilePath, sound, soundData, soundSize))
{
std::cerr << std::format("Unable to find a compatible file for sound {}\n", soundFilePath);
return false;
Expand Down

0 comments on commit bc0f42a

Please sign in to comment.