From 9cebc9157cf43ba639227b9d79b980b3613dda1e Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 10 Feb 2014 22:47:10 +0100 Subject: Rewritten Lua ChunkStay API into a single function, cWorld:ChunkStay(). This fixes problems with indeterminate class object lifespan (Lua-GC) and forgetting to disable it or keep it until ready. --- src/ChunkMap.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/ChunkMap.cpp') diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp index 7726a0b7e..0c5a8d9b9 100644 --- a/src/ChunkMap.cpp +++ b/src/ChunkMap.cpp @@ -912,9 +912,18 @@ void cChunkMap::SetChunkData( } // Notify relevant ChunkStays: - for (cChunkStays::iterator itr = m_ChunkStays.begin(), end = m_ChunkStays.end(); itr != end; ++itr) + for (cChunkStays::iterator itr = m_ChunkStays.begin(); itr != m_ChunkStays.end(); ) { - (*itr)->ChunkAvailable(a_ChunkX, a_ChunkZ); + if ((*itr)->ChunkAvailable(a_ChunkX, a_ChunkZ)) + { + cChunkStays::iterator cur = itr; + ++itr; + m_ChunkStays.erase(cur); + } + else + { + ++itr; + } } // for itr - m_ChunkStays[] } -- cgit v1.2.3