summaryrefslogtreecommitdiffstats
path: root/src/BlockArea.cpp
diff options
context:
space:
mode:
authorpeterbell10 <peterbell10@live.co.uk>2018-02-05 00:07:12 +0100
committerGitHub <noreply@github.com>2018-02-05 00:07:12 +0100
commitd3c1c626f569e5aa58085425924cca45927b6199 (patch)
treec65dee850358467c9afebdd37fcd4f6fb95a475a /src/BlockArea.cpp
parentcChunk and cChunkData: Use vectors for block get and set functions (#4172) (diff)
downloadcuberite-d3c1c626f569e5aa58085425924cca45927b6199.tar
cuberite-d3c1c626f569e5aa58085425924cca45927b6199.tar.gz
cuberite-d3c1c626f569e5aa58085425924cca45927b6199.tar.bz2
cuberite-d3c1c626f569e5aa58085425924cca45927b6199.tar.lz
cuberite-d3c1c626f569e5aa58085425924cca45927b6199.tar.xz
cuberite-d3c1c626f569e5aa58085425924cca45927b6199.tar.zst
cuberite-d3c1c626f569e5aa58085425924cca45927b6199.zip
Diffstat (limited to 'src/BlockArea.cpp')
-rw-r--r--src/BlockArea.cpp241
1 files changed, 118 insertions, 123 deletions
diff --git a/src/BlockArea.cpp b/src/BlockArea.cpp
index bd9ba3a9f..9dce7e916 100644
--- a/src/BlockArea.cpp
+++ b/src/BlockArea.cpp
@@ -2458,129 +2458,124 @@ void cBlockArea::MergeByStrategy(const cBlockArea & a_Src, int a_RelX, int a_Rel
int DstOffZ = std::max(0, a_RelZ); // Offset in Dst where to start writing
int SizeZ = std::min(a_Src.GetSizeZ() - SrcOffZ, GetSizeZ() - DstOffZ); // How many blocks to copy
- switch (a_Strategy)
- {
- case cBlockArea::msOverwrite:
- {
- InternalMergeBlocks<MetasValid, MergeCombinatorOverwrite<MetasValid> >(
- GetBlockTypes(), 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
- );
- break;
- } // case msOverwrite
-
- case cBlockArea::msFillAir:
- {
- InternalMergeBlocks<MetasValid, MergeCombinatorFillAir<MetasValid> >(
- GetBlockTypes(), 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
- );
- break;
- } // case msFillAir
-
- case cBlockArea::msImprint:
- {
- InternalMergeBlocks<MetasValid, MergeCombinatorImprint<MetasValid> >(
- GetBlockTypes(), 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
- );
- break;
- } // case msImprint
-
- case cBlockArea::msLake:
- {
- InternalMergeBlocks<MetasValid, MergeCombinatorLake<MetasValid> >(
- GetBlockTypes(), 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
- );
- break;
- } // case msLake
-
- case cBlockArea::msSpongePrint:
- {
- InternalMergeBlocks<MetasValid, MergeCombinatorSpongePrint<MetasValid> >(
- GetBlockTypes(), 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
- );
- break;
- } // case msSpongePrint
-
- case cBlockArea::msDifference:
- {
- InternalMergeBlocks<MetasValid, MergeCombinatorDifference<MetasValid> >(
- GetBlockTypes(), 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
- );
- break;
- } // case msDifference
-
- case cBlockArea::msSimpleCompare:
- {
- InternalMergeBlocks<MetasValid, MergeCombinatorSimpleCompare<MetasValid> >(
- GetBlockTypes(), 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
- );
- break;
- } // case msSimpleCompare
-
- case cBlockArea::msMask:
- {
- InternalMergeBlocks<MetasValid, MergeCombinatorMask<MetasValid> >(
- GetBlockTypes(), 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
- );
- break;
- } // case msMask
-
- #ifndef __clang__ // Clang complains about a default case in a switch with all cases covered
- default:
- {
- LOGWARNING("Unknown block area merge strategy: %d", a_Strategy);
- ASSERT(!"Unknown block area merge strategy");
- return;
- }
- #endif
- } // switch (a_Strategy)
+ [&]
+ {
+ switch (a_Strategy)
+ {
+ case cBlockArea::msOverwrite:
+ {
+ InternalMergeBlocks<MetasValid, MergeCombinatorOverwrite<MetasValid> >(
+ GetBlockTypes(), 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 msOverwrite
+
+ case cBlockArea::msFillAir:
+ {
+ InternalMergeBlocks<MetasValid, MergeCombinatorFillAir<MetasValid> >(
+ GetBlockTypes(), 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 msFillAir
+
+ case cBlockArea::msImprint:
+ {
+ InternalMergeBlocks<MetasValid, MergeCombinatorImprint<MetasValid> >(
+ GetBlockTypes(), 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 msImprint
+
+ case cBlockArea::msLake:
+ {
+ InternalMergeBlocks<MetasValid, MergeCombinatorLake<MetasValid> >(
+ GetBlockTypes(), 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 msLake
+
+ case cBlockArea::msSpongePrint:
+ {
+ InternalMergeBlocks<MetasValid, MergeCombinatorSpongePrint<MetasValid> >(
+ GetBlockTypes(), 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 msSpongePrint
+
+ case cBlockArea::msDifference:
+ {
+ InternalMergeBlocks<MetasValid, MergeCombinatorDifference<MetasValid> >(
+ GetBlockTypes(), 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 msDifference
+
+ case cBlockArea::msSimpleCompare:
+ {
+ InternalMergeBlocks<MetasValid, MergeCombinatorSimpleCompare<MetasValid> >(
+ GetBlockTypes(), 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> >(
+ GetBlockTypes(), 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 msMask
+ } // switch (a_Strategy)
+ UNREACHABLE("Unsupported block area merge strategy");
+ }();
if (HasBlockEntities())
{