Index: /code/trunk/src/modules/overlays/hud/HUDEnemyHealthBar.cc
===================================================================
--- /code/trunk/src/modules/overlays/hud/HUDEnemyHealthBar.cc	(revision 9258)
+++ /code/trunk/src/modules/overlays/hud/HUDEnemyHealthBar.cc	(revision 9259)
@@ -23,5 +23,5 @@
  *      Matthias Spalinger
  *   Co-authors:
- *      ...
+ *      Fabian 'x3n' Landau
  *
  */
@@ -29,22 +29,6 @@
 #include "HUDEnemyHealthBar.h"
 
-#include <OgreCamera.h>
-
-#include "util/Convert.h"
 #include "core/ConfigValueIncludes.h"
-#include "core/CoreIncludes.h"
-#include "core/XMLPort.h"
-#include "infos/PlayerInfo.h"
-#include "overlays/OverlayGroup.h"
-#include "CameraManager.h"
-#include "graphics/Camera.h"
-#include "util/Math.h"
-#include "HUDNavigation.h"
-#include "core/input/InputManager.h"
-#include "controllers/HumanController.h"
-#include "core/GraphicsManager.h"
-#include "Scene.h"
-#include "Radar.h"
-#include "controllers/NewHumanController.h"
+#include "worldentities/pawns/Pawn.h"
 
 namespace orxonox
@@ -57,16 +41,9 @@
 
         this->setConfigValues();
-        setSensibility(0.1f);
         this->owner_ = 0;
-        markerLimit_ = 3; //TODO connect with markerLimit_ from the settings / from HUDNavigation.cc
-        currentYaw = 0;
-        currentPitch = 0;
-
-        this->getOverlayText()->setCaption("");
     }
 
     HUDEnemyHealthBar::~HUDEnemyHealthBar()
     {
-        sortedObjectList_.clear();
     }
 
@@ -76,135 +53,37 @@
     }
 
-    void HUDEnemyHealthBar::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    void HUDEnemyHealthBar::tick(float dt)
     {
-        SUPER(HUDEnemyHealthBar, XMLPort, xmlelement, mode);
+        this->updateTarget();
 
-        XMLPortParam ( HUDEnemyHealthBar, "sensibility", setSensibility, getSensibility, xmlelement, mode );
+        SUPER(HUDEnemyHealthBar, tick, dt);
     }
 
