Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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;
Note: See TracChangeset for help on using the changeset viewer.