Owned crosshair improvements (bug #2789)

pull/280/head
Andrei Kortunov 7 years ago
parent b73ed5ccac
commit 7c80ddc9de

@ -7,6 +7,8 @@
#include <set>
#include <stdint.h>
#include "../mwworld/ptr.hpp"
namespace osg
{
class Vec3f;
@ -231,7 +233,7 @@ namespace MWBase
/// Has the player stolen this item from the given owner?
virtual bool isItemStolenFrom(const std::string& itemid, const std::string& ownerid) = 0;
virtual bool isAllowedToUse (const MWWorld::Ptr& ptr, const MWWorld::CellRef& cellref, MWWorld::Ptr& victim) = 0;
virtual bool isAllowedToUse (const MWWorld::Ptr& ptr, const MWWorld::ConstPtr& item, MWWorld::Ptr& victim) = 0;
/// Turn actor into werewolf or normal form.
virtual void setWerewolf(const MWWorld::Ptr& actor, bool werewolf) = 0;

@ -51,6 +51,11 @@ namespace MWClass
return "";
}
bool Activator::isActivator() const
{
return true;
}
bool Activator::useAnim() const
{
return true;

@ -42,6 +42,8 @@ namespace MWClass
virtual bool useAnim() const;
///< Whether or not to use animated variant of model (default false)
virtual bool isActivator() const;
};
}

@ -76,6 +76,11 @@ namespace MWClass
}
}
bool Door::isDoor() const
{
return true;
}
bool Door::useAnim() const
{
return true;

@ -20,6 +20,8 @@ namespace MWClass
virtual void insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const;
virtual bool isDoor() const;
virtual bool useAnim() const;
virtual std::string getName (const MWWorld::ConstPtr& ptr) const;

@ -359,12 +359,11 @@ namespace MWGui
{
if(!mFocusObject.isEmpty())
{
const MWWorld::CellRef& cellref = mFocusObject.getCellRef();
MWWorld::Ptr ptr = MWMechanics::getPlayer();
MWWorld::Ptr victim;
MWBase::MechanicsManager* mm = MWBase::Environment::get().getMechanicsManager();
bool allowed = mm->isAllowedToUse(ptr, cellref, victim);
bool allowed = mm->isAllowedToUse(ptr, mFocusObject, victim);
return !allowed;
}

@ -13,6 +13,7 @@
#include "../mwworld/inventorystore.hpp"
#include "../mwworld/class.hpp"
#include "../mwworld/player.hpp"
#include "../mwworld/ptr.hpp"
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
@ -829,8 +830,17 @@ namespace MWMechanics
mAI = true;
}
bool MechanicsManager::isAllowedToUse (const MWWorld::Ptr& ptr, const MWWorld::CellRef& cellref, MWWorld::Ptr& victim)
bool MechanicsManager::isAllowedToUse (const MWWorld::Ptr& ptr, const MWWorld::ConstPtr& item, MWWorld::Ptr& victim)
{
const MWWorld::CellRef& cellref = item.getCellRef();
// there is no harm to use unlocked doors
if (item.getClass().isDoor() && cellref.getLockLevel() <= 0 && ptr.getCellRef().getTrap().empty())
return true;
// TODO: implement a better check to check if item is owned bed
if (item.getClass().isActivator() && item.getClass().getScript(item).compare(0, 3, "Bed") != 0)
return true;
const std::string& owner = cellref.getOwner();
bool isOwned = !owner.empty() && owner != "player";
@ -872,7 +882,7 @@ namespace MWMechanics
}
MWWorld::Ptr victim;
if (isAllowedToUse(ptr, bed.getCellRef(), victim))
if (isAllowedToUse(ptr, bed, victim))
return false;
if(commitCrime(ptr, victim, OT_SleepingInOwnedBed))
@ -887,7 +897,7 @@ namespace MWMechanics
void MechanicsManager::objectOpened(const MWWorld::Ptr &ptr, const MWWorld::Ptr &item)
{
MWWorld::Ptr victim;
if (isAllowedToUse(ptr, item.getCellRef(), victim))
if (isAllowedToUse(ptr, item, victim))
return;
commitCrime(ptr, victim, OT_Trespassing);
}
@ -1007,7 +1017,7 @@ namespace MWMechanics
}
}
if (isAllowedToUse(ptr, *ownerCellRef, victim))
if (isAllowedToUse(ptr, item, victim))
return;
Owner owner;

@ -199,7 +199,7 @@ namespace MWMechanics
virtual bool isItemStolenFrom(const std::string& itemid, const std::string& ownerid);
/// @return is \a ptr allowed to take/use \a cellref or is it a crime?
virtual bool isAllowedToUse (const MWWorld::Ptr& ptr, const MWWorld::CellRef& cellref, MWWorld::Ptr& victim);
virtual bool isAllowedToUse (const MWWorld::Ptr& ptr, const MWWorld::ConstPtr& item, MWWorld::Ptr& victim);
virtual void setWerewolf(const MWWorld::Ptr& actor, bool werewolf);
virtual void applyWerewolfAcrobatics(const MWWorld::Ptr& actor);

@ -301,6 +301,10 @@ namespace MWWorld
virtual Ptr copyToCell(const ConstPtr &ptr, CellStore &cell, const ESM::Position &pos, int count) const;
virtual bool isActivator() const {
return false;
}
virtual bool isActor() const {
return false;
}
@ -309,6 +313,10 @@ namespace MWWorld
return false;
}
virtual bool isDoor() const {
return false;
}
virtual bool isBipedal(const MWWorld::ConstPtr& ptr) const;
virtual bool canFly(const MWWorld::ConstPtr& ptr) const;
virtual bool canSwim(const MWWorld::ConstPtr& ptr) const;

Loading…
Cancel
Save