summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-07-26 21:50:06 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-07-26 21:50:06 +0200
commitcd8720bf7e07c681ef90ba6159afbf53f5546ed2 (patch)
treed34f62f52260b0029b3b0948a149c539ac5fe88a
parentAdded a shortcut for running under helgrind with the most common parameters and suppressions (diff)
downloadcuberite-cd8720bf7e07c681ef90ba6159afbf53f5546ed2.tar
cuberite-cd8720bf7e07c681ef90ba6159afbf53f5546ed2.tar.gz
cuberite-cd8720bf7e07c681ef90ba6159afbf53f5546ed2.tar.bz2
cuberite-cd8720bf7e07c681ef90ba6159afbf53f5546ed2.tar.lz
cuberite-cd8720bf7e07c681ef90ba6159afbf53f5546ed2.tar.xz
cuberite-cd8720bf7e07c681ef90ba6159afbf53f5546ed2.tar.zst
cuberite-cd8720bf7e07c681ef90ba6159afbf53f5546ed2.zip
-rw-r--r--source/Bindings.cpp39
-rw-r--r--source/Bindings.h2
-rw-r--r--source/Inventory.cpp16
-rw-r--r--source/Inventory.h6
4 files changed, 61 insertions, 2 deletions
diff --git a/source/Bindings.cpp b/source/Bindings.cpp
index 8963c9231..fd85abba9 100644
--- a/source/Bindings.cpp
+++ b/source/Bindings.cpp
@@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
-** Generated automatically by tolua++-1.0.92 on 07/12/13 22:26:52.
+** Generated automatically by tolua++-1.0.92 on 07/26/13 21:48:46.
*/
#ifndef __cplusplus
@@ -14309,6 +14309,42 @@ static int tolua_AllToLua_cInventory_GetEquippedSlotNum00(lua_State* tolua_S)
}
#endif //#ifndef TOLUA_DISABLE
+/* method: ChangeSlotCount of class cInventory */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cInventory_ChangeSlotCount00
+static int tolua_AllToLua_cInventory_ChangeSlotCount00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cInventory",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cInventory* self = (cInventory*) tolua_tousertype(tolua_S,1,0);
+ int a_SlotNum = ((int) tolua_tonumber(tolua_S,2,0));
+ int a_AddToCount = ((int) tolua_tonumber(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'ChangeSlotCount'", NULL);
+#endif
+ {
+ int tolua_ret = (int) self->ChangeSlotCount(a_SlotNum,a_AddToCount);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'ChangeSlotCount'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
/* method: DamageItem of class cInventory */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cInventory_DamageItem00
static int tolua_AllToLua_cInventory_DamageItem00(lua_State* tolua_S)
@@ -29094,6 +29130,7 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_function(tolua_S,"SetHotbarSlot",tolua_AllToLua_cInventory_SetHotbarSlot00);
tolua_function(tolua_S,"SetEquippedSlotNum",tolua_AllToLua_cInventory_SetEquippedSlotNum00);
tolua_function(tolua_S,"GetEquippedSlotNum",tolua_AllToLua_cInventory_GetEquippedSlotNum00);
+ tolua_function(tolua_S,"ChangeSlotCount",tolua_AllToLua_cInventory_ChangeSlotCount00);
tolua_function(tolua_S,"DamageItem",tolua_AllToLua_cInventory_DamageItem00);
tolua_function(tolua_S,"DamageEquippedItem",tolua_AllToLua_cInventory_DamageEquippedItem00);
tolua_function(tolua_S,"GetEquippedHelmet",tolua_AllToLua_cInventory_GetEquippedHelmet00);
diff --git a/source/Bindings.h b/source/Bindings.h
index 9685235b3..c21612525 100644
--- a/source/Bindings.h
+++ b/source/Bindings.h
@@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
-** Generated automatically by tolua++-1.0.92 on 07/12/13 22:26:52.
+** Generated automatically by tolua++-1.0.92 on 07/26/13 21:48:46.
*/
/* Exported function */
diff --git a/source/Inventory.cpp b/source/Inventory.cpp
index b56f50ed7..74294e80e 100644
--- a/source/Inventory.cpp
+++ b/source/Inventory.cpp
@@ -336,6 +336,22 @@ bool cInventory::DamageEquippedItem(short a_Amount)
+int cInventory::ChangeSlotCount(int a_SlotNum, int a_AddToCount)
+{
+ int GridSlotNum = 0;
+ cItemGrid * Grid = GetGridForSlotNum(a_SlotNum, GridSlotNum);
+ if (Grid == NULL)
+ {
+ LOGWARNING("%s: invalid slot number, expected 0 .. %d, got %d; ignoring", __FUNCTION__, invNumSlots, a_SlotNum);
+ return -1;
+ }
+ return Grid->ChangeSlotCount(GridSlotNum, a_AddToCount);
+}
+
+
+
+
+
bool cInventory::DamageItem(int a_SlotNum, short a_Amount)
{
if ((a_SlotNum < 0) || (a_SlotNum >= invNumSlots))
diff --git a/source/Inventory.h b/source/Inventory.h
index 9ddd00ecd..f8f8042f4 100644
--- a/source/Inventory.h
+++ b/source/Inventory.h
@@ -130,6 +130,12 @@ public:
void SetEquippedSlotNum(int a_SlotNum);
int GetEquippedSlotNum(void) { return m_EquippedSlotNum; }
+ /** Adds (or subtracts, if a_AddToCount is negative) to the count of items in the specified slot.
+ If the slot is empty, ignores the call.
+ Returns the new count, or -1 if the slot number is invalid.
+ */
+ int ChangeSlotCount(int a_SlotNum, int a_AddToCount);
+
/// Adds the specified damage to the specified item; deletes the item and returns true if the item broke.
bool DamageItem(int a_SlotNum, short a_Amount);