summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-02-09 12:03:22 +0100
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-02-09 12:03:22 +0100
commitbda7c4ac13cf2ad621dee673a430cc43bb9e8e6b (patch)
tree8f7fc8d057e189010917e687840b2ace231d9b58 /source
parentAdded a few ignores (diff)
downloadcuberite-bda7c4ac13cf2ad621dee673a430cc43bb9e8e6b.tar
cuberite-bda7c4ac13cf2ad621dee673a430cc43bb9e8e6b.tar.gz
cuberite-bda7c4ac13cf2ad621dee673a430cc43bb9e8e6b.tar.bz2
cuberite-bda7c4ac13cf2ad621dee673a430cc43bb9e8e6b.tar.lz
cuberite-bda7c4ac13cf2ad621dee673a430cc43bb9e8e6b.tar.xz
cuberite-bda7c4ac13cf2ad621dee673a430cc43bb9e8e6b.tar.zst
cuberite-bda7c4ac13cf2ad621dee673a430cc43bb9e8e6b.zip
Diffstat (limited to 'source')
-rw-r--r--source/Bindings.cpp46
-rw-r--r--source/Bindings.h2
-rw-r--r--source/BlockArea.cpp90
-rw-r--r--source/BlockArea.h7
4 files changed, 143 insertions, 2 deletions
diff --git a/source/Bindings.cpp b/source/Bindings.cpp
index 84d964af7..49e54129d 100644
--- a/source/Bindings.cpp
+++ b/source/Bindings.cpp
@@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
-** Generated automatically by tolua++-1.0.92 on 02/08/13 21:06:19.
+** Generated automatically by tolua++-1.0.92 on 02/09/13 10:54:12.
*/
#ifndef __cplusplus
@@ -18038,6 +18038,49 @@ static int tolua_AllToLua_cBlockArea_Crop00(lua_State* tolua_S)
}
#endif //#ifndef TOLUA_DISABLE
+/* method: Expand of class cBlockArea */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cBlockArea_Expand00
+static int tolua_AllToLua_cBlockArea_Expand00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cBlockArea",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,5,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,6,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,7,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,8,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cBlockArea* self = (cBlockArea*) tolua_tousertype(tolua_S,1,0);
+ int a_SubMinX = ((int) tolua_tonumber(tolua_S,2,0));
+ int a_AddMaxX = ((int) tolua_tonumber(tolua_S,3,0));
+ int a_SubMinY = ((int) tolua_tonumber(tolua_S,4,0));
+ int a_AddMaxY = ((int) tolua_tonumber(tolua_S,5,0));
+ int a_SubMinZ = ((int) tolua_tonumber(tolua_S,6,0));
+ int a_AddMaxZ = ((int) tolua_tonumber(tolua_S,7,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Expand'", NULL);
+#endif
+ {
+ self->Expand(a_SubMinX,a_AddMaxX,a_SubMinY,a_AddMaxY,a_SubMinZ,a_AddMaxZ);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'Expand'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
/* method: SetRelBlockType of class cBlockArea */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cBlockArea_SetRelBlockType00
static int tolua_AllToLua_cBlockArea_SetRelBlockType00(lua_State* tolua_S)
@@ -22168,6 +22211,7 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_function(tolua_S,"LoadFromSchematicFile",tolua_AllToLua_cBlockArea_LoadFromSchematicFile00);
tolua_function(tolua_S,"SaveToSchematicFile",tolua_AllToLua_cBlockArea_SaveToSchematicFile00);
tolua_function(tolua_S,"Crop",tolua_AllToLua_cBlockArea_Crop00);
+ tolua_function(tolua_S,"Expand",tolua_AllToLua_cBlockArea_Expand00);
tolua_function(tolua_S,"SetRelBlockType",tolua_AllToLua_cBlockArea_SetRelBlockType00);
tolua_function(tolua_S,"SetBlockType",tolua_AllToLua_cBlockArea_SetBlockType00);
tolua_function(tolua_S,"SetRelBlockMeta",tolua_AllToLua_cBlockArea_SetRelBlockMeta00);
diff --git a/source/Bindings.h b/source/Bindings.h
index 2d39e3a46..76536279e 100644
--- a/source/Bindings.h
+++ b/source/Bindings.h
@@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
-** Generated automatically by tolua++-1.0.92 on 02/08/13 21:06:20.
+** Generated automatically by tolua++-1.0.92 on 02/09/13 10:54:12.
*/
/* Exported function */
diff --git a/source/BlockArea.cpp b/source/BlockArea.cpp
index a5cefb430..c39819b4f 100644
--- a/source/BlockArea.cpp
+++ b/source/BlockArea.cpp
@@ -357,6 +357,36 @@ void cBlockArea::Crop(int a_AddMinX, int a_SubMaxX, int a_AddMinY, int a_SubMaxY
+void cBlockArea::Expand(int a_SubMinX, int a_AddMaxX, int a_SubMinY, int a_AddMaxY, int a_SubMinZ, int a_AddMaxZ)
+{
+ if (HasBlockTypes())
+ {
+ ExpandBlockTypes(a_SubMinX, a_AddMaxX, a_SubMinY, a_AddMaxY, a_SubMinZ, a_AddMaxZ);
+ }
+ if (HasBlockMetas())
+ {
+ ExpandNibbles(m_BlockMetas, a_SubMinX, a_AddMaxX, a_SubMinY, a_AddMaxY, a_SubMinZ, a_AddMaxZ);
+ }
+ if (HasBlockLights())
+ {
+ ExpandNibbles(m_BlockLight, a_SubMinX, a_AddMaxX, a_SubMinY, a_AddMaxY, a_SubMinZ, a_AddMaxZ);
+ }
+ if (HasBlockSkyLights())
+ {
+ ExpandNibbles(m_BlockSkyLight, a_SubMinX, a_AddMaxX, a_SubMinY, a_AddMaxY, a_SubMinZ, a_AddMaxZ);
+ }
+ m_OriginX -= a_SubMinX;
+ m_OriginY -= a_SubMinY;
+ m_OriginZ -= a_SubMinZ;
+ m_SizeX += a_SubMinX + a_AddMaxX;
+ m_SizeY += a_SubMinY + a_AddMaxY;
+ m_SizeZ += a_SubMinZ + a_AddMaxZ;
+}
+
+
+
+
+
void cBlockArea::SetRelBlockType(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType)
{
if (m_BlockTypes == NULL)
@@ -973,6 +1003,66 @@ void cBlockArea::CropNibbles(NIBBLEARRAY & a_Array, int a_AddMinX, int a_SubMaxX
+void cBlockArea::ExpandBlockTypes(int a_SubMinX, int a_AddMaxX, int a_SubMinY, int a_AddMaxY, int a_SubMinZ, int a_AddMaxZ)
+{
+ int NewSizeX = m_SizeX + a_SubMinX + a_AddMaxX;
+ int NewSizeY = m_SizeY + a_SubMinY + a_AddMaxY;
+ int NewSizeZ = m_SizeZ + a_SubMinZ + a_AddMaxZ;
+ int BlockCount = NewSizeX * NewSizeY * NewSizeZ;
+ BLOCKTYPE * NewBlockTypes = new BLOCKTYPE[BlockCount];
+ memset(NewBlockTypes, 0, BlockCount * sizeof(BLOCKTYPE));
+ int OldIndex = 0;
+ for (int y = 0; y < m_SizeY; y++)
+ {
+ int IndexBaseY = (y + a_SubMinY) * m_SizeX * m_SizeZ;
+ for (int z = 0; z < m_SizeZ; z++)
+ {
+ int IndexBaseZ = IndexBaseY + (z + a_SubMinZ) * m_SizeX;
+ int idx = IndexBaseZ + a_SubMinX;
+ for (int x = 0; x < m_SizeX; x++)
+ {
+ NewBlockTypes[idx++] = m_BlockTypes[OldIndex++];
+ } // for x
+ } // for z
+ } // for y
+ delete m_BlockTypes;
+ m_BlockTypes = NewBlockTypes;
+}
+
+
+
+
+
+void cBlockArea::ExpandNibbles(NIBBLEARRAY & a_Array, int a_SubMinX, int a_AddMaxX, int a_SubMinY, int a_AddMaxY, int a_SubMinZ, int a_AddMaxZ)
+{
+ int NewSizeX = m_SizeX + a_SubMinX + a_AddMaxX;
+ int NewSizeY = m_SizeY + a_SubMinY + a_AddMaxY;
+ int NewSizeZ = m_SizeZ + a_SubMinZ + a_AddMaxZ;
+ int BlockCount = NewSizeX * NewSizeY * NewSizeZ;
+ NIBBLETYPE * NewNibbles = new NIBBLETYPE[BlockCount];
+ memset(NewNibbles, 0, BlockCount * sizeof(NIBBLETYPE));
+ int OldIndex = 0;
+ for (int y = 0; y < m_SizeY; y++)
+ {
+ int IndexBaseY = (y + a_SubMinY) * m_SizeX * m_SizeZ;
+ for (int z = 0; z < m_SizeZ; z++)
+ {
+ int IndexBaseZ = IndexBaseY + (z + a_SubMinZ) * m_SizeX;
+ int idx = IndexBaseZ + a_SubMinX;
+ for (int x = 0; x < m_SizeX; x++)
+ {
+ NewNibbles[idx++] = a_Array[OldIndex++];
+ } // for x
+ } // for z
+ } // for y
+ delete a_Array;
+ a_Array = NewNibbles;
+}
+
+
+
+
+
bool cBlockArea::LoadFromSchematicNBT(cParsedNBT & a_NBT)
{
int TMaterials = a_NBT.FindChildByName(a_NBT.GetRoot(), "Materials");
diff --git a/source/BlockArea.h b/source/BlockArea.h
index e01eade69..b1a2d9053 100644
--- a/source/BlockArea.h
+++ b/source/BlockArea.h
@@ -77,6 +77,9 @@ public:
/// Crops the internal contents by the specified amount of blocks from each border.
void Crop(int a_AddMinX, int a_SubMaxX, int a_AddMinY, int a_SubMaxY, int a_AddMinZ, int a_SubMaxZ);
+ /// Expands the internal contents by the specified amount of blocks from each border
+ void Expand(int a_SubMinX, int a_AddMaxX, int a_SubMinY, int a_AddMaxY, int a_SubMinZ, int a_AddMaxZ);
+
// Setters:
void SetRelBlockType (int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType);
void SetBlockType (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType);
@@ -186,6 +189,10 @@ protected:
void CropBlockTypes(int a_AddMinX, int a_SubMaxX, int a_AddMinY, int a_SubMaxY, int a_AddMinZ, int a_SubMaxZ);
void CropNibbles (NIBBLEARRAY & a_Array, int a_AddMinX, int a_SubMaxX, int a_AddMinY, int a_SubMaxY, int a_AddMinZ, int a_SubMaxZ);
+ // Expand helpers:
+ void ExpandBlockTypes(int a_SubMinX, int a_AddMaxX, int a_SubMinY, int a_AddMaxY, int a_SubMinZ, int a_AddMaxZ);
+ void ExpandNibbles (NIBBLEARRAY & a_Array, int a_SubMinX, int a_AddMaxX, int a_SubMinY, int a_AddMaxY, int a_SubMinZ, int a_AddMaxZ);
+
/// Loads the area from a schematic file uncompressed and parsed into a NBT tree. Returns true if successful.
bool LoadFromSchematicNBT(cParsedNBT & a_NBT);