summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/Makefile.am1
-rw-r--r--src/actions/commands.cpp30
-rw-r--r--src/actormanager.cpp8
-rw-r--r--src/being/being.cpp23
-rw-r--r--src/being/localplayer.cpp2
-rw-r--r--src/being/playerrelation.cpp2
-rw-r--r--src/being/playerrelation.h16
-rw-r--r--src/being/playerrelations.cpp52
-rw-r--r--src/being/playerrelations.h9
-rw-r--r--src/enums/being/relation.h42
-rw-r--r--src/gui/models/playertablemodel.cpp2
-rw-r--r--src/gui/popups/popupmenu.cpp14
-rw-r--r--src/gui/widgets/tabs/socialfriendstab.h3
-rw-r--r--src/gui/windows/chatwindow.cpp4
-rw-r--r--src/gui/windows/whoisonline.cpp14
16 files changed, 126 insertions, 97 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 904c5e3d2..805327f26 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1017,6 +1017,7 @@ SET(SRCS
being/playerrelations.h
enums/being/rank.h
enums/being/reachable.h
+ enums/being/relation.h
enums/being/targetcursorsize.h
enums/being/targetcursortype.h
listeners/playerrelationslistener.h
diff --git a/src/Makefile.am b/src/Makefile.am
index 8eea44b8d..f8e45e440 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1150,6 +1150,7 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \
being/playerrelations.h \
enums/being/rank.h \
enums/being/reachable.h \
+ enums/being/relation.h \
enums/being/targetcursorsize.h \
enums/being/targetcursortype.h \
listeners/playerrelationslistener.h \
diff --git a/src/actions/commands.cpp b/src/actions/commands.cpp
index 0bcca016c..99b09914d 100644
--- a/src/actions/commands.cpp
+++ b/src/actions/commands.cpp
@@ -85,7 +85,7 @@ static std::string getNick(const InputEvent &event)
}
static void reportRelation(const InputEvent &event,
- const PlayerRelation::Relation &rel,
+ const RelationT &rel,
const std::string &str1,
const std::string &str2)
{
@@ -105,7 +105,7 @@ static void reportRelation(const InputEvent &event,
}
static void changeRelation(const InputEvent &event,
- const PlayerRelation::Relation relation,
+ const RelationT relation,
const std::string &relationText)
{
std::string args = getNick(event);
@@ -143,7 +143,7 @@ impHandler(chatAnnounce)
impHandler(chatIgnore)
{
- changeRelation(event, PlayerRelation::IGNORED, "ignored");
+ changeRelation(event, Relation::IGNORED, "ignored");
return true;
}
@@ -153,10 +153,10 @@ impHandler(chatUnignore)
if (args.empty())
return false;
- const PlayerRelation::Relation rel = player_relations.getRelation(args);
- if (rel != PlayerRelation::NEUTRAL && rel != PlayerRelation::FRIEND)
+ const RelationT rel = player_relations.getRelation(args);
+ if (rel != Relation::NEUTRAL && rel != Relation::FRIEND)
{
- player_relations.setRelation(args, PlayerRelation::NEUTRAL);
+ player_relations.setRelation(args, Relation::NEUTRAL);
}
else
{
@@ -170,7 +170,7 @@ impHandler(chatUnignore)
}
reportRelation(event,
- PlayerRelation::NEUTRAL,
+ Relation::NEUTRAL,
// TRANSLATORS: unignore command
_("Player no longer ignored!"),
// TRANSLATORS: unignore command
@@ -184,7 +184,7 @@ impHandler(chatErase)
if (args.empty())
return false;
- if (player_relations.getRelation(args) == PlayerRelation::ERASED)
+ if (player_relations.getRelation(args) == Relation::ERASED)
{
if (event.tab)
{
@@ -196,11 +196,11 @@ impHandler(chatErase)
}
else
{
- player_relations.setRelation(args, PlayerRelation::ERASED);
+ player_relations.setRelation(args, Relation::ERASED);
}
reportRelation(event,
- PlayerRelation::ERASED,
+ Relation::ERASED,
// TRANSLATORS: erase command
_("Player no longer erased!"),
// TRANSLATORS: erase command
@@ -211,35 +211,35 @@ impHandler(chatErase)
impHandler(chatFriend)
{
// TRANSLATORS: adding friend command
- changeRelation(event, PlayerRelation::FRIEND, _("friend"));
+ changeRelation(event, Relation::FRIEND, _("friend"));
return true;
}
impHandler(chatDisregard)
{
// TRANSLATORS: disregard command
- changeRelation(event, PlayerRelation::DISREGARDED, _("disregarded"));
+ changeRelation(event, Relation::DISREGARDED, _("disregarded"));
return true;
}
impHandler(chatNeutral)
{
// TRANSLATORS: neutral command
- changeRelation(event, PlayerRelation::NEUTRAL, _("neutral"));
+ changeRelation(event, Relation::NEUTRAL, _("neutral"));
return true;
}
impHandler(chatBlackList)
{
// TRANSLATORS: blacklist command
- changeRelation(event, PlayerRelation::BLACKLISTED, _("blacklisted"));
+ changeRelation(event, Relation::BLACKLISTED, _("blacklisted"));
return true;
}
impHandler(chatEnemy)
{
// TRANSLATORS: enemy command
- changeRelation(event, PlayerRelation::ENEMY2, _("enemy"));
+ changeRelation(event, Relation::ENEMY2, _("enemy"));
return true;
}
diff --git a/src/actormanager.cpp b/src/actormanager.cpp
index 121f5e3f3..48ff9fa19 100644
--- a/src/actormanager.cpp
+++ b/src/actormanager.cpp
@@ -1251,7 +1251,7 @@ void ActorManager::heal(const Being *const target) const
{
// target not enemy
if (player_relations.getRelation(target->getName()) !=
- PlayerRelation::ENEMY2)
+ Relation::ENEMY2)
{
if (!PacketLimiter::limitPackets(PACKET_CHAT))
return;
@@ -1294,10 +1294,10 @@ Being* ActorManager::findMostDamagedPlayer() const
Being *const being = static_cast<Being*>(*it);
- if ((!being) || (!being->isAlive()) || // don't heal dead
+ if ((!being) || (!being->isAlive()) || // don't heal dead
(player_relations.getRelation(being->getName()) ==
- PlayerRelation::ENEMY2) || // don't heal enemy
- (localPlayer == being)) // don't heal self
+ Relation::ENEMY2) || // don't heal enemy
+ (localPlayer == being)) // don't heal self
{
continue;
}
diff --git a/src/being/being.cpp b/src/being/being.cpp
index ddd0e7473..e30a1e477 100644
--- a/src/being/being.cpp
+++ b/src/being/being.cpp
@@ -2005,11 +2005,8 @@ void Being::showName()
delete2(mDispName);
- if (mHideErased && player_relations.getRelation(mName) ==
- PlayerRelation::ERASED)
- {
+ if (mHideErased && player_relations.getRelation(mName) == Relation::ERASED)
return;
- }
std::string displayName(mName);
@@ -2079,7 +2076,7 @@ void Being::updateColors()
{
mTextColor = &theme->getColor(ThemeColorId::PLAYER, 255);
- if (player_relations.getRelation(mName) != PlayerRelation::ERASED)
+ if (player_relations.getRelation(mName) != Relation::ERASED)
mErased = false;
else
mErased = true;
@@ -2103,27 +2100,23 @@ void Being::updateColors()
{
mNameColor = &userPalette->getColor(UserColorId::GUILD);
}
- else if (player_relations.getRelation(mName) ==
- PlayerRelation::FRIEND)
+ else if (player_relations.getRelation(mName) == Relation::FRIEND)
{
mNameColor = &userPalette->getColor(UserColorId::FRIEND);
}
else if (player_relations.getRelation(mName) ==
- PlayerRelation::DISREGARDED
+ Relation::DISREGARDED
|| player_relations.getRelation(mName) ==
- PlayerRelation::BLACKLISTED)
+ Relation::BLACKLISTED)
{
mNameColor = &userPalette->getColor(UserColorId::DISREGARDED);
}
- else if (player_relations.getRelation(mName) ==
- PlayerRelation::IGNORED
- || player_relations.getRelation(mName) ==
- PlayerRelation::ENEMY2)
+ else if (player_relations.getRelation(mName) == Relation::IGNORED
+ || player_relations.getRelation(mName) == Relation::ENEMY2)
{
mNameColor = &userPalette->getColor(UserColorId::IGNORED);
}
- else if (player_relations.getRelation(mName) ==
- PlayerRelation::ERASED)
+ else if (player_relations.getRelation(mName) == Relation::ERASED)
{
mNameColor = &userPalette->getColor(UserColorId::ERASED);
}
diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp
index b4f19ef00..a941dc42c 100644
--- a/src/being/localplayer.cpp
+++ b/src/being/localplayer.cpp
@@ -2614,7 +2614,7 @@ bool LocalPlayer::checAttackPermissions(const Being *const target)
return true;
case 1:
return !(player_relations.getRelation(target->getName())
- == PlayerRelation::FRIEND);
+ == Relation::FRIEND);
case 2:
return player_relations.checkBadRelation(target->getName());
default:
diff --git a/src/being/playerrelation.cpp b/src/being/playerrelation.cpp
index 6737d02d1..1259d2caa 100644
--- a/src/being/playerrelation.cpp
+++ b/src/being/playerrelation.cpp
@@ -24,7 +24,7 @@
#include "debug.h"
-PlayerRelation::PlayerRelation(const Relation relation) :
+PlayerRelation::PlayerRelation(const RelationT relation) :
mRelation(relation)
{
}
diff --git a/src/being/playerrelation.h b/src/being/playerrelation.h
index 5f6e1f42d..22fb3cb64 100644
--- a/src/being/playerrelation.h
+++ b/src/being/playerrelation.h
@@ -23,6 +23,8 @@
#ifndef BEING_PLAYERRELATION_H
#define BEING_PLAYERRELATION_H
+#include "enums/being/relation.h"
+
#include "localconsts.h"
struct PlayerRelation final
@@ -44,22 +46,12 @@ struct PlayerRelation final
| SPEECH_LOG
| WHISPER
| TRADE;
- enum Relation
- {
- NEUTRAL = 0,
- FRIEND = 1,
- DISREGARDED = 2,
- IGNORED = 3,
- ERASED = 4,
- BLACKLISTED = 5,
- ENEMY2 = 6
- };
- explicit PlayerRelation(const Relation relation);
+ explicit PlayerRelation(const RelationT relation);
A_DELETE_COPY(PlayerRelation)
- Relation mRelation; // bitmask for all of the above
+ RelationT mRelation; // bitmask for all of the above
};
#endif // BEING_PLAYERRELATION_H
diff --git a/src/being/playerrelations.cpp b/src/being/playerrelations.cpp
index 22f685044..20192be07 100644
--- a/src/being/playerrelations.cpp
+++ b/src/being/playerrelations.cpp
@@ -101,10 +101,10 @@ namespace
if (!(*container)[name])
{
const int v = cobj->getValueInt(RELATION,
- static_cast<int>(PlayerRelation::NEUTRAL));
+ static_cast<int>(Relation::NEUTRAL));
(*container)[name] = new PlayerRelation(
- static_cast<PlayerRelation::Relation>(v));
+ static_cast<RelationT>(v));
}
// otherwise ignore the duplicate entry
@@ -271,19 +271,19 @@ unsigned int PlayerRelationsManager::checkPermissionSilently(
switch (r->mRelation)
{
- case PlayerRelation::NEUTRAL:
+ case Relation::NEUTRAL:
permissions = mDefaultPermissions;
break;
- case PlayerRelation::FRIEND:
+ case Relation::FRIEND:
permissions |= mDefaultPermissions; // widen
break;
- case PlayerRelation::DISREGARDED:
- case PlayerRelation::IGNORED:
- case PlayerRelation::ERASED:
- case PlayerRelation::BLACKLISTED:
- case PlayerRelation::ENEMY2:
+ case Relation::DISREGARDED:
+ case Relation::IGNORED:
+ case Relation::ERASED:
+ case Relation::BLACKLISTED:
+ case Relation::ENEMY2:
default:
permissions &= mDefaultPermissions; // narrow
}
@@ -330,10 +330,10 @@ bool PlayerRelationsManager::hasPermission(const std::string &name,
}
void PlayerRelationsManager::setRelation(const std::string &player_name,
- const PlayerRelation::Relation
+ const RelationT
relation)
{
- if (!localPlayer || (relation != PlayerRelation::NEUTRAL
+ if (!localPlayer || (relation != Relation::NEUTRAL
&& localPlayer->getName() == player_name))
{
return;
@@ -365,7 +365,7 @@ StringVect *PlayerRelationsManager::getPlayers() const
}
StringVect *PlayerRelationsManager::getPlayersByRelation(
- const PlayerRelation::Relation rel) const
+ const RelationT rel) const
{
StringVect *const retval = new StringVect();
@@ -388,7 +388,7 @@ void PlayerRelationsManager::removePlayer(const std::string &name)
}
-PlayerRelation::Relation PlayerRelationsManager::getRelation(
+RelationT PlayerRelationsManager::getRelation(
const std::string &name) const
{
const std::map<std::string, PlayerRelation *>::const_iterator
@@ -396,7 +396,7 @@ PlayerRelation::Relation PlayerRelationsManager::getRelation(
if (it != mRelations.end())
return (*it).second->mRelation;
- return PlayerRelation::NEUTRAL;
+ return Relation::NEUTRAL;
}
////////////////////////////////////////
@@ -420,18 +420,18 @@ void PlayerRelationsManager::ignoreTrade(const std::string &name) const
if (name.empty())
return;
- const PlayerRelation::Relation relation = getRelation(name);
+ const RelationT relation = getRelation(name);
- if (relation == PlayerRelation::IGNORED
- || relation == PlayerRelation::DISREGARDED
- || relation == PlayerRelation::BLACKLISTED
- || relation == PlayerRelation::ERASED)
+ if (relation == Relation::IGNORED
+ || relation == Relation::DISREGARDED
+ || relation == Relation::BLACKLISTED
+ || relation == Relation::ERASED)
{
return;
}
else
{
- player_relations.setRelation(name, PlayerRelation::BLACKLISTED);
+ player_relations.setRelation(name, Relation::BLACKLISTED);
}
}
@@ -440,13 +440,13 @@ bool PlayerRelationsManager::checkBadRelation(const std::string &name) const
if (name.empty())
return true;
- const PlayerRelation::Relation relation = getRelation(name);
+ const RelationT relation = getRelation(name);
- if (relation == PlayerRelation::IGNORED
- || relation == PlayerRelation::DISREGARDED
- || relation == PlayerRelation::BLACKLISTED
- || relation == PlayerRelation::ERASED
- || relation == PlayerRelation::ENEMY2)
+ if (relation == Relation::IGNORED
+ || relation == Relation::DISREGARDED
+ || relation == Relation::BLACKLISTED
+ || relation == Relation::ERASED
+ || relation == Relation::ENEMY2)
{
return true;
}
diff --git a/src/being/playerrelations.h b/src/being/playerrelations.h
index 87cd83d75..0976fe167 100644
--- a/src/being/playerrelations.h
+++ b/src/being/playerrelations.h
@@ -23,6 +23,8 @@
#ifndef BEING_PLAYERRELATIONS_H
#define BEING_PLAYERRELATIONS_H
+#include "enums/being/relation.h"
+
#include "utils/stringvector.h"
#include "being/playerrelation.h"
@@ -88,13 +90,12 @@ class PlayerRelationsManager final
* Updates the relationship with this player.
*/
void setRelation(const std::string &name,
- const PlayerRelation::Relation relation);
+ const RelationT relation);
/**
* Updates the relationship with this player.
*/
- PlayerRelation::Relation getRelation(const std::string &name)
- const A_WARN_UNUSED;
+ RelationT getRelation(const std::string &name) const A_WARN_UNUSED;
/**
* Deletes the information recorded for a player.
@@ -151,7 +152,7 @@ class PlayerRelationsManager final
*/
StringVect *getPlayers() const A_WARN_UNUSED;
- StringVect *getPlayersByRelation(const PlayerRelation::Relation rel)
+ StringVect *getPlayersByRelation(const RelationT rel)
const A_WARN_UNUSED;
/**
diff --git a/src/enums/being/relation.h b/src/enums/being/relation.h
new file mode 100644
index 000000000..31408ef7b
--- /dev/null
+++ b/src/enums/being/relation.h
@@ -0,0 +1,42 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2008-2009 The Mana World Development Team
+ * Copyright (C) 2009-2010 The Mana Developers
+ * Copyright (C) 2011-2015 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef ENUMS_BEING_RELATION_H
+#define ENUMS_BEING_RELATION_H
+
+namespace Relation
+{
+ enum T
+ {
+ NEUTRAL = 0,
+ FRIEND = 1,
+ DISREGARDED = 2,
+ IGNORED = 3,
+ ERASED = 4,
+ BLACKLISTED = 5,
+ ENEMY2 = 6
+ };
+} // namespace Relation
+
+typedef Relation::T RelationT;
+
+#endif // ENUMS_BEING_RELATION_H
diff --git a/src/gui/models/playertablemodel.cpp b/src/gui/models/playertablemodel.cpp
index f83a67707..4affed712 100644
--- a/src/gui/models/playertablemodel.cpp
+++ b/src/gui/models/playertablemodel.cpp
@@ -123,7 +123,7 @@ void PlayerTableModel::updateModelInRow(const int row) const
const DropDown *const choicebox = static_cast<DropDown *>(
getElementAt(row, RELATION_CHOICE_COLUMN));
player_relations.setRelation(getPlayerAt(row),
- static_cast<PlayerRelation::Relation>(
+ static_cast<RelationT>(
choicebox->getSelected()));
}
diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp
index 6c348a8e5..37c8e0d78 100644
--- a/src/gui/popups/popupmenu.cpp
+++ b/src/gui/popups/popupmenu.cpp
@@ -2264,18 +2264,18 @@ void PopupMenu::addPlayerRelation(const std::string &name)
{
switch (player_relations.getRelation(name))
{
- case PlayerRelation::NEUTRAL:
+ case Relation::NEUTRAL:
// TRANSLATORS: popup menu item
// TRANSLATORS: add player to friends list
mBrowserBox->addRow("/friend 'NAME'", _("Be friend"));
addNormalRelations();
break;
- case PlayerRelation::FRIEND:
+ case Relation::FRIEND:
addNormalRelations();
break;
- case PlayerRelation::BLACKLISTED:
+ case Relation::BLACKLISTED:
// TRANSLATORS: popup menu item
// TRANSLATORS: remove player from ignore list
mBrowserBox->addRow("/unignore 'NAME'", _("Unignore"));
@@ -2293,7 +2293,7 @@ void PopupMenu::addPlayerRelation(const std::string &name)
mBrowserBox->addRow("/erase 'NAME'", _("Erase"));
break;
- case PlayerRelation::DISREGARDED:
+ case Relation::DISREGARDED:
// TRANSLATORS: popup menu item
// TRANSLATORS: remove player from ignore list
mBrowserBox->addRow("/unignore 'NAME'", _("Unignore"));
@@ -2305,7 +2305,7 @@ void PopupMenu::addPlayerRelation(const std::string &name)
mBrowserBox->addRow("/erase 'NAME'", _("Erase"));
break;
- case PlayerRelation::IGNORED:
+ case Relation::IGNORED:
// TRANSLATORS: popup menu item
// TRANSLATORS: remove player from ignore list
mBrowserBox->addRow("/unignore 'NAME'", _("Unignore"));
@@ -2314,7 +2314,7 @@ void PopupMenu::addPlayerRelation(const std::string &name)
mBrowserBox->addRow("/erase 'NAME'", _("Erase"));
break;
- case PlayerRelation::ENEMY2:
+ case Relation::ENEMY2:
// TRANSLATORS: popup menu item
// TRANSLATORS: remove player from ignore list
mBrowserBox->addRow("/unignore 'NAME'", _("Unignore"));
@@ -2332,7 +2332,7 @@ void PopupMenu::addPlayerRelation(const std::string &name)
mBrowserBox->addRow("/erase 'NAME'", _("Erase"));
break;
- case PlayerRelation::ERASED:
+ case Relation::ERASED:
// TRANSLATORS: popup menu item
// TRANSLATORS: remove player from ignore list
mBrowserBox->addRow("/unignore 'NAME'", _("Unignore"));
diff --git a/src/gui/widgets/tabs/socialfriendstab.h b/src/gui/widgets/tabs/socialfriendstab.h
index 229591096..e09068d8d 100644
--- a/src/gui/widgets/tabs/socialfriendstab.h
+++ b/src/gui/widgets/tabs/socialfriendstab.h
@@ -86,8 +86,7 @@ class SocialFriendsTab final : public SocialTab
avatars->clear();
const StringVect *const players
- = player_relations.getPlayersByRelation(
- PlayerRelation::FRIEND);
+ = player_relations.getPlayersByRelation(Relation::FRIEND);
const std::set<std::string> &players2
= whoIsOnline->getOnlineNicks();
diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp
index f79f8b45d..747ba498e 100644
--- a/src/gui/windows/chatwindow.cpp
+++ b/src/gui/windows/chatwindow.cpp
@@ -605,10 +605,10 @@ void ChatWindow::ignoreAllWhispers()
if (tab)
{
if (player_relations.getRelation(tab->getNick())
- != PlayerRelation::IGNORED)
+ != Relation::IGNORED)
{
player_relations.setRelation(tab->getNick(),
- PlayerRelation::IGNORED);
+ Relation::IGNORED);
}
tab->handleCommand("close", "");
}
diff --git a/src/gui/windows/whoisonline.cpp b/src/gui/windows/whoisonline.cpp
index d0b896041..174b242dd 100644
--- a/src/gui/windows/whoisonline.cpp
+++ b/src/gui/windows/whoisonline.cpp
@@ -282,13 +282,13 @@ void WhoIsOnline::handlerPlayerRelation(const std::string &nick,
{
switch (player_relations.getRelation(nick))
{
- case PlayerRelation::NEUTRAL:
+ case Relation::NEUTRAL:
default:
setNeutralColor(player);
mNeutral.push_back(player);
break;
- case PlayerRelation::FRIEND:
+ case Relation::FRIEND:
player->setText("2");
if (mGroupFriends)
mFriends.push_back(player);
@@ -296,19 +296,19 @@ void WhoIsOnline::handlerPlayerRelation(const std::string &nick,
mNeutral.push_back(player);
break;
- case PlayerRelation::DISREGARDED:
- case PlayerRelation::BLACKLISTED:
+ case Relation::DISREGARDED:
+ case Relation::BLACKLISTED:
player->setText("8");
mDisregard.push_back(player);
break;
- case PlayerRelation::ENEMY2:
+ case Relation::ENEMY2:
player->setText("1");
mEnemy.push_back(player);
break;
- case PlayerRelation::IGNORED:
- case PlayerRelation::ERASED:
+ case Relation::IGNORED:
+ case Relation::ERASED:
// Ignore the ignored.
break;
}