mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-01 00:45:32 +00:00
added fill and clear functions to container store
This commit is contained in:
parent
e992a75615
commit
06e0706b35
2 changed files with 50 additions and 1 deletions
|
@ -5,6 +5,10 @@
|
|||
#include <typeinfo>
|
||||
#include <stdexcept>
|
||||
|
||||
#include <components/esm/loadcont.hpp>
|
||||
|
||||
#include "manualref.hpp"
|
||||
|
||||
MWWorld::ContainerStoreIterator MWWorld::ContainerStore::begin (int mask)
|
||||
{
|
||||
return ContainerStoreIterator (mask, this);
|
||||
|
@ -17,7 +21,7 @@ MWWorld::ContainerStoreIterator MWWorld::ContainerStore::end()
|
|||
|
||||
void MWWorld::ContainerStore::add (const Ptr& ptr)
|
||||
{
|
||||
/// \todo implement item stocking
|
||||
/// \todo implement item stacking
|
||||
|
||||
switch (getType (ptr))
|
||||
{
|
||||
|
@ -36,6 +40,40 @@ void MWWorld::ContainerStore::add (const Ptr& ptr)
|
|||
}
|
||||
}
|
||||
|
||||
void MWWorld::ContainerStore::fill (const ESM::InventoryList& items, const ESMS::ESMStore& store)
|
||||
{
|
||||
for (std::vector<ESM::ContItem>::const_iterator iter (items.list.begin()); iter!=items.list.end();
|
||||
++iter)
|
||||
{
|
||||
ManualRef ref (store, iter->item.toString());
|
||||
|
||||
if (ref.getPtr().getTypeName()==typeid (ESM::ItemLevList).name())
|
||||
{
|
||||
/// \todo implement leveled item lists
|
||||
continue;
|
||||
}
|
||||
|
||||
ref.getPtr().getRefData().setCount (iter->count);
|
||||
add (ref.getPtr());
|
||||
}
|
||||
}
|
||||
|
||||
void MWWorld::ContainerStore::clear()
|
||||
{
|
||||
potions.list.clear();
|
||||
appas.list.clear();
|
||||
armors.list.clear();
|
||||
books.list.clear();
|
||||
clothes.list.clear();
|
||||
ingreds.list.clear();
|
||||
lights.list.clear();
|
||||
lockpicks.list.clear();
|
||||
miscItems.list.clear();
|
||||
probes.list.clear();
|
||||
repairs.list.clear();
|
||||
weapons.list.clear();
|
||||
}
|
||||
|
||||
int MWWorld::ContainerStore::getType (const Ptr& ptr)
|
||||
{
|
||||
if (ptr.isEmpty())
|
||||
|
|
|
@ -6,6 +6,11 @@
|
|||
#include "refdata.hpp"
|
||||
#include "ptr.hpp"
|
||||
|
||||
namespace ESM
|
||||
{
|
||||
struct InventoryList;
|
||||
}
|
||||
|
||||
namespace MWWorld
|
||||
{
|
||||
class ContainerStoreIterator;
|
||||
|
@ -60,6 +65,12 @@ namespace MWWorld
|
|||
/// \attention Do not add items to an existing stack by increasing the count instead of
|
||||
/// calling this function!
|
||||
|
||||
void fill (const ESM::InventoryList& items, const ESMS::ESMStore& store);
|
||||
///< Insert items into *this.
|
||||
|
||||
void clear();
|
||||
///< Empty container.
|
||||
|
||||
static int getType (const Ptr& ptr);
|
||||
///< This function throws an exception, if ptr does not point to an object, that can be
|
||||
/// put into a container.
|
||||
|
|
Loading…
Reference in a new issue