Changeset 7456 for code/trunk/src/modules/questsystem/QuestManager.cc
- Timestamp:
- Sep 15, 2010, 7:29:16 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/modules/questsystem/QuestManager.cc
r7284 r7456 28 28 29 29 /** 30 @file 30 @file QuestManager.cc 31 31 @brief Implementation of the QuestManager class. 32 32 */ … … 34 34 #include "QuestManager.h" 35 35 36 #include <CEGUIWindow.h>37 38 36 #include "util/Exception.h" 39 37 #include "util/ScopedSingletonManager.h" 38 #include "core/command/ConsoleCommand.h" 40 39 #include "core/CoreIncludes.h" 41 40 #include "core/GUIManager.h" 42 41 #include "core/LuaState.h" 43 #include "core/command/ConsoleCommand.h" 42 44 43 #include "infos/PlayerInfo.h" 45 #include "overlays/GUIOverlay.h" 46 47 #include "ToluaBindQuestsystem.h" 44 48 45 #include "Quest.h" 49 46 #include "QuestHint.h" 50 47 #include "QuestItem.h" 48 49 #include "ToluaBindQuestsystem.h" 51 50 52 51 namespace orxonox … … 66 65 { 67 66 RegisterRootObject(QuestManager); 67 68 COUT(3) << "QuestManager created." << std::endl; 68 69 } 69 70 … … 74 75 QuestManager::~QuestManager() 75 76 { 76 77 COUT(3) << "QuestManager destroyed." << std::endl; 77 78 } 78 79 … … 99 100 bool QuestManager::registerQuest(Quest* quest) 100 101 { 101 if(quest == NULL) //!< Doh! Just as if there were actual quests behind NULL-pointers. 102 //TODO: Replace with assert. 103 if(quest == NULL) // Doh! Just as if there were actual quests behind NULL-pointers. 102 104 { 103 105 COUT(2) << "Registration of Quest in QuestManager failed, because inserted Quest-pointer was NULL." << std::endl; … … 106 108 107 109 std::pair<std::map<std::string, Quest*>::iterator,bool> result; 108 result = this->questMap_.insert( std::pair<std::string,Quest*>(quest->getId(),quest) ); // !<Inserting the Quest.109 110 if(result.second) // !<If inserting was a success.110 result = this->questMap_.insert( std::pair<std::string,Quest*>(quest->getId(),quest) ); // Inserting the Quest. 111 112 if(result.second) // If inserting was a success. 111 113 { 112 114 quest->setRegistered(); … … 141 143 bool QuestManager::registerHint(QuestHint* hint) 142 144 { 143 if(hint == NULL) //!< Still not liking NULL-pointers. 145 //TODO: Replace with assert. 146 if(hint == NULL) // Still not liking NULL-pointers. 144 147 { 145 148 COUT(2) << "Registration of QuestHint in QuestManager failed, because inserted QuestHint-pointer was NULL." << std::endl; … … 148 151 149 152 std::pair<std::map<std::string, QuestHint*>::iterator,bool> result; 150 result = this->hintMap_.insert ( std::pair<std::string,QuestHint*>(hint->getId(),hint) ); // !<Inserting the QuestHSint.151 152 if(result.second) // !<If inserting was a success.153 result = this->hintMap_.insert ( std::pair<std::string,QuestHint*>(hint->getId(),hint) ); // Inserting the QuestHSint. 154 155 if(result.second) // If inserting was a success. 153 156 { 154 157 hint->setRegistered(); … … 185 188 Quest* QuestManager::findQuest(const std::string & questId) 186 189 { 187 if(questId.compare(BLANKSTRING) == 1) //!< Check vor validity of the given id. 188 { 190 if(questId.compare(BLANKSTRING) == 1) // Check vor validity of the given id. 189 191 ThrowException(Argument, "Invalid questId."); 190 }191 192 192 193 Quest* quest; 193 194 std::map<std::string, Quest*>::iterator it = this->questMap_.find(questId); 194 if (it != this->questMap_.end()) //!< If the Quest is registered. 195 { 195 if (it != this->questMap_.end()) // If the Quest is registered. 196 196 quest = it->second; 197 }198 197 else 199 198 { … … 203 202 204 203 return quest; 205 206 204 } 207 205 … … 219 217 QuestHint* QuestManager::findHint(const std::string & hintId) 220 218 { 221 if(hintId.compare(BLANKSTRING) == 1) //!< Check vor validity of the given id. 222 { 219 if(hintId.compare(BLANKSTRING) == 1) // Check vor validity of the given id. 223 220 ThrowException(Argument, "Invalid hintId."); 224 }225 221 226 222 QuestHint* hint; 227 223 std::map<std::string, QuestHint*>::iterator it = this->hintMap_.find(hintId); 228 if (it != this->hintMap_.end()) //!< If the QuestHint is registered. 229 { 224 if (it != this->hintMap_.end()) // If the QuestHint is registered. 230 225 hint = it->second; 231 }232 226 else 233 227 { … … 237 231 238 232 return hint; 239 240 } 241 242 int QuestManager::getNumParentQuests(PlayerInfo* player) 233 } 234 235 /** 236 @brief 237 Get the number of Quests the input player has, that are root quests. 238 @param player 239 The player. 240 @return 241 Returns the number of Quests the input player has, that are root quests. 242 */ 243 int QuestManager::getNumRootQuests(PlayerInfo* player) 243 244 { 244 245 int numQuests = 0; … … 251 252 } 252 253 253 Quest* QuestManager::getParentQuest(PlayerInfo* player, int index) 254 /** 255 @brief 256 Get the index-th root quest of the input player. 257 @param player 258 The player. 259 @param index 260 The index of the root quest. 261 @return 262 Returns the index-th root quest of the input player. 263 */ 264 Quest* QuestManager::getRootQuest(PlayerInfo* player, int index) 254 265 { 255 266 for(std::map<std::string, Quest*>::iterator it = this->questMap_.begin(); it != this->questMap_.end(); it++) … … 261 272 } 262 273 274 /** 275 @brief 276 Get the number of sub-quest of an input Quest for the input player. 277 @param quest 278 The quest to get the sub-quests of. 279 @param player 280 The player. 281 @return 282 Returns the number of sub-quest of an input Quest for the input player. 283 */ 263 284 int QuestManager::getNumSubQuests(Quest* quest, PlayerInfo* player) 264 285 { … … 273 294 } 274 295 296 /** 297 @brief 298 Get the index-th sub-quest of the input Quest for the input player. 299 @param quest 300 The Quest to get the sub-quest of. 301 @param player 302 The player. 303 @param index 304 The index of the sub-quest. 305 */ 275 306 Quest* QuestManager::getSubQuest(Quest* quest, PlayerInfo* player, int index) 276 307 { … … 284 315 } 285 316 317 /** 318 @brief 319 Get the number of QuestHints of the input Quest for the input player. 320 @param quest 321 The quest to get the hints of. 322 @param player 323 The player. 324 @return Returns the number of QuestHints of the input Quest for the input player. 325 */ 286 326 int QuestManager::getNumHints(Quest* quest, PlayerInfo* player) 287 327 { … … 296 336 } 297 337 338 /** 339 @brief 340 Get the index-th QuestHint of the input Quest for the input player. 341 @param quest 342 The Quest to get the QuestHint of. 343 @param player 344 The player. 345 @param index 346 The index of the QuestHint. 347 */ 298 348 QuestHint* QuestManager::getHints(Quest* quest, PlayerInfo* player, int index) 299 349 { … … 307 357 } 308 358 359 /** 360 @brief 361 Get the QuestDescription of the input Quest. 362 @param item 363 The Quest to get the QuestDescription of. 364 @return 365 Return a pointer ot the QuestDescription of the input Quest. 366 */ 309 367 QuestDescription* QuestManager::getDescription(Quest* item) 310 368 { … … 312 370 } 313 371 372 /** 373 @brief 374 Get the QuestDescription of the input QuestHint. 375 @param item 376 The QuestHint to get the QuestDescription of. 377 @return 378 Returns a pointer to the QuestDescription of the input QuestHint. 379 */ 314 380 QuestDescription* QuestManager::getDescription(QuestHint* item) 315 381 {
Note: See TracChangeset
for help on using the changeset viewer.