Changeset 7456 for code/trunk/src/modules/questsystem/Quest.cc
- Timestamp:
- Sep 15, 2010, 7:29:16 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/modules/questsystem/Quest.cc
r7403 r7456 28 28 29 29 /** 30 @file 30 @file Quest.cc 31 31 @brief Implementation of the Quest class. 32 32 */ … … 36 36 #include "core/CoreIncludes.h" 37 37 #include "core/XMLPort.h" 38 39 #include "QuestDescription.h" 40 #include "QuestEffect.h" 41 #include "QuestHint.h" 42 #include "QuestListener.h" 38 43 #include "QuestManager.h" 39 #include "QuestDescription.h"40 #include "QuestHint.h"41 #include "QuestEffect.h"42 #include "QuestListener.h"43 44 44 45 namespace orxonox … … 78 79 XMLPortObject(Quest, QuestEffect, "complete-effects", addCompleteEffect, getCompleteEffect, xmlelement, mode); 79 80 80 QuestManager::getInstance().registerQuest(this); // !<Registers the Quest with the QuestManager.81 } 82 83 /** 84 @brief 85 Sets the parent quest of the Quest.81 QuestManager::getInstance().registerQuest(this); // Registers the Quest with the QuestManager. 82 } 83 84 /** 85 @brief 86 Sets the parent-quest of the Quest. 86 87 @param quest 87 A pointer to the Quest to be set as parent quest.88 @return 89 Returns true if the parent quest could be set.88 A pointer to the Quest to be set as parent-quest. 89 @return 90 Returns true if the parent-quest could be set. 90 91 */ 91 92 bool Quest::setParentQuest(Quest* quest) 92 93 { 93 if(quest == NULL) //!< We don't want to set NULL-Pointers. 94 //TODO: Replace with assert. 95 if(quest == NULL) // We don't want to set NULL-Pointers. 94 96 { 95 97 COUT(2) << "The parentquest to be added to quest {" << this->getId() << "} was NULL." << std::endl; … … 105 107 /** 106 108 @brief 107 Adds a sub quest to the Quest.109 Adds a sub-quest to the Quest. 108 110 @param quest 109 A pointer to the Quest to be set as sub quest.110 @return 111 Returns true if the sub quest could be set.111 A pointer to the Quest to be set as sub-quest. 112 @return 113 Returns true if the sub-quest could be set. 112 114 */ 113 115 bool Quest::addSubQuest(Quest* quest) 114 116 { 115 if(quest == NULL) //!< We don't want to set NULL-Pointers. 117 //TODO: Replace with assert. 118 if(quest == NULL) // We don't want to set NULL-Pointers. 116 119 { 117 120 COUT(2) << "The subquest to be added to quest {" << this->getId() << "} was NULL." << std::endl; … … 119 122 } 120 123 121 quest->setParentQuest(this); // !< Sets the currentQuest (this) as parentquest for the added subquest.122 this->subQuests_.push_back(quest); // !< Adds the Quest to the end of the list of subquests.124 quest->setParentQuest(this); // Sets the currentQuest (this) as parent-quest for the added sub-quest. 125 this->subQuests_.push_back(quest); // Adds the Quest to the end of the list of sub-quests. 123 126 124 127 COUT(4) << "Sub Quest {" << quest->getId() << "} was added to Quest {" << this->getId() << "}." << std::endl; … … 137 140 bool Quest::addHint(QuestHint* hint) 138 141 { 139 if(hint == NULL) //!< We don't want to set NULL-Pointers. Seriously! 142 //TODO: Replace with assert. 143 if(hint == NULL) // We don't want to set NULL-Pointers. Seriously! 140 144 { 141 145 COUT(2) << "A NULL-QuestHint was trying to be added." << std::endl; … … 143 147 } 144 148 145 hint->setQuest(this); // !<Sets the current Quest (this) as Quest for the added QuestHint.146 this->hints_.push_back(hint); // !<Adds the QuestHint to the end of the list of QuestHints.149 hint->setQuest(this); // Sets the current Quest (this) as Quest for the added QuestHint. 150 this->hints_.push_back(hint); // Adds the QuestHint to the end of the list of QuestHints. 147 151 148 152 COUT(4) << "QuestHint {" << hint->getId() << "} was added to Quest {" << this->getId() << "}." << std::endl; … … 160 164 bool Quest::addFailEffect(QuestEffect* effect) 161 165 { 162 if(effect == NULL) //!< We don't want to set NULL-Pointers. 166 //TODO: Replace with assert. 167 if(effect == NULL) // We don't want to set NULL-Pointers. 163 168 { 164 169 COUT(2) << "A NULL-QuestEffect was trying to be added" << std::endl; … … 166 171 } 167 172 168 this->failEffects_.push_back(effect); // !<Adds the QuestEffect to the end of the list of fail QuestEffects.173 this->failEffects_.push_back(effect); // Adds the QuestEffect to the end of the list of fail QuestEffects. 169 174 170 175 COUT(4) << "A FailEffect was added to Quest {" << this->getId() << "}." << std::endl; … … 182 187 bool Quest::addCompleteEffect(QuestEffect* effect) 183 188 { 184 if(effect == NULL) //!< We don't want to set NULL-Pointers. 189 //TODO: Replace with assert. 190 if(effect == NULL) // We don't want to set NULL-Pointers. 185 191 { 186 192 COUT(2) << "A NULL-QuestEffect was trying to be added" << std::endl; … … 188 194 } 189 195 190 this->completeEffects_.push_back(effect); // !<Adds the QuestEffect to the end of the list of complete QuestEffects.196 this->completeEffects_.push_back(effect); // Adds the QuestEffect to the end of the list of complete QuestEffects. 191 197 192 198 COUT(4) << "A CompleteEffect was added to Quest {" << this->getId() << "}." << std::endl; … … 196 202 /** 197 203 @brief 198 Returns the sub quest at the given index.204 Returns the sub-quest at the given index. 199 205 @param index 200 206 The index. 201 207 @return 202 Returns a pointer to the sub quest at the given index. NULL if there is no element at the given index.208 Returns a pointer to the sub-quest at the given index. NULL if there is no element at the given index. 203 209 */ 204 210 const Quest* Quest::getSubQuest(unsigned int index) const … … 206 212 int i = index; 207 213 208 // !Iterate through all subquests.214 // Iterate through all subquests. 209 215 for (std::list<Quest*>::const_iterator subQuest = this->subQuests_.begin(); subQuest != this->subQuests_.end(); ++subQuest) 210 216 { 211 if(i == 0) //!< We're counting down... 212 { 217 if(i == 0) // We're counting down... 213 218 return *subQuest; 214 } 219 215 220 i--; 216 221 } 217 222 218 return NULL; // !<If the index is greater than the number of elements in the list.223 return NULL; // If the index is greater than the number of elements in the list. 219 224 } 220 225 … … 231 236 int i = index; 232 237 233 // !Iterate through all QuestHints.238 // Iterate through all QuestHints. 234 239 for (std::list<QuestHint*>::const_iterator hint = this->hints_.begin(); hint != this->hints_.end(); ++hint) 235 240 { 236 if(i == 0) //!< We're counting down... 237 { 241 if(i == 0) // We're counting down... 238 242 return *hint; 239 } 243 240 244 i--; 241 245 } 242 return NULL; // !<If the index is greater than the number of elements in the list.246 return NULL; // If the index is greater than the number of elements in the list. 243 247 } 244 248 … … 255 259 int i = index; 256 260 257 // !Iterate through all fail QuestEffects.261 // Iterate through all fail QuestEffects. 258 262 for (std::list<QuestEffect*>::const_iterator effect = this->failEffects_.begin(); effect != this->failEffects_.end(); ++effect) 259 263 { 260 if(i == 0) //!< We're counting down... 261 { 264 if(i == 0) // We're counting down... 262 265 return *effect; 263 } 266 264 267 i--; 265 268 } 266 return NULL; // !<If the index is greater than the number of elements in the list.269 return NULL; // If the index is greater than the number of elements in the list. 267 270 } 268 271 … … 279 282 int i = index; 280 283 281 // !Iterate through all complete QuestEffects.284 // Iterate through all complete QuestEffects. 282 285 for (std::list<QuestEffect*>::const_iterator effect = this->completeEffects_.begin(); effect != this->completeEffects_.end(); ++effect) 283 286 { 284 if(i == 0) //!< We're counting down... 285 { 287 if(i == 0) // We're counting down... 286 288 return *effect; 287 } 289 288 290 i--; 289 291 } 290 return NULL; // !<If the index is greater than the number of elements in the list.292 return NULL; // If the index is greater than the number of elements in the list. 291 293 } 292 294 … … 318 320 bool Quest::isActive(const PlayerInfo* player) const 319 321 { 320 321 322 return this->getStatus(player) == QuestStatus::Active; 322 323 } … … 362 363 bool Quest::fail(PlayerInfo* player) 363 364 { 364 QuestListener::advertiseStatusChange(this->listeners_, "fail"); // !<Tells the QuestListeners, that the status has changed to failed.365 QuestListener::advertiseStatusChange(this->listeners_, "fail"); // Tells the QuestListeners, that the status has changed to failed. 365 366 this->setStatus(player, QuestStatus::Failed); 366 367 … … 381 382 bool Quest::complete(PlayerInfo* player) 382 383 { 383 QuestListener::advertiseStatusChange(this->listeners_, "complete"); // !<Tells the QuestListeners, that the status has changed to completed.384 QuestListener::advertiseStatusChange(this->listeners_, "complete"); // Tells the QuestListeners, that the status has changed to completed. 384 385 this->setStatus(player, QuestStatus::Completed); 385 386 … … 400 401 bool Quest::start(PlayerInfo* player) 401 402 { 402 if(!this->isStartable(player)) // !<Checks whether the quest can be started.403 if(!this->isStartable(player)) // Checks whether the quest can be started. 403 404 { 404 405 COUT(4) << "A non-startable quest was trying to be started." << std::endl; … … 408 409 COUT(4) << "Quest {" << this->getId() << "} is started for player: " << player << " ." <<std::endl; 409 410 410 QuestListener::advertiseStatusChange(this->listeners_, "start"); // !<Tells the QuestListeners, that the status has changed to active.411 QuestListener::advertiseStatusChange(this->listeners_, "start"); // Tells the QuestListeners, that the status has changed to active. 411 412 412 413 this->setStatus(player, QuestStatus::Active); … … 426 427 bool Quest::addListener(QuestListener* listener) 427 428 { 429 //TODO: Replace with assert? 428 430 if(listener == NULL) 429 431 {
Note: See TracChangeset
for help on using the changeset viewer.