[Client] Make it possible to check if an item ID belongs to a bound item

fix/skillcap
David Cernat 6 years ago
parent a1933e7bc2
commit a3b9274365

@ -255,6 +255,17 @@ namespace MWBase
virtual bool isItemStolenFrom(const std::string& itemid, const MWWorld::Ptr& ptr) = 0; virtual bool isItemStolenFrom(const std::string& itemid, const MWWorld::Ptr& ptr) = 0;
virtual bool isBoundItem(const MWWorld::Ptr& item) = 0; virtual bool isBoundItem(const MWWorld::Ptr& item) = 0;
/*
Start of tes3mp addition
Make it possible to check if an itemId corresponds to a bound item
*/
virtual bool isBoundItem(std::string itemId) = 0;
/*
End of tes3mp addition
*/
virtual bool isAllowedToUse (const MWWorld::Ptr& ptr, const MWWorld::Ptr& target, MWWorld::Ptr& victim) = 0; virtual bool isAllowedToUse (const MWWorld::Ptr& ptr, const MWWorld::Ptr& target, MWWorld::Ptr& victim) = 0;
/// Turn actor into werewolf or normal form. /// Turn actor into werewolf or normal form.

@ -879,10 +879,19 @@ namespace MWMechanics
*/ */
} }
/*
Start of tes3mp change (major)
Move boundItemIDCache outside of the original isBoundItem(const MWWorld::Ptr& item)
method so it can be reused in the new isBoundItem(std::string itemId) method
*/
std::set<std::string> boundItemIDCache;
bool MechanicsManager::isBoundItem(const MWWorld::Ptr& item) bool MechanicsManager::isBoundItem(const MWWorld::Ptr& item)
{ {
static std::set<std::string> boundItemIDCache; /*
End of tes3mp change (major)
*/
// If this is empty then we haven't executed the GMST cache logic yet; or there isn't any sMagicBound* GMST's for some reason // If this is empty then we haven't executed the GMST cache logic yet; or there isn't any sMagicBound* GMST's for some reason
if (boundItemIDCache.empty()) if (boundItemIDCache.empty())
{ {
@ -918,6 +927,24 @@ namespace MWMechanics
return false; return false;
} }
/*
Start of tes3mp addition
Make it possible to check if an itemId corresponds to a bound item
*/
bool MechanicsManager::isBoundItem(std::string itemId)
{
Misc::StringUtils::lowerCaseInPlace(itemId);
if (boundItemIDCache.count(itemId) != 0)
return true;
return false;
}
/*
End of tes3mp addition
*/
bool MechanicsManager::isAllowedToUse (const MWWorld::Ptr& ptr, const MWWorld::Ptr& target, MWWorld::Ptr& victim) bool MechanicsManager::isAllowedToUse (const MWWorld::Ptr& ptr, const MWWorld::Ptr& target, MWWorld::Ptr& victim)
{ {
if (target.isEmpty()) if (target.isEmpty())

@ -223,6 +223,16 @@ namespace MWMechanics
virtual bool isBoundItem(const MWWorld::Ptr& item); virtual bool isBoundItem(const MWWorld::Ptr& item);
/*
Start of tes3mp addition
Make it possible to check if an itemId corresponds to a bound item
*/
virtual bool isBoundItem(std::string itemId);
/*
End of tes3mp addition
*/
/// @return is \a ptr allowed to take/use \a target or is it a crime? /// @return is \a ptr allowed to take/use \a target or is it a crime?
virtual bool isAllowedToUse (const MWWorld::Ptr& ptr, const MWWorld::Ptr& target, MWWorld::Ptr& victim); virtual bool isAllowedToUse (const MWWorld::Ptr& ptr, const MWWorld::Ptr& target, MWWorld::Ptr& victim);

Loading…
Cancel
Save