mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-04 03:40:14 +00:00
Revert addImp() and remove()
add isGold() in MWWorld::Class
This commit is contained in:
parent
9485aa5e44
commit
a24df8cb66
@ -284,6 +284,8 @@ namespace MWWorld
|
||||
|
||||
virtual bool isKey (const MWWorld::Ptr& ptr) const { return false; }
|
||||
|
||||
virtual bool isGold(const MWWorld::Ptr& ptr) const { return false; };
|
||||
|
||||
/// Get a blood texture suitable for \a ptr (see Blood Texture 0-2 in Morrowind.ini)
|
||||
virtual int getBloodTexture (const MWWorld::Ptr& ptr) const;
|
||||
|
||||
|
@ -300,20 +300,22 @@ 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(MWClass::Miscellaneous().isGold(ptr))
|
||||
if(ptr.getClass().isGold(ptr))
|
||||
{
|
||||
int realCount = count * ptr.getClass().getValue(ptr);
|
||||
|
||||
for (MWWorld::ContainerStoreIterator iter (begin(type)); iter!=end(); ++iter)
|
||||
{
|
||||
if (Misc::StringUtils::ciEqual((*iter).getCellRef().getRefId(), MWWorld::ContainerStore::sGoldId))
|
||||
{
|
||||
iter->getRefData().setCount(iter->getRefData().getCount() + count);
|
||||
iter->getRefData().setCount(iter->getRefData().getCount() + realCount);
|
||||
flagAsModified();
|
||||
return iter;
|
||||
}
|
||||
}
|
||||
|
||||
MWWorld::ManualRef ref(esmStore, MWWorld::ContainerStore::sGoldId, count);
|
||||
return addNewStack(ref.getPtr(), count);
|
||||
MWWorld::ManualRef ref(esmStore, MWWorld::ContainerStore::sGoldId, realCount);
|
||||
return addNewStack(ref.getPtr(), realCount);
|
||||
}
|
||||
|
||||
// determine whether to stack or not
|
||||
@ -362,18 +364,8 @@ int MWWorld::ContainerStore::remove(const std::string& itemId, int count, const
|
||||
{
|
||||
int toRemove = count;
|
||||
|
||||
std::string id = itemId;
|
||||
|
||||
if(Misc::StringUtils::ciEqual(itemId, "gold_005")
|
||||
|| Misc::StringUtils::ciEqual(itemId, "gold_010")
|
||||
|| Misc::StringUtils::ciEqual(itemId, "gold_025")
|
||||
|| Misc::StringUtils::ciEqual(itemId, "gold_100"))
|
||||
{
|
||||
id = MWWorld::ContainerStore::sGoldId;
|
||||
}
|
||||
|
||||
for (ContainerStoreIterator iter(begin()); iter != end() && toRemove > 0; ++iter)
|
||||
if (Misc::StringUtils::ciEqual(iter->getCellRef().getRefId(), id))
|
||||
if (Misc::StringUtils::ciEqual(iter->getCellRef().getRefId(), itemId))
|
||||
toRemove -= remove(*iter, toRemove, actor);
|
||||
|
||||
flagAsModified();
|
||||
|
Loading…
x
Reference in New Issue
Block a user