Minetest  5.4.0
InventoryList Class Reference

#include <inventory.h>

+ Collaboration diagram for InventoryList:

Public Member Functions

 InventoryList (const std::string &name, u32 size, IItemDefManager *itemdef)
 
 ~InventoryList ()=default
 
void clearItems ()
 
void setSize (u32 newsize)
 
void setWidth (u32 newWidth)
 
void setName (const std::string &name)
 
void serialize (std::ostream &os, bool incremental) const
 
void deSerialize (std::istream &is)
 
 InventoryList (const InventoryList &other)
 
InventoryListoperator= (const InventoryList &other)
 
bool operator== (const InventoryList &other) const
 
bool operator!= (const InventoryList &other) const
 
const std::string & getName () const
 
u32 getSize () const
 
u32 getWidth () const
 
u32 getUsedSlots () const
 
u32 getFreeSlots () const
 
const ItemStackgetItem (u32 i) const
 
ItemStackgetItem (u32 i)
 
ItemStack changeItem (u32 i, const ItemStack &newitem)
 
void deleteItem (u32 i)
 
ItemStack addItem (const ItemStack &newitem)
 
ItemStack addItem (u32 i, const ItemStack &newitem)
 
bool itemFits (const u32 i, const ItemStack &newitem, ItemStack *restitem=NULL) const
 
bool roomForItem (const ItemStack &item) const
 
bool containsItem (const ItemStack &item, bool match_meta) const
 
ItemStack removeItem (const ItemStack &item)
 
ItemStack takeItem (u32 i, u32 takecount)
 
u32 moveItem (u32 i, InventoryList *dest, u32 dest_i, u32 count=0, bool swap_if_needed=true, bool *did_swap=NULL)
 
void moveItemSomewhere (u32 i, InventoryList *dest, u32 count)
 
bool checkModified () const
 
void setModified (bool dirty=true)
 

Private Attributes

std::vector< ItemStackm_items
 
std::string m_name
 
u32 m_size
 
u32 m_width = 0
 
IItemDefManagerm_itemdef
 
bool m_dirty = true
 

Constructor & Destructor Documentation

◆ InventoryList() [1/2]

InventoryList::InventoryList ( const std::string &  name,
u32  size,
IItemDefManager itemdef 
)

References clearItems().

+ Here is the call graph for this function:

◆ ~InventoryList()

InventoryList::~InventoryList ( )
default

◆ InventoryList() [2/2]

InventoryList::InventoryList ( const InventoryList other)

Member Function Documentation

◆ addItem() [1/2]

ItemStack InventoryList::addItem ( const ItemStack newitem)

References ItemStack::empty(), and m_items.

Referenced by Inventory::addItem(), IMoveAction::apply(), ICraftAction::apply(), RollbackAction::applyRevert(), InvRef::l_add_item(), moveItem(), and moveItemSomewhere().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addItem() [2/2]

ItemStack InventoryList::addItem ( u32  i,
const ItemStack newitem 
)

References m_itemdef, m_items, and setModified().

+ Here is the call graph for this function:

◆ changeItem()

ItemStack InventoryList::changeItem ( u32  i,
const ItemStack newitem 
)

References m_items, and setModified().

Referenced by IMoveAction::apply(), IDropAction::clientApply(), getCraftingResult(), InvRef::l_set_stack(), PlayerDatabaseSQLite3::loadPlayer(), moveItem(), moveItemSomewhere(), read_animation_definition(), PlayerSAO::setWieldedItem(), and Server::UpdateCrafting().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkModified()

bool InventoryList::checkModified ( ) const
inline

References m_dirty.

Referenced by Server::UpdateCrafting().

+ Here is the caller graph for this function:

◆ clearItems()

void InventoryList::clearItems ( )

References m_items, m_size, and setModified().

Referenced by InventoryList().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ containsItem()

bool InventoryList::containsItem ( const ItemStack item,
bool  match_meta 
) const

References ItemStack::count, m_items, ItemStack::metadata, and ItemStack::name.

Referenced by InvRef::l_contains_item().

+ Here is the caller graph for this function:

◆ deleteItem()

void InventoryList::deleteItem ( u32  i)

References m_items, and setModified().

Referenced by IMoveAction::apply(), and read_animation_definition().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deSerialize()

void InventoryList::deSerialize ( std::istream &  is)

References ItemStack::deSerialize(), getSize(), m_itemdef, m_items, m_name, m_width, and setModified().

Referenced by Inventory::deSerialize().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFreeSlots()

u32 InventoryList::getFreeSlots ( ) const

References getSize(), and getUsedSlots().

