[Orxonox-commit 5548] r10211 - code/branches/presentationFS14/src/orxonox/worldentities/pawns

landauf at orxonox.net landauf at orxonox.net
Sat Jan 31 15:51:08 CET 2015


Author: landauf
Date: 2015-01-31 15:51:08 +0100 (Sat, 31 Jan 2015)
New Revision: 10211

Modified:
   code/branches/presentationFS14/src/orxonox/worldentities/pawns/ModularSpaceShip.cc
   code/branches/presentationFS14/src/orxonox/worldentities/pawns/ModularSpaceShip.h
   code/branches/presentationFS14/src/orxonox/worldentities/pawns/SpaceShip.cc
   code/branches/presentationFS14/src/orxonox/worldentities/pawns/SpaceShip.h
Log:
made SpaceShip::engineList_ private again. moved function from ModularSpaceShip to SpaceShip and optimized it a little (neither iterator nor orxonox_casts are necessary here)

Modified: code/branches/presentationFS14/src/orxonox/worldentities/pawns/ModularSpaceShip.cc
===================================================================
--- code/branches/presentationFS14/src/orxonox/worldentities/pawns/ModularSpaceShip.cc	2015-01-31 14:35:49 UTC (rev 10210)
+++ code/branches/presentationFS14/src/orxonox/worldentities/pawns/ModularSpaceShip.cc	2015-01-31 14:51:08 UTC (rev 10211)
@@ -315,27 +315,6 @@
 
     /**
     @brief
-        Looks for an attached Engine with a certain name.
-    @param name
-        The name of the engine to be returned.
-    @return
-        Pointer to the engine with the given name, or NULL if not found.
-    */
-    Engine* ModularSpaceShip::getEngineByName(std::string name)
-    {
-        for(std::vector<Engine*>::iterator it = this->engineList_.begin(); it != this->engineList_.end(); ++it)
-        {
-            if(orxonox_cast<Engine*>(*it)->getName() == name)
-            {
-                return orxonox_cast<Engine*>(*it);
-            }
-        }
-        orxout(internal_warning) << "Couldn't find Engine with name \"" << name << "\"." << endl;
-        return NULL;
-    }
-
-    /**
-    @brief
         Detaches a child WorldEntity from this instance.
     */
     void ModularSpaceShip::detach(WorldEntity* object)

Modified: code/branches/presentationFS14/src/orxonox/worldentities/pawns/ModularSpaceShip.h
===================================================================
--- code/branches/presentationFS14/src/orxonox/worldentities/pawns/ModularSpaceShip.h	2015-01-31 14:35:49 UTC (rev 10210)
+++ code/branches/presentationFS14/src/orxonox/worldentities/pawns/ModularSpaceShip.h	2015-01-31 14:51:08 UTC (rev 10211)
@@ -126,7 +126,6 @@
             inline float getRotationThrust()
                 { return this->rotationThrust_; }
 
-            Engine* getEngineByName(std::string name);
             void detach(WorldEntity* object);
 
             virtual void updatePartAssignment();

Modified: code/branches/presentationFS14/src/orxonox/worldentities/pawns/SpaceShip.cc
===================================================================
--- code/branches/presentationFS14/src/orxonox/worldentities/pawns/SpaceShip.cc	2015-01-31 14:35:49 UTC (rev 10210)
+++ code/branches/presentationFS14/src/orxonox/worldentities/pawns/SpaceShip.cc	2015-01-31 14:51:08 UTC (rev 10211)
@@ -341,6 +341,24 @@
 
     /**
     @brief
+        Looks for an attached Engine with a certain name.
+    @param name
+        The name of the engine to be returned.
+    @return
+        Pointer to the engine with the given name, or NULL if not found.
+    */
+    Engine* SpaceShip::getEngineByName(const std::string& name)
+    {
+        for(size_t i = 0; i < this->engineList_.size(); ++i)
+            if(this->engineList_[i]->getName() == name)
+                return this->engineList_[i];
+
+        orxout(internal_warning) << "Couldn't find Engine with name \"" << name << "\"." << endl;
+        return NULL;
+    }
+
+    /**
+    @brief
         Remove and destroy all Engines of the SpaceShip.
     */
     void SpaceShip::removeAllEngines()

Modified: code/branches/presentationFS14/src/orxonox/worldentities/pawns/SpaceShip.h
===================================================================
--- code/branches/presentationFS14/src/orxonox/worldentities/pawns/SpaceShip.h	2015-01-31 14:35:49 UTC (rev 10210)
+++ code/branches/presentationFS14/src/orxonox/worldentities/pawns/SpaceShip.h	2015-01-31 14:51:08 UTC (rev 10211)
@@ -123,6 +123,7 @@
             void addEngine(Engine* engine); // Add an Engine to the SpaceShip.
             bool hasEngine(Engine* engine) const; // Check whether the SpaceShip has a particular Engine.
             Engine* getEngine(unsigned int i); // Get the i-th Engine of the SpaceShip.
+            Engine* getEngineByName(const std::string& name);
             /**
             @brief Get the list of all Engines that are mounted on the SpaceShip.
             @return Returns a vector of all Engines of the SpaceShip.
@@ -269,8 +270,6 @@
             float lift_;       //!< The amount of lift that is added.
             float stallSpeed_; //!< The forward speed where no more lift is added.
 
-            std::vector<Engine*> engineList_; //!< The list of all Engines mounted on this SpaceShip.
-
         private:
             void registerVariables();
             virtual bool isCollisionTypeLegal(WorldEntity::CollisionType type) const;
@@ -286,6 +285,8 @@
             void backupCamera(); // Save the original position and orientation of the camera.
             void resetCamera(); // Reset the camera to its original position.
 
+            std::vector<Engine*> engineList_; //!< The list of all Engines mounted on this SpaceShip.
+
             Timer timer_;                          //!< Timer for the cooldown duration.
             float shakeDt_;                        //!< Temporary variable for the shaking of the camera.
             Vector3 cameraOriginalPosition_;       //!< The original position of the camera before shaking it.




More information about the Orxonox-commit mailing list