mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-16 17:41:29 +00:00
Optimize EntityList::RemoveGroup/RemoveRaid
lambdas are cheating btw.
This commit is contained in:
parent
4c9653d204
commit
c33973f20a
@ -2251,44 +2251,30 @@ bool EntityList::RemoveCorpse(uint16 delete_id)
|
|||||||
|
|
||||||
bool EntityList::RemoveGroup(uint32 delete_id)
|
bool EntityList::RemoveGroup(uint32 delete_id)
|
||||||
{
|
{
|
||||||
std::list<Group *>::iterator iterator;
|
auto it = std::find_if(group_list.begin(), group_list.end(),
|
||||||
|
[delete_id](const Group *a) { return a->GetID() == delete_id; });
|
||||||
iterator = group_list.begin();
|
if (it == group_list.end()) {
|
||||||
|
|
||||||
while(iterator != group_list.end())
|
|
||||||
{
|
|
||||||
if((*iterator)->GetID() == delete_id) {
|
|
||||||
group_list.remove(*iterator);
|
|
||||||
delete *iterator;
|
|
||||||
#if EQDEBUG >= 5
|
|
||||||
CheckGroupList (__FILE__, __LINE__);
|
|
||||||
#endif
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
++iterator;
|
|
||||||
}
|
|
||||||
#if EQDEBUG >= 5
|
#if EQDEBUG >= 5
|
||||||
CheckGroupList (__FILE__, __LINE__);
|
CheckGroupList (__FILE__, __LINE__);
|
||||||
#endif
|
#endif
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
auto group = *it;
|
||||||
|
group_list.erase(it);
|
||||||
|
delete group;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EntityList::RemoveRaid(uint32 delete_id)
|
bool EntityList::RemoveRaid(uint32 delete_id)
|
||||||
{
|
{
|
||||||
std::list<Raid *>::iterator iterator;
|
auto it = std::find_if(raid_list.begin(), raid_list.end(),
|
||||||
|
[delete_id](const Raid *a) { return a->GetID() == delete_id; });
|
||||||
iterator = raid_list.begin();
|
if (it == raid_list.end())
|
||||||
|
|
||||||
while(iterator != raid_list.end())
|
|
||||||
{
|
|
||||||
if((*iterator)->GetID() == delete_id) {
|
|
||||||
raid_list.remove(*iterator);
|
|
||||||
delete *iterator;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
++iterator;
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
|
auto raid = *it;
|
||||||
|
raid_list.erase(it);
|
||||||
|
delete raid;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityList::Clear()
|
void EntityList::Clear()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user