Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 17, 2016, 1:59:00 PM (9 years ago)
Author:
landauf
Message:

added c++11 features to code that was added in presentationHS15

Location:
code/branches/cpp11_v3/src/modules/pickup/items
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/branches/cpp11_v3/src/modules/pickup/items/BoostPickup.cc

    r11052 r11065  
    106106
    107107        SpaceShip* ship = this->carrierToSpaceShipHelper();
    108         if(ship == NULL) // If the PickupCarrier is no SpaceShip, then this pickup is useless and therefore is destroyed.
     108        if(ship == nullptr) // If the PickupCarrier is no SpaceShip, then this pickup is useless and therefore is destroyed.
    109109            this->Pickupable::destroy();
    110110
     
    128128        Helper to transform the PickupCarrier to a SpaceShip, and throw an error message if the conversion fails.
    129129    @return
    130         A pointer to the SpaceShip, or NULL if the conversion failed.
     130        A pointer to the SpaceShip, or nullptr if the conversion failed.
    131131    */
    132132    SpaceShip* BoostPickup::carrierToSpaceShipHelper(void)
     
    135135        SpaceShip* ship = orxonox_cast<SpaceShip*>(carrier);
    136136
    137         if(ship == NULL)
     137        if(ship == nullptr)
    138138        {
    139139            orxout(internal_error, context::pickups) << "Invalid PickupCarrier in BoostPickup." << endl;
  • code/branches/cpp11_v3/src/modules/pickup/items/BoostPickup.h

    r11052 r11065  
    5252            virtual ~BoostPickup(); //!< Destructor.
    5353
    54             virtual void XMLPort(Element& xmlelement, orxonox::XMLPort::Mode mode); //!< Method for creating a BoostPickup object through XML.
     54            virtual void XMLPort(Element& xmlelement, orxonox::XMLPort::Mode mode) override; //!< Method for creating a BoostPickup object through XML.
    5555
    56             virtual void changedUsed(void); //!< Is called when the pickup has transited from used to unused or the other way around.
     56            virtual void changedUsed(void) override; //!< Is called when the pickup has transited from used to unused or the other way around.
    5757            inline float getBoostRefill()
    5858                { return this->boostRefill_; }
  • code/branches/cpp11_v3/src/modules/pickup/items/MunitionContainer.h

    r11052 r11065  
    5353            virtual ~MunitionContainer();
    5454
    55             virtual void XMLPort(Element& xmlelement, orxonox::XMLPort::Mode mode);
     55            virtual void XMLPort(Element& xmlelement, orxonox::XMLPort::Mode mode) override;
    5656
    5757            inline const std::string& getMunitionName() const
  • code/branches/cpp11_v3/src/modules/pickup/items/MunitionPickup.cc

    r11052 r11065  
    8686    void MunitionPickup::addMunitionContainer(MunitionContainer* munitionContainer)
    8787    {
    88         OrxAssert(munitionContainer != NULL, "The munitionContainer cannot be NULL.");
     88        OrxAssert(munitionContainer != nullptr, "The munitionContainer cannot be nullptr.");
    8989        this->munitionContainers_.push_back(munitionContainer);
    9090    }
     
    9393    {
    9494        if(this->munitionContainers_.size() >= index)
    95             return NULL;
     95            return nullptr;
    9696        else
    9797            return this->munitionContainers_[index];
     
    108108        Pawn* pawn = this->carrierToPawnHelper();
    109109
    110         if(pawn == NULL) // If the PickupCarrier is no Pawn, then this pickup is useless and therefore is destroyed.
     110        if(pawn == nullptr) // If the PickupCarrier is no Pawn, then this pickup is useless and therefore is destroyed.
    111111            this->Pickupable::destroy();
    112112
     
    114114        if(this->isUsed())
    115115        {
    116             for(std::vector<MunitionContainer*>::iterator it = this->munitionContainers_.begin(); it != this->munitionContainers_.end(); ++it)
     116            for(MunitionContainer* container : this->munitionContainers_)
    117117            {
    118118                //Get pointer to the appropriate munition
    119                 SubclassIdentifier<Munition> identifier = (*it)->getMunitionType();
     119                SubclassIdentifier<Munition> identifier = container->getMunitionType();
    120120                Munition* munition = pawn->getMunition(&identifier);
    121121                if (munition)
    122122                {
    123123                    // Add munition and magzines
    124                     munition->addMunition((*it)->getMunitionAmount());
    125                     munition->addMagazines((*it)->getMagazinesAmount());
     124                    munition->addMunition(container->getMunitionAmount());
     125                    munition->addMagazines(container->getMagazinesAmount());
    126126                }
    127                 (*it)->destroy();
     127                container->destroy();
    128128            }
    129129            // This will destroy the pickp
     
    140140        Helper to transform the PickupCarrier to a Pawn, and throw an error message if the conversion fails.
    141141    @return
    142         A pointer to the Pawn, or NULL if the conversion failed.
     142        A pointer to the Pawn, or nullptr if the conversion failed.
    143143    */
    144144    Pawn* MunitionPickup::carrierToPawnHelper(void)
     
    147147        Pawn* pawn = orxonox_cast<Pawn*>(carrier);
    148148
    149         if(pawn == NULL)
     149        if(pawn == nullptr)
    150150        {
    151151            orxout(internal_error, context::pickups) << "Invalid PickupCarrier in MunitionPickup." << endl;
  • code/branches/cpp11_v3/src/modules/pickup/items/MunitionPickup.h

    r11064 r11065  
    5959            virtual ~MunitionPickup(); //!< Destructor.
    6060
    61             virtual void XMLPort(Element& xmlelement, orxonox::XMLPort::Mode mode); //!< Method for creating a MunitionPickup object through XML.
     61            virtual void XMLPort(Element& xmlelement, orxonox::XMLPort::Mode mode) override; //!< Method for creating a MunitionPickup object through XML.
    6262
    63             virtual void changedUsed(void); //!< Is called when the pickup has transited from used to unused or the other way around.
     63            virtual void changedUsed(void) override; //!< Is called when the pickup has transited from used to unused or the other way around.
    6464
    6565            void addMunitionContainer(MunitionContainer* munitionContainer);
Note: See TracChangeset for help on using the changeset viewer.