mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-07 12:54:00 +00:00
Merge pull request #1325 from jordan-ayers/bugfix/3684-restock-soul-gems
Adjust restock calculations to ignore filled soul gems. (Bug #3684)
This commit is contained in:
commit
73fbaae97f
@ -156,6 +156,16 @@ int MWWorld::ContainerStore::count(const std::string &id)
|
||||
return total;
|
||||
}
|
||||
|
||||
int MWWorld::ContainerStore::restockCount(const std::string &id)
|
||||
{
|
||||
int total=0;
|
||||
for (MWWorld::ContainerStoreIterator iter (begin()); iter!=end(); ++iter)
|
||||
if (Misc::StringUtils::ciEqual(iter->getCellRef().getRefId(), id))
|
||||
if (iter->getCellRef().getSoul().empty())
|
||||
total += iter->getRefData().getCount();
|
||||
return total;
|
||||
}
|
||||
|
||||
MWWorld::ContainerStoreListener* MWWorld::ContainerStore::getContListener() const
|
||||
{
|
||||
return mListener;
|
||||
@ -512,7 +522,7 @@ void MWWorld::ContainerStore::restock (const ESM::InventoryList& items, const MW
|
||||
for (std::map<std::pair<std::string, std::string>, int>::iterator it = mLevelledItemMap.begin(); it != mLevelledItemMap.end();)
|
||||
{
|
||||
int spawnedCount = it->second; //How many items should be in shop originally
|
||||
int itemCount = count(it->first.first); //How many items are there in shop now
|
||||
int itemCount = restockCount(it->first.first); //How many items are there in shop now
|
||||
//If something was not sold
|
||||
if(itemCount >= spawnedCount)
|
||||
{
|
||||
@ -578,7 +588,7 @@ void MWWorld::ContainerStore::restock (const ESM::InventoryList& items, const MW
|
||||
else
|
||||
{
|
||||
//Restocking static item - just restock to the max count
|
||||
int currentCount = count(itemOrList);
|
||||
int currentCount = restockCount(itemOrList);
|
||||
if (currentCount < std::abs(it->mCount))
|
||||
addInitialItem(itemOrList, owner, -(std::abs(it->mCount) - currentCount), true);
|
||||
}
|
||||
|
@ -162,8 +162,12 @@ namespace MWWorld
|
||||
/// If a compatible stack is found, the item's count is added to that stack, then the original is deleted.
|
||||
/// @return If the item was stacked, return the stack, otherwise return the old (untouched) item.
|
||||
|
||||
/// @return How many items with refID \a id are in this container?
|
||||
int count (const std::string& id);
|
||||
///< @return How many items with refID \a id are in this container?
|
||||
|
||||
int restockCount (const std::string& id);
|
||||
///< Item count with restock adjustments (such as ignoring filled soul gems).
|
||||
/// @return How many items with refID \a id are in this container?
|
||||
|
||||
ContainerStoreListener* getContListener() const;
|
||||
void setContListener(ContainerStoreListener* listener);
|
||||
|
Loading…
Reference in New Issue
Block a user