From 0a5a72b8fe80ee8c60a968275a67eb24c04ef395 Mon Sep 17 00:00:00 2001 From: tylermurphy534 Date: Thu, 29 Sep 2022 11:14:22 -0400 Subject: [PATCH] fix possible run condition --- src/chunk.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/chunk.cpp b/src/chunk.cpp index 41f8014..cc99b24 100644 --- a/src/chunk.cpp +++ b/src/chunk.cpp @@ -232,6 +232,7 @@ xe::Model* Chunk::getMesh() { } uint8_t Chunk::getBlock(int32_t x, int32_t y, int32_t z) { + if(!generated) return INVALID; if(y > 256) return AIR; if(y < 0) return INVALID; int chunkX = gridX; @@ -263,6 +264,7 @@ uint8_t Chunk::getBlock(int32_t x, int32_t y, int32_t z) { } void Chunk::setBlock(int32_t x, int32_t y, int32_t z, uint8_t block) { + if(!generated) return; int index = x + (z * 16) + (y * 256); cubes[index] = block; }