From a6bacb3e1722b7507c4bf3fe8191974d741d145b Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Mon, 31 Dec 2012 20:31:55 +0000 Subject: Prevent an error message if a projectile sound iname s not set. --- src/client/soundext.cc | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'src') 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(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); + } + } } } -- cgit v1.2.3