Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

merged branch cpp11_v3 back to trunk

Location:
code/trunk
Files:
33 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/modules/objects/Attacher.cc

    r9667 r11071  
    4040        RegisterObject(Attacher);
    4141
    42         this->target_ = 0;
     42        this->target_ = nullptr;
    4343    }
    4444
     
    6161        SUPER(Attacher, changedActivity);
    6262
    63         for (std::list<WorldEntity*>::iterator it = this->objects_.begin(); it != this->objects_.end(); ++it)
    64             (*it)->setActive(this->isActive());
     63        for (WorldEntity* object : this->objects_)
     64            object->setActive(this->isActive());
    6565    }
    6666
     
    6969        SUPER(Attacher, changedVisibility);
    7070
    71         for (std::list<WorldEntity*>::iterator it = this->objects_.begin(); it != this->objects_.end(); ++it)
    72             (*it)->setVisible(this->isVisible());
     71        for (WorldEntity* object : this->objects_)
     72            object->setVisible(this->isVisible());
    7373    }
    7474
     
    8383    {
    8484        unsigned int i = 0;
    85         for (std::list<WorldEntity*>::const_iterator it = this->objects_.begin(); it != this->objects_.end(); ++it)
     85        for (WorldEntity* object : this->objects_)
    8686        {
    8787            if (i == index)
    88                 return (*it);
     88                return object;
    8989
    9090            ++i;
    9191        }
    92         return 0;
     92        return nullptr;
    9393    }
    9494
     
    9696    {
    9797        this->targetname_ = target;
    98         this->target_ = 0;
     98        this->target_ = nullptr;
    9999
    100100        if (this->targetname_.empty())
    101101            return;
    102102
    103         for (ObjectList<WorldEntity>::iterator it = ObjectList<WorldEntity>::begin(); it != ObjectList<WorldEntity>::end(); ++it)
     103        for (WorldEntity* worldEntity : ObjectList<WorldEntity>())
    104104        {
    105             if (it->getName() == this->targetname_)
     105            if (worldEntity->getName() == this->targetname_)
    106106            {
    107                 this->target_ = *it;
    108                 this->attachToParent(*it);
     107                this->target_ = worldEntity;
     108                this->attachToParent(worldEntity);
    109109            }
    110110        }
  • code/trunk/src/modules/objects/Attacher.h

    r9667 r11071  
    5151            virtual ~Attacher() {}
    5252
    53             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     53            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
    5454
    55             virtual void processEvent(Event& event);
    56             virtual void changedActivity();
    57             virtual void changedVisibility();
     55            virtual void processEvent(Event& event) override;
     56            virtual void changedActivity() override;
     57            virtual void changedVisibility() override;
    5858
    5959            void addObject(WorldEntity* object);
     
    6464                { return this->targetname_; }
    6565
    66             void loadedNewXMLName(BaseObject* object);
     66            virtual void loadedNewXMLName(BaseObject* object) override;
    6767
    6868        private:
  • code/trunk/src/modules/objects/ForceField.cc

    r9945 r11071  
    6767        this->setMassDiameter(0);   //! We allow point-masses
    6868        this->setLength(2000);
    69         this->mode_ = forceFieldMode::tube;
     69        this->mode_ = ForceFieldMode::tube;
    7070       
    7171        this->registerVariables();
     
    115115    void ForceField::tick(float dt)
    116116    {
    117         if(this->mode_ == forceFieldMode::tube)
    118         {
    119             // Iterate over all objects that could possibly be affected by the ForceField.
    120             for (ObjectList<MobileEntity>::iterator it = ObjectList<MobileEntity>::begin(); it != ObjectList<MobileEntity>::end(); ++it)
     117        if(this->mode_ == ForceFieldMode::tube)
     118        {
     119            // Iterate over all objects that could possibly be affected by the ForceField.
     120            for (MobileEntity* mobileEntity : ObjectList<MobileEntity>())
    121121            {
    122122                // The direction of the orientation of the force field.
     
    125125
    126126                // Vector from the center of the force field to the object its acting on.
    127                 Vector3 distanceVector = it->getWorldPosition() - (this->getWorldPosition() + (this->halfLength_ * direction));
     127                Vector3 distanceVector = mobileEntity->getWorldPosition() - (this->getWorldPosition() + (this->halfLength_ * direction));
    128128
    129129                // The object is outside a ball around the center with radius length/2 of the ForceField.
     
    132132
    133133                // The distance of the object form the orientation vector. (Or rather the smallest distance from the orientation vector)
    134                 float distanceFromDirectionVector = ((it->getWorldPosition() - this->getWorldPosition()).crossProduct(direction)).length();
     134                float distanceFromDirectionVector = ((mobileEntity->getWorldPosition() - this->getWorldPosition()).crossProduct(direction)).length();
    135135
    136136                // If the object in a tube of radius 'radius' around the direction of orientation.
     
    140140                // Apply a force to the object in the direction of the orientation.
    141141                // The force is highest when the object is directly on the direction vector, with a linear decrease, finally reaching zero, when distanceFromDirectionVector = radius.
    142                 it->applyCentralForce((this->radius_ - distanceFromDirectionVector)/this->radius_ * this->velocity_ * direction);
    143             }
    144         }
    145         else if(this->mode_ == forceFieldMode::sphere)
    146         {
    147             // Iterate over all objects that could possibly be affected by the ForceField.
    148             for (ObjectList<MobileEntity>::iterator it = ObjectList<MobileEntity>::begin(); it != ObjectList<MobileEntity>::end(); ++it)
    149             {
    150                 Vector3 distanceVector = it->getWorldPosition() - this->getWorldPosition();
     142                mobileEntity->applyCentralForce((this->radius_ - distanceFromDirectionVector)/this->radius_ * this->velocity_ * direction);
     143            }
     144        }
     145        else if(this->mode_ == ForceFieldMode::sphere)
     146        {
     147            // Iterate over all objects that could possibly be affected by the ForceField.
     148            for (MobileEntity* mobileEntity : ObjectList<MobileEntity>())
     149            {
     150                Vector3 distanceVector = mobileEntity->getWorldPosition() - this->getWorldPosition();
    151151                float distance = distanceVector.length();
    152152                // If the object is within 'radius' distance.
     
    155155                    distanceVector.normalise();
    156156                    // Apply a force proportional to the velocity, with highest force at the origin of the sphere, linear decreasing until reaching a distance of 'radius' from the origin, where the force reaches zero.
    157                     it->applyCentralForce((this->radius_ - distance)/this->radius_ * this->velocity_ * distanceVector);
    158                 }
    159             }
    160         }
    161         else if(this->mode_ == forceFieldMode::invertedSphere)
    162         {
    163             // Iterate over all objects that could possibly be affected by the ForceField.
    164             for (ObjectList<MobileEntity>::iterator it = ObjectList<MobileEntity>::begin(); it != ObjectList<MobileEntity>::end(); ++it)
    165             {
    166                 Vector3 distanceVector = this->getWorldPosition() - it->getWorldPosition();
     157                    mobileEntity->applyCentralForce((this->radius_ - distance)/this->radius_ * this->velocity_ * distanceVector);
     158                }
     159            }
     160        }
     161        else if(this->mode_ == ForceFieldMode::invertedSphere)
     162        {
     163            // Iterate over all objects that could possibly be affected by the ForceField.
     164            for (MobileEntity* mobileEntity : ObjectList<MobileEntity>())
     165            {
     166                Vector3 distanceVector = this->getWorldPosition() - mobileEntity->getWorldPosition();
    167167                float distance = distanceVector.length();
    168168                // If the object is within 'radius' distance and no more than 'length' away from the boundary of the sphere.
     
    172172                    distanceVector.normalise();
    173173                    // Apply a force proportional to the velocity, with highest force at the boundary of the sphere, linear decreasing until reaching a distance of 'radius-length' from the origin, where the force reaches zero.
    174                     it->applyCentralForce((distance-range)/range * this->velocity_ * distanceVector);
    175                 }
    176             }
    177         }
    178         else if(this->mode_ == forceFieldMode::newtonianGravity)
    179         {
    180             // Iterate over all objects that could possibly be affected by the ForceField.
    181             for (ObjectList<MobileEntity>::iterator it = ObjectList<MobileEntity>::begin(); it != ObjectList<MobileEntity>::end(); ++it)
    182             {
    183                 Vector3 distanceVector = it->getWorldPosition() - this->getWorldPosition();
     174                    mobileEntity->applyCentralForce((distance-range)/range * this->velocity_ * distanceVector);
     175                }
     176            }
     177        }
     178        else if(this->mode_ == ForceFieldMode::newtonianGravity)
     179        {
     180            // Iterate over all objects that could possibly be affected by the ForceField.
     181            for (MobileEntity* mobileEntity : ObjectList<MobileEntity>())
     182            {
     183                Vector3 distanceVector = mobileEntity->getWorldPosition() - this->getWorldPosition();
    184184                float distance = distanceVector.length();
    185185                // If the object is within 'radius' distance and especially further away than massRadius_
     
    197197                   
    198198                    // Note: this so called force is actually an acceleration!
    199                     it->applyCentralForce((-1) * (ForceField::attenFactor_ * ForceField::gravConstant_ * this->getMass()) / (distance * distance) * distanceVector);
    200                 }
    201             }
    202         }
    203         else if(this->mode_ == forceFieldMode::homogen)
    204         {
    205             // Iterate over all objects that could possibly be affected by the ForceField.
    206             for (ObjectList<MobileEntity>::iterator it = ObjectList<MobileEntity>::begin(); it != ObjectList<MobileEntity>::end(); ++it)
    207             {
    208                 Vector3 distanceVector = it->getWorldPosition() - this->getWorldPosition();
     199                    mobileEntity->applyCentralForce((-1) * (ForceField::attenFactor_ * ForceField::gravConstant_ * this->getMass()) / (distance * distance) * distanceVector);
     200                }
     201            }
     202        }
     203        else if(this->mode_ == ForceFieldMode::homogen)
     204        {
     205            // Iterate over all objects that could possibly be affected by the ForceField.
     206            for (MobileEntity* mobileEntity : ObjectList<MobileEntity>())
     207            {
     208                Vector3 distanceVector = mobileEntity->getWorldPosition() - this->getWorldPosition();
    209209                float distance = distanceVector.length();
    210210                if (distance < this->radius_ && distance > this->massRadius_)
     
    212212                    // Add a Acceleration in forceDirection_.
    213213                    // Vector3(0,0,0) is the direction, where the force should work.
    214                     it->addAcceleration(forceDirection_ , Vector3(0,0,0));
     214                    mobileEntity->addAcceleration(forceDirection_ , Vector3(0,0,0));
    215215                }
    216216            }
     
    227227    {
    228228        if(mode == ForceField::modeTube_s)
    229             this->mode_ = forceFieldMode::tube;
     229            this->mode_ = ForceFieldMode::tube;
    230230        else if(mode == ForceField::modeSphere_s)
    231             this->mode_ = forceFieldMode::sphere;
     231            this->mode_ = ForceFieldMode::sphere;
    232232        else if(mode == ForceField::modeInvertedSphere_s)
    233             this->mode_ = forceFieldMode::invertedSphere;
     233            this->mode_ = ForceFieldMode::invertedSphere;
    234234        else if(mode == ForceField::modeNewtonianGravity_s)
    235             this->mode_ = forceFieldMode::newtonianGravity;
     235            this->mode_ = ForceFieldMode::newtonianGravity;
    236236
    237237        else if(mode == ForceField::modeHomogen_s)
    238             this->mode_ = forceFieldMode::homogen;
     238            this->mode_ = ForceFieldMode::homogen;
    239239
    240240        else
    241241        {
    242242            orxout(internal_warning) << "Wrong mode '" << mode << "' in ForceField. Setting to 'tube'." << endl;
    243             this->mode_ = forceFieldMode::tube;
     243            this->mode_ = ForceFieldMode::tube;
    244244        }
    245245    }
     
    255255        switch(this->mode_)
    256256        {
    257             case forceFieldMode::tube:
     257            case ForceFieldMode::tube:
    258258                return ForceField::modeTube_s;
    259             case forceFieldMode::sphere:
     259            case ForceFieldMode::sphere:
    260260                return ForceField::modeSphere_s;
    261             case forceFieldMode::invertedSphere:
     261            case ForceFieldMode::invertedSphere:
    262262                return ForceField::modeInvertedSphere_s;
    263             case forceFieldMode::newtonianGravity:
     263            case ForceFieldMode::newtonianGravity:
    264264                return ForceField::modeNewtonianGravity_s;
    265265
    266             case forceFieldMode::homogen:
     266            case ForceFieldMode::homogen:
    267267                return ForceField::modeHomogen_s;
    268268
  • code/trunk/src/modules/objects/ForceField.h

    r10622 r11071  
    5252    @ingroup Objects
    5353    */
    54     namespace forceFieldMode
    55     {
    56         enum Value {
    57             tube, //!< The ForceField has a tube shape.
    58             sphere, //!< The ForceField has a spherical shape.
    59             invertedSphere, //!< The ForceField has a spherical shape but "inverted" behavior.
    60             newtonianGravity, //!< The ForceField imitates Newtonian gravitation for use in stellar bodies.
    61             homogen //!< Local homogenous Force field with changeable direction for the Space Station
    62         };
    63     }
     54    enum class ForceFieldMode {
     55        tube, //!< The ForceField has a tube shape.
     56        sphere, //!< The ForceField has a spherical shape.
     57        invertedSphere, //!< The ForceField has a spherical shape but "inverted" behavior.
     58        newtonianGravity, //!< The ForceField imitates Newtonian gravitation for use in stellar bodies.
     59        homogen //!< Local homogenous Force field with changeable direction for the Space Station
     60    };
    6461
    6562    /**
     
    9289            virtual ~ForceField();
    9390
    94             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Creates a ForceField object through XML.
     91            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; //!< Creates a ForceField object through XML.
    9592            void registerVariables(); //!< Registers the variables that should get synchronised over the network
    96             virtual void tick(float dt); //!< A method that is called every tick.
     93            virtual void tick(float dt) override; //!< A method that is called every tick.
    9794           
    9895
     
    172169            float massRadius_; //!< The radius of the stellar body for the Newtonian ForceField.
    173170            float halfLength_; //!< Half of the length of the ForceField.
    174             int mode_; //!< The mode of the ForceField.
     171            ForceFieldMode mode_; //!< The mode of the ForceField.
    175172           
    176173            //! Gravitational constant for Newtonian ForceFields.
  • code/trunk/src/modules/objects/Planet.h

    r10624 r11071  
    5252            virtual ~Planet();
    5353
    54             virtual void tick(float dt);
     54            virtual void tick(float dt) override;
    5555
    56             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     56            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
    5757
    58             virtual void changedVisibility();
     58            virtual void changedVisibility() override;
    5959
    6060            inline void setMeshSource(const std::string& meshname)
  • code/trunk/src/modules/objects/Script.cc

    r10624 r11071  
    140140
    141141        PlayerTrigger* pTrigger = orxonox_cast<PlayerTrigger*>(trigger);
    142         PlayerInfo* player = NULL;
     142        PlayerInfo* player = nullptr;
    143143
    144144        // If the trigger is a PlayerTrigger.
    145         if(pTrigger != NULL)
     145        if(pTrigger != nullptr)
    146146        {
    147147            if(!pTrigger->isForPlayer())  // The PlayerTrigger is not exclusively for Pawns which means we cannot extract one.
     
    153153            return false;
    154154
    155         if(player == NULL)  //TODO: Will this ever happen? If not, change in NotificationDispatcher as well.
     155        if(player == nullptr)  //TODO: Will this ever happen? If not, change in NotificationDispatcher as well.
    156156        {
    157157            orxout(internal_warning) << "The Script was triggered by an entity other than a Pawn. (" << trigger->getIdentifier()->getName() << ")" << endl;
     
    196196            {
    197197                const std::map<unsigned int, PlayerInfo*> clients = PlayerManager::getInstance().getClients();
    198                 for(std::map<unsigned int, PlayerInfo*>::const_iterator it = clients.begin(); it != clients.end(); it++)
     198                for(const auto& mapEntry : clients)
    199199                {
    200                     callStaticNetworkFunction(&Script::executeHelper, it->first, this->getCode(), this->getMode(), this->getNeedsGraphics());
     200                    callStaticNetworkFunction(&Script::executeHelper, mapEntry.first, this->getCode(), this->getMode(), this->getNeedsGraphics());
    201201                    if(this->times_ != Script::INF) // Decrement the number of remaining executions.
    202202                    {
  • code/trunk/src/modules/objects/Script.h

    r9667 r11071  
    5151    @brief The mode a specific @ref orxonox::Script "Script" is in.
    5252    */
    53     namespace ScriptMode
     53    enum class ScriptMode
    5454    {
    55         enum Value
    56         {
    57             normal, //!< The @ref orxonox::Script "Scripts'" code is executed through the @ref orxonox::CommandExecutor "CommandExecutor".
    58             lua //!< The @ref orxonox::Script "Scripts'" code is executed through lua.
    59         };
    60     }
     55        normal, //!< The @ref orxonox::Script "Scripts'" code is executed through the @ref orxonox::CommandExecutor "CommandExecutor".
     56        lua //!< The @ref orxonox::Script "Scripts'" code is executed through lua.
     57    };
    6158
    6259    /**
     
    9895            virtual ~Script();
    9996
    100             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a Script object through XML.
    101             virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode); //!< Creates a port that can be used to channel events and react to them.
     97            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; //!< Method for creating a Script object through XML.
     98            virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode) override; //!< Creates a port that can be used to channel events and react to them.
    10299
    103100            bool trigger(bool triggered, BaseObject* trigger); //!< Is called when an event comes in trough the event port.
     
    168165                { return this->forAll_; }
    169166
    170             virtual void clientConnected(unsigned int clientId); //!< Callback that is called when a new client has connected.
    171             virtual void clientDisconnected(unsigned int clientid) {}
     167            virtual void clientConnected(unsigned int clientId) override; //!< Callback that is called when a new client has connected.
     168            virtual void clientDisconnected(unsigned int clientid) override {}
    172169
    173170        private:
     
    178175
    179176            std::string code_; //!< The code that is executed by this Script.
    180             ScriptMode::Value mode_; //!< The mode the Script is in. Determines whether the code is executed the normal way or in lua.
     177            ScriptMode mode_; //!< The mode the Script is in. Determines whether the code is executed the normal way or in lua.
    181178            std::string modeStr_; //!< The mode the Script is in, as a string. Is used for networking purposes.
    182179            bool onLoad_; //!< Whether the Scripts code is executed upon loading (creation) of this Script.
     
    193190            @param mode The mode of the Script.
    194191            */
    195             inline void setMode(ScriptMode::Value mode)
     192            inline void setMode(ScriptMode mode)
    196193                { this->mode_ = mode; }
    197194    };
  • code/trunk/src/modules/objects/SpaceBoundaries.cc

    r10624 r11071  
    5959            this->pawnsIn_.clear();
    6060
    61             for( std::vector<BillboardAdministration>::iterator current = this->billboards_.begin(); current != this->billboards_.end(); current++)
     61            for(BillboardAdministration& billboard : this->billboards_)
    6262            {
    63                 if( current->billy != NULL)
    64                 {
    65                     delete current->billy;
     63                if( billboard.billy != nullptr)
     64                {
     65                    delete billboard.billy;
    6666                }
    6767            }
     
    7373    {
    7474        pawnsIn_.clear();
    75         for(ObjectList<Pawn>::iterator current = ObjectList<Pawn>::begin(); current != ObjectList<Pawn>::end(); ++current)
    76         {
    77             Pawn* currentPawn = *current;
     75        for(Pawn* currentPawn : ObjectList<Pawn>())
     76        {
    7877            if( this->reaction_ == 0 )
    7978            {
     
    127126    void SpaceBoundaries::setBillboardOptions(Billboard *billy)
    128127    {
    129         if(billy != NULL)
     128        if(billy != nullptr)
    130129        {
    131130            billy->setMaterial("Grid");
     
    138137    void SpaceBoundaries::removeAllBillboards()
    139138    {
    140         for( std::vector<BillboardAdministration>::iterator current = this->billboards_.begin(); current != this->billboards_.end(); current++ )
    141         {
    142             current->usedYet = false;
    143             current->billy->setVisible(false);
     139        for(BillboardAdministration& billboard : this->billboards_)
     140        {
     141            billboard.usedYet = false;
     142            billboard.billy->setVisible(false);
    144143        }
    145144    }
     
    208207        float distance;
    209208        bool humanItem;
    210         for( std::list<WeakPtr<Pawn> >::iterator current = pawnsIn_.begin(); current != pawnsIn_.end(); current++ )
    211         {
    212             Pawn* currentPawn = *current;
     209        for(Pawn* currentPawn : pawnsIn_)
     210        {
    213211            if( currentPawn && currentPawn->getNode() )
    214212            {
     
    250248    float SpaceBoundaries::computeDistance(WorldEntity *item)
    251249    {
    252         if(item != NULL)
     250        if(item != nullptr)
    253251        {
    254252            Vector3 itemPosition = item->getWorldPosition();
     
    310308    bool SpaceBoundaries::isHumanPlayer(Pawn *item)
    311309    {
    312         if(item != NULL)
     310        if(item != nullptr)
    313311        {
    314312            if(item->getPlayer())
  • code/trunk/src/modules/objects/SpaceBoundaries.h

    r9667 r11071  
    9393            int getReaction();
    9494
    95             void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     95            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
    9696
    97             void tick(float dt);
     97            virtual void tick(float dt) override;
    9898
    9999        private:
     
    101101
    102102            // Variabeln::
    103             std::list<WeakPtr<Pawn> > pawnsIn_; //!< List of the pawns that this instance of SpaceBoundaries has to handle.
     103            std::list<WeakPtr<Pawn>> pawnsIn_; //!< List of the pawns that this instance of SpaceBoundaries has to handle.
    104104
    105105            std::vector<BillboardAdministration> billboards_;
  • code/trunk/src/modules/objects/Turret.cc

    r10622 r11071  
    278278            //slower the closer it is to the destination
    279279            Quaternion drot = Quaternion::nlerp(dt*this->rotationThrust_/20.f, Quaternion::IDENTITY, this->rotation_);
    280             this->rotate(drot, WorldEntity::World);
     280            this->rotate(drot, WorldEntity::TransformSpace::World);
    281281            this->rotation_ = Quaternion::IDENTITY;
    282282        }
  • code/trunk/src/modules/objects/Turret.h

    r11052 r11071  
    6161            virtual ~Turret();
    6262
    63             virtual void rotatePitch(const Vector2& value);
    64             virtual void rotateYaw(const Vector2& value);
    65             virtual void rotateRoll(const Vector2& value);
     63            virtual void rotatePitch(const Vector2& value) override;
     64            virtual void rotateYaw(const Vector2& value) override;
     65            virtual void rotateRoll(const Vector2& value) override;
    6666            virtual float isInRange(const WorldEntity* target);
    6767            virtual void aimAtPosition(const Vector3 &position);
    6868
    69             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    70             virtual void tick(float dt);
     69            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
     70            virtual void tick(float dt) override;
    7171
    7272            /** @brief Sets the maximum distance the turret is allowed to shoot. @param radius The distance*/
  • code/trunk/src/modules/objects/controllers/TeamTargetProxy.cc

    r10262 r11071  
    2828
    2929#include "TeamTargetProxy.h"
     30#include "core/CoreIncludes.h"
    3031#include "worldentities/ControllableEntity.h"
    3132#include "worldentities/pawns/Pawn.h"
  • code/trunk/src/modules/objects/controllers/TurretController.cc

    r10622 r11071  
    3030#include "worldentities/pawns/Pawn.h"
    3131#include "objects/Turret.h"
     32#include "core/object/ObjectList.h"
     33#include "core/CoreIncludes.h"
    3234
    3335 namespace orxonox
     
    8183        {
    8284            this->forgetTarget();
    83             turret->setTarget(0);
     85            turret->setTarget(nullptr);
    8486        }
    8587
     
    99101        float minScore = FLT_MAX;
    100102        float tempScore;
    101         Pawn* minScorePawn = 0;
    102 
    103         for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); ++it)
    104         {
    105             Pawn* entity = orxonox_cast<Pawn*>(*it);
    106             if (!entity || FormationController::sameTeam(turret, entity, this->getGametype()))
     103        Pawn* minScorePawn = nullptr;
     104
     105        for (Pawn* pawn : ObjectList<Pawn>())
     106        {
     107            if (!pawn || FormationController::sameTeam(turret, pawn, this->getGametype()))
    107108                continue;
    108             tempScore = turret->isInRange(entity);
     109            tempScore = turret->isInRange(pawn);
    109110            if(tempScore != -1.f)
    110111            {
     
    112113                {
    113114                    minScore = tempScore;
    114                     minScorePawn = entity;
     115                    minScorePawn = pawn;
    115116                }
    116117            }
  • code/trunk/src/modules/objects/eventsystem/EventDispatcher.cc

    r9667 r11071  
    4545    {
    4646        if (this->isInitialized())
    47             for (std::list<BaseObject*>::iterator it = this->targets_.begin(); it != this->targets_.end(); ++it)
    48                 (*it)->destroy();
     47            for (BaseObject* target : this->targets_)
     48                target->destroy();
    4949    }
    5050
     
    6161    void EventDispatcher::processEvent(Event& event)
    6262    {
    63         for (std::list<BaseObject*>::iterator it = this->targets_.begin(); it != this->targets_.end(); ++it)
    64             (*it)->processEvent(event);
     63        for (BaseObject* target : this->targets_)
     64            target->processEvent(event);
    6565    }
    6666
     
    7373    {
    7474        unsigned int i = 0;
    75         for (std::list<BaseObject*>::const_iterator it = this->targets_.begin(); it != this->targets_.end(); ++it)
     75        for (BaseObject* target : this->targets_)
    7676        {
    7777            if (i == index)
    78                 return (*it);
     78                return target;
    7979            ++i;
    8080        }
    81         return 0;
     81        return nullptr;
    8282    }
    8383}
  • code/trunk/src/modules/objects/eventsystem/EventFilter.cc

    r9667 r11071  
    7070        {
    7171            bool success = false;
    72             for (std::list<EventName*>::const_iterator it = this->names_.begin(); it != this->names_.end(); ++it)
     72            for (EventName* name : this->names_)
    7373            {
    74                 if ((*it)->getName() == event.name_)
     74                if (name->getName() == event.name_)
    7575                {
    7676                    success = true;
     
    9696    {
    9797        unsigned int i = 0;
    98         for (std::list<BaseObject*>::const_iterator it = this->sources_.begin(); it != this->sources_.end(); ++it)
     98        for (BaseObject* source : this->sources_)
    9999        {
    100100            if (i == index)
    101                 return (*it);
     101                return source;
    102102            ++i;
    103103        }
    104         return 0;
     104        return nullptr;
    105105    }
    106106
     
    113113    {
    114114        unsigned int i = 0;
    115         for (std::list<EventName*>::const_iterator it = this->names_.begin(); it != this->names_.end(); ++it)
     115        for (EventName* name : this->names_)
    116116        {
    117117            if (i == index)
    118                 return (*it);
     118                return name;
    119119            ++i;
    120120        }
    121         return 0;
     121        return nullptr;
    122122    }
    123123}
  • code/trunk/src/modules/objects/eventsystem/EventListener.cc

    r9667 r11071  
    7878            return;
    7979
    80         for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it != ObjectList<BaseObject>::end(); ++it)
    81             if (it->getName() == this->eventName_)
    82                 this->addEventSource(*it, "");
     80        for (BaseObject* object : ObjectList<BaseObject>())
     81            if (object->getName() == this->eventName_)
     82                this->addEventSource(object, "");
    8383    }
    8484
  • code/trunk/src/modules/objects/eventsystem/EventTarget.cc

    r9667 r11071  
    7373        this->target_ = name;
    7474
    75         for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it != ObjectList<BaseObject>::end(); ++it)
    76             if (it->getName() == this->target_)
    77                 this->addEventTarget(*it);
     75        for (BaseObject* object : ObjectList<BaseObject>())
     76            if (object->getName() == this->target_)
     77                this->addEventTarget(object);
    7878    }
    7979
  • code/trunk/src/modules/objects/triggers/CheckPoint.cc

    r10624 r11071  
    5656
    5757        this->setRadarObjectColour(ColourValue::Green);
    58         this->setRadarObjectShape(RadarViewable::Dot);
     58        this->setRadarObjectShape(RadarViewable::Shape::Dot);
    5959        this->setRadarVisibility(false);
    6060
  • code/trunk/src/modules/objects/triggers/DistanceMultiTrigger.cc

    r10624 r11071  
    5858
    5959        this->distance_ = 100.0f;
    60         this->setBeaconModeDirect(distanceMultiTriggerBeaconMode::off);
     60        this->setBeaconModeDirect(DistanceMultiTriggerBeaconMode::off);
    6161        this->targetName_ = "";
    6262        this->beaconMask_.exclude(Class(BaseObject));
     
    9797    {
    9898
    99         std::queue<MultiTriggerState*>* queue = NULL;
     99        std::queue<MultiTriggerState*>* queue = nullptr;
    100100
    101101        // Check for objects that were in range but no longer are. Iterate through all objects, that are in range.
    102         for(std::set<WeakPtr<WorldEntity> >::iterator it = this->range_.begin(); it != this->range_.end(); )
     102        for(std::set<WeakPtr<WorldEntity>>::iterator it = this->range_.begin(); it != this->range_.end(); )
    103103        {
    104104            WorldEntity* entity = *it;
    105105
    106106            // If the entity no longer exists.
    107             if(entity == NULL)
     107            if(entity == nullptr)
    108108            {
    109109                this->range_.erase(it++);
     
    118118
    119119                // If no queue has been created, yet.
    120                 if(queue == NULL)
     120                if(queue == nullptr)
    121121                    queue = new std::queue<MultiTriggerState*>();
    122122
     
    136136        ClassTreeMask targetMask = this->getTargetMask();
    137137        // If we are in identify-mode another target mask has to be applies to find the DistanceTriggerBeacons.
    138         if(this->beaconMode_ == distanceMultiTriggerBeaconMode::identify)
     138        if(this->beaconMode_ == DistanceMultiTriggerBeaconMode::identify)
    139139            targetMask = this->beaconMask_;
    140140
     
    145145
    146146            // If the DistanceMultiTrigger is in identify-mode and the DistanceTriggerBeacon attached to the object has the wrong name we ignore it.
    147             if(this->beaconMode_ == distanceMultiTriggerBeaconMode::identify)
     147            if(this->beaconMode_ == DistanceMultiTriggerBeaconMode::identify)
    148148            {
    149149                if(entity->getName() != this->targetName_)
     
    155155           
    156156            // If the DistanceMultiTrigger is in exclude mode and the DistanceTriggerBeacon attached to the object has the right name, we ignore it.
    157             if(this->beaconMode_ == distanceMultiTriggerBeaconMode::exclude)
     157            if(this->beaconMode_ == DistanceMultiTriggerBeaconMode::exclude)
    158158            {
    159159               
    160                 const std::set<WorldEntity*> attached = entity->getAttachedObjects();
     160                const std::set<WorldEntity*> attachedObjects = entity->getAttachedObjects();
    161161                bool found = false;
    162                 for(std::set<WorldEntity*>::const_iterator it = attached.begin(); it != attached.end(); it++)
     162                for(WorldEntity* attachedObject : attachedObjects)
    163163                {
    164                     if((*it)->isA(ClassIdentifier<DistanceTriggerBeacon>::getIdentifier()) && static_cast<DistanceTriggerBeacon*>(*it)->getName() == this->targetName_)
     164                    if(attachedObject->isA(ClassIdentifier<DistanceTriggerBeacon>::getIdentifier()) && static_cast<DistanceTriggerBeacon*>(attachedObject)->getName() == this->targetName_)
    165165                    {
    166166                        found = true;
     
    182182
    183183                // Change the entity to the parent of the DistanceTriggerBeacon (if in identify-mode), which is the entity to which the beacon is attached.
    184                 if(this->beaconMode_ == distanceMultiTriggerBeaconMode::identify)
     184                if(this->beaconMode_ == DistanceMultiTriggerBeaconMode::identify)
    185185                    entity = entity->getParent();
    186186
    187187                // If no queue has been created, yet.
    188                 if(queue == NULL)
     188                if(queue == nullptr)
    189189                    queue = new std::queue<MultiTriggerState*>();
    190190
     
    206206        The mode as an enum.
    207207    */
    208     void DistanceMultiTrigger::setBeaconModeDirect(distanceMultiTriggerBeaconMode::Value mode)
     208    void DistanceMultiTrigger::setBeaconModeDirect(DistanceMultiTriggerBeaconMode mode)
    209209    {
    210210        this->beaconMode_ = mode;
     
    221221        switch(this->getBeaconModeDirect())
    222222        {
    223             case distanceMultiTriggerBeaconMode::off :
     223            case DistanceMultiTriggerBeaconMode::off :
    224224                return DistanceMultiTrigger::beaconModeOff_s;
    225             case distanceMultiTriggerBeaconMode::identify:
     225            case DistanceMultiTriggerBeaconMode::identify:
    226226                return DistanceMultiTrigger::beaconModeIdentify_s;
    227             case distanceMultiTriggerBeaconMode::exclude:
     227            case DistanceMultiTriggerBeaconMode::exclude:
    228228                return DistanceMultiTrigger::beaconModeExlcude_s;
    229229            default :
     
    242242    {
    243243        if(mode == DistanceMultiTrigger::beaconModeOff_s)
    244             this->setBeaconModeDirect(distanceMultiTriggerBeaconMode::off);
     244            this->setBeaconModeDirect(DistanceMultiTriggerBeaconMode::off);
    245245        else if(mode == DistanceMultiTrigger::beaconModeIdentify_s)
    246             this->setBeaconModeDirect(distanceMultiTriggerBeaconMode::identify);
     246            this->setBeaconModeDirect(DistanceMultiTriggerBeaconMode::identify);
    247247        else if(mode == DistanceMultiTrigger::beaconModeExlcude_s)
    248             this->setBeaconModeDirect(distanceMultiTriggerBeaconMode::exclude);
     248            this->setBeaconModeDirect(DistanceMultiTriggerBeaconMode::exclude);
    249249        else
    250250            orxout(internal_error, context::triggers) << "Invalid beacon mode in DistanceMultiTrigger." << endl;
     
    261261    bool DistanceMultiTrigger::addToRange(WorldEntity* entity)
    262262    {
    263         std::pair<std::set<WeakPtr<WorldEntity> >::iterator, bool> pair = this->range_.insert(entity);
     263        std::pair<std::set<WeakPtr<WorldEntity>>::iterator, bool> pair = this->range_.insert(entity);
    264264        return pair.second;
    265265    }
  • code/trunk/src/modules/objects/triggers/DistanceMultiTrigger.h

    r10624 r11071  
    5555    @ingroup MultiTrigger
    5656    */
    57     namespace distanceMultiTriggerBeaconMode
    58     {
    59         enum Value {
    60             off, //!< The DistanceMultiTrigger is not in <em>beacon-mode</em>.
    61             identify, //!< The DistanceTrigger is in <em>identify-mode</em>.
    62             exclude //!< The DistanceTrigger is in <em>exclude-mode</em>.
    63         };
    64     }
     57    enum class DistanceMultiTriggerBeaconMode {
     58        off, //!< The DistanceMultiTrigger is not in <em>beacon-mode</em>.
     59        identify, //!< The DistanceTrigger is in <em>identify-mode</em>.
     60        exclude //!< The DistanceTrigger is in <em>exclude-mode</em>.
     61    };
    6562
    6663    /**
     
    113110                { return this->distance_; }
    114111           
    115             void setBeaconModeDirect(distanceMultiTriggerBeaconMode::Value mode); // Set the beacon mode.
     112            void setBeaconModeDirect(DistanceMultiTriggerBeaconMode mode); // Set the beacon mode.
    116113            /**
    117114            @brief Get the beacon mode.
    118115            @return Returns the mode as an enum.
    119116            */
    120             inline distanceMultiTriggerBeaconMode::Value getBeaconModeDirect(void) const
     117            inline DistanceMultiTriggerBeaconMode getBeaconModeDirect(void) const
    121118                { return this->beaconMode_; }
    122119            void setBeaconMode(const std::string& mode); // Set the beacon mode.
     
    149146            float distance_; //!< The distance at which the DistanceMultiTrigger triggers.
    150147
    151             distanceMultiTriggerBeaconMode::Value beaconMode_; //!< The beacon mode, the DistanceMultiTrigger is in.
     148            DistanceMultiTriggerBeaconMode beaconMode_; //!< The beacon mode, the DistanceMultiTrigger is in.
    152149            std::string targetName_; //!< The target name, used in <em>single-target</em> mode.
    153150            ClassTreeMask beaconMask_; //!< A mask, that only accepts DistanceTriggerBeacons.
    154151
    155             std::set<WeakPtr<WorldEntity> > range_; //!< The set of entities that currently are in range of the DistanceMultiTrigger.
     152            std::set<WeakPtr<WorldEntity>> range_; //!< The set of entities that currently are in range of the DistanceMultiTrigger.
    156153
    157154    };
  • code/trunk/src/modules/objects/triggers/DistanceTrigger.cc

    r10624 r11071  
    106106            this->setForPlayer(true);
    107107
    108         if (targetId == NULL)
     108        if (targetId == nullptr)
    109109        {
    110110            orxout(internal_error, context::triggers) << "\"" << targetStr << "\" is not a valid class name to include in ClassTreeMask (in " << this->getName() << ", class " << this->getIdentifier()->getName() << ')' << endl;
     
    147147    {
    148148        // Check whether there is a cached object, it still exists and whether it is still in range, if so nothing further needs to be done.
    149         if(this->cache_ != NULL)
     149        if(this->cache_ != nullptr)
    150150        {
    151151            if((this->cache_->getWorldPosition() - this->getWorldPosition()).length() < this->distance_)
     
    158158        ClassTreeMask targetMask = this->targetMask_;
    159159        // If we are in identify-mode another target mask has to be applies to find the DistanceTriggerBeacons.
    160         if(this->beaconMode_ == distanceTriggerBeaconMode::identify)
     160        if(this->beaconMode_ == DistanceTriggerBeaconMode::identify)
    161161            targetMask = this->beaconMask_;
    162162
     
    167167
    168168            // If the DistanceTrigger is in identify-mode and the DistanceTriggerBeacon attached to the object has the wrong name we ignore it.
    169             if(this->beaconMode_ == distanceTriggerBeaconMode::identify)
     169            if(this->beaconMode_ == DistanceTriggerBeaconMode::identify)
    170170            {
    171171                if(entity->getName() != this->targetName_)
     
    177177
    178178            // If the DistanceTrigger is in exclude mode and the DistanceTriggerBeacon attached to the object has the right name, we ignore it.
    179             if(this->beaconMode_ == distanceTriggerBeaconMode::exclude)
     179            if(this->beaconMode_ == DistanceTriggerBeaconMode::exclude)
    180180            {
    181181
    182                 const std::set<WorldEntity*> attached = entity->getAttachedObjects();
     182                const std::set<WorldEntity*> attachedObjects = entity->getAttachedObjects();
    183183                bool found = false;
    184                 for(std::set<WorldEntity*>::const_iterator it = attached.begin(); it != attached.end(); it++)
     184                for(WorldEntity* attachedObject : attachedObjects)
    185185                {
    186                     if((*it)->isA(ClassIdentifier<DistanceTriggerBeacon>::getIdentifier()) && static_cast<DistanceTriggerBeacon*>(*it)->getName() == this->targetName_)
     186                    if(attachedObject->isA(ClassIdentifier<DistanceTriggerBeacon>::getIdentifier()) && static_cast<DistanceTriggerBeacon*>(attachedObject)->getName() == this->targetName_)
    187187                    {
    188188                        found = true;
     
    202202                {
    203203                    // Change the entity to the parent of the DistanceTriggerBeacon (if in identify-mode), which is the entity to which the beacon is attached.
    204                     if(this->beaconMode_ == distanceTriggerBeaconMode::identify)
     204                    if(this->beaconMode_ == DistanceTriggerBeaconMode::identify)
    205205                        entity = entity->getParent();
    206206
    207207                    Pawn* pawn = orxonox_cast<Pawn*>(entity);
    208                     if(pawn != NULL)
     208                    if(pawn != nullptr)
    209209                        this->setTriggeringPawn(pawn);
    210210                    else
    211                         orxout(internal_warning, context::triggers) << "Pawn was NULL." << endl;
     211                        orxout(internal_warning, context::triggers) << "Pawn was nullptr." << endl;
    212212                }
    213213               
     
    228228        The mode as an enum.
    229229    */
    230     void DistanceTrigger::setBeaconModeDirect(distanceTriggerBeaconMode::Value mode)
     230    void DistanceTrigger::setBeaconModeDirect(DistanceTriggerBeaconMode mode)
    231231    {
    232232        this->beaconMode_ = mode;
     
    243243        switch(this->getBeaconModeDirect())
    244244        {
    245             case distanceTriggerBeaconMode::off :
     245            case DistanceTriggerBeaconMode::off :
    246246                return DistanceTrigger::beaconModeOff_s;
    247             case distanceTriggerBeaconMode::identify:
     247            case DistanceTriggerBeaconMode::identify:
    248248                return DistanceTrigger::beaconModeIdentify_s;
    249             case distanceTriggerBeaconMode::exclude:
     249            case DistanceTriggerBeaconMode::exclude:
    250250                return DistanceTrigger::beaconModeExlcude_s;
    251251            default :
     
    264264    {
    265265        if(mode == DistanceTrigger::beaconModeOff_s)
    266             this->setBeaconModeDirect(distanceTriggerBeaconMode::off);
     266            this->setBeaconModeDirect(DistanceTriggerBeaconMode::off);
    267267        else if(mode == DistanceTrigger::beaconModeIdentify_s)
    268             this->setBeaconModeDirect(distanceTriggerBeaconMode::identify);
     268            this->setBeaconModeDirect(DistanceTriggerBeaconMode::identify);
    269269        else if(mode == DistanceTrigger::beaconModeExlcude_s)
    270             this->setBeaconModeDirect(distanceTriggerBeaconMode::exclude);
     270            this->setBeaconModeDirect(DistanceTriggerBeaconMode::exclude);
    271271        else
    272272            orxout(internal_error, context::triggers) << "Invalid beacon mode in DistanceTrigger." << endl;
     
    282282        Returns true if it is triggered ,false if not.
    283283    */
    284     bool DistanceTrigger::isTriggered(TriggerMode::Value mode)
     284    bool DistanceTrigger::isTriggered(TriggerMode mode)
    285285    {
    286286        if (Trigger::isTriggered(mode))
  • code/trunk/src/modules/objects/triggers/DistanceTrigger.h

    r9667 r11071  
    5555  @ingroup NormalTrigger
    5656  */
    57   namespace distanceTriggerBeaconMode
    58   {
    59       enum Value {
    60           off,
    61           identify,
    62           exclude
    63       };
    64   }
     57  enum class DistanceTriggerBeaconMode {
     58      off,
     59      identify,
     60      exclude
     61  };
    6562
    6663    /**
     
    118115                { return this->distance_; }
    119116
    120             void setBeaconModeDirect(distanceTriggerBeaconMode::Value mode); // Set the beacon mode.
     117            void setBeaconModeDirect(DistanceTriggerBeaconMode mode); // Set the beacon mode.
    121118            /**
    122119            @brief Get the beacon mode.
    123120            @return Returns the mode as an enum.
    124121            */
    125             inline distanceTriggerBeaconMode::Value getBeaconModeDirect(void) const
     122            inline DistanceTriggerBeaconMode getBeaconModeDirect(void) const
    126123            { return this->beaconMode_; }
    127124            void setBeaconMode(const std::string& mode); // Set the beacon mode.
     
    144141
    145142        protected:
    146             virtual bool isTriggered(TriggerMode::Value mode); // Check whether the DistanceTrigger is triggered.
     143            virtual bool isTriggered(TriggerMode mode) override; // Check whether the DistanceTrigger is triggered.
    147144            /**
    148145            @brief Notifies interested parties about a change of the DistanceTrigger's target mask.
     
    160157            float distance_; //!< The range of the DistanceTrigger.
    161158           
    162             distanceTriggerBeaconMode::Value beaconMode_; //!< The beacon mode.
     159            DistanceTriggerBeaconMode beaconMode_; //!< The beacon mode.
    163160            std::string targetName_; //!< The name a DistanceTriggerBeacon needs to have to make the DistanceTrigger react to it if in beacon-mode.
    164161            ClassTreeMask beaconMask_; //!< A mask, that only accepts DistanceTriggerBeacons.
  • code/trunk/src/modules/objects/triggers/EventMultiTrigger.cc

    r9667 r11071  
    9696    {
    9797        // If the originator is a MultiTriggerContainer, the event originates from a MultiTrigger and thus the event only triggers the EventMultiTrigger for the originator that caused the MultiTrigger to trigger.
    98         if(originator != NULL && originator->isA(ClassIdentifier<MultiTriggerContainer>::getIdentifier()))
     98        if(originator != nullptr && originator->isA(ClassIdentifier<MultiTriggerContainer>::getIdentifier()))
    9999        {
    100100            MultiTriggerContainer* container = static_cast<MultiTriggerContainer*>(originator);
  • code/trunk/src/modules/objects/triggers/EventTrigger.cc

    r9667 r11071  
    7979        It should be triggered if it is triggered according just to its sub-triggers and if the last event that came in was an event that changed from not triggered to triggered.
    8080    */
    81     bool EventTrigger::isTriggered(TriggerMode::Value mode)
     81    bool EventTrigger::isTriggered(TriggerMode mode)
    8282    {
    8383        if (Trigger::isTriggered(mode))
  • code/trunk/src/modules/objects/triggers/EventTrigger.h

    r9667 r11071  
    8484
    8585        protected:
    86             virtual bool isTriggered(TriggerMode::Value mode); // Check whether the EventTrigger should be triggered.
     86            virtual bool isTriggered(TriggerMode mode) override; // Check whether the EventTrigger should be triggered.
    8787
    8888        private:
  • code/trunk/src/modules/objects/triggers/MultiTrigger.cc

    r11020 r11071  
    124124        // Let the MultiTrigger return the states that trigger and process the new states if there are any.
    125125        std::queue<MultiTriggerState*>* queue  = this->letTrigger();
    126         if(queue != NULL)
     126        if(queue != nullptr)
    127127        {
    128128            while(queue->size() > 0)
    129129            {
    130130                MultiTriggerState* state = queue->front();
    131                 // If the state is NULL. (This really shouldn't happen)
    132                 if(state == NULL)
     131                // If the state is nullptr. (This really shouldn't happen)
     132                if(state == nullptr)
    133133                {
    134                     orxout(internal_error, context::triggers) << "In MultiTrigger '" << this->getName() << "' (&" << this << "), Error: State of new states queue was NULL. State ignored." << endl;
     134                    orxout(internal_error, context::triggers) << "In MultiTrigger '" << this->getName() << "' (&" << this << "), Error: State of new states queue was nullptr. State ignored." << endl;
    135135                    queue->pop();
    136136                    continue;
     
    227227                            {
    228228                                // If the MultiTrigger is set to broadcast and has no originator a boradcast is fired.
    229                                 if(this->getBroadcast() && state->originator == NULL)
     229                                if(this->getBroadcast() && state->originator == nullptr)
    230230                                    this->broadcast(bActive);
    231231                                // Else a normal event is fired.
     
    240240                        {
    241241                            // Print some debug output if the state has changed.
    242                             if(state->originator != NULL)
     242                            if(state->originator != nullptr)
    243243                                orxout(verbose, context::triggers) << "MultiTrigger '" << this->getName() << "' (&" << this << ") changed state. originator: " << state->originator->getIdentifier()->getName() << " (&" << state->originator << "), active: " << bActive << ", triggered: " << state->bTriggered << "." << endl;
    244244                            else
    245                                 orxout(verbose, context::triggers) << "MultiTrigger '" << this->getName() << "' (&" << this << ") changed state. originator: NULL, active: " << bActive << ", triggered: " << state->bTriggered << "." << endl;
     245                                orxout(verbose, context::triggers) << "MultiTrigger '" << this->getName() << "' (&" << this << ") changed state. originator: nullptr, active: " << bActive << ", triggered: " << state->bTriggered << "." << endl;
    246246
    247247                            // If the MultiTrigger has a parent trigger, that is itself a MultiTrigger, it needs to call a method to notify him, that its activity has changed.
    248                             if(this->parent_ != NULL && this->parent_->isMultiTrigger())
     248                            if(this->parent_ != nullptr && this->parent_->isMultiTrigger())
    249249                                static_cast<MultiTrigger*>(this->parent_)->childActivityChanged(state->originator);
    250250                        }
     
    265265                else
    266266                {
    267                     this->stateQueue_.push_back(std::pair<float, MultiTriggerState*>(timeRemaining-dt, state));
     267                    this->stateQueue_.emplace_back(timeRemaining-dt, state);
    268268                    this->stateQueue_.pop_front();
    269269                }
     
    299299
    300300        // If the target is not a valid class name display an error.
    301         if (target == NULL)
     301        if (target == nullptr)
    302302        {
    303303            orxout(internal_error, context::triggers) << "'" << targetStr << "' is not a valid class name to include in ClassTreeMask (in " << this->getName() << ", class " << this->getIdentifier()->getName() << ")" << endl;
     
    327327
    328328        // If the target is not a valid class name display an error.
    329         if (target == NULL)
     329        if (target == nullptr)
    330330        {
    331331            orxout(internal_error, context::triggers) << "'" << targetStr << "' is not a valid class name to include in ClassTreeMask (in " << this->getName() << ", class " << this->getIdentifier()->getName() << ")" << endl;
     
    346346    std::queue<MultiTriggerState*>* MultiTrigger::letTrigger(void)
    347347    {
    348         return NULL;
     348        return nullptr;
    349349    }
    350350
     
    443443    void MultiTrigger::fire(bool status, BaseObject* originator)
    444444    {
    445         // If the originator is NULL, a normal event without MultiTriggerContainer is sent.
    446         if(originator == NULL)
     445        // If the originator is nullptr, a normal event without MultiTriggerContainer is sent.
     446        if(originator == nullptr)
    447447        {
    448448            this->fireEvent(status);
     
    479479    bool MultiTrigger::addState(MultiTriggerState* state)
    480480    {
    481         assert(state); // The state really shouldn't be NULL.
     481        assert(state); // The state really shouldn't be nullptr.
    482482
    483483        // If the originator is no target of this MultiTrigger.
     
    489489
    490490        // Add it ot the state queue with the delay specified for the MultiTrigger.
    491         this->stateQueue_.push_back(std::pair<float, MultiTriggerState*>(this->getDelay(), state));
     491        this->stateQueue_.emplace_back(this->getDelay(), state);
    492492
    493493        return true;
     
    504504    bool MultiTrigger::checkAnd(BaseObject* triggerer)
    505505    {
    506         for(std::set<TriggerBase*>::iterator it = this->children_.begin(); it != this->children_.end(); ++it)
    507         {
    508             TriggerBase* trigger = *it;
     506        for(TriggerBase* trigger : this->children_)
     507        {
    509508            if(trigger->isMultiTrigger())
    510509            {
     
    531530    bool MultiTrigger::checkOr(BaseObject* triggerer)
    532531    {
    533         for(std::set<TriggerBase*>::iterator it = this->children_.begin(); it != this->children_.end(); ++it)
    534         {
    535             TriggerBase* trigger = *it;
     532        for(TriggerBase* trigger : this->children_)
     533        {
    536534            if(trigger->isMultiTrigger())
    537535            {
     
    559557    {
    560558        bool triggered = false;
    561         for(std::set<TriggerBase*>::iterator it = this->children_.begin(); it != this->children_.end(); ++it)
    562         {
    563             TriggerBase* trigger = *it;
     559        for(TriggerBase* trigger : this->children_)
     560        {
    564561            if(triggered)
    565562            {
  • code/trunk/src/modules/objects/triggers/MultiTrigger.h

    r9667 r11071  
    7676        - @b simultaneousTriggerers The number of simultaneous triggerers limits the number of objects that are allowed to trigger the MultiTrigger at the same time. Or more precisely, the number of distinct objects the MultiTrigger has <em>triggered</em> states for, at each point in time. The default is <code>-1</code>, which denotes infinity.
    7777        - @b mode The mode describes how the MultiTrigger acts in relation to all the triggers, that are appended to it. There are 3 modes: <em>and</em>, meaning that the MultiTrigger can only be triggered if all the appended triggers are active. <em>or</em>, meaning that the MultiTrigger can only triggered if at least one of the appended triggers is active. And <em>xor</em>, meaning that the MultiTrigger can only be triggered if one and only one appended trigger is active. Note, that I wrote <em>can only be active</em>, that implies, that there is an additional condition to the <em>activity</em> of the MultiTrigger and that is the fulfillment of the triggering condition (the MultiTrigger itself doesn't have one, but all derived classes should). Also bear in mind, that the <em>activity</em> of a MultiTrigger is still coupled to the object that triggered it. The default is <em>and</em>.
    78         - @b broadcast Broadcast is a boolean, if true the MutliTrigger is in <em>broadcast-mode</em>, meaning, that all trigger events that are caused by no originator (originator is NULL) are broadcast as having come from every possible originator, or more precisely as having come from all objects that are specified targets of this MultiTrigger. The default is false.
     78        - @b broadcast Broadcast is a boolean, if true the MutliTrigger is in <em>broadcast-mode</em>, meaning, that all trigger events that are caused by no originator (originator is nullptr) are broadcast as having come from every possible originator, or more precisely as having come from all objects that are specified targets of this MultiTrigger. The default is false.
    7979        - @b target The target describes the kind of objects that are allowed to trigger this MultiTrigger. The default is @ref orxonox::Pawn "Pawn".
    8080        - Also there is the possibility of appending triggers (as long as they inherit from TriggerBase) to the MultiTrigger just by adding them as children in the XML description of your MultiTrigger.
     
    110110            */
    111111            inline bool isActive(void) const
    112                 { return this->isActive(NULL); }
    113             bool isActive(BaseObject* triggerer = NULL) const; //!< Check whether the MultiTrigger is active for a given object.
     112                { return this->isActive(nullptr); }
     113            bool isActive(BaseObject* triggerer = nullptr) const; //!< Check whether the MultiTrigger is active for a given object.
    114114
    115115            /**
     
    145145            */
    146146            inline bool isTarget(BaseObject* target)
    147                 { if(target == NULL) return true; else return targetMask_.isIncluded(target->getIdentifier()); }
     147                { if(target == nullptr) return true; else return targetMask_.isIncluded(target->getIdentifier()); }
    148148               
    149149            void addTarget(const std::string& targets); //!< Add some target to the MultiTrigger.
     
    152152            virtual std::queue<MultiTriggerState*>* letTrigger(void); //!< This method is called by the MultiTrigger to get information about new trigger events that need to be looked at.
    153153
    154             void changeTriggered(BaseObject* originator = NULL); //!< This method can be called by any class inheriting from MultiTrigger to change it's triggered status for a specified originator.
    155 
    156             bool isModeTriggered(BaseObject* triggerer = NULL); //!< Checks whether the MultiTrigger is triggered concerning it's children.
    157             bool isTriggered(BaseObject* triggerer = NULL); //!< Get whether the MultiTrigger is triggered for a given object.
    158 
    159             virtual void fire(bool status, BaseObject* originator = NULL);  //!< Helper method. Creates an Event for the given status and originator and fires it.
     154            void changeTriggered(BaseObject* originator = nullptr); //!< This method can be called by any class inheriting from MultiTrigger to change it's triggered status for a specified originator.
     155
     156            bool isModeTriggered(BaseObject* triggerer = nullptr); //!< Checks whether the MultiTrigger is triggered concerning it's children.
     157            bool isTriggered(BaseObject* triggerer = nullptr); //!< Get whether the MultiTrigger is triggered for a given object.
     158
     159            virtual void fire(bool status, BaseObject* originator = nullptr);  //!< Helper method. Creates an Event for the given status and originator and fires it.
    160160            void broadcast(bool status); //!< Helper method. Broadcasts an Event for every object that is a target.
    161161
     
    192192            std::set<BaseObject*> triggered_; //!< The set of all objects the MultiTrigger is triggered for.
    193193
    194             std::deque< std::pair<float, MultiTriggerState*> > stateQueue_; //!< The queue of states waiting to become active.
     194            std::deque<std::pair<float, MultiTriggerState*>> stateQueue_; //!< The queue of states waiting to become active.
    195195
    196196            ClassTreeMask targetMask_; //!< The target mask, masking all objects that can trigger this MultiTrigger.
  • code/trunk/src/modules/objects/triggers/MultiTriggerContainer.cc

    r9667 r11071  
    5050        The creator.
    5151    */
    52     MultiTriggerContainer::MultiTriggerContainer(Context* context) : BaseObject(context), originator_(NULL), data_(NULL)
     52    MultiTriggerContainer::MultiTriggerContainer(Context* context) : BaseObject(context), originator_(nullptr), data_(nullptr)
    5353    {
    5454        RegisterObject(MultiTriggerContainer);
     
    7070
    7171        Pawn* pawn = orxonox_cast<Pawn*>(data);
    72         if(pawn != NULL)
     72        if(pawn != nullptr)
    7373        {
    7474            this->setForPlayer(true);
  • code/trunk/src/modules/objects/triggers/Trigger.cc

    r10624 r11071  
    3737#include "core/CoreIncludes.h"
    3838#include "core/GameMode.h"
    39 #include "core/XMLPort.h"
    4039#include "core/command/ConsoleCommandIncludes.h"
    4140
     
    8685    {
    8786
    88     }
    89 
    90     /**
    91     @brief
    92         Method for creating a Trigger object through XML.
    93     */
    94     void Trigger::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    95     {
    96         SUPER(Trigger, XMLPort, xmlelement, mode);
    9787    }
    9888
     
    203193        Returns true if the Trigger should be triggered and false if not.
    204194    */
    205     bool Trigger::isTriggered(TriggerMode::Value mode)
     195    bool Trigger::isTriggered(TriggerMode mode)
    206196    {
    207197        // If the trigger has sub-triggers.
     
    234224    {
    235225        // Iterate over all sub-triggers.
    236         for (std::set<TriggerBase*>::iterator it = this->children_.begin(); it != this->children_.end(); ++it)
    237         {
    238             if (!(*it)->isActive())
     226        for (TriggerBase* child : this->children_)
     227        {
     228            if (!child->isActive())
    239229                return false;
    240230        }
     
    252242    {
    253243        // Iterate over all sub-triggers.
    254         for (std::set<TriggerBase*>::iterator it = this->children_.begin(); it != this->children_.end(); ++it)
    255         {
    256             if ((*it)->isActive())
     244        for (TriggerBase* child : this->children_)
     245        {
     246            if (child->isActive())
    257247                return true;
    258248        }
     
    270260    {
    271261        bool test = false;
    272         for (std::set<TriggerBase*>::iterator it = this->children_.begin(); it != this->children_.end(); ++it)
    273         {
    274             if (test && (*it)->isActive())
     262        for (TriggerBase* child : this->children_)
     263        {
     264            if (test && child->isActive())
    275265                return false;
    276             if ((*it)->isActive())
     266            if (child->isActive())
    277267                test = true;
    278268        }
     
    346336    {
    347337        // Iterate over all Triggers.
    348         for (ObjectList<Trigger>::iterator it = ObjectList<Trigger>::begin(); it != ObjectList<Trigger>::end(); ++it)
    349             it->setVisible(bVisible);
     338        for (Trigger* trigger : ObjectList<Trigger>())
     339            trigger->setVisible(bVisible);
    350340    }
    351341
  • code/trunk/src/modules/objects/triggers/Trigger.h

    r9667 r11071  
    8383            virtual ~Trigger();
    8484
    85             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); // Method for creating a Trigger object through XML.
    8685            virtual void tick(float dt);
    8786
     
    105104            inline bool isTriggered()
    106105                { return this->isTriggered(this->mode_); }
    107             virtual bool isTriggered(TriggerMode::Value mode); // Check whether the Trigger should be triggered, given only its sub-triggers, given a specific mode.
     106            virtual bool isTriggered(TriggerMode mode); // Check whether the Trigger should be triggered, given only its sub-triggers, given a specific mode.
    108107            virtual void triggered(bool bIsTriggered); // Fires an event with the input triggered state.
    109108
     
    127126            BillboardSet debugBillboard_; //!< A set of debug billboards to visualize the state of the trigger.
    128127
    129             std::queue<std::pair<float, char> > stateChanges_; //!< A queue of state changes (in the same format as latestState_) paired with the time they will take effect since the last state change took effect.
     128            std::queue<std::pair<float, char>> stateChanges_; //!< A queue of state changes (in the same format as latestState_) paired with the time they will take effect since the last state change took effect.
    130129    };
    131130
  • code/trunk/src/modules/objects/triggers/TriggerBase.cc

    r9667 r11071  
    6767        this->mode_ = TriggerMode::EventTriggerAND;
    6868
    69         this->parent_ = NULL;
     69        this->parent_ = nullptr;
    7070
    7171        this->bMultiTrigger_ = false;
     
    100100
    101101        XMLPortObject(TriggerBase, TriggerBase, "", addTrigger, getTrigger, xmlelement, mode);
    102     }
    103 
    104     /**
    105     @brief
    106         A method that is executed each tick.
    107     @param dt
    108         The duration of the last tick.
    109     */
    110     void TriggerBase::tick(float dt)
    111     {
    112         SUPER(TriggerBase, tick, dt);
    113102    }
    114103
     
    170159        The index.
    171160    @return
    172         Returns a pointer ot the trigger. NULL if no such trigger exists.
     161        Returns a pointer ot the trigger. nullptr if no such trigger exists.
    173162    */
    174163    const TriggerBase* TriggerBase::getTrigger(unsigned int index) const
     
    176165        // If the index is greater than the number of children.
    177166        if (this->children_.size() <= index)
    178             return NULL;
     167            return nullptr;
    179168
    180169        std::set<TriggerBase*>::const_iterator it;
  • code/trunk/src/modules/objects/triggers/TriggerBase.h

    r9667 r11071  
    5252    @ingroup Triggers
    5353    */
    54     namespace TriggerMode
     54    enum class TriggerMode
    5555    {
    56         enum Value
    57         {
    58             EventTriggerAND, //!< The <em>and</em> mode. The trigger can only trigger if all the children are active.
    59             EventTriggerOR, //!< The <em>or</em> mode. The trigger can only trigger if at least one child is active.
    60             EventTriggerXOR, //!< The <em>xor</em> mode. The trigger can only trigger if exactly one child is active.
    61         };
    62     }
     56        EventTriggerAND, //!< The <em>and</em> mode. The trigger can only trigger if all the children are active.
     57        EventTriggerOR, //!< The <em>or</em> mode. The trigger can only trigger if at least one child is active.
     58        EventTriggerXOR, //!< The <em>xor</em> mode. The trigger can only trigger if exactly one child is active.
     59    };
    6360
    6461    /**
     
    7875
    7976            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);  //!< Method for creating a TriggerBase object through XML.
    80             virtual void tick(float dt); //!< A method that is executed each tick.
    8177
    8278            /**
     
    158154            @param mode The mode of the trigger.
    159155            */
    160             inline void setMode(TriggerMode::Value mode) //!< Get the mode of the trigger.
     156            inline void setMode(TriggerMode mode) //!< Get the mode of the trigger.
    161157                { this->mode_ = mode; }
    162158            const std::string& getModeString(void) const;
     
    165161            @return Returns and Enum for the mode of the trigger.
    166162            */
    167             inline TriggerMode::Value getMode(void) const
     163            inline TriggerMode getMode(void) const
    168164                { return mode_; }
    169165
     
    211207
    212208            bool bInvertMode_; //!< Bool for the invert-mode, if true the trigger is inverted.
    213             TriggerMode::Value mode_; //!< The mode of the trigger.
     209            TriggerMode mode_; //!< The mode of the trigger.
    214210
    215211            TriggerBase* parent_; //!< The parent of this trigger.
Note: See TracChangeset for help on using the changeset viewer.