From 578560d2132188279e4b0930212edd915bc90008 Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Mon, 1 Apr 2013 20:56:25 +0000 Subject: Proper fix for FS #347. Also unification of ticking block entities. git-svn-id: http://mc-server.googlecode.com/svn/trunk@1348 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/Chunk.cpp | 35 +++++++++-------------------------- 1 file changed, 9 insertions(+), 26 deletions(-) (limited to 'source/Chunk.cpp') diff --git a/source/Chunk.cpp b/source/Chunk.cpp index 9121dd112..ad534f634 100644 --- a/source/Chunk.cpp +++ b/source/Chunk.cpp @@ -296,14 +296,8 @@ void cChunk::SetAllData( CalculateHeightmap(); } - // Initialize incoming entities: - for (cEntityList::iterator itr = a_Entities.begin(), end = a_Entities.end(); itr != end; ++itr) - { - (*itr)->Initialize(m_World); - } // for itr - a_Entities[] - // Append entities to current entity list: - m_Entities.splice(m_Entities.end(), a_Entities); + m_Entities.insert(m_Entities.end(), a_Entities.begin(), a_Entities.end()); // 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) @@ -456,24 +450,13 @@ void cChunk::Tick(float a_Dt, MTRand & a_TickRandom) TickBlocks(a_TickRandom); - // Tick block entities (furnaces) + // Tick all block entities in this chunk: for (cBlockEntityList::iterator itr = m_BlockEntities.begin(); itr != m_BlockEntities.end(); ++itr) { - if ((*itr)->GetBlockType() == E_BLOCK_FURNACE) - { - m_IsDirty = ((cFurnaceEntity *)(*itr))->Tick( a_Dt ) | m_IsDirty; - } + m_IsDirty = (*itr)->Tick(a_Dt) | m_IsDirty; } - - // Tick block entities (dispensers) - for (cBlockEntityList::iterator itr = m_BlockEntities.begin(); itr != m_BlockEntities.end(); ++itr) - { - if ((*itr)->GetBlockType() == E_BLOCK_DISPENSER) - { - m_IsDirty = ((cDispenserEntity *)(*itr))->Tick( a_Dt ) | m_IsDirty; - } - } - ApplyWeatherToTop(a_TickRandom); + + ApplyWeatherToTop(); } @@ -570,10 +553,10 @@ void cChunk::TickBlocks(MTRand & a_TickRandom) -void cChunk::ApplyWeatherToTop(MTRand & a_TickRandom) +void cChunk::ApplyWeatherToTop() { if ( - (a_TickRandom.randInt(100) != 0) || + (m_World->GetTickRandomNumber(100) != 0) || ( (m_World->GetWeather() != eWeather_Rain) && (m_World->GetWeather() != eWeather_ThunderStorm) @@ -584,8 +567,8 @@ void cChunk::ApplyWeatherToTop(MTRand & a_TickRandom) return; } - int X = a_TickRandom.randInt(15); - int Z = a_TickRandom.randInt(15); + int X = m_World->GetTickRandomNumber(15); + int Z = m_World->GetTickRandomNumber(15); switch (GetBiomeAt(X, Z)) { case biTaiga: -- cgit v1.2.3