diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-07-08 04:14:42 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-07-08 04:14:42 +0300 |
commit | cf2a07dfaeae3620c4e97b660b1021f1ff1b4832 (patch) | |
tree | 6ca8dbb6267a4e8ced55d73d5647d6018a47ce35 | |
parent | a88d005220997d4c66d3a97ae8fd857a7dd3c307 (diff) | |
download | mv-cf2a07dfaeae3620c4e97b660b1021f1ff1b4832.tar.gz mv-cf2a07dfaeae3620c4e97b660b1021f1ff1b4832.tar.bz2 mv-cf2a07dfaeae3620c4e97b660b1021f1ff1b4832.tar.xz mv-cf2a07dfaeae3620c4e97b660b1021f1ff1b4832.zip |
Add to caching players statuses.
-rw-r--r-- | src/being.cpp | 46 | ||||
-rw-r--r-- | src/being.h | 2 |
2 files changed, 45 insertions, 3 deletions
diff --git a/src/being.cpp b/src/being.cpp index 25ae64211..0b4ac3ccd 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -101,7 +101,8 @@ class BeingCacheEntry mPvpRank(0), mTime(0), mIp(""), - mIsAdvanced(false) + mIsAdvanced(false), + mFlags(0) { } @@ -161,6 +162,12 @@ class BeingCacheEntry void setAdvanced(bool a) { mIsAdvanced = a; } + int getFlags() const + { return mFlags; } + + void setFlags(int flags) + { mFlags = flags; } + protected: int mId; /**< Unique sprite id */ std::string mName; /**< Name of character */ @@ -170,6 +177,7 @@ class BeingCacheEntry int mTime; std::string mIp; bool mIsAdvanced; + int mFlags; }; @@ -1759,7 +1767,23 @@ bool Being::updateFromCache() setPvpRank(entry->getPvpRank()); setIp(entry->getIp()); - setAdvanced(entry->isAdvanced()); + mAdvanced = entry->isAdvanced(); + if (entry->isAdvanced()) + { + int flags = entry->getFlags(); + mShop = (flags & FLAG_SHOP); + mAway = (flags & FLAG_AWAY); + mInactive = (flags & FLAG_INACTIVE); + if (mShop || mAway || mInactive) + updateName(); + } + else + { + mShop = false; + mAway = false; + mInactive = false; + } + if (mType == PLAYER) updateColors(); return true; @@ -1791,6 +1815,21 @@ void Being::addToCache() entry->setPvpRank(getPvpRank()); entry->setIp(getIp()); entry->setAdvanced(isAdvanced()); + if (isAdvanced()) + { + int flags = 0; + if (mShop) + flags += FLAG_SHOP; + if (mAway) + flags += FLAG_AWAY; + if (mInactive) + flags += FLAG_INACTIVE; + entry->setFlags(flags); + } + else + { + entry->setFlags(0); + } } BeingCacheEntry* Being::getCacheEntry(int id) @@ -2345,7 +2384,10 @@ void Being::setEmote(Uint8 emotion, int emote_time) mInactive = inactive; if (needUpdate) + { updateName(); + addToCache(); + } // logger->log("flags: %d", emotion - FLAG_SPECIAL); } else diff --git a/src/being.h b/src/being.h index 143f3eec5..a496121e8 100644 --- a/src/being.h +++ b/src/being.h @@ -750,7 +750,7 @@ class Being : public ActorSprite, public ConfigListener { return mAdvanced; } void setAdvanced(bool n) - { mAdvanced = n; } + { mAdvanced = n; addToCache();} bool isShopEnabled() { return mShop; } |