[Orxonox-commit 6340] r10997 - code/branches/cpp11_v2/src/modules/questsystem
landauf at orxonox.net
landauf at orxonox.net
Wed Dec 30 12:21:18 CET 2015
Author: landauf
Date: 2015-12-30 12:21:18 +0100 (Wed, 30 Dec 2015)
New Revision: 10997
Modified:
code/branches/cpp11_v2/src/modules/questsystem/GlobalQuest.cc
code/branches/cpp11_v2/src/modules/questsystem/GlobalQuest.h
code/branches/cpp11_v2/src/modules/questsystem/LocalQuest.cc
code/branches/cpp11_v2/src/modules/questsystem/LocalQuest.h
code/branches/cpp11_v2/src/modules/questsystem/Quest.h
code/branches/cpp11_v2/src/modules/questsystem/QuestEffectBeacon.h
code/branches/cpp11_v2/src/modules/questsystem/QuestHint.cc
code/branches/cpp11_v2/src/modules/questsystem/QuestHint.h
code/branches/cpp11_v2/src/modules/questsystem/QuestListener.h
Log:
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)
Modified: code/branches/cpp11_v2/src/modules/questsystem/GlobalQuest.cc
===================================================================
--- code/branches/cpp11_v2/src/modules/questsystem/GlobalQuest.cc 2015-12-30 10:59:18 UTC (rev 10996)
+++ code/branches/cpp11_v2/src/modules/questsystem/GlobalQuest.cc 2015-12-30 11:21:18 UTC (rev 10997)
@@ -176,7 +176,7 @@
@param player
The player.
*/
- QuestStatus::Value GlobalQuest::getStatus(const PlayerInfo* player) const
+ QuestStatus GlobalQuest::getStatus(const PlayerInfo* player) const
{
assert(player);
@@ -199,7 +199,7 @@
@return
Returns false if player is nullptr.
*/
- bool GlobalQuest::setStatus(PlayerInfo* player, const QuestStatus::Value & status)
+ bool GlobalQuest::setStatus(PlayerInfo* player, const QuestStatus & status)
{
assert(player);
Modified: code/branches/cpp11_v2/src/modules/questsystem/GlobalQuest.h
===================================================================
--- code/branches/cpp11_v2/src/modules/questsystem/GlobalQuest.h 2015-12-30 10:59:18 UTC (rev 10996)
+++ code/branches/cpp11_v2/src/modules/questsystem/GlobalQuest.h 2015-12-30 11:21:18 UTC (rev 10997)
@@ -102,13 +102,13 @@
virtual bool isFailable(const PlayerInfo* player) const override; //!< Checks whether the Quest can be failed.
virtual bool isCompletable(const PlayerInfo* player) const override; //!< Checks whether the Quest can be completed.
- virtual QuestStatus::Value getStatus(const PlayerInfo* player) const override; //!< Returns the status of the Quest for a specific player.
+ virtual QuestStatus getStatus(const PlayerInfo* player) const override; //!< Returns the status of the Quest for a specific player.
- virtual bool setStatus(PlayerInfo* player, const QuestStatus::Value & status) override; //!< Sets the status for a specific player.
+ virtual bool setStatus(PlayerInfo* player, const QuestStatus & status) override; //!< Sets the status for a specific player.
private:
std::set<PlayerInfo*> players_; //!< The set of players which possess this Quest.
- QuestStatus::Value status_; //!< The status of this Quest.
+ QuestStatus status_; //!< The status of this Quest.
std::list<QuestEffect*> rewards_; //!< Reward QuestEffects only invoked on the player completing the Quest.
bool addRewardEffect(QuestEffect* effect); //!< Adds a reward QuestEffect to the list of reward QuestEffects.
Modified: code/branches/cpp11_v2/src/modules/questsystem/LocalQuest.cc
===================================================================
--- code/branches/cpp11_v2/src/modules/questsystem/LocalQuest.cc 2015-12-30 10:59:18 UTC (rev 10996)
+++ code/branches/cpp11_v2/src/modules/questsystem/LocalQuest.cc 2015-12-30 11:21:18 UTC (rev 10997)
@@ -167,11 +167,11 @@
@return
Returns the status of the Quest for the input player.
*/
- QuestStatus::Value LocalQuest::getStatus(const PlayerInfo* player) const
+ QuestStatus LocalQuest::getStatus(const PlayerInfo* player) const
{
assert(player);
- std::map<const PlayerInfo*, QuestStatus::Value>::const_iterator it = this->playerStatus_.find(player);
+ std::map<const PlayerInfo*, QuestStatus>::const_iterator it = this->playerStatus_.find(player);
if (it != this->playerStatus_.end()) // If there is a player in the map.
return it->second;
@@ -189,7 +189,7 @@
@return
Returns false if player is nullptr.
*/
- bool LocalQuest::setStatus(PlayerInfo* player, const QuestStatus::Value & status)
+ bool LocalQuest::setStatus(PlayerInfo* player, const QuestStatus & status)
{
assert(player);
Modified: code/branches/cpp11_v2/src/modules/questsystem/LocalQuest.h
===================================================================
--- code/branches/cpp11_v2/src/modules/questsystem/LocalQuest.h 2015-12-30 10:59:18 UTC (rev 10996)
+++ code/branches/cpp11_v2/src/modules/questsystem/LocalQuest.h 2015-12-30 11:21:18 UTC (rev 10997)
@@ -96,11 +96,11 @@
virtual bool isFailable(const PlayerInfo* player) const override; //!< Checks whether the Quest can be failed.
virtual bool isCompletable(const PlayerInfo* player) const override; //!< Checks whether the Quest can be completed.
- virtual QuestStatus::Value getStatus(const PlayerInfo* player) const override; //!< Returns the status of the Quest for a specific player.
- virtual bool setStatus(PlayerInfo* player, const QuestStatus::Value & status) override; //!< Sets the status for a specific player.
+ virtual QuestStatus getStatus(const PlayerInfo* player) const override; //!< Returns the status of the Quest for a specific player.
+ virtual bool setStatus(PlayerInfo* player, const QuestStatus & status) override; //!< Sets the status for a specific player.
private:
- std::map<const PlayerInfo*, QuestStatus::Value> playerStatus_; //!< List of the status for each player, with the Player-pointer as key.
+ std::map<const PlayerInfo*, QuestStatus> playerStatus_; //!< List of the status for each player, with the Player-pointer as key.
};
Modified: code/branches/cpp11_v2/src/modules/questsystem/Quest.h
===================================================================
--- code/branches/cpp11_v2/src/modules/questsystem/Quest.h 2015-12-30 10:59:18 UTC (rev 10996)
+++ code/branches/cpp11_v2/src/modules/questsystem/Quest.h 2015-12-30 11:21:18 UTC (rev 10997)
@@ -50,16 +50,13 @@
@ingroup Questsystem
*/
- namespace QuestStatus
+ enum class QuestStatus
{
- enum Value
- {
- Inactive, //!< The @ref orxonox::Quest "Quest" is inactive.
- Active, //!< The @ref orxonox::Quest "Quest" is active.
- Failed, //!< The @ref orxonox::Quest "Quest" has been failed.
- Completed //!< The @ref orxonox::Quest "Quest" has been completed.
- };
- }
+ Inactive, //!< The @ref orxonox::Quest "Quest" is inactive.
+ Active, //!< The @ref orxonox::Quest "Quest" is active.
+ Failed, //!< The @ref orxonox::Quest "Quest" has been failed.
+ Completed //!< The @ref orxonox::Quest "Quest" has been completed.
+ };
/**
@brief
@@ -142,8 +139,8 @@
inline std::list<QuestEffect*> & getCompleteEffectList(void)
{ return this->completeEffects_; }
- virtual QuestStatus::Value getStatus(const PlayerInfo* player) const = 0; //!< Returns the status of the Quest for a specific player.
- virtual bool setStatus(PlayerInfo* player, const QuestStatus::Value & status) = 0; //!< Changes the status for a specific player.
+ virtual QuestStatus getStatus(const PlayerInfo* player) const = 0; //!< Returns the status of the Quest for a specific player.
+ virtual bool setStatus(PlayerInfo* player, const QuestStatus & status) = 0; //!< Changes the status for a specific player.
private:
Quest* parentQuest_; //!< Pointer to the parent-quest.
Modified: code/branches/cpp11_v2/src/modules/questsystem/QuestEffectBeacon.h
===================================================================
--- code/branches/cpp11_v2/src/modules/questsystem/QuestEffectBeacon.h 2015-12-30 10:59:18 UTC (rev 10996)
+++ code/branches/cpp11_v2/src/modules/questsystem/QuestEffectBeacon.h 2015-12-30 11:21:18 UTC (rev 10997)
@@ -49,14 +49,11 @@
@ingroup Questsystem
*/
- namespace QuestEffectBeaconStatus
+ enum class QuestEffectBeaconStatus
{
- enum Value
- {
- Inactive, //!< The @ref orxonox::QuestEffectBeacon "QuestEffectBeacon" is inactive.
- Active //!< The @ref orxonox::QuestEffectBeacon "QuestEffectBeacon" is active.
- };
- }
+ Inactive, //!< The @ref orxonox::QuestEffectBeacon "QuestEffectBeacon" is inactive.
+ Active //!< The @ref orxonox::QuestEffectBeacon "QuestEffectBeacon" is active.
+ };
/**
@brief
@@ -124,7 +121,7 @@
std::list<QuestEffect*> effects_; //!< The list of QuestEffects to be invoked on the executing player.
int times_; //!< Number of times the beacon can be exectued.
- QuestEffectBeaconStatus::Value status_; //!< The status of the QuestEffectBeacon, Can be eighter active or inactive.
+ QuestEffectBeaconStatus status_; //!< The status of the QuestEffectBeacon, Can be eighter active or inactive.
bool setTimes(const int & n); //!< Set the number of times the QuestEffectBeacon can be executed.
bool addEffect(QuestEffect* effect); //!< Add a QuestEffect to the QuestEffectBeacon.
Modified: code/branches/cpp11_v2/src/modules/questsystem/QuestHint.cc
===================================================================
--- code/branches/cpp11_v2/src/modules/questsystem/QuestHint.cc 2015-12-30 10:59:18 UTC (rev 10996)
+++ code/branches/cpp11_v2/src/modules/questsystem/QuestHint.cc 2015-12-30 11:21:18 UTC (rev 10997)
@@ -91,11 +91,11 @@
return false;
// Find the player.
- std::map<const PlayerInfo*, QuestHintStatus::Value>::const_iterator it = this->playerStatus_.find(player);
+ std::map<const PlayerInfo*, QuestHintStatus>::const_iterator it = this->playerStatus_.find(player);
if (it != this->playerStatus_.end()) // If the player is in the map.
- return it->second;
+ return (it->second == QuestHintStatus::Active);
- return QuestStatus::Inactive;
+ return false;
}
/**
Modified: code/branches/cpp11_v2/src/modules/questsystem/QuestHint.h
===================================================================
--- code/branches/cpp11_v2/src/modules/questsystem/QuestHint.h 2015-12-30 10:59:18 UTC (rev 10996)
+++ code/branches/cpp11_v2/src/modules/questsystem/QuestHint.h 2015-12-30 11:21:18 UTC (rev 10997)
@@ -49,14 +49,11 @@
@ingroup Questsystem
*/
- namespace QuestHintStatus
+ enum class QuestHintStatus
{
- enum Value
- {
- Inactive, //!< The @ref orxonox::QuestHint "QuestHint" is inactive.
- Active //!< The @ref orxonox::QuestHint "QuestHint" is active.
- };
- }
+ Inactive, //!< The @ref orxonox::QuestHint "QuestHint" is inactive.
+ Active //!< The @ref orxonox::QuestHint "QuestHint" is active.
+ };
/**
@brief
@@ -100,7 +97,7 @@
private:
Quest* quest_; //!< The Quest the QuestHint belongs to.
- std::map<const PlayerInfo*, QuestHintStatus::Value> playerStatus_; //!< List of the states for each player, with the Player-pointer as key.
+ std::map<const PlayerInfo*, QuestHintStatus> playerStatus_; //!< List of the states for each player, with the Player-pointer as key.
}; // tolua_export
Modified: code/branches/cpp11_v2/src/modules/questsystem/QuestListener.h
===================================================================
--- code/branches/cpp11_v2/src/modules/questsystem/QuestListener.h 2015-12-30 10:59:18 UTC (rev 10996)
+++ code/branches/cpp11_v2/src/modules/questsystem/QuestListener.h 2015-12-30 11:21:18 UTC (rev 10997)
@@ -49,16 +49,13 @@
@ingroup Questsystem
*/
- namespace QuestListenerMode
+ enum class QuestListenerMode
{
- enum Value
- {
- All, //!< Listens to all events.
- Start, //!< Only listens to events pertaining the starting of @ref orxonox::Quest "Quests".
- Fail, //!< Only listens to events pertaining the failing of @ref orxonox::Quest "Quests".
- Complete //!< Only listens to events pertaining the completing of @ref orxonox::Quest "Quests".
- };
- }
+ All, //!< Listens to all events.
+ Start, //!< Only listens to events pertaining the starting of @ref orxonox::Quest "Quests".
+ Fail, //!< Only listens to events pertaining the failing of @ref orxonox::Quest "Quests".
+ Complete //!< Only listens to events pertaining the completing of @ref orxonox::Quest "Quests".
+ };
/**
@brief
@@ -102,7 +99,7 @@
bool execute(void); //!< Executes the QuestListener, resp. fires an Event.
private:
- QuestListenerMode::Value mode_; //!< The mode of the QuestListener.
+ QuestListenerMode mode_; //!< The mode of the QuestListener.
Quest* quest_; //!< A pointer to the Quest the QuestListener is reacting to.
//! Static variables for the modes as strings.
More information about the Orxonox-commit
mailing list