diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/Bindings.cpp | 155 | ||||
-rw-r--r-- | source/Bindings.h | 2 | ||||
-rw-r--r-- | source/Globals.h | 1 | ||||
-rw-r--r-- | source/cClientHandle.cpp | 19 | ||||
-rw-r--r-- | source/packets/cPacket_Login.cpp | 12 | ||||
-rw-r--r-- | source/packets/cPacket_Login.h | 13 |
6 files changed, 135 insertions, 67 deletions
diff --git a/source/Bindings.cpp b/source/Bindings.cpp index ee62b876f..5622503a4 100644 --- a/source/Bindings.cpp +++ b/source/Bindings.cpp @@ -1,6 +1,6 @@ /*
** Lua binding: AllToLua
-** Generated automatically by tolua++-1.0.92 on 02/22/12 16:44:22.
+** Generated automatically by tolua++-1.0.92 on 03/01/12 18:04:42.
*/
#ifndef __cplusplus
@@ -9728,6 +9728,35 @@ static int tolua_AllToLua_cWorld_GetBlock00(lua_State* tolua_S) }
#endif //#ifndef TOLUA_DISABLE
+/* method: GetBlock of class cWorld */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cWorld_GetBlock01
+static int tolua_AllToLua_cWorld_GetBlock01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cWorld",0,&tolua_err) ||
+ (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const Vector3i",0,&tolua_err)) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ cWorld* self = (cWorld*) tolua_tousertype(tolua_S,1,0);
+ const Vector3i* a_Pos = ((const Vector3i*) tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetBlock'", NULL);
+#endif
+ {
+ char tolua_ret = (char) self->GetBlock(*a_Pos);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_AllToLua_cWorld_GetBlock00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
/* method: GetBlockMeta of class cWorld */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cWorld_GetBlockMeta00
static int tolua_AllToLua_cWorld_GetBlockMeta00(lua_State* tolua_S)
@@ -9766,6 +9795,35 @@ static int tolua_AllToLua_cWorld_GetBlockMeta00(lua_State* tolua_S) }
#endif //#ifndef TOLUA_DISABLE
+/* method: GetBlockMeta of class cWorld */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cWorld_GetBlockMeta01
+static int tolua_AllToLua_cWorld_GetBlockMeta01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cWorld",0,&tolua_err) ||
+ (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const Vector3i",0,&tolua_err)) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ cWorld* self = (cWorld*) tolua_tousertype(tolua_S,1,0);
+ const Vector3i* a_Pos = ((const Vector3i*) tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetBlockMeta'", NULL);
+#endif
+ {
+ char tolua_ret = (char) self->GetBlockMeta(*a_Pos);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+tolua_lerror:
+ return tolua_AllToLua_cWorld_GetBlockMeta00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
/* method: SetBlockMeta of class cWorld */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cWorld_SetBlockMeta00
static int tolua_AllToLua_cWorld_SetBlockMeta00(lua_State* tolua_S)
@@ -9805,6 +9863,36 @@ static int tolua_AllToLua_cWorld_SetBlockMeta00(lua_State* tolua_S) }
#endif //#ifndef TOLUA_DISABLE
+/* method: SetBlockMeta of class cWorld */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cWorld_SetBlockMeta01
+static int tolua_AllToLua_cWorld_SetBlockMeta01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cWorld",0,&tolua_err) ||
+ (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const Vector3i",0,&tolua_err)) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ cWorld* self = (cWorld*) tolua_tousertype(tolua_S,1,0);
+ const Vector3i* a_Pos = ((const Vector3i*) tolua_tousertype(tolua_S,2,0));
+ char a_MetaData = ((char) tolua_tonumber(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetBlockMeta'", NULL);
+#endif
+ {
+ self->SetBlockMeta(*a_Pos,a_MetaData);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_AllToLua_cWorld_SetBlockMeta00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
/* method: DigBlock of class cWorld */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cWorld_DigBlock00
static int tolua_AllToLua_cWorld_DigBlock00(lua_State* tolua_S)
@@ -15956,36 +16044,6 @@ static int tolua_set_cPacket_Login_m_Username(lua_State* tolua_S) }
#endif //#ifndef TOLUA_DISABLE
-/* get function: m_MapSeed of class cPacket_Login */
-#ifndef TOLUA_DISABLE_tolua_get_cPacket_Login_m_MapSeed
-static int tolua_get_cPacket_Login_m_MapSeed(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_MapSeed'",NULL);
-#endif
- tolua_pushnumber(tolua_S,(lua_Number)self->m_MapSeed);
- return 1;
-}
-#endif //#ifndef TOLUA_DISABLE
-
-/* set function: m_MapSeed of class cPacket_Login */
-#ifndef TOLUA_DISABLE_tolua_set_cPacket_Login_m_MapSeed
-static int tolua_set_cPacket_Login_m_MapSeed(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_MapSeed'",NULL);
- if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
- tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
-#endif
- self->m_MapSeed = ((long long) tolua_tonumber(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)
@@ -16046,36 +16104,6 @@ static int tolua_set_cPacket_Login_m_ServerMode(lua_State* tolua_S) }
#endif //#ifndef TOLUA_DISABLE
-/* get function: m_Dimension of class cPacket_Login */
-#ifndef TOLUA_DISABLE_tolua_get_cPacket_Login_m_Dimension
-static int tolua_get_cPacket_Login_m_Dimension(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_Dimension'",NULL);
-#endif
- tolua_pushnumber(tolua_S,(lua_Number)self->m_Dimension);
- return 1;
-}
-#endif //#ifndef TOLUA_DISABLE
-
-/* set function: m_Dimension of class cPacket_Login */
-#ifndef TOLUA_DISABLE_tolua_set_cPacket_Login_m_Dimension
-static int tolua_set_cPacket_Login_m_Dimension(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_Dimension'",NULL);
- if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
- tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
-#endif
- self->m_Dimension = ((char) 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)
@@ -17584,8 +17612,11 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S) tolua_function(tolua_S,"SetBlock",tolua_AllToLua_cWorld_SetBlock00);
tolua_function(tolua_S,"FastSetBlock",tolua_AllToLua_cWorld_FastSetBlock00);
tolua_function(tolua_S,"GetBlock",tolua_AllToLua_cWorld_GetBlock00);
+ tolua_function(tolua_S,"GetBlock",tolua_AllToLua_cWorld_GetBlock01);
tolua_function(tolua_S,"GetBlockMeta",tolua_AllToLua_cWorld_GetBlockMeta00);
+ tolua_function(tolua_S,"GetBlockMeta",tolua_AllToLua_cWorld_GetBlockMeta01);
tolua_function(tolua_S,"SetBlockMeta",tolua_AllToLua_cWorld_SetBlockMeta00);
+ tolua_function(tolua_S,"SetBlockMeta",tolua_AllToLua_cWorld_SetBlockMeta01);
tolua_function(tolua_S,"DigBlock",tolua_AllToLua_cWorld_DigBlock00);
tolua_function(tolua_S,"SendBlockTo",tolua_AllToLua_cWorld_SendBlockTo00);
tolua_function(tolua_S,"GetSpawnX",tolua_AllToLua_cWorld_GetSpawnX00);
@@ -17909,10 +17940,8 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S) 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_MapSeed",tolua_get_cPacket_Login_m_MapSeed,tolua_set_cPacket_Login_m_MapSeed);
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_Dimension",tolua_get_cPacket_Login_m_Dimension,tolua_set_cPacket_Login_m_Dimension);
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);
diff --git a/source/Bindings.h b/source/Bindings.h index 485b965c0..b76eea990 100644 --- a/source/Bindings.h +++ b/source/Bindings.h @@ -1,6 +1,6 @@ /*
** Lua binding: AllToLua
-** Generated automatically by tolua++-1.0.92 on 02/22/12 16:44:22.
+** Generated automatically by tolua++-1.0.92 on 03/01/12 18:04:42.
*/
/* Exported function */
diff --git a/source/Globals.h b/source/Globals.h index 592580153..ce122528c 100644 --- a/source/Globals.h +++ b/source/Globals.h @@ -144,3 +144,4 @@ public: +#define MINECRAFT_1_2_2 (1)
\ No newline at end of file diff --git a/source/cClientHandle.cpp b/source/cClientHandle.cpp index fbbe6b89d..11dbffa4c 100644 --- a/source/cClientHandle.cpp +++ b/source/cClientHandle.cpp @@ -89,7 +89,11 @@ cClientHandle::cClientHandle(const cSocket & a_Socket, int a_ViewDistance)
: m_ViewDistance(a_ViewDistance)
+#if (MINECRAFT_1_2_2 == 1)
+ , m_ProtocolVersion(28)
+#else
, m_ProtocolVersion(23)
+#endif
, m_Socket(a_Socket)
, m_bDestroyed(false)
, m_Player(NULL)
@@ -288,7 +292,9 @@ void cClientHandle::Authenticate(void) LoginResponse.m_ProtocolVersion = m_Player->GetUniqueID();
//LoginResponse.m_Username = "";
LoginResponse.m_ServerMode = m_Player->GetGameMode(); // set gamemode from player.
+#if (MINECRAFT_1_2_2 != 1)
LoginResponse.m_MapSeed = cRoot::Get()->GetWorld()->GetWorldSeed();
+#endif
LoginResponse.m_Dimension = 0;
LoginResponse.m_MaxPlayers = (unsigned char)cRoot::Get()->GetWorld()->GetMaxPlayers();
LoginResponse.m_Difficulty = 2;
@@ -620,7 +626,18 @@ void cClientHandle::HandlePing(void) void cClientHandle::HandleHandshake(cPacket_Handshake * a_Packet)
{
+#if (MINECRAFT_1_2_2 == 1)
+ AStringVector UserData = StringSplit( a_Packet->m_Username, ";" ); // "FakeTruth;localhost:25565"
+ if( UserData.size() == 0 )
+ {
+ Kick("Could not receive username");
+ return;
+ }
+ m_Username = UserData[0];
+#else
m_Username = a_Packet->m_Username;
+#endif
+
LOG("HANDSHAKE %s", m_Username.c_str());
if (cRoot::Get()->GetWorld()->GetNumPlayers() >= cRoot::Get()->GetWorld()->GetMaxPlayers())
@@ -1786,7 +1803,7 @@ void cClientHandle::CheckIfWorldDownloaded(void) return;
}
cCSLock Lock(m_CSChunkLists);
- if (m_ChunksToSend.empty())
+ if (m_ChunksToSend.size() < 4*4)
{
SendConfirmPosition();
}
diff --git a/source/packets/cPacket_Login.cpp b/source/packets/cPacket_Login.cpp index a96d456cc..bbb81ef52 100644 --- a/source/packets/cPacket_Login.cpp +++ b/source/packets/cPacket_Login.cpp @@ -21,10 +21,16 @@ int cPacket_Login::Parse(const char * a_Data, int a_Size) m_Username.clear();
HANDLE_PACKET_READ(ReadInteger, m_ProtocolVersion, TotalBytes);
HANDLE_PACKET_READ(ReadString16, m_Username, TotalBytes);
+#if (MINECRAFT_1_2_2 != 1 )
HANDLE_PACKET_READ(ReadLong, m_MapSeed, TotalBytes);
+#endif
HANDLE_PACKET_READ(ReadString16, m_LevelType, TotalBytes);
HANDLE_PACKET_READ(ReadInteger, m_ServerMode, TotalBytes);
+#if (MINECRAFT_1_2_2 == 1 )
+ HANDLE_PACKET_READ(ReadInteger, m_Dimension, TotalBytes);
+#else
HANDLE_PACKET_READ(ReadByte, m_Dimension, TotalBytes);
+#endif
HANDLE_PACKET_READ(ReadByte, m_Difficulty, TotalBytes);
HANDLE_PACKET_READ(ReadByte, m_WorldHeight, TotalBytes);
HANDLE_PACKET_READ(ReadByte, m_MaxPlayers, TotalBytes);
@@ -40,10 +46,16 @@ void cPacket_Login::Serialize(AString & a_Data) const AppendByte (a_Data, m_PacketID);
AppendInteger (a_Data, m_ProtocolVersion);
AppendString16(a_Data, m_Username);
+#if (MINECRAFT_1_2_2 != 1 )
AppendLong (a_Data, m_MapSeed);
+#endif
AppendString16(a_Data, m_LevelType);
AppendInteger (a_Data, m_ServerMode);
+#if (MINECRAFT_1_2_2 == 1 )
+ AppendInteger (a_Data, m_Dimension);
+#else
AppendByte (a_Data, m_Dimension);
+#endif
AppendByte (a_Data, m_Difficulty);
AppendByte (a_Data, m_WorldHeight);
AppendByte (a_Data, m_MaxPlayers);
diff --git a/source/packets/cPacket_Login.h b/source/packets/cPacket_Login.h index 364a268eb..7884bbfb1 100644 --- a/source/packets/cPacket_Login.h +++ b/source/packets/cPacket_Login.h @@ -12,7 +12,9 @@ class cPacket_Login : public cPacket //tolua_export public:
cPacket_Login()
: m_ProtocolVersion( 0 )
+#if (MINECRAFT_1_2_2 != 1)
, m_MapSeed( 0 )
+#endif
, m_ServerMode( 0 )
, m_Dimension( 0 )
, m_Difficulty( 0 )
@@ -25,12 +27,19 @@ public: virtual int Parse(const char * a_Data, int a_Size) override;
virtual void Serialize(AString & a_Data) const override;
+ // 1.2.2 http://wiki.vg/Protocol#Login_Request_.280x01.29
int m_ProtocolVersion; //tolua_export
AString m_Username; //tolua_export
- long long m_MapSeed; //tolua_export
+#if (MINECRAFT_1_2_2 != 1)
+ long long m_MapSeed;
+#endif
AString m_LevelType; //tolua_export
int m_ServerMode; //tolua_export
- char m_Dimension; //tolua_export
+#if (MINECRAFT_1_2_2 == 1 )
+ int m_Dimension;
+#else
+ char m_Dimension;
+#endif
char m_Difficulty; //tolua_export
unsigned char m_WorldHeight; //tolua_export
unsigned char m_MaxPlayers; //tolua_export
|