diff options
author | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2013-06-13 08:13:56 +0200 |
---|---|---|
committer | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2013-06-13 08:13:56 +0200 |
commit | 5c38a831bf0bda271a45f143700b3fea5e6ea7ee (patch) | |
tree | 462a6e2d32fb132940a27ae5d782530b29f0a9c5 | |
parent | ChestEntity: fixed bindings (diff) | |
download | cuberite-5c38a831bf0bda271a45f143700b3fea5e6ea7ee.tar cuberite-5c38a831bf0bda271a45f143700b3fea5e6ea7ee.tar.gz cuberite-5c38a831bf0bda271a45f143700b3fea5e6ea7ee.tar.bz2 cuberite-5c38a831bf0bda271a45f143700b3fea5e6ea7ee.tar.lz cuberite-5c38a831bf0bda271a45f143700b3fea5e6ea7ee.tar.xz cuberite-5c38a831bf0bda271a45f143700b3fea5e6ea7ee.tar.zst cuberite-5c38a831bf0bda271a45f143700b3fea5e6ea7ee.zip |
Diffstat (limited to '')
-rw-r--r-- | source/Bindings.cpp | 69 | ||||
-rw-r--r-- | source/Bindings.h | 2 | ||||
-rw-r--r-- | source/BlockEntities/ChestEntity.cpp | 13 | ||||
-rw-r--r-- | source/BlockEntities/ChestEntity.h | 8 | ||||
-rw-r--r-- | source/ItemGrid.cpp | 25 | ||||
-rw-r--r-- | source/ItemGrid.h | 6 |
6 files changed, 113 insertions, 10 deletions
diff --git a/source/Bindings.cpp b/source/Bindings.cpp index 02f8ce325..60d83b670 100644 --- a/source/Bindings.cpp +++ b/source/Bindings.cpp @@ -1,6 +1,6 @@ /* ** Lua binding: AllToLua -** Generated automatically by tolua++-1.0.92 on 06/12/13 14:28:57. +** Generated automatically by tolua++-1.0.92 on 06/13/13 08:12:33. */ #ifndef __cplusplus @@ -15487,6 +15487,71 @@ tolua_lerror: } #endif //#ifndef TOLUA_DISABLE +/* method: IsSlotEmpty of class cItemGrid */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_cItemGrid_IsSlotEmpty00 +static int tolua_AllToLua_cItemGrid_IsSlotEmpty00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const cItemGrid",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + 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 'IsSlotEmpty'", NULL); +#endif + { + bool tolua_ret = (bool) self->IsSlotEmpty(a_SlotNum); + tolua_pushboolean(tolua_S,(bool)tolua_ret); + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'IsSlotEmpty'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: IsSlotEmpty of class cItemGrid */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_cItemGrid_IsSlotEmpty01 +static int tolua_AllToLua_cItemGrid_IsSlotEmpty01(lua_State* tolua_S) +{ + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const cItemGrid",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 + { + const cItemGrid* self = (const cItemGrid*) tolua_tousertype(tolua_S,1,0); + 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 'IsSlotEmpty'", NULL); +#endif + { + bool tolua_ret = (bool) self->IsSlotEmpty(a_X,a_Y); + tolua_pushboolean(tolua_S,(bool)tolua_ret); + } + } + return 1; +tolua_lerror: + return tolua_AllToLua_cItemGrid_IsSlotEmpty00(tolua_S); +} +#endif //#ifndef TOLUA_DISABLE + /* method: Clear of class cItemGrid */ #ifndef TOLUA_DISABLE_tolua_AllToLua_cItemGrid_Clear00 static int tolua_AllToLua_cItemGrid_Clear00(lua_State* tolua_S) @@ -27698,6 +27763,8 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S) tolua_function(tolua_S,"SetSlot",tolua_AllToLua_cItemGrid_SetSlot03); tolua_function(tolua_S,"EmptySlot",tolua_AllToLua_cItemGrid_EmptySlot00); tolua_function(tolua_S,"EmptySlot",tolua_AllToLua_cItemGrid_EmptySlot01); + tolua_function(tolua_S,"IsSlotEmpty",tolua_AllToLua_cItemGrid_IsSlotEmpty00); + tolua_function(tolua_S,"IsSlotEmpty",tolua_AllToLua_cItemGrid_IsSlotEmpty01); 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 ec7581add..5d041895b 100644 --- a/source/Bindings.h +++ b/source/Bindings.h @@ -1,6 +1,6 @@ /* ** Lua binding: AllToLua -** Generated automatically by tolua++-1.0.92 on 06/12/13 14:28:57. +** Generated automatically by tolua++-1.0.92 on 06/13/13 08:12:34. */ /* Exported function */ diff --git a/source/BlockEntities/ChestEntity.cpp b/source/BlockEntities/ChestEntity.cpp index cd2b15e2b..3e75d5100 100644 --- a/source/BlockEntities/ChestEntity.cpp +++ b/source/BlockEntities/ChestEntity.cpp @@ -101,15 +101,20 @@ void cChestEntity::SendTo(cClientHandle & a_Client) void cChestEntity::UsedBy(cPlayer * a_Player) { - if (GetWindow() == NULL) + // If the window is not created, open it anew: + cWindow * Window = GetWindow(); + if (Window == NULL) { OpenNewWindow(); + Window = GetWindow(); } - if (GetWindow()) + + // Open the window for the player: + if (Window != NULL) { - if( a_Player->GetWindow() != GetWindow() ) + if (a_Player->GetWindow() != Window) { - a_Player->OpenWindow( GetWindow() ); + a_Player->OpenWindow(Window); } } diff --git a/source/BlockEntities/ChestEntity.h b/source/BlockEntities/ChestEntity.h index 86cb618d5..c6676894f 100644 --- a/source/BlockEntities/ChestEntity.h +++ b/source/BlockEntities/ChestEntity.h @@ -47,14 +47,14 @@ public: static const char * GetClassStatic(void) { return "cChestEntity"; } - bool LoadFromJson(const Json::Value& a_Value); + bool LoadFromJson(const Json::Value & a_Value); // cBlockEntity overrides: - virtual void SaveToJson(Json::Value & a_Value ) override; + virtual void SaveToJson(Json::Value & a_Value) override; virtual void SendTo(cClientHandle & a_Client) override; - virtual void UsedBy(cPlayer * a_Player); + virtual void UsedBy(cPlayer * a_Player) override; - /// Opens a new chest window for this chests. Scans for neighbors to open a double chest window, if appropriate. + /// Opens a new chest window for this chest. Scans for neighbors to open a double chest window, if appropriate. void OpenNewWindow(void); } ; // tolua_export diff --git a/source/ItemGrid.cpp b/source/ItemGrid.cpp index 5284f3ae1..c62ea6bcc 100644 --- a/source/ItemGrid.cpp +++ b/source/ItemGrid.cpp @@ -175,6 +175,31 @@ void cItemGrid::EmptySlot(int a_SlotNum) +bool cItemGrid::IsSlotEmpty(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 true;
+ }
+ return m_Slots[a_SlotNum].IsEmpty();
+}
+
+
+
+
+
+bool cItemGrid::IsSlotEmpty(int a_X, int a_Y) const
+{
+ return IsSlotEmpty(GetSlotNum(a_X, a_Y));
+}
+
+
+
+
+
void cItemGrid::Clear(void)
{
for (int i = 0; i < m_NumSlots; i++)
diff --git a/source/ItemGrid.h b/source/ItemGrid.h index 72b7d3b03..6b2713c45 100644 --- a/source/ItemGrid.h +++ b/source/ItemGrid.h @@ -62,6 +62,12 @@ public: void EmptySlot(int a_X, int a_Y);
void EmptySlot(int a_SlotNum);
+ /// Returns true if the specified slot is empty or the slot doesn't exist
+ bool IsSlotEmpty(int a_SlotNum) const;
+
+ /// Returns true if the specified slot is empty or the slot doesn't exist
+ bool IsSlotEmpty(int a_X, int a_Y) const;
+
/// Sets all items as empty
void Clear(void);
|