From 382e014ebcd44a72788bea8cdcec7f64861b063f Mon Sep 17 00:00:00 2001 From: Howaner Date: Thu, 2 Oct 2014 23:50:41 +0200 Subject: Optimized chunk loader --- src/ClientHandle.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/ClientHandle.h') diff --git a/src/ClientHandle.h b/src/ClientHandle.h index 20592c190..897fb8705 100644 --- a/src/ClientHandle.h +++ b/src/ClientHandle.h @@ -113,7 +113,11 @@ public: /** Authenticates the specified user, called by cAuthenticator */ void Authenticate(const AString & a_Name, const AString & a_UUID, const Json::Value & a_Properties); - void StreamChunks(void); + /** This function sends a new unloaded chunk to the player. */ + void StreamNextChunk(void); + + /** Remove all loaded chunks that are no longer in range */ + void UnloadOutOfRangeChunks(void); // Removes the client from all chunks. Used when switching worlds or destroying the player void RemoveFromAllChunks(void); @@ -352,10 +356,6 @@ private: cPlayer * m_Player; bool m_HasSentDC; ///< True if a D/C packet has been sent in either direction - - // Chunk position when the last StreamChunks() was called; used to avoid re-streaming while in the same chunk - int m_LastStreamedChunkX; - int m_LastStreamedChunkZ; /** Seconds since the last packet data was received (updated in Tick(), reset in DataReceived()) */ float m_TimeSinceLastPacket; -- cgit v1.2.3 From 5a6b86180e0144a5671c747b838d14992c21afae Mon Sep 17 00:00:00 2001 From: Howaner Date: Mon, 6 Oct 2014 17:38:17 +0200 Subject: Better StreamNextChunk() method --- src/ClientHandle.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/ClientHandle.h') diff --git a/src/ClientHandle.h b/src/ClientHandle.h index 897fb8705..018c537c6 100644 --- a/src/ClientHandle.h +++ b/src/ClientHandle.h @@ -357,6 +357,10 @@ private: bool m_HasSentDC; ///< True if a D/C packet has been sent in either direction + // Chunk position when the last StreamChunks() was called; used to avoid re-streaming while in the same chunk + int m_LastStreamedChunkX; + int m_LastStreamedChunkZ; + /** Seconds since the last packet data was received (updated in Tick(), reset in DataReceived()) */ float m_TimeSinceLastPacket; -- cgit v1.2.3 From b493beb3bbac05d0402a6e388a61bf446c6c00ff Mon Sep 17 00:00:00 2001 From: Howaner Date: Mon, 6 Oct 2014 21:27:53 +0200 Subject: Stream 4 chunks per tick. Added priority. --- src/ClientHandle.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/ClientHandle.h') diff --git a/src/ClientHandle.h b/src/ClientHandle.h index eb91b8487..c6444b1c2 100644 --- a/src/ClientHandle.h +++ b/src/ClientHandle.h @@ -21,6 +21,7 @@ #include "Enchantments.h" #include "UI/SlotArea.h" #include "json/json.h" +#include "ChunkSender.h" @@ -113,8 +114,8 @@ public: /** Authenticates the specified user, called by cAuthenticator */ void Authenticate(const AString & a_Name, const AString & a_UUID, const Json::Value & a_Properties); - /** This function sends a new unloaded chunk to the player. */ - void StreamNextChunk(void); + /** This function sends a new unloaded chunk to the player. Returns true if all chunks are loaded. */ + bool StreamNextChunk(); /** Remove all loaded chunks that are no longer in range */ void UnloadOutOfRangeChunks(void); @@ -448,7 +449,7 @@ private: bool CheckBlockInteractionsRate(void); /** Adds a single chunk to be streamed to the client; used by StreamChunks() */ - void StreamChunk(int a_ChunkX, int a_ChunkZ); + void StreamChunk(int a_ChunkX, int a_ChunkZ, cChunkSender::eChunkPriority a_Priority); /** Handles the DIG_STARTED dig packet: */ void HandleBlockDigStarted (int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, BLOCKTYPE a_OldBlock, NIBBLETYPE a_OldMeta); -- cgit v1.2.3