+ Here is the call graph for this function:

◆ getItem() [1/2]

ItemStack & InventoryList::getItem ( u32  i)

References m_items, and m_size.

◆ getItem() [2/2]

◆ getName()

const std::string & InventoryList::getName ( ) const

References m_name.

Referenced by PlayerDatabaseSQLite3::savePlayer().

+ Here is the caller graph for this function:

◆ getSize()

◆ getUsedSlots()

u32 InventoryList::getUsedSlots ( ) const

References m_items.

Referenced by getFreeSlots(), and InvRef::l_is_empty().

+ Here is the caller graph for this function:

◆ getWidth()

u32 InventoryList::getWidth ( ) const

References m_width.

Referenced by getCraftingResult(), InvRef::l_get_width(), PlayerDatabaseSQLite3::savePlayer(), and TestInventory::testSerializeDeserialize().

+ Here is the caller graph for this function:

◆ itemFits()

bool InventoryList::itemFits ( const u32  i,
const ItemStack newitem,
ItemStack restitem = NULL 
) const

References m_itemdef, and m_items.

Referenced by IMoveAction::apply(), ICraftAction::apply(), and roomForItem().

+ Here is the caller graph for this function:

◆ moveItem()

u32 InventoryList::moveItem ( u32  i,
InventoryList dest,
u32  dest_i,
u32  count = 0,
bool  swap_if_needed = true,
bool *  did_swap = NULL 
)

References addItem(), changeItem(), ItemStack::count, ItemStack::empty(), and takeItem().

Referenced by IMoveAction::apply(), and IMoveAction::clientApply().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ moveItemSomewhere()

void InventoryList::moveItemSomewhere ( u32  i,
InventoryList dest,
u32  count 
)

References addItem(), changeItem(), ItemStack::empty(), and takeItem().

Referenced by IMoveAction::clientApply().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator!=()

bool InventoryList::operator!= ( const InventoryList other) const
inline

◆ operator=()

InventoryList & InventoryList::operator= ( const InventoryList other)

References m_itemdef, m_items, m_name, m_size, and m_width.

◆ operator==()

bool InventoryList::operator== ( const InventoryList other) const

References m_items, m_name, m_size, and m_width.

◆ removeItem()

ItemStack InventoryList::removeItem ( const ItemStack item)

References ItemStack::addItem(), ItemStack::count, ItemStack::empty(), m_itemdef, m_items, ItemStack::name, and setModified().

Referenced by InvRef::l_remove_item().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ roomForItem()

bool InventoryList::roomForItem ( const ItemStack item) const

References itemFits(), and m_items.

Referenced by InvRef::l_room_for_item().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ serialize()

void InventoryList::serialize ( std::ostream &  os,
bool  incremental 
) const

References m_items, and m_width.

◆ setModified()

void InventoryList::setModified ( bool  dirty = true)
inline

References m_dirty.

Referenced by addItem(), Inventory::addList(), IMoveAction::apply(), IDropAction::apply(), changeItem(), clearItems(), deleteItem(), deSerialize(), removeItem(), setName(), setSize(), setWidth(), and takeItem().

+ Here is the caller graph for this function:

◆ setName()

void InventoryList::setName ( const std::string &  name)

References m_name, and setModified().

Referenced by content_nodemeta_deserialize_legacy_body(), and TestInventory::testSerializeDeserialize().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setSize()

void InventoryList::setSize ( u32  newsize)

References m_items, m_size, and setModified().

Referenced by Inventory::deSerialize(), and InvRef::l_set_size().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setWidth()

void InventoryList::setWidth ( u32  newWidth)

References m_width, and setModified().

Referenced by Player::Player(), InvRef::l_set_width(), PlayerDatabaseSQLite3::loadPlayer(), and TestInventory::testSerializeDeserialize().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ takeItem()

ItemStack InventoryList::takeItem ( u32  i,
u32  takecount 
)

References ItemStack::empty(), m_items, and setModified().

Referenced by IMoveAction::apply(), IDropAction::apply(), RollbackAction::applyRevert(), IDropAction::clientApply(), moveItem(), moveItemSomewhere(), and TestInventory::testSerializeDeserialize().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_dirty

bool InventoryList::m_dirty = true
private

Referenced by checkModified(), and setModified().

◆ m_itemdef

IItemDefManager* InventoryList::m_itemdef
private

◆ m_items

◆ m_name

std::string InventoryList::m_name
private

◆ m_size

u32 InventoryList::m_size
private

◆ m_width

u32 InventoryList::m_width = 0
private

The documentation for this class was generated from the following files: