Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 30, 2008, 9:52:12 AM (16 years ago)
Author:
dafrick
Message:

Started with XMLPort…

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/questsystem/src/orxonox/objects/QuestHint.cc

    r2021 r2068  
    2828
    2929#include "core/CoreIncludes.h"
     30#include "util/Exception.h"
    3031
    3132#include "Quest.h"
     
    3637    CreateFactory(QuestHint);
    3738
     39    /**
     40    @brief
     41        Constructor.
     42    */
    3843    QuestHint::QuestHint() : QuestItem()
    3944    {
    40        
     45        this->initialize();
    4146    }
    4247
     
    5156        The description of the hint, resp. the hint itself.
    5257    */
    53     QuestHint::QuestHint(std::string id, std::string title, std::string description) : QuestItem(id, title, description)
     58    QuestHint::QuestHint(std::string id) : QuestItem(id)
    5459    {
    55         RegisterObject(QuestHint);
     60        this->initialize();
    5661    }
    5762   
     
    6570    }
    6671   
     72    void QuestHint::initialize(void)
     73    {
     74        RegisterObject(QuestHint);
     75    }
     76   
     77    void QuestHint::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     78    {
     79        SUPER(QuestHint, XMLPort, xmlelement, mode);
     80    }
     81
     82   
    6783    /**
    6884    @brief
     
    7086    @param player
    7187        The player.
     88    @throws
     89        Throws an Argument Exception if the input Player-pointer is NULL.
    7290    @return
    73         Returns
     91        Returns true if the hint is active for the specified player.
    7492    */
    7593    bool QuestHint::isActive(Player* player)
    7694    {
     95        if(player == NULL)
     96        {
     97            ThrowException(Argument, "The input Player* is NULL.");
     98            return false;
     99        }
     100       
    77101        std::map<Player*, questHintStatus::Enum>::iterator it = this->playerStatus_.find(player);
    78102        if (it != this->playerStatus_.end())
     
    85109    /**
    86110    @brief
     111        Activates a QuestHint for a given player.
    87112    @param player
     113        The player.
    88114    @return
     115        Returns true if the activation was successful, false if there were problems.
    89116    */
    90117    bool QuestHint::activate(Player* player)
    91118    {
    92         if(this->quest_->isActive(player) && !(this->isActive(player)))
     119        if(this->quest_->isActive(player))
    93120        {
    94             this->playerStatus_[player] = questHintStatus::active;
    95             return true;
     121            if(!(this->isActive(player)))
     122            {
     123                this->playerStatus_[player] = questHintStatus::active;
     124                return true;
     125            }
     126            else
     127            {
     128                COUT(2) << "An already active questHint was trying to get activated." << std::endl;
     129                return false;
     130            }
    96131        }
    97132        COUT(2) << "A hint of a non-active quest was trying to get activated." << std::endl;
     
    101136    /**
    102137    @brief
     138        Sets the quest the QuestHitn belongs to.
    103139    @param quest
    104140    @return
    105141    */
    106     void QuestHint::setQuest(Quest* quest)
     142    bool QuestHint::setQuest(Quest* quest)
    107143    {
     144        if(quest == NULL)
     145        {
     146            COUT(2) << "The input Quest* is NULL." << std::endl;
     147            return false;
     148        }
     149       
    108150        this->quest_ = quest;
     151        return true;
    109152    }
    110153
Note: See TracChangeset for help on using the changeset viewer.