mirror of
https://github.com/mangosfour/server.git
synced 2025-12-16 04:37:00 +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
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
// *************************************************
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue