mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 08:53:52 +00:00
Accept a ConstPtr in getDoorState
This commit is contained in:
parent
7a2ca5580a
commit
51c77c5045
8 changed files with 21 additions and 8 deletions
|
@ -41,6 +41,10 @@ namespace MWClass
|
|||
{
|
||||
return *this;
|
||||
}
|
||||
virtual const DoorCustomData& asDoorCustomData() const
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
MWWorld::CustomData *DoorCustomData::clone() const
|
||||
|
@ -312,9 +316,10 @@ namespace MWClass
|
|||
}
|
||||
}
|
||||
|
||||
int Door::getDoorState (const MWWorld::Ptr &ptr) const
|
||||
int Door::getDoorState (const MWWorld::ConstPtr &ptr) const
|
||||
{
|
||||
ensureCustomData(ptr);
|
||||
if (!ptr.getRefData().getCustomData())
|
||||
return 0;
|
||||
const DoorCustomData& customData = ptr.getRefData().getCustomData()->asDoorCustomData();
|
||||
return customData.mDoorState;
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ namespace MWClass
|
|||
virtual std::string getModel(const MWWorld::ConstPtr &ptr) const;
|
||||
|
||||
/// 0 = nothing, 1 = opening, 2 = closing
|
||||
virtual int getDoorState (const MWWorld::Ptr &ptr) const;
|
||||
virtual int getDoorState (const MWWorld::ConstPtr &ptr) const;
|
||||
/// This does not actually cause the door to move. Use World::activateDoor instead.
|
||||
virtual void setDoorState (const MWWorld::Ptr &ptr, int state) const;
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
#include "steering.hpp"
|
||||
|
||||
MWMechanics::AiAvoidDoor::AiAvoidDoor(const MWWorld::Ptr& doorPtr)
|
||||
MWMechanics::AiAvoidDoor::AiAvoidDoor(const MWWorld::ConstPtr& doorPtr)
|
||||
: AiPackage(), mDuration(1), mDoorPtr(doorPtr), mAdjAngle(0)
|
||||
{
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace MWMechanics
|
|||
{
|
||||
public:
|
||||
/// Avoid door until the door is fully open
|
||||
AiAvoidDoor(const MWWorld::Ptr& doorPtr);
|
||||
AiAvoidDoor(const MWWorld::ConstPtr& doorPtr);
|
||||
|
||||
virtual AiAvoidDoor *clone() const;
|
||||
|
||||
|
@ -28,7 +28,7 @@ namespace MWMechanics
|
|||
|
||||
private:
|
||||
float mDuration;
|
||||
MWWorld::Ptr mDoorPtr;
|
||||
MWWorld::ConstPtr mDoorPtr;
|
||||
ESM::Position mLastPos;
|
||||
float mAdjAngle;
|
||||
};
|
||||
|
|
|
@ -404,7 +404,7 @@ namespace MWWorld
|
|||
return false;
|
||||
}
|
||||
|
||||
int Class::getDoorState (const MWWorld::Ptr &ptr) const
|
||||
int Class::getDoorState (const MWWorld::ConstPtr &ptr) const
|
||||
{
|
||||
throw std::runtime_error("this is not a door");
|
||||
}
|
||||
|
|
|
@ -319,7 +319,7 @@ namespace MWWorld
|
|||
virtual bool isClass(const MWWorld::ConstPtr& ptr, const std::string &className) const;
|
||||
|
||||
/// 0 = nothing, 1 = opening, 2 = closing
|
||||
virtual int getDoorState (const MWWorld::Ptr &ptr) const;
|
||||
virtual int getDoorState (const MWWorld::ConstPtr &ptr) const;
|
||||
/// This does not actually cause the door to move. Use World::activateDoor instead.
|
||||
virtual void setDoorState (const MWWorld::Ptr &ptr, int state) const;
|
||||
|
||||
|
|
|
@ -42,6 +42,13 @@ MWClass::DoorCustomData &CustomData::asDoorCustomData()
|
|||
throw std::logic_error(error.str());
|
||||
}
|
||||
|
||||
const MWClass::DoorCustomData &CustomData::asDoorCustomData() const
|
||||
{
|
||||
std::stringstream error;
|
||||
error << "bad cast " << typeid(this).name() << " to DoorCustomData";
|
||||
throw std::logic_error(error.str());
|
||||
}
|
||||
|
||||
MWClass::CreatureLevListCustomData &CustomData::asCreatureLevListCustomData()
|
||||
{
|
||||
std::stringstream error;
|
||||
|
|
|
@ -31,6 +31,7 @@ namespace MWWorld
|
|||
virtual MWClass::ContainerCustomData& asContainerCustomData();
|
||||
|
||||
virtual MWClass::DoorCustomData& asDoorCustomData();
|
||||
virtual const MWClass::DoorCustomData& asDoorCustomData() const;
|
||||
|
||||
virtual MWClass::CreatureLevListCustomData& asCreatureLevListCustomData();
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue