Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 29, 2011, 6:44:45 PM (13 years ago)
Author:
dafrick
Message:

Possible fix for segfaults due to player being NULL.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation/src/orxonox/interfaces/PlayerTrigger.h

    r7601 r8667  
    4040#include "core/OrxonoxClass.h"
    4141
     42#include "infos/PlayerInfo.h"
     43#include "worldentities/pawns/Pawn.h"
     44
    4245namespace orxonox
    4346{
    4447    /**
    4548    @brief
    46         PlayerTrigger is an interface if implemented by a specific trigger can be used to recover the Player (or more precisely the @ref orxonox::Pawn "Pawn") that triggered it.
     49        PlayerTrigger is an interface if implemented by a specific trigger can be used to recover the Player (or the @ref orxonox::Pawn "Pawn") that triggered it.
    4750
    4851    @author
     
    5861
    5962        /**
    60         @brief Returns the player that triggered the PlayerTrigger.
     63        @brief Returns the Pawn that triggered the PlayerTrigger.
    6164        @return Returns a pointer to the Pawn that triggered the PlayerTrigger.
    6265        */
    63         inline Pawn* getTriggeringPlayer(void) const
     66        inline Pawn* getTriggeringPawn(void) const
     67            { return this->pawn_.get(); }
     68
     69        /**
     70        @brief Returns the player that triggered the PlayerTrigger.
     71        @return Returns a pointer to the PlayerInfo that triggered the PlayerTrigger.
     72        */
     73        inline PlayerInfo* getTriggeringPlayer(void) const
    6474            { return this->player_; }
    6575
    6676        /**
    67         @brief Checks whether the PlayerTrigger normally returns a Pawn.
    68         @return Returns true if the PlayerTrigger normally returns a Pawn.
     77        @brief Checks whether the PlayerTrigger normally returns a Pawn/PlayerInfo.
     78        @return Returns true if the PlayerTrigger normally returns a Pawn/PlayerInfo.
    6979        */
    7080        inline bool isForPlayer(void) const
     
    7686        @param player A pointer to the Pawn that triggered the PlayerTrigger.
    7787        */
    78         inline void setTriggeringPlayer(Pawn* player)
    79            { this->player_ = player; }
     88        inline void setTriggeringPawn(Pawn* pawn)
     89           { assert(pawn); this->player_ = WeakPtr<PlayerInfo>(pawn->getPlayer()); this->pawn_ = WeakPtr<Pawn>(pawn); }
    8090
    8191        /**
     
    8797
    8898    private:
    89         Pawn* player_; //!< The player that triggered the PlayerTrigger.
     99        WeakPtr<PlayerInfo> player_; //!< The player that triggered the PlayerTrigger.
     100        WeakPtr<Pawn> pawn_; //!< The Pawn that triggered the PlayerTrigger.
    90101        bool isForPlayer_; //!< Is true when the PlayerTrigger should be set to normally be triggered by Pawns.
    91102
Note: See TracChangeset for help on using the changeset viewer.