mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-12 14:31:50 +00:00
small fix
This commit is contained in:
parent
1c6689b6b6
commit
613b7c94ea
1 changed files with 7 additions and 2 deletions
|
|
@ -169,8 +169,6 @@ bool assetload::sound(
|
||||||
std::shared_ptr<AssetCfg> config
|
std::shared_ptr<AssetCfg> config
|
||||||
) {
|
) {
|
||||||
auto cfg = dynamic_cast<SoundCfg*>(config.get());
|
auto cfg = dynamic_cast<SoundCfg*>(config.get());
|
||||||
auto soundFile = paths->find(file);
|
|
||||||
|
|
||||||
bool keepPCM = cfg ? cfg->keepPCM : false;
|
bool keepPCM = cfg ? cfg->keepPCM : false;
|
||||||
|
|
||||||
size_t lastindex = file.find_last_of(".");
|
size_t lastindex = file.find_last_of(".");
|
||||||
|
|
@ -178,13 +176,19 @@ bool assetload::sound(
|
||||||
std::string extensionless = file.substr(0, lastindex);
|
std::string extensionless = file.substr(0, lastindex);
|
||||||
try {
|
try {
|
||||||
std::unique_ptr<audio::Sound> baseSound = nullptr;
|
std::unique_ptr<audio::Sound> baseSound = nullptr;
|
||||||
|
|
||||||
|
// looking for 'sound_name' as base sound
|
||||||
|
auto soundFile = paths->find(file);
|
||||||
if (fs::exists(soundFile)) {
|
if (fs::exists(soundFile)) {
|
||||||
baseSound.reset(audio::load_sound(soundFile, keepPCM));
|
baseSound.reset(audio::load_sound(soundFile, keepPCM));
|
||||||
}
|
}
|
||||||
|
// looking for 'sound_name_0' as base sound
|
||||||
auto variantFile = paths->find(extensionless+"_0"+extension);
|
auto variantFile = paths->find(extensionless+"_0"+extension);
|
||||||
if (fs::exists(variantFile)) {
|
if (fs::exists(variantFile)) {
|
||||||
baseSound.reset(audio::load_sound(variantFile, keepPCM));
|
baseSound.reset(audio::load_sound(variantFile, keepPCM));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// loading sound variants
|
||||||
for (uint i = 1; ; i++) {
|
for (uint i = 1; ; i++) {
|
||||||
auto variantFile = paths->find(extensionless+"_"+std::to_string(i)+extension);
|
auto variantFile = paths->find(extensionless+"_"+std::to_string(i)+extension);
|
||||||
if (!fs::exists(variantFile)) {
|
if (!fs::exists(variantFile)) {
|
||||||
|
|
@ -196,6 +200,7 @@ bool assetload::sound(
|
||||||
}
|
}
|
||||||
catch (std::runtime_error& err) {
|
catch (std::runtime_error& err) {
|
||||||
std::cerr << err.what() << std::endl;
|
std::cerr << err.what() << std::endl;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue