diff options
author | Stijn Buys <ingar@osirion.org> | 2012-12-31 20:31:55 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2012-12-31 20:31:55 +0000 |
commit | a6bacb3e1722b7507c4bf3fe8191974d741d145b (patch) | |
tree | a48cd95ff21413f5e635771f782f3c757004ee05 /src | |
parent | ba21ed38d5f90465efba225567bf8576a0848352 (diff) |
Prevent an error message if a projectile sound iname s not set.
Diffstat (limited to 'src')
-rw-r--r-- | src/client/soundext.cc | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/client/soundext.cc b/src/client/soundext.cc index 477919c..ed22612 100644 --- a/src/client/soundext.cc +++ b/src/client/soundext.cc @@ -133,13 +133,18 @@ SoundExt::SoundExt(core::Entity *entity) : core::Extension(core::Extension::Soun } else if (entity->type() == core::Entity::Projectile) { core::EntityProjectile *projectile = static_cast<core::EntityProjectile *>(entity); - - state_engineeventsource = audio::Sources::get(); - if (state_engineeventsource) { + // if the sound name is set + if (projectile->projectile_soundname().size()) { state_impulsestartbuffer = audio::Buffers::load("projectiles/" + projectile->projectile_soundname()); - - audio::update_source(state_engineeventsource, entity->location(), math::Vector3f()); - audio::play(state_engineeventsource, state_impulsestartbuffer); + // if the sound file was loaded + if (state_impulsestartbuffer) { + state_engineeventsource = audio::Sources::get(); + // of the OpenAL source is available + if (state_engineeventsource) { + audio::update_source(state_engineeventsource, entity->location(), math::Vector3f()); + audio::play(state_engineeventsource, state_impulsestartbuffer); + } + } } } |