Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10211


Ignore:
Timestamp:
Jan 31, 2015, 3:51:08 PM (9 years ago)
Author:
landauf
Message:

made SpaceShip::engineList_ private again. moved function from ModularSpaceShip to SpaceShip and optimized it a little (neither iterator nor orxonox_casts are necessary here)

Location:
code/branches/presentationFS14/src/orxonox/worldentities/pawns
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentationFS14/src/orxonox/worldentities/pawns/ModularSpaceShip.cc

    r10073 r10211  
    316316    /**
    317317    @brief
    318         Looks for an attached Engine with a certain name.
    319     @param name
    320         The name of the engine to be returned.
    321     @return
    322         Pointer to the engine with the given name, or NULL if not found.
    323     */
    324     Engine* ModularSpaceShip::getEngineByName(std::string name)
    325     {
    326         for(std::vector<Engine*>::iterator it = this->engineList_.begin(); it != this->engineList_.end(); ++it)
    327         {
    328             if(orxonox_cast<Engine*>(*it)->getName() == name)
    329             {
    330                 return orxonox_cast<Engine*>(*it);
    331             }
    332         }
    333         orxout(internal_warning) << "Couldn't find Engine with name \"" << name << "\"." << endl;
    334         return NULL;
    335     }
    336 
    337     /**
    338     @brief
    339318        Detaches a child WorldEntity from this instance.
    340319    */
  • code/branches/presentationFS14/src/orxonox/worldentities/pawns/ModularSpaceShip.h

    r10073 r10211  
    127127                { return this->rotationThrust_; }
    128128
    129             Engine* getEngineByName(std::string name);
    130129            void detach(WorldEntity* object);
    131130
  • code/branches/presentationFS14/src/orxonox/worldentities/pawns/SpaceShip.cc

    r9667 r10211  
    342342    /**
    343343    @brief
     344        Looks for an attached Engine with a certain name.
     345    @param name
     346        The name of the engine to be returned.
     347    @return
     348        Pointer to the engine with the given name, or NULL if not found.
     349    */
     350    Engine* SpaceShip::getEngineByName(const std::string& name)
     351    {
     352        for(size_t i = 0; i < this->engineList_.size(); ++i)
     353            if(this->engineList_[i]->getName() == name)
     354                return this->engineList_[i];
     355
     356        orxout(internal_warning) << "Couldn't find Engine with name \"" << name << "\"." << endl;
     357        return NULL;
     358    }
     359
     360    /**
     361    @brief
    344362        Remove and destroy all Engines of the SpaceShip.
    345363    */
  • code/branches/presentationFS14/src/orxonox/worldentities/pawns/SpaceShip.h

    r10073 r10211  
    124124            bool hasEngine(Engine* engine) const; // Check whether the SpaceShip has a particular Engine.
    125125            Engine* getEngine(unsigned int i); // Get the i-th Engine of the SpaceShip.
     126            Engine* getEngineByName(const std::string& name);
    126127            /**
    127128            @brief Get the list of all Engines that are mounted on the SpaceShip.
     
    270271            float stallSpeed_; //!< The forward speed where no more lift is added.
    271272
    272             std::vector<Engine*> engineList_; //!< The list of all Engines mounted on this SpaceShip.
    273 
    274273        private:
    275274            void registerVariables();
     
    286285            void backupCamera(); // Save the original position and orientation of the camera.
    287286            void resetCamera(); // Reset the camera to its original position.
     287
     288            std::vector<Engine*> engineList_; //!< The list of all Engines mounted on this SpaceShip.
    288289
    289290            Timer timer_;                          //!< Timer for the cooldown duration.
Note: See TracChangeset for help on using the changeset viewer.