From 88697bc3503090194877b241b987ddc751034166 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 6 May 2015 17:19:32 +0300 Subject: Add strong typed bool type NpcNames. --- src/actormanager.cpp | 9 +++++---- src/actormanager.h | 2 +- src/enums/simpletypes.h | 1 + src/gui/widgets/tabs/socialplayerstab.h | 4 +++- src/gui/windows/chatwindow.cpp | 2 +- src/utils/chatutils.cpp | 2 +- 6 files changed, 12 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/actormanager.cpp b/src/actormanager.cpp index e32eda6f1..b9ff84adb 100644 --- a/src/actormanager.cpp +++ b/src/actormanager.cpp @@ -1410,7 +1410,7 @@ void ActorManager::printBeingsToChat(const std::vector &beings, } void ActorManager::getPlayerNames(StringVect &names, - const bool npcNames) const + const NpcNames npcNames) const { names.clear(); @@ -1426,9 +1426,10 @@ void ActorManager::getPlayerNames(StringVect &names, } const Being *const being = static_cast(*it); - if ((being->getType() == ActorType::Player - || (being->getType() == ActorType::Npc && npcNames)) - && being->getName() != "") + if ((being->getType() == ActorType::Player || + (being->getType() == ActorType::Npc && + npcNames == NpcNames_true)) && + being->getName() != "") { names.push_back(being->getName()); } diff --git a/src/actormanager.h b/src/actormanager.h index 9d0bc261c..b6a9eb703 100644 --- a/src/actormanager.h +++ b/src/actormanager.h @@ -236,7 +236,7 @@ class ActorManager final: public ConfigListener const std::string &header); void getPlayerNames(StringVect &names, - const bool npcNames) const; + const NpcNames npcNames) const; void getMobNames(StringVect &names) const; diff --git a/src/enums/simpletypes.h b/src/enums/simpletypes.h index a86e2629b..c6b3d26a6 100644 --- a/src/enums/simpletypes.h +++ b/src/enums/simpletypes.h @@ -61,5 +61,6 @@ defBoolEnum(Keep); defBoolEnum(Modifiable); defBoolEnum(AllPlayers); defBoolEnum(AllowSort); +defBoolEnum(NpcNames); #endif // ENUMS_SIMPLETYPES_H diff --git a/src/gui/widgets/tabs/socialplayerstab.h b/src/gui/widgets/tabs/socialplayerstab.h index 324ede7c6..7fee69deb 100644 --- a/src/gui/widgets/tabs/socialplayerstab.h +++ b/src/gui/widgets/tabs/socialplayerstab.h @@ -28,6 +28,8 @@ #include "being/being.h" +#include "enums/simpletypes.h" + #include "gui/models/beingslistmodel.h" #include "utils/gettext.h" @@ -147,7 +149,7 @@ class SocialPlayersTab final : public SocialTab if (actorManager) { StringVect names; - actorManager->getPlayerNames(names, false); + actorManager->getPlayerNames(names, NpcNames_false); std::vector::iterator ai = avatars->begin(); while (ai != avatars->end()) diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp index 4d822afc1..1a36f7a83 100644 --- a/src/gui/windows/chatwindow.cpp +++ b/src/gui/windows/chatwindow.cpp @@ -1385,7 +1385,7 @@ void ChatWindow::autoComplete() if (newName.empty() && actorManager) { - actorManager->getPlayerNames(nameList, true); + actorManager->getPlayerNames(nameList, NpcNames_true); newName = autoComplete(nameList, name); if (!newName.empty() && !startName) secureChatCommand(newName); diff --git a/src/utils/chatutils.cpp b/src/utils/chatutils.cpp index 794a21330..248856569 100644 --- a/src/utils/chatutils.cpp +++ b/src/utils/chatutils.cpp @@ -139,7 +139,7 @@ void replaceVars(std::string &str) { StringVect names; std::string newStr; - actorManager->getPlayerNames(names, false); + actorManager->getPlayerNames(names, NpcNames_false); FOR_EACH (StringVectCIter, it, names) { if (*it != localPlayer->getName()) -- cgit v1.2.3-70-g09d2