Accept a ConstPtr in canBeEquipped, getEquipmentSlots & hasItemHealth

openmw-38
scrawl 9 years ago
parent e0bb284804
commit dc92fefd2b

@ -67,7 +67,7 @@ namespace MWClass
return defaultItemActivate(ptr, actor);
}
bool Armor::hasItemHealth (const MWWorld::Ptr& ptr) const
bool Armor::hasItemHealth (const MWWorld::ConstPtr& ptr) const
{
return true;
}
@ -86,7 +86,7 @@ namespace MWClass
return ref->mBase->mScript;
}
std::pair<std::vector<int>, bool> Armor::getEquipmentSlots (const MWWorld::Ptr& ptr) const
std::pair<std::vector<int>, bool> Armor::getEquipmentSlots (const MWWorld::ConstPtr& ptr) const
{
const MWWorld::LiveCellRef<ESM::Armor> *ref = ptr.get<ESM::Armor>();
@ -295,7 +295,7 @@ namespace MWClass
return ref->mBase->mData.mArmor * armorSkill / iBaseArmorSkill;
}
std::pair<int, std::string> Armor::canBeEquipped(const MWWorld::Ptr &ptr, const MWWorld::Ptr &npc) const
std::pair<int, std::string> Armor::canBeEquipped(const MWWorld::ConstPtr &ptr, const MWWorld::Ptr &npc) const
{
MWWorld::InventoryStore& invStore = npc.getClass().getInventoryStore(npc);

@ -30,7 +30,7 @@ namespace MWClass
const MWWorld::Ptr& actor) const;
///< Generate action for activation
virtual bool hasItemHealth (const MWWorld::Ptr& ptr) const;
virtual bool hasItemHealth (const MWWorld::ConstPtr& ptr) const;
///< \return Item health data available?
virtual int getItemMaxHealth (const MWWorld::ConstPtr& ptr) const;
@ -39,7 +39,7 @@ namespace MWClass
virtual std::string getScript (const MWWorld::ConstPtr& ptr) const;
///< Return name of the script attached to ptr
virtual std::pair<std::vector<int>, bool> getEquipmentSlots (const MWWorld::Ptr& ptr) const;
virtual std::pair<std::vector<int>, bool> getEquipmentSlots (const MWWorld::ConstPtr& ptr) const;
///< \return first: Return IDs of the slot this object can be equipped in; second: can object
/// stay stacked when equipped?
@ -73,7 +73,7 @@ namespace MWClass
virtual std::string applyEnchantment(const MWWorld::Ptr &ptr, const std::string& enchId, int enchCharge, const std::string& newName) const;
///< Creates a new record using \a ptr as template, with the given name and the given enchantment applied to it.
virtual std::pair<int, std::string> canBeEquipped(const MWWorld::Ptr &ptr, const MWWorld::Ptr &npc) const;
virtual std::pair<int, std::string> canBeEquipped(const MWWorld::ConstPtr &ptr, const MWWorld::Ptr &npc) const;
///< Return 0 if player cannot equip item. 1 if can equip. 2 if it's twohanded weapon. 3 if twohanded weapon conflicts with that. \n
/// Second item in the pair specifies the error message

