1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-31 01:45:34 +00:00

Make some more optimizations to actor processing loops

This commit is contained in:
Capostrophic 2018-08-21 17:02:56 +03:00
parent b77d733c3e
commit 910065f38f

View file

@ -1782,6 +1782,8 @@ namespace MWMechanics
if (iteratedActor == getPlayer()) if (iteratedActor == getPlayer())
continue; continue;
const bool sameActor = (iteratedActor == actor);
const CreatureStats &stats = iteratedActor.getClass().getCreatureStats(iteratedActor); const CreatureStats &stats = iteratedActor.getClass().getCreatureStats(iteratedActor);
if (stats.isDead()) if (stats.isDead())
continue; continue;
@ -1792,7 +1794,7 @@ namespace MWMechanics
{ {
if ((*package)->sideWithTarget() && !(*package)->getTarget().isEmpty()) if ((*package)->sideWithTarget() && !(*package)->getTarget().isEmpty())
{ {
if (iteratedActor == actor) if (sameActor)
{ {
list.push_back((*package)->getTarget()); list.push_back((*package)->getTarget());
} }
@ -1815,7 +1817,7 @@ namespace MWMechanics
for(PtrActorMap::iterator iter(mActors.begin());iter != mActors.end();++iter) for(PtrActorMap::iterator iter(mActors.begin());iter != mActors.end();++iter)
{ {
const MWWorld::Ptr &iteratedActor = iter->first; const MWWorld::Ptr &iteratedActor = iter->first;
if (iteratedActor == getPlayer()) if (iteratedActor == getPlayer() || iteratedActor == actor)
continue; continue;
const CreatureStats &stats = iteratedActor.getClass().getCreatureStats(iteratedActor); const CreatureStats &stats = iteratedActor.getClass().getCreatureStats(iteratedActor);
@ -1878,7 +1880,7 @@ namespace MWMechanics
for(PtrActorMap::iterator iter(mActors.begin());iter != mActors.end();++iter) for(PtrActorMap::iterator iter(mActors.begin());iter != mActors.end();++iter)
{ {
const MWWorld::Ptr &iteratedActor = iter->first; const MWWorld::Ptr &iteratedActor = iter->first;
if (iteratedActor == getPlayer()) if (iteratedActor == getPlayer() || iteratedActor == actor)
continue; continue;
const CreatureStats &stats = iteratedActor.getClass().getCreatureStats(iteratedActor); const CreatureStats &stats = iteratedActor.getClass().getCreatureStats(iteratedActor);
@ -1908,8 +1910,11 @@ namespace MWMechanics
getObjectsInRange(position, aiProcessingDistance, neighbors); getObjectsInRange(position, aiProcessingDistance, neighbors);
for(auto neighbor = neighbors.begin(); neighbor != neighbors.end(); ++neighbor) for(auto neighbor = neighbors.begin(); neighbor != neighbors.end(); ++neighbor)
{ {
if (*neighbor == actor)
continue;
const CreatureStats &stats = neighbor->getClass().getCreatureStats(*neighbor); const CreatureStats &stats = neighbor->getClass().getCreatureStats(*neighbor);
if (stats.isDead() || *neighbor == actor) if (stats.isDead())
continue; continue;
if (stats.getAiSequence().isInCombat(actor)) if (stats.getAiSequence().isInCombat(actor))