Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 3, 2008, 4:30:13 PM (16 years ago)
Author:
polakma
Message:

fixed parentWeaponSystem-Pointer bugs

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

Legend:

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

    r2288 r2327  
    3737namespace orxonox
    3838{
     39    CreateFactory(Weapon);
     40
    3941    Weapon::Weapon(BaseObject* creator) : BaseObject(creator)
    4042    {
     
    4244        this->bulletReadyToShoot_ = true;
    4345        this->magazineReadyToShoot_ = true;
    44         this->setParentWeaponSystem();
    4546    }
    4647
     
    9596     *
    9697     */
    97     void Weapon::setParentWeaponSystem()
    98     {   this->parentWeaponSystem_ = this->parentWeaponSlot_->getParentWeaponSystem(); }
    99 
    10098    Munition * Weapon::getAttachedMunition()
    10199    {   return this->munition_; }
  • code/branches/weapon2/src/orxonox/objects/weaponSystem/Weapon.h

    r2272 r2327  
    5252            virtual void fire();
    5353            void attachNeededMunition(std::string munitionType);
    54             virtual void setParentWeaponSystem();
    5554            Munition * getAttachedMunition();
    5655
     
    7271
    7372            inline void setParentWeaponSlot(WeaponSlot *parentWeaponSlot)
    74                 { parentWeaponSlot_=parentWeaponSlot; };
     73                { this->parentWeaponSlot_=parentWeaponSlot; };
    7574            inline WeaponSlot * getParentWeaponSlot()
    76                 { return parentWeaponSlot_; };
     75                { return this->parentWeaponSlot_; };
     76            inline void setParentWeaponSystem(WeaponSystem *parentWeaponSystem)
     77                { this->parentWeaponSystem_=parentWeaponSystem; };
     78            inline WeaponSystem * getParentWeaponSystem()
     79                { return this->parentWeaponSystem_; };
    7780
    7881        private:
  • code/branches/weapon2/src/orxonox/objects/weaponSystem/WeaponPack.cc

    r2319 r2327  
    3939namespace orxonox
    4040{
     41    CreateFactory(WeaponPack);
     42
    4143    WeaponPack::WeaponPack(BaseObject* creator) : BaseObject(creator)
    4244    {
     
    6668        for (int i=0; i < (int) this->weapons_.size(); i++)
    6769        {
    68 COUT(0) << "WeaponPack::fire"<< i << std::endl;
     70COUT(0) << "WeaponPack::fire (attached from WeaponSet)"<< i << std::endl;
    6971            this->weapons_[i]->fire();
    7072        }
     
    9496    void WeaponPack::addWeapon(Weapon * weapon)
    9597    {
     98        weapon->setParentWeaponSystem(this->parentWeaponSystem_);
    9699        this->weapons_.push_back(weapon);
    97100    }
  • code/branches/weapon2/src/orxonox/objects/weaponSystem/WeaponSet.cc

    r2319 r2327  
    3939namespace orxonox
    4040{
     41    CreateFactory(WeaponSet);
     42
    4143    WeaponSet::WeaponSet(BaseObject* creator, int k) : BaseObject(creator)
    4244    {
     
    5355    void WeaponSet::attachWeaponPack(WeaponPack *wPack)
    5456    {
     57COUT(0) << "WeaponSet::attachWeaponPack" << std::endl;
    5558        if ( this->parentWeaponSystem_->getWeaponSlotSize()>0 && wPack->getSize()>0 && ( wPack->getSize() <= this->parentWeaponSystem_->getWeaponSlotSize() ) )
    5659        {
     
    7578    {
    7679        //fires all WeaponSlots available for this weaponSet attached from the WeaponPack
     80COUT(0) << "WeaponSet::fire" << std::endl;
    7781        this->attachedWeaponPack_->fire();
    7882    }
  • code/branches/weapon2/src/orxonox/objects/weaponSystem/WeaponSlot.cc

    r2319 r2327  
    3838namespace orxonox
    3939{
     40    CreateFactory(WeaponSlot);
     41
    4042    WeaponSlot::WeaponSlot(BaseObject* creator) : PositionableEntity(creator)
    4143    {
  • code/branches/weapon2/src/orxonox/objects/weaponSystem/WeaponSystem.cc

    r2319 r2327  
    4646namespace orxonox
    4747{
     48    CreateFactory(WeaponSystem);
    4849
    4950    WeaponSystem::WeaponSystem(BaseObject* creator) : BaseObject(creator)
     
    6162    void WeaponSystem::attachWeaponPack(WeaponPack *wPack, unsigned int firemode)
    6263    {
     64        wPack->setParentWeaponSystem(this);
    6365        this->weaponSets_[firemode]->attachWeaponPack(wPack);
    6466        this->weaponPacks_[firemode] = wPack;
    65         wPack->setParentWeaponSystem(this);
    6667    }
    6768
    6869    void WeaponSystem::attachWeaponSlot(WeaponSlot *wSlot)
    6970    {
     71        wSlot->setParentWeaponSystem(this);
    7072        this->weaponSlots_.push_back(wSlot);
    71         wSlot->setParentWeaponSystem(this);
    7273    }
    7374
    7475    void WeaponSystem::attachWeaponSet(WeaponSet *wSet)
    7576    {
     77        wSet->setParentWeaponSystem(this);
    7678        this->weaponSets_.push_back(wSet);
    77         wSet->setParentWeaponSystem(this);
    7879    }
    7980
  • code/branches/weapon2/src/orxonox/objects/weaponSystem/weapons/LaserGun.cc

    r2288 r2327  
    3939namespace orxonox
    4040{
     41    CreateFactory(LaserGun);
     42
    4143    LaserGun::LaserGun(BaseObject* creator) : Weapon(creator)
    4244    {
  • code/branches/weapon2/src/orxonox/objects/worldentities/pawns/Pawn.cc

    r2319 r2327  
    5555        //WeaponSystem
    5656        weaponSystem_ = new WeaponSystem(this);
     57        /*
    5758        WeaponSet * weaponSet1 = new WeaponSet(this,1);
    5859        this->weaponSystem_->attachWeaponSet(weaponSet1);
    5960        //totally bad solution...
    6061        weaponSet1->setParentWeaponSystem(weaponSystem_);
    61 
     62        */
    6263
    6364        this->registerVariables();
     
    157158
    158159    void Pawn::setWeaponSlot(WeaponSlot * wSlot)
    159     {   this->weaponSystem_->attachWeaponSlot(wSlot);   }
     160    {   
     161COUT(0) << "Pawn::setWeaponSlot" << std::endl;
     162        this->weaponSystem_->attachWeaponSlot(wSlot);   }
    160163    WeaponSlot * Pawn::getWeaponSlot(unsigned int index) const
    161164    {   return this->weaponSystem_->getWeaponSlotPointer(index);    }
    162165   
    163166    void Pawn::setWeaponPack(WeaponPack * wPack)
    164     {   this->weaponSystem_->attachWeaponPack( wPack,wPack->getFireMode() );   }
     167    {   
     168COUT(0) << "Pawn::setWeaponPack" << std::endl;
     169        this->weaponSystem_->attachWeaponPack( wPack,wPack->getFireMode() );   }
    165170    WeaponPack * Pawn::getWeaponPack(unsigned int firemode) const
    166171    {   return this->weaponSystem_->getWeaponPackPointer(firemode);    }
    167172   
    168173    void Pawn::setWeaponSet(WeaponSet * wSet)
    169     {   this->weaponSystem_->attachWeaponSet(wSet);   }
     174    {   
     175COUT(0) << "Pawn::setWeaponSet" << std::endl;
     176        this->weaponSystem_->attachWeaponSet(wSet);   }
    170177    WeaponSet * Pawn::getWeaponSet(unsigned int index) const
    171178    {   return this->weaponSystem_->getWeaponSetPointer(index);    }
Note: See TracChangeset for help on using the changeset viewer.