some clean up

This commit is contained in:
gus 2014-01-12 22:47:22 +01:00
parent 5d038423ec
commit 5d4e148063
5 changed files with 11 additions and 35 deletions

View file

@ -50,15 +50,6 @@ namespace MWMechanics
} }
ESM::Position pos = actor.getRefData().getPosition(); ESM::Position pos = actor.getRefData().getPosition();
float xCell = 0;
float yCell = 0;
if (actor.getCell()->mCell->isExterior())
{
xCell = actor.getCell()->mCell->mData.mX * ESM::Land::REAL_SIZE;
yCell = actor.getCell()->mCell->mData.mY * ESM::Land::REAL_SIZE;
}
ESM::Pathgrid::Point dest; ESM::Pathgrid::Point dest;
dest.mX = target.getRefData().getPosition().pos[0]; dest.mX = target.getRefData().getPosition().pos[0];
dest.mY = target.getRefData().getPosition().pos[1]; dest.mY = target.getRefData().getPosition().pos[1];

View file

@ -28,8 +28,8 @@ namespace MWMechanics
{ {
AiEscort::AiEscort(const std::string &actorId, int duration, float x, float y, float z) AiEscort::AiEscort(const std::string &actorId, int duration, float x, float y, float z)
: mActorId(actorId), mX(x), mY(y), mZ(z), mDuration(duration) : mActorId(actorId), mX(x), mY(y), mZ(z), mDuration(duration)
, cellX(std::numeric_limits<int>::max()) , mCellX(std::numeric_limits<int>::max())
, cellY(std::numeric_limits<int>::max()) , mCellY(std::numeric_limits<int>::max())
{ {
mMaxDist = 470; mMaxDist = 470;
@ -47,8 +47,8 @@ namespace MWMechanics
AiEscort::AiEscort(const std::string &actorId, const std::string &cellId,int duration, float x, float y, float z) AiEscort::AiEscort(const std::string &actorId, const std::string &cellId,int duration, float x, float y, float z)
: mActorId(actorId), mCellId(cellId), mX(x), mY(y), mZ(z), mDuration(duration) : mActorId(actorId), mCellId(cellId), mX(x), mY(y), mZ(z), mDuration(duration)
, cellX(std::numeric_limits<int>::max()) , mCellX(std::numeric_limits<int>::max())
, cellY(std::numeric_limits<int>::max()) , mCellY(std::numeric_limits<int>::max())
{ {
mMaxDist = 470; mMaxDist = 470;
@ -84,7 +84,7 @@ namespace MWMechanics
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr(); MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
ESM::Position pos = actor.getRefData().getPosition(); ESM::Position pos = actor.getRefData().getPosition();
bool cellChange = actor.getCell()->mCell->mData.mX != cellX || actor.getCell()->mCell->mData.mY != cellY; bool cellChange = actor.getCell()->mCell->mData.mX != mCellX || actor.getCell()->mCell->mData.mY != mCellY;
if(actor.getCell()->mCell->mData.mX != player.getCell()->mCell->mData.mX) if(actor.getCell()->mCell->mData.mX != player.getCell()->mCell->mData.mX)
{ {
@ -114,15 +114,8 @@ namespace MWMechanics
if(!mPathFinder.isPathConstructed() || cellChange) if(!mPathFinder.isPathConstructed() || cellChange)
{ {
cellX = actor.getCell()->mCell->mData.mX; mCellX = actor.getCell()->mCell->mData.mX;
cellY = actor.getCell()->mCell->mData.mY; mCellY = actor.getCell()->mCell->mData.mY;
float xCell = 0;
float yCell = 0;
if (actor.getCell()->mCell->isExterior())
{
xCell = actor.getCell()->mCell->mData.mX * ESM::Land::REAL_SIZE;
yCell = actor.getCell()->mCell->mData.mY * ESM::Land::REAL_SIZE;
}
ESM::Pathgrid::Point dest; ESM::Pathgrid::Point dest;
dest.mX = mX; dest.mX = mX;

View file

@ -34,8 +34,8 @@ namespace MWMechanics
unsigned int mDuration; unsigned int mDuration;
PathFinder mPathFinder; PathFinder mPathFinder;
int cellX; int mCellX;
int cellY; int mCellY;
}; };
} }
#endif #endif

View file

@ -82,15 +82,7 @@ bool MWMechanics::AiFollow::execute (const MWWorld::Ptr& actor,float duration)
start.mX = pos.pos[0]; start.mX = pos.pos[0];
start.mY = pos.pos[1]; start.mY = pos.pos[1];
start.mZ = pos.pos[2]; start.mZ = pos.pos[2];
float xCell = 0;
float yCell = 0;
if (actor.getCell()->mCell->isExterior())
{
xCell = actor.getCell()->mCell->mData.mX * ESM::Land::REAL_SIZE;
yCell = actor.getCell()->mCell->mData.mY * ESM::Land::REAL_SIZE;
}
mPathFinder.buildPath(start, dest, actor.getCell(), true); mPathFinder.buildPath(start, dest, actor.getCell(), true);
} }
mStuckTimer = 0; mStuckTimer = 0;

View file

@ -106,7 +106,7 @@ namespace
return graph; return graph;
} }
std::list<ESM::Pathgrid::Point> findPath(PointID start, PointID end, PathGridGraph graph) std::list<ESM::Pathgrid::Point> findPath(PointID start, PointID end,const PathGridGraph& graph)
{ {
std::vector<PointID> p(boost::num_vertices(graph)); std::vector<PointID> p(boost::num_vertices(graph));
std::vector<float> d(boost::num_vertices(graph)); std::vector<float> d(boost::num_vertices(graph));