-    bool compareDist ( std::pair<RadarViewable*, unsigned int > a, std::pair<RadarViewable*, unsigned int > b )
+    void HUDEnemyHealthBar::updateTarget()
     {
-        return a.second<b.second;
-    }
-
-    void HUDEnemyHealthBar::tick(float dt)
-    {
-        if (!useEnemyBar_){
-            this->setValue(0); //TODO hide it instead of setting it to 0
-            this->getOverlayText()->setCaption("");
-            return;
+        Pawn* pawn = NULL;
+        if (this->owner_ && this->useEnemyBar_)
+        {
+            // Get the owner's current target (target is usually a Model)
+            WorldEntity* target = this->owner_->getTarget();
+            // Find the Pawn that belongs to this target (if any)
+            while (target && !target->isA(Class(Pawn)))
+                target = target->getParent();
+            pawn = orxonox_cast<Pawn*>(target);
+            // Don't show the HealthBar if the pawn is invisible
+            if (pawn && !pawn->isVisible())
+                pawn = NULL;
         }
-
-        Camera* cam = CameraManager::getInstance().getActiveCamera();
-        if ( cam == NULL )
-            return;
-        const Matrix4& camTransform = cam->getOgreCamera()->getProjectionMatrix() * cam->getOgreCamera()->getViewMatrix();
-
-        unsigned int markerCount_ = 0;
-
-        for ( sortedList::iterator listIt = sortedObjectList_.begin(); listIt != sortedObjectList_.end(); ++listIt )
-        {
-            listIt->second = ( int ) ( ( listIt->first->getRVWorldPosition() - HumanController::getLocalControllerSingleton()->getControllableEntity()->getWorldPosition() ).length() + 0.5f );
-        }
-    
-        sortedObjectList_.sort ( compareDist );
-
-        for ( sortedList::iterator listIt = sortedObjectList_.begin(); listIt != sortedObjectList_.end(); ++markerCount_, ++listIt )
-        {
-            if ( markerCount_ < markerLimit_ )
-            {        
-                // Transform to screen coordinates and reverse x-axis
-                Vector3 pos = (camTransform * listIt->first->getRVWorldPosition());
-                pos.x = -pos.x;                
-
-                // get mouse position
-                if(this->getOwner() && dynamic_cast<ControllableEntity*>(this->getOwner())->getController() && dynamic_cast<NewHumanController*>(dynamic_cast<ControllableEntity*>(this->getOwner())->getController()))
-                {
-                    currentYaw = dynamic_cast<NewHumanController*>(dynamic_cast<ControllableEntity*>(this->getOwner())->getController())->getCurrentYaw();
-                    currentPitch = dynamic_cast<NewHumanController*>(dynamic_cast<ControllableEntity*>(this->getOwner())->getController())->getCurrentPitch();
-                }
-                // Compare cursor position to object position
-                if ( fabs(pos.x - currentYaw) < sens_ && fabs(pos.y - currentPitch) < sens_ )
-                {
-                    this->owner_ = orxonox_cast<Pawn*>(listIt->first);
-                    break;
-                }
-            }
-            this->owner_ = 0;
-        }
-
-
-
-        if (this->owner_)
-        {
-            this->setValue(this->owner_->getHealth() / this->owner_->getInitialHealth());
-            this->getOverlayText()->setCaption(multi_cast<std::string>(static_cast<int>(this->owner_->getHealth())));
-        }
-        else
-        {
-            this->setValue(0);      //TODO hide it instead of setting it to zero
-            this->getOverlayText()->setCaption("");
-        }
-
-        if (this->getTextUseBarColour())
-            this->getOverlayText()->setColour(this->getCurrentBarColour());
-    }
-
-    void HUDEnemyHealthBar::addObject ( RadarViewable* object )
-    {
-        if( showObject(object)==false )
-            return;
-    
-        if ( sortedObjectList_.size() >= markerLimit_ )
-            if ( object == NULL )
-                return;
-    
-        sortedObjectList_.push_front ( std::make_pair ( object, ( unsigned int ) 0 ) );
-
-        //remove duplicates
-        sortedObjectList_.unique();
-    }
-
-    bool HUDEnemyHealthBar::showObject(RadarViewable* rv)
-    {
-        if ( rv == dynamic_cast<RadarViewable*> ( this->getOwner() ) )
-            return false;
-        assert( rv->getWorldEntity() );
-        if ( rv->getWorldEntity()->isVisible()==false || rv->getRadarVisibility()==false )
-            return false;
-        return true;
-    }
-
-    void HUDEnemyHealthBar::removeObject ( RadarViewable* viewable )
-    {
-        for ( sortedList::iterator listIt = sortedObjectList_.begin(); listIt != sortedObjectList_.end(); ++listIt )
-        {
-            if ( (listIt->first) == viewable )
-            {
-                sortedObjectList_.erase ( listIt );
-                break;
-            }
-    
-        }
-
-    }
-
-    void HUDEnemyHealthBar::objectChanged(RadarViewable* viewable)
-    {
-        // TODO: niceification neccessary - and while you're at it: the same function exists in HUDNavigation.cc ;)
-        removeObject(viewable);
-        addObject(viewable);
+        // Set the pawn as owner of the HealthBar
+        this->setHealthBarOwner(pawn);
+        this->setVisible(pawn != NULL);
     }
 
     void HUDEnemyHealthBar::changedOwner()
     {
-    
-        const std::set<RadarViewable*>& respawnObjects = this->getOwner()->getScene()->getRadar()->getRadarObjects();
-        for ( std::set<RadarViewable*>::const_iterator it = respawnObjects.begin(); it != respawnObjects.end(); ++it )
-        {
-            if ( ! ( *it )->isHumanShip_ )
-                this->addObject ( *it );
-        }
+        SUPER(HUDEnemyHealthBar, changedOwner);
+
+        this->owner_ = orxonox_cast<ControllableEntity*>(this->getOwner());
+        this->updateTarget();
     }
-
 }
