forked from teamnwah/openmw-tes3coop
fix code duplication
This commit is contained in:
parent
23bfa29ae6
commit
75e5023590
3 changed files with 13 additions and 17 deletions
|
@ -25,20 +25,16 @@
|
||||||
|
|
||||||
#include <boost/lexical_cast.hpp>
|
#include <boost/lexical_cast.hpp>
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
bool isGold (const MWWorld::Ptr& ptr)
|
|
||||||
{
|
|
||||||
return Misc::StringUtils::ciEqual(ptr.getCellRef().getRefId(), "gold_001")
|
|
||||||
|| Misc::StringUtils::ciEqual(ptr.getCellRef().getRefId(), "gold_005")
|
|
||||||
|| Misc::StringUtils::ciEqual(ptr.getCellRef().getRefId(), "gold_010")
|
|
||||||
|| Misc::StringUtils::ciEqual(ptr.getCellRef().getRefId(), "gold_025")
|
|
||||||
|| Misc::StringUtils::ciEqual(ptr.getCellRef().getRefId(), "gold_100");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace MWClass
|
namespace MWClass
|
||||||
{
|
{
|
||||||
|
bool Miscellaneous::isGold (const MWWorld::Ptr& ptr) const
|
||||||
|
{
|
||||||
|
return Misc::StringUtils::ciEqual(ptr.getCellRef().getRefId(), "gold_001")
|
||||||
|
|| Misc::StringUtils::ciEqual(ptr.getCellRef().getRefId(), "gold_005")
|
||||||
|
|| Misc::StringUtils::ciEqual(ptr.getCellRef().getRefId(), "gold_010")
|
||||||
|
|| Misc::StringUtils::ciEqual(ptr.getCellRef().getRefId(), "gold_025")
|
||||||
|
|| Misc::StringUtils::ciEqual(ptr.getCellRef().getRefId(), "gold_100");
|
||||||
|
}
|
||||||
std::string Miscellaneous::getId (const MWWorld::Ptr& ptr) const
|
std::string Miscellaneous::getId (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
return ptr.get<ESM::Miscellaneous>()->mBase->mId;
|
return ptr.get<ESM::Miscellaneous>()->mBase->mId;
|
||||||
|
|
|
@ -62,6 +62,8 @@ namespace MWClass
|
||||||
virtual bool canSell (const MWWorld::Ptr& item, int npcServices) const;
|
virtual bool canSell (const MWWorld::Ptr& item, int npcServices) const;
|
||||||
|
|
||||||
virtual bool isKey (const MWWorld::Ptr &ptr) const;
|
virtual bool isKey (const MWWorld::Ptr &ptr) const;
|
||||||
|
|
||||||
|
virtual bool isGold (const MWWorld::Ptr& ptr) const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
#include "../mwmechanics/creaturestats.hpp"
|
#include "../mwmechanics/creaturestats.hpp"
|
||||||
#include "../mwmechanics/levelledlist.hpp"
|
#include "../mwmechanics/levelledlist.hpp"
|
||||||
|
|
||||||
|
#include "../mwclass/misc.hpp"
|
||||||
|
|
||||||
#include "manualref.hpp"
|
#include "manualref.hpp"
|
||||||
#include "refdata.hpp"
|
#include "refdata.hpp"
|
||||||
#include "class.hpp"
|
#include "class.hpp"
|
||||||
|
@ -298,11 +300,7 @@ MWWorld::ContainerStoreIterator MWWorld::ContainerStore::addImp (const Ptr& ptr,
|
||||||
|
|
||||||
// gold needs special handling: when it is inserted into a container, the base object automatically becomes Gold_001
|
// gold needs special handling: when it is inserted into a container, the base object automatically becomes Gold_001
|
||||||
// this ensures that gold piles of different sizes stack with each other (also, several scripts rely on Gold_001 for detecting player gold)
|
// this ensures that gold piles of different sizes stack with each other (also, several scripts rely on Gold_001 for detecting player gold)
|
||||||
if (Misc::StringUtils::ciEqual(ptr.getCellRef().getRefId(), "gold_001")
|
if(MWClass::Miscellaneous().isGold(ptr))
|
||||||
|| Misc::StringUtils::ciEqual(ptr.getCellRef().getRefId(), "gold_005")
|
|
||||||
|| Misc::StringUtils::ciEqual(ptr.getCellRef().getRefId(), "gold_010")
|
|
||||||
|| Misc::StringUtils::ciEqual(ptr.getCellRef().getRefId(), "gold_025")
|
|
||||||
|| Misc::StringUtils::ciEqual(ptr.getCellRef().getRefId(), "gold_100"))
|
|
||||||
{
|
{
|
||||||
int realCount = count * ptr.getClass().getValue(ptr);
|
int realCount = count * ptr.getClass().getValue(ptr);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue