MCPcopy Create free account
hub / github.com/cuberite/cuberite / CopyNibbles

Method CopyNibbles

src/BlockArea.cpp:1835–1895  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1833
1834
1835void cBlockArea::cChunkReader::CopyNibbles(NIBBLETYPE * a_AreaDst, const NIBBLETYPE * a_ChunkSrc)
1836{
1837 int SizeY = m_Area.m_Size.y;
1838 int MinY = m_Origin.y;
1839
1840 // SizeX, SizeZ are the dmensions of the block data to copy from the current chunk (size of the geometric union)
1841 // OffX, OffZ are the offsets of the current chunk data from the area origin
1842 // BaseX, BaseZ are the offsets of the area data within the current chunk from the chunk borders
1843 int SizeX = cChunkDef::Width;
1844 int SizeZ = cChunkDef::Width;
1845 int OffX, OffZ;
1846 int BaseX, BaseZ;
1847 OffX = m_CurrentChunkX * cChunkDef::Width - m_Origin.x;
1848 if (OffX < 0)
1849 {
1850 BaseX = -OffX;
1851 SizeX += OffX; // SizeX is decreased, OffX is negative
1852 OffX = 0;
1853 }
1854 else
1855 {
1856 BaseX = 0;
1857 }
1858 OffZ = m_CurrentChunkZ * cChunkDef::Width - m_Origin.z;
1859 if (OffZ < 0)
1860 {
1861 BaseZ = -OffZ;
1862 SizeZ += OffZ; // SizeZ is decreased, OffZ is negative
1863 OffZ = 0;
1864 }
1865 else
1866 {
1867 BaseZ = 0;
1868 }
1869 // If the chunk extends beyond the area in the X or Z axis, cut off the Size:
1870 if ((m_CurrentChunkX + 1) * cChunkDef::Width > m_Origin.x + m_Area.m_Size.x)
1871 {
1872 SizeX -= (m_CurrentChunkX + 1) * cChunkDef::Width - (m_Origin.x + m_Area.m_Size.x);
1873 }
1874 if ((m_CurrentChunkZ + 1) * cChunkDef::Width > m_Origin.z + m_Area.m_Size.z)
1875 {
1876 SizeZ -= (m_CurrentChunkZ + 1) * cChunkDef::Width - (m_Origin.z + m_Area.m_Size.z);
1877 }
1878
1879 for (int y = 0; y < SizeY; y++)
1880 {
1881 int ChunkY = MinY + y;
1882 int AreaY = y;
1883 for (int z = 0; z < SizeZ; z++)
1884 {
1885 int ChunkZ = BaseZ + z;
1886 int AreaZ = OffZ + z;
1887 for (int x = 0; x < SizeX; x++)
1888 {
1889 int ChunkX = BaseX + x;
1890 int AreaX = OffX + x;
1891 a_AreaDst[m_Area.MakeIndex(AreaX, AreaY, AreaZ)] = cChunkDef::GetNibble(a_ChunkSrc, ChunkX, ChunkY, ChunkZ);
1892 } // for x

Callers

nothing calls this directly

Calls 1

MakeIndexMethod · 0.45

Tested by

no test coverage detected