Restore getNearbyDoor

openmw-38
scrawl 9 years ago
parent f9dd549bff
commit 1875aa4a18

@ -44,10 +44,9 @@ namespace MWMechanics
return MWWorld::Ptr(); // check interior cells only return MWWorld::Ptr(); // check interior cells only
// Check all the doors in this cell // Check all the doors in this cell
/* const MWWorld::CellRefList<ESM::Door>& doors = cell->getReadOnlyDoors();
MWWorld::CellRefList<ESM::Door>& doors = cell->get<ESM::Door>(); const MWWorld::CellRefList<ESM::Door>::List& refList = doors.mList;
MWWorld::CellRefList<ESM::Door>::List& refList = doors.mList; MWWorld::CellRefList<ESM::Door>::List::const_iterator it = refList.begin();
MWWorld::CellRefList<ESM::Door>::List::iterator it = refList.begin();
osg::Vec3f pos(actor.getRefData().getPosition().asVec3()); osg::Vec3f pos(actor.getRefData().getPosition().asVec3());
/// TODO: How to check whether the actor is facing a door? Below code is for /// TODO: How to check whether the actor is facing a door? Below code is for
@ -60,14 +59,14 @@ namespace MWMechanics
/// opposite of the code in World::activateDoor() ::confused:: /// opposite of the code in World::activateDoor() ::confused::
for (; it != refList.end(); ++it) for (; it != refList.end(); ++it)
{ {
MWWorld::LiveCellRef<ESM::Door>& ref = *it; const MWWorld::LiveCellRef<ESM::Door>& ref = *it;
if((pos - ref.mData.getPosition().asVec3()).length2() < minSqr if((pos - ref.mData.getPosition().asVec3()).length2() < minSqr
&& ref.mData.getPosition().rot[2] == ref.mRef.getPosition().rot[2]) && ref.mData.getPosition().rot[2] == ref.mRef.getPosition().rot[2])
{ {
return MWWorld::Ptr(&ref, actor.getCell()); // found, stop searching // FIXME cast
return MWWorld::Ptr(&const_cast<MWWorld::LiveCellRef<ESM::Door> &>(ref), actor.getCell()); // found, stop searching
} }
} }
*/
return MWWorld::Ptr(); // none found return MWWorld::Ptr(); // none found
} }

@ -182,7 +182,7 @@ namespace MWWorld
mPosition = pos; mPosition = pos;
} }
const ESM::Position& RefData::getPosition() const ESM::Position& RefData::getPosition() const
{ {
return mPosition; return mPosition;
} }

@ -103,7 +103,7 @@ namespace MWWorld
void disable(); void disable();
void setPosition (const ESM::Position& pos); void setPosition (const ESM::Position& pos);
const ESM::Position& getPosition(); const ESM::Position& getPosition() const;
void setCustomData (CustomData *data); void setCustomData (CustomData *data);
///< Set custom data (potentially replacing old custom data). The ownership of \a data is ///< Set custom data (potentially replacing old custom data). The ownership of \a data is

Loading…
Cancel
Save