From f5466a4cb368a1554362deeb5b0f966cf5613e80 Mon Sep 17 00:00:00 2001 From: "lapayo94@gmail.com" Date: Thu, 29 Dec 2011 00:44:19 +0000 Subject: - water slacks fire now - Bug which caused lava to disappear is fixed git-svn-id: http://mc-server.googlecode.com/svn/trunk@152 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/cFireSimulator.cpp | 11 +++++++++-- source/cFireSimulator.h | 3 ++- source/cFluidSimulator.cpp | 8 ++++++++ source/cFluidSimulator.h | 2 +- source/cLavaSimulator.cpp | 6 ------ source/cLavaSimulator.h | 1 - source/cWaterSimulator.cpp | 5 ----- source/cWaterSimulator.h | 1 - 8 files changed, 20 insertions(+), 17 deletions(-) diff --git a/source/cFireSimulator.cpp b/source/cFireSimulator.cpp index 180ac9744..10dc8f589 100644 --- a/source/cFireSimulator.cpp +++ b/source/cFireSimulator.cpp @@ -30,13 +30,15 @@ void cFireSimulator::Simulate( float a_Dt ) { Vector3i *Pos = *itr; - if(!IsAllowedBlock(m_World->GetBlock(Pos->x, Pos->y, Pos->z))) //Check wheather the block is still burning + 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); else - if(!IsForeverBurnable(m_World->GetBlock(Pos->x, Pos->y - 1, Pos->z))) + 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); } @@ -91,6 +93,11 @@ bool cFireSimulator::IsBurnable( char a_BlockID ) || a_BlockID == E_BLOCK_TNT; } +bool cFireSimulator::FiresForever( char a_BlockID ) +{ + return a_BlockID != E_BLOCK_FIRE; +} + bool cFireSimulator::BurnBlockAround(int a_X, int a_Y, int a_Z) { return BurnBlock(a_X + 1, a_Y, a_Z) diff --git a/source/cFireSimulator.h b/source/cFireSimulator.h index b6ac627fb..b42131ff3 100644 --- a/source/cFireSimulator.h +++ b/source/cFireSimulator.h @@ -14,9 +14,10 @@ public: virtual void Simulate( float a_Dt ); virtual inline bool IsAllowedBlock( char a_BlockID ); - virtual inline bool IsBurnable( char a_BlockID ); + virtual inline bool IsBurnable( char a_BlockID ); virtual inline bool IsForeverBurnable( char a_BlockID ); + virtual inline bool FiresForever( char a_BlockID ); protected: virtual void AddBlock(int a_X, int a_Y, int a_Z); diff --git a/source/cFluidSimulator.cpp b/source/cFluidSimulator.cpp index 47cf0be19..cd2d1fae2 100644 --- a/source/cFluidSimulator.cpp +++ b/source/cFluidSimulator.cpp @@ -218,6 +218,14 @@ void cFluidSimulator::Simulate( float a_Dt ) } } + +bool cFluidSimulator::IsPassableForFluid(char a_BlockID) +{ + return a_BlockID == E_BLOCK_AIR + || a_BlockID == E_BLOCK_FIRE + || IsAllowedBlock(a_BlockID); +} + //TODO Not working very well yet :s Direction cFluidSimulator::GetFlowingDirection(int a_X, int a_Y, int a_Z, bool a_Over) { diff --git a/source/cFluidSimulator.h b/source/cFluidSimulator.h index 1b4cd0d55..73c76762e 100644 --- a/source/cFluidSimulator.h +++ b/source/cFluidSimulator.h @@ -29,7 +29,7 @@ public: Direction GetFlowingDirection(int a_X, int a_Y, int a_Z, bool a_Over = true); virtual inline bool IsAllowedBlock( char a_BlockID ) = 0; - virtual inline bool IsPassableForFluid( char a_BlockID ) = 0; + virtual inline bool IsPassableForFluid( char a_BlockID ); protected: virtual void AddBlock( int a_X, int a_Y, int a_Z); diff --git a/source/cLavaSimulator.cpp b/source/cLavaSimulator.cpp index 35a498ee7..fbd1734ab 100644 --- a/source/cLavaSimulator.cpp +++ b/source/cLavaSimulator.cpp @@ -14,10 +14,4 @@ cLavaSimulator::cLavaSimulator(cWorld *a_World) bool cLavaSimulator::IsAllowedBlock(char a_BlockID) { return IsBlockLava(a_BlockID); -} - - -bool cLavaSimulator::IsPassableForFluid(char a_BlockID) -{ - return ( a_BlockID == E_BLOCK_AIR || IsAllowedBlock(a_BlockID) ); } \ No newline at end of file diff --git a/source/cLavaSimulator.h b/source/cLavaSimulator.h index cb3c743be..abcad6fc6 100644 --- a/source/cLavaSimulator.h +++ b/source/cLavaSimulator.h @@ -7,6 +7,5 @@ public: cLavaSimulator( cWorld* a_World ); virtual inline bool IsAllowedBlock( char a_BlockID ); - virtual inline bool IsPassableForFluid( char a_BlockID ); }; \ No newline at end of file diff --git a/source/cWaterSimulator.cpp b/source/cWaterSimulator.cpp index 372328914..595ba556f 100644 --- a/source/cWaterSimulator.cpp +++ b/source/cWaterSimulator.cpp @@ -16,8 +16,3 @@ bool cWaterSimulator::IsAllowedBlock(char a_BlockID) return IsBlockWater(a_BlockID); } - -bool cWaterSimulator::IsPassableForFluid(char a_BlockID) -{ - return ( a_BlockID == E_BLOCK_AIR || IsAllowedBlock(a_BlockID) ); -} \ No newline at end of file diff --git a/source/cWaterSimulator.h b/source/cWaterSimulator.h index c4eab8d80..d08902e44 100644 --- a/source/cWaterSimulator.h +++ b/source/cWaterSimulator.h @@ -7,6 +7,5 @@ public: cWaterSimulator( cWorld* a_World ); virtual inline bool IsAllowedBlock( char a_BlockID ); - virtual inline bool IsPassableForFluid( char a_BlockID ); }; \ No newline at end of file -- cgit v1.2.3