summaryrefslogtreecommitdiffstats
path: root/source/Item.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-05-12 17:58:29 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-05-12 17:58:29 +0200
commit25cda4e8b4844aecf8cdc70ffcab8e0adaab3486 (patch)
treeb1fc6c925636c965f2df2fe1cb3d65e14181f5ce /source/Item.cpp
parentConverted the Noise3D generator to optimized noise and lerp (diff)
downloadcuberite-25cda4e8b4844aecf8cdc70ffcab8e0adaab3486.tar
cuberite-25cda4e8b4844aecf8cdc70ffcab8e0adaab3486.tar.gz
cuberite-25cda4e8b4844aecf8cdc70ffcab8e0adaab3486.tar.bz2
cuberite-25cda4e8b4844aecf8cdc70ffcab8e0adaab3486.tar.lz
cuberite-25cda4e8b4844aecf8cdc70ffcab8e0adaab3486.tar.xz
cuberite-25cda4e8b4844aecf8cdc70ffcab8e0adaab3486.tar.zst
cuberite-25cda4e8b4844aecf8cdc70ffcab8e0adaab3486.zip
Diffstat (limited to '')
-rw-r--r--source/Item.cpp59
1 files changed, 59 insertions, 0 deletions
diff --git a/source/Item.cpp b/source/Item.cpp
index fde4f7ba9..60bd7da95 100644
--- a/source/Item.cpp
+++ b/source/Item.cpp
@@ -138,3 +138,62 @@ bool cItem::IsEnchantable(short item)
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cItems:
+
+cItem * cItems::Get(int a_Idx)
+{
+ if ((a_Idx < 0) || (a_Idx >= (int)size()))
+ {
+ LOGWARNING("cItems: Attempt to get an out-of-bounds item at index %d; there are currently %d items. Returning a nil.", a_Idx, size());
+ return NULL;
+ }
+ return &at(a_Idx);
+}
+
+
+
+
+
+void cItems::Set(int a_Idx, const cItem & a_Item)
+{
+ if ((a_Idx < 0) || (a_Idx >= (int)size()))
+ {
+ LOGWARNING("cItems: Attempt to set an item at an out-of-bounds index %d; there are currently %d items. Not setting.", a_Idx, size());
+ return;
+ }
+ at(a_Idx) = a_Item;
+}
+
+
+
+
+
+void cItems::Delete(int a_Idx)
+{
+ if ((a_Idx < 0) || (a_Idx >= (int)size()))
+ {
+ LOGWARNING("cItems: Attempt to delete an item at an out-of-bounds index %d; there are currently %d items. Ignoring.", a_Idx, size());
+ return;
+ }
+ erase(begin() + a_Idx);
+}
+
+
+
+
+
+void cItems::Set(int a_Idx, ENUM_ITEM_ID a_ItemType, char a_ItemCount, short a_ItemDamage)
+{
+ if ((a_Idx < 0) || (a_Idx >= (int)size()))
+ {
+ LOGWARNING("cItems: Attempt to set an item at an out-of-bounds index %d; there are currently %d items. Not setting.", a_Idx, size());
+ return;
+ }
+ at(a_Idx) = cItem(a_ItemType, a_ItemCount, a_ItemDamage);
+}
+
+
+
+