@ -70,10 +70,9 @@ namespace MWClass
return ref->mBase->mScript;
}
std::pair<std::vector<int>, bool> Clothing::getEquipmentSlots (const MWWorld::Ptr& ptr) const
std::pair<std::vector<int>, bool> Clothing::getEquipmentSlots (const MWWorld::ConstPtr& ptr) const
{
MWWorld::LiveCellRef<ESM::Clothing> *ref =
ptr.get<ESM::Clothing>();
const MWWorld::LiveCellRef<ESM::Clothing> *ref = ptr.get<ESM::Clothing>();
std::vector<int> slots_;
@ -221,7 +220,7 @@ namespace MWClass
return record->mId;
}
std::pair<int, std::string> Clothing::canBeEquipped(const MWWorld::Ptr &ptr, const MWWorld::Ptr &npc) const
std::pair<int, std::string> Clothing::canBeEquipped(const MWWorld::ConstPtr &ptr, const MWWorld::Ptr &npc) const
{
// slots that this item can be equipped in
std::pair<std::vector<int>, bool> slots_ = ptr.getClass().getEquipmentSlots(ptr);

@ -31,7 +31,7 @@ namespace MWClass
virtual std::string getScript (const MWWorld::ConstPtr& ptr) const;
///< Return name of the script attached to ptr
virtual std::pair<std::vector<int>, bool> getEquipmentSlots (const MWWorld::Ptr& ptr) const;
virtual std::pair<std::vector<int>, bool> getEquipmentSlots (const MWWorld::ConstPtr& ptr) const;
///< \return first: Return IDs of the slot this object can be equipped in; second: can object
/// stay stacked when equipped?
@ -65,7 +65,7 @@ namespace MWClass
virtual std::string applyEnchantment(const MWWorld::Ptr &ptr, const std::string& enchId, int enchCharge, const std::string& newName) const;
///< Creates a new record using \a ptr as template, with the given name and the given enchantment applied to it.
virtual std::pair<int, std::string> canBeEquipped(const MWWorld::Ptr &ptr, const MWWorld::Ptr &npc) const;
virtual std::pair<int, std::string> canBeEquipped(const MWWorld::ConstPtr &ptr, const MWWorld::Ptr &npc) const;
///< Return 0 if player cannot equip item. 1 if can equip. 2 if it's twohanded weapon. 3 if twohanded weapon conflicts with that.
/// Second item in the pair specifies the error message

@ -100,10 +100,9 @@ namespace MWClass
return ref->mBase->mScript;
}
std::pair<std::vector<int>, bool> Light::getEquipmentSlots (const MWWorld::Ptr& ptr) const
std::pair<std::vector<int>, bool> Light::getEquipmentSlots (const MWWorld::ConstPtr& ptr) const
{
MWWorld::LiveCellRef<ESM::Light> *ref =
ptr.get<ESM::Light>();
const MWWorld::LiveCellRef<ESM::Light> *ref = ptr.get<ESM::Light>();
std::vector<int> slots_;
@ -224,10 +223,9 @@ namespace MWClass
return ref->mBase->mData.mWeight;
}
std::pair<int, std::string> Light::canBeEquipped(const MWWorld::Ptr &ptr, const MWWorld::Ptr &npc) const
std::pair<int, std::string> Light::canBeEquipped(const MWWorld::ConstPtr &ptr, const MWWorld::Ptr &npc) const
{
MWWorld::LiveCellRef<ESM::Light> *ref =
ptr.get<ESM::Light>();
const MWWorld::LiveCellRef<ESM::Light> *ref = ptr.get<ESM::Light>();
if (!(ref->mBase->mData.mFlags & ESM::Light::Carry))
return std::make_pair(0,"");

@ -37,7 +37,7 @@ namespace MWClass
virtual std::string getScript (const MWWorld::ConstPtr& ptr) const;
///< Return name of the script attached to ptr
virtual std::pair<std::vector<int>, bool> getEquipmentSlots (const MWWorld::Ptr& ptr) const;
virtual std::pair<std::vector<int>, bool> getEquipmentSlots (const MWWorld::ConstPtr& ptr) const;
///< \return first: Return IDs of the slot this object can be equipped in; second: can object
/// stay stacked when equipped?
@ -71,7 +71,7 @@ namespace MWClass
virtual bool canSell (const MWWorld::ConstPtr& item, int npcServices) const;
std::pair<int, std::string> canBeEquipped(const MWWorld::Ptr &ptr, const MWWorld::Ptr &npc) const;
std::pair<int, std::string> canBeEquipped(const MWWorld::ConstPtr &ptr, const MWWorld::Ptr &npc) const;
virtual std::string getSound(const MWWorld::Ptr& ptr) const;
};

@ -69,7 +69,7 @@ namespace MWClass
return ref->mBase->mScript;
}
std::pair<std::vector<int>, bool> Lockpick::getEquipmentSlots (const MWWorld::Ptr& ptr) const
std::pair<std::vector<int>, bool> Lockpick::getEquipmentSlots (const MWWorld::ConstPtr& ptr) const
{
std::vector<int> slots_;

@ -37,7 +37,7 @@ namespace MWClass
virtual std::string getScript (const MWWorld::ConstPtr& ptr) const;
///< Return name of the script attached to ptr
virtual std::pair<std::vector<int>, bool> getEquipmentSlots (const MWWorld::Ptr& ptr) const;
virtual std::pair<std::vector<int>, bool> getEquipmentSlots (const MWWorld::ConstPtr& ptr) const;
///< \return first: Return IDs of the slot this object can be equipped in; second: can object
/// stay stacked when equipped?
@ -68,7 +68,7 @@ namespace MWClass
virtual int getItemMaxHealth (const MWWorld::ConstPtr& ptr) const;
///< Return item max health or throw an exception, if class does not have item health
virtual bool hasItemHealth (const MWWorld::Ptr& ptr) const { return true; }
virtual bool hasItemHealth (const MWWorld::ConstPtr& ptr) const { return true; }
///< \return Item health data available? (default implementation: false)
};
}

