summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfaketruth <faketruth@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-03-09 14:42:28 +0100
committerfaketruth <faketruth@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-03-09 14:42:28 +0100
commitf43b65cf53274d1bbb43e2041ce72ff9eb68a7c8 (patch)
tree6799433ae65c4d4331bbfd6bcabe5bac38f6376c
parentUsing the _DEBUG macro for *nix debug builds as well; trying to force 8-byte alignment on critical sections ( http://forum.mc-server.org/showthread.php?tid=384 ) (diff)
downloadcuberite-f43b65cf53274d1bbb43e2041ce72ff9eb68a7c8.tar
cuberite-f43b65cf53274d1bbb43e2041ce72ff9eb68a7c8.tar.gz
cuberite-f43b65cf53274d1bbb43e2041ce72ff9eb68a7c8.tar.bz2
cuberite-f43b65cf53274d1bbb43e2041ce72ff9eb68a7c8.tar.lz
cuberite-f43b65cf53274d1bbb43e2041ce72ff9eb68a7c8.tar.xz
cuberite-f43b65cf53274d1bbb43e2041ce72ff9eb68a7c8.tar.zst
cuberite-f43b65cf53274d1bbb43e2041ce72ff9eb68a7c8.zip
-rw-r--r--source/Bindings.cpp141
-rw-r--r--source/Bindings.h2
-rw-r--r--source/ChunkSender.cpp5
-rw-r--r--source/WSSCompact.cpp2
-rw-r--r--source/cAggressiveMonster.cpp2
-rw-r--r--source/cAuthenticator.cpp33
-rw-r--r--source/cAuthenticator.h7
-rw-r--r--source/cChunk.cpp18
-rw-r--r--source/cChunk.h2
-rw-r--r--source/cChunkMap.cpp5
-rw-r--r--source/cChunkMap.h2
-rw-r--r--source/cClientHandle.cpp12
-rw-r--r--source/cClientHandle.h12
-rw-r--r--source/cEntity.cpp2
-rw-r--r--source/cEntity.h10
-rw-r--r--source/cPassiveAggressiveMonster.cpp2
-rw-r--r--source/cPickup.cpp4
-rw-r--r--source/cPlayer.cpp2
-rw-r--r--source/cRoot.cpp8
-rw-r--r--source/cRoot.h4
-rw-r--r--source/cServer.cpp10
-rw-r--r--source/cServer.h4
-rw-r--r--source/cWorld.cpp4
-rw-r--r--source/cWorld.h2
24 files changed, 224 insertions, 71 deletions
diff --git a/source/Bindings.cpp b/source/Bindings.cpp
index 8329dbab5..8e524beb2 100644
--- a/source/Bindings.cpp
+++ b/source/Bindings.cpp
@@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
-** Generated automatically by tolua++-1.0.92 on 03/07/12 14:22:38.
+** Generated automatically by tolua++-1.0.92 on 03/09/12 14:38:38.
*/
#ifndef __cplusplus
@@ -2993,6 +2993,135 @@ static int tolua_AllToLua_cClientHandle_Kick00(lua_State* tolua_S)
}
#endif //#ifndef TOLUA_DISABLE
+/* method: GetUsername of class cClientHandle */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cClientHandle_GetUsername00
+static int tolua_AllToLua_cClientHandle_GetUsername00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const cClientHandle",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const cClientHandle* self = (const cClientHandle*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetUsername'", NULL);
+#endif
+ {
+ const AString tolua_ret = (const AString) self->GetUsername();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetUsername'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetPing of class cClientHandle */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cClientHandle_GetPing00
+static int tolua_AllToLua_cClientHandle_GetPing00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const cClientHandle",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const cClientHandle* self = (const cClientHandle*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetPing'", NULL);
+#endif
+ {
+ short tolua_ret = (short) self->GetPing();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetPing'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: SetViewDistance of class cClientHandle */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cClientHandle_SetViewDistance00
+static int tolua_AllToLua_cClientHandle_SetViewDistance00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cClientHandle",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cClientHandle* self = (cClientHandle*) tolua_tousertype(tolua_S,1,0);
+ int a_ViewDistance = ((int) tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetViewDistance'", NULL);
+#endif
+ {
+ self->SetViewDistance(a_ViewDistance);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'SetViewDistance'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetUniqueID of class cClientHandle */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cClientHandle_GetUniqueID00
+static int tolua_AllToLua_cClientHandle_GetUniqueID00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const cClientHandle",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const cClientHandle* self = (const cClientHandle*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetUniqueID'", NULL);
+#endif
+ {
+ int tolua_ret = (int) self->GetUniqueID();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetUniqueID'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
/* method: delete of class cEntity */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cEntity_delete00
static int tolua_AllToLua_cEntity_delete00(lua_State* tolua_S)
@@ -17503,6 +17632,10 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_beginmodule(tolua_S,"cClientHandle");
tolua_function(tolua_S,"GetPlayer",tolua_AllToLua_cClientHandle_GetPlayer00);
tolua_function(tolua_S,"Kick",tolua_AllToLua_cClientHandle_Kick00);
+ tolua_function(tolua_S,"GetUsername",tolua_AllToLua_cClientHandle_GetUsername00);
+ tolua_function(tolua_S,"GetPing",tolua_AllToLua_cClientHandle_GetPing00);
+ tolua_function(tolua_S,"SetViewDistance",tolua_AllToLua_cClientHandle_SetViewDistance00);
+ tolua_function(tolua_S,"GetUniqueID",tolua_AllToLua_cClientHandle_GetUniqueID00);
tolua_endmodule(tolua_S);
#ifdef __cplusplus
tolua_cclass(tolua_S,"cEntity","cEntity","",tolua_collect_cEntity);
@@ -17512,9 +17645,9 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_beginmodule(tolua_S,"cEntity");
tolua_function(tolua_S,"delete",tolua_AllToLua_cEntity_delete00);
tolua_function(tolua_S,"Initialize",tolua_AllToLua_cEntity_Initialize00);
- tolua_constant(tolua_S,"E_ENTITY",cEntity::E_ENTITY);
- tolua_constant(tolua_S,"E_PLAYER",cEntity::E_PLAYER);
- tolua_constant(tolua_S,"E_PICKUP",cEntity::E_PICKUP);
+ tolua_constant(tolua_S,"eEntityType_Entity",cEntity::eEntityType_Entity);
+ tolua_constant(tolua_S,"eEntityType_Player",cEntity::eEntityType_Player);
+ tolua_constant(tolua_S,"eEntityType_Pickup",cEntity::eEntityType_Pickup);
tolua_function(tolua_S,"GetEntityType",tolua_AllToLua_cEntity_GetEntityType00);
tolua_function(tolua_S,"IsA",tolua_AllToLua_cEntity_IsA00);
tolua_function(tolua_S,"GetClass",tolua_AllToLua_cEntity_GetClass00);
diff --git a/source/Bindings.h b/source/Bindings.h
index e86f8c962..78f6cf818 100644
--- a/source/Bindings.h
+++ b/source/Bindings.h
@@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
-** Generated automatically by tolua++-1.0.92 on 03/07/12 14:22:38.
+** Generated automatically by tolua++-1.0.92 on 03/09/12 14:38:39.
*/
/* Exported function */
diff --git a/source/ChunkSender.cpp b/source/ChunkSender.cpp
index f3bc439d1..661e0e931 100644
--- a/source/ChunkSender.cpp
+++ b/source/ChunkSender.cpp
@@ -145,7 +145,10 @@ void cChunkSender::SendChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ, cClientHa
ASSERT(m_World != NULL);
// Prepare MapChunk packets:
- m_World->GetChunkData(a_ChunkX, a_ChunkY, a_ChunkZ, this);
+ if( !m_World->GetChunkData(a_ChunkX, a_ChunkY, a_ChunkZ, *this) )
+ {
+ return;
+ }
cPacket_PreChunk PreChunk(a_ChunkX, a_ChunkZ, true);
cPacket_MapChunk MapChunk(a_ChunkX, a_ChunkY, a_ChunkZ, m_BlockData);
diff --git a/source/WSSCompact.cpp b/source/WSSCompact.cpp
index c9ae5f2f2..420ccba62 100644
--- a/source/WSSCompact.cpp
+++ b/source/WSSCompact.cpp
@@ -626,7 +626,7 @@ bool cWSSCompact::cPAKFile::SaveChunkToData(const cChunkCoords & a_Chunk, cWorld
{
// Serialize the chunk:
cJsonChunkSerializer Serializer;
- a_World->GetChunkData(a_Chunk.m_ChunkX, a_Chunk.m_ChunkY, a_Chunk.m_ChunkZ, &Serializer);
+ a_World->GetChunkData(a_Chunk.m_ChunkX, a_Chunk.m_ChunkY, a_Chunk.m_ChunkZ, Serializer);
if (Serializer.GetBlockData().empty())
{
// Chunk not valid
diff --git a/source/cAggressiveMonster.cpp b/source/cAggressiveMonster.cpp
index 54d204c8b..e597bfed8 100644
--- a/source/cAggressiveMonster.cpp
+++ b/source/cAggressiveMonster.cpp
@@ -24,7 +24,7 @@ void cAggressiveMonster::InStateChasing(float a_Dt) {
m_ChaseTime += a_Dt;
if( m_Target )
{
- if(m_Target->GetEntityType() == cEntity::E_PLAYER)
+ if(m_Target->GetEntityType() == cEntity::eEntityType_Player)
{
cPlayer * Player = (cPlayer *) m_Target;
if(Player->GetGameMode() == 1)
diff --git a/source/cAuthenticator.cpp b/source/cAuthenticator.cpp
index 8fe19ba90..7441c6ccd 100644
--- a/source/cAuthenticator.cpp
+++ b/source/cAuthenticator.cpp
@@ -83,16 +83,16 @@ void cAuthenticator::ReadINI(void)
/// Queues a request for authenticating a user. If the auth fails, the user is kicked
-void cAuthenticator::Authenticate(const AString & iUserName, const AString & iServerID)
+void cAuthenticator::Authenticate(int a_ClientID, const AString & a_UserName, const AString & a_ServerHash)
{
if (!mShouldAuthenticate)
{
- cRoot::Get()->AuthenticateUser(iUserName);
+ cRoot::Get()->AuthenticateUser(a_ClientID);
return;
}
cCSLock Lock(mCS);
- mQueue.push_back(cUser(iUserName, iServerID));
+ mQueue.push_back(cUser(a_ClientID, a_UserName, a_ServerHash));
mQueueNonempty.Set();
}
@@ -127,6 +127,7 @@ void cAuthenticator::Execute(void)
}
ASSERT(mQueue.size() > 0);
+ int ClientID = mQueue.front().mClientID;
AString UserName = mQueue.front().mName;
AString ActualAddress = mAddress;
ReplaceString(ActualAddress, "%USERNAME%", UserName);
@@ -136,11 +137,11 @@ void cAuthenticator::Execute(void)
if (!AuthFromAddress(mServer, ActualAddress, UserName))
{
- cRoot::Get()->KickUser(UserName, "auth failed");
+ cRoot::Get()->KickUser(ClientID, "Failed to authenticate account!");
}
else
{
- cRoot::Get()->AuthenticateUser(UserName);
+ cRoot::Get()->AuthenticateUser(ClientID);
}
} // for (-ever)
}
@@ -149,18 +150,18 @@ void cAuthenticator::Execute(void)
-bool cAuthenticator::AuthFromAddress(const AString & iServer, const AString & iAddress, const AString & iUserName, int iLevel)
+bool cAuthenticator::AuthFromAddress(const AString & a_Server, const AString & a_Address, const AString & a_UserName, int a_Level /* = 1 */)
{
// Returns true if the user authenticated okay, false on error; iLevel is the recursion deptht (bails out if too deep)
cBlockingTCPLink Link;
- if (!Link.Connect(iServer.c_str(), 80))
+ if (!Link.Connect(a_Server.c_str(), 80))
{
- LOGERROR("cAuthenticator: cannot connect to auth server \"%s\", kicking user \"%s\"", iServer.c_str(), iUserName.c_str());
+ LOGERROR("cAuthenticator: cannot connect to auth server \"%s\", kicking user \"%s\"", a_Server.c_str(), a_Server.c_str());
return false;
}
- Link.SendMessage( AString( "GET " + iAddress + " HTTP/1.0\r\n\r\n" ).c_str());
+ Link.SendMessage( AString( "GET " + a_Address + " HTTP/1.0\r\n\r\n" ).c_str());
AString DataRecvd;
Link.ReceiveData(DataRecvd);
Link.CloseSocket();
@@ -180,9 +181,9 @@ bool cAuthenticator::AuthFromAddress(const AString & iServer, const AString & iA
{
// redirect blabla
LOGINFO("Need to redirect!");
- if (iLevel > MAX_REDIRECTS)
+ if (a_Level > MAX_REDIRECTS)
{
- LOGERROR("cAuthenticator: received too many levels of redirection from auth server \"%s\" for user \"%s\", bailing out and kicking the user", iServer.c_str(), iUserName.c_str());
+ LOGERROR("cAuthenticator: received too many levels of redirection from auth server \"%s\" for user \"%s\", bailing out and kicking the user", a_Server.c_str(), a_UserName.c_str());
return false;
}
bRedirect = true;
@@ -195,7 +196,7 @@ bool cAuthenticator::AuthFromAddress(const AString & iServer, const AString & iA
}
else
{
- LOGERROR("cAuthenticator: cannot parse auth reply from server \"%s\" for user \"%s\", kicking the user.", iServer.c_str(), iUserName.c_str());
+ LOGERROR("cAuthenticator: cannot parse auth reply from server \"%s\" for user \"%s\", kicking the user.", a_Server.c_str(), a_UserName.c_str());
return false;
}
@@ -221,19 +222,19 @@ bool cAuthenticator::AuthFromAddress(const AString & iServer, const AString & iA
}
if (!bFoundLocation)
{
- LOGERROR("cAuthenticator: received invalid redirection from auth server \"%s\" for user \"%s\", kicking user.", iServer.c_str(), iUserName.c_str());
+ LOGERROR("cAuthenticator: received invalid redirection from auth server \"%s\" for user \"%s\", kicking user.", a_Server.c_str(), a_UserName.c_str());
return false;
}
Location = Location.substr(strlen("http://"), std::string::npos); // Strip http://
std::string Server = Location.substr( 0, Location.find( "/" ) ); // Only leave server address
Location = Location.substr( Server.length(), std::string::npos);
- return AuthFromAddress(Server, Location, iUserName, iLevel + 1);
+ return AuthFromAddress(Server, Location, a_UserName, a_Level + 1);
}
if (!bOK)
{
- LOGERROR("cAuthenticator: received an error from auth server \"%s\" for user \"%s\", kicking user.", iServer.c_str(), iUserName.c_str());
+ LOGERROR("cAuthenticator: received an error from auth server \"%s\" for user \"%s\", kicking user.", a_Server.c_str(), a_UserName.c_str());
return false;
}
@@ -252,7 +253,7 @@ bool cAuthenticator::AuthFromAddress(const AString & iServer, const AString & iA
}
if (!ss.good())
{
- LOGERROR("cAuthenticator: error while parsing response body from auth server \"%s\" for user \"%s\", kicking user.", iServer.c_str(), iUserName.c_str());
+ LOGERROR("cAuthenticator: error while parsing response body from auth server \"%s\" for user \"%s\", kicking user.", a_Server.c_str(), a_UserName.c_str());
return false;
}
diff --git a/source/cAuthenticator.h b/source/cAuthenticator.h
index dd4c5d989..4f33ac036 100644
--- a/source/cAuthenticator.h
+++ b/source/cAuthenticator.h
@@ -40,7 +40,7 @@ public:
void ReadINI(void);
/// Queues a request for authenticating a user. If the auth fails, the user is kicked
- void Authenticate(const AString & iUserName, const AString & iServerHash);
+ void Authenticate(int a_ClientID, const AString & a_UserName, const AString & a_ServerHash);
// Stops the authenticator thread
void Stop(void);
@@ -50,10 +50,11 @@ private:
class cUser
{
public:
+ int mClientID;
AString mName;
AString mServerHash;
- cUser(const AString & iName, const AString & iServerHash) : mName(iName), mServerHash(iServerHash) {}
+ cUser(int a_ClientID, const AString & a_Name, const AString & a_ServerHash) : mClientID(a_ClientID), mName(a_Name), mServerHash(a_ServerHash) {}
} ;
typedef std::deque<cUser> cUserList;
@@ -70,7 +71,7 @@ private:
virtual void Execute(void) override;
// Returns true if the user authenticated okay, false on error; iLevel is the recursion deptht (bails out if too deep)
- bool AuthFromAddress(const AString & iServer, const AString & iAddress, const AString & iUserName, int iLevel = 1);
+ bool AuthFromAddress(const AString & a_Server, const AString & a_Address, const AString & a_UserName, int a_Level = 1);
};
diff --git a/source/cChunk.cpp b/source/cChunk.cpp
index 48d2bc086..2780af2a8 100644
--- a/source/cChunk.cpp
+++ b/source/cChunk.cpp
@@ -108,7 +108,7 @@ cChunk::~cChunk()
cEntityList Entities;
for (cEntityList::const_iterator itr = m_Entities.begin(); itr != m_Entities.end(); ++itr)
{
- if ((*itr)->GetEntityType() != cEntity::E_PLAYER)
+ if ((*itr)->GetEntityType() != cEntity::eEntityType_Player)
{
Entities.push_back(*itr);
}
@@ -218,18 +218,18 @@ void cChunk::MarkLoadFailed(void)
-void cChunk::GetAllData(cChunkDataCallback * a_Callback)
+void cChunk::GetAllData(cChunkDataCallback & a_Callback)
{
- a_Callback->BlockData(m_BlockData);
+ a_Callback.BlockData(m_BlockData);
for (cEntityList::iterator itr = m_Entities.begin(); itr != m_Entities.end(); ++itr)
{
- a_Callback->Entity(*itr);
+ a_Callback.Entity(*itr);
}
for (cBlockEntityList::iterator itr = m_BlockEntities.begin(); itr != m_BlockEntities.end(); ++itr)
{
- a_Callback->BlockEntity(*itr);
+ a_Callback.BlockEntity(*itr);
}
}
@@ -244,7 +244,7 @@ void cChunk::SetAllData(const char * a_BlockData, cEntityList & a_Entities, cBlo
// Clear the internal entities:
for (cEntityList::iterator itr = m_Entities.begin(); itr != m_Entities.end(); ++itr)
{
- if ((*itr)->GetEntityType() == cEntity::E_PLAYER)
+ if ((*itr)->GetEntityType() == cEntity::eEntityType_Player)
{
// Move players into the new entity list
a_Entities.push_back(*itr);
@@ -1102,7 +1102,7 @@ void cChunk::CollectPickupsByPlayer(cPlayer * a_Player)
for (cEntityList::iterator itr = m_Entities.begin(); itr != m_Entities.end(); ++itr)
{
- if ( (*itr)->GetEntityType() != cEntity::E_PICKUP )
+ if ( (*itr)->GetEntityType() != cEntity::eEntityType_Pickup )
{
continue; // Only pickups
}
@@ -1229,7 +1229,7 @@ bool cChunk::HasAnyClients(void)
void cChunk::AddEntity( cEntity * a_Entity)
{
- if (a_Entity->GetEntityType() != cEntity::E_PLAYER)
+ if (a_Entity->GetEntityType() != cEntity::eEntityType_Player)
{
MarkDirty();
}
@@ -1249,7 +1249,7 @@ void cChunk::RemoveEntity(cEntity * a_Entity)
if (SizeBefore != SizeAfter)
{
// Mark as dirty if it was a server-generated entity:
- if (a_Entity->GetEntityType() != cEntity::E_PLAYER)
+ if (a_Entity->GetEntityType() != cEntity::eEntityType_Player)
{
MarkDirty();
}
diff --git a/source/cChunk.h b/source/cChunk.h
index aad652c40..44a4dfbd2 100644
--- a/source/cChunk.h
+++ b/source/cChunk.h
@@ -139,7 +139,7 @@ public:
void MarkLoadFailed(void); // Marks the chunk as failed to load. Ignored is the chunk is already valid
/// Gets all chunk data, calls the a_Callback's methods for each data type
- void GetAllData(cChunkDataCallback * a_Callback);
+ void GetAllData(cChunkDataCallback & a_Callback);
/// Sets all chunk data
void SetAllData(const char * a_BlockData, cEntityList & a_Entities, cBlockEntityList & a_BlockEntities);
diff --git a/source/cChunkMap.cpp b/source/cChunkMap.cpp
index beccaefb1..a6b158360 100644
--- a/source/cChunkMap.cpp
+++ b/source/cChunkMap.cpp
@@ -312,15 +312,16 @@ void cChunkMap::ChunkDataGenerated(int a_ChunkX, int a_ChunkY, int a_ChunkZ, con
-void cChunkMap::GetChunkData(int a_ChunkX, int a_ChunkY, int a_ChunkZ, cChunkDataCallback * a_Callback)
+bool cChunkMap::GetChunkData(int a_ChunkX, int a_ChunkY, int a_ChunkZ, cChunkDataCallback & a_Callback)
{
cCSLock Lock(m_CSLayers);
cChunkPtr Chunk = GetChunkNoGen(a_ChunkX, a_ChunkY, a_ChunkZ);
if ((Chunk == NULL) || !Chunk->IsValid())
{
- return;
+ return false;
}
Chunk->GetAllData(a_Callback);
+ return true;
}
diff --git a/source/cChunkMap.h b/source/cChunkMap.h
index f5a750f87..297056d81 100644
--- a/source/cChunkMap.h
+++ b/source/cChunkMap.h
@@ -44,7 +44,7 @@ public:
void MarkChunkSaved (int a_ChunkX, int a_ChunkY, int a_ChunkZ);
void ChunkDataLoaded (int a_ChunkX, int a_ChunkY, int a_ChunkZ, const char * a_BlockData, cEntityList & a_Entities, cBlockEntityList & a_BlockEntities);
void ChunkDataGenerated (int a_ChunkX, int a_ChunkY, int a_ChunkZ, const char * a_BlockData, cEntityList & a_Entities, cBlockEntityList & a_BlockEntities);
- void GetChunkData (int a_ChunkX, int a_ChunkY, int a_ChunkZ, cChunkDataCallback * a_Callback);
+ bool GetChunkData (int a_ChunkX, int a_ChunkY, int a_ChunkZ, cChunkDataCallback & a_Callback);
/// Gets the chunk's blocks, only the block types
bool GetChunkBlocks (int a_ChunkX, int a_ChunkY, int a_ChunkZ, char * a_Blocks);
diff --git a/source/cClientHandle.cpp b/source/cClientHandle.cpp
index c722b4305..cf6c3fb5f 100644
--- a/source/cClientHandle.cpp
+++ b/source/cClientHandle.cpp
@@ -84,6 +84,12 @@
+int cClientHandle::s_ClientCount = 0;
+
+
+
+
+
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// cClientHandle:
@@ -104,7 +110,11 @@ cClientHandle::cClientHandle(const cSocket & a_Socket, int a_ViewDistance)
, m_State(csConnected)
, m_LastStreamedChunkX(0x7fffffff) // bogus chunk coords to force streaming upon login
, m_LastStreamedChunkZ(0x7fffffff)
+ , m_UniqueID(0)
{
+ s_ClientCount++; // Not protected by CS because clients are always constructed from the same thread
+ m_UniqueID = s_ClientCount;
+
cTimer t1;
m_LastPingTime = t1.GetNowTime();
@@ -696,7 +706,7 @@ void cClientHandle::HandleLogin(cPacket_Login * a_Packet)
// Schedule for authentication; until then, let them wait (but do not block)
m_State = csAuthenticating;
- cRoot::Get()->GetAuthenticator().Authenticate(m_Username, cRoot::Get()->GetServer()->GetServerID());
+ cRoot::Get()->GetAuthenticator().Authenticate(GetUniqueID(), GetUsername(), cRoot::Get()->GetServer()->GetServerID());
}
diff --git a/source/cClientHandle.h b/source/cClientHandle.h
index 6ac6e07b8..65a4e5db8 100644
--- a/source/cClientHandle.h
+++ b/source/cClientHandle.h
@@ -78,7 +78,7 @@ public:
cPlayer* GetPlayer() { return m_Player; } // tolua_export
- void Kick(const AString & a_Reason); //tolua_export
+ void Kick(const AString & a_Reason); //tolua_export
void Authenticate(void); // Called by cAuthenticator when the user passes authentication
void StreamChunks(void);
@@ -100,11 +100,13 @@ public:
void Send(const cPacket & a_Packet, ENUM_PRIORITY a_Priority = E_PRIORITY_NORMAL) { Send(&a_Packet, a_Priority); }
void Send(const cPacket * a_Packet, ENUM_PRIORITY a_Priority = E_PRIORITY_NORMAL);
- const AString & GetUsername(void) const;
+ const AString & GetUsername(void) const; //tolua_export
- inline short GetPing() { return m_Ping; }
+ inline short GetPing() const { return m_Ping; } //tolua_export
- void SetViewDistance(int a_ViewDistance);
+ void SetViewDistance(int a_ViewDistance); //tolua_export
+
+ int GetUniqueID() const { return m_UniqueID; } //tolua_export
private:
@@ -212,6 +214,8 @@ private:
virtual void GetOutgoingData(AString & a_Data) override; // Data can be sent to client
virtual void SocketClosed (void) override; // The socket has been closed for any reason
+ static int s_ClientCount;
+ int m_UniqueID;
}; // tolua_export
diff --git a/source/cEntity.cpp b/source/cEntity.cpp
index f6627fd20..ba1ca836a 100644
--- a/source/cEntity.cpp
+++ b/source/cEntity.cpp
@@ -36,7 +36,7 @@ cEntity::cEntity(const double & a_X, const double & a_Y, const double & a_Z)
, m_bDirtyPosition( true )
, m_bDirtyOrientation( true )
, m_bDestroyed( false )
- , m_EntityType( E_ENTITY )
+ , m_EntityType( eEntityType_Entity )
, m_World( 0 )
, m_bRemovedFromChunk( false )
{
diff --git a/source/cEntity.h b/source/cEntity.h
index 58c0b69f4..1b26f46be 100644
--- a/source/cEntity.h
+++ b/source/cEntity.h
@@ -57,11 +57,11 @@ public: //tolua_export
virtual void Initialize( cWorld* a_World ); //tolua_export
- enum ENUM_ENTITY_TYPE //tolua_export
+ enum eEntityType //tolua_export
{ //tolua_export
- E_ENTITY, //tolua_export
- E_PLAYER, //tolua_export
- E_PICKUP //tolua_export
+ eEntityType_Entity, //tolua_export
+ eEntityType_Player, //tolua_export
+ eEntityType_Pickup //tolua_export
}; //tolua_export
virtual unsigned int GetEntityType() { return m_EntityType; } //tolua_export
@@ -136,7 +136,7 @@ protected:
bool m_bDestroyed;
bool m_bRemovedFromChunk;
- ENUM_ENTITY_TYPE m_EntityType;
+ eEntityType m_EntityType;
cWorld* m_World;
}; //tolua_export
diff --git a/source/cPassiveAggressiveMonster.cpp b/source/cPassiveAggressiveMonster.cpp
index 9d423b0f7..09e7b6a25 100644
--- a/source/cPassiveAggressiveMonster.cpp
+++ b/source/cPassiveAggressiveMonster.cpp
@@ -21,7 +21,7 @@ cPassiveAggressiveMonster::~cPassiveAggressiveMonster()
void cPassiveAggressiveMonster::TakeDamage(int a_Damage, cEntity* a_Instigator)
{
cMonster::TakeDamage(a_Damage, a_Instigator);
- if(m_Target->GetEntityType() == cEntity::E_PLAYER)
+ if(m_Target->GetEntityType() == cEntity::eEntityType_Player)
{
cPlayer * Player = (cPlayer *) m_Target;
if(Player->GetGameMode() != 1)
diff --git a/source/cPickup.cpp b/source/cPickup.cpp
index 49dc5b342..cf71abab0 100644
--- a/source/cPickup.cpp
+++ b/source/cPickup.cpp
@@ -58,7 +58,7 @@ cPickup::cPickup(int a_X, int a_Y, int a_Z, const cItem & a_Item, float a_SpeedX
}
}
- m_EntityType = E_PICKUP;
+ m_EntityType = eEntityType_Pickup;
}
@@ -92,7 +92,7 @@ cPickup::cPickup(cPacket_PickupSpawn* a_PickupSpawnPacket)
cRoot::Get()->GetServer()->Broadcast( *a_PickupSpawnPacket );
}
- m_EntityType = E_PICKUP;
+ m_EntityType = eEntityType_Pickup;
}
diff --git a/source/cPlayer.cpp b/source/cPlayer.cpp
index c6893b076..a5e2b7565 100644
--- a/source/cPlayer.cpp
+++ b/source/cPlayer.cpp
@@ -80,7 +80,7 @@ cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName)
, m_ClientHandle( a_Client )
, m_pState( new sPlayerState )
{
- m_EntityType = E_PLAYER;
+ m_EntityType = eEntityType_Player;
SetMaxHealth(20);
SetMaxFoodLevel(125);
m_Inventory = new cSurvivalInventory( this );
diff --git a/source/cRoot.cpp b/source/cRoot.cpp
index 165c908ae..17471d6d9 100644
--- a/source/cRoot.cpp
+++ b/source/cRoot.cpp
@@ -333,18 +333,18 @@ void cRoot::ServerCommand( const char * a_Cmd )
-void cRoot::KickUser(const AString & iUserName, const AString & iReason)
+void cRoot::KickUser(int a_ClientID, const AString & a_Reason)
{
- m_Server->KickUser(iUserName, iReason);
+ m_Server->KickUser(a_ClientID, a_Reason);
}
-void cRoot::AuthenticateUser(const AString & iUserName)
+void cRoot::AuthenticateUser(int a_ClientID)
{
- m_Server->AuthenticateUser(iUserName);
+ m_Server->AuthenticateUser(a_ClientID);
}
diff --git a/source/cRoot.h b/source/cRoot.h
index 85b12eb12..9505ff6f0 100644
--- a/source/cRoot.h
+++ b/source/cRoot.h
@@ -49,8 +49,8 @@ public:
void ServerCommand(const char* a_Cmd ); //tolua_export
- void KickUser(const AString & iUserName, const AString & iReason); // Kicks the user, no matter in what world they are. Used from cAuthenticator
- void AuthenticateUser(const AString & iUserName); // Called by cAuthenticator to auth the specified user
+ void KickUser(int a_ClientID, const AString & a_Reason); // Kicks the user, no matter in what world they are. Used from cAuthenticator
+ void AuthenticateUser(int a_ClientID); // Called by cAuthenticator to auth the specified user
void TickWorlds( float a_Dt );
diff --git a/source/cServer.cpp b/source/cServer.cpp
index 116861aca..51d60d1d4 100644
--- a/source/cServer.cpp
+++ b/source/cServer.cpp
@@ -619,14 +619,14 @@ const AString & cServer::GetServerID(void) const
-void cServer::KickUser(const AString & iUserName, const AString & iReason)
+void cServer::KickUser(int a_ClientID, const AString & a_Reason)
{
cCSLock Lock(m_CSClients);
for (ClientList::iterator itr = m_Clients.begin(); itr != m_Clients.end(); ++itr)
{
- if ((*itr)->GetUsername() == iUserName)
+ if ((*itr)->GetUniqueID() == a_ClientID)
{
- (*itr)->Kick(iReason);
+ (*itr)->Kick(a_Reason);
}
} // for itr - m_Clients[]
}
@@ -635,12 +635,12 @@ void cServer::KickUser(const AString & iUserName, const AString & iReason)
-void cServer::AuthenticateUser(const AString & iUserName)
+void cServer::AuthenticateUser(int a_ClientID)
{
cCSLock Lock(m_CSClients);
for (ClientList::iterator itr = m_Clients.begin(); itr != m_Clients.end(); ++itr)
{
- if ((*itr)->GetUsername() == iUserName)
+ if ((*itr)->GetUniqueID() == a_ClientID)
{
(*itr)->Authenticate();
}
diff --git a/source/cServer.h b/source/cServer.h
index 5e21dbf37..22c4d7ef6 100644
--- a/source/cServer.h
+++ b/source/cServer.h
@@ -51,8 +51,8 @@ public: //tolua_export
void SendMessage( const char* a_Message, cPlayer* a_Player = 0, bool a_bExclude = false ); //tolua_export
- void KickUser(const AString & iUserName, const AString & iReason);
- void AuthenticateUser(const AString & iUserName); // Called by cAuthenticator to auth the specified user
+ void KickUser(int a_ClientID, const AString & a_Reason);
+ void AuthenticateUser(int a_ClientID); // Called by cAuthenticator to auth the specified user
static void ServerListenThread( void* a_Args );
diff --git a/source/cWorld.cpp b/source/cWorld.cpp
index de79d5d76..4f03ff87e 100644
--- a/source/cWorld.cpp
+++ b/source/cWorld.cpp
@@ -1006,9 +1006,9 @@ void cWorld::ChunkDataGenerated(int a_ChunkX, int a_ChunkY, int a_ChunkZ, const
-void cWorld::GetChunkData(int a_ChunkX, int a_ChunkY, int a_ChunkZ, cChunkDataCallback * a_Callback)
+bool cWorld::GetChunkData(int a_ChunkX, int a_ChunkY, int a_ChunkZ, cChunkDataCallback & a_Callback)
{
- m_ChunkMap->GetChunkData(a_ChunkX, a_ChunkY, a_ChunkZ, a_Callback);
+ return m_ChunkMap->GetChunkData(a_ChunkX, a_ChunkY, a_ChunkZ, a_Callback);
}
diff --git a/source/cWorld.h b/source/cWorld.h
index 093fc149f..ea91a854a 100644
--- a/source/cWorld.h
+++ b/source/cWorld.h
@@ -72,7 +72,7 @@ public:
void MarkChunkSaved (int a_ChunkX, int a_ChunkY, int a_ChunkZ);
void ChunkDataLoaded (int a_ChunkX, int a_ChunkY, int a_ChunkZ, const char * a_BlockData, cEntityList & a_Entities, cBlockEntityList & a_BlockEntities);
void ChunkDataGenerated(int a_ChunkX, int a_ChunkY, int a_ChunkZ, const char * a_BlockData, cEntityList & a_Entities, cBlockEntityList & a_BlockEntities);
- void GetChunkData (int a_ChunkX, int a_ChunkY, int a_ChunkZ, cChunkDataCallback * a_Callback);
+ bool GetChunkData (int a_ChunkX, int a_ChunkY, int a_ChunkZ, cChunkDataCallback & a_Callback);
/// Gets the chunk's blocks, only the block types
bool GetChunkBlocks (int a_ChunkX, int a_ChunkY, int a_ChunkZ, char * a_Blocks);