From 91242cdfe50922e7258a04743bd940956c0453da Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Sun, 3 May 2009 11:31:39 +0200 Subject: Moved mIsGM from Being to Player and made isGM() const --- src/being.cpp | 1 - src/being.h | 6 ------ src/gui/minimap.cpp | 4 ++-- src/net/ea/beinghandler.cpp | 4 ++-- src/player.cpp | 8 +++++--- src/player.h | 15 +++++++++++---- 6 files changed, 20 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/being.cpp b/src/being.cpp index d4242df0..d719635b 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -87,7 +87,6 @@ Being::Being(int id, int job, Map *map): mSpriteDirection(DIRECTION_DOWN), #endif mMap(NULL), - mIsGM(false), mParticleEffects(config.getValue("particleeffects", 1)), mEquippedWeapon(NULL), #ifdef TMWSERV_SUPPORT diff --git a/src/being.h b/src/being.h index daedcf33..a870ff0b 100644 --- a/src/being.h +++ b/src/being.h @@ -286,11 +286,6 @@ class Being : public Sprite virtual void nextStep(); #endif - /** - * Triggers whether or not to show the name as a GM name. - */ - virtual void setGM() { mIsGM = true; } - /** * Performs being logic. */ @@ -568,7 +563,6 @@ class Being : public Sprite Map *mMap; /**< Map on which this being resides */ std::string mName; /**< Name of character */ SpriteIterator mSpriteIterator; - bool mIsGM; bool mParticleEffects; /**< Whether to display particles or not */ /** Engine-related infos about weapon. */ diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp index b4a70d18..bae599a8 100644 --- a/src/gui/minimap.cpp +++ b/src/gui/minimap.cpp @@ -170,7 +170,7 @@ void Minimap::draw(gcn::Graphics *graphics) for (Beings::const_iterator bi = beings.begin(), bi_end = beings.end(); bi != bi_end; ++bi) { - Being *being = (*bi); + const Being *being = (*bi); int dotSize = 2; switch (being->getType()) @@ -185,7 +185,7 @@ void Minimap::draw(gcn::Graphics *graphics) dotSize = 3; } - if (static_cast(being)->isGM()) + if (static_cast(being)->isGM()) type = Palette::GM_NAME; graphics->setColor(guiPalette->getColor(type)); diff --git a/src/net/ea/beinghandler.cpp b/src/net/ea/beinghandler.cpp index 1f5f79c7..29ed733a 100644 --- a/src/net/ea/beinghandler.cpp +++ b/src/net/ea/beinghandler.cpp @@ -503,8 +503,8 @@ void BeingHandler::handleMessage(MessageIn &msg) } gmstatus = msg.readInt16(); - if (gmstatus & 0x80) - dstBeing->setGM(); + if ((gmstatus & 0x80) && dstBeing->getType() == Being::PLAYER) + static_cast(dstBeing)->setGM(); if (msg.getId() == SMSG_PLAYER_UPDATE_1) { diff --git a/src/player.cpp b/src/player.cpp index e1dc3806..d082719a 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -38,9 +38,11 @@ #include "utils/strprintf.h" Player::Player(int id, int job, Map *map): - Being(id, job, map) + Being(id, job, map), + mName(0), + mIsGM(false), + mInParty(false) { - mName = NULL; } Player::~Player() @@ -50,7 +52,7 @@ Player::~Player() void Player::setName(const std::string &name) { - if (mName == NULL) + if (!mName) { if (mIsGM) { diff --git a/src/player.h b/src/player.h index 53b70b1d..dfcca310 100644 --- a/src/player.h +++ b/src/player.h @@ -62,7 +62,12 @@ class Player : public Being /** * Whether or not this player is a GM. */ - bool isGM() { return mIsGM; } + bool isGM() const { return mIsGM; } + + /** + * Triggers whether or not to show the name as a GM name. + */ + virtual void setGM() { mIsGM = true; } /** * Sets the hair style and color for this player. @@ -90,7 +95,7 @@ class Player : public Being /** * Adds a guild to the player. */ - Guild* addGuild(short guildId, short rights); + Guild *addGuild(short guildId, short rights); /** * Removers a guild from the player. @@ -100,12 +105,12 @@ class Player : public Being /** * Returns a pointer to the specified guild. */ - Guild* getGuild(const std::string &guildName); + Guild *getGuild(const std::string &guildName); /** * Returns a pointer to the guild with matching id. */ - Guild* getGuild(int id); + Guild *getGuild(int id); /** * Get number of guilds the player belongs to. @@ -146,6 +151,8 @@ class Player : public Being FlashText *mName; + bool mIsGM; + private: bool mInParty; }; -- cgit v1.2.3-70-g09d2