diff --git a/src/kart.hpp b/src/kart.hpp index 046732376..832a38de1 100644 --- a/src/kart.hpp +++ b/src/kart.hpp @@ -215,7 +215,7 @@ public: virtual void collectedHerring (Herring* herring); virtual void reset (); virtual void handleZipper (); - virtual void crashed () {}; + virtual void crashed (Kart *k) {}; virtual void doLapCounting (); virtual void update (float dt); virtual void raceFinished (float time); diff --git a/src/physics.cpp b/src/physics.cpp index 43da749a7..f78064dd7 100644 --- a/src/physics.cpp +++ b/src/physics.cpp @@ -137,8 +137,8 @@ void Physics::update(float dt) */ void Physics::KartKartCollision(Kart *kartA, Kart *kartB) { - kartA->crashed(); // will play crash sound for player karts - kartB->crashed(); + kartA->crashed(kartB); // will play crash sound for player karts + kartB->crashed(kartA); Attachment *attachmentA=kartA->getAttachment(); Attachment *attachmentB=kartB->getAttachment(); @@ -213,18 +213,14 @@ btScalar Physics::solveGroup(btCollisionObject** bodies, int numBodies, if(upB->is(UserPointer::UP_FLYABLE)) // 1.1 projectile hits track m_all_collisions.push_back(upB, upA); else if(upB->is(UserPointer::UP_KART)) - upB->getPointerKart()->crashed(); + upB->getPointerKart()->crashed(NULL); } // 2) object a is a kart // ===================== else if(upA->is(UserPointer::UP_KART)) { if(upB->is(UserPointer::UP_TRACK)) - // FIXME: sound disabled for now, since the chassis of the karts hits - // the track when accelerating, causing a constant crash sfx - // to be played. Might be fixed with better physics parameters - // upA->getPointerKart()->crashed(); // Kart hit track - ; + upA->getPointerKart()->crashed(NULL); // Kart hit track else if(upB->is(UserPointer::UP_FLYABLE)) m_all_collisions.push_back(upB, upA); // 2.1 projectile hits kart else if(upB->is(UserPointer::UP_KART)) diff --git a/src/player_kart.cpp b/src/player_kart.cpp index 901ad695d..6cdec05dd 100644 --- a/src/player_kart.cpp +++ b/src/player_kart.cpp @@ -200,9 +200,9 @@ void PlayerKart::update(float dt) } // update //----------------------------------------------------------------------------- -void PlayerKart::crashed() +void PlayerKart::crashed(Kart *kart) { - Kart::crashed(); + Kart::crashed(kart); // A collision is usually reported several times, even when hitting // something only once. This results in a kind of 'machine gun' // noise by playing the crash sound over and over again. To prevent @@ -211,11 +211,15 @@ void PlayerKart::crashed() if(world->getTime() - m_time_last_crash_sound > 0.5f) { - // FIXME: sound disabled for now, since the chassis of the karts hits + // FIXME: sounds when hitting the track (i.e. the kart argument is NULL) + // are disabled for now, since the chassis of the karts hits // the track when accelerating, causing a constant crash sfx // to be played. Might be fixed with better physics parameters - //sound_manager->playSfx( SOUND_CRASH ); - m_time_last_crash_sound = world->getTime(); + if(kart) + { + sound_manager->playSfx( SOUND_CRASH ); + m_time_last_crash_sound = world->getTime(); + } } } // crashed diff --git a/src/player_kart.hpp b/src/player_kart.hpp index 8b4714c04..ad5db213f 100644 --- a/src/player_kart.hpp +++ b/src/player_kart.hpp @@ -51,7 +51,7 @@ public: void update (float); void addMessages (); void action (KartAction action, int value); - void crashed (); + void crashed (Kart *k); void handleZipper (); void collectedHerring (Herring* herring); virtual void setPosition (int p); diff --git a/src/robots/default_robot.hpp b/src/robots/default_robot.hpp index 8ee2604ab..089f2a958 100755 --- a/src/robots/default_robot.hpp +++ b/src/robots/default_robot.hpp @@ -133,7 +133,7 @@ public: void update (float delta) ; void reset (); - virtual void crashed() {m_collided = true;}; + virtual void crashed(Kart *k) {if(k) m_collided = true;}; }; #endif