Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 25, 2008, 11:56:40 PM (15 years ago)
Author:
landauf
Message:

merged questsystem2 back to trunk

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/orxonox/objects/quest/QuestHint.cc

    r2105 r2261  
    2626 *
    2727 */
     28 
     29/**
     30    @file QuestHint.cc
     31    @brief
     32    Implementation of the QuestHint class.
     33*/
    2834
    2935#include "OrxonoxStableHeaders.h"
     
    3339#include "util/Exception.h"
    3440
     41#include "orxonox/objects/infos/PlayerInfo.h"
     42#include "QuestManager.h"
    3543#include "Quest.h"
    3644
     
    4149    /**
    4250    @brief
    43         Constructor.
     51        Constructor. Registers the object.
    4452    */
    4553    QuestHint::QuestHint(BaseObject* creator) : QuestItem(creator)
    4654    {
    4755        RegisterObject(QuestHint);
    48 
    49         this->initialize();
    5056    }
    5157
     
    5965    }
    6066
    61     void QuestHint::initialize(void)
    62     {
    63         RegisterObject(QuestHint);
    64     }
    65 
     67    /**
     68    @brief
     69        Method for creating a QuestHint object through XML.
     70    */
    6671    void QuestHint::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    6772    {
    6873        SUPER(QuestHint, XMLPort, xmlelement, mode);
    6974
     75        QuestManager::registerHint(this); //!< Registers the QuestHint with the QuestManager.
     76       
    7077        COUT(3) << "New QuestHint {" << this->getId() << "} created." << std::endl;
    7178    }
     
    7481    /**
    7582    @brief
    76         Checks whether the hint is active for a specific player.
     83        Checks whether the QuestHint is active for a specific player.
    7784    @param player
    7885        The player.
     
    8087        Throws an Argument Exception if the input Player-pointer is NULL.
    8188    @return
    82         Returns true if the hint is active for the specified player.
     89        Returns true if the QuestHint is active for the specified player.
    8390    */
    84     bool QuestHint::isActive(Player* player)
     91    bool QuestHint::isActive(const PlayerInfo* player) const
    8592    {
    86         if(player == NULL)
     93        if(player == NULL) //!< NULL-Pointers are ugly!
    8794        {
    88             ThrowException(Argument, "The input Player* is NULL.");
     95            ThrowException(Argument, "The input PlayerInfo* is NULL.");
    8996            return false;
    9097        }
    9198
    92         std::map<Player*, questHintStatus::Enum>::iterator it = this->playerStatus_.find(player);
    93         if (it != this->playerStatus_.end())
     99        //! Find the player.
     100        std::map<const PlayerInfo*, questHintStatus::Enum>::const_iterator it = this->playerStatus_.find(player);
     101        if (it != this->playerStatus_.end()) //!< If the player is in the map.
    94102        {
    95103            return it->second;
    96104        }
     105       
    97106        return questStatus::inactive;
    98107    }
     
    106115        Returns true if the activation was successful, false if there were problems.
    107116    */
    108     bool QuestHint::activate(Player* player)
     117    bool QuestHint::setActive(PlayerInfo* player)
    109118    {
    110         if(this->quest_->isActive(player))
     119        if(this->quest_->isActive(player)) //!< For a hint to get activated the quest must be active.
    111120        {
    112             if(!(this->isActive(player)))
     121            if(!(this->isActive(player)))  //!< If the hint is already active, activation is pointless.
    113122            {
    114123                this->playerStatus_[player] = questHintStatus::active;
     
    121130            }
    122131        }
     132       
    123133        COUT(2) << "A hint of a non-active quest was trying to get activated." << std::endl;
    124134        return false;
     
    127137    /**
    128138    @brief
    129         Sets the quest the QuestHitn belongs to.
     139        Sets the Quest the QuestHint belongs to.
    130140    @param quest
     141        The Quest to be set as Quest the QuestHint is attached to.
    131142    @return
     143        Returns true if successful.
    132144    */
    133145    bool QuestHint::setQuest(Quest* quest)
    134146    {
    135         if(quest == NULL)
     147        if(quest == NULL) //!< NULL-Pointer. Again..?
    136148        {
    137149            COUT(2) << "The input Quest* is NULL." << std::endl;
Note: See TracChangeset for help on using the changeset viewer.