summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-04-10 23:03:15 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-04-10 23:03:15 +0200
commit929d29996585c4f2e4461519ccf2803936b81ae1 (patch)
tree86a5210c4384c9292d2d7b697f24d1dc8a6e2e6a
parentAdded cItemGrid to represent an XY grid of items; converted chests to use cItemGrid. (diff)
downloadcuberite-929d29996585c4f2e4461519ccf2803936b81ae1.tar
cuberite-929d29996585c4f2e4461519ccf2803936b81ae1.tar.gz
cuberite-929d29996585c4f2e4461519ccf2803936b81ae1.tar.bz2
cuberite-929d29996585c4f2e4461519ccf2803936b81ae1.tar.lz
cuberite-929d29996585c4f2e4461519ccf2803936b81ae1.tar.xz
cuberite-929d29996585c4f2e4461519ccf2803936b81ae1.tar.zst
cuberite-929d29996585c4f2e4461519ccf2803936b81ae1.zip
Diffstat (limited to '')
-rw-r--r--source/Bindings.cpp114
-rw-r--r--source/Bindings.h2
-rw-r--r--source/ChestEntity.cpp4
-rw-r--r--source/ChestEntity.h4
-rw-r--r--source/ItemGrid.cpp80
-rw-r--r--source/ItemGrid.h22
-rw-r--r--source/WorldStorage/NBTChunkSerializer.cpp2
7 files changed, 114 insertions, 114 deletions
diff --git a/source/Bindings.cpp b/source/Bindings.cpp
index d88fb39c5..1b73d56a2 100644
--- a/source/Bindings.cpp
+++ b/source/Bindings.cpp
@@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
-** Generated automatically by tolua++-1.0.92 on 04/10/13 21:35:56.
+** Generated automatically by tolua++-1.0.92 on 04/10/13 23:01:46.
*/
#ifndef __cplusplus
@@ -13710,9 +13710,9 @@ static int tolua_AllToLua_cItemGrid_GetSlotNum00(lua_State* tolua_S)
}
#endif //#ifndef TOLUA_DISABLE
-/* method: GetItem of class cItemGrid */
-#ifndef TOLUA_DISABLE_tolua_AllToLua_cItemGrid_GetItem00
-static int tolua_AllToLua_cItemGrid_GetItem00(lua_State* tolua_S)
+/* method: GetSlot of class cItemGrid */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cItemGrid_GetSlot00
+static int tolua_AllToLua_cItemGrid_GetSlot00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
@@ -13730,25 +13730,25 @@ static int tolua_AllToLua_cItemGrid_GetItem00(lua_State* tolua_S)
int a_X = ((int) tolua_tonumber(tolua_S,2,0));
int a_Y = ((int) tolua_tonumber(tolua_S,3,0));
#ifndef TOLUA_RELEASE
- if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetItem'", NULL);
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetSlot'", NULL);
#endif
{
- const cItem& tolua_ret = (const cItem&) self->GetItem(a_X,a_Y);
+ const cItem& tolua_ret = (const cItem&) self->GetSlot(a_X,a_Y);
tolua_pushusertype(tolua_S,(void*)&tolua_ret,"const cItem");
}
}
return 1;
#ifndef TOLUA_RELEASE
tolua_lerror:
- tolua_error(tolua_S,"#ferror in function 'GetItem'.",&tolua_err);
+ tolua_error(tolua_S,"#ferror in function 'GetSlot'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
-/* method: GetItem of class cItemGrid */
-#ifndef TOLUA_DISABLE_tolua_AllToLua_cItemGrid_GetItem01
-static int tolua_AllToLua_cItemGrid_GetItem01(lua_State* tolua_S)
+/* method: GetSlot of class cItemGrid */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cItemGrid_GetSlot01
+static int tolua_AllToLua_cItemGrid_GetSlot01(lua_State* tolua_S)
{
tolua_Error tolua_err;
if (
@@ -13764,22 +13764,22 @@ static int tolua_AllToLua_cItemGrid_GetItem01(lua_State* tolua_S)
int a_X = ((int) tolua_tonumber(tolua_S,2,0));
int a_Y = ((int) tolua_tonumber(tolua_S,3,0));
#ifndef TOLUA_RELEASE
- if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetItem'", NULL);
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetSlot'", NULL);
#endif
{
- cItem& tolua_ret = (cItem&) self->GetItem(a_X,a_Y);
+ cItem& tolua_ret = (cItem&) self->GetSlot(a_X,a_Y);
tolua_pushusertype(tolua_S,(void*)&tolua_ret,"cItem");
}
}
return 1;
tolua_lerror:
- return tolua_AllToLua_cItemGrid_GetItem00(tolua_S);
+ return tolua_AllToLua_cItemGrid_GetSlot00(tolua_S);
}
#endif //#ifndef TOLUA_DISABLE
-/* method: GetItem of class cItemGrid */
-#ifndef TOLUA_DISABLE_tolua_AllToLua_cItemGrid_GetItem02
-static int tolua_AllToLua_cItemGrid_GetItem02(lua_State* tolua_S)
+/* method: GetSlot of class cItemGrid */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cItemGrid_GetSlot02
+static int tolua_AllToLua_cItemGrid_GetSlot02(lua_State* tolua_S)
{
tolua_Error tolua_err;
if (
@@ -13793,22 +13793,22 @@ static int tolua_AllToLua_cItemGrid_GetItem02(lua_State* tolua_S)
const cItemGrid* self = (const cItemGrid*) tolua_tousertype(tolua_S,1,0);
int a_SlotNum = ((int) tolua_tonumber(tolua_S,2,0));
#ifndef TOLUA_RELEASE
- if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetItem'", NULL);
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetSlot'", NULL);
#endif
{
- const cItem& tolua_ret = (const cItem&) self->GetItem(a_SlotNum);
+ const cItem& tolua_ret = (const cItem&) self->GetSlot(a_SlotNum);
tolua_pushusertype(tolua_S,(void*)&tolua_ret,"const cItem");
}
}
return 1;
tolua_lerror:
- return tolua_AllToLua_cItemGrid_GetItem01(tolua_S);
+ return tolua_AllToLua_cItemGrid_GetSlot01(tolua_S);
}
#endif //#ifndef TOLUA_DISABLE
-/* method: GetItem of class cItemGrid */
-#ifndef TOLUA_DISABLE_tolua_AllToLua_cItemGrid_GetItem03
-static int tolua_AllToLua_cItemGrid_GetItem03(lua_State* tolua_S)
+/* method: GetSlot of class cItemGrid */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cItemGrid_GetSlot03
+static int tolua_AllToLua_cItemGrid_GetSlot03(lua_State* tolua_S)
{
tolua_Error tolua_err;
if (
@@ -13822,22 +13822,22 @@ static int tolua_AllToLua_cItemGrid_GetItem03(lua_State* tolua_S)
cItemGrid* self = (cItemGrid*) tolua_tousertype(tolua_S,1,0);
int a_SlotNum = ((int) tolua_tonumber(tolua_S,2,0));
#ifndef TOLUA_RELEASE
- if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetItem'", NULL);
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetSlot'", NULL);
#endif
{
- cItem& tolua_ret = (cItem&) self->GetItem(a_SlotNum);
+ cItem& tolua_ret = (cItem&) self->GetSlot(a_SlotNum);
tolua_pushusertype(tolua_S,(void*)&tolua_ret,"cItem");
}
}
return 1;
tolua_lerror:
- return tolua_AllToLua_cItemGrid_GetItem02(tolua_S);
+ return tolua_AllToLua_cItemGrid_GetSlot02(tolua_S);
}
#endif //#ifndef TOLUA_DISABLE
-/* method: SetItem of class cItemGrid */
-#ifndef TOLUA_DISABLE_tolua_AllToLua_cItemGrid_SetItem00
-static int tolua_AllToLua_cItemGrid_SetItem00(lua_State* tolua_S)
+/* method: SetSlot of class cItemGrid */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cItemGrid_SetSlot00
+static int tolua_AllToLua_cItemGrid_SetSlot00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
@@ -13857,24 +13857,24 @@ static int tolua_AllToLua_cItemGrid_SetItem00(lua_State* tolua_S)
int a_Y = ((int) tolua_tonumber(tolua_S,3,0));
const cItem* a_Item = ((const cItem*) tolua_tousertype(tolua_S,4,0));
#ifndef TOLUA_RELEASE
- if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetItem'", NULL);
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetSlot'", NULL);
#endif
{
- self->SetItem(a_X,a_Y,*a_Item);
+ self->SetSlot(a_X,a_Y,*a_Item);
}
}
return 0;
#ifndef TOLUA_RELEASE
tolua_lerror:
- tolua_error(tolua_S,"#ferror in function 'SetItem'.",&tolua_err);
+ tolua_error(tolua_S,"#ferror in function 'SetSlot'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
-/* method: SetItem of class cItemGrid */
-#ifndef TOLUA_DISABLE_tolua_AllToLua_cItemGrid_SetItem01
-static int tolua_AllToLua_cItemGrid_SetItem01(lua_State* tolua_S)
+/* method: SetSlot of class cItemGrid */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cItemGrid_SetSlot01
+static int tolua_AllToLua_cItemGrid_SetSlot01(lua_State* tolua_S)
{
tolua_Error tolua_err;
if (
@@ -13896,21 +13896,21 @@ static int tolua_AllToLua_cItemGrid_SetItem01(lua_State* tolua_S)
char a_ItemCount = ((char) tolua_tonumber(tolua_S,5,0));
short a_ItemDamage = ((short) tolua_tonumber(tolua_S,6,0));
#ifndef TOLUA_RELEASE
- if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetItem'", NULL);
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetSlot'", NULL);
#endif
{
- self->SetItem(a_X,a_Y,a_ItemType,a_ItemCount,a_ItemDamage);
+ self->SetSlot(a_X,a_Y,a_ItemType,a_ItemCount,a_ItemDamage);
}
}
return 0;
tolua_lerror:
- return tolua_AllToLua_cItemGrid_SetItem00(tolua_S);
+ return tolua_AllToLua_cItemGrid_SetSlot00(tolua_S);
}
#endif //#ifndef TOLUA_DISABLE
-/* method: SetItem of class cItemGrid */
-#ifndef TOLUA_DISABLE_tolua_AllToLua_cItemGrid_SetItem02
-static int tolua_AllToLua_cItemGrid_SetItem02(lua_State* tolua_S)
+/* method: SetSlot of class cItemGrid */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cItemGrid_SetSlot02
+static int tolua_AllToLua_cItemGrid_SetSlot02(lua_State* tolua_S)
{
tolua_Error tolua_err;
if (
@@ -13926,21 +13926,21 @@ static int tolua_AllToLua_cItemGrid_SetItem02(lua_State* tolua_S)
int a_SlotNum = ((int) tolua_tonumber(tolua_S,2,0));
const cItem* a_Item = ((const cItem*) tolua_tousertype(tolua_S,3,0));
#ifndef TOLUA_RELEASE
- if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetItem'", NULL);
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetSlot'", NULL);
#endif
{
- self->SetItem(a_SlotNum,*a_Item);
+ self->SetSlot(a_SlotNum,*a_Item);
}
}
return 0;
tolua_lerror:
- return tolua_AllToLua_cItemGrid_SetItem01(tolua_S);
+ return tolua_AllToLua_cItemGrid_SetSlot01(tolua_S);
}
#endif //#ifndef TOLUA_DISABLE
-/* method: SetItem of class cItemGrid */
-#ifndef TOLUA_DISABLE_tolua_AllToLua_cItemGrid_SetItem03
-static int tolua_AllToLua_cItemGrid_SetItem03(lua_State* tolua_S)
+/* method: SetSlot of class cItemGrid */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cItemGrid_SetSlot03
+static int tolua_AllToLua_cItemGrid_SetSlot03(lua_State* tolua_S)
{
tolua_Error tolua_err;
if (
@@ -13960,15 +13960,15 @@ static int tolua_AllToLua_cItemGrid_SetItem03(lua_State* tolua_S)
char a_ItemCount = ((char) tolua_tonumber(tolua_S,4,0));
short a_ItemDamage = ((short) tolua_tonumber(tolua_S,5,0));
#ifndef TOLUA_RELEASE
- if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetItem'", NULL);
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetSlot'", NULL);
#endif
{
- self->SetItem(a_SlotNum,a_ItemType,a_ItemCount,a_ItemDamage);
+ self->SetSlot(a_SlotNum,a_ItemType,a_ItemCount,a_ItemDamage);
}
}
return 0;
tolua_lerror:
- return tolua_AllToLua_cItemGrid_SetItem02(tolua_S);
+ return tolua_AllToLua_cItemGrid_SetSlot02(tolua_S);
}
#endif //#ifndef TOLUA_DISABLE
@@ -24795,14 +24795,14 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_function(tolua_S,"GetHeight",tolua_AllToLua_cItemGrid_GetHeight00);
tolua_function(tolua_S,"GetNumSlots",tolua_AllToLua_cItemGrid_GetNumSlots00);
tolua_function(tolua_S,"GetSlotNum",tolua_AllToLua_cItemGrid_GetSlotNum00);
- tolua_function(tolua_S,"GetItem",tolua_AllToLua_cItemGrid_GetItem00);
- tolua_function(tolua_S,"GetItem",tolua_AllToLua_cItemGrid_GetItem01);
- tolua_function(tolua_S,"GetItem",tolua_AllToLua_cItemGrid_GetItem02);
- tolua_function(tolua_S,"GetItem",tolua_AllToLua_cItemGrid_GetItem03);
- tolua_function(tolua_S,"SetItem",tolua_AllToLua_cItemGrid_SetItem00);
- tolua_function(tolua_S,"SetItem",tolua_AllToLua_cItemGrid_SetItem01);
- tolua_function(tolua_S,"SetItem",tolua_AllToLua_cItemGrid_SetItem02);
- tolua_function(tolua_S,"SetItem",tolua_AllToLua_cItemGrid_SetItem03);
+ tolua_function(tolua_S,"GetSlot",tolua_AllToLua_cItemGrid_GetSlot00);
+ tolua_function(tolua_S,"GetSlot",tolua_AllToLua_cItemGrid_GetSlot01);
+ tolua_function(tolua_S,"GetSlot",tolua_AllToLua_cItemGrid_GetSlot02);
+ tolua_function(tolua_S,"GetSlot",tolua_AllToLua_cItemGrid_GetSlot03);
+ tolua_function(tolua_S,"SetSlot",tolua_AllToLua_cItemGrid_SetSlot00);
+ tolua_function(tolua_S,"SetSlot",tolua_AllToLua_cItemGrid_SetSlot01);
+ tolua_function(tolua_S,"SetSlot",tolua_AllToLua_cItemGrid_SetSlot02);
+ tolua_function(tolua_S,"SetSlot",tolua_AllToLua_cItemGrid_SetSlot03);
tolua_function(tolua_S,"Clear",tolua_AllToLua_cItemGrid_Clear00);
tolua_function(tolua_S,"HowManyCanFit",tolua_AllToLua_cItemGrid_HowManyCanFit00);
tolua_function(tolua_S,"AddItem",tolua_AllToLua_cItemGrid_AddItem00);
diff --git a/source/Bindings.h b/source/Bindings.h
index b52c58a1a..352afe0d8 100644
--- a/source/Bindings.h
+++ b/source/Bindings.h
@@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
-** Generated automatically by tolua++-1.0.92 on 04/10/13 21:35:56.
+** Generated automatically by tolua++-1.0.92 on 04/10/13 23:01:47.
*/
/* Exported function */
diff --git a/source/ChestEntity.cpp b/source/ChestEntity.cpp
index aad8844c6..dbd7f6ef2 100644
--- a/source/ChestEntity.cpp
+++ b/source/ChestEntity.cpp
@@ -100,10 +100,10 @@ void cChestEntity::SaveToJson(Json::Value & a_Value)
a_Value["z"] = m_PosZ;
Json::Value AllSlots;
- for (int i = m_Contents.GetNumSlots(); i >= 0; i--)
+ for (int i = m_Contents.GetNumSlots() - 1; i >= 0; i--)
{
Json::Value Slot;
- m_Contents.GetItem(i).GetJson(Slot);
+ m_Contents.GetSlot(i).GetJson(Slot);
AllSlots.append(Slot);
}
a_Value["Slots"] = AllSlots;
diff --git a/source/ChestEntity.h b/source/ChestEntity.h
index be8172073..69e86b86c 100644
--- a/source/ChestEntity.h
+++ b/source/ChestEntity.h
@@ -41,8 +41,8 @@ public:
static const char * GetClassStatic() { return "cChestEntity"; }
// tolua_begin
- const cItem & GetSlot(int a_Slot) const { return m_Contents.GetItem(a_Slot); }
- void SetSlot(int a_Slot, const cItem & a_Item ) { m_Contents.SetItem(a_Slot, a_Item); }
+ const cItem & GetSlot(int a_Slot) const { return m_Contents.GetSlot(a_Slot); }
+ void SetSlot(int a_Slot, const cItem & a_Item ) { m_Contents.SetSlot(a_Slot, a_Item); }
// tolua_end
bool LoadFromJson( const Json::Value& a_Value );
diff --git a/source/ItemGrid.cpp b/source/ItemGrid.cpp
index f79bb5537..e9521d832 100644
--- a/source/ItemGrid.cpp
+++ b/source/ItemGrid.cpp
@@ -16,7 +16,7 @@ cItemGrid::cItemGrid(int a_Width, int a_Height) :
m_Width(a_Width),
m_Height(a_Height),
m_NumSlots(a_Width * a_Height),
- m_Items(new cItem[a_Width * a_Height])
+ m_Slots(new cItem[a_Width * a_Height])
{
}
@@ -26,7 +26,7 @@ cItemGrid::cItemGrid(int a_Width, int a_Height) :
cItemGrid::~cItemGrid()
{
- delete[] m_Items;
+ delete[] m_Slots;
}
@@ -71,75 +71,75 @@ void cItemGrid::GetSlotCoords(int a_SlotNum, int & a_X, int & a_Y) const
-const cItem & cItemGrid::GetItem(int a_X, int a_Y) const
+const cItem & cItemGrid::GetSlot(int a_X, int a_Y) const
{
- return GetItem(GetSlotNum(a_X, a_Y));
+ return GetSlot(GetSlotNum(a_X, a_Y));
}
-cItem & cItemGrid::GetItem(int a_X, int a_Y)
+cItem & cItemGrid::GetSlot(int a_X, int a_Y)
{
- return GetItem(GetSlotNum(a_X, a_Y));
+ return GetSlot(GetSlotNum(a_X, a_Y));
}
-const cItem & cItemGrid::GetItem(int a_SlotNum) const
+const cItem & cItemGrid::GetSlot(int a_SlotNum) const
{
if ((a_SlotNum < 0) || (a_SlotNum >= m_NumSlots))
{
LOGWARNING("%s: Invalid slot number, %d out of %d slots",
__FUNCTION__, a_SlotNum, m_NumSlots
);
- return m_Items[0];
+ return m_Slots[0];
}
- return m_Items[a_SlotNum];
+ return m_Slots[a_SlotNum];
}
-cItem & cItemGrid::GetItem(int a_SlotNum)
+cItem & cItemGrid::GetSlot(int a_SlotNum)
{
if ((a_SlotNum < 0) || (a_SlotNum >= m_NumSlots))
{
LOGWARNING("%s: Invalid slot number, %d out of %d slots",
__FUNCTION__, a_SlotNum, m_NumSlots
);
- return m_Items[0];
+ return m_Slots[0];
}
- return m_Items[a_SlotNum];
+ return m_Slots[a_SlotNum];
}
-void cItemGrid::SetItem(int a_X, int a_Y, const cItem & a_Item)
+void cItemGrid::SetSlot(int a_X, int a_Y, const cItem & a_Item)
{
- SetItem(GetSlotNum(a_X, a_Y), a_Item);
+ SetSlot(GetSlotNum(a_X, a_Y), a_Item);
}
-void cItemGrid::SetItem(int a_X, int a_Y, short a_ItemType, char a_ItemCount, short a_ItemDamage)
+void cItemGrid::SetSlot(int a_X, int a_Y, short a_ItemType, char a_ItemCount, short a_ItemDamage)
{
- SetItem(GetSlotNum(a_X, a_Y), cItem(a_ItemType, a_ItemCount, a_ItemDamage));
+ SetSlot(GetSlotNum(a_X, a_Y), cItem(a_ItemType, a_ItemCount, a_ItemDamage));
}
-void cItemGrid::SetItem(int a_SlotNum, const cItem & a_Item)
+void cItemGrid::SetSlot(int a_SlotNum, const cItem & a_Item)
{
if ((a_SlotNum < 0) || (a_SlotNum >= m_NumSlots))
{
@@ -148,16 +148,16 @@ void cItemGrid::SetItem(int a_SlotNum, const cItem & a_Item)
);
return;
}
- m_Items[a_SlotNum] = a_Item;
+ m_Slots[a_SlotNum] = a_Item;
}
-void cItemGrid::SetItem(int a_SlotNum, short a_ItemType, char a_ItemCount, short a_ItemDamage)
+void cItemGrid::SetSlot(int a_SlotNum, short a_ItemType, char a_ItemCount, short a_ItemDamage)
{
- SetItem(a_SlotNum, cItem(a_ItemType, a_ItemCount, a_ItemDamage));
+ SetSlot(a_SlotNum, cItem(a_ItemType, a_ItemCount, a_ItemDamage));
}
@@ -168,7 +168,7 @@ void cItemGrid::Clear(void)
{
for (int i = 0; i < m_NumSlots; i++)
{
- m_Items[i].Empty();
+ m_Slots[i].Empty();
}
}
@@ -182,20 +182,20 @@ int cItemGrid::HowManyCanFit(const cItem & a_ItemStack)
int MaxStack = ItemHandler(a_ItemStack.m_ItemType)->GetMaxStackSize();
for (int i = m_NumSlots - 1; i >= 0; i--)
{
- if (m_Items[i].IsEmpty())
+ if (m_Slots[i].IsEmpty())
{
NumLeft -= MaxStack;
}
- else if (m_Items[i].IsStackableWith(a_ItemStack))
+ else if (m_Slots[i].IsStackableWith(a_ItemStack))
{
- NumLeft -= MaxStack - m_Items[i].m_ItemCount;
+ NumLeft -= MaxStack - m_Slots[i].m_ItemCount;
}
if (NumLeft <= 0)
{
// All items fit
return a_ItemStack.m_ItemCount;
}
- } // for i - m_Items[]
+ } // for i - m_Slots[]
return a_ItemStack.m_ItemCount - NumLeft;
}
@@ -209,24 +209,24 @@ bool cItemGrid::AddItem(cItem & a_ItemStack)
int MaxStack = ItemHandler(a_ItemStack.m_ItemType)->GetMaxStackSize();
for (int i = m_NumSlots - 1; i >= 0; i--)
{
- if (m_Items[i].IsEmpty())
+ if (m_Slots[i].IsEmpty())
{
- m_Items[i] = a_ItemStack;
- m_Items[i].m_ItemCount = std::min(MaxStack, NumLeft);
- NumLeft -= m_Items[i].m_ItemCount;
+ m_Slots[i] = a_ItemStack;
+ m_Slots[i].m_ItemCount = std::min(MaxStack, NumLeft);
+ NumLeft -= m_Slots[i].m_ItemCount;
}
- else if (m_Items[i].IsStackableWith(a_ItemStack))
+ else if (m_Slots[i].IsStackableWith(a_ItemStack))
{
- int PrevCount = m_Items[i].m_ItemCount;
- m_Items[i].m_ItemCount = std::min(MaxStack, PrevCount + NumLeft);
- NumLeft -= m_Items[i].m_ItemCount - PrevCount;
+ int PrevCount = m_Slots[i].m_ItemCount;
+ m_Slots[i].m_ItemCount = std::min(MaxStack, PrevCount + NumLeft);
+ NumLeft -= m_Slots[i].m_ItemCount - PrevCount;
}
if (NumLeft <= 0)
{
// All items fit
return true;
}
- } // for i - m_Items[]
+ } // for i - m_Slots[]
return (a_ItemStack.m_ItemCount > NumLeft);
}
@@ -269,7 +269,7 @@ int cItemGrid::GetLastEmptySlot(void) const
{
for (int i = m_NumSlots - 1; i >= 0; i--)
{
- if (m_Items[i].IsEmpty())
+ if (m_Slots[i].IsEmpty())
{
return i;
}
@@ -285,7 +285,7 @@ int cItemGrid::GetNextEmptySlot(int a_StartFrom) const
{
for (int i = a_StartFrom + 1; i < m_NumSlots; i++)
{
- if (m_Items[i].IsEmpty())
+ if (m_Slots[i].IsEmpty())
{
return i;
}
@@ -301,11 +301,11 @@ void cItemGrid::CopyToItems(cItems & a_Items) const
{
for (int i = 0; i < m_NumSlots; i++)
{
- if (!m_Items[i].IsEmpty())
+ if (!m_Slots[i].IsEmpty())
{
- a_Items.push_back(m_Items[i]);
+ a_Items.push_back(m_Slots[i]);
}
- } // for i - m_Items[]
+ } // for i - m_Slots[]
}
@@ -340,7 +340,7 @@ void cItemGrid::GenerateRandomLootWithBooks(const cLootProbab * a_LootProbabs, i
break;
}
} // for j - a_LootProbabs[]
- SetItem(Rnd % m_NumSlots, CurrentLoot);
+ SetSlot(Rnd % m_NumSlots, CurrentLoot);
} // for i - NumSlots
}
diff --git a/source/ItemGrid.h b/source/ItemGrid.h
index 91eba6f33..ed4d5e58d 100644
--- a/source/ItemGrid.h
+++ b/source/ItemGrid.h
@@ -36,17 +36,17 @@ public:
void GetSlotCoords(int a_SlotNum, int & a_X, int & a_Y) const;
// tolua_begin
- // Retrieve items by coords or slot number; Logs warning and returns the first item on invalid coords / slotnum
- const cItem & GetItem(int a_X, int a_Y) const;
- cItem & GetItem(int a_X, int a_Y);
- const cItem & GetItem(int a_SlotNum) const;
- cItem & GetItem(int a_SlotNum);
+ // Retrieve slots by coords or slot number; Logs warning and returns the first slot on invalid coords / slotnum
+ const cItem & GetSlot(int a_X, int a_Y) const;
+ cItem & GetSlot(int a_X, int a_Y);
+ const cItem & GetSlot(int a_SlotNum) const;
+ cItem & GetSlot(int a_SlotNum);
- // Set item by coords or slot number; Logs warning and doesn't set on invalid coords / slotnum
- void SetItem(int a_X, int a_Y, const cItem & a_Item);
- void SetItem(int a_X, int a_Y, short a_ItemType, char a_ItemCount, short a_ItemDamage);
- void SetItem(int a_SlotNum, const cItem & a_Item);
- void SetItem(int a_SlotNum, short a_ItemType, char a_ItemCount, short a_ItemDamage);
+ // Set slot by coords or slot number; Logs warning and doesn't set on invalid coords / slotnum
+ void SetSlot(int a_X, int a_Y, const cItem & a_Item);
+ void SetSlot(int a_X, int a_Y, short a_ItemType, char a_ItemCount, short a_ItemDamage);
+ void SetSlot(int a_SlotNum, const cItem & a_Item);
+ void SetSlot(int a_SlotNum, short a_ItemType, char a_ItemCount, short a_ItemDamage);
/// Sets all items as empty
void Clear(void);
@@ -86,7 +86,7 @@ protected:
int m_Width;
int m_Height;
int m_NumSlots; // m_Width * m_Height, for easier validity checking in the access functions
- cItem * m_Items; // x + m_Width * y
+ cItem * m_Slots; // x + m_Width * y
} ;
// tolua_end
diff --git a/source/WorldStorage/NBTChunkSerializer.cpp b/source/WorldStorage/NBTChunkSerializer.cpp
index e033bfb9b..cf53e4434 100644
--- a/source/WorldStorage/NBTChunkSerializer.cpp
+++ b/source/WorldStorage/NBTChunkSerializer.cpp
@@ -79,7 +79,7 @@ void cNBTChunkSerializer::AddItemGrid(const cItemGrid & a_Grid, int a_BeginSlotN
int NumSlots = a_Grid.GetNumSlots();
for (int i = 0; i < NumSlots; i++)
{
- const cItem & Item = a_Grid.GetItem(i);
+ const cItem & Item = a_Grid.GetSlot(i);
if (Item.IsEmpty())
{
continue;