summaryrefslogtreecommitdiffstats
path: root/source/Item.h
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.h
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 'source/Item.h')
-rw-r--r--source/Item.h15
1 files changed, 7 insertions, 8 deletions
diff --git a/source/Item.h b/source/Item.h
index 570182bae..3b485d3de 100644
--- a/source/Item.h
+++ b/source/Item.h
@@ -92,8 +92,10 @@ public:
-// This stupid construct is here only so that Lua can access cItems in an API
+/** This class bridges a vector of cItem for safe access via Lua. It checks boundaries for all accesses
+Note that this class is zero-indexed!
+*/
class cItems // tolua_export
: public std::vector<cItem>
{ // tolua_export
@@ -103,22 +105,19 @@ public:
/// Need a Lua-accessible constructor
cItems(void) {}
- cItem & Get (int a_Idx) {return at(a_Idx); }
- void Set (int a_Idx, const cItem & a_Item) {at(a_Idx) = a_Item; }
+ cItem * Get (int a_Idx);
+ void Set (int a_Idx, const cItem & a_Item);
void Add (const cItem & a_Item) {push_back(a_Item); }
- void Delete(int a_Idx) {erase(begin() + a_Idx); }
+ void Delete(int a_Idx);
void Clear (void) {clear(); }
int Size (void) {return size(); }
+ void Set (int a_Idx, ENUM_ITEM_ID a_ItemType, char a_ItemCount, short a_ItemDamage);
void Add (ENUM_ITEM_ID a_ItemType, char a_ItemCount, short a_ItemDamage)
{
push_back(cItem(a_ItemType, a_ItemCount, a_ItemDamage));
}
- void Set (int a_Idx, ENUM_ITEM_ID a_ItemType, char a_ItemCount, short a_ItemDamage)
- {
- at(a_Idx) = cItem(a_ItemType, a_ItemCount, a_ItemDamage);
- }
// tolua_end
} ; // tolua_export