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

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/modules/towerdefense/TowerDefense.cc

    r10727 r11071  
    9090        RegisterObject(TowerDefense);
    9191
    92         selecter = NULL;
    93         this->player_ = NULL;       
     92        selecter = nullptr;
     93        this->player_ = nullptr;
    9494        this->setHUDTemplate("TowerDefenseHUD");
    9595        this->waveNumber_ = 0;
     
    117117    void TowerDefense::start()
    118118    {       
    119         if (center_ != NULL) // There needs to be a TowerDefenseCenterpoint, i.e. the area the game takes place.
    120         {
    121             if (selecter == NULL)
     119        if (center_ != nullptr) // There needs to be a TowerDefenseCenterpoint, i.e. the area the game takes place.
     120        {
     121            if (selecter == nullptr)
    122122            {
    123123                selecter = new TowerDefenseSelecter(this->center_->getContext());               
     
    176176        WaypointController* controller = (WaypointController*)(en1->getXMLController());
    177177
    178         if (controller != NULL && waypoints_.size() > 1)
     178        if (controller != nullptr && waypoints_.size() > 1)
    179179        {
    180180            en1->setPosition(waypoints_.at(0)->getPosition() + offset_);
     
    183183            en1->lookAt(waypoints_.at(1)->getPosition() + offset_);
    184184
    185             for (unsigned int i = 0; i < waypoints_.size(); ++ i)
     185            for (TowerDefenseField* field : waypoints_)
    186186            {
    187187                orxonox::WeakPtr<MovableEntity> waypoint = new MovableEntity(this->center_->getContext());
    188                 waypoint->setPosition(waypoints_.at(i)->getPosition() + offset_);
     188                waypoint->setPosition(field->getPosition() + offset_);
    189189                controller->addWaypoint(waypoint);
    190190            }
     
    208208        player_ = player;
    209209
    210         if (selecter->getPlayer() == NULL)
     210        if (selecter->getPlayer() == nullptr)
    211211        {
    212212            player_->startControl(selecter);
     
    219219        Get the player.
    220220    @return
    221         Returns a pointer to the player. If there is no player, NULL is returned.
     221        Returns a pointer to the player. If there is no player, nullptr is returned.
    222222    */
    223223    PlayerInfo* TowerDefense::getPlayer(void) const
     
    265265        SUPER(TowerDefense, tick, dt);
    266266
    267         if (hasStarted() == false || player_ == NULL)
     267        if (hasStarted() == false || player_ == nullptr)
    268268        {
    269269            return;
     
    273273
    274274        //build/upgrade tower at selecter position
    275         if (selecter != NULL && selecter->buildTower_ == true)
     275        if (selecter != nullptr && selecter->buildTower_ == true)
    276276        {
    277277            selecter->buildTower_ = false;
     
    287287        }
    288288       
    289         for (std::list<WeakPtr<TowerDefenseEnemy> >::iterator it = enemies_.begin(); it != enemies_.end(); )
    290         {
    291             if (*it == NULL)
     289        for (std::list<WeakPtr<TowerDefenseEnemy>>::iterator it = enemies_.begin(); it != enemies_.end(); )
     290        {
     291            if (*it == nullptr)
    292292            {
    293293                // the enemy was destroyed by a tower - remove it from the list
     
    355355                fields_[i][j]->create(fields.at(pos), fields.at(pos+1));
    356356                pos += 2;
    357                 if (fields_[i][j]->getType() == START)
     357                if (fields_[i][j]->getType() == TowerDefenseFieldType::START)
    358358                {
    359359                    startCoord.Set(i,j);
     
    365365        TDCoordinate* thisCoord = &startCoord;
    366366        TDCoordinate* nextCoord;
    367         while ((nextCoord = getNextStreetCoord(thisCoord)) != NULL)
     367        while ((nextCoord = getNextStreetCoord(thisCoord)) != nullptr)
    368368        {
    369369            waypoints_.push_back(fields_[nextCoord->GetX()][nextCoord->GetY()]);           
     
    379379        TDCoordinate* nextCoord = new TDCoordinate(0,0);
    380380
    381         if (thisField->getType() != STREET && thisField->getType() != START)
    382         {
    383             return NULL;
     381        if (thisField->getType() != TowerDefenseFieldType::STREET && thisField->getType() != TowerDefenseFieldType::START)
     382        {
     383            return nullptr;
    384384        }
    385385
     
    406406        }
    407407
    408         return NULL;
     408        return nullptr;
    409409    }
    410410}
  • code/trunk/src/modules/towerdefense/TowerDefense.h

    r10629 r11071  
    5353        virtual ~TowerDefense();       
    5454        void addTowerDefenseEnemy(int templatenr);
    55         virtual void start(); //<! The function is called when the gametype starts
    56         virtual void end();
    57         virtual void tick(float dt);
    58         virtual void spawnPlayer(PlayerInfo* player);
     55        virtual void start() override; //<! The function is called when the gametype starts
     56        virtual void end() override;
     57        virtual void tick(float dt) override;
     58        virtual void spawnPlayer(PlayerInfo* player) override;
    5959        PlayerInfo* getPlayer(void) const;
    6060        int getCredit(){ return this->credit_; }
     
    8787        int waveNumber_;
    8888        int lifes_;
    89         std::list<orxonox::WeakPtr<TowerDefenseEnemy> > enemies_;
     89        std::list<orxonox::WeakPtr<TowerDefenseEnemy>> enemies_;
    9090        TowerDefenseField* fields_[16][16];
    91         std::vector<orxonox::WeakPtr<TowerDefenseField> > waypoints_;
     91        std::vector<orxonox::WeakPtr<TowerDefenseField>> waypoints_;
    9292        Vector3 endpoint_;
    9393        Vector3 offset_;       
  • code/trunk/src/modules/towerdefense/TowerDefenseCenterpoint.cc

    r10629 r11071  
    9292    void TowerDefenseCenterpoint::checkGametype()
    9393    {
    94         if (this->getGametype() != NULL && this->getGametype()->isA(Class(TowerDefense)))
     94        if (this->getGametype() != nullptr && this->getGametype()->isA(Class(TowerDefense)))
    9595        {
    9696            // Sets the centerpoint of the gametype. The gametype uses this to later spawn in towers, he needs the tower template stored in the center point
  • code/trunk/src/modules/towerdefense/TowerDefenseCenterpoint.h

    r10629 r11071  
    5252            virtual ~TowerDefenseCenterpoint() {}
    5353
    54             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     54            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
    5555
    5656            /**
  • code/trunk/src/modules/towerdefense/TowerDefenseEnemy.cc

    r10629 r11071  
    2727        RegisterObject(TowerDefenseEnemy);
    2828
    29         this->setCollisionType(WorldEntity::Dynamic);
     29        this->setCollisionType(WorldEntity::CollisionType::Dynamic);
    3030        //needed to keep track of the PlayerStats coded in TowerDefense.h
    3131        this->td = orxonox_cast<TowerDefense*>(this->getGametype());
     
    3838    }
    3939
    40     void TowerDefenseEnemy::tick(float dt)
    41     {   
    42         //orxout() << "TDE tick1" << endl;
    43         SUPER(TowerDefenseEnemy, tick, dt);
    44         //orxout() << "TDE tick2" << endl;
    45     }
    46 
    4740    WeakPtr<TowerDefense> TowerDefenseEnemy::getGame()
    4841    {
    49         if (game == NULL)
     42        if (game == nullptr)
    5043        {
    51             for (ObjectList<TowerDefense>::iterator it = ObjectList<TowerDefense>::begin(); it != ObjectList<TowerDefense>::end(); ++it)
    52                 game = *it;
     44            for (TowerDefense* towerDefense : ObjectList<TowerDefense>())
     45                game = towerDefense;
    5346        }
    5447        return game;
    5548    }
    5649
    57     void TowerDefenseEnemy::damage(float damage, float healthdamage, float shielddamage, Pawn* originator)
     50    void TowerDefenseEnemy::damage(float damage, float healthdamage, float shielddamage, Pawn* originator, const btCollisionShape* cs)
    5851    {
    5952        Pawn::damage(damage, healthdamage, shielddamage, originator);
  • code/trunk/src/modules/towerdefense/TowerDefenseEnemy.h

    r10629 r11071  
    3737        //health gibt es unter: health_
    3838
    39         virtual void tick(float dt);
    40         virtual void damage(float damage, float healthdamage, float shielddamage, Pawn* originator);
     39        virtual void damage(float damage, float healthdamage, float shielddamage, Pawn* originator, const btCollisionShape* cs) override;
    4140
    4241    private:
  • code/trunk/src/modules/towerdefense/TowerDefenseField.cc

    r11052 r11071  
    4949        RegisterObject(TowerDefenseField);
    5050
    51         tower_ = NULL;
    52         type_ = FREE;
    53         center_ = NULL;
     51        tower_ = nullptr;
     52        type_ = TowerDefenseFieldType::FREE;
     53        center_ = nullptr;
    5454        upgrade_ = 0;
    5555        setPosition(0,0,0);                           
     
    119119    bool TowerDefenseField::canUpgrade()
    120120    {
    121         if (tower_ != NULL && upgrade_ < 5)
     121        if (tower_ != nullptr && upgrade_ < 5)
    122122        {
    123123            return true;
     
    129129    void TowerDefenseField::setAngle(int newAngle)
    130130    {
    131         if (modelGround_ != NULL)
     131        if (modelGround_ != nullptr)
    132132        {
    133133            switch (newAngle)
     
    152152        }
    153153
    154         if (modelObject_ != NULL)
     154        if (modelObject_ != nullptr)
    155155        {
    156156            switch (newAngle)
     
    185185    {           
    186186        modelGround_->setMeshSource("TD_F1.mesh");
    187         tower_ = NULL;
    188         type_ = FREE;
     187        tower_ = nullptr;
     188        type_ = TowerDefenseFieldType::FREE;
    189189        setUpgrade(0);
    190190        setAngle(orientation);
     
    194194    {     
    195195        modelGround_->setMeshSource("TD_S5.mesh");
    196         tower_ = NULL;
    197         type_ = START;
     196        tower_ = nullptr;
     197        type_ = TowerDefenseFieldType::START;
    198198        setUpgrade(0);
    199199        setAngle(orientation);   
     
    204204    {     
    205205        modelGround_->setMeshSource("TD_S4.mesh");
    206         tower_ = NULL;
    207         type_ = END;
     206        tower_ = nullptr;
     207        type_ = TowerDefenseFieldType::END;
    208208        setUpgrade(0);
    209209        setAngle(orientation);
     
    213213    {     
    214214        modelGround_->setMeshSource("TD_S1.mesh");
    215         tower_ = NULL;
    216         type_ = STREET;
     215        tower_ = nullptr;
     216        type_ = TowerDefenseFieldType::STREET;
    217217        setUpgrade(0);
    218218        setAngle(orientation);
     
    222222    {     
    223223        modelGround_->setMeshSource("TD_S2.mesh");
    224         tower_ = NULL;
    225         type_ = STREET;
     224        tower_ = nullptr;
     225        type_ = TowerDefenseFieldType::STREET;
    226226        setUpgrade(0);
    227227        setAngle(orientation);
     
    231231    {   
    232232        modelGround_->setMeshSource("TD_S3.mesh");
    233         tower_ = NULL;
    234         type_ = STREET;
     233        tower_ = nullptr;
     234        type_ = TowerDefenseFieldType::STREET;
    235235        setUpgrade(0);
    236236        setAngle(orientation);
     
    241241        modelGround_->setMeshSource("TD_F1.mesh");
    242242        modelObject_->setMeshSource("TD_O1.mesh");
    243         tower_ = NULL;
    244         type_ = OBSTACLE;
     243        tower_ = nullptr;
     244        type_ = TowerDefenseFieldType::OBSTACLE;
    245245        setUpgrade(0);
    246246        setAngle(orientation);
     
    249249    void TowerDefenseField::createTower(int upgrade)
    250250    {       
    251         if (tower_ == NULL)
     251        if (tower_ == nullptr)
    252252        {
    253253            modelGround_->setMeshSource("TD_F1.mesh");
    254254            tower_ = new TowerDefenseTower(center_->getContext());
    255255            attach(tower_);
    256             type_ = TOWER;
     256            type_ = TowerDefenseFieldType::TOWER;
    257257            setUpgrade(upgrade);
    258             if (upgrade_ > 0 && modelObject_ != NULL)
     258            if (upgrade_ > 0 && modelObject_ != nullptr)
    259259            {
    260260                switch (upgrade_)
     
    287287    void TowerDefenseField::destroyTower()
    288288    {
    289         if (tower_ != NULL)
     289        if (tower_ != nullptr)
    290290        {
    291291            tower_->destroy();
    292             tower_ = NULL;
     292            tower_ = nullptr;
    293293        }
    294294    }
  • code/trunk/src/modules/towerdefense/TowerDefenseField.h

    r11052 r11071  
    4646namespace orxonox
    4747{
    48     enum TowerDefenseFieldType
     48    enum class TowerDefenseFieldType
    4949    {
    5050        FREE,
     
    6262            TowerDefenseField(Context* context);
    6363            virtual ~TowerDefenseField() {}
    64             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     64            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
    6565            const bool isFree() const
    66                 { return type_==FREE; }
     66                { return type_==TowerDefenseFieldType::FREE; }
    6767            virtual void create(char object, char param);
    6868            virtual void setCenterpoint(TowerDefenseCenterpoint* center);
  • code/trunk/src/modules/towerdefense/TowerDefenseHUDController.cc

    r10629 r11071  
    3939    {
    4040        RegisterObject(TowerDefenseHUDController);
    41         this->td = 0;
     41        this->td = nullptr;
    4242    }
    4343
     
    8989                    else
    9090                    {
    91                         this->td = 0;
     91                        this->td = nullptr;
    9292                    }
    9393                }
  • code/trunk/src/modules/towerdefense/TowerDefenseHUDController.h

    r10258 r11071  
    5353
    5454
    55         virtual void tick(float dt);
    56         virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    57         virtual void changedOwner();
     55        virtual void tick(float dt) override;
     56        virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
     57        virtual void changedOwner() override;
    5858        void setShowlives(bool temp)
    5959            { this->showlives = temp; }
  • code/trunk/src/modules/towerdefense/TowerDefenseSelecter.cc

    r11052 r11071  
    3535
    3636#include "core/CoreIncludes.h"
    37 #include "core/XMLPort.h"
    3837#include "graphics/Model.h"
    3938
     
    5958    {
    6059
    61     }
    62 
    63     void TowerDefenseSelecter::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    64     {
    65         SUPER(TowerDefenseSelecter, XMLPort, xmlelement, mode);
    6660    }
    6761
  • code/trunk/src/modules/towerdefense/TowerDefenseSelecter.h

    r10629 r11071  
    4141            TowerDefenseSelecter(Context* context); //!< Constructor. Registers and initializes the object.
    4242            virtual ~TowerDefenseSelecter();
    43             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);         
    44             virtual void tick(float dt);           
    45             virtual void moveFrontBack(const Vector2& value); //!< Overloaded the function to steer the bat up and down.
    46             virtual void moveRightLeft(const Vector2& value); //!< Overloaded the function to steer the bat up and down.
    47             virtual void rotateYaw(const Vector2& value);
    48             virtual void rotatePitch(const Vector2& value);
    49             virtual void rotateRoll(const Vector2& value);
     43            virtual void tick(float dt) override;           
     44            virtual void moveFrontBack(const Vector2& value) override; //!< Overloaded the function to steer the bat up and down.
     45            virtual void moveRightLeft(const Vector2& value) override; //!< Overloaded the function to steer the bat up and down.
     46            virtual void rotateYaw(const Vector2& value) override;
     47            virtual void rotatePitch(const Vector2& value) override;
     48            virtual void rotateRoll(const Vector2& value) override;
    5049            void fire(unsigned int firemode);
    51             virtual void fired(unsigned int firemode);
    52             virtual void boost(bool bBoost);
     50            virtual void fired(unsigned int firemode) override;
     51            virtual void boost(bool bBoost) override;
    5352            virtual void setSelectedPosition(TDCoordinate* newPos);
    5453            virtual void setSelectedPosition(int x, int y);
  • code/trunk/src/modules/towerdefense/TowerDefenseTower.cc

    r11052 r11071  
    2525    {
    2626        RegisterObject(TowerDefenseTower);
    27         game_ =NULL;
    28         this->setCollisionType(WorldEntity::None);
     27        game_ =nullptr;
     28        this->setCollisionType(WorldEntity::CollisionType::None);
    2929        upgrade = 1;
    3030
Note: See TracChangeset for help on using the changeset viewer.