void cBlockArea::DumpToRawFile(const AString & a_FileName) { cFile f; if (!f.Open(a_FileName, cFile::fmWrite)) { LOGWARNING("cBlockArea: Cannot open file \"%s\" for raw dump", a_FileName.c_str()); return; } UInt32 SizeX = ntohl(m_SizeX); UInt32 SizeY = ntohl(m_SizeY); UInt32 SizeZ = ntohl(m_SizeZ); f.Write(&SizeX, 4); f.Write(&SizeY, 4); f.Write(&SizeZ, 4); unsigned char DataTypes = GetDataTypes(); f.Write(&DataTypes, 1); int NumBlocks = GetBlockCount(); if (HasBlockTypes()) { f.Write(m_BlockTypes, NumBlocks * sizeof(BLOCKTYPE)); } if (HasBlockMetas()) { f.Write(m_BlockMetas, NumBlocks); } if (HasBlockLights()) { f.Write(m_BlockLight, NumBlocks); } if (HasBlockSkyLights()) { f.Write(m_BlockSkyLight, NumBlocks); } }
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::CopyTo(cBlockArea & a_Into) const { if (&a_Into == this) { LOGWARNING("Trying to copy a cBlockArea into self, ignoring."); return; } a_Into.Clear(); a_Into.SetSize(m_SizeX, m_SizeY, m_SizeZ, GetDataTypes()); a_Into.m_OriginX = m_OriginX; a_Into.m_OriginY = m_OriginY; a_Into.m_OriginZ = m_OriginZ; int BlockCount = GetBlockCount(); if (HasBlockTypes()) { memcpy(a_Into.m_BlockTypes, m_BlockTypes, BlockCount * sizeof(BLOCKTYPE)); } if (HasBlockMetas()) { memcpy(a_Into.m_BlockMetas, m_BlockMetas, BlockCount * sizeof(NIBBLETYPE)); } if (HasBlockLights()) { memcpy(a_Into.m_BlockLight, m_BlockLight, BlockCount * sizeof(NIBBLETYPE)); } if (HasBlockSkyLights()) { memcpy(a_Into.m_BlockSkyLight, m_BlockSkyLight, BlockCount * sizeof(NIBBLETYPE)); } }
void cBlockArea::Crop(int a_AddMinX, int a_SubMaxX, int a_AddMinY, int a_SubMaxY, int a_AddMinZ, int a_SubMaxZ) { if ( (a_AddMinX + a_SubMaxX >= m_SizeX) || (a_AddMinY + a_SubMaxY >= m_SizeY) || (a_AddMinZ + a_SubMaxZ >= m_SizeZ) ) { LOGWARNING("cBlockArea:Crop called with more croping than the dimensions: %d x %d x %d with cropping %d, %d and %d", m_SizeX, m_SizeY, m_SizeZ, a_AddMinX + a_SubMaxX, a_AddMinY + a_SubMaxY, a_AddMinZ + a_SubMaxZ ); return; } if (HasBlockTypes()) { CropBlockTypes(a_AddMinX, a_SubMaxX, a_AddMinY, a_SubMaxY, a_AddMinZ, a_SubMaxZ); } if (HasBlockMetas()) { CropNibbles(m_BlockMetas, a_AddMinX, a_SubMaxX, a_AddMinY, a_SubMaxY, a_AddMinZ, a_SubMaxZ); } if (HasBlockLights()) { CropNibbles(m_BlockLight, a_AddMinX, a_SubMaxX, a_AddMinY, a_SubMaxY, a_AddMinZ, a_SubMaxZ); } if (HasBlockSkyLights()) { CropNibbles(m_BlockSkyLight, a_AddMinX, a_SubMaxX, a_AddMinY, a_SubMaxY, a_AddMinZ, a_SubMaxZ); } m_OriginX += a_AddMinX; m_OriginY += a_AddMinY; m_OriginZ += a_AddMinZ; m_SizeX -= a_AddMinX + a_SubMaxX; m_SizeY -= a_AddMinY + a_SubMaxY; m_SizeZ -= a_AddMinZ + a_SubMaxZ; }
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_Origin.Move(-a_SubMinX, -a_SubMinY, -a_SubMinZ); m_Size.x += a_SubMinX + a_AddMaxX; m_Size.y += a_SubMinY + a_AddMaxY; m_Size.z += a_SubMinZ + a_AddMaxZ; }