summaryrefslogtreecommitdiff
path: root/src/player.cpp
diff options
context:
space:
mode:
authorChuck Miller <shadowmil@gmail.com>2009-05-05 18:37:34 -0400
committerChuck Miller <shadowmil@gmail.com>2009-05-05 18:37:34 -0400
commitbff134a0803f68a7bf69cf2f1121824137d4b2fb (patch)
tree45e069c4cb90fdf8c8c9f6ac297941d69d09e108 /src/player.cpp
parent5a9759680427154f379499cb3268f307bb860c22 (diff)
downloadmana-bff134a0803f68a7bf69cf2f1121824137d4b2fb.tar.gz
mana-bff134a0803f68a7bf69cf2f1121824137d4b2fb.tar.bz2
mana-bff134a0803f68a7bf69cf2f1121824137d4b2fb.tar.xz
mana-bff134a0803f68a7bf69cf2f1121824137d4b2fb.zip
Moved code for hiding / showing player names from Player::logic() to a the configure listener system
Diffstat (limited to 'src/player.cpp')
-rw-r--r--src/player.cpp31
1 files changed, 19 insertions, 12 deletions
diff --git a/src/player.cpp b/src/player.cpp
index 14a9c97f..abc01152 100644
--- a/src/player.cpp
+++ b/src/player.cpp
@@ -44,10 +44,12 @@ Player::Player(int id, int job, Map *map):
mIsGM(false),
mInParty(false)
{
+ config.addListener("visiblenames", this);
}
Player::~Player()
{
+ config.removeListener("visiblenames", this);
delete mName;
}
@@ -135,18 +137,6 @@ void Player::logic()
break;
}
- if (getType() == Being::PLAYER && player_node != this)
- {
- if (!config.getValue("visiblenames", 1) && mName)
- {
- delete mName;
- mName = NULL;
- }
- else if (config.getValue("visiblenames", 1) && !mName && !(getName().empty()))
- {
- setName(getName());
- }
- }
Being::logic();
}
#endif
@@ -296,3 +286,20 @@ void Player::setInParty(bool value)
{
mInParty = value;
}
+
+void Player::optionChanged(const std::string &value)
+{
+ if (value == "visiblenames" && getType() == Being::PLAYER && player_node != this)
+ {
+ bool value = config.getValue("visiblenames", 1);
+ if (!value && mName)
+ {
+ delete mName;
+ mName = NULL;
+ }
+ else if (value && !mName && !(getName().empty()))
+ {
+ setName(getName());
+ }
+ }
+}