Skip to content

Commit

Permalink
enh: Check bank path exists before loading or unloading when DEBUG_EN…
Browse files Browse the repository at this point in the history
…ABLED (#223)
  • Loading branch information
piiertho authored Jun 18, 2024
1 parent c50306c commit 15908f2
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/fmod_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,10 +470,25 @@ void FmodServer::set_software_format(const Ref<FmodSoftwareFormatSettings>& p_se

Ref<FmodBank> FmodServer::load_bank(const String& pathToBank, unsigned int flag) {
if (cache->has_bank(pathToBank)) return {cache->get_bank(pathToBank)};// bank is already loaded

#ifdef DEBUG_ENABLED
if (!FileAccess::file_exists(pathToBank)) {
GODOT_LOG_ERROR(vformat("Cannot load bank at %s", pathToBank));
return {};
}
#endif

return cache->add_bank(pathToBank, flag);
}

void FmodServer::unload_bank(const String& pathToBank) {
#ifdef DEBUG_ENABLED
if (!FileAccess::file_exists(pathToBank)) {
GODOT_LOG_ERROR(vformat("Cannot unload bank at %s", pathToBank));
return;
}
#endif

cache->remove_bank(pathToBank);
}

Expand Down

0 comments on commit 15908f2

Please sign in to comment.