diff options
Diffstat (limited to '')
48 files changed, 1900 insertions, 2307 deletions
diff --git a/source/AllToLua.pkg b/source/AllToLua.pkg index e8268bfa6..91935c058 100644 --- a/source/AllToLua.pkg +++ b/source/AllToLua.pkg @@ -45,9 +45,6 @@ $cfile "cMCLogger.h" $cfile "cTracer.h" $cfile "cGroup.h" $cfile "BlockArea.h" -$cfile "packets/cPacket_Login.h" -$cfile "packets/cPacket_BlockDig.h" -$cfile "packets/cPacket_BlockPlace.h" $cfile "cLuaChunk.h" $cfile "CraftingRecipes.h" $cfile "LuaItems.h" diff --git a/source/Bindings.cpp b/source/Bindings.cpp index 682a7b9f2..2dee8bcc7 100644 --- a/source/Bindings.cpp +++ b/source/Bindings.cpp @@ -1,6 +1,6 @@ /* ** Lua binding: AllToLua -** Generated automatically by tolua++-1.0.92 on 08/11/12 21:48:17. +** Generated automatically by tolua++-1.0.92 on 08/18/12 11:57:21. */ #ifndef __cplusplus @@ -54,9 +54,6 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S); #include "cTracer.h" #include "cGroup.h" #include "BlockArea.h" -#include "packets/cPacket_Login.h" -#include "packets/cPacket_BlockDig.h" -#include "packets/cPacket_BlockPlace.h" #include "cLuaChunk.h" #include "CraftingRecipes.h" #include "LuaItems.h" @@ -71,13 +68,6 @@ static int tolua_collect_cMCLogger (lua_State* tolua_S) return 0; } -static int tolua_collect_cPacket_BlockDig (lua_State* tolua_S) -{ - cPacket_BlockDig* self = (cPacket_BlockDig*) tolua_tousertype(tolua_S,1,0); - Mtolua_delete(self); - return 0; -} - static int tolua_collect_cItem (lua_State* tolua_S) { cItem* self = (cItem*) tolua_tousertype(tolua_S,1,0); @@ -182,24 +172,19 @@ static int tolua_collect_Vector3d (lua_State* tolua_S) static void tolua_reg_types (lua_State* tolua_S) { tolua_usertype(tolua_S,"TakeDamageInfo"); - tolua_usertype(tolua_S,"cLuaItems"); tolua_usertype(tolua_S,"cCraftingRecipe"); tolua_usertype(tolua_S,"cPlugin"); - tolua_usertype(tolua_S,"cCraftingGrid"); tolua_usertype(tolua_S,"cStringMap"); - tolua_usertype(tolua_S,"cLuaChunk"); tolua_usertype(tolua_S,"cBlockArea"); - tolua_usertype(tolua_S,"cPluginManager"); - tolua_usertype(tolua_S,"Lua__cPacket_BlockDig"); tolua_usertype(tolua_S,"cServer"); tolua_usertype(tolua_S,"cRoot"); - tolua_usertype(tolua_S,"Lua__cTCPLink"); - tolua_usertype(tolua_S,"cPawn"); - tolua_usertype(tolua_S,"cGroup"); + tolua_usertype(tolua_S,"cLuaItems"); + tolua_usertype(tolua_S,"cCraftingGrid"); + tolua_usertype(tolua_S,"cLuaChunk"); tolua_usertype(tolua_S,"cPlugin::CommandStruct"); tolua_usertype(tolua_S,"cPickup"); tolua_usertype(tolua_S,"cItems"); - tolua_usertype(tolua_S,"cPacket_Login"); + tolua_usertype(tolua_S,"cGroup"); tolua_usertype(tolua_S,"cClientHandle"); tolua_usertype(tolua_S,"cTracer"); tolua_usertype(tolua_S,"cFurnaceRecipe"); @@ -215,8 +200,8 @@ static void tolua_reg_types (lua_State* tolua_S) tolua_usertype(tolua_S,"cPlugin_Lua"); tolua_usertype(tolua_S,"cWebPlugin_Lua"); tolua_usertype(tolua_S,"Lua__cPlugin_NewLua"); - tolua_usertype(tolua_S,"cPacket"); - tolua_usertype(tolua_S,"cPacket_BlockDig"); + tolua_usertype(tolua_S,"cPawn"); + tolua_usertype(tolua_S,"Lua__cTCPLink"); tolua_usertype(tolua_S,"cWebAdmin"); tolua_usertype(tolua_S,"cTCPLink"); tolua_usertype(tolua_S,"cCraftingRecipes"); @@ -224,7 +209,7 @@ static void tolua_reg_types (lua_State* tolua_S) tolua_usertype(tolua_S,"Lua__cPickup"); tolua_usertype(tolua_S,"Lua__cPlugin"); tolua_usertype(tolua_S,"Lua__cEntity"); - tolua_usertype(tolua_S,"cPacket_BlockPlace"); + tolua_usertype(tolua_S,"cPluginManager"); tolua_usertype(tolua_S,"cLadder"); tolua_usertype(tolua_S,"Lua__cPlayer"); tolua_usertype(tolua_S,"cWebPlugin"); @@ -5907,6 +5892,38 @@ static int tolua_AllToLua_cPlayer_GetFlying00(lua_State* tolua_S) } #endif //#ifndef TOLUA_DISABLE +/* method: IsOnGround of class cPlayer */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_IsOnGround00 +static int tolua_AllToLua_cPlayer_IsOnGround00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const cPlayer",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const cPlayer* self = (const cPlayer*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'IsOnGround'", NULL); +#endif + { + bool tolua_ret = (bool) self->IsOnGround(); + tolua_pushboolean(tolua_S,(bool)tolua_ret); + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'IsOnGround'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + /* method: GetStance of class cPlayer */ #ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_GetStance00 static int tolua_AllToLua_cPlayer_GetStance00(lua_State* tolua_S) @@ -7556,74 +7573,49 @@ static int tolua_AllToLua_cPlugin_Tick00(lua_State* tolua_S) } #endif //#ifndef TOLUA_DISABLE -/* method: OnCollectItem of class cPlugin */ -#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlugin_OnCollectItem00 -static int tolua_AllToLua_cPlugin_OnCollectItem00(lua_State* tolua_S) +/* method: OnBlockDig of class cPlugin */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlugin_OnBlockDig00 +static int tolua_AllToLua_cPlugin_OnBlockDig00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"cPlugin",0,&tolua_err) || - !tolua_isusertype(tolua_S,2,"cPickup",0,&tolua_err) || - !tolua_isusertype(tolua_S,3,"cPlayer",0,&tolua_err) || - !tolua_isnoobj(tolua_S,4,&tolua_err) + !tolua_isusertype(tolua_S,2,"cPlayer",0,&tolua_err) || + !tolua_isnumber(tolua_S,3,0,&tolua_err) || + !tolua_isnumber(tolua_S,4,0,&tolua_err) || + !tolua_isnumber(tolua_S,5,0,&tolua_err) || + !tolua_isnumber(tolua_S,6,0,&tolua_err) || + !tolua_isnumber(tolua_S,7,0,&tolua_err) || + !tolua_isnumber(tolua_S,8,0,&tolua_err) || + !tolua_isnumber(tolua_S,9,0,&tolua_err) || + !tolua_isnoobj(tolua_S,10,&tolua_err) ) goto tolua_lerror; else #endif { cPlugin* self = (cPlugin*) tolua_tousertype(tolua_S,1,0); - cPickup* a_Pickup = ((cPickup*) tolua_tousertype(tolua_S,2,0)); - cPlayer* a_Player = ((cPlayer*) tolua_tousertype(tolua_S,3,0)); + cPlayer* a_Player = ((cPlayer*) tolua_tousertype(tolua_S,2,0)); + int a_BlockX = ((int) tolua_tonumber(tolua_S,3,0)); + int a_BlockY = ((int) tolua_tonumber(tolua_S,4,0)); + int a_BlockZ = ((int) tolua_tonumber(tolua_S,5,0)); + char a_BlockFace = ((char) tolua_tonumber(tolua_S,6,0)); + char a_Status = ((char) tolua_tonumber(tolua_S,7,0)); + unsigned char a_OldBlock = (( unsigned char) tolua_tonumber(tolua_S,8,0)); + unsigned char a_OldMeta = (( unsigned char) tolua_tonumber(tolua_S,9,0)); #ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in function 'OnCollectItem'", NULL); + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'OnBlockDig'", NULL); #endif { - bool tolua_ret = (bool) self->OnCollectItem(a_Pickup,a_Player); + bool tolua_ret = (bool) self->OnBlockDig(a_Player,a_BlockX,a_BlockY,a_BlockZ,a_BlockFace,a_Status,a_OldBlock,a_OldMeta); tolua_pushboolean(tolua_S,(bool)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'OnCollectItem'.",&tolua_err); - return 0; -#endif -} -#endif //#ifndef TOLUA_DISABLE - -/* method: OnDisconnect of class cPlugin */ -#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlugin_OnDisconnect00 -static int tolua_AllToLua_cPlugin_OnDisconnect00(lua_State* tolua_S) -{ -#ifndef TOLUA_RELEASE - tolua_Error tolua_err; - if ( - !tolua_isusertype(tolua_S,1,"cPlugin",0,&tolua_err) || - !tolua_iscppstring(tolua_S,2,0,&tolua_err) || - !tolua_isusertype(tolua_S,3,"cPlayer",0,&tolua_err) || - !tolua_isnoobj(tolua_S,4,&tolua_err) - ) - goto tolua_lerror; - else -#endif - { - cPlugin* self = (cPlugin*) tolua_tousertype(tolua_S,1,0); - const AString a_Reason = ((const AString) tolua_tocppstring(tolua_S,2,0)); - cPlayer* a_Player = ((cPlayer*) tolua_tousertype(tolua_S,3,0)); -#ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in function 'OnDisconnect'", NULL); -#endif - { - bool tolua_ret = (bool) self->OnDisconnect(a_Reason,a_Player); - tolua_pushboolean(tolua_S,(bool)tolua_ret); - tolua_pushcppstring(tolua_S,(const char*)a_Reason); - } - } - return 2; -#ifndef TOLUA_RELEASE - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'OnDisconnect'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'OnBlockDig'.",&tolua_err); return 0; #endif } @@ -7637,22 +7629,30 @@ static int tolua_AllToLua_cPlugin_OnBlockPlace00(lua_State* tolua_S) tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"cPlugin",0,&tolua_err) || - !tolua_isusertype(tolua_S,2,"cPacket_BlockPlace",0,&tolua_err) || - !tolua_isusertype(tolua_S,3,"cPlayer",0,&tolua_err) || - !tolua_isnoobj(tolua_S,4,&tolua_err) + !tolua_isusertype(tolua_S,2,"cPlayer",0,&tolua_err) || + !tolua_isnumber(tolua_S,3,0,&tolua_err) || + !tolua_isnumber(tolua_S,4,0,&tolua_err) || + !tolua_isnumber(tolua_S,5,0,&tolua_err) || + !tolua_isnumber(tolua_S,6,0,&tolua_err) || + (tolua_isvaluenil(tolua_S,7,&tolua_err) || !tolua_isusertype(tolua_S,7,"const cItem",0,&tolua_err)) || + !tolua_isnoobj(tolua_S,8,&tolua_err) ) goto tolua_lerror; else #endif { cPlugin* self = (cPlugin*) tolua_tousertype(tolua_S,1,0); - cPacket_BlockPlace* a_PacketData = ((cPacket_BlockPlace*) tolua_tousertype(tolua_S,2,0)); - cPlayer* a_Player = ((cPlayer*) tolua_tousertype(tolua_S,3,0)); + cPlayer* a_Player = ((cPlayer*) tolua_tousertype(tolua_S,2,0)); + int a_BlockX = ((int) tolua_tonumber(tolua_S,3,0)); + int a_BlockY = ((int) tolua_tonumber(tolua_S,4,0)); + int a_BlockZ = ((int) tolua_tonumber(tolua_S,5,0)); + char a_BlockFace = ((char) tolua_tonumber(tolua_S,6,0)); + const cItem* a_HeldItem = ((const cItem*) tolua_tousertype(tolua_S,7,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'OnBlockPlace'", NULL); #endif { - bool tolua_ret = (bool) self->OnBlockPlace(a_PacketData,a_Player); + bool tolua_ret = (bool) self->OnBlockPlace(a_Player,a_BlockX,a_BlockY,a_BlockZ,a_BlockFace,*a_HeldItem); tolua_pushboolean(tolua_S,(bool)tolua_ret); } } @@ -7665,39 +7665,43 @@ static int tolua_AllToLua_cPlugin_OnBlockPlace00(lua_State* tolua_S) } #endif //#ifndef TOLUA_DISABLE -/* method: OnBlockDig of class cPlugin */ -#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlugin_OnBlockDig00 -static int tolua_AllToLua_cPlugin_OnBlockDig00(lua_State* tolua_S) +/* method: OnBlockToPickup of class cPlugin */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlugin_OnBlockToPickup00 +static int tolua_AllToLua_cPlugin_OnBlockToPickup00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"cPlugin",0,&tolua_err) || - !tolua_isusertype(tolua_S,2,"cPacket_BlockDig",0,&tolua_err) || - !tolua_isusertype(tolua_S,3,"cPlayer",0,&tolua_err) || - !tolua_isusertype(tolua_S,4,"cItem",0,&tolua_err) || - !tolua_isnoobj(tolua_S,5,&tolua_err) + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnumber(tolua_S,3,0,&tolua_err) || + !tolua_isusertype(tolua_S,4,"const cPlayer",0,&tolua_err) || + (tolua_isvaluenil(tolua_S,5,&tolua_err) || !tolua_isusertype(tolua_S,5,"const cItem",0,&tolua_err)) || + (tolua_isvaluenil(tolua_S,6,&tolua_err) || !tolua_isusertype(tolua_S,6,"cItems",0,&tolua_err)) || + !tolua_isnoobj(tolua_S,7,&tolua_err) ) goto tolua_lerror; else #endif { cPlugin* self = (cPlugin*) tolua_tousertype(tolua_S,1,0); - cPacket_BlockDig* a_PacketData = ((cPacket_BlockDig*) tolua_tousertype(tolua_S,2,0)); - cPlayer* a_Player = ((cPlayer*) tolua_tousertype(tolua_S,3,0)); - cItem* a_PickupItem = ((cItem*) tolua_tousertype(tolua_S,4,0)); + unsigned char a_BlockType = (( unsigned char) tolua_tonumber(tolua_S,2,0)); + unsigned char a_BlockMeta = (( unsigned char) tolua_tonumber(tolua_S,3,0)); + const cPlayer* a_Player = ((const cPlayer*) tolua_tousertype(tolua_S,4,0)); + const cItem* a_EquippedItem = ((const cItem*) tolua_tousertype(tolua_S,5,0)); + cItems* a_Pickups = ((cItems*) tolua_tousertype(tolua_S,6,0)); #ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in function 'OnBlockDig'", NULL); + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'OnBlockToPickup'", NULL); #endif { - bool tolua_ret = (bool) self->OnBlockDig(a_PacketData,a_Player,a_PickupItem); + bool tolua_ret = (bool) self->OnBlockToPickup(a_BlockType,a_BlockMeta,a_Player,*a_EquippedItem,*a_Pickups); tolua_pushboolean(tolua_S,(bool)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'OnBlockDig'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'OnBlockToPickup'.",&tolua_err); return 0; #endif } @@ -7739,150 +7743,167 @@ static int tolua_AllToLua_cPlugin_OnChat00(lua_State* tolua_S) } #endif //#ifndef TOLUA_DISABLE -/* method: OnLogin of class cPlugin */ -#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlugin_OnLogin00 -static int tolua_AllToLua_cPlugin_OnLogin00(lua_State* tolua_S) +/* method: OnChunkGenerated of class cPlugin */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlugin_OnChunkGenerated00 +static int tolua_AllToLua_cPlugin_OnChunkGenerated00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"cPlugin",0,&tolua_err) || - !tolua_isusertype(tolua_S,2,"cPacket_Login",0,&tolua_err) || - !tolua_isnoobj(tolua_S,3,&tolua_err) + !tolua_isusertype(tolua_S,2,"cWorld",0,&tolua_err) || + !tolua_isnumber(tolua_S,3,0,&tolua_err) || + !tolua_isnumber(tolua_S,4,0,&tolua_err) || + !tolua_isnoobj(tolua_S,5,&tolua_err) ) goto tolua_lerror; else #endif { cPlugin* self = (cPlugin*) tolua_tousertype(tolua_S,1,0); - cPacket_Login* a_PacketData = ((cPacket_Login*) tolua_tousertype(tolua_S,2,0)); + cWorld* a_World = ((cWorld*) tolua_tousertype(tolua_S,2,0)); + int a_ChunkX = ((int) tolua_tonumber(tolua_S,3,0)); + int a_ChunkZ = ((int) tolua_tonumber(tolua_S,4,0)); #ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in function 'OnLogin'", NULL); + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'OnChunkGenerated'", NULL); #endif { - bool tolua_ret = (bool) self->OnLogin(a_PacketData); - tolua_pushboolean(tolua_S,(bool)tolua_ret); + self->OnChunkGenerated(a_World,a_ChunkX,a_ChunkZ); } } - return 1; + return 0; #ifndef TOLUA_RELEASE tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'OnLogin'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'OnChunkGenerated'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE -/* method: OnPlayerSpawn of class cPlugin */ -#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlugin_OnPlayerSpawn00 -static int tolua_AllToLua_cPlugin_OnPlayerSpawn00(lua_State* tolua_S) +/* method: OnChunkGenerating of class cPlugin */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlugin_OnChunkGenerating00 +static int tolua_AllToLua_cPlugin_OnChunkGenerating00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"cPlugin",0,&tolua_err) || - !tolua_isusertype(tolua_S,2,"cPlayer",0,&tolua_err) || - !tolua_isnoobj(tolua_S,3,&tolua_err) + !tolua_isusertype(tolua_S,2,"cWorld",0,&tolua_err) || + !tolua_isnumber(tolua_S,3,0,&tolua_err) || + !tolua_isnumber(tolua_S,4,0,&tolua_err) || + !tolua_isusertype(tolua_S,5,"cLuaChunk",0,&tolua_err) || + !tolua_isnoobj(tolua_S,6,&tolua_err) ) goto tolua_lerror; else #endif { cPlugin* self = (cPlugin*) tolua_tousertype(tolua_S,1,0); - cPlayer* a_Player = ((cPlayer*) tolua_tousertype(tolua_S,2,0)); + cWorld* a_World = ((cWorld*) tolua_tousertype(tolua_S,2,0)); + int a_ChunkX = ((int) tolua_tonumber(tolua_S,3,0)); + int a_ChunkZ = ((int) tolua_tonumber(tolua_S,4,0)); + cLuaChunk* a_pLuaChunk = ((cLuaChunk*) tolua_tousertype(tolua_S,5,0)); #ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in function 'OnPlayerSpawn'", NULL); + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'OnChunkGenerating'", NULL); #endif { - self->OnPlayerSpawn(a_Player); + bool tolua_ret = (bool) self->OnChunkGenerating(a_World,a_ChunkX,a_ChunkZ,a_pLuaChunk); + tolua_pushboolean(tolua_S,(bool)tolua_ret); } } - return 0; + return 1; #ifndef TOLUA_RELEASE tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'OnPlayerSpawn'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'OnChunkGenerating'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE -/* method: OnPlayerJoin of class cPlugin */ -#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlugin_OnPlayerJoin00 -static int tolua_AllToLua_cPlugin_OnPlayerJoin00(lua_State* tolua_S) +/* method: OnCollectItem of class cPlugin */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlugin_OnCollectItem00 +static int tolua_AllToLua_cPlugin_OnCollectItem00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"cPlugin",0,&tolua_err) || - !tolua_isusertype(tolua_S,2,"cPlayer",0,&tolua_err) || - !tolua_isnoobj(tolua_S,3,&tolua_err) + !tolua_isusertype(tolua_S,2,"cPickup",0,&tolua_err) || + !tolua_isusertype(tolua_S,3,"cPlayer",0,&tolua_err) || + !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else #endif { cPlugin* self = (cPlugin*) tolua_tousertype(tolua_S,1,0); - cPlayer* a_Player = ((cPlayer*) tolua_tousertype(tolua_S,2,0)); + cPickup* a_Pickup = ((cPickup*) tolua_tousertype(tolua_S,2,0)); + cPlayer* a_Player = ((cPlayer*) tolua_tousertype(tolua_S,3,0)); #ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in function 'OnPlayerJoin'", NULL); + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'OnCollectItem'", NULL); #endif { - bool tolua_ret = (bool) self->OnPlayerJoin(a_Player); + bool tolua_ret = (bool) self->OnCollectItem(a_Pickup,a_Player); tolua_pushboolean(tolua_S,(bool)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'OnPlayerJoin'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'OnCollectItem'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE -/* method: OnPlayerMove of class cPlugin */ -#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlugin_OnPlayerMove00 -static int tolua_AllToLua_cPlugin_OnPlayerMove00(lua_State* tolua_S) +/* method: OnCraftingNoRecipe of class cPlugin */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlugin_OnCraftingNoRecipe00 +static int tolua_AllToLua_cPlugin_OnCraftingNoRecipe00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"cPlugin",0,&tolua_err) || - !tolua_isusertype(tolua_S,2,"cPlayer",0,&tolua_err) || - !tolua_isnoobj(tolua_S,3,&tolua_err) + !tolua_isusertype(tolua_S,2,"const cPlayer",0,&tolua_err) || + !tolua_isusertype(tolua_S,3,"const cCraftingGrid",0,&tolua_err) || + !tolua_isusertype(tolua_S,4,"cCraftingRecipe",0,&tolua_err) || + !tolua_isnoobj(tolua_S,5,&tolua_err) ) goto tolua_lerror; else #endif { cPlugin* self = (cPlugin*) tolua_tousertype(tolua_S,1,0); - cPlayer* a_Player = ((cPlayer*) tolua_tousertype(tolua_S,2,0)); + const cPlayer* a_Player = ((const cPlayer*) tolua_tousertype(tolua_S,2,0)); + const cCraftingGrid* a_Grid = ((const cCraftingGrid*) tolua_tousertype(tolua_S,3,0)); + cCraftingRecipe* a_Recipe = ((cCraftingRecipe*) tolua_tousertype(tolua_S,4,0)); #ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in function 'OnPlayerMove'", NULL); + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'OnCraftingNoRecipe'", NULL); #endif { - self->OnPlayerMove(a_Player); + bool tolua_ret = (bool) self->OnCraftingNoRecipe(a_Player,a_Grid,a_Recipe); + tolua_pushboolean(tolua_S,(bool)tolua_ret); } } - return 0; + return 1; #ifndef TOLUA_RELEASE tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'OnPlayerMove'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'OnCraftingNoRecipe'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE -/* method: OnTakeDamage of class cPlugin */ -#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlugin_OnTakeDamage00 -static int tolua_AllToLua_cPlugin_OnTakeDamage00(lua_State* tolua_S) +/* method: OnDisconnect of class cPlugin */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlugin_OnDisconnect00 +static int tolua_AllToLua_cPlugin_OnDisconnect00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"cPlugin",0,&tolua_err) || - !tolua_isusertype(tolua_S,2,"cPawn",0,&tolua_err) || - !tolua_isusertype(tolua_S,3,"TakeDamageInfo",0,&tolua_err) || + !tolua_iscppstring(tolua_S,2,0,&tolua_err) || + !tolua_isusertype(tolua_S,3,"cPlayer",0,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; @@ -7890,19 +7911,21 @@ static int tolua_AllToLua_cPlugin_OnTakeDamage00(lua_State* tolua_S) #endif { cPlugin* self = (cPlugin*) tolua_tousertype(tolua_S,1,0); - cPawn* a_Pawn = ((cPawn*) tolua_tousertype(tolua_S,2,0)); - TakeDamageInfo* a_TakeDamageInfo = ((TakeDamageInfo*) tolua_tousertype(tolua_S,3,0)); + const AString a_Reason = ((const AString) tolua_tocppstring(tolua_S,2,0)); + cPlayer* a_Player = ((cPlayer*) tolua_tousertype(tolua_S,3,0)); #ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in function 'OnTakeDamage'", NULL); + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'OnDisconnect'", NULL); #endif { - self->OnTakeDamage(a_Pawn,a_TakeDamageInfo); + bool tolua_ret = (bool) self->OnDisconnect(a_Reason,a_Player); + tolua_pushboolean(tolua_S,(bool)tolua_ret); + tolua_pushcppstring(tolua_S,(const char*)a_Reason); } } - return 0; + return 2; #ifndef TOLUA_RELEASE tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'OnTakeDamage'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'OnDisconnect'.",&tolua_err); return 0; #endif } @@ -7944,17 +7967,17 @@ static int tolua_AllToLua_cPlugin_OnKilled00(lua_State* tolua_S) } #endif //#ifndef TOLUA_DISABLE -/* method: OnChunkGenerated of class cPlugin */ -#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlugin_OnChunkGenerated00 -static int tolua_AllToLua_cPlugin_OnChunkGenerated00(lua_State* tolua_S) +/* method: OnLogin of class cPlugin */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlugin_OnLogin00 +static int tolua_AllToLua_cPlugin_OnLogin00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"cPlugin",0,&tolua_err) || - !tolua_isusertype(tolua_S,2,"cWorld",0,&tolua_err) || + !tolua_isusertype(tolua_S,2,"cClientHandle",0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || - !tolua_isnumber(tolua_S,4,0,&tolua_err) || + !tolua_iscppstring(tolua_S,4,0,&tolua_err) || !tolua_isnoobj(tolua_S,5,&tolua_err) ) goto tolua_lerror; @@ -7962,136 +7985,122 @@ static int tolua_AllToLua_cPlugin_OnChunkGenerated00(lua_State* tolua_S) #endif { cPlugin* self = (cPlugin*) tolua_tousertype(tolua_S,1,0); - cWorld* a_World = ((cWorld*) tolua_tousertype(tolua_S,2,0)); - int a_ChunkX = ((int) tolua_tonumber(tolua_S,3,0)); - int a_ChunkZ = ((int) tolua_tonumber(tolua_S,4,0)); + cClientHandle* a_Client = ((cClientHandle*) tolua_tousertype(tolua_S,2,0)); + int a_ProtocolVersion = ((int) tolua_tonumber(tolua_S,3,0)); + const AString a_Username = ((const AString) tolua_tocppstring(tolua_S,4,0)); #ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in function 'OnChunkGenerated'", NULL); + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'OnLogin'", NULL); #endif { - self->OnChunkGenerated(a_World,a_ChunkX,a_ChunkZ); + bool tolua_ret = (bool) self->OnLogin(a_Client,a_ProtocolVersion,a_Username); + tolua_pushboolean(tolua_S,(bool)tolua_ret); + tolua_pushcppstring(tolua_S,(const char*)a_Username); } } - return 0; + return 2; #ifndef TOLUA_RELEASE tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'OnChunkGenerated'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'OnLogin'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE -/* method: OnChunkGenerating of class cPlugin */ -#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlugin_OnChunkGenerating00 -static int tolua_AllToLua_cPlugin_OnChunkGenerating00(lua_State* tolua_S) +/* method: OnPlayerJoin of class cPlugin */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlugin_OnPlayerJoin00 +static int tolua_AllToLua_cPlugin_OnPlayerJoin00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"cPlugin",0,&tolua_err) || - !tolua_isusertype(tolua_S,2,"cWorld",0,&tolua_err) || - !tolua_isnumber(tolua_S,3,0,&tolua_err) || - !tolua_isnumber(tolua_S,4,0,&tolua_err) || - !tolua_isusertype(tolua_S,5,"cLuaChunk",0,&tolua_err) || - !tolua_isnoobj(tolua_S,6,&tolua_err) + !tolua_isusertype(tolua_S,2,"cPlayer",0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { cPlugin* self = (cPlugin*) tolua_tousertype(tolua_S,1,0); - cWorld* a_World = ((cWorld*) tolua_tousertype(tolua_S,2,0)); - int a_ChunkX = ((int) tolua_tonumber(tolua_S,3,0)); - int a_ChunkZ = ((int) tolua_tonumber(tolua_S,4,0)); - cLuaChunk* a_pLuaChunk = ((cLuaChunk*) tolua_tousertype(tolua_S,5,0)); + cPlayer* a_Player = ((cPlayer*) tolua_tousertype(tolua_S,2,0)); #ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in function 'OnChunkGenerating'", NULL); + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'OnPlayerJoin'", NULL); #endif { - bool tolua_ret = (bool) self->OnChunkGenerating(a_World,a_ChunkX,a_ChunkZ,a_pLuaChunk); + bool tolua_ret = (bool) self->OnPlayerJoin(a_Player); tolua_pushboolean(tolua_S,(bool)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'OnChunkGenerating'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'OnPlayerJoin'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE -/* method: OnPreCrafting of class cPlugin */ -#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlugin_OnPreCrafting00 -static int tolua_AllToLua_cPlugin_OnPreCrafting00(lua_State* tolua_S) +/* method: OnPlayerMove of class cPlugin */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlugin_OnPlayerMove00 +static int tolua_AllToLua_cPlugin_OnPlayerMove00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"cPlugin",0,&tolua_err) || - !tolua_isusertype(tolua_S,2,"const cPlayer",0,&tolua_err) || - !tolua_isusertype(tolua_S,3,"const cCraftingGrid",0,&tolua_err) || - !tolua_isusertype(tolua_S,4,"cCraftingRecipe",0,&tolua_err) || - !tolua_isnoobj(tolua_S,5,&tolua_err) + !tolua_isusertype(tolua_S,2,"cPlayer",0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { cPlugin* self = (cPlugin*) tolua_tousertype(tolua_S,1,0); - const cPlayer* a_Player = ((const cPlayer*) tolua_tousertype(tolua_S,2,0)); - const cCraftingGrid* a_Grid = ((const cCraftingGrid*) tolua_tousertype(tolua_S,3,0)); - cCraftingRecipe* a_Recipe = ((cCraftingRecipe*) tolua_tousertype(tolua_S,4,0)); + cPlayer* a_Player = ((cPlayer*) tolua_tousertype(tolua_S,2,0)); #ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in function 'OnPreCrafting'", NULL); + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'OnPlayerMove'", NULL); #endif { - bool tolua_ret = (bool) self->OnPreCrafting(a_Player,a_Grid,a_Recipe); - tolua_pushboolean(tolua_S,(bool)tolua_ret); + self->OnPlayerMove(a_Player); } } - return 1; + return 0; #ifndef TOLUA_RELEASE tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'OnPreCrafting'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'OnPlayerMove'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE -/* method: OnCraftingNoRecipe of class cPlugin */ -#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlugin_OnCraftingNoRecipe00 -static int tolua_AllToLua_cPlugin_OnCraftingNoRecipe00(lua_State* tolua_S) +/* method: OnPlayerSpawn of class cPlugin */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlugin_OnPlayerSpawn00 +static int tolua_AllToLua_cPlugin_OnPlayerSpawn00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"cPlugin",0,&tolua_err) || - !tolua_isusertype(tolua_S,2,"const cPlayer",0,&tolua_err) || - !tolua_isusertype(tolua_S,3,"const cCraftingGrid",0,&tolua_err) || - !tolua_isusertype(tolua_S,4,"cCraftingRecipe",0,&tolua_err) || - !tolua_isnoobj(tolua_S,5,&tolua_err) + !tolua_isusertype(tolua_S,2,"cPlayer",0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { cPlugin* self = (cPlugin*) tolua_tousertype(tolua_S,1,0); - const cPlayer* a_Player = ((const cPlayer*) tolua_tousertype(tolua_S,2,0)); - const cCraftingGrid* a_Grid = ((const cCraftingGrid*) tolua_tousertype(tolua_S,3,0)); - cCraftingRecipe* a_Recipe = ((cCraftingRecipe*) tolua_tousertype(tolua_S,4,0)); + cPlayer* a_Player = ((cPlayer*) tolua_tousertype(tolua_S,2,0)); #ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in function 'OnCraftingNoRecipe'", NULL); + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'OnPlayerSpawn'", NULL); #endif { - bool tolua_ret = (bool) self->OnCraftingNoRecipe(a_Player,a_Grid,a_Recipe); - tolua_pushboolean(tolua_S,(bool)tolua_ret); + self->OnPlayerSpawn(a_Player); } } - return 1; + return 0; #ifndef TOLUA_RELEASE tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'OnCraftingNoRecipe'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'OnPlayerSpawn'.",&tolua_err); return 0; #endif } @@ -8135,85 +8144,82 @@ static int tolua_AllToLua_cPlugin_OnPostCrafting00(lua_State* tolua_S) } #endif //#ifndef TOLUA_DISABLE -/* method: OnBlockToPickup of class cPlugin */ -#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlugin_OnBlockToPickup00 -static int tolua_AllToLua_cPlugin_OnBlockToPickup00(lua_State* tolua_S) +/* method: OnPreCrafting of class cPlugin */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlugin_OnPreCrafting00 +static int tolua_AllToLua_cPlugin_OnPreCrafting00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"cPlugin",0,&tolua_err) || - !tolua_isnumber(tolua_S,2,0,&tolua_err) || - !tolua_isnumber(tolua_S,3,0,&tolua_err) || - !tolua_isusertype(tolua_S,4,"const cPlayer",0,&tolua_err) || - (tolua_isvaluenil(tolua_S,5,&tolua_err) || !tolua_isusertype(tolua_S,5,"const cItem",0,&tolua_err)) || - (tolua_isvaluenil(tolua_S,6,&tolua_err) || !tolua_isusertype(tolua_S,6,"cItems",0,&tolua_err)) || - !tolua_isnoobj(tolua_S,7,&tolua_err) + !tolua_isusertype(tolua_S,2,"const cPlayer",0,&tolua_err) || + !tolua_isusertype(tolua_S,3,"const cCraftingGrid",0,&tolua_err) || + !tolua_isusertype(tolua_S,4,"cCraftingRecipe",0,&tolua_err) || + !tolua_isnoobj(tolua_S,5,&tolua_err) ) goto tolua_lerror; else #endif { cPlugin* self = (cPlugin*) tolua_tousertype(tolua_S,1,0); - unsigned char a_BlockType = (( unsigned char) tolua_tonumber(tolua_S,2,0)); - unsigned char a_BlockMeta = (( unsigned char) tolua_tonumber(tolua_S,3,0)); - const cPlayer* a_Player = ((const cPlayer*) tolua_tousertype(tolua_S,4,0)); - const cItem* a_EquippedItem = ((const cItem*) tolua_tousertype(tolua_S,5,0)); - cItems* a_Pickups = ((cItems*) tolua_tousertype(tolua_S,6,0)); + const cPlayer* a_Player = ((const cPlayer*) tolua_tousertype(tolua_S,2,0)); + const cCraftingGrid* a_Grid = ((const cCraftingGrid*) tolua_tousertype(tolua_S,3,0)); + cCraftingRecipe* a_Recipe = ((cCraftingRecipe*) tolua_tousertype(tolua_S,4,0)); #ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in function 'OnBlockToPickup'", NULL); + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'OnPreCrafting'", NULL); #endif { - bool tolua_ret = (bool) self->OnBlockToPickup(a_BlockType,a_BlockMeta,a_Player,*a_EquippedItem,*a_Pickups); + bool tolua_ret = (bool) self->OnPreCrafting(a_Player,a_Grid,a_Recipe); tolua_pushboolean(tolua_S,(bool)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'OnBlockToPickup'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'OnPreCrafting'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE -/* method: OnWeatherChanged of class cPlugin */ -#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlugin_OnWeatherChanged00 -static int tolua_AllToLua_cPlugin_OnWeatherChanged00(lua_State* tolua_S) +/* method: OnTakeDamage of class cPlugin */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlugin_OnTakeDamage00 +static int tolua_AllToLua_cPlugin_OnTakeDamage00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"cPlugin",0,&tolua_err) || - !tolua_isusertype(tolua_S,2,"cWorld",0,&tolua_err) || - !tolua_isnoobj(tolua_S,3,&tolua_err) + !tolua_isusertype(tolua_S,2,"cPawn",0,&tolua_err) || + !tolua_isusertype(tolua_S,3,"TakeDamageInfo",0,&tolua_err) || + !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else #endif { cPlugin* self = (cPlugin*) tolua_tousertype(tolua_S,1,0); - cWorld* a_World = ((cWorld*) tolua_tousertype(tolua_S,2,0)); + cPawn* a_Pawn = ((cPawn*) tolua_tousertype(tolua_S,2,0)); + TakeDamageInfo* a_TakeDamageInfo = ((TakeDamageInfo*) tolua_tousertype(tolua_S,3,0)); #ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in function 'OnWeatherChanged'", NULL); + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'OnTakeDamage'", NULL); #endif { - bool tolua_ret = (bool) self->OnWeatherChanged(a_World); - tolua_pushboolean(tolua_S,(bool)tolua_ret); + self->OnTakeDamage(a_Pawn,a_TakeDamageInfo); } } - return 1; + return 0; #ifndef TOLUA_RELEASE tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'OnWeatherChanged'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'OnTakeDamage'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE -/* method: OnUpdatingSign of class cPlugin */ -#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlugin_OnUpdatingSign00 -static int tolua_AllToLua_cPlugin_OnUpdatingSign00(lua_State* tolua_S) +/* method: OnUpdatedSign of class cPlugin */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlugin_OnUpdatedSign00 +static int tolua_AllToLua_cPlugin_OnUpdatedSign00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; @@ -8238,15 +8244,15 @@ static int tolua_AllToLua_cPlugin_OnUpdatingSign00(lua_State* tolua_S) int a_BlockX = ((int) tolua_tonumber(tolua_S,3,0)); int a_BlockY = ((int) tolua_tonumber(tolua_S,4,0)); int a_BlockZ = ((int) tolua_tonumber(tolua_S,5,0)); - AString a_Line1 = ((AString) tolua_tocppstring(tolua_S,6,0)); - AString a_Line2 = ((AString) tolua_tocppstring(tolua_S,7,0)); - AString a_Line3 = ((AString) tolua_tocppstring(tolua_S,8,0)); - AString a_Line4 = ((AString) tolua_tocppstring(tolua_S,9,0)); + const AString a_Line1 = ((const AString) tolua_tocppstring(tolua_S,6,0)); + const AString a_Line2 = ((const AString) tolua_tocppstring(tolua_S,7,0)); + const AString a_Line3 = ((const AString) tolua_tocppstring(tolua_S,8,0)); + const AString a_Line4 = ((const AString) tolua_tocppstring(tolua_S,9,0)); #ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in function 'OnUpdatingSign'", NULL); + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'OnUpdatedSign'", NULL); #endif { - bool tolua_ret = (bool) self->OnUpdatingSign(a_World,a_BlockX,a_BlockY,a_BlockZ,a_Line1,a_Line2,a_Line3,a_Line4); + bool tolua_ret = (bool) self->OnUpdatedSign(a_World,a_BlockX,a_BlockY,a_BlockZ,a_Line1,a_Line2,a_Line3,a_Line4); tolua_pushboolean(tolua_S,(bool)tolua_ret); tolua_pushcppstring(tolua_S,(const char*)a_Line1); tolua_pushcppstring(tolua_S,(const char*)a_Line2); @@ -8257,15 +8263,15 @@ static int tolua_AllToLua_cPlugin_OnUpdatingSign00(lua_State* tolua_S) return 5; #ifndef TOLUA_RELEASE tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'OnUpdatingSign'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'OnUpdatedSign'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE -/* method: OnUpdatedSign of class cPlugin */ -#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlugin_OnUpdatedSign00 -static int tolua_AllToLua_cPlugin_OnUpdatedSign00(lua_State* tolua_S) +/* method: OnUpdatingSign of class cPlugin */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlugin_OnUpdatingSign00 +static int tolua_AllToLua_cPlugin_OnUpdatingSign00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; @@ -8290,15 +8296,15 @@ static int tolua_AllToLua_cPlugin_OnUpdatedSign00(lua_State* tolua_S) int a_BlockX = ((int) tolua_tonumber(tolua_S,3,0)); int a_BlockY = ((int) tolua_tonumber(tolua_S,4,0)); int a_BlockZ = ((int) tolua_tonumber(tolua_S,5,0)); - const AString a_Line1 = ((const AString) tolua_tocppstring(tolua_S,6,0)); - const AString a_Line2 = ((const AString) tolua_tocppstring(tolua_S,7,0)); - const AString a_Line3 = ((const AString) tolua_tocppstring(tolua_S,8,0)); - const AString a_Line4 = ((const AString) tolua_tocppstring(tolua_S,9,0)); + AString a_Line1 = ((AString) tolua_tocppstring(tolua_S,6,0)); + AString a_Line2 = ((AString) tolua_tocppstring(tolua_S,7,0)); + AString a_Line3 = ((AString) tolua_tocppstring(tolua_S,8,0)); + AString a_Line4 = ((AString) tolua_tocppstring(tolua_S,9,0)); #ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in function 'OnUpdatedSign'", NULL); + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'OnUpdatingSign'", NULL); #endif { - bool tolua_ret = (bool) self->OnUpdatedSign(a_World,a_BlockX,a_BlockY,a_BlockZ,a_Line1,a_Line2,a_Line3,a_Line4); + bool tolua_ret = (bool) self->OnUpdatingSign(a_World,a_BlockX,a_BlockY,a_BlockZ,a_Line1,a_Line2,a_Line3,a_Line4); tolua_pushboolean(tolua_S,(bool)tolua_ret); tolua_pushcppstring(tolua_S,(const char*)a_Line1); tolua_pushcppstring(tolua_S,(const char*)a_Line2); @@ -8309,7 +8315,41 @@ static int tolua_AllToLua_cPlugin_OnUpdatedSign00(lua_State* tolua_S) return 5; #ifndef TOLUA_RELEASE tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'OnUpdatedSign'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'OnUpdatingSign'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: OnWeatherChanged of class cPlugin */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlugin_OnWeatherChanged00 +static int tolua_AllToLua_cPlugin_OnWeatherChanged00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"cPlugin",0,&tolua_err) || + !tolua_isusertype(tolua_S,2,"cWorld",0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + cPlugin* self = (cPlugin*) tolua_tousertype(tolua_S,1,0); + cWorld* a_World = ((cWorld*) tolua_tousertype(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'OnWeatherChanged'", NULL); +#endif + { + bool tolua_ret = (bool) self->OnWeatherChanged(a_World); + tolua_pushboolean(tolua_S,(bool)tolua_ret); + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'OnWeatherChanged'.",&tolua_err); return 0; #endif } @@ -8608,53 +8648,53 @@ public: return ( void ) cPlugin:: Tick(a_Dt); }; }; - bool OnCollectItem( cPickup* a_Pickup, cPlayer* a_Player) { - if (push_method("OnCollectItem", tolua_AllToLua_cPlugin_OnCollectItem00)) { - tolua_pushusertype(lua_state, (void*)a_Pickup, "cPickup"); - tolua_pushusertype(lua_state, (void*)a_Player, "cPlayer"); - ToluaBase::dbcall(lua_state, 3, 1); - bool tolua_ret = ( bool )tolua_toboolean(lua_state, -1, 0); - lua_pop(lua_state, 1); - return tolua_ret; - } else { - return ( bool ) cPlugin:: OnCollectItem(a_Pickup,a_Player); - }; - }; - bool OnDisconnect( const AString& a_Reason, cPlayer* a_Player) { - if (push_method("OnDisconnect", tolua_AllToLua_cPlugin_OnDisconnect00)) { - tolua_pushcppstring(lua_state, (const char*)a_Reason); + bool OnBlockDig( cPlayer* a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status, unsigned char a_OldBlock, unsigned char a_OldMeta) { + if (push_method("OnBlockDig", tolua_AllToLua_cPlugin_OnBlockDig00)) { tolua_pushusertype(lua_state, (void*)a_Player, "cPlayer"); - ToluaBase::dbcall(lua_state, 3, 1); + tolua_pushnumber(lua_state, (lua_Number)a_BlockX); + tolua_pushnumber(lua_state, (lua_Number)a_BlockY); + tolua_pushnumber(lua_state, (lua_Number)a_BlockZ); + tolua_pushnumber(lua_state, (lua_Number)a_BlockFace); + tolua_pushnumber(lua_state, (lua_Number)a_Status); + tolua_pushnumber(lua_state, (lua_Number)a_OldBlock); + tolua_pushnumber(lua_state, (lua_Number)a_OldMeta); + ToluaBase::dbcall(lua_state, 9, 1); bool tolua_ret = ( bool )tolua_toboolean(lua_state, -1, 0); lua_pop(lua_state, 1); return tolua_ret; } else { - return ( bool ) cPlugin:: OnDisconnect(a_Reason,a_Player); + return ( bool ) cPlugin:: OnBlockDig(a_Player,a_BlockX,a_BlockY,a_BlockZ,a_BlockFace,a_Status,a_OldBlock,a_OldMeta); }; }; - bool OnBlockPlace( cPacket_BlockPlace* a_PacketData, cPlayer* a_Player) { + bool OnBlockPlace( cPlayer* a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, const cItem& a_HeldItem) { if (push_method("OnBlockPlace", tolua_AllToLua_cPlugin_OnBlockPlace00)) { - tolua_pushusertype(lua_state, (void*)a_PacketData, "cPacket_BlockPlace"); tolua_pushusertype(lua_state, (void*)a_Player, "cPlayer"); - ToluaBase::dbcall(lua_state, 3, 1); + tolua_pushnumber(lua_state, (lua_Number)a_BlockX); + tolua_pushnumber(lua_state, (lua_Number)a_BlockY); + tolua_pushnumber(lua_state, (lua_Number)a_BlockZ); + tolua_pushnumber(lua_state, (lua_Number)a_BlockFace); + tolua_pushusertype(lua_state, (void*)&a_HeldItem, "const cItem"); + ToluaBase::dbcall(lua_state, 7, 1); bool tolua_ret = ( bool )tolua_toboolean(lua_state, -1, 0); lua_pop(lua_state, 1); return tolua_ret; } else { - return ( bool ) cPlugin:: OnBlockPlace(a_PacketData,a_Player); + return ( bool ) cPlugin:: OnBlockPlace(a_Player,a_BlockX,a_BlockY,a_BlockZ,a_BlockFace,a_HeldItem); }; }; - bool OnBlockDig( cPacket_BlockDig* a_PacketData, cPlayer* a_Player, cItem* a_PickupItem) { - if (push_method("OnBlockDig", tolua_AllToLua_cPlugin_OnBlockDig00)) { - tolua_pushusertype(lua_state, (void*)a_PacketData, "cPacket_BlockDig"); - tolua_pushusertype(lua_state, (void*)a_Player, "cPlayer"); - tolua_pushusertype(lua_state, (void*)a_PickupItem, "cItem"); - ToluaBase::dbcall(lua_state, 4, 1); + bool OnBlockToPickup( unsigned char a_BlockType, unsigned char a_BlockMeta, const cPlayer* a_Player, const cItem& a_EquippedItem, cItems& a_Pickups) { + if (push_method("OnBlockToPickup", tolua_AllToLua_cPlugin_OnBlockToPickup00)) { + tolua_pushnumber(lua_state, (lua_Number)a_BlockType); + tolua_pushnumber(lua_state, (lua_Number)a_BlockMeta); + tolua_pushusertype(lua_state, (void*)a_Player, "const cPlayer"); + tolua_pushusertype(lua_state, (void*)&a_EquippedItem, "const cItem"); + tolua_pushusertype(lua_state, (void*)&a_Pickups, "cItems"); + ToluaBase::dbcall(lua_state, 6, 1); bool tolua_ret = ( bool )tolua_toboolean(lua_state, -1, 0); lua_pop(lua_state, 1); return tolua_ret; } else { - return ( bool ) cPlugin:: OnBlockDig(a_PacketData,a_Player,a_PickupItem); + return ( bool ) cPlugin:: OnBlockToPickup(a_BlockType,a_BlockMeta,a_Player,a_EquippedItem,a_Pickups); }; }; bool OnChat( const char* a_Chat, cPlayer* a_Player) { @@ -8669,51 +8709,65 @@ public: return ( bool ) cPlugin:: OnChat(a_Chat,a_Player); }; }; - bool OnLogin( cPacket_Login* a_PacketData) { - if (push_method("OnLogin", tolua_AllToLua_cPlugin_OnLogin00)) { - tolua_pushusertype(lua_state, (void*)a_PacketData, "cPacket_Login"); - ToluaBase::dbcall(lua_state, 2, 1); + void OnChunkGenerated( cWorld* a_World, int a_ChunkX, int a_ChunkZ) { + if (push_method("OnChunkGenerated", tolua_AllToLua_cPlugin_OnChunkGenerated00)) { + tolua_pushusertype(lua_state, (void*)a_World, "cWorld"); + tolua_pushnumber(lua_state, (lua_Number)a_ChunkX); + tolua_pushnumber(lua_state, (lua_Number)a_ChunkZ); + ToluaBase::dbcall(lua_state, 4, 0); + } else { + return ( void ) cPlugin:: OnChunkGenerated(a_World,a_ChunkX,a_ChunkZ); + }; + }; + bool OnChunkGenerating( cWorld* a_World, int a_ChunkX, int a_ChunkZ, cLuaChunk* a_pLuaChunk) { + if (push_method("OnChunkGenerating", tolua_AllToLua_cPlugin_OnChunkGenerating00)) { + tolua_pushusertype(lua_state, (void*)a_World, "cWorld"); + tolua_pushnumber(lua_state, (lua_Number)a_ChunkX); + tolua_pushnumber(lua_state, (lua_Number)a_ChunkZ); + tolua_pushusertype(lua_state, (void*)a_pLuaChunk, "cLuaChunk"); + ToluaBase::dbcall(lua_state, 5, 1); bool tolua_ret = ( bool )tolua_toboolean(lua_state, -1, 0); lua_pop(lua_state, 1); return tolua_ret; } else { - return ( bool ) cPlugin:: OnLogin(a_PacketData); + return ( bool ) cPlugin:: OnChunkGenerating(a_World,a_ChunkX,a_ChunkZ,a_pLuaChunk); }; }; - void OnPlayerSpawn( cPlayer* a_Player) { - if (push_method("OnPlayerSpawn", tolua_AllToLua_cPlugin_OnPlayerSpawn00)) { + bool OnCollectItem( cPickup* a_Pickup, cPlayer* a_Player) { + if (push_method("OnCollectItem", tolua_AllToLua_cPlugin_OnCollectItem00)) { + tolua_pushusertype(lua_state, (void*)a_Pickup, "cPickup"); tolua_pushusertype(lua_state, (void*)a_Player, "cPlayer"); - ToluaBase::dbcall(lua_state, 2, 0); + ToluaBase::dbcall(lua_state, 3, 1); + bool tolua_ret = ( bool )tolua_toboolean(lua_state, -1, 0); + lua_pop(lua_state, 1); + return tolua_ret; } else { - return ( void ) cPlugin:: OnPlayerSpawn(a_Player); + return ( bool ) cPlugin:: OnCollectItem(a_Pickup,a_Player); }; }; - bool OnPlayerJoin( cPlayer* a_Player) { - if (push_method("OnPlayerJoin", tolua_AllToLua_cPlugin_OnPlayerJoin00)) { - tolua_pushusertype(lua_state, (void*)a_Player, "cPlayer"); - ToluaBase::dbcall(lua_state, 2, 1); + bool OnCraftingNoRecipe( const cPlayer* a_Player, const cCraftingGrid* a_Grid, cCraftingRecipe* a_Recipe) { + if (push_method("OnCraftingNoRecipe", tolua_AllToLua_cPlugin_OnCraftingNoRecipe00)) { + tolua_pushusertype(lua_state, (void*)a_Player, "const cPlayer"); + tolua_pushusertype(lua_state, (void*)a_Grid, "const cCraftingGrid"); + tolua_pushusertype(lua_state, (void*)a_Recipe, "cCraftingRecipe"); + ToluaBase::dbcall(lua_state, 4, 1); bool tolua_ret = ( bool )tolua_toboolean(lua_state, -1, 0); lua_pop(lua_state, 1); return tolua_ret; } else { - return ( bool ) cPlugin:: OnPlayerJoin(a_Player); + return ( bool ) cPlugin:: OnCraftingNoRecipe(a_Player,a_Grid,a_Recipe); }; }; - void OnPlayerMove( cPlayer* a_Player) { - if (push_method("OnPlayerMove", tolua_AllToLua_cPlugin_OnPlayerMove00)) { + bool OnDisconnect( const AString& a_Reason, cPlayer* a_Player) { + if (push_method("OnDisconnect", tolua_AllToLua_cPlugin_OnDisconnect00)) { + tolua_pushcppstring(lua_state, (const char*)a_Reason); tolua_pushusertype(lua_state, (void*)a_Player, "cPlayer"); - ToluaBase::dbcall(lua_state, 2, 0); - } else { - return ( void ) cPlugin:: OnPlayerMove(a_Player); - }; - }; - void OnTakeDamage( cPawn* a_Pawn, TakeDamageInfo* a_TakeDamageInfo) { - if (push_method("OnTakeDamage", tolua_AllToLua_cPlugin_OnTakeDamage00)) { - tolua_pushusertype(lua_state, (void*)a_Pawn, "cPawn"); - tolua_pushusertype(lua_state, (void*)a_TakeDamageInfo, "TakeDamageInfo"); - ToluaBase::dbcall(lua_state, 3, 0); + ToluaBase::dbcall(lua_state, 3, 1); + bool tolua_ret = ( bool )tolua_toboolean(lua_state, -1, 0); + lua_pop(lua_state, 1); + return tolua_ret; } else { - return ( void ) cPlugin:: OnTakeDamage(a_Pawn,a_TakeDamageInfo); + return ( bool ) cPlugin:: OnDisconnect(a_Reason,a_Player); }; }; bool OnKilled( cPawn* a_Killed, cEntity* a_Killer) { @@ -8728,54 +8782,44 @@ public: return ( bool ) cPlugin:: OnKilled(a_Killed,a_Killer); }; }; - void OnChunkGenerated( cWorld* a_World, int a_ChunkX, int a_ChunkZ) { - if (push_method("OnChunkGenerated", tolua_AllToLua_cPlugin_OnChunkGenerated00)) { - tolua_pushusertype(lua_state, (void*)a_World, "cWorld"); - tolua_pushnumber(lua_state, (lua_Number)a_ChunkX); - tolua_pushnumber(lua_state, (lua_Number)a_ChunkZ); - ToluaBase::dbcall(lua_state, 4, 0); - } else { - return ( void ) cPlugin:: OnChunkGenerated(a_World,a_ChunkX,a_ChunkZ); - }; - }; - bool OnChunkGenerating( cWorld* a_World, int a_ChunkX, int a_ChunkZ, cLuaChunk* a_pLuaChunk) { - if (push_method("OnChunkGenerating", tolua_AllToLua_cPlugin_OnChunkGenerating00)) { - tolua_pushusertype(lua_state, (void*)a_World, "cWorld"); - tolua_pushnumber(lua_state, (lua_Number)a_ChunkX); - tolua_pushnumber(lua_state, (lua_Number)a_ChunkZ); - tolua_pushusertype(lua_state, (void*)a_pLuaChunk, "cLuaChunk"); - ToluaBase::dbcall(lua_state, 5, 1); + bool OnLogin( cClientHandle* a_Client, int a_ProtocolVersion, const AString& a_Username) { + if (push_method("OnLogin", tolua_AllToLua_cPlugin_OnLogin00)) { + tolua_pushusertype(lua_state, (void*)a_Client, "cClientHandle"); + tolua_pushnumber(lua_state, (lua_Number)a_ProtocolVersion); + tolua_pushcppstring(lua_state, (const char*)a_Username); + ToluaBase::dbcall(lua_state, 4, 1); bool tolua_ret = ( bool )tolua_toboolean(lua_state, -1, 0); lua_pop(lua_state, 1); return tolua_ret; } else { - return ( bool ) cPlugin:: OnChunkGenerating(a_World,a_ChunkX,a_ChunkZ,a_pLuaChunk); + return ( bool ) cPlugin:: OnLogin(a_Client,a_ProtocolVersion,a_Username); }; }; - bool OnPreCrafting( const cPlayer* a_Player, const cCraftingGrid* a_Grid, cCraftingRecipe* a_Recipe) { - if (push_method("OnPreCrafting", tolua_AllToLua_cPlugin_OnPreCrafting00)) { - tolua_pushusertype(lua_state, (void*)a_Player, "const cPlayer"); - tolua_pushusertype(lua_state, (void*)a_Grid, "const cCraftingGrid"); - tolua_pushusertype(lua_state, (void*)a_Recipe, "cCraftingRecipe"); - ToluaBase::dbcall(lua_state, 4, 1); + bool OnPlayerJoin( cPlayer* a_Player) { + if (push_method("OnPlayerJoin", tolua_AllToLua_cPlugin_OnPlayerJoin00)) { + tolua_pushusertype(lua_state, (void*)a_Player, "cPlayer"); + ToluaBase::dbcall(lua_state, 2, 1); bool tolua_ret = ( bool )tolua_toboolean(lua_state, -1, 0); lua_pop(lua_state, 1); return tolua_ret; } else { - return ( bool ) cPlugin:: OnPreCrafting(a_Player,a_Grid,a_Recipe); + return ( bool ) cPlugin:: OnPlayerJoin(a_Player); }; }; - bool OnCraftingNoRecipe( const cPlayer* a_Player, const cCraftingGrid* a_Grid, cCraftingRecipe* a_Recipe) { - if (push_method("OnCraftingNoRecipe", tolua_AllToLua_cPlugin_OnCraftingNoRecipe00)) { - tolua_pushusertype(lua_state, (void*)a_Player, "const cPlayer"); - tolua_pushusertype(lua_state, (void*)a_Grid, "const cCraftingGrid"); - tolua_pushusertype(lua_state, (void*)a_Recipe, "cCraftingRecipe"); - ToluaBase::dbcall(lua_state, 4, 1); - bool tolua_ret = ( bool )tolua_toboolean(lua_state, -1, 0); - lua_pop(lua_state, 1); - return tolua_ret; + void OnPlayerMove( cPlayer* a_Player) { + if (push_method("OnPlayerMove", tolua_AllToLua_cPlugin_OnPlayerMove00)) { + tolua_pushusertype(lua_state, (void*)a_Player, "cPlayer"); + ToluaBase::dbcall(lua_state, 2, 0); } else { - return ( bool ) cPlugin:: OnCraftingNoRecipe(a_Player,a_Grid,a_Recipe); + return ( void ) cPlugin:: OnPlayerMove(a_Player); + }; + }; + void OnPlayerSpawn( cPlayer* a_Player) { + if (push_method("OnPlayerSpawn", tolua_AllToLua_cPlugin_OnPlayerSpawn00)) { + tolua_pushusertype(lua_state, (void*)a_Player, "cPlayer"); + ToluaBase::dbcall(lua_state, 2, 0); + } else { + return ( void ) cPlugin:: OnPlayerSpawn(a_Player); }; }; bool OnPostCrafting( const cPlayer* a_Player, const cCraftingGrid* a_Grid, cCraftingRecipe* a_Recipe) { @@ -8791,34 +8835,30 @@ public: return ( bool ) cPlugin:: OnPostCrafting(a_Player,a_Grid,a_Recipe); }; }; - bool OnBlockToPickup( unsigned char a_BlockType, unsigned char a_BlockMeta, const cPlayer* a_Player, const cItem& a_EquippedItem, cItems& a_Pickups) { - if (push_method("OnBlockToPickup", tolua_AllToLua_cPlugin_OnBlockToPickup00)) { - tolua_pushnumber(lua_state, (lua_Number)a_BlockType); - tolua_pushnumber(lua_state, (lua_Number)a_BlockMeta); + bool OnPreCrafting( const cPlayer* a_Player, const cCraftingGrid* a_Grid, cCraftingRecipe* a_Recipe) { + if (push_method("OnPreCrafting", tolua_AllToLua_cPlugin_OnPreCrafting00)) { tolua_pushusertype(lua_state, (void*)a_Player, "const cPlayer"); - tolua_pushusertype(lua_state, (void*)&a_EquippedItem, "const cItem"); - tolua_pushusertype(lua_state, (void*)&a_Pickups, "cItems"); - ToluaBase::dbcall(lua_state, 6, 1); + tolua_pushusertype(lua_state, (void*)a_Grid, "const cCraftingGrid"); + tolua_pushusertype(lua_state, (void*)a_Recipe, "cCraftingRecipe"); + ToluaBase::dbcall(lua_state, 4, 1); bool tolua_ret = ( bool )tolua_toboolean(lua_state, -1, 0); lua_pop(lua_state, 1); return tolua_ret; } else { - return ( bool ) cPlugin:: OnBlockToPickup(a_BlockType,a_BlockMeta,a_Player,a_EquippedItem,a_Pickups); + return ( bool ) cPlugin:: OnPreCrafting(a_Player,a_Grid,a_Recipe); }; }; - bool OnWeatherChanged( cWorld* a_World) { - if (push_method("OnWeatherChanged", tolua_AllToLua_cPlugin_OnWeatherChanged00)) { - tolua_pushusertype(lua_state, (void*)a_World, "cWorld"); - ToluaBase::dbcall(lua_state, 2, 1); - bool tolua_ret = ( bool )tolua_toboolean(lua_state, -1, 0); - lua_pop(lua_state, 1); - return tolua_ret; + void OnTakeDamage( cPawn* a_Pawn, TakeDamageInfo* a_TakeDamageInfo) { + if (push_method("OnTakeDamage", tolua_AllToLua_cPlugin_OnTakeDamage00)) { + tolua_pushusertype(lua_state, (void*)a_Pawn, "cPawn"); + tolua_pushusertype(lua_state, (void*)a_TakeDamageInfo, "TakeDamageInfo"); + ToluaBase::dbcall(lua_state, 3, 0); } else { - return ( bool ) cPlugin:: OnWeatherChanged(a_World); + return ( void ) cPlugin:: OnTakeDamage(a_Pawn,a_TakeDamageInfo); }; }; - bool OnUpdatingSign( cWorld* a_World, int a_BlockX, int a_BlockY, int a_BlockZ, AString& a_Line1, AString& a_Line2, AString& a_Line3, AString& a_Line4) { - if (push_method("OnUpdatingSign", tolua_AllToLua_cPlugin_OnUpdatingSign00)) { + bool OnUpdatedSign( cWorld* a_World, int a_BlockX, int a_BlockY, int a_BlockZ, const AString& a_Line1, const AString& a_Line2, const AString& a_Line3, const AString& a_Line4) { + if (push_method("OnUpdatedSign", tolua_AllToLua_cPlugin_OnUpdatedSign00)) { tolua_pushusertype(lua_state, (void*)a_World, "cWorld"); tolua_pushnumber(lua_state, (lua_Number)a_BlockX); tolua_pushnumber(lua_state, (lua_Number)a_BlockY); @@ -8832,11 +8872,11 @@ public: lua_pop(lua_state, 1); return tolua_ret; } else { - return ( bool ) cPlugin:: OnUpdatingSign(a_World,a_BlockX,a_BlockY,a_BlockZ,a_Line1,a_Line2,a_Line3,a_Line4); + return ( bool ) cPlugin:: OnUpdatedSign(a_World,a_BlockX,a_BlockY,a_BlockZ,a_Line1,a_Line2,a_Line3,a_Line4); }; }; - bool OnUpdatedSign( cWorld* a_World, int a_BlockX, int a_BlockY, int a_BlockZ, const AString& a_Line1, const AString& a_Line2, const AString& a_Line3, const AString& a_Line4) { - if (push_method("OnUpdatedSign", tolua_AllToLua_cPlugin_OnUpdatedSign00)) { + bool OnUpdatingSign( cWorld* a_World, int a_BlockX, int a_BlockY, int a_BlockZ, AString& a_Line1, AString& a_Line2, AString& a_Line3, AString& a_Line4) { + if (push_method("OnUpdatingSign", tolua_AllToLua_cPlugin_OnUpdatingSign00)) { tolua_pushusertype(lua_state, (void*)a_World, "cWorld"); tolua_pushnumber(lua_state, (lua_Number)a_BlockX); tolua_pushnumber(lua_state, (lua_Number)a_BlockY); @@ -8850,7 +8890,18 @@ public: lua_pop(lua_state, 1); return tolua_ret; } else { - return ( bool ) cPlugin:: OnUpdatedSign(a_World,a_BlockX,a_BlockY,a_BlockZ,a_Line1,a_Line2,a_Line3,a_Line4); + return ( bool ) cPlugin:: OnUpdatingSign(a_World,a_BlockX,a_BlockY,a_BlockZ,a_Line1,a_Line2,a_Line3,a_Line4); + }; + }; + bool OnWeatherChanged( cWorld* a_World) { + if (push_method("OnWeatherChanged", tolua_AllToLua_cPlugin_OnWeatherChanged00)) { + tolua_pushusertype(lua_state, (void*)a_World, "cWorld"); + ToluaBase::dbcall(lua_state, 2, 1); + bool tolua_ret = ( bool )tolua_toboolean(lua_state, -1, 0); + lua_pop(lua_state, 1); + return tolua_ret; + } else { + return ( bool ) cPlugin:: OnWeatherChanged(a_World); }; }; @@ -8860,65 +8911,65 @@ public: void cPlugin__Tick( float a_Dt) { return ( void )cPlugin::Tick(a_Dt); }; - bool cPlugin__OnCollectItem( cPickup* a_Pickup, cPlayer* a_Player) { - return ( bool )cPlugin::OnCollectItem(a_Pickup,a_Player); + bool cPlugin__OnBlockDig( cPlayer* a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status, unsigned char a_OldBlock, unsigned char a_OldMeta) { + return ( bool )cPlugin::OnBlockDig(a_Player,a_BlockX,a_BlockY,a_BlockZ,a_BlockFace,a_Status,a_OldBlock,a_OldMeta); }; - bool cPlugin__OnDisconnect( const AString& a_Reason, cPlayer* a_Player) { - return ( bool )cPlugin::OnDisconnect(a_Reason,a_Player); + bool cPlugin__OnBlockPlace( cPlayer* a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, const cItem& a_HeldItem) { + return ( bool )cPlugin::OnBlockPlace(a_Player,a_BlockX,a_BlockY,a_BlockZ,a_BlockFace,a_HeldItem); }; - bool cPlugin__OnBlockPlace( cPacket_BlockPlace* a_PacketData, cPlayer* a_Player) { - return ( bool )cPlugin::OnBlockPlace(a_PacketData,a_Player); - }; - bool cPlugin__OnBlockDig( cPacket_BlockDig* a_PacketData, cPlayer* a_Player, cItem* a_PickupItem) { - return ( bool )cPlugin::OnBlockDig(a_PacketData,a_Player,a_PickupItem); + bool cPlugin__OnBlockToPickup( unsigned char a_BlockType, unsigned char a_BlockMeta, const cPlayer* a_Player, const cItem& a_EquippedItem, cItems& a_Pickups) { + return ( bool )cPlugin::OnBlockToPickup(a_BlockType,a_BlockMeta,a_Player,a_EquippedItem,a_Pickups); }; bool cPlugin__OnChat( const char* a_Chat, cPlayer* a_Player) { return ( bool )cPlugin::OnChat(a_Chat,a_Player); }; - bool cPlugin__OnLogin( cPacket_Login* a_PacketData) { - return ( bool )cPlugin::OnLogin(a_PacketData); + void cPlugin__OnChunkGenerated( cWorld* a_World, int a_ChunkX, int a_ChunkZ) { + return ( void )cPlugin::OnChunkGenerated(a_World,a_ChunkX,a_ChunkZ); }; - void cPlugin__OnPlayerSpawn( cPlayer* a_Player) { - return ( void )cPlugin::OnPlayerSpawn(a_Player); + bool cPlugin__OnChunkGenerating( cWorld* a_World, int a_ChunkX, int a_ChunkZ, cLuaChunk* a_pLuaChunk) { + return ( bool )cPlugin::OnChunkGenerating(a_World,a_ChunkX,a_ChunkZ,a_pLuaChunk); }; - bool cPlugin__OnPlayerJoin( cPlayer* a_Player) { - return ( bool )cPlugin::OnPlayerJoin(a_Player); + bool cPlugin__OnCollectItem( cPickup* a_Pickup, cPlayer* a_Player) { + return ( bool )cPlugin::OnCollectItem(a_Pickup,a_Player); }; - void cPlugin__OnPlayerMove( cPlayer* a_Player) { - return ( void )cPlugin::OnPlayerMove(a_Player); + bool cPlugin__OnCraftingNoRecipe( const cPlayer* a_Player, const cCraftingGrid* a_Grid, cCraftingRecipe* a_Recipe) { + return ( bool )cPlugin::OnCraftingNoRecipe(a_Player,a_Grid,a_Recipe); }; - void cPlugin__OnTakeDamage( cPawn* a_Pawn, TakeDamageInfo* a_TakeDamageInfo) { - return ( void )cPlugin::OnTakeDamage(a_Pawn,a_TakeDamageInfo); + bool cPlugin__OnDisconnect( const AString& a_Reason, cPlayer* a_Player) { + return ( bool )cPlugin::OnDisconnect(a_Reason,a_Player); }; bool cPlugin__OnKilled( cPawn* a_Killed, cEntity* a_Killer) { return ( bool )cPlugin::OnKilled(a_Killed,a_Killer); }; - void cPlugin__OnChunkGenerated( cWorld* a_World, int a_ChunkX, int a_ChunkZ) { - return ( void )cPlugin::OnChunkGenerated(a_World,a_ChunkX,a_ChunkZ); + bool cPlugin__OnLogin( cClientHandle* a_Client, int a_ProtocolVersion, const AString& a_Username) { + return ( bool )cPlugin::OnLogin(a_Client,a_ProtocolVersion,a_Username); }; - bool cPlugin__OnChunkGenerating( cWorld* a_World, int a_ChunkX, int a_ChunkZ, cLuaChunk* a_pLuaChunk) { - return ( bool )cPlugin::OnChunkGenerating(a_World,a_ChunkX,a_ChunkZ,a_pLuaChunk); + bool cPlugin__OnPlayerJoin( cPlayer* a_Player) { + return ( bool )cPlugin::OnPlayerJoin(a_Player); }; - bool cPlugin__OnPreCrafting( const cPlayer* a_Player, const cCraftingGrid* a_Grid, cCraftingRecipe* a_Recipe) { - return ( bool )cPlugin::OnPreCrafting(a_Player,a_Grid,a_Recipe); + void cPlugin__OnPlayerMove( cPlayer* a_Player) { + return ( void )cPlugin::OnPlayerMove(a_Player); }; - bool cPlugin__OnCraftingNoRecipe( const cPlayer* a_Player, const cCraftingGrid* a_Grid, cCraftingRecipe* a_Recipe) { - return ( bool )cPlugin::OnCraftingNoRecipe(a_Player,a_Grid,a_Recipe); + void cPlugin__OnPlayerSpawn( cPlayer* a_Player) { + return ( void )cPlugin::OnPlayerSpawn(a_Player); }; bool cPlugin__OnPostCrafting( const cPlayer* a_Player, const cCraftingGrid* a_Grid, cCraftingRecipe* a_Recipe) { return ( bool )cPlugin::OnPostCrafting(a_Player,a_Grid,a_Recipe); }; - bool cPlugin__OnBlockToPickup( unsigned char a_BlockType, unsigned char a_BlockMeta, const cPlayer* a_Player, const cItem& a_EquippedItem, cItems& a_Pickups) { - return ( bool )cPlugin::OnBlockToPickup(a_BlockType,a_BlockMeta,a_Player,a_EquippedItem,a_Pickups); + bool cPlugin__OnPreCrafting( const cPlayer* a_Player, const cCraftingGrid* a_Grid, cCraftingRecipe* a_Recipe) { + return ( bool )cPlugin::OnPreCrafting(a_Player,a_Grid,a_Recipe); }; - bool cPlugin__OnWeatherChanged( cWorld* a_World) { - return ( bool )cPlugin::OnWeatherChanged(a_World); + void cPlugin__OnTakeDamage( cPawn* a_Pawn, TakeDamageInfo* a_TakeDamageInfo) { + return ( void )cPlugin::OnTakeDamage(a_Pawn,a_TakeDamageInfo); + }; + bool cPlugin__OnUpdatedSign( cWorld* a_World, int a_BlockX, int a_BlockY, int a_BlockZ, const AString& a_Line1, const AString& a_Line2, const AString& a_Line3, const AString& a_Line4) { + return ( bool )cPlugin::OnUpdatedSign(a_World,a_BlockX,a_BlockY,a_BlockZ,a_Line1,a_Line2,a_Line3,a_Line4); }; bool cPlugin__OnUpdatingSign( cWorld* a_World, int a_BlockX, int a_BlockY, int a_BlockZ, AString& a_Line1, AString& a_Line2, AString& a_Line3, AString& a_Line4) { return ( bool )cPlugin::OnUpdatingSign(a_World,a_BlockX,a_BlockY,a_BlockZ,a_Line1,a_Line2,a_Line3,a_Line4); }; - bool cPlugin__OnUpdatedSign( cWorld* a_World, int a_BlockX, int a_BlockY, int a_BlockZ, const AString& a_Line1, const AString& a_Line2, const AString& a_Line3, const AString& a_Line4) { - return ( bool )cPlugin::OnUpdatedSign(a_World,a_BlockX,a_BlockY,a_BlockZ,a_Line1,a_Line2,a_Line3,a_Line4); + bool cPlugin__OnWeatherChanged( cWorld* a_World) { + return ( bool )cPlugin::OnWeatherChanged(a_World); }; Lua__cPlugin( void ): cPlugin(){}; }; @@ -9020,74 +9071,49 @@ static int tolua_AllToLua_Lua__cPlugin_cPlugin__Tick00(lua_State* tolua_S) } #endif //#ifndef TOLUA_DISABLE -/* method: cPlugin__OnCollectItem of class Lua__cPlugin */ -#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPlugin_cPlugin__OnCollectItem00 -static int tolua_AllToLua_Lua__cPlugin_cPlugin__OnCollectItem00(lua_State* tolua_S) +/* method: cPlugin__OnBlockDig of class Lua__cPlugin */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPlugin_cPlugin__OnBlockDig00 +static int tolua_AllToLua_Lua__cPlugin_cPlugin__OnBlockDig00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"Lua__cPlugin",0,&tolua_err) || - !tolua_isusertype(tolua_S,2,"cPickup",0,&tolua_err) || - !tolua_isusertype(tolua_S,3,"cPlayer",0,&tolua_err) || - !tolua_isnoobj(tolua_S,4,&tolua_err) + !tolua_isusertype(tolua_S,2,"cPlayer",0,&tolua_err) || + !tolua_isnumber(tolua_S,3,0,&tolua_err) || + !tolua_isnumber(tolua_S,4,0,&tolua_err) || + !tolua_isnumber(tolua_S,5,0,&tolua_err) || + !tolua_isnumber(tolua_S,6,0,&tolua_err) || + !tolua_isnumber(tolua_S,7,0,&tolua_err) || + !tolua_isnumber(tolua_S,8,0,&tolua_err) || + !tolua_isnumber(tolua_S,9,0,&tolua_err) || + !tolua_isnoobj(tolua_S,10,&tolua_err) ) goto tolua_lerror; else #endif { Lua__cPlugin* self = (Lua__cPlugin*) tolua_tousertype(tolua_S,1,0); - cPickup* a_Pickup = ((cPickup*) tolua_tousertype(tolua_S,2,0)); - cPlayer* a_Player = ((cPlayer*) tolua_tousertype(tolua_S,3,0)); + cPlayer* a_Player = ((cPlayer*) tolua_tousertype(tolua_S,2,0)); + int a_BlockX = ((int) tolua_tonumber(tolua_S,3,0)); + int a_BlockY = ((int) tolua_tonumber(tolua_S,4,0)); + int a_BlockZ = ((int) tolua_tonumber(tolua_S,5,0)); + char a_BlockFace = ((char) tolua_tonumber(tolua_S,6,0)); + char a_Status = ((char) tolua_tonumber(tolua_S,7,0)); + unsigned char a_OldBlock = ((unsigned char) tolua_tonumber(tolua_S,8,0)); + unsigned char a_OldMeta = ((unsigned char) tolua_tonumber(tolua_S,9,0)); #ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPlugin__OnCollectItem'", NULL); + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPlugin__OnBlockDig'", NULL); #endif { - bool tolua_ret = (bool) self->cPlugin__OnCollectItem(a_Pickup,a_Player); + bool tolua_ret = (bool) self->cPlugin__OnBlockDig(a_Player,a_BlockX,a_BlockY,a_BlockZ,a_BlockFace,a_Status,a_OldBlock,a_OldMeta); tolua_pushboolean(tolua_S,(bool)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'cPlugin__OnCollectItem'.",&tolua_err); - return 0; -#endif -} -#endif //#ifndef TOLUA_DISABLE - -/* method: cPlugin__OnDisconnect of class Lua__cPlugin */ -#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPlugin_cPlugin__OnDisconnect00 -static int tolua_AllToLua_Lua__cPlugin_cPlugin__OnDisconnect00(lua_State* tolua_S) -{ -#ifndef TOLUA_RELEASE - tolua_Error tolua_err; - if ( - !tolua_isusertype(tolua_S,1,"Lua__cPlugin",0,&tolua_err) || - !tolua_iscppstring(tolua_S,2,0,&tolua_err) || - !tolua_isusertype(tolua_S,3,"cPlayer",0,&tolua_err) || - !tolua_isnoobj(tolua_S,4,&tolua_err) - ) - goto tolua_lerror; - else -#endif - { - Lua__cPlugin* self = (Lua__cPlugin*) tolua_tousertype(tolua_S,1,0); - const AString a_Reason = ((const AString) tolua_tocppstring(tolua_S,2,0)); - cPlayer* a_Player = ((cPlayer*) tolua_tousertype(tolua_S,3,0)); -#ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPlugin__OnDisconnect'", NULL); -#endif - { - bool tolua_ret = (bool) self->cPlugin__OnDisconnect(a_Reason,a_Player); - tolua_pushboolean(tolua_S,(bool)tolua_ret); - tolua_pushcppstring(tolua_S,(const char*)a_Reason); - } - } - return 2; -#ifndef TOLUA_RELEASE - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'cPlugin__OnDisconnect'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'cPlugin__OnBlockDig'.",&tolua_err); return 0; #endif } @@ -9101,22 +9127,30 @@ static int tolua_AllToLua_Lua__cPlugin_cPlugin__OnBlockPlace00(lua_State* tolua_ tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"Lua__cPlugin",0,&tolua_err) || - !tolua_isusertype(tolua_S,2,"cPacket_BlockPlace",0,&tolua_err) || - !tolua_isusertype(tolua_S,3,"cPlayer",0,&tolua_err) || - !tolua_isnoobj(tolua_S,4,&tolua_err) + !tolua_isusertype(tolua_S,2,"cPlayer",0,&tolua_err) || + !tolua_isnumber(tolua_S,3,0,&tolua_err) || + !tolua_isnumber(tolua_S,4,0,&tolua_err) || + !tolua_isnumber(tolua_S,5,0,&tolua_err) || + !tolua_isnumber(tolua_S,6,0,&tolua_err) || + (tolua_isvaluenil(tolua_S,7,&tolua_err) || !tolua_isusertype(tolua_S,7,"const cItem",0,&tolua_err)) || + !tolua_isnoobj(tolua_S,8,&tolua_err) ) goto tolua_lerror; else #endif { Lua__cPlugin* self = (Lua__cPlugin*) tolua_tousertype(tolua_S,1,0); - cPacket_BlockPlace* a_PacketData = ((cPacket_BlockPlace*) tolua_tousertype(tolua_S,2,0)); - cPlayer* a_Player = ((cPlayer*) tolua_tousertype(tolua_S,3,0)); + cPlayer* a_Player = ((cPlayer*) tolua_tousertype(tolua_S,2,0)); + int a_BlockX = ((int) tolua_tonumber(tolua_S,3,0)); + int a_BlockY = ((int) tolua_tonumber(tolua_S,4,0)); + int a_BlockZ = ((int) tolua_tonumber(tolua_S,5,0)); + char a_BlockFace = ((char) tolua_tonumber(tolua_S,6,0)); + const cItem* a_HeldItem = ((const cItem*) tolua_tousertype(tolua_S,7,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPlugin__OnBlockPlace'", NULL); #endif { - bool tolua_ret = (bool) self->cPlugin__OnBlockPlace(a_PacketData,a_Player); + bool tolua_ret = (bool) self->cPlugin__OnBlockPlace(a_Player,a_BlockX,a_BlockY,a_BlockZ,a_BlockFace,*a_HeldItem); tolua_pushboolean(tolua_S,(bool)tolua_ret); } } @@ -9129,39 +9163,43 @@ static int tolua_AllToLua_Lua__cPlugin_cPlugin__OnBlockPlace00(lua_State* tolua_ } #endif //#ifndef TOLUA_DISABLE -/* method: cPlugin__OnBlockDig of class Lua__cPlugin */ -#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPlugin_cPlugin__OnBlockDig00 -static int tolua_AllToLua_Lua__cPlugin_cPlugin__OnBlockDig00(lua_State* tolua_S) +/* method: cPlugin__OnBlockToPickup of class Lua__cPlugin */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPlugin_cPlugin__OnBlockToPickup00 +static int tolua_AllToLua_Lua__cPlugin_cPlugin__OnBlockToPickup00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"Lua__cPlugin",0,&tolua_err) || - !tolua_isusertype(tolua_S,2,"cPacket_BlockDig",0,&tolua_err) || - !tolua_isusertype(tolua_S,3,"cPlayer",0,&tolua_err) || - !tolua_isusertype(tolua_S,4,"cItem",0,&tolua_err) || - !tolua_isnoobj(tolua_S,5,&tolua_err) + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnumber(tolua_S,3,0,&tolua_err) || + !tolua_isusertype(tolua_S,4,"const cPlayer",0,&tolua_err) || + (tolua_isvaluenil(tolua_S,5,&tolua_err) || !tolua_isusertype(tolua_S,5,"const cItem",0,&tolua_err)) || + (tolua_isvaluenil(tolua_S,6,&tolua_err) || !tolua_isusertype(tolua_S,6,"cItems",0,&tolua_err)) || + !tolua_isnoobj(tolua_S,7,&tolua_err) ) goto tolua_lerror; else #endif { Lua__cPlugin* self = (Lua__cPlugin*) tolua_tousertype(tolua_S,1,0); - cPacket_BlockDig* a_PacketData = ((cPacket_BlockDig*) tolua_tousertype(tolua_S,2,0)); - cPlayer* a_Player = ((cPlayer*) tolua_tousertype(tolua_S,3,0)); - cItem* a_PickupItem = ((cItem*) tolua_tousertype(tolua_S,4,0)); + unsigned char a_BlockType = ((unsigned char) tolua_tonumber(tolua_S,2,0)); + unsigned char a_BlockMeta = ((unsigned char) tolua_tonumber(tolua_S,3,0)); + const cPlayer* a_Player = ((const cPlayer*) tolua_tousertype(tolua_S,4,0)); + const cItem* a_EquippedItem = ((const cItem*) tolua_tousertype(tolua_S,5,0)); + cItems* a_Pickups = ((cItems*) tolua_tousertype(tolua_S,6,0)); #ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPlugin__OnBlockDig'", NULL); + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPlugin__OnBlockToPickup'", NULL); #endif { - bool tolua_ret = (bool) self->cPlugin__OnBlockDig(a_PacketData,a_Player,a_PickupItem); + bool tolua_ret = (bool) self->cPlugin__OnBlockToPickup(a_BlockType,a_BlockMeta,a_Player,*a_EquippedItem,*a_Pickups); tolua_pushboolean(tolua_S,(bool)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'cPlugin__OnBlockDig'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'cPlugin__OnBlockToPickup'.",&tolua_err); return 0; #endif } @@ -9203,150 +9241,167 @@ static int tolua_AllToLua_Lua__cPlugin_cPlugin__OnChat00(lua_State* tolua_S) } #endif //#ifndef TOLUA_DISABLE -/* method: cPlugin__OnLogin of class Lua__cPlugin */ -#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPlugin_cPlugin__OnLogin00 -static int tolua_AllToLua_Lua__cPlugin_cPlugin__OnLogin00(lua_State* tolua_S) +/* method: cPlugin__OnChunkGenerated of class Lua__cPlugin */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPlugin_cPlugin__OnChunkGenerated00 +static int tolua_AllToLua_Lua__cPlugin_cPlugin__OnChunkGenerated00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"Lua__cPlugin",0,&tolua_err) || - !tolua_isusertype(tolua_S,2,"cPacket_Login",0,&tolua_err) || - !tolua_isnoobj(tolua_S,3,&tolua_err) + !tolua_isusertype(tolua_S,2,"cWorld",0,&tolua_err) || + !tolua_isnumber(tolua_S,3,0,&tolua_err) || + !tolua_isnumber(tolua_S,4,0,&tolua_err) || + !tolua_isnoobj(tolua_S,5,&tolua_err) ) goto tolua_lerror; else #endif { Lua__cPlugin* self = (Lua__cPlugin*) tolua_tousertype(tolua_S,1,0); - cPacket_Login* a_PacketData = ((cPacket_Login*) tolua_tousertype(tolua_S,2,0)); + cWorld* a_World = ((cWorld*) tolua_tousertype(tolua_S,2,0)); + int a_ChunkX = ((int) tolua_tonumber(tolua_S,3,0)); + int a_ChunkZ = ((int) tolua_tonumber(tolua_S,4,0)); #ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPlugin__OnLogin'", NULL); + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPlugin__OnChunkGenerated'", NULL); #endif { - bool tolua_ret = (bool) self->cPlugin__OnLogin(a_PacketData); - tolua_pushboolean(tolua_S,(bool)tolua_ret); + self->cPlugin__OnChunkGenerated(a_World,a_ChunkX,a_ChunkZ); } } - return 1; + return 0; #ifndef TOLUA_RELEASE tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'cPlugin__OnLogin'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'cPlugin__OnChunkGenerated'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE -/* method: cPlugin__OnPlayerSpawn of class Lua__cPlugin */ -#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPlugin_cPlugin__OnPlayerSpawn00 -static int tolua_AllToLua_Lua__cPlugin_cPlugin__OnPlayerSpawn00(lua_State* tolua_S) +/* method: cPlugin__OnChunkGenerating of class Lua__cPlugin */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPlugin_cPlugin__OnChunkGenerating00 +static int tolua_AllToLua_Lua__cPlugin_cPlugin__OnChunkGenerating00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"Lua__cPlugin",0,&tolua_err) || - !tolua_isusertype(tolua_S,2,"cPlayer",0,&tolua_err) || - !tolua_isnoobj(tolua_S,3,&tolua_err) + !tolua_isusertype(tolua_S,2,"cWorld",0,&tolua_err) || + !tolua_isnumber(tolua_S,3,0,&tolua_err) || + !tolua_isnumber(tolua_S,4,0,&tolua_err) || + !tolua_isusertype(tolua_S,5,"cLuaChunk",0,&tolua_err) || + !tolua_isnoobj(tolua_S,6,&tolua_err) ) goto tolua_lerror; else #endif { Lua__cPlugin* self = (Lua__cPlugin*) tolua_tousertype(tolua_S,1,0); - cPlayer* a_Player = ((cPlayer*) tolua_tousertype(tolua_S,2,0)); + cWorld* a_World = ((cWorld*) tolua_tousertype(tolua_S,2,0)); + int a_ChunkX = ((int) tolua_tonumber(tolua_S,3,0)); + int a_ChunkZ = ((int) tolua_tonumber(tolua_S,4,0)); + cLuaChunk* a_pLuaChunk = ((cLuaChunk*) tolua_tousertype(tolua_S,5,0)); #ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPlugin__OnPlayerSpawn'", NULL); + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPlugin__OnChunkGenerating'", NULL); #endif { - self->cPlugin__OnPlayerSpawn(a_Player); + bool tolua_ret = (bool) self->cPlugin__OnChunkGenerating(a_World,a_ChunkX,a_ChunkZ,a_pLuaChunk); + tolua_pushboolean(tolua_S,(bool)tolua_ret); } } - return 0; + return 1; #ifndef TOLUA_RELEASE tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'cPlugin__OnPlayerSpawn'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'cPlugin__OnChunkGenerating'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE -/* method: cPlugin__OnPlayerJoin of class Lua__cPlugin */ -#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPlugin_cPlugin__OnPlayerJoin00 -static int tolua_AllToLua_Lua__cPlugin_cPlugin__OnPlayerJoin00(lua_State* tolua_S) +/* method: cPlugin__OnCollectItem of class Lua__cPlugin */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPlugin_cPlugin__OnCollectItem00 +static int tolua_AllToLua_Lua__cPlugin_cPlugin__OnCollectItem00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"Lua__cPlugin",0,&tolua_err) || - !tolua_isusertype(tolua_S,2,"cPlayer",0,&tolua_err) || - !tolua_isnoobj(tolua_S,3,&tolua_err) + !tolua_isusertype(tolua_S,2,"cPickup",0,&tolua_err) || + !tolua_isusertype(tolua_S,3,"cPlayer",0,&tolua_err) || + !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else #endif { Lua__cPlugin* self = (Lua__cPlugin*) tolua_tousertype(tolua_S,1,0); - cPlayer* a_Player = ((cPlayer*) tolua_tousertype(tolua_S,2,0)); + cPickup* a_Pickup = ((cPickup*) tolua_tousertype(tolua_S,2,0)); + cPlayer* a_Player = ((cPlayer*) tolua_tousertype(tolua_S,3,0)); #ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPlugin__OnPlayerJoin'", NULL); + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPlugin__OnCollectItem'", NULL); #endif { - bool tolua_ret = (bool) self->cPlugin__OnPlayerJoin(a_Player); + bool tolua_ret = (bool) self->cPlugin__OnCollectItem(a_Pickup,a_Player); tolua_pushboolean(tolua_S,(bool)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'cPlugin__OnPlayerJoin'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'cPlugin__OnCollectItem'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE -/* method: cPlugin__OnPlayerMove of class Lua__cPlugin */ -#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPlugin_cPlugin__OnPlayerMove00 -static int tolua_AllToLua_Lua__cPlugin_cPlugin__OnPlayerMove00(lua_State* tolua_S) +/* method: cPlugin__OnCraftingNoRecipe of class Lua__cPlugin */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPlugin_cPlugin__OnCraftingNoRecipe00 +static int tolua_AllToLua_Lua__cPlugin_cPlugin__OnCraftingNoRecipe00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"Lua__cPlugin",0,&tolua_err) || - !tolua_isusertype(tolua_S,2,"cPlayer",0,&tolua_err) || - !tolua_isnoobj(tolua_S,3,&tolua_err) + !tolua_isusertype(tolua_S,2,"const cPlayer",0,&tolua_err) || + !tolua_isusertype(tolua_S,3,"const cCraftingGrid",0,&tolua_err) || + !tolua_isusertype(tolua_S,4,"cCraftingRecipe",0,&tolua_err) || + !tolua_isnoobj(tolua_S,5,&tolua_err) ) goto tolua_lerror; else #endif { Lua__cPlugin* self = (Lua__cPlugin*) tolua_tousertype(tolua_S,1,0); - cPlayer* a_Player = ((cPlayer*) tolua_tousertype(tolua_S,2,0)); + const cPlayer* a_Player = ((const cPlayer*) tolua_tousertype(tolua_S,2,0)); + const cCraftingGrid* a_Grid = ((const cCraftingGrid*) tolua_tousertype(tolua_S,3,0)); + cCraftingRecipe* a_Recipe = ((cCraftingRecipe*) tolua_tousertype(tolua_S,4,0)); #ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPlugin__OnPlayerMove'", NULL); + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPlugin__OnCraftingNoRecipe'", NULL); #endif { - self->cPlugin__OnPlayerMove(a_Player); + bool tolua_ret = (bool) self->cPlugin__OnCraftingNoRecipe(a_Player,a_Grid,a_Recipe); + tolua_pushboolean(tolua_S,(bool)tolua_ret); } } - return 0; + return 1; #ifndef TOLUA_RELEASE tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'cPlugin__OnPlayerMove'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'cPlugin__OnCraftingNoRecipe'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE -/* method: cPlugin__OnTakeDamage of class Lua__cPlugin */ -#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPlugin_cPlugin__OnTakeDamage00 -static int tolua_AllToLua_Lua__cPlugin_cPlugin__OnTakeDamage00(lua_State* tolua_S) +/* method: cPlugin__OnDisconnect of class Lua__cPlugin */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPlugin_cPlugin__OnDisconnect00 +static int tolua_AllToLua_Lua__cPlugin_cPlugin__OnDisconnect00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"Lua__cPlugin",0,&tolua_err) || - !tolua_isusertype(tolua_S,2,"cPawn",0,&tolua_err) || - !tolua_isusertype(tolua_S,3,"TakeDamageInfo",0,&tolua_err) || + !tolua_iscppstring(tolua_S,2,0,&tolua_err) || + !tolua_isusertype(tolua_S,3,"cPlayer",0,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; @@ -9354,19 +9409,21 @@ static int tolua_AllToLua_Lua__cPlugin_cPlugin__OnTakeDamage00(lua_State* tolua_ #endif { Lua__cPlugin* self = (Lua__cPlugin*) tolua_tousertype(tolua_S,1,0); - cPawn* a_Pawn = ((cPawn*) tolua_tousertype(tolua_S,2,0)); - TakeDamageInfo* a_TakeDamageInfo = ((TakeDamageInfo*) tolua_tousertype(tolua_S,3,0)); + const AString a_Reason = ((const AString) tolua_tocppstring(tolua_S,2,0)); + cPlayer* a_Player = ((cPlayer*) tolua_tousertype(tolua_S,3,0)); #ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPlugin__OnTakeDamage'", NULL); + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPlugin__OnDisconnect'", NULL); #endif { - self->cPlugin__OnTakeDamage(a_Pawn,a_TakeDamageInfo); + bool tolua_ret = (bool) self->cPlugin__OnDisconnect(a_Reason,a_Player); + tolua_pushboolean(tolua_S,(bool)tolua_ret); + tolua_pushcppstring(tolua_S,(const char*)a_Reason); } } - return 0; + return 2; #ifndef TOLUA_RELEASE tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'cPlugin__OnTakeDamage'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'cPlugin__OnDisconnect'.",&tolua_err); return 0; #endif } @@ -9408,17 +9465,17 @@ static int tolua_AllToLua_Lua__cPlugin_cPlugin__OnKilled00(lua_State* tolua_S) } #endif //#ifndef TOLUA_DISABLE -/* method: cPlugin__OnChunkGenerated of class Lua__cPlugin */ -#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPlugin_cPlugin__OnChunkGenerated00 -static int tolua_AllToLua_Lua__cPlugin_cPlugin__OnChunkGenerated00(lua_State* tolua_S) +/* method: cPlugin__OnLogin of class Lua__cPlugin */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPlugin_cPlugin__OnLogin00 +static int tolua_AllToLua_Lua__cPlugin_cPlugin__OnLogin00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"Lua__cPlugin",0,&tolua_err) || - !tolua_isusertype(tolua_S,2,"cWorld",0,&tolua_err) || + !tolua_isusertype(tolua_S,2,"cClientHandle",0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || - !tolua_isnumber(tolua_S,4,0,&tolua_err) || + !tolua_iscppstring(tolua_S,4,0,&tolua_err) || !tolua_isnoobj(tolua_S,5,&tolua_err) ) goto tolua_lerror; @@ -9426,136 +9483,122 @@ static int tolua_AllToLua_Lua__cPlugin_cPlugin__OnChunkGenerated00(lua_State* to #endif { Lua__cPlugin* self = (Lua__cPlugin*) tolua_tousertype(tolua_S,1,0); - cWorld* a_World = ((cWorld*) tolua_tousertype(tolua_S,2,0)); - int a_ChunkX = ((int) tolua_tonumber(tolua_S,3,0)); - int a_ChunkZ = ((int) tolua_tonumber(tolua_S,4,0)); + cClientHandle* a_Client = ((cClientHandle*) tolua_tousertype(tolua_S,2,0)); + int a_ProtocolVersion = ((int) tolua_tonumber(tolua_S,3,0)); + const AString a_Username = ((const AString) tolua_tocppstring(tolua_S,4,0)); #ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPlugin__OnChunkGenerated'", NULL); + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPlugin__OnLogin'", NULL); #endif { - self->cPlugin__OnChunkGenerated(a_World,a_ChunkX,a_ChunkZ); + bool tolua_ret = (bool) self->cPlugin__OnLogin(a_Client,a_ProtocolVersion,a_Username); + tolua_pushboolean(tolua_S,(bool)tolua_ret); + tolua_pushcppstring(tolua_S,(const char*)a_Username); } } - return 0; + return 2; #ifndef TOLUA_RELEASE tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'cPlugin__OnChunkGenerated'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'cPlugin__OnLogin'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE -/* method: cPlugin__OnChunkGenerating of class Lua__cPlugin */ -#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPlugin_cPlugin__OnChunkGenerating00 -static int tolua_AllToLua_Lua__cPlugin_cPlugin__OnChunkGenerating00(lua_State* tolua_S) +/* method: cPlugin__OnPlayerJoin of class Lua__cPlugin */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPlugin_cPlugin__OnPlayerJoin00 +static int tolua_AllToLua_Lua__cPlugin_cPlugin__OnPlayerJoin00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"Lua__cPlugin",0,&tolua_err) || - !tolua_isusertype(tolua_S,2,"cWorld",0,&tolua_err) || - !tolua_isnumber(tolua_S,3,0,&tolua_err) || - !tolua_isnumber(tolua_S,4,0,&tolua_err) || - !tolua_isusertype(tolua_S,5,"cLuaChunk",0,&tolua_err) || - !tolua_isnoobj(tolua_S,6,&tolua_err) + !tolua_isusertype(tolua_S,2,"cPlayer",0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { Lua__cPlugin* self = (Lua__cPlugin*) tolua_tousertype(tolua_S,1,0); - cWorld* a_World = ((cWorld*) tolua_tousertype(tolua_S,2,0)); - int a_ChunkX = ((int) tolua_tonumber(tolua_S,3,0)); - int a_ChunkZ = ((int) tolua_tonumber(tolua_S,4,0)); - cLuaChunk* a_pLuaChunk = ((cLuaChunk*) tolua_tousertype(tolua_S,5,0)); + cPlayer* a_Player = ((cPlayer*) tolua_tousertype(tolua_S,2,0)); #ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPlugin__OnChunkGenerating'", NULL); + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPlugin__OnPlayerJoin'", NULL); #endif { - bool tolua_ret = (bool) self->cPlugin__OnChunkGenerating(a_World,a_ChunkX,a_ChunkZ,a_pLuaChunk); + bool tolua_ret = (bool) self->cPlugin__OnPlayerJoin(a_Player); tolua_pushboolean(tolua_S,(bool)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'cPlugin__OnChunkGenerating'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'cPlugin__OnPlayerJoin'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE -/* method: cPlugin__OnPreCrafting of class Lua__cPlugin */ -#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPlugin_cPlugin__OnPreCrafting00 -static int tolua_AllToLua_Lua__cPlugin_cPlugin__OnPreCrafting00(lua_State* tolua_S) +/* method: cPlugin__OnPlayerMove of class Lua__cPlugin */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPlugin_cPlugin__OnPlayerMove00 +static int tolua_AllToLua_Lua__cPlugin_cPlugin__OnPlayerMove00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"Lua__cPlugin",0,&tolua_err) || - !tolua_isusertype(tolua_S,2,"const cPlayer",0,&tolua_err) || - !tolua_isusertype(tolua_S,3,"const cCraftingGrid",0,&tolua_err) || - !tolua_isusertype(tolua_S,4,"cCraftingRecipe",0,&tolua_err) || - !tolua_isnoobj(tolua_S,5,&tolua_err) + !tolua_isusertype(tolua_S,2,"cPlayer",0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { Lua__cPlugin* self = (Lua__cPlugin*) tolua_tousertype(tolua_S,1,0); - const cPlayer* a_Player = ((const cPlayer*) tolua_tousertype(tolua_S,2,0)); - const cCraftingGrid* a_Grid = ((const cCraftingGrid*) tolua_tousertype(tolua_S,3,0)); - cCraftingRecipe* a_Recipe = ((cCraftingRecipe*) tolua_tousertype(tolua_S,4,0)); + cPlayer* a_Player = ((cPlayer*) tolua_tousertype(tolua_S,2,0)); #ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPlugin__OnPreCrafting'", NULL); + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPlugin__OnPlayerMove'", NULL); #endif { - bool tolua_ret = (bool) self->cPlugin__OnPreCrafting(a_Player,a_Grid,a_Recipe); - tolua_pushboolean(tolua_S,(bool)tolua_ret); + self->cPlugin__OnPlayerMove(a_Player); } } - return 1; + return 0; #ifndef TOLUA_RELEASE tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'cPlugin__OnPreCrafting'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'cPlugin__OnPlayerMove'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE -/* method: cPlugin__OnCraftingNoRecipe of class Lua__cPlugin */ -#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPlugin_cPlugin__OnCraftingNoRecipe00 -static int tolua_AllToLua_Lua__cPlugin_cPlugin__OnCraftingNoRecipe00(lua_State* tolua_S) +/* method: cPlugin__OnPlayerSpawn of class Lua__cPlugin */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPlugin_cPlugin__OnPlayerSpawn00 +static int tolua_AllToLua_Lua__cPlugin_cPlugin__OnPlayerSpawn00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"Lua__cPlugin",0,&tolua_err) || - !tolua_isusertype(tolua_S,2,"const cPlayer",0,&tolua_err) || - !tolua_isusertype(tolua_S,3,"const cCraftingGrid",0,&tolua_err) || - !tolua_isusertype(tolua_S,4,"cCraftingRecipe",0,&tolua_err) || - !tolua_isnoobj(tolua_S,5,&tolua_err) + !tolua_isusertype(tolua_S,2,"cPlayer",0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { Lua__cPlugin* self = (Lua__cPlugin*) tolua_tousertype(tolua_S,1,0); - const cPlayer* a_Player = ((const cPlayer*) tolua_tousertype(tolua_S,2,0)); - const cCraftingGrid* a_Grid = ((const cCraftingGrid*) tolua_tousertype(tolua_S,3,0)); - cCraftingRecipe* a_Recipe = ((cCraftingRecipe*) tolua_tousertype(tolua_S,4,0)); + cPlayer* a_Player = ((cPlayer*) tolua_tousertype(tolua_S,2,0)); #ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPlugin__OnCraftingNoRecipe'", NULL); + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPlugin__OnPlayerSpawn'", NULL); #endif { - bool tolua_ret = (bool) self->cPlugin__OnCraftingNoRecipe(a_Player,a_Grid,a_Recipe); - tolua_pushboolean(tolua_S,(bool)tolua_ret); + self->cPlugin__OnPlayerSpawn(a_Player); } } - return 1; + return 0; #ifndef TOLUA_RELEASE tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'cPlugin__OnCraftingNoRecipe'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'cPlugin__OnPlayerSpawn'.",&tolua_err); return 0; #endif } @@ -9599,85 +9642,82 @@ static int tolua_AllToLua_Lua__cPlugin_cPlugin__OnPostCrafting00(lua_State* tolu } #endif //#ifndef TOLUA_DISABLE -/* method: cPlugin__OnBlockToPickup of class Lua__cPlugin */ -#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPlugin_cPlugin__OnBlockToPickup00 -static int tolua_AllToLua_Lua__cPlugin_cPlugin__OnBlockToPickup00(lua_State* tolua_S) +/* method: cPlugin__OnPreCrafting of class Lua__cPlugin */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPlugin_cPlugin__OnPreCrafting00 +static int tolua_AllToLua_Lua__cPlugin_cPlugin__OnPreCrafting00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"Lua__cPlugin",0,&tolua_err) || - !tolua_isnumber(tolua_S,2,0,&tolua_err) || - !tolua_isnumber(tolua_S,3,0,&tolua_err) || - !tolua_isusertype(tolua_S,4,"const cPlayer",0,&tolua_err) || - (tolua_isvaluenil(tolua_S,5,&tolua_err) || !tolua_isusertype(tolua_S,5,"const cItem",0,&tolua_err)) || - (tolua_isvaluenil(tolua_S,6,&tolua_err) || !tolua_isusertype(tolua_S,6,"cItems",0,&tolua_err)) || - !tolua_isnoobj(tolua_S,7,&tolua_err) + !tolua_isusertype(tolua_S,2,"const cPlayer",0,&tolua_err) || + !tolua_isusertype(tolua_S,3,"const cCraftingGrid",0,&tolua_err) || + !tolua_isusertype(tolua_S,4,"cCraftingRecipe",0,&tolua_err) || + !tolua_isnoobj(tolua_S,5,&tolua_err) ) goto tolua_lerror; else #endif { Lua__cPlugin* self = (Lua__cPlugin*) tolua_tousertype(tolua_S,1,0); - unsigned char a_BlockType = ((unsigned char) tolua_tonumber(tolua_S,2,0)); - unsigned char a_BlockMeta = ((unsigned char) tolua_tonumber(tolua_S,3,0)); - const cPlayer* a_Player = ((const cPlayer*) tolua_tousertype(tolua_S,4,0)); - const cItem* a_EquippedItem = ((const cItem*) tolua_tousertype(tolua_S,5,0)); - cItems* a_Pickups = ((cItems*) tolua_tousertype(tolua_S,6,0)); + const cPlayer* a_Player = ((const cPlayer*) tolua_tousertype(tolua_S,2,0)); + const cCraftingGrid* a_Grid = ((const cCraftingGrid*) tolua_tousertype(tolua_S,3,0)); + cCraftingRecipe* a_Recipe = ((cCraftingRecipe*) tolua_tousertype(tolua_S,4,0)); #ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPlugin__OnBlockToPickup'", NULL); + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPlugin__OnPreCrafting'", NULL); #endif { - bool tolua_ret = (bool) self->cPlugin__OnBlockToPickup(a_BlockType,a_BlockMeta,a_Player,*a_EquippedItem,*a_Pickups); + bool tolua_ret = (bool) self->cPlugin__OnPreCrafting(a_Player,a_Grid,a_Recipe); tolua_pushboolean(tolua_S,(bool)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'cPlugin__OnBlockToPickup'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'cPlugin__OnPreCrafting'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE -/* method: cPlugin__OnWeatherChanged of class Lua__cPlugin */ -#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPlugin_cPlugin__OnWeatherChanged00 -static int tolua_AllToLua_Lua__cPlugin_cPlugin__OnWeatherChanged00(lua_State* tolua_S) +/* method: cPlugin__OnTakeDamage of class Lua__cPlugin */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPlugin_cPlugin__OnTakeDamage00 +static int tolua_AllToLua_Lua__cPlugin_cPlugin__OnTakeDamage00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"Lua__cPlugin",0,&tolua_err) || - !tolua_isusertype(tolua_S,2,"cWorld",0,&tolua_err) || - !tolua_isnoobj(tolua_S,3,&tolua_err) + !tolua_isusertype(tolua_S,2,"cPawn",0,&tolua_err) || + !tolua_isusertype(tolua_S,3,"TakeDamageInfo",0,&tolua_err) || + !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else #endif { Lua__cPlugin* self = (Lua__cPlugin*) tolua_tousertype(tolua_S,1,0); - cWorld* a_World = ((cWorld*) tolua_tousertype(tolua_S,2,0)); + cPawn* a_Pawn = ((cPawn*) tolua_tousertype(tolua_S,2,0)); + TakeDamageInfo* a_TakeDamageInfo = ((TakeDamageInfo*) tolua_tousertype(tolua_S,3,0)); #ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPlugin__OnWeatherChanged'", NULL); + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPlugin__OnTakeDamage'", NULL); #endif { - bool tolua_ret = (bool) self->cPlugin__OnWeatherChanged(a_World); - tolua_pushboolean(tolua_S,(bool)tolua_ret); + self->cPlugin__OnTakeDamage(a_Pawn,a_TakeDamageInfo); } } - return 1; + return 0; #ifndef TOLUA_RELEASE tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'cPlugin__OnWeatherChanged'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'cPlugin__OnTakeDamage'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE -/* method: cPlugin__OnUpdatingSign of class Lua__cPlugin */ -#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPlugin_cPlugin__OnUpdatingSign00 -static int tolua_AllToLua_Lua__cPlugin_cPlugin__OnUpdatingSign00(lua_State* tolua_S) +/* method: cPlugin__OnUpdatedSign of class Lua__cPlugin */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPlugin_cPlugin__OnUpdatedSign00 +static int tolua_AllToLua_Lua__cPlugin_cPlugin__OnUpdatedSign00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; @@ -9702,15 +9742,15 @@ static int tolua_AllToLua_Lua__cPlugin_cPlugin__OnUpdatingSign00(lua_State* tolu int a_BlockX = ((int) tolua_tonumber(tolua_S,3,0)); int a_BlockY = ((int) tolua_tonumber(tolua_S,4,0)); int a_BlockZ = ((int) tolua_tonumber(tolua_S,5,0)); - AString a_Line1 = ((AString) tolua_tocppstring(tolua_S,6,0)); - AString a_Line2 = ((AString) tolua_tocppstring(tolua_S,7,0)); - AString a_Line3 = ((AString) tolua_tocppstring(tolua_S,8,0)); - AString a_Line4 = ((AString) tolua_tocppstring(tolua_S,9,0)); + const AString a_Line1 = ((const AString) tolua_tocppstring(tolua_S,6,0)); + const AString a_Line2 = ((const AString) tolua_tocppstring(tolua_S,7,0)); + const AString a_Line3 = ((const AString) tolua_tocppstring(tolua_S,8,0)); + const AString a_Line4 = ((const AString) tolua_tocppstring(tolua_S,9,0)); #ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPlugin__OnUpdatingSign'", NULL); + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPlugin__OnUpdatedSign'", NULL); #endif { - bool tolua_ret = (bool) self->cPlugin__OnUpdatingSign(a_World,a_BlockX,a_BlockY,a_BlockZ,a_Line1,a_Line2,a_Line3,a_Line4); + bool tolua_ret = (bool) self->cPlugin__OnUpdatedSign(a_World,a_BlockX,a_BlockY,a_BlockZ,a_Line1,a_Line2,a_Line3,a_Line4); tolua_pushboolean(tolua_S,(bool)tolua_ret); tolua_pushcppstring(tolua_S,(const char*)a_Line1); tolua_pushcppstring(tolua_S,(const char*)a_Line2); @@ -9721,15 +9761,15 @@ static int tolua_AllToLua_Lua__cPlugin_cPlugin__OnUpdatingSign00(lua_State* tolu return 5; #ifndef TOLUA_RELEASE tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'cPlugin__OnUpdatingSign'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'cPlugin__OnUpdatedSign'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE -/* method: cPlugin__OnUpdatedSign of class Lua__cPlugin */ -#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPlugin_cPlugin__OnUpdatedSign00 -static int tolua_AllToLua_Lua__cPlugin_cPlugin__OnUpdatedSign00(lua_State* tolua_S) +/* method: cPlugin__OnUpdatingSign of class Lua__cPlugin */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPlugin_cPlugin__OnUpdatingSign00 +static int tolua_AllToLua_Lua__cPlugin_cPlugin__OnUpdatingSign00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; @@ -9754,15 +9794,15 @@ static int tolua_AllToLua_Lua__cPlugin_cPlugin__OnUpdatedSign00(lua_State* tolua int a_BlockX = ((int) tolua_tonumber(tolua_S,3,0)); int a_BlockY = ((int) tolua_tonumber(tolua_S,4,0)); int a_BlockZ = ((int) tolua_tonumber(tolua_S,5,0)); - const AString a_Line1 = ((const AString) tolua_tocppstring(tolua_S,6,0)); - const AString a_Line2 = ((const AString) tolua_tocppstring(tolua_S,7,0)); - const AString a_Line3 = ((const AString) tolua_tocppstring(tolua_S,8,0)); - const AString a_Line4 = ((const AString) tolua_tocppstring(tolua_S,9,0)); + AString a_Line1 = ((AString) tolua_tocppstring(tolua_S,6,0)); + AString a_Line2 = ((AString) tolua_tocppstring(tolua_S,7,0)); + AString a_Line3 = ((AString) tolua_tocppstring(tolua_S,8,0)); + AString a_Line4 = ((AString) tolua_tocppstring(tolua_S,9,0)); #ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPlugin__OnUpdatedSign'", NULL); + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPlugin__OnUpdatingSign'", NULL); #endif { - bool tolua_ret = (bool) self->cPlugin__OnUpdatedSign(a_World,a_BlockX,a_BlockY,a_BlockZ,a_Line1,a_Line2,a_Line3,a_Line4); + bool tolua_ret = (bool) self->cPlugin__OnUpdatingSign(a_World,a_BlockX,a_BlockY,a_BlockZ,a_Line1,a_Line2,a_Line3,a_Line4); tolua_pushboolean(tolua_S,(bool)tolua_ret); tolua_pushcppstring(tolua_S,(const char*)a_Line1); tolua_pushcppstring(tolua_S,(const char*)a_Line2); @@ -9773,7 +9813,41 @@ static int tolua_AllToLua_Lua__cPlugin_cPlugin__OnUpdatedSign00(lua_State* tolua return 5; #ifndef TOLUA_RELEASE tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'cPlugin__OnUpdatedSign'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'cPlugin__OnUpdatingSign'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: cPlugin__OnWeatherChanged of class Lua__cPlugin */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPlugin_cPlugin__OnWeatherChanged00 +static int tolua_AllToLua_Lua__cPlugin_cPlugin__OnWeatherChanged00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"Lua__cPlugin",0,&tolua_err) || + !tolua_isusertype(tolua_S,2,"cWorld",0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + Lua__cPlugin* self = (Lua__cPlugin*) tolua_tousertype(tolua_S,1,0); + cWorld* a_World = ((cWorld*) tolua_tousertype(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPlugin__OnWeatherChanged'", NULL); +#endif + { + bool tolua_ret = (bool) self->cPlugin__OnWeatherChanged(a_World); + tolua_pushboolean(tolua_S,(bool)tolua_ret); + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'cPlugin__OnWeatherChanged'.",&tolua_err); return 0; #endif } @@ -10033,53 +10107,53 @@ public: return ( void ) cPlugin_NewLua:: Tick(a_Dt); }; }; - bool OnCollectItem( cPickup* a_Pickup, cPlayer* a_Player) { - if (push_method("OnCollectItem", tolua_AllToLua_cPlugin_OnCollectItem00)) { - tolua_pushusertype(lua_state, (void*)a_Pickup, "cPickup"); - tolua_pushusertype(lua_state, (void*)a_Player, "cPlayer"); - ToluaBase::dbcall(lua_state, 3, 1); - bool tolua_ret = ( bool )tolua_toboolean(lua_state, -1, 0); - lua_pop(lua_state, 1); - return tolua_ret; - } else { - return ( bool ) cPlugin_NewLua:: OnCollectItem(a_Pickup,a_Player); - }; - }; - bool OnDisconnect( const AString& a_Reason, cPlayer* a_Player) { - if (push_method("OnDisconnect", tolua_AllToLua_cPlugin_OnDisconnect00)) { - tolua_pushcppstring(lua_state, (const char*)a_Reason); + bool OnBlockDig( cPlayer* a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status, unsigned char a_OldBlock, unsigned char a_OldMeta) { + if (push_method("OnBlockDig", tolua_AllToLua_cPlugin_OnBlockDig00)) { tolua_pushusertype(lua_state, (void*)a_Player, "cPlayer"); - ToluaBase::dbcall(lua_state, 3, 1); + tolua_pushnumber(lua_state, (lua_Number)a_BlockX); + tolua_pushnumber(lua_state, (lua_Number)a_BlockY); + tolua_pushnumber(lua_state, (lua_Number)a_BlockZ); + tolua_pushnumber(lua_state, (lua_Number)a_BlockFace); + tolua_pushnumber(lua_state, (lua_Number)a_Status); + tolua_pushnumber(lua_state, (lua_Number)a_OldBlock); + tolua_pushnumber(lua_state, (lua_Number)a_OldMeta); + ToluaBase::dbcall(lua_state, 9, 1); bool tolua_ret = ( bool )tolua_toboolean(lua_state, -1, 0); lua_pop(lua_state, 1); return tolua_ret; } else { - return ( bool ) cPlugin_NewLua:: OnDisconnect(a_Reason,a_Player); + return ( bool ) cPlugin_NewLua:: OnBlockDig(a_Player,a_BlockX,a_BlockY,a_BlockZ,a_BlockFace,a_Status,a_OldBlock,a_OldMeta); }; }; - bool OnBlockPlace( cPacket_BlockPlace* a_PacketData, cPlayer* a_Player) { + bool OnBlockPlace( cPlayer* a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, const cItem& a_HeldItem) { if (push_method("OnBlockPlace", tolua_AllToLua_cPlugin_OnBlockPlace00)) { - tolua_pushusertype(lua_state, (void*)a_PacketData, "cPacket_BlockPlace"); tolua_pushusertype(lua_state, (void*)a_Player, "cPlayer"); - ToluaBase::dbcall(lua_state, 3, 1); + tolua_pushnumber(lua_state, (lua_Number)a_BlockX); + tolua_pushnumber(lua_state, (lua_Number)a_BlockY); + tolua_pushnumber(lua_state, (lua_Number)a_BlockZ); + tolua_pushnumber(lua_state, (lua_Number)a_BlockFace); + tolua_pushusertype(lua_state, (void*)&a_HeldItem, "const cItem"); + ToluaBase::dbcall(lua_state, 7, 1); bool tolua_ret = ( bool )tolua_toboolean(lua_state, -1, 0); lua_pop(lua_state, 1); return tolua_ret; } else { - return ( bool ) cPlugin_NewLua:: OnBlockPlace(a_PacketData,a_Player); + return ( bool ) cPlugin_NewLua:: OnBlockPlace(a_Player,a_BlockX,a_BlockY,a_BlockZ,a_BlockFace,a_HeldItem); }; }; - bool OnBlockDig( cPacket_BlockDig* a_PacketData, cPlayer* a_Player, cItem* a_PickupItem) { - if (push_method("OnBlockDig", tolua_AllToLua_cPlugin_OnBlockDig00)) { - tolua_pushusertype(lua_state, (void*)a_PacketData, "cPacket_BlockDig"); - tolua_pushusertype(lua_state, (void*)a_Player, "cPlayer"); - tolua_pushusertype(lua_state, (void*)a_PickupItem, "cItem"); - ToluaBase::dbcall(lua_state, 4, 1); + bool OnBlockToPickup( unsigned char a_BlockType, unsigned char a_BlockMeta, const cPlayer* a_Player, const cItem& a_EquippedItem, cItems& a_Pickups) { + if (push_method("OnBlockToPickup", tolua_AllToLua_cPlugin_OnBlockToPickup00)) { + tolua_pushnumber(lua_state, (lua_Number)a_BlockType); + tolua_pushnumber(lua_state, (lua_Number)a_BlockMeta); + tolua_pushusertype(lua_state, (void*)a_Player, "const cPlayer"); + tolua_pushusertype(lua_state, (void*)&a_EquippedItem, "const cItem"); + tolua_pushusertype(lua_state, (void*)&a_Pickups, "cItems"); + ToluaBase::dbcall(lua_state, 6, 1); bool tolua_ret = ( bool )tolua_toboolean(lua_state, -1, 0); lua_pop(lua_state, 1); return tolua_ret; } else { - return ( bool ) cPlugin_NewLua:: OnBlockDig(a_PacketData,a_Player,a_PickupItem); + return ( bool ) cPlugin_NewLua:: OnBlockToPickup(a_BlockType,a_BlockMeta,a_Player,a_EquippedItem,a_Pickups); }; }; bool OnChat( const char* a_Chat, cPlayer* a_Player) { @@ -10094,51 +10168,65 @@ public: return ( bool ) cPlugin_NewLua:: OnChat(a_Chat,a_Player); }; }; - bool OnLogin( cPacket_Login* a_PacketData) { - if (push_method("OnLogin", tolua_AllToLua_cPlugin_OnLogin00)) { - tolua_pushusertype(lua_state, (void*)a_PacketData, "cPacket_Login"); - ToluaBase::dbcall(lua_state, 2, 1); + void OnChunkGenerated( cWorld* a_World, int a_ChunkX, int a_ChunkZ) { + if (push_method("OnChunkGenerated", tolua_AllToLua_cPlugin_OnChunkGenerated00)) { + tolua_pushusertype(lua_state, (void*)a_World, "cWorld"); + tolua_pushnumber(lua_state, (lua_Number)a_ChunkX); + tolua_pushnumber(lua_state, (lua_Number)a_ChunkZ); + ToluaBase::dbcall(lua_state, 4, 0); + } else { + return ( void ) cPlugin_NewLua:: OnChunkGenerated(a_World,a_ChunkX,a_ChunkZ); + }; + }; + bool OnChunkGenerating( cWorld* a_World, int a_ChunkX, int a_ChunkZ, cLuaChunk* a_pLuaChunk) { + if (push_method("OnChunkGenerating", tolua_AllToLua_cPlugin_OnChunkGenerating00)) { + tolua_pushusertype(lua_state, (void*)a_World, "cWorld"); + tolua_pushnumber(lua_state, (lua_Number)a_ChunkX); + tolua_pushnumber(lua_state, (lua_Number)a_ChunkZ); + tolua_pushusertype(lua_state, (void*)a_pLuaChunk, "cLuaChunk"); + ToluaBase::dbcall(lua_state, 5, 1); bool tolua_ret = ( bool )tolua_toboolean(lua_state, -1, 0); lua_pop(lua_state, 1); return tolua_ret; } else { - return ( bool ) cPlugin_NewLua:: OnLogin(a_PacketData); + return ( bool ) cPlugin_NewLua:: OnChunkGenerating(a_World,a_ChunkX,a_ChunkZ,a_pLuaChunk); }; }; - void OnPlayerSpawn( cPlayer* a_Player) { - if (push_method("OnPlayerSpawn", tolua_AllToLua_cPlugin_OnPlayerSpawn00)) { + bool OnCollectItem( cPickup* a_Pickup, cPlayer* a_Player) { + if (push_method("OnCollectItem", tolua_AllToLua_cPlugin_OnCollectItem00)) { + tolua_pushusertype(lua_state, (void*)a_Pickup, "cPickup"); tolua_pushusertype(lua_state, (void*)a_Player, "cPlayer"); - ToluaBase::dbcall(lua_state, 2, 0); + ToluaBase::dbcall(lua_state, 3, 1); + bool tolua_ret = ( bool )tolua_toboolean(lua_state, -1, 0); + lua_pop(lua_state, 1); + return tolua_ret; } else { - return ( void ) cPlugin_NewLua:: OnPlayerSpawn(a_Player); + return ( bool ) cPlugin_NewLua:: OnCollectItem(a_Pickup,a_Player); }; }; - bool OnPlayerJoin( cPlayer* a_Player) { - if (push_method("OnPlayerJoin", tolua_AllToLua_cPlugin_OnPlayerJoin00)) { - tolua_pushusertype(lua_state, (void*)a_Player, "cPlayer"); - ToluaBase::dbcall(lua_state, 2, 1); + bool OnCraftingNoRecipe( const cPlayer* a_Player, const cCraftingGrid* a_Grid, cCraftingRecipe* a_Recipe) { + if (push_method("OnCraftingNoRecipe", tolua_AllToLua_cPlugin_OnCraftingNoRecipe00)) { + tolua_pushusertype(lua_state, (void*)a_Player, "const cPlayer"); + tolua_pushusertype(lua_state, (void*)a_Grid, "const cCraftingGrid"); + tolua_pushusertype(lua_state, (void*)a_Recipe, "cCraftingRecipe"); + ToluaBase::dbcall(lua_state, 4, 1); bool tolua_ret = ( bool )tolua_toboolean(lua_state, -1, 0); lua_pop(lua_state, 1); return tolua_ret; } else { - return ( bool ) cPlugin_NewLua:: OnPlayerJoin(a_Player); + return ( bool ) cPlugin_NewLua:: OnCraftingNoRecipe(a_Player,a_Grid,a_Recipe); }; }; - void OnPlayerMove( cPlayer* a_Player) { - if (push_method("OnPlayerMove", tolua_AllToLua_cPlugin_OnPlayerMove00)) { + bool OnDisconnect( const AString& a_Reason, cPlayer* a_Player) { + if (push_method("OnDisconnect", tolua_AllToLua_cPlugin_OnDisconnect00)) { + tolua_pushcppstring(lua_state, (const char*)a_Reason); tolua_pushusertype(lua_state, (void*)a_Player, "cPlayer"); - ToluaBase::dbcall(lua_state, 2, 0); - } else { - return ( void ) cPlugin_NewLua:: OnPlayerMove(a_Player); - }; - }; - void OnTakeDamage( cPawn* a_Pawn, TakeDamageInfo* a_TakeDamageInfo) { - if (push_method("OnTakeDamage", tolua_AllToLua_cPlugin_OnTakeDamage00)) { - tolua_pushusertype(lua_state, (void*)a_Pawn, "cPawn"); - tolua_pushusertype(lua_state, (void*)a_TakeDamageInfo, "TakeDamageInfo"); - ToluaBase::dbcall(lua_state, 3, 0); + ToluaBase::dbcall(lua_state, 3, 1); + bool tolua_ret = ( bool )tolua_toboolean(lua_state, -1, 0); + lua_pop(lua_state, 1); + return tolua_ret; } else { - return ( void ) cPlugin_NewLua:: OnTakeDamage(a_Pawn,a_TakeDamageInfo); + return ( bool ) cPlugin_NewLua:: OnDisconnect(a_Reason,a_Player); }; }; bool OnKilled( cPawn* a_Killed, cEntity* a_Killer) { @@ -10153,54 +10241,44 @@ public: return ( bool ) cPlugin_NewLua:: OnKilled(a_Killed,a_Killer); }; }; - void OnChunkGenerated( cWorld* a_World, int a_ChunkX, int a_ChunkZ) { - if (push_method("OnChunkGenerated", tolua_AllToLua_cPlugin_OnChunkGenerated00)) { - tolua_pushusertype(lua_state, (void*)a_World, "cWorld"); - tolua_pushnumber(lua_state, (lua_Number)a_ChunkX); - tolua_pushnumber(lua_state, (lua_Number)a_ChunkZ); - ToluaBase::dbcall(lua_state, 4, 0); - } else { - return ( void ) cPlugin_NewLua:: OnChunkGenerated(a_World,a_ChunkX,a_ChunkZ); - }; - }; - bool OnChunkGenerating( cWorld* a_World, int a_ChunkX, int a_ChunkZ, cLuaChunk* a_pLuaChunk) { - if (push_method("OnChunkGenerating", tolua_AllToLua_cPlugin_OnChunkGenerating00)) { - tolua_pushusertype(lua_state, (void*)a_World, "cWorld"); - tolua_pushnumber(lua_state, (lua_Number)a_ChunkX); - tolua_pushnumber(lua_state, (lua_Number)a_ChunkZ); - tolua_pushusertype(lua_state, (void*)a_pLuaChunk, "cLuaChunk"); - ToluaBase::dbcall(lua_state, 5, 1); + bool OnLogin( cClientHandle* a_Client, int a_ProtocolVersion, const AString& a_Username) { + if (push_method("OnLogin", tolua_AllToLua_cPlugin_OnLogin00)) { + tolua_pushusertype(lua_state, (void*)a_Client, "cClientHandle"); + tolua_pushnumber(lua_state, (lua_Number)a_ProtocolVersion); + tolua_pushcppstring(lua_state, (const char*)a_Username); + ToluaBase::dbcall(lua_state, 4, 1); bool tolua_ret = ( bool )tolua_toboolean(lua_state, -1, 0); lua_pop(lua_state, 1); return tolua_ret; } else { - return ( bool ) cPlugin_NewLua:: OnChunkGenerating(a_World,a_ChunkX,a_ChunkZ,a_pLuaChunk); + return ( bool ) cPlugin_NewLua:: OnLogin(a_Client,a_ProtocolVersion,a_Username); }; }; - bool OnPreCrafting( const cPlayer* a_Player, const cCraftingGrid* a_Grid, cCraftingRecipe* a_Recipe) { - if (push_method("OnPreCrafting", tolua_AllToLua_cPlugin_OnPreCrafting00)) { - tolua_pushusertype(lua_state, (void*)a_Player, "const cPlayer"); - tolua_pushusertype(lua_state, (void*)a_Grid, "const cCraftingGrid"); - tolua_pushusertype(lua_state, (void*)a_Recipe, "cCraftingRecipe"); - ToluaBase::dbcall(lua_state, 4, 1); + bool OnPlayerJoin( cPlayer* a_Player) { + if (push_method("OnPlayerJoin", tolua_AllToLua_cPlugin_OnPlayerJoin00)) { + tolua_pushusertype(lua_state, (void*)a_Player, "cPlayer"); + ToluaBase::dbcall(lua_state, 2, 1); bool tolua_ret = ( bool )tolua_toboolean(lua_state, -1, 0); lua_pop(lua_state, 1); return tolua_ret; } else { - return ( bool ) cPlugin_NewLua:: OnPreCrafting(a_Player,a_Grid,a_Recipe); + return ( bool ) cPlugin_NewLua:: OnPlayerJoin(a_Player); }; }; - bool OnCraftingNoRecipe( const cPlayer* a_Player, const cCraftingGrid* a_Grid, cCraftingRecipe* a_Recipe) { - if (push_method("OnCraftingNoRecipe", tolua_AllToLua_cPlugin_OnCraftingNoRecipe00)) { - tolua_pushusertype(lua_state, (void*)a_Player, "const cPlayer"); - tolua_pushusertype(lua_state, (void*)a_Grid, "const cCraftingGrid"); - tolua_pushusertype(lua_state, (void*)a_Recipe, "cCraftingRecipe"); - ToluaBase::dbcall(lua_state, 4, 1); - bool tolua_ret = ( bool )tolua_toboolean(lua_state, -1, 0); - lua_pop(lua_state, 1); - return tolua_ret; + void OnPlayerMove( cPlayer* a_Player) { + if (push_method("OnPlayerMove", tolua_AllToLua_cPlugin_OnPlayerMove00)) { + tolua_pushusertype(lua_state, (void*)a_Player, "cPlayer"); + ToluaBase::dbcall(lua_state, 2, 0); } else { - return ( bool ) cPlugin_NewLua:: OnCraftingNoRecipe(a_Player,a_Grid,a_Recipe); + return ( void ) cPlugin_NewLua:: OnPlayerMove(a_Player); + }; + }; + void OnPlayerSpawn( cPlayer* a_Player) { + if (push_method("OnPlayerSpawn", tolua_AllToLua_cPlugin_OnPlayerSpawn00)) { + tolua_pushusertype(lua_state, (void*)a_Player, "cPlayer"); + ToluaBase::dbcall(lua_state, 2, 0); + } else { + return ( void ) cPlugin_NewLua:: OnPlayerSpawn(a_Player); }; }; bool OnPostCrafting( const cPlayer* a_Player, const cCraftingGrid* a_Grid, cCraftingRecipe* a_Recipe) { @@ -10216,34 +10294,30 @@ public: return ( bool ) cPlugin_NewLua:: OnPostCrafting(a_Player,a_Grid,a_Recipe); }; }; - bool OnBlockToPickup( unsigned char a_BlockType, unsigned char a_BlockMeta, const cPlayer* a_Player, const cItem& a_EquippedItem, cItems& a_Pickups) { - if (push_method("OnBlockToPickup", tolua_AllToLua_cPlugin_OnBlockToPickup00)) { - tolua_pushnumber(lua_state, (lua_Number)a_BlockType); - tolua_pushnumber(lua_state, (lua_Number)a_BlockMeta); + bool OnPreCrafting( const cPlayer* a_Player, const cCraftingGrid* a_Grid, cCraftingRecipe* a_Recipe) { + if (push_method("OnPreCrafting", tolua_AllToLua_cPlugin_OnPreCrafting00)) { tolua_pushusertype(lua_state, (void*)a_Player, "const cPlayer"); - tolua_pushusertype(lua_state, (void*)&a_EquippedItem, "const cItem"); - tolua_pushusertype(lua_state, (void*)&a_Pickups, "cItems"); - ToluaBase::dbcall(lua_state, 6, 1); + tolua_pushusertype(lua_state, (void*)a_Grid, "const cCraftingGrid"); + tolua_pushusertype(lua_state, (void*)a_Recipe, "cCraftingRecipe"); + ToluaBase::dbcall(lua_state, 4, 1); bool tolua_ret = ( bool )tolua_toboolean(lua_state, -1, 0); lua_pop(lua_state, 1); return tolua_ret; } else { - return ( bool ) cPlugin_NewLua:: OnBlockToPickup(a_BlockType,a_BlockMeta,a_Player,a_EquippedItem,a_Pickups); + return ( bool ) cPlugin_NewLua:: OnPreCrafting(a_Player,a_Grid,a_Recipe); }; }; - bool OnWeatherChanged( cWorld* a_World) { - if (push_method("OnWeatherChanged", tolua_AllToLua_cPlugin_OnWeatherChanged00)) { - tolua_pushusertype(lua_state, (void*)a_World, "cWorld"); - ToluaBase::dbcall(lua_state, 2, 1); - bool tolua_ret = ( bool )tolua_toboolean(lua_state, -1, 0); - lua_pop(lua_state, 1); - return tolua_ret; + void OnTakeDamage( cPawn* a_Pawn, TakeDamageInfo* a_TakeDamageInfo) { + if (push_method("OnTakeDamage", tolua_AllToLua_cPlugin_OnTakeDamage00)) { + tolua_pushusertype(lua_state, (void*)a_Pawn, "cPawn"); + tolua_pushusertype(lua_state, (void*)a_TakeDamageInfo, "TakeDamageInfo"); + ToluaBase::dbcall(lua_state, 3, 0); } else { - return ( bool ) cPlugin_NewLua:: OnWeatherChanged(a_World); + return ( void ) cPlugin_NewLua:: OnTakeDamage(a_Pawn,a_TakeDamageInfo); }; }; - bool OnUpdatingSign( cWorld* a_World, int a_BlockX, int a_BlockY, int a_BlockZ, AString& a_Line1, AString& a_Line2, AString& a_Line3, AString& a_Line4) { - if (push_method("OnUpdatingSign", tolua_AllToLua_cPlugin_OnUpdatingSign00)) { + bool OnUpdatedSign( cWorld* a_World, int a_BlockX, int a_BlockY, int a_BlockZ, const AString& a_Line1, const AString& a_Line2, const AString& a_Line3, const AString& a_Line4) { + if (push_method("OnUpdatedSign", tolua_AllToLua_cPlugin_OnUpdatedSign00)) { tolua_pushusertype(lua_state, (void*)a_World, "cWorld"); tolua_pushnumber(lua_state, (lua_Number)a_BlockX); tolua_pushnumber(lua_state, (lua_Number)a_BlockY); @@ -10257,11 +10331,11 @@ public: lua_pop(lua_state, 1); return tolua_ret; } else { - return ( bool ) cPlugin_NewLua:: OnUpdatingSign(a_World,a_BlockX,a_BlockY,a_BlockZ,a_Line1,a_Line2,a_Line3,a_Line4); + return ( bool ) cPlugin_NewLua:: OnUpdatedSign(a_World,a_BlockX,a_BlockY,a_BlockZ,a_Line1,a_Line2,a_Line3,a_Line4); }; }; - bool OnUpdatedSign( cWorld* a_World, int a_BlockX, int a_BlockY, int a_BlockZ, const AString& a_Line1, const AString& a_Line2, const AString& a_Line3, const AString& a_Line4) { - if (push_method("OnUpdatedSign", tolua_AllToLua_cPlugin_OnUpdatedSign00)) { + bool OnUpdatingSign( cWorld* a_World, int a_BlockX, int a_BlockY, int a_BlockZ, AString& a_Line1, AString& a_Line2, AString& a_Line3, AString& a_Line4) { + if (push_method("OnUpdatingSign", tolua_AllToLua_cPlugin_OnUpdatingSign00)) { tolua_pushusertype(lua_state, (void*)a_World, "cWorld"); tolua_pushnumber(lua_state, (lua_Number)a_BlockX); tolua_pushnumber(lua_state, (lua_Number)a_BlockY); @@ -10275,7 +10349,18 @@ public: lua_pop(lua_state, 1); return tolua_ret; } else { - return ( bool ) cPlugin_NewLua:: OnUpdatedSign(a_World,a_BlockX,a_BlockY,a_BlockZ,a_Line1,a_Line2,a_Line3,a_Line4); + return ( bool ) cPlugin_NewLua:: OnUpdatingSign(a_World,a_BlockX,a_BlockY,a_BlockZ,a_Line1,a_Line2,a_Line3,a_Line4); + }; + }; + bool OnWeatherChanged( cWorld* a_World) { + if (push_method("OnWeatherChanged", tolua_AllToLua_cPlugin_OnWeatherChanged00)) { + tolua_pushusertype(lua_state, (void*)a_World, "cWorld"); + ToluaBase::dbcall(lua_state, 2, 1); + bool tolua_ret = ( bool )tolua_toboolean(lua_state, -1, 0); + lua_pop(lua_state, 1); + return tolua_ret; + } else { + return ( bool ) cPlugin_NewLua:: OnWeatherChanged(a_World); }; }; @@ -10288,65 +10373,65 @@ public: void cPlugin_NewLua__Tick( float a_Dt) { return ( void )cPlugin_NewLua::Tick(a_Dt); }; - bool cPlugin_NewLua__OnCollectItem( cPickup* a_Pickup, cPlayer* a_Player) { - return ( bool )cPlugin_NewLua::OnCollectItem(a_Pickup,a_Player); + bool cPlugin_NewLua__OnBlockDig( cPlayer* a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status, unsigned char a_OldBlock, unsigned char a_OldMeta) { + return ( bool )cPlugin_NewLua::OnBlockDig(a_Player,a_BlockX,a_BlockY,a_BlockZ,a_BlockFace,a_Status,a_OldBlock,a_OldMeta); }; - bool cPlugin_NewLua__OnDisconnect( const AString& a_Reason, cPlayer* a_Player) { - return ( bool )cPlugin_NewLua::OnDisconnect(a_Reason,a_Player); - }; - bool cPlugin_NewLua__OnBlockPlace( cPacket_BlockPlace* a_PacketData, cPlayer* a_Player) { - return ( bool )cPlugin_NewLua::OnBlockPlace(a_PacketData,a_Player); + bool cPlugin_NewLua__OnBlockPlace( cPlayer* a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, const cItem& a_HeldItem) { + return ( bool )cPlugin_NewLua::OnBlockPlace(a_Player,a_BlockX,a_BlockY,a_BlockZ,a_BlockFace,a_HeldItem); }; - bool cPlugin_NewLua__OnBlockDig( cPacket_BlockDig* a_PacketData, cPlayer* a_Player, cItem* a_PickupItem) { - return ( bool )cPlugin_NewLua::OnBlockDig(a_PacketData,a_Player,a_PickupItem); + bool cPlugin_NewLua__OnBlockToPickup( unsigned char a_BlockType, unsigned char a_BlockMeta, const cPlayer* a_Player, const cItem& a_EquippedItem, cItems& a_Pickups) { + return ( bool )cPlugin_NewLua::OnBlockToPickup(a_BlockType,a_BlockMeta,a_Player,a_EquippedItem,a_Pickups); }; bool cPlugin_NewLua__OnChat( const char* a_Chat, cPlayer* a_Player) { return ( bool )cPlugin_NewLua::OnChat(a_Chat,a_Player); }; - bool cPlugin_NewLua__OnLogin( cPacket_Login* a_PacketData) { - return ( bool )cPlugin_NewLua::OnLogin(a_PacketData); + void cPlugin_NewLua__OnChunkGenerated( cWorld* a_World, int a_ChunkX, int a_ChunkZ) { + return ( void )cPlugin_NewLua::OnChunkGenerated(a_World,a_ChunkX,a_ChunkZ); }; - void cPlugin_NewLua__OnPlayerSpawn( cPlayer* a_Player) { - return ( void )cPlugin_NewLua::OnPlayerSpawn(a_Player); + bool cPlugin_NewLua__OnChunkGenerating( cWorld* a_World, int a_ChunkX, int a_ChunkZ, cLuaChunk* a_pLuaChunk) { + return ( bool )cPlugin_NewLua::OnChunkGenerating(a_World,a_ChunkX,a_ChunkZ,a_pLuaChunk); }; - bool cPlugin_NewLua__OnPlayerJoin( cPlayer* a_Player) { - return ( bool )cPlugin_NewLua::OnPlayerJoin(a_Player); + bool cPlugin_NewLua__OnCollectItem( cPickup* a_Pickup, cPlayer* a_Player) { + return ( bool )cPlugin_NewLua::OnCollectItem(a_Pickup,a_Player); }; - void cPlugin_NewLua__OnPlayerMove( cPlayer* a_Player) { - return ( void )cPlugin_NewLua::OnPlayerMove(a_Player); + bool cPlugin_NewLua__OnCraftingNoRecipe( const cPlayer* a_Player, const cCraftingGrid* a_Grid, cCraftingRecipe* a_Recipe) { + return ( bool )cPlugin_NewLua::OnCraftingNoRecipe(a_Player,a_Grid,a_Recipe); }; - void cPlugin_NewLua__OnTakeDamage( cPawn* a_Pawn, TakeDamageInfo* a_TakeDamageInfo) { - return ( void )cPlugin_NewLua::OnTakeDamage(a_Pawn,a_TakeDamageInfo); + bool cPlugin_NewLua__OnDisconnect( const AString& a_Reason, cPlayer* a_Player) { + return ( bool )cPlugin_NewLua::OnDisconnect(a_Reason,a_Player); }; bool cPlugin_NewLua__OnKilled( cPawn* a_Killed, cEntity* a_Killer) { return ( bool )cPlugin_NewLua::OnKilled(a_Killed,a_Killer); }; - void cPlugin_NewLua__OnChunkGenerated( cWorld* a_World, int a_ChunkX, int a_ChunkZ) { - return ( void )cPlugin_NewLua::OnChunkGenerated(a_World,a_ChunkX,a_ChunkZ); + bool cPlugin_NewLua__OnLogin( cClientHandle* a_Client, int a_ProtocolVersion, const AString& a_Username) { + return ( bool )cPlugin_NewLua::OnLogin(a_Client,a_ProtocolVersion,a_Username); }; - bool cPlugin_NewLua__OnChunkGenerating( cWorld* a_World, int a_ChunkX, int a_ChunkZ, cLuaChunk* a_pLuaChunk) { - return ( bool )cPlugin_NewLua::OnChunkGenerating(a_World,a_ChunkX,a_ChunkZ,a_pLuaChunk); + bool cPlugin_NewLua__OnPlayerJoin( cPlayer* a_Player) { + return ( bool )cPlugin_NewLua::OnPlayerJoin(a_Player); }; - bool cPlugin_NewLua__OnPreCrafting( const cPlayer* a_Player, const cCraftingGrid* a_Grid, cCraftingRecipe* a_Recipe) { - return ( bool )cPlugin_NewLua::OnPreCrafting(a_Player,a_Grid,a_Recipe); + void cPlugin_NewLua__OnPlayerMove( cPlayer* a_Player) { + return ( void )cPlugin_NewLua::OnPlayerMove(a_Player); }; - bool cPlugin_NewLua__OnCraftingNoRecipe( const cPlayer* a_Player, const cCraftingGrid* a_Grid, cCraftingRecipe* a_Recipe) { - return ( bool )cPlugin_NewLua::OnCraftingNoRecipe(a_Player,a_Grid,a_Recipe); + void cPlugin_NewLua__OnPlayerSpawn( cPlayer* a_Player) { + return ( void )cPlugin_NewLua::OnPlayerSpawn(a_Player); }; bool cPlugin_NewLua__OnPostCrafting( const cPlayer* a_Player, const cCraftingGrid* a_Grid, cCraftingRecipe* a_Recipe) { return ( bool )cPlugin_NewLua::OnPostCrafting(a_Player,a_Grid,a_Recipe); }; - bool cPlugin_NewLua__OnBlockToPickup( unsigned char a_BlockType, unsigned char a_BlockMeta, const cPlayer* a_Player, const cItem& a_EquippedItem, cItems& a_Pickups) { - return ( bool )cPlugin_NewLua::OnBlockToPickup(a_BlockType,a_BlockMeta,a_Player,a_EquippedItem,a_Pickups); + bool cPlugin_NewLua__OnPreCrafting( const cPlayer* a_Player, const cCraftingGrid* a_Grid, cCraftingRecipe* a_Recipe) { + return ( bool )cPlugin_NewLua::OnPreCrafting(a_Player,a_Grid,a_Recipe); }; - bool cPlugin_NewLua__OnWeatherChanged( cWorld* a_World) { - return ( bool )cPlugin_NewLua::OnWeatherChanged(a_World); + void cPlugin_NewLua__OnTakeDamage( cPawn* a_Pawn, TakeDamageInfo* a_TakeDamageInfo) { + return ( void )cPlugin_NewLua::OnTakeDamage(a_Pawn,a_TakeDamageInfo); + }; + bool cPlugin_NewLua__OnUpdatedSign( cWorld* a_World, int a_BlockX, int a_BlockY, int a_BlockZ, const AString& a_Line1, const AString& a_Line2, const AString& a_Line3, const AString& a_Line4) { + return ( bool )cPlugin_NewLua::OnUpdatedSign(a_World,a_BlockX,a_BlockY,a_BlockZ,a_Line1,a_Line2,a_Line3,a_Line4); }; bool cPlugin_NewLua__OnUpdatingSign( cWorld* a_World, int a_BlockX, int a_BlockY, int a_BlockZ, AString& a_Line1, AString& a_Line2, AString& a_Line3, AString& a_Line4) { return ( bool )cPlugin_NewLua::OnUpdatingSign(a_World,a_BlockX,a_BlockY,a_BlockZ,a_Line1,a_Line2,a_Line3,a_Line4); }; - bool cPlugin_NewLua__OnUpdatedSign( cWorld* a_World, int a_BlockX, int a_BlockY, int a_BlockZ, const AString& a_Line1, const AString& a_Line2, const AString& a_Line3, const AString& a_Line4) { - return ( bool )cPlugin_NewLua::OnUpdatedSign(a_World,a_BlockX,a_BlockY,a_BlockZ,a_Line1,a_Line2,a_Line3,a_Line4); + bool cPlugin_NewLua__OnWeatherChanged( cWorld* a_World) { + return ( bool )cPlugin_NewLua::OnWeatherChanged(a_World); }; }; @@ -12727,7 +12812,7 @@ static int tolua_AllToLua_cItem_Equals00(lua_State* tolua_S) tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"const cItem",0,&tolua_err) || - (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"cItem",0,&tolua_err)) || + (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const cItem",0,&tolua_err)) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; @@ -12735,7 +12820,7 @@ static int tolua_AllToLua_cItem_Equals00(lua_State* tolua_S) #endif { const cItem* self = (const cItem*) tolua_tousertype(tolua_S,1,0); - cItem* a_Item = ((cItem*) tolua_tousertype(tolua_S,2,0)); + const cItem* a_Item = ((const cItem*) tolua_tousertype(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Equals'", NULL); #endif @@ -12753,6 +12838,74 @@ static int tolua_AllToLua_cItem_Equals00(lua_State* tolua_S) } #endif //#ifndef TOLUA_DISABLE +/* method: IsEqual of class cItem */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_cItem_IsEqual00 +static int tolua_AllToLua_cItem_IsEqual00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const cItem",0,&tolua_err) || + (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const cItem",0,&tolua_err)) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const cItem* self = (const cItem*) tolua_tousertype(tolua_S,1,0); + const cItem* a_Item = ((const cItem*) tolua_tousertype(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'IsEqual'", NULL); +#endif + { + bool tolua_ret = (bool) self->IsEqual(*a_Item); + tolua_pushboolean(tolua_S,(bool)tolua_ret); + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'IsEqual'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: IsSameType of class cItem */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_cItem_IsSameType00 +static int tolua_AllToLua_cItem_IsSameType00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const cItem",0,&tolua_err) || + (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const cItem",0,&tolua_err)) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const cItem* self = (const cItem*) tolua_tousertype(tolua_S,1,0); + const cItem* a_Item = ((const cItem*) tolua_tousertype(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'IsSameType'", NULL); +#endif + { + bool tolua_ret = (bool) self->IsSameType(*a_Item); + tolua_pushboolean(tolua_S,(bool)tolua_ret); + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'IsSameType'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + /* method: GetMaxDuration of class cItem */ #ifndef TOLUA_DISABLE_tolua_AllToLua_cItem_GetMaxDuration00 static int tolua_AllToLua_cItem_GetMaxDuration00(lua_State* tolua_S) @@ -12864,9 +13017,9 @@ static int tolua_AllToLua_cItem_IsEnchantable00(lua_State* tolua_S) else #endif { - ENUM_ITEM_ID item = ((ENUM_ITEM_ID) (int) tolua_tonumber(tolua_S,2,0)); + short a_ItemType = ((short) tolua_tonumber(tolua_S,2,0)); { - bool tolua_ret = (bool) cItem::IsEnchantable(item); + bool tolua_ret = (bool) cItem::IsEnchantable(a_ItemType); tolua_pushboolean(tolua_S,(bool)tolua_ret); } } @@ -12909,6 +13062,36 @@ static int tolua_set_cItem_m_ItemID(lua_State* tolua_S) } #endif //#ifndef TOLUA_DISABLE +/* get function: m_ItemType of class cItem */ +#ifndef TOLUA_DISABLE_tolua_get_cItem_m_ItemType +static int tolua_get_cItem_m_ItemType(lua_State* tolua_S) +{ + cItem* self = (cItem*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_ItemType'",NULL); +#endif + tolua_pushnumber(tolua_S,(lua_Number)self->m_ItemType); + return 1; +} +#endif //#ifndef TOLUA_DISABLE + +/* set function: m_ItemType of class cItem */ +#ifndef TOLUA_DISABLE_tolua_set_cItem_m_ItemType +static int tolua_set_cItem_m_ItemType(lua_State* tolua_S) +{ + cItem* self = (cItem*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_ItemType'",NULL); + if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); +#endif + self->m_ItemType = ((short) tolua_tonumber(tolua_S,2,0)) +; + return 0; +} +#endif //#ifndef TOLUA_DISABLE + /* get function: m_ItemCount of class cItem */ #ifndef TOLUA_DISABLE_tolua_get_cItem_m_ItemCount static int tolua_get_cItem_m_ItemCount(lua_State* tolua_S) @@ -12969,6 +13152,36 @@ static int tolua_set_cItem_m_ItemHealth(lua_State* tolua_S) } #endif //#ifndef TOLUA_DISABLE +/* get function: m_ItemDamage of class cItem */ +#ifndef TOLUA_DISABLE_tolua_get_cItem_m_ItemDamage +static int tolua_get_cItem_m_ItemDamage(lua_State* tolua_S) +{ + cItem* self = (cItem*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_ItemDamage'",NULL); +#endif + tolua_pushnumber(tolua_S,(lua_Number)self->m_ItemDamage); + return 1; +} +#endif //#ifndef TOLUA_DISABLE + +/* set function: m_ItemDamage of class cItem */ +#ifndef TOLUA_DISABLE_tolua_set_cItem_m_ItemDamage +static int tolua_set_cItem_m_ItemDamage(lua_State* tolua_S) +{ + cItem* self = (cItem*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_ItemDamage'",NULL); + if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); +#endif + self->m_ItemDamage = ((short) tolua_tonumber(tolua_S,2,0)) +; + return 0; +} +#endif //#ifndef TOLUA_DISABLE + /* get function: Name of class HTTPFormData */ #ifndef TOLUA_DISABLE_tolua_get_HTTPFormData_Name static int tolua_get_HTTPFormData_Name(lua_State* tolua_S) @@ -18867,818 +19080,6 @@ static int tolua_AllToLua_cBlockArea_GetDataTypes00(lua_State* tolua_S) } #endif //#ifndef TOLUA_DISABLE -/* get function: m_ProtocolVersion of class cPacket_Login */ -#ifndef TOLUA_DISABLE_tolua_get_cPacket_Login_m_ProtocolVersion -static int tolua_get_cPacket_Login_m_ProtocolVersion(lua_State* tolua_S) -{ - cPacket_Login* self = (cPacket_Login*) tolua_tousertype(tolua_S,1,0); -#ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_ProtocolVersion'",NULL); -#endif - tolua_pushnumber(tolua_S,(lua_Number)self->m_ProtocolVersion); - return 1; -} -#endif //#ifndef TOLUA_DISABLE - -/* set function: m_ProtocolVersion of class cPacket_Login */ -#ifndef TOLUA_DISABLE_tolua_set_cPacket_Login_m_ProtocolVersion -static int tolua_set_cPacket_Login_m_ProtocolVersion(lua_State* tolua_S) -{ - cPacket_Login* self = (cPacket_Login*) tolua_tousertype(tolua_S,1,0); -#ifndef TOLUA_RELEASE - tolua_Error tolua_err; - if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_ProtocolVersion'",NULL); - if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) - tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); -#endif - self->m_ProtocolVersion = ((int) tolua_tonumber(tolua_S,2,0)) -; - return 0; -} -#endif //#ifndef TOLUA_DISABLE - -/* get function: m_Username of class cPacket_Login */ -#ifndef TOLUA_DISABLE_tolua_get_cPacket_Login_m_Username -static int tolua_get_cPacket_Login_m_Username(lua_State* tolua_S) -{ - cPacket_Login* self = (cPacket_Login*) tolua_tousertype(tolua_S,1,0); -#ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_Username'",NULL); -#endif - tolua_pushcppstring(tolua_S,(const char*)self->m_Username); - return 1; -} -#endif //#ifndef TOLUA_DISABLE - -/* set function: m_Username of class cPacket_Login */ -#ifndef TOLUA_DISABLE_tolua_set_cPacket_Login_m_Username -static int tolua_set_cPacket_Login_m_Username(lua_State* tolua_S) -{ - cPacket_Login* self = (cPacket_Login*) tolua_tousertype(tolua_S,1,0); -#ifndef TOLUA_RELEASE - tolua_Error tolua_err; - if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_Username'",NULL); - if (!tolua_iscppstring(tolua_S,2,0,&tolua_err)) - tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); -#endif - self->m_Username = ((AString) tolua_tocppstring(tolua_S,2,0)) -; - return 0; -} -#endif //#ifndef TOLUA_DISABLE - -/* get function: m_LevelType of class cPacket_Login */ -#ifndef TOLUA_DISABLE_tolua_get_cPacket_Login_m_LevelType -static int tolua_get_cPacket_Login_m_LevelType(lua_State* tolua_S) -{ - cPacket_Login* self = (cPacket_Login*) tolua_tousertype(tolua_S,1,0); -#ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_LevelType'",NULL); -#endif - tolua_pushcppstring(tolua_S,(const char*)self->m_LevelType); - return 1; -} -#endif //#ifndef TOLUA_DISABLE - -/* set function: m_LevelType of class cPacket_Login */ -#ifndef TOLUA_DISABLE_tolua_set_cPacket_Login_m_LevelType -static int tolua_set_cPacket_Login_m_LevelType(lua_State* tolua_S) -{ - cPacket_Login* self = (cPacket_Login*) tolua_tousertype(tolua_S,1,0); -#ifndef TOLUA_RELEASE - tolua_Error tolua_err; - if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_LevelType'",NULL); - if (!tolua_iscppstring(tolua_S,2,0,&tolua_err)) - tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); -#endif - self->m_LevelType = ((AString) tolua_tocppstring(tolua_S,2,0)) -; - return 0; -} -#endif //#ifndef TOLUA_DISABLE - -/* get function: m_ServerMode of class cPacket_Login */ -#ifndef TOLUA_DISABLE_tolua_get_cPacket_Login_m_ServerMode -static int tolua_get_cPacket_Login_m_ServerMode(lua_State* tolua_S) -{ - cPacket_Login* self = (cPacket_Login*) tolua_tousertype(tolua_S,1,0); -#ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_ServerMode'",NULL); -#endif - tolua_pushnumber(tolua_S,(lua_Number)self->m_ServerMode); - return 1; -} -#endif //#ifndef TOLUA_DISABLE - -/* set function: m_ServerMode of class cPacket_Login */ -#ifndef TOLUA_DISABLE_tolua_set_cPacket_Login_m_ServerMode -static int tolua_set_cPacket_Login_m_ServerMode(lua_State* tolua_S) -{ - cPacket_Login* self = (cPacket_Login*) tolua_tousertype(tolua_S,1,0); -#ifndef TOLUA_RELEASE - tolua_Error tolua_err; - if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_ServerMode'",NULL); - if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) - tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); -#endif - self->m_ServerMode = ((int) tolua_tonumber(tolua_S,2,0)) -; - return 0; -} -#endif //#ifndef TOLUA_DISABLE - -/* get function: m_Difficulty of class cPacket_Login */ -#ifndef TOLUA_DISABLE_tolua_get_cPacket_Login_m_Difficulty -static int tolua_get_cPacket_Login_m_Difficulty(lua_State* tolua_S) -{ - cPacket_Login* self = (cPacket_Login*) tolua_tousertype(tolua_S,1,0); -#ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_Difficulty'",NULL); -#endif - tolua_pushnumber(tolua_S,(lua_Number)self->m_Difficulty); - return 1; -} -#endif //#ifndef TOLUA_DISABLE - -/* set function: m_Difficulty of class cPacket_Login */ -#ifndef TOLUA_DISABLE_tolua_set_cPacket_Login_m_Difficulty -static int tolua_set_cPacket_Login_m_Difficulty(lua_State* tolua_S) -{ - cPacket_Login* self = (cPacket_Login*) tolua_tousertype(tolua_S,1,0); -#ifndef TOLUA_RELEASE - tolua_Error tolua_err; - if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_Difficulty'",NULL); - if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) - tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); -#endif - self->m_Difficulty = ((char) tolua_tonumber(tolua_S,2,0)) -; - return 0; -} -#endif //#ifndef TOLUA_DISABLE - -/* get function: m_WorldHeight of class cPacket_Login */ -#ifndef TOLUA_DISABLE_tolua_get_cPacket_Login_unsigned_m_WorldHeight -static int tolua_get_cPacket_Login_unsigned_m_WorldHeight(lua_State* tolua_S) -{ - cPacket_Login* self = (cPacket_Login*) tolua_tousertype(tolua_S,1,0); -#ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_WorldHeight'",NULL); -#endif - tolua_pushnumber(tolua_S,(lua_Number)self->m_WorldHeight); - return 1; -} -#endif //#ifndef TOLUA_DISABLE - -/* set function: m_WorldHeight of class cPacket_Login */ -#ifndef TOLUA_DISABLE_tolua_set_cPacket_Login_unsigned_m_WorldHeight -static int tolua_set_cPacket_Login_unsigned_m_WorldHeight(lua_State* tolua_S) -{ - cPacket_Login* self = (cPacket_Login*) tolua_tousertype(tolua_S,1,0); -#ifndef TOLUA_RELEASE - tolua_Error tolua_err; - if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_WorldHeight'",NULL); - if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) - tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); -#endif - self->m_WorldHeight = ((unsigned char) tolua_tonumber(tolua_S,2,0)) -; - return 0; -} -#endif //#ifndef TOLUA_DISABLE - -/* get function: m_MaxPlayers of class cPacket_Login */ -#ifndef TOLUA_DISABLE_tolua_get_cPacket_Login_unsigned_m_MaxPlayers -static int tolua_get_cPacket_Login_unsigned_m_MaxPlayers(lua_State* tolua_S) -{ - cPacket_Login* self = (cPacket_Login*) tolua_tousertype(tolua_S,1,0); -#ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_MaxPlayers'",NULL); -#endif - tolua_pushnumber(tolua_S,(lua_Number)self->m_MaxPlayers); - return 1; -} -#endif //#ifndef TOLUA_DISABLE - -/* set function: m_MaxPlayers of class cPacket_Login */ -#ifndef TOLUA_DISABLE_tolua_set_cPacket_Login_unsigned_m_MaxPlayers -static int tolua_set_cPacket_Login_unsigned_m_MaxPlayers(lua_State* tolua_S) -{ - cPacket_Login* self = (cPacket_Login*) tolua_tousertype(tolua_S,1,0); -#ifndef TOLUA_RELEASE - tolua_Error tolua_err; - if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_MaxPlayers'",NULL); - if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) - tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); -#endif - self->m_MaxPlayers = ((unsigned char) tolua_tonumber(tolua_S,2,0)) -; - return 0; -} -#endif //#ifndef TOLUA_DISABLE - -/* method: new of class cPacket_BlockDig */ -#ifndef TOLUA_DISABLE_tolua_AllToLua_cPacket_BlockDig_new00 -static int tolua_AllToLua_cPacket_BlockDig_new00(lua_State* tolua_S) -{ -#ifndef TOLUA_RELEASE - tolua_Error tolua_err; - if ( - !tolua_isusertable(tolua_S,1,"cPacket_BlockDig",0,&tolua_err) || - !tolua_isnoobj(tolua_S,2,&tolua_err) - ) - goto tolua_lerror; - else -#endif - { - { - cPacket_BlockDig* tolua_ret = (cPacket_BlockDig*) Mtolua_new((cPacket_BlockDig)()); - tolua_pushusertype(tolua_S,(void*)tolua_ret,"cPacket_BlockDig"); - } - } - return 1; -#ifndef TOLUA_RELEASE - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err); - return 0; -#endif -} -#endif //#ifndef TOLUA_DISABLE - -/* method: new_local of class cPacket_BlockDig */ -#ifndef TOLUA_DISABLE_tolua_AllToLua_cPacket_BlockDig_new00_local -static int tolua_AllToLua_cPacket_BlockDig_new00_local(lua_State* tolua_S) -{ -#ifndef TOLUA_RELEASE - tolua_Error tolua_err; - if ( - !tolua_isusertable(tolua_S,1,"cPacket_BlockDig",0,&tolua_err) || - !tolua_isnoobj(tolua_S,2,&tolua_err) - ) - goto tolua_lerror; - else -#endif - { - { - cPacket_BlockDig* tolua_ret = (cPacket_BlockDig*) Mtolua_new((cPacket_BlockDig)()); - tolua_pushusertype(tolua_S,(void*)tolua_ret,"cPacket_BlockDig"); - tolua_register_gc(tolua_S,lua_gettop(tolua_S)); - } - } - return 1; -#ifndef TOLUA_RELEASE - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err); - return 0; -#endif -} -#endif //#ifndef TOLUA_DISABLE - -/* method: Clone of class cPacket_BlockDig */ -#ifndef TOLUA_DISABLE_tolua_AllToLua_cPacket_BlockDig_Clone00 -static int tolua_AllToLua_cPacket_BlockDig_Clone00(lua_State* tolua_S) -{ -#ifndef TOLUA_RELEASE - tolua_Error tolua_err; - if ( - !tolua_isusertype(tolua_S,1,"const cPacket_BlockDig",0,&tolua_err) || - !tolua_isnoobj(tolua_S,2,&tolua_err) - ) - goto tolua_lerror; - else -#endif - { - const cPacket_BlockDig* self = (const cPacket_BlockDig*) tolua_tousertype(tolua_S,1,0); -#ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Clone'", NULL); -#endif - { - cPacket* tolua_ret = (cPacket*) self->Clone(); - tolua_pushusertype(tolua_S,(void*)tolua_ret,"cPacket"); - } - } - return 1; -#ifndef TOLUA_RELEASE - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'Clone'.",&tolua_err); - return 0; -#endif -} -#endif //#ifndef TOLUA_DISABLE - -/* get function: m_Status of class cPacket_BlockDig */ -#ifndef TOLUA_DISABLE_tolua_get_cPacket_BlockDig_m_Status -static int tolua_get_cPacket_BlockDig_m_Status(lua_State* tolua_S) -{ - cPacket_BlockDig* self = (cPacket_BlockDig*) tolua_tousertype(tolua_S,1,0); -#ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_Status'",NULL); -#endif - tolua_pushnumber(tolua_S,(lua_Number)self->m_Status); - return 1; -} -#endif //#ifndef TOLUA_DISABLE - -/* set function: m_Status of class cPacket_BlockDig */ -#ifndef TOLUA_DISABLE_tolua_set_cPacket_BlockDig_m_Status -static int tolua_set_cPacket_BlockDig_m_Status(lua_State* tolua_S) -{ - cPacket_BlockDig* self = (cPacket_BlockDig*) tolua_tousertype(tolua_S,1,0); -#ifndef TOLUA_RELEASE - tolua_Error tolua_err; - if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_Status'",NULL); - if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) - tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); -#endif - self->m_Status = ((char) tolua_tonumber(tolua_S,2,0)) -; - return 0; -} -#endif //#ifndef TOLUA_DISABLE - -/* get function: m_PosX of class cPacket_BlockDig */ -#ifndef TOLUA_DISABLE_tolua_get_cPacket_BlockDig_m_PosX -static int tolua_get_cPacket_BlockDig_m_PosX(lua_State* tolua_S) -{ - cPacket_BlockDig* self = (cPacket_BlockDig*) tolua_tousertype(tolua_S,1,0); -#ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_PosX'",NULL); -#endif - tolua_pushnumber(tolua_S,(lua_Number)self->m_PosX); - return 1; -} -#endif //#ifndef TOLUA_DISABLE - -/* set function: m_PosX of class cPacket_BlockDig */ -#ifndef TOLUA_DISABLE_tolua_set_cPacket_BlockDig_m_PosX -static int tolua_set_cPacket_BlockDig_m_PosX(lua_State* tolua_S) -{ - cPacket_BlockDig* self = (cPacket_BlockDig*) tolua_tousertype(tolua_S,1,0); -#ifndef TOLUA_RELEASE - tolua_Error tolua_err; - if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_PosX'",NULL); - if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) - tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); -#endif - self->m_PosX = ((int) tolua_tonumber(tolua_S,2,0)) -; - return 0; -} -#endif //#ifndef TOLUA_DISABLE - -/* get function: m_PosY of class cPacket_BlockDig */ -#ifndef TOLUA_DISABLE_tolua_get_cPacket_BlockDig_m_PosY -static int tolua_get_cPacket_BlockDig_m_PosY(lua_State* tolua_S) -{ - cPacket_BlockDig* self = (cPacket_BlockDig*) tolua_tousertype(tolua_S,1,0); -#ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_PosY'",NULL); -#endif - tolua_pushnumber(tolua_S,(lua_Number)self->m_PosY); - return 1; -} -#endif //#ifndef TOLUA_DISABLE - -/* set function: m_PosY of class cPacket_BlockDig */ -#ifndef TOLUA_DISABLE_tolua_set_cPacket_BlockDig_m_PosY -static int tolua_set_cPacket_BlockDig_m_PosY(lua_State* tolua_S) -{ - cPacket_BlockDig* self = (cPacket_BlockDig*) tolua_tousertype(tolua_S,1,0); -#ifndef TOLUA_RELEASE - tolua_Error tolua_err; - if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_PosY'",NULL); - if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) - tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); -#endif - self->m_PosY = ((char) tolua_tonumber(tolua_S,2,0)) -; - return 0; -} -#endif //#ifndef TOLUA_DISABLE - -/* get function: m_PosZ of class cPacket_BlockDig */ -#ifndef TOLUA_DISABLE_tolua_get_cPacket_BlockDig_m_PosZ -static int tolua_get_cPacket_BlockDig_m_PosZ(lua_State* tolua_S) -{ - cPacket_BlockDig* self = (cPacket_BlockDig*) tolua_tousertype(tolua_S,1,0); -#ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_PosZ'",NULL); -#endif - tolua_pushnumber(tolua_S,(lua_Number)self->m_PosZ); - return 1; -} -#endif //#ifndef TOLUA_DISABLE - -/* set function: m_PosZ of class cPacket_BlockDig */ -#ifndef TOLUA_DISABLE_tolua_set_cPacket_BlockDig_m_PosZ -static int tolua_set_cPacket_BlockDig_m_PosZ(lua_State* tolua_S) -{ - cPacket_BlockDig* self = (cPacket_BlockDig*) tolua_tousertype(tolua_S,1,0); -#ifndef TOLUA_RELEASE - tolua_Error tolua_err; - if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_PosZ'",NULL); - if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) - tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); -#endif - self->m_PosZ = ((int) tolua_tonumber(tolua_S,2,0)) -; - return 0; -} -#endif //#ifndef TOLUA_DISABLE - -/* get function: m_Direction of class cPacket_BlockDig */ -#ifndef TOLUA_DISABLE_tolua_get_cPacket_BlockDig_m_Direction -static int tolua_get_cPacket_BlockDig_m_Direction(lua_State* tolua_S) -{ - cPacket_BlockDig* self = (cPacket_BlockDig*) tolua_tousertype(tolua_S,1,0); -#ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_Direction'",NULL); -#endif - tolua_pushnumber(tolua_S,(lua_Number)self->m_Direction); - return 1; -} -#endif //#ifndef TOLUA_DISABLE - -/* set function: m_Direction of class cPacket_BlockDig */ -#ifndef TOLUA_DISABLE_tolua_set_cPacket_BlockDig_m_Direction -static int tolua_set_cPacket_BlockDig_m_Direction(lua_State* tolua_S) -{ - cPacket_BlockDig* self = (cPacket_BlockDig*) tolua_tousertype(tolua_S,1,0); -#ifndef TOLUA_RELEASE - tolua_Error tolua_err; - if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_Direction'",NULL); - if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) - tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); -#endif - self->m_Direction = ((char) tolua_tonumber(tolua_S,2,0)) -; - return 0; -} -#endif //#ifndef TOLUA_DISABLE - - class Lua__cPacket_BlockDig : public cPacket_BlockDig, public ToluaBase { -public: - cPacket* Clone( void )const { - if (push_method("Clone", tolua_AllToLua_cPacket_BlockDig_Clone00)) { - ToluaBase::dbcall(lua_state, 1, 1); - cPacket* tolua_ret = ( cPacket* )tolua_tousertype(lua_state, -1, 0); - lua_pop(lua_state, 1); - return tolua_ret; - } else { - return ( cPacket* ) cPacket_BlockDig:: Clone(); - }; - }; - - cPacket* cPacket_BlockDig__Clone( void ) { - return ( cPacket* )cPacket_BlockDig::Clone(); - }; - Lua__cPacket_BlockDig( void ): cPacket_BlockDig(){}; -}; - -/* method: tolua__set_instance of class Lua__cPacket_BlockDig */ -#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPacket_BlockDig_tolua__set_instance00 -static int tolua_AllToLua_Lua__cPacket_BlockDig_tolua__set_instance00(lua_State* tolua_S) -{ -#ifndef TOLUA_RELEASE - tolua_Error tolua_err; - if ( - !tolua_isusertype(tolua_S,1,"Lua__cPacket_BlockDig",0,&tolua_err) || - !tolua_isnoobj(tolua_S,3,&tolua_err) - ) - goto tolua_lerror; - else -#endif - { - Lua__cPacket_BlockDig* self = (Lua__cPacket_BlockDig*) tolua_tousertype(tolua_S,1,0); - lua_State* L = tolua_S; - lua_Object lo = ((lua_Object) tolua_tovalue(tolua_S,2,0)); -#ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in function 'tolua__set_instance'", NULL); -#endif - { - self->tolua__set_instance(L,lo); - } - } - return 0; -#ifndef TOLUA_RELEASE - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'tolua__set_instance'.",&tolua_err); - return 0; -#endif -} -#endif //#ifndef TOLUA_DISABLE - -/* method: cPacket_BlockDig__Clone of class Lua__cPacket_BlockDig */ -#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPacket_BlockDig_cPacket_BlockDig__Clone00 -static int tolua_AllToLua_Lua__cPacket_BlockDig_cPacket_BlockDig__Clone00(lua_State* tolua_S) -{ -#ifndef TOLUA_RELEASE - tolua_Error tolua_err; - if ( - !tolua_isusertype(tolua_S,1,"Lua__cPacket_BlockDig",0,&tolua_err) || - !tolua_isnoobj(tolua_S,2,&tolua_err) - ) - goto tolua_lerror; - else -#endif - { - Lua__cPacket_BlockDig* self = (Lua__cPacket_BlockDig*) tolua_tousertype(tolua_S,1,0); -#ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPacket_BlockDig__Clone'", NULL); -#endif - { - cPacket* tolua_ret = (cPacket*) self->cPacket_BlockDig__Clone(); - tolua_pushusertype(tolua_S,(void*)tolua_ret,"cPacket"); - } - } - return 1; -#ifndef TOLUA_RELEASE - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'cPacket_BlockDig__Clone'.",&tolua_err); - return 0; -#endif -} -#endif //#ifndef TOLUA_DISABLE - -/* method: new of class Lua__cPacket_BlockDig */ -#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPacket_BlockDig_new00 -static int tolua_AllToLua_Lua__cPacket_BlockDig_new00(lua_State* tolua_S) -{ -#ifndef TOLUA_RELEASE - tolua_Error tolua_err; - if ( - !tolua_isusertable(tolua_S,1,"Lua__cPacket_BlockDig",0,&tolua_err) || - !tolua_isnoobj(tolua_S,2,&tolua_err) - ) - goto tolua_lerror; - else -#endif - { - { - Lua__cPacket_BlockDig* tolua_ret = (Lua__cPacket_BlockDig*) Mtolua_new((Lua__cPacket_BlockDig)()); - tolua_pushusertype(tolua_S,(void*)tolua_ret,"Lua__cPacket_BlockDig"); - } - } - return 1; -#ifndef TOLUA_RELEASE - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err); - return 0; -#endif -} -#endif //#ifndef TOLUA_DISABLE - -/* method: new_local of class Lua__cPacket_BlockDig */ -#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPacket_BlockDig_new00_local -static int tolua_AllToLua_Lua__cPacket_BlockDig_new00_local(lua_State* tolua_S) -{ -#ifndef TOLUA_RELEASE - tolua_Error tolua_err; - if ( - !tolua_isusertable(tolua_S,1,"Lua__cPacket_BlockDig",0,&tolua_err) || - !tolua_isnoobj(tolua_S,2,&tolua_err) - ) - goto tolua_lerror; - else -#endif - { - { - Lua__cPacket_BlockDig* tolua_ret = (Lua__cPacket_BlockDig*) Mtolua_new((Lua__cPacket_BlockDig)()); - tolua_pushusertype(tolua_S,(void*)tolua_ret,"Lua__cPacket_BlockDig"); - tolua_register_gc(tolua_S,lua_gettop(tolua_S)); - } - } - return 1; -#ifndef TOLUA_RELEASE - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err); - return 0; -#endif -} -#endif //#ifndef TOLUA_DISABLE - - -/* function to release collected object via destructor */ -#ifdef __cplusplus - -static int tolua_collect_Lua__cPacket_BlockDig (lua_State* tolua_S) -{ - Lua__cPacket_BlockDig* self = (Lua__cPacket_BlockDig*) tolua_tousertype(tolua_S,1,0); - delete self; - return 0; -} -#endif - -/* get function: m_PosX of class cPacket_BlockPlace */ -#ifndef TOLUA_DISABLE_tolua_get_cPacket_BlockPlace_m_PosX -static int tolua_get_cPacket_BlockPlace_m_PosX(lua_State* tolua_S) -{ - cPacket_BlockPlace* self = (cPacket_BlockPlace*) tolua_tousertype(tolua_S,1,0); -#ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_PosX'",NULL); -#endif - tolua_pushnumber(tolua_S,(lua_Number)self->m_PosX); - return 1; -} -#endif //#ifndef TOLUA_DISABLE - -/* set function: m_PosX of class cPacket_BlockPlace */ -#ifndef TOLUA_DISABLE_tolua_set_cPacket_BlockPlace_m_PosX -static int tolua_set_cPacket_BlockPlace_m_PosX(lua_State* tolua_S) -{ - cPacket_BlockPlace* self = (cPacket_BlockPlace*) tolua_tousertype(tolua_S,1,0); -#ifndef TOLUA_RELEASE - tolua_Error tolua_err; - if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_PosX'",NULL); - if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) - tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); -#endif - self->m_PosX = ((int) tolua_tonumber(tolua_S,2,0)) -; - return 0; -} -#endif //#ifndef TOLUA_DISABLE - -/* get function: m_PosY of class cPacket_BlockPlace */ -#ifndef TOLUA_DISABLE_tolua_get_cPacket_BlockPlace_unsigned_m_PosY -static int tolua_get_cPacket_BlockPlace_unsigned_m_PosY(lua_State* tolua_S) -{ - cPacket_BlockPlace* self = (cPacket_BlockPlace*) tolua_tousertype(tolua_S,1,0); -#ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_PosY'",NULL); -#endif - tolua_pushnumber(tolua_S,(lua_Number)self->m_PosY); - return 1; -} -#endif //#ifndef TOLUA_DISABLE - -/* set function: m_PosY of class cPacket_BlockPlace */ -#ifndef TOLUA_DISABLE_tolua_set_cPacket_BlockPlace_unsigned_m_PosY -static int tolua_set_cPacket_BlockPlace_unsigned_m_PosY(lua_State* tolua_S) -{ - cPacket_BlockPlace* self = (cPacket_BlockPlace*) tolua_tousertype(tolua_S,1,0); -#ifndef TOLUA_RELEASE - tolua_Error tolua_err; - if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_PosY'",NULL); - if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) - tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); -#endif - self->m_PosY = ((unsigned char) tolua_tonumber(tolua_S,2,0)) -; - return 0; -} -#endif //#ifndef TOLUA_DISABLE - -/* get function: m_PosZ of class cPacket_BlockPlace */ -#ifndef TOLUA_DISABLE_tolua_get_cPacket_BlockPlace_m_PosZ -static int tolua_get_cPacket_BlockPlace_m_PosZ(lua_State* tolua_S) -{ - cPacket_BlockPlace* self = (cPacket_BlockPlace*) tolua_tousertype(tolua_S,1,0); -#ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_PosZ'",NULL); -#endif - tolua_pushnumber(tolua_S,(lua_Number)self->m_PosZ); - return 1; -} -#endif //#ifndef TOLUA_DISABLE - -/* set function: m_PosZ of class cPacket_BlockPlace */ -#ifndef TOLUA_DISABLE_tolua_set_cPacket_BlockPlace_m_PosZ -static int tolua_set_cPacket_BlockPlace_m_PosZ(lua_State* tolua_S) -{ - cPacket_BlockPlace* self = (cPacket_BlockPlace*) tolua_tousertype(tolua_S,1,0); -#ifndef TOLUA_RELEASE - tolua_Error tolua_err; - if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_PosZ'",NULL); - if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) - tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); -#endif - self->m_PosZ = ((int) tolua_tonumber(tolua_S,2,0)) -; - return 0; -} -#endif //#ifndef TOLUA_DISABLE - -/* get function: m_Direction of class cPacket_BlockPlace */ -#ifndef TOLUA_DISABLE_tolua_get_cPacket_BlockPlace_m_Direction -static int tolua_get_cPacket_BlockPlace_m_Direction(lua_State* tolua_S) -{ - cPacket_BlockPlace* self = (cPacket_BlockPlace*) tolua_tousertype(tolua_S,1,0); -#ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_Direction'",NULL); -#endif - tolua_pushnumber(tolua_S,(lua_Number)self->m_Direction); - return 1; -} -#endif //#ifndef TOLUA_DISABLE - -/* set function: m_Direction of class cPacket_BlockPlace */ -#ifndef TOLUA_DISABLE_tolua_set_cPacket_BlockPlace_m_Direction -static int tolua_set_cPacket_BlockPlace_m_Direction(lua_State* tolua_S) -{ - cPacket_BlockPlace* self = (cPacket_BlockPlace*) tolua_tousertype(tolua_S,1,0); -#ifndef TOLUA_RELEASE - tolua_Error tolua_err; - if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_Direction'",NULL); - if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) - tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); -#endif - self->m_Direction = ((char) tolua_tonumber(tolua_S,2,0)) -; - return 0; -} -#endif //#ifndef TOLUA_DISABLE - -/* get function: m_ItemType of class cPacket_BlockPlace */ -#ifndef TOLUA_DISABLE_tolua_get_cPacket_BlockPlace_m_ItemType -static int tolua_get_cPacket_BlockPlace_m_ItemType(lua_State* tolua_S) -{ - cPacket_BlockPlace* self = (cPacket_BlockPlace*) tolua_tousertype(tolua_S,1,0); -#ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_ItemType'",NULL); -#endif - tolua_pushnumber(tolua_S,(lua_Number)self->m_ItemType); - return 1; -} -#endif //#ifndef TOLUA_DISABLE - -/* set function: m_ItemType of class cPacket_BlockPlace */ -#ifndef TOLUA_DISABLE_tolua_set_cPacket_BlockPlace_m_ItemType -static int tolua_set_cPacket_BlockPlace_m_ItemType(lua_State* tolua_S) -{ - cPacket_BlockPlace* self = (cPacket_BlockPlace*) tolua_tousertype(tolua_S,1,0); -#ifndef TOLUA_RELEASE - tolua_Error tolua_err; - if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_ItemType'",NULL); - if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) - tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); -#endif - self->m_ItemType = ((short) tolua_tonumber(tolua_S,2,0)) -; - return 0; -} -#endif //#ifndef TOLUA_DISABLE - -/* get function: m_Count of class cPacket_BlockPlace */ -#ifndef TOLUA_DISABLE_tolua_get_cPacket_BlockPlace_m_Count -static int tolua_get_cPacket_BlockPlace_m_Count(lua_State* tolua_S) -{ - cPacket_BlockPlace* self = (cPacket_BlockPlace*) tolua_tousertype(tolua_S,1,0); -#ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_Count'",NULL); -#endif - tolua_pushnumber(tolua_S,(lua_Number)self->m_Count); - return 1; -} -#endif //#ifndef TOLUA_DISABLE - -/* set function: m_Count of class cPacket_BlockPlace */ -#ifndef TOLUA_DISABLE_tolua_set_cPacket_BlockPlace_m_Count -static int tolua_set_cPacket_BlockPlace_m_Count(lua_State* tolua_S) -{ - cPacket_BlockPlace* self = (cPacket_BlockPlace*) tolua_tousertype(tolua_S,1,0); -#ifndef TOLUA_RELEASE - tolua_Error tolua_err; - if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_Count'",NULL); - if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) - tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); -#endif - self->m_Count = ((char) tolua_tonumber(tolua_S,2,0)) -; - return 0; -} -#endif //#ifndef TOLUA_DISABLE - -/* get function: m_Uses of class cPacket_BlockPlace */ -#ifndef TOLUA_DISABLE_tolua_get_cPacket_BlockPlace_m_Uses -static int tolua_get_cPacket_BlockPlace_m_Uses(lua_State* tolua_S) -{ - cPacket_BlockPlace* self = (cPacket_BlockPlace*) tolua_tousertype(tolua_S,1,0); -#ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_Uses'",NULL); -#endif - tolua_pushnumber(tolua_S,(lua_Number)self->m_Uses); - return 1; -} -#endif //#ifndef TOLUA_DISABLE - -/* set function: m_Uses of class cPacket_BlockPlace */ -#ifndef TOLUA_DISABLE_tolua_set_cPacket_BlockPlace_m_Uses -static int tolua_set_cPacket_BlockPlace_m_Uses(lua_State* tolua_S) -{ - cPacket_BlockPlace* self = (cPacket_BlockPlace*) tolua_tousertype(tolua_S,1,0); -#ifndef TOLUA_RELEASE - tolua_Error tolua_err; - if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_Uses'",NULL); - if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) - tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); -#endif - self->m_Uses = ((short) tolua_tonumber(tolua_S,2,0)) -; - return 0; -} -#endif //#ifndef TOLUA_DISABLE - /* method: FillBlocks of class cLuaChunk */ #ifndef TOLUA_DISABLE_tolua_AllToLua_cLuaChunk_FillBlocks00 static int tolua_AllToLua_cLuaChunk_FillBlocks00(lua_State* tolua_S) @@ -21659,7 +21060,9 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S) tolua_constant(tolua_S,"E_ITEM_GOLD_LEGGINGS",E_ITEM_GOLD_LEGGINGS); tolua_constant(tolua_S,"E_ITEM_GOLD_BOOTS",E_ITEM_GOLD_BOOTS); tolua_constant(tolua_S,"E_ITEM_FLINT",E_ITEM_FLINT); + tolua_constant(tolua_S,"E_ITEM_RAW_PORKCHOP",E_ITEM_RAW_PORKCHOP); tolua_constant(tolua_S,"E_ITEM_RAW_MEAT",E_ITEM_RAW_MEAT); + tolua_constant(tolua_S,"E_ITEM_COOKED_PORKCHOP",E_ITEM_COOKED_PORKCHOP); tolua_constant(tolua_S,"E_ITEM_COOKED_MEAT",E_ITEM_COOKED_MEAT); tolua_constant(tolua_S,"E_ITEM_PAINTINGS",E_ITEM_PAINTINGS); tolua_constant(tolua_S,"E_ITEM_GOLDEN_APPLE",E_ITEM_GOLDEN_APPLE); @@ -21918,6 +21321,16 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S) tolua_array(tolua_S,"g_BlockSpreadLightFalloff",tolua_get_AllToLua_g_BlockSpreadLightFalloff,tolua_set_AllToLua_g_BlockSpreadLightFalloff); tolua_array(tolua_S,"g_BlockTransparent",tolua_get_AllToLua_g_BlockTransparent,tolua_set_AllToLua_g_BlockTransparent); tolua_array(tolua_S,"g_BlockOneHitDig",tolua_get_AllToLua_g_BlockOneHitDig,tolua_set_AllToLua_g_BlockOneHitDig); + tolua_constant(tolua_S,"BLOCK_FACE_BOTTOM",BLOCK_FACE_BOTTOM); + tolua_constant(tolua_S,"BLOCK_FACE_TOP",BLOCK_FACE_TOP); + tolua_constant(tolua_S,"BLOCK_FACE_NORTH",BLOCK_FACE_NORTH); + tolua_constant(tolua_S,"BLOCK_FACE_SOUTH",BLOCK_FACE_SOUTH); + tolua_constant(tolua_S,"BLOCK_FACE_WEST",BLOCK_FACE_WEST); + tolua_constant(tolua_S,"BLOCK_FACE_EAST",BLOCK_FACE_EAST); + tolua_constant(tolua_S,"DIG_STATUS_STARTED",DIG_STATUS_STARTED); + tolua_constant(tolua_S,"DIG_STATUS_FINISHED",DIG_STATUS_FINISHED); + tolua_constant(tolua_S,"DIG_STATUS_DROP_HELD",DIG_STATUS_DROP_HELD); + tolua_constant(tolua_S,"DIG_STATUS_SHOOT_EAT",DIG_STATUS_SHOOT_EAT); tolua_function(tolua_S,"IsValidBlock",tolua_AllToLua_IsValidBlock00); tolua_function(tolua_S,"IsValidItem",tolua_AllToLua_IsValidItem00); tolua_function(tolua_S,"AddDirection",tolua_AllToLua_AddDirection00); @@ -22072,6 +21485,7 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S) tolua_function(tolua_S,"GetEyeHeight",tolua_AllToLua_cPlayer_GetEyeHeight00); tolua_function(tolua_S,"GetEyePosition",tolua_AllToLua_cPlayer_GetEyePosition00); tolua_function(tolua_S,"GetFlying",tolua_AllToLua_cPlayer_GetFlying00); + tolua_function(tolua_S,"IsOnGround",tolua_AllToLua_cPlayer_IsOnGround00); tolua_function(tolua_S,"GetStance",tolua_AllToLua_cPlayer_GetStance00); tolua_function(tolua_S,"GetInventory",tolua_AllToLua_cPlayer_GetInventory00); tolua_function(tolua_S,"TeleportTo",tolua_AllToLua_cPlayer_TeleportTo00); @@ -22170,26 +21584,26 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S) tolua_function(tolua_S,"OnDisable",tolua_AllToLua_cPlugin_OnDisable00); tolua_function(tolua_S,"Initialize",tolua_AllToLua_cPlugin_Initialize00); tolua_function(tolua_S,"Tick",tolua_AllToLua_cPlugin_Tick00); - tolua_function(tolua_S,"OnCollectItem",tolua_AllToLua_cPlugin_OnCollectItem00); - tolua_function(tolua_S,"OnDisconnect",tolua_AllToLua_cPlugin_OnDisconnect00); - tolua_function(tolua_S,"OnBlockPlace",tolua_AllToLua_cPlugin_OnBlockPlace00); tolua_function(tolua_S,"OnBlockDig",tolua_AllToLua_cPlugin_OnBlockDig00); + tolua_function(tolua_S,"OnBlockPlace",tolua_AllToLua_cPlugin_OnBlockPlace00); + tolua_function(tolua_S,"OnBlockToPickup",tolua_AllToLua_cPlugin_OnBlockToPickup00); tolua_function(tolua_S,"OnChat",tolua_AllToLua_cPlugin_OnChat00); - tolua_function(tolua_S,"OnLogin",tolua_AllToLua_cPlugin_OnLogin00); - tolua_function(tolua_S,"OnPlayerSpawn",tolua_AllToLua_cPlugin_OnPlayerSpawn00); - tolua_function(tolua_S,"OnPlayerJoin",tolua_AllToLua_cPlugin_OnPlayerJoin00); - tolua_function(tolua_S,"OnPlayerMove",tolua_AllToLua_cPlugin_OnPlayerMove00); - tolua_function(tolua_S,"OnTakeDamage",tolua_AllToLua_cPlugin_OnTakeDamage00); - tolua_function(tolua_S,"OnKilled",tolua_AllToLua_cPlugin_OnKilled00); tolua_function(tolua_S,"OnChunkGenerated",tolua_AllToLua_cPlugin_OnChunkGenerated00); tolua_function(tolua_S,"OnChunkGenerating",tolua_AllToLua_cPlugin_OnChunkGenerating00); - tolua_function(tolua_S,"OnPreCrafting",tolua_AllToLua_cPlugin_OnPreCrafting00); + tolua_function(tolua_S,"OnCollectItem",tolua_AllToLua_cPlugin_OnCollectItem00); tolua_function(tolua_S,"OnCraftingNoRecipe",tolua_AllToLua_cPlugin_OnCraftingNoRecipe00); + tolua_function(tolua_S,"OnDisconnect",tolua_AllToLua_cPlugin_OnDisconnect00); + tolua_function(tolua_S,"OnKilled",tolua_AllToLua_cPlugin_OnKilled00); + tolua_function(tolua_S,"OnLogin",tolua_AllToLua_cPlugin_OnLogin00); + tolua_function(tolua_S,"OnPlayerJoin",tolua_AllToLua_cPlugin_OnPlayerJoin00); + tolua_function(tolua_S,"OnPlayerMove",tolua_AllToLua_cPlugin_OnPlayerMove00); + tolua_function(tolua_S,"OnPlayerSpawn",tolua_AllToLua_cPlugin_OnPlayerSpawn00); tolua_function(tolua_S,"OnPostCrafting",tolua_AllToLua_cPlugin_OnPostCrafting00); - tolua_function(tolua_S,"OnBlockToPickup",tolua_AllToLua_cPlugin_OnBlockToPickup00); - tolua_function(tolua_S,"OnWeatherChanged",tolua_AllToLua_cPlugin_OnWeatherChanged00); - tolua_function(tolua_S,"OnUpdatingSign",tolua_AllToLua_cPlugin_OnUpdatingSign00); + tolua_function(tolua_S,"OnPreCrafting",tolua_AllToLua_cPlugin_OnPreCrafting00); + tolua_function(tolua_S,"OnTakeDamage",tolua_AllToLua_cPlugin_OnTakeDamage00); tolua_function(tolua_S,"OnUpdatedSign",tolua_AllToLua_cPlugin_OnUpdatedSign00); + tolua_function(tolua_S,"OnUpdatingSign",tolua_AllToLua_cPlugin_OnUpdatingSign00); + tolua_function(tolua_S,"OnWeatherChanged",tolua_AllToLua_cPlugin_OnWeatherChanged00); tolua_function(tolua_S,"GetName",tolua_AllToLua_cPlugin_GetName00); tolua_function(tolua_S,"SetName",tolua_AllToLua_cPlugin_SetName00); tolua_function(tolua_S,"GetVersion",tolua_AllToLua_cPlugin_GetVersion00); @@ -22211,26 +21625,26 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S) tolua_function(tolua_S,"tolua__set_instance",tolua_AllToLua_Lua__cPlugin_tolua__set_instance00); tolua_function(tolua_S,"cPlugin__OnDisable",tolua_AllToLua_Lua__cPlugin_cPlugin__OnDisable00); tolua_function(tolua_S,"cPlugin__Tick",tolua_AllToLua_Lua__cPlugin_cPlugin__Tick00); - tolua_function(tolua_S,"cPlugin__OnCollectItem",tolua_AllToLua_Lua__cPlugin_cPlugin__OnCollectItem00); - tolua_function(tolua_S,"cPlugin__OnDisconnect",tolua_AllToLua_Lua__cPlugin_cPlugin__OnDisconnect00); - tolua_function(tolua_S,"cPlugin__OnBlockPlace",tolua_AllToLua_Lua__cPlugin_cPlugin__OnBlockPlace00); tolua_function(tolua_S,"cPlugin__OnBlockDig",tolua_AllToLua_Lua__cPlugin_cPlugin__OnBlockDig00); + tolua_function(tolua_S,"cPlugin__OnBlockPlace",tolua_AllToLua_Lua__cPlugin_cPlugin__OnBlockPlace00); + tolua_function(tolua_S,"cPlugin__OnBlockToPickup",tolua_AllToLua_Lua__cPlugin_cPlugin__OnBlockToPickup00); tolua_function(tolua_S,"cPlugin__OnChat",tolua_AllToLua_Lua__cPlugin_cPlugin__OnChat00); - tolua_function(tolua_S,"cPlugin__OnLogin",tolua_AllToLua_Lua__cPlugin_cPlugin__OnLogin00); - tolua_function(tolua_S,"cPlugin__OnPlayerSpawn",tolua_AllToLua_Lua__cPlugin_cPlugin__OnPlayerSpawn00); - tolua_function(tolua_S,"cPlugin__OnPlayerJoin",tolua_AllToLua_Lua__cPlugin_cPlugin__OnPlayerJoin00); - tolua_function(tolua_S,"cPlugin__OnPlayerMove",tolua_AllToLua_Lua__cPlugin_cPlugin__OnPlayerMove00); - tolua_function(tolua_S,"cPlugin__OnTakeDamage",tolua_AllToLua_Lua__cPlugin_cPlugin__OnTakeDamage00); - tolua_function(tolua_S,"cPlugin__OnKilled",tolua_AllToLua_Lua__cPlugin_cPlugin__OnKilled00); tolua_function(tolua_S,"cPlugin__OnChunkGenerated",tolua_AllToLua_Lua__cPlugin_cPlugin__OnChunkGenerated00); tolua_function(tolua_S,"cPlugin__OnChunkGenerating",tolua_AllToLua_Lua__cPlugin_cPlugin__OnChunkGenerating00); - tolua_function(tolua_S,"cPlugin__OnPreCrafting",tolua_AllToLua_Lua__cPlugin_cPlugin__OnPreCrafting00); + tolua_function(tolua_S,"cPlugin__OnCollectItem",tolua_AllToLua_Lua__cPlugin_cPlugin__OnCollectItem00); tolua_function(tolua_S,"cPlugin__OnCraftingNoRecipe",tolua_AllToLua_Lua__cPlugin_cPlugin__OnCraftingNoRecipe00); + tolua_function(tolua_S,"cPlugin__OnDisconnect",tolua_AllToLua_Lua__cPlugin_cPlugin__OnDisconnect00); + tolua_function(tolua_S,"cPlugin__OnKilled",tolua_AllToLua_Lua__cPlugin_cPlugin__OnKilled00); + tolua_function(tolua_S,"cPlugin__OnLogin",tolua_AllToLua_Lua__cPlugin_cPlugin__OnLogin00); + tolua_function(tolua_S,"cPlugin__OnPlayerJoin",tolua_AllToLua_Lua__cPlugin_cPlugin__OnPlayerJoin00); + tolua_function(tolua_S,"cPlugin__OnPlayerMove",tolua_AllToLua_Lua__cPlugin_cPlugin__OnPlayerMove00); + tolua_function(tolua_S,"cPlugin__OnPlayerSpawn",tolua_AllToLua_Lua__cPlugin_cPlugin__OnPlayerSpawn00); tolua_function(tolua_S,"cPlugin__OnPostCrafting",tolua_AllToLua_Lua__cPlugin_cPlugin__OnPostCrafting00); - tolua_function(tolua_S,"cPlugin__OnBlockToPickup",tolua_AllToLua_Lua__cPlugin_cPlugin__OnBlockToPickup00); - tolua_function(tolua_S,"cPlugin__OnWeatherChanged",tolua_AllToLua_Lua__cPlugin_cPlugin__OnWeatherChanged00); - tolua_function(tolua_S,"cPlugin__OnUpdatingSign",tolua_AllToLua_Lua__cPlugin_cPlugin__OnUpdatingSign00); + tolua_function(tolua_S,"cPlugin__OnPreCrafting",tolua_AllToLua_Lua__cPlugin_cPlugin__OnPreCrafting00); + tolua_function(tolua_S,"cPlugin__OnTakeDamage",tolua_AllToLua_Lua__cPlugin_cPlugin__OnTakeDamage00); tolua_function(tolua_S,"cPlugin__OnUpdatedSign",tolua_AllToLua_Lua__cPlugin_cPlugin__OnUpdatedSign00); + tolua_function(tolua_S,"cPlugin__OnUpdatingSign",tolua_AllToLua_Lua__cPlugin_cPlugin__OnUpdatingSign00); + tolua_function(tolua_S,"cPlugin__OnWeatherChanged",tolua_AllToLua_Lua__cPlugin_cPlugin__OnWeatherChanged00); tolua_function(tolua_S,"new",tolua_AllToLua_Lua__cPlugin_new00); tolua_function(tolua_S,"new_local",tolua_AllToLua_Lua__cPlugin_new00_local); tolua_function(tolua_S,".call",tolua_AllToLua_Lua__cPlugin_new00_local); @@ -22335,13 +21749,17 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S) tolua_function(tolua_S,"Clear",tolua_AllToLua_cItem_Clear00); tolua_function(tolua_S,"IsEmpty",tolua_AllToLua_cItem_IsEmpty00); tolua_function(tolua_S,"Equals",tolua_AllToLua_cItem_Equals00); + tolua_function(tolua_S,"IsEqual",tolua_AllToLua_cItem_IsEqual00); + tolua_function(tolua_S,"IsSameType",tolua_AllToLua_cItem_IsSameType00); tolua_function(tolua_S,"GetMaxDuration",tolua_AllToLua_cItem_GetMaxDuration00); tolua_function(tolua_S,"DamageItem",tolua_AllToLua_cItem_DamageItem00); tolua_function(tolua_S,"HasDuration",tolua_AllToLua_cItem_HasDuration00); tolua_function(tolua_S,"IsEnchantable",tolua_AllToLua_cItem_IsEnchantable00); tolua_variable(tolua_S,"m_ItemID",tolua_get_cItem_m_ItemID,tolua_set_cItem_m_ItemID); + tolua_variable(tolua_S,"m_ItemType",tolua_get_cItem_m_ItemType,tolua_set_cItem_m_ItemType); tolua_variable(tolua_S,"m_ItemCount",tolua_get_cItem_m_ItemCount,tolua_set_cItem_m_ItemCount); tolua_variable(tolua_S,"m_ItemHealth",tolua_get_cItem_m_ItemHealth,tolua_set_cItem_m_ItemHealth); + tolua_variable(tolua_S,"m_ItemDamage",tolua_get_cItem_m_ItemDamage,tolua_set_cItem_m_ItemDamage); tolua_endmodule(tolua_S); tolua_cclass(tolua_S,"HTTPFormData","HTTPFormData","",NULL); tolua_beginmodule(tolua_S,"HTTPFormData"); @@ -22653,54 +22071,6 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S) tolua_function(tolua_S,"GetBlockSkyLight",tolua_AllToLua_cBlockArea_GetBlockSkyLight00); tolua_function(tolua_S,"GetDataTypes",tolua_AllToLua_cBlockArea_GetDataTypes00); tolua_endmodule(tolua_S); - tolua_cclass(tolua_S,"cPacket_Login","cPacket_Login","cPacket",NULL); - tolua_beginmodule(tolua_S,"cPacket_Login"); - tolua_variable(tolua_S,"m_ProtocolVersion",tolua_get_cPacket_Login_m_ProtocolVersion,tolua_set_cPacket_Login_m_ProtocolVersion); - tolua_variable(tolua_S,"m_Username",tolua_get_cPacket_Login_m_Username,tolua_set_cPacket_Login_m_Username); - tolua_variable(tolua_S,"m_LevelType",tolua_get_cPacket_Login_m_LevelType,tolua_set_cPacket_Login_m_LevelType); - tolua_variable(tolua_S,"m_ServerMode",tolua_get_cPacket_Login_m_ServerMode,tolua_set_cPacket_Login_m_ServerMode); - tolua_variable(tolua_S,"m_Difficulty",tolua_get_cPacket_Login_m_Difficulty,tolua_set_cPacket_Login_m_Difficulty); - tolua_variable(tolua_S,"m_WorldHeight",tolua_get_cPacket_Login_unsigned_m_WorldHeight,tolua_set_cPacket_Login_unsigned_m_WorldHeight); - tolua_variable(tolua_S,"m_MaxPlayers",tolua_get_cPacket_Login_unsigned_m_MaxPlayers,tolua_set_cPacket_Login_unsigned_m_MaxPlayers); - tolua_endmodule(tolua_S); - #ifdef __cplusplus - tolua_cclass(tolua_S,"cPacket_BlockDig","cPacket_BlockDig","cPacket",tolua_collect_cPacket_BlockDig); - #else - tolua_cclass(tolua_S,"cPacket_BlockDig","cPacket_BlockDig","cPacket",NULL); - #endif - tolua_beginmodule(tolua_S,"cPacket_BlockDig"); - tolua_function(tolua_S,"new",tolua_AllToLua_cPacket_BlockDig_new00); - tolua_function(tolua_S,"new_local",tolua_AllToLua_cPacket_BlockDig_new00_local); - tolua_function(tolua_S,".call",tolua_AllToLua_cPacket_BlockDig_new00_local); - tolua_function(tolua_S,"Clone",tolua_AllToLua_cPacket_BlockDig_Clone00); - tolua_variable(tolua_S,"m_Status",tolua_get_cPacket_BlockDig_m_Status,tolua_set_cPacket_BlockDig_m_Status); - tolua_variable(tolua_S,"m_PosX",tolua_get_cPacket_BlockDig_m_PosX,tolua_set_cPacket_BlockDig_m_PosX); - tolua_variable(tolua_S,"m_PosY",tolua_get_cPacket_BlockDig_m_PosY,tolua_set_cPacket_BlockDig_m_PosY); - tolua_variable(tolua_S,"m_PosZ",tolua_get_cPacket_BlockDig_m_PosZ,tolua_set_cPacket_BlockDig_m_PosZ); - tolua_variable(tolua_S,"m_Direction",tolua_get_cPacket_BlockDig_m_Direction,tolua_set_cPacket_BlockDig_m_Direction); - tolua_endmodule(tolua_S); - #ifdef __cplusplus - tolua_cclass(tolua_S,"Lua__cPacket_BlockDig","Lua__cPacket_BlockDig","cPacket_BlockDig",tolua_collect_Lua__cPacket_BlockDig); - #else - tolua_cclass(tolua_S,"Lua__cPacket_BlockDig","Lua__cPacket_BlockDig","cPacket_BlockDig",NULL); - #endif - tolua_beginmodule(tolua_S,"Lua__cPacket_BlockDig"); - tolua_function(tolua_S,"tolua__set_instance",tolua_AllToLua_Lua__cPacket_BlockDig_tolua__set_instance00); - tolua_function(tolua_S,"cPacket_BlockDig__Clone",tolua_AllToLua_Lua__cPacket_BlockDig_cPacket_BlockDig__Clone00); - tolua_function(tolua_S,"new",tolua_AllToLua_Lua__cPacket_BlockDig_new00); - tolua_function(tolua_S,"new_local",tolua_AllToLua_Lua__cPacket_BlockDig_new00_local); - tolua_function(tolua_S,".call",tolua_AllToLua_Lua__cPacket_BlockDig_new00_local); - tolua_endmodule(tolua_S); - tolua_cclass(tolua_S,"cPacket_BlockPlace","cPacket_BlockPlace","cPacket",NULL); - tolua_beginmodule(tolua_S,"cPacket_BlockPlace"); - tolua_variable(tolua_S,"m_PosX",tolua_get_cPacket_BlockPlace_m_PosX,tolua_set_cPacket_BlockPlace_m_PosX); - tolua_variable(tolua_S,"m_PosY",tolua_get_cPacket_BlockPlace_unsigned_m_PosY,tolua_set_cPacket_BlockPlace_unsigned_m_PosY); - tolua_variable(tolua_S,"m_PosZ",tolua_get_cPacket_BlockPlace_m_PosZ,tolua_set_cPacket_BlockPlace_m_PosZ); - tolua_variable(tolua_S,"m_Direction",tolua_get_cPacket_BlockPlace_m_Direction,tolua_set_cPacket_BlockPlace_m_Direction); - tolua_variable(tolua_S,"m_ItemType",tolua_get_cPacket_BlockPlace_m_ItemType,tolua_set_cPacket_BlockPlace_m_ItemType); - tolua_variable(tolua_S,"m_Count",tolua_get_cPacket_BlockPlace_m_Count,tolua_set_cPacket_BlockPlace_m_Count); - tolua_variable(tolua_S,"m_Uses",tolua_get_cPacket_BlockPlace_m_Uses,tolua_set_cPacket_BlockPlace_m_Uses); - tolua_endmodule(tolua_S); tolua_cclass(tolua_S,"cLuaChunk","cLuaChunk","",NULL); tolua_beginmodule(tolua_S,"cLuaChunk"); tolua_function(tolua_S,"FillBlocks",tolua_AllToLua_cLuaChunk_FillBlocks00); diff --git a/source/Bindings.h b/source/Bindings.h index 9244533ce..6b5c612d3 100644 --- a/source/Bindings.h +++ b/source/Bindings.h @@ -1,6 +1,6 @@ /* ** Lua binding: AllToLua -** Generated automatically by tolua++-1.0.92 on 08/11/12 21:48:17. +** Generated automatically by tolua++-1.0.92 on 08/18/12 11:57:21. */ /* Exported function */ diff --git a/source/ByteBuffer.cpp b/source/ByteBuffer.cpp index d25eb8e0b..e410bdfe0 100644 --- a/source/ByteBuffer.cpp +++ b/source/ByteBuffer.cpp @@ -292,6 +292,20 @@ bool cByteBuffer::ReadUTF16String(AString & a_String, int a_NumChars) +bool cByteBuffer::SkipRead(int a_Count)
+{
+ if (!CanReadBytes(a_Count))
+ {
+ return false;
+ }
+ AdvanceReadPos(a_Count);
+ return true;
+}
+
+
+
+
+
void cByteBuffer::CommitRead(void)
{
m_DataStart = m_ReadPos;
diff --git a/source/ByteBuffer.h b/source/ByteBuffer.h index 23be3e922..f49461fce 100644 --- a/source/ByteBuffer.h +++ b/source/ByteBuffer.h @@ -65,8 +65,8 @@ public: /// Reads 2 * a_NumChars bytes and interprets it as a UTF16 string, converting it into UTF8 string a_String
bool ReadUTF16String(AString & a_String, int a_NumChars);
- /// Skips reading by a_Count bytes
- void SkipRead(int a_Count);
+ /// Skips reading by a_Count bytes; returns false if not enough bytes in the ringbuffer
+ bool SkipRead(int a_Count);
/// Removes the bytes that have been read from the ringbuffer
void CommitRead(void);
diff --git a/source/Defines.h b/source/Defines.h index 6dde8cc8f..4f8473ac5 100644 --- a/source/Defines.h +++ b/source/Defines.h @@ -11,7 +11,6 @@ extern unsigned char g_BlockSpreadLightFalloff[]; extern bool g_BlockTransparent[]; // one hit break blocks extern bool g_BlockOneHitDig[]; -//tolua_end //--DO NOT DELETE THIS COMMENT-- //tolua_export @@ -19,15 +18,26 @@ extern bool g_BlockOneHitDig[]; +// Block face constants, used in PlayerDigging and PlayerBlockPlacement packets enum { BLOCK_FACE_BOTTOM = 0, // Interacting with the bottom face of the block BLOCK_FACE_TOP = 1, // Interacting with the top face of the block BLOCK_FACE_NORTH = 2, // Interacting with the northern face of the block BLOCK_FACE_SOUTH = 3, // Interacting with the southern face of the block - BLOCK_FACE_EAST = 5, // Interacting with the eastern face of the block BLOCK_FACE_WEST = 4, // Interacting with the western face of the block + BLOCK_FACE_EAST = 5, // Interacting with the eastern face of the block +} ; + +// PlayerDigging status constants: +enum +{ + DIG_STATUS_STARTED = 0, + DIG_STATUS_FINISHED = 2, + DIG_STATUS_DROP_HELD = 4, + DIG_STATUS_SHOOT_EAT = 5, } ; +//tolua_end diff --git a/source/cClientHandle.cpp b/source/cClientHandle.cpp index c045a4ed7..07cf1c62f 100644 --- a/source/cClientHandle.cpp +++ b/source/cClientHandle.cpp @@ -66,6 +66,7 @@ #include "packets/cPacket_NamedEntitySpawn.h" #include "packets/cPacket_MapChunk.h" #include "packets/cPacket_PreChunk.h" +#include "packets/cPacket_InventorySlot.h" // DEBUG: #include "packets/cPacket_BlockChange.h" @@ -492,6 +493,11 @@ void cClientHandle::RemoveFromAllChunks() void cClientHandle::HandlePacket(cPacket * a_Packet) { + // TODO: _X: This function will get out-sourced into a separate cProtocol class + // and the switch statements will be split into virtual functions of that class + // Therefore I keep this function huge and untidy for the time being + // ( http://forum.mc-server.org/showthread.php?tid=524 ) + m_TimeLastPacket = cWorld::GetTime(); // LOG("Recv packet 0x%02x from client \"%s\" (\"%s\")", a_Packet->m_PacketID, m_Socket.GetIPString().c_str(), m_Username.c_str()); @@ -513,8 +519,18 @@ void cClientHandle::HandlePacket(cPacket * a_Packet) break; } case E_PING: HandlePing (); break; - case E_HANDSHAKE: HandleHandshake(reinterpret_cast<cPacket_Handshake *>(a_Packet)); break; - case E_LOGIN: HandleLogin (reinterpret_cast<cPacket_Login *> (a_Packet)); break; + case E_HANDSHAKE: + { + cPacket_Handshake * Handshake = reinterpret_cast<cPacket_Handshake *>(a_Packet); + HandleHandshake(Handshake->m_Username); + break; + } + case E_LOGIN: + { + cPacket_Login * Login = reinterpret_cast<cPacket_Login *>(a_Packet); + HandleLogin(Login->m_ProtocolVersion, Login->m_Username); + break; + } // Ignored packets: case E_PLAYERLOOK: @@ -522,7 +538,7 @@ void cClientHandle::HandlePacket(cPacket * a_Packet) case E_PLAYERMOVELOOK: case E_PLAYERPOS: case E_KEEP_ALIVE: break; - default: HandleUnexpectedPacket(a_Packet); break; + default: HandleUnexpectedPacket(a_Packet->m_PacketID); break; } // switch (PacketType) break; } // case csConnected @@ -540,7 +556,7 @@ void cClientHandle::HandlePacket(cPacket * a_Packet) case E_PLAYERMOVELOOK: case E_PLAYERPOS: break; - default: HandleUnexpectedPacket(a_Packet); break; + default: HandleUnexpectedPacket(a_Packet->m_PacketID); break; } break; } @@ -558,7 +574,7 @@ void cClientHandle::HandlePacket(cPacket * a_Packet) case E_PLAYERMOVELOOK: case E_PLAYERPOS: break; - default: HandleUnexpectedPacket(a_Packet); break; + default: HandleUnexpectedPacket(a_Packet->m_PacketID); break; } break; } @@ -574,11 +590,16 @@ void cClientHandle::HandlePacket(cPacket * a_Packet) case E_PLAYERLOOK: case E_PLAYERPOS: break; - case E_PLAYERMOVELOOK: HandleMoveLookConfirm(reinterpret_cast<cPacket_PlayerMoveLook *>(a_Packet)); break; + case E_PLAYERMOVELOOK: + { + cPacket_PlayerMoveLook * MoveLook = reinterpret_cast<cPacket_PlayerMoveLook *>(a_Packet); + HandleMoveLookConfirm(MoveLook->m_PosX, MoveLook->m_PosY, MoveLook->m_PosZ); + break; + } default: { - HandleUnexpectedPacket(a_Packet); + HandleUnexpectedPacket(a_Packet->m_PacketID); break; } } // switch (PacketType) @@ -589,10 +610,30 @@ void cClientHandle::HandlePacket(cPacket * a_Packet) { switch (a_Packet->m_PacketID) { - case E_CREATIVE_INVENTORY_ACTION: HandleCreativeInventory(reinterpret_cast<cPacket_CreativeInventoryAction *>(a_Packet)); break; - case E_PLAYERPOS: HandlePlayerPos (reinterpret_cast<cPacket_PlayerPosition *> (a_Packet)); break; - case E_BLOCK_DIG: HandleBlockDig (reinterpret_cast<cPacket_BlockDig *> (a_Packet)); break; - case E_BLOCK_PLACE: HandleBlockPlace (reinterpret_cast<cPacket_BlockPlace *> (a_Packet)); break; + case E_CREATIVE_INVENTORY_ACTION: + { + cPacket_CreativeInventoryAction * cia = reinterpret_cast<cPacket_CreativeInventoryAction *>(a_Packet); + HandleCreativeInventory(cia->m_SlotNum, cia->m_ClickedItem); + break; + } + case E_PLAYERPOS: + { + cPacket_PlayerPosition * pp = reinterpret_cast<cPacket_PlayerPosition *>(a_Packet); + HandlePlayerPos(pp->m_PosX, pp->m_PosY, pp->m_PosZ, pp->m_Stance, pp->m_IsOnGround); + break; + } + case E_BLOCK_DIG: + { + cPacket_BlockDig * bd = reinterpret_cast<cPacket_BlockDig *>(a_Packet); + HandleBlockDig(bd->m_PosX, bd->m_PosY, bd->m_PosZ, bd->m_Direction, bd->m_Status); + break; + } + case E_BLOCK_PLACE: + { + cPacket_BlockPlace * bp = reinterpret_cast<cPacket_BlockPlace *>(a_Packet); + HandleBlockPlace(bp->m_PosX, bp->m_PosY, bp->m_PosZ, bp->m_Direction, bp->m_HeldItem); + break; + } case E_PICKUP_SPAWN: HandlePickupSpawn (reinterpret_cast<cPacket_PickupSpawn *> (a_Packet)); break; case E_CHAT: HandleChat (reinterpret_cast<cPacket_Chat *> (a_Packet)); break; case E_PLAYERLOOK: HandlePlayerLook (reinterpret_cast<cPacket_PlayerLook *> (a_Packet)); break; @@ -600,7 +641,12 @@ void cClientHandle::HandlePacket(cPacket * a_Packet) case E_ANIMATION: HandleAnimation (reinterpret_cast<cPacket_ArmAnim *> (a_Packet)); break; case E_ITEM_SWITCH: HandleItemSwitch (reinterpret_cast<cPacket_ItemSwitch *> (a_Packet)); break; case E_WINDOW_CLOSE: HandleWindowClose (reinterpret_cast<cPacket_WindowClose *> (a_Packet)); break; - case E_WINDOW_CLICK: HandleWindowClick (reinterpret_cast<cPacket_WindowClick *> (a_Packet)); break; + case E_WINDOW_CLICK: + { + cPacket_WindowClick * wc = reinterpret_cast<cPacket_WindowClick *>(a_Packet); + HandleWindowClick(wc->m_WindowID, wc->m_SlotNum, wc->m_IsRightClick, wc->m_IsShiftPressed, wc->m_HeldItem); + break; + } case E_UPDATE_SIGN: HandleUpdateSign (reinterpret_cast<cPacket_UpdateSign *> (a_Packet)); break; case E_USE_ENTITY: HandleUseEntity (reinterpret_cast<cPacket_UseEntity *> (a_Packet)); break; case E_RESPAWN: HandleRespawn(); break; @@ -634,17 +680,17 @@ void cClientHandle::HandlePing(void) -void cClientHandle::HandleHandshake(cPacket_Handshake * a_Packet) +void cClientHandle::HandleHandshake(const AString & a_Username) { - AStringVector UserData = StringSplit( a_Packet->m_Username, ";" ); // "FakeTruth;localhost:25565" - if( UserData.size() == 0 ) + AStringVector UserData = StringSplit(a_Username, ";"); // "FakeTruth;localhost:25565" + if (UserData.empty()) { - Kick("Could not receive username"); + Kick("Did not receive username"); return; } m_Username = UserData[0]; - LOG("HANDSHAKE %s", m_Username.c_str()); + LOGD("HANDSHAKE %s", m_Username.c_str()); if (cRoot::Get()->GetDefaultWorld()->GetNumPlayers() >= cRoot::Get()->GetDefaultWorld()->GetMaxPlayers()) { @@ -654,9 +700,7 @@ void cClientHandle::HandleHandshake(cPacket_Handshake * a_Packet) cPacket_Chat Connecting(m_Username + " is connecting."); cRoot::Get()->GetServer()->Broadcast(Connecting, this); - cPacket_Handshake Handshake; - Handshake.m_Username = cRoot::Get()->GetServer()->GetServerID(); - Send(Handshake); + SendHandshake(cRoot::Get()->GetServer()->GetServerID()); LOG("User \"%s\" was sent a handshake", m_Username.c_str()); } @@ -664,23 +708,23 @@ void cClientHandle::HandleHandshake(cPacket_Handshake * a_Packet) -void cClientHandle::HandleLogin(cPacket_Login * a_Packet) +void cClientHandle::HandleLogin(int a_ProtocolVersion, const AString & a_Username) { - LOG("LOGIN %s", m_Username.c_str()); - if (a_Packet->m_ProtocolVersion < m_ProtocolVersion) + LOGD("LOGIN %s", a_Username.c_str()); + if (a_ProtocolVersion < m_ProtocolVersion) { Kick("Your client is outdated!"); return; } - else if (a_Packet->m_ProtocolVersion > m_ProtocolVersion) + else if (a_ProtocolVersion > m_ProtocolVersion) { Kick("Your client version is higher than the server!"); return; } - if (m_Username.compare(a_Packet->m_Username) != 0) + if (m_Username.compare(a_Username) != 0) { - LOGWARNING("Login Username (\"%s\") does not match Handshake username (\"%s\") for client \"%s\")", - a_Packet->m_Username.c_str(), + LOGWARNING("Login Username (\"%s\") does not match Handshake username (\"%s\") for client @ \"%s\")", + a_Username.c_str(), m_Username.c_str(), m_Socket.GetIPString().c_str() ); @@ -688,7 +732,7 @@ void cClientHandle::HandleLogin(cPacket_Login * a_Packet) return; } - if (cRoot::Get()->GetPluginManager()->CallHook(cPluginManager::HOOK_LOGIN, 1, a_Packet)) + if (cRoot::Get()->GetPluginManager()->CallHookLogin(this, a_ProtocolVersion, a_Username)) { Destroy(); return; @@ -703,12 +747,12 @@ void cClientHandle::HandleLogin(cPacket_Login * a_Packet) -void cClientHandle::HandleUnexpectedPacket(cPacket * a_Packet) +void cClientHandle::HandleUnexpectedPacket(int a_PacketType) { LOGWARNING( "Invalid packet in state %d: 0x%02x from client \"%s\", username \"%s\"", m_State, - a_Packet->m_PacketID, + a_PacketType, m_Socket.GetIPString().c_str(), m_Username.c_str() ); @@ -719,9 +763,9 @@ void cClientHandle::HandleUnexpectedPacket(cPacket * a_Packet) -void cClientHandle::HandleMoveLookConfirm(cPacket_PlayerMoveLook * a_Packet) +void cClientHandle::HandleMoveLookConfirm(double a_PosX, double a_PosY, double a_PosZ) { - Vector3d ReceivedPosition = Vector3d(a_Packet->m_PosX, a_Packet->m_PosY, a_Packet->m_PosZ); + Vector3d ReceivedPosition = Vector3d(a_PosX, a_PosY, a_PosZ); // Test the distance between points with a small/large enough value instead of comparing directly. Floating point inaccuracies might screw stuff up double Dist = (ReceivedPosition - m_ConfirmPosition).SqrLength(); @@ -746,12 +790,12 @@ void cClientHandle::HandleMoveLookConfirm(cPacket_PlayerMoveLook * a_Packet) -void cClientHandle::HandleCreativeInventory(cPacket_CreativeInventoryAction * a_Packet) +void cClientHandle::HandleCreativeInventory(short a_SlotNum, const cItem & a_HeldItem) { // This is for creative Inventory changes if (m_Player->GetGameMode() == 1) { - m_Player->GetInventory().Clicked(a_Packet); + m_Player->GetInventory().Clicked(a_SlotNum, false, false, a_HeldItem); } else { @@ -763,84 +807,86 @@ void cClientHandle::HandleCreativeInventory(cPacket_CreativeInventoryAction * a_ -void cClientHandle::HandlePlayerPos(cPacket_PlayerPosition * a_Packet) +void cClientHandle::HandlePlayerPos(double a_PosX, double a_PosY, double a_PosZ, double a_Stance, bool a_IsOnGround) { // LOG("recv player pos: %0.2f %0.2f %0.2f", PacketData->m_PosX, PacketData->m_PosY, PacketData->m_PosZ); - m_Player->MoveTo(Vector3d(a_Packet->m_PosX, a_Packet->m_PosY, a_Packet->m_PosZ)); - m_Player->SetStance(a_Packet->m_Stance); - m_Player->SetTouchGround(a_Packet->m_bFlying); + m_Player->MoveTo(Vector3d(a_PosX, a_PosY, a_PosZ)); + m_Player->SetStance(a_Stance); + m_Player->SetTouchGround(a_IsOnGround); } -void cClientHandle::HandleBlockDig(cPacket_BlockDig * a_Packet) +void cClientHandle::HandleBlockDig(int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status) { if (!CheckBlockInteractionsRate()) { return; } - LOGD("OnBlockDig: {%i, %i, %i} Dir: %i Stat: %i", - a_Packet->m_PosX, a_Packet->m_PosY, a_Packet->m_PosZ, - a_Packet->m_Direction, a_Packet->m_Status + LOGD("OnBlockDig: {%i, %i, %i}; Face: %i; Stat: %i", + a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_Status ); // Do we want plugins to disable tossing items? Probably no, so toss item before asking plugins for permission - if (a_Packet->m_Status == 0x04) // Drop held item + if (a_Status == DIG_STATUS_DROP_HELD) // Drop held item { m_Player->TossItem(false); return; } - if (a_Packet->m_Status == 0x05) + if (a_Status == DIG_STATUS_SHOOT_EAT) { - LOGINFO("BlockDig: Status 5 not implemented"); + LOGINFO("BlockDig: Status SHOOT/EAT not implemented"); + return; } - cWorld* World = m_Player->GetWorld(); - BLOCKTYPE OldBlock = World->GetBlock(a_Packet->m_PosX, a_Packet->m_PosY, a_Packet->m_PosZ); - NIBBLETYPE OldMeta = World->GetBlockMeta(a_Packet->m_PosX, a_Packet->m_PosY, a_Packet->m_PosZ); + cWorld * World = m_Player->GetWorld(); + BLOCKTYPE OldBlock; + NIBBLETYPE OldMeta; + World->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, OldBlock, OldMeta); - if (cRoot::Get()->GetPluginManager()->CallHook(cPluginManager::HOOK_BLOCK_DIG, 4, a_Packet, m_Player, OldBlock, OldMeta)) + if (cRoot::Get()->GetPluginManager()->CallHookBlockDig(m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_Status, OldBlock, OldMeta)) { // The plugin doesn't agree with the digging, replace the block on the client and quit: - World->SendBlockTo(a_Packet->m_PosX, a_Packet->m_PosY, a_Packet->m_PosZ, m_Player); + World->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player); return; } bool bBroken = ( - (a_Packet->m_Status == 0x02) || + (a_Status == DIG_STATUS_FINISHED) || (g_BlockOneHitDig[(int)OldBlock]) || - ((a_Packet->m_Status == 0x00) && (m_Player->GetGameMode() == 1)) + ((a_Status == DIG_STATUS_STARTED) && (m_Player->GetGameMode() == 1)) ); - cItem &Equipped = m_Player->GetInventory().GetEquippedItem(); - - cItemHandler *ItemHandler = cItemHandler::GetItemHandler(Equipped.m_ItemID); + cItem & Equipped = m_Player->GetInventory().GetEquippedItem(); + cItemHandler * ItemHandler = cItemHandler::GetItemHandler(Equipped.m_ItemID); - if(bBroken) + if (bBroken) { - ItemHandler->OnBlockDestroyed(World, m_Player, &Equipped, a_Packet->m_PosX, a_Packet->m_PosY, a_Packet->m_PosZ); + ItemHandler->OnBlockDestroyed(World, m_Player, &Equipped, a_BlockX, a_BlockY, a_BlockZ); - BlockHandler(OldBlock)->OnDestroyedByPlayer(World, m_Player, a_Packet->m_PosX, a_Packet->m_PosY, a_Packet->m_PosZ); - World->DigBlock(a_Packet->m_PosX, a_Packet->m_PosY, a_Packet->m_PosZ); - }else{ - cBlockHandler *Handler = cBlockHandler::GetBlockHandler(OldBlock); - Handler->OnClick(World, m_Player, a_Packet->m_PosX, a_Packet->m_PosY, a_Packet->m_PosZ); + BlockHandler(OldBlock)->OnDestroyedByPlayer(World, m_Player, a_BlockX, a_BlockY, a_BlockZ); + World->DigBlock(a_BlockX, a_BlockY, a_BlockZ); + } + else + { + cBlockHandler * Handler = cBlockHandler::GetBlockHandler(OldBlock); + Handler->OnClick(World, m_Player, a_BlockX, a_BlockY, a_BlockZ); - ItemHandler->OnDiggingBlock(World, m_Player, &Equipped, a_Packet->m_PosX, a_Packet->m_PosY, a_Packet->m_PosZ, a_Packet->m_Direction); + ItemHandler->OnDiggingBlock(World, m_Player, &Equipped, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace); - //Check for clickthrough-blocks: - int pX = a_Packet->m_PosX; - unsigned char pY = a_Packet->m_PosY; - int pZ = a_Packet->m_PosZ; - AddDirection(pX, pY, pZ, a_Packet->m_Direction); + // Check for clickthrough-blocks: + int pX = a_BlockX; + unsigned char pY = a_BlockY; + int pZ = a_BlockZ; + AddDirection(pX, pY, pZ, a_BlockFace); Handler = cBlockHandler::GetBlockHandler(World->GetBlock(pX, pY, pZ)); - if(Handler->IsClickedThrough()) + if (Handler->IsClickedThrough()) { Handler->OnClick(World, m_Player, pX, pY, pZ); } @@ -851,9 +897,8 @@ void cClientHandle::HandleBlockDig(cPacket_BlockDig * a_Packet) -void cClientHandle::HandleBlockPlace(cPacket_BlockPlace * a_Packet) +void cClientHandle::HandleBlockPlace(int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, const cItem & a_HeldItem) { - if (!CheckBlockInteractionsRate()) { return; @@ -861,94 +906,105 @@ void cClientHandle::HandleBlockPlace(cPacket_BlockPlace * a_Packet) cItem & Equipped = m_Player->GetInventory().GetEquippedItem(); - if ((Equipped.m_ItemID != a_Packet->m_ItemType)) // Not valid + if ((Equipped.m_ItemID != a_HeldItem.m_ItemType)) // Not valid { LOGWARN("Player %s tried to place a block that was not equipped (exp %d, got %d)", - m_Username.c_str(), Equipped.m_ItemID, a_Packet->m_ItemType + m_Username.c_str(), Equipped.m_ItemType, a_HeldItem.m_ItemType ); - // TODO: We should probably send the current world block to the client, so that it can immediately "let the user know" that they haven't placed the block + + // Let's send the current world block to the client, so that it can immediately "let the user know" that they haven't placed the block + if (a_BlockFace > -1) + { + AddDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace); + m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player); + } return; } - if (cRoot::Get()->GetPluginManager()->CallHook(cPluginManager::HOOK_BLOCK_PLACE, 2, a_Packet, m_Player)) + if (cRoot::Get()->GetPluginManager()->CallHookBlockPlace(m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_HeldItem)) { - if (a_Packet->m_Direction > -1) + if (a_BlockFace > -1) { - AddDirection(a_Packet->m_PosX, a_Packet->m_PosY, a_Packet->m_PosZ, a_Packet->m_Direction); - m_Player->GetWorld()->SendBlockTo(a_Packet->m_PosX, a_Packet->m_PosY, a_Packet->m_PosZ, m_Player); + AddDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace); + m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player); } return; } cWorld * World = m_Player->GetWorld(); - cBlockHandler *Handler = cBlockHandler::GetBlockHandler(World->GetBlock(a_Packet->m_PosX, a_Packet->m_PosY, a_Packet->m_PosZ)); + cBlockHandler *Handler = cBlockHandler::GetBlockHandler(World->GetBlock(a_BlockX, a_BlockY, a_BlockZ)); if (Handler->IsUseable()) { - Handler->OnClick(World, m_Player, a_Packet->m_PosX, a_Packet->m_PosY, a_Packet->m_PosZ); + Handler->OnClick(World, m_Player, a_BlockX, a_BlockY, a_BlockZ); } else { - cItemHandler *ItemHandler = cItemHandler::GetItemHandler(Equipped.m_ItemID); + cItemHandler * ItemHandler = cItemHandler::GetItemHandler(Equipped.m_ItemID); - if(ItemHandler->OnItemUse(World, m_Player, &Equipped, a_Packet->m_PosX, a_Packet->m_PosY, a_Packet->m_PosZ, a_Packet->m_Direction)) + if (ItemHandler->OnItemUse(World, m_Player, &Equipped, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace)) { - //Nothing here :P - }else if(ItemHandler->IsPlaceable()) + // Nothing here :P + } + else if (ItemHandler->IsPlaceable()) { - if (a_Packet->m_Direction < 0) + if (a_BlockFace < 0) { // clicked in air return; } - int X = a_Packet->m_PosX; - int Y = a_Packet->m_PosY; - int Z = a_Packet->m_PosZ; - char Dir = a_Packet->m_Direction; - BLOCKTYPE ClickedBlock = World->GetBlock(X, Y, Z); + BLOCKTYPE ClickedBlock = World->GetBlock(a_BlockX, a_BlockY, a_BlockZ); cBlockHandler *Handler = cBlockHandler::GetBlockHandler(ClickedBlock); if(Handler->IgnoreBuildCollision()) { - Handler->OnDestroyedByPlayer(World, m_Player, X, Y, Z); - World->FastSetBlock(X, Y, Z, E_BLOCK_AIR, 0); - }else{ - AddDirection(X, Y, Z, a_Packet->m_Direction); - //Check for Blocks not allowing placement on top - if(Dir == 1 && !Handler->AllowBlockOnTop()) + Handler->OnDestroyedByPlayer(World, m_Player, a_BlockX, a_BlockY, a_BlockZ); + World->FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0); + } + else + { + AddDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace); + // Check for Blocks not allowing placement on top + if ((a_BlockFace == BLOCK_FACE_TOP) && !Handler->AllowBlockOnTop()) { - //Resend the old block - //Some times the client still places the block O.o + // Resend the old block + // Some times the client still places the block O.o - World->SendBlockTo(X, Y, Z, m_Player); + World->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player); return; } - int PlaceBlock = m_Player->GetWorld()->GetBlock(X, Y, Z); + int PlaceBlock = m_Player->GetWorld()->GetBlock(a_BlockX, a_BlockY, a_BlockZ); if (!BlockHandler(PlaceBlock)->IgnoreBuildCollision()) { - //tried to place a block *into* another? - return; // happens when you place a block aiming at side of block like torch or stem + // Tried to place a block *into* another? + return; // Happens when you place a block aiming at side of block like torch or stem } } - cBlockHandler *NewBlock = BlockHandler(ItemHandler->GetBlockType()); + cBlockHandler * NewBlock = BlockHandler(ItemHandler->GetBlockType()); - //cannot be placed on the side of an other block - if(Dir != 1 && !NewBlock->CanBePlacedOnSide()) + // Cannot be placed on the side of an other block + if ((a_BlockFace != BLOCK_FACE_TOP) && !NewBlock->CanBePlacedOnSide()) + { return; + } - if(NewBlock->CanBePlacedAt(World, X, Y, Z, Dir)) + if (NewBlock->CanBePlacedAt(World, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace)) { - ItemHandler->PlaceBlock(World, m_Player, &m_Player->GetInventory().GetEquippedItem(), X, Y, Z, a_Packet->m_Direction); - }else{ - World->SendBlockTo(X, Y, Z, m_Player); //Send the old block back to the player + ItemHandler->PlaceBlock(World, m_Player, &m_Player->GetInventory().GetEquippedItem(), a_BlockX, a_BlockY, a_BlockZ, a_BlockFace); + } + else + { + World->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player); // Send the old block back to the player return; } - } else if(ItemHandler->IsFood()) { + } + else if (ItemHandler->IsFood()) + { cItem Item; Item.m_ItemID = Equipped.m_ItemID; Item.m_ItemCount = 1; @@ -1058,11 +1114,11 @@ void cClientHandle::HandleWindowClose(cPacket_WindowClose * a_Packet) -void cClientHandle::HandleWindowClick(cPacket_WindowClick * a_Packet) +void cClientHandle::HandleWindowClick(int a_WindowID, short a_SlotNum, bool a_IsRightClick, bool a_IsShiftPressed, const cItem & a_HeldItem) { - if (a_Packet->m_WindowID == 0) + if (a_WindowID == 0) { - m_Player->GetInventory().Clicked(a_Packet); + m_Player->GetInventory().Clicked(a_SlotNum, a_IsRightClick, a_IsShiftPressed, a_HeldItem); return; } @@ -1073,7 +1129,7 @@ void cClientHandle::HandleWindowClick(cPacket_WindowClick * a_Packet) return; } - Window->Clicked(a_Packet, *m_Player); + Window->Clicked(*m_Player, a_WindowID, a_SlotNum, a_IsRightClick, a_IsShiftPressed, a_HeldItem); } @@ -1361,7 +1417,32 @@ void cClientHandle::Send(const cPacket & a_Packet, ENUM_PRIORITY a_Priority /* = void cClientHandle::SendDisconnect(const AString & a_Reason) { cPacket_Disconnect DC(a_Reason); - m_Socket.Send(&DC); + m_Socket.Send(&DC); // Send it immediately to the socket, bypassing any packet buffers +} + + + + + +void cClientHandle::SendHandshake(const AString & a_ServerName) +{ + cPacket_Handshake Handshake; + Handshake.m_Username = a_ServerName; + Send(Handshake); +} + + + + + +void cClientHandle::SendInventorySlot(int a_WindowID, short a_SlotNum, const cItem & a_Item) +{ + cPacket_InventorySlot Packet; + Packet.m_WindowID = (char)a_WindowID; + Packet.m_SlotNum = a_SlotNum; + Packet.m_ItemID = (short)(a_Item.m_ItemID); + Packet.m_ItemCount = a_Item.m_ItemCount; + Packet.m_ItemUses = a_Item.m_ItemHealth; } diff --git a/source/cClientHandle.h b/source/cClientHandle.h index aee835337..1085f4695 100644 --- a/source/cClientHandle.h +++ b/source/cClientHandle.h @@ -103,6 +103,8 @@ public: void Send(const cPacket & a_Packet, ENUM_PRIORITY a_Priority = E_PRIORITY_NORMAL); void SendDisconnect(const AString & a_Reason); + void SendHandshake (const AString & a_ServerName); + void SendInventorySlot(int a_WindowID, short a_SlotNum, const cItem & a_Item); const AString & GetUsername(void) const; //tolua_export @@ -182,18 +184,18 @@ private: // Packets handled in csConnected: void HandlePing (void); - void HandleHandshake (cPacket_Handshake * a_Packet); - void HandleLogin (cPacket_Login * a_Packet); - void HandleUnexpectedPacket(cPacket * a_Packet); // the default case -> kick + void HandleHandshake (const AString & a_Username); + void HandleLogin (int a_ProtocolVersion, const AString & a_Username); + void HandleUnexpectedPacket(int a_PacketType); // the default case -> kick // Packets handled while in csConfirmingPos: - void HandleMoveLookConfirm(cPacket_PlayerMoveLook * a_Packet); // While !m_bPositionConfirmed + void HandleMoveLookConfirm(double a_PosX, double a_PosY, double a_PosZ); // While !m_bPositionConfirmed // Packets handled while in csPlaying: - void HandleCreativeInventory(cPacket_CreativeInventoryAction * a_Packet); - void HandlePlayerPos (cPacket_PlayerPosition * a_Packet); - void HandleBlockDig (cPacket_BlockDig * a_Packet); - void HandleBlockPlace (cPacket_BlockPlace * a_Packet); + void HandleCreativeInventory(short a_SlotNum, const cItem & a_HeldItem); + void HandlePlayerPos (double a_PosX, double a_PosY, double a_PosZ, double a_Stance, bool a_IsOnGround); + void HandleBlockDig (int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status); + void HandleBlockPlace (int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, const cItem & a_HeldItem); void HandlePickupSpawn (cPacket_PickupSpawn * a_Packet); void HandleChat (cPacket_Chat * a_Packet); void HandlePlayerLook (cPacket_PlayerLook * a_Packet); @@ -201,7 +203,7 @@ private: void HandleAnimation (cPacket_ArmAnim * a_Packet); void HandleItemSwitch (cPacket_ItemSwitch * a_Packet); void HandleWindowClose (cPacket_WindowClose * a_Packet); - void HandleWindowClick (cPacket_WindowClick * a_Packet); + void HandleWindowClick (int a_WindowID, short a_SlotNum, bool a_IsRightClick, bool a_IsShiftPressed, const cItem & a_HeldItem); void HandleUpdateSign (cPacket_UpdateSign * a_Packet); void HandleUseEntity (cPacket_UseEntity * a_Packet); void HandleRespawn (void); diff --git a/source/cCraftingWindow.cpp b/source/cCraftingWindow.cpp index 40e41f2c4..0f03167c8 100644 --- a/source/cCraftingWindow.cpp +++ b/source/cCraftingWindow.cpp @@ -10,9 +10,7 @@ #include "cPickup.h" #include "cRoot.h" #include "cWorld.h" - -#include "packets/cPacket_WindowClick.h" -#include "packets/cPacket_InventorySlot.h" +#include "items/Item.h" @@ -44,33 +42,38 @@ cCraftingWindow::cCraftingWindow( cWindowOwner* a_Owner, bool a_bInventoryVisibl -void cCraftingWindow::Clicked( cPacket_WindowClick* a_ClickPacket, cPlayer & a_Player ) +void cCraftingWindow::Clicked( + cPlayer & a_Player, + int a_WindowID, short a_SlotNum, bool a_IsRightClick, bool a_IsShiftPressed, + const cItem & a_HeldItem +) { bool bDontCook = false; cItem * DraggingItem = GetDraggingItem(&a_Player); if ( - a_ClickPacket->m_IsShiftPressed && + a_IsShiftPressed && ((DraggingItem == NULL) || DraggingItem->IsEmpty()) ) { - ShiftClicked(a_ClickPacket, a_Player); + ShiftClicked(a_Player, a_SlotNum); return; } // Override for craft result slot - if (a_ClickPacket->m_SlotNum == 0) + if (a_SlotNum == 0) { - LOG("In craft slot: %i x %i !!", GetSlot(0)->m_ItemID, GetSlot(0)->m_ItemCount ); - cItem* DraggingItem = GetDraggingItem( &a_Player ); - if( DraggingItem->m_ItemID <= 0 ) + LOGD("Clicked in craft result slot, item there: %d:%d (%d times) !!", GetSlot(0)->m_ItemID, GetSlot(0)->m_ItemHealth, GetSlot(0)->m_ItemCount); + cItem * DraggingItem = GetDraggingItem(&a_Player); + if (DraggingItem->IsEmpty()) { *DraggingItem = *GetSlot(0); GetSlot(0)->Empty(); } - else if( DraggingItem->Equals( *GetSlot(0) ) ) + else if (DraggingItem->IsEqual(*GetSlot(0))) { - if( DraggingItem->m_ItemCount + GetSlot(0)->m_ItemCount <= 64 ) + cItemHandler * Handler = ItemHandler(GetSlot(0)->m_ItemID); + if (DraggingItem->m_ItemCount + GetSlot(0)->m_ItemCount <= Handler->GetMaxStackSize()) { DraggingItem->m_ItemCount += GetSlot(0)->m_ItemCount; GetSlot(0)->Empty(); @@ -84,21 +87,20 @@ void cCraftingWindow::Clicked( cPacket_WindowClick* a_ClickPacket, cPlayer & a_P { bDontCook = true; } - LOG("Dragging Dish %i", DraggingItem->m_ItemCount ); } else { - cWindow::Clicked( a_ClickPacket, a_Player ); + cWindow::Clicked(a_Player, GetWindowID(), a_SlotNum, a_IsRightClick, a_IsShiftPressed, a_HeldItem); } - if ((a_ClickPacket->m_SlotNum >= 0) && (a_ClickPacket->m_SlotNum < 10)) + if ((a_SlotNum >= 0) && (a_SlotNum < 10)) { cCraftingGrid Grid(GetSlots() + 1, 3, 3); cCraftingRecipe Recipe(Grid); cRoot::Get()->GetCraftingRecipes()->GetRecipe(&a_Player, Grid, Recipe); - if ((a_ClickPacket->m_SlotNum == 0) && !bDontCook) + if ((a_SlotNum == 0) && !bDontCook) { // Consume the items from the crafting grid: Recipe.ConsumeIngredients(Grid); @@ -110,19 +112,13 @@ void cCraftingWindow::Clicked( cPacket_WindowClick* a_ClickPacket, cPlayer & a_P cRoot::Get()->GetCraftingRecipes()->GetRecipe(&a_Player, Grid, Recipe); } *GetSlot(0) = Recipe.GetResult(); - LOGD("%s cooked: %i x %i !!", a_Player.GetName().c_str(), GetSlot(0)->m_ItemID, GetSlot(0)->m_ItemCount ); + LOGD("%s cooked: %d:%d (%d times) !!", a_Player.GetName().c_str(), GetSlot(0)->m_ItemID, GetSlot(0)->m_ItemHealth, GetSlot(0)->m_ItemCount); } SendWholeWindow( a_Player.GetClientHandle() ); a_Player.GetInventory().SendWholeInventory( a_Player.GetClientHandle() ); // Separate packet for result =/ Don't know why - cPacket_InventorySlot Packet; - Packet.m_WindowID = (char)GetWindowID(); - Packet.m_SlotNum = 0; - Packet.m_ItemID = (short)GetSlot(0)->m_ItemID; - Packet.m_ItemCount = GetSlot(0)->m_ItemCount; - Packet.m_ItemUses = (char)GetSlot(0)->m_ItemHealth; - a_Player.GetClientHandle()->Send( Packet ); + a_Player.GetClientHandle()->SendInventorySlot(GetWindowID(), 0, *GetSlot(0)); } @@ -153,16 +149,15 @@ void cCraftingWindow::Close(cPlayer & a_Player) -void cCraftingWindow::ShiftClicked(cPacket_WindowClick * a_ClickPacket, cPlayer & a_Player) +void cCraftingWindow::ShiftClicked(cPlayer & a_Player, short a_SlotNum) { - short Slot = a_ClickPacket->m_SlotNum; - if (Slot == SLOT_CRAFTING_RESULT) + if (a_SlotNum == SLOT_CRAFTING_RESULT) { - ShiftClickedCraftingResult(Slot, a_Player); + ShiftClickedCraftingResult(a_Player, a_SlotNum); } - else if ((Slot >= SLOT_CRAFTING_MIN) && (Slot <= SLOT_CRAFTING_MAX)) + else if ((a_SlotNum >= SLOT_CRAFTING_MIN) && (a_SlotNum <= SLOT_CRAFTING_MAX)) { - ShiftClickedCraftingGrid(Slot, a_Player); + ShiftClickedCraftingGrid(a_Player, a_SlotNum); } else { @@ -175,7 +170,7 @@ void cCraftingWindow::ShiftClicked(cPacket_WindowClick * a_ClickPacket, cPlayer -void cCraftingWindow::ShiftClickedCraftingResult(short a_Slot, cPlayer & a_Player) +void cCraftingWindow::ShiftClickedCraftingResult(cPlayer & a_Player, short a_Slot) { // Craft until either the recipe changes (due to ingredients) or there's not enough storage for the result cInventory & Inventory = a_Player.GetInventory(); @@ -210,7 +205,7 @@ void cCraftingWindow::ShiftClickedCraftingResult(short a_Slot, cPlayer & a_Playe GetSlots()[SLOT_CRAFTING_RESULT] = Recipe.GetResult(); // If the recipe changed, abort: - if (!Recipe.GetResult().Equals(ResultCopy)) + if (!Recipe.GetResult().IsEqual(ResultCopy)) { break; } @@ -221,7 +216,7 @@ void cCraftingWindow::ShiftClickedCraftingResult(short a_Slot, cPlayer & a_Playe -void cCraftingWindow::ShiftClickedCraftingGrid(short a_Slot, cPlayer & a_Player) +void cCraftingWindow::ShiftClickedCraftingGrid(cPlayer & a_Player, short a_Slot) { cInventory & Inventory = a_Player.GetInventory(); cItem * Item = GetSlot(a_Slot); diff --git a/source/cCraftingWindow.h b/source/cCraftingWindow.h index 70a731a65..638b1aa53 100644 --- a/source/cCraftingWindow.h +++ b/source/cCraftingWindow.h @@ -25,12 +25,17 @@ public: cCraftingWindow(cWindowOwner * a_Owner, bool a_bInventoryVisible); - virtual void Clicked(cPacket_WindowClick * a_ClickPacket, cPlayer & a_Player); - virtual void Close(cPlayer & a_Player); + virtual void Clicked( + cPlayer & a_Player, + int a_WindowID, short a_SlotNum, bool a_IsRightClick, bool a_IsShiftPressed, + const cItem & a_HeldItem + ) override; - void ShiftClicked(cPacket_WindowClick * a_ClickPacket, cPlayer & a_Player); - void ShiftClickedCraftingResult(short a_Slot, cPlayer & a_Player); - void ShiftClickedCraftingGrid (short a_Slot, cPlayer & a_Player); + virtual void Close(cPlayer & a_Player) override; + + void ShiftClicked(cPlayer & a_Player, short a_SlotNum); + void ShiftClickedCraftingResult(cPlayer & a_Player, short a_SlotNum); + void ShiftClickedCraftingGrid (cPlayer & a_Player, short a_SlotNum); }; diff --git a/source/cCreativeInventory.cpp b/source/cCreativeInventory.cpp index 77b9107b7..f1a1ae89c 100644 --- a/source/cCreativeInventory.cpp +++ b/source/cCreativeInventory.cpp @@ -14,37 +14,50 @@ #include "packets/cPacket_WholeInventory.h" #include "packets/cPacket_InventorySlot.h" -cCreativeInventory::~cCreativeInventory() -{ -} -cCreativeInventory::cCreativeInventory(cPlayer* a_Owner) + + + +cCreativeInventory::cCreativeInventory(cPlayer * a_Owner) : cInventory(a_Owner) { } -void cCreativeInventory::Clicked( cPacket* a_ClickPacket ) + + + + +cCreativeInventory::~cCreativeInventory() { - cPacket_CreativeInventoryAction* Packet = reinterpret_cast<cPacket_CreativeInventoryAction *>(a_ClickPacket); - short Slot = Packet->m_Slot; - if (Slot == -1) +} + + + + + +void cCreativeInventory::Clicked( + short a_SlotNum, bool a_IsRightClick, bool a_IsShiftPressed, + const cItem & a_HeldItem +) +{ + if (a_SlotNum == -1) { // object thrown out - m_Owner->TossItem(false, Packet->m_Quantity, Packet->m_ItemID, Packet->m_Damage); + m_Owner->TossItem(false, a_HeldItem.m_ItemCount, a_HeldItem.m_ItemType, a_HeldItem.m_ItemDamage); return; } - if ((Slot < c_HotOffset) || (Slot >= c_NumSlots)) + if ((a_SlotNum < c_HotOffset) || (a_SlotNum >= c_NumSlots)) { - LOG("%s: Invalid slot (%d) in CreativeInventoryAction packet. Ignoring...", m_Owner->GetName().c_str(), Slot); + LOG("%s: Invalid slot (%d) in cCreativeInventory::Clicked(). Ignoring...", m_Owner->GetName().c_str(), a_SlotNum); return; } - cItem * SlotItem = &(this->m_Slots[Slot]); - - SlotItem->m_ItemID = (ENUM_ITEM_ID) Packet->m_ItemID; - SlotItem->m_ItemHealth = Packet->m_Damage; - SlotItem->m_ItemCount = Packet->m_Quantity; + m_Slots[a_SlotNum] = a_HeldItem; } + + + + diff --git a/source/cCreativeInventory.h b/source/cCreativeInventory.h index f38c02c6c..469f0ecd6 100644 --- a/source/cCreativeInventory.h +++ b/source/cCreativeInventory.h @@ -1,13 +1,22 @@ + #pragma once #include "cInventory.h" -class cCreativeInventory //tolua_export + + + + +class cCreativeInventory : public cInventory -{ //tolua_export +{ public: - cCreativeInventory(cPlayer* a_Owner); + cCreativeInventory(cPlayer * a_Owner); ~cCreativeInventory(); - virtual void Clicked( cPacket* a_ClickPacket ); -}; //tolua_export + virtual void Clicked(short a_SlotNum, bool a_IsRightClick, bool a_IsShiftPressed, const cItem & a_HeldItem) override; +} ; + + + + diff --git a/source/cFurnaceEntity.cpp b/source/cFurnaceEntity.cpp index 6fe1936e9..2373b3555 100644 --- a/source/cFurnaceEntity.cpp +++ b/source/cFurnaceEntity.cpp @@ -120,7 +120,7 @@ bool cFurnaceEntity::Tick( float a_Dt ) if ((m_CookingItem != NULL) && ((m_TimeBurned < m_BurnTime) || (m_TimeCooked + a_Dt >= m_CookTime))) { - if (m_CookingItem->Equals(m_Items[2]) || m_Items[2].IsEmpty()) + if (m_CookingItem->IsEqual(m_Items[2]) || m_Items[2].IsEmpty()) { m_TimeCooked += a_Dt; if ( m_TimeCooked >= m_CookTime ) @@ -201,9 +201,9 @@ bool cFurnaceEntity::StartCooking(void) if( (m_TimeBurned < m_BurnTime) || BurnTime > 0.f ) // burnable material { const cFurnaceRecipe::Recipe* R = FR->GetRecipeFrom( m_Items[0] ); - if( R ) // cook able ingredient + if (R != NULL) // cook able ingredient { - if( m_Items[2].Equals( *R->Out ) || m_Items[2].IsEmpty() ) + if (m_Items[2].IsEqual(*R->Out) || m_Items[2].IsEmpty()) { // good to go @@ -241,7 +241,7 @@ bool cFurnaceEntity::ContinueCooking(void) const cFurnaceRecipe::Recipe * R = FR->GetRecipeFrom( m_Items[0] ); if (R != NULL) // cook able ingredient { - if (m_Items[2].Equals(*R->Out) || m_Items[2].IsEmpty()) + if (m_Items[2].IsEqual(*R->Out) || m_Items[2].IsEmpty()) { // good to go if (m_CookingItem == NULL) // Only cook new item if not already cooking diff --git a/source/cFurnaceWindow.cpp b/source/cFurnaceWindow.cpp index 8dcd0c8a5..480eaee1c 100644 --- a/source/cFurnaceWindow.cpp +++ b/source/cFurnaceWindow.cpp @@ -22,21 +22,27 @@ cFurnaceWindow::cFurnaceWindow( cFurnaceEntity* a_Owner ) -void cFurnaceWindow::Clicked(cPacket_WindowClick * a_ClickPacket, cPlayer & a_Player) +void cFurnaceWindow::Clicked( + cPlayer & a_Player, + int a_WindowID, short a_SlotNum, bool a_IsRightClick, bool a_IsShiftPressed, + const cItem & a_HeldItem +) { cItem Fuel = *GetSlot( 0 ); - cWindow::Clicked( a_ClickPacket, a_Player ); + cWindow::Clicked(a_Player, a_WindowID, a_SlotNum, a_IsRightClick, a_IsShiftPressed, a_HeldItem); if (m_Furnace != NULL) { - if ((a_ClickPacket->m_SlotNum >= 0) && (a_ClickPacket->m_SlotNum <= 2)) // them important slots + if ((a_SlotNum >= 0) && (a_SlotNum <= 2)) // them important slots { - if( Fuel.m_ItemID != GetSlot( 0 )->m_ItemID ) + if (Fuel.m_ItemID != GetSlot( 0 )->m_ItemID) + { m_Furnace->ResetCookTimer(); + } - if( m_Furnace->StartCooking() ) + if (m_Furnace->StartCooking()) { - SendWholeWindow( a_Player.GetClientHandle() ); + SendWholeWindow(a_Player.GetClientHandle()); } } } diff --git a/source/cFurnaceWindow.h b/source/cFurnaceWindow.h index f6ae36be5..ccaa5a97c 100644 --- a/source/cFurnaceWindow.h +++ b/source/cFurnaceWindow.h @@ -1,16 +1,37 @@ + #pragma once #include "cWindow.h" + + + + class cFurnaceEntity; class cWindowOwner; -class cFurnaceWindow : public cWindow + + + + + +class cFurnaceWindow : + public cWindow { public: cFurnaceWindow( cFurnaceEntity* a_Owner ); - virtual void Clicked( cPacket_WindowClick* a_ClickPacket, cPlayer & a_Player ); - virtual void Close( cPlayer & a_Player ); + virtual void Clicked( + cPlayer & a_Player, + int a_WindowID, short a_SlotNum, bool a_IsRightClick, bool a_IsShiftPressed, + const cItem & a_HeldItem + ) override; + + virtual void Close( cPlayer & a_Player ) override; + private: - cFurnaceEntity* m_Furnace; -};
\ No newline at end of file + cFurnaceEntity * m_Furnace; +}; + + + + diff --git a/source/cInventory.cpp b/source/cInventory.cpp index 8750b5368..d532ec7c9 100644 --- a/source/cInventory.cpp +++ b/source/cInventory.cpp @@ -293,7 +293,7 @@ void cInventory::SendWholeInventoryToAll(void) void cInventory::SendSlot( int a_SlotNum ) { - cItem* Item = GetSlot( a_SlotNum ); + cItem * Item = GetSlot(a_SlotNum); if (Item != NULL) { if (Item->IsEmpty()) diff --git a/source/cInventory.h b/source/cInventory.h index 6f824f0f5..8bf517769 100644 --- a/source/cInventory.h +++ b/source/cInventory.h @@ -51,7 +51,7 @@ public: void SetEquippedSlot( int a_SlotNum ); //tolua_export short GetEquippedSlot() { return m_EquippedSlot; } //tolua_export - virtual void Clicked( cPacket* a_ClickPacket ) = 0; + virtual void Clicked(short a_SlotNum, bool a_IsRightClick, bool a_IsShiftPressed, const cItem & a_HeldItem) = 0; void SendSlot( int a_SlotNum ); //tolua_export diff --git a/source/cItem.cpp b/source/cItem.cpp index f13b9cbf3..fd71a0b54 100644 --- a/source/cItem.cpp +++ b/source/cItem.cpp @@ -28,24 +28,31 @@ void cItem::FromJson( const Json::Value & a_Value ) } } -bool cItem::IsEnchantable(ENUM_ITEM_ID item) + + + + +bool cItem::IsEnchantable(short item) { - if(item >= 256 && item <= 259) + if ((item >= 256) && (item <= 259)) return true; - if(item >= 267 && item <= 279) + if ((item >= 267) && (item <= 279)) return true; - if(item >= 283 && item <= 286) + if ((item >= 283) && (item <= 286)) return true; - if(item >= 290 && item <= 294) + if ((item >= 290) && (item <= 294)) return true; - if(item >= 298 && item <= 317) + if ((item >= 298) && (item <= 317)) return true; - if(item >= 290 && item <= 294) + if ((item >= 290) && (item <= 294)) return true; - if(item == 346 || item == 359 || item == 261) + if ((item == 346) || (item == 359) || (item == 261)) return true; - return false; } + + + + diff --git a/source/cItem.h b/source/cItem.h index 15a6e3ca1..53764d06a 100644 --- a/source/cItem.h +++ b/source/cItem.h @@ -39,9 +39,23 @@ public: { return (m_ItemID <= 0 || m_ItemCount <= 0); } - bool Equals( cItem & a_Item ) const + + // tolua_end + OBSOLETE + // tolua_begin + bool Equals(const cItem & a_Item) const // obsolete, use IsEqual() instead + { + return IsEqual(a_Item); + } + + bool IsEqual(const cItem & a_Item) const + { + return (IsSameType(a_Item) && (m_ItemHealth == a_Item.m_ItemHealth)); + } + + bool IsSameType(const cItem & a_Item) const { - return ( (m_ItemID == a_Item.m_ItemID) && (m_ItemHealth == a_Item.m_ItemHealth) ); + return (m_ItemID == a_Item.m_ItemID) || (IsEmpty() && a_Item.IsEmpty()); } // TODO Sorry for writing the functions in the header. But somehow it doesnīt worked when I put them into the cpp File :s @@ -100,12 +114,25 @@ public: void FromJson( const Json::Value & a_Value ); // tolua_begin - static bool IsEnchantable(ENUM_ITEM_ID item); - - ENUM_ITEM_ID m_ItemID; - char m_ItemCount; - short m_ItemHealth; + static bool IsEnchantable(short a_ItemType); + // tolua_end + union + { + // tolua_begin + ENUM_ITEM_ID m_ItemID; // OBSOLETE, use m_ItemType instead + short m_ItemType; + // tolua_end + } ; + char m_ItemCount; // tolua_export + union + { + // tolua_begin + short m_ItemHealth; // OBSOLETE, use m_ItemDamage instead + short m_ItemDamage; + // tolua_end + } ; + // tolua_begin }; // tolua_end diff --git a/source/cPlayer.h b/source/cPlayer.h index 469d84701..a27070048 100644 --- a/source/cPlayer.h +++ b/source/cPlayer.h @@ -39,6 +39,7 @@ public: double GetEyeHeight(); //tolua_export Vector3d GetEyePosition(); //tolua_export inline bool GetFlying() { return m_bTouchGround; } //tolua_export + inline bool IsOnGround(void) const {return m_bTouchGround; } // tolua_export inline const double & GetStance() { return m_Stance; } //tolua_export inline cInventory & GetInventory() { if(GetGameMode() == eGameMode_Survival) return *m_Inventory; else return *m_CreativeInventory; } //tolua_export diff --git a/source/cPlugin.cpp b/source/cPlugin.cpp index 9a963f3f2..146e222cc 100644 --- a/source/cPlugin.cpp +++ b/source/cPlugin.cpp @@ -37,10 +37,16 @@ void cPlugin::Tick(float a_Dt) -bool cPlugin::OnBlockPlace(cPacket_BlockPlace * a_PacketData, cPlayer * a_Player) +bool cPlugin::OnBlockDig(cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status, BLOCKTYPE a_OldBlock, NIBBLETYPE a_OldMeta) { - UNUSED(a_PacketData); UNUSED(a_Player); + UNUSED(a_BlockX); + UNUSED(a_BlockY); + UNUSED(a_BlockZ); + UNUSED(a_BlockFace); + UNUSED(a_Status); + UNUSED(a_OldBlock); + UNUSED(a_OldMeta); return false; } @@ -48,22 +54,14 @@ bool cPlugin::OnBlockPlace(cPacket_BlockPlace * a_PacketData, cPlayer * a_Player -bool cPlugin::OnBlockDig(cPacket_BlockDig * a_PacketData, cPlayer * a_Player, cItem * a_PickupItem) -{ - UNUSED(a_PacketData); - UNUSED(a_Player); - UNUSED(a_PickupItem); - return false; -} - - - - - -bool cPlugin::OnCollectItem(cPickup * a_Pickup, cPlayer * a_Player) +bool cPlugin::OnBlockPlace(cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, const cItem & a_HeldItem) { - UNUSED(a_Pickup); UNUSED(a_Player); + UNUSED(a_BlockX); + UNUSED(a_BlockY); + UNUSED(a_BlockZ); + UNUSED(a_BlockFace); + UNUSED(a_HeldItem); return false; } @@ -71,10 +69,13 @@ bool cPlugin::OnCollectItem(cPickup * a_Pickup, cPlayer * a_Player) -bool cPlugin::OnDisconnect(const AString & a_Reason, cPlayer * a_Player) +bool cPlugin::OnBlockToPickup(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, const cPlayer * a_Player, const cItem & a_EquippedItem, cItems & a_Pickups) { - UNUSED(a_Reason); + UNUSED(a_BlockType); + UNUSED(a_BlockMeta); UNUSED(a_Player); + UNUSED(a_EquippedItem); + UNUSED(a_Pickups); return false; } @@ -93,27 +94,33 @@ bool cPlugin::OnChat(const char * a_Chat, cPlayer * a_Player) -bool cPlugin::OnLogin(cPacket_Login * a_PacketData) +void cPlugin::OnChunkGenerated(cWorld * a_World, int a_ChunkX, int a_ChunkZ) { - UNUSED(a_PacketData); - return false; + UNUSED(a_World); + UNUSED(a_ChunkX); + UNUSED(a_ChunkZ); } -void cPlugin::OnPlayerSpawn(cPlayer * a_Player) +bool cPlugin::OnChunkGenerating(cWorld * a_World, int a_ChunkX, int a_ChunkZ, cLuaChunk * a_pLuaChunk) { - UNUSED(a_Player); + UNUSED(a_World); + UNUSED(a_ChunkX); + UNUSED(a_ChunkZ); + UNUSED(a_pLuaChunk); + return false; } -bool cPlugin::OnPlayerJoin(cPlayer * a_Player) +bool cPlugin::OnCollectItem(cPickup * a_Pickup, cPlayer * a_Player) { + UNUSED(a_Pickup); UNUSED(a_Player); return false; } @@ -122,19 +129,23 @@ bool cPlugin::OnPlayerJoin(cPlayer * a_Player) -void cPlugin::OnPlayerMove(cPlayer * a_Player) +bool cPlugin::OnCraftingNoRecipe(const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) { UNUSED(a_Player); + UNUSED(a_Grid); + UNUSED(a_Recipe); + return false; } -void cPlugin::OnTakeDamage(cPawn * a_Pawn, TakeDamageInfo * a_TakeDamageInfo) +bool cPlugin::OnDisconnect(const AString & a_Reason, cPlayer * a_Player) { - UNUSED(a_Pawn); - UNUSED(a_TakeDamageInfo); + UNUSED(a_Reason); + UNUSED(a_Player); + return false; } @@ -152,23 +163,21 @@ bool cPlugin::OnKilled(cPawn * a_Killed, cEntity * a_Killer) -void cPlugin::OnChunkGenerated(cWorld * a_World, int a_ChunkX, int a_ChunkZ) +bool cPlugin::OnLogin(cClientHandle * a_Client, int a_ProtocolVersion, const AString & a_Username) { - UNUSED(a_World); - UNUSED(a_ChunkX); - UNUSED(a_ChunkZ); + UNUSED(a_Client); + UNUSED(a_ProtocolVersion); + UNUSED(a_Username); + return false; } -bool cPlugin::OnChunkGenerating(cWorld * a_World, int a_ChunkX, int a_ChunkZ, cLuaChunk * a_pLuaChunk) +bool cPlugin::OnPlayerJoin(cPlayer * a_Player) { - UNUSED(a_World); - UNUSED(a_ChunkX); - UNUSED(a_ChunkZ); - UNUSED(a_pLuaChunk); + UNUSED(a_Player); return false; } @@ -176,24 +185,18 @@ bool cPlugin::OnChunkGenerating(cWorld * a_World, int a_ChunkX, int a_ChunkZ, cL -bool cPlugin::OnPreCrafting(const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) +void cPlugin::OnPlayerMove(cPlayer * a_Player) { UNUSED(a_Player); - UNUSED(a_Grid); - UNUSED(a_Recipe); - return false; } -bool cPlugin::OnCraftingNoRecipe(const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) +void cPlugin::OnPlayerSpawn(cPlayer * a_Player) { UNUSED(a_Player); - UNUSED(a_Grid); - UNUSED(a_Recipe); - return false; } @@ -212,13 +215,11 @@ bool cPlugin::OnPostCrafting(const cPlayer * a_Player, const cCraftingGrid * a_G -bool cPlugin::OnBlockToPickup(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, const cPlayer * a_Player, const cItem & a_EquippedItem, cItems & a_Pickups) +bool cPlugin::OnPreCrafting(const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) { - UNUSED(a_BlockType); - UNUSED(a_BlockMeta); UNUSED(a_Player); - UNUSED(a_EquippedItem); - UNUSED(a_Pickups); + UNUSED(a_Grid); + UNUSED(a_Recipe); return false; } @@ -226,17 +227,17 @@ bool cPlugin::OnBlockToPickup(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, con -bool cPlugin::OnWeatherChanged(cWorld * a_World) +void cPlugin::OnTakeDamage(cPawn * a_Pawn, TakeDamageInfo * a_TakeDamageInfo) { - UNUSED(a_World); - return false; + UNUSED(a_Pawn); + UNUSED(a_TakeDamageInfo); } -bool cPlugin::OnUpdatingSign(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, AString & a_Line1, AString & a_Line2, AString & a_Line3, AString & a_Line4) +bool cPlugin::OnUpdatedSign(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4) { UNUSED(a_World); UNUSED(a_BlockX); @@ -253,7 +254,7 @@ bool cPlugin::OnUpdatingSign(cWorld * a_World, int a_BlockX, int a_BlockY, int a -bool cPlugin::OnUpdatedSign(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4) +bool cPlugin::OnUpdatingSign(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, AString & a_Line1, AString & a_Line2, AString & a_Line3, AString & a_Line4) { UNUSED(a_World); UNUSED(a_BlockX); @@ -270,6 +271,16 @@ bool cPlugin::OnUpdatedSign(cWorld * a_World, int a_BlockX, int a_BlockY, int a_ +bool cPlugin::OnWeatherChanged(cWorld * a_World) +{ + UNUSED(a_World); + return false; +} + + + + + void cPlugin::AddCommand(const AString & a_Command, const AString & a_Description, const AString & a_Permission) { CommandStruct Command; diff --git a/source/cPlugin.h b/source/cPlugin.h index 21994977e..97c8cec5f 100644 --- a/source/cPlugin.h +++ b/source/cPlugin.h @@ -46,28 +46,28 @@ public: /** * On all these functions, return true if you want to override default behavior - * You can also return false, so default behavior is used, but with changed PacketData + * You can also return false, so default behavior is used. **/ + virtual bool OnBlockDig (cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status, BLOCKTYPE a_OldBlock, NIBBLETYPE a_OldMeta); + virtual bool OnBlockPlace (cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, const cItem & a_HeldItem); + virtual bool OnBlockToPickup (BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, const cPlayer * a_Player, const cItem & a_EquippedItem, cItems & a_Pickups); + virtual bool OnChat (const char * a_Chat, cPlayer * a_Player ); + virtual void OnChunkGenerated (cWorld * a_World, int a_ChunkX, int a_ChunkZ); + virtual bool OnChunkGenerating (cWorld * a_World, int a_ChunkX, int a_ChunkZ, cLuaChunk * a_pLuaChunk); virtual bool OnCollectItem (cPickup* a_Pickup, cPlayer* a_Player ); + virtual bool OnCraftingNoRecipe(const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe); virtual bool OnDisconnect (const AString & a_Reason, cPlayer * a_Player ); - virtual bool OnBlockPlace (cPacket_BlockPlace* a_PacketData, cPlayer* a_Player ); - virtual bool OnBlockDig (cPacket_BlockDig * a_PacketData, cPlayer * a_Player, cItem * a_PickupItem); - virtual bool OnChat (const char * a_Chat, cPlayer* a_Player ); - virtual bool OnLogin (cPacket_Login* a_PacketData ); - virtual void OnPlayerSpawn (cPlayer* a_Player ); + virtual bool OnKilled (cPawn* a_Killed, cEntity* a_Killer ); + virtual bool OnLogin (cClientHandle * a_Client, int a_ProtocolVersion, const AString & a_Username); virtual bool OnPlayerJoin (cPlayer* a_Player ); virtual void OnPlayerMove (cPlayer* a_Player ); - virtual void OnTakeDamage (cPawn* a_Pawn, TakeDamageInfo* a_TakeDamageInfo ); - virtual bool OnKilled (cPawn* a_Killed, cEntity* a_Killer ); - virtual void OnChunkGenerated (cWorld * a_World, int a_ChunkX, int a_ChunkZ); - virtual bool OnChunkGenerating (cWorld * a_World, int a_ChunkX, int a_ChunkZ, cLuaChunk * a_pLuaChunk); - virtual bool OnPreCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe); - virtual bool OnCraftingNoRecipe(const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe); + virtual void OnPlayerSpawn (cPlayer* a_Player ); virtual bool OnPostCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe); - virtual bool OnBlockToPickup (BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, const cPlayer * a_Player, const cItem & a_EquippedItem, cItems & a_Pickups); - virtual bool OnWeatherChanged (cWorld * a_World); - virtual bool OnUpdatingSign (cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, AString & a_Line1, AString & a_Line2, AString & a_Line3, AString & a_Line4); + virtual bool OnPreCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe); + virtual void OnTakeDamage (cPawn * a_Pawn, TakeDamageInfo * a_TakeDamageInfo ); virtual bool OnUpdatedSign (cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4); + virtual bool OnUpdatingSign (cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, AString & a_Line1, AString & a_Line2, AString & a_Line3, AString & a_Line4); + virtual bool OnWeatherChanged (cWorld * a_World); // Accessors const char* GetName() const { return m_Name.c_str(); } diff --git a/source/cPluginManager.cpp b/source/cPluginManager.cpp index b3392e356..c64b466c2 100644 --- a/source/cPluginManager.cpp +++ b/source/cPluginManager.cpp @@ -262,40 +262,7 @@ bool cPluginManager::CallHook(PluginHook a_Hook, unsigned int a_NumArgs, ...) } break; } - - case HOOK_BLOCK_DIG: - { - if( a_NumArgs != 2 ) break; - va_list argptr; - va_start( argptr, a_NumArgs); - cPacket_BlockDig* Packet = va_arg(argptr, cPacket_BlockDig* ); - cPlayer* Player = va_arg(argptr, cPlayer* ); - cItem* Item = va_arg( argptr, cItem* ); - va_end (argptr); - for( PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr ) - { - if( (*itr)->OnBlockDig( Packet, Player, Item ) ) - return true; - } - break; - } - - case HOOK_BLOCK_PLACE: - { - if( a_NumArgs != 2 ) break; - va_list argptr; - va_start( argptr, a_NumArgs); - cPacket_BlockPlace* Packet = va_arg(argptr, cPacket_BlockPlace* ); - cPlayer* Player = va_arg(argptr, cPlayer* ); - va_end (argptr); - for( PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr ) - { - if( (*itr)->OnBlockPlace( Packet, Player ) ) - return true; - } - break; - } - + case HOOK_DISCONNECT: { if( a_NumArgs != 2 ) break; @@ -312,21 +279,6 @@ bool cPluginManager::CallHook(PluginHook a_Hook, unsigned int a_NumArgs, ...) break; } - case HOOK_LOGIN: - { - if( a_NumArgs != 1 ) break; - va_list argptr; - va_start( argptr, a_NumArgs); - cPacket_Login* Packet = va_arg(argptr, cPacket_Login* ); - va_end (argptr); - for( PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr ) - { - if( (*itr)->OnLogin( Packet ) ) - return true; - } - break; - } - case HOOK_PLAYER_JOIN: { if( a_NumArgs != 1 ) break; @@ -437,6 +389,69 @@ bool cPluginManager::CallHook(PluginHook a_Hook, unsigned int a_NumArgs, ...) +bool cPluginManager::CallHookLogin(cClientHandle * a_Client, int a_ProtocolVersion, const AString & a_Username) +{ + HookMap::iterator Plugins = m_Hooks.find(HOOK_LOGIN); + if (Plugins == m_Hooks.end()) + { + return false; + } + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) + { + if ((*itr)->OnLogin(a_Client, a_ProtocolVersion, a_Username)) + { + return true; + } + } + return false; +} + + + + + +bool cPluginManager::CallHookBlockDig(cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status, BLOCKTYPE a_OldBlock, NIBBLETYPE a_OldMeta) +{ + HookMap::iterator Plugins = m_Hooks.find(HOOK_BLOCK_DIG); + if (Plugins == m_Hooks.end()) + { + return false; + } + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) + { + if ((*itr)->OnBlockDig(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_Status, a_OldBlock, a_OldMeta)) + { + return true; + } + } + return false; +} + + + + + +bool cPluginManager::CallHookBlockPlace(cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, const cItem & a_HeldItem) +{ + HookMap::iterator Plugins = m_Hooks.find(HOOK_BLOCK_PLACE); + if (Plugins == m_Hooks.end()) + { + return false; + } + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) + { + if ((*itr)->OnBlockPlace(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_HeldItem)) + { + return true; + } + } + return false; +} + + + + + bool cPluginManager::CallHookChunkGenerating(cWorld * a_World, int a_ChunkX, int a_ChunkZ, cLuaChunk * a_LuaChunk) { HookMap::iterator Plugins = m_Hooks.find(HOOK_CHUNK_GENERATING); diff --git a/source/cPluginManager.h b/source/cPluginManager.h index 2e50b2005..3edf80e73 100644 --- a/source/cPluginManager.h +++ b/source/cPluginManager.h @@ -97,6 +97,9 @@ public: //tolua_export // If the hook returns true, no further hook is called and the functions return false bool CallHook( PluginHook a_Hook, unsigned int a_NumArgs, ... ); + bool CallHookLogin (cClientHandle * a_Client, int a_ProtocolVersion, const AString & a_Username); + bool CallHookBlockDig (cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status, BLOCKTYPE OldBlock, NIBBLETYPE OldMeta); + bool CallHookBlockPlace (cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, const cItem & a_HeldItem); bool CallHookChunkGenerating (cWorld * a_World, int a_ChunkX, int a_ChunkZ, cLuaChunk * a_Chunk); bool CallHookPreCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe); bool CallHookCraftingNoRecipe(const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe); diff --git a/source/cPlugin_NewLua.cpp b/source/cPlugin_NewLua.cpp index 7f7f0c20c..51d2dc9df 100644 --- a/source/cPlugin_NewLua.cpp +++ b/source/cPlugin_NewLua.cpp @@ -204,41 +204,56 @@ bool cPlugin_NewLua::OnDisconnect(const AString & a_Reason, cPlayer* a_Player ) -bool cPlugin_NewLua::OnBlockPlace( cPacket_BlockPlace* a_PacketData, cPlayer* a_Player ) +bool cPlugin_NewLua::OnBlockPlace(cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, const cItem & a_HeldItem) { - cCSLock Lock( m_CriticalSection ); - if( !PushFunction("OnBlockPlace") ) + cCSLock Lock(m_CriticalSection); + if (!PushFunction("OnBlockPlace")) + { return false; + } - tolua_pushusertype(m_LuaState, a_PacketData, "cPacket_BlockPlace"); tolua_pushusertype(m_LuaState, a_Player, "cPlayer"); + tolua_pushnumber (m_LuaState, a_BlockX); + tolua_pushnumber (m_LuaState, a_BlockY); + tolua_pushnumber (m_LuaState, a_BlockZ); + tolua_pushnumber (m_LuaState, a_BlockFace); + tolua_pushusertype(m_LuaState, (void *)&a_HeldItem, "cItem"); - if( !CallFunction(2, 1, "OnBlockPlace") ) + if (!CallFunction(6, 1, "OnBlockPlace")) + { return false; + } - bool bRetVal = (tolua_toboolean( m_LuaState, -1, 0) > 0); - return bRetVal; + return (tolua_toboolean( m_LuaState, -1, 0) > 0); } -bool cPlugin_NewLua::OnBlockDig( cPacket_BlockDig* a_PacketData, cPlayer* a_Player, cItem* a_PickupItem ) +bool cPlugin_NewLua::OnBlockDig(cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status, BLOCKTYPE a_OldBlock, NIBBLETYPE a_OldMeta) { - cCSLock Lock( m_CriticalSection ); - if( !PushFunction("OnBlockDig") ) + cCSLock Lock(m_CriticalSection); + if (!PushFunction("OnBlockDig")) + { return false; + } - tolua_pushusertype(m_LuaState, a_PacketData, "cPacket_BlockDig"); tolua_pushusertype(m_LuaState, a_Player, "cPlayer"); - tolua_pushusertype(m_LuaState, a_PickupItem, "cItem"); + tolua_pushnumber (m_LuaState, a_BlockX); + tolua_pushnumber (m_LuaState, a_BlockY); + tolua_pushnumber (m_LuaState, a_BlockZ); + tolua_pushnumber (m_LuaState, a_BlockFace); + tolua_pushnumber (m_LuaState, a_Status); + tolua_pushnumber (m_LuaState, a_OldBlock); + tolua_pushnumber (m_LuaState, a_OldMeta); - if( !CallFunction(3, 1, "OnBlockDig") ) + if (!CallFunction(8, 1, "OnBlockDig")) + { return false; + } - bool bRetVal = (tolua_toboolean( m_LuaState, -1, 0) > 0); - return bRetVal; + return (tolua_toboolean( m_LuaState, -1, 0) > 0); } @@ -265,15 +280,17 @@ bool cPlugin_NewLua::OnChat( const char* a_Chat, cPlayer* a_Player ) -bool cPlugin_NewLua::OnLogin( cPacket_Login* a_PacketData ) +bool cPlugin_NewLua::OnLogin(cClientHandle * a_Client, int a_ProtocolVersion, const AString & a_Username) { cCSLock Lock( m_CriticalSection ); if( !PushFunction("OnLogin") ) return false; - tolua_pushusertype(m_LuaState, a_PacketData, "cPacket_Login"); + tolua_pushusertype (m_LuaState, a_Client, "cClientHandle"); + tolua_pushnumber (m_LuaState, a_ProtocolVersion); + tolua_pushcppstring(m_LuaState, a_Username); - if( !CallFunction(1, 1, "OnLogin") ) + if (!CallFunction(3, 1, "OnLogin")) return false; bool bRetVal = (tolua_toboolean( m_LuaState, -1, 0) > 0); diff --git a/source/cPlugin_NewLua.h b/source/cPlugin_NewLua.h index 5756e526c..13f8ce8f4 100644 --- a/source/cPlugin_NewLua.h +++ b/source/cPlugin_NewLua.h @@ -27,10 +27,10 @@ public: //tolua_export virtual bool OnCollectItem (cPickup* a_Pickup, cPlayer* a_Player ) override; virtual bool OnDisconnect (const AString & a_Reason, cPlayer * a_Player ) override; - virtual bool OnBlockPlace (cPacket_BlockPlace* a_PacketData, cPlayer* a_Player ) override; - virtual bool OnBlockDig (cPacket_BlockDig* a_PacketData, cPlayer* a_Player, cItem* a_PickupItem ) override; + virtual bool OnBlockPlace (cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, const cItem & a_HeldItem) override; + virtual bool OnBlockDig (cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status, BLOCKTYPE a_OldBlock, NIBBLETYPE a_OldMeta) override; virtual bool OnChat (const char* a_Chat, cPlayer* a_Player ) override; - virtual bool OnLogin (cPacket_Login* a_PacketData ) override; + virtual bool OnLogin (cClientHandle * a_Client, int a_ProtocolVersion, const AString & a_Username) override; virtual void OnPlayerSpawn (cPlayer* a_Player ) override; virtual bool OnPlayerJoin (cPlayer* a_Player ) override; virtual void OnPlayerMove (cPlayer* a_Player ) override; diff --git a/source/cPlugin_Squirrel.cpp b/source/cPlugin_Squirrel.cpp index 4ce412dbf..07ca0d2da 100644 --- a/source/cPlugin_Squirrel.cpp +++ b/source/cPlugin_Squirrel.cpp @@ -125,37 +125,37 @@ bool cPlugin_Squirrel::OnDisconnect(const AString & a_Reason, cPlayer* a_Player -bool cPlugin_Squirrel::OnBlockPlace( cPacket_BlockPlace* a_PacketData, cPlayer* a_Player )
+bool cPlugin_Squirrel::OnBlockPlace(cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, const cItem & a_HeldItem)
{
- cCSLock Lock( m_CriticalSection );
+ cCSLock Lock(m_CriticalSection);
- if(!m_Plugin->HasFunction("OnBlockPlace")) return false;
+ if (!m_Plugin->HasFunction("OnBlockPlace")) return false;
- return m_Plugin->GetFunction("OnBlockPlace").Evaluate<bool>(a_PacketData, a_Player);
+ return m_Plugin->GetFunction("OnBlockPlace").Evaluate<bool>(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_HeldItem);
}
-bool cPlugin_Squirrel::OnBlockDig( cPacket_BlockDig* a_PacketData, cPlayer* a_Player, cItem* a_PickupItem )
+bool cPlugin_Squirrel::OnBlockDig(cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status, BLOCKTYPE a_OldBlock, NIBBLETYPE a_OldMeta)
{
- cCSLock Lock( m_CriticalSection );
+ cCSLock Lock(m_CriticalSection);
- if(!m_Plugin->HasFunction("OnBlockDig")) return false;
+ if (!m_Plugin->HasFunction("OnBlockDig")) return false;
- return m_Plugin->GetFunction("OnBlockDig").Evaluate<bool>(a_PacketData, a_Player, a_PickupItem);
+ return m_Plugin->GetFunction("OnBlockDig").Evaluate<bool>(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_Status, a_OldBlock, a_OldMeta);
}
-bool cPlugin_Squirrel::OnChat( const char* a_Chat, cPlayer* a_Player )
+bool cPlugin_Squirrel::OnChat(const char * a_Chat, cPlayer * a_Player)
{
cCSLock Lock( m_CriticalSection );
- if(!m_Plugin->HasFunction("OnChat")) return false;
+ if (!m_Plugin->HasFunction("OnChat")) return false;
return m_Plugin->GetFunction("OnChat").Evaluate<bool>(a_Chat, a_Player);
@@ -165,13 +165,16 @@ bool cPlugin_Squirrel::OnChat( const char* a_Chat, cPlayer* a_Player ) -bool cPlugin_Squirrel::OnLogin( cPacket_Login* a_PacketData )
+bool cPlugin_Squirrel::OnLogin(cClientHandle * a_Client, int a_ProtocolVersion, const AString & a_Username)
{
cCSLock Lock( m_CriticalSection );
- if(!m_Plugin->HasFunction("OnLogin")) return false;
+ if (!m_Plugin->HasFunction("OnLogin"))
+ {
+ return false;
+ }
- return m_Plugin->GetFunction("OnLogin").Evaluate<bool>(a_PacketData);
+ return m_Plugin->GetFunction("OnLogin").Evaluate<bool>(a_Client, a_ProtocolVersion, a_Username);
}
diff --git a/source/cPlugin_Squirrel.h b/source/cPlugin_Squirrel.h index cd05e117a..d32ccb3d0 100644 --- a/source/cPlugin_Squirrel.h +++ b/source/cPlugin_Squirrel.h @@ -16,10 +16,10 @@ public: bool OnCollectItem (cPickup* a_Pickup, cPlayer* a_Player ) override;
bool OnDisconnect (const AString & a_Reason, cPlayer * a_Player ) override;
- bool OnBlockPlace (cPacket_BlockPlace* a_PacketData, cPlayer* a_Player ) override;
- bool OnBlockDig (cPacket_BlockDig* a_PacketData, cPlayer* a_Player, cItem* a_PickupItem ) override;
- bool OnChat (const char* a_Chat, cPlayer* a_Player ) override;
- bool OnLogin (cPacket_Login* a_PacketData ) override;
+ bool OnBlockPlace (cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, const cItem & a_HeldItem) override;
+ bool OnBlockDig (cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status, BLOCKTYPE a_OldBlock, NIBBLETYPE a_OldMeta) override;
+ bool OnChat (const char * a_Chat, cPlayer * a_Player ) override;
+ bool OnLogin (cClientHandle * a_Client, int a_ProtocolVersion, const AString & a_Username) override;
void OnPlayerSpawn (cPlayer* a_Player ) override;
bool OnPlayerJoin (cPlayer* a_Player ) override;
void OnPlayerMove (cPlayer* a_Player ) override;
diff --git a/source/cSurvivalInventory.cpp b/source/cSurvivalInventory.cpp index 887868fd7..3786f86fa 100644 --- a/source/cSurvivalInventory.cpp +++ b/source/cSurvivalInventory.cpp @@ -8,7 +8,7 @@ #include "cItem.h" #include "CraftingRecipes.h" #include "cRoot.h" -#include "packets/cPacket_WindowClick.h" +#include "items/Item.h" @@ -31,39 +31,42 @@ cSurvivalInventory::~cSurvivalInventory() -void cSurvivalInventory::Clicked( cPacket* a_ClickPacket ) +void cSurvivalInventory::Clicked( + short a_SlotNum, bool a_IsRightClick, bool a_IsShiftPressed, + const cItem & a_HeldItem +) { - cPacket_WindowClick * Packet = reinterpret_cast<cPacket_WindowClick *>(a_ClickPacket); - + cWindow * Window = GetWindow(); if ( - Packet->m_IsShiftPressed && // Shift pressed - (GetWindow() != NULL) && // Window is valid - (GetWindow()->GetDraggingItem()->IsEmpty()) // Not dragging anything + a_IsShiftPressed && // Shift pressed + (Window != NULL) && // Window is valid + (Window->GetDraggingItem()->IsEmpty()) // Not dragging anything ) { - ShiftClicked(Packet); + ShiftClicked(a_SlotNum); return; } bool bDontCook = false; - if (GetWindow()) + if (Window != NULL) { // Override for craft result slot - if (Packet->m_SlotNum == (short)c_CraftOffset) + if (a_SlotNum == (short)c_CraftOffset) { - LOGD("In craft slot: %i x %i !!", m_Slots[c_CraftOffset].m_ItemID, m_Slots[c_CraftOffset].m_ItemCount ); - cItem * DraggingItem = GetWindow()->GetDraggingItem(); + LOGD("Clicked in craft result slot, item there: %d:%d (%d times) !!", m_Slots[c_CraftOffset].m_ItemID, m_Slots[c_CraftOffset].m_ItemHealth, m_Slots[c_CraftOffset].m_ItemCount); + cItem * DraggingItem = Window->GetDraggingItem(); if (DraggingItem->IsEmpty()) { *DraggingItem = m_Slots[c_CraftOffset]; m_Slots[c_CraftOffset].Empty(); } - else if (DraggingItem->Equals(m_Slots[c_CraftOffset])) + else if (DraggingItem->IsEqual(m_Slots[c_CraftOffset])) { - if (DraggingItem->m_ItemCount + m_Slots[c_CraftOffset].m_ItemCount <= 64) + cItemHandler * Handler = ItemHandler(m_Slots[c_CraftOffset].m_ItemID); + if (DraggingItem->m_ItemCount + m_Slots[c_CraftOffset].m_ItemCount <= Handler->GetMaxStackSize()) { DraggingItem->m_ItemCount += m_Slots[c_CraftOffset].m_ItemCount; - m_Slots[0].Empty(); + m_Slots[c_CraftOffset].Empty(); } else { @@ -74,11 +77,10 @@ void cSurvivalInventory::Clicked( cPacket* a_ClickPacket ) { bDontCook = true; } - LOGD("Dragging Dish %i", DraggingItem->m_ItemCount ); } else { - GetWindow()->Clicked( Packet, *m_Owner ); + Window->Clicked(*m_Owner, 0, a_SlotNum, a_IsRightClick, a_IsShiftPressed, a_HeldItem); } } else @@ -87,14 +89,14 @@ void cSurvivalInventory::Clicked( cPacket* a_ClickPacket ) LOG("No Inventory window! WTF"); } - if ((Packet->m_SlotNum >= (short)c_CraftOffset) && (Packet->m_SlotNum < (short)(c_CraftOffset + c_CraftSlots + 1))) + if ((a_SlotNum >= (short)c_CraftOffset) && (a_SlotNum < (short)(c_CraftOffset + c_CraftSlots + 1))) { cCraftingGrid Grid(m_Slots + c_CraftOffset + 1, 2, 2); cCraftingRecipe Recipe(Grid); cRoot::Get()->GetCraftingRecipes()->GetRecipe(m_Owner, Grid, Recipe); - if ((Packet->m_SlotNum == 0) && !bDontCook) + if ((a_SlotNum == 0) && !bDontCook) { // Consume the items from the crafting grid: Recipe.ConsumeIngredients(Grid); @@ -106,8 +108,8 @@ void cSurvivalInventory::Clicked( cPacket* a_ClickPacket ) cRoot::Get()->GetCraftingRecipes()->GetRecipe(m_Owner, Grid, Recipe); } m_Slots[c_CraftOffset] = Recipe.GetResult(); - LOGD("%s cooked: %i x %i !!", m_Owner->GetName().c_str(), m_Slots[c_CraftOffset].m_ItemID, m_Slots[c_CraftOffset].m_ItemCount ); - SendWholeInventory( m_Owner->GetClientHandle() ); + LOGD("%s cooked: %d:%d (%d times) !!", m_Owner->GetName().c_str(), m_Slots[c_CraftOffset].m_ItemID, m_Slots[c_CraftOffset].m_ItemHealth, m_Slots[c_CraftOffset].m_ItemCount ); + SendWholeInventory(m_Owner->GetClientHandle()); } SendSlot(0); } @@ -116,32 +118,31 @@ void cSurvivalInventory::Clicked( cPacket* a_ClickPacket ) -void cSurvivalInventory::ShiftClicked(cPacket_WindowClick * a_ClickPacket) +void cSurvivalInventory::ShiftClicked(short a_SlotNum) { ASSERT((GetWindow() == NULL) || (GetWindow()->GetDraggingItem()->IsEmpty())); // Cannot handle shift-click if dragging something - short Slot = a_ClickPacket->m_SlotNum; - if (Slot == SLOT_CRAFTING_RESULT) + if (a_SlotNum == SLOT_CRAFTING_RESULT) { - ShiftClickedCraftingResult(Slot); + ShiftClickedCraftingResult(a_SlotNum); } - else if ((Slot >= SLOT_CRAFTING_MIN) && (Slot <= SLOT_CRAFTING_MAX)) + else if ((a_SlotNum >= SLOT_CRAFTING_MIN) && (a_SlotNum <= SLOT_CRAFTING_MAX)) { - ShiftClickedCraftingGrid(Slot); + ShiftClickedCraftingGrid(a_SlotNum); } - else if ((Slot >= SLOT_ARMOR_MIN) && (Slot <= SLOT_ARMOR_MAX)) + else if ((a_SlotNum >= SLOT_ARMOR_MIN) && (a_SlotNum <= SLOT_ARMOR_MAX)) { - ShiftClickedArmor(Slot); + ShiftClickedArmor(a_SlotNum); } - else if ((Slot >= SLOT_HOTBAR_MIN) && (Slot <= SLOT_HOTBAR_MAX)) + else if ((a_SlotNum >= SLOT_HOTBAR_MIN) && (a_SlotNum <= SLOT_HOTBAR_MAX)) { - ShiftClickedHotbar(Slot); + ShiftClickedHotbar(a_SlotNum); } else { - ShiftClickedInventory(Slot); + ShiftClickedInventory(a_SlotNum); } - // Because the client tries to guess our actions, not always right, send the whole inventory: + // Because the client tries to guess our actions and is not always right, send the whole inventory: SendWholeInventoryToAll(); } @@ -182,7 +183,7 @@ void cSurvivalInventory::ShiftClickedCraftingResult(short a_Slot) m_Slots[SLOT_CRAFTING_RESULT] = Recipe.GetResult(); // If the recipe changed, abort: - if (!Recipe.GetResult().Equals(ResultCopy)) + if (!Recipe.GetResult().IsEqual(ResultCopy)) { break; } diff --git a/source/cSurvivalInventory.h b/source/cSurvivalInventory.h index cdab62e93..3ad385fcf 100644 --- a/source/cSurvivalInventory.h +++ b/source/cSurvivalInventory.h @@ -28,8 +28,8 @@ class cSurvivalInventory //tolua_export SLOT_HOTBAR_MAX = 44, } ; - void ShiftClickedCraftingResult(short a_Slot); - void ShiftClickedCraftingGrid (short a_Slot); + void ShiftClickedCraftingResult(short a_SlotNum); + void ShiftClickedCraftingGrid (short a_SlotNum); void ShiftClickedArmor (short a_Slot); void ShiftClickedHotbar (short a_Slot); void ShiftClickedInventory (short a_Slot); @@ -38,9 +38,9 @@ public: cSurvivalInventory(cPlayer* a_Owner); ~cSurvivalInventory(); - virtual void Clicked(cPacket * a_ClickPacket) override; + virtual void Clicked(short a_SlotNum, bool a_IsRightClick, bool a_IsShiftPressed, const cItem & a_HeldItem) override; - void ShiftClicked(cPacket_WindowClick * a_ClickPacket); + void ShiftClicked(short a_SlotNum); }; //tolua_export diff --git a/source/cWindow.cpp b/source/cWindow.cpp index a7eceac27..f3b4bc883 100644 --- a/source/cWindow.cpp +++ b/source/cWindow.cpp @@ -8,8 +8,8 @@ #include "cPickup.h" #include "cInventory.h" #include "cWindowOwner.h" +#include "items/Item.h" -#include "packets/cPacket_WindowClick.h" #include "packets/cPacket_WholeInventory.h" #include "packets/cPacket_WindowOpen.h" #include "packets/cPacket_WindowClose.h" @@ -84,11 +84,15 @@ cItem* cWindow::GetDraggingItem( cPlayer * a_Player /* = 0 */ ) -void cWindow::Clicked( cPacket_WindowClick* a_ClickPacket, cPlayer & a_Player ) +void cWindow::Clicked( + cPlayer & a_Player, + int a_WindowID, short a_SlotNum, bool a_IsRightClick, bool a_IsShiftPressed, + const cItem & a_HeldItem +) { - if (a_ClickPacket->m_WindowID != m_WindowID) + if (a_WindowID != m_WindowID) { - LOG("WRONG WINDOW ID! (exp %d, got %d)", m_WindowID, a_ClickPacket->m_WindowID); + LOG("WRONG WINDOW ID! (exp %d, got %d) received from \"%s\"", m_WindowID, a_WindowID, a_Player.GetName().c_str()); return; } @@ -101,111 +105,118 @@ void cWindow::Clicked( cPacket_WindowClick* a_ClickPacket, cPlayer & a_Player ) } } bool bAsync = false; - if (a_ClickPacket->m_SlotNum == -999) // Outside window click + if (a_SlotNum == -999) // Outside window click { - if (a_ClickPacket->m_RightMouse) + if (a_IsRightClick) { - a_Player.TossItem( true ); + a_Player.TossItem(true); } else { - a_Player.TossItem( true, m_DraggingItem->m_ItemCount ); + a_Player.TossItem(true, m_DraggingItem->m_ItemCount); } } - else if (GetSlot(a_ClickPacket->m_SlotNum) != NULL) + else if (GetSlot(a_SlotNum) != NULL) { - cItem * Item = GetSlot(a_ClickPacket->m_SlotNum); - if ( - (a_ClickPacket->m_ItemID != Item->m_ItemID) || - (a_ClickPacket->m_ItemCount != Item->m_ItemCount) || - (a_ClickPacket->m_ItemUses != Item->m_ItemHealth) - ) + cItem * Item = GetSlot(a_SlotNum); + if (!Item->IsEqual(a_HeldItem)) { - if (!((a_ClickPacket->m_ItemID == -1 || a_ClickPacket->m_ItemID == 0) && (Item->m_ItemID == -1 || Item->m_ItemID == 0 )) ) - { - LOGD("My ID: %i Their ID: %i", Item->m_ItemID, a_ClickPacket->m_ItemID ); - LOGD("My Count: %i Their Count: %i", Item->m_ItemCount, a_ClickPacket->m_ItemCount ); - LOGD("My Uses: %i Their Uses: %i", Item->m_ItemHealth, a_ClickPacket->m_ItemUses ); - bAsync = true; - } + LOGD("*** Window lost sync ***"); + LOGD("My Type: %i Their Type: %i", Item->m_ItemID, a_HeldItem.m_ItemID); + LOGD("My Count: %i Their Count: %i", Item->m_ItemCount, a_HeldItem.m_ItemCount); + LOGD("My Dmg: %i Their Dmg: %i", Item->m_ItemHealth, a_HeldItem.m_ItemHealth); + bAsync = true; } } - if (m_DraggingItem && (a_ClickPacket->m_SlotNum > -1) && (a_ClickPacket->m_SlotNum < m_NumSlots)) + if (m_DraggingItem && (a_SlotNum > -1) && (a_SlotNum < m_NumSlots)) { - if (a_ClickPacket->m_RightMouse == 0) + if (!a_IsRightClick) { - if (!m_DraggingItem->Equals(m_Slots[a_ClickPacket->m_SlotNum])) + // Left-clicked + if (!m_DraggingItem->IsEqual(m_Slots[a_SlotNum])) { + // Switch contents cItem tmp(*m_DraggingItem); - *m_DraggingItem = m_Slots[a_ClickPacket->m_SlotNum]; - m_Slots[a_ClickPacket->m_SlotNum] = tmp; // Switch contents + *m_DraggingItem = m_Slots[a_SlotNum]; + m_Slots[a_SlotNum] = tmp; } else { - int FreeSlots = 64 - m_Slots[a_ClickPacket->m_SlotNum].m_ItemCount; + // Same type, add items: + cItemHandler * Handler = ItemHandler(m_DraggingItem->m_ItemID); + int FreeSlots = Handler->GetMaxStackSize() - m_Slots[a_SlotNum].m_ItemCount; + if (FreeSlots < 0) + { + ASSERT(!"Bad item stack size - where did we get more items in a slot than allowed?"); + FreeSlots = 0; + } int Filling = (FreeSlots > m_DraggingItem->m_ItemCount) ? m_DraggingItem->m_ItemCount : FreeSlots; - m_Slots[a_ClickPacket->m_SlotNum].m_ItemCount += (char)Filling; + m_Slots[a_SlotNum].m_ItemCount += (char)Filling; m_DraggingItem->m_ItemCount -= (char)Filling; - if( m_DraggingItem->m_ItemCount <= 0 ) + if (m_DraggingItem->m_ItemCount <= 0) + { m_DraggingItem->Empty(); + } } } - else // Right clicked + else { - if( m_DraggingItem->m_ItemID <= 0 ) // Empty? + // Right clicked + if (m_DraggingItem->m_ItemID <= 0) // Empty-handed? { - m_DraggingItem->m_ItemCount = (char)(((float)m_Slots[a_ClickPacket->m_SlotNum].m_ItemCount)/2.f + 0.5f); - m_Slots[a_ClickPacket->m_SlotNum].m_ItemCount -= m_DraggingItem->m_ItemCount; - m_DraggingItem->m_ItemID = m_Slots[a_ClickPacket->m_SlotNum].m_ItemID; - m_DraggingItem->m_ItemHealth = m_Slots[a_ClickPacket->m_SlotNum].m_ItemHealth; + m_DraggingItem->m_ItemCount = (char)(((float)m_Slots[a_SlotNum].m_ItemCount) / 2.f + 0.5f); + m_Slots[a_SlotNum].m_ItemCount -= m_DraggingItem->m_ItemCount; + m_DraggingItem->m_ItemID = m_Slots[a_SlotNum].m_ItemID; + m_DraggingItem->m_ItemHealth = m_Slots[a_SlotNum].m_ItemHealth; - if( m_Slots[a_ClickPacket->m_SlotNum].m_ItemCount <= 0 ) + if (m_Slots[a_SlotNum].m_ItemCount <= 0) { - m_Slots[a_ClickPacket->m_SlotNum].Empty(); + m_Slots[a_SlotNum].Empty(); } } - else if( m_Slots[a_ClickPacket->m_SlotNum].m_ItemID <= 0 || m_DraggingItem->Equals( m_Slots[a_ClickPacket->m_SlotNum] ) ) - { // Drop one item in slot - if( m_DraggingItem->m_ItemCount > 0 && m_Slots[a_ClickPacket->m_SlotNum].m_ItemCount < 64 ) + else if ((m_Slots[a_SlotNum].m_ItemID <= 0) || m_DraggingItem->IsEqual(m_Slots[a_SlotNum])) + { + // Drop one item in slot + cItemHandler * Handler = ItemHandler(m_Slots[a_SlotNum].m_ItemID); + if ((m_DraggingItem->m_ItemCount > 0) && (m_Slots[a_SlotNum].m_ItemCount < Handler->GetMaxStackSize())) { - m_Slots[a_ClickPacket->m_SlotNum].m_ItemID = m_DraggingItem->m_ItemID; - m_Slots[a_ClickPacket->m_SlotNum].m_ItemCount++; - m_Slots[a_ClickPacket->m_SlotNum].m_ItemHealth = m_DraggingItem->m_ItemHealth; + m_Slots[a_SlotNum].m_ItemID = m_DraggingItem->m_ItemID; + m_Slots[a_SlotNum].m_ItemCount++; + m_Slots[a_SlotNum].m_ItemHealth = m_DraggingItem->m_ItemHealth; m_DraggingItem->m_ItemCount--; } - if( m_DraggingItem->m_ItemCount <= 0 ) + if (m_DraggingItem->m_ItemCount <= 0) { m_DraggingItem->Empty(); } } - else if( !m_DraggingItem->Equals( m_Slots[a_ClickPacket->m_SlotNum]) ) // Swap contents + else if (!m_DraggingItem->IsEqual(m_Slots[a_SlotNum])) { + // Swap contents cItem tmp( *m_DraggingItem ); - *m_DraggingItem = m_Slots[a_ClickPacket->m_SlotNum]; - m_Slots[a_ClickPacket->m_SlotNum] = tmp; // Switch contents + *m_DraggingItem = m_Slots[a_SlotNum]; + m_Slots[a_SlotNum] = tmp; } } - if( bAsync ) + if (bAsync) { - LOG("Window is not synchonous with client. Sending whole window. ID: %i", m_WindowID); - for( std::list< cPlayer* >::iterator itr = m_OpenedBy.begin(); itr != m_OpenedBy.end(); ++itr ) + // TODO: Handle this thread-safely (m_OpenedBy may change by another cSocketThread + for (cPlayerList::iterator itr = m_OpenedBy.begin(); itr != m_OpenedBy.end(); ++itr) { - SendWholeWindow( (*itr)->GetClientHandle() ); + SendWholeWindow((*itr)->GetClientHandle()); } - if( m_bInventoryVisible || m_OpenedBy.size() == 0 ) + if (m_bInventoryVisible || m_OpenedBy.empty()) { a_Player.GetInventory().SendWholeInventory( a_Player.GetClientHandle() ); } } } - else if( m_bInventoryVisible ) // Click in player inventory + else if (m_bInventoryVisible) // Click in player inventory { - a_ClickPacket->m_WindowID = 0; - a_ClickPacket->m_SlotNum -= (short)(m_NumSlots - 9); - cWindow* Window = a_Player.GetInventory().GetWindow(); - if( Window ) + cWindow * Window = a_Player.GetInventory().GetWindow(); + if (Window) { - Window->Clicked( a_ClickPacket, a_Player ); + Window->Clicked(a_Player, a_WindowID, a_SlotNum - 9, a_IsRightClick, a_IsShiftPressed, a_HeldItem); } } if (m_DraggingItem != NULL) diff --git a/source/cWindow.h b/source/cWindow.h index 303c9e503..cbb90b893 100644 --- a/source/cWindow.h +++ b/source/cWindow.h @@ -10,12 +10,11 @@ #pragma once -class cPacket_WindowClick; class cPlayer; class cItem; class cWindowOwner; class cClientHandle; -class cPacket; +class cPacket; // TODO: remove this typedef std::list<cPlayer *> cPlayerList; @@ -63,7 +62,11 @@ public: bool IsInventoryVisible() { return m_bInventoryVisible; } void SetInventoryVisible( bool a_bVisible ) { m_bInventoryVisible = a_bVisible; } - virtual void Clicked( cPacket_WindowClick* a_ClickPacket, cPlayer & a_Player ); + virtual void Clicked( + cPlayer & a_Player, int a_WindowID, + short a_SlotNum, bool a_IsRightClick, bool a_IsShiftPressed, + const cItem & a_HeldItem + ); virtual void Open( cPlayer & a_Player ); virtual void Close( cPlayer & a_Player ); @@ -71,7 +74,7 @@ public: cWindowOwner* GetOwner() { return m_Owner; } void SetOwner( cWindowOwner* a_Owner ) { m_Owner = a_Owner; } - void SendWholeWindow( cClientHandle* a_Client ); + void SendWholeWindow(cClientHandle * a_Client); void BroadcastWholeWindow(void); void Broadcast(const cPacket & a_Packet); diff --git a/source/items/Item.h b/source/items/Item.h index 5fe260fd8..f3d5842b8 100644 --- a/source/items/Item.h +++ b/source/items/Item.h @@ -19,7 +19,7 @@ class cItemHandler public:
cItemHandler(int a_ItemID);
virtual bool OnItemUse(cWorld *a_World, cPlayer *a_Player, cItem *a_Item, int a_X, int a_Y, int a_Z, char a_Dir); //eg for fishing or hoes
- virtual bool OnDiggingBlock(cWorld *a_World, cPlayer *a_Player, cItem *a_Item, int a_X, int a_Y, int a_Z, char a_Dir);
+ virtual bool OnDiggingBlock(cWorld * a_World, cPlayer * a_Player, cItem * a_HeldItem, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace);
virtual void OnBlockDestroyed(cWorld *a_World, cPlayer *a_Player, cItem *a_Item, int a_X, int a_Y, int a_Z);
virtual void OnFoodEaten(cWorld *a_World, cPlayer *a_Player, cItem *a_Item);
diff --git a/source/packets/cPacket_BlockDig.h b/source/packets/cPacket_BlockDig.h index e1bdc14f1..01eb54377 100644 --- a/source/packets/cPacket_BlockDig.h +++ b/source/packets/cPacket_BlockDig.h @@ -1,31 +1,37 @@ + #pragma once #include "cPacket.h" -class cPacket_BlockDig : public cPacket //tolua_export -{ //tolua_export + + + +class cPacket_BlockDig : + public cPacket +{ public: - cPacket_BlockDig() //tolua_export + cPacket_BlockDig() : m_Status( 0 ) , m_PosX( 0 ) , m_PosY( 0 ) , m_PosZ( 0 ) , m_Direction( 0 ) - { m_PacketID = E_BLOCK_DIG; } //tolua_export - virtual cPacket* Clone() const { return new cPacket_BlockDig(*this); } //tolua_export + { + m_PacketID = E_BLOCK_DIG; + } + + virtual cPacket* Clone() const { return new cPacket_BlockDig(*this); } virtual int Parse(cByteBuffer & a_Buffer) override; virtual void Serialize(AString & a_Data) const override; - char m_Status; // tolua_export - int m_PosX; // tolua_export - char m_PosY; // tolua_export - int m_PosZ; // tolua_export - char m_Direction; // tolua_export - - static const unsigned int c_Size = 12; -}; //tolua_export + char m_Status; + int m_PosX; + char m_PosY; + int m_PosZ; + char m_Direction; +}; diff --git a/source/packets/cPacket_BlockPlace.cpp b/source/packets/cPacket_BlockPlace.cpp index f767456a2..6b4219a8b 100644 --- a/source/packets/cPacket_BlockPlace.cpp +++ b/source/packets/cPacket_BlockPlace.cpp @@ -16,18 +16,13 @@ int cPacket_BlockPlace::Parse(cByteBuffer & a_Buffer) HANDLE_PACKET_READ(ReadBEInt, m_PosZ, TotalBytes); HANDLE_PACKET_READ(ReadChar, m_Direction, TotalBytes); - cPacket_ItemData Item; + cPacket_ItemData Item(m_HeldItem); int res = Item.Parse(a_Buffer); if (res < 0) { return res; } TotalBytes += res; - - m_ItemType = Item.m_ItemID; - m_Count = Item.m_ItemCount; - m_Uses = Item.m_ItemUses; - return TotalBytes; } diff --git a/source/packets/cPacket_BlockPlace.h b/source/packets/cPacket_BlockPlace.h index fa8aae585..187abf549 100644 --- a/source/packets/cPacket_BlockPlace.h +++ b/source/packets/cPacket_BlockPlace.h @@ -2,38 +2,36 @@ #pragma once #include "cPacket.h" +#include "../cItem.h" -class cPacket_BlockPlace : public cPacket //tolua_export -{ //tolua_export +class cPacket_BlockPlace : + public cPacket +{ public: cPacket_BlockPlace() : m_PosX( 0 ) , m_PosY( 0 ) , m_PosZ( 0 ) , m_Direction( 0 ) - , m_ItemType( 0 ) - , m_Count( 0 ) - , m_Uses( 0 ) - { m_PacketID = E_BLOCK_PLACE; } + { + m_PacketID = E_BLOCK_PLACE; + } + virtual cPacket* Clone() const { return new cPacket_BlockPlace(*this); } virtual int Parse(cByteBuffer & a_Buffer) override; - int m_PosX; //tolua_export - unsigned char m_PosY; //tolua_export - int m_PosZ; //tolua_export - char m_Direction; //tolua_export + int m_PosX; + unsigned char m_PosY; + int m_PosZ; + char m_Direction; - short m_ItemType; //tolua_export - char m_Count; //tolua_export - short m_Uses; //tolua_export - - static const unsigned int c_Size = 1 + 4 + 1 + 4 + 1 + 2;// ( + 2 ) -}; //tolua_export + cItem m_HeldItem; +} ; diff --git a/source/packets/cPacket_CreativeInventoryAction.cpp b/source/packets/cPacket_CreativeInventoryAction.cpp index a71585df3..85291da3e 100644 --- a/source/packets/cPacket_CreativeInventoryAction.cpp +++ b/source/packets/cPacket_CreativeInventoryAction.cpp @@ -10,11 +10,9 @@ cPacket_CreativeInventoryAction::cPacket_CreativeInventoryAction( const cPacket_CreativeInventoryAction & a_Copy ) { - m_PacketID = E_CREATIVE_INVENTORY_ACTION; - m_Slot = a_Copy.m_Slot; - m_ItemID = a_Copy.m_ItemID; - m_Quantity = a_Copy.m_Quantity; - m_Damage = a_Copy.m_Damage; + m_PacketID = E_CREATIVE_INVENTORY_ACTION; + m_SlotNum = a_Copy.m_SlotNum; + m_ClickedItem = a_Copy.m_ClickedItem; } @@ -24,20 +22,15 @@ cPacket_CreativeInventoryAction::cPacket_CreativeInventoryAction( const cPacket_ int cPacket_CreativeInventoryAction::Parse(cByteBuffer & a_Buffer) { int TotalBytes = 0; - HANDLE_PACKET_READ(ReadBEShort, m_Slot, TotalBytes); + HANDLE_PACKET_READ(ReadBEShort, m_SlotNum, TotalBytes); - cPacket_ItemData Item; + cPacket_ItemData Item(m_ClickedItem); int res = Item.Parse(a_Buffer); if (res < 0) { return res; } TotalBytes += res; - - m_ItemID = Item.m_ItemID; - m_Quantity = Item.m_ItemCount; - m_Damage = Item.m_ItemUses; - return TotalBytes; } @@ -47,19 +40,10 @@ int cPacket_CreativeInventoryAction::Parse(cByteBuffer & a_Buffer) void cPacket_CreativeInventoryAction::Serialize(AString & a_Data) const { - short ItemID = m_ItemID; - ASSERT(ItemID >= -1); // Check validity of packets in debug runtime - if (ItemID <= 0) - { - ItemID = -1; - // Fix, to make sure no invalid values are sent. - // WARNING: HERE ITS -1, BUT IN NAMED ENTITY SPAWN PACKET ITS 0 !! - } - - AppendByte (a_Data, m_PacketID); - AppendShort (a_Data, m_Slot); + AppendByte (a_Data, m_PacketID); + AppendShort(a_Data, m_SlotNum); - cPacket_ItemData::AppendItem(a_Data, ItemID, m_Quantity, m_Damage); + cPacket_ItemData::AppendItem(a_Data, m_ClickedItem); } diff --git a/source/packets/cPacket_CreativeInventoryAction.h b/source/packets/cPacket_CreativeInventoryAction.h index 4d983e51d..ae438a7a8 100644 --- a/source/packets/cPacket_CreativeInventoryAction.h +++ b/source/packets/cPacket_CreativeInventoryAction.h @@ -2,35 +2,31 @@ #pragma once #include "cPacket.h" +#include "../cItem.h" -//Sure itīs not Creative Inventory? - -class cPacket_CreativeInventoryAction : public cPacket +class cPacket_CreativeInventoryAction : + public cPacket { public: - cPacket_CreativeInventoryAction() - : m_Slot( 0 ) - , m_ItemID( 0 ) - , m_Quantity( 0 ) - , m_Damage( 0 ) - { m_PacketID = E_CREATIVE_INVENTORY_ACTION; m_Quantity = 1; } + cPacket_CreativeInventoryAction() : + m_SlotNum(0) + { + m_PacketID = E_CREATIVE_INVENTORY_ACTION; + } + cPacket_CreativeInventoryAction( const cPacket_CreativeInventoryAction & a_Copy ); virtual cPacket* Clone() const { return new cPacket_CreativeInventoryAction(*this); } virtual int Parse(cByteBuffer & a_Buffer) override; virtual void Serialize(AString & a_Data) const override; - short m_Slot; // 0 = hold 1-4 = armor - short m_ItemID; - char m_Quantity; //Byte not short ;) - short m_Damage; - - static const unsigned int c_Size = 1 + 2; -}; + short m_SlotNum; + cItem m_ClickedItem; +} ; diff --git a/source/packets/cPacket_Handshake.h b/source/packets/cPacket_Handshake.h index d1b06dacc..0ddddb1c1 100644 --- a/source/packets/cPacket_Handshake.h +++ b/source/packets/cPacket_Handshake.h @@ -17,7 +17,6 @@ public: virtual void Serialize(AString & a_Data) const override; std::string m_Username; - static const unsigned int c_Size = 3; // Minimal size }; diff --git a/source/packets/cPacket_ItemData.cpp b/source/packets/cPacket_ItemData.cpp index 2e4203bfc..4f0803475 100644 --- a/source/packets/cPacket_ItemData.cpp +++ b/source/packets/cPacket_ItemData.cpp @@ -10,25 +10,26 @@ int cPacket_ItemData::Parse(cByteBuffer & a_Buffer) { int TotalBytes = 0; - HANDLE_PACKET_READ(ReadBEShort, m_ItemID, TotalBytes); + HANDLE_PACKET_READ(ReadBEShort, m_Dst.m_ItemType, TotalBytes); - if (m_ItemID <= -1) + if (m_Dst.m_ItemType <= -1) { - m_ItemCount = 0; - m_ItemUses = 0; + m_Dst.Empty(); return TotalBytes; } - HANDLE_PACKET_READ(ReadChar, m_ItemCount, TotalBytes); - HANDLE_PACKET_READ(ReadBEShort, m_ItemUses, TotalBytes); + HANDLE_PACKET_READ(ReadChar, m_Dst.m_ItemCount, TotalBytes); + HANDLE_PACKET_READ(ReadBEShort, m_Dst.m_ItemDamage, TotalBytes); - if (cItem::IsEnchantable((ENUM_ITEM_ID) m_ItemID)) + if (cItem::IsEnchantable(m_Dst.m_ItemType)) { - HANDLE_PACKET_READ(ReadBEShort, m_EnchantNums, TotalBytes); + short EnchantNumBytes; + HANDLE_PACKET_READ(ReadBEShort, EnchantNumBytes, TotalBytes); - if ( m_EnchantNums > -1 ) + if (EnchantNumBytes > 0) { // TODO: Enchantment not implemented yet! + a_Buffer.SkipRead(EnchantNumBytes); } } return TotalBytes; @@ -51,24 +52,32 @@ int cPacket_ItemData::GetSize(short a_ItemID) -void cPacket_ItemData::AppendItem(AString & a_Data, const cItem * a_Item) +void cPacket_ItemData::AppendItem(AString & a_Data, const cItem & a_Item) { - return AppendItem(a_Data, a_Item->m_ItemID, a_Item->m_ItemCount, a_Item->m_ItemHealth); + return AppendItem(a_Data, a_Item.m_ItemType, a_Item.m_ItemCount, a_Item.m_ItemDamage); } -void cPacket_ItemData::AppendItem(AString & a_Data, short a_ItemID, char a_Quantity, short a_Damage) +void cPacket_ItemData::AppendItem(AString & a_Data, short a_ItemType, char a_Quantity, short a_Damage) { - AppendShort(a_Data, (short) a_ItemID); - if (a_ItemID > -1) + short ItemType = a_ItemType; + ASSERT(ItemType >= -1); // Check validity of packets in debug runtime + if (ItemType <= 0) + { + // Fix, to make sure no invalid values are sent. + ItemType = -1; + } + + AppendShort(a_Data, ItemType); + if (a_ItemType > -1) { AppendByte (a_Data, a_Quantity); AppendShort(a_Data, a_Damage); - if (cItem::IsEnchantable((ENUM_ITEM_ID) a_ItemID)) + if (cItem::IsEnchantable(a_ItemType)) { // TODO: Implement enchantments AppendShort(a_Data, (short) -1); diff --git a/source/packets/cPacket_ItemData.h b/source/packets/cPacket_ItemData.h index 5a1554b19..e1a6c547d 100644 --- a/source/packets/cPacket_ItemData.h +++ b/source/packets/cPacket_ItemData.h @@ -1,35 +1,34 @@ + #pragma once #include "cPacket.h" #include "../cItem.h" + + + + class cPacket_ItemData : public cPacket { + cItem & m_Dst; + public: - cPacket_ItemData() - : m_ItemID( 0 ) - , m_ItemCount( 0 ) - , m_ItemUses( 0 ) - , m_EnchantNums(-1) + cPacket_ItemData(cItem & a_Dst) : + m_Dst(a_Dst) { } - virtual cPacket* Clone() const { return new cPacket_ItemData(*this); } + virtual cPacket * Clone() const { return new cPacket_ItemData(*this); } virtual int Parse(cByteBuffer & a_Buffer) override; - static void AppendItem(AString & a_Data, short a_ItemID, char a_Quantity, short a_Damage); - static void AppendItem(AString & a_Data, const cItem * a_Item); + static void AppendItem(AString & a_Data, short a_ItemType, char a_Quantity, short a_Damage); + static void AppendItem(AString & a_Data, const cItem & a_Item); int GetSize(short a_ItemID); +} ; + - // Below = item - short m_ItemID; // if this is -1 the next stuff dont exist - char m_ItemCount; - short m_ItemUses; - short m_EnchantNums; - static unsigned int c_Size; // Minimal size ( +1+1 = max) -};
\ No newline at end of file diff --git a/source/packets/cPacket_Login.cpp b/source/packets/cPacket_Login.cpp index 90da4c009..b19e389d1 100644 --- a/source/packets/cPacket_Login.cpp +++ b/source/packets/cPacket_Login.cpp @@ -7,8 +7,8 @@ -const std::string cPacket_Login::LEVEL_TYPE_DEFAULT = "DEFAULT"; -const std::string cPacket_Login::LEVEL_TYPE_SUPERFLAT = "SUPERFLAT"; +const char * cPacket_Login::LEVEL_TYPE_DEFAULT = "DEFAULT"; +const char * cPacket_Login::LEVEL_TYPE_SUPERFLAT = "SUPERFLAT"; @@ -16,7 +16,6 @@ const std::string cPacket_Login::LEVEL_TYPE_SUPERFLAT = "SUPERFLAT"; int cPacket_Login::Parse(cByteBuffer & a_Buffer) { - //printf("Parse: NEW Login\n"); int TotalBytes = 0; m_Username.clear(); HANDLE_PACKET_READ(ReadBEInt, m_ProtocolVersion, TotalBytes); diff --git a/source/packets/cPacket_Login.h b/source/packets/cPacket_Login.h index f512b098a..a93d2807e 100644 --- a/source/packets/cPacket_Login.h +++ b/source/packets/cPacket_Login.h @@ -7,8 +7,8 @@ -class cPacket_Login : public cPacket //tolua_export -{ //tolua_export +class cPacket_Login : public cPacket +{ public: cPacket_Login() : m_ProtocolVersion( 0 ) @@ -24,18 +24,18 @@ public: virtual int Parse(cByteBuffer & a_Buffer) override; virtual void Serialize(AString & a_Data) const override; - int m_ProtocolVersion; //tolua_export - AString m_Username; //tolua_export - AString m_LevelType; //tolua_export - int m_ServerMode; //tolua_export - int m_Dimension; - char m_Difficulty; //tolua_export - unsigned char m_WorldHeight; //tolua_export - unsigned char m_MaxPlayers; //tolua_export - - static const AString LEVEL_TYPE_DEFAULT; - static const AString LEVEL_TYPE_SUPERFLAT; -}; //tolua_export + int m_ProtocolVersion; + AString m_Username; + AString m_LevelType; + int m_ServerMode; + int m_Dimension; + char m_Difficulty; + unsigned char m_WorldHeight; + unsigned char m_MaxPlayers; + + static const char * LEVEL_TYPE_DEFAULT; + static const char * LEVEL_TYPE_SUPERFLAT; +}; diff --git a/source/packets/cPacket_Player.cpp b/source/packets/cPacket_Player.cpp index a71cdee33..3a897a1ea 100644 --- a/source/packets/cPacket_Player.cpp +++ b/source/packets/cPacket_Player.cpp @@ -195,15 +195,15 @@ void cPacket_PlayerMoveLook::Serialize(AString & a_Data) const /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cPacket_PlayerPosition: -cPacket_PlayerPosition::cPacket_PlayerPosition( cPlayer* a_Player ) +cPacket_PlayerPosition::cPacket_PlayerPosition(cPlayer * a_Player) { m_PacketID = E_PLAYERPOS; - m_PosX = a_Player->GetPosX(); - m_PosY = a_Player->GetPosY() + 1.65; - m_PosZ = a_Player->GetPosZ(); - m_Stance = a_Player->GetStance(); - m_bFlying = a_Player->GetFlying(); + m_PosX = a_Player->GetPosX(); + m_PosY = a_Player->GetPosY() + 1.65; + m_PosZ = a_Player->GetPosZ(); + m_Stance = a_Player->GetStance(); + m_IsOnGround = a_Player->IsOnGround(); } @@ -213,11 +213,11 @@ cPacket_PlayerPosition::cPacket_PlayerPosition( cPlayer* a_Player ) int cPacket_PlayerPosition::Parse(cByteBuffer & a_Buffer) { int TotalBytes = 0; - HANDLE_PACKET_READ(ReadBEDouble, m_PosX, TotalBytes); - HANDLE_PACKET_READ(ReadBEDouble, m_PosY, TotalBytes); - HANDLE_PACKET_READ(ReadBEDouble, m_Stance, TotalBytes); - HANDLE_PACKET_READ(ReadBEDouble, m_PosZ, TotalBytes); - HANDLE_PACKET_READ(ReadBool, m_bFlying, TotalBytes); + HANDLE_PACKET_READ(ReadBEDouble, m_PosX, TotalBytes); + HANDLE_PACKET_READ(ReadBEDouble, m_PosY, TotalBytes); + HANDLE_PACKET_READ(ReadBEDouble, m_Stance, TotalBytes); + HANDLE_PACKET_READ(ReadBEDouble, m_PosZ, TotalBytes); + HANDLE_PACKET_READ(ReadBool, m_IsOnGround, TotalBytes); return TotalBytes; } @@ -232,7 +232,7 @@ void cPacket_PlayerPosition::Serialize(AString & a_Data) const AppendDouble (a_Data, m_PosY); AppendDouble (a_Data, m_Stance); AppendDouble (a_Data, m_PosZ); - AppendBool (a_Data, m_bFlying); + AppendBool (a_Data, m_IsOnGround); } diff --git a/source/packets/cPacket_Player.h b/source/packets/cPacket_Player.h index 8dadcdaea..05b75d9d1 100644 --- a/source/packets/cPacket_Player.h +++ b/source/packets/cPacket_Player.h @@ -129,9 +129,9 @@ public: cPacket_PlayerPosition() : m_PosX( 0.0 ) , m_PosY( 0.0 ) - , m_Stance( 0.0 ) , m_PosZ( 0.0 ) - , m_bFlying( false ) + , m_Stance( 0.0 ) + , m_IsOnGround(true) { m_PacketID = E_PLAYERPOS; } virtual cPacket* Clone() const { return new cPacket_PlayerPosition(*this); } @@ -140,9 +140,9 @@ public: double m_PosX; double m_PosY; - double m_Stance; double m_PosZ; - bool m_bFlying; // Yeah.. wtf + double m_Stance; + bool m_IsOnGround; } ; diff --git a/source/packets/cPacket_WholeInventory.cpp b/source/packets/cPacket_WholeInventory.cpp index 3b8fa5cde..fd6a6b457 100644 --- a/source/packets/cPacket_WholeInventory.cpp +++ b/source/packets/cPacket_WholeInventory.cpp @@ -17,19 +17,21 @@ cPacket_WholeInventory::cPacket_WholeInventory( const cPacket_WholeInventory & a m_WindowID = a_Clone.m_WindowID; m_Count = a_Clone.m_Count; m_Items = new cItem[m_Count]; - memcpy( m_Items, a_Clone.m_Items, sizeof(cItem)*m_Count ); + // TODO: copy items one by one, they may have some values that needn't be shallow-copiable + memcpy(m_Items, a_Clone.m_Items, sizeof(cItem) * m_Count); } -cPacket_WholeInventory::cPacket_WholeInventory( cInventory* a_Inventory ) +cPacket_WholeInventory::cPacket_WholeInventory(cInventory * a_Inventory) { m_PacketID = E_INVENTORY_WHOLE; m_WindowID = 0; m_Count = a_Inventory->c_NumSlots; m_Items = new cItem[m_Count]; + // TODO: copy items one by one, they may have some values that needn't be shallow-copiable memcpy( m_Items, a_Inventory->GetSlots(), sizeof(cItem)*m_Count ); } @@ -37,13 +39,14 @@ cPacket_WholeInventory::cPacket_WholeInventory( cInventory* a_Inventory ) -cPacket_WholeInventory::cPacket_WholeInventory( cWindow* a_Window ) +cPacket_WholeInventory::cPacket_WholeInventory(cWindow * a_Window) { m_PacketID = E_INVENTORY_WHOLE; m_WindowID = (char)a_Window->GetWindowID(); m_Count = (short)a_Window->GetNumSlots(); m_Items = new cItem[m_Count]; - memcpy( m_Items, a_Window->GetSlots(), sizeof(cItem)*m_Count ); + // TODO: copy items one by one, they may have some values that needn't be shallow-copiable + memcpy( m_Items, a_Window->GetSlots(), sizeof(cItem) * m_Count); } @@ -67,7 +70,7 @@ void cPacket_WholeInventory::Serialize(AString & a_Data) const for (int j = 0; j < m_Count; j++) { - cPacket_ItemData::AppendItem(a_Data, &(m_Items[j])); + cPacket_ItemData::AppendItem(a_Data, m_Items[j]); } } diff --git a/source/packets/cPacket_WindowClick.cpp b/source/packets/cPacket_WindowClick.cpp index c250c187e..1d4304917 100644 --- a/source/packets/cPacket_WindowClick.cpp +++ b/source/packets/cPacket_WindowClick.cpp @@ -14,11 +14,11 @@ int cPacket_WindowClick::Parse(cByteBuffer & a_Buffer) int TotalBytes = 0; HANDLE_PACKET_READ(ReadChar, m_WindowID, TotalBytes); HANDLE_PACKET_READ(ReadBEShort, m_SlotNum, TotalBytes); - HANDLE_PACKET_READ(ReadChar, m_RightMouse, TotalBytes); - HANDLE_PACKET_READ(ReadBEShort, m_NumClicks, TotalBytes); + HANDLE_PACKET_READ(ReadBool, m_IsRightClick, TotalBytes); + HANDLE_PACKET_READ(ReadBEShort, m_TransactionID, TotalBytes); HANDLE_PACKET_READ(ReadBool, m_IsShiftPressed, TotalBytes); - cPacket_ItemData Item; + cPacket_ItemData Item(m_HeldItem); int res = Item.Parse(a_Buffer); if (res < 0) { @@ -26,12 +26,6 @@ int cPacket_WindowClick::Parse(cByteBuffer & a_Buffer) } TotalBytes += res; - m_ItemID = Item.m_ItemID; - m_ItemCount = Item.m_ItemCount; - m_ItemUses = Item.m_ItemUses; - - m_EnchantNums = Item.m_EnchantNums; - return TotalBytes; } diff --git a/source/packets/cPacket_WindowClick.h b/source/packets/cPacket_WindowClick.h index 72ebad2a1..e0f6f964e 100644 --- a/source/packets/cPacket_WindowClick.h +++ b/source/packets/cPacket_WindowClick.h @@ -2,6 +2,7 @@ #pragma once #include "cPacket.h" +#include "../cItem.h" @@ -13,36 +14,24 @@ public: cPacket_WindowClick() : m_WindowID( 0 ) , m_SlotNum( 0 ) - , m_RightMouse( 0 ) - , m_NumClicks( 0 ) + , m_IsRightClick(false) + , m_TransactionID( 0 ) , m_IsShiftPressed( false ) - , m_ItemID( 0 ) - , m_ItemCount( 0 ) - , m_ItemUses( 0 ) - , m_EnchantNums(-1) - { m_PacketID = E_WINDOW_CLICK; } + { + m_PacketID = E_WINDOW_CLICK; + } + virtual cPacket* Clone() const { return new cPacket_WindowClick(*this); } virtual int Parse(cByteBuffer & a_Buffer) override; char m_WindowID; - short m_SlotNum; // Slot - // 0 = craft result - // 1-4 = crafting table - // 5-8 = armor - // 9-35 = inventory - // 36-44 = Hot bar - - char m_RightMouse; // 0 = Left 1 = Right mb - short m_NumClicks; // Num clicks + short m_SlotNum; + bool m_IsRightClick; + short m_TransactionID; bool m_IsShiftPressed; // Shift pressed when clicked? - // Below = item - short m_ItemID; // if this is -1 the next stuff dont exist - char m_ItemCount; - short m_ItemUses; - - short m_EnchantNums; + cItem m_HeldItem; }; |