Luanti 5.10.0-dev
 
Loading...
Searching...
No Matches
InventoryList Class Reference

#include <inventory.h>

+ Collaboration diagram for InventoryList:

Classes

struct  ResizeUnlocker
 

Public Types

using ResizeLocked = std::unique_ptr<InventoryList, ResizeUnlocker>
 

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
 
const ItemStackgetItem (u32 i) const
 
ItemStackgetItem (u32 i)
 
const std::vector< ItemStack > & getItems () const
 
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)
 
ItemStack 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)
 
void checkResizeLock ()
 
ResizeLocked resizeLock ()
 

Private Attributes

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

Member Typedef Documentation

◆ ResizeLocked

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)
inline

Member Function Documentation

◆ addItem() [1/2]

ItemStack InventoryList::addItem ( const ItemStack & newitem)

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

Referenced by Inventory::addItem(), addItem(), ICraftAction::apply(), RollbackAction::applyRevert(), InvRef::l_add_item(), moveItem(), moveItemSomewhere(), GUIFormSpecMenu::OnEvent(), TestMoveAction::testCallbacks(), TestMoveAction::testCallbacksSwap(), TestMoveAction::testMove(), TestMoveAction::testMovePartial(), TestMoveAction::testMoveSomewhere(), TestMoveAction::testMoveSomewherePartial(), TestMoveAction::testMoveUnallowed(), TestMoveAction::testSwap(), TestMoveAction::testSwapFromUnallowed(), and TestMoveAction::testSwapToUnallowed().

+ 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 IDropAction::clientApply(), getCraftingResult(), InvRef::l_set_stack(), PlayerDatabaseSQLite3::loadPlayer(), moveItem(), moveItemSomewhere(), GUIFormSpecMenu::OnEvent(), read_inventory_list(), PlayerSAO::setWieldedItem(), TestMoveAction::testMoveFillStack(), TestMoveAction::testMoveSomewherePartial(), 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:

◆ checkResizeLock()

void InventoryList::checkResizeLock ( )

References m_name, and m_resize_locks.

Referenced by operator=(), and setSize().

+ Here is the caller graph for this function:

◆ clearItems()

void InventoryList::clearItems ( )

References m_items, m_size, and setModified().

Referenced by InventoryList(), and Inventory::addList().

+ 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().

+ Here is the call 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:

◆ getItem() [1/2]

ItemStack & InventoryList::getItem ( u32 i)
inline

References m_items, and m_size.

◆ getItem() [2/2]

◆ getItems()

const std::vector< ItemStack > & InventoryList::getItems ( ) const
inline

References m_items.

Referenced by push_inventory_list().

+ Here is the caller graph for this function:

◆ getName()

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

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 InvRef::l_is_empty().

+ Here is the caller graph for this function:

◆ getWidth()

u32 InventoryList::getWidth ( ) const
inline

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 ICraftAction::apply(), and roomForItem().

+ Here is the caller graph for this function:

◆ moveItem()

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

References ItemStack::add(), addItem(), changeItem(), ItemStack::clear(), ItemStack::count, ItemStack::empty(), getItem(), ItemStack::remove(), and takeItem().

Referenced by 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 ItemStack::add(), addItem(), changeItem(), ItemStack::empty(), getItem(), 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 checkResizeLock(), m_itemdef, m_items, m_name, m_size, and m_width.

+ Here is the call graph for this function:

◆ 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:

◆ resizeLock()

ResizeLocked InventoryList::resizeLock ( )
inline

References m_resize_locks.

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

+ 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(), 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 checkResizeLock(), m_items, m_size, and setModified().

Referenced by Inventory::addList(), 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 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_resize_locks

int InventoryList::m_resize_locks = 0
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: