summaryrefslogtreecommitdiffstats
path: root/src/ChunkSender.h
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@outlook.com>2020-09-12 21:43:18 +0200
committerGitHub <noreply@github.com>2020-09-12 21:43:18 +0200
commit198407807f1241ea2b06179bcc036f9373c7258e (patch)
treef0e4f690aaa1d35fa43115c8aa102b7f127ee70a /src/ChunkSender.h
parentUse tracing for explosions (#4845) (diff)
downloadcuberite-198407807f1241ea2b06179bcc036f9373c7258e.tar
cuberite-198407807f1241ea2b06179bcc036f9373c7258e.tar.gz
cuberite-198407807f1241ea2b06179bcc036f9373c7258e.tar.bz2
cuberite-198407807f1241ea2b06179bcc036f9373c7258e.tar.lz
cuberite-198407807f1241ea2b06179bcc036f9373c7258e.tar.xz
cuberite-198407807f1241ea2b06179bcc036f9373c7258e.tar.zst
cuberite-198407807f1241ea2b06179bcc036f9373c7258e.zip
Diffstat (limited to 'src/ChunkSender.h')
-rw-r--r--src/ChunkSender.h33
1 files changed, 15 insertions, 18 deletions
diff --git a/src/ChunkSender.h b/src/ChunkSender.h
index 2d9c478e9..be7b55b16 100644
--- a/src/ChunkSender.h
+++ b/src/ChunkSender.h
@@ -58,20 +58,21 @@ public:
cChunkSender(cWorld & a_World);
virtual ~cChunkSender() override;
- enum eChunkPriority
+ /** Tag indicating urgency of chunk to be sent.
+ Order MUST be from least to most urgent. */
+ enum class Priority
{
- E_CHUNK_PRIORITY_HIGH = 0,
- E_CHUNK_PRIORITY_MIDHIGH,
- E_CHUNK_PRIORITY_MEDIUM,
- E_CHUNK_PRIORITY_LOW,
-
+ Low,
+ Medium,
+ High,
+ Critical
};
void Stop(void);
/** Queues a chunk to be sent to a specific client */
- void QueueSendChunkTo(int a_ChunkX, int a_ChunkZ, eChunkPriority a_Priority, cClientHandle * a_Client);
- void QueueSendChunkTo(int a_ChunkX, int a_ChunkZ, eChunkPriority a_Priority, cChunkClientHandles a_Client);
+ void QueueSendChunkTo(int a_ChunkX, int a_ChunkZ, Priority a_Priority, cClientHandle * a_Client);
+ void QueueSendChunkTo(int a_ChunkX, int a_ChunkZ, Priority a_Priority, cChunkClientHandles a_Client);
/** Removes the a_Client from all waiting chunk send operations */
void RemoveClient(cClientHandle * a_Client);
@@ -80,18 +81,14 @@ protected:
struct sChunkQueue
{
- eChunkPriority m_Priority;
+ Priority m_Priority;
cChunkCoords m_Chunk;
bool operator <(const sChunkQueue & a_Other) const
{
- /* The Standard Priority Queue sorts from biggest to smallest
- return true here means you are smaller than the other object, and you get pushed down.
-
- The priorities go from HIGH (0) to LOW (2), so a smaller priority should mean further up the list
- therefore, return true (affirm we're "smaller", and get pushed down) only if our priority is bigger than theirs (they're more urgent)
- */
- return this->m_Priority > a_Other.m_Priority;
+ // The operator will return true to affirm we're less urgent than Other
+ // This comparison depends on the Priority enum ordering lower priority as smaller:
+ return m_Priority < a_Other.m_Priority;
}
};
@@ -100,8 +97,8 @@ protected:
{
cChunkCoords m_Chunk;
std::unordered_set<cClientHandle *> m_Clients;
- eChunkPriority m_Priority;
- sSendChunk(cChunkCoords a_Chunk, eChunkPriority a_Priority) :
+ Priority m_Priority;
+ sSendChunk(cChunkCoords a_Chunk, Priority a_Priority) :
m_Chunk(a_Chunk),
m_Priority(a_Priority)
{