mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-03 13:19:40 +00:00
Revert addImp() and remove()
add isGold() in MWWorld::Class
This commit is contained in:
parent
9485aa5e44
commit
a24df8cb66
2 changed files with 9 additions and 15 deletions
|
@ -284,6 +284,8 @@ namespace MWWorld
|
||||||
|
|
||||||
virtual bool isKey (const MWWorld::Ptr& ptr) const { return false; }
|
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)
|
/// Get a blood texture suitable for \a ptr (see Blood Texture 0-2 in Morrowind.ini)
|
||||||
virtual int getBloodTexture (const MWWorld::Ptr& ptr) const;
|
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
|
// 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(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)
|
for (MWWorld::ContainerStoreIterator iter (begin(type)); iter!=end(); ++iter)
|
||||||
{
|
{
|
||||||
if (Misc::StringUtils::ciEqual((*iter).getCellRef().getRefId(), MWWorld::ContainerStore::sGoldId))
|
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();
|
flagAsModified();
|
||||||
return iter;
|
return iter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MWWorld::ManualRef ref(esmStore, MWWorld::ContainerStore::sGoldId, count);
|
MWWorld::ManualRef ref(esmStore, MWWorld::ContainerStore::sGoldId, realCount);
|
||||||
return addNewStack(ref.getPtr(), count);
|
return addNewStack(ref.getPtr(), realCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
// determine whether to stack or not
|
// determine whether to stack or not
|
||||||
|
@ -362,18 +364,8 @@ int MWWorld::ContainerStore::remove(const std::string& itemId, int count, const
|
||||||
{
|
{
|
||||||
int toRemove = count;
|
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)
|
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);
|
toRemove -= remove(*iter, toRemove, actor);
|
||||||
|
|
||||||
flagAsModified();
|
flagAsModified();
|
||||||
|
|
Loading…
Reference in a new issue