From 6844f88a70a7b746b74696e80a21d9b8f740afcb Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sat, 24 Jan 2009 21:22:39 +0000 Subject: fixes a crash when going to impulse in a ship with an unkown model --- src/client/soundext.cc | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/client/soundext.cc b/src/client/soundext.cc index 4b3e1c7..02613e1 100644 --- a/src/client/soundext.cc +++ b/src/client/soundext.cc @@ -98,6 +98,8 @@ void SoundExt::frame(float elapsed) float speed = entity->speed(); float pitch = 1.0f; float gain = 0.0; + float r = ( entity->model() ? entity->model()->maxbbox().x : entity->radius()); + if (entity->eventstate() == core::Entity::Impulse) { pitch = 1.0f; gain = 1.0f; @@ -110,7 +112,9 @@ void SoundExt::frame(float elapsed) if (state_engineeventbuffer != state_impulsestartbuffer) { audio::update_source(state_engineeventsource, - entity->location() - entity->axis().forward() * entity->model()->maxbbox().y , entity->axis().forward() * speed); + entity->location() - entity->axis().forward() * r , + entity->axis().forward() * speed); + state_engineeventbuffer = audio::play(state_engineeventsource, state_impulsestartbuffer); } } else if (entity->eventstate() == core::Entity::Impulse) { @@ -123,9 +127,10 @@ void SoundExt::frame(float elapsed) pitch = 1.0f; } else { - if (state_engineeventbuffer == state_impulseloopbuffer) { + if (state_engineeventbuffer == state_impulseloopbuffer) { audio::update_source(state_engineeventsource, - entity->location() - entity->axis().forward() * entity->model()->maxbbox().y , entity->axis().forward() * speed); + entity->location() - entity->axis().forward() * r , + entity->axis().forward() * speed); state_engineeventbuffer = audio::play(state_engineeventsource, state_impulsestopbuffer); } state_engineeventbuffer = 0; @@ -135,16 +140,11 @@ void SoundExt::frame(float elapsed) } } - - float x = entity->radius(); - if (entity->model()) - x = entity->model()->maxbbox().x; - audio::update_source(state_engineloopsource, - entity->location() - entity->axis().forward() * x , entity->axis().forward() * speed, pitch, gain); + entity->location() - entity->axis().forward() * r , entity->axis().forward() * speed, pitch, gain); audio::update_source(state_engineeventsource, - entity->location() - entity->axis().forward() * x , entity->axis().forward() * speed); + entity->location() - entity->axis().forward() * r , entity->axis().forward() * speed); } } -- cgit v1.2.3