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:
16 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • 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.