Index: /code/trunk/src/modules/overlays/hud/HUDEnemyHealthBar.h
===================================================================
--- /code/trunk/src/modules/overlays/hud/HUDEnemyHealthBar.h	(revision 9258)
+++ /code/trunk/src/modules/overlays/hud/HUDEnemyHealthBar.h	(revision 9259)
@@ -23,5 +23,5 @@
  *      Matthias Spalinger
  *   Co-authors:
- *      ...
+ *      Fabian 'x3n' Landau
  *
  */
@@ -30,53 +30,24 @@
 #define _HUDEnemyHealthBar_H__
 
-#include "interfaces/RadarViewable.h"
-#include "worldentities/pawns/Pawn.h"
-
 #include "HUDHealthBar.h"
-#include "interfaces/RadarListener.h"
 
 namespace orxonox
 {
-    class _OverlaysExport HUDEnemyHealthBar : public HUDHealthBar, public RadarListener
+    class _OverlaysExport HUDEnemyHealthBar : public HUDHealthBar
     {
         public:
             HUDEnemyHealthBar(BaseObject* creator);
             virtual ~HUDEnemyHealthBar();
+
             void setConfigValues();
-
-            bool compareDistance ( std::pair<RadarViewable*, unsigned int > a, std::pair<RadarViewable*, unsigned int > b );
-
-            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
             virtual void tick(float dt);
-
-            //RadarListener interface
-            void addObject ( RadarViewable* object );
-            void removeObject ( RadarViewable* viewable );
-            void objectChanged(RadarViewable* viewable);
-            virtual void radarTick ( float dt ) {}
-            inline float getRadarSensitivity() const
-                { return 1.0f; }
 
             void changedOwner();
 
         private:
+            void updateTarget();
 
-            void setSensibility (float sense){
-                this->sens_ = sense;}
-            float getSensibility(){
-                return this->sens_;}
-
-            bool showObject(RadarViewable* rv);
-        
-            typedef std::list < std::pair<RadarViewable*, unsigned int > > sortedList;
-            sortedList sortedObjectList_;
-
-            Pawn* owner_;
-            float sens_;
+            ControllableEntity* owner_;
             bool useEnemyBar_;
-            unsigned int markerLimit_;
-
-            float currentYaw;
-            float currentPitch;
     };
 }
Index: /code/trunk/src/modules/overlays/hud/HUDHealthBar.h
===================================================================
--- /code/trunk/src/modules/overlays/hud/HUDHealthBar.h	(revision 9258)
+++ /code/trunk/src/modules/overlays/hud/HUDHealthBar.h	(revision 9259)
@@ -110,8 +110,6 @@
                 { return this->textoverlay_->getSpaceWidth(); }
 
-            inline void setOverlayText(SmartPtr<OverlayText> textoverlay)
-                { this->textoverlay_ = textoverlay; }
-            inline SmartPtr<OverlayText> getOverlayText() const
-                {return this->textoverlay_; }
+            inline void setHealthBarOwner(Pawn* owner)
+                { this->owner_ = owner; }
 
         private:
Index: /code/trunk/src/modules/pong/PongScore.cc
===================================================================
--- /code/trunk/src/modules/pong/PongScore.cc	(revision 9258)
+++ /code/trunk/src/modules/pong/PongScore.cc	(revision 9259)
@@ -130,9 +130,9 @@
             {
                 if (this->bShowName_ && this->bShowScore_ && player1_ != NULL)
-                        output1 = name1 + " - " + score1;
+                    output1 = name1 + " - " + score1;
                 else if (this->bShowScore_)
-                        output1 = score1;
+                    output1 = score1;
                 else if (this->bShowName_)
-                        output1 = name1;
+                    output1 = name1;
             }
 
