Skip to content

Commit

Permalink
prefer previous tools over best tools
Browse files Browse the repository at this point in the history
  • Loading branch information
kuyondo committed Nov 19, 2023
1 parent d2d99a4 commit a96c038
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion apps/openmw/mwmechanics/alchemy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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;
Expand Down Expand Up @@ -415,7 +423,6 @@ MWMechanics::Alchemy::TIngredientsIterator MWMechanics::Alchemy::endIngredients(
void MWMechanics::Alchemy::clear()
{
mAlchemist = MWWorld::Ptr();
mTools.clear();
mIngredients.clear();
mEffects.clear();
setPotionName("");
Expand Down

0 comments on commit a96c038

Please sign in to comment.