QcItemData Class
The optional data of an item stack (decision E-823): typed components, each with a fixed id that is never reused (ids from QcItemData::firstModId on belong to mods). More...
| Header: | #include <common/gameplay/QcItemStack.h> |
Public Types
| enum class | Component { MapId, Contents, Name, Enchantments, PriorWork } |
Public Functions
| int | depth() const |
| bool | fitsLimits() const |
| bool | isEmpty() const |
| QcItemData | normalized() const |
| int | stacksInside() const |
| bool | operator==(const QcItemData &other) const |
Public Variables
| QList<QcItemStack> | contents |
| QList<QcEnchantment> | enchantments |
| QcKeptComponents | kept |
| quint32 | mapId |
| QString | name |
| int | priorWork |
Static Public Members
| int | compare(const QcItemData &a, const QcItemData &b) |
| const quint16 | firstModId |
| const qsizetype | maxContents |
| const int | maxDepth |
| const int | maxEnchantmentLevel |
| const qsizetype | maxEnchantmentName |
| const qsizetype | maxEnchantments |
| const qsizetype | maxNameLength |
| const int | maxPriorWork |
| const int | maxStacksInside |
Detailed Description
Saves keep components this version does not know (kept, QcComponentFrames); the wire carries only the known ones.
Member Type Documentation
enum class QcItemData::Component
The ids of the known components.
| Constant | Value | Description |
|---|---|---|
QcItemData::Component::MapId | 1 | The map id of a filled map (mapId). |
QcItemData::Component::Contents | 2 | The stacks held inside (contents). |
QcItemData::Component::Name | 3 | The custom name (name). |
QcItemData::Component::Enchantments | 4 | The enchantments (enchantments). |
QcItemData::Component::PriorWork | 5 | The anvil uses (priorWork). |
Member Function Documentation
[static] int QcItemData::compare(const QcItemData &a, const QcItemData &b)
Returns the order of a and b in a total order of data (QcItemStack::compare): negative, 0 or positive.
int QcItemData::depth() const
Returns how deep its contents nest: 0 without contents, 1 for contents without contents, ….
bool QcItemData::fitsLimits() const
Returns whether it keeps the limits every reader checks: a name of at most maxNameLength characters, at most maxContents slots, maxDepth levels and maxStacksInside stacks (the stacks inside were checked when they got their data).
bool QcItemData::isEmpty() const
Returns whether it holds no component.
QcItemData QcItemData::normalized() const
Returns the same data with trailing empty slots of the contents left out.
int QcItemData::stacksInside() const
Returns how many stacks its contents hold on all levels together, empty slots included.
bool QcItemData::operator==(const QcItemData &other) const
Returns whether other holds the same components.
Member Variable Documentation
QList<QcItemStack> QcItemData::contents
The stacks held inside, by slot; trailing empty slots are left out, so all empty is none.
QList<QcEnchantment> QcItemData::enchantments
The enchantments; empty for none.
const quint16 QcItemData::firstModId
The first component id that belongs to mods.
QcKeptComponents QcItemData::kept
Components read from a save this version does not know, written back as read.
quint32 QcItemData::mapId
The map id of a filled map; 0: none.
const qsizetype QcItemData::maxContents
The most stacks a contents list holds (slots, empty ones included).
const int QcItemData::maxDepth
Contents nest at most this deep (a stack in a stack in a stack); deeper is damaged data.
const qsizetype QcItemData::maxNameLength
The longest custom name (characters).
const int QcItemData::maxPriorWork
The most anvil uses a stack remembers (decision E-866); its penalty is 2^priorWork − 1 levels.
const int QcItemData::maxStacksInside
The most stacks inside one stack on all levels together (empty slots included). With the other limits a stack without contents takes at most about 2.2 KB on the wire (item, count and damage 12 bytes, map id 4, a name of maxNameLength characters 104, maxEnchantments enchantments of maxEnchantmentName characters 2128, and the component bits, counts and prior work), so the largest stack, with maxStacksInside stacks inside, takes about 146 KB. Every list of stacks a message carries is bounded by its own size (QcProtocolCodec::readStacks), so the largest message of such stacks stays below a frame (QcProtocol::maxFrameBytes): a trade screen with its 96 stacks takes about 14 MB, a player's inventory with its 50 stacks about 7 MB (test_item_data_limits). Stacks from clients carry no contents (QcProtocolCodec::readFlatStack).
QString QcItemData::name
The custom name; empty for none.
int QcItemData::priorWork
How often the stack went through an anvil (decision E-866); 0 for never.