ItemGrid: Renamed all Item to Slot - better and consistent naming
git-svn-id: http://mc-server.googlecode.com/svn/trunk@1381 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
parent
cc26f16463
commit
929d299965
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
** Lua binding: AllToLua
|
** 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
|
#ifndef __cplusplus
|
||||||
@ -13710,9 +13710,9 @@ static int tolua_AllToLua_cItemGrid_GetSlotNum00(lua_State* tolua_S)
|
|||||||
}
|
}
|
||||||
#endif //#ifndef TOLUA_DISABLE
|
#endif //#ifndef TOLUA_DISABLE
|
||||||
|
|
||||||
/* method: GetItem of class cItemGrid */
|
/* method: GetSlot of class cItemGrid */
|
||||||
#ifndef TOLUA_DISABLE_tolua_AllToLua_cItemGrid_GetItem00
|
#ifndef TOLUA_DISABLE_tolua_AllToLua_cItemGrid_GetSlot00
|
||||||
static int tolua_AllToLua_cItemGrid_GetItem00(lua_State* tolua_S)
|
static int tolua_AllToLua_cItemGrid_GetSlot00(lua_State* tolua_S)
|
||||||
{
|
{
|
||||||
#ifndef TOLUA_RELEASE
|
#ifndef TOLUA_RELEASE
|
||||||
tolua_Error tolua_err;
|
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_X = ((int) tolua_tonumber(tolua_S,2,0));
|
||||||
int a_Y = ((int) tolua_tonumber(tolua_S,3,0));
|
int a_Y = ((int) tolua_tonumber(tolua_S,3,0));
|
||||||
#ifndef TOLUA_RELEASE
|
#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
|
#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");
|
tolua_pushusertype(tolua_S,(void*)&tolua_ret,"const cItem");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
#ifndef TOLUA_RELEASE
|
#ifndef TOLUA_RELEASE
|
||||||
tolua_lerror:
|
tolua_lerror:
|
||||||
tolua_error(tolua_S,"#ferror in function 'GetItem'.",&tolua_err);
|
tolua_error(tolua_S,"#ferror in function 'GetSlot'.",&tolua_err);
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif //#ifndef TOLUA_DISABLE
|
#endif //#ifndef TOLUA_DISABLE
|
||||||
|
|
||||||
/* method: GetItem of class cItemGrid */
|
/* method: GetSlot of class cItemGrid */
|
||||||
#ifndef TOLUA_DISABLE_tolua_AllToLua_cItemGrid_GetItem01
|
#ifndef TOLUA_DISABLE_tolua_AllToLua_cItemGrid_GetSlot01
|
||||||
static int tolua_AllToLua_cItemGrid_GetItem01(lua_State* tolua_S)
|
static int tolua_AllToLua_cItemGrid_GetSlot01(lua_State* tolua_S)
|
||||||
{
|
{
|
||||||
tolua_Error tolua_err;
|
tolua_Error tolua_err;
|
||||||
if (
|
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_X = ((int) tolua_tonumber(tolua_S,2,0));
|
||||||
int a_Y = ((int) tolua_tonumber(tolua_S,3,0));
|
int a_Y = ((int) tolua_tonumber(tolua_S,3,0));
|
||||||
#ifndef TOLUA_RELEASE
|
#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
|
#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");
|
tolua_pushusertype(tolua_S,(void*)&tolua_ret,"cItem");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
tolua_lerror:
|
tolua_lerror:
|
||||||
return tolua_AllToLua_cItemGrid_GetItem00(tolua_S);
|
return tolua_AllToLua_cItemGrid_GetSlot00(tolua_S);
|
||||||
}
|
}
|
||||||
#endif //#ifndef TOLUA_DISABLE
|
#endif //#ifndef TOLUA_DISABLE
|
||||||
|
|
||||||
/* method: GetItem of class cItemGrid */
|
/* method: GetSlot of class cItemGrid */
|
||||||
#ifndef TOLUA_DISABLE_tolua_AllToLua_cItemGrid_GetItem02
|
#ifndef TOLUA_DISABLE_tolua_AllToLua_cItemGrid_GetSlot02
|
||||||
static int tolua_AllToLua_cItemGrid_GetItem02(lua_State* tolua_S)
|
static int tolua_AllToLua_cItemGrid_GetSlot02(lua_State* tolua_S)
|
||||||
{
|
{
|
||||||
tolua_Error tolua_err;
|
tolua_Error tolua_err;
|
||||||
if (
|
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);
|
const cItemGrid* self = (const cItemGrid*) tolua_tousertype(tolua_S,1,0);
|
||||||
int a_SlotNum = ((int) tolua_tonumber(tolua_S,2,0));
|
int a_SlotNum = ((int) tolua_tonumber(tolua_S,2,0));
|
||||||
#ifndef TOLUA_RELEASE
|
#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
|
#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");
|
tolua_pushusertype(tolua_S,(void*)&tolua_ret,"const cItem");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
tolua_lerror:
|
tolua_lerror:
|
||||||
return tolua_AllToLua_cItemGrid_GetItem01(tolua_S);
|
return tolua_AllToLua_cItemGrid_GetSlot01(tolua_S);
|
||||||
}
|
}
|
||||||
#endif //#ifndef TOLUA_DISABLE
|
#endif //#ifndef TOLUA_DISABLE
|
||||||
|
|
||||||
/* method: GetItem of class cItemGrid */
|
/* method: GetSlot of class cItemGrid */
|
||||||
#ifndef TOLUA_DISABLE_tolua_AllToLua_cItemGrid_GetItem03
|
#ifndef TOLUA_DISABLE_tolua_AllToLua_cItemGrid_GetSlot03
|
||||||
static int tolua_AllToLua_cItemGrid_GetItem03(lua_State* tolua_S)
|
static int tolua_AllToLua_cItemGrid_GetSlot03(lua_State* tolua_S)
|
||||||
{
|
{
|
||||||
tolua_Error tolua_err;
|
tolua_Error tolua_err;
|
||||||
if (
|
if (
|
||||||
@ -13822,22 +13822,22 @@ static int tolua_AllToLua_cItemGrid_GetItem03(lua_State* tolua_S)
|
|||||||
cItemGrid* self = (cItemGrid*) tolua_tousertype(tolua_S,1,0);
|
cItemGrid* self = (cItemGrid*) tolua_tousertype(tolua_S,1,0);
|
||||||
int a_SlotNum = ((int) tolua_tonumber(tolua_S,2,0));
|
int a_SlotNum = ((int) tolua_tonumber(tolua_S,2,0));
|
||||||
#ifndef TOLUA_RELEASE
|
#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
|
#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");
|
tolua_pushusertype(tolua_S,(void*)&tolua_ret,"cItem");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
tolua_lerror:
|
tolua_lerror:
|
||||||
return tolua_AllToLua_cItemGrid_GetItem02(tolua_S);
|
return tolua_AllToLua_cItemGrid_GetSlot02(tolua_S);
|
||||||
}
|
}
|
||||||
#endif //#ifndef TOLUA_DISABLE
|
#endif //#ifndef TOLUA_DISABLE
|
||||||
|
|
||||||
/* method: SetItem of class cItemGrid */
|
/* method: SetSlot of class cItemGrid */
|
||||||
#ifndef TOLUA_DISABLE_tolua_AllToLua_cItemGrid_SetItem00
|
#ifndef TOLUA_DISABLE_tolua_AllToLua_cItemGrid_SetSlot00
|
||||||
static int tolua_AllToLua_cItemGrid_SetItem00(lua_State* tolua_S)
|
static int tolua_AllToLua_cItemGrid_SetSlot00(lua_State* tolua_S)
|
||||||
{
|
{
|
||||||
#ifndef TOLUA_RELEASE
|
#ifndef TOLUA_RELEASE
|
||||||
tolua_Error tolua_err;
|
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));
|
int a_Y = ((int) tolua_tonumber(tolua_S,3,0));
|
||||||
const cItem* a_Item = ((const cItem*) tolua_tousertype(tolua_S,4,0));
|
const cItem* a_Item = ((const cItem*) tolua_tousertype(tolua_S,4,0));
|
||||||
#ifndef TOLUA_RELEASE
|
#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
|
#endif
|
||||||
{
|
{
|
||||||
self->SetItem(a_X,a_Y,*a_Item);
|
self->SetSlot(a_X,a_Y,*a_Item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
#ifndef TOLUA_RELEASE
|
#ifndef TOLUA_RELEASE
|
||||||
tolua_lerror:
|
tolua_lerror:
|
||||||
tolua_error(tolua_S,"#ferror in function 'SetItem'.",&tolua_err);
|
tolua_error(tolua_S,"#ferror in function 'SetSlot'.",&tolua_err);
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif //#ifndef TOLUA_DISABLE
|
#endif //#ifndef TOLUA_DISABLE
|
||||||
|
|
||||||
/* method: SetItem of class cItemGrid */
|
/* method: SetSlot of class cItemGrid */
|
||||||
#ifndef TOLUA_DISABLE_tolua_AllToLua_cItemGrid_SetItem01
|
#ifndef TOLUA_DISABLE_tolua_AllToLua_cItemGrid_SetSlot01
|
||||||
static int tolua_AllToLua_cItemGrid_SetItem01(lua_State* tolua_S)
|
static int tolua_AllToLua_cItemGrid_SetSlot01(lua_State* tolua_S)
|
||||||
{
|
{
|
||||||
tolua_Error tolua_err;
|
tolua_Error tolua_err;
|
||||||
if (
|
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));
|
char a_ItemCount = ((char) tolua_tonumber(tolua_S,5,0));
|
||||||
short a_ItemDamage = ((short) tolua_tonumber(tolua_S,6,0));
|
short a_ItemDamage = ((short) tolua_tonumber(tolua_S,6,0));
|
||||||
#ifndef TOLUA_RELEASE
|
#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
|
#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;
|
return 0;
|
||||||
tolua_lerror:
|
tolua_lerror:
|
||||||
return tolua_AllToLua_cItemGrid_SetItem00(tolua_S);
|
return tolua_AllToLua_cItemGrid_SetSlot00(tolua_S);
|
||||||
}
|
}
|
||||||
#endif //#ifndef TOLUA_DISABLE
|
#endif //#ifndef TOLUA_DISABLE
|
||||||
|
|
||||||
/* method: SetItem of class cItemGrid */
|
/* method: SetSlot of class cItemGrid */
|
||||||
#ifndef TOLUA_DISABLE_tolua_AllToLua_cItemGrid_SetItem02
|
#ifndef TOLUA_DISABLE_tolua_AllToLua_cItemGrid_SetSlot02
|
||||||
static int tolua_AllToLua_cItemGrid_SetItem02(lua_State* tolua_S)
|
static int tolua_AllToLua_cItemGrid_SetSlot02(lua_State* tolua_S)
|
||||||
{
|
{
|
||||||
tolua_Error tolua_err;
|
tolua_Error tolua_err;
|
||||||
if (
|
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));
|
int a_SlotNum = ((int) tolua_tonumber(tolua_S,2,0));
|
||||||
const cItem* a_Item = ((const cItem*) tolua_tousertype(tolua_S,3,0));
|
const cItem* a_Item = ((const cItem*) tolua_tousertype(tolua_S,3,0));
|
||||||
#ifndef TOLUA_RELEASE
|
#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
|
#endif
|
||||||
{
|
{
|
||||||
self->SetItem(a_SlotNum,*a_Item);
|
self->SetSlot(a_SlotNum,*a_Item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
tolua_lerror:
|
tolua_lerror:
|
||||||
return tolua_AllToLua_cItemGrid_SetItem01(tolua_S);
|
return tolua_AllToLua_cItemGrid_SetSlot01(tolua_S);
|
||||||
}
|
}
|
||||||
#endif //#ifndef TOLUA_DISABLE
|
#endif //#ifndef TOLUA_DISABLE
|
||||||
|
|
||||||
/* method: SetItem of class cItemGrid */
|
/* method: SetSlot of class cItemGrid */
|
||||||
#ifndef TOLUA_DISABLE_tolua_AllToLua_cItemGrid_SetItem03
|
#ifndef TOLUA_DISABLE_tolua_AllToLua_cItemGrid_SetSlot03
|
||||||
static int tolua_AllToLua_cItemGrid_SetItem03(lua_State* tolua_S)
|
static int tolua_AllToLua_cItemGrid_SetSlot03(lua_State* tolua_S)
|
||||||
{
|
{
|
||||||
tolua_Error tolua_err;
|
tolua_Error tolua_err;
|
||||||
if (
|
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));
|
char a_ItemCount = ((char) tolua_tonumber(tolua_S,4,0));
|
||||||
short a_ItemDamage = ((short) tolua_tonumber(tolua_S,5,0));
|
short a_ItemDamage = ((short) tolua_tonumber(tolua_S,5,0));
|
||||||
#ifndef TOLUA_RELEASE
|
#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
|
#endif
|
||||||
{
|
{
|
||||||
self->SetItem(a_SlotNum,a_ItemType,a_ItemCount,a_ItemDamage);
|
self->SetSlot(a_SlotNum,a_ItemType,a_ItemCount,a_ItemDamage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
tolua_lerror:
|
tolua_lerror:
|
||||||
return tolua_AllToLua_cItemGrid_SetItem02(tolua_S);
|
return tolua_AllToLua_cItemGrid_SetSlot02(tolua_S);
|
||||||
}
|
}
|
||||||
#endif //#ifndef TOLUA_DISABLE
|
#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,"GetHeight",tolua_AllToLua_cItemGrid_GetHeight00);
|
||||||
tolua_function(tolua_S,"GetNumSlots",tolua_AllToLua_cItemGrid_GetNumSlots00);
|
tolua_function(tolua_S,"GetNumSlots",tolua_AllToLua_cItemGrid_GetNumSlots00);
|
||||||
tolua_function(tolua_S,"GetSlotNum",tolua_AllToLua_cItemGrid_GetSlotNum00);
|
tolua_function(tolua_S,"GetSlotNum",tolua_AllToLua_cItemGrid_GetSlotNum00);
|
||||||
tolua_function(tolua_S,"GetItem",tolua_AllToLua_cItemGrid_GetItem00);
|
tolua_function(tolua_S,"GetSlot",tolua_AllToLua_cItemGrid_GetSlot00);
|
||||||
tolua_function(tolua_S,"GetItem",tolua_AllToLua_cItemGrid_GetItem01);
|
tolua_function(tolua_S,"GetSlot",tolua_AllToLua_cItemGrid_GetSlot01);
|
||||||
tolua_function(tolua_S,"GetItem",tolua_AllToLua_cItemGrid_GetItem02);
|
tolua_function(tolua_S,"GetSlot",tolua_AllToLua_cItemGrid_GetSlot02);
|
||||||
tolua_function(tolua_S,"GetItem",tolua_AllToLua_cItemGrid_GetItem03);
|
tolua_function(tolua_S,"GetSlot",tolua_AllToLua_cItemGrid_GetSlot03);
|
||||||
tolua_function(tolua_S,"SetItem",tolua_AllToLua_cItemGrid_SetItem00);
|
tolua_function(tolua_S,"SetSlot",tolua_AllToLua_cItemGrid_SetSlot00);
|
||||||
tolua_function(tolua_S,"SetItem",tolua_AllToLua_cItemGrid_SetItem01);
|
tolua_function(tolua_S,"SetSlot",tolua_AllToLua_cItemGrid_SetSlot01);
|
||||||
tolua_function(tolua_S,"SetItem",tolua_AllToLua_cItemGrid_SetItem02);
|
tolua_function(tolua_S,"SetSlot",tolua_AllToLua_cItemGrid_SetSlot02);
|
||||||
tolua_function(tolua_S,"SetItem",tolua_AllToLua_cItemGrid_SetItem03);
|
tolua_function(tolua_S,"SetSlot",tolua_AllToLua_cItemGrid_SetSlot03);
|
||||||
tolua_function(tolua_S,"Clear",tolua_AllToLua_cItemGrid_Clear00);
|
tolua_function(tolua_S,"Clear",tolua_AllToLua_cItemGrid_Clear00);
|
||||||
tolua_function(tolua_S,"HowManyCanFit",tolua_AllToLua_cItemGrid_HowManyCanFit00);
|
tolua_function(tolua_S,"HowManyCanFit",tolua_AllToLua_cItemGrid_HowManyCanFit00);
|
||||||
tolua_function(tolua_S,"AddItem",tolua_AllToLua_cItemGrid_AddItem00);
|
tolua_function(tolua_S,"AddItem",tolua_AllToLua_cItemGrid_AddItem00);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
** Lua binding: AllToLua
|
** 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 */
|
/* Exported function */
|
||||||
|
@ -100,10 +100,10 @@ void cChestEntity::SaveToJson(Json::Value & a_Value)
|
|||||||
a_Value["z"] = m_PosZ;
|
a_Value["z"] = m_PosZ;
|
||||||
|
|
||||||
Json::Value AllSlots;
|
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;
|
Json::Value Slot;
|
||||||
m_Contents.GetItem(i).GetJson(Slot);
|
m_Contents.GetSlot(i).GetJson(Slot);
|
||||||
AllSlots.append(Slot);
|
AllSlots.append(Slot);
|
||||||
}
|
}
|
||||||
a_Value["Slots"] = AllSlots;
|
a_Value["Slots"] = AllSlots;
|
||||||
|
@ -41,8 +41,8 @@ public:
|
|||||||
static const char * GetClassStatic() { return "cChestEntity"; }
|
static const char * GetClassStatic() { return "cChestEntity"; }
|
||||||
|
|
||||||
// tolua_begin
|
// tolua_begin
|
||||||
const cItem & GetSlot(int a_Slot) const { return m_Contents.GetItem(a_Slot); }
|
const cItem & GetSlot(int a_Slot) const { return m_Contents.GetSlot(a_Slot); }
|
||||||
void SetSlot(int a_Slot, const cItem & a_Item ) { m_Contents.SetItem(a_Slot, a_Item); }
|
void SetSlot(int a_Slot, const cItem & a_Item ) { m_Contents.SetSlot(a_Slot, a_Item); }
|
||||||
// tolua_end
|
// tolua_end
|
||||||
|
|
||||||
bool LoadFromJson( const Json::Value& a_Value );
|
bool LoadFromJson( const Json::Value& a_Value );
|
||||||
|
@ -16,7 +16,7 @@ cItemGrid::cItemGrid(int a_Width, int a_Height) :
|
|||||||
m_Width(a_Width),
|
m_Width(a_Width),
|
||||||
m_Height(a_Height),
|
m_Height(a_Height),
|
||||||
m_NumSlots(a_Width * 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()
|
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))
|
if ((a_SlotNum < 0) || (a_SlotNum >= m_NumSlots))
|
||||||
{
|
{
|
||||||
LOGWARNING("%s: Invalid slot number, %d out of %d slots",
|
LOGWARNING("%s: Invalid slot number, %d out of %d slots",
|
||||||
__FUNCTION__, a_SlotNum, m_NumSlots
|
__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))
|
if ((a_SlotNum < 0) || (a_SlotNum >= m_NumSlots))
|
||||||
{
|
{
|
||||||
LOGWARNING("%s: Invalid slot number, %d out of %d slots",
|
LOGWARNING("%s: Invalid slot number, %d out of %d slots",
|
||||||
__FUNCTION__, a_SlotNum, m_NumSlots
|
__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))
|
if ((a_SlotNum < 0) || (a_SlotNum >= m_NumSlots))
|
||||||
{
|
{
|
||||||
@ -148,16 +148,16 @@ void cItemGrid::SetItem(int a_SlotNum, const cItem & a_Item)
|
|||||||
);
|
);
|
||||||
return;
|
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++)
|
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();
|
int MaxStack = ItemHandler(a_ItemStack.m_ItemType)->GetMaxStackSize();
|
||||||
for (int i = m_NumSlots - 1; i >= 0; i--)
|
for (int i = m_NumSlots - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
if (m_Items[i].IsEmpty())
|
if (m_Slots[i].IsEmpty())
|
||||||
{
|
{
|
||||||
NumLeft -= MaxStack;
|
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)
|
if (NumLeft <= 0)
|
||||||
{
|
{
|
||||||
// All items fit
|
// All items fit
|
||||||
return a_ItemStack.m_ItemCount;
|
return a_ItemStack.m_ItemCount;
|
||||||
}
|
}
|
||||||
} // for i - m_Items[]
|
} // for i - m_Slots[]
|
||||||
return a_ItemStack.m_ItemCount - NumLeft;
|
return a_ItemStack.m_ItemCount - NumLeft;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,24 +209,24 @@ bool cItemGrid::AddItem(cItem & a_ItemStack)
|
|||||||
int MaxStack = ItemHandler(a_ItemStack.m_ItemType)->GetMaxStackSize();
|
int MaxStack = ItemHandler(a_ItemStack.m_ItemType)->GetMaxStackSize();
|
||||||
for (int i = m_NumSlots - 1; i >= 0; i--)
|
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_Slots[i] = a_ItemStack;
|
||||||
m_Items[i].m_ItemCount = std::min(MaxStack, NumLeft);
|
m_Slots[i].m_ItemCount = std::min(MaxStack, NumLeft);
|
||||||
NumLeft -= m_Items[i].m_ItemCount;
|
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;
|
int PrevCount = m_Slots[i].m_ItemCount;
|
||||||
m_Items[i].m_ItemCount = std::min(MaxStack, PrevCount + NumLeft);
|
m_Slots[i].m_ItemCount = std::min(MaxStack, PrevCount + NumLeft);
|
||||||
NumLeft -= m_Items[i].m_ItemCount - PrevCount;
|
NumLeft -= m_Slots[i].m_ItemCount - PrevCount;
|
||||||
}
|
}
|
||||||
if (NumLeft <= 0)
|
if (NumLeft <= 0)
|
||||||
{
|
{
|
||||||
// All items fit
|
// All items fit
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} // for i - m_Items[]
|
} // for i - m_Slots[]
|
||||||
return (a_ItemStack.m_ItemCount > NumLeft);
|
return (a_ItemStack.m_ItemCount > NumLeft);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -269,7 +269,7 @@ int cItemGrid::GetLastEmptySlot(void) const
|
|||||||
{
|
{
|
||||||
for (int i = m_NumSlots - 1; i >= 0; i--)
|
for (int i = m_NumSlots - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
if (m_Items[i].IsEmpty())
|
if (m_Slots[i].IsEmpty())
|
||||||
{
|
{
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
@ -285,7 +285,7 @@ int cItemGrid::GetNextEmptySlot(int a_StartFrom) const
|
|||||||
{
|
{
|
||||||
for (int i = a_StartFrom + 1; i < m_NumSlots; i++)
|
for (int i = a_StartFrom + 1; i < m_NumSlots; i++)
|
||||||
{
|
{
|
||||||
if (m_Items[i].IsEmpty())
|
if (m_Slots[i].IsEmpty())
|
||||||
{
|
{
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
@ -301,11 +301,11 @@ void cItemGrid::CopyToItems(cItems & a_Items) const
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < m_NumSlots; i++)
|
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;
|
break;
|
||||||
}
|
}
|
||||||
} // for j - a_LootProbabs[]
|
} // for j - a_LootProbabs[]
|
||||||
SetItem(Rnd % m_NumSlots, CurrentLoot);
|
SetSlot(Rnd % m_NumSlots, CurrentLoot);
|
||||||
} // for i - NumSlots
|
} // for i - NumSlots
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,17 +36,17 @@ public:
|
|||||||
void GetSlotCoords(int a_SlotNum, int & a_X, int & a_Y) const;
|
void GetSlotCoords(int a_SlotNum, int & a_X, int & a_Y) const;
|
||||||
// tolua_begin
|
// tolua_begin
|
||||||
|
|
||||||
// Retrieve items by coords or slot number; Logs warning and returns the first item on invalid coords / slotnum
|
// Retrieve slots by coords or slot number; Logs warning and returns the first slot on invalid coords / slotnum
|
||||||
const cItem & GetItem(int a_X, int a_Y) const;
|
const cItem & GetSlot(int a_X, int a_Y) const;
|
||||||
cItem & GetItem(int a_X, int a_Y);
|
cItem & GetSlot(int a_X, int a_Y);
|
||||||
const cItem & GetItem(int a_SlotNum) const;
|
const cItem & GetSlot(int a_SlotNum) const;
|
||||||
cItem & GetItem(int a_SlotNum);
|
cItem & GetSlot(int a_SlotNum);
|
||||||
|
|
||||||
// Set item by coords or slot number; Logs warning and doesn't set on invalid coords / slotnum
|
// Set slot 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 SetSlot(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 SetSlot(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 SetSlot(int a_SlotNum, const cItem & a_Item);
|
||||||
void SetItem(int a_SlotNum, short a_ItemType, char a_ItemCount, short a_ItemDamage);
|
void SetSlot(int a_SlotNum, short a_ItemType, char a_ItemCount, short a_ItemDamage);
|
||||||
|
|
||||||
/// Sets all items as empty
|
/// Sets all items as empty
|
||||||
void Clear(void);
|
void Clear(void);
|
||||||
@ -86,7 +86,7 @@ protected:
|
|||||||
int m_Width;
|
int m_Width;
|
||||||
int m_Height;
|
int m_Height;
|
||||||
int m_NumSlots; // m_Width * m_Height, for easier validity checking in the access functions
|
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
|
// tolua_end
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ void cNBTChunkSerializer::AddItemGrid(const cItemGrid & a_Grid, int a_BeginSlotN
|
|||||||
int NumSlots = a_Grid.GetNumSlots();
|
int NumSlots = a_Grid.GetNumSlots();
|
||||||
for (int i = 0; i < NumSlots; i++)
|
for (int i = 0; i < NumSlots; i++)
|
||||||
{
|
{
|
||||||
const cItem & Item = a_Grid.GetItem(i);
|
const cItem & Item = a_Grid.GetSlot(i);
|
||||||
if (Item.IsEmpty())
|
if (Item.IsEmpty())
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
|
Loading…
Reference in New Issue
Block a user