diff options
author | madmaxoft <github@xoft.cz> | 2014-04-12 22:15:09 +0200 |
---|---|---|
committer | madmaxoft <github@xoft.cz> | 2014-04-12 22:15:09 +0200 |
commit | 75b7244f0565170ccc40a3ebdf277945e5191be8 (patch) | |
tree | b6d29ecdfffd8317608902794d61dc746421126d | |
parent | Updated the NetherFort prefabs to current Gallery contents. (diff) | |
download | cuberite-75b7244f0565170ccc40a3ebdf277945e5191be8.tar cuberite-75b7244f0565170ccc40a3ebdf277945e5191be8.tar.gz cuberite-75b7244f0565170ccc40a3ebdf277945e5191be8.tar.bz2 cuberite-75b7244f0565170ccc40a3ebdf277945e5191be8.tar.lz cuberite-75b7244f0565170ccc40a3ebdf277945e5191be8.tar.xz cuberite-75b7244f0565170ccc40a3ebdf277945e5191be8.tar.zst cuberite-75b7244f0565170ccc40a3ebdf277945e5191be8.zip |
-rw-r--r-- | src/ChunkMap.cpp | 26 | ||||
-rw-r--r-- | src/ChunkStay.cpp | 3 |
2 files changed, 19 insertions, 10 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(); } diff --git a/src/ChunkStay.cpp b/src/ChunkStay.cpp index 6b1d5ee34..a35ccf58c 100644 --- a/src/ChunkStay.cpp +++ b/src/ChunkStay.cpp @@ -97,8 +97,9 @@ void cChunkStay::Disable(void) { ASSERT(m_ChunkMap != NULL); - m_ChunkMap->DelChunkStay(*this); + cChunkMap * ChunkMap = m_ChunkMap; m_ChunkMap = NULL; + ChunkMap->DelChunkStay(*this); } |