1
0

ChunkDataSerializer: don't repeatedly mallocate

+ Store an instance of the class, the way it seems it is meant to be used.
This commit is contained in:
Tiger Wang
2020-08-21 18:22:04 +01:00
parent 440523b022
commit a473e8ba52
5 changed files with 216 additions and 171 deletions

View File

@@ -11,7 +11,6 @@
#include "ChunkSender.h"
#include "World.h"
#include "BlockEntities/BlockEntity.h"
#include "Protocol/ChunkDataSerializer.h"
#include "ClientHandle.h"
#include "Chunk.h"
@@ -61,7 +60,8 @@ public:
cChunkSender::cChunkSender(cWorld & a_World) :
Super("ChunkSender"),
m_World(a_World)
m_World(a_World),
m_Serializer(m_World.GetDimension())
{
}
@@ -246,11 +246,8 @@ void cChunkSender::SendChunk(int a_ChunkX, int a_ChunkZ, std::unordered_set<cCli
return;
}
{
// Send:
cChunkDataSerializer Data(a_ChunkX, a_ChunkZ, m_Data, m_BiomeMap, m_World.GetDimension());
Data.SendToClients(a_Clients);
}
// Send:
m_Serializer.SendToClients(a_ChunkX, a_ChunkZ, m_Data, m_BiomeMap, a_Clients);
for (const auto Client : a_Clients)
{