1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-02-21 08:39:45 +00:00

prefer previous tools over best tools

This commit is contained in:
kuyondo 2023-11-19 19:10:12 +08:00
parent d2d99a4348
commit a96c038f19

View file

@ -368,6 +368,8 @@ void MWMechanics::Alchemy::setAlchemist(const MWWorld::Ptr& npc)
mTools.resize(4);
std::vector<MWWorld::Ptr> prevTools(mTools);
std::fill(mTools.begin(), mTools.end(), MWWorld::Ptr());
mEffects.clear();
@ -384,6 +386,12 @@ void MWMechanics::Alchemy::setAlchemist(const MWWorld::Ptr& npc)
if (type < 0 || type >= static_cast<int>(mTools.size()))
throw std::runtime_error("invalid apparatus type");
if (prevTools[type] == *iter)
mTools[type] = *iter; // prefer the previous tool if still in the container
if (!mTools[type].isEmpty() && !prevTools[type].isEmpty() && mTools[type] == prevTools[type])
continue;
if (!mTools[type].isEmpty())
if (ref->mBase->mData.mQuality <= mTools[type].get<ESM::Apparatus>()->mBase->mData.mQuality)
continue;
@ -415,7 +423,6 @@ MWMechanics::Alchemy::TIngredientsIterator MWMechanics::Alchemy::endIngredients(
void MWMechanics::Alchemy::clear()
{
mAlchemist = MWWorld::Ptr();
mTools.clear();
mIngredients.clear();
mEffects.clear();
setPotionName("");