@ -69,7 +69,7 @@ namespace MWClass
return ref->mBase->mScript;
}
std::pair<std::vector<int>, bool> Probe::getEquipmentSlots (const MWWorld::Ptr& ptr) const
std::pair<std::vector<int>, bool> Probe::getEquipmentSlots (const MWWorld::ConstPtr& ptr) const
{
std::vector<int> slots_;

@ -37,7 +37,7 @@ namespace MWClass
virtual std::string getScript (const MWWorld::ConstPtr& ptr) const;
///< Return name of the script attached to ptr
virtual std::pair<std::vector<int>, bool> getEquipmentSlots (const MWWorld::Ptr& ptr) const;
virtual std::pair<std::vector<int>, bool> getEquipmentSlots (const MWWorld::ConstPtr& ptr) const;
///< \return first: Return IDs of the slot this object can be equipped in; second: can object
/// stay stacked when equipped?
@ -68,7 +68,7 @@ namespace MWClass
virtual int getItemMaxHealth (const MWWorld::ConstPtr& ptr) const;
///< Return item max health or throw an exception, if class does not have item health
virtual bool hasItemHealth (const MWWorld::Ptr& ptr) const { return true; }
virtual bool hasItemHealth (const MWWorld::ConstPtr& ptr) const { return true; }
///< \return Item health data available? (default implementation: false)
};
}

@ -108,7 +108,7 @@ namespace MWClass
return (ref->mBase->mName != "");
}
bool Repair::hasItemHealth (const MWWorld::Ptr& ptr) const
bool Repair::hasItemHealth (const MWWorld::ConstPtr& ptr) const
{
return true;
}

@ -58,7 +58,7 @@ namespace MWClass
///< Generate action for using via inventory menu (default implementation: return a
/// null action).
virtual bool hasItemHealth (const MWWorld::Ptr& ptr) const;
virtual bool hasItemHealth (const MWWorld::ConstPtr& ptr) const;
///< \return Item health data available? (default implementation: false)
virtual int getItemMaxHealth (const MWWorld::ConstPtr& ptr) const;

@ -65,10 +65,9 @@ namespace MWClass
return defaultItemActivate(ptr, actor);
}
bool Weapon::hasItemHealth (const MWWorld::Ptr& ptr) const
bool Weapon::hasItemHealth (const MWWorld::ConstPtr& ptr) const
{
MWWorld::LiveCellRef<ESM::Weapon> *ref =
ptr.get<ESM::Weapon>();
const MWWorld::LiveCellRef<ESM::Weapon> *ref = ptr.get<ESM::Weapon>();
return (ref->mBase->mData.mType < 11); // thrown weapons and arrows/bolts don't have health, only quantity
}
@ -88,10 +87,9 @@ namespace MWClass
return ref->mBase->mScript;
}
std::pair<std::vector<int>, bool> Weapon::getEquipmentSlots (const MWWorld::Ptr& ptr) const
std::pair<std::vector<int>, bool> Weapon::getEquipmentSlots (const MWWorld::ConstPtr& ptr) const
{
MWWorld::LiveCellRef<ESM::Weapon> *ref =
ptr.get<ESM::Weapon>();
const MWWorld::LiveCellRef<ESM::Weapon> *ref = ptr.get<ESM::Weapon>();
std::vector<int> slots_;
bool stack = false;
@ -369,7 +367,7 @@ namespace MWClass
return record->mId;
}
std::pair<int, std::string> Weapon::canBeEquipped(const MWWorld::Ptr &ptr, const MWWorld::Ptr &npc) const
std::pair<int, std::string> Weapon::canBeEquipped(const MWWorld::ConstPtr &ptr, const MWWorld::Ptr &npc) const
{
if (hasItemHealth(ptr) && ptr.getCellRef().getCharge() == 0)
return std::make_pair(0, "#{sInventoryMessage1}");

@ -34,7 +34,7 @@ namespace MWClass
virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::ConstPtr& ptr) const;
///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.
virtual bool hasItemHealth (const MWWorld::Ptr& ptr) const;
virtual bool hasItemHealth (const MWWorld::ConstPtr& ptr) const;
///< \return Item health data available?
virtual int getItemMaxHealth (const MWWorld::ConstPtr& ptr) const;
@ -43,7 +43,7 @@ namespace MWClass
virtual std::string getScript (const MWWorld::ConstPtr& ptr) const;
///< Return name of the script attached to ptr
virtual std::pair<std::vector<int>, bool> getEquipmentSlots (const MWWorld::Ptr& ptr) const;
virtual std::pair<std::vector<int>, bool> getEquipmentSlots (const MWWorld::ConstPtr& ptr) const;
///< \return first: Return IDs of the slot this object can be equipped in; second: can object
/// stay stacked when equipped?
@ -71,7 +71,7 @@ namespace MWClass
virtual std::string applyEnchantment(const MWWorld::Ptr &ptr, const std::string& enchId, int enchCharge, const std::string& newName) const;
///< Creates a new record using \a ptr as template, with the given name and the given enchantment applied to it.
virtual std::pair<int, std::string> canBeEquipped(const MWWorld::Ptr &ptr, const MWWorld::Ptr &npc) const;
virtual std::pair<int, std::string> canBeEquipped(const MWWorld::ConstPtr &ptr, const MWWorld::Ptr &npc) const;
///< Return 0 if player cannot equip item. 1 if can equip. 2 if it's twohanded weapon. 3 if twohanded weapon conflicts with that.
/// Second item in the pair specifies the error message

