MCPcopy Create free account
hub / github.com/TombEngine/TombEngine / EnumerateLegacyTracks

Function EnumerateLegacyTracks

TombEngine/Sound/sound.cpp:415–456  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

413}
414
415void EnumerateLegacyTracks()
416{
417 auto dir = std::filesystem::path{ FullAudioDirectory };
418 if (!std::filesystem::is_directory(dir))
419 {
420 TENLog("Folder \"" + dir.string() + "\" does not exist. ", LogLevel::Warning, LogConfig::All);
421 return;
422 }
423
424 try
425 {
426 // Capture three-digit filenames, or those which start with three digits.
427 std::regex upToThreeDigits("((\\d{1,3})[^\\.]*)");
428 std::smatch result;
429
430 for (const auto& file : std::filesystem::directory_iterator{ dir })
431 {
432 auto fileName = file.path().filename().u8string();
433 auto bResult = std::regex_search(fileName, result, upToThreeDigits);
434 if (!result.empty())
435 {
436 // result[0] is the whole match including the leading backslash, so ignore it
437 // result[1] is the full file name, not including the extension
438 int index = std::stoi(result[2].str());
439 SoundTrackInfo s;
440
441 // TRLE default looping tracks
442 if (index >= LegacyLoopingTrackMin && index <= LegacyLoopingTrackMax)
443 {
444 s.Mode = SoundTrackType::BGM;
445 }
446 s.Name = result[1];
447 SoundTracks.insert(std::make_pair(index, s));
448 SecretSoundIndex = std::max(SecretSoundIndex, index);
449 }
450 }
451 }
452 catch (std::filesystem::filesystem_error const& e)
453 {
454 TENLog(e.what(), LogLevel::Error, LogConfig::All);
455 }
456}
457
458float GetSoundTrackLoudness(SoundTrackType type)
459{

Callers 1

Sound_InitFunction · 0.85

Calls 6

TENLogFunction · 0.85
filenameMethod · 0.45
emptyMethod · 0.45
strMethod · 0.45
insertMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected