Index: code/trunk/src/orxonox/overlays/map/Map.cc
===================================================================
--- code/branches/map/src/orxonox/overlays/map/Map.cc	(revision 3082)
+++ code/trunk/src/orxonox/overlays/map/Map.cc	(revision 3089)
@@ -26,5 +26,5 @@
 #include "OrxonoxStableHeaders.h"
 #include "Map.h"
- 
+
 #include <string>
 #include "util/String.h"
@@ -57,5 +57,5 @@
 #include "objects/RadarViewable.h"
 #include "objects/controllers/HumanController.h"
- 
+
  namespace orxonox
  {
@@ -79,5 +79,5 @@
         RegisterObject(Map);
         Map::singletonMap_s=this;
-        
+
         //Getting Scene Manager (Hack)
         if( !sManager_ )
@@ -90,5 +90,5 @@
             Map::setMapSceneManager( Ogre::Root::getSingletonPtr()->createSceneManager( Ogre::ST_GENERIC,"MapScene" ) );
         }
-        
+
         this->playerShipNode_ = 0;
         //this->sNode_ = new Ogre::SceneNode(sManager_);
@@ -96,5 +96,5 @@
         //overlay_ = oManager_->create("Map");
         //overlay_ is member of OrxonoxOverlay
-        
+
         //Not Showing the map as default
         //this->isVisible_=false;
@@ -104,14 +104,14 @@
         //TestEntity
         //Ogre::Entity * ent = mapSceneM_s->createEntity("ent", "drone.mesh");
-        
+
         //Map::getMapSceneManager()->getRootSceneNode()->attachObject( ent );
         /*sNode_->setPosition(0,0,-50);
         overlay_->add3D(sNode_);
         */
-	
-        
-        
-
-        
+
+
+
+
+
         // Alter the camera aspect ratio to match the viewport
         //mCamera->setAspectRatio(Real(vp->getActualWidth()) / Real(vp->getActualHeight()));
@@ -122,5 +122,5 @@
         //Cam_->setRenderingDistance(0);
         CamNode_ = Map::getMapSceneManager()->getRootSceneNode()->createChildSceneNode();
-        
+
 
         //Create overlay material
@@ -148,5 +148,5 @@
 /*
         Ogre::Overlay* pOverlay = Ogre::OverlayManager::getSingleton().create("Overlay1");
-        
+
         // Create a panel with RenderToTexture texture
         Ogre::OverlayContainer* m_pOverlayPanel = static_cast<Ogre::OverlayContainer*>(Ogre::OverlayManager::getSingleton().createOverlayElement("Panel","OverlayPanelName%d"));
@@ -155,5 +155,5 @@
         m_pOverlayPanel->setDimensions(500, 300);
         // Give overlay a texture
-        m_pOverlayPanel->setMaterialName(camMat_id); 
+        m_pOverlayPanel->setMaterialName(camMat_id);
         pOverlay->add2D(m_pOverlayPanel);
         pOverlay->show();
@@ -165,9 +165,9 @@
         m_pOverlayPanel->setDimensions(600, 400);
         // Give overlay a texture
-        m_pOverlayPanel->setMaterialName(camMat_id); 
+        m_pOverlayPanel->setMaterialName(camMat_id);
         overlay_->add2D(m_pOverlayPanel);
 
         //Add Borders
-        Ogre::BorderPanelOverlayElement* oBorder = static_cast<Ogre::BorderPanelOverlayElement*>(Ogre::OverlayManager::getSingletonPtr()->createOverlayElement("BorderPanel", "MapBorderPanel" + getUniqueNumberString()));
+//        Ogre::BorderPanelOverlayElement* oBorder = static_cast<Ogre::BorderPanelOverlayElement*>(Ogre::OverlayManager::getSingletonPtr()->createOverlayElement("BorderPanel", "MapBorderPanel" + getUniqueNumberString()));
 /*
 //TODO border size
@@ -201,16 +201,16 @@
         plane_ent->setMaterialName("Map/Grid");
         planeNode_->attachObject(plane_ent);
-        
+
         planeNode_->scale(10,1,10);
 //        planeNode_->attachObject(movablePlane_);
         //Ogre::Material plane_mat = Ogre::MaterialManager::getSingletonPtr()->getByName("rock");
-        
+
 
         //ToDo create material script
-        Ogre::MaterialPtr myManualObjectMaterial = Ogre::MaterialManager::getSingleton().create("Map/Line","General"); 
-        myManualObjectMaterial->setReceiveShadows(false); 
-        myManualObjectMaterial->getTechnique(0)->setLightingEnabled(true); 
-        myManualObjectMaterial->getTechnique(0)->getPass(0)->setDiffuse(1,1,0,0); 
-        myManualObjectMaterial->getTechnique(0)->getPass(0)->setAmbient(1,1,0); 
+        Ogre::MaterialPtr myManualObjectMaterial = Ogre::MaterialManager::getSingleton().create("Map/Line","General");
+        myManualObjectMaterial->setReceiveShadows(false);
+        myManualObjectMaterial->getTechnique(0)->setLightingEnabled(true);
+        myManualObjectMaterial->getTechnique(0)->getPass(0)->setDiffuse(1,1,0,0);
+        myManualObjectMaterial->getTechnique(0)->getPass(0)->setAmbient(1,1,0);
         myManualObjectMaterial->getTechnique(0)->getPass(0)->setSelfIllumination(1,1,0);
 
@@ -306,27 +306,30 @@
             }
             it->updateMapPosition();
-            
-
-
-
-            
-            
-        }
-    }
-    
-
-    
+
+
+
+
+
+
+        }
+    }
+
+
+
     void Map::XMLPort(Element& xmlElement, XMLPort::Mode mode)
     {
         SUPER(Map, XMLPort, xmlElement, mode);
-    }	
+    }
 
     void Map::changedOwner()
     {
+        SUPER(Map, changedOwner);
         //COUT(0) << "shipptr" << this->getOwner()->getReverseCamera() << std::endl;
-        if(this->getOwner()->getReverseCamera())
+
+        ControllableEntity* entity = dynamic_cast<ControllableEntity*>(this->getOwner());
+        if(entity && entity->getReverseCamera())
         {
             //COUT(0) << "foo";
-            this->getOwner()->getReverseCamera()->attachCamera(this->Cam_);
+            entity->getReverseCamera()->attachCamera(this->Cam_);
         }
     }
@@ -351,5 +354,5 @@
         }
     }
-    
+
     //Static function to toggle visibility of the map
     void Map::openMap()
@@ -365,5 +368,5 @@
         }
     }
-    
+
     void Map::tick(float dt)
     {
@@ -375,5 +378,5 @@
             updatePositions();
         //Cam_->roll(Degree(1));
-        
+
     }
 
@@ -403,7 +406,7 @@
 */
         singletonMap_s->CamNode_->pitch( (Degree)(value.y * singletonMap_s->mouseLookSpeed_), Ogre::Node::TS_LOCAL);
-        
-    }
-    
+
+    }
+
     void Map::Zoom(const Vector2& value)
     {
Index: code/trunk/src/orxonox/overlays/map/Map.h
===================================================================
--- code/branches/map/src/orxonox/overlays/map/Map.h	(revision 3082)
+++ code/trunk/src/orxonox/overlays/map/Map.h	(revision 3089)
@@ -62,5 +62,5 @@
 
         static Ogre::MaterialPtr createRenderCamera(Ogre::Camera * cam, std::string matName);
-        
+
         static void openMap();
 
@@ -92,5 +92,5 @@
 
 
-        
+
     private: // functions
 
@@ -118,5 +118,5 @@
         int mouseLookSpeed_;
         bool isVisible_;
-     
+
     friend class RadarViewable;
     };
