Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 13, 2016, 10:19:21 PM (9 years ago)
Author:
landauf
Message:

return const-ref to collections instead of pointer

Location:
code/branches/cpp11_v3/src/modules/overlays/hud
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/cpp11_v3/src/modules/overlays/hud/HUDWeapon.cc

    r11054 r11059  
    4444        weaponModeHUDActualSize_ = Vector2(0.0f,0.0f);
    4545
    46         weaponModes_ = NULL;
    4746        weaponIndex_ = 0;
    4847        hudWeaponModes_.clear();
     
    148147        destroyHUDChilds();
    149148
    150         weaponModes_ = weapon_->getAllWeaponmodes();
    151 
    152149        updateSize();
    153150        createHUDChilds();
     
    157154    void HUDWeapon::createHUDChilds()
    158155    {
    159         if (weaponModes_ == NULL)
     156        if (weapon_ == NULL)
    160157        {
    161158            return;
     
    164161        int positionIndex = 0;
    165162
    166         for (std::multimap<unsigned int, WeaponMode*>::iterator it = weaponModes_->begin(); it != weaponModes_->end(); ++it)
     163        for (std::multimap<unsigned int, WeaponMode*>::const_iterator it = weapon_->getAllWeaponmodes().begin(); it != weapon_->getAllWeaponmodes().end(); ++it)
    167164        {
    168165            HUDWeaponMode* hudWeaponMode = new HUDWeaponMode(this->getContext());
     
    208205    void HUDWeapon::updateSize()
    209206    {
    210         if (weaponModes_ != NULL)
    211         {
    212             this->setSize(Vector2(weaponModeHUDActualSize_.x,weaponModeHUDActualSize_.y*weaponModes_->size()));
     207        if (weapon_ != NULL)
     208        {
     209            this->setSize(Vector2(weaponModeHUDActualSize_.x,weaponModeHUDActualSize_.y*weapon_->getAllWeaponmodes().size()));
    213210            updatePosition();
    214211        }       
     
    217214    void HUDWeapon::updatePosition()
    218215    {
    219         if (weaponModes_ != NULL)
     216        if (weapon_ != NULL)
    220217        {
    221218            this->setPosition(Vector2(weaponModeHUDActualSize_.x*weaponIndex_,0.0f) + this->positionOffset_);
  • code/branches/cpp11_v3/src/modules/overlays/hud/HUDWeapon.h

    r11052 r11059  
    9494        WeakPtr<Weapon> weapon_;
    9595
    96         std::multimap<unsigned int, WeaponMode*>* weaponModes_;
    9796        std::vector<WeakPtr<HUDWeaponMode> > hudWeaponModes_;
    9897
  • code/branches/cpp11_v3/src/modules/overlays/hud/HUDWeaponSystem.cc

    r11054 r11059  
    126126        destroyHUDChilds();
    127127
    128         std::vector<WeaponPack*>* weaponPacks = owner_->getAllWeaponPacks();
     128        if (owner_->getWeaponSystem())
     129        {
     130            const std::vector<WeaponPack*>& weaponPacks = owner_->getWeaponSystem()->getAllWeaponPacks();
    129131
    130         for (std::vector<WeaponPack*>::const_iterator itPacks = weaponPacks->begin(); itPacks != weaponPacks->end(); ++itPacks)
    131         {
    132             std::vector<Weapon*>* weapons = (*itPacks)->getAllWeapons();
     132            for (std::vector<WeaponPack*>::const_iterator itPacks = weaponPacks.begin(); itPacks != weaponPacks.end(); ++itPacks)
     133            {
     134                const std::vector<Weapon*>& weapons = (*itPacks)->getAllWeapons();
    133135
    134             for (std::vector<Weapon*>::const_iterator itWeapons = weapons->begin(); itWeapons != weapons->end(); ++itWeapons)
    135             {
    136                 this->weapons_.push_back(*itWeapons);
     136                for (std::vector<Weapon*>::const_iterator itWeapons = weapons.begin(); itWeapons != weapons.end(); ++itWeapons)
     137                {
     138                    this->weapons_.push_back(*itWeapons);
     139                }
    137140            }
     141
     142            createHUDChilds();
     143            positionHUDChilds();
    138144        }
    139 
    140         createHUDChilds();
    141         positionHUDChilds();
    142145    }
    143146
Note: See TracChangeset for help on using the changeset viewer.