Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5860 for code/branches


Ignore:
Timestamp:
Oct 2, 2009, 8:41:33 PM (15 years ago)
Author:
landauf
Message:

using a WeakPtr in Projectile instead of inheriting from PawnListener
fixed another small inaccuracy in TeamDeathmatch

Location:
code/branches/core5/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core5/src/modules/weapons/projectiles/Projectile.cc

    r5831 r5860  
    133133    }
    134134
    135     void Projectile::destroyedPawn(Pawn* pawn)
     135    void Projectile::setOwner(Pawn* owner)
    136136    {
    137         if (this->owner_ == pawn)
    138             this->owner_ = 0;
     137        this->owner_ = owner;
    139138    }
    140139}
  • code/branches/core5/src/modules/weapons/projectiles/Projectile.h

    r5831 r5860  
    3333
    3434#include "tools/Timer.h"
    35 #include "interfaces/PawnListener.h"
    3635#include "worldentities/MovableEntity.h"
    3736
    3837namespace orxonox
    3938{
    40     class _WeaponsExport Projectile : public MovableEntity, public PawnListener
     39    class _WeaponsExport Projectile : public MovableEntity
    4140    {
    4241        public:
     
    4948            virtual void tick(float dt);
    5049            virtual bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint);
    51             virtual void destroyedPawn(Pawn* pawn);
    5250
    5351            inline void setDamage(float damage)
     
    5654                { return this->damage_; }
    5755
    58             inline void setOwner(Pawn* owner)
    59                 { this->owner_ = owner; }
     56            void setOwner(Pawn* owner);
    6057            inline Pawn* getOwner() const
    6158                { return this->owner_; }
    6259
    6360        private:
    64             Pawn* owner_;
     61            WeakPtr<Pawn> owner_;
    6562            float lifetime_;
    6663            float damage_;
  • code/branches/core5/src/orxonox/gametypes/TeamDeathmatch.cc

    r5859 r5860  
    100100    bool TeamDeathmatch::allowPawnHit(Pawn* victim, Pawn* originator)
    101101    {
    102         return (!this->pawnsAreInTheSameTeam(victim, originator));
     102        return (!this->pawnsAreInTheSameTeam(victim, originator) || !originator);
    103103    }
    104104
    105105    bool TeamDeathmatch::allowPawnDamage(Pawn* victim, Pawn* originator)
    106106    {
    107         return (!this->pawnsAreInTheSameTeam(victim, originator));
     107        return (!this->pawnsAreInTheSameTeam(victim, originator) || !originator);
    108108    }
    109109
    110110    bool TeamDeathmatch::allowPawnDeath(Pawn* victim, Pawn* originator)
    111111    {
    112         return (!this->pawnsAreInTheSameTeam(victim, originator));
     112        return (!this->pawnsAreInTheSameTeam(victim, originator) || !originator);
    113113    }
    114114
Note: See TracChangeset for help on using the changeset viewer.