summaryrefslogtreecommitdiffstats
path: root/source/cFireSimulator.cpp
diff options
context:
space:
mode:
authorfaketruth <faketruth@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-02-14 13:29:39 +0100
committerfaketruth <faketruth@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-02-14 13:29:39 +0100
commit504803cb6dbeebcaec969dae9d71f7e78e7bd725 (patch)
tree4aa4934581d0c8427ebeb4247f6bce7aabd4a9d3 /source/cFireSimulator.cpp
parentFixed a (pretty big) memory leak in cSandSimulator (diff)
downloadcuberite-504803cb6dbeebcaec969dae9d71f7e78e7bd725.tar
cuberite-504803cb6dbeebcaec969dae9d71f7e78e7bd725.tar.gz
cuberite-504803cb6dbeebcaec969dae9d71f7e78e7bd725.tar.bz2
cuberite-504803cb6dbeebcaec969dae9d71f7e78e7bd725.tar.lz
cuberite-504803cb6dbeebcaec969dae9d71f7e78e7bd725.tar.xz
cuberite-504803cb6dbeebcaec969dae9d71f7e78e7bd725.tar.zst
cuberite-504803cb6dbeebcaec969dae9d71f7e78e7bd725.zip
Diffstat (limited to '')
-rw-r--r--source/cFireSimulator.cpp29
1 files changed, 14 insertions, 15 deletions
diff --git a/source/cFireSimulator.cpp b/source/cFireSimulator.cpp
index 31ac1e992..1af6deb69 100644
--- a/source/cFireSimulator.cpp
+++ b/source/cFireSimulator.cpp
@@ -9,9 +9,9 @@
cFireSimulator::cFireSimulator( cWorld* a_World )
: cSimulator(a_World)
- , m_Blocks(new std::vector <Vector3i *>)
- , m_Buffer(new std::vector <Vector3i *>)
- , m_BurningBlocks(new std::vector <Vector3i *>)
+ , m_Blocks(new BlockList)
+ , m_Buffer(new BlockList)
+ , m_BurningBlocks(new BlockList)
{
}
@@ -28,20 +28,20 @@ void cFireSimulator::Simulate( float a_Dt )
m_Buffer->clear();
std::swap( m_Blocks, m_Buffer );
- for( std::vector<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;
+ Vector3i Pos = *itr;
- char BlockID = m_World->GetBlock(Pos->x, Pos->y, Pos->z);
+ char BlockID = m_World->GetBlock(Pos.x, Pos.y, Pos.z);
if(!IsAllowedBlock(BlockID)) //Check wheather the block is still burning
continue;
- if(BurnBlockAround(Pos->x, Pos->y, Pos->z)) //Burn single block and if there was one -> next time again
- _AddBlock(Pos->x, Pos->y, Pos->z);
+ if(BurnBlockAround(Pos.x, Pos.y, Pos.z)) //Burn single block and if there was one -> next time again
+ _AddBlock(Pos.x, Pos.y, Pos.z);
else
- if(!IsForeverBurnable(m_World->GetBlock(Pos->x, Pos->y - 1, Pos->z)) && !FiresForever(BlockID))
- m_World->SetBlock(Pos->x, Pos->y, Pos->z, E_BLOCK_AIR, 0);
+ if(!IsForeverBurnable(m_World->GetBlock(Pos.x, Pos.y - 1, Pos.z)) && !FiresForever(BlockID))
+ m_World->SetBlock(Pos.x, Pos.y, Pos.z, E_BLOCK_AIR, 0);
}
@@ -61,10 +61,10 @@ void cFireSimulator::AddBlock(int a_X, int a_Y, int a_Z)
return;
//check for duplicates
- for( std::vector<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;
}
@@ -74,8 +74,7 @@ void cFireSimulator::AddBlock(int a_X, int a_Y, int a_Z)
void cFireSimulator::_AddBlock(int a_X, int a_Y, int a_Z)
{
- Vector3i *Block = new Vector3i(a_X, a_Y, a_Z);
- m_Blocks->push_back(Block);
+ m_Blocks->push_back( Vector3i(a_X, a_Y, a_Z) );
}