diff options
-rw-r--r-- | Tools/ProtoProxy/Connection.cpp | 26 | ||||
-rw-r--r-- | Tools/ProtoProxy/Connection.h | 6 | ||||
-rw-r--r-- | Tools/ProtoProxy/Globals.h | 1 | ||||
-rw-r--r-- | Tools/ProtoProxy/ProtoProxy.vcproj | 8 | ||||
-rw-r--r-- | docs/Login sequence.txt | 26 | ||||
-rw-r--r-- | source/Bindings.cpp | 312 | ||||
-rw-r--r-- | source/Bindings.h | 2 | ||||
-rw-r--r-- | source/Defines.h | 10 | ||||
-rw-r--r-- | source/Entities/ProjectileEntity.h | 4 | ||||
-rw-r--r-- | source/OSSupport/IsThread.cpp | 17 | ||||
-rw-r--r-- | source/OSSupport/Timer.cpp | 45 | ||||
-rw-r--r-- | source/OSSupport/Timer.h | 31 |
12 files changed, 445 insertions, 43 deletions
diff --git a/Tools/ProtoProxy/Connection.cpp b/Tools/ProtoProxy/Connection.cpp index 4c2b0d4e9..08daf5766 100644 --- a/Tools/ProtoProxy/Connection.cpp +++ b/Tools/ProtoProxy/Connection.cpp @@ -201,6 +201,9 @@ enum PACKET_ENCRYPTION_KEY_REQUEST = 0xfd, PACKET_PING = 0xfe, PACKET_KICK = 0xff, + + // Synonyms: + PACKET_DISCONNECT = PACKET_KICK, } ; @@ -238,7 +241,7 @@ cConnection::cConnection(SOCKET a_ClientSocket, cServer & a_Server) : m_Server(a_Server), m_ClientSocket(a_ClientSocket), m_ServerSocket(-1), - m_BeginTick(clock()), + m_BeginTick(m_Timer.GetNowTime()), m_ClientState(csUnencrypted), m_ServerState(csUnencrypted), m_Nonce(0), @@ -475,8 +478,7 @@ bool cConnection::RelayFromClient(void) double cConnection::GetRelativeTime(void) { - return (double)(clock() - m_BeginTick) / CLOCKS_PER_SEC; - + return (double)(m_Timer.GetNowTime() - m_BeginTick) / 1000; } @@ -558,9 +560,9 @@ bool cConnection::DecodeClientsPackets(const char * a_Data, int a_Size) while (m_ClientBuffer.CanReadBytes(1)) { - Log("Decoding client's packets, there are now %d bytes in the queue", m_ClientBuffer.GetReadableSpace()); unsigned char PacketType; m_ClientBuffer.ReadByte(PacketType); + Log("Decoding client's packets, there are now %d bytes in the queue; next packet is 0x%02x", m_ClientBuffer.GetReadableSpace(), PacketType); switch (PacketType) { case PACKET_BLOCK_DIG: HANDLE_CLIENT_READ(HandleClientBlockDig); break; @@ -568,6 +570,7 @@ bool cConnection::DecodeClientsPackets(const char * a_Data, int a_Size) case PACKET_CHAT_MESSAGE: HANDLE_CLIENT_READ(HandleClientChatMessage); break; case PACKET_CLIENT_STATUSES: HANDLE_CLIENT_READ(HandleClientClientStatuses); break; case PACKET_CREATIVE_INVENTORY_ACTION: HANDLE_CLIENT_READ(HandleClientCreativeInventoryAction); break; + case PACKET_DISCONNECT: HANDLE_CLIENT_READ(HandleClientDisconnect); break; case PACKET_ENCRYPTION_KEY_RESPONSE: HANDLE_CLIENT_READ(HandleClientEncryptionKeyResponse); break; case PACKET_ENTITY_ACTION: HANDLE_CLIENT_READ(HandleClientEntityAction); break; case PACKET_HANDSHAKE: HANDLE_CLIENT_READ(HandleClientHandshake); break; @@ -644,7 +647,7 @@ bool cConnection::DecodeServersPackets(const char * a_Data, int a_Size) { unsigned char PacketType; m_ServerBuffer.ReadByte(PacketType); - Log("Decoding server's packets, there are now %d bytes in the queue; next packet is 0x%x", m_ServerBuffer.GetReadableSpace(), PacketType); + Log("Decoding server's packets, there are now %d bytes in the queue; next packet is 0x%02x", m_ServerBuffer.GetReadableSpace(), PacketType); LogFlush(); switch (PacketType) { @@ -843,6 +846,19 @@ bool cConnection::HandleClientCreativeInventoryAction(void) +bool cConnection::HandleClientDisconnect(void) +{ + HANDLE_CLIENT_PACKET_READ(ReadBEUTF16String16, AString, Reason); + Log("Received a PACKET_DISCONNECT from the client:"); + Log(" Reason = \"%s\"", Reason.c_str()); + COPY_TO_SERVER(); + return true; +} + + + + + bool cConnection::HandleClientEncryptionKeyResponse(void) { HANDLE_CLIENT_PACKET_READ(ReadBEShort, short, EncKeyLength); diff --git a/Tools/ProtoProxy/Connection.h b/Tools/ProtoProxy/Connection.h index 8d466c62d..c30a28727 100644 --- a/Tools/ProtoProxy/Connection.h +++ b/Tools/ProtoProxy/Connection.h @@ -9,8 +9,8 @@ #pragma once -#include <time.h> #include "ByteBuffer.h" +#include "../../source/OSSupport/Timer.h" @@ -35,7 +35,8 @@ class cConnection SOCKET m_ClientSocket; SOCKET m_ServerSocket; - clock_t m_BeginTick; // Tick when the relative time was first retrieved (used for GetRelativeTime()) + cTimer m_Timer; + long long m_BeginTick; // Tick when the relative time was first retrieved (used for GetRelativeTime()) enum eConnectionState { @@ -115,6 +116,7 @@ protected: bool HandleClientChatMessage(void); bool HandleClientClientStatuses(void); bool HandleClientCreativeInventoryAction(void); + bool HandleClientDisconnect(void); bool HandleClientEncryptionKeyResponse(void); bool HandleClientEntityAction(void); bool HandleClientHandshake(void); diff --git a/Tools/ProtoProxy/Globals.h b/Tools/ProtoProxy/Globals.h index f2c47e96f..3b154b866 100644 --- a/Tools/ProtoProxy/Globals.h +++ b/Tools/ProtoProxy/Globals.h @@ -143,6 +143,7 @@ typedef short Int16; #include <stdio.h> #include <math.h> #include <stdarg.h> +#include <time.h> diff --git a/Tools/ProtoProxy/ProtoProxy.vcproj b/Tools/ProtoProxy/ProtoProxy.vcproj index 695e01e76..926bbe586 100644 --- a/Tools/ProtoProxy/ProtoProxy.vcproj +++ b/Tools/ProtoProxy/ProtoProxy.vcproj @@ -256,6 +256,14 @@ RelativePath="..\..\source\StringUtils.h" > </File> + <File + RelativePath="..\..\source\OSSupport\Timer.cpp" + > + </File> + <File + RelativePath="..\..\source\OSSupport\Timer.h" + > + </File> </Filter> <File RelativePath=".\ProtoProxy.txt" diff --git a/docs/Login sequence.txt b/docs/Login sequence.txt new file mode 100644 index 000000000..df9d386c6 --- /dev/null +++ b/docs/Login sequence.txt @@ -0,0 +1,26 @@ + +This is the connection sequence of the 1.6.2 client to a vanilla server, after the encryption has been established: + +S->C: 0xfc (encryption key response) empty payload (4 * 0x00) +C->S: 0xcd (client statuses) +S->C: 0x01 (login) +S->C: 0xfa (plugin message) - "MC|Brand": "vanilla" +S->C: 0x06 (compass) +S->C: 0xca (player capabilities) +S->C: 0x10 (slot select) +S->C: 0x04 (time update) +S->C: 0xc9 (player list item) +S->C: 0x0d (player pos + look) +S->C: 0x04 (time update) +S->C: 0x68 (window contents) +S->C: 0x67 (slot contents) - Window -1, slot -1 +S->C: 0x67 (slot contents) - Window 0, slot 9 .. 44, only occupied slots +S->C: 0x38 (chunk bulk) +S->C: 0x28 (entity metadata) player metadata +S->C: 0x2c (entity properties) player properties +S->C: 0x04 (time update) +S->C: 0x38 (chunk bulk) +C->S: 0xcc (client settings / locale and view) +C->S: 0xfa (plugin message) - "MC|Brand": "vanilla" +C->S: 0x0d (player pos + look) +S->C: 0x38 (chunk bulk)
\ No newline at end of file diff --git a/source/Bindings.cpp b/source/Bindings.cpp index e5ec4dfd2..af3e83dda 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/25/13 21:26:25. +** Generated automatically by tolua++-1.0.92 on 08/30/13 14:30:24. */ #ifndef __cplusplus @@ -3078,6 +3078,182 @@ static int tolua_set_AllToLua_g_BlockOneHitDig(lua_State* tolua_S) } #endif //#ifndef TOLUA_DISABLE +/* get function: g_BlockPistonBreakable */ +#ifndef TOLUA_DISABLE_tolua_get_AllToLua_g_BlockPistonBreakable +static int tolua_get_AllToLua_g_BlockPistonBreakable(lua_State* tolua_S) +{ + int tolua_index; +#ifndef TOLUA_RELEASE + { + tolua_Error tolua_err; + if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err); + } +#endif + tolua_index = (int)tolua_tonumber(tolua_S,2,0); +#ifndef TOLUA_RELEASE + if (tolua_index<0 || tolua_index>=256) + tolua_error(tolua_S,"array indexing out of range.",NULL); +#endif + tolua_pushboolean(tolua_S,(bool)g_BlockPistonBreakable[tolua_index]); + return 1; +} +#endif //#ifndef TOLUA_DISABLE + +/* set function: g_BlockPistonBreakable */ +#ifndef TOLUA_DISABLE_tolua_set_AllToLua_g_BlockPistonBreakable +static int tolua_set_AllToLua_g_BlockPistonBreakable(lua_State* tolua_S) +{ + int tolua_index; +#ifndef TOLUA_RELEASE + { + tolua_Error tolua_err; + if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err); + } +#endif + tolua_index = (int)tolua_tonumber(tolua_S,2,0); +#ifndef TOLUA_RELEASE + if (tolua_index<0 || tolua_index>=256) + tolua_error(tolua_S,"array indexing out of range.",NULL); +#endif + g_BlockPistonBreakable[tolua_index] = ((bool) tolua_toboolean(tolua_S,3,0)); + return 0; +} +#endif //#ifndef TOLUA_DISABLE + +/* get function: g_BlockIsSnowable */ +#ifndef TOLUA_DISABLE_tolua_get_AllToLua_g_BlockIsSnowable +static int tolua_get_AllToLua_g_BlockIsSnowable(lua_State* tolua_S) +{ + int tolua_index; +#ifndef TOLUA_RELEASE + { + tolua_Error tolua_err; + if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err); + } +#endif + tolua_index = (int)tolua_tonumber(tolua_S,2,0); +#ifndef TOLUA_RELEASE + if (tolua_index<0 || tolua_index>=256) + tolua_error(tolua_S,"array indexing out of range.",NULL); +#endif + tolua_pushboolean(tolua_S,(bool)g_BlockIsSnowable[tolua_index]); + return 1; +} +#endif //#ifndef TOLUA_DISABLE + +/* set function: g_BlockIsSnowable */ +#ifndef TOLUA_DISABLE_tolua_set_AllToLua_g_BlockIsSnowable +static int tolua_set_AllToLua_g_BlockIsSnowable(lua_State* tolua_S) +{ + int tolua_index; +#ifndef TOLUA_RELEASE + { + tolua_Error tolua_err; + if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err); + } +#endif + tolua_index = (int)tolua_tonumber(tolua_S,2,0); +#ifndef TOLUA_RELEASE + if (tolua_index<0 || tolua_index>=256) + tolua_error(tolua_S,"array indexing out of range.",NULL); +#endif + g_BlockIsSnowable[tolua_index] = ((bool) tolua_toboolean(tolua_S,3,0)); + return 0; +} +#endif //#ifndef TOLUA_DISABLE + +/* get function: g_BlockRequiresSpecialTool */ +#ifndef TOLUA_DISABLE_tolua_get_AllToLua_g_BlockRequiresSpecialTool +static int tolua_get_AllToLua_g_BlockRequiresSpecialTool(lua_State* tolua_S) +{ + int tolua_index; +#ifndef TOLUA_RELEASE + { + tolua_Error tolua_err; + if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err); + } +#endif + tolua_index = (int)tolua_tonumber(tolua_S,2,0); +#ifndef TOLUA_RELEASE + if (tolua_index<0 || tolua_index>=256) + tolua_error(tolua_S,"array indexing out of range.",NULL); +#endif + tolua_pushboolean(tolua_S,(bool)g_BlockRequiresSpecialTool[tolua_index]); + return 1; +} +#endif //#ifndef TOLUA_DISABLE + +/* set function: g_BlockRequiresSpecialTool */ +#ifndef TOLUA_DISABLE_tolua_set_AllToLua_g_BlockRequiresSpecialTool +static int tolua_set_AllToLua_g_BlockRequiresSpecialTool(lua_State* tolua_S) +{ + int tolua_index; +#ifndef TOLUA_RELEASE + { + tolua_Error tolua_err; + if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err); + } +#endif + tolua_index = (int)tolua_tonumber(tolua_S,2,0); +#ifndef TOLUA_RELEASE + if (tolua_index<0 || tolua_index>=256) + tolua_error(tolua_S,"array indexing out of range.",NULL); +#endif + g_BlockRequiresSpecialTool[tolua_index] = ((bool) tolua_toboolean(tolua_S,3,0)); + return 0; +} +#endif //#ifndef TOLUA_DISABLE + +/* get function: g_BlockIsSolid */ +#ifndef TOLUA_DISABLE_tolua_get_AllToLua_g_BlockIsSolid +static int tolua_get_AllToLua_g_BlockIsSolid(lua_State* tolua_S) +{ + int tolua_index; +#ifndef TOLUA_RELEASE + { + tolua_Error tolua_err; + if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err); + } +#endif + tolua_index = (int)tolua_tonumber(tolua_S,2,0); +#ifndef TOLUA_RELEASE + if (tolua_index<0 || tolua_index>=256) + tolua_error(tolua_S,"array indexing out of range.",NULL); +#endif + tolua_pushboolean(tolua_S,(bool)g_BlockIsSolid[tolua_index]); + return 1; +} +#endif //#ifndef TOLUA_DISABLE + +/* set function: g_BlockIsSolid */ +#ifndef TOLUA_DISABLE_tolua_set_AllToLua_g_BlockIsSolid +static int tolua_set_AllToLua_g_BlockIsSolid(lua_State* tolua_S) +{ + int tolua_index; +#ifndef TOLUA_RELEASE + { + tolua_Error tolua_err; + if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err); + } +#endif + tolua_index = (int)tolua_tonumber(tolua_S,2,0); +#ifndef TOLUA_RELEASE + if (tolua_index<0 || tolua_index>=256) + tolua_error(tolua_S,"array indexing out of range.",NULL); +#endif + g_BlockIsSolid[tolua_index] = ((bool) tolua_toboolean(tolua_S,3,0)); + return 0; +} +#endif //#ifndef TOLUA_DISABLE + /* function: ClickActionToString */ #ifndef TOLUA_DISABLE_tolua_AllToLua_ClickActionToString00 static int tolua_AllToLua_ClickActionToString00(lua_State* tolua_S) @@ -9528,6 +9704,88 @@ static int tolua_AllToLua_cProjectileEntity_IsInGround00(lua_State* tolua_S) } #endif //#ifndef TOLUA_DISABLE +/* method: PosFromPlayerPos of class cArrowEntity */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_cArrowEntity_PosFromPlayerPos00 +static int tolua_AllToLua_cArrowEntity_PosFromPlayerPos00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertable(tolua_S,1,"cArrowEntity",0,&tolua_err) || + (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const cPlayer",0,&tolua_err)) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const cPlayer* a_Player = ((const cPlayer*) tolua_tousertype(tolua_S,2,0)); + { + Vector3d tolua_ret = (Vector3d) cArrowEntity::PosFromPlayerPos(*a_Player); + { +#ifdef __cplusplus + void* tolua_obj = Mtolua_new((Vector3d)(tolua_ret)); + tolua_pushusertype(tolua_S,tolua_obj,"Vector3d"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#else + void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(Vector3d)); + tolua_pushusertype(tolua_S,tolua_obj,"Vector3d"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#endif + } + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'PosFromPlayerPos'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: SpeedFromPlayerLook of class cArrowEntity */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_cArrowEntity_SpeedFromPlayerLook00 +static int tolua_AllToLua_cArrowEntity_SpeedFromPlayerLook00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertable(tolua_S,1,"cArrowEntity",0,&tolua_err) || + (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const cPlayer",0,&tolua_err)) || + !tolua_isnumber(tolua_S,3,0,&tolua_err) || + !tolua_isnoobj(tolua_S,4,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const cPlayer* a_Player = ((const cPlayer*) tolua_tousertype(tolua_S,2,0)); + double a_Force = ((double) tolua_tonumber(tolua_S,3,0)); + { + Vector3d tolua_ret = (Vector3d) cArrowEntity::SpeedFromPlayerLook(*a_Player,a_Force); + { +#ifdef __cplusplus + void* tolua_obj = Mtolua_new((Vector3d)(tolua_ret)); + tolua_pushusertype(tolua_S,tolua_obj,"Vector3d"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#else + void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(Vector3d)); + tolua_pushusertype(tolua_S,tolua_obj,"Vector3d"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#endif + } + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'SpeedFromPlayerLook'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + /* method: GetPickupState of class cArrowEntity */ #ifndef TOLUA_DISABLE_tolua_AllToLua_cArrowEntity_GetPickupState00 static int tolua_AllToLua_cArrowEntity_GetPickupState00(lua_State* tolua_S) @@ -20740,6 +20998,50 @@ tolua_lerror: } #endif //#ifndef TOLUA_DISABLE +/* method: operator/ of class Vector3d */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_Vector3d__div00 +static int tolua_AllToLua_Vector3d__div00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const Vector3d",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const Vector3d* self = (const Vector3d*) tolua_tousertype(tolua_S,1,0); + const double f = ((const double) tolua_tonumber(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator/'", NULL); +#endif + { + Vector3d tolua_ret = (Vector3d) self->operator/(f); + { +#ifdef __cplusplus + void* tolua_obj = Mtolua_new((Vector3d)(tolua_ret)); + tolua_pushusertype(tolua_S,tolua_obj,"Vector3d"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#else + void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(Vector3d)); + tolua_pushusertype(tolua_S,tolua_obj,"Vector3d"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#endif + } + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function '.div'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + /* get function: x of class Vector3d */ #ifndef TOLUA_DISABLE_tolua_get_Vector3d_x static int tolua_get_Vector3d_x(lua_State* tolua_S) @@ -27769,6 +28071,7 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S) tolua_constant(tolua_S,"E_ITEM_WAIT_DISC",E_ITEM_WAIT_DISC); tolua_constant(tolua_S,"E_ITEM_LAST_DISC_PLUS_ONE",E_ITEM_LAST_DISC_PLUS_ONE); tolua_constant(tolua_S,"E_ITEM_LAST_DISC",E_ITEM_LAST_DISC); + tolua_constant(tolua_S,"E_ITEM_LAST",E_ITEM_LAST); tolua_constant(tolua_S,"E_META_CHEST_FACING_ZM",E_META_CHEST_FACING_ZM); tolua_constant(tolua_S,"E_META_CHEST_FACING_ZP",E_META_CHEST_FACING_ZP); tolua_constant(tolua_S,"E_META_CHEST_FACING_XM",E_META_CHEST_FACING_XM); @@ -28017,6 +28320,10 @@ 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_array(tolua_S,"g_BlockPistonBreakable",tolua_get_AllToLua_g_BlockPistonBreakable,tolua_set_AllToLua_g_BlockPistonBreakable); + tolua_array(tolua_S,"g_BlockIsSnowable",tolua_get_AllToLua_g_BlockIsSnowable,tolua_set_AllToLua_g_BlockIsSnowable); + tolua_array(tolua_S,"g_BlockRequiresSpecialTool",tolua_get_AllToLua_g_BlockRequiresSpecialTool,tolua_set_AllToLua_g_BlockRequiresSpecialTool); + tolua_array(tolua_S,"g_BlockIsSolid",tolua_get_AllToLua_g_BlockIsSolid,tolua_set_AllToLua_g_BlockIsSolid); tolua_constant(tolua_S,"BLOCK_FACE_NONE",BLOCK_FACE_NONE); tolua_constant(tolua_S,"BLOCK_FACE_BOTTOM",BLOCK_FACE_BOTTOM); tolua_constant(tolua_S,"BLOCK_FACE_TOP",BLOCK_FACE_TOP); @@ -28370,6 +28677,8 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S) tolua_constant(tolua_S,"psNoPickup",cArrowEntity::psNoPickup); tolua_constant(tolua_S,"psInSurvivalOrCreative",cArrowEntity::psInSurvivalOrCreative); tolua_constant(tolua_S,"psInCreative",cArrowEntity::psInCreative); + tolua_function(tolua_S,"PosFromPlayerPos",tolua_AllToLua_cArrowEntity_PosFromPlayerPos00); + tolua_function(tolua_S,"SpeedFromPlayerLook",tolua_AllToLua_cArrowEntity_SpeedFromPlayerLook00); tolua_function(tolua_S,"GetPickupState",tolua_AllToLua_cArrowEntity_GetPickupState00); tolua_function(tolua_S,"SetPickupState",tolua_AllToLua_cArrowEntity_SetPickupState00); tolua_function(tolua_S,"GetDamageCoeff",tolua_AllToLua_cArrowEntity_GetDamageCoeff00); @@ -28938,6 +29247,7 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S) tolua_function(tolua_S,".sub",tolua_AllToLua_Vector3d__sub01); tolua_function(tolua_S,".mul",tolua_AllToLua_Vector3d__mul00); tolua_function(tolua_S,".mul",tolua_AllToLua_Vector3d__mul01); + tolua_function(tolua_S,".div",tolua_AllToLua_Vector3d__div00); tolua_variable(tolua_S,"x",tolua_get_Vector3d_x,tolua_set_Vector3d_x); tolua_variable(tolua_S,"y",tolua_get_Vector3d_y,tolua_set_Vector3d_y); tolua_variable(tolua_S,"z",tolua_get_Vector3d_z,tolua_set_Vector3d_z); diff --git a/source/Bindings.h b/source/Bindings.h index 9ab753010..e5b7e0f76 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/25/13 21:26:25. +** Generated automatically by tolua++-1.0.92 on 08/30/13 14:30:25. */ /* Exported function */ diff --git a/source/Defines.h b/source/Defines.h index 48a7cfb1e..6bc1a18f6 100644 --- a/source/Defines.h +++ b/source/Defines.h @@ -29,6 +29,16 @@ extern bool g_BlockTransparent[]; /// Is a block destroyed after a single hit? extern bool g_BlockOneHitDig[]; +/// Can a piston break this block? +extern bool g_BlockPistonBreakable[256]; + +/// Can this block hold snow atop? +extern bool g_BlockIsSnowable[256]; + +extern bool g_BlockRequiresSpecialTool[256]; + +extern bool g_BlockIsSolid[256]; + diff --git a/source/Entities/ProjectileEntity.h b/source/Entities/ProjectileEntity.h index de0366014..1569ad035 100644 --- a/source/Entities/ProjectileEntity.h +++ b/source/Entities/ProjectileEntity.h @@ -73,9 +73,13 @@ protected: /// True if the projectile has hit the ground and is stuck there bool m_IsInGround; + // tolua_end + // cEntity overrides: virtual void Tick(float a_Dt, cChunk & a_Chunk) override; virtual void HandlePhysics(float a_Dt, cChunk & a_Chunk) override; + + // tolua_begin } ; diff --git a/source/OSSupport/IsThread.cpp b/source/OSSupport/IsThread.cpp index 1fadb3769..d5fbfcf19 100644 --- a/source/OSSupport/IsThread.cpp +++ b/source/OSSupport/IsThread.cpp @@ -136,17 +136,28 @@ bool cIsThread::Wait(void) { return true; } - LOGD("Waiting for thread %s to finish", m_ThreadName.c_str()); + + #ifdef LOGD // ProtoProxy doesn't have LOGD + LOGD("Waiting for thread %s to finish", m_ThreadName.c_str()); + #endif // LOGD #ifdef _WIN32 int res = WaitForSingleObject(m_Handle, INFINITE); m_Handle = NULL; - LOGD("Thread %s finished", m_ThreadName.c_str()); + + #ifdef LOGD // ProtoProxy doesn't have LOGD + LOGD("Thread %s finished", m_ThreadName.c_str()); + #endif // LOGD + return (res == WAIT_OBJECT_0); #else // _WIN32 int res = pthread_join(m_Handle, NULL); m_Handle = NULL; - LOGD("Thread %s finished", m_ThreadName.c_str()); + + #ifdef LOGD // ProtoProxy doesn't have LOGD + LOGD("Thread %s finished", m_ThreadName.c_str()); + #endif // LOGD + m_HasStarted = false; return (res == 0); #endif // else _WIN32 diff --git a/source/OSSupport/Timer.cpp b/source/OSSupport/Timer.cpp index ab7325b5e..ed16f9e3a 100644 --- a/source/OSSupport/Timer.cpp +++ b/source/OSSupport/Timer.cpp @@ -8,33 +8,30 @@ -cTimer::cTimer() -#ifdef _WIN32 - : m_TicksPerSecond( new LARGE_INTEGER ) -#endif +cTimer::cTimer(void) { -#ifdef _WIN32 - QueryPerformanceFrequency( (LARGE_INTEGER*)m_TicksPerSecond ); -#endif + #ifdef _WIN32 + QueryPerformanceFrequency(&m_TicksPerSecond); + #endif } -cTimer::~cTimer() + + + + +long long cTimer::GetNowTime(void) { -#ifdef _WIN32 - delete (LARGE_INTEGER*)m_TicksPerSecond; -#endif + #ifdef _WIN32 + LARGE_INTEGER now; + QueryPerformanceCounter(&now); + return ((now.QuadPart * 1000) / m_TicksPerSecond.QuadPart); + #else + struct timeval now; + gettimeofday(&now, NULL); + return (long long)(now.tv_sec * 1000 + now.tv_usec / 1000); + #endif } -long long cTimer::GetNowTime() -{ -#ifdef _WIN32 - LARGE_INTEGER now; - QueryPerformanceCounter( &now ); - LARGE_INTEGER & tps = *((LARGE_INTEGER*)m_TicksPerSecond); - return ((now.QuadPart*1000) / tps.QuadPart ); -#else - struct timeval now; - gettimeofday(&now, NULL); - return (long long)(now.tv_sec*1000 + now.tv_usec/1000); -#endif -}
\ No newline at end of file + + + diff --git a/source/OSSupport/Timer.h b/source/OSSupport/Timer.h index 5969d0fc9..a059daa41 100644 --- a/source/OSSupport/Timer.h +++ b/source/OSSupport/Timer.h @@ -1,15 +1,32 @@ + +// Timer.h + +// Declares the cTimer class representing an OS-independent of retrieving current time with msec accuracy + + + + + #pragma once + + + + class cTimer { public: - cTimer(); - ~cTimer(); + cTimer(void); - long long GetNowTime(); + // Returns the current time expressed in milliseconds + long long GetNowTime(void); private: -#ifdef _WIN32 - void* m_TicksPerSecond; // LARGE_INTEGER* -#endif -};
\ No newline at end of file + #ifdef _WIN32 + LARGE_INTEGER m_TicksPerSecond; + #endif +} ; + + + + |