mirror of https://github.com/OpenMW/openmw.git
added GetItemCount
parent
3ea85b4619
commit
589f8b5ede
@ -0,0 +1,43 @@
|
||||
|
||||
#include "containerutil.hpp"
|
||||
|
||||
namespace
|
||||
{
|
||||
template<typename T>
|
||||
void listItemsInContainerImp (const std::string& id,
|
||||
ESMS::CellRefList<T, MWWorld::RefData>& containerStore,
|
||||
const ESMS::RecListT<T>& store, std::vector<MWWorld::Ptr>& list)
|
||||
{
|
||||
if (const T *record = store.search (id))
|
||||
{
|
||||
for (typename ESMS::CellRefList<T, MWWorld::RefData>::List::iterator iter
|
||||
(containerStore.list.begin());
|
||||
iter!=containerStore.list.end(); ++iter)
|
||||
{
|
||||
if (iter->base==record)
|
||||
list.push_back (MWWorld::Ptr (&*iter, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace MWWorld
|
||||
{
|
||||
void listItemsInContainer (const std::string& id,
|
||||
ContainerStore<MWWorld::RefData>& containerStore,
|
||||
const ESMS::ESMStore& store, std::vector<Ptr>& list)
|
||||
{
|
||||
listItemsInContainerImp (id, containerStore.potions, store.potions, list);
|
||||
listItemsInContainerImp (id, containerStore.appas, store.appas, list);
|
||||
listItemsInContainerImp (id, containerStore.armors, store.armors, list);
|
||||
listItemsInContainerImp (id, containerStore.books, store.books, list);
|
||||
listItemsInContainerImp (id, containerStore.clothes, store.clothes, list);
|
||||
listItemsInContainerImp (id, containerStore.ingreds, store.ingreds, list);
|
||||
listItemsInContainerImp (id, containerStore.lights, store.lights, list);
|
||||
listItemsInContainerImp (id, containerStore.lockpicks, store.lockpicks, list);
|
||||
listItemsInContainerImp (id, containerStore.miscItems, store.miscItems, list);
|
||||
listItemsInContainerImp (id, containerStore.probes, store.probes, list);
|
||||
listItemsInContainerImp (id, containerStore.repairs, store.repairs, list);
|
||||
listItemsInContainerImp (id, containerStore.weapons, store.weapons, list);
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
#ifndef GAME_MWWORLD_CONTAINERUTIL_H
|
||||
#define GAME_MWWORLD_CONTAINERUTIL_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <components/esm_store/store.hpp>
|
||||
|
||||
#include "containerstore.hpp"
|
||||
#include "ptr.hpp"
|
||||
#include "refdata.hpp"
|
||||
|
||||
namespace MWWorld
|
||||
{
|
||||
void listItemsInContainer (const std::string& id, ContainerStore<MWWorld::RefData>& containerStore,
|
||||
const ESMS::ESMStore& store, std::vector<Ptr>& list);
|
||||
///< append all references with the given id to list.
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue