Merge pull request #56 from OpenMW/master

Add OpenMW commits up to 15 Sep
coverity_scan^2
David Cernat 8 years ago committed by GitHub
commit cdada00a8a

@ -83,4 +83,19 @@ namespace MWClass
bool Actor::allowTelekinesis(const MWWorld::ConstPtr &ptr) const {
return false;
}
bool Actor::isActor() const
{
return true;
}
bool Actor::canBeActivated(const MWWorld::Ptr& ptr) const
{
MWMechanics::CreatureStats &stats = getCreatureStats(ptr);
if (stats.getAiSequence().isInCombat() && !stats.isDead())
return false;
return true;
}
}

@ -38,6 +38,10 @@ namespace MWClass
virtual bool allowTelekinesis(const MWWorld::ConstPtr& ptr) const;
///< Return whether this class of object can be activated with telekinesis
virtual bool isActor() const;
virtual bool canBeActivated(const MWWorld::Ptr& ptr) const;
// not implemented
Actor(const Actor&);
Actor& operator= (const Actor&);

@ -104,11 +104,6 @@ namespace MWClass
virtual void getModelsToPreload(const MWWorld::Ptr& ptr, std::vector<std::string>& models) const;
///< Get a list of models to preload that this object may use (directly or indirectly). default implementation: list getModel().
virtual bool
isActor() const {
return true;
}
virtual bool isBipedal (const MWWorld::ConstPtr &ptr) const;
virtual bool canFly (const MWWorld::ConstPtr &ptr) const;
virtual bool canSwim (const MWWorld::ConstPtr &ptr) const;

@ -135,10 +135,6 @@ namespace MWClass
/// Get a blood texture suitable for \a ptr (see Blood Texture 0-2 in Morrowind.ini)
virtual int getBloodTexture (const MWWorld::ConstPtr& ptr) const;
virtual bool isActor() const {
return true;
}
virtual bool isNpc() const {
return true;
}

@ -98,6 +98,11 @@ namespace MWWorld
throw std::runtime_error("class cannot block");
}
bool Class::canBeActivated(const Ptr& ptr) const
{
return !getName(ptr).empty();
}
void Class::onHit(const Ptr& ptr, float damage, bool ishealth, const Ptr& object, const Ptr& attacker, const osg::Vec3f& hitPosition, bool successful) const
{
throw std::runtime_error("class cannot be hit");

@ -130,6 +130,10 @@ namespace MWWorld
///< Play the appropriate sound for a blocked attack, depending on the currently equipped shield
/// (default implementation: throw an exception)
virtual bool canBeActivated(const Ptr& ptr) const;
///< \return Can the player activate this object?
/// (default implementation: true if object's user-readable name is not empty, false otherwise)
virtual boost::shared_ptr<Action> activate (const Ptr& ptr, const Ptr& actor) const;
///< Generate action for activation (default implementation: return a null action).

@ -220,17 +220,9 @@ namespace MWWorld
if (toActivate.isEmpty())
return;
if (toActivate.getClass().getName(toActivate) == "") // objects without name presented to user can never be activated
if (!toActivate.getClass().canBeActivated(toActivate))
return;
if (toActivate.getClass().isActor())
{
MWMechanics::CreatureStats &stats = toActivate.getClass().getCreatureStats(toActivate);
if (stats.getAiSequence().isInCombat() && !stats.isDead())
return;
}
MWBase::Environment::get().getWorld()->activate(toActivate, player);
}

@ -238,7 +238,7 @@ namespace MWWorld
bool RefData::hasChanged() const
{
return mChanged;
return mChanged || !mAnimationState.empty();
}
bool RefData::activate()

@ -5,6 +5,11 @@
namespace ESM
{
bool AnimationState::empty() const
{
return mScriptedAnims.empty();
}
void AnimationState::load(ESMReader& esm)
{
mScriptedAnims.clear();

@ -26,6 +26,8 @@ namespace ESM
typedef std::vector<ScriptedAnimation> ScriptedAnimations;
ScriptedAnimations mScriptedAnims;
bool empty() const;
void load(ESMReader& esm);
void save(ESMWriter& esm) const;
};

Loading…
Cancel
Save