From 5b0c6c5c95645813f96ea413b1c14f2ffc18a481 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 6 May 2015 16:29:31 +0300 Subject: Add strong typed bool type AllPlayers. --- src/actormanager.cpp | 8 ++++---- src/actormanager.h | 6 ++++-- src/enums/simpletypes.h | 1 + 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 &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 &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 &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 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 -- cgit v1.2.3-60-g2f50