Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 21, 2016, 1:59:04 PM (8 years ago)
Author:
muemart
Message:

Fix some clang-tidy warnings.
Also, Serialise.h was doing some C-style casts that ended up being const casts. I moved those const casts as close to the source as possible and changed the loadAndIncrease functions to not do that.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/orxonox/controllers/ActionpointController.cc

    r11071 r11083  
    7474    void ActionpointController::tick(float dt)
    7575    {
    76         if (!this || !this->getControllableEntity() || !this->isActive())
     76        if (!this->getControllableEntity() || !this->isActive())
    7777            return;
    7878
     
    8686        }
    8787
    88         if (!this || !this->getControllableEntity())
    89             return;
    9088        //fly
    9189        if (this->bHasTargetPosition_)
     
    9896        }
    9997       
    100 
    101         if (!this || !this->getControllableEntity())
    102             return;
    10398        //don't fire rocket each tick
    10499        if (timeout_ <= 0)
     
    111106        }
    112107
    113         if (!this || !this->getControllableEntity())
    114             return;
    115108        //sometimes dodge, sometimes attack
    116109        if (this->ticks_ % 80 <= 10)
     
    123116        }
    124117
    125         if (!this || !this->getControllableEntity())
    126             return;
    127118        //fire if you can
    128119        if (this->bShooting_)
     
    140131    void ActionpointController::action()
    141132    {
    142         if (!this || !this->getControllableEntity() || !this->isActive())
     133        if (!this->getControllableEntity() || !this->isActive())
    143134            return;
    144135
     
    152143            this->startAttackingEnemiesThatAreClose();
    153144        }
    154         if (!this || !this->getControllableEntity())
    155             return;
    156145
    157146        //No action -> pop one from stack
     
    161150            if (this->parsedActionpoints_.empty() && this->loopActionpoints_.empty() && this->bDefaultFightAll_)
    162151            {
    163                 if (!this || !this->getControllableEntity())
    164                     return;
    165152                Point p = { Action::FIGHTALL, "", Vector3::ZERO, false };
    166153                this->parsedActionpoints_.push_back (p);
    167154            }
    168             if (!this || !this->getControllableEntity())
    169                 return;
    170155            this->executeActionpoint();
    171             if (!this || !this->getControllableEntity())
    172                 return;
    173156            this->bTakenOver_ = false;
    174157        }
    175         if (!this || !this->getControllableEntity())
    176             return;
    177158
    178159        //Action fightall -> fight till nobody alive
     
    185166                if (newTarget)
    186167                {
    187                     if (!this || !this->getControllableEntity())
    188                         return;
    189168                    this->setAction (Action::FIGHTALL, newTarget);
    190169                }
    191170                else
    192171                {
    193                     if (!this || !this->getControllableEntity())
    194                         return;
    195172                    this->nextActionpoint();
    196                     if (!this || !this->getControllableEntity())
    197                         return;
    198173                    this->executeActionpoint();
    199174   
     
    207182            {
    208183                //----find a target----
    209                 ControllableEntity* newTarget = this->closestTarget(); 
    210                 if (!this || !this->getControllableEntity())
    211                     return; 
     184                ControllableEntity* newTarget = this->closestTarget();
    212185                if (newTarget &&
    213186                        CommonController::distance (this->getControllableEntity(), newTarget) < this->attackRange_)
    214187                {
    215                     if (!this || !this->getControllableEntity())
    216                         return;
    217188                    this->setAction (Action::FIGHT, newTarget);
    218189                }
    219190                else
    220191                {
    221                     if (!this || !this->getControllableEntity())
    222                         return;
    223192                    this->nextActionpoint();
    224                     if (!this || !this->getControllableEntity())
    225                         return;
    226193                    this->executeActionpoint();
    227194                }
     
    235202                {
    236203                    ControllableEntity* newTarget = this->closestTarget();
    237                     if (!this || !this->getControllableEntity())
    238                         return;
    239204                    if (newTarget &&
    240205                        CommonController::distance (this->getControllableEntity(), newTarget) < this->attackRange_)
    241206                    {
    242                         if (!this || !this->getControllableEntity())
    243                             return;
    244207                        this->setAction (Action::FIGHT, newTarget);
    245208                    }
    246209                    else
    247210                    {
    248                         if (!this || !this->getControllableEntity())
    249                             return;
    250211                        this->nextActionpoint();
    251                         if (!this || !this->getControllableEntity())
    252                             return;
    253212                        this->executeActionpoint();
    254213                    }
     
    260219            if (this->squaredDistanceToTarget() <= this->squaredaccuracy_)
    261220            {
    262                 if (!this || !this->getControllableEntity())
    263                     return;
    264221                this->nextActionpoint();   
    265                 if (!this || !this->getControllableEntity())
    266                     return;
    267222                this->executeActionpoint();
    268223            }
     
    272227            if (!this->getProtect())
    273228            {
    274                 if (!this || !this->getControllableEntity())
    275                     return;
    276229                this->nextActionpoint();
    277                 if (!this || !this->getControllableEntity())
    278                     return;
    279230                this->executeActionpoint();
    280231            }
    281             if (!this || !this->getControllableEntity())
    282                 return;
    283232            this->stayNearProtect();
    284233        }
    285234        else if (this->action_ == Action::ATTACK)
    286235        {   
    287             if (!this || !this->getControllableEntity())
    288                 return;
    289236            if (!this->hasTarget())
    290237            {
    291                 if (!this || !this->getControllableEntity())
    292                     return;
    293238                this->nextActionpoint();
    294                 if (!this || !this->getControllableEntity())
    295                     return;
    296239                this->executeActionpoint();
    297240            }
     
    408351    void ActionpointController::setAction (Action action, ControllableEntity* target)
    409352    {
    410         if (!this || !this->getControllableEntity())
     353        if (!this->getControllableEntity())
    411354            return;
    412355        this->action_ = action;
     
    425368    void ActionpointController::setAction (Action action, const Vector3& target)
    426369    {
    427         if (!this || !this->getControllableEntity())
     370        if (!this->getControllableEntity())
    428371            return;
    429372        this->action_ = action;
     
    436379    void ActionpointController::setAction (Action action, const Vector3& target,  const Quaternion& orient )
    437380    {
    438         if (!this || !this->getControllableEntity())
     381        if (!this->getControllableEntity())
    439382            return;
    440383        this->action_ = action;
     
    454397    void ActionpointController::executeActionpoint()
    455398    {
    456         if (!this || !this->getControllableEntity())
     399        if (!this->getControllableEntity())
    457400            return;
    458401
     
    473416        else
    474417        {
    475             if (!this || !this->getControllableEntity())
    476                 return;
    477 
    478418            this->setTarget(nullptr);
    479419            this->setTargetPosition(this->getControllableEntity()->getWorldPosition());
     
    481421            return;
    482422        }
    483         if (!this || !this->getControllableEntity())
    484             return;
    485423        if (!this->bLoop_ && this->parsedActionpoints_.back().inLoop)
    486424        {
    487425            //MOVES all points that are in loop to a loop vector
    488426            this->fillLoop();
    489             if (!this || !this->getControllableEntity())
    490                 return;
    491427            this->bLoop_ = true;
    492428            executeActionpoint();
    493429            return;
    494430        }
    495         if (!this || !this->getControllableEntity())
    496             return;
    497431        this->setAction (p.action);
    498         if (!this || !this->getControllableEntity())
    499             return;
    500432
    501433        switch (this->action_)
     
    508440                for (Pawn* pawn : ObjectList<Pawn>())
    509441                {
    510                     if (!this || !this->getControllableEntity())
    511                         return;
    512442                    if (CommonController::getName(pawn) == targetName)
    513443                    {
     
    520450            {
    521451                this->setTargetPosition( p.position );
    522                 if (!this || !this->getControllableEntity())
    523                     return;
    524452                if (this->squaredDistanceToTarget() <= this->squaredaccuracy_)
    525453                {
    526                     if (!this || !this->getControllableEntity())
    527                         return;
    528454                    this->nextActionpoint();
    529                     if (!this || !this->getControllableEntity())
    530                         return;
    531455                    this->executeActionpoint();
    532456                }
     
    535459            case Action::PROTECT:
    536460            {
    537                 if (!this || !this->getControllableEntity())
    538                     return;
    539461
    540462                std::string protectName = p.name;
     
    582504                    if (CommonController::getName(pawn) == targetName)
    583505                    {
    584                         if (!this || !this->getControllableEntity())
    585                             return;
    586506                        this->setTarget (static_cast<ControllableEntity*>(pawn));
    587507                    }
     
    590510                {
    591511                    this->nextActionpoint();
    592                     if (!this || !this->getControllableEntity())
    593                         return;
    594512                    this->executeActionpoint();
    595513                }
     
    604522    void ActionpointController::stayNearProtect()
    605523    {
    606         if (!this || !this->getControllableEntity())
     524        if (!this->getControllableEntity())
    607525            return;
    608526
     
    626544    void ActionpointController::nextActionpoint()
    627545    {
    628         if (!this || !this->getControllableEntity())
    629             return;
    630546        if (this->bLoop_)
    631547        {
     
    653569    void ActionpointController::moveBackToTop()
    654570    {
    655         if (!this || !this->getControllableEntity())
     571        if (!this->getControllableEntity())
    656572            return;
    657573
     
    684600    void ActionpointController::takeActionpoints (const std::vector<Point>& vector, const std::vector<Point>& loop, bool b)
    685601    {
    686         if (!this || !this->getControllableEntity())
     602        if (!this->getControllableEntity())
    687603            return;
    688604        this->parsedActionpoints_ = vector;
    689         if (!this || !this->getControllableEntity())
    690             return;
    691605        this->loopActionpoints_ = loop;
    692606        this->bLoop_ = b;
     
    701615    Pawn* ActionpointController::closestTarget()
    702616    {
    703         if (!this || !this->getControllableEntity())
     617        if (!this->getControllableEntity())
    704618            return nullptr;
    705619
     
    709623        for (Pawn* pawn : ObjectList<Pawn>())
    710624        {
    711             if (!this || !this->getControllableEntity())
    712                 return nullptr;
    713625            if ( CommonController::sameTeam (this->getControllableEntity(), static_cast<ControllableEntity*>(pawn), gt) )
    714626                continue;
     
    730642    void ActionpointController::startAttackingEnemiesThatAreClose()
    731643    {
    732         if (!this || !this->getControllableEntity())
     644        if (!this->getControllableEntity())
    733645            return;
    734646       
    735647        if (!this->target_ || (this->target_ && CommonController::distance (this->getControllableEntity(), this->target_) > this->attackRange_))
    736648        {
    737             if (!this || !this->getControllableEntity())
    738                 return;
    739649            Pawn* newTarget = this->closestTarget();
    740650            if ( newTarget &&
     
    742652                    <= this->attackRange_ )
    743653            {
    744                 if (!this || !this->getControllableEntity())
    745                     return;
    746654                this->setTarget(newTarget);
    747655                if (this->bLoop_ && !this->bPatrolling_)
Note: See TracChangeset for help on using the changeset viewer.