summaryrefslogtreecommitdiffstats
path: root/src/Simulator
diff options
context:
space:
mode:
authorpeterbell10 <peterbell10@live.co.uk>2018-09-24 22:33:39 +0200
committerAlexander Harkness <me@bearbin.net>2018-09-24 22:33:39 +0200
commit4727ed20846bb3d1a9eabb27aaaa9c5524129556 (patch)
treed6206a51db95a15fd3dfadb9691c868fc6bd8bd1 /src/Simulator
parentAdd BurnsInDaylight to Lua API and Monsters.ini (#4295) (diff)
downloadcuberite-4727ed20846bb3d1a9eabb27aaaa9c5524129556.tar
cuberite-4727ed20846bb3d1a9eabb27aaaa9c5524129556.tar.gz
cuberite-4727ed20846bb3d1a9eabb27aaaa9c5524129556.tar.bz2
cuberite-4727ed20846bb3d1a9eabb27aaaa9c5524129556.tar.lz
cuberite-4727ed20846bb3d1a9eabb27aaaa9c5524129556.tar.xz
cuberite-4727ed20846bb3d1a9eabb27aaaa9c5524129556.tar.zst
cuberite-4727ed20846bb3d1a9eabb27aaaa9c5524129556.zip
Diffstat (limited to 'src/Simulator')
-rw-r--r--src/Simulator/FireSimulator.cpp24
-rw-r--r--src/Simulator/FloodyFluidSimulator.cpp47
-rw-r--r--src/Simulator/SandSimulator.cpp6
3 files changed, 36 insertions, 41 deletions
diff --git a/src/Simulator/FireSimulator.cpp b/src/Simulator/FireSimulator.cpp
index df2456455..9a00d00a8 100644
--- a/src/Simulator/FireSimulator.cpp
+++ b/src/Simulator/FireSimulator.cpp
@@ -14,9 +14,9 @@
// Easy switch for turning on debugging logging:
#if 0
- #define FIRE_LOG LOGD
+ #define FIRE_FLOG FLOGD
#else
- #define FIRE_LOG(...)
+ #define FIRE_FLOG(...)
#endif
@@ -111,9 +111,7 @@ void cFireSimulator::SimulateChunk(std::chrono::milliseconds a_Dt, int a_ChunkX,
if (!IsAllowedBlock(BlockType))
{
// The block is no longer eligible (not a fire block anymore; a player probably placed a block over the fire)
- FIRE_LOG("FS: Removing block {%d, %d, %d}",
- AbsPos.x, AbsPos.y, AbsPos.z
- );
+ FIRE_FLOG("FS: Removing block {0}", AbsPos);
itr = Data.erase(itr);
continue;
}
@@ -148,16 +146,16 @@ void cFireSimulator::SimulateChunk(std::chrono::milliseconds a_Dt, int a_ChunkX,
}
/*
- FIRE_LOG("FS: Fire at {%d, %d, %d} is stepping",
- itr->x + a_ChunkX * cChunkDef::Width, itr->y, itr->z + a_ChunkZ * cChunkDef::Width
+ FIRE_FLOG("FS: Fire at {0} is stepping",
+ a_Chunk->PositionToWorldPosition(itr->x, itr->y, itr->z)
);
*/
// Has the fire burnt out?
if (BlockMeta == 0x0f)
{
// The fire burnt out completely
- FIRE_LOG("FS: Fire at {%d, %d, %d} burnt out, removing the fire block",
- itr->x + a_ChunkX * cChunkDef::Width, itr->y, itr->z + a_ChunkZ * cChunkDef::Width
+ FIRE_FLOG("FS: Fire at {0} burnt out, removing the fire block",
+ a_Chunk->PositionToWorldPosition({itr->x, itr->y, itr->z})
);
a_Chunk->SetBlock(x, y, z, E_BLOCK_AIR, 0);
RemoveFuelNeighbors(a_Chunk, x, y, z);
@@ -272,7 +270,7 @@ void cFireSimulator::AddBlock(Vector3i a_Block, cChunk * a_Chunk)
}
} // for itr - ChunkData[]
- FIRE_LOG("FS: Adding block {%d, %d, %d}", a_Block.x, a_Block.y, a_Block.z);
+ FIRE_FLOG("FS: Adding block {0}", a_Block);
ChunkData.push_back(cCoordWithInt(RelX, a_Block.y, RelZ, 100));
}
@@ -352,8 +350,8 @@ void cFireSimulator::TrySpreadFire(cChunk * a_Chunk, int a_RelX, int a_RelY, int
// Start the fire in the neighbor {x, y, z}
/*
- FIRE_LOG("FS: Trying to start fire at {%d, %d, %d}.",
- x + a_Chunk->GetPosX() * cChunkDef::Width, y, z + a_Chunk->GetPosZ() * cChunkDef::Width
+ FIRE_LOG("FS: Trying to start fire at {0}.",
+ a_Chunk->PositionToWorldPosition(x, y, z)
);
*/
if (CanStartFireInBlock(a_Chunk, x, y, z))
@@ -366,7 +364,7 @@ void cFireSimulator::TrySpreadFire(cChunk * a_Chunk, int a_RelX, int a_RelY, int
return;
}
- FIRE_LOG("FS: Starting new fire at {%d, %d, %d}.", a_PosX, y, a_PosZ);
+ FIRE_FLOG("FS: Starting new fire at {0}.", Vector3i{a_PosX, y, a_PosZ});
a_Chunk->UnboundedRelSetBlock(x, y, z, E_BLOCK_FIRE, 0);
}
} // for y
diff --git a/src/Simulator/FloodyFluidSimulator.cpp b/src/Simulator/FloodyFluidSimulator.cpp
index 8d5a3a8ae..7066dc016 100644
--- a/src/Simulator/FloodyFluidSimulator.cpp
+++ b/src/Simulator/FloodyFluidSimulator.cpp
@@ -20,9 +20,9 @@
// Enable or disable detailed logging
#if 0
- #define FLUID_LOG LOGD
+ #define FLUID_FLOG FLOGD
#else
- #define FLUID_LOG(...)
+ #define FLUID_FLOG(...)
#endif
@@ -49,8 +49,8 @@ cFloodyFluidSimulator::cFloodyFluidSimulator(
void cFloodyFluidSimulator::SimulateBlock(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ)
{
- FLUID_LOG("Simulating block {%d, %d, %d}: block %d, meta %d",
- a_Chunk->GetPosX() * cChunkDef::Width + a_RelX, a_RelY, a_Chunk->GetPosZ() * cChunkDef::Width + a_RelZ,
+ FLUID_FLOG("Simulating block {0}: block {1}, meta {2}",
+ a_Chunk->PositionToWorldPosition(a_RelX, a_RelY, a_RelZ),
a_Chunk->GetBlock(a_RelX, a_RelY, a_RelZ),
a_Chunk->GetMeta(a_RelX, a_RelY, a_RelZ)
);
@@ -61,7 +61,7 @@ void cFloodyFluidSimulator::SimulateBlock(cChunk * a_Chunk, int a_RelX, int a_Re
if (!IsAnyFluidBlock(MyBlock))
{
// Can happen - if a block is scheduled for simulating and gets replaced in the meantime.
- FLUID_LOG(" BadBlockType exit");
+ FLUID_FLOG(" BadBlockType exit");
return;
}
@@ -79,7 +79,7 @@ void cFloodyFluidSimulator::SimulateBlock(cChunk * a_Chunk, int a_RelX, int a_Re
{
// Has no tributary, has been decreased (in CheckTributaries()),
// no more processing needed (neighbors have been scheduled by the decrease)
- FLUID_LOG(" CheckTributaries exit");
+ FLUID_FLOG(" CheckTributaries exit");
return;
}
}
@@ -154,7 +154,7 @@ bool cFloodyFluidSimulator::CheckTributaries(cChunk * a_Chunk, int a_RelX, int a
if (IsAnyFluidBlock(a_Chunk->GetBlock(a_RelX, a_RelY + 1, a_RelZ)))
{
// This block is fed from above, no more processing needed
- FLUID_LOG(" Fed from above");
+ FLUID_FLOG(" Fed from above");
return false;
}
}
@@ -180,10 +180,8 @@ bool cFloodyFluidSimulator::CheckTributaries(cChunk * a_Chunk, int a_RelX, int a
if (IsAllowedBlock(BlockType) && IsHigherMeta(BlockMeta, a_MyMeta))
{
// This block is fed, no more processing needed
- FLUID_LOG(" Fed from {%d, %d, %d}, type %d, meta %d",
- a_Chunk->GetPosX() * cChunkDef::Width + a_RelX + Coords[i].x,
- a_RelY,
- a_Chunk->GetPosZ() * cChunkDef::Width + a_RelZ + Coords[i].z,
+ FLUID_FLOG(" Fed from {0}, type {1}, meta {2}",
+ a_Chunk->PositionToWorldPosition(a_RelX+ Coords[i].x, a_RelY, a_RelZ + Coords[i].z),
BlockType, BlockMeta
);
return false;
@@ -194,7 +192,7 @@ bool cFloodyFluidSimulator::CheckTributaries(cChunk * a_Chunk, int a_RelX, int a
// Block is not fed, decrease by m_Falloff levels:
if (a_MyMeta >= 8)
{
- FLUID_LOG(" Not fed and downwards, turning into non-downwards meta %d", m_Falloff);
+ FLUID_FLOG(" Not fed and downwards, turning into non-downwards meta {0}", m_Falloff);
a_Chunk->SetBlock(a_RelX, a_RelY, a_RelZ, m_StationaryFluidBlock, m_Falloff);
}
else
@@ -202,12 +200,12 @@ bool cFloodyFluidSimulator::CheckTributaries(cChunk * a_Chunk, int a_RelX, int a
a_MyMeta += m_Falloff;
if (a_MyMeta < 8)
{
- FLUID_LOG(" Not fed, decreasing from %d to %d", a_MyMeta - m_Falloff, a_MyMeta);
+ FLUID_FLOG(" Not fed, decreasing from {0} to {1}", a_MyMeta - m_Falloff, a_MyMeta);
a_Chunk->SetBlock(a_RelX, a_RelY, a_RelZ, m_StationaryFluidBlock, a_MyMeta);
}
else
{
- FLUID_LOG(" Not fed, meta %d, erasing altogether", a_MyMeta);
+ FLUID_FLOG(" Not fed, meta {0}, erasing altogether", a_MyMeta);
a_Chunk->SetBlock(a_RelX, a_RelY, a_RelZ, E_BLOCK_AIR, 0);
}
}
@@ -253,9 +251,8 @@ void cFloodyFluidSimulator::SpreadToNeighbor(cChunk * a_NearChunk, int a_RelX, i
{
// Lava flowing into water, change to stone / cobblestone based on direction:
BLOCKTYPE NewBlock = (a_NewMeta == 8) ? E_BLOCK_STONE : E_BLOCK_COBBLESTONE;
- FLUID_LOG(" Lava flowing into water, turning water at rel {%d, %d, %d} into stone",
- a_RelX, a_RelY, a_RelZ,
- ItemTypeToString(NewBlock).c_str()
+ FLUID_FLOG(" Lava flowing into water, turning water at rel {0} into {1}",
+ Vector3i{a_RelX, a_RelY, a_RelZ}, ItemTypeToString(NewBlock)
);
a_NearChunk->SetBlock(a_RelX, a_RelY, a_RelZ, NewBlock, 0);
@@ -274,8 +271,8 @@ void cFloodyFluidSimulator::SpreadToNeighbor(cChunk * a_NearChunk, int a_RelX, i
{
// Water flowing into lava, change to cobblestone / obsidian based on dest block:
BLOCKTYPE NewBlock = (BlockMeta == 0) ? E_BLOCK_OBSIDIAN : E_BLOCK_COBBLESTONE;
- FLUID_LOG(" Water flowing into lava, turning lava at rel {%d, %d, %d} into %s",
- a_RelX, a_RelY, a_RelZ, ItemTypeToString(NewBlock).c_str()
+ FLUID_FLOG(" Water flowing into lava, turning lava at rel {0} into {1}",
+ Vector3i{a_RelX, a_RelY, a_RelZ}, ItemTypeToString(NewBlock)
);
a_NearChunk->SetBlock(a_RelX, a_RelY, a_RelZ, NewBlock, 0);
@@ -320,7 +317,7 @@ void cFloodyFluidSimulator::SpreadToNeighbor(cChunk * a_NearChunk, int a_RelX, i
} // if (CanWashAway)
// Spread:
- FLUID_LOG(" Spreading to {%d, %d, %d} with meta %d", BlockX, a_RelY, BlockZ, a_NewMeta);
+ FLUID_FLOG(" Spreading to {0} with meta {1}", Vector3i{BlockX, a_RelY, BlockZ}, a_NewMeta);
a_NearChunk->SetBlock(a_RelX, a_RelY, a_RelZ, m_FluidBlock, a_NewMeta);
m_World.GetSimulatorManager()->WakeUp({BlockX, a_RelY, BlockZ}, a_NearChunk);
@@ -333,7 +330,7 @@ void cFloodyFluidSimulator::SpreadToNeighbor(cChunk * a_NearChunk, int a_RelX, i
bool cFloodyFluidSimulator::CheckNeighborsForSource(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ)
{
- FLUID_LOG(" Checking neighbors for source creation");
+ FLUID_FLOG(" Checking neighbors for source creation");
static const Vector3i NeighborCoords[] =
{
@@ -356,21 +353,21 @@ bool cFloodyFluidSimulator::CheckNeighborsForSource(cChunk * a_Chunk, int a_RelX
// Neighbor not available, skip it
continue;
}
- // FLUID_LOG(" Neighbor at {%d, %d, %d}: %s", x, y, z, ItemToFullString(cItem(BlockType, 1, BlockMeta)).c_str());
+ // FLUID_FLOG(" Neighbor at {0}: {1}", Vector3i{x, y, z}, ItemToFullString(cItem(BlockType, 1, BlockMeta)));
if ((BlockMeta == 0) && IsAnyFluidBlock(BlockType))
{
NumNeeded--;
- // FLUID_LOG(" Found a neighbor source at {%d, %d, %d}, NumNeeded := %d", x, y, z, NumNeeded);
+ // FLUID_FLOG(" Found a neighbor source at {0}, NumNeeded := {1}", Vector3i{x, y, z}, NumNeeded);
if (NumNeeded == 0)
{
// Found enough, turn into a source and bail out
- // FLUID_LOG(" Found enough neighbor sources, turning into a source");
+ // FLUID_FLOG(" Found enough neighbor sources, turning into a source");
a_Chunk->SetBlock(a_RelX, a_RelY, a_RelZ, m_FluidBlock, 0);
return true;
}
}
}
- // FLUID_LOG(" Not enough neighbors for turning into a source, NumNeeded = %d", NumNeeded);
+ // FLUID_FLOG(" Not enough neighbors for turning into a source, NumNeeded = {0}", NumNeeded);
return false;
}
diff --git a/src/Simulator/SandSimulator.cpp b/src/Simulator/SandSimulator.cpp
index 53dc3f94d..a75ea2d11 100644
--- a/src/Simulator/SandSimulator.cpp
+++ b/src/Simulator/SandSimulator.cpp
@@ -55,9 +55,9 @@ void cSandSimulator::SimulateChunk(std::chrono::milliseconds a_Dt, int a_ChunkX,
Pos.y = itr->y;
Pos.z = itr->z + BaseZ;
/*
- LOGD(
- "Creating a falling block at {%d, %d, %d} of type %s, block below: %s",
- Pos.x, Pos.y, Pos.z, ItemTypeToString(BlockType).c_str(), ItemTypeToString(BlockBelow).c_str()
+ FLOGD(
+ "Creating a falling block at {0} of type {1}, block below: {2}",
+ Pos, ItemTypeToString(BlockType), ItemTypeToString(BlockBelow)
);
*/