summaryrefslogtreecommitdiffstats
path: root/src/ChunkData.h
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@outlook.com>2021-03-06 13:59:39 +0100
committerGitHub <noreply@github.com>2021-03-06 13:59:39 +0100
commitd9a2b8611c86252a0d080ead7d17095a54489b2d (patch)
tree372a0d91bbe655a7db98df8e40225632fe46416e /src/ChunkData.h
parentUpdate Core (diff)
downloadcuberite-d9a2b8611c86252a0d080ead7d17095a54489b2d.tar
cuberite-d9a2b8611c86252a0d080ead7d17095a54489b2d.tar.gz
cuberite-d9a2b8611c86252a0d080ead7d17095a54489b2d.tar.bz2
cuberite-d9a2b8611c86252a0d080ead7d17095a54489b2d.tar.lz
cuberite-d9a2b8611c86252a0d080ead7d17095a54489b2d.tar.xz
cuberite-d9a2b8611c86252a0d080ead7d17095a54489b2d.tar.zst
cuberite-d9a2b8611c86252a0d080ead7d17095a54489b2d.zip
Diffstat (limited to '')
-rw-r--r--src/ChunkData.h45
1 files changed, 18 insertions, 27 deletions
diff --git a/src/ChunkData.h b/src/ChunkData.h
index a984b752e..69ae1d5b8 100644
--- a/src/ChunkData.h
+++ b/src/ChunkData.h
@@ -130,33 +130,24 @@ public:
-namespace ChunkDef
-{
- using cForEachSectionCallback = cFunctionRef<void(
- size_t,
- ChunkBlockData::BlockArray *,
- ChunkBlockData::MetaArray *,
- ChunkLightData::LightArray *,
- ChunkLightData::LightArray *)>;
-
- /** Invokes the callback functor for every chunk section containing at least one present block or light section data.
- This is used to collect all data for all sections. */
- inline void ForEachSection(const ChunkBlockData & a_BlockData, const ChunkLightData & a_LightData, cForEachSectionCallback a_Callback)
- {
- for (size_t Y = 0; Y < cChunkDef::NumSections; ++Y)
- {
- const auto Blocks = a_BlockData.GetSection(Y);
- const auto Metas = a_BlockData.GetMetaSection(Y);
- const auto BlockLights = a_LightData.GetBlockLightSection(Y);
- const auto SkyLights = a_LightData.GetSkyLightSection(Y);
-
- if ((Blocks != nullptr) || (Metas != nullptr) || (BlockLights != nullptr) || (SkyLights != nullptr))
- {
- a_Callback(Y, Blocks, Metas, BlockLights, SkyLights);
- }
- }
- }
-}
+/** Invokes the callback functor for every chunk section containing at least one present block or light section data.
+This is used to collect all data for all sections.
+In macro form to work around a Visual Studio 2017 ICE bug. */
+#define ChunkDef_ForEachSection(BlockData, LightData, Callback) \
+ do \
+ { \
+ for (size_t Y = 0; Y < cChunkDef::NumSections; ++Y) \
+ { \
+ const auto Blocks = BlockData.GetSection(Y); \
+ const auto Metas = BlockData.GetMetaSection(Y); \
+ const auto BlockLights = LightData.GetBlockLightSection(Y); \
+ const auto SkyLights = LightData.GetSkyLightSection(Y); \
+ if ((Blocks != nullptr) || (Metas != nullptr) || (BlockLights != nullptr) || (SkyLights != nullptr)) \
+ { \
+ Callback \
+ } \
+ } \
+ } while (false)