summaryrefslogtreecommitdiffstats
path: root/game/client/sound_effect.cc
diff options
context:
space:
mode:
authoruntodesu <kirill@untode.su>2025-03-27 13:28:09 +0500
committeruntodesu <kirill@untode.su>2025-03-27 13:28:09 +0500
commit60cb5a829b54732176936e21511aa5372ae46fab (patch)
treea2d671ea8d19607042e3177ec0bb50d69f6f85a8 /game/client/sound_effect.cc
parentb2d4a09a5621e214636593641d9799b2b1cdcf72 (diff)
downloadvoxelius-60cb5a829b54732176936e21511aa5372ae46fab.tar.bz2
voxelius-60cb5a829b54732176936e21511aa5372ae46fab.zip
Allow game to not die when sound is not available
Diffstat (limited to 'game/client/sound_effect.cc')
-rw-r--r--game/client/sound_effect.cc7
1 files changed, 7 insertions, 0 deletions
diff --git a/game/client/sound_effect.cc b/game/client/sound_effect.cc
index c6cee72..4e01e8c 100644
--- a/game/client/sound_effect.cc
+++ b/game/client/sound_effect.cc
@@ -3,6 +3,8 @@
#include "core/resource.hh"
+#include "client/globals.hh"
+
static emhash8::HashMap<std::string, resource_ptr<SoundEffect>> resource_map;
static std::size_t drwav_read_physfs(void *file, void *output, std::size_t count)
@@ -27,6 +29,11 @@ resource_ptr<SoundEffect> resource::load<SoundEffect>(const char *name, unsigned
return it->second;
}
+ if(globals::sound_ctx == nullptr) {
+ // Sound is disabled
+ return nullptr;
+ }
+
auto file = PHYSFS_openRead(name);
if(file == nullptr) {