From 34a02fef45f0d02dc455ca77d24ce00ac5770da1 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sat, 7 Apr 2012 20:09:09 +0200 Subject: [PATCH] consider item value when auto equipping --- apps/openmw/mwworld/inventorystore.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/apps/openmw/mwworld/inventorystore.cpp b/apps/openmw/mwworld/inventorystore.cpp index aedd119c8..1fe76a0a8 100644 --- a/apps/openmw/mwworld/inventorystore.cpp +++ b/apps/openmw/mwworld/inventorystore.cpp @@ -101,20 +101,30 @@ void MWWorld::InventoryStore::autoEquip (const MWMechanics::NpcStats& stats) for (ContainerStoreIterator iter (begin()); iter!=end(); ++iter) { + Ptr test = *iter; + std::pair, bool> itemsSlots = MWWorld::Class::get (*iter).getEquipmentSlots (*iter); for (std::vector::const_iterator iter2 (itemsSlots.first.begin()); iter2!=itemsSlots.first.end(); ++iter2) { - /// \todo comapre item with item in slot - if (slots.at (*iter2)==end()) + if (slots.at (*iter2)!=end()) { - /// \todo unstack, if reqquired (itemsSlots.second) + Ptr old = *slots.at (*iter2); - slots[*iter2] = iter; - break; + // check value + if (MWWorld::Class::get (old).getValue (old)>=MWWorld::Class::get (test).getValue (test)) + { + /// \todo check skill + continue; + } } + + /// \todo unstack, if reqquired (itemsSlots.second) + + slots[*iter2] = iter; + break; } }