From af7aa7fd027c30b6a44fa7c2c13c5872bf2a1674 Mon Sep 17 00:00:00 2001 From: yasin-ghannam Date: Mon, 14 Oct 2013 00:51:29 +0000 Subject: [PATCH] Allowing scorer identification if he shot the ball with a projectile. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@14250 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- src/items/flyable.cpp | 5 +++++ src/items/flyable.hpp | 2 ++ src/physics/physics.cpp | 7 +++++++ 3 files changed, 14 insertions(+) diff --git a/src/items/flyable.cpp b/src/items/flyable.cpp index 2655a4d09..ed35ac2af 100644 --- a/src/items/flyable.cpp +++ b/src/items/flyable.cpp @@ -515,4 +515,9 @@ HitEffect* Flyable::getHitEffect() const return new Explosion(getXYZ(), "explosion", "explosion_cake.xml"); } // getHitEffect +// ---------------------------------------------------------------------------- +unsigned int Flyable::getOwnerId() +{ + return m_owner->getWorldKartId(); +} /* EOF */ diff --git a/src/items/flyable.hpp b/src/items/flyable.hpp index bfd46835f..b10960aa9 100644 --- a/src/items/flyable.hpp +++ b/src/items/flyable.hpp @@ -208,6 +208,8 @@ public: * call, or if the inheriting object will update TerrainInfo itself * (or perhaps not at all if it is not needed). */ void setDoTerrainInfo(bool d) { m_do_terrain_info = d; } + // ------------------------------------------------------------------------ + unsigned int getOwnerId(); }; // Flyable #endif diff --git a/src/physics/physics.cpp b/src/physics/physics.cpp index 8ac559baf..0b955f97a 100644 --- a/src/physics/physics.cpp +++ b/src/physics/physics.cpp @@ -235,6 +235,13 @@ void Physics::update(float dt) // ------------------------------- p->getUserPointer(0)->getPointerFlyable() ->hit(NULL, p->getUserPointer(1)->getPointerPhysicalObject()); + PhysicalObject* obj = p->getUserPointer(1)->getPointerPhysicalObject(); + if(obj->isSoccerBall()) + { + int kartId = p->getUserPointer(0)->getPointerFlyable()->getOwnerId(); + SoccerWorld* soccerWorld = (SoccerWorld*)World::getWorld(); + soccerWorld->setLastKartTohitBall(kartId); + } } else if(p->getUserPointer(1)->is(UserPointer::UP_KART))