summaryrefslogtreecommitdiffstats
path: root/src/Simulator/FireSimulator.cpp
diff options
context:
space:
mode:
authordaniel0916 <theschokolps@gmail.com>2014-04-07 20:12:17 +0200
committerdaniel0916 <theschokolps@gmail.com>2014-04-07 20:12:17 +0200
commit2e9754ac1cf0537c12ab7974cf55c451c0724540 (patch)
tree713c5b8c8f22f77893b30b9c8cefca4a7c491483 /src/Simulator/FireSimulator.cpp
parentFixed merge conflict (diff)
parentFixed some more minor issues with the redstone simulator. (diff)
downloadcuberite-2e9754ac1cf0537c12ab7974cf55c451c0724540.tar
cuberite-2e9754ac1cf0537c12ab7974cf55c451c0724540.tar.gz
cuberite-2e9754ac1cf0537c12ab7974cf55c451c0724540.tar.bz2
cuberite-2e9754ac1cf0537c12ab7974cf55c451c0724540.tar.lz
cuberite-2e9754ac1cf0537c12ab7974cf55c451c0724540.tar.xz
cuberite-2e9754ac1cf0537c12ab7974cf55c451c0724540.tar.zst
cuberite-2e9754ac1cf0537c12ab7974cf55c451c0724540.zip
Diffstat (limited to 'src/Simulator/FireSimulator.cpp')
-rw-r--r--src/Simulator/FireSimulator.cpp56
1 files changed, 45 insertions, 11 deletions
diff --git a/src/Simulator/FireSimulator.cpp b/src/Simulator/FireSimulator.cpp
index d7c5ab3b4..470dfc791 100644
--- a/src/Simulator/FireSimulator.cpp
+++ b/src/Simulator/FireSimulator.cpp
@@ -6,6 +6,8 @@
#include "../BlockID.h"
#include "../Defines.h"
#include "../Chunk.h"
+#include "Root.h"
+#include "../Bindings/PluginManager.h"
@@ -162,13 +164,27 @@ bool cFireSimulator::IsFuel(BLOCKTYPE a_BlockType)
switch (a_BlockType)
{
case E_BLOCK_PLANKS:
+ case E_BLOCK_DOUBLE_WOODEN_SLAB:
+ case E_BLOCK_WOODEN_SLAB:
+ case E_BLOCK_WOODEN_STAIRS:
+ case E_BLOCK_SPRUCE_WOOD_STAIRS:
+ case E_BLOCK_BIRCH_WOOD_STAIRS:
+ case E_BLOCK_JUNGLE_WOOD_STAIRS:
case E_BLOCK_LEAVES:
+ case E_BLOCK_NEW_LEAVES:
case E_BLOCK_LOG:
+ case E_BLOCK_NEW_LOG:
case E_BLOCK_WOOL:
case E_BLOCK_BOOKCASE:
case E_BLOCK_FENCE:
case E_BLOCK_TNT:
case E_BLOCK_VINES:
+ case E_BLOCK_HAY_BALE:
+ case E_BLOCK_TALL_GRASS:
+ case E_BLOCK_BIG_FLOWER:
+ case E_BLOCK_DANDELION:
+ case E_BLOCK_FLOWER:
+ case E_BLOCK_CARPET:
{
return true;
}
@@ -238,7 +254,7 @@ int cFireSimulator::GetBurnStepTime(cChunk * a_Chunk, int a_RelX, int a_RelY, in
{
return m_BurnStepTimeFuel;
}
- IsBlockBelowSolid = g_BlockIsSolid[BlockBelow];
+ IsBlockBelowSolid = cBlockInfo::IsSolid(BlockBelow);
}
for (size_t i = 0; i < ARRAYCOUNT(gCrossCoords); i++)
@@ -301,9 +317,15 @@ void cFireSimulator::TrySpreadFire(cChunk * a_Chunk, int a_RelX, int a_RelY, int
*/
if (CanStartFireInBlock(a_Chunk, x, y, z))
{
- FLOG("FS: Starting new fire at {%d, %d, %d}.",
- x + a_Chunk->GetPosX() * cChunkDef::Width, y, z + a_Chunk->GetPosZ() * cChunkDef::Width
- );
+ int a_PosX = x + a_Chunk->GetPosX() * cChunkDef::Width;
+ int a_PosZ = z + a_Chunk->GetPosZ() * cChunkDef::Width;
+
+ if (cRoot::Get()->GetPluginManager()->CallHookBlockSpread(&m_World, a_PosX, y, a_PosZ, ssFireSpread))
+ {
+ return;
+ }
+
+ FLOG("FS: Starting new fire at {%d, %d, %d}.", a_PosX, y, a_PosZ);
a_Chunk->UnboundedRelSetBlock(x, y, z, E_BLOCK_FIRE, 0);
}
} // for y
@@ -320,21 +342,33 @@ void cFireSimulator::RemoveFuelNeighbors(cChunk * a_Chunk, int a_RelX, int a_Rel
for (size_t i = 0; i < ARRAYCOUNT(gNeighborCoords); i++)
{
BLOCKTYPE BlockType;
- NIBBLETYPE BlockMeta;
- if (!a_Chunk->UnboundedRelGetBlock(a_RelX + gNeighborCoords[i].x, a_RelY + gNeighborCoords[i].y, a_RelZ + gNeighborCoords[i].z, BlockType, BlockMeta))
+ int X = a_RelX + gNeighborCoords[i].x;
+ int Z = a_RelZ + gNeighborCoords[i].z;
+
+ cChunkPtr Neighbour = a_Chunk->GetRelNeighborChunkAdjustCoords(X, Z);
+ if (Neighbour == NULL)
{
- // Neighbor not accessible, ignore it
continue;
}
+ BlockType = Neighbour->GetBlock(X, a_RelY + gCrossCoords[i].y, Z);
+
if (!IsFuel(BlockType))
{
continue;
}
+
+ if (BlockType == E_BLOCK_TNT)
+ {
+ int AbsX = X + Neighbour->GetPosX() * cChunkDef::Width;
+ int AbsZ = Z + Neighbour->GetPosZ() * cChunkDef::Width;
+
+ m_World.SpawnPrimedTNT(AbsX, a_RelY + gNeighborCoords[i].y, AbsZ, 0);
+ Neighbour->SetBlock(X, a_RelY + gNeighborCoords[i].y, Z, E_BLOCK_AIR, 0);
+ return;
+ }
+
bool ShouldReplaceFuel = (m_World.GetTickRandomNumber(MAX_CHANCE_REPLACE_FUEL) < m_ReplaceFuelChance);
- a_Chunk->UnboundedRelSetBlock(
- a_RelX + gNeighborCoords[i].x, a_RelY + gNeighborCoords[i].y, a_RelZ + gNeighborCoords[i].z,
- ShouldReplaceFuel ? E_BLOCK_FIRE : E_BLOCK_AIR, 0
- );
+ Neighbour->SetBlock(X, a_RelY + gNeighborCoords[i].y, Z, ShouldReplaceFuel ? E_BLOCK_FIRE : E_BLOCK_AIR, 0);
} // for i - Coords[]
}