summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2009-05-12 22:23:58 -0600
committerJared Adams <jaxad0127@gmail.com>2009-05-12 22:23:58 -0600
commit85ce3c416f6d6060c522ef6b3b5834f27f83cc5b (patch)
treec26c060c104881a8875e4141b5d42e7546864c7b
parent94716c19748ab87a0a215f05e15ad6cac1008f07 (diff)
downloadmana-client-85ce3c416f6d6060c522ef6b3b5834f27f83cc5b.tar.gz
mana-client-85ce3c416f6d6060c522ef6b3b5834f27f83cc5b.tar.bz2
mana-client-85ce3c416f6d6060c522ef6b3b5834f27f83cc5b.tar.xz
mana-client-85ce3c416f6d6060c522ef6b3b5834f27f83cc5b.zip
Fix up handling of GM status
-rw-r--r--src/gui/popupmenu.cpp21
-rw-r--r--src/gui/widgets/chattab.cpp2
-rw-r--r--src/localplayer.cpp8
-rw-r--r--src/localplayer.h2
-rw-r--r--src/net/ea/beinghandler.cpp5
-rw-r--r--src/player.cpp60
-rw-r--r--src/player.h2
7 files changed, 49 insertions, 51 deletions
diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp
index fdb8c5ac..e12ca822 100644
--- a/src/gui/popupmenu.cpp
+++ b/src/gui/popupmenu.cpp
@@ -118,9 +118,11 @@ void PopupMenu::showPopup(int x, int y, Being *being)
if (player_node->isInParty())
mBrowserBox->addRow(strprintf(_("@@party|Invite %s to join your party@@"), name.c_str()));
- /*
- mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(_("@@admin-kick|Kick player@@"));*/
+ if (player_node->isGM())
+ {
+ mBrowserBox->addRow("##3---");
+ mBrowserBox->addRow(_("@@admin-kick|Kick player@@"));
+ }
}
break;
@@ -131,13 +133,14 @@ void PopupMenu::showPopup(int x, int y, Being *being)
break;
case Being::MONSTER:
- // Monsters can be attacked
- mBrowserBox->addRow(strprintf(_("@@attack|Attack %s@@"), name.c_str()));
- break;
+ {
+ // Monsters can be attacked
+ mBrowserBox->addRow(strprintf(_("@@attack|Attack %s@@"), name.c_str()));
- /*case Being::MONSTER:
- mBrowserBox->addRow(_("@@admin-kick|Kick monster@@"));
- break;*/
+ if (player_node->isGM())
+ mBrowserBox->addRow(_("@@admin-kick|Kick monster@@"));
+ }
+ break;
default:
/* Other beings aren't interesting... */
diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp
index d55e5da8..defc06f0 100644
--- a/src/gui/widgets/chattab.cpp
+++ b/src/gui/widgets/chattab.cpp
@@ -165,7 +165,7 @@ void ChatTab::chatLog(std::string line, int own, bool ignoreRecord)
#ifdef EATHENA_SUPPORT
if (tmp.nick.empty() && tmp.text.substr(0, 17) == "Visible GM status")
{
- player_node->setGM();
+ player_node->setGM(true);
}
#endif
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index 059ccd31..24502dd1 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -236,13 +236,9 @@ void LocalPlayer::setAction(Action action, int attackType)
Player::setAction(action, attackType);
}
-void LocalPlayer::setGM()
+void LocalPlayer::setGM(bool gm)
{
- mIsGM = !mIsGM;
- mNameColor = mIsGM ?
- &guiPalette->getColor(Palette::GM) :
- &guiPalette->getColor(Palette::PLAYER);
- setName(getName());
+ mIsGM = gm;
config.setValue(getName() + "GMassert", mIsGM);
}
diff --git a/src/localplayer.h b/src/localplayer.h
index bab254ab..39f438d1 100644
--- a/src/localplayer.h
+++ b/src/localplayer.h
@@ -223,7 +223,7 @@ class LocalPlayer : public Player
/**
* Triggers whether or not to show the name as a GM name.
*/
- virtual void setGM();
+ virtual void setGM(bool gm);
void stopAttack();
diff --git a/src/net/ea/beinghandler.cpp b/src/net/ea/beinghandler.cpp
index 5a49442c..34a0d70a 100644
--- a/src/net/ea/beinghandler.cpp
+++ b/src/net/ea/beinghandler.cpp
@@ -508,8 +508,9 @@ void BeingHandler::handleMessage(MessageIn &msg)
}
gmstatus = msg.readInt16();
- if ((gmstatus & 0x80) && dstBeing->getType() == Being::PLAYER)
- static_cast<Player*>(dstBeing)->setGM();
+ if (gmstatus & 0x80)
+ if (Player *player = dynamic_cast<Player*>(dstBeing))
+ player->setGM(true);
if (msg.getId() == SMSG_PLAYER_UPDATE_1)
{
diff --git a/src/player.cpp b/src/player.cpp
index 453b8bdd..520342e3 100644
--- a/src/player.cpp
+++ b/src/player.cpp
@@ -58,44 +58,34 @@ void Player::setName(const std::string &name)
{
if (!mName && mShowName)
{
- if (mIsGM)
+ mNameColor = &guiPalette->getColor(Palette::PLAYER);
+
+ const gcn::Color *color;
+ if (this == player_node)
+ {
+ color = &guiPalette->getColor(Palette::SELF);
+ }
+ else if (mIsGM)
{
mNameColor = &guiPalette->getColor(Palette::GM);
- mName = new FlashText("(GM) " + name,
- getPixelX(),
- getPixelY(),
- gcn::Graphics::CENTER,
- &guiPalette->getColor(Palette::GM_NAME));
+ color = &guiPalette->getColor(Palette::GM_NAME);
+ }
+ else if (mInParty)
+ {
+ color = &guiPalette->getColor(Palette::PARTY);
}
else
{
- mNameColor = &guiPalette->getColor(Palette::PLAYER);
-
- const gcn::Color *color;
- if (this == player_node)
- {
- color = &guiPalette->getColor(Palette::SELF);
- }
- else if (mIsGM)
- {
- color = &guiPalette->getColor(Palette::GM);
- }
- else if (mInParty)
- {
- color = &guiPalette->getColor(Palette::PARTY);
- }
- else
- {
- color = &guiPalette->getColor(Palette::PC);
- }
-
- mName = new FlashText(name,
- getPixelX(),
- getPixelY(),
- gcn::Graphics::CENTER,
- color);
+ color = &guiPalette->getColor(Palette::PC);
}
+
+ mName = new FlashText(name,
+ getPixelX(),
+ getPixelY(),
+ gcn::Graphics::CENTER,
+ color);
}
+
Being::setName(name);
}
@@ -191,6 +181,14 @@ void Player::setGender(Gender gender)
}
}
+void Player::setGM(bool gm)
+{
+ mIsGM = gm;
+
+ if (gm && mName)
+ mName->setColor(&guiPalette->getColor(Palette::GM));
+}
+
void Player::setHairStyle(int style, int color)
{
style = style < 0 ? mHairStyle : style % mNumberOfHairstyles;
diff --git a/src/player.h b/src/player.h
index 330d0c14..bb44f462 100644
--- a/src/player.h
+++ b/src/player.h
@@ -67,7 +67,7 @@ class Player : public Being
/**
* Triggers whether or not to show the name as a GM name.
*/
- virtual void setGM() { mIsGM = true; }
+ virtual void setGM(bool gm);
/**
* Sets the hair style and color for this player.