Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 8, 2009, 1:07:27 AM (15 years ago)
Author:
dafrick
Message:

Merging the QuestSystem branch to the trunk. Let's hope, this isn't a 'third time's the charm'-thing…

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/orxonox/objects/quest/QuestManager.cc

    r2896 r2909  
    2828
    2929/**
    30     @file
     30    @file QuestManager.cc
    3131    @brief Implementation of the QuestManager class.
    3232*/
     
    4343namespace orxonox
    4444{
    45     //! All Quests registered by their id's.
    46     std::map<std::string, Quest*> QuestManager::questMap_s;
    47     //! All QuestHints registered by their id's.
    48     std::map<std::string, QuestHint*> QuestManager::hintMap_s;
     45    //! Pointer to the current (and single) instance of this class.
     46    QuestManager* QuestManager::singletonRef_s = NULL;
    4947
    5048    /**
    5149    @brief
    5250        Constructor. Registers the object.
    53     */
    54     QuestManager::QuestManager(BaseObject* creator) : BaseObject(creator)
    55     {
    56         RegisterObject(QuestManager);
     51    @todo
     52        Is inheriting from BaseObject proper?
     53    */
     54    QuestManager::QuestManager()
     55    {
     56        RegisterRootObject(QuestManager);
     57
     58        assert(singletonRef_s == 0);
     59        singletonRef_s = this;
    5760    }
    5861
     
    6467    {
    6568
     69    }
     70
     71    /**
     72    @brief
     73        Returns a reference to the current (and single) instance of the QuestManager, and creates one if there isn't one to begin with.
     74    @return
     75        Returns a reference to the single instance of the Quest Manager.
     76    */
     77    /*static*/ QuestManager & QuestManager::getInstance()
     78    {
     79        assert(singletonRef_s);
     80        return *singletonRef_s;
    6681    }
    6782
     
    7590        Returns true if successful, false if not.
    7691    */
    77     /*static*/ bool QuestManager::registerQuest(Quest* quest)
     92    bool QuestManager::registerQuest(Quest* quest)
    7893    {
    7994        if(quest == NULL) //!< Doh! Just as if there were actual quests behind NULL-pointers.
     
    8499
    85100        std::pair<std::map<std::string, Quest*>::iterator,bool> result;
    86         result = questMap_s.insert( std::pair<std::string,Quest*>(quest->getId(),quest) ); //!< Inserting the Quest.
     101        result = this->questMap_.insert( std::pair<std::string,Quest*>(quest->getId(),quest) ); //!< Inserting the Quest.
    87102
    88103        if(result.second) //!< If inserting was a success.
     
    107122        Returns true if successful, false if not.
    108123    */
    109     /*static*/ bool QuestManager::registerHint(QuestHint* hint)
     124    bool QuestManager::registerHint(QuestHint* hint)
    110125    {
    111126        if(hint == NULL) //!< Still not liking NULL-pointers.
     
    116131
    117132        std::pair<std::map<std::string, QuestHint*>::iterator,bool> result;
    118         result = hintMap_s.insert ( std::pair<std::string,QuestHint*>(hint->getId(),hint) ); //!< Inserting the QuestHSint.
     133        result = this->hintMap_.insert ( std::pair<std::string,QuestHint*>(hint->getId(),hint) ); //!< Inserting the QuestHSint.
    119134
    120135        if(result.second) //!< If inserting was a success.
     
    141156        Throws an exception if the given questId is invalid.
    142157    */
    143     /*static*/ Quest* QuestManager::findQuest(const std::string & questId)
     158    Quest* QuestManager::findQuest(const std::string & questId)
    144159    {
    145160        if(!QuestItem::isId(questId)) //!< Check vor validity of the given id.
     
    149164
    150165        Quest* quest;
    151         std::map<std::string, Quest*>::iterator it = questMap_s.find(questId);
    152         if (it != questMap_s.end()) //!< If the Quest is registered.
     166        std::map<std::string, Quest*>::iterator it = this->questMap_.find(questId);
     167        if (it != this->questMap_.end()) //!< If the Quest is registered.
    153168        {
    154169            quest = it->second;
     
    175190        Throws an exception if the given hintId is invalid.
    176191    */
    177     /*static*/ QuestHint* QuestManager::findHint(const std::string & hintId)
     192    QuestHint* QuestManager::findHint(const std::string & hintId)
    178193    {
    179194        if(!QuestItem::isId(hintId)) //!< Check vor validity of the given id.
     
    183198
    184199        QuestHint* hint;
    185         std::map<std::string, QuestHint*>::iterator it = hintMap_s.find(hintId);
    186         if (it != hintMap_s.end()) //!< If the QuestHint is registered.
     200        std::map<std::string, QuestHint*>::iterator it = this->hintMap_.find(hintId);
     201        if (it != this->hintMap_.end()) //!< If the QuestHint is registered.
    187202        {
    188203            hint = it->second;
Note: See TracChangeset for help on using the changeset viewer.