Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 17, 2016, 10:29:21 PM (8 years ago)
Author:
landauf
Message:

merged branch cpp11_v3 back to trunk

Location:
code/trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/orxonox/items/Engine.cc

    r9667 r11071  
    5050        RegisterObject(Engine);
    5151
    52         this->ship_ = 0;
     52        this->ship_ = nullptr;
    5353        this->shipID_ = OBJECTID_UNKNOWN;
    5454        this->relativePosition_ = Vector3::ZERO;
     
    136136    void Engine::networkcallback_shipID()
    137137    {
    138         this->ship_ = 0;
     138        this->ship_ = nullptr;
    139139
    140140        if (this->shipID_ != OBJECTID_UNKNOWN)
     
    155155    void Engine::run(float dt)
    156156    {
    157         if (this->ship_ == NULL)
     157        if (this->ship_ == nullptr)
    158158        {
    159159            if (this->shipID_ != 0)
     
    161161                this->networkcallback_shipID();
    162162
    163                 if (this->ship_ == NULL)
     163                if (this->ship_ == nullptr)
    164164                    return;
    165165            }
  • code/trunk/src/orxonox/items/Engine.h

    r9667 r11071  
    5959            virtual ~Engine();
    6060
    61             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     61            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
    6262            void setConfigValues();
    6363
     
    6767            /**
    6868            @brief Get the SpaceShip this Engine is mounted on.
    69             @return Returns a pointer to the SpaceShip. NULL if it isn't mounted on any ship.
     69            @return Returns a pointer to the SpaceShip. nullptr if it isn't mounted on any ship.
    7070            */
    7171            inline SpaceShip* getShip() const
  • code/trunk/src/orxonox/items/MultiStateEngine.cc

    r9939 r11071  
    6767        else
    6868        {
    69             this->defEngineSndBoost_ = 0;
    70             this->defEngineSndNormal_ = 0;
    71             this->lua_ = 0;
     69            this->defEngineSndBoost_ = nullptr;
     70            this->defEngineSndNormal_ = nullptr;
     71            this->lua_ = nullptr;
    7272        }
    7373        this->state_ = 0;
     
    8585            {
    8686                // We have no ship, so the effects are not attached and won't be destroyed automatically
    87                 for (std::vector<EffectContainer*>::const_iterator it = this->effectContainers_.begin(); it != this->effectContainers_.end(); ++it)
    88                     for (std::vector<WorldEntity*>::const_iterator it2 = (*it)->getEffectsBegin(); it2 != (*it)->getEffectsBegin(); ++it2)
    89                         (*it2)->destroy();
     87                for (EffectContainer* container : this->effectContainers_)
     88                    for (WorldEntity* effect : container->getEffects())
     89                        effect->destroy();
    9090                if (this->defEngineSndNormal_)
    9191                    this->defEngineSndNormal_->destroy();
     
    124124                this->state_ = 0;
    125125                if (this->getShip()->isBoosting() && forward)
    126                     this->state_ = Boost;
     126                    this->state_ = EngineState::Boost;
    127127                else if (forward && !this->state_) // this->state_ == Boost
    128                     this->state_ = Normal;
     128                    this->state_ = EngineState::Normal;
    129129                else if (direction.z > 0.0 && velocity.z < 0.0)
    130                     this->state_ = Brake;
     130                    this->state_ = EngineState::Brake;
    131131                else
    132                     this->state_ = Idle;
    133 
    134                 if (this->state_ == Idle && this->getSpeedAdd() > 0)
    135                     this->state_ = Normal;
     132                    this->state_ = EngineState::Idle;
     133
     134                if (this->state_ == EngineState::Idle && this->getSpeedAdd() > 0)
     135                    this->state_ = EngineState::Normal;
    136136            }
    137137
     
    141141
    142142                float pitch = velocity.length();
    143                 if (this->state_ & Normal)
     143                if (this->state_ & EngineState::Normal)
    144144                    defEngineSndNormal_->setPitch(clamp(pitch/MAX_VELOCITY_NORMAL + 1, 0.5f, 2.0f));
    145                 if (this->state_ & Boost)
     145                if (this->state_ & EngineState::Boost)
    146146                    defEngineSndBoost_->setPitch(clamp(pitch/MAX_VELOCITY_BOOST + 1, 0.5f, 2.0f));
    147147
    148                 if (changes & Idle)
    149                 {
    150                     lua_pushboolean(this->lua_->getInternalLuaState(), this->state_ & Idle);
     148                if (changes & EngineState::Idle)
     149                {
     150                    lua_pushboolean(this->lua_->getInternalLuaState(), this->state_ & EngineState::Idle);
    151151                    lua_setglobal(this->lua_->getInternalLuaState(), "idle");
    152152                }
    153                 if (changes & Normal)
    154                 {
    155                     lua_pushboolean(this->lua_->getInternalLuaState(), this->state_ & Normal);
     153                if (changes & EngineState::Normal)
     154                {
     155                    lua_pushboolean(this->lua_->getInternalLuaState(), this->state_ & EngineState::Normal);
    156156                    lua_setglobal(this->lua_->getInternalLuaState(), "normal");
    157                     if (this->state_ & Normal)
     157                    if (this->state_ & EngineState::Normal)
    158158                        defEngineSndNormal_->play();
    159159                    else
    160160                        defEngineSndNormal_->stop();
    161161                }
    162                 if (changes & Brake)
    163                 {
    164                     lua_pushboolean(this->lua_->getInternalLuaState(), this->state_ & Brake);
     162                if (changes & EngineState::Brake)
     163                {
     164                    lua_pushboolean(this->lua_->getInternalLuaState(), this->state_ & EngineState::Brake);
    165165                    lua_setglobal(this->lua_->getInternalLuaState(), "brake");
    166166                }
    167                 if (changes & Boost)
    168                 {
    169                     lua_pushboolean(this->lua_->getInternalLuaState(), this->state_ & Boost);
     167                if (changes & EngineState::Boost)
     168                {
     169                    lua_pushboolean(this->lua_->getInternalLuaState(), this->state_ & EngineState::Boost);
    170170                    lua_setglobal(this->lua_->getInternalLuaState(), "boost");
    171                     if (this->state_ & Boost)
     171                    if (this->state_ & EngineState::Boost)
    172172                        defEngineSndBoost_->play();
    173173                    else
     
    178178
    179179                // Update all effect conditions
    180                 for (std::vector<EffectContainer*>::const_iterator it = this->effectContainers_.begin(); it != this->effectContainers_.end(); ++it)
    181                     (*it)->updateCondition();
     180                for (EffectContainer* container : this->effectContainers_)
     181                    container->updateCondition();
    182182            }
    183183        }
     
    198198            this->getShip()->attach(defEngineSndBoost_);
    199199
    200         for (std::vector<EffectContainer*>::const_iterator it = this->effectContainers_.begin(); it != this->effectContainers_.end(); ++it)
    201             for (std::vector<WorldEntity*>::const_iterator it2 = (*it)->getEffectsBegin(); it2 != (*it)->getEffectsEnd(); ++it2)
    202                 this->getShip()->attach(*it2);
    203     }
    204 
    205     void MultiStateEngine::addEffectContainer(EffectContainer* effect)
    206     {
    207         if (effect == NULL)
     200        for (EffectContainer* container : this->effectContainers_)
     201            for (WorldEntity* effect : container->getEffects())
     202                this->getShip()->attach(effect);
     203    }
     204
     205    void MultiStateEngine::addEffectContainer(EffectContainer* container)
     206    {
     207        if (container == nullptr)
    208208            return;
    209         effect->setLuaState(this->lua_, 'f' + multi_cast<std::string>(this->effectContainers_.size()));
    210         this->effectContainers_.push_back(effect);
     209        container->setLuaState(this->lua_, 'f' + multi_cast<std::string>(this->effectContainers_.size()));
     210        this->effectContainers_.push_back(container);
    211211        if (this->getShip())
    212212        {
    213             for (std::vector<WorldEntity*>::const_iterator it = effect->getEffectsBegin(); it != effect->getEffectsBegin(); ++it)
    214                 this->getShip()->attach(*it);
     213            for (WorldEntity* effect : container->getEffects())
     214                this->getShip()->attach(effect);
    215215        }
    216216    }
     
    219219    {
    220220        unsigned int i = 0;
    221         for (std::vector<EffectContainer*>::const_iterator it = this->effectContainers_.begin(); it != this->effectContainers_.end(); ++it)
     221        for (EffectContainer* effectContainer : this->effectContainers_)
    222222        {
    223223            if (i == index)
    224                 return (*it);
    225         }
    226         return NULL;
     224                return effectContainer;
     225            i++;
     226        }
     227        return nullptr;
    227228    }
    228229
  • code/trunk/src/orxonox/items/MultiStateEngine.h

    r9667 r11071  
    4141    {
    4242        public:
    43             enum EngineState
     43            struct EngineState
    4444            {
    45                 Idle    = 1,
    46                 Normal  = 2,
    47                 Brake   = 4,
    48                 Boost   = 8
     45                static constexpr int Idle    = 1;
     46                static constexpr int Normal  = 2;
     47                static constexpr int Brake   = 4;
     48                static constexpr int Boost   = 8;
    4949            };
    5050
     
    5252            virtual ~MultiStateEngine();
    5353
    54             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     54            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
    5555
    56             virtual void run(float dt);
     56            virtual void run(float dt) override;
    5757
    58             virtual void addToSpaceShip(SpaceShip* ship);
     58            virtual void addToSpaceShip(SpaceShip* ship) override;
    5959
    6060            void addEffectContainer(EffectContainer* effect);
  • code/trunk/src/orxonox/items/PartDestructionEvent.cc

    r10262 r11071  
    9898        {
    9999            switch (this->targetParam_) {
    100             case shieldhealth:
     100            case TargetParam::shieldhealth:
    101101                this->parent_->getParent()->setShieldHealth(operate(this->parent_->getParent()->getShieldHealth()));
    102102                break;
    103             case boostpower:
     103            case TargetParam::boostpower:
    104104                this->parent_->getParent()->setInitialBoostPower(operate(this->parent_->getParent()->getInitialBoostPower()));
    105105                break;
    106             case boostpowerrate:
     106            case TargetParam::boostpowerrate:
    107107                this->parent_->getParent()->setBoostPowerRate(operate(this->parent_->getParent()->getBoostPowerRate()));
    108108                break;
    109             case rotationthrust:
     109            case TargetParam::rotationthrust:
    110110                this->parent_->getParent()->setRotationThrust(operate(this->parent_->getParent()->getRotationThrust()));
    111111                break;
     
    120120        {
    121121            switch (this->targetParam_) {
    122             case null:
     122            case TargetParam::null:
    123123                this->parent_->getParent()->getEngineByName(targetName_)->destroy();
    124124                break;
    125             case boostfactor:
     125            case TargetParam::boostfactor:
    126126                this->parent_->getParent()->getEngineByName(targetName_)->setBoostFactor(operate(this->parent_->getParent()->getEngineByName(targetName_)->getBoostFactor()));
    127127                break;
    128             case speedfront:
     128            case TargetParam::speedfront:
    129129                this->parent_->getParent()->getEngineByName(targetName_)->setMaxSpeedFront(operate(this->parent_->getParent()->getEngineByName(targetName_)->getMaxSpeedFront()));
    130130                break;
    131             case accelerationfront:
     131            case TargetParam::accelerationfront:
    132132                this->parent_->getParent()->getEngineByName(targetName_)->setAccelerationFront(operate(this->parent_->getParent()->getEngineByName(targetName_)->getAccelerationFront()));
    133133                break;
     
    142142        {
    143143            switch (this->targetParam_) {
    144             case null:
     144            case TargetParam::null:
    145145                if (!this->parent_->getParent()->getShipPartByName(targetName_))
    146146                    return;
     
    214214            if (param == "NULL")
    215215            {
    216                 this->targetParam_ = null;
     216                this->targetParam_ = TargetParam::null;
    217217                return;
    218218            }
    219219            if (param == "boostfactor")
    220220            {
    221                 this->targetParam_ = boostfactor;
     221                this->targetParam_ = TargetParam::boostfactor;
    222222                return;
    223223            }
    224224            if (param == "speedfront")
    225225            {
    226                 this->targetParam_ = speedfront;
     226                this->targetParam_ = TargetParam::speedfront;
    227227                return;
    228228            }
    229229            if (param == "accelerationfront")
    230230            {
    231                 this->targetParam_ = accelerationfront;
     231                this->targetParam_ = TargetParam::accelerationfront;
    232232                return;
    233233            }
     
    244244            if (param == "shieldhealth")
    245245            {
    246                 this->targetParam_ = shieldhealth;
     246                this->targetParam_ = TargetParam::shieldhealth;
    247247                return;
    248248            }
    249249            if (param == "boostpower")
    250250            {
    251                 this->targetParam_ = boostpower;
     251                this->targetParam_ = TargetParam::boostpower;
    252252                return;
    253253            }
    254254            if (param == "boostpowerrate")
    255255            {
    256                 this->targetParam_ = boostpowerrate;
     256                this->targetParam_ = TargetParam::boostpowerrate;
    257257                return;
    258258            }
    259259            if (param == "rotationthrust")
    260260            {
    261                 this->targetParam_ = rotationthrust;
     261                this->targetParam_ = TargetParam::rotationthrust;
    262262                return;
    263263            }
     
    271271            if (param == "NULL")
    272272            {
    273                 this->targetParam_ = null;
     273                this->targetParam_ = TargetParam::null;
    274274                return;
    275275            }
  • code/trunk/src/orxonox/items/PartDestructionEvent.h

    r10262 r11071  
    8282                    List of all allowed parameters.
    8383                */
    84             enum TargetParam
     84            enum class TargetParam
    8585            {
    8686                shieldhealth,
     
    100100            virtual ~PartDestructionEvent();
    101101
    102             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     102            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
    103103
    104104            void execute();
  • code/trunk/src/orxonox/items/ShipPart.cc

    r11052 r11071  
    4949
    5050    ShipPart::ShipPart(Context* context)
    51         : Item(context), parent_(NULL)
     51        : Item(context), parent_(nullptr)
    5252    {
    5353        RegisterObject(ShipPart);
     
    121121    void ShipPart::addEntity(StaticEntity* entity)
    122122    {
    123         OrxAssert(entity != NULL, "The Entity cannot be NULL.");
     123        OrxAssert(entity != nullptr, "The Entity cannot be nullptr.");
    124124        this->entityList_.push_back(entity);
    125125    }
     
    129129        Get the i-th StaticEntity of the ShipPart.
    130130    @return
    131         Returns a pointer to the i-the StaticEntity. NULL if there is no StaticEntity with that index.
     131        Returns a pointer to the i-the StaticEntity. nullptr if there is no StaticEntity with that index.
    132132    */
    133133    StaticEntity* ShipPart::getEntity(unsigned int index)
    134134    {
    135135        if(this->entityList_.size() >= index)
    136             return NULL;
     136            return nullptr;
    137137        else
    138138            return this->entityList_[index];
     
    142142    @brief
    143143        Check whether the ShipPart has a particular Entity.
    144     @param engine
     144    @param search
    145145        A pointer to the Entity to be checked.
    146146    */
    147     bool ShipPart::hasEntity(StaticEntity* entity) const
    148     {
    149         for(unsigned int i = 0; i < this->entityList_.size(); i++)
    150         {
    151             if(this->entityList_[i] == entity)
     147    bool ShipPart::hasEntity(StaticEntity* search) const
     148    {
     149        for(StaticEntity* entity : this->entityList_)
     150        {
     151            if(entity == search)
    152152                return true;
    153153        }
     
    163163    void ShipPart::addDestructionEvent(PartDestructionEvent* event)
    164164    {
    165         OrxAssert(event != NULL, "The PartDestructionEvent cannot be NULL.");
     165        OrxAssert(event != nullptr, "The PartDestructionEvent cannot be nullptr.");
    166166        event->setParent(this);
    167167        this->eventList_.push_back(event);
     
    172172        Get the i-th PartDestructionEvent of the ShipPart.
    173173    @return
    174         Returns a pointer to the i-the PartDestructionEvent. NULL if there is no PartDestructionEvent with that index.
     174        Returns a pointer to the i-the PartDestructionEvent. nullptr if there is no PartDestructionEvent with that index.
    175175    */
    176176    PartDestructionEvent* ShipPart::getDestructionEvent(unsigned int index)
    177177    {
    178178        if(this->eventList_.size() <= index)
    179             return NULL;
     179            return nullptr;
    180180        else
    181181            return this->eventList_[index];
    182182    }
    183183
    184     void ShipPart::setDamageAbsorption(float value)
    185     {
    186         this->damageAbsorption_ = value;
    187     }
    188 
    189184    void ShipPart::setParent(ModularSpaceShip* ship)
    190185    {
    191186        this->parent_ = ship;
    192     }
    193 
    194     /**
    195     @brief
    196         Sets the health of the ShipPart.
    197     */
    198     void ShipPart::setHealth(float health)
    199     {
    200         this->health_ = health;
    201187    }
    202188
  • code/trunk/src/orxonox/items/ShipPart.h

    r10624 r11071  
    4747            virtual ~ShipPart();
    4848
    49             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     49            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
    5050
    5151            virtual void handleHit(float damage, float healthdamage, float shielddamage, Pawn* originator);
     
    6464            PartDestructionEvent* getDestructionEvent(unsigned int index);
    6565
    66             virtual void setDamageAbsorption(float value);
    67             inline float getDamageAbsorption()
     66            inline void setDamageAbsorption(float value)
     67                { this->damageAbsorption_ = value; }
     68            inline float getDamageAbsorption() const
    6869                { return this->damageAbsorption_; }
    6970
    7071            void setParent(ModularSpaceShip* ship);
    71             inline ModularSpaceShip* getParent()
     72            inline ModularSpaceShip* getParent() const
    7273                { return this->parent_; }
    7374
    7475            inline void setEventExecution(bool var)
    7576                { this->eventExecution_ = var; }
    76             inline bool isEventExecution()
     77            inline bool isEventExecution() const
    7778                { return this->eventExecution_; }
    7879
    79             virtual void setHealth(float health);
     80            inline void setHealth(float health)
     81                { this->health_ = health; }
    8082            inline void addHealth(float health)
    8183                { this->setHealth(this->health_ + health); }
Note: See TracChangeset for help on using the changeset viewer.