ManaPlus
|
#include <playerrelations.h>
Public Member Functions | |
PlayerRelationsManager () | |
~PlayerRelationsManager () | |
void | init () |
void | load () |
void | store () const |
unsigned int | checkPermissionSilently (const std::string &player_name, const unsigned int flags) const |
bool | hasPermission (const Being *const being, const unsigned int flags) const |
bool | hasPermission (const std::string &being, const unsigned int flags) const |
void | setRelation (const std::string &name, const RelationT relation) |
RelationT | getRelation (const std::string &name) const |
void | removePlayer (const std::string &name) |
unsigned int | getDefault () const |
void | setDefault (const unsigned int permissions) |
std::vector< PlayerIgnoreStrategy * > * | getPlayerIgnoreStrategies () |
const PlayerIgnoreStrategy * | getPlayerIgnoreStrategy () const |
void | setPlayerIgnoreStrategy (PlayerIgnoreStrategy *const strategy) |
int | getPlayerIgnoreStrategyIndex (const std::string &shortname) |
StringVect * | getPlayers () const |
StringVect * | getPlayersByRelation (const RelationT rel) const |
void | clear () |
bool | getPersistIgnores () const |
void | ignoreTrade (const std::string &name) const |
bool | isGoodName (Being *const being) const |
bool | isGoodName (const std::string &name) const |
void | setPersistIgnores (const bool value) |
void | addListener (PlayerRelationsListener *const listener) |
void | removeListener (PlayerRelationsListener *const listener) |
bool | checkBadRelation (const std::string &name) const |
Private Member Functions | |
void | signalUpdate (const std::string &name) |
Static Private Member Functions | |
static bool | checkName (const std::string &name) |
Private Attributes | |
bool | mPersistIgnores |
unsigned int | mDefaultPermissions |
PlayerIgnoreStrategy * | mIgnoreStrategy |
std::map< std::string, PlayerRelation * > | mRelations |
std::list< PlayerRelationsListener * > | mListeners |
std::vector< PlayerIgnoreStrategy * > | mIgnoreStrategies |
Player relations class, represents any particular relations and/or preferences the user of the local client has wrt other players (identified by std::string).
Definition at line 47 of file playerrelations.h.
PlayerRelationsManager::PlayerRelationsManager | ( | ) |
Definition at line 151 of file playerrelations.cpp.
PlayerRelationsManager::~PlayerRelationsManager | ( | ) |
Definition at line 161 of file playerrelations.cpp.
References delete_all(), FOR_EACH, mIgnoreStrategies, and mRelations.
|
inline |
Definition at line 186 of file playerrelations.h.
References anonymous_namespace{itemlinkhandler.cpp}::listener, and mListeners.
Referenced by Setup_Relations::action(), SocialWindow::postInit(), and Setup_Relations::Setup_Relations().
bool PlayerRelationsManager::checkBadRelation | ( | const std::string & | name | ) | const |
Definition at line 460 of file playerrelations.cpp.
References Relation::BLACKLISTED, Relation::DISREGARDED, Relation::ENEMY2, Relation::ERASED, getRelation(), and Relation::IGNORED.
Referenced by LocalPlayer::checAttackPermissions().
|
staticprivate |
Definition at line 635 of file playerrelations.cpp.
References config, Configuration::getStringValue(), and EmoteDB::size().
Referenced by isGoodName().
unsigned int PlayerRelationsManager::checkPermissionSilently | ( | const std::string & | player_name, |
const unsigned int | flags | ||
) | const |
Determines whether the player in question is being ignored, filtered by the specified flags.
Definition at line 277 of file playerrelations.cpp.
References Relation::BLACKLISTED, CAST_S32, Relation::DISREGARDED, Relation::ENEMY2, Relation::ERASED, Relation::FRIEND, Relation::IGNORED, mDefaultPermissions, PlayerRelation::mRelation, mRelations, Relation::NEUTRAL, and PlayerRelation::RELATION_PERMISSIONS.
Referenced by hasPermission(), EAthena::ChatRecv::processBeingChat(), and TmwAthena::ChatRecv::processBeingChat().
void PlayerRelationsManager::clear | ( | ) |
Removes all recorded player info.
Definition at line 170 of file playerrelations.cpp.
References FOR_EACHP, getPlayers(), and removePlayer().
unsigned int PlayerRelationsManager::getDefault | ( | ) | const |
Retrieves the default permissions.
Definition at line 430 of file playerrelations.cpp.
References mDefaultPermissions.
Referenced by PopupMenu::addBuySell(), PopupMenu::addBuySellDefault(), Setup_Relations::apply(), Setup_Relations::externalUpdated(), and Setup_Relations::updatedPlayer().
|
inline |
Do we persist our ‘ignore’ setup?
Definition at line 169 of file playerrelations.h.
References mPersistIgnores.
std::vector< PlayerIgnoreStrategy * > * PlayerRelationsManager::getPlayerIgnoreStrategies | ( | ) |
Retrieves all known player ignore strategies.
The player ignore strategies are allocated statically and must not be deleted.
Definition at line 577 of file playerrelations.cpp.
References _, FIRST_IGNORE_EMOTE, mIgnoreStrategies, and PLAYER_IGNORE_STRATEGY_EMOTE0.
Referenced by Setup_Relations::action(), IgnoreChoicesListModel::getElementAt(), getPlayerIgnoreStrategyIndex(), load(), and Setup_Relations::reset().
|
inline |
Return the current player ignore strategy.
Definition at line 130 of file playerrelations.h.
References mIgnoreStrategy.
Referenced by Setup_Relations::reset(), Setup_Relations::Setup_Relations(), and Setup_Relations::updateAll().
int PlayerRelationsManager::getPlayerIgnoreStrategyIndex | ( | const std::string & | shortname | ) |
For a given ignore strategy short name, find the appropriate index in the ignore strategies vector.
The | short name of the ignore strategy to look up |
Definition at line 182 of file playerrelations.cpp.
References CAST_S32, and getPlayerIgnoreStrategies().
Referenced by load(), Setup_Relations::Setup_Relations(), and Setup_Relations::updateAll().
StringVect * PlayerRelationsManager::getPlayers | ( | ) | const |
Retrieves a sorted vector of all players for which we have any relations recorded.
Definition at line 374 of file playerrelations.cpp.
References FOR_EACH, mRelations, and anonymous_namespace{playerrelations.cpp}::playersRelSorter.
Referenced by clear(), and PlayerTableModel::playerRelationsUpdated().
StringVect * PlayerRelationsManager::getPlayersByRelation | ( | const RelationT | rel | ) | const |
Definition at line 389 of file playerrelations.cpp.
References FOR_EACH, mRelations, and anonymous_namespace{playerrelations.cpp}::playersRelSorter.
Referenced by SocialFriendsTab::getPlayersAvatars().
RelationT PlayerRelationsManager::getRelation | ( | const std::string & | name | ) | const |
Updates the relationship with this player.
Definition at line 416 of file playerrelations.cpp.
References mRelations, and Relation::NEUTRAL.
Referenced by PopupMenu::addPlayerRelation(), Actions::changeRelation(), LocalPlayer::checAttackPermissions(), checkBadRelation(), ActorManager::findMostDamagedPlayer(), WhoIsOnline::handlerPlayerRelation(), ActorManager::heal(), ChatWindow::ignoreAllWhispers(), ignoreTrade(), PlayerTableModel::playerRelationsUpdated(), Actions::reportRelation(), Being::showName(), and Being::updateColors().
bool PlayerRelationsManager::hasPermission | ( | const Being *const | being, |
const unsigned int | flags | ||
) | const |
Tests whether the player in question is being ignored for any of the actions in the specified flags. If so, trigger appropriate side effects if requested by the player.
Definition at line 314 of file playerrelations.cpp.
References Being::getName(), Being::getType(), and ActorType::Player.
Referenced by EAthena::ChatRecv::processBeingChat(), TmwAthena::ChatRecv::processBeingChat(), Ea::BeingRecv::processBeingEmotion(), Ea::TradeRecv::processTradeRequestContinue(), TmwAthena::TradeRecv::processTradeResponse(), Ea::TradeRecv::processTradeResponseContinue(), EAthena::ChatRecv::processWhisperContinue(), and TmwAthena::ChatRecv::processWhisperContinue().
bool PlayerRelationsManager::hasPermission | ( | const std::string & | being, |
const unsigned int | flags | ||
) | const |
Definition at line 328 of file playerrelations.cpp.
References actorManager, checkPermissionSilently(), ActorManager::findBeingByName(), Being::getType(), PlayerIgnoreStrategy::ignore(), mIgnoreStrategy, and ActorType::Player.
void PlayerRelationsManager::ignoreTrade | ( | const std::string & | name | ) | const |
Definition at line 443 of file playerrelations.cpp.
References Relation::BLACKLISTED, Relation::DISREGARDED, Relation::ERASED, getRelation(), Relation::IGNORED, playerRelations, and setRelation().
Referenced by ShopWindow::action(), and RequestTradeListener::action().
void PlayerRelationsManager::init | ( | ) |
Initialise player relations manager (load config file etc.)
Definition at line 227 of file playerrelations.cpp.
References clear(), FOR_EACH, load(), mListeners, and mPersistIgnores.
Referenced by Client::stateConnectServer1().
bool PlayerRelationsManager::isGoodName | ( | Being *const | being | ) | const |
Definition at line 612 of file playerrelations.cpp.
References checkName(), Being::getGoodStatus(), Being::getName(), mRelations, Being::setGoodStatus(), and EmoteDB::size().
Referenced by ChatWindow::addWhisperTab(), TradeWindow::initTrade(), BeingPopup::show(), and Being::showName().
bool PlayerRelationsManager::isGoodName | ( | const std::string & | name | ) | const |
Definition at line 597 of file playerrelations.cpp.
References checkName(), mRelations, and EmoteDB::size().
void PlayerRelationsManager::load | ( | ) |
Load configuration from our config file, or substitute defaults.
Definition at line 201 of file playerrelations.cpp.
References CAST_S32, clear(), DEFAULT_IGNORE_STRATEGY, DEFAULT_PERMISSIONS, ConfigurationObject::getList(), getPlayerIgnoreStrategies(), getPlayerIgnoreStrategyIndex(), ConfigurationObject::getValue(), mDefaultPermissions, mPersistIgnores, mRelations, PERSIST_IGNORE_LIST, player_conf_serialiser, PLAYER_IGNORE_STRATEGY, serverConfig, and setPlayerIgnoreStrategy().
Referenced by init().
|
inline |
Definition at line 189 of file playerrelations.h.
References anonymous_namespace{itemlinkhandler.cpp}::listener, and mListeners.
Referenced by Setup_Relations::action(), Setup_Relations::~Setup_Relations(), and SocialWindow::~SocialWindow().
void PlayerRelationsManager::removePlayer | ( | const std::string & | name | ) |
Deletes the information recorded for a player.
Definition at line 408 of file playerrelations.cpp.
References mRelations, and signalUpdate().
Referenced by Setup_Relations::action(), and clear().
void PlayerRelationsManager::setDefault | ( | const unsigned int | permissions | ) |
Sets the default permissions.
Definition at line 435 of file playerrelations.cpp.
References mDefaultPermissions, signalUpdate(), and store().
Referenced by Setup_Relations::apply().
|
inline |
Change the ‘ignore persist’ flag.
value | Whether to persist ignores |
Definition at line 183 of file playerrelations.h.
References mPersistIgnores.
|
inline |
Sets the strategy to call when ignoring players.
Definition at line 138 of file playerrelations.h.
References mIgnoreStrategy.
Referenced by Setup_Relations::action(), and load().
void PlayerRelationsManager::setRelation | ( | const std::string & | name, |
const RelationT | relation | ||
) |
Updates the relationship with this player.
Definition at line 354 of file playerrelations.cpp.
References Being::getName(), localPlayer, PlayerRelation::mRelation, mRelations, Relation::NEUTRAL, signalUpdate(), and store().
Referenced by Actions::changeRelation(), ChatWindow::ignoreAllWhispers(), ignoreTrade(), and PlayerTableModel::updateModelInRow().
|
private |
Definition at line 259 of file playerrelations.cpp.
References actorManager, ActorManager::findBeingByName(), FOR_EACH, Being::getType(), mListeners, ActorType::Player, and Being::updateColors().
Referenced by removePlayer(), setDefault(), and setRelation().
void PlayerRelationsManager::store | ( | ) | const |
Save configuration to our config file.
Definition at line 241 of file playerrelations.cpp.
References DEFAULT_IGNORE_STRATEGY, DEFAULT_PERMISSIONS, mDefaultPermissions, mIgnoreStrategy, mPersistIgnores, mRelations, PlayerIgnoreStrategy::mShortName, PERSIST_IGNORE_LIST, player_conf_serialiser, PLAYER_IGNORE_STRATEGY, serverConfig, ConfigurationObject::setList(), Configuration::setValue(), and Configuration::write().
Referenced by Setup_Relations::apply(), setDefault(), and setRelation().
|
private |
Definition at line 199 of file playerrelations.h.
Referenced by checkPermissionSilently(), getDefault(), load(), setDefault(), and store().
|
private |
Definition at line 206 of file playerrelations.h.
Referenced by getPlayerIgnoreStrategies(), and ~PlayerRelationsManager().
|
private |
Definition at line 203 of file playerrelations.h.
Referenced by getPlayerIgnoreStrategy(), hasPermission(), setPlayerIgnoreStrategy(), and store().
|
private |
Definition at line 205 of file playerrelations.h.
Referenced by addListener(), init(), removeListener(), and signalUpdate().
|
private |
Definition at line 197 of file playerrelations.h.
Referenced by getPersistIgnores(), init(), load(), setPersistIgnores(), and store().
|
private |
Definition at line 204 of file playerrelations.h.
Referenced by checkPermissionSilently(), getPlayers(), getPlayersByRelation(), getRelation(), isGoodName(), load(), removePlayer(), setRelation(), store(), and ~PlayerRelationsManager().