Made code a bit more efficient

deque
Thomas 11 years ago
parent 203ef580cf
commit 58bf7624be

@ -29,7 +29,7 @@ bool MWMechanics::AiActivate::execute (const MWWorld::Ptr& actor,float duration)
//Set the target desition from the actor
ESM::Pathgrid::Point dest = target.getRefData().getPosition().pos;
if(distance(dest, pos.pos[0], pos.pos[1], pos.pos[2]) < 200 || mPathFinder.checkPathCompleted(pos.pos[0], pos.pos[1], pos.pos[2])) { //Stop when you get close
if(distance(dest, pos.pos[0], pos.pos[1], pos.pos[2]) < 200) { //Stop when you get close
actor.getClass().getMovementSettings(actor).mPosition[1] = 0;
MWWorld::Ptr target = MWBase::Environment::get().getWorld()->getPtr(mObjectId,false);
MWWorld::Class::get(target).activate(target,actor).get()->execute(actor); //Arrest player

@ -29,7 +29,7 @@ namespace MWMechanics
private:
float mDuration;
MWWorld::Ptr mDoorPtr;
const MWWorld::Ptr& mDoorPtr;
};
}
#endif

@ -96,7 +96,7 @@ bool MWMechanics::AiPackage::pathTo(const MWWorld::Ptr& actor, ESM::Pathgrid::Po
if(door != NULL) // NOTE: checks interior cells only
{
if(door->mRef.mTrap.empty() && mLastDoorChecked != door) { //Open the door if untrapped
door->mClass->activate(MWBase::Environment::get().getWorld()->getPtr(door->mRef.mRefID,false), actor).get()->execute(actor);
door->mClass->activate(MWWorld::Ptr(door, actor.getCell()), actor).get()->execute(actor);
mLastDoorChecked = door;
}
}

@ -1863,12 +1863,8 @@ namespace MWWorld
bool World::getIsMovingDoor(const Ptr& door)
{
//This more expensive comparison is needed for some reason
// TODO (tluppi#1#): Figure out why comparing Ptr isn't working
for(std::map<MWWorld::Ptr, int>::iterator it = mDoorStates.begin(); it != mDoorStates.end(); it++)
if(it->first.getCellRef().mRefID == door.getCellRef().mRefID)
return true;
return false;
bool result = mDoorStates.find(door) != mDoorStates.end();
return result;
}
bool World::getPlayerStandingOn (const MWWorld::Ptr& object)

Loading…
Cancel
Save