#include <inventory.h>
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) | |
InventoryList & | operator= (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 ItemStack & | getItem (u32 i) const |
ItemStack & | getItem (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< ItemStack > | m_items |
std::string | m_name |
u32 | m_size |
u32 | m_width = 0 |
IItemDefManager * | m_itemdef |
bool | m_dirty = true |
int | m_resize_locks = 0 |
using InventoryList::ResizeLocked = std::unique_ptr<InventoryList, ResizeUnlocker> |
InventoryList::InventoryList | ( | const std::string & | name, |
u32 | size, | ||
IItemDefManager * | itemdef ) |
|
default |
|
inline |
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().
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().
|
inline |
References m_dirty.
Referenced by Server::UpdateCrafting().
void InventoryList::checkResizeLock | ( | ) |
References m_name, and m_resize_locks.
Referenced by operator=(), and setSize().
void InventoryList::clearItems | ( | ) |
References m_items, m_size, and setModified().
Referenced by InventoryList(), and Inventory::addList().
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().
void InventoryList::deleteItem | ( | u32 | i | ) |
void InventoryList::deSerialize | ( | std::istream & | is | ) |
References ItemStack::deSerialize(), getSize(), m_itemdef, m_items, m_name, m_width, and setModified().
Referenced by Inventory::deSerialize().
|
inline |
References m_items, and m_size.
Referenced by IDropAction::apply(), RollbackAction::applyRevert(), GUIInventoryList::draw(), Hud::drawItems(), GUIFormSpecMenu::drawSelectedItem(), getCraftingResult(), Player::getWieldedItem(), ScriptApiItem::item_CraftPredict(), ScriptApiItem::item_OnCraft(), InvRef::l_get_stack(), moveItem(), moveItemSomewhere(), GUIFormSpecMenu::OnEvent(), PlayerDatabaseSQLite3::savePlayer(), TestMoveAction::testMove(), TestMoveAction::testMovePartial(), TestMoveAction::testMoveSomewhere(), TestMoveAction::testMoveSomewherePartial(), TestMoveAction::testMoveUnallowed(), TestInventory::testSerializeDeserialize(), TestMoveAction::testSwap(), TestMoveAction::testSwapFromUnallowed(), TestMoveAction::testSwapToUnallowed(), GUIFormSpecMenu::updateSelectedItem(), and GUIFormSpecMenu::verifySelectedItem().
|
inline |
References m_items.
Referenced by push_inventory_list().
|
inline |
References m_name.
Referenced by PlayerDatabaseSQLite3::savePlayer().
|
inline |
References m_items.
Referenced by ICraftAction::apply(), RollbackAction::applyRevert(), deSerialize(), GUIInventoryList::draw(), Hud::drawItems(), getCraftingResult(), GUIInventoryList::getItemIndexAtPos(), Player::getMaxHotbarItemcount(), ScriptApiItem::item_CraftPredict(), ScriptApiItem::item_OnCraft(), InvRef::l_get_size(), InvRef::l_get_stack(), InvRef::l_set_list(), InvRef::l_set_stack(), GUIFormSpecMenu::OnEvent(), PlayerDatabaseSQLite3::savePlayer(), Player::setWieldIndex(), Server::UpdateCrafting(), GUIFormSpecMenu::updateSelectedItem(), and GUIFormSpecMenu::verifySelectedItem().
u32 InventoryList::getUsedSlots | ( | ) | const |
|
inline |
References m_width.
Referenced by getCraftingResult(), InvRef::l_get_width(), PlayerDatabaseSQLite3::savePlayer(), and TestInventory::testSerializeDeserialize().
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().
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().
void InventoryList::moveItemSomewhere | ( | u32 | i, |
InventoryList * | dest, | ||
u32 | count ) |
References ItemStack::add(), addItem(), changeItem(), ItemStack::empty(), getItem(), and takeItem().
Referenced by IMoveAction::clientApply().
|
inline |
InventoryList & InventoryList::operator= | ( | const InventoryList & | other | ) |
bool InventoryList::operator== | ( | const InventoryList & | other | ) | const |
References ItemStack::addItem(), ItemStack::count, ItemStack::empty(), m_itemdef, m_items, ItemStack::name, and setModified().
Referenced by InvRef::l_remove_item().
|
inline |
References m_resize_locks.
Referenced by ICraftAction::apply(), IDropAction::apply(), and IMoveAction::apply().
bool InventoryList::roomForItem | ( | const ItemStack & | item | ) | const |
References itemFits(), and m_items.
Referenced by InvRef::l_room_for_item().
void InventoryList::serialize | ( | std::ostream & | os, |
bool | incremental ) const |
|
inline |
References m_dirty.
Referenced by addItem(), Inventory::addList(), IDropAction::apply(), changeItem(), clearItems(), deleteItem(), deSerialize(), removeItem(), setName(), setSize(), setWidth(), and takeItem().
void InventoryList::setName | ( | const std::string & | name | ) |
References m_name, and setModified().
Referenced by content_nodemeta_deserialize_legacy_body(), and TestInventory::testSerializeDeserialize().
void InventoryList::setSize | ( | u32 | newsize | ) |
References checkResizeLock(), m_items, m_size, and setModified().
Referenced by Inventory::addList(), Inventory::deSerialize(), and InvRef::l_set_size().
void InventoryList::setWidth | ( | u32 | newWidth | ) |
References m_width, and setModified().
Referenced by Player::Player(), InvRef::l_set_width(), PlayerDatabaseSQLite3::loadPlayer(), and TestInventory::testSerializeDeserialize().
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().
|
private |
Referenced by checkModified(), and setModified().
|
private |
Referenced by addItem(), deSerialize(), itemFits(), operator=(), and removeItem().
|
private |
Referenced by addItem(), addItem(), changeItem(), clearItems(), containsItem(), deleteItem(), deSerialize(), getItem(), getItem(), getItems(), getSize(), getUsedSlots(), itemFits(), operator=(), operator==(), removeItem(), roomForItem(), serialize(), setSize(), and takeItem().
|
private |
Referenced by checkResizeLock(), deSerialize(), getName(), operator=(), operator==(), and setName().
|
private |
Referenced by checkResizeLock(), InventoryList::ResizeUnlocker::operator()(), and resizeLock().
|
private |
Referenced by clearItems(), getItem(), getItem(), operator=(), operator==(), and setSize().
|
private |
Referenced by deSerialize(), getWidth(), operator=(), operator==(), serialize(), and setWidth().