summaryrefslogtreecommitdiffstats
path: root/src/World
diff options
context:
space:
mode:
Diffstat (limited to 'src/World')
-rw-r--r--src/World/BlockType.cpp208
-rw-r--r--src/World/BlockType.hpp42
-rw-r--r--src/World/Chunk.cpp5
3 files changed, 252 insertions, 3 deletions
diff --git a/src/World/BlockType.cpp b/src/World/BlockType.cpp
new file mode 100644
index 0000000..a65e3eb
--- /dev/null
+++ b/src/World/BlockType.cpp
@@ -0,0 +1,208 @@
+/*
+ Copyright (c) 2015, Matthias Schiffer <mschiffer@universe-factory.net>
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+
+#include "BlockType.hpp"
+
+
+namespace MinedMap {
+namespace World {
+
+const BlockType BLOCK_TYPES[256] = {
+ /* 0 */ {false, 0},
+ /* 1 */ {true, 8224125},
+ /* 2 */ {true, 9671571},
+ /* 3 */ {true, 8806467},
+ /* 4 */ {true, 8026746},
+ /* 5 */ {true, 10256206},
+ /* 6 */ {true, 4679205},
+ /* 7 */ {true, 5460819},
+ /* 8 */ {true, 3229684},
+ /* 9 */ {true, 3032052},
+ /* 10 */ {true, 13589267},
+ /* 11 */ {true, 13916690},
+ /* 12 */ {true, 14406560},
+ /* 13 */ {true, 8289402},
+ /* 14 */ {true, 9407356},
+ /* 15 */ {true, 8880766},
+ /* 16 */ {true, 7566195},
+ /* 17 */ {true, 10124621},
+ /* 18 */ {true, 8882055},
+ /* 19 */ {true, 11974201},
+ /* 20 */ {true, 14348532},
+ /* 21 */ {true, 6713478},
+ /* 22 */ {true, 2507657},
+ /* 23 */ {true, 6316128},
+ /* 24 */ {true, 14340766},
+ /* 25 */ {true, 6570802},
+ /* 26 */ {true, 9311766},
+ /* 27 */ {true, 8678472},
+ /* 28 */ {true, 7890265},
+ /* 29 */ {true, 6316128},
+ /* 30 */ {true, 14474460},
+ /* 31 */ {false, 0},
+ /* 32 */ {false, 0},
+ /* 33 */ {true, 6316128},
+ /* 34 */ {true, 10060121},
+ /* 35 */ {true, 14540253},
+ /* 36 */ {false, 0},
+ /* 37 */ {false, 0},
+ /* 38 */ {false, 0},
+ /* 39 */ {false, 0},
+ /* 40 */ {false, 0},
+ /* 41 */ {true, 16378958},
+ /* 42 */ {true, 14408667},
+ /* 43 */ {true, 10461087},
+ /* 44 */ {true, 10461087},
+ /* 45 */ {true, 9593686},
+ /* 46 */ {true, 8536367},
+ /* 47 */ {true, 10256206},
+ /* 48 */ {true, 6781287},
+ /* 49 */ {true, 1315357},
+ /* 50 */ {false, 0},
+ /* 51 */ {true, 13863989},
+ /* 52 */ {true, 1713969},
+ /* 53 */ {true, 10256206},
+ /* 54 */ {true, 10256206},
+ /* 55 */ {true, 11213577},
+ /* 56 */ {true, 8490127},
+ /* 57 */ {true, 6413269},
+ /* 58 */ {true, 7030570},
+ /* 59 */ {true, 45842},
+ /* 60 */ {true, 7555885},
+ /* 61 */ {true, 6316128},
+ /* 62 */ {true, 6316128},
+ /* 63 */ {false, 0},
+ /* 64 */ {true, 8807730},
+ /* 65 */ {false, 0},
+ /* 66 */ {true, 7957592},
+ /* 67 */ {true, 8026746},
+ /* 68 */ {false, 0},
+ /* 69 */ {false, 0},
+ /* 70 */ {true, 8224125},
+ /* 71 */ {true, 10724259},
+ /* 72 */ {true, 10256206},
+ /* 73 */ {true, 8678251},
+ /* 74 */ {true, 8678251},
+ /* 75 */ {true, 11213577},
+ /* 76 */ {true, 11213577},
+ /* 77 */ {false, 0},
+ /* 78 */ {true, 15727611},
+ /* 79 */ {true, 8236543},
+ /* 80 */ {true, 15727611},
+ /* 81 */ {true, 877336},
+ /* 82 */ {true, 10396848},
+ /* 83 */ {true, 9748581},
+ /* 84 */ {true, 7031095},
+ /* 85 */ {true, 10256206},
+ /* 86 */ {true, 12613141},
+ /* 87 */ {true, 7288372},
+ /* 88 */ {true, 5521459},
+ /* 89 */ {true, 9401925},
+ /* 90 */ {true, 5704383},
+ /* 91 */ {true, 12613141},
+ /* 92 */ {true, 14994894},
+ /* 93 */ {true, 9933715},
+ /* 94 */ {true, 10523539},
+ /* 95 */ {true, 16777215},
+ /* 96 */ {true, 8281389},
+ /* 97 */ {true, 8224125},
+ /* 98 */ {true, 8026746},
+ /* 99 */ {true, 9267795},
+ /* 100 */ {true, 11937060},
+ /* 101 */ {true, 7171178},
+ /* 102 */ {true, 14348532},
+ /* 103 */ {true, 9935140},
+ /* 104 */ {false, 0},
+ /* 105 */ {false, 0},
+ /* 106 */ {true, 7303023},
+ /* 107 */ {true, 10256206},
+ /* 108 */ {true, 9593686},
+ /* 109 */ {true, 8026746},
+ /* 110 */ {true, 7299945},
+ /* 111 */ {true, 7763574},
+ /* 112 */ {true, 2889242},
+ /* 113 */ {true, 2889242},
+ /* 114 */ {true, 2889242},
+ /* 115 */ {true, 6950430},
+ /* 116 */ {true, 6766651},
+ /* 117 */ {true, 6974058},
+ /* 118 */ {true, 3618615},
+ /* 119 */ {true, 788751},
+ /* 120 */ {true, 5862752},
+ /* 121 */ {true, 14540709},
+ /* 122 */ {true, 788751},
+ /* 123 */ {true, 4598554},
+ /* 124 */ {true, 7821623},
+ /* 125 */ {true, 10256206},
+ /* 126 */ {true, 10256206},
+ /* 127 */ {true, 9079872},
+ /* 128 */ {true, 14340766},
+ /* 129 */ {true, 7176308},
+ /* 130 */ {true, 788751},
+ /* 131 */ {false, 0},
+ /* 132 */ {false, 0},
+ /* 133 */ {true, 5364085},
+ /* 134 */ {true, 6769966},
+ /* 135 */ {true, 12825467},
+ /* 136 */ {true, 10120781},
+ /* 137 */ {true, 11700591},
+ /* 138 */ {true, 7658967},
+ /* 139 */ {true, 8026746},
+ /* 140 */ {true, 7749939},
+ /* 141 */ {true, 109328},
+ /* 142 */ {true, 109328},
+ /* 143 */ {false, 0},
+ /* 144 */ {false, 0},
+ /* 145 */ {true, 4209724},
+ /* 146 */ {true, 10256206},
+ /* 147 */ {true, 16378958},
+ /* 148 */ {true, 14408667},
+ /* 149 */ {true, 10262165},
+ /* 150 */ {true, 10851732},
+ /* 151 */ {true, 8549470},
+ /* 152 */ {true, 11213577},
+ /* 153 */ {true, 8213583},
+ /* 154 */ {true, 3618615},
+ /* 155 */ {true, 15526370},
+ /* 156 */ {true, 15526370},
+ /* 157 */ {true, 6837063},
+ /* 158 */ {true, 6316128},
+ /* 159 */ {true, 13742753},
+ /* 160 */ {true, 16777215},
+ /* 161 */ {true, 8882055},
+ /* 162 */ {true, 10115904},
+ /* 163 */ {true, 11098931},
+ /* 164 */ {true, 4007698},
+ /* 170 */ {true, 11045648},
+ /* 171 */ {true, 14540253},
+ /* 172 */ {true, 9854018},
+ /* 173 */ {true, 1184274},
+ /* 174 */ {true, 10863349},
+ /* 175 */ {false, 0},
+};
+
+}
+}
diff --git a/src/World/BlockType.hpp b/src/World/BlockType.hpp
new file mode 100644
index 0000000..d131487
--- /dev/null
+++ b/src/World/BlockType.hpp
@@ -0,0 +1,42 @@
+/*
+ Copyright (c) 2015, Matthias Schiffer <mschiffer@universe-factory.net>
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+
+#pragma once
+
+#include <cstdint>
+
+namespace MinedMap {
+namespace World {
+
+struct BlockType {
+ bool opaque;
+ uint32_t color;
+};
+
+extern const BlockType BLOCK_TYPES[256];
+
+}
+}
diff --git a/src/World/Chunk.cpp b/src/World/Chunk.cpp
index 2dc9014..99d40a5 100644
--- a/src/World/Chunk.cpp
+++ b/src/World/Chunk.cpp
@@ -25,6 +25,7 @@
#include "Chunk.hpp"
+#include "BlockType.hpp"
#include "../Util.hpp"
#include "../NBT/ByteTag.hpp"
#include "../NBT/ByteArrayTag.hpp"
@@ -143,7 +144,7 @@ Chunk::Blocks Chunk::getTopLayer() const {
continue;
uint8_t block = getBlockAt(*it, x, y, z);
- if (block) {
+ if (BLOCK_TYPES[block].opaque) {
blocks.blocks[x][z].id = block;
blocks.blocks[x][z].data = getDataAt(*it, x, y, z);
done++;
@@ -153,8 +154,6 @@ Chunk::Blocks Chunk::getTopLayer() const {
}
}
- std::cerr << "Done: " << done << std::endl;
-
return blocks;
}