diff options
Diffstat (limited to 'src/BlockArea.cpp')
-rw-r--r-- | src/BlockArea.cpp | 107 |
1 files changed, 101 insertions, 6 deletions
diff --git a/src/BlockArea.cpp b/src/BlockArea.cpp index 194e2d68a..d07ef747a 100644 --- a/src/BlockArea.cpp +++ b/src/BlockArea.cpp @@ -8,6 +8,7 @@ #include "BlockArea.h" #include "OSSupport/GZipFile.h" #include "Blocks/BlockHandler.h" +#include "Cuboid.h" @@ -264,6 +265,15 @@ void cBlockArea::SetOrigin(int a_OriginX, int a_OriginY, int a_OriginZ) +void cBlockArea::SetOrigin(const Vector3i & a_Origin) +{ + SetOrigin(a_Origin.x, a_Origin.y, a_Origin.z); +} + + + + + bool cBlockArea::Read(cForEachChunkProvider * a_ForEachChunkProvider, int a_MinBlockX, int a_MaxBlockX, int a_MinBlockY, int a_MaxBlockY, int a_MinBlockZ, int a_MaxBlockZ, int a_DataTypes) { // Normalize the coords: @@ -338,6 +348,36 @@ bool cBlockArea::Read(cForEachChunkProvider * a_ForEachChunkProvider, int a_MinB +bool cBlockArea::Read(cForEachChunkProvider * a_ForEachChunkProvider, const cCuboid & a_Bounds, int a_DataTypes) +{ + return Read( + a_ForEachChunkProvider, + a_Bounds.p1.x, a_Bounds.p2.x, + a_Bounds.p1.y, a_Bounds.p2.y, + a_Bounds.p1.z, a_Bounds.p2.z, + a_DataTypes + ); +} + + + + + +bool cBlockArea::Read(cForEachChunkProvider * a_ForEachChunkProvider, const Vector3i & a_Point1, const Vector3i & a_Point2, int a_DataTypes) +{ + return Read( + a_ForEachChunkProvider, + a_Point1.x, a_Point2.x, + a_Point1.y, a_Point2.y, + a_Point1.z, a_Point2.z, + a_DataTypes + ); +} + + + + + bool cBlockArea::Write(cForEachChunkProvider * a_ForEachChunkProvider, int a_MinBlockX, int a_MinBlockY, int a_MinBlockZ, int a_DataTypes) { ASSERT((a_DataTypes & GetDataTypes()) == a_DataTypes); // Are you requesting only the data that I have? @@ -362,6 +402,19 @@ bool cBlockArea::Write(cForEachChunkProvider * a_ForEachChunkProvider, int a_Min +bool cBlockArea::Write(cForEachChunkProvider * a_ForEachChunkProvider, const Vector3i & a_MinCoords, int a_DataTypes) +{ + return Write( + a_ForEachChunkProvider, + a_MinCoords.x, a_MinCoords.y, a_MinCoords.z, + a_DataTypes + ); +} + + + + + void cBlockArea::CopyTo(cBlockArea & a_Into) const { if (&a_Into == this) @@ -643,6 +696,15 @@ void cBlockArea::Merge(const cBlockArea & a_Src, int a_RelX, int a_RelY, int a_R +void cBlockArea::Merge(const cBlockArea & a_Src, const Vector3i & a_RelMinCoords, eMergeStrategy a_Strategy) +{ + Merge(a_Src, a_RelMinCoords.x, a_RelMinCoords.y, a_RelMinCoords.z, a_Strategy); +} + + + + + void cBlockArea::Fill(int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, NIBBLETYPE a_BlockLight, NIBBLETYPE a_BlockSkyLight) { if ((a_DataTypes & GetDataTypes()) != a_DataTypes) @@ -735,6 +797,23 @@ void cBlockArea::FillRelCuboid(int a_MinRelX, int a_MaxRelX, int a_MinRelY, int +void cBlockArea::FillRelCuboid(const cCuboid & a_RelCuboid, + int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, + NIBBLETYPE a_BlockLight, NIBBLETYPE a_BlockSkyLight +) +{ + FillRelCuboid( + a_RelCuboid.p1.x, a_RelCuboid.p2.x, + a_RelCuboid.p1.y, a_RelCuboid.p2.y, + a_RelCuboid.p1.z, a_RelCuboid.p2.z, + a_DataTypes, a_BlockType, a_BlockMeta, a_BlockLight, a_BlockSkyLight + ); +} + + + + + void cBlockArea::RelLine(int a_RelX1, int a_RelY1, int a_RelZ1, int a_RelX2, int a_RelY2, int a_RelZ2, int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, NIBBLETYPE a_BlockLight, NIBBLETYPE a_BlockSkyLight @@ -852,6 +931,22 @@ void cBlockArea::RelLine(int a_RelX1, int a_RelY1, int a_RelZ1, int a_RelX2, int +void cBlockArea::RelLine(const Vector3i & a_Point1, const Vector3i & a_Point2, + int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, + NIBBLETYPE a_BlockLight, NIBBLETYPE a_BlockSkyLight +) +{ + RelLine( + a_Point1.x, a_Point1.y, a_Point1.z, + a_Point2.x, a_Point2.y, a_Point2.z, + a_DataTypes, a_BlockType, a_BlockMeta, a_BlockLight, a_BlockSkyLight + ); +} + + + + + void cBlockArea::RotateCCW(void) { if (!HasBlockTypes()) @@ -878,7 +973,7 @@ void cBlockArea::RotateCCW(void) int NewX = z; for (int y = 0; y < m_SizeY; y++) { - int NewIdx = NewX + NewZ * m_SizeX + y * m_SizeX * m_SizeZ; + int NewIdx = NewX + NewZ * m_SizeZ + y * m_SizeX * m_SizeZ; int OldIdx = MakeIndex(x, y, z); NewTypes[NewIdx] = m_BlockTypes[OldIdx]; NewMetas[NewIdx] = BlockHandler(m_BlockTypes[OldIdx])->MetaRotateCCW(m_BlockMetas[OldIdx]); @@ -923,7 +1018,7 @@ void cBlockArea::RotateCW(void) int NewX = m_SizeZ - z - 1; for (int y = 0; y < m_SizeY; y++) { - int NewIdx = NewX + NewZ * m_SizeX + y * m_SizeX * m_SizeZ; + int NewIdx = NewX + NewZ * m_SizeZ + y * m_SizeX * m_SizeZ; int OldIdx = MakeIndex(x, y, z); NewTypes[NewIdx] = m_BlockTypes[OldIdx]; NewMetas[NewIdx] = BlockHandler(m_BlockTypes[OldIdx])->MetaRotateCW(m_BlockMetas[OldIdx]); @@ -1075,7 +1170,7 @@ void cBlockArea::RotateCCWNoMeta(void) int NewX = z; for (int y = 0; y < m_SizeY; y++) { - NewTypes[NewX + NewZ * m_SizeX + y * m_SizeX * m_SizeZ] = m_BlockTypes[MakeIndex(x, y, z)]; + NewTypes[NewX + NewZ * m_SizeZ + y * m_SizeX * m_SizeZ] = m_BlockTypes[MakeIndex(x, y, z)]; } // for y } // for z } // for x @@ -1093,7 +1188,7 @@ void cBlockArea::RotateCCWNoMeta(void) int NewX = z; for (int y = 0; y < m_SizeY; y++) { - NewMetas[NewX + NewZ * m_SizeX + y * m_SizeX * m_SizeZ] = m_BlockMetas[MakeIndex(x, y, z)]; + NewMetas[NewX + NewZ * m_SizeZ + y * m_SizeX * m_SizeZ] = m_BlockMetas[MakeIndex(x, y, z)]; } // for y } // for z } // for x @@ -1120,7 +1215,7 @@ void cBlockArea::RotateCWNoMeta(void) int NewZ = x; for (int y = 0; y < m_SizeY; y++) { - NewTypes[NewX + NewZ * m_SizeX + y * m_SizeX * m_SizeZ] = m_BlockTypes[MakeIndex(x, y, z)]; + NewTypes[NewX + NewZ * m_SizeZ + y * m_SizeX * m_SizeZ] = m_BlockTypes[MakeIndex(x, y, z)]; } // for y } // for x } // for z @@ -1138,7 +1233,7 @@ void cBlockArea::RotateCWNoMeta(void) int NewZ = x; for (int y = 0; y < m_SizeY; y++) { - NewMetas[NewX + NewZ * m_SizeX + y * m_SizeX * m_SizeZ] = m_BlockMetas[MakeIndex(x, y, z)]; + NewMetas[NewX + NewZ * m_SizeZ + y * m_SizeX * m_SizeZ] = m_BlockMetas[MakeIndex(x, y, z)]; } // for y } // for x } // for z |