summaryrefslogtreecommitdiffstats
path: root/src/ChunkMap.cpp
diff options
context:
space:
mode:
authordaniel0916 <theschokolps@gmail.com>2014-04-16 14:31:02 +0200
committerdaniel0916 <theschokolps@gmail.com>2014-04-16 14:31:02 +0200
commit5a9acb7eb6eef293dc53cfe916c74f5cfa069db4 (patch)
tree8e0b29c5f0240ac0961e69b905921243130d0258 /src/ChunkMap.cpp
parentFixed merge conflict (diff)
parentAttempted fix for the client crash with the new protocols. (diff)
downloadcuberite-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.cpp26
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();
}