Add a formatting function for Vector3 (#4282)
* Vector3: Add custom fmt compatible formatter. * cLuaState: Add fmt version of ApiParamError * Use vector formatting in manual bindings * Always log vectors with FLOG
This commit is contained in:
committed by
Alexander Harkness
parent
73689024f0
commit
4727ed2084
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user