Add some checks

master
Marc Gilleron 2020-08-17 22:27:52 +01:00
parent 464bb734ba
commit 07e91d4892
2 changed files with 6 additions and 3 deletions

View File

@ -196,6 +196,8 @@ void VoxelLibrary::generate_side_culling_matrix() {
std::vector<Pattern> patterns;
uint32_t full_side_pattern_index = NULL_INDEX;
CRASH_COND(_voxel_types.size() != _baked_data.models.size());
// Gather patterns
for (uint16_t type_id = 0; type_id < _voxel_types.size(); ++type_id) {
if (_voxel_types[type_id].is_null()) {

View File

@ -120,10 +120,11 @@ VoxelBuffer::~VoxelBuffer() {
}
void VoxelBuffer::create(int sx, int sy, int sz) {
if (sx <= 0 || sy <= 0 || sz <= 0) {
return;
}
ERR_FAIL_COND(sx <= 0 || sy <= 0 || sz <= 0);
ERR_FAIL_COND(sx > MAX_SIZE || sy > MAX_SIZE || sz > MAX_SIZE);
clear_voxel_metadata();
Vector3i new_size(sx, sy, sz);
if (new_size != _size) {
for (unsigned int i = 0; i < MAX_CHANNELS; ++i) {