summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-12-28 03:45:20 +0100
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-12-28 03:45:20 +0100
commit0cc3ab7c1ee21ea35ebe3ff17f641477dd34f9ec (patch)
tree4d421bba734bb56e7021b170f94f11a3daa54158 /source
parentFixed OnBlockPlace hook (diff)
downloadcuberite-0cc3ab7c1ee21ea35ebe3ff17f641477dd34f9ec.tar
cuberite-0cc3ab7c1ee21ea35ebe3ff17f641477dd34f9ec.tar.gz
cuberite-0cc3ab7c1ee21ea35ebe3ff17f641477dd34f9ec.tar.bz2
cuberite-0cc3ab7c1ee21ea35ebe3ff17f641477dd34f9ec.tar.lz
cuberite-0cc3ab7c1ee21ea35ebe3ff17f641477dd34f9ec.tar.xz
cuberite-0cc3ab7c1ee21ea35ebe3ff17f641477dd34f9ec.tar.zst
cuberite-0cc3ab7c1ee21ea35ebe3ff17f641477dd34f9ec.zip
Diffstat (limited to '')
-rw-r--r--source/Bindings.cpp106
-rw-r--r--source/Bindings.h2
-rw-r--r--source/Pickup.cpp21
-rw-r--r--source/Pickup.h12
-rw-r--r--source/Protocol/Protocol125.cpp6
-rw-r--r--source/Protocol/Protocol14x.cpp6
6 files changed, 45 insertions, 108 deletions
diff --git a/source/Bindings.cpp b/source/Bindings.cpp
index cff8943cf..ba1eeb3f4 100644
--- a/source/Bindings.cpp
+++ b/source/Bindings.cpp
@@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
-** Generated automatically by tolua++-1.0.92 on 12/22/12 19:15:15.
+** Generated automatically by tolua++-1.0.92 on 12/28/12 15:46:17.
*/
#ifndef __cplusplus
@@ -16168,15 +16168,15 @@ static int tolua_AllToLua_cPickup_new00(lua_State* tolua_S)
else
#endif
{
- int a_X = ((int) tolua_tonumber(tolua_S,2,0));
- int a_Y = ((int) tolua_tonumber(tolua_S,3,0));
- int a_Z = ((int) tolua_tonumber(tolua_S,4,0));
+ int a_MicroPosX = ((int) tolua_tonumber(tolua_S,2,0));
+ int a_MicroPosY = ((int) tolua_tonumber(tolua_S,3,0));
+ int a_MicroPosZ = ((int) tolua_tonumber(tolua_S,4,0));
const cItem* a_Item = ((const cItem*) tolua_tousertype(tolua_S,5,0));
float a_SpeedX = ((float) tolua_tonumber(tolua_S,6,0.f));
float a_SpeedY = ((float) tolua_tonumber(tolua_S,7,0.f));
float a_SpeedZ = ((float) tolua_tonumber(tolua_S,8,0.f));
{
- cPickup* tolua_ret = (cPickup*) Mtolua_new((cPickup)(a_X,a_Y,a_Z,*a_Item,a_SpeedX,a_SpeedY,a_SpeedZ));
+ cPickup* tolua_ret = (cPickup*) Mtolua_new((cPickup)(a_MicroPosX,a_MicroPosY,a_MicroPosZ,*a_Item,a_SpeedX,a_SpeedY,a_SpeedZ));
tolua_pushusertype(tolua_S,(void*)tolua_ret,"cPickup");
}
}
@@ -16210,15 +16210,15 @@ static int tolua_AllToLua_cPickup_new00_local(lua_State* tolua_S)
else
#endif
{
- int a_X = ((int) tolua_tonumber(tolua_S,2,0));
- int a_Y = ((int) tolua_tonumber(tolua_S,3,0));
- int a_Z = ((int) tolua_tonumber(tolua_S,4,0));
+ int a_MicroPosX = ((int) tolua_tonumber(tolua_S,2,0));
+ int a_MicroPosY = ((int) tolua_tonumber(tolua_S,3,0));
+ int a_MicroPosZ = ((int) tolua_tonumber(tolua_S,4,0));
const cItem* a_Item = ((const cItem*) tolua_tousertype(tolua_S,5,0));
float a_SpeedX = ((float) tolua_tonumber(tolua_S,6,0.f));
float a_SpeedY = ((float) tolua_tonumber(tolua_S,7,0.f));
float a_SpeedZ = ((float) tolua_tonumber(tolua_S,8,0.f));
{
- cPickup* tolua_ret = (cPickup*) Mtolua_new((cPickup)(a_X,a_Y,a_Z,*a_Item,a_SpeedX,a_SpeedY,a_SpeedZ));
+ cPickup* tolua_ret = (cPickup*) Mtolua_new((cPickup)(a_MicroPosX,a_MicroPosY,a_MicroPosZ,*a_Item,a_SpeedX,a_SpeedY,a_SpeedZ));
tolua_pushusertype(tolua_S,(void*)tolua_ret,"cPickup");
tolua_register_gc(tolua_S,lua_gettop(tolua_S));
}
@@ -16232,35 +16232,6 @@ static int tolua_AllToLua_cPickup_new00_local(lua_State* tolua_S)
}
#endif //#ifndef TOLUA_DISABLE
-/* method: delete of class cPickup */
-#ifndef TOLUA_DISABLE_tolua_AllToLua_cPickup_delete00
-static int tolua_AllToLua_cPickup_delete00(lua_State* tolua_S)
-{
-#ifndef TOLUA_RELEASE
- tolua_Error tolua_err;
- if (
- !tolua_isusertype(tolua_S,1,"cPickup",0,&tolua_err) ||
- !tolua_isnoobj(tolua_S,2,&tolua_err)
- )
- goto tolua_lerror;
- else
-#endif
- {
- cPickup* self = (cPickup*) tolua_tousertype(tolua_S,1,0);
-#ifndef TOLUA_RELEASE
- if (!self) tolua_error(tolua_S,"invalid 'self' in function 'delete'", NULL);
-#endif
- Mtolua_delete(self);
- }
- return 0;
-#ifndef TOLUA_RELEASE
- tolua_lerror:
- tolua_error(tolua_S,"#ferror in function 'delete'.",&tolua_err);
- return 0;
-#endif
-}
-#endif //#ifndef TOLUA_DISABLE
-
/* method: GetItem of class cPickup */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cPickup_GetItem00
static int tolua_AllToLua_cPickup_GetItem00(lua_State* tolua_S)
@@ -16280,8 +16251,8 @@ static int tolua_AllToLua_cPickup_GetItem00(lua_State* tolua_S)
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetItem'", NULL);
#endif
{
- cItem* tolua_ret = (cItem*) self->GetItem();
- tolua_pushusertype(tolua_S,(void*)tolua_ret,"cItem");
+ cItem& tolua_ret = (cItem&) self->GetItem();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"cItem");
}
}
return 1;
@@ -16429,7 +16400,7 @@ public:
void cPickup__SpawnOn( cClientHandle& a_Client) {
return ( void )cPickup::SpawnOn(a_Client);
};
- Lua__cPickup( int a_X, int a_Y, int a_Z, const cItem& a_Item, float a_SpeedX = 0.f, float a_SpeedY = 0.f, float a_SpeedZ = 0.f): cPickup(a_X,a_Y,a_Z,a_Item,a_SpeedX,a_SpeedY,a_SpeedZ){};
+ Lua__cPickup( int a_MicroPosX, int a_MicroPosY, int a_MicroPosZ, const cItem& a_Item, float a_SpeedX = 0.f, float a_SpeedY = 0.f, float a_SpeedZ = 0.f): cPickup(a_MicroPosX,a_MicroPosY,a_MicroPosZ,a_Item,a_SpeedX,a_SpeedY,a_SpeedZ){};
};
/* method: tolua__set_instance of class Lua__cPickup */
@@ -16520,15 +16491,15 @@ static int tolua_AllToLua_Lua__cPickup_new00(lua_State* tolua_S)
else
#endif
{
- int a_X = ((int) tolua_tonumber(tolua_S,2,0));
- int a_Y = ((int) tolua_tonumber(tolua_S,3,0));
- int a_Z = ((int) tolua_tonumber(tolua_S,4,0));
+ int a_MicroPosX = ((int) tolua_tonumber(tolua_S,2,0));
+ int a_MicroPosY = ((int) tolua_tonumber(tolua_S,3,0));
+ int a_MicroPosZ = ((int) tolua_tonumber(tolua_S,4,0));
const cItem* a_Item = ((const cItem*) tolua_tousertype(tolua_S,5,0));
float a_SpeedX = ((float) tolua_tonumber(tolua_S,6,0.f));
float a_SpeedY = ((float) tolua_tonumber(tolua_S,7,0.f));
float a_SpeedZ = ((float) tolua_tonumber(tolua_S,8,0.f));
{
- Lua__cPickup* tolua_ret = (Lua__cPickup*) Mtolua_new((Lua__cPickup)(a_X,a_Y,a_Z,*a_Item,a_SpeedX,a_SpeedY,a_SpeedZ));
+ Lua__cPickup* tolua_ret = (Lua__cPickup*) Mtolua_new((Lua__cPickup)(a_MicroPosX,a_MicroPosY,a_MicroPosZ,*a_Item,a_SpeedX,a_SpeedY,a_SpeedZ));
tolua_pushusertype(tolua_S,(void*)tolua_ret,"Lua__cPickup");
}
}
@@ -16562,15 +16533,15 @@ static int tolua_AllToLua_Lua__cPickup_new00_local(lua_State* tolua_S)
else
#endif
{
- int a_X = ((int) tolua_tonumber(tolua_S,2,0));
- int a_Y = ((int) tolua_tonumber(tolua_S,3,0));
- int a_Z = ((int) tolua_tonumber(tolua_S,4,0));
+ int a_MicroPosX = ((int) tolua_tonumber(tolua_S,2,0));
+ int a_MicroPosY = ((int) tolua_tonumber(tolua_S,3,0));
+ int a_MicroPosZ = ((int) tolua_tonumber(tolua_S,4,0));
const cItem* a_Item = ((const cItem*) tolua_tousertype(tolua_S,5,0));
float a_SpeedX = ((float) tolua_tonumber(tolua_S,6,0.f));
float a_SpeedY = ((float) tolua_tonumber(tolua_S,7,0.f));
float a_SpeedZ = ((float) tolua_tonumber(tolua_S,8,0.f));
{
- Lua__cPickup* tolua_ret = (Lua__cPickup*) Mtolua_new((Lua__cPickup)(a_X,a_Y,a_Z,*a_Item,a_SpeedX,a_SpeedY,a_SpeedZ));
+ Lua__cPickup* tolua_ret = (Lua__cPickup*) Mtolua_new((Lua__cPickup)(a_MicroPosX,a_MicroPosY,a_MicroPosZ,*a_Item,a_SpeedX,a_SpeedY,a_SpeedZ));
tolua_pushusertype(tolua_S,(void*)tolua_ret,"Lua__cPickup");
tolua_register_gc(tolua_S,lua_gettop(tolua_S));
}
@@ -16584,35 +16555,6 @@ static int tolua_AllToLua_Lua__cPickup_new00_local(lua_State* tolua_S)
}
#endif //#ifndef TOLUA_DISABLE
-/* method: delete of class Lua__cPickup */
-#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPickup_delete00
-static int tolua_AllToLua_Lua__cPickup_delete00(lua_State* tolua_S)
-{
-#ifndef TOLUA_RELEASE
- tolua_Error tolua_err;
- if (
- !tolua_isusertype(tolua_S,1,"Lua__cPickup",0,&tolua_err) ||
- !tolua_isnoobj(tolua_S,2,&tolua_err)
- )
- goto tolua_lerror;
- else
-#endif
- {
- Lua__cPickup* self = (Lua__cPickup*) tolua_tousertype(tolua_S,1,0);
-#ifndef TOLUA_RELEASE
- if (!self) tolua_error(tolua_S,"invalid 'self' in function 'delete'", NULL);
-#endif
- Mtolua_delete(self);
- }
- return 0;
-#ifndef TOLUA_RELEASE
- tolua_lerror:
- tolua_error(tolua_S,"#ferror in function 'delete'.",&tolua_err);
- return 0;
-#endif
-}
-#endif //#ifndef TOLUA_DISABLE
-
/* function to release collected object via destructor */
#ifdef __cplusplus
@@ -23969,6 +23911,10 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_constant(tolua_S,"E_ITEM_BOOK_AND_QUILL",E_ITEM_BOOK_AND_QUILL);
tolua_constant(tolua_S,"E_ITEM_WRITTEN_BOOK",E_ITEM_WRITTEN_BOOK);
tolua_constant(tolua_S,"E_ITEM_EMERALD",E_ITEM_EMERALD);
+ tolua_constant(tolua_S,"E_ITEM_FLOWER_POT",E_ITEM_FLOWER_POT);
+ tolua_constant(tolua_S,"E_ITEM_FIREWORK_ROCKET",E_ITEM_FIREWORK_ROCKET);
+ tolua_constant(tolua_S,"E_ITEM_FIREWORK_STAR",E_ITEM_FIREWORK_STAR);
+ tolua_constant(tolua_S,"E_ITEM_ENCHANTED_BOOK",E_ITEM_ENCHANTED_BOOK);
tolua_constant(tolua_S,"E_ITEM_13_DISC",E_ITEM_13_DISC);
tolua_constant(tolua_S,"E_ITEM_CAT_DISC",E_ITEM_CAT_DISC);
tolua_constant(tolua_S,"E_ITEM_BLOCKS_DISC",E_ITEM_BLOCKS_DISC);
@@ -24030,6 +23976,7 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_constant(tolua_S,"E_META_DOUBLE_STEP_COBBLESTONE",E_META_DOUBLE_STEP_COBBLESTONE);
tolua_constant(tolua_S,"E_META_DOUBLE_STEP_BRICK",E_META_DOUBLE_STEP_BRICK);
tolua_constant(tolua_S,"E_META_DOUBLE_STEP_STONE_BRICK",E_META_DOUBLE_STEP_STONE_BRICK);
+ tolua_constant(tolua_S,"E_META_DOUBLE_STEP_NETHER_BRICK",E_META_DOUBLE_STEP_NETHER_BRICK);
tolua_constant(tolua_S,"E_META_DOUBLE_STEP_STONE_SECRET",E_META_DOUBLE_STEP_STONE_SECRET);
tolua_constant(tolua_S,"E_META_STEP_STONE",E_META_STEP_STONE);
tolua_constant(tolua_S,"E_META_STEP_SANDSTONE",E_META_STEP_SANDSTONE);
@@ -24037,6 +23984,7 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_constant(tolua_S,"E_META_STEP_COBBLESTONE",E_META_STEP_COBBLESTONE);
tolua_constant(tolua_S,"E_META_STEP_BRICK",E_META_STEP_BRICK);
tolua_constant(tolua_S,"E_META_STEP_STONE_BRICK",E_META_STEP_STONE_BRICK);
+ tolua_constant(tolua_S,"E_META_STEP_NETHER_BRICK",E_META_STEP_NETHER_BRICK);
tolua_constant(tolua_S,"E_META_STEP_STONE_SECRET",E_META_STEP_STONE_SECRET);
tolua_constant(tolua_S,"E_META_SILVERFISH_EGG_STONE",E_META_SILVERFISH_EGG_STONE);
tolua_constant(tolua_S,"E_META_SILVERFISH_EGG_COBBLESTONE",E_META_SILVERFISH_EGG_COBBLESTONE);
@@ -24718,7 +24666,6 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_function(tolua_S,"new",tolua_AllToLua_cPickup_new00);
tolua_function(tolua_S,"new_local",tolua_AllToLua_cPickup_new00_local);
tolua_function(tolua_S,".call",tolua_AllToLua_cPickup_new00_local);
- tolua_function(tolua_S,"delete",tolua_AllToLua_cPickup_delete00);
tolua_function(tolua_S,"GetItem",tolua_AllToLua_cPickup_GetItem00);
tolua_function(tolua_S,"CollectedBy",tolua_AllToLua_cPickup_CollectedBy00);
tolua_endmodule(tolua_S);
@@ -24733,7 +24680,6 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_function(tolua_S,"new",tolua_AllToLua_Lua__cPickup_new00);
tolua_function(tolua_S,"new_local",tolua_AllToLua_Lua__cPickup_new00_local);
tolua_function(tolua_S,".call",tolua_AllToLua_Lua__cPickup_new00_local);
- tolua_function(tolua_S,"delete",tolua_AllToLua_Lua__cPickup_delete00);
tolua_endmodule(tolua_S);
tolua_cclass(tolua_S,"cRoot","cRoot","",NULL);
tolua_beginmodule(tolua_S,"cRoot");
diff --git a/source/Bindings.h b/source/Bindings.h
index e8bc37787..dcd96a4de 100644
--- a/source/Bindings.h
+++ b/source/Bindings.h
@@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
-** Generated automatically by tolua++-1.0.92 on 12/22/12 19:15:16.
+** Generated automatically by tolua++-1.0.92 on 12/28/12 15:46:18.
*/
/* Exported function */
diff --git a/source/Pickup.cpp b/source/Pickup.cpp
index f147434ab..b2290ab73 100644
--- a/source/Pickup.cpp
+++ b/source/Pickup.cpp
@@ -24,13 +24,13 @@
-cPickup::cPickup(int a_X, int a_Y, int a_Z, const cItem & a_Item, float a_SpeedX /* = 0.f */, float a_SpeedY /* = 0.f */, float a_SpeedZ /* = 0.f */)
- : cEntity(etPickup, ((double)(a_X))/32, ((double)(a_Y))/32, ((double)(a_Z))/32 )
+cPickup::cPickup(int a_MicroPosX, int a_MicroPosY, int a_MicroPosZ, const cItem & a_Item, float a_SpeedX /* = 0.f */, float a_SpeedY /* = 0.f */, float a_SpeedZ /* = 0.f */)
+ : cEntity(etPickup, ((double)(a_MicroPosX)) / 32, ((double)(a_MicroPosY)) / 32, ((double)(a_MicroPosZ)) / 32)
, m_Speed( a_SpeedX, a_SpeedY, a_SpeedZ )
, m_bOnGround( false )
, m_bReplicated( false )
, m_Timer( 0.f )
- , m_Item( new cItem( a_Item ) )
+ , m_Item(a_Item)
, m_bCollected( false )
{
}
@@ -39,15 +39,6 @@ cPickup::cPickup(int a_X, int a_Y, int a_Z, const cItem & a_Item, float a_SpeedX
-cPickup::~cPickup()
-{
- delete m_Item;
-}
-
-
-
-
-
void cPickup::Initialize(cWorld * a_World)
{
super::Initialize(a_World);
@@ -244,15 +235,15 @@ bool cPickup::CollectedBy(cPlayer * a_Dest)
return false;
}
- if (a_Dest->GetInventory().AddItemAnyAmount(*m_Item))
+ if (a_Dest->GetInventory().AddItemAnyAmount(m_Item))
{
m_World->BroadcastCollectPickup(*this, *a_Dest);
m_bCollected = true;
m_Timer = 0;
- if (m_Item->m_ItemCount != 0)
+ if (m_Item.m_ItemCount != 0)
{
cItems Pickup;
- Pickup.push_back(cItem(*m_Item));
+ Pickup.push_back(cItem(m_Item));
m_World->SpawnItemPickups(Pickup, m_Pos.x, m_Pos.y, m_Pos.z);
}
return true;
diff --git a/source/Pickup.h b/source/Pickup.h
index 6c5979e13..17dc379a7 100644
--- a/source/Pickup.h
+++ b/source/Pickup.h
@@ -2,12 +2,13 @@
#pragma once
#include "Entity.h"
+#include "Item.h"
+
class cPlayer;
-class cItem;
@@ -23,13 +24,12 @@ class cPickup :
public:
CLASS_PROTODEF(cPickup);
- cPickup(int a_X, int a_Y, int a_Z, const cItem & a_Item, float a_SpeedX = 0.f, float a_SpeedY = 0.f, float a_SpeedZ = 0.f); //tolua_export
- ~cPickup(); //tolua_export
+ cPickup(int a_MicroPosX, int a_MicroPosY, int a_MicroPosZ, const cItem & a_Item, float a_SpeedX = 0.f, float a_SpeedY = 0.f, float a_SpeedZ = 0.f); //tolua_export
virtual void Initialize(cWorld * a_World) override;
- cItem * GetItem(void) {return m_Item; } //tolua_export
- const cItem * GetItem(void) const {return m_Item; }
+ cItem & GetItem(void) {return m_Item; } //tolua_export
+ const cItem & GetItem(void) const {return m_Item; }
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
@@ -51,7 +51,7 @@ private:
float m_Timer;
- cItem* m_Item;
+ cItem m_Item;
bool m_bCollected;
}; //tolua_export
diff --git a/source/Protocol/Protocol125.cpp b/source/Protocol/Protocol125.cpp
index cb1e46193..0b5acc771 100644
--- a/source/Protocol/Protocol125.cpp
+++ b/source/Protocol/Protocol125.cpp
@@ -477,9 +477,9 @@ void cProtocol125::SendPickupSpawn(const cPickup & a_Pickup)
cCSLock Lock(m_CSPacket);
WriteByte (PACKET_PICKUP_SPAWN);
WriteInt (a_Pickup.GetUniqueID());
- WriteShort (a_Pickup.GetItem()->m_ItemType);
- WriteByte (a_Pickup.GetItem()->m_ItemCount);
- WriteShort (a_Pickup.GetItem()->m_ItemDamage);
+ WriteShort (a_Pickup.GetItem().m_ItemType);
+ WriteByte (a_Pickup.GetItem().m_ItemCount);
+ WriteShort (a_Pickup.GetItem().m_ItemDamage);
WriteVectorI((Vector3i)(a_Pickup.GetPosition() * 32));
WriteByte ((char)(a_Pickup.GetSpeed().x * 8));
WriteByte ((char)(a_Pickup.GetSpeed().y * 8));
diff --git a/source/Protocol/Protocol14x.cpp b/source/Protocol/Protocol14x.cpp
index 1cb4c922d..912a1a266 100644
--- a/source/Protocol/Protocol14x.cpp
+++ b/source/Protocol/Protocol14x.cpp
@@ -98,7 +98,7 @@ void cProtocol142::SendPickupSpawn(const cPickup & a_Pickup)
cCSLock Lock(m_CSPacket);
WriteByte (PACKET_PICKUP_SPAWN);
WriteInt (a_Pickup.GetUniqueID());
- WriteItem (*(a_Pickup.GetItem()));
+ WriteItem (a_Pickup.GetItem());
WriteVectorI((Vector3i)(a_Pickup.GetPosition() * 32));
WriteByte ((char)(a_Pickup.GetSpeed().x * 8));
WriteByte ((char)(a_Pickup.GetSpeed().y * 8));
@@ -155,7 +155,7 @@ cProtocol146::cProtocol146(cClientHandle * a_Client) :
void cProtocol146::SendPickupSpawn(const cPickup & a_Pickup)
{
- ASSERT(!a_Pickup.GetItem()->IsEmpty());
+ ASSERT(!a_Pickup.GetItem().IsEmpty());
cCSLock Lock(m_CSPacket);
@@ -177,7 +177,7 @@ void cProtocol146::SendPickupSpawn(const cPickup & a_Pickup)
WriteByte(PACKET_ENTITY_METADATA);
WriteInt(a_Pickup.GetUniqueID());
WriteByte(0xaa); // a slot value at index 10
- WriteItem(*a_Pickup.GetItem());
+ WriteItem(a_Pickup.GetItem());
WriteByte(0x7f); // End of metadata
Flush();
}