@ -75,7 +75,7 @@ namespace MWWorld
throw std::runtime_error ("class does not have NPC stats");
}
bool Class::hasItemHealth (const Ptr& ptr) const
bool Class::hasItemHealth (const ConstPtr& ptr) const
{
return false;
}
@ -188,7 +188,7 @@ namespace MWWorld
return osg::Vec3f (0, 0, 0);
}
std::pair<std::vector<int>, bool> Class::getEquipmentSlots (const Ptr& ptr) const
std::pair<std::vector<int>, bool> Class::getEquipmentSlots (const ConstPtr& ptr) const
{
return std::make_pair (std::vector<int>(), false);
}
@ -301,7 +301,7 @@ namespace MWWorld
throw std::runtime_error ("class can't be enchanted");
}
std::pair<int, std::string> Class::canBeEquipped(const MWWorld::Ptr &ptr, const MWWorld::Ptr &npc) const
std::pair<int, std::string> Class::canBeEquipped(const MWWorld::ConstPtr &ptr, const MWWorld::Ptr &npc) const
{
return std::make_pair (1, "");
}

@ -108,7 +108,7 @@ namespace MWWorld
///< Return NPC stats or throw an exception, if class does not have NPC stats
/// (default implementation: throw an exception)
virtual bool hasItemHealth (const Ptr& ptr) const;
virtual bool hasItemHealth (const ConstPtr& ptr) const;
///< \return Item health data available? (default implementation: false)
virtual int getItemHealth (const ConstPtr& ptr) const;
@ -187,7 +187,7 @@ namespace MWWorld
virtual osg::Vec3f getRotationVector (const Ptr& ptr) const;
///< Return desired rotations, as euler angles.
virtual std::pair<std::vector<int>, bool> getEquipmentSlots (const Ptr& ptr) const;
virtual std::pair<std::vector<int>, bool> getEquipmentSlots (const ConstPtr& ptr) const;
///< \return first: Return IDs of the slot this object can be equipped in; second: can object
/// stay stacked when equipped?
///
@ -271,7 +271,7 @@ namespace MWWorld
virtual std::string applyEnchantment(const MWWorld::Ptr &ptr, const std::string& enchId, int enchCharge, const std::string& newName) const;
///< Creates a new record using \a ptr as template, with the given name and the given enchantment applied to it.
virtual std::pair<int, std::string> canBeEquipped(const MWWorld::Ptr &ptr, const MWWorld::Ptr &npc) const;
virtual std::pair<int, std::string> canBeEquipped(const MWWorld::ConstPtr &ptr, const MWWorld::Ptr &npc) const;
///< Return 0 if player cannot equip item. 1 if can equip. 2 if it's twohanded weapon. 3 if twohanded weapon conflicts with that.
/// Second item in the pair specifies the error message

Loading…
Cancel
Save