summaryrefslogtreecommitdiff
path: root/src/being.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-07-08 04:14:42 +0300
committerAndrei Karas <akaras@inbox.ru>2011-07-08 04:14:42 +0300
commitcf2a07dfaeae3620c4e97b660b1021f1ff1b4832 (patch)
tree6ca8dbb6267a4e8ced55d73d5647d6018a47ce35 /src/being.cpp
parenta88d005220997d4c66d3a97ae8fd857a7dd3c307 (diff)
downloadmanaplus-cf2a07dfaeae3620c4e97b660b1021f1ff1b4832.tar.gz
manaplus-cf2a07dfaeae3620c4e97b660b1021f1ff1b4832.tar.bz2
manaplus-cf2a07dfaeae3620c4e97b660b1021f1ff1b4832.tar.xz
manaplus-cf2a07dfaeae3620c4e97b660b1021f1ff1b4832.zip
Add to caching players statuses.
Diffstat (limited to 'src/being.cpp')
-rw-r--r--src/being.cpp46
1 files changed, 44 insertions, 2 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