summaryrefslogtreecommitdiffstats
path: root/source/ClientHandle.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-04-13 23:02:10 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-04-13 23:02:10 +0200
commita49c004278b0e300521e9cedf44a46ac843a958b (patch)
treecc268ccbd5b938be93923d9aced847572364e263 /source/ClientHandle.cpp
parentFixed a bit of coding style and function names in cItem (diff)
downloadcuberite-a49c004278b0e300521e9cedf44a46ac843a958b.tar
cuberite-a49c004278b0e300521e9cedf44a46ac843a958b.tar.gz
cuberite-a49c004278b0e300521e9cedf44a46ac843a958b.tar.bz2
cuberite-a49c004278b0e300521e9cedf44a46ac843a958b.tar.lz
cuberite-a49c004278b0e300521e9cedf44a46ac843a958b.tar.xz
cuberite-a49c004278b0e300521e9cedf44a46ac843a958b.tar.zst
cuberite-a49c004278b0e300521e9cedf44a46ac843a958b.zip
Diffstat (limited to 'source/ClientHandle.cpp')
-rw-r--r--source/ClientHandle.cpp30
1 files changed, 14 insertions, 16 deletions
diff --git a/source/ClientHandle.cpp b/source/ClientHandle.cpp
index c1b696630..497639649 100644
--- a/source/ClientHandle.cpp
+++ b/source/ClientHandle.cpp
@@ -137,7 +137,10 @@ cClientHandle::~cClientHandle()
if (World != NULL)
{
World->RemovePlayer(m_Player);
+ m_Player->Destroy();
}
+ delete m_Player;
+ m_Player = NULL;
}
if (!m_HasSentDC)
@@ -145,12 +148,6 @@ cClientHandle::~cClientHandle()
SendDisconnect("Server shut down? Kthnxbai");
}
- if (m_Player != NULL)
- {
- m_Player->Destroy();
- m_Player = NULL;
- }
-
// Queue all remaining outgoing packets to cSocketThreads:
{
cCSLock Lock(m_CSOutgoingData);
@@ -325,7 +322,7 @@ void cClientHandle::StreamChunks(void)
}
for (cChunkCoordsList::iterator itr = RemoveChunks.begin(); itr != RemoveChunks.end(); ++itr)
{
- World->RemoveChunkClient(itr->m_ChunkX, itr->m_ChunkY, itr->m_ChunkZ, this);
+ World->RemoveChunkClient(itr->m_ChunkX, itr->m_ChunkZ, this);
m_Protocol->SendUnloadChunk(itr->m_ChunkX, itr->m_ChunkZ);
} // for itr - RemoveChunks[]
@@ -336,13 +333,13 @@ void cClientHandle::StreamChunks(void)
// For each distance add chunks in a hollow square centered around current position:
for (int i = -d; i <= d; ++i)
{
- StreamChunk(ChunkPosX + d, ZERO_CHUNK_Y, ChunkPosZ + i);
- StreamChunk(ChunkPosX - d, ZERO_CHUNK_Y, ChunkPosZ + i);
+ StreamChunk(ChunkPosX + d, ChunkPosZ + i);
+ StreamChunk(ChunkPosX - d, ChunkPosZ + i);
} // for i
for (int i = -d + 1; i < d; ++i)
{
- StreamChunk(ChunkPosX + i, ZERO_CHUNK_Y, ChunkPosZ + d);
- StreamChunk(ChunkPosX + i, ZERO_CHUNK_Y, ChunkPosZ - d);
+ StreamChunk(ChunkPosX + i, ChunkPosZ + d);
+ StreamChunk(ChunkPosX + i, ChunkPosZ - d);
} // for i
} // for d
@@ -366,7 +363,7 @@ void cClientHandle::StreamChunks(void)
-void cClientHandle::StreamChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ)
+void cClientHandle::StreamChunk(int a_ChunkX, int a_ChunkZ)
{
if (m_State >= csDestroying)
{
@@ -377,14 +374,14 @@ void cClientHandle::StreamChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ)
cWorld * World = m_Player->GetWorld();
ASSERT(World != NULL);
- if (World->AddChunkClient(a_ChunkX, a_ChunkY, a_ChunkZ, this))
+ if (World->AddChunkClient(a_ChunkX, a_ChunkZ, this))
{
{
cCSLock Lock(m_CSChunkLists);
- m_LoadedChunks.push_back(cChunkCoords(a_ChunkX, a_ChunkY, a_ChunkZ));
- m_ChunksToSend.push_back(cChunkCoords(a_ChunkX, a_ChunkY, a_ChunkZ));
+ m_LoadedChunks.push_back(cChunkCoords(a_ChunkX, ZERO_CHUNK_Y, a_ChunkZ));
+ m_ChunksToSend.push_back(cChunkCoords(a_ChunkX, ZERO_CHUNK_Y, a_ChunkZ));
}
- World->SendChunkTo(a_ChunkX, a_ChunkY, a_ChunkZ, this);
+ World->SendChunkTo(a_ChunkX, a_ChunkZ, this);
}
}
@@ -1128,6 +1125,7 @@ void cClientHandle::HandleDisconnect(const AString & a_Reason)
Printf(DisconnectMessage, "%s disconnected: %s", m_Username.c_str(), a_Reason.c_str());
m_Player->GetWorld()->BroadcastChat(DisconnectMessage, this);
}
+ m_HasSentDC = true;
Destroy();
}