mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-04-01 10:36:42 +00:00
Made code a bit more efficient
This commit is contained in:
parent
203ef580cf
commit
58bf7624be
4 changed files with 5 additions and 9 deletions
|
@ -29,7 +29,7 @@ bool MWMechanics::AiActivate::execute (const MWWorld::Ptr& actor,float duration)
|
||||||
//Set the target desition from the actor
|
//Set the target desition from the actor
|
||||||
ESM::Pathgrid::Point dest = target.getRefData().getPosition().pos;
|
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;
|
actor.getClass().getMovementSettings(actor).mPosition[1] = 0;
|
||||||
MWWorld::Ptr target = MWBase::Environment::get().getWorld()->getPtr(mObjectId,false);
|
MWWorld::Ptr target = MWBase::Environment::get().getWorld()->getPtr(mObjectId,false);
|
||||||
MWWorld::Class::get(target).activate(target,actor).get()->execute(actor); //Arrest player
|
MWWorld::Class::get(target).activate(target,actor).get()->execute(actor); //Arrest player
|
||||||
|
|
|
@ -29,7 +29,7 @@ namespace MWMechanics
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float mDuration;
|
float mDuration;
|
||||||
MWWorld::Ptr mDoorPtr;
|
const MWWorld::Ptr& mDoorPtr;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif
|
#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 != NULL) // NOTE: checks interior cells only
|
||||||
{
|
{
|
||||||
if(door->mRef.mTrap.empty() && mLastDoorChecked != door) { //Open the door if untrapped
|
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;
|
mLastDoorChecked = door;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1863,12 +1863,8 @@ namespace MWWorld
|
||||||
|
|
||||||
bool World::getIsMovingDoor(const Ptr& door)
|
bool World::getIsMovingDoor(const Ptr& door)
|
||||||
{
|
{
|
||||||
//This more expensive comparison is needed for some reason
|
bool result = mDoorStates.find(door) != mDoorStates.end();
|
||||||
// TODO (tluppi#1#): Figure out why comparing Ptr isn't working
|
return result;
|
||||||
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 World::getPlayerStandingOn (const MWWorld::Ptr& object)
|
bool World::getPlayerStandingOn (const MWWorld::Ptr& object)
|
||||||
|
|
Loading…
Reference in a new issue