Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10997


Ignore:
Timestamp:
Dec 30, 2015, 12:21:18 PM (9 years ago)
Author:
landauf
Message:

using strongly typed enum class in questsystem.
this also revealed a possible error in QuestHint::isActive (which may have worked so far, but was never guaranteed to do so)

Location:
code/branches/cpp11_v2/src/modules/questsystem
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • code/branches/cpp11_v2/src/modules/questsystem/GlobalQuest.cc

    r10916 r10997  
    177177        The player.
    178178    */
    179     QuestStatus::Value GlobalQuest::getStatus(const PlayerInfo* player) const
     179    QuestStatus GlobalQuest::getStatus(const PlayerInfo* player) const
    180180    {
    181181        assert(player);
     
    200200        Returns false if player is nullptr.
    201201    */
    202     bool GlobalQuest::setStatus(PlayerInfo* player, const QuestStatus::Value & status)
     202    bool GlobalQuest::setStatus(PlayerInfo* player, const QuestStatus & status)
    203203    {
    204204        assert(player);
  • code/branches/cpp11_v2/src/modules/questsystem/GlobalQuest.h

    r10817 r10997  
    103103            virtual bool isCompletable(const PlayerInfo* player) const override; //!< Checks whether the Quest can be completed.
    104104
    105             virtual QuestStatus::Value getStatus(const PlayerInfo* player) const override; //!< Returns the status of the Quest for a specific player.
     105            virtual QuestStatus getStatus(const PlayerInfo* player) const override; //!< Returns the status of the Quest for a specific player.
    106106
    107             virtual bool setStatus(PlayerInfo* player, const QuestStatus::Value & status) override; //!< Sets the status for a specific player.
     107            virtual bool setStatus(PlayerInfo* player, const QuestStatus & status) override; //!< Sets the status for a specific player.
    108108
    109109        private:
    110110            std::set<PlayerInfo*> players_; //!< The set of players which possess this Quest.
    111             QuestStatus::Value status_; //!< The status of this Quest.
     111            QuestStatus status_; //!< The status of this Quest.
    112112            std::list<QuestEffect*> rewards_; //!< Reward QuestEffects only invoked on the player completing the Quest.
    113113
  • code/branches/cpp11_v2/src/modules/questsystem/LocalQuest.cc

    r10765 r10997  
    168168        Returns the status of the Quest for the input player.
    169169    */
    170     QuestStatus::Value LocalQuest::getStatus(const PlayerInfo* player) const
     170    QuestStatus LocalQuest::getStatus(const PlayerInfo* player) const
    171171    {
    172172        assert(player);
    173173
    174         std::map<const PlayerInfo*, QuestStatus::Value>::const_iterator it = this->playerStatus_.find(player);
     174        std::map<const PlayerInfo*, QuestStatus>::const_iterator it = this->playerStatus_.find(player);
    175175        if (it != this->playerStatus_.end()) // If there is a player in the map.
    176176            return it->second;
     
    190190        Returns false if player is nullptr.
    191191    */
    192     bool LocalQuest::setStatus(PlayerInfo* player, const QuestStatus::Value & status)
     192    bool LocalQuest::setStatus(PlayerInfo* player, const QuestStatus & status)
    193193    {
    194194        assert(player);
  • code/branches/cpp11_v2/src/modules/questsystem/LocalQuest.h

    r10817 r10997  
    9797            virtual bool isCompletable(const PlayerInfo* player) const override; //!< Checks whether the Quest can be completed.
    9898
    99             virtual QuestStatus::Value getStatus(const PlayerInfo* player) const override; //!< Returns the status of the Quest for a specific player.
    100             virtual bool setStatus(PlayerInfo* player, const QuestStatus::Value & status) override; //!< Sets the status for a specific player.
     99            virtual QuestStatus getStatus(const PlayerInfo* player) const override; //!< Returns the status of the Quest for a specific player.
     100            virtual bool setStatus(PlayerInfo* player, const QuestStatus & status) override; //!< Sets the status for a specific player.
    101101
    102102        private:
    103             std::map<const PlayerInfo*, QuestStatus::Value> playerStatus_; //!< List of the status for each player, with the Player-pointer as key.
     103            std::map<const PlayerInfo*, QuestStatus> playerStatus_; //!< List of the status for each player, with the Player-pointer as key.
    104104
    105105    };
  • code/branches/cpp11_v2/src/modules/questsystem/Quest.h

    r10817 r10997  
    5151    @ingroup Questsystem
    5252    */
    53     namespace QuestStatus
     53    enum class QuestStatus
    5454    {
    55         enum Value
    56         {
    57             Inactive, //!< The @ref orxonox::Quest "Quest" is inactive.
    58             Active, //!< The @ref orxonox::Quest "Quest" is active.
    59             Failed, //!< The @ref orxonox::Quest "Quest" has been failed.
    60             Completed //!< The @ref orxonox::Quest "Quest" has been completed.
    61         };
    62     }
     55        Inactive, //!< The @ref orxonox::Quest "Quest" is inactive.
     56        Active, //!< The @ref orxonox::Quest "Quest" is active.
     57        Failed, //!< The @ref orxonox::Quest "Quest" has been failed.
     58        Completed //!< The @ref orxonox::Quest "Quest" has been completed.
     59    };
    6360
    6461    /**
     
    143140                { return this->completeEffects_; }
    144141
    145             virtual QuestStatus::Value getStatus(const PlayerInfo* player) const = 0; //!< Returns the status of the Quest for a specific player.
    146             virtual bool setStatus(PlayerInfo* player, const QuestStatus::Value & status) = 0; //!< Changes the status for a specific player.
     142            virtual QuestStatus getStatus(const PlayerInfo* player) const = 0; //!< Returns the status of the Quest for a specific player.
     143            virtual bool setStatus(PlayerInfo* player, const QuestStatus & status) = 0; //!< Changes the status for a specific player.
    147144
    148145        private:
  • code/branches/cpp11_v2/src/modules/questsystem/QuestEffectBeacon.h

    r10817 r10997  
    5050    @ingroup Questsystem
    5151    */
    52     namespace QuestEffectBeaconStatus
     52    enum class QuestEffectBeaconStatus
    5353    {
    54         enum Value
    55         {
    56             Inactive, //!< The @ref orxonox::QuestEffectBeacon "QuestEffectBeacon" is inactive.
    57             Active //!< The @ref orxonox::QuestEffectBeacon "QuestEffectBeacon" is active.
    58         };
    59     }
     54        Inactive, //!< The @ref orxonox::QuestEffectBeacon "QuestEffectBeacon" is inactive.
     55        Active //!< The @ref orxonox::QuestEffectBeacon "QuestEffectBeacon" is active.
     56    };
    6057
    6158    /**
     
    125122            std::list<QuestEffect*> effects_; //!< The list of QuestEffects to be invoked on the executing player.
    126123            int times_; //!< Number of times the beacon can be exectued.
    127             QuestEffectBeaconStatus::Value status_; //!< The status of the QuestEffectBeacon, Can be eighter active or inactive.
     124            QuestEffectBeaconStatus status_; //!< The status of the QuestEffectBeacon, Can be eighter active or inactive.
    128125
    129126            bool setTimes(const int & n); //!< Set the number of times the QuestEffectBeacon can be executed.
  • code/branches/cpp11_v2/src/modules/questsystem/QuestHint.cc

    r10765 r10997  
    9292
    9393        // Find the player.
    94         std::map<const PlayerInfo*, QuestHintStatus::Value>::const_iterator it = this->playerStatus_.find(player);
     94        std::map<const PlayerInfo*, QuestHintStatus>::const_iterator it = this->playerStatus_.find(player);
    9595        if (it != this->playerStatus_.end()) // If the player is in the map.
    96             return it->second;
     96            return (it->second == QuestHintStatus::Active);
    9797
    98         return QuestStatus::Inactive;
     98        return false;
    9999    }
    100100
  • code/branches/cpp11_v2/src/modules/questsystem/QuestHint.h

    r10817 r10997  
    5050    @ingroup Questsystem
    5151    */
    52     namespace QuestHintStatus
     52    enum class QuestHintStatus
    5353    {
    54         enum Value
    55         {
    56             Inactive, //!< The @ref orxonox::QuestHint "QuestHint" is inactive.
    57             Active //!< The @ref orxonox::QuestHint "QuestHint" is active.
    58         };
    59     }
     54        Inactive, //!< The @ref orxonox::QuestHint "QuestHint" is inactive.
     55        Active //!< The @ref orxonox::QuestHint "QuestHint" is active.
     56    };
    6057
    6158    /**
     
    10198        private:
    10299            Quest* quest_; //!< The Quest the QuestHint belongs to.
    103             std::map<const PlayerInfo*, QuestHintStatus::Value> playerStatus_; //!< List of the states for each player, with the Player-pointer as key.
     100            std::map<const PlayerInfo*, QuestHintStatus> playerStatus_; //!< List of the states for each player, with the Player-pointer as key.
    104101
    105102    }; // tolua_export
  • code/branches/cpp11_v2/src/modules/questsystem/QuestListener.h

    r10817 r10997  
    5050    @ingroup Questsystem
    5151    */
    52     namespace QuestListenerMode
     52    enum class QuestListenerMode
    5353    {
    54         enum Value
    55         {
    56             All, //!< Listens to all events.
    57             Start, //!< Only listens to events pertaining the starting of @ref orxonox::Quest "Quests".
    58             Fail, //!< Only listens to events pertaining the failing of @ref orxonox::Quest "Quests".
    59             Complete //!< Only listens to events pertaining the completing of @ref orxonox::Quest "Quests".
    60         };
    61     }
     54        All, //!< Listens to all events.
     55        Start, //!< Only listens to events pertaining the starting of @ref orxonox::Quest "Quests".
     56        Fail, //!< Only listens to events pertaining the failing of @ref orxonox::Quest "Quests".
     57        Complete //!< Only listens to events pertaining the completing of @ref orxonox::Quest "Quests".
     58    };
    6259
    6360    /**
     
    103100
    104101        private:
    105             QuestListenerMode::Value mode_; //!< The mode of the QuestListener.
     102            QuestListenerMode mode_; //!< The mode of the QuestListener.
    106103            Quest* quest_; //!< A pointer to the Quest the QuestListener is reacting to.
    107104
Note: See TracChangeset for help on using the changeset viewer.