summaryrefslogtreecommitdiffstats
path: root/src/Map.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Map.cpp')
-rw-r--r--src/Map.cpp36
1 files changed, 20 insertions, 16 deletions
diff --git a/src/Map.cpp b/src/Map.cpp
index 3691d0ab0..7c63d8ceb 100644
--- a/src/Map.cpp
+++ b/src/Map.cpp
@@ -16,14 +16,15 @@
-cMap::cMap(unsigned int a_ID, cWorld * a_World):
+cMap::cMap(unsigned int a_ID, cWorld * a_World) :
m_ID(a_ID),
m_Width(cChunkDef::Width * 8),
m_Height(cChunkDef::Width * 8),
m_Scale(3),
m_CenterX(0),
m_CenterZ(0),
- m_Dirty(false), // This constructor is for an empty map object which will be filled by the caller with the correct values - it does not need saving.
+ m_Dirty(false), // This constructor is for an empty map object which will be filled by the caller with the correct
+ // values - it does not need saving.
m_World(a_World),
m_Name(fmt::format(FMT_STRING("map_{}"), m_ID))
{
@@ -34,7 +35,7 @@ cMap::cMap(unsigned int a_ID, cWorld * a_World):
-cMap::cMap(unsigned int a_ID, int a_CenterX, int a_CenterZ, cWorld * a_World, unsigned int a_Scale):
+cMap::cMap(unsigned int a_ID, int a_CenterX, int a_CenterZ, cWorld * a_World, unsigned int a_Scale) :
m_ID(a_ID),
m_Width(cChunkDef::Width * 8),
m_Height(cChunkDef::Width * 8),
@@ -73,8 +74,8 @@ void cMap::UpdateRadius(int a_PixelX, int a_PixelZ, unsigned int a_Radius)
unsigned int StartX = static_cast<unsigned int>(Clamp(a_PixelX - PixelRadius, 0, static_cast<int>(m_Width)));
unsigned int StartZ = static_cast<unsigned int>(Clamp(a_PixelZ - PixelRadius, 0, static_cast<int>(m_Height)));
- unsigned int EndX = static_cast<unsigned int>(Clamp(a_PixelX + PixelRadius, 0, static_cast<int>(m_Width)));
- unsigned int EndZ = static_cast<unsigned int>(Clamp(a_PixelZ + PixelRadius, 0, static_cast<int>(m_Height)));
+ unsigned int EndX = static_cast<unsigned int>(Clamp(a_PixelX + PixelRadius, 0, static_cast<int>(m_Width)));
+ unsigned int EndZ = static_cast<unsigned int>(Clamp(a_PixelZ + PixelRadius, 0, static_cast<int>(m_Height)));
for (unsigned int X = StartX; X < EndX; ++X)
{
@@ -99,7 +100,7 @@ void cMap::UpdateRadius(cPlayer & a_Player, unsigned int a_Radius)
{
int PixelWidth = static_cast<int>(GetPixelWidth());
- int PixelX = static_cast<int>(a_Player.GetPosX() - m_CenterX) / PixelWidth + static_cast<int>(m_Width / 2);
+ int PixelX = static_cast<int>(a_Player.GetPosX() - m_CenterX) / PixelWidth + static_cast<int>(m_Width / 2);
int PixelZ = static_cast<int>(a_Player.GetPosZ() - m_CenterZ) / PixelWidth + static_cast<int>(m_Height / 2);
UpdateRadius(PixelX, PixelZ, a_Radius);
@@ -111,7 +112,7 @@ void cMap::UpdateRadius(cPlayer & a_Player, unsigned int a_Radius)
bool cMap::UpdatePixel(unsigned int a_X, unsigned int a_Z)
{
- int BlockX = m_CenterX + static_cast<int>((a_X - m_Width / 2) * GetPixelWidth());
+ int BlockX = m_CenterX + static_cast<int>((a_X - m_Width / 2) * GetPixelWidth());
int BlockZ = m_CenterZ + static_cast<int>((a_Z - m_Height / 2) * GetPixelWidth());
int ChunkX, ChunkZ;
@@ -123,7 +124,10 @@ bool cMap::UpdatePixel(unsigned int a_X, unsigned int a_Z)
ASSERT(m_World != nullptr);
ColorID PixelData;
- m_World->DoWithChunk(ChunkX, ChunkZ, [&](cChunk & a_Chunk)
+ m_World->DoWithChunk(
+ ChunkX,
+ ChunkZ,
+ [&](cChunk & a_Chunk)
{
if (GetDimension() == dimNether)
{
@@ -132,7 +136,7 @@ bool cMap::UpdatePixel(unsigned int a_X, unsigned int a_Z)
return false;
}
- static const std::array<unsigned char, 4> BrightnessID = { { 3, 0, 1, 2 } }; // Darkest to lightest
+ static const std::array<unsigned char, 4> BrightnessID = {{3, 0, 1, 2}}; // Darkest to lightest
BLOCKTYPE TargetBlock;
NIBBLETYPE TargetMeta;
@@ -151,7 +155,9 @@ bool cMap::UpdatePixel(unsigned int a_X, unsigned int a_Z)
}
else if (ColourID == 0)
{
- while (((--Height) != -1) && ((ColourID = cBlockHandler::For(a_Chunk.GetBlock(RelX, Height, RelZ)).GetMapBaseColourID(a_Chunk.GetMeta(RelX, Height, RelZ))) == 0))
+ while (((--Height) != -1) &&
+ ((ColourID = cBlockHandler::For(a_Chunk.GetBlock(RelX, Height, RelZ))
+ .GetMapBaseColourID(a_Chunk.GetMeta(RelX, Height, RelZ))) == 0))
{
continue;
}
@@ -159,7 +165,10 @@ bool cMap::UpdatePixel(unsigned int a_X, unsigned int a_Z)
// Multiply base color ID by 4 and add brightness ID
const int BrightnessIDSize = static_cast<int>(BrightnessID.size());
- PixelData = ColourID * 4 + BrightnessID[static_cast<size_t>(Clamp<int>((BrightnessIDSize * Height) / ChunkHeight, 0, BrightnessIDSize - 1))];
+ PixelData = ColourID * 4 +
+ BrightnessID[static_cast<size_t>(
+ Clamp<int>((BrightnessIDSize * Height) / ChunkHeight, 0, BrightnessIDSize - 1)
+ )];
return false;
}
);
@@ -333,8 +342,3 @@ unsigned int cMap::GetPixelWidth(void) const
{
return static_cast<unsigned int>(pow(2.0, static_cast<double>(m_Scale)));
}
-
-
-
-
-