mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-27 03:35:27 +00:00
implemented un-stacking
This commit is contained in:
parent
16522ddc59
commit
ee7e482cba
@ -75,7 +75,13 @@ void MWWorld::ContainerStore::add (const Ptr& ptr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (type)
|
// if we got here, this means no stacking
|
||||||
|
addImpl(ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MWWorld::ContainerStore::addImpl (const Ptr& ptr)
|
||||||
|
{
|
||||||
|
switch (getType(ptr))
|
||||||
{
|
{
|
||||||
case Type_Potion: potions.list.push_back (*ptr.get<ESM::Potion>()); break;
|
case Type_Potion: potions.list.push_back (*ptr.get<ESM::Potion>()); break;
|
||||||
case Type_Apparatus: appas.list.push_back (*ptr.get<ESM::Apparatus>()); break;
|
case Type_Apparatus: appas.list.push_back (*ptr.get<ESM::Apparatus>()); break;
|
||||||
|
@ -70,13 +70,19 @@ namespace MWWorld
|
|||||||
///< @return true if the two specified objects can stack with each other
|
///< @return true if the two specified objects can stack with each other
|
||||||
|
|
||||||
void add (const Ptr& ptr);
|
void add (const Ptr& ptr);
|
||||||
///< Add the item pointed to by \a ptr to this container.
|
///< Add the item pointed to by \a ptr to this container. (Stacks automatically if needed)
|
||||||
///
|
///
|
||||||
/// \note The item pointed to is not required to exist beyond this function call.
|
/// \note The item pointed to is not required to exist beyond this function call.
|
||||||
///
|
///
|
||||||
/// \attention Do not add items to an existing stack by increasing the count instead of
|
/// \attention Do not add items to an existing stack by increasing the count instead of
|
||||||
/// calling this function!
|
/// calling this function!
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void addImpl (const Ptr& ptr);
|
||||||
|
///< Add the item to this container (no stacking)
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
void fill (const ESM::InventoryList& items, const ESMS::ESMStore& store);
|
void fill (const ESM::InventoryList& items, const ESMS::ESMStore& store);
|
||||||
///< Insert items into *this.
|
///< Insert items into *this.
|
||||||
|
|
||||||
|
@ -84,7 +84,11 @@ void MWWorld::InventoryStore::equip (int slot, const ContainerStoreIterator& ite
|
|||||||
// unstack item pointed to by iterator if required
|
// unstack item pointed to by iterator if required
|
||||||
if (iterator->getRefData().getCount() > 1)
|
if (iterator->getRefData().getCount() > 1)
|
||||||
{
|
{
|
||||||
/// \ŧodo ???
|
// add the item again with a count of count-1, then set the count of the original (that will be equipped) to 1
|
||||||
|
int count = iterator->getRefData().getCount();
|
||||||
|
iterator->getRefData().setCount(count-1);
|
||||||
|
addImpl(*iterator);
|
||||||
|
iterator->getRefData().setCount(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
mSlots[slot] = iterator;
|
mSlots[slot] = iterator;
|
||||||
@ -163,7 +167,18 @@ void MWWorld::InventoryStore::autoEquip (const MWMechanics::NpcStats& stats)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \todo unstack, if reqquired (itemsSlots.second)
|
if (!itemsSlots.second) // if itemsSlots.second is true, item can stay stacked when equipped
|
||||||
|
{
|
||||||
|
// unstack item pointed to by iterator if required
|
||||||
|
if (iter->getRefData().getCount() > 1)
|
||||||
|
{
|
||||||
|
// add the item again with a count of count-1, then set the count of the original (that will be equipped) to 1
|
||||||
|
int count = iter->getRefData().getCount();
|
||||||
|
iter->getRefData().setCount(count-1);
|
||||||
|
addImpl(*iter);
|
||||||
|
iter->getRefData().setCount(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
slots[*iter2] = iter;
|
slots[*iter2] = iter;
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user