summaryrefslogtreecommitdiffstats
path: root/source/cSandSimulator.cpp
diff options
context:
space:
mode:
authorfaketruth <faketruth@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-02-14 13:23:02 +0100
committerfaketruth <faketruth@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-02-14 13:23:02 +0100
commiteaa17b6a84d19e605549d6d1ea94eede98f77c67 (patch)
tree59139c7605f07310c08517b79d99252e677e4a7c /source/cSandSimulator.cpp
parentRewritten most of the code for multithreading; still not 100%, but getting there. If this commit proves to be too problematic, we can always undo it. (diff)
downloadcuberite-eaa17b6a84d19e605549d6d1ea94eede98f77c67.tar
cuberite-eaa17b6a84d19e605549d6d1ea94eede98f77c67.tar.gz
cuberite-eaa17b6a84d19e605549d6d1ea94eede98f77c67.tar.bz2
cuberite-eaa17b6a84d19e605549d6d1ea94eede98f77c67.tar.lz
cuberite-eaa17b6a84d19e605549d6d1ea94eede98f77c67.tar.xz
cuberite-eaa17b6a84d19e605549d6d1ea94eede98f77c67.tar.zst
cuberite-eaa17b6a84d19e605549d6d1ea94eede98f77c67.zip
Diffstat (limited to 'source/cSandSimulator.cpp')
-rw-r--r--source/cSandSimulator.cpp24
1 files changed, 12 insertions, 12 deletions
diff --git a/source/cSandSimulator.cpp b/source/cSandSimulator.cpp
index 9adde94e7..3fe678f90 100644
--- a/source/cSandSimulator.cpp
+++ b/source/cSandSimulator.cpp
@@ -13,8 +13,8 @@
cSandSimulator::cSandSimulator( cWorld* a_World )
: cSimulator(a_World)
- , m_Blocks(new std::list <Vector3i *>)
- , m_Buffer(new std::list <Vector3i *>)
+ , m_Blocks(new BlockList)
+ , m_Buffer(new BlockList)
{
}
@@ -30,19 +30,19 @@ void cSandSimulator::Simulate( float a_Dt )
m_Buffer->clear();
std::swap( m_Blocks, m_Buffer );
- for( std::list<Vector3i *>::iterator itr = m_Buffer->begin(); itr != m_Buffer->end(); ++itr )
+ for( BlockList::iterator itr = m_Buffer->begin(); itr != m_Buffer->end(); ++itr )
{
- Vector3i *Pos = *itr;
- char BlockID = m_World->GetBlock(Pos->x, Pos->y, Pos->z);
+ Vector3i Pos = *itr;
+ char BlockID = m_World->GetBlock(Pos.x, Pos.y, Pos.z);
if(!IsAllowedBlock(BlockID))
continue;
- char BottomBlock = m_World->GetBlock( Pos->x, Pos->y - 1, Pos->z );
+ char BottomBlock = m_World->GetBlock( Pos.x, Pos.y - 1, Pos.z );
if( IsPassable(BottomBlock) )
{
- m_World->SetBlock( Pos->x, Pos->y, Pos->z, E_BLOCK_AIR, 0 );
- m_World->SetBlock( Pos->x, Pos->y - 1, Pos->z, BlockID, 0 );
+ m_World->SetBlock( Pos.x, Pos.y, Pos.z, E_BLOCK_AIR, 0 );
+ m_World->SetBlock( Pos.x, Pos.y - 1, Pos.z, BlockID, 0 );
}
}
@@ -60,13 +60,13 @@ void cSandSimulator::AddBlock(int a_X, int a_Y, int a_Z)
if(!IsAllowedBlock(m_World->GetBlock(a_X, a_Y, a_Z))) //This should save very much time because it doesn´t have to iterate through all blocks
return;
- Vector3i *Block = new Vector3i(a_X, a_Y, a_Z);
+ Vector3i Block(a_X, a_Y, a_Z);
//check for duplicates
- for( std::list<Vector3i *>::iterator itr = m_Blocks->begin(); itr != m_Blocks->end(); ++itr )
+ for( BlockList::iterator itr = m_Blocks->begin(); itr != m_Blocks->end(); ++itr )
{
- Vector3i *Pos = *itr;
- if( Pos->x == a_X && Pos->y == a_Y && Pos->z == a_Z )
+ Vector3i Pos = *itr;
+ if( Pos.x == a_X && Pos.y == a_Y && Pos.z == a_Z )
return;
}