diff options
author | Tiger Wang <ziwei.tiger@outlook.com> | 2021-03-05 14:03:55 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-05 14:03:55 +0100 |
commit | 868cd94ee9a5a0638c014a4cc42224f01ff234c8 (patch) | |
tree | cd23dc866f77de5b0b3e89a5eafeeb2ef24ffbdd /src/ChunkMap.cpp | |
parent | fixed the crash on generating in the SinglePiceStructuresGen (#5136) (diff) | |
download | cuberite-868cd94ee9a5a0638c014a4cc42224f01ff234c8.tar cuberite-868cd94ee9a5a0638c014a4cc42224f01ff234c8.tar.gz cuberite-868cd94ee9a5a0638c014a4cc42224f01ff234c8.tar.bz2 cuberite-868cd94ee9a5a0638c014a4cc42224f01ff234c8.tar.lz cuberite-868cd94ee9a5a0638c014a4cc42224f01ff234c8.tar.xz cuberite-868cd94ee9a5a0638c014a4cc42224f01ff234c8.tar.zst cuberite-868cd94ee9a5a0638c014a4cc42224f01ff234c8.zip |
Diffstat (limited to '')
-rw-r--r-- | src/ChunkMap.cpp | 46 |
1 files changed, 6 insertions, 40 deletions
diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp index c1d9b78ab..dbd6f8cf3 100644 --- a/src/ChunkMap.cpp +++ b/src/ChunkMap.cpp @@ -30,12 +30,7 @@ // cChunkMap: cChunkMap::cChunkMap(cWorld * a_World) : - m_World(a_World), - m_Pool( - std::make_unique<cListAllocationPool<cChunkData::sChunkSection>>( - std::make_unique<cStarvationCallbacks>(), 1600u, 5000u - ) - ) + m_World(a_World) { } @@ -43,25 +38,12 @@ cChunkMap::cChunkMap(cWorld * a_World) : -cChunkMap::~cChunkMap() -{ - // Explicitly destroy all chunks, so that they're guaranteed to be - // destroyed before other internals. This fixes crashes on stopping the server. - // because the chunk destructor deletes entities and those may access the chunkmap. - // Also, the cChunkData destructor accesses the chunkMap's allocator. - m_Chunks.clear(); -} - - - - - cChunk & cChunkMap::ConstructChunk(int a_ChunkX, int a_ChunkZ) { // If not exists insert. Then, return the chunk at these coordinates: return m_Chunks.try_emplace( { a_ChunkX, a_ChunkZ }, - a_ChunkX, a_ChunkZ, this, m_World, *m_Pool + a_ChunkX, a_ChunkZ, this, m_World ).first->second; } @@ -232,15 +214,15 @@ void cChunkMap::MarkChunkSaved (int a_ChunkX, int a_ChunkZ) -void cChunkMap::SetChunkData(cSetChunkData & a_SetChunkData) +void cChunkMap::SetChunkData(struct SetChunkData && a_SetChunkData) { - int ChunkX = a_SetChunkData.GetChunkX(); - int ChunkZ = a_SetChunkData.GetChunkZ(); + const int ChunkX = a_SetChunkData.Chunk.m_ChunkX; + const int ChunkZ = a_SetChunkData.Chunk.m_ChunkZ; { cCSLock Lock(m_CSChunks); const auto Chunk = FindChunk(ChunkX, ChunkZ); ASSERT(Chunk != nullptr); // Chunk cannot have unloaded since it is marked as queued - Chunk->SetAllData(a_SetChunkData); + Chunk->SetAllData(std::move(a_SetChunkData)); // Notify relevant ChunkStays: cChunkStays ToBeDisabled; @@ -310,22 +292,6 @@ bool cChunkMap::GetChunkData(cChunkCoords a_Coords, cChunkDataCallback & a_Callb -bool cChunkMap::GetChunkBlockTypes(int a_ChunkX, int a_ChunkZ, BLOCKTYPE * a_BlockTypes) -{ - cCSLock Lock(m_CSChunks); - const auto Chunk = FindChunk(a_ChunkX, a_ChunkZ); - if ((Chunk == nullptr) || !Chunk->IsValid()) - { - return false; - } - Chunk->GetBlockTypes(a_BlockTypes); - return true; -} - - - - - bool cChunkMap::IsChunkQueued(int a_ChunkX, int a_ChunkZ) const { cCSLock Lock(m_CSChunks); |