diff options
author | Mattes D <github@xoft.cz> | 2015-04-29 15:45:48 +0200 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2015-04-29 15:45:48 +0200 |
commit | ca90f6d280487568b0c02d75e9e92d9335c1e43f (patch) | |
tree | 541a8923a8d031a84f304eb446663f882a9283f8 /src/BlockArea.cpp | |
parent | Added cBlockArea:GetNonAirCropRelCoords() API function. (diff) | |
download | cuberite-ca90f6d280487568b0c02d75e9e92d9335c1e43f.tar cuberite-ca90f6d280487568b0c02d75e9e92d9335c1e43f.tar.gz cuberite-ca90f6d280487568b0c02d75e9e92d9335c1e43f.tar.bz2 cuberite-ca90f6d280487568b0c02d75e9e92d9335c1e43f.tar.lz cuberite-ca90f6d280487568b0c02d75e9e92d9335c1e43f.tar.xz cuberite-ca90f6d280487568b0c02d75e9e92d9335c1e43f.tar.zst cuberite-ca90f6d280487568b0c02d75e9e92d9335c1e43f.zip |
Diffstat (limited to 'src/BlockArea.cpp')
-rw-r--r-- | src/BlockArea.cpp | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/src/BlockArea.cpp b/src/BlockArea.cpp index 7526e1c32..600940d96 100644 --- a/src/BlockArea.cpp +++ b/src/BlockArea.cpp @@ -245,6 +245,26 @@ void MergeCombinatorDifference(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBL +/** Combinator used for cBlockArea::msSimpleCompare merging */ +template <bool MetaValid> +void MergeCombinatorSimpleCompare(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta) +{ + if ((a_DstType == a_SrcType) && (!MetaValid || (a_DstMeta == a_SrcMeta))) + { + // The blocktypes are the same, and the blockmetas are not present or are the same + a_DstType = E_BLOCK_AIR; + } + else + { + // The blocktypes or blockmetas differ + a_DstType = E_BLOCK_STONE; + } +} + + + + + /** Combinator used for cBlockArea::msMask merging */ template <bool MetaValid> void MergeCombinatorMask(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE & a_DstMeta, NIBBLETYPE a_SrcMeta) @@ -2188,10 +2208,12 @@ void cBlockArea::RelSetData( + + template <bool MetasValid> void cBlockArea::MergeByStrategy(const cBlockArea & a_Src, int a_RelX, int a_RelY, int a_RelZ, eMergeStrategy a_Strategy, const NIBBLETYPE * SrcMetas, NIBBLETYPE * DstMetas) { - // Block types are compulsory, block metas are voluntary + // Block types are compulsory, block metas are optional if (!HasBlockTypes() || !a_Src.HasBlockTypes()) { LOGWARNING("%s: cannot merge because one of the areas doesn't have blocktypes.", __FUNCTION__); @@ -2297,6 +2319,20 @@ void cBlockArea::MergeByStrategy(const cBlockArea & a_Src, int a_RelX, int a_Rel return; } // case msDifference + case cBlockArea::msSimpleCompare: + { + InternalMergeBlocks<MetasValid, MergeCombinatorSimpleCompare<MetasValid> >( + m_BlockTypes, a_Src.GetBlockTypes(), + DstMetas, SrcMetas, + SizeX, SizeY, SizeZ, + SrcOffX, SrcOffY, SrcOffZ, + DstOffX, DstOffY, DstOffZ, + a_Src.GetSizeX(), a_Src.GetSizeY(), a_Src.GetSizeZ(), + m_Size.x, m_Size.y, m_Size.z + ); + return; + } // case msSimpleCompare + case cBlockArea::msMask: { InternalMergeBlocks<MetasValid, MergeCombinatorMask<MetasValid> >( |