mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 23:23:52 +00:00
fix code duplication
This commit is contained in:
parent
23bfa29ae6
commit
75e5023590
3 changed files with 13 additions and 17 deletions
|
@ -25,9 +25,9 @@
|
|||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
namespace
|
||||
namespace MWClass
|
||||
{
|
||||
bool isGold (const MWWorld::Ptr& ptr)
|
||||
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")
|
||||
|
@ -35,10 +35,6 @@ bool isGold (const MWWorld::Ptr& ptr)
|
|||
|| Misc::StringUtils::ciEqual(ptr.getCellRef().getRefId(), "gold_025")
|
||||
|| Misc::StringUtils::ciEqual(ptr.getCellRef().getRefId(), "gold_100");
|
||||
}
|
||||
}
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
std::string Miscellaneous::getId (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
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 isKey (const MWWorld::Ptr &ptr) const;
|
||||
|
||||
virtual bool isGold (const MWWorld::Ptr& ptr) const;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
#include "../mwmechanics/creaturestats.hpp"
|
||||
#include "../mwmechanics/levelledlist.hpp"
|
||||
|
||||
#include "../mwclass/misc.hpp"
|
||||
|
||||
#include "manualref.hpp"
|
||||
#include "refdata.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
|
||||
// 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")
|
||||
|| 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"))
|
||||
if(MWClass::Miscellaneous().isGold(ptr))
|
||||
{
|
||||
int realCount = count * ptr.getClass().getValue(ptr);
|
||||
|
||||
|
|
Loading…
Reference in a new issue