mirror of
https://github.com/mod-playerbots/mod-playerbots.git
synced 2026-01-15 01:49:09 +00:00
performance optimize
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "TargetValue.h"
|
||||
#include "LastMovementValue.h"
|
||||
#include "ObjectGuid.h"
|
||||
#include "RtiTargetValue.h"
|
||||
#include "Playerbots.h"
|
||||
#include "ScriptedCreature.h"
|
||||
@@ -117,31 +118,24 @@ WorldPosition HomeBindValue::Calculate()
|
||||
Unit* FindTargetValue::Calculate()
|
||||
{
|
||||
if (qualifier == "") {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
Group* group = bot->GetGroup();
|
||||
if (!group) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
for (GroupReference *gref = group->GetFirstMember(); gref; gref = gref->next()) {
|
||||
Player* member = gref->GetSource();
|
||||
if (!member) {
|
||||
continue;
|
||||
}
|
||||
HostileReference *ref = member->getHostileRefMgr().getFirst();
|
||||
while (ref)
|
||||
{
|
||||
ThreatMgr *threatManager = ref->GetSource();
|
||||
Unit *unit = threatManager->GetOwner();
|
||||
std::wstring wnamepart;
|
||||
Utf8toWStr(unit->GetName(), wnamepart);
|
||||
wstrToLower(wnamepart);
|
||||
if (!qualifier.empty() && qualifier.length() == wnamepart.length() && Utf8FitTo(qualifier, wnamepart)) {
|
||||
return unit;
|
||||
}
|
||||
assert(ref);
|
||||
ref = ref->next();
|
||||
HostileReference *ref = bot->getHostileRefMgr().getFirst();
|
||||
while (ref)
|
||||
{
|
||||
ThreatMgr *threatManager = ref->GetSource();
|
||||
Unit *unit = threatManager->GetOwner();
|
||||
std::wstring wnamepart;
|
||||
Utf8toWStr(unit->GetName(), wnamepart);
|
||||
wstrToLower(wnamepart);
|
||||
if (!qualifier.empty() && qualifier.length() == wnamepart.length() && Utf8FitTo(qualifier, wnamepart)) {
|
||||
return unit;
|
||||
}
|
||||
ref = ref->next();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user