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

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/modules/tetris/Tetris.cc

    r10624 r11071  
    6666        RegisterObject(Tetris);
    6767
    68         this->activeBrick_ = 0;
     68        this->activeBrick_ = nullptr;
    6969
    7070        // Pre-set the timer, but don't start it yet.
     
    7272        this->starttimer_.stopTimer();
    7373
    74         this->player_ = NULL;
     74        this->player_ = nullptr;
    7575        this->setHUDTemplate("TetrisHUD");
    76         this->futureBrick_ = 0;
     76        this->futureBrick_ = nullptr;
    7777    }
    7878
     
    9696        {
    9797            this->activeBrick_->destroy();
    98             this->activeBrick_ = 0;
     98            this->activeBrick_ = nullptr;
    9999        }
    100100        if (this->futureBrick_)
    101101        {
    102102            this->futureBrick_->destroy();
    103             this->futureBrick_ = 0;
    104         }
    105 
    106         for (std::list<StrongPtr<TetrisStone> >::iterator it = this->stones_.begin(); it != this->stones_.end(); ++it)
    107             (*it)->destroy();
     103            this->futureBrick_ = nullptr;
     104        }
     105
     106        for (TetrisStone* stone : this->stones_)
     107            stone->destroy();
    108108        this->stones_.clear();
    109109    }
     
    113113        SUPER(Tetris, tick, dt);
    114114
    115         if((this->activeBrick_ != NULL)&&(!this->hasEnded()))
     115        if((this->activeBrick_ != nullptr)&&(!this->hasEnded()))
    116116        {
    117117            if(!this->isValidBrickPosition(this->activeBrick_))
     
    136136            return false;
    137137
    138         for(std::list<StrongPtr<TetrisStone> >::const_iterator it = this->stones_.begin(); it != this->stones_.end(); ++it)
    139         {
    140             const Vector3& currentStonePosition = (*it)->getPosition(); //!< Saves the position of the currentStone
     138        for(TetrisStone* someStone : this->stones_)
     139        {
     140            const Vector3& currentStonePosition = someStone->getPosition(); //!< Saves the position of the currentStone
    141141
    142142            if((position.x == currentStonePosition.x) && abs(position.y-currentStonePosition.y) < this->center_->getStoneSize())
     
    192192
    193193        // check for collisions with all stones
    194         for(std::list<StrongPtr<TetrisStone> >::const_iterator it = this->stones_.begin(); it != this->stones_.end(); ++it)
     194        for(TetrisStone* someStone : this->stones_)
    195195        {
    196196            //Vector3 currentStonePosition = rotateVector((*it)->getPosition(), this->activeBrick_->getRotationCount());
    197             const Vector3& currentStonePosition = (*it)->getPosition(); //!< Saves the position of the currentStone
     197            const Vector3& currentStonePosition = someStone->getPosition(); //!< Saves the position of the currentStone
    198198
    199199            //filter out cases where the falling stone is already below a steady stone
     
    290290    void Tetris::start()
    291291    {
    292         if (this->center_ != NULL) // There needs to be a TetrisCenterpoint, i.e. the area the game takes place.
     292        if (this->center_ != nullptr) // There needs to be a TetrisCenterpoint, i.e. the area the game takes place.
    293293        {
    294294            // Create the first brick.
     
    323323    {
    324324        this->activeBrick_->setVelocity(Vector3::ZERO);
    325         if(this->activeBrick_ != NULL)
     325        if(this->activeBrick_ != nullptr)
    326326        {
    327327            this->player_->stopControl();
     
    341341    {
    342342        // Spawn a human player.
    343         for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
    344             if (it->first->isHumanPlayer() && (it->first->isReadyToSpawn() || this->bForceSpawn_))
    345                 this->spawnPlayer(it->first);
     343        for (const auto& mapEntry : this->players_)
     344            if (mapEntry.first->isHumanPlayer() && (mapEntry.first->isReadyToSpawn() || this->bForceSpawn_))
     345                this->spawnPlayer(mapEntry.first);
    346346    }
    347347   
     
    351351        if(player && player->isHumanPlayer())
    352352        {
    353             if(this->activeBrick_ != NULL)
     353            if(this->activeBrick_ != nullptr)
    354354            {
    355355                this->player_->stopControl();
     
    370370        assert(player);
    371371
    372         if(this->player_ == NULL)
     372        if(this->player_ == nullptr)
    373373        {
    374374            this->player_ = player;
     
    381381    void Tetris::startBrick(void)
    382382    {
    383         if(this->player_ == NULL)
     383        if(this->player_ == nullptr)
    384384            return;
    385385
    386386        unsigned int cameraIndex = 0;
    387         if(this->activeBrick_ != NULL)
     387        if(this->activeBrick_ != nullptr)
    388388        {
    389389            // Get camera settings
     
    396396        // Make the last brick to be created the active brick.
    397397        this->activeBrick_ = this->futureBrick_;
    398         this->futureBrick_ = 0;
     398        this->futureBrick_ = nullptr;
    399399
    400400        // set its position
     
    437437        Get the player.
    438438    @return
    439         Returns a pointer to the player. If there is no player, NULL is returned.
     439        Returns a pointer to the player. If there is no player, nullptr is returned.
    440440    */
    441441    PlayerInfo* Tetris::getPlayer(void) const
     
    469469        {
    470470            stonesPerRow = 0;
    471             for(std::list<StrongPtr<TetrisStone> >::iterator it = this->stones_.begin(); it != this->stones_.end(); )
    472             {
    473                 std::list<StrongPtr<TetrisStone> >::iterator it_temp = it++;
     471            for(std::list<StrongPtr<TetrisStone>>::iterator it = this->stones_.begin(); it != this->stones_.end(); )
     472            {
     473                std::list<StrongPtr<TetrisStone>>::iterator it_temp = it++;
    474474                correctPosition = static_cast<unsigned int>(((*it_temp)->getPosition().y - 5)/this->center_->getStoneSize());
    475475                if(correctPosition == row)
     
    491491    void Tetris::clearRow(unsigned int row)
    492492    {// clear the full row
    493         for(std::list<StrongPtr<TetrisStone> >::iterator it = this->stones_.begin(); it != this->stones_.end(); )
     493        for(std::list<StrongPtr<TetrisStone>>::iterator it = this->stones_.begin(); it != this->stones_.end(); )
    494494        {
    495495            if(static_cast<unsigned int>(((*it)->getPosition().y - 5)/this->center_->getStoneSize()) == row)
     
    502502        }
    503503      // adjust height of stones above the deleted row //TODO: check if this could be a source of a bug.
    504         for(std::list<StrongPtr<TetrisStone> >::iterator it = this->stones_.begin(); it != this->stones_.end(); ++it)
    505         {
    506             if(static_cast<unsigned int>(((*it)->getPosition().y - 5)/this->center_->getStoneSize()) > row)
    507                 (*it)->setPosition((*it)->getPosition()-Vector3(0,10,0));
     504        for(TetrisStone* stone : this->stones_)
     505        {
     506            if(static_cast<unsigned int>((stone->getPosition().y - 5)/this->center_->getStoneSize()) > row)
     507                stone->setPosition(stone->getPosition()-Vector3(0,10,0));
    508508        }
    509509
  • code/trunk/src/modules/tetris/Tetris.h

    r10624 r11071  
    5858            virtual ~Tetris(); //!< Destructor. Cleans up, if initialized.
    5959
    60             virtual void start(void); //!< Starts the Tetris minigame.
    61             virtual void end(void); ///!< Ends the Tetris minigame.
     60            virtual void start(void) override; //!< Starts the Tetris minigame.
     61            virtual void end(void) override; ///!< Ends the Tetris minigame.
    6262
    63             virtual void tick(float dt);
     63            virtual void tick(float dt) override;
    6464
    65             virtual void spawnPlayer(PlayerInfo* player); //!< Spawns the input player.
    66             virtual bool playerLeft(PlayerInfo* player);
     65            virtual void spawnPlayer(PlayerInfo* player) override; //!< Spawns the input player.
     66            virtual bool playerLeft(PlayerInfo* player) override;
    6767
    6868            void setCenterpoint(TetrisCenterpoint* center);
     
    7777
    7878        protected:
    79             virtual void spawnPlayersIfRequested(); //!< Spawns player.
     79            virtual void spawnPlayersIfRequested() override; //!< Spawns player.
    8080
    8181
     
    9393
    9494            WeakPtr<TetrisCenterpoint> center_; //!< The playing field.
    95             std::list<StrongPtr<TetrisStone> > stones_; //!< A list of all stones in play.
     95            std::list<StrongPtr<TetrisStone>> stones_; //!< A list of all stones in play.
    9696            WeakPtr<TetrisBrick> activeBrick_;
    9797            WeakPtr<TetrisBrick> futureBrick_;
  • code/trunk/src/modules/tetris/TetrisBrick.cc

    r10624 r11071  
    8181            this->attach(stone);
    8282            this->formBrick(stone, i);
    83             if(this->tetris_ != NULL)
     83            if(this->tetris_ != nullptr)
    8484            {
    8585                stone->setGame(this->tetris_);
    86                 if(this->tetris_->getCenterpoint() != NULL)
     86                if(this->tetris_->getCenterpoint() != nullptr)
    8787                    stone->addTemplate(this->tetris_->getCenterpoint()->getStoneTemplate());
    8888                else
    89                     orxout()<< "tetris_->getCenterpoint == NULL in TetrisBrick.cc"<< endl;
     89                    orxout()<< "tetris_->getCenterpoint == nullptr in TetrisBrick.cc"<< endl;
    9090            }
    9191            else
    92                 orxout()<< "tetris_ == NULL in TetrisBrick.cc"<< endl;
     92                orxout()<< "tetris_ == nullptr in TetrisBrick.cc"<< endl;
    9393        }
    9494    }
     
    161161        if(i < this->brickStones_.size())
    162162            return this->brickStones_[i];
    163         else return NULL;
     163        else return nullptr;
    164164    }
    165165
     
    167167    Tetris* TetrisBrick::getTetris()
    168168    {
    169         if (this->getGametype() != NULL && this->getGametype()->isA(Class(Tetris)))
     169        if (this->getGametype() != nullptr && this->getGametype()->isA(Class(Tetris)))
    170170        {
    171171            Tetris* tetrisGametype = orxonox_cast<Tetris*>(this->getGametype());
    172172            return tetrisGametype;
    173173        }
    174         return NULL;
     174        return nullptr;
    175175    }
    176176
     
    239239    {
    240240        assert(this->tetris_);
    241         for(unsigned int i = 0; i < this->brickStones_.size(); i++)
    242         {
    243             this->brickStones_[i]->detachFromParent();
    244             this->brickStones_[i]->attachToParent(center);
    245             this->brickStones_[i]->setPosition(this->getPosition()+this->tetris_->rotateVector(this->brickStones_[i]->getPosition(),this->rotationCount_ ));
     241        for(TetrisStone* stone : this->brickStones_)
     242        {
     243            stone->detachFromParent();
     244            stone->attachToParent(center);
     245            stone->setPosition(this->getPosition()+this->tetris_->rotateVector(stone->getPosition(),this->rotationCount_ ));
    246246        }
    247247        this->brickStones_.clear();
  • code/trunk/src/modules/tetris/TetrisBrick.h

    r10262 r11071  
    5757            virtual ~TetrisBrick() {}
    5858
    59             virtual void moveFrontBack(const Vector2& value); //!< Overloaded the function to steer the bat up and down.
    60             virtual void moveRightLeft(const Vector2& value); //!< Overloaded the function to steer the bat up and down.
    61             virtual void changedPlayer(); //!< Is called when the player changed.
     59            virtual void moveFrontBack(const Vector2& value) override; //!< Overloaded the function to steer the bat up and down.
     60            virtual void moveRightLeft(const Vector2& value) override; //!< Overloaded the function to steer the bat up and down.
     61            virtual void changedPlayer() override; //!< Is called when the player changed.
    6262
    6363            bool isValidMove(const Vector3& position, bool isRotation);
  • code/trunk/src/modules/tetris/TetrisCenterpoint.cc

    r10624 r11071  
    8484    void TetrisCenterpoint::checkGametype()
    8585    {
    86         if (this->getGametype() != NULL && this->getGametype()->isA(Class(Tetris)))
     86        if (this->getGametype() != nullptr && this->getGametype()->isA(Class(Tetris)))
    8787        {
    8888            Tetris* tetrisGametype = orxonox_cast<Tetris*>(this->getGametype());
  • code/trunk/src/modules/tetris/TetrisCenterpoint.h

    r10624 r11071  
    6262            virtual ~TetrisCenterpoint() {}
    6363
    64             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method to create a TetrisCenterpoint through XML.
     64            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; //!< Method to create a TetrisCenterpoint through XML.
    6565
    6666            /**
  • code/trunk/src/modules/tetris/TetrisScore.cc

    r10624 r11071  
    3636
    3737#include "core/CoreIncludes.h"
    38 #include "core/XMLPort.h"
    3938#include "util/Convert.h"
    4039
     
    5655        RegisterObject(TetrisScore);
    5756
    58         this->owner_ = 0;
    59         this->player_ = NULL;
     57        this->owner_ = nullptr;
     58        this->player_ = nullptr;
    6059    }
    6160
     
    6665    TetrisScore::~TetrisScore()
    6766    {
    68     }
    69 
    70     /**
    71     @brief
    72         Method to create a TetrisScore through XML.
    73     */
    74     void TetrisScore::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    75     {
    76         SUPER(TetrisScore, XMLPort, xmlelement, mode);
    7767    }
    7868
     
    8979
    9080        // If the owner is set. The owner being a Tetris game.
    91         if (this->owner_ != NULL)
     81        if (this->owner_ != nullptr)
    9282        {
    9383            std::string score("0");
     
    10191            {
    10292                // Save the name and score of each player as a string.
    103                 if (player_ != NULL)
     93                if (player_ != nullptr)
    10494                    score = multi_cast<std::string>(this->owner_->getScore(player_));
    10595            }
     
    111101    @brief
    112102        Is called when the owner changes.
    113         Sets the owner to NULL, if it is not a pointer to a Tetris game.
     103        Sets the owner to nullptr, if it is not a pointer to a Tetris game.
    114104    */
    115105    void TetrisScore::changedOwner()
     
    117107        SUPER(TetrisScore, changedOwner);
    118108
    119         if (this->getOwner() != NULL && this->getOwner()->getGametype())
     109        if (this->getOwner() != nullptr && this->getOwner()->getGametype())
    120110            this->owner_ = orxonox_cast<Tetris*>(this->getOwner()->getGametype());
    121111        else
    122             this->owner_ = 0;
     112            this->owner_ = nullptr;
    123113    }
    124114}
  • code/trunk/src/modules/tetris/TetrisScore.h

    r10262 r11071  
    6060            virtual ~TetrisScore();
    6161
    62             virtual void tick(float dt); //!< Creates and sets the caption to be displayed by the TetrisScore.
    63             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    64             virtual void changedOwner(); //!< Is called when the owner changes.
     62            virtual void tick(float dt) override; //!< Creates and sets the caption to be displayed by the TetrisScore.
     63            virtual void changedOwner() override; //!< Is called when the owner changes.
    6564
    6665        private:
Note: See TracChangeset for help on using the changeset viewer.