Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2366 for code/branches/weapon2


Ignore:
Timestamp:
Dec 9, 2008, 5:44:34 PM (16 years ago)
Author:
polakma
Message:

fixed some pointer bugs

Location:
code/branches/weapon2/src/orxonox/objects
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • code/branches/weapon2/src/orxonox/objects/weaponSystem/Weapon.cc

    r2354 r2366  
    8484    void Weapon::attachNeededMunition(std::string munitionName)
    8585    {
     86COUT(0) << "Weapon::attachNeededMunition, parentWeaponSystem=" << this->parentWeaponSystem_ << std::endl;
    8687        //if munition type already exists attach it, else create a new one of this type and attach it to the weapon and to the WeaponSystem
    8788        if (this->parentWeaponSystem_)
    8889        {
     90COUT(0) << "Weapon::attachNeededMunition " << munitionName << std::endl;
    8991            Munition* munition = this->parentWeaponSystem_->getMunitionType(munitionName);
    9092            if ( munition )
  • code/branches/weapon2/src/orxonox/objects/weaponSystem/Weapon.h

    r2354 r2366  
    7070            Timer<Weapon> *getMagazineTimer();
    7171
    72             void setMunitionType(std::string munitionType);
    73             const std::string getMunitionType();
     72            virtual void setMunitionType(std::string munitionType);
     73            virtual const std::string getMunitionType();
    7474
    7575            inline void setParentWeaponSlot(WeaponSlot *parentWeaponSlot)
  • code/branches/weapon2/src/orxonox/objects/weaponSystem/WeaponPack.cc

    r2354 r2366  
    9292    void WeaponPack::addWeapon(Weapon * weapon)
    9393    {
    94         weapon->setParentWeaponSystem(this->parentWeaponSystem_);
    95 COUT(0) << "WeaponPack::addWeapon " << weapon << "   munition " << weapon->getMunitionType() << std::endl;
     94COUT(0) << "WeaponPack::addWeapon:" << weapon << "   munition " << weapon->getMunitionType() << std::endl;
    9695        this->weapons_.push_back(weapon);
    9796    }
     
    102101    }
    103102
    104     void WeaponPack::setWeaponSystemToAllWeapons(WeaponSystem * weaponSystem)
     103    void WeaponPack::setParentWeaponSystemToAllWeapons(WeaponSystem * weaponSystem)
    105104    {
    106105        for (int i=0; i < (int) this->weapons_.size(); i++)
     
    110109
    111110    }
     111
     112    void WeaponPack::attachNeededMunitionToAllWeapons()
     113    {
     114        for (int i=0; i < (int) this->weapons_.size(); i++)
     115        {
     116            this->weapons_[i]->attachNeededMunition(weapons_[i]->getMunitionType());
     117        }
     118
     119    }
     120
    112121}
  • code/branches/weapon2/src/orxonox/objects/weaponSystem/WeaponPack.h

    r2354 r2366  
    5959            const Weapon * getWeapon(unsigned int index);
    6060
    61             void setWeaponSystemToAllWeapons(WeaponSystem * weaponSystem);
     61            //functions needed for creating Pointer to the right objects (-->Pawn.cc)
     62            void setParentWeaponSystemToAllWeapons(WeaponSystem * weaponSystem);
     63            void attachNeededMunitionToAllWeapons();
    6264
    6365            inline void setParentWeaponSystem(WeaponSystem *parentWeaponSystem)
  • code/branches/weapon2/src/orxonox/objects/weaponSystem/WeaponSet.cc

    r2337 r2366  
    5656    {
    5757COUT(0) << "WeaponSet::attachWeaponPack" << std::endl;
     58COUT(0) << "........ parentWeaponSystem_=" << this->parentWeaponSystem_ << std::endl;
     59COUT(0) << "........ this->parentWeaponSystem_->getWeaponSlotSize()" << this->parentWeaponSystem_->getWeaponSlotSize() << std::endl;
     60COUT(0) << "........ wPack->getSize()" << wPack->getSize() << std::endl;
    5861        if ( this->parentWeaponSystem_->getWeaponSlotSize()>0 && wPack->getSize()>0 && ( wPack->getSize() <= this->parentWeaponSystem_->getWeaponSlotSize() ) )
    5962        {
     63COUT(0) << "WeaponSet::attachWeaponPack after if" << std::endl;
    6064            this->attachedWeaponPack_ = wPack;
    6165            int wPackWeapon = 0;    //WeaponCounter for Attaching
     
    7882    {
    7983        //fires all WeaponSlots available for this weaponSet attached from the WeaponPack
    80 COUT(0) << "WeaponSet::fire" << std::endl;
     84COUT(0) << "WeaponSet::fire from Pack: " << this->attachedWeaponPack_ << std::endl;
    8185        this->attachedWeaponPack_->fire();
    8286    }
  • code/branches/weapon2/src/orxonox/objects/weaponSystem/WeaponSystem.cc

    r2337 r2366  
    6262    void WeaponSystem::attachWeaponPack(WeaponPack *wPack, unsigned int firemode)
    6363    {
    64         wPack->setParentWeaponSystem(this);
    6564        if (firemode < this->weaponSets_.size())
    6665            this->weaponSets_[firemode]->attachWeaponPack(wPack);
     
    8887    Munition * WeaponSystem::getMunitionType(std::string munitionType)
    8988    {
     89COUT(0) << "WeaponSystem::getMunitionType " << munitionType << std::endl;
    9090        std::map<std::string, Munition *>::const_iterator it = this->munitionSet_.find(munitionType);
    9191        if (it != this->munitionSet_.end())
  • code/branches/weapon2/src/orxonox/objects/weaponSystem/weapons/LaserGun.cc

    r2354 r2366  
    4444    {
    4545        RegisterObject(LaserGun);
    46 
    47         //set weapon properties here
    48         //this->setLoadingTime(0.5);
    49 
    50 COUT(0) << "LaserGun::LaserGun" << std::endl;
    51         this->attachNeededMunition(this->getMunitionType());
    5246    }
    5347
     
    5852    void LaserGun::fire()
    5953    {
    60 COUT(0) << "LaserGun::fire" << std::endl;
     54COUT(0) << "LaserGun::fire, this=" << this << std::endl;
    6155        if ( this->getBulletReadyToShoot() && this->getMagazineReadyToShoot() )
    6256        {
     
    8175    }
    8276
    83     void LaserGun::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    84     {
    85         SUPER(LaserGun, XMLPort, xmlelement, mode);
    86         XMLPortParam(LaserGun, "munitionType", setMunitionType, getMunitionType, xmlelement, mode);
    87     }
    88 
    89     void LaserGun::setMunitionType(std::string munitionType)
    90     {   
    91 COUT(0) << "LaserGun::setMunitionType (XMLPort) "<< munitionType << std::endl;
    92         this->munitionType_ = munitionType; }
    93 
    94     const std::string LaserGun::getMunitionType()
    95     {   return this->munitionType_;  }
    96 
    9777}
  • code/branches/weapon2/src/orxonox/objects/weaponSystem/weapons/LaserGun.h

    r2354 r2366  
    4848            virtual ~LaserGun();
    4949
    50             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    51 
    5250            void fire();
    53 
    54             void setMunitionType(std::string munitionType);
    55             const std::string getMunitionType();
    5651
    5752        private:
  • code/branches/weapon2/src/orxonox/objects/worldentities/pawns/Pawn.cc

    r2337 r2366  
    167167    {   
    168168COUT(0) << "Pawn::setWeaponPack" << std::endl;
     169        wPack->setParentWeaponSystem(this->weaponSystem_);
     170        wPack->setParentWeaponSystemToAllWeapons(this->weaponSystem_);
    169171        this->weaponSystem_->attachWeaponPack( wPack,wPack->getFireMode() );
    170         wPack->setParentWeaponSystem(this->weaponSystem_);
    171         wPack->setWeaponSystemToAllWeapons(this->weaponSystem_);
     172        wPack->attachNeededMunitionToAllWeapons();
    172173    }
    173174
Note: See TracChangeset for help on using the changeset viewer.