summaryrefslogtreecommitdiffstats
path: root/src/ClientHandle.cpp
diff options
context:
space:
mode:
authorHowaner <franzi.moos@googlemail.com>2014-11-14 22:53:12 +0100
committerHowaner <franzi.moos@googlemail.com>2014-11-14 22:53:12 +0100
commit83d3f3347b5c812b06be87804b7582a92d0294d3 (patch)
treea3e50b52ed513401b11a231c62a3a24eaf698756 /src/ClientHandle.cpp
parentMerge branch 'master' into ViewDistance (diff)
downloadcuberite-83d3f3347b5c812b06be87804b7582a92d0294d3.tar
cuberite-83d3f3347b5c812b06be87804b7582a92d0294d3.tar.gz
cuberite-83d3f3347b5c812b06be87804b7582a92d0294d3.tar.bz2
cuberite-83d3f3347b5c812b06be87804b7582a92d0294d3.tar.lz
cuberite-83d3f3347b5c812b06be87804b7582a92d0294d3.tar.xz
cuberite-83d3f3347b5c812b06be87804b7582a92d0294d3.tar.zst
cuberite-83d3f3347b5c812b06be87804b7582a92d0294d3.zip
Diffstat (limited to 'src/ClientHandle.cpp')
-rw-r--r--src/ClientHandle.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp
index d7d97c6c4..d5882da06 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -65,7 +65,8 @@ int cClientHandle::s_ClientCount = 0;
// cClientHandle:
cClientHandle::cClientHandle(const cSocket * a_Socket, int a_ViewDistance) :
- m_ViewDistance(a_ViewDistance),
+ m_UsedViewDistance(a_ViewDistance),
+ m_SetViewDistance(a_ViewDistance),
m_IPString(a_Socket->GetIPString()),
m_OutgoingData(64 KiB),
m_Player(nullptr),
@@ -430,7 +431,7 @@ bool cClientHandle::StreamNextChunk(void)
cCSLock Lock(m_CSChunkLists);
// High priority: Load the chunks that are in the view-direction of the player (with a radius of 3)
- for (int Range = 0; Range < m_ViewDistance; Range++)
+ for (int Range = 0; Range < m_UsedViewDistance; Range++)
{
Vector3d Vector = Position + LookVector * cChunkDef::Width * Range;
@@ -447,7 +448,7 @@ bool cClientHandle::StreamNextChunk(void)
cChunkCoords Coords(ChunkX, ChunkZ);
// Checks if the chunk is in distance
- if ((Diff(ChunkX, ChunkPosX) > m_ViewDistance) || (Diff(ChunkZ, ChunkPosZ) > m_ViewDistance))
+ if ((Diff(ChunkX, ChunkPosX) > m_UsedViewDistance) || (Diff(ChunkZ, ChunkPosZ) > m_UsedViewDistance))
{
continue;
}
@@ -470,7 +471,7 @@ bool cClientHandle::StreamNextChunk(void)
}
// Low priority: Add all chunks that are in range. (From the center out to the edge)
- for (int d = 0; d <= m_ViewDistance; ++d) // cycle through (square) distance, from nearest to furthest
+ for (int d = 0; d <= m_UsedViewDistance; ++d) // cycle through (square) distance, from nearest to furthest
{
// For each distance add chunks in a hollow square centered around current position:
cChunkCoordsList CurcleChunks;
@@ -528,7 +529,7 @@ void cClientHandle::UnloadOutOfRangeChunks(void)
{
int DiffX = Diff((*itr).m_ChunkX, ChunkPosX);
int DiffZ = Diff((*itr).m_ChunkZ, ChunkPosZ);
- if ((DiffX > m_ViewDistance) || (DiffZ > m_ViewDistance))
+ if ((DiffX > m_UsedViewDistance) || (DiffZ > m_UsedViewDistance))
{
ChunksToRemove.push_back(*itr);
itr = m_LoadedChunks.erase(itr);
@@ -543,7 +544,7 @@ void cClientHandle::UnloadOutOfRangeChunks(void)
{
int DiffX = Diff((*itr).m_ChunkX, ChunkPosX);
int DiffZ = Diff((*itr).m_ChunkZ, ChunkPosZ);
- if ((DiffX > m_ViewDistance) || (DiffZ > m_ViewDistance))
+ if ((DiffX > m_UsedViewDistance) || (DiffZ > m_UsedViewDistance))
{
itr = m_ChunksToSend.erase(itr);
}
@@ -2849,8 +2850,9 @@ void cClientHandle::SetViewDistance(int a_ViewDistance)
{
ASSERT(m_Player->GetWorld() == NULL);
- m_ViewDistance = Clamp(a_ViewDistance, cClientHandle::MIN_VIEW_DISTANCE, m_Player->GetWorld()->GetMaxViewDistance());
- LOGD("Setted %s's view distance to %i", GetUsername().c_str(), m_ViewDistance);
+ m_SetViewDistance = a_ViewDistance;
+ m_UsedViewDistance = Clamp(m_SetViewDistance, cClientHandle::MIN_VIEW_DISTANCE, m_Player->GetWorld()->GetMaxViewDistance());
+ LOGD("Setted view distance from %s to %i!", GetUsername().c_str(), m_UsedViewDistance);
}