parent
5f72cdac38
commit
e11f41d048
|
@ -40,9 +40,6 @@
|
||||||
/** Maximum number of block change interactions a player can perform per tick - exceeding this causes a kick */
|
/** Maximum number of block change interactions a player can perform per tick - exceeding this causes a kick */
|
||||||
#define MAX_BLOCK_CHANGE_INTERACTIONS 20
|
#define MAX_BLOCK_CHANGE_INTERACTIONS 20
|
||||||
|
|
||||||
/** How many ticks before the socket is closed after the client is destroyed (#31) */
|
|
||||||
static const int TICKS_BEFORE_CLOSE = 20;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -79,7 +76,6 @@ cClientHandle::cClientHandle(const cSocket * a_Socket, int a_ViewDistance) :
|
||||||
m_PingID(1),
|
m_PingID(1),
|
||||||
m_BlockDigAnimStage(-1),
|
m_BlockDigAnimStage(-1),
|
||||||
m_HasStartedDigging(false),
|
m_HasStartedDigging(false),
|
||||||
m_TicksSinceDestruction(0),
|
|
||||||
m_State(csConnected),
|
m_State(csConnected),
|
||||||
m_ShouldCheckDownloaded(false),
|
m_ShouldCheckDownloaded(false),
|
||||||
m_NumExplosionsThisTick(0),
|
m_NumExplosionsThisTick(0),
|
||||||
|
@ -104,7 +100,7 @@ cClientHandle::cClientHandle(const cSocket * a_Socket, int a_ViewDistance) :
|
||||||
|
|
||||||
cClientHandle::~cClientHandle()
|
cClientHandle::~cClientHandle()
|
||||||
{
|
{
|
||||||
ASSERT(m_State >= csDestroyedWaiting); // Has Destroy() been called?
|
ASSERT(m_State == csDestroyed); // Has Destroy() been called?
|
||||||
|
|
||||||
LOGD("Deleting client \"%s\" at %p", GetUsername().c_str(), this);
|
LOGD("Deleting client \"%s\" at %p", GetUsername().c_str(), this);
|
||||||
|
|
||||||
|
@ -169,7 +165,7 @@ void cClientHandle::Destroy(void)
|
||||||
RemoveFromAllChunks();
|
RemoveFromAllChunks();
|
||||||
m_Player->GetWorld()->RemoveClientFromChunkSender(this);
|
m_Player->GetWorld()->RemoveClientFromChunkSender(this);
|
||||||
}
|
}
|
||||||
m_State = csDestroyedWaiting;
|
m_State = csDestroyed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1823,18 +1819,7 @@ bool cClientHandle::CheckBlockInteractionsRate(void)
|
||||||
|
|
||||||
|
|
||||||
void cClientHandle::Tick(float a_Dt)
|
void cClientHandle::Tick(float a_Dt)
|
||||||
{
|
{
|
||||||
// Handle clients that are waiting for final close while destroyed:
|
|
||||||
if (m_State == csDestroyedWaiting)
|
|
||||||
{
|
|
||||||
m_TicksSinceDestruction += 1; // This field is misused for the timeout counting
|
|
||||||
if (m_TicksSinceDestruction > TICKS_BEFORE_CLOSE)
|
|
||||||
{
|
|
||||||
m_State = csDestroyed;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Process received network data:
|
// Process received network data:
|
||||||
AString IncomingData;
|
AString IncomingData;
|
||||||
{
|
{
|
||||||
|
@ -1900,15 +1885,7 @@ void cClientHandle::Tick(float a_Dt)
|
||||||
|
|
||||||
|
|
||||||
void cClientHandle::ServerTick(float a_Dt)
|
void cClientHandle::ServerTick(float a_Dt)
|
||||||
{
|
{
|
||||||
// Handle clients that are waiting for final close while destroyed:
|
|
||||||
if (m_State == csDestroyedWaiting)
|
|
||||||
{
|
|
||||||
// Do not wait while the client is not in the world, simply cut them off.
|
|
||||||
m_State = csDestroyed;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Process received network data:
|
// Process received network data:
|
||||||
AString IncomingData;
|
AString IncomingData;
|
||||||
{
|
{
|
||||||
|
|
|
@ -325,9 +325,6 @@ private:
|
||||||
int m_LastDigBlockX;
|
int m_LastDigBlockX;
|
||||||
int m_LastDigBlockY;
|
int m_LastDigBlockY;
|
||||||
int m_LastDigBlockZ;
|
int m_LastDigBlockZ;
|
||||||
|
|
||||||
/** Used while csDestroyedWaiting for counting the ticks until the connection is closed */
|
|
||||||
int m_TicksSinceDestruction;
|
|
||||||
|
|
||||||
enum eState
|
enum eState
|
||||||
{
|
{
|
||||||
|
@ -338,7 +335,6 @@ private:
|
||||||
csConfirmingPos, ///< The client has been sent the position packet, waiting for them to repeat the position back
|
csConfirmingPos, ///< The client has been sent the position packet, waiting for them to repeat the position back
|
||||||
csPlaying, ///< Normal gameplay
|
csPlaying, ///< Normal gameplay
|
||||||
csDestroying, ///< The client is being destroyed, don't queue any more packets / don't add to chunks
|
csDestroying, ///< The client is being destroyed, don't queue any more packets / don't add to chunks
|
||||||
csDestroyedWaiting, ///< The client has been destroyed, but is still kept so that the Kick packet is delivered (#31)
|
|
||||||
csDestroyed, ///< The client has been destroyed, the destructor is to be called from the owner thread
|
csDestroyed, ///< The client has been destroyed, the destructor is to be called from the owner thread
|
||||||
|
|
||||||
// TODO: Add Kicking here as well
|
// TODO: Add Kicking here as well
|
||||||
|
|
Loading…
Reference in New Issue
Block a user