Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 17, 2016, 10:29:21 PM (8 years ago)
Author:
landauf
Message:

merged branch cpp11_v3 back to trunk

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/modules/questsystem/QuestManager.cc

    r10624 r11071  
    9393    bool QuestManager::registerQuest(Quest* quest)
    9494    {
    95         if(quest == NULL)
    96         {
    97             orxout(internal_error, context::quests) << "Quest pointer is NULL." << endl;
     95        if(quest == nullptr)
     96        {
     97            orxout(internal_error, context::quests) << "Quest pointer is nullptr." << endl;
    9898            return false;
    9999        }
     
    135135    bool QuestManager::registerHint(QuestHint* hint)
    136136    {
    137         if(hint == NULL)
    138         {
    139             orxout(internal_error, context::quests) << "Quest pointer is NULL." << endl;
     137        if(hint == nullptr)
     138        {
     139            orxout(internal_error, context::quests) << "Quest pointer is nullptr." << endl;
    140140            return false;
    141141        }
     
    173173    @return
    174174        Returns a pointer to the Quest with the input id.
    175         Returns NULL if there is no Quest with the given questId.
     175        Returns nullptr if there is no Quest with the given questId.
    176176    @throws
    177177        Throws an exception if the given questId is invalid.
     
    188188        else
    189189        {
    190            quest = NULL;
     190           quest = nullptr;
    191191           orxout(internal_warning, context::quests) << "The quest with id {" << questId << "} is nowhere to be found." << endl;
    192192        }
     
    202202    @return
    203203        Returns a pointer to the QuestHint with the input id.
    204         Returns NULL if there is no QuestHint with the given hintId.
     204        Returns nullptr if there is no QuestHint with the given hintId.
    205205    @throws
    206206        Throws an exception if the given hintId is invalid.
     
    217217        else
    218218        {
    219            hint = NULL;
     219           hint = nullptr;
    220220           orxout(internal_warning, context::quests) << "The hint with id {" << hintId << "} is nowhere to be found." << endl;
    221221        }
     
    235235    {
    236236        int numQuests = 0;
    237         for(std::map<std::string, Quest*>::iterator it = this->questMap_.begin(); it != this->questMap_.end(); it++)
    238         {
    239             if(it->second->getParentQuest() == NULL && !it->second->isInactive(player))
     237        for(const auto& mapEntry : this->questMap_)
     238        {
     239            if(mapEntry.second->getParentQuest() == nullptr && !mapEntry.second->isInactive(player))
    240240                numQuests++;
    241241        }
     
    255255    Quest* QuestManager::getRootQuest(PlayerInfo* player, int index)
    256256    {
    257         for(std::map<std::string, Quest*>::iterator it = this->questMap_.begin(); it != this->questMap_.end(); it++)
    258         {
    259             if(it->second->getParentQuest() == NULL && !it->second->isInactive(player) && index-- == 0)
    260                 return it->second;
    261         }
    262         return NULL;
     257        for(const auto& mapEntry : this->questMap_)
     258        {
     259            if(mapEntry.second->getParentQuest() == nullptr && !mapEntry.second->isInactive(player) && index-- == 0)
     260                return mapEntry.second;
     261        }
     262        return nullptr;
    263263    }
    264264
     
    275275    int QuestManager::getNumSubQuests(Quest* quest, PlayerInfo* player)
    276276    {
    277         if(quest == NULL)
     277        if(quest == nullptr)
    278278            return this->getNumRootQuests(player);
    279279
    280280        std::list<Quest*> quests = quest->getSubQuestList();
    281281        int numQuests = 0;
    282         for(std::list<Quest*>::iterator it = quests.begin(); it != quests.end(); it++)
    283         {
    284             if(!(*it)->isInactive(player))
     282        for(Quest* subquest : quests)
     283        {
     284            if(!subquest->isInactive(player))
    285285                numQuests++;
    286286        }
     
    300300    Quest* QuestManager::getSubQuest(Quest* quest, PlayerInfo* player, int index)
    301301    {
    302         if(quest == NULL)
     302        if(quest == nullptr)
    303303            return this->getRootQuest(player, index);
    304304
    305305        std::list<Quest*> quests = quest->getSubQuestList();
    306         for(std::list<Quest*>::iterator it = quests.begin(); it != quests.end(); it++)
    307         {
    308             if(!(*it)->isInactive(player) && index-- == 0)
    309                 return *it;
    310         }
    311         return NULL;
     306        for(Quest* subquest : quests)
     307        {
     308            if(!subquest->isInactive(player) && index-- == 0)
     309                return quest;
     310        }
     311        return nullptr;
    312312    }
    313313
     
    326326        std::list<QuestHint*> hints = quest->getHintsList();
    327327        int numHints = 0;
    328         for(std::list<QuestHint*>::iterator it = hints.begin(); it != hints.end(); it++)
    329         {
    330             if((*it)->isActive(player))
     328        for(QuestHint* hint : hints)
     329        {
     330            if(hint->isActive(player))
    331331                numHints++;
    332332        }
     
    349349    {
    350350        std::list<QuestHint*> hints = quest->getHintsList();
    351         for(std::list<QuestHint*>::iterator it = hints.begin(); it != hints.end(); it++)
    352         {
    353             if((*it)->isActive(player) && index-- == 0)
    354                 return *it;
    355         }
    356         return NULL;
     351        for(QuestHint* hint : hints)
     352        {
     353            if(hint->isActive(player) && index-- == 0)
     354                return hint;
     355        }
     356        return nullptr;
    357357    }
    358358
     
    367367    Quest* QuestManager::getParentQuest(Quest* quest)
    368368    {
    369         OrxAssert(quest, "The input Quest is NULL.");
     369        OrxAssert(quest, "The input Quest is nullptr.");
    370370        return quest->getParentQuest();
    371371    }
     
    381381    QuestDescription* QuestManager::getDescription(Quest* item)
    382382    {
    383         OrxAssert(item, "The input Quest is NULL.");
     383        OrxAssert(item, "The input Quest is nullptr.");
    384384        return item->getDescription();
    385385    }
     
    395395    QuestDescription* QuestManager::getDescription(QuestHint* item)
    396396    {
    397         OrxAssert(item, "The input QuestHint is NULL.");
     397        OrxAssert(item, "The input QuestHint is nullptr.");
    398398        return item->getDescription();
    399399    }
     
    409409    const std::string QuestManager::getId(Quest* item) const
    410410    {
    411         OrxAssert(item, "The input Quest is NULL.");
     411        OrxAssert(item, "The input Quest is nullptr.");
    412412        return item->getId();
    413413    }
     
    423423    const std::string QuestManager::getId(QuestHint* item) const
    424424    {
    425         OrxAssert(item, "The input QuestHint is NULL.");
     425        OrxAssert(item, "The input QuestHint is nullptr.");
    426426        return item->getId();
    427427    }
     
    440440    {
    441441        PlayerInfo* player = GUIManager::getInstance().getPlayer(guiName);
    442         if(player == NULL)
     442        if(player == nullptr)
    443443        {
    444444            orxout(internal_error, context::quests) << "GUIOverlay with name '" << guiName << "' has no player." << endl;
    445             return NULL;
     445            return nullptr;
    446446        }
    447447
Note: See TracChangeset for help on using the changeset viewer.