mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-04 11:39:42 +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 <typeinfo>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
|
#include <components/esm/loadcont.hpp>
|
||||||
|
|
||||||
|
#include "manualref.hpp"
|
||||||
|
|
||||||
MWWorld::ContainerStoreIterator MWWorld::ContainerStore::begin (int mask)
|
MWWorld::ContainerStoreIterator MWWorld::ContainerStore::begin (int mask)
|
||||||
{
|
{
|
||||||
return ContainerStoreIterator (mask, this);
|
return ContainerStoreIterator (mask, this);
|
||||||
|
@ -17,7 +21,7 @@ MWWorld::ContainerStoreIterator MWWorld::ContainerStore::end()
|
||||||
|
|
||||||
void MWWorld::ContainerStore::add (const Ptr& ptr)
|
void MWWorld::ContainerStore::add (const Ptr& ptr)
|
||||||
{
|
{
|
||||||
/// \todo implement item stocking
|
/// \todo implement item stacking
|
||||||
|
|
||||||
switch (getType (ptr))
|
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)
|
int MWWorld::ContainerStore::getType (const Ptr& ptr)
|
||||||
{
|
{
|
||||||
if (ptr.isEmpty())
|
if (ptr.isEmpty())
|
||||||
|
|
|
@ -6,6 +6,11 @@
|
||||||
#include "refdata.hpp"
|
#include "refdata.hpp"
|
||||||
#include "ptr.hpp"
|
#include "ptr.hpp"
|
||||||
|
|
||||||
|
namespace ESM
|
||||||
|
{
|
||||||
|
struct InventoryList;
|
||||||
|
}
|
||||||
|
|
||||||
namespace MWWorld
|
namespace MWWorld
|
||||||
{
|
{
|
||||||
class ContainerStoreIterator;
|
class ContainerStoreIterator;
|
||||||
|
@ -60,6 +65,12 @@ namespace MWWorld
|
||||||
/// \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!
|
||||||
|
|
||||||
|
void fill (const ESM::InventoryList& items, const ESMS::ESMStore& store);
|
||||||
|
///< Insert items into *this.
|
||||||
|
|
||||||
|
void clear();
|
||||||
|
///< Empty container.
|
||||||
|
|
||||||
static int getType (const Ptr& ptr);
|
static int getType (const Ptr& ptr);
|
||||||
///< This function throws an exception, if ptr does not point to an object, that can be
|
///< This function throws an exception, if ptr does not point to an object, that can be
|
||||||
/// put into a container.
|
/// put into a container.
|
||||||
|
|
Loading…
Reference in a new issue