From 06942871dde1388284a4fe222040720de3923b03 Mon Sep 17 00:00:00 2001 From: Tycho Date: Tue, 5 Aug 2014 21:48:23 +0100 Subject: Refactored Redstone simulator not to depend on TNTEntity or DropSpenserENtity Directly --- src/Chunk.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'src/Chunk.cpp') diff --git a/src/Chunk.cpp b/src/Chunk.cpp index cd7dc698c..9e06f58ec 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -2127,6 +2127,40 @@ bool cChunk::DoWithBlockEntityAt(int a_BlockX, int a_BlockY, int a_BlockZ, cBloc +bool cChunk::DoWithRedstonePoweredEntityAt(int a_BlockX, int a_BlockY, int a_BlockZ, cRedstonePoweredCallback & a_Callback) +{ + // The blockentity list is locked by the parent chunkmap's CS + for (cBlockEntityList::iterator itr = m_BlockEntities.begin(), itr2 = itr; itr != m_BlockEntities.end(); itr = itr2) + { + ++itr2; + if (((*itr)->GetPosX() != a_BlockX) || ((*itr)->GetPosY() != a_BlockY) || ((*itr)->GetPosZ() != a_BlockZ)) + { + continue; + } + switch ((*itr)->GetBlockType()) + { + case E_BLOCK_DROPPER: + case E_BLOCK_DISPENSER: + break; + default: + // There is a block entity here, but of different type. No other block entity can be here, so we can safely bail out + return false; + } + + if (a_Callback.Item((cRedstonePoweredEntity *)*itr)) + { + return false; + } + return true; + } // for itr - m_BlockEntitites[] + + // Not found: + return false; +} + + + + bool cChunk::DoWithBeaconAt(int a_BlockX, int a_BlockY, int a_BlockZ, cBeaconCallback & a_Callback) { // The blockentity list is locked by the parent chunkmap's CS -- cgit v1.2.3 From 9272bd627c732771b81e6dcf6b8465404917a9d6 Mon Sep 17 00:00:00 2001 From: Tycho Date: Tue, 5 Aug 2014 22:54:36 +0100 Subject: Removed dependecy of redstone simulator on NoteBlock --- src/Chunk.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/Chunk.cpp') diff --git a/src/Chunk.cpp b/src/Chunk.cpp index 9e06f58ec..1e8d0e6f0 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -2141,6 +2141,7 @@ bool cChunk::DoWithRedstonePoweredEntityAt(int a_BlockX, int a_BlockY, int a_Blo { case E_BLOCK_DROPPER: case E_BLOCK_DISPENSER: + case E_BLOCK_NOTE_BLOCK: break; default: // There is a block entity here, but of different type. No other block entity can be here, so we can safely bail out -- cgit v1.2.3 From 6acddd0cad25078ae2c67e7a0eb353e9d4d100e2 Mon Sep 17 00:00:00 2001 From: Tycho Date: Wed, 6 Aug 2014 13:19:22 +0100 Subject: Fixed style issues --- src/Chunk.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/Chunk.cpp') diff --git a/src/Chunk.cpp b/src/Chunk.cpp index 1e8d0e6f0..a79a485a6 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -2142,10 +2142,10 @@ bool cChunk::DoWithRedstonePoweredEntityAt(int a_BlockX, int a_BlockY, int a_Blo case E_BLOCK_DROPPER: case E_BLOCK_DISPENSER: case E_BLOCK_NOTE_BLOCK: - break; + break; default: - // There is a block entity here, but of different type. No other block entity can be here, so we can safely bail out - return false; + // There is a block entity here, but of different type. No other block entity can be here, so we can safely bail out + return false; } if (a_Callback.Item((cRedstonePoweredEntity *)*itr)) -- cgit v1.2.3 From 008c1cdaf436dec2d7a4a925c6a600570594d6a2 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 14 Aug 2014 01:03:30 +0200 Subject: CheckBasicStyle checks the src folder as well. --- src/Chunk.cpp | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'src/Chunk.cpp') diff --git a/src/Chunk.cpp b/src/Chunk.cpp index a79a485a6..7bdf4196d 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -579,7 +579,7 @@ void cChunk::Tick(float a_Dt) } for (cEntityList::iterator itr = m_Entities.begin(); itr != m_Entities.end();) - { + { if (!((*itr)->IsMob())) // Mobs are ticked inside cWorld::TickMobs() (as we don't have to tick them if they are far away from players) { // Tick all entities in this chunk (except mobs): @@ -594,17 +594,19 @@ void cChunk::Tick(float a_Dt) itr = m_Entities.erase(itr); delete ToDelete; } - else if ((*itr)->IsWorldTravellingFrom(m_World)) // Remove all entities that are travelling to another world: + else if ((*itr)->IsWorldTravellingFrom(m_World)) { + // Remove all entities that are travelling to another world MarkDirty(); (*itr)->SetWorldTravellingFrom(NULL); itr = m_Entities.erase(itr); } - else if ( // If any entity moved out of the chunk, move it to the neighbor: + else if ( ((*itr)->GetChunkX() != m_PosX) || ((*itr)->GetChunkZ() != m_PosZ) ) { + // The entity moved out of the chunk, move it to the neighbor MarkDirty(); MoveEntityToNewChunk(*itr); itr = m_Entities.erase(itr); @@ -885,14 +887,14 @@ void cChunk::ApplyWeatherToTop() SetBlock(X, Height, Z, E_BLOCK_ICE, 0); } else if ( - (m_World->IsDeepSnowEnabled()) && - ( - (TopBlock == E_BLOCK_RED_ROSE) || - (TopBlock == E_BLOCK_YELLOW_FLOWER) || - (TopBlock == E_BLOCK_RED_MUSHROOM) || - (TopBlock == E_BLOCK_BROWN_MUSHROOM) - ) + (m_World->IsDeepSnowEnabled()) && + ( + (TopBlock == E_BLOCK_RED_ROSE) || + (TopBlock == E_BLOCK_YELLOW_FLOWER) || + (TopBlock == E_BLOCK_RED_MUSHROOM) || + (TopBlock == E_BLOCK_BROWN_MUSHROOM) ) + ) { SetBlock(X, Height, Z, E_BLOCK_SNOW, 0); } @@ -2142,10 +2144,14 @@ bool cChunk::DoWithRedstonePoweredEntityAt(int a_BlockX, int a_BlockY, int a_Blo case E_BLOCK_DROPPER: case E_BLOCK_DISPENSER: case E_BLOCK_NOTE_BLOCK: + { break; + } default: + { // There is a block entity here, but of different type. No other block entity can be here, so we can safely bail out return false; + } } if (a_Callback.Item((cRedstonePoweredEntity *)*itr)) -- cgit v1.2.3 From b5ffe06f884221f98407910bdd30baf533d84970 Mon Sep 17 00:00:00 2001 From: Howaner Date: Tue, 19 Aug 2014 22:14:37 +0200 Subject: Code formatting fixes. --- src/Chunk.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/Chunk.cpp') diff --git a/src/Chunk.cpp b/src/Chunk.cpp index 7bdf4196d..116c0f3a0 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -1,3 +1,4 @@ + #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #ifndef _WIN32 -- cgit v1.2.3