diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-10-05 01:41:54 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-10-05 01:41:54 +0300 |
commit | ab545fee3daf930dc46aaf303355c1c578320484 (patch) | |
tree | 24c8286acb9fea22b1e689810be5534de2323623 | |
parent | 851bee28374c5c60114c9f78299e28eaa14891b3 (diff) | |
download | ManaVerse-ab545fee3daf930dc46aaf303355c1c578320484.tar.gz ManaVerse-ab545fee3daf930dc46aaf303355c1c578320484.tar.bz2 ManaVerse-ab545fee3daf930dc46aaf303355c1c578320484.tar.xz ManaVerse-ab545fee3daf930dc46aaf303355c1c578320484.zip |
Add blacklist relation. In this mode blocked trades, emotes, speech text.
-rw-r--r-- | src/being.cpp | 4 | ||||
-rw-r--r-- | src/commandhandler.cpp | 13 | ||||
-rw-r--r-- | src/commandhandler.h | 5 | ||||
-rw-r--r-- | src/gui/chatwindow.cpp | 1 | ||||
-rw-r--r-- | src/gui/popupmenu.cpp | 38 | ||||
-rw-r--r-- | src/gui/setup_relations.cpp | 3 | ||||
-rw-r--r-- | src/gui/whoisonline.cpp | 1 | ||||
-rw-r--r-- | src/net/ea/tradehandler.cpp | 2 | ||||
-rw-r--r-- | src/playerrelations.cpp | 15 | ||||
-rw-r--r-- | src/playerrelations.h | 6 |
10 files changed, 74 insertions, 14 deletions
diff --git a/src/being.cpp b/src/being.cpp index 2ed05449a..84528622d 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -1623,7 +1623,9 @@ void Being::updateColors() mNameColor = &userPalette->getColor(UserPalette::FRIEND); } else if (player_relations.getRelation(mName) == - PlayerRelation::DISREGARDED) + PlayerRelation::DISREGARDED + || player_relations.getRelation(mName) == + PlayerRelation::BLACKLISTED) { mNameColor = &userPalette->getColor(UserPalette::DISREGARDED); } diff --git a/src/commandhandler.cpp b/src/commandhandler.cpp index 189485461..f1b7518c5 100644 --- a/src/commandhandler.cpp +++ b/src/commandhandler.cpp @@ -112,6 +112,8 @@ void CommandHandler::handleCommand(const std::string &command, ChatTab *tab) handleDisregard(args, tab); else if (type == "neutral") handleNeutral(args, tab); + else if (type == "blacklist") + handleBlackList(args, tab); else if (type == "erase") handleErase(args, tab); else if (type == "join") @@ -523,9 +525,10 @@ void CommandHandler::handleUnignore(const std::string &args, ChatTab *tab) return; } - if (player_relations.getRelation(args) == PlayerRelation::IGNORED) + if (player_relations.getRelation(args) != PlayerRelation::NEUTRAL + && player_relations.getRelation(args) != PlayerRelation::FRIEND) { - player_relations.removePlayer(args); + player_relations.setRelation(args, PlayerRelation::NEUTRAL); } else { @@ -536,13 +539,17 @@ void CommandHandler::handleUnignore(const std::string &args, ChatTab *tab) if (tab) { - if (player_relations.getRelation(args) != PlayerRelation::IGNORED) + if (player_relations.getRelation(args) == PlayerRelation::NEUTRAL) tab->chatLog(_("Player no longer ignored!"), BY_SERVER); else tab->chatLog(_("Player could not be unignored!"), BY_SERVER); } } +void CommandHandler::handleBlackList(const std::string &args, ChatTab *tab) +{ + changeRelation(args, PlayerRelation::BLACKLISTED, _("blacklisted"), tab); +} void CommandHandler::handleErase(const std::string &args, ChatTab *tab) { diff --git a/src/commandhandler.h b/src/commandhandler.h index 64f0288c3..52080dfcd 100644 --- a/src/commandhandler.h +++ b/src/commandhandler.h @@ -172,6 +172,11 @@ class CommandHandler void handleNeutral(const std::string &args, ChatTab *tab); /** + * Handle an blacklist command. + */ + void handleBlackList(const std::string &args, ChatTab *tab); + + /** * Handle an erase command. */ void handleErase(const std::string &args, ChatTab *tab); diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp index 82d6c2ff5..59bd173bd 100644 --- a/src/gui/chatwindow.cpp +++ b/src/gui/chatwindow.cpp @@ -293,6 +293,7 @@ void ChatWindow::fillCommands() mCommands.push_back("/addpriorityattack "); mCommands.push_back("/removeattack "); mCommands.push_back("/addignoreattack "); + mCommands.push_back("/blacklist "); } void ChatWindow::resetToDefaultSize() diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index 16e3d9ec7..d7c7e54df 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -144,12 +144,21 @@ void PopupMenu::showPopup(int x, int y, Being *being) mBrowserBox->addRow("friend", _("Be friend")); mBrowserBox->addRow("disregard", _("Disregard")); mBrowserBox->addRow("ignore", _("Ignore")); + mBrowserBox->addRow("blacklist", _("Black list")); mBrowserBox->addRow("erase", _("Erase")); break; case PlayerRelation::FRIEND: mBrowserBox->addRow("disregard", _("Disregard")); mBrowserBox->addRow("ignore", _("Ignore")); + mBrowserBox->addRow("blacklist", _("Black list")); + mBrowserBox->addRow("erase", _("Erase")); + break; + + case PlayerRelation::BLACKLISTED: + mBrowserBox->addRow("unignore", _("Unignore")); + mBrowserBox->addRow("disregard", _("Disregard")); + mBrowserBox->addRow("ignore", _("Ignore")); mBrowserBox->addRow("erase", _("Erase")); break; @@ -369,12 +378,21 @@ void PopupMenu::showPlayerPopup(int x, int y, std::string nick) mBrowserBox->addRow("friend", _("Be friend")); mBrowserBox->addRow("disregard", _("Disregard")); mBrowserBox->addRow("ignore", _("Ignore")); + mBrowserBox->addRow("blacklist", _("Black list")); mBrowserBox->addRow("erase", _("Erase")); break; case PlayerRelation::FRIEND: mBrowserBox->addRow("disregard", _("Disregard")); mBrowserBox->addRow("ignore", _("Ignore")); + mBrowserBox->addRow("blacklist", _("Black list")); + mBrowserBox->addRow("erase", _("Erase")); + break; + + case PlayerRelation::BLACKLISTED: + mBrowserBox->addRow("unignore", _("Unignore")); + mBrowserBox->addRow("disregard", _("Disregard")); + mBrowserBox->addRow("ignore", _("Ignore")); mBrowserBox->addRow("erase", _("Erase")); break; @@ -606,12 +624,21 @@ void PopupMenu::showChatPopup(int x, int y, ChatTab *tab) mBrowserBox->addRow("friend", _("Be friend")); mBrowserBox->addRow("disregard", _("Disregard")); mBrowserBox->addRow("ignore", _("Ignore")); + mBrowserBox->addRow("blacklist", _("Black list")); mBrowserBox->addRow("erase", _("Erase")); break; case PlayerRelation::FRIEND: mBrowserBox->addRow("disregard", _("Disregard")); mBrowserBox->addRow("ignore", _("Ignore")); + mBrowserBox->addRow("blacklist", _("Black list")); + mBrowserBox->addRow("erase", _("Erase")); + break; + + case PlayerRelation::BLACKLISTED: + mBrowserBox->addRow("unignore", _("Unignore")); + mBrowserBox->addRow("disregard", _("Disregard")); + mBrowserBox->addRow("ignore", _("Ignore")); mBrowserBox->addRow("erase", _("Erase")); break; @@ -857,6 +884,17 @@ void PopupMenu::handleLink(const std::string &link, { player_relations.setRelation(mNick, PlayerRelation::IGNORED); } + + else if (link == "blacklist" && being && + being->getType() == ActorSprite::PLAYER) + { + player_relations.setRelation(being->getName(), + PlayerRelation::BLACKLISTED); + } + else if (link == "blacklist" && !mNick.empty()) + { + player_relations.setRelation(mNick, PlayerRelation::BLACKLISTED); + } else if (link == "erase" && being && being->getType() == ActorSprite::PLAYER) { diff --git a/src/gui/setup_relations.cpp b/src/gui/setup_relations.cpp index 57a51e435..de88c2bee 100644 --- a/src/gui/setup_relations.cpp +++ b/src/gui/setup_relations.cpp @@ -71,7 +71,8 @@ static const char *RELATION_NAMES[PlayerRelation::RELATIONS_NR] = N_("Friend"), N_("Disregarded"), N_("Ignored"), - N_("Erased") + N_("Erased"), + N_("Black listed") }; class PlayerRelationListModel : public gcn::ListModel diff --git a/src/gui/whoisonline.cpp b/src/gui/whoisonline.cpp index a14e99afc..3c34da9ec 100644 --- a/src/gui/whoisonline.cpp +++ b/src/gui/whoisonline.cpp @@ -278,6 +278,7 @@ void WhoIsOnline::loadList() break; case PlayerRelation::DISREGARDED: + case PlayerRelation::BLACKLISTED: disregard.push_back(prepareNick(nick, level, "8")); break; diff --git a/src/net/ea/tradehandler.cpp b/src/net/ea/tradehandler.cpp index a03782db2..ff39f6761 100644 --- a/src/net/ea/tradehandler.cpp +++ b/src/net/ea/tradehandler.cpp @@ -84,7 +84,7 @@ void TradeHandler::processTradeRequest(Net::MessageIn &msg) // special message about the player being occupied. std::string tradePartnerNameTemp = msg.readString(24); - if (player_relations.hasPermission(tradePartnerName, + if (player_relations.hasPermission(tradePartnerNameTemp, PlayerRelation::TRADE)) { if (PlayerInfo::isTrading() || confirmDlg) diff --git a/src/playerrelations.cpp b/src/playerrelations.cpp index 00a9d1cad..d7532b884 100644 --- a/src/playerrelations.cpp +++ b/src/playerrelations.cpp @@ -103,11 +103,12 @@ class PlayerConfSerialiser : static PlayerConfSerialiser player_conf_serialiser; // stateless singleton const unsigned int PlayerRelation::RELATION_PERMISSIONS[RELATIONS_NR] = { - /* NEUTRAL */ 0, // we always fall back to the defaults anyway - /* FRIEND */ EMOTE | SPEECH_FLOAT | SPEECH_LOG | WHISPER | TRADE, - /* DISREGARDED*/ EMOTE | SPEECH_FLOAT, - /* IGNORED */ 0, - /* ERASED */ INVISIBLE + /* NEUTRAL */ 0, // we always fall back to the defaults anyway + /* FRIEND */ EMOTE | SPEECH_FLOAT | SPEECH_LOG | WHISPER | TRADE, + /* DISREGARDED*/ EMOTE | SPEECH_FLOAT, + /* IGNORED */ 0, + /* ERASED */ INVISIBLE, + /* BLACKLISTED */ SPEECH_LOG | WHISPER }; PlayerRelation::PlayerRelation(Relation relation) @@ -278,6 +279,7 @@ unsigned int PlayerRelationsManager::checkPermissionSilently( case PlayerRelation::DISREGARDED: case PlayerRelation::IGNORED: case PlayerRelation::ERASED: + case PlayerRelation::BLACKLISTED: default: permissions &= mDefaultPermissions; // narrow } @@ -395,13 +397,14 @@ void PlayerRelationsManager::ignoreTrade(std::string name) if (relation == PlayerRelation::IGNORED || relation == PlayerRelation::DISREGARDED + || relation == PlayerRelation::BLACKLISTED || relation == PlayerRelation::ERASED) { return; } else { - player_relations.setRelation(name, PlayerRelation::DISREGARDED); + player_relations.setRelation(name, PlayerRelation::BLACKLISTED); } } diff --git a/src/playerrelations.h b/src/playerrelations.h index bb483a793..41ca14b40 100644 --- a/src/playerrelations.h +++ b/src/playerrelations.h @@ -44,8 +44,9 @@ struct PlayerRelation static const unsigned int WHISPER = (1 << 3); static const unsigned int TRADE = (1 << 4); static const unsigned int INVISIBLE = (1 << 5); + static const unsigned int BLACKLIST = (1 << 6); - static const unsigned int RELATIONS_NR = 5; + static const unsigned int RELATIONS_NR = 6; static const unsigned int RELATION_PERMISSIONS[RELATIONS_NR]; static const unsigned int DEFAULT = EMOTE @@ -59,7 +60,8 @@ struct PlayerRelation FRIEND = 1, DISREGARDED = 2, IGNORED = 3, - ERASED = 4 + ERASED = 4, + BLACKLISTED = 5 }; PlayerRelation(Relation relation); |