Implement and use new method allowTelekinesis()

coverity_scan^2
Allofich 9 years ago
parent 8014f37879
commit 35a23c3b49

@ -81,6 +81,10 @@ namespace MWClass
return (ref->mBase->mName != "");
}
bool Activator::allowTelekinesis(const MWWorld::ConstPtr &ptr) const {
return false;
}
MWGui::ToolTipInfo Activator::getToolTipInfo (const MWWorld::ConstPtr& ptr, int count) const
{
const MWWorld::LiveCellRef<ESM::Activator> *ref = ptr.get<ESM::Activator>();

@ -24,6 +24,9 @@ namespace MWClass
virtual bool hasToolTip (const MWWorld::ConstPtr& ptr) const;
///< @return true if this object has a tooltip when focused (default implementation: false)
virtual bool allowTelekinesis(const MWWorld::ConstPtr& ptr) const;
///< Return whether this class of object can be activated with telekinesis
virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::ConstPtr& ptr, int count) const;
///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.

@ -79,4 +79,8 @@ namespace MWClass
weight += effects.get(MWMechanics::EffectKey(ESM::MagicEffect::Burden)).getMagnitude();
return (weight < 0) ? 0.0f : weight;
}
bool Actor::allowTelekinesis(const MWWorld::ConstPtr &ptr) const {
return false;
}
}

@ -35,6 +35,9 @@ namespace MWClass
///< Returns total weight of objects inside this object (including modifications from magic
/// effects). Throws an exception, if the object can't hold other objects.
virtual bool allowTelekinesis(const MWWorld::ConstPtr& ptr) const;
///< Return whether this class of object can be activated with telekinesis
// not implemented
Actor(const Actor&);
Actor& operator= (const Actor&);

@ -213,6 +213,14 @@ namespace MWClass
return true;
}
bool Door::allowTelekinesis(const MWWorld::ConstPtr &ptr) const
{
if (ptr.getCellRef().getTeleport())
return false;
else
return true;
}
std::string Door::getScript (const MWWorld::ConstPtr& ptr) const
{
const MWWorld::LiveCellRef<ESM::Door> *ref = ptr.get<ESM::Door>();

@ -45,6 +45,9 @@ namespace MWClass
virtual bool canLock(const MWWorld::ConstPtr &ptr) const;
virtual bool allowTelekinesis(const MWWorld::ConstPtr &ptr) const;
///< Return whether this class of object can be activated with telekinesis
virtual std::string getScript (const MWWorld::ConstPtr& ptr) const;
///< Return name of the script attached to ptr

@ -279,6 +279,9 @@ namespace MWWorld
virtual bool isKey (const MWWorld::ConstPtr& ptr) const { return false; }
virtual bool isGold(const MWWorld::ConstPtr& ptr) const { return false; }
virtual bool allowTelekinesis(const MWWorld::ConstPtr& ptr) const { return true; }
///< Return whether this class of object can be activated with telekinesis
/// Get a blood texture suitable for \a ptr (see Blood Texture 0-2 in Morrowind.ini)
virtual int getBloodTexture (const MWWorld::ConstPtr& ptr) const;

@ -1027,11 +1027,8 @@ namespace MWWorld
facedObject = getFacedObject(activationDistance, distanceToObject, true);
// Not allowing telekinesis on actors, on doors that teleport to other cells, or on activators
// Original engine doesn't allow telekinesis on books or lights, either
if (!facedObject.isEmpty() && (facedObject.getClass().isActor()
|| facedObject.getCellRef().getTeleport() || facedObject.getClass().getTypeName() == typeid(ESM::Activator).name())
&& (distanceToObject > getMaxActivationDistance()))
if (!facedObject.isEmpty() && !facedObject.getClass().allowTelekinesis(facedObject)
&& distanceToObject > getMaxActivationDistance())
return 0;
}

Loading…
Cancel
Save