summaryrefslogtreecommitdiffstats
path: root/source/Item.h
diff options
context:
space:
mode:
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