[10285] Use lazy computition for Guild::GetAccountsNumber

This commit is contained in:
VladimirMangos 2010-07-29 22:30:44 +04:00
parent 3ca05f9d4d
commit 696b8c06dc
3 changed files with 13 additions and 6 deletions

View file

@ -822,17 +822,23 @@ void Guild::UpdateLogoutTime(uint64 guid)
}
/**
* Updates the number of accounts that are in the guild
* Return the number of accounts that are in the guild after possible update if required
* A player may have many characters in the guild, but with the same account
*/
void Guild::UpdateAccountsNumber()
uint32 Guild::GetAccountsNumber()
{
// not need recalculation
if (m_accountsNumber)
return m_accountsNumber;
//We use a set to be sure each element will be unique
std::set<uint32> accountsIdSet;
for (MemberList::const_iterator itr = members.begin(); itr != members.end(); ++itr)
accountsIdSet.insert(itr->second.accountId);
m_accountsNumber = accountsIdSet.size();
return m_accountsNumber;
}
// *************************************************

View file

@ -327,7 +327,7 @@ class Guild
void SetEmblem(uint32 emblemStyle, uint32 emblemColor, uint32 borderStyle, uint32 borderColor, uint32 backgroundColor);
uint32 GetMemberSize() const { return members.size(); }
uint32 GetAccountsNumber() const { return m_accountsNumber; }
uint32 GetAccountsNumber();
bool LoadGuildFromDB(QueryResult *guildDataResult);
bool CheckGuildStructure();
@ -447,7 +447,7 @@ class Guild
uint32 m_BorderStyle;
uint32 m_BorderColor;
uint32 m_BackgroundColor;
uint32 m_accountsNumber;
uint32 m_accountsNumber; // 0 used as marker for need lazy calculation at request
RankList m_Ranks;
@ -470,7 +470,8 @@ class Guild
uint64 m_GuildBankMoney;
private:
void UpdateAccountsNumber();
void UpdateAccountsNumber() { m_accountsNumber = 0;}// mark for lazy calculation at request in GetAccountsNumber
// used only from high level Swap/Move functions
Item* GetItem(uint8 TabId, uint8 SlotId);
uint8 CanStoreItem( uint8 tab, uint8 slot, GuildItemPosCountVec& dest, uint32 count, Item *pItem, bool swap = false) const;

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "10284"
#define REVISION_NR "10285"
#endif // __REVISION_NR_H__