Changeset 6940
- Timestamp:
- May 20, 2010, 7:38:53 PM (15 years ago)
- Location:
- code/branches/presentation3/src/modules/questsystem
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation3/src/modules/questsystem/AddQuestHint.cc
r6417 r6940 85 85 bool AddQuestHint::setHintId(const std::string & id) 86 86 { 87 if( !QuestItem::isId(id))87 if(id.compare(BLANKSTRING) == 0) 88 88 { 89 89 COUT(2) << "Invalid id. QuestItem id {" << id << "} could not be set." << std::endl; -
code/branches/presentation3/src/modules/questsystem/ChangeQuestStatus.cc
r6417 r6940 78 78 bool ChangeQuestStatus::setQuestId(const std::string & id) 79 79 { 80 if( !QuestItem::isId(id))80 if(id.compare(BLANKSTRING) == 0) 81 81 { 82 82 COUT(2) << "Invalid id. QuestItem id {" << id << "} could not be set." << std::endl; -
code/branches/presentation3/src/modules/questsystem/Quest.cc
r6417 r6940 61 61 Quest::~Quest() 62 62 { 63 63 if(this->isRegistered()) 64 QuestManager::getInstance().unregisterQuest(this); 64 65 } 65 66 -
code/branches/presentation3/src/modules/questsystem/Quest.h
r5781 r6940 104 104 virtual bool fail(PlayerInfo* player); //!< Fails the Quest. 105 105 virtual bool complete(PlayerInfo* player); //!< Completes the Quest. 106 106 107 107 bool addListener(QuestListener* listener); //!< Adds a QuestListener to the list of QuestListeners listening to this Quest. 108 108 -
code/branches/presentation3/src/modules/questsystem/QuestHint.cc
r6417 r6940 59 59 QuestHint::~QuestHint() 60 60 { 61 61 if(this->isRegistered()) 62 QuestManager::getInstance().unregisterHint(this); 62 63 } 63 64 -
code/branches/presentation3/src/modules/questsystem/QuestItem.cc
r6417 r6940 46 46 QuestItem::QuestItem(BaseObject* creator) : BaseObject(creator) 47 47 { 48 this->registered_ = false; 49 48 50 RegisterObject(QuestItem); 49 51 } … … 79 81 void QuestItem::setId(const std::string & id) 80 82 { 81 if( !isId(id)) //!< Checks whether the id is a valid id.83 if(id.compare(BLANKSTRING) == 0) //!< Checks whether the id is a valid id. 82 84 { 83 85 COUT(2) << "Invalid id. QuestItem id {" << id << "} could not be set." << std::endl; … … 88 90 } 89 91 90 /**91 @brief92 Checks whether an input id is of the required form.93 @param id94 The id to be checked.95 @return96 Returns true if the string is likely to be of the required form.97 */98 /*static*/ bool QuestItem::isId(const std::string & id)99 {100 return id.size() >= 32;101 }102 103 92 } -
code/branches/presentation3/src/modules/questsystem/QuestItem.h
r5781 r6940 41 41 #include <string> 42 42 #include "core/BaseObject.h" 43 #include "QuestManager.h" 43 44 44 45 namespace orxonox … … 74 75 { return this->description_; } 75 76 76 static bool isId(const std::string & id); //!< Checks whether a given id is valid. 77 /** 78 @brief Check whether the QuestItem is registered with the QuestManager. 79 @return Returns true if the QuestItem is registered with the QuestManager. 80 */ 81 inline bool isRegistered(void) 82 { return this->registered_; } 83 /** 84 @brief Set the QuestItem as being registered with the QuestManager. 85 */ 86 inline void setRegistered(void) 87 { this->registered_ = true; } 77 88 78 89 protected: … … 90 101 QuestDescription* description_; //!< The QuestDescription of the QuestItem. 91 102 103 bool registered_; 104 92 105 }; 93 106 -
code/branches/presentation3/src/modules/questsystem/QuestListener.cc
r6417 r6940 74 74 XMLPortParam(QuestListener, "mode", setMode, getMode, xmlelement, mode); 75 75 76 this->quest_->addListener(this); //!< Adds the QuestListener to the Quests list of listeners. 76 if(this->quest_ != NULL) 77 this->quest_->addListener(this); //!< Adds the QuestListener to the Quests list of listeners. 77 78 78 79 COUT(3) << "QuestListener created for quest: {" << this->quest_->getId() << "} with mode '" << this->getMode() << "'." << std::endl; -
code/branches/presentation3/src/modules/questsystem/QuestManager.cc
r6536 r6940 114 114 if(result.second) //!< If inserting was a success. 115 115 { 116 quest->setRegistered(); 116 117 COUT(3) << "Quest with questId {" << quest->getId() << "} successfully inserted." << std::endl; 117 118 return true; … … 122 123 return false; 123 124 } 125 } 126 127 /** 128 @brief 129 Unregisters a Quest in the QuestManager. 130 */ 131 bool QuestManager::unregisterQuest(Quest* quest) 132 { 133 return this->questMap_.erase(quest->getId()) == 1; 124 134 } 125 135 … … 146 156 if(result.second) //!< If inserting was a success. 147 157 { 158 hint->setRegistered(); 148 159 COUT(3) << "QuestHint with hintId {" << hint->getId() << "} successfully inserted." << std::endl; 149 160 return true; … … 154 165 return false; 155 166 } 167 } 168 169 /** 170 @brief 171 Unregisters a QuestHint in the QuestManager. 172 */ 173 bool QuestManager::unregisterHint(QuestHint* hint) 174 { 175 return this->hintMap_.erase(hint->getId()) == 1; 156 176 } 157 177 … … 169 189 Quest* QuestManager::findQuest(const std::string & questId) 170 190 { 171 if( !QuestItem::isId(questId)) //!< Check vor validity of the given id.191 if(questId.compare(BLANKSTRING) == 1) //!< Check vor validity of the given id. 172 192 { 173 193 ThrowException(Argument, "Invalid questId."); … … 203 223 QuestHint* QuestManager::findHint(const std::string & hintId) 204 224 { 205 if( !QuestItem::isId(hintId)) //!< Check vor validity of the given id.225 if(hintId.compare(BLANKSTRING) == 1) //!< Check vor validity of the given id. 206 226 { 207 227 ThrowException(Argument, "Invalid hintId."); -
code/branches/presentation3/src/modules/questsystem/QuestManager.h
r6536 r6940 76 76 77 77 bool registerQuest(Quest* quest); //!< Registers a Quest in the QuestManager. 78 bool registerHint(QuestHint* quest); //!< Registers a QuestHint in the QuestManager. 78 bool unregisterQuest(Quest* quest); //!< Unregisters a Quest in the QuestManager. 79 bool registerHint(QuestHint* hint); //!< Registers a QuestHint in the QuestManager. 80 bool unregisterHint(QuestHint* hint); //!< Unregisters a QuestHint in the QuestManager. 79 81 80 82 Quest* findQuest(const std::string & questId); //!< Returns the Quest with the input id.
Note: See TracChangeset
for help on using the changeset viewer.