Skip to content

Commit

Permalink
Check SFX folder for on remastered levels (#1310)
Browse files Browse the repository at this point in the history
For TR2-3 levels check `../SFX/MAIN.SFX` as well as checking for OG `MAIN.SFX`.
People can then open the levels from the remastered folders without having to copy MAIN.SFX around, or even know about it.
Closes #1309.
  • Loading branch information
chreden authored Nov 17, 2024
1 parent f9bcf25 commit e7ab021
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
13 changes: 12 additions & 1 deletion trlevel/Level.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2200,7 +2200,7 @@ namespace trlevel

void Level::load_sound_fx(const LoadCallbacks& callbacks)
{
if (auto main = _files->load_file(std::format("{}MAIN.SFX", trview::path_for_filename(_filename))))
if (auto main = load_main_sfx())
{
std::basic_ispanstream<uint8_t> sfx_file{ { *main } };

Expand Down Expand Up @@ -2230,4 +2230,15 @@ namespace trlevel
}
}
}

std::optional<std::vector<uint8_t>> Level::load_main_sfx() const
{
const auto path = trview::path_for_filename(_filename);
const auto og_main = _files->load_file(std::format("{}MAIN.SFX", path));
if (og_main.has_value())
{
return og_main;
}
return _files->load_file(std::format("{}../SFX/MAIN.SFX", path));
}
}
1 change: 1 addition & 0 deletions trlevel/Level.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ namespace trlevel

void generate_sounds_tr1(const LoadCallbacks& callbacks);
void load_sound_fx(const LoadCallbacks& callbacks);
std::optional<std::vector<uint8_t>> load_main_sfx() const;

PlatformAndVersion _platform_and_version;

Expand Down

0 comments on commit e7ab021

Please sign in to comment.