add block size check to ContentLoader
This commit is contained in:
parent
45a793d647
commit
b984e363ea
@ -241,17 +241,22 @@ void ContentLoader::loadBlock(
|
|||||||
// block light emission [r, g, b] where r,g,b in range [0..15]
|
// block light emission [r, g, b] where r,g,b in range [0..15]
|
||||||
if (auto found = root.at("emission")) {
|
if (auto found = root.at("emission")) {
|
||||||
const auto& emissionarr = *found;
|
const auto& emissionarr = *found;
|
||||||
def.emission[0] = emissionarr[0].asNumber();
|
def.emission[0] = emissionarr[0].asInteger();
|
||||||
def.emission[1] = emissionarr[1].asNumber();
|
def.emission[1] = emissionarr[1].asInteger();
|
||||||
def.emission[2] = emissionarr[2].asNumber();
|
def.emission[2] = emissionarr[2].asInteger();
|
||||||
}
|
}
|
||||||
|
|
||||||
// block size
|
// block size
|
||||||
if (auto found = root.at("size")) {
|
if (auto found = root.at("size")) {
|
||||||
const auto& sizearr = *found;
|
const auto& sizearr = *found;
|
||||||
def.size.x = sizearr[0].asNumber();
|
def.size.x = sizearr[0].asInteger();
|
||||||
def.size.y = sizearr[1].asNumber();
|
def.size.y = sizearr[1].asInteger();
|
||||||
def.size.z = sizearr[2].asNumber();
|
def.size.z = sizearr[2].asInteger();
|
||||||
|
if (def.size.x < 1 || def.size.y < 1 || def.size.z < 1) {
|
||||||
|
throw std::runtime_error(
|
||||||
|
"block " + util::quote(def.name) + ": invalid block size"
|
||||||
|
);
|
||||||
|
}
|
||||||
if (def.model == BlockModel::block &&
|
if (def.model == BlockModel::block &&
|
||||||
(def.size.x != 1 || def.size.y != 1 || def.size.z != 1)) {
|
(def.size.x != 1 || def.size.y != 1 || def.size.z != 1)) {
|
||||||
def.model = BlockModel::aabb;
|
def.model = BlockModel::aabb;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user