mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-22 17:18:39 +00:00
Fix the documentation of InvRef:get_lists() and clean up code (#12150)
This commit is contained in:
parent
0f25fa7af6
commit
8d387433b1
10 changed files with 56 additions and 96 deletions
|
@ -198,7 +198,7 @@ public:
|
|||
void serialize(std::ostream &os, bool incremental) const;
|
||||
void deSerialize(std::istream &is);
|
||||
|
||||
InventoryList(const InventoryList &other);
|
||||
InventoryList(const InventoryList &other) { *this = other; }
|
||||
InventoryList & operator = (const InventoryList &other);
|
||||
bool operator == (const InventoryList &other) const;
|
||||
bool operator != (const InventoryList &other) const
|
||||
|
@ -206,15 +206,25 @@ public:
|
|||
return !(*this == other);
|
||||
}
|
||||
|
||||
const std::string &getName() const;
|
||||
u32 getSize() const;
|
||||
u32 getWidth() const;
|
||||
const std::string &getName() const { return m_name; }
|
||||
u32 getSize() const { return static_cast<u32>(m_items.size()); }
|
||||
u32 getWidth() const { return m_width; }
|
||||
// Count used slots
|
||||
u32 getUsedSlots() const;
|
||||
|
||||
// Get reference to item
|
||||
const ItemStack& getItem(u32 i) const;
|
||||
ItemStack& getItem(u32 i);
|
||||
const ItemStack &getItem(u32 i) const
|
||||
{
|
||||
assert(i < m_size); // Pre-condition
|
||||
return m_items[i];
|
||||
}
|
||||
ItemStack &getItem(u32 i)
|
||||
{
|
||||
assert(i < m_size); // Pre-condition
|
||||
return m_items[i];
|
||||
}
|
||||
// Get reference to all items
|
||||
const std::vector<ItemStack> &getItems() const { return m_items; }
|
||||
// Returns old item. Parameter can be an empty item.
|
||||
ItemStack changeItem(u32 i, const ItemStack &newitem);
|
||||
// Delete item
|
||||
|
@ -271,7 +281,7 @@ public:
|
|||
private:
|
||||
std::vector<ItemStack> m_items;
|
||||
std::string m_name;
|
||||
u32 m_size;
|
||||
u32 m_size; // always the same as m_items.size()
|
||||
u32 m_width = 0;
|
||||
IItemDefManager *m_itemdef;
|
||||
bool m_dirty = true;
|
||||
|
@ -301,7 +311,7 @@ public:
|
|||
InventoryList * addList(const std::string &name, u32 size);
|
||||
InventoryList * getList(const std::string &name);
|
||||
const InventoryList * getList(const std::string &name) const;
|
||||
std::vector<const InventoryList*> getLists();
|
||||
const std::vector<InventoryList *> &getLists() const { return m_lists; }
|
||||
bool deleteList(const std::string &name);
|
||||
// A shorthand for adding items. Returns leftover item (possibly empty).
|
||||
ItemStack addItem(const std::string &listname, const ItemStack &newitem)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue