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/QuestManager.cc

    r2105 r2261  
    2727 */
    2828
     29/**
     30    @file QuestManager.cc
     31    @brief
     32    Implementation of the QuestManager class.
     33*/
     34
    2935#include "OrxonoxStableHeaders.h"
    3036#include "QuestManager.h"
     
    3844namespace orxonox {
    3945
    40     std::map<std::string, Quest*> QuestManager::questMap_;
    41     std::map<std::string, QuestHint*> QuestManager::hintMap_;
    42 
     46    //! All Quests registered by their id's.
     47    std::map<std::string, Quest*> QuestManager::questMap_s;
     48    //! All QuestHints registered by their id's.
     49    std::map<std::string, QuestHint*> QuestManager::hintMap_s;
     50
     51    /**
     52    @brief
     53        Constructor. Registers the object.
     54    */
    4355    QuestManager::QuestManager(BaseObject* creator) : BaseObject(creator)
    4456    {
     
    4658    }
    4759
    48 
     60    /**
     61    @brief
     62        Destructor.
     63    */
    4964    QuestManager::~QuestManager()
    5065    {
     
    5469    /**
    5570    @brief
    56         Registers a quest with the QuestManager to make it globally accessable.
     71        Registers a Quest with the QuestManager to make it globally accessable.
     72        Uses it's id to make sure to be able to be identify and retrieve it later.
    5773    @param quest
    58         The quest that is to be registered.
     74        The Quest that is to be registered.
    5975    @return
    6076        Returns true if successful, false if not.
     
    6278    bool QuestManager::registerQuest(Quest* quest)
    6379    {
    64         if(quest == NULL)
     80        if(quest == NULL) //!< Doh! Just as if there were actual quests behind NULL-pointers.
    6581        {
    6682            COUT(2) << "Registration of Quest in QuestManager failed, because inserted Quest-pointer was NULL." << std::endl;
     
    6884        }
    6985
    70         std::pair<std::map<std::string, Quest*>::iterator,bool> ret;
    71         ret = questMap_.insert( std::pair<std::string,Quest*>(quest->getId(),quest) );
    72 
    73         if(ret.second)
     86        std::pair<std::map<std::string, Quest*>::iterator,bool> result;
     87        result = questMap_s.insert( std::pair<std::string,Quest*>(quest->getId(),quest) ); //!< Inserting the Quest.
     88
     89        if(result.second) //!< If inserting was a success.
    7490        {
    7591            COUT(3) << "Quest with questId {" << quest->getId() << "} successfully inserted." << std::endl;
     
    86102    @brief
    87103        Registers a QuestHint with the QuestManager to make it globally accessable.
     104        Uses it's id to make sure to be able to be identify and retrieve it later.
    88105    @param hint
    89106        The QuestHint to be registered.
     
    93110    bool QuestManager::registerHint(QuestHint* hint)
    94111    {
    95         if(hint == NULL)
     112        if(hint == NULL) //!< Still not liking NULL-pointers.
    96113        {
    97114            COUT(2) << "Registration of QuestHint in QuestManager failed, because inserted QuestHint-pointer was NULL." << std::endl;
     
    99116        }
    100117
    101         std::pair<std::map<std::string, QuestHint*>::iterator,bool> ret;
    102         ret = hintMap_.insert ( std::pair<std::string,QuestHint*>(hint->getId(),hint) );
    103 
    104         if(ret.second)
     118        std::pair<std::map<std::string, QuestHint*>::iterator,bool> result;
     119        result = hintMap_s.insert ( std::pair<std::string,QuestHint*>(hint->getId(),hint) ); //!< Inserting the QuestHSint.
     120
     121        if(result.second) //!< If inserting was a success.
    105122        {
    106123            COUT(3) << "QuestHint with hintId {" << hint->getId() << "} successfully inserted." << std::endl;
     
    116133    /**
    117134    @brief
    118         Finds a quest with the given id.
     135        Finds a Quest with the given id.
    119136    @param questId
    120         The id of the quest sought for.
    121     @return
    122         Returns a reference to the quest with the input id.
    123         Returns NULL if there is no quest with the given questId.
     137        The id of the Quest sought for.
     138    @return
     139        Returns a pointer to the Quest with the input id.
     140        Returns NULL if there is no Quest with the given questId.
    124141    @throws
    125142        Throws an exception if the given questId is invalid.
     
    127144    Quest* QuestManager::findQuest(const std::string & questId)
    128145    {
    129         if(!QuestItem::isId(questId))
     146        if(!QuestItem::isId(questId)) //!< Check vor validity of the given id.
    130147        {
    131148            ThrowException(Argument, "Invalid questId.");
     
    133150
    134151        Quest* quest;
    135         std::map<std::string, Quest*>::iterator it = questMap_.find(questId);
    136         if (it != questMap_.end())
     152        std::map<std::string, Quest*>::iterator it = questMap_s.find(questId);
     153        if (it != questMap_s.end()) //!< If the Quest is registered.
    137154        {
    138155            quest = it->second;
     
    150167    /**
    151168    @brief
    152         Finds a hint with the given id.
     169        Finds a QuestHint with the given id.
    153170    @param hintId
    154         The id of the hint sought for.
    155     @return
    156         Returns a reference to the hint with the input id.
    157         Returns NULL if there is no hint with the given hintId.
     171        The id of the QuestHint sought for.
     172    @return
     173        Returns a pointer to the QuestHint with the input id.
     174        Returns NULL if there is no QuestHint with the given hintId.
    158175    @throws
    159176        Throws an exception if the given hintId is invalid.
     
    161178    QuestHint* QuestManager::findHint(const std::string & hintId)
    162179    {
    163         if(!QuestItem::isId(hintId))
     180        if(!QuestItem::isId(hintId)) //!< Check vor validity of the given id.
    164181        {
    165182            ThrowException(Argument, "Invalid hintId.");
     
    167184
    168185        QuestHint* hint;
    169         std::map<std::string, QuestHint*>::iterator it = hintMap_.find(hintId);
    170         if (it != hintMap_.end())
     186        std::map<std::string, QuestHint*>::iterator it = hintMap_s.find(hintId);
     187        if (it != hintMap_s.end()) //!< If the QuestHint is registered.
    171188        {
    172189            hint = it->second;
Note: See TracChangeset for help on using the changeset viewer.