diff options
author | daniel0916 <theschokolps@gmail.com> | 2014-04-16 14:31:02 +0200 |
---|---|---|
committer | daniel0916 <theschokolps@gmail.com> | 2014-04-16 14:31:02 +0200 |
commit | 5a9acb7eb6eef293dc53cfe916c74f5cfa069db4 (patch) | |
tree | 8e0b29c5f0240ac0961e69b905921243130d0258 /src/ChunkMap.cpp | |
parent | Fixed merge conflict (diff) | |
parent | Attempted fix for the client crash with the new protocols. (diff) | |
download | cuberite-5a9acb7eb6eef293dc53cfe916c74f5cfa069db4.tar cuberite-5a9acb7eb6eef293dc53cfe916c74f5cfa069db4.tar.gz cuberite-5a9acb7eb6eef293dc53cfe916c74f5cfa069db4.tar.bz2 cuberite-5a9acb7eb6eef293dc53cfe916c74f5cfa069db4.tar.lz cuberite-5a9acb7eb6eef293dc53cfe916c74f5cfa069db4.tar.xz cuberite-5a9acb7eb6eef293dc53cfe916c74f5cfa069db4.tar.zst cuberite-5a9acb7eb6eef293dc53cfe916c74f5cfa069db4.zip |
Diffstat (limited to 'src/ChunkMap.cpp')
-rw-r--r-- | src/ChunkMap.cpp | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp index e695f0ab2..83eae2665 100644 --- a/src/ChunkMap.cpp +++ b/src/ChunkMap.cpp @@ -916,19 +916,21 @@ void cChunkMap::SetChunkData( } // Notify relevant ChunkStays: - for (cChunkStays::iterator itr = m_ChunkStays.begin(); itr != m_ChunkStays.end(); ) + cChunkStays ToBeDisabled; + for (cChunkStays::iterator itr = m_ChunkStays.begin(), end = m_ChunkStays.end(); itr != end; ++itr) { if ((*itr)->ChunkAvailable(a_ChunkX, a_ChunkZ)) { - cChunkStays::iterator cur = itr; - ++itr; - m_ChunkStays.erase(cur); - } - else - { - ++itr; + // The chunkstay wants to be disabled, add it to a list of to-be-disabled chunkstays for later processing: + ToBeDisabled.push_back(*itr); } } // for itr - m_ChunkStays[] + + // Disable (and possibly remove) the chunkstays that chose to get disabled: + for (cChunkStays::iterator itr = ToBeDisabled.begin(), end = ToBeDisabled.end(); itr != end; ++itr) + { + (*itr)->Disable(); + } } // Notify plugins of the chunk becoming available @@ -2974,7 +2976,12 @@ void cChunkMap::AddChunkStay(cChunkStay & a_ChunkStay) Chunk->Stay(true); if (Chunk->IsValid()) { - a_ChunkStay.ChunkAvailable(itr->m_ChunkX, itr->m_ChunkZ); + if (a_ChunkStay.ChunkAvailable(itr->m_ChunkX, itr->m_ChunkZ)) + { + // The chunkstay wants to be deactivated, disable it and bail out: + a_ChunkStay.Disable(); + return; + } } } // for itr - WantedChunks[] } @@ -3017,6 +3024,7 @@ void cChunkMap::DelChunkStay(cChunkStay & a_ChunkStay) } Chunk->Stay(false); } // for itr - Chunks[] + a_ChunkStay.OnDisabled(); } |