mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 22:37:03 +00:00
[7282] Store guilds in map for fast search by id, some other guild/arenateam related cleanups.
Signed-off-by: VladimirMangos <vladimir@getmangos.com>
This commit is contained in:
parent
1fb8a52032
commit
cdfee0fdfc
5 changed files with 51 additions and 39 deletions
|
|
@ -170,8 +170,9 @@ ObjectMgr::~ObjectMgr()
|
|||
// free group and guild objects
|
||||
for (GroupSet::iterator itr = mGroupSet.begin(); itr != mGroupSet.end(); ++itr)
|
||||
delete (*itr);
|
||||
for (GuildSet::iterator itr = mGuildSet.begin(); itr != mGuildSet.end(); ++itr)
|
||||
delete (*itr);
|
||||
|
||||
for (GuildMap::iterator itr = mGuildMap.begin(); itr != mGuildMap.end(); ++itr)
|
||||
delete itr->second;
|
||||
|
||||
for (CacheVendorItemMap::iterator itr = m_mCacheVendorItemMap.begin(); itr != m_mCacheVendorItemMap.end(); ++itr)
|
||||
itr->second.Clear();
|
||||
|
|
@ -189,43 +190,53 @@ Group * ObjectMgr::GetGroupByLeader(const uint64 &guid) const
|
|||
return NULL;
|
||||
}
|
||||
|
||||
Guild * ObjectMgr::GetGuildById(const uint32 GuildId) const
|
||||
Guild * ObjectMgr::GetGuildById(uint32 GuildId) const
|
||||
{
|
||||
for(GuildSet::const_iterator itr = mGuildSet.begin(); itr != mGuildSet.end(); ++itr)
|
||||
if ((*itr)->GetId() == GuildId)
|
||||
return *itr;
|
||||
GuildMap::const_iterator itr = mGuildMap.find(GuildId);
|
||||
if (itr != mGuildMap.end())
|
||||
return itr->second;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Guild * ObjectMgr::GetGuildByName(const std::string& guildname) const
|
||||
{
|
||||
for(GuildSet::const_iterator itr = mGuildSet.begin(); itr != mGuildSet.end(); ++itr)
|
||||
if ((*itr)->GetName() == guildname)
|
||||
return *itr;
|
||||
for(GuildMap::const_iterator itr = mGuildMap.begin(); itr != mGuildMap.end(); ++itr)
|
||||
if (itr->second->GetName() == guildname)
|
||||
return itr->second;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
std::string ObjectMgr::GetGuildNameById(const uint32 GuildId) const
|
||||
std::string ObjectMgr::GetGuildNameById(uint32 GuildId) const
|
||||
{
|
||||
for(GuildSet::const_iterator itr = mGuildSet.begin(); itr != mGuildSet.end(); ++itr)
|
||||
if ((*itr)->GetId() == GuildId)
|
||||
return (*itr)->GetName();
|
||||
GuildMap::const_iterator itr = mGuildMap.find(GuildId);
|
||||
if (itr != mGuildMap.end())
|
||||
return itr->second->GetName();
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
Guild* ObjectMgr::GetGuildByLeader(const uint64 &guid) const
|
||||
{
|
||||
for(GuildSet::const_iterator itr = mGuildSet.begin(); itr != mGuildSet.end(); ++itr)
|
||||
if( (*itr)->GetLeader() == guid)
|
||||
return *itr;
|
||||
for(GuildMap::const_iterator itr = mGuildMap.begin(); itr != mGuildMap.end(); ++itr)
|
||||
if (itr->second->GetLeader() == guid)
|
||||
return itr->second;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ArenaTeam* ObjectMgr::GetArenaTeamById(const uint32 arenateamid) const
|
||||
void ObjectMgr::AddGuild(Guild* guild)
|
||||
{
|
||||
mGuildMap[guild->GetId()] = guild;
|
||||
}
|
||||
|
||||
void ObjectMgr::RemoveGuild(uint32 Id)
|
||||
{
|
||||
mGuildMap.erase(Id);
|
||||
}
|
||||
|
||||
ArenaTeam* ObjectMgr::GetArenaTeamById(uint32 arenateamid) const
|
||||
{
|
||||
ArenaTeamMap::const_iterator itr = mArenaTeamMap.find(arenateamid);
|
||||
if (itr != mArenaTeamMap.end())
|
||||
|
|
@ -257,9 +268,9 @@ void ObjectMgr::AddArenaTeam(ArenaTeam* arenaTeam)
|
|||
mArenaTeamMap[arenaTeam->GetId()] = arenaTeam;
|
||||
}
|
||||
|
||||
void ObjectMgr::RemoveArenaTeam(ArenaTeam* arenaTeam)
|
||||
void ObjectMgr::RemoveArenaTeam(uint32 Id)
|
||||
{
|
||||
mArenaTeamMap.erase( arenaTeam->GetId() );
|
||||
mArenaTeamMap.erase(Id);
|
||||
}
|
||||
|
||||
CreatureInfo const* ObjectMgr::GetCreatureTemplate(uint32 id)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue