diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-05-06 16:29:31 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-05-06 16:29:31 +0300 |
commit | 5b0c6c5c95645813f96ea413b1c14f2ffc18a481 (patch) | |
tree | 15f9a59ac6c585a2391ab5713f8ce2261a105928 /src | |
parent | 7fa78a35307227453ab55c7452e348a40cd41d65 (diff) | |
download | mv-5b0c6c5c95645813f96ea413b1c14f2ffc18a481.tar.gz mv-5b0c6c5c95645813f96ea413b1c14f2ffc18a481.tar.bz2 mv-5b0c6c5c95645813f96ea413b1c14f2ffc18a481.tar.xz mv-5b0c6c5c95645813f96ea413b1c14f2ffc18a481.zip |
Add strong typed bool type AllPlayers.
Diffstat (limited to 'src')
-rw-r--r-- | src/actormanager.cpp | 8 | ||||
-rw-r--r-- | src/actormanager.h | 6 | ||||
-rw-r--r-- | src/enums/simpletypes.h | 1 | ||||
-rw-r--r-- | src/gui/viewport.cpp | 4 |
4 files changed, 11 insertions, 8 deletions
diff --git a/src/actormanager.cpp b/src/actormanager.cpp index 7a074661d..1df31fbeb 100644 --- a/src/actormanager.cpp +++ b/src/actormanager.cpp @@ -359,7 +359,7 @@ Being *ActorManager::findBeing(const int x, const int y, } Being *ActorManager::findBeingByPixel(const int x, const int y, - const bool allPlayers) const + const AllPlayers allPlayers) const { if (!mMap) return nullptr; @@ -410,7 +410,7 @@ Being *ActorManager::findBeingByPixel(const int x, const int y, if ((being->mAction != BeingAction::DEAD || (targetDead && being->getType() == ActorType::Player)) - && (allPlayers || being != localPlayer)) + && (allPlayers == AllPlayers_true || being != localPlayer)) { const int px = being->getPixelX(); const int py = being->getPixelY(); @@ -476,7 +476,7 @@ Being *ActorManager::findBeingByPixel(const int x, const int y, void ActorManager::findBeingsByPixel(std::vector<ActorSprite*> &beings, const int x, const int y, - const bool allPlayers) const + const AllPlayers allPlayers) const { if (!mMap) return; @@ -506,7 +506,7 @@ void ActorManager::findBeingsByPixel(std::vector<ActorSprite*> &beings, if ((being && (being->isAlive() || (mTargetDeadPlayers && being->getType() == ActorType::Player)) - && (allPlayers || being != localPlayer)) + && (allPlayers == AllPlayers_true || being != localPlayer)) || actor->getType() == ActorType::FloorItem) { if ((actor->getPixelX() - xtol <= x) && diff --git a/src/actormanager.h b/src/actormanager.h index 9387b2961..ae4b7217f 100644 --- a/src/actormanager.h +++ b/src/actormanager.h @@ -25,6 +25,8 @@ #include "flooritem.h" +#include "enums/simpletypes.h" + #include "listeners/configlistener.h" #include "utils/stringmap.h" @@ -105,7 +107,7 @@ class ActorManager final: public ConfigListener * Returns a being at the specific pixel. */ Being *findBeingByPixel(const int x, const int y, - const bool allPlayers = false) + const AllPlayers allPlayers = AllPlayers_false) const A_WARN_UNUSED; /** @@ -113,7 +115,7 @@ class ActorManager final: public ConfigListener */ void findBeingsByPixel(std::vector<ActorSprite*> &beings, const int x, const int y, - const bool allPlayers) const; + const AllPlayers allPlayers) const; /** * Returns a portal at the specific tile. diff --git a/src/enums/simpletypes.h b/src/enums/simpletypes.h index 5fa747c56..21b0e03cc 100644 --- a/src/enums/simpletypes.h +++ b/src/enums/simpletypes.h @@ -59,5 +59,6 @@ defBoolEnum(Trading); defBoolEnum(Sfx); defBoolEnum(Keep); defBoolEnum(Modifiable); +defBoolEnum(AllPlayers); #endif // ENUMS_SIMPLETYPES_H diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index fd9166c33..5bee2f8ff 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -379,7 +379,7 @@ bool Viewport::openContextMenu(const MouseEvent &event) std::vector<ActorSprite*> beings; const int x = mMouseX + mPixelViewX; const int y = mMouseY + mPixelViewY; - actorManager->findBeingsByPixel(beings, x, y, true); + actorManager->findBeingsByPixel(beings, x, y, AllPlayers_true); if (beings.size() > 1) popupMenu->showPopup(eventX, eventY, beings); else @@ -771,7 +771,7 @@ void Viewport::mouseMoved(MouseEvent &event) const int y = mMouseY + mPixelViewY; ActorType::Type type = ActorType::Unknown; - mHoverBeing = actorManager->findBeingByPixel(x, y, true); + mHoverBeing = actorManager->findBeingByPixel(x, y, AllPlayers_true); if (mHoverBeing) type = mHoverBeing->getType(); if (mHoverBeing |