summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHowaner <franzi.moos@googlemail.com>2014-11-15 22:26:54 +0100
committerHowaner <franzi.moos@googlemail.com>2014-11-15 22:26:54 +0100
commit09cea625fcf2d1eb1fb37a57c5712d992c96e4fd (patch)
tree8998994303f688065504f16841f815dc436e7fa4
parentRenamed m_SetViewDistance to m_RequestedViewDistance (diff)
downloadcuberite-09cea625fcf2d1eb1fb37a57c5712d992c96e4fd.tar
cuberite-09cea625fcf2d1eb1fb37a57c5712d992c96e4fd.tar.gz
cuberite-09cea625fcf2d1eb1fb37a57c5712d992c96e4fd.tar.bz2
cuberite-09cea625fcf2d1eb1fb37a57c5712d992c96e4fd.tar.lz
cuberite-09cea625fcf2d1eb1fb37a57c5712d992c96e4fd.tar.xz
cuberite-09cea625fcf2d1eb1fb37a57c5712d992c96e4fd.tar.zst
cuberite-09cea625fcf2d1eb1fb37a57c5712d992c96e4fd.zip
-rw-r--r--src/ClientHandle.cpp16
-rw-r--r--src/ClientHandle.h6
2 files changed, 11 insertions, 11 deletions
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp
index 3feb4c596..0b9d84bf7 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -65,7 +65,7 @@ int cClientHandle::s_ClientCount = 0;
// cClientHandle:
cClientHandle::cClientHandle(const cSocket * a_Socket, int a_ViewDistance) :
- m_UsedViewDistance(a_ViewDistance),
+ m_CurrentViewDistance(a_ViewDistance),
m_RequestedViewDistance(a_ViewDistance),
m_IPString(a_Socket->GetIPString()),
m_OutgoingData(64 KiB),
@@ -431,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_UsedViewDistance; Range++)
+ for (int Range = 0; Range < m_CurrentViewDistance; Range++)
{
Vector3d Vector = Position + LookVector * cChunkDef::Width * Range;
@@ -448,7 +448,7 @@ bool cClientHandle::StreamNextChunk(void)
cChunkCoords Coords(ChunkX, ChunkZ);
// Checks if the chunk is in distance
- if ((Diff(ChunkX, ChunkPosX) > m_UsedViewDistance) || (Diff(ChunkZ, ChunkPosZ) > m_UsedViewDistance))
+ if ((Diff(ChunkX, ChunkPosX) > m_CurrentViewDistance) || (Diff(ChunkZ, ChunkPosZ) > m_CurrentViewDistance))
{
continue;
}
@@ -471,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_UsedViewDistance; ++d) // cycle through (square) distance, from nearest to furthest
+ for (int d = 0; d <= m_CurrentViewDistance; ++d) // cycle through (square) distance, from nearest to furthest
{
// For each distance add chunks in a hollow square centered around current position:
cChunkCoordsList CurcleChunks;
@@ -529,7 +529,7 @@ void cClientHandle::UnloadOutOfRangeChunks(void)
{
int DiffX = Diff((*itr).m_ChunkX, ChunkPosX);
int DiffZ = Diff((*itr).m_ChunkZ, ChunkPosZ);
- if ((DiffX > m_UsedViewDistance) || (DiffZ > m_UsedViewDistance))
+ if ((DiffX > m_CurrentViewDistance) || (DiffZ > m_CurrentViewDistance))
{
ChunksToRemove.push_back(*itr);
itr = m_LoadedChunks.erase(itr);
@@ -544,7 +544,7 @@ void cClientHandle::UnloadOutOfRangeChunks(void)
{
int DiffX = Diff((*itr).m_ChunkX, ChunkPosX);
int DiffZ = Diff((*itr).m_ChunkZ, ChunkPosZ);
- if ((DiffX > m_UsedViewDistance) || (DiffZ > m_UsedViewDistance))
+ if ((DiffX > m_CurrentViewDistance) || (DiffZ > m_CurrentViewDistance))
{
itr = m_ChunksToSend.erase(itr);
}
@@ -2851,8 +2851,8 @@ void cClientHandle::SetViewDistance(int a_ViewDistance)
ASSERT(m_Player->GetWorld() == NULL);
m_RequestedViewDistance = a_ViewDistance;
- m_UsedViewDistance = Clamp(a_ViewDistance, cClientHandle::MIN_VIEW_DISTANCE, m_Player->GetWorld()->GetMaxViewDistance());
- LOGD("Setted view distance from %s to %d!", GetUsername().c_str(), m_UsedViewDistance);
+ m_CurrentViewDistance = Clamp(a_ViewDistance, cClientHandle::MIN_VIEW_DISTANCE, m_Player->GetWorld()->GetMaxViewDistance());
+ LOGD("Setted view distance from %s to %d!", GetUsername().c_str(), m_CurrentViewDistance);
}
diff --git a/src/ClientHandle.h b/src/ClientHandle.h
index c0826d7c4..8d241c1e7 100644
--- a/src/ClientHandle.h
+++ b/src/ClientHandle.h
@@ -221,7 +221,7 @@ public:
void SetViewDistance(int a_ViewDistance);
/** Returns the view distance that the player currently have. */
- int GetViewDistance(void) const { return m_UsedViewDistance; }
+ int GetViewDistance(void) const { return m_CurrentViewDistance; }
/** Returns the view distance that the player request, not the used view distance. */
int GetRequestedViewDistance(void) const { return m_RequestedViewDistance; }
@@ -339,8 +339,8 @@ private:
/** The type used for storing the names of registered plugin channels. */
typedef std::set<AString> cChannels;
- /** Number of chunks the player can see in each direction */
- int m_UsedViewDistance;
+ /** The actual view distance used, the minimum of client's requested view distance and world's max view distance. */
+ int m_CurrentViewDistance;
/** The requested view distance from the player. It isn't clamped with 1 and the max view distance of the world. */
int m_RequestedViewDistance;