diff options
-rw-r--r-- | src/ChunkMap.cpp | 10 | ||||
-rw-r--r-- | src/ChunkMap.h | 16 |
2 files changed, 6 insertions, 20 deletions
diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp index facfe8a31..4425ebb23 100644 --- a/src/ChunkMap.cpp +++ b/src/ChunkMap.cpp @@ -63,7 +63,7 @@ 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( - ChunkCoordinate{ a_ChunkX, a_ChunkZ }, + { a_ChunkX, a_ChunkZ }, a_ChunkX, a_ChunkZ, this, m_World, *m_Pool ).first->second; } @@ -1548,7 +1548,7 @@ bool cChunkMap::ForEachLoadedChunk(cFunctionRef<bool(int, int)> a_Callback) cons { if (Chunk.second.IsValid()) { - if (a_Callback(Chunk.first.ChunkX, Chunk.first.ChunkZ)) + if (a_Callback(Chunk.first.m_ChunkX, Chunk.first.m_ChunkZ)) { return false; } @@ -1729,11 +1729,11 @@ void cChunkMap::UnloadUnusedChunks(void) { if ( itr->second.CanUnload() && // Can unload - !cPluginManager::Get()->CallHookChunkUnloading(*GetWorld(), itr->first.ChunkX, itr->first.ChunkZ) // Plugins agree + !cPluginManager::Get()->CallHookChunkUnloading(*GetWorld(), itr->first.m_ChunkX, itr->first.m_ChunkZ) // Plugins agree ) { // First notify plugins: - cPluginManager::Get()->CallHookChunkUnloaded(*m_World, itr->first.ChunkX, itr->first.ChunkZ); + cPluginManager::Get()->CallHookChunkUnloaded(*m_World, itr->first.m_ChunkX, itr->first.m_ChunkZ); // Notify entities within the chunk, while everything's still valid: itr->second.OnUnload(); @@ -1759,7 +1759,7 @@ void cChunkMap::SaveAllChunks(void) const { if (Chunk.second.IsValid() && Chunk.second.IsDirty()) { - GetWorld()->GetStorage().QueueSaveChunk(Chunk.first.ChunkX, Chunk.first.ChunkZ); + GetWorld()->GetStorage().QueueSaveChunk(Chunk.first.m_ChunkX, Chunk.first.m_ChunkZ); } } } diff --git a/src/ChunkMap.h b/src/ChunkMap.h index 38f03255a..e40a5d59d 100644 --- a/src/ChunkMap.h +++ b/src/ChunkMap.h @@ -421,27 +421,13 @@ private: } }; - struct ChunkCoordinate - { - struct Comparer - { - bool operator() (const ChunkCoordinate & a_Lhs, const ChunkCoordinate & a_Rhs) const - { - return ((a_Lhs.ChunkX == a_Rhs.ChunkX) ? (a_Lhs.ChunkZ < a_Rhs.ChunkZ) : (a_Lhs.ChunkX < a_Rhs.ChunkX)); - } - }; - - int ChunkX; - int ChunkZ; - }; - typedef std::list<cChunkStay *> cChunkStays; mutable cCriticalSection m_CSChunks; /** A map of chunk coordinates to chunks. Uses a map (as opposed to unordered_map) because sorted maps are apparently faster. */ - std::map<ChunkCoordinate, cChunk, ChunkCoordinate::Comparer> m_Chunks; + std::map<cChunkCoords, cChunk> m_Chunks; cEvent m_evtChunkValid; // Set whenever any chunk becomes valid, via ChunkValidated() |