From bb44d25d60fa4719e42e27ff163c194fa3c9fb00 Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Wed, 30 May 2012 13:11:58 +0000 Subject: Fixed a crash when chunks were loaded / generated with entities ( http://forum.mc-server.org/showthread.php?tid=450 ) git-svn-id: http://mc-server.googlecode.com/svn/trunk@521 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/cChunk.cpp | 30 ++++-------------------------- 1 file changed, 4 insertions(+), 26 deletions(-) diff --git a/source/cChunk.cpp b/source/cChunk.cpp index ff8badc19..32b6f1664 100644 --- a/source/cChunk.cpp +++ b/source/cChunk.cpp @@ -259,36 +259,14 @@ void cChunk::SetAllData( CalculateHeightmap(); } - // Clear the internal entities: - for (cEntityList::iterator itr = m_Entities.begin(); itr != m_Entities.end(); ++itr) - { - if ((*itr)->GetEntityType() == cEntity::eEntityType_Player) - { - // Move players into the new entity list - a_Entities.push_back(*itr); - } - else - { - // Delete other entities (there should not be any, since we're now loading / generating the chunk) - LOGWARNING("cChunk: There is an unexpected entity #%d of type %s in chunk [%d, %d]; it will be deleted", - (*itr)->GetUniqueID(), (*itr)->GetClass(), - m_PosX, m_PosZ - ); - - // MD 2012_03_10: This may happen if a mob is generated near the edge of loaded chunks and walks off of the edge. - // Older: Assert because this is a very curious case. These lines were executed once before, when a player died, re spawned, and walked around a bit. It's uncertain why an entity would be in the chunk in this case. - // ASSERT(!"Unexpected entity in chunk!"); - - (*itr)->Destroy(); - } - } + // Append entities to current entity list: + m_Entities.splice(m_Entities.end(), a_Entities); + + // Clear the block entities present - either the loader / saver has better, or we'll create empty ones: for (cBlockEntityList::iterator itr = m_BlockEntities.begin(); itr != m_BlockEntities.end(); ++itr) { delete *itr; } - - // Swap the entity lists: - std::swap(a_Entities, m_Entities); std::swap(a_BlockEntities, m_BlockEntities); // Create block entities that the loader didn't load; fill them with defaults -- cgit v1.2.3