summaryrefslogtreecommitdiffstats
path: root/src/Item.h
diff options
context:
space:
mode:
authorTobias Wilken <TooAngel@TooAngel.de>2020-07-14 18:56:42 +0200
committerGitHub <noreply@github.com>2020-07-14 18:56:42 +0200
commit36eab1b3237dbeeaaf5b48808bf0d47eb4bd32e9 (patch)
tree04c224231a800002692a296131af4988dd465845 /src/Item.h
parentCustom command depend is automatic (diff)
downloadcuberite-36eab1b3237dbeeaaf5b48808bf0d47eb4bd32e9.tar
cuberite-36eab1b3237dbeeaaf5b48808bf0d47eb4bd32e9.tar.gz
cuberite-36eab1b3237dbeeaaf5b48808bf0d47eb4bd32e9.tar.bz2
cuberite-36eab1b3237dbeeaaf5b48808bf0d47eb4bd32e9.tar.lz
cuberite-36eab1b3237dbeeaaf5b48808bf0d47eb4bd32e9.tar.xz
cuberite-36eab1b3237dbeeaaf5b48808bf0d47eb4bd32e9.tar.zst
cuberite-36eab1b3237dbeeaaf5b48808bf0d47eb4bd32e9.zip
Diffstat (limited to '')
-rw-r--r--src/Item.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/Item.h b/src/Item.h
index 175f044b5..2f7b1a238 100644
--- a/src/Item.h
+++ b/src/Item.h
@@ -169,6 +169,31 @@ public:
AStringVector m_LoreTable; // Exported in ManualBindings.cpp
+ /**
+ Compares two items for the same type or category. Type of item is defined
+ via `m_ItemType` and `m_ItemDamage`. Some items (e.g. planks) have the same
+ `m_ItemType` and the wood kind is defined via `m_ItemDamage`. `-1` is used
+ as placeholder for all kinds (e.g. all kind of planks).
+
+ Items are different when the `ItemType` is different or the `ItemDamage`
+ is different and unequal -1.
+ */
+ struct sItemCompare
+ {
+ bool operator() (const cItem & a_Lhs, const cItem & a_Rhs) const
+ {
+ if (a_Lhs.m_ItemType != a_Rhs.m_ItemType)
+ {
+ return (a_Lhs.m_ItemType < a_Rhs.m_ItemType);
+ }
+ if ((a_Lhs.m_ItemDamage == -1) || (a_Rhs.m_ItemDamage == -1))
+ {
+ return false; // -1 is a wildcard, damage of -1 alway compares equal
+ }
+ return (a_Lhs.m_ItemDamage < a_Rhs.m_ItemDamage);
+ }
+ };
+
// tolua_begin
int m_RepairCost;