From 707a1570df9146c42411afb6dd7b2e9bc11b0251 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 12 May 2014 17:29:22 +0300 Subject: Move being flags into separate file. --- src/CMakeLists.txt | 1 + src/Makefile.am | 1 + src/being/being.cpp | 20 ++++++++++---------- src/being/being.h | 12 +----------- src/being/beingflag.h | 37 +++++++++++++++++++++++++++++++++++++ src/being/localplayer.cpp | 14 +++++++------- src/gui/windows/whoisonline.cpp | 10 +++++----- src/net/tmwa/playerhandler.cpp | 4 ++-- 8 files changed, 64 insertions(+), 35 deletions(-) create mode 100644 src/being/beingflag.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e914fbb14..d98772322 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -625,6 +625,7 @@ SET(SRCS being/being.h being/beingcacheentry.h being/beingdirection.h + being/beingflag.h beingequipbackend.cpp beingequipbackend.h spellmanager.cpp diff --git a/src/Makefile.am b/src/Makefile.am index ff3d1dc85..5e6b6db6e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -714,6 +714,7 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ being/being.h \ being/beingcacheentry.h \ being/beingdirection.h \ + being/beingflag.h \ beingequipbackend.cpp \ beingequipbackend.h \ spellmanager.cpp \ diff --git a/src/being/being.cpp b/src/being/being.cpp index e06190623..0e06d45fd 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -2167,9 +2167,9 @@ bool Being::updateFromCache() if (mAdvanced) { const int flags = entry->getFlags(); - mShop = ((flags & FLAG_SHOP) != 0); - mAway = ((flags & FLAG_AWAY) != 0); - mInactive = ((flags & FLAG_INACTIVE) != 0); + mShop = ((flags & BeingFlag::SHOP) != 0); + mAway = ((flags & BeingFlag::AWAY) != 0); + mInactive = ((flags & BeingFlag::INACTIVE) != 0); if (mShop || mAway || mInactive) updateName(); } @@ -2220,11 +2220,11 @@ void Being::addToCache() const { int flags = 0; if (mShop) - flags += FLAG_SHOP; + flags += BeingFlag::SHOP; if (mAway) - flags += FLAG_AWAY; + flags += BeingFlag::AWAY; if (mInactive) - flags += FLAG_INACTIVE; + flags += BeingFlag::INACTIVE; entry->setFlags(flags); } else @@ -2916,9 +2916,9 @@ void Being::saveComment(const std::string &restrict name, void Being::setState(const uint8_t state) { - const bool shop = ((state & FLAG_SHOP) != 0); - const bool away = ((state & FLAG_AWAY) != 0); - const bool inactive = ((state & FLAG_INACTIVE) != 0); + const bool shop = ((state & BeingFlag::SHOP) != 0); + const bool away = ((state & BeingFlag::AWAY) != 0); + const bool inactive = ((state & BeingFlag::INACTIVE) != 0); const bool needUpdate = (shop != mShop || away != mAway || inactive != mInactive); @@ -2938,7 +2938,7 @@ void Being::setState(const uint8_t state) void Being::setEmote(const uint8_t emotion, const int emote_time) { - if ((emotion & FLAG_SPECIAL) == FLAG_SPECIAL) + if ((emotion & BeingFlag::SPECIAL) == BeingFlag::SPECIAL) { setState(emotion); mAdvanced = true; diff --git a/src/being/being.h b/src/being/being.h index c476e45b3..4de35303f 100644 --- a/src/being/being.h +++ b/src/being/being.h @@ -30,6 +30,7 @@ #include "listeners/configlistener.h" #include "being/beingdirection.h" +#include "being/beingflag.h" #include "being/gender.h" #include @@ -84,17 +85,6 @@ class Being : public ActorSprite, public ConfigListener friend class BeingEquipBackend; friend class LocalPlayer; - enum FLAGS - { - FLAG_SHOP = 1, - FLAG_AWAY = 2, - FLAG_INACTIVE = 4, - FLAG_GENDER_OTHER = 32, - FLAG_GM = 64, - FLAG_GENDER_MALE = 128, - FLAG_SPECIAL = 128 + 64 - }; - /** * Action the being is currently performing * WARNING: Has to be in sync with the same enum in the Being class diff --git a/src/being/beingflag.h b/src/being/beingflag.h new file mode 100644 index 000000000..9c9a76ef4 --- /dev/null +++ b/src/being/beingflag.h @@ -0,0 +1,37 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef BEING_BEINGFLAG_H +#define BEING_BEINGFLAG_H + +namespace BeingFlag +{ + enum + { + SHOP = 1, + AWAY = 2, + INACTIVE = 4, + GENDER_OTHER = 32, + GM = 64, + GENDER_MALE = 128, + SPECIAL = 128 + 64 + }; +} +#endif // BEING_BEINGFLAG_H diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp index 283024243..800cd10a8 100644 --- a/src/being/localplayer.cpp +++ b/src/being/localplayer.cpp @@ -342,15 +342,15 @@ void LocalPlayer::slowLogic() if (serverVersion < 4 && mEnableAdvert && !mBlockAdvert && mAdvertTime < cur_time) { - uint8_t smile = FLAG_SPECIAL; + uint8_t smile = BeingFlag::SPECIAL; if (mTradebot && shopWindow && !shopWindow->isShopEmpty()) - smile |= FLAG_SHOP; + smile |= BeingFlag::SHOP; if (mAwayMode || mPseudoAwayMode) - smile |= FLAG_AWAY; + smile |= BeingFlag::AWAY; if (mInactive) - smile |= FLAG_INACTIVE; + smile |= BeingFlag::INACTIVE; if (emote(smile)) mAdvertTime = time + 60; @@ -3782,13 +3782,13 @@ void LocalPlayer::updateStatus() const { uint8_t status = 0; if (mTradebot && shopWindow && !shopWindow->isShopEmpty()) - status |= FLAG_SHOP; + status |= BeingFlag::SHOP; if (mAwayMode || mPseudoAwayMode) - status |= FLAG_AWAY; + status |= BeingFlag::AWAY; if (mInactive) - status |= FLAG_INACTIVE; + status |= BeingFlag::INACTIVE; Net::getPlayerHandler()->updateStatus(status); } diff --git a/src/gui/windows/whoisonline.cpp b/src/gui/windows/whoisonline.cpp index c417e6b37..38ddcf806 100644 --- a/src/gui/windows/whoisonline.cpp +++ b/src/gui/windows/whoisonline.cpp @@ -818,7 +818,7 @@ void OnlinePlayer::setText(std::string color) } } - if ((mStatus != 255 && mStatus & Being::FLAG_GM) || mIsGM) + if ((mStatus != 255 && mStatus & BeingFlag::GM) || mIsGM) mText.append("(GM) "); if (mLevel > 0) @@ -831,20 +831,20 @@ void OnlinePlayer::setText(std::string color) if (mStatus > 0 && mStatus != 255) { - if (mStatus & Being::FLAG_SHOP) + if (mStatus & BeingFlag::SHOP) mText.append("$"); - if (mStatus & Being::FLAG_AWAY) + if (mStatus & BeingFlag::AWAY) { // TRANSLATORS: this away status writed in player nick mText.append(_("A")); } - if (mStatus & Being::FLAG_INACTIVE) + if (mStatus & BeingFlag::INACTIVE) { // TRANSLATORS: this inactive status writed in player nick mText.append(_("I")); } - if (mStatus & Being::FLAG_GM && color == "0") + if (mStatus & BeingFlag::GM && color == "0") color = "2"; } else if (mIsGM && color == "0") diff --git a/src/net/tmwa/playerhandler.cpp b/src/net/tmwa/playerhandler.cpp index e844720c3..f9a8580df 100644 --- a/src/net/tmwa/playerhandler.cpp +++ b/src/net/tmwa/playerhandler.cpp @@ -288,9 +288,9 @@ void PlayerHandler::processOnlineList(Net::MessageIn &msg) { if (config.getBoolValue("showgender")) { - if (status & Being::FLAG_GENDER_MALE) + if (status & BeingFlag::GENDER_MALE) gender = GENDER_MALE; - else if (status & Being::FLAG_GENDER_OTHER) + else if (status & BeingFlag::GENDER_OTHER) gender = GENDER_OTHER; else gender = GENDER_FEMALE; -- cgit v1.2.3-60-g2f50