mirror of
https://github.com/mangosfour/server.git
synced 2025-12-15 10:37:02 +00:00
[10285] Use lazy computition for Guild::GetAccountsNumber
This commit is contained in:
parent
3ca05f9d4d
commit
696b8c06dc
3 changed files with 13 additions and 6 deletions
|
|
@ -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
|
* 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
|
//We use a set to be sure each element will be unique
|
||||||
std::set<uint32> accountsIdSet;
|
std::set<uint32> accountsIdSet;
|
||||||
for (MemberList::const_iterator itr = members.begin(); itr != members.end(); ++itr)
|
for (MemberList::const_iterator itr = members.begin(); itr != members.end(); ++itr)
|
||||||
accountsIdSet.insert(itr->second.accountId);
|
accountsIdSet.insert(itr->second.accountId);
|
||||||
|
|
||||||
m_accountsNumber = accountsIdSet.size();
|
m_accountsNumber = accountsIdSet.size();
|
||||||
|
|
||||||
|
return m_accountsNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
// *************************************************
|
// *************************************************
|
||||||
|
|
|
||||||
|
|
@ -327,7 +327,7 @@ class Guild
|
||||||
void SetEmblem(uint32 emblemStyle, uint32 emblemColor, uint32 borderStyle, uint32 borderColor, uint32 backgroundColor);
|
void SetEmblem(uint32 emblemStyle, uint32 emblemColor, uint32 borderStyle, uint32 borderColor, uint32 backgroundColor);
|
||||||
|
|
||||||
uint32 GetMemberSize() const { return members.size(); }
|
uint32 GetMemberSize() const { return members.size(); }
|
||||||
uint32 GetAccountsNumber() const { return m_accountsNumber; }
|
uint32 GetAccountsNumber();
|
||||||
|
|
||||||
bool LoadGuildFromDB(QueryResult *guildDataResult);
|
bool LoadGuildFromDB(QueryResult *guildDataResult);
|
||||||
bool CheckGuildStructure();
|
bool CheckGuildStructure();
|
||||||
|
|
@ -447,7 +447,7 @@ class Guild
|
||||||
uint32 m_BorderStyle;
|
uint32 m_BorderStyle;
|
||||||
uint32 m_BorderColor;
|
uint32 m_BorderColor;
|
||||||
uint32 m_BackgroundColor;
|
uint32 m_BackgroundColor;
|
||||||
uint32 m_accountsNumber;
|
uint32 m_accountsNumber; // 0 used as marker for need lazy calculation at request
|
||||||
|
|
||||||
RankList m_Ranks;
|
RankList m_Ranks;
|
||||||
|
|
||||||
|
|
@ -470,7 +470,8 @@ class Guild
|
||||||
uint64 m_GuildBankMoney;
|
uint64 m_GuildBankMoney;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void UpdateAccountsNumber();
|
void UpdateAccountsNumber() { m_accountsNumber = 0;}// mark for lazy calculation at request in GetAccountsNumber
|
||||||
|
|
||||||
// used only from high level Swap/Move functions
|
// used only from high level Swap/Move functions
|
||||||
Item* GetItem(uint8 TabId, uint8 SlotId);
|
Item* GetItem(uint8 TabId, uint8 SlotId);
|
||||||
uint8 CanStoreItem( uint8 tab, uint8 slot, GuildItemPosCountVec& dest, uint32 count, Item *pItem, bool swap = false) const;
|
uint8 CanStoreItem( uint8 tab, uint8 slot, GuildItemPosCountVec& dest, uint32 count, Item *pItem, bool swap = false) const;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "10284"
|
#define REVISION_NR "10285"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue